@activepieces/piece-resend 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 ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-resend
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running lint
6
+
7
+ Run `nx lint pieces-resend` to execute the lint via [ESLint](https://eslint.org/).
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@activepieces/piece-resend",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "0.26.8",
6
+ "axios": "1.2.4",
7
+ "lodash": "4.17.21",
8
+ "nanoid": "3.3.4",
9
+ "@activepieces/pieces-framework": "0.3.28",
10
+ "@activepieces/shared": "0.3.46",
11
+ "@activepieces/pieces-common": "0.0.7",
12
+ "tslib": "2.5.3"
13
+ },
14
+ "main": "./src/index.js",
15
+ "types": "./src/index.d.ts"
16
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const resend: import("@activepieces/pieces-framework").Piece;
package/src/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resend = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const send_email_1 = require("./lib/actions/send-email");
6
+ exports.resend = (0, pieces_framework_1.createPiece)({
7
+ displayName: "Resend",
8
+ logoUrl: "https://cdn.activepieces.com/pieces/resend.png",
9
+ authors: [],
10
+ actions: [send_email_1.sendEmail],
11
+ triggers: [],
12
+ });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/resend/src/index.ts"],"names":[],"mappings":";;;AACA,qEAA6D;AAC7D,yDAAqD;AAExC,QAAA,MAAM,GAAG,IAAA,8BAAW,EAAC;IAChC,WAAW,EAAE,QAAQ;IACrB,OAAO,EAAE,gDAAgD;IACzD,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,CAAC,sBAAS,CAAC;IACpB,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const sendEmail: import("@activepieces/pieces-framework").Action;
@@ -0,0 +1,102 @@
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("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ exports.sendEmail = (0, pieces_framework_1.createAction)({
8
+ name: 'send_email',
9
+ displayName: "Send Email",
10
+ description: "Send a text or HTML email",
11
+ props: {
12
+ authentication: pieces_framework_1.Property.SecretText({
13
+ displayName: "API Key",
14
+ required: true,
15
+ }),
16
+ to: pieces_framework_1.Property.Array({
17
+ displayName: 'To',
18
+ description: 'Emails of the recipients',
19
+ required: true,
20
+ }),
21
+ from_name: pieces_framework_1.Property.ShortText({
22
+ displayName: 'Sender Name',
23
+ description: 'Sender name',
24
+ required: true,
25
+ }),
26
+ from: pieces_framework_1.Property.ShortText({
27
+ displayName: 'Sender Email (From)',
28
+ description: 'Sender email',
29
+ required: true,
30
+ }),
31
+ bcc: pieces_framework_1.Property.Array({
32
+ displayName: "BCC",
33
+ description: "List of emails in bcc",
34
+ required: false,
35
+ }),
36
+ cc: pieces_framework_1.Property.Array({
37
+ displayName: "CC",
38
+ description: "List of emails in cc",
39
+ required: false,
40
+ }),
41
+ reply_to: pieces_framework_1.Property.ShortText({
42
+ displayName: 'Reply To',
43
+ description: 'Email to receive replies on (defaults to sender)',
44
+ required: false,
45
+ }),
46
+ subject: pieces_framework_1.Property.ShortText({
47
+ displayName: 'Subject',
48
+ description: undefined,
49
+ required: true,
50
+ }),
51
+ content_type: pieces_framework_1.Property.Dropdown({
52
+ displayName: "Content Type",
53
+ refreshers: [],
54
+ required: true,
55
+ defaultValue: 'html',
56
+ options: () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
57
+ return {
58
+ disabled: false,
59
+ options: [
60
+ { label: 'Plain Text', value: 'text' },
61
+ { label: 'HTML', value: 'html' },
62
+ ]
63
+ };
64
+ })
65
+ }),
66
+ content: pieces_framework_1.Property.ShortText({
67
+ displayName: 'Content',
68
+ description: 'HTML is only allowed if you selected HTML as type',
69
+ required: true,
70
+ }),
71
+ },
72
+ run(context) {
73
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
74
+ const { to, from, from_name, reply_to, subject, content_type, content, cc, bcc } = context.propsValue;
75
+ const requestBody = {
76
+ to,
77
+ from: from_name ? `${from_name} <${from}>` : from,
78
+ reply_to: reply_to !== null && reply_to !== void 0 ? reply_to : from,
79
+ cc,
80
+ bcc,
81
+ subject: subject,
82
+ };
83
+ if (content_type === 'text') {
84
+ requestBody['text'] = content;
85
+ }
86
+ else if (content_type === 'html') {
87
+ requestBody['html'] = content;
88
+ }
89
+ return yield pieces_common_1.httpClient.sendRequest({
90
+ method: pieces_common_1.HttpMethod.POST,
91
+ url: `https://api.resend.com/emails`,
92
+ body: requestBody,
93
+ authentication: {
94
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
95
+ token: context.propsValue.authentication,
96
+ },
97
+ queryParams: {},
98
+ });
99
+ });
100
+ }
101
+ });
102
+ //# sourceMappingURL=send-email.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-email.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/resend/src/lib/actions/send-email.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyF;AAE5E,QAAA,SAAS,GAAG,IAAA,+BAAY,EAAC;IAClC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,2BAA2B;IACxC,KAAK,EAAE;QACH,cAAc,EAAE,2BAAQ,CAAC,UAAU,CAAC;YAChC,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,IAAI;SACjB,CAA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