@aidc-toolkit/app-extension 1.0.31-beta → 1.0.32-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 +3446 -627
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +575 -300
- package/dist/index.d.ts +575 -300
- package/dist/index.js +3435 -610
- package/dist/index.js.map +1 -1
- package/package.json +8 -9
- package/src/app-data.ts +94 -0
- package/src/app-extension.ts +162 -93
- package/src/app-utility-proxy.ts +154 -103
- package/src/descriptor.ts +33 -6
- package/src/generator/generator.ts +3 -6
- package/src/generator/locale-resources-generator.ts +30 -28
- package/src/gs1/character-set-proxy.ts +8 -8
- package/src/gs1/check-proxy.ts +14 -14
- package/src/gs1/gtin-creator-proxy.ts +12 -25
- package/src/gs1/gtin-descriptor.ts +0 -21
- package/src/gs1/gtin-validator-proxy.ts +34 -35
- package/src/gs1/identifier-creator-proxy.ts +44 -32
- package/src/gs1/identifier-descriptor.ts +15 -0
- package/src/gs1/identifier-type.ts +37 -0
- package/src/gs1/identifier-validator-proxy.ts +52 -19
- package/src/gs1/index.ts +8 -0
- package/src/gs1/non-gtin-creator-proxy.ts +22 -22
- package/src/gs1/non-gtin-validator-proxy.ts +22 -22
- package/src/gs1/prefix-manager-proxy.ts +199 -4
- package/src/gs1/service-proxy.ts +56 -0
- package/src/gs1/variable-measure-proxy.ts +61 -0
- package/src/index.ts +6 -0
- package/src/lib-proxy.ts +112 -70
- package/src/locale/en/locale-resources.ts +147 -34
- package/src/locale/fr/locale-resources.ts +147 -34
- package/src/locale/i18n.ts +2 -5
- package/src/proxy.ts +82 -106
- package/src/streaming.ts +13 -0
- package/src/type.ts +8 -7
- package/src/utility/character-set-proxy.ts +33 -32
- package/src/utility/reg-exp-proxy.ts +7 -6
- package/src/utility/string-proxy.ts +3 -7
- package/src/utility/transformer-proxy.ts +19 -13
|
@@ -11,18 +11,12 @@ import type {
|
|
|
11
11
|
SerializableNumericIdentifierType
|
|
12
12
|
} from "@aidc-toolkit/gs1";
|
|
13
13
|
import type { AppExtension } from "../app-extension.js";
|
|
14
|
-
import { type ExtendsParameterDescriptor,
|
|
14
|
+
import { type ExtendsParameterDescriptor, Types } from "../descriptor.js";
|
|
15
15
|
import { proxy } from "../proxy.js";
|
|
16
|
-
import type { ErrorExtends, Matrix,
|
|
16
|
+
import type { ErrorExtends, Matrix, MatrixResult } from "../type.js";
|
|
17
17
|
import { exclusionAllNumericParameterDescriptor } from "../utility/character-set-descriptor.js";
|
|
18
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
|
-
};
|
|
19
|
+
import { identifierParameterDescriptor } from "./identifier-descriptor.js";
|
|
26
20
|
|
|
27
21
|
const validateIdentifierParameterDescriptor: ExtendsParameterDescriptor = {
|
|
28
22
|
extendsDescriptor: identifierParameterDescriptor,
|
|
@@ -30,10 +24,16 @@ const validateIdentifierParameterDescriptor: ExtendsParameterDescriptor = {
|
|
|
30
24
|
name: "validateIdentifier"
|
|
31
25
|
};
|
|
32
26
|
|
|
33
|
-
|
|
27
|
+
const splitIdentifierParameterDescriptor: ExtendsParameterDescriptor = {
|
|
28
|
+
extendsDescriptor: identifierParameterDescriptor,
|
|
29
|
+
sortOrder: 1,
|
|
30
|
+
name: "splitIdentifier"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
abstract class IdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt, TIdentifierType extends IdentifierType> extends StringProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
34
34
|
readonly #validator: IdentifierTypeValidator<TIdentifierType>;
|
|
35
35
|
|
|
36
|
-
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>, validator: IdentifierTypeValidator<TIdentifierType>) {
|
|
36
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>, validator: IdentifierTypeValidator<TIdentifierType>) {
|
|
37
37
|
super(appExtension);
|
|
38
38
|
|
|
39
39
|
this.#validator = validator;
|
|
@@ -47,41 +47,74 @@ abstract class IdentifierValidatorProxy<ThrowError extends boolean, TError exten
|
|
|
47
47
|
@proxy.describeClass(true, {
|
|
48
48
|
namespace: "GS1"
|
|
49
49
|
})
|
|
50
|
-
abstract class NumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt, TNumericIdentifierType extends NumericIdentifierType> extends IdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, TNumericIdentifierType> {
|
|
50
|
+
abstract class NumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt, TNumericIdentifierType extends NumericIdentifierType> extends IdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, TNumericIdentifierType> {
|
|
51
51
|
@proxy.describeMethod({
|
|
52
52
|
type: Types.String,
|
|
53
53
|
isMatrix: true,
|
|
54
54
|
parameterDescriptors: [validateIdentifierParameterDescriptor]
|
|
55
55
|
})
|
|
56
|
-
validate(matrixIdentifiers: Matrix<string>):
|
|
56
|
+
validate(matrixIdentifiers: Matrix<string>): Matrix<string> {
|
|
57
57
|
return this.validateString(this.validator, matrixIdentifiers);
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
@proxy.describeMethod({
|
|
61
|
+
type: Types.String,
|
|
62
|
+
isMatrix: true,
|
|
63
|
+
parameterDescriptors: [validateIdentifierParameterDescriptor]
|
|
64
|
+
})
|
|
65
|
+
isValid(matrixIdentifiers: Matrix<string>): Matrix<boolean> {
|
|
66
|
+
return this.isValidString(this.validate(matrixIdentifiers));
|
|
67
|
+
}
|
|
59
68
|
}
|
|
60
69
|
|
|
61
|
-
export abstract class GTINValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, GTINType> {
|
|
70
|
+
export abstract class GTINValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, GTINType> {
|
|
62
71
|
}
|
|
63
72
|
|
|
64
|
-
abstract class NonGTINNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt, TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType = NonGTINNumericIdentifierType> extends NumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, TNonGTINNumericIdentifierType> {
|
|
73
|
+
abstract class NonGTINNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt, TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType = NonGTINNumericIdentifierType> extends NumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, TNonGTINNumericIdentifierType> {
|
|
65
74
|
}
|
|
66
75
|
|
|
67
|
-
export abstract class NonSerializableNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonGTINNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonSerializableNumericIdentifierType> {
|
|
76
|
+
export abstract class NonSerializableNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonGTINNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, NonSerializableNumericIdentifierType> {
|
|
68
77
|
}
|
|
69
78
|
|
|
70
|
-
|
|
79
|
+
@proxy.describeClass(true, {
|
|
80
|
+
namespace: "GS1"
|
|
81
|
+
})
|
|
82
|
+
export abstract class SerializableNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonGTINNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, SerializableNumericIdentifierType> {
|
|
83
|
+
@proxy.describeMethod({
|
|
84
|
+
type: Types.String,
|
|
85
|
+
isMatrix: true,
|
|
86
|
+
parameterDescriptors: [splitIdentifierParameterDescriptor]
|
|
87
|
+
})
|
|
88
|
+
split(matrixIdentifiers: Matrix<string>): MatrixResult<string, ThrowError, TError> {
|
|
89
|
+
return this.arrayResult(matrixIdentifiers, (identifier) => {
|
|
90
|
+
const serializableNumericIdentifierSplit = this.validator.split(identifier);
|
|
91
|
+
|
|
92
|
+
return [serializableNumericIdentifierSplit.baseIdentifier, serializableNumericIdentifierSplit.serialComponent];
|
|
93
|
+
});
|
|
94
|
+
}
|
|
71
95
|
}
|
|
72
96
|
|
|
73
97
|
@proxy.describeClass(true, {
|
|
74
98
|
namespace: "GS1"
|
|
75
99
|
})
|
|
76
|
-
export abstract class NonNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends IdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonNumericIdentifierType> {
|
|
100
|
+
export abstract class NonNumericIdentifierValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends IdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, NonNumericIdentifierType> {
|
|
77
101
|
@proxy.describeMethod({
|
|
78
102
|
type: Types.String,
|
|
79
103
|
isMatrix: true,
|
|
80
104
|
parameterDescriptors: [validateIdentifierParameterDescriptor, exclusionAllNumericParameterDescriptor]
|
|
81
105
|
})
|
|
82
|
-
validate(matrixIdentifiers: Matrix<string>, exclusion: Nullishable<NonNumericIdentifierValidation["exclusion"]>):
|
|
106
|
+
validate(matrixIdentifiers: Matrix<string>, exclusion: Nullishable<NonNumericIdentifierValidation["exclusion"]>): Matrix<string> {
|
|
83
107
|
return this.validateString(this.validator, matrixIdentifiers, {
|
|
84
108
|
exclusion: exclusion ?? undefined
|
|
85
109
|
} satisfies NonNumericIdentifierValidation);
|
|
86
110
|
}
|
|
111
|
+
|
|
112
|
+
@proxy.describeMethod({
|
|
113
|
+
type: Types.String,
|
|
114
|
+
isMatrix: true,
|
|
115
|
+
parameterDescriptors: [validateIdentifierParameterDescriptor, exclusionAllNumericParameterDescriptor]
|
|
116
|
+
})
|
|
117
|
+
isValid(matrixIdentifiers: Matrix<string>, exclusion: Nullishable<NonNumericIdentifierValidation["exclusion"]>): Matrix<boolean> {
|
|
118
|
+
return this.isValidString(this.validate(matrixIdentifiers, exclusion));
|
|
119
|
+
}
|
|
87
120
|
}
|
package/src/gs1/index.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
export * from "./character-set-proxy.js";
|
|
2
|
+
|
|
2
3
|
export * from "./check-proxy.js";
|
|
4
|
+
|
|
3
5
|
export * from "./gtin-validator-proxy.js";
|
|
4
6
|
export * from "./non-gtin-validator-proxy.js";
|
|
7
|
+
|
|
5
8
|
export * from "./prefix-manager-proxy.js";
|
|
9
|
+
|
|
6
10
|
export * from "./gtin-creator-proxy.js";
|
|
7
11
|
export * from "./non-gtin-creator-proxy.js";
|
|
12
|
+
|
|
13
|
+
export * from "./variable-measure-proxy.js";
|
|
14
|
+
|
|
15
|
+
export * from "./service-proxy.js";
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
namespace: "GS1",
|
|
13
13
|
methodInfix: "GLN"
|
|
14
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>) {
|
|
15
|
+
export class GLNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
16
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
17
17
|
super(appExtension, prefixManager => prefixManager.glnCreator);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -22,8 +22,8 @@ export class GLNCreatorProxy<ThrowError extends boolean, TError extends ErrorExt
|
|
|
22
22
|
namespace: "GS1",
|
|
23
23
|
methodInfix: "SSCC"
|
|
24
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>) {
|
|
25
|
+
export class SSCCCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
26
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
27
27
|
super(appExtension, prefixManager => prefixManager.ssccCreator);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -32,8 +32,8 @@ export class SSCCCreatorProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
32
32
|
namespace: "GS1",
|
|
33
33
|
methodInfix: "GRAI"
|
|
34
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>) {
|
|
35
|
+
export class GRAICreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends SerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
36
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
37
37
|
super(appExtension, prefixManager => prefixManager.graiCreator);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -42,8 +42,8 @@ export class GRAICreatorProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
42
42
|
namespace: "GS1",
|
|
43
43
|
methodInfix: "GIAI"
|
|
44
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>) {
|
|
45
|
+
export class GIAICreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
46
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
47
47
|
super(appExtension, prefixManager => prefixManager.giaiCreator);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -52,8 +52,8 @@ export class GIAICreatorProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
52
52
|
namespace: "GS1",
|
|
53
53
|
methodInfix: "GSRN"
|
|
54
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>) {
|
|
55
|
+
export class GSRNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
56
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
57
57
|
super(appExtension, prefixManager => prefixManager.gsrnCreator);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -62,8 +62,8 @@ export class GSRNCreatorProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
62
62
|
namespace: "GS1",
|
|
63
63
|
methodInfix: "GDTI"
|
|
64
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>) {
|
|
65
|
+
export class GDTICreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends SerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
66
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
67
67
|
super(appExtension, prefixManager => prefixManager.gdtiCreator);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -72,8 +72,8 @@ export class GDTICreatorProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
72
72
|
namespace: "GS1",
|
|
73
73
|
methodInfix: "GINC"
|
|
74
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>) {
|
|
75
|
+
export class GINCCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
76
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
77
77
|
super(appExtension, prefixManager => prefixManager.gincCreator);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -82,8 +82,8 @@ export class GINCCreatorProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
82
82
|
namespace: "GS1",
|
|
83
83
|
methodInfix: "GSIN"
|
|
84
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>) {
|
|
85
|
+
export class GSINCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonSerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, NonSerializableNumericIdentifierType, NonGTINNumericIdentifierCreator> {
|
|
86
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
87
87
|
super(appExtension, prefixManager => prefixManager.gsinCreator);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -92,8 +92,8 @@ export class GSINCreatorProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
92
92
|
namespace: "GS1",
|
|
93
93
|
methodInfix: "GCN"
|
|
94
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>) {
|
|
95
|
+
export class GCNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends SerializableNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
96
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
97
97
|
super(appExtension, prefixManager => prefixManager.gcnCreator);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -102,8 +102,8 @@ export class GCNCreatorProxy<ThrowError extends boolean, TError extends ErrorExt
|
|
|
102
102
|
namespace: "GS1",
|
|
103
103
|
methodInfix: "CPID"
|
|
104
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>) {
|
|
105
|
+
export class CPIDCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
106
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
107
107
|
super(appExtension, prefixManager => prefixManager.cpidCreator);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -112,8 +112,8 @@ export class CPIDCreatorProxy<ThrowError extends boolean, TError extends ErrorEx
|
|
|
112
112
|
namespace: "GS1",
|
|
113
113
|
methodInfix: "GMN"
|
|
114
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>) {
|
|
115
|
+
export class GMNCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
116
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
117
117
|
super(appExtension, prefixManager => prefixManager.gmnCreator);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
namespace: "GS1",
|
|
13
13
|
methodInfix: "GLN"
|
|
14
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>) {
|
|
15
|
+
export class GLNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
16
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
17
17
|
super(appExtension, IdentifierValidators.GLN);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -22,8 +22,8 @@ export class GLNValidatorProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
22
22
|
namespace: "GS1",
|
|
23
23
|
methodInfix: "SSCC"
|
|
24
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>) {
|
|
25
|
+
export class SSCCValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
26
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
27
27
|
super(appExtension, IdentifierValidators.SSCC);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -32,8 +32,8 @@ export class SSCCValidatorProxy<ThrowError extends boolean, TError extends Error
|
|
|
32
32
|
namespace: "GS1",
|
|
33
33
|
methodInfix: "GRAI"
|
|
34
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>) {
|
|
35
|
+
export class GRAIValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends SerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
36
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
37
37
|
super(appExtension, IdentifierValidators.GRAI);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -42,8 +42,8 @@ export class GRAIValidatorProxy<ThrowError extends boolean, TError extends Error
|
|
|
42
42
|
namespace: "GS1",
|
|
43
43
|
methodInfix: "GIAI"
|
|
44
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>) {
|
|
45
|
+
export class GIAIValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
46
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
47
47
|
super(appExtension, IdentifierValidators.GIAI);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -52,8 +52,8 @@ export class GIAIValidatorProxy<ThrowError extends boolean, TError extends Error
|
|
|
52
52
|
namespace: "GS1",
|
|
53
53
|
methodInfix: "GSRN"
|
|
54
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>) {
|
|
55
|
+
export class GSRNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
56
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
57
57
|
super(appExtension, IdentifierValidators.GSRN);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -62,8 +62,8 @@ export class GSRNValidatorProxy<ThrowError extends boolean, TError extends Error
|
|
|
62
62
|
namespace: "GS1",
|
|
63
63
|
methodInfix: "GDTI"
|
|
64
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>) {
|
|
65
|
+
export class GDTIValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends SerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
66
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
67
67
|
super(appExtension, IdentifierValidators.GDTI);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -72,8 +72,8 @@ export class GDTIValidatorProxy<ThrowError extends boolean, TError extends Error
|
|
|
72
72
|
namespace: "GS1",
|
|
73
73
|
methodInfix: "GINC"
|
|
74
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>) {
|
|
75
|
+
export class GINCValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
76
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
77
77
|
super(appExtension, IdentifierValidators.GINC);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -82,8 +82,8 @@ export class GINCValidatorProxy<ThrowError extends boolean, TError extends Error
|
|
|
82
82
|
namespace: "GS1",
|
|
83
83
|
methodInfix: "GSIN"
|
|
84
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>) {
|
|
85
|
+
export class GSINValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonSerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
86
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
87
87
|
super(appExtension, IdentifierValidators.GSIN);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -92,8 +92,8 @@ export class GSINValidatorProxy<ThrowError extends boolean, TError extends Error
|
|
|
92
92
|
namespace: "GS1",
|
|
93
93
|
methodInfix: "GCN"
|
|
94
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>) {
|
|
95
|
+
export class GCNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends SerializableNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
96
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
97
97
|
super(appExtension, IdentifierValidators.GCN);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -102,8 +102,8 @@ export class GCNValidatorProxy<ThrowError extends boolean, TError extends ErrorE
|
|
|
102
102
|
namespace: "GS1",
|
|
103
103
|
methodInfix: "CPID"
|
|
104
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>) {
|
|
105
|
+
export class CPIDValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
106
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
107
107
|
super(appExtension, IdentifierValidators.CPID);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -112,8 +112,8 @@ export class CPIDValidatorProxy<ThrowError extends boolean, TError extends Error
|
|
|
112
112
|
namespace: "GS1",
|
|
113
113
|
methodInfix: "GMN"
|
|
114
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>) {
|
|
115
|
+
export class GMNValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonNumericIdentifierValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
116
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
117
117
|
super(appExtension, IdentifierValidators.GMN);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Nullishable } from "@aidc-toolkit/core";
|
|
2
|
-
import type
|
|
3
|
-
import
|
|
2
|
+
import { type GCPLengthData, PrefixManager, type PrefixType, RemoteGCPLengthCache } from "@aidc-toolkit/gs1";
|
|
3
|
+
import type { AppData } from "../app-data.js";
|
|
4
|
+
import { AppExtension } from "../app-extension.js";
|
|
5
|
+
import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
|
|
4
6
|
import { LibProxy } from "../lib-proxy.js";
|
|
5
7
|
import { proxy } from "../proxy.js";
|
|
6
|
-
import type { ErrorExtends, Matrix } from "../type.js";
|
|
8
|
+
import type { ErrorExtends, Matrix, MatrixResult, SingletonResult } from "../type.js";
|
|
9
|
+
import { identifierParameterDescriptor, identifierTypeParameterDescriptor } from "./identifier-descriptor.js";
|
|
10
|
+
import { validateIdentifierType } from "./identifier-type.js";
|
|
7
11
|
|
|
8
12
|
const prefixParameterDescriptor: ParameterDescriptor = {
|
|
9
13
|
name: "prefix",
|
|
@@ -26,10 +30,144 @@ const tweakFactorParameterDescriptor: ParameterDescriptor = {
|
|
|
26
30
|
isRequired: false
|
|
27
31
|
};
|
|
28
32
|
|
|
33
|
+
const gcpLengthIdentifierParameterDescriptor: ExtendsParameterDescriptor = {
|
|
34
|
+
extendsDescriptor: identifierParameterDescriptor,
|
|
35
|
+
name: "gcpLengthIdentifier"
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* GS1 Company Prefix length application data.
|
|
40
|
+
*/
|
|
41
|
+
interface GCPLengthAppData {
|
|
42
|
+
/**
|
|
43
|
+
* Next check date/time.
|
|
44
|
+
*/
|
|
45
|
+
nextCheckDateTime: Date | undefined;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* GS1 Company Prefix length data.
|
|
49
|
+
*/
|
|
50
|
+
gcpLengthData: GCPLengthData | undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Determine if data object is GS1 Company Prefix length application data.
|
|
55
|
+
*
|
|
56
|
+
* @param data
|
|
57
|
+
* Data object.
|
|
58
|
+
*
|
|
59
|
+
* @returns
|
|
60
|
+
* True if data object is GS1 Company Prefix length application data.
|
|
61
|
+
*/
|
|
62
|
+
function isGCPLengthAppData(data: AppData | undefined): data is GCPLengthAppData {
|
|
63
|
+
// Property type check is necessary to guard against data corruption or changes in format.
|
|
64
|
+
return typeof data === "object" && "nextCheckDateTime" in data && data.nextCheckDateTime instanceof Date;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Application extension GCP length cache. Data is stored in application extension shared data.
|
|
69
|
+
*/
|
|
70
|
+
class AppExtensionGCPLengthCache<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends RemoteGCPLengthCache {
|
|
71
|
+
/**
|
|
72
|
+
* GS1 Company Prefix length data property name.
|
|
73
|
+
*/
|
|
74
|
+
static readonly #GCP_LENGTH_DATA_NAME = `${AppExtension.APPLICATION_NAME_PREFIX}gcpLength`;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Application extension.
|
|
78
|
+
*/
|
|
79
|
+
readonly #appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>;
|
|
80
|
+
|
|
81
|
+
#gcpLengthAppData?: GCPLengthAppData | undefined;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Constructor.
|
|
85
|
+
*
|
|
86
|
+
* @param appExtension
|
|
87
|
+
* Application extension.
|
|
88
|
+
*/
|
|
89
|
+
constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
|
|
90
|
+
super();
|
|
91
|
+
|
|
92
|
+
this.#appExtension = appExtension;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async initialize(): Promise<void> {
|
|
96
|
+
const gcpLengthAppData = await this.#appExtension.getSharedData(AppExtensionGCPLengthCache.#GCP_LENGTH_DATA_NAME);
|
|
97
|
+
|
|
98
|
+
if (isGCPLengthAppData(gcpLengthAppData)) {
|
|
99
|
+
this.#gcpLengthAppData = gcpLengthAppData;
|
|
100
|
+
|
|
101
|
+
this.#appExtension.logger.trace("GS1 Company Prefix length data loaded from shared data");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
get nextCheckDateTime(): Date | undefined {
|
|
106
|
+
const nextCheckDateTime = this.#gcpLengthAppData?.nextCheckDateTime;
|
|
107
|
+
|
|
108
|
+
this.#appExtension.logger.debug(`GS1 Company Prefix length next check date/time ${nextCheckDateTime?.toISOString()}`);
|
|
109
|
+
|
|
110
|
+
return nextCheckDateTime;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get cacheDateTime(): Date | undefined {
|
|
114
|
+
const cacheDateTime = this.#gcpLengthAppData?.gcpLengthData?.dateTime;
|
|
115
|
+
|
|
116
|
+
this.#appExtension.logger.debug(`GS1 Company Prefix length cache date/time ${cacheDateTime?.toISOString()}`);
|
|
117
|
+
|
|
118
|
+
return cacheDateTime;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
get cacheData(): GCPLengthData {
|
|
122
|
+
this.#appExtension.logger.debug("GS1 Company Prefix length cache data retrieved");
|
|
123
|
+
|
|
124
|
+
const gcpLengthData = this.#gcpLengthAppData?.gcpLengthData;
|
|
125
|
+
|
|
126
|
+
if (gcpLengthData === undefined) {
|
|
127
|
+
// Application bug; localization not necessary.
|
|
128
|
+
throw new Error("Cache data not defined");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return gcpLengthData;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
override get sourceDateTime(): Promise<Date> {
|
|
135
|
+
return super.sourceDateTime.then((sourceDateTime) => {
|
|
136
|
+
this.#appExtension.logger.debug(`GS1 Company Prefix source date/time ${sourceDateTime.toISOString()}`);
|
|
137
|
+
|
|
138
|
+
return sourceDateTime;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
override get sourceData(): Promise<GCPLengthData> {
|
|
143
|
+
return super.sourceData.then((sourceData) => {
|
|
144
|
+
this.#appExtension.logger.debug("GS1 Company Prefix length source data retrieved");
|
|
145
|
+
|
|
146
|
+
return sourceData;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @inheritDoc
|
|
152
|
+
*/
|
|
153
|
+
async update(nextCheckDateTime: Date, _cacheDateTime?: Date, cacheData?: GCPLengthData): Promise<void> {
|
|
154
|
+
this.#gcpLengthAppData = {
|
|
155
|
+
nextCheckDateTime,
|
|
156
|
+
gcpLengthData: cacheData ?? this.#gcpLengthAppData?.gcpLengthData
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
await this.#appExtension.setSharedData(AppExtensionGCPLengthCache.#GCP_LENGTH_DATA_NAME, this.#gcpLengthAppData);
|
|
160
|
+
|
|
161
|
+
this.#appExtension.logger.trace(`GS1 Company Prefix length saved to shared data with next check date/time ${nextCheckDateTime.toISOString()}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
29
165
|
@proxy.describeClass(false, {
|
|
30
166
|
namespace: "GS1"
|
|
31
167
|
})
|
|
32
|
-
export class PrefixManagerProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TBigInt> {
|
|
168
|
+
export class PrefixManagerProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
|
|
169
|
+
#gcpLengthCache?: AppExtensionGCPLengthCache<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>;
|
|
170
|
+
|
|
33
171
|
@proxy.describeMethod({
|
|
34
172
|
type: Types.Any,
|
|
35
173
|
isMatrix: true,
|
|
@@ -39,4 +177,61 @@ export class PrefixManagerProxy<ThrowError extends boolean, TError extends Error
|
|
|
39
177
|
// Parameters will be validated by IdentifierCreatorProxy.getCreator().
|
|
40
178
|
return [[prefix, prefixType, tweakFactor]];
|
|
41
179
|
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Load GS1 Company Prefix length data.
|
|
183
|
+
*/
|
|
184
|
+
async #loadGCPLengthData(): Promise<void> {
|
|
185
|
+
const appExtension = this.appExtension;
|
|
186
|
+
|
|
187
|
+
if (this.#gcpLengthCache === undefined) {
|
|
188
|
+
this.#gcpLengthCache = new AppExtensionGCPLengthCache(this.appExtension);
|
|
189
|
+
|
|
190
|
+
await this.#gcpLengthCache.initialize();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const gcpLengthCache = this.#gcpLengthCache;
|
|
194
|
+
|
|
195
|
+
await PrefixManager.loadGCPLengthData(gcpLengthCache).catch((e: unknown) => {
|
|
196
|
+
// Swallow error and log it.
|
|
197
|
+
appExtension.logger.error("Load GS1 Company Prefix length data failed", e);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
@proxy.describeMethod({
|
|
202
|
+
type: Types.Number,
|
|
203
|
+
isMatrix: true,
|
|
204
|
+
parameterDescriptors: [identifierTypeParameterDescriptor, gcpLengthIdentifierParameterDescriptor]
|
|
205
|
+
})
|
|
206
|
+
async gcpLength(identifierType: string, matrixIdentifiers: Matrix<string>): Promise<MatrixResult<number, ThrowError, TError>> {
|
|
207
|
+
await this.#loadGCPLengthData();
|
|
208
|
+
|
|
209
|
+
return this.setUpMatrixResult(() =>
|
|
210
|
+
validateIdentifierType(identifierType),
|
|
211
|
+
matrixIdentifiers, (validatedIdentifierType, identifier) =>
|
|
212
|
+
PrefixManager.gcpLength(validatedIdentifierType, identifier)
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@proxy.describeMethod({
|
|
217
|
+
type: Types.String,
|
|
218
|
+
isMatrix: false,
|
|
219
|
+
parameterDescriptors: []
|
|
220
|
+
})
|
|
221
|
+
async gcpLengthDateTime(): Promise<SingletonResult<string, ThrowError, TError>> {
|
|
222
|
+
await this.#loadGCPLengthData();
|
|
223
|
+
|
|
224
|
+
return this.singletonResult(() => PrefixManager.gcpLengthDateTime().toISOString());
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@proxy.describeMethod({
|
|
228
|
+
type: Types.String,
|
|
229
|
+
isMatrix: false,
|
|
230
|
+
parameterDescriptors: []
|
|
231
|
+
})
|
|
232
|
+
async gcpLengthDisclaimer(): Promise<SingletonResult<string, ThrowError, TError>> {
|
|
233
|
+
await this.#loadGCPLengthData();
|
|
234
|
+
|
|
235
|
+
return this.singletonResult(() => PrefixManager.gcpLengthDisclaimer());
|
|
236
|
+
}
|
|
42
237
|
}
|