@aidc-toolkit/gs1 0.9.5 → 0.9.7-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/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { gs1NS } from "./locale/i18n.js";
1
2
  export * from "./character_set.js";
2
3
  export * from "./check.js";
3
4
  export * from "./idkey.js";
@@ -11,7 +11,7 @@ import {
11
11
  hasValidCheckDigit
12
12
  } from "../src/index.js";
13
13
 
14
- await i18nInit(I18NEnvironment.CLI, true);
14
+ await i18nInit(I18NEnvironment.CLI);
15
15
 
16
16
  describe("Check digit", () => {
17
17
  const testNumericString = "1234567890";
@@ -4,7 +4,7 @@ import { describe, expect, test } from "vitest";
4
4
  import {
5
5
  AI39_CREATOR,
6
6
  AI82_CREATOR,
7
- CharacterSet,
7
+ ContentCharacterSet,
8
8
  CPID_VALIDATOR,
9
9
  GCN_VALIDATOR,
10
10
  GDTI_VALIDATOR,
@@ -41,21 +41,21 @@ import {
41
41
  SSCC_VALIDATOR
42
42
  } from "../src/index.js";
43
43
 
44
- await i18nInit(I18NEnvironment.CLI, true);
44
+ await i18nInit(I18NEnvironment.CLI);
45
45
 
46
- function creatorFor(characterSet: CharacterSet): CharacterSetCreator {
46
+ function creatorFor(characterSet: ContentCharacterSet): CharacterSetCreator {
47
47
  let creator: CharacterSetCreator;
48
48
 
49
49
  switch (characterSet) {
50
- case CharacterSet.Numeric:
50
+ case ContentCharacterSet.Numeric:
51
51
  creator = NUMERIC_CREATOR;
52
52
  break;
53
53
 
54
- case CharacterSet.AI82:
54
+ case ContentCharacterSet.AI82:
55
55
  creator = AI82_CREATOR;
56
56
  break;
57
57
 
58
- case CharacterSet.AI39:
58
+ case ContentCharacterSet.AI39:
59
59
  creator = AI39_CREATOR;
60
60
  break;
61
61
  }
@@ -73,8 +73,8 @@ function validateNumericIdentificationKeyValidator(validator: NumericIdentificat
73
73
  validateIdentificationKeyValidator(validator, identificationKeyType, prefixType, length);
74
74
 
75
75
  expect(validator.leaderType).toBe(leaderType);
76
- expect(validator.referenceCharacterSet).toBe(CharacterSet.Numeric);
77
- expect(validator.referenceValidator).toBe(NUMERIC_CREATOR);
76
+ expect(validator.referenceCharacterSet).toBe(ContentCharacterSet.Numeric);
77
+ expect(validator.referenceCreator).toBe(NUMERIC_CREATOR);
78
78
 
79
79
  if (isCreator) {
80
80
  expect((validator as NumericIdentificationKeyCreator).referenceCreator).toBe(NUMERIC_CREATOR);
@@ -110,27 +110,27 @@ function validateNonGTINNumericIdentificationKeyValidator<T extends NonGTINNumer
110
110
  validateNumericIdentificationKeyValidator(validator, isCreator, identificationKeyType, PrefixType.GS1CompanyPrefix, length, leaderType);
111
111
  }
112
112
 
113
- function validateSerializableNumericIdentificationKeyValidator(validator: SerializableNumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, length: number, leaderType: LeaderType, serialLength: number, serialCharacterSet: CharacterSet): void {
113
+ function validateSerializableNumericIdentificationKeyValidator(validator: SerializableNumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, length: number, leaderType: LeaderType, serialLength: number, serialCharacterSet: ContentCharacterSet): void {
114
114
  validateNonGTINNumericIdentificationKeyValidator(validator, isCreator, identificationKeyType, length, leaderType);
115
115
 
116
116
  const serialCreator = creatorFor(serialCharacterSet);
117
117
 
118
118
  expect(validator.serialComponentLength).toBe(serialLength);
119
119
  expect(validator.serialComponentCharacterSet).toBe(serialCharacterSet);
120
- expect(validator.serialComponentValidator).toBe(serialCreator);
120
+ expect(validator.serialComponentCreator).toBe(serialCreator);
121
121
 
122
122
  if (isCreator) {
123
123
  expect((validator as SerializableNumericIdentificationKeyCreator).serialComponentCreator).toBe(serialCreator);
124
124
  }
125
125
  }
126
126
 
127
- function validateNonNumericIdentificationKeyValidator(validator: NonNumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: CharacterSet, requiresCheckCharacterPair: boolean): void {
127
+ function validateNonNumericIdentificationKeyValidator(validator: NonNumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair: boolean): void {
128
128
  validateIdentificationKeyValidator(validator, identificationKeyType, PrefixType.GS1CompanyPrefix, length);
129
129
 
130
130
  const referenceCreator = creatorFor(referenceCharacterSet);
131
131
 
132
132
  expect(validator.referenceCharacterSet).toBe(referenceCharacterSet);
133
- expect(validator.referenceValidator).toBe(referenceCreator);
133
+ expect(validator.referenceCreator).toBe(referenceCreator);
134
134
  expect(validator.requiresCheckCharacterPair).toBe(requiresCheckCharacterPair);
135
135
 
136
136
  if (isCreator) {
@@ -151,15 +151,15 @@ describe("Validators", () => {
151
151
  validateGTINValidator(GTIN8_VALIDATOR, false, GTINType.GTIN8);
152
152
  validateNonGTINNumericIdentificationKeyValidator(GLN_VALIDATOR, false, IdentificationKeyType.GLN, 13, LeaderType.None);
153
153
  validateNonGTINNumericIdentificationKeyValidator(SSCC_VALIDATOR, false, IdentificationKeyType.SSCC, 18, LeaderType.ExtensionDigit);
154
- validateSerializableNumericIdentificationKeyValidator(GRAI_VALIDATOR, false, IdentificationKeyType.GRAI, 13, LeaderType.None, 16, CharacterSet.AI82);
155
- validateNonNumericIdentificationKeyValidator(GIAI_VALIDATOR, false, IdentificationKeyType.GIAI, 30, CharacterSet.AI82, false);
154
+ validateSerializableNumericIdentificationKeyValidator(GRAI_VALIDATOR, false, IdentificationKeyType.GRAI, 13, LeaderType.None, 16, ContentCharacterSet.AI82);
155
+ validateNonNumericIdentificationKeyValidator(GIAI_VALIDATOR, false, IdentificationKeyType.GIAI, 30, ContentCharacterSet.AI82, false);
156
156
  validateNonGTINNumericIdentificationKeyValidator(GSRN_VALIDATOR, false, IdentificationKeyType.GSRN, 18, LeaderType.None);
157
- validateSerializableNumericIdentificationKeyValidator(GDTI_VALIDATOR, false, IdentificationKeyType.GDTI, 13, LeaderType.None, 17, CharacterSet.AI82);
158
- validateNonNumericIdentificationKeyValidator(GINC_VALIDATOR, false, IdentificationKeyType.GINC, 30, CharacterSet.AI82, false);
157
+ validateSerializableNumericIdentificationKeyValidator(GDTI_VALIDATOR, false, IdentificationKeyType.GDTI, 13, LeaderType.None, 17, ContentCharacterSet.AI82);
158
+ validateNonNumericIdentificationKeyValidator(GINC_VALIDATOR, false, IdentificationKeyType.GINC, 30, ContentCharacterSet.AI82, false);
159
159
  validateNonGTINNumericIdentificationKeyValidator(GSIN_VALIDATOR, false, IdentificationKeyType.GSIN, 17, LeaderType.None);
160
- validateSerializableNumericIdentificationKeyValidator(GCN_VALIDATOR, false, IdentificationKeyType.GCN, 13, LeaderType.None, 12, CharacterSet.Numeric);
161
- validateNonNumericIdentificationKeyValidator(CPID_VALIDATOR, false, IdentificationKeyType.CPID, 30, CharacterSet.AI39, false);
162
- validateNonNumericIdentificationKeyValidator(GMN_VALIDATOR, false, IdentificationKeyType.GMN, 25, CharacterSet.AI82, true);
160
+ validateSerializableNumericIdentificationKeyValidator(GCN_VALIDATOR, false, IdentificationKeyType.GCN, 13, LeaderType.None, 12, ContentCharacterSet.Numeric);
161
+ validateNonNumericIdentificationKeyValidator(CPID_VALIDATOR, false, IdentificationKeyType.CPID, 30, ContentCharacterSet.AI39, false);
162
+ validateNonNumericIdentificationKeyValidator(GMN_VALIDATOR, false, IdentificationKeyType.GMN, 25, ContentCharacterSet.AI82, true);
163
163
  });
164
164
  });
165
165
 
@@ -202,15 +202,15 @@ function validateIdentificationKeyCreators(prefixManager: PrefixManager): void {
202
202
 
203
203
  validateNonGTINNumericIdentificationKeyValidator(prefixManager.glnCreator, true, IdentificationKeyType.GLN, 13, LeaderType.None);
204
204
  validateNonGTINNumericIdentificationKeyValidator(prefixManager.ssccCreator, true, IdentificationKeyType.SSCC, 18, LeaderType.ExtensionDigit);
205
- validateSerializableNumericIdentificationKeyValidator(prefixManager.graiCreator, true, IdentificationKeyType.GRAI, 13, LeaderType.None, 16, CharacterSet.AI82);
206
- validateNonNumericIdentificationKeyValidator(prefixManager.giaiCreator, true, IdentificationKeyType.GIAI, 30, CharacterSet.AI82, false);
205
+ validateSerializableNumericIdentificationKeyValidator(prefixManager.graiCreator, true, IdentificationKeyType.GRAI, 13, LeaderType.None, 16, ContentCharacterSet.AI82);
206
+ validateNonNumericIdentificationKeyValidator(prefixManager.giaiCreator, true, IdentificationKeyType.GIAI, 30, ContentCharacterSet.AI82, false);
207
207
  validateNonGTINNumericIdentificationKeyValidator(prefixManager.gsrnCreator, true, IdentificationKeyType.GSRN, 18, LeaderType.None);
208
- validateSerializableNumericIdentificationKeyValidator(prefixManager.gdtiCreator, true, IdentificationKeyType.GDTI, 13, LeaderType.None, 17, CharacterSet.AI82);
209
- validateNonNumericIdentificationKeyValidator(prefixManager.gincCreator, true, IdentificationKeyType.GINC, 30, CharacterSet.AI82, false);
208
+ validateSerializableNumericIdentificationKeyValidator(prefixManager.gdtiCreator, true, IdentificationKeyType.GDTI, 13, LeaderType.None, 17, ContentCharacterSet.AI82);
209
+ validateNonNumericIdentificationKeyValidator(prefixManager.gincCreator, true, IdentificationKeyType.GINC, 30, ContentCharacterSet.AI82, false);
210
210
  validateNonGTINNumericIdentificationKeyValidator(prefixManager.gsinCreator, true, IdentificationKeyType.GSIN, 17, LeaderType.None);
211
- validateSerializableNumericIdentificationKeyValidator(prefixManager.gcnCreator, true, IdentificationKeyType.GCN, 13, LeaderType.None, 12, CharacterSet.Numeric);
212
- validateNonNumericIdentificationKeyValidator(prefixManager.cpidCreator, true, IdentificationKeyType.CPID, 30, CharacterSet.AI39, false);
213
- validateNonNumericIdentificationKeyValidator(prefixManager.gmnCreator, true, IdentificationKeyType.GMN, 25, CharacterSet.AI82, true);
211
+ validateSerializableNumericIdentificationKeyValidator(prefixManager.gcnCreator, true, IdentificationKeyType.GCN, 13, LeaderType.None, 12, ContentCharacterSet.Numeric);
212
+ validateNonNumericIdentificationKeyValidator(prefixManager.cpidCreator, true, IdentificationKeyType.CPID, 30, ContentCharacterSet.AI39, false);
213
+ validateNonNumericIdentificationKeyValidator(prefixManager.gmnCreator, true, IdentificationKeyType.GMN, 25, ContentCharacterSet.AI82, true);
214
214
  } else {
215
215
  expect(() => prefixManager.glnCreator).toThrow("GLN not supported by GS1-8 Prefix");
216
216
  expect(() => prefixManager.ssccCreator).toThrow("SSCC not supported by GS1-8 Prefix");
@@ -902,15 +902,15 @@ function testSerializableNumericIdentificationKeyCreator(creator: SerializableNu
902
902
  let invalidSerial: string;
903
903
 
904
904
  switch (creator.serialComponentCharacterSet) {
905
- case CharacterSet.Numeric:
905
+ case ContentCharacterSet.Numeric:
906
906
  invalidSerial = "1234A5678";
907
907
  break;
908
908
 
909
- case CharacterSet.AI82:
909
+ case ContentCharacterSet.AI82:
910
910
  invalidSerial = "ABCD~1234";
911
911
  break;
912
912
 
913
- case CharacterSet.AI39:
913
+ case ContentCharacterSet.AI39:
914
914
  invalidSerial = "ABCD%1234";
915
915
  break;
916
916
  }
@@ -1,32 +0,0 @@
1
- ---
2
- name: Bug report
3
- about: Create a report to help us improve
4
- title: ''
5
- labels: ''
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Describe the bug**
11
- A clear and concise description of what the bug is.
12
-
13
- **To Reproduce**
14
- Steps to reproduce the behavior:
15
- 1. Go to '...'
16
- 2. Click on '....'
17
- 3. Scroll down to '....'
18
- 4. See error
19
-
20
- **Expected behavior**
21
- A clear and concise description of what you expected to happen.
22
-
23
- **Screenshots**
24
- If applicable, add screenshots to help explain your problem.
25
-
26
- **Platform**
27
- - OS: [e.g. Windows, iOS]
28
- - Browser [e.g. chrome, safari]
29
- - Browser Version [e.g. 22]
30
-
31
- **Additional context**
32
- Add any other context about the problem here.
@@ -1,20 +0,0 @@
1
- ---
2
- name: Feature request
3
- about: Suggest an idea for this project
4
- title: ''
5
- labels: ''
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Is your feature request related to a problem? Please describe.**
11
- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
-
13
- **Describe the solution you'd like**
14
- A clear and concise description of what you want to happen.
15
-
16
- **Describe alternatives you've considered**
17
- A clear and concise description of any alternative solutions or features you've considered.
18
-
19
- **Additional context**
20
- Add any other context or screenshots about the feature request here.
@@ -1,20 +0,0 @@
1
- name: Build and publish
2
-
3
- on:
4
- release:
5
- types:
6
- - published
7
-
8
- jobs:
9
- build-and-publish:
10
- runs-on: ubuntu-latest
11
-
12
- steps:
13
- - name: Build and publish gs1
14
- uses: aidc-toolkit/dev/.github/actions/build-publish@main
15
- with:
16
- project: gs1
17
- node_version: ${{ vars.NODE_VERSION }}
18
- node_auth_token: ${{ secrets.NODE_AUTH_TOKEN }}
19
- terminal_pre_build: ${{ vars.TERMINAL_PRE_BUILD }}
20
- terminal_post_build: ${{ vars.TERMINAL_POST_BUILD }}
package/.idea/gs1.iml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="JAVA_MODULE" version="4">
3
- <component name="NewModuleRootManager" inherit-compiler-output="true">
4
- <exclude-output />
5
- <content url="file://$MODULE_DIR$" />
6
- <orderEntry type="inheritedJdk" />
7
- <orderEntry type="sourceFolder" forTests="false" />
8
- </component>
9
- </module>
@@ -1,7 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
- <inspection_tool class="UpdateDependencyToLatestVersion" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
6
- </profile>
7
- </component>
package/.idea/misc.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
4
- <output url="file://$PROJECT_DIR$/out" />
5
- </component>
6
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/gs1.iml" filepath="$PROJECT_DIR$/.idea/gs1.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,12 +0,0 @@
1
- <component name="ProjectRunConfigurationManager">
2
- <configuration default="false" name="Test all" type="JavaScriptTestRunnerVitest">
3
- <node-interpreter value="project" />
4
- <vitest-package value="$PROJECT_DIR$/node_modules/vitest" />
5
- <working-dir value="$PROJECT_DIR$" />
6
- <vitest-options value="--run" />
7
- <envs />
8
- <scope-kind value="DIRECTORY" />
9
- <test-directory value="$PROJECT_DIR$/test" />
10
- <method v="2" />
11
- </configuration>
12
- </component>
@@ -1,12 +0,0 @@
1
- <component name="ProjectRunConfigurationManager">
2
- <configuration default="false" name="Test check" type="JavaScriptTestRunnerVitest">
3
- <node-interpreter value="project" />
4
- <vitest-package value="$PROJECT_DIR$/node_modules/vitest" />
5
- <working-dir value="$PROJECT_DIR$" />
6
- <vitest-options value="--run" />
7
- <envs />
8
- <scope-kind value="TEST_FILE" />
9
- <test-file value="$PROJECT_DIR$/test/check.test.ts" />
10
- <method v="2" />
11
- </configuration>
12
- </component>
@@ -1,12 +0,0 @@
1
- <component name="ProjectRunConfigurationManager">
2
- <configuration default="false" name="Test identification key" type="JavaScriptTestRunnerVitest">
3
- <node-interpreter value="project" />
4
- <vitest-package value="$PROJECT_DIR$/node_modules/vitest" />
5
- <working-dir value="$PROJECT_DIR$" />
6
- <vitest-options value="--run" />
7
- <envs />
8
- <scope-kind value="TEST_FILE" />
9
- <test-file value="$PROJECT_DIR$/test/idkey.test.ts" />
10
- <method v="2" />
11
- </configuration>
12
- </component>
@@ -1,12 +0,0 @@
1
- <component name="ProjectRunConfigurationManager">
2
- <configuration default="false" name="build" type="js.build_tools.npm" nameIsGenerated="true">
3
- <package-json value="$PROJECT_DIR$/package.json" />
4
- <command value="run" />
5
- <scripts>
6
- <script value="build" />
7
- </scripts>
8
- <node-interpreter value="project" />
9
- <envs />
10
- <method v="2" />
11
- </configuration>
12
- </component>
@@ -1,12 +0,0 @@
1
- <component name="ProjectRunConfigurationManager">
2
- <configuration default="false" name="eslint" type="js.build_tools.npm" nameIsGenerated="true">
3
- <package-json value="$PROJECT_DIR$/package.json" />
4
- <command value="run" />
5
- <scripts>
6
- <script value="eslint" />
7
- </scripts>
8
- <node-interpreter value="project" />
9
- <envs />
10
- <method v="2" />
11
- </configuration>
12
- </component>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>