@aidc-toolkit/gs1 1.0.22-beta → 1.0.23-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/locale/en/{locale-strings.d.ts → locale-resources.d.ts} +3 -2
- package/dist/locale/en/locale-resources.d.ts.map +1 -0
- package/dist/locale/en/{locale-strings.js → locale-resources.js} +2 -2
- package/dist/locale/en/locale-resources.js.map +1 -0
- package/dist/locale/fr/{locale-strings.d.ts → locale-resources.d.ts} +4 -3
- package/dist/locale/fr/locale-resources.d.ts.map +1 -0
- package/dist/locale/fr/{locale-strings.js → locale-resources.js} +3 -3
- package/dist/locale/fr/locale-resources.js.map +1 -0
- package/dist/locale/i18n.d.ts +2 -2
- package/dist/locale/i18n.d.ts.map +1 -1
- package/dist/locale/i18n.js +5 -5
- package/dist/locale/i18n.js.map +1 -1
- package/dist/prefix-manager.d.ts +4 -4
- package/dist/prefix-manager.d.ts.map +1 -1
- package/dist/prefix-manager.js +21 -21
- package/dist/prefix-manager.js.map +1 -1
- package/package.json +1 -1
- 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 -6
- package/src/locale/i18next.d.ts +4 -4
- package/src/prefix-manager.ts +21 -20
- package/dist/locale/en/locale-strings.d.ts.map +0 -1
- package/dist/locale/en/locale-strings.js.map +0 -1
- package/dist/locale/fr/locale-strings.d.ts.map +0 -1
- package/dist/locale/fr/locale-strings.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
declare const _default: {
|
|
2
2
|
readonly Check: {
|
|
3
3
|
readonly lengthOfStringForPriceOrWeightMustBeExactly: "Length {{length, number}} of string for price or weight must be 4 or 5";
|
|
4
4
|
readonly priceOrWeightComponent: "price or weight";
|
|
@@ -39,4 +39,5 @@ export declare const localeStrings: {
|
|
|
39
39
|
readonly identifierTypeNotSupportedByGS18Prefix: "{{identifierType}} not supported by GS1-8 Prefix";
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
export default _default;
|
|
43
|
+
//# sourceMappingURL=locale-resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-resources.d.ts","sourceRoot":"","sources":["../../../src/locale/en/locale-resources.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAwCW"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
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",
|
|
@@ -39,4 +39,4 @@ export const localeStrings = {
|
|
|
39
39
|
identifierTypeNotSupportedByGS18Prefix: "{{identifierType}} not supported by GS1-8 Prefix"
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
//# sourceMappingURL=locale-
|
|
42
|
+
//# sourceMappingURL=locale-resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-resources.js","sourceRoot":"","sources":["../../../src/locale/en/locale-resources.ts"],"names":[],"mappings":"AAAA,eAAe;IACX,KAAK,EAAE;QACH,2CAA2C,EAAE,wEAAwE;QACrH,sBAAsB,EAAE,iBAAiB;QACzC,0DAA0D,EAAE,sHAAsH;KACrL;IACD,UAAU,EAAE;QACR,oBAAoB,EAAE,2DAA2D;QACjF,iBAAiB,EAAE,qBAAqB;QACxC,iBAAiB,EAAE,2CAA2C;QAC9D,mBAAmB,EAAE,6BAA6B;QAClD,2BAA2B,EAAE,iCAAiC;QAC9D,6BAA6B,EAAE,+BAA+B;QAC9D,mCAAmC,EAAE,4CAA4C;QACjF,mCAAmC,EAAE,4CAA4C;QACjF,qBAAqB,EAAE,mEAAmE;QAC1F,mBAAmB,EAAE,wDAAwD;QAC7E,4BAA4B,EAAE,mEAAmE;QACjG,gBAAgB,EAAE,qCAAqC;QACvD,+BAA+B,EAAE,qCAAqC;QACtE,+BAA+B,EAAE,qCAAqC;QACtE,mCAAmC,EAAE,0CAA0C;QAC/E,cAAc,EAAE,iBAAiB;QACjC,eAAe,EAAE,kBAAkB;QACnC,SAAS,EAAE,WAAW;QACtB,yBAAyB,EAAE,gCAAgC;QAC3D,yBAAyB,EAAE,8BAA8B;KAC5D;IACD,MAAM,EAAE;QACJ,gBAAgB,EAAE,oBAAoB;QACtC,gBAAgB,EAAE,uBAAuB;QACzC,UAAU,EAAE,cAAc;QAC1B,iBAAiB,EAAE,qBAAqB;QACxC,8BAA8B,EAAE,2CAA2C;QAC3E,kCAAkC,EAAE,+CAA+C;QACnF,mCAAmC,EAAE,gDAAgD;QACrF,iCAAiC,EAAE,iDAAiD;QACpF,wBAAwB,EAAE,qCAAqC;QAC/D,sCAAsC,EAAE,kDAAkD;KAC7F;CACK,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
declare const _default: {
|
|
2
2
|
readonly Check: {
|
|
3
3
|
readonly lengthOfStringForPriceOrWeightMustBeExactly: "La longueur {{length, number}} de la chaîne pour le prix ou le poids doit être 4 ou 5";
|
|
4
4
|
readonly priceOrWeightComponent: "prix ou poids";
|
|
5
|
-
readonly lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "La longueur {{length, number}} de la chaîne pour la paire de caractères de vérification doit être inférieure ou égale à {{
|
|
5
|
+
readonly 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
|
readonly Identifier: {
|
|
8
8
|
readonly identifierTypeLength: "{{identifierType}} doit comporter {{length, number}} chiffres";
|
|
@@ -39,4 +39,5 @@ export declare const localeStrings: {
|
|
|
39
39
|
readonly identifierTypeNotSupportedByGS18Prefix: "{{identifierType}} non pris en charge par le préfixe GS1-8";
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
export default _default;
|
|
43
|
+
//# sourceMappingURL=locale-resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-resources.d.ts","sourceRoot":"","sources":["../../../src/locale/fr/locale-resources.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAwCW"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
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 à {{
|
|
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",
|
|
@@ -39,4 +39,4 @@ export const localeStrings = {
|
|
|
39
39
|
identifierTypeNotSupportedByGS18Prefix: "{{identifierType}} non pris en charge par le préfixe GS1-8"
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
//# sourceMappingURL=locale-
|
|
42
|
+
//# sourceMappingURL=locale-resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-resources.js","sourceRoot":"","sources":["../../../src/locale/fr/locale-resources.ts"],"names":[],"mappings":"AAAA,eAAe;IACX,KAAK,EAAE;QACH,2CAA2C,EAAE,uFAAuF;QACpI,sBAAsB,EAAE,eAAe;QACvC,0DAA0D,EAAE,mJAAmJ;KAClN;IACD,UAAU,EAAE;QACR,oBAAoB,EAAE,+DAA+D;QACrF,iBAAiB,EAAE,gCAAgC;QACnD,iBAAiB,EAAE,iDAAiD;QACpE,mBAAmB,EAAE,oCAAoC;QACzD,2BAA2B,EAAE,4CAA4C;QACzE,6BAA6B,EAAE,+CAA+C;QAC9E,mCAAmC,EAAE,2DAA2D;QAChG,mCAAmC,EAAE,2DAA2D;QAChG,qBAAqB,EAAE,4FAA4F;QACnH,mBAAmB,EAAE,mFAAmF;QACxG,4BAA4B,EAAE,qGAAqG;QACnI,gBAAgB,EAAE,8DAA8D;QAChF,+BAA+B,EAAE,0CAA0C;QAC3E,+BAA+B,EAAE,2CAA2C;QAC5E,mCAAmC,EAAE,0CAA0C;QAC/E,cAAc,EAAE,oBAAoB;QACpC,eAAe,EAAE,iBAAiB;QAClC,SAAS,EAAE,WAAW;QACtB,yBAAyB,EAAE,qDAAqD;QAChF,yBAAyB,EAAE,4CAA4C;KAC1E;IACD,MAAM,EAAE;QACJ,gBAAgB,EAAE,6BAA6B;QAC/C,gBAAgB,EAAE,gCAAgC;QAClD,UAAU,EAAE,eAAe;QAC3B,iBAAiB,EAAE,0BAA0B;QAC7C,8BAA8B,EAAE,gEAAgE;QAChG,kCAAkC,EAAE,oEAAoE;QACxG,mCAAmC,EAAE,qEAAqE;QAC1G,iCAAiC,EAAE,sEAAsE;QACzG,wBAAwB,EAAE,kDAAkD;QAC5E,sCAAsC,EAAE,4DAA4D;KACvG;CACK,CAAC"}
|
package/dist/locale/i18n.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type I18nEnvironment } from "@aidc-toolkit/core";
|
|
2
2
|
import { type i18n, type Resource } from "i18next";
|
|
3
|
-
import
|
|
3
|
+
import enLocaleResources from "./en/locale-resources.js";
|
|
4
4
|
export declare const gs1NS = "aidct_gs1";
|
|
5
5
|
/**
|
|
6
6
|
* Locale strings type is extracted from the English locale strings object.
|
|
7
7
|
*/
|
|
8
|
-
export type
|
|
8
|
+
export type GS1LocaleResources = typeof enLocaleResources;
|
|
9
9
|
/**
|
|
10
10
|
* GS1 resources.
|
|
11
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAElG,OAAgB,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAElG,OAAgB,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AAGzD,eAAO,MAAM,KAAK,cAAc,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,iBAAiB,CAAC;AAI1D;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,QAO1B,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,IAA+B,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAG5F"}
|
package/dist/locale/i18n.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { i18nAssertValidResources, i18nCoreInit } from "@aidc-toolkit/core";
|
|
2
2
|
import { i18nUtilityInit, utilityResources } from "@aidc-toolkit/utility";
|
|
3
3
|
import i18next from "i18next";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import enLocaleResources from "./en/locale-resources.js";
|
|
5
|
+
import frLocaleResources from "./fr/locale-resources.js";
|
|
6
6
|
export const gs1NS = "aidct_gs1";
|
|
7
|
-
i18nAssertValidResources(
|
|
7
|
+
i18nAssertValidResources(enLocaleResources, "fr", frLocaleResources);
|
|
8
8
|
/**
|
|
9
9
|
* GS1 resources.
|
|
10
10
|
*/
|
|
11
11
|
export const gs1Resources = {
|
|
12
12
|
en: {
|
|
13
|
-
aidct_gs1:
|
|
13
|
+
aidct_gs1: enLocaleResources
|
|
14
14
|
},
|
|
15
15
|
fr: {
|
|
16
|
-
aidct_gs1:
|
|
16
|
+
aidct_gs1: frLocaleResources
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
// Explicit type is necessary to work around bug in type discovery with linked packages.
|
package/dist/locale/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,iBAAiB,MAAM,0BAA0B,CAAC;AACzD,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC;AAOjC,wBAAwB,CAAC,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAa;IAClC,EAAE,EAAE;QACA,SAAS,EAAE,iBAAiB;KAC/B;IACD,EAAE,EAAE;QACA,SAAS,EAAE,iBAAiB;KAC/B;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"}
|
package/dist/prefix-manager.d.ts
CHANGED
|
@@ -31,10 +31,10 @@ export declare class PrefixManager implements PrefixProvider {
|
|
|
31
31
|
*/
|
|
32
32
|
private static readonly PREFIX_MANAGERS_MAP;
|
|
33
33
|
/**
|
|
34
|
-
* Creator tweak factors. Different numeric identifier types have different tweak factors so that sparse
|
|
35
|
-
*
|
|
34
|
+
* Creator tweak factors. Different numeric identifier types have different tweak factors so that sparse creation
|
|
35
|
+
* generates different sequences for each.
|
|
36
36
|
*/
|
|
37
|
-
private static readonly
|
|
37
|
+
private static readonly CREATOR_TWEAK_FACTORS;
|
|
38
38
|
/**
|
|
39
39
|
* Normalized prefix type.
|
|
40
40
|
*/
|
|
@@ -66,7 +66,7 @@ export declare class PrefixManager implements PrefixProvider {
|
|
|
66
66
|
/**
|
|
67
67
|
* Cached identifier creators.
|
|
68
68
|
*/
|
|
69
|
-
private readonly
|
|
69
|
+
private readonly _identifierCreators;
|
|
70
70
|
/**
|
|
71
71
|
* Constructor.
|
|
72
72
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix-manager.d.ts","sourceRoot":"","sources":["../src/prefix-manager.ts"],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;OAEG;IACH,IAAI,WAAW,IAAI,+BAA+B,CAEjD;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,oCAAoC,CAErD;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,2BAA2B,CAE7C;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,2BAA2B,CAE5C;CACJ"}
|
package/dist/prefix-manager.js
CHANGED
|
@@ -37,19 +37,19 @@ export class PrefixManager {
|
|
|
37
37
|
*/
|
|
38
38
|
static PREFIX_MANAGERS_MAP = new Map();
|
|
39
39
|
/**
|
|
40
|
-
* Creator tweak factors. Different numeric identifier types have different tweak factors so that sparse
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
static
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
* Creator tweak factors. Different numeric identifier types have different tweak factors so that sparse creation
|
|
41
|
+
* generates different sequences for each.
|
|
42
|
+
*/
|
|
43
|
+
static CREATOR_TWEAK_FACTORS = {
|
|
44
|
+
GTIN: 1987n,
|
|
45
|
+
GLN: 4241n,
|
|
46
|
+
SSCC: 8087n,
|
|
47
|
+
GRAI: 3221n,
|
|
48
|
+
GSRN: 2341n,
|
|
49
|
+
GDTI: 7333n,
|
|
50
|
+
GSIN: 5623n,
|
|
51
|
+
GCN: 6869n
|
|
52
|
+
};
|
|
53
53
|
/**
|
|
54
54
|
* Normalized prefix type.
|
|
55
55
|
*/
|
|
@@ -81,7 +81,7 @@ export class PrefixManager {
|
|
|
81
81
|
/**
|
|
82
82
|
* Cached identifier creators.
|
|
83
83
|
*/
|
|
84
|
-
|
|
84
|
+
_identifierCreators = {};
|
|
85
85
|
/**
|
|
86
86
|
* Constructor.
|
|
87
87
|
*
|
|
@@ -146,10 +146,10 @@ export class PrefixManager {
|
|
|
146
146
|
* Identifier creator.
|
|
147
147
|
*/
|
|
148
148
|
setCreatorTweak(creator) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion,no-param-reassign --
|
|
149
|
+
if (creator.identifierType in PrefixManager.CREATOR_TWEAK_FACTORS) {
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type is known by testing for presence in record.
|
|
151
|
+
const creatorTweakFactor = PrefixManager.CREATOR_TWEAK_FACTORS[creator.identifierType];
|
|
152
|
+
// 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.
|
|
153
153
|
creator.tweak = this.tweakFactor * creatorTweakFactor;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -169,7 +169,7 @@ export class PrefixManager {
|
|
|
169
169
|
const tweakFactor = BigInt(value);
|
|
170
170
|
if (this._tweakFactor !== tweakFactor) {
|
|
171
171
|
this._tweakFactor = tweakFactor;
|
|
172
|
-
for (const creator of
|
|
172
|
+
for (const creator of Object.values(this._identifierCreators)) {
|
|
173
173
|
this.setCreatorTweak(creator);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
@@ -230,7 +230,7 @@ export class PrefixManager {
|
|
|
230
230
|
*/
|
|
231
231
|
getIdentifierCreator(identifierType, constructorCallback) {
|
|
232
232
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type is paired with constructor callback.
|
|
233
|
-
let creator = this.
|
|
233
|
+
let creator = this._identifierCreators[identifierType];
|
|
234
234
|
if (creator === undefined) {
|
|
235
235
|
if (this.prefixType === PrefixTypes.GS18Prefix && identifierType !== IdentifierTypes.GTIN) {
|
|
236
236
|
throw new RangeError(i18nextGS1.t("Prefix.identifierTypeNotSupportedByGS18Prefix", {
|
|
@@ -239,7 +239,7 @@ export class PrefixManager {
|
|
|
239
239
|
}
|
|
240
240
|
creator = constructorCallback();
|
|
241
241
|
this.setCreatorTweak(creator);
|
|
242
|
-
this.
|
|
242
|
+
this._identifierCreators[identifierType] = creator;
|
|
243
243
|
}
|
|
244
244
|
return creator;
|
|
245
245
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix-manager.js","sourceRoot":"","sources":["../src/prefix-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAiB,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAuB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAC3F,OAAO,EACH,aAAa,EACb,cAAc,EACd,cAAc,EAEd,cAAc,EACjB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EACH,cAAc,EACd,cAAc,EACd,cAAc,EACd,aAAa,EAEhB,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"prefix-manager.js","sourceRoot":"","sources":["../src/prefix-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAiB,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAuB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAC3F,OAAO,EACH,aAAa,EACb,cAAc,EACd,cAAc,EAEd,cAAc,EACjB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EACH,cAAc,EACd,cAAc,EACd,cAAc,EACd,aAAa,EAEhB,MAAM,uCAAuC,CAAC;AAI/C,OAAO,EA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OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,uCAAuC,CAAC,cAAc,CAAC,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,8BAA8B,CAAC,cAAc,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,kCAAkC,CAAC,cAAc,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,uCAAuC,CAAC,cAAc,CAAC,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,8BAA8B,CAAC,cAAc,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,kCAAkC,CAAC,cAAc,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,uCAAuC,CAAC,aAAa,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,8BAA8B,CAAC,cAAc,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,8BAA8B,CAAC,aAAa,CAAC,CAAC;IAC9D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
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 à {{
|
|
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",
|
package/src/locale/i18n.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { i18nAssertValidResources, 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
|
|
5
|
-
import
|
|
4
|
+
import enLocaleResources from "./en/locale-resources.js";
|
|
5
|
+
import frLocaleResources from "./fr/locale-resources.js";
|
|
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
|
|
12
|
+
export type GS1LocaleResources = typeof enLocaleResources;
|
|
13
13
|
|
|
14
|
-
i18nAssertValidResources(
|
|
14
|
+
i18nAssertValidResources(enLocaleResources, "fr", frLocaleResources);
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* GS1 resources.
|
|
18
18
|
*/
|
|
19
19
|
export const gs1Resources: Resource = {
|
|
20
20
|
en: {
|
|
21
|
-
aidct_gs1:
|
|
21
|
+
aidct_gs1: enLocaleResources
|
|
22
22
|
},
|
|
23
23
|
fr: {
|
|
24
|
-
aidct_gs1:
|
|
24
|
+
aidct_gs1: frLocaleResources
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
|
package/src/locale/i18next.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { UtilityLocaleResources } from "@aidc-toolkit/utility";
|
|
2
|
+
import type { GS1LocaleResources } from "./i18n.js";
|
|
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:
|
|
15
|
-
aidct_gs1:
|
|
14
|
+
aidct_utility: UtilityLocaleResources;
|
|
15
|
+
aidct_gs1: GS1LocaleResources;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
}
|
package/src/prefix-manager.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
type NonNumericIdentifierValidator
|
|
21
21
|
} from "./non-numeric-identifier-validator.js";
|
|
22
22
|
import type { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
|
|
23
|
+
import type { NumericIdentifierType } from "./numeric-identifier-validator.js";
|
|
23
24
|
import type { PrefixProvider } from "./prefix-provider.js";
|
|
24
25
|
import { type PrefixType, PrefixTypes } from "./prefix-type.js";
|
|
25
26
|
import { PrefixValidator } from "./prefix-validator.js";
|
|
@@ -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
|
-
*
|
|
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
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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.
|
|
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.
|
|
301
|
+
this._identifierCreators[identifierType] = creator;
|
|
301
302
|
}
|
|
302
303
|
|
|
303
304
|
return creator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale-strings.d.ts","sourceRoot":"","sources":["../../../src/locale/en/locale-strings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwChB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale-strings.js","sourceRoot":"","sources":["../../../src/locale/en/locale-strings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,KAAK,EAAE;QACH,2CAA2C,EAAE,wEAAwE;QACrH,sBAAsB,EAAE,iBAAiB;QACzC,0DAA0D,EAAE,sHAAsH;KACrL;IACD,UAAU,EAAE;QACR,oBAAoB,EAAE,2DAA2D;QACjF,iBAAiB,EAAE,qBAAqB;QACxC,iBAAiB,EAAE,2CAA2C;QAC9D,mBAAmB,EAAE,6BAA6B;QAClD,2BAA2B,EAAE,iCAAiC;QAC9D,6BAA6B,EAAE,+BAA+B;QAC9D,mCAAmC,EAAE,4CAA4C;QACjF,mCAAmC,EAAE,4CAA4C;QACjF,qBAAqB,EAAE,mEAAmE;QAC1F,mBAAmB,EAAE,wDAAwD;QAC7E,4BAA4B,EAAE,mEAAmE;QACjG,gBAAgB,EAAE,qCAAqC;QACvD,+BAA+B,EAAE,qCAAqC;QACtE,+BAA+B,EAAE,qCAAqC;QACtE,mCAAmC,EAAE,0CAA0C;QAC/E,cAAc,EAAE,iBAAiB;QACjC,eAAe,EAAE,kBAAkB;QACnC,SAAS,EAAE,WAAW;QACtB,yBAAyB,EAAE,gCAAgC;QAC3D,yBAAyB,EAAE,8BAA8B;KAC5D;IACD,MAAM,EAAE;QACJ,gBAAgB,EAAE,oBAAoB;QACtC,gBAAgB,EAAE,uBAAuB;QACzC,UAAU,EAAE,cAAc;QAC1B,iBAAiB,EAAE,qBAAqB;QACxC,8BAA8B,EAAE,2CAA2C;QAC3E,kCAAkC,EAAE,+CAA+C;QACnF,mCAAmC,EAAE,gDAAgD;QACrF,iCAAiC,EAAE,iDAAiD;QACpF,wBAAwB,EAAE,qCAAqC;QAC/D,sCAAsC,EAAE,kDAAkD;KAC7F;CACK,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale-strings.d.ts","sourceRoot":"","sources":["../../../src/locale/fr/locale-strings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwChB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale-strings.js","sourceRoot":"","sources":["../../../src/locale/fr/locale-strings.ts"],"names":[],"mappings":"A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