better-call 1.0.0-beta.3 → 1.0.0-beta.5

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/node.d.cts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { j as Router } from './router-DNpkEV0c.cjs';
3
- import '@standard-schema/spec';
2
+ import { j as Router } from './router-G7pIJBUB.cjs';
4
3
 
5
4
  declare function getRequest({ request, base, bodySizeLimit, }: {
6
5
  base: string;
package/dist/node.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { j as Router } from './router-DNpkEV0c.js';
3
- import '@standard-schema/spec';
2
+ import { j as Router } from './router-G7pIJBUB.js';
4
3
 
5
4
  declare function getRequest({ request, base, bodySizeLimit, }: {
6
5
  base: string;
@@ -1,5 +1,3 @@
1
- import { StandardSchemaV1 } from '@standard-schema/spec';
2
-
3
1
  declare const _statusCode: {
4
2
  OK: number;
5
3
  CREATED: number;
@@ -84,6 +82,7 @@ type Prettify<T> = {
84
82
  } & {};
85
83
  type IsEmptyObject<T> = keyof T extends never ? true : false;
86
84
  type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection & Union : never;
85
+ type MergeObject<T extends Record<string, any> | never, S extends Record<string, any> | never> = T extends never ? S : S extends never ? T : T & S;
87
86
  type InferParamPath<Path> = Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
88
87
  [K in Param | keyof InferParamPath<Rest>]: string;
89
88
  } : Path extends `${infer _Start}:${infer Param}` ? {
@@ -329,6 +328,62 @@ declare function parseCookies(cookieHeader: string): Map<string, string>;
329
328
  declare const serializeCookie: (key: string, value: string, opt?: CookieOptions) => string;
330
329
  declare const serializeSignedCookie: (key: string, value: string, secret: string, opt?: CookieOptions) => Promise<string>;
331
330
 
331
+ /** The Standard Schema interface. */
332
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
333
+ /** The Standard Schema properties. */
334
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
335
+ }
336
+ declare namespace StandardSchemaV1 {
337
+ /** The Standard Schema properties interface. */
338
+ interface Props<Input = unknown, Output = Input> {
339
+ /** The version number of the standard. */
340
+ readonly version: 1;
341
+ /** The vendor name of the schema library. */
342
+ readonly vendor: string;
343
+ /** Validates unknown input values. */
344
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
345
+ /** Inferred types associated with the schema. */
346
+ readonly types?: Types<Input, Output> | undefined;
347
+ }
348
+ /** The result interface of the validate function. */
349
+ type Result<Output> = SuccessResult<Output> | FailureResult;
350
+ /** The result interface if validation succeeds. */
351
+ interface SuccessResult<Output> {
352
+ /** The typed output value. */
353
+ readonly value: Output;
354
+ /** The non-existent issues. */
355
+ readonly issues?: undefined;
356
+ }
357
+ /** The result interface if validation fails. */
358
+ interface FailureResult {
359
+ /** The issues of failed validation. */
360
+ readonly issues: ReadonlyArray<Issue>;
361
+ }
362
+ /** The issue interface of the failure output. */
363
+ interface Issue {
364
+ /** The error message of the issue. */
365
+ readonly message: string;
366
+ /** The path of the issue, if any. */
367
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
368
+ }
369
+ /** The path segment interface of the issue. */
370
+ interface PathSegment {
371
+ /** The key representing a path segment. */
372
+ readonly key: PropertyKey;
373
+ }
374
+ /** The Standard Schema types interface. */
375
+ interface Types<Input = unknown, Output = Input> {
376
+ /** The input type of the schema. */
377
+ readonly input: Input;
378
+ /** The output type of the schema. */
379
+ readonly output: Output;
380
+ }
381
+ /** Infers the input type of a Standard Schema. */
382
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
383
+ /** Infers the output type of a Standard Schema. */
384
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
385
+ }
386
+
332
387
  type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
333
388
  type Method = HTTPMethod | "*";
334
389
  type InferBodyInput<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
@@ -430,7 +485,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
430
485
  status?: number;
431
486
  headers?: Record<string, string>;
432
487
  response?: Response;
433
- body?: Record<string, string>;
488
+ body?: Record<string, any>;
434
489
  } | Response) => Record<string, any>;
435
490
  responseHeaders: Headers;
436
491
  asResponse?: boolean | undefined;
@@ -1206,4 +1261,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
1206
1261
  };
1207
1262
  type Router = ReturnType<typeof createRouter>;
1208
1263
 
1209
- export { APIError as A, type InferHeaders as B, type CookiePrefixOptions as C, type InferHeadersInput as D, type EndpointOptions as E, type InferUse as F, type InferMiddlewareBody as G, type HTTPMethod as H, type InferBodyInput as I, type InferMiddlewareQuery as J, type InputContext as K, createInternalContext as L, type MiddlewareOptions as M, type HasRequiredKeys as N, type OpenAPISchemaType as O, type Path as P, type RouterConfig as R, type Status as S, type UnionToIntersection as U, _statusCode as _, type EndpointContext as a, type Endpoint as b, createEndpoint as c, type MiddlewareResponse as d, type MiddlewareContext as e, createMiddleware as f, type MiddlewareInputContext as g, type Middleware as h, createRouter as i, type Router as j, type CookieOptions as k, getCookieKey as l, serializeSignedCookie as m, type OpenAPIParameter as n, generator as o, parseCookies as p, getHTML as q, type Method as r, serializeCookie as s, type InferBody as t, type InferQueryInput as u, type InferQuery as v, type InferMethod as w, type InferInputMethod as x, type InferParam as y, type InferRequest as z };
1264
+ export { StandardSchemaV1 as $, APIError as A, type InferHeaders as B, type CookiePrefixOptions as C, type InferHeadersInput as D, type EndpointOptions as E, type InferUse as F, type InferMiddlewareBody as G, type HTTPMethod as H, type InferBodyInput as I, type InferMiddlewareQuery as J, type InputContext as K, createInternalContext as L, type MiddlewareOptions as M, type Input as N, type OpenAPISchemaType as O, type Path as P, type RequiredKeysOf as Q, type RouterConfig as R, type Status as S, type HasRequiredKeys as T, type Prettify as U, type IsEmptyObject as V, type UnionToIntersection as W, type MergeObject as X, type InferParamPath as Y, type InferParamWildCard as Z, _statusCode as _, type EndpointContext as a, type Endpoint as b, createEndpoint as c, type MiddlewareResponse as d, type MiddlewareContext as e, createMiddleware as f, type MiddlewareInputContext as g, type Middleware as h, createRouter as i, type Router as j, type CookieOptions as k, getCookieKey as l, serializeSignedCookie as m, type OpenAPIParameter as n, generator as o, parseCookies as p, getHTML as q, type Method as r, serializeCookie as s, type InferBody as t, type InferQueryInput as u, type InferQuery as v, type InferMethod as w, type InferInputMethod as x, type InferParam as y, type InferRequest as z };
@@ -1,5 +1,3 @@
1
- import { StandardSchemaV1 } from '@standard-schema/spec';
2
-
3
1
  declare const _statusCode: {
4
2
  OK: number;
5
3
  CREATED: number;
@@ -84,6 +82,7 @@ type Prettify<T> = {
84
82
  } & {};
85
83
  type IsEmptyObject<T> = keyof T extends never ? true : false;
86
84
  type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection & Union : never;
85
+ type MergeObject<T extends Record<string, any> | never, S extends Record<string, any> | never> = T extends never ? S : S extends never ? T : T & S;
87
86
  type InferParamPath<Path> = Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
88
87
  [K in Param | keyof InferParamPath<Rest>]: string;
89
88
  } : Path extends `${infer _Start}:${infer Param}` ? {
@@ -329,6 +328,62 @@ declare function parseCookies(cookieHeader: string): Map<string, string>;
329
328
  declare const serializeCookie: (key: string, value: string, opt?: CookieOptions) => string;
330
329
  declare const serializeSignedCookie: (key: string, value: string, secret: string, opt?: CookieOptions) => Promise<string>;
331
330
 
331
+ /** The Standard Schema interface. */
332
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
333
+ /** The Standard Schema properties. */
334
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
335
+ }
336
+ declare namespace StandardSchemaV1 {
337
+ /** The Standard Schema properties interface. */
338
+ interface Props<Input = unknown, Output = Input> {
339
+ /** The version number of the standard. */
340
+ readonly version: 1;
341
+ /** The vendor name of the schema library. */
342
+ readonly vendor: string;
343
+ /** Validates unknown input values. */
344
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
345
+ /** Inferred types associated with the schema. */
346
+ readonly types?: Types<Input, Output> | undefined;
347
+ }
348
+ /** The result interface of the validate function. */
349
+ type Result<Output> = SuccessResult<Output> | FailureResult;
350
+ /** The result interface if validation succeeds. */
351
+ interface SuccessResult<Output> {
352
+ /** The typed output value. */
353
+ readonly value: Output;
354
+ /** The non-existent issues. */
355
+ readonly issues?: undefined;
356
+ }
357
+ /** The result interface if validation fails. */
358
+ interface FailureResult {
359
+ /** The issues of failed validation. */
360
+ readonly issues: ReadonlyArray<Issue>;
361
+ }
362
+ /** The issue interface of the failure output. */
363
+ interface Issue {
364
+ /** The error message of the issue. */
365
+ readonly message: string;
366
+ /** The path of the issue, if any. */
367
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
368
+ }
369
+ /** The path segment interface of the issue. */
370
+ interface PathSegment {
371
+ /** The key representing a path segment. */
372
+ readonly key: PropertyKey;
373
+ }
374
+ /** The Standard Schema types interface. */
375
+ interface Types<Input = unknown, Output = Input> {
376
+ /** The input type of the schema. */
377
+ readonly input: Input;
378
+ /** The output type of the schema. */
379
+ readonly output: Output;
380
+ }
381
+ /** Infers the input type of a Standard Schema. */
382
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
383
+ /** Infers the output type of a Standard Schema. */
384
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
385
+ }
386
+
332
387
  type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
333
388
  type Method = HTTPMethod | "*";
334
389
  type InferBodyInput<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
@@ -430,7 +485,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
430
485
  status?: number;
431
486
  headers?: Record<string, string>;
432
487
  response?: Response;
433
- body?: Record<string, string>;
488
+ body?: Record<string, any>;
434
489
  } | Response) => Record<string, any>;
435
490
  responseHeaders: Headers;
436
491
  asResponse?: boolean | undefined;
@@ -1206,4 +1261,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
1206
1261
  };
1207
1262
  type Router = ReturnType<typeof createRouter>;
1208
1263
 
1209
- export { APIError as A, type InferHeaders as B, type CookiePrefixOptions as C, type InferHeadersInput as D, type EndpointOptions as E, type InferUse as F, type InferMiddlewareBody as G, type HTTPMethod as H, type InferBodyInput as I, type InferMiddlewareQuery as J, type InputContext as K, createInternalContext as L, type MiddlewareOptions as M, type HasRequiredKeys as N, type OpenAPISchemaType as O, type Path as P, type RouterConfig as R, type Status as S, type UnionToIntersection as U, _statusCode as _, type EndpointContext as a, type Endpoint as b, createEndpoint as c, type MiddlewareResponse as d, type MiddlewareContext as e, createMiddleware as f, type MiddlewareInputContext as g, type Middleware as h, createRouter as i, type Router as j, type CookieOptions as k, getCookieKey as l, serializeSignedCookie as m, type OpenAPIParameter as n, generator as o, parseCookies as p, getHTML as q, type Method as r, serializeCookie as s, type InferBody as t, type InferQueryInput as u, type InferQuery as v, type InferMethod as w, type InferInputMethod as x, type InferParam as y, type InferRequest as z };
1264
+ export { StandardSchemaV1 as $, APIError as A, type InferHeaders as B, type CookiePrefixOptions as C, type InferHeadersInput as D, type EndpointOptions as E, type InferUse as F, type InferMiddlewareBody as G, type HTTPMethod as H, type InferBodyInput as I, type InferMiddlewareQuery as J, type InputContext as K, createInternalContext as L, type MiddlewareOptions as M, type Input as N, type OpenAPISchemaType as O, type Path as P, type RequiredKeysOf as Q, type RouterConfig as R, type Status as S, type HasRequiredKeys as T, type Prettify as U, type IsEmptyObject as V, type UnionToIntersection as W, type MergeObject as X, type InferParamPath as Y, type InferParamWildCard as Z, _statusCode as _, type EndpointContext as a, type Endpoint as b, createEndpoint as c, type MiddlewareResponse as d, type MiddlewareContext as e, createMiddleware as f, type MiddlewareInputContext as g, type Middleware as h, createRouter as i, type Router as j, type CookieOptions as k, getCookieKey as l, serializeSignedCookie as m, type OpenAPIParameter as n, generator as o, parseCookies as p, getHTML as q, type Method as r, serializeCookie as s, type InferBody as t, type InferQueryInput as u, type InferQuery as v, type InferMethod as w, type InferInputMethod as x, type InferParam as y, type InferRequest as z };
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "better-call",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "devDependencies": {
9
9
  "@arethetypeswrong/cli": "^0.16.4",
10
+ "arktype": "^2.0.0",
11
+ "zod": "^3.24.1",
12
+ "valibot": "1.0.0-beta.15",
10
13
  "@biomejs/biome": "^1.8.3",
11
14
  "@types/bun": "latest",
12
15
  "@types/set-cookie-parser": "^2.4.10",
@@ -18,13 +21,9 @@
18
21
  },
19
22
  "dependencies": {
20
23
  "@better-fetch/fetch": "^1.1.4",
21
- "@standard-schema/spec": "^1.0.0",
22
- "arktype": "^2.0.0",
23
24
  "rou3": "^0.5.1",
24
25
  "set-cookie-parser": "^2.7.1",
25
- "uncrypto": "^0.1.3",
26
- "valibot": "1.0.0-beta.15",
27
- "zod": "^3.24.1"
26
+ "uncrypto": "^0.1.3"
28
27
  },
29
28
  "exports": {
30
29
  ".": {