@aidc-toolkit/gs1 0.9.5 → 0.9.7-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/index.cjs +207 -139
- package/dist/index.d.cts +70 -155
- package/dist/index.d.ts +70 -155
- package/dist/index.js +205 -138
- package/package.json +9 -10
- package/src/idkey.ts +141 -232
- package/src/index.ts +1 -0
- package/test/check.test.ts +1 -1
- package/test/idkey.test.ts +29 -29
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -32
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/workflows/build-publish.yml +0 -20
- package/.idea/gs1.iml +0 -9
- package/.idea/inspectionProfiles/Project_Default.xml +0 -7
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/runConfigurations/Test_all.xml +0 -12
- package/.idea/runConfigurations/Test_check.xml +0 -12
- package/.idea/runConfigurations/Test_identification_key.xml +0 -12
- package/.idea/runConfigurations/build.xml +0 -12
- package/.idea/runConfigurations/eslint.xml +0 -12
- package/.idea/vcs.xml +0 -6
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ __export(src_exports, {
|
|
|
23
23
|
AI39_CREATOR: () => AI39_CREATOR,
|
|
24
24
|
AI82_CREATOR: () => AI82_CREATOR,
|
|
25
25
|
CPID_VALIDATOR: () => CPID_VALIDATOR,
|
|
26
|
-
|
|
26
|
+
ContentCharacterSet: () => ContentCharacterSet,
|
|
27
27
|
GCN_VALIDATOR: () => GCN_VALIDATOR,
|
|
28
28
|
GDTI_VALIDATOR: () => GDTI_VALIDATOR,
|
|
29
29
|
GIAI_VALIDATOR: () => GIAI_VALIDATOR,
|
|
@@ -57,11 +57,94 @@ __export(src_exports, {
|
|
|
57
57
|
checkDigitSum: () => checkDigitSum,
|
|
58
58
|
fiveDigitPriceWeightCheckDigit: () => fiveDigitPriceWeightCheckDigit,
|
|
59
59
|
fourDigitPriceWeightCheckDigit: () => fourDigitPriceWeightCheckDigit,
|
|
60
|
+
gs1NS: () => gs1NS,
|
|
60
61
|
hasValidCheckCharacterPair: () => hasValidCheckCharacterPair,
|
|
61
62
|
hasValidCheckDigit: () => hasValidCheckDigit
|
|
62
63
|
});
|
|
63
64
|
module.exports = __toCommonJS(src_exports);
|
|
64
65
|
|
|
66
|
+
// src/locale/i18n.ts
|
|
67
|
+
var import_core = require("@aidc-toolkit/core");
|
|
68
|
+
|
|
69
|
+
// src/locale/en/locale_strings.ts
|
|
70
|
+
var localeStrings = {
|
|
71
|
+
Check: {
|
|
72
|
+
lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}"
|
|
73
|
+
},
|
|
74
|
+
IdentificationKey: {
|
|
75
|
+
identificationKeyTypeLength: "{{identificationKeyType}} must be {{length}} digits long",
|
|
76
|
+
invalidCheckDigit: "Invalid check digit",
|
|
77
|
+
invalidGTINLength: "GTIN must be 13, 12, 8, or 14 digits long",
|
|
78
|
+
invalidGTIN14Length: "GTIN must be 14 digits long",
|
|
79
|
+
invalidZeroSuppressedGTIN12: "Invalid zero-suppressed GTIN-12",
|
|
80
|
+
invalidZeroSuppressibleGTIN12: "GTIN-12 not zero-suppressible",
|
|
81
|
+
invalidZeroSuppressedGTIN12AsGTIN13: "Invalid zero-suppressed GTIN-12 as GTIN-13",
|
|
82
|
+
invalidZeroSuppressedGTIN12AsGTIN14: "Invalid zero-suppressed GTIN-12 as GTIN-14",
|
|
83
|
+
invalidGTIN13AtRetail: "GTIN-13 at retail consumer trade item level can't start with zero",
|
|
84
|
+
invalidGTINAtRetail: "GTIN not supported at retail consumer trade item level",
|
|
85
|
+
invalidGTINAtOtherThanRetail: "GTIN not supported at other than retail consumer trade item level",
|
|
86
|
+
indicatorDigit: "indicator digit",
|
|
87
|
+
serialComponent: "serial component",
|
|
88
|
+
reference: "reference",
|
|
89
|
+
referenceCantBeAllNumeric: "Reference can't be all-numeric",
|
|
90
|
+
invalidCheckCharacterPair: "Invalid check character pair"
|
|
91
|
+
},
|
|
92
|
+
Prefix: {
|
|
93
|
+
gs1CompanyPrefix: "GS1 Company Prefix",
|
|
94
|
+
upcCompanyPrefix: "U.P.C. Company Prefix",
|
|
95
|
+
gs18Prefix: "GS1-8 Prefix",
|
|
96
|
+
gs1CompanyPrefixCantStartWith0: `GS1 Company Prefix can't start with "0"`,
|
|
97
|
+
gs1CompanyPrefixCantStartWith00000: `GS1 Company Prefix can't start with "00000"`,
|
|
98
|
+
gs1CompanyPrefixCantStartWith000000: `GS1 Company Prefix can't start with "000000"`,
|
|
99
|
+
upcCompanyPrefixCantStartWith0000: `U.P.C. Company Prefix can't start with "0000"`,
|
|
100
|
+
gs18PrefixCantStartWith0: `GS1-8 Prefix can't start with "0"`,
|
|
101
|
+
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} not supported by GS1-8 Prefix"
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/locale/fr/locale_strings.ts
|
|
106
|
+
var localeStrings2 = {
|
|
107
|
+
Check: {
|
|
108
|
+
lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "La longueur {{length}} de la cha\xEEne pour la paire de caract\xE8res de v\xE9rification doit \xEAtre inf\xE9rieure ou \xE9gale \xE0 {{maximum Length}}"
|
|
109
|
+
},
|
|
110
|
+
IdentificationKey: {
|
|
111
|
+
identificationKeyTypeLength: "{{identificationKeyType}} doit comporter {{length}} chiffres",
|
|
112
|
+
invalidCheckDigit: "Chiffre de contr\xF4le non valide",
|
|
113
|
+
invalidGTINLength: "Le GTIN doit comporter 13, 12, 8 ou 14 chiffres",
|
|
114
|
+
invalidGTIN14Length: "Le GTIN doit comporter 14 chiffres",
|
|
115
|
+
invalidZeroSuppressedGTIN12: "Code GTIN-12 non valide avec z\xE9ro supprim\xE9",
|
|
116
|
+
invalidZeroSuppressibleGTIN12: "Le GTIN-12 ne peut pas \xEAtre supprim\xE9 par z\xE9ro",
|
|
117
|
+
invalidZeroSuppressedGTIN12AsGTIN13: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-13",
|
|
118
|
+
invalidZeroSuppressedGTIN12AsGTIN14: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-14",
|
|
119
|
+
invalidGTIN13AtRetail: "Le GTIN-13 au niveau des articles de consommation au d\xE9tail ne peut pas commencer par z\xE9ro",
|
|
120
|
+
invalidGTINAtRetail: "Le GTIN n'est pas pris en charge au niveau des articles de consommation au d\xE9tail",
|
|
121
|
+
invalidGTINAtOtherThanRetail: "Le GTIN n'est pas pris en charge \xE0 d'autres niveaux que ceux des articles de consommation au d\xE9tail",
|
|
122
|
+
indicatorDigit: "chiffre indicateur",
|
|
123
|
+
serialComponent: "composant s\xE9rie",
|
|
124
|
+
reference: "r\xE9f\xE9rence",
|
|
125
|
+
referenceCantBeAllNumeric: "La r\xE9f\xE9rence ne peut pas \xEAtre enti\xE8rement num\xE9rique",
|
|
126
|
+
invalidCheckCharacterPair: "Paire de caract\xE8res de contr\xF4le non valide"
|
|
127
|
+
},
|
|
128
|
+
Prefix: {
|
|
129
|
+
gs1CompanyPrefix: "Pr\xE9fixe de l'entreprise GS1",
|
|
130
|
+
upcCompanyPrefix: "Pr\xE9fixe de l'entreprise U.P.C.",
|
|
131
|
+
gs18Prefix: "Pr\xE9fixe GS1-8",
|
|
132
|
+
gs1CompanyPrefixCantStartWith0: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "0"`,
|
|
133
|
+
gs1CompanyPrefixCantStartWith00000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "00000"`,
|
|
134
|
+
gs1CompanyPrefixCantStartWith000000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "000000"`,
|
|
135
|
+
upcCompanyPrefixCantStartWith0000: `Le pr\xE9fixe de l'entreprise U.P.C. ne peut pas commencer par "0000"`,
|
|
136
|
+
gs18PrefixCantStartWith0: 'Le pr\xE9fixe GS1-8 ne peut pas commencer par "0"',
|
|
137
|
+
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} non pris en charge par le pr\xE9fixe GS1-8"
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// src/locale/i18n.ts
|
|
142
|
+
var gs1NS = "aidct_gs1";
|
|
143
|
+
(0, import_core.i18nAssertValidResources)(localeStrings, "fr", localeStrings2);
|
|
144
|
+
(0, import_core.i18nAddResourceBundle)("en", gs1NS, localeStrings);
|
|
145
|
+
(0, import_core.i18nAddResourceBundle)("fr", gs1NS, localeStrings2);
|
|
146
|
+
var i18n_default = import_core.i18next;
|
|
147
|
+
|
|
65
148
|
// src/character_set.ts
|
|
66
149
|
var import_utility = require("@aidc-toolkit/utility");
|
|
67
150
|
var AI82_CREATOR = new import_utility.CharacterSetCreator([
|
|
@@ -192,90 +275,6 @@ var AI39_CREATOR = new import_utility.CharacterSetCreator([
|
|
|
192
275
|
|
|
193
276
|
// src/check.ts
|
|
194
277
|
var import_utility2 = require("@aidc-toolkit/utility");
|
|
195
|
-
|
|
196
|
-
// src/locale/i18n.ts
|
|
197
|
-
var import_core = require("@aidc-toolkit/core");
|
|
198
|
-
|
|
199
|
-
// src/locale/en/locale_strings.ts
|
|
200
|
-
var localeStrings = {
|
|
201
|
-
Check: {
|
|
202
|
-
lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}"
|
|
203
|
-
},
|
|
204
|
-
IdentificationKey: {
|
|
205
|
-
identificationKeyTypeLength: "{{identificationKeyType}} must be {{length}} digits long",
|
|
206
|
-
invalidCheckDigit: "Invalid check digit",
|
|
207
|
-
invalidGTINLength: "GTIN must be 13, 12, 8, or 14 digits long",
|
|
208
|
-
invalidGTIN14Length: "GTIN must be 14 digits long",
|
|
209
|
-
invalidZeroSuppressedGTIN12: "Invalid zero-suppressed GTIN-12",
|
|
210
|
-
invalidZeroSuppressibleGTIN12: "GTIN-12 not zero-suppressible",
|
|
211
|
-
invalidZeroSuppressedGTIN12AsGTIN13: "Invalid zero-suppressed GTIN-12 as GTIN-13",
|
|
212
|
-
invalidZeroSuppressedGTIN12AsGTIN14: "Invalid zero-suppressed GTIN-12 as GTIN-14",
|
|
213
|
-
invalidGTIN13AtRetail: "GTIN-13 at retail consumer trade item level can't start with zero",
|
|
214
|
-
invalidGTINAtRetail: "GTIN not supported at retail consumer trade item level",
|
|
215
|
-
invalidGTINAtOtherThanRetail: "GTIN not supported at other than retail consumer trade item level",
|
|
216
|
-
indicatorDigit: "indicator digit",
|
|
217
|
-
serialComponent: "serial component",
|
|
218
|
-
reference: "reference",
|
|
219
|
-
referenceCantBeAllNumeric: "Reference can't be all-numeric",
|
|
220
|
-
invalidCheckCharacterPair: "Invalid check character pair"
|
|
221
|
-
},
|
|
222
|
-
Prefix: {
|
|
223
|
-
gs1CompanyPrefix: "GS1 Company Prefix",
|
|
224
|
-
upcCompanyPrefix: "U.P.C. Company Prefix",
|
|
225
|
-
gs18Prefix: "GS1-8 Prefix",
|
|
226
|
-
gs1CompanyPrefixCantStartWith0: `GS1 Company Prefix can't start with "0"`,
|
|
227
|
-
gs1CompanyPrefixCantStartWith00000: `GS1 Company Prefix can't start with "00000"`,
|
|
228
|
-
gs1CompanyPrefixCantStartWith000000: `GS1 Company Prefix can't start with "000000"`,
|
|
229
|
-
upcCompanyPrefixCantStartWith0000: `U.P.C. Company Prefix can't start with "0000"`,
|
|
230
|
-
gs18PrefixCantStartWith0: `GS1-8 Prefix can't start with "0"`,
|
|
231
|
-
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} not supported by GS1-8 Prefix"
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
// src/locale/fr/locale_strings.ts
|
|
236
|
-
var localeStrings2 = {
|
|
237
|
-
Check: {
|
|
238
|
-
lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "La longueur {{length}} de la cha\xEEne pour la paire de caract\xE8res de v\xE9rification doit \xEAtre inf\xE9rieure ou \xE9gale \xE0 {{maximum Length}}"
|
|
239
|
-
},
|
|
240
|
-
IdentificationKey: {
|
|
241
|
-
identificationKeyTypeLength: "{{identificationKeyType}} doit comporter {{length}} chiffres",
|
|
242
|
-
invalidCheckDigit: "Chiffre de contr\xF4le non valide",
|
|
243
|
-
invalidGTINLength: "Le GTIN doit comporter 13, 12, 8 ou 14 chiffres",
|
|
244
|
-
invalidGTIN14Length: "Le GTIN doit comporter 14 chiffres",
|
|
245
|
-
invalidZeroSuppressedGTIN12: "Code GTIN-12 non valide avec z\xE9ro supprim\xE9",
|
|
246
|
-
invalidZeroSuppressibleGTIN12: "Le GTIN-12 ne peut pas \xEAtre supprim\xE9 par z\xE9ro",
|
|
247
|
-
invalidZeroSuppressedGTIN12AsGTIN13: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-13",
|
|
248
|
-
invalidZeroSuppressedGTIN12AsGTIN14: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-14",
|
|
249
|
-
invalidGTIN13AtRetail: "Le GTIN-13 au niveau des articles de consommation au d\xE9tail ne peut pas commencer par z\xE9ro",
|
|
250
|
-
invalidGTINAtRetail: "Le GTIN n'est pas pris en charge au niveau des articles de consommation au d\xE9tail",
|
|
251
|
-
invalidGTINAtOtherThanRetail: "Le GTIN n'est pas pris en charge \xE0 d'autres niveaux que ceux des articles de consommation au d\xE9tail",
|
|
252
|
-
indicatorDigit: "chiffre indicateur",
|
|
253
|
-
serialComponent: "composant s\xE9rie",
|
|
254
|
-
reference: "r\xE9f\xE9rence",
|
|
255
|
-
referenceCantBeAllNumeric: "La r\xE9f\xE9rence ne peut pas \xEAtre enti\xE8rement num\xE9rique",
|
|
256
|
-
invalidCheckCharacterPair: "Paire de caract\xE8res de contr\xF4le non valide"
|
|
257
|
-
},
|
|
258
|
-
Prefix: {
|
|
259
|
-
gs1CompanyPrefix: "Pr\xE9fixe de l'entreprise GS1",
|
|
260
|
-
upcCompanyPrefix: "Pr\xE9fixe de l'entreprise U.P.C.",
|
|
261
|
-
gs18Prefix: "Pr\xE9fixe GS1-8",
|
|
262
|
-
gs1CompanyPrefixCantStartWith0: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "0"`,
|
|
263
|
-
gs1CompanyPrefixCantStartWith00000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "00000"`,
|
|
264
|
-
gs1CompanyPrefixCantStartWith000000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "000000"`,
|
|
265
|
-
upcCompanyPrefixCantStartWith0000: `Le pr\xE9fixe de l'entreprise U.P.C. ne peut pas commencer par "0000"`,
|
|
266
|
-
gs18PrefixCantStartWith0: 'Le pr\xE9fixe GS1-8 ne peut pas commencer par "0"',
|
|
267
|
-
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} non pris en charge par le pr\xE9fixe GS1-8"
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
// src/locale/i18n.ts
|
|
272
|
-
var gs1NS = "aidct_gs1";
|
|
273
|
-
(0, import_core.i18nAssertValidResources)(localeStrings, "fr", localeStrings2);
|
|
274
|
-
(0, import_core.i18nAddResourceBundle)("en", gs1NS, localeStrings);
|
|
275
|
-
(0, import_core.i18nAddResourceBundle)("fr", gs1NS, localeStrings2);
|
|
276
|
-
var i18n_default = import_core.i18next;
|
|
277
|
-
|
|
278
|
-
// src/check.ts
|
|
279
278
|
var THREE_WEIGHT_RESULTS = [
|
|
280
279
|
0,
|
|
281
280
|
3,
|
|
@@ -481,12 +480,12 @@ var PrefixType = /* @__PURE__ */ ((PrefixType2) => {
|
|
|
481
480
|
PrefixType2[PrefixType2["GS18Prefix"] = 2] = "GS18Prefix";
|
|
482
481
|
return PrefixType2;
|
|
483
482
|
})(PrefixType || {});
|
|
484
|
-
var
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
return
|
|
489
|
-
})(
|
|
483
|
+
var ContentCharacterSet = /* @__PURE__ */ ((ContentCharacterSet2) => {
|
|
484
|
+
ContentCharacterSet2[ContentCharacterSet2["Numeric"] = 0] = "Numeric";
|
|
485
|
+
ContentCharacterSet2[ContentCharacterSet2["AI82"] = 1] = "AI82";
|
|
486
|
+
ContentCharacterSet2[ContentCharacterSet2["AI39"] = 2] = "AI39";
|
|
487
|
+
return ContentCharacterSet2;
|
|
488
|
+
})(ContentCharacterSet || {});
|
|
490
489
|
var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidator {
|
|
491
490
|
static CHARACTER_SET_CREATORS = [
|
|
492
491
|
import_utility3.NUMERIC_CREATOR,
|
|
@@ -510,19 +509,19 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
|
|
|
510
509
|
*/
|
|
511
510
|
_referenceCharacterSet;
|
|
512
511
|
/**
|
|
513
|
-
* Reference
|
|
512
|
+
* Reference creator.
|
|
514
513
|
*/
|
|
515
|
-
|
|
514
|
+
_referenceCreator;
|
|
516
515
|
/**
|
|
517
|
-
* Get the character set
|
|
516
|
+
* Get the character set creator for a character set.
|
|
518
517
|
*
|
|
519
518
|
* @param characterSet
|
|
520
519
|
* Character set.
|
|
521
520
|
*
|
|
522
521
|
* @returns
|
|
523
|
-
* Character set
|
|
522
|
+
* Character set creator.
|
|
524
523
|
*/
|
|
525
|
-
static
|
|
524
|
+
static creatorFor(characterSet) {
|
|
526
525
|
return _AbstractIdentificationKeyValidator.CHARACTER_SET_CREATORS[characterSet];
|
|
527
526
|
}
|
|
528
527
|
/**
|
|
@@ -545,7 +544,7 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
|
|
|
545
544
|
this._prefixType = prefixType;
|
|
546
545
|
this._length = length;
|
|
547
546
|
this._referenceCharacterSet = referenceCharacterSet;
|
|
548
|
-
this.
|
|
547
|
+
this._referenceCreator = _AbstractIdentificationKeyValidator.creatorFor(referenceCharacterSet);
|
|
549
548
|
}
|
|
550
549
|
/**
|
|
551
550
|
* @inheritDoc
|
|
@@ -574,8 +573,8 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
|
|
|
574
573
|
/**
|
|
575
574
|
* @inheritDoc
|
|
576
575
|
*/
|
|
577
|
-
get
|
|
578
|
-
return this.
|
|
576
|
+
get referenceCreator() {
|
|
577
|
+
return this._referenceCreator;
|
|
579
578
|
}
|
|
580
579
|
/**
|
|
581
580
|
* Pad an identification key on the left with zero-value character for validation purposes. This is done to align an
|
|
@@ -591,7 +590,7 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
|
|
|
591
590
|
* Padded identification key.
|
|
592
591
|
*/
|
|
593
592
|
padIdentificationKey(identificationKey, validation) {
|
|
594
|
-
return validation?.positionOffset === void 0 ? identificationKey : this.
|
|
593
|
+
return validation?.positionOffset === void 0 ? identificationKey : this.referenceCreator.character(0).repeat(validation.positionOffset).concat(identificationKey);
|
|
595
594
|
}
|
|
596
595
|
/**
|
|
597
596
|
* Validate the prefix within an identification key.
|
|
@@ -858,9 +857,9 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
|
|
|
858
857
|
*/
|
|
859
858
|
_serialComponentValidation;
|
|
860
859
|
/**
|
|
861
|
-
* Serial component
|
|
860
|
+
* Serial component creator.
|
|
862
861
|
*/
|
|
863
|
-
|
|
862
|
+
_serialComponentCreator;
|
|
864
863
|
/**
|
|
865
864
|
* Constructor.
|
|
866
865
|
*
|
|
@@ -887,7 +886,7 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
|
|
|
887
886
|
ns: gs1NS
|
|
888
887
|
})
|
|
889
888
|
};
|
|
890
|
-
this.
|
|
889
|
+
this._serialComponentCreator = _SerializableNumericIdentificationKeyValidator.creatorFor(serialComponentCharacterSet);
|
|
891
890
|
}
|
|
892
891
|
/**
|
|
893
892
|
* Get the serial component length.
|
|
@@ -908,10 +907,10 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
|
|
|
908
907
|
return this._serialComponentValidation;
|
|
909
908
|
}
|
|
910
909
|
/**
|
|
911
|
-
* Get the serial component
|
|
910
|
+
* Get the serial component creator.
|
|
912
911
|
*/
|
|
913
|
-
get
|
|
914
|
-
return this.
|
|
912
|
+
get serialComponentCreator() {
|
|
913
|
+
return this._serialComponentCreator;
|
|
915
914
|
}
|
|
916
915
|
/**
|
|
917
916
|
* @inheritDoc
|
|
@@ -919,7 +918,7 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
|
|
|
919
918
|
validate(identificationKey, validation) {
|
|
920
919
|
super.validate(identificationKey.substring(0, this.length), validation);
|
|
921
920
|
if (identificationKey.length > this.length) {
|
|
922
|
-
this.
|
|
921
|
+
this.serialComponentCreator.validate(identificationKey.substring(this.length), this._serialComponentValidation);
|
|
923
922
|
}
|
|
924
923
|
}
|
|
925
924
|
};
|
|
@@ -979,7 +978,7 @@ var NonNumericIdentificationKeyValidator = class _NonNumericIdentificationKeyVal
|
|
|
979
978
|
const partialIdentificationKey = this.requiresCheckCharacterPair ? identificationKey.substring(0, identificationKey.length - 2) : identificationKey;
|
|
980
979
|
super.validatePrefix(partialIdentificationKey, validation?.positionOffset);
|
|
981
980
|
if (!this.requiresCheckCharacterPair) {
|
|
982
|
-
this.
|
|
981
|
+
this.referenceCreator.validate(identificationKey, {
|
|
983
982
|
maximumLength: this.length,
|
|
984
983
|
positionOffset: validation?.positionOffset
|
|
985
984
|
});
|
|
@@ -1037,12 +1036,6 @@ var AbstractIdentificationKeyCreator = class {
|
|
|
1037
1036
|
this._prefixManager = prefixManager;
|
|
1038
1037
|
this._referenceLength = this.length - prefix.length - checkAllowance;
|
|
1039
1038
|
}
|
|
1040
|
-
/**
|
|
1041
|
-
* @inheritDoc
|
|
1042
|
-
*/
|
|
1043
|
-
get referenceCreator() {
|
|
1044
|
-
return this.referenceValidator;
|
|
1045
|
-
}
|
|
1046
1039
|
/**
|
|
1047
1040
|
* @inheritDoc
|
|
1048
1041
|
*/
|
|
@@ -1115,7 +1108,9 @@ var AbstractNumericIdentificationKeyCreator = class _AbstractNumericIdentificati
|
|
|
1115
1108
|
const partialIdentificationKey = this.leaderType === 2 /* ExtensionDigit */ ? reference.substring(0, 1) + this.prefix + reference.substring(1) : this.prefix + reference;
|
|
1116
1109
|
return partialIdentificationKey + checkDigit(partialIdentificationKey);
|
|
1117
1110
|
}
|
|
1118
|
-
|
|
1111
|
+
/**
|
|
1112
|
+
* @inheritDoc
|
|
1113
|
+
*/
|
|
1119
1114
|
create(valueOrValues, sparse = false) {
|
|
1120
1115
|
return import_utility3.NUMERIC_CREATOR.create(this.referenceLength, valueOrValues, import_utility3.Exclusion.None, sparse ? this.tweak : void 0, (reference) => this.buildIdentificationKey(reference));
|
|
1121
1116
|
}
|
|
@@ -1213,7 +1208,22 @@ var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINVali
|
|
|
1213
1208
|
get prefix() {
|
|
1214
1209
|
return this.prefixManager.prefix;
|
|
1215
1210
|
}
|
|
1216
|
-
|
|
1211
|
+
/**
|
|
1212
|
+
* Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
|
|
1213
|
+
* converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
|
|
1214
|
+
*
|
|
1215
|
+
* @param indicatorDigit
|
|
1216
|
+
* Indicator digit.
|
|
1217
|
+
*
|
|
1218
|
+
* @param valueOrValues
|
|
1219
|
+
* Numeric value(s).
|
|
1220
|
+
*
|
|
1221
|
+
* @param sparse
|
|
1222
|
+
* If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
|
|
1223
|
+
*
|
|
1224
|
+
* @returns
|
|
1225
|
+
* GTIN-14(s).
|
|
1226
|
+
*/
|
|
1217
1227
|
createGTIN14(indicatorDigit, valueOrValues, sparse = false) {
|
|
1218
1228
|
import_utility3.NUMERIC_CREATOR.validate(indicatorDigit, _GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
|
|
1219
1229
|
return import_utility3.NUMERIC_CREATOR.create(13 /* GTIN13 */ - this.prefixManager.gs1CompanyPrefix.length - 1, valueOrValues, import_utility3.Exclusion.None, sparse ? this.tweak : void 0, (reference) => {
|
|
@@ -1386,30 +1396,66 @@ var SerializableNumericIdentificationKeyCreator = class extends (0, import_ts_mi
|
|
|
1386
1396
|
this.init(prefixManager, prefixManager.gs1CompanyPrefix);
|
|
1387
1397
|
}
|
|
1388
1398
|
/**
|
|
1389
|
-
*
|
|
1399
|
+
* Concatenate a validated base identification key with serial component(s).
|
|
1400
|
+
*
|
|
1401
|
+
* @param baseIdentificationKey
|
|
1402
|
+
* Base identification key.
|
|
1403
|
+
*
|
|
1404
|
+
* @param serialComponentOrComponents
|
|
1405
|
+
* Serial component(s).
|
|
1406
|
+
*
|
|
1407
|
+
* @returns
|
|
1408
|
+
* Serialized identification key(s).
|
|
1390
1409
|
*/
|
|
1391
|
-
|
|
1392
|
-
return this.serialComponentValidator;
|
|
1393
|
-
}
|
|
1394
|
-
// eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
|
|
1395
|
-
concatenateValidated(baseIdentificationKey, serialComponent) {
|
|
1410
|
+
concatenateValidated(baseIdentificationKey, serialComponentOrComponents) {
|
|
1396
1411
|
let result;
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1412
|
+
const serialComponentCreator = this.serialComponentCreator;
|
|
1413
|
+
const serialComponentValidation = this.serialComponentValidation;
|
|
1414
|
+
function validateAndConcatenate(serialComponent) {
|
|
1415
|
+
serialComponentCreator.validate(serialComponent, serialComponentValidation);
|
|
1416
|
+
return baseIdentificationKey + serialComponent;
|
|
1417
|
+
}
|
|
1418
|
+
if (typeof serialComponentOrComponents !== "object") {
|
|
1419
|
+
result = validateAndConcatenate(serialComponentOrComponents);
|
|
1400
1420
|
} else {
|
|
1401
|
-
result = import_utility3.IteratorProxy.from(
|
|
1421
|
+
result = import_utility3.IteratorProxy.from(serialComponentOrComponents).map(validateAndConcatenate);
|
|
1402
1422
|
}
|
|
1403
1423
|
return result;
|
|
1404
1424
|
}
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1425
|
+
/**
|
|
1426
|
+
* Create serialized identification key(s) with a reference based on a numeric value concatenated with serial
|
|
1427
|
+
* component(s). The value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
|
|
1428
|
+
*
|
|
1429
|
+
* @param value
|
|
1430
|
+
* Numeric value of the reference.
|
|
1431
|
+
*
|
|
1432
|
+
* @param serialComponentOrComponents
|
|
1433
|
+
* Serial component(s).
|
|
1434
|
+
*
|
|
1435
|
+
* @param sparse
|
|
1436
|
+
* If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
|
|
1437
|
+
*
|
|
1438
|
+
* @returns
|
|
1439
|
+
* Serialized identification keys.
|
|
1440
|
+
*/
|
|
1441
|
+
createSerialized(value, serialComponentOrComponents, sparse) {
|
|
1442
|
+
return this.concatenateValidated(this.create(value, sparse), serialComponentOrComponents);
|
|
1408
1443
|
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1444
|
+
/**
|
|
1445
|
+
* Concatenate a base identification key with serial component(s).
|
|
1446
|
+
*
|
|
1447
|
+
* @param baseIdentificationKey
|
|
1448
|
+
* Base identification key.
|
|
1449
|
+
*
|
|
1450
|
+
* @param serialComponentOrComponents
|
|
1451
|
+
* Serial component(s).
|
|
1452
|
+
*
|
|
1453
|
+
* @returns
|
|
1454
|
+
* Serialized identification key(s).
|
|
1455
|
+
*/
|
|
1456
|
+
concatenate(baseIdentificationKey, serialComponentOrComponents) {
|
|
1411
1457
|
this.validate(baseIdentificationKey);
|
|
1412
|
-
return this.concatenateValidated(baseIdentificationKey,
|
|
1458
|
+
return this.concatenateValidated(baseIdentificationKey, serialComponentOrComponents);
|
|
1413
1459
|
}
|
|
1414
1460
|
};
|
|
1415
1461
|
var NonNumericIdentificationKeyCreator = class extends (0, import_ts_mixer.Mixin)(NonNumericIdentificationKeyValidator, AbstractIdentificationKeyCreator) {
|
|
@@ -1448,15 +1494,36 @@ var NonNumericIdentificationKeyCreator = class extends (0, import_ts_mixer.Mixin
|
|
|
1448
1494
|
})
|
|
1449
1495
|
};
|
|
1450
1496
|
}
|
|
1451
|
-
|
|
1497
|
+
/**
|
|
1498
|
+
* Get the reference validation parameters.
|
|
1499
|
+
*/
|
|
1500
|
+
get referenceValidation() {
|
|
1501
|
+
return this._referenceValidation;
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* Create identification key(s) with reference(s).
|
|
1505
|
+
*
|
|
1506
|
+
* @param referenceOrReferences
|
|
1507
|
+
* Reference(s).
|
|
1508
|
+
*
|
|
1509
|
+
* @returns
|
|
1510
|
+
* Identification key(s).
|
|
1511
|
+
*/
|
|
1452
1512
|
create(referenceOrReferences) {
|
|
1453
1513
|
let result;
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1514
|
+
const referenceCreator = this.referenceCreator;
|
|
1515
|
+
const referenceValidation = this.referenceValidation;
|
|
1516
|
+
const prefix = this.prefix;
|
|
1517
|
+
const requiresCheckCharacterPair = this.requiresCheckCharacterPair;
|
|
1518
|
+
function validateAndCreate(reference) {
|
|
1519
|
+
referenceCreator.validate(reference, referenceValidation);
|
|
1520
|
+
const partialIdentificationKey = prefix + reference;
|
|
1521
|
+
return requiresCheckCharacterPair ? partialIdentificationKey + checkCharacterPair(partialIdentificationKey) : partialIdentificationKey;
|
|
1522
|
+
}
|
|
1523
|
+
if (typeof referenceOrReferences !== "object") {
|
|
1524
|
+
result = validateAndCreate(referenceOrReferences);
|
|
1458
1525
|
} else {
|
|
1459
|
-
result = import_utility3.IteratorProxy.from(referenceOrReferences).map(
|
|
1526
|
+
result = import_utility3.IteratorProxy.from(referenceOrReferences).map(validateAndCreate);
|
|
1460
1527
|
}
|
|
1461
1528
|
return result;
|
|
1462
1529
|
}
|
|
@@ -1938,7 +2005,7 @@ var PrefixManager = class _PrefixManager {
|
|
|
1938
2005
|
AI39_CREATOR,
|
|
1939
2006
|
AI82_CREATOR,
|
|
1940
2007
|
CPID_VALIDATOR,
|
|
1941
|
-
|
|
2008
|
+
ContentCharacterSet,
|
|
1942
2009
|
GCN_VALIDATOR,
|
|
1943
2010
|
GDTI_VALIDATOR,
|
|
1944
2011
|
GIAI_VALIDATOR,
|
|
@@ -1972,6 +2039,7 @@ var PrefixManager = class _PrefixManager {
|
|
|
1972
2039
|
checkDigitSum,
|
|
1973
2040
|
fiveDigitPriceWeightCheckDigit,
|
|
1974
2041
|
fourDigitPriceWeightCheckDigit,
|
|
2042
|
+
gs1NS,
|
|
1975
2043
|
hasValidCheckCharacterPair,
|
|
1976
2044
|
hasValidCheckDigit
|
|
1977
2045
|
});
|