@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bool-ts/core",
3
- "version": "1.5.10",
3
+ "version": "1.6.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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
+ };
@@ -1,10 +1,11 @@
1
1
  export {
2
- RequestHeaders,
3
2
  Body,
3
+ Config,
4
4
  Params,
5
5
  Param,
6
6
  Query,
7
7
  Request,
8
+ RequestHeaders,
8
9
  ResponseHeaders,
9
10
  EArgumentTypes,
10
11
  argumentsKey
@@ -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;