From ce9fef1d12f6ef79396fb633e56cfbc87d67684e Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 11 Nov 2024 15:23:08 -0500 Subject: [PATCH 1/4] init --- .../actions/create-mural/create-mural.mjs | 34 ++++++ .../actions/create-sticky/create-sticky.mjs | 50 +++++++++ components/mural/mural.app.mjs | 106 +++++++++++++++++- .../mural/sources/new-area/new-area.mjs | 46 ++++++++ .../mural/sources/new-mural/new-mural.mjs | 64 +++++++++++ .../mural/sources/new-sticky/new-sticky.mjs | 71 ++++++++++++ 6 files changed, 366 insertions(+), 5 deletions(-) create mode 100644 components/mural/actions/create-mural/create-mural.mjs create mode 100644 components/mural/actions/create-sticky/create-sticky.mjs create mode 100644 components/mural/sources/new-area/new-area.mjs create mode 100644 components/mural/sources/new-mural/new-mural.mjs create mode 100644 components/mural/sources/new-sticky/new-sticky.mjs diff --git a/components/mural/actions/create-mural/create-mural.mjs b/components/mural/actions/create-mural/create-mural.mjs new file mode 100644 index 0000000000000..c046c859f4db7 --- /dev/null +++ b/components/mural/actions/create-mural/create-mural.mjs @@ -0,0 +1,34 @@ +import mural from "../../mural.app.mjs"; + +export default { + key: "mural-create-mural", + name: "Create Mural", + description: "Create a new mural within a specified workspace.", + version: "0.0.{{ts}}", + type: "action", + props: { + mural, + workspaceId: mural.propDefinitions.workspaceId, + name: mural.propDefinitions.name, + description: { + ...mural.propDefinitions.description, + optional: true, + }, + templateId: { + ...mural.propDefinitions.templateId, + optional: true, + }, + }, + async run({ $ }) { + const response = await this.mural.createMural({ + data: { + workspaceId: this.workspaceId, + name: this.name, + description: this.description, + templateId: this.templateId, + }, + }); + $.export("$summary", `Successfully created mural ${this.name}`); + return response; + }, +}; diff --git a/components/mural/actions/create-sticky/create-sticky.mjs b/components/mural/actions/create-sticky/create-sticky.mjs new file mode 100644 index 0000000000000..4285e7d939f88 --- /dev/null +++ b/components/mural/actions/create-sticky/create-sticky.mjs @@ -0,0 +1,50 @@ +import mural from "../../mural.app.mjs"; + +export default { + key: "mural-create-sticky", + name: "Create Sticky", + description: "Create a new sticky note within a given mural. [See the documentation](https://developers.mural.co/public/docs/mural-api)", + version: "0.0.{{ts}}", + type: "action", + props: { + mural, + muralId: { + propDefinition: [ + mural, + "muralId", + ], + }, + content: { + propDefinition: [ + mural, + "stickyContent", + ], + }, + color: { + propDefinition: [ + mural, + "color", + ], + optional: true, + }, + position: { + propDefinition: [ + mural, + "position", + ], + optional: true, + }, + }, + async run({ $ }) { + const response = await this.mural.createSticky({ + data: { + muralId: this.muralId, + content: this.content, + color: this.color, + position: this.position, + }, + }); + $.export("$summary", `Successfully created sticky note with ID: ${response.id}`); + return response; + }, +}; diff --git a/components/mural/mural.app.mjs b/components/mural/mural.app.mjs index c4859e6998b0d..d3aa065648b1b 100644 --- a/components/mural/mural.app.mjs +++ b/components/mural/mural.app.mjs @@ -1,11 +1,107 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "mural", - propDefinitions: {}, + propDefinitions: { + muralId: { + type: "string", + label: "Mural ID", + description: "The ID of the Mural.", + required: true, + }, + stickyId: { + type: "string", + label: "Sticky ID", + description: "The ID of the Sticky Note.", + required: true, + }, + stickyContent: { + type: "string", + label: "Sticky Content", + description: "The content of the Sticky Note.", + optional: true, + }, + userId: { + type: "string", + label: "User ID", + description: "The ID of the User.", + required: true, + }, + muralTitle: { + type: "string", + label: "Mural Title", + description: "The title of the Mural.", + optional: true, + }, + workspaceId: { + type: "string", + label: "Workspace ID", + description: "The ID of the Workspace.", + required: true, + }, + name: { + type: "string", + label: "Name", + description: "The name of the Mural.", + required: true, + }, + description: { + type: "string", + label: "Description", + description: "A short description of the Mural.", + optional: true, + }, + templateId: { + type: "string", + label: "Template ID", + description: "The ID of a pre-existing design.", + optional: true, + }, + color: { + type: "string", + label: "Color", + description: "The color of the Sticky Note.", + optional: true, + }, + position: { + type: "string", + label: "Position", + description: "The position of the Sticky Note.", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://app.mural.co/api/public"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, method = "GET", path, headers, ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + method, + url: this._baseUrl() + path, + headers: { + ...headers, + Authorization: `Bearer ${this.$auth.oauth_access_token}`, + }, + }); + }, + async createMural(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/v1/murals", + ...opts, + }); + }, + async createSticky(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/v1/murals/sticky", + ...opts, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/mural/sources/new-area/new-area.mjs b/components/mural/sources/new-area/new-area.mjs new file mode 100644 index 0000000000000..9e6c4e64098bb --- /dev/null +++ b/components/mural/sources/new-area/new-area.mjs @@ -0,0 +1,46 @@ +import mural from "../../mural.app.mjs"; + +export default { + key: "mural-new-area", + name: "New Area Created", + description: "Emits an event when a new area is created in the user's mural", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + mural, + muralId: { + propDefinition: [ + mural, + "muralId", + ], + }, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: 60 * 15, // 15 minutes + }, + }, + }, + methods: { + _getLastEvent() { + return this.db.get("lastEvent") || null; + }, + _setLastEvent(lastEvent) { + this.db.set("lastEvent", lastEvent); + }, + }, + async run() { + const lastEvent = this._getLastEvent(); + const newEvent = await this.mural.getArea(this.muralId); + if (!lastEvent || new Date(newEvent.created_at) > new Date(lastEvent.created_at)) { + this.$emit(newEvent, { + id: newEvent.id, + summary: `New area created: ${newEvent.name}`, + ts: Date.parse(newEvent.created_at), + }); + this._setLastEvent(newEvent); + } + }, +}; diff --git a/components/mural/sources/new-mural/new-mural.mjs b/components/mural/sources/new-mural/new-mural.mjs new file mode 100644 index 0000000000000..f44f4c6c8bf03 --- /dev/null +++ b/components/mural/sources/new-mural/new-mural.mjs @@ -0,0 +1,64 @@ +import mural from "../../mural.app.mjs"; + +export default { + key: "mural-new-mural", + name: "New Mural", + description: "Emit new event when a new mural is created.", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + mural: { + type: "app", + app: "mural", + }, + muralId: { + propDefinition: [ + mural, + "muralId", + ], + }, + userId: { + propDefinition: [ + mural, + "userId", + ], + }, + muralTitle: { + propDefinition: [ + mural, + "muralTitle", + ], + optional: true, + }, + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: 60 * 15, // 15 minutes + }, + }, + }, + methods: { + ...mural.methods, + generateMeta(mural) { + const { + id, name, createdAt, + } = mural; + return { + id, + summary: name, + ts: Date.parse(createdAt), + }; + }, + }, + async run() { + const murals = await this.mural._makeRequest({ + path: `/v1/murals/${this.muralId}`, + }); + for (const mural of murals) { + if (mural.id === this.muralId && mural.createdBy === this.userId) { + this.$emit(mural, this.generateMeta(mural)); + } + } + }, +}; diff --git a/components/mural/sources/new-sticky/new-sticky.mjs b/components/mural/sources/new-sticky/new-sticky.mjs new file mode 100644 index 0000000000000..5dd5d26f58ef3 --- /dev/null +++ b/components/mural/sources/new-sticky/new-sticky.mjs @@ -0,0 +1,71 @@ +import mural from "../../mural.app.mjs"; + +export default { + key: "mural-new-sticky", + name: "New Sticky Note Created", + description: "Emits an event each time a new sticky note is created in a specified mural", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + mural: { + type: "app", + app: "mural", + }, + muralId: { + propDefinition: [ + mural, + "muralId", + ], + }, + stickyId: { + propDefinition: [ + mural, + "stickyId", + ], + }, + stickyContent: { + propDefinition: [ + mural, + "stickyContent", + ], + optional: true, + }, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: 60 * 15, // 15 minutes + }, + }, + }, + methods: { + _getSticky() { + return this.db.get("sticky") ?? { + id: this.stickyId, + }; + }, + _setSticky(sticky) { + this.db.set("sticky", sticky); + }, + }, + async run() { + // get the sticky + const sticky = await this.mural.createSticky({ + muralId: this.muralId, + stickyId: this.stickyId, + content: this.stickyContent, + }); + + // check if the sticky is new + const lastSticky = this._getSticky(); + if (sticky.id !== lastSticky.id) { + this.$emit(sticky, { + id: sticky.id, + summary: `New Sticky: ${sticky.content}`, + ts: Date.now(), + }); + this._setSticky(sticky); + } + }, +}; From ec7e4149153866c592b2702c5555bb9f487d26f9 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 11 Nov 2024 17:09:50 -0500 Subject: [PATCH 2/4] new components --- .../actions/create-mural/create-mural.mjs | 87 +++++- .../actions/create-sticky/create-sticky.mjs | 105 +++++-- components/mural/mural.app.mjs | 264 ++++++++++++++---- components/mural/package.json | 7 +- components/mural/sources/common/base.mjs | 85 ++++++ .../mural/sources/new-area/new-area.mjs | 50 ++-- .../mural/sources/new-mural/new-mural.mjs | 68 ++--- .../mural/sources/new-sticky/new-sticky.mjs | 73 ++--- 8 files changed, 511 insertions(+), 228 deletions(-) create mode 100644 components/mural/sources/common/base.mjs diff --git a/components/mural/actions/create-mural/create-mural.mjs b/components/mural/actions/create-mural/create-mural.mjs index c046c859f4db7..d3809f1625a10 100644 --- a/components/mural/actions/create-mural/create-mural.mjs +++ b/components/mural/actions/create-mural/create-mural.mjs @@ -3,32 +3,93 @@ import mural from "../../mural.app.mjs"; export default { key: "mural-create-mural", name: "Create Mural", - description: "Create a new mural within a specified workspace.", - version: "0.0.{{ts}}", + description: "Create a new mural within a specified workspace. [See the documentation](https://developers.mural.co/public/reference/createmural)", + version: "0.0.1", type: "action", props: { mural, - workspaceId: mural.propDefinitions.workspaceId, - name: mural.propDefinitions.name, - description: { - ...mural.propDefinitions.description, + workspaceId: { + propDefinition: [ + mural, + "workspaceId", + ], + }, + roomId: { + propDefinition: [ + mural, + "roomId", + (c) => ({ + workspaceId: c.workspaceId, + }), + ], + }, + title: { + type: "string", + label: "Title", + description: "The title of the Mural.", + }, + backgroundColor: { + type: "string", + label: "Background Color", + description: "The background color of the mural. Example: `#FAFAFAFF`", + optional: true, + }, + height: { + type: "integer", + label: "Height", + description: "The height of the mural in px", + optional: true, + }, + width: { + type: "integer", + label: "Width", + description: "The width of the mural in px", + optional: true, + }, + infinite: { + type: "boolean", + label: "Infinite", + description: "When `true`, this indicates that the mural canvas is borderless and grows as you add widgets to it.", + optional: true, + }, + timerSoundTheme: { + type: "string", + label: "Timer Sound Theme", + description: "The timer sound theme for the mural", + options: [ + "airplane", + "cello", + "cuckoo", + ], optional: true, }, - templateId: { - ...mural.propDefinitions.templateId, + visitorAvatarTheme: { + type: "string", + label: "Visitor Avatar Theme", + description: "The timer sound theme for the mural", + options: [ + "animals", + "music", + "travel", + ], optional: true, }, }, async run({ $ }) { const response = await this.mural.createMural({ + $, data: { - workspaceId: this.workspaceId, - name: this.name, - description: this.description, - templateId: this.templateId, + roomId: this.roomId, + title: this.title, + backgroundColor: this.backgroundColor, + height: this.height, + width: this.width, + infinite: this.infinite, + timerSoundTheme: this.timerSoundTheme, + visitorAvatarTheme: this.visitorAvatarTheme, }, }); - $.export("$summary", `Successfully created mural ${this.name}`); + $.export("$summary", `Successfully created mural "${this.title}"`); return response; }, }; diff --git a/components/mural/actions/create-sticky/create-sticky.mjs b/components/mural/actions/create-sticky/create-sticky.mjs index 4285e7d939f88..ae273cb02d290 100644 --- a/components/mural/actions/create-sticky/create-sticky.mjs +++ b/components/mural/actions/create-sticky/create-sticky.mjs @@ -3,48 +3,115 @@ import mural from "../../mural.app.mjs"; export default { key: "mural-create-sticky", name: "Create Sticky", - description: "Create a new sticky note within a given mural. [See the documentation](https://developers.mural.co/public/docs/mural-api)", - version: "0.0.{{ts}}", + description: "Create a new sticky note within a given mural. [See the documentation](https://developers.mural.co/public/reference/createstickynote)", + version: "0.0.1", type: "action", props: { mural, - muralId: { + workspaceId: { propDefinition: [ mural, - "muralId", + "workspaceId", ], }, - content: { + muralId: { propDefinition: [ mural, - "stickyContent", + "muralId", + (c) => ({ + workspaceId: c.workspaceId, + }), + ], + }, + shape: { + type: "string", + label: "Shape", + description: "The shape of the sticky note widget", + options: [ + "circle", + "rectangle", ], }, - color: { + xPosition: { + type: "integer", + label: "X Position", + description: "The horizontal position of the widget in px. This is the distance from the left of the parent widget, such as an area. If the widget has no parent widget, this is the distance from the left of the mural.", + }, + yPosition: { + type: "integer", + label: "Y Position", + description: "The vertical position of the widget in px. This is the distance from the top of the parent widget, such as an area. If the widget has no parent widget, this is the distance from the top of the mural.", + }, + text: { + type: "string", + label: "Text", + description: "The text in the widget", + }, + title: { + type: "string", + label: "Title", + description: "The title of the widget in the outline", + optional: true, + }, + height: { + type: "integer", + label: "Height", + description: "The height of the widget in px", + optional: true, + }, + width: { + type: "integer", + label: "Width", + description: "The width of the widget in px", + optional: true, + }, + hidden: { + type: "boolean", + label: "Hidden", + description: "If `true`, the widget is hidden from non-facilitators. Applies only when the widget is in the outline", + optional: true, + }, + tagIds: { propDefinition: [ mural, - "color", + "tagIds", + (c) => ({ + muralId: c.muralId, + }), ], - optional: true, }, - position: { + parentId: { propDefinition: [ mural, - "position", + "widgetId", + (c) => ({ + muralId: c.muralId, + type: "areas", + }), ], - optional: true, + label: "Parent ID", + description: "The ID of the area widget that contains the widget", }, }, async run({ $ }) { const response = await this.mural.createSticky({ - data: { - muralId: this.muralId, - content: this.content, - color: this.color, - position: this.position, - }, + $, + muralId: this.muralId, + data: [ + { + shape: this.shape, + x: this.xPosition, + y: this.yPosition, + text: this.text, + title: this.title, + height: this.height, + width: this.width, + hidden: this.hidden, + parentId: this.parentId, + }, + ], }); - $.export("$summary", `Successfully created sticky note with ID: ${response.id}`); + $.export("$summary", `Successfully created sticky note with ID: ${response.value[0].id}`); return response; }, }; diff --git a/components/mural/mural.app.mjs b/components/mural/mural.app.mjs index d3aa065648b1b..79bfc8c0a77e6 100644 --- a/components/mural/mural.app.mjs +++ b/components/mural/mural.app.mjs @@ -4,104 +4,244 @@ export default { type: "app", app: "mural", propDefinitions: { - muralId: { - type: "string", - label: "Mural ID", - description: "The ID of the Mural.", - required: true, - }, - stickyId: { - type: "string", - label: "Sticky ID", - description: "The ID of the Sticky Note.", - required: true, - }, - stickyContent: { - type: "string", - label: "Sticky Content", - description: "The content of the Sticky Note.", - optional: true, - }, - userId: { - type: "string", - label: "User ID", - description: "The ID of the User.", - required: true, - }, - muralTitle: { - type: "string", - label: "Mural Title", - description: "The title of the Mural.", - optional: true, - }, workspaceId: { type: "string", label: "Workspace ID", description: "The ID of the Workspace.", - required: true, + async options({ prevContext }) { + const { + value, next: nextToken, + } = await this.listWorkspaces({ + params: { + next: prevContext?.next, + }, + }); + return { + options: value?.map(({ + id: value, name: label, + }) => ({ + value, + label, + })) || [], + context: { + next: nextToken, + }, + }; + }, }, - name: { - type: "string", - label: "Name", - description: "The name of the Mural.", - required: true, - }, - description: { + muralId: { type: "string", - label: "Description", - description: "A short description of the Mural.", - optional: true, + label: "Mural ID", + description: "The ID of the Mural.", + async options({ + workspaceId, prevContext, + }) { + const { + value, next: nextToken, + } = await this.listMurals({ + workspaceId, + params: { + next: prevContext?.next, + }, + }); + return { + options: value?.map(({ + id: value, title: label, + }) => ({ + value, + label, + })) || [], + context: { + next: nextToken, + }, + }; + }, }, - templateId: { + roomId: { type: "string", - label: "Template ID", - description: "The ID of a pre-existing design.", - optional: true, + label: "Room ID", + description: "The ID of the Room.", + async options({ + workspaceId, prevContext, + }) { + const { + value, next: nextToken, + } = await this.listRooms({ + workspaceId, + params: { + next: prevContext?.next, + }, + }); + return { + options: value?.map(({ + id: value, name: label, + }) => ({ + value, + label, + })) || [], + context: { + next: nextToken, + }, + }; + }, }, - color: { - type: "string", - label: "Color", - description: "The color of the Sticky Note.", + tagIds: { + type: "string[]", + label: "Tag IDs", + description: "Unique identifiers of the tags in the widget", optional: true, + async options({ + muralId, prevContext, + }) { + const { + value, next: nextToken, + } = await this.listTags({ + muralId, + params: { + next: prevContext?.next, + }, + }); + return { + options: value?.map(({ + id: value, text: label, + }) => ({ + value, + label, + })) || [], + context: { + next: nextToken, + }, + }; + }, }, - position: { + widgetId: { type: "string", - label: "Position", - description: "The position of the Sticky Note.", + label: "Widget ID", + description: "Unique identifiers of the widget", optional: true, + async options({ + muralId, type, prevContext, + }) { + const { + value, next: nextToken, + } = await this.listWidgets({ + muralId, + params: { + type, + next: prevContext?.next, + }, + }); + return { + options: value?.map(({ + id: value, title: label, + }) => ({ + value, + label, + })) || [], + context: { + next: nextToken, + }, + }; + }, }, }, methods: { _baseUrl() { - return "https://app.mural.co/api/public"; + return "https://app.mural.co/api/public/v1"; }, - async _makeRequest(opts = {}) { + _makeRequest(opts = {}) { const { - $ = this, method = "GET", path, headers, ...otherOpts + $ = this, + path, + ...otherOpts } = opts; return axios($, { ...otherOpts, - method, - url: this._baseUrl() + path, + url: `${this._baseUrl()}${path}`, headers: { - ...headers, Authorization: `Bearer ${this.$auth.oauth_access_token}`, }, }); }, - async createMural(opts = {}) { + listWorkspaces(opts = {}) { + return this._makeRequest({ + path: "/workspaces", + ...opts, + }); + }, + listMurals({ + workspaceId, ...opts + }) { + return this._makeRequest({ + path: `/workspaces/${workspaceId}/murals`, + ...opts, + }); + }, + listRooms({ + workspaceId, ...opts + }) { + return this._makeRequest({ + path: `/workspaces/${workspaceId}/rooms`, + ...opts, + }); + }, + listTags({ + muralId, ...opts + }) { + return this._makeRequest({ + path: `/murals/${muralId}/tags`, + ...opts, + }); + }, + listWidgets({ + muralId, ...opts + }) { + return this._makeRequest({ + path: `/murals/${muralId}/widgets`, + ...opts, + }); + }, + createMural(opts = {}) { return this._makeRequest({ method: "POST", - path: "/v1/murals", + path: "/murals", ...opts, }); }, - async createSticky(opts = {}) { + createSticky({ + muralId, ...opts + }) { return this._makeRequest({ method: "POST", - path: "/v1/murals/sticky", + path: `/murals/${muralId}/widgets/sticky-note`, ...opts, }); }, + async *paginate({ + fn, + args, + max, + }) { + args = { + ...args, + params: { + ...args?.params, + limit: 100, + }, + }; + let count = 0; + do { + const { + value, next, + } = await fn(args); + for (const item of value) { + yield item; + if (max && ++count >= max) { + return; + } + } + args.params.next = next; + } while (args.params.next); + }, }, }; diff --git a/components/mural/package.json b/components/mural/package.json index 6da8a3e0b5df3..227fca215ed5d 100644 --- a/components/mural/package.json +++ b/components/mural/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/mural", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Mural Components", "main": "mural.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/mural/sources/common/base.mjs b/components/mural/sources/common/base.mjs new file mode 100644 index 0000000000000..7fada52e4d214 --- /dev/null +++ b/components/mural/sources/common/base.mjs @@ -0,0 +1,85 @@ +import mural from "../../mural.app.mjs"; +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; + +export default { + props: { + mural, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + workspaceId: { + propDefinition: [ + mural, + "workspaceId", + ], + }, + }, + hooks: { + async deploy() { + await this.processEvent(25); + }, + }, + methods: { + _getLastTs() { + return this.db.get("lastTs") || 0; + }, + _setLastTs(lastTs) { + this.db.set("lastTs", lastTs); + }, + getResourceFn() { + throw new Error("getResourceFn is not implemented"); + }, + getArgs() { + return {}; + }, + getTsField() { + return "createdOn"; + }, + generateMeta(item) { + return { + id: item.id, + summary: this.getSummary(item), + ts: item[this.getTsField()], + }; + }, + getSummary() { + throw new Error("getSummary is not implemented"); + }, + async processEvent(max) { + const lastTs = this._getLastTs(); + let maxTs = lastTs; + const fn = this.getResourceFn(); + const args = this.getArgs(); + const tsField = this.getTsField(); + + const results = this.mural.paginate({ + fn, + args, + max, + }); + + const items = []; + for await (const item of results) { + const ts = item[tsField]; + if (ts > lastTs) { + items.push(item); + maxTs = Math.max(ts, maxTs); + } + } + + this._setLastTs(maxTs); + + items.forEach((item) => { + const meta = this.generateMeta(item); + this.$emit(item, meta); + }); + }, + }, + async run() { + await this.processEvent(); + }, +}; diff --git a/components/mural/sources/new-area/new-area.mjs b/components/mural/sources/new-area/new-area.mjs index 9e6c4e64098bb..d97417079f6f4 100644 --- a/components/mural/sources/new-area/new-area.mjs +++ b/components/mural/sources/new-area/new-area.mjs @@ -1,46 +1,40 @@ -import mural from "../../mural.app.mjs"; +import common from "../common/base.mjs"; export default { + ...common, key: "mural-new-area", name: "New Area Created", - description: "Emits an event when a new area is created in the user's mural", - version: "0.0.{{ts}}", + description: "Emit new event when a new area is created in the user's mural", + version: "0.0.1", type: "source", dedupe: "unique", props: { - mural, + ...common.props, muralId: { propDefinition: [ - mural, + common.props.mural, "muralId", + (c) => ({ + workspaceId: c.workspaceId, + }), ], }, - db: "$.service.db", - timer: { - type: "$.interface.timer", - default: { - intervalSeconds: 60 * 15, // 15 minutes - }, - }, }, methods: { - _getLastEvent() { - return this.db.get("lastEvent") || null; + ...common.methods, + getResourceFn() { + return this.mural.listWidgets; }, - _setLastEvent(lastEvent) { - this.db.set("lastEvent", lastEvent); + getArgs() { + return { + muralId: this.muralId, + params: { + type: "areas", + }, + }; + }, + getSummary(item) { + return `New Area Widget ID: ${item.id}`; }, - }, - async run() { - const lastEvent = this._getLastEvent(); - const newEvent = await this.mural.getArea(this.muralId); - if (!lastEvent || new Date(newEvent.created_at) > new Date(lastEvent.created_at)) { - this.$emit(newEvent, { - id: newEvent.id, - summary: `New area created: ${newEvent.name}`, - ts: Date.parse(newEvent.created_at), - }); - this._setLastEvent(newEvent); - } }, }; diff --git a/components/mural/sources/new-mural/new-mural.mjs b/components/mural/sources/new-mural/new-mural.mjs index f44f4c6c8bf03..49abc7fd03fda 100644 --- a/components/mural/sources/new-mural/new-mural.mjs +++ b/components/mural/sources/new-mural/new-mural.mjs @@ -1,64 +1,28 @@ -import mural from "../../mural.app.mjs"; +import common from "../common/base.mjs"; export default { + ...common, key: "mural-new-mural", - name: "New Mural", + name: "New Mural Created", description: "Emit new event when a new mural is created.", - version: "0.0.{{ts}}", + version: "0.0.1", type: "source", dedupe: "unique", - props: { - mural: { - type: "app", - app: "mural", - }, - muralId: { - propDefinition: [ - mural, - "muralId", - ], - }, - userId: { - propDefinition: [ - mural, - "userId", - ], - }, - muralTitle: { - propDefinition: [ - mural, - "muralTitle", - ], - optional: true, - }, - timer: { - type: "$.interface.timer", - default: { - intervalSeconds: 60 * 15, // 15 minutes - }, - }, - }, methods: { - ...mural.methods, - generateMeta(mural) { - const { - id, name, createdAt, - } = mural; + ...common.methods, + getResourceFn() { + return this.mural.listMurals; + }, + getArgs() { return { - id, - summary: name, - ts: Date.parse(createdAt), + workspaceId: this.workspaceId, + params: { + sortBy: "lastCreated", + }, }; }, - }, - async run() { - const murals = await this.mural._makeRequest({ - path: `/v1/murals/${this.muralId}`, - }); - for (const mural of murals) { - if (mural.id === this.muralId && mural.createdBy === this.userId) { - this.$emit(mural, this.generateMeta(mural)); - } - } + getSummary(item) { + return `New Mural ID: ${item.id}`; + }, }, }; diff --git a/components/mural/sources/new-sticky/new-sticky.mjs b/components/mural/sources/new-sticky/new-sticky.mjs index 5dd5d26f58ef3..6316a2dc51261 100644 --- a/components/mural/sources/new-sticky/new-sticky.mjs +++ b/components/mural/sources/new-sticky/new-sticky.mjs @@ -1,71 +1,40 @@ -import mural from "../../mural.app.mjs"; +import common from "../common/base.mjs"; export default { + ...common, key: "mural-new-sticky", name: "New Sticky Note Created", - description: "Emits an event each time a new sticky note is created in a specified mural", - version: "0.0.{{ts}}", + description: "Emit new event each time a new sticky note is created in a specified mural", + version: "0.0.1", type: "source", dedupe: "unique", props: { - mural: { - type: "app", - app: "mural", - }, + ...common.props, muralId: { propDefinition: [ - mural, + common.props.mural, "muralId", + (c) => ({ + workspaceId: c.workspaceId, + }), ], }, - stickyId: { - propDefinition: [ - mural, - "stickyId", - ], - }, - stickyContent: { - propDefinition: [ - mural, - "stickyContent", - ], - optional: true, - }, - db: "$.service.db", - timer: { - type: "$.interface.timer", - default: { - intervalSeconds: 60 * 15, // 15 minutes - }, - }, }, methods: { - _getSticky() { - return this.db.get("sticky") ?? { - id: this.stickyId, + ...common.methods, + getResourceFn() { + return this.mural.listWidgets; + }, + getArgs() { + return { + muralId: this.muralId, + params: { + type: "sticky notes", + }, }; }, - _setSticky(sticky) { - this.db.set("sticky", sticky); + getSummary(item) { + return `New Sticky Note ID: ${item.id}`; }, }, - async run() { - // get the sticky - const sticky = await this.mural.createSticky({ - muralId: this.muralId, - stickyId: this.stickyId, - content: this.stickyContent, - }); - - // check if the sticky is new - const lastSticky = this._getSticky(); - if (sticky.id !== lastSticky.id) { - this.$emit(sticky, { - id: sticky.id, - summary: `New Sticky: ${sticky.content}`, - ts: Date.now(), - }); - this._setSticky(sticky); - } - }, }; From c16e457cb29a9313444d2d14709d42578689022c Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 11 Nov 2024 17:11:19 -0500 Subject: [PATCH 3/4] pnpm-lock.yaml --- pnpm-lock.yaml | 107 +++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 67a0ced94a27a..a8ae685925a6e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6498,7 +6498,10 @@ importers: specifiers: {} components/mural: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.3 + dependencies: + '@pipedream/platform': 3.0.3 components/murlist: specifiers: {} @@ -13375,55 +13378,6 @@ packages: - aws-crt dev: false - /@aws-sdk/client-sso-oidc/3.600.0_tdq3komn4zwyd65w7klbptsu34: - resolution: {integrity: sha512-7+I8RWURGfzvChyNQSyj5/tKrqRbzRl7H+BnTOf/4Vsw1nFOi5ROhlhD4X/Y0QCTacxnaoNcIrqnY7uGGvVRzw==} - engines: {node: '>=16.0.0'} - dependencies: - '@aws-crypto/sha256-browser': 5.2.0 - '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sts': 3.600.0 - '@aws-sdk/core': 3.598.0 - '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 - '@aws-sdk/middleware-host-header': 3.598.0 - '@aws-sdk/middleware-logger': 3.598.0 - '@aws-sdk/middleware-recursion-detection': 3.598.0 - '@aws-sdk/middleware-user-agent': 3.598.0 - '@aws-sdk/region-config-resolver': 3.598.0 - '@aws-sdk/types': 3.598.0 - '@aws-sdk/util-endpoints': 3.598.0 - '@aws-sdk/util-user-agent-browser': 3.598.0 - '@aws-sdk/util-user-agent-node': 3.598.0 - '@smithy/config-resolver': 3.0.3 - '@smithy/core': 2.2.3 - '@smithy/fetch-http-handler': 3.2.1 - '@smithy/hash-node': 3.0.2 - '@smithy/invalid-dependency': 3.0.2 - '@smithy/middleware-content-length': 3.0.2 - '@smithy/middleware-endpoint': 3.0.4 - '@smithy/middleware-retry': 3.0.6 - '@smithy/middleware-serde': 3.0.3 - '@smithy/middleware-stack': 3.0.3 - '@smithy/node-config-provider': 3.1.3 - '@smithy/node-http-handler': 3.1.2 - '@smithy/protocol-http': 4.0.3 - '@smithy/smithy-client': 3.1.6 - '@smithy/types': 3.3.0 - '@smithy/url-parser': 3.0.3 - '@smithy/util-base64': 3.0.0 - '@smithy/util-body-length-browser': 3.0.0 - '@smithy/util-body-length-node': 3.0.0 - '@smithy/util-defaults-mode-browser': 3.0.6 - '@smithy/util-defaults-mode-node': 3.0.6 - '@smithy/util-endpoints': 2.0.3 - '@smithy/util-middleware': 3.0.3 - '@smithy/util-retry': 3.0.2 - '@smithy/util-utf8': 3.0.0 - tslib: 2.6.3 - transitivePeerDependencies: - - '@aws-sdk/client-sts' - - aws-crt - dev: false - /@aws-sdk/client-sso/3.423.0: resolution: {integrity: sha512-znIufHkwhCIePgaYciIs3x/+BpzR57CZzbCKHR9+oOvGyufEPPpUT5bFLvbwTgfiVkTjuk6sG/ES3U5Bc+xtrA==} engines: {node: '>=14.0.0'} @@ -13659,7 +13613,7 @@ packages: dependencies: '@aws-crypto/sha256-browser': 5.2.0 '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0_tdq3komn4zwyd65w7klbptsu34 + '@aws-sdk/client-sso-oidc': 3.600.0 '@aws-sdk/core': 3.598.0 '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 '@aws-sdk/middleware-host-header': 3.598.0 @@ -13701,6 +13655,55 @@ packages: - aws-crt dev: false + /@aws-sdk/client-sts/3.600.0_dseaa2p5u2yk67qiepewcq3hkq: + resolution: {integrity: sha512-KQG97B7LvTtTiGmjlrG1LRAY8wUvCQzrmZVV5bjrJ/1oXAU7DITYwVbSJeX9NWg6hDuSk0VE3MFwIXS2SvfLIA==} + engines: {node: '>=16.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 5.2.0 + '@aws-crypto/sha256-js': 5.2.0 + '@aws-sdk/client-sso-oidc': 3.600.0 + '@aws-sdk/core': 3.598.0 + '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 + '@aws-sdk/middleware-host-header': 3.598.0 + '@aws-sdk/middleware-logger': 3.598.0 + '@aws-sdk/middleware-recursion-detection': 3.598.0 + '@aws-sdk/middleware-user-agent': 3.598.0 + '@aws-sdk/region-config-resolver': 3.598.0 + '@aws-sdk/types': 3.598.0 + '@aws-sdk/util-endpoints': 3.598.0 + '@aws-sdk/util-user-agent-browser': 3.598.0 + '@aws-sdk/util-user-agent-node': 3.598.0 + '@smithy/config-resolver': 3.0.3 + '@smithy/core': 2.2.3 + '@smithy/fetch-http-handler': 3.2.1 + '@smithy/hash-node': 3.0.2 + '@smithy/invalid-dependency': 3.0.2 + '@smithy/middleware-content-length': 3.0.2 + '@smithy/middleware-endpoint': 3.0.4 + '@smithy/middleware-retry': 3.0.6 + '@smithy/middleware-serde': 3.0.3 + '@smithy/middleware-stack': 3.0.3 + '@smithy/node-config-provider': 3.1.3 + '@smithy/node-http-handler': 3.1.2 + '@smithy/protocol-http': 4.0.3 + '@smithy/smithy-client': 3.1.6 + '@smithy/types': 3.3.0 + '@smithy/url-parser': 3.0.3 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.6 + '@smithy/util-defaults-mode-node': 3.0.6 + '@smithy/util-endpoints': 2.0.3 + '@smithy/util-middleware': 3.0.3 + '@smithy/util-retry': 3.0.2 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.3 + transitivePeerDependencies: + - '@aws-sdk/client-sso-oidc' + - aws-crt + dev: false + /@aws-sdk/core/3.556.0: resolution: {integrity: sha512-vJaSaHw2kPQlo11j/Rzuz0gk1tEaKdz+2ser0f0qZ5vwFlANjt08m/frU17ctnVKC1s58bxpctO/1P894fHLrA==} engines: {node: '>=14.0.0'} @@ -18044,7 +18047,7 @@ packages: '@aws-sdk/client-sns': 3.423.0 '@aws-sdk/client-sqs': 3.423.0 '@aws-sdk/client-ssm': 3.423.0 - '@aws-sdk/client-sts': 3.600.0 + '@aws-sdk/client-sts': 3.600.0_dseaa2p5u2yk67qiepewcq3hkq '@aws-sdk/s3-request-presigner': 3.609.0 '@pipedream/helper_functions': 0.3.12 '@pipedream/platform': 1.6.6 From e424c1da4bab3efd10dfb6c3f8e15b1651f78042 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 11 Nov 2024 17:26:18 -0500 Subject: [PATCH 4/4] fix description --- components/mural/actions/create-mural/create-mural.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mural/actions/create-mural/create-mural.mjs b/components/mural/actions/create-mural/create-mural.mjs index d3809f1625a10..f61afb50a29b2 100644 --- a/components/mural/actions/create-mural/create-mural.mjs +++ b/components/mural/actions/create-mural/create-mural.mjs @@ -66,7 +66,7 @@ export default { visitorAvatarTheme: { type: "string", label: "Visitor Avatar Theme", - description: "The timer sound theme for the mural", + description: "The visitor avatar theme for the mural", options: [ "animals", "music",