@sme.up/doc-alchemist 1.1.0-SNAPSHOT-20250623155458 → 1.1.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.
Files changed (127) hide show
  1. package/README.md +278 -30
  2. package/dist/assets/gfx-data.d.ts +1 -0
  3. package/dist/assets/gfx-data.js +2 -0
  4. package/dist/assets/gfx-data.js.map +1 -0
  5. package/dist/converters/excel/commons.d.ts +35 -0
  6. package/dist/converters/excel/commons.js +216 -0
  7. package/dist/converters/excel/commons.js.map +1 -0
  8. package/dist/{src/excel/excel-generator.types.d.ts → converters/excel/excel-converter.types.d.ts} +1 -0
  9. package/dist/{src/excel/excel-generator.types.js → converters/excel/excel-converter.types.js} +4 -2
  10. package/dist/converters/excel/excel-converter.types.js.map +1 -0
  11. package/dist/{src/excel/matrix-generator.d.ts → converters/excel/matrix-converter.d.ts} +4 -2
  12. package/dist/{src/excel/matrix-generator.js → converters/excel/matrix-converter.js} +32 -17
  13. package/dist/converters/excel/matrix-converter.js.map +1 -0
  14. package/dist/{src/excel/tree-generator.d.ts → converters/excel/tree-converter.d.ts} +2 -2
  15. package/dist/{src/excel/tree-generator.js → converters/excel/tree-converter.js} +5 -5
  16. package/dist/converters/excel/tree-converter.js.map +1 -0
  17. package/dist/{src/excel/excel-generator.d.ts → converters/excel-converter.d.ts} +2 -1
  18. package/dist/{src/excel/excel-generator.js → converters/excel-converter.js} +4 -4
  19. package/dist/converters/excel-converter.js.map +1 -0
  20. package/dist/converters/images/charts-generator.d.ts +9 -0
  21. package/dist/converters/images/charts-generator.js +250 -0
  22. package/dist/converters/images/charts-generator.js.map +1 -0
  23. package/dist/converters/pdf/autotable-renderer.d.ts +3 -0
  24. package/dist/converters/pdf/autotable-renderer.js +89 -0
  25. package/dist/converters/pdf/autotable-renderer.js.map +1 -0
  26. package/dist/converters/pdf/cover-renderer.d.ts +1 -0
  27. package/dist/converters/pdf/cover-renderer.js +26 -0
  28. package/dist/converters/pdf/cover-renderer.js.map +1 -0
  29. package/dist/converters/pdf/formulas-helper.d.ts +40 -0
  30. package/dist/converters/pdf/formulas-helper.js +227 -0
  31. package/dist/converters/pdf/formulas-helper.js.map +1 -0
  32. package/dist/converters/pdf/matrix-converter.d.ts +16 -0
  33. package/dist/converters/pdf/matrix-converter.js +198 -0
  34. package/dist/converters/pdf/matrix-converter.js.map +1 -0
  35. package/dist/converters/pdf/pdf-converter.types.d.ts +12 -0
  36. package/dist/converters/pdf/pdf-converter.types.js +2 -0
  37. package/dist/converters/pdf/pdf-converter.types.js.map +1 -0
  38. package/dist/converters/pdf/sch-converter.d.ts +3 -0
  39. package/dist/converters/pdf/sch-converter.js +99 -0
  40. package/dist/converters/pdf/sch-converter.js.map +1 -0
  41. package/dist/converters/pdf-converter.d.ts +8 -0
  42. package/dist/converters/pdf-converter.js +44 -0
  43. package/dist/converters/pdf-converter.js.map +1 -0
  44. package/dist/index.d.ts +7 -4
  45. package/dist/index.js +4 -2
  46. package/dist/index.js.map +1 -1
  47. package/dist/types/component.d.ts +53 -0
  48. package/dist/types/component.js +53 -0
  49. package/dist/types/component.js.map +1 -0
  50. package/dist/types/data-structures/smeupDataStructure.d.ts +215 -0
  51. package/dist/types/data-structures/smeupDataStructure.js +99 -0
  52. package/dist/types/data-structures/smeupDataStructure.js.map +1 -0
  53. package/dist/types/data-structures/smeupDataTable.d.ts +116 -0
  54. package/dist/types/data-structures/smeupDataTable.js +43 -0
  55. package/dist/types/data-structures/smeupDataTable.js.map +1 -0
  56. package/dist/types/data-structures/smeupDataTree.d.ts +13 -0
  57. package/dist/types/data-structures/smeupDataTree.js +2 -0
  58. package/dist/types/data-structures/smeupDataTree.js.map +1 -0
  59. package/dist/types/data-structures/smeupSch.d.ts +72 -0
  60. package/dist/types/data-structures/smeupSch.js +11 -0
  61. package/dist/types/data-structures/smeupSch.js.map +1 -0
  62. package/dist/types/dynamism.d.ts +45 -0
  63. package/dist/types/dynamism.js +30 -0
  64. package/dist/types/dynamism.js.map +1 -0
  65. package/dist/types/general.d.ts +22 -0
  66. package/dist/types/general.js +24 -0
  67. package/dist/types/general.js.map +1 -0
  68. package/dist/types/helpers.d.ts +4 -0
  69. package/dist/types/helpers.js +6 -0
  70. package/dist/types/helpers.js.map +1 -0
  71. package/dist/{src/types → types}/index.d.ts +8 -2
  72. package/dist/{src/types → types}/index.js +1 -0
  73. package/dist/types/index.js.map +1 -0
  74. package/dist/utils/commons-utility.d.ts +59 -0
  75. package/dist/{src/utils/generator-utility.js → utils/commons-utility.js} +63 -10
  76. package/dist/utils/commons-utility.js.map +1 -0
  77. package/dist/utils/datastructure-utility.d.ts +2 -0
  78. package/dist/utils/datastructure-utility.js +5 -0
  79. package/dist/utils/datastructure-utility.js.map +1 -0
  80. package/dist/{src/utils → utils}/dates-utility.d.ts +9 -0
  81. package/dist/{src/utils → utils}/dates-utility.js +18 -0
  82. package/dist/utils/dates-utility.js.map +1 -0
  83. package/dist/utils/formatter-utility.d.ts +3 -0
  84. package/dist/utils/formatter-utility.js +36 -0
  85. package/dist/utils/formatter-utility.js.map +1 -0
  86. package/dist/{src/utils → utils}/math-utility.d.ts +1 -0
  87. package/dist/{src/utils → utils}/math-utility.js +10 -0
  88. package/dist/utils/math-utility.js.map +1 -0
  89. package/dist/utils/objects-utility.js.map +1 -0
  90. package/dist/utils/regex-utility.js.map +1 -0
  91. package/package.json +13 -11
  92. package/dist/assets/sample-data.d.ts +0 -48
  93. package/dist/assets/sample-data.js +0 -372
  94. package/dist/assets/sample-data.js.map +0 -1
  95. package/dist/debug.d.ts +0 -1
  96. package/dist/debug.js +0 -29
  97. package/dist/debug.js.map +0 -1
  98. package/dist/src/excel/commons.d.ts +0 -21
  99. package/dist/src/excel/commons.js +0 -120
  100. package/dist/src/excel/commons.js.map +0 -1
  101. package/dist/src/excel/excel-generator.js.map +0 -1
  102. package/dist/src/excel/excel-generator.types.js.map +0 -1
  103. package/dist/src/excel/matrix-generator.js.map +0 -1
  104. package/dist/src/excel/tree-generator.js.map +0 -1
  105. package/dist/src/index.d.ts +0 -1
  106. package/dist/src/index.js +0 -2
  107. package/dist/src/index.js.map +0 -1
  108. package/dist/src/pdf/pdf-generator.d.ts +0 -7
  109. package/dist/src/pdf/pdf-generator.js +0 -28
  110. package/dist/src/pdf/pdf-generator.js.map +0 -1
  111. package/dist/src/types/index.js.map +0 -1
  112. package/dist/src/utils/datastructure-utility.d.ts +0 -2
  113. package/dist/src/utils/datastructure-utility.js +0 -5
  114. package/dist/src/utils/datastructure-utility.js.map +0 -1
  115. package/dist/src/utils/dates-utility.js.map +0 -1
  116. package/dist/src/utils/generator-utility.d.ts +0 -34
  117. package/dist/src/utils/generator-utility.js.map +0 -1
  118. package/dist/src/utils/math-utility.js.map +0 -1
  119. package/dist/src/utils/objects-utility.js.map +0 -1
  120. package/dist/src/utils/regex-utility.js.map +0 -1
  121. package/dist/tests/excel-generator.test.d.ts +0 -1
  122. package/dist/tests/excel-generator.test.js +0 -406
  123. package/dist/tests/excel-generator.test.js.map +0 -1
  124. /package/dist/{src/utils → utils}/objects-utility.d.ts +0 -0
  125. /package/dist/{src/utils → utils}/objects-utility.js +0 -0
  126. /package/dist/{src/utils → utils}/regex-utility.d.ts +0 -0
  127. /package/dist/{src/utils → utils}/regex-utility.js +0 -0
@@ -0,0 +1,99 @@
1
+ import * as jsPDFModule from "jspdf";
2
+ import { dataTableToChart } from "../images/charts-generator.js";
3
+ import { Shapes } from "../../types/component.js";
4
+ const jsPDF = jsPDFModule.jsPDF;
5
+ export const schedaToPdfDoc = async (sch) => {
6
+ const doc = new jsPDF({ orientation: "landscape" });
7
+ const x = 10;
8
+ const y = 10;
9
+ doc.setFont("Helvetica", "normal", 10);
10
+ const pageWidth = doc.internal.pageSize.getWidth();
11
+ const pageHeight = doc.internal.pageSize.getHeight();
12
+ const layout = sch.layout || "column";
13
+ const sections = sch.sections || [];
14
+ let offsetX = x;
15
+ let offsetY = y;
16
+ for (const section of filterSections(sections)) {
17
+ let sectionW = pageWidth - 2 * x;
18
+ let sectionH = (pageHeight - 2 * y) / sections.length;
19
+ if (layout === "row") {
20
+ sectionW = (pageWidth - 2 * x) / sections.length;
21
+ sectionH = pageHeight - 2 * y;
22
+ }
23
+ await renderSection(doc, section, layout, offsetX, offsetY, sectionW, sectionH);
24
+ if (layout === "row")
25
+ offsetX += sectionW;
26
+ else
27
+ offsetY += sectionH;
28
+ }
29
+ return doc;
30
+ };
31
+ // Helper to render a section
32
+ const renderSection = async (doc, section, parentLayout, parentX, parentY, parentW, parentH) => {
33
+ const layout = section.layout || parentLayout;
34
+ const title = section.components?.[0]?.title || "";
35
+ const dim = section.dim ? parseFloat(section.dim) : undefined;
36
+ let sectionW = parentW;
37
+ let sectionH = parentH;
38
+ if (dim) {
39
+ if (layout === "row")
40
+ sectionW = parentW * (dim / 100);
41
+ else
42
+ sectionH = parentH * (dim / 100);
43
+ }
44
+ // Draw title
45
+ doc.text(title, parentX + 2, parentY + 7);
46
+ // Draw component type (assume one component)
47
+ if (section.components && section.components.length > 0) {
48
+ //const compType = section.components[0].type;
49
+ const data = section.components[0].data || {};
50
+ const options = section.components[0].options?.EXA?.[0];
51
+ if (options == null) {
52
+ throw new Error("Options is undefined or null for component");
53
+ }
54
+ const image = await dataTableToChart(data, "line", {
55
+ Width: String((sectionW - 4) * 10),
56
+ Height: String((sectionH - 20) * 10),
57
+ ...options,
58
+ });
59
+ const base64Image = image.toString("base64");
60
+ doc.addImage(`data:image/jpg;base64,${base64Image}`, "JPG", parentX + 2, parentY + 15, sectionW - 4, sectionH - 20, undefined);
61
+ }
62
+ // Draw child sections
63
+ if (section.sections && section.sections.length > 0) {
64
+ let offsetX = parentX;
65
+ let offsetY = parentY + 20;
66
+ const filteredSections = filterSections(section.sections);
67
+ for (let i = 0; i < filteredSections.length; i++) {
68
+ const sub = filteredSections[i];
69
+ let subW = sectionW;
70
+ let subH = sectionH;
71
+ if (layout === "row")
72
+ subW = sectionW / section.sections.length;
73
+ else
74
+ subH = sectionH / section.sections.length;
75
+ await renderSection(doc, sub, layout, offsetX, offsetY, subW, subH);
76
+ if (layout === "row")
77
+ offsetX += subW;
78
+ else
79
+ offsetY += subH;
80
+ }
81
+ }
82
+ };
83
+ const filterSections = (sections) => {
84
+ return sections.filter(section => {
85
+ // Filter out sections that are empty or have no components
86
+ if (section.components &&
87
+ section.components.length > 0 &&
88
+ section.components[0].type === Shapes.EXA) {
89
+ return true;
90
+ }
91
+ // Recursively filter child sections
92
+ if (section.sections && section.sections.length > 0) {
93
+ section.sections = filterSections(section.sections);
94
+ return section.sections.length > 0;
95
+ }
96
+ return false;
97
+ });
98
+ };
99
+ //# sourceMappingURL=sch-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sch-converter.js","sourceRoot":"","sources":["../../../src/converters/pdf/sch-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAMlD,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC;AAEhC,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,GAAa,EACe,EAAE;IAC9B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC;IACpD,MAAM,CAAC,GAAG,EAAE,CAAC;IACb,MAAM,CAAC,GAAG,EAAE,CAAC;IACb,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IACvC,MAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;IAErD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,QAAQ,CAAC;I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CAAC;YAC7B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,GAAG,EACzC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,oCAAoC;QACpC,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpD,OAAO,CAAC,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpD,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import * as jsPDFModule from \"jspdf\";\nimport { dataTableToChart } from \"../images/charts-generator.js\";\nimport { Shapes } from \"../../types/component.js\";\nimport { SmeupDataTable } from \"../../types/data-structures/smeupDataTable.js\";\nimport {\n SmeupSch,\n SmeupSchSection,\n} from \"../../types/data-structures/smeupSch.js\";\nconst jsPDF = jsPDFModule.jsPDF;\n\nexport const schedaToPdfDoc = async (\n sch: SmeupSch,\n): Promise<jsPDFModule.jsPDF> => {\n const doc = new jsPDF({ orientation: \"landscape\" });\n const x = 10;\n const y = 10;\n doc.setFont(\"Helvetica\", \"normal\", 10);\n const pageWidth = doc.internal.pageSize.getWidth();\n const pageHeight = doc.internal.pageSize.getHeight();\n\n const layout = sch.layout || \"column\";\n const sections = sch.sections || [];\n let offsetX = x;\n let offsetY = y;\n for (const section of filterSections(sections)) {\n let sectionW = pageWidth - 2 * x;\n let sectionH = (pageHeight - 2 * y) / sections.length;\n if (layout === \"row\") {\n sectionW = (pageWidth - 2 * x) / sections.length;\n sectionH = pageHeight - 2 * y;\n }\n await renderSection(\n doc,\n section,\n layout,\n offsetX,\n offsetY,\n sectionW,\n sectionH,\n );\n if (layout === \"row\") offsetX += sectionW;\n else offsetY += sectionH;\n }\n\n return doc;\n};\n\n// Helper to render a section\nconst renderSection = async (\n doc: jsPDFModule.jsPDF,\n section: SmeupSchSection,\n parentLayout: string,\n parentX: number,\n parentY: number,\n parentW: number,\n parentH: number,\n): Promise<void> => {\n const layout = section.layout || parentLayout;\n const title = section.components?.[0]?.title || \"\";\n const dim = section.dim ? parseFloat(section.dim) : undefined;\n let sectionW = parentW;\n let sectionH = parentH;\n if (dim) {\n if (layout === \"row\") sectionW = parentW * (dim / 100);\n else sectionH = parentH * (dim / 100);\n }\n // Draw title\n doc.text(title, parentX + 2, parentY + 7);\n // Draw component type (assume one component)\n if (section.components && section.components.length > 0) {\n //const compType = section.components[0].type;\n const data = section.components[0].data || ({} as SmeupDataTable);\n const options = section.components[0].options?.EXA?.[0];\n if (options == null) {\n throw new Error(\"Options is undefined or null for component\");\n }\n const image = await dataTableToChart(data as SmeupDataTable, \"line\", {\n Width: String((sectionW - 4) * 10),\n Height: String((sectionH - 20) * 10),\n ...options,\n });\n const base64Image = image.toString(\"base64\");\n doc.addImage(\n `data:image/jpg;base64,${base64Image}`,\n \"JPG\",\n parentX + 2,\n parentY + 15,\n sectionW - 4,\n sectionH - 20,\n undefined,\n );\n }\n // Draw child sections\n if (section.sections && section.sections.length > 0) {\n let offsetX = parentX;\n let offsetY = parentY + 20;\n const filteredSections = filterSections(section.sections);\n for (let i = 0; i < filteredSections.length; i++) {\n const sub = filteredSections[i];\n let subW = sectionW;\n let subH = sectionH;\n if (layout === \"row\") subW = sectionW / section.sections!.length;\n else subH = sectionH / section.sections!.length;\n await renderSection(doc, sub, layout, offsetX, offsetY, subW, subH);\n if (layout === \"row\") offsetX += subW;\n else offsetY += subH;\n }\n }\n};\n\nconst filterSections = (sections: SmeupSchSection[]): SmeupSchSection[] => {\n return sections.filter(section => {\n // Filter out sections that are empty or have no components\n if (\n section.components &&\n section.components.length > 0 &&\n section.components[0].type === Shapes.EXA\n ) {\n return true;\n }\n // Recursively filter child sections\n if (section.sections && section.sections.length > 0) {\n section.sections = filterSections(section.sections);\n return section.sections.length > 0;\n }\n return false;\n });\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import { SmeupDataTable } from "../types/data-structures/smeupDataTable.js";
2
+ import { SmeupSch } from "../types/data-structures/smeupSch.js";
3
+ import { WebupManagerData, GenericObject } from "../types/index.js";
4
+ export declare const schedaToPdfData: (sch: SmeupSch, webupManagerData: WebupManagerData) => Promise<Buffer>;
5
+ export declare const dataTableToPdfData: (component: {
6
+ smeupDataTable: SmeupDataTable;
7
+ props: GenericObject;
8
+ }, webupManagerData: WebupManagerData) => Promise<Buffer | Uint8Array>;
@@ -0,0 +1,44 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import { SupportedExportFormats, } from "../types/index.js";
3
+ import { convertToBuffer } from "../utils/commons-utility.js";
4
+ import { dataTableToExcelWorkbook } from "./excel/matrix-converter.js";
5
+ import { dataTableToPdfDoc } from "./pdf/matrix-converter.js";
6
+ import { schedaToPdfDoc } from "./pdf/sch-converter.js";
7
+ import { PDFDocument } from "pdf-lib";
8
+ import { createCoverPdf } from "./pdf/cover-renderer.js";
9
+ export const schedaToPdfData = async (sch, webupManagerData) => {
10
+ const doc = await schedaToPdfDoc(sch);
11
+ return Buffer.from(doc.output("arraybuffer"));
12
+ };
13
+ export const dataTableToPdfData = async (component, webupManagerData) => {
14
+ const workbook = dataTableToExcelWorkbook(component, SupportedExportFormats.XLSX, webupManagerData);
15
+ const worksheet = workbook.getWorksheet(1);
16
+ if (worksheet) {
17
+ const cover = createCoverPdf("AZIENDA SMEUP BSA SRL", "P.IVA/CD.FISCALE: 03474030289 - VIA ALBANO ZANELLA, 23 - 25030 ERBUSCO BS", "Esportazione dati");
18
+ const pdfDoc = await dataTableToPdfDoc(worksheet, webupManagerData);
19
+ const pdfBuffer = pdfDoc.output("arraybuffer");
20
+ return convertToBuffer(await appendPdfDocs([cover, pdfBuffer]));
21
+ }
22
+ else {
23
+ throw new Error("Worksheet not found in the workbook");
24
+ }
25
+ };
26
+ /**
27
+ * Unisce più PDF (in formato ArrayBuffer/Uint8Array/Buffer) in un unico PDF.
28
+ * @param pdfBuffers Array di buffer PDF (es. ottenuti da jsPDF.output("arraybuffer"))
29
+ * @returns Buffer del PDF unito
30
+ */
31
+ const appendPdfDocs = async (pdfBuffers) => {
32
+ if (!pdfBuffers.length)
33
+ throw new Error("No PDF buffers to append");
34
+ // Crea un nuovo documento PDF vuoto
35
+ const mergedPdf = await PDFDocument.create();
36
+ for (const pdfBytes of pdfBuffers) {
37
+ const srcPdf = await PDFDocument.load(pdfBytes);
38
+ const copiedPages = await mergedPdf.copyPages(srcPdf, srcPdf.getPageIndices());
39
+ copiedPages.forEach(page => mergedPdf.addPage(page));
40
+ }
41
+ const mergedBytes = await mergedPdf.save();
42
+ return mergedBytes;
43
+ };
44
+ //# sourceMappingURL=pdf-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf-converter.js","sourceRoot":"","sources":["../../src/converters/pdf-converter.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAKtD,OAAO,EAGL,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,GAAa,EACb,gBAAkC,EACjB,EAAE;IACnB,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,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IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;IAC3C,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\nimport { create } from \"domain\";\nimport { SmeupDataTable } from \"../types/data-structures/smeupDataTable.js\";\nimport { SmeupSch } from \"../types/data-structures/smeupSch.js\";\nimport {\n WebupManagerData,\n GenericObject,\n SupportedExportFormats,\n} from \"../types/index.js\";\nimport { convertToBuffer } from \"../utils/commons-utility.js\";\nimport { dataTableToExcelWorkbook } from \"./excel/matrix-converter.js\";\nimport { dataTableToPdfDoc } from \"./pdf/matrix-converter.js\";\nimport { schedaToPdfDoc } from \"./pdf/sch-converter.js\";\nimport { PDFDocument } from \"pdf-lib\";\nimport { createCoverPdf } from \"./pdf/cover-renderer.js\";\n\nexport const schedaToPdfData = async (\n sch: SmeupSch,\n webupManagerData: WebupManagerData,\n): Promise<Buffer> => {\n const doc = await schedaToPdfDoc(sch);\n return Buffer.from(doc.output(\"arraybuffer\"));\n};\n\nexport const dataTableToPdfData = async (\n component: {\n smeupDataTable: SmeupDataTable;\n props: GenericObject;\n },\n webupManagerData: WebupManagerData,\n): Promise<Buffer | Uint8Array> => {\n const workbook = dataTableToExcelWorkbook(\n component,\n SupportedExportFormats.XLSX,\n webupManagerData,\n );\n\n const worksheet = workbook.getWorksheet(1);\n if (worksheet) {\n const cover = createCoverPdf(\n \"AZIENDA SMEUP BSA SRL\",\n \"P.IVA/CD.FISCALE: 03474030289 - VIA ALBANO ZANELLA, 23 - 25030 ERBUSCO BS\",\n \"Esportazione dati\",\n );\n const pdfDoc = await dataTableToPdfDoc(worksheet, webupManagerData);\n const pdfBuffer = pdfDoc.output(\"arraybuffer\");\n return convertToBuffer(await appendPdfDocs([cover, pdfBuffer]));\n } else {\n throw new Error(\"Worksheet not found in the workbook\");\n }\n};\n\n/**\n * Unisce più PDF (in formato ArrayBuffer/Uint8Array/Buffer) in un unico PDF.\n * @param pdfBuffers Array di buffer PDF (es. ottenuti da jsPDF.output(\"arraybuffer\"))\n * @returns Buffer del PDF unito\n */\nconst appendPdfDocs = async (\n pdfBuffers: (Uint8Array | ArrayBuffer | Buffer)[],\n): Promise<Uint8Array> => {\n if (!pdfBuffers.length) throw new Error(\"No PDF buffers to append\");\n\n // Crea un nuovo documento PDF vuoto\n const mergedPdf = await PDFDocument.create();\n\n for (const pdfBytes of pdfBuffers) {\n const srcPdf = await PDFDocument.load(pdfBytes);\n const copiedPages = await mergedPdf.copyPages(\n srcPdf,\n srcPdf.getPageIndices(),\n );\n copiedPages.forEach(page => mergedPdf.addPage(page));\n }\n\n const mergedBytes = await mergedPdf.save();\n return mergedBytes;\n};\n"]}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
- export { dataTableToExcelData, dataTreeToExcelData, } from "./src/excel/excel-generator.js";
2
- export type { WebupManagerData, GenericObject } from "./src/types/index.js";
3
- export { SupportedExportFormats } from "./src/types/index.js";
4
- export type { SmeupDataTable, SmeupDataTree } from "@sme.up/kokos-sdk-node";
1
+ export { dataTableToExcelData, dataTreeToExcelData, } from "./converters/excel-converter.js";
2
+ export { schedaToPdfData, dataTableToPdfData, } from "./converters/pdf-converter.js";
3
+ export { dataTableToChart } from "./converters/images/charts-generator.js";
4
+ export type { WebupManagerData, GenericObject } from "./types/index.js";
5
+ export { SupportedExportFormats } from "./types/index.js";
6
+ export type { SmeupDataTable } from "./types/data-structures/smeupDataTable.js";
7
+ export type { SmeupDataTree } from "./types/data-structures/smeupDataTree.js";
5
8
  export type ColumnGroup = {
6
9
  column: string;
7
10
  visible: boolean;
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  // Public API exports
2
- export { dataTableToExcelData, dataTreeToExcelData, } from "./src/excel/excel-generator.js";
3
- export { SupportedExportFormats } from "./src/types/index.js";
2
+ export { dataTableToExcelData, dataTreeToExcelData, } from "./converters/excel-converter.js";
3
+ export { schedaToPdfData, dataTableToPdfData, } from "./converters/pdf-converter.js";
4
+ export { dataTableToChart } from "./converters/images/charts-generator.js";
5
+ export { SupportedExportFormats } from "./types/index.js";
4
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,gCAAgC,CAAC;AAKxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["// Public API exports\nexport {\n dataTableToExcelData,\n dataTreeToExcelData,\n} from \"./src/excel/excel-generator.js\";\n\n// Export types that users might need\nexport type { WebupManagerData, GenericObject } from \"./src/types/index.js\";\n\nexport { SupportedExportFormats } from \"./src/types/index.js\";\n\n// Re-export useful types from kokos-sdk-node if needed\nexport type { SmeupDataTable, SmeupDataTree } from \"@sme.up/kokos-sdk-node\";\n\nexport type ColumnGroup = {\n column: string;\n visible: boolean;\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,eAAe,EACf,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAG3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["// Public API exports\nexport {\n dataTableToExcelData,\n dataTreeToExcelData,\n} from \"./converters/excel-converter.js\";\n\nexport {\n schedaToPdfData,\n dataTableToPdfData,\n} from \"./converters/pdf-converter.js\";\n\nexport { dataTableToChart } from \"./converters/images/charts-generator.js\";\n// Export types that users might need\nexport type { WebupManagerData, GenericObject } from \"./types/index.js\";\nexport { SupportedExportFormats } from \"./types/index.js\";\nexport type { SmeupDataTable } from \"./types/data-structures/smeupDataTable.js\";\nexport type { SmeupDataTree } from \"./types/data-structures/smeupDataTree.js\";\n\nexport type ColumnGroup = {\n column: string;\n visible: boolean;\n};\n"]}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Supported shapes.
3
+ */
4
+ export declare enum Shapes {
5
+ ACC = "ACC",
6
+ ACT = "ACT",
7
+ ATM = "ATM",
8
+ BOX = "BOX",
9
+ BTN = "BTN",
10
+ CAL = "CAL",
11
+ CHA = "CHA",// = EXA
12
+ DFT = "DFT",
13
+ DYN = "DYN",
14
+ DSH = "DSH",
15
+ EML = "EML",
16
+ EXA = "EXA",// = CHA
17
+ EXB = "EXB",// = MAT
18
+ EXD = "EXD",// = SCH
19
+ EXU = "EXU",
20
+ FBK = "FBK",
21
+ FLD = "FLD",
22
+ FOR = "FOR",
23
+ GNT = "GNT",
24
+ HTM = "HTM",
25
+ IML = "IML",
26
+ IMG = "IMG",
27
+ INT = "INT",
28
+ INP = "INP",
29
+ JSO = "JSO",
30
+ LAB = "LAB",
31
+ MAT = "MAT",// = EXB
32
+ PLN = "PLN",
33
+ PDF = "PDF",
34
+ SCH = "SCH",// = EXD
35
+ SPL = "SPL",
36
+ TED = "TED",
37
+ TRE = "TRE",
38
+ TXT = "TXT",
39
+ CND = "CND",
40
+ UNK = "UNK",
41
+ OGN = "OGN"
42
+ }
43
+ /**
44
+ * ToolbarState Info.
45
+ */
46
+ export declare enum ToolbarState {
47
+ EXPANDED = "Expanded",
48
+ COLLAPSED = "Collapsed",
49
+ INVISIBLE = "Invisible"
50
+ }
51
+ export interface ComponentOptions extends Record<string, string> {
52
+ Name: string;
53
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Supported shapes.
3
+ */
4
+ export var Shapes;
5
+ (function (Shapes) {
6
+ Shapes["ACC"] = "ACC";
7
+ Shapes["ACT"] = "ACT";
8
+ Shapes["ATM"] = "ATM";
9
+ Shapes["BOX"] = "BOX";
10
+ Shapes["BTN"] = "BTN";
11
+ Shapes["CAL"] = "CAL";
12
+ Shapes["CHA"] = "CHA";
13
+ Shapes["DFT"] = "DFT";
14
+ Shapes["DYN"] = "DYN";
15
+ Shapes["DSH"] = "DSH";
16
+ Shapes["EML"] = "EML";
17
+ Shapes["EXA"] = "EXA";
18
+ Shapes["EXB"] = "EXB";
19
+ Shapes["EXD"] = "EXD";
20
+ Shapes["EXU"] = "EXU";
21
+ Shapes["FBK"] = "FBK";
22
+ Shapes["FLD"] = "FLD";
23
+ Shapes["FOR"] = "FOR";
24
+ Shapes["GNT"] = "GNT";
25
+ Shapes["HTM"] = "HTM";
26
+ Shapes["IML"] = "IML";
27
+ Shapes["IMG"] = "IMG";
28
+ Shapes["INT"] = "INT";
29
+ Shapes["INP"] = "INP";
30
+ Shapes["JSO"] = "JSO";
31
+ Shapes["LAB"] = "LAB";
32
+ Shapes["MAT"] = "MAT";
33
+ Shapes["PLN"] = "PLN";
34
+ Shapes["PDF"] = "PDF";
35
+ Shapes["SCH"] = "SCH";
36
+ Shapes["SPL"] = "SPL";
37
+ Shapes["TED"] = "TED";
38
+ Shapes["TRE"] = "TRE";
39
+ Shapes["TXT"] = "TXT";
40
+ Shapes["CND"] = "CND";
41
+ Shapes["UNK"] = "UNK";
42
+ Shapes["OGN"] = "OGN";
43
+ })(Shapes || (Shapes = {}));
44
+ /**
45
+ * ToolbarState Info.
46
+ */
47
+ export var ToolbarState;
48
+ (function (ToolbarState) {
49
+ ToolbarState["EXPANDED"] = "Expanded";
50
+ ToolbarState["COLLAPSED"] = "Collapsed";
51
+ ToolbarState["INVISIBLE"] = "Invisible";
52
+ })(ToolbarState || (ToolbarState = {}));
53
+ //# sourceMappingURL=component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/types/component.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,MAsCX;AAtCD,WAAY,MAAM;IAChB,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;IACX,qBAAW,CAAA;AACb,CAAC,EAtCW,MAAM,KAAN,MAAM,QAsCjB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,uCAAuB,CAAA;IACvB,uCAAuB,CAAA;AACzB,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB","sourcesContent":["/**\n * Supported shapes.\n */\nexport enum Shapes {\n ACC = \"ACC\",\n ACT = \"ACT\",\n ATM = \"ATM\",\n BOX = \"BOX\",\n BTN = \"BTN\",\n CAL = \"CAL\",\n CHA = \"CHA\", // = EXA\n DFT = \"DFT\",\n DYN = \"DYN\",\n DSH = \"DSH\",\n EML = \"EML\",\n EXA = \"EXA\", // = CHA\n EXB = \"EXB\", // = MAT\n EXD = \"EXD\", // = SCH\n EXU = \"EXU\",\n FBK = \"FBK\",\n FLD = \"FLD\",\n FOR = \"FOR\",\n GNT = \"GNT\",\n HTM = \"HTM\",\n IML = \"IML\",\n IMG = \"IMG\",\n INT = \"INT\",\n INP = \"INP\",\n JSO = \"JSO\",\n LAB = \"LAB\",\n MAT = \"MAT\", // = EXB\n PLN = \"PLN\",\n PDF = \"PDF\",\n SCH = \"SCH\", // = EXD\n SPL = \"SPL\",\n TED = \"TED\",\n TRE = \"TRE\",\n TXT = \"TXT\",\n CND = \"CND\",\n UNK = \"UNK\",\n OGN = \"OGN\",\n}\n\n/**\n * ToolbarState Info.\n */\nexport enum ToolbarState {\n EXPANDED = \"Expanded\",\n COLLAPSED = \"Collapsed\",\n INVISIBLE = \"Invisible\",\n}\n\nexport interface ComponentOptions extends Record<string, string> {\n Name: string;\n}\n"]}
@@ -0,0 +1,215 @@
1
+ import { ComponentOptions, Shapes } from "../component.js";
2
+ import { Fun } from "../general.js";
3
+ import { SmeupDataCell } from "./smeupDataTable.js";
4
+ import { SmeupDataNode } from "./smeupDataTree.js";
5
+ /**
6
+ * Smeup data structure
7
+ */
8
+ export interface SmeupDataStructure {
9
+ type: SmeupDataStructureType;
10
+ messages?: SmeupMessage[];
11
+ variables?: SmeupVariable[];
12
+ buttons?: SmeupDataNode[];
13
+ actions?: SmeupAction[];
14
+ setup?: SmeupSetup;
15
+ debugInfo?: DebugInfo;
16
+ }
17
+ /**
18
+ * Api version
19
+ */
20
+ export declare enum ApiVersion {
21
+ V2 = 0
22
+ }
23
+ /**
24
+ * SmeupDataStructure types
25
+ */
26
+ export declare enum SmeupDataStructureType {
27
+ /** Smeup feedback (FBK) */
28
+ SmeupFeedback = "SmeupFeedback",
29
+ /** SmeupDataTable (DTA) */
30
+ SmeupDataTable = "SmeupDataTable",
31
+ /** SmeupDataTree (DTR) */
32
+ SmeupDataTree = "SmeupDataTree",
33
+ /** SmeupSch */
34
+ SmeupScheda = "SmeupSch"
35
+ }
36
+ export declare function getSmeupDataStructureType(fun: Fun, version: ApiVersion): SmeupDataStructureType;
37
+ /**
38
+ * Smeup data structure
39
+ */
40
+ export interface SmeupFeedback extends SmeupDataStructure {
41
+ type: SmeupDataStructureType.SmeupFeedback;
42
+ }
43
+ /**
44
+ * SmeupMessage type
45
+ */
46
+ export interface SmeupMessage {
47
+ gravity: SmeupMessageGravity;
48
+ message: string;
49
+ mode: string;
50
+ }
51
+ /**
52
+ * SmeupMessage Gravity
53
+ */
54
+ export declare const SMEUP_MESSAGE_GRAVITY: {
55
+ readonly INFO: "INFO";
56
+ readonly ERROR: "ERROR";
57
+ readonly WARNING: "WARNING";
58
+ readonly UNAUTHORIZED: "UNAUTHORIZED";
59
+ };
60
+ export type SmeupMessageGravity = (typeof SMEUP_MESSAGE_GRAVITY)[keyof typeof SMEUP_MESSAGE_GRAVITY];
61
+ /**
62
+ * SmeupMessage Mode
63
+ */
64
+ export declare const SMEUP_MESSAGE_MODE: {
65
+ readonly PM: "PM";
66
+ readonly PN: "PN";
67
+ readonly TN: "TN";
68
+ };
69
+ /**
70
+ * SmeupVariable
71
+ */
72
+ export interface SmeupVariable {
73
+ name: string;
74
+ value: string;
75
+ type?: SmeupVariableType;
76
+ }
77
+ /**
78
+ * SmeupVariableType
79
+ */
80
+ export declare const SMEUP_VARIABLE_TYPE: {
81
+ readonly SEC: "sec";
82
+ readonly SCH: "sch";
83
+ readonly SSC: "ssc";
84
+ readonly LOO: "loo";
85
+ };
86
+ export type SmeupVariableType = (typeof SMEUP_VARIABLE_TYPE)[keyof typeof SMEUP_VARIABLE_TYPE];
87
+ /**
88
+ * SmeupAction
89
+ */
90
+ export interface SmeupAction {
91
+ exec?: string;
92
+ parameter?: string;
93
+ type?: SmeupActionType;
94
+ }
95
+ /**
96
+ * SmeupActionType
97
+ */
98
+ export declare const SMEUP_ACTION_TYPE: {
99
+ readonly CLOSE: "CLOSE";
100
+ readonly CLOSEW: "CLOSEW";
101
+ readonly DYNAMIC: "DYNAMIC";
102
+ readonly DINAMIC: "DINAMIC";
103
+ readonly EXECUTE: "EXECUTE";
104
+ readonly LOAD: "LOAD";
105
+ readonly RELOAD: "RELOAD";
106
+ readonly UPDATE: "UPDATE";
107
+ readonly EXIT: "EXIT";
108
+ readonly REFRESH: "REFRESH";
109
+ readonly HARDREFRESH: "HARDREFRESH";
110
+ readonly POPUP: "POPUP";
111
+ readonly RETURNVALUE: "RETURNVALUE";
112
+ };
113
+ type SmeupActionType = (typeof SMEUP_ACTION_TYPE)[keyof typeof SMEUP_ACTION_TYPE];
114
+ /**
115
+ * Smeup Data Cell Input Settings Keys
116
+ */
117
+ export declare const SMEUP_DATA_CELL_INPUT_SETTINGS_KEYS: {
118
+ readonly MANDATORY: {
119
+ readonly key: "mandatory";
120
+ readonly type: "boolean";
121
+ };
122
+ readonly CHECK_VALUE_ON_EXIT: {
123
+ readonly key: "checkValueOnExit";
124
+ readonly type: "boolean";
125
+ };
126
+ readonly CHECK_OBJECT: {
127
+ readonly key: "checkObject";
128
+ readonly type: "boolean";
129
+ };
130
+ readonly FORCE_UPPERCASE: {
131
+ readonly key: "forceUppercase";
132
+ readonly type: "boolean";
133
+ };
134
+ };
135
+ export type SmeupDataCellInputSettingsKeys = keyof typeof SMEUP_DATA_CELL_INPUT_SETTINGS_KEYS;
136
+ export type SmeupDataCellInputSettingsValue = (typeof SMEUP_DATA_CELL_INPUT_SETTINGS_KEYS)[SmeupDataCellInputSettingsKeys];
137
+ export interface DebugInfo {
138
+ executionTime_ms: number;
139
+ initialTimestamp: string;
140
+ finalTimestamp: string;
141
+ runtime: {
142
+ [index: string]: string;
143
+ };
144
+ }
145
+ /**
146
+ * LAYOUT
147
+ * Represent the layout of the fields in a form and the adjuntive informations
148
+ */
149
+ export interface SmeupLayout {
150
+ horizontal?: boolean;
151
+ absolute?: boolean;
152
+ sections?: SmeupLayoutSection[];
153
+ sectionsType?: SmeupLayoutSectionType;
154
+ }
155
+ /**
156
+ * Represent a layout section
157
+ */
158
+ export interface SmeupLayoutSection {
159
+ id?: string;
160
+ content?: SmeupLayoutField[];
161
+ sections?: SmeupLayoutSection[];
162
+ dim?: string;
163
+ collapsible?: boolean;
164
+ horizontal?: boolean;
165
+ icon?: string;
166
+ sectionsType?: SmeupLayoutSectionType;
167
+ styleName?: string;
168
+ gridCols?: number;
169
+ gridRows?: number;
170
+ gap?: number;
171
+ title?: string;
172
+ absoluteColumn?: number;
173
+ absoluteWidth?: number;
174
+ absoluteRow?: number;
175
+ absoluteHeight?: number;
176
+ columns?: string;
177
+ }
178
+ export declare enum SmeupLayoutSectionType {
179
+ TAB = "tab"
180
+ }
181
+ /**
182
+ * Represent the presentation information of a field in a form
183
+ */
184
+ export interface SmeupLayoutField extends SmeupDataCell {
185
+ id: string;
186
+ title?: string;
187
+ visible?: boolean;
188
+ colSpan?: number;
189
+ colStart?: number;
190
+ colEnd?: number;
191
+ rowSpan?: number;
192
+ rowStart?: number;
193
+ rowEnd?: number;
194
+ absoluteColumn?: number;
195
+ absoluteRow?: number;
196
+ absoluteLength?: number;
197
+ absoluteHeight?: number;
198
+ useAs?: string;
199
+ }
200
+ export type SmeupSetupBase<T extends ComponentOptions = ComponentOptions> = {
201
+ [key in Shapes]?: T[];
202
+ };
203
+ export interface SmeupSetup<T extends ComponentOptions = ComponentOptions> {
204
+ title?: string;
205
+ options?: SmeupSetupBase<T>;
206
+ userSetups?: boolean;
207
+ context?: string;
208
+ commands?: Array<SmeupDataNode>;
209
+ operations?: {
210
+ insert?: boolean;
211
+ delete?: boolean;
212
+ update?: boolean;
213
+ };
214
+ }
215
+ export {};
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Api version
3
+ */
4
+ export var ApiVersion;
5
+ (function (ApiVersion) {
6
+ ApiVersion[ApiVersion["V2"] = 0] = "V2";
7
+ })(ApiVersion || (ApiVersion = {}));
8
+ /**
9
+ * SmeupDataStructure types
10
+ */
11
+ export var SmeupDataStructureType;
12
+ (function (SmeupDataStructureType) {
13
+ /** Smeup feedback (FBK) */
14
+ SmeupDataStructureType["SmeupFeedback"] = "SmeupFeedback";
15
+ /** SmeupDataTable (DTA) */
16
+ SmeupDataStructureType["SmeupDataTable"] = "SmeupDataTable";
17
+ /** SmeupDataTree (DTR) */
18
+ SmeupDataStructureType["SmeupDataTree"] = "SmeupDataTree";
19
+ /** SmeupSch */
20
+ SmeupDataStructureType["SmeupScheda"] = "SmeupSch";
21
+ })(SmeupDataStructureType || (SmeupDataStructureType = {}));
22
+ export function getSmeupDataStructureType(fun, version) {
23
+ switch (fun.component) {
24
+ case "TRE":
25
+ case "HTM":
26
+ case "CDE":
27
+ case "EDT":
28
+ return SmeupDataStructureType.SmeupDataTree;
29
+ case "EXU":
30
+ case "INP":
31
+ case "EXB":
32
+ case "EXC":
33
+ return SmeupDataStructureType.SmeupDataTable;
34
+ case "FBK":
35
+ return SmeupDataStructureType.SmeupFeedback;
36
+ case "SCH":
37
+ return SmeupDataStructureType.SmeupScheda;
38
+ default:
39
+ throw new Error(`${fun.component} not correspond to a valid SmeupDataStructure type`);
40
+ }
41
+ }
42
+ /**
43
+ * SmeupMessage Gravity
44
+ */
45
+ export const SMEUP_MESSAGE_GRAVITY = {
46
+ INFO: "INFO",
47
+ ERROR: "ERROR",
48
+ WARNING: "WARNING",
49
+ UNAUTHORIZED: "UNAUTHORIZED",
50
+ };
51
+ /**
52
+ * SmeupMessage Mode
53
+ */
54
+ export const SMEUP_MESSAGE_MODE = {
55
+ PM: "PM",
56
+ PN: "PN",
57
+ TN: "TN",
58
+ };
59
+ /**
60
+ * SmeupVariableType
61
+ */
62
+ export const SMEUP_VARIABLE_TYPE = {
63
+ SEC: "sec",
64
+ SCH: "sch",
65
+ SSC: "ssc",
66
+ LOO: "loo",
67
+ };
68
+ /**
69
+ * SmeupActionType
70
+ */
71
+ export const SMEUP_ACTION_TYPE = {
72
+ CLOSE: "CLOSE",
73
+ CLOSEW: "CLOSEW",
74
+ DYNAMIC: "DYNAMIC",
75
+ DINAMIC: "DINAMIC",
76
+ EXECUTE: "EXECUTE",
77
+ LOAD: "LOAD",
78
+ RELOAD: "RELOAD",
79
+ UPDATE: "UPDATE",
80
+ EXIT: "EXIT",
81
+ REFRESH: "REFRESH",
82
+ HARDREFRESH: "HARDREFRESH",
83
+ POPUP: "POPUP",
84
+ RETURNVALUE: "RETURNVALUE",
85
+ };
86
+ /**
87
+ * Smeup Data Cell Input Settings Keys
88
+ */
89
+ export const SMEUP_DATA_CELL_INPUT_SETTINGS_KEYS = {
90
+ MANDATORY: { key: "mandatory", type: "boolean" },
91
+ CHECK_VALUE_ON_EXIT: { key: "checkValueOnExit", type: "boolean" },
92
+ CHECK_OBJECT: { key: "checkObject", type: "boolean" },
93
+ FORCE_UPPERCASE: { key: "forceUppercase", type: "boolean" },
94
+ };
95
+ export var SmeupLayoutSectionType;
96
+ (function (SmeupLayoutSectionType) {
97
+ SmeupLayoutSectionType["TAB"] = "tab";
98
+ })(SmeupLayoutSectionType || (SmeupLayoutSectionType = {}));
99
+ //# sourceMappingURL=smeupDataStructure.js.map