@aidc-toolkit/gs1 0.9.20-beta → 1.0.22-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/character-set.d.ts +4 -4
  2. package/dist/character-set.d.ts.map +1 -1
  3. package/dist/character-set.js +7 -7
  4. package/dist/character-set.js.map +1 -1
  5. package/dist/gtin-creator.d.ts +68 -0
  6. package/dist/gtin-creator.d.ts.map +1 -0
  7. package/dist/gtin-creator.js +158 -0
  8. package/dist/gtin-creator.js.map +1 -0
  9. package/dist/gtin-validator.d.ts +202 -0
  10. package/dist/gtin-validator.d.ts.map +1 -0
  11. package/dist/gtin-validator.js +470 -0
  12. package/dist/gtin-validator.js.map +1 -0
  13. package/dist/identifier-creator.d.ts +72 -0
  14. package/dist/identifier-creator.d.ts.map +1 -0
  15. package/dist/identifier-creator.js +50 -0
  16. package/dist/identifier-creator.js.map +1 -0
  17. package/dist/identifier-type.d.ts +58 -0
  18. package/dist/identifier-type.d.ts.map +1 -0
  19. package/dist/identifier-type.js +54 -0
  20. package/dist/identifier-type.js.map +1 -0
  21. package/dist/identifier-validator.d.ts +174 -0
  22. package/dist/identifier-validator.d.ts.map +1 -0
  23. package/dist/identifier-validator.js +145 -0
  24. package/dist/identifier-validator.js.map +1 -0
  25. package/dist/index.d.ts +16 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +16 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/locale/en/locale-strings.d.ts +3 -3
  30. package/dist/locale/en/locale-strings.js +3 -3
  31. package/dist/locale/en/locale-strings.js.map +1 -1
  32. package/dist/locale/fr/locale-strings.d.ts +3 -3
  33. package/dist/locale/fr/locale-strings.js +3 -3
  34. package/dist/locale/fr/locale-strings.js.map +1 -1
  35. package/dist/non-gtin-numeric-identifier-creator.d.ts +30 -0
  36. package/dist/non-gtin-numeric-identifier-creator.d.ts.map +1 -0
  37. package/dist/non-gtin-numeric-identifier-creator.js +30 -0
  38. package/dist/non-gtin-numeric-identifier-creator.js.map +1 -0
  39. package/dist/non-gtin-numeric-identifier-validator.d.ts +41 -0
  40. package/dist/non-gtin-numeric-identifier-validator.d.ts.map +1 -0
  41. package/dist/non-gtin-numeric-identifier-validator.js +40 -0
  42. package/dist/non-gtin-numeric-identifier-validator.js.map +1 -0
  43. package/dist/non-numeric-identifier-creator.d.ts +55 -0
  44. package/dist/non-numeric-identifier-creator.d.ts.map +1 -0
  45. package/dist/non-numeric-identifier-creator.js +93 -0
  46. package/dist/non-numeric-identifier-creator.js.map +1 -0
  47. package/dist/non-numeric-identifier-validator.d.ts +78 -0
  48. package/dist/non-numeric-identifier-validator.d.ts.map +1 -0
  49. package/dist/non-numeric-identifier-validator.js +95 -0
  50. package/dist/non-numeric-identifier-validator.js.map +1 -0
  51. package/dist/numeric-identifier-creator.d.ts +121 -0
  52. package/dist/numeric-identifier-creator.d.ts.map +1 -0
  53. package/dist/numeric-identifier-creator.js +135 -0
  54. package/dist/numeric-identifier-creator.js.map +1 -0
  55. package/dist/numeric-identifier-validator.d.ts +76 -0
  56. package/dist/numeric-identifier-validator.d.ts.map +1 -0
  57. package/dist/numeric-identifier-validator.js +84 -0
  58. package/dist/numeric-identifier-validator.js.map +1 -0
  59. package/dist/prefix-manager.d.ts +224 -0
  60. package/dist/prefix-manager.d.ts.map +1 -0
  61. package/dist/prefix-manager.js +369 -0
  62. package/dist/prefix-manager.js.map +1 -0
  63. package/dist/prefix-provider.d.ts +27 -0
  64. package/dist/prefix-provider.d.ts.map +1 -0
  65. package/dist/prefix-provider.js +2 -0
  66. package/dist/prefix-provider.js.map +1 -0
  67. package/dist/prefix-type.d.ts +22 -0
  68. package/dist/prefix-type.d.ts.map +1 -0
  69. package/dist/prefix-type.js +18 -0
  70. package/dist/prefix-type.js.map +1 -0
  71. package/dist/prefix-validator.d.ts +58 -0
  72. package/dist/prefix-validator.d.ts.map +1 -0
  73. package/dist/prefix-validator.js +154 -0
  74. package/dist/prefix-validator.js.map +1 -0
  75. package/dist/serializable-numeric-identifier-creator.d.ts +86 -0
  76. package/dist/serializable-numeric-identifier-creator.d.ts.map +1 -0
  77. package/dist/serializable-numeric-identifier-creator.js +116 -0
  78. package/dist/serializable-numeric-identifier-creator.js.map +1 -0
  79. package/dist/serializable-numeric-identifier-validator.d.ts +79 -0
  80. package/dist/serializable-numeric-identifier-validator.d.ts.map +1 -0
  81. package/dist/serializable-numeric-identifier-validator.js +99 -0
  82. package/dist/serializable-numeric-identifier-validator.js.map +1 -0
  83. package/gs1.iml +4 -1
  84. package/package.json +2 -3
  85. package/src/character-set.ts +7 -7
  86. package/src/gtin-creator.ts +195 -0
  87. package/src/gtin-validator.ts +564 -0
  88. package/src/identifier-creator.ts +97 -0
  89. package/src/identifier-type.ts +69 -0
  90. package/src/identifier-validator.ts +235 -0
  91. package/src/index.ts +16 -1
  92. package/src/locale/en/locale-strings.ts +3 -3
  93. package/src/locale/fr/locale-strings.ts +3 -3
  94. package/src/non-gtin-numeric-identifier-creator.ts +33 -0
  95. package/src/non-gtin-numeric-identifier-validator.ts +54 -0
  96. package/src/non-numeric-identifier-creator.ts +111 -0
  97. package/src/non-numeric-identifier-validator.ts +128 -0
  98. package/src/numeric-identifier-creator.ts +200 -0
  99. package/src/numeric-identifier-validator.ts +128 -0
  100. package/src/prefix-manager.ts +446 -0
  101. package/src/prefix-provider.ts +31 -0
  102. package/src/prefix-type.ts +24 -0
  103. package/src/prefix-validator.ts +191 -0
  104. package/src/serializable-numeric-identifier-creator.ts +128 -0
  105. package/src/serializable-numeric-identifier-validator.ts +124 -0
  106. package/test/check.test.ts +0 -4
  107. package/test/creator.test.ts +30 -0
  108. package/test/gtin-creator.ts +239 -0
  109. package/test/gtin-validator.test.ts +149 -0
  110. package/test/identifier-creator.ts +84 -0
  111. package/test/identifier-validator.ts +8 -0
  112. package/test/non-gtin-numeric-identifier-creator.ts +98 -0
  113. package/test/non-gtin-numeric-identifier-validator.ts +6 -0
  114. package/test/non-numeric-identifier-validator.ts +24 -0
  115. package/test/numeric-identifier-creator.ts +132 -0
  116. package/test/numeric-identifier-validator.ts +23 -0
  117. package/test/prefix-manager.test.ts +112 -0
  118. package/test/serializable-numeric-identifier-creator.ts +56 -0
  119. package/test/serializable-numeric-identifier-validator.ts +24 -0
  120. package/test/setup.ts +4 -0
  121. package/test/sparse.test.ts +56 -0
  122. package/test/utility.ts +22 -0
  123. package/test/validator.test.ts +52 -0
  124. package/test/variable-measure-rcn.test.ts +201 -0
  125. package/vitest.config.ts +7 -0
  126. package/dist/idkey.d.ts +0 -1346
  127. package/dist/idkey.d.ts.map +0 -1
  128. package/dist/idkey.js +0 -2024
  129. package/dist/idkey.js.map +0 -1
  130. package/src/idkey.ts +0 -2532
  131. package/test/idkey.test.ts +0 -1247
@@ -1,22 +1,22 @@
1
1
  import { CharacterSetCreator, type CharacterSetValidator } from "@aidc-toolkit/utility";
2
2
  /**
3
3
  * GS1 AI encodable character set 82 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
4
- * General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
4
+ * General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
5
5
  */
6
6
  export declare const AI82_CREATOR: CharacterSetCreator;
7
7
  /**
8
8
  * GS1 AI encodable character set 82 validator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs |
9
- * GS1 General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
9
+ * GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
10
10
  */
11
11
  export declare const AI82_VALIDATOR: CharacterSetValidator;
12
12
  /**
13
13
  * GS1 AI encodable character set 39 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
14
- * General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
14
+ * General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
15
15
  */
16
16
  export declare const AI39_CREATOR: CharacterSetCreator;
17
17
  /**
18
18
  * GS1 AI encodable character set 39 validator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs |
19
- * GS1 General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
19
+ * GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
20
20
  */
21
21
  export declare const AI39_VALIDATOR: CharacterSetValidator;
22
22
  //# sourceMappingURL=character-set.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"character-set.d.ts","sourceRoot":"","sources":["../src/character-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,qBAAqB,EAAa,MAAM,uBAAuB,CAAC;AAEnG;;;GAGG;AACH,eAAO,MAAM,YAAY,qBASD,CAAC;AAEzB;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAmB,qBAAqB,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,YAAY,qBAKD,CAAC;AAEzB;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAmB,qBAAqB,CAAC"}
1
+ {"version":3,"file":"character-set.d.ts","sourceRoot":"","sources":["../src/character-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,qBAAqB,EAAc,MAAM,uBAAuB,CAAC;AAEpG;;;GAGG;AACH,eAAO,MAAM,YAAY,qBASA,CAAC;AAE1B;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAmB,qBAAqB,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,YAAY,qBAKA,CAAC;AAE1B;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAmB,qBAAqB,CAAC"}
@@ -1,7 +1,7 @@
1
- import { CharacterSetCreator, Exclusion } from "@aidc-toolkit/utility";
1
+ import { CharacterSetCreator, Exclusions } from "@aidc-toolkit/utility";
2
2
  /**
3
3
  * GS1 AI encodable character set 82 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
4
- * General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
4
+ * General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
5
5
  */
6
6
  export const AI82_CREATOR = new CharacterSetCreator([
7
7
  "!", "\"", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/",
@@ -12,25 +12,25 @@ export const AI82_CREATOR = new CharacterSetCreator([
12
12
  "_",
13
13
  "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
14
14
  "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
15
- ], Exclusion.AllNumeric);
15
+ ], Exclusions.AllNumeric);
16
16
  /**
17
17
  * GS1 AI encodable character set 82 validator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs |
18
- * GS1 General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
18
+ * GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
19
19
  */
20
20
  export const AI82_VALIDATOR = AI82_CREATOR;
21
21
  /**
22
22
  * GS1 AI encodable character set 39 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
23
- * General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
23
+ * General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
24
24
  */
25
25
  export const AI39_CREATOR = new CharacterSetCreator([
26
26
  "#", "-", "/",
27
27
  "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
28
28
  "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
29
29
  "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
30
- ], Exclusion.AllNumeric);
30
+ ], Exclusions.AllNumeric);
31
31
  /**
32
32
  * GS1 AI encodable character set 39 validator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs |
33
- * GS1 General Specifications}. Supports {@linkcode Exclusion.AllNumeric}.
33
+ * GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
34
34
  */
35
35
  export const AI39_VALIDATOR = AI39_CREATOR;
36
36
  //# sourceMappingURL=character-set.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"character-set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AAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;CAClE,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,YAAqC,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { type TransformerInput, type TransformerOutput } from "@aidc-toolkit/utility";
2
+ import { type GTINType, GTINValidator } from "./gtin-validator.js";
3
+ import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
4
+ import type { PrefixProvider } from "./prefix-provider";
5
+ declare const GTINCreator_base: import("ts-mixer/dist/types/types.js").Class<any[], GTINValidator & AbstractNumericIdentifierCreator, typeof GTINValidator & typeof AbstractNumericIdentifierCreator>;
6
+ /**
7
+ * GTIN creator. Applicable to GTIN-13, GTIN-12, and GTIN-8 types; no applicable to GTIN-14 type.
8
+ */
9
+ export declare class GTINCreator extends GTINCreator_base {
10
+ /**
11
+ * Validation parameters for required indicator digit.
12
+ */
13
+ private static readonly REQUIRED_INDICATOR_DIGIT_VALIDATION;
14
+ /**
15
+ * Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix
16
+ * provider type.
17
+ *
18
+ * @param prefixProvider
19
+ * Prefix provider.
20
+ *
21
+ * @param gtinType
22
+ * GTIN type.
23
+ */
24
+ constructor(prefixProvider: PrefixProvider, gtinType: GTINType);
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ get prefix(): string;
29
+ /**
30
+ * Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
31
+ * converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
32
+ *
33
+ * @template TTransformerInput
34
+ * Transformer input type.
35
+ *
36
+ * @param indicatorDigit
37
+ * Indicator digit.
38
+ *
39
+ * @param valueOrValues
40
+ * Numeric value(s).
41
+ *
42
+ * @param sparse
43
+ * If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
44
+ *
45
+ * @returns
46
+ * GTIN-14(s).
47
+ */
48
+ createGTIN14<TTransformerInput extends TransformerInput<number | bigint>>(indicatorDigit: string, valueOrValues: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
49
+ /**
50
+ * Create a Restricted Circulation Number (RCN) using a variable measure trade item format. See {@linkcode
51
+ * GTINValidator.parseVariableMeasureRCN} for format details.
52
+ *
53
+ * @param format
54
+ * Format.
55
+ *
56
+ * @param itemReference
57
+ * Item reference.
58
+ *
59
+ * @param priceOrWeight
60
+ * Price or weight (whole number only).
61
+ *
62
+ * @returns
63
+ * RCN-12 or RCN-13.
64
+ */
65
+ static createVariableMeasureRCN(format: string, itemReference: number, priceOrWeight: number): string;
66
+ }
67
+ export {};
68
+ //# sourceMappingURL=gtin-creator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gtin-creator.d.ts","sourceRoot":"","sources":["../src/gtin-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACzB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,KAAK,QAAQ,EAAa,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9E,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;;AAExD;;GAEG;AACH,qBAAa,WAAY,SAAQ,gBAAsD;IACnF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mCAAmC,CAIzD;IAEF;;;;;;;;;OASG;gBACS,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ;IAM9D;;OAEG;IACH,IAAa,MAAM,IAAI,MAAM,CAE5B;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAQ,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,CAAC;IAUjM;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM;CAmGxG"}
@@ -0,0 +1,158 @@
1
+ import { Exclusions, NUMERIC_CREATOR } from "@aidc-toolkit/utility";
2
+ import { Mixin } from "ts-mixer";
3
+ import { checkDigit, priceOrWeightCheckDigit } from "./check.js";
4
+ import { GTINTypes, GTINValidator } from "./gtin-validator.js";
5
+ import { i18nextGS1 } from "./locale/i18n.js";
6
+ import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
7
+ /**
8
+ * GTIN creator. Applicable to GTIN-13, GTIN-12, and GTIN-8 types; no applicable to GTIN-14 type.
9
+ */
10
+ export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentifierCreator) {
11
+ /**
12
+ * Validation parameters for required indicator digit.
13
+ */
14
+ static REQUIRED_INDICATOR_DIGIT_VALIDATION = {
15
+ minimumLength: 1,
16
+ maximumLength: 1,
17
+ component: () => i18nextGS1.t("Identifier.indicatorDigit")
18
+ };
19
+ /**
20
+ * Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix
21
+ * provider type.
22
+ *
23
+ * @param prefixProvider
24
+ * Prefix provider.
25
+ *
26
+ * @param gtinType
27
+ * GTIN type.
28
+ */
29
+ constructor(prefixProvider, gtinType) {
30
+ super(gtinType);
31
+ this.init(prefixProvider, prefixProvider.prefix);
32
+ }
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ get prefix() {
37
+ return this.prefixProvider.prefix;
38
+ }
39
+ /**
40
+ * Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
41
+ * converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
42
+ *
43
+ * @template TTransformerInput
44
+ * Transformer input type.
45
+ *
46
+ * @param indicatorDigit
47
+ * Indicator digit.
48
+ *
49
+ * @param valueOrValues
50
+ * Numeric value(s).
51
+ *
52
+ * @param sparse
53
+ * If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
54
+ *
55
+ * @returns
56
+ * GTIN-14(s).
57
+ */
58
+ createGTIN14(indicatorDigit, valueOrValues, sparse = false) {
59
+ NUMERIC_CREATOR.validate(indicatorDigit, GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
60
+ return NUMERIC_CREATOR.create(GTINTypes.GTIN13 - this.prefixProvider.gs1CompanyPrefix.length - 1, valueOrValues, Exclusions.None, sparse ? this.tweak : undefined, (reference) => {
61
+ const partialIdentifier = indicatorDigit + this.prefixProvider.gs1CompanyPrefix + reference;
62
+ return partialIdentifier + checkDigit(partialIdentifier);
63
+ });
64
+ }
65
+ /**
66
+ * Create a Restricted Circulation Number (RCN) using a variable measure trade item format. See {@linkcode
67
+ * GTINValidator.parseVariableMeasureRCN} for format details.
68
+ *
69
+ * @param format
70
+ * Format.
71
+ *
72
+ * @param itemReference
73
+ * Item reference.
74
+ *
75
+ * @param priceOrWeight
76
+ * Price or weight (whole number only).
77
+ *
78
+ * @returns
79
+ * RCN-12 or RCN-13.
80
+ */
81
+ static createVariableMeasureRCN(format, itemReference, priceOrWeight) {
82
+ const formatLength = format.length;
83
+ let validFormat = formatLength === 12 || formatLength === 13;
84
+ let rcnPrefix = "";
85
+ let buildingItemReference = false;
86
+ let itemReferenceString = "";
87
+ let itemReferenceLength = 0;
88
+ let buildingPriceOrWeight = false;
89
+ let priceOrWeightString = "";
90
+ let priceOrWeightLength = 0;
91
+ let calculatePriceOrWeightCheckDigit = false;
92
+ // RCN may be built in almost any order, so defer to builders that will be in ordered array.
93
+ const rcnPrefixBuilder = (partialRCN) => partialRCN + rcnPrefix;
94
+ const itemReferenceBuilder = (partialRCN) => partialRCN + itemReferenceString;
95
+ const priceOrWeightBuilder = (partialRCN) => partialRCN + priceOrWeightString;
96
+ const priceOrWeightCheckDigitBuilder = (partialRCN) => partialRCN + priceOrWeightCheckDigit(priceOrWeightString);
97
+ const checkDigitBuilder = (partialRCN) => partialRCN + checkDigit(partialRCN);
98
+ const rcnBuilders = [rcnPrefixBuilder];
99
+ for (let index = 0; validFormat && index < formatLength; index++) {
100
+ const formatChar = format.charAt(index);
101
+ if (index === 0) {
102
+ validFormat = formatChar === "2";
103
+ rcnPrefix = formatChar;
104
+ }
105
+ else if (formatLength === 13 && index === 1) {
106
+ validFormat = NUMERIC_CREATOR.characterIndex(formatChar) !== undefined;
107
+ rcnPrefix += formatChar;
108
+ }
109
+ else if (index === formatLength - 1) {
110
+ validFormat = formatChar === "C";
111
+ }
112
+ else {
113
+ switch (formatChar) {
114
+ case "I":
115
+ if (!buildingItemReference) {
116
+ // Item reference can't appear more than once.
117
+ validFormat = itemReferenceLength === 0;
118
+ buildingItemReference = true;
119
+ buildingPriceOrWeight = false;
120
+ rcnBuilders.push(itemReferenceBuilder);
121
+ }
122
+ itemReferenceLength++;
123
+ break;
124
+ case "P":
125
+ if (!buildingPriceOrWeight) {
126
+ // Price or weight can't appear more than once.
127
+ validFormat = priceOrWeightLength === 0;
128
+ buildingPriceOrWeight = true;
129
+ buildingItemReference = false;
130
+ rcnBuilders.push(priceOrWeightBuilder);
131
+ }
132
+ priceOrWeightLength++;
133
+ break;
134
+ case "V":
135
+ // Price or weight check digit can't appear more than once.
136
+ validFormat = !calculatePriceOrWeightCheckDigit;
137
+ buildingItemReference = false;
138
+ buildingPriceOrWeight = false;
139
+ calculatePriceOrWeightCheckDigit = true;
140
+ rcnBuilders.push(priceOrWeightCheckDigitBuilder);
141
+ break;
142
+ default:
143
+ validFormat = false;
144
+ break;
145
+ }
146
+ }
147
+ }
148
+ validFormat &&= itemReferenceLength !== 0 && priceOrWeightLength !== 0;
149
+ if (!validFormat) {
150
+ throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasureRCNFormat"));
151
+ }
152
+ itemReferenceString = NUMERIC_CREATOR.create(itemReferenceLength, itemReference);
153
+ priceOrWeightString = NUMERIC_CREATOR.create(priceOrWeightLength, priceOrWeight);
154
+ rcnBuilders.push(checkDigitBuilder);
155
+ return rcnBuilders.reduce((partialRCN, rcnBuilder) => rcnBuilder(partialRCN), "");
156
+ }
157
+ }
158
+ //# sourceMappingURL=gtin-creator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gtin-creator.js","sourceRoot":"","sources":["../src/gtin-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,UAAU,EACV,eAAe,EAGlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAiB,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AAGnF;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,aAAa,EAAE,gCAAgC,CAAC;IACnF;;OAEG;IACK,MAAM,CAAU,mCAAmC,GAA2B;QAClF,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,CAAC;QAChB,SAAS,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,2BAA2B,CAAC;KAC7D,CAAC;IAEF;;;;;;;;;OASG;IACH,YAAY,cAA8B,EAAE,QAAkB;QAC1D,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,IAAa,MAAM;QACf,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;IACtC,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,YA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AC,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC"}
@@ -0,0 +1,202 @@
1
+ import { AbstractNumericIdentifierValidator } from "./numeric-identifier-validator.js";
2
+ import { type PrefixType } from "./prefix-type.js";
3
+ /**
4
+ * GTIN types. The numeric values are equal to the lengths of the GTIN types.
5
+ */
6
+ export declare const GTINTypes: {
7
+ /**
8
+ * GTIN-13.
9
+ */
10
+ readonly GTIN13: 13;
11
+ /**
12
+ * GTIN-12.
13
+ */
14
+ readonly GTIN12: 12;
15
+ /**
16
+ * GTIN-8.
17
+ */
18
+ readonly GTIN8: 8;
19
+ /**
20
+ * GTIN-14.
21
+ */
22
+ readonly GTIN14: 14;
23
+ };
24
+ /**
25
+ * GTIN type.
26
+ */
27
+ export type GTINType = typeof GTINTypes[keyof typeof GTINTypes];
28
+ /**
29
+ * Levels at which GTIN is to be validated.
30
+ */
31
+ export declare const GTINLevels: {
32
+ /**
33
+ * Any level (level is ignored).
34
+ */
35
+ readonly Any: 0;
36
+ /**
37
+ * Retail consumer trade item level, supporting GTIN-13, GTIN-12 (optionally zero-suppressed), and GTIN-8.
38
+ */
39
+ readonly RetailConsumer: 1;
40
+ /**
41
+ * Other than retail consumer trade item level, supporting GTIN-13, GTIN-12 (not zero-suppressed), and GTIN-14.
42
+ */
43
+ readonly OtherThanRetailConsumer: 2;
44
+ };
45
+ /**
46
+ * GTIN level.
47
+ */
48
+ export type GTINLevel = typeof GTINLevels[keyof typeof GTINLevels];
49
+ /**
50
+ * Restricted Circulation Number reference.
51
+ */
52
+ export interface RCNReference {
53
+ /**
54
+ * Item reference.
55
+ */
56
+ itemReference: number;
57
+ /**
58
+ * Price or weight (whole number only).
59
+ */
60
+ priceOrWeight: number;
61
+ }
62
+ /**
63
+ * GTIN validator.
64
+ */
65
+ export declare class GTINValidator extends AbstractNumericIdentifierValidator {
66
+ /**
67
+ * Validation parameters for optional indicator digit.
68
+ */
69
+ private static readonly OPTIONAL_INDICATOR_DIGIT_VALIDATION;
70
+ /**
71
+ * Validation parameters for zero-suppressed GTIN-12.
72
+ */
73
+ private static readonly ZERO_SUPPRESSED_GTIN12_VALIDATION;
74
+ /**
75
+ * Constructor.
76
+ *
77
+ * @param gtinType
78
+ * GTIN type.
79
+ */
80
+ constructor(gtinType: GTINType);
81
+ /**
82
+ * @inheritDoc
83
+ */
84
+ get gtinType(): GTINType;
85
+ /**
86
+ * @inheritDoc
87
+ */
88
+ protected validatePrefix(partialIdentifier: string, positionOffset?: number): void;
89
+ /**
90
+ * Zero suppress a GTIN-12.
91
+ *
92
+ * @param gtin12
93
+ * GTIN-12.
94
+ *
95
+ * @returns
96
+ * Zero-suppressed GTIN-12.
97
+ */
98
+ static zeroSuppress(gtin12: string): string;
99
+ /**
100
+ * Zero expand a zero-suppressed GTIN-12.
101
+ *
102
+ * @param zeroSuppressedGTIN12
103
+ * Zero-suppressed GTIN-12.
104
+ *
105
+ * @returns
106
+ * GTIN-12.
107
+ */
108
+ static zeroExpand(zeroSuppressedGTIN12: string): string;
109
+ /**
110
+ * Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
111
+ *
112
+ * @param indicatorDigit
113
+ * Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
114
+ *
115
+ * @param gtin
116
+ * GTIN.
117
+ *
118
+ * @returns
119
+ * GTIN-14.
120
+ */
121
+ static convertToGTIN14(indicatorDigit: string, gtin: string): string;
122
+ /**
123
+ * Normalize a GTIN of any length.
124
+ * - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
125
+ * - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
126
+ * - A GTIN-14 that starts with one zero is normalized to GTIN-13.
127
+ * - Otherwise, the GTIN is unchanged.
128
+ *
129
+ * @param gtin
130
+ * GTIN.
131
+ *
132
+ * @returns
133
+ * Normalized GTIN.
134
+ */
135
+ static normalize(gtin: string): string;
136
+ /**
137
+ * Validate any GTIN, optionally against a level.
138
+ *
139
+ * @param gtin
140
+ * GTIN.
141
+ *
142
+ * @param gtinLevel
143
+ * Level at which GTIN is to be validated.
144
+ */
145
+ static validateAny(gtin: string, gtinLevel?: GTINLevel): void;
146
+ /**
147
+ * Validate a GTIN-14.
148
+ *
149
+ * @param gtin14
150
+ * GTIN-14.
151
+ */
152
+ static validateGTIN14(gtin14: string): void;
153
+ /**
154
+ * Parse a Restricted Circulation Number (RCN) using a variable measure trade item format. The format is a 12- or
155
+ * 13-character string (for RCN-12 or RCN-13 respectively), containing the following:
156
+ *
157
+ * - '2' - The first character of the RCN.
158
+ * - '0'-'9' - The second character of the RCN (RCN-13 only).
159
+ * - 'I' - One or more, in sequence, for the item reference.
160
+ * - 'P' - One or more, in sequence, for the price or weight.
161
+ * - 'V' - Zero or one, for the price or weight check digit.
162
+ * - 'C' - The check digit of the entire RCN.
163
+ *
164
+ * The 'I', 'P', and 'V' formats may be in any order.
165
+ *
166
+ * Some examples:
167
+ *
168
+ * - 2IIIIIVPPPPC - RCN-12 with a five-digit item reference, a price or weight check digit, and a four-digit price
169
+ * or weight.
170
+ * - 23IIIIVPPPPPC - RCN-13 with a four-digit item reference, a price or weight check digit, and a five-digit price
171
+ * or weight.
172
+ * - 2IIIIIIPPPPC - RCN-12 with a six-digit item reference and a four-digit price or eight.
173
+ * - 29IIIIIPPPPPC - RCN-13 with a five-digit item reference and a five-digit price or weight.
174
+ *
175
+ * @param format
176
+ * Format.
177
+ *
178
+ * @param rcn
179
+ * RCN.
180
+ *
181
+ * @returns
182
+ * RCN reference.
183
+ */
184
+ static parseVariableMeasureRCN(format: string, rcn: string): RCNReference;
185
+ }
186
+ /**
187
+ * GTIN-13 validator.
188
+ */
189
+ export declare const GTIN13_VALIDATOR: GTINValidator;
190
+ /**
191
+ * GTIN-12 validator.
192
+ */
193
+ export declare const GTIN12_VALIDATOR: GTINValidator;
194
+ /**
195
+ * GTIN-8 validator.
196
+ */
197
+ export declare const GTIN8_VALIDATOR: GTINValidator;
198
+ /**
199
+ * GTIN validators indexed by prefix type.
200
+ */
201
+ export declare const GTIN_VALIDATORS: Record<PrefixType, GTINValidator>;
202
+ //# sourceMappingURL=gtin-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gtin-validator.d.ts","sourceRoot":"","sources":["../src/gtin-validator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kCAAkC,EAAe,MAAM,mCAAmC,CAAC;AACpG,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,kBAAkB,CAAC;AAGhE;;GAEG;AACH,eAAO,MAAM,SAAS;IAClB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEG,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,SAAS,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,UAAU;IACnB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEG,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,kCAAkC;IACjE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mCAAmC,CAIzD;IAEF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iCAAiC,CAGvD;IAEF;;;;;OAKG;gBACS,QAAQ,EAAE,QAAQ;IAyB9B;;OAEG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAGvB;IAED;;OAEG;cACgB,cAAc,CAAC,iBAAiB,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI;IAK3F;;;;;;;;OAQG;IACH,MAAM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