@aidc-toolkit/app-extension 1.0.25-beta → 1.0.27-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 +146 -117
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -139
- package/dist/index.d.ts +123 -139
- package/dist/index.js +147 -118
- package/dist/index.js.map +1 -1
- package/package.json +14 -9
- package/src/app-extension.ts +30 -21
- package/src/app-utility-proxy.ts +19 -7
- package/src/descriptor.ts +64 -4
- package/src/generator/descriptor.ts +6 -3
- package/src/generator/generator.ts +46 -25
- package/src/generator/index.ts +2 -2
- package/src/generator/locale-resources-generator.ts +35 -35
- package/src/gs1/character-set-proxy.ts +5 -5
- package/src/gs1/check-proxy.ts +3 -3
- package/src/gs1/identifier-proxy.ts +45 -44
- package/src/gs1/index.ts +3 -3
- package/src/index.ts +9 -9
- package/src/lib-proxy.ts +24 -21
- package/src/locale/i18n.ts +3 -3
- package/src/locale/i18next.d.ts +1 -1
- package/src/utility/character-set-descriptor.ts +1 -1
- package/src/utility/character-set-proxy.ts +16 -16
- package/src/utility/index.ts +3 -3
- package/src/utility/reg-exp-proxy.ts +4 -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 +4 -4
- package/tsconfig-config.json +4 -0
- package/tsconfig-src.json +11 -0
- package/tsconfig.json +9 -4
- package/tsup.config.ts +3 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
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";
|
|
4
|
+
import { expandParameterDescriptor, type ParameterDescriptor } from "../descriptor.js";
|
|
5
|
+
import type { ProxyFunctionDescriptor } from "./descriptor.js";
|
|
6
|
+
import { Generator } from "./generator.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Parameters sequencer entry.
|
|
@@ -37,7 +37,7 @@ interface LocaleResourcesModule {
|
|
|
37
37
|
/**
|
|
38
38
|
* Locale resources.
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
default: LocaleResources;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -47,34 +47,34 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
47
47
|
/**
|
|
48
48
|
* Locale resources import path.
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
static readonly #IMPORT_PATH = "../app-extension/src/locale";
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Logger.
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
readonly #logger = getLogger();
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Parameters sequencer.
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
readonly #parametersSequencer: ParametersSequencer = {};
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Parameters locale resources.
|
|
64
64
|
*/
|
|
65
|
-
|
|
65
|
+
readonly #parametersLocaleResources: LocaleResources = {};
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Functions locale resources.
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
readonly #functionsLocaleResources: LocaleResources = {};
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Locale resources.
|
|
74
74
|
*/
|
|
75
|
-
|
|
76
|
-
Parameters: this
|
|
77
|
-
Functions: this
|
|
75
|
+
readonly #LocaleResources: LocaleResources = {
|
|
76
|
+
Parameters: this.#parametersLocaleResources,
|
|
77
|
+
Functions: this.#functionsLocaleResources
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
/**
|
|
@@ -108,26 +108,26 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
108
108
|
* @returns
|
|
109
109
|
* Parameters sequencer entry.
|
|
110
110
|
*/
|
|
111
|
-
|
|
111
|
+
#saveParameterSequence(parameterDescriptor: ParameterDescriptor, isUsed: boolean): ParametersSequencerEntry {
|
|
112
112
|
let parametersSequencerEntry: ParametersSequencerEntry;
|
|
113
113
|
|
|
114
114
|
if (!("extendsDescriptor" in parameterDescriptor)) {
|
|
115
115
|
const parameterName = parameterDescriptor.name;
|
|
116
116
|
|
|
117
117
|
// Create entry if it doesn't exist, otherwise pick up where last call left off.
|
|
118
|
-
if (!(parameterName in this
|
|
118
|
+
if (!(parameterName in this.#parametersSequencer)) {
|
|
119
119
|
parametersSequencerEntry = {
|
|
120
120
|
parametersSequencerOrNull: null,
|
|
121
121
|
parameterDescriptor,
|
|
122
122
|
isUsed
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
this
|
|
125
|
+
this.#parametersSequencer[parameterName] = parametersSequencerEntry;
|
|
126
126
|
} else {
|
|
127
|
-
parametersSequencerEntry = this
|
|
127
|
+
parametersSequencerEntry = this.#parametersSequencer[parameterName];
|
|
128
128
|
}
|
|
129
129
|
} else {
|
|
130
|
-
const baseParametersSequencerEntry = this
|
|
130
|
+
const baseParametersSequencerEntry = this.#saveParameterSequence(parameterDescriptor.extendsDescriptor, false);
|
|
131
131
|
|
|
132
132
|
const expandedParameterDescriptor = expandParameterDescriptor(parameterDescriptor);
|
|
133
133
|
const parameterName = expandedParameterDescriptor.name;
|
|
@@ -168,10 +168,10 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
168
168
|
|
|
169
169
|
// Add any parameters that are not already known.
|
|
170
170
|
for (const parameterDescriptor of methodDescriptor.parameterDescriptors) {
|
|
171
|
-
this
|
|
171
|
+
this.#saveParameterSequence(parameterDescriptor, true);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
let functionsLocaleResources = this
|
|
174
|
+
let functionsLocaleResources = this.#functionsLocaleResources;
|
|
175
175
|
|
|
176
176
|
if (namespace !== undefined) {
|
|
177
177
|
if (!(namespace in functionsLocaleResources)) {
|
|
@@ -188,7 +188,7 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
if (functionName in functionsLocaleResources) {
|
|
191
|
-
throw new Error(`Duplicate function
|
|
191
|
+
throw new Error(`Duplicate function ${functionName}`);
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// Add function.
|
|
@@ -219,7 +219,7 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
219
219
|
* @returns
|
|
220
220
|
* Merged locale resources.
|
|
221
221
|
*/
|
|
222
|
-
|
|
222
|
+
#merge(logChanges: boolean, parentKey: string, sourceLocaleResources: LocaleResources, destinationLocaleResources: LocaleResources, addMissing: boolean): LocaleResources {
|
|
223
223
|
// Some entries at the top are not part of the generator output.
|
|
224
224
|
const deleteMissing = parentKey.length !== 0;
|
|
225
225
|
|
|
@@ -231,7 +231,7 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
231
231
|
if (!deleteMissing) {
|
|
232
232
|
newDestinationLocaleResources[key] = destinationValue;
|
|
233
233
|
} else if (logChanges) {
|
|
234
|
-
this.
|
|
234
|
+
this.#logger.info(`Deleting ${parentKey}${key}...`);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
}
|
|
@@ -240,7 +240,7 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
240
240
|
if (!(key in destinationLocaleResources)) {
|
|
241
241
|
if (addMissing) {
|
|
242
242
|
if (logChanges) {
|
|
243
|
-
this.
|
|
243
|
+
this.#logger.info(`Adding ${parentKey}${key}...`);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
newDestinationLocaleResources[key] = sourceValue;
|
|
@@ -249,7 +249,7 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
249
249
|
const destinationValue = destinationLocaleResources[key];
|
|
250
250
|
|
|
251
251
|
if (typeof sourceValue === "object" && typeof destinationValue === "object") {
|
|
252
|
-
newDestinationLocaleResources[key] = this
|
|
252
|
+
newDestinationLocaleResources[key] = this.#merge(logChanges, `${parentKey}${key}.`, sourceValue, destinationValue, addMissing);
|
|
253
253
|
} else if (typeof sourceValue === "string" && typeof destinationValue === "string") {
|
|
254
254
|
newDestinationLocaleResources[key] = destinationValue;
|
|
255
255
|
} else {
|
|
@@ -267,7 +267,7 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
267
267
|
* @param parametersSequencer
|
|
268
268
|
* Parameters sequencer.
|
|
269
269
|
*/
|
|
270
|
-
|
|
270
|
+
#buildParametersLocaleResources(parametersSequencer: ParametersSequencer): void {
|
|
271
271
|
const entries = Object.entries(parametersSequencer);
|
|
272
272
|
|
|
273
273
|
// Sort the entries as defined by the descriptors.
|
|
@@ -299,14 +299,14 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
299
299
|
|
|
300
300
|
for (const [parameterName, parametersSequencerEntry] of entries) {
|
|
301
301
|
if (parametersSequencerEntry.isUsed) {
|
|
302
|
-
this
|
|
302
|
+
this.#parametersLocaleResources[parameterName] = {
|
|
303
303
|
name: parameterName,
|
|
304
304
|
description: "*** LOCALIZATION REQUIRED ***"
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
if (parametersSequencerEntry.parametersSequencerOrNull !== null) {
|
|
309
|
-
this
|
|
309
|
+
this.#buildParametersLocaleResources(parametersSequencerEntry.parametersSequencerOrNull);
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
}
|
|
@@ -326,10 +326,10 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
326
326
|
* @returns
|
|
327
327
|
* Output string.
|
|
328
328
|
*/
|
|
329
|
-
|
|
329
|
+
static #buildOutput(prefix: string, value: LocaleResources | string, indentLevel: number): string {
|
|
330
330
|
return `${" ".repeat(indentLevel)}${prefix} ${typeof value === "object" ?
|
|
331
331
|
`{\n${
|
|
332
|
-
Object.entries(value).map(entry => LocaleResourcesGenerator
|
|
332
|
+
Object.entries(value).map(entry => LocaleResourcesGenerator.#buildOutput(`${entry[0]}:`, entry[1], indentLevel + 1)).join(",\n")
|
|
333
333
|
}\n${" ".repeat(indentLevel)}}` :
|
|
334
334
|
// JSON.stringify() will apply quotes as appropriate.
|
|
335
335
|
JSON.stringify(value)
|
|
@@ -341,18 +341,18 @@ class LocaleResourcesGenerator extends Generator {
|
|
|
341
341
|
*/
|
|
342
342
|
protected async finalize(success: boolean): Promise<void> {
|
|
343
343
|
if (success) {
|
|
344
|
-
this
|
|
344
|
+
this.#buildParametersLocaleResources(this.#parametersSequencer);
|
|
345
345
|
|
|
346
|
-
await Promise.all(fs.readdirSync(LocaleResourcesGenerator
|
|
346
|
+
await Promise.all(fs.readdirSync(LocaleResourcesGenerator.#IMPORT_PATH, {
|
|
347
347
|
withFileTypes: true
|
|
348
348
|
}).filter(entry => entry.isDirectory()).map(async (entry) => {
|
|
349
|
-
const
|
|
349
|
+
const localeResourcesSource = path.resolve(LocaleResourcesGenerator.#IMPORT_PATH, entry.name, "locale-resources.ts");
|
|
350
350
|
|
|
351
|
-
await import(
|
|
351
|
+
await import(localeResourcesSource).then((module) => {
|
|
352
352
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Module format is known.
|
|
353
|
-
const
|
|
353
|
+
const localeResources = this.#merge(entry.name === "en", "", this.#LocaleResources, (module as LocaleResourcesModule).default, !entry.name.includes("-"));
|
|
354
354
|
|
|
355
|
-
fs.writeFileSync(
|
|
355
|
+
fs.writeFileSync(localeResourcesSource, `${LocaleResourcesGenerator.#buildOutput("export default", localeResources, 0)};\n`);
|
|
356
356
|
});
|
|
357
357
|
}));
|
|
358
358
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AI39_CREATOR, AI64_VALIDATOR, AI82_CREATOR } from "@aidc-toolkit/gs1";
|
|
2
|
-
import type { AppExtension } from "../app-extension";
|
|
3
|
-
import { expandParameterDescriptor, ProxyClass } from "../descriptor";
|
|
4
|
-
import type { ErrorExtends } from "../type";
|
|
5
|
-
import { CharacterSetCreatorProxy, CharacterSetValidatorProxy } from "../utility";
|
|
2
|
+
import type { AppExtension } from "../app-extension.js";
|
|
3
|
+
import { expandParameterDescriptor, ProxyClass } from "../descriptor.js";
|
|
4
|
+
import type { ErrorExtends } from "../type.js";
|
|
5
|
+
import { CharacterSetCreatorProxy, CharacterSetValidatorProxy } from "../utility/index.js";
|
|
6
6
|
import {
|
|
7
7
|
exclusionAllNumericParameterDescriptor,
|
|
8
8
|
exclusionNoneParameterDescriptor
|
|
9
|
-
} from "../utility/character-set-descriptor";
|
|
9
|
+
} from "../utility/character-set-descriptor.js";
|
|
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 "../type";
|
|
9
|
+
import { type ParameterDescriptor, ProxyClass, ProxyMethod, ProxyParameter, Types } from "../descriptor.js";
|
|
10
|
+
import { LibProxy } from "../lib-proxy.js";
|
|
11
|
+
import type { ErrorExtends, Matrix, MatrixResultError, ResultError } from "../type.js";
|
|
12
12
|
|
|
13
13
|
const checkSParameterDescriptor: ParameterDescriptor = {
|
|
14
14
|
name: "checkS",
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import { isNullish, type Nullishable } from "@aidc-toolkit/core";
|
|
2
2
|
import {
|
|
3
3
|
GTINCreator,
|
|
4
|
-
|
|
4
|
+
GTINLengths,
|
|
5
5
|
type GTINLevel,
|
|
6
|
-
|
|
6
|
+
type GTINType,
|
|
7
7
|
GTINValidator,
|
|
8
8
|
type IdentifierCreator,
|
|
9
|
-
type IdentifierDescriptor,
|
|
10
9
|
type IdentifierType,
|
|
11
|
-
type IdentifierTypes,
|
|
12
10
|
type IdentifierTypeValidator,
|
|
13
11
|
type IdentifierValidation,
|
|
14
12
|
IdentifierValidators,
|
|
15
13
|
type NonGTINNumericIdentifierCreator,
|
|
16
|
-
type NonGTINNumericIdentifierDescriptor,
|
|
17
14
|
type NonGTINNumericIdentifierType,
|
|
18
15
|
type NonNumericIdentifierCreator,
|
|
19
|
-
type NonNumericIdentifierDescriptor,
|
|
20
16
|
type NonNumericIdentifierType,
|
|
21
17
|
type NonNumericIdentifierValidation,
|
|
18
|
+
type NonSerializableNumericIdentifierType,
|
|
22
19
|
type NumericIdentifierCreator,
|
|
23
|
-
type NumericIdentifierDescriptor,
|
|
24
20
|
type NumericIdentifierType,
|
|
25
21
|
type NumericIdentifierValidation,
|
|
26
22
|
PrefixManager,
|
|
@@ -28,11 +24,10 @@ import {
|
|
|
28
24
|
PrefixTypes,
|
|
29
25
|
PrefixValidator,
|
|
30
26
|
type SerializableNumericIdentifierCreator,
|
|
31
|
-
type SerializableNumericIdentifierDescriptor,
|
|
32
27
|
type SerializableNumericIdentifierType
|
|
33
28
|
} from "@aidc-toolkit/gs1";
|
|
34
29
|
import { Sequence } from "@aidc-toolkit/utility";
|
|
35
|
-
import type { AppExtension } from "../app-extension";
|
|
30
|
+
import type { AppExtension } from "../app-extension.js";
|
|
36
31
|
import {
|
|
37
32
|
expandParameterDescriptor,
|
|
38
33
|
type ParameterDescriptor,
|
|
@@ -40,17 +35,17 @@ import {
|
|
|
40
35
|
ProxyMethod,
|
|
41
36
|
ProxyParameter,
|
|
42
37
|
Types
|
|
43
|
-
} from "../descriptor";
|
|
44
|
-
import { LibProxy } from "../lib-proxy";
|
|
45
|
-
import { i18nextAppExtension } from "../locale/i18n";
|
|
46
|
-
import type { ErrorExtends, Matrix, MatrixResultError } from "../type";
|
|
47
|
-
import { exclusionAllNumericParameterDescriptor } from "../utility/character-set-descriptor";
|
|
48
|
-
import { StringProxy } from "../utility/string-proxy";
|
|
38
|
+
} from "../descriptor.js";
|
|
39
|
+
import { LibProxy } from "../lib-proxy.js";
|
|
40
|
+
import { i18nextAppExtension } from "../locale/i18n.js";
|
|
41
|
+
import type { ErrorExtends, Matrix, MatrixResultError } from "../type.js";
|
|
42
|
+
import { exclusionAllNumericParameterDescriptor } from "../utility/character-set-descriptor.js";
|
|
43
|
+
import { StringProxy } from "../utility/string-proxy.js";
|
|
49
44
|
import {
|
|
50
45
|
countParameterDescriptor,
|
|
51
46
|
startValueParameterDescriptor,
|
|
52
47
|
valueParameterDescriptor
|
|
53
|
-
} from "../utility/transformer-descriptor";
|
|
48
|
+
} from "../utility/transformer-descriptor.js";
|
|
54
49
|
|
|
55
50
|
const identifierParameterDescriptor: ParameterDescriptor = {
|
|
56
51
|
name: "identifier",
|
|
@@ -66,16 +61,16 @@ const validateIdentifierParameterDescriptor: ParameterDescriptor = {
|
|
|
66
61
|
};
|
|
67
62
|
|
|
68
63
|
abstract class IdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt, TIdentifierType extends IdentifierType> extends StringProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
69
|
-
|
|
64
|
+
readonly #validator: IdentifierTypeValidator<TIdentifierType>;
|
|
70
65
|
|
|
71
66
|
protected constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>, validator: IdentifierTypeValidator<TIdentifierType>) {
|
|
72
67
|
super(appExtension);
|
|
73
68
|
|
|
74
|
-
this
|
|
69
|
+
this.#validator = validator;
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
protected get validator(): IdentifierTypeValidator<TIdentifierType> {
|
|
78
|
-
return this
|
|
73
|
+
return this.#validator;
|
|
79
74
|
}
|
|
80
75
|
}
|
|
81
76
|
|
|
@@ -91,12 +86,15 @@ abstract class NumericIdentifierValidatorProxy<ThrowError extends boolean, TErro
|
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
88
|
|
|
94
|
-
abstract class GTINValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt,
|
|
89
|
+
abstract class GTINValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, GTINType> {
|
|
95
90
|
}
|
|
96
91
|
|
|
97
92
|
abstract class NonGTINNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt, TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType = NonGTINNumericIdentifierType> extends NumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, TNonGTINNumericIdentifierType> {
|
|
98
93
|
}
|
|
99
94
|
|
|
95
|
+
abstract class NonSerializableNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonGTINNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonSerializableNumericIdentifierType> {
|
|
96
|
+
}
|
|
97
|
+
|
|
100
98
|
abstract class SerializableNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonGTINNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, SerializableNumericIdentifierType> {
|
|
101
99
|
}
|
|
102
100
|
|
|
@@ -121,7 +119,7 @@ abstract class NonNumericIdentifierValidatorProxy<ThrowError extends boolean, TE
|
|
|
121
119
|
})
|
|
122
120
|
export class GTIN13ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
123
121
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
124
|
-
super(appExtension, IdentifierValidators.GTIN[
|
|
122
|
+
super(appExtension, IdentifierValidators.GTIN[GTINLengths.GTIN13]);
|
|
125
123
|
}
|
|
126
124
|
}
|
|
127
125
|
|
|
@@ -131,7 +129,7 @@ export class GTIN13ValidatorProxy<ThrowError extends boolean, TError extends Err
|
|
|
131
129
|
})
|
|
132
130
|
export class GTIN12ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
133
131
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
134
|
-
super(appExtension, IdentifierValidators.GTIN[
|
|
132
|
+
super(appExtension, IdentifierValidators.GTIN[GTINLengths.GTIN12]);
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
135
|
|
|
@@ -141,7 +139,7 @@ export class GTIN12ValidatorProxy<ThrowError extends boolean, TError extends Err
|
|
|
141
139
|
})
|
|
142
140
|
export class GTIN8ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
143
141
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
144
|
-
super(appExtension, IdentifierValidators.GTIN[
|
|
142
|
+
super(appExtension, IdentifierValidators.GTIN[GTINLengths.GTIN8]);
|
|
145
143
|
}
|
|
146
144
|
}
|
|
147
145
|
|
|
@@ -309,7 +307,7 @@ export class GTINValidatorStaticProxy<ThrowError extends boolean, TError extends
|
|
|
309
307
|
namespace: "GS1",
|
|
310
308
|
methodInfix: "GLN"
|
|
311
309
|
})
|
|
312
|
-
export class GLNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends
|
|
310
|
+
export class GLNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
313
311
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
314
312
|
super(appExtension, IdentifierValidators.GLN);
|
|
315
313
|
}
|
|
@@ -319,7 +317,7 @@ export class GLNValidatorProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
319
317
|
namespace: "GS1",
|
|
320
318
|
methodInfix: "SSCC"
|
|
321
319
|
})
|
|
322
|
-
export class SSCCValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends
|
|
320
|
+
export class SSCCValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
323
321
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
324
322
|
super(appExtension, IdentifierValidators.SSCC);
|
|
325
323
|
}
|
|
@@ -349,7 +347,7 @@ export class GIAIValidatorProxy<ThrowError extends boolean, TError extends Error
|
|
|
349
347
|
namespace: "GS1",
|
|
350
348
|
methodInfix: "GSRN"
|
|
351
349
|
})
|
|
352
|
-
export class GSRNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends
|
|
350
|
+
export class GSRNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
353
351
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
354
352
|
super(appExtension, IdentifierValidators.GSRN);
|
|
355
353
|
}
|
|
@@ -379,7 +377,7 @@ export class GINCValidatorProxy<ThrowError extends boolean, TError extends Error
|
|
|
379
377
|
namespace: "GS1",
|
|
380
378
|
methodInfix: "GSIN"
|
|
381
379
|
})
|
|
382
|
-
export class GSINValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends
|
|
380
|
+
export class GSINValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
383
381
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
384
382
|
super(appExtension, IdentifierValidators.GSIN);
|
|
385
383
|
}
|
|
@@ -471,15 +469,15 @@ export class PrefixManagerProxy<ThrowError extends boolean, TError extends Error
|
|
|
471
469
|
}
|
|
472
470
|
}
|
|
473
471
|
|
|
474
|
-
abstract class IdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt,
|
|
475
|
-
|
|
472
|
+
abstract class IdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt, TIdentifierType extends IdentifierType, TIdentifierValidation extends IdentifierValidation, TIdentifierCreator extends IdentifierCreator<TIdentifierType, TIdentifierValidation>> extends LibProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
473
|
+
static readonly #PREFIX_TYPES: Array<PrefixType | undefined> = [PrefixTypes.GS1CompanyPrefix, PrefixTypes.UPCCompanyPrefix, PrefixTypes.GS18Prefix];
|
|
476
474
|
|
|
477
|
-
|
|
475
|
+
readonly #getCreator: (prefixManager: PrefixManager) => TIdentifierCreator;
|
|
478
476
|
|
|
479
477
|
protected constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>, getCreator: (prefixManager: PrefixManager) => TIdentifierCreator) {
|
|
480
478
|
super(appExtension);
|
|
481
479
|
|
|
482
|
-
this
|
|
480
|
+
this.#getCreator = getCreator;
|
|
483
481
|
}
|
|
484
482
|
|
|
485
483
|
protected getCreator(prefixDefinition: Matrix<unknown>): TIdentifierCreator {
|
|
@@ -506,13 +504,13 @@ abstract class IdentifierCreatorProxy<ThrowError extends boolean, TError extends
|
|
|
506
504
|
|
|
507
505
|
const prefixTypeIndex = reducedPrefixDefinition[1] ?? 0;
|
|
508
506
|
|
|
509
|
-
if (typeof prefixTypeIndex !== "number" || prefixTypeIndex < 0 || prefixTypeIndex >= IdentifierCreatorProxy
|
|
507
|
+
if (typeof prefixTypeIndex !== "number" || prefixTypeIndex < 0 || prefixTypeIndex >= IdentifierCreatorProxy.#PREFIX_TYPES.length) {
|
|
510
508
|
throw new RangeError(i18nextAppExtension.t("IdentifierCreatorProxy.prefixTypeMustBeNumber", {
|
|
511
|
-
maximumPrefixType: IdentifierCreatorProxy
|
|
509
|
+
maximumPrefixType: IdentifierCreatorProxy.#PREFIX_TYPES.length - 1
|
|
512
510
|
}));
|
|
513
511
|
}
|
|
514
512
|
|
|
515
|
-
const prefixType = IdentifierCreatorProxy
|
|
513
|
+
const prefixType = IdentifierCreatorProxy.#PREFIX_TYPES[prefixTypeIndex];
|
|
516
514
|
|
|
517
515
|
// Undefined is included in type in case of invalid input.
|
|
518
516
|
if (prefixType === undefined) {
|
|
@@ -533,7 +531,7 @@ abstract class IdentifierCreatorProxy<ThrowError extends boolean, TError extends
|
|
|
533
531
|
prefixManager.resetTweakFactor();
|
|
534
532
|
}
|
|
535
533
|
|
|
536
|
-
return this
|
|
534
|
+
return this.#getCreator(prefixManager);
|
|
537
535
|
}
|
|
538
536
|
}
|
|
539
537
|
|
|
@@ -544,7 +542,7 @@ const sparseParameterDescriptor: ParameterDescriptor = {
|
|
|
544
542
|
isRequired: false
|
|
545
543
|
};
|
|
546
544
|
|
|
547
|
-
abstract class NumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt,
|
|
545
|
+
abstract class NumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt, TNumericIdentifierType extends NumericIdentifierType, TNumericIdentifierCreator extends NumericIdentifierCreator<TNumericIdentifierType>> extends IdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, TNumericIdentifierType, NumericIdentifierValidation, TNumericIdentifierCreator> {
|
|
548
546
|
@ProxyMethod({
|
|
549
547
|
type: Types.String,
|
|
550
548
|
isMatrix: true
|
|
@@ -592,7 +590,10 @@ abstract class NumericIdentifierCreatorProxy<ThrowError extends boolean, TError
|
|
|
592
590
|
}
|
|
593
591
|
}
|
|
594
592
|
|
|
595
|
-
abstract class NonGTINNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt,
|
|
593
|
+
abstract class NonGTINNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt, TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType, TNonGTINNumericIdentifierCreator extends NonGTINNumericIdentifierCreator> extends NumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, TNonGTINNumericIdentifierType, TNonGTINNumericIdentifierCreator> {
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
abstract class NonSerializableNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt, TNonSerializableNumericIdentifierType extends NonSerializableNumericIdentifierType, TNonGTINNumericIdentifierCreator extends NonGTINNumericIdentifierCreator> extends NonGTINNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, TNonSerializableNumericIdentifierType, TNonGTINNumericIdentifierCreator> {
|
|
596
597
|
}
|
|
597
598
|
|
|
598
599
|
const singleValueParameterDescriptor: ParameterDescriptor = {
|
|
@@ -613,7 +614,7 @@ const serialComponentParameterDescriptor: ParameterDescriptor = {
|
|
|
613
614
|
isRequired: true
|
|
614
615
|
};
|
|
615
616
|
|
|
616
|
-
abstract class SerializableNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonGTINNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt,
|
|
617
|
+
abstract class SerializableNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonGTINNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, SerializableNumericIdentifierType, SerializableNumericIdentifierCreator> {
|
|
617
618
|
@ProxyMethod({
|
|
618
619
|
type: Types.String,
|
|
619
620
|
isMatrix: true
|
|
@@ -652,7 +653,7 @@ const referenceParameterDescriptor: ParameterDescriptor = {
|
|
|
652
653
|
isRequired: true
|
|
653
654
|
};
|
|
654
655
|
|
|
655
|
-
abstract class NonNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends IdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt,
|
|
656
|
+
abstract class NonNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends IdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonNumericIdentifierType, NonNumericIdentifierValidation, NonNumericIdentifierCreator> {
|
|
656
657
|
@ProxyMethod({
|
|
657
658
|
type: Types.String,
|
|
658
659
|
isMatrix: true
|
|
@@ -677,7 +678,7 @@ abstract class NonNumericIdentifierCreatorProxy<ThrowError extends boolean, TErr
|
|
|
677
678
|
}
|
|
678
679
|
]
|
|
679
680
|
})
|
|
680
|
-
export class GTINCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt,
|
|
681
|
+
export class GTINCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, GTINType, GTINCreator> {
|
|
681
682
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
682
683
|
super(appExtension, prefixManager => prefixManager.gtinCreator);
|
|
683
684
|
}
|
|
@@ -718,7 +719,7 @@ export class GTINCreatorProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
718
719
|
namespace: "GS1",
|
|
719
720
|
methodInfix: "GLN"
|
|
720
721
|
})
|
|
721
|
-
export class GLNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends
|
|
722
|
+
export class GLNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
722
723
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
723
724
|
super(appExtension, prefixManager => prefixManager.glnCreator);
|
|
724
725
|
}
|
|
@@ -728,7 +729,7 @@ export class GLNCreatorProxy<ThrowError extends boolean, TError extends ErrorExt
|
|
|
728
729
|
namespace: "GS1",
|
|
729
730
|
methodInfix: "SSCC"
|
|
730
731
|
})
|
|
731
|
-
export class SSCCCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends
|
|
732
|
+
export class SSCCCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
732
733
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
733
734
|
super(appExtension, prefixManager => prefixManager.ssccCreator);
|
|
734
735
|
}
|
|
@@ -758,7 +759,7 @@ export class GIAICreatorProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
758
759
|
namespace: "GS1",
|
|
759
760
|
methodInfix: "GSRN"
|
|
760
761
|
})
|
|
761
|
-
export class GSRNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends
|
|
762
|
+
export class GSRNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
762
763
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
763
764
|
super(appExtension, prefixManager => prefixManager.gsrnCreator);
|
|
764
765
|
}
|
|
@@ -788,7 +789,7 @@ export class GINCCreatorProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
788
789
|
namespace: "GS1",
|
|
789
790
|
methodInfix: "GSIN"
|
|
790
791
|
})
|
|
791
|
-
export class GSINCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends
|
|
792
|
+
export class GSINCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
792
793
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
793
794
|
super(appExtension, prefixManager => prefixManager.gsinCreator);
|
|
794
795
|
}
|
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.js";
|
|
2
|
+
export * from "./check-proxy.js";
|
|
3
|
+
export * from "./identifier-proxy.js";
|
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 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";
|
|
17
|
+
export * from "./locale/i18n.js";
|
|
18
|
+
export type * from "./type.js";
|
|
19
|
+
export * from "./app-extension.js";
|
|
20
|
+
export * from "./lib-proxy.js";
|
|
21
|
+
export * from "./descriptor.js";
|
|
22
|
+
export * from "./app-utility-proxy.js";
|
|
23
|
+
export * from "./utility/index.js";
|
|
24
|
+
export * as GS1 from "./gs1/index.js";
|
|
25
|
+
export * from "./generator/index.js";
|