@activepieces/piece-promotekit 0.2.1 → 0.3.0
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 +5 -5
- package/src/index.d.ts.map +1 -1
- package/src/index.js +4 -2
- package/src/index.js.map +1 -1
- package/src/lib/triggers/new-affiliate-event.d.ts +15 -0
- package/src/lib/triggers/new-affiliate-event.d.ts.map +1 -0
- package/src/lib/triggers/new-affiliate-event.js +91 -0
- package/src/lib/triggers/new-affiliate-event.js.map +1 -0
- package/src/lib/triggers/{new-event.d.ts → new-commission-event.d.ts} +2 -6
- package/src/lib/triggers/new-commission-event.d.ts.map +1 -0
- package/src/lib/triggers/new-commission-event.js +71 -0
- package/src/lib/triggers/new-commission-event.js.map +1 -0
- package/src/lib/triggers/new-referral-event.d.ts +15 -0
- package/src/lib/triggers/new-referral-event.d.ts.map +1 -0
- package/src/lib/triggers/new-referral-event.js +90 -0
- package/src/lib/triggers/new-referral-event.js.map +1 -0
- package/src/lib/triggers/new-event.d.ts.map +0 -1
- package/src/lib/triggers/new-event.js +0 -105
- package/src/lib/triggers/new-event.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/piece-promotekit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"
|
|
9
|
-
"@activepieces/pieces-
|
|
10
|
-
"@activepieces/
|
|
11
|
-
"
|
|
8
|
+
"@activepieces/pieces-common": "0.12.3",
|
|
9
|
+
"@activepieces/pieces-framework": "0.29.0",
|
|
10
|
+
"@activepieces/shared": "0.82.1",
|
|
11
|
+
"tslib": "2.6.2"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "tsc -p tsconfig.lib.json && cp package.json dist/",
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,cAAc,mEAsBzB,CAAC;AAEH,eAAO,MAAM,UAAU,mHA+BrB,CAAC"}
|
package/src/index.js
CHANGED
|
@@ -18,7 +18,9 @@ const list_campaigns_1 = require("./lib/actions/list-campaigns");
|
|
|
18
18
|
const find_campaign_1 = require("./lib/actions/find-campaign");
|
|
19
19
|
const list_payouts_1 = require("./lib/actions/list-payouts");
|
|
20
20
|
const find_payout_1 = require("./lib/actions/find-payout");
|
|
21
|
-
const
|
|
21
|
+
const new_affiliate_event_1 = require("./lib/triggers/new-affiliate-event");
|
|
22
|
+
const new_referral_event_1 = require("./lib/triggers/new-referral-event");
|
|
23
|
+
const new_commission_event_1 = require("./lib/triggers/new-commission-event");
|
|
22
24
|
exports.promotekitAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
23
25
|
displayName: 'API Key',
|
|
24
26
|
description: `To get your API key:
|
|
@@ -75,6 +77,6 @@ exports.promotekit = (0, pieces_framework_1.createPiece)({
|
|
|
75
77
|
}),
|
|
76
78
|
}),
|
|
77
79
|
],
|
|
78
|
-
triggers: [
|
|
80
|
+
triggers: [new_affiliate_event_1.newAffiliateEvent, new_referral_event_1.newReferralEvent, new_commission_event_1.newCommissionEvent],
|
|
79
81
|
});
|
|
80
82
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAIqC;AACrC,qEAAwE;AACxE,iDAAqD;AACrD,mEAA+D;AAC/D,iEAA6D;AAC7D,qEAAiE;AACjE,qEAAiE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ACnE,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,oDAAoD;IAC7D,UAAU,EAAE,CAAC,sBAAa,CAAC,SAAS,CAAC;IACrC,IAAI,EAAE,sBAAc;IACpB,OAAO,EAAE,CAAC,SAAS,CAAC;IACpB,OAAO,EAAE;QACP,gCAAc;QACd,8BAAa;QACb,kCAAe;QACf,kCAAe;QACf,8BAAa;QACb,4BAAY;QACZ,gCAAc;QACd,kCAAe;QACf,gCAAc;QACd,8BAAa;QACb,4BAAY;QACZ,0BAAW;QACX,wBAAU;QACV,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,mCAAmC;YAClD,IAAI,EAAE,sBAAc;YACpB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,UAAU,IAAI,EAAE;iBAChC,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,uCAAiB,EAAE,qCAAgB,EAAE,yCAAkB,CAAC;CACpE,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newAffiliateEvent: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
3
|
+
eventTypes: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
4
|
+
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
5
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
6
|
+
eventTypes: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
7
|
+
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
8
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
9
|
+
eventTypes: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
10
|
+
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
11
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
12
|
+
eventTypes: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
13
|
+
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=new-affiliate-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-affiliate-event.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-affiliate-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAY,MAAM,gCAAgC,CAAC;AAU1F,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EA6E5B,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newAffiliateEvent = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
+
const AFFILIATE_EVENT_OPTIONS = [
|
|
10
|
+
{ label: 'Affiliate Created', value: 'affiliate.created' },
|
|
11
|
+
{ label: 'Affiliate Approved', value: 'affiliate.approved' },
|
|
12
|
+
];
|
|
13
|
+
exports.newAffiliateEvent = (0, pieces_framework_1.createTrigger)({
|
|
14
|
+
auth: __1.promotekitAuth,
|
|
15
|
+
name: 'new_affiliate_event',
|
|
16
|
+
displayName: 'New Affiliate Event',
|
|
17
|
+
description: 'Triggers when a PromoteKit affiliate event is received.',
|
|
18
|
+
props: {
|
|
19
|
+
eventTypes: pieces_framework_1.Property.StaticMultiSelectDropdown({
|
|
20
|
+
displayName: 'Affiliate Event Types',
|
|
21
|
+
description: 'Select the affiliate event types to listen for. Leave empty to receive all affiliate events.',
|
|
22
|
+
required: false,
|
|
23
|
+
options: { options: AFFILIATE_EVENT_OPTIONS },
|
|
24
|
+
}),
|
|
25
|
+
instructions: pieces_framework_1.Property.MarkDown({
|
|
26
|
+
value: `### Setup Instructions
|
|
27
|
+
|
|
28
|
+
1. Go to your PromoteKit dashboard.
|
|
29
|
+
2. Navigate to **Settings > Webhooks**.
|
|
30
|
+
3. Click **Add Endpoint**.
|
|
31
|
+
4. Paste the webhook URL shown below :
|
|
32
|
+
\`\`\`text
|
|
33
|
+
{{webhookUrl}}
|
|
34
|
+
\`\`\`
|
|
35
|
+
5. Enable the affiliate event types you selected above.
|
|
36
|
+
6. Save the endpoint.
|
|
37
|
+
|
|
38
|
+
**Need different flows for different events?** Create a separate flow with its own webhook URL, and add a new endpoint in PromoteKit for that flow with only the matching event enabled.`,
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
sampleData: {
|
|
42
|
+
type: 'affiliate.created',
|
|
43
|
+
id: 'aff_sample',
|
|
44
|
+
email: 'affiliate@example.com',
|
|
45
|
+
first_name: 'John',
|
|
46
|
+
last_name: 'Doe',
|
|
47
|
+
approved: false,
|
|
48
|
+
banned: false,
|
|
49
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
50
|
+
},
|
|
51
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
52
|
+
onEnable() {
|
|
53
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
// Webhook is configured manually in PromoteKit dashboard
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
onDisable() {
|
|
58
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
// Webhook is configured manually in PromoteKit dashboard
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
run(context) {
|
|
63
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
var _a;
|
|
65
|
+
const payload = context.payload.body;
|
|
66
|
+
const selected = (_a = context.propsValue.eventTypes) !== null && _a !== void 0 ? _a : [];
|
|
67
|
+
const isAffiliate = payload.type === 'affiliate.created' ||
|
|
68
|
+
payload.type === 'affiliate.approved';
|
|
69
|
+
if (!isAffiliate)
|
|
70
|
+
return [];
|
|
71
|
+
if (selected.length > 0 && !selected.includes(payload.type))
|
|
72
|
+
return [];
|
|
73
|
+
return [Object.assign({ type: payload.type }, common_1.promotekitCommon.flattenAffiliate(payload.data))];
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
test(context) {
|
|
77
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
const response = yield (0, common_1.promotekitApiCall)({
|
|
80
|
+
token: context.auth.secret_text,
|
|
81
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
82
|
+
path: '/affiliates',
|
|
83
|
+
queryParams: { limit: '5' },
|
|
84
|
+
});
|
|
85
|
+
const selected = (_a = context.propsValue.eventTypes) !== null && _a !== void 0 ? _a : [];
|
|
86
|
+
const eventType = (_b = selected[0]) !== null && _b !== void 0 ? _b : 'affiliate.created';
|
|
87
|
+
return response.body.data.map((item) => (Object.assign({ type: eventType }, common_1.promotekitCommon.flattenAffiliate(item))));
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=new-affiliate-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-affiliate-event.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-affiliate-event.ts"],"names":[],"mappings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AW,GACf,OAAO,CAAC,IAAI,KAAK,mBAAmB;gBACpC,OAAO,CAAC,IAAI,KAAK,oBAAoB,CAAC;YACxC,IAAI,CAAC,WAAW;gBAAE,OAAO,EAAE,CAAC;YAC5B,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;gBAAE,OAAO,EAAE,CAAC;YACvE,OAAO,iBAAG,IAAI,EAAE,OAAO,CAAC,IAAI,IAAK,yBAAgB,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAG,CAAC;QACtF,CAAC;KAAA;IAEK,IAAI,CAAC,OAAO;;;YAChB,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAiB,EAAsC;gBAC5E,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW;gBAC/B,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;aAC5B,CAAC,CAAC;YACH,MAAM,QAAQ,GAAa,MAAA,OAAO,CAAC,UAAU,CAAC,UAAU,mCAAI,EAAE,CAAC;YAC/D,MAAM,SAAS,GAAG,MAAA,QAAQ,CAAC,CAAC,CAAC,mCAAI,mBAAmB,CAAC;YACrD,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iBACtC,IAAI,EAAE,SAAS,IACZ,yBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAC1C,CAAC,CAAC;QACN,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
-
export declare const
|
|
3
|
-
eventType: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
2
|
+
export declare const newCommissionEvent: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
4
3
|
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
5
4
|
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
6
|
-
eventType: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
7
5
|
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
8
6
|
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
9
|
-
eventType: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
10
7
|
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
11
8
|
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
12
|
-
eventType: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
13
9
|
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
14
10
|
}>;
|
|
15
|
-
//# sourceMappingURL=new-event.d.ts.map
|
|
11
|
+
//# sourceMappingURL=new-commission-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-commission-event.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-commission-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAY,MAAM,gCAAgC,CAAC;AAK1F,eAAO,MAAM,kBAAkB;;;;;;;;EA8D7B,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newCommissionEvent = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
+
exports.newCommissionEvent = (0, pieces_framework_1.createTrigger)({
|
|
10
|
+
auth: __1.promotekitAuth,
|
|
11
|
+
name: 'new_commission_event',
|
|
12
|
+
displayName: 'New Commission Event',
|
|
13
|
+
description: 'Triggers when a PromoteKit commission webhook event is received.',
|
|
14
|
+
props: {
|
|
15
|
+
instructions: pieces_framework_1.Property.MarkDown({
|
|
16
|
+
value: `### Setup Instructions
|
|
17
|
+
|
|
18
|
+
1. Go to your PromoteKit dashboard.
|
|
19
|
+
2. Navigate to **Settings > Webhooks**.
|
|
20
|
+
3. Click **Add Endpoint**.
|
|
21
|
+
4. Paste the webhook URL shown below :
|
|
22
|
+
\`\`\`text
|
|
23
|
+
{{webhookUrl}}
|
|
24
|
+
\`\`\`
|
|
25
|
+
5. Enable the **Commission Created** event.
|
|
26
|
+
6. Save the endpoint.`,
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
sampleData: {
|
|
30
|
+
type: 'commission.created',
|
|
31
|
+
id: 'com_sample',
|
|
32
|
+
revenue_amount: 100,
|
|
33
|
+
currency: 'usd',
|
|
34
|
+
commission_amount: 20,
|
|
35
|
+
payout_status: 'pending',
|
|
36
|
+
affiliate_id: 'aff_sample',
|
|
37
|
+
affiliate_email: 'affiliate@example.com',
|
|
38
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
39
|
+
},
|
|
40
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
41
|
+
onEnable() {
|
|
42
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
// Webhook is configured manually in PromoteKit dashboard
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
onDisable() {
|
|
47
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
// Webhook is configured manually in PromoteKit dashboard
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
run(context) {
|
|
52
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const payload = context.payload.body;
|
|
54
|
+
if (payload.type !== 'commission.created')
|
|
55
|
+
return [];
|
|
56
|
+
return [Object.assign({ type: payload.type }, common_1.promotekitCommon.flattenCommission(payload.data))];
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
test(context) {
|
|
60
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const response = yield (0, common_1.promotekitApiCall)({
|
|
62
|
+
token: context.auth.secret_text,
|
|
63
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
64
|
+
path: '/commissions',
|
|
65
|
+
queryParams: { limit: '5' },
|
|
66
|
+
});
|
|
67
|
+
return response.body.data.map((item) => (Object.assign({ type: 'commission.created' }, common_1.promotekitCommon.flattenCommission(item))));
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=new-commission-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-commission-event.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-commission-event.ts"],"names":[],"mappings":";;;;AAAA,qEAA0F;AAC1F,6BAAuC;AACvC,sCAAgE;AAChE,+DAAyD;AAE5C,QAAA,kBAAkB,GAAG,IAAA,gCAAa,EAAC;IAC9C,IAAI,EAAE,kBAAc;IACpB,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,kEAAkE;IAC/E,KAAK,EAAE;QACL,YAAY,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC9B,KAAK,EAAE;;;;;;;;;;sBAUS;SACjB,CAAC;KACH;IACD,UAAU,EAAE;QACV,IAAI,EAAE,oBAAoB;QAC1B,EAAE,EAAE,YAAY;QAChB,cAAc,EAAE,GAAG;QACnB,QAAQ,EAAE,KAAK;QACf,iBAAiB,EAAE,EAAE;QACrB,aAAa,EAAE,SAAS;QACxB,YAAY,EAAE,YAAY;QAC1B,eAAe,EAAE,uBAAuB;QACxC,UAAU,EAAE,sBAAsB;KACnC;IACD,IAAI,EAAE,kCAAe,CAAC,OAAO;IAEvB,QAAQ;;YACZ,yDAAyD;QAC3D,CAAC;KAAA;IAEK,SAAS;;YACb,yDAAyD;QAC3D,CAAC;KAAA;IAEK,GAAG,CAAC,OAAO;;YACf,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAG/B,CAAC;YACF,IAAI,OAAO,CAAC,IAAI,KAAK,oBAAoB;gBAAE,OAAO,EAAE,CAAC;YACrD,OAAO,iBAAG,IAAI,EAAE,OAAO,CAAC,IAAI,IAAK,yBAAgB,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAG,CAAC;QACvF,CAAC;KAAA;IAEK,IAAI,CAAC,OAAO;;YAChB,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAiB,EAAsC;gBAC5E,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW;gBAC/B,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,cAAc;gBACpB,WAAW,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;aAC5B,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iBACtC,IAAI,EAAE,oBAAoB,IACvB,yBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAC3C,CAAC,CAAC;QACN,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newReferralEvent: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
3
|
+
eventTypes: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
4
|
+
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
5
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
6
|
+
eventTypes: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
7
|
+
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
8
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
9
|
+
eventTypes: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
10
|
+
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
11
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
12
|
+
eventTypes: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
13
|
+
instructions: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=new-referral-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-referral-event.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-referral-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAY,MAAM,gCAAgC,CAAC;AAU1F,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EA4E3B,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newReferralEvent = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
+
const REFERRAL_EVENT_OPTIONS = [
|
|
10
|
+
{ label: 'Referral Created', value: 'referral.created' },
|
|
11
|
+
{ label: 'Referral Converted', value: 'referral.converted' },
|
|
12
|
+
];
|
|
13
|
+
exports.newReferralEvent = (0, pieces_framework_1.createTrigger)({
|
|
14
|
+
auth: __1.promotekitAuth,
|
|
15
|
+
name: 'new_referral_event',
|
|
16
|
+
displayName: 'New Referral Event',
|
|
17
|
+
description: 'Triggers when a PromoteKit referral webhook event is received.',
|
|
18
|
+
props: {
|
|
19
|
+
eventTypes: pieces_framework_1.Property.StaticMultiSelectDropdown({
|
|
20
|
+
displayName: 'Referral Event Types',
|
|
21
|
+
description: 'Select the referral event types to listen for. Leave empty to receive all referral events.',
|
|
22
|
+
required: false,
|
|
23
|
+
options: { options: REFERRAL_EVENT_OPTIONS },
|
|
24
|
+
}),
|
|
25
|
+
instructions: pieces_framework_1.Property.MarkDown({
|
|
26
|
+
value: `### Setup Instructions
|
|
27
|
+
|
|
28
|
+
1. Go to your PromoteKit dashboard.
|
|
29
|
+
2. Navigate to **Settings > Webhooks**.
|
|
30
|
+
3. Click **Add Endpoint**.
|
|
31
|
+
4. Paste the webhook URL shown below.
|
|
32
|
+
\`\`\`text
|
|
33
|
+
{{webhookUrl}}
|
|
34
|
+
\`\`\`
|
|
35
|
+
5. Enable the referral event types you selected above.
|
|
36
|
+
6. Save the endpoint.
|
|
37
|
+
|
|
38
|
+
**Need different flows for different events?** Create a separate flow with its own webhook URL, and add a new endpoint in PromoteKit for that flow with only the matching event enabled.`,
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
sampleData: {
|
|
42
|
+
type: 'referral.created',
|
|
43
|
+
id: 'ref_sample',
|
|
44
|
+
email: 'referral@example.com',
|
|
45
|
+
subscription_status: null,
|
|
46
|
+
affiliate_id: 'aff_sample',
|
|
47
|
+
affiliate_email: 'affiliate@example.com',
|
|
48
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
49
|
+
},
|
|
50
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
51
|
+
onEnable() {
|
|
52
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
// Webhook is configured manually in PromoteKit dashboard
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
onDisable() {
|
|
57
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
// Webhook is configured manually in PromoteKit dashboard
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
run(context) {
|
|
62
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
var _a;
|
|
64
|
+
const payload = context.payload.body;
|
|
65
|
+
const selected = (_a = context.propsValue.eventTypes) !== null && _a !== void 0 ? _a : [];
|
|
66
|
+
const isReferral = payload.type === 'referral.created' ||
|
|
67
|
+
payload.type === 'referral.converted';
|
|
68
|
+
if (!isReferral)
|
|
69
|
+
return [];
|
|
70
|
+
if (selected.length > 0 && !selected.includes(payload.type))
|
|
71
|
+
return [];
|
|
72
|
+
return [Object.assign({ type: payload.type }, common_1.promotekitCommon.flattenReferral(payload.data))];
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
test(context) {
|
|
76
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
const response = yield (0, common_1.promotekitApiCall)({
|
|
79
|
+
token: context.auth.secret_text,
|
|
80
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
81
|
+
path: '/referrals',
|
|
82
|
+
queryParams: { limit: '5' },
|
|
83
|
+
});
|
|
84
|
+
const selected = (_a = context.propsValue.eventTypes) !== null && _a !== void 0 ? _a : [];
|
|
85
|
+
const eventType = (_b = selected[0]) !== null && _b !== void 0 ? _b : 'referral.created';
|
|
86
|
+
return response.body.data.map((item) => (Object.assign({ type: eventType }, common_1.promotekitCommon.flattenReferral(item))));
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=new-referral-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-referral-event.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-referral-event.ts"],"names":[],"mappings":";;;;AAAA,qEAA0F;AAC1F,6BAAuC;AACvC,sCAAgE;AAChE,+DAAyD;AAEzD,MAAM,sBAAsB,GAAG;IAC7B,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,EAAE;IACxD,EAAE,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,EAAE;CAC7D,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAA,gCAAa,EAAC;IAC5C,IAAI,EAAE,kBAAc;IACpB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,gEAAgE;IAC7E,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,yBAAyB,CAAC;YAC7C,WAAW,EAAE,sBAAsB;YACnC,WAAW,EACT,4FAA4F;YAC9F,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,EAAE,OAAO,EAAE,sBAAsB,EAAE;SAC7C,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC9B,KAAK,EAAE;;;;;;;;;;;;yLAY4K;SACpL,CAAC;KACH;IACD,UAAU,EAAE;QACV,IAAI,EAAE,kBAAkB;QACxB,EAAE,EAAE,YAAY;QAChB,KAAK,EAAE,sBAAsB;QAC7B,mBAAmB,EAAE,IAAI;QACzB,YAAY,EAAE,YAAY;QAC1B,eAAe,EAAE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AG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iBACtC,IAAI,EAAE,SAAS,IACZ,yBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,EACzC,CAAC,CAAC;QACN,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new-event.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAaxC,eAAO,MAAM,QAAQ;;;;;;;;;;;;EA0EnB,CAAC"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.newEvent = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const __1 = require("../..");
|
|
7
|
-
const common_1 = require("../common");
|
|
8
|
-
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
-
const EVENT_TYPE_OPTIONS = [
|
|
10
|
-
{ label: 'Affiliate Created', value: 'affiliate.created' },
|
|
11
|
-
{ label: 'Affiliate Approved', value: 'affiliate.approved' },
|
|
12
|
-
{ label: 'Referral Created', value: 'referral.created' },
|
|
13
|
-
{ label: 'Referral Converted', value: 'referral.converted' },
|
|
14
|
-
{ label: 'Commission Created', value: 'commission.created' },
|
|
15
|
-
];
|
|
16
|
-
exports.newEvent = (0, pieces_framework_1.createTrigger)({
|
|
17
|
-
auth: __1.promotekitAuth,
|
|
18
|
-
name: 'new_event',
|
|
19
|
-
displayName: 'New Event',
|
|
20
|
-
description: 'Triggers when a PromoteKit webhook event is received.',
|
|
21
|
-
props: {
|
|
22
|
-
eventType: pieces_framework_1.Property.StaticDropdown({
|
|
23
|
-
displayName: 'Event Type',
|
|
24
|
-
description: 'The event type this trigger should respond to.',
|
|
25
|
-
required: true,
|
|
26
|
-
options: { options: EVENT_TYPE_OPTIONS },
|
|
27
|
-
}),
|
|
28
|
-
instructions: pieces_framework_1.Property.MarkDown({
|
|
29
|
-
value: `### Setup Instructions
|
|
30
|
-
|
|
31
|
-
1. Go to your PromoteKit dashboard
|
|
32
|
-
2. Navigate to **Settings > Webhooks**
|
|
33
|
-
3. Click **Add Endpoint**
|
|
34
|
-
4. Paste the webhook URL shown below
|
|
35
|
-
5. Enable the event type you selected above (and any others you need for separate flows)
|
|
36
|
-
6. Save the endpoint`,
|
|
37
|
-
}),
|
|
38
|
-
},
|
|
39
|
-
sampleData: {
|
|
40
|
-
id: 'sample-id',
|
|
41
|
-
created_at: '2024-01-01T00:00:00Z',
|
|
42
|
-
},
|
|
43
|
-
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
44
|
-
onEnable() {
|
|
45
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
// Webhook is configured manually in PromoteKit dashboard
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
onDisable() {
|
|
50
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
// Webhook is configured manually in PromoteKit dashboard
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
run(context) {
|
|
55
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
const payload = context.payload.body;
|
|
57
|
-
if (payload.type !== context.propsValue.eventType)
|
|
58
|
-
return [];
|
|
59
|
-
return [flattenByType(payload.type, payload.data)];
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
test(context) {
|
|
63
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const eventType = context.propsValue.eventType;
|
|
65
|
-
if (eventType === 'affiliate.created' || eventType === 'affiliate.approved') {
|
|
66
|
-
const response = yield (0, common_1.promotekitApiCall)({
|
|
67
|
-
token: context.auth.secret_text,
|
|
68
|
-
method: pieces_common_1.HttpMethod.GET,
|
|
69
|
-
path: '/affiliates',
|
|
70
|
-
queryParams: { limit: '5' },
|
|
71
|
-
});
|
|
72
|
-
return response.body.data.map(common_1.promotekitCommon.flattenAffiliate);
|
|
73
|
-
}
|
|
74
|
-
if (eventType === 'referral.created' || eventType === 'referral.converted') {
|
|
75
|
-
const response = yield (0, common_1.promotekitApiCall)({
|
|
76
|
-
token: context.auth.secret_text,
|
|
77
|
-
method: pieces_common_1.HttpMethod.GET,
|
|
78
|
-
path: '/referrals',
|
|
79
|
-
queryParams: { limit: '5' },
|
|
80
|
-
});
|
|
81
|
-
return response.body.data.map(common_1.promotekitCommon.flattenReferral);
|
|
82
|
-
}
|
|
83
|
-
const response = yield (0, common_1.promotekitApiCall)({
|
|
84
|
-
token: context.auth.secret_text,
|
|
85
|
-
method: pieces_common_1.HttpMethod.GET,
|
|
86
|
-
path: '/commissions',
|
|
87
|
-
queryParams: { limit: '5' },
|
|
88
|
-
});
|
|
89
|
-
return response.body.data.map(common_1.promotekitCommon.flattenCommission);
|
|
90
|
-
});
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
function flattenByType(type, data) {
|
|
94
|
-
if (type === 'affiliate.created' || type === 'affiliate.approved') {
|
|
95
|
-
return common_1.promotekitCommon.flattenAffiliate(data);
|
|
96
|
-
}
|
|
97
|
-
if (type === 'referral.created' || type === 'referral.converted') {
|
|
98
|
-
return common_1.promotekitCommon.flattenReferral(data);
|
|
99
|
-
}
|
|
100
|
-
if (type === 'commission.created') {
|
|
101
|
-
return common_1.promotekitCommon.flattenCommission(data);
|
|
102
|
-
}
|
|
103
|
-
return data;
|
|
104
|
-
}
|
|
105
|
-
//# sourceMappingURL=new-event.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new-event.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-event.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,6BAAuC;AACvC,sCAAgE;AAChE,+DAAyD;AAEzD,MAAM,kBA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