@aidc-toolkit/gs1 0.9.11-beta → 0.9.13-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aidc-toolkit/gs1",
3
- "version": "0.9.11-beta",
3
+ "version": "0.9.13-beta",
4
4
  "description": "GS1 AIDC Toolkit",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,22 +20,20 @@
20
20
  },
21
21
  "scripts": {
22
22
  "lint": "eslint .",
23
- "build-dist": "tsup src/index.ts --clean --format cjs,esm --dts",
24
- "build-doc": "npm run build-dist && tsc src/index.ts --outDir dist --target esnext --moduleResolution nodenext --module nodenext --emitDeclarationOnly --declaration --declarationMap",
23
+ "build:core": "tsup src/index.ts --format cjs,esm --dts --clean",
24
+ "build:dev": "npm run build:core && tsc src/index.ts --outDir dist --target esnext --moduleResolution nodenext --module nodenext --emitDeclarationOnly --declaration --declarationMap",
25
+ "build:release": "npm run build:core -- --minify",
26
+ "publish-dev": "publish-dev",
25
27
  "test": "vitest run"
26
28
  },
27
29
  "devDependencies": {
28
- "@aidc-toolkit/dev": "^0.9.11-beta",
29
- "eslint": "^9.18.0",
30
- "ts-node": "^10.9.2",
31
- "tsup": "^8.3.5",
32
- "typescript": "^5.7.3",
33
- "vitest": "^2.1.8"
30
+ "@aidc-toolkit/dev": "^0.9.13-beta",
31
+ "vitest": "^3.0.5"
34
32
  },
35
33
  "dependencies": {
36
- "@aidc-toolkit/core": "^0.9.11-beta",
37
- "@aidc-toolkit/utility": "^0.9.11-beta",
38
- "i18next": "^24.2.1",
34
+ "@aidc-toolkit/core": "^0.9.13-beta",
35
+ "@aidc-toolkit/utility": "^0.9.13-beta",
36
+ "i18next": "^24.2.2",
39
37
  "ts-mixer": "^6.0.4"
40
38
  }
41
39
  }
package/src/idkey.ts CHANGED
@@ -1823,6 +1823,11 @@ export class PrefixManager {
1823
1823
  */
1824
1824
  private readonly _gs18Prefix: string | undefined;
1825
1825
 
1826
+ /**
1827
+ * Default tweak factor.
1828
+ */
1829
+ private readonly _defaultTweakFactor: bigint;
1830
+
1826
1831
  /**
1827
1832
  * Tweak factor.
1828
1833
  */
@@ -1856,6 +1861,9 @@ export class PrefixManager {
1856
1861
  this._prefix = this._gs18Prefix;
1857
1862
  }
1858
1863
 
1864
+ // Default tweak factor is the numeric value of the GS1 Company Prefix preceded by '1'.
1865
+ this._defaultTweakFactor = BigInt(`1${this.gs1CompanyPrefix}`);
1866
+
1859
1867
  this.resetTweakFactor();
1860
1868
  }
1861
1869
 
@@ -1939,8 +1947,7 @@ export class PrefixManager {
1939
1947
  * Reset the tweak factor to its default (numeric value of the GS1 Company Prefix preceded by '1').
1940
1948
  */
1941
1949
  resetTweakFactor(): void {
1942
- // Default tweak factor is the numeric value of the GS1 Company Prefix preceded by '1'.
1943
- this.tweakFactor = BigInt("1" + this.gs1CompanyPrefix);
1950
+ this.tweakFactor = this._defaultTweakFactor;
1944
1951
  }
1945
1952
 
1946
1953
  /**
@@ -1972,6 +1979,10 @@ export class PrefixManager {
1972
1979
  case PrefixType.GS18Prefix:
1973
1980
  gs1CompanyPrefix = "00000" + prefix;
1974
1981
  break;
1982
+
1983
+ // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- Method may be called by unsafe means.
1984
+ default:
1985
+ throw new RangeError(i18nextGS1.t("Prefix.invalidPrefixType"));
1975
1986
  }
1976
1987
 
1977
1988
  let prefixManager = PrefixManager.PREFIX_MANAGERS_MAP.get(gs1CompanyPrefix);
@@ -26,6 +26,7 @@ export const localeStrings = {
26
26
  gs1CompanyPrefix: "GS1 Company Prefix",
27
27
  upcCompanyPrefix: "U.P.C. Company Prefix",
28
28
  gs18Prefix: "GS1-8 Prefix",
29
+ invalidPrefixType: "Invalid prefix type",
29
30
  gs1CompanyPrefixCantStartWith0: "GS1 Company Prefix can't start with \"0\"",
30
31
  gs1CompanyPrefixCantStartWith00000: "GS1 Company Prefix can't start with \"00000\"",
31
32
  gs1CompanyPrefixCantStartWith000000: "GS1 Company Prefix can't start with \"000000\"",
@@ -26,6 +26,7 @@ export const localeStrings = {
26
26
  gs1CompanyPrefix: "Préfixe de l'entreprise GS1",
27
27
  upcCompanyPrefix: "Préfixe de l'entreprise U.P.C.",
28
28
  gs18Prefix: "Préfixe GS1-8",
29
+ invalidPrefixType: "Type de préfixe invalide",
29
30
  gs1CompanyPrefixCantStartWith0: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"0\"",
30
31
  gs1CompanyPrefixCantStartWith00000: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"00000\"",
31
32
  gs1CompanyPrefixCantStartWith000000: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"000000\"",
@@ -420,7 +420,10 @@ function testNumericIdentificationKeyCreator(creator: NumericIdentificationKeyCr
420
420
  expect(hasValidCheckDigit(identificationKey)).toBe(true);
421
421
  }
422
422
 
423
- test("Straight", () => {
423
+ test("Straight", {
424
+ // Test can take a long time.
425
+ timeout: 20 * 1000
426
+ }, () => {
424
427
  expect(creator.referenceLength).toBe(referenceLength);
425
428
  expect(creator.capacity).toBe(Number(CharacterSetCreator.powerOf10(referenceLength)));
426
429
 
File without changes