@miiajs/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +57 -0
- package/dist/app/app.d.ts +106 -0
- package/dist/app/app.d.ts.map +1 -0
- package/dist/app/app.js +449 -0
- package/dist/app/app.js.map +1 -0
- package/dist/app/index.d.ts +3 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +2 -0
- package/dist/app/index.js.map +1 -0
- package/dist/app/module-loader.d.ts +16 -0
- package/dist/app/module-loader.d.ts.map +1 -0
- package/dist/app/module-loader.js +107 -0
- package/dist/app/module-loader.js.map +1 -0
- package/dist/app/router-explorer.d.ts +12 -0
- package/dist/app/router-explorer.d.ts.map +1 -0
- package/dist/app/router-explorer.js +76 -0
- package/dist/app/router-explorer.js.map +1 -0
- package/dist/app/routes-resolver.d.ts +11 -0
- package/dist/app/routes-resolver.d.ts.map +1 -0
- package/dist/app/routes-resolver.js +24 -0
- package/dist/app/routes-resolver.js.map +1 -0
- package/dist/cors.d.ts +22 -0
- package/dist/cors.d.ts.map +1 -0
- package/dist/cors.js +48 -0
- package/dist/cors.js.map +1 -0
- package/dist/decorators/apply-decorators.d.ts +19 -0
- package/dist/decorators/apply-decorators.d.ts.map +1 -0
- package/dist/decorators/apply-decorators.js +27 -0
- package/dist/decorators/apply-decorators.js.map +1 -0
- package/dist/decorators/class.d.ts +9 -0
- package/dist/decorators/class.d.ts.map +1 -0
- package/dist/decorators/class.js +15 -0
- package/dist/decorators/class.js.map +1 -0
- package/dist/decorators/create-decorator.d.ts +6 -0
- package/dist/decorators/create-decorator.d.ts.map +1 -0
- package/dist/decorators/create-decorator.js +31 -0
- package/dist/decorators/create-decorator.js.map +1 -0
- package/dist/decorators/http.d.ts +8 -0
- package/dist/decorators/http.d.ts.map +1 -0
- package/dist/decorators/http.js +24 -0
- package/dist/decorators/http.js.map +1 -0
- package/dist/decorators/index.d.ts +9 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +7 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/metadata.d.ts +29 -0
- package/dist/decorators/metadata.d.ts.map +1 -0
- package/dist/decorators/metadata.js +40 -0
- package/dist/decorators/metadata.js.map +1 -0
- package/dist/decorators/middleware.d.ts +9 -0
- package/dist/decorators/middleware.d.ts.map +1 -0
- package/dist/decorators/middleware.js +82 -0
- package/dist/decorators/middleware.js.map +1 -0
- package/dist/di-container.d.ts +52 -0
- package/dist/di-container.d.ts.map +1 -0
- package/dist/di-container.js +177 -0
- package/dist/di-container.js.map +1 -0
- package/dist/discovery/discovery-service.d.ts +63 -0
- package/dist/discovery/discovery-service.d.ts.map +1 -0
- package/dist/discovery/discovery-service.js +65 -0
- package/dist/discovery/discovery-service.js.map +1 -0
- package/dist/discovery/index.d.ts +3 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +2 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/exceptions.d.ts +28 -0
- package/dist/exceptions.d.ts.map +1 -0
- package/dist/exceptions.js +67 -0
- package/dist/exceptions.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +43 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +123 -0
- package/dist/logger.js.map +1 -0
- package/dist/middleware.d.ts +4 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +36 -0
- package/dist/middleware.js.map +1 -0
- package/dist/polyfill.d.ts +2 -0
- package/dist/polyfill.d.ts.map +1 -0
- package/dist/polyfill.js +6 -0
- package/dist/polyfill.js.map +1 -0
- package/dist/resolver.d.ts +36 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +42 -0
- package/dist/resolver.js.map +1 -0
- package/dist/response.d.ts +19 -0
- package/dist/response.d.ts.map +1 -0
- package/dist/response.js +62 -0
- package/dist/response.js.map +1 -0
- package/dist/router.d.ts +35 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +160 -0
- package/dist/router.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/test-app.d.ts +22 -0
- package/dist/testing/test-app.d.ts.map +1 -0
- package/dist/testing/test-app.js +76 -0
- package/dist/testing/test-app.js.map +1 -0
- package/dist/types.d.ts +85 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/join-paths.d.ts +2 -0
- package/dist/utils/join-paths.d.ts.map +1 -0
- package/dist/utils/join-paths.js +7 -0
- package/dist/utils/join-paths.js.map +1 -0
- package/dist/utils/resolve-options.d.ts +32 -0
- package/dist/utils/resolve-options.d.ts.map +1 -0
- package/dist/utils/resolve-options.js +10 -0
- package/dist/utils/resolve-options.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import '../polyfill.js';
|
|
2
|
+
import type { Constructor, Scope } from '../types.js';
|
|
3
|
+
export interface InjectableMeta {
|
|
4
|
+
scope: Scope;
|
|
5
|
+
token?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const INJECTABLE: unique symbol;
|
|
8
|
+
export declare const MODULE: unique symbol;
|
|
9
|
+
export declare const PREFIX: unique symbol;
|
|
10
|
+
export declare const RESOLVED_PREFIX: unique symbol;
|
|
11
|
+
export declare const ROUTES: unique symbol;
|
|
12
|
+
export declare const CLASS_MW: unique symbol;
|
|
13
|
+
export declare const METHOD_MW: unique symbol;
|
|
14
|
+
export declare const STATUSES: unique symbol;
|
|
15
|
+
export declare const CLASS_GUARDS: unique symbol;
|
|
16
|
+
export declare const METHOD_GUARDS: unique symbol;
|
|
17
|
+
export declare const SKIP_GUARDS: unique symbol;
|
|
18
|
+
export declare const GUARD_FACTORY: unique symbol;
|
|
19
|
+
export declare const BODY_SCHEMAS: unique symbol;
|
|
20
|
+
export declare const QUERY_SCHEMAS: unique symbol;
|
|
21
|
+
export declare const PARAMS_SCHEMAS: unique symbol;
|
|
22
|
+
type Meta = Record<string | symbol, any>;
|
|
23
|
+
export declare function getMeta<T>(ctor: Constructor, key: symbol): T | undefined;
|
|
24
|
+
export declare function setMeta<T>(meta: Meta, key: symbol, value: T): void;
|
|
25
|
+
export declare function pushMeta<T>(meta: Meta, key: symbol, item: T): void;
|
|
26
|
+
export declare function addToMapMeta<T>(meta: Meta, key: symbol, name: string, items: T[]): void;
|
|
27
|
+
export declare function setInMapMeta<T>(meta: Meta, key: symbol, name: string, value: T): void;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/decorators/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIrD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,KAAK,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAID,eAAO,MAAM,UAAU,eAAuB,CAAA;AAC9C,eAAO,MAAM,MAAM,eAAmB,CAAA;AACtC,eAAO,MAAM,MAAM,eAAmB,CAAA;AACtC,eAAO,MAAM,eAAe,eAA2B,CAAA;AACvD,eAAO,MAAM,MAAM,eAAmB,CAAA;AACtC,eAAO,MAAM,QAAQ,eAA6B,CAAA;AAClD,eAAO,MAAM,SAAS,eAA8B,CAAA;AACpD,eAAO,MAAM,QAAQ,eAAqB,CAAA;AAC1C,eAAO,MAAM,YAAY,eAAwB,CAAA;AACjD,eAAO,MAAM,aAAa,eAAyB,CAAA;AACnD,eAAO,MAAM,WAAW,eAAuB,CAAA;AAC/C,eAAO,MAAM,aAAa,eAAyB,CAAA;AACnD,eAAO,MAAM,YAAY,eAAwB,CAAA;AACjD,eAAO,MAAM,aAAa,eAAyB,CAAA;AACnD,eAAO,MAAM,cAAc,eAA0B,CAAA;AAIrD,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAA;AAExC,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAExE;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAElE;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAIlE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAKvF;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAIrF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import '../polyfill.js';
|
|
2
|
+
// ─── Symbol keys ─────────────────────────────────────────────────
|
|
3
|
+
export const INJECTABLE = Symbol('injectable');
|
|
4
|
+
export const MODULE = Symbol('module');
|
|
5
|
+
export const PREFIX = Symbol('prefix');
|
|
6
|
+
export const RESOLVED_PREFIX = Symbol('resolvedPrefix');
|
|
7
|
+
export const ROUTES = Symbol('routes');
|
|
8
|
+
export const CLASS_MW = Symbol('classMiddlewares');
|
|
9
|
+
export const METHOD_MW = Symbol('methodMiddlewares');
|
|
10
|
+
export const STATUSES = Symbol('statuses');
|
|
11
|
+
export const CLASS_GUARDS = Symbol('classGuards');
|
|
12
|
+
export const METHOD_GUARDS = Symbol('methodGuards');
|
|
13
|
+
export const SKIP_GUARDS = Symbol('skipGuards');
|
|
14
|
+
export const GUARD_FACTORY = Symbol('guardFactory');
|
|
15
|
+
export const BODY_SCHEMAS = Symbol('bodySchemas');
|
|
16
|
+
export const QUERY_SCHEMAS = Symbol('querySchemas');
|
|
17
|
+
export const PARAMS_SCHEMAS = Symbol('paramsSchemas');
|
|
18
|
+
export function getMeta(ctor, key) {
|
|
19
|
+
return ctor[Symbol.metadata]?.[key];
|
|
20
|
+
}
|
|
21
|
+
export function setMeta(meta, key, value) {
|
|
22
|
+
meta[key] = value;
|
|
23
|
+
}
|
|
24
|
+
export function pushMeta(meta, key, item) {
|
|
25
|
+
const arr = meta[key] ?? [];
|
|
26
|
+
arr.push(item);
|
|
27
|
+
meta[key] = arr;
|
|
28
|
+
}
|
|
29
|
+
export function addToMapMeta(meta, key, name, items) {
|
|
30
|
+
const map = meta[key] ?? new Map();
|
|
31
|
+
const existing = map.get(name) ?? [];
|
|
32
|
+
map.set(name, [...existing, ...items]);
|
|
33
|
+
meta[key] = map;
|
|
34
|
+
}
|
|
35
|
+
export function setInMapMeta(meta, key, name, value) {
|
|
36
|
+
const map = meta[key] ?? new Map();
|
|
37
|
+
map.set(name, value);
|
|
38
|
+
meta[key] = map;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/decorators/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AAUvB,oEAAoE;AAEpE,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC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ED,MAAM,UAAU,QAAQ,CAAI,IAAU,EAAE,GAAW,EAAE,IAAO;IAC1D,MAAM,GAAG,GAAI,IAAI,CAAC,GAAG,CAAS,IAAI,EAAE,CAAA;IACpC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACd,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;AACjB,CAAC;AAED,MAAM,UAAU,YAAY,CAAI,IAAU,EAAE,GAAW,EAAE,IAAY,EAAE,KAAU;IAC/E,MAAM,GAAG,GAAI,IAAI,CAAC,GAAG,CAAsB,IAAI,IAAI,GAAG,EAAe,CAAA;IACrE,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IACpC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC,CAAA;IACtC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;AACjB,CAAC;AAED,MAAM,UAAU,YAAY,CAAI,IAAU,EAAE,GAAW,EAAE,IAAY,EAAE,KAAQ;IAC7E,MAAM,GAAG,GAAI,IAAI,CAAC,GAAG,CAAoB,IAAI,IAAI,GAAG,EAAa,CAAA;IACjE,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACpB,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Guard, Middleware, ZodLike } from '../types.js';
|
|
2
|
+
export declare const Use: (...args: Middleware[]) => (target: any, context: ClassDecoratorContext | ClassMethodDecoratorContext) => any;
|
|
3
|
+
export declare const UseGuard: (...args: Guard[]) => (target: any, context: ClassDecoratorContext | ClassMethodDecoratorContext) => any;
|
|
4
|
+
export declare const SkipGuard: (first: Function | Guard, ...rest: (Function | Guard)[]) => (target: any, context: ClassDecoratorContext | ClassMethodDecoratorContext) => any;
|
|
5
|
+
export declare const ValidateBody: (schema: ZodLike<any>) => (target: Function, context: ClassMethodDecoratorContext) => void;
|
|
6
|
+
export declare const ValidateQuery: (schema: ZodLike<any>) => (target: Function, context: ClassMethodDecoratorContext) => void;
|
|
7
|
+
export declare const ValidateParams: (schema: ZodLike<any>) => (target: Function, context: ClassMethodDecoratorContext) => void;
|
|
8
|
+
export declare const Status: (code: number) => (target: Function, context: ClassMethodDecoratorContext) => void;
|
|
9
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/decorators/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAqB7D,eAAO,MAAM,GAAG,+GAOd,CAAA;AAIF,eAAO,MAAM,QAAQ,0GAOnB,CAAA;AAIF,eAAO,MAAM,SAAS,gJASrB,CAAA;AAID,eAAO,MAAM,YAAY,4FAevB,CAAA;AAIF,eAAO,MAAM,aAAa,4FAWxB,CAAA;AAIF,eAAO,MAAM,cAAc,4FAWzB,CAAA;AAIF,eAAO,MAAM,MAAM,oFAEjB,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { CLASS_MW, METHOD_MW, CLASS_GUARDS, METHOD_GUARDS, STATUSES, SKIP_GUARDS, BODY_SCHEMAS, QUERY_SCHEMAS, PARAMS_SCHEMAS, addToMapMeta, setMeta, setInMapMeta, } from './metadata.js';
|
|
2
|
+
import { UnprocessableException } from '../exceptions.js';
|
|
3
|
+
import { createMethodDecorator } from './create-decorator.js';
|
|
4
|
+
import { createDecorator } from './create-decorator.js';
|
|
5
|
+
// ─── @Use ────────────────────────────────────────────────────────
|
|
6
|
+
export const Use = createDecorator((context, ...middlewares) => {
|
|
7
|
+
if (context.kind === 'class') {
|
|
8
|
+
const existing = context.metadata[CLASS_MW] ?? [];
|
|
9
|
+
setMeta(context.metadata, CLASS_MW, [...existing, ...middlewares]);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
addToMapMeta(context.metadata, METHOD_MW, String(context.name), middlewares);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
// ─── @UseGuard ───────────────────────────────────────────────────
|
|
16
|
+
export const UseGuard = createDecorator((context, ...guards) => {
|
|
17
|
+
if (context.kind === 'class') {
|
|
18
|
+
const existing = context.metadata[CLASS_GUARDS] ?? [];
|
|
19
|
+
setMeta(context.metadata, CLASS_GUARDS, [...existing, ...guards]);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
addToMapMeta(context.metadata, METHOD_GUARDS, String(context.name), guards);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
// ─── @SkipGuard ─────────────────────────────────────────────────
|
|
26
|
+
export const SkipGuard = createDecorator((context, ...guards) => {
|
|
27
|
+
const name = context.kind === 'class' ? '*' : String(context.name);
|
|
28
|
+
const map = context.metadata[SKIP_GUARDS] ?? new Map();
|
|
29
|
+
const existing = map.get(name) ?? new Set();
|
|
30
|
+
for (const g of guards)
|
|
31
|
+
existing.add(g);
|
|
32
|
+
map.set(name, existing);
|
|
33
|
+
context.metadata[SKIP_GUARDS] = map;
|
|
34
|
+
});
|
|
35
|
+
// ─── @ValidateBody ───────────────────────────────────────────────
|
|
36
|
+
export const ValidateBody = createMethodDecorator((_target, context, schema) => {
|
|
37
|
+
const mw = async (ctx, next) => {
|
|
38
|
+
// .catch(() => null) intentionally swallows both fresh req.json() rejections
|
|
39
|
+
// (malformed body) and cached rejections from prior ctx.json() calls in other
|
|
40
|
+
// middleware - null then flows through safeParse and becomes an UnprocessableException.
|
|
41
|
+
const body = await ctx.json().catch(() => null);
|
|
42
|
+
const result = schema.safeParse(body);
|
|
43
|
+
if (!result.success) {
|
|
44
|
+
throw new UnprocessableException('Body validation failed', result.error.issues);
|
|
45
|
+
}
|
|
46
|
+
ctx._setBody(result.data);
|
|
47
|
+
await next();
|
|
48
|
+
};
|
|
49
|
+
setInMapMeta(context.metadata, BODY_SCHEMAS, String(context.name), schema);
|
|
50
|
+
addToMapMeta(context.metadata, METHOD_MW, String(context.name), [mw]);
|
|
51
|
+
});
|
|
52
|
+
// ─── @ValidateQuery ──────────────────────────────────────────────
|
|
53
|
+
export const ValidateQuery = createMethodDecorator((_target, context, schema) => {
|
|
54
|
+
const mw = async (ctx, next) => {
|
|
55
|
+
const result = schema.safeParse(ctx.query);
|
|
56
|
+
if (!result.success) {
|
|
57
|
+
throw new UnprocessableException('Query validation failed', result.error.issues);
|
|
58
|
+
}
|
|
59
|
+
ctx.query = result.data;
|
|
60
|
+
await next();
|
|
61
|
+
};
|
|
62
|
+
setInMapMeta(context.metadata, QUERY_SCHEMAS, String(context.name), schema);
|
|
63
|
+
addToMapMeta(context.metadata, METHOD_MW, String(context.name), [mw]);
|
|
64
|
+
});
|
|
65
|
+
// ─── @ValidateParams ─────────────────────────────────────────────
|
|
66
|
+
export const ValidateParams = createMethodDecorator((_target, context, schema) => {
|
|
67
|
+
const mw = async (ctx, next) => {
|
|
68
|
+
const result = schema.safeParse(ctx.params);
|
|
69
|
+
if (!result.success) {
|
|
70
|
+
throw new UnprocessableException('Params validation failed', result.error.issues);
|
|
71
|
+
}
|
|
72
|
+
ctx.params = result.data;
|
|
73
|
+
await next();
|
|
74
|
+
};
|
|
75
|
+
setInMapMeta(context.metadata, PARAMS_SCHEMAS, String(context.name), schema);
|
|
76
|
+
addToMapMeta(context.metadata, METHOD_MW, String(context.name), [mw]);
|
|
77
|
+
});
|
|
78
|
+
// ─── @Status ─────────────────────────────────────────────────────
|
|
79
|
+
export const Status = createMethodDecorator((_target, context, code) => {
|
|
80
|
+
setInMapMeta(context.metadata, STATUSES, String(context.name), code);
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/dec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: Container | null;
|
|
5
|
+
private registry;
|
|
6
|
+
private requestInstances;
|
|
7
|
+
private resolving;
|
|
8
|
+
register<T>(token: Constructor<T> | string, factory: ((resolve: Resolve) => T) | (() => T), scope?: Scope): void;
|
|
9
|
+
registerClass<T>(cls: Constructor<T>, scope?: Scope): void;
|
|
10
|
+
resolve<T>(token: Constructor<T> | string): T;
|
|
11
|
+
resolveOptional<T>(token: Constructor<T> | string): T | null;
|
|
12
|
+
has(token: Constructor | string): boolean;
|
|
13
|
+
clearRequestScope(): void;
|
|
14
|
+
initAll(): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Phase 3 of init: invoke onReady() on all singletons that define it.
|
|
17
|
+
* Called by Miia.doInit() after initAll() and compilePipelines().
|
|
18
|
+
*
|
|
19
|
+
* Guarantees:
|
|
20
|
+
* - By the time any onReady() runs, all onInit() hooks have completed.
|
|
21
|
+
*
|
|
22
|
+
* Caveats:
|
|
23
|
+
* - Order of onReady() calls is registration order (same as initAll()).
|
|
24
|
+
* Avoid inter-onReady dependencies - if provider A's onReady() relies on
|
|
25
|
+
* provider B's onReady() having run first, the result is order-fragile.
|
|
26
|
+
* - Lazy-registered providers (e.g. global guards added via app.useGuard()
|
|
27
|
+
* after initAll() - see compilePipelines() in app.ts) will receive
|
|
28
|
+
* onReady() but may not have received onInit(). This mirrors the existing
|
|
29
|
+
* pre-existing quirk with onDestroy() and is not introduced by this change.
|
|
30
|
+
*/
|
|
31
|
+
bootstrapAll(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns all singleton instances currently registered in the container.
|
|
34
|
+
* Filters out string-token registrations (only class-keyed entries) and
|
|
35
|
+
* entries that have not yet been instantiated.
|
|
36
|
+
*
|
|
37
|
+
* Used by DiscoveryService for ambient method-decorator discovery.
|
|
38
|
+
*/
|
|
39
|
+
getSingletonInstances(): Array<{
|
|
40
|
+
ctor: Constructor;
|
|
41
|
+
instance: object;
|
|
42
|
+
}>;
|
|
43
|
+
destroyAll(): Promise<void>;
|
|
44
|
+
private instantiate;
|
|
45
|
+
private callFactory;
|
|
46
|
+
}
|
|
47
|
+
export declare function inject<T>(token: Constructor<T>): T;
|
|
48
|
+
export declare function inject<T>(token: string): T;
|
|
49
|
+
export declare function injectOptional<T>(token: Constructor<T>): T | null;
|
|
50
|
+
export declare function injectOptional<T>(token: string): T | null;
|
|
51
|
+
export declare function runInContainerContext<T>(container: Container, fn: () => T): T;
|
|
52
|
+
//# sourceMappingURL=di-container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"di-container.d.ts","sourceRoot":"","sources":["../src/di-container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAQ7D,qBAAa,SAAS;IACpB,gBAAgB;IAChB,MAAM,CAAC,eAAe,EAAE,SAAS,GAAG,IAAI,CAAO;IAE/C,OAAO,CAAC,QAAQ,CAAkD;IAClE,OAAO,CAAC,gBAAgB,CAA2C;IACnE,OAAO,CAAC,SAAS,CAAkC;IAEnD,QAAQ,CAAC,CAAC,EACR,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM,EAC9B,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAC9C,KAAK,GAAE,KAAmB,GACzB,IAAI;IAIP,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,GAAE,KAAmB,GAAG,IAAI;IAOvE,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC;IAQ7C,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,IAAI;IAM5D,GAAG,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO;IAIzC,iBAAiB,IAAI,IAAI;IAInB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB9B;;;;;;;;;;;;;;;OAeG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAWnC;;;;;;OAMG;IACH,qBAAqB,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAejE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAajC,OAAO,CAAC,WAAW;IA6BnB,OAAO,CAAC,WAAW;CAYpB;AAcD,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AACnD,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAAA;AAK3C,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;AAClE,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAA;AAM1D,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQ7E"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
export class Container {
|
|
2
|
+
/** @internal */
|
|
3
|
+
static activeContainer = null;
|
|
4
|
+
registry = new Map();
|
|
5
|
+
requestInstances = new Map();
|
|
6
|
+
resolving = new Set();
|
|
7
|
+
register(token, factory, scope = 'singleton') {
|
|
8
|
+
this.registry.set(token, { factory, scope });
|
|
9
|
+
}
|
|
10
|
+
registerClass(cls, scope = 'singleton') {
|
|
11
|
+
this.registry.set(cls, {
|
|
12
|
+
factory: () => new cls(),
|
|
13
|
+
scope,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
resolve(token) {
|
|
17
|
+
const entry = this.registry.get(token);
|
|
18
|
+
if (!entry) {
|
|
19
|
+
throw new Error(`[Miia] No provider found for token: ${String(token)}`);
|
|
20
|
+
}
|
|
21
|
+
return this.instantiate(token, entry);
|
|
22
|
+
}
|
|
23
|
+
resolveOptional(token) {
|
|
24
|
+
const entry = this.registry.get(token);
|
|
25
|
+
if (!entry)
|
|
26
|
+
return null;
|
|
27
|
+
return this.instantiate(token, entry);
|
|
28
|
+
}
|
|
29
|
+
has(token) {
|
|
30
|
+
return this.registry.has(token);
|
|
31
|
+
}
|
|
32
|
+
clearRequestScope() {
|
|
33
|
+
if (this.requestInstances.size > 0)
|
|
34
|
+
this.requestInstances.clear();
|
|
35
|
+
}
|
|
36
|
+
async initAll() {
|
|
37
|
+
// Phase 1: instantiate all singletons (runs all factories)
|
|
38
|
+
const singletons = [];
|
|
39
|
+
for (const [token, entry] of this.registry) {
|
|
40
|
+
if (entry.scope === 'singleton') {
|
|
41
|
+
singletons.push(this.instantiate(token, entry));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Phase 2: lifecycle hooks
|
|
45
|
+
for (const instance of singletons) {
|
|
46
|
+
const onInit = instance?.onInit;
|
|
47
|
+
if (typeof onInit === 'function') {
|
|
48
|
+
await onInit.call(instance);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Phase 3 of init: invoke onReady() on all singletons that define it.
|
|
54
|
+
* Called by Miia.doInit() after initAll() and compilePipelines().
|
|
55
|
+
*
|
|
56
|
+
* Guarantees:
|
|
57
|
+
* - By the time any onReady() runs, all onInit() hooks have completed.
|
|
58
|
+
*
|
|
59
|
+
* Caveats:
|
|
60
|
+
* - Order of onReady() calls is registration order (same as initAll()).
|
|
61
|
+
* Avoid inter-onReady dependencies - if provider A's onReady() relies on
|
|
62
|
+
* provider B's onReady() having run first, the result is order-fragile.
|
|
63
|
+
* - Lazy-registered providers (e.g. global guards added via app.useGuard()
|
|
64
|
+
* after initAll() - see compilePipelines() in app.ts) will receive
|
|
65
|
+
* onReady() but may not have received onInit(). This mirrors the existing
|
|
66
|
+
* pre-existing quirk with onDestroy() and is not introduced by this change.
|
|
67
|
+
*/
|
|
68
|
+
async bootstrapAll() {
|
|
69
|
+
for (const [, entry] of this.registry) {
|
|
70
|
+
if (entry.scope === 'singleton' && entry.instance) {
|
|
71
|
+
const onReady = entry.instance.onReady;
|
|
72
|
+
if (typeof onReady === 'function') {
|
|
73
|
+
await onReady.call(entry.instance);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Returns all singleton instances currently registered in the container.
|
|
80
|
+
* Filters out string-token registrations (only class-keyed entries) and
|
|
81
|
+
* entries that have not yet been instantiated.
|
|
82
|
+
*
|
|
83
|
+
* Used by DiscoveryService for ambient method-decorator discovery.
|
|
84
|
+
*/
|
|
85
|
+
getSingletonInstances() {
|
|
86
|
+
const result = [];
|
|
87
|
+
for (const [token, entry] of this.registry) {
|
|
88
|
+
if (entry.scope === 'singleton' &&
|
|
89
|
+
typeof entry.instance === 'object' &&
|
|
90
|
+
entry.instance !== null &&
|
|
91
|
+
typeof token === 'function') {
|
|
92
|
+
result.push({ ctor: token, instance: entry.instance });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
async destroyAll() {
|
|
98
|
+
for (const [, entry] of this.registry) {
|
|
99
|
+
if (entry.scope === 'singleton' && entry.instance) {
|
|
100
|
+
const onDestroy = entry.instance.onDestroy;
|
|
101
|
+
if (typeof onDestroy === 'function') {
|
|
102
|
+
await onDestroy.call(entry.instance);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
this.registry.clear();
|
|
107
|
+
this.requestInstances.clear();
|
|
108
|
+
}
|
|
109
|
+
instantiate(token, entry) {
|
|
110
|
+
if (entry.scope === 'singleton' && entry.instance !== undefined)
|
|
111
|
+
return entry.instance;
|
|
112
|
+
if (this.resolving.has(token)) {
|
|
113
|
+
throw new Error(`[Miia] Circular dependency detected: ${String(token)}`);
|
|
114
|
+
}
|
|
115
|
+
this.resolving.add(token);
|
|
116
|
+
try {
|
|
117
|
+
if (entry.scope === 'singleton') {
|
|
118
|
+
const instance = this.callFactory(entry);
|
|
119
|
+
entry.instance = instance;
|
|
120
|
+
return instance;
|
|
121
|
+
}
|
|
122
|
+
if (entry.scope === 'request') {
|
|
123
|
+
const cached = this.requestInstances.get(token);
|
|
124
|
+
if (cached !== undefined)
|
|
125
|
+
return cached;
|
|
126
|
+
const instance = this.callFactory(entry);
|
|
127
|
+
this.requestInstances.set(token, instance);
|
|
128
|
+
return instance;
|
|
129
|
+
}
|
|
130
|
+
// transient - always new
|
|
131
|
+
return this.callFactory(entry);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
this.resolving.delete(token);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
callFactory(entry) {
|
|
138
|
+
const prev = Container.activeContainer;
|
|
139
|
+
Container.activeContainer = this;
|
|
140
|
+
try {
|
|
141
|
+
const fn = entry.factory;
|
|
142
|
+
if (fn.length === 0)
|
|
143
|
+
return fn();
|
|
144
|
+
const resolve = (t) => this.resolve(t);
|
|
145
|
+
return fn(resolve);
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
Container.activeContainer = prev;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// ─── inject / injectOptional ─────────────────────────────────────
|
|
153
|
+
function getActiveContainer() {
|
|
154
|
+
if (!Container.activeContainer) {
|
|
155
|
+
throw new Error('[Miia] inject() called outside of container context. ' +
|
|
156
|
+
'Ensure inject() is used inside a class field initializer or factory function within the DI system.');
|
|
157
|
+
}
|
|
158
|
+
return Container.activeContainer;
|
|
159
|
+
}
|
|
160
|
+
export function inject(token) {
|
|
161
|
+
return getActiveContainer().resolve(token);
|
|
162
|
+
}
|
|
163
|
+
export function injectOptional(token) {
|
|
164
|
+
return getActiveContainer().resolveOptional(token);
|
|
165
|
+
}
|
|
166
|
+
// ─── runInContainerContext ───────────────────────────────────────
|
|
167
|
+
export function runInContainerContext(container, fn) {
|
|
168
|
+
const prev = Container.activeContainer;
|
|
169
|
+
Container.activeContainer = container;
|
|
170
|
+
try {
|
|
171
|
+
return fn();
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
174
|
+
Container.activeContainer = prev;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=di-container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"di-container.js","sourceRoot":"","sources":["../src/di-container.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,SAAS;IACpB,gBAAgB;IAChB,MAAM,CAAC,eAAe,GAAqB,IAAI,CAAA;IAEvC,QAAQ,GAAG,IAAI,GAAG,EAAwC,CAAA;IAC1D,gBAAgB,GAAG,IAAI,GAAG,EAAiC,CAAA;IAC3D,SAAS,GAAG,IAAI,GAAG,EAAwB,CAAA;IAEnD,QAAQ,CACN,KAA8B,EAC9B,OAA8C,EAC9C,QAAe,WAAW;QAE1B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;IAC9C,CAAC;IAED,aAAa,CAAI,GAAmB,EAAE,QAAe,WAAW;QAC9D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE;YACrB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE;YACxB,KAAK;SACN,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,CAAI,KAA8B;QACvC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACtC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KA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AAC;YAAS,CAAC;QACT,SAAS,CAAC,eAAe,GAAG,IAAI,CAAA;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Container } from '../di-container.js';
|
|
2
|
+
import type { Constructor } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Base shape that discoverable method-decorator metadata must satisfy.
|
|
5
|
+
* Decorators should push items like `{ handlerName: ctx.name as string, ...userData }`
|
|
6
|
+
* into metadata so that DiscoveryService can bind them back to their method.
|
|
7
|
+
*/
|
|
8
|
+
export interface DiscoverableMethodMeta {
|
|
9
|
+
handlerName: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DiscoveredMethod<T extends DiscoverableMethodMeta> {
|
|
12
|
+
instance: object;
|
|
13
|
+
ctor: Constructor;
|
|
14
|
+
methodName: string;
|
|
15
|
+
metadata: T;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Public facade over Container for ambient discovery of singleton instances
|
|
19
|
+
* and their method-level metadata. Auto-registered by Miia in its constructor.
|
|
20
|
+
*
|
|
21
|
+
* Use inside `onReady()` (not `onInit()`) to guarantee all providers have
|
|
22
|
+
* finished their own initialization before scanning.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const ON = Symbol('on')
|
|
27
|
+
* export const On = createMethodDecorator<[event: string]>((_target, ctx, event) => {
|
|
28
|
+
* pushMeta(ctx.metadata!, ON, { event, handlerName: ctx.name as string })
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* @Injectable()
|
|
32
|
+
* class EventBus {
|
|
33
|
+
* private discovery = inject(DiscoveryService)
|
|
34
|
+
* private handlers = new Map<string, Function[]>()
|
|
35
|
+
*
|
|
36
|
+
* async onReady() {
|
|
37
|
+
* for (const { instance, methodName, metadata } of
|
|
38
|
+
* this.discovery.getMethodsWithMeta<{ event: string; handlerName: string }>(ON)) {
|
|
39
|
+
* const list = this.handlers.get(metadata.event) ?? []
|
|
40
|
+
* list.push((instance as any)[methodName].bind(instance))
|
|
41
|
+
* this.handlers.set(metadata.event, list)
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class DiscoveryService {
|
|
48
|
+
private readonly container;
|
|
49
|
+
constructor(container: Container);
|
|
50
|
+
/** All singleton instances currently in the container (providers + controllers + guards). */
|
|
51
|
+
getSingletons(): Array<{
|
|
52
|
+
ctor: Constructor;
|
|
53
|
+
instance: object;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Scans every singleton for the given metadata key. The metadata under
|
|
57
|
+
* `key` must be an array of objects each containing `handlerName: string`.
|
|
58
|
+
*
|
|
59
|
+
* Returns one entry per discovered method, ready for binding.
|
|
60
|
+
*/
|
|
61
|
+
getMethodsWithMeta<T extends DiscoverableMethodMeta>(key: symbol): DiscoveredMethod<T>[];
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=discovery-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-service.d.ts","sourceRoot":"","sources":["../../src/discovery/discovery-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,sBAAsB;IAChE,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,WAAW,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,CAAC,CAAA;CACZ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAEjD,6FAA6F;IAC7F,aAAa,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAI/D;;;;;OAKG;IACH,kBAAkB,CAAC,CAAC,SAAS,sBAAsB,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAAE;CAgBzF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { getMeta } from '../decorators/metadata.js';
|
|
2
|
+
/**
|
|
3
|
+
* Public facade over Container for ambient discovery of singleton instances
|
|
4
|
+
* and their method-level metadata. Auto-registered by Miia in its constructor.
|
|
5
|
+
*
|
|
6
|
+
* Use inside `onReady()` (not `onInit()`) to guarantee all providers have
|
|
7
|
+
* finished their own initialization before scanning.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const ON = Symbol('on')
|
|
12
|
+
* export const On = createMethodDecorator<[event: string]>((_target, ctx, event) => {
|
|
13
|
+
* pushMeta(ctx.metadata!, ON, { event, handlerName: ctx.name as string })
|
|
14
|
+
* })
|
|
15
|
+
*
|
|
16
|
+
* @Injectable()
|
|
17
|
+
* class EventBus {
|
|
18
|
+
* private discovery = inject(DiscoveryService)
|
|
19
|
+
* private handlers = new Map<string, Function[]>()
|
|
20
|
+
*
|
|
21
|
+
* async onReady() {
|
|
22
|
+
* for (const { instance, methodName, metadata } of
|
|
23
|
+
* this.discovery.getMethodsWithMeta<{ event: string; handlerName: string }>(ON)) {
|
|
24
|
+
* const list = this.handlers.get(metadata.event) ?? []
|
|
25
|
+
* list.push((instance as any)[methodName].bind(instance))
|
|
26
|
+
* this.handlers.set(metadata.event, list)
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export class DiscoveryService {
|
|
33
|
+
container;
|
|
34
|
+
constructor(container) {
|
|
35
|
+
this.container = container;
|
|
36
|
+
}
|
|
37
|
+
/** All singleton instances currently in the container (providers + controllers + guards). */
|
|
38
|
+
getSingletons() {
|
|
39
|
+
return this.container.getSingletonInstances();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Scans every singleton for the given metadata key. The metadata under
|
|
43
|
+
* `key` must be an array of objects each containing `handlerName: string`.
|
|
44
|
+
*
|
|
45
|
+
* Returns one entry per discovered method, ready for binding.
|
|
46
|
+
*/
|
|
47
|
+
getMethodsWithMeta(key) {
|
|
48
|
+
const result = [];
|
|
49
|
+
for (const { ctor, instance } of this.container.getSingletonInstances()) {
|
|
50
|
+
const items = getMeta(ctor, key);
|
|
51
|
+
if (!items || items.length === 0)
|
|
52
|
+
continue;
|
|
53
|
+
for (const metadata of items) {
|
|
54
|
+
result.push({
|
|
55
|
+
instance,
|
|
56
|
+
ctor,
|
|
57
|
+
methodName: metadata.handlerName,
|
|
58
|
+
metadata,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=discovery-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-service.js","sourceRoot":"","sources":["../../src/discovery/discovery-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAoBnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,gBAAgB;IACE;IAA7B,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAErD,6FAA6F;IAC7F,aAAa;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,qBAAqB,EAAE,CAAA;IAC/C,CAAC;IAED;;;;;OAKG;IACH,kBAAkB,CAAmC,GAAW;QAC9D,MAAM,MAAM,GAA0B,EAAE,CAAA;QACxC,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,qBAAqB,EAAE,EAAE,CAAC;YACxE,MAAM,KAAK,GAAG,OAAO,CAAM,IAAI,EAAE,GAAG,CAAC,CAAA;YACrC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAQ;YAC1C,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;gBAC7B,MAAM,CAAC,IAAI,CAAC;oBACV,QAAQ;oBACR,IAAI;oBACJ,UAAU,EAAE,QAAQ,CAAC,WAAW;oBAChC,QAAQ;iBACT,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare class HttpException extends Error {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
details?: unknown | undefined;
|
|
4
|
+
constructor(statusCode: number, message: string, details?: unknown | undefined);
|
|
5
|
+
toJSON(): Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export declare class BadRequestException extends HttpException {
|
|
8
|
+
constructor(message?: string, details?: unknown);
|
|
9
|
+
}
|
|
10
|
+
export declare class UnauthorizedException extends HttpException {
|
|
11
|
+
constructor(message?: string, details?: unknown);
|
|
12
|
+
}
|
|
13
|
+
export declare class ForbiddenException extends HttpException {
|
|
14
|
+
constructor(message?: string, details?: unknown);
|
|
15
|
+
}
|
|
16
|
+
export declare class NotFoundException extends HttpException {
|
|
17
|
+
constructor(message?: string, details?: unknown);
|
|
18
|
+
}
|
|
19
|
+
export declare class ConflictException extends HttpException {
|
|
20
|
+
constructor(message?: string, details?: unknown);
|
|
21
|
+
}
|
|
22
|
+
export declare class UnprocessableException extends HttpException {
|
|
23
|
+
constructor(message?: string, details?: unknown);
|
|
24
|
+
}
|
|
25
|
+
export declare class InternalServerException extends HttpException {
|
|
26
|
+
constructor(message?: string, details?: unknown);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=exceptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"AAcA,qBAAa,aAAc,SAAQ,KAAK;IAE7B,UAAU,EAAE,MAAM;IAElB,OAAO,CAAC,EAAE,OAAO;gBAFjB,UAAU,EAAE,MAAM,EACzB,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,OAAO,YAAA;IAM1B,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQlC;AAED,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,OAAO,SAAgB,EAAE,OAAO,CAAC,EAAE,OAAO;CAGvD;AAED,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,OAAO,SAAiB,EAAE,OAAO,CAAC,EAAE,OAAO;CAGxD;AAED,qBAAa,kBAAmB,SAAQ,aAAa;gBACvC,OAAO,SAAc,EAAE,OAAO,CAAC,EAAE,OAAO;CAGrD;AAED,qBAAa,iBAAkB,SAAQ,aAAa;gBACtC,OAAO,SAAc,EAAE,OAAO,CAAC,EAAE,OAAO;CAGrD;AAED,qBAAa,iBAAkB,SAAQ,aAAa;gBACtC,OAAO,SAAa,EAAE,OAAO,CAAC,EAAE,OAAO;CAGpD;AAED,qBAAa,sBAAuB,SAAQ,aAAa;gBAC3C,OAAO,SAAyB,EAAE,OAAO,CAAC,EAAE,OAAO;CAGhE;AAED,qBAAa,uBAAwB,SAAQ,aAAa;gBAC5C,OAAO,SAA0B,EAAE,OAAO,CAAC,EAAE,OAAO;CAGjE"}
|