@aidc-toolkit/app-extension 1.0.48-beta → 1.0.49

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 (181) hide show
  1. package/dist/character-set-proxy-BOW94WCe.d.cts +473 -0
  2. package/dist/character-set-proxy-BOW94WCe.d.ts +473 -0
  3. package/dist/chunk-22IRLVWO.js +1 -0
  4. package/dist/chunk-MR63TJ3B.js +1 -0
  5. package/dist/chunk-TWX7TPRC.js +1 -0
  6. package/dist/{descriptor.d.ts → descriptor-D6tZH-vc.d.cts} +13 -13
  7. package/dist/descriptor-D6tZH-vc.d.ts +185 -0
  8. package/dist/generator/index.cjs +17 -0
  9. package/dist/generator/index.d.cts +240 -0
  10. package/dist/generator/index.d.ts +239 -17
  11. package/dist/generator/index.js +1 -2
  12. package/dist/gs1/index.cjs +1 -0
  13. package/dist/gs1/index.d.cts +185 -0
  14. package/dist/gs1/index.d.ts +185 -11
  15. package/dist/gs1/index.js +1 -11
  16. package/dist/index.cjs +17 -0
  17. package/dist/{locale/en/locale-resources.d.ts → index.d.cts} +113 -2
  18. package/dist/index.d.ts +862 -21
  19. package/dist/index.js +1 -7
  20. package/package.json +5 -5
  21. package/src/app-extension.ts +29 -0
  22. package/src/app-helper-proxy.ts +45 -7
  23. package/src/generator/functions-generator.ts +292 -0
  24. package/src/generator/generator.ts +9 -29
  25. package/src/generator/index.ts +1 -0
  26. package/src/generator/locale-resources-generator.ts +9 -7
  27. package/src/gs1/check-proxy.ts +3 -3
  28. package/src/gs1/gtin-validator-proxy.ts +2 -2
  29. package/src/gs1/identifier-validator-proxy.ts +2 -2
  30. package/src/locale/fr/locale-resources.ts +2 -2
  31. package/src/locale/i18n.ts +5 -5
  32. package/src/version.ts +4 -0
  33. package/tsconfig-src.tsbuildinfo +1 -1
  34. package/dist/app-extension.d.ts +0 -198
  35. package/dist/app-extension.d.ts.map +0 -1
  36. package/dist/app-extension.js +0 -133
  37. package/dist/app-extension.js.map +0 -1
  38. package/dist/app-helper-proxy.d.ts +0 -61
  39. package/dist/app-helper-proxy.d.ts.map +0 -1
  40. package/dist/app-helper-proxy.js +0 -333
  41. package/dist/app-helper-proxy.js.map +0 -1
  42. package/dist/descriptor.d.ts.map +0 -1
  43. package/dist/descriptor.js +0 -44
  44. package/dist/descriptor.js.map +0 -1
  45. package/dist/generator/generator.d.ts +0 -124
  46. package/dist/generator/generator.d.ts.map +0 -1
  47. package/dist/generator/generator.js +0 -198
  48. package/dist/generator/generator.js.map +0 -1
  49. package/dist/generator/index.d.ts.map +0 -1
  50. package/dist/generator/index.js.map +0 -1
  51. package/dist/generator/locale-resources-generator.d.ts +0 -2
  52. package/dist/generator/locale-resources-generator.d.ts.map +0 -1
  53. package/dist/generator/locale-resources-generator.js +0 -312
  54. package/dist/generator/locale-resources-generator.js.map +0 -1
  55. package/dist/gs1/character-set-proxy.d.ts +0 -13
  56. package/dist/gs1/character-set-proxy.d.ts.map +0 -1
  57. package/dist/gs1/character-set-proxy.js +0 -126
  58. package/dist/gs1/character-set-proxy.js.map +0 -1
  59. package/dist/gs1/check-proxy.d.ts +0 -11
  60. package/dist/gs1/check-proxy.d.ts.map +0 -1
  61. package/dist/gs1/check-proxy.js +0 -163
  62. package/dist/gs1/check-proxy.js.map +0 -1
  63. package/dist/gs1/gcp-length-proxy.d.ts +0 -11
  64. package/dist/gs1/gcp-length-proxy.d.ts.map +0 -1
  65. package/dist/gs1/gcp-length-proxy.js +0 -187
  66. package/dist/gs1/gcp-length-proxy.js.map +0 -1
  67. package/dist/gs1/gtin-creator-proxy.d.ts +0 -10
  68. package/dist/gs1/gtin-creator-proxy.d.ts.map +0 -1
  69. package/dist/gs1/gtin-creator-proxy.js +0 -85
  70. package/dist/gs1/gtin-creator-proxy.js.map +0 -1
  71. package/dist/gs1/gtin-descriptor.d.ts +0 -3
  72. package/dist/gs1/gtin-descriptor.d.ts.map +0 -1
  73. package/dist/gs1/gtin-descriptor.js +0 -8
  74. package/dist/gs1/gtin-descriptor.js.map +0 -1
  75. package/dist/gs1/gtin-validator-proxy.d.ts +0 -26
  76. package/dist/gs1/gtin-validator-proxy.d.ts.map +0 -1
  77. package/dist/gs1/gtin-validator-proxy.js +0 -256
  78. package/dist/gs1/gtin-validator-proxy.js.map +0 -1
  79. package/dist/gs1/identifier-creator-proxy.d.ts +0 -30
  80. package/dist/gs1/identifier-creator-proxy.d.ts.map +0 -1
  81. package/dist/gs1/identifier-creator-proxy.js +0 -318
  82. package/dist/gs1/identifier-creator-proxy.js.map +0 -1
  83. package/dist/gs1/identifier-descriptor.d.ts +0 -4
  84. package/dist/gs1/identifier-descriptor.d.ts.map +0 -1
  85. package/dist/gs1/identifier-descriptor.js +0 -14
  86. package/dist/gs1/identifier-descriptor.js.map +0 -1
  87. package/dist/gs1/identifier-type.d.ts +0 -22
  88. package/dist/gs1/identifier-type.d.ts.map +0 -1
  89. package/dist/gs1/identifier-type.js +0 -34
  90. package/dist/gs1/identifier-type.js.map +0 -1
  91. package/dist/gs1/identifier-validator-proxy.d.ts +0 -29
  92. package/dist/gs1/identifier-validator-proxy.d.ts.map +0 -1
  93. package/dist/gs1/identifier-validator-proxy.js +0 -212
  94. package/dist/gs1/identifier-validator-proxy.js.map +0 -1
  95. package/dist/gs1/index.d.ts.map +0 -1
  96. package/dist/gs1/index.js.map +0 -1
  97. package/dist/gs1/non-gtin-creator-proxy.d.ts +0 -38
  98. package/dist/gs1/non-gtin-creator-proxy.d.ts.map +0 -1
  99. package/dist/gs1/non-gtin-creator-proxy.js +0 -301
  100. package/dist/gs1/non-gtin-creator-proxy.js.map +0 -1
  101. package/dist/gs1/non-gtin-validator-proxy.d.ts +0 -37
  102. package/dist/gs1/non-gtin-validator-proxy.d.ts.map +0 -1
  103. package/dist/gs1/non-gtin-validator-proxy.js +0 -302
  104. package/dist/gs1/non-gtin-validator-proxy.js.map +0 -1
  105. package/dist/gs1/prefix-definition-descriptor.d.ts +0 -4
  106. package/dist/gs1/prefix-definition-descriptor.d.ts.map +0 -1
  107. package/dist/gs1/prefix-definition-descriptor.js +0 -16
  108. package/dist/gs1/prefix-definition-descriptor.js.map +0 -1
  109. package/dist/gs1/prefix-manager-proxy.d.ts +0 -8
  110. package/dist/gs1/prefix-manager-proxy.d.ts.map +0 -1
  111. package/dist/gs1/prefix-manager-proxy.js +0 -94
  112. package/dist/gs1/prefix-manager-proxy.js.map +0 -1
  113. package/dist/gs1/variable-measure-proxy.d.ts +0 -7
  114. package/dist/gs1/variable-measure-proxy.d.ts.map +0 -1
  115. package/dist/gs1/variable-measure-proxy.js +0 -114
  116. package/dist/gs1/variable-measure-proxy.js.map +0 -1
  117. package/dist/gs1/verified-by-gs1-proxy.d.ts +0 -7
  118. package/dist/gs1/verified-by-gs1-proxy.d.ts.map +0 -1
  119. package/dist/gs1/verified-by-gs1-proxy.js +0 -106
  120. package/dist/gs1/verified-by-gs1-proxy.js.map +0 -1
  121. package/dist/index.d.ts.map +0 -1
  122. package/dist/index.js.map +0 -1
  123. package/dist/lib-proxy.d.ts +0 -135
  124. package/dist/lib-proxy.d.ts.map +0 -1
  125. package/dist/lib-proxy.js +0 -276
  126. package/dist/lib-proxy.js.map +0 -1
  127. package/dist/locale/en/locale-resources.d.ts.map +0 -1
  128. package/dist/locale/en/locale-resources.js +0 -754
  129. package/dist/locale/en/locale-resources.js.map +0 -1
  130. package/dist/locale/fr/locale-resources.d.ts +0 -755
  131. package/dist/locale/fr/locale-resources.d.ts.map +0 -1
  132. package/dist/locale/fr/locale-resources.js +0 -754
  133. package/dist/locale/fr/locale-resources.js.map +0 -1
  134. package/dist/locale/i18n.d.ts +0 -27
  135. package/dist/locale/i18n.d.ts.map +0 -1
  136. package/dist/locale/i18n.js +0 -36
  137. package/dist/locale/i18n.js.map +0 -1
  138. package/dist/proxy.d.ts +0 -136
  139. package/dist/proxy.d.ts.map +0 -1
  140. package/dist/proxy.js +0 -291
  141. package/dist/proxy.js.map +0 -1
  142. package/dist/streaming.d.ts +0 -10
  143. package/dist/streaming.d.ts.map +0 -1
  144. package/dist/streaming.js +0 -2
  145. package/dist/streaming.js.map +0 -1
  146. package/dist/type.d.ts +0 -91
  147. package/dist/type.d.ts.map +0 -1
  148. package/dist/type.js +0 -2
  149. package/dist/type.js.map +0 -1
  150. package/dist/utility/character-set-descriptor.d.ts +0 -6
  151. package/dist/utility/character-set-descriptor.d.ts.map +0 -1
  152. package/dist/utility/character-set-descriptor.js +0 -28
  153. package/dist/utility/character-set-descriptor.js.map +0 -1
  154. package/dist/utility/character-set-proxy.d.ts +0 -31
  155. package/dist/utility/character-set-proxy.d.ts.map +0 -1
  156. package/dist/utility/character-set-proxy.js +0 -278
  157. package/dist/utility/character-set-proxy.js.map +0 -1
  158. package/dist/utility/index.d.ts +0 -4
  159. package/dist/utility/index.d.ts.map +0 -1
  160. package/dist/utility/index.js +0 -4
  161. package/dist/utility/index.js.map +0 -1
  162. package/dist/utility/reg-exp-proxy.d.ts +0 -8
  163. package/dist/utility/reg-exp-proxy.d.ts.map +0 -1
  164. package/dist/utility/reg-exp-proxy.js +0 -103
  165. package/dist/utility/reg-exp-proxy.js.map +0 -1
  166. package/dist/utility/string-descriptor.d.ts +0 -4
  167. package/dist/utility/string-descriptor.d.ts.map +0 -1
  168. package/dist/utility/string-descriptor.js +0 -12
  169. package/dist/utility/string-descriptor.js.map +0 -1
  170. package/dist/utility/string-proxy.d.ts +0 -7
  171. package/dist/utility/string-proxy.d.ts.map +0 -1
  172. package/dist/utility/string-proxy.js +0 -63
  173. package/dist/utility/string-proxy.js.map +0 -1
  174. package/dist/utility/transformer-descriptor.d.ts +0 -6
  175. package/dist/utility/transformer-descriptor.d.ts.map +0 -1
  176. package/dist/utility/transformer-descriptor.js +0 -24
  177. package/dist/utility/transformer-descriptor.js.map +0 -1
  178. package/dist/utility/transformer-proxy.d.ts +0 -9
  179. package/dist/utility/transformer-proxy.d.ts.map +0 -1
  180. package/dist/utility/transformer-proxy.js +0 -111
  181. package/dist/utility/transformer-proxy.js.map +0 -1
@@ -1,124 +0,0 @@
1
- import { type Promisable } from "@aidc-toolkit/core";
2
- import type { Logger } from "tslog";
3
- import type { ClassDescriptor, MethodDescriptor } from "../descriptor.js";
4
- /**
5
- * Localization.
6
- */
7
- export interface Localization {
8
- /**
9
- * Name.
10
- */
11
- readonly name: string;
12
- /**
13
- * Description.
14
- */
15
- readonly description: string;
16
- }
17
- /**
18
- * Function localization.
19
- */
20
- export interface FunctionLocalization extends Localization {
21
- /**
22
- * Name in title case.
23
- */
24
- readonly titleCaseName: string;
25
- /**
26
- * Documentation URL.
27
- */
28
- readonly documentationURL: string;
29
- /**
30
- * Parameters map.
31
- */
32
- readonly parametersMap: ReadonlyMap<string, Localization>;
33
- }
34
- /**
35
- * Abstract generator.
36
- */
37
- export declare abstract class Generator {
38
- #private;
39
- /**
40
- * Constructor.
41
- *
42
- * @param version
43
- * Package version.
44
- *
45
- * @param includeLocalizations
46
- * Include localizations if true.
47
- */
48
- constructor(version: string, includeLocalizations?: boolean);
49
- /**
50
- * Get the logger.
51
- */
52
- get logger(): Logger<object>;
53
- /**
54
- * Get the package version.
55
- */
56
- get version(): string;
57
- /**
58
- * Get the locales.
59
- */
60
- protected get locales(): readonly string[];
61
- /**
62
- * Get the default locale.
63
- */
64
- protected get defaultLocale(): string;
65
- /**
66
- * Initialize the generation of the output.
67
- */
68
- protected abstract initialize(): Promisable<void>;
69
- /**
70
- * Create a namespace.
71
- *
72
- * @param namespace
73
- * Namespace.
74
- */
75
- protected abstract createNamespace(namespace: string | undefined): void;
76
- /**
77
- * Create a category.
78
- *
79
- * @param namespace
80
- * Namespace.
81
- *
82
- * @param category
83
- * Category.
84
- *
85
- * @param categoryLocalizationsMap
86
- * Category localizations map.
87
- */
88
- protected abstract createCategory(namespace: string | undefined, category: string, categoryLocalizationsMap: ReadonlyMap<string, string>): void;
89
- /**
90
- * Create a proxy object for a class.
91
- *
92
- * @param objectName
93
- * Object name, derived from namespace and class name.
94
- *
95
- * @param classDescriptor
96
- * Class descriptor.
97
- */
98
- protected abstract createProxyObject(objectName: string, classDescriptor: ClassDescriptor): void;
99
- /**
100
- * Create a proxy function for a class and method.
101
- *
102
- * @param classDescriptor
103
- * Class descriptor.
104
- *
105
- * @param methodDescriptor
106
- * Method descriptor.
107
- *
108
- * @param functionLocalizationsMap
109
- * Function localizations map.
110
- */
111
- protected abstract createProxyFunction(classDescriptor: ClassDescriptor, methodDescriptor: MethodDescriptor, functionLocalizationsMap: ReadonlyMap<string, FunctionLocalization>): void;
112
- /**
113
- * Finalize the generation of the output.
114
- *
115
- * @param success
116
- * True if successful.
117
- */
118
- protected abstract finalize(success: boolean): Promisable<void>;
119
- /**
120
- * Generate by processing individual imports.
121
- */
122
- generate(): Promise<void>;
123
- }
124
- //# sourceMappingURL=generator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/generator/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,UAAU,EAAc,MAAM,oBAAoB,CAAC;AAEzG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAiB1E;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACtD;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC7D;AAED;;GAEG;AACH,8BAAsB,SAAS;;IA0B3B;;;;;;;;OAQG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xy } from "../app-helper-proxy.js";
3
- import * as GS1 from "../gs1/index.js";
4
- import { appExtensionResourceBundle, i18nAppExtensionInit, i18nextAppExtension } from "../locale/i18n.js";
5
- import { proxy } from "../proxy.js";
6
- import * as Utility from "../utility/index.js";
7
- /**
8
- * Dummy method to force proxies to register their decorators.
9
- *
10
- * @param _proxies
11
- * Proxies.
12
- */
13
- function registerProxies(..._proxies) {
14
- }
15
- registerProxies(AppHelperProxy, Utility, GS1);
16
- /**
17
- * Abstract generator.
18
- */
19
- export class Generator {
20
- /**
21
- * Documentation path, optionally preceded by locale.
22
- */
23
- static #DOCUMENTATION_PATH = "app-extension/";
24
- /**
25
- * Logger.
26
- */
27
- #logger = getLogger();
28
- /**
29
- * Package version.
30
- */
31
- #version;
32
- /**
33
- * Locales.
34
- */
35
- #locales;
36
- /**
37
- * Default locale.
38
- */
39
- #defaultLocale;
40
- /**
41
- * Constructor.
42
- *
43
- * @param version
44
- * Package version.
45
- *
46
- * @param includeLocalizations
47
- * Include localizations if true.
48
- */
49
- constructor(version, includeLocalizations = true) {
50
- this.#version = version;
51
- this.#locales = includeLocalizations ? Object.keys(appExtensionResourceBundle) : [];
52
- this.#defaultLocale = this.#locales[0] ?? "";
53
- }
54
- /**
55
- * Get the logger.
56
- */
57
- get logger() {
58
- return this.#logger;
59
- }
60
- /**
61
- * Get the package version.
62
- */
63
- get version() {
64
- return this.#version;
65
- }
66
- /**
67
- * Get the locales.
68
- */
69
- get locales() {
70
- return this.#locales;
71
- }
72
- /**
73
- * Get the default locale.
74
- */
75
- get defaultLocale() {
76
- return this.#defaultLocale;
77
- }
78
- /**
79
- * Generate a localization.
80
- *
81
- * @template TLocalization
82
- * Localization type.
83
- *
84
- * @param locale
85
- * Locale.
86
- *
87
- * @param key
88
- * Key.
89
- *
90
- * @param localizationCallback
91
- * Callback to finalize localization.
92
- *
93
- * @returns
94
- * Localization.
95
- */
96
- static #generateLocalization(locale, key, localizationCallback) {
97
- const lngReturnObjectsOption = {
98
- lng: locale,
99
- returnObjects: true
100
- };
101
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Assume localized key exists.
102
- const parseKey = key;
103
- if (!i18nextAppExtension.exists(parseKey, lngReturnObjectsOption)) {
104
- throw new Error(`Missing localization for ${key} in ${locale}`);
105
- }
106
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Localized key exists and return type is Localization & Partial<TLocalization>.
107
- return localizationCallback(locale, i18nextAppExtension.t(key, lngReturnObjectsOption));
108
- }
109
- /**
110
- * Generate by processing individual imports.
111
- */
112
- async generate() {
113
- let success = false;
114
- await i18nAppExtensionInit(I18nEnvironments.CLI);
115
- const documentationBaseURL = websiteURL(this.version, true, await ALPHA_URL);
116
- await this.initialize();
117
- const namespaceHierarchy = new Map();
118
- // Organize class descriptors by namespace and category.
119
- for (const classDescriptor of proxy.classDescriptors) {
120
- const namespace = classDescriptor.namespace;
121
- const category = classDescriptor.category;
122
- let categoryHierarchy = namespaceHierarchy.get(namespace);
123
- if (categoryHierarchy === undefined) {
124
- categoryHierarchy = new Map();
125
- namespaceHierarchy.set(namespace, categoryHierarchy);
126
- }
127
- let classDescriptors = categoryHierarchy.get(category);
128
- if (classDescriptors === undefined) {
129
- classDescriptors = [];
130
- categoryHierarchy.set(category, classDescriptors);
131
- }
132
- classDescriptors.push(classDescriptor);
133
- }
134
- try {
135
- for (const [namespace, categoryHierarchy] of namespaceHierarchy) {
136
- const namespacePrefix = namespace === undefined ? "" : `${namespace}.`;
137
- const namespacePath = namespace === undefined ? "" : `${namespace}/`;
138
- this.createNamespace(namespace);
139
- for (const [category, classDescriptors] of categoryHierarchy) {
140
- const namespaceCategory = `${namespacePrefix}${category}`;
141
- const categoriesKey = `Categories.${category}`;
142
- const namespaceCategoriesKey = `Categories.${namespaceCategory}`;
143
- const categoryLocalizationsMap = new Map(this.locales.map((locale) => {
144
- const lngOption = {
145
- lng: locale
146
- };
147
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Localized key exists.
148
- return [locale, i18nextAppExtension.t((i18nextAppExtension.exists(namespaceCategoriesKey, lngOption) ? namespaceCategoriesKey : categoriesKey), lngOption)];
149
- }));
150
- this.createCategory(namespace, category, categoryLocalizationsMap);
151
- const namespaceClassNamesSet = new Set();
152
- for (const classDescriptor of classDescriptors) {
153
- const namespaceClassName = `${namespacePrefix}${classDescriptor.name}`;
154
- if (namespaceClassNamesSet.has(namespaceClassName)) {
155
- throw new Error(`Duplicate class ${namespaceClassName}`);
156
- }
157
- namespaceClassNamesSet.add(namespaceClassName);
158
- // First capture group is:
159
- // - one or more uppercase letters followed by zero or more numbers; or
160
- // - single uppercase letter followed by zero or more characters except uppercase letters or period.
161
- //
162
- // Second capture group is:
163
- // - single uppercase letter followed by zero or more characters except period; or
164
- // - zero characters (empty string).
165
- //
166
- // Third capture group, separated by optional period, is:
167
- // - single uppercase letter followed by zero or more characters (remainder of string); or
168
- // - zero characters (empty string).
169
- const objectNameGroups = /^(?<namespaceFirstWord>[A-Z]+[0-9]*|[A-Z][^A-Z.]*)(?<namespaceRemaining>[A-Z][^.]*|)\.?(?<className>[A-Z].*|)$/u.exec(namespaceClassName)?.groups;
170
- if (objectNameGroups === undefined) {
171
- throw new Error(`${namespaceClassName} is not a valid namespace-qualified class name`);
172
- }
173
- this.createProxyObject(`${objectNameGroups["namespaceFirstWord"].toLowerCase()}${objectNameGroups["namespaceRemaining"]}${objectNameGroups["className"]}`, classDescriptor);
174
- for (const methodDescriptor of classDescriptor.methodDescriptors) {
175
- const functionLocalizationsMap = new Map(methodDescriptor.isHidden !== true ?
176
- this.locales.map(locale => [locale, Generator.#generateLocalization(locale, `Functions.${namespacePrefix}${methodDescriptor.functionName}`, (locale, localization) => ({
177
- ...localization,
178
- titleCaseName: localization.titleCaseName ?? `${localization.name.substring(0, 1).toUpperCase()}${localization.name.substring(1)}`,
179
- documentationURL: `${documentationBaseURL}/${locale === this.defaultLocale ? "" : `${locale}/`}${Generator.#DOCUMENTATION_PATH}${namespacePath}${localization.name}.html`,
180
- parametersMap: new Map(methodDescriptor.parameterDescriptors.map(parameterDescriptor =>
181
- // eslint-disable-next-line max-nested-callbacks -- Callback is empty.
182
- [parameterDescriptor.name, Generator.#generateLocalization(locale, `Parameters.${parameterDescriptor.name}`, (_locale, localization) => localization)]))
183
- }))]) :
184
- // Hidden methods are not localized.
185
- []);
186
- this.createProxyFunction(classDescriptor, methodDescriptor, functionLocalizationsMap);
187
- }
188
- }
189
- }
190
- }
191
- success = true;
192
- }
193
- finally {
194
- await this.finalize(success);
195
- }
196
- }
197
- }
198
- //# sourceMappingURL=generator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/generator/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAmB,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGzG,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1G,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAE/C;;;;;GAKG;AACH,SAAS,eAAe,CAAC,GAAG,QAAmB;AAC/C,CAAC;AAED,eAAe,CAAC,cAAc,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;AAqC9C;;GAEG;AACH,MAAM,OAAgB,SAAS;IAC3B;;OAEG;IACH,MAAM,CAAU,mBAAmB,GAAG,gBAAgB,CAAC;IAEvD;;OAEG;IACM,OAAO,GAAG,SAAS,EAAE,CAAC;IAE/B;;OAEG;IACM,QAAQ,CAAS;IAE1B;;OAEG;IACM,QAAQ,CAAoB;IAErC;;OAEG;IACM,cAAc,CAAS;IAEhC;;;;;;;;OAQG;IACH,YAA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AAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,GAAG,SAAS,CAAC,mBAAmB,GAAG,aAAa,GAAG,YAAY,CAAC,IAAI,OAAO;wCACzK,aAAa,EAAE,IAAI,GAAG,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE;wCACnF,sEAAsE;wCACtE,CAAC,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,qBAAqB,CAAC,MAAM,EAAE,cAAc,mBAAmB,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CACzJ,CAAC;qCACL,CAAC,CAAC,CAAC,CACP,CAAC,CAAC;gCACH,oCAAoC;gCACpC,EAAE,CACL,CAAC;4BAEF,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,gBAAgB,EAAE,wBAAwB,CAAC,CAAC;wBAC1F,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;YAED,OAAO,GAAG,IAAI,CAAC;QACnB,CAAC;gBAAS,CAAC;YACP,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;IACL,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,gBAAgB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,gBAAgB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=locale-resources-generator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"locale-resources-generator.d.ts","sourceRoot":"","sources":["../../src/generator/locale-resources-generator.ts"],"names":[],"mappings":""}
@@ -1,312 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as path from "node:path";
3
- import packageConfiguration from "../../package.json" with { type: "json" };
4
- import { Generator } from "./generator.js";
5
- /**
6
- * Locale resources generator.
7
- */
8
- class LocaleResourcesGenerator extends Generator {
9
- /**
10
- * Locale resources import path.
11
- */
12
- static #IMPORT_PATH = "../app-extension/src/locale";
13
- /**
14
- * Parameters sequencer.
15
- */
16
- #parametersSequencer = {};
17
- /**
18
- * Parameters locale resources.
19
- */
20
- #parametersLocaleResources = {};
21
- /**
22
- * Functions locale resources.
23
- */
24
- #functionsLocaleResources = {};
25
- /**
26
- * Locale resources.
27
- */
28
- #LocaleResources = {
29
- Parameters: this.#parametersLocaleResources,
30
- Functions: this.#functionsLocaleResources
31
- };
32
- /**
33
- * Constructor.
34
- */
35
- constructor() {
36
- super(packageConfiguration.version, false);
37
- }
38
- /**
39
- * @inheritDoc
40
- */
41
- initialize() {
42
- }
43
- /**
44
- * @inheritDoc
45
- */
46
- createNamespace() {
47
- }
48
- /**
49
- * @inheritDoc
50
- */
51
- createCategory() {
52
- }
53
- /**
54
- * @inheritDoc
55
- */
56
- createProxyObject() {
57
- }
58
- /**
59
- * Save a parameter descriptor in the appropriate spot in the sequence.
60
- *
61
- * @param parameterDescriptor
62
- * Parameter descriptor.
63
- *
64
- * @param isUsed
65
- * True if parameter descriptor is actually used and not just a base.
66
- *
67
- * @returns
68
- * Parameters sequencer entry.
69
- */
70
- #saveParameterSequence(parameterDescriptor, isUsed) {
71
- let parametersSequencerEntry;
72
- if (!("extendsDescriptor" in parameterDescriptor)) {
73
- const parameterName = parameterDescriptor.name;
74
- // Create entry if it doesn't exist, otherwise pick up where last call left off.
75
- if (!(parameterName in this.#parametersSequencer)) {
76
- parametersSequencerEntry = {
77
- parametersSequencerOrNull: null,
78
- parameterDescriptor,
79
- parameterName,
80
- baseParameterName: parameterName,
81
- isUsed
82
- };
83
- this.#parametersSequencer[parameterName] = parametersSequencerEntry;
84
- }
85
- else {
86
- parametersSequencerEntry = this.#parametersSequencer[parameterName];
87
- }
88
- }
89
- else {
90
- const baseParametersSequencerEntry = this.#saveParameterSequence(parameterDescriptor.extendsDescriptor, false);
91
- let parameterName;
92
- let baseParameterName;
93
- if (parameterDescriptor.name !== undefined) {
94
- parameterName = parameterDescriptor.name;
95
- baseParameterName = baseParametersSequencerEntry.parameterName;
96
- }
97
- else {
98
- parameterName = baseParametersSequencerEntry.parameterName;
99
- baseParameterName = baseParametersSequencerEntry.baseParameterName;
100
- }
101
- if (parameterName !== baseParameterName) {
102
- // Make sure that base parameters sequencer entry refers to a record type.
103
- baseParametersSequencerEntry.parametersSequencerOrNull ??= {};
104
- if (!(parameterName in baseParametersSequencerEntry.parametersSequencerOrNull)) {
105
- parametersSequencerEntry = {
106
- parametersSequencerOrNull: null,
107
- parameterDescriptor,
108
- parameterName,
109
- baseParameterName,
110
- isUsed
111
- };
112
- baseParametersSequencerEntry.parametersSequencerOrNull[parameterName] = parametersSequencerEntry;
113
- }
114
- else {
115
- parametersSequencerEntry = baseParametersSequencerEntry.parametersSequencerOrNull[parameterName];
116
- }
117
- }
118
- else {
119
- // If name is the same, which means that parameter descriptor modified type information only.
120
- parametersSequencerEntry = baseParametersSequencerEntry;
121
- }
122
- }
123
- return parametersSequencerEntry;
124
- }
125
- /**
126
- * @inheritDoc
127
- */
128
- createProxyFunction(classDescriptor, methodDescriptor) {
129
- // Hidden functions aren't localized.
130
- if (methodDescriptor.isHidden !== true) {
131
- // Add any parameters that are not already known.
132
- for (const parameterDescriptor of methodDescriptor.parameterDescriptors) {
133
- this.#saveParameterSequence(parameterDescriptor, true);
134
- }
135
- let functionsLocaleResources = this.#functionsLocaleResources;
136
- const namespace = classDescriptor.namespace;
137
- if (namespace !== undefined) {
138
- if (!(namespace in functionsLocaleResources)) {
139
- const namespaceFunctionsLocaleResources = {};
140
- // Add namespace and navigate to it.
141
- functionsLocaleResources[namespace] = namespaceFunctionsLocaleResources;
142
- functionsLocaleResources = namespaceFunctionsLocaleResources;
143
- }
144
- else {
145
- // Navigate to namespace.
146
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Entry is never a string.
147
- functionsLocaleResources = functionsLocaleResources[namespace];
148
- }
149
- }
150
- const functionName = methodDescriptor.functionName;
151
- if (functionName in functionsLocaleResources) {
152
- throw new Error(`Duplicate function ${functionName}`);
153
- }
154
- // Add function.
155
- functionsLocaleResources[functionName] = {
156
- name: functionName,
157
- description: "*** LOCALIZATION REQUIRED ***"
158
- };
159
- }
160
- }
161
- /**
162
- * Merge source locale resources into existing destination locale resources.
163
- *
164
- * @param logChanges
165
- * If true, changes are logged. Limits output when processing multiple sources.
166
- *
167
- * @param parentKey
168
- * Parent key for logging purposes.
169
- *
170
- * @param sourceLocaleResources
171
- * Source locale resources.
172
- *
173
- * @param destinationLocaleResources
174
- * Destination locale resources.
175
- *
176
- * @param addMissing
177
- * Add missing if true; applies to locale resources that are not regional.
178
- *
179
- * @returns
180
- * Merged locale resources.
181
- */
182
- #merge(logChanges, parentKey, sourceLocaleResources, destinationLocaleResources, addMissing) {
183
- // Some entries at the top are not part of the generator output.
184
- const deleteMissing = parentKey.length !== 0;
185
- const newDestinationLocaleResources = {};
186
- // Copy over or delete any destination keys that are not in source.
187
- for (const [key, destinationValue] of Object.entries(destinationLocaleResources)) {
188
- if (!(key in sourceLocaleResources)) {
189
- if (!deleteMissing) {
190
- newDestinationLocaleResources[key] = destinationValue;
191
- }
192
- else if (logChanges) {
193
- this.logger.info(`Deleting ${parentKey}${key}...`);
194
- }
195
- }
196
- }
197
- for (const [key, sourceValue] of Object.entries(sourceLocaleResources)) {
198
- if (!(key in destinationLocaleResources)) {
199
- if (addMissing) {
200
- if (logChanges) {
201
- this.logger.info(`Adding ${parentKey}${key}...`);
202
- }
203
- newDestinationLocaleResources[key] = sourceValue;
204
- }
205
- }
206
- else {
207
- const destinationValue = destinationLocaleResources[key];
208
- if (typeof sourceValue === "object" && typeof destinationValue === "object") {
209
- newDestinationLocaleResources[key] = this.#merge(logChanges, `${parentKey}${key}.`, sourceValue, destinationValue, addMissing);
210
- }
211
- else if (typeof sourceValue === "string" && typeof destinationValue === "string") {
212
- newDestinationLocaleResources[key] = destinationValue;
213
- }
214
- else {
215
- throw new Error(`Mismatched types at ${parentKey}${key}`);
216
- }
217
- }
218
- }
219
- return newDestinationLocaleResources;
220
- }
221
- /**
222
- * Build parameters locale resources by going through parameters sequencer.
223
- *
224
- * @param parametersSequencer
225
- * Parameters sequencer.
226
- */
227
- #buildParametersLocaleResources(parametersSequencer) {
228
- const entries = Object.entries(parametersSequencer);
229
- // Sort the entries as defined by the descriptors.
230
- entries.sort((entry1, entry2) => {
231
- let result;
232
- const parameterDescriptor1 = entry1[1].parameterDescriptor;
233
- const parameterDescriptor2 = entry2[1].parameterDescriptor;
234
- if ("sortOrder" in parameterDescriptor1) {
235
- if ("sortOrder" in parameterDescriptor2) {
236
- result = parameterDescriptor1.sortOrder - parameterDescriptor2.sortOrder;
237
- }
238
- else {
239
- // Parameter descriptors with undefined sort order to go the end.
240
- result = -parameterDescriptor1.sortOrder;
241
- }
242
- }
243
- else {
244
- // eslint-disable-next-line no-lonely-if -- Matches structure in "then" clause.
245
- if ("sortOrder" in parameterDescriptor2) {
246
- // Parameter descriptors with undefined sort order to go the end.
247
- result = parameterDescriptor2.sortOrder;
248
- }
249
- else {
250
- result = 0;
251
- }
252
- }
253
- return result;
254
- });
255
- for (const [parameterName, parametersSequencerEntry] of entries) {
256
- if (parametersSequencerEntry.isUsed) {
257
- this.#parametersLocaleResources[parameterName] = {
258
- name: parameterName,
259
- description: "*** LOCALIZATION REQUIRED ***"
260
- };
261
- }
262
- if (parametersSequencerEntry.parametersSequencerOrNull !== null) {
263
- this.#buildParametersLocaleResources(parametersSequencerEntry.parametersSequencerOrNull);
264
- }
265
- }
266
- }
267
- /**
268
- * Build output to be written back to source file.
269
- *
270
- * @param prefix
271
- * Line prefix.
272
- *
273
- * @param value
274
- * Line value.
275
- *
276
- * @param indentLevel
277
- * Indent level.
278
- *
279
- * @returns
280
- * Output string.
281
- */
282
- static #buildOutput(prefix, value, indentLevel) {
283
- return `${" ".repeat(indentLevel)}${prefix} ${typeof value === "object" ?
284
- `{\n${Object.entries(value).map(entry => LocaleResourcesGenerator.#buildOutput(`${entry[0]}:`, entry[1], indentLevel + 1)).join(",\n")}\n${" ".repeat(indentLevel)}}` :
285
- // JSON.stringify() will apply quotes as appropriate.
286
- JSON.stringify(value)}`;
287
- }
288
- /**
289
- * @inheritDoc
290
- */
291
- async finalize(success) {
292
- if (success) {
293
- this.#buildParametersLocaleResources(this.#parametersSequencer);
294
- await Promise.all(fs.readdirSync(LocaleResourcesGenerator.#IMPORT_PATH, {
295
- withFileTypes: true
296
- }).filter(entry => entry.isDirectory()).map(async (entry) => {
297
- const localeResourcesSource = path.resolve(LocaleResourcesGenerator.#IMPORT_PATH, entry.name, "locale-resources.ts");
298
- return import(localeResourcesSource).then((module) => {
299
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Module format is known.
300
- const localeResources = this.#merge(entry.name === "en", "", this.#LocaleResources, module.default, !entry.name.includes("-"));
301
- fs.writeFileSync(localeResourcesSource, `${LocaleResourcesGenerator.#buildOutput("export default", localeResources, 0)};\n`);
302
- });
303
- }));
304
- }
305
- }
306
- }
307
- const generator = new LocaleResourcesGenerator();
308
- generator.generate().catch((e) => {
309
- generator.logger.error(e);
310
- process.exit(1);
311
- });
312
- //# sourceMappingURL=locale-resources-generator.js.map