@aidc-toolkit/gs1 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/abstract-identifier-creator.d.ts +32 -66
- package/dist/abstract-identifier-creator.d.ts.map +1 -1
- package/dist/abstract-identifier-creator.js +62 -45
- package/dist/abstract-identifier-creator.js.map +1 -1
- package/dist/abstract-non-gtin-numeric-identifier-creator.d.ts +36 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.js +37 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.js.map +1 -0
- package/dist/abstract-numeric-identifier-creator.d.ts +28 -86
- package/dist/abstract-numeric-identifier-creator.d.ts.map +1 -1
- package/dist/abstract-numeric-identifier-creator.js +138 -121
- package/dist/abstract-numeric-identifier-creator.js.map +1 -1
- package/dist/content-character-set-creators.d.ts +4 -0
- package/dist/content-character-set-creators.d.ts.map +1 -0
- package/dist/content-character-set-creators.js +9 -0
- package/dist/content-character-set-creators.js.map +1 -0
- package/dist/gtin-creator.d.ts +8 -13
- package/dist/gtin-creator.d.ts.map +1 -1
- package/dist/gtin-creator.js +12 -15
- package/dist/gtin-creator.js.map +1 -1
- package/dist/gtin-descriptor.d.ts +8 -3
- package/dist/gtin-descriptor.d.ts.map +1 -1
- package/dist/gtin-length.d.ts +64 -0
- package/dist/gtin-length.d.ts.map +1 -0
- package/dist/gtin-length.js +36 -0
- package/dist/gtin-length.js.map +1 -0
- package/dist/gtin-type.d.ts +15 -28
- package/dist/gtin-type.d.ts.map +1 -1
- package/dist/gtin-type.js +4 -28
- package/dist/gtin-type.js.map +1 -1
- package/dist/gtin-validator.d.ts +9 -23
- package/dist/gtin-validator.d.ts.map +1 -1
- package/dist/gtin-validator.js +32 -39
- package/dist/gtin-validator.js.map +1 -1
- package/dist/identifier-creator.d.ts +4 -4
- package/dist/identifier-creator.d.ts.map +1 -1
- package/dist/{creators.d.ts → identifier-creators.d.ts} +47 -10
- package/dist/identifier-creators.d.ts.map +1 -0
- package/dist/identifier-creators.js +92 -0
- package/dist/identifier-creators.js.map +1 -0
- package/dist/{descriptors.d.ts → identifier-descriptors.d.ts} +20 -10
- package/dist/identifier-descriptors.d.ts.map +1 -0
- package/dist/{descriptors.js → identifier-descriptors.js} +27 -31
- package/dist/identifier-descriptors.js.map +1 -0
- package/dist/identifier-extension.d.ts +82 -0
- package/dist/identifier-extension.d.ts.map +1 -0
- package/dist/identifier-extension.js +79 -0
- package/dist/identifier-extension.js.map +1 -0
- package/dist/identifier-validator.d.ts +44 -9
- package/dist/identifier-validator.d.ts.map +1 -1
- package/dist/identifier-validator.js +109 -1
- package/dist/identifier-validator.js.map +1 -1
- package/dist/{validators.d.ts → identifier-validators.d.ts} +47 -12
- package/dist/identifier-validators.d.ts.map +1 -0
- package/dist/{validators.js → identifier-validators.js} +40 -13
- package/dist/identifier-validators.js.map +1 -0
- package/dist/index.d.ts +15 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/leader-type.d.ts +26 -0
- package/dist/leader-type.d.ts.map +1 -0
- package/dist/leader-type.js +18 -0
- package/dist/leader-type.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-creator.d.ts +7 -19
- package/dist/non-gtin-numeric-identifier-creator.d.ts.map +1 -1
- package/dist/non-gtin-numeric-identifier-creator.js +1 -22
- package/dist/non-gtin-numeric-identifier-creator.js.map +1 -1
- package/dist/non-gtin-numeric-identifier-descriptor.d.ts +1 -1
- package/dist/non-gtin-numeric-identifier-descriptor.d.ts.map +1 -1
- package/dist/non-gtin-numeric-identifier-type.d.ts +22 -3
- package/dist/non-gtin-numeric-identifier-type.d.ts.map +1 -1
- package/dist/non-gtin-numeric-identifier-type.js +7 -1
- package/dist/non-gtin-numeric-identifier-type.js.map +1 -1
- package/dist/non-gtin-numeric-identifier-validator.d.ts +5 -10
- package/dist/non-gtin-numeric-identifier-validator.d.ts.map +1 -1
- package/dist/non-gtin-numeric-identifier-validator.js +5 -12
- package/dist/non-gtin-numeric-identifier-validator.js.map +1 -1
- package/dist/non-numeric-identifier-creator.d.ts +4 -9
- package/dist/non-numeric-identifier-creator.d.ts.map +1 -1
- package/dist/non-numeric-identifier-creator.js +8 -10
- package/dist/non-numeric-identifier-creator.js.map +1 -1
- package/dist/non-numeric-identifier-type.d.ts +22 -3
- package/dist/non-numeric-identifier-type.d.ts.map +1 -1
- package/dist/non-numeric-identifier-type.js +7 -1
- package/dist/non-numeric-identifier-type.js.map +1 -1
- package/dist/non-numeric-identifier-validator.d.ts +3 -11
- package/dist/non-numeric-identifier-validator.d.ts.map +1 -1
- package/dist/non-numeric-identifier-validator.js +8 -8
- package/dist/non-numeric-identifier-validator.js.map +1 -1
- package/dist/non-serializable-numeric-identifier-creator.d.ts +10 -0
- package/dist/non-serializable-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/non-serializable-numeric-identifier-creator.js +8 -0
- package/dist/non-serializable-numeric-identifier-creator.js.map +1 -0
- package/dist/non-serializable-numeric-identifier-descriptor.d.ts +12 -0
- package/dist/non-serializable-numeric-identifier-descriptor.d.ts.map +1 -0
- package/dist/non-serializable-numeric-identifier-descriptor.js +2 -0
- package/dist/non-serializable-numeric-identifier-descriptor.js.map +1 -0
- package/dist/non-serializable-numeric-identifier-type.d.ts +26 -0
- package/dist/non-serializable-numeric-identifier-type.d.ts.map +1 -0
- package/dist/non-serializable-numeric-identifier-type.js +7 -0
- package/dist/non-serializable-numeric-identifier-type.js.map +1 -0
- package/dist/non-serializable-numeric-identifier-validator.d.ts +16 -0
- package/dist/non-serializable-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/non-serializable-numeric-identifier-validator.js +17 -0
- package/dist/non-serializable-numeric-identifier-validator.js.map +1 -0
- package/dist/numeric-identifier-creator.d.ts +6 -6
- package/dist/numeric-identifier-creator.d.ts.map +1 -1
- package/dist/numeric-identifier-descriptor.d.ts +2 -1
- package/dist/numeric-identifier-descriptor.d.ts.map +1 -1
- package/dist/numeric-identifier-type.d.ts +19 -24
- package/dist/numeric-identifier-type.d.ts.map +1 -1
- package/dist/numeric-identifier-type.js +4 -15
- package/dist/numeric-identifier-type.js.map +1 -1
- package/dist/numeric-identifier-validator.d.ts +20 -6
- package/dist/numeric-identifier-validator.d.ts.map +1 -1
- package/dist/numeric-identifier-validator.js +60 -1
- package/dist/numeric-identifier-validator.js.map +1 -1
- package/dist/prefix-manager.d.ts +13 -94
- package/dist/prefix-manager.d.ts.map +1 -1
- package/dist/prefix-manager.js +65 -102
- package/dist/prefix-manager.js.map +1 -1
- package/dist/serializable-numeric-identifier-creator.d.ts +3 -31
- package/dist/serializable-numeric-identifier-creator.d.ts.map +1 -1
- package/dist/serializable-numeric-identifier-creator.js +7 -21
- package/dist/serializable-numeric-identifier-creator.js.map +1 -1
- package/dist/serializable-numeric-identifier-descriptor.d.ts +1 -1
- package/dist/serializable-numeric-identifier-descriptor.d.ts.map +1 -1
- package/dist/serializable-numeric-identifier-type.d.ts +22 -2
- package/dist/serializable-numeric-identifier-type.d.ts.map +1 -1
- package/dist/serializable-numeric-identifier-type.js +7 -1
- package/dist/serializable-numeric-identifier-type.js.map +1 -1
- package/dist/serializable-numeric-identifier-validator.d.ts +3 -18
- package/dist/serializable-numeric-identifier-validator.d.ts.map +1 -1
- package/dist/serializable-numeric-identifier-validator.js +17 -16
- package/dist/serializable-numeric-identifier-validator.js.map +1 -1
- package/package.json +4 -5
- package/src/abstract-identifier-creator.ts +104 -75
- package/src/abstract-non-gtin-numeric-identifier-creator.ts +81 -0
- package/src/abstract-numeric-identifier-creator.ts +185 -133
- package/src/content-character-set-creators.ts +9 -0
- package/src/gtin-creator.ts +15 -16
- package/src/gtin-descriptor.ts +9 -3
- package/src/gtin-length.ts +61 -0
- package/src/gtin-type.ts +6 -37
- package/src/gtin-validator.ts +34 -41
- package/src/identifier-creator.ts +4 -4
- package/src/identifier-creators.ts +177 -0
- package/src/{descriptors.ts → identifier-descriptors.ts} +56 -54
- package/src/identifier-extension.ts +155 -0
- package/src/identifier-validator.ts +93 -10
- package/src/{validators.ts → identifier-validators.ts} +98 -36
- package/src/index.ts +15 -9
- package/src/leader-type.ts +29 -0
- package/src/non-gtin-numeric-identifier-creator.ts +7 -22
- package/src/non-gtin-numeric-identifier-descriptor.ts +1 -1
- package/src/non-gtin-numeric-identifier-type.ts +14 -3
- package/src/non-gtin-numeric-identifier-validator.ts +5 -13
- package/src/non-numeric-identifier-creator.ts +15 -12
- package/src/non-numeric-identifier-type.ts +14 -3
- package/src/non-numeric-identifier-validator.ts +8 -9
- package/src/non-serializable-numeric-identifier-creator.ts +11 -0
- package/src/non-serializable-numeric-identifier-descriptor.ts +12 -0
- package/src/non-serializable-numeric-identifier-type.ts +22 -0
- package/src/non-serializable-numeric-identifier-validator.ts +19 -0
- package/src/numeric-identifier-creator.ts +7 -6
- package/src/numeric-identifier-descriptor.ts +2 -1
- package/src/numeric-identifier-type.ts +17 -35
- package/src/numeric-identifier-validator.ts +61 -6
- package/src/prefix-manager.ts +76 -112
- package/src/serializable-numeric-identifier-creator.ts +10 -25
- package/src/serializable-numeric-identifier-descriptor.ts +1 -1
- package/src/serializable-numeric-identifier-type.ts +14 -5
- package/src/serializable-numeric-identifier-validator.ts +17 -16
- package/test/gtin-creator.ts +9 -2
- package/test/gtin-validator.test.ts +8 -10
- package/test/identifier-creator.ts +7 -7
- package/test/mixin.test.ts +35 -0
- package/test/non-gtin-numeric-identifier-validator.ts +7 -2
- package/test/non-numeric-identifier-validator.ts +2 -2
- package/test/non-serializable-numeric-identifier-creator.ts +64 -0
- package/test/non-serializable-numeric-identifier-validator.ts +6 -0
- package/test/numeric-identifier-creator.ts +7 -2
- package/test/serializable-numeric-identifier-validator.ts +2 -2
- package/test/utility.ts +6 -6
- package/test/validator.test.ts +11 -10
- package/test/variable-measure-rcn.test.ts +23 -23
- package/dist/abstract-identifier-validator.d.ts +0 -95
- package/dist/abstract-identifier-validator.d.ts.map +0 -1
- package/dist/abstract-identifier-validator.js +0 -123
- package/dist/abstract-identifier-validator.js.map +0 -1
- package/dist/abstract-numeric-identifier-validator.d.ts +0 -35
- package/dist/abstract-numeric-identifier-validator.d.ts.map +0 -1
- package/dist/abstract-numeric-identifier-validator.js +0 -61
- package/dist/abstract-numeric-identifier-validator.js.map +0 -1
- package/dist/creators.d.ts.map +0 -1
- package/dist/creators.js +0 -62
- package/dist/creators.js.map +0 -1
- package/dist/descriptors.d.ts.map +0 -1
- package/dist/descriptors.js.map +0 -1
- package/dist/validators.d.ts.map +0 -1
- package/dist/validators.js.map +0 -1
- package/src/abstract-identifier-validator.ts +0 -140
- package/src/abstract-numeric-identifier-validator.ts +0 -69
- package/src/creators.ts +0 -113
package/src/prefix-manager.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { GTINCreator } from "./gtin-creator.js";
|
|
2
|
+
import { GTIN_BASE_TYPES } from "./gtin-length.js";
|
|
3
|
+
import type { GTINType } from "./gtin-type.js";
|
|
4
4
|
import type { IdentifierCreator } from "./identifier-creator.js";
|
|
5
|
+
import {
|
|
6
|
+
IdentifierCreatorConstructors,
|
|
7
|
+
type IdentifierCreatorsRecord,
|
|
8
|
+
isNumericIdentifierCreator,
|
|
9
|
+
type NonGTINCreatorConstructor
|
|
10
|
+
} from "./identifier-creators.js";
|
|
5
11
|
import { type IdentifierType, IdentifierTypes } from "./identifier-type.js";
|
|
6
12
|
import { i18nextGS1 } from "./locale/i18n.js";
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
9
|
-
import { NonNumericIdentifierCreator } from "./non-numeric-identifier-creator.js";
|
|
10
|
-
import type { NonNumericIdentifierType } from "./non-numeric-identifier-type.js";
|
|
13
|
+
import type { NonNumericIdentifierCreator } from "./non-numeric-identifier-creator.js";
|
|
14
|
+
import type { NonSerializableNumericIdentifierCreator } from "./non-serializable-numeric-identifier-creator.js";
|
|
11
15
|
import type { NumericIdentifierType } from "./numeric-identifier-type.js";
|
|
12
16
|
import type { PrefixProvider } from "./prefix-provider.js";
|
|
13
17
|
import { type PrefixType, PrefixTypes } from "./prefix-type.js";
|
|
14
18
|
import { PrefixValidator } from "./prefix-validator.js";
|
|
15
|
-
import { SerializableNumericIdentifierCreator } from "./serializable-numeric-identifier-creator.js";
|
|
16
|
-
import type { SerializableNumericIdentifierType } from "./serializable-numeric-identifier-type.js";
|
|
19
|
+
import type { SerializableNumericIdentifierCreator } from "./serializable-numeric-identifier-creator.js";
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
22
|
* Prefix manager. This is the core class for identifier creation.
|
|
@@ -39,13 +42,13 @@ export class PrefixManager implements PrefixProvider {
|
|
|
39
42
|
/**
|
|
40
43
|
* Cached prefix managers, keyed by GS1 Company Prefix.
|
|
41
44
|
*/
|
|
42
|
-
|
|
45
|
+
static readonly #PREFIX_MANAGERS_MAP = new Map<string, PrefixManager>();
|
|
43
46
|
|
|
44
47
|
/**
|
|
45
48
|
* Creator tweak factors. Different numeric identifier types have different tweak factors so that sparse creation
|
|
46
49
|
* generates different sequences for each.
|
|
47
50
|
*/
|
|
48
|
-
|
|
51
|
+
static readonly #CREATOR_TWEAK_FACTORS: Readonly<Record<NumericIdentifierType, bigint>> = {
|
|
49
52
|
GTIN: 1987n,
|
|
50
53
|
GLN: 4241n,
|
|
51
54
|
SSCC: 8087n,
|
|
@@ -59,42 +62,42 @@ export class PrefixManager implements PrefixProvider {
|
|
|
59
62
|
/**
|
|
60
63
|
* Normalized prefix type.
|
|
61
64
|
*/
|
|
62
|
-
|
|
65
|
+
readonly #prefixType: PrefixType;
|
|
63
66
|
|
|
64
67
|
/**
|
|
65
68
|
* Normalized prefix.
|
|
66
69
|
*/
|
|
67
|
-
|
|
70
|
+
readonly #prefix: string;
|
|
68
71
|
|
|
69
72
|
/**
|
|
70
73
|
* Prefix as GS1 Company Prefix.
|
|
71
74
|
*/
|
|
72
|
-
|
|
75
|
+
readonly #gs1CompanyPrefix: string;
|
|
73
76
|
|
|
74
77
|
/**
|
|
75
78
|
* U.P.C. Company Prefix if prefix type is {@linkcode PrefixTypes.UPCCompanyPrefix}.
|
|
76
79
|
*/
|
|
77
|
-
|
|
80
|
+
readonly #upcCompanyPrefix: string | undefined;
|
|
78
81
|
|
|
79
82
|
/**
|
|
80
83
|
* GS1-8 Prefix if prefix type is {@linkcode PrefixTypes.GS18Prefix}.
|
|
81
84
|
*/
|
|
82
|
-
|
|
85
|
+
readonly #gs18Prefix: string | undefined;
|
|
83
86
|
|
|
84
87
|
/**
|
|
85
88
|
* Default tweak factor.
|
|
86
89
|
*/
|
|
87
|
-
|
|
90
|
+
readonly #defaultTweakFactor: bigint;
|
|
88
91
|
|
|
89
92
|
/**
|
|
90
93
|
* Tweak factor.
|
|
91
94
|
*/
|
|
92
|
-
|
|
95
|
+
#tweakFactor = 0n;
|
|
93
96
|
|
|
94
97
|
/**
|
|
95
98
|
* Cached identifier creators.
|
|
96
99
|
*/
|
|
97
|
-
|
|
100
|
+
readonly #identifierCreators: Partial<IdentifierCreatorsRecord> = {};
|
|
98
101
|
|
|
99
102
|
/**
|
|
100
103
|
* Constructor.
|
|
@@ -108,14 +111,14 @@ export class PrefixManager implements PrefixProvider {
|
|
|
108
111
|
constructor(prefixType: PrefixType, prefix: string) {
|
|
109
112
|
const normalizedPrefixProvider = PrefixValidator.normalize(prefixType, prefix);
|
|
110
113
|
|
|
111
|
-
this
|
|
112
|
-
this
|
|
113
|
-
this
|
|
114
|
-
this
|
|
115
|
-
this
|
|
114
|
+
this.#prefixType = normalizedPrefixProvider.prefixType;
|
|
115
|
+
this.#prefix = normalizedPrefixProvider.prefix;
|
|
116
|
+
this.#gs1CompanyPrefix = normalizedPrefixProvider.gs1CompanyPrefix;
|
|
117
|
+
this.#upcCompanyPrefix = normalizedPrefixProvider.upcCompanyPrefix;
|
|
118
|
+
this.#gs18Prefix = normalizedPrefixProvider.gs18Prefix;
|
|
116
119
|
|
|
117
120
|
// Default tweak factor is the numeric value of the GS1 Company Prefix preceded by '1'.
|
|
118
|
-
this
|
|
121
|
+
this.#defaultTweakFactor = BigInt(`1${this.gs1CompanyPrefix}`);
|
|
119
122
|
|
|
120
123
|
this.resetTweakFactor();
|
|
121
124
|
}
|
|
@@ -124,35 +127,35 @@ export class PrefixManager implements PrefixProvider {
|
|
|
124
127
|
* Get the prefix type.
|
|
125
128
|
*/
|
|
126
129
|
get prefixType(): PrefixType {
|
|
127
|
-
return this
|
|
130
|
+
return this.#prefixType;
|
|
128
131
|
}
|
|
129
132
|
|
|
130
133
|
/**
|
|
131
134
|
* Get the prefix.
|
|
132
135
|
*/
|
|
133
136
|
get prefix(): string {
|
|
134
|
-
return this
|
|
137
|
+
return this.#prefix;
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
/**
|
|
138
141
|
* Get the GS1 Company Prefix.
|
|
139
142
|
*/
|
|
140
143
|
get gs1CompanyPrefix(): string {
|
|
141
|
-
return this
|
|
144
|
+
return this.#gs1CompanyPrefix;
|
|
142
145
|
}
|
|
143
146
|
|
|
144
147
|
/**
|
|
145
148
|
* Get the U.P.C. Company Prefix if prefix type is {@linkcode PrefixTypes.UPCCompanyPrefix} or undefined if not.
|
|
146
149
|
*/
|
|
147
150
|
get upcCompanyPrefix(): string | undefined {
|
|
148
|
-
return this
|
|
151
|
+
return this.#upcCompanyPrefix;
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
/**
|
|
152
155
|
* Get the GS1-8 Prefix if prefix type is {@linkcode PrefixTypes.GS18Prefix} or undefined if not.
|
|
153
156
|
*/
|
|
154
157
|
get gs18Prefix(): string | undefined {
|
|
155
|
-
return this
|
|
158
|
+
return this.#gs18Prefix;
|
|
156
159
|
}
|
|
157
160
|
|
|
158
161
|
/**
|
|
@@ -161,10 +164,10 @@ export class PrefixManager implements PrefixProvider {
|
|
|
161
164
|
* @param identifierCreator
|
|
162
165
|
* Identifier creator.
|
|
163
166
|
*/
|
|
164
|
-
|
|
167
|
+
#setCreatorTweak(identifierCreator: IdentifierCreator): void {
|
|
165
168
|
if (isNumericIdentifierCreator(identifierCreator)) {
|
|
166
169
|
// eslint-disable-next-line no-param-reassign -- Method purpose is to set the tweak.
|
|
167
|
-
identifierCreator.tweak = this.tweakFactor * PrefixManager
|
|
170
|
+
identifierCreator.tweak = this.tweakFactor * PrefixManager.#CREATOR_TWEAK_FACTORS[identifierCreator.identifierType];
|
|
168
171
|
}
|
|
169
172
|
}
|
|
170
173
|
|
|
@@ -172,7 +175,7 @@ export class PrefixManager implements PrefixProvider {
|
|
|
172
175
|
* Get the tweak factor.
|
|
173
176
|
*/
|
|
174
177
|
get tweakFactor(): bigint {
|
|
175
|
-
return this
|
|
178
|
+
return this.#tweakFactor;
|
|
176
179
|
}
|
|
177
180
|
|
|
178
181
|
/**
|
|
@@ -184,11 +187,11 @@ export class PrefixManager implements PrefixProvider {
|
|
|
184
187
|
set tweakFactor(value: number | bigint) {
|
|
185
188
|
const tweakFactor = BigInt(value);
|
|
186
189
|
|
|
187
|
-
if (this
|
|
188
|
-
this
|
|
190
|
+
if (this.#tweakFactor !== tweakFactor) {
|
|
191
|
+
this.#tweakFactor = tweakFactor;
|
|
189
192
|
|
|
190
|
-
for (const creator of Object.values(this
|
|
191
|
-
this
|
|
193
|
+
for (const creator of Object.values(this.#identifierCreators)) {
|
|
194
|
+
this.#setCreatorTweak(creator);
|
|
192
195
|
}
|
|
193
196
|
}
|
|
194
197
|
}
|
|
@@ -197,7 +200,7 @@ export class PrefixManager implements PrefixProvider {
|
|
|
197
200
|
* Reset the tweak factor to its default (numeric value of the GS1 Company Prefix preceded by '1').
|
|
198
201
|
*/
|
|
199
202
|
resetTweakFactor(): void {
|
|
200
|
-
this.tweakFactor = this
|
|
203
|
+
this.tweakFactor = this.#defaultTweakFactor;
|
|
201
204
|
}
|
|
202
205
|
|
|
203
206
|
/**
|
|
@@ -216,11 +219,11 @@ export class PrefixManager implements PrefixProvider {
|
|
|
216
219
|
// Normalization will occur in constructor as well, but it's necessary here for the map.
|
|
217
220
|
const normalizedPrefixProvider = PrefixValidator.normalize(prefixType, prefix);
|
|
218
221
|
|
|
219
|
-
let prefixManager = PrefixManager
|
|
222
|
+
let prefixManager = PrefixManager.#PREFIX_MANAGERS_MAP.get(normalizedPrefixProvider.gs1CompanyPrefix);
|
|
220
223
|
|
|
221
224
|
if (prefixManager === undefined) {
|
|
222
225
|
prefixManager = new PrefixManager(normalizedPrefixProvider.prefixType, normalizedPrefixProvider.prefix);
|
|
223
|
-
PrefixManager
|
|
226
|
+
PrefixManager.#PREFIX_MANAGERS_MAP.set(normalizedPrefixProvider.gs1CompanyPrefix, prefixManager);
|
|
224
227
|
}
|
|
225
228
|
|
|
226
229
|
return prefixManager;
|
|
@@ -233,157 +236,118 @@ export class PrefixManager implements PrefixProvider {
|
|
|
233
236
|
* Identifier type type.
|
|
234
237
|
*
|
|
235
238
|
* @param identifierType
|
|
236
|
-
* Identifier type
|
|
237
|
-
*
|
|
238
|
-
* @param constructorParameter
|
|
239
|
-
* Second constructor parameter passed to constructor callback alongside this.
|
|
240
|
-
*
|
|
241
|
-
* @param ConstructorCallback
|
|
242
|
-
* Constructor callback.
|
|
239
|
+
* Identifier type for which to retrieve or construct identifier creator.
|
|
243
240
|
*
|
|
244
241
|
* @returns
|
|
245
242
|
* Identifier creator.
|
|
246
243
|
*/
|
|
247
|
-
|
|
248
|
-
let creator: IdentifierCreatorsRecord[TIdentifierType] | undefined = this
|
|
244
|
+
getIdentifierCreator<TIdentifierType extends IdentifierType>(identifierType: TIdentifierType): IdentifierCreatorsRecord[TIdentifierType] {
|
|
245
|
+
let creator: IdentifierCreatorsRecord[TIdentifierType] | undefined = this.#identifierCreators[identifierType];
|
|
249
246
|
|
|
250
247
|
if (creator === undefined) {
|
|
251
|
-
if (
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
248
|
+
if (identifierType === IdentifierTypes.GTIN) {
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Types are known to match.
|
|
250
|
+
creator = new IdentifierCreatorConstructors.GTIN(this, GTIN_BASE_TYPES[this.prefixType]) as IdentifierCreatorsRecord[TIdentifierType];
|
|
251
|
+
} else {
|
|
252
|
+
if (this.prefixType === PrefixTypes.GS18Prefix) {
|
|
253
|
+
throw new RangeError(i18nextGS1.t("Prefix.identifierTypeNotSupportedByGS18Prefix", {
|
|
254
|
+
identifierType
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Types are known to match.
|
|
259
|
+
creator = new (IdentifierCreatorConstructors[identifierType] as unknown as NonGTINCreatorConstructor<Exclude<TIdentifierType, GTINType>>)(this, identifierType as Exclude<TIdentifierType, GTINType>);
|
|
255
260
|
}
|
|
256
261
|
|
|
257
|
-
creator
|
|
262
|
+
this.#setCreatorTweak(creator);
|
|
258
263
|
|
|
259
|
-
this
|
|
260
|
-
|
|
261
|
-
this._identifierCreators[identifierType] = creator;
|
|
264
|
+
this.#identifierCreators[identifierType] = creator;
|
|
262
265
|
}
|
|
263
266
|
|
|
264
267
|
return creator;
|
|
265
268
|
}
|
|
266
269
|
|
|
267
|
-
/**
|
|
268
|
-
* Get non-GTIN numeric identifier creator.
|
|
269
|
-
*
|
|
270
|
-
* @param identifierType
|
|
271
|
-
* Identifier type used to construct identifier creator.
|
|
272
|
-
*
|
|
273
|
-
* @returns
|
|
274
|
-
* Identifier creator.
|
|
275
|
-
*/
|
|
276
|
-
private getNonGTINNumericIdentifierCreator(identifierType: Exclude<NonGTINNumericIdentifierType, SerializableNumericIdentifierType>): NonGTINNumericIdentifierCreator {
|
|
277
|
-
return this.getIdentifierCreator(identifierType, identifierType, NonGTINNumericIdentifierCreator);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Get serialized numeric identifier creator.
|
|
282
|
-
*
|
|
283
|
-
* @param identifierType
|
|
284
|
-
* Identifier type used to construct identifier creator.
|
|
285
|
-
*
|
|
286
|
-
* @returns
|
|
287
|
-
* Identifier creator.
|
|
288
|
-
*/
|
|
289
|
-
private getSerializableNumericIdentifierCreator(identifierType: SerializableNumericIdentifierType): SerializableNumericIdentifierCreator {
|
|
290
|
-
return this.getIdentifierCreator(identifierType, identifierType, SerializableNumericIdentifierCreator);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Get non-numeric identifier creator.
|
|
295
|
-
*
|
|
296
|
-
* @param identifierType
|
|
297
|
-
* Identifier type used to construct identifier creator.
|
|
298
|
-
*
|
|
299
|
-
* @returns
|
|
300
|
-
* Identifier creator.
|
|
301
|
-
*/
|
|
302
|
-
private getNonNumericIdentifierCreator(identifierType: NonNumericIdentifierType): NonNumericIdentifierCreator {
|
|
303
|
-
return this.getIdentifierCreator(identifierType, identifierType, NonNumericIdentifierCreator);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
270
|
/**
|
|
307
271
|
* Get GTIN creator.
|
|
308
272
|
*/
|
|
309
273
|
get gtinCreator(): GTINCreator {
|
|
310
|
-
return this.getIdentifierCreator(IdentifierTypes.GTIN
|
|
274
|
+
return this.getIdentifierCreator(IdentifierTypes.GTIN);
|
|
311
275
|
}
|
|
312
276
|
|
|
313
277
|
/**
|
|
314
278
|
* Get GLN creator.
|
|
315
279
|
*/
|
|
316
|
-
get glnCreator():
|
|
317
|
-
return this.
|
|
280
|
+
get glnCreator(): NonSerializableNumericIdentifierCreator {
|
|
281
|
+
return this.getIdentifierCreator(IdentifierTypes.GLN);
|
|
318
282
|
}
|
|
319
283
|
|
|
320
284
|
/**
|
|
321
285
|
* Get SSCC creator.
|
|
322
286
|
*/
|
|
323
|
-
get ssccCreator():
|
|
324
|
-
return this.
|
|
287
|
+
get ssccCreator(): NonSerializableNumericIdentifierCreator {
|
|
288
|
+
return this.getIdentifierCreator(IdentifierTypes.SSCC);
|
|
325
289
|
}
|
|
326
290
|
|
|
327
291
|
/**
|
|
328
292
|
* Get GRAI creator.
|
|
329
293
|
*/
|
|
330
294
|
get graiCreator(): SerializableNumericIdentifierCreator {
|
|
331
|
-
return this.
|
|
295
|
+
return this.getIdentifierCreator(IdentifierTypes.GRAI);
|
|
332
296
|
}
|
|
333
297
|
|
|
334
298
|
/**
|
|
335
299
|
* Get GIAI creator.
|
|
336
300
|
*/
|
|
337
301
|
get giaiCreator(): NonNumericIdentifierCreator {
|
|
338
|
-
return this.
|
|
302
|
+
return this.getIdentifierCreator(IdentifierTypes.GIAI);
|
|
339
303
|
}
|
|
340
304
|
|
|
341
305
|
/**
|
|
342
306
|
* Get GSRN creator.
|
|
343
307
|
*/
|
|
344
|
-
get gsrnCreator():
|
|
345
|
-
return this.
|
|
308
|
+
get gsrnCreator(): NonSerializableNumericIdentifierCreator {
|
|
309
|
+
return this.getIdentifierCreator(IdentifierTypes.GSRN);
|
|
346
310
|
}
|
|
347
311
|
|
|
348
312
|
/**
|
|
349
313
|
* Get GDTI creator.
|
|
350
314
|
*/
|
|
351
315
|
get gdtiCreator(): SerializableNumericIdentifierCreator {
|
|
352
|
-
return this.
|
|
316
|
+
return this.getIdentifierCreator(IdentifierTypes.GDTI);
|
|
353
317
|
}
|
|
354
318
|
|
|
355
319
|
/**
|
|
356
320
|
* Get GINC creator.
|
|
357
321
|
*/
|
|
358
322
|
get gincCreator(): NonNumericIdentifierCreator {
|
|
359
|
-
return this.
|
|
323
|
+
return this.getIdentifierCreator(IdentifierTypes.GINC);
|
|
360
324
|
}
|
|
361
325
|
|
|
362
326
|
/**
|
|
363
327
|
* Get GSIN creator.
|
|
364
328
|
*/
|
|
365
|
-
get gsinCreator():
|
|
366
|
-
return this.
|
|
329
|
+
get gsinCreator(): NonSerializableNumericIdentifierCreator {
|
|
330
|
+
return this.getIdentifierCreator(IdentifierTypes.GSIN);
|
|
367
331
|
}
|
|
368
332
|
|
|
369
333
|
/**
|
|
370
334
|
* Get GCN creator.
|
|
371
335
|
*/
|
|
372
336
|
get gcnCreator(): SerializableNumericIdentifierCreator {
|
|
373
|
-
return this.
|
|
337
|
+
return this.getIdentifierCreator(IdentifierTypes.GCN);
|
|
374
338
|
}
|
|
375
339
|
|
|
376
340
|
/**
|
|
377
341
|
* Get CPID creator.
|
|
378
342
|
*/
|
|
379
343
|
get cpidCreator(): NonNumericIdentifierCreator {
|
|
380
|
-
return this.
|
|
344
|
+
return this.getIdentifierCreator(IdentifierTypes.CPID);
|
|
381
345
|
}
|
|
382
346
|
|
|
383
347
|
/**
|
|
384
348
|
* Get GMN creator.
|
|
385
349
|
*/
|
|
386
350
|
get gmnCreator(): NonNumericIdentifierCreator {
|
|
387
|
-
return this.
|
|
351
|
+
return this.getIdentifierCreator(IdentifierTypes.GMN);
|
|
388
352
|
}
|
|
389
353
|
}
|
|
@@ -1,30 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type { PrefixProvider } from "./prefix-provider.js";
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Used in JSDoc.
|
|
2
|
+
import { mapIterable, NUMERIC_CREATOR, type TransformerInput, type TransformerOutput } from "@aidc-toolkit/utility";
|
|
3
|
+
import { MixinAbstractNonGTINNumericIdentifierCreator } from "./abstract-non-gtin-numeric-identifier-creator.js";
|
|
5
4
|
import type { SerializableNumericIdentifierType } from "./serializable-numeric-identifier-type.js";
|
|
6
5
|
import { SerializableNumericIdentifierValidator } from "./serializable-numeric-identifier-validator.js";
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Serializable numeric identifier creator.
|
|
10
9
|
*/
|
|
11
|
-
export class SerializableNumericIdentifierCreator extends
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* provider type.
|
|
15
|
-
*
|
|
16
|
-
* @param prefixProvider
|
|
17
|
-
* Prefix provider.
|
|
18
|
-
*
|
|
19
|
-
* @param identifierType
|
|
20
|
-
* Identifier type.
|
|
21
|
-
*/
|
|
22
|
-
constructor(prefixProvider: PrefixProvider, identifierType: SerializableNumericIdentifierType) {
|
|
23
|
-
super(identifierType);
|
|
24
|
-
|
|
25
|
-
this.init(prefixProvider, prefixProvider.gs1CompanyPrefix);
|
|
26
|
-
}
|
|
27
|
-
|
|
10
|
+
export class SerializableNumericIdentifierCreator extends MixinAbstractNonGTINNumericIdentifierCreator<
|
|
11
|
+
SerializableNumericIdentifierType
|
|
12
|
+
>(SerializableNumericIdentifierValidator) {
|
|
28
13
|
/**
|
|
29
14
|
* Concatenate a validated base identifier with serial component(s).
|
|
30
15
|
*
|
|
@@ -40,7 +25,7 @@ export class SerializableNumericIdentifierCreator extends Mixin(SerializableNume
|
|
|
40
25
|
* @returns
|
|
41
26
|
* Serialized identifier(s).
|
|
42
27
|
*/
|
|
43
|
-
|
|
28
|
+
#concatenateValidated<TTransformerInput extends TransformerInput<string>>(baseIdentifier: string, serialComponentOrComponents: TTransformerInput): TransformerOutput<TTransformerInput, string> {
|
|
44
29
|
// TODO Refactor type when https://github.com/microsoft/TypeScript/pull/56941 released.
|
|
45
30
|
let result: string | Iterable<string>;
|
|
46
31
|
|
|
@@ -74,7 +59,7 @@ export class SerializableNumericIdentifierCreator extends Mixin(SerializableNume
|
|
|
74
59
|
|
|
75
60
|
/**
|
|
76
61
|
* Create serialized identifier(s) with a reference based on a numeric value concatenated with serial component(s).
|
|
77
|
-
* The value is converted to a reference of the appropriate length using
|
|
62
|
+
* The value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
|
|
78
63
|
*
|
|
79
64
|
* @template TTransformerInput
|
|
80
65
|
* Transformer input type.
|
|
@@ -92,7 +77,7 @@ export class SerializableNumericIdentifierCreator extends Mixin(SerializableNume
|
|
|
92
77
|
* Serialized identifiers.
|
|
93
78
|
*/
|
|
94
79
|
createSerialized<TTransformerInput extends TransformerInput<string>>(value: number, serialComponentOrComponents: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string> {
|
|
95
|
-
return this
|
|
80
|
+
return this.#concatenateValidated(this.create(value, sparse), serialComponentOrComponents);
|
|
96
81
|
}
|
|
97
82
|
|
|
98
83
|
/**
|
|
@@ -113,6 +98,6 @@ export class SerializableNumericIdentifierCreator extends Mixin(SerializableNume
|
|
|
113
98
|
concatenate<TTransformerInput extends TransformerInput<string>>(baseIdentifier: string, serialComponentOrComponents: TTransformerInput): TransformerOutput<TTransformerInput, string> {
|
|
114
99
|
this.validate(baseIdentifier);
|
|
115
100
|
|
|
116
|
-
return this
|
|
101
|
+
return this.#concatenateValidated(baseIdentifier, serialComponentOrComponents);
|
|
117
102
|
}
|
|
118
103
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContentCharacterSet } from "./content-character-set.js";
|
|
2
|
+
import type { LeaderTypes } from "./leader-type.js";
|
|
2
3
|
import type { NonGTINNumericIdentifierDescriptor } from "./non-gtin-numeric-identifier-descriptor.js";
|
|
3
|
-
import type { LeaderTypes } from "./numeric-identifier-type.js";
|
|
4
4
|
import type { SerializableNumericIdentifierType } from "./serializable-numeric-identifier-type.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { exclude } from "@aidc-toolkit/core";
|
|
2
|
+
import { NonGTINNumericIdentifierTypes } from "./non-gtin-numeric-identifier-type.js";
|
|
3
|
+
import { NonSerializableNumericIdentifierTypes } from "./non-serializable-numeric-identifier-type.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Serializable numeric identifier types.
|
|
7
|
+
*/
|
|
8
|
+
export const SerializableNumericIdentifierTypes = exclude(NonGTINNumericIdentifierTypes, NonSerializableNumericIdentifierTypes);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Serializable numeric identifier type key.
|
|
12
|
+
*/
|
|
13
|
+
export type SerializableNumericIdentifierTypeKey = keyof typeof SerializableNumericIdentifierTypes;
|
|
2
14
|
|
|
3
15
|
/**
|
|
4
16
|
* Serializable numeric identifier type.
|
|
5
17
|
*/
|
|
6
|
-
export type SerializableNumericIdentifierType =
|
|
7
|
-
typeof IdentifierTypes.GRAI |
|
|
8
|
-
typeof IdentifierTypes.GDTI |
|
|
9
|
-
typeof IdentifierTypes.GCN;
|
|
18
|
+
export type SerializableNumericIdentifierType = typeof SerializableNumericIdentifierTypes[SerializableNumericIdentifierTypeKey];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { CharacterSetCreator, CharacterSetValidation } from "@aidc-toolkit/utility";
|
|
2
|
-
import {
|
|
2
|
+
import { CONTENT_CHARACTER_SET_CREATORS } from "./content-character-set-creators.js";
|
|
3
3
|
import type { ContentCharacterSet } from "./content-character-set.js";
|
|
4
|
-
import { IdentifierDescriptors } from "./descriptors.js";
|
|
4
|
+
import { IdentifierDescriptors } from "./identifier-descriptors.js";
|
|
5
5
|
import type { IdentifierValidation } from "./identifier-validator.js";
|
|
6
6
|
import { i18nextGS1 } from "./locale/i18n.js";
|
|
7
|
+
import { NonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
|
|
7
8
|
import type { SerializableNumericIdentifierDescriptor } from "./serializable-numeric-identifier-descriptor.js";
|
|
8
9
|
import type { SerializableNumericIdentifierType } from "./serializable-numeric-identifier-type.js";
|
|
9
10
|
|
|
@@ -11,26 +12,26 @@ import type { SerializableNumericIdentifierType } from "./serializable-numeric-i
|
|
|
11
12
|
* Serializable numeric identifier validator. Validates both serialized and non-serialized forms of numeric identifiers
|
|
12
13
|
* that support serialization.
|
|
13
14
|
*/
|
|
14
|
-
export class SerializableNumericIdentifierValidator extends
|
|
15
|
+
export class SerializableNumericIdentifierValidator extends NonGTINNumericIdentifierValidator<SerializableNumericIdentifierType> implements SerializableNumericIdentifierDescriptor {
|
|
15
16
|
/**
|
|
16
17
|
* Serial component length.
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
readonly #serialComponentLength: number;
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Serial component character set.
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
+
readonly #serialComponentCharacterSet: ContentCharacterSet;
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Serial component validation parameters.
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
+
readonly #serialComponentValidation: CharacterSetValidation;
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Serial component creator.
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
+
readonly #serialComponentCreator: CharacterSetCreator;
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
37
|
* Constructor.
|
|
@@ -43,44 +44,44 @@ export class SerializableNumericIdentifierValidator extends AbstractNumericIdent
|
|
|
43
44
|
|
|
44
45
|
super(identifierDescriptor);
|
|
45
46
|
|
|
46
|
-
this
|
|
47
|
-
this
|
|
47
|
+
this.#serialComponentLength = identifierDescriptor.serialComponentLength;
|
|
48
|
+
this.#serialComponentCharacterSet = identifierDescriptor.serialComponentCharacterSet;
|
|
48
49
|
|
|
49
|
-
this
|
|
50
|
+
this.#serialComponentValidation = {
|
|
50
51
|
minimumLength: 1,
|
|
51
52
|
maximumLength: identifierDescriptor.serialComponentLength,
|
|
52
53
|
component: () => i18nextGS1.t("Identifier.serialComponent")
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
this
|
|
56
|
+
this.#serialComponentCreator = CONTENT_CHARACTER_SET_CREATORS[identifierDescriptor.serialComponentCharacterSet];
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
/**
|
|
59
60
|
* Get the serial component length.
|
|
60
61
|
*/
|
|
61
62
|
get serialComponentLength(): number {
|
|
62
|
-
return this
|
|
63
|
+
return this.#serialComponentLength;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* Get the serial component character set.
|
|
67
68
|
*/
|
|
68
69
|
get serialComponentCharacterSet(): ContentCharacterSet {
|
|
69
|
-
return this
|
|
70
|
+
return this.#serialComponentCharacterSet;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
/**
|
|
73
74
|
* Get the serial component validation parameters.
|
|
74
75
|
*/
|
|
75
76
|
protected get serialComponentValidation(): CharacterSetValidation {
|
|
76
|
-
return this
|
|
77
|
+
return this.#serialComponentValidation;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
81
|
* Get the serial component creator.
|
|
81
82
|
*/
|
|
82
83
|
get serialComponentCreator(): CharacterSetCreator {
|
|
83
|
-
return this
|
|
84
|
+
return this.#serialComponentCreator;
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
/**
|
|
@@ -90,7 +91,7 @@ export class SerializableNumericIdentifierValidator extends AbstractNumericIdent
|
|
|
90
91
|
super.validate(identifier.substring(0, this.length), validation);
|
|
91
92
|
|
|
92
93
|
if (identifier.length > this.length) {
|
|
93
|
-
this.serialComponentCreator.validate(identifier.substring(this.length), this
|
|
94
|
+
this.serialComponentCreator.validate(identifier.substring(this.length), this.#serialComponentValidation);
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
}
|
package/test/gtin-creator.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { CharacterSetCreator, Sequence } from "@aidc-toolkit/utility";
|
|
2
2
|
import { expect, test } from "vitest";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type GTINCreator,
|
|
5
|
+
GTINLengths,
|
|
6
|
+
GTINValidator,
|
|
7
|
+
hasValidCheckDigit,
|
|
8
|
+
isGTINCreator,
|
|
9
|
+
PrefixTypes
|
|
10
|
+
} from "../src/index.js";
|
|
4
11
|
import { testNumericIdentifierCreator } from "./numeric-identifier-creator.js";
|
|
5
12
|
|
|
6
13
|
export function testGTINCreator(creator: GTINCreator): void {
|
|
@@ -111,7 +118,7 @@ export function testGTINCreator(creator: GTINCreator): void {
|
|
|
111
118
|
expect(Array.from(creator.createGTIN14("5", randomValues, true))).toStrictEqual(identifiers);
|
|
112
119
|
});
|
|
113
120
|
|
|
114
|
-
if (creator.
|
|
121
|
+
if (creator.length === GTINLengths.GTIN12) {
|
|
115
122
|
test("Zero-suppress GTIN-12 rule 1", () => {
|
|
116
123
|
expect(GTINValidator.zeroSuppress("012345000058")).toBe("01234558");
|
|
117
124
|
expect(GTINValidator.zeroSuppress("012345000065")).toBe("01234565");
|