@aidc-toolkit/gs1 1.0.22-beta → 1.0.24-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4624 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1588 -0
- package/dist/index.d.ts +1588 -36
- package/dist/index.js +4541 -19
- package/dist/index.js.map +1 -1
- package/package.json +4 -8
- package/src/character-set.ts +16 -1
- package/src/check.ts +2 -2
- package/src/gtin-creator.ts +4 -4
- package/src/gtin-validator.ts +6 -6
- package/src/identifier-creator.ts +3 -3
- package/src/identifier-validator.ts +4 -4
- package/src/index.ts +19 -19
- package/src/locale/en/{locale-strings.ts → locale-resources.ts} +1 -1
- package/src/locale/fr/{locale-strings.ts → locale-resources.ts} +2 -2
- package/src/locale/i18n.ts +6 -8
- package/src/locale/i18next.d.ts +4 -4
- package/src/non-gtin-numeric-identifier-creator.ts +4 -4
- package/src/non-gtin-numeric-identifier-validator.ts +3 -3
- package/src/non-numeric-identifier-creator.ts +6 -6
- package/src/non-numeric-identifier-validator.ts +6 -6
- package/src/numeric-identifier-creator.ts +3 -3
- package/src/numeric-identifier-validator.ts +5 -5
- package/src/prefix-manager.ts +36 -35
- package/src/prefix-provider.ts +1 -1
- package/src/prefix-validator.ts +2 -2
- package/src/serializable-numeric-identifier-creator.ts +4 -4
- package/src/serializable-numeric-identifier-validator.ts +5 -5
- package/test/creator.test.ts +3 -3
- package/test/gtin-creator.ts +1 -1
- package/test/gtin-validator.test.ts +1 -1
- package/test/identifier-creator.ts +4 -4
- package/test/non-gtin-numeric-identifier-creator.ts +1 -1
- package/test/non-gtin-numeric-identifier-validator.ts +1 -1
- package/test/non-numeric-identifier-validator.ts +2 -2
- package/test/numeric-identifier-creator.ts +1 -1
- package/test/numeric-identifier-validator.ts +1 -1
- package/test/prefix-manager.test.ts +1 -1
- package/test/serializable-numeric-identifier-creator.ts +1 -1
- package/test/serializable-numeric-identifier-validator.ts +2 -2
- package/test/validator.test.ts +4 -4
- package/tsup.config.ts +3 -0
- package/typedoc.json +1 -3
- package/dist/character-set.d.ts +0 -22
- package/dist/character-set.d.ts.map +0 -1
- package/dist/character-set.js +0 -36
- package/dist/character-set.js.map +0 -1
- package/dist/check.d.ts +0 -81
- package/dist/check.d.ts.map +0 -1
- package/dist/check.js +0 -218
- package/dist/check.js.map +0 -1
- package/dist/gtin-creator.d.ts +0 -68
- package/dist/gtin-creator.d.ts.map +0 -1
- package/dist/gtin-creator.js +0 -158
- package/dist/gtin-creator.js.map +0 -1
- package/dist/gtin-validator.d.ts +0 -202
- package/dist/gtin-validator.d.ts.map +0 -1
- package/dist/gtin-validator.js +0 -470
- package/dist/gtin-validator.js.map +0 -1
- package/dist/identifier-creator.d.ts +0 -72
- package/dist/identifier-creator.d.ts.map +0 -1
- package/dist/identifier-creator.js +0 -50
- package/dist/identifier-creator.js.map +0 -1
- package/dist/identifier-type.d.ts +0 -58
- package/dist/identifier-type.d.ts.map +0 -1
- package/dist/identifier-type.js +0 -54
- package/dist/identifier-type.js.map +0 -1
- package/dist/identifier-validator.d.ts +0 -174
- package/dist/identifier-validator.d.ts.map +0 -1
- package/dist/identifier-validator.js +0 -145
- package/dist/identifier-validator.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/locale/en/locale-strings.d.ts +0 -42
- package/dist/locale/en/locale-strings.d.ts.map +0 -1
- package/dist/locale/en/locale-strings.js +0 -42
- package/dist/locale/en/locale-strings.js.map +0 -1
- package/dist/locale/fr/locale-strings.d.ts +0 -42
- package/dist/locale/fr/locale-strings.d.ts.map +0 -1
- package/dist/locale/fr/locale-strings.js +0 -42
- package/dist/locale/fr/locale-strings.js.map +0 -1
- package/dist/locale/i18n.d.ts +0 -27
- package/dist/locale/i18n.d.ts.map +0 -1
- package/dist/locale/i18n.js +0 -37
- package/dist/locale/i18n.js.map +0 -1
- package/dist/non-gtin-numeric-identifier-creator.d.ts +0 -30
- package/dist/non-gtin-numeric-identifier-creator.d.ts.map +0 -1
- package/dist/non-gtin-numeric-identifier-creator.js +0 -30
- package/dist/non-gtin-numeric-identifier-creator.js.map +0 -1
- package/dist/non-gtin-numeric-identifier-validator.d.ts +0 -41
- package/dist/non-gtin-numeric-identifier-validator.d.ts.map +0 -1
- package/dist/non-gtin-numeric-identifier-validator.js +0 -40
- package/dist/non-gtin-numeric-identifier-validator.js.map +0 -1
- package/dist/non-numeric-identifier-creator.d.ts +0 -55
- package/dist/non-numeric-identifier-creator.d.ts.map +0 -1
- package/dist/non-numeric-identifier-creator.js +0 -93
- package/dist/non-numeric-identifier-creator.js.map +0 -1
- package/dist/non-numeric-identifier-validator.d.ts +0 -78
- package/dist/non-numeric-identifier-validator.d.ts.map +0 -1
- package/dist/non-numeric-identifier-validator.js +0 -95
- package/dist/non-numeric-identifier-validator.js.map +0 -1
- package/dist/numeric-identifier-creator.d.ts +0 -121
- package/dist/numeric-identifier-creator.d.ts.map +0 -1
- package/dist/numeric-identifier-creator.js +0 -135
- package/dist/numeric-identifier-creator.js.map +0 -1
- package/dist/numeric-identifier-validator.d.ts +0 -76
- package/dist/numeric-identifier-validator.d.ts.map +0 -1
- package/dist/numeric-identifier-validator.js +0 -84
- package/dist/numeric-identifier-validator.js.map +0 -1
- package/dist/prefix-manager.d.ts +0 -224
- package/dist/prefix-manager.d.ts.map +0 -1
- package/dist/prefix-manager.js +0 -369
- package/dist/prefix-manager.js.map +0 -1
- package/dist/prefix-provider.d.ts +0 -27
- package/dist/prefix-provider.d.ts.map +0 -1
- package/dist/prefix-provider.js +0 -2
- package/dist/prefix-provider.js.map +0 -1
- package/dist/prefix-type.d.ts +0 -22
- package/dist/prefix-type.d.ts.map +0 -1
- package/dist/prefix-type.js +0 -18
- package/dist/prefix-type.js.map +0 -1
- package/dist/prefix-validator.d.ts +0 -58
- package/dist/prefix-validator.d.ts.map +0 -1
- package/dist/prefix-validator.js +0 -154
- package/dist/prefix-validator.js.map +0 -1
- package/dist/serializable-numeric-identifier-creator.d.ts +0 -86
- package/dist/serializable-numeric-identifier-creator.d.ts.map +0 -1
- package/dist/serializable-numeric-identifier-creator.js +0 -116
- package/dist/serializable-numeric-identifier-creator.js.map +0 -1
- package/dist/serializable-numeric-identifier-validator.d.ts +0 -79
- package/dist/serializable-numeric-identifier-validator.d.ts.map +0 -1
- package/dist/serializable-numeric-identifier-validator.js +0 -99
- package/dist/serializable-numeric-identifier-validator.js.map +0 -1
package/dist/locale/i18n.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,OAAqC,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE1E,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC;AAOjC,wBAAwB,CAAC,eAAe,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAa;IAClC,EAAE,EAAE;QACA,SAAS,EAAE,eAAe;KAC7B;IACD,EAAE,EAAE;QACA,SAAS,EAAE,eAAe;KAC7B;CACJ,CAAC;AAEF,wFAAwF;AACxF,MAAM,CAAC,MAAM,UAAU,GAAS,OAAO,CAAC,cAAc,EAAE,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAA4B,EAAE,KAAK,GAAG,KAAK;IACzE,MAAM,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC1C,MAAM,YAAY,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { IdentifierType } from "./identifier-type.js";
|
|
2
|
-
import { NonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
|
|
3
|
-
import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
|
|
4
|
-
import { type LeaderType } from "./numeric-identifier-validator.js";
|
|
5
|
-
import type { PrefixProvider } from "./prefix-provider";
|
|
6
|
-
declare const NonGTINNumericIdentifierCreator_base: import("ts-mixer/dist/types/types.js").Class<any[], NonGTINNumericIdentifierValidator & AbstractNumericIdentifierCreator, typeof NonGTINNumericIdentifierValidator & typeof AbstractNumericIdentifierCreator>;
|
|
7
|
-
/**
|
|
8
|
-
* Non-GTIN numeric identifier creator.
|
|
9
|
-
*/
|
|
10
|
-
export declare class NonGTINNumericIdentifierCreator extends NonGTINNumericIdentifierCreator_base {
|
|
11
|
-
/**
|
|
12
|
-
* Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix
|
|
13
|
-
* provider type.
|
|
14
|
-
*
|
|
15
|
-
* @param prefixProvider
|
|
16
|
-
* Prefix provider.
|
|
17
|
-
*
|
|
18
|
-
* @param identifierType
|
|
19
|
-
* Identifier type.
|
|
20
|
-
*
|
|
21
|
-
* @param length
|
|
22
|
-
* Length.
|
|
23
|
-
*
|
|
24
|
-
* @param leaderType
|
|
25
|
-
* Leader type.
|
|
26
|
-
*/
|
|
27
|
-
constructor(prefixProvider: PrefixProvider, identifierType: IdentifierType, length: number, leaderType?: LeaderType);
|
|
28
|
-
}
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=non-gtin-numeric-identifier-creator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"non-gtin-numeric-identifier-creator.d.ts","sourceRoot":"","sources":["../src/non-gtin-numeric-identifier-creator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,mCAAmC,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;;AAExD;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,oCAA0E;IAC3H;;;;;;;;;;;;;;;OAeG;gBACS,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAE,UAA6B;CAKxI"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Mixin } from "ts-mixer";
|
|
2
|
-
import { NonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
|
|
3
|
-
import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
|
|
4
|
-
import { LeaderTypes } from "./numeric-identifier-validator.js";
|
|
5
|
-
/**
|
|
6
|
-
* Non-GTIN numeric identifier creator.
|
|
7
|
-
*/
|
|
8
|
-
export class NonGTINNumericIdentifierCreator extends Mixin(NonGTINNumericIdentifierValidator, AbstractNumericIdentifierCreator) {
|
|
9
|
-
/**
|
|
10
|
-
* Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix
|
|
11
|
-
* provider type.
|
|
12
|
-
*
|
|
13
|
-
* @param prefixProvider
|
|
14
|
-
* Prefix provider.
|
|
15
|
-
*
|
|
16
|
-
* @param identifierType
|
|
17
|
-
* Identifier type.
|
|
18
|
-
*
|
|
19
|
-
* @param length
|
|
20
|
-
* Length.
|
|
21
|
-
*
|
|
22
|
-
* @param leaderType
|
|
23
|
-
* Leader type.
|
|
24
|
-
*/
|
|
25
|
-
constructor(prefixProvider, identifierType, length, leaderType = LeaderTypes.None) {
|
|
26
|
-
super(identifierType, length, leaderType);
|
|
27
|
-
this.init(prefixProvider, prefixProvider.gs1CompanyPrefix);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=non-gtin-numeric-identifier-creator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"non-gtin-numeric-identifier-creator.js","sourceRoot":"","sources":["../src/non-gtin-numeric-identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAmB,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAGjF;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,KAAK,CAAC,iCAAiC,EAAE,gCAAgC,CAAC;IAC3H;;;;;;;;;;;;;;;OAeG;IACH,YAAY,cAA8B,EAAE,cAA8B,EAAE,MAAc,EAAE,aAAyB,WAAW,CAAC,IAAI;QACjI,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QAE1C,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAC/D,CAAC;CACJ"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type IdentifierType, IdentifierTypes } from "./identifier-type.js";
|
|
2
|
-
import { AbstractNumericIdentifierValidator, type LeaderType, type NumericIdentifierType } from "./numeric-identifier-validator.js";
|
|
3
|
-
/**
|
|
4
|
-
* Non-GTIN numeric identifier type.
|
|
5
|
-
*/
|
|
6
|
-
export type NonGTINNumericIdentifierType = Exclude<NumericIdentifierType, typeof IdentifierTypes.GTIN>;
|
|
7
|
-
/**
|
|
8
|
-
* Non-GTIN numeric identifier validator.
|
|
9
|
-
*/
|
|
10
|
-
export declare class NonGTINNumericIdentifierValidator extends AbstractNumericIdentifierValidator {
|
|
11
|
-
/**
|
|
12
|
-
* Constructor.
|
|
13
|
-
*
|
|
14
|
-
* @param identifierType
|
|
15
|
-
* Identifier type.
|
|
16
|
-
*
|
|
17
|
-
* @param length
|
|
18
|
-
* Length.
|
|
19
|
-
*
|
|
20
|
-
* @param leaderType
|
|
21
|
-
* Leader type.
|
|
22
|
-
*/
|
|
23
|
-
constructor(identifierType: IdentifierType, length: number, leaderType?: LeaderType);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* GLN validator.
|
|
27
|
-
*/
|
|
28
|
-
export declare const GLN_VALIDATOR: NonGTINNumericIdentifierValidator;
|
|
29
|
-
/**
|
|
30
|
-
* SSCC validator.
|
|
31
|
-
*/
|
|
32
|
-
export declare const SSCC_VALIDATOR: NonGTINNumericIdentifierValidator;
|
|
33
|
-
/**
|
|
34
|
-
* GSRN validator.
|
|
35
|
-
*/
|
|
36
|
-
export declare const GSRN_VALIDATOR: NonGTINNumericIdentifierValidator;
|
|
37
|
-
/**
|
|
38
|
-
* GSIN validator.
|
|
39
|
-
*/
|
|
40
|
-
export declare const GSIN_VALIDATOR: NonGTINNumericIdentifierValidator;
|
|
41
|
-
//# sourceMappingURL=non-gtin-numeric-identifier-validator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"non-gtin-numeric-identifier-validator.d.ts","sourceRoot":"","sources":["../src/non-gtin-numeric-identifier-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACH,kCAAkC,EAClC,KAAK,UAAU,EAEf,KAAK,qBAAqB,EAC7B,MAAM,mCAAmC,CAAC;AAG3C;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,qBAAqB,EAAE,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;AAEvG;;GAEG;AACH,qBAAa,iCAAkC,SAAQ,kCAAkC;IACrF;;;;;;;;;;;OAWG;gBACS,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAE,UAA6B;CAGxG;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,mCAAiE,CAAC;AAE5F;;GAEG;AACH,eAAO,MAAM,cAAc,mCAA8F,CAAC;AAE1H;;GAEG;AACH,eAAO,MAAM,cAAc,mCAAkE,CAAC;AAE9F;;GAEG;AACH,eAAO,MAAM,cAAc,mCAAkE,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IdentifierTypes } from "./identifier-type.js";
|
|
2
|
-
import { AbstractNumericIdentifierValidator, LeaderTypes } from "./numeric-identifier-validator.js";
|
|
3
|
-
import { PrefixTypes } from "./prefix-type.js";
|
|
4
|
-
/**
|
|
5
|
-
* Non-GTIN numeric identifier validator.
|
|
6
|
-
*/
|
|
7
|
-
export class NonGTINNumericIdentifierValidator extends AbstractNumericIdentifierValidator {
|
|
8
|
-
/**
|
|
9
|
-
* Constructor.
|
|
10
|
-
*
|
|
11
|
-
* @param identifierType
|
|
12
|
-
* Identifier type.
|
|
13
|
-
*
|
|
14
|
-
* @param length
|
|
15
|
-
* Length.
|
|
16
|
-
*
|
|
17
|
-
* @param leaderType
|
|
18
|
-
* Leader type.
|
|
19
|
-
*/
|
|
20
|
-
constructor(identifierType, length, leaderType = LeaderTypes.None) {
|
|
21
|
-
super(identifierType, PrefixTypes.GS1CompanyPrefix, length, leaderType);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* GLN validator.
|
|
26
|
-
*/
|
|
27
|
-
export const GLN_VALIDATOR = new NonGTINNumericIdentifierValidator(IdentifierTypes.GLN, 13);
|
|
28
|
-
/**
|
|
29
|
-
* SSCC validator.
|
|
30
|
-
*/
|
|
31
|
-
export const SSCC_VALIDATOR = new NonGTINNumericIdentifierValidator(IdentifierTypes.SSCC, 18, LeaderTypes.ExtensionDigit);
|
|
32
|
-
/**
|
|
33
|
-
* GSRN validator.
|
|
34
|
-
*/
|
|
35
|
-
export const GSRN_VALIDATOR = new NonGTINNumericIdentifierValidator(IdentifierTypes.GSRN, 18);
|
|
36
|
-
/**
|
|
37
|
-
* GSIN validator.
|
|
38
|
-
*/
|
|
39
|
-
export const GSIN_VALIDATOR = new NonGTINNumericIdentifierValidator(IdentifierTypes.GSIN, 17);
|
|
40
|
-
//# sourceMappingURL=non-gtin-numeric-identifier-validator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"non-gtin-numeric-identifier-validator.js","sourceRoot":"","sources":["../src/non-gtin-numeric-identifier-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACH,kCAAkC,EAElC,WAAW,EAEd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAO/C;;GAEG;AACH,MAAM,OAAO,iCAAkC,SAAQ,kCAAkC;IACrF;;;;;;;;;;;OAWG;IACH,YAAY,cAA8B,EAAE,MAAc,EAAE,aAAyB,WAAW,CAAC,IAAI;QACjG,KAAK,CAAC,cAAc,EAAE,WAAW,CAAC,gBAAgB,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC5E,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,iCAAiC,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAE5F;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,iCAAiC,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;AAE1H;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,iCAAiC,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAE9F;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,iCAAiC,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { type CharacterSetValidation, type TransformerInput, type TransformerOutput } from "@aidc-toolkit/utility";
|
|
2
|
-
import { AbstractIdentifierCreator } from "./identifier-creator.js";
|
|
3
|
-
import type { IdentifierType } from "./identifier-type.js";
|
|
4
|
-
import type { ContentCharacterSet } from "./identifier-validator.js";
|
|
5
|
-
import { NonNumericIdentifierValidator } from "./non-numeric-identifier-validator.js";
|
|
6
|
-
import type { PrefixProvider } from "./prefix-provider";
|
|
7
|
-
declare const NonNumericIdentifierCreator_base: import("ts-mixer/dist/types/types.js").Class<any[], NonNumericIdentifierValidator & AbstractIdentifierCreator, typeof NonNumericIdentifierValidator & typeof AbstractIdentifierCreator>;
|
|
8
|
-
/**
|
|
9
|
-
* Non-numeric identifier creator.
|
|
10
|
-
*/
|
|
11
|
-
export declare class NonNumericIdentifierCreator extends NonNumericIdentifierCreator_base {
|
|
12
|
-
/**
|
|
13
|
-
* Reference validation parameters.
|
|
14
|
-
*/
|
|
15
|
-
private readonly _referenceValidation;
|
|
16
|
-
/**
|
|
17
|
-
* Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix
|
|
18
|
-
* provider type.
|
|
19
|
-
*
|
|
20
|
-
* @param prefixProvider
|
|
21
|
-
* Prefix provider.
|
|
22
|
-
*
|
|
23
|
-
* @param identifierType
|
|
24
|
-
* Identifier type.
|
|
25
|
-
*
|
|
26
|
-
* @param length
|
|
27
|
-
* Length.
|
|
28
|
-
*
|
|
29
|
-
* @param referenceCharacterSet
|
|
30
|
-
* Reference character set.
|
|
31
|
-
*
|
|
32
|
-
* @param requiresCheckCharacterPair
|
|
33
|
-
* True if the identifier requires a check character pair.
|
|
34
|
-
*/
|
|
35
|
-
constructor(prefixProvider: PrefixProvider, identifierType: IdentifierType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair?: boolean);
|
|
36
|
-
/**
|
|
37
|
-
* Get the reference validation parameters.
|
|
38
|
-
*/
|
|
39
|
-
protected get referenceValidation(): CharacterSetValidation;
|
|
40
|
-
/**
|
|
41
|
-
* Create identifier(s) with reference(s).
|
|
42
|
-
*
|
|
43
|
-
* @template TTransformerInput
|
|
44
|
-
* Transformer input type.
|
|
45
|
-
*
|
|
46
|
-
* @param referenceOrReferences
|
|
47
|
-
* Reference(s).
|
|
48
|
-
*
|
|
49
|
-
* @returns
|
|
50
|
-
* Identifier(s).
|
|
51
|
-
*/
|
|
52
|
-
create<TTransformerInput extends TransformerInput<string>>(referenceOrReferences: TTransformerInput): TransformerOutput<TTransformerInput, string>;
|
|
53
|
-
}
|
|
54
|
-
export {};
|
|
55
|
-
//# sourceMappingURL=non-numeric-identifier-creator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"non-numeric-identifier-creator.d.ts","sourceRoot":"","sources":["../src/non-numeric-identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,sBAAsB,EAE3B,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACzB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;;AAExD;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,gCAA+D;IAC5G;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAyB;IAE9D;;;;;;;;;;;;;;;;;;OAkBG;gBACS,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,0BAA0B,UAAQ;IAa1K;;OAEG;IACH,SAAS,KAAK,mBAAmB,IAAI,sBAAsB,CAE1D;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,MAAM,CAAC,EAAE,qBAAqB,EAAE,iBAAiB,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,CAAC;CAmCrJ"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { mapIterable } from "@aidc-toolkit/utility";
|
|
2
|
-
import { Mixin } from "ts-mixer";
|
|
3
|
-
import { checkCharacterPair } from "./check.js";
|
|
4
|
-
import { AbstractIdentifierCreator } from "./identifier-creator.js";
|
|
5
|
-
import { i18nextGS1 } from "./locale/i18n.js";
|
|
6
|
-
import { NonNumericIdentifierValidator } from "./non-numeric-identifier-validator.js";
|
|
7
|
-
/**
|
|
8
|
-
* Non-numeric identifier creator.
|
|
9
|
-
*/
|
|
10
|
-
export class NonNumericIdentifierCreator extends Mixin(NonNumericIdentifierValidator, AbstractIdentifierCreator) {
|
|
11
|
-
/**
|
|
12
|
-
* Reference validation parameters.
|
|
13
|
-
*/
|
|
14
|
-
_referenceValidation;
|
|
15
|
-
/**
|
|
16
|
-
* Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix
|
|
17
|
-
* provider type.
|
|
18
|
-
*
|
|
19
|
-
* @param prefixProvider
|
|
20
|
-
* Prefix provider.
|
|
21
|
-
*
|
|
22
|
-
* @param identifierType
|
|
23
|
-
* Identifier type.
|
|
24
|
-
*
|
|
25
|
-
* @param length
|
|
26
|
-
* Length.
|
|
27
|
-
*
|
|
28
|
-
* @param referenceCharacterSet
|
|
29
|
-
* Reference character set.
|
|
30
|
-
*
|
|
31
|
-
* @param requiresCheckCharacterPair
|
|
32
|
-
* True if the identifier requires a check character pair.
|
|
33
|
-
*/
|
|
34
|
-
constructor(prefixProvider, identifierType, length, referenceCharacterSet, requiresCheckCharacterPair = false) {
|
|
35
|
-
super(identifierType, length, referenceCharacterSet, requiresCheckCharacterPair);
|
|
36
|
-
this.init(prefixProvider, prefixProvider.gs1CompanyPrefix, 2 * Number(requiresCheckCharacterPair));
|
|
37
|
-
this._referenceValidation = {
|
|
38
|
-
minimumLength: 1,
|
|
39
|
-
// Maximum reference length has to account for prefix and check character pair.
|
|
40
|
-
maximumLength: this.referenceLength,
|
|
41
|
-
component: () => i18nextGS1.t("Identifier.reference")
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Get the reference validation parameters.
|
|
46
|
-
*/
|
|
47
|
-
get referenceValidation() {
|
|
48
|
-
return this._referenceValidation;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Create identifier(s) with reference(s).
|
|
52
|
-
*
|
|
53
|
-
* @template TTransformerInput
|
|
54
|
-
* Transformer input type.
|
|
55
|
-
*
|
|
56
|
-
* @param referenceOrReferences
|
|
57
|
-
* Reference(s).
|
|
58
|
-
*
|
|
59
|
-
* @returns
|
|
60
|
-
* Identifier(s).
|
|
61
|
-
*/
|
|
62
|
-
create(referenceOrReferences) {
|
|
63
|
-
// TODO Refactor type when https://github.com/microsoft/TypeScript/pull/56941 released.
|
|
64
|
-
let result;
|
|
65
|
-
const referenceCreator = this.referenceCreator;
|
|
66
|
-
const referenceValidation = this.referenceValidation;
|
|
67
|
-
const prefix = this.prefix;
|
|
68
|
-
const requiresCheckCharacterPair = this.requiresCheckCharacterPair;
|
|
69
|
-
/**
|
|
70
|
-
* Validate a reference and create an identifier.
|
|
71
|
-
*
|
|
72
|
-
* @param reference
|
|
73
|
-
* Reference.
|
|
74
|
-
*
|
|
75
|
-
* @returns
|
|
76
|
-
* Identifier.
|
|
77
|
-
*/
|
|
78
|
-
function validateAndCreate(reference) {
|
|
79
|
-
referenceCreator.validate(reference, referenceValidation);
|
|
80
|
-
const partialIdentifier = prefix + reference;
|
|
81
|
-
return requiresCheckCharacterPair ? partialIdentifier + checkCharacterPair(partialIdentifier) : partialIdentifier;
|
|
82
|
-
}
|
|
83
|
-
if (typeof referenceOrReferences !== "object") {
|
|
84
|
-
result = validateAndCreate(referenceOrReferences);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
result = mapIterable(referenceOrReferences, validateAndCreate);
|
|
88
|
-
}
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type determination is handled above.
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=non-numeric-identifier-creator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"non-numeric-identifier-creator.js","sourceRoot":"","sources":["../src/non-numeric-identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,WAAW,EAGd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAGtF;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK,CAAC,6BAA6B,EAAE,yBAAyB,CAAC;IAC5G;;OAEG;IACc,oBAAoB,CAAyB;IAE9D;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,cAA8B,EAAE,cAA8B,EAAE,MAAc,EAAE,qBAA0C,EAAE,0BAA0B,GAAG,KAAK;QACtK,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,qBAAqB,EAAE,0BAA0B,CAAC,CAAC;QAEjF,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,gBAAgB,EAAE,CAAC,GAAG,MAAM,CAAC,0BA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idc-toolkit/utility";
|
|
2
|
-
import { type IdentifierType } from "./identifier-type.js";
|
|
3
|
-
import { AbstractIdentifierValidator, type ContentCharacterSet, type IdentifierValidation } from "./identifier-validator.js";
|
|
4
|
-
import type { NumericIdentifierType } from "./numeric-identifier-validator.js";
|
|
5
|
-
/**
|
|
6
|
-
* Non-numeric identifier type.
|
|
7
|
-
*/
|
|
8
|
-
export type NonNumericIdentifierType = Exclude<IdentifierType, NumericIdentifierType>;
|
|
9
|
-
/**
|
|
10
|
-
* Non-numeric identifier validation parameters.
|
|
11
|
-
*/
|
|
12
|
-
export interface NonNumericIdentifierValidation extends IdentifierValidation {
|
|
13
|
-
/**
|
|
14
|
-
* Exclusion support for reference. Prevents non-numeric identifier from being mistaken for numeric
|
|
15
|
-
* identifier.
|
|
16
|
-
*/
|
|
17
|
-
exclusion?: typeof Exclusions.None | typeof Exclusions.AllNumeric | undefined;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Non-numeric identifier validator.
|
|
21
|
-
*/
|
|
22
|
-
export declare class NonNumericIdentifierValidator extends AbstractIdentifierValidator<NonNumericIdentifierValidation> {
|
|
23
|
-
/**
|
|
24
|
-
* Validator to ensure that an identifier (minus check character pair) is not all numeric.
|
|
25
|
-
*/
|
|
26
|
-
private static readonly NOT_ALL_NUMERIC_VALIDATOR;
|
|
27
|
-
/**
|
|
28
|
-
* True if the identifier requires a check character pair.
|
|
29
|
-
*/
|
|
30
|
-
private readonly _requiresCheckCharacterPair;
|
|
31
|
-
/**
|
|
32
|
-
* Constructor.
|
|
33
|
-
*
|
|
34
|
-
* @param identifierType
|
|
35
|
-
* Identifier type.
|
|
36
|
-
*
|
|
37
|
-
* @param length
|
|
38
|
-
* Length.
|
|
39
|
-
*
|
|
40
|
-
* @param referenceCharacterSet
|
|
41
|
-
* Reference character set.
|
|
42
|
-
*
|
|
43
|
-
* @param requiresCheckCharacterPair
|
|
44
|
-
* True if the identifier requires a check character pair.
|
|
45
|
-
*/
|
|
46
|
-
constructor(identifierType: IdentifierType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair?: boolean);
|
|
47
|
-
/**
|
|
48
|
-
* Determine if the identifier requires a check character pair.
|
|
49
|
-
*/
|
|
50
|
-
get requiresCheckCharacterPair(): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Validate a non-numeric identifier and throw an error if validation fails.
|
|
53
|
-
*
|
|
54
|
-
* @param identifier
|
|
55
|
-
* Identifier.
|
|
56
|
-
*
|
|
57
|
-
* @param validation
|
|
58
|
-
* Validation parameters.
|
|
59
|
-
*/
|
|
60
|
-
validate(identifier: string, validation?: NonNumericIdentifierValidation): void;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* GIAI validator.
|
|
64
|
-
*/
|
|
65
|
-
export declare const GIAI_VALIDATOR: NonNumericIdentifierValidator;
|
|
66
|
-
/**
|
|
67
|
-
* GINC validator.
|
|
68
|
-
*/
|
|
69
|
-
export declare const GINC_VALIDATOR: NonNumericIdentifierValidator;
|
|
70
|
-
/**
|
|
71
|
-
* CPID validator.
|
|
72
|
-
*/
|
|
73
|
-
export declare const CPID_VALIDATOR: NonNumericIdentifierValidator;
|
|
74
|
-
/**
|
|
75
|
-
* GMN validator.
|
|
76
|
-
*/
|
|
77
|
-
export declare const GMN_VALIDATOR: NonNumericIdentifierValidator;
|
|
78
|
-
//# sourceMappingURL=non-numeric-identifier-validator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"non-numeric-identifier-validator.d.ts","sourceRoot":"","sources":["../src/non-numeric-identifier-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,KAAK,cAAc,EAAmB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACH,2BAA2B,EAC3B,KAAK,mBAAmB,EAExB,KAAK,oBAAoB,EAC5B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAG/E;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,8BAA+B,SAAQ,oBAAoB;IACxE;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,UAAU,CAAC,IAAI,GAAG,OAAO,UAAU,CAAC,UAAU,GAAG,SAAS,CAAC;CACjF;AAED;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,2BAA2B,CAAC,8BAA8B,CAAC;IAC1G;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAOzC;IAER;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAU;IAEtD;;;;;;;;;;;;;;OAcG;gBACS,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,0BAA0B,UAAQ;IAM1I;;OAEG;IACH,IAAI,0BAA0B,IAAI,OAAO,CAExC;IAED;;;;;;;;OAQG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,8BAA8B,GAAG,IAAI;CAoBlF;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,+BAAyF,CAAC;AAErH;;GAEG;AACH,eAAO,MAAM,cAAc,+BAAyF,CAAC;AAErH;;GAEG;AACH,eAAO,MAAM,cAAc,+BAAyF,CAAC;AAErH;;GAEG;AACH,eAAO,MAAM,aAAa,+BAA8F,CAAC"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { Exclusions, RegExpValidator } from "@aidc-toolkit/utility";
|
|
2
|
-
import { hasValidCheckCharacterPair } from "./check.js";
|
|
3
|
-
import { IdentifierTypes } from "./identifier-type.js";
|
|
4
|
-
import { AbstractIdentifierValidator, ContentCharacterSets } from "./identifier-validator.js";
|
|
5
|
-
import { i18nextGS1 } from "./locale/i18n.js";
|
|
6
|
-
import { PrefixTypes } from "./prefix-type.js";
|
|
7
|
-
/**
|
|
8
|
-
* Non-numeric identifier validator.
|
|
9
|
-
*/
|
|
10
|
-
export class NonNumericIdentifierValidator extends AbstractIdentifierValidator {
|
|
11
|
-
/**
|
|
12
|
-
* Validator to ensure that an identifier (minus check character pair) is not all numeric.
|
|
13
|
-
*/
|
|
14
|
-
static NOT_ALL_NUMERIC_VALIDATOR = new class extends RegExpValidator {
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
createErrorMessage(_s) {
|
|
19
|
-
return i18nextGS1.t("Identifier.referenceCantBeAllNumeric");
|
|
20
|
-
}
|
|
21
|
-
}(/\D/);
|
|
22
|
-
/**
|
|
23
|
-
* True if the identifier requires a check character pair.
|
|
24
|
-
*/
|
|
25
|
-
_requiresCheckCharacterPair;
|
|
26
|
-
/**
|
|
27
|
-
* Constructor.
|
|
28
|
-
*
|
|
29
|
-
* @param identifierType
|
|
30
|
-
* Identifier type.
|
|
31
|
-
*
|
|
32
|
-
* @param length
|
|
33
|
-
* Length.
|
|
34
|
-
*
|
|
35
|
-
* @param referenceCharacterSet
|
|
36
|
-
* Reference character set.
|
|
37
|
-
*
|
|
38
|
-
* @param requiresCheckCharacterPair
|
|
39
|
-
* True if the identifier requires a check character pair.
|
|
40
|
-
*/
|
|
41
|
-
constructor(identifierType, length, referenceCharacterSet, requiresCheckCharacterPair = false) {
|
|
42
|
-
super(identifierType, PrefixTypes.GS1CompanyPrefix, length, referenceCharacterSet);
|
|
43
|
-
this._requiresCheckCharacterPair = requiresCheckCharacterPair;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Determine if the identifier requires a check character pair.
|
|
47
|
-
*/
|
|
48
|
-
get requiresCheckCharacterPair() {
|
|
49
|
-
return this._requiresCheckCharacterPair;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Validate a non-numeric identifier and throw an error if validation fails.
|
|
53
|
-
*
|
|
54
|
-
* @param identifier
|
|
55
|
-
* Identifier.
|
|
56
|
-
*
|
|
57
|
-
* @param validation
|
|
58
|
-
* Validation parameters.
|
|
59
|
-
*/
|
|
60
|
-
validate(identifier, validation) {
|
|
61
|
-
const partialIdentifier = this.requiresCheckCharacterPair ? identifier.substring(0, identifier.length - 2) : identifier;
|
|
62
|
-
super.validatePrefix(partialIdentifier, validation?.positionOffset);
|
|
63
|
-
if (!this.requiresCheckCharacterPair) {
|
|
64
|
-
this.referenceCreator.validate(identifier, {
|
|
65
|
-
maximumLength: this.length,
|
|
66
|
-
positionOffset: validation?.positionOffset
|
|
67
|
-
});
|
|
68
|
-
// Validating the check character pair will also validate the characters.
|
|
69
|
-
}
|
|
70
|
-
else if (!hasValidCheckCharacterPair(this.padIdentifier(identifier, validation))) {
|
|
71
|
-
throw new RangeError(i18nextGS1.t("Identifier.invalidCheckCharacterPair"));
|
|
72
|
-
}
|
|
73
|
-
// Check for all-numeric identifier (minus check character pair) if excluded.
|
|
74
|
-
if (validation?.exclusion === Exclusions.AllNumeric) {
|
|
75
|
-
NonNumericIdentifierValidator.NOT_ALL_NUMERIC_VALIDATOR.validate(partialIdentifier);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* GIAI validator.
|
|
81
|
-
*/
|
|
82
|
-
export const GIAI_VALIDATOR = new NonNumericIdentifierValidator(IdentifierTypes.GIAI, 30, ContentCharacterSets.AI82);
|
|
83
|
-
/**
|
|
84
|
-
* GINC validator.
|
|
85
|
-
*/
|
|
86
|
-
export const GINC_VALIDATOR = new NonNumericIdentifierValidator(IdentifierTypes.GINC, 30, ContentCharacterSets.AI82);
|
|
87
|
-
/**
|
|
88
|
-
* CPID validator.
|
|
89
|
-
*/
|
|
90
|
-
export const CPID_VALIDATOR = new NonNumericIdentifierValidator(IdentifierTypes.CPID, 30, ContentCharacterSets.AI39);
|
|
91
|
-
/**
|
|
92
|
-
* GMN validator.
|
|
93
|
-
*/
|
|
94
|
-
export const GMN_VALIDATOR = new NonNumericIdentifierValidator(IdentifierTypes.GMN, 25, ContentCharacterSets.AI82, true);
|
|
95
|
-
//# sourceMappingURL=non-numeric-identifier-validator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"non-numeric-identifier-validator.js","sourceRoot":"","sources":["../src/non-numeric-identifier-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAuB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACH,2BAA2B,EAE3B,oBAAoB,EAEvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAkB/C;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,2BAA2D;IAC1G;;OAEG;IACK,MAAM,CAAU,yBAAyB,GAAG,IAAI,KAAM,SAAQ,eAAe;QACjF;;WAEG;QACgB,kBAAkB,CAAC,EAAU;YAC5C,OAAO,UAAU,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC;QAChE,CAAC;KACJ,CAAC,IAAI,CAAC,CAAC;IAER;;OAEG;IACc,2BAA2B,CAAU;IAEtD;;;;;;;;;;;;;;OAcG;IACH,YAAY,cAA8B,EAAE,MAAc,EAAE,qBAA0C,EAAE,0BAA0B,GAAG,KAAK;QACtI,KAAK,CAAC,cAAc,EAAE,WAAW,CAAC,gBAAgB,EAAE,MAAM,EAAE,qBAAqB,CAAC,CAAC;QAEnF,IAAI,CAAC,2BAA2B,GAAG,0BAA0B,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,IAAI,0BAA0B;QAC1B,OAAO,IAAI,CAAC,2BA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AAc,GAAG,IAAI,6BAA6B,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC;AAErH;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,6BAA6B,CAAC,eAAe,CAAC,GAAG,EAAE,EAAE,EAAE,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC"}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { type TransformerInput, type TransformerOutput } from "@aidc-toolkit/utility";
|
|
2
|
-
import { AbstractIdentifierCreator, type IdentifierCreator } from "./identifier-creator.js";
|
|
3
|
-
import { type LeaderType, type NumericIdentifierValidator } from "./numeric-identifier-validator.js";
|
|
4
|
-
import type { PrefixProvider } from "./prefix-provider";
|
|
5
|
-
/**
|
|
6
|
-
* Numeric identifier creator. Creates one or many numeric identifiers.
|
|
7
|
-
*/
|
|
8
|
-
export interface NumericIdentifierCreator extends NumericIdentifierValidator, IdentifierCreator {
|
|
9
|
-
/**
|
|
10
|
-
* Get the capacity (`10**referenceLength`).
|
|
11
|
-
*/
|
|
12
|
-
get capacity(): number;
|
|
13
|
-
/**
|
|
14
|
-
* Create identifier(s) with reference(s) based on numeric value(s). The value(s) is/are converted to
|
|
15
|
-
* references of the appropriate length using {@linkcode NUMERIC_CREATOR}.
|
|
16
|
-
*
|
|
17
|
-
* @template TTransformerInput
|
|
18
|
-
* Transformer input type.
|
|
19
|
-
*
|
|
20
|
-
* @param valueOrValues
|
|
21
|
-
* Numeric value(s).
|
|
22
|
-
*
|
|
23
|
-
* @param sparse
|
|
24
|
-
* If true, the value(s) are mapped to a sparse sequence resistant to discovery. Default is false.
|
|
25
|
-
*
|
|
26
|
-
* @returns
|
|
27
|
-
* Identifier(s).
|
|
28
|
-
*/
|
|
29
|
-
create: <TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput, sparse?: boolean) => TransformerOutput<TTransformerInput, string>;
|
|
30
|
-
/**
|
|
31
|
-
* Create all identifiers for the prefix from `0` to `capacity - 1`.
|
|
32
|
-
*
|
|
33
|
-
* The implementation creates the strings only as needed using an internal generator function. Although the result
|
|
34
|
-
* is equivalent to calling `creator.create(new Sequence(0, creator.capacity))`, this method is significantly
|
|
35
|
-
* faster.
|
|
36
|
-
*
|
|
37
|
-
* @returns
|
|
38
|
-
* All identifiers for the prefix.
|
|
39
|
-
*/
|
|
40
|
-
createAll: () => Iterable<string>;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Abstract numeric identifier creator. Implements common functionality for a numeric identifier
|
|
44
|
-
* creator.
|
|
45
|
-
*/
|
|
46
|
-
export declare abstract class AbstractNumericIdentifierCreator extends AbstractIdentifierCreator implements NumericIdentifierCreator {
|
|
47
|
-
/**
|
|
48
|
-
* Capacity.
|
|
49
|
-
*/
|
|
50
|
-
private _capacity;
|
|
51
|
-
/**
|
|
52
|
-
* Tweak for sparse creation.
|
|
53
|
-
*/
|
|
54
|
-
private _tweak;
|
|
55
|
-
/**
|
|
56
|
-
* Initialize the prefix provider. This method is in lieu of a constructor due to the mixin architecture.
|
|
57
|
-
*
|
|
58
|
-
* @param prefixProvider
|
|
59
|
-
* Prefix provider.
|
|
60
|
-
*
|
|
61
|
-
* @param prefix
|
|
62
|
-
* Prefix within prefix manager to use to calculate reference length.
|
|
63
|
-
*/
|
|
64
|
-
protected init(prefixProvider: PrefixProvider, prefix: string): void;
|
|
65
|
-
abstract get leaderType(): LeaderType;
|
|
66
|
-
/**
|
|
67
|
-
* @inheritDoc
|
|
68
|
-
*/
|
|
69
|
-
get capacity(): number;
|
|
70
|
-
/**
|
|
71
|
-
* Get the tweak for sparse creation.
|
|
72
|
-
*/
|
|
73
|
-
get tweak(): bigint;
|
|
74
|
-
/**
|
|
75
|
-
* Set the tweak for sparse creation.
|
|
76
|
-
*/
|
|
77
|
-
set tweak(value: bigint);
|
|
78
|
-
/**
|
|
79
|
-
* Build an identifier from a reference by merging it with the prefix and adding the check digit.
|
|
80
|
-
*
|
|
81
|
-
* @param reference
|
|
82
|
-
* Identifier reference.
|
|
83
|
-
*
|
|
84
|
-
* @returns
|
|
85
|
-
* Identifier.
|
|
86
|
-
*/
|
|
87
|
-
private buildIdentifier;
|
|
88
|
-
/**
|
|
89
|
-
* @inheritDoc
|
|
90
|
-
*/
|
|
91
|
-
create<TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
|
|
92
|
-
/**
|
|
93
|
-
* Create all identifiers from a partial identifier. Call is recursive until remaining reference
|
|
94
|
-
* length is 0.
|
|
95
|
-
*
|
|
96
|
-
* @param partialIdentifier
|
|
97
|
-
* Partial identifier. Initial value is `this.prefix`.
|
|
98
|
-
*
|
|
99
|
-
* @param remainingReferenceLength
|
|
100
|
-
* Remaining reference length. Initial value is `this.referenceLength`.
|
|
101
|
-
*
|
|
102
|
-
* @param extensionWeight
|
|
103
|
-
* If this value is not zero, the identifier has an extension digit, this call is setting it, and this value
|
|
104
|
-
* is applied to the calculation of the check digit.
|
|
105
|
-
*
|
|
106
|
-
* @param weight
|
|
107
|
-
* If the extension weight is zero, this value is applied to the calculation of the check digit.
|
|
108
|
-
*
|
|
109
|
-
* @param partialCheckDigitSum
|
|
110
|
-
* Partial check digit sum for the partial identifier.
|
|
111
|
-
*
|
|
112
|
-
* @yields
|
|
113
|
-
* Identifier.
|
|
114
|
-
*/
|
|
115
|
-
private static createAllPartial;
|
|
116
|
-
/**
|
|
117
|
-
* @inheritDoc
|
|
118
|
-
*/
|
|
119
|
-
createAll(): Iterable<string>;
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=numeric-identifier-creator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"numeric-identifier-creator.d.ts","sourceRoot":"","sources":["../src/numeric-identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAC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