@aidc-toolkit/gs1 1.0.26-beta → 1.0.27-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abstract-identifier-creator.d.ts +66 -66
- package/dist/abstract-identifier-creator.d.ts.map +1 -1
- package/dist/abstract-identifier-creator.js +68 -45
- package/dist/abstract-identifier-creator.js.map +1 -1
- package/dist/abstract-non-gtin-numeric-identifier-creator.d.ts +42 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.js +40 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.js.map +1 -0
- package/dist/abstract-numeric-identifier-creator.d.ts +37 -86
- package/dist/abstract-numeric-identifier-creator.d.ts.map +1 -1
- package/dist/abstract-numeric-identifier-creator.js +144 -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 +7 -12
- package/dist/gtin-creator.d.ts.map +1 -1
- package/dist/gtin-creator.js +11 -14
- 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} +16 -7
- package/dist/identifier-creators.d.ts.map +1 -0
- package/dist/{creators.js → identifier-creators.js} +19 -7
- 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} +21 -11
- package/dist/identifier-validators.d.ts.map +1 -0
- package/dist/{validators.js → identifier-validators.js} +25 -12
- 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 +7 -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 +6 -102
- package/dist/prefix-manager.d.ts.map +1 -1
- package/dist/prefix-manager.js +65 -60
- 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 +155 -74
- package/src/abstract-non-gtin-numeric-identifier-creator.ts +86 -0
- package/src/abstract-numeric-identifier-creator.ts +202 -133
- package/src/content-character-set-creators.ts +9 -0
- package/src/gtin-creator.ts +16 -15
- 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/{creators.ts → identifier-creators.ts} +40 -26
- 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} +51 -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 +17 -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 +12 -0
- package/src/non-serializable-numeric-identifier-descriptor.ts +7 -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 +67 -64
- package/src/serializable-numeric-identifier-creator.ts +11 -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/non-gtin-numeric-identifier-validator.ts +7 -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/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.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/gtin-validator.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type CharacterSetValidation, NUMERIC_CREATOR } from "@aidc-toolkit/utility";
|
|
2
|
-
import { AbstractNumericIdentifierValidator } from "./abstract-numeric-identifier-validator.js";
|
|
3
2
|
import { checkDigit, hasValidCheckDigit, isValidPriceOrWeightCheckDigit } from "./check.js";
|
|
4
|
-
import { IdentifierDescriptors } from "./descriptors.js";
|
|
5
3
|
import type { GTINDescriptor } from "./gtin-descriptor.js";
|
|
6
|
-
import { type
|
|
4
|
+
import { type GTINBaseLength, GTINLengths } from "./gtin-length.js";
|
|
5
|
+
import type { GTINType } from "./gtin-type.js";
|
|
6
|
+
import { IdentifierDescriptors } from "./identifier-descriptors.js";
|
|
7
7
|
import { i18nextGS1 } from "./locale/i18n.js";
|
|
8
|
+
import { NumericIdentifierValidator } from "./numeric-identifier-validator.js";
|
|
8
9
|
import { type PrefixType, PrefixTypes } from "./prefix-type.js";
|
|
9
10
|
import { PrefixValidator } from "./prefix-validator.js";
|
|
10
11
|
|
|
@@ -56,11 +57,11 @@ export interface RCNReference {
|
|
|
56
57
|
/**
|
|
57
58
|
* GTIN validator.
|
|
58
59
|
*/
|
|
59
|
-
export class GTINValidator extends
|
|
60
|
+
export class GTINValidator extends NumericIdentifierValidator<GTINType> implements GTINDescriptor {
|
|
60
61
|
/**
|
|
61
62
|
* Validation parameters for optional indicator digit.
|
|
62
63
|
*/
|
|
63
|
-
|
|
64
|
+
static readonly #OPTIONAL_INDICATOR_DIGIT_VALIDATION: CharacterSetValidation = {
|
|
64
65
|
minimumLength: 0,
|
|
65
66
|
maximumLength: 1,
|
|
66
67
|
component: () => i18nextGS1.t("Identifier.indicatorDigit")
|
|
@@ -69,7 +70,7 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
69
70
|
/**
|
|
70
71
|
* Validation parameters for zero-suppressed GTIN-12.
|
|
71
72
|
*/
|
|
72
|
-
|
|
73
|
+
static readonly #ZERO_SUPPRESSED_GTIN12_VALIDATION: CharacterSetValidation = {
|
|
73
74
|
minimumLength: 8,
|
|
74
75
|
maximumLength: 8
|
|
75
76
|
};
|
|
@@ -77,35 +78,27 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
77
78
|
/**
|
|
78
79
|
* Prefix type.
|
|
79
80
|
*/
|
|
80
|
-
|
|
81
|
+
readonly #prefixType: PrefixType;
|
|
81
82
|
|
|
82
83
|
/**
|
|
83
84
|
* Constructor.
|
|
84
85
|
*
|
|
85
|
-
* @param
|
|
86
|
-
* GTIN base
|
|
86
|
+
* @param gtinBaseLength
|
|
87
|
+
* GTIN base length (all except GTIN-14).
|
|
87
88
|
*/
|
|
88
|
-
constructor(
|
|
89
|
-
const identifierDescriptor = IdentifierDescriptors.GTIN[
|
|
89
|
+
constructor(gtinBaseLength: GTINBaseLength) {
|
|
90
|
+
const identifierDescriptor = IdentifierDescriptors.GTIN[gtinBaseLength];
|
|
90
91
|
|
|
91
92
|
super(identifierDescriptor);
|
|
92
93
|
|
|
93
|
-
this
|
|
94
|
+
this.#prefixType = identifierDescriptor.prefixType;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
/**
|
|
97
98
|
* @inheritDoc
|
|
98
99
|
*/
|
|
99
100
|
override get prefixType(): PrefixType {
|
|
100
|
-
return this
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @inheritDoc
|
|
105
|
-
*/
|
|
106
|
-
get gtinType(): GTINType {
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Length maps to GTIN type.
|
|
108
|
-
return this.length as GTINType;
|
|
101
|
+
return this.#prefixType;
|
|
109
102
|
}
|
|
110
103
|
|
|
111
104
|
/**
|
|
@@ -163,7 +156,7 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
163
156
|
* GTIN-12.
|
|
164
157
|
*/
|
|
165
158
|
static zeroExpand(zeroSuppressedGTIN12: string): string {
|
|
166
|
-
NUMERIC_CREATOR.validate(zeroSuppressedGTIN12, GTINValidator
|
|
159
|
+
NUMERIC_CREATOR.validate(zeroSuppressedGTIN12, GTINValidator.#ZERO_SUPPRESSED_GTIN12_VALIDATION);
|
|
167
160
|
|
|
168
161
|
// Convert to individual digits.
|
|
169
162
|
const d = Array.from(zeroSuppressedGTIN12);
|
|
@@ -208,14 +201,14 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
208
201
|
static convertToGTIN14(indicatorDigit: string, gtin: string): string {
|
|
209
202
|
GTINValidator.validateAny(gtin);
|
|
210
203
|
|
|
211
|
-
NUMERIC_CREATOR.validate(indicatorDigit, GTINValidator
|
|
204
|
+
NUMERIC_CREATOR.validate(indicatorDigit, GTINValidator.#OPTIONAL_INDICATOR_DIGIT_VALIDATION);
|
|
212
205
|
|
|
213
206
|
// Check digit doesn't change by prepending zeros.
|
|
214
|
-
let gtin14 = gtin.padStart(
|
|
207
|
+
let gtin14 = gtin.padStart(GTINLengths.GTIN14, "0");
|
|
215
208
|
|
|
216
209
|
// If indicator digit provided and is different, recalculate the check digit.
|
|
217
210
|
if (indicatorDigit.length !== 0 && indicatorDigit !== gtin14.charAt(0)) {
|
|
218
|
-
const partialGTIN14 = indicatorDigit + gtin14.substring(1,
|
|
211
|
+
const partialGTIN14 = indicatorDigit + gtin14.substring(1, GTINLengths.GTIN14 - 1);
|
|
219
212
|
|
|
220
213
|
gtin14 = partialGTIN14 + checkDigit(partialGTIN14);
|
|
221
214
|
}
|
|
@@ -242,7 +235,7 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
242
235
|
let normalizedGTIN: string;
|
|
243
236
|
|
|
244
237
|
switch (gtinLength) {
|
|
245
|
-
case
|
|
238
|
+
case GTINLengths.GTIN13 as number:
|
|
246
239
|
if (!gtin.startsWith("0")) {
|
|
247
240
|
// GTIN is GTIN-13.
|
|
248
241
|
normalizedGTIN = gtin;
|
|
@@ -257,12 +250,12 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
257
250
|
}
|
|
258
251
|
break;
|
|
259
252
|
|
|
260
|
-
case
|
|
253
|
+
case GTINLengths.GTIN12 as number:
|
|
261
254
|
// GTIN is GTIN-12.
|
|
262
255
|
normalizedGTIN = gtin;
|
|
263
256
|
break;
|
|
264
257
|
|
|
265
|
-
case
|
|
258
|
+
case GTINLengths.GTIN8 as number:
|
|
266
259
|
if (!gtin.startsWith("0")) {
|
|
267
260
|
// GTIN is GTIN-8.
|
|
268
261
|
normalizedGTIN = gtin;
|
|
@@ -272,7 +265,7 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
272
265
|
}
|
|
273
266
|
break;
|
|
274
267
|
|
|
275
|
-
case
|
|
268
|
+
case GTINLengths.GTIN14 as number:
|
|
276
269
|
if (!gtin.startsWith("0")) {
|
|
277
270
|
// GTIN is GTIN-14.
|
|
278
271
|
normalizedGTIN = gtin;
|
|
@@ -316,7 +309,7 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
316
309
|
let gtinLevelRestriction: GTINLevel;
|
|
317
310
|
|
|
318
311
|
switch (gtin.length) {
|
|
319
|
-
case
|
|
312
|
+
case GTINLengths.GTIN13 as number:
|
|
320
313
|
if (gtin.startsWith("0")) {
|
|
321
314
|
throw new RangeError(i18nextGS1.t("Identifier.invalidGTIN13AtRetail"));
|
|
322
315
|
}
|
|
@@ -327,14 +320,14 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
327
320
|
gtinLevelRestriction = GTINLevels.Any;
|
|
328
321
|
break;
|
|
329
322
|
|
|
330
|
-
case
|
|
323
|
+
case GTINLengths.GTIN12 as number:
|
|
331
324
|
// Validate prefix requiring exact match for prefix type.
|
|
332
325
|
PrefixValidator.validate(PrefixTypes.UPCCompanyPrefix, false, false, gtin, true, true);
|
|
333
326
|
|
|
334
327
|
gtinLevelRestriction = GTINLevels.Any;
|
|
335
328
|
break;
|
|
336
329
|
|
|
337
|
-
case
|
|
330
|
+
case GTINLengths.GTIN8 as number:
|
|
338
331
|
// Zero-suppressed GTIN-12 always starts with 0.
|
|
339
332
|
if (!gtin.startsWith("0")) {
|
|
340
333
|
// Validate prefix requiring exact match for prefix type.
|
|
@@ -346,7 +339,7 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
346
339
|
gtinLevelRestriction = GTINLevels.RetailConsumer;
|
|
347
340
|
break;
|
|
348
341
|
|
|
349
|
-
case
|
|
342
|
+
case GTINLengths.GTIN14 as number:
|
|
350
343
|
// Validate prefix supporting any prefix type.
|
|
351
344
|
PrefixValidator.validate(PrefixTypes.GS1CompanyPrefix, true, true, gtin.substring(1), true, true);
|
|
352
345
|
|
|
@@ -375,7 +368,7 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
375
368
|
* GTIN-14.
|
|
376
369
|
*/
|
|
377
370
|
static validateGTIN14(gtin14: string): void {
|
|
378
|
-
if (gtin14.length !==
|
|
371
|
+
if (gtin14.length !== GTINLengths.GTIN14) {
|
|
379
372
|
throw new RangeError(i18nextGS1.t("Identifier.invalidGTIN14Length"));
|
|
380
373
|
}
|
|
381
374
|
|
|
@@ -515,26 +508,26 @@ export class GTINValidator extends AbstractNumericIdentifierValidator<GTINDescri
|
|
|
515
508
|
* GTIN-13 validator.
|
|
516
509
|
*/
|
|
517
510
|
// Defined here because of circular reference.
|
|
518
|
-
export const GTIN13_VALIDATOR = new GTINValidator(
|
|
511
|
+
export const GTIN13_VALIDATOR = new GTINValidator(GTINLengths.GTIN13);
|
|
519
512
|
|
|
520
513
|
/**
|
|
521
514
|
* GTIN-12 validator.
|
|
522
515
|
*/
|
|
523
516
|
// Defined here because of circular reference.
|
|
524
|
-
export const GTIN12_VALIDATOR = new GTINValidator(
|
|
517
|
+
export const GTIN12_VALIDATOR = new GTINValidator(GTINLengths.GTIN12);
|
|
525
518
|
|
|
526
519
|
/**
|
|
527
520
|
* GTIN-8 validator.
|
|
528
521
|
*/
|
|
529
522
|
// Defined here because of circular reference.
|
|
530
|
-
export const GTIN8_VALIDATOR = new GTINValidator(
|
|
523
|
+
export const GTIN8_VALIDATOR = new GTINValidator(GTINLengths.GTIN8);
|
|
531
524
|
|
|
532
525
|
/**
|
|
533
526
|
* GTIN validators indexed by prefix type.
|
|
534
527
|
*/
|
|
535
528
|
// Defined here because of circular reference.
|
|
536
|
-
export const GTIN_VALIDATORS: Readonly<Record<
|
|
537
|
-
[
|
|
538
|
-
[
|
|
539
|
-
[
|
|
529
|
+
export const GTIN_VALIDATORS: Readonly<Record<GTINBaseLength, GTINValidator>> = {
|
|
530
|
+
[GTINLengths.GTIN13]: GTIN13_VALIDATOR,
|
|
531
|
+
[GTINLengths.GTIN12]: GTIN12_VALIDATOR,
|
|
532
|
+
[GTINLengths.GTIN8]: GTIN8_VALIDATOR
|
|
540
533
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IdentifierType } from "./identifier-type.js";
|
|
2
2
|
import type { IdentifierValidation, IdentifierValidator } from "./identifier-validator.js";
|
|
3
3
|
import type { PrefixProvider } from "./prefix-provider.js";
|
|
4
4
|
|
|
@@ -8,13 +8,13 @@ import type { PrefixProvider } from "./prefix-provider.js";
|
|
|
8
8
|
*
|
|
9
9
|
* Keys are created based on a prefix defined in a prefix provider to which the identifier creator is bound.
|
|
10
10
|
*
|
|
11
|
-
* @template
|
|
12
|
-
* Identifier
|
|
11
|
+
* @template TIdentifierType
|
|
12
|
+
* Identifier type type.
|
|
13
13
|
*
|
|
14
14
|
* @template TIdentifierValidation
|
|
15
15
|
* Identifier validation type.
|
|
16
16
|
*/
|
|
17
|
-
export interface IdentifierCreator<
|
|
17
|
+
export interface IdentifierCreator<TIdentifierType extends IdentifierType = IdentifierType, TIdentifierValidation extends IdentifierValidation = IdentifierValidation> extends IdentifierValidator<TIdentifierType, TIdentifierValidation> {
|
|
18
18
|
/**
|
|
19
19
|
* Get the prefix provider to which this identifier creator is bound.
|
|
20
20
|
*/
|
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isGTINDescriptor,
|
|
3
|
-
isNonGTINNumericIdentifierDescriptor,
|
|
4
|
-
isNonNumericIdentifierDescriptor,
|
|
5
|
-
isNumericIdentifierDescriptor,
|
|
6
|
-
isSerializableNumericIdentifierDescriptor
|
|
7
|
-
} from "./descriptors.js";
|
|
8
1
|
import type { GTINCreator } from "./gtin-creator.js";
|
|
9
2
|
import type { IdentifierCreator } from "./identifier-creator.js";
|
|
10
|
-
import
|
|
3
|
+
import {
|
|
4
|
+
type IdentifierTypeExtension,
|
|
5
|
+
isGTINExtension,
|
|
6
|
+
isNonGTINNumericIdentifierExtension,
|
|
7
|
+
isNonNumericIdentifierExtension,
|
|
8
|
+
isNonSerializableNumericIdentifierExtension,
|
|
9
|
+
isNumericIdentifierExtension,
|
|
10
|
+
isSerializableNumericIdentifierExtension
|
|
11
|
+
} from "./identifier-extension.js";
|
|
12
|
+
import type { IdentifierType } from "./identifier-type.js";
|
|
11
13
|
import type { NonGTINNumericIdentifierCreator } from "./non-gtin-numeric-identifier-creator.js";
|
|
12
|
-
import type { NonGTINNumericIdentifierType } from "./non-gtin-numeric-identifier-type.js";
|
|
13
14
|
import type { NonNumericIdentifierCreator } from "./non-numeric-identifier-creator.js";
|
|
14
|
-
import type {
|
|
15
|
+
import type { NonSerializableNumericIdentifierCreator } from "./non-serializable-numeric-identifier-creator.js";
|
|
15
16
|
import type { NumericIdentifierCreator } from "./numeric-identifier-creator.js";
|
|
16
17
|
import type { SerializableNumericIdentifierCreator } from "./serializable-numeric-identifier-creator.js";
|
|
17
|
-
import type { SerializableNumericIdentifierType } from "./serializable-numeric-identifier-type.js";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Identifier creator type based on identifier type type.
|
|
21
21
|
*
|
|
22
22
|
* @template TIdentifierType
|
|
23
23
|
* Identifier type type.
|
|
24
24
|
*/
|
|
25
|
-
export type IdentifierTypeCreator<TIdentifierType extends IdentifierType> =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
export type IdentifierTypeCreator<TIdentifierType extends IdentifierType> = IdentifierTypeExtension<
|
|
26
|
+
TIdentifierType,
|
|
27
|
+
IdentifierCreator,
|
|
28
|
+
NumericIdentifierCreator,
|
|
29
|
+
GTINCreator,
|
|
30
|
+
NonGTINNumericIdentifierCreator,
|
|
31
|
+
NonSerializableNumericIdentifierCreator,
|
|
32
|
+
SerializableNumericIdentifierCreator,
|
|
33
|
+
NonNumericIdentifierCreator
|
|
34
|
+
>;
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
37
|
* Identifier creators entry type based on identifier type type.
|
|
@@ -57,7 +58,7 @@ export type IdentifierCreatorsRecord = {
|
|
|
57
58
|
* True if identifier creator is a numeric identifier creator.
|
|
58
59
|
*/
|
|
59
60
|
export function isNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NumericIdentifierCreator {
|
|
60
|
-
return
|
|
61
|
+
return isNumericIdentifierExtension(identifierCreator);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
/**
|
|
@@ -70,7 +71,7 @@ export function isNumericIdentifierCreator(identifierCreator: IdentifierCreator)
|
|
|
70
71
|
* True if identifier creator is a GTIN creator.
|
|
71
72
|
*/
|
|
72
73
|
export function isGTINCreator(identifierCreator: IdentifierCreator): identifierCreator is GTINCreator {
|
|
73
|
-
return
|
|
74
|
+
return isGTINExtension(identifierCreator);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
/**
|
|
@@ -83,7 +84,20 @@ export function isGTINCreator(identifierCreator: IdentifierCreator): identifierC
|
|
|
83
84
|
* True if identifier creator is a non-GTIN numeric identifier creator.
|
|
84
85
|
*/
|
|
85
86
|
export function isNonGTINNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NonGTINNumericIdentifierCreator {
|
|
86
|
-
return
|
|
87
|
+
return isNonGTINNumericIdentifierExtension(identifierCreator);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Determine if identifier creator is a non-serializable numeric identifier creator.
|
|
92
|
+
*
|
|
93
|
+
* @param identifierCreator
|
|
94
|
+
* Identifier creator.
|
|
95
|
+
*
|
|
96
|
+
* @returns
|
|
97
|
+
* True if identifier creator is a non-serializable numeric identifier creator.
|
|
98
|
+
*/
|
|
99
|
+
export function isNonSerializableNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NonSerializableNumericIdentifierCreator {
|
|
100
|
+
return isNonSerializableNumericIdentifierExtension(identifierCreator);
|
|
87
101
|
}
|
|
88
102
|
|
|
89
103
|
/**
|
|
@@ -96,7 +110,7 @@ export function isNonGTINNumericIdentifierCreator(identifierCreator: IdentifierC
|
|
|
96
110
|
* True if identifier creator is a serializable numeric identifier creator.
|
|
97
111
|
*/
|
|
98
112
|
export function isSerializableNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is SerializableNumericIdentifierCreator {
|
|
99
|
-
return
|
|
113
|
+
return isSerializableNumericIdentifierExtension(identifierCreator);
|
|
100
114
|
}
|
|
101
115
|
|
|
102
116
|
/**
|
|
@@ -109,5 +123,5 @@ export function isSerializableNumericIdentifierCreator(identifierCreator: Identi
|
|
|
109
123
|
* True if identifier creator is a non-numeric identifier creator.
|
|
110
124
|
*/
|
|
111
125
|
export function isNonNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NonNumericIdentifierCreator {
|
|
112
|
-
return
|
|
126
|
+
return isNonNumericIdentifierExtension(identifierCreator);
|
|
113
127
|
}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { ContentCharacterSets } from "./content-character-set.js";
|
|
2
2
|
import type { GTINDescriptor } from "./gtin-descriptor.js";
|
|
3
|
-
import { type
|
|
3
|
+
import { type GTINBaseLength, GTINBaseLengths } from "./gtin-length.js";
|
|
4
|
+
import type { GTINType } from "./gtin-type.js";
|
|
4
5
|
import type { IdentifierDescriptor } from "./identifier-descriptor.js";
|
|
6
|
+
import {
|
|
7
|
+
type IdentifierTypeExtension,
|
|
8
|
+
isGTINExtension,
|
|
9
|
+
isNonGTINNumericIdentifierExtension,
|
|
10
|
+
isNonNumericIdentifierExtension,
|
|
11
|
+
isNonSerializableNumericIdentifierExtension,
|
|
12
|
+
isNumericIdentifierExtension,
|
|
13
|
+
isSerializableNumericIdentifierExtension
|
|
14
|
+
} from "./identifier-extension.js";
|
|
5
15
|
import { type IdentifierType, IdentifierTypes } from "./identifier-type.js";
|
|
16
|
+
import { LeaderTypes } from "./leader-type.js";
|
|
6
17
|
import type { NonGTINNumericIdentifierDescriptor } from "./non-gtin-numeric-identifier-descriptor.js";
|
|
7
|
-
import type { NonGTINNumericIdentifierType } from "./non-gtin-numeric-identifier-type.js";
|
|
8
18
|
import type { NonNumericIdentifierDescriptor } from "./non-numeric-identifier-descriptor.js";
|
|
9
|
-
import type {
|
|
19
|
+
import type { NonSerializableNumericIdentifierDescriptor } from "./non-serializable-numeric-identifier-descriptor.js";
|
|
10
20
|
import type { NumericIdentifierDescriptor } from "./numeric-identifier-descriptor.js";
|
|
11
|
-
import { LeaderTypes, type NumericIdentifierType } from "./numeric-identifier-type.js";
|
|
12
21
|
import { PrefixTypes } from "./prefix-type.js";
|
|
13
22
|
import type { SerializableNumericIdentifierDescriptor } from "./serializable-numeric-identifier-descriptor.js";
|
|
14
|
-
import type { SerializableNumericIdentifierType } from "./serializable-numeric-identifier-type.js";
|
|
15
23
|
|
|
16
24
|
/**
|
|
17
25
|
* GTIN-13 descriptor.
|
|
@@ -19,7 +27,7 @@ import type { SerializableNumericIdentifierType } from "./serializable-numeric-i
|
|
|
19
27
|
const GTIN13_DESCRIPTOR: GTINDescriptor = {
|
|
20
28
|
identifierType: IdentifierTypes.GTIN,
|
|
21
29
|
prefixType: PrefixTypes.GS1CompanyPrefix,
|
|
22
|
-
length:
|
|
30
|
+
length: GTINBaseLengths.GTIN13,
|
|
23
31
|
referenceCharacterSet: ContentCharacterSets.Numeric,
|
|
24
32
|
leaderType: LeaderTypes.IndicatorDigit
|
|
25
33
|
};
|
|
@@ -30,7 +38,7 @@ const GTIN13_DESCRIPTOR: GTINDescriptor = {
|
|
|
30
38
|
const GTIN12_DESCRIPTOR: GTINDescriptor = {
|
|
31
39
|
identifierType: IdentifierTypes.GTIN,
|
|
32
40
|
prefixType: PrefixTypes.UPCCompanyPrefix,
|
|
33
|
-
length:
|
|
41
|
+
length: GTINBaseLengths.GTIN12,
|
|
34
42
|
referenceCharacterSet: ContentCharacterSets.Numeric,
|
|
35
43
|
leaderType: LeaderTypes.IndicatorDigit
|
|
36
44
|
};
|
|
@@ -41,7 +49,7 @@ const GTIN12_DESCRIPTOR: GTINDescriptor = {
|
|
|
41
49
|
const GTIN8_DESCRIPTOR: GTINDescriptor = {
|
|
42
50
|
identifierType: IdentifierTypes.GTIN,
|
|
43
51
|
prefixType: PrefixTypes.GS18Prefix,
|
|
44
|
-
length:
|
|
52
|
+
length: GTINBaseLengths.GTIN8,
|
|
45
53
|
referenceCharacterSet: ContentCharacterSets.Numeric,
|
|
46
54
|
leaderType: LeaderTypes.IndicatorDigit
|
|
47
55
|
};
|
|
@@ -49,16 +57,16 @@ const GTIN8_DESCRIPTOR: GTINDescriptor = {
|
|
|
49
57
|
/**
|
|
50
58
|
* GTIN descriptors indexed by prefix type.
|
|
51
59
|
*/
|
|
52
|
-
const GTIN_DESCRIPTORS: Readonly<Record<
|
|
53
|
-
[
|
|
54
|
-
[
|
|
55
|
-
[
|
|
60
|
+
const GTIN_DESCRIPTORS: Readonly<Record<GTINBaseLength, GTINDescriptor>> = {
|
|
61
|
+
[GTINBaseLengths.GTIN13]: GTIN13_DESCRIPTOR,
|
|
62
|
+
[GTINBaseLengths.GTIN12]: GTIN12_DESCRIPTOR,
|
|
63
|
+
[GTINBaseLengths.GTIN8]: GTIN8_DESCRIPTOR
|
|
56
64
|
};
|
|
57
65
|
|
|
58
66
|
/**
|
|
59
67
|
* GLN descriptor.
|
|
60
68
|
*/
|
|
61
|
-
const GLN_DESCRIPTOR:
|
|
69
|
+
const GLN_DESCRIPTOR: NonSerializableNumericIdentifierDescriptor = {
|
|
62
70
|
identifierType: IdentifierTypes.GLN,
|
|
63
71
|
prefixType: PrefixTypes.GS1CompanyPrefix,
|
|
64
72
|
length: 13,
|
|
@@ -69,7 +77,7 @@ const GLN_DESCRIPTOR: NonGTINNumericIdentifierDescriptor = {
|
|
|
69
77
|
/**
|
|
70
78
|
* SSCC descriptor.
|
|
71
79
|
*/
|
|
72
|
-
const SSCC_DESCRIPTOR:
|
|
80
|
+
const SSCC_DESCRIPTOR: NonSerializableNumericIdentifierDescriptor = {
|
|
73
81
|
identifierType: IdentifierTypes.SSCC,
|
|
74
82
|
prefixType: PrefixTypes.GS1CompanyPrefix,
|
|
75
83
|
length: 18,
|
|
@@ -104,7 +112,7 @@ const GIAI_DESCRIPTOR: NonNumericIdentifierDescriptor = {
|
|
|
104
112
|
/**
|
|
105
113
|
* GSRN descriptor.
|
|
106
114
|
*/
|
|
107
|
-
const GSRN_DESCRIPTOR:
|
|
115
|
+
const GSRN_DESCRIPTOR: NonSerializableNumericIdentifierDescriptor = {
|
|
108
116
|
identifierType: IdentifierTypes.GSRN,
|
|
109
117
|
prefixType: PrefixTypes.GS1CompanyPrefix,
|
|
110
118
|
length: 18,
|
|
@@ -139,7 +147,7 @@ const GINC_DESCRIPTOR: NonNumericIdentifierDescriptor = {
|
|
|
139
147
|
/**
|
|
140
148
|
* GSIN descriptor.
|
|
141
149
|
*/
|
|
142
|
-
const GSIN_DESCRIPTOR:
|
|
150
|
+
const GSIN_DESCRIPTOR: NonSerializableNumericIdentifierDescriptor = {
|
|
143
151
|
identifierType: IdentifierTypes.GSIN,
|
|
144
152
|
prefixType: PrefixTypes.GS1CompanyPrefix,
|
|
145
153
|
length: 17,
|
|
@@ -188,15 +196,16 @@ const GMN_DESCRIPTOR: NonNumericIdentifierDescriptor = {
|
|
|
188
196
|
* @template TIdentifierType
|
|
189
197
|
* Identifier type type.
|
|
190
198
|
*/
|
|
191
|
-
export type IdentifierTypeDescriptor<TIdentifierType extends IdentifierType> =
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
export type IdentifierTypeDescriptor<TIdentifierType extends IdentifierType> = IdentifierTypeExtension<
|
|
200
|
+
TIdentifierType,
|
|
201
|
+
IdentifierDescriptor,
|
|
202
|
+
NumericIdentifierDescriptor,
|
|
203
|
+
GTINDescriptor,
|
|
204
|
+
NonGTINNumericIdentifierDescriptor,
|
|
205
|
+
NonSerializableNumericIdentifierDescriptor,
|
|
206
|
+
SerializableNumericIdentifierDescriptor,
|
|
207
|
+
NonNumericIdentifierDescriptor
|
|
208
|
+
>;
|
|
200
209
|
|
|
201
210
|
/**
|
|
202
211
|
* Identifier descriptors entry type based on identifier type type.
|
|
@@ -204,15 +213,15 @@ export type IdentifierTypeDescriptor<TIdentifierType extends IdentifierType> = T
|
|
|
204
213
|
* @template TIdentifierType
|
|
205
214
|
* Identifier type type.
|
|
206
215
|
*/
|
|
207
|
-
export type IdentifierDescriptorsEntry<TIdentifierType extends IdentifierType> = TIdentifierType extends
|
|
208
|
-
Readonly<Record<
|
|
216
|
+
export type IdentifierDescriptorsEntry<TIdentifierType extends IdentifierType> = TIdentifierType extends GTINType ?
|
|
217
|
+
Readonly<Record<GTINBaseLength, GTINDescriptor>> :
|
|
209
218
|
IdentifierTypeDescriptor<TIdentifierType>;
|
|
210
219
|
|
|
211
220
|
/**
|
|
212
221
|
* Identifier descriptors record type.
|
|
213
222
|
*/
|
|
214
223
|
export type IdentifierDescriptorsRecord = {
|
|
215
|
-
[TIdentifierType in IdentifierType]: IdentifierDescriptorsEntry<TIdentifierType>;
|
|
224
|
+
readonly [TIdentifierType in IdentifierType]: IdentifierDescriptorsEntry<TIdentifierType>;
|
|
216
225
|
};
|
|
217
226
|
|
|
218
227
|
/**
|
|
@@ -231,7 +240,7 @@ export const IdentifierDescriptors: IdentifierDescriptorsRecord = {
|
|
|
231
240
|
[IdentifierTypes.GCN]: GCN_DESCRIPTOR,
|
|
232
241
|
[IdentifierTypes.CPID]: CPID_DESCRIPTOR,
|
|
233
242
|
[IdentifierTypes.GMN]: GMN_DESCRIPTOR
|
|
234
|
-
}
|
|
243
|
+
};
|
|
235
244
|
|
|
236
245
|
/**
|
|
237
246
|
* Determine if identifier descriptors or descriptor is GTIN descriptors.
|
|
@@ -242,28 +251,10 @@ export const IdentifierDescriptors: IdentifierDescriptorsRecord = {
|
|
|
242
251
|
* @returns
|
|
243
252
|
* True if GTIN descriptors.
|
|
244
253
|
*/
|
|
245
|
-
export function isGTINDescriptors(identifierDescriptorsOrDescriptor: IdentifierDescriptorsEntry<IdentifierType>): identifierDescriptorsOrDescriptor is Readonly<Record<
|
|
254
|
+
export function isGTINDescriptors(identifierDescriptorsOrDescriptor: IdentifierDescriptorsEntry<IdentifierType>): identifierDescriptorsOrDescriptor is Readonly<Record<GTINBaseLength, GTINDescriptor>> {
|
|
246
255
|
return !("identifierType" in identifierDescriptorsOrDescriptor);
|
|
247
256
|
}
|
|
248
257
|
|
|
249
|
-
/**
|
|
250
|
-
* Determine if an array of identifier types includes a given identifier type.
|
|
251
|
-
*
|
|
252
|
-
* @param identifierTypes
|
|
253
|
-
* Identifier types.
|
|
254
|
-
*
|
|
255
|
-
* @param identifierType
|
|
256
|
-
* Identifier type.
|
|
257
|
-
*
|
|
258
|
-
* @returns
|
|
259
|
-
* True if element is included in the array.
|
|
260
|
-
*/
|
|
261
|
-
function identifierTypesIncludes(identifierTypes: readonly IdentifierType[], identifierType: IdentifierType): boolean {
|
|
262
|
-
return identifierTypes.includes(identifierType);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const NUMERIC_IDENTIFIER_TYPES: readonly NumericIdentifierType[] = [IdentifierTypes.GTIN, IdentifierTypes.GLN, IdentifierTypes.SSCC, IdentifierTypes.GRAI, IdentifierTypes.GSRN, IdentifierTypes.GDTI, IdentifierTypes.GSIN, IdentifierTypes.GCN];
|
|
266
|
-
|
|
267
258
|
/**
|
|
268
259
|
* Determine if identifier descriptor is a numeric identifier descriptor.
|
|
269
260
|
*
|
|
@@ -274,7 +265,7 @@ const NUMERIC_IDENTIFIER_TYPES: readonly NumericIdentifierType[] = [IdentifierTy
|
|
|
274
265
|
* True if identifier descriptor is a numeric identifier descriptor.
|
|
275
266
|
*/
|
|
276
267
|
export function isNumericIdentifierDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is NumericIdentifierDescriptor {
|
|
277
|
-
return
|
|
268
|
+
return isNumericIdentifierExtension(identifierDescriptor);
|
|
278
269
|
}
|
|
279
270
|
|
|
280
271
|
/**
|
|
@@ -287,7 +278,7 @@ export function isNumericIdentifierDescriptor(identifierDescriptor: IdentifierDe
|
|
|
287
278
|
* True if identifier descriptor is a GTIN descriptor.
|
|
288
279
|
*/
|
|
289
280
|
export function isGTINDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is GTINDescriptor {
|
|
290
|
-
return identifierDescriptor
|
|
281
|
+
return isGTINExtension(identifierDescriptor);
|
|
291
282
|
}
|
|
292
283
|
|
|
293
284
|
/**
|
|
@@ -300,10 +291,21 @@ export function isGTINDescriptor(identifierDescriptor: IdentifierDescriptor): id
|
|
|
300
291
|
* True if identifier descriptor is a non-GTIN numeric identifier descriptor.
|
|
301
292
|
*/
|
|
302
293
|
export function isNonGTINNumericIdentifierDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is NonGTINNumericIdentifierDescriptor {
|
|
303
|
-
return
|
|
294
|
+
return isNonGTINNumericIdentifierExtension(identifierDescriptor);
|
|
304
295
|
}
|
|
305
296
|
|
|
306
|
-
|
|
297
|
+
/**
|
|
298
|
+
* Determine if identifier descriptor is a non-serializable numeric identifier descriptor.
|
|
299
|
+
*
|
|
300
|
+
* @param identifierDescriptor
|
|
301
|
+
* Identifier descriptor.
|
|
302
|
+
*
|
|
303
|
+
* @returns
|
|
304
|
+
* True if identifier descriptor is a non-serializable numeric identifier descriptor.
|
|
305
|
+
*/
|
|
306
|
+
export function isNonSerializableNumericIdentifierDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is NonSerializableNumericIdentifierDescriptor {
|
|
307
|
+
return isNonSerializableNumericIdentifierExtension(identifierDescriptor);
|
|
308
|
+
}
|
|
307
309
|
|
|
308
310
|
/**
|
|
309
311
|
* Determine if identifier descriptor is a serializable numeric identifier descriptor.
|
|
@@ -315,7 +317,7 @@ const SERIALIZABLE_NUMERIC_IDENTIFIER_TYPES: readonly SerializableNumericIdentif
|
|
|
315
317
|
* True if identifier descriptor is a serializable numeric identifier descriptor.
|
|
316
318
|
*/
|
|
317
319
|
export function isSerializableNumericIdentifierDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is SerializableNumericIdentifierDescriptor {
|
|
318
|
-
return
|
|
320
|
+
return isSerializableNumericIdentifierExtension(identifierDescriptor);
|
|
319
321
|
}
|
|
320
322
|
|
|
321
323
|
/**
|
|
@@ -328,5 +330,5 @@ export function isSerializableNumericIdentifierDescriptor(identifierDescriptor:
|
|
|
328
330
|
* True if identifier descriptor is a non-numeric identifier descriptor.
|
|
329
331
|
*/
|
|
330
332
|
export function isNonNumericIdentifierDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is NonNumericIdentifierDescriptor {
|
|
331
|
-
return
|
|
333
|
+
return isNonNumericIdentifierExtension(identifierDescriptor);
|
|
332
334
|
}
|