@venizia/ignis-inversion 0.4.3 → 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/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/constants.d.ts +0 -14
- package/dist/cjs/modules/error/common/constants.d.ts.map +0 -1
- package/dist/cjs/modules/error/common/constants.js +0 -23
- package/dist/cjs/modules/error/common/constants.js.map +0 -1
- package/dist/cjs/modules/error/common/index.d.ts +0 -3
- package/dist/cjs/modules/error/common/index.d.ts.map +0 -1
- package/dist/cjs/modules/error/common/index.js +0 -19
- package/dist/cjs/modules/error/common/index.js.map +0 -1
- package/dist/cjs/modules/error/common/types.d.ts +0 -75
- 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,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageCode = void 0;
|
|
4
|
-
class MessageCode {
|
|
5
|
-
static { this.SEPARATOR = '.'; }
|
|
6
|
-
static { this.SEGMENT_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/; }
|
|
7
|
-
static { this.MIN_SEGMENTS = 2; }
|
|
8
|
-
static { this.DEFAULT = 'core.system_error'; }
|
|
9
|
-
// The one permitted raw `new Error`, used only until `src/index.ts` registers `getError`.
|
|
10
|
-
static { this.errorFactory = (opts) =>
|
|
11
|
-
// eslint-disable-next-line venizia/no-new-error -- the bootstrap factory, replaced by getError at init
|
|
12
|
-
new Error(typeof opts.message === 'string' ? opts.message : JSON.stringify(opts.message)); }
|
|
13
|
-
/**
|
|
14
|
-
* Registered by the package entry at module init; keeps the throws identical without a
|
|
15
|
-
* static import of app-error (that import was the cycle).
|
|
16
|
-
* @internal Framework wiring; consumers must not replace the factory.
|
|
17
|
-
*/
|
|
18
|
-
static useErrorFactory(opts) {
|
|
19
|
-
this.errorFactory = opts.factory;
|
|
20
|
-
}
|
|
21
|
-
/** Builds a code from its segments, throwing on a malformed one - codes are declared at module scope, so a bad code fails the process at import instead of shipping dead into production. */
|
|
22
|
-
static build(opts) {
|
|
23
|
-
const { parts } = opts;
|
|
24
|
-
if (parts.length < this.MIN_SEGMENTS) {
|
|
25
|
-
throw this.errorFactory({
|
|
26
|
-
messageCode: 'core.message_code.invalid_segment_count',
|
|
27
|
-
message: `[MessageCode][build] A code needs at least ${this.MIN_SEGMENTS} segments (namespace + reason) | Got: ${JSON.stringify(parts)}`,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
for (const segment of parts) {
|
|
31
|
-
if (!this.SEGMENT_PATTERN.test(segment)) {
|
|
32
|
-
throw this.errorFactory({
|
|
33
|
-
messageCode: 'core.message_code.invalid_segment_format',
|
|
34
|
-
message: `[MessageCode][build] Invalid segment '${segment}' | Expected lower snake_case (a-z, 0-9, '_') | Full: ${JSON.stringify(parts)}`,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return parts.join(this.SEPARATOR).toLowerCase();
|
|
39
|
-
}
|
|
40
|
-
/** True when `code` is well-formed. Takes `unknown` because it guards codes arriving from outside - a guard that throws on the very input it exists to screen is not a guard. */
|
|
41
|
-
static isValid(code) {
|
|
42
|
-
if (typeof code !== 'string') {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
const segments = code.split(this.SEPARATOR);
|
|
46
|
-
return (segments.length >= this.MIN_SEGMENTS &&
|
|
47
|
-
segments.every((segment) => this.SEGMENT_PATTERN.test(segment)));
|
|
48
|
-
}
|
|
49
|
-
/** Normalizes an absent, empty or non-string code to {@link DEFAULT}. */
|
|
50
|
-
static resolve(code) {
|
|
51
|
-
return typeof code === 'string' && code.length
|
|
52
|
-
? code.toLowerCase()
|
|
53
|
-
: this.DEFAULT.toLowerCase();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.MessageCode = MessageCode;
|
|
57
|
-
//# sourceMappingURL=message-code.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message-code.js","sourceRoot":"","sources":["../../../../src/modules/error/message-code.ts"],"names":[],"mappings":";;;AAKA,MAAa,WAAW;aACN,cAAS,GAAG,GAAG,CAAC;aAChB,oBAAe,GAAG,0BAA0B,CAAC;aAC7C,iBAAY,GAAG,CAAC,CAAC;aACjB,YAAO,GAAG,mBAAmB,CAAC;IAE9C,0FAA0F;aAC3E,iBAAY,GA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QACf,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE5C,OAAO,CACL,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY;YACpC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAChE,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,MAAM,CAAC,OAAO,CAAC,IAAwB;QACrC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM;YAC5C,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE;YACpB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IACjC,CAAC;;AA9DH,kCA+DC","sourcesContent":["import type { TNullable } from '@/common/types';\nimport type { TError } from './common';\n\ntype TErrorFactory = (opts: TError) => Error;\n\nexport class MessageCode {\n static readonly SEPARATOR = '.';\n static readonly SEGMENT_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;\n static readonly MIN_SEGMENTS = 2;\n static readonly DEFAULT = 'core.system_error';\n\n // The one permitted raw `new Error`, used only until `src/index.ts` registers `getError`.\n private static errorFactory: TErrorFactory = (opts) =>\n // eslint-disable-next-line venizia/no-new-error -- the bootstrap factory, replaced by getError at init\n new Error(typeof opts.message === 'string' ? opts.message : JSON.stringify(opts.message));\n\n /**\n * Registered by the package entry at module init; keeps the throws identical without a\n * static import of app-error (that import was the cycle).\n * @internal Framework wiring; consumers must not replace the factory.\n */\n static useErrorFactory(opts: { factory: TErrorFactory }): void {\n this.errorFactory = opts.factory;\n }\n\n /** Builds a code from its segments, throwing on a malformed one - codes are declared at module scope, so a bad code fails the process at import instead of shipping dead into production. */\n static build(opts: { parts: Array<string> }): string {\n const { parts } = opts;\n\n if (parts.length < this.MIN_SEGMENTS) {\n throw this.errorFactory({\n messageCode: 'core.message_code.invalid_segment_count',\n message: `[MessageCode][build] A code needs at least ${this.MIN_SEGMENTS} segments (namespace + reason) | Got: ${JSON.stringify(parts)}`,\n });\n }\n\n for (const segment of parts) {\n if (!this.SEGMENT_PATTERN.test(segment)) {\n throw this.errorFactory({\n messageCode: 'core.message_code.invalid_segment_format',\n message: `[MessageCode][build] Invalid segment '${segment}' | Expected lower snake_case (a-z, 0-9, '_') | Full: ${JSON.stringify(parts)}`,\n });\n }\n }\n\n return parts.join(this.SEPARATOR).toLowerCase();\n }\n\n /** True when `code` is well-formed. Takes `unknown` because it guards codes arriving from outside - a guard that throws on the very input it exists to screen is not a guard. */\n static isValid(code: unknown): boolean {\n if (typeof code !== 'string') {\n return false;\n }\n\n const segments = code.split(this.SEPARATOR);\n\n return (\n segments.length >= this.MIN_SEGMENTS &&\n segments.every((segment) => this.SEGMENT_PATTERN.test(segment))\n );\n }\n\n /** Normalizes an absent, empty or non-string code to {@link DEFAULT}. */\n static resolve(code?: TNullable<string>): string {\n return typeof code === 'string' && code.length\n ? code.toLowerCase()\n : this.DEFAULT.toLowerCase();\n }\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fills a catalog template - `Only %{available} left of %{sku}` - from its args. The error keeps the
|
|
3
|
-
* template in `message` and `normalized.text`, so a log redacts values by key and a client can
|
|
4
|
-
* translate `code` + `args`; this is where a reader that wants the sentence gets it.
|
|
5
|
-
*/
|
|
6
|
-
export declare class MessageTemplate {
|
|
7
|
-
/**
|
|
8
|
-
* Each `%{key}` replaced by `String(args[key])`. A key with no arg (absent or `undefined`) stays as
|
|
9
|
-
* written and is listed in `missing`. Never throws: it runs inside the last-resort error handler.
|
|
10
|
-
*/
|
|
11
|
-
static render(opts: {
|
|
12
|
-
text: string;
|
|
13
|
-
args: unknown;
|
|
14
|
-
}): {
|
|
15
|
-
text: string;
|
|
16
|
-
missing: Array<string>;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=message-template.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message-template.d.ts","sourceRoot":"","sources":["../../../../src/modules/error/message-template.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,qBAAa,eAAe;IAC1B;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;KAAE;CAuB/F"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageTemplate = void 0;
|
|
4
|
-
/** `%{key}`: a placeholder a catalog message carries for one of its args. */
|
|
5
|
-
const PLACEHOLDER_PATTERN = /%\{(\w+)\}/g;
|
|
6
|
-
/**
|
|
7
|
-
* Fills a catalog template - `Only %{available} left of %{sku}` - from its args. The error keeps the
|
|
8
|
-
* template in `message` and `normalized.text`, so a log redacts values by key and a client can
|
|
9
|
-
* translate `code` + `args`; this is where a reader that wants the sentence gets it.
|
|
10
|
-
*/
|
|
11
|
-
class MessageTemplate {
|
|
12
|
-
/**
|
|
13
|
-
* Each `%{key}` replaced by `String(args[key])`. A key with no arg (absent or `undefined`) stays as
|
|
14
|
-
* written and is listed in `missing`. Never throws: it runs inside the last-resort error handler.
|
|
15
|
-
*/
|
|
16
|
-
static render(opts) {
|
|
17
|
-
const { text, args } = opts;
|
|
18
|
-
const values = typeof args === 'object' && args !== null ? args : {};
|
|
19
|
-
const missing = new Set();
|
|
20
|
-
const rendered = text.replace(PLACEHOLDER_PATTERN, (placeholder, key) => {
|
|
21
|
-
const value = Object.hasOwn(values, key) ? Reflect.get(values, key) : undefined;
|
|
22
|
-
if (value === undefined) {
|
|
23
|
-
missing.add(key);
|
|
24
|
-
return placeholder;
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
return String(value);
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
// A null-prototype object has no `toString`; leave its placeholder rather than fail.
|
|
31
|
-
return placeholder;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return { text: rendered, missing: [...missing] };
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.MessageTemplate = MessageTemplate;
|
|
38
|
-
//# sourceMappingURL=message-template.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message-template.js","sourceRoot":"","sources":["../../../../src/modules/error/message-template.ts"],"names":[],"mappings":";;;AAAA,6EAA6E;AAC7E,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAE1C;;;;GAIG;AACH,MAAa,eAAe;IAC1B;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,IAAqC;QACjD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAC5B,MAAM,MAAM,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACrE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,WAAW,EAAE,GAAW,EAAE,EAAE;YAC9E,MAAM,KAAK,GAAY,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAEzF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACjB,OAAO,WAAW,CAAC;YACrB,CAAC;YAED,IAAI,CAAC;gBACH,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;YAAC,MAAM,CAAC;gBACP,qFAAqF;gBACrF,OAAO,WAAW,CAAC;YACrB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC;IACnD,CAAC;CACF;AA5BD,0CA4BC","sourcesContent":["/** `%{key}`: a placeholder a catalog message carries for one of its args. */\nconst PLACEHOLDER_PATTERN = /%\\{(\\w+)\\}/g;\n\n/**\n * Fills a catalog template - `Only %{available} left of %{sku}` - from its args. The error keeps the\n * template in `message` and `normalized.text`, so a log redacts values by key and a client can\n * translate `code` + `args`; this is where a reader that wants the sentence gets it.\n */\nexport class MessageTemplate {\n /**\n * Each `%{key}` replaced by `String(args[key])`. A key with no arg (absent or `undefined`) stays as\n * written and is listed in `missing`. Never throws: it runs inside the last-resort error handler.\n */\n static render(opts: { text: string; args: unknown }): { text: string; missing: Array<string> } {\n const { text, args } = opts;\n const values = typeof args === 'object' && args !== null ? args : {};\n const missing = new Set<string>();\n\n const rendered = text.replace(PLACEHOLDER_PATTERN, (placeholder, key: string) => {\n const value: unknown = Object.hasOwn(values, key) ? Reflect.get(values, key) : undefined;\n\n if (value === undefined) {\n missing.add(key);\n return placeholder;\n }\n\n try {\n return String(value);\n } catch {\n // A null-prototype object has no `toString`; leave its placeholder rather than fail.\n return placeholder;\n }\n });\n\n return { text: rendered, missing: [...missing] };\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,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("./binding"), exports);
|
|
18
|
-
__exportStar(require("./container"), exports);
|
|
19
|
-
__exportStar(require("./error"), exports);
|
|
20
|
-
__exportStar(require("./metadata"), exports);
|
|
21
|
-
__exportStar(require("./registry"), exports);
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,8CAA4B;AAC5B,0CAAwB;AACxB,6CAA2B;AAC3B,6CAA2B","sourcesContent":["export * from './binding';\nexport * from './container';\nexport * from './error';\nexport * from './metadata';\nexport * from './registry';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/modules/metadata/common/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;CAIxB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MetadataKeys = void 0;
|
|
4
|
-
exports.MetadataKeys = {
|
|
5
|
-
PROPERTIES: Symbol.for('ignis:properties'),
|
|
6
|
-
INJECT: Symbol.for('ignis:inject'),
|
|
7
|
-
BINDING_KEY: Symbol.for('ignis:binding-key'),
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/metadata/common/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC;CAC7C,CAAC","sourcesContent":["export const MetadataKeys = {\n PROPERTIES: Symbol.for('ignis:properties'),\n INJECT: Symbol.for('ignis:inject'),\n BINDING_KEY: Symbol.for('ignis:binding-key'),\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/metadata/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,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("./constants"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/metadata/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B","sourcesContent":["export * from './constants';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/metadata/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@@ -1,19 +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("./common"), exports);
|
|
18
|
-
__exportStar(require("./injectors"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/metadata/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B","sourcesContent":["export * from './common';\nexport * from './injectors';\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type TBindingKey, type TInjectTarget } from '../../common/types';
|
|
2
|
-
import { type MetadataRegistry } from '../registry';
|
|
3
|
-
/** Either a key, or the class bound under it - never both. The class may be named directly or through a function, which defers the reference past an import cycle. */
|
|
4
|
-
export type TInjectOptions = {
|
|
5
|
-
isOptional?: boolean;
|
|
6
|
-
registry?: MetadataRegistry;
|
|
7
|
-
} & ({
|
|
8
|
-
key: TBindingKey;
|
|
9
|
-
target?: never;
|
|
10
|
-
} | {
|
|
11
|
-
target: TInjectTarget;
|
|
12
|
-
key?: never;
|
|
13
|
-
});
|
|
14
|
-
/** Marks a property or constructor parameter for dependency injection. */
|
|
15
|
-
export declare const inject: (opts: TInjectOptions) => (target: any, propertyName: string | symbol | undefined, parameterIndex?: number) => void;
|
|
16
|
-
//# sourceMappingURL=injectors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injectors.d.ts","sourceRoot":"","sources":["../../../../src/modules/metadata/injectors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,KAAK,gBAAgB,EAAoB,MAAM,oBAAoB,CAAC;AAE7E,sKAAsK;AACtK,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B,GAAG,CAAC;IAAE,GAAG,EAAE,WAAW,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,GAAG,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAEpF,0EAA0E;AAC1E,eAAO,MAAM,MAAM,GAAI,MAAM,cAAc,MAWjC,QAAQ,GAAG,EAAE,cAAc,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,iBAAiB,MAAM,SAgCxF,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inject = void 0;
|
|
4
|
-
const error_1 = require("../error");
|
|
5
|
-
const registry_1 = require("../registry");
|
|
6
|
-
/** Marks a property or constructor parameter for dependency injection. */
|
|
7
|
-
const inject = (opts) => {
|
|
8
|
-
const { key, target: injected } = opts;
|
|
9
|
-
// A circular import leaves `target` undefined; fail here, not at resolve time. A function is the
|
|
10
|
-
// deferred form - what it returns is checked when the container resolves it.
|
|
11
|
-
if (key === undefined && typeof injected !== 'function') {
|
|
12
|
-
throw (0, error_1.getError)({
|
|
13
|
-
message: `@inject was given no binding key and no class | target: ${String(injected)}`,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return (target, propertyName, parameterIndex) => {
|
|
17
|
-
const registry = opts.registry ?? registry_1.metadataRegistry;
|
|
18
|
-
if (typeof parameterIndex === 'number') {
|
|
19
|
-
registry.setInjectMetadata({
|
|
20
|
-
target,
|
|
21
|
-
index: parameterIndex,
|
|
22
|
-
metadata: {
|
|
23
|
-
...(key === undefined ? { target: injected } : { key }),
|
|
24
|
-
index: parameterIndex,
|
|
25
|
-
isOptional: opts.isOptional ?? false,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (propertyName !== undefined) {
|
|
31
|
-
registry.setPropertyMetadata({
|
|
32
|
-
target,
|
|
33
|
-
propertyName: propertyName,
|
|
34
|
-
metadata: {
|
|
35
|
-
...(key === undefined ? { target: injected } : { bindingKey: key }),
|
|
36
|
-
isOptional: opts.isOptional ?? false,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
throw (0, error_1.getError)({
|
|
42
|
-
message: '@inject decorator can only be used on class properties or constructor parameters',
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
exports.inject = inject;
|
|
47
|
-
//# sourceMappingURL=injectors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injectors.js","sourceRoot":"","sources":["../../../../src/modules/metadata/injectors.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C,iDAA6E;AAQ7E,0EAA0E;AACnE,MAAM,MAAM,GAAG,CAAC,IAAoB,EAAE,EAAE;IAC7C,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAEvC,iGAAiG;IACjG,6EAA6E;IAC7E,IAAI,GAAG,KAAK,SAAS,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACxD,MAAM,IAAA,gBAAQ,EAAC;YACb,OAAO,EAAE,2DAA2D,MAAM,CAAC,QAAQ,CAAC,EAAE;SACvF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,MAAW,EAAE,YAAyC,EAAE,cAAuB,EAAE,EAAE;QACzF,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,2BAAgB,CAAC;QAEnD,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;YACvC,QAAQ,CAAC,iBAAiB,CAAC;gBACzB,MAAM;gBACN,KAAK,EAAE,cAAc;gBACrB,QAAQ,EAAE;oBACR,GAAG,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;oBACvD,KAAK,EAAE,cAAc;oBACrB,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK;iBACrC;aACF,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAC/B,QAAQ,CAAC,mBAAmB,CAAC;gBAC3B,MAAM;gBACN,YAAY,EAAE,YAAY;gBAC1B,QAAQ,EAAE;oBACR,GAAG,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;oBACnE,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK;iBACrC;aACF,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,MAAM,IAAA,gBAAQ,EAAC;YACb,OAAO,EAAE,kFAAkF;SAC5F,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AA3CW,QAAA,MAAM,UA2CjB","sourcesContent":["import { getError } from '@/modules/error';\nimport { type TBindingKey, type TInjectTarget } from '@/common/types';\nimport { type MetadataRegistry, metadataRegistry } from '@/modules/registry';\n\n/** Either a key, or the class bound under it - never both. The class may be named directly or through a function, which defers the reference past an import cycle. */\nexport type TInjectOptions = {\n isOptional?: boolean;\n registry?: MetadataRegistry;\n} & ({ key: TBindingKey; target?: never } | { target: TInjectTarget; key?: never });\n\n/** Marks a property or constructor parameter for dependency injection. */\nexport const inject = (opts: TInjectOptions) => {\n const { key, target: injected } = opts;\n\n // A circular import leaves `target` undefined; fail here, not at resolve time. A function is the\n // deferred form - what it returns is checked when the container resolves it.\n if (key === undefined && typeof injected !== 'function') {\n throw getError({\n message: `@inject was given no binding key and no class | target: ${String(injected)}`,\n });\n }\n\n return (target: any, propertyName: string | symbol | undefined, parameterIndex?: number) => {\n const registry = opts.registry ?? metadataRegistry;\n\n if (typeof parameterIndex === 'number') {\n registry.setInjectMetadata({\n target,\n index: parameterIndex,\n metadata: {\n ...(key === undefined ? { target: injected } : { key }),\n index: parameterIndex,\n isOptional: opts.isOptional ?? false,\n },\n });\n return;\n }\n\n if (propertyName !== undefined) {\n registry.setPropertyMetadata({\n target,\n propertyName: propertyName,\n metadata: {\n ...(key === undefined ? { target: injected } : { bindingKey: key }),\n isOptional: opts.isOptional ?? false,\n },\n });\n return;\n }\n\n throw getError({\n message: '@inject decorator can only be used on class properties or constructor parameters',\n });\n };\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/registry/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/registry/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB","sourcesContent":["export * from './types';\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { TBindingKey, TInjectTarget } from '../../../common/types';
|
|
2
|
-
export interface IPropertyMetadata {
|
|
3
|
-
bindingKey?: TBindingKey;
|
|
4
|
-
/** Named by class, or by a function returning it; the key is read off the class at resolve time. */
|
|
5
|
-
target?: TInjectTarget;
|
|
6
|
-
isOptional?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface IInjectMetadata {
|
|
9
|
-
key?: TBindingKey;
|
|
10
|
-
/** Named by class, or by a function returning it; the key is read off the class at resolve time. */
|
|
11
|
-
target?: TInjectTarget;
|
|
12
|
-
index: number;
|
|
13
|
-
isOptional?: boolean;
|
|
14
|
-
}
|
|
15
|
-
/** What `MetadataKeys.BINDING_KEY` holds. */
|
|
16
|
-
export interface IBindingKeyRecord {
|
|
17
|
-
key: TBindingKey;
|
|
18
|
-
isProvisional: boolean;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/modules/registry/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGjE,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,oGAAoG;IACpG,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,oGAAoG;IACpG,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,WAAW,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/registry/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TBindingKey, TInjectTarget } from '@/common/types';\n\n// No index signature: it would let a misspelled read (`metadata.optional`) compile as `any`.\nexport interface IPropertyMetadata {\n bindingKey?: TBindingKey;\n /** Named by class, or by a function returning it; the key is read off the class at resolve time. */\n target?: TInjectTarget;\n isOptional?: boolean;\n}\n\nexport interface IInjectMetadata {\n key?: TBindingKey;\n /** Named by class, or by a function returning it; the key is read off the class at resolve time. */\n target?: TInjectTarget;\n index: number;\n isOptional?: boolean;\n}\n\n/** What `MetadataKeys.BINDING_KEY` holds. */\nexport interface IBindingKeyRecord {\n key: TBindingKey;\n isProvisional: boolean;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/registry/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
@@ -1,19 +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("./common"), exports);
|
|
18
|
-
__exportStar(require("./registry"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/registry/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,6CAA2B","sourcesContent":["export * from './common';\nexport * from './registry';\n"]}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { BaseHelper } from '../../common/base-helper';
|
|
3
|
-
import { type TBindingKey, type TClass } from '../../common/types';
|
|
4
|
-
import { type IInjectMetadata, type IPropertyMetadata } from './common/types';
|
|
5
|
-
/** Central metadata registry for storing and retrieving decorator metadata. */
|
|
6
|
-
export declare class MetadataRegistry extends BaseHelper {
|
|
7
|
-
constructor();
|
|
8
|
-
define<Target extends object = object, Value = any>(opts: {
|
|
9
|
-
target: Target;
|
|
10
|
-
key: TBindingKey;
|
|
11
|
-
value: Value;
|
|
12
|
-
}): void;
|
|
13
|
-
get<Target extends object = object, Value = any>(opts: {
|
|
14
|
-
target: Target;
|
|
15
|
-
key: TBindingKey;
|
|
16
|
-
}): Value | undefined;
|
|
17
|
-
has<Target extends object = object>(opts: {
|
|
18
|
-
target: Target;
|
|
19
|
-
key: TBindingKey;
|
|
20
|
-
}): boolean;
|
|
21
|
-
delete<Target extends object = object>(opts: {
|
|
22
|
-
target: Target;
|
|
23
|
-
key: TBindingKey;
|
|
24
|
-
}): boolean;
|
|
25
|
-
getKeys<Target extends object = object>(opts: {
|
|
26
|
-
target: Target;
|
|
27
|
-
}): TBindingKey[];
|
|
28
|
-
getMethodNames<T = any>(opts: {
|
|
29
|
-
target: TClass<T>;
|
|
30
|
-
}): string[];
|
|
31
|
-
clearMetadata<T extends object = object>(opts: {
|
|
32
|
-
target: T;
|
|
33
|
-
}): void;
|
|
34
|
-
setPropertyMetadata<T extends object = object>(opts: {
|
|
35
|
-
target: T;
|
|
36
|
-
propertyName: string | symbol;
|
|
37
|
-
metadata: IPropertyMetadata;
|
|
38
|
-
}): void;
|
|
39
|
-
getPropertiesMetadata<T extends object = object>(opts: {
|
|
40
|
-
target: T;
|
|
41
|
-
}): Map<string | symbol, IPropertyMetadata> | undefined;
|
|
42
|
-
getPropertyMetadata<T extends object = object>(opts: {
|
|
43
|
-
target: T;
|
|
44
|
-
propertyName: string | symbol;
|
|
45
|
-
}): IPropertyMetadata | undefined;
|
|
46
|
-
setInjectMetadata<T extends object = object>(opts: {
|
|
47
|
-
target: T;
|
|
48
|
-
index: number;
|
|
49
|
-
metadata: IInjectMetadata;
|
|
50
|
-
}): void;
|
|
51
|
-
getInjectMetadata<T extends object = object>(opts: {
|
|
52
|
-
target: T;
|
|
53
|
-
}): IInjectMetadata[] | undefined;
|
|
54
|
-
/** `isProvisional` marks a DERIVED key; a registration replaces it silently, having seen the call-site override. */
|
|
55
|
-
setBindingKey<T extends object = object>(opts: {
|
|
56
|
-
target: T;
|
|
57
|
-
key: TBindingKey;
|
|
58
|
-
isProvisional?: boolean;
|
|
59
|
-
}): void;
|
|
60
|
-
/** Own metadata only: a subclass is not registered, and the parent key would resolve the wrong binding. */
|
|
61
|
-
getBindingKey<T extends object = object>(opts: {
|
|
62
|
-
target: T;
|
|
63
|
-
}): TBindingKey | undefined;
|
|
64
|
-
}
|
|
65
|
-
export declare const metadataRegistry: MetadataRegistry;
|
|
66
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/modules/registry/registry.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,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,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.metadataRegistry = exports.MetadataRegistry = void 0;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const base_helper_1 = require("../../common/base-helper");
|
|
6
|
-
const logger_1 = require("../../common/logger");
|
|
7
|
-
const constants_1 = require("../metadata/common/constants");
|
|
8
|
-
/** Central metadata registry for storing and retrieving decorator metadata. */
|
|
9
|
-
class MetadataRegistry extends base_helper_1.BaseHelper {
|
|
10
|
-
constructor() {
|
|
11
|
-
super({ scope: MetadataRegistry.name });
|
|
12
|
-
}
|
|
13
|
-
define(opts) {
|
|
14
|
-
const { target, key, value } = opts;
|
|
15
|
-
logger_1.Logger.debug('[define] Set metadata | target: %s | key: %s | value: %j', target.constructor.name, key.toString(), value);
|
|
16
|
-
Reflect.defineMetadata(key, value, target);
|
|
17
|
-
}
|
|
18
|
-
get(opts) {
|
|
19
|
-
const { target, key } = opts;
|
|
20
|
-
return Reflect.getMetadata(key, target);
|
|
21
|
-
}
|
|
22
|
-
has(opts) {
|
|
23
|
-
const { target, key } = opts;
|
|
24
|
-
return Reflect.hasMetadata(key, target);
|
|
25
|
-
}
|
|
26
|
-
delete(opts) {
|
|
27
|
-
const { target, key } = opts;
|
|
28
|
-
return Reflect.deleteMetadata(key, target);
|
|
29
|
-
}
|
|
30
|
-
getKeys(opts) {
|
|
31
|
-
const { target } = opts;
|
|
32
|
-
return (Reflect.getMetadataKeys(target)?.filter((key) => {
|
|
33
|
-
return typeof key === 'symbol' || typeof key === 'string';
|
|
34
|
-
}) ?? []);
|
|
35
|
-
}
|
|
36
|
-
getMethodNames(opts) {
|
|
37
|
-
const { target } = opts;
|
|
38
|
-
const prototype = target.prototype;
|
|
39
|
-
const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== 'constructor' && typeof prototype[name] === 'function');
|
|
40
|
-
return methods;
|
|
41
|
-
}
|
|
42
|
-
clearMetadata(opts) {
|
|
43
|
-
const { target } = opts;
|
|
44
|
-
const keys = Reflect.getMetadataKeys(target);
|
|
45
|
-
for (const key of keys) {
|
|
46
|
-
Reflect.deleteMetadata(key, target);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
setPropertyMetadata(opts) {
|
|
50
|
-
const { target, propertyName, metadata } = opts;
|
|
51
|
-
// Copy-on-write, as for constructor injection: the inherited map belongs to the parent class and
|
|
52
|
-
// every sibling subclass reads it.
|
|
53
|
-
const own = Reflect.getOwnMetadata(constants_1.MetadataKeys.PROPERTIES, target.constructor);
|
|
54
|
-
const properties = own ?? new Map(this.getPropertiesMetadata({ target }));
|
|
55
|
-
properties.set(propertyName, metadata);
|
|
56
|
-
Reflect.defineMetadata(constants_1.MetadataKeys.PROPERTIES, properties, target.constructor);
|
|
57
|
-
}
|
|
58
|
-
getPropertiesMetadata(opts) {
|
|
59
|
-
const { target } = opts;
|
|
60
|
-
return Reflect.getMetadata(constants_1.MetadataKeys.PROPERTIES, target.constructor);
|
|
61
|
-
}
|
|
62
|
-
getPropertyMetadata(opts) {
|
|
63
|
-
const { target, propertyName } = opts;
|
|
64
|
-
const properties = this.getPropertiesMetadata({ target });
|
|
65
|
-
return properties?.get(propertyName);
|
|
66
|
-
}
|
|
67
|
-
setInjectMetadata(opts) {
|
|
68
|
-
const { target, index, metadata } = opts;
|
|
69
|
-
// Copy-on-write: the inherited list belongs to the parent class and every sibling subclass reads it.
|
|
70
|
-
const own = Reflect.getOwnMetadata(constants_1.MetadataKeys.INJECT, target);
|
|
71
|
-
const injects = own ?? [...(Reflect.getMetadata(constants_1.MetadataKeys.INJECT, target) ?? [])];
|
|
72
|
-
injects[index] = metadata;
|
|
73
|
-
Reflect.defineMetadata(constants_1.MetadataKeys.INJECT, injects, target);
|
|
74
|
-
}
|
|
75
|
-
getInjectMetadata(opts) {
|
|
76
|
-
const { target } = opts;
|
|
77
|
-
return Reflect.getMetadata(constants_1.MetadataKeys.INJECT, target);
|
|
78
|
-
}
|
|
79
|
-
/** `isProvisional` marks a DERIVED key; a registration replaces it silently, having seen the call-site override. */
|
|
80
|
-
setBindingKey(opts) {
|
|
81
|
-
const { target, key, isProvisional = false } = opts;
|
|
82
|
-
const current = Reflect.getOwnMetadata(constants_1.MetadataKeys.BINDING_KEY, target);
|
|
83
|
-
// Two apps in one process, one class, two keys: the last registration would decide for both.
|
|
84
|
-
if (current !== undefined && current.key !== key && !current.isProvisional && !isProvisional) {
|
|
85
|
-
logger_1.Logger.warn('[setBindingKey] Rebound under a different key | target: %s | was: %s | now: %s', target.name, current.key.toString(), key.toString());
|
|
86
|
-
}
|
|
87
|
-
Reflect.defineMetadata(constants_1.MetadataKeys.BINDING_KEY, { key, isProvisional }, target);
|
|
88
|
-
}
|
|
89
|
-
/** Own metadata only: a subclass is not registered, and the parent key would resolve the wrong binding. */
|
|
90
|
-
getBindingKey(opts) {
|
|
91
|
-
const { target } = opts;
|
|
92
|
-
const record = Reflect.getOwnMetadata(constants_1.MetadataKeys.BINDING_KEY, target);
|
|
93
|
-
return record?.key;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.MetadataRegistry = MetadataRegistry;
|
|
97
|
-
exports.metadataRegistry = new MetadataRegistry();
|
|
98
|
-
//# sourceMappingURL=registry.js.map
|