@taskmagic/apps-pdf-co 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.
Files changed (41) hide show
  1. package/README.md +7 -0
  2. package/package.json +47 -0
  3. package/src/index.d.ts +1 -0
  4. package/src/index.js +28 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/actions/add-barcode-to-pdf.d.ts +15 -0
  7. package/src/lib/actions/add-barcode-to-pdf.js +148 -0
  8. package/src/lib/actions/add-barcode-to-pdf.js.map +1 -0
  9. package/src/lib/actions/add-image-to-pdf.d.ts +14 -0
  10. package/src/lib/actions/add-image-to-pdf.js +114 -0
  11. package/src/lib/actions/add-image-to-pdf.js.map +1 -0
  12. package/src/lib/actions/add-text-to-pdf.d.ts +21 -0
  13. package/src/lib/actions/add-text-to-pdf.js +149 -0
  14. package/src/lib/actions/add-text-to-pdf.js.map +1 -0
  15. package/src/lib/actions/convert-html-to-pdf.d.ts +14 -0
  16. package/src/lib/actions/convert-html-to-pdf.js +190 -0
  17. package/src/lib/actions/convert-html-to-pdf.js.map +1 -0
  18. package/src/lib/actions/convert-pdf-to-structured-format.d.ts +12 -0
  19. package/src/lib/actions/convert-pdf-to-structured-format.js +123 -0
  20. package/src/lib/actions/convert-pdf-to-structured-format.js.map +1 -0
  21. package/src/lib/actions/extract-tables-from-pdf.d.ts +11 -0
  22. package/src/lib/actions/extract-tables-from-pdf.js +103 -0
  23. package/src/lib/actions/extract-tables-from-pdf.js.map +1 -0
  24. package/src/lib/actions/extract-text-from-pdf.d.ts +8 -0
  25. package/src/lib/actions/extract-text-from-pdf.js +96 -0
  26. package/src/lib/actions/extract-text-from-pdf.js.map +1 -0
  27. package/src/lib/actions/index.d.ts +8 -0
  28. package/src/lib/actions/index.js +12 -0
  29. package/src/lib/actions/index.js.map +1 -0
  30. package/src/lib/actions/search-and-replace-text.d.ts +13 -0
  31. package/src/lib/actions/search-and-replace-text.js +99 -0
  32. package/src/lib/actions/search-and-replace-text.js.map +1 -0
  33. package/src/lib/auth.d.ts +1 -0
  34. package/src/lib/auth.js +10 -0
  35. package/src/lib/auth.js.map +1 -0
  36. package/src/lib/common/props.d.ts +8 -0
  37. package/src/lib/common/props.js +33 -0
  38. package/src/lib/common/props.js.map +1 -0
  39. package/src/lib/common/types.d.ts +37 -0
  40. package/src/lib/common/types.js +3 -0
  41. package/src/lib/common/types.js.map +1 -0
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchAndReplaceText = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@taskmagic/pieces-framework");
6
+ const pieces_common_1 = require("@taskmagic/pieces-common");
7
+ const auth_1 = require("../auth");
8
+ const props_1 = require("../common/props");
9
+ exports.searchAndReplaceText = (0, pieces_framework_1.createAction)({
10
+ name: 'search_and_replace_text',
11
+ displayName: 'Search and Replace Text in PDF',
12
+ description: 'Search for specific text or patterns in a PDF and replace it with new text.',
13
+ auth: auth_1.pdfCoAuth,
14
+ props: Object.assign({ url: pieces_framework_1.Property.ShortText({
15
+ displayName: 'PDF URL',
16
+ description: 'URL to the source PDF file.',
17
+ required: true,
18
+ }), searchStrings: pieces_framework_1.Property.Array({
19
+ displayName: 'Text to Locate',
20
+ required: true,
21
+ }), replaceStrings: pieces_framework_1.Property.Array({
22
+ displayName: 'Replacement Text',
23
+ required: true,
24
+ }), caseSensitive: pieces_framework_1.Property.Checkbox({
25
+ displayName: 'Case Sensitive',
26
+ description: 'Set to true for case-sensitive search, false otherwise.',
27
+ required: false,
28
+ defaultValue: true,
29
+ }), regex: pieces_framework_1.Property.Checkbox({
30
+ displayName: 'Use Regular Expressions ?',
31
+ description: 'Set to true to use regular expressions for search texts.',
32
+ required: false,
33
+ defaultValue: false,
34
+ }), pages: pieces_framework_1.Property.ShortText({
35
+ displayName: 'Pages',
36
+ description: 'Comma-separated page numbers or ranges (e.g., "0,2,5-10"). Leave empty for all pages.',
37
+ required: false,
38
+ }) }, props_1.commonProps),
39
+ run(context) {
40
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
41
+ var _a;
42
+ const { auth, propsValue } = context;
43
+ const { url, searchStrings, replaceStrings, caseSensitive, regex, pages, fileName, httpPassword, httpUsername, pdfPassword, expiration, } = propsValue;
44
+ const requestBody = {
45
+ url: url,
46
+ searchStrings: searchStrings,
47
+ replaceStrings: replaceStrings,
48
+ async: false,
49
+ caseSensitive: caseSensitive,
50
+ regex,
51
+ pages,
52
+ name: fileName,
53
+ expiration,
54
+ httppassword: httpPassword,
55
+ httpusername: httpUsername,
56
+ password: pdfPassword,
57
+ };
58
+ try {
59
+ const response = yield pieces_common_1.httpClient.sendRequest({
60
+ method: pieces_common_1.HttpMethod.POST,
61
+ url: `${props_1.BASE_URL}/pdf/edit/replace-text`,
62
+ headers: {
63
+ 'x-api-key': auth,
64
+ 'Content-Type': 'application/json',
65
+ },
66
+ body: requestBody,
67
+ });
68
+ if (response.body.error) {
69
+ const errorBody = response.body;
70
+ let errorMessage = `PDF.co API Error: Status ${errorBody.status}.`;
71
+ if (errorBody.message) {
72
+ errorMessage += ` Message: ${errorBody.message}.`;
73
+ }
74
+ else {
75
+ errorMessage += ` An unspecified error occurred.`;
76
+ }
77
+ errorMessage += ` Check input parameters, API key, and PDF.co dashboard for more details. Raw response: ${JSON.stringify(errorBody)}`;
78
+ throw new Error(errorMessage);
79
+ }
80
+ return response.body;
81
+ }
82
+ catch (error) {
83
+ if (error instanceof pieces_common_1.HttpError) {
84
+ const responseBody = (_a = error.response) === null || _a === void 0 ? void 0 : _a.body;
85
+ let detailedMessage = `HTTP Error calling PDF.co API: ${error.message}.`;
86
+ if (responseBody && responseBody.message) {
87
+ detailedMessage += ` Server message: ${responseBody.message}.`;
88
+ }
89
+ else if (responseBody) {
90
+ detailedMessage += ` Server response: ${JSON.stringify(responseBody)}.`;
91
+ }
92
+ throw new Error(detailedMessage);
93
+ }
94
+ throw error;
95
+ }
96
+ });
97
+ },
98
+ });
99
+ //# sourceMappingURL=search-and-replace-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-and-replace-text.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf-co/src/lib/actions/search-and-replace-text.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,4DAA6E;AAE7E,kCAAoC;AACpC,2CAAwD;AAiB3C,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE,gCAAgC;IAC7C,WAAW,EAAE,6EAA6E;IAC1F,IAAI,EAAE,gBAAS;IACf,KAAK,kBACJ,GAAG,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,6BAA6B;YAC1C,QAAQ,EAAE,IAAI;SACd,CAAC,EACF,aAAa,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAC7B,WAAW,EAAE,gBAAgB;YAC7B,QAAQ,EAAE,IAAI;SACd,CAAC,EACF,cAAc,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAC9B,WAAW,EAAE,kBAAkB;YAC/B,QAAQ,EAAE,IAAI;SACd,CAAC,EACF,aAAa,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAChC,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,yDAAyD;YACtE,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,IAAI;SAClB,CAAC,EACF,KAAK,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACxB,WAAW,EAAE,2BAA2B;YACxC,WAAW,EAAE,0DAA0D;YACvE,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;SACnB,CAAC,EACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,OAAO;YACpB,WAAW,EACV,uFAAuF;YACxF,QAAQ,EAAE,KAAK;SACf,CAAC,IACC,mBAAW,CACd;IACK,GAAG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CAAC;oBACJ,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;gBAC/B,CAAC;gBAED,OAAO,QAAQ,CAAC,IAAI,CAAC;YACtB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,KAAK,YAAY,yBAAS,EAAE,CAAC;oBAChC,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAsC,CAAC;oBAC5E,IAAI,eAAe,GAAG,kCAAkC,KAAK,CAAC,OAAO,GAAG,CAAC;oBACzE,IAAI,YAAY,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;wBAC1C,eAAe,IAAI,oBAAoB,YAAY,CAAC,OAAO,GAAG,CAAC;oBAChE,CAAC;yBAAM,IAAI,YAAY,EAAE,CAAC;wBACzB,eAAe,IAAI,qBAAqB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC;oBACzE,CAAC;oBACD,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;gBAClC,CAAC;gBACD,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const pdfCoAuth: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pdfCoAuth = void 0;
4
+ const pieces_framework_1 = require("@taskmagic/pieces-framework");
5
+ exports.pdfCoAuth = pieces_framework_1.PieceAuth.SecretText({
6
+ displayName: 'API Key',
7
+ description: `To get your PDF.co API key please [click here to create your account](https://app.pdf.co/).`,
8
+ required: true,
9
+ });
10
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/community/pdf-co/src/lib/auth.ts"],"names":[],"mappings":";;;AAAA,kEAAwD;AAE3C,QAAA,SAAS,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC7C,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,6FAA6F;IAC1G,QAAQ,EAAE,IAAI;CACd,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const BASE_URL = "https://api.pdf.co/v1";
2
+ export declare const commonProps: {
3
+ fileName: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
4
+ expiration: import("@taskmagic/pieces-framework").NumberProperty<false>;
5
+ pdfPassword: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
6
+ httpUsername: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
7
+ httpPassword: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
8
+ };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commonProps = exports.BASE_URL = void 0;
4
+ const pieces_framework_1 = require("@taskmagic/pieces-framework");
5
+ exports.BASE_URL = 'https://api.pdf.co/v1';
6
+ exports.commonProps = {
7
+ fileName: pieces_framework_1.Property.ShortText({
8
+ displayName: 'File Name',
9
+ description: 'Desired name for the output PDF file (e.g., "result.pdf").',
10
+ required: false,
11
+ }),
12
+ expiration: pieces_framework_1.Property.Number({
13
+ displayName: 'Expiration Time in Minutes',
14
+ description: 'Set the expiration time for the output link in minutes (default is 60 i.e 60 minutes or 1 hour).',
15
+ required: false,
16
+ }),
17
+ pdfPassword: pieces_framework_1.Property.ShortText({
18
+ displayName: 'Source PDF Password',
19
+ description: 'Password if the source PDF is protected.',
20
+ required: false,
21
+ }),
22
+ httpUsername: pieces_framework_1.Property.ShortText({
23
+ displayName: 'HTTP Username',
24
+ description: 'HTTP auth username if required to access source url.',
25
+ required: false,
26
+ }),
27
+ httpPassword: pieces_framework_1.Property.ShortText({
28
+ displayName: 'HTTP Password',
29
+ description: 'HTTP auth password if required to access source url.',
30
+ required: false,
31
+ }),
32
+ };
33
+ //# sourceMappingURL=props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf-co/src/lib/common/props.ts"],"names":[],"mappings":";;;AAAA,kEAAuD;AAE1C,QAAA,QAAQ,GAAG,uBAAuB,CAAC;AAEnC,QAAA,WAAW,GAAG;IAC1B,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;QAC5B,WAAW,EAAE,WAAW;QACxB,WAAW,EAAE,4DAA4D;QACzE,QAAQ,EAAE,KAAK;KACf,CAAC;IACF,UAAU,EAAE,2BAAQ,CAAC,MAAM,CAAC;QAC3B,WAAW,EAAE,4BAA4B;QACzC,WAAW,EACV,kGAAkG;QACnG,QAAQ,EAAE,KAAK;KACf,CAAC;IACF,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;QAC/B,WAAW,EAAE,qBAAqB;QAClC,WAAW,EAAE,0CAA0C;QACvD,QAAQ,EAAE,KAAK;KACf,CAAC;IACF,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;QAChC,WAAW,EAAE,eAAe;QAC5B,WAAW,EAAE,sDAAsD;QACnE,QAAQ,EAAE,KAAK;KACf,CAAC;IACF,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;QAChC,WAAW,EAAE,eAAe;QAC5B,WAAW,EAAE,sDAAsD;QACnE,QAAQ,EAAE,KAAK;KACf,CAAC;CACF,CAAC"}
@@ -0,0 +1,37 @@
1
+ export interface PdfCoSuccessResponse {
2
+ url: string;
3
+ pageCount: number;
4
+ error: false;
5
+ status: number;
6
+ name: string;
7
+ remainingCredits: number;
8
+ credits: number;
9
+ }
10
+ export interface PdfCoErrorResponse {
11
+ error: true;
12
+ status: number;
13
+ message?: string;
14
+ [key: string]: unknown;
15
+ }
16
+ export interface PdfCoImageAnnotation {
17
+ url: string;
18
+ x: number;
19
+ y: number;
20
+ pages?: string;
21
+ width?: number;
22
+ height?: number;
23
+ link?: string;
24
+ keepAspectRatio?: boolean;
25
+ }
26
+ export interface PdfCoAddImagesRequestBody {
27
+ url: string;
28
+ images: PdfCoImageAnnotation[];
29
+ async: boolean;
30
+ inline: boolean;
31
+ name?: string;
32
+ password?: string;
33
+ expiration?: number;
34
+ profiles?: Record<string, unknown>;
35
+ httpusername?: string;
36
+ httppassword?: string;
37
+ }
@@ -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/pdf-co/src/lib/common/types.ts"],"names":[],"mappings":""}