@aidc-toolkit/app-extension 1.0.46 → 1.0.47-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 (168) hide show
  1. package/dist/app-extension.d.ts +198 -0
  2. package/dist/app-extension.d.ts.map +1 -0
  3. package/dist/app-extension.js +133 -0
  4. package/dist/app-extension.js.map +1 -0
  5. package/dist/app-helper-proxy.d.ts +61 -0
  6. package/dist/app-helper-proxy.d.ts.map +1 -0
  7. package/dist/app-helper-proxy.js +333 -0
  8. package/dist/app-helper-proxy.js.map +1 -0
  9. package/dist/{descriptor-FJHoLlYK.d.cts → descriptor.d.ts} +13 -13
  10. package/dist/descriptor.d.ts.map +1 -0
  11. package/dist/descriptor.js +44 -0
  12. package/dist/descriptor.js.map +1 -0
  13. package/dist/generator/{index.d.cts → generator.d.ts} +7 -9
  14. package/dist/generator/generator.d.ts.map +1 -0
  15. package/dist/generator/generator.js +190 -0
  16. package/dist/generator/generator.js.map +1 -0
  17. package/dist/generator/index.d.ts +17 -125
  18. package/dist/generator/index.d.ts.map +1 -0
  19. package/dist/generator/index.js +2 -1
  20. package/dist/generator/index.js.map +1 -0
  21. package/dist/generator/locale-resources-generator.d.ts +2 -0
  22. package/dist/generator/locale-resources-generator.d.ts.map +1 -0
  23. package/dist/generator/locale-resources-generator.js +312 -0
  24. package/dist/generator/locale-resources-generator.js.map +1 -0
  25. package/dist/gs1/character-set-proxy.d.ts +13 -0
  26. package/dist/gs1/character-set-proxy.d.ts.map +1 -0
  27. package/dist/gs1/character-set-proxy.js +126 -0
  28. package/dist/gs1/character-set-proxy.js.map +1 -0
  29. package/dist/gs1/check-proxy.d.ts +11 -0
  30. package/dist/gs1/check-proxy.d.ts.map +1 -0
  31. package/dist/gs1/check-proxy.js +163 -0
  32. package/dist/gs1/check-proxy.js.map +1 -0
  33. package/dist/gs1/gcp-length-proxy.d.ts +11 -0
  34. package/dist/gs1/gcp-length-proxy.d.ts.map +1 -0
  35. package/dist/gs1/gcp-length-proxy.js +190 -0
  36. package/dist/gs1/gcp-length-proxy.js.map +1 -0
  37. package/dist/gs1/gtin-creator-proxy.d.ts +10 -0
  38. package/dist/gs1/gtin-creator-proxy.d.ts.map +1 -0
  39. package/dist/gs1/gtin-creator-proxy.js +85 -0
  40. package/dist/gs1/gtin-creator-proxy.js.map +1 -0
  41. package/dist/gs1/gtin-descriptor.d.ts +3 -0
  42. package/dist/gs1/gtin-descriptor.d.ts.map +1 -0
  43. package/dist/gs1/gtin-descriptor.js +8 -0
  44. package/dist/gs1/gtin-descriptor.js.map +1 -0
  45. package/dist/gs1/gtin-validator-proxy.d.ts +26 -0
  46. package/dist/gs1/gtin-validator-proxy.d.ts.map +1 -0
  47. package/dist/gs1/gtin-validator-proxy.js +256 -0
  48. package/dist/gs1/gtin-validator-proxy.js.map +1 -0
  49. package/dist/gs1/identifier-creator-proxy.d.ts +30 -0
  50. package/dist/gs1/identifier-creator-proxy.d.ts.map +1 -0
  51. package/dist/gs1/identifier-creator-proxy.js +318 -0
  52. package/dist/gs1/identifier-creator-proxy.js.map +1 -0
  53. package/dist/gs1/identifier-descriptor.d.ts +4 -0
  54. package/dist/gs1/identifier-descriptor.d.ts.map +1 -0
  55. package/dist/gs1/identifier-descriptor.js +14 -0
  56. package/dist/gs1/identifier-descriptor.js.map +1 -0
  57. package/dist/gs1/identifier-type.d.ts +22 -0
  58. package/dist/gs1/identifier-type.d.ts.map +1 -0
  59. package/dist/gs1/identifier-type.js +34 -0
  60. package/dist/gs1/identifier-type.js.map +1 -0
  61. package/dist/gs1/identifier-validator-proxy.d.ts +29 -0
  62. package/dist/gs1/identifier-validator-proxy.d.ts.map +1 -0
  63. package/dist/gs1/identifier-validator-proxy.js +212 -0
  64. package/dist/gs1/identifier-validator-proxy.js.map +1 -0
  65. package/dist/gs1/index.d.ts +11 -0
  66. package/dist/gs1/index.d.ts.map +1 -0
  67. package/dist/gs1/index.js +11 -0
  68. package/dist/gs1/index.js.map +1 -0
  69. package/dist/gs1/non-gtin-creator-proxy.d.ts +38 -0
  70. package/dist/gs1/non-gtin-creator-proxy.d.ts.map +1 -0
  71. package/dist/gs1/non-gtin-creator-proxy.js +301 -0
  72. package/dist/gs1/non-gtin-creator-proxy.js.map +1 -0
  73. package/dist/gs1/non-gtin-validator-proxy.d.ts +37 -0
  74. package/dist/gs1/non-gtin-validator-proxy.d.ts.map +1 -0
  75. package/dist/gs1/non-gtin-validator-proxy.js +302 -0
  76. package/dist/gs1/non-gtin-validator-proxy.js.map +1 -0
  77. package/dist/gs1/prefix-definition-descriptor.d.ts +4 -0
  78. package/dist/gs1/prefix-definition-descriptor.d.ts.map +1 -0
  79. package/dist/gs1/prefix-definition-descriptor.js +16 -0
  80. package/dist/gs1/prefix-definition-descriptor.js.map +1 -0
  81. package/dist/gs1/prefix-manager-proxy.d.ts +8 -0
  82. package/dist/gs1/prefix-manager-proxy.d.ts.map +1 -0
  83. package/dist/gs1/prefix-manager-proxy.js +94 -0
  84. package/dist/gs1/prefix-manager-proxy.js.map +1 -0
  85. package/dist/gs1/variable-measure-proxy.d.ts +7 -0
  86. package/dist/gs1/variable-measure-proxy.d.ts.map +1 -0
  87. package/dist/gs1/variable-measure-proxy.js +114 -0
  88. package/dist/gs1/variable-measure-proxy.js.map +1 -0
  89. package/dist/gs1/verified-by-gs1-proxy.d.ts +7 -0
  90. package/dist/gs1/verified-by-gs1-proxy.d.ts.map +1 -0
  91. package/dist/gs1/verified-by-gs1-proxy.js +106 -0
  92. package/dist/gs1/verified-by-gs1-proxy.js.map +1 -0
  93. package/dist/index.d.ts +25 -1557
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +7 -1
  96. package/dist/index.js.map +1 -0
  97. package/dist/lib-proxy.d.ts +135 -0
  98. package/dist/lib-proxy.d.ts.map +1 -0
  99. package/dist/lib-proxy.js +276 -0
  100. package/dist/lib-proxy.js.map +1 -0
  101. package/dist/locale/en/locale-resources.d.ts +752 -0
  102. package/dist/locale/en/locale-resources.d.ts.map +1 -0
  103. package/dist/locale/en/locale-resources.js +751 -0
  104. package/dist/locale/en/locale-resources.js.map +1 -0
  105. package/dist/locale/fr/locale-resources.d.ts +752 -0
  106. package/dist/locale/fr/locale-resources.d.ts.map +1 -0
  107. package/dist/locale/fr/locale-resources.js +751 -0
  108. package/dist/locale/fr/locale-resources.js.map +1 -0
  109. package/dist/locale/i18n.d.ts +27 -0
  110. package/dist/locale/i18n.d.ts.map +1 -0
  111. package/dist/locale/i18n.js +36 -0
  112. package/dist/locale/i18n.js.map +1 -0
  113. package/dist/proxy.d.ts +136 -0
  114. package/dist/proxy.d.ts.map +1 -0
  115. package/dist/proxy.js +295 -0
  116. package/dist/proxy.js.map +1 -0
  117. package/dist/streaming.d.ts +10 -0
  118. package/dist/streaming.d.ts.map +1 -0
  119. package/dist/streaming.js +2 -0
  120. package/dist/streaming.js.map +1 -0
  121. package/dist/type.d.ts +91 -0
  122. package/dist/type.d.ts.map +1 -0
  123. package/dist/type.js +2 -0
  124. package/dist/type.js.map +1 -0
  125. package/dist/utility/character-set-descriptor.d.ts +6 -0
  126. package/dist/utility/character-set-descriptor.d.ts.map +1 -0
  127. package/dist/utility/character-set-descriptor.js +28 -0
  128. package/dist/utility/character-set-descriptor.js.map +1 -0
  129. package/dist/utility/character-set-proxy.d.ts +31 -0
  130. package/dist/utility/character-set-proxy.d.ts.map +1 -0
  131. package/dist/utility/character-set-proxy.js +278 -0
  132. package/dist/utility/character-set-proxy.js.map +1 -0
  133. package/dist/utility/index.d.ts +4 -0
  134. package/dist/utility/index.d.ts.map +1 -0
  135. package/dist/utility/index.js +4 -0
  136. package/dist/utility/index.js.map +1 -0
  137. package/dist/utility/reg-exp-proxy.d.ts +8 -0
  138. package/dist/utility/reg-exp-proxy.d.ts.map +1 -0
  139. package/dist/utility/reg-exp-proxy.js +103 -0
  140. package/dist/utility/reg-exp-proxy.js.map +1 -0
  141. package/dist/utility/string-descriptor.d.ts +4 -0
  142. package/dist/utility/string-descriptor.d.ts.map +1 -0
  143. package/dist/utility/string-descriptor.js +12 -0
  144. package/dist/utility/string-descriptor.js.map +1 -0
  145. package/dist/utility/string-proxy.d.ts +7 -0
  146. package/dist/utility/string-proxy.d.ts.map +1 -0
  147. package/dist/utility/string-proxy.js +63 -0
  148. package/dist/utility/string-proxy.js.map +1 -0
  149. package/dist/utility/transformer-descriptor.d.ts +6 -0
  150. package/dist/utility/transformer-descriptor.d.ts.map +1 -0
  151. package/dist/utility/transformer-descriptor.js +24 -0
  152. package/dist/utility/transformer-descriptor.js.map +1 -0
  153. package/dist/utility/transformer-proxy.d.ts +9 -0
  154. package/dist/utility/transformer-proxy.d.ts.map +1 -0
  155. package/dist/utility/transformer-proxy.js +111 -0
  156. package/dist/utility/transformer-proxy.js.map +1 -0
  157. package/package.json +6 -5
  158. package/src/app-extension.ts +6 -0
  159. package/src/gs1/gcp-length-proxy.ts +1 -1
  160. package/src/gs1/identifier-creator-proxy.ts +21 -2
  161. package/src/index.ts +0 -1
  162. package/tsconfig-src.tsbuildinfo +1 -1
  163. package/tsup.config.ts +1 -1
  164. package/dist/chunk-FAD3UX6B.js +0 -1
  165. package/dist/descriptor-FJHoLlYK.d.ts +0 -197
  166. package/dist/generator/index.cjs +0 -17
  167. package/dist/index.cjs +0 -17
  168. package/dist/index.d.cts +0 -1557
@@ -0,0 +1,190 @@
1
+ import { ALPHA_URL, getLogger, I18nEnvironments, websiteURL } from "@aidc-toolkit/core";
2
+ import { AppHelperProxy } 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 -- Localized key exists and return type is Localization.
102
+ return localizationCallback(locale, i18nextAppExtension.t(key, lngReturnObjectsOption));
103
+ }
104
+ /**
105
+ * Generate by processing individual imports.
106
+ */
107
+ async generate() {
108
+ let success = false;
109
+ await i18nAppExtensionInit(I18nEnvironments.CLI);
110
+ const documentationBaseURL = websiteURL(this.version, true, await ALPHA_URL);
111
+ await this.initialize();
112
+ const namespaceHierarchy = new Map();
113
+ // Organize class descriptors by namespace and category.
114
+ for (const classDescriptor of proxy.classDescriptors) {
115
+ const namespace = classDescriptor.namespace;
116
+ const category = classDescriptor.category;
117
+ let categoryHierarchy = namespaceHierarchy.get(namespace);
118
+ if (categoryHierarchy === undefined) {
119
+ categoryHierarchy = new Map();
120
+ namespaceHierarchy.set(namespace, categoryHierarchy);
121
+ }
122
+ let classDescriptors = categoryHierarchy.get(category);
123
+ if (classDescriptors === undefined) {
124
+ classDescriptors = [];
125
+ categoryHierarchy.set(category, classDescriptors);
126
+ }
127
+ classDescriptors.push(classDescriptor);
128
+ }
129
+ try {
130
+ for (const [namespace, categoryHierarchy] of namespaceHierarchy) {
131
+ const namespacePrefix = namespace === undefined ? "" : `${namespace}.`;
132
+ const namespacePath = namespace === undefined ? "" : `${namespace}/`;
133
+ this.createNamespace(namespace);
134
+ for (const [category, classDescriptors] of categoryHierarchy) {
135
+ const namespaceCategory = `${namespacePrefix}${category}`;
136
+ const categoriesKey = `Categories.${category}`;
137
+ const namespaceCategoriesKey = `Categories.${namespaceCategory}`;
138
+ const categoryLocalizationsMap = new Map(this.locales.map((locale) => {
139
+ const lngOption = {
140
+ lng: locale
141
+ };
142
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Localized key exists.
143
+ return [locale, i18nextAppExtension.t((i18nextAppExtension.exists(namespaceCategoriesKey, lngOption) ? namespaceCategoriesKey : categoriesKey), lngOption)];
144
+ }));
145
+ this.createCategory(namespace, category, categoryLocalizationsMap);
146
+ const namespaceClassNamesSet = new Set();
147
+ for (const classDescriptor of classDescriptors) {
148
+ const namespaceClassName = classDescriptor.namespaceClassName;
149
+ if (namespaceClassNamesSet.has(namespaceClassName)) {
150
+ throw new Error(`Duplicate class ${namespaceClassName}`);
151
+ }
152
+ namespaceClassNamesSet.add(namespaceClassName);
153
+ // First capture group is:
154
+ // - one or more uppercase letters followed by zero or more numbers; or
155
+ // - single uppercase letter followed by zero or more characters except uppercase letters or period.
156
+ //
157
+ // Second capture group is:
158
+ // - single uppercase letter followed by zero or more characters except period; or
159
+ // - zero characters (empty string).
160
+ //
161
+ // Third capture group, separated by optional period, is:
162
+ // - single uppercase letter followed by zero or more characters (remainder of string); or
163
+ // - zero characters (empty string).
164
+ const objectNameGroups = /^(?<namespaceFirstWord>[A-Z]+[0-9]*|[A-Z][^A-Z.]*)(?<namespaceRemaining>[A-Z][^.]*|)\.?(?<className>[A-Z].*|)$/u.exec(namespaceClassName)?.groups;
165
+ if (objectNameGroups === undefined) {
166
+ throw new Error(`${namespaceClassName} is not a valid namespace-qualified class name`);
167
+ }
168
+ this.createProxyObject(`${objectNameGroups["namespaceFirstWord"].toLowerCase()}${objectNameGroups["namespaceRemaining"]}${objectNameGroups["className"]}`, classDescriptor);
169
+ for (const methodDescriptor of classDescriptor.methodDescriptors) {
170
+ const functionLocalizationsMap = new Map(this.locales.map(locale => [locale, Generator.#generateLocalization(locale, `Functions.${methodDescriptor.namespaceFunctionName}`, (locale, localization) => ({
171
+ ...localization,
172
+ namespaceFunctionName: `${namespacePrefix}${localization.name}`,
173
+ documentationURL: `${documentationBaseURL}/${locale === this.defaultLocale ? "" : `${locale}/`}${Generator.#DOCUMENTATION_PATH}${namespacePath}${localization.name}.html`,
174
+ parametersMap: new Map(methodDescriptor.parameterDescriptors.map(parameterDescriptor =>
175
+ // eslint-disable-next-line max-nested-callbacks -- Callback is empty.
176
+ [parameterDescriptor.name, Generator.#generateLocalization(locale, `Parameters.${parameterDescriptor.name}`, (_locale, localization) => localization)]))
177
+ }))]));
178
+ this.createProxyFunction(classDescriptor, methodDescriptor, functionLocalizationsMap);
179
+ }
180
+ }
181
+ }
182
+ }
183
+ success = true;
184
+ }
185
+ finally {
186
+ await this.finalize(success);
187
+ }
188
+ }
189
+ }
190
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
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,YAAY,OAAe,EAAE,oBAAoB,GAAG,IAAI;QACpD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,IAAI,CAAC,QAAQ,GAAG,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpF,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,O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{ Logger } from 'tslog';
3
- import { C as ClassDescriptor, e as MethodDescriptor } from '../descriptor-FJHoLlYK.js';
4
-
5
- /**
6
- * Localization.
1
+ /*!
2
+ * Copyright © 2024-2026 Dolphin Data Development Ltd. and AIDC Toolkit
3
+ * contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
7
16
  */
8
- interface Localization {
9
- /**
10
- * Name.
11
- */
12
- readonly name: string;
13
- /**
14
- * Description.
15
- */
16
- readonly description: string;
17
- }
18
- /**
19
- * Function localization.
20
- */
21
- interface FunctionLocalization extends Localization {
22
- /**
23
- * Namespace function name.
24
- */
25
- readonly namespaceFunctionName: string;
26
- /**
27
- * Documentation URL.
28
- */
29
- readonly documentationURL: string;
30
- /**
31
- * Parameters map.
32
- */
33
- readonly parametersMap: ReadonlyMap<string, Localization>;
34
- }
35
- /**
36
- * Abstract generator.
37
- */
38
- declare abstract class Generator {
39
- #private;
40
- /**
41
- * Constructor.
42
- *
43
- * @param version
44
- * Package version.
45
- *
46
- * @param includeLocalizations
47
- * Include localizations if true.
48
- */
49
- constructor(version: string, includeLocalizations?: boolean);
50
- /**
51
- * Get the logger.
52
- */
53
- get logger(): Logger<object>;
54
- /**
55
- * Get the package version.
56
- */
57
- get version(): string;
58
- /**
59
- * Get the locales.
60
- */
61
- protected get locales(): readonly string[];
62
- /**
63
- * Get the default locale.
64
- */
65
- protected get defaultLocale(): string;
66
- /**
67
- * Initialize the generation of the output.
68
- */
69
- protected abstract initialize(): Promisable<void>;
70
- /**
71
- * Create a namespace.
72
- *
73
- * @param namespace
74
- * Namespace.
75
- */
76
- protected abstract createNamespace(namespace: string | undefined): void;
77
- /**
78
- * Create a category.
79
- *
80
- * @param namespace
81
- * Namespace.
82
- *
83
- * @param category
84
- * Category.
85
- *
86
- * @param categoryLocalizationsMap
87
- * Category localizations map.
88
- */
89
- protected abstract createCategory(namespace: string | undefined, category: string, categoryLocalizationsMap: ReadonlyMap<string, string>): void;
90
- /**
91
- * Create a proxy object for a class.
92
- *
93
- * @param objectName
94
- * Object name, derived from namespace and class name.
95
- *
96
- * @param classDescriptor
97
- * Class descriptor.
98
- */
99
- protected abstract createProxyObject(objectName: string, classDescriptor: ClassDescriptor): void;
100
- /**
101
- * Create a proxy function for a class and method.
102
- *
103
- * @param classDescriptor
104
- * Class descriptor.
105
- *
106
- * @param methodDescriptor
107
- * Method descriptor.
108
- *
109
- * @param functionLocalizationsMap
110
- * Function localizations map.
111
- */
112
- protected abstract createProxyFunction(classDescriptor: ClassDescriptor, methodDescriptor: MethodDescriptor, functionLocalizationsMap: ReadonlyMap<string, FunctionLocalization>): void;
113
- /**
114
- * Finalize the generation of the output.
115
- *
116
- * @param success
117
- * True if successful.
118
- */
119
- protected abstract finalize(success: boolean): Promisable<void>;
120
- /**
121
- * Generate by processing individual imports.
122
- */
123
- generate(): Promise<void>;
124
- }
125
-
126
- export { type FunctionLocalization, Generator, type Localization };
17
+ export * from "./generator.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,gBAAgB,CAAC"}
@@ -1,4 +1,3 @@
1
- import{b as $,c as d,d as b,h as z,i as D,r as M,s as P}from"../chunk-FAD3UX6B.js";import{ALPHA_URL as O,getLogger as j,I18nEnvironments as E,websiteURL as U}from"@aidc-toolkit/core";function H(...p){}H(D,M,P);var w=class p{static#o="app-extension/";#n=j();#t;#e;#a;constructor(s,r=!0){this.#t=s,this.#e=r?Object.keys($):[],this.#a=this.#e[0]??""}get logger(){return this.#n}get version(){return this.#t}get locales(){return this.#e}get defaultLocale(){return this.#a}static#s(s,r,i){let e={lng:s,returnObjects:!0};return i(s,d.t(r,e))}async generate(){let s=!1;await b(E.CLI);let r=U(this.version,!0,await O);await this.initialize();let i=new Map;for(let e of z.classDescriptors){let l=e.namespace,c=e.category,o=i.get(l);o===void 0&&(o=new Map,i.set(l,o));let t=o.get(c);t===void 0&&(t=[],o.set(c,t)),t.push(e)}try{for(let[e,l]of i){let c=e===void 0?"":`${e}.`,o=e===void 0?"":`${e}/`;this.createNamespace(e);for(let[t,C]of l){let N=`${c}${t}`,v=`Categories.${t}`,f=`Categories.${N}`,R=new Map(this.locales.map(n=>{let a={lng:n};return[n,d.t(d.exists(f,a)?f:v,a)]}));this.createCategory(e,t,R);let h=new Set;for(let n of C){let a=n.namespaceClassName;if(h.has(a))throw new Error(`Duplicate class ${a}`);h.add(a);let m=/^(?<namespaceFirstWord>[A-Z]+[0-9]*|[A-Z][^A-Z.]*)(?<namespaceRemaining>[A-Z][^.]*|)\.?(?<className>[A-Z].*|)$/u.exec(a)?.groups;if(m===void 0)throw new Error(`${a} is not a valid namespace-qualified class name`);this.createProxyObject(`${m.namespaceFirstWord.toLowerCase()}${m.namespaceRemaining}${m.className}`,n);for(let g of n.methodDescriptors){let A=new Map(this.locales.map(L=>[L,p.#s(L,`Functions.${g.namespaceFunctionName}`,(u,y)=>({...y,namespaceFunctionName:`${c}${y.name}`,documentationURL:`${r}/${u===this.defaultLocale?"":`${u}/`}${p.#o}${o}${y.name}.html`,parametersMap:new Map(g.parameterDescriptors.map(x=>[x.name,p.#s(u,`Parameters.${x.name}`,(T,F)=>F)]))}))]));this.createProxyFunction(n,g,A)}}}}s=!0}finally{await this.finalize(s)}}};export{w as Generator};
2
1
  /*!
3
2
  * Copyright © 2024-2026 Dolphin Data Development Ltd. and AIDC Toolkit
4
3
  * contributors
@@ -15,3 +14,5 @@ import{b as $,c as d,d as b,h as z,i as D,r as M,s as P}from"../chunk-FAD3UX6B.j
15
14
  * See the License for the specific language governing permissions and
16
15
  * limitations under the License.
17
16
  */
17
+ export * from "./generator.js";
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=locale-resources-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-resources-generator.d.ts","sourceRoot":"","sources":["../../src/generator/locale-resources-generator.ts"],"names":[],"mappings":""}
@@ -0,0 +1,312 @@
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