@aidc-toolkit/app-extension 1.0.26-beta → 1.0.28-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 +1205 -967
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +134 -312
- package/dist/index.d.ts +134 -312
- package/dist/index.js +1207 -964
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/app-extension.ts +33 -24
- package/src/app-utility-proxy.ts +33 -27
- package/src/descriptor.ts +29 -199
- package/src/generator/generator.ts +102 -145
- package/src/generator/index.ts +0 -1
- package/src/generator/locale-resources-generator.ts +67 -42
- package/src/gs1/character-set-proxy.ts +5 -5
- package/src/gs1/check-proxy.ts +35 -42
- package/src/gs1/gtin-creator-proxy.ts +58 -0
- package/src/gs1/gtin-descriptor.ts +29 -0
- package/src/gs1/gtin-validator-proxy.ts +161 -0
- package/src/gs1/identifier-creator-proxy.ts +227 -0
- package/src/gs1/identifier-validator-proxy.ts +87 -0
- package/src/gs1/index.ts +5 -1
- package/src/gs1/non-gtin-creator-proxy.ts +119 -0
- package/src/gs1/non-gtin-validator-proxy.ts +119 -0
- package/src/gs1/prefix-definition-descriptor.ts +18 -0
- package/src/gs1/prefix-manager-proxy.ts +42 -0
- package/src/index.ts +1 -0
- package/src/lib-proxy.ts +22 -19
- package/src/proxy.ts +509 -0
- package/src/utility/character-set-descriptor.ts +5 -5
- package/src/utility/character-set-proxy.ts +39 -55
- package/src/utility/reg-exp-proxy.ts +11 -15
- package/src/utility/string-descriptor.ts +2 -2
- package/src/utility/transformer-descriptor.ts +3 -3
- package/src/utility/transformer-proxy.ts +16 -26
- package/tsconfig-src.json +1 -4
- package/src/generator/descriptor.ts +0 -122
- package/src/gs1/identifier-proxy.ts +0 -825
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Nullishable } from "@aidc-toolkit/core";
|
|
2
|
+
import type {
|
|
3
|
+
GTINType,
|
|
4
|
+
IdentifierType,
|
|
5
|
+
IdentifierTypeValidator,
|
|
6
|
+
NonGTINNumericIdentifierType,
|
|
7
|
+
NonNumericIdentifierType,
|
|
8
|
+
NonNumericIdentifierValidation,
|
|
9
|
+
NonSerializableNumericIdentifierType,
|
|
10
|
+
NumericIdentifierType,
|
|
11
|
+
SerializableNumericIdentifierType
|
|
12
|
+
} from "@aidc-toolkit/gs1";
|
|
13
|
+
import type { AppExtension } from "../app-extension.js";
|
|
14
|
+
import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
15
|
+
import { proxy } from "../proxy.js";
|
|
16
|
+
import type { ErrorExtends, Matrix, MatrixResultError } from "../type.js";
|
|
17
|
+
import { exclusionAllNumericParameterDescriptor } from "../utility/character-set-descriptor.js";
|
|
18
|
+
import { StringProxy } from "../utility/string-proxy.js";
|
|
19
|
+
|
|
20
|
+
export const identifierParameterDescriptor: ParameterDescriptor = {
|
|
21
|
+
name: "identifier",
|
|
22
|
+
type: Types.String,
|
|
23
|
+
isMatrix: true,
|
|
24
|
+
isRequired: true
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const validateIdentifierParameterDescriptor: ExtendsParameterDescriptor = {
|
|
28
|
+
extendsDescriptor: identifierParameterDescriptor,
|
|
29
|
+
sortOrder: 0,
|
|
30
|
+
name: "validateIdentifier"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
abstract class IdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt, TIdentifierType extends IdentifierType> extends StringProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
34
|
+
readonly #validator: IdentifierTypeValidator<TIdentifierType>;
|
|
35
|
+
|
|
36
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>, validator: IdentifierTypeValidator<TIdentifierType>) {
|
|
37
|
+
super(appExtension);
|
|
38
|
+
|
|
39
|
+
this.#validator = validator;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected get validator(): IdentifierTypeValidator<TIdentifierType> {
|
|
43
|
+
return this.#validator;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@proxy.describeClass(true, {
|
|
48
|
+
namespace: "GS1"
|
|
49
|
+
})
|
|
50
|
+
abstract class NumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt, TNumericIdentifierType extends NumericIdentifierType> extends IdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, TNumericIdentifierType> {
|
|
51
|
+
@proxy.describeMethod({
|
|
52
|
+
type: Types.String,
|
|
53
|
+
isMatrix: true,
|
|
54
|
+
parameterDescriptors: [validateIdentifierParameterDescriptor]
|
|
55
|
+
})
|
|
56
|
+
validate(matrixIdentifiers: Matrix<string>): MatrixResultError<string, ThrowError, TError> {
|
|
57
|
+
return this.validateString(this.validator, matrixIdentifiers);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export abstract class GTINValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, GTINType> {
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
abstract class NonGTINNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt, TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType = NonGTINNumericIdentifierType> extends NumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, TNonGTINNumericIdentifierType> {
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export abstract class NonSerializableNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonGTINNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonSerializableNumericIdentifierType> {
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export abstract class SerializableNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonGTINNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, SerializableNumericIdentifierType> {
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@proxy.describeClass(true, {
|
|
74
|
+
namespace: "GS1"
|
|
75
|
+
})
|
|
76
|
+
export abstract class NonNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends IdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonNumericIdentifierType> {
|
|
77
|
+
@proxy.describeMethod({
|
|
78
|
+
type: Types.String,
|
|
79
|
+
isMatrix: true,
|
|
80
|
+
parameterDescriptors: [validateIdentifierParameterDescriptor, exclusionAllNumericParameterDescriptor]
|
|
81
|
+
})
|
|
82
|
+
validate(matrixIdentifiers: Matrix<string>, exclusion: Nullishable<NonNumericIdentifierValidation["exclusion"]>): MatrixResultError<string, ThrowError, TError> {
|
|
83
|
+
return this.validateString(this.validator, matrixIdentifiers, {
|
|
84
|
+
exclusion: exclusion ?? undefined
|
|
85
|
+
} satisfies NonNumericIdentifierValidation);
|
|
86
|
+
}
|
|
87
|
+
}
|
package/src/gs1/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export * from "./character-set-proxy.js";
|
|
2
2
|
export * from "./check-proxy.js";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./gtin-validator-proxy.js";
|
|
4
|
+
export * from "./non-gtin-validator-proxy.js";
|
|
5
|
+
export * from "./prefix-manager-proxy.js";
|
|
6
|
+
export * from "./gtin-creator-proxy.js";
|
|
7
|
+
export * from "./non-gtin-creator-proxy.js";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { NonGTINNumericIdentifierCreator, NonSerializableNumericIdentifierType } from "@aidc-toolkit/gs1";
|
|
2
|
+
import type { AppExtension } from "../app-extension.js";
|
|
3
|
+
import { proxy } from "../proxy.js";
|
|
4
|
+
import type { ErrorExtends } from "../type.js";
|
|
5
|
+
import {
|
|
6
|
+
NonNumericIdentifierCreatorProxy,
|
|
7
|
+
NonSerializableNumericIdentifierCreatorProxy,
|
|
8
|
+
SerializableNumericIdentifierCreatorProxy
|
|
9
|
+
} from "./identifier-creator-proxy.js";
|
|
10
|
+
|
|
11
|
+
@proxy.describeClass(false, {
|
|
12
|
+
namespace: "GS1",
|
|
13
|
+
methodInfix: "GLN"
|
|
14
|
+
})
|
|
15
|
+
export class GLNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
16
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
17
|
+
super(appExtension, prefixManager => prefixManager.glnCreator);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@proxy.describeClass(false, {
|
|
22
|
+
namespace: "GS1",
|
|
23
|
+
methodInfix: "SSCC"
|
|
24
|
+
})
|
|
25
|
+
export class SSCCCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
26
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
27
|
+
super(appExtension, prefixManager => prefixManager.ssccCreator);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@proxy.describeClass(false, {
|
|
32
|
+
namespace: "GS1",
|
|
33
|
+
methodInfix: "GRAI"
|
|
34
|
+
})
|
|
35
|
+
export class GRAICreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends SerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
36
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
37
|
+
super(appExtension, prefixManager => prefixManager.graiCreator);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@proxy.describeClass(false, {
|
|
42
|
+
namespace: "GS1",
|
|
43
|
+
methodInfix: "GIAI"
|
|
44
|
+
})
|
|
45
|
+
export class GIAICreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
46
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
47
|
+
super(appExtension, prefixManager => prefixManager.giaiCreator);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@proxy.describeClass(false, {
|
|
52
|
+
namespace: "GS1",
|
|
53
|
+
methodInfix: "GSRN"
|
|
54
|
+
})
|
|
55
|
+
export class GSRNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
56
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
57
|
+
super(appExtension, prefixManager => prefixManager.gsrnCreator);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@proxy.describeClass(false, {
|
|
62
|
+
namespace: "GS1",
|
|
63
|
+
methodInfix: "GDTI"
|
|
64
|
+
})
|
|
65
|
+
export class GDTICreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends SerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
66
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
67
|
+
super(appExtension, prefixManager => prefixManager.gdtiCreator);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@proxy.describeClass(false, {
|
|
72
|
+
namespace: "GS1",
|
|
73
|
+
methodInfix: "GINC"
|
|
74
|
+
})
|
|
75
|
+
export class GINCCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
76
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
77
|
+
super(appExtension, prefixManager => prefixManager.gincCreator);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@proxy.describeClass(false, {
|
|
82
|
+
namespace: "GS1",
|
|
83
|
+
methodInfix: "GSIN"
|
|
84
|
+
})
|
|
85
|
+
export class GSINCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
86
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
87
|
+
super(appExtension, prefixManager => prefixManager.gsinCreator);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@proxy.describeClass(false, {
|
|
92
|
+
namespace: "GS1",
|
|
93
|
+
methodInfix: "GCN"
|
|
94
|
+
})
|
|
95
|
+
export class GCNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends SerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
96
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
97
|
+
super(appExtension, prefixManager => prefixManager.gcnCreator);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@proxy.describeClass(false, {
|
|
102
|
+
namespace: "GS1",
|
|
103
|
+
methodInfix: "CPID"
|
|
104
|
+
})
|
|
105
|
+
export class CPIDCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
106
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
107
|
+
super(appExtension, prefixManager => prefixManager.cpidCreator);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@proxy.describeClass(false, {
|
|
112
|
+
namespace: "GS1",
|
|
113
|
+
methodInfix: "GMN"
|
|
114
|
+
})
|
|
115
|
+
export class GMNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
116
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
117
|
+
super(appExtension, prefixManager => prefixManager.gmnCreator);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { IdentifierValidators } from "@aidc-toolkit/gs1";
|
|
2
|
+
import type { AppExtension } from "../app-extension.js";
|
|
3
|
+
import { proxy } from "../proxy.js";
|
|
4
|
+
import type { ErrorExtends } from "../type.js";
|
|
5
|
+
import {
|
|
6
|
+
NonNumericIdentifierValidatorProxy,
|
|
7
|
+
NonSerializableNumericIdentifierValidatorProxy,
|
|
8
|
+
SerializableNumericIdentifierValidatorProxy
|
|
9
|
+
} from "./identifier-validator-proxy.js";
|
|
10
|
+
|
|
11
|
+
@proxy.describeClass(false, {
|
|
12
|
+
namespace: "GS1",
|
|
13
|
+
methodInfix: "GLN"
|
|
14
|
+
})
|
|
15
|
+
export class GLNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
16
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
17
|
+
super(appExtension, IdentifierValidators.GLN);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@proxy.describeClass(false, {
|
|
22
|
+
namespace: "GS1",
|
|
23
|
+
methodInfix: "SSCC"
|
|
24
|
+
})
|
|
25
|
+
export class SSCCValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
26
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
27
|
+
super(appExtension, IdentifierValidators.SSCC);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@proxy.describeClass(false, {
|
|
32
|
+
namespace: "GS1",
|
|
33
|
+
methodInfix: "GRAI"
|
|
34
|
+
})
|
|
35
|
+
export class GRAIValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends SerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
36
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
37
|
+
super(appExtension, IdentifierValidators.GRAI);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@proxy.describeClass(false, {
|
|
42
|
+
namespace: "GS1",
|
|
43
|
+
methodInfix: "GIAI"
|
|
44
|
+
})
|
|
45
|
+
export class GIAIValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
46
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
47
|
+
super(appExtension, IdentifierValidators.GIAI);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@proxy.describeClass(false, {
|
|
52
|
+
namespace: "GS1",
|
|
53
|
+
methodInfix: "GSRN"
|
|
54
|
+
})
|
|
55
|
+
export class GSRNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
56
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
57
|
+
super(appExtension, IdentifierValidators.GSRN);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@proxy.describeClass(false, {
|
|
62
|
+
namespace: "GS1",
|
|
63
|
+
methodInfix: "GDTI"
|
|
64
|
+
})
|
|
65
|
+
export class GDTIValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends SerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
66
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
67
|
+
super(appExtension, IdentifierValidators.GDTI);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@proxy.describeClass(false, {
|
|
72
|
+
namespace: "GS1",
|
|
73
|
+
methodInfix: "GINC"
|
|
74
|
+
})
|
|
75
|
+
export class GINCValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
76
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
77
|
+
super(appExtension, IdentifierValidators.GINC);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@proxy.describeClass(false, {
|
|
82
|
+
namespace: "GS1",
|
|
83
|
+
methodInfix: "GSIN"
|
|
84
|
+
})
|
|
85
|
+
export class GSINValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
86
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
87
|
+
super(appExtension, IdentifierValidators.GSIN);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@proxy.describeClass(false, {
|
|
92
|
+
namespace: "GS1",
|
|
93
|
+
methodInfix: "GCN"
|
|
94
|
+
})
|
|
95
|
+
export class GCNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends SerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
96
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
97
|
+
super(appExtension, IdentifierValidators.GCN);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@proxy.describeClass(false, {
|
|
102
|
+
namespace: "GS1",
|
|
103
|
+
methodInfix: "CPID"
|
|
104
|
+
})
|
|
105
|
+
export class CPIDValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
106
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
107
|
+
super(appExtension, IdentifierValidators.CPID);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@proxy.describeClass(false, {
|
|
112
|
+
namespace: "GS1",
|
|
113
|
+
methodInfix: "GMN"
|
|
114
|
+
})
|
|
115
|
+
export class GMNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
116
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
|
|
117
|
+
super(appExtension, IdentifierValidators.GMN);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
2
|
+
|
|
3
|
+
const prefixDefinitionParameterDescriptor: ParameterDescriptor = {
|
|
4
|
+
name: "prefixDefinition",
|
|
5
|
+
type: Types.Any,
|
|
6
|
+
isMatrix: true,
|
|
7
|
+
isRequired: true
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const prefixDefinitionGS1UPCParameterDescriptor: ExtendsParameterDescriptor = {
|
|
11
|
+
extendsDescriptor: prefixDefinitionParameterDescriptor,
|
|
12
|
+
name: "prefixDefinitionGS1UPC"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const prefixDefinitionAnyParameterDescriptor: ExtendsParameterDescriptor = {
|
|
16
|
+
extendsDescriptor: prefixDefinitionParameterDescriptor,
|
|
17
|
+
name: "prefixDefinitionAny"
|
|
18
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Nullishable } from "@aidc-toolkit/core";
|
|
2
|
+
import type { PrefixType } from "@aidc-toolkit/gs1";
|
|
3
|
+
import { type ParameterDescriptor, Types } from "../descriptor.js";
|
|
4
|
+
import { LibProxy } from "../lib-proxy.js";
|
|
5
|
+
import { proxy } from "../proxy.js";
|
|
6
|
+
import type { ErrorExtends, Matrix } from "../type.js";
|
|
7
|
+
|
|
8
|
+
const prefixParameterDescriptor: ParameterDescriptor = {
|
|
9
|
+
name: "prefix",
|
|
10
|
+
type: Types.String,
|
|
11
|
+
isMatrix: false,
|
|
12
|
+
isRequired: true
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const prefixTypeParameterDescriptor: ParameterDescriptor = {
|
|
16
|
+
name: "prefixType",
|
|
17
|
+
type: Types.Number,
|
|
18
|
+
isMatrix: false,
|
|
19
|
+
isRequired: false
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const tweakFactorParameterDescriptor: ParameterDescriptor = {
|
|
23
|
+
name: "tweakFactor",
|
|
24
|
+
type: Types.Number,
|
|
25
|
+
isMatrix: false,
|
|
26
|
+
isRequired: false
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
@proxy.describeClass(false, {
|
|
30
|
+
namespace: "GS1"
|
|
31
|
+
})
|
|
32
|
+
export class PrefixManagerProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
33
|
+
@proxy.describeMethod({
|
|
34
|
+
type: Types.Any,
|
|
35
|
+
isMatrix: true,
|
|
36
|
+
parameterDescriptors: [prefixParameterDescriptor, prefixTypeParameterDescriptor, tweakFactorParameterDescriptor]
|
|
37
|
+
})
|
|
38
|
+
definePrefix(prefix: string, prefixType: Nullishable<PrefixType>, tweakFactor: Nullishable<number>): Matrix<unknown> {
|
|
39
|
+
// Parameters will be validated by IdentifierCreatorProxy.getCreator().
|
|
40
|
+
return [[prefix, prefixType, tweakFactor]];
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/index.ts
CHANGED
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
|
-
|
|
38
|
-
return this
|
|
40
|
+
get appExtension(): AppExtension<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
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;
|