@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.
Files changed (133) hide show
  1. package/dist/index.cjs +4624 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +1588 -0
  4. package/dist/index.d.ts +1588 -36
  5. package/dist/index.js +4541 -19
  6. package/dist/index.js.map +1 -1
  7. package/package.json +4 -8
  8. package/src/character-set.ts +16 -1
  9. package/src/check.ts +2 -2
  10. package/src/gtin-creator.ts +4 -4
  11. package/src/gtin-validator.ts +6 -6
  12. package/src/identifier-creator.ts +3 -3
  13. package/src/identifier-validator.ts +4 -4
  14. package/src/index.ts +19 -19
  15. package/src/locale/en/{locale-strings.ts → locale-resources.ts} +1 -1
  16. package/src/locale/fr/{locale-strings.ts → locale-resources.ts} +2 -2
  17. package/src/locale/i18n.ts +6 -8
  18. package/src/locale/i18next.d.ts +4 -4
  19. package/src/non-gtin-numeric-identifier-creator.ts +4 -4
  20. package/src/non-gtin-numeric-identifier-validator.ts +3 -3
  21. package/src/non-numeric-identifier-creator.ts +6 -6
  22. package/src/non-numeric-identifier-validator.ts +6 -6
  23. package/src/numeric-identifier-creator.ts +3 -3
  24. package/src/numeric-identifier-validator.ts +5 -5
  25. package/src/prefix-manager.ts +36 -35
  26. package/src/prefix-provider.ts +1 -1
  27. package/src/prefix-validator.ts +2 -2
  28. package/src/serializable-numeric-identifier-creator.ts +4 -4
  29. package/src/serializable-numeric-identifier-validator.ts +5 -5
  30. package/test/creator.test.ts +3 -3
  31. package/test/gtin-creator.ts +1 -1
  32. package/test/gtin-validator.test.ts +1 -1
  33. package/test/identifier-creator.ts +4 -4
  34. package/test/non-gtin-numeric-identifier-creator.ts +1 -1
  35. package/test/non-gtin-numeric-identifier-validator.ts +1 -1
  36. package/test/non-numeric-identifier-validator.ts +2 -2
  37. package/test/numeric-identifier-creator.ts +1 -1
  38. package/test/numeric-identifier-validator.ts +1 -1
  39. package/test/prefix-manager.test.ts +1 -1
  40. package/test/serializable-numeric-identifier-creator.ts +1 -1
  41. package/test/serializable-numeric-identifier-validator.ts +2 -2
  42. package/test/validator.test.ts +4 -4
  43. package/tsup.config.ts +3 -0
  44. package/typedoc.json +1 -3
  45. package/dist/character-set.d.ts +0 -22
  46. package/dist/character-set.d.ts.map +0 -1
  47. package/dist/character-set.js +0 -36
  48. package/dist/character-set.js.map +0 -1
  49. package/dist/check.d.ts +0 -81
  50. package/dist/check.d.ts.map +0 -1
  51. package/dist/check.js +0 -218
  52. package/dist/check.js.map +0 -1
  53. package/dist/gtin-creator.d.ts +0 -68
  54. package/dist/gtin-creator.d.ts.map +0 -1
  55. package/dist/gtin-creator.js +0 -158
  56. package/dist/gtin-creator.js.map +0 -1
  57. package/dist/gtin-validator.d.ts +0 -202
  58. package/dist/gtin-validator.d.ts.map +0 -1
  59. package/dist/gtin-validator.js +0 -470
  60. package/dist/gtin-validator.js.map +0 -1
  61. package/dist/identifier-creator.d.ts +0 -72
  62. package/dist/identifier-creator.d.ts.map +0 -1
  63. package/dist/identifier-creator.js +0 -50
  64. package/dist/identifier-creator.js.map +0 -1
  65. package/dist/identifier-type.d.ts +0 -58
  66. package/dist/identifier-type.d.ts.map +0 -1
  67. package/dist/identifier-type.js +0 -54
  68. package/dist/identifier-type.js.map +0 -1
  69. package/dist/identifier-validator.d.ts +0 -174
  70. package/dist/identifier-validator.d.ts.map +0 -1
  71. package/dist/identifier-validator.js +0 -145
  72. package/dist/identifier-validator.js.map +0 -1
  73. package/dist/index.d.ts.map +0 -1
  74. package/dist/locale/en/locale-strings.d.ts +0 -42
  75. package/dist/locale/en/locale-strings.d.ts.map +0 -1
  76. package/dist/locale/en/locale-strings.js +0 -42
  77. package/dist/locale/en/locale-strings.js.map +0 -1
  78. package/dist/locale/fr/locale-strings.d.ts +0 -42
  79. package/dist/locale/fr/locale-strings.d.ts.map +0 -1
  80. package/dist/locale/fr/locale-strings.js +0 -42
  81. package/dist/locale/fr/locale-strings.js.map +0 -1
  82. package/dist/locale/i18n.d.ts +0 -27
  83. package/dist/locale/i18n.d.ts.map +0 -1
  84. package/dist/locale/i18n.js +0 -37
  85. package/dist/locale/i18n.js.map +0 -1
  86. package/dist/non-gtin-numeric-identifier-creator.d.ts +0 -30
  87. package/dist/non-gtin-numeric-identifier-creator.d.ts.map +0 -1
  88. package/dist/non-gtin-numeric-identifier-creator.js +0 -30
  89. package/dist/non-gtin-numeric-identifier-creator.js.map +0 -1
  90. package/dist/non-gtin-numeric-identifier-validator.d.ts +0 -41
  91. package/dist/non-gtin-numeric-identifier-validator.d.ts.map +0 -1
  92. package/dist/non-gtin-numeric-identifier-validator.js +0 -40
  93. package/dist/non-gtin-numeric-identifier-validator.js.map +0 -1
  94. package/dist/non-numeric-identifier-creator.d.ts +0 -55
  95. package/dist/non-numeric-identifier-creator.d.ts.map +0 -1
  96. package/dist/non-numeric-identifier-creator.js +0 -93
  97. package/dist/non-numeric-identifier-creator.js.map +0 -1
  98. package/dist/non-numeric-identifier-validator.d.ts +0 -78
  99. package/dist/non-numeric-identifier-validator.d.ts.map +0 -1
  100. package/dist/non-numeric-identifier-validator.js +0 -95
  101. package/dist/non-numeric-identifier-validator.js.map +0 -1
  102. package/dist/numeric-identifier-creator.d.ts +0 -121
  103. package/dist/numeric-identifier-creator.d.ts.map +0 -1
  104. package/dist/numeric-identifier-creator.js +0 -135
  105. package/dist/numeric-identifier-creator.js.map +0 -1
  106. package/dist/numeric-identifier-validator.d.ts +0 -76
  107. package/dist/numeric-identifier-validator.d.ts.map +0 -1
  108. package/dist/numeric-identifier-validator.js +0 -84
  109. package/dist/numeric-identifier-validator.js.map +0 -1
  110. package/dist/prefix-manager.d.ts +0 -224
  111. package/dist/prefix-manager.d.ts.map +0 -1
  112. package/dist/prefix-manager.js +0 -369
  113. package/dist/prefix-manager.js.map +0 -1
  114. package/dist/prefix-provider.d.ts +0 -27
  115. package/dist/prefix-provider.d.ts.map +0 -1
  116. package/dist/prefix-provider.js +0 -2
  117. package/dist/prefix-provider.js.map +0 -1
  118. package/dist/prefix-type.d.ts +0 -22
  119. package/dist/prefix-type.d.ts.map +0 -1
  120. package/dist/prefix-type.js +0 -18
  121. package/dist/prefix-type.js.map +0 -1
  122. package/dist/prefix-validator.d.ts +0 -58
  123. package/dist/prefix-validator.d.ts.map +0 -1
  124. package/dist/prefix-validator.js +0 -154
  125. package/dist/prefix-validator.js.map +0 -1
  126. package/dist/serializable-numeric-identifier-creator.d.ts +0 -86
  127. package/dist/serializable-numeric-identifier-creator.d.ts.map +0 -1
  128. package/dist/serializable-numeric-identifier-creator.js +0 -116
  129. package/dist/serializable-numeric-identifier-creator.js.map +0 -1
  130. package/dist/serializable-numeric-identifier-validator.d.ts +0 -79
  131. package/dist/serializable-numeric-identifier-validator.d.ts.map +0 -1
  132. package/dist/serializable-numeric-identifier-validator.js +0 -99
  133. package/dist/serializable-numeric-identifier-validator.js.map +0 -1
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "@aidc-toolkit/gs1",
3
- "version": "1.0.22-beta",
3
+ "version": "1.0.24-beta",
4
4
  "description": "GS1 AIDC Toolkit",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "homepage": "https://aidc-toolkit.com/",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/aidc-toolkit/gs1.git"
11
- },
8
+ "repository": "aidc-toolkit/gs1",
12
9
  "bugs": {
13
10
  "url": "https://github.com/aidc-toolkit/gs1/issues"
14
11
  },
@@ -20,9 +17,8 @@
20
17
  },
21
18
  "scripts": {
22
19
  "lint": "eslint",
23
- "build:core": "rimraf dist && tsc --project",
24
- "build:dev": "npm run build:core -- node_modules/@aidc-toolkit/dev/tsconfig-build-dev.json",
25
- "build:release": "npm run build:core -- node_modules/@aidc-toolkit/dev/tsconfig-build.json",
20
+ "build:dev": "tsup --define.mode=dev",
21
+ "build:release": "tsup",
26
22
  "build:doc": "npm run build:dev",
27
23
  "test": "vitest run"
28
24
  },
@@ -1,4 +1,4 @@
1
- import { CharacterSetCreator, type CharacterSetValidator, Exclusions } from "@aidc-toolkit/utility";
1
+ import { CharacterSetCreator, CharacterSetValidator, Exclusions } from "@aidc-toolkit/utility";
2
2
 
3
3
  /**
4
4
  * GS1 AI encodable character set 82 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
@@ -37,3 +37,18 @@ export const AI39_CREATOR = new CharacterSetCreator([
37
37
  * GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
38
38
  */
39
39
  export const AI39_VALIDATOR = AI39_CREATOR as CharacterSetValidator;
40
+
41
+ /**
42
+ * GS1 AI encodable character set 64 validator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs |
43
+ * GS1 General Specifications}. Doesn't support any exclusions.
44
+ */
45
+ export const AI64_VALIDATOR = new CharacterSetValidator([
46
+ "-",
47
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
48
+ "=",
49
+ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
50
+ "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
51
+ "_",
52
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
53
+ "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
54
+ ]);
package/src/check.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { NUMERIC_CREATOR, utilityNS } from "@aidc-toolkit/utility";
2
- import { AI82_CREATOR } from "./character-set.js";
3
- import { i18nextGS1 } from "./locale/i18n.js";
2
+ import { AI82_CREATOR } from "./character-set";
3
+ import { i18nextGS1 } from "./locale/i18n";
4
4
 
5
5
  /**
6
6
  * Results of multiplying digits by 3.
@@ -6,10 +6,10 @@ import {
6
6
  type TransformerOutput
7
7
  } from "@aidc-toolkit/utility";
8
8
  import { Mixin } from "ts-mixer";
9
- import { checkDigit, priceOrWeightCheckDigit } from "./check.js";
10
- import { type GTINType, GTINTypes, GTINValidator } from "./gtin-validator.js";
11
- import { i18nextGS1 } from "./locale/i18n.js";
12
- import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
9
+ import { checkDigit, priceOrWeightCheckDigit } from "./check";
10
+ import { type GTINType, GTINTypes, GTINValidator } from "./gtin-validator";
11
+ import { i18nextGS1 } from "./locale/i18n";
12
+ import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator";
13
13
  import type { PrefixProvider } from "./prefix-provider";
14
14
 
15
15
  /**
@@ -1,10 +1,10 @@
1
1
  import { type CharacterSetValidation, NUMERIC_CREATOR } from "@aidc-toolkit/utility";
2
- import { checkDigit, hasValidCheckDigit, isValidPriceOrWeightCheckDigit } from "./check.js";
3
- import { IdentifierTypes } from "./identifier-type.js";
4
- import { i18nextGS1 } from "./locale/i18n.js";
5
- import { AbstractNumericIdentifierValidator, LeaderTypes } from "./numeric-identifier-validator.js";
6
- import { type PrefixType, PrefixTypes } from "./prefix-type.js";
7
- import { PrefixValidator } from "./prefix-validator.js";
2
+ import { checkDigit, hasValidCheckDigit, isValidPriceOrWeightCheckDigit } from "./check";
3
+ import { IdentifierTypes } from "./identifier-type";
4
+ import { i18nextGS1 } from "./locale/i18n";
5
+ import { AbstractNumericIdentifierValidator, LeaderTypes } from "./numeric-identifier-validator";
6
+ import { type PrefixType, PrefixTypes } from "./prefix-type";
7
+ import { PrefixValidator } from "./prefix-validator";
8
8
 
9
9
  /**
10
10
  * GTIN types. The numeric values are equal to the lengths of the GTIN types.
@@ -1,8 +1,8 @@
1
1
  import type { CharacterSetCreator } from "@aidc-toolkit/utility";
2
- import type { IdentifierType } from "./identifier-type.js";
3
- import type { ContentCharacterSet, IdentifierValidation, IdentifierValidator } from "./identifier-validator.js";
2
+ import type { IdentifierType } from "./identifier-type";
3
+ import type { ContentCharacterSet, IdentifierValidation, IdentifierValidator } from "./identifier-validator";
4
4
  import type { PrefixProvider } from "./prefix-provider";
5
- import type { PrefixType } from "./prefix-type.js";
5
+ import type { PrefixType } from "./prefix-type";
6
6
 
7
7
  /**
8
8
  * Identifier creator. Creates an identifier based on its definition in section 3 of the {@link
@@ -4,10 +4,10 @@ import {
4
4
  type StringValidation,
5
5
  type StringValidator
6
6
  } from "@aidc-toolkit/utility";
7
- import { AI39_CREATOR, AI82_CREATOR } from "./character-set.js";
8
- import type { IdentifierType } from "./identifier-type.js";
9
- import type { PrefixType } from "./prefix-type.js";
10
- import { PrefixValidator } from "./prefix-validator.js";
7
+ import { AI39_CREATOR, AI82_CREATOR } from "./character-set";
8
+ import type { IdentifierType } from "./identifier-type";
9
+ import type { PrefixType } from "./prefix-type";
10
+ import { PrefixValidator } from "./prefix-validator";
11
11
 
12
12
  /**
13
13
  * Character sets supported by the reference portion of an identifier or the serial component of a numeric identifier.
package/src/index.ts CHANGED
@@ -14,22 +14,22 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- export * from "./locale/i18n.js";
18
- export * from "./character-set.js";
19
- export * from "./check.js";
20
- export * from "./prefix-type.js";
21
- export * from "./prefix-validator.js";
22
- export * from "./identifier-type.js";
23
- export * from "./identifier-validator.js";
24
- export * from "./numeric-identifier-validator.js";
25
- export * from "./gtin-validator.js";
26
- export * from "./non-gtin-numeric-identifier-validator.js";
27
- export * from "./serializable-numeric-identifier-validator.js";
28
- export * from "./non-numeric-identifier-validator.js";
29
- export * from "./identifier-creator.js";
30
- export * from "./numeric-identifier-creator.js";
31
- export * from "./gtin-creator.js";
32
- export * from "./non-gtin-numeric-identifier-creator.js";
33
- export * from "./serializable-numeric-identifier-creator.js";
34
- export * from "./non-numeric-identifier-creator.js";
35
- export * from "./prefix-manager.js";
17
+ export * from "./locale/i18n";
18
+ export * from "./character-set";
19
+ export * from "./check";
20
+ export * from "./prefix-type";
21
+ export * from "./prefix-validator";
22
+ export * from "./identifier-type";
23
+ export * from "./identifier-validator";
24
+ export * from "./numeric-identifier-validator";
25
+ export * from "./gtin-validator";
26
+ export * from "./non-gtin-numeric-identifier-validator";
27
+ export * from "./serializable-numeric-identifier-validator";
28
+ export * from "./non-numeric-identifier-validator";
29
+ export * from "./identifier-creator";
30
+ export * from "./numeric-identifier-creator";
31
+ export * from "./gtin-creator";
32
+ export * from "./non-gtin-numeric-identifier-creator";
33
+ export * from "./serializable-numeric-identifier-creator";
34
+ export * from "./non-numeric-identifier-creator";
35
+ export * from "./prefix-manager";
@@ -1,4 +1,4 @@
1
- export const localeStrings = {
1
+ export default {
2
2
  Check: {
3
3
  lengthOfStringForPriceOrWeightMustBeExactly: "Length {{length, number}} of string for price or weight must be 4 or 5",
4
4
  priceOrWeightComponent: "price or weight",
@@ -1,8 +1,8 @@
1
- export const localeStrings = {
1
+ export default {
2
2
  Check: {
3
3
  lengthOfStringForPriceOrWeightMustBeExactly: "La longueur {{length, number}} de la chaîne pour le prix ou le poids doit être 4 ou 5",
4
4
  priceOrWeightComponent: "prix ou poids",
5
- lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "La longueur {{length, number}} de la chaîne pour la paire de caractères de vérification doit être inférieure ou égale à {{maximum Length}}"
5
+ lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "La longueur {{length, number}} de la chaîne pour la paire de caractères de vérification doit être inférieure ou égale à {{maximumLength, number}}"
6
6
  },
7
7
  Identifier: {
8
8
  identifierTypeLength: "{{identifierType}} doit comporter {{length, number}} chiffres",
@@ -1,27 +1,25 @@
1
- import { i18nAssertValidResources, i18nCoreInit, type I18nEnvironment } from "@aidc-toolkit/core";
1
+ import { i18nCoreInit, type I18nEnvironment } from "@aidc-toolkit/core";
2
2
  import { i18nUtilityInit, utilityResources } from "@aidc-toolkit/utility";
3
3
  import i18next, { type i18n, type Resource } from "i18next";
4
- import { localeStrings as enLocaleStrings } from "./en/locale-strings.js";
5
- import { localeStrings as frLocaleStrings } from "./fr/locale-strings.js";
4
+ import enLocaleResources from "./en/locale-resources";
5
+ import frLocaleResources from "./fr/locale-resources";
6
6
 
7
7
  export const gs1NS = "aidct_gs1";
8
8
 
9
9
  /**
10
10
  * Locale strings type is extracted from the English locale strings object.
11
11
  */
12
- export type GS1LocaleStrings = typeof enLocaleStrings;
13
-
14
- i18nAssertValidResources(enLocaleStrings, "fr", frLocaleStrings);
12
+ export type GS1LocaleResources = typeof enLocaleResources;
15
13
 
16
14
  /**
17
15
  * GS1 resources.
18
16
  */
19
17
  export const gs1Resources: Resource = {
20
18
  en: {
21
- aidct_gs1: enLocaleStrings
19
+ aidct_gs1: enLocaleResources
22
20
  },
23
21
  fr: {
24
- aidct_gs1: frLocaleStrings
22
+ aidct_gs1: frLocaleResources
25
23
  }
26
24
  };
27
25
 
@@ -1,5 +1,5 @@
1
- import type { UtilityLocaleStrings } from "@aidc-toolkit/utility";
2
- import type { GS1LocaleStrings } from "./i18n.js";
1
+ import type { UtilityLocaleResources } from "@aidc-toolkit/utility";
2
+ import type { GS1LocaleResources } from "./i18n";
3
3
 
4
4
  /**
5
5
  * Internationalization module.
@@ -11,8 +11,8 @@ declare module "i18next" {
11
11
  interface CustomTypeOptions {
12
12
  defaultNS: "aidct_gs1";
13
13
  resources: {
14
- aidct_utility: UtilityLocaleStrings;
15
- aidct_gs1: GS1LocaleStrings;
14
+ aidct_utility: UtilityLocaleResources;
15
+ aidct_gs1: GS1LocaleResources;
16
16
  };
17
17
  }
18
18
  }
@@ -1,8 +1,8 @@
1
1
  import { Mixin } from "ts-mixer";
2
- import type { IdentifierType } from "./identifier-type.js";
3
- import { NonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
4
- import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
5
- import { type LeaderType, LeaderTypes } from "./numeric-identifier-validator.js";
2
+ import type { IdentifierType } from "./identifier-type";
3
+ import { NonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator";
4
+ import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator";
5
+ import { type LeaderType, LeaderTypes } from "./numeric-identifier-validator";
6
6
  import type { PrefixProvider } from "./prefix-provider";
7
7
 
8
8
  /**
@@ -1,11 +1,11 @@
1
- import { type IdentifierType, IdentifierTypes } from "./identifier-type.js";
1
+ import { type IdentifierType, IdentifierTypes } from "./identifier-type";
2
2
  import {
3
3
  AbstractNumericIdentifierValidator,
4
4
  type LeaderType,
5
5
  LeaderTypes,
6
6
  type NumericIdentifierType
7
- } from "./numeric-identifier-validator.js";
8
- import { PrefixTypes } from "./prefix-type.js";
7
+ } from "./numeric-identifier-validator";
8
+ import { PrefixTypes } from "./prefix-type";
9
9
 
10
10
  /**
11
11
  * Non-GTIN numeric identifier type.
@@ -5,12 +5,12 @@ import {
5
5
  type TransformerOutput
6
6
  } from "@aidc-toolkit/utility";
7
7
  import { Mixin } from "ts-mixer";
8
- import { checkCharacterPair } from "./check.js";
9
- import { AbstractIdentifierCreator } from "./identifier-creator.js";
10
- import type { IdentifierType } from "./identifier-type.js";
11
- import type { ContentCharacterSet } from "./identifier-validator.js";
12
- import { i18nextGS1 } from "./locale/i18n.js";
13
- import { NonNumericIdentifierValidator } from "./non-numeric-identifier-validator.js";
8
+ import { checkCharacterPair } from "./check";
9
+ import { AbstractIdentifierCreator } from "./identifier-creator";
10
+ import type { IdentifierType } from "./identifier-type";
11
+ import type { ContentCharacterSet } from "./identifier-validator";
12
+ import { i18nextGS1 } from "./locale/i18n";
13
+ import { NonNumericIdentifierValidator } from "./non-numeric-identifier-validator";
14
14
  import type { PrefixProvider } from "./prefix-provider";
15
15
 
16
16
  /**
@@ -1,15 +1,15 @@
1
1
  import { Exclusions, RegExpValidator } from "@aidc-toolkit/utility";
2
- import { hasValidCheckCharacterPair } from "./check.js";
3
- import { type IdentifierType, IdentifierTypes } from "./identifier-type.js";
2
+ import { hasValidCheckCharacterPair } from "./check";
3
+ import { type IdentifierType, IdentifierTypes } from "./identifier-type";
4
4
  import {
5
5
  AbstractIdentifierValidator,
6
6
  type ContentCharacterSet,
7
7
  ContentCharacterSets,
8
8
  type IdentifierValidation
9
- } from "./identifier-validator.js";
10
- import { i18nextGS1 } from "./locale/i18n.js";
11
- import type { NumericIdentifierType } from "./numeric-identifier-validator.js";
12
- import { PrefixTypes } from "./prefix-type.js";
9
+ } from "./identifier-validator";
10
+ import { i18nextGS1 } from "./locale/i18n";
11
+ import type { NumericIdentifierType } from "./numeric-identifier-validator";
12
+ import { PrefixTypes } from "./prefix-type";
13
13
 
14
14
  /**
15
15
  * Non-numeric identifier type.
@@ -5,9 +5,9 @@ import {
5
5
  type TransformerInput,
6
6
  type TransformerOutput
7
7
  } from "@aidc-toolkit/utility";
8
- import { checkDigit, checkDigitSum } from "./check.js";
9
- import { AbstractIdentifierCreator, type IdentifierCreator } from "./identifier-creator.js";
10
- import { type LeaderType, LeaderTypes, type NumericIdentifierValidator } from "./numeric-identifier-validator.js";
8
+ import { checkDigit, checkDigitSum } from "./check";
9
+ import { AbstractIdentifierCreator, type IdentifierCreator } from "./identifier-creator";
10
+ import { type LeaderType, LeaderTypes, type NumericIdentifierValidator } from "./numeric-identifier-validator";
11
11
  import type { PrefixProvider } from "./prefix-provider";
12
12
 
13
13
  /**
@@ -1,13 +1,13 @@
1
- import { hasValidCheckDigit } from "./check.js";
2
- import type { IdentifierType, IdentifierTypes } from "./identifier-type.js";
1
+ import { hasValidCheckDigit } from "./check";
2
+ import type { IdentifierType, IdentifierTypes } from "./identifier-type";
3
3
  import {
4
4
  AbstractIdentifierValidator,
5
5
  ContentCharacterSets,
6
6
  type IdentifierValidation,
7
7
  type IdentifierValidator
8
- } from "./identifier-validator.js";
9
- import { i18nextGS1 } from "./locale/i18n.js";
10
- import type { PrefixType } from "./prefix-type.js";
8
+ } from "./identifier-validator";
9
+ import { i18nextGS1 } from "./locale/i18n";
10
+ import type { PrefixType } from "./prefix-type";
11
11
 
12
12
  /**
13
13
  * Numeric identifier type.
@@ -1,35 +1,36 @@
1
- import { GTINCreator } from "./gtin-creator.js";
2
- import { type GTINType, GTINTypes } from "./gtin-validator.js";
3
- import type { IdentifierCreator } from "./identifier-creator.js";
4
- import { type IdentifierType, IdentifierTypes } from "./identifier-type.js";
5
- import { i18nextGS1 } from "./locale/i18n.js";
6
- import { NonGTINNumericIdentifierCreator } from "./non-gtin-numeric-identifier-creator.js";
1
+ import { GTINCreator } from "./gtin-creator";
2
+ import { type GTINType, GTINTypes } from "./gtin-validator";
3
+ import type { IdentifierCreator } from "./identifier-creator";
4
+ import { type IdentifierType, IdentifierTypes } from "./identifier-type";
5
+ import { i18nextGS1 } from "./locale/i18n";
6
+ import { NonGTINNumericIdentifierCreator } from "./non-gtin-numeric-identifier-creator";
7
7
  import {
8
8
  GLN_VALIDATOR,
9
9
  GSIN_VALIDATOR,
10
10
  GSRN_VALIDATOR,
11
11
  type NonGTINNumericIdentifierValidator,
12
12
  SSCC_VALIDATOR
13
- } from "./non-gtin-numeric-identifier-validator.js";
14
- import { NonNumericIdentifierCreator } from "./non-numeric-identifier-creator.js";
13
+ } from "./non-gtin-numeric-identifier-validator";
14
+ import { NonNumericIdentifierCreator } from "./non-numeric-identifier-creator";
15
15
  import {
16
16
  CPID_VALIDATOR,
17
17
  GIAI_VALIDATOR,
18
18
  GINC_VALIDATOR,
19
19
  GMN_VALIDATOR,
20
20
  type NonNumericIdentifierValidator
21
- } from "./non-numeric-identifier-validator.js";
22
- import type { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
23
- import type { PrefixProvider } from "./prefix-provider.js";
24
- import { type PrefixType, PrefixTypes } from "./prefix-type.js";
25
- import { PrefixValidator } from "./prefix-validator.js";
26
- import { SerializableNumericIdentifierCreator } from "./serializable-numeric-identifier-creator.js";
21
+ } from "./non-numeric-identifier-validator";
22
+ import type { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator";
23
+ import type { NumericIdentifierType } from "./numeric-identifier-validator";
24
+ import type { PrefixProvider } from "./prefix-provider";
25
+ import { type PrefixType, PrefixTypes } from "./prefix-type";
26
+ import { PrefixValidator } from "./prefix-validator";
27
+ import { SerializableNumericIdentifierCreator } from "./serializable-numeric-identifier-creator";
27
28
  import {
28
29
  GCN_VALIDATOR,
29
30
  GDTI_VALIDATOR,
30
31
  GRAI_VALIDATOR,
31
32
  type SerializableNumericIdentifierValidator
32
- } from "./serializable-numeric-identifier-validator.js";
33
+ } from "./serializable-numeric-identifier-validator";
33
34
 
34
35
  /**
35
36
  * Prefix manager. This is the core class for identifier creation.
@@ -59,19 +60,19 @@ export class PrefixManager implements PrefixProvider {
59
60
  private static readonly PREFIX_MANAGERS_MAP = new Map<string, PrefixManager>();
60
61
 
61
62
  /**
62
- * Creator tweak factors. Different numeric identifier types have different tweak factors so that sparse
63
- * creation generates different sequences for each.
63
+ * Creator tweak factors. Different numeric identifier types have different tweak factors so that sparse creation
64
+ * generates different sequences for each.
64
65
  */
65
- private static readonly CREATOR_TWEAK_FACTORS_MAP: ReadonlyMap<IdentifierType, bigint> = new Map([
66
- [IdentifierTypes.GTIN, 1987n],
67
- [IdentifierTypes.GLN, 4241n],
68
- [IdentifierTypes.SSCC, 8087n],
69
- [IdentifierTypes.GRAI, 3221n],
70
- [IdentifierTypes.GSRN, 2341n],
71
- [IdentifierTypes.GDTI, 7333n],
72
- [IdentifierTypes.GSIN, 5623n],
73
- [IdentifierTypes.GCN, 6869n]
74
- ]);
66
+ private static readonly CREATOR_TWEAK_FACTORS: Readonly<Record<NumericIdentifierType, bigint>> = {
67
+ GTIN: 1987n,
68
+ GLN: 4241n,
69
+ SSCC: 8087n,
70
+ GRAI: 3221n,
71
+ GSRN: 2341n,
72
+ GDTI: 7333n,
73
+ GSIN: 5623n,
74
+ GCN: 6869n
75
+ };
75
76
 
76
77
  /**
77
78
  * Normalized prefix type.
@@ -111,7 +112,7 @@ export class PrefixManager implements PrefixProvider {
111
112
  /**
112
113
  * Cached identifier creators.
113
114
  */
114
- private readonly _identifierCreatorsMap = new Map<IdentifierType, IdentifierCreator>();
115
+ private readonly _identifierCreators: Partial<Record<IdentifierType, IdentifierCreator>> = {};
115
116
 
116
117
  /**
117
118
  * Constructor.
@@ -184,11 +185,11 @@ export class PrefixManager implements PrefixProvider {
184
185
  * Identifier creator.
185
186
  */
186
187
  private setCreatorTweak(creator: IdentifierCreator): void {
187
- const creatorTweakFactor = PrefixManager.CREATOR_TWEAK_FACTORS_MAP.get(creator.identifierType);
188
+ if (creator.identifierType in PrefixManager.CREATOR_TWEAK_FACTORS) {
189
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type is known by testing for presence in record.
190
+ const creatorTweakFactor = PrefixManager.CREATOR_TWEAK_FACTORS[creator.identifierType as NumericIdentifierType];
188
191
 
189
- // Creator tweak factor is defined for numeric identifiers only.
190
- if (creatorTweakFactor !== undefined) {
191
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion,no-param-reassign -- Explicit cast without testing is necessary as "instanceof" doesn't work for mixin types. Method purpose is to set the tweak.
192
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion,no-param-reassign -- Type is known by testing identifier type. Method purpose is to set the tweak.
192
193
  (creator as AbstractNumericIdentifierCreator).tweak = this.tweakFactor * creatorTweakFactor;
193
194
  }
194
195
  }
@@ -212,7 +213,7 @@ export class PrefixManager implements PrefixProvider {
212
213
  if (this._tweakFactor !== tweakFactor) {
213
214
  this._tweakFactor = tweakFactor;
214
215
 
215
- for (const creator of this._identifierCreatorsMap.values()) {
216
+ for (const creator of Object.values(this._identifierCreators)) {
216
217
  this.setCreatorTweak(creator);
217
218
  }
218
219
  }
@@ -284,7 +285,7 @@ export class PrefixManager implements PrefixProvider {
284
285
  */
285
286
  private getIdentifierCreator<TIdentifierCreator extends IdentifierCreator>(identifierType: IdentifierType, constructorCallback: () => TIdentifierCreator): TIdentifierCreator {
286
287
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type is paired with constructor callback.
287
- let creator = this._identifierCreatorsMap.get(identifierType) as TIdentifierCreator | undefined;
288
+ let creator = this._identifierCreators[identifierType] as TIdentifierCreator | undefined;
288
289
 
289
290
  if (creator === undefined) {
290
291
  if (this.prefixType === PrefixTypes.GS18Prefix && identifierType !== IdentifierTypes.GTIN) {
@@ -297,7 +298,7 @@ export class PrefixManager implements PrefixProvider {
297
298
 
298
299
  this.setCreatorTweak(creator);
299
300
 
300
- this._identifierCreatorsMap.set(identifierType, creator);
301
+ this._identifierCreators[identifierType] = creator;
301
302
  }
302
303
 
303
304
  return creator;
@@ -1,4 +1,4 @@
1
- import type { PrefixType } from "./prefix-type.js";
1
+ import type { PrefixType } from "./prefix-type";
2
2
 
3
3
  /**
4
4
  * Prefix provider.
@@ -1,6 +1,6 @@
1
1
  import { type CharacterSetValidation, NUMERIC_CREATOR } from "@aidc-toolkit/utility";
2
- import { i18nextGS1 } from "./locale/i18n.js";
3
- import { type PrefixType, PrefixTypes } from "./prefix-type.js";
2
+ import { i18nextGS1 } from "./locale/i18n";
3
+ import { type PrefixType, PrefixTypes } from "./prefix-type";
4
4
 
5
5
  /**
6
6
  * Prefix validation parameters.
@@ -1,10 +1,10 @@
1
1
  import { mapIterable, type TransformerInput, type TransformerOutput } from "@aidc-toolkit/utility";
2
2
  import { Mixin } from "ts-mixer";
3
- import type { IdentifierType } from "./identifier-type.js";
4
- import type { ContentCharacterSet } from "./identifier-validator.js";
5
- import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
3
+ import type { IdentifierType } from "./identifier-type";
4
+ import type { ContentCharacterSet } from "./identifier-validator";
5
+ import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator";
6
6
  import type { PrefixProvider } from "./prefix-provider";
7
- import { SerializableNumericIdentifierValidator } from "./serializable-numeric-identifier-validator.js";
7
+ import { SerializableNumericIdentifierValidator } from "./serializable-numeric-identifier-validator";
8
8
 
9
9
  /**
10
10
  * Serializable numeric identifier creator.
@@ -1,12 +1,12 @@
1
1
  import type { CharacterSetCreator, CharacterSetValidation } from "@aidc-toolkit/utility";
2
- import { type IdentifierType, IdentifierTypes } from "./identifier-type.js";
3
- import { type ContentCharacterSet, ContentCharacterSets, type IdentifierValidation } from "./identifier-validator.js";
4
- import { i18nextGS1 } from "./locale/i18n.js";
2
+ import { type IdentifierType, IdentifierTypes } from "./identifier-type";
3
+ import { type ContentCharacterSet, ContentCharacterSets, type IdentifierValidation } from "./identifier-validator";
4
+ import { i18nextGS1 } from "./locale/i18n";
5
5
  import {
6
6
  type NonGTINNumericIdentifierType,
7
7
  NonGTINNumericIdentifierValidator
8
- } from "./non-gtin-numeric-identifier-validator.js";
9
- import { LeaderTypes } from "./numeric-identifier-validator.js";
8
+ } from "./non-gtin-numeric-identifier-validator";
9
+ import { LeaderTypes } from "./numeric-identifier-validator";
10
10
 
11
11
  /**
12
12
  * Serializable numeric identifier type.
@@ -1,11 +1,11 @@
1
1
  import { describe } from "vitest";
2
2
  import { PrefixManager, PrefixTypes } from "../src";
3
- import { testGTINCreator } from "./gtin-creator.js";
3
+ import { testGTINCreator } from "./gtin-creator";
4
4
  import {
5
5
  testNonGTINNumericIdentifierCreator,
6
6
  testNonNumericIdentifierCreator
7
- } from "./non-gtin-numeric-identifier-creator.js";
8
- import { testSerializableNumericIdentifierCreator } from "./serializable-numeric-identifier-creator.js";
7
+ } from "./non-gtin-numeric-identifier-creator";
8
+ import { testSerializableNumericIdentifierCreator } from "./serializable-numeric-identifier-creator";
9
9
 
10
10
  describe("Creators", () => {
11
11
  testGTINCreator(PrefixManager.get(PrefixTypes.GS1CompanyPrefix, "952123456").gtinCreator);
@@ -1,7 +1,7 @@
1
1
  import { CharacterSetCreator, Sequence } from "@aidc-toolkit/utility";
2
2
  import { expect, test } from "vitest";
3
3
  import { type GTINCreator, GTINTypes, GTINValidator, hasValidCheckDigit, PrefixTypes } from "../src";
4
- import { testNumericIdentifierCreator } from "./numeric-identifier-creator.js";
4
+ import { testNumericIdentifierCreator } from "./numeric-identifier-creator";
5
5
 
6
6
  export function testGTINCreator(creator: GTINCreator): void {
7
7
  testNumericIdentifierCreator(creator, () => {
@@ -9,7 +9,7 @@ import {
9
9
  type PrefixType,
10
10
  PrefixTypes
11
11
  } from "../src";
12
- import { validateNumericIdentifierValidator } from "./numeric-identifier-validator.js";
12
+ import { validateNumericIdentifierValidator } from "./numeric-identifier-validator";
13
13
 
14
14
  export function validateGTINValidator(validator: GTINValidator, isCreator: boolean, gtinType: GTINType): void {
15
15
  let prefixType: PrefixType;
@@ -8,10 +8,10 @@ import {
8
8
  type PrefixManager,
9
9
  PrefixTypes
10
10
  } from "../src";
11
- import { validateGTINValidator } from "./gtin-validator.test.js";
12
- import { validateNonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
13
- import { validateNonNumericIdentifierValidator } from "./non-numeric-identifier-validator.js";
14
- import { validateSerializableNumericIdentifierValidator } from "./serializable-numeric-identifier-validator.js";
11
+ import { validateGTINValidator } from "./gtin-validator.test";
12
+ import { validateNonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator";
13
+ import { validateNonNumericIdentifierValidator } from "./non-numeric-identifier-validator";
14
+ import { validateSerializableNumericIdentifierValidator } from "./serializable-numeric-identifier-validator";
15
15
 
16
16
  export function validateIdentifierCreators(prefixManager: PrefixManager): void {
17
17
  let gtinType: GTINType;
@@ -5,7 +5,7 @@ import {
5
5
  type NonGTINNumericIdentifierCreator,
6
6
  type NonNumericIdentifierCreator
7
7
  } from "../src";
8
- import { testNumericIdentifierCreator } from "./numeric-identifier-creator.js";
8
+ import { testNumericIdentifierCreator } from "./numeric-identifier-creator";
9
9
 
10
10
  export function testNonGTINNumericIdentifierCreator(creator: NonGTINNumericIdentifierCreator, preTestCallback?: () => void, postTestCallback?: () => void): void {
11
11
  testNumericIdentifierCreator(creator, preTestCallback, postTestCallback);
@@ -1,5 +1,5 @@
1
1
  import { type IdentifierType, type LeaderType, type NonGTINNumericIdentifierValidator, PrefixTypes } from "../src";
2
- import { validateNumericIdentifierValidator } from "./numeric-identifier-validator.js";
2
+ import { validateNumericIdentifierValidator } from "./numeric-identifier-validator";
3
3
 
4
4
  export function validateNonGTINNumericIdentifierValidator(validator: NonGTINNumericIdentifierValidator, isCreator: boolean, identifierType: IdentifierType, length: number, leaderType: LeaderType): void {
5
5
  validateNumericIdentifierValidator(validator, isCreator, identifierType, PrefixTypes.GS1CompanyPrefix, length, leaderType);
@@ -6,8 +6,8 @@ import {
6
6
  type NonNumericIdentifierValidator,
7
7
  PrefixTypes
8
8
  } from "../src";
9
- import { validateIdentifierValidator } from "./identifier-validator.js";
10
- import { creatorFor } from "./utility.js";
9
+ import { validateIdentifierValidator } from "./identifier-validator";
10
+ import { creatorFor } from "./utility";
11
11
 
12
12
  export function validateNonNumericIdentifierValidator(validator: NonNumericIdentifierValidator, isCreator: boolean, identifierType: IdentifierType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair: boolean): void {
13
13
  validateIdentifierValidator(validator, identifierType, PrefixTypes.GS1CompanyPrefix, length);