@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.cjs +115 -47
- package/dist/index.d.cts +57 -144
- package/dist/index.d.ts +57 -144
- package/dist/index.js +115 -47
- package/package.json +9 -10
- package/src/idkey.ts +120 -211
- package/test/check.test.ts +1 -1
- package/test/idkey.test.ts +4 -4
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -32
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/workflows/build-publish.yml +0 -20
- package/.idea/gs1.iml +0 -9
- package/.idea/inspectionProfiles/Project_Default.xml +0 -7
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/runConfigurations/Test_all.xml +0 -12
- package/.idea/runConfigurations/Test_check.xml +0 -12
- package/.idea/runConfigurations/Test_identification_key.xml +0 -12
- package/.idea/runConfigurations/build.xml +0 -12
- package/.idea/runConfigurations/eslint.xml +0 -12
- package/.idea/vcs.xml +0 -6
package/dist/index.cjs
CHANGED
|
@@ -510,19 +510,19 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
|
|
|
510
510
|
*/
|
|
511
511
|
_referenceCharacterSet;
|
|
512
512
|
/**
|
|
513
|
-
* Reference
|
|
513
|
+
* Reference creator.
|
|
514
514
|
*/
|
|
515
|
-
|
|
515
|
+
_referenceCreator;
|
|
516
516
|
/**
|
|
517
|
-
* Get the character set
|
|
517
|
+
* Get the character set creator for a character set.
|
|
518
518
|
*
|
|
519
519
|
* @param characterSet
|
|
520
520
|
* Character set.
|
|
521
521
|
*
|
|
522
522
|
* @returns
|
|
523
|
-
* Character set
|
|
523
|
+
* Character set creator.
|
|
524
524
|
*/
|
|
525
|
-
static
|
|
525
|
+
static creatorFor(characterSet) {
|
|
526
526
|
return _AbstractIdentificationKeyValidator.CHARACTER_SET_CREATORS[characterSet];
|
|
527
527
|
}
|
|
528
528
|
/**
|
|
@@ -545,7 +545,7 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
|
|
|
545
545
|
this._prefixType = prefixType;
|
|
546
546
|
this._length = length;
|
|
547
547
|
this._referenceCharacterSet = referenceCharacterSet;
|
|
548
|
-
this.
|
|
548
|
+
this._referenceCreator = _AbstractIdentificationKeyValidator.creatorFor(referenceCharacterSet);
|
|
549
549
|
}
|
|
550
550
|
/**
|
|
551
551
|
* @inheritDoc
|
|
@@ -574,8 +574,8 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
|
|
|
574
574
|
/**
|
|
575
575
|
* @inheritDoc
|
|
576
576
|
*/
|
|
577
|
-
get
|
|
578
|
-
return this.
|
|
577
|
+
get referenceCreator() {
|
|
578
|
+
return this._referenceCreator;
|
|
579
579
|
}
|
|
580
580
|
/**
|
|
581
581
|
* Pad an identification key on the left with zero-value character for validation purposes. This is done to align an
|
|
@@ -591,7 +591,7 @@ var AbstractIdentificationKeyValidator = class _AbstractIdentificationKeyValidat
|
|
|
591
591
|
* Padded identification key.
|
|
592
592
|
*/
|
|
593
593
|
padIdentificationKey(identificationKey, validation) {
|
|
594
|
-
return validation?.positionOffset === void 0 ? identificationKey : this.
|
|
594
|
+
return validation?.positionOffset === void 0 ? identificationKey : this.referenceCreator.character(0).repeat(validation.positionOffset).concat(identificationKey);
|
|
595
595
|
}
|
|
596
596
|
/**
|
|
597
597
|
* Validate the prefix within an identification key.
|
|
@@ -858,9 +858,9 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
|
|
|
858
858
|
*/
|
|
859
859
|
_serialComponentValidation;
|
|
860
860
|
/**
|
|
861
|
-
* Serial component
|
|
861
|
+
* Serial component creator.
|
|
862
862
|
*/
|
|
863
|
-
|
|
863
|
+
_serialComponentCreator;
|
|
864
864
|
/**
|
|
865
865
|
* Constructor.
|
|
866
866
|
*
|
|
@@ -887,7 +887,7 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
|
|
|
887
887
|
ns: gs1NS
|
|
888
888
|
})
|
|
889
889
|
};
|
|
890
|
-
this.
|
|
890
|
+
this._serialComponentCreator = _SerializableNumericIdentificationKeyValidator.creatorFor(serialComponentCharacterSet);
|
|
891
891
|
}
|
|
892
892
|
/**
|
|
893
893
|
* Get the serial component length.
|
|
@@ -908,10 +908,10 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
|
|
|
908
908
|
return this._serialComponentValidation;
|
|
909
909
|
}
|
|
910
910
|
/**
|
|
911
|
-
* Get the serial component
|
|
911
|
+
* Get the serial component creator.
|
|
912
912
|
*/
|
|
913
|
-
get
|
|
914
|
-
return this.
|
|
913
|
+
get serialComponentCreator() {
|
|
914
|
+
return this._serialComponentCreator;
|
|
915
915
|
}
|
|
916
916
|
/**
|
|
917
917
|
* @inheritDoc
|
|
@@ -919,7 +919,7 @@ var SerializableNumericIdentificationKeyValidator = class _SerializableNumericId
|
|
|
919
919
|
validate(identificationKey, validation) {
|
|
920
920
|
super.validate(identificationKey.substring(0, this.length), validation);
|
|
921
921
|
if (identificationKey.length > this.length) {
|
|
922
|
-
this.
|
|
922
|
+
this.serialComponentCreator.validate(identificationKey.substring(this.length), this._serialComponentValidation);
|
|
923
923
|
}
|
|
924
924
|
}
|
|
925
925
|
};
|
|
@@ -979,7 +979,7 @@ var NonNumericIdentificationKeyValidator = class _NonNumericIdentificationKeyVal
|
|
|
979
979
|
const partialIdentificationKey = this.requiresCheckCharacterPair ? identificationKey.substring(0, identificationKey.length - 2) : identificationKey;
|
|
980
980
|
super.validatePrefix(partialIdentificationKey, validation?.positionOffset);
|
|
981
981
|
if (!this.requiresCheckCharacterPair) {
|
|
982
|
-
this.
|
|
982
|
+
this.referenceCreator.validate(identificationKey, {
|
|
983
983
|
maximumLength: this.length,
|
|
984
984
|
positionOffset: validation?.positionOffset
|
|
985
985
|
});
|
|
@@ -1037,12 +1037,6 @@ var AbstractIdentificationKeyCreator = class {
|
|
|
1037
1037
|
this._prefixManager = prefixManager;
|
|
1038
1038
|
this._referenceLength = this.length - prefix.length - checkAllowance;
|
|
1039
1039
|
}
|
|
1040
|
-
/**
|
|
1041
|
-
* @inheritDoc
|
|
1042
|
-
*/
|
|
1043
|
-
get referenceCreator() {
|
|
1044
|
-
return this.referenceValidator;
|
|
1045
|
-
}
|
|
1046
1040
|
/**
|
|
1047
1041
|
* @inheritDoc
|
|
1048
1042
|
*/
|
|
@@ -1115,7 +1109,9 @@ var AbstractNumericIdentificationKeyCreator = class _AbstractNumericIdentificati
|
|
|
1115
1109
|
const partialIdentificationKey = this.leaderType === 2 /* ExtensionDigit */ ? reference.substring(0, 1) + this.prefix + reference.substring(1) : this.prefix + reference;
|
|
1116
1110
|
return partialIdentificationKey + checkDigit(partialIdentificationKey);
|
|
1117
1111
|
}
|
|
1118
|
-
|
|
1112
|
+
/**
|
|
1113
|
+
* @inheritDoc
|
|
1114
|
+
*/
|
|
1119
1115
|
create(valueOrValues, sparse = false) {
|
|
1120
1116
|
return import_utility3.NUMERIC_CREATOR.create(this.referenceLength, valueOrValues, import_utility3.Exclusion.None, sparse ? this.tweak : void 0, (reference) => this.buildIdentificationKey(reference));
|
|
1121
1117
|
}
|
|
@@ -1213,7 +1209,22 @@ var GTINCreator = class _GTINCreator extends (0, import_ts_mixer.Mixin)(GTINVali
|
|
|
1213
1209
|
get prefix() {
|
|
1214
1210
|
return this.prefixManager.prefix;
|
|
1215
1211
|
}
|
|
1216
|
-
|
|
1212
|
+
/**
|
|
1213
|
+
* Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
|
|
1214
|
+
* converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
|
|
1215
|
+
*
|
|
1216
|
+
* @param indicatorDigit
|
|
1217
|
+
* Indicator digit.
|
|
1218
|
+
*
|
|
1219
|
+
* @param valueOrValues
|
|
1220
|
+
* Numeric value(s).
|
|
1221
|
+
*
|
|
1222
|
+
* @param sparse
|
|
1223
|
+
* If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
|
|
1224
|
+
*
|
|
1225
|
+
* @returns
|
|
1226
|
+
* GTIN-14(s).
|
|
1227
|
+
*/
|
|
1217
1228
|
createGTIN14(indicatorDigit, valueOrValues, sparse = false) {
|
|
1218
1229
|
import_utility3.NUMERIC_CREATOR.validate(indicatorDigit, _GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
|
|
1219
1230
|
return import_utility3.NUMERIC_CREATOR.create(13 /* GTIN13 */ - this.prefixManager.gs1CompanyPrefix.length - 1, valueOrValues, import_utility3.Exclusion.None, sparse ? this.tweak : void 0, (reference) => {
|
|
@@ -1386,30 +1397,66 @@ var SerializableNumericIdentificationKeyCreator = class extends (0, import_ts_mi
|
|
|
1386
1397
|
this.init(prefixManager, prefixManager.gs1CompanyPrefix);
|
|
1387
1398
|
}
|
|
1388
1399
|
/**
|
|
1389
|
-
*
|
|
1400
|
+
* Concatenate a validated base identification key with serial component(s).
|
|
1401
|
+
*
|
|
1402
|
+
* @param baseIdentificationKey
|
|
1403
|
+
* Base identification key.
|
|
1404
|
+
*
|
|
1405
|
+
* @param serialComponentOrComponents
|
|
1406
|
+
* Serial component(s).
|
|
1407
|
+
*
|
|
1408
|
+
* @returns
|
|
1409
|
+
* Serialized identification key(s).
|
|
1390
1410
|
*/
|
|
1391
|
-
|
|
1392
|
-
return this.serialComponentValidator;
|
|
1393
|
-
}
|
|
1394
|
-
// eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
|
|
1395
|
-
concatenateValidated(baseIdentificationKey, serialComponent) {
|
|
1411
|
+
concatenateValidated(baseIdentificationKey, serialComponentOrComponents) {
|
|
1396
1412
|
let result;
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1413
|
+
const serialComponentCreator = this.serialComponentCreator;
|
|
1414
|
+
const serialComponentValidation = this.serialComponentValidation;
|
|
1415
|
+
function validateAndConcatenate(serialComponent) {
|
|
1416
|
+
serialComponentCreator.validate(serialComponent, serialComponentValidation);
|
|
1417
|
+
return baseIdentificationKey + serialComponent;
|
|
1418
|
+
}
|
|
1419
|
+
if (typeof serialComponentOrComponents !== "object") {
|
|
1420
|
+
result = validateAndConcatenate(serialComponentOrComponents);
|
|
1400
1421
|
} else {
|
|
1401
|
-
result = import_utility3.IteratorProxy.from(
|
|
1422
|
+
result = import_utility3.IteratorProxy.from(serialComponentOrComponents).map(validateAndConcatenate);
|
|
1402
1423
|
}
|
|
1403
1424
|
return result;
|
|
1404
1425
|
}
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1426
|
+
/**
|
|
1427
|
+
* Create serialized identification key(s) with a reference based on a numeric value concatenated with serial
|
|
1428
|
+
* component(s). The value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
|
|
1429
|
+
*
|
|
1430
|
+
* @param value
|
|
1431
|
+
* Numeric value of the reference.
|
|
1432
|
+
*
|
|
1433
|
+
* @param serialComponentOrComponents
|
|
1434
|
+
* Serial component(s).
|
|
1435
|
+
*
|
|
1436
|
+
* @param sparse
|
|
1437
|
+
* If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
|
|
1438
|
+
*
|
|
1439
|
+
* @returns
|
|
1440
|
+
* Serialized identification keys.
|
|
1441
|
+
*/
|
|
1442
|
+
createSerialized(value, serialComponentOrComponents, sparse) {
|
|
1443
|
+
return this.concatenateValidated(this.create(value, sparse), serialComponentOrComponents);
|
|
1408
1444
|
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1445
|
+
/**
|
|
1446
|
+
* Concatenate a base identification key with serial component(s).
|
|
1447
|
+
*
|
|
1448
|
+
* @param baseIdentificationKey
|
|
1449
|
+
* Base identification key.
|
|
1450
|
+
*
|
|
1451
|
+
* @param serialComponentOrComponents
|
|
1452
|
+
* Serial component(s).
|
|
1453
|
+
*
|
|
1454
|
+
* @returns
|
|
1455
|
+
* Serialized identification key(s).
|
|
1456
|
+
*/
|
|
1457
|
+
concatenate(baseIdentificationKey, serialComponentOrComponents) {
|
|
1411
1458
|
this.validate(baseIdentificationKey);
|
|
1412
|
-
return this.concatenateValidated(baseIdentificationKey,
|
|
1459
|
+
return this.concatenateValidated(baseIdentificationKey, serialComponentOrComponents);
|
|
1413
1460
|
}
|
|
1414
1461
|
};
|
|
1415
1462
|
var NonNumericIdentificationKeyCreator = class extends (0, import_ts_mixer.Mixin)(NonNumericIdentificationKeyValidator, AbstractIdentificationKeyCreator) {
|
|
@@ -1448,15 +1495,36 @@ var NonNumericIdentificationKeyCreator = class extends (0, import_ts_mixer.Mixin
|
|
|
1448
1495
|
})
|
|
1449
1496
|
};
|
|
1450
1497
|
}
|
|
1451
|
-
|
|
1498
|
+
/**
|
|
1499
|
+
* Get the reference validation parameters.
|
|
1500
|
+
*/
|
|
1501
|
+
get referenceValidation() {
|
|
1502
|
+
return this._referenceValidation;
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Create identification key(s) with reference(s).
|
|
1506
|
+
*
|
|
1507
|
+
* @param referenceOrReferences
|
|
1508
|
+
* Reference(s).
|
|
1509
|
+
*
|
|
1510
|
+
* @returns
|
|
1511
|
+
* Identification key(s).
|
|
1512
|
+
*/
|
|
1452
1513
|
create(referenceOrReferences) {
|
|
1453
1514
|
let result;
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1515
|
+
const referenceCreator = this.referenceCreator;
|
|
1516
|
+
const referenceValidation = this.referenceValidation;
|
|
1517
|
+
const prefix = this.prefix;
|
|
1518
|
+
const requiresCheckCharacterPair = this.requiresCheckCharacterPair;
|
|
1519
|
+
function validateAndCreate(reference) {
|
|
1520
|
+
referenceCreator.validate(reference, referenceValidation);
|
|
1521
|
+
const partialIdentificationKey = prefix + reference;
|
|
1522
|
+
return requiresCheckCharacterPair ? partialIdentificationKey + checkCharacterPair(partialIdentificationKey) : partialIdentificationKey;
|
|
1523
|
+
}
|
|
1524
|
+
if (typeof referenceOrReferences !== "object") {
|
|
1525
|
+
result = validateAndCreate(referenceOrReferences);
|
|
1458
1526
|
} else {
|
|
1459
|
-
result = import_utility3.IteratorProxy.from(referenceOrReferences).map(
|
|
1527
|
+
result = import_utility3.IteratorProxy.from(referenceOrReferences).map(validateAndCreate);
|
|
1460
1528
|
}
|
|
1461
1529
|
return result;
|
|
1462
1530
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CharacterSetCreator, StringValidation, StringValidator,
|
|
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
|
|
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
|
|
253
|
+
* Reference creator.
|
|
254
254
|
*/
|
|
255
|
-
private readonly
|
|
255
|
+
private readonly _referenceCreator;
|
|
256
256
|
/**
|
|
257
|
-
* Get the 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
|
|
263
|
+
* Character set creator.
|
|
264
264
|
*/
|
|
265
|
-
protected static
|
|
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
|
|
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
|
|
517
|
+
* Serial component creator.
|
|
518
518
|
*/
|
|
519
|
-
private readonly
|
|
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
|
|
549
|
+
* Get the serial component creator.
|
|
550
550
|
*/
|
|
551
|
-
get
|
|
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
|
|
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
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
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
|
|
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
|
|
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
|
|
911
|
-
* Numeric value
|
|
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,
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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
|
|
1067
|
-
* Serial
|
|
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,
|
|
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
|
|
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
|
|
1096
|
-
* Serial
|
|
1014
|
+
* @param serialComponentOrComponents
|
|
1015
|
+
* Serial component(s).
|
|
1097
1016
|
*
|
|
1098
1017
|
* @returns
|
|
1099
|
-
* Serialized identification
|
|
1018
|
+
* Serialized identification key(s).
|
|
1100
1019
|
*/
|
|
1101
|
-
concatenate(baseIdentificationKey: 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
|
-
*
|
|
1134
|
-
*
|
|
1135
|
-
* @param reference
|
|
1136
|
-
* Reference.
|
|
1137
|
-
*
|
|
1138
|
-
* @returns
|
|
1139
|
-
* Identification key.
|
|
1052
|
+
* Get the reference validation parameters.
|
|
1140
1053
|
*/
|
|
1141
|
-
|
|
1054
|
+
protected get referenceValidation(): CharacterSetValidation;
|
|
1142
1055
|
/**
|
|
1143
|
-
* Create
|
|
1056
|
+
* Create identification key(s) with reference(s).
|
|
1144
1057
|
*
|
|
1145
|
-
* @param
|
|
1146
|
-
*
|
|
1058
|
+
* @param referenceOrReferences
|
|
1059
|
+
* Reference(s).
|
|
1147
1060
|
*
|
|
1148
1061
|
* @returns
|
|
1149
|
-
* Identification
|
|
1062
|
+
* Identification key(s).
|
|
1150
1063
|
*/
|
|
1151
|
-
create(
|
|
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.
|