From c5fe9f1052ef4e2a4eb1d2ce948d541523f43a41 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 28 Oct 2024 15:32:37 -0400 Subject: [PATCH 1/2] updates --- components/jira/package.json | 2 +- components/jira/sources/common/common.mjs | 26 +++++++++++++++++++ components/jira/sources/events/events.mjs | 2 +- .../sources/issue-created/issue-created.mjs | 2 +- .../sources/issue-deleted/issue-deleted.mjs | 2 +- .../sources/issue-updated/issue-updated.mjs | 2 +- 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/components/jira/package.json b/components/jira/package.json index e12af30ad40e6..a40a0d335e23c 100644 --- a/components/jira/package.json +++ b/components/jira/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/jira", - "version": "0.1.2", + "version": "0.1.3", "description": "Pipedream Jira Components", "main": "jira.app.mjs", "keywords": [ diff --git a/components/jira/sources/common/common.mjs b/components/jira/sources/common/common.mjs index 0532476f7f768..d25fc992239e4 100644 --- a/components/jira/sources/common/common.mjs +++ b/components/jira/sources/common/common.mjs @@ -21,6 +21,13 @@ export default { ], description: "The JQL filter that specifies which issues the webhook is sent for, only a subset of JQL can be used, e.g. `project = P1` [See supported JQL filters](https://developer.atlassian.com/cloud/jira/service-desk/webhooks/#supported-jql-queries)", }, + overrideExistingWebhooks: { + type: "boolean", + label: "Override Existing Webhooks", + description: "Override existing webhooks with this new Pipedream source's webhook. Recommend to set this to `true` if you have an existing Jira webhook that you no longer use and want to override with the new Pipedream source.", + default: false, + optional: true, + }, }, methods: { _getHookID() { @@ -91,9 +98,28 @@ export default { ts, }; }, + async deleteExistingWebhooks() { + const resourcesStream = await this.jira.getResourcesStream({ + cloudId: this.cloudId, + resourceFn: this.jira.getWebhook, + resourceFnArgs: { + params: {}, + }, + resourceFiltererFn: (resource) => resource.values, + }); + for await (const webhook of resourcesStream) { + await this.jira.deleteHook({ + hookId: webhook.id, + cloudId: this.cloudId, + }); + } + }, }, hooks: { async activate() { + if (this.overrideExistingWebhooks) { + await this.deleteExistingWebhooks(); + } const { hookId } = await this.jira.createHook({ url: this.http.endpoint, events: this.getEvents(), diff --git a/components/jira/sources/events/events.mjs b/components/jira/sources/events/events.mjs index 2331c35d109ed..1329faa50e701 100644 --- a/components/jira/sources/events/events.mjs +++ b/components/jira/sources/events/events.mjs @@ -5,7 +5,7 @@ export default { key: "jira-events", name: "New Event", description: "Emit new event when an event with subscribed event source triggered, [See the docs](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-webhooks/#api-rest-api-3-webhook-post)", - version: "0.0.9", + version: "0.0.10", type: "source", dedupe: "unique", ...common, diff --git a/components/jira/sources/issue-created/issue-created.mjs b/components/jira/sources/issue-created/issue-created.mjs index b696d3acd974a..683cf7884a872 100644 --- a/components/jira/sources/issue-created/issue-created.mjs +++ b/components/jira/sources/issue-created/issue-created.mjs @@ -4,7 +4,7 @@ export default { key: "jira-issue-created", name: "New Issue Created Event", description: "Emit new event when an issue is created. Note that Jira supports only one webhook, if more sources are needed please use `New Event` source and select multiple events.", - version: "0.0.9", + version: "0.0.10", type: "source", dedupe: "unique", ...common, diff --git a/components/jira/sources/issue-deleted/issue-deleted.mjs b/components/jira/sources/issue-deleted/issue-deleted.mjs index b8e73b78554ae..f4b644f1ba6c8 100644 --- a/components/jira/sources/issue-deleted/issue-deleted.mjs +++ b/components/jira/sources/issue-deleted/issue-deleted.mjs @@ -4,7 +4,7 @@ export default { key: "jira-issue-deleted", name: "New Issue Deleted Event", description: "Emit new event when an issue is deleted. Note that Jira supports only one webhook, if more sources are needed please use `New Event` source and select multiple events.", - version: "0.0.9", + version: "0.0.10", type: "source", dedupe: "unique", ...common, diff --git a/components/jira/sources/issue-updated/issue-updated.mjs b/components/jira/sources/issue-updated/issue-updated.mjs index 6ce2287dfafc8..4faf21a9af1c1 100644 --- a/components/jira/sources/issue-updated/issue-updated.mjs +++ b/components/jira/sources/issue-updated/issue-updated.mjs @@ -4,7 +4,7 @@ export default { key: "jira-issue-updated", name: "New Issue Updated Event", description: "Emit new event when an issue is updated. Note that Jira supports only one webhook, if more sources are needed please use `New Event` source and select multiple events.", - version: "0.0.9", + version: "0.0.10", type: "source", dedupe: "unique", ...common, From 8e5f8cf6fe8034c2fc458d812c12a50848ad37f0 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Wed, 30 Oct 2024 14:19:05 -0400 Subject: [PATCH 2/2] add (Instant) to source names --- components/jira/sources/issue-created/issue-created.mjs | 2 +- components/jira/sources/issue-deleted/issue-deleted.mjs | 2 +- components/jira/sources/issue-updated/issue-updated.mjs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/jira/sources/issue-created/issue-created.mjs b/components/jira/sources/issue-created/issue-created.mjs index 683cf7884a872..1699d666fa308 100644 --- a/components/jira/sources/issue-created/issue-created.mjs +++ b/components/jira/sources/issue-created/issue-created.mjs @@ -2,7 +2,7 @@ import common from "../common/common.mjs"; export default { key: "jira-issue-created", - name: "New Issue Created Event", + name: "New Issue Created Event (Instant)", description: "Emit new event when an issue is created. Note that Jira supports only one webhook, if more sources are needed please use `New Event` source and select multiple events.", version: "0.0.10", type: "source", diff --git a/components/jira/sources/issue-deleted/issue-deleted.mjs b/components/jira/sources/issue-deleted/issue-deleted.mjs index f4b644f1ba6c8..90e34de11b911 100644 --- a/components/jira/sources/issue-deleted/issue-deleted.mjs +++ b/components/jira/sources/issue-deleted/issue-deleted.mjs @@ -2,7 +2,7 @@ import common from "../common/common.mjs"; export default { key: "jira-issue-deleted", - name: "New Issue Deleted Event", + name: "New Issue Deleted Event (Instant)", description: "Emit new event when an issue is deleted. Note that Jira supports only one webhook, if more sources are needed please use `New Event` source and select multiple events.", version: "0.0.10", type: "source", diff --git a/components/jira/sources/issue-updated/issue-updated.mjs b/components/jira/sources/issue-updated/issue-updated.mjs index 4faf21a9af1c1..71e7e82a74069 100644 --- a/components/jira/sources/issue-updated/issue-updated.mjs +++ b/components/jira/sources/issue-updated/issue-updated.mjs @@ -2,7 +2,7 @@ import common from "../common/common.mjs"; export default { key: "jira-issue-updated", - name: "New Issue Updated Event", + name: "New Issue Updated Event (Instant)", description: "Emit new event when an issue is updated. Note that Jira supports only one webhook, if more sources are needed please use `New Event` source and select multiple events.", version: "0.0.10", type: "source",