vovk 3.0.0-draft.86 → 3.0.0-draft.87

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.
@@ -1,7 +1,6 @@
1
- import type { VovkHandlerSchema, KnownAny, VovkController, VovkRequest, VovkControllerSchema } from './types';
1
+ import type { VovkHandlerSchema, KnownAny, VovkController, VovkRequest } from './types';
2
2
  type Next = () => Promise<unknown>;
3
3
  export declare function createDecorator<ARGS extends unknown[], REQUEST = VovkRequest>(handler: null | ((this: VovkController, req: REQUEST, next: Next, ...args: ARGS) => unknown), initHandler?: (this: VovkController, ...args: ARGS) => Omit<VovkHandlerSchema, 'path' | 'httpMethod'> | ((handlerSchema: VovkHandlerSchema | null, options: {
4
4
  handlerName: string;
5
- controllerSchema: VovkControllerSchema;
6
5
  }) => Omit<Partial<VovkHandlerSchema>, 'path' | 'httpMethod'>) | null | undefined): (...args: ARGS) => (target: KnownAny, propertyKey: string) => void;
7
6
  export {};
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createDecorator = createDecorator;
4
- const getSchema_1 = require("./utils/getSchema");
5
4
  function createDecorator(handler, initHandler) {
6
5
  return function decoratorCreator(...args) {
7
6
  return function decorator(target, propertyKey) {
@@ -27,7 +26,6 @@ function createDecorator(handler, initHandler) {
27
26
  const initResult = typeof initResultReturn === 'function'
28
27
  ? initResultReturn(handlerSchema, {
29
28
  handlerName: propertyKey,
30
- controllerSchema: (0, getSchema_1.getControllerSchema)(controller, controller._controllerName ?? 'ERROR', true),
31
29
  })
32
30
  : initResultReturn;
33
31
  controller._handlers = {
package/dist/types.d.ts CHANGED
@@ -50,7 +50,7 @@ export type DecoratorOptions = {
50
50
  export type RouteHandler = ((req: VovkRequest, params: Record<string, string>) => Response | Promise<Response> | Iterable<unknown> | AsyncIterable<unknown>) & {
51
51
  _options?: DecoratorOptions;
52
52
  };
53
- export interface VovkRequest<BODY extends KnownAny = null, QUERY extends KnownAny = undefined, PARAMS extends object = Record<string, string>> extends Omit<NextRequest, 'json' | 'nextUrl'> {
53
+ export interface VovkRequest<BODY extends KnownAny = null, QUERY extends KnownAny = undefined, PARAMS extends KnownAny = undefined> extends Omit<NextRequest, 'json' | 'nextUrl'> {
54
54
  json: () => Promise<BODY>;
55
55
  nextUrl: Omit<NextRequest['nextUrl'], 'searchParams'> & {
56
56
  searchParams: Omit<NextRequest['nextUrl']['searchParams'], 'get' | 'getAll' | 'entries' | 'forEach' | 'keys' | 'values'> & {
@@ -77,7 +77,7 @@ export type ControllerStaticMethod<REQ extends VovkRequest<KnownAny, KnownAny> =
77
77
  };
78
78
  export type VovkControllerBody<T extends (...args: KnownAny) => KnownAny> = Awaited<ReturnType<Parameters<T>[0]['vovk']['body']>>;
79
79
  export type VovkControllerQuery<T extends (...args: KnownAny) => KnownAny> = ReturnType<Parameters<T>[0]['vovk']['query']>;
80
- export type VovkControllerParams<T extends (...args: KnownAny) => KnownAny> = Parameters<T>[1];
80
+ export type VovkControllerParams<T extends (...args: KnownAny) => KnownAny> = Parameters<T>[1] extends object ? Parameters<T>[1] : ReturnType<Parameters<T>[0]['vovk']['params']>;
81
81
  export type VovkControllerYieldType<T extends (req: VovkRequest<KnownAny, KnownAny>) => KnownAny> = T extends (...args: KnownAny[]) => AsyncGenerator<infer Y, KnownAny, KnownAny> ? Y : T extends (...args: KnownAny[]) => Generator<infer Y, KnownAny, KnownAny> ? Y : T extends (...args: KnownAny[]) => Promise<StreamJSONResponse<infer Y>> | StreamJSONResponse<infer Y> ? Y : never;
82
82
  export type VovkBody<T extends (...args: KnownAny[]) => unknown> = Parameters<T>[0]['body'];
83
83
  export type VovkQuery<T extends (...args: KnownAny[]) => unknown> = Parameters<T>[0]['query'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.86",
3
+ "version": "3.0.0-draft.87",
4
4
  "main": "dist/index.js",
5
5
  "description": "RESTful RPC for Next.js - Transforms Next.js into a powerful REST API platform with RPC capabilities.",
6
6
  "repository": {