@activepieces/piece-line 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-line
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-line` to build the library.
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@activepieces/piece-line",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "0.26.8",
6
+ "axios": "^1.6.0",
7
+ "dayjs": "1.11.9",
8
+ "is-base64": "1.1.0",
9
+ "lodash": "4.17.21",
10
+ "nanoid": "3.3.6",
11
+ "semver": "7.5.4",
12
+ "@activepieces/pieces-common": "0.2.5",
13
+ "@activepieces/pieces-framework": "0.7.4",
14
+ "@activepieces/shared": "0.10.45",
15
+ "tslib": "1.14.1"
16
+ },
17
+ "main": "./src/index.js",
18
+ "type": "commonjs"
19
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const lineAuth2: import("@activepieces/pieces-framework").SecretTextProperty<true>;
2
+ export declare const line: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
package/src/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.line = exports.lineAuth2 = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const push_message_1 = require("./lib/actions/push-message");
6
+ const new_message_1 = require("./lib/trigger/new-message");
7
+ exports.lineAuth2 = pieces_framework_1.PieceAuth.SecretText({
8
+ displayName: "Bot Token",
9
+ required: true,
10
+ });
11
+ exports.line = (0, pieces_framework_1.createPiece)({
12
+ displayName: "Line Bot",
13
+ auth: exports.lineAuth2,
14
+ minimumSupportedRelease: '0.9.0',
15
+ logoUrl: "https://cdn.activepieces.com/pieces/line.png",
16
+ authors: ["abuaboud"],
17
+ actions: [push_message_1.pushMessage],
18
+ triggers: [new_message_1.newMessage],
19
+ });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/line/src/index.ts"],"names":[],"mappings":";;;AACA,qEAAwE;AACxE,6DAAyD;AACzD,2DAAuD;AAE1C,QAAA,SAAS,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC5C,WAAW,EAAE,WAAW;IACxB,QAAQ,EAAE,IAAI;CACf,CAAC,CAAA;AAEW,QAAA,IAAI,GAAG,IAAA,8BAAW,EAAC;IAC9B,WAAW,EAAE,UAAU;IACvB,IAAI,EAAE,iBAAS;IACf,uBAAuB,EAAE,OAAO;IAChC,OAAO,EAAE,8CAA8C;IACvD,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,OAAO,EAAE,CAAC,0BAAW,CAAC;IACtB,QAAQ,EAAE,CAAC,wBAAU,CAAC;CACvB,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const pushMessage: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ userId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ text: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ }>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pushMessage = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const __1 = require("../..");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ exports.pushMessage = (0, pieces_framework_1.createAction)({
9
+ name: 'push_message',
10
+ auth: __1.lineAuth2,
11
+ displayName: 'Push Message',
12
+ description: 'Push message to the line account',
13
+ props: {
14
+ userId: pieces_framework_1.Property.ShortText({
15
+ displayName: 'User Id',
16
+ description: 'The user id can be obtained from the webhook payload',
17
+ required: true,
18
+ }),
19
+ text: pieces_framework_1.Property.ShortText({
20
+ displayName: 'Text',
21
+ required: true,
22
+ })
23
+ },
24
+ run(context) {
25
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
26
+ return pieces_common_1.httpClient.sendRequest({
27
+ method: pieces_common_1.HttpMethod.POST,
28
+ url: `https://api.line.me/v2/bot/message/push`,
29
+ authentication: {
30
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
31
+ token: context.auth,
32
+ },
33
+ body: {
34
+ "to": context.propsValue.userId,
35
+ "messages": [
36
+ {
37
+ "type": "text",
38
+ "text": context.propsValue.text,
39
+ }
40
+ ]
41
+ }
42
+ });
43
+ });
44
+ },
45
+ });
46
+ //# sourceMappingURL=push-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-message.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/line/src/lib/actions/push-message.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,6BAAkC;AAClC,+DAAyF;AAE5E,QAAA,WAAW,GAAG,IAAA,+BAAY,EAAC;IACpC,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,aAAS;IACf,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,kCAAkC;IAC/C,KAAK,EAAE;QACH,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,sDAAsD;YACnE,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACrB,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,IAAI;SACjB,CAAC;KACL;IACK,GAAG,CAAC,OAAO;;YACb,OAAO,0BAAU,CAAC,WAAW,CAAC;gBAC1B,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,yCAAyC;gBAC9C,cAAc,EAAE;oBACZ,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,OAAO,CAAC,IAAI;iBACtB;gBACD,IAAI,EAAE;oBACF,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM;oBAC/B,UAAU,EAAE;wBACR;4BACI,MAAM,EAAE,MAAM;4BACd,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI;yBAClC;qBACJ;iBACJ;aACJ,CAAC,CAAC;QACP,CAAC;KAAA;CACJ,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const newMessage: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").PieceAuthProperty, {
3
+ md: import("@activepieces/pieces-framework").MarkDownProperty;
4
+ }>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newMessage = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const markdown = `
7
+ - Create Line bot account from Developer Console
8
+ - Go to the "Messaging API" section.
9
+ - In the webhook settings, paste this URL:
10
+ \`{{webhookUrl}}\`
11
+ - Publish Activepieces flow first then click "Verify" button
12
+ `;
13
+ exports.newMessage = (0, pieces_framework_1.createTrigger)({
14
+ name: 'new-message',
15
+ displayName: 'New Message',
16
+ auth: pieces_framework_1.PieceAuth.None(),
17
+ description: 'Triggers when a new message is received',
18
+ props: {
19
+ md: pieces_framework_1.Property.MarkDown({
20
+ value: markdown
21
+ }),
22
+ },
23
+ type: pieces_framework_1.TriggerStrategy.WEBHOOK,
24
+ sampleData: {},
25
+ onEnable(context) {
26
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
27
+ // Empty
28
+ });
29
+ },
30
+ onDisable(context) {
31
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
32
+ // Empty
33
+ });
34
+ },
35
+ run(context) {
36
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
37
+ const { events } = context.payload.body;
38
+ if (!events) {
39
+ return [];
40
+ }
41
+ return events.filter((event) => event.mode === 'active' && event.type === 'message');
42
+ });
43
+ }
44
+ });
45
+ //# sourceMappingURL=new-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-message.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/line/src/lib/trigger/new-message.ts"],"names":[],"mappings":";;;;AAAA,qEAAqG;AAGrG,MAAM,QAAQ,GAAG;;;;;;CAMhB,CAAA;AAEY,QAAA,UAAU,GAAG,IAAA,gCAAa,EAAC;IACpC,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,IAAI,EAAE,4BAAS,CAAC,IAAI,EAAE;IACtB,WAAW,EAAE,yCAAyC;IACtD,KAAK,EAAE;QACH,EAAE,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAClB,KAAK,EAAE,QAAQ;SAClB,CAAC;KACL;IACD,IAAI,EAAE,kCAAe,CAAC,OAAO;IAC7B,UAAU,EAAE,EAAE;IACR,QAAQ,CAAC,OAAO;;YAClB,QAAQ;QACZ,CAAC;KAAA;IACK,SAAS,CAAC,OAAO;;YACnB,QAAQ;QACZ,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACb,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,IAA6B,CAAC;YACjE,IAAI,CAAC,MAAM,EAAE;gBACT,OAAO,EAAE,CAAC;aACb;YACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QAC9F,CAAC;KAAA;CACJ,CAAC,CAAC"}