@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.
- package/package.json +8 -7
- package/src/{active-context.ts → active-context.d.ts} +1 -0
- package/src/active-context.d.ts.map +1 -0
- package/src/active-context.js +3 -0
- package/src/active-context.js.map +1 -0
- package/src/builders/i18n-builder.d.ts +26 -0
- package/src/builders/i18n-builder.d.ts.map +1 -0
- package/src/builders/i18n-builder.js +70 -0
- package/src/builders/i18n-builder.js.map +1 -0
- package/src/builders/{index.ts → index.d.ts} +1 -1
- package/src/builders/index.d.ts.map +1 -0
- package/src/builders/index.js +8 -0
- package/src/builders/index.js.map +1 -0
- package/src/component-definition.d.ts +12 -0
- package/src/component-definition.d.ts.map +1 -0
- package/src/component-definition.js +3 -0
- package/src/component-definition.js.map +1 -0
- package/src/component-registration.d.ts +22 -0
- package/src/component-registration.d.ts.map +1 -0
- package/src/component-registration.js +3 -0
- package/src/component-registration.js.map +1 -0
- package/src/component-registry.d.ts +102 -0
- package/src/component-registry.d.ts.map +1 -0
- package/src/component-registry.js +282 -0
- package/src/component-registry.js.map +1 -0
- package/src/context-error-type.d.ts +8 -0
- package/src/context-error-type.d.ts.map +1 -0
- package/src/context-error-type.js +12 -0
- package/src/context-error-type.js.map +1 -0
- package/src/core/component-store.d.ts +93 -0
- package/src/core/component-store.d.ts.map +1 -0
- package/src/core/component-store.js +198 -0
- package/src/core/component-store.js.map +1 -0
- package/src/core/context-manager.d.ts +72 -0
- package/src/core/context-manager.d.ts.map +1 -0
- package/src/core/context-manager.js +98 -0
- package/src/core/context-manager.js.map +1 -0
- package/src/core/enum-registry.d.ts +48 -0
- package/src/core/enum-registry.d.ts.map +1 -0
- package/src/core/enum-registry.js +85 -0
- package/src/core/enum-registry.js.map +1 -0
- package/src/core/i18n-engine.d.ts +241 -0
- package/src/core/i18n-engine.d.ts.map +1 -0
- package/src/core/i18n-engine.js +568 -0
- package/src/core/i18n-engine.js.map +1 -0
- package/src/core/{index.ts → index.d.ts} +1 -4
- package/src/core/index.d.ts.map +1 -0
- package/src/core/index.js +21 -0
- package/src/core/index.js.map +1 -0
- package/src/core/language-registry.d.ts +180 -0
- package/src/core/language-registry.d.ts.map +1 -0
- package/src/core/language-registry.js +298 -0
- package/src/core/language-registry.js.map +1 -0
- package/src/{core-component-id.ts → core-component-id.d.ts} +2 -1
- package/src/core-component-id.d.ts.map +1 -0
- package/src/core-component-id.js +9 -0
- package/src/core-component-id.js.map +1 -0
- package/src/core-i18n.d.ts +69 -0
- package/src/core-i18n.d.ts.map +1 -0
- package/src/core-i18n.js +219 -0
- package/src/core-i18n.js.map +1 -0
- package/src/core-plugin-factory.d.ts +28 -0
- package/src/core-plugin-factory.d.ts.map +1 -0
- package/src/core-plugin-factory.js +80 -0
- package/src/core-plugin-factory.js.map +1 -0
- package/src/core-string-key.d.ts +52 -0
- package/src/core-string-key.d.ts.map +1 -0
- package/src/core-string-key.js +61 -0
- package/src/core-string-key.js.map +1 -0
- package/src/create-translation-adapter.d.ts +33 -0
- package/src/create-translation-adapter.d.ts.map +1 -0
- package/src/create-translation-adapter.js +72 -0
- package/src/create-translation-adapter.js.map +1 -0
- package/src/enum-registry.d.ts +65 -0
- package/src/enum-registry.d.ts.map +1 -0
- package/src/enum-registry.js +123 -0
- package/src/enum-registry.js.map +1 -0
- package/src/errors/{base.ts → base.d.ts} +1 -1
- package/src/errors/base.d.ts.map +1 -0
- package/src/errors/base.js +11 -0
- package/src/errors/base.js.map +1 -0
- package/src/errors/context-error.d.ts +50 -0
- package/src/errors/context-error.d.ts.map +1 -0
- package/src/errors/context-error.js +93 -0
- package/src/errors/context-error.js.map +1 -0
- package/src/errors/enhanced-error-base.d.ts +125 -0
- package/src/errors/enhanced-error-base.d.ts.map +1 -0
- package/src/errors/enhanced-error-base.js +165 -0
- package/src/errors/enhanced-error-base.js.map +1 -0
- package/src/errors/handleable.d.ts +83 -0
- package/src/errors/handleable.d.ts.map +1 -0
- package/src/errors/handleable.js +136 -0
- package/src/errors/handleable.js.map +1 -0
- package/src/errors/i18n-error.d.ts +211 -0
- package/src/errors/i18n-error.d.ts.map +1 -0
- package/src/errors/i18n-error.js +358 -0
- package/src/errors/i18n-error.js.map +1 -0
- package/src/errors/{index.ts → index.d.ts} +1 -4
- package/src/errors/index.d.ts.map +1 -0
- package/src/errors/index.js +17 -0
- package/src/errors/index.js.map +1 -0
- package/src/errors/simple-typed-error.d.ts +53 -0
- package/src/errors/simple-typed-error.d.ts.map +1 -0
- package/src/errors/simple-typed-error.js +51 -0
- package/src/errors/simple-typed-error.js.map +1 -0
- package/src/errors/{translatable-exports.ts → translatable-exports.d.ts} +1 -1
- package/src/errors/translatable-exports.d.ts.map +1 -0
- package/src/errors/translatable-exports.js +15 -0
- package/src/errors/translatable-exports.js.map +1 -0
- package/src/errors/translatable-generic.d.ts +87 -0
- package/src/errors/translatable-generic.d.ts.map +1 -0
- package/src/errors/translatable-generic.js +139 -0
- package/src/errors/translatable-generic.js.map +1 -0
- package/src/errors/translatable-handleable-generic.d.ts +116 -0
- package/src/errors/translatable-handleable-generic.d.ts.map +1 -0
- package/src/errors/translatable-handleable-generic.js +121 -0
- package/src/errors/translatable-handleable-generic.js.map +1 -0
- package/src/errors/translatable.d.ts +63 -0
- package/src/errors/translatable.d.ts.map +1 -0
- package/src/errors/translatable.js +85 -0
- package/src/errors/translatable.js.map +1 -0
- package/src/errors/typed-handleable.d.ts +62 -0
- package/src/errors/typed-handleable.d.ts.map +1 -0
- package/src/errors/typed-handleable.js +108 -0
- package/src/errors/typed-handleable.js.map +1 -0
- package/src/errors/typed.d.ts +206 -0
- package/src/errors/typed.d.ts.map +1 -0
- package/src/errors/typed.js +458 -0
- package/src/errors/typed.js.map +1 -0
- package/src/gender/{gender-categories.ts → gender-categories.d.ts} +2 -6
- package/src/gender/gender-categories.d.ts.map +1 -0
- package/src/gender/gender-categories.js +15 -0
- package/src/gender/gender-categories.js.map +1 -0
- package/src/gender/gender-resolver.d.ts +14 -0
- package/src/gender/gender-resolver.d.ts.map +1 -0
- package/src/gender/gender-resolver.js +35 -0
- package/src/gender/gender-resolver.js.map +1 -0
- package/src/gender/{index.ts → index.d.ts} +1 -0
- package/src/gender/index.d.ts.map +1 -0
- package/src/gender/index.js +6 -0
- package/src/gender/index.js.map +1 -0
- package/src/global-active-context.d.ts +50 -0
- package/src/global-active-context.d.ts.map +1 -0
- package/src/global-active-context.js +185 -0
- package/src/global-active-context.js.map +1 -0
- package/src/icu/ast.d.ts +48 -0
- package/src/icu/ast.d.ts.map +1 -0
- package/src/icu/ast.js +16 -0
- package/src/icu/ast.js.map +1 -0
- package/src/icu/compiler.d.ts +16 -0
- package/src/icu/compiler.d.ts.map +1 -0
- package/src/icu/compiler.js +87 -0
- package/src/icu/compiler.js.map +1 -0
- package/src/icu/formatter-registry.d.ts +10 -0
- package/src/icu/formatter-registry.d.ts.map +1 -0
- package/src/icu/formatter-registry.js +34 -0
- package/src/icu/formatter-registry.js.map +1 -0
- package/src/icu/formatters/base-formatter.d.ts +8 -0
- package/src/icu/formatters/base-formatter.d.ts.map +1 -0
- package/src/icu/formatters/base-formatter.js +3 -0
- package/src/icu/formatters/base-formatter.js.map +1 -0
- package/src/icu/formatters/date-formatter.d.ts +5 -0
- package/src/icu/formatters/date-formatter.d.ts.map +1 -0
- package/src/icu/formatters/date-formatter.js +31 -0
- package/src/icu/formatters/date-formatter.js.map +1 -0
- package/src/icu/formatters/number-formatter.d.ts +5 -0
- package/src/icu/formatters/number-formatter.d.ts.map +1 -0
- package/src/icu/formatters/number-formatter.js +33 -0
- package/src/icu/formatters/number-formatter.js.map +1 -0
- package/src/icu/formatters/plural-formatter.d.ts +5 -0
- package/src/icu/formatters/plural-formatter.d.ts.map +1 -0
- package/src/icu/formatters/plural-formatter.js +15 -0
- package/src/icu/formatters/plural-formatter.js.map +1 -0
- package/src/icu/formatters/select-formatter.d.ts +5 -0
- package/src/icu/formatters/select-formatter.d.ts.map +1 -0
- package/src/icu/formatters/select-formatter.js +10 -0
- package/src/icu/formatters/select-formatter.js.map +1 -0
- package/src/icu/formatters/selectordinal-formatter.d.ts +5 -0
- package/src/icu/formatters/selectordinal-formatter.d.ts.map +1 -0
- package/src/icu/formatters/selectordinal-formatter.js +22 -0
- package/src/icu/formatters/selectordinal-formatter.js.map +1 -0
- package/src/icu/formatters/time-formatter.d.ts +5 -0
- package/src/icu/formatters/time-formatter.d.ts.map +1 -0
- package/src/icu/formatters/time-formatter.js +31 -0
- package/src/icu/formatters/time-formatter.js.map +1 -0
- package/src/icu/helpers.d.ts +9 -0
- package/src/icu/helpers.d.ts.map +1 -0
- package/src/icu/helpers.js +31 -0
- package/src/icu/helpers.js.map +1 -0
- package/src/icu/parser.d.ts +31 -0
- package/src/icu/parser.d.ts.map +1 -0
- package/src/icu/parser.js +203 -0
- package/src/icu/parser.js.map +1 -0
- package/src/icu/runtime.d.ts +10 -0
- package/src/icu/runtime.d.ts.map +1 -0
- package/src/icu/runtime.js +33 -0
- package/src/icu/runtime.js.map +1 -0
- package/src/icu/tokenizer.d.ts +37 -0
- package/src/icu/tokenizer.d.ts.map +1 -0
- package/src/icu/tokenizer.js +187 -0
- package/src/icu/tokenizer.js.map +1 -0
- package/src/icu/validator.d.ts +11 -0
- package/src/icu/validator.d.ts.map +1 -0
- package/src/icu/validator.js +140 -0
- package/src/icu/validator.js.map +1 -0
- package/src/{index.ts → index.d.ts} +6 -38
- package/src/index.d.ts.map +1 -0
- package/src/index.js +76 -0
- package/src/index.js.map +1 -0
- package/src/interfaces/active-context.interface.d.ts +36 -0
- package/src/interfaces/active-context.interface.d.ts.map +1 -0
- package/src/interfaces/active-context.interface.js +3 -0
- package/src/interfaces/active-context.interface.js.map +1 -0
- package/src/interfaces/component-config.interface.d.ts +16 -0
- package/src/interfaces/component-config.interface.d.ts.map +1 -0
- package/src/interfaces/component-config.interface.js +6 -0
- package/src/interfaces/component-config.interface.js.map +1 -0
- package/src/interfaces/engine-config.interface.d.ts +22 -0
- package/src/interfaces/engine-config.interface.d.ts.map +1 -0
- package/src/interfaces/engine-config.interface.js +6 -0
- package/src/interfaces/engine-config.interface.js.map +1 -0
- package/src/interfaces/global-active-context.d.ts +23 -0
- package/src/interfaces/global-active-context.d.ts.map +1 -0
- package/src/interfaces/global-active-context.js +3 -0
- package/src/interfaces/global-active-context.js.map +1 -0
- package/src/interfaces/handleable-error-options.d.ts +14 -0
- package/src/interfaces/handleable-error-options.d.ts.map +1 -0
- package/src/interfaces/handleable-error-options.js +3 -0
- package/src/interfaces/handleable-error-options.js.map +1 -0
- package/src/interfaces/handleable.d.ts +21 -0
- package/src/interfaces/handleable.d.ts.map +1 -0
- package/src/interfaces/handleable.js +3 -0
- package/src/interfaces/handleable.js.map +1 -0
- package/src/interfaces/i18n-engine.interface.d.ts +46 -0
- package/src/interfaces/i18n-engine.interface.d.ts.map +1 -0
- package/src/interfaces/i18n-engine.interface.js +6 -0
- package/src/interfaces/i18n-engine.interface.js.map +1 -0
- package/src/interfaces/{index.ts → index.d.ts} +1 -1
- package/src/interfaces/index.d.ts.map +1 -0
- package/src/interfaces/index.js +7 -0
- package/src/interfaces/index.js.map +1 -0
- package/src/interfaces/language-definition.interface.d.ts +17 -0
- package/src/interfaces/language-definition.interface.d.ts.map +1 -0
- package/src/interfaces/language-definition.interface.js +6 -0
- package/src/interfaces/language-definition.interface.js.map +1 -0
- package/src/interfaces/translation-options.interface.d.ts +15 -0
- package/src/interfaces/translation-options.interface.d.ts.map +1 -0
- package/src/interfaces/translation-options.interface.js +6 -0
- package/src/interfaces/translation-options.interface.js.map +1 -0
- package/src/interfaces/validation-result.interface.d.ts +24 -0
- package/src/interfaces/validation-result.interface.d.ts.map +1 -0
- package/src/interfaces/validation-result.interface.js +6 -0
- package/src/interfaces/validation-result.interface.js.map +1 -0
- package/src/language-codes.d.ts +28 -0
- package/src/language-codes.d.ts.map +1 -0
- package/src/language-codes.js +32 -0
- package/src/language-codes.js.map +1 -0
- package/src/language-definition.d.ts +14 -0
- package/src/language-definition.d.ts.map +1 -0
- package/src/language-definition.js +3 -0
- package/src/language-definition.js.map +1 -0
- package/src/plugin-i18n-engine.d.ts +164 -0
- package/src/plugin-i18n-engine.d.ts.map +1 -0
- package/src/plugin-i18n-engine.js +493 -0
- package/src/plugin-i18n-engine.js.map +1 -0
- package/src/pluralization/{index.ts → index.d.ts} +1 -1
- package/src/pluralization/index.d.ts.map +1 -0
- package/src/pluralization/index.js +10 -0
- package/src/pluralization/index.js.map +1 -0
- package/src/pluralization/language-plural-map.d.ts +29 -0
- package/src/pluralization/language-plural-map.d.ts.map +1 -0
- package/src/pluralization/language-plural-map.js +155 -0
- package/src/pluralization/language-plural-map.js.map +1 -0
- package/src/pluralization/{plural-categories.ts → plural-categories.d.ts} +3 -5
- package/src/pluralization/plural-categories.d.ts.map +1 -0
- package/src/pluralization/plural-categories.js +8 -0
- package/src/pluralization/plural-categories.js.map +1 -0
- package/src/pluralization/plural-rules.d.ts +102 -0
- package/src/pluralization/plural-rules.d.ts.map +1 -0
- package/src/pluralization/plural-rules.js +263 -0
- package/src/pluralization/plural-rules.js.map +1 -0
- package/src/registry-config.d.ts +16 -0
- package/src/registry-config.d.ts.map +1 -0
- package/src/registry-config.js +3 -0
- package/src/registry-config.js.map +1 -0
- package/src/registry-error-type.d.ts +20 -0
- package/src/registry-error-type.d.ts.map +1 -0
- package/src/registry-error-type.js +24 -0
- package/src/registry-error-type.js.map +1 -0
- package/src/registry-error.d.ts +25 -0
- package/src/registry-error.d.ts.map +1 -0
- package/src/registry-error.js +63 -0
- package/src/registry-error.js.map +1 -0
- package/src/strict-types.d.ts +19 -0
- package/src/strict-types.d.ts.map +1 -0
- package/src/strict-types.js +18 -0
- package/src/strict-types.js.map +1 -0
- package/src/strings/de.d.ts +3 -0
- package/src/strings/de.d.ts.map +1 -0
- package/src/strings/de.js +57 -0
- package/src/strings/de.js.map +1 -0
- package/src/strings/en-GB.d.ts +3 -0
- package/src/strings/en-GB.d.ts.map +1 -0
- package/src/strings/en-GB.js +57 -0
- package/src/strings/en-GB.js.map +1 -0
- package/src/strings/en-US.d.ts +3 -0
- package/src/strings/en-US.d.ts.map +1 -0
- package/src/strings/en-US.js +57 -0
- package/src/strings/en-US.js.map +1 -0
- package/src/strings/es.d.ts +3 -0
- package/src/strings/es.d.ts.map +1 -0
- package/src/strings/es.js +57 -0
- package/src/strings/es.js.map +1 -0
- package/src/strings/fr.d.ts +3 -0
- package/src/strings/fr.d.ts.map +1 -0
- package/src/strings/fr.js +57 -0
- package/src/strings/fr.js.map +1 -0
- package/src/strings/ja.d.ts +3 -0
- package/src/strings/ja.d.ts.map +1 -0
- package/src/strings/ja.js +57 -0
- package/src/strings/ja.js.map +1 -0
- package/src/strings/uk.d.ts +3 -0
- package/src/strings/uk.d.ts.map +1 -0
- package/src/strings/uk.js +57 -0
- package/src/strings/uk.js.map +1 -0
- package/src/strings/zh-CN.d.ts +3 -0
- package/src/strings/zh-CN.d.ts.map +1 -0
- package/src/strings/zh-CN.js +57 -0
- package/src/strings/zh-CN.js.map +1 -0
- package/src/template.d.ts +13 -0
- package/src/template.d.ts.map +1 -0
- package/src/template.js +40 -0
- package/src/template.js.map +1 -0
- package/src/translation-engine.d.ts +9 -0
- package/src/translation-engine.d.ts.map +1 -0
- package/src/translation-engine.js +3 -0
- package/src/translation-engine.js.map +1 -0
- package/src/translation-request.d.ts +10 -0
- package/src/translation-request.d.ts.map +1 -0
- package/src/translation-request.js +3 -0
- package/src/translation-request.js.map +1 -0
- package/src/translation-response.d.ts +9 -0
- package/src/translation-response.d.ts.map +1 -0
- package/src/translation-response.js +3 -0
- package/src/translation-response.js.map +1 -0
- package/src/types/engine.d.ts +47 -0
- package/src/types/engine.d.ts.map +1 -0
- package/src/types/engine.js +8 -0
- package/src/types/engine.js.map +1 -0
- package/src/types/{index.ts → index.d.ts} +1 -1
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.js +9 -0
- package/src/types/index.js.map +1 -0
- package/src/types/{plural-types.ts → plural-types.d.ts} +3 -29
- package/src/types/plural-types.d.ts.map +1 -0
- package/src/types/plural-types.js +39 -0
- package/src/types/plural-types.js.map +1 -0
- package/src/{types.ts → types.d.ts} +21 -72
- package/src/types.d.ts.map +1 -0
- package/src/types.js +23 -0
- package/src/types.js.map +1 -0
- package/src/utils/currency.d.ts +81 -0
- package/src/utils/currency.d.ts.map +1 -0
- package/src/utils/currency.js +99 -0
- package/src/utils/currency.js.map +1 -0
- package/src/utils/html-escape.d.ts +22 -0
- package/src/utils/html-escape.d.ts.map +1 -0
- package/src/utils/html-escape.js +53 -0
- package/src/utils/html-escape.js.map +1 -0
- package/src/utils/{index.ts → index.d.ts} +1 -0
- package/src/utils/index.d.ts.map +1 -0
- package/src/utils/index.js +12 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/lru-cache.d.ts +42 -0
- package/src/utils/lru-cache.d.ts.map +1 -0
- package/src/utils/lru-cache.js +73 -0
- package/src/utils/lru-cache.js.map +1 -0
- package/src/utils/{plural-helpers.ts → plural-helpers.d.ts} +4 -14
- package/src/utils/plural-helpers.d.ts.map +1 -0
- package/src/utils/plural-helpers.js +35 -0
- package/src/utils/plural-helpers.js.map +1 -0
- package/src/utils/safe-object.d.ts +39 -0
- package/src/utils/safe-object.d.ts.map +1 -0
- package/src/utils/{safe-object.ts → safe-object.js} +34 -37
- package/src/utils/safe-object.js.map +1 -0
- package/src/utils/string-utils.d.ts +28 -0
- package/src/utils/string-utils.d.ts.map +1 -0
- package/src/utils/string-utils.js +63 -0
- package/src/utils/string-utils.js.map +1 -0
- package/src/utils/timezone.d.ts +50 -0
- package/src/utils/timezone.d.ts.map +1 -0
- package/src/utils/timezone.js +74 -0
- package/src/utils/timezone.js.map +1 -0
- package/src/utils/validation.d.ts +40 -0
- package/src/utils/validation.d.ts.map +1 -0
- package/src/utils/validation.js +69 -0
- package/src/utils/validation.js.map +1 -0
- package/src/utils.d.ts +65 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.js +129 -0
- package/src/utils.js.map +1 -0
- package/src/validation/{index.ts → index.d.ts} +1 -0
- package/src/validation/index.d.ts.map +1 -0
- package/src/validation/index.js +5 -0
- package/src/validation/index.js.map +1 -0
- package/src/validation/plural-validator.d.ts +46 -0
- package/src/validation/plural-validator.d.ts.map +1 -0
- package/src/validation/plural-validator.js +123 -0
- package/src/validation/plural-validator.js.map +1 -0
- package/src/validation-config.d.ts +12 -0
- package/src/validation-config.d.ts.map +1 -0
- package/src/validation-config.js +3 -0
- package/src/validation-config.js.map +1 -0
- package/src/validation-result.d.ts +13 -0
- package/src/validation-result.d.ts.map +1 -0
- package/src/validation-result.js +3 -0
- package/src/validation-result.js.map +1 -0
- package/LICENSE +0 -21
- package/src/builders/i18n-builder.ts +0 -82
- package/src/component-definition.ts +0 -11
- package/src/component-registration.ts +0 -29
- package/src/component-registry.ts +0 -432
- package/src/context-error-type.ts +0 -7
- package/src/core/component-store.ts +0 -241
- package/src/core/context-manager.ts +0 -113
- package/src/core/enum-registry.ts +0 -106
- package/src/core/i18n-engine.ts +0 -710
- package/src/core/language-registry.ts +0 -345
- package/src/core-i18n.ts +0 -270
- package/src/core-plugin-factory.ts +0 -111
- package/src/core-string-key.ts +0 -59
- package/src/create-translation-adapter.ts +0 -93
- package/src/enum-registry.ts +0 -152
- package/src/errors/context-error.ts +0 -122
- package/src/errors/enhanced-error-base.ts +0 -260
- package/src/errors/handleable.ts +0 -152
- package/src/errors/i18n-error.ts +0 -494
- package/src/errors/simple-typed-error.ts +0 -81
- package/src/errors/translatable-generic.ts +0 -245
- package/src/errors/translatable-handleable-generic.ts +0 -222
- package/src/errors/translatable.ts +0 -138
- package/src/errors/typed-handleable.ts +0 -138
- package/src/errors/typed.ts +0 -617
- package/src/gender/gender-resolver.ts +0 -40
- package/src/global-active-context.ts +0 -266
- package/src/icu/ast.ts +0 -56
- package/src/icu/compiler.ts +0 -96
- package/src/icu/formatter-registry.ts +0 -36
- package/src/icu/formatters/base-formatter.ts +0 -8
- package/src/icu/formatters/date-formatter.ts +0 -30
- package/src/icu/formatters/number-formatter.ts +0 -32
- package/src/icu/formatters/plural-formatter.ts +0 -12
- package/src/icu/formatters/select-formatter.ts +0 -7
- package/src/icu/formatters/selectordinal-formatter.ts +0 -17
- package/src/icu/formatters/time-formatter.ts +0 -30
- package/src/icu/helpers.ts +0 -34
- package/src/icu/parser.ts +0 -242
- package/src/icu/runtime.ts +0 -37
- package/src/icu/tokenizer.ts +0 -212
- package/src/icu/validator.ts +0 -163
- package/src/interfaces/active-context.interface.ts +0 -41
- package/src/interfaces/component-config.interface.ts +0 -17
- package/src/interfaces/engine-config.interface.ts +0 -22
- package/src/interfaces/global-active-context.ts +0 -39
- package/src/interfaces/handleable-error-options.ts +0 -13
- package/src/interfaces/handleable.ts +0 -20
- package/src/interfaces/i18n-engine.interface.ts +0 -57
- package/src/interfaces/language-definition.interface.ts +0 -17
- package/src/interfaces/translation-options.interface.ts +0 -15
- package/src/interfaces/validation-result.interface.ts +0 -24
- package/src/language-codes.ts +0 -40
- package/src/language-definition.ts +0 -13
- package/src/plugin-i18n-engine.ts +0 -707
- package/src/pluralization/language-plural-map.ts +0 -186
- package/src/pluralization/plural-rules.ts +0 -228
- package/src/registry-config.ts +0 -16
- package/src/registry-error-type.ts +0 -19
- package/src/registry-error.ts +0 -100
- package/src/strict-types.ts +0 -35
- package/src/strings/de.ts +0 -75
- package/src/strings/en-GB.ts +0 -74
- package/src/strings/en-US.ts +0 -74
- package/src/strings/es.ts +0 -74
- package/src/strings/fr.ts +0 -75
- package/src/strings/ja.ts +0 -73
- package/src/strings/uk.ts +0 -73
- package/src/strings/zh-CN.ts +0 -72
- package/src/template.ts +0 -72
- package/src/translation-engine.ts +0 -18
- package/src/translation-request.ts +0 -12
- package/src/translation-response.ts +0 -8
- package/src/types/engine.ts +0 -55
- package/src/utils/currency.ts +0 -141
- package/src/utils/html-escape.ts +0 -55
- package/src/utils/lru-cache.ts +0 -76
- package/src/utils/string-utils.ts +0 -77
- package/src/utils/timezone.ts +0 -76
- package/src/utils/validation.ts +0 -66
- package/src/utils.ts +0 -215
- package/src/validation/plural-validator.ts +0 -168
- package/src/validation-config.ts +0 -11
- package/src/validation-result.ts +0 -12
package/src/types/engine.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* I18n Engine type definitions
|
|
3
|
-
*
|
|
4
|
-
* This file provides type-safe interfaces for i18n engine implementations.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Generic I18n Engine interface with type-safe string key constraints
|
|
9
|
-
*
|
|
10
|
-
* This interface defines the core methods that any i18n engine implementation
|
|
11
|
-
* should provide, with proper generic constraints for string keys.
|
|
12
|
-
*
|
|
13
|
-
* @template TStringKeys - Union type of valid string keys for translation
|
|
14
|
-
*/
|
|
15
|
-
export interface II18nEngine<TStringKeys extends string = string> {
|
|
16
|
-
/**
|
|
17
|
-
* Translate a string key with optional variables
|
|
18
|
-
* @param key - The translation key
|
|
19
|
-
* @param params - Optional parameters for interpolation
|
|
20
|
-
* @returns The translated string
|
|
21
|
-
*/
|
|
22
|
-
translate(key: TStringKeys, params?: Record<string, unknown>): string;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Translate an enum value to a string
|
|
26
|
-
* @template T - The enum type
|
|
27
|
-
* @param enumObj - The enum object
|
|
28
|
-
* @param value - The enum value to translate
|
|
29
|
-
* @param language - Optional language override
|
|
30
|
-
* @returns The translated enum value
|
|
31
|
-
*/
|
|
32
|
-
translateEnum<T extends Record<string, string | number>>(
|
|
33
|
-
enumObj: T,
|
|
34
|
-
value: T[keyof T],
|
|
35
|
-
language?: string,
|
|
36
|
-
): string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Set the current language for translations
|
|
40
|
-
* @param language - The language code to set
|
|
41
|
-
*/
|
|
42
|
-
setLanguage(language: string): void;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Get the current language
|
|
46
|
-
* @returns The current language code
|
|
47
|
-
*/
|
|
48
|
-
getLanguage(): string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Re-export the main II18nEngine interface from interfaces
|
|
53
|
-
* This provides a centralized location for engine type imports
|
|
54
|
-
*/
|
|
55
|
-
export type { II18nEngine as IMainI18nEngine } from '../interfaces/i18n-engine.interface';
|
package/src/utils/currency.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Currency utilities (v2)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { codes, data } from 'currency-codes';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Position of the currency symbol relative to the amount.
|
|
9
|
-
*/
|
|
10
|
-
export type CurrencyPosition = 'prefix' | 'postfix' | 'infix';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Configuration for formatting currency values in a specific locale.
|
|
14
|
-
*/
|
|
15
|
-
export interface CurrencyFormat {
|
|
16
|
-
/** The currency symbol (e.g., "$", "€") */
|
|
17
|
-
symbol: string;
|
|
18
|
-
/** Position of the symbol relative to the amount */
|
|
19
|
-
position: CurrencyPosition;
|
|
20
|
-
/** Character used to separate thousands (e.g., ",") */
|
|
21
|
-
groupSeparator: string;
|
|
22
|
-
/** Character used to separate decimal places (e.g., ".") */
|
|
23
|
-
decimalSeparator: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Detailed information about a currency.
|
|
28
|
-
*/
|
|
29
|
-
export interface CurrencyData {
|
|
30
|
-
/** ISO 4217 currency code (e.g., "USD") */
|
|
31
|
-
code: string;
|
|
32
|
-
/** Numeric currency code */
|
|
33
|
-
number: string;
|
|
34
|
-
/** Number of decimal digits */
|
|
35
|
-
digits: number;
|
|
36
|
-
/** Currency name */
|
|
37
|
-
currency: string;
|
|
38
|
-
/** Countries using this currency */
|
|
39
|
-
countries: string[];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Represents a valid ISO 4217 currency code with validation.
|
|
44
|
-
*/
|
|
45
|
-
export class CurrencyCode {
|
|
46
|
-
private _value: string;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Creates a new CurrencyCode instance.
|
|
50
|
-
* @param value - The ISO 4217 currency code (defaults to 'USD')
|
|
51
|
-
* @throws {Error} If the currency code is invalid
|
|
52
|
-
*/
|
|
53
|
-
constructor(value: string = 'USD') {
|
|
54
|
-
if (!CurrencyCode.isValid(value)) {
|
|
55
|
-
throw new Error(`Invalid currency code: ${value}`);
|
|
56
|
-
}
|
|
57
|
-
this._value = value;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Gets the currency code value.
|
|
62
|
-
* @returns The ISO 4217 currency code
|
|
63
|
-
*/
|
|
64
|
-
get value(): string {
|
|
65
|
-
return this._value;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Gets the currency code (alias for value).
|
|
70
|
-
* @returns The ISO 4217 currency code
|
|
71
|
-
*/
|
|
72
|
-
get code(): string {
|
|
73
|
-
return this._value;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Checks if a currency code is valid according to ISO 4217.
|
|
78
|
-
* @param code - The currency code to validate
|
|
79
|
-
* @returns True if the code is valid, false otherwise
|
|
80
|
-
*/
|
|
81
|
-
static isValid(code: string): boolean {
|
|
82
|
-
return codes().includes(code);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Gets all valid ISO 4217 currency codes.
|
|
87
|
-
* @returns Array of currency codes
|
|
88
|
-
*/
|
|
89
|
-
static getAll(): string[] {
|
|
90
|
-
return codes();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Gets detailed information for all currencies.
|
|
95
|
-
* @returns Array of currency data objects
|
|
96
|
-
*/
|
|
97
|
-
static getAllData(): CurrencyData[] {
|
|
98
|
-
return data as CurrencyData[];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Gets the currency formatting rules for a specific locale and currency.
|
|
104
|
-
* @param locale - The locale code (e.g., 'en-US', 'fr-FR')
|
|
105
|
-
* @param currencyCode - The ISO 4217 currency code
|
|
106
|
-
* @returns Currency format configuration including symbol, position, and separators
|
|
107
|
-
*/
|
|
108
|
-
export function getCurrencyFormat(
|
|
109
|
-
locale: string,
|
|
110
|
-
currencyCode: string,
|
|
111
|
-
): CurrencyFormat {
|
|
112
|
-
const formatter = new Intl.NumberFormat(locale, {
|
|
113
|
-
style: 'currency',
|
|
114
|
-
currency: currencyCode,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
const parts = formatter.formatToParts(1234567.89);
|
|
118
|
-
const symbol = parts.find((part) => part.type === 'currency')?.value || '';
|
|
119
|
-
const symbolIndex = parts.findIndex((part) => part.type === 'currency');
|
|
120
|
-
const decimalIndex = parts.findIndex((part) => part.type === 'decimal');
|
|
121
|
-
const integerIndex = parts.findIndex((part) => part.type === 'integer');
|
|
122
|
-
|
|
123
|
-
let position: CurrencyPosition;
|
|
124
|
-
if (decimalIndex === -1) {
|
|
125
|
-
position = symbolIndex < integerIndex ? 'prefix' : 'postfix';
|
|
126
|
-
} else if (symbolIndex < decimalIndex && symbolIndex < integerIndex) {
|
|
127
|
-
position = 'prefix';
|
|
128
|
-
} else if (symbolIndex > decimalIndex) {
|
|
129
|
-
position = 'postfix';
|
|
130
|
-
} else {
|
|
131
|
-
position = 'infix';
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
symbol,
|
|
136
|
-
position,
|
|
137
|
-
groupSeparator: parts.find((part) => part.type === 'group')?.value || ',',
|
|
138
|
-
decimalSeparator:
|
|
139
|
-
parts.find((part) => part.type === 'decimal')?.value || '.',
|
|
140
|
-
};
|
|
141
|
-
}
|
package/src/utils/html-escape.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTML escaping utilities for XSS prevention
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Map of HTML characters to their escaped equivalents.
|
|
7
|
-
*/
|
|
8
|
-
const HTML_ESCAPES: Record<string, string> = {
|
|
9
|
-
'&': '&',
|
|
10
|
-
'<': '<',
|
|
11
|
-
'>': '>',
|
|
12
|
-
'"': '"',
|
|
13
|
-
"'": ''',
|
|
14
|
-
'/': '/',
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Regular expression to match characters that need HTML escaping.
|
|
19
|
-
*/
|
|
20
|
-
const HTML_ESCAPE_REGEX = /[&<>"'/]/g;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Escapes HTML special characters to prevent XSS attacks.
|
|
24
|
-
* @param str - The string to escape
|
|
25
|
-
* @returns The escaped string
|
|
26
|
-
*/
|
|
27
|
-
export function escapeHtml(str: string): string {
|
|
28
|
-
return str.replace(HTML_ESCAPE_REGEX, char => HTML_ESCAPES[char]);
|
|
29
|
-
}
|
|
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
|
-
export function safeStringify(value: any, options?: { escapeHtml?: boolean }): string {
|
|
41
|
-
if (value === null || value === undefined) {
|
|
42
|
-
return '';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (typeof value === 'string') {
|
|
46
|
-
return options?.escapeHtml ? escapeHtml(value) : value;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
50
|
-
return String(value);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Reject objects to prevent toString exploits
|
|
54
|
-
throw new Error('Invalid value type for stringification');
|
|
55
|
-
}
|
package/src/utils/lru-cache.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple LRU Cache implementation for security
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Least Recently Used (LRU) cache implementation.
|
|
7
|
-
* Automatically evicts the oldest entries when the cache reaches maximum size.
|
|
8
|
-
* @template K - The type of cache keys
|
|
9
|
-
* @template V - The type of cached values
|
|
10
|
-
*/
|
|
11
|
-
export class LRUCache<K, V> {
|
|
12
|
-
private cache = new Map<K, V>();
|
|
13
|
-
private readonly maxSize: number;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new LRUCache instance.
|
|
17
|
-
* @param maxSize - Maximum number of entries to store (default: 1000)
|
|
18
|
-
*/
|
|
19
|
-
constructor(maxSize: number = 1000) {
|
|
20
|
-
this.maxSize = maxSize;
|
|
21
|
-
}
|
|
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: K): V | undefined {
|
|
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
|
-
/**
|
|
40
|
-
* Adds or updates a value in the cache.
|
|
41
|
-
* If the cache is at capacity, the oldest entry is removed.
|
|
42
|
-
* @param key - The key to store
|
|
43
|
-
* @param value - The value to cache
|
|
44
|
-
*/
|
|
45
|
-
set(key: K, value: V): void {
|
|
46
|
-
// Remove if exists to update position
|
|
47
|
-
if (this.cache.has(key)) {
|
|
48
|
-
this.cache.delete(key);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Remove oldest if at capacity
|
|
52
|
-
if (this.cache.size >= this.maxSize) {
|
|
53
|
-
const firstKey = this.cache.keys().next().value;
|
|
54
|
-
if (firstKey !== undefined) {
|
|
55
|
-
this.cache.delete(firstKey);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
this.cache.set(key, value);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Removes all entries from the cache.
|
|
64
|
-
*/
|
|
65
|
-
clear(): void {
|
|
66
|
-
this.cache.clear();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Gets the current number of entries in the cache.
|
|
71
|
-
* @returns The number of cached entries
|
|
72
|
-
*/
|
|
73
|
-
size(): number {
|
|
74
|
-
return this.cache.size;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* String utility functions
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { escapeHtml, safeStringify } from './html-escape';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Extract the actual value from an object that might be a wrapper (CurrencyCode, Timezone, etc.).
|
|
9
|
-
* @param value - The value to extract from
|
|
10
|
-
* @returns The extracted value or the original value if not a wrapper
|
|
11
|
-
*/
|
|
12
|
-
function extractValue(value: any): any {
|
|
13
|
-
// Handle objects with a 'value' property (CurrencyCode, Timezone, etc.)
|
|
14
|
-
if (value && typeof value === 'object' && 'value' in value && typeof value.value !== 'function') {
|
|
15
|
-
return value.value;
|
|
16
|
-
}
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Options for the replaceVariables function.
|
|
22
|
-
*/
|
|
23
|
-
export interface ReplaceVariablesOptions {
|
|
24
|
-
/** If true, HTML-escapes the replaced values */
|
|
25
|
-
escapeHtml?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Replaces variables in a string template with values from vars or constants.
|
|
30
|
-
* Variables are denoted by {variableName} in the template string.
|
|
31
|
-
* @param str - The template string containing variables
|
|
32
|
-
* @param vars - Optional object mapping variable names to values
|
|
33
|
-
* @param constants - Optional object containing constant values
|
|
34
|
-
* @param options - Optional configuration including HTML escaping
|
|
35
|
-
* @returns The string with variables replaced
|
|
36
|
-
*/
|
|
37
|
-
export function replaceVariables(
|
|
38
|
-
str: string,
|
|
39
|
-
vars?: Record<string, any>,
|
|
40
|
-
constants?: Record<string, any>,
|
|
41
|
-
options?: ReplaceVariablesOptions,
|
|
42
|
-
): string {
|
|
43
|
-
if (typeof str !== 'string') {
|
|
44
|
-
str = String(str);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const variables = str.match(/\{(.+?)\}/g);
|
|
48
|
-
if (!variables) return str;
|
|
49
|
-
|
|
50
|
-
let result = str;
|
|
51
|
-
for (const variable of variables) {
|
|
52
|
-
const varName = variable.slice(1, -1);
|
|
53
|
-
let replacement = '';
|
|
54
|
-
|
|
55
|
-
if (vars && varName in vars) {
|
|
56
|
-
const value = extractValue(vars[varName]);
|
|
57
|
-
replacement = safeStringify(value, options);
|
|
58
|
-
result = result.replace(variable, replacement);
|
|
59
|
-
} else if (constants && varName in constants) {
|
|
60
|
-
const value = extractValue(constants[varName]);
|
|
61
|
-
replacement = safeStringify(value, options);
|
|
62
|
-
result = result.replace(variable, replacement);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Checks if a string key indicates a template that expects variable replacement.
|
|
71
|
-
* Template keys end with 'template' (case-insensitive).
|
|
72
|
-
* @param key - The key to check
|
|
73
|
-
* @returns True if the key indicates a template, false otherwise
|
|
74
|
-
*/
|
|
75
|
-
export function isTemplate(key: string): boolean {
|
|
76
|
-
return key.trim().toLowerCase().endsWith('template');
|
|
77
|
-
}
|
package/src/utils/timezone.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Timezone utilities (v2)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import moment from 'moment-timezone';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Represents a valid timezone with validation.
|
|
9
|
-
* Uses moment-timezone for validation and timezone database.
|
|
10
|
-
*/
|
|
11
|
-
export class Timezone {
|
|
12
|
-
private readonly _value: string;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Creates a new Timezone instance.
|
|
16
|
-
* @param timezone - The timezone name (e.g., 'America/New_York', 'UTC')
|
|
17
|
-
* @throws {Error} If the timezone is invalid
|
|
18
|
-
*/
|
|
19
|
-
constructor(timezone: string) {
|
|
20
|
-
if (!Timezone.isValid(timezone)) {
|
|
21
|
-
throw new Error(`Invalid timezone: ${timezone}`);
|
|
22
|
-
}
|
|
23
|
-
this._value = timezone;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Gets the timezone name.
|
|
28
|
-
* @returns The timezone name
|
|
29
|
-
*/
|
|
30
|
-
get value(): string {
|
|
31
|
-
return this._value;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Gets the timezone name (alias for value).
|
|
36
|
-
* @returns The timezone name
|
|
37
|
-
*/
|
|
38
|
-
get name(): string {
|
|
39
|
-
return this._value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Checks if a timezone name is valid.
|
|
44
|
-
* @param timezone - The timezone name to validate
|
|
45
|
-
* @returns True if the timezone is valid, false otherwise
|
|
46
|
-
*/
|
|
47
|
-
static isValid(timezone: string): boolean {
|
|
48
|
-
return moment.tz.zone(timezone) !== null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Gets all available timezone names.
|
|
53
|
-
* @returns Array of timezone names
|
|
54
|
-
*/
|
|
55
|
-
static getAll(): string[] {
|
|
56
|
-
return moment.tz.names();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Attempts to guess the user's timezone based on their system settings.
|
|
61
|
-
* @returns The guessed timezone name
|
|
62
|
-
*/
|
|
63
|
-
static guess(): string {
|
|
64
|
-
return moment.tz.guess();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Checks if a timezone name is valid.
|
|
70
|
-
* This is a convenience function that delegates to Timezone.isValid().
|
|
71
|
-
* @param timezone - The timezone name to validate
|
|
72
|
-
* @returns True if the timezone is valid, false otherwise
|
|
73
|
-
*/
|
|
74
|
-
export function isValidTimezone(timezone: string): boolean {
|
|
75
|
-
return Timezone.isValid(timezone);
|
|
76
|
-
}
|
package/src/utils/validation.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Input validation utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Security limits for various input types to prevent abuse.
|
|
7
|
-
*/
|
|
8
|
-
export const LIMITS = {
|
|
9
|
-
MAX_TEMPLATE_LENGTH: 10000,
|
|
10
|
-
MAX_KEY_LENGTH: 200,
|
|
11
|
-
MAX_COMPONENT_ID_LENGTH: 100,
|
|
12
|
-
MAX_LANGUAGE_CODE_LENGTH: 10,
|
|
13
|
-
MAX_NESTING_DEPTH: 10,
|
|
14
|
-
} as const;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Validates that a template string does not exceed the maximum allowed length.
|
|
18
|
-
* @param template - The template string to validate
|
|
19
|
-
* @throws {Error} If the template exceeds the maximum length
|
|
20
|
-
*/
|
|
21
|
-
export function validateTemplateLength(template: string): void {
|
|
22
|
-
if (template.length > LIMITS.MAX_TEMPLATE_LENGTH) {
|
|
23
|
-
throw new Error(`Template exceeds maximum length of ${LIMITS.MAX_TEMPLATE_LENGTH}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Validates that a key does not exceed the maximum allowed length.
|
|
29
|
-
* @param key - The key to validate
|
|
30
|
-
* @throws {Error} If the key exceeds the maximum length
|
|
31
|
-
*/
|
|
32
|
-
export function validateKeyLength(key: string): void {
|
|
33
|
-
if (key.length > LIMITS.MAX_KEY_LENGTH) {
|
|
34
|
-
throw new Error(`Key exceeds maximum length of ${LIMITS.MAX_KEY_LENGTH}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Validates that a component ID meets length and character requirements.
|
|
40
|
-
* Component IDs must contain only alphanumeric characters, underscores, and hyphens.
|
|
41
|
-
* @param componentId - The component ID to validate
|
|
42
|
-
* @throws {Error} If the component ID is invalid
|
|
43
|
-
*/
|
|
44
|
-
export function validateComponentId(componentId: string): void {
|
|
45
|
-
if (componentId.length > LIMITS.MAX_COMPONENT_ID_LENGTH) {
|
|
46
|
-
throw new Error(`Component ID exceeds maximum length of ${LIMITS.MAX_COMPONENT_ID_LENGTH}`);
|
|
47
|
-
}
|
|
48
|
-
if (!/^[a-zA-Z0-9_-]+$/.test(componentId)) {
|
|
49
|
-
throw new Error('Component ID contains invalid characters');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Validates that a language code meets BCP 47 format requirements.
|
|
55
|
-
* Expected format: two lowercase letters, optionally followed by a hyphen and two uppercase letters (e.g., 'en', 'en-US').
|
|
56
|
-
* @param language - The language code to validate
|
|
57
|
-
* @throws {Error} If the language code is invalid
|
|
58
|
-
*/
|
|
59
|
-
export function validateLanguageCode(language: string): void {
|
|
60
|
-
if (language.length > LIMITS.MAX_LANGUAGE_CODE_LENGTH) {
|
|
61
|
-
throw new Error(`Language code exceeds maximum length of ${LIMITS.MAX_LANGUAGE_CODE_LENGTH}`);
|
|
62
|
-
}
|
|
63
|
-
if (!/^[a-z]{2}(-[A-Z]{2})?$/.test(language)) {
|
|
64
|
-
throw new Error('Invalid language code format');
|
|
65
|
-
}
|
|
66
|
-
}
|