@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
|
@@ -1,137 +1,160 @@
|
|
|
1
1
|
import { CharacterSetCreator, Exclusions, NUMERIC_CREATOR } from "@aidc-toolkit/utility";
|
|
2
|
-
import {
|
|
2
|
+
import { MixinAbstractIdentifierCreator } from "./abstract-identifier-creator.js";
|
|
3
3
|
import { checkDigit, checkDigitSum } from "./check.js";
|
|
4
|
-
import { LeaderTypes } from "./
|
|
4
|
+
import { LeaderTypes } from "./leader-type.js";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Mixin implementation of {@linkcode NumericIdentifierCreator} with an appropriate numeric identifier validator base.
|
|
7
7
|
*
|
|
8
|
-
* @template
|
|
9
|
-
*
|
|
8
|
+
* @template TConstructorArguments
|
|
9
|
+
* Constructor arguments types.
|
|
10
|
+
*
|
|
11
|
+
* @template TNumericIdentifierType
|
|
12
|
+
* Numeric identifier type type.
|
|
13
|
+
*
|
|
14
|
+
* @template TNumericIdentifierValidatorConstructor
|
|
15
|
+
* Numeric identifier validator constructor type.
|
|
16
|
+
*
|
|
17
|
+
* @param NumericIdentifierValidatorBase
|
|
18
|
+
* Numeric identifier validator base.
|
|
19
|
+
*
|
|
20
|
+
* @returns
|
|
21
|
+
* Numeric identifier creator class.
|
|
10
22
|
*/
|
|
11
|
-
export
|
|
12
|
-
/**
|
|
13
|
-
* Capacity.
|
|
14
|
-
*/
|
|
15
|
-
_capacity;
|
|
16
|
-
/**
|
|
17
|
-
* Tweak for sparse creation.
|
|
18
|
-
*/
|
|
19
|
-
_tweak = 0n;
|
|
20
|
-
/**
|
|
21
|
-
* Initialize the prefix provider. This method is in lieu of a constructor due to the mixin architecture.
|
|
22
|
-
*
|
|
23
|
-
* @param prefixProvider
|
|
24
|
-
* Prefix provider.
|
|
25
|
-
*
|
|
26
|
-
* @param prefix
|
|
27
|
-
* Prefix within prefix manager to use to calculate reference length.
|
|
28
|
-
*/
|
|
29
|
-
init(prefixProvider, prefix) {
|
|
30
|
-
super.init(prefixProvider, prefix, 1);
|
|
31
|
-
// Capacity is always in number range.
|
|
32
|
-
this._capacity = Number(CharacterSetCreator.powerOf10(this.referenceLength));
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @inheritDoc
|
|
36
|
-
*/
|
|
37
|
-
get capacity() {
|
|
38
|
-
return this._capacity;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* @inheritDoc
|
|
42
|
-
*/
|
|
43
|
-
get tweak() {
|
|
44
|
-
return this._tweak;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* @inheritDoc
|
|
48
|
-
*/
|
|
49
|
-
set tweak(value) {
|
|
50
|
-
this._tweak = value;
|
|
51
|
-
}
|
|
23
|
+
export function MixinAbstractNumericIdentifierCreator(NumericIdentifierValidatorBase) {
|
|
52
24
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @param reference
|
|
56
|
-
* Identifier reference.
|
|
57
|
-
*
|
|
58
|
-
* @returns
|
|
59
|
-
* Identifier.
|
|
25
|
+
* Abstract numeric identifier creator. Implements common functionality for a numeric identifier creator, mixed in
|
|
26
|
+
* with a matching numeric identifier validator.
|
|
60
27
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
* If the extension weight is zero, this value is applied to the calculation of the check digit.
|
|
87
|
-
*
|
|
88
|
-
* @param partialCheckDigitSum
|
|
89
|
-
* Partial check digit sum for the partial identifier.
|
|
90
|
-
*
|
|
91
|
-
* @yields
|
|
92
|
-
* Identifier.
|
|
93
|
-
*/
|
|
94
|
-
static *createAllPartial(partialIdentifier, remainingReferenceLength, extensionWeight, weight, partialCheckDigitSum) {
|
|
95
|
-
if (remainingReferenceLength === 0) {
|
|
96
|
-
// Finalize check digit calculation and append.
|
|
97
|
-
yield partialIdentifier + NUMERIC_CREATOR.character(9 - (partialCheckDigitSum + 9) % 10);
|
|
28
|
+
class AbstractNumericIdentifierCreator extends MixinAbstractIdentifierCreator(NumericIdentifierValidatorBase) {
|
|
29
|
+
/**
|
|
30
|
+
* Capacity.
|
|
31
|
+
*/
|
|
32
|
+
#capacity;
|
|
33
|
+
/**
|
|
34
|
+
* Tweak for sparse creation.
|
|
35
|
+
*/
|
|
36
|
+
#tweak = 0n;
|
|
37
|
+
/**
|
|
38
|
+
* Constructor.
|
|
39
|
+
*
|
|
40
|
+
* @param prefixProvider
|
|
41
|
+
* Prefix provider.
|
|
42
|
+
*
|
|
43
|
+
* @param prefix
|
|
44
|
+
* Prefix within prefix provider to use to calculate reference length.
|
|
45
|
+
*
|
|
46
|
+
* @param args
|
|
47
|
+
* Originating constructor arguments.
|
|
48
|
+
*/
|
|
49
|
+
constructor(prefixProvider, prefix, ...args) {
|
|
50
|
+
super(prefixProvider, prefix, 1, ...args);
|
|
51
|
+
// Capacity is always in number range.
|
|
52
|
+
this.#capacity = Number(CharacterSetCreator.powerOf10(this.referenceLength));
|
|
98
53
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
54
|
+
/**
|
|
55
|
+
* @inheritDoc
|
|
56
|
+
*/
|
|
57
|
+
get capacity() {
|
|
58
|
+
return this.#capacity;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
*/
|
|
63
|
+
get tweak() {
|
|
64
|
+
return this.#tweak;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @inheritDoc
|
|
68
|
+
*/
|
|
69
|
+
set tweak(value) {
|
|
70
|
+
this.#tweak = value;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Build an identifier from a reference by merging it with the prefix and adding the check digit.
|
|
74
|
+
*
|
|
75
|
+
* @param reference
|
|
76
|
+
* Identifier reference.
|
|
77
|
+
*
|
|
78
|
+
* @returns
|
|
79
|
+
* Identifier.
|
|
80
|
+
*/
|
|
81
|
+
#buildIdentifier(reference) {
|
|
82
|
+
const partialIdentifier = this.leaderType === LeaderTypes.ExtensionDigit ? reference.substring(0, 1) + this.prefix + reference.substring(1) : this.prefix + reference;
|
|
83
|
+
return partialIdentifier + checkDigit(partialIdentifier);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @inheritDoc
|
|
87
|
+
*/
|
|
88
|
+
create(valueOrValues, sparse = false) {
|
|
89
|
+
return NUMERIC_CREATOR.create(this.referenceLength, valueOrValues, Exclusions.None, sparse ? this.tweak : undefined, reference => this.#buildIdentifier(reference));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create all identifiers from a partial identifier. Call is recursive until remaining reference
|
|
93
|
+
* length is 0.
|
|
94
|
+
*
|
|
95
|
+
* @param partialIdentifier
|
|
96
|
+
* Partial identifier. Initial value is `this.prefix`.
|
|
97
|
+
*
|
|
98
|
+
* @param remainingReferenceLength
|
|
99
|
+
* Remaining reference length. Initial value is `this.referenceLength`.
|
|
100
|
+
*
|
|
101
|
+
* @param extensionWeight
|
|
102
|
+
* If this value is not zero, the identifier has an extension digit, this call is setting it, and this value is
|
|
103
|
+
* applied to the calculation of the check digit.
|
|
104
|
+
*
|
|
105
|
+
* @param weight
|
|
106
|
+
* If the extension weight is zero, this value is applied to the calculation of the check digit.
|
|
107
|
+
*
|
|
108
|
+
* @param partialCheckDigitSum
|
|
109
|
+
* Partial check digit sum for the partial identifier.
|
|
110
|
+
*
|
|
111
|
+
* @yields
|
|
112
|
+
* Identifier.
|
|
113
|
+
*/
|
|
114
|
+
static *createAllPartial(partialIdentifier, remainingReferenceLength, extensionWeight, weight, partialCheckDigitSum) {
|
|
115
|
+
if (remainingReferenceLength === 0) {
|
|
116
|
+
// Finalize check digit calculation and append.
|
|
117
|
+
yield partialIdentifier + NUMERIC_CREATOR.character(9 - (partialCheckDigitSum + 9) % 10);
|
|
108
118
|
}
|
|
109
119
|
else {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
const nextRemainingReferenceLength = remainingReferenceLength - 1;
|
|
121
|
+
let nextPartialCheckDigitSum = partialCheckDigitSum;
|
|
122
|
+
if (extensionWeight !== 0) {
|
|
123
|
+
// Apply every digit to the extension digit.
|
|
124
|
+
for (const c of NUMERIC_CREATOR.characterSet) {
|
|
125
|
+
yield* AbstractNumericIdentifierCreator.createAllPartial(c + partialIdentifier, nextRemainingReferenceLength, 0, weight, nextPartialCheckDigitSum);
|
|
126
|
+
nextPartialCheckDigitSum += extensionWeight;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const nextWeight = 4 - weight;
|
|
131
|
+
// Apply every digit to the current character in the identifier.
|
|
132
|
+
for (const c of NUMERIC_CREATOR.characterSet) {
|
|
133
|
+
yield* AbstractNumericIdentifierCreator.createAllPartial(partialIdentifier + c, nextRemainingReferenceLength, 0, nextWeight, nextPartialCheckDigitSum);
|
|
134
|
+
nextPartialCheckDigitSum += weight;
|
|
135
|
+
}
|
|
115
136
|
}
|
|
116
137
|
}
|
|
117
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* @inheritDoc
|
|
141
|
+
*/
|
|
142
|
+
createAll() {
|
|
143
|
+
const hasExtensionDigit = this.leaderType === LeaderTypes.ExtensionDigit;
|
|
144
|
+
const prefix = this.prefix;
|
|
145
|
+
const length = this.length;
|
|
146
|
+
const referenceLength = this.referenceLength;
|
|
147
|
+
// Start weight is for reference excluding extension digit, which has its weight calculated separately.
|
|
148
|
+
const startWeight = 3 - 2 * ((referenceLength + 1 - Number(hasExtensionDigit)) % 2);
|
|
149
|
+
// Returning separate Iterable object makes iteration repeatable.
|
|
150
|
+
return {
|
|
151
|
+
[Symbol.iterator]() {
|
|
152
|
+
return AbstractNumericIdentifierCreator.createAllPartial(prefix, referenceLength, hasExtensionDigit ? 3 - 2 * length % 2 : 0, startWeight, checkDigitSum(startWeight === 3, prefix));
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
118
156
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
*/
|
|
122
|
-
createAll() {
|
|
123
|
-
const hasExtensionDigit = this.leaderType === LeaderTypes.ExtensionDigit;
|
|
124
|
-
const prefix = this.prefix;
|
|
125
|
-
const length = this.length;
|
|
126
|
-
const referenceLength = this.referenceLength;
|
|
127
|
-
// Start weight is for reference excluding extension digit, which has its weight calculated separately.
|
|
128
|
-
const startWeight = 3 - 2 * ((referenceLength + 1 - Number(hasExtensionDigit)) % 2);
|
|
129
|
-
// Returning separate Iterable object makes iteration repeatable.
|
|
130
|
-
return {
|
|
131
|
-
[Symbol.iterator]() {
|
|
132
|
-
return AbstractNumericIdentifierCreator.createAllPartial(prefix, referenceLength, hasExtensionDigit ? 3 - 2 * length % 2 : 0, startWeight, checkDigitSum(startWeight === 3, prefix));
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Base class was upcast to type with statically known members for mixin, downcast result.
|
|
158
|
+
return AbstractNumericIdentifierCreator;
|
|
136
159
|
}
|
|
137
160
|
//# sourceMappingURL=abstract-numeric-identifier-creator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-numeric-identifier-creator.js","sourceRoot":"","sources":["../src/abstract-numeric-identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EACnB,UAAU,EACV,eAAe,EAGlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"abstract-numeric-identifier-creator.js","sourceRoot":"","sources":["../src/abstract-numeric-identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EACnB,UAAU,EACV,eAAe,EAGlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAIH,8BAA8B,EACjC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA2B/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,qCAAqC,CAQnD,8BAAsE;IAKpE;;;OAGG;IACH,MAAe,gCAAiC,SAAS,8BAA8B,CAAC,8BAA8B,CAKpH;QACE;;WAEG;QACM,SAAS,CAAS;QAE3B;;WAEG;QACH,MAAM,GAAG,EAAE,CAAC;QAEZ;;;;;;;;;;;WAWG;QACH,YAAY,cAA8B,EAAE,MAAc,EAAE,GAAG,IAA2B;YACtF,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;YAE1C,sCAAsC;YACtC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;QACjF,CAAC;QAED;;WAEG;QACH,IAAI,QAAQ;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AAO;gBACH,CAAC,MAAM,CAAC,QAAQ,CAAC;oBACb,OAAO,gCAAgC,CAAC,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,WAAW,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;gBACzL,CAAC;aACJ,CAAC;QACN,CAAC;KACJ;IAED,kKAAkK;IAClK,OAAO,gCAMN,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type CharacterSetCreator } from "@aidc-toolkit/utility";
|
|
2
|
+
import { type ContentCharacterSet } from "./content-character-set.js";
|
|
3
|
+
export declare const CONTENT_CHARACTER_SET_CREATORS: Record<ContentCharacterSet, CharacterSetCreator>;
|
|
4
|
+
//# sourceMappingURL=content-character-set-creators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-character-set-creators.d.ts","sourceRoot":"","sources":["../src/content-character-set-creators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAmB,MAAM,uBAAuB,CAAC;AAElF,OAAO,EAAE,KAAK,mBAAmB,EAAwB,MAAM,4BAA4B,CAAC;AAE5F,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,mBAAmB,EAAE,mBAAmB,CAI3F,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NUMERIC_CREATOR } from "@aidc-toolkit/utility";
|
|
2
|
+
import { AI39_CREATOR, AI82_CREATOR } from "./character-set.js";
|
|
3
|
+
import { ContentCharacterSets } from "./content-character-set.js";
|
|
4
|
+
export const CONTENT_CHARACTER_SET_CREATORS = {
|
|
5
|
+
[ContentCharacterSets.Numeric]: NUMERIC_CREATOR,
|
|
6
|
+
[ContentCharacterSets.AI82]: AI82_CREATOR,
|
|
7
|
+
[ContentCharacterSets.AI39]: AI39_CREATOR
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=content-character-set-creators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-character-set-creators.js","sourceRoot":"","sources":["../src/content-character-set-creators.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAA4B,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAE5F,MAAM,CAAC,MAAM,8BAA8B,GAAqD;IAC5F,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,eAAe;IAC/C,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,YAAY;IACzC,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,YAAY;CAC5C,CAAC"}
|
package/dist/gtin-creator.d.ts
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
import { type TransformerInput, type TransformerOutput } from "@aidc-toolkit/utility";
|
|
2
|
-
import {
|
|
3
|
-
import { type GTINBaseType } from "./gtin-type.js";
|
|
2
|
+
import { type GTINBaseLength } from "./gtin-length.js";
|
|
4
3
|
import { GTINValidator } from "./gtin-validator.js";
|
|
5
4
|
import type { PrefixProvider } from "./prefix-provider.js";
|
|
6
|
-
declare const GTINCreator_base: import("
|
|
5
|
+
declare const GTINCreator_base: import("./abstract-numeric-identifier-creator.js").NumericIdentifierCreatorConstructor<[GTINBaseLength], "GTIN", GTINValidator>;
|
|
7
6
|
/**
|
|
8
7
|
* GTIN creator. Applicable to GTIN-13, GTIN-12, and GTIN-8 types; no applicable to GTIN-14 type.
|
|
9
8
|
*/
|
|
10
9
|
export declare class GTINCreator extends GTINCreator_base {
|
|
10
|
+
#private;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
private static readonly REQUIRED_INDICATOR_DIGIT_VALIDATION;
|
|
15
|
-
/**
|
|
16
|
-
* Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix
|
|
17
|
-
* provider type.
|
|
12
|
+
* Constructor.
|
|
18
13
|
*
|
|
19
14
|
* @param prefixProvider
|
|
20
15
|
* Prefix provider.
|
|
21
16
|
*
|
|
22
|
-
* @param
|
|
23
|
-
* GTIN base
|
|
17
|
+
* @param gtinBaseLength
|
|
18
|
+
* GTIN base length (all except GTIN-14).
|
|
24
19
|
*/
|
|
25
|
-
constructor(prefixProvider: PrefixProvider,
|
|
20
|
+
constructor(prefixProvider: PrefixProvider, gtinBaseLength: GTINBaseLength);
|
|
26
21
|
/**
|
|
27
22
|
* @inheritDoc
|
|
28
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gtin-creator.d.ts","sourceRoot":"","sources":["../src/gtin-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACzB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"gtin-creator.d.ts","sourceRoot":"","sources":["../src/gtin-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACzB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;;AAE3D;;GAEG;AACH,qBAAa,WAAY,SAAQ,gBAIjB;;IAUZ;;;;;;;;OAQG;gBACS,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc;IAI1E;;OAEG;IACH,IAAa,MAAM,IAAI,MAAM,CAE5B;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAQ,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,CAAC;IAUjM;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM;CAmGxG"}
|
package/dist/gtin-creator.js
CHANGED
|
@@ -1,35 +1,32 @@
|
|
|
1
1
|
import { Exclusions, NUMERIC_CREATOR } from "@aidc-toolkit/utility";
|
|
2
|
-
import {
|
|
3
|
-
import { AbstractNumericIdentifierCreator } from "./abstract-numeric-identifier-creator.js";
|
|
2
|
+
import { MixinAbstractNumericIdentifierCreator } from "./abstract-numeric-identifier-creator.js";
|
|
4
3
|
import { checkDigit, priceOrWeightCheckDigit } from "./check.js";
|
|
5
|
-
import {
|
|
4
|
+
import { GTINLengths } from "./gtin-length.js";
|
|
6
5
|
import { GTINValidator } from "./gtin-validator.js";
|
|
7
6
|
import { i18nextGS1 } from "./locale/i18n.js";
|
|
8
7
|
/**
|
|
9
8
|
* GTIN creator. Applicable to GTIN-13, GTIN-12, and GTIN-8 types; no applicable to GTIN-14 type.
|
|
10
9
|
*/
|
|
11
|
-
export class GTINCreator extends
|
|
10
|
+
export class GTINCreator extends MixinAbstractNumericIdentifierCreator(GTINValidator) {
|
|
12
11
|
/**
|
|
13
12
|
* Validation parameters for required indicator digit.
|
|
14
13
|
*/
|
|
15
|
-
static REQUIRED_INDICATOR_DIGIT_VALIDATION = {
|
|
14
|
+
static #REQUIRED_INDICATOR_DIGIT_VALIDATION = {
|
|
16
15
|
minimumLength: 1,
|
|
17
16
|
maximumLength: 1,
|
|
18
17
|
component: () => i18nextGS1.t("Identifier.indicatorDigit")
|
|
19
18
|
};
|
|
20
19
|
/**
|
|
21
|
-
* Constructor.
|
|
22
|
-
* provider type.
|
|
20
|
+
* Constructor.
|
|
23
21
|
*
|
|
24
22
|
* @param prefixProvider
|
|
25
23
|
* Prefix provider.
|
|
26
24
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* GTIN base
|
|
25
|
+
* @param gtinBaseLength
|
|
26
|
+
* GTIN base length (all except GTIN-14).
|
|
29
27
|
*/
|
|
30
|
-
constructor(prefixProvider,
|
|
31
|
-
super(
|
|
32
|
-
this.init(prefixProvider, prefixProvider.prefix);
|
|
28
|
+
constructor(prefixProvider, gtinBaseLength) {
|
|
29
|
+
super(prefixProvider, prefixProvider.prefix, gtinBaseLength);
|
|
33
30
|
}
|
|
34
31
|
/**
|
|
35
32
|
* @inheritDoc
|
|
@@ -57,8 +54,8 @@ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentifierC
|
|
|
57
54
|
* GTIN-14(s).
|
|
58
55
|
*/
|
|
59
56
|
createGTIN14(indicatorDigit, valueOrValues, sparse = false) {
|
|
60
|
-
NUMERIC_CREATOR.validate(indicatorDigit, GTINCreator
|
|
61
|
-
return NUMERIC_CREATOR.create(
|
|
57
|
+
NUMERIC_CREATOR.validate(indicatorDigit, GTINCreator.#REQUIRED_INDICATOR_DIGIT_VALIDATION);
|
|
58
|
+
return NUMERIC_CREATOR.create(GTINLengths.GTIN13 - this.prefixProvider.gs1CompanyPrefix.length - 1, valueOrValues, Exclusions.None, sparse ? this.tweak : undefined, (reference) => {
|
|
62
59
|
const partialIdentifier = indicatorDigit + this.prefixProvider.gs1CompanyPrefix + reference;
|
|
63
60
|
return partialIdentifier + checkDigit(partialIdentifier);
|
|
64
61
|
});
|
package/dist/gtin-creator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gtin-creator.js","sourceRoot":"","sources":["../src/gtin-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,UAAU,EACV,eAAe,EAGlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"g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oBAAoB,CAAC,CAAC;wBAC3C,CAAC;wBAED,mBAAmB,EAAE,CAAC;wBACtB,MAAM;oBAEV,KAAK,GAAG;wBACJ,2DAA2D;wBAC3D,WAAW,GAAG,CAAC,gCAAgC,CAAC;wBAEhD,qBAAqB,GAAG,KAAK,CAAC;wBAC9B,qBAAqB,GAAG,KAAK,CAAC;wBAE9B,gCAAgC,GAAG,IAAI,CAAC;wBAExC,WAAW,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;wBACjD,MAAM;oBAEV;wBACI,WAAW,GAAG,KAAK,CAAC;wBACpB,MAAM;gBACd,CAAC;YACL,CAAC;QACL,CAAC;QAED,WAAW,KAAK,mBAAmB,KAAK,CAAC,IAAI,mBAAmB,KAAK,CAAC,CAAC;QAEvE,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC;QACrF,CAAC;QAED,mBAAmB,GAAG,eAAe,CAAC,MAAM,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;QACjF,mBAAmB,GAAG,eAAe,CAAC,MAAM,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;QAEjF,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEpC,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GTINBaseLength } from "./gtin-length.js";
|
|
2
|
+
import type { GTINType } from "./gtin-type.js";
|
|
3
|
+
import type { LeaderTypes } from "./leader-type.js";
|
|
2
4
|
import type { NumericIdentifierDescriptor } from "./numeric-identifier-descriptor.js";
|
|
3
|
-
import type { LeaderTypes } from "./numeric-identifier-type.js";
|
|
4
5
|
/**
|
|
5
6
|
* GTIN descriptor.
|
|
6
7
|
*/
|
|
@@ -8,7 +9,11 @@ export interface GTINDescriptor extends NumericIdentifierDescriptor {
|
|
|
8
9
|
/**
|
|
9
10
|
* @inheritDoc
|
|
10
11
|
*/
|
|
11
|
-
readonly identifierType:
|
|
12
|
+
readonly identifierType: GTINType;
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
readonly length: GTINBaseLength;
|
|
12
17
|
/**
|
|
13
18
|
* @inheritDoc
|
|
14
19
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gtin-descriptor.d.ts","sourceRoot":"","sources":["../src/gtin-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"gtin-descriptor.d.ts","sourceRoot":"","sources":["../src/gtin-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,2BAA2B;IAC/D;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,WAAW,CAAC,cAAc,CAAC;CAC1D"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type PrefixType } from "./prefix-type.js";
|
|
2
|
+
/**
|
|
3
|
+
* GTIN lengths. The numeric values are equal to the lengths of the GTINs.
|
|
4
|
+
*/
|
|
5
|
+
export declare const GTINLengths: {
|
|
6
|
+
/**
|
|
7
|
+
* GTIN-13.
|
|
8
|
+
*/
|
|
9
|
+
readonly GTIN13: 13;
|
|
10
|
+
/**
|
|
11
|
+
* GTIN-12.
|
|
12
|
+
*/
|
|
13
|
+
readonly GTIN12: 12;
|
|
14
|
+
/**
|
|
15
|
+
* GTIN-8.
|
|
16
|
+
*/
|
|
17
|
+
readonly GTIN8: 8;
|
|
18
|
+
/**
|
|
19
|
+
* GTIN-14.
|
|
20
|
+
*/
|
|
21
|
+
readonly GTIN14: 14;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* GTIN length key.
|
|
25
|
+
*/
|
|
26
|
+
export type GTINLengthKey = keyof typeof GTINLengths;
|
|
27
|
+
/**
|
|
28
|
+
* GTIN length.
|
|
29
|
+
*/
|
|
30
|
+
export type GTINLength = typeof GTINLengths[GTINLengthKey];
|
|
31
|
+
/**
|
|
32
|
+
* GTIN base lengths (all except GTIN-14).
|
|
33
|
+
*/
|
|
34
|
+
export declare const GTINBaseLengths: Omit<{
|
|
35
|
+
/**
|
|
36
|
+
* GTIN-13.
|
|
37
|
+
*/
|
|
38
|
+
readonly GTIN13: 13;
|
|
39
|
+
/**
|
|
40
|
+
* GTIN-12.
|
|
41
|
+
*/
|
|
42
|
+
readonly GTIN12: 12;
|
|
43
|
+
/**
|
|
44
|
+
* GTIN-8.
|
|
45
|
+
*/
|
|
46
|
+
readonly GTIN8: 8;
|
|
47
|
+
/**
|
|
48
|
+
* GTIN-14.
|
|
49
|
+
*/
|
|
50
|
+
readonly GTIN14: 14;
|
|
51
|
+
}, "GTIN14">;
|
|
52
|
+
/**
|
|
53
|
+
* GTIN base length key.
|
|
54
|
+
*/
|
|
55
|
+
export type GTINBaseLengthKey = keyof typeof GTINBaseLengths;
|
|
56
|
+
/**
|
|
57
|
+
* GTIN length.
|
|
58
|
+
*/
|
|
59
|
+
export type GTINBaseLength = typeof GTINBaseLengths[GTINBaseLengthKey];
|
|
60
|
+
/**
|
|
61
|
+
* GTIN base lengths by prefix type. Used to determine the GTIN length supported by a prefix type.
|
|
62
|
+
*/
|
|
63
|
+
export declare const GTIN_BASE_TYPES: Readonly<Record<PrefixType, GTINBaseLength>>;
|
|
64
|
+
//# sourceMappingURL=gtin-length.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gtin-length.d.ts","sourceRoot":"","sources":["../src/gtin-length.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,kBAAkB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,WAAW;IACpB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEG,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,WAAW,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,WAAW,CAAC,aAAa,CAAC,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,eAAe;IAlCxB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;YAiBmD,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,eAAe,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,eAAe,CAAC,iBAAiB,CAAC,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,CAIxE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { omit } from "@aidc-toolkit/core";
|
|
2
|
+
import { PrefixTypes } from "./prefix-type.js";
|
|
3
|
+
/**
|
|
4
|
+
* GTIN lengths. The numeric values are equal to the lengths of the GTINs.
|
|
5
|
+
*/
|
|
6
|
+
export const GTINLengths = {
|
|
7
|
+
/**
|
|
8
|
+
* GTIN-13.
|
|
9
|
+
*/
|
|
10
|
+
GTIN13: 13,
|
|
11
|
+
/**
|
|
12
|
+
* GTIN-12.
|
|
13
|
+
*/
|
|
14
|
+
GTIN12: 12,
|
|
15
|
+
/**
|
|
16
|
+
* GTIN-8.
|
|
17
|
+
*/
|
|
18
|
+
GTIN8: 8,
|
|
19
|
+
/**
|
|
20
|
+
* GTIN-14.
|
|
21
|
+
*/
|
|
22
|
+
GTIN14: 14
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* GTIN base lengths (all except GTIN-14).
|
|
26
|
+
*/
|
|
27
|
+
export const GTINBaseLengths = omit(GTINLengths, "GTIN14");
|
|
28
|
+
/**
|
|
29
|
+
* GTIN base lengths by prefix type. Used to determine the GTIN length supported by a prefix type.
|
|
30
|
+
*/
|
|
31
|
+
export const GTIN_BASE_TYPES = {
|
|
32
|
+
[PrefixTypes.GS1CompanyPrefix]: GTINLengths.GTIN13,
|
|
33
|
+
[PrefixTypes.UPCCompanyPrefix]: GTINLengths.GTIN12,
|
|
34
|
+
[PrefixTypes.GS18Prefix]: GTINLengths.GTIN8
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=gtin-length.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gtin-length.js","sourceRoot":"","sources":["../src/gtin-length.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAmB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB;;OAEG;IACH,MAAM,EAAE,EAAE;IAEV;;OAEG;IACH,MAAM,EAAE,EAAE;IAEV;;OAEG;IACH,KAAK,EAAE,CAAC;IAER;;OAEG;IACH,MAAM,EAAE,EAAE;CACJ,CAAC;AAYX;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AAY3D;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAiD;IACzE,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM;IAClD,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM;IAClD,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,KAAK;CAC9C,CAAC"}
|
package/dist/gtin-type.d.ts
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { type PrefixType } from "./prefix-type.js";
|
|
2
1
|
/**
|
|
3
|
-
* GTIN types.
|
|
2
|
+
* GTIN types.
|
|
4
3
|
*/
|
|
5
|
-
export declare const GTINTypes: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
readonly
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
readonly
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readonly
|
|
18
|
-
|
|
19
|
-
* GTIN-14.
|
|
20
|
-
*/
|
|
21
|
-
readonly GTIN14: 14;
|
|
22
|
-
};
|
|
4
|
+
export declare const GTINTypes: Pick<Pick<{
|
|
5
|
+
readonly GTIN: "GTIN";
|
|
6
|
+
readonly GLN: "GLN";
|
|
7
|
+
readonly SSCC: "SSCC";
|
|
8
|
+
readonly GRAI: "GRAI";
|
|
9
|
+
readonly GIAI: "GIAI";
|
|
10
|
+
readonly GSRN: "GSRN";
|
|
11
|
+
readonly GDTI: "GDTI";
|
|
12
|
+
readonly GINC: "GINC";
|
|
13
|
+
readonly GSIN: "GSIN";
|
|
14
|
+
readonly GCN: "GCN";
|
|
15
|
+
readonly CPID: "CPID";
|
|
16
|
+
readonly GMN: "GMN";
|
|
17
|
+
}, "GTIN" | "GLN" | "SSCC" | "GRAI" | "GSRN" | "GDTI" | "GSIN" | "GCN">, "GTIN">;
|
|
23
18
|
/**
|
|
24
19
|
* GTIN type key.
|
|
25
20
|
*/
|
|
@@ -28,12 +23,4 @@ export type GTINTypeKey = keyof typeof GTINTypes;
|
|
|
28
23
|
* GTIN type.
|
|
29
24
|
*/
|
|
30
25
|
export type GTINType = typeof GTINTypes[GTINTypeKey];
|
|
31
|
-
/**
|
|
32
|
-
* GTIN base type (all except GTIN-14).
|
|
33
|
-
*/
|
|
34
|
-
export type GTINBaseType = Exclude<GTINType, typeof GTINTypes.GTIN14>;
|
|
35
|
-
/**
|
|
36
|
-
* GTIN base types by prefix type. Used to determine the GTIN type supported by a prefix type.
|
|
37
|
-
*/
|
|
38
|
-
export declare const GTIN_BASE_TYPES: Readonly<Record<PrefixType, GTINBaseType>>;
|
|
39
26
|
//# sourceMappingURL=gtin-type.d.ts.map
|