better-call 0.3.3 → 1.0.0-beta.4

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.
@@ -0,0 +1,1263 @@
1
+ declare const _statusCode: {
2
+ OK: number;
3
+ CREATED: number;
4
+ ACCEPTED: number;
5
+ NO_CONTENT: number;
6
+ MULTIPLE_CHOICES: number;
7
+ MOVED_PERMANENTLY: number;
8
+ FOUND: number;
9
+ SEE_OTHER: number;
10
+ NOT_MODIFIED: number;
11
+ TEMPORARY_REDIRECT: number;
12
+ BAD_REQUEST: number;
13
+ UNAUTHORIZED: number;
14
+ PAYMENT_REQUIRED: number;
15
+ FORBIDDEN: number;
16
+ NOT_FOUND: number;
17
+ METHOD_NOT_ALLOWED: number;
18
+ NOT_ACCEPTABLE: number;
19
+ PROXY_AUTHENTICATION_REQUIRED: number;
20
+ REQUEST_TIMEOUT: number;
21
+ CONFLICT: number;
22
+ GONE: number;
23
+ LENGTH_REQUIRED: number;
24
+ PRECONDITION_FAILED: number;
25
+ PAYLOAD_TOO_LARGE: number;
26
+ URI_TOO_LONG: number;
27
+ UNSUPPORTED_MEDIA_TYPE: number;
28
+ RANGE_NOT_SATISFIABLE: number;
29
+ EXPECTATION_FAILED: number;
30
+ "I'M_A_TEAPOT": number;
31
+ MISDIRECTED_REQUEST: number;
32
+ UNPROCESSABLE_ENTITY: number;
33
+ LOCKED: number;
34
+ FAILED_DEPENDENCY: number;
35
+ TOO_EARLY: number;
36
+ UPGRADE_REQUIRED: number;
37
+ PRECONDITION_REQUIRED: number;
38
+ TOO_MANY_REQUESTS: number;
39
+ REQUEST_HEADER_FIELDS_TOO_LARGE: number;
40
+ UNAVAILABLE_FOR_LEGAL_REASONS: number;
41
+ INTERNAL_SERVER_ERROR: number;
42
+ NOT_IMPLEMENTED: number;
43
+ BAD_GATEWAY: number;
44
+ SERVICE_UNAVAILABLE: number;
45
+ GATEWAY_TIMEOUT: number;
46
+ HTTP_VERSION_NOT_SUPPORTED: number;
47
+ VARIANT_ALSO_NEGOTIATES: number;
48
+ INSUFFICIENT_STORAGE: number;
49
+ LOOP_DETECTED: number;
50
+ NOT_EXTENDED: number;
51
+ NETWORK_AUTHENTICATION_REQUIRED: number;
52
+ };
53
+ type Status = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
54
+ declare class APIError extends Error {
55
+ status: keyof typeof _statusCode | Status;
56
+ body: ({
57
+ message?: string;
58
+ code?: string;
59
+ } & Record<string, any>) | undefined;
60
+ headers: HeadersInit;
61
+ statusCode: number;
62
+ constructor(status?: keyof typeof _statusCode | Status, body?: ({
63
+ message?: string;
64
+ code?: string;
65
+ } & Record<string, any>) | undefined, headers?: HeadersInit, statusCode?: number);
66
+ }
67
+
68
+ /**
69
+ * Improve this type if possible
70
+ */
71
+ type Input<T> = Prettify<{
72
+ [K in keyof T as T[K] extends never ? never : undefined extends T[K] ? never : K]: T[K];
73
+ } & {
74
+ [K in keyof T as undefined extends T[K] ? K : never]?: T[K];
75
+ }>;
76
+ type RequiredKeysOf<BaseType extends object> = Exclude<{
77
+ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never;
78
+ }[keyof BaseType], undefined>;
79
+ type HasRequiredKeys<BaseType extends object> = RequiredKeysOf<BaseType> extends never ? false : true;
80
+ type Prettify<T> = {
81
+ [K in keyof T]: T[K];
82
+ } & {};
83
+ type IsEmptyObject<T> = keyof T extends never ? true : false;
84
+ type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection & Union : never;
85
+ type InferParamPath<Path> = Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
86
+ [K in Param | keyof InferParamPath<Rest>]: string;
87
+ } : Path extends `${infer _Start}:${infer Param}` ? {
88
+ [K in Param]: string;
89
+ } : Path extends `${infer _Start}/${infer Rest}` ? InferParamPath<Rest> : {};
90
+ type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/${infer Rest}` | `${infer _Start}/**:${infer Param}/${infer Rest}` ? {
91
+ [K in Param | keyof InferParamPath<Rest>]: string;
92
+ } : Path extends `${infer _Start}/*` ? {
93
+ [K in "_"]: string;
94
+ } : Path extends `${infer _Start}/${infer Rest}` ? InferParamPath<Rest> : {};
95
+
96
+ interface MiddlewareOptions extends Omit<EndpointOptions, "method"> {
97
+ }
98
+ type MiddlewareResponse = null | void | undefined | Record<string, any>;
99
+ type MiddlewareContext<Options extends MiddlewareOptions, Context = {}> = EndpointContext<string, Options & {
100
+ method: "*";
101
+ }> & {
102
+ /**
103
+ * Method
104
+ *
105
+ * The request method
106
+ */
107
+ method: string;
108
+ /**
109
+ * Path
110
+ *
111
+ * The path of the endpoint
112
+ */
113
+ path: string;
114
+ /**
115
+ * Body
116
+ *
117
+ * The body object will be the parsed JSON from the request and validated
118
+ * against the body schema if it exists
119
+ */
120
+ body: InferMiddlewareBody<Options>;
121
+ /**
122
+ * Query
123
+ *
124
+ * The query object will be the parsed query string from the request
125
+ * and validated against the query schema if it exists
126
+ */
127
+ query: InferMiddlewareQuery<Options>;
128
+ /**
129
+ * Params
130
+ *
131
+ * If the path is `/user/:id` and the request is `/user/1` then the
132
+ * params will
133
+ * be `{ id: "1" }` and if the path includes a wildcard like `/user/*`
134
+ * then the
135
+ * params will be `{ _: "1" }` where `_` is the wildcard key. If the
136
+ * wildcard
137
+ * is named like `/user/**:name` then the params will be `{ name: string }`
138
+ */
139
+ params: string;
140
+ /**
141
+ * Request object
142
+ *
143
+ * If `requireRequest` is set to true in the endpoint options this will be
144
+ * required
145
+ */
146
+ request: InferRequest<Options>;
147
+ /**
148
+ * Headers
149
+ *
150
+ * If `requireHeaders` is set to true in the endpoint options this will be
151
+ * required
152
+ */
153
+ headers: InferHeaders<Options>;
154
+ /**
155
+ * Set header
156
+ *
157
+ * If it's called outside of a request it will just be ignored.
158
+ */
159
+ setHeader: (key: string, value: string) => void;
160
+ /**
161
+ * Get header
162
+ *
163
+ * If it's called outside of a request it will just return null
164
+ *
165
+ * @param key - The key of the header
166
+ * @returns
167
+ */
168
+ getHeader: (key: string) => string | null;
169
+ /**
170
+ * JSON
171
+ *
172
+ * a helper function to create a JSON response with
173
+ * the correct headers
174
+ * and status code. If `asResponse` is set to true in
175
+ * the context then
176
+ * it will return a Response object instead of the
177
+ * JSON object.
178
+ *
179
+ * @param json - The JSON object to return
180
+ * @param routerResponse - The response object to
181
+ * return if `asResponse` is
182
+ * true in the context this will take precedence
183
+ */
184
+ json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
185
+ status?: number;
186
+ headers?: Record<string, string>;
187
+ response?: Response;
188
+ } | Response) => Promise<R>;
189
+ /**
190
+ * Middleware context
191
+ */
192
+ context: Prettify<Context>;
193
+ };
194
+ declare function createMiddleware<Options extends MiddlewareOptions, R>(options: Options, handler: (context: MiddlewareContext<Options>) => Promise<R>): <InputCtx extends MiddlewareInputContext<Options>>(inputContext: InputCtx) => Promise<R>;
195
+ declare function createMiddleware<Options extends MiddlewareOptions, R>(handler: (context: MiddlewareContext<Options>) => Promise<R>): <InputCtx extends MiddlewareInputContext<Options>>(inputContext: InputCtx) => Promise<R>;
196
+ declare namespace createMiddleware {
197
+ var create: <E extends {
198
+ use?: Middleware[];
199
+ }>(opts?: E) => {
200
+ <Options extends MiddlewareOptions, R>(options: Options, handler: (ctx: MiddlewareContext<Options, InferUse<E["use"]>>) => Promise<R>): (inputContext: MiddlewareInputContext<Options>) => Promise<R>;
201
+ <Options extends MiddlewareOptions, R_1>(handler: (ctx: MiddlewareContext<Options, InferUse<E["use"]>>) => Promise<R_1>): (inputContext: MiddlewareInputContext<Options>) => Promise<R_1>;
202
+ };
203
+ }
204
+ type MiddlewareInputContext<Options extends MiddlewareOptions> = Input<{
205
+ /**
206
+ * Payload
207
+ */
208
+ body: InferBody<Options>;
209
+ /**
210
+ * Query Params
211
+ */
212
+ query: InferQuery<Options>;
213
+ /**
214
+ * Request Object
215
+ */
216
+ request: InferRequest<Options>;
217
+ /**
218
+ * Headers
219
+ */
220
+ headers: InferHeaders<Options>;
221
+ /**
222
+ * Return a `Response` object
223
+ */
224
+ asResponse?: boolean;
225
+ /**
226
+ * include headers on the return
227
+ */
228
+ returnHeaders?: boolean;
229
+ /**
230
+ * Middlewares to use
231
+ */
232
+ use?: Middleware[];
233
+ }>;
234
+ type Middleware<Options extends MiddlewareOptions = MiddlewareOptions, Handler extends (inputCtx: any) => Promise<any> = any> = Handler & {
235
+ options: Options;
236
+ };
237
+
238
+ type CookiePrefixOptions = "host" | "secure";
239
+ type CookieOptions = {
240
+ /**
241
+ * Domain of the cookie
242
+ *
243
+ * The Domain attribute specifies which server can receive a cookie. If specified, cookies are
244
+ * available on the specified server and its subdomains. If the it is not
245
+ * specified, the cookies are available on the server that sets it but not on
246
+ * its subdomains.
247
+ *
248
+ * @example
249
+ * `domain: "example.com"`
250
+ */
251
+ domain?: string;
252
+ /**
253
+ * A lifetime of a cookie. Permanent cookies are deleted after the date specified in the
254
+ * Expires attribute:
255
+ *
256
+ * Expires has been available for longer than Max-Age, however Max-Age is less error-prone, and
257
+ * takes precedence when both are set. The rationale behind this is that when you set an
258
+ * Expires date and time, they're relative to the client the cookie is being set on. If the
259
+ * server is set to a different time, this could cause errors
260
+ */
261
+ expires?: Date;
262
+ /**
263
+ * Forbids JavaScript from accessing the cookie, for example, through the Document.cookie
264
+ * property. Note that a cookie that has been created with HttpOnly will still be sent with
265
+ * JavaScript-initiated requests, for example, when calling XMLHttpRequest.send() or fetch().
266
+ * This mitigates attacks against cross-site scripting
267
+ */
268
+ httpOnly?: boolean;
269
+ /**
270
+ * Indicates the number of seconds until the cookie expires. A zero or negative number will
271
+ * expire the cookie immediately. If both Expires and Max-Age are set, Max-Age has precedence.
272
+ *
273
+ * @example 604800 - 7 days
274
+ */
275
+ maxAge?: number;
276
+ /**
277
+ * Indicates the path that must exist in the requested URL for the browser to send the Cookie
278
+ * header.
279
+ *
280
+ * @example
281
+ * "/docs"
282
+ * // -> the request paths /docs, /docs/, /docs/Web/, and /docs/Web/HTTP will all match. the request paths /, /fr/docs will not match.
283
+ */
284
+ path?: string;
285
+ /**
286
+ * Indicates that the cookie is sent to the server only when a request is made with the https:
287
+ * scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.
288
+ */
289
+ secure?: boolean;
290
+ /**
291
+ * Controls whether or not a cookie is sent with cross-site requests, providing some protection
292
+ * against cross-site request forgery attacks (CSRF).
293
+ *
294
+ * Strict - Means that the browser sends the cookie only for same-site requests, that is,
295
+ * requests originating from the same site that set the cookie. If a request originates from a
296
+ * different domain or scheme (even with the same domain), no cookies with the SameSite=Strict
297
+ * attribute are sent.
298
+ *
299
+ * Lax - Means that the cookie is not sent on cross-site requests, such as on requests to load
300
+ * images or frames, but is sent when a user is navigating to the origin site from an external
301
+ * site (for example, when following a link). This is the default behavior if the SameSite
302
+ * attribute is not specified.
303
+ *
304
+ * None - Means that the browser sends the cookie with both cross-site and same-site requests.
305
+ * The Secure attribute must also be set when setting this value.
306
+ */
307
+ sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
308
+ /**
309
+ * Indicates that the cookie should be stored using partitioned storage. Note that if this is
310
+ * set, the Secure directive must also be set.
311
+ *
312
+ * @see https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
313
+ */
314
+ partitioned?: boolean;
315
+ /**
316
+ * Cooke Prefix
317
+ *
318
+ * - secure: `__Secure-` -> `__Secure-cookie-name`
319
+ * - host: `__Host-` -> `__Host-cookie-name`
320
+ *
321
+ * `secure` must be set to true to use prefixes
322
+ */
323
+ prefix?: CookiePrefixOptions;
324
+ };
325
+ declare const getCookieKey: (key: string, prefix?: CookiePrefixOptions) => string | undefined;
326
+ declare function parseCookies(cookieHeader: string): Map<string, string>;
327
+ declare const serializeCookie: (key: string, value: string, opt?: CookieOptions) => string;
328
+ declare const serializeSignedCookie: (key: string, value: string, secret: string, opt?: CookieOptions) => Promise<string>;
329
+
330
+ /** The Standard Schema interface. */
331
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
332
+ /** The Standard Schema properties. */
333
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
334
+ }
335
+ declare namespace StandardSchemaV1 {
336
+ /** The Standard Schema properties interface. */
337
+ interface Props<Input = unknown, Output = Input> {
338
+ /** The version number of the standard. */
339
+ readonly version: 1;
340
+ /** The vendor name of the schema library. */
341
+ readonly vendor: string;
342
+ /** Validates unknown input values. */
343
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
344
+ /** Inferred types associated with the schema. */
345
+ readonly types?: Types<Input, Output> | undefined;
346
+ }
347
+ /** The result interface of the validate function. */
348
+ type Result<Output> = SuccessResult<Output> | FailureResult;
349
+ /** The result interface if validation succeeds. */
350
+ interface SuccessResult<Output> {
351
+ /** The typed output value. */
352
+ readonly value: Output;
353
+ /** The non-existent issues. */
354
+ readonly issues?: undefined;
355
+ }
356
+ /** The result interface if validation fails. */
357
+ interface FailureResult {
358
+ /** The issues of failed validation. */
359
+ readonly issues: ReadonlyArray<Issue>;
360
+ }
361
+ /** The issue interface of the failure output. */
362
+ interface Issue {
363
+ /** The error message of the issue. */
364
+ readonly message: string;
365
+ /** The path of the issue, if any. */
366
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
367
+ }
368
+ /** The path segment interface of the issue. */
369
+ interface PathSegment {
370
+ /** The key representing a path segment. */
371
+ readonly key: PropertyKey;
372
+ }
373
+ /** The Standard Schema types interface. */
374
+ interface Types<Input = unknown, Output = Input> {
375
+ /** The input type of the schema. */
376
+ readonly input: Input;
377
+ /** The output type of the schema. */
378
+ readonly output: Output;
379
+ }
380
+ /** Infers the input type of a Standard Schema. */
381
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
382
+ /** Infers the output type of a Standard Schema. */
383
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
384
+ }
385
+
386
+ type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
387
+ type Method = HTTPMethod | "*";
388
+ type InferBodyInput<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
389
+ $Infer: {
390
+ body: infer Body;
391
+ };
392
+ } ? Body : Options["body"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["body"]> : undefined;
393
+ type InferBody<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
394
+ $Infer: {
395
+ body: infer Body;
396
+ };
397
+ } ? Body : Options["body"] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Options["body"]> : any;
398
+ type InferQueryInput<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
399
+ $Infer: {
400
+ query: infer Query;
401
+ };
402
+ } ? Query : Options["query"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined;
403
+ type InferQuery<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
404
+ $Infer: {
405
+ query: infer Query;
406
+ };
407
+ } ? Query : Options["query"] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Options["query"]> : Record<string, any> | undefined;
408
+ type InferMethod<Options extends EndpointOptions> = Options["method"] extends Array<Method> ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"];
409
+ type InferInputMethod<Options extends EndpointOptions> = Options["method"] extends Array<Method> ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined;
410
+ type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? Record<string, any> | undefined : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
411
+ type InferRequest<Option extends EndpointOptions | MiddlewareOptions> = Option["requireRequest"] extends true ? Request : Request | undefined;
412
+ type InferHeaders<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? Headers : Headers | undefined;
413
+ type InferHeadersInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? HeadersInit : HeadersInit | undefined;
414
+ type InferUse<Opts extends EndpointOptions["use"]> = Opts extends Middleware[] ? UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : {};
415
+ type InferMiddlewareBody<Options extends MiddlewareOptions> = Options["body"] extends StandardSchemaV1<infer T> ? T : any;
416
+ type InferMiddlewareQuery<Options extends MiddlewareOptions> = Options["query"] extends StandardSchemaV1<infer T> ? T : Record<string, any> | undefined;
417
+ type InputContext<Path extends string, Options extends EndpointOptions> = Input<{
418
+ /**
419
+ * Payload
420
+ */
421
+ body: InferBodyInput<Options>;
422
+ /**
423
+ * Request Method
424
+ */
425
+ method: InferInputMethod<Options>;
426
+ /**
427
+ * Query Params
428
+ */
429
+ query: InferQueryInput<Options>;
430
+ /**
431
+ * Dynamic Params
432
+ */
433
+ params: InferParam<Path>;
434
+ /**
435
+ * Request Object
436
+ */
437
+ request: InferRequest<Options>;
438
+ /**
439
+ * Headers
440
+ */
441
+ headers: InferHeadersInput<Options>;
442
+ /**
443
+ * Return a `Response` object
444
+ */
445
+ asResponse?: boolean;
446
+ /**
447
+ * include headers on the return
448
+ */
449
+ returnHeaders?: boolean;
450
+ /**
451
+ * Middlewares to use
452
+ */
453
+ use?: Middleware[];
454
+ /**
455
+ * Customize the path
456
+ */
457
+ path?: string;
458
+ }>;
459
+ declare const createInternalContext: (context: InputContext<any, any>, { options, path, }: {
460
+ options: EndpointOptions;
461
+ path: string;
462
+ }) => Promise<{
463
+ body: any;
464
+ query: any;
465
+ path: string;
466
+ context: {};
467
+ returned: any;
468
+ headers: HeadersInit | undefined;
469
+ request: Request | undefined;
470
+ params: Record<string, any> | undefined;
471
+ method: any;
472
+ setHeader: (key: string, value: string) => void;
473
+ getHeader: (key: string) => string | null;
474
+ getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
475
+ getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | false | null>;
476
+ setCookie: (key: string, value: string, options?: CookieOptions) => string;
477
+ setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
478
+ redirect: (url: string) => APIError;
479
+ error: (status: keyof typeof _statusCode | Status, body?: {
480
+ message?: string;
481
+ code?: string;
482
+ } | undefined, headers?: HeadersInit) => APIError;
483
+ json: (json: Record<string, any>, routerResponse?: {
484
+ status?: number;
485
+ headers?: Record<string, string>;
486
+ response?: Response;
487
+ body?: Record<string, any>;
488
+ } | Response) => Record<string, any>;
489
+ responseHeaders: Headers;
490
+ asResponse?: boolean | undefined;
491
+ returnHeaders?: boolean | undefined;
492
+ use?: Middleware[] | undefined;
493
+ }>;
494
+
495
+ type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
496
+ interface OpenAPIParameter {
497
+ in: "query" | "path" | "header" | "cookie";
498
+ name?: string;
499
+ description?: string;
500
+ required?: boolean;
501
+ schema?: {
502
+ type: OpenAPISchemaType;
503
+ format?: string;
504
+ items?: {
505
+ type: OpenAPISchemaType;
506
+ };
507
+ enum?: string[];
508
+ minLength?: number;
509
+ description?: string;
510
+ default?: string;
511
+ example?: string;
512
+ };
513
+ }
514
+ interface Path {
515
+ get?: {
516
+ tags?: string[];
517
+ operationId?: string;
518
+ description?: string;
519
+ security?: [{
520
+ bearerAuth: string[];
521
+ }];
522
+ parameters?: OpenAPIParameter[];
523
+ responses?: {
524
+ [key in string]: {
525
+ description?: string;
526
+ content: {
527
+ "application/json": {
528
+ schema: {
529
+ type?: OpenAPISchemaType;
530
+ properties?: Record<string, any>;
531
+ required?: string[];
532
+ $ref?: string;
533
+ };
534
+ };
535
+ };
536
+ };
537
+ };
538
+ };
539
+ post?: {
540
+ tags?: string[];
541
+ operationId?: string;
542
+ description?: string;
543
+ security?: [{
544
+ bearerAuth: string[];
545
+ }];
546
+ parameters?: OpenAPIParameter[];
547
+ requestBody?: {
548
+ content: {
549
+ "application/json": {
550
+ schema: {
551
+ type?: OpenAPISchemaType;
552
+ properties?: Record<string, any>;
553
+ required?: string[];
554
+ $ref?: string;
555
+ };
556
+ };
557
+ };
558
+ };
559
+ responses?: {
560
+ [key in string]: {
561
+ description?: string;
562
+ content: {
563
+ "application/json": {
564
+ schema: {
565
+ type?: OpenAPISchemaType;
566
+ properties?: Record<string, any>;
567
+ required?: string[];
568
+ $ref?: string;
569
+ };
570
+ };
571
+ };
572
+ };
573
+ };
574
+ };
575
+ }
576
+ declare function generator(endpoints: Record<string, Endpoint>, config?: {
577
+ url: string;
578
+ }): Promise<{
579
+ openapi: string;
580
+ info: {
581
+ title: string;
582
+ description: string;
583
+ version: string;
584
+ };
585
+ components: {
586
+ schemas: {};
587
+ };
588
+ security: {
589
+ apiKeyCookie: never[];
590
+ }[];
591
+ servers: {
592
+ url: string | undefined;
593
+ }[];
594
+ tags: {
595
+ name: string;
596
+ description: string;
597
+ }[];
598
+ paths: Record<string, Path>;
599
+ }>;
600
+ declare const getHTML: (apiReference: Record<string, any>, config?: {
601
+ logo?: string;
602
+ theme?: string;
603
+ title?: string;
604
+ description?: string;
605
+ }) => string;
606
+
607
+ interface EndpointOptions {
608
+ /**
609
+ * Request Method
610
+ */
611
+ method: Method | Method[];
612
+ /**
613
+ * Body Schema
614
+ */
615
+ body?: StandardSchemaV1;
616
+ /**
617
+ * Query Schema
618
+ */
619
+ query?: StandardSchemaV1;
620
+ /**
621
+ * If true headers will be required to be passed in the context
622
+ */
623
+ requireHeaders?: boolean;
624
+ /**
625
+ * If true request object will be required
626
+ */
627
+ requireRequest?: boolean;
628
+ /**
629
+ * Clone the request object from the router
630
+ */
631
+ cloneRequest?: boolean;
632
+ /**
633
+ * Endpoint metadata
634
+ */
635
+ metadata?: {
636
+ /**
637
+ * Open API definition
638
+ */
639
+ openAPI?: {
640
+ summary?: string;
641
+ description?: string;
642
+ tags?: string[];
643
+ operationId?: string;
644
+ parameters?: OpenAPIParameter[];
645
+ requestBody?: {
646
+ content: {
647
+ "application/json": {
648
+ schema: {
649
+ type?: OpenAPISchemaType;
650
+ properties?: Record<string, any>;
651
+ required?: string[];
652
+ $ref?: string;
653
+ };
654
+ };
655
+ };
656
+ };
657
+ responses?: {
658
+ [status: string]: {
659
+ description: string;
660
+ content?: {
661
+ "application/json"?: {
662
+ schema: {
663
+ type?: OpenAPISchemaType;
664
+ properties?: Record<string, any>;
665
+ required?: string[];
666
+ $ref?: string;
667
+ };
668
+ };
669
+ "text/plain"?: {
670
+ schema?: {
671
+ type?: OpenAPISchemaType;
672
+ properties?: Record<string, any>;
673
+ required?: string[];
674
+ $ref?: string;
675
+ };
676
+ };
677
+ "text/html"?: {
678
+ schema?: {
679
+ type?: OpenAPISchemaType;
680
+ properties?: Record<string, any>;
681
+ required?: string[];
682
+ $ref?: string;
683
+ };
684
+ };
685
+ };
686
+ };
687
+ };
688
+ };
689
+ /**
690
+ * Infer body and query type from ts interface
691
+ *
692
+ * useful for generic and dynamic types
693
+ *
694
+ * @example
695
+ * ```ts
696
+ * const endpoint = createEndpoint("/path", {
697
+ * method: "POST",
698
+ * body: z.record(z.string()),
699
+ * $Infer: {
700
+ * body: {} as {
701
+ * type: InferTypeFromOptions<Option> // custom type inference
702
+ * }
703
+ * }
704
+ * }, async(ctx)=>{
705
+ * const body = ctx.body
706
+ * })
707
+ * ```
708
+ */
709
+ $Infer?: {
710
+ /**
711
+ * Body
712
+ */
713
+ body?: any;
714
+ /**
715
+ * Query
716
+ */
717
+ query?: Record<string, any>;
718
+ };
719
+ /**
720
+ * If enabled, endpoint won't be exposed over a router
721
+ */
722
+ SERVER_ONLY?: boolean;
723
+ /**
724
+ * Extra metadata
725
+ */
726
+ [key: string]: any;
727
+ };
728
+ /**
729
+ * List of middlewares to use
730
+ */
731
+ use?: Middleware[];
732
+ }
733
+ type EndpointContext<Path extends string, Options extends EndpointOptions, Context = {}> = {
734
+ /**
735
+ * Method
736
+ *
737
+ * The request method
738
+ */
739
+ method: InferMethod<Options>;
740
+ /**
741
+ * Path
742
+ *
743
+ * The path of the endpoint
744
+ */
745
+ path: Path;
746
+ /**
747
+ * Body
748
+ *
749
+ * The body object will be the parsed JSON from the request and validated
750
+ * against the body schema if it exists.
751
+ */
752
+ body: InferBody<Options>;
753
+ /**
754
+ * Query
755
+ *
756
+ * The query object will be the parsed query string from the request
757
+ * and validated against the query schema if it exists
758
+ */
759
+ query: InferQuery<Options>;
760
+ /**
761
+ * Params
762
+ *
763
+ * If the path is `/user/:id` and the request is `/user/1` then the params will
764
+ * be `{ id: "1" }` and if the path includes a wildcard like `/user/*` then the
765
+ * params will be `{ _: "1" }` where `_` is the wildcard key. If the wildcard
766
+ * is named like `/user/**:name` then the params will be `{ name: string }`
767
+ */
768
+ params: InferParam<Path>;
769
+ /**
770
+ * Request object
771
+ *
772
+ * If `requireRequest` is set to true in the endpoint options this will be
773
+ * required
774
+ */
775
+ request: InferRequest<Options>;
776
+ /**
777
+ * Headers
778
+ *
779
+ * If `requireHeaders` is set to true in the endpoint options this will be
780
+ * required
781
+ */
782
+ headers: InferHeaders<Options>;
783
+ /**
784
+ * Set header
785
+ *
786
+ * If it's called outside of a request it will just be ignored.
787
+ */
788
+ setHeader: (key: string, value: string) => void;
789
+ /**
790
+ * Get header
791
+ *
792
+ * If it's called outside of a request it will just return null
793
+ *
794
+ * @param key - The key of the header
795
+ * @returns
796
+ */
797
+ getHeader: (key: string) => string | null;
798
+ /**
799
+ * Get a cookie value from the request
800
+ *
801
+ * @param key - The key of the cookie
802
+ * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
803
+ * @returns - The value of the cookie
804
+ */
805
+ getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
806
+ /**
807
+ * Get a signed cookie value from the request
808
+ *
809
+ * @param key - The key of the cookie
810
+ * @param secret - The secret of the signed cookie
811
+ * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
812
+ * @returns
813
+ */
814
+ getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | null>;
815
+ /**
816
+ * Set a cookie value in the response
817
+ *
818
+ * @param key - The key of the cookie
819
+ * @param value - The value to set
820
+ * @param options - The options of the cookie
821
+ * @returns - The cookie string
822
+ */
823
+ setCookie: (key: string, value: string, options?: CookieOptions) => string;
824
+ /**
825
+ * Set signed cookie
826
+ *
827
+ * @param key - The key of the cookie
828
+ * @param value - The value to set
829
+ * @param secret - The secret to sign the cookie with
830
+ * @param options - The options of the cookie
831
+ * @returns - The cookie string
832
+ */
833
+ setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
834
+ /**
835
+ * JSON
836
+ *
837
+ * a helper function to create a JSON response with
838
+ * the correct headers
839
+ * and status code. If `asResponse` is set to true in
840
+ * the context then
841
+ * it will return a Response object instead of the
842
+ * JSON object.
843
+ *
844
+ * @param json - The JSON object to return
845
+ * @param routerResponse - The response object to
846
+ * return if `asResponse` is
847
+ * true in the context this will take precedence
848
+ */
849
+ json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
850
+ status?: number;
851
+ headers?: Record<string, string>;
852
+ response?: Response;
853
+ body?: Record<string, string>;
854
+ } | Response) => Promise<R>;
855
+ /**
856
+ * Middleware context
857
+ */
858
+ context: Prettify<Context & InferUse<Options["use"]>>;
859
+ /**
860
+ * Redirect to a new URL
861
+ */
862
+ redirect: (url: string) => APIError;
863
+ /**
864
+ * Return error
865
+ */
866
+ error: (status: keyof typeof _statusCode | Status, body?: {
867
+ message?: string;
868
+ code?: string;
869
+ } & Record<string, any>, headers?: HeadersInit) => APIError;
870
+ };
871
+ declare const createEndpoint: {
872
+ <Path extends string, Options extends EndpointOptions, R>(path: Path, options: Options, handler: (context: EndpointContext<Path, Options>) => Promise<R>): {
873
+ <Context extends InputContext<Path, Options>>(...inputCtx: HasRequiredKeys<Context> extends true ? [Context] : [Context?]): Promise<Context["asResponse"] extends true ? Response : Context["returnHeaders"] extends true ? {
874
+ headers: Headers;
875
+ response: R;
876
+ } : R>;
877
+ options: Options;
878
+ path: Path;
879
+ };
880
+ create<E extends {
881
+ use?: Middleware[];
882
+ }>(opts?: E): <Path extends string, Opts extends EndpointOptions, R>(path: Path, options: Opts, handler: (ctx: EndpointContext<Path, Opts, InferUse<E["use"]>>) => Promise<R>) => {
883
+ <Context extends ({
884
+ body: InferBodyInput<Opts & {
885
+ use: any[];
886
+ }>;
887
+ method: InferInputMethod<Opts & {
888
+ use: any[];
889
+ }>;
890
+ query: InferQueryInput<Opts & {
891
+ use: any[];
892
+ }>;
893
+ params: InferParam<Path>;
894
+ request: InferRequest<Opts & {
895
+ use: any[];
896
+ }>;
897
+ headers: InferHeadersInput<Opts & {
898
+ use: any[];
899
+ }>;
900
+ asResponse?: boolean;
901
+ returnHeaders?: boolean;
902
+ use?: Middleware[];
903
+ path?: string;
904
+ } extends infer T_3 ? { [K_1 in keyof T_3 as {
905
+ body: InferBodyInput<Opts & {
906
+ use: any[];
907
+ }>;
908
+ method: InferInputMethod<Opts & {
909
+ use: any[];
910
+ }>;
911
+ query: InferQueryInput<Opts & {
912
+ use: any[];
913
+ }>;
914
+ params: InferParam<Path>;
915
+ request: InferRequest<Opts & {
916
+ use: any[];
917
+ }>;
918
+ headers: InferHeadersInput<Opts & {
919
+ use: any[];
920
+ }>;
921
+ asResponse?: boolean;
922
+ returnHeaders?: boolean;
923
+ use?: Middleware[];
924
+ path?: string;
925
+ }[K_1] extends never ? never : undefined extends {
926
+ body: InferBodyInput<Opts & {
927
+ use: any[];
928
+ }>;
929
+ method: InferInputMethod<Opts & {
930
+ use: any[];
931
+ }>;
932
+ query: InferQueryInput<Opts & {
933
+ use: any[];
934
+ }>;
935
+ params: InferParam<Path>;
936
+ request: InferRequest<Opts & {
937
+ use: any[];
938
+ }>;
939
+ headers: InferHeadersInput<Opts & {
940
+ use: any[];
941
+ }>;
942
+ asResponse?: boolean;
943
+ returnHeaders?: boolean;
944
+ use?: Middleware[];
945
+ path?: string;
946
+ }[K_1] ? never : K_1]: {
947
+ body: InferBodyInput<Opts & {
948
+ use: any[];
949
+ }>;
950
+ method: InferInputMethod<Opts & {
951
+ use: any[];
952
+ }>;
953
+ query: InferQueryInput<Opts & {
954
+ use: any[];
955
+ }>;
956
+ params: InferParam<Path>;
957
+ request: InferRequest<Opts & {
958
+ use: any[];
959
+ }>;
960
+ headers: InferHeadersInput<Opts & {
961
+ use: any[];
962
+ }>;
963
+ asResponse?: boolean;
964
+ returnHeaders?: boolean;
965
+ use?: Middleware[];
966
+ path?: string;
967
+ }[K_1]; } : never) & ({
968
+ body: InferBodyInput<Opts & {
969
+ use: any[];
970
+ }>;
971
+ method: InferInputMethod<Opts & {
972
+ use: any[];
973
+ }>;
974
+ query: InferQueryInput<Opts & {
975
+ use: any[];
976
+ }>;
977
+ params: InferParam<Path>;
978
+ request: InferRequest<Opts & {
979
+ use: any[];
980
+ }>;
981
+ headers: InferHeadersInput<Opts & {
982
+ use: any[];
983
+ }>;
984
+ asResponse?: boolean;
985
+ returnHeaders?: boolean;
986
+ use?: Middleware[];
987
+ path?: string;
988
+ } extends infer T_4 ? { [K_2 in keyof T_4 as undefined extends {
989
+ body: InferBodyInput<Opts & {
990
+ use: any[];
991
+ }>;
992
+ method: InferInputMethod<Opts & {
993
+ use: any[];
994
+ }>;
995
+ query: InferQueryInput<Opts & {
996
+ use: any[];
997
+ }>;
998
+ params: InferParam<Path>;
999
+ request: InferRequest<Opts & {
1000
+ use: any[];
1001
+ }>;
1002
+ headers: InferHeadersInput<Opts & {
1003
+ use: any[];
1004
+ }>;
1005
+ asResponse?: boolean;
1006
+ returnHeaders?: boolean;
1007
+ use?: Middleware[];
1008
+ path?: string;
1009
+ }[K_2] ? K_2 : never]?: {
1010
+ body: InferBodyInput<Opts & {
1011
+ use: any[];
1012
+ }>;
1013
+ method: InferInputMethod<Opts & {
1014
+ use: any[];
1015
+ }>;
1016
+ query: InferQueryInput<Opts & {
1017
+ use: any[];
1018
+ }>;
1019
+ params: InferParam<Path>;
1020
+ request: InferRequest<Opts & {
1021
+ use: any[];
1022
+ }>;
1023
+ headers: InferHeadersInput<Opts & {
1024
+ use: any[];
1025
+ }>;
1026
+ asResponse?: boolean;
1027
+ returnHeaders?: boolean;
1028
+ use?: Middleware[];
1029
+ path?: string;
1030
+ }[K_2] | undefined; } : never) extends infer T ? { [K in keyof T]: (({
1031
+ body: InferBodyInput<Opts & {
1032
+ use: any[];
1033
+ }>;
1034
+ method: InferInputMethod<Opts & {
1035
+ use: any[];
1036
+ }>;
1037
+ query: InferQueryInput<Opts & {
1038
+ use: any[];
1039
+ }>;
1040
+ params: InferParam<Path>;
1041
+ request: InferRequest<Opts & {
1042
+ use: any[];
1043
+ }>;
1044
+ headers: InferHeadersInput<Opts & {
1045
+ use: any[];
1046
+ }>;
1047
+ asResponse?: boolean;
1048
+ returnHeaders?: boolean;
1049
+ use?: Middleware[];
1050
+ path?: string;
1051
+ } extends infer T_1 ? { [K_1 in keyof T_1 as {
1052
+ body: InferBodyInput<Opts & {
1053
+ use: any[];
1054
+ }>;
1055
+ method: InferInputMethod<Opts & {
1056
+ use: any[];
1057
+ }>;
1058
+ query: InferQueryInput<Opts & {
1059
+ use: any[];
1060
+ }>;
1061
+ params: InferParam<Path>;
1062
+ request: InferRequest<Opts & {
1063
+ use: any[];
1064
+ }>;
1065
+ headers: InferHeadersInput<Opts & {
1066
+ use: any[];
1067
+ }>;
1068
+ asResponse?: boolean;
1069
+ returnHeaders?: boolean;
1070
+ use?: Middleware[];
1071
+ path?: string;
1072
+ }[K_1] extends never ? never : undefined extends {
1073
+ body: InferBodyInput<Opts & {
1074
+ use: any[];
1075
+ }>;
1076
+ method: InferInputMethod<Opts & {
1077
+ use: any[];
1078
+ }>;
1079
+ query: InferQueryInput<Opts & {
1080
+ use: any[];
1081
+ }>;
1082
+ params: InferParam<Path>;
1083
+ request: InferRequest<Opts & {
1084
+ use: any[];
1085
+ }>;
1086
+ headers: InferHeadersInput<Opts & {
1087
+ use: any[];
1088
+ }>;
1089
+ asResponse?: boolean;
1090
+ returnHeaders?: boolean;
1091
+ use?: Middleware[];
1092
+ path?: string;
1093
+ }[K_1] ? never : K_1]: {
1094
+ body: InferBodyInput<Opts & {
1095
+ use: any[];
1096
+ }>;
1097
+ method: InferInputMethod<Opts & {
1098
+ use: any[];
1099
+ }>;
1100
+ query: InferQueryInput<Opts & {
1101
+ use: any[];
1102
+ }>;
1103
+ params: InferParam<Path>;
1104
+ request: InferRequest<Opts & {
1105
+ use: any[];
1106
+ }>;
1107
+ headers: InferHeadersInput<Opts & {
1108
+ use: any[];
1109
+ }>;
1110
+ asResponse?: boolean;
1111
+ returnHeaders?: boolean;
1112
+ use?: Middleware[];
1113
+ path?: string;
1114
+ }[K_1]; } : never) & ({
1115
+ body: InferBodyInput<Opts & {
1116
+ use: any[];
1117
+ }>;
1118
+ method: InferInputMethod<Opts & {
1119
+ use: any[];
1120
+ }>;
1121
+ query: InferQueryInput<Opts & {
1122
+ use: any[];
1123
+ }>;
1124
+ params: InferParam<Path>;
1125
+ request: InferRequest<Opts & {
1126
+ use: any[];
1127
+ }>;
1128
+ headers: InferHeadersInput<Opts & {
1129
+ use: any[];
1130
+ }>;
1131
+ asResponse?: boolean;
1132
+ returnHeaders?: boolean;
1133
+ use?: Middleware[];
1134
+ path?: string;
1135
+ } extends infer T_2 ? { [K_2 in keyof T_2 as undefined extends {
1136
+ body: InferBodyInput<Opts & {
1137
+ use: any[];
1138
+ }>;
1139
+ method: InferInputMethod<Opts & {
1140
+ use: any[];
1141
+ }>;
1142
+ query: InferQueryInput<Opts & {
1143
+ use: any[];
1144
+ }>;
1145
+ params: InferParam<Path>;
1146
+ request: InferRequest<Opts & {
1147
+ use: any[];
1148
+ }>;
1149
+ headers: InferHeadersInput<Opts & {
1150
+ use: any[];
1151
+ }>;
1152
+ asResponse?: boolean;
1153
+ returnHeaders?: boolean;
1154
+ use?: Middleware[];
1155
+ path?: string;
1156
+ }[K_2] ? K_2 : never]?: {
1157
+ body: InferBodyInput<Opts & {
1158
+ use: any[];
1159
+ }>;
1160
+ method: InferInputMethod<Opts & {
1161
+ use: any[];
1162
+ }>;
1163
+ query: InferQueryInput<Opts & {
1164
+ use: any[];
1165
+ }>;
1166
+ params: InferParam<Path>;
1167
+ request: InferRequest<Opts & {
1168
+ use: any[];
1169
+ }>;
1170
+ headers: InferHeadersInput<Opts & {
1171
+ use: any[];
1172
+ }>;
1173
+ asResponse?: boolean;
1174
+ returnHeaders?: boolean;
1175
+ use?: Middleware[];
1176
+ path?: string;
1177
+ }[K_2] | undefined; } : never))[K]; } : never>(...inputCtx: HasRequiredKeys<Context> extends true ? [Context] : [(Context | undefined)?]): Promise<Context["asResponse"] extends true ? Response : Context["returnHeaders"] extends true ? {
1178
+ headers: Headers;
1179
+ response: R;
1180
+ } : R>;
1181
+ options: Opts & {
1182
+ use: any[];
1183
+ };
1184
+ path: Path;
1185
+ };
1186
+ };
1187
+ type Endpoint<Path extends string = string, Options extends EndpointOptions = EndpointOptions, Handler extends (inputCtx: any) => Promise<any> = (inputCtx: any) => Promise<any>> = Handler & {
1188
+ options: Options;
1189
+ path: Path;
1190
+ };
1191
+
1192
+ interface RouterConfig {
1193
+ throwError?: boolean;
1194
+ onError?: (e: unknown) => void | Promise<void> | Response | Promise<Response>;
1195
+ basePath?: string;
1196
+ routerMiddleware?: Array<{
1197
+ path: string;
1198
+ middleware: Middleware;
1199
+ }>;
1200
+ /**
1201
+ * additional Context that needs to passed to endpoints
1202
+ *
1203
+ * this will be available on `ctx.context` on endpoints
1204
+ */
1205
+ routerContext?: Record<string, any>;
1206
+ /**
1207
+ * A callback to run before any response
1208
+ */
1209
+ onResponse?: (res: Response) => any | Promise<any>;
1210
+ /**
1211
+ * A callback to run before any request
1212
+ */
1213
+ onRequest?: (req: Request) => any | Promise<any>;
1214
+ /**
1215
+ * Open API route configuration
1216
+ */
1217
+ openAPI?: {
1218
+ /**
1219
+ * Disable openapi route
1220
+ *
1221
+ * @default false
1222
+ */
1223
+ disabled?: boolean;
1224
+ /**
1225
+ * A path to display open api using scalar
1226
+ *
1227
+ * @default "/api/reference"
1228
+ */
1229
+ path?: string;
1230
+ /**
1231
+ * Scalar Configuration
1232
+ */
1233
+ scalar?: {
1234
+ /**
1235
+ * Title
1236
+ * @default "Open API Reference"
1237
+ */
1238
+ title?: string;
1239
+ /**
1240
+ * Description
1241
+ *
1242
+ * @default "Better Call Open API Reference"
1243
+ */
1244
+ description?: string;
1245
+ /**
1246
+ * Logo URL
1247
+ */
1248
+ logo?: string;
1249
+ /**
1250
+ * Scalar theme
1251
+ * @default "saturn"
1252
+ */
1253
+ theme?: string;
1254
+ };
1255
+ };
1256
+ }
1257
+ declare const createRouter: <E extends Record<string, Endpoint>, Config extends RouterConfig>(endpoints: E, config?: Config) => {
1258
+ handler: (request: Request) => Promise<Response>;
1259
+ endpoints: E;
1260
+ };
1261
+ type Router = ReturnType<typeof createRouter>;
1262
+
1263
+ 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 };