From ac814a9c613f6f9943be8002110ca9e2433918b2 Mon Sep 17 00:00:00 2001 From: Elias Meire Date: Fri, 20 Oct 2023 13:43:55 +0200 Subject: [PATCH] feat(Facebook Lead Ads Trigger Node): Add Facebook Lead Ads Trigger Node (#7113) Github issue / Community forum post (link here to close automatically): https://community.n8n.io/t/facebook-lead-ads-integration/4590/19 --------- Co-authored-by: Marcus --- packages/core/bin/generate-ui-types | 16 + .../editor-ui/src/components/NodeWebhooks.vue | 6 +- .../FacebookLeadAdsOAuth2Api.credentials.ts | 52 +++ .../nodes/Facebook/FacebookTrigger.node.ts | 38 ++- packages/nodes-base/nodes/Facebook/types.ts | 29 ++ .../FacebookLeadAdsTrigger.node.json | 18 + .../FacebookLeadAdsTrigger.node.ts | 311 ++++++++++++++++++ .../nodes/FacebookLeadAds/GenericFunctions.ts | 222 +++++++++++++ .../nodes/FacebookLeadAds/facebook.svg | 1 + .../nodes/FacebookLeadAds/methods/index.ts | 1 + .../FacebookLeadAds/methods/listSearch.ts | 42 +++ .../nodes-base/nodes/FacebookLeadAds/types.ts | 105 ++++++ packages/nodes-base/package.json | 2 + packages/workflow/src/Interfaces.ts | 17 +- 14 files changed, 835 insertions(+), 25 deletions(-) create mode 100644 packages/nodes-base/credentials/FacebookLeadAdsOAuth2Api.credentials.ts create mode 100644 packages/nodes-base/nodes/Facebook/types.ts create mode 100644 packages/nodes-base/nodes/FacebookLeadAds/FacebookLeadAdsTrigger.node.json create mode 100644 packages/nodes-base/nodes/FacebookLeadAds/FacebookLeadAdsTrigger.node.ts create mode 100644 packages/nodes-base/nodes/FacebookLeadAds/GenericFunctions.ts create mode 100644 packages/nodes-base/nodes/FacebookLeadAds/facebook.svg create mode 100644 packages/nodes-base/nodes/FacebookLeadAds/methods/index.ts create mode 100644 packages/nodes-base/nodes/FacebookLeadAds/methods/listSearch.ts create mode 100644 packages/nodes-base/nodes/FacebookLeadAds/types.ts diff --git a/packages/core/bin/generate-ui-types b/packages/core/bin/generate-ui-types index 76ceae31fc..f320dea390 100755 --- a/packages/core/bin/generate-ui-types +++ b/packages/core/bin/generate-ui-types @@ -29,6 +29,21 @@ function findReferencedMethods(obj, refs = {}, latestName = '') { return refs; } +function addWebhookLifecycle(nodeType) { + if (nodeType.description.webhooks) { + nodeType.description.webhooks = nodeType.description.webhooks.map((webhook) => { + const webhookMethods = + nodeType?.webhookMethods?.[webhook.name] ?? nodeType?.webhookMethods?.default; + webhook.hasLifecycleMethods = Boolean( + webhookMethods?.checkExists && webhookMethods?.create && webhookMethods?.delete, + ); + return webhook; + }); + } + + return nodeType; +} + (async () => { const loader = new PackageDirectoryLoader(packageDir); await loader.loadAll(); @@ -60,6 +75,7 @@ function findReferencedMethods(obj, refs = {}, latestName = '') { .map((data) => { const nodeType = NodeHelpers.getVersionedNodeType(data.type); NodeHelpers.applySpecialNodeParameters(nodeType); + addWebhookLifecycle(nodeType); return data.type; }) .flatMap((nodeData) => { diff --git a/packages/editor-ui/src/components/NodeWebhooks.vue b/packages/editor-ui/src/components/NodeWebhooks.vue index 0b2ef78282..0fec295a7f 100644 --- a/packages/editor-ui/src/components/NodeWebhooks.vue +++ b/packages/editor-ui/src/components/NodeWebhooks.vue @@ -61,12 +61,12 @@