@aidc-toolkit/gs1 0.9.6-beta → 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 +92 -92
- package/dist/index.d.cts +14 -12
- package/dist/index.d.ts +14 -12
- package/dist/index.js +90 -91
- package/package.json +6 -6
- package/src/idkey.ts +22 -22
- package/src/index.ts +1 -0
- package/test/idkey.test.ts +25 -25
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,
|
|
@@ -2006,7 +2005,7 @@ var PrefixManager = class _PrefixManager {
|
|
|
2006
2005
|
AI39_CREATOR,
|
|
2007
2006
|
AI82_CREATOR,
|
|
2008
2007
|
CPID_VALIDATOR,
|
|
2009
|
-
|
|
2008
|
+
ContentCharacterSet,
|
|
2010
2009
|
GCN_VALIDATOR,
|
|
2011
2010
|
GDTI_VALIDATOR,
|
|
2012
2011
|
GIAI_VALIDATOR,
|
|
@@ -2040,6 +2039,7 @@ var PrefixManager = class _PrefixManager {
|
|
|
2040
2039
|
checkDigitSum,
|
|
2041
2040
|
fiveDigitPriceWeightCheckDigit,
|
|
2042
2041
|
fourDigitPriceWeightCheckDigit,
|
|
2042
|
+
gs1NS,
|
|
2043
2043
|
hasValidCheckCharacterPair,
|
|
2044
2044
|
hasValidCheckDigit
|
|
2045
2045
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CharacterSetCreator, StringValidation, StringValidator, CharacterSetValidation, Exclusion, TransformerInput, TransformerOutput } from '@aidc-toolkit/utility';
|
|
2
2
|
import * as ts_mixer_dist_types_types_js from 'ts-mixer/dist/types/types.js';
|
|
3
3
|
|
|
4
|
+
declare const gs1NS = "aidct_gs1";
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* GS1 AI encodable character set 82 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
|
|
6
8
|
* General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
|
|
@@ -165,7 +167,7 @@ declare enum PrefixType {
|
|
|
165
167
|
* Character set supported by the reference portion of an identification key or the serial component of a numeric
|
|
166
168
|
* identification key.
|
|
167
169
|
*/
|
|
168
|
-
declare enum
|
|
170
|
+
declare enum ContentCharacterSet {
|
|
169
171
|
/**
|
|
170
172
|
* Numeric.
|
|
171
173
|
*/
|
|
@@ -212,7 +214,7 @@ interface IdentificationKeyValidator<V extends IdentificationKeyValidation = Ide
|
|
|
212
214
|
/**
|
|
213
215
|
* Get the reference character set.
|
|
214
216
|
*/
|
|
215
|
-
get referenceCharacterSet():
|
|
217
|
+
get referenceCharacterSet(): ContentCharacterSet;
|
|
216
218
|
/**
|
|
217
219
|
* Get the reference validator.
|
|
218
220
|
*/
|
|
@@ -262,7 +264,7 @@ declare abstract class AbstractIdentificationKeyValidator<V extends Identificati
|
|
|
262
264
|
* @returns
|
|
263
265
|
* Character set creator.
|
|
264
266
|
*/
|
|
265
|
-
protected static creatorFor(characterSet:
|
|
267
|
+
protected static creatorFor(characterSet: ContentCharacterSet): CharacterSetCreator;
|
|
266
268
|
/**
|
|
267
269
|
* Constructor.
|
|
268
270
|
*
|
|
@@ -278,7 +280,7 @@ declare abstract class AbstractIdentificationKeyValidator<V extends Identificati
|
|
|
278
280
|
* @param referenceCharacterSet
|
|
279
281
|
* Reference character set.
|
|
280
282
|
*/
|
|
281
|
-
protected constructor(identificationKeyType: IdentificationKeyType, prefixType: PrefixType, length: number, referenceCharacterSet:
|
|
283
|
+
protected constructor(identificationKeyType: IdentificationKeyType, prefixType: PrefixType, length: number, referenceCharacterSet: ContentCharacterSet);
|
|
282
284
|
/**
|
|
283
285
|
* @inheritDoc
|
|
284
286
|
*/
|
|
@@ -294,7 +296,7 @@ declare abstract class AbstractIdentificationKeyValidator<V extends Identificati
|
|
|
294
296
|
/**
|
|
295
297
|
* @inheritDoc
|
|
296
298
|
*/
|
|
297
|
-
get referenceCharacterSet():
|
|
299
|
+
get referenceCharacterSet(): ContentCharacterSet;
|
|
298
300
|
/**
|
|
299
301
|
* @inheritDoc
|
|
300
302
|
*/
|
|
@@ -532,7 +534,7 @@ declare class SerializableNumericIdentificationKeyValidator extends NonGTINNumer
|
|
|
532
534
|
* @param serialComponentCharacterSet
|
|
533
535
|
* Serial component character set.
|
|
534
536
|
*/
|
|
535
|
-
constructor(identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet:
|
|
537
|
+
constructor(identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet: ContentCharacterSet);
|
|
536
538
|
/**
|
|
537
539
|
* Get the serial component length.
|
|
538
540
|
*/
|
|
@@ -540,7 +542,7 @@ declare class SerializableNumericIdentificationKeyValidator extends NonGTINNumer
|
|
|
540
542
|
/**
|
|
541
543
|
* Get the serial component character set.
|
|
542
544
|
*/
|
|
543
|
-
get serialComponentCharacterSet():
|
|
545
|
+
get serialComponentCharacterSet(): ContentCharacterSet;
|
|
544
546
|
/**
|
|
545
547
|
* Get the serial component validation parameters.
|
|
546
548
|
*/
|
|
@@ -591,7 +593,7 @@ declare class NonNumericIdentificationKeyValidator extends AbstractIdentificatio
|
|
|
591
593
|
* @param requiresCheckCharacterPair
|
|
592
594
|
* True if the identification key requires a check character pair.
|
|
593
595
|
*/
|
|
594
|
-
constructor(identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet:
|
|
596
|
+
constructor(identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair?: boolean);
|
|
595
597
|
/**
|
|
596
598
|
* Determine if the identification key requires a check character pair.
|
|
597
599
|
*/
|
|
@@ -718,7 +720,7 @@ declare abstract class AbstractIdentificationKeyCreator implements Identificatio
|
|
|
718
720
|
abstract get identificationKeyType(): IdentificationKeyType;
|
|
719
721
|
abstract get prefixType(): PrefixType;
|
|
720
722
|
abstract get length(): number;
|
|
721
|
-
abstract get referenceCharacterSet():
|
|
723
|
+
abstract get referenceCharacterSet(): ContentCharacterSet;
|
|
722
724
|
abstract get referenceCreator(): CharacterSetCreator;
|
|
723
725
|
/**
|
|
724
726
|
* @inheritDoc
|
|
@@ -974,7 +976,7 @@ declare class SerializableNumericIdentificationKeyCreator extends SerializableNu
|
|
|
974
976
|
* @param serialComponentCharacterSet
|
|
975
977
|
* Serial component character set.
|
|
976
978
|
*/
|
|
977
|
-
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet:
|
|
979
|
+
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet: ContentCharacterSet);
|
|
978
980
|
/**
|
|
979
981
|
* Concatenate a validated base identification key with serial component(s).
|
|
980
982
|
*
|
|
@@ -1047,7 +1049,7 @@ declare class NonNumericIdentificationKeyCreator extends NonNumericIdentificatio
|
|
|
1047
1049
|
* @param requiresCheckCharacterPair
|
|
1048
1050
|
* True if the identification key requires a check character pair.
|
|
1049
1051
|
*/
|
|
1050
|
-
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet:
|
|
1052
|
+
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair?: boolean);
|
|
1051
1053
|
/**
|
|
1052
1054
|
* Get the reference validation parameters.
|
|
1053
1055
|
*/
|
|
@@ -1346,4 +1348,4 @@ declare class PrefixManager {
|
|
|
1346
1348
|
get gmnCreator(): NonNumericIdentificationKeyCreator;
|
|
1347
1349
|
}
|
|
1348
1350
|
|
|
1349
|
-
export { AI39_CREATOR, AI82_CREATOR, CPID_VALIDATOR,
|
|
1351
|
+
export { AI39_CREATOR, AI82_CREATOR, CPID_VALIDATOR, ContentCharacterSet, GCN_VALIDATOR, GDTI_VALIDATOR, GIAI_VALIDATOR, GINC_VALIDATOR, GLN_VALIDATOR, GMN_VALIDATOR, GRAI_VALIDATOR, GSIN_VALIDATOR, GSRN_VALIDATOR, GTIN12_VALIDATOR, GTIN13_VALIDATOR, GTIN8_VALIDATOR, GTINCreator, GTINLevel, GTINType, GTINValidator, GTIN_VALIDATORS, type IdentificationKeyCreator, IdentificationKeyType, type IdentificationKeyValidation, type IdentificationKeyValidator, LeaderType, NonGTINNumericIdentificationKeyCreator, NonGTINNumericIdentificationKeyValidator, NonNumericIdentificationKeyCreator, type NonNumericIdentificationKeyValidation, NonNumericIdentificationKeyValidator, type NumericIdentificationKeyCreator, type NumericIdentificationKeyValidator, PrefixManager, PrefixType, SSCC_VALIDATOR, SerializableNumericIdentificationKeyCreator, SerializableNumericIdentificationKeyValidator, checkCharacterPair, checkDigit, checkDigitSum, fiveDigitPriceWeightCheckDigit, fourDigitPriceWeightCheckDigit, gs1NS, hasValidCheckCharacterPair, hasValidCheckDigit };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CharacterSetCreator, StringValidation, StringValidator, CharacterSetValidation, Exclusion, TransformerInput, TransformerOutput } from '@aidc-toolkit/utility';
|
|
2
2
|
import * as ts_mixer_dist_types_types_js from 'ts-mixer/dist/types/types.js';
|
|
3
3
|
|
|
4
|
+
declare const gs1NS = "aidct_gs1";
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* GS1 AI encodable character set 82 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
|
|
6
8
|
* General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
|
|
@@ -165,7 +167,7 @@ declare enum PrefixType {
|
|
|
165
167
|
* Character set supported by the reference portion of an identification key or the serial component of a numeric
|
|
166
168
|
* identification key.
|
|
167
169
|
*/
|
|
168
|
-
declare enum
|
|
170
|
+
declare enum ContentCharacterSet {
|
|
169
171
|
/**
|
|
170
172
|
* Numeric.
|
|
171
173
|
*/
|
|
@@ -212,7 +214,7 @@ interface IdentificationKeyValidator<V extends IdentificationKeyValidation = Ide
|
|
|
212
214
|
/**
|
|
213
215
|
* Get the reference character set.
|
|
214
216
|
*/
|
|
215
|
-
get referenceCharacterSet():
|
|
217
|
+
get referenceCharacterSet(): ContentCharacterSet;
|
|
216
218
|
/**
|
|
217
219
|
* Get the reference validator.
|
|
218
220
|
*/
|
|
@@ -262,7 +264,7 @@ declare abstract class AbstractIdentificationKeyValidator<V extends Identificati
|
|
|
262
264
|
* @returns
|
|
263
265
|
* Character set creator.
|
|
264
266
|
*/
|
|
265
|
-
protected static creatorFor(characterSet:
|
|
267
|
+
protected static creatorFor(characterSet: ContentCharacterSet): CharacterSetCreator;
|
|
266
268
|
/**
|
|
267
269
|
* Constructor.
|
|
268
270
|
*
|
|
@@ -278,7 +280,7 @@ declare abstract class AbstractIdentificationKeyValidator<V extends Identificati
|
|
|
278
280
|
* @param referenceCharacterSet
|
|
279
281
|
* Reference character set.
|
|
280
282
|
*/
|
|
281
|
-
protected constructor(identificationKeyType: IdentificationKeyType, prefixType: PrefixType, length: number, referenceCharacterSet:
|
|
283
|
+
protected constructor(identificationKeyType: IdentificationKeyType, prefixType: PrefixType, length: number, referenceCharacterSet: ContentCharacterSet);
|
|
282
284
|
/**
|
|
283
285
|
* @inheritDoc
|
|
284
286
|
*/
|
|
@@ -294,7 +296,7 @@ declare abstract class AbstractIdentificationKeyValidator<V extends Identificati
|
|
|
294
296
|
/**
|
|
295
297
|
* @inheritDoc
|
|
296
298
|
*/
|
|
297
|
-
get referenceCharacterSet():
|
|
299
|
+
get referenceCharacterSet(): ContentCharacterSet;
|
|
298
300
|
/**
|
|
299
301
|
* @inheritDoc
|
|
300
302
|
*/
|
|
@@ -532,7 +534,7 @@ declare class SerializableNumericIdentificationKeyValidator extends NonGTINNumer
|
|
|
532
534
|
* @param serialComponentCharacterSet
|
|
533
535
|
* Serial component character set.
|
|
534
536
|
*/
|
|
535
|
-
constructor(identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet:
|
|
537
|
+
constructor(identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet: ContentCharacterSet);
|
|
536
538
|
/**
|
|
537
539
|
* Get the serial component length.
|
|
538
540
|
*/
|
|
@@ -540,7 +542,7 @@ declare class SerializableNumericIdentificationKeyValidator extends NonGTINNumer
|
|
|
540
542
|
/**
|
|
541
543
|
* Get the serial component character set.
|
|
542
544
|
*/
|
|
543
|
-
get serialComponentCharacterSet():
|
|
545
|
+
get serialComponentCharacterSet(): ContentCharacterSet;
|
|
544
546
|
/**
|
|
545
547
|
* Get the serial component validation parameters.
|
|
546
548
|
*/
|
|
@@ -591,7 +593,7 @@ declare class NonNumericIdentificationKeyValidator extends AbstractIdentificatio
|
|
|
591
593
|
* @param requiresCheckCharacterPair
|
|
592
594
|
* True if the identification key requires a check character pair.
|
|
593
595
|
*/
|
|
594
|
-
constructor(identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet:
|
|
596
|
+
constructor(identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair?: boolean);
|
|
595
597
|
/**
|
|
596
598
|
* Determine if the identification key requires a check character pair.
|
|
597
599
|
*/
|
|
@@ -718,7 +720,7 @@ declare abstract class AbstractIdentificationKeyCreator implements Identificatio
|
|
|
718
720
|
abstract get identificationKeyType(): IdentificationKeyType;
|
|
719
721
|
abstract get prefixType(): PrefixType;
|
|
720
722
|
abstract get length(): number;
|
|
721
|
-
abstract get referenceCharacterSet():
|
|
723
|
+
abstract get referenceCharacterSet(): ContentCharacterSet;
|
|
722
724
|
abstract get referenceCreator(): CharacterSetCreator;
|
|
723
725
|
/**
|
|
724
726
|
* @inheritDoc
|
|
@@ -974,7 +976,7 @@ declare class SerializableNumericIdentificationKeyCreator extends SerializableNu
|
|
|
974
976
|
* @param serialComponentCharacterSet
|
|
975
977
|
* Serial component character set.
|
|
976
978
|
*/
|
|
977
|
-
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet:
|
|
979
|
+
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet: ContentCharacterSet);
|
|
978
980
|
/**
|
|
979
981
|
* Concatenate a validated base identification key with serial component(s).
|
|
980
982
|
*
|
|
@@ -1047,7 +1049,7 @@ declare class NonNumericIdentificationKeyCreator extends NonNumericIdentificatio
|
|
|
1047
1049
|
* @param requiresCheckCharacterPair
|
|
1048
1050
|
* True if the identification key requires a check character pair.
|
|
1049
1051
|
*/
|
|
1050
|
-
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet:
|
|
1052
|
+
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair?: boolean);
|
|
1051
1053
|
/**
|
|
1052
1054
|
* Get the reference validation parameters.
|
|
1053
1055
|
*/
|
|
@@ -1346,4 +1348,4 @@ declare class PrefixManager {
|
|
|
1346
1348
|
get gmnCreator(): NonNumericIdentificationKeyCreator;
|
|
1347
1349
|
}
|
|
1348
1350
|
|
|
1349
|
-
export { AI39_CREATOR, AI82_CREATOR, CPID_VALIDATOR,
|
|
1351
|
+
export { AI39_CREATOR, AI82_CREATOR, CPID_VALIDATOR, ContentCharacterSet, GCN_VALIDATOR, GDTI_VALIDATOR, GIAI_VALIDATOR, GINC_VALIDATOR, GLN_VALIDATOR, GMN_VALIDATOR, GRAI_VALIDATOR, GSIN_VALIDATOR, GSRN_VALIDATOR, GTIN12_VALIDATOR, GTIN13_VALIDATOR, GTIN8_VALIDATOR, GTINCreator, GTINLevel, GTINType, GTINValidator, GTIN_VALIDATORS, type IdentificationKeyCreator, IdentificationKeyType, type IdentificationKeyValidation, type IdentificationKeyValidator, LeaderType, NonGTINNumericIdentificationKeyCreator, NonGTINNumericIdentificationKeyValidator, NonNumericIdentificationKeyCreator, type NonNumericIdentificationKeyValidation, NonNumericIdentificationKeyValidator, type NumericIdentificationKeyCreator, type NumericIdentificationKeyValidator, PrefixManager, PrefixType, SSCC_VALIDATOR, SerializableNumericIdentificationKeyCreator, SerializableNumericIdentificationKeyValidator, checkCharacterPair, checkDigit, checkDigitSum, fiveDigitPriceWeightCheckDigit, fourDigitPriceWeightCheckDigit, gs1NS, hasValidCheckCharacterPair, hasValidCheckDigit };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,85 @@
|
|
|
1
|
+
// src/locale/i18n.ts
|
|
2
|
+
import { i18nAddResourceBundle, i18nAssertValidResources, i18next } from "@aidc-toolkit/core";
|
|
3
|
+
|
|
4
|
+
// src/locale/en/locale_strings.ts
|
|
5
|
+
var localeStrings = {
|
|
6
|
+
Check: {
|
|
7
|
+
lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}"
|
|
8
|
+
},
|
|
9
|
+
IdentificationKey: {
|
|
10
|
+
identificationKeyTypeLength: "{{identificationKeyType}} must be {{length}} digits long",
|
|
11
|
+
invalidCheckDigit: "Invalid check digit",
|
|
12
|
+
invalidGTINLength: "GTIN must be 13, 12, 8, or 14 digits long",
|
|
13
|
+
invalidGTIN14Length: "GTIN must be 14 digits long",
|
|
14
|
+
invalidZeroSuppressedGTIN12: "Invalid zero-suppressed GTIN-12",
|
|
15
|
+
invalidZeroSuppressibleGTIN12: "GTIN-12 not zero-suppressible",
|
|
16
|
+
invalidZeroSuppressedGTIN12AsGTIN13: "Invalid zero-suppressed GTIN-12 as GTIN-13",
|
|
17
|
+
invalidZeroSuppressedGTIN12AsGTIN14: "Invalid zero-suppressed GTIN-12 as GTIN-14",
|
|
18
|
+
invalidGTIN13AtRetail: "GTIN-13 at retail consumer trade item level can't start with zero",
|
|
19
|
+
invalidGTINAtRetail: "GTIN not supported at retail consumer trade item level",
|
|
20
|
+
invalidGTINAtOtherThanRetail: "GTIN not supported at other than retail consumer trade item level",
|
|
21
|
+
indicatorDigit: "indicator digit",
|
|
22
|
+
serialComponent: "serial component",
|
|
23
|
+
reference: "reference",
|
|
24
|
+
referenceCantBeAllNumeric: "Reference can't be all-numeric",
|
|
25
|
+
invalidCheckCharacterPair: "Invalid check character pair"
|
|
26
|
+
},
|
|
27
|
+
Prefix: {
|
|
28
|
+
gs1CompanyPrefix: "GS1 Company Prefix",
|
|
29
|
+
upcCompanyPrefix: "U.P.C. Company Prefix",
|
|
30
|
+
gs18Prefix: "GS1-8 Prefix",
|
|
31
|
+
gs1CompanyPrefixCantStartWith0: `GS1 Company Prefix can't start with "0"`,
|
|
32
|
+
gs1CompanyPrefixCantStartWith00000: `GS1 Company Prefix can't start with "00000"`,
|
|
33
|
+
gs1CompanyPrefixCantStartWith000000: `GS1 Company Prefix can't start with "000000"`,
|
|
34
|
+
upcCompanyPrefixCantStartWith0000: `U.P.C. Company Prefix can't start with "0000"`,
|
|
35
|
+
gs18PrefixCantStartWith0: `GS1-8 Prefix can't start with "0"`,
|
|
36
|
+
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} not supported by GS1-8 Prefix"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/locale/fr/locale_strings.ts
|
|
41
|
+
var localeStrings2 = {
|
|
42
|
+
Check: {
|
|
43
|
+
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}}"
|
|
44
|
+
},
|
|
45
|
+
IdentificationKey: {
|
|
46
|
+
identificationKeyTypeLength: "{{identificationKeyType}} doit comporter {{length}} chiffres",
|
|
47
|
+
invalidCheckDigit: "Chiffre de contr\xF4le non valide",
|
|
48
|
+
invalidGTINLength: "Le GTIN doit comporter 13, 12, 8 ou 14 chiffres",
|
|
49
|
+
invalidGTIN14Length: "Le GTIN doit comporter 14 chiffres",
|
|
50
|
+
invalidZeroSuppressedGTIN12: "Code GTIN-12 non valide avec z\xE9ro supprim\xE9",
|
|
51
|
+
invalidZeroSuppressibleGTIN12: "Le GTIN-12 ne peut pas \xEAtre supprim\xE9 par z\xE9ro",
|
|
52
|
+
invalidZeroSuppressedGTIN12AsGTIN13: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-13",
|
|
53
|
+
invalidZeroSuppressedGTIN12AsGTIN14: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-14",
|
|
54
|
+
invalidGTIN13AtRetail: "Le GTIN-13 au niveau des articles de consommation au d\xE9tail ne peut pas commencer par z\xE9ro",
|
|
55
|
+
invalidGTINAtRetail: "Le GTIN n'est pas pris en charge au niveau des articles de consommation au d\xE9tail",
|
|
56
|
+
invalidGTINAtOtherThanRetail: "Le GTIN n'est pas pris en charge \xE0 d'autres niveaux que ceux des articles de consommation au d\xE9tail",
|
|
57
|
+
indicatorDigit: "chiffre indicateur",
|
|
58
|
+
serialComponent: "composant s\xE9rie",
|
|
59
|
+
reference: "r\xE9f\xE9rence",
|
|
60
|
+
referenceCantBeAllNumeric: "La r\xE9f\xE9rence ne peut pas \xEAtre enti\xE8rement num\xE9rique",
|
|
61
|
+
invalidCheckCharacterPair: "Paire de caract\xE8res de contr\xF4le non valide"
|
|
62
|
+
},
|
|
63
|
+
Prefix: {
|
|
64
|
+
gs1CompanyPrefix: "Pr\xE9fixe de l'entreprise GS1",
|
|
65
|
+
upcCompanyPrefix: "Pr\xE9fixe de l'entreprise U.P.C.",
|
|
66
|
+
gs18Prefix: "Pr\xE9fixe GS1-8",
|
|
67
|
+
gs1CompanyPrefixCantStartWith0: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "0"`,
|
|
68
|
+
gs1CompanyPrefixCantStartWith00000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "00000"`,
|
|
69
|
+
gs1CompanyPrefixCantStartWith000000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "000000"`,
|
|
70
|
+
upcCompanyPrefixCantStartWith0000: `Le pr\xE9fixe de l'entreprise U.P.C. ne peut pas commencer par "0000"`,
|
|
71
|
+
gs18PrefixCantStartWith0: 'Le pr\xE9fixe GS1-8 ne peut pas commencer par "0"',
|
|
72
|
+
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} non pris en charge par le pr\xE9fixe GS1-8"
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/locale/i18n.ts
|
|
77
|
+
var gs1NS = "aidct_gs1";
|
|
78
|
+
i18nAssertValidResources(localeStrings, "fr", localeStrings2);
|
|
79
|
+
i18nAddResourceBundle("en", gs1NS, localeStrings);
|
|
80
|
+
i18nAddResourceBundle("fr", gs1NS, localeStrings2);
|
|
81
|
+
var i18n_default = i18next;
|
|
82
|
+
|
|
1
83
|
// src/character_set.ts
|
|
2
84
|
import { CharacterSetCreator, Exclusion } from "@aidc-toolkit/utility";
|
|
3
85
|
var AI82_CREATOR = new CharacterSetCreator([
|
|
@@ -128,90 +210,6 @@ var AI39_CREATOR = new CharacterSetCreator([
|
|
|
128
210
|
|
|
129
211
|
// src/check.ts
|
|
130
212
|
import { NUMERIC_CREATOR } from "@aidc-toolkit/utility";
|
|
131
|
-
|
|
132
|
-
// src/locale/i18n.ts
|
|
133
|
-
import { i18nAddResourceBundle, i18nAssertValidResources, i18next } from "@aidc-toolkit/core";
|
|
134
|
-
|
|
135
|
-
// src/locale/en/locale_strings.ts
|
|
136
|
-
var localeStrings = {
|
|
137
|
-
Check: {
|
|
138
|
-
lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}"
|
|
139
|
-
},
|
|
140
|
-
IdentificationKey: {
|
|
141
|
-
identificationKeyTypeLength: "{{identificationKeyType}} must be {{length}} digits long",
|
|
142
|
-
invalidCheckDigit: "Invalid check digit",
|
|
143
|
-
invalidGTINLength: "GTIN must be 13, 12, 8, or 14 digits long",
|
|
144
|
-
invalidGTIN14Length: "GTIN must be 14 digits long",
|
|
145
|
-
invalidZeroSuppressedGTIN12: "Invalid zero-suppressed GTIN-12",
|
|
146
|
-
invalidZeroSuppressibleGTIN12: "GTIN-12 not zero-suppressible",
|
|
147
|
-
invalidZeroSuppressedGTIN12AsGTIN13: "Invalid zero-suppressed GTIN-12 as GTIN-13",
|
|
148
|
-
invalidZeroSuppressedGTIN12AsGTIN14: "Invalid zero-suppressed GTIN-12 as GTIN-14",
|
|
149
|
-
invalidGTIN13AtRetail: "GTIN-13 at retail consumer trade item level can't start with zero",
|
|
150
|
-
invalidGTINAtRetail: "GTIN not supported at retail consumer trade item level",
|
|
151
|
-
invalidGTINAtOtherThanRetail: "GTIN not supported at other than retail consumer trade item level",
|
|
152
|
-
indicatorDigit: "indicator digit",
|
|
153
|
-
serialComponent: "serial component",
|
|
154
|
-
reference: "reference",
|
|
155
|
-
referenceCantBeAllNumeric: "Reference can't be all-numeric",
|
|
156
|
-
invalidCheckCharacterPair: "Invalid check character pair"
|
|
157
|
-
},
|
|
158
|
-
Prefix: {
|
|
159
|
-
gs1CompanyPrefix: "GS1 Company Prefix",
|
|
160
|
-
upcCompanyPrefix: "U.P.C. Company Prefix",
|
|
161
|
-
gs18Prefix: "GS1-8 Prefix",
|
|
162
|
-
gs1CompanyPrefixCantStartWith0: `GS1 Company Prefix can't start with "0"`,
|
|
163
|
-
gs1CompanyPrefixCantStartWith00000: `GS1 Company Prefix can't start with "00000"`,
|
|
164
|
-
gs1CompanyPrefixCantStartWith000000: `GS1 Company Prefix can't start with "000000"`,
|
|
165
|
-
upcCompanyPrefixCantStartWith0000: `U.P.C. Company Prefix can't start with "0000"`,
|
|
166
|
-
gs18PrefixCantStartWith0: `GS1-8 Prefix can't start with "0"`,
|
|
167
|
-
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} not supported by GS1-8 Prefix"
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// src/locale/fr/locale_strings.ts
|
|
172
|
-
var localeStrings2 = {
|
|
173
|
-
Check: {
|
|
174
|
-
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}}"
|
|
175
|
-
},
|
|
176
|
-
IdentificationKey: {
|
|
177
|
-
identificationKeyTypeLength: "{{identificationKeyType}} doit comporter {{length}} chiffres",
|
|
178
|
-
invalidCheckDigit: "Chiffre de contr\xF4le non valide",
|
|
179
|
-
invalidGTINLength: "Le GTIN doit comporter 13, 12, 8 ou 14 chiffres",
|
|
180
|
-
invalidGTIN14Length: "Le GTIN doit comporter 14 chiffres",
|
|
181
|
-
invalidZeroSuppressedGTIN12: "Code GTIN-12 non valide avec z\xE9ro supprim\xE9",
|
|
182
|
-
invalidZeroSuppressibleGTIN12: "Le GTIN-12 ne peut pas \xEAtre supprim\xE9 par z\xE9ro",
|
|
183
|
-
invalidZeroSuppressedGTIN12AsGTIN13: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-13",
|
|
184
|
-
invalidZeroSuppressedGTIN12AsGTIN14: "GTIN-12 non valide avec z\xE9ro supprim\xE9 en tant que GTIN-14",
|
|
185
|
-
invalidGTIN13AtRetail: "Le GTIN-13 au niveau des articles de consommation au d\xE9tail ne peut pas commencer par z\xE9ro",
|
|
186
|
-
invalidGTINAtRetail: "Le GTIN n'est pas pris en charge au niveau des articles de consommation au d\xE9tail",
|
|
187
|
-
invalidGTINAtOtherThanRetail: "Le GTIN n'est pas pris en charge \xE0 d'autres niveaux que ceux des articles de consommation au d\xE9tail",
|
|
188
|
-
indicatorDigit: "chiffre indicateur",
|
|
189
|
-
serialComponent: "composant s\xE9rie",
|
|
190
|
-
reference: "r\xE9f\xE9rence",
|
|
191
|
-
referenceCantBeAllNumeric: "La r\xE9f\xE9rence ne peut pas \xEAtre enti\xE8rement num\xE9rique",
|
|
192
|
-
invalidCheckCharacterPair: "Paire de caract\xE8res de contr\xF4le non valide"
|
|
193
|
-
},
|
|
194
|
-
Prefix: {
|
|
195
|
-
gs1CompanyPrefix: "Pr\xE9fixe de l'entreprise GS1",
|
|
196
|
-
upcCompanyPrefix: "Pr\xE9fixe de l'entreprise U.P.C.",
|
|
197
|
-
gs18Prefix: "Pr\xE9fixe GS1-8",
|
|
198
|
-
gs1CompanyPrefixCantStartWith0: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "0"`,
|
|
199
|
-
gs1CompanyPrefixCantStartWith00000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "00000"`,
|
|
200
|
-
gs1CompanyPrefixCantStartWith000000: `Le pr\xE9fixe de l'entreprise GS1 ne peut pas commencer par "000000"`,
|
|
201
|
-
upcCompanyPrefixCantStartWith0000: `Le pr\xE9fixe de l'entreprise U.P.C. ne peut pas commencer par "0000"`,
|
|
202
|
-
gs18PrefixCantStartWith0: 'Le pr\xE9fixe GS1-8 ne peut pas commencer par "0"',
|
|
203
|
-
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} non pris en charge par le pr\xE9fixe GS1-8"
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
// src/locale/i18n.ts
|
|
208
|
-
var gs1NS = "aidct_gs1";
|
|
209
|
-
i18nAssertValidResources(localeStrings, "fr", localeStrings2);
|
|
210
|
-
i18nAddResourceBundle("en", gs1NS, localeStrings);
|
|
211
|
-
i18nAddResourceBundle("fr", gs1NS, localeStrings2);
|
|
212
|
-
var i18n_default = i18next;
|
|
213
|
-
|
|
214
|
-
// src/check.ts
|
|
215
213
|
var THREE_WEIGHT_RESULTS = [
|
|
216
214
|
0,
|
|
217
215
|
3,
|
|
@@ -423,12 +421,12 @@ var PrefixType = /* @__PURE__ */ ((PrefixType2) => {
|
|
|
423
421
|
PrefixType2[PrefixType2["GS18Prefix"] = 2] = "GS18Prefix";
|
|
424
422
|
return PrefixType2;
|
|
425
423
|
})(PrefixType || {});
|
|
426
|
-
var
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
return
|
|
431
|
-
})(
|
|
424
|
+
var ContentCharacterSet = /* @__PURE__ */ ((ContentCharacterSet2) => {
|
|
425
|
+
ContentCharacterSet2[ContentCharacterSet2["Numeric"] = 0] = "Numeric";
|
|
426
|
+
ContentCharacterSet2[ContentCharacterSet2["AI82"] = 1] = "AI82";
|
|
427
|
+
ContentCharacterSet2[ContentCharacterSet2["AI39"] = 2] = "AI39";
|
|
428
|
+
return ContentCharacterSet2;
|
|
429
|
+
})(ContentCharacterSet || {});
|
|
432
430
|
var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidator {
|
|
433
431
|
static CHARACTER_SET_CREATORS = [
|
|
434
432
|
NUMERIC_CREATOR2,
|
|
@@ -1947,7 +1945,7 @@ export {
|
|
|
1947
1945
|
AI39_CREATOR,
|
|
1948
1946
|
AI82_CREATOR,
|
|
1949
1947
|
CPID_VALIDATOR,
|
|
1950
|
-
|
|
1948
|
+
ContentCharacterSet,
|
|
1951
1949
|
GCN_VALIDATOR,
|
|
1952
1950
|
GDTI_VALIDATOR,
|
|
1953
1951
|
GIAI_VALIDATOR,
|
|
@@ -1981,6 +1979,7 @@ export {
|
|
|
1981
1979
|
checkDigitSum,
|
|
1982
1980
|
fiveDigitPriceWeightCheckDigit,
|
|
1983
1981
|
fourDigitPriceWeightCheckDigit,
|
|
1982
|
+
gs1NS,
|
|
1984
1983
|
hasValidCheckCharacterPair,
|
|
1985
1984
|
hasValidCheckDigit
|
|
1986
1985
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidc-toolkit/gs1",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7-beta",
|
|
4
4
|
"description": "GS1 AIDC Toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"test": "vitest run"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@aidc-toolkit/dev": "^0.9.
|
|
28
|
+
"@aidc-toolkit/dev": "^0.9.7-beta",
|
|
29
29
|
"eslint": "^9.16.0",
|
|
30
30
|
"ts-node": "^10.9.2",
|
|
31
31
|
"tsup": "^8.3.5",
|
|
32
32
|
"typescript": "^5.7.2",
|
|
33
|
-
"vitest": "^2.1.
|
|
33
|
+
"vitest": "^2.1.8"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@aidc-toolkit/core": "^0.9.
|
|
37
|
-
"@aidc-toolkit/utility": "^0.9.
|
|
38
|
-
"@rollup/rollup-linux-x64-gnu": "^4.28.
|
|
36
|
+
"@aidc-toolkit/core": "^0.9.7-beta",
|
|
37
|
+
"@aidc-toolkit/utility": "^0.9.7-beta",
|
|
38
|
+
"@rollup/rollup-linux-x64-gnu": "^4.28.1",
|
|
39
39
|
"ts-mixer": "^6.0.4"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/idkey.ts
CHANGED
|
@@ -110,7 +110,7 @@ export enum PrefixType {
|
|
|
110
110
|
* Character set supported by the reference portion of an identification key or the serial component of a numeric
|
|
111
111
|
* identification key.
|
|
112
112
|
*/
|
|
113
|
-
export enum
|
|
113
|
+
export enum ContentCharacterSet {
|
|
114
114
|
/**
|
|
115
115
|
* Numeric.
|
|
116
116
|
*/
|
|
@@ -164,7 +164,7 @@ export interface IdentificationKeyValidator<V extends IdentificationKeyValidatio
|
|
|
164
164
|
/**
|
|
165
165
|
* Get the reference character set.
|
|
166
166
|
*/
|
|
167
|
-
get referenceCharacterSet():
|
|
167
|
+
get referenceCharacterSet(): ContentCharacterSet;
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
170
|
* Get the reference validator.
|
|
@@ -209,7 +209,7 @@ abstract class AbstractIdentificationKeyValidator<V extends IdentificationKeyVal
|
|
|
209
209
|
/**
|
|
210
210
|
* Reference character set.
|
|
211
211
|
*/
|
|
212
|
-
private readonly _referenceCharacterSet:
|
|
212
|
+
private readonly _referenceCharacterSet: ContentCharacterSet;
|
|
213
213
|
|
|
214
214
|
/**
|
|
215
215
|
* Reference creator.
|
|
@@ -225,7 +225,7 @@ abstract class AbstractIdentificationKeyValidator<V extends IdentificationKeyVal
|
|
|
225
225
|
* @returns
|
|
226
226
|
* Character set creator.
|
|
227
227
|
*/
|
|
228
|
-
protected static creatorFor(characterSet:
|
|
228
|
+
protected static creatorFor(characterSet: ContentCharacterSet): CharacterSetCreator {
|
|
229
229
|
return AbstractIdentificationKeyValidator.CHARACTER_SET_CREATORS[characterSet];
|
|
230
230
|
}
|
|
231
231
|
|
|
@@ -244,7 +244,7 @@ abstract class AbstractIdentificationKeyValidator<V extends IdentificationKeyVal
|
|
|
244
244
|
* @param referenceCharacterSet
|
|
245
245
|
* Reference character set.
|
|
246
246
|
*/
|
|
247
|
-
protected constructor(identificationKeyType: IdentificationKeyType, prefixType: PrefixType, length: number, referenceCharacterSet:
|
|
247
|
+
protected constructor(identificationKeyType: IdentificationKeyType, prefixType: PrefixType, length: number, referenceCharacterSet: ContentCharacterSet) {
|
|
248
248
|
this._identificationKeyType = identificationKeyType;
|
|
249
249
|
this._prefixType = prefixType;
|
|
250
250
|
this._length = length;
|
|
@@ -276,7 +276,7 @@ abstract class AbstractIdentificationKeyValidator<V extends IdentificationKeyVal
|
|
|
276
276
|
/**
|
|
277
277
|
* @inheritDoc
|
|
278
278
|
*/
|
|
279
|
-
get referenceCharacterSet():
|
|
279
|
+
get referenceCharacterSet(): ContentCharacterSet {
|
|
280
280
|
return this._referenceCharacterSet;
|
|
281
281
|
}
|
|
282
282
|
|
|
@@ -316,7 +316,7 @@ abstract class AbstractIdentificationKeyValidator<V extends IdentificationKeyVal
|
|
|
316
316
|
*/
|
|
317
317
|
protected validatePrefix(partialIdentificationKey: string, positionOffset?: number): void {
|
|
318
318
|
// Delegate to prefix manager with support for U.P.C. Company Prefix but not GS1-8 Prefix.
|
|
319
|
-
PrefixManager.validatePrefix(this.prefixType, true, false, partialIdentificationKey, true, this.referenceCharacterSet ===
|
|
319
|
+
PrefixManager.validatePrefix(this.prefixType, true, false, partialIdentificationKey, true, this.referenceCharacterSet === ContentCharacterSet.Numeric, positionOffset);
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
abstract validate(identificationKey: string, validation?: V): void;
|
|
@@ -383,7 +383,7 @@ abstract class AbstractNumericIdentificationKeyValidator extends AbstractIdentif
|
|
|
383
383
|
* Leader type.
|
|
384
384
|
*/
|
|
385
385
|
protected constructor(identificationKeyType: IdentificationKeyType, prefixType: PrefixType, length: number, leaderType: LeaderType) {
|
|
386
|
-
super(identificationKeyType, prefixType, length,
|
|
386
|
+
super(identificationKeyType, prefixType, length, ContentCharacterSet.Numeric);
|
|
387
387
|
|
|
388
388
|
this._leaderType = leaderType;
|
|
389
389
|
this._prefixPosition = Number(this.leaderType === LeaderType.ExtensionDigit);
|
|
@@ -698,7 +698,7 @@ export class SerializableNumericIdentificationKeyValidator extends NonGTINNumeri
|
|
|
698
698
|
/**
|
|
699
699
|
* Serial component character set.
|
|
700
700
|
*/
|
|
701
|
-
private readonly _serialComponentCharacterSet:
|
|
701
|
+
private readonly _serialComponentCharacterSet: ContentCharacterSet;
|
|
702
702
|
|
|
703
703
|
/**
|
|
704
704
|
* Serial component validation parameters.
|
|
@@ -725,7 +725,7 @@ export class SerializableNumericIdentificationKeyValidator extends NonGTINNumeri
|
|
|
725
725
|
* @param serialComponentCharacterSet
|
|
726
726
|
* Serial component character set.
|
|
727
727
|
*/
|
|
728
|
-
constructor(identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet:
|
|
728
|
+
constructor(identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet: ContentCharacterSet) {
|
|
729
729
|
super(identificationKeyType, length, LeaderType.None);
|
|
730
730
|
|
|
731
731
|
this._serialComponentLength = serialComponentLength;
|
|
@@ -752,7 +752,7 @@ export class SerializableNumericIdentificationKeyValidator extends NonGTINNumeri
|
|
|
752
752
|
/**
|
|
753
753
|
* Get the serial component character set.
|
|
754
754
|
*/
|
|
755
|
-
get serialComponentCharacterSet():
|
|
755
|
+
get serialComponentCharacterSet(): ContentCharacterSet {
|
|
756
756
|
return this._serialComponentCharacterSet;
|
|
757
757
|
}
|
|
758
758
|
|
|
@@ -831,7 +831,7 @@ export class NonNumericIdentificationKeyValidator extends AbstractIdentification
|
|
|
831
831
|
* @param requiresCheckCharacterPair
|
|
832
832
|
* True if the identification key requires a check character pair.
|
|
833
833
|
*/
|
|
834
|
-
constructor(identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet:
|
|
834
|
+
constructor(identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair = false) {
|
|
835
835
|
super(identificationKeyType, PrefixType.GS1CompanyPrefix, length, referenceCharacterSet);
|
|
836
836
|
|
|
837
837
|
this._requiresCheckCharacterPair = requiresCheckCharacterPair;
|
|
@@ -912,12 +912,12 @@ export const SSCC_VALIDATOR = new NonGTINNumericIdentificationKeyValidator(Ident
|
|
|
912
912
|
/**
|
|
913
913
|
* GRAI validator.
|
|
914
914
|
*/
|
|
915
|
-
export const GRAI_VALIDATOR = new SerializableNumericIdentificationKeyValidator(IdentificationKeyType.GRAI, 13, 16,
|
|
915
|
+
export const GRAI_VALIDATOR = new SerializableNumericIdentificationKeyValidator(IdentificationKeyType.GRAI, 13, 16, ContentCharacterSet.AI82);
|
|
916
916
|
|
|
917
917
|
/**
|
|
918
918
|
* GIAI validator.
|
|
919
919
|
*/
|
|
920
|
-
export const GIAI_VALIDATOR = new NonNumericIdentificationKeyValidator(IdentificationKeyType.GIAI, 30,
|
|
920
|
+
export const GIAI_VALIDATOR = new NonNumericIdentificationKeyValidator(IdentificationKeyType.GIAI, 30, ContentCharacterSet.AI82);
|
|
921
921
|
|
|
922
922
|
/**
|
|
923
923
|
* GSRN validator.
|
|
@@ -927,12 +927,12 @@ export const GSRN_VALIDATOR = new NonGTINNumericIdentificationKeyValidator(Ident
|
|
|
927
927
|
/**
|
|
928
928
|
* GDTI validator.
|
|
929
929
|
*/
|
|
930
|
-
export const GDTI_VALIDATOR = new SerializableNumericIdentificationKeyValidator(IdentificationKeyType.GDTI, 13, 17,
|
|
930
|
+
export const GDTI_VALIDATOR = new SerializableNumericIdentificationKeyValidator(IdentificationKeyType.GDTI, 13, 17, ContentCharacterSet.AI82);
|
|
931
931
|
|
|
932
932
|
/**
|
|
933
933
|
* GINC validator.
|
|
934
934
|
*/
|
|
935
|
-
export const GINC_VALIDATOR = new NonNumericIdentificationKeyValidator(IdentificationKeyType.GINC, 30,
|
|
935
|
+
export const GINC_VALIDATOR = new NonNumericIdentificationKeyValidator(IdentificationKeyType.GINC, 30, ContentCharacterSet.AI82);
|
|
936
936
|
|
|
937
937
|
/**
|
|
938
938
|
* GSIN validator.
|
|
@@ -942,17 +942,17 @@ export const GSIN_VALIDATOR = new NonGTINNumericIdentificationKeyValidator(Ident
|
|
|
942
942
|
/**
|
|
943
943
|
* GCN validator.
|
|
944
944
|
*/
|
|
945
|
-
export const GCN_VALIDATOR = new SerializableNumericIdentificationKeyValidator(IdentificationKeyType.GCN, 13, 12,
|
|
945
|
+
export const GCN_VALIDATOR = new SerializableNumericIdentificationKeyValidator(IdentificationKeyType.GCN, 13, 12, ContentCharacterSet.Numeric);
|
|
946
946
|
|
|
947
947
|
/**
|
|
948
948
|
* CPID validator.
|
|
949
949
|
*/
|
|
950
|
-
export const CPID_VALIDATOR = new NonNumericIdentificationKeyValidator(IdentificationKeyType.CPID, 30,
|
|
950
|
+
export const CPID_VALIDATOR = new NonNumericIdentificationKeyValidator(IdentificationKeyType.CPID, 30, ContentCharacterSet.AI39);
|
|
951
951
|
|
|
952
952
|
/**
|
|
953
953
|
* GMN validator.
|
|
954
954
|
*/
|
|
955
|
-
export const GMN_VALIDATOR = new NonNumericIdentificationKeyValidator(IdentificationKeyType.GMN, 25,
|
|
955
|
+
export const GMN_VALIDATOR = new NonNumericIdentificationKeyValidator(IdentificationKeyType.GMN, 25, ContentCharacterSet.AI82, true);
|
|
956
956
|
|
|
957
957
|
/**
|
|
958
958
|
* Identification key creator. Creates an identification key based on its definition in section 3 of the {@link
|
|
@@ -1019,7 +1019,7 @@ abstract class AbstractIdentificationKeyCreator implements IdentificationKeyCrea
|
|
|
1019
1019
|
|
|
1020
1020
|
abstract get length(): number;
|
|
1021
1021
|
|
|
1022
|
-
abstract get referenceCharacterSet():
|
|
1022
|
+
abstract get referenceCharacterSet(): ContentCharacterSet;
|
|
1023
1023
|
|
|
1024
1024
|
abstract get referenceCreator(): CharacterSetCreator;
|
|
1025
1025
|
|
|
@@ -1504,7 +1504,7 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
|
|
|
1504
1504
|
* @param serialComponentCharacterSet
|
|
1505
1505
|
* Serial component character set.
|
|
1506
1506
|
*/
|
|
1507
|
-
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet:
|
|
1507
|
+
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet: ContentCharacterSet) {
|
|
1508
1508
|
super(identificationKeyType, length, serialComponentLength, serialComponentCharacterSet);
|
|
1509
1509
|
|
|
1510
1510
|
this.init(prefixManager, prefixManager.gs1CompanyPrefix);
|
|
@@ -1620,7 +1620,7 @@ export class NonNumericIdentificationKeyCreator extends Mixin(NonNumericIdentifi
|
|
|
1620
1620
|
* @param requiresCheckCharacterPair
|
|
1621
1621
|
* True if the identification key requires a check character pair.
|
|
1622
1622
|
*/
|
|
1623
|
-
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet:
|
|
1623
|
+
constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair = false) {
|
|
1624
1624
|
super(identificationKeyType, length, referenceCharacterSet, requiresCheckCharacterPair);
|
|
1625
1625
|
|
|
1626
1626
|
this.init(prefixManager, prefixManager.gs1CompanyPrefix, 2 * Number(requiresCheckCharacterPair));
|
package/src/index.ts
CHANGED
package/test/idkey.test.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { describe, expect, test } from "vitest";
|
|
|
4
4
|
import {
|
|
5
5
|
AI39_CREATOR,
|
|
6
6
|
AI82_CREATOR,
|
|
7
|
-
|
|
7
|
+
ContentCharacterSet,
|
|
8
8
|
CPID_VALIDATOR,
|
|
9
9
|
GCN_VALIDATOR,
|
|
10
10
|
GDTI_VALIDATOR,
|
|
@@ -43,19 +43,19 @@ import {
|
|
|
43
43
|
|
|
44
44
|
await i18nInit(I18NEnvironment.CLI);
|
|
45
45
|
|
|
46
|
-
function creatorFor(characterSet:
|
|
46
|
+
function creatorFor(characterSet: ContentCharacterSet): CharacterSetCreator {
|
|
47
47
|
let creator: CharacterSetCreator;
|
|
48
48
|
|
|
49
49
|
switch (characterSet) {
|
|
50
|
-
case
|
|
50
|
+
case ContentCharacterSet.Numeric:
|
|
51
51
|
creator = NUMERIC_CREATOR;
|
|
52
52
|
break;
|
|
53
53
|
|
|
54
|
-
case
|
|
54
|
+
case ContentCharacterSet.AI82:
|
|
55
55
|
creator = AI82_CREATOR;
|
|
56
56
|
break;
|
|
57
57
|
|
|
58
|
-
case
|
|
58
|
+
case ContentCharacterSet.AI39:
|
|
59
59
|
creator = AI39_CREATOR;
|
|
60
60
|
break;
|
|
61
61
|
}
|
|
@@ -73,7 +73,7 @@ function validateNumericIdentificationKeyValidator(validator: NumericIdentificat
|
|
|
73
73
|
validateIdentificationKeyValidator(validator, identificationKeyType, prefixType, length);
|
|
74
74
|
|
|
75
75
|
expect(validator.leaderType).toBe(leaderType);
|
|
76
|
-
expect(validator.referenceCharacterSet).toBe(
|
|
76
|
+
expect(validator.referenceCharacterSet).toBe(ContentCharacterSet.Numeric);
|
|
77
77
|
expect(validator.referenceCreator).toBe(NUMERIC_CREATOR);
|
|
78
78
|
|
|
79
79
|
if (isCreator) {
|
|
@@ -110,7 +110,7 @@ function validateNonGTINNumericIdentificationKeyValidator<T extends NonGTINNumer
|
|
|
110
110
|
validateNumericIdentificationKeyValidator(validator, isCreator, identificationKeyType, PrefixType.GS1CompanyPrefix, length, leaderType);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
function validateSerializableNumericIdentificationKeyValidator(validator: SerializableNumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, length: number, leaderType: LeaderType, serialLength: number, serialCharacterSet:
|
|
113
|
+
function validateSerializableNumericIdentificationKeyValidator(validator: SerializableNumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, length: number, leaderType: LeaderType, serialLength: number, serialCharacterSet: ContentCharacterSet): void {
|
|
114
114
|
validateNonGTINNumericIdentificationKeyValidator(validator, isCreator, identificationKeyType, length, leaderType);
|
|
115
115
|
|
|
116
116
|
const serialCreator = creatorFor(serialCharacterSet);
|
|
@@ -124,7 +124,7 @@ function validateSerializableNumericIdentificationKeyValidator(validator: Serial
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
function validateNonNumericIdentificationKeyValidator(validator: NonNumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet:
|
|
127
|
+
function validateNonNumericIdentificationKeyValidator(validator: NonNumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair: boolean): void {
|
|
128
128
|
validateIdentificationKeyValidator(validator, identificationKeyType, PrefixType.GS1CompanyPrefix, length);
|
|
129
129
|
|
|
130
130
|
const referenceCreator = creatorFor(referenceCharacterSet);
|
|
@@ -151,15 +151,15 @@ describe("Validators", () => {
|
|
|
151
151
|
validateGTINValidator(GTIN8_VALIDATOR, false, GTINType.GTIN8);
|
|
152
152
|
validateNonGTINNumericIdentificationKeyValidator(GLN_VALIDATOR, false, IdentificationKeyType.GLN, 13, LeaderType.None);
|
|
153
153
|
validateNonGTINNumericIdentificationKeyValidator(SSCC_VALIDATOR, false, IdentificationKeyType.SSCC, 18, LeaderType.ExtensionDigit);
|
|
154
|
-
validateSerializableNumericIdentificationKeyValidator(GRAI_VALIDATOR, false, IdentificationKeyType.GRAI, 13, LeaderType.None, 16,
|
|
155
|
-
validateNonNumericIdentificationKeyValidator(GIAI_VALIDATOR, false, IdentificationKeyType.GIAI, 30,
|
|
154
|
+
validateSerializableNumericIdentificationKeyValidator(GRAI_VALIDATOR, false, IdentificationKeyType.GRAI, 13, LeaderType.None, 16, ContentCharacterSet.AI82);
|
|
155
|
+
validateNonNumericIdentificationKeyValidator(GIAI_VALIDATOR, false, IdentificationKeyType.GIAI, 30, ContentCharacterSet.AI82, false);
|
|
156
156
|
validateNonGTINNumericIdentificationKeyValidator(GSRN_VALIDATOR, false, IdentificationKeyType.GSRN, 18, LeaderType.None);
|
|
157
|
-
validateSerializableNumericIdentificationKeyValidator(GDTI_VALIDATOR, false, IdentificationKeyType.GDTI, 13, LeaderType.None, 17,
|
|
158
|
-
validateNonNumericIdentificationKeyValidator(GINC_VALIDATOR, false, IdentificationKeyType.GINC, 30,
|
|
157
|
+
validateSerializableNumericIdentificationKeyValidator(GDTI_VALIDATOR, false, IdentificationKeyType.GDTI, 13, LeaderType.None, 17, ContentCharacterSet.AI82);
|
|
158
|
+
validateNonNumericIdentificationKeyValidator(GINC_VALIDATOR, false, IdentificationKeyType.GINC, 30, ContentCharacterSet.AI82, false);
|
|
159
159
|
validateNonGTINNumericIdentificationKeyValidator(GSIN_VALIDATOR, false, IdentificationKeyType.GSIN, 17, LeaderType.None);
|
|
160
|
-
validateSerializableNumericIdentificationKeyValidator(GCN_VALIDATOR, false, IdentificationKeyType.GCN, 13, LeaderType.None, 12,
|
|
161
|
-
validateNonNumericIdentificationKeyValidator(CPID_VALIDATOR, false, IdentificationKeyType.CPID, 30,
|
|
162
|
-
validateNonNumericIdentificationKeyValidator(GMN_VALIDATOR, false, IdentificationKeyType.GMN, 25,
|
|
160
|
+
validateSerializableNumericIdentificationKeyValidator(GCN_VALIDATOR, false, IdentificationKeyType.GCN, 13, LeaderType.None, 12, ContentCharacterSet.Numeric);
|
|
161
|
+
validateNonNumericIdentificationKeyValidator(CPID_VALIDATOR, false, IdentificationKeyType.CPID, 30, ContentCharacterSet.AI39, false);
|
|
162
|
+
validateNonNumericIdentificationKeyValidator(GMN_VALIDATOR, false, IdentificationKeyType.GMN, 25, ContentCharacterSet.AI82, true);
|
|
163
163
|
});
|
|
164
164
|
});
|
|
165
165
|
|
|
@@ -202,15 +202,15 @@ function validateIdentificationKeyCreators(prefixManager: PrefixManager): void {
|
|
|
202
202
|
|
|
203
203
|
validateNonGTINNumericIdentificationKeyValidator(prefixManager.glnCreator, true, IdentificationKeyType.GLN, 13, LeaderType.None);
|
|
204
204
|
validateNonGTINNumericIdentificationKeyValidator(prefixManager.ssccCreator, true, IdentificationKeyType.SSCC, 18, LeaderType.ExtensionDigit);
|
|
205
|
-
validateSerializableNumericIdentificationKeyValidator(prefixManager.graiCreator, true, IdentificationKeyType.GRAI, 13, LeaderType.None, 16,
|
|
206
|
-
validateNonNumericIdentificationKeyValidator(prefixManager.giaiCreator, true, IdentificationKeyType.GIAI, 30,
|
|
205
|
+
validateSerializableNumericIdentificationKeyValidator(prefixManager.graiCreator, true, IdentificationKeyType.GRAI, 13, LeaderType.None, 16, ContentCharacterSet.AI82);
|
|
206
|
+
validateNonNumericIdentificationKeyValidator(prefixManager.giaiCreator, true, IdentificationKeyType.GIAI, 30, ContentCharacterSet.AI82, false);
|
|
207
207
|
validateNonGTINNumericIdentificationKeyValidator(prefixManager.gsrnCreator, true, IdentificationKeyType.GSRN, 18, LeaderType.None);
|
|
208
|
-
validateSerializableNumericIdentificationKeyValidator(prefixManager.gdtiCreator, true, IdentificationKeyType.GDTI, 13, LeaderType.None, 17,
|
|
209
|
-
validateNonNumericIdentificationKeyValidator(prefixManager.gincCreator, true, IdentificationKeyType.GINC, 30,
|
|
208
|
+
validateSerializableNumericIdentificationKeyValidator(prefixManager.gdtiCreator, true, IdentificationKeyType.GDTI, 13, LeaderType.None, 17, ContentCharacterSet.AI82);
|
|
209
|
+
validateNonNumericIdentificationKeyValidator(prefixManager.gincCreator, true, IdentificationKeyType.GINC, 30, ContentCharacterSet.AI82, false);
|
|
210
210
|
validateNonGTINNumericIdentificationKeyValidator(prefixManager.gsinCreator, true, IdentificationKeyType.GSIN, 17, LeaderType.None);
|
|
211
|
-
validateSerializableNumericIdentificationKeyValidator(prefixManager.gcnCreator, true, IdentificationKeyType.GCN, 13, LeaderType.None, 12,
|
|
212
|
-
validateNonNumericIdentificationKeyValidator(prefixManager.cpidCreator, true, IdentificationKeyType.CPID, 30,
|
|
213
|
-
validateNonNumericIdentificationKeyValidator(prefixManager.gmnCreator, true, IdentificationKeyType.GMN, 25,
|
|
211
|
+
validateSerializableNumericIdentificationKeyValidator(prefixManager.gcnCreator, true, IdentificationKeyType.GCN, 13, LeaderType.None, 12, ContentCharacterSet.Numeric);
|
|
212
|
+
validateNonNumericIdentificationKeyValidator(prefixManager.cpidCreator, true, IdentificationKeyType.CPID, 30, ContentCharacterSet.AI39, false);
|
|
213
|
+
validateNonNumericIdentificationKeyValidator(prefixManager.gmnCreator, true, IdentificationKeyType.GMN, 25, ContentCharacterSet.AI82, true);
|
|
214
214
|
} else {
|
|
215
215
|
expect(() => prefixManager.glnCreator).toThrow("GLN not supported by GS1-8 Prefix");
|
|
216
216
|
expect(() => prefixManager.ssccCreator).toThrow("SSCC not supported by GS1-8 Prefix");
|
|
@@ -902,15 +902,15 @@ function testSerializableNumericIdentificationKeyCreator(creator: SerializableNu
|
|
|
902
902
|
let invalidSerial: string;
|
|
903
903
|
|
|
904
904
|
switch (creator.serialComponentCharacterSet) {
|
|
905
|
-
case
|
|
905
|
+
case ContentCharacterSet.Numeric:
|
|
906
906
|
invalidSerial = "1234A5678";
|
|
907
907
|
break;
|
|
908
908
|
|
|
909
|
-
case
|
|
909
|
+
case ContentCharacterSet.AI82:
|
|
910
910
|
invalidSerial = "ABCD~1234";
|
|
911
911
|
break;
|
|
912
912
|
|
|
913
|
-
case
|
|
913
|
+
case ContentCharacterSet.AI39:
|
|
914
914
|
invalidSerial = "ABCD%1234";
|
|
915
915
|
break;
|
|
916
916
|
}
|