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