@aidc-toolkit/app-extension 1.0.31-beta → 1.0.33-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.
Files changed (45) hide show
  1. package/dist/index.cjs +1 -3709
  2. package/dist/index.d.cts +607 -333
  3. package/dist/index.d.ts +607 -333
  4. package/dist/index.js +1 -3683
  5. package/package.json +12 -13
  6. package/src/app-extension.ts +141 -93
  7. package/src/app-helper-proxy.ts +326 -0
  8. package/src/descriptor.ts +75 -7
  9. package/src/generator/generator.ts +118 -96
  10. package/src/generator/locale-resources-generator.ts +56 -42
  11. package/src/gs1/character-set-proxy.ts +8 -8
  12. package/src/gs1/check-proxy.ts +26 -25
  13. package/src/gs1/gtin-creator-proxy.ts +14 -28
  14. package/src/gs1/gtin-descriptor.ts +2 -23
  15. package/src/gs1/gtin-validator-proxy.ts +45 -48
  16. package/src/gs1/identifier-creator-proxy.ts +63 -53
  17. package/src/gs1/identifier-descriptor.ts +15 -0
  18. package/src/gs1/identifier-type.ts +37 -0
  19. package/src/gs1/identifier-validator-proxy.ts +59 -27
  20. package/src/gs1/index.ts +8 -0
  21. package/src/gs1/non-gtin-creator-proxy.ts +22 -33
  22. package/src/gs1/non-gtin-validator-proxy.ts +22 -33
  23. package/src/gs1/prefix-definition-descriptor.ts +2 -2
  24. package/src/gs1/prefix-manager-proxy.ts +164 -9
  25. package/src/gs1/service-proxy.ts +57 -0
  26. package/src/gs1/variable-measure-proxy.ts +62 -0
  27. package/src/index.ts +6 -1
  28. package/src/lib-proxy.ts +112 -70
  29. package/src/locale/en/locale-resources.ts +173 -47
  30. package/src/locale/fr/locale-resources.ts +173 -47
  31. package/src/locale/i18n.ts +8 -10
  32. package/src/locale/i18next.d.ts +2 -0
  33. package/src/proxy.ts +140 -140
  34. package/src/streaming.ts +13 -0
  35. package/src/type.ts +8 -7
  36. package/src/utility/character-set-descriptor.ts +2 -2
  37. package/src/utility/character-set-proxy.ts +39 -38
  38. package/src/utility/reg-exp-proxy.ts +12 -11
  39. package/src/utility/string-descriptor.ts +2 -2
  40. package/src/utility/string-proxy.ts +7 -7
  41. package/src/utility/transformer-descriptor.ts +5 -5
  42. package/src/utility/transformer-proxy.ts +25 -18
  43. package/dist/index.cjs.map +0 -1
  44. package/dist/index.js.map +0 -1
  45. package/src/app-utility-proxy.ts +0 -273
@@ -6,15 +6,15 @@ import {
6
6
  isValidPriceOrWeightCheckDigit,
7
7
  priceOrWeightCheckDigit
8
8
  } from "@aidc-toolkit/gs1";
9
- import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
9
+ import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
10
10
  import { LibProxy } from "../lib-proxy.js";
11
11
  import { proxy } from "../proxy.js";
12
- import type { ErrorExtends, Matrix, MatrixResultError, ResultError } from "../type.js";
12
+ import type { ErrorExtends, Matrix, MatrixResult, SingletonResult } from "../type.js";
13
13
 
14
14
  const checkSParameterDescriptor: ParameterDescriptor = {
15
15
  name: "checkS",
16
16
  type: Types.String,
17
- isMatrix: true,
17
+ multiplicity: Multiplicities.Matrix,
18
18
  isRequired: true
19
19
  };
20
20
 
@@ -39,7 +39,7 @@ const checkDigitParameterDescriptor: ExtendsParameterDescriptor = {
39
39
  extendsDescriptor: numericSParameterDescriptor,
40
40
  sortOrder: 2,
41
41
  name: "checkDigit",
42
- isMatrix: false
42
+ multiplicity: Multiplicities.Singleton
43
43
  };
44
44
 
45
45
  const ai82SParameterDescriptor: ExtendsParameterDescriptor = {
@@ -53,63 +53,64 @@ const ai82SWithCheckCharacterPairParameterDescriptor: ExtendsParameterDescriptor
53
53
  };
54
54
 
55
55
  @proxy.describeClass(false, {
56
- namespace: "GS1"
56
+ namespace: "GS1",
57
+ category: "checkCharacter"
57
58
  })
58
- export class CheckProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TBigInt> {
59
+ export class CheckProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
59
60
  @proxy.describeMethod({
60
61
  type: Types.String,
61
- isMatrix: true,
62
+ multiplicity: Multiplicities.Matrix,
62
63
  parameterDescriptors: [numericSParameterDescriptor]
63
64
  })
64
- checkDigit(matrixSs: Matrix<string>): MatrixResultError<string, ThrowError, TError> {
65
- return this.mapMatrix(matrixSs, s => checkDigit(s));
65
+ checkDigit(matrixSs: Matrix<string>): MatrixResult<string, ThrowError, TError> {
66
+ return this.matrixResult(matrixSs, s => checkDigit(s));
66
67
  }
67
68
 
68
69
  @proxy.describeMethod({
69
70
  type: Types.String,
70
- isMatrix: true,
71
+ multiplicity: Multiplicities.Matrix,
71
72
  parameterDescriptors: [numericSWithCheckDigitParameterDescriptor]
72
73
  })
73
- hasValidCheckDigit(matrixSs: Matrix<string>): MatrixResultError<boolean, ThrowError, TError> {
74
- return this.mapMatrix(matrixSs, s => hasValidCheckDigit(s));
74
+ hasValidCheckDigit(matrixSs: Matrix<string>): MatrixResult<boolean, ThrowError, TError> {
75
+ return this.matrixResult(matrixSs, s => hasValidCheckDigit(s));
75
76
  }
76
77
 
77
78
  @proxy.describeMethod({
78
79
  type: Types.String,
79
- isMatrix: true,
80
+ multiplicity: Multiplicities.Matrix,
80
81
  parameterDescriptors: [numericSFourOrFiveDigitsParameterDescriptor]
81
82
  })
82
- priceOrWeightCheckDigit(matrixSs: Matrix<string>): MatrixResultError<string, ThrowError, TError> {
83
- return this.mapMatrix(matrixSs, s => priceOrWeightCheckDigit(s));
83
+ priceOrWeightCheckDigit(matrixSs: Matrix<string>): MatrixResult<string, ThrowError, TError> {
84
+ return this.matrixResult(matrixSs, s => priceOrWeightCheckDigit(s));
84
85
  }
85
86
 
86
87
  @proxy.describeMethod({
87
88
  type: Types.String,
88
- isMatrix: false,
89
+ multiplicity: Multiplicities.Singleton,
89
90
  parameterDescriptors: [{
90
91
  ...numericSFourOrFiveDigitsParameterDescriptor,
91
- isMatrix: false
92
+ multiplicity: Multiplicities.Singleton
92
93
  }, checkDigitParameterDescriptor]
93
94
  })
94
- isValidPriceOrWeightCheckDigit(s: string, checkDigit: string): ResultError<boolean, ThrowError, TError> {
95
- return isValidPriceOrWeightCheckDigit(s, checkDigit);
95
+ isValidPriceOrWeightCheckDigit(s: string, checkDigit: string): SingletonResult<boolean, ThrowError, TError> {
96
+ return this.singletonResult(() => isValidPriceOrWeightCheckDigit(s, checkDigit));
96
97
  }
97
98
 
98
99
  @proxy.describeMethod({
99
100
  type: Types.String,
100
- isMatrix: true,
101
+ multiplicity: Multiplicities.Matrix,
101
102
  parameterDescriptors: [ai82SParameterDescriptor]
102
103
  })
103
- checkCharacterPair(matrixSs: Matrix<string>): MatrixResultError<string, ThrowError, TError> {
104
- return this.mapMatrix(matrixSs, s => checkCharacterPair(s));
104
+ checkCharacterPair(matrixSs: Matrix<string>): MatrixResult<string, ThrowError, TError> {
105
+ return this.matrixResult(matrixSs, s => checkCharacterPair(s));
105
106
  }
106
107
 
107
108
  @proxy.describeMethod({
108
109
  type: Types.String,
109
- isMatrix: true,
110
+ multiplicity: Multiplicities.Matrix,
110
111
  parameterDescriptors: [ai82SWithCheckCharacterPairParameterDescriptor]
111
112
  })
112
- hasValidCheckCharacterPair(matrixSs: Matrix<string>): MatrixResultError<boolean, ThrowError, TError> {
113
- return this.mapMatrix(matrixSs, s => hasValidCheckCharacterPair(s));
113
+ hasValidCheckCharacterPair(matrixSs: Matrix<string>): MatrixResult<boolean, ThrowError, TError> {
114
+ return this.matrixResult(matrixSs, s => hasValidCheckCharacterPair(s));
114
115
  }
115
116
  }
@@ -1,16 +1,11 @@
1
1
  import type { Nullishable } from "@aidc-toolkit/core";
2
- import { GTINCreator, type GTINType } from "@aidc-toolkit/gs1";
2
+ import type { GTINCreator, GTINType } from "@aidc-toolkit/gs1";
3
3
  import type { AppExtension } from "../app-extension.js";
4
- import { Types } from "../descriptor.js";
4
+ import { Multiplicities, Types } from "../descriptor.js";
5
5
  import { expandParameterDescriptor, proxy } from "../proxy.js";
6
- import type { ErrorExtends, Matrix, MatrixResultError } from "../type.js";
6
+ import type { ErrorExtends, Matrix, MatrixResult } from "../type.js";
7
7
  import { valueParameterDescriptor } from "../utility/transformer-descriptor.js";
8
- import {
9
- indicatorDigitParameterDescriptor,
10
- rcnFormatParameterDescriptor,
11
- rcnItemReferenceParameterDescriptor,
12
- rcnPriceOrWeightParameterDescriptor
13
- } from "./gtin-descriptor.js";
8
+ import { indicatorDigitParameterDescriptor } from "./gtin-descriptor.js";
14
9
  import { NumericIdentifierCreatorProxy, sparseParameterDescriptor } from "./identifier-creator-proxy.js";
15
10
  import {
16
11
  prefixDefinitionAnyParameterDescriptor,
@@ -18,41 +13,32 @@ import {
18
13
  } from "./prefix-definition-descriptor.js";
19
14
 
20
15
  @proxy.describeClass(false, {
21
- namespace: "GS1",
22
16
  methodInfix: "GTIN",
23
- replaceParameterDescriptors: [
17
+ replacementParameterDescriptors: [
24
18
  {
25
19
  name: expandParameterDescriptor(prefixDefinitionGS1UPCParameterDescriptor).name,
26
20
  replacement: prefixDefinitionAnyParameterDescriptor
27
21
  }
28
22
  ]
29
23
  })
30
- export class GTINCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, GTINType, GTINCreator> {
31
- constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
24
+ export class GTINCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, GTINType, GTINCreator> {
25
+ constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
32
26
  super(appExtension, prefixManager => prefixManager.gtinCreator);
33
27
  }
34
28
 
35
29
  @proxy.describeMethod({
36
30
  type: Types.String,
37
- isMatrix: true,
31
+ multiplicity: Multiplicities.Matrix,
38
32
  ignoreInfix: true,
39
33
  parameterDescriptors: [indicatorDigitParameterDescriptor, prefixDefinitionAnyParameterDescriptor, valueParameterDescriptor, sparseParameterDescriptor]
40
34
  })
41
- createGTIN14(indicatorDigit: string, prefixDefinition: Matrix<unknown>, matrixValues: Matrix<number | bigint>, sparse: Nullishable<boolean>): MatrixResultError<string, ThrowError, TError> {
42
- const creator = this.getCreator(prefixDefinition);
43
-
35
+ createGTIN14(indicatorDigit: string, prefixDefinition: Matrix<unknown>, matrixValues: Matrix<number | bigint>, sparse: Nullishable<boolean>): MatrixResult<string, ThrowError, TError> {
44
36
  const sparseOrUndefined = sparse ?? undefined;
45
37
 
46
- return this.mapMatrix(matrixValues, value => creator.createGTIN14(indicatorDigit, value, sparseOrUndefined));
47
- }
48
-
49
- @proxy.describeMethod({
50
- type: Types.String,
51
- isMatrix: true,
52
- ignoreInfix: true,
53
- parameterDescriptors: [rcnFormatParameterDescriptor, rcnItemReferenceParameterDescriptor, rcnPriceOrWeightParameterDescriptor]
54
- })
55
- createVariableMeasureRCN(format: string, itemReference: number, matrixPricesOrWeights: Matrix<number>): MatrixResultError<string, ThrowError, TError> {
56
- return this.mapMatrix(matrixPricesOrWeights, priceOrWeight => GTINCreator.createVariableMeasureRCN(format, itemReference, priceOrWeight));
38
+ return this.setUpMatrixResult(() =>
39
+ this.getCreator(prefixDefinition),
40
+ matrixValues, (creator, value) =>
41
+ creator.createGTIN14(indicatorDigit, value, sparseOrUndefined)
42
+ );
57
43
  }
58
44
  }
@@ -1,29 +1,8 @@
1
- import { type ParameterDescriptor, Types } from "../descriptor.js";
1
+ import { Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
2
2
 
3
3
  export const indicatorDigitParameterDescriptor: ParameterDescriptor = {
4
4
  name: "indicatorDigit",
5
5
  type: Types.String,
6
- isMatrix: false,
7
- isRequired: true
8
- };
9
-
10
- export const rcnFormatParameterDescriptor: ParameterDescriptor = {
11
- name: "rcnFormat",
12
- type: Types.String,
13
- isMatrix: false,
14
- isRequired: true
15
- };
16
-
17
- export const rcnItemReferenceParameterDescriptor: ParameterDescriptor = {
18
- name: "rcnItemReference",
19
- type: Types.Number,
20
- isMatrix: false,
21
- isRequired: true
22
- };
23
-
24
- export const rcnPriceOrWeightParameterDescriptor: ParameterDescriptor = {
25
- name: "rcnPriceOrWeight",
26
- type: Types.Number,
27
- isMatrix: true,
6
+ multiplicity: Multiplicities.Singleton,
28
7
  isRequired: true
29
8
  };
@@ -1,39 +1,37 @@
1
1
  import type { Nullishable } from "@aidc-toolkit/core";
2
2
  import { GTINLengths, type GTINLevel, GTINValidator, IdentifierValidators } from "@aidc-toolkit/gs1";
3
3
  import type { AppExtension } from "../app-extension.js";
4
- import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
4
+ import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
5
5
  import { LibProxy } from "../lib-proxy.js";
6
6
  import { proxy } from "../proxy.js";
7
- import type { ErrorExtends, Matrix, MatrixResultError } from "../type.js";
8
- import { indicatorDigitParameterDescriptor, rcnFormatParameterDescriptor } from "./gtin-descriptor.js";
9
- import { GTINValidatorProxy, identifierParameterDescriptor } from "./identifier-validator-proxy.js";
7
+ import type { ErrorExtends, Matrix, MatrixResult } from "../type.js";
8
+ import { indicatorDigitParameterDescriptor } from "./gtin-descriptor.js";
9
+ import { identifierParameterDescriptor } from "./identifier-descriptor.js";
10
+ import { GTINValidatorProxy } from "./identifier-validator-proxy.js";
10
11
 
11
12
  @proxy.describeClass(false, {
12
- namespace: "GS1",
13
13
  methodInfix: "GTIN13"
14
14
  })
15
- export class GTIN13ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
16
- constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
15
+ export class GTIN13ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
16
+ constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
17
17
  super(appExtension, IdentifierValidators.GTIN[GTINLengths.GTIN13]);
18
18
  }
19
19
  }
20
20
 
21
21
  @proxy.describeClass(false, {
22
- namespace: "GS1",
23
22
  methodInfix: "GTIN12"
24
23
  })
25
- export class GTIN12ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
26
- constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
24
+ export class GTIN12ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
25
+ constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
27
26
  super(appExtension, IdentifierValidators.GTIN[GTINLengths.GTIN12]);
28
27
  }
29
28
  }
30
29
 
31
30
  @proxy.describeClass(false, {
32
- namespace: "GS1",
33
31
  methodInfix: "GTIN8"
34
32
  })
35
- export class GTIN8ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TBigInt> {
36
- constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>) {
33
+ export class GTIN8ValidatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends GTINValidatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
34
+ constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>) {
37
35
  super(appExtension, IdentifierValidators.GTIN[GTINLengths.GTIN8]);
38
36
  }
39
37
  }
@@ -66,7 +64,7 @@ const validateGTINParameterDescriptor: ExtendsParameterDescriptor = {
66
64
  const gtinLevelParameterDescriptor: ParameterDescriptor = {
67
65
  name: "gtinLevel",
68
66
  type: Types.Number,
69
- isMatrix: false,
67
+ multiplicity: Multiplicities.Singleton,
70
68
  isRequired: false
71
69
  };
72
70
 
@@ -75,87 +73,86 @@ const validateGTIN14ParameterDescriptor: ExtendsParameterDescriptor = {
75
73
  name: "validateGTIN14"
76
74
  };
77
75
 
78
- const rcnParameterDescriptor: ParameterDescriptor = {
79
- name: "rcn",
80
- type: Types.String,
81
- isMatrix: true,
82
- isRequired: true
83
- };
84
-
85
76
  @proxy.describeClass(false, {
86
- namespace: "GS1"
77
+ namespace: "GS1",
78
+ category: "identifierValidation"
87
79
  })
88
- export class GTINValidatorStaticProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TBigInt> {
80
+ export class GTINValidatorStaticProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
89
81
  @proxy.describeMethod({
90
82
  type: Types.String,
91
- isMatrix: true,
83
+ multiplicity: Multiplicities.Matrix,
92
84
  parameterDescriptors: [zeroSuppressibleGTIN12ParameterDescriptor]
93
85
  })
94
- zeroSuppressGTIN12(matrixGTIN12s: Matrix<string>): MatrixResultError<string, ThrowError, TError> {
95
- return this.mapMatrix(matrixGTIN12s, gtin12 => GTINValidator.zeroSuppress(gtin12));
86
+ zeroSuppressGTIN12(matrixGTIN12s: Matrix<string>): MatrixResult<string, ThrowError, TError> {
87
+ return this.matrixResult(matrixGTIN12s, gtin12 => GTINValidator.zeroSuppress(gtin12));
96
88
  }
97
89
 
98
90
  @proxy.describeMethod({
99
91
  type: Types.String,
100
- isMatrix: true,
92
+ multiplicity: Multiplicities.Matrix,
101
93
  parameterDescriptors: [zeroSuppressedGTIN12ParameterDescriptor]
102
94
  })
103
- zeroExpandGTIN12(matrixZeroSuppressedGTIN12s: Matrix<string>): MatrixResultError<string, ThrowError, TError> {
104
- return this.mapMatrix(matrixZeroSuppressedGTIN12s, zeroSuppressedGTIN12 => GTINValidator.zeroExpand(zeroSuppressedGTIN12));
95
+ zeroExpandGTIN12(matrixZeroSuppressedGTIN12s: Matrix<string>): MatrixResult<string, ThrowError, TError> {
96
+ return this.matrixResult(matrixZeroSuppressedGTIN12s, zeroSuppressedGTIN12 => GTINValidator.zeroExpand(zeroSuppressedGTIN12));
105
97
  }
106
98
 
107
99
  @proxy.describeMethod({
108
100
  type: Types.String,
109
- isMatrix: true,
101
+ multiplicity: Multiplicities.Matrix,
110
102
  parameterDescriptors: [indicatorDigitParameterDescriptor, convertGTINParameterDescriptor]
111
103
  })
112
- convertToGTIN14(indicatorDigit: string, matrixGTINs: Matrix<string>): MatrixResultError<string, ThrowError, TError> {
113
- return this.mapMatrix(matrixGTINs, gtin => GTINValidator.convertToGTIN14(indicatorDigit, gtin));
104
+ convertToGTIN14(indicatorDigit: string, matrixGTINs: Matrix<string>): MatrixResult<string, ThrowError, TError> {
105
+ return this.matrixResult(matrixGTINs, gtin => GTINValidator.convertToGTIN14(indicatorDigit, gtin));
114
106
  }
115
107
 
116
108
  @proxy.describeMethod({
117
109
  type: Types.String,
118
- isMatrix: true,
110
+ multiplicity: Multiplicities.Matrix,
119
111
  parameterDescriptors: [normalizeGTINParameterDescriptor]
120
112
  })
121
- normalizeGTIN(matrixGTINs: Matrix<string>): MatrixResultError<string, ThrowError, TError> {
122
- return this.mapMatrix(matrixGTINs, gtin => GTINValidator.normalize(gtin));
113
+ normalizeGTIN(matrixGTINs: Matrix<string>): MatrixResult<string, ThrowError, TError> {
114
+ return this.matrixResult(matrixGTINs, gtin => GTINValidator.normalize(gtin));
123
115
  }
124
116
 
125
117
  @proxy.describeMethod({
126
118
  type: Types.String,
127
- isMatrix: true,
119
+ multiplicity: Multiplicities.Matrix,
128
120
  parameterDescriptors: [validateGTINParameterDescriptor, gtinLevelParameterDescriptor]
129
121
  })
130
122
  validateGTIN(matrixGTINs: Matrix<string>, gtinLevel: Nullishable<GTINLevel>): Matrix<string> {
131
123
  const gtinLevelOrUndefined = gtinLevel ?? undefined;
132
124
 
133
- return LibProxy.mapMatrixRangeError(matrixGTINs, (gtin) => {
125
+ return this.matrixErrorResult(matrixGTINs, (gtin) => {
134
126
  GTINValidator.validateAny(gtin, gtinLevelOrUndefined);
135
127
  });
136
128
  }
137
129
 
138
130
  @proxy.describeMethod({
139
131
  type: Types.String,
140
- isMatrix: true,
132
+ multiplicity: Multiplicities.Matrix,
133
+ parameterDescriptors: [validateGTINParameterDescriptor, gtinLevelParameterDescriptor]
134
+ })
135
+ isValidGTIN(matrixGTINs: Matrix<string>, gtinLevel: Nullishable<GTINLevel>): Matrix<boolean> {
136
+ return this.isValidString(this.validateGTIN(matrixGTINs, gtinLevel));
137
+ }
138
+
139
+ @proxy.describeMethod({
140
+ type: Types.String,
141
+ multiplicity: Multiplicities.Matrix,
141
142
  parameterDescriptors: [validateGTIN14ParameterDescriptor]
142
143
  })
143
144
  validateGTIN14(matrixGTIN14s: Matrix<string>): Matrix<string> {
144
- return LibProxy.mapMatrixRangeError(matrixGTIN14s, (gtin14) => {
145
+ return this.matrixErrorResult(matrixGTIN14s, (gtin14) => {
145
146
  GTINValidator.validateGTIN14(gtin14);
146
147
  });
147
148
  }
148
149
 
149
150
  @proxy.describeMethod({
150
- type: Types.Number,
151
- isMatrix: true,
152
- parameterDescriptors: [rcnFormatParameterDescriptor, rcnParameterDescriptor]
151
+ type: Types.String,
152
+ multiplicity: Multiplicities.Matrix,
153
+ parameterDescriptors: [validateGTIN14ParameterDescriptor]
153
154
  })
154
- parseVariableMeasureRCN(format: string, matrixRCNs: Matrix<string>): MatrixResultError<number, ThrowError, TError> {
155
- return this.mapArray(matrixRCNs, (rcn) => {
156
- const rcnReference = GTINValidator.parseVariableMeasureRCN(format, rcn);
157
-
158
- return [rcnReference.itemReference, rcnReference.priceOrWeight];
159
- });
155
+ isValidGTIN14(matrixGTIN14s: Matrix<string>): Matrix<boolean> {
156
+ return this.isValidString(this.validateGTIN14(matrixGTIN14s));
160
157
  }
161
158
  }
@@ -21,25 +21,29 @@ import {
21
21
  } from "@aidc-toolkit/gs1";
22
22
  import { Sequence } from "@aidc-toolkit/utility";
23
23
  import type { AppExtension } from "../app-extension.js";
24
- import { type ExtendsParameterDescriptor, type ParameterDescriptor, Types } from "../descriptor.js";
24
+ import { type ExtendsParameterDescriptor, Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
25
25
  import { LibProxy } from "../lib-proxy.js";
26
26
  import { i18nextAppExtension } from "../locale/i18n.js";
27
27
  import { proxy } from "../proxy.js";
28
- import type { ErrorExtends, Matrix, MatrixResultError } from "../type.js";
28
+ import type { ErrorExtends, Matrix, MatrixResult } from "../type.js";
29
29
  import {
30
30
  countParameterDescriptor,
31
31
  startValueParameterDescriptor,
32
32
  valueParameterDescriptor
33
33
  } from "../utility/transformer-descriptor.js";
34
- import { identifierParameterDescriptor } from "./identifier-validator-proxy.js";
34
+ import { identifierParameterDescriptor } from "./identifier-descriptor.js";
35
35
  import { prefixDefinitionGS1UPCParameterDescriptor } from "./prefix-definition-descriptor.js";
36
36
 
37
- 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> {
37
+ @proxy.describeClass(true, {
38
+ namespace: "GS1",
39
+ category: "identifierCreation"
40
+ })
41
+ abstract class IdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt, TIdentifierType extends IdentifierType, TIdentifierValidation extends IdentifierValidation, TIdentifierCreator extends IdentifierCreator<TIdentifierType, TIdentifierValidation>> extends LibProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt> {
38
42
  static readonly #PREFIX_TYPES: Array<PrefixType | undefined> = [PrefixTypes.GS1CompanyPrefix, PrefixTypes.UPCCompanyPrefix, PrefixTypes.GS18Prefix];
39
43
 
40
44
  readonly #getCreator: (prefixManager: PrefixManager) => TIdentifierCreator;
41
45
 
42
- constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TBigInt>, getCreator: (prefixManager: PrefixManager) => TIdentifierCreator) {
46
+ constructor(appExtension: AppExtension<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt>, getCreator: (prefixManager: PrefixManager) => TIdentifierCreator) {
43
47
  super(appExtension);
44
48
 
45
49
  this.#getCreator = getCreator;
@@ -103,125 +107,131 @@ abstract class IdentifierCreatorProxy<ThrowError extends boolean, TError extends
103
107
  export const sparseParameterDescriptor: ParameterDescriptor = {
104
108
  name: "sparse",
105
109
  type: Types.Boolean,
106
- isMatrix: false,
110
+ multiplicity: Multiplicities.Singleton,
107
111
  isRequired: false
108
112
  };
109
113
 
110
- @proxy.describeClass(true, {
111
- namespace: "GS1"
112
- })
113
- export 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> {
114
+ @proxy.describeClass(true)
115
+ export abstract class NumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt, TNumericIdentifierType extends NumericIdentifierType, TNumericIdentifierCreator extends NumericIdentifierCreator<TNumericIdentifierType>> extends IdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, TNumericIdentifierType, NumericIdentifierValidation, TNumericIdentifierCreator> {
114
116
  @proxy.describeMethod({
115
117
  type: Types.String,
116
- isMatrix: true,
118
+ multiplicity: Multiplicities.Matrix,
117
119
  parameterDescriptors: [prefixDefinitionGS1UPCParameterDescriptor, valueParameterDescriptor, sparseParameterDescriptor]
118
120
  })
119
- create(prefixDefinition: Matrix<unknown>, matrixValues: Matrix<number | bigint>, sparse: Nullishable<boolean>): MatrixResultError<string, ThrowError, TError> {
120
- const creator = this.getCreator(prefixDefinition);
121
-
121
+ create(prefixDefinition: Matrix<unknown>, matrixValues: Matrix<number | bigint>, sparse: Nullishable<boolean>): MatrixResult<string, ThrowError, TError> {
122
122
  const sparseOrUndefined = sparse ?? undefined;
123
123
 
124
- return this.mapMatrix(matrixValues, value => creator.create(value, sparseOrUndefined));
124
+ return this.setUpMatrixResult(() =>
125
+ this.getCreator(prefixDefinition),
126
+ matrixValues, (creator, value) =>
127
+ creator.create(value, sparseOrUndefined)
128
+ );
125
129
  }
126
130
 
127
131
  @proxy.describeMethod({
128
132
  infixBefore: "Sequence",
129
133
  type: Types.String,
130
- isMatrix: true,
134
+ multiplicity: Multiplicities.Array,
131
135
  parameterDescriptors: [prefixDefinitionGS1UPCParameterDescriptor, startValueParameterDescriptor, countParameterDescriptor, sparseParameterDescriptor]
132
136
  })
133
- createSequence(prefixDefinition: Matrix<unknown>, startValue: number, count: number, sparse: Nullishable<boolean>): Matrix<string> {
134
- this.appExtension.validateSequenceCount(count);
137
+ createSequence(prefixDefinition: Matrix<unknown>, startValue: number, count: number, sparse: Nullishable<boolean>): MatrixResult<string, ThrowError, TError> {
138
+ return this.iterableResult(() => {
139
+ this.appExtension.validateSequenceCount(count);
135
140
 
136
- return LibProxy.matrixResult(this.getCreator(prefixDefinition).create(new Sequence(startValue, count), sparse ?? undefined));
141
+ return this.getCreator(prefixDefinition).create(new Sequence(startValue, count), sparse ?? undefined);
142
+ });
137
143
  }
138
144
 
139
145
  @proxy.describeMethod({
140
146
  type: Types.String,
141
- isMatrix: true,
147
+ multiplicity: Multiplicities.Array,
142
148
  parameterDescriptors: [prefixDefinitionGS1UPCParameterDescriptor]
143
149
  })
144
- createAll(prefixDefinition: Matrix<unknown>): Matrix<string> {
145
- const creator = this.getCreator(prefixDefinition);
150
+ createAll(prefixDefinition: Matrix<unknown>): MatrixResult<string, ThrowError, TError> {
151
+ return this.iterableResult(() => {
152
+ const creator = this.getCreator(prefixDefinition);
146
153
 
147
- this.appExtension.validateSequenceCount(creator.capacity);
154
+ this.appExtension.validateSequenceCount(creator.capacity);
148
155
 
149
- return LibProxy.matrixResult(creator.createAll());
156
+ return creator.createAll();
157
+ });
150
158
  }
151
159
  }
152
160
 
153
- 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> {
161
+ abstract class NonGTINNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt, TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType, TNonGTINNumericIdentifierCreator extends NonGTINNumericIdentifierCreator> extends NumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, TNonGTINNumericIdentifierType, TNonGTINNumericIdentifierCreator> {
154
162
  }
155
163
 
156
- export 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> {
164
+ export abstract class NonSerializableNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt, TNonSerializableNumericIdentifierType extends NonSerializableNumericIdentifierType, TNonGTINNumericIdentifierCreator extends NonGTINNumericIdentifierCreator> extends NonGTINNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, TNonSerializableNumericIdentifierType, TNonGTINNumericIdentifierCreator> {
157
165
  }
158
166
 
159
167
  const singleValueParameterDescriptor: ExtendsParameterDescriptor = {
160
168
  extendsDescriptor: valueParameterDescriptor,
161
- isMatrix: false
169
+ multiplicity: Multiplicities.Singleton
162
170
  };
163
171
 
164
172
  const baseIdentifierParameterDescriptor: ExtendsParameterDescriptor = {
165
173
  extendsDescriptor: identifierParameterDescriptor,
166
174
  name: "baseIdentifier",
167
- isMatrix: false
175
+ multiplicity: Multiplicities.Singleton
168
176
  };
169
177
 
170
178
  const serialComponentParameterDescriptor: ParameterDescriptor = {
171
179
  name: "serialComponent",
172
180
  type: Types.String,
173
- isMatrix: true,
181
+ multiplicity: Multiplicities.Matrix,
174
182
  isRequired: true
175
183
  };
176
184
 
177
- @proxy.describeClass(true, {
178
- namespace: "GS1"
179
- })
180
- export abstract class SerializableNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends NonGTINNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, SerializableNumericIdentifierType, SerializableNumericIdentifierCreator> {
185
+ @proxy.describeClass(true)
186
+ export abstract class SerializableNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends NonGTINNumericIdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, SerializableNumericIdentifierType, SerializableNumericIdentifierCreator> {
181
187
  @proxy.describeMethod({
182
188
  type: Types.String,
183
- isMatrix: true,
189
+ multiplicity: Multiplicities.Matrix,
184
190
  parameterDescriptors: [prefixDefinitionGS1UPCParameterDescriptor, singleValueParameterDescriptor, serialComponentParameterDescriptor, sparseParameterDescriptor]
185
191
  })
186
- createSerialized(prefixDefinition: Matrix<unknown>, value: number, matrixSerialComponents: Matrix<string>, sparse: Nullishable<boolean>): MatrixResultError<string, ThrowError, TError> {
187
- const creator = this.getCreator(prefixDefinition);
188
-
192
+ createSerialized(prefixDefinition: Matrix<unknown>, value: number, matrixSerialComponents: Matrix<string>, sparse: Nullishable<boolean>): MatrixResult<string, ThrowError, TError> {
189
193
  const sparseOrUndefined = sparse ?? undefined;
190
194
 
191
- return this.mapMatrix(matrixSerialComponents, serialComponent => creator.createSerialized(value, serialComponent, sparseOrUndefined));
195
+ return this.setUpMatrixResult(() =>
196
+ this.getCreator(prefixDefinition),
197
+ matrixSerialComponents, (creator, serialComponent) =>
198
+ creator.createSerialized(value, serialComponent, sparseOrUndefined)
199
+ );
192
200
  }
193
201
 
194
202
  @proxy.describeMethod({
195
203
  type: Types.String,
196
- isMatrix: true,
204
+ multiplicity: Multiplicities.Matrix,
197
205
  parameterDescriptors: [baseIdentifierParameterDescriptor, serialComponentParameterDescriptor]
198
206
  })
199
- concatenate(baseIdentifier: string, matrixSerialComponents: Matrix<string>): MatrixResultError<string, ThrowError, TError> {
200
- const creator = this.getCreator([[baseIdentifier.substring(0, !baseIdentifier.startsWith("0") ? PrefixValidator.GS1_COMPANY_PREFIX_MINIMUM_LENGTH : PrefixValidator.UPC_COMPANY_PREFIX_MINIMUM_LENGTH + 1), PrefixTypes.GS1CompanyPrefix]]);
201
-
202
- return this.mapMatrix(matrixSerialComponents, serialComponent => creator.concatenate(baseIdentifier, serialComponent));
207
+ concatenate(baseIdentifier: string, matrixSerialComponents: Matrix<string>): MatrixResult<string, ThrowError, TError> {
208
+ return this.setUpMatrixResult(() =>
209
+ this.getCreator([[baseIdentifier.substring(0, !baseIdentifier.startsWith("0") ? PrefixValidator.GS1_COMPANY_PREFIX_MINIMUM_LENGTH : PrefixValidator.UPC_COMPANY_PREFIX_MINIMUM_LENGTH + 1), PrefixTypes.GS1CompanyPrefix]]),
210
+ matrixSerialComponents, (creator, serialComponent) =>
211
+ creator.concatenate(baseIdentifier, serialComponent)
212
+ );
203
213
  }
204
214
  }
205
215
 
206
216
  const referenceParameterDescriptor: ParameterDescriptor = {
207
217
  name: "reference",
208
218
  type: Types.String,
209
- isMatrix: true,
219
+ multiplicity: Multiplicities.Matrix,
210
220
  isRequired: true
211
221
  };
212
222
 
213
- @proxy.describeClass(true, {
214
- namespace: "GS1"
215
- })
216
- export abstract class NonNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TBigInt> extends IdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TBigInt, NonNumericIdentifierType, NonNumericIdentifierValidation, NonNumericIdentifierCreator> {
223
+ @proxy.describeClass(true)
224
+ export abstract class NonNumericIdentifierCreatorProxy<ThrowError extends boolean, TError extends ErrorExtends<ThrowError>, TInvocationContext, TStreamingInvocationContext, TBigInt> extends IdentifierCreatorProxy<ThrowError, TError, TInvocationContext, TStreamingInvocationContext, TBigInt, NonNumericIdentifierType, NonNumericIdentifierValidation, NonNumericIdentifierCreator> {
217
225
  @proxy.describeMethod({
218
226
  type: Types.String,
219
- isMatrix: true,
227
+ multiplicity: Multiplicities.Matrix,
220
228
  parameterDescriptors: [prefixDefinitionGS1UPCParameterDescriptor, referenceParameterDescriptor]
221
229
  })
222
- create(prefixDefinition: Matrix<unknown>, matrixReferences: Matrix<string>): MatrixResultError<string, ThrowError, TError> {
223
- const creator = this.getCreator(prefixDefinition);
224
-
225
- return this.mapMatrix(matrixReferences, reference => creator.create(reference));
230
+ create(prefixDefinition: Matrix<unknown>, matrixReferences: Matrix<string>): MatrixResult<string, ThrowError, TError> {
231
+ return this.setUpMatrixResult(() =>
232
+ this.getCreator(prefixDefinition),
233
+ matrixReferences, (creator, reference) =>
234
+ creator.create(reference)
235
+ );
226
236
  }
227
237
  }
@@ -0,0 +1,15 @@
1
+ import { Multiplicities, type ParameterDescriptor, Types } from "../descriptor.js";
2
+
3
+ export const identifierTypeParameterDescriptor: ParameterDescriptor = {
4
+ name: "identifierType",
5
+ type: Types.String,
6
+ multiplicity: Multiplicities.Singleton,
7
+ isRequired: true
8
+ };
9
+
10
+ export const identifierParameterDescriptor: ParameterDescriptor = {
11
+ name: "identifier",
12
+ type: Types.String,
13
+ multiplicity: Multiplicities.Matrix,
14
+ isRequired: true
15
+ };