@aidc-toolkit/gs1 0.9.5 → 0.9.6-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CharacterSetCreator, StringValidation, StringValidator, CharacterSetValidator, CharacterSetValidation, Exclusion } from '@aidc-toolkit/utility';
1
+ import { CharacterSetCreator, StringValidation, StringValidator, CharacterSetValidation, Exclusion, TransformerInput, TransformerOutput } from '@aidc-toolkit/utility';
2
2
  import * as ts_mixer_dist_types_types_js from 'ts-mixer/dist/types/types.js';
3
3
 
4
4
  /**
@@ -216,7 +216,7 @@ interface IdentificationKeyValidator<V extends IdentificationKeyValidation = Ide
216
216
  /**
217
217
  * Get the reference validator.
218
218
  */
219
- get referenceValidator(): CharacterSetValidator;
219
+ get referenceCreator(): CharacterSetCreator;
220
220
  /**
221
221
  * Validate an identification key and throw an error if validation fails.
222
222
  *
@@ -250,19 +250,19 @@ declare abstract class AbstractIdentificationKeyValidator<V extends Identificati
250
250
  */
251
251
  private readonly _referenceCharacterSet;
252
252
  /**
253
- * Reference validator.
253
+ * Reference creator.
254
254
  */
255
- private readonly _referenceValidator;
255
+ private readonly _referenceCreator;
256
256
  /**
257
- * Get the character set validator for a character set.
257
+ * Get the character set creator for a character set.
258
258
  *
259
259
  * @param characterSet
260
260
  * Character set.
261
261
  *
262
262
  * @returns
263
- * Character set validator.
263
+ * Character set creator.
264
264
  */
265
- protected static validatorFor(characterSet: CharacterSet): CharacterSetValidator;
265
+ protected static creatorFor(characterSet: CharacterSet): CharacterSetCreator;
266
266
  /**
267
267
  * Constructor.
268
268
  *
@@ -298,7 +298,7 @@ declare abstract class AbstractIdentificationKeyValidator<V extends Identificati
298
298
  /**
299
299
  * @inheritDoc
300
300
  */
301
- get referenceValidator(): CharacterSetValidator;
301
+ get referenceCreator(): CharacterSetCreator;
302
302
  /**
303
303
  * Pad an identification key on the left with zero-value character for validation purposes. This is done to align an
304
304
  * identification key with a position offset for any error message that may be thrown by the reference validator.
@@ -514,9 +514,9 @@ declare class SerializableNumericIdentificationKeyValidator extends NonGTINNumer
514
514
  */
515
515
  private readonly _serialComponentValidation;
516
516
  /**
517
- * Serial component validator.
517
+ * Serial component creator.
518
518
  */
519
- private readonly _serialComponentValidator;
519
+ private readonly _serialComponentCreator;
520
520
  /**
521
521
  * Constructor.
522
522
  *
@@ -546,9 +546,9 @@ declare class SerializableNumericIdentificationKeyValidator extends NonGTINNumer
546
546
  */
547
547
  protected get serialComponentValidation(): CharacterSetValidation;
548
548
  /**
549
- * Get the serial component validator.
549
+ * Get the serial component creator.
550
550
  */
551
- get serialComponentValidator(): CharacterSetValidator;
551
+ get serialComponentCreator(): CharacterSetCreator;
552
552
  /**
553
553
  * @inheritDoc
554
554
  */
@@ -674,10 +674,6 @@ declare const GMN_VALIDATOR: NonNumericIdentificationKeyValidator;
674
674
  * Keys are created based on a prefix defined in a prefix manager to which the identification key creator is bound.
675
675
  */
676
676
  interface IdentificationKeyCreator extends IdentificationKeyValidator {
677
- /**
678
- * Get the reference creator.
679
- */
680
- get referenceCreator(): CharacterSetCreator;
681
677
  /**
682
678
  * Get the prefix manager to which this identification key creator is bound.
683
679
  */
@@ -723,11 +719,7 @@ declare abstract class AbstractIdentificationKeyCreator implements Identificatio
723
719
  abstract get prefixType(): PrefixType;
724
720
  abstract get length(): number;
725
721
  abstract get referenceCharacterSet(): CharacterSet;
726
- abstract get referenceValidator(): CharacterSetValidator;
727
- /**
728
- * @inheritDoc
729
- */
730
- get referenceCreator(): CharacterSetCreator;
722
+ abstract get referenceCreator(): CharacterSetCreator;
731
723
  /**
732
724
  * @inheritDoc
733
725
  */
@@ -750,36 +742,20 @@ interface NumericIdentificationKeyCreator extends NumericIdentificationKeyValida
750
742
  * Get the capacity (`10**referenceLength`).
751
743
  */
752
744
  get capacity(): number;
753
- create: {
754
- /**
755
- * Create an identification key with a reference based on a numeric value. The value is converted to a reference of
756
- * the appropriate length using {@linkcode NUMERIC_CREATOR}.
757
- *
758
- * @param value
759
- * Numeric value.
760
- *
761
- * @param sparse
762
- * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
763
- *
764
- * @returns
765
- * Identification key.
766
- */
767
- (value: number | bigint, sparse?: boolean): string;
768
- /**
769
- * Create identification keys with references based on numeric values. The values are converted to references of
770
- * the appropriate length using {@linkcode NUMERIC_CREATOR}.
771
- *
772
- * @param values
773
- * Numeric values.
774
- *
775
- * @param sparse
776
- * If true, the values are mapped to a sparse sequence resistant to discovery. Default is false.
777
- *
778
- * @returns
779
- * Identification keys.
780
- */
781
- (values: Iterable<number | bigint>, sparse?: boolean): IterableIterator<string>;
782
- };
745
+ /**
746
+ * Create identification key(s) with reference(s) based on numeric value(s). The value(s) is/are converted to
747
+ * references of the appropriate length using {@linkcode NUMERIC_CREATOR}.
748
+ *
749
+ * @param valueOrValues
750
+ * Numeric value(s).
751
+ *
752
+ * @param sparse
753
+ * If true, the value(s) are mapped to a sparse sequence resistant to discovery. Default is false.
754
+ *
755
+ * @returns
756
+ * Identification key(s).
757
+ */
758
+ create: <T extends TransformerInput<number | bigint>>(valueOrValues: T, sparse?: boolean) => TransformerOutput<T, string>;
783
759
  /**
784
760
  * Create all identification keys for the prefix from `0` to `capacity - 1`.
785
761
  *
@@ -839,11 +815,7 @@ declare abstract class AbstractNumericIdentificationKeyCreator extends AbstractI
839
815
  /**
840
816
  * @inheritDoc
841
817
  */
842
- create(value: number | bigint, sparse?: boolean): string;
843
- /**
844
- * @inheritDoc
845
- */
846
- create(values: Iterable<number | bigint>, sparse?: boolean): IterableIterator<string>;
818
+ create<T extends TransformerInput<number | bigint>>(valueOrValues: T, sparse?: boolean): TransformerOutput<T, string>;
847
819
  /**
848
820
  * Create all identification keys from a partial identification key. Call is recursive until remaining reference
849
821
  * length is 0.
@@ -901,41 +873,22 @@ declare class GTINCreator extends GTINCreator_base {
901
873
  */
902
874
  get prefix(): string;
903
875
  /**
904
- * Create a GTIN-14 with an indicator digit and a reference based on a numeric value. The value is converted to a
905
- * reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
876
+ * Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
877
+ * converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
906
878
  *
907
879
  * @param indicatorDigit
908
880
  * Indicator digit.
909
881
  *
910
- * @param value
911
- * Numeric value of the reference.
882
+ * @param valueOrValues
883
+ * Numeric value(s).
912
884
  *
913
885
  * @param sparse
914
- * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
886
+ * If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
915
887
  *
916
888
  * @returns
917
- * GTIN-14.
889
+ * GTIN-14(s).
918
890
  */
919
- createGTIN14(indicatorDigit: string, value: number | bigint, sparse?: boolean): string;
920
- /**
921
- * Create multiple GTIN-14s with an indicator digit and references based on numeric values. The values are converted
922
- * to references of the appropriate length using {@linkcode NUMERIC_CREATOR}.
923
- *
924
- * The implementation uses {@link CharacterSetCreator.create}, so the values are created only as needed.
925
- *
926
- * @param indicatorDigit
927
- * Indicator digit.
928
- *
929
- * @param values
930
- * Values.
931
- *
932
- * @param sparse
933
- * If true, the values are mapped to a sparse sequence resistant to discovery. Default is false.
934
- *
935
- * @returns
936
- * Iterable iterator over created GTIN-14s.
937
- */
938
- createGTIN14(indicatorDigit: string, values: Iterable<number | bigint>, sparse?: boolean): IterableIterator<string>;
891
+ createGTIN14<T extends TransformerInput<number | bigint>>(indicatorDigit: string, valueOrValues: T, sparse?: boolean): TransformerOutput<T, string>;
939
892
  /**
940
893
  * Zero suppress a GTIN-12.
941
894
  *
@@ -1023,48 +976,27 @@ declare class SerializableNumericIdentificationKeyCreator extends SerializableNu
1023
976
  */
1024
977
  constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, serialComponentLength: number, serialComponentCharacterSet: CharacterSet);
1025
978
  /**
1026
- * Get the serial component creator.
1027
- */
1028
- get serialComponentCreator(): CharacterSetCreator;
1029
- /**
1030
- * Concatenate a validated base identification key with a serial component.
979
+ * Concatenate a validated base identification key with serial component(s).
1031
980
  *
1032
981
  * @param baseIdentificationKey
1033
982
  * Base identification key.
1034
983
  *
1035
- * @param serialComponent
1036
- * Serial component.
984
+ * @param serialComponentOrComponents
985
+ * Serial component(s).
1037
986
  *
1038
987
  * @returns
1039
- * Serialized identification key.
988
+ * Serialized identification key(s).
1040
989
  */
1041
990
  private concatenateValidated;
1042
991
  /**
1043
- * Create a serialized identification key with a reference based on a numeric value and a serial component. The
1044
- * value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1045
- *
1046
- * @param value
1047
- * Numeric value of the references.
1048
- *
1049
- * @param serialComponent
1050
- * Serial component.
1051
- *
1052
- * @param sparse
1053
- * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
1054
- *
1055
- * @returns
1056
- * Serialized identification key.
1057
- */
1058
- createSerialized(value: number, serialComponent: string, sparse?: boolean): string;
1059
- /**
1060
- * Create multiple serialized identification keys with a reference based on a numeric value and multiple serial
1061
- * components. The value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
992
+ * Create serialized identification key(s) with a reference based on a numeric value concatenated with serial
993
+ * component(s). The value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1062
994
  *
1063
995
  * @param value
1064
- * Numeric value.
996
+ * Numeric value of the reference.
1065
997
  *
1066
- * @param serialComponents
1067
- * Serial components.
998
+ * @param serialComponentOrComponents
999
+ * Serial component(s).
1068
1000
  *
1069
1001
  * @param sparse
1070
1002
  * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
@@ -1072,33 +1004,20 @@ declare class SerializableNumericIdentificationKeyCreator extends SerializableNu
1072
1004
  * @returns
1073
1005
  * Serialized identification keys.
1074
1006
  */
1075
- createSerialized(value: number, serialComponents: Iterable<string>, sparse?: boolean): IterableIterator<string>;
1076
- /**
1077
- * Concatenate a base identification key with a serial component.
1078
- *
1079
- * @param baseIdentificationKey
1080
- * Base identification key.
1081
- *
1082
- * @param serialComponent
1083
- * Serial component.
1084
- *
1085
- * @returns
1086
- * Serialized identification key.
1087
- */
1088
- concatenate(baseIdentificationKey: string, serialComponent: string): string;
1007
+ createSerialized<T extends TransformerInput<string>>(value: number, serialComponentOrComponents: T, sparse?: boolean): TransformerOutput<T, string>;
1089
1008
  /**
1090
- * Concatenate a base identification key with multiple serial components.
1009
+ * Concatenate a base identification key with serial component(s).
1091
1010
  *
1092
1011
  * @param baseIdentificationKey
1093
1012
  * Base identification key.
1094
1013
  *
1095
- * @param serialComponents
1096
- * Serial components.
1014
+ * @param serialComponentOrComponents
1015
+ * Serial component(s).
1097
1016
  *
1098
1017
  * @returns
1099
- * Serialized identification keys.
1018
+ * Serialized identification key(s).
1100
1019
  */
1101
- concatenate(baseIdentificationKey: string, serialComponents: Iterable<string>): IterableIterator<string>;
1020
+ concatenate<T extends TransformerInput<string>>(baseIdentificationKey: string, serialComponentOrComponents: T): TransformerOutput<T, string>;
1102
1021
  }
1103
1022
  declare const NonNumericIdentificationKeyCreator_base: ts_mixer_dist_types_types_js.Class<any[], NonNumericIdentificationKeyValidator & AbstractIdentificationKeyCreator, typeof NonNumericIdentificationKeyValidator & typeof AbstractIdentificationKeyCreator>;
1104
1023
  /**
@@ -1130,25 +1049,19 @@ declare class NonNumericIdentificationKeyCreator extends NonNumericIdentificatio
1130
1049
  */
1131
1050
  constructor(prefixManager: PrefixManager, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: CharacterSet, requiresCheckCharacterPair?: boolean);
1132
1051
  /**
1133
- * Create an identification key with a reference.
1134
- *
1135
- * @param reference
1136
- * Reference.
1137
- *
1138
- * @returns
1139
- * Identification key.
1052
+ * Get the reference validation parameters.
1140
1053
  */
1141
- create(reference: string): string;
1054
+ protected get referenceValidation(): CharacterSetValidation;
1142
1055
  /**
1143
- * Create multiple identification keys with references.
1056
+ * Create identification key(s) with reference(s).
1144
1057
  *
1145
- * @param references
1146
- * References.
1058
+ * @param referenceOrReferences
1059
+ * Reference(s).
1147
1060
  *
1148
1061
  * @returns
1149
- * Identification keys.
1062
+ * Identification key(s).
1150
1063
  */
1151
- create(references: Iterable<string>): IterableIterator<string>;
1064
+ create<T extends TransformerInput<string>>(referenceOrReferences: T): TransformerOutput<T, string>;
1152
1065
  }
1153
1066
  /**
1154
1067
  * Prefix manager. This is the core class for identification key creation.
package/dist/index.js CHANGED
@@ -452,19 +452,19 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
452
452
  */
453
453
  _referenceCharacterSet;
454
454
  /**
455
- * Reference validator.
455
+ * Reference creator.
456
456
  */
457
- _referenceValidator;
457
+ _referenceCreator;
458
458
  /**
459
- * Get the character set validator for a character set.
459
+ * Get the character set creator for a character set.
460
460
  *
461
461
  * @param characterSet
462
462
  * Character set.
463
463
  *
464
464
  * @returns
465
- * Character set validator.
465
+ * Character set creator.
466
466
  */
467
- static validatorFor(characterSet) {
467
+ static creatorFor(characterSet) {
468
468
  return _AbstractIdentificationKeyValidator.CHARACTER_SET_CREATORS[characterSet];
469
469
  }
470
470
  /**
@@ -487,7 +487,7 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
487
487
  this._prefixType = prefixType;
488
488
  this._length = length;
489
489
  this._referenceCharacterSet = referenceCharacterSet;
490
- this._referenceValidator = _AbstractIdentificationKeyValidator.validatorFor(referenceCharacterSet);
490
+ this._referenceCreator = _AbstractIdentificationKeyValidator.creatorFor(referenceCharacterSet);
491
491
  }
492
492
  /**
493
493
  * @inheritDoc
@@ -516,8 +516,8 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
516
516
  /**
517
517
  * @inheritDoc
518
518
  */
519
- get referenceValidator() {
520
- return this._referenceValidator;
519
+ get referenceCreator() {
520
+ return this._referenceCreator;
521
521
  }
522
522
  /**
523
523
  * Pad an identification key on the left with zero-value character for validation purposes. This is done to align an
@@ -533,7 +533,7 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
533
533
  * Padded identification key.
534
534
  */
535
535
  padIdentificationKey(identificationKey, validation) {
536
- return validation?.positionOffset === void 0 ? identificationKey : this.referenceValidator.character(0).repeat(validation.positionOffset).concat(identificationKey);
536
+ return validation?.positionOffset === void 0 ? identificationKey : this.referenceCreator.character(0).repeat(validation.positionOffset).concat(identificationKey);
537
537
  }
538
538
  /**
539
539
  * Validate the prefix within an identification key.
@@ -800,9 +800,9 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
800
800
  */
801
801
  _serialComponentValidation;
802
802
  /**
803
- * Serial component validator.
803
+ * Serial component creator.
804
804
  */
805
- _serialComponentValidator;
805
+ _serialComponentCreator;
806
806
  /**
807
807
  * Constructor.
808
808
  *
@@ -829,7 +829,7 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
829
829
  ns: gs1NS
830
830
  })
831
831
  };
832
- this._serialComponentValidator = _SerializableNumericIdentificationKeyValidator.validatorFor(serialComponentCharacterSet);
832
+ this._serialComponentCreator = _SerializableNumericIdentificationKeyValidator.creatorFor(serialComponentCharacterSet);
833
833
  }
834
834
  /**
835
835
  * Get the serial component length.
@@ -850,10 +850,10 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
850
850
  return this._serialComponentValidation;
851
851
  }
852
852
  /**
853
- * Get the serial component validator.
853
+ * Get the serial component creator.
854
854
  */
855
- get serialComponentValidator() {
856
- return this._serialComponentValidator;
855
+ get serialComponentCreator() {
856
+ return this._serialComponentCreator;
857
857
  }
858
858
  /**
859
859
  * @inheritDoc
@@ -861,7 +861,7 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
861
861
  validate(identificationKey, validation) {
862
862
  super.validate(identificationKey.substring(0, this.length), validation);
863
863
  if (identificationKey.length > this.length) {
864
- this.serialComponentValidator.validate(identificationKey.substring(this.length), this._serialComponentValidation);
864
+ this.serialComponentCreator.validate(identificationKey.substring(this.length), this._serialComponentValidation);
865
865
  }
866
866
  }
867
867
  };
@@ -921,7 +921,7 @@ var NonNumericIdentificationKeyValidator = class _NonNumericIdentificationKeyVal
921
921
  const partialIdentificationKey = this.requiresCheckCharacterPair ? identificationKey.substring(0, identificationKey.length - 2) : identificationKey;
922
922
  super.validatePrefix(partialIdentificationKey, validation?.positionOffset);
923
923
  if (!this.requiresCheckCharacterPair) {
924
- this.referenceValidator.validate(identificationKey, {
924
+ this.referenceCreator.validate(identificationKey, {
925
925
  maximumLength: this.length,
926
926
  positionOffset: validation?.positionOffset
927
927
  });
@@ -979,12 +979,6 @@ var AbstractIdentificationKeyCreator = class {
979
979
  this._prefixManager = prefixManager;
980
980
  this._referenceLength = this.length - prefix.length - checkAllowance;
981
981
  }
982
- /**
983
- * @inheritDoc
984
- */
985
- get referenceCreator() {
986
- return this.referenceValidator;
987
- }
988
982
  /**
989
983
  * @inheritDoc
990
984
  */
@@ -1057,7 +1051,9 @@ var AbstractNumericIdentificationKeyCreator = class _AbstractNumericIdentificati
1057
1051
  const partialIdentificationKey = this.leaderType === 2 /* ExtensionDigit */ ? reference.substring(0, 1) + this.prefix + reference.substring(1) : this.prefix + reference;
1058
1052
  return partialIdentificationKey + checkDigit(partialIdentificationKey);
1059
1053
  }
1060
- // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1054
+ /**
1055
+ * @inheritDoc
1056
+ */
1061
1057
  create(valueOrValues, sparse = false) {
1062
1058
  return NUMERIC_CREATOR2.create(this.referenceLength, valueOrValues, Exclusion2.None, sparse ? this.tweak : void 0, (reference) => this.buildIdentificationKey(reference));
1063
1059
  }
@@ -1155,7 +1151,22 @@ var GTINCreator = class _GTINCreator extends Mixin(GTINValidator, AbstractNumeri
1155
1151
  get prefix() {
1156
1152
  return this.prefixManager.prefix;
1157
1153
  }
1158
- // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1154
+ /**
1155
+ * Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
1156
+ * converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1157
+ *
1158
+ * @param indicatorDigit
1159
+ * Indicator digit.
1160
+ *
1161
+ * @param valueOrValues
1162
+ * Numeric value(s).
1163
+ *
1164
+ * @param sparse
1165
+ * If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
1166
+ *
1167
+ * @returns
1168
+ * GTIN-14(s).
1169
+ */
1159
1170
  createGTIN14(indicatorDigit, valueOrValues, sparse = false) {
1160
1171
  NUMERIC_CREATOR2.validate(indicatorDigit, _GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
1161
1172
  return NUMERIC_CREATOR2.create(13 /* GTIN13 */ - this.prefixManager.gs1CompanyPrefix.length - 1, valueOrValues, Exclusion2.None, sparse ? this.tweak : void 0, (reference) => {
@@ -1328,30 +1339,66 @@ var SerializableNumericIdentificationKeyCreator = class extends Mixin(Serializab
1328
1339
  this.init(prefixManager, prefixManager.gs1CompanyPrefix);
1329
1340
  }
1330
1341
  /**
1331
- * Get the serial component creator.
1342
+ * Concatenate a validated base identification key with serial component(s).
1343
+ *
1344
+ * @param baseIdentificationKey
1345
+ * Base identification key.
1346
+ *
1347
+ * @param serialComponentOrComponents
1348
+ * Serial component(s).
1349
+ *
1350
+ * @returns
1351
+ * Serialized identification key(s).
1332
1352
  */
1333
- get serialComponentCreator() {
1334
- return this.serialComponentValidator;
1335
- }
1336
- // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1337
- concatenateValidated(baseIdentificationKey, serialComponent) {
1353
+ concatenateValidated(baseIdentificationKey, serialComponentOrComponents) {
1338
1354
  let result;
1339
- if (typeof serialComponent === "string") {
1340
- this.serialComponentCreator.validate(serialComponent, this.serialComponentValidation);
1341
- result = baseIdentificationKey + serialComponent;
1355
+ const serialComponentCreator = this.serialComponentCreator;
1356
+ const serialComponentValidation = this.serialComponentValidation;
1357
+ function validateAndConcatenate(serialComponent) {
1358
+ serialComponentCreator.validate(serialComponent, serialComponentValidation);
1359
+ return baseIdentificationKey + serialComponent;
1360
+ }
1361
+ if (typeof serialComponentOrComponents !== "object") {
1362
+ result = validateAndConcatenate(serialComponentOrComponents);
1342
1363
  } else {
1343
- result = IteratorProxy.from(serialComponent).map((serialComponent2) => this.concatenateValidated(baseIdentificationKey, serialComponent2));
1364
+ result = IteratorProxy.from(serialComponentOrComponents).map(validateAndConcatenate);
1344
1365
  }
1345
1366
  return result;
1346
1367
  }
1347
- // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1348
- createSerialized(value, serialComponent, sparse = false) {
1349
- return this.concatenateValidated(this.create(value, sparse), serialComponent);
1368
+ /**
1369
+ * Create serialized identification key(s) with a reference based on a numeric value concatenated with serial
1370
+ * component(s). The value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1371
+ *
1372
+ * @param value
1373
+ * Numeric value of the reference.
1374
+ *
1375
+ * @param serialComponentOrComponents
1376
+ * Serial component(s).
1377
+ *
1378
+ * @param sparse
1379
+ * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
1380
+ *
1381
+ * @returns
1382
+ * Serialized identification keys.
1383
+ */
1384
+ createSerialized(value, serialComponentOrComponents, sparse) {
1385
+ return this.concatenateValidated(this.create(value, sparse), serialComponentOrComponents);
1350
1386
  }
1351
- // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1352
- concatenate(baseIdentificationKey, serialComponent) {
1387
+ /**
1388
+ * Concatenate a base identification key with serial component(s).
1389
+ *
1390
+ * @param baseIdentificationKey
1391
+ * Base identification key.
1392
+ *
1393
+ * @param serialComponentOrComponents
1394
+ * Serial component(s).
1395
+ *
1396
+ * @returns
1397
+ * Serialized identification key(s).
1398
+ */
1399
+ concatenate(baseIdentificationKey, serialComponentOrComponents) {
1353
1400
  this.validate(baseIdentificationKey);
1354
- return this.concatenateValidated(baseIdentificationKey, serialComponent);
1401
+ return this.concatenateValidated(baseIdentificationKey, serialComponentOrComponents);
1355
1402
  }
1356
1403
  };
1357
1404
  var NonNumericIdentificationKeyCreator = class extends Mixin(NonNumericIdentificationKeyValidator, AbstractIdentificationKeyCreator) {
@@ -1390,15 +1437,36 @@ var NonNumericIdentificationKeyCreator = class extends Mixin(NonNumericIdentific
1390
1437
  })
1391
1438
  };
1392
1439
  }
1393
- // eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
1440
+ /**
1441
+ * Get the reference validation parameters.
1442
+ */
1443
+ get referenceValidation() {
1444
+ return this._referenceValidation;
1445
+ }
1446
+ /**
1447
+ * Create identification key(s) with reference(s).
1448
+ *
1449
+ * @param referenceOrReferences
1450
+ * Reference(s).
1451
+ *
1452
+ * @returns
1453
+ * Identification key(s).
1454
+ */
1394
1455
  create(referenceOrReferences) {
1395
1456
  let result;
1396
- if (typeof referenceOrReferences === "string") {
1397
- this.referenceValidator.validate(referenceOrReferences, this._referenceValidation);
1398
- const partialIdentificationKey = this.prefix + referenceOrReferences;
1399
- result = this.requiresCheckCharacterPair ? partialIdentificationKey + checkCharacterPair(partialIdentificationKey) : partialIdentificationKey;
1457
+ const referenceCreator = this.referenceCreator;
1458
+ const referenceValidation = this.referenceValidation;
1459
+ const prefix = this.prefix;
1460
+ const requiresCheckCharacterPair = this.requiresCheckCharacterPair;
1461
+ function validateAndCreate(reference) {
1462
+ referenceCreator.validate(reference, referenceValidation);
1463
+ const partialIdentificationKey = prefix + reference;
1464
+ return requiresCheckCharacterPair ? partialIdentificationKey + checkCharacterPair(partialIdentificationKey) : partialIdentificationKey;
1465
+ }
1466
+ if (typeof referenceOrReferences !== "object") {
1467
+ result = validateAndCreate(referenceOrReferences);
1400
1468
  } else {
1401
- result = IteratorProxy.from(referenceOrReferences).map((reference) => this.create(reference));
1469
+ result = IteratorProxy.from(referenceOrReferences).map(validateAndCreate);
1402
1470
  }
1403
1471
  return result;
1404
1472
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aidc-toolkit/gs1",
3
- "version": "0.9.5",
3
+ "version": "0.9.6-beta",
4
4
  "description": "GS1 AIDC Toolkit",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,24 +19,23 @@
19
19
  "url": "https://www.linkedin.com/in/kdean"
20
20
  },
21
21
  "scripts": {
22
- "eslint": "eslint .",
22
+ "lint": "eslint .",
23
23
  "build": "tsup src/index.ts --clean --format cjs,esm --dts",
24
24
  "build-doc": "npm run build && tsc src/index.ts --outDir dist --target esnext --moduleResolution nodenext --module nodenext --emitDeclarationOnly --declaration --declarationMap",
25
25
  "test": "vitest run"
26
26
  },
27
27
  "devDependencies": {
28
- "@aidc-toolkit/dev": "^0.9.5",
29
- "eslint": "^9.15.0",
28
+ "@aidc-toolkit/dev": "^0.9.6-beta",
29
+ "eslint": "^9.16.0",
30
30
  "ts-node": "^10.9.2",
31
31
  "tsup": "^8.3.5",
32
- "typescript": "^5.6.3",
33
- "vitest": "^2.1.5"
32
+ "typescript": "^5.7.2",
33
+ "vitest": "^2.1.7"
34
34
  },
35
35
  "dependencies": {
36
- "@aidc-toolkit/core": "^0.9.5",
37
- "@aidc-toolkit/utility": "^0.9.5",
38
- "@rollup/rollup-linux-x64-gnu": "^4.27.3",
39
- "i18next": "^23.16.8",
36
+ "@aidc-toolkit/core": "^0.9.6-beta",
37
+ "@aidc-toolkit/utility": "^0.9.6-beta",
38
+ "@rollup/rollup-linux-x64-gnu": "^4.28.0",
40
39
  "ts-mixer": "^6.0.4"
41
40
  }
42
41
  }