snap-on-openapi 1.0.25 → 1.0.27

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/OpenApi.js CHANGED
@@ -284,7 +284,7 @@ export class OpenApi {
284
284
  if (this.config.onResponse) {
285
285
  await this.config.onResponse(onResponse);
286
286
  }
287
- return response;
287
+ return { status: validated.data.status, body: validated.data.body, headers: validated.data.headers };
288
288
  }
289
289
  catch (e) {
290
290
  return await this.handleError(e, originalReq, {
@@ -1,4 +1,4 @@
1
- import { ZodFirstPartySchemaTypes, ZodObject, ZodRawShape } from 'zod';
1
+ import { ZodTypeAny, ZodObject, ZodRawShape } from 'zod';
2
2
  import { Method } from '../../enums/Methods.js';
3
3
  import { Route } from '../../types/Route.js';
4
4
  import { AnyConfig } from '../../types/config/AnyConfig.js';
@@ -7,6 +7,6 @@ import { StandardRoute } from './types/StandardRoute.js';
7
7
  export declare class RoutingFactory<TRouteTypes extends string, TErrorCodes extends string, TConfig extends AnyConfig<TRouteTypes, TErrorCodes>> {
8
8
  protected map: TConfig;
9
9
  constructor(map: TConfig);
10
- createCustomRoute<TType extends TRouteTypes, TMethod extends Method, TResponseValidator extends ZodFirstPartySchemaTypes | undefined = undefined, TQueryValidator extends ZodObject<ZodRawShape> | undefined = undefined, TPathValidator extends ZodObject<ZodRawShape> | undefined = undefined, TBodyValidator extends ZodFirstPartySchemaTypes | undefined = undefined, TResponseHeadersValidator extends ZodObject<ZodRawShape> | undefined = undefined>(params: Route<TType, Awaited<ReturnType<TConfig['routes'][TType]['contextFactory']>>, TResponseValidator, TPathValidator, TQueryValidator, TBodyValidator, TResponseHeadersValidator, TMethod> & (RouteExtraProps<TConfig['routes'][TType]['extraProps']>)): Route<TType, Awaited<ReturnType<TConfig['routes'][TType]['contextFactory']>>, TResponseValidator, TPathValidator, TQueryValidator, TBodyValidator, TResponseHeadersValidator>;
11
- createRoute<TType extends TRouteTypes, TMethod extends Method, TResponseValidator extends ZodFirstPartySchemaTypes | undefined = undefined, TQueryValidator extends ZodObject<ZodRawShape> | undefined = undefined, TPathValidator extends ZodObject<ZodRawShape> | undefined = undefined, TBodyValidator extends ZodFirstPartySchemaTypes | undefined = undefined, TResponseHeadersValidator extends ZodObject<ZodRawShape> | undefined = undefined>(params: StandardRoute<TType, Awaited<ReturnType<TConfig['routes'][TType]['contextFactory']>>, TResponseValidator, TPathValidator, TQueryValidator, TBodyValidator, TMethod> & (RouteExtraProps<TConfig['routes'][TType]['extraProps']>)): Route<TType, Awaited<ReturnType<TConfig['routes'][TType]['contextFactory']>>, TResponseValidator, TPathValidator, TQueryValidator, TBodyValidator, TResponseHeadersValidator>;
10
+ createCustomRoute<TType extends TRouteTypes, TMethod extends Method, TResponseValidator extends ZodTypeAny | undefined = undefined, TQueryValidator extends ZodObject<ZodRawShape> | undefined = undefined, TPathValidator extends ZodObject<ZodRawShape> | undefined = undefined, TBodyValidator extends ZodTypeAny | undefined = undefined, TResponseHeadersValidator extends ZodObject<ZodRawShape> | undefined = undefined>(params: Route<TType, Awaited<ReturnType<TConfig['routes'][TType]['contextFactory']>>, TResponseValidator, TPathValidator, TQueryValidator, TBodyValidator, TResponseHeadersValidator, TMethod> & (RouteExtraProps<TConfig['routes'][TType]['extraProps']>)): Route<TType, Awaited<ReturnType<TConfig['routes'][TType]['contextFactory']>>, TResponseValidator, TPathValidator, TQueryValidator, TBodyValidator, TResponseHeadersValidator>;
11
+ createRoute<TType extends TRouteTypes, TMethod extends Method, TResponseValidator extends ZodTypeAny | undefined = undefined, TQueryValidator extends ZodObject<ZodRawShape> | undefined = undefined, TPathValidator extends ZodObject<ZodRawShape> | undefined = undefined, TBodyValidator extends ZodTypeAny | undefined = undefined, TResponseHeadersValidator extends ZodObject<ZodRawShape> | undefined = undefined>(params: StandardRoute<TType, Awaited<ReturnType<TConfig['routes'][TType]['contextFactory']>>, TResponseValidator, TPathValidator, TQueryValidator, TBodyValidator, TMethod> & (RouteExtraProps<TConfig['routes'][TType]['extraProps']>)): Route<TType, Awaited<ReturnType<TConfig['routes'][TType]['contextFactory']>>, TResponseValidator, TPathValidator, TQueryValidator, TBodyValidator, TResponseHeadersValidator>;
12
12
  }
@@ -1,8 +1,8 @@
1
- import { z, ZodFirstPartySchemaTypes, ZodObject, ZodRawShape } from 'zod';
1
+ import { z, ZodTypeAny, ZodObject, ZodRawShape } from 'zod';
2
2
  import { Method } from '../../../enums/Methods.js';
3
3
  import { RoutePath } from '../../../types/RoutePath.js';
4
- type BodyHandlerResponse<T extends ZodFirstPartySchemaTypes | undefined = undefined> = Promise<T extends undefined ? void : z.infer<Exclude<T, undefined>>>;
5
- export interface StandardRoute<TType extends string, TContext extends object, TResponseValidator extends ZodFirstPartySchemaTypes | undefined, TPathValidator extends ZodObject<ZodRawShape> | undefined, TQueryValidator extends ZodObject<ZodRawShape> | undefined, TBodyValidator extends ZodFirstPartySchemaTypes | undefined, TMethod extends Method = Method> {
4
+ type BodyHandlerResponse<T extends ZodTypeAny | undefined = undefined> = Promise<T extends undefined ? void : z.infer<Exclude<T, undefined>>>;
5
+ export interface StandardRoute<TType extends string, TContext extends object, TResponseValidator extends ZodTypeAny | undefined, TPathValidator extends ZodObject<ZodRawShape> | undefined, TQueryValidator extends ZodObject<ZodRawShape> | undefined, TBodyValidator extends ZodTypeAny | undefined, TMethod extends Method = Method> {
6
6
  tags?: string[];
7
7
  operationId?: string;
8
8
  type: TType;
@@ -17,7 +17,7 @@ export interface StandardRoute<TType extends string, TContext extends object, TR
17
17
  };
18
18
  handler: (context: {
19
19
  params: {
20
- body: TBodyValidator extends ZodFirstPartySchemaTypes ? z.infer<TBodyValidator> : object;
20
+ body: TBodyValidator extends ZodTypeAny ? z.infer<TBodyValidator> : object;
21
21
  query: TQueryValidator extends ZodObject<ZodRawShape> ? z.infer<TQueryValidator> : object;
22
22
  path: TPathValidator extends ZodObject<ZodRawShape> ? z.infer<TPathValidator> : object;
23
23
  };
@@ -40,18 +40,18 @@ export declare class ValidationUtils {
40
40
  count: number;
41
41
  }>;
42
42
  }, "strip", import("zod").ZodTypeAny, {
43
- items: T["_output"][];
44
43
  info: {
45
44
  page: number;
46
45
  pageSize: number;
47
46
  count: number;
48
47
  };
48
+ items: T["_output"][];
49
49
  }, {
50
- items: T["_input"][];
51
50
  info: {
52
51
  page: number;
53
52
  pageSize: number;
54
53
  count: number;
55
54
  };
55
+ items: T["_input"][];
56
56
  }>;
57
57
  }
@@ -1,3 +1,3 @@
1
- import { ZodObject, ZodRawShape, ZodFirstPartySchemaTypes } from 'zod';
1
+ import { ZodObject, ZodRawShape, ZodTypeAny } from 'zod';
2
2
  import { Route } from './Route.js';
3
- export type AnyRoute<TRouteType extends string> = Route<TRouteType, any, ZodFirstPartySchemaTypes | undefined, ZodObject<ZodRawShape> | undefined, ZodObject<ZodRawShape> | undefined, ZodFirstPartySchemaTypes | undefined, ZodObject<ZodRawShape> | undefined>;
3
+ export type AnyRoute<TRouteType extends string> = Route<TRouteType, any, ZodTypeAny | undefined, ZodObject<ZodRawShape> | undefined, ZodObject<ZodRawShape> | undefined, ZodTypeAny | undefined, ZodObject<ZodRawShape> | undefined>;
@@ -1,8 +1,8 @@
1
- import { z, ZodFirstPartySchemaTypes, ZodObject, ZodRawShape } from 'zod';
1
+ import { z, ZodTypeAny, ZodObject, ZodRawShape } from 'zod';
2
2
  import { Method } from '../enums/Methods.js';
3
3
  import { RoutePath } from './RoutePath.js';
4
4
  import { RouteResponse } from './RouteResponse.js';
5
- export interface Route<TType extends string, TContext extends object, TResponseValidator extends ZodFirstPartySchemaTypes | undefined, TPathValidator extends ZodObject<ZodRawShape> | undefined, TQueryValidator extends ZodObject<ZodRawShape> | undefined, TBodyValidator extends ZodFirstPartySchemaTypes | undefined, TResponseHeadersValidator extends ZodObject<ZodRawShape> | undefined, TMethod extends Method = Method> {
5
+ export interface Route<TType extends string, TContext extends object, TResponseValidator extends ZodTypeAny | undefined, TPathValidator extends ZodObject<ZodRawShape> | undefined, TQueryValidator extends ZodObject<ZodRawShape> | undefined, TBodyValidator extends ZodTypeAny | undefined, TResponseHeadersValidator extends ZodObject<ZodRawShape> | undefined, TMethod extends Method = Method> {
6
6
  tags?: string[];
7
7
  operationId?: string;
8
8
  type: TType;
@@ -18,7 +18,7 @@ export interface Route<TType extends string, TContext extends object, TResponseV
18
18
  };
19
19
  handler: (context: {
20
20
  params: {
21
- body: TBodyValidator extends ZodFirstPartySchemaTypes ? z.infer<TBodyValidator> : object;
21
+ body: TBodyValidator extends ZodTypeAny ? z.infer<TBodyValidator> : object;
22
22
  query: TQueryValidator extends ZodObject<ZodRawShape> ? z.infer<TQueryValidator> : object;
23
23
  path: TPathValidator extends ZodObject<ZodRawShape> ? z.infer<TPathValidator> : object;
24
24
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "snap-on-openapi",
3
3
  "author": "Alex Sarychev",
4
- "version": "1.0.25",
4
+ "version": "1.0.27",
5
5
  "description": "Swiftly build type-checked OpenAPI applications with Zod and TypeScript",
6
6
  "type": "module",
7
7
  "license": "ISC",