@taskmagic/apps-plunk 0.0.1
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/README.md +3 -0
- package/package.json +47 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +38 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/get-contact.d.ts +6 -0
- package/src/lib/actions/get-contact.js +35 -0
- package/src/lib/actions/get-contact.js.map +1 -0
- package/src/lib/actions/get-contacts.d.ts +4 -0
- package/src/lib/actions/get-contacts.js +50 -0
- package/src/lib/actions/get-contacts.js.map +1 -0
- package/src/lib/actions/send-email.d.ts +12 -0
- package/src/lib/actions/send-email.js +82 -0
- package/src/lib/actions/send-email.js.map +1 -0
- package/src/lib/actions/track-event.d.ts +9 -0
- package/src/lib/actions/track-event.js +63 -0
- package/src/lib/actions/track-event.js.map +1 -0
- package/src/lib/auth.d.ts +5 -0
- package/src/lib/auth.js +46 -0
- package/src/lib/auth.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taskmagic/apps-plunk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@anthropic-ai/sdk": "0.33.1",
|
|
6
|
+
"@sinclair/typebox": "0.34.11",
|
|
7
|
+
"axios": "1.17.0",
|
|
8
|
+
"axios-retry": "4.4.1",
|
|
9
|
+
"deepmerge-ts": "7.1.0",
|
|
10
|
+
"mime-types": "2.1.35",
|
|
11
|
+
"nanoid": "3.3.8",
|
|
12
|
+
"openai": "4.67.1",
|
|
13
|
+
"replicate": "0.34.1",
|
|
14
|
+
"semver": "7.6.0",
|
|
15
|
+
"zod": "3.25.76",
|
|
16
|
+
"@taskmagic/pieces-common": "0.4.4",
|
|
17
|
+
"@taskmagic/pieces-framework": "0.7.46",
|
|
18
|
+
"@taskmagic/shared": "0.10.171",
|
|
19
|
+
"tslib": "1.14.1"
|
|
20
|
+
},
|
|
21
|
+
"overrides": {
|
|
22
|
+
"cross-spawn": "7.0.6",
|
|
23
|
+
"elliptic": "^6.6.1",
|
|
24
|
+
"fast-xml-parser": "^4.4.1",
|
|
25
|
+
"protobufjs": "^7.5.5",
|
|
26
|
+
"tmp": "^0.2.4",
|
|
27
|
+
"koa": "^2.16.4",
|
|
28
|
+
"picomatch": "^4.0.4",
|
|
29
|
+
"langsmith": "^0.6.0",
|
|
30
|
+
"serialize-javascript": "^6.0.2",
|
|
31
|
+
"elevenlabs": {
|
|
32
|
+
"form-data": "^4.0.4"
|
|
33
|
+
},
|
|
34
|
+
"@tryfabric/martian": {
|
|
35
|
+
"@notionhq/client": "$@notionhq/client"
|
|
36
|
+
},
|
|
37
|
+
"vite": {
|
|
38
|
+
"rollup": "npm:@rollup/wasm-node@^4.61.1"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"resolutions": {
|
|
42
|
+
"rollup": "npm:@rollup/wasm-node@^4.61.1"
|
|
43
|
+
},
|
|
44
|
+
"types": "./src/index.d.ts",
|
|
45
|
+
"main": "./src/index.js",
|
|
46
|
+
"type": "commonjs"
|
|
47
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const plunk: import("@taskmagic/pieces-framework").Piece<import("@taskmagic/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
secretKey: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
publicKey: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.plunk = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
7
|
+
const shared_1 = require("@taskmagic/shared");
|
|
8
|
+
const send_email_1 = require("./lib/actions/send-email");
|
|
9
|
+
const track_event_1 = require("./lib/actions/track-event");
|
|
10
|
+
const get_contacts_1 = require("./lib/actions/get-contacts");
|
|
11
|
+
const get_contact_1 = require("./lib/actions/get-contact");
|
|
12
|
+
const auth_1 = require("./lib/auth");
|
|
13
|
+
exports.plunk = (0, pieces_framework_1.createPiece)({
|
|
14
|
+
displayName: 'Plunk',
|
|
15
|
+
description: 'Open-source email platform for transactional emails, marketing campaigns, and contact management.',
|
|
16
|
+
minimumSupportedRelease: '0.30.0',
|
|
17
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/plunk.png',
|
|
18
|
+
categories: [shared_1.PieceCategory.MARKETING, shared_1.PieceCategory.COMMUNICATION],
|
|
19
|
+
authors: ['fran-mora'],
|
|
20
|
+
auth: auth_1.plunkAuth,
|
|
21
|
+
actions: [
|
|
22
|
+
send_email_1.sendTransactionalEmail,
|
|
23
|
+
track_event_1.trackEvent,
|
|
24
|
+
get_contacts_1.getContacts,
|
|
25
|
+
get_contact_1.getContact,
|
|
26
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
27
|
+
baseUrl: () => auth_1.PLUNK_BASE_URL,
|
|
28
|
+
auth: auth_1.plunkAuth,
|
|
29
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
return ({
|
|
31
|
+
Authorization: `Bearer ${auth.secretKey}`,
|
|
32
|
+
});
|
|
33
|
+
}),
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
triggers: [],
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/plunk/src/index.ts"],"names":[],"mappings":";;;;AAAA,4DAAqE;AACrE,kEAA0D;AAC1D,8CAAkD;AAClD,yDAAkE;AAClE,2DAAuD;AACvD,6DAAyD;AACzD,2DAAuD;AACvD,qCAAuD;AAE1C,QAAA,KAAK,GAAG,IAAA,8BAAW,EAAC;IAC/B,WAAW,EAAE,OAAO;IACpB,WAAW,EACT,mGAAmG;IACrG,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,+CAA+C;IACxD,UAAU,EAAE,CAAC,sBAAa,CAAC,SAAS,EAAE,sBAAa,CAAC,aAAa,CAAC;IAClE,OAAO,EAAE,CAAC,WAAW,CAAC;IACtB,IAAI,EAAE,gBAAS;IACf,OAAO,EAAE;QACP,mCAAsB;QACtB,wBAAU;QACV,0BAAW;QACX,wBAAU;QACV,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,qBAAc;YAC7B,IAAI,EAAE,gBAAS;YACf,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,UACZ,IAA8B,CAAC,SAClC,EAAE;iBACH,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getContact: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
secretKey: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
publicKey: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>, {
|
|
5
|
+
contactId: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getContact = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
exports.getContact = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.plunkAuth,
|
|
10
|
+
name: 'get_contact',
|
|
11
|
+
displayName: 'Get Contact',
|
|
12
|
+
description: 'Retrieve a single contact by ID.',
|
|
13
|
+
props: {
|
|
14
|
+
contactId: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Contact ID',
|
|
16
|
+
description: 'The Plunk contact ID.',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
run(context) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const { contactId } = context.propsValue;
|
|
23
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
24
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
25
|
+
url: `${auth_1.PLUNK_BASE_URL}/contacts/${encodeURIComponent(contactId)}`,
|
|
26
|
+
authentication: {
|
|
27
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
28
|
+
token: context.auth.secretKey,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return response.body;
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=get-contact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-contact.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/plunk/src/lib/actions/get-contact.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,4DAIkC;AAClC,kCAAoD;AAEvC,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACrC,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,kCAAkC;IAC/C,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,uBAAuB;YACpC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACzC,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,GAAG,qBAAc,aAAa,kBAAkB,CAAC,SAAS,CAAC,EAAE;gBAClE,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS;iBAC9B;aACF,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const getContacts: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
secretKey: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
publicKey: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>, {}>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getContacts = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
// Plunk's GET /v1/contacts is cursor-paginated. We page through with the
|
|
9
|
+
// max page size and accumulate items until `hasMore` is false. The page-cap
|
|
10
|
+
// guards against an unbounded loop if the API ever returns hasMore=true
|
|
11
|
+
// without advancing the cursor.
|
|
12
|
+
const MAX_PAGES = 200;
|
|
13
|
+
exports.getContacts = (0, pieces_framework_1.createAction)({
|
|
14
|
+
auth: auth_1.plunkAuth,
|
|
15
|
+
name: 'get_all_contacts',
|
|
16
|
+
displayName: 'Get All Contacts',
|
|
17
|
+
description: 'Retrieve every contact in your Plunk project.',
|
|
18
|
+
props: {},
|
|
19
|
+
run(context) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
var _a;
|
|
22
|
+
const items = [];
|
|
23
|
+
let cursor;
|
|
24
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
25
|
+
const queryParams = { limit: '100' };
|
|
26
|
+
if (cursor)
|
|
27
|
+
queryParams['cursor'] = cursor;
|
|
28
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
29
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
30
|
+
url: `${auth_1.PLUNK_BASE_URL}/contacts`,
|
|
31
|
+
queryParams,
|
|
32
|
+
authentication: {
|
|
33
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
34
|
+
token: context.auth.secretKey,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const body = response.body;
|
|
38
|
+
if ((_a = body.data) === null || _a === void 0 ? void 0 : _a.length) {
|
|
39
|
+
items.push(...body.data);
|
|
40
|
+
}
|
|
41
|
+
if (!body.hasMore || !body.cursor) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
cursor = body.cursor;
|
|
45
|
+
}
|
|
46
|
+
return { items };
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=get-contacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-contacts.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/plunk/src/lib/actions/get-contacts.ts"],"names":[],"mappings":";;;;AAAA,kEAA2D;AAC3D,4DAIkC;AAClC,kCAAoD;AAQpD,yEAAyE;AACzE,4EAA4E;AAC5E,wEAAwE;AACxE,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AC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const sendTransactionalEmail: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
secretKey: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
publicKey: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>, {
|
|
5
|
+
to: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
subject: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
body: import("@taskmagic/pieces-framework").LongTextProperty<true>;
|
|
8
|
+
name: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
from: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
10
|
+
reply: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
11
|
+
subscribed: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendTransactionalEmail = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
exports.sendTransactionalEmail = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.plunkAuth,
|
|
10
|
+
name: 'send_transactional_email',
|
|
11
|
+
displayName: 'Send Transactional Email',
|
|
12
|
+
description: 'Send a transactional email through Plunk. Recipient can be a single address or a comma-separated list.',
|
|
13
|
+
props: {
|
|
14
|
+
to: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'To',
|
|
16
|
+
description: 'Recipient email address. For multiple recipients, separate with commas.',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
subject: pieces_framework_1.Property.ShortText({
|
|
20
|
+
displayName: 'Subject',
|
|
21
|
+
required: true,
|
|
22
|
+
}),
|
|
23
|
+
body: pieces_framework_1.Property.LongText({
|
|
24
|
+
displayName: 'Body',
|
|
25
|
+
description: 'HTML body of the email.',
|
|
26
|
+
required: true,
|
|
27
|
+
}),
|
|
28
|
+
name: pieces_framework_1.Property.ShortText({
|
|
29
|
+
displayName: 'Sender Name',
|
|
30
|
+
description: 'Optional sender name. Falls back to the project default.',
|
|
31
|
+
required: false,
|
|
32
|
+
}),
|
|
33
|
+
from: pieces_framework_1.Property.ShortText({
|
|
34
|
+
displayName: 'Sender Email (From)',
|
|
35
|
+
description: 'Optional sender email. Must be a verified address on your Plunk project.',
|
|
36
|
+
required: false,
|
|
37
|
+
}),
|
|
38
|
+
reply: pieces_framework_1.Property.ShortText({
|
|
39
|
+
displayName: 'Reply-To',
|
|
40
|
+
description: 'Optional reply-to email.',
|
|
41
|
+
required: false,
|
|
42
|
+
}),
|
|
43
|
+
subscribed: pieces_framework_1.Property.Checkbox({
|
|
44
|
+
displayName: 'Mark Recipient as Subscribed',
|
|
45
|
+
description: 'When enabled, Plunk creates the recipient as a subscribed contact if they do not already exist.',
|
|
46
|
+
required: false,
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
run(context) {
|
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const { to, subject, body, name, from, reply, subscribed } = context.propsValue;
|
|
52
|
+
const recipients = to
|
|
53
|
+
.split(',')
|
|
54
|
+
.map((r) => r.trim())
|
|
55
|
+
.filter((r) => r.length > 0);
|
|
56
|
+
const requestBody = {
|
|
57
|
+
to: recipients.length === 1 ? recipients[0] : recipients,
|
|
58
|
+
subject,
|
|
59
|
+
body,
|
|
60
|
+
};
|
|
61
|
+
if (name)
|
|
62
|
+
requestBody['name'] = name;
|
|
63
|
+
if (from)
|
|
64
|
+
requestBody['from'] = from;
|
|
65
|
+
if (reply)
|
|
66
|
+
requestBody['reply'] = reply;
|
|
67
|
+
if (subscribed === true)
|
|
68
|
+
requestBody['subscribed'] = true;
|
|
69
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
70
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
71
|
+
url: `${auth_1.PLUNK_BASE_URL}/v1/send`,
|
|
72
|
+
body: requestBody,
|
|
73
|
+
authentication: {
|
|
74
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
75
|
+
token: context.auth.secretKey,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
return response.body;
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=send-email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-email.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/plunk/src/lib/actions/send-email.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,4DAIkC;AAClC,kCAAoD;AAEvC,QAAA,sBAAsB,GAAG,IAAA,+BAAY,EAAC;IACjD,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,0BAA0B;IAChC,WAAW,EAAE,0BAA0B;IACvC,WAAW,EACT,wGAAwG;IAC1G,KAAK,EAAE;QACL,EAAE,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACrB,WAAW,EAAE,IAAI;YACjB,WAAW,EACT,yEAAyE;YAC3E,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACtB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,yBAAyB;YACtC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE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KAAK,CAAC;YACxC,IAAI,UAAU,KAAK,IAAI;gBAAE,WAAW,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;YAE1D,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,GAAG,qBAAc,UAAU;gBAChC,IAAI,EAAE,WAAW;gBACjB,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS;iBAC9B;aACF,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const trackEvent: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
secretKey: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
publicKey: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>, {
|
|
5
|
+
event: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
email: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
subscribed: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
8
|
+
data: import("@taskmagic/pieces-framework").ObjectProperty<false>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trackEvent = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
exports.trackEvent = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.plunkAuth,
|
|
10
|
+
name: 'track_event',
|
|
11
|
+
displayName: 'Track Event',
|
|
12
|
+
description: 'Track a Plunk event for a contact. Plunk auto-creates the contact if they do not exist. Requires the public API key.',
|
|
13
|
+
props: {
|
|
14
|
+
event: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Event Name',
|
|
16
|
+
description: 'Identifier of the event being tracked, e.g. `order.completed`.',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
email: pieces_framework_1.Property.ShortText({
|
|
20
|
+
displayName: 'Contact Email',
|
|
21
|
+
description: 'Email address of the contact the event belongs to.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
subscribed: pieces_framework_1.Property.Checkbox({
|
|
25
|
+
displayName: 'Mark Contact as Subscribed',
|
|
26
|
+
description: 'When enabled, contacts auto-created by this event will be marked as subscribed.',
|
|
27
|
+
required: false,
|
|
28
|
+
}),
|
|
29
|
+
data: pieces_framework_1.Property.Object({
|
|
30
|
+
displayName: 'Event Data',
|
|
31
|
+
description: 'Optional metadata stored alongside the event.',
|
|
32
|
+
required: false,
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
run(context) {
|
|
36
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const publicKey = context.auth.publicKey;
|
|
38
|
+
if (!publicKey || publicKey.trim().length === 0) {
|
|
39
|
+
throw new Error('Track Event requires a Plunk public API key. Add the public key in the piece authentication.');
|
|
40
|
+
}
|
|
41
|
+
const { event, email, subscribed, data } = context.propsValue;
|
|
42
|
+
const requestBody = {
|
|
43
|
+
event,
|
|
44
|
+
email,
|
|
45
|
+
};
|
|
46
|
+
if (subscribed === true)
|
|
47
|
+
requestBody['subscribed'] = true;
|
|
48
|
+
if (data && Object.keys(data).length > 0)
|
|
49
|
+
requestBody['data'] = data;
|
|
50
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
51
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
52
|
+
url: `${auth_1.PLUNK_BASE_URL}/v1/track`,
|
|
53
|
+
body: requestBody,
|
|
54
|
+
authentication: {
|
|
55
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
56
|
+
token: publicKey,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
return response.body;
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=track-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-event.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/plunk/src/lib/actions/track-event.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,4DAIkC;AAClC,kCAAoD;AAEvC,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACrC,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EACT,sHAAsH;IACxH,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,YAAY;YACzB,WAAW,EACT,gEAAgE;YAClE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,eAAe;YAC5B,WAAW,EAAE,oDAAoD;YACjE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC5B,WAAW,EAAE,4BAA4B;YACzC,WAAW,EACT,iFAAiF;YACnF,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,+CAA+C;YAC5D,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;YACzC,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAChD,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;YACJ,CAAC;YAED,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAC9D,MAAM,WAAW,GAA4B;gBAC3C,KAAK;gBACL,KAAK;aACN,CAAC;YACF,IAAI,UAAU,KAAK,IAAI;gBAAE,WAAW,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;YAC1D,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;gBAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;YAErE,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,GAAG,qBAAc,WAAW;gBACjC,IAAI,EAAE,WAAW;gBACjB,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,SAAS;iBACjB;aACF,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const PLUNK_BASE_URL = "https://next-api.useplunk.com";
|
|
2
|
+
export declare const plunkAuth: import("@taskmagic/pieces-framework").CustomAuthProperty<{
|
|
3
|
+
secretKey: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
publicKey: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
}>;
|
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.plunkAuth = exports.PLUNK_BASE_URL = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
7
|
+
exports.PLUNK_BASE_URL = 'https://next-api.useplunk.com';
|
|
8
|
+
exports.plunkAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
9
|
+
description: `Find both API keys in your Plunk project's API settings.
|
|
10
|
+
|
|
11
|
+
- Secret API key (\`sk_*\`) is required for sending email and managing contacts.
|
|
12
|
+
- Public API key (\`pk_*\`) is optional. It is only used by the Track Event action.`,
|
|
13
|
+
required: true,
|
|
14
|
+
props: {
|
|
15
|
+
secretKey: pieces_framework_1.PieceAuth.SecretText({
|
|
16
|
+
displayName: 'Secret API Key',
|
|
17
|
+
description: 'Used for /v1/send, /v1/contacts, and the Custom API Call action.',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
publicKey: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Public API Key',
|
|
22
|
+
description: 'Required only for the Track Event action.',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
27
|
+
try {
|
|
28
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
29
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
30
|
+
url: `${exports.PLUNK_BASE_URL}/contacts`,
|
|
31
|
+
authentication: {
|
|
32
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
33
|
+
token: auth.secretKey,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
return { valid: true };
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
return {
|
|
40
|
+
valid: false,
|
|
41
|
+
error: 'Could not authenticate with Plunk. Verify the secret API key is correct.',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/community/plunk/src/lib/auth.ts"],"names":[],"mappings":";;;;AAAA,4DAIkC;AAClC,kEAAkE;AAErD,QAAA,cAAc,GAAG,+BAA+B,CAAC;AAEjD,QAAA,SAAS,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC5C,WAAW,EAAE;;;sFAGuE;IACpF,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACL,SAAS,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC9B,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EACT,kEAAkE;YACpE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,2CAA2C;YACxD,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC3B,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,GAAG,sBAAc,WAAW;gBACjC,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,IAAI,CAAC,SAAS;iBACtB;aACF,CAAC,CAAC;YACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EACH,0EAA0E;aAC7E,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|