@aidc-toolkit/gs1 0.9.14-beta → 0.9.16-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.d.ts CHANGED
@@ -1,1497 +1,21 @@
1
- import { I18NEnvironment } from '@aidc-toolkit/core';
2
- import { i18n } from 'i18next';
3
- import { CharacterSetCreator, StringValidation, StringValidator, CharacterSetValidation, Exclusion, TransformerInput, TransformerOutput } from '@aidc-toolkit/utility';
4
- import * as ts_mixer_dist_types_types_js from 'ts-mixer/dist/types/types.js';
5
-
6
- declare const localeStrings: {
7
- readonly Check: {
8
- readonly lengthOfStringForPriceOrWeightMustBeExactly: "Length {{length}} of string for price or weight sum must be exactly {{exactLength}}";
9
- readonly priceOrWeightComponent: "price or weight";
10
- readonly lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}";
11
- };
12
- readonly IdentificationKey: {
13
- readonly identificationKeyTypeLength: "{{identificationKeyType}} must be {{length}} digits long";
14
- readonly invalidCheckDigit: "Invalid check digit";
15
- readonly invalidGTINLength: "GTIN must be 13, 12, 8, or 14 digits long";
16
- readonly invalidGTIN14Length: "GTIN must be 14 digits long";
17
- readonly invalidZeroSuppressedGTIN12: "Invalid zero-suppressed GTIN-12";
18
- readonly invalidZeroSuppressibleGTIN12: "GTIN-12 not zero-suppressible";
19
- readonly invalidZeroSuppressedGTIN12AsGTIN13: "Invalid zero-suppressed GTIN-12 as GTIN-13";
20
- readonly invalidZeroSuppressedGTIN12AsGTIN14: "Invalid zero-suppressed GTIN-12 as GTIN-14";
21
- readonly invalidGTIN13AtRetail: "GTIN-13 at retail consumer trade item level can't start with zero";
22
- readonly invalidGTINAtRetail: "GTIN not supported at retail consumer trade item level";
23
- readonly invalidGTINAtOtherThanRetail: "GTIN not supported at other than retail consumer trade item level";
24
- readonly indicatorDigit: "indicator digit";
25
- readonly serialComponent: "serial component";
26
- readonly reference: "reference";
27
- readonly referenceCantBeAllNumeric: "Reference can't be all-numeric";
28
- readonly invalidCheckCharacterPair: "Invalid check character pair";
29
- };
30
- readonly Prefix: {
31
- readonly gs1CompanyPrefix: "GS1 Company Prefix";
32
- readonly upcCompanyPrefix: "U.P.C. Company Prefix";
33
- readonly gs18Prefix: "GS1-8 Prefix";
34
- readonly invalidPrefixType: "Invalid prefix type";
35
- readonly gs1CompanyPrefixCantStartWith0: "GS1 Company Prefix can't start with \"0\"";
36
- readonly gs1CompanyPrefixCantStartWith00000: "GS1 Company Prefix can't start with \"00000\"";
37
- readonly gs1CompanyPrefixCantStartWith000000: "GS1 Company Prefix can't start with \"000000\"";
38
- readonly upcCompanyPrefixCantStartWith0000: "U.P.C. Company Prefix can't start with \"0000\"";
39
- readonly gs18PrefixCantStartWith0: "GS1-8 Prefix can't start with \"0\"";
40
- readonly identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} not supported by GS1-8 Prefix";
41
- };
42
- };
43
-
44
- declare const gs1NS = "aidct_gs1";
45
- /**
46
- * Locale strings type is extracted from the English locale strings object.
47
- */
48
- type GS1LocaleStrings = typeof localeStrings;
49
- /**
50
- * GS1 resources.
51
- */
52
- declare const gs1Resources: {
53
- en: {
54
- aidct_gs1: {
55
- readonly Check: {
56
- readonly lengthOfStringForPriceOrWeightMustBeExactly: "Length {{length}} of string for price or weight sum must be exactly {{exactLength}}";
57
- readonly priceOrWeightComponent: "price or weight";
58
- readonly lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}";
59
- };
60
- readonly IdentificationKey: {
61
- readonly identificationKeyTypeLength: "{{identificationKeyType}} must be {{length}} digits long";
62
- readonly invalidCheckDigit: "Invalid check digit";
63
- readonly invalidGTINLength: "GTIN must be 13, 12, 8, or 14 digits long";
64
- readonly invalidGTIN14Length: "GTIN must be 14 digits long";
65
- readonly invalidZeroSuppressedGTIN12: "Invalid zero-suppressed GTIN-12";
66
- readonly invalidZeroSuppressibleGTIN12: "GTIN-12 not zero-suppressible";
67
- readonly invalidZeroSuppressedGTIN12AsGTIN13: "Invalid zero-suppressed GTIN-12 as GTIN-13";
68
- readonly invalidZeroSuppressedGTIN12AsGTIN14: "Invalid zero-suppressed GTIN-12 as GTIN-14";
69
- readonly invalidGTIN13AtRetail: "GTIN-13 at retail consumer trade item level can't start with zero";
70
- readonly invalidGTINAtRetail: "GTIN not supported at retail consumer trade item level";
71
- readonly invalidGTINAtOtherThanRetail: "GTIN not supported at other than retail consumer trade item level";
72
- readonly indicatorDigit: "indicator digit";
73
- readonly serialComponent: "serial component";
74
- readonly reference: "reference";
75
- readonly referenceCantBeAllNumeric: "Reference can't be all-numeric";
76
- readonly invalidCheckCharacterPair: "Invalid check character pair";
77
- };
78
- readonly Prefix: {
79
- readonly gs1CompanyPrefix: "GS1 Company Prefix";
80
- readonly upcCompanyPrefix: "U.P.C. Company Prefix";
81
- readonly gs18Prefix: "GS1-8 Prefix";
82
- readonly invalidPrefixType: "Invalid prefix type";
83
- readonly gs1CompanyPrefixCantStartWith0: "GS1 Company Prefix can't start with \"0\"";
84
- readonly gs1CompanyPrefixCantStartWith00000: "GS1 Company Prefix can't start with \"00000\"";
85
- readonly gs1CompanyPrefixCantStartWith000000: "GS1 Company Prefix can't start with \"000000\"";
86
- readonly upcCompanyPrefixCantStartWith0000: "U.P.C. Company Prefix can't start with \"0000\"";
87
- readonly gs18PrefixCantStartWith0: "GS1-8 Prefix can't start with \"0\"";
88
- readonly identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} not supported by GS1-8 Prefix";
89
- };
90
- };
91
- };
92
- fr: {
93
- aidct_gs1: {
94
- readonly Check: {
95
- readonly lengthOfStringForPriceOrWeightMustBeExactly: "La longueur {{longueur}} de la chaîne pour le prix ou la somme du poids doit être exactement {{exactLength}}";
96
- readonly priceOrWeightComponent: "prix ou poids";
97
- readonly lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "La longueur {{length}} de la chaîne pour la paire de caractères de vérification doit être inférieure ou égale à {{maximum Length}}";
98
- };
99
- readonly IdentificationKey: {
100
- readonly identificationKeyTypeLength: "{{identificationKeyType}} doit comporter {{length}} chiffres";
101
- readonly invalidCheckDigit: "Chiffre de contrôle non valide";
102
- readonly invalidGTINLength: "Le GTIN doit comporter 13, 12, 8 ou 14 chiffres";
103
- readonly invalidGTIN14Length: "Le GTIN doit comporter 14 chiffres";
104
- readonly invalidZeroSuppressedGTIN12: "Code GTIN-12 non valide avec zéro supprimé";
105
- readonly invalidZeroSuppressibleGTIN12: "Le GTIN-12 ne peut pas être supprimé par zéro";
106
- readonly invalidZeroSuppressedGTIN12AsGTIN13: "GTIN-12 non valide avec zéro supprimé en tant que GTIN-13";
107
- readonly invalidZeroSuppressedGTIN12AsGTIN14: "GTIN-12 non valide avec zéro supprimé en tant que GTIN-14";
108
- readonly invalidGTIN13AtRetail: "Le GTIN-13 au niveau des articles de consommation au détail ne peut pas commencer par zéro";
109
- readonly invalidGTINAtRetail: "Le GTIN n'est pas pris en charge au niveau des articles de consommation au détail";
110
- readonly invalidGTINAtOtherThanRetail: "Le GTIN n'est pas pris en charge à d'autres niveaux que ceux des articles de consommation au détail";
111
- readonly indicatorDigit: "chiffre indicateur";
112
- readonly serialComponent: "composant série";
113
- readonly reference: "référence";
114
- readonly referenceCantBeAllNumeric: "La référence ne peut pas être entièrement numérique";
115
- readonly invalidCheckCharacterPair: "Paire de caractères de contrôle non valide";
116
- };
117
- readonly Prefix: {
118
- readonly gs1CompanyPrefix: "Préfixe de l'entreprise GS1";
119
- readonly upcCompanyPrefix: "Préfixe de l'entreprise U.P.C.";
120
- readonly gs18Prefix: "Préfixe GS1-8";
121
- readonly invalidPrefixType: "Type de préfixe invalide";
122
- readonly gs1CompanyPrefixCantStartWith0: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"0\"";
123
- readonly gs1CompanyPrefixCantStartWith00000: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"00000\"";
124
- readonly gs1CompanyPrefixCantStartWith000000: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"000000\"";
125
- readonly upcCompanyPrefixCantStartWith0000: "Le préfixe de l'entreprise U.P.C. ne peut pas commencer par \"0000\"";
126
- readonly gs18PrefixCantStartWith0: "Le préfixe GS1-8 ne peut pas commencer par \"0\"";
127
- readonly identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} non pris en charge par le préfixe GS1-8";
128
- };
129
- };
130
- };
131
- };
132
- declare const i18nextGS1: i18n;
133
- /**
134
- * Initialize internationalization.
135
- *
136
- * @param environment
137
- * Environment in which the application is running.
138
- *
139
- * @param debug
140
- * Debug setting.
141
- *
142
- * @returns
143
- * Void promise.
144
- */
145
- declare function i18nGS1Init(environment: I18NEnvironment, debug?: boolean): Promise<void>;
146
-
147
- /**
148
- * GS1 AI encodable character set 82 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
149
- * General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
150
- */
151
- declare const AI82_CREATOR: CharacterSetCreator;
152
- /**
153
- * GS1 AI encodable character set 39 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
154
- * General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
155
- */
156
- declare const AI39_CREATOR: CharacterSetCreator;
157
-
158
- /**
159
- * Calculate the check digit sum for a numeric string as per section 7.9.1 of the {@link https://www.gs1.org/genspecs |
160
- * GS1 General Specifications}.
161
- *
162
- * @param exchangeWeights
163
- * If true, start the weights at 1 instead of 3 on the right.
164
- *
165
- * @param s
166
- * Numeric string.
167
- *
168
- * @returns
169
- * Accumulated sum of each digit multiplied by the weight at its position.
170
- */
171
- declare function checkDigitSum(exchangeWeights: boolean, s: string): number;
172
- /**
173
- * Calculate the check digit for a numeric string as per section 7.9.1 of the {@link https://www.gs1.org/genspecs | GS1
174
- * General Specifications}.
175
- *
176
- * @param s
177
- * Numeric string.
178
- *
179
- * @returns
180
- * Check digit 0-9 as a string.
181
- */
182
- declare function checkDigit(s: string): string;
183
- /**
184
- * Determine if a numeric string has a valid check digit.
185
- *
186
- * @param s
187
- * Numeric string with check digit.
188
- *
189
- * @returns
190
- * True if the check digit is valid.
191
- */
192
- declare function hasValidCheckDigit(s: string): boolean;
193
- /**
194
- * Calculate the price/weight check digit for a four-digit numeric string as per section 7.9.3 of the {@link
195
- * https://www.gs1.org/genspecs | GS1 General Specifications}.
196
- *
197
- * @param s
198
- * Numeric string exactly four characters long.
199
- *
200
- * @returns
201
- * Check digit 0-9 as a string.
202
- */
203
- declare function fourDigitPriceWeightCheckDigit(s: string): string;
204
- /**
205
- * Calculate the price/weight check digit for a five-digit numeric string as per section 7.9.3 of the {@link
206
- * https://www.gs1.org/genspecs | GS1 General Specifications}.
207
- *
208
- * @param s
209
- * Numeric string exactly five characters long.
210
- *
211
- * @returns
212
- * Check digit 0-9 as a string.
213
- */
214
- declare function fiveDigitPriceWeightCheckDigit(s: string): string;
215
- /**
216
- * Calculate the check character for a GS1 AI encodable character set 82 string as per section 7.9.5 of the {@link
217
- * https://www.gs1.org/genspecs | GS1 General Specifications}.
218
- *
219
- * @param s
220
- * GS1 AI encodable character set 82 string.
221
- *
222
- * @returns
223
- * Check character pair.
224
- */
225
- declare function checkCharacterPair(s: string): string;
226
- /**
227
- * Determine if a GS1 AI encodable character set 82 string has a valid check character pair.
228
- *
229
- * @param s
230
- * GS1 AI encodable character set 82 string with check character pair.
231
- *
232
- * @returns
233
- * True if the check character pair is valid.
234
- */
235
- declare function hasValidCheckCharacterPair(s: string): boolean;
236
-
237
- /**
238
- * Identification key type.
239
- */
240
- declare enum IdentificationKeyType {
241
- /**
242
- * Global Trade Item Number.
243
- */
244
- GTIN = "GTIN",
245
- /**
246
- * Global Location Number.
247
- */
248
- GLN = "GLN",
249
- /**
250
- * Serial Shipping Container Code.
251
- */
252
- SSCC = "SSCC",
253
- /**
254
- * Global Returnable Asset Identifier.
255
- */
256
- GRAI = "GRAI",
257
- /**
258
- * Global Individual Asset Identifier.
259
- */
260
- GIAI = "GIAI",
261
- /**
262
- * Global Service Relation Number.
263
- */
264
- GSRN = "GSRN",
265
- /**
266
- * Global Document Type Identifier.
267
- */
268
- GDTI = "GDTI",
269
- /**
270
- * Global Identification Number for Consignment.
271
- */
272
- GINC = "GINC",
273
- /**
274
- * Global Shipment Identification Number.
275
- */
276
- GSIN = "GSIN",
277
- /**
278
- * Global Coupon Number.
279
- */
280
- GCN = "GCN",
281
- /**
282
- * Component/Part Identifier.
283
- */
284
- CPID = "CPID",
285
- /**
286
- * Global Model Number.
287
- */
288
- GMN = "GMN"
289
- }
290
- /**
291
- * Prefix type.
292
- */
293
- declare enum PrefixType {
294
- /**
295
- * GS1 Company Prefix.
296
- */
297
- GS1CompanyPrefix = 0,
298
- /**
299
- * U.P.C. Company Prefix.
300
- */
301
- UPCCompanyPrefix = 1,
302
- /**
303
- * GS1-8 Prefix.
304
- */
305
- GS18Prefix = 2
306
- }
307
- /**
308
- * Character set supported by the reference portion of an identification key or the serial component of a numeric
309
- * identification key.
310
- */
311
- declare enum ContentCharacterSet {
312
- /**
313
- * Numeric.
314
- */
315
- Numeric = 0,
316
- /**
317
- * GS1 AI encodable character set 82.
318
- */
319
- AI82 = 1,
320
- /**
321
- * GS1 AI encodable character set 39.
322
- */
323
- AI39 = 2
324
- }
325
- /**
326
- * Identification key validation parameters.
327
- */
328
- interface IdentificationKeyValidation extends StringValidation {
329
- /**
330
- * Position offset within a larger string. Strings are sometimes composed of multiple substrings; this parameter
331
- * ensures that the error notes the proper position in the string.
332
- */
333
- positionOffset?: number | undefined;
334
- }
335
- /**
336
- * Identification key validator. Validates an identification key against its definition in section 3 of the {@link
337
- * https://www.gs1.org/genspecs | GS1 General Specifications}.
338
- */
339
- interface IdentificationKeyValidator<TIdentificationKeyValidation extends IdentificationKeyValidation = IdentificationKeyValidation> extends StringValidator<TIdentificationKeyValidation> {
340
- /**
341
- * Get the identification key type. Per the GS1 General Specifications, the identification key type determines
342
- * the remaining properties.
343
- */
344
- get identificationKeyType(): IdentificationKeyType;
345
- /**
346
- * Get the prefix type supported by the identification key type. For all identification key types except the GTIN,
347
- * this is {@linkcode PrefixType.GS1CompanyPrefix}. For the GTIN, the prefix type determines the length.
348
- */
349
- get prefixType(): PrefixType;
350
- /**
351
- * Get the length. For numeric identification key types, the length is fixed; for alphanumeric identification key
352
- * types, the length is the maximum.
353
- */
354
- get length(): number;
355
- /**
356
- * Get the reference character set.
357
- */
358
- get referenceCharacterSet(): ContentCharacterSet;
359
- /**
360
- * Get the reference validator.
361
- */
362
- get referenceCreator(): CharacterSetCreator;
363
- /**
364
- * Validate an identification key and throw an error if validation fails.
365
- *
366
- * @param identificationKey
367
- * Identification key.
368
- *
369
- * @param validation
370
- * Identification key validation parameters.
371
- */
372
- validate: (identificationKey: string, validation?: TIdentificationKeyValidation) => void;
373
- }
374
- /**
375
- * Abstract identification key validator. Implements common functionality for an identification key validator.
376
- */
377
- declare abstract class AbstractIdentificationKeyValidator<TIdentificationKeyValidation extends IdentificationKeyValidation = IdentificationKeyValidation> implements IdentificationKeyValidator<TIdentificationKeyValidation> {
378
- private static readonly CHARACTER_SET_CREATORS;
379
- /**
380
- * Identification key type.
381
- */
382
- private readonly _identificationKeyType;
383
- /**
384
- * Prefix type.
385
- */
386
- private readonly _prefixType;
387
- /**
388
- * Length.
389
- */
390
- private readonly _length;
391
- /**
392
- * Reference character set.
393
- */
394
- private readonly _referenceCharacterSet;
395
- /**
396
- * Reference creator.
397
- */
398
- private readonly _referenceCreator;
399
- /**
400
- * Get the character set creator for a character set.
401
- *
402
- * @param characterSet
403
- * Character set.
404
- *
405
- * @returns
406
- * Character set creator.
407
- */
408
- protected static creatorFor(characterSet: ContentCharacterSet): CharacterSetCreator;
409
- /**
410
- * Constructor.
411
- *
412
- * @param identificationKeyType
413
- * Identification key type.
414
- *
415
- * @param prefixType
416
- * Prefix type.
417
- *
418
- * @param length
419
- * Length.
420
- *
421
- * @param referenceCharacterSet
422
- * Reference character set.
423
- */
424
- protected constructor(identificationKeyType: IdentificationKeyType, prefixType: PrefixType, length: number, referenceCharacterSet: ContentCharacterSet);
425
- /**
426
- * @inheritDoc
427
- */
428
- get identificationKeyType(): IdentificationKeyType;
429
- /**
430
- * @inheritDoc
431
- */
432
- get prefixType(): PrefixType;
433
- /**
434
- * @inheritDoc
435
- */
436
- get length(): number;
437
- /**
438
- * @inheritDoc
439
- */
440
- get referenceCharacterSet(): ContentCharacterSet;
441
- /**
442
- * @inheritDoc
443
- */
444
- get referenceCreator(): CharacterSetCreator;
445
- /**
446
- * Pad an identification key on the left with zero-value character for validation purposes. This is done to align an
447
- * identification key with a position offset for any error message that may be thrown by the reference validator.
448
- *
449
- * @param identificationKey
450
- * Identification key.
451
- *
452
- * @param validation
453
- * Identification key validation parameters.
454
- *
455
- * @returns
456
- * Padded identification key.
457
- */
458
- protected padIdentificationKey(identificationKey: string, validation: IdentificationKeyValidation | undefined): string;
459
- /**
460
- * Validate the prefix within an identification key.
461
- *
462
- * @param partialIdentificationKey
463
- * Partial identification key.
464
- *
465
- * @param positionOffset
466
- * Position offset within a larger string.
467
- */
468
- protected validatePrefix(partialIdentificationKey: string, positionOffset?: number): void;
469
- abstract validate(identificationKey: string, validation?: TIdentificationKeyValidation): void;
470
- }
471
- /**
472
- * Leader type.
473
- */
474
- declare enum LeaderType {
475
- /**
476
- * No leader.
477
- */
478
- None = 0,
479
- /**
480
- * Indicator digit (GTIN only).
481
- */
482
- IndicatorDigit = 1,
483
- /**
484
- * Extension digit (SSCC only).
485
- */
486
- ExtensionDigit = 2
487
- }
488
- /**
489
- * Numeric identification key validator. Validates a numeric identification key.
490
- */
491
- interface NumericIdentificationKeyValidator extends IdentificationKeyValidator {
492
- /**
493
- * Get the leader type.
494
- */
495
- get leaderType(): LeaderType;
496
- }
497
- /**
498
- * Abstract numeric identification key validator. Implements common functionality for a numeric identification key
499
- * validator.
500
- */
501
- declare abstract class AbstractNumericIdentificationKeyValidator extends AbstractIdentificationKeyValidator implements NumericIdentificationKeyValidator {
502
- /**
503
- * Leader type.
504
- */
505
- private readonly _leaderType;
506
- /**
507
- * Prefix position, determined by the leader type.
508
- */
509
- private readonly _prefixPosition;
510
- /**
511
- * Constructor.
512
- *
513
- * @param identificationKeyType
514
- * Identification key type.
515
- *
516
- * @param prefixType
517
- * Prefix type.
518
- *
519
- * @param length
520
- * Length.
521
- *
522
- * @param leaderType
523
- * Leader type.
524
- */
525
- protected constructor(identificationKeyType: IdentificationKeyType, prefixType: PrefixType, length: number, leaderType: LeaderType);
526
- /**
527
- * @inheritDoc
528
- */
529
- get leaderType(): LeaderType;
530
- /**
531
- * @inheritDoc
532
- */
533
- validate(identificationKey: string, validation?: IdentificationKeyValidation): void;
534
- }
535
- /**
536
- * GTIN type. The numeric values of this enumeration are equal to the lengths of the GTIN types.
537
- */
538
- declare enum GTINType {
539
- /**
540
- * GTIN-13.
541
- */
542
- GTIN13 = 13,
543
- /**
544
- * GTIN-12.
545
- */
546
- GTIN12 = 12,
547
- /**
548
- * GTIN-8.
549
- */
550
- GTIN8 = 8,
551
- /**
552
- * GTIN-14.
553
- */
554
- GTIN14 = 14
555
- }
556
- /**
557
- * Level at which GTIN is to be validated.
558
- */
559
- declare enum GTINLevel {
560
- /**
561
- * Any level (level is ignored).
562
- */
563
- Any = 0,
564
- /**
565
- * Retail consumer trade item level, supporting GTIN-13, GTIN-12 (optionally zero-suppressed), and GTIN-8.
566
- */
567
- RetailConsumer = 1,
568
- /**
569
- * Other than retail consumer trade item level, supporting GTIN-13, GTIN-12 (not zero-suppressed), and GTIN-14.
570
- */
571
- OtherThanRetailConsumer = 2
572
- }
573
- /**
574
- * GTIN validator.
575
- */
576
- declare class GTINValidator extends AbstractNumericIdentificationKeyValidator {
577
- /**
578
- * Validation parameters for optional indicator digit.
579
- */
580
- private static readonly OPTIONAL_INDICATOR_DIGIT_VALIDATION;
581
- /**
582
- * Validation parameters for zero-suppressed GTIN-12.
583
- */
584
- private static readonly ZERO_SUPPRESSED_GTIN12_VALIDATION;
585
- /**
586
- * Constructor.
587
- *
588
- * @param gtinType
589
- * GTIN type.
590
- */
591
- constructor(gtinType: GTINType);
592
- /**
593
- * @inheritDoc
594
- */
595
- get gtinType(): GTINType;
596
- /**
597
- * @inheritDoc
598
- */
599
- protected validatePrefix(partialIdentificationKey: string, positionOffset?: number): void;
600
- /**
601
- * Zero suppress a GTIN-12.
602
- *
603
- * @param gtin12
604
- * GTIN-12.
605
- *
606
- * @returns
607
- * Zero-suppressed GTIN-12.
608
- */
609
- static zeroSuppress(gtin12: string): string;
610
- /**
611
- * Zero expand a zero-suppressed GTIN-12.
612
- *
613
- * @param zeroSuppressedGTIN12
614
- * Zero-suppressed GTIN-12.
615
- *
616
- * @returns
617
- * GTIN-12.
618
- */
619
- static zeroExpand(zeroSuppressedGTIN12: string): string;
620
- /**
621
- * Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
622
- *
623
- * @param indicatorDigit
624
- * Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
625
- *
626
- * @param gtin
627
- * GTIN.
628
- *
629
- * @returns
630
- * GTIN-14.
631
- */
632
- static convertToGTIN14(indicatorDigit: string, gtin: string): string;
633
- /**
634
- * Normalize a GTIN of any length.
635
- * - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
636
- * - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
637
- * - A GTIN-14 that starts with one zero is normalized to GTIN-13.
638
- * - Otherwise, the GTIN is unchanged.
639
- *
640
- * @param gtin
641
- * GTIN.
642
- *
643
- * @returns
644
- * Normalized GTIN.
645
- */
646
- static normalize(gtin: string): string;
647
- /**
648
- * Validate any GTIN, optionally against a level.
649
- *
650
- * @param gtin
651
- * GTIN.
652
- *
653
- * @param gtinLevel
654
- * Level at which GTIN is to be validated.
655
- */
656
- static validateAny(gtin: string, gtinLevel?: GTINLevel): void;
657
- /**
658
- * Validate a GTIN-14.
659
- *
660
- * @param gtin14
661
- * GTIN-14.
662
- */
663
- static validateGTIN14(gtin14: string): void;
664
- }
665
- /**
666
- * Non-GTIN numeric identification key validator.
667
- */
668
- declare class NonGTINNumericIdentificationKeyValidator extends AbstractNumericIdentificationKeyValidator {
669
- /**
670
- * Constructor.
671
- *
672
- * @param identificationKeyType
673
- * Identification key type.
674
- *
675
- * @param length
676
- * Length.
677
- *
678
- * @param leaderType
679
- * Leader type.
680
- */
681
- constructor(identificationKeyType: IdentificationKeyType, length: number, leaderType?: LeaderType);
682
- }
683
- /**
684
- * Serializable numeric identification key validator. Validates both serialized and non-serialized forms of
685
- * numeric identification keys that support serialization.
686
- */
687
- declare class SerializableNumericIdentificationKeyValidator extends NonGTINNumericIdentificationKeyValidator {
688
- /**
689
- * Serial component length.
690
- */
691
- private readonly _serialComponentLength;
692
- /**
693
- * Serial component character set.
694
- */
695
- private readonly _serialComponentCharacterSet;
696
- /**
697
- * Serial component validation parameters.
698
- */
699
- private readonly _serialComponentValidation;
700
- /**
701
- * Serial component creator.
702
- */
703
- private readonly _serialComponentCreator;
704
- /**
705
- * Constructor.
706
- *
707
- * @param identificationKeyType
708
- * Identification key type.
709
- *
710
- * @param length
711
- * Length.
712
- *
713
- * @param serialComponentLength
714
- * Serial component length.
715
- *
716
- * @param serialComponentCharacterSet
717
- * Serial component character set.
718
- */
719
- constructor(identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet: ContentCharacterSet);
720
- /**
721
- * Get the serial component length.
722
- */
723
- get serialComponentLength(): number;
724
- /**
725
- * Get the serial component character set.
726
- */
727
- get serialComponentCharacterSet(): ContentCharacterSet;
728
- /**
729
- * Get the serial component validation parameters.
730
- */
731
- protected get serialComponentValidation(): CharacterSetValidation;
732
- /**
733
- * Get the serial component creator.
734
- */
735
- get serialComponentCreator(): CharacterSetCreator;
736
- /**
737
- * @inheritDoc
738
- */
739
- validate(identificationKey: string, validation?: IdentificationKeyValidation): void;
740
- }
741
- /**
742
- * Non-numeric identification key validation parameters.
743
- */
744
- interface NonNumericIdentificationKeyValidation extends IdentificationKeyValidation {
745
- /**
746
- * Exclusion support for reference. Prevents non-numeric identification key from being mistaken for numeric
747
- * identification key.
748
- */
749
- exclusion?: Exclusion.None | Exclusion.AllNumeric | undefined;
750
- }
751
- /**
752
- * Non-numeric identification key validator.
753
- */
754
- declare class NonNumericIdentificationKeyValidator extends AbstractIdentificationKeyValidator<NonNumericIdentificationKeyValidation> {
755
- /**
756
- * Validator to ensure that an identification key (minus check character pair) is not all numeric.
757
- */
758
- private static readonly NOT_ALL_NUMERIC_VALIDATOR;
759
- /**
760
- * True if the identification key requires a check character pair.
761
- */
762
- private readonly _requiresCheckCharacterPair;
763
- /**
764
- * Constructor.
765
- *
766
- * @param identificationKeyType
767
- * Identification key type.
768
- *
769
- * @param length
770
- * Length.
771
- *
772
- * @param referenceCharacterSet
773
- * Reference character set.
774
- *
775
- * @param requiresCheckCharacterPair
776
- * True if the identification key requires a check character pair.
777
- */
778
- constructor(identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair?: boolean);
779
- /**
780
- * Determine if the identification key requires a check character pair.
781
- */
782
- get requiresCheckCharacterPair(): boolean;
783
- /**
784
- * Validate a non-numeric identification key and throw an error if validation fails.
785
- *
786
- * @param identificationKey
787
- * Identification key.
788
- *
789
- * @param validation
790
- * Validation parameters.
791
- */
792
- validate(identificationKey: string, validation?: NonNumericIdentificationKeyValidation): void;
793
- }
794
- /**
795
- * GTIN-13 validator.
796
- */
797
- declare const GTIN13_VALIDATOR: GTINValidator;
798
- /**
799
- * GTIN-12 validator.
800
- */
801
- declare const GTIN12_VALIDATOR: GTINValidator;
802
- /**
803
- * GTIN-8 validator.
804
- */
805
- declare const GTIN8_VALIDATOR: GTINValidator;
806
- /**
807
- * GTIN validators indexed by prefix type.
808
- */
809
- declare const GTIN_VALIDATORS: GTINValidator[];
810
- /**
811
- * GLN validator.
812
- */
813
- declare const GLN_VALIDATOR: NonGTINNumericIdentificationKeyValidator;
814
- /**
815
- * SSCC validator.
816
- */
817
- declare const SSCC_VALIDATOR: NonGTINNumericIdentificationKeyValidator;
818
- /**
819
- * GRAI validator.
820
- */
821
- declare const GRAI_VALIDATOR: SerializableNumericIdentificationKeyValidator;
822
- /**
823
- * GIAI validator.
824
- */
825
- declare const GIAI_VALIDATOR: NonNumericIdentificationKeyValidator;
826
- /**
827
- * GSRN validator.
828
- */
829
- declare const GSRN_VALIDATOR: NonGTINNumericIdentificationKeyValidator;
830
- /**
831
- * GDTI validator.
832
- */
833
- declare const GDTI_VALIDATOR: SerializableNumericIdentificationKeyValidator;
834
- /**
835
- * GINC validator.
836
- */
837
- declare const GINC_VALIDATOR: NonNumericIdentificationKeyValidator;
838
- /**
839
- * GSIN validator.
840
- */
841
- declare const GSIN_VALIDATOR: NonGTINNumericIdentificationKeyValidator;
842
- /**
843
- * GCN validator.
844
- */
845
- declare const GCN_VALIDATOR: SerializableNumericIdentificationKeyValidator;
846
- /**
847
- * CPID validator.
848
- */
849
- declare const CPID_VALIDATOR: NonNumericIdentificationKeyValidator;
850
- /**
851
- * GMN validator.
852
- */
853
- declare const GMN_VALIDATOR: NonNumericIdentificationKeyValidator;
854
- /**
855
- * Identification key creator. Creates an identification key based on its definition in section 3 of the {@link
856
- * https://www.gs1.org/genspecs | GS1 General Specifications}.
857
- *
858
- * Keys are created based on a prefix defined in a prefix manager to which the identification key creator is bound.
859
- */
860
- interface IdentificationKeyCreator extends IdentificationKeyValidator {
861
- /**
862
- * Get the prefix manager to which this identification key creator is bound.
863
- */
864
- get prefixManager(): PrefixManager;
865
- /**
866
- * Get the prefix, equivalent to calling {@linkcode PrefixManager.prefix | prefixManager.prefix} for a GTIN or
867
- * {@linkcode PrefixManager.gs1CompanyPrefix | prefixManager.gs1CompanyPrefix} for all other identification key
868
- * types.
869
- */
870
- get prefix(): string;
871
- /**
872
- * Get the reference length.
873
- */
874
- get referenceLength(): number;
875
- }
876
- /**
877
- * Abstract identification key creator. Implements common functionality for an identification key creator, bound to a
878
- * {@link PrefixManager}.
879
- */
880
- declare abstract class AbstractIdentificationKeyCreator implements IdentificationKeyCreator {
881
- /**
882
- * Prefix manager.
883
- */
884
- private _prefixManager;
885
- /**
886
- * Reference length.
887
- */
888
- private _referenceLength;
889
- /**
890
- * Initialize the prefix manager. This method is in lieu of a constructor due to the mixin architecture.
891
- *
892
- * @param prefixManager
893
- * Prefix manager.
894
- *
895
- * @param prefix
896
- * Prefix within prefix manager to use to calculate reference length.
897
- *
898
- * @param checkAllowance
899
- * Number of characters to allow for check digit or check character pair.
900
- */
901
- protected init(prefixManager: PrefixManager, prefix: string, checkAllowance: number): void;
902
- abstract get identificationKeyType(): IdentificationKeyType;
903
- abstract get prefixType(): PrefixType;
904
- abstract get length(): number;
905
- abstract get referenceCharacterSet(): ContentCharacterSet;
906
- abstract get referenceCreator(): CharacterSetCreator;
907
- /**
908
- * @inheritDoc
909
- */
910
- get prefixManager(): PrefixManager;
911
- /**
912
- * @inheritDoc
913
- */
914
- get prefix(): string;
915
- /**
916
- * @inheritDoc
917
- */
918
- get referenceLength(): number;
919
- abstract validate(identificationKey: string, validation?: IdentificationKeyValidation): void;
920
- }
921
- /**
922
- * Numeric identification key creator. Creates one or many numeric identification keys.
923
- */
924
- interface NumericIdentificationKeyCreator extends NumericIdentificationKeyValidator, IdentificationKeyCreator {
925
- /**
926
- * Get the capacity (`10**referenceLength`).
927
- */
928
- get capacity(): number;
929
- /**
930
- * Create identification key(s) with reference(s) based on numeric value(s). The value(s) is/are converted to
931
- * references of the appropriate length using {@linkcode NUMERIC_CREATOR}.
932
- *
933
- * @param valueOrValues
934
- * Numeric value(s).
935
- *
936
- * @param sparse
937
- * If true, the value(s) are mapped to a sparse sequence resistant to discovery. Default is false.
938
- *
939
- * @returns
940
- * Identification key(s).
941
- */
942
- create: <TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput, sparse?: boolean) => TransformerOutput<TTransformerInput, string>;
943
- /**
944
- * Create all identification keys for the prefix from `0` to `capacity - 1`.
945
- *
946
- * The implementation creates the strings only as needed using an internal generator function. Although the result
947
- * is equivalent to calling `creator.create(new Sequence(0, creator.capacity))`, this method is significantly
948
- * faster.
949
- *
950
- * @returns
951
- * All identification keys for the prefix.
952
- */
953
- createAll: () => Iterable<string>;
954
- }
955
- /**
956
- * Abstract numeric identification key creator. Implements common functionality for a numeric identification key creator.
957
- */
958
- declare abstract class AbstractNumericIdentificationKeyCreator extends AbstractIdentificationKeyCreator implements NumericIdentificationKeyCreator {
959
- /**
960
- * Capacity.
961
- */
962
- private _capacity;
963
- /**
964
- * Tweak for sparse creation.
965
- */
966
- private _tweak;
967
- /**
968
- * Initialize the prefix manager. This method is in lieu of a constructor due to the mixin architecture.
969
- *
970
- * @param prefixManager
971
- * Prefix manager.
972
- *
973
- * @param prefix
974
- * Prefix within prefix manager to use to calculate reference length.
975
- */
976
- protected init(prefixManager: PrefixManager, prefix: string): void;
977
- abstract get leaderType(): LeaderType;
978
- /**
979
- * @inheritDoc
980
- */
981
- get capacity(): number;
982
- /**
983
- * Get the tweak for sparse creation.
984
- */
985
- get tweak(): bigint;
986
- /**
987
- * Set the tweak for sparse creation.
988
- */
989
- set tweak(value: bigint);
990
- /**
991
- * Build an identification key from a reference by merging it with the prefix and adding the check digit.
992
- *
993
- * @param reference
994
- * Identification key reference.
995
- *
996
- * @returns
997
- * Identification key.
998
- */
999
- private buildIdentificationKey;
1000
- /**
1001
- * @inheritDoc
1002
- */
1003
- create<TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
1004
- /**
1005
- * Create all identification keys from a partial identification key. Call is recursive until remaining reference
1006
- * length is 0.
1007
- *
1008
- * @param partialIdentificationKey
1009
- * Partial identification key. Initial value is `this.prefix`.
1010
- *
1011
- * @param remainingReferenceLength
1012
- * Remaining reference length. Initial value is `this.referenceLength`.
1013
- *
1014
- * @param extensionWeight
1015
- * If this value is not zero, the identification key has an extension digit, this call is setting it, and this value
1016
- * is applied to the calculation of the check digit.
1017
- *
1018
- * @param weight
1019
- * If the extension weight is zero, this value is applied to the calculation of the check digit.
1020
- *
1021
- * @param partialCheckDigitSum
1022
- * Partial check digit sum for the partial identification key.
1023
- *
1024
- * @yields
1025
- * Identification key.
1026
- */
1027
- private static createAllPartial;
1028
- /**
1029
- * @inheritDoc
1030
- */
1031
- createAll(): Iterable<string>;
1032
- }
1033
- declare const GTINCreator_base: ts_mixer_dist_types_types_js.Class<any[], GTINValidator & AbstractNumericIdentificationKeyCreator, typeof GTINValidator & typeof AbstractNumericIdentificationKeyCreator>;
1034
- /**
1035
- * GTIN creator. Applicable to GTIN-13, GTIN-12, and GTIN-8 types; no applicable to GTIN-14 type.
1036
- */
1037
- declare class GTINCreator extends GTINCreator_base {
1038
- /**
1039
- * Validation parameters for required indicator digit.
1040
- */
1041
- private static readonly REQUIRED_INDICATOR_DIGIT_VALIDATION;
1042
- /**
1043
- * Constructor. Called internally by {@link PrefixManager.gtinCreator}; should not be called by other code.
1044
- *
1045
- * @param prefixManager
1046
- * Prefix manager.
1047
- *
1048
- * @param gtinType
1049
- * GTIN type.
1050
- */
1051
- constructor(prefixManager: PrefixManager, gtinType: GTINType);
1052
- /**
1053
- * @inheritDoc
1054
- */
1055
- get prefix(): string;
1056
- /**
1057
- * Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
1058
- * converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1059
- *
1060
- * @param indicatorDigit
1061
- * Indicator digit.
1062
- *
1063
- * @param valueOrValues
1064
- * Numeric value(s).
1065
- *
1066
- * @param sparse
1067
- * If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
1068
- *
1069
- * @returns
1070
- * GTIN-14(s).
1071
- */
1072
- createGTIN14<TTransformerInput extends TransformerInput<number | bigint>>(indicatorDigit: string, valueOrValues: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
1073
- }
1074
- declare const NonGTINNumericIdentificationKeyCreator_base: ts_mixer_dist_types_types_js.Class<any[], NonGTINNumericIdentificationKeyValidator & AbstractNumericIdentificationKeyCreator, typeof NonGTINNumericIdentificationKeyValidator & typeof AbstractNumericIdentificationKeyCreator>;
1075
- /**
1076
- * Non-GTIN numeric identification key creator.
1077
- */
1078
- declare class NonGTINNumericIdentificationKeyCreator extends NonGTINNumericIdentificationKeyCreator_base {
1079
- /**
1080
- * Constructor. Called internally by {@link PrefixManager} non-GTIN numeric identification key creator getters;
1081
- * should not be called by other code.
1082
- *
1083
- * @param prefixManager
1084
- * Prefix manager.
1085
- *
1086
- * @param identificationKeyType
1087
- * Identification key type.
1088
- *
1089
- * @param length
1090
- * Length.
1091
- *
1092
- * @param leaderType
1093
- * Leader type.
1094
- */
1095
- constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, leaderType?: LeaderType);
1096
- }
1097
- declare const SerializableNumericIdentificationKeyCreator_base: ts_mixer_dist_types_types_js.Class<any[], SerializableNumericIdentificationKeyValidator & AbstractNumericIdentificationKeyCreator, typeof SerializableNumericIdentificationKeyValidator & typeof AbstractNumericIdentificationKeyCreator>;
1098
- /**
1099
- * Serializable numeric identification key creator.
1100
- */
1101
- declare class SerializableNumericIdentificationKeyCreator extends SerializableNumericIdentificationKeyCreator_base {
1102
- /**
1103
- * Constructor. Called internally by {@link PrefixManager} serialized numeric identification key creator getters;
1104
- * should not be called by other code.
1105
- *
1106
- * @param prefixManager
1107
- * Prefix manager.
1108
- *
1109
- * @param identificationKeyType
1110
- * Identification key type.
1111
- *
1112
- * @param length
1113
- * Length.
1114
- *
1115
- * @param serialComponentLength
1116
- * Serial component length.
1117
- *
1118
- * @param serialComponentCharacterSet
1119
- * Serial component character set.
1120
- */
1121
- constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet: ContentCharacterSet);
1122
- /**
1123
- * Concatenate a validated base identification key with serial component(s).
1124
- *
1125
- * @param baseIdentificationKey
1126
- * Base identification key.
1127
- *
1128
- * @param serialComponentOrComponents
1129
- * Serial component(s).
1130
- *
1131
- * @returns
1132
- * Serialized identification key(s).
1133
- */
1134
- private concatenateValidated;
1135
- /**
1136
- * Create serialized identification key(s) with a reference based on a numeric value concatenated with serial
1137
- * component(s). The value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1138
- *
1139
- * @param value
1140
- * Numeric value of the reference.
1141
- *
1142
- * @param serialComponentOrComponents
1143
- * Serial component(s).
1144
- *
1145
- * @param sparse
1146
- * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
1147
- *
1148
- * @returns
1149
- * Serialized identification keys.
1150
- */
1151
- createSerialized<TTransformerInput extends TransformerInput<string>>(value: number, serialComponentOrComponents: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
1152
- /**
1153
- * Concatenate a base identification key with serial component(s).
1154
- *
1155
- * @param baseIdentificationKey
1156
- * Base identification key.
1157
- *
1158
- * @param serialComponentOrComponents
1159
- * Serial component(s).
1160
- *
1161
- * @returns
1162
- * Serialized identification key(s).
1163
- */
1164
- concatenate<TTransformerInput extends TransformerInput<string>>(baseIdentificationKey: string, serialComponentOrComponents: TTransformerInput): TransformerOutput<TTransformerInput, string>;
1165
- }
1166
- declare const NonNumericIdentificationKeyCreator_base: ts_mixer_dist_types_types_js.Class<any[], NonNumericIdentificationKeyValidator & AbstractIdentificationKeyCreator, typeof NonNumericIdentificationKeyValidator & typeof AbstractIdentificationKeyCreator>;
1167
- /**
1168
- * Non-numeric identification key creator.
1169
- */
1170
- declare class NonNumericIdentificationKeyCreator extends NonNumericIdentificationKeyCreator_base {
1171
- /**
1172
- * Reference validation parameters.
1173
- */
1174
- private readonly _referenceValidation;
1175
- /**
1176
- * Constructor. Called internally by {@link PrefixManager} non-numeric identification key creator getters; should
1177
- * not be called by other code.
1178
- *
1179
- * @param prefixManager
1180
- * Prefix manager.
1181
- *
1182
- * @param identificationKeyType
1183
- * Identification key type.
1184
- *
1185
- * @param length
1186
- * Length.
1187
- *
1188
- * @param referenceCharacterSet
1189
- * Reference character set.
1190
- *
1191
- * @param requiresCheckCharacterPair
1192
- * True if the identification key requires a check character pair.
1193
- */
1194
- constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair?: boolean);
1195
- /**
1196
- * Get the reference validation parameters.
1197
- */
1198
- protected get referenceValidation(): CharacterSetValidation;
1199
- /**
1200
- * Create identification key(s) with reference(s).
1201
- *
1202
- * @param referenceOrReferences
1203
- * Reference(s).
1204
- *
1205
- * @returns
1206
- * Identification key(s).
1207
- */
1208
- create<TTransformerInput extends TransformerInput<string>>(referenceOrReferences: TTransformerInput): TransformerOutput<TTransformerInput, string>;
1209
- }
1210
- /**
1211
- * Prefix manager. This is the core class for identification key creation.
1212
- *
1213
- * A prefix manager may be created for any {@link PrefixType | prefix type}. As most applications work with a limited
1214
- * number of prefixes for creating identification keys, prefix managers are cached in memory and may be reused.
1215
- *
1216
- * Prefix managers are keyed by GS1 Company Prefix, so the prefix type that is requested may not match the prefix type
1217
- * of the returned prefix manager. For example, the prefix manager for GS1 Company Prefix 0614141 is identical to the
1218
- * one for U.P.C. Company Prefix 614141, with the prefix type equal to {@link PrefixType.UPCCompanyPrefix} and the
1219
- * prefix equal to "614141".
1220
- *
1221
- * To support the creation of sparse identification keys, a prefix manager maintains a {@link tweakFactor | tweak
1222
- * factor} which is used, along with a type-specific multiplier, as the tweak when creating numeric identification keys.
1223
- * The default tweak factor is the numeric value of the GS1 Company Prefix representation of the prefix preceded by '1'
1224
- * to ensure uniqueness (i.e., so that prefixes 0 N1 N2 N3... and N1 N2 N3... produce different tweak factors). This is
1225
- * usually sufficient for obfuscation, but as the sparse creation algorithm is reversible and as the GS1 Company Prefix
1226
- * is discoverable via {@link https://www.gs1.org/services/verified-by-gs1 | Verified by GS1}, a user-defined tweak
1227
- * factor should be used if a higher degree of obfuscation is required. When using a tweak factor other than the
1228
- * default, care should be taken to restore it when resuming the application. A tweak factor of 0 creates a straight
1229
- * sequence.
1230
- */
1231
- declare class PrefixManager {
1232
- /**
1233
- * Cached prefix managers, keyed by GS1 Company Prefix.
1234
- */
1235
- private static readonly PREFIX_MANAGERS_MAP;
1236
- /**
1237
- * GS1 Company Prefix minimum length.
1238
- */
1239
- static readonly GS1_COMPANY_PREFIX_MINIMUM_LENGTH = 4;
1240
- /**
1241
- * GS1 Company Prefix maximum length.
1242
- */
1243
- static readonly GS1_COMPANY_PREFIX_MAXIMUM_LENGTH = 12;
1244
- /**
1245
- * U.P.C. Company Prefix minimum length.
1246
- */
1247
- static readonly UPC_COMPANY_PREFIX_MINIMUM_LENGTH = 6;
1248
- /**
1249
- * U.P.C. Company Prefix maximum length.
1250
- */
1251
- static readonly UPC_COMPANY_PREFIX_MAXIMUM_LENGTH = 11;
1252
- /**
1253
- * GS1-8 Prefix minimum length.
1254
- */
1255
- static readonly GS1_8_PREFIX_MINIMUM_LENGTH = 2;
1256
- /**
1257
- * GS1-8 Prefix maximum length.
1258
- */
1259
- static readonly GS1_8_PREFIX_MAXIMUM_LENGTH = 7;
1260
- /**
1261
- * Validation parameters for GS1 Company Prefix.
1262
- */
1263
- private static readonly GS1_COMPANY_PREFIX_VALIDATION;
1264
- /**
1265
- * Validation parameters for U.P.C. Company Prefix expressed as GS1 Company Prefix.
1266
- */
1267
- private static readonly UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION;
1268
- /**
1269
- * Validation parameters for GS1-8 Prefix expressed as GS1 Company Prefix.
1270
- */
1271
- private static readonly GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION;
1272
- /**
1273
- * Validation parameters for U.P.C. Company Prefix.
1274
- */
1275
- private static readonly UPC_COMPANY_PREFIX_VALIDATION;
1276
- /**
1277
- * Validation parameters for GS1-8 Prefix.
1278
- */
1279
- private static readonly GS1_8_PREFIX_VALIDATION;
1280
- /**
1281
- * Creator tweak factors. Different numeric identification key types have different tweak factors so that sparse
1282
- * creation generates different sequences for each.
1283
- */
1284
- private static readonly CREATOR_TWEAK_FACTORS_MAP;
1285
- /**
1286
- * Normalized prefix type.
1287
- */
1288
- private readonly _prefixType;
1289
- /**
1290
- * Normalized prefix.
1291
- */
1292
- private readonly _prefix;
1293
- /**
1294
- * Prefix as GS1 Company Prefix.
1295
- */
1296
- private readonly _gs1CompanyPrefix;
1297
- /**
1298
- * U.P.C. Company Prefix if prefix type is {@link PrefixType.UPCCompanyPrefix}.
1299
- */
1300
- private readonly _upcCompanyPrefix;
1301
- /**
1302
- * GS1-8 Prefix if prefix type is {@link PrefixType.GS18Prefix}.
1303
- */
1304
- private readonly _gs18Prefix;
1305
- /**
1306
- * Default tweak factor.
1307
- */
1308
- private readonly _defaultTweakFactor;
1309
- /**
1310
- * Tweak factor.
1311
- */
1312
- private _tweakFactor;
1313
- /**
1314
- * Cached identification key creators.
1315
- */
1316
- private readonly _identificationKeyCreatorsMap;
1317
- /**
1318
- * Constructor.
1319
- *
1320
- * @param gs1CompanyPrefix
1321
- * GS1 Company Prefix.
1322
- */
1323
- private constructor();
1324
- /**
1325
- * Get the prefix type.
1326
- */
1327
- get prefixType(): PrefixType;
1328
- /**
1329
- * Get the prefix.
1330
- */
1331
- get prefix(): string;
1332
- /**
1333
- * Get the GS1 Company Prefix.
1334
- */
1335
- get gs1CompanyPrefix(): string;
1336
- /**
1337
- * Get the U.P.C. Company Prefix if prefix type is {@link PrefixType.UPCCompanyPrefix} or undefined if not.
1338
- */
1339
- get upcCompanyPrefix(): string | undefined;
1340
- /**
1341
- * Get the GS1-8 Prefix if prefix type is {@link PrefixType.GS18Prefix} or undefined if not.
1342
- */
1343
- get gs18Prefix(): string | undefined;
1344
- /**
1345
- * Set the tweak for an identification key creator if it's a numeric identification key creator.
1346
- *
1347
- * @param creator
1348
- * Identification key creator.
1349
- */
1350
- private setCreatorTweak;
1351
- /**
1352
- * Get the tweak factor.
1353
- */
1354
- get tweakFactor(): bigint;
1355
- /**
1356
- * Set the tweak factor.
1357
- *
1358
- * @param value
1359
- * Tweak factor.
1360
- */
1361
- set tweakFactor(value: number | bigint);
1362
- /**
1363
- * Reset the tweak factor to its default (numeric value of the GS1 Company Prefix preceded by '1').
1364
- */
1365
- resetTweakFactor(): void;
1366
- /**
1367
- * Get a prefix manager.
1368
- *
1369
- * @param prefixType
1370
- * Prefix type.
1371
- *
1372
- * @param prefix
1373
- * Prefix.
1374
- *
1375
- * @returns
1376
- * Prefix manager with normalized prefix type and prefix.
1377
- */
1378
- static get(prefixType: PrefixType, prefix: string): PrefixManager;
1379
- /**
1380
- * Validate a prefix.
1381
- *
1382
- * @param prefixType
1383
- * Prefix type.
1384
- *
1385
- * @param allowUPCCompanyPrefix
1386
- * If true, a U.P.C. Company Prefix expressed as a GS1 Company Prefix is permitted.
1387
- *
1388
- * @param allowGS18Prefix
1389
- * If true, a GS1-8 Prefix expressed as a GS1 Company Prefix is permitted.
1390
- *
1391
- * @param prefix
1392
- * Prefix.
1393
- *
1394
- * @param isFromIdentificationKey
1395
- * If true, the prefix is from an identification key and should be trimmed before its character set is validated.
1396
- *
1397
- * @param isNumericIdentificationKey
1398
- * If true, the prefix is from a numeric identification key and its character set will be validated by the caller.
1399
- *
1400
- * @param positionOffset
1401
- * Position offset within a larger string.
1402
- */
1403
- static validatePrefix(prefixType: PrefixType, allowUPCCompanyPrefix: boolean, allowGS18Prefix: boolean, prefix: string, isFromIdentificationKey?: boolean, isNumericIdentificationKey?: boolean, positionOffset?: number): void;
1404
- /**
1405
- * Get an identification key creator.
1406
- *
1407
- * @param identificationKeyType
1408
- * Identification key type.
1409
- *
1410
- * @param constructorCallback
1411
- * Constructor callback.
1412
- *
1413
- * @returns
1414
- * Identification key creator.
1415
- */
1416
- private getIdentificationKeyCreator;
1417
- /**
1418
- * Get non-GTIN numeric identification key creator.
1419
- *
1420
- * @param validator
1421
- * Validator on which identification key creator is based.
1422
- *
1423
- * @returns
1424
- * Identification key creator.
1425
- */
1426
- private getNonGTINNumericIdentificationKeyCreator;
1427
- /**
1428
- * Get serialized numeric identification key creator.
1429
- *
1430
- * @param validator
1431
- * Validator on which identification key creator is based.
1432
- *
1433
- * @returns
1434
- * Identification key creator.
1435
- */
1436
- private getSerializableNumericIdentificationKeyCreator;
1437
- /**
1438
- * Get non-numeric identification key creator.
1439
- *
1440
- * @param validator
1441
- * Validator on which identification key creator is based.
1442
- *
1443
- * @returns
1444
- * Identification key creator.
1445
- */
1446
- private getNonNumericIdentificationKeyCreator;
1447
- /**
1448
- * Get GTIN creator.
1449
- */
1450
- get gtinCreator(): GTINCreator;
1451
- /**
1452
- * Get GLN creator.
1453
- */
1454
- get glnCreator(): NonGTINNumericIdentificationKeyCreator;
1455
- /**
1456
- * Get SSCC creator.
1457
- */
1458
- get ssccCreator(): NonGTINNumericIdentificationKeyCreator;
1459
- /**
1460
- * Get GRAI creator.
1461
- */
1462
- get graiCreator(): SerializableNumericIdentificationKeyCreator;
1463
- /**
1464
- * Get GIAI creator.
1465
- */
1466
- get giaiCreator(): NonNumericIdentificationKeyCreator;
1467
- /**
1468
- * Get GSRN creator.
1469
- */
1470
- get gsrnCreator(): NonGTINNumericIdentificationKeyCreator;
1471
- /**
1472
- * Get GDTI creator.
1473
- */
1474
- get gdtiCreator(): SerializableNumericIdentificationKeyCreator;
1475
- /**
1476
- * Get GINC creator.
1477
- */
1478
- get gincCreator(): NonNumericIdentificationKeyCreator;
1479
- /**
1480
- * Get GSIN creator.
1481
- */
1482
- get gsinCreator(): NonGTINNumericIdentificationKeyCreator;
1483
- /**
1484
- * Get GCN creator.
1485
- */
1486
- get gcnCreator(): SerializableNumericIdentificationKeyCreator;
1487
- /**
1488
- * Get CPID creator.
1489
- */
1490
- get cpidCreator(): NonNumericIdentificationKeyCreator;
1491
- /**
1492
- * Get GMN creator.
1493
- */
1494
- get gmnCreator(): NonNumericIdentificationKeyCreator;
1495
- }
1496
-
1497
- export { AI39_CREATOR, AI82_CREATOR, CPID_VALIDATOR, ContentCharacterSet, GCN_VALIDATOR, GDTI_VALIDATOR, GIAI_VALIDATOR, GINC_VALIDATOR, GLN_VALIDATOR, GMN_VALIDATOR, GRAI_VALIDATOR, type GS1LocaleStrings, 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, gs1Resources, hasValidCheckCharacterPair, hasValidCheckDigit, i18nGS1Init, i18nextGS1 };
1
+ /*!
2
+ * Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
3
+ * contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export * from "./locale/i18n.js";
18
+ export * from "./character-set.js";
19
+ export * from "./check.js";
20
+ export * from "./idkey.js";
21
+ //# sourceMappingURL=index.d.ts.map