@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.
- package/LICENSE +21 -0
- package/README.md +261 -0
- package/package.json +12 -4
- package/src/active-context.ts +4 -0
- package/src/builders/i18n-builder.ts +82 -0
- package/src/builders/{index.d.ts → index.ts} +1 -1
- package/src/component-definition.ts +11 -0
- package/src/component-registration.ts +29 -0
- package/src/component-registry.ts +432 -0
- package/src/context-error-type.ts +7 -0
- package/src/core/component-store.ts +241 -0
- package/src/core/context-manager.ts +113 -0
- package/src/core/enum-registry.ts +106 -0
- package/src/core/i18n-engine.ts +710 -0
- package/src/core/index.ts +16 -0
- package/src/core/language-registry.ts +345 -0
- package/src/core-component-id.ts +5 -0
- package/src/core-i18n.ts +270 -0
- package/src/core-plugin-factory.ts +111 -0
- package/src/core-string-key.ts +59 -0
- package/src/create-translation-adapter.ts +93 -0
- package/src/enum-registry.ts +152 -0
- package/src/errors/base.ts +8 -0
- package/src/errors/context-error.ts +122 -0
- package/src/errors/enhanced-error-base.ts +260 -0
- package/src/errors/handleable.ts +152 -0
- package/src/errors/i18n-error.ts +494 -0
- package/src/errors/index.ts +15 -0
- package/src/errors/simple-typed-error.ts +81 -0
- package/src/errors/{index.d.ts → translatable-exports.ts} +3 -5
- package/src/errors/translatable-generic.ts +245 -0
- package/src/errors/translatable-handleable-generic.ts +222 -0
- package/src/errors/translatable.ts +138 -0
- package/src/errors/typed-handleable.ts +138 -0
- package/src/errors/typed.ts +617 -0
- package/src/gender/{gender-categories.d.ts → gender-categories.ts} +6 -2
- package/src/gender/gender-resolver.ts +40 -0
- package/src/gender/{index.d.ts → index.ts} +0 -1
- package/src/global-active-context.ts +266 -0
- package/src/icu/ast.ts +56 -0
- package/src/icu/compiler.ts +96 -0
- package/src/icu/formatter-registry.ts +36 -0
- package/src/icu/formatters/base-formatter.ts +8 -0
- package/src/icu/formatters/date-formatter.ts +30 -0
- package/src/icu/formatters/number-formatter.ts +32 -0
- package/src/icu/formatters/plural-formatter.ts +12 -0
- package/src/icu/formatters/select-formatter.ts +7 -0
- package/src/icu/formatters/selectordinal-formatter.ts +17 -0
- package/src/icu/formatters/time-formatter.ts +30 -0
- package/src/icu/helpers.ts +34 -0
- package/src/icu/parser.ts +242 -0
- package/src/icu/runtime.ts +37 -0
- package/src/icu/tokenizer.ts +212 -0
- package/src/icu/validator.ts +163 -0
- package/src/{index.d.ts → index.ts} +46 -14
- package/src/interfaces/active-context.interface.ts +41 -0
- package/src/interfaces/component-config.interface.ts +17 -0
- package/src/interfaces/engine-config.interface.ts +22 -0
- package/src/interfaces/global-active-context.ts +39 -0
- package/src/interfaces/handleable-error-options.ts +13 -0
- package/src/interfaces/handleable.ts +20 -0
- package/src/interfaces/i18n-engine.interface.ts +57 -0
- package/src/interfaces/index.ts +13 -0
- package/src/interfaces/language-definition.interface.ts +17 -0
- package/src/interfaces/translation-options.interface.ts +15 -0
- package/src/interfaces/validation-result.interface.ts +24 -0
- package/src/language-codes.ts +40 -0
- package/src/language-definition.ts +13 -0
- package/src/plugin-i18n-engine.ts +707 -0
- package/src/pluralization/{index.d.ts → index.ts} +1 -1
- package/src/pluralization/language-plural-map.ts +186 -0
- package/src/pluralization/{plural-categories.d.ts → plural-categories.ts} +5 -3
- package/src/pluralization/plural-rules.ts +228 -0
- package/src/registry-config.ts +16 -0
- package/src/registry-error-type.ts +19 -0
- package/src/registry-error.ts +100 -0
- package/src/strict-types.ts +35 -0
- package/src/strings/de.ts +75 -0
- package/src/strings/en-GB.ts +74 -0
- package/src/strings/en-US.ts +74 -0
- package/src/strings/es.ts +74 -0
- package/src/strings/fr.ts +75 -0
- package/src/strings/ja.ts +73 -0
- package/src/strings/uk.ts +73 -0
- package/src/strings/zh-CN.ts +72 -0
- package/src/template.ts +72 -0
- package/src/translation-engine.ts +18 -0
- package/src/translation-request.ts +12 -0
- package/src/translation-response.ts +8 -0
- package/src/types/engine.ts +55 -0
- package/src/types/{index.d.ts → index.ts} +1 -1
- package/src/types/{plural-types.d.ts → plural-types.ts} +29 -3
- package/src/types.ts +142 -0
- package/src/utils/currency.ts +141 -0
- package/src/utils/html-escape.ts +55 -0
- package/src/utils/{index.d.ts → index.ts} +0 -1
- package/src/utils/lru-cache.ts +76 -0
- package/src/utils/{plural-helpers.d.ts → plural-helpers.ts} +14 -4
- package/src/utils/{safe-object.js → safe-object.ts} +37 -34
- package/src/utils/string-utils.ts +77 -0
- package/src/utils/timezone.ts +76 -0
- package/src/utils/validation.ts +66 -0
- package/src/utils.ts +215 -0
- package/src/validation/{index.d.ts → index.ts} +0 -1
- package/src/validation/plural-validator.ts +168 -0
- package/src/validation-config.ts +11 -0
- package/src/validation-result.ts +12 -0
- package/src/active-context.d.ts +0 -36
- package/src/active-context.d.ts.map +0 -1
- package/src/active-context.js +0 -3
- package/src/active-context.js.map +0 -1
- package/src/builders/i18n-builder.d.ts +0 -26
- package/src/builders/i18n-builder.d.ts.map +0 -1
- package/src/builders/i18n-builder.js +0 -70
- package/src/builders/i18n-builder.js.map +0 -1
- package/src/builders/index.d.ts.map +0 -1
- package/src/builders/index.js +0 -8
- package/src/builders/index.js.map +0 -1
- package/src/component-definition.d.ts +0 -12
- package/src/component-definition.d.ts.map +0 -1
- package/src/component-definition.js +0 -3
- package/src/component-definition.js.map +0 -1
- package/src/component-registration.d.ts +0 -13
- package/src/component-registration.d.ts.map +0 -1
- package/src/component-registration.js +0 -3
- package/src/component-registration.js.map +0 -1
- package/src/component-registry.d.ts +0 -102
- package/src/component-registry.d.ts.map +0 -1
- package/src/component-registry.js +0 -282
- package/src/component-registry.js.map +0 -1
- package/src/context-error-type.d.ts +0 -8
- package/src/context-error-type.d.ts.map +0 -1
- package/src/context-error-type.js +0 -12
- package/src/context-error-type.js.map +0 -1
- package/src/core/component-store.d.ts +0 -93
- package/src/core/component-store.d.ts.map +0 -1
- package/src/core/component-store.js +0 -198
- package/src/core/component-store.js.map +0 -1
- package/src/core/context-manager.d.ts +0 -72
- package/src/core/context-manager.d.ts.map +0 -1
- package/src/core/context-manager.js +0 -98
- package/src/core/context-manager.js.map +0 -1
- package/src/core/enum-registry.d.ts +0 -48
- package/src/core/enum-registry.d.ts.map +0 -1
- package/src/core/enum-registry.js +0 -85
- package/src/core/enum-registry.js.map +0 -1
- package/src/core/i18n-engine.d.ts +0 -241
- package/src/core/i18n-engine.d.ts.map +0 -1
- package/src/core/i18n-engine.js +0 -568
- package/src/core/i18n-engine.js.map +0 -1
- package/src/core/index.d.ts +0 -9
- package/src/core/index.d.ts.map +0 -1
- package/src/core/index.js +0 -12
- package/src/core/index.js.map +0 -1
- package/src/core/language-registry.d.ts +0 -180
- package/src/core/language-registry.d.ts.map +0 -1
- package/src/core/language-registry.js +0 -295
- package/src/core/language-registry.js.map +0 -1
- package/src/core-i18n.d.ts +0 -91
- package/src/core-i18n.d.ts.map +0 -1
- package/src/core-i18n.js +0 -287
- package/src/core-i18n.js.map +0 -1
- package/src/core-string-key.d.ts +0 -52
- package/src/core-string-key.d.ts.map +0 -1
- package/src/core-string-key.js +0 -61
- package/src/core-string-key.js.map +0 -1
- package/src/create-translation-adapter.d.ts +0 -33
- package/src/create-translation-adapter.d.ts.map +0 -1
- package/src/create-translation-adapter.js +0 -72
- package/src/create-translation-adapter.js.map +0 -1
- package/src/enum-registry.d.ts +0 -65
- package/src/enum-registry.d.ts.map +0 -1
- package/src/enum-registry.js +0 -123
- package/src/enum-registry.js.map +0 -1
- package/src/errors/context-error.d.ts +0 -50
- package/src/errors/context-error.d.ts.map +0 -1
- package/src/errors/context-error.js +0 -75
- package/src/errors/context-error.js.map +0 -1
- package/src/errors/enhanced-error-base.d.ts +0 -125
- package/src/errors/enhanced-error-base.d.ts.map +0 -1
- package/src/errors/enhanced-error-base.js +0 -165
- package/src/errors/enhanced-error-base.js.map +0 -1
- package/src/errors/handleable.d.ts +0 -83
- package/src/errors/handleable.d.ts.map +0 -1
- package/src/errors/handleable.js +0 -136
- package/src/errors/handleable.js.map +0 -1
- package/src/errors/i18n-error.d.ts +0 -211
- package/src/errors/i18n-error.d.ts.map +0 -1
- package/src/errors/i18n-error.js +0 -358
- package/src/errors/i18n-error.js.map +0 -1
- package/src/errors/index.d.ts.map +0 -1
- package/src/errors/index.js +0 -17
- package/src/errors/index.js.map +0 -1
- package/src/errors/simple-typed-error.d.ts +0 -53
- package/src/errors/simple-typed-error.d.ts.map +0 -1
- package/src/errors/simple-typed-error.js +0 -51
- package/src/errors/simple-typed-error.js.map +0 -1
- package/src/errors/translatable-generic.d.ts +0 -84
- package/src/errors/translatable-generic.d.ts.map +0 -1
- package/src/errors/translatable-generic.js +0 -134
- package/src/errors/translatable-generic.js.map +0 -1
- package/src/errors/translatable-handleable-generic.d.ts +0 -116
- package/src/errors/translatable-handleable-generic.d.ts.map +0 -1
- package/src/errors/translatable-handleable-generic.js +0 -121
- package/src/errors/translatable-handleable-generic.js.map +0 -1
- package/src/errors/translatable.d.ts +0 -59
- package/src/errors/translatable.d.ts.map +0 -1
- package/src/errors/translatable.js +0 -80
- package/src/errors/translatable.js.map +0 -1
- package/src/errors/typed-handleable.d.ts +0 -62
- package/src/errors/typed-handleable.d.ts.map +0 -1
- package/src/errors/typed-handleable.js +0 -106
- package/src/errors/typed-handleable.js.map +0 -1
- package/src/errors/typed.d.ts +0 -206
- package/src/errors/typed.d.ts.map +0 -1
- package/src/errors/typed.js +0 -452
- package/src/errors/typed.js.map +0 -1
- package/src/gender/gender-categories.d.ts.map +0 -1
- package/src/gender/gender-categories.js +0 -15
- package/src/gender/gender-categories.js.map +0 -1
- package/src/gender/gender-resolver.d.ts +0 -14
- package/src/gender/gender-resolver.d.ts.map +0 -1
- package/src/gender/gender-resolver.js +0 -35
- package/src/gender/gender-resolver.js.map +0 -1
- package/src/gender/index.d.ts.map +0 -1
- package/src/gender/index.js +0 -6
- package/src/gender/index.js.map +0 -1
- package/src/global-active-context.d.ts +0 -50
- package/src/global-active-context.d.ts.map +0 -1
- package/src/global-active-context.js +0 -185
- package/src/global-active-context.js.map +0 -1
- package/src/icu/ast.d.ts +0 -48
- package/src/icu/ast.d.ts.map +0 -1
- package/src/icu/ast.js +0 -16
- package/src/icu/ast.js.map +0 -1
- package/src/icu/compiler.d.ts +0 -16
- package/src/icu/compiler.d.ts.map +0 -1
- package/src/icu/compiler.js +0 -87
- package/src/icu/compiler.js.map +0 -1
- package/src/icu/formatter-registry.d.ts +0 -10
- package/src/icu/formatter-registry.d.ts.map +0 -1
- package/src/icu/formatter-registry.js +0 -34
- package/src/icu/formatter-registry.js.map +0 -1
- package/src/icu/formatters/base-formatter.d.ts +0 -8
- package/src/icu/formatters/base-formatter.d.ts.map +0 -1
- package/src/icu/formatters/base-formatter.js +0 -3
- package/src/icu/formatters/base-formatter.js.map +0 -1
- package/src/icu/formatters/date-formatter.d.ts +0 -5
- package/src/icu/formatters/date-formatter.d.ts.map +0 -1
- package/src/icu/formatters/date-formatter.js +0 -31
- package/src/icu/formatters/date-formatter.js.map +0 -1
- package/src/icu/formatters/number-formatter.d.ts +0 -5
- package/src/icu/formatters/number-formatter.d.ts.map +0 -1
- package/src/icu/formatters/number-formatter.js +0 -33
- package/src/icu/formatters/number-formatter.js.map +0 -1
- package/src/icu/formatters/plural-formatter.d.ts +0 -5
- package/src/icu/formatters/plural-formatter.d.ts.map +0 -1
- package/src/icu/formatters/plural-formatter.js +0 -15
- package/src/icu/formatters/plural-formatter.js.map +0 -1
- package/src/icu/formatters/select-formatter.d.ts +0 -5
- package/src/icu/formatters/select-formatter.d.ts.map +0 -1
- package/src/icu/formatters/select-formatter.js +0 -10
- package/src/icu/formatters/select-formatter.js.map +0 -1
- package/src/icu/formatters/selectordinal-formatter.d.ts +0 -5
- package/src/icu/formatters/selectordinal-formatter.d.ts.map +0 -1
- package/src/icu/formatters/selectordinal-formatter.js +0 -22
- package/src/icu/formatters/selectordinal-formatter.js.map +0 -1
- package/src/icu/formatters/time-formatter.d.ts +0 -5
- package/src/icu/formatters/time-formatter.d.ts.map +0 -1
- package/src/icu/formatters/time-formatter.js +0 -31
- package/src/icu/formatters/time-formatter.js.map +0 -1
- package/src/icu/helpers.d.ts +0 -9
- package/src/icu/helpers.d.ts.map +0 -1
- package/src/icu/helpers.js +0 -31
- package/src/icu/helpers.js.map +0 -1
- package/src/icu/parser.d.ts +0 -31
- package/src/icu/parser.d.ts.map +0 -1
- package/src/icu/parser.js +0 -203
- package/src/icu/parser.js.map +0 -1
- package/src/icu/runtime.d.ts +0 -10
- package/src/icu/runtime.d.ts.map +0 -1
- package/src/icu/runtime.js +0 -33
- package/src/icu/runtime.js.map +0 -1
- package/src/icu/tokenizer.d.ts +0 -37
- package/src/icu/tokenizer.d.ts.map +0 -1
- package/src/icu/tokenizer.js +0 -187
- package/src/icu/tokenizer.js.map +0 -1
- package/src/icu/validator.d.ts +0 -11
- package/src/icu/validator.d.ts.map +0 -1
- package/src/icu/validator.js +0 -140
- package/src/icu/validator.js.map +0 -1
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -76
- package/src/index.js.map +0 -1
- package/src/interfaces/component-config.interface.d.ts +0 -16
- package/src/interfaces/component-config.interface.d.ts.map +0 -1
- package/src/interfaces/component-config.interface.js +0 -6
- package/src/interfaces/component-config.interface.js.map +0 -1
- package/src/interfaces/engine-config.interface.d.ts +0 -22
- package/src/interfaces/engine-config.interface.d.ts.map +0 -1
- package/src/interfaces/engine-config.interface.js +0 -6
- package/src/interfaces/engine-config.interface.js.map +0 -1
- package/src/interfaces/global-active-context.d.ts +0 -23
- package/src/interfaces/global-active-context.d.ts.map +0 -1
- package/src/interfaces/global-active-context.js +0 -3
- package/src/interfaces/global-active-context.js.map +0 -1
- package/src/interfaces/handleable-error-options.d.ts +0 -14
- package/src/interfaces/handleable-error-options.d.ts.map +0 -1
- package/src/interfaces/handleable-error-options.js +0 -3
- package/src/interfaces/handleable-error-options.js.map +0 -1
- package/src/interfaces/handleable.d.ts +0 -21
- package/src/interfaces/handleable.d.ts.map +0 -1
- package/src/interfaces/handleable.js +0 -3
- package/src/interfaces/handleable.js.map +0 -1
- package/src/interfaces/i18n-engine.interface.d.ts +0 -46
- package/src/interfaces/i18n-engine.interface.d.ts.map +0 -1
- package/src/interfaces/i18n-engine.interface.js +0 -6
- package/src/interfaces/i18n-engine.interface.js.map +0 -1
- package/src/interfaces/index.d.ts +0 -11
- package/src/interfaces/index.d.ts.map +0 -1
- package/src/interfaces/index.js +0 -14
- package/src/interfaces/index.js.map +0 -1
- package/src/interfaces/language-definition.interface.d.ts +0 -17
- package/src/interfaces/language-definition.interface.d.ts.map +0 -1
- package/src/interfaces/language-definition.interface.js +0 -6
- package/src/interfaces/language-definition.interface.js.map +0 -1
- package/src/interfaces/translation-options.interface.d.ts +0 -15
- package/src/interfaces/translation-options.interface.d.ts.map +0 -1
- package/src/interfaces/translation-options.interface.js +0 -6
- package/src/interfaces/translation-options.interface.js.map +0 -1
- package/src/interfaces/validation-result.interface.d.ts +0 -24
- package/src/interfaces/validation-result.interface.d.ts.map +0 -1
- package/src/interfaces/validation-result.interface.js +0 -6
- package/src/interfaces/validation-result.interface.js.map +0 -1
- package/src/language-codes.d.ts +0 -28
- package/src/language-codes.d.ts.map +0 -1
- package/src/language-codes.js +0 -32
- package/src/language-codes.js.map +0 -1
- package/src/language-definition.d.ts +0 -14
- package/src/language-definition.d.ts.map +0 -1
- package/src/language-definition.js +0 -3
- package/src/language-definition.js.map +0 -1
- package/src/plugin-i18n-engine.d.ts +0 -164
- package/src/plugin-i18n-engine.d.ts.map +0 -1
- package/src/plugin-i18n-engine.js +0 -489
- package/src/plugin-i18n-engine.js.map +0 -1
- package/src/pluralization/index.d.ts.map +0 -1
- package/src/pluralization/index.js +0 -10
- package/src/pluralization/index.js.map +0 -1
- package/src/pluralization/language-plural-map.d.ts +0 -29
- package/src/pluralization/language-plural-map.d.ts.map +0 -1
- package/src/pluralization/language-plural-map.js +0 -155
- package/src/pluralization/language-plural-map.js.map +0 -1
- package/src/pluralization/plural-categories.d.ts.map +0 -1
- package/src/pluralization/plural-categories.js +0 -8
- package/src/pluralization/plural-categories.js.map +0 -1
- package/src/pluralization/plural-rules.d.ts +0 -102
- package/src/pluralization/plural-rules.d.ts.map +0 -1
- package/src/pluralization/plural-rules.js +0 -263
- package/src/pluralization/plural-rules.js.map +0 -1
- package/src/registry-config.d.ts +0 -16
- package/src/registry-config.d.ts.map +0 -1
- package/src/registry-config.js +0 -3
- package/src/registry-config.js.map +0 -1
- package/src/registry-error-type.d.ts +0 -20
- package/src/registry-error-type.d.ts.map +0 -1
- package/src/registry-error-type.js +0 -24
- package/src/registry-error-type.js.map +0 -1
- package/src/registry-error.d.ts +0 -19
- package/src/registry-error.d.ts.map +0 -1
- package/src/registry-error.js +0 -49
- package/src/registry-error.js.map +0 -1
- package/src/strict-types.d.ts +0 -19
- package/src/strict-types.d.ts.map +0 -1
- package/src/strict-types.js +0 -18
- package/src/strict-types.js.map +0 -1
- package/src/strings/de.d.ts +0 -3
- package/src/strings/de.d.ts.map +0 -1
- package/src/strings/de.js +0 -57
- package/src/strings/de.js.map +0 -1
- package/src/strings/en-GB.d.ts +0 -3
- package/src/strings/en-GB.d.ts.map +0 -1
- package/src/strings/en-GB.js +0 -57
- package/src/strings/en-GB.js.map +0 -1
- package/src/strings/en-US.d.ts +0 -3
- package/src/strings/en-US.d.ts.map +0 -1
- package/src/strings/en-US.js +0 -57
- package/src/strings/en-US.js.map +0 -1
- package/src/strings/es.d.ts +0 -3
- package/src/strings/es.d.ts.map +0 -1
- package/src/strings/es.js +0 -57
- package/src/strings/es.js.map +0 -1
- package/src/strings/fr.d.ts +0 -3
- package/src/strings/fr.d.ts.map +0 -1
- package/src/strings/fr.js +0 -57
- package/src/strings/fr.js.map +0 -1
- package/src/strings/ja.d.ts +0 -3
- package/src/strings/ja.d.ts.map +0 -1
- package/src/strings/ja.js +0 -57
- package/src/strings/ja.js.map +0 -1
- package/src/strings/uk.d.ts +0 -3
- package/src/strings/uk.d.ts.map +0 -1
- package/src/strings/uk.js +0 -57
- package/src/strings/uk.js.map +0 -1
- package/src/strings/zh-CN.d.ts +0 -3
- package/src/strings/zh-CN.d.ts.map +0 -1
- package/src/strings/zh-CN.js +0 -57
- package/src/strings/zh-CN.js.map +0 -1
- package/src/template.d.ts +0 -13
- package/src/template.d.ts.map +0 -1
- package/src/template.js +0 -40
- package/src/template.js.map +0 -1
- package/src/translation-engine.d.ts +0 -9
- package/src/translation-engine.d.ts.map +0 -1
- package/src/translation-engine.js +0 -3
- package/src/translation-engine.js.map +0 -1
- package/src/translation-request.d.ts +0 -10
- package/src/translation-request.d.ts.map +0 -1
- package/src/translation-request.js +0 -3
- package/src/translation-request.js.map +0 -1
- package/src/translation-response.d.ts +0 -9
- package/src/translation-response.d.ts.map +0 -1
- package/src/translation-response.js +0 -3
- package/src/translation-response.js.map +0 -1
- package/src/types/engine.d.ts +0 -47
- package/src/types/engine.d.ts.map +0 -1
- package/src/types/engine.js +0 -8
- package/src/types/engine.js.map +0 -1
- package/src/types/index.d.ts.map +0 -1
- package/src/types/index.js +0 -9
- package/src/types/index.js.map +0 -1
- package/src/types/plural-types.d.ts.map +0 -1
- package/src/types/plural-types.js +0 -39
- package/src/types/plural-types.js.map +0 -1
- package/src/types.d.ts +0 -96
- package/src/types.d.ts.map +0 -1
- package/src/types.js +0 -23
- package/src/types.js.map +0 -1
- package/src/utils/currency.d.ts +0 -81
- package/src/utils/currency.d.ts.map +0 -1
- package/src/utils/currency.js +0 -101
- package/src/utils/currency.js.map +0 -1
- package/src/utils/html-escape.d.ts +0 -22
- package/src/utils/html-escape.d.ts.map +0 -1
- package/src/utils/html-escape.js +0 -53
- package/src/utils/html-escape.js.map +0 -1
- package/src/utils/index.d.ts.map +0 -1
- package/src/utils/index.js +0 -12
- package/src/utils/index.js.map +0 -1
- package/src/utils/lru-cache.d.ts +0 -42
- package/src/utils/lru-cache.d.ts.map +0 -1
- package/src/utils/lru-cache.js +0 -73
- package/src/utils/lru-cache.js.map +0 -1
- package/src/utils/plural-helpers.d.ts.map +0 -1
- package/src/utils/plural-helpers.js +0 -35
- package/src/utils/plural-helpers.js.map +0 -1
- package/src/utils/safe-object.d.ts +0 -39
- package/src/utils/safe-object.d.ts.map +0 -1
- package/src/utils/safe-object.js.map +0 -1
- package/src/utils/string-utils.d.ts +0 -28
- package/src/utils/string-utils.d.ts.map +0 -1
- package/src/utils/string-utils.js +0 -63
- package/src/utils/string-utils.js.map +0 -1
- package/src/utils/timezone.d.ts +0 -50
- package/src/utils/timezone.d.ts.map +0 -1
- package/src/utils/timezone.js +0 -74
- package/src/utils/timezone.js.map +0 -1
- package/src/utils/validation.d.ts +0 -40
- package/src/utils/validation.d.ts.map +0 -1
- package/src/utils/validation.js +0 -69
- package/src/utils/validation.js.map +0 -1
- package/src/utils.d.ts +0 -65
- package/src/utils.d.ts.map +0 -1
- package/src/utils.js +0 -129
- package/src/utils.js.map +0 -1
- package/src/validation/index.d.ts.map +0 -1
- package/src/validation/index.js +0 -5
- package/src/validation/index.js.map +0 -1
- package/src/validation/plural-validator.d.ts +0 -46
- package/src/validation/plural-validator.d.ts.map +0 -1
- package/src/validation/plural-validator.js +0 -123
- package/src/validation/plural-validator.js.map +0 -1
- package/src/validation-config.d.ts +0 -12
- package/src/validation-config.d.ts.map +0 -1
- package/src/validation-config.js +0 -3
- package/src/validation-config.js.map +0 -1
- package/src/validation-result.d.ts +0 -13
- package/src/validation-result.d.ts.map +0 -1
- package/src/validation-result.js +0 -3
- package/src/validation-result.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/currency.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAS;IAEvB;;;;OAIG;gBACS,KAAK,GAAE,MAAc;IAWjC;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIrC;;;OAGG;IACH,MAAM,CAAC,MAAM,IAAI,MAAM,EAAE;IAIzB;;;OAGG;IACH,MAAM,CAAC,UAAU,IAAI,YAAY,EAAE;CAGpC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,cAAc,CA6BtF"}
|
package/src/utils/currency.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Currency utilities (v2)
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CurrencyCode = void 0;
|
|
7
|
-
exports.getCurrencyFormat = getCurrencyFormat;
|
|
8
|
-
const currency_codes_1 = require("currency-codes");
|
|
9
|
-
const translatable_1 = require("../errors/translatable");
|
|
10
|
-
const core_string_key_1 = require("../core-string-key");
|
|
11
|
-
/**
|
|
12
|
-
* Represents a valid ISO 4217 currency code with validation.
|
|
13
|
-
*/
|
|
14
|
-
class CurrencyCode {
|
|
15
|
-
_value;
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new CurrencyCode instance.
|
|
18
|
-
* @param value - The ISO 4217 currency code (defaults to 'USD')
|
|
19
|
-
* @throws {TranslatableError} If the currency code is invalid
|
|
20
|
-
*/
|
|
21
|
-
constructor(value = 'USD') {
|
|
22
|
-
if (!CurrencyCode.isValid(value)) {
|
|
23
|
-
throw new translatable_1.TranslatableError('core', core_string_key_1.CoreStringKey.Error_InvalidCurrencyCodeTemplate, { value });
|
|
24
|
-
}
|
|
25
|
-
this._value = value;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Gets the currency code value.
|
|
29
|
-
* @returns The ISO 4217 currency code
|
|
30
|
-
*/
|
|
31
|
-
get value() {
|
|
32
|
-
return this._value;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Gets the currency code (alias for value).
|
|
36
|
-
* @returns The ISO 4217 currency code
|
|
37
|
-
*/
|
|
38
|
-
get code() {
|
|
39
|
-
return this._value;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Checks if a currency code is valid according to ISO 4217.
|
|
43
|
-
* @param code - The currency code to validate
|
|
44
|
-
* @returns True if the code is valid, false otherwise
|
|
45
|
-
*/
|
|
46
|
-
static isValid(code) {
|
|
47
|
-
return (0, currency_codes_1.codes)().includes(code);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Gets all valid ISO 4217 currency codes.
|
|
51
|
-
* @returns Array of currency codes
|
|
52
|
-
*/
|
|
53
|
-
static getAll() {
|
|
54
|
-
return (0, currency_codes_1.codes)();
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Gets detailed information for all currencies.
|
|
58
|
-
* @returns Array of currency data objects
|
|
59
|
-
*/
|
|
60
|
-
static getAllData() {
|
|
61
|
-
return currency_codes_1.data;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.CurrencyCode = CurrencyCode;
|
|
65
|
-
/**
|
|
66
|
-
* Gets the currency formatting rules for a specific locale and currency.
|
|
67
|
-
* @param locale - The locale code (e.g., 'en-US', 'fr-FR')
|
|
68
|
-
* @param currencyCode - The ISO 4217 currency code
|
|
69
|
-
* @returns Currency format configuration including symbol, position, and separators
|
|
70
|
-
*/
|
|
71
|
-
function getCurrencyFormat(locale, currencyCode) {
|
|
72
|
-
const formatter = new Intl.NumberFormat(locale, {
|
|
73
|
-
style: 'currency',
|
|
74
|
-
currency: currencyCode,
|
|
75
|
-
});
|
|
76
|
-
const parts = formatter.formatToParts(1234567.89);
|
|
77
|
-
const symbol = parts.find((part) => part.type === 'currency')?.value || '';
|
|
78
|
-
const symbolIndex = parts.findIndex((part) => part.type === 'currency');
|
|
79
|
-
const decimalIndex = parts.findIndex((part) => part.type === 'decimal');
|
|
80
|
-
const integerIndex = parts.findIndex((part) => part.type === 'integer');
|
|
81
|
-
let position;
|
|
82
|
-
if (decimalIndex === -1) {
|
|
83
|
-
position = symbolIndex < integerIndex ? 'prefix' : 'postfix';
|
|
84
|
-
}
|
|
85
|
-
else if (symbolIndex < decimalIndex && symbolIndex < integerIndex) {
|
|
86
|
-
position = 'prefix';
|
|
87
|
-
}
|
|
88
|
-
else if (symbolIndex > decimalIndex) {
|
|
89
|
-
position = 'postfix';
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
position = 'infix';
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
symbol,
|
|
96
|
-
position,
|
|
97
|
-
groupSeparator: parts.find((part) => part.type === 'group')?.value || ',',
|
|
98
|
-
decimalSeparator: parts.find((part) => part.type === 'decimal')?.value || '.',
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=currency.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/currency.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA+GH,8CA6BC;AA1ID,mDAA6C;AAC7C,yDAA2D;AAC3D,wDAAmD;AAqCnD;;GAEG;AACH,MAAa,YAAY;IACf,MAAM,CAAS;IAEvB;;;;OAIG;IACH,YAAY,QAAgB,KAAK;QAC/B,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,gCAAiB,CACzB,MAAM,EACN,+BAAa,CAAC,iCAAiC,EAC/C,EAAE,KAAK,EAAE,CACV,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;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,IAAY;QACzB,OAAO,IAAA,sBAAK,GAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM;QACX,OAAO,IAAA,sBAAK,GAAE,CAAC;IACjB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU;QACf,OAAO,qBAAsB,CAAC;IAChC,CAAC;CACF;AA3DD,oCA2DC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,MAAc,EAAE,YAAoB;IACpE,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QAC9C,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,YAAY;KACvB,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;IAC3E,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;IACxE,MAAM,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACxE,MAAM,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IAExE,IAAI,QAA0B,CAAC;IAC/B,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;QACxB,QAAQ,GAAG,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/D,CAAC;SAAM,IAAI,WAAW,GAAG,YAAY,IAAI,WAAW,GAAG,YAAY,EAAE,CAAC;QACpE,QAAQ,GAAG,QAAQ,CAAC;IACtB,CAAC;SAAM,IAAI,WAAW,GAAG,YAAY,EAAE,CAAC;QACtC,QAAQ,GAAG,SAAS,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,QAAQ,GAAG,OAAO,CAAC;IACrB,CAAC;IAED,OAAO;QACL,MAAM;QACN,QAAQ;QACR,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,EAAE,KAAK,IAAI,GAAG;QACzE,gBAAgB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,EAAE,KAAK,IAAI,GAAG;KAC9E,CAAC;AACJ,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTML escaping utilities for XSS prevention
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Escapes HTML special characters to prevent XSS attacks.
|
|
6
|
-
* @param str - The string to escape
|
|
7
|
-
* @returns The escaped string
|
|
8
|
-
*/
|
|
9
|
-
export declare function escapeHtml(str: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* Safely converts a value to a string, optionally escaping HTML.
|
|
12
|
-
* Rejects objects to prevent toString exploits.
|
|
13
|
-
* @param value - The value to stringify
|
|
14
|
-
* @param options - Options including whether to escape HTML
|
|
15
|
-
* @param options.escapeHtml - If true, HTML-escapes the result
|
|
16
|
-
* @returns The stringified value
|
|
17
|
-
* @throws {Error} If the value is an object (to prevent exploits)
|
|
18
|
-
*/
|
|
19
|
-
export declare function safeStringify(value: any, options?: {
|
|
20
|
-
escapeHtml?: boolean;
|
|
21
|
-
}): string;
|
|
22
|
-
//# sourceMappingURL=html-escape.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"html-escape.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/html-escape.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmBH;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAepF"}
|
package/src/utils/html-escape.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* HTML escaping utilities for XSS prevention
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.escapeHtml = escapeHtml;
|
|
7
|
-
exports.safeStringify = safeStringify;
|
|
8
|
-
/**
|
|
9
|
-
* Map of HTML characters to their escaped equivalents.
|
|
10
|
-
*/
|
|
11
|
-
const HTML_ESCAPES = {
|
|
12
|
-
'&': '&',
|
|
13
|
-
'<': '<',
|
|
14
|
-
'>': '>',
|
|
15
|
-
'"': '"',
|
|
16
|
-
"'": ''',
|
|
17
|
-
'/': '/',
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Regular expression to match characters that need HTML escaping.
|
|
21
|
-
*/
|
|
22
|
-
const HTML_ESCAPE_REGEX = /[&<>"'/]/g;
|
|
23
|
-
/**
|
|
24
|
-
* Escapes HTML special characters to prevent XSS attacks.
|
|
25
|
-
* @param str - The string to escape
|
|
26
|
-
* @returns The escaped string
|
|
27
|
-
*/
|
|
28
|
-
function escapeHtml(str) {
|
|
29
|
-
return str.replace(HTML_ESCAPE_REGEX, char => HTML_ESCAPES[char]);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Safely converts a value to a string, optionally escaping HTML.
|
|
33
|
-
* Rejects objects to prevent toString exploits.
|
|
34
|
-
* @param value - The value to stringify
|
|
35
|
-
* @param options - Options including whether to escape HTML
|
|
36
|
-
* @param options.escapeHtml - If true, HTML-escapes the result
|
|
37
|
-
* @returns The stringified value
|
|
38
|
-
* @throws {Error} If the value is an object (to prevent exploits)
|
|
39
|
-
*/
|
|
40
|
-
function safeStringify(value, options) {
|
|
41
|
-
if (value === null || value === undefined) {
|
|
42
|
-
return '';
|
|
43
|
-
}
|
|
44
|
-
if (typeof value === 'string') {
|
|
45
|
-
return options?.escapeHtml ? escapeHtml(value) : value;
|
|
46
|
-
}
|
|
47
|
-
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
48
|
-
return String(value);
|
|
49
|
-
}
|
|
50
|
-
// Reject objects to prevent toString exploits
|
|
51
|
-
throw new Error('Invalid value type for stringification');
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=html-escape.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"html-escape.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/html-escape.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAwBH,gCAEC;AAWD,sCAeC;AAlDD;;GAEG;AACH,MAAM,YAAY,GAA2B;IAC3C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,QAAQ;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAEtC;;;;GAIG;AACH,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAAC,KAAU,EAAE,OAAkC;IAC1E,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACzD,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,8CAA8C;IAC9C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;AAC5D,CAAC"}
|
package/src/utils/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
package/src/utils/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./plural-helpers"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./safe-object"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./string-utils"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./currency"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./timezone"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./validation"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./html-escape"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./lru-cache"), exports);
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
package/src/utils/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,wDAA8B;AAC9B,yDAA+B;AAC/B,qDAA2B;AAC3B,qDAA2B;AAC3B,uDAA6B;AAC7B,wDAA8B;AAC9B,sDAA4B"}
|
package/src/utils/lru-cache.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple LRU Cache implementation for security
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Least Recently Used (LRU) cache implementation.
|
|
6
|
-
* Automatically evicts the oldest entries when the cache reaches maximum size.
|
|
7
|
-
* @template K - The type of cache keys
|
|
8
|
-
* @template V - The type of cached values
|
|
9
|
-
*/
|
|
10
|
-
export declare class LRUCache<K, V> {
|
|
11
|
-
private cache;
|
|
12
|
-
private readonly maxSize;
|
|
13
|
-
/**
|
|
14
|
-
* Creates a new LRUCache instance.
|
|
15
|
-
* @param maxSize - Maximum number of entries to store (default: 1000)
|
|
16
|
-
*/
|
|
17
|
-
constructor(maxSize?: number);
|
|
18
|
-
/**
|
|
19
|
-
* Retrieves a value from the cache by key.
|
|
20
|
-
* Accessing an item moves it to the end (marks it as most recently used).
|
|
21
|
-
* @param key - The key to look up
|
|
22
|
-
* @returns The cached value, or undefined if not found
|
|
23
|
-
*/
|
|
24
|
-
get(key: K): V | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Adds or updates a value in the cache.
|
|
27
|
-
* If the cache is at capacity, the oldest entry is removed.
|
|
28
|
-
* @param key - The key to store
|
|
29
|
-
* @param value - The value to cache
|
|
30
|
-
*/
|
|
31
|
-
set(key: K, value: V): void;
|
|
32
|
-
/**
|
|
33
|
-
* Removes all entries from the cache.
|
|
34
|
-
*/
|
|
35
|
-
clear(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Gets the current number of entries in the cache.
|
|
38
|
-
* @returns The number of cached entries
|
|
39
|
-
*/
|
|
40
|
-
size(): number;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=lru-cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lru-cache.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/lru-cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC;IACxB,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC;;;OAGG;gBACS,OAAO,GAAE,MAAa;IAIlC;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAU1B;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAiB3B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,IAAI,IAAI,MAAM;CAGf"}
|
package/src/utils/lru-cache.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Simple LRU Cache implementation for security
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LRUCache = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Least Recently Used (LRU) cache implementation.
|
|
9
|
-
* Automatically evicts the oldest entries when the cache reaches maximum size.
|
|
10
|
-
* @template K - The type of cache keys
|
|
11
|
-
* @template V - The type of cached values
|
|
12
|
-
*/
|
|
13
|
-
class LRUCache {
|
|
14
|
-
cache = new Map();
|
|
15
|
-
maxSize;
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new LRUCache instance.
|
|
18
|
-
* @param maxSize - Maximum number of entries to store (default: 1000)
|
|
19
|
-
*/
|
|
20
|
-
constructor(maxSize = 1000) {
|
|
21
|
-
this.maxSize = maxSize;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Retrieves a value from the cache by key.
|
|
25
|
-
* Accessing an item moves it to the end (marks it as most recently used).
|
|
26
|
-
* @param key - The key to look up
|
|
27
|
-
* @returns The cached value, or undefined if not found
|
|
28
|
-
*/
|
|
29
|
-
get(key) {
|
|
30
|
-
const value = this.cache.get(key);
|
|
31
|
-
if (value !== undefined) {
|
|
32
|
-
// Move to end (most recently used)
|
|
33
|
-
this.cache.delete(key);
|
|
34
|
-
this.cache.set(key, value);
|
|
35
|
-
}
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Adds or updates a value in the cache.
|
|
40
|
-
* If the cache is at capacity, the oldest entry is removed.
|
|
41
|
-
* @param key - The key to store
|
|
42
|
-
* @param value - The value to cache
|
|
43
|
-
*/
|
|
44
|
-
set(key, value) {
|
|
45
|
-
// Remove if exists to update position
|
|
46
|
-
if (this.cache.has(key)) {
|
|
47
|
-
this.cache.delete(key);
|
|
48
|
-
}
|
|
49
|
-
// Remove oldest if at capacity
|
|
50
|
-
if (this.cache.size >= this.maxSize) {
|
|
51
|
-
const firstKey = this.cache.keys().next().value;
|
|
52
|
-
if (firstKey !== undefined) {
|
|
53
|
-
this.cache.delete(firstKey);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
this.cache.set(key, value);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Removes all entries from the cache.
|
|
60
|
-
*/
|
|
61
|
-
clear() {
|
|
62
|
-
this.cache.clear();
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Gets the current number of entries in the cache.
|
|
66
|
-
* @returns The number of cached entries
|
|
67
|
-
*/
|
|
68
|
-
size() {
|
|
69
|
-
return this.cache.size;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.LRUCache = LRUCache;
|
|
73
|
-
//# sourceMappingURL=lru-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lru-cache.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/lru-cache.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH;;;;;GAKG;AACH,MAAa,QAAQ;IACX,KAAK,GAAG,IAAI,GAAG,EAAQ,CAAC;IACf,OAAO,CAAS;IAEjC;;;OAGG;IACH,YAAY,UAAkB,IAAI;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,GAAM;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,mCAAmC;YACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,GAAM,EAAE,KAAQ;QAClB,sCAAsC;QACtC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;QAED,+BAA+B;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YAChD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AAjED,4BAiEC"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plural-helpers.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/utils/plural-helpers.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAYH,gDAEC;AAOD,oDAEC;AAQD,wDAEC;AA5BD,8EAAyG;AAEzG;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,KAA8C;IAC/E,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,KAA8C;IACjF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,OAAO,IAAA,4CAAuB,EAAC,QAAQ,CAAqB,CAAC;AAC/D,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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"}
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,63 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/src/utils/timezone.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|