better-call 0.2.13-beta.6 → 0.2.13-beta.8

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,6 +1,6 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
2
  import * as undici_types from 'undici-types';
3
- import { R as Router } from '../shared/better-call.bb4fb8f1.cjs';
3
+ import { R as Router } from '../shared/better-call.25f0dd59.cjs';
4
4
  import 'zod';
5
5
  import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
6
6
  import '@asteasolutions/zod-to-openapi';
@@ -1,6 +1,6 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
2
  import * as undici_types from 'undici-types';
3
- import { R as Router } from '../shared/better-call.bb4fb8f1.mjs';
3
+ import { R as Router } from '../shared/better-call.25f0dd59.mjs';
4
4
  import 'zod';
5
5
  import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
6
6
  import '@asteasolutions/zod-to-openapi';
@@ -1,6 +1,6 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
2
  import * as undici_types from 'undici-types';
3
- import { R as Router } from '../shared/better-call.bb4fb8f1.js';
3
+ import { R as Router } from '../shared/better-call.25f0dd59.js';
4
4
  import 'zod';
5
5
  import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
6
6
  import '@asteasolutions/zod-to-openapi';
package/dist/client.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BetterFetchOption, BetterFetchResponse } from '@better-fetch/fetch';
2
- import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.bb4fb8f1.cjs';
2
+ import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.25f0dd59.cjs';
3
3
  import 'zod';
4
4
  import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
5
5
  import '@asteasolutions/zod-to-openapi';
package/dist/client.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BetterFetchOption, BetterFetchResponse } from '@better-fetch/fetch';
2
- import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.bb4fb8f1.mjs';
2
+ import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.25f0dd59.mjs';
3
3
  import 'zod';
4
4
  import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
5
5
  import '@asteasolutions/zod-to-openapi';
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BetterFetchOption, BetterFetchResponse } from '@better-fetch/fetch';
2
- import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.bb4fb8f1.js';
2
+ import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.25f0dd59.js';
3
3
  import 'zod';
4
4
  import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
5
5
  import '@asteasolutions/zod-to-openapi';
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.bb4fb8f1.cjs';
2
- export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, _ as _statusCode, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.bb4fb8f1.cjs';
1
+ import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.25f0dd59.cjs';
2
+ export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, M as MergeObject, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, _ as _statusCode, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.25f0dd59.cjs';
3
3
  import { BufferSource } from 'stream/web';
4
4
  import 'zod';
5
5
  import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.bb4fb8f1.mjs';
2
- export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, _ as _statusCode, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.bb4fb8f1.mjs';
1
+ import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.25f0dd59.mjs';
2
+ export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, M as MergeObject, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, _ as _statusCode, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.25f0dd59.mjs';
3
3
  import { BufferSource } from 'stream/web';
4
4
  import 'zod';
5
5
  import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.bb4fb8f1.js';
2
- export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, _ as _statusCode, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.bb4fb8f1.js';
1
+ import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.25f0dd59.js';
2
+ export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, M as MergeObject, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, _ as _statusCode, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.25f0dd59.js';
3
3
  import { BufferSource } from 'stream/web';
4
4
  import 'zod';
5
5
  import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
@@ -21,6 +21,7 @@ type Prettify<T> = {
21
21
  } & {};
22
22
  type IsEmptyObject<T> = keyof T extends never ? true : false;
23
23
  type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection & Union : never;
24
+ type MergeObject<T extends Record<string, any> | never, S extends Record<string, any> | never> = T extends never ? S : S extends never ? T : T & S;
24
25
 
25
26
  declare module "zod" {
26
27
  interface ZodTypeDef {
@@ -85,7 +86,7 @@ type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/$
85
86
  type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? never : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
86
87
  type InferRequest<Option extends EndpointOptions> = Option["requireRequest"] extends true ? Request : Request | undefined;
87
88
  type InferHeaders<Option extends EndpointOptions> = Option["requireHeaders"] extends true ? Headers : Headers | undefined;
88
- type InferUse<Opts extends EndpointOptions["use"]> = Opts extends Endpoint[] ? UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : never;
89
+ type InferUse<Opts extends EndpointOptions["use"]> = Opts extends Endpoint[] ? UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : {};
89
90
  type InferMethod<Options extends EndpointOptions> = Options["method"] extends Array<Method> ? Options["method"][number] : Options["method"];
90
91
 
91
92
  type Cookie = Record<string, string>;
@@ -202,7 +203,7 @@ interface EndpointContext<Path extends string, Options extends EndpointOptions>
202
203
  * @param routerResponse - The response object to return if `asResponse` is
203
204
  * true in the context this will take precedence
204
205
  */
205
- json: <R extends Record<string, any>>(json: R, routerResponse?: {
206
+ json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
206
207
  status?: number;
207
208
  headers?: Record<string, string>;
208
209
  response?: Response;
@@ -331,7 +332,7 @@ interface JSONResponse<R = any> {
331
332
  */
332
333
  _flag: "json";
333
334
  }
334
- type EndpointResponse = JSONResponse | Response | void | Record<string, any>;
335
+ type EndpointResponse = JSONResponse | Response | void | Record<string, any> | null;
335
336
  type InferResponse<Ctx, R> = Ctx extends {
336
337
  asResponse: true;
337
338
  } ? Response : R extends JSONResponse<infer T> ? T : R;
@@ -366,7 +367,7 @@ declare const createEndpoint: {
366
367
  declare function createEndpointCreator<E extends {
367
368
  use: Endpoint[];
368
369
  }>(opts: E): <Path extends string, Opts extends EndpointOptions, R extends EndpointResponse>(path: Path, options: Opts, handler: <InferE extends EndpointContext<Path, Opts>>(ctx: Omit<InferE, "context"> & {
369
- context: InferUse<E["use"]> & (InferE["context"] extends never ? {} : InferE["context"]);
370
+ context: InferUse<E["use"]> & InferE["context"];
370
371
  }) => Promise<R>) => {
371
372
  <Ctx extends ({
372
373
  body: InferBody<Opts & {
@@ -673,4 +674,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
673
674
  };
674
675
  type Router = ReturnType<typeof createRouter>;
675
676
 
676
- export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, _statusCode as _, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
677
+ export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type MergeObject as M, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, _statusCode as _, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
@@ -21,6 +21,7 @@ type Prettify<T> = {
21
21
  } & {};
22
22
  type IsEmptyObject<T> = keyof T extends never ? true : false;
23
23
  type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection & Union : never;
24
+ type MergeObject<T extends Record<string, any> | never, S extends Record<string, any> | never> = T extends never ? S : S extends never ? T : T & S;
24
25
 
25
26
  declare module "zod" {
26
27
  interface ZodTypeDef {
@@ -85,7 +86,7 @@ type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/$
85
86
  type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? never : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
86
87
  type InferRequest<Option extends EndpointOptions> = Option["requireRequest"] extends true ? Request : Request | undefined;
87
88
  type InferHeaders<Option extends EndpointOptions> = Option["requireHeaders"] extends true ? Headers : Headers | undefined;
88
- type InferUse<Opts extends EndpointOptions["use"]> = Opts extends Endpoint[] ? UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : never;
89
+ type InferUse<Opts extends EndpointOptions["use"]> = Opts extends Endpoint[] ? UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : {};
89
90
  type InferMethod<Options extends EndpointOptions> = Options["method"] extends Array<Method> ? Options["method"][number] : Options["method"];
90
91
 
91
92
  type Cookie = Record<string, string>;
@@ -202,7 +203,7 @@ interface EndpointContext<Path extends string, Options extends EndpointOptions>
202
203
  * @param routerResponse - The response object to return if `asResponse` is
203
204
  * true in the context this will take precedence
204
205
  */
205
- json: <R extends Record<string, any>>(json: R, routerResponse?: {
206
+ json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
206
207
  status?: number;
207
208
  headers?: Record<string, string>;
208
209
  response?: Response;
@@ -331,7 +332,7 @@ interface JSONResponse<R = any> {
331
332
  */
332
333
  _flag: "json";
333
334
  }
334
- type EndpointResponse = JSONResponse | Response | void | Record<string, any>;
335
+ type EndpointResponse = JSONResponse | Response | void | Record<string, any> | null;
335
336
  type InferResponse<Ctx, R> = Ctx extends {
336
337
  asResponse: true;
337
338
  } ? Response : R extends JSONResponse<infer T> ? T : R;
@@ -366,7 +367,7 @@ declare const createEndpoint: {
366
367
  declare function createEndpointCreator<E extends {
367
368
  use: Endpoint[];
368
369
  }>(opts: E): <Path extends string, Opts extends EndpointOptions, R extends EndpointResponse>(path: Path, options: Opts, handler: <InferE extends EndpointContext<Path, Opts>>(ctx: Omit<InferE, "context"> & {
369
- context: InferUse<E["use"]> & (InferE["context"] extends never ? {} : InferE["context"]);
370
+ context: InferUse<E["use"]> & InferE["context"];
370
371
  }) => Promise<R>) => {
371
372
  <Ctx extends ({
372
373
  body: InferBody<Opts & {
@@ -673,4 +674,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
673
674
  };
674
675
  type Router = ReturnType<typeof createRouter>;
675
676
 
676
- export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, _statusCode as _, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
677
+ export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type MergeObject as M, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, _statusCode as _, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
@@ -21,6 +21,7 @@ type Prettify<T> = {
21
21
  } & {};
22
22
  type IsEmptyObject<T> = keyof T extends never ? true : false;
23
23
  type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection & Union : never;
24
+ type MergeObject<T extends Record<string, any> | never, S extends Record<string, any> | never> = T extends never ? S : S extends never ? T : T & S;
24
25
 
25
26
  declare module "zod" {
26
27
  interface ZodTypeDef {
@@ -85,7 +86,7 @@ type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/$
85
86
  type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? never : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
86
87
  type InferRequest<Option extends EndpointOptions> = Option["requireRequest"] extends true ? Request : Request | undefined;
87
88
  type InferHeaders<Option extends EndpointOptions> = Option["requireHeaders"] extends true ? Headers : Headers | undefined;
88
- type InferUse<Opts extends EndpointOptions["use"]> = Opts extends Endpoint[] ? UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : never;
89
+ type InferUse<Opts extends EndpointOptions["use"]> = Opts extends Endpoint[] ? UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : {};
89
90
  type InferMethod<Options extends EndpointOptions> = Options["method"] extends Array<Method> ? Options["method"][number] : Options["method"];
90
91
 
91
92
  type Cookie = Record<string, string>;
@@ -202,7 +203,7 @@ interface EndpointContext<Path extends string, Options extends EndpointOptions>
202
203
  * @param routerResponse - The response object to return if `asResponse` is
203
204
  * true in the context this will take precedence
204
205
  */
205
- json: <R extends Record<string, any>>(json: R, routerResponse?: {
206
+ json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
206
207
  status?: number;
207
208
  headers?: Record<string, string>;
208
209
  response?: Response;
@@ -331,7 +332,7 @@ interface JSONResponse<R = any> {
331
332
  */
332
333
  _flag: "json";
333
334
  }
334
- type EndpointResponse = JSONResponse | Response | void | Record<string, any>;
335
+ type EndpointResponse = JSONResponse | Response | void | Record<string, any> | null;
335
336
  type InferResponse<Ctx, R> = Ctx extends {
336
337
  asResponse: true;
337
338
  } ? Response : R extends JSONResponse<infer T> ? T : R;
@@ -366,7 +367,7 @@ declare const createEndpoint: {
366
367
  declare function createEndpointCreator<E extends {
367
368
  use: Endpoint[];
368
369
  }>(opts: E): <Path extends string, Opts extends EndpointOptions, R extends EndpointResponse>(path: Path, options: Opts, handler: <InferE extends EndpointContext<Path, Opts>>(ctx: Omit<InferE, "context"> & {
369
- context: InferUse<E["use"]> & (InferE["context"] extends never ? {} : InferE["context"]);
370
+ context: InferUse<E["use"]> & InferE["context"];
370
371
  }) => Promise<R>) => {
371
372
  <Ctx extends ({
372
373
  body: InferBody<Opts & {
@@ -673,4 +674,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
673
674
  };
674
675
  type Router = ReturnType<typeof createRouter>;
675
676
 
676
- export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, _statusCode as _, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
677
+ export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type MergeObject as M, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, _statusCode as _, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-call",
3
- "version": "0.2.13-beta.6",
3
+ "version": "0.2.13-beta.8",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.ts",