@aidc-toolkit/gs1 1.0.25-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 +75 -0
- package/dist/abstract-identifier-creator.d.ts.map +1 -0
- package/dist/abstract-identifier-creator.js +79 -0
- package/dist/abstract-identifier-creator.js.map +1 -0
- 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 +43 -0
- package/dist/abstract-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/abstract-numeric-identifier-creator.js +160 -0
- package/dist/abstract-numeric-identifier-creator.js.map +1 -0
- package/dist/character-set.d.ts +27 -0
- package/dist/character-set.d.ts.map +1 -0
- package/dist/character-set.js +50 -0
- package/dist/character-set.js.map +1 -0
- package/dist/check.d.ts +81 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +218 -0
- package/dist/check.js.map +1 -0
- 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/content-character-set.d.ts +26 -0
- package/dist/content-character-set.d.ts.map +1 -0
- package/dist/content-character-set.js +18 -0
- package/dist/content-character-set.js.map +1 -0
- package/dist/gtin-creator.d.ts +64 -0
- package/dist/gtin-creator.d.ts.map +1 -0
- package/dist/gtin-creator.js +156 -0
- package/dist/gtin-creator.js.map +1 -0
- package/dist/gtin-descriptor.d.ts +22 -0
- package/dist/gtin-descriptor.d.ts.map +1 -0
- package/dist/gtin-descriptor.js +2 -0
- package/dist/gtin-descriptor.js.map +1 -0
- 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 +26 -0
- package/dist/gtin-type.d.ts.map +1 -0
- package/dist/gtin-type.js +7 -0
- package/dist/gtin-type.js.map +1 -0
- package/dist/gtin-validator.d.ts +177 -0
- package/dist/gtin-validator.d.ts.map +1 -0
- package/dist/gtin-validator.js +443 -0
- package/dist/gtin-validator.js.map +1 -0
- package/dist/identifier-creator.d.ts +31 -0
- package/dist/identifier-creator.d.ts.map +1 -0
- package/dist/identifier-creator.js +2 -0
- package/dist/identifier-creator.js.map +1 -0
- package/dist/identifier-creators.d.ts +90 -0
- package/dist/identifier-creators.d.ts.map +1 -0
- package/dist/identifier-creators.js +74 -0
- package/dist/identifier-creators.js.map +1 -0
- package/dist/identifier-descriptor.d.ts +27 -0
- package/dist/identifier-descriptor.d.ts.map +1 -0
- package/dist/identifier-descriptor.js +2 -0
- package/dist/identifier-descriptor.js.map +1 -0
- package/dist/identifier-descriptors.d.ts +106 -0
- package/dist/identifier-descriptors.d.ts.map +1 -0
- package/dist/identifier-descriptors.js +262 -0
- 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-type.d.ts +62 -0
- package/dist/identifier-type.d.ts.map +1 -0
- package/dist/identifier-type.js +54 -0
- package/dist/identifier-type.js.map +1 -0
- package/dist/identifier-validator.d.ts +88 -0
- package/dist/identifier-validator.d.ts.map +1 -0
- package/dist/identifier-validator.js +110 -0
- package/dist/identifier-validator.js.map +1 -0
- package/dist/identifier-validators.d.ts +106 -0
- package/dist/identifier-validators.d.ts.map +1 -0
- package/dist/identifier-validators.js +153 -0
- package/dist/identifier-validators.js.map +1 -0
- package/dist/index.d.ts +58 -1949
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -4727
- 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/locale/en/locale-resources.d.ts +42 -0
- package/dist/locale/en/locale-resources.d.ts.map +1 -0
- package/dist/locale/en/locale-resources.js +41 -0
- package/dist/locale/en/locale-resources.js.map +1 -0
- package/dist/locale/fr/locale-resources.d.ts +42 -0
- package/dist/locale/fr/locale-resources.d.ts.map +1 -0
- package/dist/locale/fr/locale-resources.js +41 -0
- package/dist/locale/fr/locale-resources.js.map +1 -0
- package/dist/locale/i18n.d.ts +27 -0
- package/dist/locale/i18n.d.ts.map +1 -0
- package/dist/locale/i18n.js +36 -0
- package/dist/locale/i18n.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-creator.d.ts +12 -0
- package/dist/non-gtin-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-creator.js +2 -0
- package/dist/non-gtin-numeric-identifier-creator.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-descriptor.d.ts +22 -0
- package/dist/non-gtin-numeric-identifier-descriptor.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-descriptor.js +2 -0
- package/dist/non-gtin-numeric-identifier-descriptor.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-type.d.ts +26 -0
- package/dist/non-gtin-numeric-identifier-type.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-type.js +8 -0
- package/dist/non-gtin-numeric-identifier-type.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-validator.d.ts +12 -0
- package/dist/non-gtin-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-validator.js +10 -0
- package/dist/non-gtin-numeric-identifier-validator.js.map +1 -0
- package/dist/non-numeric-identifier-creator.d.ts +40 -0
- package/dist/non-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/non-numeric-identifier-creator.js +82 -0
- package/dist/non-numeric-identifier-creator.js.map +1 -0
- package/dist/non-numeric-identifier-descriptor.d.ts +26 -0
- package/dist/non-numeric-identifier-descriptor.d.ts.map +1 -0
- package/dist/non-numeric-identifier-descriptor.js +2 -0
- package/dist/non-numeric-identifier-descriptor.js.map +1 -0
- package/dist/non-numeric-identifier-type.d.ts +26 -0
- package/dist/non-numeric-identifier-type.d.ts.map +1 -0
- package/dist/non-numeric-identifier-type.js +8 -0
- package/dist/non-numeric-identifier-type.js.map +1 -0
- package/dist/non-numeric-identifier-validator.d.ts +41 -0
- package/dist/non-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/non-numeric-identifier-validator.js +69 -0
- package/dist/non-numeric-identifier-validator.js.map +1 -0
- 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 +53 -0
- package/dist/numeric-identifier-creator.d.ts.map +1 -0
- package/dist/numeric-identifier-creator.js +2 -0
- package/dist/numeric-identifier-creator.js.map +1 -0
- package/dist/numeric-identifier-descriptor.d.ts +22 -0
- package/dist/numeric-identifier-descriptor.d.ts.map +1 -0
- package/dist/numeric-identifier-descriptor.js +2 -0
- package/dist/numeric-identifier-descriptor.js.map +1 -0
- package/dist/numeric-identifier-type.d.ts +26 -0
- package/dist/numeric-identifier-type.d.ts.map +1 -0
- package/dist/numeric-identifier-type.js +7 -0
- package/dist/numeric-identifier-type.js.map +1 -0
- package/dist/numeric-identifier-validator.d.ts +38 -0
- package/dist/numeric-identifier-validator.d.ts.map +1 -0
- package/dist/numeric-identifier-validator.js +61 -0
- package/dist/numeric-identifier-validator.js.map +1 -0
- package/dist/prefix-manager.d.ts +136 -0
- package/dist/prefix-manager.d.ts.map +1 -0
- package/dist/prefix-manager.js +339 -0
- package/dist/prefix-manager.js.map +1 -0
- package/dist/prefix-provider.d.ts +27 -0
- package/dist/prefix-provider.d.ts.map +1 -0
- package/dist/prefix-provider.js +2 -0
- package/dist/prefix-provider.js.map +1 -0
- package/dist/prefix-type.d.ts +26 -0
- package/dist/prefix-type.d.ts.map +1 -0
- package/dist/prefix-type.js +18 -0
- package/dist/prefix-type.js.map +1 -0
- package/dist/prefix-validator.d.ts +70 -0
- package/dist/prefix-validator.d.ts.map +1 -0
- package/dist/prefix-validator.js +208 -0
- package/dist/prefix-validator.js.map +1 -0
- package/dist/serializable-numeric-identifier-creator.d.ts +48 -0
- package/dist/serializable-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-creator.js +93 -0
- package/dist/serializable-numeric-identifier-creator.js.map +1 -0
- package/dist/serializable-numeric-identifier-descriptor.d.ts +26 -0
- package/dist/serializable-numeric-identifier-descriptor.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-descriptor.js +2 -0
- package/dist/serializable-numeric-identifier-descriptor.js.map +1 -0
- package/dist/serializable-numeric-identifier-type.d.ts +26 -0
- package/dist/serializable-numeric-identifier-type.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-type.js +8 -0
- package/dist/serializable-numeric-identifier-type.js.map +1 -0
- package/dist/serializable-numeric-identifier-validator.d.ts +41 -0
- package/dist/serializable-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-validator.js +78 -0
- package/dist/serializable-numeric-identifier-validator.js.map +1 -0
- package/package.json +11 -8
- package/src/abstract-identifier-creator.ts +157 -76
- package/src/abstract-non-gtin-numeric-identifier-creator.ts +86 -0
- package/src/abstract-numeric-identifier-creator.ts +205 -136
- package/src/check.ts +2 -2
- package/src/content-character-set-creators.ts +9 -0
- package/src/gtin-creator.ts +20 -19
- package/src/gtin-descriptor.ts +10 -4
- package/src/gtin-length.ts +61 -0
- package/src/gtin-type.ts +6 -37
- package/src/gtin-validator.ts +39 -46
- package/src/identifier-creator.ts +6 -6
- package/src/{creators.ts → identifier-creators.ts} +45 -31
- package/src/identifier-descriptor.ts +3 -3
- package/src/{descriptors.ts → identifier-descriptors.ts} +65 -63
- package/src/identifier-extension.ts +155 -0
- package/src/identifier-validator.ts +94 -11
- package/src/{validators.ts → identifier-validators.ts} +56 -41
- package/src/index.ts +50 -43
- package/src/leader-type.ts +29 -0
- package/src/locale/i18n.ts +3 -3
- package/src/locale/i18next.d.ts +1 -1
- package/src/non-gtin-numeric-identifier-creator.ts +8 -23
- package/src/non-gtin-numeric-identifier-descriptor.ts +4 -4
- package/src/non-gtin-numeric-identifier-type.ts +14 -3
- package/src/non-gtin-numeric-identifier-validator.ts +7 -15
- package/src/non-numeric-identifier-creator.ts +21 -16
- package/src/non-numeric-identifier-descriptor.ts +4 -4
- package/src/non-numeric-identifier-type.ts +14 -3
- package/src/non-numeric-identifier-validator.ts +12 -13
- 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 +9 -8
- package/src/numeric-identifier-descriptor.ts +4 -3
- package/src/numeric-identifier-type.ts +17 -35
- package/src/numeric-identifier-validator.ts +62 -7
- package/src/prefix-manager.ts +79 -76
- package/src/prefix-provider.ts +1 -1
- package/src/prefix-validator.ts +3 -3
- package/src/serializable-numeric-identifier-creator.ts +13 -27
- package/src/serializable-numeric-identifier-descriptor.ts +4 -4
- package/src/serializable-numeric-identifier-type.ts +14 -5
- package/src/serializable-numeric-identifier-validator.ts +22 -21
- package/test/check.test.ts +1 -1
- package/test/creator.test.ts +5 -5
- package/test/gtin-creator.ts +10 -3
- package/test/gtin-validator.test.ts +10 -12
- package/test/identifier-creator.ts +12 -12
- package/test/identifier-validator.ts +1 -1
- package/test/non-gtin-numeric-identifier-creator.ts +3 -3
- package/test/non-gtin-numeric-identifier-validator.ts +8 -3
- package/test/non-numeric-identifier-creator.ts +1 -1
- package/test/non-numeric-identifier-validator.ts +3 -3
- 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 +9 -4
- package/test/numeric-identifier-validator.ts +2 -2
- package/test/prefix-manager.test.ts +2 -2
- package/test/serializable-numeric-identifier-creator.ts +2 -2
- package/test/serializable-numeric-identifier-validator.ts +3 -3
- package/test/setup.ts +1 -1
- package/test/sparse.test.ts +1 -1
- package/test/utility.ts +1 -1
- package/test/validator.test.ts +16 -15
- package/test/variable-measure-rcn.test.ts +24 -24
- package/tsconfig-config.json +4 -0
- package/tsconfig-src.json +8 -0
- package/tsconfig-test.json +9 -0
- package/tsconfig.json +12 -1
- package/tsup.config.ts +3 -2
- package/dist/index.cjs +0 -4813
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1949
- package/src/abstract-identifier-validator.ts +0 -140
- package/src/abstract-numeric-identifier-validator.ts +0 -69
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import { NUMERIC_CREATOR } from "@aidc-toolkit/utility";
|
|
2
|
+
import { checkDigit, hasValidCheckDigit, isValidPriceOrWeightCheckDigit } from "./check.js";
|
|
3
|
+
import { GTINLengths } from "./gtin-length.js";
|
|
4
|
+
import { IdentifierDescriptors } from "./identifier-descriptors.js";
|
|
5
|
+
import { i18nextGS1 } from "./locale/i18n.js";
|
|
6
|
+
import { NumericIdentifierValidator } from "./numeric-identifier-validator.js";
|
|
7
|
+
import { PrefixTypes } from "./prefix-type.js";
|
|
8
|
+
import { PrefixValidator } from "./prefix-validator.js";
|
|
9
|
+
/**
|
|
10
|
+
* Levels at which GTIN is to be validated.
|
|
11
|
+
*/
|
|
12
|
+
export const GTINLevels = {
|
|
13
|
+
/**
|
|
14
|
+
* Any level (level is ignored).
|
|
15
|
+
*/
|
|
16
|
+
Any: 0,
|
|
17
|
+
/**
|
|
18
|
+
* Retail consumer trade item level, supporting GTIN-13, GTIN-12 (optionally zero-suppressed), and GTIN-8.
|
|
19
|
+
*/
|
|
20
|
+
RetailConsumer: 1,
|
|
21
|
+
/**
|
|
22
|
+
* Other than retail consumer trade item level, supporting GTIN-13, GTIN-12 (not zero-suppressed), and GTIN-14.
|
|
23
|
+
*/
|
|
24
|
+
OtherThanRetailConsumer: 2
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* GTIN validator.
|
|
28
|
+
*/
|
|
29
|
+
export class GTINValidator extends NumericIdentifierValidator {
|
|
30
|
+
/**
|
|
31
|
+
* Validation parameters for optional indicator digit.
|
|
32
|
+
*/
|
|
33
|
+
static #OPTIONAL_INDICATOR_DIGIT_VALIDATION = {
|
|
34
|
+
minimumLength: 0,
|
|
35
|
+
maximumLength: 1,
|
|
36
|
+
component: () => i18nextGS1.t("Identifier.indicatorDigit")
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Validation parameters for zero-suppressed GTIN-12.
|
|
40
|
+
*/
|
|
41
|
+
static #ZERO_SUPPRESSED_GTIN12_VALIDATION = {
|
|
42
|
+
minimumLength: 8,
|
|
43
|
+
maximumLength: 8
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Prefix type.
|
|
47
|
+
*/
|
|
48
|
+
#prefixType;
|
|
49
|
+
/**
|
|
50
|
+
* Constructor.
|
|
51
|
+
*
|
|
52
|
+
* @param gtinBaseLength
|
|
53
|
+
* GTIN base length (all except GTIN-14).
|
|
54
|
+
*/
|
|
55
|
+
constructor(gtinBaseLength) {
|
|
56
|
+
const identifierDescriptor = IdentifierDescriptors.GTIN[gtinBaseLength];
|
|
57
|
+
super(identifierDescriptor);
|
|
58
|
+
this.#prefixType = identifierDescriptor.prefixType;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
*/
|
|
63
|
+
get prefixType() {
|
|
64
|
+
return this.#prefixType;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @inheritDoc
|
|
68
|
+
*/
|
|
69
|
+
validatePrefix(partialIdentifier, positionOffset) {
|
|
70
|
+
// Delegate to prefix validator requiring exact match for prefix type.
|
|
71
|
+
PrefixValidator.validate(this.prefixType, false, false, partialIdentifier, true, true, positionOffset);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Zero suppress a GTIN-12.
|
|
75
|
+
*
|
|
76
|
+
* @param gtin12
|
|
77
|
+
* GTIN-12.
|
|
78
|
+
*
|
|
79
|
+
* @returns
|
|
80
|
+
* Zero-suppressed GTIN-12.
|
|
81
|
+
*/
|
|
82
|
+
static zeroSuppress(gtin12) {
|
|
83
|
+
GTIN12_VALIDATOR.validate(gtin12);
|
|
84
|
+
// Convert to individual digits.
|
|
85
|
+
const d = Array.from(gtin12);
|
|
86
|
+
let zeroSuppressedGTIN12;
|
|
87
|
+
// All rules require that digits in positions 1, 5, and 6 be zero.
|
|
88
|
+
if (d[0] === "0" && d[6] === "0" && d[7] === "0") {
|
|
89
|
+
if (d[10] >= "5" && d[8] === "0" && d[9] === "0" && d[5] !== "0") {
|
|
90
|
+
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}${d[10]}${d[11]}`;
|
|
91
|
+
}
|
|
92
|
+
else if (d[5] === "0" && d[8] === "0" && d[9] === "0" && d[4] !== "0") {
|
|
93
|
+
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[10]}4${d[11]}`;
|
|
94
|
+
}
|
|
95
|
+
else if (d[3] <= "2" && d[4] === "0" && d[5] === "0") {
|
|
96
|
+
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[8]}${d[9]}${d[10]}${d[3]}${d[11]}`;
|
|
97
|
+
}
|
|
98
|
+
else if (d[3] >= "3" && d[4] === "0" && d[5] === "0" && d[8] === "0") {
|
|
99
|
+
zeroSuppressedGTIN12 = `0${d[1]}${d[2]}${d[3]}${d[9]}${d[10]}3${d[11]}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (zeroSuppressedGTIN12 === undefined) {
|
|
103
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidZeroSuppressibleGTIN12"));
|
|
104
|
+
}
|
|
105
|
+
return zeroSuppressedGTIN12;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Zero expand a zero-suppressed GTIN-12.
|
|
109
|
+
*
|
|
110
|
+
* @param zeroSuppressedGTIN12
|
|
111
|
+
* Zero-suppressed GTIN-12.
|
|
112
|
+
*
|
|
113
|
+
* @returns
|
|
114
|
+
* GTIN-12.
|
|
115
|
+
*/
|
|
116
|
+
static zeroExpand(zeroSuppressedGTIN12) {
|
|
117
|
+
NUMERIC_CREATOR.validate(zeroSuppressedGTIN12, GTINValidator.#ZERO_SUPPRESSED_GTIN12_VALIDATION);
|
|
118
|
+
// Convert to individual digits.
|
|
119
|
+
const d = Array.from(zeroSuppressedGTIN12);
|
|
120
|
+
let gtin12;
|
|
121
|
+
// Zero-suppressed GTIN-12 always starts with 0.
|
|
122
|
+
if (d[0] === "0") {
|
|
123
|
+
if (d[6] >= "5" && d[5] !== "0") {
|
|
124
|
+
gtin12 = `0${d[1]}${d[2]}${d[3]}${d[4]}${d[5]}0000${d[6]}${d[7]}`;
|
|
125
|
+
}
|
|
126
|
+
else if (d[6] === "4" && d[4] !== "0") {
|
|
127
|
+
gtin12 = `0${d[1]}${d[2]}${d[3]}${d[4]}00000${d[5]}${d[7]}`;
|
|
128
|
+
}
|
|
129
|
+
else if (d[6] <= "2") {
|
|
130
|
+
gtin12 = `0${d[1]}${d[2]}${d[6]}0000${d[3]}${d[4]}${d[5]}${d[7]}`;
|
|
131
|
+
}
|
|
132
|
+
else if (d[6] === "3" && d[3] >= "3") {
|
|
133
|
+
gtin12 = `0${d[1]}${d[2]}${d[3]}00000${d[4]}${d[5]}${d[7]}`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (gtin12 === undefined) {
|
|
137
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidZeroSuppressedGTIN12"));
|
|
138
|
+
}
|
|
139
|
+
// Make sure that resulting GTIN-12 is valid.
|
|
140
|
+
GTIN12_VALIDATOR.validate(gtin12);
|
|
141
|
+
return gtin12;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
|
|
145
|
+
*
|
|
146
|
+
* @param indicatorDigit
|
|
147
|
+
* Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
|
|
148
|
+
*
|
|
149
|
+
* @param gtin
|
|
150
|
+
* GTIN.
|
|
151
|
+
*
|
|
152
|
+
* @returns
|
|
153
|
+
* GTIN-14.
|
|
154
|
+
*/
|
|
155
|
+
static convertToGTIN14(indicatorDigit, gtin) {
|
|
156
|
+
GTINValidator.validateAny(gtin);
|
|
157
|
+
NUMERIC_CREATOR.validate(indicatorDigit, GTINValidator.#OPTIONAL_INDICATOR_DIGIT_VALIDATION);
|
|
158
|
+
// Check digit doesn't change by prepending zeros.
|
|
159
|
+
let gtin14 = gtin.padStart(GTINLengths.GTIN14, "0");
|
|
160
|
+
// If indicator digit provided and is different, recalculate the check digit.
|
|
161
|
+
if (indicatorDigit.length !== 0 && indicatorDigit !== gtin14.charAt(0)) {
|
|
162
|
+
const partialGTIN14 = indicatorDigit + gtin14.substring(1, GTINLengths.GTIN14 - 1);
|
|
163
|
+
gtin14 = partialGTIN14 + checkDigit(partialGTIN14);
|
|
164
|
+
}
|
|
165
|
+
return gtin14;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Normalize a GTIN of any length.
|
|
169
|
+
* - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
|
|
170
|
+
* - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
|
|
171
|
+
* - A GTIN-14 that starts with one zero is normalized to GTIN-13.
|
|
172
|
+
* - Otherwise, the GTIN is unchanged.
|
|
173
|
+
*
|
|
174
|
+
* @param gtin
|
|
175
|
+
* GTIN.
|
|
176
|
+
*
|
|
177
|
+
* @returns
|
|
178
|
+
* Normalized GTIN.
|
|
179
|
+
*/
|
|
180
|
+
static normalize(gtin) {
|
|
181
|
+
const gtinLength = gtin.length;
|
|
182
|
+
let normalizedGTIN;
|
|
183
|
+
switch (gtinLength) {
|
|
184
|
+
case GTINLengths.GTIN13:
|
|
185
|
+
if (!gtin.startsWith("0")) {
|
|
186
|
+
// GTIN is GTIN-13.
|
|
187
|
+
normalizedGTIN = gtin;
|
|
188
|
+
}
|
|
189
|
+
else if (!gtin.startsWith("00000")) {
|
|
190
|
+
// GTIN is GTIN-12.
|
|
191
|
+
normalizedGTIN = gtin.substring(1);
|
|
192
|
+
}
|
|
193
|
+
else if (!gtin.startsWith("000000")) {
|
|
194
|
+
// GTIN is GTIN-8.
|
|
195
|
+
normalizedGTIN = gtin.substring(5);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidZeroSuppressedGTIN12AsGTIN13"));
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
case GTINLengths.GTIN12:
|
|
202
|
+
// GTIN is GTIN-12.
|
|
203
|
+
normalizedGTIN = gtin;
|
|
204
|
+
break;
|
|
205
|
+
case GTINLengths.GTIN8:
|
|
206
|
+
if (!gtin.startsWith("0")) {
|
|
207
|
+
// GTIN is GTIN-8.
|
|
208
|
+
normalizedGTIN = gtin;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
// GTIN is zero-suppressed GTIN-12.
|
|
212
|
+
normalizedGTIN = GTINValidator.zeroExpand(gtin);
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
case GTINLengths.GTIN14:
|
|
216
|
+
if (!gtin.startsWith("0")) {
|
|
217
|
+
// GTIN is GTIN-14.
|
|
218
|
+
normalizedGTIN = gtin;
|
|
219
|
+
}
|
|
220
|
+
else if (!gtin.startsWith("00")) {
|
|
221
|
+
// GTIN is GTIN-13.
|
|
222
|
+
normalizedGTIN = gtin.substring(1);
|
|
223
|
+
}
|
|
224
|
+
else if (!gtin.startsWith("000000")) {
|
|
225
|
+
// GTIN is GTIN-12.
|
|
226
|
+
normalizedGTIN = gtin.substring(2);
|
|
227
|
+
}
|
|
228
|
+
else if (!gtin.startsWith("0000000")) {
|
|
229
|
+
// GTIN is GTIN-8.
|
|
230
|
+
normalizedGTIN = gtin.substring(6);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidZeroSuppressedGTIN12AsGTIN14"));
|
|
234
|
+
}
|
|
235
|
+
break;
|
|
236
|
+
default:
|
|
237
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidGTINLength"));
|
|
238
|
+
}
|
|
239
|
+
// Validation applies to the normalized GTIN.
|
|
240
|
+
GTINValidator.validateAny(normalizedGTIN);
|
|
241
|
+
return normalizedGTIN;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Validate any GTIN, optionally against a level.
|
|
245
|
+
*
|
|
246
|
+
* @param gtin
|
|
247
|
+
* GTIN.
|
|
248
|
+
*
|
|
249
|
+
* @param gtinLevel
|
|
250
|
+
* Level at which GTIN is to be validated.
|
|
251
|
+
*/
|
|
252
|
+
static validateAny(gtin, gtinLevel = GTINLevels.Any) {
|
|
253
|
+
// Assume length-validated GTIN is the GTIN (true for all except zero-suppressed GTIN-12).
|
|
254
|
+
let lengthValidatedGTIN = gtin;
|
|
255
|
+
let gtinLevelRestriction;
|
|
256
|
+
switch (gtin.length) {
|
|
257
|
+
case GTINLengths.GTIN13:
|
|
258
|
+
if (gtin.startsWith("0")) {
|
|
259
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidGTIN13AtRetail"));
|
|
260
|
+
}
|
|
261
|
+
// Validate prefix requiring exact match for prefix type.
|
|
262
|
+
PrefixValidator.validate(PrefixTypes.GS1CompanyPrefix, false, false, gtin, true, true);
|
|
263
|
+
gtinLevelRestriction = GTINLevels.Any;
|
|
264
|
+
break;
|
|
265
|
+
case GTINLengths.GTIN12:
|
|
266
|
+
// Validate prefix requiring exact match for prefix type.
|
|
267
|
+
PrefixValidator.validate(PrefixTypes.UPCCompanyPrefix, false, false, gtin, true, true);
|
|
268
|
+
gtinLevelRestriction = GTINLevels.Any;
|
|
269
|
+
break;
|
|
270
|
+
case GTINLengths.GTIN8:
|
|
271
|
+
// Zero-suppressed GTIN-12 always starts with 0.
|
|
272
|
+
if (!gtin.startsWith("0")) {
|
|
273
|
+
// Validate prefix requiring exact match for prefix type.
|
|
274
|
+
PrefixValidator.validate(PrefixTypes.GS18Prefix, false, false, gtin, true, true);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
lengthValidatedGTIN = GTINValidator.zeroExpand(gtin);
|
|
278
|
+
}
|
|
279
|
+
gtinLevelRestriction = GTINLevels.RetailConsumer;
|
|
280
|
+
break;
|
|
281
|
+
case GTINLengths.GTIN14:
|
|
282
|
+
// Validate prefix supporting any prefix type.
|
|
283
|
+
PrefixValidator.validate(PrefixTypes.GS1CompanyPrefix, true, true, gtin.substring(1), true, true);
|
|
284
|
+
gtinLevelRestriction = GTINLevels.OtherThanRetailConsumer;
|
|
285
|
+
break;
|
|
286
|
+
default:
|
|
287
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidGTINLength"));
|
|
288
|
+
}
|
|
289
|
+
// Validating the check digit will also validate the characters.
|
|
290
|
+
if (!hasValidCheckDigit(lengthValidatedGTIN)) {
|
|
291
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidCheckDigit"));
|
|
292
|
+
}
|
|
293
|
+
// Validate against level if required.
|
|
294
|
+
if (gtinLevel !== GTINLevels.Any && gtinLevelRestriction !== GTINLevels.Any && gtinLevelRestriction !== gtinLevel) {
|
|
295
|
+
throw new RangeError(i18nextGS1.t(gtinLevel === GTINLevels.RetailConsumer ? "Identifier.invalidGTINAtRetail" : "Identifier.invalidGTINAtOtherThanRetail"));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Validate a GTIN-14.
|
|
300
|
+
*
|
|
301
|
+
* @param gtin14
|
|
302
|
+
* GTIN-14.
|
|
303
|
+
*/
|
|
304
|
+
static validateGTIN14(gtin14) {
|
|
305
|
+
if (gtin14.length !== GTINLengths.GTIN14) {
|
|
306
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidGTIN14Length"));
|
|
307
|
+
}
|
|
308
|
+
GTINValidator.validateAny(gtin14);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Parse a Restricted Circulation Number (RCN) using a variable measure trade item format. The format is a 12- or
|
|
312
|
+
* 13-character string (for RCN-12 or RCN-13 respectively), containing the following:
|
|
313
|
+
*
|
|
314
|
+
* - '2' - The first character of the RCN.
|
|
315
|
+
* - '0'-'9' - The second character of the RCN (RCN-13 only).
|
|
316
|
+
* - 'I' - One or more, in sequence, for the item reference.
|
|
317
|
+
* - 'P' - One or more, in sequence, for the price or weight.
|
|
318
|
+
* - 'V' - Zero or one, for the price or weight check digit.
|
|
319
|
+
* - 'C' - The check digit of the entire RCN.
|
|
320
|
+
*
|
|
321
|
+
* The 'I', 'P', and 'V' formats may be in any order.
|
|
322
|
+
*
|
|
323
|
+
* Some examples:
|
|
324
|
+
*
|
|
325
|
+
* - 2IIIIIVPPPPC - RCN-12 with a five-digit item reference, a price or weight check digit, and a four-digit price
|
|
326
|
+
* or weight.
|
|
327
|
+
* - 23IIIIVPPPPPC - RCN-13 with a four-digit item reference, a price or weight check digit, and a five-digit price
|
|
328
|
+
* or weight.
|
|
329
|
+
* - 2IIIIIIPPPPC - RCN-12 with a six-digit item reference and a four-digit price or eight.
|
|
330
|
+
* - 29IIIIIPPPPPC - RCN-13 with a five-digit item reference and a five-digit price or weight.
|
|
331
|
+
*
|
|
332
|
+
* @param format
|
|
333
|
+
* Format.
|
|
334
|
+
*
|
|
335
|
+
* @param rcn
|
|
336
|
+
* RCN.
|
|
337
|
+
*
|
|
338
|
+
* @returns
|
|
339
|
+
* RCN reference.
|
|
340
|
+
*/
|
|
341
|
+
static parseVariableMeasureRCN(format, rcn) {
|
|
342
|
+
const formatLength = format.length;
|
|
343
|
+
if (rcn.length !== formatLength) {
|
|
344
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidRCNLength"));
|
|
345
|
+
}
|
|
346
|
+
let validFormat = formatLength === 12 || formatLength === 13;
|
|
347
|
+
let validRCNPrefix = true;
|
|
348
|
+
let buildingItemReference = false;
|
|
349
|
+
let itemReference = "";
|
|
350
|
+
let buildingPriceOrWeight = false;
|
|
351
|
+
let priceOrWeight = "";
|
|
352
|
+
let priceOrWeightCheckDigit = "";
|
|
353
|
+
for (let index = 0; validFormat && index < formatLength; index++) {
|
|
354
|
+
const formatChar = format.charAt(index);
|
|
355
|
+
const rcnChar = rcn.charAt(index);
|
|
356
|
+
if (index === 0) {
|
|
357
|
+
validFormat = formatChar === "2";
|
|
358
|
+
validRCNPrefix = rcnChar === "2";
|
|
359
|
+
}
|
|
360
|
+
else if (formatLength === 13 && index === 1) {
|
|
361
|
+
validFormat = NUMERIC_CREATOR.characterIndex(formatChar) !== undefined;
|
|
362
|
+
validRCNPrefix = rcnChar === formatChar;
|
|
363
|
+
}
|
|
364
|
+
else if (index === formatLength - 1) {
|
|
365
|
+
validFormat = formatChar === "C";
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
switch (formatChar) {
|
|
369
|
+
case "I":
|
|
370
|
+
if (!buildingItemReference) {
|
|
371
|
+
// Item reference can't appear more than once.
|
|
372
|
+
validFormat = itemReference === "";
|
|
373
|
+
buildingItemReference = true;
|
|
374
|
+
buildingPriceOrWeight = false;
|
|
375
|
+
}
|
|
376
|
+
itemReference += rcnChar;
|
|
377
|
+
break;
|
|
378
|
+
case "P":
|
|
379
|
+
if (!buildingPriceOrWeight) {
|
|
380
|
+
// Price or weight can't appear more than once.
|
|
381
|
+
validFormat = priceOrWeight === "";
|
|
382
|
+
buildingPriceOrWeight = true;
|
|
383
|
+
buildingItemReference = false;
|
|
384
|
+
}
|
|
385
|
+
priceOrWeight += rcnChar;
|
|
386
|
+
break;
|
|
387
|
+
case "V":
|
|
388
|
+
// Price or weight check digit can't appear more than once.
|
|
389
|
+
validFormat = priceOrWeightCheckDigit === "";
|
|
390
|
+
buildingItemReference = false;
|
|
391
|
+
buildingPriceOrWeight = false;
|
|
392
|
+
priceOrWeightCheckDigit = rcnChar;
|
|
393
|
+
break;
|
|
394
|
+
default:
|
|
395
|
+
validFormat = false;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
validFormat &&= itemReference !== "" && priceOrWeight !== "";
|
|
401
|
+
if (!validFormat) {
|
|
402
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasureRCNFormat"));
|
|
403
|
+
}
|
|
404
|
+
if (!validRCNPrefix) {
|
|
405
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasureRCNPrefix"));
|
|
406
|
+
}
|
|
407
|
+
if (priceOrWeightCheckDigit !== "" && !isValidPriceOrWeightCheckDigit(priceOrWeight, priceOrWeightCheckDigit)) {
|
|
408
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasurePriceOrWeight"));
|
|
409
|
+
}
|
|
410
|
+
if (!hasValidCheckDigit(rcn)) {
|
|
411
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidCheckDigit"));
|
|
412
|
+
}
|
|
413
|
+
return {
|
|
414
|
+
itemReference: Number(itemReference),
|
|
415
|
+
priceOrWeight: Number(priceOrWeight)
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* GTIN-13 validator.
|
|
421
|
+
*/
|
|
422
|
+
// Defined here because of circular reference.
|
|
423
|
+
export const GTIN13_VALIDATOR = new GTINValidator(GTINLengths.GTIN13);
|
|
424
|
+
/**
|
|
425
|
+
* GTIN-12 validator.
|
|
426
|
+
*/
|
|
427
|
+
// Defined here because of circular reference.
|
|
428
|
+
export const GTIN12_VALIDATOR = new GTINValidator(GTINLengths.GTIN12);
|
|
429
|
+
/**
|
|
430
|
+
* GTIN-8 validator.
|
|
431
|
+
*/
|
|
432
|
+
// Defined here because of circular reference.
|
|
433
|
+
export const GTIN8_VALIDATOR = new GTINValidator(GTINLengths.GTIN8);
|
|
434
|
+
/**
|
|
435
|
+
* GTIN validators indexed by prefix type.
|
|
436
|
+
*/
|
|
437
|
+
// Defined here because of circular reference.
|
|
438
|
+
export const GTIN_VALIDATORS = {
|
|
439
|
+
[GTINLengths.GTIN13]: GTIN13_VALIDATOR,
|
|
440
|
+
[GTINLengths.GTIN12]: GTIN12_VALIDATOR,
|
|
441
|
+
[GTINLengths.GTIN8]: GTIN8_VALIDATOR
|
|
442
|
+
};
|
|
443
|
+
//# sourceMappingURL=gtin-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gtin-validator.js","sourceRoot":"","sources":["../src/gtin-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,eAAe,EAAE,MAAM,uBAAuB,CAAC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CAAC;;AAGL;;GAEG;AACH,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAEtE;;GAEG;AACH,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAEtE;;GAEG;AACH,8CAA8C;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAEpE;;GAEG;AACH,8CAA8C;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAoD;IAC5E,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,gBAAgB;IACtC,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,gBAAgB;IACtC,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,eAAe;CACvC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { IdentifierType } from "./identifier-type.js";
|
|
2
|
+
import type { IdentifierValidation, IdentifierValidator } from "./identifier-validator.js";
|
|
3
|
+
import type { PrefixProvider } from "./prefix-provider.js";
|
|
4
|
+
/**
|
|
5
|
+
* Identifier creator. Creates an identifier based on its definition in section 3 of the {@link
|
|
6
|
+
* https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}.
|
|
7
|
+
*
|
|
8
|
+
* Keys are created based on a prefix defined in a prefix provider to which the identifier creator is bound.
|
|
9
|
+
*
|
|
10
|
+
* @template TIdentifierType
|
|
11
|
+
* Identifier type type.
|
|
12
|
+
*
|
|
13
|
+
* @template TIdentifierValidation
|
|
14
|
+
* Identifier validation type.
|
|
15
|
+
*/
|
|
16
|
+
export interface IdentifierCreator<TIdentifierType extends IdentifierType = IdentifierType, TIdentifierValidation extends IdentifierValidation = IdentifierValidation> extends IdentifierValidator<TIdentifierType, TIdentifierValidation> {
|
|
17
|
+
/**
|
|
18
|
+
* Get the prefix provider to which this identifier creator is bound.
|
|
19
|
+
*/
|
|
20
|
+
get prefixProvider(): PrefixProvider;
|
|
21
|
+
/**
|
|
22
|
+
* Get the prefix, equivalent to calling {@linkcode PrefixProvider.prefix | prefixProvider.prefix} for a GTIN or
|
|
23
|
+
* {@linkcode PrefixProvider.gs1CompanyPrefix | prefixProvider.gs1CompanyPrefix} for all other identifier types.
|
|
24
|
+
*/
|
|
25
|
+
get prefix(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Get the reference length.
|
|
28
|
+
*/
|
|
29
|
+
get referenceLength(): number;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=identifier-creator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifier-creator.d.ts","sourceRoot":"","sources":["../src/identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAiB,CAAC,eAAe,SAAS,cAAc,GAAG,cAAc,EAAE,qBAAqB,SAAS,oBAAoB,GAAG,oBAAoB,CAAE,SAAQ,mBAAmB,CAAC,eAAe,EAAE,qBAAqB,CAAC;IACtO;;OAEG;IACH,IAAI,cAAc,IAAI,cAAc,CAAC;IAErC;;;OAGG;IACH,IAAI,MAAM,IAAI,MAAM,CAAC;IAErB;;OAEG;IACH,IAAI,eAAe,IAAI,MAAM,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifier-creator.js","sourceRoot":"","sources":["../src/identifier-creator.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { GTINCreator } from "./gtin-creator.js";
|
|
2
|
+
import type { IdentifierCreator } from "./identifier-creator.js";
|
|
3
|
+
import { type IdentifierTypeExtension } from "./identifier-extension.js";
|
|
4
|
+
import type { IdentifierType } from "./identifier-type.js";
|
|
5
|
+
import type { NonGTINNumericIdentifierCreator } from "./non-gtin-numeric-identifier-creator.js";
|
|
6
|
+
import type { NonNumericIdentifierCreator } from "./non-numeric-identifier-creator.js";
|
|
7
|
+
import type { NonSerializableNumericIdentifierCreator } from "./non-serializable-numeric-identifier-creator.js";
|
|
8
|
+
import type { NumericIdentifierCreator } from "./numeric-identifier-creator.js";
|
|
9
|
+
import type { SerializableNumericIdentifierCreator } from "./serializable-numeric-identifier-creator.js";
|
|
10
|
+
/**
|
|
11
|
+
* Identifier creator type based on identifier type type.
|
|
12
|
+
*
|
|
13
|
+
* @template TIdentifierType
|
|
14
|
+
* Identifier type type.
|
|
15
|
+
*/
|
|
16
|
+
export type IdentifierTypeCreator<TIdentifierType extends IdentifierType> = IdentifierTypeExtension<TIdentifierType, IdentifierCreator, NumericIdentifierCreator, GTINCreator, NonGTINNumericIdentifierCreator, NonSerializableNumericIdentifierCreator, SerializableNumericIdentifierCreator, NonNumericIdentifierCreator>;
|
|
17
|
+
/**
|
|
18
|
+
* Identifier creators entry type based on identifier type type.
|
|
19
|
+
*
|
|
20
|
+
* @template TIdentifierType
|
|
21
|
+
* Identifier type type.
|
|
22
|
+
*/
|
|
23
|
+
export type IdentifierCreatorsEntry<TIdentifierType extends IdentifierType> = IdentifierTypeCreator<TIdentifierType>;
|
|
24
|
+
/**
|
|
25
|
+
* Identifier creators record type.
|
|
26
|
+
*/
|
|
27
|
+
export type IdentifierCreatorsRecord = {
|
|
28
|
+
[TIdentifierType in IdentifierType]: IdentifierCreatorsEntry<TIdentifierType>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Determine if identifier creator is a numeric identifier creator.
|
|
32
|
+
*
|
|
33
|
+
* @param identifierCreator
|
|
34
|
+
* Identifier creator.
|
|
35
|
+
*
|
|
36
|
+
* @returns
|
|
37
|
+
* True if identifier creator is a numeric identifier creator.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NumericIdentifierCreator;
|
|
40
|
+
/**
|
|
41
|
+
* Determine if identifier creator is a GTIN creator.
|
|
42
|
+
*
|
|
43
|
+
* @param identifierCreator
|
|
44
|
+
* Identifier creator.
|
|
45
|
+
*
|
|
46
|
+
* @returns
|
|
47
|
+
* True if identifier creator is a GTIN creator.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isGTINCreator(identifierCreator: IdentifierCreator): identifierCreator is GTINCreator;
|
|
50
|
+
/**
|
|
51
|
+
* Determine if identifier creator is a non-GTIN numeric identifier creator.
|
|
52
|
+
*
|
|
53
|
+
* @param identifierCreator
|
|
54
|
+
* Identifier creator.
|
|
55
|
+
*
|
|
56
|
+
* @returns
|
|
57
|
+
* True if identifier creator is a non-GTIN numeric identifier creator.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isNonGTINNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NonGTINNumericIdentifierCreator;
|
|
60
|
+
/**
|
|
61
|
+
* Determine if identifier creator is a non-serializable numeric identifier creator.
|
|
62
|
+
*
|
|
63
|
+
* @param identifierCreator
|
|
64
|
+
* Identifier creator.
|
|
65
|
+
*
|
|
66
|
+
* @returns
|
|
67
|
+
* True if identifier creator is a non-serializable numeric identifier creator.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isNonSerializableNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NonSerializableNumericIdentifierCreator;
|
|
70
|
+
/**
|
|
71
|
+
* Determine if identifier creator is a serializable numeric identifier creator.
|
|
72
|
+
*
|
|
73
|
+
* @param identifierCreator
|
|
74
|
+
* Identifier creator.
|
|
75
|
+
*
|
|
76
|
+
* @returns
|
|
77
|
+
* True if identifier creator is a serializable numeric identifier creator.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isSerializableNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is SerializableNumericIdentifierCreator;
|
|
80
|
+
/**
|
|
81
|
+
* Determine if identifier creator is a non-numeric identifier creator.
|
|
82
|
+
*
|
|
83
|
+
* @param identifierCreator
|
|
84
|
+
* Identifier creator.
|
|
85
|
+
*
|
|
86
|
+
* @returns
|
|
87
|
+
* True if identifier creator is a non-numeric identifier creator.
|
|
88
|
+
*/
|
|
89
|
+
export declare function isNonNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NonNumericIdentifierCreator;
|
|
90
|
+
//# sourceMappingURL=identifier-creators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifier-creators.d.ts","sourceRoot":"","sources":["../src/identifier-creators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EACH,KAAK,uBAAuB,EAO/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAChG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AACvF,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,kDAAkD,CAAC;AAChH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,8CAA8C,CAAC;AAEzG;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,CAAC,eAAe,SAAS,cAAc,IAAI,uBAAuB,CAC/F,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,WAAW,EACX,+BAA+B,EAC/B,uCAAuC,EACvC,oCAAoC,EACpC,2BAA2B,CAC9B,CAAC;AA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