@aidc-toolkit/app-extension 1.0.26-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 +127 -114
- 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 +128 -115
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/app-extension.ts +28 -19
- package/src/app-utility-proxy.ts +15 -3
- package/src/descriptor.ts +61 -1
- package/src/generator/descriptor.ts +5 -2
- package/src/generator/generator.ts +22 -19
- package/src/generator/locale-resources-generator.ts +29 -29
- package/src/gs1/identifier-proxy.ts +37 -36
- package/src/lib-proxy.ts +21 -18
- package/src/utility/character-set-proxy.ts +8 -8
|
@@ -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,7 +24,6 @@ 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";
|
|
@@ -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/lib-proxy.ts
CHANGED
|
@@ -6,20 +6,23 @@ import type { ErrorExtends, Matrix, MatrixResultError, ResultError } from "./typ
|
|
|
6
6
|
/**
|
|
7
7
|
* Library proxy.
|
|
8
8
|
*
|
|
9
|
-
* @template TBigInt
|
|
10
|
-
* Type to which big integer is mapped.
|
|
11
|
-
*
|
|
12
9
|
* @template ThrowError
|
|
13
10
|
* If true, errors are reported through the throw/catch mechanism.
|
|
14
11
|
*
|
|
15
12
|
* @template TError
|
|
16
13
|
* Error type.
|
|
14
|
+
*
|
|
15
|
+
* @template TInvocationContext
|
|
16
|
+
* Application-specific invocation context type.
|
|
17
|
+
*
|
|
18
|
+
* @template TBigInt
|
|
19
|
+
* Type to which big integer is mapped.
|
|
17
20
|
*/
|
|
18
21
|
export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> {
|
|
19
22
|
/**
|
|
20
23
|
* Application extension.
|
|
21
24
|
*/
|
|
22
|
-
|
|
25
|
+
readonly #appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>;
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
* Constructor.
|
|
@@ -28,14 +31,14 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
28
31
|
* Application extension.
|
|
29
32
|
*/
|
|
30
33
|
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
31
|
-
this
|
|
34
|
+
this.#appExtension = appExtension;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
/**
|
|
35
38
|
* Get the application extension.
|
|
36
39
|
*/
|
|
37
40
|
protected get appExtension(): AppExtension<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
38
|
-
return this
|
|
41
|
+
return this.#appExtension;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
/**
|
|
@@ -48,7 +51,7 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
48
51
|
* Mapped big integer value.
|
|
49
52
|
*/
|
|
50
53
|
mapBigInt(value: bigint): ResultError<TBigInt, ThrowError, TError> {
|
|
51
|
-
return this.
|
|
54
|
+
return this.#appExtension.mapBigInt(value);
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
/**
|
|
@@ -60,13 +63,13 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
60
63
|
* @returns
|
|
61
64
|
* Error if errors are not thrown.
|
|
62
65
|
*/
|
|
63
|
-
|
|
66
|
+
#handleError<TResult>(e: unknown): ResultError<TResult, ThrowError, TError> {
|
|
64
67
|
let result: ResultError<TResult, ThrowError, TError>;
|
|
65
68
|
|
|
66
69
|
if (e instanceof RangeError) {
|
|
67
|
-
const error = this.
|
|
70
|
+
const error = this.#appExtension.mapRangeError(e);
|
|
68
71
|
|
|
69
|
-
if (this.
|
|
72
|
+
if (this.#appExtension.throwError) {
|
|
70
73
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type is determined by application mapping.
|
|
71
74
|
throw error as Error;
|
|
72
75
|
}
|
|
@@ -94,13 +97,13 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
94
97
|
* @returns
|
|
95
98
|
* Callback result or error if errors are not thrown.
|
|
96
99
|
*/
|
|
97
|
-
|
|
100
|
+
#doCallback<TValue, TResult>(value: TValue, callback: (value: TValue) => TResult): ResultError<TResult, ThrowError, TError> {
|
|
98
101
|
let result: ResultError<TResult, ThrowError, TError>;
|
|
99
102
|
|
|
100
103
|
try {
|
|
101
104
|
result = callback(value);
|
|
102
105
|
} catch (e: unknown) {
|
|
103
|
-
result = this
|
|
106
|
+
result = this.#handleError(e);
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
return result;
|
|
@@ -119,7 +122,7 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
119
122
|
* Matrix of callback results and errors if errors are not thrown.
|
|
120
123
|
*/
|
|
121
124
|
protected mapMatrix<TValue, TResult>(matrixValues: Matrix<TValue>, callback: (value: TValue) => TResult): MatrixResultError<TResult, ThrowError, TError> {
|
|
122
|
-
return matrixValues.map(rowValues => rowValues.map(value => this
|
|
125
|
+
return matrixValues.map(rowValues => rowValues.map(value => this.#doCallback(value, callback)));
|
|
123
126
|
}
|
|
124
127
|
|
|
125
128
|
/**
|
|
@@ -134,8 +137,8 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
134
137
|
* @returns
|
|
135
138
|
* Callback result or error as array if errors are not thrown.
|
|
136
139
|
*/
|
|
137
|
-
|
|
138
|
-
const result = this
|
|
140
|
+
#doArrayCallback<TValue, TResult>(value: TValue, callback: (value: TValue) => TResult[]): Array<ResultError<TResult, ThrowError, TError>> {
|
|
141
|
+
const result = this.#doCallback(value, callback);
|
|
139
142
|
|
|
140
143
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type determination is handled.
|
|
141
144
|
return result instanceof Array ? result : [result as ResultError<TResult, ThrowError, TError>];
|
|
@@ -163,7 +166,7 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
163
166
|
matrixResultError = [];
|
|
164
167
|
|
|
165
168
|
matrixValues[0].forEach((value, columnIndex) => {
|
|
166
|
-
const arrayResultError = this
|
|
169
|
+
const arrayResultError = this.#doArrayCallback(value, callback);
|
|
167
170
|
|
|
168
171
|
arrayResultError.forEach((resultError, rowIndex) => {
|
|
169
172
|
if (matrixResultError.length <= rowIndex) {
|
|
@@ -182,9 +185,9 @@ export abstract class LibProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
182
185
|
// Special case; unlikely to occur.
|
|
183
186
|
arrayResultError = [];
|
|
184
187
|
} else if (rowValue.length === 1) {
|
|
185
|
-
arrayResultError = this
|
|
188
|
+
arrayResultError = this.#doArrayCallback(rowValue[0], callback);
|
|
186
189
|
} else {
|
|
187
|
-
arrayResultError = [this
|
|
190
|
+
arrayResultError = [this.#handleError(new RangeError(i18nextAppExtension.t("Proxy.matrixMustBeArray")))];
|
|
188
191
|
}
|
|
189
192
|
|
|
190
193
|
return arrayResultError;
|
|
@@ -48,12 +48,12 @@ const valueForSParameterDescriptor: ParameterDescriptor = {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
export abstract class CharacterSetValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends StringProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
51
|
-
|
|
51
|
+
readonly #characterSetValidator: CharacterSetValidator;
|
|
52
52
|
|
|
53
53
|
protected constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>, characterSetValidator: CharacterSetValidator) {
|
|
54
54
|
super(appExtension);
|
|
55
55
|
|
|
56
|
-
this
|
|
56
|
+
this.#characterSetValidator = characterSetValidator;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
@ProxyMethod({
|
|
@@ -64,7 +64,7 @@ export abstract class CharacterSetValidatorProxy<ThrowError extends boolean, TEr
|
|
|
64
64
|
@ProxyParameter(validateSParameterDescriptor) matrixSs: Matrix<string>,
|
|
65
65
|
@ProxyParameter(exclusionNoneParameterDescriptor) exclusion: Nullishable<Exclusion>
|
|
66
66
|
): MatrixResultError<string, ThrowError, TError> {
|
|
67
|
-
return this.validateString(this
|
|
67
|
+
return this.validateString(this.#characterSetValidator, matrixSs, {
|
|
68
68
|
exclusion: exclusion ?? undefined
|
|
69
69
|
} satisfies CharacterSetValidation);
|
|
70
70
|
}
|
|
@@ -82,12 +82,12 @@ export abstract class CharacterSetValidatorProxy<ThrowError extends boolean, TEr
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends CharacterSetValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
85
|
-
|
|
85
|
+
readonly #characterSetCreator: CharacterSetCreator;
|
|
86
86
|
|
|
87
87
|
protected constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>, characterSetCreator: CharacterSetCreator) {
|
|
88
88
|
super(appExtension, characterSetCreator);
|
|
89
89
|
|
|
90
|
-
this
|
|
90
|
+
this.#characterSetCreator = characterSetCreator;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
@ProxyMethod({
|
|
@@ -103,7 +103,7 @@ export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TErro
|
|
|
103
103
|
const exclusionOrUndefined = exclusion ?? undefined;
|
|
104
104
|
const tweakOrUndefined = tweak ?? undefined;
|
|
105
105
|
|
|
106
|
-
return this.mapMatrix(matrixValues, value => this.
|
|
106
|
+
return this.mapMatrix(matrixValues, value => this.#characterSetCreator.create(length, value, exclusionOrUndefined, tweakOrUndefined));
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
@ProxyMethod({
|
|
@@ -123,7 +123,7 @@ export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TErro
|
|
|
123
123
|
const exclusionOrUndefined = exclusion ?? undefined;
|
|
124
124
|
const tweakOrUndefined = tweak ?? undefined;
|
|
125
125
|
|
|
126
|
-
return LibProxy.matrixResult(this.
|
|
126
|
+
return LibProxy.matrixResult(this.#characterSetCreator.create(length, new Sequence(startValue, count), exclusionOrUndefined, tweakOrUndefined));
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
@ProxyMethod({
|
|
@@ -138,7 +138,7 @@ export abstract class CharacterSetCreatorProxy<ThrowError extends boolean, TErro
|
|
|
138
138
|
const exclusionOrUndefined = exclusion ?? undefined;
|
|
139
139
|
const tweakOrUndefined = tweak ?? undefined;
|
|
140
140
|
|
|
141
|
-
return this.mapMatrix(matrixSs, s => this.mapBigInt(this.
|
|
141
|
+
return this.mapMatrix(matrixSs, s => this.mapBigInt(this.#characterSetCreator.valueFor(s, exclusionOrUndefined, tweakOrUndefined)));
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|