@taskmagic/apps-postmark 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 +7 -0
- package/package.json +47 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +38 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/get-bounces.d.ts +8 -0
- package/src/lib/actions/get-bounces.js +74 -0
- package/src/lib/actions/get-bounces.js.map +1 -0
- package/src/lib/actions/get-delivery-stats.d.ts +1 -0
- package/src/lib/actions/get-delivery-stats.js +21 -0
- package/src/lib/actions/get-delivery-stats.js.map +1 -0
- package/src/lib/actions/send-email-with-template.d.ts +12 -0
- package/src/lib/actions/send-email-with-template.js +86 -0
- package/src/lib/actions/send-email-with-template.js.map +1 -0
- package/src/lib/actions/send-email.d.ts +13 -0
- package/src/lib/actions/send-email.js +98 -0
- package/src/lib/actions/send-email.js.map +1 -0
- package/src/lib/auth.d.ts +1 -0
- package/src/lib/auth.js +32 -0
- package/src/lib/auth.js.map +1 -0
- package/src/lib/common/client.d.ts +53 -0
- package/src/lib/common/client.js +47 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/utils.d.ts +5 -0
- package/src/lib/common/utils.js +16 -0
- package/src/lib/common/utils.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taskmagic/apps-postmark",
|
|
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 @@
|
|
|
1
|
+
export declare const postmark: import("@taskmagic/pieces-framework").Piece<import("@taskmagic/pieces-framework").SecretTextProperty<true>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postmark = 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 get_delivery_stats_1 = require("./lib/actions/get-delivery-stats");
|
|
9
|
+
const get_bounces_1 = require("./lib/actions/get-bounces");
|
|
10
|
+
const send_email_1 = require("./lib/actions/send-email");
|
|
11
|
+
const send_email_with_template_1 = require("./lib/actions/send-email-with-template");
|
|
12
|
+
const auth_1 = require("./lib/auth");
|
|
13
|
+
exports.postmark = (0, pieces_framework_1.createPiece)({
|
|
14
|
+
displayName: 'Postmark',
|
|
15
|
+
description: 'Transactional email platform for sending email, templates, and retrieving delivery and bounce insights.',
|
|
16
|
+
minimumSupportedRelease: '0.30.0',
|
|
17
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/postmark.png',
|
|
18
|
+
authors: ['Harmatta', 'Angelebeats'],
|
|
19
|
+
categories: [shared_1.PieceCategory.COMMUNICATION, shared_1.PieceCategory.MARKETING],
|
|
20
|
+
auth: auth_1.postmarkAuth,
|
|
21
|
+
actions: [
|
|
22
|
+
send_email_1.sendEmail,
|
|
23
|
+
send_email_with_template_1.sendEmailWithTemplate,
|
|
24
|
+
get_bounces_1.getEmailBounces,
|
|
25
|
+
get_delivery_stats_1.getDeliveryStats,
|
|
26
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
27
|
+
baseUrl: () => 'https://api.postmarkapp.com',
|
|
28
|
+
auth: auth_1.postmarkAuth,
|
|
29
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
return ({
|
|
31
|
+
'X-Postmark-Server-Token': auth,
|
|
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/postmark/src/index.ts"],"names":[],"mappings":";;;;AAAA,4DAAqE;AACrE,kEAA0D;AAC1D,8CAAkD;AAElD,yEAAoE;AACpE,2DAA4D;AAC5D,yDAAqD;AACrD,qFAA+E;AAC/E,qCAA0C;AAE7B,QAAA,QAAQ,GAAG,IAAA,8BAAW,EAAC;IAClC,WAAW,EAAE,UAAU;IACvB,WAAW,EACT,yGAAyG;IAC3G,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,kDAAkD;IAC3D,OAAO,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC;IACpC,UAAU,EAAE,CAAC,sBAAa,CAAC,aAAa,EAAE,sBAAa,CAAC,SAAS,CAAC;IAClE,IAAI,EAAE,mBAAY;IAClB,OAAO,EAAE;QACP,sBAAS;QACT,gDAAqB;QACrB,6BAAe;QACf,qCAAgB;QAChB,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,6BAA6B;YAC5C,IAAI,EAAE,mBAAY;YAClB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,yBAAyB,EAAE,IAAc;iBAC1C,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const getEmailBounces: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
count: import("@taskmagic/pieces-framework").NumberProperty<true>;
|
|
3
|
+
offset: import("@taskmagic/pieces-framework").NumberProperty<true>;
|
|
4
|
+
type: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
inactive: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
6
|
+
emailFilter: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
messageId: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEmailBounces = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const client_1 = require("../common/client");
|
|
8
|
+
exports.getEmailBounces = (0, pieces_framework_1.createAction)({
|
|
9
|
+
name: 'get_email_bounces',
|
|
10
|
+
displayName: 'Get Email Bounces',
|
|
11
|
+
description: 'List bounces from your Postmark server.',
|
|
12
|
+
auth: auth_1.postmarkAuth,
|
|
13
|
+
props: {
|
|
14
|
+
count: pieces_framework_1.Property.Number({
|
|
15
|
+
displayName: 'Count',
|
|
16
|
+
description: 'Maximum number of bounces to return (max 500).',
|
|
17
|
+
required: true,
|
|
18
|
+
defaultValue: 25,
|
|
19
|
+
}),
|
|
20
|
+
offset: pieces_framework_1.Property.Number({
|
|
21
|
+
displayName: 'Offset',
|
|
22
|
+
description: 'Number of bounces to skip before returning results.',
|
|
23
|
+
required: true,
|
|
24
|
+
defaultValue: 0,
|
|
25
|
+
}),
|
|
26
|
+
type: pieces_framework_1.Property.ShortText({
|
|
27
|
+
displayName: 'Type',
|
|
28
|
+
description: 'Optional bounce type filter, for example HardBounce.',
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
31
|
+
inactive: pieces_framework_1.Property.Checkbox({
|
|
32
|
+
displayName: 'Inactive Only',
|
|
33
|
+
description: 'Filter by inactive bounces only. When not set, both active and inactive bounces are returned.',
|
|
34
|
+
required: false,
|
|
35
|
+
}),
|
|
36
|
+
emailFilter: pieces_framework_1.Property.ShortText({
|
|
37
|
+
displayName: 'Email Filter',
|
|
38
|
+
description: 'Filter results by bounced recipient email address.',
|
|
39
|
+
required: false,
|
|
40
|
+
}),
|
|
41
|
+
messageId: pieces_framework_1.Property.ShortText({
|
|
42
|
+
displayName: 'Message ID',
|
|
43
|
+
description: 'Filter results by Postmark message ID.',
|
|
44
|
+
required: false,
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
run(context) {
|
|
48
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
var _a, _b, _c, _d, _e;
|
|
50
|
+
const props = context.propsValue;
|
|
51
|
+
const count = (_a = props.count) !== null && _a !== void 0 ? _a : 25;
|
|
52
|
+
const offset = (_b = props.offset) !== null && _b !== void 0 ? _b : 0;
|
|
53
|
+
const queryParams = {
|
|
54
|
+
count: count.toString(),
|
|
55
|
+
offset: offset.toString(),
|
|
56
|
+
};
|
|
57
|
+
if ((_c = props.type) === null || _c === void 0 ? void 0 : _c.trim()) {
|
|
58
|
+
queryParams['type'] = props.type.trim();
|
|
59
|
+
}
|
|
60
|
+
if (props.inactive === true) {
|
|
61
|
+
queryParams['inactive'] = 'true';
|
|
62
|
+
}
|
|
63
|
+
if ((_d = props.emailFilter) === null || _d === void 0 ? void 0 : _d.trim()) {
|
|
64
|
+
queryParams['emailFilter'] = props.emailFilter.trim();
|
|
65
|
+
}
|
|
66
|
+
if ((_e = props.messageId) === null || _e === void 0 ? void 0 : _e.trim()) {
|
|
67
|
+
queryParams['messageID'] = props.messageId.trim();
|
|
68
|
+
}
|
|
69
|
+
const response = yield client_1.postmarkClient.get(context.auth, '/bounces', queryParams);
|
|
70
|
+
return response;
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=get-bounces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-bounces.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/postmark/src/lib/actions/get-bounces.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AAErE,kCAAuC;AACvC,6CAAsE;AAWzD,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,mBAAmB;IACz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EAAE,MAAM,CAAC,QAAQ,EAAE;aAC1B,CAAC;YAEF,IAAI,MAAA,KAAK,CAAC,IAAI,0CAAE,IAAI,EAAE,EAAE,CAAC;gBACvB,WAAW,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1C,CAAC;YACD,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;gBAC5B,WAAW,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;YACnC,CAAC;YACD,IAAI,MAAA,KAAK,CAAC,WAAW,0CAAE,IAAI,EAAE,EAAE,CAAC;gBAC9B,WAAW,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YACxD,CAAC;YACD,IAAI,MAAA,KAAK,CAAC,SAAS,0CAAE,IAAI,EAAE,EAAE,CAAC;gBAC5B,WAAW,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YACpD,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,uBAAc,CAAC,GAAG,CACvC,OAAO,CAAC,IAAc,EACtB,UAAU,EACV,WAAW,CACZ,CAAC;YAEF,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getDeliveryStats: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {}>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDeliveryStats = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const client_1 = require("../common/client");
|
|
8
|
+
exports.getDeliveryStats = (0, pieces_framework_1.createAction)({
|
|
9
|
+
name: 'get_delivery_stats',
|
|
10
|
+
displayName: 'Get Delivery Stats',
|
|
11
|
+
description: 'Retrieve delivery statistics for the current Postmark server.',
|
|
12
|
+
auth: auth_1.postmarkAuth,
|
|
13
|
+
props: {},
|
|
14
|
+
run(context) {
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const response = yield client_1.postmarkClient.get(context.auth, '/deliverystats');
|
|
17
|
+
return response;
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=get-delivery-stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-delivery-stats.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/postmark/src/lib/actions/get-delivery-stats.ts"],"names":[],"mappings":";;;;AAAA,kEAA2D;AAE3D,kCAAuC;AACvC,6CAAyE;AAE5D,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,+DAA+D;IAC5E,IAAI,EAAE,mBAAY;IAClB,KAAK,EAAE,EAAE;IACH,GAAG,CAAC,OAAO;;YACf,MAAM,QAAQ,GAAG,MAAM,uBAAc,CAAC,GAAG,CACvC,OAAO,CAAC,IAAc,EACtB,gBAAgB,CACjB,CAAC;YAEF,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const sendEmailWithTemplate: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
from: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
to: import("@taskmagic/pieces-framework").ArrayProperty<true>;
|
|
4
|
+
cc: import("@taskmagic/pieces-framework").ArrayProperty<false>;
|
|
5
|
+
bcc: import("@taskmagic/pieces-framework").ArrayProperty<false>;
|
|
6
|
+
replyTo: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
templateId: import("@taskmagic/pieces-framework").NumberProperty<true>;
|
|
8
|
+
templateModel: import("@taskmagic/pieces-framework").JsonProperty<true>;
|
|
9
|
+
tag: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
10
|
+
trackOpens: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
11
|
+
messageStream: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendEmailWithTemplate = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const client_1 = require("../common/client");
|
|
8
|
+
const utils_1 = require("../common/utils");
|
|
9
|
+
exports.sendEmailWithTemplate = (0, pieces_framework_1.createAction)({
|
|
10
|
+
name: 'send_email_with_template',
|
|
11
|
+
displayName: 'Send Email With Template',
|
|
12
|
+
description: 'Send an email using a Postmark template ID and template model.',
|
|
13
|
+
auth: auth_1.postmarkAuth,
|
|
14
|
+
props: {
|
|
15
|
+
from: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'From',
|
|
17
|
+
description: 'Sender email address configured in Postmark.',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
to: pieces_framework_1.Property.Array({
|
|
21
|
+
displayName: 'To',
|
|
22
|
+
description: 'Recipient email addresses.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
cc: pieces_framework_1.Property.Array({
|
|
26
|
+
displayName: 'CC',
|
|
27
|
+
required: false,
|
|
28
|
+
}),
|
|
29
|
+
bcc: pieces_framework_1.Property.Array({
|
|
30
|
+
displayName: 'BCC',
|
|
31
|
+
required: false,
|
|
32
|
+
}),
|
|
33
|
+
replyTo: pieces_framework_1.Property.ShortText({
|
|
34
|
+
displayName: 'Reply To',
|
|
35
|
+
required: false,
|
|
36
|
+
}),
|
|
37
|
+
templateId: pieces_framework_1.Property.Number({
|
|
38
|
+
displayName: 'Template ID',
|
|
39
|
+
description: 'Numeric Postmark template ID.',
|
|
40
|
+
required: true,
|
|
41
|
+
}),
|
|
42
|
+
templateModel: pieces_framework_1.Property.Json({
|
|
43
|
+
displayName: 'Template Model',
|
|
44
|
+
description: 'JSON object used to populate the Postmark template.',
|
|
45
|
+
required: true,
|
|
46
|
+
}),
|
|
47
|
+
tag: pieces_framework_1.Property.ShortText({
|
|
48
|
+
displayName: 'Tag',
|
|
49
|
+
required: false,
|
|
50
|
+
}),
|
|
51
|
+
trackOpens: pieces_framework_1.Property.Checkbox({
|
|
52
|
+
displayName: 'Track Opens',
|
|
53
|
+
required: false,
|
|
54
|
+
defaultValue: true,
|
|
55
|
+
}),
|
|
56
|
+
messageStream: pieces_framework_1.Property.ShortText({
|
|
57
|
+
displayName: 'Message Stream',
|
|
58
|
+
description: 'Defaults to outbound if omitted.',
|
|
59
|
+
required: false,
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
run(context) {
|
|
63
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
var _a, _b, _c;
|
|
65
|
+
const props = context.propsValue;
|
|
66
|
+
const payload = {
|
|
67
|
+
From: props.from,
|
|
68
|
+
To: (0, utils_1.normalizeEmails)(props.to),
|
|
69
|
+
Cc: (0, utils_1.normalizeEmails)(props.cc),
|
|
70
|
+
Bcc: (0, utils_1.normalizeEmails)(props.bcc),
|
|
71
|
+
ReplyTo: ((_a = props.replyTo) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
|
|
72
|
+
TemplateId: props.templateId,
|
|
73
|
+
TemplateModel: props.templateModel,
|
|
74
|
+
Tag: ((_b = props.tag) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
|
|
75
|
+
TrackOpens: props.trackOpens,
|
|
76
|
+
MessageStream: ((_c = props.messageStream) === null || _c === void 0 ? void 0 : _c.trim()) || 'outbound',
|
|
77
|
+
};
|
|
78
|
+
const response = yield client_1.postmarkClient.post(context.auth, '/email/withTemplate', payload);
|
|
79
|
+
return {
|
|
80
|
+
success: response.ErrorCode === 0,
|
|
81
|
+
response,
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=send-email-with-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-email-with-template.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/postmark/src/lib/actions/send-email-with-template.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AAErE,kCAAuC;AACvC,6CAAqE;AACrE,2CAAkD;AAerC,QAAA,qBAAqB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,0BAA0B;IAChC,WAAW,EAAE,0BAA0B;IACvC,WAAW,EAAE,gEAAgE;IAC7E,IAAI,EAAE,mBAAY;IAClB,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,8CAA8C;YAC3D,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,EAAE,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACjB,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,EAAE,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACjB,WAAW,EAAE,IAAI;YACjB,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,GAAG,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAClB,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,W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0CAAE,IAAI,EAAE,KAAI,SAAS;gBACnC,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,aAAa,EAAE,CAAA,MAAA,KAAK,CAAC,aAAa,0CAAE,IAAI,EAAE,KAAI,UAAU;aACzD,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,uBAAc,CAAC,IAAI,CACxC,OAAO,CAAC,IAAc,EACtB,qBAAqB,EACrB,OAAO,CACR,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,QAAQ,CAAC,SAAS,KAAK,CAAC;gBACjC,QAAQ;aACT,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const sendEmail: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
from: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
to: import("@taskmagic/pieces-framework").ArrayProperty<true>;
|
|
4
|
+
cc: import("@taskmagic/pieces-framework").ArrayProperty<false>;
|
|
5
|
+
bcc: import("@taskmagic/pieces-framework").ArrayProperty<false>;
|
|
6
|
+
replyTo: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
subject: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
textBody: import("@taskmagic/pieces-framework").LongTextProperty<false>;
|
|
9
|
+
htmlBody: import("@taskmagic/pieces-framework").LongTextProperty<false>;
|
|
10
|
+
tag: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
11
|
+
trackOpens: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
12
|
+
messageStream: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendEmail = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const client_1 = require("../common/client");
|
|
8
|
+
const utils_1 = require("../common/utils");
|
|
9
|
+
function assertBodyProvided(textBody, htmlBody) {
|
|
10
|
+
if (!(textBody === null || textBody === void 0 ? void 0 : textBody.trim()) && !(htmlBody === null || htmlBody === void 0 ? void 0 : htmlBody.trim())) {
|
|
11
|
+
throw new Error('Please provide a text body, an HTML body, or both.');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.sendEmail = (0, pieces_framework_1.createAction)({
|
|
15
|
+
name: 'send_email',
|
|
16
|
+
displayName: 'Send Email',
|
|
17
|
+
description: 'Send a single transactional email using Postmark.',
|
|
18
|
+
auth: auth_1.postmarkAuth,
|
|
19
|
+
props: {
|
|
20
|
+
from: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'From',
|
|
22
|
+
description: 'Sender email address configured in Postmark.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
to: pieces_framework_1.Property.Array({
|
|
26
|
+
displayName: 'To',
|
|
27
|
+
description: 'Recipient email addresses.',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
cc: pieces_framework_1.Property.Array({
|
|
31
|
+
displayName: 'CC',
|
|
32
|
+
description: 'Optional CC recipients.',
|
|
33
|
+
required: false,
|
|
34
|
+
}),
|
|
35
|
+
bcc: pieces_framework_1.Property.Array({
|
|
36
|
+
displayName: 'BCC',
|
|
37
|
+
description: 'Optional BCC recipients.',
|
|
38
|
+
required: false,
|
|
39
|
+
}),
|
|
40
|
+
replyTo: pieces_framework_1.Property.ShortText({
|
|
41
|
+
displayName: 'Reply To',
|
|
42
|
+
description: 'Optional reply-to email address.',
|
|
43
|
+
required: false,
|
|
44
|
+
}),
|
|
45
|
+
subject: pieces_framework_1.Property.ShortText({
|
|
46
|
+
displayName: 'Subject',
|
|
47
|
+
required: true,
|
|
48
|
+
}),
|
|
49
|
+
textBody: pieces_framework_1.Property.LongText({
|
|
50
|
+
displayName: 'Text Body',
|
|
51
|
+
required: false,
|
|
52
|
+
}),
|
|
53
|
+
htmlBody: pieces_framework_1.Property.LongText({
|
|
54
|
+
displayName: 'HTML Body',
|
|
55
|
+
required: false,
|
|
56
|
+
}),
|
|
57
|
+
tag: pieces_framework_1.Property.ShortText({
|
|
58
|
+
displayName: 'Tag',
|
|
59
|
+
required: false,
|
|
60
|
+
}),
|
|
61
|
+
trackOpens: pieces_framework_1.Property.Checkbox({
|
|
62
|
+
displayName: 'Track Opens',
|
|
63
|
+
required: false,
|
|
64
|
+
defaultValue: true,
|
|
65
|
+
}),
|
|
66
|
+
messageStream: pieces_framework_1.Property.ShortText({
|
|
67
|
+
displayName: 'Message Stream',
|
|
68
|
+
description: 'Defaults to outbound if omitted.',
|
|
69
|
+
required: false,
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
72
|
+
run(context) {
|
|
73
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
var _a, _b, _c, _d, _e;
|
|
75
|
+
const props = context.propsValue;
|
|
76
|
+
assertBodyProvided(props.textBody, props.htmlBody);
|
|
77
|
+
const payload = {
|
|
78
|
+
From: props.from,
|
|
79
|
+
To: (0, utils_1.normalizeEmails)(props.to),
|
|
80
|
+
Cc: (0, utils_1.normalizeEmails)(props.cc),
|
|
81
|
+
Bcc: (0, utils_1.normalizeEmails)(props.bcc),
|
|
82
|
+
ReplyTo: ((_a = props.replyTo) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
|
|
83
|
+
Subject: props.subject,
|
|
84
|
+
TextBody: ((_b = props.textBody) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
|
|
85
|
+
HtmlBody: ((_c = props.htmlBody) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
|
|
86
|
+
Tag: ((_d = props.tag) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|
|
87
|
+
TrackOpens: props.trackOpens,
|
|
88
|
+
MessageStream: ((_e = props.messageStream) === null || _e === void 0 ? void 0 : _e.trim()) || 'outbound',
|
|
89
|
+
};
|
|
90
|
+
const response = yield client_1.postmarkClient.post(context.auth, '/email', payload);
|
|
91
|
+
return {
|
|
92
|
+
success: response.ErrorCode === 0,
|
|
93
|
+
response,
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=send-email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-email.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/postmark/src/lib/actions/send-email.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AAErE,kCAAuC;AACvC,6CAAqE;AACrE,2CAAkD;AAgBlD,SAAS,kBAAkB,CAAC,QAAiB,EAAE,QAAiB;IAC9D,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE,CAAA,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE,CAAA,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;AACH,CAAC;AAEY,QAAA,SAAS,GAAG,IAAA,+BAAY,EAAC;IACpC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,mDAAmD;IAChE,IAAI,EAAE,mBAAY;IAClB,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,8CAA8C;YAC3D,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,EAAE,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACjB,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,EAAE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C;YAEnD,MAAM,OAAO,GAAG;gBACd,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,EAAE,EAAE,IAAA,uBAAe,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,EAAE,EAAE,IAAA,uBAAe,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,GAAG,EAAE,IAAA,uBAAe,EAAC,KAAK,CAAC,GAAG,CAAC;gBAC/B,OAAO,EAAE,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,IAAI,EAAE,KAAI,SAAS;gBAC3C,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,QAAQ,EAAE,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,EAAE,KAAI,SAAS;gBAC7C,QAAQ,EAAE,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,EAAE,KAAI,SAAS;gBAC7C,GAAG,EAAE,CAAA,MAAA,KAAK,CAAC,GAAG,0CAAE,IAAI,EAAE,KAAI,SAAS;gBACnC,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,aAAa,EAAE,CAAA,MAAA,KAAK,CAAC,aAAa,0CAAE,IAAI,EAAE,KAAI,UAAU;aACzD,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,uBAAc,CAAC,IAAI,CACxC,OAAO,CAAC,IAAc,EACtB,QAAQ,EACR,OAAO,CACR,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,QAAQ,CAAC,SAAS,KAAK,CAAC;gBACjC,QAAQ;aACT,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const postmarkAuth: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postmarkAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const client_1 = require("./common/client");
|
|
7
|
+
exports.postmarkAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
8
|
+
displayName: 'Server API Token',
|
|
9
|
+
description: 'Create or copy a Postmark Server API Token from Servers → API Tokens in Postmark.',
|
|
10
|
+
required: true,
|
|
11
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
12
|
+
try {
|
|
13
|
+
const response = yield client_1.postmarkClient.get(auth, '/message-streams');
|
|
14
|
+
if (!response || !Array.isArray(response.MessageStreams)) {
|
|
15
|
+
return {
|
|
16
|
+
valid: false,
|
|
17
|
+
error: 'Unexpected response while validating Postmark token.',
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return { valid: true };
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return {
|
|
24
|
+
valid: false,
|
|
25
|
+
error: error instanceof Error
|
|
26
|
+
? error.message
|
|
27
|
+
: 'Failed to validate Postmark Server API Token.',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/community/postmark/src/lib/auth.ts"],"names":[],"mappings":";;;;AAAA,kEAAwD;AAExD,4CAA4E;AAE/D,QAAA,YAAY,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC/C,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EACT,mFAAmF;IACrF,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,uBAAc,CAAC,GAAG,CACvC,IAAc,EACd,kBAAkB,CACnB,CAAC;YAEF,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;gBACzD,OAAO;oBACL,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,sDAAsD;iBAC9D,CAAC;YACJ,CAAC;YAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EACH,KAAK,YAAY,KAAK;oBACpB,CAAC,CAAC,KAAK,CAAC,OAAO;oBACf,CAAC,CAAC,+CAA+C;aACtD,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { QueryParams } from '@taskmagic/pieces-common';
|
|
2
|
+
export declare const postmarkClient: {
|
|
3
|
+
get: <TResponse>(apiToken: string, path: string, queryParams?: QueryParams) => Promise<TResponse>;
|
|
4
|
+
post: <TResponse>(apiToken: string, path: string, body?: unknown) => Promise<TResponse>;
|
|
5
|
+
};
|
|
6
|
+
export type MessageStream = {
|
|
7
|
+
ID: string;
|
|
8
|
+
ServerID?: number;
|
|
9
|
+
Name: string;
|
|
10
|
+
MessageStreamType?: string;
|
|
11
|
+
Description?: string;
|
|
12
|
+
ArchivedAt?: string | null;
|
|
13
|
+
};
|
|
14
|
+
export type MessageStreamListResponse = {
|
|
15
|
+
MessageStreams: MessageStream[];
|
|
16
|
+
TotalCount: number;
|
|
17
|
+
};
|
|
18
|
+
export type SendEmailResponse = {
|
|
19
|
+
To: string;
|
|
20
|
+
SubmittedAt: string;
|
|
21
|
+
MessageID: string;
|
|
22
|
+
ErrorCode: number;
|
|
23
|
+
Message: string;
|
|
24
|
+
};
|
|
25
|
+
export type Bounce = {
|
|
26
|
+
ID: number;
|
|
27
|
+
Type: string;
|
|
28
|
+
TypeCode: number;
|
|
29
|
+
Name?: string;
|
|
30
|
+
Tag?: string;
|
|
31
|
+
MessageID: string;
|
|
32
|
+
Description: string;
|
|
33
|
+
Details?: string;
|
|
34
|
+
Email: string;
|
|
35
|
+
BouncedAt: string;
|
|
36
|
+
DumpAvailable?: boolean;
|
|
37
|
+
Inactive?: boolean;
|
|
38
|
+
CanActivate?: boolean;
|
|
39
|
+
Content?: string;
|
|
40
|
+
Subject?: string;
|
|
41
|
+
};
|
|
42
|
+
export type BounceListResponse = {
|
|
43
|
+
TotalCount: number;
|
|
44
|
+
Bounces: Bounce[];
|
|
45
|
+
};
|
|
46
|
+
export type DeliveryStatsResponse = {
|
|
47
|
+
InactiveMails?: number;
|
|
48
|
+
Bounces?: Array<{
|
|
49
|
+
Type: string;
|
|
50
|
+
Name: string;
|
|
51
|
+
Count: number;
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postmarkClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
6
|
+
const POSTMARK_API_BASE_URL = 'https://api.postmarkapp.com';
|
|
7
|
+
function postmarkRequest(_a) {
|
|
8
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ method, path, apiToken, body, queryParams, }) {
|
|
9
|
+
var _b, _c, _d, _e;
|
|
10
|
+
try {
|
|
11
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
12
|
+
method,
|
|
13
|
+
url: `${POSTMARK_API_BASE_URL}${path}`,
|
|
14
|
+
headers: {
|
|
15
|
+
Accept: 'application/json',
|
|
16
|
+
'Content-Type': 'application/json',
|
|
17
|
+
'X-Postmark-Server-Token': apiToken,
|
|
18
|
+
},
|
|
19
|
+
body,
|
|
20
|
+
queryParams,
|
|
21
|
+
});
|
|
22
|
+
return response.body;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
const postmarkError = error;
|
|
26
|
+
const message = (_d = (_c = (_b = postmarkError.response) === null || _b === void 0 ? void 0 : _b.body) === null || _c === void 0 ? void 0 : _c.Message) !== null && _d !== void 0 ? _d : `Postmark API request failed${((_e = postmarkError.response) === null || _e === void 0 ? void 0 : _e.status)
|
|
27
|
+
? ` (${postmarkError.response.status})`
|
|
28
|
+
: ''}`;
|
|
29
|
+
throw new Error(message);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.postmarkClient = {
|
|
34
|
+
get: (apiToken, path, queryParams) => postmarkRequest({
|
|
35
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
36
|
+
path,
|
|
37
|
+
apiToken,
|
|
38
|
+
queryParams,
|
|
39
|
+
}),
|
|
40
|
+
post: (apiToken, path, body) => postmarkRequest({
|
|
41
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
42
|
+
path,
|
|
43
|
+
apiToken,
|
|
44
|
+
body,
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/postmark/src/lib/common/client.ts"],"names":[],"mappings":";;;;AAAA,4DAIkC;AAElC,MAAM,qBAAqB,GAAG,6BAA6B,CAAC;AAe5D,SAAe,eAAe;iEAAY,EACxC,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,WAAW,GACQ;;QACnB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAY;gBACvD,MAAM;gBACN,GAAG,EAAE,GAAG,qBAAqB,GAAG,IAAI,EAAE;gBACtC,OAAO,EAAE;oBACP,MAAM,EAAE,kBAAkB;oBAC1B,cAAc,EAAE,kBAAkB;oBAClC,yBAAyB,EAAE,QAAQ;iBACpC;gBACD,IAAI;gBACJ,WAAW;aACZ,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,aAAa,GAAG,KAErB,CAAC;YACF,MAAM,OAAO,GACX,MAAA,MAAA,MAAA,aAAa,CAAC,QAAQ,0CAAE,IAAI,0CAAE,OAAO,mCACrC,8BACE,CAAA,MAAA,aAAa,CAAC,QAAQ,0CAAE,MAAM;gBAC5B,CAAC,CAAC,KAAK,aAAa,CAAC,QAAQ,CAAC,MAAM,GAAG;gBACvC,CAAC,CAAC,EACN,EAAE,CAAC;YACL,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;CAAA;AAEY,QAAA,cAAc,GAAG;IAC5B,GAAG,EAAE,CAAY,QAAgB,EAAE,IAAY,EAAE,WAAyB,EAAE,EAAE,CAC5E,eAAe,CAAY;QACzB,MAAM,EAAE,0BAAU,CAAC,GAAG;QACtB,IAAI;QACJ,QAAQ;QACR,WAAW;KACZ,CAAC;IACJ,IAAI,EAAE,CAAY,QAAgB,EAAE,IAAY,EAAE,IAAc,EAAE,EAAE,CAClE,eAAe,CAAY;QACzB,MAAM,EAAE,0BAAU,CAAC,IAAI;QACvB,IAAI;QACJ,QAAQ;QACR,IAAI;KACL,CAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeEmails = normalizeEmails;
|
|
4
|
+
/**
|
|
5
|
+
* Normalise an optional array of email addresses into a single
|
|
6
|
+
* comma-separated string accepted by the Postmark API.
|
|
7
|
+
*/
|
|
8
|
+
function normalizeEmails(emails) {
|
|
9
|
+
if (!emails || emails.length === 0)
|
|
10
|
+
return undefined;
|
|
11
|
+
return emails
|
|
12
|
+
.map((e) => e.trim())
|
|
13
|
+
.filter((e) => e.length > 0)
|
|
14
|
+
.join(', ');
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/postmark/src/lib/common/utils.ts"],"names":[],"mappings":";;AAIA,0CAMC;AAVD;;;GAGG;AACH,SAAgB,eAAe,CAAC,MAAiB;IAC/C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACrD,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;SAC3B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|