@digitaldefiance/i18n-lib 3.6.1 → 3.6.3

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 (151) hide show
  1. package/README.md +9 -0
  2. package/package.json +1 -1
  3. package/src/active-context.d.ts +12 -6
  4. package/src/active-context.d.ts.map +1 -1
  5. package/src/component-registry.d.ts +44 -12
  6. package/src/component-registry.d.ts.map +1 -1
  7. package/src/component-registry.js +44 -12
  8. package/src/component-registry.js.map +1 -1
  9. package/src/context-error-type.d.ts +4 -0
  10. package/src/context-error-type.d.ts.map +1 -1
  11. package/src/context-error-type.js +4 -0
  12. package/src/context-error-type.js.map +1 -1
  13. package/src/core/component-store.d.ts +69 -1
  14. package/src/core/component-store.d.ts.map +1 -1
  15. package/src/core/component-store.js +69 -1
  16. package/src/core/component-store.js.map +1 -1
  17. package/src/core/context-manager.d.ts +53 -1
  18. package/src/core/context-manager.d.ts.map +1 -1
  19. package/src/core/context-manager.js +52 -4
  20. package/src/core/context-manager.js.map +1 -1
  21. package/src/core/enum-registry.d.ts +34 -0
  22. package/src/core/enum-registry.d.ts.map +1 -1
  23. package/src/core/enum-registry.js +34 -0
  24. package/src/core/enum-registry.js.map +1 -1
  25. package/src/core/i18n-engine.d.ts +186 -0
  26. package/src/core/i18n-engine.d.ts.map +1 -1
  27. package/src/core/i18n-engine.js +189 -17
  28. package/src/core/i18n-engine.js.map +1 -1
  29. package/src/core/language-registry.d.ts +139 -0
  30. package/src/core/language-registry.d.ts.map +1 -1
  31. package/src/core/language-registry.js +138 -0
  32. package/src/core/language-registry.js.map +1 -1
  33. package/src/core-i18n.d.ts.map +1 -1
  34. package/src/core-i18n.js +16 -416
  35. package/src/core-i18n.js.map +1 -1
  36. package/src/enum-registry.d.ts +41 -21
  37. package/src/enum-registry.d.ts.map +1 -1
  38. package/src/enum-registry.js +44 -24
  39. package/src/enum-registry.js.map +1 -1
  40. package/src/errors/context-error.d.ts +11 -0
  41. package/src/errors/context-error.d.ts.map +1 -1
  42. package/src/errors/context-error.js +11 -0
  43. package/src/errors/context-error.js.map +1 -1
  44. package/src/errors/handleable.d.ts +33 -0
  45. package/src/errors/handleable.d.ts.map +1 -1
  46. package/src/errors/handleable.js +33 -0
  47. package/src/errors/handleable.js.map +1 -1
  48. package/src/errors/i18n-error.d.ts +107 -0
  49. package/src/errors/i18n-error.d.ts.map +1 -1
  50. package/src/errors/i18n-error.js +104 -0
  51. package/src/errors/i18n-error.js.map +1 -1
  52. package/src/gender/gender-categories.d.ts +11 -0
  53. package/src/gender/gender-categories.d.ts.map +1 -1
  54. package/src/gender/gender-categories.js +5 -0
  55. package/src/gender/gender-categories.js.map +1 -1
  56. package/src/gender/gender-resolver.d.ts +6 -1
  57. package/src/gender/gender-resolver.d.ts.map +1 -1
  58. package/src/gender/gender-resolver.js +6 -1
  59. package/src/gender/gender-resolver.js.map +1 -1
  60. package/src/interfaces/component-config.interface.d.ts +6 -0
  61. package/src/interfaces/component-config.interface.d.ts.map +1 -1
  62. package/src/interfaces/engine-config.interface.d.ts +9 -0
  63. package/src/interfaces/engine-config.interface.d.ts.map +1 -1
  64. package/src/interfaces/handleable-error-options.d.ts +7 -0
  65. package/src/interfaces/handleable-error-options.d.ts.map +1 -1
  66. package/src/interfaces/handleable.d.ts +15 -0
  67. package/src/interfaces/handleable.d.ts.map +1 -1
  68. package/src/interfaces/i18n-engine.interface.d.ts +20 -0
  69. package/src/interfaces/i18n-engine.interface.d.ts.map +1 -1
  70. package/src/interfaces/language-definition.interface.d.ts +7 -0
  71. package/src/interfaces/language-definition.interface.d.ts.map +1 -1
  72. package/src/interfaces/translation-options.interface.d.ts +6 -0
  73. package/src/interfaces/translation-options.interface.d.ts.map +1 -1
  74. package/src/interfaces/validation-result.interface.d.ts +10 -0
  75. package/src/interfaces/validation-result.interface.d.ts.map +1 -1
  76. package/src/registry-error-type.d.ts +7 -0
  77. package/src/registry-error-type.d.ts.map +1 -1
  78. package/src/registry-error-type.js +7 -0
  79. package/src/registry-error-type.js.map +1 -1
  80. package/src/strings/de.d.ts +3 -0
  81. package/src/strings/de.d.ts.map +1 -0
  82. package/src/strings/de.js +57 -0
  83. package/src/strings/de.js.map +1 -0
  84. package/src/strings/en-GB.d.ts +3 -0
  85. package/src/strings/en-GB.d.ts.map +1 -0
  86. package/src/strings/en-GB.js +57 -0
  87. package/src/strings/en-GB.js.map +1 -0
  88. package/src/strings/en-US.d.ts +3 -0
  89. package/src/strings/en-US.d.ts.map +1 -0
  90. package/src/strings/en-US.js +57 -0
  91. package/src/strings/en-US.js.map +1 -0
  92. package/src/strings/es.d.ts +3 -0
  93. package/src/strings/es.d.ts.map +1 -0
  94. package/src/strings/es.js +57 -0
  95. package/src/strings/es.js.map +1 -0
  96. package/src/strings/fr.d.ts +3 -0
  97. package/src/strings/fr.d.ts.map +1 -0
  98. package/src/strings/fr.js +57 -0
  99. package/src/strings/fr.js.map +1 -0
  100. package/src/strings/ja.d.ts +3 -0
  101. package/src/strings/ja.d.ts.map +1 -0
  102. package/src/strings/ja.js +57 -0
  103. package/src/strings/ja.js.map +1 -0
  104. package/src/strings/uk.d.ts +3 -0
  105. package/src/strings/uk.d.ts.map +1 -0
  106. package/src/strings/uk.js +57 -0
  107. package/src/strings/uk.js.map +1 -0
  108. package/src/strings/zh-CN.d.ts +3 -0
  109. package/src/strings/zh-CN.d.ts.map +1 -0
  110. package/src/strings/zh-CN.js +57 -0
  111. package/src/strings/zh-CN.js.map +1 -0
  112. package/src/types/plural-types.d.ts +10 -3
  113. package/src/types/plural-types.d.ts.map +1 -1
  114. package/src/types/plural-types.js +8 -2
  115. package/src/types/plural-types.js.map +1 -1
  116. package/src/utils/currency.d.ts +53 -0
  117. package/src/utils/currency.d.ts.map +1 -1
  118. package/src/utils/currency.js +35 -0
  119. package/src/utils/currency.js.map +1 -1
  120. package/src/utils/html-escape.d.ts +14 -0
  121. package/src/utils/html-escape.d.ts.map +1 -1
  122. package/src/utils/html-escape.js +20 -0
  123. package/src/utils/html-escape.js.map +1 -1
  124. package/src/utils/lru-cache.d.ts +29 -0
  125. package/src/utils/lru-cache.d.ts.map +1 -1
  126. package/src/utils/lru-cache.js +29 -0
  127. package/src/utils/lru-cache.js.map +1 -1
  128. package/src/utils/plural-helpers.d.ts +16 -0
  129. package/src/utils/plural-helpers.d.ts.map +1 -1
  130. package/src/utils/plural-helpers.js +16 -0
  131. package/src/utils/plural-helpers.js.map +1 -1
  132. package/src/utils/safe-object.d.ts +30 -0
  133. package/src/utils/safe-object.d.ts.map +1 -1
  134. package/src/utils/safe-object.js +33 -0
  135. package/src/utils/safe-object.js.map +1 -1
  136. package/src/utils/string-utils.d.ts +19 -0
  137. package/src/utils/string-utils.d.ts.map +1 -1
  138. package/src/utils/string-utils.js +18 -1
  139. package/src/utils/string-utils.js.map +1 -1
  140. package/src/utils/timezone.d.ts +36 -0
  141. package/src/utils/timezone.d.ts.map +1 -1
  142. package/src/utils/timezone.js +36 -0
  143. package/src/utils/timezone.js.map +1 -1
  144. package/src/utils/validation.d.ts +25 -0
  145. package/src/utils/validation.d.ts.map +1 -1
  146. package/src/utils/validation.js +25 -0
  147. package/src/utils/validation.js.map +1 -1
  148. package/src/validation/plural-validator.d.ts +25 -2
  149. package/src/validation/plural-validator.d.ts.map +1 -1
  150. package/src/validation/plural-validator.js +22 -4
  151. package/src/validation/plural-validator.js.map +1 -1
@@ -3,15 +3,22 @@
3
3
  */
4
4
  import { PluralCategory } from '../pluralization/plural-categories';
5
5
  /**
6
- * A string value that can be either a simple string or an object with plural forms
6
+ * A string value that can be either a simple string or an object with plural forms.
7
+ * When using plural forms, the object should have keys matching PluralCategory values.
7
8
  */
8
9
  export type PluralString = string | Partial<Record<PluralCategory, string>>;
9
10
  /**
10
- * Check if a value is a plural string object (not a simple string)
11
+ * Check if a value is a plural string object (not a simple string).
12
+ * @param value - The value to check
13
+ * @returns True if the value is a plural string object, false if it's a simple string
11
14
  */
12
15
  export declare function isPluralString(value: any): value is Record<PluralCategory, string>;
13
16
  /**
14
- * Get the appropriate plural form from a PluralString
17
+ * Get the appropriate plural form from a PluralString based on the category.
18
+ * Falls back to 'other' if the exact category is not found, then to the first available form.
19
+ * @param value - The PluralString to resolve (either a string or plural forms object)
20
+ * @param category - The plural category to retrieve
21
+ * @returns The resolved string, or undefined if no suitable form is found
15
22
  */
16
23
  export declare function resolvePluralString(value: PluralString, category: PluralCategory): string | undefined;
17
24
  //# sourceMappingURL=plural-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plural-types.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/types/plural-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAE5E;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAElF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACvB,MAAM,GAAG,SAAS,CAkBpB"}
1
+ {"version":3,"file":"plural-types.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/types/plural-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAElF;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACvB,MAAM,GAAG,SAAS,CAkBpB"}
@@ -6,13 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isPluralString = isPluralString;
7
7
  exports.resolvePluralString = resolvePluralString;
8
8
  /**
9
- * Check if a value is a plural string object (not a simple string)
9
+ * Check if a value is a plural string object (not a simple string).
10
+ * @param value - The value to check
11
+ * @returns True if the value is a plural string object, false if it's a simple string
10
12
  */
11
13
  function isPluralString(value) {
12
14
  return typeof value === 'object' && value !== null && !Array.isArray(value);
13
15
  }
14
16
  /**
15
- * Get the appropriate plural form from a PluralString
17
+ * Get the appropriate plural form from a PluralString based on the category.
18
+ * Falls back to 'other' if the exact category is not found, then to the first available form.
19
+ * @param value - The PluralString to resolve (either a string or plural forms object)
20
+ * @param category - The plural category to retrieve
21
+ * @returns The resolved string, or undefined if no suitable form is found
16
22
  */
17
23
  function resolvePluralString(value, category) {
18
24
  if (typeof value === 'string') {
@@ -1 +1 @@
1
- {"version":3,"file":"plural-types.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/types/plural-types.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAYH,wCAEC;AAKD,kDAqBC;AA/BD;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CACjC,KAAmB,EACnB,QAAwB;IAExB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,wBAAwB;IACxB,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED,sBAAsB;IACtB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IAED,mCAAmC;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACjD,CAAC"}
1
+ {"version":3,"file":"plural-types.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/types/plural-types.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAeH,wCAEC;AASD,kDAqBC;AArCD;;;;GAIG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,KAAmB,EACnB,QAAwB;IAExB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,wBAAwB;IACxB,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED,sBAAsB;IACtB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IAED,mCAAmC;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACjD,CAAC"}
@@ -1,28 +1,81 @@
1
1
  /**
2
2
  * Currency utilities (v2)
3
3
  */
4
+ /**
5
+ * Position of the currency symbol relative to the amount.
6
+ */
4
7
  export type CurrencyPosition = 'prefix' | 'postfix' | 'infix';
8
+ /**
9
+ * Configuration for formatting currency values in a specific locale.
10
+ */
5
11
  export interface CurrencyFormat {
12
+ /** The currency symbol (e.g., "$", "€") */
6
13
  symbol: string;
14
+ /** Position of the symbol relative to the amount */
7
15
  position: CurrencyPosition;
16
+ /** Character used to separate thousands (e.g., ",") */
8
17
  groupSeparator: string;
18
+ /** Character used to separate decimal places (e.g., ".") */
9
19
  decimalSeparator: string;
10
20
  }
21
+ /**
22
+ * Detailed information about a currency.
23
+ */
11
24
  export interface CurrencyData {
25
+ /** ISO 4217 currency code (e.g., "USD") */
12
26
  code: string;
27
+ /** Numeric currency code */
13
28
  number: string;
29
+ /** Number of decimal digits */
14
30
  digits: number;
31
+ /** Currency name */
15
32
  currency: string;
33
+ /** Countries using this currency */
16
34
  countries: string[];
17
35
  }
36
+ /**
37
+ * Represents a valid ISO 4217 currency code with validation.
38
+ */
18
39
  export declare class CurrencyCode {
19
40
  private _value;
41
+ /**
42
+ * Creates a new CurrencyCode instance.
43
+ * @param value - The ISO 4217 currency code (defaults to 'USD')
44
+ * @throws {TranslatableError} If the currency code is invalid
45
+ */
20
46
  constructor(value?: string);
47
+ /**
48
+ * Gets the currency code value.
49
+ * @returns The ISO 4217 currency code
50
+ */
21
51
  get value(): string;
52
+ /**
53
+ * Gets the currency code (alias for value).
54
+ * @returns The ISO 4217 currency code
55
+ */
22
56
  get code(): string;
57
+ /**
58
+ * Checks if a currency code is valid according to ISO 4217.
59
+ * @param code - The currency code to validate
60
+ * @returns True if the code is valid, false otherwise
61
+ */
23
62
  static isValid(code: string): boolean;
63
+ /**
64
+ * Gets all valid ISO 4217 currency codes.
65
+ * @returns Array of currency codes
66
+ */
24
67
  static getAll(): string[];
68
+ /**
69
+ * Gets detailed information for all currencies.
70
+ * @returns Array of currency data objects
71
+ */
25
72
  static getAllData(): CurrencyData[];
26
73
  }
74
+ /**
75
+ * Gets the currency formatting rules for a specific locale and currency.
76
+ * @param locale - The locale code (e.g., 'en-US', 'fr-FR')
77
+ * @param currencyCode - The ISO 4217 currency code
78
+ * @returns Currency format configuration including symbol, position, and separators
79
+ */
27
80
  export declare function getCurrencyFormat(locale: string, currencyCode: string): CurrencyFormat;
28
81
  //# sourceMappingURL=currency.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/currency.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAE9D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAS;gBAEX,KAAK,GAAE,MAAc;IAWjC,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIrC,MAAM,CAAC,MAAM,IAAI,MAAM,EAAE;IAIzB,MAAM,CAAC,UAAU,IAAI,YAAY,EAAE;CAGpC;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,cAAc,CA6BtF"}
1
+ {"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/currency.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAS;IAEvB;;;;OAIG;gBACS,KAAK,GAAE,MAAc;IAWjC;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIrC;;;OAGG;IACH,MAAM,CAAC,MAAM,IAAI,MAAM,EAAE;IAIzB;;;OAGG;IACH,MAAM,CAAC,UAAU,IAAI,YAAY,EAAE;CAGpC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,cAAc,CA6BtF"}
@@ -8,31 +8,66 @@ exports.getCurrencyFormat = getCurrencyFormat;
8
8
  const currency_codes_1 = require("currency-codes");
9
9
  const translatable_1 = require("../errors/translatable");
10
10
  const core_string_key_1 = require("../core-string-key");
11
+ /**
12
+ * Represents a valid ISO 4217 currency code with validation.
13
+ */
11
14
  class CurrencyCode {
12
15
  _value;
16
+ /**
17
+ * Creates a new CurrencyCode instance.
18
+ * @param value - The ISO 4217 currency code (defaults to 'USD')
19
+ * @throws {TranslatableError} If the currency code is invalid
20
+ */
13
21
  constructor(value = 'USD') {
14
22
  if (!CurrencyCode.isValid(value)) {
15
23
  throw new translatable_1.TranslatableError('core', core_string_key_1.CoreStringKey.Error_InvalidCurrencyCodeTemplate, { value });
16
24
  }
17
25
  this._value = value;
18
26
  }
27
+ /**
28
+ * Gets the currency code value.
29
+ * @returns The ISO 4217 currency code
30
+ */
19
31
  get value() {
20
32
  return this._value;
21
33
  }
34
+ /**
35
+ * Gets the currency code (alias for value).
36
+ * @returns The ISO 4217 currency code
37
+ */
22
38
  get code() {
23
39
  return this._value;
24
40
  }
41
+ /**
42
+ * Checks if a currency code is valid according to ISO 4217.
43
+ * @param code - The currency code to validate
44
+ * @returns True if the code is valid, false otherwise
45
+ */
25
46
  static isValid(code) {
26
47
  return (0, currency_codes_1.codes)().includes(code);
27
48
  }
49
+ /**
50
+ * Gets all valid ISO 4217 currency codes.
51
+ * @returns Array of currency codes
52
+ */
28
53
  static getAll() {
29
54
  return (0, currency_codes_1.codes)();
30
55
  }
56
+ /**
57
+ * Gets detailed information for all currencies.
58
+ * @returns Array of currency data objects
59
+ */
31
60
  static getAllData() {
32
61
  return currency_codes_1.data;
33
62
  }
34
63
  }
35
64
  exports.CurrencyCode = CurrencyCode;
65
+ /**
66
+ * Gets the currency formatting rules for a specific locale and currency.
67
+ * @param locale - The locale code (e.g., 'en-US', 'fr-FR')
68
+ * @param currencyCode - The ISO 4217 currency code
69
+ * @returns Currency format configuration including symbol, position, and separators
70
+ */
36
71
  function getCurrencyFormat(locale, currencyCode) {
37
72
  const formatter = new Intl.NumberFormat(locale, {
38
73
  style: 'currency',
@@ -1 +1 @@
1
- {"version":3,"file":"currency.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/currency.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA0DH,8CA6BC;AArFD,mDAA6C;AAC7C,yDAA2D;AAC3D,wDAAmD;AAmBnD,MAAa,YAAY;IACf,MAAM,CAAS;IAEvB,YAAY,QAAgB,KAAK;QAC/B,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,gCAAiB,CACzB,MAAM,EACN,+BAAa,CAAC,iCAAiC,EAC/C,EAAE,KAAK,EAAE,CACV,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,IAAY;QACzB,OAAO,IAAA,sBAAK,GAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,IAAA,sBAAK,GAAE,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,UAAU;QACf,OAAO,qBAAsB,CAAC;IAChC,CAAC;CACF;AAjCD,oCAiCC;AAED,SAAgB,iBAAiB,CAAC,MAAc,EAAE,YAAoB;IACpE,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QAC9C,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,YAAY;KACvB,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KA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ities for XSS prevention
3
3
  */
4
+ /**
5
+ * Escapes HTML special characters to prevent XSS attacks.
6
+ * @param str - The string to escape
7
+ * @returns The escaped string
8
+ */
4
9
  export declare function escapeHtml(str: string): string;
10
+ /**
11
+ * Safely converts a value to a string, optionally escaping HTML.
12
+ * Rejects objects to prevent toString exploits.
13
+ * @param value - The value to stringify
14
+ * @param options - Options including whether to escape HTML
15
+ * @param options.escapeHtml - If true, HTML-escapes the result
16
+ * @returns The stringified value
17
+ * @throws {Error} If the value is an object (to prevent exploits)
18
+ */
5
19
  export declare function safeStringify(value: any, options?: {
6
20
  escapeHtml?: boolean;
7
21
  }): string;
@@ -1 +1 @@
1
- {"version":3,"file":"html-escape.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/html-escape.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAepF"}
1
+ {"version":3,"file":"html-escape.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/html-escape.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmBH;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAepF"}
@@ -5,6 +5,9 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.escapeHtml = escapeHtml;
7
7
  exports.safeStringify = safeStringify;
8
+ /**
9
+ * Map of HTML characters to their escaped equivalents.
10
+ */
8
11
  const HTML_ESCAPES = {
9
12
  '&': '&amp;',
10
13
  '<': '&lt;',
@@ -13,10 +16,27 @@ const HTML_ESCAPES = {
13
16
  "'": '&#x27;',
14
17
  '/': '&#x2F;',
15
18
  };
19
+ /**
20
+ * Regular expression to match characters that need HTML escaping.
21
+ */
16
22
  const HTML_ESCAPE_REGEX = /[&<>"'/]/g;
23
+ /**
24
+ * Escapes HTML special characters to prevent XSS attacks.
25
+ * @param str - The string to escape
26
+ * @returns The escaped string
27
+ */
17
28
  function escapeHtml(str) {
18
29
  return str.replace(HTML_ESCAPE_REGEX, char => HTML_ESCAPES[char]);
19
30
  }
31
+ /**
32
+ * Safely converts a value to a string, optionally escaping HTML.
33
+ * Rejects objects to prevent toString exploits.
34
+ * @param value - The value to stringify
35
+ * @param options - Options including whether to escape HTML
36
+ * @param options.escapeHtml - If true, HTML-escapes the result
37
+ * @returns The stringified value
38
+ * @throws {Error} If the value is an object (to prevent exploits)
39
+ */
20
40
  function safeStringify(value, options) {
21
41
  if (value === null || value === undefined) {
22
42
  return '';
@@ -1 +1 @@
1
- {"version":3,"file":"html-escape.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/html-escape.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAaH,gCAEC;AAED,sCAeC;AA9BD,MAAM,YAAY,GAA2B;IAC3C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,QAAQ;CACd,CAAC;AAEF,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAEtC,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,SAAgB,aAAa,CAAC,KAAU,EAAE,OAAkC;IAC1E,IAAI,KAAK,KAAK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9B,OAAO,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACzD,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,8CAA8C;IAC9C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;AAC5D,CAAC"}
@@ -1,13 +1,42 @@
1
1
  /**
2
2
  * Simple LRU Cache implementation for security
3
3
  */
4
+ /**
5
+ * Least Recently Used (LRU) cache implementation.
6
+ * Automatically evicts the oldest entries when the cache reaches maximum size.
7
+ * @template K - The type of cache keys
8
+ * @template V - The type of cached values
9
+ */
4
10
  export declare class LRUCache<K, V> {
5
11
  private cache;
6
12
  private readonly maxSize;
13
+ /**
14
+ * Creates a new LRUCache instance.
15
+ * @param maxSize - Maximum number of entries to store (default: 1000)
16
+ */
7
17
  constructor(maxSize?: number);
18
+ /**
19
+ * Retrieves a value from the cache by key.
20
+ * Accessing an item moves it to the end (marks it as most recently used).
21
+ * @param key - The key to look up
22
+ * @returns The cached value, or undefined if not found
23
+ */
8
24
  get(key: K): V | undefined;
25
+ /**
26
+ * Adds or updates a value in the cache.
27
+ * If the cache is at capacity, the oldest entry is removed.
28
+ * @param key - The key to store
29
+ * @param value - The value to cache
30
+ */
9
31
  set(key: K, value: V): void;
32
+ /**
33
+ * Removes all entries from the cache.
34
+ */
10
35
  clear(): void;
36
+ /**
37
+ * Gets the current number of entries in the cache.
38
+ * @returns The number of cached entries
39
+ */
11
40
  size(): number;
12
41
  }
13
42
  //# sourceMappingURL=lru-cache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lru-cache.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/lru-cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC;IACxB,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,GAAE,MAAa;IAIlC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAU1B,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAiB3B,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,MAAM;CAGf"}
1
+ {"version":3,"file":"lru-cache.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/lru-cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC;IACxB,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC;;;OAGG;gBACS,OAAO,GAAE,MAAa;IAIlC;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAU1B;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAiB3B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,IAAI,IAAI,MAAM;CAGf"}
@@ -4,12 +4,28 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LRUCache = void 0;
7
+ /**
8
+ * Least Recently Used (LRU) cache implementation.
9
+ * Automatically evicts the oldest entries when the cache reaches maximum size.
10
+ * @template K - The type of cache keys
11
+ * @template V - The type of cached values
12
+ */
7
13
  class LRUCache {
8
14
  cache = new Map();
9
15
  maxSize;
16
+ /**
17
+ * Creates a new LRUCache instance.
18
+ * @param maxSize - Maximum number of entries to store (default: 1000)
19
+ */
10
20
  constructor(maxSize = 1000) {
11
21
  this.maxSize = maxSize;
12
22
  }
23
+ /**
24
+ * Retrieves a value from the cache by key.
25
+ * Accessing an item moves it to the end (marks it as most recently used).
26
+ * @param key - The key to look up
27
+ * @returns The cached value, or undefined if not found
28
+ */
13
29
  get(key) {
14
30
  const value = this.cache.get(key);
15
31
  if (value !== undefined) {
@@ -19,6 +35,12 @@ class LRUCache {
19
35
  }
20
36
  return value;
21
37
  }
38
+ /**
39
+ * Adds or updates a value in the cache.
40
+ * If the cache is at capacity, the oldest entry is removed.
41
+ * @param key - The key to store
42
+ * @param value - The value to cache
43
+ */
22
44
  set(key, value) {
23
45
  // Remove if exists to update position
24
46
  if (this.cache.has(key)) {
@@ -33,9 +55,16 @@ class LRUCache {
33
55
  }
34
56
  this.cache.set(key, value);
35
57
  }
58
+ /**
59
+ * Removes all entries from the cache.
60
+ */
36
61
  clear() {
37
62
  this.cache.clear();
38
63
  }
64
+ /**
65
+ * Gets the current number of entries in the cache.
66
+ * @returns The number of cached entries
67
+ */
39
68
  size() {
40
69
  return this.cache.size;
41
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"lru-cache.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/lru-cache.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,MAAa,QAAQ;IACX,KAAK,GAAG,IAAI,GAAG,EAAQ,CAAC;IACf,OAAO,CAAS;IAEjC,YAAY,UAAkB,IAAI;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,GAAG,CAAC,GAAM;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,mCAAmC;YACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,GAAG,CAAC,GAAM,EAAE,KAAQ;QAClB,sCAAsC;QACtC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;QAED,+BAA+B;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YAChD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AA1CD,4BA0CC"}
1
+ {"version":3,"file":"lru-cache.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/lru-cache.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH;;;;;GAKG;AACH,MAAa,QAAQ;IACX,KAAK,GAAG,IAAI,GAAG,EAAQ,CAAC;IACf,OAAO,CAAS;IAEjC;;;OAGG;IACH,YAAY,UAAkB,IAAI;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,GAAM;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,mCAAmC;YACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,GAAM,EAAE,KAAQ;QAClB,sCAAsC;QACtC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;QAED,+BAA+B;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YAChD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AAjED,4BAiEC"}
@@ -4,7 +4,23 @@
4
4
  import { PluralCategory } from '../pluralization/plural-categories';
5
5
  import { PluralString } from '../types/plural-types';
6
6
  import { GenderCategory, GenderedString } from '../gender/gender-categories';
7
+ /**
8
+ * Creates a PluralString from a partial record of plural forms.
9
+ * @param forms - Object mapping plural categories to their string forms
10
+ * @returns A PluralString that can be used in translations
11
+ */
7
12
  export declare function createPluralString(forms: Partial<Record<PluralCategory, string>>): PluralString;
13
+ /**
14
+ * Creates a GenderedString from a partial record of gender forms.
15
+ * @param forms - Object mapping gender categories to their string forms
16
+ * @returns A GenderedString that can be used in translations
17
+ */
8
18
  export declare function createGenderedString(forms: Partial<Record<GenderCategory, string>>): GenderedString;
19
+ /**
20
+ * Gets the required plural forms for a given language.
21
+ * Different languages have different plural rules and require different forms.
22
+ * @param language - The language code
23
+ * @returns Array of plural categories required for the language
24
+ */
9
25
  export declare function getRequiredPluralForms(language: string): PluralCategory[];
10
26
  //# sourceMappingURL=plural-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plural-helpers.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/plural-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,GAAG,YAAY,CAE/F;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,GAAG,cAAc,CAEnG;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,CAEzE"}
1
+ {"version":3,"file":"plural-helpers.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/plural-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,GAAG,YAAY,CAE/F;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,GAAG,cAAc,CAEnG;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,CAEzE"}
@@ -7,12 +7,28 @@ exports.createPluralString = createPluralString;
7
7
  exports.createGenderedString = createGenderedString;
8
8
  exports.getRequiredPluralForms = getRequiredPluralForms;
9
9
  const language_plural_map_1 = require("../pluralization/language-plural-map");
10
+ /**
11
+ * Creates a PluralString from a partial record of plural forms.
12
+ * @param forms - Object mapping plural categories to their string forms
13
+ * @returns A PluralString that can be used in translations
14
+ */
10
15
  function createPluralString(forms) {
11
16
  return forms;
12
17
  }
18
+ /**
19
+ * Creates a GenderedString from a partial record of gender forms.
20
+ * @param forms - Object mapping gender categories to their string forms
21
+ * @returns A GenderedString that can be used in translations
22
+ */
13
23
  function createGenderedString(forms) {
14
24
  return forms;
15
25
  }
26
+ /**
27
+ * Gets the required plural forms for a given language.
28
+ * Different languages have different plural rules and require different forms.
29
+ * @param language - The language code
30
+ * @returns Array of plural categories required for the language
31
+ */
16
32
  function getRequiredPluralForms(language) {
17
33
  return (0, language_plural_map_1.getRequiredPluralForms)(language);
18
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plural-helpers.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/plural-helpers.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAOH,gDAEC;AAED,oDAEC;AAED,wDAEC;AAZD,8EAAyG;AAEzG,SAAgB,kBAAkB,CAAC,KAA8C;IAC/E,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,oBAAoB,CAAC,KAA8C;IACjF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,OAAO,IAAA,4CAAuB,EAAC,QAAQ,CAAqB,CAAC;AAC/D,CAAC"}
1
+ {"version":3,"file":"plural-helpers.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/plural-helpers.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAYH,gDAEC;AAOD,oDAEC;AAQD,wDAEC;AA5BD,8EAAyG;AAEzG;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,KAA8C;IAC/E,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,KAA8C;IACjF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,OAAO,IAAA,4CAAuB,EAAC,QAAQ,CAAqB,CAAC;AAC/D,CAAC"}
@@ -1,9 +1,39 @@
1
1
  /**
2
2
  * Safe object utilities to prevent prototype pollution
3
3
  */
4
+ /**
5
+ * Creates a safe object without a prototype chain.
6
+ * This prevents prototype pollution attacks.
7
+ * @template T - The type of values in the object
8
+ * @returns A new object without a prototype
9
+ */
4
10
  export declare function createSafeObject<T = any>(): Record<string, T>;
11
+ /**
12
+ * Checks if a key is in the list of dangerous keys that could enable prototype pollution.
13
+ * @param key - The key to check
14
+ * @returns True if the key is dangerous, false otherwise
15
+ */
5
16
  export declare function isDangerousKey(key: string): boolean;
17
+ /**
18
+ * Safely assigns properties from source objects to a target object.
19
+ * Filters out dangerous keys to prevent prototype pollution.
20
+ * @template T - The type of the target object
21
+ * @param target - The target object to assign to
22
+ * @param sources - One or more source objects to copy properties from
23
+ * @returns The target object with properties assigned
24
+ */
6
25
  export declare function safeAssign<T extends Record<string, any>>(target: T, ...sources: Array<Record<string, any> | undefined>): T;
26
+ /**
27
+ * Gets key-value pairs from an object, filtering out dangerous keys.
28
+ * @template T - The type of values in the object
29
+ * @param obj - The object to get entries from
30
+ * @returns Array of [key, value] pairs, excluding dangerous keys
31
+ */
7
32
  export declare function safeObjectEntries<T>(obj: Record<string, T>): Array<[string, T]>;
33
+ /**
34
+ * Validates that an object does not contain dangerous keys.
35
+ * @param obj - The object to validate
36
+ * @throws {Error} If a dangerous key is detected
37
+ */
8
38
  export declare function validateObjectKeys(obj: Record<string, any>): void;
9
39
  //# sourceMappingURL=safe-object.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"safe-object.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/safe-object.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,GAAG,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAE7D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACtD,MAAM,EAAE,CAAC,EACT,GAAG,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,GACjD,CAAC,CAWH;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAE/E;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAUjE"}
1
+ {"version":3,"file":"safe-object.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/safe-object.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,GAAG,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACtD,MAAM,EAAE,CAAC,EACT,GAAG,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,GACjD,CAAC,CAWH;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAE/E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAUjE"}
@@ -8,13 +8,35 @@ exports.isDangerousKey = isDangerousKey;
8
8
  exports.safeAssign = safeAssign;
9
9
  exports.safeObjectEntries = safeObjectEntries;
10
10
  exports.validateObjectKeys = validateObjectKeys;
11
+ /**
12
+ * List of dangerous keys that should never be set on objects to prevent prototype pollution.
13
+ */
11
14
  const DANGEROUS_KEYS = ['__proto__', 'constructor', 'prototype'];
15
+ /**
16
+ * Creates a safe object without a prototype chain.
17
+ * This prevents prototype pollution attacks.
18
+ * @template T - The type of values in the object
19
+ * @returns A new object without a prototype
20
+ */
12
21
  function createSafeObject() {
13
22
  return Object.create(null);
14
23
  }
24
+ /**
25
+ * Checks if a key is in the list of dangerous keys that could enable prototype pollution.
26
+ * @param key - The key to check
27
+ * @returns True if the key is dangerous, false otherwise
28
+ */
15
29
  function isDangerousKey(key) {
16
30
  return DANGEROUS_KEYS.includes(key);
17
31
  }
32
+ /**
33
+ * Safely assigns properties from source objects to a target object.
34
+ * Filters out dangerous keys to prevent prototype pollution.
35
+ * @template T - The type of the target object
36
+ * @param target - The target object to assign to
37
+ * @param sources - One or more source objects to copy properties from
38
+ * @returns The target object with properties assigned
39
+ */
18
40
  function safeAssign(target, ...sources) {
19
41
  for (const source of sources) {
20
42
  if (!source)
@@ -27,9 +49,20 @@ function safeAssign(target, ...sources) {
27
49
  }
28
50
  return target;
29
51
  }
52
+ /**
53
+ * Gets key-value pairs from an object, filtering out dangerous keys.
54
+ * @template T - The type of values in the object
55
+ * @param obj - The object to get entries from
56
+ * @returns Array of [key, value] pairs, excluding dangerous keys
57
+ */
30
58
  function safeObjectEntries(obj) {
31
59
  return Object.entries(obj).filter(([key]) => !isDangerousKey(key));
32
60
  }
61
+ /**
62
+ * Validates that an object does not contain dangerous keys.
63
+ * @param obj - The object to validate
64
+ * @throws {Error} If a dangerous key is detected
65
+ */
33
66
  function validateObjectKeys(obj) {
34
67
  if (!obj || typeof obj !== 'object')
35
68
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"safe-object.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/safe-object.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAIH,4CAEC;AAED,wCAEC;AAED,gCAcC;AAED,8CAEC;AAED,gDAUC;AAxCD,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AAEjE,SAAgB,gBAAgB;IAC9B,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,SAAgB,UAAU,CACxB,MAAS,EACT,GAAG,OAA+C;IAElD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM;YAAE,SAAS;QAEtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxB,MAAc,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,iBAAiB,CAAI,GAAsB;IACzD,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,SAAgB,kBAAkB,CAAC,GAAwB;IACzD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO;IAE5C,kEAAkE;IAClE,MAAM,OAAO,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1E,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"safe-object.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/safe-object.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAaH,4CAEC;AAOD,wCAEC;AAUD,gCAcC;AAQD,8CAEC;AAOD,gDAUC;AAzED;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AAEjE;;;;;GAKG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,MAAM,CAAC,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D,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,9 +1,28 @@
1
1
  /**
2
2
  * String utility functions
3
3
  */
4
+ /**
5
+ * Options for the replaceVariables function.
6
+ */
4
7
  export interface ReplaceVariablesOptions {
8
+ /** If true, HTML-escapes the replaced values */
5
9
  escapeHtml?: boolean;
6
10
  }
11
+ /**
12
+ * Replaces variables in a string template with values from vars or constants.
13
+ * Variables are denoted by {variableName} in the template string.
14
+ * @param str - The template string containing variables
15
+ * @param vars - Optional object mapping variable names to values
16
+ * @param constants - Optional object containing constant values
17
+ * @param options - Optional configuration including HTML escaping
18
+ * @returns The string with variables replaced
19
+ */
7
20
  export declare function replaceVariables(str: string, vars?: Record<string, any>, constants?: Record<string, any>, options?: ReplaceVariablesOptions): string;
21
+ /**
22
+ * Checks if a string key indicates a template that expects variable replacement.
23
+ * Template keys end with 'template' (case-insensitive).
24
+ * @param key - The key to check
25
+ * @returns True if the key indicates a template, false otherwise
26
+ */
8
27
  export declare function isTemplate(key: string): boolean;
9
28
  //# sourceMappingURL=string-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/string-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/B,OAAO,CAAC,EAAE,uBAAuB,GAChC,MAAM,CAyBR;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C"}
1
+ {"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/string-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiBH;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,gDAAgD;IAChD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/B,OAAO,CAAC,EAAE,uBAAuB,GAChC,MAAM,CAyBR;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C"}