vovk 3.0.0-draft.310 → 3.0.0-draft.313

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.
@@ -116,7 +116,7 @@ export type VovkValidateOnClient = (input: {
116
116
  params?: unknown;
117
117
  endpoint: string;
118
118
  }, validation: Omit<Exclude<VovkHandlerSchema['validation'], undefined>, 'output' | 'iteration'>, fullSchema: VovkSchema) => void | Promise<void>;
119
- type IsEmptyObject<T> = T extends object ? keyof T extends never ? true : false : false;
119
+ type IsEmptyObject<T> = T extends object ? keyof T extends never ? true : T extends Partial<T> ? Partial<T> extends T ? true : false : false : false;
120
120
  type Prettify<T> = {
121
121
  [K in keyof T]: T[K];
122
122
  } & {};
package/cjs/types.d.ts CHANGED
@@ -16,7 +16,7 @@ export type VovkHandlerSchema<T = KnownAny> = {
16
16
  iteration?: T;
17
17
  };
18
18
  openapi?: OperationObject;
19
- misc?: Record<string, KnownAny> | Promise<Record<string, KnownAny>>;
19
+ misc?: Record<string, KnownAny>;
20
20
  };
21
21
  export type VovkControllerSchema<T = KnownAny> = {
22
22
  rpcModuleName: string;
@@ -77,7 +77,7 @@ export type DecoratorOptions = {
77
77
  export type RouteHandler = ((req: VovkRequest, params: Record<string, string>) => Response | Promise<Response> | Iterable<unknown> | AsyncIterable<unknown>) & {
78
78
  _options?: DecoratorOptions;
79
79
  };
80
- export interface VovkRequest<BODY = unknown, QUERY = unknown, PARAMS = unknown> extends Omit<NextRequest, 'json' | 'nextUrl'> {
80
+ export interface VovkRequest<BODY extends KnownAny = undefined, QUERY extends KnownAny = undefined, PARAMS extends KnownAny = undefined> extends Omit<NextRequest, 'json' | 'nextUrl'> {
81
81
  json: () => Promise<BODY>;
82
82
  nextUrl: Omit<NextRequest['nextUrl'], 'searchParams'> & {
83
83
  searchParams: Omit<NextRequest['nextUrl']['searchParams'], 'get' | 'getAll' | 'entries' | 'forEach' | 'keys' | 'values'> & {
@@ -8,7 +8,7 @@ export declare function getControllerSchema(controller: VovkController, rpcModul
8
8
  path: string;
9
9
  httpMethod: string;
10
10
  openapi?: import("openapi3-ts/oas31").OperationObject;
11
- misc?: Record<string, import("../types").KnownAny> | Promise<Record<string, import("../types").KnownAny>>;
11
+ misc?: Record<string, import("../types").KnownAny>;
12
12
  };
13
13
  };
14
14
  }>;
@@ -9,12 +9,6 @@ async function getControllerSchema(controller, rpcModuleName, exposeValidation)
9
9
  : Object.fromEntries(
10
10
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
11
  Object.entries(controller._handlers ?? {}).map(([key, { validation: _v, ...value }]) => [key, value]));
12
- // TODO: misc is the only async property for experimental purposes, this should be refactored and documented
13
- await Promise.all(Object.values(handlers ?? {})
14
- .filter(({ misc }) => misc instanceof Promise)
15
- .map(async (schema) => {
16
- schema.misc = await schema.misc;
17
- }));
18
12
  return {
19
13
  rpcModuleName,
20
14
  originalControllerName: controller.name,
@@ -116,7 +116,7 @@ export type VovkValidateOnClient = (input: {
116
116
  params?: unknown;
117
117
  endpoint: string;
118
118
  }, validation: Omit<Exclude<VovkHandlerSchema['validation'], undefined>, 'output' | 'iteration'>, fullSchema: VovkSchema) => void | Promise<void>;
119
- type IsEmptyObject<T> = T extends object ? keyof T extends never ? true : false : false;
119
+ type IsEmptyObject<T> = T extends object ? keyof T extends never ? true : T extends Partial<T> ? Partial<T> extends T ? true : false : false : false;
120
120
  type Prettify<T> = {
121
121
  [K in keyof T]: T[K];
122
122
  } & {};
package/mjs/types.d.ts CHANGED
@@ -16,7 +16,7 @@ export type VovkHandlerSchema<T = KnownAny> = {
16
16
  iteration?: T;
17
17
  };
18
18
  openapi?: OperationObject;
19
- misc?: Record<string, KnownAny> | Promise<Record<string, KnownAny>>;
19
+ misc?: Record<string, KnownAny>;
20
20
  };
21
21
  export type VovkControllerSchema<T = KnownAny> = {
22
22
  rpcModuleName: string;
@@ -77,7 +77,7 @@ export type DecoratorOptions = {
77
77
  export type RouteHandler = ((req: VovkRequest, params: Record<string, string>) => Response | Promise<Response> | Iterable<unknown> | AsyncIterable<unknown>) & {
78
78
  _options?: DecoratorOptions;
79
79
  };
80
- export interface VovkRequest<BODY = unknown, QUERY = unknown, PARAMS = unknown> extends Omit<NextRequest, 'json' | 'nextUrl'> {
80
+ export interface VovkRequest<BODY extends KnownAny = undefined, QUERY extends KnownAny = undefined, PARAMS extends KnownAny = undefined> extends Omit<NextRequest, 'json' | 'nextUrl'> {
81
81
  json: () => Promise<BODY>;
82
82
  nextUrl: Omit<NextRequest['nextUrl'], 'searchParams'> & {
83
83
  searchParams: Omit<NextRequest['nextUrl']['searchParams'], 'get' | 'getAll' | 'entries' | 'forEach' | 'keys' | 'values'> & {
@@ -8,7 +8,7 @@ export declare function getControllerSchema(controller: VovkController, rpcModul
8
8
  path: string;
9
9
  httpMethod: string;
10
10
  openapi?: import("openapi3-ts/oas31").OperationObject;
11
- misc?: Record<string, import("../types").KnownAny> | Promise<Record<string, import("../types").KnownAny>>;
11
+ misc?: Record<string, import("../types").KnownAny>;
12
12
  };
13
13
  };
14
14
  }>;
@@ -9,12 +9,6 @@ async function getControllerSchema(controller, rpcModuleName, exposeValidation)
9
9
  : Object.fromEntries(
10
10
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
11
  Object.entries(controller._handlers ?? {}).map(([key, { validation: _v, ...value }]) => [key, value]));
12
- // TODO: misc is the only async property for experimental purposes, this should be refactored and documented
13
- await Promise.all(Object.values(handlers ?? {})
14
- .filter(({ misc }) => misc instanceof Promise)
15
- .map(async (schema) => {
16
- schema.misc = await schema.misc;
17
- }));
18
12
  return {
19
13
  rpcModuleName,
20
14
  originalControllerName: controller.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.310",
3
+ "version": "3.0.0-draft.313",
4
4
  "main": "./cjs/index.js",
5
5
  "module": "./mjs/index.js",
6
6
  "types": "./mjs/index.d.ts",