@activepieces/piece-gmail 0.0.0-pre1

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-gmail
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running lint
6
+
7
+ Run `nx lint pieces-gmail` to execute the lint via [ESLint](https://eslint.org/).
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@activepieces/piece-gmail",
3
+ "version": "0.0.0-pre1",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "0.24.51",
6
+ "axios": "1.2.4",
7
+ "cron-validator": "1.3.1",
8
+ "nanoid": "3.3.4"
9
+ },
10
+ "peerDependencies": {
11
+ "@activepieces/framework": "0.0.1",
12
+ "@activepieces/shared": "0.0.1",
13
+ "tslib": "2.4.1"
14
+ },
15
+ "main": "./src/index.js",
16
+ "types": "./src/index.d.ts"
17
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const gmail: import("@activepieces/framework").Piece;
package/src/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gmail = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const package_json_1 = tslib_1.__importDefault(require("../package.json"));
6
+ const framework_1 = require("@activepieces/framework");
7
+ const send_email_action_1 = require("./lib/actions/send-email-action");
8
+ exports.gmail = (0, framework_1.createPiece)({
9
+ name: 'gmail',
10
+ logoUrl: 'https://cdn.activepieces.com/pieces/gmail.png',
11
+ actions: [send_email_action_1.gmailSendEmailAction],
12
+ displayName: 'Gmail',
13
+ authors: ['AbdulTheActivePiecer'],
14
+ triggers: [],
15
+ version: package_json_1.default.version,
16
+ });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/gmail/src/index.ts"],"names":[],"mappings":";;;;AAAA,2EAA0C;AAC1C,uDAAsD;AACtD,uEAAqE;AAExD,QAAA,KAAK,GAAG,IAAA,uBAAW,EAAC;IAChC,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,+CAA+C;IACxD,OAAO,EAAE,CAAC,wCAAoB,CAAC;IAC9B,WAAW,EAAC,OAAO;IACpB,OAAO,EAAE,CAAC,sBAAsB,CAAC;IACjC,QAAQ,EAAE,EAAE;IACX,OAAO,EAAE,sBAAW,CAAC,OAAO;CAC7B,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const gmailSendEmailAction: import("@activepieces/framework").Action;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gmailSendEmailAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ exports.gmailSendEmailAction = (0, framework_1.createAction)({
7
+ name: 'send_email',
8
+ description: 'Send an email through a Gmail account',
9
+ displayName: 'Send Email',
10
+ props: {
11
+ authentication: framework_1.Property.OAuth2({
12
+ description: "",
13
+ displayName: 'Authentication',
14
+ authUrl: "https://accounts.google.com/o/oauth2/auth",
15
+ tokenUrl: "https://oauth2.googleapis.com/token",
16
+ required: true,
17
+ scope: ["https://mail.google.com/"]
18
+ }),
19
+ receiver: framework_1.Property.ShortText({
20
+ displayName: 'Receiver Email (To)',
21
+ description: undefined,
22
+ required: true,
23
+ }),
24
+ subject: framework_1.Property.ShortText({
25
+ displayName: 'Subject',
26
+ description: undefined,
27
+ required: true,
28
+ }),
29
+ body_text: framework_1.Property.ShortText({
30
+ displayName: 'Body (Text)',
31
+ description: 'Text version of the body for the email you want to send',
32
+ required: true,
33
+ }),
34
+ body_html: framework_1.Property.ShortText({
35
+ displayName: 'Body (HTML)',
36
+ description: 'HTML version of the body for the email you want to send',
37
+ required: false,
38
+ })
39
+ },
40
+ sampleData: {},
41
+ run(configValue) {
42
+ var _a;
43
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
44
+ const headers = [
45
+ "subject: " + configValue.propsValue['subject'],
46
+ "to: " + configValue.propsValue['receiver'],
47
+ "mime-version: 1.0",
48
+ "content-type: text/html"
49
+ ];
50
+ const message = headers.join("\n") + "\n\n" + ((_a = configValue.propsValue['body_html']) !== null && _a !== void 0 ? _a : configValue.propsValue['body_text']);
51
+ const requestBody = {
52
+ raw: Buffer.from(message).toString("base64").replace(/\+/g, '-').replace(/\//g, '_'),
53
+ };
54
+ const request = {
55
+ method: framework_1.HttpMethod.POST,
56
+ url: `https://gmail.googleapis.com/gmail/v1/users/me/messages/send`,
57
+ body: requestBody,
58
+ authentication: {
59
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
60
+ token: configValue.propsValue['authentication']['access_token'],
61
+ },
62
+ queryParams: {},
63
+ };
64
+ return yield framework_1.httpClient.sendRequest(request);
65
+ });
66
+ },
67
+ });
68
+ //# sourceMappingURL=send-email-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-email-action.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/gmail/src/lib/actions/send-email-action.ts"],"names":[],"mappings":";;;;AAAA,uDAA0H;AAE7G,QAAA,oBAAoB,GAAG,IAAA,wBAAY,EAAC;IAChD,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,uCAAuC;IACjD,WAAW,EAAC,YAAY;IAC3B,KAAK,EAAE;QACN,cAAc,EAAE,oBAAQ,CAAC,MAAM,CAAC;YAC/B,WAAW,EAAE,EAAE;YACf,WAAW,EAAE,gBAAgB;YAC7B,OAAO,EAAE,2CAA2C;YACpD,QAAQ,EAAE,qCAAqC;YAC/C,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,CAAC,0BAA0B,CAAC;SACnC,CAAC;QACF,QAAQ,EAAE,oBAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,qBAAqB;YAClC,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,IAAI;SACd,CAAC;QACF,O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