@activepieces/piece-forms 0.0.2

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-forms
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-forms` to build the library.
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@activepieces/piece-forms",
3
+ "version": "0.0.2",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "0.26.8",
6
+ "axios": "^1.6.3",
7
+ "dayjs": "1.11.9",
8
+ "http-status-codes": "2.2.0",
9
+ "is-base64": "1.1.0",
10
+ "lodash": "4.17.21",
11
+ "mime-types": "2.1.35",
12
+ "nanoid": "3.3.6",
13
+ "semver": "7.6.0",
14
+ "@activepieces/pieces-framework": "0.7.19",
15
+ "@activepieces/shared": "0.10.82",
16
+ "tslib": "2.6.2"
17
+ },
18
+ "main": "./src/index.js",
19
+ "type": "commonjs"
20
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const forms: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").PieceAuthProperty>;
package/src/index.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.forms = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const return_file_1 = require("./lib/actions/return-file");
6
+ const return_markdown_1 = require("./lib/actions/return-markdown");
7
+ const form_trigger_1 = require("./lib/triggers/form-trigger");
8
+ const file_trigger_1 = require("./lib/triggers/file-trigger");
9
+ const shared_1 = require("@activepieces/shared");
10
+ exports.forms = (0, pieces_framework_1.createPiece)({
11
+ displayName: 'Forms (BETA)',
12
+ description: 'Trigger a flow through form interfaces.',
13
+ auth: pieces_framework_1.PieceAuth.None(),
14
+ minimumSupportedRelease: '0.20.3',
15
+ categories: [shared_1.PieceCategory.CORE],
16
+ logoUrl: 'https://cdn.activepieces.com/pieces/forms.png',
17
+ authors: ['MoShizzle'],
18
+ actions: [
19
+ return_file_1.returnFile,
20
+ return_markdown_1.returnMarkdown
21
+ ],
22
+ triggers: [
23
+ form_trigger_1.onFormSubmission,
24
+ file_trigger_1.onFileSubmission,
25
+ ],
26
+ });
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/forms/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AACxE,2DAAuD;AACvD,mEAA+D;AAC/D,8DAA+D;AAC/D,8DAA+D;AAC/D,iDAAqD;AAExC,QAAA,KAAK,GAAG,IAAA,8BAAW,EAAC;IAC/B,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,yCAAyC;IACtD,IAAI,EAAE,4BAAS,CAAC,IAAI,EAAE;IACtB,uBAAuB,EAAE,QAAQ;IACjC,UAAU,EAAE,CAAC,sBAAa,CAAC,IAAI,CAAC;IAChC,OAAO,EAAE,+CAA+C;IACxD,OAAO,EAAE,CAAC,WAAW,CAAC;IACtB,OAAO,EAAE;QACP,wBAAU;QACV,gCAAc;KACf;IACD,QAAQ,EAAE;QACR,+BAAgB;QAChB,+BAAgB;KACjB;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const returnFile: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
2
+ file: import("@activepieces/pieces-framework").FileProperty<true>;
3
+ }>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.returnFile = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const http_status_codes_1 = require("http-status-codes");
7
+ const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
8
+ exports.returnFile = (0, pieces_framework_1.createAction)({
9
+ name: 'return_file',
10
+ displayName: 'Respond with a file',
11
+ description: 'Download a file as a response.',
12
+ props: {
13
+ file: pieces_framework_1.Property.File({
14
+ displayName: 'File',
15
+ required: true,
16
+ }),
17
+ },
18
+ run({ propsValue, run }) {
19
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ const fileName = propsValue.file.filename;
21
+ const fileExtension = propsValue.file.extension;
22
+ const fileBase64 = propsValue.file.base64;
23
+ const mimeType = fileExtension ? mime_types_1.default.lookup(fileExtension) : 'application/octet-stream';
24
+ const base64Url = `data:${mimeType};base64,${fileBase64}`;
25
+ const value = {
26
+ base64Url,
27
+ fileName,
28
+ extension: fileExtension,
29
+ };
30
+ const response = {
31
+ status: http_status_codes_1.StatusCodes.OK,
32
+ body: {
33
+ type: 'file',
34
+ value,
35
+ },
36
+ headers: {},
37
+ };
38
+ run.stop({
39
+ response: response,
40
+ });
41
+ return response;
42
+ });
43
+ },
44
+ });
45
+ //# sourceMappingURL=return-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"return-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/forms/src/lib/actions/return-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAExE,yDAAgD;AAChD,oEAAmC;AACtB,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACrC,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,gCAAgC;IAC7C,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,IAAI,CAAC;YAClB,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE;;YAC3B,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC1C,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC;YAChD,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;YAE1C,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,oBAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC;YAC9F,MAAM,SAAS,GAAG,QAAQ,QAAQ,WAAW,UAAU,EAAE,CAAC;YAE1D,MAAM,KAAK,GAA0B;gBACnC,SAAS;gBACT,QAAQ;gBACR,SAAS,EAAE,aAAa;aAEzB,CAAA;YACD,MAAM,QAAQ,GAAG;gBACf,MAAM,EAAE,+BAAW,CAAC,EAAE;gBACtB,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;oBACZ,KAAK;iBACN;gBACD,OAAO,EAAE,EAAE;aACZ,CAAC;YAEF,GAAG,CAAC,IAAI,CAAC;gBACP,QAAQ,EAAE,QAAQ;aACnB,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const returnMarkdown: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
2
+ markdown: import("@activepieces/pieces-framework").LongTextProperty<true>;
3
+ }>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.returnMarkdown = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const http_status_codes_1 = require("http-status-codes");
7
+ exports.returnMarkdown = (0, pieces_framework_1.createAction)({
8
+ name: 'return_markdown',
9
+ displayName: 'Respond with a Markdown',
10
+ description: 'Display a markdown as a response.',
11
+ props: {
12
+ markdown: pieces_framework_1.Property.LongText({
13
+ displayName: 'Markdown',
14
+ required: true,
15
+ }),
16
+ },
17
+ run({ propsValue, run }) {
18
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
+ const response = {
20
+ status: http_status_codes_1.StatusCodes.OK,
21
+ body: {
22
+ type: 'markdown',
23
+ value: propsValue.markdown,
24
+ },
25
+ headers: {},
26
+ };
27
+ run.stop({
28
+ response: response,
29
+ });
30
+ return response;
31
+ });
32
+ },
33
+ });
34
+ //# sourceMappingURL=return-markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"return-markdown.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/forms/src/lib/actions/return-markdown.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,yDAAgD;AAEnC,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,yBAAyB;IACtC,WAAW,EAAE,mCAAmC;IAChD,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC1B,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IAEK,GAAG,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE;;YAE3B,MAAM,QAAQ,GAAG;gBACf,MAAM,EAAE,+BAAW,CAAC,EAAE;gBACtB,IAAI,EAAE;oBACJ,IAAI,EAAE,UAAU;oBAChB,KAAK,EAAE,UAAU,CAAC,QAAQ;iBAC3B;gBACD,OAAO,EAAE,EAAE;aACZ,CAAC;YAEF,GAAG,CAAC,IAAI,CAAC;gBACP,QAAQ,EAAE,QAAQ;aACnB,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const onFileSubmission: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").PieceAuthProperty, {
3
+ about: import("../../../../../../../dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
4
+ waitForResponse: import("@activepieces/pieces-framework").CheckboxProperty<true>;
5
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").PieceAuthProperty, {
6
+ about: import("../../../../../../../dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
7
+ waitForResponse: import("@activepieces/pieces-framework").CheckboxProperty<true>;
8
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").PieceAuthProperty, {
9
+ about: import("../../../../../../../dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
10
+ waitForResponse: import("@activepieces/pieces-framework").CheckboxProperty<true>;
11
+ }>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onFileSubmission = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const markdown = `
7
+ The form title is same as the flow's title. \n
8
+ Form URL: \n
9
+ **{{formUrl}}**
10
+ `;
11
+ exports.onFileSubmission = (0, pieces_framework_1.createTrigger)({
12
+ name: 'file_submission',
13
+ displayName: 'Simple File Submission',
14
+ description: 'Trigger the flow by submitting a file.',
15
+ props: {
16
+ about: pieces_framework_1.Property.MarkDown({
17
+ value: markdown,
18
+ }),
19
+ waitForResponse: pieces_framework_1.Property.Checkbox({
20
+ displayName: 'Wait for Response',
21
+ description: 'If enabled, the form will return the flow output to the frontend. Make sure to use the Return Response action to return a response.',
22
+ defaultValue: true,
23
+ required: true,
24
+ }),
25
+ },
26
+ sampleData: {},
27
+ type: pieces_framework_1.TriggerStrategy.WEBHOOK,
28
+ onEnable() {
29
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
30
+ return;
31
+ });
32
+ },
33
+ onDisable() {
34
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
35
+ return;
36
+ });
37
+ },
38
+ run(context) {
39
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
40
+ return [context.payload.body];
41
+ });
42
+ },
43
+ });
44
+ //# sourceMappingURL=file-trigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-trigger.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/forms/src/lib/triggers/file-trigger.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AAExC,MAAM,QAAQ,GAAG;;;;CAIhB,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAA,gCAAa,EAAC;IAC5C,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,wBAAwB;IACrC,WAAW,EAAE,wCAAwC;IACrD,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACvB,KAAK,EAAE,QAAQ;SAChB,CAAC;QACF,eAAe,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACjC,WAAW,EAAE,mBAAmB;YAChC,WAAW,EACT,qIAAqI;YACvI,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,kCAAe,CAAC,OAAO;IACvB,QAAQ;;YACZ,OAAO;QACT,CAAC;KAAA;IACK,SAAS;;YACb,OAAO;QACT,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACf,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const onFormSubmission: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").PieceAuthProperty, {
3
+ about: import("../../../../../../../dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
4
+ inputs: import("@activepieces/pieces-framework").ArrayProperty<true> | import("@activepieces/pieces-framework").ArrayProperty<false>;
5
+ waitForResponse: import("@activepieces/pieces-framework").CheckboxProperty<true>;
6
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").PieceAuthProperty, {
7
+ about: import("../../../../../../../dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
8
+ inputs: import("@activepieces/pieces-framework").ArrayProperty<true> | import("@activepieces/pieces-framework").ArrayProperty<false>;
9
+ waitForResponse: import("@activepieces/pieces-framework").CheckboxProperty<true>;
10
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").PieceAuthProperty, {
11
+ about: import("../../../../../../../dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
12
+ inputs: import("@activepieces/pieces-framework").ArrayProperty<true> | import("@activepieces/pieces-framework").ArrayProperty<false>;
13
+ waitForResponse: import("@activepieces/pieces-framework").CheckboxProperty<true>;
14
+ }>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onFormSubmission = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const markdown = `
7
+ The form title is same as the flow's title. \n
8
+ Form URL: \n
9
+ **{{formUrl}}**
10
+ `;
11
+ exports.onFormSubmission = (0, pieces_framework_1.createTrigger)({
12
+ name: 'form_submission',
13
+ displayName: 'On Form Submission',
14
+ description: 'Trigger the flow by submitting a form.',
15
+ props: {
16
+ about: pieces_framework_1.Property.MarkDown({
17
+ value: markdown,
18
+ }),
19
+ inputs: pieces_framework_1.Property.Array({
20
+ displayName: 'Inputs',
21
+ required: true,
22
+ properties: {
23
+ displayName: pieces_framework_1.Property.ShortText({
24
+ displayName: 'Field Name',
25
+ required: true,
26
+ }),
27
+ type: pieces_framework_1.Property.StaticDropdown({
28
+ displayName: 'Field Type',
29
+ required: true,
30
+ options: {
31
+ options: [
32
+ { value: 'text', label: 'Text' },
33
+ { value: 'text_area', label: 'Text Area' },
34
+ { value: 'file', label: 'File' },
35
+ { value: 'toggle', label: 'Toggle' },
36
+ ],
37
+ },
38
+ }),
39
+ description: pieces_framework_1.Property.ShortText({
40
+ displayName: 'Field Description',
41
+ required: false,
42
+ }),
43
+ required: pieces_framework_1.Property.Checkbox({
44
+ displayName: 'Required',
45
+ required: true,
46
+ }),
47
+ },
48
+ }),
49
+ waitForResponse: pieces_framework_1.Property.Checkbox({
50
+ displayName: 'Wait for Response',
51
+ description: 'If enabled, the form will return the flow output to the frontend. Make sure to use the Return Response action to return a response.',
52
+ defaultValue: true,
53
+ required: true,
54
+ }),
55
+ },
56
+ sampleData: {},
57
+ type: pieces_framework_1.TriggerStrategy.WEBHOOK,
58
+ onEnable() {
59
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
60
+ return;
61
+ });
62
+ },
63
+ onDisable() {
64
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
65
+ return;
66
+ });
67
+ },
68
+ run(context) {
69
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
70
+ return [context.payload.body];
71
+ });
72
+ },
73
+ });
74
+ //# sourceMappingURL=form-trigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-trigger.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/forms/src/lib/triggers/form-trigger.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AAExC,MAAM,QAAQ,GAAG;;;;CAIhB,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAA,gCAAa,EAAC;IAC5C,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,wCAAwC;IACrD,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACvB,KAAK,EAAE,QAAQ;SAChB,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACrB,WAAW,EAAE,QAAQ;YACrB,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE;gBACV,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;oBAC9B,WAAW,EAAE,YAAY;oBACzB,QAAQ,EAAE,IAAI;iBACf,CAAC;gBACF,IAAI,EAAE,2BAAQ,CAAC,cAAc,CAAC;oBAC5B,WAAW,EAAE,YAAY;oBACzB,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE;wBACP,OAAO,EAAE;4BACP,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;4BAChC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;4BAC1C,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;4BAChC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;yBACrC;qBACF;iBACF,CAAC;gBACF,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;oBAC9B,WAAW,EAAE,mBAAmB;oBAChC,QAAQ,EAAE,KAAK;iBAChB,CAAC;gBACF,QAAQ,EAAE,2BAAQ,CAAC,QAAQ,CAAC;oBAC1B,WAAW,EAAE,UAAU;oBACvB,QAAQ,EAAE,IAAI;iBACf,CAAC;aACH;SACF,CAAC;QACF,eAAe,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACjC,WAAW,EAAE,mBAAmB;YAChC,WAAW,EACT,qIAAqI;YACvI,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,kCAAe,CAAC,OAAO;IACvB,QAAQ;;YACZ,OAAO;QACT,CAAC;KAAA;IACK,SAAS;;YACb,OAAO;QACT,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACf,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;KAAA;CACF,CAAC,CAAC"}