piece-snapchat-leads 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +14 -4
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +19 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/get-lead-details.d.ts +6 -0
- package/src/lib/actions/get-lead-details.d.ts.map +1 -0
- package/src/lib/actions/get-lead-details.js +40 -0
- package/src/lib/actions/get-lead-details.js.map +1 -0
- package/src/lib/actions/list-lead-forms.d.ts +4 -0
- package/src/lib/actions/list-lead-forms.d.ts.map +1 -0
- package/src/lib/actions/list-lead-forms.js +26 -0
- package/src/lib/actions/list-lead-forms.js.map +1 -0
- package/src/lib/auth.d.ts +2 -0
- package/src/lib/auth.d.ts.map +1 -0
- package/src/lib/auth.js +48 -0
- package/src/lib/auth.js.map +1 -0
- package/src/lib/common.d.ts +61 -0
- package/src/lib/common.d.ts.map +1 -0
- package/src/lib/common.js +350 -0
- package/src/lib/common.js.map +1 -0
- package/src/lib/props.d.ts +5 -0
- package/src/lib/props.d.ts.map +1 -0
- package/src/lib/props.js +87 -0
- package/src/lib/props.js.map +1 -0
- package/src/lib/triggers/new-lead.d.ts +15 -0
- package/src/lib/triggers/new-lead.d.ts.map +1 -0
- package/src/lib/triggers/new-lead.js +81 -0
- package/src/lib/triggers/new-lead.js.map +1 -0
- package/README.md +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@activepieces/pieces-common": "0.12.3",
|
|
4
|
+
"@activepieces/pieces-framework": "0.27.2",
|
|
5
|
+
"@activepieces/shared": "0.66.0",
|
|
6
|
+
"tslib": "2.6.2"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/src/index.js",
|
|
2
9
|
"name": "piece-snapchat-leads",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc -p tsconfig.lib.json && cp package.json dist/",
|
|
12
|
+
"lint": "eslint 'src/**/*.ts'"
|
|
13
|
+
},
|
|
14
|
+
"types": "./dist/src/index.d.ts",
|
|
15
|
+
"version": "0.0.2"
|
|
16
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,+JASxB,CAAC"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.snapchatLeads = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
|
+
const auth_1 = require("./lib/auth");
|
|
6
|
+
const get_lead_details_1 = require("./lib/actions/get-lead-details");
|
|
7
|
+
const list_lead_forms_1 = require("./lib/actions/list-lead-forms");
|
|
8
|
+
const new_lead_1 = require("./lib/triggers/new-lead");
|
|
9
|
+
exports.snapchatLeads = (0, pieces_framework_1.createPiece)({
|
|
10
|
+
displayName: 'Snapchat Leads',
|
|
11
|
+
description: 'Receive Snapchat lead form submissions as they arrive, and list the lead forms of an ad account.',
|
|
12
|
+
minimumSupportedRelease: '0.82.0',
|
|
13
|
+
logoUrl: 'https://cdn.simpleicons.org/snapchat',
|
|
14
|
+
authors: [],
|
|
15
|
+
auth: auth_1.snapchatLeadsAuth,
|
|
16
|
+
actions: [get_lead_details_1.getLeadDetails, list_lead_forms_1.listLeadForms],
|
|
17
|
+
triggers: [new_lead_1.newLead],
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,qEAA6D;AAC7D,qCAA+C;AAC/C,qEAAgE;AAChE,mEAA8D;AAC9D,sDAAkD;AAErC,QAAA,aAAa,GAAG,IAAA,8BAAW,EAAC;IACvC,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,kGAAkG;IAC/G,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,sCAAsC;IAC/C,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,wBAAiB;IACvB,OAAO,EAAE,CAAC,iCAAc,EAAE,+BAAa,CAAC;IACxC,QAAQ,EAAE,CAAC,kBAAO,CAAC;CACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getLeadDetails: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
adAccountId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
3
|
+
formId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
4
|
+
leadId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=get-lead-details.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-lead-details.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-lead-details.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc;;;;EA6BzB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLeadDetails = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const props_1 = require("../props");
|
|
9
|
+
exports.getLeadDetails = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.snapchatLeadsAuth,
|
|
11
|
+
name: 'snapchat_leads_get_lead_details',
|
|
12
|
+
displayName: 'Get Lead Details',
|
|
13
|
+
description: "Snapchat's public API has no endpoint to fetch one lead by its lead ID — the New Lead trigger already delivers the full lead with all of its answers. This action returns the lead form's definition (its questions, title, and description) for the given lead, so answers from the trigger can be mapped to questions.",
|
|
14
|
+
props: {
|
|
15
|
+
adAccountId: props_1.snapchatLeadsProps.adAccountDropdown,
|
|
16
|
+
formId: props_1.snapchatLeadsProps.formDropdown,
|
|
17
|
+
leadId: pieces_framework_1.Property.ShortText({
|
|
18
|
+
displayName: 'Lead ID',
|
|
19
|
+
description: 'The lead_id from a New Lead trigger.',
|
|
20
|
+
required: true,
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
run(context) {
|
|
24
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const { auth, propsValue } = context;
|
|
26
|
+
const form = yield common_1.snapchatLeadsCommon.getLeadForm({
|
|
27
|
+
auth,
|
|
28
|
+
formId: propsValue.formId,
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
lead_id: propsValue.leadId,
|
|
32
|
+
form_id: propsValue.formId,
|
|
33
|
+
ad_account_id: propsValue.adAccountId,
|
|
34
|
+
form,
|
|
35
|
+
note: "Snapchat's public API has no per-lead GET endpoint; the lead's answers arrive in the New Lead trigger payload. This returns the form definition for that lead.",
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=get-lead-details.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-lead-details.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-lead-details.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,kCAA4C;AAC5C,sCAAgD;AAChD,oCAA8C;AAEjC,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,wBAAiB;IACvB,IAAI,EAAE,iCAAiC;IACvC,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EACT,0TAA0T;IAC5T,KAAK,EAAE;QACL,WAAW,EAAE,0BAAkB,CAAC,iBAAiB;QACjD,MAAM,EAAE,0BAAkB,CAAC,YAAY;QACvC,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,sCAAsC;YACnD,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;YACrC,MAAM,IAAI,GAAG,MAAM,4BAAmB,CAAC,WAAW,CAAC;gBACjD,IAAI;gBACJ,MAAM,EAAE,UAAU,CAAC,MAAM;aAC1B,CAAC,CAAC;YACH,OAAO;gBACL,OAAO,EAAE,UAAU,CAAC,MAAM;gBAC1B,OAAO,EAAE,UAAU,CAAC,MAAM;gBAC1B,aAAa,EAAE,UAAU,CAAC,WAAW;gBACrC,IAAI;gBACJ,IAAI,EAAE,gKAAgK;aACvK,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const listLeadForms: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
adAccountId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
3
|
+
}>;
|
|
4
|
+
//# sourceMappingURL=list-lead-forms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-lead-forms.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/list-lead-forms.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa;;EAexB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listLeadForms = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const props_1 = require("../props");
|
|
9
|
+
exports.listLeadForms = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.snapchatLeadsAuth,
|
|
11
|
+
name: 'snapchat_leads_list_lead_forms',
|
|
12
|
+
displayName: 'List Lead Forms',
|
|
13
|
+
description: 'Lists the lead forms of the selected ad account, each with its ID, name, title, and description.',
|
|
14
|
+
props: {
|
|
15
|
+
adAccountId: props_1.snapchatLeadsProps.adAccountDropdown,
|
|
16
|
+
},
|
|
17
|
+
run(context) {
|
|
18
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return yield common_1.snapchatLeadsCommon.listLeadForms({
|
|
20
|
+
auth: context.auth,
|
|
21
|
+
adAccountId: context.propsValue.adAccountId,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=list-lead-forms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-lead-forms.js","sourceRoot":"","sources":["../../../../src/lib/actions/list-lead-forms.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,kCAA4C;AAC5C,sCAAgD;AAChD,oCAA8C;AAEjC,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACxC,IAAI,EAAE,wBAAiB;IACvB,IAAI,EAAE,gCAAgC;IACtC,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EACT,kGAAkG;IACpG,KAAK,EAAE;QACL,WAAW,EAAE,0BAAkB,CAAC,iBAAiB;KAClD;IACK,GAAG,CAAC,OAAO;;YACf,OAAO,MAAM,4BAAmB,CAAC,aAAa,CAAC;gBAC7C,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW;aAC5C,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,iBAAiB,+GAoB5B,CAAC"}
|
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.snapchatLeadsAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
const authGuide = `
|
|
8
|
+
Snapchat access tokens live about 1 hour, so this connection uses the
|
|
9
|
+
standard OAuth2 flow and Activepieces refreshes the token automatically —
|
|
10
|
+
no token is ever pasted here.
|
|
11
|
+
|
|
12
|
+
1. In Snap Business Manager, create a NEW OAuth app for this connection
|
|
13
|
+
(an existing app's redirect URI cannot be changed — Snap locks it at
|
|
14
|
+
creation). Set the new app's redirect URI to:
|
|
15
|
+
https://activepieces.mediabuyer.tech/redirect
|
|
16
|
+
2. Copy the app's Client ID and Client Secret into the fields below.
|
|
17
|
+
3. Click Connect and authorize as an Organization Admin. The app needs the
|
|
18
|
+
snapchat-marketing-api scope, which covers both reporting reads and lead
|
|
19
|
+
webhooks.
|
|
20
|
+
|
|
21
|
+
The user who authorizes must be an Organization Admin on the ad accounts
|
|
22
|
+
whose lead forms this connection will use — Snapchat only lets an admin
|
|
23
|
+
register a form's lead webhook, and a form can send its leads to one
|
|
24
|
+
destination only.
|
|
25
|
+
`;
|
|
26
|
+
exports.snapchatLeadsAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
27
|
+
required: true,
|
|
28
|
+
description: authGuide,
|
|
29
|
+
authUrl: 'https://accounts.snapchat.com/login/oauth2/authorize',
|
|
30
|
+
tokenUrl: 'https://accounts.snapchat.com/login/oauth2/access_token',
|
|
31
|
+
scope: ['snapchat-marketing-api'],
|
|
32
|
+
prompt: 'omit',
|
|
33
|
+
authorizationMethod: pieces_framework_1.OAuth2AuthorizationMethod.BODY,
|
|
34
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
35
|
+
try {
|
|
36
|
+
yield common_1.snapchatLeadsCommon.listAdAccounts(auth);
|
|
37
|
+
return { valid: true };
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const detail = error instanceof Error && error.message !== '' ? error.message : '';
|
|
41
|
+
return {
|
|
42
|
+
valid: false,
|
|
43
|
+
error: `Invalid Snapchat credentials: could not list ad accounts with this connection. Check that the app is authorized with the snapchat-marketing-api scope.${detail !== '' ? ` Snapchat said: ${detail}` : ''}`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAAsF;AACtF,qCAA+C;AAE/C,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;CAkBjB,CAAC;AAEW,QAAA,iBAAiB,GAAG,4BAAS,CAAC,MAAM,CAAC;IAChD,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,SAAS;IACtB,OAAO,EAAE,sDAAsD;IAC/D,QAAQ,EAAE,yDAAyD;IACnE,KAAK,EAAE,CAAC,wBAAwB,CAAC;IACjC,MAAM,EAAE,MAAM;IACd,mBAAmB,EAAE,4CAAyB,CAAC,IAAI;IACnD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,4BAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC/C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YACnF,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,yJAAyJ,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;aACnN,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
declare function listAdAccounts(auth: SnapAuth): Promise<AdAccount[]>;
|
|
2
|
+
declare function listLeadForms(params: {
|
|
3
|
+
auth: SnapAuth;
|
|
4
|
+
adAccountId: string;
|
|
5
|
+
}): Promise<LeadForm[]>;
|
|
6
|
+
declare function getLeadForm(params: {
|
|
7
|
+
auth: SnapAuth;
|
|
8
|
+
formId: string;
|
|
9
|
+
}): Promise<Record<string, unknown>>;
|
|
10
|
+
declare function listLeadWebhooks(params: {
|
|
11
|
+
auth: SnapAuth;
|
|
12
|
+
formId: string;
|
|
13
|
+
}): Promise<LeadWebhook[]>;
|
|
14
|
+
declare function createLeadWebhook(params: {
|
|
15
|
+
auth: SnapAuth;
|
|
16
|
+
formId: string;
|
|
17
|
+
webhookUrl: string;
|
|
18
|
+
}): Promise<CreatedLeadWebhook>;
|
|
19
|
+
declare function deleteLeadWebhook(params: {
|
|
20
|
+
auth: SnapAuth;
|
|
21
|
+
webhookId: string;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
declare function parseLeadWebhook(body: unknown): Record<string, string>;
|
|
24
|
+
export declare const snapchatLeadsCommon: {
|
|
25
|
+
listAdAccounts: typeof listAdAccounts;
|
|
26
|
+
listLeadForms: typeof listLeadForms;
|
|
27
|
+
getLeadForm: typeof getLeadForm;
|
|
28
|
+
listLeadWebhooks: typeof listLeadWebhooks;
|
|
29
|
+
createLeadWebhook: typeof createLeadWebhook;
|
|
30
|
+
deleteLeadWebhook: typeof deleteLeadWebhook;
|
|
31
|
+
parseLeadWebhook: typeof parseLeadWebhook;
|
|
32
|
+
};
|
|
33
|
+
export type SnapAuth = {
|
|
34
|
+
access_token: string;
|
|
35
|
+
};
|
|
36
|
+
export type SnapApiResponse = Record<string, unknown> & {
|
|
37
|
+
request_status?: string;
|
|
38
|
+
error_code?: string;
|
|
39
|
+
debug_message?: string;
|
|
40
|
+
display_message?: string;
|
|
41
|
+
};
|
|
42
|
+
export type AdAccount = {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
};
|
|
46
|
+
export type LeadForm = {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
title: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
export type LeadWebhook = {
|
|
53
|
+
id: string;
|
|
54
|
+
url: string;
|
|
55
|
+
};
|
|
56
|
+
export type CreatedLeadWebhook = {
|
|
57
|
+
id: string;
|
|
58
|
+
secret: string;
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/lib/common.ts"],"names":[],"mappings":"AA+EA,iBAAe,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAsBlE;AAED,i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EF,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.snapchatLeadsCommon = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const baseUrl = 'https://adsapi.snapchat.com/v1';
|
|
7
|
+
function isRecord(value) {
|
|
8
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function toStringValue(value) {
|
|
11
|
+
if (value === null || value === undefined) {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
if (typeof value === 'string') {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
18
|
+
return String(value);
|
|
19
|
+
}
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
function toIsoString(value) {
|
|
23
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
24
|
+
const millis = value < 10000000000 ? value * 1000 : value;
|
|
25
|
+
return new Date(millis).toISOString();
|
|
26
|
+
}
|
|
27
|
+
if (typeof value === 'string' && value !== '') {
|
|
28
|
+
const parsed = Number(value);
|
|
29
|
+
if (Number.isFinite(parsed)) {
|
|
30
|
+
const millis = parsed < 10000000000 ? parsed * 1000 : parsed;
|
|
31
|
+
return new Date(millis).toISOString();
|
|
32
|
+
}
|
|
33
|
+
const date = new Date(value);
|
|
34
|
+
if (!Number.isNaN(date.getTime())) {
|
|
35
|
+
return date.toISOString();
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
function assertSnapSuccess(response, action) {
|
|
42
|
+
const status = toStringValue(response['request_status']);
|
|
43
|
+
if (status !== '' && status !== 'SUCCESS') {
|
|
44
|
+
const code = toStringValue(response['error_code']);
|
|
45
|
+
const detail = toStringValue(response['debug_message']) !== ''
|
|
46
|
+
? toStringValue(response['debug_message'])
|
|
47
|
+
: toStringValue(response['display_message']);
|
|
48
|
+
throw new Error(`${action}: Snapchat returned ${status}${code !== '' ? ` (code ${code})` : ''}${detail !== '' ? `: ${detail}` : ''}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function unwrapEntities(body, plural, singular) {
|
|
52
|
+
const list = body[plural];
|
|
53
|
+
if (!Array.isArray(list)) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
const entities = [];
|
|
57
|
+
for (const item of list) {
|
|
58
|
+
if (!isRecord(item)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const wrapped = item[singular];
|
|
62
|
+
if (isRecord(wrapped)) {
|
|
63
|
+
entities.push(wrapped);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
entities.push(item);
|
|
67
|
+
}
|
|
68
|
+
return entities;
|
|
69
|
+
}
|
|
70
|
+
function bearerHeaders(auth) {
|
|
71
|
+
return {
|
|
72
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function listAdAccounts(auth) {
|
|
76
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
78
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
79
|
+
url: `${baseUrl}/me/adaccounts`,
|
|
80
|
+
headers: bearerHeaders(auth),
|
|
81
|
+
queryParams: {
|
|
82
|
+
limit: '1000',
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
assertSnapSuccess(response.body, 'Failed to list ad accounts');
|
|
86
|
+
const accounts = [];
|
|
87
|
+
for (const entity of unwrapEntities(response.body, 'adaccounts', 'adaccount')) {
|
|
88
|
+
const id = toStringValue(entity['id']);
|
|
89
|
+
if (id === '') {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
accounts.push({
|
|
93
|
+
id,
|
|
94
|
+
name: toStringValue(entity['name']),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return accounts;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function listLeadForms(params) {
|
|
101
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
103
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
104
|
+
url: `${baseUrl}/adaccounts/${params.adAccountId}/lead_generation_forms`,
|
|
105
|
+
headers: bearerHeaders(params.auth),
|
|
106
|
+
queryParams: {
|
|
107
|
+
limit: '1000',
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
assertSnapSuccess(response.body, 'Failed to list lead forms');
|
|
111
|
+
const forms = [];
|
|
112
|
+
for (const entity of unwrapEntities(response.body, 'lead_generation_forms', 'lead_generation_form')) {
|
|
113
|
+
const id = toStringValue(entity['id']);
|
|
114
|
+
if (id === '') {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
forms.push({
|
|
118
|
+
id,
|
|
119
|
+
name: toStringValue(entity['name']),
|
|
120
|
+
title: toStringValue(entity['title']),
|
|
121
|
+
description: toStringValue(entity['description']),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return forms;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function getLeadForm(params) {
|
|
128
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
130
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
131
|
+
url: `${baseUrl}/lead_generation_forms/${params.formId}`,
|
|
132
|
+
headers: bearerHeaders(params.auth),
|
|
133
|
+
});
|
|
134
|
+
assertSnapSuccess(response.body, 'Failed to fetch lead form');
|
|
135
|
+
const entities = unwrapEntities(response.body, 'lead_generation_forms', 'lead_generation_form');
|
|
136
|
+
if (entities.length > 0) {
|
|
137
|
+
return entities[0];
|
|
138
|
+
}
|
|
139
|
+
const single = response.body['lead_generation_form'];
|
|
140
|
+
if (isRecord(single)) {
|
|
141
|
+
return single;
|
|
142
|
+
}
|
|
143
|
+
return {};
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function listLeadWebhooks(params) {
|
|
147
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
149
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
150
|
+
url: `${baseUrl}/lead_generation_forms/${params.formId}/lead_webhooks`,
|
|
151
|
+
headers: bearerHeaders(params.auth),
|
|
152
|
+
});
|
|
153
|
+
assertSnapSuccess(response.body, 'Failed to list lead webhooks');
|
|
154
|
+
const webhooks = [];
|
|
155
|
+
for (const entity of unwrapEntities(response.body, 'lead_webhooks', 'lead_webhook')) {
|
|
156
|
+
const id = toStringValue(entity['id']);
|
|
157
|
+
if (id === '') {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
webhooks.push({
|
|
161
|
+
id,
|
|
162
|
+
url: toStringValue(entity['url']),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return webhooks;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function createLeadWebhook(params) {
|
|
169
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
// Snapchat allows one lead webhook per form. Reuse the registration when
|
|
171
|
+
// this flow is already the destination, and refuse to steal a form that
|
|
172
|
+
// already sends its leads elsewhere — that destination must release it
|
|
173
|
+
// first.
|
|
174
|
+
const existing = yield listLeadWebhooks({ auth: params.auth, formId: params.formId });
|
|
175
|
+
for (const webhook of existing) {
|
|
176
|
+
if (webhook.url === params.webhookUrl) {
|
|
177
|
+
return { id: webhook.id, secret: '' };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (existing.length > 0) {
|
|
181
|
+
throw new Error('Failed to register lead webhook: this form already sends its leads to another destination (Snapchat allows one lead webhook per form). Release it there first, then enable this flow.');
|
|
182
|
+
}
|
|
183
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
184
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
185
|
+
url: `${baseUrl}/lead_generation_forms/${params.formId}/lead_webhooks`,
|
|
186
|
+
headers: Object.assign(Object.assign({}, bearerHeaders(params.auth)), { 'Content-Type': 'application/json' }),
|
|
187
|
+
body: {
|
|
188
|
+
lead_webhooks: [{ url: params.webhookUrl }],
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
assertSnapSuccess(response.body, 'Failed to register lead webhook');
|
|
192
|
+
const entities = unwrapEntities(response.body, 'lead_webhooks', 'lead_webhook');
|
|
193
|
+
if (entities.length === 0) {
|
|
194
|
+
throw new Error('Failed to register lead webhook: Snapchat did not return a webhook id');
|
|
195
|
+
}
|
|
196
|
+
const created = entities[0];
|
|
197
|
+
const id = toStringValue(created['id']);
|
|
198
|
+
if (id === '') {
|
|
199
|
+
throw new Error('Failed to register lead webhook: Snapchat did not return a webhook id');
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
id,
|
|
203
|
+
secret: toStringValue(created['secret']) !== ''
|
|
204
|
+
? toStringValue(created['secret'])
|
|
205
|
+
: toStringValue(created['signing_secret']) !== ''
|
|
206
|
+
? toStringValue(created['signing_secret'])
|
|
207
|
+
: toStringValue(created['webhook_secret']),
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function deleteLeadWebhook(params) {
|
|
212
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
213
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
214
|
+
method: pieces_common_1.HttpMethod.DELETE,
|
|
215
|
+
url: `${baseUrl}/lead_webhooks/${params.webhookId}`,
|
|
216
|
+
headers: bearerHeaders(params.auth),
|
|
217
|
+
});
|
|
218
|
+
assertSnapSuccess(response.body, 'Failed to delete lead webhook');
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function parseLeadWebhook(body) {
|
|
222
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
223
|
+
const output = {};
|
|
224
|
+
if (!isRecord(body)) {
|
|
225
|
+
return output;
|
|
226
|
+
}
|
|
227
|
+
// Snapchat's delivery shape is not published in the public docs, so unwrap
|
|
228
|
+
// the common envelopes defensively: a flat object, a nested lead object,
|
|
229
|
+
// or a data/payload wrapper.
|
|
230
|
+
let lead = body;
|
|
231
|
+
for (const key of ['lead', 'data', 'payload']) {
|
|
232
|
+
const nested = body[key];
|
|
233
|
+
if (isRecord(nested)) {
|
|
234
|
+
lead = nested;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// Every answer becomes an output keyed by its field name, whatever the
|
|
239
|
+
// form asks. Nothing about the form's questions is hardcoded, so a form
|
|
240
|
+
// can add, rename, or remove questions and new leads carry the new
|
|
241
|
+
// questions as outputs with no piece change.
|
|
242
|
+
const answerKeys = ['answers', 'form_fields', 'field_data', 'responses', 'questions', 'fields'];
|
|
243
|
+
for (const key of answerKeys) {
|
|
244
|
+
const answers = lead[key];
|
|
245
|
+
if (!Array.isArray(answers)) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
for (const answer of answers) {
|
|
249
|
+
if (!isRecord(answer)) {
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const field = toStringValue((_d = (_c = (_b = (_a = answer['field']) !== null && _a !== void 0 ? _a : answer['question']) !== null && _b !== void 0 ? _b : answer['name']) !== null && _c !== void 0 ? _c : answer['label']) !== null && _d !== void 0 ? _d : answer['key']);
|
|
253
|
+
if (field === '') {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
const value = (_f = (_e = answer['value']) !== null && _e !== void 0 ? _e : answer['answer']) !== null && _f !== void 0 ? _f : answer['response'];
|
|
257
|
+
output[field] = toStringValue(value);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const skippedKeys = new Set([...answerKeys, 'lead', 'data', 'payload']);
|
|
261
|
+
for (const [key, value] of Object.entries(lead)) {
|
|
262
|
+
if (skippedKeys.has(key)) {
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (isRecord(value)) {
|
|
266
|
+
// Nested objects like campaign / ad_squad / ad / form / ad_account
|
|
267
|
+
// flatten to <key>_id and <key>_name when they carry them.
|
|
268
|
+
const nestedId = toStringValue(value['id']);
|
|
269
|
+
const nestedName = toStringValue(value['name']);
|
|
270
|
+
if (nestedId !== '' || nestedName !== '') {
|
|
271
|
+
output[`${key}_id`] = nestedId;
|
|
272
|
+
output[`${key}_name`] = nestedName;
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
output[key] = JSON.stringify(value);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (Array.isArray(value)) {
|
|
279
|
+
output[key] = JSON.stringify(value);
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
output[key] = toStringValue(value);
|
|
283
|
+
}
|
|
284
|
+
// Convenience keys for the standard fields, so flows can map name and
|
|
285
|
+
// phone without knowing the form's exact field names.
|
|
286
|
+
if (output['name'] === undefined || output['name'] === '') {
|
|
287
|
+
const fullName = toStringValue(lead['full_name']);
|
|
288
|
+
const firstName = toStringValue(lead['first_name']);
|
|
289
|
+
const lastName = toStringValue(lead['last_name']);
|
|
290
|
+
output['name'] = fullName !== '' ? fullName : `${firstName} ${lastName}`.trim();
|
|
291
|
+
}
|
|
292
|
+
if (output['phone'] === undefined || output['phone'] === '') {
|
|
293
|
+
output['phone'] = toStringValue(lead['phone']) !== '' ? toStringValue(lead['phone']) : toStringValue(lead['phone_number']);
|
|
294
|
+
}
|
|
295
|
+
if (output['email'] === undefined) {
|
|
296
|
+
output['email'] = '';
|
|
297
|
+
}
|
|
298
|
+
// Meta fields last, so a form question can never overwrite them. A flat
|
|
299
|
+
// value in the payload wins; otherwise keep what the nested flattening
|
|
300
|
+
// already found, so a campaign carried as an object is not lost.
|
|
301
|
+
const createdAt = toIsoString(lead['created_at']) !== ''
|
|
302
|
+
? toIsoString(lead['created_at'])
|
|
303
|
+
: toIsoString(lead['submitted_at']) !== ''
|
|
304
|
+
? toIsoString(lead['submitted_at'])
|
|
305
|
+
: toIsoString(lead['timestamp']) !== ''
|
|
306
|
+
? toIsoString(lead['timestamp'])
|
|
307
|
+
: toIsoString(lead['date']);
|
|
308
|
+
output['created_at'] = createdAt !== '' ? createdAt : ((_g = output['created_at']) !== null && _g !== void 0 ? _g : '');
|
|
309
|
+
output['lead_id'] =
|
|
310
|
+
toStringValue(lead['lead_id']) !== ''
|
|
311
|
+
? toStringValue(lead['lead_id'])
|
|
312
|
+
: toStringValue(lead['id']) !== ''
|
|
313
|
+
? toStringValue(lead['id'])
|
|
314
|
+
: ((_h = output['lead_id']) !== null && _h !== void 0 ? _h : '');
|
|
315
|
+
output['form_id'] = toStringValue(lead['form_id']) !== '' ? toStringValue(lead['form_id']) : ((_j = output['form_id']) !== null && _j !== void 0 ? _j : '');
|
|
316
|
+
output['form_name'] = toStringValue(lead['form_name']) !== '' ? toStringValue(lead['form_name']) : ((_k = output['form_name']) !== null && _k !== void 0 ? _k : '');
|
|
317
|
+
output['ad_account_id'] =
|
|
318
|
+
toStringValue(lead['ad_account_id']) !== '' ? toStringValue(lead['ad_account_id']) : ((_l = output['ad_account_id']) !== null && _l !== void 0 ? _l : '');
|
|
319
|
+
output['ad_account_name'] =
|
|
320
|
+
toStringValue(lead['ad_account_name']) !== '' ? toStringValue(lead['ad_account_name']) : ((_m = output['ad_account_name']) !== null && _m !== void 0 ? _m : '');
|
|
321
|
+
output['campaign_id'] =
|
|
322
|
+
toStringValue(lead['campaign_id']) !== '' ? toStringValue(lead['campaign_id']) : ((_o = output['campaign_id']) !== null && _o !== void 0 ? _o : '');
|
|
323
|
+
output['campaign_name'] =
|
|
324
|
+
toStringValue(lead['campaign_name']) !== '' ? toStringValue(lead['campaign_name']) : ((_p = output['campaign_name']) !== null && _p !== void 0 ? _p : '');
|
|
325
|
+
output['ad_squad_id'] =
|
|
326
|
+
toStringValue(lead['ad_squad_id']) !== ''
|
|
327
|
+
? toStringValue(lead['ad_squad_id'])
|
|
328
|
+
: toStringValue(lead['adset_id']) !== ''
|
|
329
|
+
? toStringValue(lead['adset_id'])
|
|
330
|
+
: ((_q = output['ad_squad_id']) !== null && _q !== void 0 ? _q : '');
|
|
331
|
+
output['ad_squad_name'] =
|
|
332
|
+
toStringValue(lead['ad_squad_name']) !== ''
|
|
333
|
+
? toStringValue(lead['ad_squad_name'])
|
|
334
|
+
: toStringValue(lead['adset_name']) !== ''
|
|
335
|
+
? toStringValue(lead['adset_name'])
|
|
336
|
+
: ((_r = output['ad_squad_name']) !== null && _r !== void 0 ? _r : '');
|
|
337
|
+
output['ad_id'] = toStringValue(lead['ad_id']) !== '' ? toStringValue(lead['ad_id']) : ((_s = output['ad_id']) !== null && _s !== void 0 ? _s : '');
|
|
338
|
+
output['ad_name'] = toStringValue(lead['ad_name']) !== '' ? toStringValue(lead['ad_name']) : ((_t = output['ad_name']) !== null && _t !== void 0 ? _t : '');
|
|
339
|
+
return output;
|
|
340
|
+
}
|
|
341
|
+
exports.snapchatLeadsCommon = {
|
|
342
|
+
listAdAccounts,
|
|
343
|
+
listLeadForms,
|
|
344
|
+
getLeadForm,
|
|
345
|
+
listLeadWebhooks,
|
|
346
|
+
createLeadWebhook,
|
|
347
|
+
deleteLeadWebhook,
|
|
348
|
+
parseLeadWebhook,
|
|
349
|
+
};
|
|
350
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/lib/common.ts"],"names":[],"mappings":";;;;AAAA,+DAAqE;AAErE,MAAM,OAAO,GAAG,gCAAgC,CAAC;AAEjD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,MAAM,MAAM,GAAG,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1D,OAAO,IAAI,IAAI,C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C,CAAC;IACvH,OAAO,MAAM,CAAC;AAChB,CAAC;AAEY,QAAA,mBAAmB,GAAG;IACjC,cAAc;IACd,aAAa;IACb,WAAW;IACX,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;CACjB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const snapchatLeadsProps: {
|
|
2
|
+
adAccountDropdown: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
3
|
+
formDropdown: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
4
|
+
};
|
|
5
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/lib/props.ts"],"names":[],"mappings":"AA+EA,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC"}
|
package/src/lib/props.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.snapchatLeadsProps = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("./auth");
|
|
7
|
+
const common_1 = require("./common");
|
|
8
|
+
const adAccountDropdown = pieces_framework_1.Property.Dropdown({
|
|
9
|
+
auth: auth_1.snapchatLeadsAuth,
|
|
10
|
+
displayName: 'Ad Account',
|
|
11
|
+
description: 'The Snapchat ad account the lead form belongs to.',
|
|
12
|
+
required: true,
|
|
13
|
+
refreshers: [],
|
|
14
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
15
|
+
if (!auth) {
|
|
16
|
+
return {
|
|
17
|
+
disabled: true,
|
|
18
|
+
options: [],
|
|
19
|
+
placeholder: 'Connect your Snapchat account first',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const accounts = yield common_1.snapchatLeadsCommon.listAdAccounts(auth);
|
|
24
|
+
return {
|
|
25
|
+
options: accounts.map((account) => ({
|
|
26
|
+
label: account.name !== '' ? account.name : account.id,
|
|
27
|
+
value: account.id,
|
|
28
|
+
})),
|
|
29
|
+
placeholder: 'Choose an ad account',
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
console.debug(e);
|
|
34
|
+
return {
|
|
35
|
+
disabled: true,
|
|
36
|
+
options: [],
|
|
37
|
+
placeholder: 'Could not load ad accounts, check the connection',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
const formDropdown = pieces_framework_1.Property.Dropdown({
|
|
43
|
+
auth: auth_1.snapchatLeadsAuth,
|
|
44
|
+
displayName: 'Lead Form',
|
|
45
|
+
description: 'The lead form whose submissions trigger the flow.',
|
|
46
|
+
required: true,
|
|
47
|
+
refreshers: ['adAccountId'],
|
|
48
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, adAccountId }) {
|
|
49
|
+
if (!auth) {
|
|
50
|
+
return {
|
|
51
|
+
disabled: true,
|
|
52
|
+
options: [],
|
|
53
|
+
placeholder: 'Connect your Snapchat account first',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (typeof adAccountId !== 'string' || adAccountId === '') {
|
|
57
|
+
return {
|
|
58
|
+
disabled: true,
|
|
59
|
+
options: [],
|
|
60
|
+
placeholder: 'Choose an ad account first',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const forms = yield common_1.snapchatLeadsCommon.listLeadForms({ auth, adAccountId });
|
|
65
|
+
return {
|
|
66
|
+
options: forms.map((form) => ({
|
|
67
|
+
label: form.name !== '' ? form.name : form.id,
|
|
68
|
+
value: form.id,
|
|
69
|
+
})),
|
|
70
|
+
placeholder: 'Choose a lead form',
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
console.debug(e);
|
|
75
|
+
return {
|
|
76
|
+
disabled: true,
|
|
77
|
+
options: [],
|
|
78
|
+
placeholder: 'Could not load lead forms, check the connection',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
exports.snapchatLeadsProps = {
|
|
84
|
+
adAccountDropdown,
|
|
85
|
+
formDropdown,
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/lib/props.ts"],"names":[],"mappings":";;;;AAAA,qEAA0D;AAC1D,iCAA2C;AAC3C,qCAA+C;AAE/C,MAAM,iBAAiB,GAAG,2BAAQ,CAAC,QAAQ,CAAyC;IAClF,IAAI,EAAE,wBAAiB;IACvB,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,mDAAmD;IAChE,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACtB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,qCAAqC;aACnD,CAAC;QACJ,CAAC;QACD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,4BAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAChE,OAAO;gBACL,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;oBAClC,KAAK,EAAE,OAAO,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,I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C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;oBAC7C,KAAK,EAAE,IAAI,CAAC,EAAE;iBACf,CAAC,CAAC;gBACH,WAAW,EAAE,oBAAoB;aAClC,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,iDAAiD;aAC/D,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC;AAEU,QAAA,kBAAkB,GAAG;IAChC,iBAAiB;IACjB,YAAY;CACb,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newLead: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
+
adAccountId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
4
|
+
formId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
5
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
6
|
+
adAccountId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
7
|
+
formId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
8
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
9
|
+
adAccountId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
10
|
+
formId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
11
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
12
|
+
adAccountId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
13
|
+
formId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=new-lead.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-lead.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-lead.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAiB,MAAM,gCAAgC,CAAC;AAUhF,eAAO,MAAM,OAAO;;;;;;;;;;;;EA6DlB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newLead = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const props_1 = require("../props");
|
|
9
|
+
const WEBHOOK_STORE_KEY = 'snapchat_leads_webhook_id';
|
|
10
|
+
const WEBHOOK_SECRET_STORE_KEY = 'snapchat_leads_webhook_secret';
|
|
11
|
+
const FORM_STORE_KEY = 'snapchat_leads_form_id';
|
|
12
|
+
const AD_ACCOUNT_STORE_KEY = 'snapchat_leads_ad_account_id';
|
|
13
|
+
exports.newLead = (0, pieces_framework_1.createTrigger)({
|
|
14
|
+
auth: auth_1.snapchatLeadsAuth,
|
|
15
|
+
name: 'snapchat_leads_new_lead',
|
|
16
|
+
displayName: 'New Lead',
|
|
17
|
+
description: 'Triggers when a new lead is submitted to the selected Snapchat lead form. The form webhook is registered automatically when the flow is enabled.',
|
|
18
|
+
props: {
|
|
19
|
+
adAccountId: props_1.snapchatLeadsProps.adAccountDropdown,
|
|
20
|
+
formId: props_1.snapchatLeadsProps.formDropdown,
|
|
21
|
+
},
|
|
22
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
23
|
+
onEnable(context) {
|
|
24
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const { auth, propsValue } = context;
|
|
26
|
+
const webhook = yield common_1.snapchatLeadsCommon.createLeadWebhook({
|
|
27
|
+
auth,
|
|
28
|
+
formId: propsValue.formId,
|
|
29
|
+
webhookUrl: context.webhookUrl,
|
|
30
|
+
});
|
|
31
|
+
yield context.store.put(WEBHOOK_STORE_KEY, webhook.id);
|
|
32
|
+
yield context.store.put(WEBHOOK_SECRET_STORE_KEY, webhook.secret);
|
|
33
|
+
yield context.store.put(FORM_STORE_KEY, propsValue.formId);
|
|
34
|
+
yield context.store.put(AD_ACCOUNT_STORE_KEY, propsValue.adAccountId);
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
onDisable(context) {
|
|
38
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const webhookId = yield context.store.get(WEBHOOK_STORE_KEY);
|
|
40
|
+
if (webhookId !== null) {
|
|
41
|
+
try {
|
|
42
|
+
yield common_1.snapchatLeadsCommon.deleteLeadWebhook({
|
|
43
|
+
auth: context.auth,
|
|
44
|
+
webhookId,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
// Disabling a flow must never fail because of a Snapchat-side cleanup
|
|
49
|
+
// problem; the webhook also dies if the app authorization is revoked.
|
|
50
|
+
console.debug('Failed to delete Snapchat lead webhook:', error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
run(context) {
|
|
56
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
return [common_1.snapchatLeadsCommon.parseLeadWebhook(context.payload.body)];
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
sampleData: {
|
|
61
|
+
created_at: '2026-11-14T10:48:00.000Z',
|
|
62
|
+
name: 'Jane Doe',
|
|
63
|
+
phone: '8001000000',
|
|
64
|
+
phone_number: '8001000000',
|
|
65
|
+
email: 'jane.doe@example.com',
|
|
66
|
+
'Which service do you need?': 'Laser',
|
|
67
|
+
Branch: 'Qurtuba',
|
|
68
|
+
lead_id: '00000000-0000-4000-8000-000000000001',
|
|
69
|
+
form_id: '00000000-0000-4000-8000-000000000002',
|
|
70
|
+
form_name: 'Example Lead Form',
|
|
71
|
+
ad_account_id: '00000000-0000-4000-8000-000000000003',
|
|
72
|
+
ad_account_name: 'Example Ad Account',
|
|
73
|
+
campaign_id: '00000000-0000-4000-8000-000000000004',
|
|
74
|
+
campaign_name: 'Example Campaign',
|
|
75
|
+
ad_squad_id: '00000000-0000-4000-8000-000000000005',
|
|
76
|
+
ad_squad_name: 'Example Ad Squad',
|
|
77
|
+
ad_id: '00000000-0000-4000-8000-000000000006',
|
|
78
|
+
ad_name: 'Example Ad',
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=new-lead.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-lead.js","sourceRoot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