@digitaldefiance/i18n-lib 3.8.2 → 3.8.4

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 (502) hide show
  1. package/package.json +8 -7
  2. package/src/{active-context.ts → active-context.d.ts} +1 -0
  3. package/src/active-context.d.ts.map +1 -0
  4. package/src/active-context.js +3 -0
  5. package/src/active-context.js.map +1 -0
  6. package/src/builders/i18n-builder.d.ts +26 -0
  7. package/src/builders/i18n-builder.d.ts.map +1 -0
  8. package/src/builders/i18n-builder.js +70 -0
  9. package/src/builders/i18n-builder.js.map +1 -0
  10. package/src/builders/{index.ts → index.d.ts} +1 -1
  11. package/src/builders/index.d.ts.map +1 -0
  12. package/src/builders/index.js +8 -0
  13. package/src/builders/index.js.map +1 -0
  14. package/src/component-definition.d.ts +12 -0
  15. package/src/component-definition.d.ts.map +1 -0
  16. package/src/component-definition.js +3 -0
  17. package/src/component-definition.js.map +1 -0
  18. package/src/component-registration.d.ts +22 -0
  19. package/src/component-registration.d.ts.map +1 -0
  20. package/src/component-registration.js +3 -0
  21. package/src/component-registration.js.map +1 -0
  22. package/src/component-registry.d.ts +102 -0
  23. package/src/component-registry.d.ts.map +1 -0
  24. package/src/component-registry.js +282 -0
  25. package/src/component-registry.js.map +1 -0
  26. package/src/context-error-type.d.ts +8 -0
  27. package/src/context-error-type.d.ts.map +1 -0
  28. package/src/context-error-type.js +12 -0
  29. package/src/context-error-type.js.map +1 -0
  30. package/src/core/component-store.d.ts +93 -0
  31. package/src/core/component-store.d.ts.map +1 -0
  32. package/src/core/component-store.js +198 -0
  33. package/src/core/component-store.js.map +1 -0
  34. package/src/core/context-manager.d.ts +72 -0
  35. package/src/core/context-manager.d.ts.map +1 -0
  36. package/src/core/context-manager.js +98 -0
  37. package/src/core/context-manager.js.map +1 -0
  38. package/src/core/enum-registry.d.ts +48 -0
  39. package/src/core/enum-registry.d.ts.map +1 -0
  40. package/src/core/enum-registry.js +85 -0
  41. package/src/core/enum-registry.js.map +1 -0
  42. package/src/core/i18n-engine.d.ts +241 -0
  43. package/src/core/i18n-engine.d.ts.map +1 -0
  44. package/src/core/i18n-engine.js +568 -0
  45. package/src/core/i18n-engine.js.map +1 -0
  46. package/src/core/{index.ts → index.d.ts} +1 -4
  47. package/src/core/index.d.ts.map +1 -0
  48. package/src/core/index.js +21 -0
  49. package/src/core/index.js.map +1 -0
  50. package/src/core/language-registry.d.ts +180 -0
  51. package/src/core/language-registry.d.ts.map +1 -0
  52. package/src/core/language-registry.js +298 -0
  53. package/src/core/language-registry.js.map +1 -0
  54. package/src/{core-component-id.ts → core-component-id.d.ts} +2 -1
  55. package/src/core-component-id.d.ts.map +1 -0
  56. package/src/core-component-id.js +9 -0
  57. package/src/core-component-id.js.map +1 -0
  58. package/src/core-i18n.d.ts +69 -0
  59. package/src/core-i18n.d.ts.map +1 -0
  60. package/src/core-i18n.js +219 -0
  61. package/src/core-i18n.js.map +1 -0
  62. package/src/core-plugin-factory.d.ts +28 -0
  63. package/src/core-plugin-factory.d.ts.map +1 -0
  64. package/src/core-plugin-factory.js +80 -0
  65. package/src/core-plugin-factory.js.map +1 -0
  66. package/src/core-string-key.d.ts +52 -0
  67. package/src/core-string-key.d.ts.map +1 -0
  68. package/src/core-string-key.js +61 -0
  69. package/src/core-string-key.js.map +1 -0
  70. package/src/create-translation-adapter.d.ts +33 -0
  71. package/src/create-translation-adapter.d.ts.map +1 -0
  72. package/src/create-translation-adapter.js +72 -0
  73. package/src/create-translation-adapter.js.map +1 -0
  74. package/src/enum-registry.d.ts +65 -0
  75. package/src/enum-registry.d.ts.map +1 -0
  76. package/src/enum-registry.js +123 -0
  77. package/src/enum-registry.js.map +1 -0
  78. package/src/errors/{base.ts → base.d.ts} +1 -1
  79. package/src/errors/base.d.ts.map +1 -0
  80. package/src/errors/base.js +11 -0
  81. package/src/errors/base.js.map +1 -0
  82. package/src/errors/context-error.d.ts +50 -0
  83. package/src/errors/context-error.d.ts.map +1 -0
  84. package/src/errors/context-error.js +93 -0
  85. package/src/errors/context-error.js.map +1 -0
  86. package/src/errors/enhanced-error-base.d.ts +125 -0
  87. package/src/errors/enhanced-error-base.d.ts.map +1 -0
  88. package/src/errors/enhanced-error-base.js +165 -0
  89. package/src/errors/enhanced-error-base.js.map +1 -0
  90. package/src/errors/handleable.d.ts +83 -0
  91. package/src/errors/handleable.d.ts.map +1 -0
  92. package/src/errors/handleable.js +136 -0
  93. package/src/errors/handleable.js.map +1 -0
  94. package/src/errors/i18n-error.d.ts +211 -0
  95. package/src/errors/i18n-error.d.ts.map +1 -0
  96. package/src/errors/i18n-error.js +358 -0
  97. package/src/errors/i18n-error.js.map +1 -0
  98. package/src/errors/{index.ts → index.d.ts} +1 -4
  99. package/src/errors/index.d.ts.map +1 -0
  100. package/src/errors/index.js +17 -0
  101. package/src/errors/index.js.map +1 -0
  102. package/src/errors/simple-typed-error.d.ts +53 -0
  103. package/src/errors/simple-typed-error.d.ts.map +1 -0
  104. package/src/errors/simple-typed-error.js +51 -0
  105. package/src/errors/simple-typed-error.js.map +1 -0
  106. package/src/errors/{translatable-exports.ts → translatable-exports.d.ts} +1 -1
  107. package/src/errors/translatable-exports.d.ts.map +1 -0
  108. package/src/errors/translatable-exports.js +15 -0
  109. package/src/errors/translatable-exports.js.map +1 -0
  110. package/src/errors/translatable-generic.d.ts +87 -0
  111. package/src/errors/translatable-generic.d.ts.map +1 -0
  112. package/src/errors/translatable-generic.js +139 -0
  113. package/src/errors/translatable-generic.js.map +1 -0
  114. package/src/errors/translatable-handleable-generic.d.ts +116 -0
  115. package/src/errors/translatable-handleable-generic.d.ts.map +1 -0
  116. package/src/errors/translatable-handleable-generic.js +121 -0
  117. package/src/errors/translatable-handleable-generic.js.map +1 -0
  118. package/src/errors/translatable.d.ts +63 -0
  119. package/src/errors/translatable.d.ts.map +1 -0
  120. package/src/errors/translatable.js +85 -0
  121. package/src/errors/translatable.js.map +1 -0
  122. package/src/errors/typed-handleable.d.ts +62 -0
  123. package/src/errors/typed-handleable.d.ts.map +1 -0
  124. package/src/errors/typed-handleable.js +108 -0
  125. package/src/errors/typed-handleable.js.map +1 -0
  126. package/src/errors/typed.d.ts +206 -0
  127. package/src/errors/typed.d.ts.map +1 -0
  128. package/src/errors/typed.js +458 -0
  129. package/src/errors/typed.js.map +1 -0
  130. package/src/gender/{gender-categories.ts → gender-categories.d.ts} +2 -6
  131. package/src/gender/gender-categories.d.ts.map +1 -0
  132. package/src/gender/gender-categories.js +15 -0
  133. package/src/gender/gender-categories.js.map +1 -0
  134. package/src/gender/gender-resolver.d.ts +14 -0
  135. package/src/gender/gender-resolver.d.ts.map +1 -0
  136. package/src/gender/gender-resolver.js +35 -0
  137. package/src/gender/gender-resolver.js.map +1 -0
  138. package/src/gender/{index.ts → index.d.ts} +1 -0
  139. package/src/gender/index.d.ts.map +1 -0
  140. package/src/gender/index.js +6 -0
  141. package/src/gender/index.js.map +1 -0
  142. package/src/global-active-context.d.ts +50 -0
  143. package/src/global-active-context.d.ts.map +1 -0
  144. package/src/global-active-context.js +185 -0
  145. package/src/global-active-context.js.map +1 -0
  146. package/src/icu/ast.d.ts +48 -0
  147. package/src/icu/ast.d.ts.map +1 -0
  148. package/src/icu/ast.js +16 -0
  149. package/src/icu/ast.js.map +1 -0
  150. package/src/icu/compiler.d.ts +16 -0
  151. package/src/icu/compiler.d.ts.map +1 -0
  152. package/src/icu/compiler.js +87 -0
  153. package/src/icu/compiler.js.map +1 -0
  154. package/src/icu/formatter-registry.d.ts +10 -0
  155. package/src/icu/formatter-registry.d.ts.map +1 -0
  156. package/src/icu/formatter-registry.js +34 -0
  157. package/src/icu/formatter-registry.js.map +1 -0
  158. package/src/icu/formatters/base-formatter.d.ts +8 -0
  159. package/src/icu/formatters/base-formatter.d.ts.map +1 -0
  160. package/src/icu/formatters/base-formatter.js +3 -0
  161. package/src/icu/formatters/base-formatter.js.map +1 -0
  162. package/src/icu/formatters/date-formatter.d.ts +5 -0
  163. package/src/icu/formatters/date-formatter.d.ts.map +1 -0
  164. package/src/icu/formatters/date-formatter.js +31 -0
  165. package/src/icu/formatters/date-formatter.js.map +1 -0
  166. package/src/icu/formatters/number-formatter.d.ts +5 -0
  167. package/src/icu/formatters/number-formatter.d.ts.map +1 -0
  168. package/src/icu/formatters/number-formatter.js +33 -0
  169. package/src/icu/formatters/number-formatter.js.map +1 -0
  170. package/src/icu/formatters/plural-formatter.d.ts +5 -0
  171. package/src/icu/formatters/plural-formatter.d.ts.map +1 -0
  172. package/src/icu/formatters/plural-formatter.js +15 -0
  173. package/src/icu/formatters/plural-formatter.js.map +1 -0
  174. package/src/icu/formatters/select-formatter.d.ts +5 -0
  175. package/src/icu/formatters/select-formatter.d.ts.map +1 -0
  176. package/src/icu/formatters/select-formatter.js +10 -0
  177. package/src/icu/formatters/select-formatter.js.map +1 -0
  178. package/src/icu/formatters/selectordinal-formatter.d.ts +5 -0
  179. package/src/icu/formatters/selectordinal-formatter.d.ts.map +1 -0
  180. package/src/icu/formatters/selectordinal-formatter.js +22 -0
  181. package/src/icu/formatters/selectordinal-formatter.js.map +1 -0
  182. package/src/icu/formatters/time-formatter.d.ts +5 -0
  183. package/src/icu/formatters/time-formatter.d.ts.map +1 -0
  184. package/src/icu/formatters/time-formatter.js +31 -0
  185. package/src/icu/formatters/time-formatter.js.map +1 -0
  186. package/src/icu/helpers.d.ts +9 -0
  187. package/src/icu/helpers.d.ts.map +1 -0
  188. package/src/icu/helpers.js +31 -0
  189. package/src/icu/helpers.js.map +1 -0
  190. package/src/icu/parser.d.ts +31 -0
  191. package/src/icu/parser.d.ts.map +1 -0
  192. package/src/icu/parser.js +203 -0
  193. package/src/icu/parser.js.map +1 -0
  194. package/src/icu/runtime.d.ts +10 -0
  195. package/src/icu/runtime.d.ts.map +1 -0
  196. package/src/icu/runtime.js +33 -0
  197. package/src/icu/runtime.js.map +1 -0
  198. package/src/icu/tokenizer.d.ts +37 -0
  199. package/src/icu/tokenizer.d.ts.map +1 -0
  200. package/src/icu/tokenizer.js +187 -0
  201. package/src/icu/tokenizer.js.map +1 -0
  202. package/src/icu/validator.d.ts +11 -0
  203. package/src/icu/validator.d.ts.map +1 -0
  204. package/src/icu/validator.js +140 -0
  205. package/src/icu/validator.js.map +1 -0
  206. package/src/{index.ts → index.d.ts} +6 -38
  207. package/src/index.d.ts.map +1 -0
  208. package/src/index.js +76 -0
  209. package/src/index.js.map +1 -0
  210. package/src/interfaces/active-context.interface.d.ts +36 -0
  211. package/src/interfaces/active-context.interface.d.ts.map +1 -0
  212. package/src/interfaces/active-context.interface.js +3 -0
  213. package/src/interfaces/active-context.interface.js.map +1 -0
  214. package/src/interfaces/component-config.interface.d.ts +16 -0
  215. package/src/interfaces/component-config.interface.d.ts.map +1 -0
  216. package/src/interfaces/component-config.interface.js +6 -0
  217. package/src/interfaces/component-config.interface.js.map +1 -0
  218. package/src/interfaces/engine-config.interface.d.ts +22 -0
  219. package/src/interfaces/engine-config.interface.d.ts.map +1 -0
  220. package/src/interfaces/engine-config.interface.js +6 -0
  221. package/src/interfaces/engine-config.interface.js.map +1 -0
  222. package/src/interfaces/global-active-context.d.ts +23 -0
  223. package/src/interfaces/global-active-context.d.ts.map +1 -0
  224. package/src/interfaces/global-active-context.js +3 -0
  225. package/src/interfaces/global-active-context.js.map +1 -0
  226. package/src/interfaces/handleable-error-options.d.ts +14 -0
  227. package/src/interfaces/handleable-error-options.d.ts.map +1 -0
  228. package/src/interfaces/handleable-error-options.js +3 -0
  229. package/src/interfaces/handleable-error-options.js.map +1 -0
  230. package/src/interfaces/handleable.d.ts +21 -0
  231. package/src/interfaces/handleable.d.ts.map +1 -0
  232. package/src/interfaces/handleable.js +3 -0
  233. package/src/interfaces/handleable.js.map +1 -0
  234. package/src/interfaces/i18n-engine.interface.d.ts +46 -0
  235. package/src/interfaces/i18n-engine.interface.d.ts.map +1 -0
  236. package/src/interfaces/i18n-engine.interface.js +6 -0
  237. package/src/interfaces/i18n-engine.interface.js.map +1 -0
  238. package/src/interfaces/{index.ts → index.d.ts} +1 -1
  239. package/src/interfaces/index.d.ts.map +1 -0
  240. package/src/interfaces/index.js +7 -0
  241. package/src/interfaces/index.js.map +1 -0
  242. package/src/interfaces/language-definition.interface.d.ts +17 -0
  243. package/src/interfaces/language-definition.interface.d.ts.map +1 -0
  244. package/src/interfaces/language-definition.interface.js +6 -0
  245. package/src/interfaces/language-definition.interface.js.map +1 -0
  246. package/src/interfaces/translation-options.interface.d.ts +15 -0
  247. package/src/interfaces/translation-options.interface.d.ts.map +1 -0
  248. package/src/interfaces/translation-options.interface.js +6 -0
  249. package/src/interfaces/translation-options.interface.js.map +1 -0
  250. package/src/interfaces/validation-result.interface.d.ts +24 -0
  251. package/src/interfaces/validation-result.interface.d.ts.map +1 -0
  252. package/src/interfaces/validation-result.interface.js +6 -0
  253. package/src/interfaces/validation-result.interface.js.map +1 -0
  254. package/src/language-codes.d.ts +28 -0
  255. package/src/language-codes.d.ts.map +1 -0
  256. package/src/language-codes.js +32 -0
  257. package/src/language-codes.js.map +1 -0
  258. package/src/language-definition.d.ts +14 -0
  259. package/src/language-definition.d.ts.map +1 -0
  260. package/src/language-definition.js +3 -0
  261. package/src/language-definition.js.map +1 -0
  262. package/src/plugin-i18n-engine.d.ts +164 -0
  263. package/src/plugin-i18n-engine.d.ts.map +1 -0
  264. package/src/plugin-i18n-engine.js +493 -0
  265. package/src/plugin-i18n-engine.js.map +1 -0
  266. package/src/pluralization/{index.ts → index.d.ts} +1 -1
  267. package/src/pluralization/index.d.ts.map +1 -0
  268. package/src/pluralization/index.js +10 -0
  269. package/src/pluralization/index.js.map +1 -0
  270. package/src/pluralization/language-plural-map.d.ts +29 -0
  271. package/src/pluralization/language-plural-map.d.ts.map +1 -0
  272. package/src/pluralization/language-plural-map.js +155 -0
  273. package/src/pluralization/language-plural-map.js.map +1 -0
  274. package/src/pluralization/{plural-categories.ts → plural-categories.d.ts} +3 -5
  275. package/src/pluralization/plural-categories.d.ts.map +1 -0
  276. package/src/pluralization/plural-categories.js +8 -0
  277. package/src/pluralization/plural-categories.js.map +1 -0
  278. package/src/pluralization/plural-rules.d.ts +102 -0
  279. package/src/pluralization/plural-rules.d.ts.map +1 -0
  280. package/src/pluralization/plural-rules.js +263 -0
  281. package/src/pluralization/plural-rules.js.map +1 -0
  282. package/src/registry-config.d.ts +16 -0
  283. package/src/registry-config.d.ts.map +1 -0
  284. package/src/registry-config.js +3 -0
  285. package/src/registry-config.js.map +1 -0
  286. package/src/registry-error-type.d.ts +20 -0
  287. package/src/registry-error-type.d.ts.map +1 -0
  288. package/src/registry-error-type.js +24 -0
  289. package/src/registry-error-type.js.map +1 -0
  290. package/src/registry-error.d.ts +25 -0
  291. package/src/registry-error.d.ts.map +1 -0
  292. package/src/registry-error.js +63 -0
  293. package/src/registry-error.js.map +1 -0
  294. package/src/strict-types.d.ts +19 -0
  295. package/src/strict-types.d.ts.map +1 -0
  296. package/src/strict-types.js +18 -0
  297. package/src/strict-types.js.map +1 -0
  298. package/src/strings/de.d.ts +3 -0
  299. package/src/strings/de.d.ts.map +1 -0
  300. package/src/strings/de.js +57 -0
  301. package/src/strings/de.js.map +1 -0
  302. package/src/strings/en-GB.d.ts +3 -0
  303. package/src/strings/en-GB.d.ts.map +1 -0
  304. package/src/strings/en-GB.js +57 -0
  305. package/src/strings/en-GB.js.map +1 -0
  306. package/src/strings/en-US.d.ts +3 -0
  307. package/src/strings/en-US.d.ts.map +1 -0
  308. package/src/strings/en-US.js +57 -0
  309. package/src/strings/en-US.js.map +1 -0
  310. package/src/strings/es.d.ts +3 -0
  311. package/src/strings/es.d.ts.map +1 -0
  312. package/src/strings/es.js +57 -0
  313. package/src/strings/es.js.map +1 -0
  314. package/src/strings/fr.d.ts +3 -0
  315. package/src/strings/fr.d.ts.map +1 -0
  316. package/src/strings/fr.js +57 -0
  317. package/src/strings/fr.js.map +1 -0
  318. package/src/strings/ja.d.ts +3 -0
  319. package/src/strings/ja.d.ts.map +1 -0
  320. package/src/strings/ja.js +57 -0
  321. package/src/strings/ja.js.map +1 -0
  322. package/src/strings/uk.d.ts +3 -0
  323. package/src/strings/uk.d.ts.map +1 -0
  324. package/src/strings/uk.js +57 -0
  325. package/src/strings/uk.js.map +1 -0
  326. package/src/strings/zh-CN.d.ts +3 -0
  327. package/src/strings/zh-CN.d.ts.map +1 -0
  328. package/src/strings/zh-CN.js +57 -0
  329. package/src/strings/zh-CN.js.map +1 -0
  330. package/src/template.d.ts +13 -0
  331. package/src/template.d.ts.map +1 -0
  332. package/src/template.js +40 -0
  333. package/src/template.js.map +1 -0
  334. package/src/translation-engine.d.ts +9 -0
  335. package/src/translation-engine.d.ts.map +1 -0
  336. package/src/translation-engine.js +3 -0
  337. package/src/translation-engine.js.map +1 -0
  338. package/src/translation-request.d.ts +10 -0
  339. package/src/translation-request.d.ts.map +1 -0
  340. package/src/translation-request.js +3 -0
  341. package/src/translation-request.js.map +1 -0
  342. package/src/translation-response.d.ts +9 -0
  343. package/src/translation-response.d.ts.map +1 -0
  344. package/src/translation-response.js +3 -0
  345. package/src/translation-response.js.map +1 -0
  346. package/src/types/engine.d.ts +47 -0
  347. package/src/types/engine.d.ts.map +1 -0
  348. package/src/types/engine.js +8 -0
  349. package/src/types/engine.js.map +1 -0
  350. package/src/types/{index.ts → index.d.ts} +1 -1
  351. package/src/types/index.d.ts.map +1 -0
  352. package/src/types/index.js +9 -0
  353. package/src/types/index.js.map +1 -0
  354. package/src/types/{plural-types.ts → plural-types.d.ts} +3 -29
  355. package/src/types/plural-types.d.ts.map +1 -0
  356. package/src/types/plural-types.js +39 -0
  357. package/src/types/plural-types.js.map +1 -0
  358. package/src/{types.ts → types.d.ts} +21 -72
  359. package/src/types.d.ts.map +1 -0
  360. package/src/types.js +23 -0
  361. package/src/types.js.map +1 -0
  362. package/src/utils/currency.d.ts +81 -0
  363. package/src/utils/currency.d.ts.map +1 -0
  364. package/src/utils/currency.js +99 -0
  365. package/src/utils/currency.js.map +1 -0
  366. package/src/utils/html-escape.d.ts +22 -0
  367. package/src/utils/html-escape.d.ts.map +1 -0
  368. package/src/utils/html-escape.js +53 -0
  369. package/src/utils/html-escape.js.map +1 -0
  370. package/src/utils/{index.ts → index.d.ts} +1 -0
  371. package/src/utils/index.d.ts.map +1 -0
  372. package/src/utils/index.js +12 -0
  373. package/src/utils/index.js.map +1 -0
  374. package/src/utils/lru-cache.d.ts +42 -0
  375. package/src/utils/lru-cache.d.ts.map +1 -0
  376. package/src/utils/lru-cache.js +73 -0
  377. package/src/utils/lru-cache.js.map +1 -0
  378. package/src/utils/{plural-helpers.ts → plural-helpers.d.ts} +4 -14
  379. package/src/utils/plural-helpers.d.ts.map +1 -0
  380. package/src/utils/plural-helpers.js +35 -0
  381. package/src/utils/plural-helpers.js.map +1 -0
  382. package/src/utils/safe-object.d.ts +39 -0
  383. package/src/utils/safe-object.d.ts.map +1 -0
  384. package/src/utils/{safe-object.ts → safe-object.js} +34 -37
  385. package/src/utils/safe-object.js.map +1 -0
  386. package/src/utils/string-utils.d.ts +28 -0
  387. package/src/utils/string-utils.d.ts.map +1 -0
  388. package/src/utils/string-utils.js +63 -0
  389. package/src/utils/string-utils.js.map +1 -0
  390. package/src/utils/timezone.d.ts +50 -0
  391. package/src/utils/timezone.d.ts.map +1 -0
  392. package/src/utils/timezone.js +74 -0
  393. package/src/utils/timezone.js.map +1 -0
  394. package/src/utils/validation.d.ts +40 -0
  395. package/src/utils/validation.d.ts.map +1 -0
  396. package/src/utils/validation.js +69 -0
  397. package/src/utils/validation.js.map +1 -0
  398. package/src/utils.d.ts +65 -0
  399. package/src/utils.d.ts.map +1 -0
  400. package/src/utils.js +129 -0
  401. package/src/utils.js.map +1 -0
  402. package/src/validation/{index.ts → index.d.ts} +1 -0
  403. package/src/validation/index.d.ts.map +1 -0
  404. package/src/validation/index.js +5 -0
  405. package/src/validation/index.js.map +1 -0
  406. package/src/validation/plural-validator.d.ts +46 -0
  407. package/src/validation/plural-validator.d.ts.map +1 -0
  408. package/src/validation/plural-validator.js +123 -0
  409. package/src/validation/plural-validator.js.map +1 -0
  410. package/src/validation-config.d.ts +12 -0
  411. package/src/validation-config.d.ts.map +1 -0
  412. package/src/validation-config.js +3 -0
  413. package/src/validation-config.js.map +1 -0
  414. package/src/validation-result.d.ts +13 -0
  415. package/src/validation-result.d.ts.map +1 -0
  416. package/src/validation-result.js +3 -0
  417. package/src/validation-result.js.map +1 -0
  418. package/LICENSE +0 -21
  419. package/src/builders/i18n-builder.ts +0 -82
  420. package/src/component-definition.ts +0 -11
  421. package/src/component-registration.ts +0 -29
  422. package/src/component-registry.ts +0 -432
  423. package/src/context-error-type.ts +0 -7
  424. package/src/core/component-store.ts +0 -241
  425. package/src/core/context-manager.ts +0 -113
  426. package/src/core/enum-registry.ts +0 -106
  427. package/src/core/i18n-engine.ts +0 -710
  428. package/src/core/language-registry.ts +0 -345
  429. package/src/core-i18n.ts +0 -270
  430. package/src/core-plugin-factory.ts +0 -111
  431. package/src/core-string-key.ts +0 -59
  432. package/src/create-translation-adapter.ts +0 -93
  433. package/src/enum-registry.ts +0 -152
  434. package/src/errors/context-error.ts +0 -122
  435. package/src/errors/enhanced-error-base.ts +0 -260
  436. package/src/errors/handleable.ts +0 -152
  437. package/src/errors/i18n-error.ts +0 -494
  438. package/src/errors/simple-typed-error.ts +0 -81
  439. package/src/errors/translatable-generic.ts +0 -245
  440. package/src/errors/translatable-handleable-generic.ts +0 -222
  441. package/src/errors/translatable.ts +0 -138
  442. package/src/errors/typed-handleable.ts +0 -138
  443. package/src/errors/typed.ts +0 -617
  444. package/src/gender/gender-resolver.ts +0 -40
  445. package/src/global-active-context.ts +0 -266
  446. package/src/icu/ast.ts +0 -56
  447. package/src/icu/compiler.ts +0 -96
  448. package/src/icu/formatter-registry.ts +0 -36
  449. package/src/icu/formatters/base-formatter.ts +0 -8
  450. package/src/icu/formatters/date-formatter.ts +0 -30
  451. package/src/icu/formatters/number-formatter.ts +0 -32
  452. package/src/icu/formatters/plural-formatter.ts +0 -12
  453. package/src/icu/formatters/select-formatter.ts +0 -7
  454. package/src/icu/formatters/selectordinal-formatter.ts +0 -17
  455. package/src/icu/formatters/time-formatter.ts +0 -30
  456. package/src/icu/helpers.ts +0 -34
  457. package/src/icu/parser.ts +0 -242
  458. package/src/icu/runtime.ts +0 -37
  459. package/src/icu/tokenizer.ts +0 -212
  460. package/src/icu/validator.ts +0 -163
  461. package/src/interfaces/active-context.interface.ts +0 -41
  462. package/src/interfaces/component-config.interface.ts +0 -17
  463. package/src/interfaces/engine-config.interface.ts +0 -22
  464. package/src/interfaces/global-active-context.ts +0 -39
  465. package/src/interfaces/handleable-error-options.ts +0 -13
  466. package/src/interfaces/handleable.ts +0 -20
  467. package/src/interfaces/i18n-engine.interface.ts +0 -57
  468. package/src/interfaces/language-definition.interface.ts +0 -17
  469. package/src/interfaces/translation-options.interface.ts +0 -15
  470. package/src/interfaces/validation-result.interface.ts +0 -24
  471. package/src/language-codes.ts +0 -40
  472. package/src/language-definition.ts +0 -13
  473. package/src/plugin-i18n-engine.ts +0 -707
  474. package/src/pluralization/language-plural-map.ts +0 -186
  475. package/src/pluralization/plural-rules.ts +0 -228
  476. package/src/registry-config.ts +0 -16
  477. package/src/registry-error-type.ts +0 -19
  478. package/src/registry-error.ts +0 -100
  479. package/src/strict-types.ts +0 -35
  480. package/src/strings/de.ts +0 -75
  481. package/src/strings/en-GB.ts +0 -74
  482. package/src/strings/en-US.ts +0 -74
  483. package/src/strings/es.ts +0 -74
  484. package/src/strings/fr.ts +0 -75
  485. package/src/strings/ja.ts +0 -73
  486. package/src/strings/uk.ts +0 -73
  487. package/src/strings/zh-CN.ts +0 -72
  488. package/src/template.ts +0 -72
  489. package/src/translation-engine.ts +0 -18
  490. package/src/translation-request.ts +0 -12
  491. package/src/translation-response.ts +0 -8
  492. package/src/types/engine.ts +0 -55
  493. package/src/utils/currency.ts +0 -141
  494. package/src/utils/html-escape.ts +0 -55
  495. package/src/utils/lru-cache.ts +0 -76
  496. package/src/utils/string-utils.ts +0 -77
  497. package/src/utils/timezone.ts +0 -76
  498. package/src/utils/validation.ts +0 -66
  499. package/src/utils.ts +0 -215
  500. package/src/validation/plural-validator.ts +0 -168
  501. package/src/validation-config.ts +0 -11
  502. package/src/validation-result.ts +0 -12
@@ -1,36 +1,26 @@
1
1
  /**
2
2
  * Helper functions for creating plural and gender strings
3
3
  */
4
-
5
4
  import { PluralCategory } from '../pluralization/plural-categories';
6
5
  import { PluralString } from '../types/plural-types';
7
6
  import { GenderCategory, GenderedString } from '../gender/gender-categories';
8
- import { getRequiredPluralForms as getRequiredFormsFromMap } from '../pluralization/language-plural-map';
9
-
10
7
  /**
11
8
  * Creates a PluralString from a partial record of plural forms.
12
9
  * @param forms - Object mapping plural categories to their string forms
13
10
  * @returns A PluralString that can be used in translations
14
11
  */
15
- export function createPluralString(forms: Partial<Record<PluralCategory, string>>): PluralString {
16
- return forms;
17
- }
18
-
12
+ export declare function createPluralString(forms: Partial<Record<PluralCategory, string>>): PluralString;
19
13
  /**
20
14
  * Creates a GenderedString from a partial record of gender forms.
21
15
  * @param forms - Object mapping gender categories to their string forms
22
16
  * @returns A GenderedString that can be used in translations
23
17
  */
24
- export function createGenderedString(forms: Partial<Record<GenderCategory, string>>): GenderedString {
25
- return forms;
26
- }
27
-
18
+ export declare function createGenderedString(forms: Partial<Record<GenderCategory, string>>): GenderedString;
28
19
  /**
29
20
  * Gets the required plural forms for a given language.
30
21
  * Different languages have different plural rules and require different forms.
31
22
  * @param language - The language code
32
23
  * @returns Array of plural categories required for the language
33
24
  */
34
- export function getRequiredPluralForms(language: string): PluralCategory[] {
35
- return getRequiredFormsFromMap(language) as PluralCategory[];
36
- }
25
+ export declare function getRequiredPluralForms(language: string): PluralCategory[];
26
+ //# sourceMappingURL=plural-helpers.d.ts.map
@@ -0,0 +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;;;;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"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * Helper functions for creating plural and gender strings
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createPluralString = createPluralString;
7
+ exports.createGenderedString = createGenderedString;
8
+ exports.getRequiredPluralForms = getRequiredPluralForms;
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
+ */
15
+ function createPluralString(forms) {
16
+ return forms;
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
+ */
23
+ function createGenderedString(forms) {
24
+ return forms;
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
+ */
32
+ function getRequiredPluralForms(language) {
33
+ return (0, language_plural_map_1.getRequiredPluralForms)(language);
34
+ }
35
+ //# sourceMappingURL=plural-helpers.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Safe object utilities to prevent prototype pollution
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
+ */
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
+ */
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
+ */
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
+ */
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
+ */
38
+ export declare function validateObjectKeys(obj: Record<string, any>): void;
39
+ //# sourceMappingURL=safe-object.d.ts.map
@@ -0,0 +1 @@
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,CAYH;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GACrB,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAEpB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAUjE"}
@@ -1,31 +1,34 @@
1
+ "use strict";
1
2
  /**
2
3
  * Safe object utilities to prevent prototype pollution
3
4
  */
4
-
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createSafeObject = createSafeObject;
7
+ exports.isDangerousKey = isDangerousKey;
8
+ exports.safeAssign = safeAssign;
9
+ exports.safeObjectEntries = safeObjectEntries;
10
+ exports.validateObjectKeys = validateObjectKeys;
5
11
  /**
6
12
  * List of dangerous keys that should never be set on objects to prevent prototype pollution.
7
13
  */
8
14
  const DANGEROUS_KEYS = ['__proto__', 'constructor', 'prototype'];
9
-
10
15
  /**
11
16
  * Creates a safe object without a prototype chain.
12
17
  * This prevents prototype pollution attacks.
13
18
  * @template T - The type of values in the object
14
19
  * @returns A new object without a prototype
15
20
  */
16
- export function createSafeObject<T = any>(): Record<string, T> {
17
- return Object.create(null);
21
+ function createSafeObject() {
22
+ return Object.create(null);
18
23
  }
19
-
20
24
  /**
21
25
  * Checks if a key is in the list of dangerous keys that could enable prototype pollution.
22
26
  * @param key - The key to check
23
27
  * @returns True if the key is dangerous, false otherwise
24
28
  */
25
- export function isDangerousKey(key: string): boolean {
26
- return DANGEROUS_KEYS.includes(key);
29
+ function isDangerousKey(key) {
30
+ return DANGEROUS_KEYS.includes(key);
27
31
  }
28
-
29
32
  /**
30
33
  * Safely assigns properties from source objects to a target object.
31
34
  * Filters out dangerous keys to prevent prototype pollution.
@@ -34,48 +37,42 @@ export function isDangerousKey(key: string): boolean {
34
37
  * @param sources - One or more source objects to copy properties from
35
38
  * @returns The target object with properties assigned
36
39
  */
37
- export function safeAssign<T extends Record<string, any>>(
38
- target: T,
39
- ...sources: Array<Record<string, any> | undefined>
40
- ): T {
41
- for (const source of sources) {
42
- if (!source) continue;
43
-
44
- for (const key of Object.keys(source)) {
45
- if (!isDangerousKey(key)) {
46
- // Type-safe property assignment using index signature
47
- (target as Record<string, any>)[key] = source[key];
48
- }
40
+ function safeAssign(target, ...sources) {
41
+ for (const source of sources) {
42
+ if (!source)
43
+ continue;
44
+ for (const key of Object.keys(source)) {
45
+ if (!isDangerousKey(key)) {
46
+ // Type-safe property assignment using index signature
47
+ target[key] = source[key];
48
+ }
49
+ }
49
50
  }
50
- }
51
- return target;
51
+ return target;
52
52
  }
53
-
54
53
  /**
55
54
  * Gets key-value pairs from an object, filtering out dangerous keys.
56
55
  * @template T - The type of values in the object
57
56
  * @param obj - The object to get entries from
58
57
  * @returns Array of [key, value] pairs, excluding dangerous keys
59
58
  */
60
- export function safeObjectEntries<T>(
61
- obj: Record<string, T>,
62
- ): Array<[string, T]> {
63
- return Object.entries(obj).filter(([key]) => !isDangerousKey(key));
59
+ function safeObjectEntries(obj) {
60
+ return Object.entries(obj).filter(([key]) => !isDangerousKey(key));
64
61
  }
65
-
66
62
  /**
67
63
  * Validates that an object does not contain dangerous keys.
68
64
  * @param obj - The object to validate
69
65
  * @throws {Error} If a dangerous key is detected
70
66
  */
71
- export function validateObjectKeys(obj: Record<string, any>): void {
72
- if (!obj || typeof obj !== 'object') return;
73
-
74
- // Check for dangerous keys in Object.keys and getOwnPropertyNames
75
- const allKeys = [...Object.keys(obj), ...Object.getOwnPropertyNames(obj)];
76
- for (const key of allKeys) {
77
- if (DANGEROUS_KEYS.includes(key)) {
78
- throw new Error(`Dangerous key detected: ${key}`);
67
+ function validateObjectKeys(obj) {
68
+ if (!obj || typeof obj !== 'object')
69
+ return;
70
+ // Check for dangerous keys in Object.keys and getOwnPropertyNames
71
+ const allKeys = [...Object.keys(obj), ...Object.getOwnPropertyNames(obj)];
72
+ for (const key of allKeys) {
73
+ if (DANGEROUS_KEYS.includes(key)) {
74
+ throw new Error(`Dangerous key detected: ${key}`);
75
+ }
79
76
  }
80
- }
81
77
  }
78
+ //# sourceMappingURL=safe-object.js.map
@@ -0,0 +1 @@
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,gCAeC;AAQD,8CAIC;AAOD,gDAUC;AA5ED;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AAEjE;;;;;GAKG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;;GAOG;AACH,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;gBACzB,sDAAsD;gBACrD,MAA8B,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,GAAsB;IAEtB,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;;;;GAIG;AACH,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"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * String utility functions
3
+ */
4
+ /**
5
+ * Options for the replaceVariables function.
6
+ */
7
+ export interface ReplaceVariablesOptions {
8
+ /** If true, HTML-escapes the replaced values */
9
+ escapeHtml?: boolean;
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
+ */
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
+ */
27
+ export declare function isTemplate(key: string): boolean;
28
+ //# sourceMappingURL=string-utils.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /**
3
+ * String utility functions
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.replaceVariables = replaceVariables;
7
+ exports.isTemplate = isTemplate;
8
+ const html_escape_1 = require("./html-escape");
9
+ /**
10
+ * Extract the actual value from an object that might be a wrapper (CurrencyCode, Timezone, etc.).
11
+ * @param value - The value to extract from
12
+ * @returns The extracted value or the original value if not a wrapper
13
+ */
14
+ function extractValue(value) {
15
+ // Handle objects with a 'value' property (CurrencyCode, Timezone, etc.)
16
+ if (value && typeof value === 'object' && 'value' in value && typeof value.value !== 'function') {
17
+ return value.value;
18
+ }
19
+ return value;
20
+ }
21
+ /**
22
+ * Replaces variables in a string template with values from vars or constants.
23
+ * Variables are denoted by {variableName} in the template string.
24
+ * @param str - The template string containing variables
25
+ * @param vars - Optional object mapping variable names to values
26
+ * @param constants - Optional object containing constant values
27
+ * @param options - Optional configuration including HTML escaping
28
+ * @returns The string with variables replaced
29
+ */
30
+ function replaceVariables(str, vars, constants, options) {
31
+ if (typeof str !== 'string') {
32
+ str = String(str);
33
+ }
34
+ const variables = str.match(/\{(.+?)\}/g);
35
+ if (!variables)
36
+ return str;
37
+ let result = str;
38
+ for (const variable of variables) {
39
+ const varName = variable.slice(1, -1);
40
+ let replacement = '';
41
+ if (vars && varName in vars) {
42
+ const value = extractValue(vars[varName]);
43
+ replacement = (0, html_escape_1.safeStringify)(value, options);
44
+ result = result.replace(variable, replacement);
45
+ }
46
+ else if (constants && varName in constants) {
47
+ const value = extractValue(constants[varName]);
48
+ replacement = (0, html_escape_1.safeStringify)(value, options);
49
+ result = result.replace(variable, replacement);
50
+ }
51
+ }
52
+ return result;
53
+ }
54
+ /**
55
+ * Checks if a string key indicates a template that expects variable replacement.
56
+ * Template keys end with 'template' (case-insensitive).
57
+ * @param key - The key to check
58
+ * @returns True if the key indicates a template, false otherwise
59
+ */
60
+ function isTemplate(key) {
61
+ return key.trim().toLowerCase().endsWith('template');
62
+ }
63
+ //# sourceMappingURL=string-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-utils.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/string-utils.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAkCH,4CA8BC;AAQD,gCAEC;AAxED,+CAA0D;AAE1D;;;;GAIG;AACH,SAAS,YAAY,CAAC,KAAU;IAC9B,wEAAwE;IACxE,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QAChG,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAUD;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAC9B,GAAW,EACX,IAA0B,EAC1B,SAA+B,EAC/B,OAAiC;IAEjC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC1C,IAAI,CAAC,SAAS;QAAE,OAAO,GAAG,CAAC;IAE3B,IAAI,MAAM,GAAG,GAAG,CAAC;IACjB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACtC,IAAI,WAAW,GAAG,EAAE,CAAC;QAErB,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1C,WAAW,GAAG,IAAA,2BAAa,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC5C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACjD,CAAC;aAAM,IAAI,SAAS,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;YAC7C,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;YAC/C,WAAW,GAAG,IAAA,2BAAa,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC5C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Timezone utilities (v2)
3
+ */
4
+ /**
5
+ * Represents a valid timezone with validation.
6
+ * Uses moment-timezone for validation and timezone database.
7
+ */
8
+ export declare class Timezone {
9
+ private readonly _value;
10
+ /**
11
+ * Creates a new Timezone instance.
12
+ * @param timezone - The timezone name (e.g., 'America/New_York', 'UTC')
13
+ * @throws {Error} If the timezone is invalid
14
+ */
15
+ constructor(timezone: string);
16
+ /**
17
+ * Gets the timezone name.
18
+ * @returns The timezone name
19
+ */
20
+ get value(): string;
21
+ /**
22
+ * Gets the timezone name (alias for value).
23
+ * @returns The timezone name
24
+ */
25
+ get name(): string;
26
+ /**
27
+ * Checks if a timezone name is valid.
28
+ * @param timezone - The timezone name to validate
29
+ * @returns True if the timezone is valid, false otherwise
30
+ */
31
+ static isValid(timezone: string): boolean;
32
+ /**
33
+ * Gets all available timezone names.
34
+ * @returns Array of timezone names
35
+ */
36
+ static getAll(): string[];
37
+ /**
38
+ * Attempts to guess the user's timezone based on their system settings.
39
+ * @returns The guessed timezone name
40
+ */
41
+ static guess(): string;
42
+ }
43
+ /**
44
+ * Checks if a timezone name is valid.
45
+ * This is a convenience function that delegates to Timezone.isValid().
46
+ * @param timezone - The timezone name to validate
47
+ * @returns True if the timezone is valid, false otherwise
48
+ */
49
+ export declare function isValidTimezone(timezone: string): boolean;
50
+ //# sourceMappingURL=timezone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/timezone.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;GAGG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;OAIG;gBACS,QAAQ,EAAE,MAAM;IAO5B;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIzC;;;OAGG;IACH,MAAM,CAAC,MAAM,IAAI,MAAM,EAAE;IAIzB;;;OAGG;IACH,MAAM,CAAC,KAAK,IAAI,MAAM;CAGvB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /**
3
+ * Timezone utilities (v2)
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Timezone = void 0;
7
+ exports.isValidTimezone = isValidTimezone;
8
+ const tslib_1 = require("tslib");
9
+ const moment_timezone_1 = tslib_1.__importDefault(require("moment-timezone"));
10
+ /**
11
+ * Represents a valid timezone with validation.
12
+ * Uses moment-timezone for validation and timezone database.
13
+ */
14
+ class Timezone {
15
+ _value;
16
+ /**
17
+ * Creates a new Timezone instance.
18
+ * @param timezone - The timezone name (e.g., 'America/New_York', 'UTC')
19
+ * @throws {Error} If the timezone is invalid
20
+ */
21
+ constructor(timezone) {
22
+ if (!Timezone.isValid(timezone)) {
23
+ throw new Error(`Invalid timezone: ${timezone}`);
24
+ }
25
+ this._value = timezone;
26
+ }
27
+ /**
28
+ * Gets the timezone name.
29
+ * @returns The timezone name
30
+ */
31
+ get value() {
32
+ return this._value;
33
+ }
34
+ /**
35
+ * Gets the timezone name (alias for value).
36
+ * @returns The timezone name
37
+ */
38
+ get name() {
39
+ return this._value;
40
+ }
41
+ /**
42
+ * Checks if a timezone name is valid.
43
+ * @param timezone - The timezone name to validate
44
+ * @returns True if the timezone is valid, false otherwise
45
+ */
46
+ static isValid(timezone) {
47
+ return moment_timezone_1.default.tz.zone(timezone) !== null;
48
+ }
49
+ /**
50
+ * Gets all available timezone names.
51
+ * @returns Array of timezone names
52
+ */
53
+ static getAll() {
54
+ return moment_timezone_1.default.tz.names();
55
+ }
56
+ /**
57
+ * Attempts to guess the user's timezone based on their system settings.
58
+ * @returns The guessed timezone name
59
+ */
60
+ static guess() {
61
+ return moment_timezone_1.default.tz.guess();
62
+ }
63
+ }
64
+ exports.Timezone = Timezone;
65
+ /**
66
+ * Checks if a timezone name is valid.
67
+ * This is a convenience function that delegates to Timezone.isValid().
68
+ * @param timezone - The timezone name to validate
69
+ * @returns True if the timezone is valid, false otherwise
70
+ */
71
+ function isValidTimezone(timezone) {
72
+ return Timezone.isValid(timezone);
73
+ }
74
+ //# sourceMappingURL=timezone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timezone.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/timezone.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAuEH,0CAEC;;AAvED,8EAAqC;AAErC;;;GAGG;AACH,MAAa,QAAQ;IACF,MAAM,CAAS;IAEhC;;;;OAIG;IACH,YAAY,QAAgB;QAC1B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,QAAgB;QAC7B,OAAO,yBAAM,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM;QACX,OAAO,yBAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK;QACV,OAAO,yBAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF;AAvDD,4BAuDC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,QAAgB;IAC9C,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Input validation utilities
3
+ */
4
+ /**
5
+ * Security limits for various input types to prevent abuse.
6
+ */
7
+ export declare const LIMITS: {
8
+ readonly MAX_TEMPLATE_LENGTH: 10000;
9
+ readonly MAX_KEY_LENGTH: 200;
10
+ readonly MAX_COMPONENT_ID_LENGTH: 100;
11
+ readonly MAX_LANGUAGE_CODE_LENGTH: 10;
12
+ readonly MAX_NESTING_DEPTH: 10;
13
+ };
14
+ /**
15
+ * Validates that a template string does not exceed the maximum allowed length.
16
+ * @param template - The template string to validate
17
+ * @throws {Error} If the template exceeds the maximum length
18
+ */
19
+ export declare function validateTemplateLength(template: string): void;
20
+ /**
21
+ * Validates that a key does not exceed the maximum allowed length.
22
+ * @param key - The key to validate
23
+ * @throws {Error} If the key exceeds the maximum length
24
+ */
25
+ export declare function validateKeyLength(key: string): void;
26
+ /**
27
+ * Validates that a component ID meets length and character requirements.
28
+ * Component IDs must contain only alphanumeric characters, underscores, and hyphens.
29
+ * @param componentId - The component ID to validate
30
+ * @throws {Error} If the component ID is invalid
31
+ */
32
+ export declare function validateComponentId(componentId: string): void;
33
+ /**
34
+ * Validates that a language code meets BCP 47 format requirements.
35
+ * Expected format: two lowercase letters, optionally followed by a hyphen and two uppercase letters (e.g., 'en', 'en-US').
36
+ * @param language - The language code to validate
37
+ * @throws {Error} If the language code is invalid
38
+ */
39
+ export declare function validateLanguageCode(language: string): void;
40
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;CAMT,CAAC;AAEX;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAI7D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAInD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAO7D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAO3D"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ /**
3
+ * Input validation utilities
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LIMITS = void 0;
7
+ exports.validateTemplateLength = validateTemplateLength;
8
+ exports.validateKeyLength = validateKeyLength;
9
+ exports.validateComponentId = validateComponentId;
10
+ exports.validateLanguageCode = validateLanguageCode;
11
+ /**
12
+ * Security limits for various input types to prevent abuse.
13
+ */
14
+ exports.LIMITS = {
15
+ MAX_TEMPLATE_LENGTH: 10000,
16
+ MAX_KEY_LENGTH: 200,
17
+ MAX_COMPONENT_ID_LENGTH: 100,
18
+ MAX_LANGUAGE_CODE_LENGTH: 10,
19
+ MAX_NESTING_DEPTH: 10,
20
+ };
21
+ /**
22
+ * Validates that a template string does not exceed the maximum allowed length.
23
+ * @param template - The template string to validate
24
+ * @throws {Error} If the template exceeds the maximum length
25
+ */
26
+ function validateTemplateLength(template) {
27
+ if (template.length > exports.LIMITS.MAX_TEMPLATE_LENGTH) {
28
+ throw new Error(`Template exceeds maximum length of ${exports.LIMITS.MAX_TEMPLATE_LENGTH}`);
29
+ }
30
+ }
31
+ /**
32
+ * Validates that a key does not exceed the maximum allowed length.
33
+ * @param key - The key to validate
34
+ * @throws {Error} If the key exceeds the maximum length
35
+ */
36
+ function validateKeyLength(key) {
37
+ if (key.length > exports.LIMITS.MAX_KEY_LENGTH) {
38
+ throw new Error(`Key exceeds maximum length of ${exports.LIMITS.MAX_KEY_LENGTH}`);
39
+ }
40
+ }
41
+ /**
42
+ * Validates that a component ID meets length and character requirements.
43
+ * Component IDs must contain only alphanumeric characters, underscores, and hyphens.
44
+ * @param componentId - The component ID to validate
45
+ * @throws {Error} If the component ID is invalid
46
+ */
47
+ function validateComponentId(componentId) {
48
+ if (componentId.length > exports.LIMITS.MAX_COMPONENT_ID_LENGTH) {
49
+ throw new Error(`Component ID exceeds maximum length of ${exports.LIMITS.MAX_COMPONENT_ID_LENGTH}`);
50
+ }
51
+ if (!/^[a-zA-Z0-9_-]+$/.test(componentId)) {
52
+ throw new Error('Component ID contains invalid characters');
53
+ }
54
+ }
55
+ /**
56
+ * Validates that a language code meets BCP 47 format requirements.
57
+ * Expected format: two lowercase letters, optionally followed by a hyphen and two uppercase letters (e.g., 'en', 'en-US').
58
+ * @param language - The language code to validate
59
+ * @throws {Error} If the language code is invalid
60
+ */
61
+ function validateLanguageCode(language) {
62
+ if (language.length > exports.LIMITS.MAX_LANGUAGE_CODE_LENGTH) {
63
+ throw new Error(`Language code exceeds maximum length of ${exports.LIMITS.MAX_LANGUAGE_CODE_LENGTH}`);
64
+ }
65
+ if (!/^[a-z]{2}(-[A-Z]{2})?$/.test(language)) {
66
+ throw new Error('Invalid language code format');
67
+ }
68
+ }
69
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/validation.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAkBH,wDAIC;AAOD,8CAIC;AAQD,kDAOC;AAQD,oDAOC;AA7DD;;GAEG;AACU,QAAA,MAAM,GAAG;IACpB,mBAAmB,EAAE,KAAK;IAC1B,cAAc,EAAE,GAAG;IACnB,uBAAuB,EAAE,GAAG;IAC5B,wBAAwB,EAAE,EAAE;IAC5B,iBAAiB,EAAE,EAAE;CACb,CAAC;AAEX;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,IAAI,QAAQ,CAAC,MAAM,GAAG,cAAM,CAAC,mBAAmB,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,sCAAsC,cAAM,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACtF,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,IAAI,GAAG,CAAC,MAAM,GAAG,cAAM,CAAC,cAAc,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,iCAAiC,cAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,WAAmB;IACrD,IAAI,WAAW,CAAC,MAAM,GAAG,cAAM,CAAC,uBAAuB,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CAAC,0CAA0C,cAAM,CAAC,uBAAuB,EAAE,CAAC,CAAC;IAC9F,CAAC;IACD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,QAAgB;IACnD,IAAI,QAAQ,CAAC,MAAM,GAAG,cAAM,CAAC,wBAAwB,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,2CAA2C,cAAM,CAAC,wBAAwB,EAAE,CAAC,CAAC;IAChG,CAAC;IACD,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}