@aidc-toolkit/app-extension 1.0.32-beta → 1.0.33-beta

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 (39) hide show
  1. package/dist/index.cjs +1 -6528
  2. package/dist/index.d.cts +105 -106
  3. package/dist/index.d.ts +105 -106
  4. package/dist/index.js +1 -6508
  5. package/package.json +12 -12
  6. package/src/app-extension.ts +26 -47
  7. package/src/{app-utility-proxy.ts → app-helper-proxy.ts} +21 -19
  8. package/src/descriptor.ts +43 -2
  9. package/src/generator/generator.ts +116 -91
  10. package/src/generator/locale-resources-generator.ts +26 -14
  11. package/src/gs1/check-proxy.ts +12 -11
  12. package/src/gs1/gtin-creator-proxy.ts +2 -3
  13. package/src/gs1/gtin-descriptor.ts +2 -2
  14. package/src/gs1/gtin-validator-proxy.ts +12 -14
  15. package/src/gs1/identifier-creator-proxy.ts +19 -21
  16. package/src/gs1/identifier-descriptor.ts +3 -3
  17. package/src/gs1/identifier-validator-proxy.ts +15 -16
  18. package/src/gs1/non-gtin-creator-proxy.ts +0 -11
  19. package/src/gs1/non-gtin-validator-proxy.ts +0 -11
  20. package/src/gs1/prefix-definition-descriptor.ts +2 -2
  21. package/src/gs1/prefix-manager-proxy.ts +80 -120
  22. package/src/gs1/service-proxy.ts +6 -5
  23. package/src/gs1/variable-measure-proxy.ts +9 -8
  24. package/src/index.ts +1 -2
  25. package/src/locale/en/locale-resources.ts +28 -15
  26. package/src/locale/fr/locale-resources.ts +28 -15
  27. package/src/locale/i18n.ts +10 -9
  28. package/src/locale/i18next.d.ts +2 -0
  29. package/src/proxy.ts +64 -40
  30. package/src/utility/character-set-descriptor.ts +2 -2
  31. package/src/utility/character-set-proxy.ts +7 -7
  32. package/src/utility/reg-exp-proxy.ts +5 -5
  33. package/src/utility/string-descriptor.ts +2 -2
  34. package/src/utility/string-proxy.ts +4 -0
  35. package/src/utility/transformer-descriptor.ts +5 -5
  36. package/src/utility/transformer-proxy.ts +6 -5
  37. package/dist/index.cjs.map +0 -1
  38. package/dist/index.js.map +0 -1
  39. package/src/app-data.ts +0 -94
package/src/app-data.ts DELETED
@@ -1,94 +0,0 @@
1
- import { fromByteArray, toByteArray } from "base64-js";
2
-
3
- /**
4
- * Application data.
5
- */
6
- export type AppData = string | number | boolean | Date | Uint8Array | object;
7
-
8
- /**
9
- * Decode application data from an encoded string.
10
- *
11
- * @param stringData
12
- * String data.
13
- *
14
- * @returns
15
- * Decoded application data.
16
- */
17
- export function decodeAppData(stringData: string): AppData | undefined {
18
- let decodedAppData: AppData | undefined;
19
-
20
- try {
21
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Mapping is expected to be correct.
22
- decodedAppData = JSON.parse(stringData, (_key, value: unknown) => {
23
- let replacementValue = value;
24
-
25
- // Decode string representing date/time and binary array and pass through other values unmodified.
26
- if (typeof value === "string") {
27
- // First capture group is type, second is data; simple split at ':' character.
28
- const stringDataGroups = /^(?<type>\w+):(?<data>.*)$/u.exec(value)?.groups;
29
-
30
- if (stringDataGroups !== undefined) {
31
- const type = stringDataGroups["type"];
32
- const data = stringDataGroups["data"];
33
-
34
- switch (type) {
35
- case "dateTime":
36
- replacementValue = new Date(data);
37
- break;
38
-
39
- case "binary":
40
- replacementValue = toByteArray(data);
41
- break;
42
- }
43
- }
44
- }
45
-
46
- return replacementValue;
47
- }) as AppData;
48
- } catch {
49
- // String data is not valid JSON; discard it.
50
- decodedAppData = undefined;
51
- }
52
-
53
- return decodedAppData;
54
- }
55
-
56
- /**
57
- * Encode an object to a format suitable for storage.
58
- *
59
- * @param data
60
- * Object.
61
- *
62
- * @returns
63
- * Object suitable for storage with date/time and binary types encoded as strings.
64
- */
65
- function encodeObject(data: object): object | string {
66
- let mappedData: object | string;
67
-
68
- if (data instanceof Date) {
69
- mappedData = `dateTime:${data.toISOString()}`;
70
- } else if (data instanceof Uint8Array) {
71
- mappedData = `binary:${fromByteArray(data)}`;
72
- } else {
73
- mappedData = Object.fromEntries(Object.entries(data).map(([key, value]: [string, unknown]) =>
74
- // Encode date/time and binary array as string and pass through other values unmodified.
75
- [key, typeof value === "object" && value !== null ? encodeObject(value) : value]
76
- ));
77
- }
78
-
79
- return mappedData;
80
- }
81
-
82
- /**
83
- * Encode application data as a string for storage. Encoded string is in JSON format with date/time and binary data
84
- * converted to identifiable strings for decoding.
85
- *
86
- * @param appData
87
- * Application data.
88
- *
89
- * @returns
90
- * Encoded application data.
91
- */
92
- export function encodeAppData(appData: AppData): string {
93
- return JSON.stringify(typeof appData !== "object" ? appData : encodeObject(appData));
94
- }