makeapps-transformer 1.0.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 (174) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.js +4 -0
  4. package/dist/lib-public/FA3-generator.js +50 -0
  5. package/dist/lib-public/enums/invoice.enums.js +9 -0
  6. package/dist/lib-public/generate-invoice.js +21 -0
  7. package/dist/lib-public/generators/FA2/Adnotacje.js +174 -0
  8. package/dist/lib-public/generators/FA2/Adres.js +23 -0
  9. package/dist/lib-public/generators/FA2/DodatkoweInformacje.js +69 -0
  10. package/dist/lib-public/generators/FA2/Platnosc.js +91 -0
  11. package/dist/lib-public/generators/FA2/Podmiot1.js +32 -0
  12. package/dist/lib-public/generators/FA2/Podmiot1Podmiot1K.js +63 -0
  13. package/dist/lib-public/generators/FA2/Podmiot2.js +28 -0
  14. package/dist/lib-public/generators/FA2/Podmiot2Podmiot2k.js +62 -0
  15. package/dist/lib-public/generators/FA2/Podmiot3.js +37 -0
  16. package/dist/lib-public/generators/FA2/Podmiot3Podmiot2k.js +57 -0
  17. package/dist/lib-public/generators/FA2/PodmiotAdres.js +14 -0
  18. package/dist/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.js +10 -0
  19. package/dist/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.js +34 -0
  20. package/dist/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.js +44 -0
  21. package/dist/lib-public/generators/FA2/PodmiotDaneKontaktowe.js +13 -0
  22. package/dist/lib-public/generators/FA2/PodmiotUpowazniony.js +29 -0
  23. package/dist/lib-public/generators/FA2/PodmiotUpowaznionyDaneKontaktowe.js +28 -0
  24. package/dist/lib-public/generators/FA2/Podmioty.js +92 -0
  25. package/dist/lib-public/generators/FA2/PodsumowanieStawekPodatkuVat.js +260 -0
  26. package/dist/lib-public/generators/FA2/Przewoznik.js +17 -0
  27. package/dist/lib-public/generators/FA2/Rabat.js +57 -0
  28. package/dist/lib-public/generators/FA2/RachunekBankowy.js +54 -0
  29. package/dist/lib-public/generators/FA2/Szczegoly.js +138 -0
  30. package/dist/lib-public/generators/FA2/Transport.js +78 -0
  31. package/dist/lib-public/generators/FA2/WarunkiTransakcji.js +68 -0
  32. package/dist/lib-public/generators/FA2/Wiersze.js +140 -0
  33. package/dist/lib-public/generators/FA2/Zamowienie.js +148 -0
  34. package/dist/lib-public/generators/FA3/Adnotacje.js +185 -0
  35. package/dist/lib-public/generators/FA3/Adres.js +23 -0
  36. package/dist/lib-public/generators/FA3/DodatkoweInformacje.js +69 -0
  37. package/dist/lib-public/generators/FA3/Platnosc.js +105 -0
  38. package/dist/lib-public/generators/FA3/Podmiot1.js +32 -0
  39. package/dist/lib-public/generators/FA3/Podmiot1Podmiot1K.js +67 -0
  40. package/dist/lib-public/generators/FA3/Podmiot2.js +34 -0
  41. package/dist/lib-public/generators/FA3/Podmiot2Podmiot2k.js +49 -0
  42. package/dist/lib-public/generators/FA3/Podmiot3.js +37 -0
  43. package/dist/lib-public/generators/FA3/Podmiot3Podmiot2k.js +57 -0
  44. package/dist/lib-public/generators/FA3/PodmiotAdres.js +14 -0
  45. package/dist/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.js +10 -0
  46. package/dist/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.js +34 -0
  47. package/dist/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.js +44 -0
  48. package/dist/lib-public/generators/FA3/PodmiotDaneKontaktowe.js +13 -0
  49. package/dist/lib-public/generators/FA3/PodmiotUpowazniony.js +29 -0
  50. package/dist/lib-public/generators/FA3/PodmiotUpowaznionyDaneKontaktowe.js +28 -0
  51. package/dist/lib-public/generators/FA3/Podmioty.js +92 -0
  52. package/dist/lib-public/generators/FA3/PodsumowanieStawekPodatkuVat.js +264 -0
  53. package/dist/lib-public/generators/FA3/Przewoznik.js +17 -0
  54. package/dist/lib-public/generators/FA3/Rabat.js +57 -0
  55. package/dist/lib-public/generators/FA3/RachunekBankowy.js +58 -0
  56. package/dist/lib-public/generators/FA3/Szczegoly.js +138 -0
  57. package/dist/lib-public/generators/FA3/Transport.js +78 -0
  58. package/dist/lib-public/generators/FA3/WarunkiTransakcji.js +68 -0
  59. package/dist/lib-public/generators/FA3/Wiersze.js +140 -0
  60. package/dist/lib-public/generators/FA3/Zamowienie.js +148 -0
  61. package/dist/lib-public/generators/common/DaneFaKorygowanej.js +74 -0
  62. package/dist/lib-public/generators/common/Naglowek.js +100 -0
  63. package/dist/lib-public/generators/common/Rozliczenie.js +120 -0
  64. package/dist/lib-public/generators/common/Stopka.js +113 -0
  65. package/dist/lib-public/generators/common/Wiersze.js +28 -0
  66. package/dist/lib-public/generators/common/Zalaczniki.js +182 -0
  67. package/dist/lib-public/index.js +5 -0
  68. package/dist/lib-public/types/common.types.js +2 -0
  69. package/dist/lib-public/types/fa1-additional-types.js +2 -0
  70. package/dist/lib-public/types/fa1.types.js +2 -0
  71. package/dist/lib-public/types/fa2-additional-types.js +2 -0
  72. package/dist/lib-public/types/fa2.types.js +2 -0
  73. package/dist/lib-public/types/fa2Podmiot3DaneIdentyfikacyjne.types.js +2 -0
  74. package/dist/lib-public/types/fa3.types.js +2 -0
  75. package/dist/lib-public/types/fa3Podmiot3DaneIdentyfikacyjne.types.js +2 -0
  76. package/dist/lib-public/types/tax-summary.types.js +2 -0
  77. package/dist/lib-public/types/upo-v4_2.types.js +2 -0
  78. package/dist/shared/PDF-functions.js +429 -0
  79. package/dist/shared/XML-parser.js +21 -0
  80. package/dist/shared/consts/const.js +390 -0
  81. package/dist/shared/enums/common.enum.js +48 -0
  82. package/dist/shared/enums/invoice.enums.js +13 -0
  83. package/dist/shared/generators/common/functions.js +95 -0
  84. package/dist/shared/types/additional-data.types.js +2 -0
  85. package/dist/shared/types/pdf-types.js +2 -0
  86. package/dist/shared/types/universal.types.js +2 -0
  87. package/package.json +21 -0
  88. package/src/index.d.ts +7 -0
  89. package/src/index.ts +2 -0
  90. package/src/lib-public/FA3-generator.ts +56 -0
  91. package/src/lib-public/enums/invoice.enums.ts +5 -0
  92. package/src/lib-public/generate-invoice.ts +32 -0
  93. package/src/lib-public/generators/FA2/Adnotacje.ts +206 -0
  94. package/src/lib-public/generators/FA2/Adres.ts +20 -0
  95. package/src/lib-public/generators/FA2/DodatkoweInformacje.ts +97 -0
  96. package/src/lib-public/generators/FA2/Platnosc.ts +131 -0
  97. package/src/lib-public/generators/FA2/Podmiot1.ts +40 -0
  98. package/src/lib-public/generators/FA2/Podmiot1Podmiot1K.ts +73 -0
  99. package/src/lib-public/generators/FA2/Podmiot2.ts +42 -0
  100. package/src/lib-public/generators/FA2/Podmiot2Podmiot2k.ts +74 -0
  101. package/src/lib-public/generators/FA2/Podmiot3.ts +50 -0
  102. package/src/lib-public/generators/FA2/Podmiot3Podmiot2k.ts +77 -0
  103. package/src/lib-public/generators/FA2/PodmiotAdres.ts +19 -0
  104. package/src/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.ts +10 -0
  105. package/src/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.ts +37 -0
  106. package/src/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.ts +44 -0
  107. package/src/lib-public/generators/FA2/PodmiotDaneKontaktowe.ts +12 -0
  108. package/src/lib-public/generators/FA2/PodmiotUpowazniony.ts +31 -0
  109. package/src/lib-public/generators/FA2/PodmiotUpowaznionyDaneKontaktowe.ts +34 -0
  110. package/src/lib-public/generators/FA2/Podmioty.ts +96 -0
  111. package/src/lib-public/generators/FA2/PodsumowanieStawekPodatkuVat.ts +294 -0
  112. package/src/lib-public/generators/FA2/Przewoznik.ts +21 -0
  113. package/src/lib-public/generators/FA2/Rabat.ts +47 -0
  114. package/src/lib-public/generators/FA2/RachunekBankowy.ts +60 -0
  115. package/src/lib-public/generators/FA2/Szczegoly.ts +187 -0
  116. package/src/lib-public/generators/FA2/Transport.ts +108 -0
  117. package/src/lib-public/generators/FA2/WarunkiTransakcji.ts +105 -0
  118. package/src/lib-public/generators/FA2/Wiersze.ts +126 -0
  119. package/src/lib-public/generators/FA2/Zamowienie.ts +144 -0
  120. package/src/lib-public/generators/FA3/Adnotacje.ts +249 -0
  121. package/src/lib-public/generators/FA3/Adres.ts +20 -0
  122. package/src/lib-public/generators/FA3/DodatkoweInformacje.ts +92 -0
  123. package/src/lib-public/generators/FA3/Platnosc.ts +144 -0
  124. package/src/lib-public/generators/FA3/Podmiot1.ts +40 -0
  125. package/src/lib-public/generators/FA3/Podmiot1Podmiot1K.ts +78 -0
  126. package/src/lib-public/generators/FA3/Podmiot2.ts +55 -0
  127. package/src/lib-public/generators/FA3/Podmiot2Podmiot2k.ts +59 -0
  128. package/src/lib-public/generators/FA3/Podmiot3.ts +50 -0
  129. package/src/lib-public/generators/FA3/Podmiot3Podmiot2k.ts +78 -0
  130. package/src/lib-public/generators/FA3/PodmiotAdres.ts +19 -0
  131. package/src/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.ts +10 -0
  132. package/src/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.ts +37 -0
  133. package/src/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.ts +44 -0
  134. package/src/lib-public/generators/FA3/PodmiotDaneKontaktowe.ts +12 -0
  135. package/src/lib-public/generators/FA3/PodmiotUpowazniony.ts +31 -0
  136. package/src/lib-public/generators/FA3/PodmiotUpowaznionyDaneKontaktowe.ts +34 -0
  137. package/src/lib-public/generators/FA3/Podmioty.ts +96 -0
  138. package/src/lib-public/generators/FA3/PodsumowanieStawekPodatkuVat.ts +298 -0
  139. package/src/lib-public/generators/FA3/Przewoznik.ts +24 -0
  140. package/src/lib-public/generators/FA3/Rabat.ts +45 -0
  141. package/src/lib-public/generators/FA3/RachunekBankowy.ts +60 -0
  142. package/src/lib-public/generators/FA3/Szczegoly.ts +184 -0
  143. package/src/lib-public/generators/FA3/Transport.ts +108 -0
  144. package/src/lib-public/generators/FA3/WarunkiTransakcji.ts +100 -0
  145. package/src/lib-public/generators/FA3/Wiersze.ts +126 -0
  146. package/src/lib-public/generators/FA3/Zamowienie.ts +143 -0
  147. package/src/lib-public/generators/common/DaneFaKorygowanej.ts +91 -0
  148. package/src/lib-public/generators/common/Naglowek.ts +84 -0
  149. package/src/lib-public/generators/common/Rozliczenie.ts +119 -0
  150. package/src/lib-public/generators/common/Stopka.ts +161 -0
  151. package/src/lib-public/generators/common/Wiersze.ts +32 -0
  152. package/src/lib-public/generators/common/Zalaczniki.ts +232 -0
  153. package/src/lib-public/index.ts +3 -0
  154. package/src/lib-public/types/common.types.ts +29 -0
  155. package/src/lib-public/types/fa1-additional-types.ts +26 -0
  156. package/src/lib-public/types/fa1.types.ts +299 -0
  157. package/src/lib-public/types/fa2-additional-types.ts +30 -0
  158. package/src/lib-public/types/fa2.types.ts +307 -0
  159. package/src/lib-public/types/fa2Podmiot3DaneIdentyfikacyjne.types.ts +12 -0
  160. package/src/lib-public/types/fa3.types.ts +384 -0
  161. package/src/lib-public/types/fa3Podmiot3DaneIdentyfikacyjne.types.ts +12 -0
  162. package/src/lib-public/types/tax-summary.types.ts +8 -0
  163. package/src/lib-public/types/upo-v4_2.types.ts +68 -0
  164. package/src/shared/PDF-functions.ts +466 -0
  165. package/src/shared/XML-parser.ts +42 -0
  166. package/src/shared/consts/const.ts +406 -0
  167. package/src/shared/enums/common.enum.ts +45 -0
  168. package/src/shared/enums/invoice.enums.ts +9 -0
  169. package/src/shared/generators/common/functions.ts +101 -0
  170. package/src/shared/types/additional-data.types.ts +15 -0
  171. package/src/shared/types/pdf-types.ts +58 -0
  172. package/src/shared/types/universal.types.ts +16 -0
  173. package/transformer.code-workspace +45 -0
  174. package/tsconfig.json +16 -0
@@ -0,0 +1,429 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.formatText = formatText;
37
+ exports.generateTable = generateTable;
38
+ exports.hasValue = hasValue;
39
+ exports.getValue = getValue;
40
+ exports.getNumber = getNumber;
41
+ exports.getNumberRounded = getNumberRounded;
42
+ exports.createLabelTextArray = createLabelTextArray;
43
+ exports.createLabelText = createLabelText;
44
+ exports.createSection = createSection;
45
+ exports.createHeader = createHeader;
46
+ exports.createSubHeader = createSubHeader;
47
+ exports.generateStyle = generateStyle;
48
+ exports.getTable = getTable;
49
+ exports.getRowTable = getRowTable;
50
+ exports.hasColumnsValue = hasColumnsValue;
51
+ exports.getDifferentColumnsValue = getDifferentColumnsValue;
52
+ exports.getContentTable = getContentTable;
53
+ exports.generateTwoColumns = generateTwoColumns;
54
+ exports.generateQRCode = generateQRCode;
55
+ exports.verticalSpacing = verticalSpacing;
56
+ exports.getKraj = getKraj;
57
+ exports.generateLine = generateLine;
58
+ const const_1 = require("./consts/const");
59
+ const functions_1 = require("./generators/common/functions");
60
+ const common_enum_1 = __importStar(require("./enums/common.enum"));
61
+ function formatText(value, format = null, options = {}, currency = '') {
62
+ if (!value) {
63
+ return '';
64
+ }
65
+ const result = { text: value.toString() };
66
+ Object.assign(result, options);
67
+ if (format) {
68
+ result.style = format;
69
+ if (!Array.isArray(format)) {
70
+ formatValue(format, result, value, currency);
71
+ }
72
+ else {
73
+ format.forEach((item) => {
74
+ formatValue(item, result, value, currency);
75
+ });
76
+ }
77
+ }
78
+ return result;
79
+ }
80
+ function generateTable(array, keys) {
81
+ var _a;
82
+ const faRows = getTable(array);
83
+ const headers = Object.entries(keys).map(([key, value]) => {
84
+ return {
85
+ name: key,
86
+ title: value,
87
+ format: common_enum_1.default.Default,
88
+ };
89
+ });
90
+ const table = getContentTable(headers, faRows, '*');
91
+ return (_a = table.content) !== null && _a !== void 0 ? _a : [];
92
+ }
93
+ function formatValue(item, result, value, currency = '') {
94
+ switch (item) {
95
+ case common_enum_1.default.Currency:
96
+ result.text = isNaN(Number(value)) ? value : `${Number(value).toFixed(2)} ${currency}`;
97
+ result.alignment = common_enum_1.Position.RIGHT;
98
+ break;
99
+ case common_enum_1.default.CurrencyAbs:
100
+ result.text = isNaN(Number(value))
101
+ ? value
102
+ : `${Math.abs(Number(value)).toFixed(2)} ${currency}`;
103
+ result.alignment = common_enum_1.Position.RIGHT;
104
+ break;
105
+ case common_enum_1.default.CurrencyGreater:
106
+ result.text = isNaN(Number(value)) ? value : `${Number(value).toFixed(2)} ${currency}`;
107
+ result.fontSize = 10;
108
+ break;
109
+ case common_enum_1.default.Currency6:
110
+ result.text = isNaN(Number(value)) ? value : `${Number(value).toFixed(6)} ${currency}`;
111
+ result.alignment = common_enum_1.Position.RIGHT;
112
+ break;
113
+ case common_enum_1.default.DateTime:
114
+ result.text = (0, functions_1.formatDateTime)(value, false, true);
115
+ break;
116
+ case common_enum_1.default.Date:
117
+ result.text = (0, functions_1.formatDateTime)(value, false, true);
118
+ break;
119
+ case common_enum_1.default.FormOfPayment:
120
+ result.text = (0, functions_1.getFormaPlatnosciString)({ _text: value });
121
+ break;
122
+ case common_enum_1.default.Boolean:
123
+ result.text = value === '1' ? common_enum_1.Answer.TRUE : common_enum_1.Answer.FALSE;
124
+ break;
125
+ case common_enum_1.default.Percentage:
126
+ result.text = `${value}%`;
127
+ break;
128
+ }
129
+ }
130
+ function hasValue(value) {
131
+ return (!!((typeof value !== 'object' && value) || (typeof value === 'object' && value._text)) || value === 0);
132
+ }
133
+ function getValue(value) {
134
+ if (typeof value === 'object') {
135
+ return value._text;
136
+ }
137
+ return value;
138
+ }
139
+ function getNumber(value) {
140
+ const text = getValue(value);
141
+ if (!text) {
142
+ return 0;
143
+ }
144
+ if (typeof text === 'number') {
145
+ return text;
146
+ }
147
+ return parseFloat(text.toString());
148
+ }
149
+ function getNumberRounded(value) {
150
+ const number = getNumber(value);
151
+ return Math.round(number * 100) / 100;
152
+ }
153
+ function createLabelTextArray(data) {
154
+ return [
155
+ {
156
+ text: data.map((textEl) => { var _a, _b; return formatText((_a = getValue(textEl.value)) !== null && _a !== void 0 ? _a : '', (_b = textEl.formatTyp) !== null && _b !== void 0 ? _b : common_enum_1.default.Label, {}, textEl.currency); }),
157
+ },
158
+ ];
159
+ }
160
+ function createLabelText(label, value, formatTyp = common_enum_1.default.Value, style = {}) {
161
+ if (!value || (typeof value === 'object' && !value._text)) {
162
+ return [];
163
+ }
164
+ if (typeof value === 'object') {
165
+ return [
166
+ {
167
+ text: [formatText(label, common_enum_1.default.Label), formatText(value._text, formatTyp)],
168
+ ...style,
169
+ },
170
+ ];
171
+ }
172
+ return [
173
+ {
174
+ text: [formatText(label, common_enum_1.default.Label), formatText(value, formatTyp)],
175
+ ...style,
176
+ },
177
+ ];
178
+ }
179
+ function createSection(content, isLineOnTop, margin) {
180
+ return [
181
+ {
182
+ stack: [
183
+ ...(content.length
184
+ ? [...(isLineOnTop ? [{ stack: [generateLine()], margin: [0, 8, 0, 0] }] : []), content]
185
+ : []),
186
+ ],
187
+ margin: margin !== null && margin !== void 0 ? margin : [0, 0, 0, 8],
188
+ },
189
+ ];
190
+ }
191
+ function createHeader(text, margin) {
192
+ return [
193
+ {
194
+ stack: [formatText(text, common_enum_1.default.HeaderContent)],
195
+ margin: margin !== null && margin !== void 0 ? margin : [0, 8, 0, 8],
196
+ },
197
+ ];
198
+ }
199
+ function createSubHeader(text, margin) {
200
+ return [
201
+ {
202
+ stack: [formatText(text, common_enum_1.default.SubHeaderContent)],
203
+ margin: margin !== null && margin !== void 0 ? margin : [0, 4, 0, 4],
204
+ },
205
+ ];
206
+ }
207
+ function generateStyle() {
208
+ return {
209
+ styles: {
210
+ columnMarginLeft: {
211
+ margin: [4, 0, 0, 0],
212
+ },
213
+ columnMarginRight: {
214
+ margin: [0, 0, 4, 0],
215
+ },
216
+ GrayBoldTitle: {
217
+ fillColor: '#F6F7FA',
218
+ bold: true,
219
+ },
220
+ GrayTitle: {
221
+ fillColor: '#F6F7FA',
222
+ },
223
+ Label: {
224
+ color: '#343A40',
225
+ bold: true,
226
+ },
227
+ LabelMargin: {
228
+ margin: [0, 12, 0, 1.3],
229
+ },
230
+ LabelSmallMargin: {
231
+ margin: [0, 6, 0, 1.3],
232
+ },
233
+ LabelMedium: {
234
+ color: '#343A40',
235
+ bold: true,
236
+ fontSize: 9,
237
+ },
238
+ LabelGreater: {
239
+ color: '#343A40',
240
+ bold: true,
241
+ fontSize: 10,
242
+ },
243
+ Value: {
244
+ color: '#343A40',
245
+ },
246
+ ValueMedium: {
247
+ color: '#343A40',
248
+ fontSize: 9,
249
+ },
250
+ Bold: {
251
+ fontSize: 9,
252
+ bold: true,
253
+ },
254
+ Description: {
255
+ color: 'blue',
256
+ bold: false,
257
+ },
258
+ HeaderPosition: {
259
+ fontSize: 16,
260
+ bold: true,
261
+ },
262
+ Right: {
263
+ alignment: common_enum_1.Position.RIGHT,
264
+ },
265
+ header: {
266
+ fontSize: 12,
267
+ bold: true,
268
+ margin: [0, 12, 0, 5],
269
+ },
270
+ HeaderContent: {
271
+ fontSize: 10,
272
+ bold: true,
273
+ },
274
+ SubHeaderContent: {
275
+ fontSize: 7,
276
+ bold: true,
277
+ },
278
+ TitleContent: {
279
+ fontSize: 10,
280
+ bold: true,
281
+ },
282
+ Link: {
283
+ color: 'blue',
284
+ },
285
+ MarginBottom4: {
286
+ marginBottom: 4,
287
+ },
288
+ MarginBottom8: {
289
+ marginBottom: 8,
290
+ },
291
+ MarginTop4: {
292
+ marginTop: 4,
293
+ },
294
+ },
295
+ defaultStyle: {
296
+ font: 'Roboto',
297
+ fontSize: 7,
298
+ lineHeight: 1.2,
299
+ },
300
+ };
301
+ }
302
+ function getTable(data) {
303
+ if (!data) {
304
+ return [];
305
+ }
306
+ if (Array.isArray(data)) {
307
+ return data;
308
+ }
309
+ return [data];
310
+ }
311
+ function getRowTable(data, formatColumn) {
312
+ return data.map((el, index) => {
313
+ var _a;
314
+ if (Array.isArray(formatColumn)) {
315
+ return formatText(el, (_a = formatColumn[index]) !== null && _a !== void 0 ? _a : common_enum_1.default.Default);
316
+ }
317
+ return formatText(el, formatColumn !== null && formatColumn !== void 0 ? formatColumn : common_enum_1.default.Default);
318
+ });
319
+ }
320
+ function hasColumnsValue(name, data) {
321
+ return data.some((el) => {
322
+ return hasValue(el[name]);
323
+ });
324
+ }
325
+ function getDifferentColumnsValue(name, data) {
326
+ const result = [];
327
+ data.forEach((el) => {
328
+ const val = getValue(el[name]);
329
+ if (val) {
330
+ const index = result.findIndex((el) => el.value === val);
331
+ if (index < 0) {
332
+ result.push({ value: val, count: 1 });
333
+ }
334
+ else {
335
+ result[index].count++;
336
+ }
337
+ }
338
+ });
339
+ return result;
340
+ }
341
+ function getContentTable(headers, data, defaultWidths, margin) {
342
+ const fieldsWithValue = headers.filter((header) => {
343
+ return data.some((d) => {
344
+ var _a;
345
+ const name = header.name;
346
+ if (name === '' && (d === null || d === void 0 ? void 0 : d._text)) {
347
+ return true;
348
+ }
349
+ if (name === '') {
350
+ return false;
351
+ }
352
+ if (typeof d[name] === 'object' && ((_a = d[name]) === null || _a === void 0 ? void 0 : _a._text)) {
353
+ return true;
354
+ }
355
+ return !!(typeof d[name] !== 'object' && d[name]);
356
+ });
357
+ });
358
+ if (fieldsWithValue.length < 1) {
359
+ return { content: null, fieldsWithValue: [] };
360
+ }
361
+ const headerRow = getRowTable(fieldsWithValue.map((header) => header.title), common_enum_1.default.GrayBoldTitle);
362
+ const tableBody = data.map((row) => {
363
+ return fieldsWithValue.map((header) => {
364
+ var _a, _b;
365
+ const fp = (header.name ? row[header.name] : row);
366
+ const value = typeof fp === 'object' ? fp === null || fp === void 0 ? void 0 : fp._text : fp;
367
+ return formatText(header.mappingData && value ? header.mappingData[value] : (value !== null && value !== void 0 ? value : ''), (_a = header.format) !== null && _a !== void 0 ? _a : common_enum_1.default.Default, { rowSpan: (_b = fp === null || fp === void 0 ? void 0 : fp._rowSpan) !== null && _b !== void 0 ? _b : 1 });
368
+ });
369
+ });
370
+ return {
371
+ fieldsWithValue: fieldsWithValue.map((el) => el.name),
372
+ content: {
373
+ table: {
374
+ headerRows: 1,
375
+ keepWithHeaderRows: 1,
376
+ widths: fieldsWithValue.map((header) => { var _a; return (_a = header.width) !== null && _a !== void 0 ? _a : defaultWidths; }),
377
+ body: [headerRow, ...tableBody],
378
+ },
379
+ margin: margin !== null && margin !== void 0 ? margin : [0, 0, 0, 8],
380
+ layout: const_1.DEFAULT_TABLE_LAYOUT,
381
+ },
382
+ };
383
+ }
384
+ function generateTwoColumns(kol1, kol2, margin) {
385
+ return {
386
+ columns: [
387
+ { stack: [kol1], margin: [0, 0, 5, 0] },
388
+ { stack: [kol2], margin: [5, 0, 0, 0] },
389
+ ],
390
+ margin: margin !== null && margin !== void 0 ? margin : [0, 0, 0, 0],
391
+ };
392
+ }
393
+ function generateQRCode(qrCode) {
394
+ return qrCode
395
+ ? {
396
+ qr: qrCode,
397
+ fit: 150,
398
+ foreground: 'black',
399
+ background: 'white',
400
+ eccLevel: 'M',
401
+ }
402
+ : undefined;
403
+ }
404
+ function verticalSpacing(height) {
405
+ return { text: '\n', fontSize: height };
406
+ }
407
+ function getKraj(kod) {
408
+ if (const_1.Kraj[kod]) {
409
+ return const_1.Kraj[kod];
410
+ }
411
+ return kod;
412
+ }
413
+ function generateLine() {
414
+ return {
415
+ table: {
416
+ widths: ['*'],
417
+ body: [[{ text: ' ', fontSize: 1 }]],
418
+ },
419
+ layout: {
420
+ hLineWidth: (i) => (i === 0 ? 1 : 0),
421
+ vLineWidth: () => 0,
422
+ hLineColor: function () {
423
+ return '#c0bfc1';
424
+ },
425
+ paddingTop: () => 0,
426
+ paddingBottom: () => 0,
427
+ },
428
+ };
429
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripPrefixes = stripPrefixes;
4
+ exports.parseXML = parseXML;
5
+ const xml_js_1 = require("xml-js");
6
+ function stripPrefixes(obj) {
7
+ if (Array.isArray(obj)) {
8
+ return obj.map(stripPrefixes);
9
+ }
10
+ else if (typeof obj === 'object' && obj !== null) {
11
+ return Object.fromEntries(Object.entries(obj).map(([key, value]) => [
12
+ key.includes(':') ? key.split(':')[1] : key,
13
+ stripPrefixes(value),
14
+ ]));
15
+ }
16
+ return obj;
17
+ }
18
+ function parseXML(xml) {
19
+ return stripPrefixes((0, xml_js_1.xml2js)(xml, { compact: true }));
20
+ }
21
+ ;