@digitaldefiance/i18n-lib 1.3.11 → 1.3.12
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 +4 -0
- package/dist/typed-error.d.ts +3 -3
- package/dist/typed-error.js +1 -1
- package/dist/typed-handleable.d.ts +4 -4
- package/dist/typed-handleable.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/typed-error.d.ts
CHANGED
|
@@ -11,18 +11,18 @@ export type CompleteReasonMap<TEnum extends Record<string, string | number>, TSt
|
|
|
11
11
|
/**
|
|
12
12
|
* Base typed error class with common patterns
|
|
13
13
|
*/
|
|
14
|
-
export declare abstract class BaseTypedError<TEnum extends Record<string, string
|
|
14
|
+
export declare abstract class BaseTypedError<TEnum extends Record<string, string>> extends Error {
|
|
15
15
|
readonly type: TEnum[keyof TEnum];
|
|
16
16
|
readonly metadata?: Record<string, any> | undefined;
|
|
17
17
|
constructor(type: TEnum[keyof TEnum], message: string, metadata?: Record<string, any> | undefined);
|
|
18
18
|
/**
|
|
19
19
|
* Create a simple typed error without engine dependency
|
|
20
20
|
*/
|
|
21
|
-
static createSimple<TEnum extends Record<string, string>,
|
|
21
|
+
static createSimple<TEnum extends Record<string, string>, TError extends BaseTypedError<TEnum>>(this: new (type: TEnum[keyof TEnum], message: string, metadata?: Record<string, any>) => TError, type: TEnum[keyof TEnum], message: string, metadata?: Record<string, any>): TError;
|
|
22
22
|
/**
|
|
23
23
|
* Create a typed error with translation support
|
|
24
24
|
*/
|
|
25
|
-
static createTranslated<TEnum extends Record<string, string>, TStringKey extends string, TError extends BaseTypedError<TEnum
|
|
25
|
+
static createTranslated<TEnum extends Record<string, string>, TStringKey extends string, TError extends BaseTypedError<TEnum>>(this: new (type: TEnum[keyof TEnum], message: string, metadata?: Record<string, any>) => TError, engine: TranslationEngine, type: TEnum[keyof TEnum], reasonMap: CompleteReasonMap<TEnum, TStringKey>, variables?: Record<string, string | number>, language?: string, metadata?: Record<string, any>): TError;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Legacy TypedError that ensures complete enum coverage (for backward compatibility)
|
package/dist/typed-error.js
CHANGED
|
@@ -29,7 +29,7 @@ class BaseTypedError extends Error {
|
|
|
29
29
|
/**
|
|
30
30
|
* Create a typed error with translation support
|
|
31
31
|
*/
|
|
32
|
-
static createTranslated(engine,
|
|
32
|
+
static createTranslated(engine, type, reasonMap, variables, language, metadata) {
|
|
33
33
|
const key = reasonMap[type];
|
|
34
34
|
let message;
|
|
35
35
|
if (key && engine) {
|
|
@@ -2,13 +2,13 @@ import { HandleableErrorOptions } from './i-handleable-error-options';
|
|
|
2
2
|
import { IHandleable } from './i-handleable';
|
|
3
3
|
import { HandleableError } from './handleable';
|
|
4
4
|
import { CompleteReasonMap, TranslationEngine } from './typed-error';
|
|
5
|
-
import {
|
|
6
|
-
export declare class TypedHandleableError<TEnum extends Record<string, string>, TStringKey extends string> extends HandleableError implements IHandleable {
|
|
5
|
+
import { CoreLanguageCode } from './core-i18n';
|
|
6
|
+
export declare class TypedHandleableError<TEnum extends Record<string, string>, TStringKey extends string, TLanguage extends CoreLanguageCode = CoreLanguageCode> extends HandleableError implements IHandleable {
|
|
7
7
|
readonly type: TEnum[keyof TEnum];
|
|
8
8
|
readonly reasonMap: CompleteReasonMap<TEnum, TStringKey>;
|
|
9
9
|
readonly engine: TranslationEngine<TStringKey>;
|
|
10
|
-
readonly language?:
|
|
10
|
+
readonly language?: TLanguage;
|
|
11
11
|
readonly otherVars?: Record<string, string | number>;
|
|
12
|
-
constructor(type: TEnum[keyof TEnum], reasonMap: CompleteReasonMap<TEnum, TStringKey>, engine: TranslationEngine<TStringKey>, language?:
|
|
12
|
+
constructor(type: TEnum[keyof TEnum], reasonMap: CompleteReasonMap<TEnum, TStringKey>, engine: TranslationEngine<TStringKey>, language?: TLanguage, otherVars?: Record<string, string | number>, options?: HandleableErrorOptions);
|
|
13
13
|
toJSON(): Record<string, unknown>;
|
|
14
14
|
}
|
package/dist/typed-handleable.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypedHandleableError = void 0;
|
|
4
4
|
const handleable_1 = require("./handleable");
|
|
5
|
-
const
|
|
5
|
+
const plugin_i18n_engine_1 = require("./plugin-i18n-engine");
|
|
6
6
|
const core_string_key_1 = require("./core-string-key");
|
|
7
7
|
class TypedHandleableError extends handleable_1.HandleableError {
|
|
8
8
|
constructor(type, reasonMap, engine, language, otherVars, options) {
|
|
9
9
|
const key = reasonMap[type];
|
|
10
10
|
if (!key) {
|
|
11
|
-
const coreEngine =
|
|
12
|
-
throw new Error(coreEngine.translate(core_string_key_1.CoreStringKey.Error_MissingTranslationKeyTemplate, {
|
|
11
|
+
const coreEngine = plugin_i18n_engine_1.PluginI18nEngine.getInstance();
|
|
12
|
+
throw new Error(coreEngine.translate('core', core_string_key_1.CoreStringKey.Error_MissingTranslationKeyTemplate, {
|
|
13
13
|
stringKey: key,
|
|
14
14
|
}));
|
|
15
15
|
}
|