@bool-ts/core 1.5.10 → 1.6.1
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/dist/decorators/arguments.d.ts +7 -1
- package/dist/decorators/arguments.js +15 -0
- package/dist/decorators/index.d.ts +1 -1
- package/dist/decorators/index.js +1 -1
- package/dist/decorators/module.d.ts +2 -0
- package/dist/hooks/factory.d.ts +2 -1
- package/dist/hooks/factory.js +332 -306
- package/package.json +1 -1
- package/src/decorators/arguments.ts +30 -1
- package/src/decorators/index.ts +2 -1
- package/src/decorators/module.ts +2 -0
- package/src/hooks/factory.ts +498 -464
package/package.json
CHANGED
|
@@ -7,7 +7,8 @@ export enum EArgumentTypes {
|
|
|
7
7
|
param = "PARAM",
|
|
8
8
|
query = "QUERY",
|
|
9
9
|
request = "REQUEST",
|
|
10
|
-
responseHeaders = "RESPONSE_HEADERS"
|
|
10
|
+
responseHeaders = "RESPONSE_HEADERS",
|
|
11
|
+
config = "CONFIG"
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export type TArgumentsMetadata =
|
|
@@ -47,6 +48,11 @@ export type TArgumentsMetadata =
|
|
|
47
48
|
index: number;
|
|
48
49
|
type: EArgumentTypes.responseHeaders;
|
|
49
50
|
zodSchema?: Zod.Schema;
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
index: number;
|
|
54
|
+
type: EArgumentTypes.config;
|
|
55
|
+
zodSchema?: Zod.Schema;
|
|
50
56
|
};
|
|
51
57
|
|
|
52
58
|
export const argumentsKey = Symbol.for("__bool:arguments__");
|
|
@@ -212,3 +218,26 @@ export const ResponseHeaders = (zodSchema?: Zod.Schema) => {
|
|
|
212
218
|
Reflect.defineMetadata(argumentsKey, queryMetadata, target.constructor, methodName);
|
|
213
219
|
};
|
|
214
220
|
};
|
|
221
|
+
|
|
222
|
+
export const Config = (zodSchema?: Zod.Schema) => {
|
|
223
|
+
return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
224
|
+
if (!methodName) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const queryMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
229
|
+
|
|
230
|
+
queryMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
231
|
+
index: parameterIndex,
|
|
232
|
+
type: EArgumentTypes.config,
|
|
233
|
+
zodSchema: zodSchema
|
|
234
|
+
} satisfies Extract<
|
|
235
|
+
TArgumentsMetadata,
|
|
236
|
+
{
|
|
237
|
+
type: EArgumentTypes.config;
|
|
238
|
+
}
|
|
239
|
+
>;
|
|
240
|
+
|
|
241
|
+
Reflect.defineMetadata(argumentsKey, queryMetadata, target.constructor, methodName);
|
|
242
|
+
};
|
|
243
|
+
};
|
package/src/decorators/index.ts
CHANGED
package/src/decorators/module.ts
CHANGED
|
@@ -9,6 +9,7 @@ type TInstances = Array<new (...args: any[]) => any>;
|
|
|
9
9
|
|
|
10
10
|
export type TModuleOptions =
|
|
11
11
|
| Partial<{
|
|
12
|
+
config: Record<string | symbol, any> | (() => Record<string | symbol, any> | Promise<Record<string | symbol, any>>);
|
|
12
13
|
prefix: string;
|
|
13
14
|
dependencies: TInstances;
|
|
14
15
|
controllers: TInstances;
|
|
@@ -21,6 +22,7 @@ export type TModuleOptions =
|
|
|
21
22
|
|
|
22
23
|
export type TModuleMetadata =
|
|
23
24
|
| Partial<{
|
|
25
|
+
config: Record<string | symbol, any> | (() => Record<string | symbol, any> | Promise<Record<string | symbol, any>>);
|
|
24
26
|
prefix: string;
|
|
25
27
|
controllers: TInstances;
|
|
26
28
|
dependencies: TInstances;
|