@aidc-toolkit/app-extension 1.0.32-beta → 1.0.34-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 (191) hide show
  1. package/README.md +1 -5
  2. package/dist/app-extension.d.ts +194 -0
  3. package/dist/app-extension.d.ts.map +1 -0
  4. package/dist/app-extension.js +133 -0
  5. package/dist/app-extension.js.map +1 -0
  6. package/dist/app-helper-proxy.d.ts +61 -0
  7. package/dist/app-helper-proxy.d.ts.map +1 -0
  8. package/dist/app-helper-proxy.js +332 -0
  9. package/dist/app-helper-proxy.js.map +1 -0
  10. package/dist/descriptor.d.ts +193 -0
  11. package/dist/descriptor.d.ts.map +1 -0
  12. package/dist/descriptor.js +44 -0
  13. package/dist/descriptor.js.map +1 -0
  14. package/dist/generator/generator.d.ts +114 -0
  15. package/dist/generator/generator.d.ts.map +1 -0
  16. package/dist/generator/generator.js +160 -0
  17. package/dist/generator/generator.js.map +1 -0
  18. package/dist/generator/index.d.ts +2 -0
  19. package/dist/generator/index.d.ts.map +1 -0
  20. package/dist/generator/index.js +2 -0
  21. package/dist/generator/index.js.map +1 -0
  22. package/dist/generator/locale-resources-generator.d.ts +2 -0
  23. package/dist/generator/locale-resources-generator.d.ts.map +1 -0
  24. package/dist/generator/locale-resources-generator.js +311 -0
  25. package/dist/generator/locale-resources-generator.js.map +1 -0
  26. package/dist/gs1/character-set-proxy.d.ts +13 -0
  27. package/dist/gs1/character-set-proxy.d.ts.map +1 -0
  28. package/dist/gs1/character-set-proxy.js +126 -0
  29. package/dist/gs1/character-set-proxy.js.map +1 -0
  30. package/dist/gs1/check-proxy.d.ts +11 -0
  31. package/dist/gs1/check-proxy.d.ts.map +1 -0
  32. package/dist/gs1/check-proxy.js +163 -0
  33. package/dist/gs1/check-proxy.js.map +1 -0
  34. package/dist/gs1/gtin-creator-proxy.d.ts +10 -0
  35. package/dist/gs1/gtin-creator-proxy.d.ts.map +1 -0
  36. package/dist/gs1/gtin-creator-proxy.js +85 -0
  37. package/dist/gs1/gtin-creator-proxy.js.map +1 -0
  38. package/dist/gs1/gtin-descriptor.d.ts +3 -0
  39. package/dist/gs1/gtin-descriptor.d.ts.map +1 -0
  40. package/dist/gs1/gtin-descriptor.js +8 -0
  41. package/dist/gs1/gtin-descriptor.js.map +1 -0
  42. package/dist/gs1/gtin-validator-proxy.d.ts +26 -0
  43. package/dist/gs1/gtin-validator-proxy.d.ts.map +1 -0
  44. package/dist/gs1/gtin-validator-proxy.js +256 -0
  45. package/dist/gs1/gtin-validator-proxy.js.map +1 -0
  46. package/dist/gs1/identifier-creator-proxy.d.ts +30 -0
  47. package/dist/gs1/identifier-creator-proxy.d.ts.map +1 -0
  48. package/dist/gs1/identifier-creator-proxy.js +302 -0
  49. package/dist/gs1/identifier-creator-proxy.js.map +1 -0
  50. package/dist/gs1/identifier-descriptor.d.ts +4 -0
  51. package/dist/gs1/identifier-descriptor.d.ts.map +1 -0
  52. package/dist/gs1/identifier-descriptor.js +14 -0
  53. package/dist/gs1/identifier-descriptor.js.map +1 -0
  54. package/dist/gs1/identifier-type.d.ts +22 -0
  55. package/dist/gs1/identifier-type.d.ts.map +1 -0
  56. package/dist/gs1/identifier-type.js +34 -0
  57. package/dist/gs1/identifier-type.js.map +1 -0
  58. package/dist/gs1/identifier-validator-proxy.d.ts +29 -0
  59. package/dist/gs1/identifier-validator-proxy.d.ts.map +1 -0
  60. package/dist/gs1/identifier-validator-proxy.js +212 -0
  61. package/dist/gs1/identifier-validator-proxy.js.map +1 -0
  62. package/dist/gs1/index.d.ts +10 -0
  63. package/dist/gs1/index.d.ts.map +1 -0
  64. package/dist/gs1/index.js +10 -0
  65. package/dist/gs1/index.js.map +1 -0
  66. package/dist/gs1/non-gtin-creator-proxy.d.ts +38 -0
  67. package/dist/gs1/non-gtin-creator-proxy.d.ts.map +1 -0
  68. package/dist/gs1/non-gtin-creator-proxy.js +301 -0
  69. package/dist/gs1/non-gtin-creator-proxy.js.map +1 -0
  70. package/dist/gs1/non-gtin-validator-proxy.d.ts +37 -0
  71. package/dist/gs1/non-gtin-validator-proxy.d.ts.map +1 -0
  72. package/dist/gs1/non-gtin-validator-proxy.js +302 -0
  73. package/dist/gs1/non-gtin-validator-proxy.js.map +1 -0
  74. package/dist/gs1/prefix-definition-descriptor.d.ts +4 -0
  75. package/dist/gs1/prefix-definition-descriptor.d.ts.map +1 -0
  76. package/dist/gs1/prefix-definition-descriptor.js +16 -0
  77. package/dist/gs1/prefix-definition-descriptor.js.map +1 -0
  78. package/dist/gs1/prefix-manager-proxy.d.ts +14 -0
  79. package/dist/gs1/prefix-manager-proxy.d.ts.map +1 -0
  80. package/dist/gs1/prefix-manager-proxy.js +213 -0
  81. package/dist/gs1/prefix-manager-proxy.js.map +1 -0
  82. package/dist/gs1/service-proxy.d.ts +7 -0
  83. package/dist/gs1/service-proxy.d.ts.map +1 -0
  84. package/dist/gs1/service-proxy.js +105 -0
  85. package/dist/gs1/service-proxy.js.map +1 -0
  86. package/dist/gs1/variable-measure-proxy.d.ts +7 -0
  87. package/dist/gs1/variable-measure-proxy.d.ts.map +1 -0
  88. package/dist/gs1/variable-measure-proxy.js +114 -0
  89. package/dist/gs1/variable-measure-proxy.js.map +1 -0
  90. package/dist/index.d.ts +28 -1866
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +10 -6508
  93. package/dist/index.js.map +1 -1
  94. package/dist/lib-proxy.d.ts +135 -0
  95. package/dist/lib-proxy.d.ts.map +1 -0
  96. package/dist/lib-proxy.js +276 -0
  97. package/dist/lib-proxy.js.map +1 -0
  98. package/dist/locale/en/locale-resources.d.ts +752 -0
  99. package/dist/locale/en/locale-resources.d.ts.map +1 -0
  100. package/dist/locale/en/locale-resources.js +751 -0
  101. package/dist/locale/en/locale-resources.js.map +1 -0
  102. package/dist/locale/fr/locale-resources.d.ts +752 -0
  103. package/dist/locale/fr/locale-resources.d.ts.map +1 -0
  104. package/dist/locale/fr/locale-resources.js +751 -0
  105. package/dist/locale/fr/locale-resources.js.map +1 -0
  106. package/dist/locale/i18n.d.ts +27 -0
  107. package/dist/locale/i18n.d.ts.map +1 -0
  108. package/dist/locale/i18n.js +36 -0
  109. package/dist/locale/i18n.js.map +1 -0
  110. package/dist/proxy.d.ts +136 -0
  111. package/dist/proxy.d.ts.map +1 -0
  112. package/dist/proxy.js +319 -0
  113. package/dist/proxy.js.map +1 -0
  114. package/dist/streaming.d.ts +10 -0
  115. package/dist/streaming.d.ts.map +1 -0
  116. package/dist/streaming.js +2 -0
  117. package/dist/streaming.js.map +1 -0
  118. package/dist/type.d.ts +91 -0
  119. package/dist/type.d.ts.map +1 -0
  120. package/dist/type.js +2 -0
  121. package/dist/type.js.map +1 -0
  122. package/dist/utility/character-set-descriptor.d.ts +6 -0
  123. package/dist/utility/character-set-descriptor.d.ts.map +1 -0
  124. package/dist/utility/character-set-descriptor.js +28 -0
  125. package/dist/utility/character-set-descriptor.js.map +1 -0
  126. package/dist/utility/character-set-proxy.d.ts +31 -0
  127. package/dist/utility/character-set-proxy.d.ts.map +1 -0
  128. package/dist/utility/character-set-proxy.js +278 -0
  129. package/dist/utility/character-set-proxy.js.map +1 -0
  130. package/dist/utility/index.d.ts +4 -0
  131. package/dist/utility/index.d.ts.map +1 -0
  132. package/dist/utility/index.js +4 -0
  133. package/dist/utility/index.js.map +1 -0
  134. package/dist/utility/reg-exp-proxy.d.ts +8 -0
  135. package/dist/utility/reg-exp-proxy.d.ts.map +1 -0
  136. package/dist/utility/reg-exp-proxy.js +103 -0
  137. package/dist/utility/reg-exp-proxy.js.map +1 -0
  138. package/dist/utility/string-descriptor.d.ts +4 -0
  139. package/dist/utility/string-descriptor.d.ts.map +1 -0
  140. package/dist/utility/string-descriptor.js +12 -0
  141. package/dist/utility/string-descriptor.js.map +1 -0
  142. package/dist/utility/string-proxy.d.ts +7 -0
  143. package/dist/utility/string-proxy.d.ts.map +1 -0
  144. package/dist/utility/string-proxy.js +63 -0
  145. package/dist/utility/string-proxy.js.map +1 -0
  146. package/dist/utility/transformer-descriptor.d.ts +6 -0
  147. package/dist/utility/transformer-descriptor.d.ts.map +1 -0
  148. package/dist/utility/transformer-descriptor.js +24 -0
  149. package/dist/utility/transformer-descriptor.js.map +1 -0
  150. package/dist/utility/transformer-proxy.d.ts +9 -0
  151. package/dist/utility/transformer-proxy.d.ts.map +1 -0
  152. package/dist/utility/transformer-proxy.js +111 -0
  153. package/dist/utility/transformer-proxy.js.map +1 -0
  154. package/package.json +13 -12
  155. package/src/app-extension.ts +26 -47
  156. package/src/{app-utility-proxy.ts → app-helper-proxy.ts} +21 -19
  157. package/src/descriptor.ts +43 -2
  158. package/src/generator/generator.ts +122 -95
  159. package/src/generator/locale-resources-generator.ts +26 -14
  160. package/src/gs1/check-proxy.ts +12 -11
  161. package/src/gs1/gtin-creator-proxy.ts +2 -3
  162. package/src/gs1/gtin-descriptor.ts +2 -2
  163. package/src/gs1/gtin-validator-proxy.ts +12 -14
  164. package/src/gs1/identifier-creator-proxy.ts +19 -21
  165. package/src/gs1/identifier-descriptor.ts +3 -3
  166. package/src/gs1/identifier-validator-proxy.ts +15 -16
  167. package/src/gs1/non-gtin-creator-proxy.ts +0 -11
  168. package/src/gs1/non-gtin-validator-proxy.ts +0 -11
  169. package/src/gs1/prefix-definition-descriptor.ts +2 -2
  170. package/src/gs1/prefix-manager-proxy.ts +80 -120
  171. package/src/gs1/service-proxy.ts +6 -5
  172. package/src/gs1/variable-measure-proxy.ts +9 -8
  173. package/src/index.ts +3 -3
  174. package/src/locale/en/locale-resources.ts +28 -15
  175. package/src/locale/fr/locale-resources.ts +28 -15
  176. package/src/locale/i18n.ts +10 -9
  177. package/src/locale/i18next.d.ts +2 -0
  178. package/src/proxy.ts +64 -40
  179. package/src/utility/character-set-descriptor.ts +2 -2
  180. package/src/utility/character-set-proxy.ts +7 -7
  181. package/src/utility/reg-exp-proxy.ts +5 -5
  182. package/src/utility/string-descriptor.ts +2 -2
  183. package/src/utility/string-proxy.ts +4 -0
  184. package/src/utility/transformer-descriptor.ts +5 -5
  185. package/src/utility/transformer-proxy.ts +6 -5
  186. package/tsconfig-src.json +7 -1
  187. package/tsconfig-src.tsbuildinfo +1 -0
  188. package/dist/index.cjs +0 -6544
  189. package/dist/index.cjs.map +0 -1
  190. package/dist/index.d.cts +0 -1866
  191. package/src/app-data.ts +0 -94
@@ -1,9 +1,11 @@
1
- import { I18nEnvironments, type Promisable } from "@aidc-toolkit/core";
2
- import type { ParseKeys } from "i18next";
3
- import { AppUtilityProxy } from "../app-utility-proxy.js";
1
+ import { getLogger, I18nEnvironments, phaseURL, type Promisable } from "@aidc-toolkit/core";
2
+ import type { DefaultNamespace, ParseKeys } from "i18next";
3
+ import type { Logger } from "tslog";
4
+ import packageConfiguration from "../../package.json" with { type: "json" };
5
+ import { AppHelperProxy } from "../app-helper-proxy.js";
4
6
  import type { ClassDescriptor, MethodDescriptor } from "../descriptor.js";
5
7
  import * as GS1 from "../gs1/index.js";
6
- import { appExtensionResources, i18nAppExtensionInit, i18nextAppExtension } from "../locale/i18n.js";
8
+ import { appExtensionResourceBundle, i18nAppExtensionInit, i18nextAppExtension } from "../locale/i18n.js";
7
9
  import { proxy } from "../proxy.js";
8
10
  import * as Utility from "../utility/index.js";
9
11
 
@@ -16,7 +18,7 @@ import * as Utility from "../utility/index.js";
16
18
  function registerProxies(..._proxies: unknown[]): void {
17
19
  }
18
20
 
19
- registerProxies(AppUtilityProxy, Utility, GS1);
21
+ registerProxies(AppHelperProxy, Utility, GS1);
20
22
 
21
23
  /**
22
24
  * Localization.
@@ -25,27 +27,32 @@ export interface Localization {
25
27
  /**
26
28
  * Name.
27
29
  */
28
- name: string;
30
+ readonly name: string;
29
31
 
30
32
  /**
31
33
  * Description.
32
34
  */
33
- description: string;
35
+ readonly description: string;
34
36
  }
35
37
 
36
38
  /**
37
39
  * Function localization.
38
40
  */
39
41
  export interface FunctionLocalization extends Localization {
42
+ /**
43
+ * Namespace function name.
44
+ */
45
+ readonly namespaceFunctionName: string;
46
+
40
47
  /**
41
48
  * Documentation URL.
42
49
  */
43
- documentationURL: string;
50
+ readonly documentationURL: string;
44
51
 
45
52
  /**
46
53
  * Parameters map.
47
54
  */
48
- parametersMap: Map<string, Localization>;
55
+ readonly parametersMap: ReadonlyMap<string, Localization>;
49
56
  }
50
57
 
51
58
  /**
@@ -53,14 +60,19 @@ export interface FunctionLocalization extends Localization {
53
60
  */
54
61
  export abstract class Generator {
55
62
  /**
56
- * Documentation base URL.
63
+ * Documentation path, optionally preceded by locale.
57
64
  */
58
- static readonly #DOCUMENTATION_BASE_URL = "https://aidc-toolkit.com/";
65
+ static readonly #DOCUMENTATION_PATH = "app-extension/";
59
66
 
60
67
  /**
61
- * Documentation path, optionally preceded by locale.
68
+ * Logger.
62
69
  */
63
- static readonly #DOCUMENTATION_PATH = "app-extension/";
70
+ readonly #logger = getLogger();
71
+
72
+ /**
73
+ * Base URL.
74
+ */
75
+ readonly #baseURL: string;
64
76
 
65
77
  /**
66
78
  * Locales.
@@ -72,11 +84,6 @@ export abstract class Generator {
72
84
  */
73
85
  readonly #defaultLocale: string;
74
86
 
75
- /**
76
- * Map of function localizations maps by namespace function name.
77
- */
78
- readonly #functionLocalizationsMapsMap = new Map<string, ReadonlyMap<string, FunctionLocalization>>();
79
-
80
87
  /**
81
88
  * Constructor.
82
89
  *
@@ -84,10 +91,18 @@ export abstract class Generator {
84
91
  * Include localizations if true.
85
92
  */
86
93
  constructor(includeLocalizations = true) {
87
- this.#locales = includeLocalizations ? Object.keys(appExtensionResources) : [];
94
+ this.#baseURL = phaseURL(packageConfiguration.version, "http://10.211.55.2:5173");
95
+ this.#locales = includeLocalizations ? Object.keys(appExtensionResourceBundle) : [];
88
96
  this.#defaultLocale = this.#locales[0] ?? "";
89
97
  }
90
98
 
99
+ /**
100
+ * Get the logger.
101
+ */
102
+ get logger(): Logger<object> {
103
+ return this.#logger;
104
+ }
105
+
91
106
  /**
92
107
  * Get the locales.
93
108
  */
@@ -103,56 +118,31 @@ export abstract class Generator {
103
118
  }
104
119
 
105
120
  /**
106
- * Get function localization.
107
- *
108
- * @param locale
109
- * Locale.
110
- *
111
- * @param namespaceFunctionName
112
- * Namespace function name.
113
- *
114
- * @returns
115
- * Function localization.
121
+ * Initialize the generation of the output.
116
122
  */
117
- protected getFunctionLocalization(locale: string, namespaceFunctionName: string): FunctionLocalization {
118
- const functionLocalization = this.#functionLocalizationsMapsMap.get(namespaceFunctionName)?.get(locale);
119
-
120
- if (functionLocalization === undefined) {
121
- throw new Error(`${locale} localization for function ${namespaceFunctionName} not found`);
122
- }
123
-
124
- return functionLocalization;
125
- }
123
+ protected abstract initialize(): void;
126
124
 
127
125
  /**
128
- * Get parameter localization.
126
+ * Create a namespace.
129
127
  *
130
- * @param locale
131
- * Locale.
132
- *
133
- * @param namespaceFunctionName
134
- * Namespace function name.
135
- *
136
- * @param parameterName
137
- * Parameter name.
138
- *
139
- * @returns
140
- * Parameter localization.
128
+ * @param namespace
129
+ * Namespace.
141
130
  */
142
- protected getParameterLocalization(locale: string, namespaceFunctionName: string, parameterName: string): Localization {
143
- const parameterLocalization = this.getFunctionLocalization(locale, namespaceFunctionName).parametersMap.get(parameterName);
144
-
145
- if (parameterLocalization === undefined) {
146
- throw new Error(`${locale} localization for function ${namespaceFunctionName} parameter ${parameterName} not found`);
147
- }
148
-
149
- return parameterLocalization;
150
- }
131
+ protected abstract createNamespace(namespace: string | undefined): void;
151
132
 
152
133
  /**
153
- * Initialize the generation of the output.
134
+ * Create a category.
135
+ *
136
+ * @param namespace
137
+ * Namespace.
138
+ *
139
+ * @param category
140
+ * Category.
141
+ *
142
+ * @param categoryLocalizationsMap
143
+ * Category localizations map.
154
144
  */
155
- protected abstract initialize(): void;
145
+ protected abstract createCategory(namespace: string | undefined, category: string, categoryLocalizationsMap: ReadonlyMap<string, string>): void;
156
146
 
157
147
  /**
158
148
  * Create a proxy object for a class.
@@ -172,7 +162,7 @@ export abstract class Generator {
172
162
  * Method descriptor.
173
163
  *
174
164
  * @param functionLocalizationsMap
175
- * Localizations map.
165
+ * Function localizations map.
176
166
  */
177
167
  protected abstract createProxyFunction(classDescriptor: ClassDescriptor, methodDescriptor: MethodDescriptor, functionLocalizationsMap: ReadonlyMap<string, FunctionLocalization>): void;
178
168
 
@@ -193,11 +183,8 @@ export abstract class Generator {
193
183
  * @param locale
194
184
  * Locale.
195
185
  *
196
- * @param localizedKeyPrefix
197
- * Localized key prefix.
198
- *
199
- * @param namespacePrefix
200
- * Namespace prefix to be appended to name.
186
+ * @param key
187
+ * Key.
201
188
  *
202
189
  * @param localizationCallback
203
190
  * Callback to finalize localization.
@@ -205,17 +192,14 @@ export abstract class Generator {
205
192
  * @returns
206
193
  * Localization.
207
194
  */
208
- #generateLocalization<TLocalization extends Localization>(locale: string, localizedKeyPrefix: string, namespacePrefix: string, localizationCallback: (locale: string, localization: Localization) => TLocalization): TLocalization {
209
- const lngOption = {
210
- lng: locale
211
- };
212
-
213
- return localizationCallback(locale, {
214
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Localized key exists.
215
- name: `${namespacePrefix}${i18nextAppExtension.t(`${localizedKeyPrefix}name` as ParseKeys, lngOption)}`,
216
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Localized key exists.
217
- description: i18nextAppExtension.t(`${localizedKeyPrefix}description` as ParseKeys, lngOption)
218
- });
195
+ static #generateLocalization<TLocalization extends Localization>(locale: string, key: string, localizationCallback: (locale: string, localization: Localization) => TLocalization): TLocalization {
196
+ const lngReturnObjectsOption = {
197
+ lng: locale,
198
+ returnObjects: true
199
+ } as const;
200
+
201
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Localized key exists and return type is Localization.
202
+ return localizationCallback(locale, i18nextAppExtension.t(key as ParseKeys<DefaultNamespace, typeof lngReturnObjectsOption>, lngReturnObjectsOption) as Localization);
219
203
  }
220
204
 
221
205
  /**
@@ -228,30 +212,73 @@ export abstract class Generator {
228
212
 
229
213
  this.initialize();
230
214
 
215
+ const namespaceHierarchy = new Map<string | undefined, Map<string, ClassDescriptor[]>>();
216
+
217
+ // Organize class descriptors by namespace and category.
218
+ for (const classDescriptor of proxy.classDescriptors) {
219
+ const namespace = classDescriptor.namespace;
220
+ const category = classDescriptor.category;
221
+
222
+ let categoryHierarchy = namespaceHierarchy.get(namespace);
223
+
224
+ if (categoryHierarchy === undefined) {
225
+ categoryHierarchy = new Map();
226
+ namespaceHierarchy.set(namespace, categoryHierarchy);
227
+ }
228
+
229
+ let classDescriptors = categoryHierarchy.get(category);
230
+
231
+ if (classDescriptors === undefined) {
232
+ classDescriptors = [];
233
+ categoryHierarchy.set(category, classDescriptors);
234
+ }
235
+
236
+ classDescriptors.push(classDescriptor);
237
+ }
238
+
231
239
  try {
232
- for (const [_namespaceClassName, classDescriptor] of proxy.classDescriptorsMap.entries()) {
233
- const namespace = classDescriptor.namespace;
240
+ for (const [namespace, categoryHierarchy] of namespaceHierarchy) {
234
241
  const namespacePrefix = namespace === undefined ? "" : `${namespace}.`;
235
242
  const namespacePath = namespace === undefined ? "" : `${namespace}/`;
236
243
 
237
- this.createProxyObject(classDescriptor);
244
+ this.createNamespace(namespace);
245
+
246
+ for (const [category, classDescriptors] of categoryHierarchy) {
247
+ const namespaceCategory = `${namespacePrefix}${category}`;
248
+
249
+ const categoriesKey = `Categories.${category}`;
250
+ const namespaceCategoriesKey = `Categories.${namespaceCategory}`;
251
+
252
+ const categoryLocalizationsMap = new Map(this.locales.map((locale) => {
253
+ const lngOption = {
254
+ lng: locale
255
+ } as const;
256
+
257
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Localized key exists.
258
+ return [locale, i18nextAppExtension.t((i18nextAppExtension.exists(namespaceCategoriesKey, lngOption) ? namespaceCategoriesKey : categoriesKey) as ParseKeys, lngOption)];
259
+ }));
260
+
261
+ this.createCategory(namespace, category, categoryLocalizationsMap);
238
262
 
239
- for (const methodDescriptor of classDescriptor.methodDescriptors) {
240
- const namespaceFunctionName = methodDescriptor.namespaceFunctionName;
241
- const functionLocalizationsMap = new Map(this.#locales.map(locale =>
242
- [locale, this.#generateLocalization<FunctionLocalization>(locale, `Functions.${namespaceFunctionName}.`, namespacePrefix, (locale, localization) => ({
243
- ...localization,
244
- documentationURL: `${Generator.#DOCUMENTATION_BASE_URL}${locale === this.defaultLocale ? "" : `${locale}/`}${Generator.#DOCUMENTATION_PATH}${namespacePath}${localization.name}.html`,
245
- parametersMap: new Map(methodDescriptor.parameterDescriptors.map(parameterDescriptor =>
246
- // eslint-disable-next-line max-nested-callbacks -- Callback is empty.
247
- [parameterDescriptor.name, this.#generateLocalization(locale, `Parameters.${parameterDescriptor.name}.`, "", (_locale, localization) => localization)]
248
- ))
249
- }))]
250
- ));
263
+ for (const classDescriptor of classDescriptors) {
264
+ this.createProxyObject(classDescriptor);
251
265
 
252
- this.#functionLocalizationsMapsMap.set(namespaceFunctionName, functionLocalizationsMap);
266
+ for (const methodDescriptor of classDescriptor.methodDescriptors) {
267
+ const functionLocalizationsMap = new Map(this.locales.map(locale =>
268
+ [locale, Generator.#generateLocalization<FunctionLocalization>(locale, `Functions.${methodDescriptor.namespaceFunctionName}`, (locale, localization) => ({
269
+ ...localization,
270
+ namespaceFunctionName: `${namespacePrefix}${localization.name}`,
271
+ documentationURL: `${this.#baseURL}/${locale === this.defaultLocale ? "" : `${locale}/`}${Generator.#DOCUMENTATION_PATH}${namespacePath}${localization.name}.html`,
272
+ parametersMap: new Map(methodDescriptor.parameterDescriptors.map(parameterDescriptor =>
273
+ // eslint-disable-next-line max-nested-callbacks -- Callback is empty.
274
+ [parameterDescriptor.name, Generator.#generateLocalization(locale, `Parameters.${parameterDescriptor.name}`, (_locale, localization) => localization)]
275
+ ))
276
+ }))]
277
+ ));
253
278
 
254
- this.createProxyFunction(classDescriptor, methodDescriptor, functionLocalizationsMap);
279
+ this.createProxyFunction(classDescriptor, methodDescriptor, functionLocalizationsMap);
280
+ }
281
+ }
255
282
  }
256
283
  }
257
284
 
@@ -1,4 +1,4 @@
1
- import { getLogger, type LocaleResources } from "@aidc-toolkit/core";
1
+ import type { LocaleResources } from "@aidc-toolkit/core";
2
2
  import * as fs from "node:fs";
3
3
  import * as path from "node:path";
4
4
  import type {
@@ -63,11 +63,6 @@ class LocaleResourcesGenerator extends Generator {
63
63
  */
64
64
  static readonly #IMPORT_PATH = "../app-extension/src/locale";
65
65
 
66
- /**
67
- * Logger.
68
- */
69
- readonly #logger = getLogger();
70
-
71
66
  /**
72
67
  * Parameters sequencer.
73
68
  */
@@ -101,13 +96,25 @@ class LocaleResourcesGenerator extends Generator {
101
96
  /**
102
97
  * @inheritDoc
103
98
  */
104
- protected initialize(): void {
99
+ protected override initialize(): void {
100
+ }
101
+
102
+ /**
103
+ * @inheritDoc
104
+ */
105
+ protected override createNamespace(): void {
105
106
  }
106
107
 
107
108
  /**
108
109
  * @inheritDoc
109
110
  */
110
- protected createProxyObject(): void {
111
+ protected override createCategory(): void {
112
+ }
113
+
114
+ /**
115
+ * @inheritDoc
116
+ */
117
+ protected override createProxyObject(): void {
111
118
  }
112
119
 
113
120
  /**
@@ -185,7 +192,7 @@ class LocaleResourcesGenerator extends Generator {
185
192
  /**
186
193
  * @inheritDoc
187
194
  */
188
- protected createProxyFunction(classDescriptor: ClassDescriptor, methodDescriptor: MethodDescriptor): void {
195
+ protected override createProxyFunction(classDescriptor: ClassDescriptor, methodDescriptor: MethodDescriptor): void {
189
196
  // Hidden functions aren't localized.
190
197
  if (!(methodDescriptor.isHidden ?? false)) {
191
198
  // Add any parameters that are not already known.
@@ -258,7 +265,7 @@ class LocaleResourcesGenerator extends Generator {
258
265
  if (!deleteMissing) {
259
266
  newDestinationLocaleResources[key] = destinationValue;
260
267
  } else if (logChanges) {
261
- this.#logger.info(`Deleting ${parentKey}${key}...`);
268
+ this.logger.info(`Deleting ${parentKey}${key}...`);
262
269
  }
263
270
  }
264
271
  }
@@ -267,7 +274,7 @@ class LocaleResourcesGenerator extends Generator {
267
274
  if (!(key in destinationLocaleResources)) {
268
275
  if (addMissing) {
269
276
  if (logChanges) {
270
- this.#logger.info(`Adding ${parentKey}${key}...`);
277
+ this.logger.info(`Adding ${parentKey}${key}...`);
271
278
  }
272
279
 
273
280
  newDestinationLocaleResources[key] = sourceValue;
@@ -366,7 +373,7 @@ class LocaleResourcesGenerator extends Generator {
366
373
  /**
367
374
  * @inheritDoc
368
375
  */
369
- protected async finalize(success: boolean): Promise<void> {
376
+ protected override async finalize(success: boolean): Promise<void> {
370
377
  if (success) {
371
378
  this.#buildParametersLocaleResources(this.#parametersSequencer);
372
379
 
@@ -375,7 +382,7 @@ class LocaleResourcesGenerator extends Generator {
375
382
  }).filter(entry => entry.isDirectory()).map(async (entry) => {
376
383
  const localeResourcesSource = path.resolve(LocaleResourcesGenerator.#IMPORT_PATH, entry.name, "locale-resources.ts");
377
384
 
378
- await import(localeResourcesSource).then((module) => {
385
+ return import(localeResourcesSource).then((module) => {
379
386
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Module format is known.
380
387
  const localeResources = this.#merge(entry.name === "en", "", this.#LocaleResources, (module as LocaleResourcesModule).default, !entry.name.includes("-"));
381
388
 
@@ -386,4 +393,9 @@ class LocaleResourcesGenerator extends Generator {
386
393
  }
387
394
  }
388
395
 
389
- await new LocaleResourcesGenerator().generate();
396
+ const generator = new LocaleResourcesGenerator();
397
+
398
+ generator.generate().catch((e: unknown) => {
399
+ generator.logger.error(e);
400
+ process.exit(1);
401
+ });
@@ -6,7 +6,7 @@ import {
6
6
  isValidPriceOrWeightCheckDigit,
7
7
  priceOrWeightCheckDigit
8
8
  } from "@aidc-toolkit/gs1";
9
- import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
9
+ import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
10
10
  import { LibProxy } from "../lib-proxy.js";
11
11
  import { proxy } from "../proxy.js";
12
12
  import type { ErrorExtends, Matrix, MatrixResult, SingletonResult } from "../type.js";
@@ -14,7 +14,7 @@ import type { ErrorExtends, Matrix, MatrixResult, SingletonResult } from "../typ
14
14
  const checkSParameterDescriptor: ParameterDescriptor = {
15
15
  name: "checkS",
16
16
  type: Types.String,
17
- isMatrix: true,
17
+ multiplicity: Multiplicities.Matrix,
18
18
  isRequired: true
19
19
  };
20
20
 
@@ -39,7 +39,7 @@ const checkDigitParameterDescriptor: ExtendsParameterDescriptor = {
39
39
  extendsDescriptor: numericSParameterDescriptor,
40
40
  sortOrder: 2,
41
41
  name: "checkDigit",
42
- isMatrix: false
42
+ multiplicity: Multiplicities.Singleton
43
43
  };
44
44
 
45
45
  const ai82SParameterDescriptor: ExtendsParameterDescriptor = {
@@ -53,12 +53,13 @@ const ai82SWithCheckCharacterPairParameterDescriptor: ExtendsParameterDescriptor
53
53
  };
54
54
 
55
55
  @proxy.describeClass(false, {
56
- namespace: "GS1"
56
+ namespace: "GS1",
57
+ category: "checkCharacter"
57
58
  })
58
59
  export class CheckProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
59
60
  @proxy.describeMethod({
60
61
  type: Types.String,
61
- isMatrix: true,
62
+ multiplicity: Multiplicities.Matrix,
62
63
  parameterDescriptors: [numericSParameterDescriptor]
63
64
  })
64
65
  checkDigit(matrixSs: Matrix<string>): MatrixResult<string, ThrowError, TError> {
@@ -67,7 +68,7 @@ export class CheckProxy<ThrowError extends boolean, TError extends ErrorExtends<
67
68
 
68
69
  @proxy.describeMethod({
69
70
  type: Types.String,
70
- isMatrix: true,
71
+ multiplicity: Multiplicities.Matrix,
71
72
  parameterDescriptors: [numericSWithCheckDigitParameterDescriptor]
72
73
  })
73
74
  hasValidCheckDigit(matrixSs: Matrix<string>): MatrixResult<boolean, ThrowError, TError> {
@@ -76,7 +77,7 @@ export class CheckProxy<ThrowError extends boolean, TError extends ErrorExtends<
76
77
 
77
78
  @proxy.describeMethod({
78
79
  type: Types.String,
79
- isMatrix: true,
80
+ multiplicity: Multiplicities.Matrix,
80
81
  parameterDescriptors: [numericSFourOrFiveDigitsParameterDescriptor]
81
82
  })
82
83
  priceOrWeightCheckDigit(matrixSs: Matrix<string>): MatrixResult<string, ThrowError, TError> {
@@ -85,10 +86,10 @@ export class CheckProxy<ThrowError extends boolean, TError extends ErrorExtends<
85
86
 
86
87
  @proxy.describeMethod({
87
88
  type: Types.String,
88
- isMatrix: false,
89
+ multiplicity: Multiplicities.Singleton,
89
90
  parameterDescriptors: [{
90
91
  ...numericSFourOrFiveDigitsParameterDescriptor,
91
- isMatrix: false
92
+ multiplicity: Multiplicities.Singleton
92
93
  }, checkDigitParameterDescriptor]
93
94
  })
94
95
  isValidPriceOrWeightCheckDigit(s: string, checkDigit: string): SingletonResult<boolean, ThrowError, TError> {
@@ -97,7 +98,7 @@ export class CheckProxy<ThrowError extends boolean, TError extends ErrorExtends<
97
98
 
98
99
  @proxy.describeMethod({
99
100
  type: Types.String,
100
- isMatrix: true,
101
+ multiplicity: Multiplicities.Matrix,
101
102
  parameterDescriptors: [ai82SParameterDescriptor]
102
103
  })
103
104
  checkCharacterPair(matrixSs: Matrix<string>): MatrixResult<string, ThrowError, TError> {
@@ -106,7 +107,7 @@ export class CheckProxy<ThrowError extends boolean, TError extends ErrorExtends<
106
107
 
107
108
  @proxy.describeMethod({
108
109
  type: Types.String,
109
- isMatrix: true,
110
+ multiplicity: Multiplicities.Matrix,
110
111
  parameterDescriptors: [ai82SWithCheckCharacterPairParameterDescriptor]
111
112
  })
112
113
  hasValidCheckCharacterPair(matrixSs: Matrix<string>): MatrixResult<boolean, ThrowError, TError> {
@@ -1,7 +1,7 @@
1
1
  import type { Nullishable } from "@aidc-toolkit/core";
2
2
  import type { GTINCreator, GTINType } from "@aidc-toolkit/gs1";
3
3
  import type { AppExtension } from "../app-extension.js";
4
- import { Types } from "../descriptor.js";
4
+ import { Multiplicities, Types } from "../descriptor.js";
5
5
  import { expandParameterDescriptor, proxy } from "../proxy.js";
6
6
  import type { ErrorExtends, Matrix, MatrixResult } from "../type.js";
7
7
  import { valueParameterDescriptor } from "../utility/transformer-descriptor.js";
@@ -13,7 +13,6 @@ import {
13
13
  } from "./prefix-definition-descriptor.js";
14
14
 
15
15
  @proxy.describeClass(false, {
16
- namespace: "GS1",
17
16
  methodInfix: "GTIN",
18
17
  replacementParameterDescriptors: [
19
18
  {
@@ -29,7 +28,7 @@ export class GTINCreatorProxy<ThrowError extends boolean, TError extends ErrorEx
29
28
 
30
29
  @proxy.describeMethod({
31
30
  type: Types.String,
32
- isMatrix: true,
31
+ multiplicity: Multiplicities.Matrix,
33
32
  ignoreInfix: true,
34
33
  parameterDescriptors: [indicatorDigitParameterDescriptor, prefixDefinitionAnyParameterDescriptor, valueParameterDescriptor, sparseParameterDescriptor]
35
34
  })
@@ -1,8 +1,8 @@
1
- import { type ParameterDescriptor, Types } from "../descriptor.js";
1
+ import { Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
2
2
 
3
3
  export const indicatorDigitParameterDescriptor: ParameterDescriptor = {
4
4
  name: "indicatorDigit",
5
5
  type: Types.String,
6
- isMatrix: false,
6
+ multiplicity: Multiplicities.Singleton,
7
7
  isRequired: true
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import type { Nullishable } from "@aidc-toolkit/core";
2
2
  import { GTINLengths, type GTINLevel, GTINValidator, IdentifierValidators } from "@aidc-toolkit/gs1";
3
3
  import type { AppExtension } from "../app-extension.js";
4
- import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
4
+ import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
5
5
  import { LibProxy } from "../lib-proxy.js";
6
6
  import { proxy } from "../proxy.js";
7
7
  import type { ErrorExtends, Matrix, MatrixResult } from "../type.js";
@@ -10,7 +10,6 @@ import { identifierParameterDescriptor } from "./identifier-descriptor.js";
10
10
  import { GTINValidatorProxy } from "./identifier-validator-proxy.js";
11
11
 
12
12
  @proxy.describeClass(false, {
13
- namespace: "GS1",
14
13
  methodInfix: "GTIN13"
15
14
  })
16
15
  export class GTIN13ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
@@ -20,7 +19,6 @@ export class GTIN13ValidatorProxy<ThrowError extends boolean, TError extends Err
20
19
  }
21
20
 
22
21
  @proxy.describeClass(false, {
23
- namespace: "GS1",
24
22
  methodInfix: "GTIN12"
25
23
  })
26
24
  export class GTIN12ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
@@ -30,7 +28,6 @@ export class GTIN12ValidatorProxy<ThrowError extends boolean, TError extends Err
30
28
  }
31
29
 
32
30
  @proxy.describeClass(false, {
33
- namespace: "GS1",
34
31
  methodInfix: "GTIN8"
35
32
  })
36
33
  export class GTIN8ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
@@ -67,7 +64,7 @@ const validateGTINParameterDescriptor: ExtendsParameterDescriptor = {
67
64
  const gtinLevelParameterDescriptor: ParameterDescriptor = {
68
65
  name: "gtinLevel",
69
66
  type: Types.Number,
70
- isMatrix: false,
67
+ multiplicity: Multiplicities.Singleton,
71
68
  isRequired: false
72
69
  };
73
70
 
@@ -77,12 +74,13 @@ const validateGTIN14ParameterDescriptor: ExtendsParameterDescriptor = {
77
74
  };
78
75
 
79
76
  @proxy.describeClass(false, {
80
- namespace: "GS1"
77
+ namespace: "GS1",
78
+ category: "identifierValidation"
81
79
  })
82
80
  export class GTINValidatorStaticProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
83
81
  @proxy.describeMethod({
84
82
  type: Types.String,
85
- isMatrix: true,
83
+ multiplicity: Multiplicities.Matrix,
86
84
  parameterDescriptors: [zeroSuppressibleGTIN12ParameterDescriptor]
87
85
  })
88
86
  zeroSuppressGTIN12(matrixGTIN12s: Matrix<string>): MatrixResult<string, ThrowError, TError> {
@@ -91,7 +89,7 @@ export class GTINValidatorStaticProxy<ThrowError extends boolean, TError extends
91
89
 
92
90
  @proxy.describeMethod({
93
91
  type: Types.String,
94
- isMatrix: true,
92
+ multiplicity: Multiplicities.Matrix,
95
93
  parameterDescriptors: [zeroSuppressedGTIN12ParameterDescriptor]
96
94
  })
97
95
  zeroExpandGTIN12(matrixZeroSuppressedGTIN12s: Matrix<string>): MatrixResult<string, ThrowError, TError> {
@@ -100,7 +98,7 @@ export class GTINValidatorStaticProxy<ThrowError extends boolean, TError extends
100
98
 
101
99
  @proxy.describeMethod({
102
100
  type: Types.String,
103
- isMatrix: true,
101
+ multiplicity: Multiplicities.Matrix,
104
102
  parameterDescriptors: [indicatorDigitParameterDescriptor, convertGTINParameterDescriptor]
105
103
  })
106
104
  convertToGTIN14(indicatorDigit: string, matrixGTINs: Matrix<string>): MatrixResult<string, ThrowError, TError> {
@@ -109,7 +107,7 @@ export class GTINValidatorStaticProxy<ThrowError extends boolean, TError extends
109
107
 
110
108
  @proxy.describeMethod({
111
109
  type: Types.String,
112
- isMatrix: true,
110
+ multiplicity: Multiplicities.Matrix,
113
111
  parameterDescriptors: [normalizeGTINParameterDescriptor]
114
112
  })
115
113
  normalizeGTIN(matrixGTINs: Matrix<string>): MatrixResult<string, ThrowError, TError> {
@@ -118,7 +116,7 @@ export class GTINValidatorStaticProxy<ThrowError extends boolean, TError extends
118
116
 
119
117
  @proxy.describeMethod({
120
118
  type: Types.String,
121
- isMatrix: true,
119
+ multiplicity: Multiplicities.Matrix,
122
120
  parameterDescriptors: [validateGTINParameterDescriptor, gtinLevelParameterDescriptor]
123
121
  })
124
122
  validateGTIN(matrixGTINs: Matrix<string>, gtinLevel: Nullishable<GTINLevel>): Matrix<string> {
@@ -131,7 +129,7 @@ export class GTINValidatorStaticProxy<ThrowError extends boolean, TError extends
131
129
 
132
130
  @proxy.describeMethod({
133
131
  type: Types.String,
134
- isMatrix: true,
132
+ multiplicity: Multiplicities.Matrix,
135
133
  parameterDescriptors: [validateGTINParameterDescriptor, gtinLevelParameterDescriptor]
136
134
  })
137
135
  isValidGTIN(matrixGTINs: Matrix<string>, gtinLevel: Nullishable<GTINLevel>): Matrix<boolean> {
@@ -140,7 +138,7 @@ export class GTINValidatorStaticProxy<ThrowError extends boolean, TError extends
140
138
 
141
139
  @proxy.describeMethod({
142
140
  type: Types.String,
143
- isMatrix: true,
141
+ multiplicity: Multiplicities.Matrix,
144
142
  parameterDescriptors: [validateGTIN14ParameterDescriptor]
145
143
  })
146
144
  validateGTIN14(matrixGTIN14s: Matrix<string>): Matrix<string> {
@@ -151,7 +149,7 @@ export class GTINValidatorStaticProxy<ThrowError extends boolean, TError extends
151
149
 
152
150
  @proxy.describeMethod({
153
151
  type: Types.String,
154
- isMatrix: true,
152
+ multiplicity: Multiplicities.Matrix,
155
153
  parameterDescriptors: [validateGTIN14ParameterDescriptor]
156
154
  })
157
155
  isValidGTIN14(matrixGTIN14s: Matrix<string>): Matrix<boolean> {