@digitaldefiance/i18n-lib 3.6.1 → 3.6.2
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/README.md +5 -0
- package/package.json +1 -1
- package/src/active-context.d.ts +12 -6
- package/src/active-context.d.ts.map +1 -1
- package/src/component-registry.d.ts +44 -12
- package/src/component-registry.d.ts.map +1 -1
- package/src/component-registry.js +44 -12
- package/src/component-registry.js.map +1 -1
- package/src/context-error-type.d.ts +4 -0
- package/src/context-error-type.d.ts.map +1 -1
- package/src/context-error-type.js +4 -0
- package/src/context-error-type.js.map +1 -1
- package/src/core/component-store.d.ts +69 -1
- package/src/core/component-store.d.ts.map +1 -1
- package/src/core/component-store.js +69 -1
- package/src/core/component-store.js.map +1 -1
- package/src/core/context-manager.d.ts +53 -1
- package/src/core/context-manager.d.ts.map +1 -1
- package/src/core/context-manager.js +52 -4
- package/src/core/context-manager.js.map +1 -1
- package/src/core/enum-registry.d.ts +34 -0
- package/src/core/enum-registry.d.ts.map +1 -1
- package/src/core/enum-registry.js +34 -0
- package/src/core/enum-registry.js.map +1 -1
- package/src/core/i18n-engine.d.ts +186 -0
- package/src/core/i18n-engine.d.ts.map +1 -1
- package/src/core/i18n-engine.js +189 -17
- package/src/core/i18n-engine.js.map +1 -1
- package/src/core/language-registry.d.ts +139 -0
- package/src/core/language-registry.d.ts.map +1 -1
- package/src/core/language-registry.js +138 -0
- package/src/core/language-registry.js.map +1 -1
- package/src/core-i18n.d.ts.map +1 -1
- package/src/core-i18n.js +16 -416
- package/src/core-i18n.js.map +1 -1
- package/src/enum-registry.d.ts +41 -21
- package/src/enum-registry.d.ts.map +1 -1
- package/src/enum-registry.js +44 -24
- package/src/enum-registry.js.map +1 -1
- package/src/errors/context-error.d.ts +11 -0
- package/src/errors/context-error.d.ts.map +1 -1
- package/src/errors/context-error.js +11 -0
- package/src/errors/context-error.js.map +1 -1
- package/src/errors/handleable.d.ts +33 -0
- package/src/errors/handleable.d.ts.map +1 -1
- package/src/errors/handleable.js +33 -0
- package/src/errors/handleable.js.map +1 -1
- package/src/errors/i18n-error.d.ts +107 -0
- package/src/errors/i18n-error.d.ts.map +1 -1
- package/src/errors/i18n-error.js +104 -0
- package/src/errors/i18n-error.js.map +1 -1
- package/src/gender/gender-categories.d.ts +11 -0
- package/src/gender/gender-categories.d.ts.map +1 -1
- package/src/gender/gender-categories.js +5 -0
- package/src/gender/gender-categories.js.map +1 -1
- package/src/gender/gender-resolver.d.ts +6 -1
- package/src/gender/gender-resolver.d.ts.map +1 -1
- package/src/gender/gender-resolver.js +6 -1
- package/src/gender/gender-resolver.js.map +1 -1
- package/src/interfaces/component-config.interface.d.ts +6 -0
- package/src/interfaces/component-config.interface.d.ts.map +1 -1
- package/src/interfaces/engine-config.interface.d.ts +9 -0
- package/src/interfaces/engine-config.interface.d.ts.map +1 -1
- package/src/interfaces/handleable-error-options.d.ts +7 -0
- package/src/interfaces/handleable-error-options.d.ts.map +1 -1
- package/src/interfaces/handleable.d.ts +15 -0
- package/src/interfaces/handleable.d.ts.map +1 -1
- package/src/interfaces/i18n-engine.interface.d.ts +20 -0
- package/src/interfaces/i18n-engine.interface.d.ts.map +1 -1
- package/src/interfaces/language-definition.interface.d.ts +7 -0
- package/src/interfaces/language-definition.interface.d.ts.map +1 -1
- package/src/interfaces/translation-options.interface.d.ts +6 -0
- package/src/interfaces/translation-options.interface.d.ts.map +1 -1
- package/src/interfaces/validation-result.interface.d.ts +10 -0
- package/src/interfaces/validation-result.interface.d.ts.map +1 -1
- package/src/registry-error-type.d.ts +7 -0
- package/src/registry-error-type.d.ts.map +1 -1
- package/src/registry-error-type.js +7 -0
- package/src/registry-error-type.js.map +1 -1
- 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/types/plural-types.d.ts +10 -3
- package/src/types/plural-types.d.ts.map +1 -1
- package/src/types/plural-types.js +8 -2
- package/src/types/plural-types.js.map +1 -1
- package/src/utils/currency.d.ts +53 -0
- package/src/utils/currency.d.ts.map +1 -1
- package/src/utils/currency.js +35 -0
- package/src/utils/currency.js.map +1 -1
- package/src/utils/html-escape.d.ts +14 -0
- package/src/utils/html-escape.d.ts.map +1 -1
- package/src/utils/html-escape.js +20 -0
- package/src/utils/html-escape.js.map +1 -1
- package/src/utils/lru-cache.d.ts +29 -0
- package/src/utils/lru-cache.d.ts.map +1 -1
- package/src/utils/lru-cache.js +29 -0
- package/src/utils/lru-cache.js.map +1 -1
- package/src/utils/plural-helpers.d.ts +16 -0
- package/src/utils/plural-helpers.d.ts.map +1 -1
- package/src/utils/plural-helpers.js +16 -0
- package/src/utils/plural-helpers.js.map +1 -1
- package/src/utils/safe-object.d.ts +30 -0
- package/src/utils/safe-object.d.ts.map +1 -1
- package/src/utils/safe-object.js +33 -0
- package/src/utils/safe-object.js.map +1 -1
- package/src/utils/string-utils.d.ts +19 -0
- package/src/utils/string-utils.d.ts.map +1 -1
- package/src/utils/string-utils.js +18 -1
- package/src/utils/string-utils.js.map +1 -1
- package/src/utils/timezone.d.ts +36 -0
- package/src/utils/timezone.d.ts.map +1 -1
- package/src/utils/timezone.js +36 -0
- package/src/utils/timezone.js.map +1 -1
- package/src/utils/validation.d.ts +25 -0
- package/src/utils/validation.d.ts.map +1 -1
- package/src/utils/validation.js +25 -0
- package/src/utils/validation.js.map +1 -1
- package/src/validation/plural-validator.d.ts +25 -2
- package/src/validation/plural-validator.d.ts.map +1 -1
- package/src/validation/plural-validator.js +22 -4
- package/src/validation/plural-validator.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum-registry.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/enum-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD
|
|
1
|
+
{"version":3,"file":"enum-registry.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/enum-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;GAKG;AACH,qBAAa,uBAAuB,CAClC,UAAU,SAAS,MAAM,EACzB,SAAS,SAAS,MAAM;IAExB,SAAS,CAAC,YAAY,mFAA2D;IACjF,SAAS,CAAC,SAAS,uBAA8B;IACjD,SAAS,CAAC,kBAAkB,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7C,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;IAEhF;;;;;OAKG;gBAED,kBAAkB,EAAE,SAAS,EAAE,EAC/B,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM;IAMvE;;;;;;;;OAQG;IACI,QAAQ,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9B,YAAY,EAAE,uBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,EACvD,QAAQ,EAAE,MAAM,GACf,IAAI;IAMP;;;;;;;;;OASG;IACI,SAAS,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,SAAS,GAClB,MAAM;IA2CT;;;;;OAKG;IACI,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAIjC;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAInB;;;;;;;OAOG;IACH,OAAO,CAAC,oBAAoB;CAgB7B"}
|
package/src/enum-registry.js
CHANGED
|
@@ -2,22 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnumTranslationRegistry = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Registry for managing enum
|
|
5
|
+
* Registry for managing translations of enum values across multiple languages.
|
|
6
|
+
*
|
|
7
|
+
* @template TStringKey Type of translation key used in error messages.
|
|
8
|
+
* @template TLanguage Type of supported language codes.
|
|
6
9
|
*/
|
|
7
10
|
class EnumTranslationRegistry {
|
|
8
11
|
translations = new Map();
|
|
9
12
|
enumNames = new WeakMap();
|
|
10
13
|
availableLanguages;
|
|
11
14
|
translateFn;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new EnumTranslationRegistry.
|
|
17
|
+
*
|
|
18
|
+
* @param availableLanguages Array of supported language codes.
|
|
19
|
+
* @param translateFn Optional translation function for error templates.
|
|
20
|
+
*/
|
|
12
21
|
constructor(availableLanguages, translateFn) {
|
|
13
22
|
this.availableLanguages = new Set(availableLanguages);
|
|
14
23
|
this.translateFn = translateFn;
|
|
15
24
|
}
|
|
16
25
|
/**
|
|
17
|
-
* Registers an
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
20
|
-
* @param
|
|
26
|
+
* Registers an enum and its language-specific translations.
|
|
27
|
+
*
|
|
28
|
+
* @template TEnum Enum value type (string or number).
|
|
29
|
+
* @param enumObj The enum object to register.
|
|
30
|
+
* @param translations Mapping of language codes to value-to-string translations.
|
|
31
|
+
* @param enumName Human-readable name of the enum (used in errors).
|
|
32
|
+
* @throws {Error} If translations contain languages not in availableLanguages.
|
|
21
33
|
*/
|
|
22
34
|
register(enumObj, translations, enumName) {
|
|
23
35
|
this.validateTranslations(translations, enumName);
|
|
@@ -25,11 +37,14 @@ class EnumTranslationRegistry {
|
|
|
25
37
|
this.enumNames.set(enumObj, enumName);
|
|
26
38
|
}
|
|
27
39
|
/**
|
|
28
|
-
* Translates a
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
31
|
-
* @param
|
|
32
|
-
* @
|
|
40
|
+
* Translates a specific enum value into the target language.
|
|
41
|
+
*
|
|
42
|
+
* @template TEnum Enum value type.
|
|
43
|
+
* @param enumObj The enum object registered previously.
|
|
44
|
+
* @param value The enum value to translate.
|
|
45
|
+
* @param language The target language code.
|
|
46
|
+
* @returns The translated string.
|
|
47
|
+
* @throws {Error} If the enum or language or value is not found.
|
|
33
48
|
*/
|
|
34
49
|
translate(enumObj, value, language) {
|
|
35
50
|
const translations = this.translations.get(enumObj);
|
|
@@ -68,32 +83,37 @@ class EnumTranslationRegistry {
|
|
|
68
83
|
return result;
|
|
69
84
|
}
|
|
70
85
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
86
|
+
* Checks whether translations exist for the given enum object.
|
|
87
|
+
*
|
|
88
|
+
* @param enumObj The enum object to check.
|
|
89
|
+
* @returns True if registered, false otherwise.
|
|
74
90
|
*/
|
|
75
|
-
|
|
76
|
-
return this.
|
|
91
|
+
has(enumObj) {
|
|
92
|
+
return this.translations.has(enumObj);
|
|
77
93
|
}
|
|
78
94
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* @
|
|
95
|
+
* Internal: Retrieves the human-readable name of the enum.
|
|
96
|
+
*
|
|
97
|
+
* @param enumObj The enum object.
|
|
98
|
+
* @returns Registered enum name or 'UnknownEnum' if not set.
|
|
82
99
|
*/
|
|
83
|
-
|
|
84
|
-
return this.
|
|
100
|
+
getEnumName(enumObj) {
|
|
101
|
+
return this.enumNames.get(enumObj) || 'UnknownEnum';
|
|
85
102
|
}
|
|
86
103
|
/**
|
|
87
|
-
* Validates that
|
|
88
|
-
*
|
|
89
|
-
* @
|
|
104
|
+
* Internal: Validates that translation entries only use available languages.
|
|
105
|
+
*
|
|
106
|
+
* @template TEnum Enum value type.
|
|
107
|
+
* @param translations Mapping of language codes to translations.
|
|
108
|
+
* @param enumName Enum name for error reporting.
|
|
109
|
+
* @throws {Error} If a translation language is not available.
|
|
90
110
|
*/
|
|
91
111
|
validateTranslations(translations, enumName) {
|
|
92
112
|
for (const language of Object.keys(translations)) {
|
|
93
113
|
if (!this.availableLanguages.has(language)) {
|
|
94
114
|
const message = this.translateFn
|
|
95
115
|
? this.translateFn('Error_EnumLanguageNotAvailableTemplate', { language, enumName })
|
|
96
|
-
: `Language '${language}' in enum '${enumName}' is not available in this
|
|
116
|
+
: `Language '${language}' in enum '${enumName}' is not available in this registry`;
|
|
97
117
|
throw new Error(message);
|
|
98
118
|
}
|
|
99
119
|
}
|
package/src/enum-registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum-registry.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-i18n-lib/src/enum-registry.ts"],"names":[],"mappings":";;;AAEA
|
|
1
|
+
{"version":3,"file":"enum-registry.js","sourceRoot":"","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,CAAC,IAAI,aAAa,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACK,oBAAoB,CAC1B,YAAuD,EACvD,QAAgB;QAEhB,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAgB,EAAE,CAAC;YAChE,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW;oBAC9B,CAAC,CAAC,IAAI,CAAC,WAAW,CACd,wCAAsD,EACtD,EAAE,QAAQ,EAAE,QAAQ,EAAE,CACvB;oBACH,CAAC,CAAC,aAAa,QAAQ,cAAc,QAAQ,qCAAqC,CAAC;gBACrF,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA/ID,0DA+IC"}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { ContextErrorType } from '../context-error-type';
|
|
2
|
+
/**
|
|
3
|
+
* Error class for context-related failures in the i18n system.
|
|
4
|
+
* Thrown when attempting to access or manipulate an invalid or non-existent context.
|
|
5
|
+
*/
|
|
2
6
|
export declare class ContextError extends Error {
|
|
7
|
+
/** The type of context error */
|
|
3
8
|
readonly type: ContextErrorType;
|
|
9
|
+
/** The context key that caused the error, if applicable */
|
|
4
10
|
readonly contextKey?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new ContextError instance.
|
|
13
|
+
* @param type - The type of context error
|
|
14
|
+
* @param contextKey - Optional context key that caused the error
|
|
15
|
+
*/
|
|
5
16
|
constructor(type: ContextErrorType, contextKey?: string);
|
|
6
17
|
}
|
|
7
18
|
//# sourceMappingURL=context-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-error.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/context-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,IAAI,EAAE,gBAAgB,CAAC;IACvC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"context-error.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/context-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD;;;GAGG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,gCAAgC;IAChC,SAAgB,IAAI,EAAE,gBAAgB,CAAC;IACvC,2DAA2D;IAC3D,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpC;;;;OAIG;gBACS,IAAI,EAAE,gBAAgB,EAAE,UAAU,CAAC,EAAE,MAAM;CAUxD"}
|
|
@@ -3,9 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ContextError = void 0;
|
|
4
4
|
const core_i18n_1 = require("../core-i18n");
|
|
5
5
|
const core_string_key_1 = require("../core-string-key");
|
|
6
|
+
/**
|
|
7
|
+
* Error class for context-related failures in the i18n system.
|
|
8
|
+
* Thrown when attempting to access or manipulate an invalid or non-existent context.
|
|
9
|
+
*/
|
|
6
10
|
class ContextError extends Error {
|
|
11
|
+
/** The type of context error */
|
|
7
12
|
type;
|
|
13
|
+
/** The context key that caused the error, if applicable */
|
|
8
14
|
contextKey;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new ContextError instance.
|
|
17
|
+
* @param type - The type of context error
|
|
18
|
+
* @param contextKey - Optional context key that caused the error
|
|
19
|
+
*/
|
|
9
20
|
constructor(type, contextKey) {
|
|
10
21
|
const engine = (0, core_i18n_1.getCoreI18nEngine)();
|
|
11
22
|
const message = contextKey
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-error.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/context-error.ts"],"names":[],"mappings":";;;AACA,4CAAsE;AACtE,wDAAmD;AAEnD,MAAa,YAAa,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"context-error.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/context-error.ts"],"names":[],"mappings":";;;AACA,4CAAsE;AACtE,wDAAmD;AAEnD;;;GAGG;AACH,MAAa,YAAa,SAAQ,KAAK;IACrC,gCAAgC;IAChB,IAAI,CAAmB;IACvC,2DAA2D;IAC3C,UAAU,CAAU;IAEpC;;;;OAIG;IACH,YAAY,IAAsB,EAAE,UAAmB;QACrD,MAAM,MAAM,GAAG,IAAA,6BAAiB,GAAE,CAAC;QACnC,MAAM,OAAO,GAAG,UAAU;YACxB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,+BAAmB,EAAE,+BAAa,CAAC,4BAA4B,EAAE,EAAC,UAAU,EAAC,CAAC;YACrG,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,+BAAmB,EAAE,+BAAa,CAAC,oBAAoB,CAAC,CAAC;QAClF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AArBD,oCAqBC"}
|
|
@@ -1,14 +1,47 @@
|
|
|
1
1
|
import { IHandleable } from '../interfaces/handleable';
|
|
2
2
|
import { HandleableErrorOptions } from '../interfaces/handleable-error-options';
|
|
3
|
+
/**
|
|
4
|
+
* Base error class that implements IHandleable interface.
|
|
5
|
+
* Provides enhanced error handling capabilities including status codes, handled state tracking,
|
|
6
|
+
* and source data preservation.
|
|
7
|
+
*/
|
|
3
8
|
export declare class HandleableError extends Error implements IHandleable {
|
|
9
|
+
/** The original error that caused this error */
|
|
4
10
|
readonly cause?: Error;
|
|
11
|
+
/** HTTP status code associated with this error */
|
|
5
12
|
readonly statusCode: number;
|
|
13
|
+
/** Optional source data related to the error */
|
|
6
14
|
readonly sourceData?: unknown;
|
|
15
|
+
/** Internal tracking of whether this error has been handled */
|
|
7
16
|
private _handled;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new HandleableError instance.
|
|
19
|
+
* @param source - The original error being wrapped
|
|
20
|
+
* @param options - Optional configuration for the error
|
|
21
|
+
*/
|
|
8
22
|
constructor(source: Error, options?: HandleableErrorOptions);
|
|
23
|
+
/**
|
|
24
|
+
* Gets the handled state of this error.
|
|
25
|
+
* @returns True if the error has been handled, false otherwise
|
|
26
|
+
*/
|
|
9
27
|
get handled(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Sets the handled state of this error.
|
|
30
|
+
* @param value - The new handled state
|
|
31
|
+
*/
|
|
10
32
|
set handled(value: boolean);
|
|
33
|
+
/**
|
|
34
|
+
* Serializes a value to a JSON-compatible format.
|
|
35
|
+
* Handles objects with toJSON methods, Error instances, arrays, and plain objects.
|
|
36
|
+
* @param value - The value to serialize
|
|
37
|
+
* @returns The serialized value
|
|
38
|
+
*/
|
|
11
39
|
private serializeValue;
|
|
40
|
+
/**
|
|
41
|
+
* Converts the error to a JSON-serializable object.
|
|
42
|
+
* Includes name, message, status code, handled state, stack trace, and optional source data.
|
|
43
|
+
* @returns A plain object representation of the error
|
|
44
|
+
*/
|
|
12
45
|
toJSON(): Record<string, unknown>;
|
|
13
46
|
}
|
|
14
47
|
//# sourceMappingURL=handleable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleable.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/handleable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"handleable.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/handleable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAShF;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAM,YAAW,WAAW;IAC/D,gDAAgD;IAChD,SAAyB,KAAK,CAAC,EAAE,KAAK,CAAC;IACvC,kDAAkD;IAClD,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,gDAAgD;IAChD,SAAgB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrC,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;OAIG;gBACS,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,sBAAsB;IAsB3D;;;OAGG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;OAGG;IACH,IAAW,OAAO,CAAC,KAAK,EAAE,OAAO,EAEhC;IAED;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAuBtB;;;;OAIG;IACI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAazC"}
|
package/src/errors/handleable.js
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HandleableError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base error class that implements IHandleable interface.
|
|
6
|
+
* Provides enhanced error handling capabilities including status codes, handled state tracking,
|
|
7
|
+
* and source data preservation.
|
|
8
|
+
*/
|
|
4
9
|
class HandleableError extends Error {
|
|
10
|
+
/** The original error that caused this error */
|
|
5
11
|
cause;
|
|
12
|
+
/** HTTP status code associated with this error */
|
|
6
13
|
statusCode;
|
|
14
|
+
/** Optional source data related to the error */
|
|
7
15
|
sourceData;
|
|
16
|
+
/** Internal tracking of whether this error has been handled */
|
|
8
17
|
_handled;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new HandleableError instance.
|
|
20
|
+
* @param source - The original error being wrapped
|
|
21
|
+
* @param options - Optional configuration for the error
|
|
22
|
+
*/
|
|
9
23
|
constructor(source, options) {
|
|
10
24
|
super(source.message);
|
|
11
25
|
this.name = this.constructor.name;
|
|
@@ -25,12 +39,26 @@ class HandleableError extends Error {
|
|
|
25
39
|
this.stack = new Error().stack;
|
|
26
40
|
}
|
|
27
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Gets the handled state of this error.
|
|
44
|
+
* @returns True if the error has been handled, false otherwise
|
|
45
|
+
*/
|
|
28
46
|
get handled() {
|
|
29
47
|
return this._handled;
|
|
30
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Sets the handled state of this error.
|
|
51
|
+
* @param value - The new handled state
|
|
52
|
+
*/
|
|
31
53
|
set handled(value) {
|
|
32
54
|
this._handled = value;
|
|
33
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Serializes a value to a JSON-compatible format.
|
|
58
|
+
* Handles objects with toJSON methods, Error instances, arrays, and plain objects.
|
|
59
|
+
* @param value - The value to serialize
|
|
60
|
+
* @returns The serialized value
|
|
61
|
+
*/
|
|
34
62
|
serializeValue(value) {
|
|
35
63
|
if (value &&
|
|
36
64
|
typeof value === 'object' &&
|
|
@@ -49,6 +77,11 @@ class HandleableError extends Error {
|
|
|
49
77
|
}
|
|
50
78
|
return value;
|
|
51
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Converts the error to a JSON-serializable object.
|
|
82
|
+
* Includes name, message, status code, handled state, stack trace, and optional source data.
|
|
83
|
+
* @returns A plain object representation of the error
|
|
84
|
+
*/
|
|
52
85
|
toJSON() {
|
|
53
86
|
return {
|
|
54
87
|
name: this.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleable.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/handleable.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"handleable.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/handleable.ts"],"names":[],"mappings":";;;AAUA;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,KAAK;IACxC,gDAAgD;IACvB,KAAK,CAAS;IACvC,kDAAkD;IAClC,UAAU,CAAS;IACnC,gDAAgD;IAChC,UAAU,CAAW;IACrC,+DAA+D;IACvD,QAAQ,CAAU;IAE1B;;;;OAIG;IACH,YAAY,MAAa,EAAE,OAAgC;QACzD,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,MAAM,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,GAAG,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,OAAO,IAAI,KAAK,CAAC;QAC1C,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAE9B,sEAAsE;QACtE,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC5B,CAAC;aAAM,IAAK,KAAmC,CAAC,iBAAiB,EAAE,CAAC;YACjE,KAAmC,CAAC,iBAAiB,EAAE,CACtD,IAAI,EACJ,IAAI,CAAC,WAAW,CACjB,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC;QACjC,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,IAAW,OAAO,CAAC,KAAc;Q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IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;gBACtD,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;IACJ,CAAC;CACF;AApGD,0CAoGC"}
|
|
@@ -1,40 +1,147 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unified error class for i18n library
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Error codes used throughout the i18n library.
|
|
6
|
+
*/
|
|
4
7
|
export declare const I18nErrorCode: {
|
|
8
|
+
/** Component not found in registry */
|
|
5
9
|
readonly COMPONENT_NOT_FOUND: "COMPONENT_NOT_FOUND";
|
|
10
|
+
/** String key not found in component */
|
|
6
11
|
readonly STRING_KEY_NOT_FOUND: "STRING_KEY_NOT_FOUND";
|
|
12
|
+
/** Language not found in registry */
|
|
7
13
|
readonly LANGUAGE_NOT_FOUND: "LANGUAGE_NOT_FOUND";
|
|
14
|
+
/** Translation missing for specified key and language */
|
|
8
15
|
readonly TRANSLATION_MISSING: "TRANSLATION_MISSING";
|
|
16
|
+
/** Invalid configuration provided */
|
|
9
17
|
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
18
|
+
/** Attempt to register duplicate component */
|
|
10
19
|
readonly DUPLICATE_COMPONENT: "DUPLICATE_COMPONENT";
|
|
20
|
+
/** Attempt to register duplicate language */
|
|
11
21
|
readonly DUPLICATE_LANGUAGE: "DUPLICATE_LANGUAGE";
|
|
22
|
+
/** Validation failed during registration */
|
|
12
23
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
24
|
+
/** I18n instance not found */
|
|
13
25
|
readonly INSTANCE_NOT_FOUND: "INSTANCE_NOT_FOUND";
|
|
26
|
+
/** I18n instance already exists */
|
|
14
27
|
readonly INSTANCE_EXISTS: "INSTANCE_EXISTS";
|
|
28
|
+
/** Invalid context key provided */
|
|
15
29
|
readonly INVALID_CONTEXT: "INVALID_CONTEXT";
|
|
30
|
+
/** Plural form not found for language and category */
|
|
16
31
|
readonly PLURAL_FORM_NOT_FOUND: "PLURAL_FORM_NOT_FOUND";
|
|
32
|
+
/** Invalid plural category provided */
|
|
17
33
|
readonly INVALID_PLURAL_CATEGORY: "INVALID_PLURAL_CATEGORY";
|
|
34
|
+
/** Count variable missing for plural translation */
|
|
18
35
|
readonly MISSING_COUNT_VARIABLE: "MISSING_COUNT_VARIABLE";
|
|
19
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Type representing all possible i18n error codes.
|
|
39
|
+
*/
|
|
20
40
|
export type I18nErrorCode = (typeof I18nErrorCode)[keyof typeof I18nErrorCode];
|
|
41
|
+
/**
|
|
42
|
+
* Main error class for i18n-related errors.
|
|
43
|
+
* Includes error code and optional metadata for debugging.
|
|
44
|
+
*/
|
|
21
45
|
export declare class I18nError extends Error {
|
|
22
46
|
readonly code: I18nErrorCode;
|
|
23
47
|
readonly metadata?: Record<string, any> | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new I18nError instance.
|
|
50
|
+
* @param code - The specific error code
|
|
51
|
+
* @param message - Human-readable error message
|
|
52
|
+
* @param metadata - Optional metadata providing context about the error
|
|
53
|
+
*/
|
|
24
54
|
constructor(code: I18nErrorCode, message: string, metadata?: Record<string, any> | undefined);
|
|
55
|
+
/**
|
|
56
|
+
* Creates an error for when a component is not found.
|
|
57
|
+
* @param componentId - The ID of the component that was not found
|
|
58
|
+
* @returns An I18nError instance
|
|
59
|
+
*/
|
|
25
60
|
static componentNotFound(componentId: string): I18nError;
|
|
61
|
+
/**
|
|
62
|
+
* Creates an error for when a string key is not found in a component.
|
|
63
|
+
* @param componentId - The ID of the component
|
|
64
|
+
* @param stringKey - The string key that was not found
|
|
65
|
+
* @returns An I18nError instance
|
|
66
|
+
*/
|
|
26
67
|
static stringKeyNotFound(componentId: string, stringKey: string): I18nError;
|
|
68
|
+
/**
|
|
69
|
+
* Creates an error for when a language is not found.
|
|
70
|
+
* @param language - The language code that was not found
|
|
71
|
+
* @returns An I18nError instance
|
|
72
|
+
*/
|
|
27
73
|
static languageNotFound(language: string): I18nError;
|
|
74
|
+
/**
|
|
75
|
+
* Creates an error for when a translation is missing.
|
|
76
|
+
* @param componentId - The ID of the component
|
|
77
|
+
* @param stringKey - The string key
|
|
78
|
+
* @param language - The language code
|
|
79
|
+
* @returns An I18nError instance
|
|
80
|
+
*/
|
|
28
81
|
static translationMissing(componentId: string, stringKey: string, language: string): I18nError;
|
|
82
|
+
/**
|
|
83
|
+
* Creates an error for invalid configuration.
|
|
84
|
+
* @param reason - The reason why the configuration is invalid
|
|
85
|
+
* @returns An I18nError instance
|
|
86
|
+
*/
|
|
29
87
|
static invalidConfig(reason: string): I18nError;
|
|
88
|
+
/**
|
|
89
|
+
* Creates an error for duplicate component registration.
|
|
90
|
+
* @param componentId - The ID of the duplicate component
|
|
91
|
+
* @returns An I18nError instance
|
|
92
|
+
*/
|
|
30
93
|
static duplicateComponent(componentId: string): I18nError;
|
|
94
|
+
/**
|
|
95
|
+
* Creates an error for duplicate language registration.
|
|
96
|
+
* @param language - The language code that is duplicate
|
|
97
|
+
* @returns An I18nError instance
|
|
98
|
+
*/
|
|
31
99
|
static duplicateLanguage(language: string): I18nError;
|
|
100
|
+
/**
|
|
101
|
+
* Creates an error for validation failure.
|
|
102
|
+
* @param errors - Array of validation error messages
|
|
103
|
+
* @returns An I18nError instance
|
|
104
|
+
*/
|
|
32
105
|
static validationFailed(errors: string[]): I18nError;
|
|
106
|
+
/**
|
|
107
|
+
* Creates an error for when an i18n instance is not found.
|
|
108
|
+
* @param key - The instance key that was not found
|
|
109
|
+
* @returns An I18nError instance
|
|
110
|
+
*/
|
|
33
111
|
static instanceNotFound(key: string): I18nError;
|
|
112
|
+
/**
|
|
113
|
+
* Creates an error for when an i18n instance already exists.
|
|
114
|
+
* @param key - The instance key that already exists
|
|
115
|
+
* @returns An I18nError instance
|
|
116
|
+
*/
|
|
34
117
|
static instanceExists(key: string): I18nError;
|
|
118
|
+
/**
|
|
119
|
+
* Creates an error for an invalid context key.
|
|
120
|
+
* @param contextKey - The invalid context key
|
|
121
|
+
* @returns An I18nError instance
|
|
122
|
+
*/
|
|
35
123
|
static invalidContext(contextKey: string): I18nError;
|
|
124
|
+
/**
|
|
125
|
+
* Creates an error for when a plural form is not found.
|
|
126
|
+
* @param category - The plural category that was not found
|
|
127
|
+
* @param language - The language code
|
|
128
|
+
* @param key - The translation key
|
|
129
|
+
* @param availableForms - Array of available plural forms
|
|
130
|
+
* @returns An I18nError instance
|
|
131
|
+
*/
|
|
36
132
|
static pluralFormNotFound(category: string, language: string, key: string, availableForms: string[]): I18nError;
|
|
133
|
+
/**
|
|
134
|
+
* Creates an error for an invalid plural category.
|
|
135
|
+
* @param category - The invalid category
|
|
136
|
+
* @param validCategories - Array of valid categories
|
|
137
|
+
* @returns An I18nError instance
|
|
138
|
+
*/
|
|
37
139
|
static invalidPluralCategory(category: string, validCategories: string[]): I18nError;
|
|
140
|
+
/**
|
|
141
|
+
* Creates an error for when the count variable is missing for plural forms.
|
|
142
|
+
* @param key - The translation key that requires a count variable
|
|
143
|
+
* @returns An I18nError instance
|
|
144
|
+
*/
|
|
38
145
|
static missingCountVariable(key: string): I18nError;
|
|
39
146
|
}
|
|
40
147
|
//# sourceMappingURL=i18n-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-error.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/i18n-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"i18n-error.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/errors/i18n-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB,sCAAsC;;IAEtC,wCAAwC;;IAExC,qCAAqC;;IAErC,yDAAyD;;IAEzD,qCAAqC;;IAErC,8CAA8C;;IAE9C,6CAA6C;;IAE7C,4CAA4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