@activepieces/piece-doctly 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-doctly
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-doctly` to build the library.
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@activepieces/piece-doctly",
3
+ "version": "0.0.1",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "@sinclair/typebox": "0.34.11",
9
+ "axios": "1.8.3",
10
+ "axios-retry": "4.4.1",
11
+ "deepmerge-ts": "7.1.0",
12
+ "form-data": "4.0.4",
13
+ "mime-types": "2.1.35",
14
+ "nanoid": "3.3.8",
15
+ "semver": "7.6.0",
16
+ "socket.io-client": "4.8.1",
17
+ "tslib": "^2.3.0",
18
+ "zod": "3.25.76",
19
+ "@activepieces/pieces-common": "0.8.1",
20
+ "@activepieces/pieces-framework": "0.20.2",
21
+ "@activepieces/shared": "0.26.0"
22
+ },
23
+ "resolutions": {
24
+ "rollup": "npm:@rollup/wasm-node"
25
+ }
26
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const doctly: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
package/src/index.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.doctly = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("./lib/common/auth");
7
+ const shared_1 = require("@activepieces/shared");
8
+ const convert_pdf_to_text_1 = require("./lib/actions/convert-pdf-to-text");
9
+ const pieces_common_1 = require("@activepieces/pieces-common");
10
+ const constants_1 = require("./lib/common/constants");
11
+ exports.doctly = (0, pieces_framework_1.createPiece)({
12
+ displayName: 'Doctly AI',
13
+ auth: auth_1.doctlyAuth,
14
+ minimumSupportedRelease: '0.36.1',
15
+ logoUrl: 'https://cdn.activepieces.com/pieces/doctly.png',
16
+ categories: [shared_1.PieceCategory.ARTIFICIAL_INTELLIGENCE],
17
+ authors: ['kishanprmr'],
18
+ actions: [
19
+ convert_pdf_to_text_1.convertPdfToTextAction,
20
+ (0, pieces_common_1.createCustomApiCallAction)({
21
+ auth: auth_1.doctlyAuth,
22
+ baseUrl: () => constants_1.BASE_URL,
23
+ authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
24
+ return {
25
+ Authorization: `Bearer ${auth}`,
26
+ };
27
+ }),
28
+ }),
29
+ ],
30
+ triggers: [],
31
+ });
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/doctly/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAA6D;AAC7D,4CAA+C;AAC/C,iDAAqD;AACrD,2EAA2E;AAC3E,+DAAwE;AACxE,sDAAkD;AAErC,QAAA,MAAM,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,WAAW;IACxB,IAAI,EAAE,iBAAU;IAChB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,gDAAgD;IACzD,UAAU,EAAE,CAAC,sBAAa,CAAC,uBAAuB,CAAC;IACnD,OAAO,EAAE,CAAC,YAAY,CAAC;IACvB,OAAO,EAAE;QACR,4CAAsB;QACtB,IAAA,yCAAyB,EAAC;YACzB,IAAI,EAAE,iBAAU;YAChB,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAQ;YACvB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC3B,OAAO;oBACN,aAAa,EAAE,UAAU,IAAI,EAAE;iBAC/B,CAAC;YACH,CAAC,CAAA;SACD,CAAC;KACF;IACD,QAAQ,EAAE,EAAE;CACZ,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const convertPdfToTextAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ file: import("@activepieces/pieces-framework").FileProperty<true>;
3
+ }>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertPdfToTextAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const form_data_1 = tslib_1.__importDefault(require("form-data"));
8
+ const pieces_common_1 = require("@activepieces/pieces-common");
9
+ const constants_1 = require("../common/constants");
10
+ exports.convertPdfToTextAction = (0, pieces_framework_1.createAction)({
11
+ name: 'convert-pdf-to-text',
12
+ auth: auth_1.doctlyAuth,
13
+ displayName: 'Convert PDF to Text',
14
+ description: 'Converts PDF document to text file with markdown formatting.',
15
+ props: {
16
+ file: pieces_framework_1.Property.File({
17
+ displayName: 'Document File',
18
+ required: true,
19
+ }),
20
+ },
21
+ run(context) {
22
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ const { file } = context.propsValue;
24
+ const formData = new form_data_1.default();
25
+ formData.append('file', file.data, { filename: file.filename });
26
+ const response = yield pieces_common_1.httpClient.sendRequest({
27
+ method: pieces_common_1.HttpMethod.POST,
28
+ url: constants_1.BASE_URL + '/documents/',
29
+ authentication: {
30
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
31
+ token: context.auth,
32
+ },
33
+ headers: Object.assign({}, formData.getHeaders()),
34
+ body: formData,
35
+ });
36
+ const docId = response.body.id;
37
+ let status = response.body.status;
38
+ const timeoutAt = Date.now() + 5 * 60 * 1000;
39
+ while (!['COMPLETED', 'FAILED'].includes(status) && Date.now() < timeoutAt) {
40
+ yield new Promise((resolve) => setTimeout(resolve, 5000));
41
+ const pollResponse = yield pieces_common_1.httpClient.sendRequest({
42
+ method: pieces_common_1.HttpMethod.GET,
43
+ url: constants_1.BASE_URL + `/documents/${docId}`,
44
+ authentication: {
45
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
46
+ token: context.auth,
47
+ },
48
+ });
49
+ status = pollResponse.body.status;
50
+ if (status === 'COMPLETED') {
51
+ const mdResponse = yield pieces_common_1.httpClient.sendRequest({
52
+ method: pieces_common_1.HttpMethod.GET,
53
+ url: pollResponse.body.output_file_url,
54
+ });
55
+ const markdownText = mdResponse.body;
56
+ return Object.assign({ markdownText }, pollResponse.body);
57
+ }
58
+ if (status === 'FAILED')
59
+ throw new Error('Document processing failed.');
60
+ }
61
+ throw new Error('Document Parse timed out or failed.');
62
+ });
63
+ },
64
+ });
65
+ //# sourceMappingURL=convert-pdf-to-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-pdf-to-text.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/doctly/src/lib/actions/convert-pdf-to-text.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,yCAA4C;AAC5C,kEAAiC;AACjC,+DAAyF;AACzF,mDAA+C;AAGlC,QAAA,sBAAsB,GAAG,IAAA,+BAAY,EAAC;IAClD,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,iBAAU;IAChB,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,8DAA8D;IAC3E,KAAK,EAAE;QACN,IAAI,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACnB,WAAW,EAAE,eAAe;YAC5B,QAAQ,EAAE,IAAI;SACd,CAAC;KACF;IACK,GAAG,CAAC,OAAO;;YAChB,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAEpC,MAAM,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;YAChC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;Y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EAAE,0BAAU,CAAC,GAAG;wBACtB,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,eAAe;qBACtC,CAAC,CAAC;oBAEH,MAAM,YAAY,GAAG,UAAU,CAAC,IAAyB,CAAC;oBAE1D,uBAAS,YAAY,IAAK,YAAY,CAAC,IAAI,EAAG;gBAC/C,CAAC;gBACD,IAAI,MAAM,KAAK,QAAQ;oBAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;YACzE,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACxD,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const doctlyAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.doctlyAuth = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ exports.doctlyAuth = pieces_framework_1.PieceAuth.SecretText({
6
+ displayName: 'API Key',
7
+ required: true,
8
+ description: `You can obtain API key from [API Settings](https://doctly.ai/keys).`
9
+ });
10
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/doctly/src/lib/common/auth.ts"],"names":[],"mappings":";;;AAAA,qEAA2D;AAE9C,QAAA,UAAU,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC3C,WAAW,EAAC,SAAS;IACrB,QAAQ,EAAC,IAAI;IACb,WAAW,EAAC,qEAAqE;CACpF,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const BASE_URL = "https://api.doctly.ai/api/v1";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BASE_URL = void 0;
4
+ exports.BASE_URL = 'https://api.doctly.ai/api/v1';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/doctly/src/lib/common/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,8BAA8B,CAAA"}
@@ -0,0 +1,11 @@
1
+ export type CreateDocumentResponse = {
2
+ id: string;
3
+ file_name: string;
4
+ status: string;
5
+ };
6
+ export type GetDocumentResponse = {
7
+ id: string;
8
+ file_name: string;
9
+ status: string;
10
+ output_file_url: string;
11
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/doctly/src/lib/common/types.ts"],"names":[],"mappings":""}