@aidc-toolkit/app-extension 1.0.22-beta → 1.0.24-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.
- package/dist/index.cjs +3414 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1747 -0
- package/dist/index.d.ts +1747 -26
- package/dist/index.js +3379 -9
- package/dist/index.js.map +1 -1
- package/package.json +7 -10
- package/src/app-extension.ts +3 -10
- package/src/app-utility-proxy.ts +5 -4
- package/src/descriptor.ts +12 -8
- package/src/generator/descriptor.ts +1 -1
- package/src/generator/generator.ts +4 -4
- package/src/generator/index.ts +2 -2
- package/src/generator/{locale-strings-generator.ts → locale-resources-generator.ts} +66 -62
- package/src/gs1/character-set-proxy.ts +5 -5
- package/src/gs1/check-proxy.ts +3 -3
- package/src/gs1/identifier-proxy.ts +9 -8
- package/src/gs1/index.ts +3 -3
- package/src/index.ts +9 -9
- package/src/lib-proxy.ts +3 -3
- package/src/locale/en/{locale-strings.ts → locale-resources.ts} +1 -1
- package/src/locale/fr/{locale-strings.ts → locale-resources.ts} +1 -1
- package/src/locale/i18n.ts +7 -9
- package/src/locale/i18next.d.ts +6 -6
- package/{dist/types.d.ts → src/type.ts} +10 -38
- package/src/utility/character-set-descriptor.ts +1 -1
- package/src/utility/character-set-proxy.ts +9 -8
- package/src/utility/index.ts +3 -3
- package/src/utility/reg-exp-proxy.ts +5 -4
- package/src/utility/string-descriptor.ts +1 -1
- package/src/utility/string-proxy.ts +2 -2
- package/src/utility/transformer-descriptor.ts +1 -1
- package/src/utility/transformer-proxy.ts +5 -4
- package/tsup.config.ts +3 -0
- package/dist/app-extension.d.ts +0 -169
- package/dist/app-extension.d.ts.map +0 -1
- package/dist/app-extension.js +0 -148
- package/dist/app-extension.js.map +0 -1
- package/dist/app-utility-proxy.d.ts +0 -66
- package/dist/app-utility-proxy.d.ts.map +0 -1
- package/dist/app-utility-proxy.js +0 -233
- package/dist/app-utility-proxy.js.map +0 -1
- package/dist/descriptor.d.ts +0 -172
- package/dist/descriptor.d.ts.map +0 -1
- package/dist/descriptor.js +0 -174
- package/dist/descriptor.js.map +0 -1
- package/dist/generator/descriptor.d.ts +0 -107
- package/dist/generator/descriptor.d.ts.map +0 -1
- package/dist/generator/descriptor.js +0 -2
- package/dist/generator/descriptor.js.map +0 -1
- package/dist/generator/generator.d.ts +0 -120
- package/dist/generator/generator.d.ts.map +0 -1
- package/dist/generator/generator.js +0 -213
- package/dist/generator/generator.js.map +0 -1
- package/dist/generator/index.d.ts +0 -3
- package/dist/generator/index.d.ts.map +0 -1
- package/dist/generator/index.js +0 -2
- package/dist/generator/index.js.map +0 -1
- package/dist/gs1/character-set-proxy.d.ts +0 -10
- package/dist/gs1/character-set-proxy.d.ts.map +0 -1
- package/dist/gs1/character-set-proxy.js +0 -47
- package/dist/gs1/character-set-proxy.js.map +0 -1
- package/dist/gs1/check-proxy.d.ts +0 -11
- package/dist/gs1/check-proxy.d.ts.map +0 -1
- package/dist/gs1/check-proxy.js +0 -120
- package/dist/gs1/check-proxy.js.map +0 -1
- package/dist/gs1/identifier-proxy.d.ts +0 -136
- package/dist/gs1/identifier-proxy.d.ts.map +0 -1
- package/dist/gs1/identifier-proxy.js +0 -782
- package/dist/gs1/identifier-proxy.js.map +0 -1
- package/dist/gs1/index.d.ts +0 -4
- package/dist/gs1/index.d.ts.map +0 -1
- package/dist/gs1/index.js +0 -4
- package/dist/gs1/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lib-proxy.d.ts +0 -135
- package/dist/lib-proxy.d.ts.map +0 -1
- package/dist/lib-proxy.js +0 -235
- package/dist/lib-proxy.js.map +0 -1
- package/dist/locale/en/locale-strings.d.ts +0 -616
- package/dist/locale/en/locale-strings.d.ts.map +0 -1
- package/dist/locale/en/locale-strings.js +0 -616
- package/dist/locale/en/locale-strings.js.map +0 -1
- package/dist/locale/fr/locale-strings.d.ts +0 -616
- package/dist/locale/fr/locale-strings.d.ts.map +0 -1
- package/dist/locale/fr/locale-strings.js +0 -616
- package/dist/locale/fr/locale-strings.js.map +0 -1
- package/dist/locale/i18n.d.ts +0 -27
- package/dist/locale/i18n.d.ts.map +0 -1
- package/dist/locale/i18n.js +0 -39
- package/dist/locale/i18n.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -13
- package/dist/types.js.map +0 -1
- package/dist/utility/character-set-descriptor.d.ts +0 -6
- package/dist/utility/character-set-descriptor.d.ts.map +0 -1
- package/dist/utility/character-set-descriptor.js +0 -28
- package/dist/utility/character-set-descriptor.js.map +0 -1
- package/dist/utility/character-set-proxy.d.ts +0 -26
- package/dist/utility/character-set-proxy.d.ts.map +0 -1
- package/dist/utility/character-set-proxy.js +0 -167
- package/dist/utility/character-set-proxy.js.map +0 -1
- package/dist/utility/index.d.ts +0 -4
- package/dist/utility/index.d.ts.map +0 -1
- package/dist/utility/index.js +0 -4
- package/dist/utility/index.js.map +0 -1
- package/dist/utility/reg-exp-proxy.d.ts +0 -7
- package/dist/utility/reg-exp-proxy.d.ts.map +0 -1
- package/dist/utility/reg-exp-proxy.js +0 -61
- package/dist/utility/reg-exp-proxy.js.map +0 -1
- package/dist/utility/string-descriptor.d.ts +0 -4
- package/dist/utility/string-descriptor.d.ts.map +0 -1
- package/dist/utility/string-descriptor.js +0 -12
- package/dist/utility/string-descriptor.js.map +0 -1
- package/dist/utility/string-proxy.d.ts +0 -8
- package/dist/utility/string-proxy.d.ts.map +0 -1
- package/dist/utility/string-proxy.js +0 -12
- package/dist/utility/string-proxy.js.map +0 -1
- package/dist/utility/transformer-descriptor.d.ts +0 -6
- package/dist/utility/transformer-descriptor.d.ts.map +0 -1
- package/dist/utility/transformer-descriptor.js +0 -24
- package/dist/utility/transformer-descriptor.js.map +0 -1
- package/dist/utility/transformer-proxy.d.ts +0 -8
- package/dist/utility/transformer-proxy.d.ts.map +0 -1
- package/dist/utility/transformer-proxy.js +0 -74
- package/dist/utility/transformer-proxy.js.map +0 -1
- package/src/generator/logger.ts +0 -45
- package/src/types.ts +0 -144
package/src/descriptor.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import type { TypedFunction } from "@aidc-toolkit/core";
|
|
2
|
+
import type { AppExtension } from "./app-extension";
|
|
3
|
+
import { LibProxy } from "./lib-proxy";
|
|
4
|
+
import type { ErrorExtends } from "./type";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Core descriptor.
|
|
7
8
|
*/
|
|
8
9
|
interface Descriptor {
|
|
10
|
+
/**
|
|
11
|
+
* Name.
|
|
12
|
+
*/
|
|
9
13
|
readonly name: string;
|
|
10
14
|
}
|
|
11
15
|
|
|
@@ -167,12 +171,12 @@ type ProxyClassType<ThrowError extends boolean, TError extends ErrorExtends<Thro
|
|
|
167
171
|
let pendingParameterDescriptors: ParameterDescriptor[] = [];
|
|
168
172
|
|
|
169
173
|
/**
|
|
170
|
-
* Class method descriptors, keyed on declaration class name and method name.
|
|
174
|
+
* Class method descriptors map, keyed on declaration class name and method name.
|
|
171
175
|
*/
|
|
172
176
|
const classMethodsDescriptorsMap = new Map<string, MethodDescriptor[]>();
|
|
173
177
|
|
|
174
178
|
/**
|
|
175
|
-
* Class descriptors, keyed on declaration class name.
|
|
179
|
+
* Class descriptors map, keyed on declaration class name.
|
|
176
180
|
*/
|
|
177
181
|
const classDescriptorsMap = new Map<string, ClassDescriptor>();
|
|
178
182
|
|
|
@@ -309,11 +313,11 @@ export function ProxyClass<ThrowError extends boolean, TError extends ErrorExten
|
|
|
309
313
|
}
|
|
310
314
|
|
|
311
315
|
/**
|
|
312
|
-
* Get class descriptors.
|
|
316
|
+
* Get class descriptors map.
|
|
313
317
|
*
|
|
314
318
|
* @returns
|
|
315
|
-
* Class descriptors.
|
|
319
|
+
* Class descriptors map.
|
|
316
320
|
*/
|
|
317
|
-
export function
|
|
321
|
+
export function getClassDescriptorsMap(): ReadonlyMap<string, ClassDescriptor> {
|
|
318
322
|
return classDescriptorsMap;
|
|
319
323
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { I18nEnvironments } from "@aidc-toolkit/core";
|
|
2
2
|
import type { ParseKeys } from "i18next";
|
|
3
|
-
import { expandParameterDescriptor,
|
|
4
|
-
import { appExtensionResources, i18nAppExtensionInit, i18nextAppExtension } from "../locale/i18n
|
|
3
|
+
import { expandParameterDescriptor, getClassDescriptorsMap } from "../descriptor";
|
|
4
|
+
import { appExtensionResources, i18nAppExtensionInit, i18nextAppExtension } from "../locale/i18n";
|
|
5
5
|
import type {
|
|
6
6
|
FunctionLocalization,
|
|
7
7
|
Localization,
|
|
8
8
|
ParameterLocalization,
|
|
9
9
|
ProxyFunctionDescriptor,
|
|
10
10
|
ProxyObjectDescriptor
|
|
11
|
-
} from "./descriptor
|
|
11
|
+
} from "./descriptor";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Abstract generator.
|
|
@@ -187,7 +187,7 @@ export abstract class Generator {
|
|
|
187
187
|
this.initialize();
|
|
188
188
|
|
|
189
189
|
try {
|
|
190
|
-
for (const classDescriptor of
|
|
190
|
+
for (const classDescriptor of getClassDescriptorsMap().values()) {
|
|
191
191
|
const namespace = classDescriptor.namespace;
|
|
192
192
|
const namespacePrefix = namespace === undefined ? "" : `${namespace}.`;
|
|
193
193
|
const className = classDescriptor.name;
|
package/src/generator/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type * from "./descriptor
|
|
2
|
-
export * from "./generator
|
|
1
|
+
export type * from "./descriptor";
|
|
2
|
+
export * from "./generator";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { getLogger, type LocaleResources } from "@aidc-toolkit/core";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
-
import { expandParameterDescriptor, type ParameterDescriptor } from "../descriptor
|
|
5
|
-
import type { ProxyFunctionDescriptor } from "./descriptor
|
|
6
|
-
import { Generator } from "./generator
|
|
7
|
-
import { logger } from "./logger.js";
|
|
4
|
+
import { expandParameterDescriptor, type ParameterDescriptor } from "../descriptor";
|
|
5
|
+
import type { ProxyFunctionDescriptor } from "./descriptor";
|
|
6
|
+
import { Generator } from "./generator";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Parameters sequencer entry.
|
|
@@ -32,45 +31,50 @@ interface ParametersSequencerEntry {
|
|
|
32
31
|
type ParametersSequencer = Record<string, ParametersSequencerEntry>;
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
|
-
* Format of locale
|
|
34
|
+
* Format of locale resources module.
|
|
36
35
|
*/
|
|
37
|
-
interface
|
|
36
|
+
interface LocaleResourcesModule {
|
|
38
37
|
/**
|
|
39
|
-
* Locale
|
|
38
|
+
* Locale resources.
|
|
40
39
|
*/
|
|
41
|
-
|
|
40
|
+
LocaleResources: LocaleResources;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
/**
|
|
45
|
-
* Locale
|
|
44
|
+
* Locale resources generator.
|
|
46
45
|
*/
|
|
47
|
-
class
|
|
46
|
+
class LocaleResourcesGenerator extends Generator {
|
|
48
47
|
/**
|
|
49
|
-
* Locale
|
|
48
|
+
* Locale resources import path.
|
|
50
49
|
*/
|
|
51
50
|
private static readonly IMPORT_PATH = "../app-extension/src/locale";
|
|
52
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Logger.
|
|
54
|
+
*/
|
|
55
|
+
private readonly _logger = getLogger();
|
|
56
|
+
|
|
53
57
|
/**
|
|
54
58
|
* Parameters sequencer.
|
|
55
59
|
*/
|
|
56
60
|
private readonly _parametersSequencer: ParametersSequencer = {};
|
|
57
61
|
|
|
58
62
|
/**
|
|
59
|
-
* Parameters locale
|
|
63
|
+
* Parameters locale resources.
|
|
60
64
|
*/
|
|
61
|
-
private readonly
|
|
65
|
+
private readonly _parametersLocaleResources: LocaleResources = {};
|
|
62
66
|
|
|
63
67
|
/**
|
|
64
|
-
* Functions locale
|
|
68
|
+
* Functions locale resources.
|
|
65
69
|
*/
|
|
66
|
-
private readonly
|
|
70
|
+
private readonly _functionsLocaleResources: LocaleResources = {};
|
|
67
71
|
|
|
68
72
|
/**
|
|
69
|
-
* Locale
|
|
73
|
+
* Locale resources.
|
|
70
74
|
*/
|
|
71
|
-
private readonly
|
|
72
|
-
Parameters: this.
|
|
73
|
-
Functions: this.
|
|
75
|
+
private readonly _LocaleResources: LocaleResources = {
|
|
76
|
+
Parameters: this._parametersLocaleResources,
|
|
77
|
+
Functions: this._functionsLocaleResources
|
|
74
78
|
};
|
|
75
79
|
|
|
76
80
|
/**
|
|
@@ -167,35 +171,35 @@ class LocaleStringsGenerator extends Generator {
|
|
|
167
171
|
this.saveParameterSequence(parameterDescriptor, true);
|
|
168
172
|
}
|
|
169
173
|
|
|
170
|
-
let
|
|
174
|
+
let functionsLocaleResources = this._functionsLocaleResources;
|
|
171
175
|
|
|
172
176
|
if (namespace !== undefined) {
|
|
173
|
-
if (!(namespace in
|
|
174
|
-
const
|
|
177
|
+
if (!(namespace in functionsLocaleResources)) {
|
|
178
|
+
const namespaceFunctionsLocaleResources: LocaleResources = {};
|
|
175
179
|
|
|
176
180
|
// Add namespace and navigate to it.
|
|
177
|
-
|
|
178
|
-
|
|
181
|
+
functionsLocaleResources[namespace] = namespaceFunctionsLocaleResources;
|
|
182
|
+
functionsLocaleResources = namespaceFunctionsLocaleResources;
|
|
179
183
|
} else {
|
|
180
184
|
// Navigate to namespace.
|
|
181
185
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Entry is never a string.
|
|
182
|
-
|
|
186
|
+
functionsLocaleResources = functionsLocaleResources[namespace] as LocaleResources;
|
|
183
187
|
}
|
|
184
188
|
}
|
|
185
189
|
|
|
186
|
-
if (functionName in
|
|
190
|
+
if (functionName in functionsLocaleResources) {
|
|
187
191
|
throw new Error(`Duplicate function "${functionName}"`);
|
|
188
192
|
}
|
|
189
193
|
|
|
190
194
|
// Add function.
|
|
191
|
-
|
|
195
|
+
functionsLocaleResources[functionName] = {
|
|
192
196
|
name: functionName,
|
|
193
197
|
description: "*** LOCALIZATION REQUIRED ***"
|
|
194
198
|
};
|
|
195
199
|
}
|
|
196
200
|
|
|
197
201
|
/**
|
|
198
|
-
* Merge source locale
|
|
202
|
+
* Merge source locale resources into existing destination locale resources.
|
|
199
203
|
*
|
|
200
204
|
* @param logChanges
|
|
201
205
|
* If true, changes are logged. Limits output when processing multiple sources.
|
|
@@ -203,67 +207,67 @@ class LocaleStringsGenerator extends Generator {
|
|
|
203
207
|
* @param parentKey
|
|
204
208
|
* Parent key for logging purposes.
|
|
205
209
|
*
|
|
206
|
-
* @param
|
|
207
|
-
* Source locale
|
|
210
|
+
* @param sourceLocaleResources
|
|
211
|
+
* Source locale resources.
|
|
208
212
|
*
|
|
209
|
-
* @param
|
|
210
|
-
* Destination locale
|
|
213
|
+
* @param destinationLocaleResources
|
|
214
|
+
* Destination locale resources.
|
|
211
215
|
*
|
|
212
216
|
* @param addMissing
|
|
213
|
-
* Add missing if true; applies to locale
|
|
217
|
+
* Add missing if true; applies to locale resources that are not regional.
|
|
214
218
|
*
|
|
215
219
|
* @returns
|
|
216
|
-
* Merged locale
|
|
220
|
+
* Merged locale resources.
|
|
217
221
|
*/
|
|
218
|
-
private
|
|
222
|
+
private merge(logChanges: boolean, parentKey: string, sourceLocaleResources: LocaleResources, destinationLocaleResources: LocaleResources, addMissing: boolean): LocaleResources {
|
|
219
223
|
// Some entries at the top are not part of the generator output.
|
|
220
224
|
const deleteMissing = parentKey.length !== 0;
|
|
221
225
|
|
|
222
|
-
const
|
|
226
|
+
const newDestinationLocaleResources: LocaleResources = {};
|
|
223
227
|
|
|
224
228
|
// Copy over or delete any destination keys that are not in source.
|
|
225
|
-
for (const [key, destinationValue] of Object.entries(
|
|
226
|
-
if (!(key in
|
|
229
|
+
for (const [key, destinationValue] of Object.entries(destinationLocaleResources)) {
|
|
230
|
+
if (!(key in sourceLocaleResources)) {
|
|
227
231
|
if (!deleteMissing) {
|
|
228
|
-
|
|
232
|
+
newDestinationLocaleResources[key] = destinationValue;
|
|
229
233
|
} else if (logChanges) {
|
|
230
|
-
|
|
234
|
+
this._logger.info(`Deleting ${parentKey}${key}...`);
|
|
231
235
|
}
|
|
232
236
|
}
|
|
233
237
|
}
|
|
234
238
|
|
|
235
|
-
for (const [key, sourceValue] of Object.entries(
|
|
236
|
-
if (!(key in
|
|
239
|
+
for (const [key, sourceValue] of Object.entries(sourceLocaleResources)) {
|
|
240
|
+
if (!(key in destinationLocaleResources)) {
|
|
237
241
|
if (addMissing) {
|
|
238
242
|
if (logChanges) {
|
|
239
|
-
|
|
243
|
+
this._logger.info(`Adding ${parentKey}${key}...`);
|
|
240
244
|
}
|
|
241
245
|
|
|
242
|
-
|
|
246
|
+
newDestinationLocaleResources[key] = sourceValue;
|
|
243
247
|
}
|
|
244
248
|
} else {
|
|
245
|
-
const destinationValue =
|
|
249
|
+
const destinationValue = destinationLocaleResources[key];
|
|
246
250
|
|
|
247
251
|
if (typeof sourceValue === "object" && typeof destinationValue === "object") {
|
|
248
|
-
|
|
252
|
+
newDestinationLocaleResources[key] = this.merge(logChanges, `${parentKey}${key}.`, sourceValue, destinationValue, addMissing);
|
|
249
253
|
} else if (typeof sourceValue === "string" && typeof destinationValue === "string") {
|
|
250
|
-
|
|
254
|
+
newDestinationLocaleResources[key] = destinationValue;
|
|
251
255
|
} else {
|
|
252
256
|
throw new Error(`Mismatched types at ${parentKey}${key}`);
|
|
253
257
|
}
|
|
254
258
|
}
|
|
255
259
|
}
|
|
256
260
|
|
|
257
|
-
return
|
|
261
|
+
return newDestinationLocaleResources;
|
|
258
262
|
}
|
|
259
263
|
|
|
260
264
|
/**
|
|
261
|
-
* Build parameters locale
|
|
265
|
+
* Build parameters locale resources by going through parameters sequencer.
|
|
262
266
|
*
|
|
263
267
|
* @param parametersSequencer
|
|
264
268
|
* Parameters sequencer.
|
|
265
269
|
*/
|
|
266
|
-
private
|
|
270
|
+
private buildParametersLocaleResources(parametersSequencer: ParametersSequencer): void {
|
|
267
271
|
const entries = Object.entries(parametersSequencer);
|
|
268
272
|
|
|
269
273
|
// Sort the entries as defined by the descriptors.
|
|
@@ -295,14 +299,14 @@ class LocaleStringsGenerator extends Generator {
|
|
|
295
299
|
|
|
296
300
|
for (const [parameterName, parametersSequencerEntry] of entries) {
|
|
297
301
|
if (parametersSequencerEntry.isUsed) {
|
|
298
|
-
this.
|
|
302
|
+
this._parametersLocaleResources[parameterName] = {
|
|
299
303
|
name: parameterName,
|
|
300
304
|
description: "*** LOCALIZATION REQUIRED ***"
|
|
301
305
|
};
|
|
302
306
|
}
|
|
303
307
|
|
|
304
308
|
if (parametersSequencerEntry.parametersSequencerOrNull !== null) {
|
|
305
|
-
this.
|
|
309
|
+
this.buildParametersLocaleResources(parametersSequencerEntry.parametersSequencerOrNull);
|
|
306
310
|
}
|
|
307
311
|
}
|
|
308
312
|
}
|
|
@@ -322,10 +326,10 @@ class LocaleStringsGenerator extends Generator {
|
|
|
322
326
|
* @returns
|
|
323
327
|
* Output string.
|
|
324
328
|
*/
|
|
325
|
-
private static buildOutput(prefix: string, value:
|
|
329
|
+
private static buildOutput(prefix: string, value: LocaleResources | string, indentLevel: number): string {
|
|
326
330
|
return `${" ".repeat(indentLevel)}${prefix} ${typeof value === "object" ?
|
|
327
331
|
`{\n${
|
|
328
|
-
Object.entries(value).map(entry =>
|
|
332
|
+
Object.entries(value).map(entry => LocaleResourcesGenerator.buildOutput(`${entry[0]}:`, entry[1], indentLevel + 1)).join(",\n")
|
|
329
333
|
}\n${" ".repeat(indentLevel)}}` :
|
|
330
334
|
// JSON.stringify() will apply quotes as appropriate.
|
|
331
335
|
JSON.stringify(value)
|
|
@@ -337,22 +341,22 @@ class LocaleStringsGenerator extends Generator {
|
|
|
337
341
|
*/
|
|
338
342
|
protected async finalize(success: boolean): Promise<void> {
|
|
339
343
|
if (success) {
|
|
340
|
-
this.
|
|
344
|
+
this.buildParametersLocaleResources(this._parametersSequencer);
|
|
341
345
|
|
|
342
|
-
await Promise.all(fs.readdirSync(
|
|
346
|
+
await Promise.all(fs.readdirSync(LocaleResourcesGenerator.IMPORT_PATH, {
|
|
343
347
|
withFileTypes: true
|
|
344
348
|
}).filter(entry => entry.isDirectory()).map(async (entry) => {
|
|
345
|
-
const
|
|
349
|
+
const LocaleResourcesSource = path.resolve(LocaleResourcesGenerator.IMPORT_PATH, entry.name, "locale-resources.ts");
|
|
346
350
|
|
|
347
|
-
await import(
|
|
351
|
+
await import(LocaleResourcesSource).then((module) => {
|
|
348
352
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Module format is known.
|
|
349
|
-
const
|
|
353
|
+
const LocaleResources = this.merge(entry.name === "en", "", this._LocaleResources, (module as LocaleResourcesModule).LocaleResources, !entry.name.includes("-"));
|
|
350
354
|
|
|
351
|
-
fs.writeFileSync(
|
|
355
|
+
fs.writeFileSync(LocaleResourcesSource, `${LocaleResourcesGenerator.buildOutput("export default", LocaleResources, 0)};\n`);
|
|
352
356
|
});
|
|
353
357
|
}));
|
|
354
358
|
}
|
|
355
359
|
}
|
|
356
360
|
}
|
|
357
361
|
|
|
358
|
-
await new
|
|
362
|
+
await new LocaleResourcesGenerator().generate();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AI39_CREATOR, AI82_CREATOR } from "@aidc-toolkit/gs1";
|
|
2
|
-
import type { AppExtension } from "../app-extension
|
|
3
|
-
import { expandParameterDescriptor, ProxyClass } from "../descriptor
|
|
4
|
-
import type { ErrorExtends } from "../
|
|
2
|
+
import type { AppExtension } from "../app-extension";
|
|
3
|
+
import { expandParameterDescriptor, ProxyClass } from "../descriptor";
|
|
4
|
+
import type { ErrorExtends } from "../type";
|
|
5
5
|
import {
|
|
6
6
|
exclusionAllNumericParameterDescriptor,
|
|
7
7
|
exclusionNoneParameterDescriptor
|
|
8
|
-
} from "../utility/character-set-descriptor
|
|
9
|
-
import { CharacterSetProxy } from "../utility
|
|
8
|
+
} from "../utility/character-set-descriptor";
|
|
9
|
+
import { CharacterSetProxy } from "../utility";
|
|
10
10
|
|
|
11
11
|
@ProxyClass({
|
|
12
12
|
namespace: "GS1",
|
package/src/gs1/check-proxy.ts
CHANGED
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
isValidPriceOrWeightCheckDigit,
|
|
7
7
|
priceOrWeightCheckDigit
|
|
8
8
|
} from "@aidc-toolkit/gs1";
|
|
9
|
-
import { type ParameterDescriptor, ProxyClass, ProxyMethod, ProxyParameter, Types } from "../descriptor
|
|
10
|
-
import { LibProxy } from "../lib-proxy
|
|
11
|
-
import type { ErrorExtends, Matrix, MatrixResultError, ResultError } from "../
|
|
9
|
+
import { type ParameterDescriptor, ProxyClass, ProxyMethod, ProxyParameter, Types } from "../descriptor";
|
|
10
|
+
import { LibProxy } from "../lib-proxy";
|
|
11
|
+
import type { ErrorExtends, Matrix, MatrixResultError, ResultError } from "../type";
|
|
12
12
|
|
|
13
13
|
const checkSParameterDescriptor: ParameterDescriptor = {
|
|
14
14
|
name: "checkS",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNullish, type Nullishable } from "@aidc-toolkit/core";
|
|
1
2
|
import {
|
|
2
3
|
CPID_VALIDATOR,
|
|
3
4
|
GCN_VALIDATOR,
|
|
@@ -34,7 +35,7 @@ import {
|
|
|
34
35
|
SSCC_VALIDATOR
|
|
35
36
|
} from "@aidc-toolkit/gs1";
|
|
36
37
|
import { Sequence } from "@aidc-toolkit/utility";
|
|
37
|
-
import type { AppExtension } from "../app-extension
|
|
38
|
+
import type { AppExtension } from "../app-extension";
|
|
38
39
|
import {
|
|
39
40
|
expandParameterDescriptor,
|
|
40
41
|
type ParameterDescriptor,
|
|
@@ -42,17 +43,17 @@ import {
|
|
|
42
43
|
ProxyMethod,
|
|
43
44
|
ProxyParameter,
|
|
44
45
|
Types
|
|
45
|
-
} from "../descriptor
|
|
46
|
-
import { LibProxy } from "../lib-proxy
|
|
47
|
-
import { i18nextAppExtension } from "../locale/i18n
|
|
48
|
-
import {
|
|
49
|
-
import { exclusionAllNumericParameterDescriptor } from "../utility/character-set-descriptor
|
|
50
|
-
import { StringProxy } from "../utility/string-proxy
|
|
46
|
+
} from "../descriptor";
|
|
47
|
+
import { LibProxy } from "../lib-proxy";
|
|
48
|
+
import { i18nextAppExtension } from "../locale/i18n";
|
|
49
|
+
import type { ErrorExtends, Matrix, MatrixResultError } from "../type";
|
|
50
|
+
import { exclusionAllNumericParameterDescriptor } from "../utility/character-set-descriptor";
|
|
51
|
+
import { StringProxy } from "../utility/string-proxy";
|
|
51
52
|
import {
|
|
52
53
|
countParameterDescriptor,
|
|
53
54
|
startValueParameterDescriptor,
|
|
54
55
|
valueParameterDescriptor
|
|
55
|
-
} from "../utility/transformer-descriptor
|
|
56
|
+
} from "../utility/transformer-descriptor";
|
|
56
57
|
|
|
57
58
|
const identifierParameterDescriptor: ParameterDescriptor = {
|
|
58
59
|
name: "identifier",
|
package/src/gs1/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./character-set-proxy
|
|
2
|
-
export * from "./check-proxy
|
|
3
|
-
export * from "./identifier-proxy
|
|
1
|
+
export * from "./character-set-proxy";
|
|
2
|
+
export * from "./check-proxy";
|
|
3
|
+
export * from "./identifier-proxy";
|
package/src/index.ts
CHANGED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
export * from "./locale/i18n
|
|
18
|
-
export * from "./
|
|
19
|
-
export * from "./app-extension
|
|
20
|
-
export * from "./lib-proxy
|
|
21
|
-
export * from "./descriptor
|
|
22
|
-
export * from "./app-utility-proxy
|
|
23
|
-
export * from "./utility/index
|
|
24
|
-
export * as GS1 from "./gs1/index
|
|
25
|
-
export * from "./generator/index
|
|
17
|
+
export * from "./locale/i18n";
|
|
18
|
+
export type * from "./type";
|
|
19
|
+
export * from "./app-extension";
|
|
20
|
+
export * from "./lib-proxy";
|
|
21
|
+
export * from "./descriptor";
|
|
22
|
+
export * from "./app-utility-proxy";
|
|
23
|
+
export * from "./utility/index";
|
|
24
|
+
export * as GS1 from "./gs1/index";
|
|
25
|
+
export * from "./generator/index";
|
package/src/lib-proxy.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mapIterable } from "@aidc-toolkit/utility";
|
|
2
|
-
import type { AppExtension } from "./app-extension
|
|
3
|
-
import { i18nextAppExtension } from "./locale/i18n
|
|
4
|
-
import type { ErrorExtends, Matrix, MatrixResultError, ResultError } from "./
|
|
2
|
+
import type { AppExtension } from "./app-extension";
|
|
3
|
+
import { i18nextAppExtension } from "./locale/i18n";
|
|
4
|
+
import type { ErrorExtends, Matrix, MatrixResultError, ResultError } from "./type";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Library proxy.
|
package/src/locale/i18n.ts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i18nCoreInit, type I18nEnvironment } from "@aidc-toolkit/core";
|
|
2
2
|
import { gs1Resources, i18nGS1Init } from "@aidc-toolkit/gs1";
|
|
3
3
|
import { i18nUtilityInit, utilityResources } from "@aidc-toolkit/utility";
|
|
4
4
|
import i18next, { type i18n, type Resource } from "i18next";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import enLocaleResources from "./en/locale-resources";
|
|
6
|
+
import frLocaleResources from "./fr/locale-resources";
|
|
7
7
|
|
|
8
8
|
export const appExtensionNS = "aidct_app_extension";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Locale
|
|
11
|
+
* Locale resources type is extracted from the English locale resources object.
|
|
12
12
|
*/
|
|
13
|
-
export type
|
|
14
|
-
|
|
15
|
-
i18nAssertValidResources(enLocaleStrings, "fr", frLocaleStrings);
|
|
13
|
+
export type AppExtensionLocaleResources = typeof enLocaleResources;
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
16
|
* App extension resources.
|
|
19
17
|
*/
|
|
20
18
|
export const appExtensionResources: Resource = {
|
|
21
19
|
en: {
|
|
22
|
-
aidct_app_extension:
|
|
20
|
+
aidct_app_extension: enLocaleResources
|
|
23
21
|
},
|
|
24
22
|
fr: {
|
|
25
|
-
aidct_app_extension:
|
|
23
|
+
aidct_app_extension: frLocaleResources
|
|
26
24
|
}
|
|
27
25
|
};
|
|
28
26
|
|
package/src/locale/i18next.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { GS1LocaleResources } from "@aidc-toolkit/gs1";
|
|
2
|
+
import type { UtilityLocaleResources } from "@aidc-toolkit/utility";
|
|
3
|
+
import type { AppExtensionLocaleResources } from "./i18n";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Internationalization module.
|
|
@@ -12,9 +12,9 @@ declare module "i18next" {
|
|
|
12
12
|
interface CustomTypeOptions {
|
|
13
13
|
defaultNS: "aidct_app_extension";
|
|
14
14
|
resources: {
|
|
15
|
-
aidct_utility:
|
|
16
|
-
aidct_gs1:
|
|
17
|
-
aidct_app_extension:
|
|
15
|
+
aidct_utility: UtilityLocaleResources;
|
|
16
|
+
aidct_gs1: GS1LocaleResources;
|
|
17
|
+
aidct_app_extension: AppExtensionLocaleResources;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
}
|