@venizia/ignis-inversion 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +2 -5
- package/README.md +18 -6
- package/dist/esm/modules/container/base.d.ts.map +1 -1
- package/dist/esm/modules/container/base.js +3 -1
- package/dist/esm/modules/container/base.js.map +1 -1
- package/dist/esm/modules/container/container.d.ts.map +1 -1
- package/dist/esm/modules/container/container.js +1 -0
- package/dist/esm/modules/container/container.js.map +1 -1
- package/dist/esm/modules/container/index.d.ts +1 -0
- package/dist/esm/modules/container/index.d.ts.map +1 -1
- package/dist/esm/modules/container/index.js +1 -0
- package/dist/esm/modules/container/index.js.map +1 -1
- package/dist/esm/modules/container/verifier.d.ts +47 -0
- package/dist/esm/modules/container/verifier.d.ts.map +1 -0
- package/dist/esm/modules/container/verifier.js +115 -0
- package/dist/esm/modules/container/verifier.js.map +1 -0
- package/dist/esm/modules/error/common/constants.d.ts +14 -0
- package/dist/esm/modules/error/common/constants.d.ts.map +1 -0
- package/dist/esm/modules/error/common/constants.js +19 -0
- package/dist/esm/modules/error/common/constants.js.map +1 -0
- package/dist/esm/modules/error/common/index.d.ts +1 -0
- package/dist/esm/modules/error/common/index.d.ts.map +1 -1
- package/dist/esm/modules/error/common/index.js +1 -0
- package/dist/esm/modules/error/common/index.js.map +1 -1
- package/dist/esm/modules/error/common/types.d.ts +1 -2
- package/dist/esm/modules/error/common/types.d.ts.map +1 -1
- package/dist/esm/modules/error/common/types.js.map +1 -1
- package/package.json +7 -15
- package/dist/cjs/common/base-helper.d.ts +0 -9
- package/dist/cjs/common/base-helper.d.ts.map +0 -1
- package/dist/cjs/common/base-helper.js +0 -11
- package/dist/cjs/common/base-helper.js.map +0 -1
- package/dist/cjs/common/index.d.ts +0 -5
- package/dist/cjs/common/index.d.ts.map +0 -1
- package/dist/cjs/common/index.js +0 -21
- package/dist/cjs/common/index.js.map +0 -1
- package/dist/cjs/common/logger.d.ts +0 -11
- package/dist/cjs/common/logger.d.ts.map +0 -1
- package/dist/cjs/common/logger.js +0 -26
- package/dist/cjs/common/logger.js.map +0 -1
- package/dist/cjs/common/types.d.ts +0 -22
- package/dist/cjs/common/types.d.ts.map +0 -1
- package/dist/cjs/common/types.js +0 -3
- package/dist/cjs/common/types.js.map +0 -1
- package/dist/cjs/common/utilities.d.ts +0 -38
- package/dist/cjs/common/utilities.d.ts.map +0 -1
- package/dist/cjs/common/utilities.js +0 -83
- package/dist/cjs/common/utilities.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -4
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -26
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/modules/binding/binding.d.ts +0 -37
- package/dist/cjs/modules/binding/binding.d.ts.map +0 -1
- package/dist/cjs/modules/binding/binding.js +0 -120
- package/dist/cjs/modules/binding/binding.js.map +0 -1
- package/dist/cjs/modules/binding/common/constants.d.ts +0 -19
- package/dist/cjs/modules/binding/common/constants.d.ts.map +0 -1
- package/dist/cjs/modules/binding/common/constants.js +0 -33
- package/dist/cjs/modules/binding/common/constants.js.map +0 -1
- package/dist/cjs/modules/binding/common/index.d.ts +0 -3
- package/dist/cjs/modules/binding/common/index.d.ts.map +0 -1
- package/dist/cjs/modules/binding/common/index.js +0 -19
- package/dist/cjs/modules/binding/common/index.js.map +0 -1
- package/dist/cjs/modules/binding/common/types.d.ts +0 -28
- package/dist/cjs/modules/binding/common/types.d.ts.map +0 -1
- package/dist/cjs/modules/binding/common/types.js +0 -8
- package/dist/cjs/modules/binding/common/types.js.map +0 -1
- package/dist/cjs/modules/binding/index.d.ts +0 -3
- package/dist/cjs/modules/binding/index.d.ts.map +0 -1
- package/dist/cjs/modules/binding/index.js +0 -19
- package/dist/cjs/modules/binding/index.js.map +0 -1
- package/dist/cjs/modules/container/abstract.d.ts +0 -69
- package/dist/cjs/modules/container/abstract.d.ts.map +0 -1
- package/dist/cjs/modules/container/abstract.js +0 -12
- package/dist/cjs/modules/container/abstract.js.map +0 -1
- package/dist/cjs/modules/container/base.d.ts +0 -101
- package/dist/cjs/modules/container/base.d.ts.map +0 -1
- package/dist/cjs/modules/container/base.js +0 -193
- package/dist/cjs/modules/container/base.js.map +0 -1
- package/dist/cjs/modules/container/common/index.d.ts +0 -2
- package/dist/cjs/modules/container/common/index.d.ts.map +0 -1
- package/dist/cjs/modules/container/common/index.js +0 -18
- package/dist/cjs/modules/container/common/index.js.map +0 -1
- package/dist/cjs/modules/container/common/types.d.ts +0 -60
- package/dist/cjs/modules/container/common/types.d.ts.map +0 -1
- package/dist/cjs/modules/container/common/types.js +0 -3
- package/dist/cjs/modules/container/common/types.js.map +0 -1
- package/dist/cjs/modules/container/container.d.ts +0 -24
- package/dist/cjs/modules/container/container.d.ts.map +0 -1
- package/dist/cjs/modules/container/container.js +0 -100
- package/dist/cjs/modules/container/container.js.map +0 -1
- package/dist/cjs/modules/container/index.d.ts +0 -5
- package/dist/cjs/modules/container/index.d.ts.map +0 -1
- package/dist/cjs/modules/container/index.js +0 -21
- package/dist/cjs/modules/container/index.js.map +0 -1
- package/dist/cjs/modules/error/app-error.d.ts +0 -32
- package/dist/cjs/modules/error/app-error.d.ts.map +0 -1
- package/dist/cjs/modules/error/app-error.js +0 -102
- package/dist/cjs/modules/error/app-error.js.map +0 -1
- package/dist/cjs/modules/error/common/index.d.ts +0 -2
- package/dist/cjs/modules/error/common/index.d.ts.map +0 -1
- package/dist/cjs/modules/error/common/index.js +0 -18
- package/dist/cjs/modules/error/common/index.js.map +0 -1
- package/dist/cjs/modules/error/common/types.d.ts +0 -76
- package/dist/cjs/modules/error/common/types.d.ts.map +0 -1
- package/dist/cjs/modules/error/common/types.js +0 -3
- package/dist/cjs/modules/error/common/types.js.map +0 -1
- package/dist/cjs/modules/error/definition.d.ts +0 -10
- package/dist/cjs/modules/error/definition.d.ts.map +0 -1
- package/dist/cjs/modules/error/definition.js +0 -12
- package/dist/cjs/modules/error/definition.js.map +0 -1
- package/dist/cjs/modules/error/index.d.ts +0 -6
- package/dist/cjs/modules/error/index.d.ts.map +0 -1
- package/dist/cjs/modules/error/index.js +0 -22
- package/dist/cjs/modules/error/index.js.map +0 -1
- package/dist/cjs/modules/error/message-code.d.ts +0 -28
- package/dist/cjs/modules/error/message-code.d.ts.map +0 -1
- package/dist/cjs/modules/error/message-code.js +0 -57
- package/dist/cjs/modules/error/message-code.js.map +0 -1
- package/dist/cjs/modules/error/message-template.d.ts +0 -19
- package/dist/cjs/modules/error/message-template.d.ts.map +0 -1
- package/dist/cjs/modules/error/message-template.js +0 -38
- package/dist/cjs/modules/error/message-template.js.map +0 -1
- package/dist/cjs/modules/index.d.ts +0 -6
- package/dist/cjs/modules/index.d.ts.map +0 -1
- package/dist/cjs/modules/index.js +0 -22
- package/dist/cjs/modules/index.js.map +0 -1
- package/dist/cjs/modules/metadata/common/constants.d.ts +0 -6
- package/dist/cjs/modules/metadata/common/constants.d.ts.map +0 -1
- package/dist/cjs/modules/metadata/common/constants.js +0 -9
- package/dist/cjs/modules/metadata/common/constants.js.map +0 -1
- package/dist/cjs/modules/metadata/common/index.d.ts +0 -2
- package/dist/cjs/modules/metadata/common/index.d.ts.map +0 -1
- package/dist/cjs/modules/metadata/common/index.js +0 -18
- package/dist/cjs/modules/metadata/common/index.js.map +0 -1
- package/dist/cjs/modules/metadata/index.d.ts +0 -3
- package/dist/cjs/modules/metadata/index.d.ts.map +0 -1
- package/dist/cjs/modules/metadata/index.js +0 -19
- package/dist/cjs/modules/metadata/index.js.map +0 -1
- package/dist/cjs/modules/metadata/injectors.d.ts +0 -16
- package/dist/cjs/modules/metadata/injectors.d.ts.map +0 -1
- package/dist/cjs/modules/metadata/injectors.js +0 -47
- package/dist/cjs/modules/metadata/injectors.js.map +0 -1
- package/dist/cjs/modules/registry/common/index.d.ts +0 -2
- package/dist/cjs/modules/registry/common/index.d.ts.map +0 -1
- package/dist/cjs/modules/registry/common/index.js +0 -18
- package/dist/cjs/modules/registry/common/index.js.map +0 -1
- package/dist/cjs/modules/registry/common/types.d.ts +0 -20
- package/dist/cjs/modules/registry/common/types.d.ts.map +0 -1
- package/dist/cjs/modules/registry/common/types.js +0 -3
- package/dist/cjs/modules/registry/common/types.js.map +0 -1
- package/dist/cjs/modules/registry/index.d.ts +0 -3
- package/dist/cjs/modules/registry/index.d.ts.map +0 -1
- package/dist/cjs/modules/registry/index.js +0 -19
- package/dist/cjs/modules/registry/index.js.map +0 -1
- package/dist/cjs/modules/registry/registry.d.ts +0 -66
- package/dist/cjs/modules/registry/registry.d.ts.map +0 -1
- package/dist/cjs/modules/registry/registry.js +0 -98
- package/dist/cjs/modules/registry/registry.js.map +0 -1
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { IBinding } from '../../binding/common/types';
|
|
2
|
-
import type { TBindingKey, TClass, TNullable } from '../../../common/types';
|
|
3
|
-
import type { MetadataRegistry } from '../../registry/registry';
|
|
4
|
-
export interface IContainer {
|
|
5
|
-
getMetadataRegistry(): MetadataRegistry;
|
|
6
|
-
bind<T>(opts: {
|
|
7
|
-
key: TBindingKey;
|
|
8
|
-
}): IBinding<T>;
|
|
9
|
-
isBound(opts: {
|
|
10
|
-
key: TBindingKey;
|
|
11
|
-
}): boolean;
|
|
12
|
-
getBinding<T>(opts: {
|
|
13
|
-
key: TBindingKey | {
|
|
14
|
-
namespace: string;
|
|
15
|
-
key: string;
|
|
16
|
-
};
|
|
17
|
-
}): TNullable<IBinding<T>>;
|
|
18
|
-
unbind(opts: {
|
|
19
|
-
key: TBindingKey;
|
|
20
|
-
}): boolean;
|
|
21
|
-
set<T>(opts: {
|
|
22
|
-
binding: IBinding<T>;
|
|
23
|
-
}): void;
|
|
24
|
-
get<T>(opts: {
|
|
25
|
-
key: TBindingKey | {
|
|
26
|
-
namespace: string;
|
|
27
|
-
key: string;
|
|
28
|
-
};
|
|
29
|
-
isOptional?: false;
|
|
30
|
-
}): T;
|
|
31
|
-
get<T>(opts: {
|
|
32
|
-
key: TBindingKey | {
|
|
33
|
-
namespace: string;
|
|
34
|
-
key: string;
|
|
35
|
-
};
|
|
36
|
-
isOptional?: boolean;
|
|
37
|
-
}): T | undefined;
|
|
38
|
-
gets<T extends unknown[]>(opts: {
|
|
39
|
-
bindings: {
|
|
40
|
-
[K in keyof T]: {
|
|
41
|
-
key: TBindingKey | {
|
|
42
|
-
namespace: string;
|
|
43
|
-
key: string;
|
|
44
|
-
};
|
|
45
|
-
isOptional?: boolean;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
}): {
|
|
49
|
-
[K in keyof T]: T[K] | undefined;
|
|
50
|
-
};
|
|
51
|
-
resolve<T>(cls: TClass<T>): T;
|
|
52
|
-
instantiate<T>(cls: TClass<T>): T;
|
|
53
|
-
findByTag<T = any>(opts: {
|
|
54
|
-
tag: string;
|
|
55
|
-
exclude?: Array<string> | Set<string>;
|
|
56
|
-
}): IBinding<T>[];
|
|
57
|
-
clear(): void;
|
|
58
|
-
reset(): void;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/modules/container/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,UAAU;IACzB,mBAAmB,IAAI,gBAAgB,CAAC;IAExC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE;QAAE,GAAG,EAAE,WAAW,CAAA;KAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,WAAW,CAAA;KAAE,GAAG,OAA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AC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC9B,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAElC,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAChG,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/container/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IBinding } from '../../binding/common/types';\nimport type { TBindingKey, TClass, TNullable } from '@/common/types';\nimport type { MetadataRegistry } from '../../registry/registry';\n\nexport interface IContainer {\n getMetadataRegistry(): MetadataRegistry;\n\n bind<T>(opts: { key: TBindingKey }): IBinding<T>;\n isBound(opts: { key: TBindingKey }): boolean;\n getBinding<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n }): TNullable<IBinding<T>>;\n unbind(opts: { key: TBindingKey }): boolean;\n set<T>(opts: { binding: IBinding<T> }): void;\n\n get<T>(opts: { key: TBindingKey | { namespace: string; key: string }; isOptional?: false }): T;\n get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n }): T | undefined;\n gets<T extends unknown[]>(opts: {\n bindings: {\n [K in keyof T]: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n };\n };\n }): { [K in keyof T]: T[K] | undefined };\n\n resolve<T>(cls: TClass<T>): T;\n instantiate<T>(cls: TClass<T>): T;\n\n findByTag<T = any>(opts: { tag: string; exclude?: Array<string> | Set<string> }): IBinding<T>[];\n clear(): void;\n reset(): void;\n}\n"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type AnyType, type TBindingKey, type TClass, type TInjectTarget } from '../../common/types';
|
|
2
|
-
import { BaseContainer } from './base';
|
|
3
|
-
/** Default container: constructor + property injection driven by the decorator metadata registry. */
|
|
4
|
-
export declare class Container extends BaseContainer {
|
|
5
|
-
constructor(opts?: {
|
|
6
|
-
scope: string;
|
|
7
|
-
});
|
|
8
|
-
/**
|
|
9
|
-
* The class form reads the key the REGISTRATION recorded, so a call-site override and an imperative
|
|
10
|
-
* `application.service(X)` both resolve. `@inject` takes a key or a class; metadata a framework
|
|
11
|
-
* writes may carry both, and then the class wins and the key is the fallback for a class nothing
|
|
12
|
-
* recorded - one bound by hand with `bind({ key }).toClass(X)`. An optional class with neither
|
|
13
|
-
* resolves to `undefined`, as an optional key would.
|
|
14
|
-
*/
|
|
15
|
-
protected resolveBindingKey(opts: {
|
|
16
|
-
key?: TBindingKey;
|
|
17
|
-
target?: TInjectTarget;
|
|
18
|
-
isOptional?: boolean;
|
|
19
|
-
cls: TClass<AnyType>;
|
|
20
|
-
at: string;
|
|
21
|
-
}): TBindingKey | undefined;
|
|
22
|
-
instantiate<T>(cls: TClass<T>): T;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=container.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../../src/modules/container/container.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEjG,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,qGAAqG;AACrG,qBAAa,SAAU,SAAQ,aAAa;gBAC9B,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAIpC;;;;;;OAMG;IACH,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE;QAChC,GAAG,CAAC,EAAE,WAAW,CAAC;QAClB,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QACrB,EAAE,EAAE,MAAM,CAAC;KACZ,GAAG,WAAW,GAAG,SAAS;IA0ClB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;CAyD3C"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Container = void 0;
|
|
4
|
-
const error_1 = require("../error");
|
|
5
|
-
const utilities_1 = require("../../common/utilities");
|
|
6
|
-
const base_1 = require("./base");
|
|
7
|
-
/** Default container: constructor + property injection driven by the decorator metadata registry. */
|
|
8
|
-
class Container extends base_1.BaseContainer {
|
|
9
|
-
constructor(opts) {
|
|
10
|
-
super({ scope: opts?.scope ?? Container.name });
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* The class form reads the key the REGISTRATION recorded, so a call-site override and an imperative
|
|
14
|
-
* `application.service(X)` both resolve. `@inject` takes a key or a class; metadata a framework
|
|
15
|
-
* writes may carry both, and then the class wins and the key is the fallback for a class nothing
|
|
16
|
-
* recorded - one bound by hand with `bind({ key }).toClass(X)`. An optional class with neither
|
|
17
|
-
* resolves to `undefined`, as an optional key would.
|
|
18
|
-
*/
|
|
19
|
-
resolveBindingKey(opts) {
|
|
20
|
-
const { key, target: declared, isOptional = false, cls, at } = opts;
|
|
21
|
-
if (declared === undefined && key !== undefined) {
|
|
22
|
-
return key;
|
|
23
|
-
}
|
|
24
|
-
if (declared === undefined) {
|
|
25
|
-
throw (0, error_1.getError)({
|
|
26
|
-
message: `[${cls.name}] ${at} has neither an @inject key nor a class`,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
const target = (0, utilities_1.resolveInjectTarget)({ target: declared });
|
|
30
|
-
if (target === undefined) {
|
|
31
|
-
throw (0, error_1.getError)({
|
|
32
|
-
message: `[${cls.name}] ${at} names a function that did not return a class`,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
const recorded = this.getMetadataRegistry().getBindingKey({ target }) ?? key;
|
|
36
|
-
if (recorded === undefined && isOptional) {
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
if (recorded === undefined) {
|
|
40
|
-
throw (0, error_1.getError)({
|
|
41
|
-
message: `[${cls.name}] ${at} names '${target.name}', which is not registered as an artifact | Decorate it (@service, @repository, ...) or register it on the application before it is injected`,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
// A same-name class records the same derived key (a library's own copy of a class the application registers): resolving it would hand back the OTHER class without a word.
|
|
45
|
-
const bound = this.getBinding({ key: recorded })?.boundClass();
|
|
46
|
-
if (bound && bound !== target && !(bound.prototype instanceof target)) {
|
|
47
|
-
throw (0, error_1.getError)({
|
|
48
|
-
message: `[${cls.name}] ${at} names '${target.name}', but '${String(recorded)}' is bound to a different class named '${bound.name}' | Two classes share one name and so one key - rename one, re-export the registered one, or inject by key`,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return recorded;
|
|
52
|
-
}
|
|
53
|
-
instantiate(cls) {
|
|
54
|
-
const registry = this.getMetadataRegistry();
|
|
55
|
-
const injectMetadata = registry.getInjectMetadata({
|
|
56
|
-
target: cls,
|
|
57
|
-
});
|
|
58
|
-
const args = [];
|
|
59
|
-
for (let index = 0; index < (injectMetadata?.length ?? 0); index++) {
|
|
60
|
-
const meta = injectMetadata?.[index];
|
|
61
|
-
if (!meta) {
|
|
62
|
-
throw (0, error_1.getError)({
|
|
63
|
-
message: `[${cls.name}] Constructor parameter ${index} has no @inject | Every parameter of a container-instantiated class must be decorated - the container cannot supply an undecorated one`,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
const isOptional = meta.isOptional ?? false;
|
|
67
|
-
const key = this.resolveBindingKey({
|
|
68
|
-
key: meta.key,
|
|
69
|
-
target: meta.target,
|
|
70
|
-
isOptional,
|
|
71
|
-
cls,
|
|
72
|
-
at: `Constructor parameter ${index}`,
|
|
73
|
-
});
|
|
74
|
-
args[meta.index] = key === undefined ? undefined : this.get({ key, isOptional });
|
|
75
|
-
}
|
|
76
|
-
const instance = new cls(...args);
|
|
77
|
-
const propertyMetadata = registry.getPropertiesMetadata({
|
|
78
|
-
target: instance,
|
|
79
|
-
});
|
|
80
|
-
if (!propertyMetadata?.size) {
|
|
81
|
-
return instance;
|
|
82
|
-
}
|
|
83
|
-
const properties = propertyMetadata.entries();
|
|
84
|
-
for (const [propertyKey, metadata] of properties) {
|
|
85
|
-
const isOptional = metadata.isOptional ?? false;
|
|
86
|
-
const key = this.resolveBindingKey({
|
|
87
|
-
key: metadata.bindingKey,
|
|
88
|
-
target: metadata.target,
|
|
89
|
-
isOptional,
|
|
90
|
-
cls,
|
|
91
|
-
at: `Property '${String(propertyKey)}'`,
|
|
92
|
-
});
|
|
93
|
-
instance[propertyKey] =
|
|
94
|
-
key === undefined ? undefined : this.get({ key, isOptional });
|
|
95
|
-
}
|
|
96
|
-
return instance;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.Container = Container;
|
|
100
|
-
//# sourceMappingURL=container.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../../src/modules/container/container.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AAEpC,kDAAyD;AACzD,iCAAuC;AAEvC,qGAAqG;AACrG,MAAa,SAAU,SAAQ,oBAAa;IAC1C,YAAY,IAAwB;QAClC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;OAMG;IACO,iBAAiB,CAAC,IAM3B;Q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AC,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;QACnF,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;QAElC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,qBAAqB,CAAC;YACtD,MAAM,EAAE,QAAkB;SAC3B,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC;YAC5B,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAC9C,KAAK,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,UAAU,EAAE,CAAC;YACjD,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,KAAK,CAAC;YAChD,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC;gBACjC,GAAG,EAAE,QAAQ,CAAC,UAAU;gBACxB,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,UAAU;gBACV,GAAG;gBACH,EAAE,EAAE,aAAa,MAAM,CAAC,WAAW,CAAC,GAAG;aACxC,CAAC,CAAC;YAEF,QAAgB,CAAC,WAAW,CAAC;gBAC5B,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AArHD,8BAqHC","sourcesContent":["import { getError } from '../error';\nimport { type AnyType, type TBindingKey, type TClass, type TInjectTarget } from '@/common/types';\nimport { resolveInjectTarget } from '@/common/utilities';\nimport { BaseContainer } from './base';\n\n/** Default container: constructor + property injection driven by the decorator metadata registry. */\nexport class Container extends BaseContainer {\n constructor(opts?: { scope: string }) {\n super({ scope: opts?.scope ?? Container.name });\n }\n\n /**\n * The class form reads the key the REGISTRATION recorded, so a call-site override and an imperative\n * `application.service(X)` both resolve. `@inject` takes a key or a class; metadata a framework\n * writes may carry both, and then the class wins and the key is the fallback for a class nothing\n * recorded - one bound by hand with `bind({ key }).toClass(X)`. An optional class with neither\n * resolves to `undefined`, as an optional key would.\n */\n protected resolveBindingKey(opts: {\n key?: TBindingKey;\n target?: TInjectTarget;\n isOptional?: boolean;\n cls: TClass<AnyType>;\n at: string;\n }): TBindingKey | undefined {\n const { key, target: declared, isOptional = false, cls, at } = opts;\n\n if (declared === undefined && key !== undefined) {\n return key;\n }\n\n if (declared === undefined) {\n throw getError({\n message: `[${cls.name}] ${at} has neither an @inject key nor a class`,\n });\n }\n\n const target = resolveInjectTarget({ target: declared });\n if (target === undefined) {\n throw getError({\n message: `[${cls.name}] ${at} names a function that did not return a class`,\n });\n }\n\n const recorded = this.getMetadataRegistry().getBindingKey({ target }) ?? key;\n if (recorded === undefined && isOptional) {\n return undefined;\n }\n\n if (recorded === undefined) {\n throw getError({\n message: `[${cls.name}] ${at} names '${target.name}', which is not registered as an artifact | Decorate it (@service, @repository, ...) or register it on the application before it is injected`,\n });\n }\n\n // A same-name class records the same derived key (a library's own copy of a class the application registers): resolving it would hand back the OTHER class without a word.\n const bound = this.getBinding({ key: recorded })?.boundClass();\n if (bound && bound !== target && !(bound.prototype instanceof target)) {\n throw getError({\n message: `[${cls.name}] ${at} names '${target.name}', but '${String(recorded)}' is bound to a different class named '${bound.name}' | Two classes share one name and so one key - rename one, re-export the registered one, or inject by key`,\n });\n }\n\n return recorded;\n }\n\n override instantiate<T>(cls: TClass<T>): T {\n const registry = this.getMetadataRegistry();\n\n const injectMetadata = registry.getInjectMetadata({\n target: cls,\n });\n\n const args: any[] = [];\n\n for (let index = 0; index < (injectMetadata?.length ?? 0); index++) {\n const meta = injectMetadata?.[index];\n\n if (!meta) {\n throw getError({\n message: `[${cls.name}] Constructor parameter ${index} has no @inject | Every parameter of a container-instantiated class must be decorated - the container cannot supply an undecorated one`,\n });\n }\n\n const isOptional = meta.isOptional ?? false;\n const key = this.resolveBindingKey({\n key: meta.key,\n target: meta.target,\n isOptional,\n cls,\n at: `Constructor parameter ${index}`,\n });\n\n args[meta.index] = key === undefined ? undefined : this.get({ key, isOptional });\n }\n\n const instance = new cls(...args);\n\n const propertyMetadata = registry.getPropertiesMetadata({\n target: instance as object,\n });\n\n if (!propertyMetadata?.size) {\n return instance;\n }\n\n const properties = propertyMetadata.entries();\n for (const [propertyKey, metadata] of properties) {\n const isOptional = metadata.isOptional ?? false;\n const key = this.resolveBindingKey({\n key: metadata.bindingKey,\n target: metadata.target,\n isOptional,\n cls,\n at: `Property '${String(propertyKey)}'`,\n });\n\n (instance as any)[propertyKey] =\n key === undefined ? undefined : this.get({ key, isOptional });\n }\n\n return instance;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/container/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./abstract"), exports);
|
|
18
|
-
__exportStar(require("./base"), exports);
|
|
19
|
-
__exportStar(require("./common"), exports);
|
|
20
|
-
__exportStar(require("./container"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/container/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,yCAAuB;AACvB,2CAAyB;AACzB,8CAA4B","sourcesContent":["export * from './abstract';\nexport * from './base';\nexport * from './common';\nexport * from './container';\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { TError, TErrorLogLevel, TErrorNormalized, TResponsedError } from './common';
|
|
2
|
-
export declare class ApplicationError extends Error {
|
|
3
|
-
statusCode: number;
|
|
4
|
-
normalized: TErrorNormalized;
|
|
5
|
-
extra?: Record<string, unknown>;
|
|
6
|
-
readonly logLevel?: TErrorLogLevel;
|
|
7
|
-
constructor(opts: TError);
|
|
8
|
-
/**
|
|
9
|
-
* The message with its args filled in: `Only 2 left of TRA-01`. `message` itself stays the template,
|
|
10
|
-
* so a log or an error tracker never prints a value outside the args it redacts by key - call this
|
|
11
|
-
* where a plain reader stores or shows the text, such as a queue's failure reason.
|
|
12
|
-
*/
|
|
13
|
-
toFilledText(): string;
|
|
14
|
-
static getError(opts: TError): ApplicationError;
|
|
15
|
-
static fromError(opts: {
|
|
16
|
-
error: TResponsedError;
|
|
17
|
-
}): ApplicationError;
|
|
18
|
-
}
|
|
19
|
-
export declare const getError: (opts: TError) => ApplicationError;
|
|
20
|
-
export declare const fromError: (opts: {
|
|
21
|
-
error: TResponsedError;
|
|
22
|
-
}) => ApplicationError;
|
|
23
|
-
/**
|
|
24
|
-
* An `ApplicationError` by shape - a numeric `statusCode` and a `normalized` with its `text` - so it
|
|
25
|
-
* holds across the CJS and ESM copies of this class, where `instanceof` does not. A plain `Error`
|
|
26
|
-
* that merely carries a `statusCode` (an HTTP client's, an engine's) is not one.
|
|
27
|
-
*
|
|
28
|
-
* An error from a copy older than 0.2.2-0 matches but has no `toFilledText()`.
|
|
29
|
-
*/
|
|
30
|
-
export declare const isApplicationError: (error: unknown) => error is ApplicationError;
|
|
31
|
-
export type TApplicationError = ApplicationError;
|
|
32
|
-
//# sourceMappingURL=app-error.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-error.d.ts","sourceRoot":"","sources":["../../../../src/modules/error/app-error.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAgB1F,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;gBAEvB,IAAI,EAAE,MAAM;IA2CxB;;;;OAIG;IACH,YAAY,IAAI,MAAM;IAItB,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM;IAI5B,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,eAAe,CAAA;KAAE,GAAG,gBAAgB;CAcrE;AAED,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,gBAAmD,CAAC;AAE5F,eAAO,MAAM,SAAS,GAAI,MAAM;IAAE,KAAK,EAAE,eAAe,CAAA;CAAE,KAAG,gBAC3B,CAAC;AAEnC;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,gBAa5D,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isApplicationError = exports.fromError = exports.getError = exports.ApplicationError = void 0;
|
|
4
|
-
const utilities_1 = require("../../common/utilities");
|
|
5
|
-
const message_code_1 = require("./message-code");
|
|
6
|
-
const message_template_1 = require("./message-template");
|
|
7
|
-
/** Consumed keys. Everything else rides into `extra`. */
|
|
8
|
-
const KNOWN_KEYS = [
|
|
9
|
-
'error',
|
|
10
|
-
'message',
|
|
11
|
-
'messageCode',
|
|
12
|
-
'statusCode',
|
|
13
|
-
'messageArgs',
|
|
14
|
-
'cause',
|
|
15
|
-
'extra',
|
|
16
|
-
'transform',
|
|
17
|
-
'logLevel',
|
|
18
|
-
'name',
|
|
19
|
-
];
|
|
20
|
-
class ApplicationError extends Error {
|
|
21
|
-
constructor(opts) {
|
|
22
|
-
const { statusCode, messageArgs, cause, extra, transform, logLevel } = opts;
|
|
23
|
-
// Index signature defeats `in` narrowing - read the discriminant and cast.
|
|
24
|
-
const definition = 'error' in opts ? opts.error : undefined;
|
|
25
|
-
const input = opts.message;
|
|
26
|
-
const override = typeof input === 'string' ? { text: input } : input;
|
|
27
|
-
// `?.message?.` has to guard BOTH: `error` reaches here from an untyped call site as anything at all, and a bare `definition?.message.text` throws on a malformed one.
|
|
28
|
-
const message = override?.text ?? definition?.message?.text ?? '';
|
|
29
|
-
const messageCode = message_code_1.MessageCode.resolve(override?.code ?? definition?.message?.code ?? opts.messageCode);
|
|
30
|
-
const args = override?.args ?? messageArgs ?? definition?.message?.args;
|
|
31
|
-
super(message, cause === undefined ? undefined : { cause });
|
|
32
|
-
this.statusCode = statusCode ?? definition?.statusCode ?? 400;
|
|
33
|
-
this.logLevel = logLevel;
|
|
34
|
-
// Explicit `extra` wins over swept keys.
|
|
35
|
-
const merged = {
|
|
36
|
-
...(0, utilities_1.omit)({ source: opts, keys: KNOWN_KEYS }),
|
|
37
|
-
...extra,
|
|
38
|
-
};
|
|
39
|
-
this.extra = Object.keys(merged).length > 0 ? merged : undefined;
|
|
40
|
-
const normalized = {
|
|
41
|
-
text: message,
|
|
42
|
-
code: messageCode,
|
|
43
|
-
args: args ?? {},
|
|
44
|
-
};
|
|
45
|
-
this.normalized = transform
|
|
46
|
-
? transform({
|
|
47
|
-
message: normalized,
|
|
48
|
-
statusCode: this.statusCode,
|
|
49
|
-
extra: this.extra,
|
|
50
|
-
})
|
|
51
|
-
: normalized;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* The message with its args filled in: `Only 2 left of TRA-01`. `message` itself stays the template,
|
|
55
|
-
* so a log or an error tracker never prints a value outside the args it redacts by key - call this
|
|
56
|
-
* where a plain reader stores or shows the text, such as a queue's failure reason.
|
|
57
|
-
*/
|
|
58
|
-
toFilledText() {
|
|
59
|
-
return message_template_1.MessageTemplate.render({ text: this.message, args: this.normalized.args }).text;
|
|
60
|
-
}
|
|
61
|
-
static getError(opts) {
|
|
62
|
-
return new ApplicationError(opts);
|
|
63
|
-
}
|
|
64
|
-
static fromError(opts) {
|
|
65
|
-
const { error } = opts;
|
|
66
|
-
return this.getError({
|
|
67
|
-
message: {
|
|
68
|
-
text: error.normalized?.text ?? error.message ?? '',
|
|
69
|
-
code: error.normalized?.code,
|
|
70
|
-
args: error.normalized?.args,
|
|
71
|
-
},
|
|
72
|
-
statusCode: error.statusCode,
|
|
73
|
-
extra: error.extra,
|
|
74
|
-
...(error.requestId === undefined ? {} : { requestId: error.requestId }),
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.ApplicationError = ApplicationError;
|
|
79
|
-
const getError = (opts) => ApplicationError.getError(opts);
|
|
80
|
-
exports.getError = getError;
|
|
81
|
-
const fromError = (opts) => ApplicationError.fromError(opts);
|
|
82
|
-
exports.fromError = fromError;
|
|
83
|
-
/**
|
|
84
|
-
* An `ApplicationError` by shape - a numeric `statusCode` and a `normalized` with its `text` - so it
|
|
85
|
-
* holds across the CJS and ESM copies of this class, where `instanceof` does not. A plain `Error`
|
|
86
|
-
* that merely carries a `statusCode` (an HTTP client's, an engine's) is not one.
|
|
87
|
-
*
|
|
88
|
-
* An error from a copy older than 0.2.2-0 matches but has no `toFilledText()`.
|
|
89
|
-
*/
|
|
90
|
-
const isApplicationError = (error) => {
|
|
91
|
-
if (!(error instanceof Error) || !('statusCode' in error) || !('normalized' in error)) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
const { statusCode, normalized } = error;
|
|
95
|
-
return (typeof statusCode === 'number' &&
|
|
96
|
-
typeof normalized === 'object' &&
|
|
97
|
-
normalized !== null &&
|
|
98
|
-
'text' in normalized &&
|
|
99
|
-
typeof normalized.text === 'string');
|
|
100
|
-
};
|
|
101
|
-
exports.isApplicationError = isApplicationError;
|
|
102
|
-
//# sourceMappingURL=app-error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-error.js","sourceRoot":"","sources":["../../../../src/modules/error/app-error.ts"],"names":[],"mappings":";;;AACA,kDAA0C;AAC1C,iDAA6C;AAC7C,yDAAqD;AAGrD,yDAAyD;AACzD,MAAM,UAAU,GAAG;IACjB,OAAO;IACP,SAAS;IACT,aAAa;IACb,YAAY;IACZ,aAAa;IACb,OAAO;IACP,OAAO;IACP,WAAW;IACX,UAAU;IACV,MAAM;CACE,CAAC;AAEX,MAAa,gBAAiB,SAAQ,KAAK;IAMzC,YAAY,IAAY;QACtB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAE5E,2EAA2E;QAC3E,MAAM,UAAU,GAAG,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAE5D,MAAM,KAAK,GAAG,IAAI,CAAC,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,SAAS,CAAC,IAAI,CAAC,CAAC;AADtB,QAAA,SAAS,aACa;AAEnC;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAA6B,EAAE;IAC9E,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,KAAK,CAAC,EAAE,CAAC;QACtF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IACzC,OAAO,CACL,OAAO,UAAU,KAAK,QAAQ;QAC9B,OAAO,UAAU,KAAK,QAAQ;QAC9B,UAAU,KAAK,IAAI;QACnB,MAAM,IAAI,UAAU;QACpB,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,CACpC,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,kBAAkB,sBAa7B","sourcesContent":["import { type TNullable } from '@/common/types';\nimport { omit } from '@/common/utilities';\nimport { MessageCode } from './message-code';\nimport { MessageTemplate } from './message-template';\nimport type { TError, TErrorLogLevel, TErrorNormalized, TResponsedError } from './common';\n\n/** Consumed keys. Everything else rides into `extra`. */\nconst KNOWN_KEYS = [\n 'error',\n 'message',\n 'messageCode',\n 'statusCode',\n 'messageArgs',\n 'cause',\n 'extra',\n 'transform',\n 'logLevel',\n 'name',\n] as const;\n\nexport class ApplicationError extends Error {\n statusCode: number;\n normalized: TErrorNormalized;\n extra?: Record<string, unknown>;\n readonly logLevel?: TErrorLogLevel;\n\n constructor(opts: TError) {\n const { statusCode, messageArgs, cause, extra, transform, logLevel } = opts;\n\n // Index signature defeats `in` narrowing - read the discriminant and cast.\n const definition = 'error' in opts ? opts.error : undefined;\n\n const input = opts.message;\n const override = typeof input === 'string' ? { text: input } : input;\n\n // `?.message?.` has to guard BOTH: `error` reaches here from an untyped call site as anything at all, and a bare `definition?.message.text` throws on a malformed one.\n const message = override?.text ?? definition?.message?.text ?? '';\n const messageCode = MessageCode.resolve(\n override?.code ?? definition?.message?.code ?? (opts.messageCode as TNullable<string>),\n );\n const args = override?.args ?? messageArgs ?? definition?.message?.args;\n\n super(message, cause === undefined ? undefined : { cause });\n\n this.statusCode = statusCode ?? definition?.statusCode ?? 400;\n this.logLevel = logLevel;\n\n // Explicit `extra` wins over swept keys.\n const merged = {\n ...omit({ source: opts, keys: KNOWN_KEYS }),\n ...extra,\n };\n this.extra = Object.keys(merged).length > 0 ? merged : undefined;\n\n const normalized: TErrorNormalized = {\n text: message,\n code: messageCode,\n args: args ?? {},\n };\n\n this.normalized = transform\n ? transform({\n message: normalized,\n statusCode: this.statusCode,\n extra: this.extra,\n })\n : normalized;\n }\n\n /**\n * The message with its args filled in: `Only 2 left of TRA-01`. `message` itself stays the template,\n * so a log or an error tracker never prints a value outside the args it redacts by key - call this\n * where a plain reader stores or shows the text, such as a queue's failure reason.\n */\n toFilledText(): string {\n return MessageTemplate.render({ text: this.message, args: this.normalized.args }).text;\n }\n\n static getError(opts: TError) {\n return new ApplicationError(opts);\n }\n\n static fromError(opts: { error: TResponsedError }): ApplicationError {\n const { error } = opts;\n\n return this.getError({\n message: {\n text: error.normalized?.text ?? error.message ?? '',\n code: error.normalized?.code,\n args: error.normalized?.args,\n },\n statusCode: error.statusCode,\n extra: error.extra,\n ...(error.requestId === undefined ? {} : { requestId: error.requestId }),\n });\n }\n}\n\nexport const getError = (opts: TError): ApplicationError => ApplicationError.getError(opts);\n\nexport const fromError = (opts: { error: TResponsedError }): ApplicationError =>\n ApplicationError.fromError(opts);\n\n/**\n * An `ApplicationError` by shape - a numeric `statusCode` and a `normalized` with its `text` - so it\n * holds across the CJS and ESM copies of this class, where `instanceof` does not. A plain `Error`\n * that merely carries a `statusCode` (an HTTP client's, an engine's) is not one.\n *\n * An error from a copy older than 0.2.2-0 matches but has no `toFilledText()`.\n */\nexport const isApplicationError = (error: unknown): error is ApplicationError => {\n if (!(error instanceof Error) || !('statusCode' in error) || !('normalized' in error)) {\n return false;\n }\n\n const { statusCode, normalized } = error;\n return (\n typeof statusCode === 'number' &&\n typeof normalized === 'object' &&\n normalized !== null &&\n 'text' in normalized &&\n typeof normalized.text === 'string'\n );\n};\n\nexport type TApplicationError = ApplicationError;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/error/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/error/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB","sourcesContent":["export * from './types';\n"]}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { TErrorScope } from '../definition';
|
|
2
|
-
/** Declared here, not imported from helpers' `TLogLevel` (browser-safe); a helpers guard pins them equal. */
|
|
3
|
-
export type TErrorLogLevel = 'error' | 'emerg' | 'warn' | 'info' | 'debug';
|
|
4
|
-
/** Resolved message a client renders. All fields always present - no null-checks downstream. */
|
|
5
|
-
export type TErrorNormalized = {
|
|
6
|
-
text: string;
|
|
7
|
-
code: string;
|
|
8
|
-
args: Record<string, unknown>;
|
|
9
|
-
};
|
|
10
|
-
/** Wire payload as a CLIENT receives it - the input to {@link ApplicationError.fromError}. Every field is optional on purpose: a client parses what a gateway, a proxy or an older server actually sent. */
|
|
11
|
-
export type TResponsedError = {
|
|
12
|
-
message?: string;
|
|
13
|
-
statusCode?: number;
|
|
14
|
-
normalized?: Partial<TErrorNormalized>;
|
|
15
|
-
extra?: Record<string, unknown>;
|
|
16
|
-
requestId?: string;
|
|
17
|
-
details?: Record<string, unknown>;
|
|
18
|
-
};
|
|
19
|
-
/** The message a CALLER supplies - only `text` is required, the rest is what {@link TErrorNormalized} resolves; every other message shape is derived from this one. */
|
|
20
|
-
export type TErrorMessageInput = {
|
|
21
|
-
text: string;
|
|
22
|
-
code?: TErrorKey | (string & Record<never, never>);
|
|
23
|
-
args?: Record<string, unknown>;
|
|
24
|
-
};
|
|
25
|
-
/** Catalogued message - `code` required, typed `string` and not {@link TErrorKey}: catalogs DECLARE the registry keys, so typing against the registry would be self-referential. */
|
|
26
|
-
export type TErrorDefinitionMessage = Omit<TErrorMessageInput, 'code'> & {
|
|
27
|
-
code: string;
|
|
28
|
-
};
|
|
29
|
-
/** The free-form input: a bare string is the historical shape. */
|
|
30
|
-
export type TErrorMessage = string | TErrorMessageInput;
|
|
31
|
-
/** The catalogued form's override - every field optional, since the definition supplies the rest. */
|
|
32
|
-
export type TErrorMessageOverride = string | Partial<TErrorMessageInput>;
|
|
33
|
-
export type TErrorDefinition = {
|
|
34
|
-
message: TErrorDefinitionMessage;
|
|
35
|
-
statusCode: number;
|
|
36
|
-
category?: TErrorScope;
|
|
37
|
-
description?: string;
|
|
38
|
-
};
|
|
39
|
-
/** Augmented per-package via declaration merging, driving `messageCode` autocomplete. */
|
|
40
|
-
export interface IErrorKeyRegistry {
|
|
41
|
-
}
|
|
42
|
-
export type TErrorKey = [keyof IErrorKeyRegistry] extends [never] ? string : Extract<keyof IErrorKeyRegistry, string>;
|
|
43
|
-
/** Builds {@link TErrorNormalized} in place of the default; `message` is the default it replaces. */
|
|
44
|
-
export type TErrorNormalizeTransformFn = (opts: {
|
|
45
|
-
message: TErrorNormalized;
|
|
46
|
-
statusCode: number;
|
|
47
|
-
extra?: Record<string, unknown>;
|
|
48
|
-
}) => TErrorNormalized;
|
|
49
|
-
/** Shared by both input forms - unknown keys ride the index signature into `extra`, so a throw site can attach context the framework does not model, and so does a mistyped key. */
|
|
50
|
-
type TErrorCommon = {
|
|
51
|
-
statusCode?: number;
|
|
52
|
-
messageArgs?: Record<string, unknown>;
|
|
53
|
-
cause?: unknown;
|
|
54
|
-
extra?: Record<string, unknown>;
|
|
55
|
-
transform?: TErrorNormalizeTransformFn;
|
|
56
|
-
logLevel?: TErrorLogLevel;
|
|
57
|
-
};
|
|
58
|
-
/** Catalogued form - `message` and `statusCode` override the definition's defaults; the object form is partial, so `{ message: { args } }` amends the args and keeps the definition's text and code. */
|
|
59
|
-
export type TErrorByDefinition = TErrorCommon & {
|
|
60
|
-
error: TErrorDefinition;
|
|
61
|
-
message?: TErrorMessageOverride;
|
|
62
|
-
[key: string]: unknown;
|
|
63
|
-
};
|
|
64
|
-
/** Free-form: an invariant, a misconfiguration, a failure carrying no i18n code. `message` is the only required field - most throw sites legitimately fall back to `MessageCode.DEFAULT`. */
|
|
65
|
-
export type TErrorByField = TErrorCommon & {
|
|
66
|
-
message: TErrorMessage;
|
|
67
|
-
messageCode?: TErrorKey | (string & Record<never, never>);
|
|
68
|
-
/** Never valid here - `error` is the catalogued form's discriminant and a CONSUMED key, so a wrapped failure passed as `error` would vanish; use `cause`. */
|
|
69
|
-
error?: never;
|
|
70
|
-
[key: string]: unknown;
|
|
71
|
-
};
|
|
72
|
-
export type TError = TErrorByDefinition | TErrorByField;
|
|
73
|
-
/** Registers a catalog's keys with {@link IErrorKeyRegistry}, via `declare module '@venizia/ignis-helpers' { interface IErrorKeyRegistry extends TRegisterErrors<typeof CategoryErrors> {} }`. */
|
|
74
|
-
export type TRegisterErrors<T extends Record<string, TErrorDefinition>> = Record<T[keyof T]['message']['code'], true>;
|
|
75
|
-
export {};
|
|
76
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/modules/error/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,6GAA6G;AAC7G,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3E,gGAAgG;AAChG,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,CAAC;AAEF,4MAA4M;AAC5M,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF,uKAAuK;AACvK,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,SAA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AChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,0BAA0B,CAAC;IACvC,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;AAEF,wMAAwM;AACxM,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG;IAC9C,KAAK,EAAE,gBAAgB,CAAC;IACxB,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,6LAA6L;AAC7L,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG;IACzC,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,SAAS,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAC1D,6JAA6J;IAC7J,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,kBAAkB,GAAG,aAAa,CAAC;AAExD,kMAAkM;AAClM,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,MAAM,CAC9E,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EAC7B,IAAI,CACL,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/error/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TErrorScope } from '../definition';\n\n/** Declared here, not imported from helpers' `TLogLevel` (browser-safe); a helpers guard pins them equal. */\nexport type TErrorLogLevel = 'error' | 'emerg' | 'warn' | 'info' | 'debug';\n\n/** Resolved message a client renders. All fields always present - no null-checks downstream. */\nexport type TErrorNormalized = {\n text: string;\n code: string;\n args: Record<string, unknown>;\n};\n\n/** Wire payload as a CLIENT receives it - the input to {@link ApplicationError.fromError}. Every field is optional on purpose: a client parses what a gateway, a proxy or an older server actually sent. */\nexport type TResponsedError = {\n message?: string;\n statusCode?: number;\n normalized?: Partial<TErrorNormalized>;\n extra?: Record<string, unknown>;\n requestId?: string;\n details?: Record<string, unknown>;\n};\n\n/** The message a CALLER supplies - only `text` is required, the rest is what {@link TErrorNormalized} resolves; every other message shape is derived from this one. */\nexport type TErrorMessageInput = {\n text: string;\n code?: TErrorKey | (string & Record<never, never>);\n args?: Record<string, unknown>;\n};\n\n/** Catalogued message - `code` required, typed `string` and not {@link TErrorKey}: catalogs DECLARE the registry keys, so typing against the registry would be self-referential. */\nexport type TErrorDefinitionMessage = Omit<TErrorMessageInput, 'code'> & { code: string };\n\n/** The free-form input: a bare string is the historical shape. */\nexport type TErrorMessage = string | TErrorMessageInput;\n\n/** The catalogued form's override - every field optional, since the definition supplies the rest. */\nexport type TErrorMessageOverride = string | Partial<TErrorMessageInput>;\n\nexport type TErrorDefinition = {\n message: TErrorDefinitionMessage;\n statusCode: number;\n category?: TErrorScope;\n description?: string;\n};\n\n/** Augmented per-package via declaration merging, driving `messageCode` autocomplete. */\nexport interface IErrorKeyRegistry {}\n\nexport type TErrorKey = [keyof IErrorKeyRegistry] extends [never]\n ? string\n : Extract<keyof IErrorKeyRegistry, string>;\n\n/** Builds {@link TErrorNormalized} in place of the default; `message` is the default it replaces. */\nexport type TErrorNormalizeTransformFn = (opts: {\n message: TErrorNormalized;\n statusCode: number;\n extra?: Record<string, unknown>;\n}) => TErrorNormalized;\n\n/** Shared by both input forms - unknown keys ride the index signature into `extra`, so a throw site can attach context the framework does not model, and so does a mistyped key. */\ntype TErrorCommon = {\n statusCode?: number;\n messageArgs?: Record<string, unknown>;\n cause?: unknown;\n extra?: Record<string, unknown>;\n transform?: TErrorNormalizeTransformFn;\n logLevel?: TErrorLogLevel; // Default: error\n};\n\n/** Catalogued form - `message` and `statusCode` override the definition's defaults; the object form is partial, so `{ message: { args } }` amends the args and keeps the definition's text and code. */\nexport type TErrorByDefinition = TErrorCommon & {\n error: TErrorDefinition;\n message?: TErrorMessageOverride;\n [key: string]: unknown;\n};\n\n/** Free-form: an invariant, a misconfiguration, a failure carrying no i18n code. `message` is the only required field - most throw sites legitimately fall back to `MessageCode.DEFAULT`. */\nexport type TErrorByField = TErrorCommon & {\n message: TErrorMessage;\n messageCode?: TErrorKey | (string & Record<never, never>);\n /** Never valid here - `error` is the catalogued form's discriminant and a CONSUMED key, so a wrapped failure passed as `error` would vanish; use `cause`. */\n error?: never;\n [key: string]: unknown;\n};\n\nexport type TError = TErrorByDefinition | TErrorByField;\n\n/** Registers a catalog's keys with {@link IErrorKeyRegistry}, via `declare module '@venizia/ignis-helpers' { interface IErrorKeyRegistry extends TRegisterErrors<typeof CategoryErrors> {} }`. */\nexport type TRegisterErrors<T extends Record<string, TErrorDefinition>> = Record<\n T[keyof T]['message']['code'],\n true\n>;\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { TConstValue } from '../../common/types';
|
|
2
|
-
export declare class ErrorScopes {
|
|
3
|
-
static readonly AUTH = "auth";
|
|
4
|
-
static readonly VALIDATION = "validation";
|
|
5
|
-
static readonly BUSINESS = "business";
|
|
6
|
-
static readonly SYSTEM = "system";
|
|
7
|
-
static readonly INTEGRATION = "integration";
|
|
8
|
-
}
|
|
9
|
-
export type TErrorScope = TConstValue<typeof ErrorScopes>;
|
|
10
|
-
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../../src/modules/error/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,qBAAa,WAAW;IACtB,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,UAAU,gBAAgB;IAC1C,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAAc;IACtC,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,WAAW,iBAAiB;CAC7C;AAED,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorScopes = void 0;
|
|
4
|
-
class ErrorScopes {
|
|
5
|
-
static { this.AUTH = 'auth'; }
|
|
6
|
-
static { this.VALIDATION = 'validation'; }
|
|
7
|
-
static { this.BUSINESS = 'business'; }
|
|
8
|
-
static { this.SYSTEM = 'system'; }
|
|
9
|
-
static { this.INTEGRATION = 'integration'; }
|
|
10
|
-
}
|
|
11
|
-
exports.ErrorScopes = ErrorScopes;
|
|
12
|
-
//# sourceMappingURL=definition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../../src/modules/error/definition.ts"],"names":[],"mappings":";;;AAEA,MAAa,WAAW;aACN,SAAI,GAAG,MAAM,CAAC;aACd,eAAU,GAAG,YAAY,CAAC;aAC1B,aAAQ,GAAG,UAAU,CAAC;aACtB,WAAM,GAAG,QAAQ,CAAC;aAClB,gBAAW,GAAG,aAAa,CAAC;;AAL9C,kCAMC","sourcesContent":["import type { TConstValue } from '@/common/types';\n\nexport class ErrorScopes {\n static readonly AUTH = 'auth';\n static readonly VALIDATION = 'validation';\n static readonly BUSINESS = 'business';\n static readonly SYSTEM = 'system';\n static readonly INTEGRATION = 'integration';\n}\n\nexport type TErrorScope = TConstValue<typeof ErrorScopes>;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/error/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./app-error"), exports);
|
|
18
|
-
__exportStar(require("./common"), exports);
|
|
19
|
-
__exportStar(require("./definition"), exports);
|
|
20
|
-
__exportStar(require("./message-code"), exports);
|
|
21
|
-
__exportStar(require("./message-template"), exports);
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,2CAAyB;AACzB,+CAA6B;AAC7B,iDAA+B;AAC/B,qDAAmC","sourcesContent":["export * from './app-error';\nexport * from './common';\nexport * from './definition';\nexport * from './message-code';\nexport * from './message-template';\n"]}
|