@pdfme/generator 3.1.5-dev.7 → 3.1.5-dev.8

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.
@@ -29,14 +29,11 @@ const helper_js_1 = require("./helper.js");
29
29
  const generate = async (props) => {
30
30
  (0, common_1.checkGenerateProps)(props);
31
31
  const { inputs, template, options = {}, plugins: userPlugins = {} } = props;
32
- const { pdfDoc, embeddedPages, embedPdfBoxes, renderObj } = await (0, helper_js_1.preprocessing)({
33
- template,
34
- userPlugins,
35
- });
32
+ const { pdfDoc, embeddedPages, embedPdfBoxes, renderObj, readOnlySchemaKeys } = await (0, helper_js_1.preprocessing)({ template, userPlugins });
36
33
  const _cache = new Map();
37
34
  for (let i = 0; i < inputs.length; i += 1) {
38
35
  const inputObj = inputs[i];
39
- const keys = Object.keys(inputObj);
36
+ const keys = Object.keys(inputObj).concat(readOnlySchemaKeys);
40
37
  for (let j = 0; j < embeddedPages.length; j += 1) {
41
38
  const embeddedPage = embeddedPages[j];
42
39
  const { width: pageWidth, height: pageHeight } = embeddedPage;
@@ -47,7 +44,6 @@ const generate = async (props) => {
47
44
  const key = keys[l];
48
45
  const schemaObj = template.schemas[j];
49
46
  const schema = schemaObj[key];
50
- const value = inputObj[key];
51
47
  if (!schema) {
52
48
  continue;
53
49
  }
@@ -55,7 +51,7 @@ const generate = async (props) => {
55
51
  if (!render) {
56
52
  continue;
57
53
  }
58
- await render({ key, value, schema, pdfLib, pdfDoc, page, options, _cache });
54
+ await render({ key, value: inputObj[key], schema, pdfLib, pdfDoc, page, options, _cache });
59
55
  }
60
56
  }
61
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/generate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAyC;AAEzC,0CAAmD;AACnD,2CAA8E;AAE9E,MAAM,QAAQ,GAAG,KAAK,EAAE,KAAoB,EAAE,EAAE;IAC9C,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MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;aAC5F;SACF;KACF;IAED,IAAA,0BAAc,EAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAEpC,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,kBAAe,QAAQ,CAAC"}
@@ -62,7 +62,7 @@ const drawEmbeddedPage = (arg) => {
62
62
  exports.drawEmbeddedPage = drawEmbeddedPage;
63
63
  const preprocessing = async (arg) => {
64
64
  const { template, userPlugins } = arg;
65
- const { basePdf } = template;
65
+ const { basePdf, schemas } = template;
66
66
  const pdfDoc = await pdfLib.PDFDocument.create();
67
67
  // @ts-ignore
68
68
  pdfDoc.registerFontkit(fontkit);
@@ -71,7 +71,7 @@ const preprocessing = async (arg) => {
71
71
  const pluginValues = (Object.values(userPlugins).length > 0
72
72
  ? Object.values(userPlugins)
73
73
  : Object.values(schemas_1.builtInPlugins));
74
- const schemaTypes = template.schemas.flatMap((schemaObj) => Object.values(schemaObj).map((schema) => schema.type));
74
+ const schemaTypes = schemas.flatMap((schemaObj) => Object.values(schemaObj).map((schema) => schema.type));
75
75
  const renderObj = schemaTypes.reduce((acc, type) => {
76
76
  const render = pluginValues.find((pv) => pv.propPanel.defaultSchema.type === type);
77
77
  if (!render) {
@@ -80,7 +80,12 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
80
80
  }
81
81
  return { ...acc, [type]: render.pdf };
82
82
  }, {});
83
- return { pdfDoc, embeddedPages, embedPdfBoxes, renderObj };
83
+ const readOnlySchemaKeys = schemas.reduce((acc, schema) => {
84
+ const entries = Object.entries(schema);
85
+ const keys = entries.reduce((acc, [key, value]) => (value.readOnly ? [...acc, key] : acc), []);
86
+ return [...acc, ...keys];
87
+ }, []);
88
+ return { pdfDoc, embeddedPages, embedPdfBoxes, renderObj, readOnlySchemaKeys };
84
89
  };
85
90
  exports.preprocessing = pre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awEmbeddedPage, preprocessing, postProcessing } from './helper.js';
4
4
  const generate = async (props) => {
5
5
  checkGenerateProps(props);
6
6
  const { inputs, template, options = {}, plugins: userPlugins = {} } = props;
7
- const { pdfDoc, embeddedPages, embedPdfBoxes, renderObj } = await preprocessing({
8
- template,
9
- userPlugins,
10
- });
7
+ const { pdfDoc, embeddedPages, embedPdfBoxes, renderObj, readOnlySchemaKeys } = await preprocessing({ template, userPlugins });
11
8
  const _cache = new Map();
12
9
  for (let i = 0; i < inputs.length; i += 1) {
13
10
  const inputObj = inputs[i];
14
- const keys = Object.keys(inputObj);
11
+ const keys = Object.keys(inputObj).concat(readOnlySchemaKeys);
15
12
  for (let j = 0; j < embeddedPages.length; j += 1) {
16
13
  const embeddedPage = embeddedPages[j];
17
14
  const { width: pageWidth, height: pageHeight } = embeddedPage;
@@ -22,7 +19,6 @@ const generate = async (props) => {
22
19
  const key = keys[l];
23
20
  const schemaObj = template.schemas[j];
24
21
  const schema = schemaObj[key];
25
- const value = inputObj[key];
26
22
  if (!schema) {
27
23
  continue;
28
24
  }
@@ -30,7 +26,7 @@ const generate = async (props) => {
30
26
  if (!render) {
31
27
  continue;
32
28
  }
33
- await render({ key, value, schema, pdfLib, pdfDoc, page, options, _cache });
29
+ await render({ key, value: inputObj[key], schema, pdfLib, pdfDoc, page, options, _cache });
34
30
  }
35
31
  }
36
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE9E,MAAM,QAAQ,GAAG,KAAK,EAAE,KAAoB,EAAE,EAAE;IAC9C,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAM,EAAE,MAAM,EAAE,QA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M,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;aAC5F;SACF;KACF;IAED,cAAc,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAEpC,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -34,7 +34,7 @@ export const drawEmbeddedPage = (arg) => {
34
34
  };
35
35
  export const preprocessing = async (arg) => {
36
36
  const { template, userPlugins } = arg;
37
- const { basePdf } = template;
37
+ const { basePdf, schemas } = template;
38
38
  const pdfDoc = await pdfLib.PDFDocument.create();
39
39
  // @ts-ignore
40
40
  pdfDoc.registerFontkit(fontkit);
@@ -43,7 +43,7 @@ export const preprocessing = async (arg) => {
43
43
  const pluginValues = (Object.values(userPlugins).length > 0
44
44
  ? Object.values(userPlugins)
45
45
  : Object.values(builtInPlugins));
46
- const schemaTypes = template.schemas.flatMap((schemaObj) => Object.values(schemaObj).map((schema) => schema.type));
46
+ const schemaTypes = schemas.flatMap((schemaObj) => Object.values(schemaObj).map((schema) => schema.type));
47
47
  const renderObj = schemaTypes.reduce((acc, type) => {
48
48
  const render = pluginValues.find((pv) => pv.propPanel.defaultSchema.type === type);
49
49
  if (!render) {
@@ -52,7 +52,12 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
52
52
  }
53
53
  return { ...acc, [type]: render.pdf };
54
54
  }, {});
55
- return { pdfDoc, embeddedPages, embedPdfBoxes, renderObj };
55
+ const readOnlySchemaKeys = schemas.reduce((acc, schema) => {
56
+ const entries = Object.entries(schema);
57
+ const keys = entries.reduce((acc, [key, value]) => (value.readOnly ? [...acc, key] : acc), []);
58
+ return [...acc, ...keys];
59
+ }, []);
60
+ return { pdfDoc, embeddedPages, embedPdfBoxes, renderObj, readOnlySchemaKeys };
56
61
  };
57
62
  export const postProcessing = (props) => {
58
63
  const { pdfDoc, options } = props;
@@ -1 +1 @@
1
- {"version":3,"file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,CAAC,CAAC;IAC3B,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC,CAAC"}
@@ -24,6 +24,7 @@ export declare const preprocessing: (arg: {
24
24
  embeddedPages: pdfLib.PDFEmbeddedPage[];
25
25
  embedPdfBoxes: EmbedPdfBox[];
26
26
  renderObj: Record<string, (arg: PDFRenderProps<Schema>) => Promise<void> | void>;
27
+ readOnlySchemaKeys: string[];
27
28
  }>;
28
29
  export declare const postProcessing: (props: {
29
30
  pdfDoc: pdfLib.PDFDocument;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/generator",
3
- "version": "3.1.5-dev.7",
3
+ "version": "3.1.5-dev.8",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
package/src/generate.ts CHANGED
@@ -7,16 +7,14 @@ const generate = async (props: GenerateProps) => {
7
7
  checkGenerateProps(props);
8
8
  const { inputs, template, options = {}, plugins: userPlugins = {} } = props;
9
9
 
10
- const { pdfDoc, embeddedPages, embedPdfBoxes, renderObj } = await preprocessing({
11
- template,
12
- userPlugins,
13
- });
10
+ const { pdfDoc, embeddedPages, embedPdfBoxes, renderObj, readOnlySchemaKeys } =
11
+ await preprocessing({ template, userPlugins });
14
12
 
15
13
  const _cache = new Map();
16
14
 
17
15
  for (let i = 0; i < inputs.length; i += 1) {
18
16
  const inputObj = inputs[i];
19
- const keys = Object.keys(inputObj);
17
+ const keys = Object.keys(inputObj).concat(readOnlySchemaKeys);
20
18
  for (let j = 0; j < embeddedPages.length; j += 1) {
21
19
  const embeddedPage = embeddedPages[j];
22
20
  const { width: pageWidth, height: pageHeight } = embeddedPage;
@@ -29,8 +27,6 @@ const generate = async (props: GenerateProps) => {
29
27
  const key = keys[l];
30
28
  const schemaObj = template.schemas[j];
31
29
  const schema = schemaObj[key];
32
- const value = inputObj[key];
33
-
34
30
  if (!schema) {
35
31
  continue;
36
32
  }
@@ -40,7 +36,7 @@ const generate = async (props: GenerateProps) => {
40
36
  continue;
41
37
  }
42
38
 
43
- await render({ key, value, schema, pdfLib, pdfDoc, page, options, _cache });
39
+ await render({ key, value: inputObj[key], schema, pdfLib, pdfDoc, page, options, _cache });
44
40
  }
45
41
  }
46
42
  }
package/src/helper.ts CHANGED
@@ -55,7 +55,7 @@ export const drawEmbeddedPage = (arg: {
55
55
 
56
56
  export const preprocessing = async (arg: { template: Template; userPlugins: Plugins }) => {
57
57
  const { template, userPlugins } = arg;
58
- const { basePdf } = template;
58
+ const { basePdf, schemas } = template;
59
59
 
60
60
  const pdfDoc = await pdfLib.PDFDocument.create();
61
61
  // @ts-ignore
@@ -70,7 +70,7 @@ export const preprocessing = async (arg: { template: Template; userPlugins: Plug
70
70
  : Object.values(builtInPlugins)
71
71
  ) as Plugin<Schema>[];
72
72
 
73
- const schemaTypes = template.schemas.flatMap((schemaObj) =>
73
+ const schemaTypes = schemas.flatMap((schemaObj) =>
74
74
  Object.values(schemaObj).map((schema) => schema.type)
75
75
  );
76
76
 
@@ -84,7 +84,16 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
84
84
  return { ...acc, [type]: render.pdf };
85
85
  }, {} as Record<string, (arg: PDFRenderProps<Schema>) => Promise<void> | void>);
86
86
 
87
- return { pdfDoc, embeddedPages, embedPdfBoxes, renderObj };
87
+ const readOnlySchemaKeys = schemas.reduce((acc, schema) => {
88
+ const entries = Object.entries(schema);
89
+ const keys = entries.reduce(
90
+ (acc, [key, value]) => (value.readOnly ? [...acc, key] : acc),
91
+ [] as string[]
92
+ );
93
+ return [...acc, ...keys];
94
+ }, [] as string[]);
95
+
96
+ return { pdfDoc, embeddedPages, embedPdfBoxes, renderObj, readOnlySchemaKeys };
88
97
  };
89
98
 
90
99
  export const postProcessing = (props: {