@digitaldefiance/i18n-lib 3.8.0 → 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 +182 -0
- package/package.json +12 -4
- package/src/{active-context.d.ts → active-context.ts} +0 -1
- 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.d.ts → index.ts} +4 -1
- package/src/core/language-registry.ts +345 -0
- package/src/{core-component-id.d.ts → core-component-id.ts} +1 -2
- 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.d.ts → base.ts} +1 -1
- 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.d.ts → index.ts} +4 -1
- package/src/errors/simple-typed-error.ts +81 -0
- package/src/errors/{translatable-exports.d.ts → translatable-exports.ts} +1 -1
- 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} +38 -6
- 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.d.ts → index.ts} +1 -1
- 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.d.ts → types.ts} +72 -21
- 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.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 -22
- 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.map +0 -1
- package/src/core/index.js +0 -21
- 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 -298
- package/src/core/language-registry.js.map +0 -1
- package/src/core-component-id.d.ts.map +0 -1
- package/src/core-component-id.js +0 -9
- package/src/core-component-id.js.map +0 -1
- package/src/core-i18n.d.ts +0 -69
- package/src/core-i18n.d.ts.map +0 -1
- package/src/core-i18n.js +0 -219
- package/src/core-i18n.js.map +0 -1
- package/src/core-plugin-factory.d.ts +0 -28
- package/src/core-plugin-factory.d.ts.map +0 -1
- package/src/core-plugin-factory.js +0 -80
- package/src/core-plugin-factory.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/base.d.ts.map +0 -1
- package/src/errors/base.js +0 -11
- package/src/errors/base.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 -93
- 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-exports.d.ts.map +0 -1
- package/src/errors/translatable-exports.js +0 -15
- package/src/errors/translatable-exports.js.map +0 -1
- package/src/errors/translatable-generic.d.ts +0 -87
- package/src/errors/translatable-generic.d.ts.map +0 -1
- package/src/errors/translatable-generic.js +0 -139
- 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 -63
- package/src/errors/translatable.d.ts.map +0 -1
- package/src/errors/translatable.js +0 -85
- 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 -108
- 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 -458
- 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/active-context.interface.d.ts +0 -36
- package/src/interfaces/active-context.interface.d.ts.map +0 -1
- package/src/interfaces/active-context.interface.js +0 -3
- package/src/interfaces/active-context.interface.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.map +0 -1
- package/src/interfaces/index.js +0 -7
- 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 -493
- 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 -25
- package/src/registry-error.d.ts.map +0 -1
- package/src/registry-error.js +0 -63
- 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.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 -99
- 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
package/src/errors/typed.js
DELETED
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CoreTypedError = exports.ComponentTypedError = exports.PluginTypedError = exports.AbstractTypedError = exports.BaseTypedError = void 0;
|
|
4
|
-
exports.createPluginTypedError = createPluginTypedError;
|
|
5
|
-
exports.createComponentTypedError = createComponentTypedError;
|
|
6
|
-
exports.createCoreTypedError = createCoreTypedError;
|
|
7
|
-
exports.createTranslatedError = createTranslatedError;
|
|
8
|
-
// New plugin architecture imports
|
|
9
|
-
// CoreLanguageCode is deprecated - using string for flexibility
|
|
10
|
-
const core_component_id_1 = require("../core-component-id");
|
|
11
|
-
const core_string_key_1 = require("../core-string-key");
|
|
12
|
-
const i18n_engine_1 = require("../core/i18n-engine");
|
|
13
|
-
const simple_typed_error_1 = require("./simple-typed-error");
|
|
14
|
-
/**
|
|
15
|
-
* Base typed error class with full i18n feature support.
|
|
16
|
-
*
|
|
17
|
-
* **Supported i18n Features** (via translation strings):
|
|
18
|
-
* - ICU MessageFormat: plural, select, selectordinal
|
|
19
|
-
* - Pluralization: 37 languages with CLDR rules
|
|
20
|
-
* - Gender support: male, female, neutral, other
|
|
21
|
-
* - Number formatting: integer, currency, percent
|
|
22
|
-
* - Date/Time formatting: short, medium, long, full
|
|
23
|
-
* - Nested messages: up to 4 levels deep
|
|
24
|
-
*
|
|
25
|
-
* **Translation String Examples:**
|
|
26
|
-
* ```typescript
|
|
27
|
-
* // Register translations with ICU features
|
|
28
|
-
* engine.registerComponent({
|
|
29
|
-
* component: { id: 'errors', name: 'Errors', stringKeys: ['invalidCount'] },
|
|
30
|
-
* strings: {
|
|
31
|
-
* 'en-US': {
|
|
32
|
-
* invalidCount: "{count, plural, one {# item is invalid} other {# items are invalid}}"
|
|
33
|
-
* }
|
|
34
|
-
* }
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* // Use with typed error
|
|
38
|
-
* throw BaseTypedError.createTranslated(
|
|
39
|
-
* engine, 'errors', ErrorType.InvalidCount, reasonMap,
|
|
40
|
-
* { count: 5 }, 'en-US'
|
|
41
|
-
* );
|
|
42
|
-
* // Result: "5 items are invalid"
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
class BaseTypedError extends Error {
|
|
46
|
-
type;
|
|
47
|
-
metadata;
|
|
48
|
-
constructor(type, message, metadata) {
|
|
49
|
-
super(message);
|
|
50
|
-
this.type = type;
|
|
51
|
-
this.metadata = metadata;
|
|
52
|
-
this.name = this.constructor.name;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Create a simple typed error without engine dependency
|
|
56
|
-
*/
|
|
57
|
-
static createSimple(type, message, metadata) {
|
|
58
|
-
return new this(type, message, metadata);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Create a typed error with translation support
|
|
62
|
-
*/
|
|
63
|
-
static createTranslated(engine, componentId, type, reasonMap, variables, language, metadata) {
|
|
64
|
-
const key = reasonMap[type];
|
|
65
|
-
let message;
|
|
66
|
-
if (key && engine) {
|
|
67
|
-
// Try to translate the error message using the engine
|
|
68
|
-
message = engine.safeTranslate(componentId, key, variables, language);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// Fallback to a basic English message
|
|
72
|
-
message = `Error: ${type}${metadata ? ` - ${JSON.stringify(metadata)}` : ''}`;
|
|
73
|
-
}
|
|
74
|
-
return new this(type, message, metadata);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.BaseTypedError = BaseTypedError;
|
|
78
|
-
/**
|
|
79
|
-
* AbstractTypedError with complete enum coverage and full i18n feature support.
|
|
80
|
-
* @deprecated Use SimpleTypedError from './simple-typed-error' for new code
|
|
81
|
-
*
|
|
82
|
-
* **Supported i18n Features** (via translation strings):
|
|
83
|
-
* - ICU MessageFormat: plural, select, selectordinal
|
|
84
|
-
* - Pluralization: 37 languages with CLDR rules
|
|
85
|
-
* - Gender support: male, female, neutral, other
|
|
86
|
-
* - Number formatting: integer, currency, percent
|
|
87
|
-
* - Nested messages: up to 4 levels deep
|
|
88
|
-
*
|
|
89
|
-
* **Translation String Examples:**
|
|
90
|
-
* ```typescript
|
|
91
|
-
* // Define error types
|
|
92
|
-
* enum ValidationError {
|
|
93
|
-
* InvalidCount = 'invalidCount',
|
|
94
|
-
* ThresholdExceeded = 'thresholdExceeded'
|
|
95
|
-
* }
|
|
96
|
-
*
|
|
97
|
-
* // Register translations with ICU
|
|
98
|
-
* engine.registerComponent({
|
|
99
|
-
* component: { id: 'validation', stringKeys: ['invalidCount', 'thresholdExceeded'] },
|
|
100
|
-
* strings: {
|
|
101
|
-
* 'en-US': {
|
|
102
|
-
* invalidCount: "{count, plural, one {# error found} other {# errors found}}",
|
|
103
|
-
* thresholdExceeded: "Value {value, number, integer} exceeds limit"
|
|
104
|
-
* }
|
|
105
|
-
* }
|
|
106
|
-
* });
|
|
107
|
-
*
|
|
108
|
-
* // Use typed error
|
|
109
|
-
* throw new MyTypedError('validation', ValidationError.InvalidCount, reasonMap, 'en-US', { count: 3 });
|
|
110
|
-
* // Result: "3 errors found"
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
class AbstractTypedError extends Error {
|
|
114
|
-
componentId;
|
|
115
|
-
type;
|
|
116
|
-
reasonMap;
|
|
117
|
-
language;
|
|
118
|
-
otherVars;
|
|
119
|
-
constructor(componentId, type, reasonMap, language, otherVars) {
|
|
120
|
-
const key = reasonMap[type];
|
|
121
|
-
// Lazy initialization: getInstance() is only called when error is constructed
|
|
122
|
-
const engine = i18n_engine_1.I18nEngine.getInstance('default');
|
|
123
|
-
if (!key) {
|
|
124
|
-
throw new Error(engine.safeTranslate(core_component_id_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_MissingTranslationKeyTemplate, { type }, language));
|
|
125
|
-
}
|
|
126
|
-
// Use translate instead of safeTranslate to get actual translations
|
|
127
|
-
let message;
|
|
128
|
-
try {
|
|
129
|
-
message = engine.translate(componentId, key, otherVars, language);
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
// Fallback to safeTranslate if translate fails
|
|
133
|
-
message = engine.safeTranslate(componentId, key, otherVars, language);
|
|
134
|
-
}
|
|
135
|
-
super(message);
|
|
136
|
-
this.componentId = componentId;
|
|
137
|
-
this.type = type;
|
|
138
|
-
this.reasonMap = reasonMap;
|
|
139
|
-
this.language = language;
|
|
140
|
-
this.otherVars = otherVars;
|
|
141
|
-
this.name = this.constructor.name;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
exports.AbstractTypedError = AbstractTypedError;
|
|
145
|
-
/**
|
|
146
|
-
* Component-based TypedError that works with the component registration system
|
|
147
|
-
* @deprecated Use TypedError instead - PluginTypedError is an alias for backward compatibility
|
|
148
|
-
*/
|
|
149
|
-
class PluginTypedError extends Error {
|
|
150
|
-
componentId;
|
|
151
|
-
type;
|
|
152
|
-
reasonMap;
|
|
153
|
-
language;
|
|
154
|
-
otherVars;
|
|
155
|
-
constructor(componentId, type, reasonMap, language, otherVars) {
|
|
156
|
-
const key = reasonMap[type];
|
|
157
|
-
// Lazy initialization: getInstance() is only called when error is constructed
|
|
158
|
-
const engine = i18n_engine_1.I18nEngine.getInstance('default');
|
|
159
|
-
// If key is not found in the reason map, use core error message
|
|
160
|
-
if (!key) {
|
|
161
|
-
const errorMsg = engine.safeTranslate(core_component_id_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_StringKeyNotFoundTemplate, {
|
|
162
|
-
stringKey: String(type),
|
|
163
|
-
componentId: componentId,
|
|
164
|
-
}, language);
|
|
165
|
-
throw new Error(errorMsg);
|
|
166
|
-
}
|
|
167
|
-
// Translate the error message using the component and string key
|
|
168
|
-
const translatedMessage = engine.safeTranslate(componentId, key, otherVars, language);
|
|
169
|
-
super(translatedMessage);
|
|
170
|
-
this.componentId = componentId;
|
|
171
|
-
this.type = type;
|
|
172
|
-
this.reasonMap = reasonMap;
|
|
173
|
-
this.language = language;
|
|
174
|
-
this.otherVars = otherVars;
|
|
175
|
-
this.name = this.constructor.name;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
exports.PluginTypedError = PluginTypedError;
|
|
179
|
-
/**
|
|
180
|
-
* Component-based TypedError with full i18n feature support.
|
|
181
|
-
*
|
|
182
|
-
* **Supported i18n Features** (via translation strings):
|
|
183
|
-
* - ICU MessageFormat: plural, select, selectordinal
|
|
184
|
-
* - Pluralization: 37 languages with CLDR rules
|
|
185
|
-
* - Gender support: male, female, neutral, other
|
|
186
|
-
* - Number formatting: integer, currency, percent
|
|
187
|
-
* - SelectOrdinal: 1st, 2nd, 3rd formatting
|
|
188
|
-
* - Nested messages: complex multi-level patterns
|
|
189
|
-
*
|
|
190
|
-
* **Translation String Examples:**
|
|
191
|
-
* ```typescript
|
|
192
|
-
* // Define component errors
|
|
193
|
-
* enum UserError {
|
|
194
|
-
* AccountLocked = 'accountLocked',
|
|
195
|
-
* TooManyAttempts = 'tooManyAttempts'
|
|
196
|
-
* }
|
|
197
|
-
*
|
|
198
|
-
* // Register with ICU features
|
|
199
|
-
* engine.registerComponent({
|
|
200
|
-
* component: { id: 'user', stringKeys: ['accountLocked', 'tooManyAttempts'] },
|
|
201
|
-
* strings: {
|
|
202
|
-
* 'en-US': {
|
|
203
|
-
* accountLocked: "{gender, select, male {His account} female {Her account} other {Their account}} is locked",
|
|
204
|
-
* tooManyAttempts: "{count, plural, one {# attempt} other {# attempts}} failed. Try again in {minutes, number, integer} minutes."
|
|
205
|
-
* }
|
|
206
|
-
* }
|
|
207
|
-
* });
|
|
208
|
-
*
|
|
209
|
-
* // Use component error
|
|
210
|
-
* throw new MyComponentError('user', UserError.TooManyAttempts, reasonMap, 'en-US', { count: 5, minutes: 10 });
|
|
211
|
-
* // Result: "5 attempts failed. Try again in 10 minutes."
|
|
212
|
-
* ```
|
|
213
|
-
*/
|
|
214
|
-
class ComponentTypedError extends Error {
|
|
215
|
-
componentId;
|
|
216
|
-
type;
|
|
217
|
-
reasonMap;
|
|
218
|
-
language;
|
|
219
|
-
otherVars;
|
|
220
|
-
constructor(componentId, type, reasonMap, language, otherVars) {
|
|
221
|
-
const key = reasonMap[type];
|
|
222
|
-
// Lazy initialization: getInstance() is only called when error is constructed
|
|
223
|
-
const engine = i18n_engine_1.I18nEngine.getInstance('default');
|
|
224
|
-
// If key is not found in the reason map, use core error message
|
|
225
|
-
if (!key) {
|
|
226
|
-
const errorMsg = engine.safeTranslate(core_component_id_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_StringKeyNotFoundTemplate, {
|
|
227
|
-
stringKey: String(type),
|
|
228
|
-
componentId: componentId,
|
|
229
|
-
}, language);
|
|
230
|
-
throw new Error(errorMsg);
|
|
231
|
-
}
|
|
232
|
-
// Translate the error message using the component and string key
|
|
233
|
-
const translatedMessage = engine.safeTranslate(componentId, key, otherVars, language);
|
|
234
|
-
super(translatedMessage);
|
|
235
|
-
this.componentId = componentId;
|
|
236
|
-
this.type = type;
|
|
237
|
-
this.reasonMap = reasonMap;
|
|
238
|
-
this.language = language;
|
|
239
|
-
this.otherVars = otherVars;
|
|
240
|
-
this.name = this.constructor.name;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
exports.ComponentTypedError = ComponentTypedError;
|
|
244
|
-
/**
|
|
245
|
-
* Core system TypedError using core component strings with full i18n support.
|
|
246
|
-
*
|
|
247
|
-
* **Supported i18n Features** (via CoreStringKey translations):
|
|
248
|
-
* - ICU MessageFormat: plural, select, selectordinal
|
|
249
|
-
* - Pluralization: 37 languages with CLDR rules
|
|
250
|
-
* - Gender support: male, female, neutral, other
|
|
251
|
-
* - Number formatting: integer, currency, percent
|
|
252
|
-
* - Nested messages: complex patterns
|
|
253
|
-
*
|
|
254
|
-
* **Usage Example:**
|
|
255
|
-
* ```typescript
|
|
256
|
-
* // Define core error types
|
|
257
|
-
* enum CoreErrorType {
|
|
258
|
-
* InvalidOperation = 'invalidOperation',
|
|
259
|
-
* ResourceNotFound = 'resourceNotFound'
|
|
260
|
-
* }
|
|
261
|
-
*
|
|
262
|
-
* // Core strings already registered with ICU features
|
|
263
|
-
* const reasonMap: CompleteReasonMap<typeof CoreErrorType, CoreStringKey> = {
|
|
264
|
-
* [CoreErrorType.InvalidOperation]: CoreStringKey.Error_InvalidOperation,
|
|
265
|
-
* [CoreErrorType.ResourceNotFound]: CoreStringKey.Error_ResourceNotFound
|
|
266
|
-
* };
|
|
267
|
-
*
|
|
268
|
-
* // Use core typed error
|
|
269
|
-
* throw new MyCoreError(CoreErrorType.ResourceNotFound, reasonMap, 'en-US', { resource: 'user', id: 123 });
|
|
270
|
-
* ```
|
|
271
|
-
*/
|
|
272
|
-
class CoreTypedError extends Error {
|
|
273
|
-
type;
|
|
274
|
-
reasonMap;
|
|
275
|
-
language;
|
|
276
|
-
otherVars;
|
|
277
|
-
constructor(type, reasonMap, language, otherVars) {
|
|
278
|
-
const key = reasonMap[type];
|
|
279
|
-
// Lazy initialization: getInstance() is only called when error is constructed
|
|
280
|
-
const engine = i18n_engine_1.I18nEngine.getInstance('default');
|
|
281
|
-
// If key is not found in the reason map, use a fallback error
|
|
282
|
-
if (!key) {
|
|
283
|
-
const errorMsg = engine.safeTranslate(core_component_id_1.CoreI18nComponentId, core_string_key_1.CoreStringKey.Error_StringKeyNotFoundTemplate, {
|
|
284
|
-
stringKey: String(type),
|
|
285
|
-
componentId: core_component_id_1.CoreI18nComponentId,
|
|
286
|
-
}, language);
|
|
287
|
-
throw new Error(errorMsg);
|
|
288
|
-
}
|
|
289
|
-
// Translate the error message using the core component
|
|
290
|
-
const translatedMessage = engine.safeTranslate(core_component_id_1.CoreI18nComponentId, key, otherVars, language);
|
|
291
|
-
super(translatedMessage);
|
|
292
|
-
this.type = type;
|
|
293
|
-
this.reasonMap = reasonMap;
|
|
294
|
-
this.language = language;
|
|
295
|
-
this.otherVars = otherVars;
|
|
296
|
-
this.name = this.constructor.name;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
exports.CoreTypedError = CoreTypedError;
|
|
300
|
-
/**
|
|
301
|
-
* Helper function to create a component-based TypedError with automatic engine detection
|
|
302
|
-
* @deprecated Use createComponentTypedError instead
|
|
303
|
-
*/
|
|
304
|
-
function createPluginTypedError(componentId, type, reasonMap, otherVars, language, instanceKey) {
|
|
305
|
-
return createComponentTypedError(componentId, type, reasonMap, otherVars, language, instanceKey);
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Helper function to create a component-based TypedError with automatic engine detection
|
|
309
|
-
*/
|
|
310
|
-
function createComponentTypedError(componentId, type, reasonMap, otherVars, language, instanceKey) {
|
|
311
|
-
const key = reasonMap[type];
|
|
312
|
-
if (!key) {
|
|
313
|
-
throw new Error(`Missing key for type ${type} in reason map`);
|
|
314
|
-
}
|
|
315
|
-
// Lazy initialization: getInstance() is only called when function is executed
|
|
316
|
-
const engine = i18n_engine_1.I18nEngine.getInstance(instanceKey || 'default');
|
|
317
|
-
const message = engine.safeTranslate(componentId, key, otherVars, language);
|
|
318
|
-
const error = new simple_typed_error_1.TypedError(message, {
|
|
319
|
-
type,
|
|
320
|
-
componentId,
|
|
321
|
-
reasonMap,
|
|
322
|
-
});
|
|
323
|
-
error.name = 'PluginTypedError';
|
|
324
|
-
return error;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Helper function to create a core system TypedError with automatic engine detection
|
|
328
|
-
*/
|
|
329
|
-
function createCoreTypedError(type, reasonMap, otherVars, language, instanceKey) {
|
|
330
|
-
const key = reasonMap[type];
|
|
331
|
-
if (!key) {
|
|
332
|
-
throw new Error(`Missing key for type ${type} in reason map`);
|
|
333
|
-
}
|
|
334
|
-
// Lazy initialization: getInstance() is only called when function is executed
|
|
335
|
-
const engine = i18n_engine_1.I18nEngine.getInstance(instanceKey || 'default');
|
|
336
|
-
const message = engine.safeTranslate(core_component_id_1.CoreI18nComponentId, key, otherVars, language);
|
|
337
|
-
const error = new simple_typed_error_1.TypedError(message, {
|
|
338
|
-
type,
|
|
339
|
-
componentId: core_component_id_1.CoreI18nComponentId,
|
|
340
|
-
reasonMap,
|
|
341
|
-
});
|
|
342
|
-
error.name = 'CoreTypedError';
|
|
343
|
-
return error;
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Create a simple error with translation support (generalized pattern from RegistryError)
|
|
347
|
-
*/
|
|
348
|
-
function createTranslatedError(engine, componentId, type, reasonMap, variables, language, metadata, errorName) {
|
|
349
|
-
const key = reasonMap[type];
|
|
350
|
-
let message;
|
|
351
|
-
if (key && engine) {
|
|
352
|
-
try {
|
|
353
|
-
// Try to translate the error message using the engine
|
|
354
|
-
message = engine.safeTranslate(componentId, key, variables, language);
|
|
355
|
-
}
|
|
356
|
-
catch (translationError) {
|
|
357
|
-
// Fallback if translation fails
|
|
358
|
-
message = `Error: ${type}${metadata ? ` - ${JSON.stringify(metadata)}` : ''}`;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
// Fallback to a basic English message
|
|
363
|
-
message = `Error: ${type}${metadata ? ` - ${JSON.stringify(metadata)}` : ''}`;
|
|
364
|
-
}
|
|
365
|
-
const error = new simple_typed_error_1.TypedError(message, {
|
|
366
|
-
type,
|
|
367
|
-
componentId,
|
|
368
|
-
metadata,
|
|
369
|
-
});
|
|
370
|
-
error.name = errorName || 'TranslatedError';
|
|
371
|
-
return error;
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Example usage of the new plugin-based TypedError system
|
|
375
|
-
*/
|
|
376
|
-
// Example 1: Core system error using CoreStringKey
|
|
377
|
-
/*
|
|
378
|
-
enum DatabaseErrorType {
|
|
379
|
-
ConnectionFailed = 'connectionFailed',
|
|
380
|
-
QueryTimeout = 'queryTimeout',
|
|
381
|
-
AccessDenied = 'accessDenied'
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
const coreErrorReasonMap: CompleteReasonMap<typeof DatabaseErrorType, CoreStringKey> = {
|
|
385
|
-
[DatabaseErrorType.ConnectionFailed]: CoreStringKey.Error_NetworkError,
|
|
386
|
-
[DatabaseErrorType.QueryTimeout]: CoreStringKey.Error_InternalServer,
|
|
387
|
-
[DatabaseErrorType.AccessDenied]: CoreStringKey.Error_AccessDenied
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
class DatabaseError extends CoreTypedError<typeof DatabaseErrorType> {
|
|
391
|
-
constructor(
|
|
392
|
-
type: DatabaseErrorType,
|
|
393
|
-
otherVars?: Record<string, string | number>,
|
|
394
|
-
language?: string
|
|
395
|
-
) {
|
|
396
|
-
super(type, coreErrorReasonMap, language, otherVars);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
// Usage:
|
|
401
|
-
// throw new DatabaseError(DatabaseErrorType.ConnectionFailed);
|
|
402
|
-
*/
|
|
403
|
-
// Example 2: Custom component error with custom strings
|
|
404
|
-
/*
|
|
405
|
-
enum UserErrorType {
|
|
406
|
-
UserNotFound = 'userNotFound',
|
|
407
|
-
InvalidCredentials = 'invalidCredentials',
|
|
408
|
-
AccountLocked = 'accountLocked'
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
enum UserErrorStringKey {
|
|
412
|
-
UserNotFoundMessage = 'userNotFoundMessage',
|
|
413
|
-
InvalidCredentialsMessage = 'invalidCredentialsMessage',
|
|
414
|
-
AccountLockedMessage = 'accountLockedMessage'
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
const userErrorReasonMap: CompleteReasonMap<typeof UserErrorType, UserErrorStringKey> = {
|
|
418
|
-
[UserErrorType.UserNotFound]: UserErrorStringKey.UserNotFoundMessage,
|
|
419
|
-
[UserErrorType.InvalidCredentials]: UserErrorStringKey.InvalidCredentialsMessage,
|
|
420
|
-
[UserErrorType.AccountLocked]: UserErrorStringKey.AccountLockedMessage
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
class UserError extends PluginTypedError<typeof UserErrorType, UserErrorStringKey> {
|
|
424
|
-
constructor(
|
|
425
|
-
type: UserErrorType,
|
|
426
|
-
otherVars?: Record<string, string | number>,
|
|
427
|
-
language?: string
|
|
428
|
-
) {
|
|
429
|
-
super('user-system', type, userErrorReasonMap, language, otherVars);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// Usage:
|
|
434
|
-
// throw new UserError(UserErrorType.UserNotFound, { username: 'john_doe' });
|
|
435
|
-
*/
|
|
436
|
-
// Example 3: Using helper functions for simpler error creation
|
|
437
|
-
/*
|
|
438
|
-
// Define your error types and mappings
|
|
439
|
-
enum ApiErrorType {
|
|
440
|
-
Timeout = 'timeout',
|
|
441
|
-
NotFound = 'notFound'
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
const apiErrorMap: CompleteReasonMap<typeof ApiErrorType, CoreStringKey> = {
|
|
445
|
-
[ApiErrorType.Timeout]: CoreStringKey.Error_NetworkError,
|
|
446
|
-
[ApiErrorType.NotFound]: CoreStringKey.Error_NotFound
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
// Create errors using helper functions
|
|
450
|
-
function throwApiError(type: ApiErrorType, vars?: Record<string, string | number>) {
|
|
451
|
-
throw createCoreTypedError(type, apiErrorMap, vars);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// Usage:
|
|
455
|
-
// throwApiError(ApiErrorType.NotFound, { resource: 'user' });
|
|
456
|
-
*/
|
|
457
|
-
// Export the type for external use (already exported above)
|
|
458
|
-
//# sourceMappingURL=typed.js.map
|
package/src/errors/typed.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typed.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/typ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AC,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACxE,CAAC;QAAC,OAAO,gBAAgB,EAAE,CAAC;YAC1B,gCAAgC;YAChC,OAAO,GAAG,UAAU,IAAI,GACtB,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAChD,EAAE,CAAC;QACL,CAAC;IACH,CAAC;SAAM,CAAC;QACN,sCAAsC;QACtC,OAAO,GAAG,UAAU,IAAI,GACtB,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAChD,EAAE,CAAC;IACL,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,+BAAgB,CAAC,OAAO,EAAE;QAC1C,IAAI;QACJ,WAAW;QACX,QAAQ;KACT,CAAC,CAAC;IACH,KAAK,CAAC,IAAI,GAAG,SAAS,IAAI,iBAAiB,CAAC;IAE5C,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AAEH,mDAAmD;AACnD;;;;;;;;;;;;;;;;;;;;;;;;;EAyBE;AAEF,wDAAwD;AACxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BE;AAEF,+DAA+D;AAC/D;;;;;;;;;;;;;;;;;;;EAmBE;AAEF,4DAA4D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gender-categories.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/gender/gender-categories.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAE7F"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Gender categories for gendered translations
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isGenderedString = isGenderedString;
|
|
7
|
-
/**
|
|
8
|
-
* Checks if a value is a gendered string object (not a simple string).
|
|
9
|
-
* @param value - The value to check
|
|
10
|
-
* @returns True if the value is a gendered string object, false otherwise
|
|
11
|
-
*/
|
|
12
|
-
function isGenderedString(value) {
|
|
13
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=gender-categories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gender-categories.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/gender/gender-categories.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAiBH,4CAEC;AAPD;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,KAAU;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gender form resolution
|
|
3
|
-
*/
|
|
4
|
-
import { GenderCategory, GenderedString } from './gender-categories';
|
|
5
|
-
/**
|
|
6
|
-
* Resolve a gender-specific form with fallback logic.
|
|
7
|
-
* If the value is a simple string, it's returned as-is.
|
|
8
|
-
* For gendered strings, it tries the requested gender, then neutral, then other, then the first available form.
|
|
9
|
-
* @param value - The gendered string value or simple string
|
|
10
|
-
* @param gender - The gender category to resolve (optional)
|
|
11
|
-
* @returns The resolved string form
|
|
12
|
-
*/
|
|
13
|
-
export declare function resolveGenderForm(value: GenderedString, gender: GenderCategory | string | undefined): string;
|
|
14
|
-
//# sourceMappingURL=gender-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gender-resolver.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/gender/gender-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAoB,MAAM,qBAAqB,CAAC;AAEvF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,GAC1C,MAAM,CAsBR"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Gender form resolution
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveGenderForm = resolveGenderForm;
|
|
7
|
-
const gender_categories_1 = require("./gender-categories");
|
|
8
|
-
/**
|
|
9
|
-
* Resolve a gender-specific form with fallback logic.
|
|
10
|
-
* If the value is a simple string, it's returned as-is.
|
|
11
|
-
* For gendered strings, it tries the requested gender, then neutral, then other, then the first available form.
|
|
12
|
-
* @param value - The gendered string value or simple string
|
|
13
|
-
* @param gender - The gender category to resolve (optional)
|
|
14
|
-
* @returns The resolved string form
|
|
15
|
-
*/
|
|
16
|
-
function resolveGenderForm(value, gender) {
|
|
17
|
-
if (typeof value === 'string') {
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
if (!(0, gender_categories_1.isGenderedString)(value)) {
|
|
21
|
-
return '';
|
|
22
|
-
}
|
|
23
|
-
// No gender provided - use neutral or other or first available
|
|
24
|
-
if (!gender) {
|
|
25
|
-
return value.neutral || value.other || Object.values(value)[0] || '';
|
|
26
|
-
}
|
|
27
|
-
// Try requested gender
|
|
28
|
-
const requested = value[gender];
|
|
29
|
-
if (requested) {
|
|
30
|
-
return requested;
|
|
31
|
-
}
|
|
32
|
-
// Fallback: neutral → other → first available
|
|
33
|
-
return value.neutral || value.other || Object.values(value)[0] || '';
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=gender-resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gender-resolver.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/gender/gender-resolver.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAYH,8CAyBC;AAnCD,2DAAuF;AAEvF;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAC/B,KAAqB,EACrB,MAA2C;IAE3C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,IAAA,oCAAgB,EAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,+DAA+D;IAC/D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvE,CAAC;IAED,uBAAuB;IACvB,MAAM,SAAS,GAAG,KAAK,CAAC,MAAwB,CAAC,CAAC;IAClD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,8CAA8C;IAC9C,OAAO,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/gender/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
|
package/src/gender/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./gender-categories"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./gender-resolver"), exports);
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
package/src/gender/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/gender/index.ts"],"names":[],"mappings":";;;AAAA,8DAAoC;AACpC,4DAAkC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { IActiveContext } from './interfaces/active-context.interface';
|
|
2
|
-
import type { IGlobalActiveContext } from './interfaces/global-active-context';
|
|
3
|
-
import { LanguageContextSpace } from './types';
|
|
4
|
-
import { CurrencyCode } from './utils/currency';
|
|
5
|
-
import { Timezone } from './utils/timezone';
|
|
6
|
-
export declare class GlobalActiveContext<TLanguage extends string, TActiveContext extends IActiveContext<TLanguage>> implements IGlobalActiveContext<TLanguage, TActiveContext> {
|
|
7
|
-
protected static _contextMap: Map<string, IActiveContext<any>>;
|
|
8
|
-
static readonly defaultContextKey = "default";
|
|
9
|
-
static readonly defaultLanguage: string;
|
|
10
|
-
private static _instance;
|
|
11
|
-
static get instance(): GlobalActiveContext<any, any>;
|
|
12
|
-
static getInstance<TLanguage extends string, TActiveContext extends IActiveContext<TLanguage>>(): GlobalActiveContext<TLanguage, TActiveContext>;
|
|
13
|
-
static overrideInstance(instance: GlobalActiveContext<any, any>): void;
|
|
14
|
-
createContext(defaultLanguage: TLanguage, defaultAdminLanguage?: TLanguage, key?: string): TActiveContext;
|
|
15
|
-
getContext(key?: string): TActiveContext;
|
|
16
|
-
get context(): TActiveContext;
|
|
17
|
-
set context(ctx: TActiveContext);
|
|
18
|
-
setUserLanguage(language: TLanguage, key?: string): void;
|
|
19
|
-
get userLanguage(): TLanguage;
|
|
20
|
-
set userLanguage(lang: TLanguage);
|
|
21
|
-
setCurrencyCode(code: CurrencyCode, key?: string): void;
|
|
22
|
-
get currencyCode(): CurrencyCode;
|
|
23
|
-
set currencyCode(code: CurrencyCode);
|
|
24
|
-
/**
|
|
25
|
-
* Sets the admin language for console operations
|
|
26
|
-
* @param language The language to set for admin operations
|
|
27
|
-
*/
|
|
28
|
-
setAdminLanguage(language: TLanguage, key?: string): void;
|
|
29
|
-
get adminLanguage(): TLanguage;
|
|
30
|
-
set adminLanguage(lang: TLanguage);
|
|
31
|
-
/**
|
|
32
|
-
* Sets the language context for the current context
|
|
33
|
-
* @param context The language context to set
|
|
34
|
-
*/
|
|
35
|
-
setLanguageContextSpace(context: LanguageContextSpace, key?: string): void;
|
|
36
|
-
getLanguageContextSpace(key?: string): LanguageContextSpace;
|
|
37
|
-
get languageContextSpace(): LanguageContextSpace;
|
|
38
|
-
set languageContextSpace(context: LanguageContextSpace);
|
|
39
|
-
setUserTimezone(tz: Timezone, key?: string): void;
|
|
40
|
-
get userTimezone(): Timezone;
|
|
41
|
-
set userTimezone(tz: Timezone);
|
|
42
|
-
setAdminTimezone(tz: Timezone, key?: string): void;
|
|
43
|
-
get adminTimezone(): Timezone;
|
|
44
|
-
set adminTimezone(tz: Timezone);
|
|
45
|
-
/**
|
|
46
|
-
* Clear all contexts (useful for testing)
|
|
47
|
-
*/
|
|
48
|
-
static clearAll(): void;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=global-active-context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global-active-context.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/global-active-context.ts"],"names":[],"mappings":"AAEA,OAAO,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