@aidc-toolkit/gs1 0.9.0 → 0.9.2

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/src/idkey.ts CHANGED
@@ -2,7 +2,8 @@ import {
2
2
  CharacterSetCreator,
3
3
  type CharacterSetValidation,
4
4
  type CharacterSetValidator,
5
- Exclusion, IterationHelper, type IterationSource, NUMERIC_CREATOR,
5
+ Exclusion,
6
+ NUMERIC_CREATOR,
6
7
  RegExpValidator,
7
8
  type StringValidation,
8
9
  type StringValidator
@@ -130,7 +131,7 @@ export enum CharacterSet {
130
131
  export interface IdentificationKeyValidation extends StringValidation {
131
132
  /**
132
133
  * Position offset within a larger string. Strings are sometimes composed of multiple substrings; this parameter
133
- * ensures that the exception notes the proper position in the string.
134
+ * ensures that the error notes the proper position in the string.
134
135
  */
135
136
  positionOffset?: number | undefined;
136
137
  }
@@ -139,7 +140,7 @@ export interface IdentificationKeyValidation extends StringValidation {
139
140
  * Identification key validator. Validates an identification key against its definition in section 3 of the {@link
140
141
  * https://www.gs1.org/genspecs | GS1 General Specifications}.
141
142
  */
142
- export interface IdentificationKeyValidator extends StringValidator {
143
+ export interface IdentificationKeyValidator<V extends IdentificationKeyValidation = IdentificationKeyValidation> extends StringValidator<V> {
143
144
  /**
144
145
  * Get the identification key type. Per the GS1 General Specifications, the identification key type determines
145
146
  * the remaining properties.
@@ -169,7 +170,7 @@ export interface IdentificationKeyValidator extends StringValidator {
169
170
  get referenceValidator(): CharacterSetValidator;
170
171
 
171
172
  /**
172
- * Validate an identification key and throw an exception if validation fails.
173
+ * Validate an identification key and throw an error if validation fails.
173
174
  *
174
175
  * @param identificationKey
175
176
  * Identification key.
@@ -177,13 +178,17 @@ export interface IdentificationKeyValidator extends StringValidator {
177
178
  * @param validation
178
179
  * Identification key validation parameters.
179
180
  */
180
- validate: (identificationKey: string, validation?: IdentificationKeyValidation) => void;
181
+ validate: (identificationKey: string, validation?: V) => void;
181
182
  }
182
183
 
183
184
  /**
184
185
  * Abstract identification key validator. Implements common functionality for an identification key validator.
185
186
  */
186
- abstract class AbstractIdentificationKeyValidator implements IdentificationKeyValidator {
187
+ abstract class AbstractIdentificationKeyValidator<V extends IdentificationKeyValidation = IdentificationKeyValidation> implements IdentificationKeyValidator<V> {
188
+ private static readonly CHARACTER_SET_CREATORS = [
189
+ NUMERIC_CREATOR, AI82_CREATOR, AI39_CREATOR
190
+ ];
191
+
187
192
  /**
188
193
  * Identification key type.
189
194
  */
@@ -205,7 +210,7 @@ abstract class AbstractIdentificationKeyValidator implements IdentificationKeyVa
205
210
  private readonly _referenceCharacterSet: CharacterSet;
206
211
 
207
212
  /**
208
- * Character set validator.
213
+ * Reference validator.
209
214
  */
210
215
  private readonly _referenceValidator: CharacterSetValidator;
211
216
 
@@ -219,23 +224,7 @@ abstract class AbstractIdentificationKeyValidator implements IdentificationKeyVa
219
224
  * Character set validator.
220
225
  */
221
226
  protected static validatorFor(characterSet: CharacterSet): CharacterSetValidator {
222
- let characterSetValidator: CharacterSetValidator;
223
-
224
- switch (characterSet) {
225
- case CharacterSet.Numeric:
226
- characterSetValidator = NUMERIC_CREATOR;
227
- break;
228
-
229
- case CharacterSet.AI82:
230
- characterSetValidator = AI82_CREATOR;
231
- break;
232
-
233
- case CharacterSet.AI39:
234
- characterSetValidator = AI39_CREATOR;
235
- break;
236
- }
237
-
238
- return characterSetValidator;
227
+ return AbstractIdentificationKeyValidator.CHARACTER_SET_CREATORS[characterSet];
239
228
  }
240
229
 
241
230
  /**
@@ -261,28 +250,43 @@ abstract class AbstractIdentificationKeyValidator implements IdentificationKeyVa
261
250
  this._referenceValidator = AbstractIdentificationKeyValidator.validatorFor(referenceCharacterSet);
262
251
  }
263
252
 
253
+ /**
254
+ * @inheritDoc
255
+ */
264
256
  get identificationKeyType(): IdentificationKeyType {
265
257
  return this._identificationKeyType;
266
258
  }
267
259
 
260
+ /**
261
+ * @inheritDoc
262
+ */
268
263
  get prefixType(): PrefixType {
269
264
  return this._prefixType;
270
265
  }
271
266
 
267
+ /**
268
+ * @inheritDoc
269
+ */
272
270
  get length(): number {
273
271
  return this._length;
274
272
  }
275
273
 
274
+ /**
275
+ * @inheritDoc
276
+ */
276
277
  get referenceCharacterSet(): CharacterSet {
277
278
  return this._referenceCharacterSet;
278
279
  }
279
280
 
281
+ /**
282
+ * @inheritDoc
283
+ */
280
284
  get referenceValidator(): CharacterSetValidator {
281
285
  return this._referenceValidator;
282
286
  }
283
287
 
284
288
  /**
285
- * Pad an identification key on the left with zeroes for validation purposes. This is done to align an
289
+ * Pad an identification key on the left with zero-value character for validation purposes. This is done to align an
286
290
  * identification key with a position offset for any error message that may be thrown by the reference validator.
287
291
  *
288
292
  * @param identificationKey
@@ -294,9 +298,9 @@ abstract class AbstractIdentificationKeyValidator implements IdentificationKeyVa
294
298
  * @returns
295
299
  * Padded identification key.
296
300
  */
297
- protected static padIdentificationKey(identificationKey: string, validation: IdentificationKeyValidation | undefined): string {
301
+ protected padIdentificationKey(identificationKey: string, validation: IdentificationKeyValidation | undefined): string {
298
302
  // Identification key is returned as is if position offset is undefined.
299
- return validation?.positionOffset === undefined ? identificationKey : "0".repeat(validation.positionOffset).concat(identificationKey);
303
+ return validation?.positionOffset === undefined ? identificationKey : this.referenceValidator.character(0).repeat(validation.positionOffset).concat(identificationKey);
300
304
  }
301
305
 
302
306
  /**
@@ -313,7 +317,7 @@ abstract class AbstractIdentificationKeyValidator implements IdentificationKeyVa
313
317
  PrefixManager.validatePrefix(this.prefixType, true, false, partialIdentificationKey, true, this.referenceCharacterSet === CharacterSet.Numeric, positionOffset);
314
318
  }
315
319
 
316
- abstract validate(identificationKey: string, validation?: IdentificationKeyValidation): void;
320
+ abstract validate(identificationKey: string, validation?: V): void;
317
321
  }
318
322
 
319
323
  /**
@@ -383,10 +387,16 @@ abstract class AbstractNumericIdentificationKeyValidator extends AbstractIdentif
383
387
  this._prefixPosition = Number(this.leaderType === LeaderType.ExtensionDigit);
384
388
  }
385
389
 
390
+ /**
391
+ * @inheritDoc
392
+ */
386
393
  get leaderType(): LeaderType {
387
394
  return this._leaderType;
388
395
  }
389
396
 
397
+ /**
398
+ * @inheritDoc
399
+ */
390
400
  validate(identificationKey: string, validation?: IdentificationKeyValidation): void {
391
401
  // Validate the prefix, with care taken for its position within the identification key.
392
402
  if (this._prefixPosition === 0) {
@@ -405,7 +415,7 @@ abstract class AbstractNumericIdentificationKeyValidator extends AbstractIdentif
405
415
  }
406
416
 
407
417
  // Validating the check digit will also validate the characters.
408
- if (!hasValidCheckDigit(AbstractIdentificationKeyValidator.padIdentificationKey(identificationKey, validation))) {
418
+ if (!hasValidCheckDigit(this.padIdentificationKey(identificationKey, validation))) {
409
419
  throw new RangeError(i18next.t("IdentificationKey.invalidCheckDigit", {
410
420
  ns: gs1NS
411
421
  }));
@@ -501,11 +511,17 @@ export class GTINValidator extends AbstractNumericIdentificationKeyValidator {
501
511
  super(IdentificationKeyType.GTIN, prefixType, gtinType, LeaderType.IndicatorDigit);
502
512
  }
503
513
 
514
+ /**
515
+ * @inheritDoc
516
+ */
504
517
  get gtinType(): GTINType {
505
518
  // Length maps to GTIN type enumeration.
506
- return this.length as GTINType;
519
+ return this.length satisfies GTINType;
507
520
  }
508
521
 
522
+ /**
523
+ * @inheritDoc
524
+ */
509
525
  protected override validatePrefix(partialIdentificationKey: string, positionOffset?: number): void {
510
526
  // Delegate to prefix manager requiring exact match for prefix type.
511
527
  PrefixManager.validatePrefix(this.prefixType, false, false, partialIdentificationKey, true, true, positionOffset);
@@ -519,8 +535,6 @@ export class GTINValidator extends AbstractNumericIdentificationKeyValidator {
519
535
  *
520
536
  * @returns
521
537
  * GTIN-12.
522
- *
523
- * @throws RangeError
524
538
  */
525
539
  static zeroExpand(zeroSuppressedGTIN12: string): string {
526
540
  NUMERIC_CREATOR.validate(zeroSuppressedGTIN12, GTINValidator.ZERO_SUPPRESSED_GTIN12_VALIDATION);
@@ -563,8 +577,6 @@ export class GTINValidator extends AbstractNumericIdentificationKeyValidator {
563
577
  *
564
578
  * @param gtinLevel
565
579
  * Level at which GTIN is to be validated.
566
- *
567
- * @throws RangeError
568
580
  */
569
581
  static validateAny(gtin: string, gtinLevel: GTINLevel = GTINLevel.Any): void {
570
582
  // Assume length-validated GTIN is the GTIN (true for all except zero-suppressed GTIN-12).
@@ -638,11 +650,9 @@ export class GTINValidator extends AbstractNumericIdentificationKeyValidator {
638
650
  *
639
651
  * @param gtin14
640
652
  * GTIN-14.
641
- *
642
- * @throws RangeError
643
653
  */
644
654
  static validateGTIN14(gtin14: string): void {
645
- if (gtin14.length !== GTINType.GTIN14 as number) {
655
+ if (gtin14.length as GTINType !== GTINType.GTIN14) {
646
656
  throw new RangeError(i18next.t("IdentificationKey.invalidGTIN14Length", {
647
657
  ns: gs1NS
648
658
  }));
@@ -689,7 +699,7 @@ export class SerializableNumericIdentificationKeyValidator extends NonGTINNumeri
689
699
  private readonly _serialComponentCharacterSet: CharacterSet;
690
700
 
691
701
  /**
692
- * Serial component character set validation parameters.
702
+ * Serial component validation parameters.
693
703
  */
694
704
  private readonly _serialComponentValidation: CharacterSetValidation;
695
705
 
@@ -758,6 +768,9 @@ export class SerializableNumericIdentificationKeyValidator extends NonGTINNumeri
758
768
  return this._serialComponentValidator;
759
769
  }
760
770
 
771
+ /**
772
+ * @inheritDoc
773
+ */
761
774
  override validate(identificationKey: string, validation?: IdentificationKeyValidation): void {
762
775
  super.validate(identificationKey.substring(0, this.length), validation);
763
776
 
@@ -771,17 +784,24 @@ export class SerializableNumericIdentificationKeyValidator extends NonGTINNumeri
771
784
  * Non-numeric identification key validation parameters.
772
785
  */
773
786
  export interface NonNumericIdentificationKeyValidation extends IdentificationKeyValidation {
787
+ /**
788
+ * Exclusion support for reference. Prevents non-numeric identification key from being mistaken for numeric
789
+ * identification key.
790
+ */
774
791
  exclusion?: Exclusion.None | Exclusion.AllNumeric | undefined;
775
792
  }
776
793
 
777
794
  /**
778
795
  * Non-numeric identification key validator.
779
796
  */
780
- export class NonNumericIdentificationKeyValidator extends AbstractIdentificationKeyValidator {
797
+ export class NonNumericIdentificationKeyValidator extends AbstractIdentificationKeyValidator<NonNumericIdentificationKeyValidation> {
781
798
  /**
782
799
  * Validator to ensure that an identification key (minus check character pair) is not all numeric.
783
800
  */
784
801
  private static readonly NOT_ALL_NUMERIC_VALIDATOR = new class extends RegExpValidator {
802
+ /**
803
+ * @inheritDoc
804
+ */
785
805
  protected override createErrorMessage(_s: string): string {
786
806
  return i18next.t("IdentificationKey.referenceCantBeAllNumeric", {
787
807
  ns: gs1NS
@@ -822,6 +842,15 @@ export class NonNumericIdentificationKeyValidator extends AbstractIdentification
822
842
  return this._requiresCheckCharacterPair;
823
843
  }
824
844
 
845
+ /**
846
+ * Validate a non-numeric identification key and throw an error if validation fails.
847
+ *
848
+ * @param identificationKey
849
+ * Identification key.
850
+ *
851
+ * @param validation
852
+ * Validation parameters.
853
+ */
825
854
  validate(identificationKey: string, validation?: NonNumericIdentificationKeyValidation): void {
826
855
  const partialIdentificationKey = this.requiresCheckCharacterPair ? identificationKey.substring(0, identificationKey.length - 2) : identificationKey;
827
856
 
@@ -833,7 +862,7 @@ export class NonNumericIdentificationKeyValidator extends AbstractIdentification
833
862
  positionOffset: validation?.positionOffset
834
863
  });
835
864
  // Validating the check character pair will also validate the characters.
836
- } else if (!hasValidCheckCharacterPair(AbstractIdentificationKeyValidator.padIdentificationKey(identificationKey, validation))) {
865
+ } else if (!hasValidCheckCharacterPair(this.padIdentificationKey(identificationKey, validation))) {
837
866
  throw new RangeError(i18next.t("IdentificationKey.invalidCheckCharacterPair", {
838
867
  ns: gs1NS
839
868
  }));
@@ -961,12 +990,12 @@ abstract class AbstractIdentificationKeyCreator implements IdentificationKeyCrea
961
990
  /**
962
991
  * Prefix manager.
963
992
  */
964
- private _prefixManager?: PrefixManager;
993
+ private _prefixManager!: PrefixManager;
965
994
 
966
995
  /**
967
996
  * Reference length.
968
997
  */
969
- private _referenceLength?: number;
998
+ private _referenceLength!: number;
970
999
 
971
1000
  /**
972
1001
  * Initialize the prefix manager. This method is in lieu of a constructor due to the mixin architecture.
@@ -979,16 +1008,8 @@ abstract class AbstractIdentificationKeyCreator implements IdentificationKeyCrea
979
1008
  *
980
1009
  * @param checkAllowance
981
1010
  * Number of characters to allow for check digit or check character pair.
982
- *
983
- * @throws Error
984
1011
  */
985
1012
  protected init(prefixManager: PrefixManager, prefix: string, checkAllowance: number): void {
986
- // Verify that prefix manager has not already been assigned.
987
- if (this._prefixManager !== undefined) {
988
- // Should never get here.
989
- throw new Error("Not supported");
990
- }
991
-
992
1013
  this._prefixManager = prefixManager;
993
1014
 
994
1015
  // Reference length allows for prefix and optionally check digit or check character pair.
@@ -1005,22 +1026,32 @@ abstract class AbstractIdentificationKeyCreator implements IdentificationKeyCrea
1005
1026
 
1006
1027
  abstract get referenceValidator(): CharacterSetValidator;
1007
1028
 
1029
+ /**
1030
+ * @inheritDoc
1031
+ */
1008
1032
  get referenceCreator(): CharacterSetCreator {
1009
1033
  return this.referenceValidator as CharacterSetCreator;
1010
1034
  }
1011
1035
 
1036
+ /**
1037
+ * @inheritDoc
1038
+ */
1012
1039
  get prefixManager(): PrefixManager {
1013
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1014
- return this._prefixManager!;
1040
+ return this._prefixManager;
1015
1041
  }
1016
1042
 
1043
+ /**
1044
+ * @inheritDoc
1045
+ */
1017
1046
  get prefix(): string {
1018
1047
  return this.prefixManager.gs1CompanyPrefix;
1019
1048
  }
1020
1049
 
1050
+ /**
1051
+ * @inheritDoc
1052
+ */
1021
1053
  get referenceLength(): number {
1022
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1023
- return this._referenceLength!;
1054
+ return this._referenceLength;
1024
1055
  }
1025
1056
 
1026
1057
  abstract validate(identificationKey: string, validation?: IdentificationKeyValidation): void;
@@ -1035,58 +1066,37 @@ export interface NumericIdentificationKeyCreator extends NumericIdentificationKe
1035
1066
  */
1036
1067
  get capacity(): number;
1037
1068
 
1038
- /**
1039
- * Create an identification key with a reference based on a numeric value. The value is converted to a reference of
1040
- * the appropriate length using {@linkcode NUMERIC_CREATOR}.
1041
- *
1042
- * @param value
1043
- * Numeric value.
1044
- *
1045
- * @param sparse
1046
- * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
1047
- *
1048
- * @returns
1049
- * Identification key.
1050
- */
1051
- create: (value: number, sparse?: boolean) => string;
1052
-
1053
- /**
1054
- * Create a sequence of identification keys with references based on a sequence of numeric values. The values are
1055
- * converted to references of the appropriate length using {@linkcode NUMERIC_CREATOR}. References are created with
1056
- * values from `startValue` to `startValue + count - 1`.
1057
- *
1058
- * The implementation uses {@link CharacterSetCreator.createSequence}, so the values are created only as needed.
1059
- *
1060
- * @param startValue
1061
- * Start numeric value.
1062
- *
1063
- * @param count
1064
- * Count of identification keys to create.
1065
- *
1066
- * @param sparse
1067
- * If true, the values are mapped to a sparse sequence resistant to discovery. Default is false.
1068
- *
1069
- * @returns
1070
- * Iterable iterator over created identification keys.
1071
- */
1072
- createSequence: (startValue: number, count: number, sparse?: boolean) => IterableIterator<string>;
1073
-
1074
- /**
1075
- * Create multiple identification keys with references based on numeric values. The values are converted to
1076
- * references of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1077
- *
1078
- * The implementation uses {@link CharacterSetCreator.createMultiple}, so the values are created only as needed.
1079
- *
1080
- * @param valuesSource
1081
- * Source of values.
1082
- *
1083
- * @param sparse
1084
- * If true, the values are mapped to a sparse sequence resistant to discovery. Default is false.
1085
- *
1086
- * @returns
1087
- * Iterable iterator over created identification keys.
1088
- */
1089
- createMultiple: (valuesSource: IterationSource<number>, sparse?: boolean) => IterableIterator<string>;
1069
+ create: {
1070
+ /**
1071
+ * Create an identification key with a reference based on a numeric value. The value is converted to a reference of
1072
+ * the appropriate length using {@linkcode NUMERIC_CREATOR}.
1073
+ *
1074
+ * @param value
1075
+ * Numeric value.
1076
+ *
1077
+ * @param sparse
1078
+ * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
1079
+ *
1080
+ * @returns
1081
+ * Identification key.
1082
+ */
1083
+ (value: number | bigint, sparse?: boolean): string;
1084
+
1085
+ /**
1086
+ * Create identification keys with references based on numeric values. The values are converted to references of
1087
+ * the appropriate length using {@linkcode NUMERIC_CREATOR}.
1088
+ *
1089
+ * @param values
1090
+ * Numeric values.
1091
+ *
1092
+ * @param sparse
1093
+ * If true, the values are mapped to a sparse sequence resistant to discovery. Default is false.
1094
+ *
1095
+ * @returns
1096
+ * Identification keys.
1097
+ */
1098
+ (values: Iterable<number | bigint>, sparse?: boolean): IterableIterator<string>;
1099
+ };
1090
1100
 
1091
1101
  /**
1092
1102
  * Create all identification keys for the prefix from `0` to `capacity - 1`.
@@ -1107,7 +1117,7 @@ abstract class AbstractNumericIdentificationKeyCreator extends AbstractIdentific
1107
1117
  /**
1108
1118
  * Capacity.
1109
1119
  */
1110
- private _capacity?: number;
1120
+ private _capacity!: number;
1111
1121
 
1112
1122
  /**
1113
1123
  * Tweak for sparse creation.
@@ -1122,8 +1132,6 @@ abstract class AbstractNumericIdentificationKeyCreator extends AbstractIdentific
1122
1132
  *
1123
1133
  * @param prefix
1124
1134
  * Prefix within prefix manager to use to calculate reference length.
1125
- *
1126
- * @throws Error
1127
1135
  */
1128
1136
  protected override init(prefixManager: PrefixManager, prefix: string): void {
1129
1137
  super.init(prefixManager, prefix, 1);
@@ -1134,9 +1142,11 @@ abstract class AbstractNumericIdentificationKeyCreator extends AbstractIdentific
1134
1142
 
1135
1143
  abstract get leaderType(): LeaderType;
1136
1144
 
1145
+ /**
1146
+ * @inheritDoc
1147
+ */
1137
1148
  get capacity(): number {
1138
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1139
- return this._capacity!;
1149
+ return this._capacity;
1140
1150
  }
1141
1151
 
1142
1152
  /**
@@ -1168,16 +1178,19 @@ abstract class AbstractNumericIdentificationKeyCreator extends AbstractIdentific
1168
1178
  return partialIdentificationKey + checkDigit(partialIdentificationKey);
1169
1179
  }
1170
1180
 
1171
- create(value: number, sparse = false): string {
1172
- return NUMERIC_CREATOR.create(this.referenceLength, value, Exclusion.None, sparse ? this.tweak : undefined, reference => this.buildIdentificationKey(reference));
1173
- }
1181
+ /**
1182
+ * @inheritDoc
1183
+ */
1184
+ create(value: number | bigint, sparse?: boolean): string;
1174
1185
 
1175
- createSequence(startValue: number, count: number, sparse = false): IterableIterator<string> {
1176
- return NUMERIC_CREATOR.createSequence(this.referenceLength, startValue, count, Exclusion.None, sparse ? this.tweak : undefined, reference => this.buildIdentificationKey(reference));
1177
- }
1186
+ /**
1187
+ * @inheritDoc
1188
+ */
1189
+ create(values: Iterable<number | bigint>, sparse?: boolean): IterableIterator<string>;
1178
1190
 
1179
- createMultiple(valuesSource: IterationSource<number>, sparse = false): IterableIterator<string> {
1180
- return NUMERIC_CREATOR.createMultiple(this.referenceLength, valuesSource, Exclusion.None, sparse ? this.tweak : undefined, reference => this.buildIdentificationKey(reference));
1191
+ // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1192
+ create(valueOrValues: number | bigint | Iterable<number | bigint>, sparse = false): string | IterableIterator<string> {
1193
+ return NUMERIC_CREATOR.create(this.referenceLength, valueOrValues, Exclusion.None, sparse ? this.tweak : undefined, reference => this.buildIdentificationKey(reference));
1181
1194
  }
1182
1195
 
1183
1196
  /**
@@ -1232,6 +1245,9 @@ abstract class AbstractNumericIdentificationKeyCreator extends AbstractIdentific
1232
1245
  }
1233
1246
  }
1234
1247
 
1248
+ /**
1249
+ * @inheritDoc
1250
+ */
1235
1251
  createAll(): IterableIterator<string> {
1236
1252
  const hasExtensionDigit = this.leaderType === LeaderType.ExtensionDigit;
1237
1253
  const prefix = this.prefix;
@@ -1285,26 +1301,11 @@ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentificat
1285
1301
  this.init(prefixManager, prefixManager.prefix);
1286
1302
  }
1287
1303
 
1288
- override get prefix(): string {
1289
- return this.prefixManager.prefix;
1290
- }
1291
-
1292
1304
  /**
1293
- * Build a GTIN-14 from an indicator digit, the prefix, and a reference.
1294
- *
1295
- * @param indicatorDigit
1296
- * Indicator digit.
1297
- *
1298
- * @param reference
1299
- * Reference.
1300
- *
1301
- * @returns
1302
- * GTIN-14.
1305
+ * @inheritDoc
1303
1306
  */
1304
- private buildGTIN14(indicatorDigit: string, reference: string): string {
1305
- const partialIdentificationKey = indicatorDigit + this.prefixManager.gs1CompanyPrefix + reference;
1306
-
1307
- return partialIdentificationKey + checkDigit(partialIdentificationKey);
1307
+ override get prefix(): string {
1308
+ return this.prefixManager.prefix;
1308
1309
  }
1309
1310
 
1310
1311
  /**
@@ -1315,7 +1316,7 @@ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentificat
1315
1316
  * Indicator digit.
1316
1317
  *
1317
1318
  * @param value
1318
- * Numeric value.
1319
+ * Numeric value of the reference.
1319
1320
  *
1320
1321
  * @param sparse
1321
1322
  * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
@@ -1323,51 +1324,19 @@ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentificat
1323
1324
  * @returns
1324
1325
  * GTIN-14.
1325
1326
  */
1326
- createGTIN14(indicatorDigit: string, value: number, sparse = false): string {
1327
- NUMERIC_CREATOR.validate(indicatorDigit, GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
1328
-
1329
- return NUMERIC_CREATOR.create(GTINType.GTIN13 - this.prefixManager.gs1CompanyPrefix.length - 1, value, Exclusion.None, sparse ? this.tweak : undefined, reference => this.buildGTIN14(indicatorDigit, reference));
1330
- }
1331
-
1332
- /**
1333
- * Create a sequence of GTIN-14s with an indicator digit and references based on a sequence of numeric values.
1334
- * The values are converted to references of the appropriate length using {@linkcode NUMERIC_CREATOR}. References
1335
- * are created with values from `startValue` to `startValue + count - 1`.
1336
- *
1337
- * The implementation uses {@link CharacterSetCreator.createSequence}, so the values are created only as needed.
1338
- *
1339
- * @param indicatorDigit
1340
- * Indicator digit.
1341
- *
1342
- * @param startValue
1343
- * Start numeric value.
1344
- *
1345
- * @param count
1346
- * Count of identification keys to create.
1347
- *
1348
- * @param sparse
1349
- * If true, the values are mapped to a sparse sequence resistant to discovery. Default is false.
1350
- *
1351
- * @returns
1352
- * Iterable iterator over created GTIN-14s.
1353
- */
1354
- createGTIN14Sequence(indicatorDigit: string, startValue: number, count: number, sparse = false): IterableIterator<string> {
1355
- NUMERIC_CREATOR.validate(indicatorDigit, GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
1356
-
1357
- return NUMERIC_CREATOR.createSequence(GTINType.GTIN13 - this.prefixManager.gs1CompanyPrefix.length - 1, startValue, count, Exclusion.None, sparse ? this.tweak : undefined, reference => this.buildGTIN14(indicatorDigit, reference));
1358
- }
1327
+ createGTIN14(indicatorDigit: string, value: number | bigint, sparse?: boolean): string;
1359
1328
 
1360
1329
  /**
1361
1330
  * Create multiple GTIN-14s with an indicator digit and references based on numeric values. The values are converted
1362
1331
  * to references of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1363
1332
  *
1364
- * The implementation uses {@link CharacterSetCreator.createMultiple}, so the values are created only as needed.
1333
+ * The implementation uses {@link CharacterSetCreator.create}, so the values are created only as needed.
1365
1334
  *
1366
1335
  * @param indicatorDigit
1367
1336
  * Indicator digit.
1368
1337
  *
1369
- * @param valuesSource
1370
- * Source of values.
1338
+ * @param values
1339
+ * Values.
1371
1340
  *
1372
1341
  * @param sparse
1373
1342
  * If true, the values are mapped to a sparse sequence resistant to discovery. Default is false.
@@ -1375,10 +1344,17 @@ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentificat
1375
1344
  * @returns
1376
1345
  * Iterable iterator over created GTIN-14s.
1377
1346
  */
1378
- createGTIN14Multiple(indicatorDigit: string, valuesSource: IterationSource<number>, sparse = false): IterableIterator<string> {
1347
+ createGTIN14(indicatorDigit: string, values: Iterable<number | bigint>, sparse?: boolean): IterableIterator<string>;
1348
+
1349
+ // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1350
+ createGTIN14(indicatorDigit: string, valueOrValues: number | bigint | Iterable<number | bigint>, sparse = false): string | IterableIterator<string> {
1379
1351
  NUMERIC_CREATOR.validate(indicatorDigit, GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
1380
1352
 
1381
- return NUMERIC_CREATOR.createMultiple(GTINType.GTIN13 - this.prefixManager.gs1CompanyPrefix.length - 1, valuesSource, Exclusion.None, sparse ? this.tweak : undefined, reference => this.buildGTIN14(indicatorDigit, reference));
1353
+ return NUMERIC_CREATOR.create(GTINType.GTIN13 - this.prefixManager.gs1CompanyPrefix.length - 1, valueOrValues, Exclusion.None, sparse ? this.tweak : undefined, (reference) => {
1354
+ const partialIdentificationKey = indicatorDigit + this.prefixManager.gs1CompanyPrefix + reference;
1355
+
1356
+ return partialIdentificationKey + checkDigit(partialIdentificationKey);
1357
+ });
1382
1358
  }
1383
1359
 
1384
1360
  /**
@@ -1389,8 +1365,6 @@ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentificat
1389
1365
  *
1390
1366
  * @returns
1391
1367
  * Zero-suppressed GTIN-12.
1392
- *
1393
- * @throws RangeError
1394
1368
  */
1395
1369
  static zeroSuppress(gtin12: string): string {
1396
1370
  GTIN12_VALIDATOR.validate(gtin12);
@@ -1466,8 +1440,6 @@ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentificat
1466
1440
  *
1467
1441
  * @returns
1468
1442
  * Normalized GTIN.
1469
- *
1470
- * @throws RangeError
1471
1443
  */
1472
1444
  static normalize(gtin: string): string {
1473
1445
  const gtinLength = gtin.length;
@@ -1498,7 +1470,7 @@ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentificat
1498
1470
  break;
1499
1471
 
1500
1472
  case GTINType.GTIN8 as number:
1501
- if (gtin.charAt(0) !== "0") {
1473
+ if (!gtin.startsWith("0")) {
1502
1474
  // GTIN is GTIN-8.
1503
1475
  normalizedGTIN = gtin;
1504
1476
  } else {
@@ -1615,11 +1587,7 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1615
1587
  * @returns
1616
1588
  * Serialized identification key.
1617
1589
  */
1618
- private concatenateValidated(baseIdentificationKey: string, serialComponent: string): string {
1619
- this.serialComponentCreator.validate(serialComponent, this.serialComponentValidation);
1620
-
1621
- return baseIdentificationKey + serialComponent;
1622
- }
1590
+ private concatenateValidated(baseIdentificationKey: string, serialComponent: string): string;
1623
1591
 
1624
1592
  /**
1625
1593
  * Concatenate a validated base identification key with multiple serial components.
@@ -1627,14 +1595,27 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1627
1595
  * @param baseIdentificationKey
1628
1596
  * Base identification key.
1629
1597
  *
1630
- * @param serialComponentsSource
1631
- * Source of serial components.
1598
+ * @param serialComponents
1599
+ * Serial components.
1632
1600
  *
1633
1601
  * @returns
1634
1602
  * Serialized identification keys.
1635
1603
  */
1636
- private concatenateValidatedMultiple(baseIdentificationKey: string, serialComponentsSource: IterationSource<string>): IterableIterator<string> {
1637
- return IterationHelper.from(serialComponentsSource).map(serialComponent => this.concatenateValidated(baseIdentificationKey, serialComponent));
1604
+ private concatenateValidated(baseIdentificationKey: string, serialComponents: Iterable<string>): IterableIterator<string>;
1605
+
1606
+ // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1607
+ private concatenateValidated(baseIdentificationKey: string, serialComponent: string | Iterable<string>): string | IterableIterator<string> {
1608
+ let result: string | IterableIterator<string>;
1609
+
1610
+ if (typeof serialComponent === "string") {
1611
+ this.serialComponentCreator.validate(serialComponent, this.serialComponentValidation);
1612
+
1613
+ result = baseIdentificationKey + serialComponent;
1614
+ } else {
1615
+ result = Iterator.from(serialComponent).map(serialComponent => this.concatenateValidated(baseIdentificationKey, serialComponent));
1616
+ }
1617
+
1618
+ return result;
1638
1619
  }
1639
1620
 
1640
1621
  /**
@@ -1642,7 +1623,7 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1642
1623
  * value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1643
1624
  *
1644
1625
  * @param value
1645
- * Numeric value.
1626
+ * Numeric value of the references.
1646
1627
  *
1647
1628
  * @param serialComponent
1648
1629
  * Serial component.
@@ -1653,9 +1634,7 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1653
1634
  * @returns
1654
1635
  * Serialized identification key.
1655
1636
  */
1656
- createSerialized(value: number, serialComponent: string, sparse = false): string {
1657
- return this.concatenateValidated(this.create(value, sparse), serialComponent);
1658
- }
1637
+ createSerialized(value: number, serialComponent: string, sparse?: boolean): string;
1659
1638
 
1660
1639
  /**
1661
1640
  * Create multiple serialized identification keys with a reference based on a numeric value and multiple serial
@@ -1664,8 +1643,8 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1664
1643
  * @param value
1665
1644
  * Numeric value.
1666
1645
  *
1667
- * @param serialComponentsSource
1668
- * Source of serial components.
1646
+ * @param serialComponents
1647
+ * Serial components.
1669
1648
  *
1670
1649
  * @param sparse
1671
1650
  * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
@@ -1673,8 +1652,11 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1673
1652
  * @returns
1674
1653
  * Serialized identification keys.
1675
1654
  */
1676
- createMultipleSerialized(value: number, serialComponentsSource: IterationSource<string>, sparse = false): IterableIterator<string> {
1677
- return this.concatenateValidatedMultiple(this.create(value, sparse), serialComponentsSource);
1655
+ createSerialized(value: number, serialComponents: Iterable<string>, sparse?: boolean): IterableIterator<string>;
1656
+
1657
+ // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1658
+ createSerialized(value: number, serialComponent: string | Iterable<string>, sparse = false): string | IterableIterator<string> {
1659
+ return this.concatenateValidated(this.create(value, sparse), serialComponent);
1678
1660
  }
1679
1661
 
1680
1662
  /**
@@ -1689,11 +1671,7 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1689
1671
  * @returns
1690
1672
  * Serialized identification key.
1691
1673
  */
1692
- concatenate(baseIdentificationKey: string, serialComponent: string): string {
1693
- this.validate(baseIdentificationKey);
1694
-
1695
- return this.concatenateValidated(baseIdentificationKey, serialComponent);
1696
- }
1674
+ concatenate(baseIdentificationKey: string, serialComponent: string): string;
1697
1675
 
1698
1676
  /**
1699
1677
  * Concatenate a base identification key with multiple serial components.
@@ -1701,16 +1679,19 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1701
1679
  * @param baseIdentificationKey
1702
1680
  * Base identification key.
1703
1681
  *
1704
- * @param serialComponentsSource
1705
- * Source of serial components.
1682
+ * @param serialComponents
1683
+ * Serial components.
1706
1684
  *
1707
1685
  * @returns
1708
1686
  * Serialized identification keys.
1709
1687
  */
1710
- concatenateMultiple(baseIdentificationKey: string, serialComponentsSource: IterationSource<string>): IterableIterator<string> {
1688
+ concatenate(baseIdentificationKey: string, serialComponents: Iterable<string>): IterableIterator<string>;
1689
+
1690
+ // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1691
+ concatenate(baseIdentificationKey: string, serialComponent: string | Iterable<string>): string | IterableIterator<string> {
1711
1692
  this.validate(baseIdentificationKey);
1712
1693
 
1713
- return this.concatenateValidatedMultiple(baseIdentificationKey, serialComponentsSource);
1694
+ return this.concatenateValidated(baseIdentificationKey, serialComponent);
1714
1695
  }
1715
1696
  }
1716
1697
 
@@ -1719,7 +1700,7 @@ export class SerializableNumericIdentificationKeyCreator extends Mixin(Serializa
1719
1700
  */
1720
1701
  export class NonNumericIdentificationKeyCreator extends Mixin(NonNumericIdentificationKeyValidator, AbstractIdentificationKeyCreator) {
1721
1702
  /**
1722
- * Reference character set validation parameters.
1703
+ * Reference validation parameters.
1723
1704
  */
1724
1705
  private readonly _referenceValidation: CharacterSetValidation;
1725
1706
 
@@ -1766,28 +1747,57 @@ export class NonNumericIdentificationKeyCreator extends Mixin(NonNumericIdentifi
1766
1747
  * @returns
1767
1748
  * Identification key.
1768
1749
  */
1769
- create(reference: string): string {
1770
- this.referenceValidator.validate(reference, this._referenceValidation);
1771
-
1772
- const partialIdentificationKey = this.prefix + reference;
1773
-
1774
- return this.requiresCheckCharacterPair ? partialIdentificationKey + checkCharacterPair(partialIdentificationKey) : partialIdentificationKey;
1775
- }
1750
+ create(reference: string): string;
1776
1751
 
1777
1752
  /**
1778
1753
  * Create multiple identification keys with references.
1779
1754
  *
1780
- * @param referencesSource
1781
- * Source of references.
1755
+ * @param references
1756
+ * References.
1782
1757
  *
1783
1758
  * @returns
1784
1759
  * Identification keys.
1785
1760
  */
1786
- createMultiple(referencesSource: IterationSource<string>): IterableIterator<string> {
1787
- return IterationHelper.from(referencesSource).map(reference => this.create(reference));
1761
+ create(references: Iterable<string>): IterableIterator<string>;
1762
+
1763
+ // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1764
+ create(referenceOrReferences: string | Iterable<string>): string | IterableIterator<string> {
1765
+ let result: string | IterableIterator<string>;
1766
+
1767
+ if (typeof referenceOrReferences === "string") {
1768
+ this.referenceValidator.validate(referenceOrReferences, this._referenceValidation);
1769
+
1770
+ const partialIdentificationKey = this.prefix + referenceOrReferences;
1771
+
1772
+ result = this.requiresCheckCharacterPair ? partialIdentificationKey + checkCharacterPair(partialIdentificationKey) : partialIdentificationKey;
1773
+ } else {
1774
+ result = Iterator.from(referenceOrReferences).map(reference => this.create(reference));
1775
+ }
1776
+
1777
+ return result;
1788
1778
  }
1789
1779
  }
1790
1780
 
1781
+ /**
1782
+ * Prefix validation parameters.
1783
+ */
1784
+ interface PrefixValidation extends CharacterSetValidation {
1785
+ /**
1786
+ * Minimum length.
1787
+ */
1788
+ minimumLength: number;
1789
+
1790
+ /**
1791
+ * Maximum length.
1792
+ */
1793
+ maximumLength: number;
1794
+
1795
+ /**
1796
+ * Callback to localized prefix type name.
1797
+ */
1798
+ component: () => string;
1799
+ }
1800
+
1791
1801
  /**
1792
1802
  * Prefix manager. This is the core class for identification key creation.
1793
1803
  *
@@ -1848,7 +1858,7 @@ export class PrefixManager {
1848
1858
  /**
1849
1859
  * Validation parameters for GS1 Company Prefix.
1850
1860
  */
1851
- private static readonly GS1_COMPANY_PREFIX_VALIDATION: CharacterSetValidation = {
1861
+ private static readonly GS1_COMPANY_PREFIX_VALIDATION: PrefixValidation = {
1852
1862
  minimumLength: PrefixManager.GS1_COMPANY_PREFIX_MINIMUM_LENGTH,
1853
1863
  maximumLength: PrefixManager.GS1_COMPANY_PREFIX_MAXIMUM_LENGTH,
1854
1864
  component: () => i18next.t("Prefix.gs1CompanyPrefix", {
@@ -1859,7 +1869,7 @@ export class PrefixManager {
1859
1869
  /**
1860
1870
  * Validation parameters for U.P.C. Company Prefix expressed as GS1 Company Prefix.
1861
1871
  */
1862
- private static readonly UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION: CharacterSetValidation = {
1872
+ private static readonly UPC_COMPANY_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION: PrefixValidation = {
1863
1873
  minimumLength: PrefixManager.UPC_COMPANY_PREFIX_MINIMUM_LENGTH + 1,
1864
1874
  maximumLength: PrefixManager.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH + 1,
1865
1875
  component: () => i18next.t("Prefix.gs1CompanyPrefix", {
@@ -1870,7 +1880,7 @@ export class PrefixManager {
1870
1880
  /**
1871
1881
  * Validation parameters for GS1-8 Prefix expressed as GS1 Company Prefix.
1872
1882
  */
1873
- private static readonly GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION: CharacterSetValidation = {
1883
+ private static readonly GS1_8_PREFIX_AS_GS1_COMPANY_PREFIX_VALIDATION: PrefixValidation = {
1874
1884
  minimumLength: PrefixManager.GS1_8_PREFIX_MINIMUM_LENGTH + 5,
1875
1885
  maximumLength: PrefixManager.GS1_8_PREFIX_MAXIMUM_LENGTH + 5,
1876
1886
  component: () => i18next.t("Prefix.gs1CompanyPrefix", {
@@ -1881,7 +1891,7 @@ export class PrefixManager {
1881
1891
  /**
1882
1892
  * Validation parameters for U.P.C. Company Prefix.
1883
1893
  */
1884
- private static readonly UPC_COMPANY_PREFIX_VALIDATION: CharacterSetValidation = {
1894
+ private static readonly UPC_COMPANY_PREFIX_VALIDATION: PrefixValidation = {
1885
1895
  minimumLength: PrefixManager.UPC_COMPANY_PREFIX_MINIMUM_LENGTH,
1886
1896
  maximumLength: PrefixManager.UPC_COMPANY_PREFIX_MAXIMUM_LENGTH,
1887
1897
  component: () => i18next.t("Prefix.upcCompanyPrefix", {
@@ -1892,7 +1902,7 @@ export class PrefixManager {
1892
1902
  /**
1893
1903
  * Validation parameters for GS1-8 Prefix.
1894
1904
  */
1895
- private static readonly GS1_8_PREFIX_VALIDATION: CharacterSetValidation = {
1905
+ private static readonly GS1_8_PREFIX_VALIDATION: PrefixValidation = {
1896
1906
  minimumLength: PrefixManager.GS1_8_PREFIX_MINIMUM_LENGTH,
1897
1907
  maximumLength: PrefixManager.GS1_8_PREFIX_MAXIMUM_LENGTH,
1898
1908
  component: () => i18next.t("Prefix.gs18Prefix", {
@@ -1904,7 +1914,7 @@ export class PrefixManager {
1904
1914
  * Creator tweak factors. Different numeric identification key types have different tweak factors so that sparse
1905
1915
  * creation generates different sequences for each.
1906
1916
  */
1907
- private static readonly CREATOR_TWEAK_FACTORS_MAP = new Map<IdentificationKeyType, bigint>([
1917
+ private static readonly CREATOR_TWEAK_FACTORS_MAP: ReadonlyMap<IdentificationKeyType, bigint> = new Map([
1908
1918
  [IdentificationKeyType.GTIN, 1987n],
1909
1919
  [IdentificationKeyType.GLN, 4241n],
1910
1920
  [IdentificationKeyType.SSCC, 8087n],
@@ -2046,9 +2056,9 @@ export class PrefixManager {
2046
2056
  if (this._tweakFactor !== tweakFactor) {
2047
2057
  this._tweakFactor = tweakFactor;
2048
2058
 
2049
- this._identificationKeyCreatorsMap.forEach((creator) => {
2059
+ for (const creator of this._identificationKeyCreatorsMap.values()) {
2050
2060
  this.setCreatorTweak(creator);
2051
- });
2061
+ }
2052
2062
  }
2053
2063
  }
2054
2064
 
@@ -2124,11 +2134,9 @@ export class PrefixManager {
2124
2134
  *
2125
2135
  * @param positionOffset
2126
2136
  * Position offset within a larger string.
2127
- *
2128
- * @throws RangeError
2129
2137
  */
2130
2138
  static validatePrefix(prefixType: PrefixType, allowUPCCompanyPrefix: boolean, allowGS18Prefix: boolean, prefix: string, isFromIdentificationKey = false, isNumericIdentificationKey = false, positionOffset?: number): void {
2131
- let baseValidation: CharacterSetValidation;
2139
+ let baseValidation: PrefixValidation;
2132
2140
 
2133
2141
  // Validate the prefix type and determine the prefix validation parameters.
2134
2142
  switch (prefixType) {
@@ -2179,7 +2187,7 @@ export class PrefixManager {
2179
2187
  break;
2180
2188
  }
2181
2189
 
2182
- const mergedValidation: CharacterSetValidation = {
2190
+ const mergedValidation: PrefixValidation = {
2183
2191
  ...baseValidation,
2184
2192
  positionOffset
2185
2193
  };
@@ -2189,8 +2197,7 @@ export class PrefixManager {
2189
2197
  NUMERIC_CREATOR.validate(prefix, mergedValidation);
2190
2198
  } else if (!isNumericIdentificationKey) {
2191
2199
  // Validate only the minimum length, allowing at least one character for the (possibly non-numeric) reference.
2192
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2193
- NUMERIC_CREATOR.validate(prefix.substring(0, Math.min(mergedValidation.minimumLength!, prefix.length - 1)), mergedValidation);
2200
+ NUMERIC_CREATOR.validate(prefix.substring(0, Math.min(mergedValidation.minimumLength, prefix.length - 1)), mergedValidation);
2194
2201
  }
2195
2202
  }
2196
2203
 
@@ -2205,8 +2212,6 @@ export class PrefixManager {
2205
2212
  *
2206
2213
  * @returns
2207
2214
  * Identification key creator.
2208
- *
2209
- * @throws RangeError
2210
2215
  */
2211
2216
  private getIdentificationKeyCreator<T extends IdentificationKeyCreator>(identificationKeyType: IdentificationKeyType, constructorCallback: () => T): T {
2212
2217
  let creator = this._identificationKeyCreatorsMap.get(identificationKeyType) as (T | undefined);
@@ -2222,6 +2227,8 @@ export class PrefixManager {
2222
2227
  creator = constructorCallback();
2223
2228
 
2224
2229
  this.setCreatorTweak(creator);
2230
+
2231
+ this._identificationKeyCreatorsMap.set(identificationKeyType, creator);
2225
2232
  }
2226
2233
 
2227
2234
  return creator;