av6-pdf-engine 1.0.7 → 1.0.9
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/dist/index.d.mts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +40 -31
- package/dist/index.mjs +36 -30
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -312,7 +312,31 @@ declare enum PdfEngineErrorCode {
|
|
|
312
312
|
PDF_ERROR_PDFKIT_ERROR = "PDF_ERROR_PDFKIT_ERROR"
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
+
declare class PdfEngineError extends Error {
|
|
316
|
+
readonly code: PdfEngineErrorCode;
|
|
317
|
+
readonly statusCode: number;
|
|
318
|
+
readonly details?: Record<string, unknown>;
|
|
319
|
+
readonly retryable: boolean;
|
|
320
|
+
cause?: unknown;
|
|
321
|
+
constructor(args: {
|
|
322
|
+
code: PdfEngineErrorCode;
|
|
323
|
+
message: string;
|
|
324
|
+
statusCode?: number;
|
|
325
|
+
details?: Record<string, unknown>;
|
|
326
|
+
retryable?: boolean;
|
|
327
|
+
cause?: unknown;
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
declare function isPdfEngineError(e: unknown): e is PdfEngineError;
|
|
331
|
+
declare function toPdfEngineError(cause: unknown, fallback: {
|
|
332
|
+
code: PdfEngineErrorCode;
|
|
333
|
+
message: string;
|
|
334
|
+
statusCode?: number;
|
|
335
|
+
details?: Record<string, unknown>;
|
|
336
|
+
retryable?: boolean;
|
|
337
|
+
}): PdfEngineError;
|
|
338
|
+
|
|
315
339
|
declare function renderCustomPdf(def: CustomDocDefinition, outputPath: string): Promise<void>;
|
|
316
340
|
declare function renderCustomPdfToBuffer(def: CustomDocDefinition): Promise<Buffer>;
|
|
317
341
|
|
|
318
|
-
export { type Alignment, BARCODE_TYPES, type BarcodeBlock, type BarcodeType, type BaseBlock, type Block, type BuiltInFont, type ColumnsBlock, type CustomDocDefinition, type FontName, type FontRegistration, type FooterDef, type FooterInput, type HeaderDef, type ImageBlock, type InlineTextStyle, type KeyValueGridBlock, type KeyValueItem, type LineBlock, type Orientation, type PDFDoc, type PageBackgroundDef, type PageBreakBlock, type PageContext, type PageMargins, PdfEngineErrorCode, type QRErrorLevel, QR_ERROR_LEVEL, type QrCodeBlock, type RenderEnv, type SignatureBlock, type StyleDef, type StyleRef, type TableBlock, type TableCell, type TextBlock, type WatermarkDef, type WatermarkMode, type Width, renderCustomPdf, renderCustomPdfToBuffer };
|
|
342
|
+
export { type Alignment, BARCODE_TYPES, type BarcodeBlock, type BarcodeType, type BaseBlock, type Block, type BuiltInFont, type ColumnsBlock, type CustomDocDefinition, type FontName, type FontRegistration, type FooterDef, type FooterInput, type HeaderDef, type ImageBlock, type InlineTextStyle, type KeyValueGridBlock, type KeyValueItem, type LineBlock, type Orientation, type PDFDoc, type PageBackgroundDef, type PageBreakBlock, type PageContext, type PageMargins, PdfEngineError, PdfEngineErrorCode, type QRErrorLevel, QR_ERROR_LEVEL, type QrCodeBlock, type RenderEnv, type SignatureBlock, type StyleDef, type StyleRef, type TableBlock, type TableCell, type TextBlock, type WatermarkDef, type WatermarkMode, type Width, isPdfEngineError, renderCustomPdf, renderCustomPdfToBuffer, toPdfEngineError };
|
package/dist/index.d.ts
CHANGED
|
@@ -312,7 +312,31 @@ declare enum PdfEngineErrorCode {
|
|
|
312
312
|
PDF_ERROR_PDFKIT_ERROR = "PDF_ERROR_PDFKIT_ERROR"
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
+
declare class PdfEngineError extends Error {
|
|
316
|
+
readonly code: PdfEngineErrorCode;
|
|
317
|
+
readonly statusCode: number;
|
|
318
|
+
readonly details?: Record<string, unknown>;
|
|
319
|
+
readonly retryable: boolean;
|
|
320
|
+
cause?: unknown;
|
|
321
|
+
constructor(args: {
|
|
322
|
+
code: PdfEngineErrorCode;
|
|
323
|
+
message: string;
|
|
324
|
+
statusCode?: number;
|
|
325
|
+
details?: Record<string, unknown>;
|
|
326
|
+
retryable?: boolean;
|
|
327
|
+
cause?: unknown;
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
declare function isPdfEngineError(e: unknown): e is PdfEngineError;
|
|
331
|
+
declare function toPdfEngineError(cause: unknown, fallback: {
|
|
332
|
+
code: PdfEngineErrorCode;
|
|
333
|
+
message: string;
|
|
334
|
+
statusCode?: number;
|
|
335
|
+
details?: Record<string, unknown>;
|
|
336
|
+
retryable?: boolean;
|
|
337
|
+
}): PdfEngineError;
|
|
338
|
+
|
|
315
339
|
declare function renderCustomPdf(def: CustomDocDefinition, outputPath: string): Promise<void>;
|
|
316
340
|
declare function renderCustomPdfToBuffer(def: CustomDocDefinition): Promise<Buffer>;
|
|
317
341
|
|
|
318
|
-
export { type Alignment, BARCODE_TYPES, type BarcodeBlock, type BarcodeType, type BaseBlock, type Block, type BuiltInFont, type ColumnsBlock, type CustomDocDefinition, type FontName, type FontRegistration, type FooterDef, type FooterInput, type HeaderDef, type ImageBlock, type InlineTextStyle, type KeyValueGridBlock, type KeyValueItem, type LineBlock, type Orientation, type PDFDoc, type PageBackgroundDef, type PageBreakBlock, type PageContext, type PageMargins, PdfEngineErrorCode, type QRErrorLevel, QR_ERROR_LEVEL, type QrCodeBlock, type RenderEnv, type SignatureBlock, type StyleDef, type StyleRef, type TableBlock, type TableCell, type TextBlock, type WatermarkDef, type WatermarkMode, type Width, renderCustomPdf, renderCustomPdfToBuffer };
|
|
342
|
+
export { type Alignment, BARCODE_TYPES, type BarcodeBlock, type BarcodeType, type BaseBlock, type Block, type BuiltInFont, type ColumnsBlock, type CustomDocDefinition, type FontName, type FontRegistration, type FooterDef, type FooterInput, type HeaderDef, type ImageBlock, type InlineTextStyle, type KeyValueGridBlock, type KeyValueItem, type LineBlock, type Orientation, type PDFDoc, type PageBackgroundDef, type PageBreakBlock, type PageContext, type PageMargins, PdfEngineError, PdfEngineErrorCode, type QRErrorLevel, QR_ERROR_LEVEL, type QrCodeBlock, type RenderEnv, type SignatureBlock, type StyleDef, type StyleRef, type TableBlock, type TableCell, type TextBlock, type WatermarkDef, type WatermarkMode, type Width, isPdfEngineError, renderCustomPdf, renderCustomPdfToBuffer, toPdfEngineError };
|
package/dist/index.js
CHANGED
|
@@ -31,13 +31,48 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
BARCODE_TYPES: () => BARCODE_TYPES,
|
|
34
|
+
PdfEngineError: () => PdfEngineError,
|
|
34
35
|
PdfEngineErrorCode: () => PdfEngineErrorCode,
|
|
35
36
|
QR_ERROR_LEVEL: () => QR_ERROR_LEVEL,
|
|
37
|
+
isPdfEngineError: () => isPdfEngineError,
|
|
36
38
|
renderCustomPdf: () => renderCustomPdf,
|
|
37
|
-
renderCustomPdfToBuffer: () => renderCustomPdfToBuffer
|
|
39
|
+
renderCustomPdfToBuffer: () => renderCustomPdfToBuffer,
|
|
40
|
+
toPdfEngineError: () => toPdfEngineError
|
|
38
41
|
});
|
|
39
42
|
module.exports = __toCommonJS(index_exports);
|
|
40
43
|
|
|
44
|
+
// src/error/index.ts
|
|
45
|
+
var PdfEngineError = class extends Error {
|
|
46
|
+
code;
|
|
47
|
+
statusCode;
|
|
48
|
+
details;
|
|
49
|
+
retryable;
|
|
50
|
+
cause;
|
|
51
|
+
constructor(args) {
|
|
52
|
+
super(args.message);
|
|
53
|
+
this.name = "PdfEngineError";
|
|
54
|
+
this.code = args.code;
|
|
55
|
+
this.statusCode = args.statusCode ?? 400;
|
|
56
|
+
this.details = args.details;
|
|
57
|
+
this.retryable = args.retryable ?? false;
|
|
58
|
+
this.cause = args.cause;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function isPdfEngineError(e) {
|
|
62
|
+
return e instanceof PdfEngineError;
|
|
63
|
+
}
|
|
64
|
+
function toPdfEngineError(cause, fallback) {
|
|
65
|
+
if (cause instanceof PdfEngineError) return cause;
|
|
66
|
+
return new PdfEngineError({
|
|
67
|
+
code: fallback.code,
|
|
68
|
+
message: fallback.message,
|
|
69
|
+
statusCode: fallback.statusCode,
|
|
70
|
+
details: fallback.details,
|
|
71
|
+
retryable: fallback.retryable,
|
|
72
|
+
cause
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
41
76
|
// src/renderer-engine/index.ts
|
|
42
77
|
var import_fs = __toESM(require("fs"));
|
|
43
78
|
var import_pdfkit = __toESM(require("pdfkit"));
|
|
@@ -825,35 +860,6 @@ var contentEnv = (doc) => ({
|
|
|
825
860
|
allowPageBreak: true
|
|
826
861
|
});
|
|
827
862
|
|
|
828
|
-
// src/renderer-engine/utils/error.ts
|
|
829
|
-
var PdfEngineError = class extends Error {
|
|
830
|
-
code;
|
|
831
|
-
statusCode;
|
|
832
|
-
details;
|
|
833
|
-
retryable;
|
|
834
|
-
cause;
|
|
835
|
-
constructor(args) {
|
|
836
|
-
super(args.message);
|
|
837
|
-
this.name = "PdfEngineError";
|
|
838
|
-
this.code = args.code;
|
|
839
|
-
this.statusCode = args.statusCode ?? 400;
|
|
840
|
-
this.details = args.details;
|
|
841
|
-
this.retryable = args.retryable ?? false;
|
|
842
|
-
this.cause = args.cause;
|
|
843
|
-
}
|
|
844
|
-
};
|
|
845
|
-
function toPdfEngineError(cause, fallback) {
|
|
846
|
-
if (cause instanceof PdfEngineError) return cause;
|
|
847
|
-
return new PdfEngineError({
|
|
848
|
-
code: fallback.code,
|
|
849
|
-
message: fallback.message,
|
|
850
|
-
statusCode: fallback.statusCode,
|
|
851
|
-
details: fallback.details,
|
|
852
|
-
retryable: fallback.retryable,
|
|
853
|
-
cause
|
|
854
|
-
});
|
|
855
|
-
}
|
|
856
|
-
|
|
857
863
|
// src/renderer-engine/utils/finish-page.ts
|
|
858
864
|
function finishPage({
|
|
859
865
|
addNewPage,
|
|
@@ -1963,8 +1969,11 @@ async function renderCustomPdfToBuffer(def) {
|
|
|
1963
1969
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1964
1970
|
0 && (module.exports = {
|
|
1965
1971
|
BARCODE_TYPES,
|
|
1972
|
+
PdfEngineError,
|
|
1966
1973
|
PdfEngineErrorCode,
|
|
1967
1974
|
QR_ERROR_LEVEL,
|
|
1975
|
+
isPdfEngineError,
|
|
1968
1976
|
renderCustomPdf,
|
|
1969
|
-
renderCustomPdfToBuffer
|
|
1977
|
+
renderCustomPdfToBuffer,
|
|
1978
|
+
toPdfEngineError
|
|
1970
1979
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
// src/error/index.ts
|
|
2
|
+
var PdfEngineError = class extends Error {
|
|
3
|
+
code;
|
|
4
|
+
statusCode;
|
|
5
|
+
details;
|
|
6
|
+
retryable;
|
|
7
|
+
cause;
|
|
8
|
+
constructor(args) {
|
|
9
|
+
super(args.message);
|
|
10
|
+
this.name = "PdfEngineError";
|
|
11
|
+
this.code = args.code;
|
|
12
|
+
this.statusCode = args.statusCode ?? 400;
|
|
13
|
+
this.details = args.details;
|
|
14
|
+
this.retryable = args.retryable ?? false;
|
|
15
|
+
this.cause = args.cause;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function isPdfEngineError(e) {
|
|
19
|
+
return e instanceof PdfEngineError;
|
|
20
|
+
}
|
|
21
|
+
function toPdfEngineError(cause, fallback) {
|
|
22
|
+
if (cause instanceof PdfEngineError) return cause;
|
|
23
|
+
return new PdfEngineError({
|
|
24
|
+
code: fallback.code,
|
|
25
|
+
message: fallback.message,
|
|
26
|
+
statusCode: fallback.statusCode,
|
|
27
|
+
details: fallback.details,
|
|
28
|
+
retryable: fallback.retryable,
|
|
29
|
+
cause
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
1
33
|
// src/renderer-engine/index.ts
|
|
2
34
|
import fs from "fs";
|
|
3
35
|
import PDFDocument from "pdfkit";
|
|
@@ -785,35 +817,6 @@ var contentEnv = (doc) => ({
|
|
|
785
817
|
allowPageBreak: true
|
|
786
818
|
});
|
|
787
819
|
|
|
788
|
-
// src/renderer-engine/utils/error.ts
|
|
789
|
-
var PdfEngineError = class extends Error {
|
|
790
|
-
code;
|
|
791
|
-
statusCode;
|
|
792
|
-
details;
|
|
793
|
-
retryable;
|
|
794
|
-
cause;
|
|
795
|
-
constructor(args) {
|
|
796
|
-
super(args.message);
|
|
797
|
-
this.name = "PdfEngineError";
|
|
798
|
-
this.code = args.code;
|
|
799
|
-
this.statusCode = args.statusCode ?? 400;
|
|
800
|
-
this.details = args.details;
|
|
801
|
-
this.retryable = args.retryable ?? false;
|
|
802
|
-
this.cause = args.cause;
|
|
803
|
-
}
|
|
804
|
-
};
|
|
805
|
-
function toPdfEngineError(cause, fallback) {
|
|
806
|
-
if (cause instanceof PdfEngineError) return cause;
|
|
807
|
-
return new PdfEngineError({
|
|
808
|
-
code: fallback.code,
|
|
809
|
-
message: fallback.message,
|
|
810
|
-
statusCode: fallback.statusCode,
|
|
811
|
-
details: fallback.details,
|
|
812
|
-
retryable: fallback.retryable,
|
|
813
|
-
cause
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
|
|
817
820
|
// src/renderer-engine/utils/finish-page.ts
|
|
818
821
|
function finishPage({
|
|
819
822
|
addNewPage,
|
|
@@ -1922,8 +1925,11 @@ async function renderCustomPdfToBuffer(def) {
|
|
|
1922
1925
|
}
|
|
1923
1926
|
export {
|
|
1924
1927
|
BARCODE_TYPES,
|
|
1928
|
+
PdfEngineError,
|
|
1925
1929
|
PdfEngineErrorCode,
|
|
1926
1930
|
QR_ERROR_LEVEL,
|
|
1931
|
+
isPdfEngineError,
|
|
1927
1932
|
renderCustomPdf,
|
|
1928
|
-
renderCustomPdfToBuffer
|
|
1933
|
+
renderCustomPdfToBuffer,
|
|
1934
|
+
toPdfEngineError
|
|
1929
1935
|
};
|