@telorun/pdf 0.2.1 → 0.3.0
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.
|
@@ -14,10 +14,10 @@ class PdfFormFields {
|
|
|
14
14
|
}
|
|
15
15
|
async invoke(inputs) {
|
|
16
16
|
const label = `Pdf.FormFields "${this.resource.metadata.name}"`;
|
|
17
|
+
// An `inputs.scale` is declared on `inputType` with `exclusiveMinimum: 0` and
|
|
18
|
+
// enforced by the kernel's contract binding; the resource-level fallback is
|
|
19
|
+
// checked by the config schema. Neither needs re-checking here.
|
|
17
20
|
const scale = inputs?.scale ?? this.resource.scale ?? 1;
|
|
18
|
-
if (typeof scale !== "number" || !(scale > 0)) {
|
|
19
|
-
throw new InvokeError("ERR_INVALID_INPUT", `${label}: 'scale' must be a positive number; got ${scale}.`);
|
|
20
|
-
}
|
|
21
21
|
const data = inputs?.data;
|
|
22
22
|
if (!(data instanceof Uint8Array)) {
|
|
23
23
|
throw new InvokeError("ERR_INVALID_INPUT", `${label}: 'data' must be a Uint8Array of PDF bytes; got ${typeof data}.`);
|
|
@@ -32,10 +32,11 @@ class PdfRasterizer {
|
|
|
32
32
|
if (!(data instanceof Uint8Array)) {
|
|
33
33
|
throw new InvokeError("ERR_INVALID_INPUT", `Pdf.Rasterizer "${name}": 'data' must be a Uint8Array of PDF bytes; got ${typeof data}.`);
|
|
34
34
|
}
|
|
35
|
+
// `page` is declared on `inputType` as an integer with `minimum: 1` and
|
|
36
|
+
// enforced by the kernel's contract binding, so only the range check the
|
|
37
|
+
// schema cannot express — page vs. the document's actual page count — is
|
|
38
|
+
// still this controller's to make (below).
|
|
35
39
|
const pageNumber = inputs.page ?? 1;
|
|
36
|
-
if (!Number.isInteger(pageNumber) || pageNumber < 1) {
|
|
37
|
-
throw new InvokeError("ERR_INVALID_INPUT", `Pdf.Rasterizer "${name}": 'page' must be a positive integer; got ${pageNumber}.`);
|
|
38
|
-
}
|
|
39
40
|
const task = loadPdf(data);
|
|
40
41
|
try {
|
|
41
42
|
const doc = await task.promise.catch((err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telorun/pdf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "PDF primitives — rasterize pages to PNG images and author editable AcroForm fields.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"telo",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^20.0.0",
|
|
49
49
|
"typescript": "^5.0.0",
|
|
50
|
-
"@telorun/sdk": "0.
|
|
50
|
+
"@telorun/sdk": "0.61.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@telorun/sdk": "*"
|
|
@@ -41,13 +41,10 @@ class PdfFormFields implements ResourceInstance<FormFieldsInputs, FormFieldsOutp
|
|
|
41
41
|
|
|
42
42
|
async invoke(inputs: FormFieldsInputs): Promise<FormFieldsOutputs> {
|
|
43
43
|
const label = `Pdf.FormFields "${this.resource.metadata.name}"`;
|
|
44
|
+
// An `inputs.scale` is declared on `inputType` with `exclusiveMinimum: 0` and
|
|
45
|
+
// enforced by the kernel's contract binding; the resource-level fallback is
|
|
46
|
+
// checked by the config schema. Neither needs re-checking here.
|
|
44
47
|
const scale = inputs?.scale ?? this.resource.scale ?? 1;
|
|
45
|
-
if (typeof scale !== "number" || !(scale > 0)) {
|
|
46
|
-
throw new InvokeError(
|
|
47
|
-
"ERR_INVALID_INPUT",
|
|
48
|
-
`${label}: 'scale' must be a positive number; got ${scale}.`,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
48
|
const data = inputs?.data;
|
|
52
49
|
if (!(data instanceof Uint8Array)) {
|
|
53
50
|
throw new InvokeError(
|
|
@@ -59,13 +59,11 @@ class PdfRasterizer implements ResourceInstance<RasterizerInputs, RasterizerOutp
|
|
|
59
59
|
`Pdf.Rasterizer "${name}": 'data' must be a Uint8Array of PDF bytes; got ${typeof data}.`,
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
|
+
// `page` is declared on `inputType` as an integer with `minimum: 1` and
|
|
63
|
+
// enforced by the kernel's contract binding, so only the range check the
|
|
64
|
+
// schema cannot express — page vs. the document's actual page count — is
|
|
65
|
+
// still this controller's to make (below).
|
|
62
66
|
const pageNumber = inputs.page ?? 1;
|
|
63
|
-
if (!Number.isInteger(pageNumber) || pageNumber < 1) {
|
|
64
|
-
throw new InvokeError(
|
|
65
|
-
"ERR_INVALID_INPUT",
|
|
66
|
-
`Pdf.Rasterizer "${name}": 'page' must be a positive integer; got ${pageNumber}.`,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
67
|
|
|
70
68
|
const task = loadPdf(data);
|
|
71
69
|
try {
|