-
Notifications
You must be signed in to change notification settings - Fork 5.5k
17478 components pencil spaces #17524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
components/pencil_spaces/actions/create-space/create-space.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import { VISIBILITY_OPTIONS } from "../../common/constants.mjs"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import pencilSpaces from "../../pencil_spaces.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "pencil_spaces-create-space", | ||
| name: "Create A Space", | ||
| description: "Create a new space in Pencil Spaces. [See the documentation](https://api.pencilspaces.com/reference#tag/spaces/POST/spaces/create)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| pencilSpaces, | ||
| title: { | ||
| type: "string", | ||
| label: "Title", | ||
| description: "The title of the Space. If not provided and `Space To Clone Id` is set, the existing Space name will be used. If not, a random Space name will be generated.", | ||
| optional: true, | ||
| }, | ||
| spaceToCloneId: { | ||
| propDefinition: [ | ||
| pencilSpaces, | ||
| "spaceToCloneId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| ownerId: { | ||
| propDefinition: [ | ||
| pencilSpaces, | ||
| "ownerId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| hostIds: { | ||
| propDefinition: [ | ||
| pencilSpaces, | ||
| "ownerId", | ||
| ], | ||
| type: "string[]", | ||
| label: "Host Ids", | ||
| description: "The hosts you wish to invite to the Space. The user associated with your API key will always be added as a host.", | ||
| optional: true, | ||
| }, | ||
| participantIds: { | ||
| propDefinition: [ | ||
| pencilSpaces, | ||
| "ownerId", | ||
| ], | ||
| type: "string[]", | ||
| label: "Participant Ids", | ||
| description: "The participants you wish to invite to the Space.", | ||
| optional: true, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| visibility: { | ||
| type: "string", | ||
| label: "Visibility", | ||
| description: "The visibility of the Space.", | ||
| options: VISIBILITY_OPTIONS, | ||
| optional: true, | ||
| }, | ||
| notifyInvitees: { | ||
| type: "boolean", | ||
| label: "Notify Invitees", | ||
| description: "Whether you want to automatically notify invitees when you create your Space.", | ||
| }, | ||
| siteId: { | ||
| propDefinition: [ | ||
| pencilSpaces, | ||
| "siteId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.pencilSpaces.createSpace({ | ||
| $, | ||
| data: { | ||
| title: this.title, | ||
| spaceToCloneId: this.spaceToCloneId, | ||
| ownerId: { | ||
| userId: this.ownerId, | ||
| }, | ||
| hostIds: parseObject(this.hostIds)?.map((hostId) => ({ | ||
| userId: hostId, | ||
| })), | ||
| participantIds: parseObject(this.participantIds)?.map((participantId) => ({ | ||
| userId: participantId, | ||
| })), | ||
| visibility: this.visibility, | ||
| notifyInvitees: this.notifyInvitees, | ||
| siteId: this.siteId, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully created space with ID: "${response.spaceId}"`); | ||
| return response; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| export const VISIBILITY_OPTIONS = [ | ||
| { | ||
| label: "Public", | ||
| value: "public", | ||
| }, | ||
| { | ||
| label: "Private", | ||
| value: "private", | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| export const parseObject = (obj) => { | ||
| if (!obj) return undefined; | ||
|
|
||
| if (Array.isArray(obj)) { | ||
| return obj.map((item) => { | ||
| if (typeof item === "string") { | ||
| try { | ||
| return JSON.parse(item); | ||
| } catch (e) { | ||
| return item; | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
| return obj; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/pencil_spaces", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Pencil Spaces Components", | ||
| "main": "pencil_spaces.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.1.0" | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,107 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "pencil_spaces", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| spaceToCloneId: { | ||
| type: "string", | ||
| label: "Space To Clone Id", | ||
| description: "The space ID of the Space you want to clone. You may only clone Spaces that are templates, Spaces for which you are a host, and Spaces which you can access as an admin due to your institution settings.", | ||
| async options({ page }) { | ||
| const { results } = await this.listSpaces({ | ||
| params: { | ||
| pageNumber: page + 1, | ||
| }, | ||
| }); | ||
|
|
||
| return results.map(({ | ||
| spaceId: value, title: label, | ||
| }) => ({ | ||
| label, | ||
| value, | ||
| })); | ||
| }, | ||
| }, | ||
| ownerId: { | ||
| type: "string", | ||
| label: "Owner Id", | ||
| description: "The ID of the user who will be the owner of the space. If not provided, the current user will be the owner.", | ||
| async options({ page }) { | ||
| const { results } = await this.listUsers({ | ||
| params: { | ||
| pageNumber: page + 1, | ||
| }, | ||
| }); | ||
|
|
||
| return results.map(({ | ||
| userId: value, email: label, | ||
| }) => ({ | ||
| label, | ||
| value, | ||
| })); | ||
| }, | ||
| }, | ||
| siteId: { | ||
| type: "string", | ||
| label: "Site Id", | ||
| description: "The ID of the site you want to create the Space in.", | ||
| async options() { | ||
| const { results } = await this.listSites(); | ||
|
|
||
| return results.map(({ | ||
| id: value, name: label, | ||
| }) => ({ | ||
| label, | ||
| value, | ||
| })); | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return this.$auth.api_url; | ||
| }, | ||
| _headers(headers = {}) { | ||
| return { | ||
| ...headers, | ||
| "Authorization": `Bearer ${this.$auth.api_key}`, | ||
| "Content-Type": "application/json", | ||
| }; | ||
| }, | ||
| async _makeRequest({ | ||
| $ = this, path, headers, ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: `${this._baseUrl()}${path}`, | ||
| headers: this._headers(headers), | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listSpaces(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "spaces", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listUsers(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "users", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listSites(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "sites", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| createSpace(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "spaces/create", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.