@taskmagic/apps-polydoc 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 +3 -0
- package/package.json +47 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +55 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/capture-screenshot.d.ts +23 -0
- package/src/lib/actions/capture-screenshot.js +108 -0
- package/src/lib/actions/capture-screenshot.js.map +1 -0
- package/src/lib/actions/convert-pdf.d.ts +27 -0
- package/src/lib/actions/convert-pdf.js +107 -0
- package/src/lib/actions/convert-pdf.js.map +1 -0
- package/src/lib/actions/generate-einvoice.d.ts +20 -0
- package/src/lib/actions/generate-einvoice.js +107 -0
- package/src/lib/actions/generate-einvoice.js.map +1 -0
- package/src/lib/common/auth.d.ts +4 -0
- package/src/lib/common/auth.js +62 -0
- package/src/lib/common/auth.js.map +1 -0
- package/src/lib/common/build-request-body.d.ts +10 -0
- package/src/lib/common/build-request-body.js +172 -0
- package/src/lib/common/build-request-body.js.map +1 -0
- package/src/lib/common/client.d.ts +23 -0
- package/src/lib/common/client.js +68 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/constants.d.ts +40 -0
- package/src/lib/common/constants.js +28 -0
- package/src/lib/common/constants.js.map +1 -0
- package/src/lib/common/output.d.ts +23 -0
- package/src/lib/common/output.js +53 -0
- package/src/lib/common/output.js.map +1 -0
- package/src/lib/common/props.d.ts +19 -0
- package/src/lib/common/props.js +144 -0
- package/src/lib/common/props.js.map +1 -0
- package/src/lib/common/types.d.ts +36 -0
- package/src/lib/common/types.js +3 -0
- package/src/lib/common/types.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taskmagic/apps-polydoc",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@anthropic-ai/sdk": "0.33.1",
|
|
6
|
+
"@sinclair/typebox": "0.34.11",
|
|
7
|
+
"axios": "1.17.0",
|
|
8
|
+
"axios-retry": "4.4.1",
|
|
9
|
+
"deepmerge-ts": "7.1.0",
|
|
10
|
+
"mime-types": "2.1.35",
|
|
11
|
+
"nanoid": "3.3.8",
|
|
12
|
+
"openai": "4.67.1",
|
|
13
|
+
"replicate": "0.34.1",
|
|
14
|
+
"semver": "7.6.0",
|
|
15
|
+
"zod": "3.25.76",
|
|
16
|
+
"@taskmagic/pieces-common": "0.4.4",
|
|
17
|
+
"@taskmagic/pieces-framework": "0.7.46",
|
|
18
|
+
"@taskmagic/shared": "0.10.171",
|
|
19
|
+
"tslib": "1.14.1"
|
|
20
|
+
},
|
|
21
|
+
"overrides": {
|
|
22
|
+
"cross-spawn": "7.0.6",
|
|
23
|
+
"elliptic": "^6.6.1",
|
|
24
|
+
"fast-xml-parser": "^4.4.1",
|
|
25
|
+
"protobufjs": "^7.5.5",
|
|
26
|
+
"tmp": "^0.2.4",
|
|
27
|
+
"koa": "^2.16.4",
|
|
28
|
+
"picomatch": "^4.0.4",
|
|
29
|
+
"langsmith": "^0.6.0",
|
|
30
|
+
"serialize-javascript": "^6.0.2",
|
|
31
|
+
"elevenlabs": {
|
|
32
|
+
"form-data": "^4.0.4"
|
|
33
|
+
},
|
|
34
|
+
"@tryfabric/martian": {
|
|
35
|
+
"@notionhq/client": "$@notionhq/client"
|
|
36
|
+
},
|
|
37
|
+
"vite": {
|
|
38
|
+
"rollup": "npm:@rollup/wasm-node@^4.61.1"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"resolutions": {
|
|
42
|
+
"rollup": "npm:@rollup/wasm-node@^4.61.1"
|
|
43
|
+
},
|
|
44
|
+
"types": "./src/index.d.ts",
|
|
45
|
+
"main": "./src/index.js",
|
|
46
|
+
"type": "commonjs"
|
|
47
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const polydoc: import("@taskmagic/pieces-framework").Piece<import("@taskmagic/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
apiKey: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
sandbox: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
4
|
+
}>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.polydoc = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
7
|
+
const shared_1 = require("@taskmagic/shared");
|
|
8
|
+
const capture_screenshot_1 = require("./lib/actions/capture-screenshot");
|
|
9
|
+
const convert_pdf_1 = require("./lib/actions/convert-pdf");
|
|
10
|
+
const generate_einvoice_1 = require("./lib/actions/generate-einvoice");
|
|
11
|
+
const auth_1 = require("./lib/common/auth");
|
|
12
|
+
const constants_1 = require("./lib/common/constants");
|
|
13
|
+
exports.polydoc = (0, pieces_framework_1.createPiece)({
|
|
14
|
+
displayName: 'PolyDoc',
|
|
15
|
+
description: 'Convert HTML or a URL to PDF, capture screenshots, and generate EU e-invoices (Factur-X / ZUGFeRD).',
|
|
16
|
+
auth: auth_1.polydocAuth,
|
|
17
|
+
minimumSupportedRelease: '0.30.0',
|
|
18
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/polydoc.png',
|
|
19
|
+
categories: [shared_1.PieceCategory.CONTENT_AND_FILES, shared_1.PieceCategory.PRODUCTIVITY],
|
|
20
|
+
authors: ['polydoc-tech', 'sanket-a11y'],
|
|
21
|
+
ai: {
|
|
22
|
+
description: 'Generate documents with PolyDoc: convert a URL, HTML, or a saved template to PDF, capture web page screenshots, and produce hybrid EU e-invoices (Factur-X / ZUGFeRD, EN 16931).',
|
|
23
|
+
keywords: [
|
|
24
|
+
'pdf',
|
|
25
|
+
'html to pdf',
|
|
26
|
+
'url to pdf',
|
|
27
|
+
'screenshot',
|
|
28
|
+
'web page capture',
|
|
29
|
+
'e-invoice',
|
|
30
|
+
'einvoice',
|
|
31
|
+
'factur-x',
|
|
32
|
+
'zugferd',
|
|
33
|
+
'document generation',
|
|
34
|
+
'render template',
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
actions: [
|
|
38
|
+
convert_pdf_1.convertToPdf,
|
|
39
|
+
capture_screenshot_1.captureScreenshot,
|
|
40
|
+
generate_einvoice_1.generateEinvoice,
|
|
41
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
42
|
+
baseUrl: () => constants_1.DEFAULT_BASE_URL,
|
|
43
|
+
auth: auth_1.polydocAuth,
|
|
44
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
const value = auth;
|
|
46
|
+
return {
|
|
47
|
+
Authorization: `Bearer ${value.apiKey}`,
|
|
48
|
+
'X-Sandbox': value.sandbox ? 'true' : 'false',
|
|
49
|
+
};
|
|
50
|
+
}),
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
triggers: [],
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/polydoc/src/index.ts"],"names":[],"mappings":";;;;AAAA,4DAAqE;AACrE,kEAA0D;AAC1D,8CAAkD;AAClD,yEAAqE;AACrE,2DAAyD;AACzD,uEAAmE;AACnE,4CAAgD;AAChD,sDAA0D;AAE7C,QAAA,OAAO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,SAAS;IACtB,WAAW,EACT,qGAAqG;IACvG,IAAI,EAAE,kBAAW;IACjB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,iDAAiD;IAC1D,UAAU,EAAE,CAAC,sBAAa,CAAC,iBAAiB,EAAE,sBAAa,CAAC,YAAY,CAAC;IACzE,OAAO,EAAE,CAAC,cAAc,EAAE,aAAa,CAAC;IACxC,EAAE,EAAE;QACF,WAAW,EACT,kLAAkL;QACpL,QAAQ,EAAE;YACR,KAAK;YACL,aAAa;YACb,YAAY;YACZ,YAAY;YACZ,kBAAkB;YAClB,WAAW;YACX,UAAU;YACV,UAAU;YACV,SAAS;YACT,qBAAqB;YACrB,iBAAiB;SAClB;KACF;IACD,OAAO,EAAE;QACP,0BAAY;QACZ,sCAAiB;QACjB,oCAAgB;QAChB,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,4BAAgB;YAC/B,IAAI,EAAE,kBAAW;YACjB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,MAAM,KAAK,GAAG,IAA6C,CAAC;gBAC5D,OAAO;oBACL,aAAa,EAAE,UAAU,KAAK,CAAC,MAAM,EAAE;oBACvC,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;iBAC9C,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const captureScreenshot: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
apiKey: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
sandbox: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
4
|
+
}>, {
|
|
5
|
+
sourceType: import("@taskmagic/pieces-framework").StaticDropdownProperty<"url" | "html" | "template", true>;
|
|
6
|
+
source: import("@taskmagic/pieces-framework").LongTextProperty<true>;
|
|
7
|
+
templateData: import("@taskmagic/pieces-framework").JsonProperty<false>;
|
|
8
|
+
imageType: import("@taskmagic/pieces-framework").StaticDropdownProperty<"png" | "jpeg" | "webp", false>;
|
|
9
|
+
fullPage: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
10
|
+
quality: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
11
|
+
viewportWidth: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
12
|
+
viewportHeight: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
13
|
+
devicePixelRatio: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
14
|
+
outputEncoding: import("@taskmagic/pieces-framework").StaticDropdownProperty<"binaryFile" | "base64", false>;
|
|
15
|
+
deliveryMode: import("@taskmagic/pieces-framework").StaticDropdownProperty<"download" | "cloudStorage" | "webhook", true>;
|
|
16
|
+
presignedUrl: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
17
|
+
webhookUrl: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
18
|
+
webhookOptions: import("@taskmagic/pieces-framework").JsonProperty<false>;
|
|
19
|
+
filename: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
20
|
+
tag: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
21
|
+
timeout: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
22
|
+
advanced: import("@taskmagic/pieces-framework").JsonProperty<false>;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.captureScreenshot = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../common/auth");
|
|
7
|
+
const build_request_body_1 = require("../common/build-request-body");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const constants_1 = require("../common/constants");
|
|
10
|
+
const output_1 = require("../common/output");
|
|
11
|
+
const props_1 = require("../common/props");
|
|
12
|
+
exports.captureScreenshot = (0, pieces_framework_1.createAction)({
|
|
13
|
+
auth: auth_1.polydocAuth,
|
|
14
|
+
name: 'capture_screenshot',
|
|
15
|
+
displayName: 'Capture Screenshot',
|
|
16
|
+
description: 'Capture a screenshot of a URL, inline HTML, or a saved template.',
|
|
17
|
+
props: {
|
|
18
|
+
sourceType: (0, props_1.sourceTypeProp)('url'),
|
|
19
|
+
source: props_1.sourceProp,
|
|
20
|
+
templateData: props_1.templateDataProp,
|
|
21
|
+
imageType: pieces_framework_1.Property.StaticDropdown({
|
|
22
|
+
displayName: 'Image Type',
|
|
23
|
+
required: false,
|
|
24
|
+
defaultValue: 'png',
|
|
25
|
+
options: { disabled: false, options: constants_1.IMAGE_TYPES.map((t) => ({ label: t, value: t })) },
|
|
26
|
+
}),
|
|
27
|
+
fullPage: pieces_framework_1.Property.Checkbox({
|
|
28
|
+
displayName: 'Full Page',
|
|
29
|
+
description: 'Capture the entire scrollable page.',
|
|
30
|
+
required: false,
|
|
31
|
+
defaultValue: false,
|
|
32
|
+
}),
|
|
33
|
+
quality: pieces_framework_1.Property.Number({
|
|
34
|
+
displayName: 'Quality',
|
|
35
|
+
description: 'Compression quality for JPEG/WebP (0 to 100).',
|
|
36
|
+
required: false,
|
|
37
|
+
}),
|
|
38
|
+
viewportWidth: pieces_framework_1.Property.Number({
|
|
39
|
+
displayName: 'Viewport Width',
|
|
40
|
+
description: 'Viewport width in CSS pixels.',
|
|
41
|
+
required: false,
|
|
42
|
+
}),
|
|
43
|
+
viewportHeight: pieces_framework_1.Property.Number({
|
|
44
|
+
displayName: 'Viewport Height',
|
|
45
|
+
description: 'Viewport height in CSS pixels.',
|
|
46
|
+
required: false,
|
|
47
|
+
}),
|
|
48
|
+
devicePixelRatio: pieces_framework_1.Property.Number({
|
|
49
|
+
displayName: 'Device Pixel Ratio',
|
|
50
|
+
description: 'Device pixel ratio, e.g. 2 for retina (0 to 10).',
|
|
51
|
+
required: false,
|
|
52
|
+
}),
|
|
53
|
+
outputEncoding: pieces_framework_1.Property.StaticDropdown({
|
|
54
|
+
displayName: 'Output',
|
|
55
|
+
description: 'Return the image as a file (default) or as a base64 string.',
|
|
56
|
+
required: false,
|
|
57
|
+
defaultValue: 'binaryFile',
|
|
58
|
+
options: {
|
|
59
|
+
disabled: false,
|
|
60
|
+
options: constants_1.SCREENSHOT_OUTPUT_ENCODINGS.map((o) => ({ label: o.label, value: o.value })),
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
deliveryMode: props_1.deliveryModeProp,
|
|
64
|
+
presignedUrl: props_1.presignedUrlProp,
|
|
65
|
+
webhookUrl: props_1.webhookUrlProp,
|
|
66
|
+
webhookOptions: props_1.webhookOptionsProp,
|
|
67
|
+
filename: props_1.filenameProp,
|
|
68
|
+
tag: props_1.tagProp,
|
|
69
|
+
timeout: props_1.timeoutProp,
|
|
70
|
+
advanced: props_1.advancedProp,
|
|
71
|
+
},
|
|
72
|
+
run(context) {
|
|
73
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
var _a;
|
|
75
|
+
const props = context.propsValue;
|
|
76
|
+
const base64 = props['outputEncoding'] === 'base64';
|
|
77
|
+
const params = Object.assign(Object.assign(Object.assign({ operation: 'screenshot' }, (0, props_1.resolveSourceParams)(props)), (0, props_1.resolveMetadata)(props)), { delivery: (0, props_1.resolveDelivery)(props), screenshotOptions: {
|
|
78
|
+
imageType: props['imageType'],
|
|
79
|
+
fullPage: props['fullPage'],
|
|
80
|
+
quality: props['quality'],
|
|
81
|
+
encoding: base64 ? 'base64' : undefined,
|
|
82
|
+
viewportWidth: props['viewportWidth'],
|
|
83
|
+
viewportHeight: props['viewportHeight'],
|
|
84
|
+
devicePixelRatio: props['devicePixelRatio'],
|
|
85
|
+
} });
|
|
86
|
+
const request = (0, build_request_body_1.buildRequestBody)(params);
|
|
87
|
+
// base64 encoding makes the API answer with JSON, never raw bytes.
|
|
88
|
+
if (base64) {
|
|
89
|
+
request.isBinary = false;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const response = yield (0, client_1.polyDocRequest)(context.auth, request);
|
|
93
|
+
return yield (0, output_1.shapeOutput)({
|
|
94
|
+
response,
|
|
95
|
+
isBinary: request.isBinary,
|
|
96
|
+
files: context.files,
|
|
97
|
+
operation: 'screenshot',
|
|
98
|
+
filename: params.filename,
|
|
99
|
+
imageType: props['imageType'],
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
throw new Error((_a = (0, client_1.extractApiErrorMessage)(error)) !== null && _a !== void 0 ? _a : error.message);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=capture-screenshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-screenshot.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/polydoc/src/lib/actions/capture-screenshot.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,yCAA6C;AAC7C,qEAAgE;AAChE,6CAAiG;AACjG,mDAA+E;AAC/E,6CAA+C;AAC/C,2CAeyB;AAGZ,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,kEAAkE;IAC/E,KAAK,EAAE;QACL,UAAU,EAAE,IAAA,sBAAc,EAAC,KAAK,CAAC;QACjC,MAAM,EAAE,kBAAU;QAClB,YAAY,EAAE,wBAAgB;QAC9B,SAAS,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACjC,WAAW,EAAE,YAAY;YACzB,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;YACnB,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,uBAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,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;oBACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,SAAS,EAAE,KAAK,CAAC,WAAW,CAAuB;iBACpD,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,MAAA,IAAA,+BAAsB,EAAC,KAAK,CAAC,mCAAK,KAAe,CAAC,OAAO,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const convertToPdf: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
apiKey: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
sandbox: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
4
|
+
}>, {
|
|
5
|
+
sourceType: import("@taskmagic/pieces-framework").StaticDropdownProperty<"url" | "html" | "template", true>;
|
|
6
|
+
source: import("@taskmagic/pieces-framework").LongTextProperty<true>;
|
|
7
|
+
templateData: import("@taskmagic/pieces-framework").JsonProperty<false>;
|
|
8
|
+
format: import("@taskmagic/pieces-framework").StaticDropdownProperty<"A3" | "A4" | "A5" | "Ledger" | "Legal" | "Letter" | "Tabloid", false>;
|
|
9
|
+
landscape: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
10
|
+
printBackground: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
11
|
+
scale: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
12
|
+
pageRanges: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
13
|
+
outline: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
14
|
+
tagged: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
15
|
+
marginTop: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
16
|
+
marginRight: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
17
|
+
marginBottom: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
18
|
+
marginLeft: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
19
|
+
deliveryMode: import("@taskmagic/pieces-framework").StaticDropdownProperty<"download" | "cloudStorage" | "webhook", true>;
|
|
20
|
+
presignedUrl: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
21
|
+
webhookUrl: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
22
|
+
webhookOptions: import("@taskmagic/pieces-framework").JsonProperty<false>;
|
|
23
|
+
filename: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
24
|
+
tag: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
25
|
+
timeout: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
26
|
+
advanced: import("@taskmagic/pieces-framework").JsonProperty<false>;
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToPdf = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../common/auth");
|
|
7
|
+
const build_request_body_1 = require("../common/build-request-body");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const constants_1 = require("../common/constants");
|
|
10
|
+
const output_1 = require("../common/output");
|
|
11
|
+
const props_1 = require("../common/props");
|
|
12
|
+
exports.convertToPdf = (0, pieces_framework_1.createAction)({
|
|
13
|
+
auth: auth_1.polydocAuth,
|
|
14
|
+
name: 'convert_to_pdf',
|
|
15
|
+
displayName: 'Convert to PDF',
|
|
16
|
+
description: 'Convert HTML, a URL, or a saved template to a PDF.',
|
|
17
|
+
props: {
|
|
18
|
+
sourceType: (0, props_1.sourceTypeProp)('url'),
|
|
19
|
+
source: props_1.sourceProp,
|
|
20
|
+
templateData: props_1.templateDataProp,
|
|
21
|
+
format: pieces_framework_1.Property.StaticDropdown({
|
|
22
|
+
displayName: 'Page Format',
|
|
23
|
+
required: false,
|
|
24
|
+
defaultValue: 'A4',
|
|
25
|
+
options: { disabled: false, options: constants_1.PAGE_FORMATS.map((f) => ({ label: f, value: f })) },
|
|
26
|
+
}),
|
|
27
|
+
landscape: pieces_framework_1.Property.Checkbox({ displayName: 'Landscape', required: false, defaultValue: false }),
|
|
28
|
+
printBackground: pieces_framework_1.Property.Checkbox({
|
|
29
|
+
displayName: 'Print Background',
|
|
30
|
+
description: 'Print background graphics and colors.',
|
|
31
|
+
required: false,
|
|
32
|
+
defaultValue: true,
|
|
33
|
+
}),
|
|
34
|
+
scale: pieces_framework_1.Property.Number({
|
|
35
|
+
displayName: 'Scale',
|
|
36
|
+
description: 'Render scale (0.1 to 2).',
|
|
37
|
+
required: false,
|
|
38
|
+
}),
|
|
39
|
+
pageRanges: pieces_framework_1.Property.ShortText({
|
|
40
|
+
displayName: 'Page Ranges',
|
|
41
|
+
description: 'Pages to include, e.g. "1-5, 8". Empty means all pages.',
|
|
42
|
+
required: false,
|
|
43
|
+
}),
|
|
44
|
+
outline: pieces_framework_1.Property.Checkbox({
|
|
45
|
+
displayName: 'Outline (Bookmarks)',
|
|
46
|
+
description: 'Generate PDF bookmarks from HTML headings.',
|
|
47
|
+
required: false,
|
|
48
|
+
defaultValue: false,
|
|
49
|
+
}),
|
|
50
|
+
tagged: pieces_framework_1.Property.Checkbox({
|
|
51
|
+
displayName: 'Tagged (Accessible)',
|
|
52
|
+
description: 'Produce a tagged, accessible PDF.',
|
|
53
|
+
required: false,
|
|
54
|
+
defaultValue: false,
|
|
55
|
+
}),
|
|
56
|
+
marginTop: pieces_framework_1.Property.ShortText({
|
|
57
|
+
displayName: 'Margin Top',
|
|
58
|
+
description: 'Top margin with optional unit, e.g. 10mm, 1cm, 0.5in.',
|
|
59
|
+
required: false,
|
|
60
|
+
}),
|
|
61
|
+
marginRight: pieces_framework_1.Property.ShortText({ displayName: 'Margin Right', required: false }),
|
|
62
|
+
marginBottom: pieces_framework_1.Property.ShortText({ displayName: 'Margin Bottom', required: false }),
|
|
63
|
+
marginLeft: pieces_framework_1.Property.ShortText({ displayName: 'Margin Left', required: false }),
|
|
64
|
+
deliveryMode: props_1.deliveryModeProp,
|
|
65
|
+
presignedUrl: props_1.presignedUrlProp,
|
|
66
|
+
webhookUrl: props_1.webhookUrlProp,
|
|
67
|
+
webhookOptions: props_1.webhookOptionsProp,
|
|
68
|
+
filename: props_1.filenameProp,
|
|
69
|
+
tag: props_1.tagProp,
|
|
70
|
+
timeout: props_1.timeoutProp,
|
|
71
|
+
advanced: props_1.advancedProp,
|
|
72
|
+
},
|
|
73
|
+
run(context) {
|
|
74
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
var _a;
|
|
76
|
+
const props = context.propsValue;
|
|
77
|
+
const params = Object.assign(Object.assign(Object.assign({ operation: 'pdf' }, (0, props_1.resolveSourceParams)(props)), (0, props_1.resolveMetadata)(props)), { delivery: (0, props_1.resolveDelivery)(props), pdfOptions: {
|
|
78
|
+
format: props['format'],
|
|
79
|
+
landscape: props['landscape'],
|
|
80
|
+
printBackground: props['printBackground'],
|
|
81
|
+
scale: props['scale'],
|
|
82
|
+
pageRanges: props['pageRanges'],
|
|
83
|
+
outline: props['outline'],
|
|
84
|
+
tagged: props['tagged'],
|
|
85
|
+
marginTop: props['marginTop'],
|
|
86
|
+
marginRight: props['marginRight'],
|
|
87
|
+
marginBottom: props['marginBottom'],
|
|
88
|
+
marginLeft: props['marginLeft'],
|
|
89
|
+
} });
|
|
90
|
+
const request = (0, build_request_body_1.buildRequestBody)(params);
|
|
91
|
+
try {
|
|
92
|
+
const response = yield (0, client_1.polyDocRequest)(context.auth, request);
|
|
93
|
+
return yield (0, output_1.shapeOutput)({
|
|
94
|
+
response,
|
|
95
|
+
isBinary: request.isBinary,
|
|
96
|
+
files: context.files,
|
|
97
|
+
operation: 'pdf',
|
|
98
|
+
filename: params.filename,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
throw new Error((_a = (0, client_1.extractApiErrorMessage)(error)) !== null && _a !== void 0 ? _a : error.message);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=convert-pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-pdf.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/polydoc/src/lib/actions/convert-pdf.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,yCAA6C;AAC7C,qEAAgE;AAChE,6CAAiG;AACjG,mDAAmD;AACnD,6CAA+C;AAC/C,2CAeyB;AAGZ,QAAA,YAAY,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,oDAAoD;IACjE,KAAK,EAAE;QACL,UAAU,EAAE,IAAA,sBAAc,EAAC,KAAK,CAAC;QACjC,MAAM,EAAE,kBAAU;QAClB,YAAY,EAAE,wBAAgB;QAC9B,MAAM,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC9B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,IAAI;YAClB,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,wBAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE;SACzF,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;QAChG,eAAe,EAAE,2B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S,EAAE,KAAK;oBAChB,QAAQ,EAAE,MAAM,CAAC,QAAQ;iBAC1B,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,MAAA,IAAA,+BAAsB,EAAC,KAAK,CAAC,mCAAK,KAAe,CAAC,OAAO,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const generateEinvoice: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
apiKey: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
sandbox: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
4
|
+
}>, {
|
|
5
|
+
sourceType: import("@taskmagic/pieces-framework").StaticDropdownProperty<"url" | "html" | "template", true>;
|
|
6
|
+
source: import("@taskmagic/pieces-framework").LongTextProperty<true>;
|
|
7
|
+
templateData: import("@taskmagic/pieces-framework").JsonProperty<false>;
|
|
8
|
+
standard: import("@taskmagic/pieces-framework").StaticDropdownProperty<"zugferd" | "facturx", true>;
|
|
9
|
+
profile: import("@taskmagic/pieces-framework").StaticDropdownProperty<"minimum" | "basicwl" | "basic" | "en16931" | "extended", true>;
|
|
10
|
+
invoice: import("@taskmagic/pieces-framework").JsonProperty<true>;
|
|
11
|
+
verify: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
12
|
+
deliveryMode: import("@taskmagic/pieces-framework").StaticDropdownProperty<"download" | "cloudStorage" | "webhook", true>;
|
|
13
|
+
presignedUrl: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
14
|
+
webhookUrl: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
15
|
+
webhookOptions: import("@taskmagic/pieces-framework").JsonProperty<false>;
|
|
16
|
+
filename: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
17
|
+
tag: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
18
|
+
timeout: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
19
|
+
advanced: import("@taskmagic/pieces-framework").JsonProperty<false>;
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateEinvoice = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../common/auth");
|
|
7
|
+
const build_request_body_1 = require("../common/build-request-body");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const constants_1 = require("../common/constants");
|
|
10
|
+
const output_1 = require("../common/output");
|
|
11
|
+
const props_1 = require("../common/props");
|
|
12
|
+
const SAMPLE_INVOICE = {
|
|
13
|
+
number: 'INV-001',
|
|
14
|
+
issueDate: '2026-01-31',
|
|
15
|
+
dueDate: '2026-03-02',
|
|
16
|
+
currencyCode: 'EUR',
|
|
17
|
+
seller: {
|
|
18
|
+
name: 'Your Company GmbH',
|
|
19
|
+
address: { line1: 'Main St 1', city: 'Berlin', postalCode: '10115', countryCode: 'DE' },
|
|
20
|
+
taxId: 'DE123456789',
|
|
21
|
+
},
|
|
22
|
+
buyer: {
|
|
23
|
+
name: 'Customer SARL',
|
|
24
|
+
address: { line1: 'Rue 2', city: 'Paris', postalCode: '75001', countryCode: 'FR' },
|
|
25
|
+
},
|
|
26
|
+
lines: [
|
|
27
|
+
{ description: 'Widget', quantity: 2, unitPrice: 10, lineTotal: 20, vatRate: 19, vatCategoryCode: 'S' },
|
|
28
|
+
],
|
|
29
|
+
taxSummary: [{ categoryCode: 'S', rate: 19, taxableAmount: 20, taxAmount: 3.8 }],
|
|
30
|
+
paymentTerms: 'Net 30 days',
|
|
31
|
+
totalNetAmount: 20,
|
|
32
|
+
totalTaxAmount: 3.8,
|
|
33
|
+
totalGrossAmount: 23.8,
|
|
34
|
+
};
|
|
35
|
+
exports.generateEinvoice = (0, pieces_framework_1.createAction)({
|
|
36
|
+
auth: auth_1.polydocAuth,
|
|
37
|
+
name: 'generate_einvoice',
|
|
38
|
+
displayName: 'Generate E-Invoice',
|
|
39
|
+
description: 'Generate a hybrid e-invoice PDF (Factur-X / ZUGFeRD, EN 16931) from a visual layout plus structured invoice data.',
|
|
40
|
+
props: {
|
|
41
|
+
sourceType: (0, props_1.sourceTypeProp)('html'),
|
|
42
|
+
source: props_1.sourceProp,
|
|
43
|
+
templateData: props_1.templateDataProp,
|
|
44
|
+
standard: pieces_framework_1.Property.StaticDropdown({
|
|
45
|
+
displayName: 'Standard',
|
|
46
|
+
description: 'The hybrid e-invoice standard to embed.',
|
|
47
|
+
required: true,
|
|
48
|
+
defaultValue: 'zugferd',
|
|
49
|
+
options: {
|
|
50
|
+
disabled: false,
|
|
51
|
+
options: constants_1.EINVOICE_STANDARDS.map((o) => ({ label: o.label, value: o.value })),
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
profile: pieces_framework_1.Property.StaticDropdown({
|
|
55
|
+
displayName: 'Profile',
|
|
56
|
+
description: 'The data granularity profile to validate against.',
|
|
57
|
+
required: true,
|
|
58
|
+
defaultValue: 'en16931',
|
|
59
|
+
options: {
|
|
60
|
+
disabled: false,
|
|
61
|
+
options: constants_1.EINVOICE_PROFILES.map((p) => ({ label: p, value: p })),
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
invoice: pieces_framework_1.Property.Json({
|
|
65
|
+
displayName: 'Invoice Data',
|
|
66
|
+
description: 'Structured invoice data: number, dates, currency, seller, buyer, lines, totals. EN 16931 needs payment terms (or due date), seller taxId for VAT category S, and consistent totals. See docs.polydoc.tech.',
|
|
67
|
+
required: true,
|
|
68
|
+
defaultValue: SAMPLE_INVOICE,
|
|
69
|
+
}),
|
|
70
|
+
verify: pieces_framework_1.Property.Checkbox({
|
|
71
|
+
displayName: 'Verify',
|
|
72
|
+
description: 'Validate PDF/A and e-invoice compliance (returns an error if it fails).',
|
|
73
|
+
required: false,
|
|
74
|
+
defaultValue: false,
|
|
75
|
+
}),
|
|
76
|
+
deliveryMode: props_1.deliveryModeProp,
|
|
77
|
+
presignedUrl: props_1.presignedUrlProp,
|
|
78
|
+
webhookUrl: props_1.webhookUrlProp,
|
|
79
|
+
webhookOptions: props_1.webhookOptionsProp,
|
|
80
|
+
filename: props_1.filenameProp,
|
|
81
|
+
tag: props_1.tagProp,
|
|
82
|
+
timeout: props_1.timeoutProp,
|
|
83
|
+
advanced: props_1.advancedProp,
|
|
84
|
+
},
|
|
85
|
+
run(context) {
|
|
86
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
const props = context.propsValue;
|
|
89
|
+
const params = Object.assign(Object.assign(Object.assign({ operation: 'einvoice' }, (0, props_1.resolveSourceParams)(props)), (0, props_1.resolveMetadata)(props)), { delivery: (0, props_1.resolveDelivery)(props), eInvoiceStandard: props['standard'], eInvoiceProfile: props['profile'], eInvoiceVerify: props['verify'] === true, invoice: (_a = (0, props_1.asJsonObject)(props['invoice'])) !== null && _a !== void 0 ? _a : {} });
|
|
90
|
+
const request = (0, build_request_body_1.buildRequestBody)(params);
|
|
91
|
+
try {
|
|
92
|
+
const response = yield (0, client_1.polyDocRequest)(context.auth, request);
|
|
93
|
+
return yield (0, output_1.shapeOutput)({
|
|
94
|
+
response,
|
|
95
|
+
isBinary: request.isBinary,
|
|
96
|
+
files: context.files,
|
|
97
|
+
operation: 'einvoice',
|
|
98
|
+
filename: params.filename,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
throw new Error((_b = (0, client_1.extractApiErrorMessage)(error)) !== null && _b !== void 0 ? _b : error.message);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=generate-einvoice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-einvoice.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/polydoc/src/lib/actions/generate-einvoice.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,yCAA6C;AAC7C,qEAAgE;AAChE,6CAAiG;AACjG,mDAA4E;AAC5E,6CAA+C;AAC/C,2CAgByB;AAGzB,MAAM,cAAc,GAAG;IACrB,MAAM,EAAE,SAAS;IACjB,SAAS,EAAE,YAAY;IACvB,OAAO,EAAE,YAAY;IACrB,YAAY,EAAE,KAAK;IACnB,MAAM,EAAE;QACN,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE;QACvF,KAAK,EAAE,aAAa;KACrB;IACD,KAAK,EAAE;QACL,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE;KACnF;IACD,KAAK,EAAE;QACL,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,eAAe,EAAE,GAAG,EAAE;KACxG;IACD,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;IAChF,YAAY,EAAE,aAAa;IAC3B,cAAc,EAAE,EAAE;IAClB,cAAc,EAAE,GAAG;IACnB,gBAAgB,EAAE,IAAI;CACvB,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,kBA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,OAAO,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.polydocAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const AUTH_GUIDE = `Get an API key from the PolyDoc dashboard (dashboard.polydoc.tech, API Keys). It is sent as Authorization: Bearer <key>.
|
|
9
|
+
|
|
10
|
+
Turn on **Sandbox** to test against sandbox quota (output is watermarked). Leave it off for production conversions.`;
|
|
11
|
+
exports.polydocAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
12
|
+
description: AUTH_GUIDE,
|
|
13
|
+
required: true,
|
|
14
|
+
props: {
|
|
15
|
+
apiKey: pieces_framework_1.PieceAuth.SecretText({
|
|
16
|
+
displayName: 'API Key',
|
|
17
|
+
description: 'Your PolyDoc API key from dashboard.polydoc.tech.',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
sandbox: pieces_framework_1.Property.Checkbox({
|
|
21
|
+
displayName: 'Sandbox',
|
|
22
|
+
description: 'Use sandbox quota (watermarked output).',
|
|
23
|
+
required: false,
|
|
24
|
+
defaultValue: false,
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
28
|
+
var _b;
|
|
29
|
+
const apiKey = auth.apiKey;
|
|
30
|
+
if (!apiKey) {
|
|
31
|
+
return { valid: false, error: 'API key is required.' };
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
// Minimal forced-sandbox screenshot: proves the key is valid without
|
|
35
|
+
// touching production quota. 200 means valid, 401 means a bad key.
|
|
36
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
37
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
38
|
+
url: `${constants_1.DEFAULT_BASE_URL.replace(/\/+$/, '')}${constants_1.SCREENSHOT_CONVERT_PATH}`,
|
|
39
|
+
headers: {
|
|
40
|
+
Authorization: `Bearer ${apiKey}`,
|
|
41
|
+
'Content-Type': 'application/json',
|
|
42
|
+
'X-Sandbox': auth.sandbox ? 'true' : 'false',
|
|
43
|
+
},
|
|
44
|
+
body: { source: '<p>polydoc</p>', screenshot: { type: 'png' } },
|
|
45
|
+
responseType: 'arraybuffer',
|
|
46
|
+
});
|
|
47
|
+
return { valid: true };
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
const status = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.status;
|
|
51
|
+
if (status === 401) {
|
|
52
|
+
return { valid: false, error: 'Invalid PolyDoc API key.' };
|
|
53
|
+
}
|
|
54
|
+
const detail = status ? `the API returned HTTP ${status}` : 'the API was unreachable';
|
|
55
|
+
return {
|
|
56
|
+
valid: false,
|
|
57
|
+
error: `Could not validate the PolyDoc API key (${detail}). Check the key and try again.`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/polydoc/src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,4DAAkE;AAClE,kEAAkE;AAClE,2CAAwE;AAExE,MAAM,UAAU,GAAG;;oHAEiG,CAAC;AAExG,QAAA,WAAW,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC9C,WAAW,EAAE,UAAU;IACvB,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACL,MAAM,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC3B,WAAW,E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gBACnB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC;YAC7D,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,MAAM,EAAE,CAAC,CAAC,CAAC,yBAAyB,CAAC;YACtF,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,2CAA2C,MAAM,iCAAiC;aAC1F,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JsonObject, PolyDocOperation, PolyDocParams, PolyDocRequest } from './types';
|
|
2
|
+
/** Deep-merge `source` into `target` (source wins). Arrays and scalars overwrite. */
|
|
3
|
+
export declare function mergeDeep(target: JsonObject, source: JsonObject): JsonObject;
|
|
4
|
+
/**
|
|
5
|
+
* Assemble the PolyDoc request body. Returns the endpoint to call, the body to
|
|
6
|
+
* send, and whether the default (binary) delivery is in effect.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildRequestBody(params: PolyDocParams): PolyDocRequest;
|
|
9
|
+
/** Default output filename when the user did not set one. */
|
|
10
|
+
export declare function defaultFilename(operation: PolyDocOperation, imageType?: string): string;
|