@digitaldefiance/i18n-lib 3.7.5 → 3.8.1

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 (490) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +261 -0
  3. package/package.json +12 -4
  4. package/src/active-context.ts +4 -0
  5. package/src/builders/i18n-builder.ts +82 -0
  6. package/src/builders/{index.d.ts → index.ts} +1 -1
  7. package/src/component-definition.ts +11 -0
  8. package/src/component-registration.ts +29 -0
  9. package/src/component-registry.ts +432 -0
  10. package/src/context-error-type.ts +7 -0
  11. package/src/core/component-store.ts +241 -0
  12. package/src/core/context-manager.ts +113 -0
  13. package/src/core/enum-registry.ts +106 -0
  14. package/src/core/i18n-engine.ts +710 -0
  15. package/src/core/index.ts +16 -0
  16. package/src/core/language-registry.ts +345 -0
  17. package/src/core-component-id.ts +5 -0
  18. package/src/core-i18n.ts +270 -0
  19. package/src/core-plugin-factory.ts +111 -0
  20. package/src/core-string-key.ts +59 -0
  21. package/src/create-translation-adapter.ts +93 -0
  22. package/src/enum-registry.ts +152 -0
  23. package/src/errors/base.ts +8 -0
  24. package/src/errors/context-error.ts +122 -0
  25. package/src/errors/enhanced-error-base.ts +260 -0
  26. package/src/errors/handleable.ts +152 -0
  27. package/src/errors/i18n-error.ts +494 -0
  28. package/src/errors/index.ts +15 -0
  29. package/src/errors/simple-typed-error.ts +81 -0
  30. package/src/errors/{index.d.ts → translatable-exports.ts} +3 -5
  31. package/src/errors/translatable-generic.ts +245 -0
  32. package/src/errors/translatable-handleable-generic.ts +222 -0
  33. package/src/errors/translatable.ts +138 -0
  34. package/src/errors/typed-handleable.ts +138 -0
  35. package/src/errors/typed.ts +617 -0
  36. package/src/gender/{gender-categories.d.ts → gender-categories.ts} +6 -2
  37. package/src/gender/gender-resolver.ts +40 -0
  38. package/src/gender/{index.d.ts → index.ts} +0 -1
  39. package/src/global-active-context.ts +266 -0
  40. package/src/icu/ast.ts +56 -0
  41. package/src/icu/compiler.ts +96 -0
  42. package/src/icu/formatter-registry.ts +36 -0
  43. package/src/icu/formatters/base-formatter.ts +8 -0
  44. package/src/icu/formatters/date-formatter.ts +30 -0
  45. package/src/icu/formatters/number-formatter.ts +32 -0
  46. package/src/icu/formatters/plural-formatter.ts +12 -0
  47. package/src/icu/formatters/select-formatter.ts +7 -0
  48. package/src/icu/formatters/selectordinal-formatter.ts +17 -0
  49. package/src/icu/formatters/time-formatter.ts +30 -0
  50. package/src/icu/helpers.ts +34 -0
  51. package/src/icu/parser.ts +242 -0
  52. package/src/icu/runtime.ts +37 -0
  53. package/src/icu/tokenizer.ts +212 -0
  54. package/src/icu/validator.ts +163 -0
  55. package/src/{index.d.ts → index.ts} +46 -14
  56. package/src/interfaces/active-context.interface.ts +41 -0
  57. package/src/interfaces/component-config.interface.ts +17 -0
  58. package/src/interfaces/engine-config.interface.ts +22 -0
  59. package/src/interfaces/global-active-context.ts +39 -0
  60. package/src/interfaces/handleable-error-options.ts +13 -0
  61. package/src/interfaces/handleable.ts +20 -0
  62. package/src/interfaces/i18n-engine.interface.ts +57 -0
  63. package/src/interfaces/index.ts +13 -0
  64. package/src/interfaces/language-definition.interface.ts +17 -0
  65. package/src/interfaces/translation-options.interface.ts +15 -0
  66. package/src/interfaces/validation-result.interface.ts +24 -0
  67. package/src/language-codes.ts +40 -0
  68. package/src/language-definition.ts +13 -0
  69. package/src/plugin-i18n-engine.ts +707 -0
  70. package/src/pluralization/{index.d.ts → index.ts} +1 -1
  71. package/src/pluralization/language-plural-map.ts +186 -0
  72. package/src/pluralization/{plural-categories.d.ts → plural-categories.ts} +5 -3
  73. package/src/pluralization/plural-rules.ts +228 -0
  74. package/src/registry-config.ts +16 -0
  75. package/src/registry-error-type.ts +19 -0
  76. package/src/registry-error.ts +100 -0
  77. package/src/strict-types.ts +35 -0
  78. package/src/strings/de.ts +75 -0
  79. package/src/strings/en-GB.ts +74 -0
  80. package/src/strings/en-US.ts +74 -0
  81. package/src/strings/es.ts +74 -0
  82. package/src/strings/fr.ts +75 -0
  83. package/src/strings/ja.ts +73 -0
  84. package/src/strings/uk.ts +73 -0
  85. package/src/strings/zh-CN.ts +72 -0
  86. package/src/template.ts +72 -0
  87. package/src/translation-engine.ts +18 -0
  88. package/src/translation-request.ts +12 -0
  89. package/src/translation-response.ts +8 -0
  90. package/src/types/engine.ts +55 -0
  91. package/src/types/{index.d.ts → index.ts} +1 -1
  92. package/src/types/{plural-types.d.ts → plural-types.ts} +29 -3
  93. package/src/types.ts +142 -0
  94. package/src/utils/currency.ts +141 -0
  95. package/src/utils/html-escape.ts +55 -0
  96. package/src/utils/{index.d.ts → index.ts} +0 -1
  97. package/src/utils/lru-cache.ts +76 -0
  98. package/src/utils/{plural-helpers.d.ts → plural-helpers.ts} +14 -4
  99. package/src/utils/{safe-object.js → safe-object.ts} +37 -34
  100. package/src/utils/string-utils.ts +77 -0
  101. package/src/utils/timezone.ts +76 -0
  102. package/src/utils/validation.ts +66 -0
  103. package/src/utils.ts +215 -0
  104. package/src/validation/{index.d.ts → index.ts} +0 -1
  105. package/src/validation/plural-validator.ts +168 -0
  106. package/src/validation-config.ts +11 -0
  107. package/src/validation-result.ts +12 -0
  108. package/src/active-context.d.ts +0 -36
  109. package/src/active-context.d.ts.map +0 -1
  110. package/src/active-context.js +0 -3
  111. package/src/active-context.js.map +0 -1
  112. package/src/builders/i18n-builder.d.ts +0 -26
  113. package/src/builders/i18n-builder.d.ts.map +0 -1
  114. package/src/builders/i18n-builder.js +0 -70
  115. package/src/builders/i18n-builder.js.map +0 -1
  116. package/src/builders/index.d.ts.map +0 -1
  117. package/src/builders/index.js +0 -8
  118. package/src/builders/index.js.map +0 -1
  119. package/src/component-definition.d.ts +0 -12
  120. package/src/component-definition.d.ts.map +0 -1
  121. package/src/component-definition.js +0 -3
  122. package/src/component-definition.js.map +0 -1
  123. package/src/component-registration.d.ts +0 -13
  124. package/src/component-registration.d.ts.map +0 -1
  125. package/src/component-registration.js +0 -3
  126. package/src/component-registration.js.map +0 -1
  127. package/src/component-registry.d.ts +0 -102
  128. package/src/component-registry.d.ts.map +0 -1
  129. package/src/component-registry.js +0 -282
  130. package/src/component-registry.js.map +0 -1
  131. package/src/context-error-type.d.ts +0 -8
  132. package/src/context-error-type.d.ts.map +0 -1
  133. package/src/context-error-type.js +0 -12
  134. package/src/context-error-type.js.map +0 -1
  135. package/src/core/component-store.d.ts +0 -93
  136. package/src/core/component-store.d.ts.map +0 -1
  137. package/src/core/component-store.js +0 -198
  138. package/src/core/component-store.js.map +0 -1
  139. package/src/core/context-manager.d.ts +0 -72
  140. package/src/core/context-manager.d.ts.map +0 -1
  141. package/src/core/context-manager.js +0 -98
  142. package/src/core/context-manager.js.map +0 -1
  143. package/src/core/enum-registry.d.ts +0 -48
  144. package/src/core/enum-registry.d.ts.map +0 -1
  145. package/src/core/enum-registry.js +0 -85
  146. package/src/core/enum-registry.js.map +0 -1
  147. package/src/core/i18n-engine.d.ts +0 -241
  148. package/src/core/i18n-engine.d.ts.map +0 -1
  149. package/src/core/i18n-engine.js +0 -568
  150. package/src/core/i18n-engine.js.map +0 -1
  151. package/src/core/index.d.ts +0 -9
  152. package/src/core/index.d.ts.map +0 -1
  153. package/src/core/index.js +0 -12
  154. package/src/core/index.js.map +0 -1
  155. package/src/core/language-registry.d.ts +0 -180
  156. package/src/core/language-registry.d.ts.map +0 -1
  157. package/src/core/language-registry.js +0 -295
  158. package/src/core/language-registry.js.map +0 -1
  159. package/src/core-i18n.d.ts +0 -91
  160. package/src/core-i18n.d.ts.map +0 -1
  161. package/src/core-i18n.js +0 -287
  162. package/src/core-i18n.js.map +0 -1
  163. package/src/core-string-key.d.ts +0 -52
  164. package/src/core-string-key.d.ts.map +0 -1
  165. package/src/core-string-key.js +0 -61
  166. package/src/core-string-key.js.map +0 -1
  167. package/src/create-translation-adapter.d.ts +0 -33
  168. package/src/create-translation-adapter.d.ts.map +0 -1
  169. package/src/create-translation-adapter.js +0 -72
  170. package/src/create-translation-adapter.js.map +0 -1
  171. package/src/enum-registry.d.ts +0 -65
  172. package/src/enum-registry.d.ts.map +0 -1
  173. package/src/enum-registry.js +0 -123
  174. package/src/enum-registry.js.map +0 -1
  175. package/src/errors/context-error.d.ts +0 -50
  176. package/src/errors/context-error.d.ts.map +0 -1
  177. package/src/errors/context-error.js +0 -75
  178. package/src/errors/context-error.js.map +0 -1
  179. package/src/errors/enhanced-error-base.d.ts +0 -125
  180. package/src/errors/enhanced-error-base.d.ts.map +0 -1
  181. package/src/errors/enhanced-error-base.js +0 -165
  182. package/src/errors/enhanced-error-base.js.map +0 -1
  183. package/src/errors/handleable.d.ts +0 -83
  184. package/src/errors/handleable.d.ts.map +0 -1
  185. package/src/errors/handleable.js +0 -136
  186. package/src/errors/handleable.js.map +0 -1
  187. package/src/errors/i18n-error.d.ts +0 -211
  188. package/src/errors/i18n-error.d.ts.map +0 -1
  189. package/src/errors/i18n-error.js +0 -358
  190. package/src/errors/i18n-error.js.map +0 -1
  191. package/src/errors/index.d.ts.map +0 -1
  192. package/src/errors/index.js +0 -17
  193. package/src/errors/index.js.map +0 -1
  194. package/src/errors/simple-typed-error.d.ts +0 -53
  195. package/src/errors/simple-typed-error.d.ts.map +0 -1
  196. package/src/errors/simple-typed-error.js +0 -51
  197. package/src/errors/simple-typed-error.js.map +0 -1
  198. package/src/errors/translatable-generic.d.ts +0 -84
  199. package/src/errors/translatable-generic.d.ts.map +0 -1
  200. package/src/errors/translatable-generic.js +0 -134
  201. package/src/errors/translatable-generic.js.map +0 -1
  202. package/src/errors/translatable-handleable-generic.d.ts +0 -116
  203. package/src/errors/translatable-handleable-generic.d.ts.map +0 -1
  204. package/src/errors/translatable-handleable-generic.js +0 -121
  205. package/src/errors/translatable-handleable-generic.js.map +0 -1
  206. package/src/errors/translatable.d.ts +0 -59
  207. package/src/errors/translatable.d.ts.map +0 -1
  208. package/src/errors/translatable.js +0 -80
  209. package/src/errors/translatable.js.map +0 -1
  210. package/src/errors/typed-handleable.d.ts +0 -62
  211. package/src/errors/typed-handleable.d.ts.map +0 -1
  212. package/src/errors/typed-handleable.js +0 -106
  213. package/src/errors/typed-handleable.js.map +0 -1
  214. package/src/errors/typed.d.ts +0 -206
  215. package/src/errors/typed.d.ts.map +0 -1
  216. package/src/errors/typed.js +0 -452
  217. package/src/errors/typed.js.map +0 -1
  218. package/src/gender/gender-categories.d.ts.map +0 -1
  219. package/src/gender/gender-categories.js +0 -15
  220. package/src/gender/gender-categories.js.map +0 -1
  221. package/src/gender/gender-resolver.d.ts +0 -14
  222. package/src/gender/gender-resolver.d.ts.map +0 -1
  223. package/src/gender/gender-resolver.js +0 -35
  224. package/src/gender/gender-resolver.js.map +0 -1
  225. package/src/gender/index.d.ts.map +0 -1
  226. package/src/gender/index.js +0 -6
  227. package/src/gender/index.js.map +0 -1
  228. package/src/global-active-context.d.ts +0 -50
  229. package/src/global-active-context.d.ts.map +0 -1
  230. package/src/global-active-context.js +0 -185
  231. package/src/global-active-context.js.map +0 -1
  232. package/src/icu/ast.d.ts +0 -48
  233. package/src/icu/ast.d.ts.map +0 -1
  234. package/src/icu/ast.js +0 -16
  235. package/src/icu/ast.js.map +0 -1
  236. package/src/icu/compiler.d.ts +0 -16
  237. package/src/icu/compiler.d.ts.map +0 -1
  238. package/src/icu/compiler.js +0 -87
  239. package/src/icu/compiler.js.map +0 -1
  240. package/src/icu/formatter-registry.d.ts +0 -10
  241. package/src/icu/formatter-registry.d.ts.map +0 -1
  242. package/src/icu/formatter-registry.js +0 -34
  243. package/src/icu/formatter-registry.js.map +0 -1
  244. package/src/icu/formatters/base-formatter.d.ts +0 -8
  245. package/src/icu/formatters/base-formatter.d.ts.map +0 -1
  246. package/src/icu/formatters/base-formatter.js +0 -3
  247. package/src/icu/formatters/base-formatter.js.map +0 -1
  248. package/src/icu/formatters/date-formatter.d.ts +0 -5
  249. package/src/icu/formatters/date-formatter.d.ts.map +0 -1
  250. package/src/icu/formatters/date-formatter.js +0 -31
  251. package/src/icu/formatters/date-formatter.js.map +0 -1
  252. package/src/icu/formatters/number-formatter.d.ts +0 -5
  253. package/src/icu/formatters/number-formatter.d.ts.map +0 -1
  254. package/src/icu/formatters/number-formatter.js +0 -33
  255. package/src/icu/formatters/number-formatter.js.map +0 -1
  256. package/src/icu/formatters/plural-formatter.d.ts +0 -5
  257. package/src/icu/formatters/plural-formatter.d.ts.map +0 -1
  258. package/src/icu/formatters/plural-formatter.js +0 -15
  259. package/src/icu/formatters/plural-formatter.js.map +0 -1
  260. package/src/icu/formatters/select-formatter.d.ts +0 -5
  261. package/src/icu/formatters/select-formatter.d.ts.map +0 -1
  262. package/src/icu/formatters/select-formatter.js +0 -10
  263. package/src/icu/formatters/select-formatter.js.map +0 -1
  264. package/src/icu/formatters/selectordinal-formatter.d.ts +0 -5
  265. package/src/icu/formatters/selectordinal-formatter.d.ts.map +0 -1
  266. package/src/icu/formatters/selectordinal-formatter.js +0 -22
  267. package/src/icu/formatters/selectordinal-formatter.js.map +0 -1
  268. package/src/icu/formatters/time-formatter.d.ts +0 -5
  269. package/src/icu/formatters/time-formatter.d.ts.map +0 -1
  270. package/src/icu/formatters/time-formatter.js +0 -31
  271. package/src/icu/formatters/time-formatter.js.map +0 -1
  272. package/src/icu/helpers.d.ts +0 -9
  273. package/src/icu/helpers.d.ts.map +0 -1
  274. package/src/icu/helpers.js +0 -31
  275. package/src/icu/helpers.js.map +0 -1
  276. package/src/icu/parser.d.ts +0 -31
  277. package/src/icu/parser.d.ts.map +0 -1
  278. package/src/icu/parser.js +0 -203
  279. package/src/icu/parser.js.map +0 -1
  280. package/src/icu/runtime.d.ts +0 -10
  281. package/src/icu/runtime.d.ts.map +0 -1
  282. package/src/icu/runtime.js +0 -33
  283. package/src/icu/runtime.js.map +0 -1
  284. package/src/icu/tokenizer.d.ts +0 -37
  285. package/src/icu/tokenizer.d.ts.map +0 -1
  286. package/src/icu/tokenizer.js +0 -187
  287. package/src/icu/tokenizer.js.map +0 -1
  288. package/src/icu/validator.d.ts +0 -11
  289. package/src/icu/validator.d.ts.map +0 -1
  290. package/src/icu/validator.js +0 -140
  291. package/src/icu/validator.js.map +0 -1
  292. package/src/index.d.ts.map +0 -1
  293. package/src/index.js +0 -76
  294. package/src/index.js.map +0 -1
  295. package/src/interfaces/component-config.interface.d.ts +0 -16
  296. package/src/interfaces/component-config.interface.d.ts.map +0 -1
  297. package/src/interfaces/component-config.interface.js +0 -6
  298. package/src/interfaces/component-config.interface.js.map +0 -1
  299. package/src/interfaces/engine-config.interface.d.ts +0 -22
  300. package/src/interfaces/engine-config.interface.d.ts.map +0 -1
  301. package/src/interfaces/engine-config.interface.js +0 -6
  302. package/src/interfaces/engine-config.interface.js.map +0 -1
  303. package/src/interfaces/global-active-context.d.ts +0 -23
  304. package/src/interfaces/global-active-context.d.ts.map +0 -1
  305. package/src/interfaces/global-active-context.js +0 -3
  306. package/src/interfaces/global-active-context.js.map +0 -1
  307. package/src/interfaces/handleable-error-options.d.ts +0 -14
  308. package/src/interfaces/handleable-error-options.d.ts.map +0 -1
  309. package/src/interfaces/handleable-error-options.js +0 -3
  310. package/src/interfaces/handleable-error-options.js.map +0 -1
  311. package/src/interfaces/handleable.d.ts +0 -21
  312. package/src/interfaces/handleable.d.ts.map +0 -1
  313. package/src/interfaces/handleable.js +0 -3
  314. package/src/interfaces/handleable.js.map +0 -1
  315. package/src/interfaces/i18n-engine.interface.d.ts +0 -46
  316. package/src/interfaces/i18n-engine.interface.d.ts.map +0 -1
  317. package/src/interfaces/i18n-engine.interface.js +0 -6
  318. package/src/interfaces/i18n-engine.interface.js.map +0 -1
  319. package/src/interfaces/index.d.ts +0 -11
  320. package/src/interfaces/index.d.ts.map +0 -1
  321. package/src/interfaces/index.js +0 -14
  322. package/src/interfaces/index.js.map +0 -1
  323. package/src/interfaces/language-definition.interface.d.ts +0 -17
  324. package/src/interfaces/language-definition.interface.d.ts.map +0 -1
  325. package/src/interfaces/language-definition.interface.js +0 -6
  326. package/src/interfaces/language-definition.interface.js.map +0 -1
  327. package/src/interfaces/translation-options.interface.d.ts +0 -15
  328. package/src/interfaces/translation-options.interface.d.ts.map +0 -1
  329. package/src/interfaces/translation-options.interface.js +0 -6
  330. package/src/interfaces/translation-options.interface.js.map +0 -1
  331. package/src/interfaces/validation-result.interface.d.ts +0 -24
  332. package/src/interfaces/validation-result.interface.d.ts.map +0 -1
  333. package/src/interfaces/validation-result.interface.js +0 -6
  334. package/src/interfaces/validation-result.interface.js.map +0 -1
  335. package/src/language-codes.d.ts +0 -28
  336. package/src/language-codes.d.ts.map +0 -1
  337. package/src/language-codes.js +0 -32
  338. package/src/language-codes.js.map +0 -1
  339. package/src/language-definition.d.ts +0 -14
  340. package/src/language-definition.d.ts.map +0 -1
  341. package/src/language-definition.js +0 -3
  342. package/src/language-definition.js.map +0 -1
  343. package/src/plugin-i18n-engine.d.ts +0 -164
  344. package/src/plugin-i18n-engine.d.ts.map +0 -1
  345. package/src/plugin-i18n-engine.js +0 -489
  346. package/src/plugin-i18n-engine.js.map +0 -1
  347. package/src/pluralization/index.d.ts.map +0 -1
  348. package/src/pluralization/index.js +0 -10
  349. package/src/pluralization/index.js.map +0 -1
  350. package/src/pluralization/language-plural-map.d.ts +0 -29
  351. package/src/pluralization/language-plural-map.d.ts.map +0 -1
  352. package/src/pluralization/language-plural-map.js +0 -155
  353. package/src/pluralization/language-plural-map.js.map +0 -1
  354. package/src/pluralization/plural-categories.d.ts.map +0 -1
  355. package/src/pluralization/plural-categories.js +0 -8
  356. package/src/pluralization/plural-categories.js.map +0 -1
  357. package/src/pluralization/plural-rules.d.ts +0 -102
  358. package/src/pluralization/plural-rules.d.ts.map +0 -1
  359. package/src/pluralization/plural-rules.js +0 -263
  360. package/src/pluralization/plural-rules.js.map +0 -1
  361. package/src/registry-config.d.ts +0 -16
  362. package/src/registry-config.d.ts.map +0 -1
  363. package/src/registry-config.js +0 -3
  364. package/src/registry-config.js.map +0 -1
  365. package/src/registry-error-type.d.ts +0 -20
  366. package/src/registry-error-type.d.ts.map +0 -1
  367. package/src/registry-error-type.js +0 -24
  368. package/src/registry-error-type.js.map +0 -1
  369. package/src/registry-error.d.ts +0 -19
  370. package/src/registry-error.d.ts.map +0 -1
  371. package/src/registry-error.js +0 -49
  372. package/src/registry-error.js.map +0 -1
  373. package/src/strict-types.d.ts +0 -19
  374. package/src/strict-types.d.ts.map +0 -1
  375. package/src/strict-types.js +0 -18
  376. package/src/strict-types.js.map +0 -1
  377. package/src/strings/de.d.ts +0 -3
  378. package/src/strings/de.d.ts.map +0 -1
  379. package/src/strings/de.js +0 -57
  380. package/src/strings/de.js.map +0 -1
  381. package/src/strings/en-GB.d.ts +0 -3
  382. package/src/strings/en-GB.d.ts.map +0 -1
  383. package/src/strings/en-GB.js +0 -57
  384. package/src/strings/en-GB.js.map +0 -1
  385. package/src/strings/en-US.d.ts +0 -3
  386. package/src/strings/en-US.d.ts.map +0 -1
  387. package/src/strings/en-US.js +0 -57
  388. package/src/strings/en-US.js.map +0 -1
  389. package/src/strings/es.d.ts +0 -3
  390. package/src/strings/es.d.ts.map +0 -1
  391. package/src/strings/es.js +0 -57
  392. package/src/strings/es.js.map +0 -1
  393. package/src/strings/fr.d.ts +0 -3
  394. package/src/strings/fr.d.ts.map +0 -1
  395. package/src/strings/fr.js +0 -57
  396. package/src/strings/fr.js.map +0 -1
  397. package/src/strings/ja.d.ts +0 -3
  398. package/src/strings/ja.d.ts.map +0 -1
  399. package/src/strings/ja.js +0 -57
  400. package/src/strings/ja.js.map +0 -1
  401. package/src/strings/uk.d.ts +0 -3
  402. package/src/strings/uk.d.ts.map +0 -1
  403. package/src/strings/uk.js +0 -57
  404. package/src/strings/uk.js.map +0 -1
  405. package/src/strings/zh-CN.d.ts +0 -3
  406. package/src/strings/zh-CN.d.ts.map +0 -1
  407. package/src/strings/zh-CN.js +0 -57
  408. package/src/strings/zh-CN.js.map +0 -1
  409. package/src/template.d.ts +0 -13
  410. package/src/template.d.ts.map +0 -1
  411. package/src/template.js +0 -40
  412. package/src/template.js.map +0 -1
  413. package/src/translation-engine.d.ts +0 -9
  414. package/src/translation-engine.d.ts.map +0 -1
  415. package/src/translation-engine.js +0 -3
  416. package/src/translation-engine.js.map +0 -1
  417. package/src/translation-request.d.ts +0 -10
  418. package/src/translation-request.d.ts.map +0 -1
  419. package/src/translation-request.js +0 -3
  420. package/src/translation-request.js.map +0 -1
  421. package/src/translation-response.d.ts +0 -9
  422. package/src/translation-response.d.ts.map +0 -1
  423. package/src/translation-response.js +0 -3
  424. package/src/translation-response.js.map +0 -1
  425. package/src/types/engine.d.ts +0 -47
  426. package/src/types/engine.d.ts.map +0 -1
  427. package/src/types/engine.js +0 -8
  428. package/src/types/engine.js.map +0 -1
  429. package/src/types/index.d.ts.map +0 -1
  430. package/src/types/index.js +0 -9
  431. package/src/types/index.js.map +0 -1
  432. package/src/types/plural-types.d.ts.map +0 -1
  433. package/src/types/plural-types.js +0 -39
  434. package/src/types/plural-types.js.map +0 -1
  435. package/src/types.d.ts +0 -96
  436. package/src/types.d.ts.map +0 -1
  437. package/src/types.js +0 -23
  438. package/src/types.js.map +0 -1
  439. package/src/utils/currency.d.ts +0 -81
  440. package/src/utils/currency.d.ts.map +0 -1
  441. package/src/utils/currency.js +0 -101
  442. package/src/utils/currency.js.map +0 -1
  443. package/src/utils/html-escape.d.ts +0 -22
  444. package/src/utils/html-escape.d.ts.map +0 -1
  445. package/src/utils/html-escape.js +0 -53
  446. package/src/utils/html-escape.js.map +0 -1
  447. package/src/utils/index.d.ts.map +0 -1
  448. package/src/utils/index.js +0 -12
  449. package/src/utils/index.js.map +0 -1
  450. package/src/utils/lru-cache.d.ts +0 -42
  451. package/src/utils/lru-cache.d.ts.map +0 -1
  452. package/src/utils/lru-cache.js +0 -73
  453. package/src/utils/lru-cache.js.map +0 -1
  454. package/src/utils/plural-helpers.d.ts.map +0 -1
  455. package/src/utils/plural-helpers.js +0 -35
  456. package/src/utils/plural-helpers.js.map +0 -1
  457. package/src/utils/safe-object.d.ts +0 -39
  458. package/src/utils/safe-object.d.ts.map +0 -1
  459. package/src/utils/safe-object.js.map +0 -1
  460. package/src/utils/string-utils.d.ts +0 -28
  461. package/src/utils/string-utils.d.ts.map +0 -1
  462. package/src/utils/string-utils.js +0 -63
  463. package/src/utils/string-utils.js.map +0 -1
  464. package/src/utils/timezone.d.ts +0 -50
  465. package/src/utils/timezone.d.ts.map +0 -1
  466. package/src/utils/timezone.js +0 -74
  467. package/src/utils/timezone.js.map +0 -1
  468. package/src/utils/validation.d.ts +0 -40
  469. package/src/utils/validation.d.ts.map +0 -1
  470. package/src/utils/validation.js +0 -69
  471. package/src/utils/validation.js.map +0 -1
  472. package/src/utils.d.ts +0 -65
  473. package/src/utils.d.ts.map +0 -1
  474. package/src/utils.js +0 -129
  475. package/src/utils.js.map +0 -1
  476. package/src/validation/index.d.ts.map +0 -1
  477. package/src/validation/index.js +0 -5
  478. package/src/validation/index.js.map +0 -1
  479. package/src/validation/plural-validator.d.ts +0 -46
  480. package/src/validation/plural-validator.d.ts.map +0 -1
  481. package/src/validation/plural-validator.js +0 -123
  482. package/src/validation/plural-validator.js.map +0 -1
  483. package/src/validation-config.d.ts +0 -12
  484. package/src/validation-config.d.ts.map +0 -1
  485. package/src/validation-config.js +0 -3
  486. package/src/validation-config.js.map +0 -1
  487. package/src/validation-result.d.ts +0 -13
  488. package/src/validation-result.d.ts.map +0 -1
  489. package/src/validation-result.js +0 -3
  490. package/src/validation-result.js.map +0 -1
@@ -1,123 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnumTranslationRegistry = void 0;
4
- /**
5
- * Registry for managing translations of enum values across multiple languages.
6
- *
7
- * @template TStringKey Type of translation key used in error messages.
8
- * @template TLanguage Type of supported language codes.
9
- */
10
- class EnumTranslationRegistry {
11
- translations = new Map();
12
- enumNames = new WeakMap();
13
- availableLanguages;
14
- translateFn;
15
- /**
16
- * Creates a new EnumTranslationRegistry.
17
- *
18
- * @param availableLanguages Array of supported language codes.
19
- * @param translateFn Optional translation function for error templates.
20
- */
21
- constructor(availableLanguages, translateFn) {
22
- this.availableLanguages = new Set(availableLanguages);
23
- this.translateFn = translateFn;
24
- }
25
- /**
26
- * Registers an enum and its language-specific translations.
27
- *
28
- * @template TEnum Enum value type (string or number).
29
- * @param enumObj The enum object to register.
30
- * @param translations Mapping of language codes to value-to-string translations.
31
- * @param enumName Human-readable name of the enum (used in errors).
32
- * @throws {Error} If translations contain languages not in availableLanguages.
33
- */
34
- register(enumObj, translations, enumName) {
35
- this.validateTranslations(translations, enumName);
36
- this.translations.set(enumObj, translations);
37
- this.enumNames.set(enumObj, enumName);
38
- }
39
- /**
40
- * Translates a specific enum value into the target language.
41
- *
42
- * @template TEnum Enum value type.
43
- * @param enumObj The enum object registered previously.
44
- * @param value The enum value to translate.
45
- * @param language The target language code.
46
- * @returns The translated string.
47
- * @throws {Error} If the enum or language or value is not found.
48
- */
49
- translate(enumObj, value, language) {
50
- const translations = this.translations.get(enumObj);
51
- if (!translations) {
52
- const message = this.translateFn
53
- ? this.translateFn('Error_EnumNotFoundTemplate', {
54
- enumName: this.getEnumName(enumObj),
55
- })
56
- : `No translations found for enum: ${this.getEnumName(enumObj)}`;
57
- throw new Error(message);
58
- }
59
- const langTranslations = translations[language];
60
- if (!langTranslations) {
61
- const message = this.translateFn
62
- ? this.translateFn('Error_EnumLanguageNotFoundTemplate', {
63
- language,
64
- })
65
- : `No translations found for language: ${language}`;
66
- throw new Error(message);
67
- }
68
- let result = langTranslations[value];
69
- if (!result && typeof value === 'number') {
70
- const stringKey = Object.keys(enumObj).find((key) => enumObj[key] === value);
71
- if (stringKey) {
72
- result = langTranslations[stringKey];
73
- }
74
- }
75
- if (!result) {
76
- const message = this.translateFn
77
- ? this.translateFn('Error_EnumValueNotFoundTemplate', {
78
- value: String(value),
79
- })
80
- : `No translation found for value: ${String(value)}`;
81
- throw new Error(message);
82
- }
83
- return result;
84
- }
85
- /**
86
- * Checks whether translations exist for the given enum object.
87
- *
88
- * @param enumObj The enum object to check.
89
- * @returns True if registered, false otherwise.
90
- */
91
- has(enumObj) {
92
- return this.translations.has(enumObj);
93
- }
94
- /**
95
- * Internal: Retrieves the human-readable name of the enum.
96
- *
97
- * @param enumObj The enum object.
98
- * @returns Registered enum name or 'UnknownEnum' if not set.
99
- */
100
- getEnumName(enumObj) {
101
- return this.enumNames.get(enumObj) || 'UnknownEnum';
102
- }
103
- /**
104
- * Internal: Validates that translation entries only use available languages.
105
- *
106
- * @template TEnum Enum value type.
107
- * @param translations Mapping of language codes to translations.
108
- * @param enumName Enum name for error reporting.
109
- * @throws {Error} If a translation language is not available.
110
- */
111
- validateTranslations(translations, enumName) {
112
- for (const language of Object.keys(translations)) {
113
- if (!this.availableLanguages.has(language)) {
114
- const message = this.translateFn
115
- ? this.translateFn('Error_EnumLanguageNotAvailableTemplate', { language, enumName })
116
- : `Language '${language}' in enum '${enumName}' is not available in this registry`;
117
- throw new Error(message);
118
- }
119
- }
120
- }
121
- }
122
- exports.EnumTranslationRegistry = EnumTranslationRegistry;
123
- //# sourceMappingURL=enum-registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enum-registry.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/enum-registry.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,MAAa,uBAAuB;IAIxB,YAAY,GAAG,IAAI,GAAG,EAAgD,CAAC;IACvE,SAAS,GAAG,IAAI,OAAO,EAAe,CAAC;IACvC,kBAAkB,CAAiB;IACnC,WAAW,CAA2D;IAEhF;;;;;OAKG;IACH,YACE,kBAA+B,EAC/B,WAAqE;QAErE,IAAI,CAAC,kBAAkB,GAAG,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACtD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;;;;OAQG;IACI,QAAQ,CACb,OAA8B,EAC9B,YAAuD,EACvD,QAAgB;QAEhB,IAAI,CAAC,oBAAoB,CAA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CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA/ID,0DA+IC"}
@@ -1,50 +0,0 @@
1
- import { ContextErrorType } from '../context-error-type';
2
- /**
3
- * Error class for context-related failures in the i18n system.
4
- * Thrown when attempting to access or manipulate an invalid or non-existent context.
5
- *
6
- * **i18n Feature Support:**
7
- * - ICU MessageFormat variable substitution
8
- * - Nested message paths detection
9
- * - Number formatting for context depths/positions
10
- * - SelectOrdinal for context priority levels
11
- *
12
- * **Translation String Examples:**
13
- * ```typescript
14
- * // ICU plural
15
- * "Context has {count, plural, one {# issue} other {# issues}}"
16
- *
17
- * // ICU select + nested
18
- * "{severity, select, low {Minor context issue} high {Critical context error}}"
19
- *
20
- * // Number formatting
21
- * "Context exceeded {limit, number, integer} maximum depth"
22
- * ```
23
- */
24
- export declare class ContextError extends Error {
25
- /** The type of context error */
26
- readonly type: ContextErrorType;
27
- /** The context key that caused the error, if applicable */
28
- readonly contextKey?: string;
29
- /** Additional context metadata */
30
- readonly metadata?: Record<string, any>;
31
- /**
32
- * Creates a new ContextError instance.
33
- * @param type - The type of context error
34
- * @param contextKey - Optional context key that caused the error
35
- * @param variables - Additional variables for ICU message formatting
36
- * @param language - Optional language code
37
- */
38
- constructor(type: ContextErrorType, contextKey?: string, variables?: Record<string, string | number>, language?: string);
39
- /**
40
- * Create context error with nested path information
41
- * Demonstrates selectordinal for depth level
42
- */
43
- static withNestedPath(type: ContextErrorType, contextPath: string, language?: string): ContextError;
44
- /**
45
- * Create context error with count information
46
- * Demonstrates plural formatting
47
- */
48
- static withCount(type: ContextErrorType, contextKey: string, count: number, language?: string): ContextError;
49
- }
50
- //# sourceMappingURL=context-error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-error.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/context-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAKzD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,gCAAgC;IAChC,SAAyB,IAAI,EAAE,gBAAgB,CAAC;IAChD,2DAA2D;IAC3D,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,kCAAkC;IAClC,SAAyB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAExD;;;;;;OAMG;gBAED,IAAI,EAAE,gBAAgB,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3C,QAAQ,CAAC,EAAE,MAAM;IAwBnB;;;OAGG;IACH,MAAM,CAAC,cAAc,CACnB,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,MAAM,EACnB,QAAQ,SAAU,GACjB,YAAY;IAaf;;;OAGG;IACH,MAAM,CAAC,SAAS,CACd,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,QAAQ,SAAU,GACjB,YAAY;CAGhB"}
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContextError = void 0;
4
- const core_i18n_1 = require("../core-i18n");
5
- const core_string_key_1 = require("../core-string-key");
6
- const enhanced_error_base_1 = require("./enhanced-error-base");
7
- /**
8
- * Error class for context-related failures in the i18n system.
9
- * Thrown when attempting to access or manipulate an invalid or non-existent context.
10
- *
11
- * **i18n Feature Support:**
12
- * - ICU MessageFormat variable substitution
13
- * - Nested message paths detection
14
- * - Number formatting for context depths/positions
15
- * - SelectOrdinal for context priority levels
16
- *
17
- * **Translation String Examples:**
18
- * ```typescript
19
- * // ICU plural
20
- * "Context has {count, plural, one {# issue} other {# issues}}"
21
- *
22
- * // ICU select + nested
23
- * "{severity, select, low {Minor context issue} high {Critical context error}}"
24
- *
25
- * // Number formatting
26
- * "Context exceeded {limit, number, integer} maximum depth"
27
- * ```
28
- */
29
- class ContextError extends Error {
30
- /** The type of context error */
31
- type;
32
- /** The context key that caused the error, if applicable */
33
- contextKey;
34
- /** Additional context metadata */
35
- metadata;
36
- /**
37
- * Creates a new ContextError instance.
38
- * @param type - The type of context error
39
- * @param contextKey - Optional context key that caused the error
40
- * @param variables - Additional variables for ICU message formatting
41
- * @param language - Optional language code
42
- */
43
- constructor(type, contextKey, variables, language) {
44
- const engine = (0, core_i18n_1.getCoreI18nEngine)();
45
- const allVars = { ...variables, contextKey: contextKey || '' };
46
- const message = contextKey
47
- ? engine.safeTranslate(core_i18n_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_InvalidContextTemplate, allVars, language)
48
- : engine.safeTranslate(core_i18n_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_InvalidContext, allVars, language);
49
- super(message);
50
- this.name = 'ContextError';
51
- this.type = type;
52
- this.contextKey = contextKey;
53
- this.metadata = variables;
54
- }
55
- /**
56
- * Create context error with nested path information
57
- * Demonstrates selectordinal for depth level
58
- */
59
- static withNestedPath(type, contextPath, language = 'en-US') {
60
- const analysis = enhanced_error_base_1.EnhancedErrorHelper.analyzeKeyPath(contextPath);
61
- return new ContextError(type, contextPath, {
62
- depth: analysis.depth,
63
- isNested: analysis.isNested ? 'true' : 'false',
64
- }, language);
65
- }
66
- /**
67
- * Create context error with count information
68
- * Demonstrates plural formatting
69
- */
70
- static withCount(type, contextKey, count, language = 'en-US') {
71
- return new ContextError(type, contextKey, { count }, language);
72
- }
73
- }
74
- exports.ContextError = ContextError;
75
- //# sourceMappingURL=context-error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-error.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/context-error.ts"],"names":[],"mappings":";;;AACA,4CAAsE;AACtE,wDAAmD;AACnD,+DAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,YAAa,SAAQ,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EAClB,KAAa,EACb,QAAQ,GAAG,OAAO;QAElB,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;CACF;AA5ED,oCA4EC"}
@@ -1,125 +0,0 @@
1
- /**
2
- * Enhanced error base with i18n 3.0/3.5 feature support
3
- * Provides helper methods for ICU MessageFormat, pluralization, gender, and advanced features
4
- */
5
- import { GenderCategory } from '../gender/gender-categories';
6
- /**
7
- * Options for enhanced error message formatting
8
- */
9
- export interface EnhancedErrorOptions {
10
- /** Variables for ICU substitution */
11
- variables?: Record<string, string | number | boolean>;
12
- /** Language code for message formatting */
13
- language?: string;
14
- /** Count for plural formatting */
15
- count?: number;
16
- /** Gender for gender-aware formatting */
17
- gender?: GenderCategory;
18
- /** Additional metadata */
19
- metadata?: Record<string, any>;
20
- }
21
- /**
22
- * Helper class providing advanced i18n features for error messages
23
- * This can be used as a mixin or utility class for error classes
24
- */
25
- export declare class EnhancedErrorHelper {
26
- /**
27
- * Format error message with ICU MessageFormat
28
- * @param pattern - ICU message pattern
29
- * @param options - Formatting options
30
- * @returns Formatted message string
31
- */
32
- static formatMessage(pattern: string, options?: EnhancedErrorOptions): string;
33
- /**
34
- * Create a plural-aware error message
35
- * @param singularPattern - Pattern for singular form
36
- * @param pluralPattern - Pattern for plural form
37
- * @param count - Count value
38
- * @param options - Additional formatting options
39
- * @returns Formatted message
40
- */
41
- static formatPlural(singularPattern: string, pluralPattern: string, count: number, options?: Omit<EnhancedErrorOptions, 'count'>): string;
42
- /**
43
- * Create a gender-aware error message
44
- * @param patterns - Patterns for different genders
45
- * @param gender - Gender value
46
- * @param options - Additional formatting options
47
- * @returns Formatted message
48
- */
49
- static formatGender(patterns: Partial<Record<GenderCategory, string>>, gender: GenderCategory, options?: Omit<EnhancedErrorOptions, 'gender'>): string;
50
- /**
51
- * Format ordinal numbers (1st, 2nd, 3rd, etc.)
52
- * @param number - The number to format
53
- * @param pattern - Pattern with {number} placeholder
54
- * @param options - Additional formatting options
55
- * @returns Formatted message with ordinal
56
- */
57
- static formatOrdinal(number: number, pattern: string, options?: EnhancedErrorOptions): string;
58
- /**
59
- * Format numbers with specific formatting (integer, currency, percent)
60
- * @param value - Number value
61
- * @param format - Format type
62
- * @param pattern - Pattern with {value} placeholder
63
- * @param options - Additional formatting options
64
- * @returns Formatted message
65
- */
66
- static formatNumber(value: number, format: 'integer' | 'currency' | 'percent', pattern: string, options?: EnhancedErrorOptions): string;
67
- /**
68
- * Create nested messages with multiple levels of ICU formatting
69
- * @param pattern - Complex nested ICU pattern
70
- * @param options - Formatting options
71
- * @returns Formatted message
72
- */
73
- static formatNested(pattern: string, options?: EnhancedErrorOptions): string;
74
- /**
75
- * Detect if a string key represents a nested path
76
- * @param key - String key to check
77
- * @returns Object with nesting information
78
- */
79
- static analyzeKeyPath(key: string): {
80
- isNested: boolean;
81
- depth: number;
82
- parts: string[];
83
- };
84
- /**
85
- * Create metadata object with count information for debugging
86
- * @param count - Count value
87
- * @param additionalMetadata - Additional metadata to include
88
- * @returns Metadata object
89
- */
90
- static createCountMetadata(count: number, additionalMetadata?: Record<string, any>): Record<string, any>;
91
- /**
92
- * Validate that all required ICU variables are provided
93
- * @param pattern - ICU pattern
94
- * @param variables - Provided variables
95
- * @returns Object with validation result
96
- */
97
- static validateVariables(pattern: string, variables: Record<string, any>): {
98
- valid: boolean;
99
- missing: string[];
100
- };
101
- }
102
- /**
103
- * Mixin function to add enhanced i18n features to error classes
104
- * @param Base - Base error class
105
- * @returns Enhanced error class
106
- */
107
- export declare function withEnhancedI18n<T extends new (...args: any[]) => Error>(Base: T): {
108
- new (...args: any[]): {
109
- formatMessage(pattern: string, options?: EnhancedErrorOptions): string;
110
- formatPlural(singularPattern: string, pluralPattern: string, count: number, options?: Omit<EnhancedErrorOptions, "count">): string;
111
- formatGender(patterns: Partial<Record<GenderCategory, string>>, gender: GenderCategory, options?: Omit<EnhancedErrorOptions, "gender">): string;
112
- formatOrdinal(number: number, pattern: string, options?: EnhancedErrorOptions): string;
113
- formatNumber(value: number, format: "integer" | "currency" | "percent", pattern: string, options?: EnhancedErrorOptions): string;
114
- name: string;
115
- message: string;
116
- stack?: string;
117
- cause?: unknown;
118
- disposedAt?: string;
119
- type?: string;
120
- componentId?: string;
121
- reasonMap?: Record<string, unknown>;
122
- metadata?: Record<string, unknown>;
123
- };
124
- } & T;
125
- //# sourceMappingURL=enhanced-error-base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enhanced-error-base.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/enhanced-error-base.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACtD,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAClB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,oBAAyB,GACjC,MAAM;IAaT;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CACjB,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAM,GAChD,MAAM;IAKT;;;;;;OAMG;IACH,MAAM,CAA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I,EAAE,CAAC;kBADgD,GAAG,EAAE;+BAK/C,MAAM,YACN,oBAAoB,GAC5B,MAAM;sCAKU,MAAM,iBACR,MAAM,SACd,MAAM,YACJ,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAC3C,MAAM;+BAKG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,UACzC,cAAc,YACb,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,GAC5C,MAAM;8BAKC,MAAM,WACL,MAAM,YACN,oBAAoB,GAC5B,MAAM;4BAKA,MAAM,UACL,SAAS,GAAG,UAAU,GAAG,SAAS,WACjC,MAAM,YACN,oBAAoB,GAC5B,MAAM;;;;;;;;;;;MAIZ"}
@@ -1,165 +0,0 @@
1
- "use strict";
2
- /**
3
- * Enhanced error base with i18n 3.0/3.5 feature support
4
- * Provides helper methods for ICU MessageFormat, pluralization, gender, and advanced features
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.EnhancedErrorHelper = void 0;
8
- exports.withEnhancedI18n = withEnhancedI18n;
9
- const helpers_1 = require("../icu/helpers");
10
- /**
11
- * Helper class providing advanced i18n features for error messages
12
- * This can be used as a mixin or utility class for error classes
13
- */
14
- class EnhancedErrorHelper {
15
- /**
16
- * Format error message with ICU MessageFormat
17
- * @param pattern - ICU message pattern
18
- * @param options - Formatting options
19
- * @returns Formatted message string
20
- */
21
- static formatMessage(pattern, options = {}) {
22
- const { variables = {}, language = 'en-US', count, gender } = options;
23
- // Add count and gender to variables if provided
24
- const allVars = {
25
- ...variables,
26
- ...(count !== undefined ? { count } : {}),
27
- ...(gender ? { gender } : {}),
28
- };
29
- return (0, helpers_1.formatICUMessage)(pattern, allVars, language);
30
- }
31
- /**
32
- * Create a plural-aware error message
33
- * @param singularPattern - Pattern for singular form
34
- * @param pluralPattern - Pattern for plural form
35
- * @param count - Count value
36
- * @param options - Additional formatting options
37
- * @returns Formatted message
38
- */
39
- static formatPlural(singularPattern, pluralPattern, count, options = {}) {
40
- const pattern = `{count, plural, one {${singularPattern}} other {${pluralPattern}}}`;
41
- return this.formatMessage(pattern, { ...options, count });
42
- }
43
- /**
44
- * Create a gender-aware error message
45
- * @param patterns - Patterns for different genders
46
- * @param gender - Gender value
47
- * @param options - Additional formatting options
48
- * @returns Formatted message
49
- */
50
- static formatGender(patterns, gender, options = {}) {
51
- const { male, female, neutral, other } = patterns;
52
- const selectPattern = `{gender, select, ${male ? `male {${male}}` : ''} ${female ? `female {${female}}` : ''} ${neutral ? `neutral {${neutral}}` : ''} other {${other || patterns.male || patterns.female || patterns.neutral || 'Error'}}}`;
53
- return this.formatMessage(selectPattern, { ...options, gender });
54
- }
55
- /**
56
- * Format ordinal numbers (1st, 2nd, 3rd, etc.)
57
- * @param number - The number to format
58
- * @param pattern - Pattern with {number} placeholder
59
- * @param options - Additional formatting options
60
- * @returns Formatted message with ordinal
61
- */
62
- static formatOrdinal(number, pattern, options = {}) {
63
- const ordinalPattern = pattern.replace('{number}', `{number, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}`);
64
- return this.formatMessage(ordinalPattern, {
65
- ...options,
66
- variables: { ...options.variables, number },
67
- });
68
- }
69
- /**
70
- * Format numbers with specific formatting (integer, currency, percent)
71
- * @param value - Number value
72
- * @param format - Format type
73
- * @param pattern - Pattern with {value} placeholder
74
- * @param options - Additional formatting options
75
- * @returns Formatted message
76
- */
77
- static formatNumber(value, format, pattern, options = {}) {
78
- const numberPattern = pattern.replace('{value}', `{value, number, ${format}}`);
79
- return this.formatMessage(numberPattern, {
80
- ...options,
81
- variables: { ...options.variables, value },
82
- });
83
- }
84
- /**
85
- * Create nested messages with multiple levels of ICU formatting
86
- * @param pattern - Complex nested ICU pattern
87
- * @param options - Formatting options
88
- * @returns Formatted message
89
- */
90
- static formatNested(pattern, options = {}) {
91
- return this.formatMessage(pattern, options);
92
- }
93
- /**
94
- * Detect if a string key represents a nested path
95
- * @param key - String key to check
96
- * @returns Object with nesting information
97
- */
98
- static analyzeKeyPath(key) {
99
- const parts = key.split('.');
100
- return {
101
- isNested: parts.length > 1,
102
- depth: parts.length,
103
- parts,
104
- };
105
- }
106
- /**
107
- * Create metadata object with count information for debugging
108
- * @param count - Count value
109
- * @param additionalMetadata - Additional metadata to include
110
- * @returns Metadata object
111
- */
112
- static createCountMetadata(count, additionalMetadata = {}) {
113
- return {
114
- count,
115
- ...additionalMetadata,
116
- };
117
- }
118
- /**
119
- * Validate that all required ICU variables are provided
120
- * @param pattern - ICU pattern
121
- * @param variables - Provided variables
122
- * @returns Object with validation result
123
- */
124
- static validateVariables(pattern, variables) {
125
- // Extract variable names from ICU pattern
126
- const variableMatches = pattern.match(/\{([a-zA-Z_][a-zA-Z0-9_]*)/g);
127
- if (!variableMatches) {
128
- return { valid: true, missing: [] };
129
- }
130
- const required = variableMatches
131
- .map(match => match.substring(1))
132
- .filter((name, index, self) => self.indexOf(name) === index);
133
- const missing = required.filter(name => !(name in variables));
134
- return {
135
- valid: missing.length === 0,
136
- missing,
137
- };
138
- }
139
- }
140
- exports.EnhancedErrorHelper = EnhancedErrorHelper;
141
- /**
142
- * Mixin function to add enhanced i18n features to error classes
143
- * @param Base - Base error class
144
- * @returns Enhanced error class
145
- */
146
- function withEnhancedI18n(Base) {
147
- return class extends Base {
148
- formatMessage(pattern, options = {}) {
149
- return EnhancedErrorHelper.formatMessage(pattern, options);
150
- }
151
- formatPlural(singularPattern, pluralPattern, count, options = {}) {
152
- return EnhancedErrorHelper.formatPlural(singularPattern, pluralPattern, count, options);
153
- }
154
- formatGender(patterns, gender, options = {}) {
155
- return EnhancedErrorHelper.formatGender(patterns, gender, options);
156
- }
157
- formatOrdinal(number, pattern, options = {}) {
158
- return EnhancedErrorHelper.formatOrdinal(number, pattern, options);
159
- }
160
- formatNumber(value, format, pattern, options = {}) {
161
- return EnhancedErrorHelper.formatNumber(value, format, pattern, options);
162
- }
163
- };
164
- }
165
- //# sourceMappingURL=enhanced-error-base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enhanced-error-base.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/enhanced-error-base.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmNH,4CA6CC;AA9PD,4CAAkD;AAoBlD;;;GAGG;AACH,MAAa,mBAAmB;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAClB,OAAe,EACf,UAAgC,EAAE;QAElC,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAEtE,gDAAgD;QAChD,MAAM,OAAO,GAAG;YACd,GAAG,SAAS;YACZ,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9B,CAAC;QAEF,OAAO,IAAA,0BAAgB,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CACjB,eAAuB,EACvB,aAAqB,EACrB,KAAa,EACb,UAA+C,EAAE;QAEjD,MAAM,OAAO,GAAG,wBAAwB,eAAe,YAAY,aAAa,IAAI,CAAC;QACrF,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CACjB,QAAiD,EACjD,MAAsB,EACtB,UAAgD,EAAE;QAElD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC;QAClD,MAAM,aAAa,GAAG,oBAAoB,IAAI,CAAC,CAAC,CAAC,SAAS,I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AAe,EACf,UAAgC,EAAE;YAElC,OAAO,mBAAmB,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC;QAEM,YAAY,CACjB,eAAuB,EACvB,aAAqB,EACrB,KAAa,EACb,UAA+C,EAAE;YAEjD,OAAO,mBAAmB,CAAC,YAAY,CAAC,eAAe,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC1F,CAAC;QAEM,YAAY,CACjB,QAAiD,EACjD,MAAsB,EACtB,UAAgD,EAAE;YAElD,OAAO,mBAAmB,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACrE,CAAC;QAEM,aAAa,CAClB,MAAc,EACd,OAAe,EACf,UAAgC,EAAE;YAElC,OAAO,mBAAmB,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACrE,CAAC;QAEM,YAAY,CACjB,KAAa,EACb,MAA0C,EAC1C,OAAe,EACf,UAAgC,EAAE;YAElC,OAAO,mBAAmB,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3E,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,83 +0,0 @@
1
- import { IHandleable } from '../interfaces/handleable';
2
- import { HandleableErrorOptions } from '../interfaces/handleable-error-options';
3
- /**
4
- * Base error class that implements IHandleable interface with full i18n support.
5
- *
6
- * Provides enhanced error handling capabilities including status codes, handled state tracking,
7
- * and source data preservation. Fully compatible with all i18n features when used with
8
- * translation strings.
9
- *
10
- * **Supported i18n Features** (via translation strings in derived classes):
11
- * - ICU MessageFormat: plural, select, selectordinal
12
- * - Pluralization: 37 languages with CLDR rules
13
- * - Gender support: male, female, neutral, other
14
- * - Number formatting: integer, currency, percent
15
- * - Nested messages: complex patterns
16
- *
17
- * **Usage Pattern:**
18
- * ```typescript
19
- * // Extend HandleableError with translated messages
20
- * class MyHandleableError extends HandleableError {
21
- * constructor(componentId: string, stringKey: string, variables?: Record<string, any>) {
22
- * const engine = I18nEngine.getInstance();
23
- * const message = engine.translate(componentId, stringKey, variables);
24
- * const error = new Error(message);
25
- * super(error, { statusCode: 400 });
26
- * }
27
- * }
28
- *
29
- * // Register translation with ICU features
30
- * engine.registerComponent({
31
- * component: { id: 'api', stringKeys: ['validationError'] },
32
- * strings: {
33
- * 'en-US': {
34
- * validationError: \"{count, plural, one {# field is invalid} other {# fields are invalid}}\"
35
- * }
36
- * }
37
- * });
38
- *
39
- * // Use with i18n features
40
- * throw new MyHandleableError('api', 'validationError', { count: 3 });
41
- * // Result: \"3 fields are invalid\"
42
- * ```
43
- */
44
- export declare class HandleableError extends Error implements IHandleable {
45
- /** The original error that caused this error */
46
- readonly cause?: Error;
47
- /** HTTP status code associated with this error */
48
- readonly statusCode: number;
49
- /** Optional source data related to the error */
50
- readonly sourceData?: unknown;
51
- /** Internal tracking of whether this error has been handled */
52
- private _handled;
53
- /**
54
- * Creates a new HandleableError instance.
55
- * @param source - The original error being wrapped
56
- * @param options - Optional configuration for the error
57
- */
58
- constructor(source: Error, options?: HandleableErrorOptions);
59
- /**
60
- * Gets the handled state of this error.
61
- * @returns True if the error has been handled, false otherwise
62
- */
63
- get handled(): boolean;
64
- /**
65
- * Sets the handled state of this error.
66
- * @param value - The new handled state
67
- */
68
- set handled(value: boolean);
69
- /**
70
- * Serializes a value to a JSON-compatible format.
71
- * Handles objects with toJSON methods, Error instances, arrays, and plain objects.
72
- * @param value - The value to serialize
73
- * @returns The serialized value
74
- */
75
- private serializeValue;
76
- /**
77
- * Converts the error to a JSON-serializable object.
78
- * Includes name, message, status code, handled state, stack trace, and optional source data.
79
- * @returns A plain object representation of the error
80
- */
81
- toJSON(): Record<string, unknown>;
82
- }
83
- //# sourceMappingURL=handleable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handleable.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/handleable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAShF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,eAAgB,SAAQ,KAAM,YAAW,WAAW;IAC/D,gDAAgD;IAChD,SAAyB,KAAK,CAAC,EAAE,KAAK,CAAC;IACvC,kDAAkD;IAClD,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,gDAAgD;IAChD,SAAgB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrC,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;OAIG;gBACS,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,sBAAsB;IAsB3D;;;OAGG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;OAGG;IACH,IAAW,OAAO,CAAC,KAAK,EAAE,OAAO,EAEhC;IAED;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAuBtB;;;;OAIG;IACI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAazC"}