@aidc-toolkit/utility 1.0.25-beta → 1.0.27-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 (71) hide show
  1. package/dist/character-set.d.ts +222 -0
  2. package/dist/character-set.d.ts.map +1 -0
  3. package/dist/character-set.js +568 -0
  4. package/dist/character-set.js.map +1 -0
  5. package/dist/exclusion.d.ts +26 -0
  6. package/dist/exclusion.d.ts.map +1 -0
  7. package/dist/exclusion.js +18 -0
  8. package/dist/exclusion.js.map +1 -0
  9. package/dist/index.d.ts +26 -953
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +8 -3505
  12. package/dist/index.js.map +1 -1
  13. package/dist/iterable-utility.d.ts +39 -0
  14. package/dist/iterable-utility.d.ts.map +1 -0
  15. package/dist/iterable-utility.js +35 -0
  16. package/dist/iterable-utility.js.map +1 -0
  17. package/dist/locale/en/locale-resources.d.ts +33 -0
  18. package/dist/locale/en/locale-resources.d.ts.map +1 -0
  19. package/dist/locale/en/locale-resources.js +32 -0
  20. package/dist/locale/en/locale-resources.js.map +1 -0
  21. package/dist/locale/fr/locale-resources.d.ts +33 -0
  22. package/dist/locale/fr/locale-resources.d.ts.map +1 -0
  23. package/dist/locale/fr/locale-resources.js +32 -0
  24. package/dist/locale/fr/locale-resources.js.map +1 -0
  25. package/dist/locale/i18n.d.ts +27 -0
  26. package/dist/locale/i18n.d.ts.map +1 -0
  27. package/dist/locale/i18n.js +34 -0
  28. package/dist/locale/i18n.js.map +1 -0
  29. package/dist/record.d.ts +37 -0
  30. package/dist/record.d.ts.map +1 -0
  31. package/dist/record.js +58 -0
  32. package/dist/record.js.map +1 -0
  33. package/dist/reg-exp.d.ts +40 -0
  34. package/dist/reg-exp.d.ts.map +1 -0
  35. package/dist/reg-exp.js +55 -0
  36. package/dist/reg-exp.js.map +1 -0
  37. package/dist/sequence.d.ts +45 -0
  38. package/dist/sequence.d.ts.map +1 -0
  39. package/dist/sequence.js +96 -0
  40. package/dist/sequence.js.map +1 -0
  41. package/dist/string.d.ts +25 -0
  42. package/dist/string.d.ts.map +1 -0
  43. package/dist/string.js +2 -0
  44. package/dist/string.js.map +1 -0
  45. package/dist/transformer.d.ts +196 -0
  46. package/dist/transformer.d.ts.map +1 -0
  47. package/dist/transformer.js +457 -0
  48. package/dist/transformer.js.map +1 -0
  49. package/package.json +10 -6
  50. package/src/character-set.ts +62 -59
  51. package/src/index.ts +9 -9
  52. package/src/locale/i18n.ts +3 -3
  53. package/src/locale/i18next.d.ts +1 -1
  54. package/src/record.ts +8 -8
  55. package/src/reg-exp.ts +6 -6
  56. package/src/sequence.ts +21 -21
  57. package/src/transformer.ts +54 -54
  58. package/test/character-set.test.ts +1 -1
  59. package/test/record.test.ts +1 -1
  60. package/test/reg-exp.test.ts +1 -1
  61. package/test/sequence.test.ts +1 -1
  62. package/test/setup.ts +1 -1
  63. package/test/transformer.test.ts +1 -6
  64. package/tsconfig-config.json +4 -0
  65. package/tsconfig-src.json +8 -0
  66. package/tsconfig-test.json +9 -0
  67. package/tsconfig.json +12 -1
  68. package/tsup.config.ts +3 -2
  69. package/dist/index.cjs +0 -3570
  70. package/dist/index.cjs.map +0 -1
  71. package/dist/index.d.cts +0 -953
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Map an input iterable to an output iterable that applies a transformer callback to each value in the input.
3
+ *
4
+ * @template TInput
5
+ * Input type.
6
+ *
7
+ * @template TOutput
8
+ * Output type.
9
+ *
10
+ * @param values
11
+ * Input values iterable.
12
+ *
13
+ * @param indexedCallback
14
+ * Callback to transform input value to output value.
15
+ *
16
+ * @returns
17
+ * Output values iterable.
18
+ */
19
+ export function mapIterable(values, indexedCallback) {
20
+ return {
21
+ /**
22
+ * Iterable implementation.
23
+ *
24
+ * @yields
25
+ * Next output value.
26
+ */
27
+ *[Symbol.iterator]() {
28
+ let index = 0;
29
+ for (const value of values) {
30
+ yield indexedCallback(value, index++);
31
+ }
32
+ }
33
+ };
34
+ }
35
+ //# sourceMappingURL=iterable-utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterable-utility.js","sourceRoot":"","sources":["../src/iterable-utility.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,WAAW,CAAkB,MAAwB,EAAE,eAAiD;IACpH,OAAO;QACH;;;;;WAKG;QACH,CAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;YACf,IAAI,KAAK,GAAG,CAAC,CAAC;YAEd,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBACzB,MAAM,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YAC1C,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,33 @@
1
+ declare const _default: {
2
+ readonly Transformer: {
3
+ readonly domainMustBeGreaterThanZero: "Domain {{domain, number}} must be greater than 0";
4
+ readonly tweakMustBeGreaterThanOrEqualToZero: "Tweak {{tweak, number}} must be greater than or equal to 0";
5
+ readonly valueMustBeGreaterThanOrEqualToZero: "Value {{value, number}} must be greater than or equal to 0";
6
+ readonly valueMustBeLessThan: "Value {{value, number}} must be less than {{domain, number}}";
7
+ readonly minimumValueMustBeGreaterThanOrEqualToZero: "Minimum value {{minimumValue, number}} must be greater than or equal to 0";
8
+ readonly maximumValueMustBeLessThan: "Maximum value {{maximumValue, number}} must be less than {{domain, number}}";
9
+ };
10
+ readonly RegExpValidator: {
11
+ readonly stringDoesNotMatchPattern: "String {{s}} does not match pattern";
12
+ };
13
+ readonly CharacterSetValidator: {
14
+ readonly firstZeroFirstCharacter: "Character set must support zero as first character";
15
+ readonly allNumericAllNumericCharacters: "Character set must support all numeric characters in sequence";
16
+ readonly stringMustNotBeAllNumeric: "String must not be all numeric";
17
+ readonly lengthMustBeGreaterThanOrEqualTo: "Length {{length, number}} must be greater than or equal to {{minimumLength, number}}";
18
+ readonly lengthMustBeLessThanOrEqualTo: "Length {{length, number}} must be less than or equal to {{maximumLength, number}}";
19
+ readonly lengthMustBeEqualTo: "Length {{length, number}} must be equal to {{exactLength, number}}";
20
+ readonly lengthOfComponentMustBeGreaterThanOrEqualTo: "Length {{length, number}} of {{component}} must be greater than or equal to {{minimumLength, number}}";
21
+ readonly lengthOfComponentMustBeLessThanOrEqualTo: "Length {{length, number}} of {{component}} must be less than or equal to {{maximumLength, number}}";
22
+ readonly lengthOfComponentMustBeEqualTo: "Length {{length, number}} of {{component}} must be equal to {{exactLength, number}}";
23
+ readonly invalidCharacterAtPosition: "Invalid character '{{c}}' at position {{position, number}}";
24
+ readonly invalidCharacterAtPositionOfComponent: "Invalid character '{{c}}' at position {{position, number}} of {{component}}";
25
+ readonly exclusionNotSupported: "Exclusion value of {{exclusion, number}} is not supported";
26
+ readonly endSequenceValueMustBeLessThanOrEqualTo: "End sequence value (start sequence value + count - 1) must be less than {{domain, number}}";
27
+ };
28
+ readonly RecordValidator: {
29
+ readonly typeNameKeyNotFound: "{{typeName}} \"{{key}}\" not found";
30
+ };
31
+ };
32
+ export default _default;
33
+ //# 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,wBA8BW"}
@@ -0,0 +1,32 @@
1
+ export default {
2
+ Transformer: {
3
+ domainMustBeGreaterThanZero: "Domain {{domain, number}} must be greater than 0",
4
+ tweakMustBeGreaterThanOrEqualToZero: "Tweak {{tweak, number}} must be greater than or equal to 0",
5
+ valueMustBeGreaterThanOrEqualToZero: "Value {{value, number}} must be greater than or equal to 0",
6
+ valueMustBeLessThan: "Value {{value, number}} must be less than {{domain, number}}",
7
+ minimumValueMustBeGreaterThanOrEqualToZero: "Minimum value {{minimumValue, number}} must be greater than or equal to 0",
8
+ maximumValueMustBeLessThan: "Maximum value {{maximumValue, number}} must be less than {{domain, number}}"
9
+ },
10
+ RegExpValidator: {
11
+ stringDoesNotMatchPattern: "String {{s}} does not match pattern"
12
+ },
13
+ CharacterSetValidator: {
14
+ firstZeroFirstCharacter: "Character set must support zero as first character",
15
+ allNumericAllNumericCharacters: "Character set must support all numeric characters in sequence",
16
+ stringMustNotBeAllNumeric: "String must not be all numeric",
17
+ lengthMustBeGreaterThanOrEqualTo: "Length {{length, number}} must be greater than or equal to {{minimumLength, number}}",
18
+ lengthMustBeLessThanOrEqualTo: "Length {{length, number}} must be less than or equal to {{maximumLength, number}}",
19
+ lengthMustBeEqualTo: "Length {{length, number}} must be equal to {{exactLength, number}}",
20
+ lengthOfComponentMustBeGreaterThanOrEqualTo: "Length {{length, number}} of {{component}} must be greater than or equal to {{minimumLength, number}}",
21
+ lengthOfComponentMustBeLessThanOrEqualTo: "Length {{length, number}} of {{component}} must be less than or equal to {{maximumLength, number}}",
22
+ lengthOfComponentMustBeEqualTo: "Length {{length, number}} of {{component}} must be equal to {{exactLength, number}}",
23
+ invalidCharacterAtPosition: "Invalid character '{{c}}' at position {{position, number}}",
24
+ invalidCharacterAtPositionOfComponent: "Invalid character '{{c}}' at position {{position, number}} of {{component}}",
25
+ exclusionNotSupported: "Exclusion value of {{exclusion, number}} is not supported",
26
+ endSequenceValueMustBeLessThanOrEqualTo: "End sequence value (start sequence value + count - 1) must be less than {{domain, number}}"
27
+ },
28
+ RecordValidator: {
29
+ typeNameKeyNotFound: "{{typeName}} \"{{key}}\" not found"
30
+ }
31
+ };
32
+ //# 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,WAAW,EAAE;QACT,2BAA2B,EAAE,kDAAkD;QAC/E,mCAAmC,EAAE,4DAA4D;QACjG,mCAAmC,EAAE,4DAA4D;QACjG,mBAAmB,EAAE,8DAA8D;QACnF,0CAA0C,EAAE,2EAA2E;QACvH,0BAA0B,EAAE,6EAA6E;KAC5G;IACD,eAAe,EAAE;QACb,yBAAyB,EAAE,qCAAqC;KACnE;IACD,qBAAqB,EAAE;QACnB,uBAAuB,EAAE,oDAAoD;QAC7E,8BAA8B,EAAE,+DAA+D;QAC/F,yBAAyB,EAAE,gCAAgC;QAC3D,gCAAgC,EAAE,sFAAsF;QACxH,6BAA6B,EAAE,mFAAmF;QAClH,mBAAmB,EAAE,oEAAoE;QACzF,2CAA2C,EAAE,uGAAuG;QACpJ,wCAAwC,EAAE,oGAAoG;QAC9I,8BAA8B,EAAE,qFAAqF;QACrH,0BAA0B,EAAE,4DAA4D;QACxF,qCAAqC,EAAE,6EAA6E;QACpH,qBAAqB,EAAE,2DAA2D;QAClF,uCAAuC,EAAE,4FAA4F;KACxI;IACD,eAAe,EAAE;QACb,mBAAmB,EAAE,oCAAoC;KAC5D;CACK,CAAC"}
@@ -0,0 +1,33 @@
1
+ declare const _default: {
2
+ readonly Transformer: {
3
+ readonly domainMustBeGreaterThanZero: "Le domaine {{domain, number}} doit être supérieur à 0";
4
+ readonly tweakMustBeGreaterThanOrEqualToZero: "Le réglage {{tweak, number}} doit être supérieur ou égal à 0";
5
+ readonly valueMustBeGreaterThanOrEqualToZero: "La valeur {{value, number}} doit être supérieure ou égale à 0";
6
+ readonly valueMustBeLessThan: "La valeur {{value, number}} doit être inférieure à {{domain, number}}";
7
+ readonly minimumValueMustBeGreaterThanOrEqualToZero: "La valeur minimale {{minimumValue, number}} doit être supérieure ou égale à 0";
8
+ readonly maximumValueMustBeLessThan: "La valeur maximale {{maximumValue, number}} doit être inférieure à {{domain, number}}";
9
+ };
10
+ readonly RegExpValidator: {
11
+ readonly stringDoesNotMatchPattern: "La chaîne {{s}} ne correspond pas au modèle";
12
+ };
13
+ readonly CharacterSetValidator: {
14
+ readonly firstZeroFirstCharacter: "Le jeu de caractères doit prendre en charge zéro comme premier caractère";
15
+ readonly allNumericAllNumericCharacters: "Le jeu de caractères doit prendre en charge tous les caractères numériques en séquence";
16
+ readonly stringMustNotBeAllNumeric: "La chaîne ne doit pas être entièrement numérique";
17
+ readonly lengthMustBeGreaterThanOrEqualTo: "La longueur {{length, number}} doit être supérieure ou égale à {{minimumLength, number}}";
18
+ readonly lengthMustBeLessThanOrEqualTo: "La longueur {{length, number}} doit être inférieure ou égale à {{maximumLength, number}}";
19
+ readonly lengthMustBeEqualTo: "La longueur {{length, number}} doit être égale à {{exactLength, number}}";
20
+ readonly lengthOfComponentMustBeGreaterThanOrEqualTo: "La longueur {{length, number}} de {{component}} doit être supérieure ou égale à {{minimumLength, number}}";
21
+ readonly lengthOfComponentMustBeLessThanOrEqualTo: "La longueur {{length, number}} de {{component}} doit être inférieure ou égale à {{maximumLength, number}}";
22
+ readonly lengthOfComponentMustBeEqualTo: "La longueur {{length, number}} de {{component}} doit être égale à {{exactLength, number}}";
23
+ readonly invalidCharacterAtPosition: "Caractère non valide '{{c}}' à la position {{position, number}}";
24
+ readonly invalidCharacterAtPositionOfComponent: "Caractère non valide '{{c}}' à la position {{position, number}} de {{component}}";
25
+ readonly exclusionNotSupported: "La valeur d'exclusion de {{exclusion, number}} n'est pas prise en charge";
26
+ readonly endSequenceValueMustBeLessThanOrEqualTo: "La valeur de la séquence de fin (valeur de la séquence de début + nombre - 1) doit être inférieure à {{domain, number}}";
27
+ };
28
+ readonly RecordValidator: {
29
+ readonly typeNameKeyNotFound: "{{typeName}} \"{{key}}\" introuvable";
30
+ };
31
+ };
32
+ export default _default;
33
+ //# 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,wBA8BW"}
@@ -0,0 +1,32 @@
1
+ export default {
2
+ Transformer: {
3
+ domainMustBeGreaterThanZero: "Le domaine {{domain, number}} doit être supérieur à 0",
4
+ tweakMustBeGreaterThanOrEqualToZero: "Le réglage {{tweak, number}} doit être supérieur ou égal à 0",
5
+ valueMustBeGreaterThanOrEqualToZero: "La valeur {{value, number}} doit être supérieure ou égale à 0",
6
+ valueMustBeLessThan: "La valeur {{value, number}} doit être inférieure à {{domain, number}}",
7
+ minimumValueMustBeGreaterThanOrEqualToZero: "La valeur minimale {{minimumValue, number}} doit être supérieure ou égale à 0",
8
+ maximumValueMustBeLessThan: "La valeur maximale {{maximumValue, number}} doit être inférieure à {{domain, number}}"
9
+ },
10
+ RegExpValidator: {
11
+ stringDoesNotMatchPattern: "La chaîne {{s}} ne correspond pas au modèle"
12
+ },
13
+ CharacterSetValidator: {
14
+ firstZeroFirstCharacter: "Le jeu de caractères doit prendre en charge zéro comme premier caractère",
15
+ allNumericAllNumericCharacters: "Le jeu de caractères doit prendre en charge tous les caractères numériques en séquence",
16
+ stringMustNotBeAllNumeric: "La chaîne ne doit pas être entièrement numérique",
17
+ lengthMustBeGreaterThanOrEqualTo: "La longueur {{length, number}} doit être supérieure ou égale à {{minimumLength, number}}",
18
+ lengthMustBeLessThanOrEqualTo: "La longueur {{length, number}} doit être inférieure ou égale à {{maximumLength, number}}",
19
+ lengthMustBeEqualTo: "La longueur {{length, number}} doit être égale à {{exactLength, number}}",
20
+ lengthOfComponentMustBeGreaterThanOrEqualTo: "La longueur {{length, number}} de {{component}} doit être supérieure ou égale à {{minimumLength, number}}",
21
+ lengthOfComponentMustBeLessThanOrEqualTo: "La longueur {{length, number}} de {{component}} doit être inférieure ou égale à {{maximumLength, number}}",
22
+ lengthOfComponentMustBeEqualTo: "La longueur {{length, number}} de {{component}} doit être égale à {{exactLength, number}}",
23
+ invalidCharacterAtPosition: "Caractère non valide '{{c}}' à la position {{position, number}}",
24
+ invalidCharacterAtPositionOfComponent: "Caractère non valide '{{c}}' à la position {{position, number}} de {{component}}",
25
+ exclusionNotSupported: "La valeur d'exclusion de {{exclusion, number}} n'est pas prise en charge",
26
+ endSequenceValueMustBeLessThanOrEqualTo: "La valeur de la séquence de fin (valeur de la séquence de début + nombre - 1) doit être inférieure à {{domain, number}}"
27
+ },
28
+ RecordValidator: {
29
+ typeNameKeyNotFound: "{{typeName}} \"{{key}}\" introuvable"
30
+ }
31
+ };
32
+ //# 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,WAAW,EAAE;QACT,2BAA2B,EAAE,uDAAuD;QACpF,mCAAmC,EAAE,8DAA8D;QACnG,mCAAmC,EAAE,+DAA+D;QACpG,mBAAmB,EAAE,uEAAuE;QAC5F,0CAA0C,EAAE,+EAA+E;QAC3H,0BAA0B,EAAE,uFAAuF;KACtH;IACD,eAAe,EAAE;QACb,yBAAyB,EAAE,6CAA6C;KAC3E;IACD,qBAAqB,EAAE;QACnB,uBAAuB,EAAE,0EAA0E;QACnG,8BAA8B,EAAE,wFAAwF;QACxH,yBAAyB,EAAE,kDAAkD;QAC7E,gCAAgC,EAAE,0FAA0F;QAC5H,6BAA6B,EAAE,0FAA0F;QACzH,mBAAmB,EAAE,0EAA0E;QAC/F,2CAA2C,EAAE,2GAA2G;QACxJ,wCAAwC,EAAE,2GAA2G;QACrJ,8BAA8B,EAAE,2FAA2F;QAC3H,0BAA0B,EAAE,iEAAiE;QAC7F,qCAAqC,EAAE,kFAAkF;QACzH,qBAAqB,EAAE,0EAA0E;QACjG,uCAAuC,EAAE,yHAAyH;KACrK;IACD,eAAe,EAAE;QACb,mBAAmB,EAAE,sCAAsC;KAC9D;CACK,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type I18nEnvironment } from "@aidc-toolkit/core";
2
+ import { type i18n, type Resource } from "i18next";
3
+ import enLocaleResources from "./en/locale-resources.js";
4
+ export declare const utilityNS = "aidct_utility";
5
+ /**
6
+ * Locale strings type is extracted from the English locale strings object.
7
+ */
8
+ export type UtilityLocaleResources = typeof enLocaleResources;
9
+ /**
10
+ * Utility resources.
11
+ */
12
+ export declare const utilityResources: Resource;
13
+ export declare const i18nextUtility: i18n;
14
+ /**
15
+ * Initialize internationalization.
16
+ *
17
+ * @param environment
18
+ * Environment in which the application is running.
19
+ *
20
+ * @param debug
21
+ * Debug setting.
22
+ *
23
+ * @returns
24
+ * Void promise.
25
+ */
26
+ export declare function i18nUtilityInit(environment: I18nEnvironment, debug?: boolean): Promise<void>;
27
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAgB,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AAGzD,eAAO,MAAM,SAAS,kBAAkB,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,iBAAiB,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAO9B,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,IAA+B,CAAC;AAE7D;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhG"}
@@ -0,0 +1,34 @@
1
+ import { i18nCoreInit } from "@aidc-toolkit/core";
2
+ import i18next from "i18next";
3
+ import enLocaleResources from "./en/locale-resources.js";
4
+ import frLocaleResources from "./fr/locale-resources.js";
5
+ export const utilityNS = "aidct_utility";
6
+ /**
7
+ * Utility resources.
8
+ */
9
+ export const utilityResources = {
10
+ en: {
11
+ aidct_utility: enLocaleResources
12
+ },
13
+ fr: {
14
+ aidct_utility: frLocaleResources
15
+ }
16
+ };
17
+ // Explicit type is necessary because type can't be inferred without additional references.
18
+ export const i18nextUtility = i18next.createInstance();
19
+ /**
20
+ * Initialize internationalization.
21
+ *
22
+ * @param environment
23
+ * Environment in which the application is running.
24
+ *
25
+ * @param debug
26
+ * Debug setting.
27
+ *
28
+ * @returns
29
+ * Void promise.
30
+ */
31
+ export async function i18nUtilityInit(environment, debug = false) {
32
+ await i18nCoreInit(i18nextUtility, environment, debug, utilityNS, utilityResources);
33
+ }
34
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AACxE,OAAO,OAAqC,MAAM,SAAS,CAAC;AAC5D,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AACzD,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC;AAOzC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAa;IACtC,EAAE,EAAE;QACA,aAAa,EAAE,iBAAiB;KACnC;IACD,EAAE,EAAE;QACA,aAAa,EAAE,iBAAiB;KACnC;CACJ,CAAC;AAEF,2FAA2F;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAS,OAAO,CAAC,cAAc,EAAE,CAAC;AAE7D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,WAA4B,EAAE,KAAK,GAAG,KAAK;IAC7E,MAAM,YAAY,CAAC,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;AACxF,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { StringValidator } from "./string.js";
2
+ /**
3
+ * Record validator. Validation is performed against a record with a string key type and throws an error if the key is
4
+ * not found.
5
+ *
6
+ * @template T
7
+ * Property type.
8
+ */
9
+ export declare class RecordValidator<T> implements StringValidator {
10
+ #private;
11
+ /**
12
+ * Constructor.
13
+ *
14
+ * @param typeName
15
+ * Type name for error message.
16
+ *
17
+ * @param record
18
+ * Record in which to look up keys.
19
+ */
20
+ constructor(typeName: string, record: Readonly<Record<string, T>>);
21
+ /**
22
+ * Get the type name.
23
+ */
24
+ get typeName(): string;
25
+ /**
26
+ * Get the record.
27
+ */
28
+ get record(): Readonly<Record<string, T>>;
29
+ /**
30
+ * Validate a key by looking it up in the record.
31
+ *
32
+ * @param key
33
+ * Record key.
34
+ */
35
+ validate(key: string): void;
36
+ }
37
+ //# sourceMappingURL=record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;GAMG;AACH,qBAAa,eAAe,CAAC,CAAC,CAAE,YAAW,eAAe;;IAWtD;;;;;;;;OAQG;gBACS,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAKjE;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAExC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAQ9B"}
package/dist/record.js ADDED
@@ -0,0 +1,58 @@
1
+ import { i18nextUtility } from "./locale/i18n.js";
2
+ /**
3
+ * Record validator. Validation is performed against a record with a string key type and throws an error if the key is
4
+ * not found.
5
+ *
6
+ * @template T
7
+ * Property type.
8
+ */
9
+ export class RecordValidator {
10
+ /**
11
+ * Type name for error message.
12
+ */
13
+ #typeName;
14
+ /**
15
+ * Record in which to look up keys.
16
+ */
17
+ #record;
18
+ /**
19
+ * Constructor.
20
+ *
21
+ * @param typeName
22
+ * Type name for error message.
23
+ *
24
+ * @param record
25
+ * Record in which to look up keys.
26
+ */
27
+ constructor(typeName, record) {
28
+ this.#typeName = typeName;
29
+ this.#record = record;
30
+ }
31
+ /**
32
+ * Get the type name.
33
+ */
34
+ get typeName() {
35
+ return this.#typeName;
36
+ }
37
+ /**
38
+ * Get the record.
39
+ */
40
+ get record() {
41
+ return this.#record;
42
+ }
43
+ /**
44
+ * Validate a key by looking it up in the record.
45
+ *
46
+ * @param key
47
+ * Record key.
48
+ */
49
+ validate(key) {
50
+ if (!(key in this.record)) {
51
+ throw new RangeError(i18nextUtility.t("RecordValidator.typeNameKeyNotFound", {
52
+ typeName: this.typeName,
53
+ key
54
+ }));
55
+ }
56
+ }
57
+ }
58
+ //# sourceMappingURL=record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IACxB;;OAEG;IACM,SAAS,CAAS;IAE3B;;OAEG;IACM,OAAO,CAA8B;IAE9C;;;;;;;;OAQG;IACH,YAAY,QAAgB,EAAE,MAAmC;QAC7D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,GAAW;QAChB,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,qCAAqC,EAAE;gBACzE,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,GAAG;aACN,CAAC,CAAC,CAAC;QACR,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,40 @@
1
+ import type { StringValidator } from "./string.js";
2
+ /**
3
+ * Regular expression validator. The regular expression applies to the full string only if constructed as such. For
4
+ * example, <code>&#x2F;\d&#x2A;&#x2F;</code> (0 or more digits) matches every string, <code>&#x2F;\d+&#x2F;</code> (1
5
+ * or more digits) matches strings with at least one digit, <code>&#x2F;^\d&#x2A;$&#x2F;</code> matches strings that are
6
+ * all digits or empty, and <code>&#x2F;^\d+$&#x2F;</code> matches strings that are all digits and not empty.
7
+ *
8
+ * Clients of this class are recommended to override the {@linkcode createErrorMessage | createErrorMessage()} method
9
+ * to create a more suitable error message for their use case.
10
+ */
11
+ export declare class RegExpValidator implements StringValidator {
12
+ #private;
13
+ /**
14
+ * Constructor.
15
+ *
16
+ * @param regExp
17
+ * Regular expression. See {@link RegExpValidator | class documentation} for notes.
18
+ */
19
+ constructor(regExp: RegExp);
20
+ /**
21
+ * Get the regular expression.
22
+ */
23
+ get regExp(): RegExp;
24
+ /**
25
+ * Create an error message for a string. The generic error message is sufficient for many use cases but a more
26
+ * domain-specific error message, possibly including the pattern itself, is often required.
27
+ *
28
+ * @param s
29
+ * String.
30
+ *
31
+ * @returns
32
+ * Error message.
33
+ */
34
+ protected createErrorMessage(s: string): string;
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ validate(s: string): void;
39
+ }
40
+ //# sourceMappingURL=reg-exp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reg-exp.d.ts","sourceRoot":"","sources":["../src/reg-exp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;GAQG;AACH,qBAAa,eAAgB,YAAW,eAAe;;IAMnD;;;;;OAKG;gBACS,MAAM,EAAE,MAAM;IAI1B;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;;;;;OASG;IACH,SAAS,CAAC,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAM/C;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;CAK5B"}
@@ -0,0 +1,55 @@
1
+ import { i18nextUtility } from "./locale/i18n.js";
2
+ /**
3
+ * Regular expression validator. The regular expression applies to the full string only if constructed as such. For
4
+ * example, <code>&#x2F;\d&#x2A;&#x2F;</code> (0 or more digits) matches every string, <code>&#x2F;\d+&#x2F;</code> (1
5
+ * or more digits) matches strings with at least one digit, <code>&#x2F;^\d&#x2A;$&#x2F;</code> matches strings that are
6
+ * all digits or empty, and <code>&#x2F;^\d+$&#x2F;</code> matches strings that are all digits and not empty.
7
+ *
8
+ * Clients of this class are recommended to override the {@linkcode createErrorMessage | createErrorMessage()} method
9
+ * to create a more suitable error message for their use case.
10
+ */
11
+ export class RegExpValidator {
12
+ /**
13
+ * Regular expression.
14
+ */
15
+ #regExp;
16
+ /**
17
+ * Constructor.
18
+ *
19
+ * @param regExp
20
+ * Regular expression. See {@link RegExpValidator | class documentation} for notes.
21
+ */
22
+ constructor(regExp) {
23
+ this.#regExp = regExp;
24
+ }
25
+ /**
26
+ * Get the regular expression.
27
+ */
28
+ get regExp() {
29
+ return this.#regExp;
30
+ }
31
+ /**
32
+ * Create an error message for a string. The generic error message is sufficient for many use cases but a more
33
+ * domain-specific error message, possibly including the pattern itself, is often required.
34
+ *
35
+ * @param s
36
+ * String.
37
+ *
38
+ * @returns
39
+ * Error message.
40
+ */
41
+ createErrorMessage(s) {
42
+ return i18nextUtility.t("RegExpValidator.stringDoesNotMatchPattern", {
43
+ s
44
+ });
45
+ }
46
+ /**
47
+ * @inheritDoc
48
+ */
49
+ validate(s) {
50
+ if (!this.#regExp.test(s)) {
51
+ throw new RangeError(this.createErrorMessage(s));
52
+ }
53
+ }
54
+ }
55
+ //# sourceMappingURL=reg-exp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reg-exp.js","sourceRoot":"","sources":["../src/reg-exp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IACxB;;OAEG;IACM,OAAO,CAAS;IAEzB;;;;;OAKG;IACH,YAAY,MAAc;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;;;;;;OASG;IACO,kBAAkB,CAAC,CAAS;QAClC,OAAO,cAAc,CAAC,CAAC,CAAC,2CAA2C,EAAE;YACjE,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,CAAS;QACd,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Sequence. Defines an ascending or descending sequence of big integers implemented as an iterable.
3
+ */
4
+ export declare class Sequence implements Iterable<bigint> {
5
+ #private;
6
+ /**
7
+ * Constructor.
8
+ *
9
+ * @param startValue
10
+ * Start value.
11
+ *
12
+ * @param count
13
+ * Count of values. If count is zero or positive, iteration ascends from start value, otherwise it descends from
14
+ * start value.
15
+ */
16
+ constructor(startValue: number | bigint, count: number);
17
+ /**
18
+ * Get the start value (inclusive).
19
+ */
20
+ get startValue(): bigint;
21
+ /**
22
+ * Get the end value (exclusive).
23
+ */
24
+ get endValue(): bigint;
25
+ /**
26
+ * Get the count of values.
27
+ */
28
+ get count(): number;
29
+ /**
30
+ * Get the minimum value (inclusive).
31
+ */
32
+ get minimumValue(): bigint;
33
+ /**
34
+ * Get the maximum value (inclusive).
35
+ */
36
+ get maximumValue(): bigint;
37
+ /**
38
+ * Iterable implementation.
39
+ *
40
+ * @yields
41
+ * Next value in sequence.
42
+ */
43
+ [Symbol.iterator](): Generator<bigint>;
44
+ }
45
+ //# sourceMappingURL=sequence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequence.d.ts","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAS,YAAW,QAAQ,CAAC,MAAM,CAAC;;IA+B7C;;;;;;;;;OASG;gBACS,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM;IAgBtD;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;;;;OAKG;IACD,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC;CAK3C"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Sequence. Defines an ascending or descending sequence of big integers implemented as an iterable.
3
+ */
4
+ export class Sequence {
5
+ /**
6
+ * Start value (inclusive).
7
+ */
8
+ #startValue;
9
+ /**
10
+ * End value (exclusive).
11
+ */
12
+ #endValue;
13
+ /**
14
+ * Count of values.
15
+ */
16
+ #count;
17
+ /**
18
+ * Delta to the next value; equal to the sign of the count.
19
+ */
20
+ #nextDelta;
21
+ /**
22
+ * Minimum value (inclusive).
23
+ */
24
+ #minimumValue;
25
+ /**
26
+ * Maximum value (inclusive).
27
+ */
28
+ #maximumValue;
29
+ /**
30
+ * Constructor.
31
+ *
32
+ * @param startValue
33
+ * Start value.
34
+ *
35
+ * @param count
36
+ * Count of values. If count is zero or positive, iteration ascends from start value, otherwise it descends from
37
+ * start value.
38
+ */
39
+ constructor(startValue, count) {
40
+ this.#startValue = BigInt(startValue);
41
+ this.#endValue = this.#startValue + BigInt(count);
42
+ this.#count = count;
43
+ if (count >= 0) {
44
+ this.#nextDelta = 1n;
45
+ this.#minimumValue = this.#startValue;
46
+ this.#maximumValue = this.#endValue - 1n;
47
+ }
48
+ else {
49
+ this.#nextDelta = -1n;
50
+ this.#minimumValue = this.#endValue + 1n;
51
+ this.#maximumValue = this.#startValue;
52
+ }
53
+ }
54
+ /**
55
+ * Get the start value (inclusive).
56
+ */
57
+ get startValue() {
58
+ return this.#startValue;
59
+ }
60
+ /**
61
+ * Get the end value (exclusive).
62
+ */
63
+ get endValue() {
64
+ return this.#endValue;
65
+ }
66
+ /**
67
+ * Get the count of values.
68
+ */
69
+ get count() {
70
+ return this.#count;
71
+ }
72
+ /**
73
+ * Get the minimum value (inclusive).
74
+ */
75
+ get minimumValue() {
76
+ return this.#minimumValue;
77
+ }
78
+ /**
79
+ * Get the maximum value (inclusive).
80
+ */
81
+ get maximumValue() {
82
+ return this.#maximumValue;
83
+ }
84
+ /**
85
+ * Iterable implementation.
86
+ *
87
+ * @yields
88
+ * Next value in sequence.
89
+ */
90
+ *[Symbol.iterator]() {
91
+ for (let value = this.#startValue; value !== this.#endValue; value += this.#nextDelta) {
92
+ yield value;
93
+ }
94
+ }
95
+ }
96
+ //# sourceMappingURL=sequence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,QAAQ;IACjB;;OAEG;IACM,WAAW,CAAS;IAE7B;;OAEG;IACM,SAAS,CAAS;IAE3B;;OAEG;IACM,MAAM,CAAS;IAExB;;OAEG;IACM,UAAU,CAAW;IAE9B;;OAEG;IACM,aAAa,CAAS;IAE/B;;OAEG;IACM,aAAa,CAAS;IAE/B;;;;;;;;;OASG;IACH,YAAY,UAA2B,EAAE,KAAa;QAClD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACb,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;YACrB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC;YACtC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACzC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC;QAC1C,CAAC;IACL,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,CAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,SAAS,EAAE,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpF,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * String validation interface. To ensure signature compatibility in implementing classes, string validation is
3
+ * controlled by validation interfaces specific to each validator type.
4
+ */
5
+ export interface StringValidation {
6
+ }
7
+ /**
8
+ * String validator interface.
9
+ *
10
+ * @template TStringValidation
11
+ * String validation type.
12
+ */
13
+ export interface StringValidator<TStringValidation extends StringValidation = StringValidation> {
14
+ /**
15
+ * Validate a string and throw an error if validation fails.
16
+ *
17
+ * @param s
18
+ * String.
19
+ *
20
+ * @param validation
21
+ * String validation parameters.
22
+ */
23
+ validate: (s: string, validation?: TStringValidation) => void;
24
+ }
25
+ //# sourceMappingURL=string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,iBAAiB,SAAS,gBAAgB,GAAG,gBAAgB;IAC1F;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;CACjE"}