From 6b9896a1eeeac177e44234baa2855cf8b6df6eac Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 2 Jul 2025 13:53:38 -0400 Subject: [PATCH 01/10] wip --- components/asters/asters.app.mjs | 68 +++++++++++++++++-- components/asters/package.json | 13 +++- components/asters/sources/common/base.mjs | 17 +++++ .../sources/label-edited/label-edited.mjs | 13 ++++ .../new-label-added/new-label-added.mjs | 13 ++++ 5 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 components/asters/sources/common/base.mjs create mode 100644 components/asters/sources/label-edited/label-edited.mjs create mode 100644 components/asters/sources/new-label-added/new-label-added.mjs diff --git a/components/asters/asters.app.mjs b/components/asters/asters.app.mjs index 2ceeb25264ab0..e1cd480076f00 100644 --- a/components/asters/asters.app.mjs +++ b/components/asters/asters.app.mjs @@ -1,11 +1,71 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "asters", - propDefinitions: {}, + propDefinitions: { + workspaceId: { + type: "string", + label: "Workspace ID", + description: "The ID of a workspace", + async options() { + const { data: { workspaces = [] } } = await this.listWorkspaces(); + return workspaces.map((workspace) => ({ + label: workspace.name, + value: workspace._id, + })); + }, + }, + socialAccountId: { + type: "string", + label: "Social Account ID", + description: "The ID of a social account", + async options({ workspaceId }) { + const { data = [] } = await this.listSocialAccounts({ + workspaceId, + }); + return data.map((account) => ({ + label: account.name, + value: account.account_id, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.asters.ai/api/external/v1.0"; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + url: `${this._baseUrl()}${path}`, + headers: { + "x-api-key": `${this.$auth.api_key}`, + }, + ...opts, + }); + }, + listWorkspaces(opts = {}) { + return this._makeRequest({ + path: "/workspaces", + ...opts, + }); + }, + listSocialAccounts({ + workspaceId, ...opts + }) { + return this._makeRequest({ + path: `/workspaces/${workspaceId}/socialAccounts`, + ...opts, + }); + }, + listPosts(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/data/posts", + ...opts, + }); }, }, }; diff --git a/components/asters/package.json b/components/asters/package.json index 36fd0c6e81a24..3b491e0e8fcd8 100644 --- a/components/asters/package.json +++ b/components/asters/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/asters", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Asters Components", "main": "asters.app.mjs", "keywords": [ @@ -11,5 +11,14 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" + }, + "actions": { + "directory": "actions" + }, + "sources": { + "directory": "sources" } -} \ No newline at end of file +} diff --git a/components/asters/sources/common/base.mjs b/components/asters/sources/common/base.mjs new file mode 100644 index 0000000000000..4c75553d9cb6a --- /dev/null +++ b/components/asters/sources/common/base.mjs @@ -0,0 +1,17 @@ +import asters from "../../asters.app.mjs"; +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; + +export default { + props: { + asters, + db: "$.service.db", + timer: { + label: "Polling interval", + description: "Pipedream will poll the Trello API on this schedule", + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, +}; diff --git a/components/asters/sources/label-edited/label-edited.mjs b/components/asters/sources/label-edited/label-edited.mjs new file mode 100644 index 0000000000000..13193bd0b9d78 --- /dev/null +++ b/components/asters/sources/label-edited/label-edited.mjs @@ -0,0 +1,13 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "asters-label-edited", + name: "Label Edited", + description: "Emit new event when a label is edited on a post.", + type: "source", + version: "0.0.{{ts}}", + dedupe: "unique", + async run() { + }, +}; diff --git a/components/asters/sources/new-label-added/new-label-added.mjs b/components/asters/sources/new-label-added/new-label-added.mjs new file mode 100644 index 0000000000000..ee3a09179018f --- /dev/null +++ b/components/asters/sources/new-label-added/new-label-added.mjs @@ -0,0 +1,13 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "asters-new-label-added", + name: "New Label Added", + description: "Emit new event when a label is added to a post.", + type: "source", + version: "0.0.{{ts}}", + dedupe: "unique", + async run() { + }, +}; From 82bfb9d83661a3a9126d1b79e88a1ca063f8d3b7 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 2 Jul 2025 15:29:01 -0400 Subject: [PATCH 02/10] new components --- .../actions/list-labels/list-labels.mjs | 27 ++++++++ .../list-posts-analytics.mjs | 59 ++++++++++++++++++ .../asters/actions/list-posts/list-posts.mjs | 59 ++++++++++++++++++ .../list-social-accounts.mjs | 27 ++++++++ components/asters/asters.app.mjs | 61 +++++++++++++++++++ components/asters/sources/common/base.mjs | 28 ++++++++- .../sources/label-edited/label-edited.mjs | 13 ---- .../new-label-added/new-label-added.mjs | 55 ++++++++++++++++- .../sources/new-label-added/test-event.mjs | 23 +++++++ 9 files changed, 336 insertions(+), 16 deletions(-) create mode 100644 components/asters/actions/list-labels/list-labels.mjs create mode 100644 components/asters/actions/list-posts-analytics/list-posts-analytics.mjs create mode 100644 components/asters/actions/list-posts/list-posts.mjs create mode 100644 components/asters/actions/list-social-accounts/list-social-accounts.mjs delete mode 100644 components/asters/sources/label-edited/label-edited.mjs create mode 100644 components/asters/sources/new-label-added/test-event.mjs diff --git a/components/asters/actions/list-labels/list-labels.mjs b/components/asters/actions/list-labels/list-labels.mjs new file mode 100644 index 0000000000000..8b11745ef6264 --- /dev/null +++ b/components/asters/actions/list-labels/list-labels.mjs @@ -0,0 +1,27 @@ +import asters from "../../asters.app.mjs"; + +export default { + key: "asters-list-labels", + name: "List Labels", + description: "Retrieve the list of all labels of a specific workspace. [See the documentation](https://docs.asters.ai/api/endpoints/labels)", + type: "action", + version: "0.0.1", + props: { + asters, + workspaceId: { + propDefinition: [ + asters, + "workspaceId", + ], + }, + }, + async run({ $ }) { + const { data } = await this.asters.listLabels({ + workspaceId: this.workspaceId, + }); + $.export("$summary", `Successfully retrieved ${data.length} label${data.length === 1 + ? "" + : "s"}`); + return data; + }, +}; diff --git a/components/asters/actions/list-posts-analytics/list-posts-analytics.mjs b/components/asters/actions/list-posts-analytics/list-posts-analytics.mjs new file mode 100644 index 0000000000000..a50387b6b9343 --- /dev/null +++ b/components/asters/actions/list-posts-analytics/list-posts-analytics.mjs @@ -0,0 +1,59 @@ +import asters from "../../asters.app.mjs"; + +export default { + key: "asters-list-posts-analytics", + name: "List Posts Analytics", + description: "Retrieve the list of posts' analytics of a social account. [See the documentation](https://docs.asters.ai/api/endpoints/analytics)", + type: "action", + version: "0.0.1", + props: { + asters, + workspaceId: { + propDefinition: [ + asters, + "workspaceId", + ], + }, + socialAccountId: { + propDefinition: [ + asters, + "socialAccountId", + (c) => ({ + workspaceId: c.workspaceId, + }), + ], + }, + fromDate: { + propDefinition: [ + asters, + "fromDate", + ], + }, + toDate: { + propDefinition: [ + asters, + "toDate", + ], + }, + }, + async run({ $ }) { + const posts = await this.asters.getPaginatedResources({ + fn: this.asters.listPostAnalytics, + args: { + data: { + socialAccountId: this.socialAccountId, + filters: { + date: { + from: this.fromDate, + to: this.toDate, + }, + }, + }, + }, + }); + $.export("$summary", `Successfully retrieved ${posts.length} post${posts.length === 1 + ? "" + : "s"}`); + return posts; + }, +}; diff --git a/components/asters/actions/list-posts/list-posts.mjs b/components/asters/actions/list-posts/list-posts.mjs new file mode 100644 index 0000000000000..4e1c67c1bdb70 --- /dev/null +++ b/components/asters/actions/list-posts/list-posts.mjs @@ -0,0 +1,59 @@ +import asters from "../../asters.app.mjs"; + +export default { + key: "asters-list-posts", + name: "List Posts", + description: "Retrieve a list of posts of a social profile. [See the documentation](https://docs.asters.ai/api/endpoints/posts)", + type: "action", + version: "0.0.1", + props: { + asters, + workspaceId: { + propDefinition: [ + asters, + "workspaceId", + ], + }, + socialAccountId: { + propDefinition: [ + asters, + "socialAccountId", + (c) => ({ + workspaceId: c.workspaceId, + }), + ], + }, + fromDate: { + propDefinition: [ + asters, + "fromDate", + ], + }, + toDate: { + propDefinition: [ + asters, + "toDate", + ], + }, + }, + async run({ $ }) { + const posts = await this.asters.getPaginatedResources({ + fn: this.asters.listPosts, + args: { + data: { + socialAccountId: this.socialAccountId, + filters: { + date: { + from: this.fromDate, + to: this.toDate, + }, + }, + }, + }, + }); + $.export("$summary", `Successfully retrieved ${posts.length} post${posts.length === 1 + ? "" + : "s"}`); + return posts; + }, +}; diff --git a/components/asters/actions/list-social-accounts/list-social-accounts.mjs b/components/asters/actions/list-social-accounts/list-social-accounts.mjs new file mode 100644 index 0000000000000..d72fe62ea3cc8 --- /dev/null +++ b/components/asters/actions/list-social-accounts/list-social-accounts.mjs @@ -0,0 +1,27 @@ +import asters from "../../asters.app.mjs"; + +export default { + key: "asters-list-social-accounts", + name: "List Social Accounts", + description: "Retrieve the list of all social accounts of a specific workspace. [See the documentation](https://docs.asters.ai/api/endpoints/social-accounts)", + type: "action", + version: "0.0.1", + props: { + asters, + workspaceId: { + propDefinition: [ + asters, + "workspaceId", + ], + }, + }, + async run({ $ }) { + const { data } = await this.asters.listSocialAccounts({ + workspaceId: this.workspaceId, + }); + $.export("$summary", `Successfully retrieved ${data.length} social account${data.length === 1 + ? "" + : "s"}`); + return data; + }, +}; diff --git a/components/asters/asters.app.mjs b/components/asters/asters.app.mjs index e1cd480076f00..f6d2bda372da7 100644 --- a/components/asters/asters.app.mjs +++ b/components/asters/asters.app.mjs @@ -30,6 +30,16 @@ export default { })); }, }, + fromDate: { + type: "string", + label: "From Date", + description: "The date to start the search from (YYYY-MM-DD)", + }, + toDate: { + type: "string", + label: "To Date", + description: "The date to end the search (YYYY-MM-DD)", + }, }, methods: { _baseUrl() { @@ -43,6 +53,7 @@ export default { headers: { "x-api-key": `${this.$auth.api_key}`, }, + debug: true, ...opts, }); }, @@ -60,6 +71,14 @@ export default { ...opts, }); }, + listLabels({ + workspaceId, ...opts + }) { + return this._makeRequest({ + path: `/workspaces/${workspaceId}/labels`, + ...opts, + }); + }, listPosts(opts = {}) { return this._makeRequest({ method: "POST", @@ -67,5 +86,47 @@ export default { ...opts, }); }, + listPostAnalytics(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/analytics/posts", + ...opts, + }); + }, + async *paginate({ + fn, args, max, + }) { + args = { + ...args, + data: { + ...args?.data, + page: 1, + }, + }; + let hasMore, count = 0; + do { + const { + data, pagination, + } = await fn(args); + if (!data?.length) { + return; + } + for (const item of data) { + yield item; + if (max && ++count >= max) { + return; + } + } + hasMore = pagination?.totalPages > args.data.page; + args.data.page++; + } while (hasMore); + }, + async getPaginatedResources(opts) { + const results = []; + for await (const item of this.paginate(opts)) { + results.push(item); + } + return results; + }, }, }; diff --git a/components/asters/sources/common/base.mjs b/components/asters/sources/common/base.mjs index 4c75553d9cb6a..2f9230be03e1e 100644 --- a/components/asters/sources/common/base.mjs +++ b/components/asters/sources/common/base.mjs @@ -1,5 +1,7 @@ import asters from "../../asters.app.mjs"; -import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import { + DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, ConfigurationError, +} from "@pipedream/platform"; export default { props: { @@ -14,4 +16,28 @@ export default { }, }, }, + methods: { + getResourceFn() { + throw new ConfigurationError("getResourceFn must be implemented"); + }, + getArgs() { + throw new ConfigurationError("getArgs must be implemented"); + }, + generateMeta() { + throw new ConfigurationError("generateMeta must be implemented"); + }, + processResource() { + throw new ConfigurationError("processResource must be implemented"); + }, + }, + async run() { + const resources = await this.asters.getPaginatedResources({ + fn: this.getResourceFn(), + args: this.getArgs(), + }); + + for (const resource of resources) { + await this.processResource(resource); + } + }, }; diff --git a/components/asters/sources/label-edited/label-edited.mjs b/components/asters/sources/label-edited/label-edited.mjs deleted file mode 100644 index 13193bd0b9d78..0000000000000 --- a/components/asters/sources/label-edited/label-edited.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import common from "../common/base.mjs"; - -export default { - ...common, - key: "asters-label-edited", - name: "Label Edited", - description: "Emit new event when a label is edited on a post.", - type: "source", - version: "0.0.{{ts}}", - dedupe: "unique", - async run() { - }, -}; diff --git a/components/asters/sources/new-label-added/new-label-added.mjs b/components/asters/sources/new-label-added/new-label-added.mjs index ee3a09179018f..ecf56bcc0f003 100644 --- a/components/asters/sources/new-label-added/new-label-added.mjs +++ b/components/asters/sources/new-label-added/new-label-added.mjs @@ -1,4 +1,5 @@ import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; export default { ...common, @@ -6,8 +7,58 @@ export default { name: "New Label Added", description: "Emit new event when a label is added to a post.", type: "source", - version: "0.0.{{ts}}", + version: "0.0.1", dedupe: "unique", - async run() { + props: { + ...common.props, + workspaceId: { + propDefinition: [ + common.props.asters, + "workspaceId", + ], + }, + socialAccountId: { + propDefinition: [ + common.props.asters, + "socialAccountId", + (c) => ({ + workspaceId: c.workspaceId, + }), + ], + }, }, + methods: { + ...common.methods, + getResourceFn() { + return this.asters.listPosts; + }, + getArgs() { + return { + data: { + socialAccountId: this.socialAccountId, + filters: { + date: { + from: "1979-01-01", + to: new Date().toISOString(), + }, + }, + }, + }; + }, + async processResource(post) { + const { labels = [] } = post; + for (const label of labels) { + const meta = this.generateMeta(post, label); + this.$emit(post, meta); + } + }, + generateMeta(post, label) { + return { + id: `${post._id}-${label._id}`, + summary: `New Label ${label._id} added to post ${post._id}`, + ts: Date.now(), + }; + }, + }, + sampleEmit, }; diff --git a/components/asters/sources/new-label-added/test-event.mjs b/components/asters/sources/new-label-added/test-event.mjs new file mode 100644 index 0000000000000..0132ddc30eef7 --- /dev/null +++ b/components/asters/sources/new-label-added/test-event.mjs @@ -0,0 +1,23 @@ +export default { + "_id": "67f1426b5d81d91673b9b2db", + "variantId": "faej60xwwyw", + "text": "Not just a dog β€” a heartbeat at our feet, a soul at peace 🐢✨", + "status": "published", + "medias": [ + { + "_id": "67dc38ae012dabdb705d4d53", + "type": "file", + "mimetype": "video/mp4", + "name": "67dc2d88012dabdb705c51c9_Snapinst.app_video_AQPuuFqL4SkuU-iT7VBhx7VJvkRGUc6ozCJduveEHszAI4J_FzTG55DCxnF3M1kjzXRey-bN5f6n5CyUUvnW-4yQJh_cwiBhZDCOXs4.mp4", + "url": "https://asters.s3.eu-central-1.amazonaws.com/67dc2d88012dabdb705c51c9_Snapinst.app_video_AQPuuFqL4SkuU-iT7VBhx7VJvkRGUc6ozCJduveEHszAI4J_FzTG55DCxnF3M1kjzXRey-bN5f6n5CyUUvnW-4yQJh_cwiBhZDCOXs4.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA5OA4V6PRA7YCYIRG%2F20250430%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20250430T103322Z&X-Amz-Expires=86400&X-Amz-Signature=20c24be9d5ea45b5fda3d13463e7c9ea91b2813b3541126ebfbdc97b4d97eaa7&X-Amz-SignedHeaders=host&response-cache-control=No-cache&response-content-disposition=attachment%3B%20filename%3D%2267dc2d88012dabdb705c51c9_Snapinst.app_video_AQPuuFqL4SkuU-iT7VBhx7VJvkRGUc6ozCJduveEHszAI4J_FzTG55DCxnF3M1kjzXRey-bN5f6n5CyUUvnW-4yQJh_cwiBhZDCOXs4.mp4%22", + }, + ], + "urls": [], + "labels": [], + "socialIdentifier": "18032713838636836", + "socialLink": "https://www.instagram.com/reel/DIEZuNpi46I/", + "publishDate": "2025-04-05T14:47:07.015Z", + "isAutopilot": false, + "user": "67dc2d88012dabdb705c51c9", + "workspace": "67dc2eda012dabdb705c7970", +}; From b69f9aa887ca7db0293ba3ef9a27e5a542314e41 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 2 Jul 2025 15:29:53 -0400 Subject: [PATCH 03/10] pnpm-lock.yaml --- pnpm-lock.yaml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e27c4a5bf631d..526896c1bc517 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1048,7 +1048,11 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/asters: {} + components/asters: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/astica_ai: dependencies: @@ -29571,22 +29575,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please downgrade to v7.1.5 if you need IE/ActiveXObject support OR upgrade to v8.0.0 as we no longer support IE and published an incorrect patch version (see https://github.com/visionmedia/superagent/issues/1731) + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} From 8af17fd11ad6bffa63b9e5ffca7204c24fc15f73 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 2 Jul 2025 15:31:48 -0400 Subject: [PATCH 04/10] remove debug --- components/asters/asters.app.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/components/asters/asters.app.mjs b/components/asters/asters.app.mjs index f6d2bda372da7..2ff0f1dd13451 100644 --- a/components/asters/asters.app.mjs +++ b/components/asters/asters.app.mjs @@ -53,7 +53,6 @@ export default { headers: { "x-api-key": `${this.$auth.api_key}`, }, - debug: true, ...opts, }); }, From 89fb6e091367784162a0df23a4f2ac577169c48a Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 2 Jul 2025 15:33:16 -0400 Subject: [PATCH 05/10] update package.json --- components/asters/package.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/components/asters/package.json b/components/asters/package.json index 3b491e0e8fcd8..97d037eb0aa99 100644 --- a/components/asters/package.json +++ b/components/asters/package.json @@ -14,11 +14,5 @@ }, "dependencies": { "@pipedream/platform": "^3.1.0" - }, - "actions": { - "directory": "actions" - }, - "sources": { - "directory": "sources" } } From 9409e17f544244092bd459b95d31b8cb1782085e Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 2 Jul 2025 16:35:20 -0400 Subject: [PATCH 06/10] update --- components/asters/sources/common/base.mjs | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/asters/sources/common/base.mjs b/components/asters/sources/common/base.mjs index 2f9230be03e1e..34278eca97fda 100644 --- a/components/asters/sources/common/base.mjs +++ b/components/asters/sources/common/base.mjs @@ -8,8 +8,6 @@ export default { asters, db: "$.service.db", timer: { - label: "Polling interval", - description: "Pipedream will poll the Trello API on this schedule", type: "$.interface.timer", default: { intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, From 1c96ee9eb7135d985a7ada8b94ee5f5c85a46afd Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 2 Jul 2025 18:41:24 -0400 Subject: [PATCH 07/10] add doc link --- .../asters/sources/new-label-added/new-label-added.mjs | 2 +- components/asters/sources/new-label-added/test-event.mjs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/asters/sources/new-label-added/new-label-added.mjs b/components/asters/sources/new-label-added/new-label-added.mjs index ecf56bcc0f003..5502508b701c6 100644 --- a/components/asters/sources/new-label-added/new-label-added.mjs +++ b/components/asters/sources/new-label-added/new-label-added.mjs @@ -5,7 +5,7 @@ export default { ...common, key: "asters-new-label-added", name: "New Label Added", - description: "Emit new event when a label is added to a post.", + description: "Emit new event when a label is added to a post. [See the documentation](https://docs.asters.ai/api/endpoints/posts)", type: "source", version: "0.0.1", dedupe: "unique", diff --git a/components/asters/sources/new-label-added/test-event.mjs b/components/asters/sources/new-label-added/test-event.mjs index 0132ddc30eef7..5b7daaf2b0d85 100644 --- a/components/asters/sources/new-label-added/test-event.mjs +++ b/components/asters/sources/new-label-added/test-event.mjs @@ -13,7 +13,11 @@ export default { }, ], "urls": [], - "labels": [], + "labels": [ + { + "_id": "6811f76c3aa4bf3deb1e940b", + }, + ], "socialIdentifier": "18032713838636836", "socialLink": "https://www.instagram.com/reel/DIEZuNpi46I/", "publishDate": "2025-04-05T14:47:07.015Z", From 765405f6e9d64067b8cb564a17ffb1c452a43e8e Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 2 Jul 2025 18:41:55 -0400 Subject: [PATCH 08/10] pnpm-lock.yaml --- pnpm-lock.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 526896c1bc517..863bb7d7273ed 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15946,7 +15946,7 @@ importers: version: 3.1.7 ts-jest: specifier: ^29.2.5 - version: 29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2) + version: 29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2) tsup: specifier: ^8.3.6 version: 8.3.6(@microsoft/api-extractor@7.47.12(@types/node@20.17.30))(jiti@2.4.2)(postcss@8.4.49)(tsx@4.19.4)(typescript@5.7.2)(yaml@2.6.1) @@ -15989,7 +15989,7 @@ importers: version: 3.1.0 jest: specifier: ^29.1.2 - version: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0) + version: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0) type-fest: specifier: ^4.15.0 version: 4.27.0 @@ -50429,7 +50429,7 @@ snapshots: ts-interface-checker@0.1.13: {} - ts-jest@29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2): + ts-jest@29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2): dependencies: bs-logger: 0.2.6 ejs: 3.1.10 @@ -50443,10 +50443,10 @@ snapshots: typescript: 5.7.2 yargs-parser: 21.1.1 optionalDependencies: - '@babel/core': 7.26.0 + '@babel/core': 8.0.0-alpha.13 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@7.26.0) + babel-jest: 29.7.0(@babel/core@8.0.0-alpha.13) ts-jest@29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0))(typescript@5.6.3): dependencies: From 45f442abf436cbf777ade410ffe8ae12b06a8da0 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 2 Jul 2025 18:42:21 -0400 Subject: [PATCH 09/10] pnpm-lock.yaml --- pnpm-lock.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 863bb7d7273ed..526896c1bc517 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15946,7 +15946,7 @@ importers: version: 3.1.7 ts-jest: specifier: ^29.2.5 - version: 29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2) + version: 29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2) tsup: specifier: ^8.3.6 version: 8.3.6(@microsoft/api-extractor@7.47.12(@types/node@20.17.30))(jiti@2.4.2)(postcss@8.4.49)(tsx@4.19.4)(typescript@5.7.2)(yaml@2.6.1) @@ -15989,7 +15989,7 @@ importers: version: 3.1.0 jest: specifier: ^29.1.2 - version: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0) + version: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0) type-fest: specifier: ^4.15.0 version: 4.27.0 @@ -50429,7 +50429,7 @@ snapshots: ts-interface-checker@0.1.13: {} - ts-jest@29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2): + ts-jest@29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2): dependencies: bs-logger: 0.2.6 ejs: 3.1.10 @@ -50443,10 +50443,10 @@ snapshots: typescript: 5.7.2 yargs-parser: 21.1.1 optionalDependencies: - '@babel/core': 8.0.0-alpha.13 + '@babel/core': 7.26.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@8.0.0-alpha.13) + babel-jest: 29.7.0(@babel/core@7.26.0) ts-jest@29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0))(typescript@5.6.3): dependencies: From 31a03ee17407d77c93b4cd522e6ac6c60552e4ed Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Thu, 3 Jul 2025 12:46:29 -0400 Subject: [PATCH 10/10] updates --- components/asters/sources/common/base.mjs | 8 ++--- .../new-label-added/new-label-added.mjs | 17 +++++++---- .../sources/new-label-added/test-event.mjs | 30 +++---------------- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/components/asters/sources/common/base.mjs b/components/asters/sources/common/base.mjs index 34278eca97fda..c9854610a2a99 100644 --- a/components/asters/sources/common/base.mjs +++ b/components/asters/sources/common/base.mjs @@ -24,8 +24,8 @@ export default { generateMeta() { throw new ConfigurationError("generateMeta must be implemented"); }, - processResource() { - throw new ConfigurationError("processResource must be implemented"); + processResources() { + throw new ConfigurationError("processResources must be implemented"); }, }, async run() { @@ -34,8 +34,6 @@ export default { args: this.getArgs(), }); - for (const resource of resources) { - await this.processResource(resource); - } + await this.processResources(resources); }, }; diff --git a/components/asters/sources/new-label-added/new-label-added.mjs b/components/asters/sources/new-label-added/new-label-added.mjs index 5502508b701c6..a420abc76c964 100644 --- a/components/asters/sources/new-label-added/new-label-added.mjs +++ b/components/asters/sources/new-label-added/new-label-added.mjs @@ -45,11 +45,18 @@ export default { }, }; }, - async processResource(post) { - const { labels = [] } = post; - for (const label of labels) { - const meta = this.generateMeta(post, label); - this.$emit(post, meta); + async processResources(posts) { + const { data: allLabels } = await this.asters.listLabels({ + workspaceId: this.workspaceId, + }); + + for (const post of posts) { + const { labels = [] } = post; + for (const label of labels) { + const postLabel = allLabels.find((l) => l._id === label._id); + const meta = this.generateMeta(post, label); + this.$emit(postLabel, meta); + } } }, generateMeta(post, label) { diff --git a/components/asters/sources/new-label-added/test-event.mjs b/components/asters/sources/new-label-added/test-event.mjs index 5b7daaf2b0d85..4767a9eda016c 100644 --- a/components/asters/sources/new-label-added/test-event.mjs +++ b/components/asters/sources/new-label-added/test-event.mjs @@ -1,27 +1,5 @@ export default { - "_id": "67f1426b5d81d91673b9b2db", - "variantId": "faej60xwwyw", - "text": "Not just a dog β€” a heartbeat at our feet, a soul at peace 🐢✨", - "status": "published", - "medias": [ - { - "_id": "67dc38ae012dabdb705d4d53", - "type": "file", - "mimetype": "video/mp4", - "name": "67dc2d88012dabdb705c51c9_Snapinst.app_video_AQPuuFqL4SkuU-iT7VBhx7VJvkRGUc6ozCJduveEHszAI4J_FzTG55DCxnF3M1kjzXRey-bN5f6n5CyUUvnW-4yQJh_cwiBhZDCOXs4.mp4", - "url": "https://asters.s3.eu-central-1.amazonaws.com/67dc2d88012dabdb705c51c9_Snapinst.app_video_AQPuuFqL4SkuU-iT7VBhx7VJvkRGUc6ozCJduveEHszAI4J_FzTG55DCxnF3M1kjzXRey-bN5f6n5CyUUvnW-4yQJh_cwiBhZDCOXs4.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA5OA4V6PRA7YCYIRG%2F20250430%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20250430T103322Z&X-Amz-Expires=86400&X-Amz-Signature=20c24be9d5ea45b5fda3d13463e7c9ea91b2813b3541126ebfbdc97b4d97eaa7&X-Amz-SignedHeaders=host&response-cache-control=No-cache&response-content-disposition=attachment%3B%20filename%3D%2267dc2d88012dabdb705c51c9_Snapinst.app_video_AQPuuFqL4SkuU-iT7VBhx7VJvkRGUc6ozCJduveEHszAI4J_FzTG55DCxnF3M1kjzXRey-bN5f6n5CyUUvnW-4yQJh_cwiBhZDCOXs4.mp4%22", - }, - ], - "urls": [], - "labels": [ - { - "_id": "6811f76c3aa4bf3deb1e940b", - }, - ], - "socialIdentifier": "18032713838636836", - "socialLink": "https://www.instagram.com/reel/DIEZuNpi46I/", - "publishDate": "2025-04-05T14:47:07.015Z", - "isAutopilot": false, - "user": "67dc2d88012dabdb705c51c9", - "workspace": "67dc2eda012dabdb705c7970", -}; + "_id": "68656e18071c9698f12dcdeb", + "label": "label1", + "color": "blue" +}