@forklaunch/core 0.17.1 → 0.17.3

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,7 @@
1
- import { UnionToIntersection, TypeSafeFunction, StringWithoutSlash, Prettify, MakePropertyOptionalIfChildrenOptional, SanitizePathSlashes } from '@forklaunch/common';
1
+ import { Prettify, SanitizePathSlashes, MakePropertyOptionalIfChildrenOptional, UnionToIntersection, TypeSafeFunction, StringWithoutSlash } from '@forklaunch/common';
2
2
  import { AnySchemaValidator, UnboxedObjectSchema, IdiomaticSchema, Schema } from '@forklaunch/validator';
3
- import { Counter, Gauge, Histogram, UpDownCounter, ObservableCounter, ObservableGauge, ObservableUpDownCounter, Span } from '@opentelemetry/api';
4
3
  import { JWTPayload, JWK } from 'jose';
4
+ import { Counter, Gauge, Histogram, UpDownCounter, ObservableCounter, ObservableGauge, ObservableUpDownCounter, Span } from '@opentelemetry/api';
5
5
  import { ParsedQs } from 'qs';
6
6
  import { Readable } from 'stream';
7
7
  import { LevelWithSilentOrString, LevelWithSilent } from 'pino';
@@ -57,1012 +57,1012 @@ declare const httpServerDurationHistogram: Histogram<{
57
57
  "http.response.status_code": number;
58
58
  }>;
59
59
 
60
- /**
61
- * Dictionary type for URL parameters.
62
- */
63
- type ParamsDictionary = {
64
- [key: string]: string;
60
+ type DocsConfiguration = ({
61
+ type: 'scalar';
62
+ } & Partial<Omit<ApiReferenceConfiguration, 'spec'>>) | {
63
+ type: 'swagger';
65
64
  };
65
+
66
66
  /**
67
- * Type representing an object with only string keys.
67
+ * Options for global authentication in Express-like applications.
68
68
  *
69
- * @template SV - A type that extends AnySchemaValidator.
69
+ * @template SV - The schema validator type.
70
+ * @template SessionSchema - The session schema type.
71
+ *
72
+ * Can be `false` to disable authentication, or an object specifying session schema and
73
+ * functions to surface scopes, permissions, and roles from the JWT/session.
70
74
  */
71
- type StringOnlyObject<SV extends AnySchemaValidator> = Omit<UnboxedObjectSchema<SV>, number | symbol>;
75
+ type ExpressLikeGlobalAuthOptions<SV extends AnySchemaValidator, SessionSchema extends Record<string, unknown>> = false | {
76
+ /**
77
+ * Optional session schema for the authentication context.
78
+ */
79
+ sessionSchema?: SessionSchema;
80
+ /**
81
+ * Optional array describing the scope hierarchy for authorization.
82
+ */
83
+ scopeHeirarchy?: string[];
84
+ /**
85
+ * Function to extract a set of scopes from the JWT payload and request.
86
+ */
87
+ surfaceScopes?: (payload: JWTPayload & SessionSchema, req?: ForklaunchRequest<SV, Record<string, string>, Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, string, SessionSchema>) => Set<string> | Promise<Set<string>>;
88
+ /**
89
+ * Function to extract a set of permissions from the JWT payload and request.
90
+ */
91
+ surfacePermissions?: (payload: JWTPayload & SessionSchema, req?: ForklaunchRequest<SV, Record<string, string>, Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, string, SessionSchema>) => Set<string> | Promise<Set<string>>;
92
+ /**
93
+ * Function to extract a set of roles from the JWT payload and request.
94
+ */
95
+ surfaceRoles?: (payload: JWTPayload & SessionSchema, req?: ForklaunchRequest<SV, Record<string, string>, Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, string, SessionSchema>) => Set<string> | Promise<Set<string>>;
96
+ };
72
97
  /**
73
- * Type representing an object with only number keys.
98
+ * Schema-aware version of ExpressLikeGlobalAuthOptions.
74
99
  *
75
- * @template SV - A type that extends AnySchemaValidator.
100
+ * @template SV - The schema validator type.
101
+ * @template SessionSchema - The session object type.
76
102
  */
77
- type NumberOnlyObject<SV extends AnySchemaValidator> = Omit<UnboxedObjectSchema<SV>, string | symbol>;
103
+ type ExpressLikeSchemaGlobalAuthOptions<SV extends AnySchemaValidator, SessionSchema extends SessionObject<SV>> = ExpressLikeGlobalAuthOptions<SV, MapSessionSchema<SV, SessionSchema>>;
78
104
  /**
79
- * Type representing the body object in a request.
105
+ * Options for configuring an Express-like router.
80
106
  *
81
- * @template SV - A type that extends AnySchemaValidator.
107
+ * @template SV - The schema validator type.
108
+ * @template SessionSchema - The session object type.
82
109
  */
83
- type BodyObject<SV extends AnySchemaValidator> = StringOnlyObject<SV>;
110
+ type ExpressLikeRouterOptions<SV extends AnySchemaValidator, SessionSchema extends SessionObject<SV>> = {
111
+ /**
112
+ * Authentication options for the router.
113
+ */
114
+ auth?: ExpressLikeSchemaGlobalAuthOptions<SV, SessionSchema>;
115
+ /**
116
+ * Validation options for request and response.
117
+ * Can be `false` to disable validation, or an object to configure request/response validation levels.
118
+ */
119
+ validation?: false | {
120
+ /**
121
+ * Request validation mode: 'none', 'warning', or 'error'.
122
+ */
123
+ request?: 'none' | 'warning' | 'error';
124
+ /**
125
+ * Response validation mode: 'none', 'warning', or 'error'.
126
+ */
127
+ response?: 'none' | 'warning' | 'error';
128
+ };
129
+ /**
130
+ * OpenAPI documentation options.
131
+ */
132
+ openapi?: boolean;
133
+ /**
134
+ * MCP options.
135
+ */
136
+ mcp?: boolean;
137
+ };
84
138
  /**
85
- * Type representing the parameters object in a request.
139
+ * Options for configuring an Express-like application.
86
140
  *
87
- * @template SV - A type that extends AnySchemaValidator.
141
+ * @template SV - The schema validator type.
142
+ * @template SessionSchema - The session object type.
88
143
  */
89
- type ParamsObject<SV extends AnySchemaValidator> = StringOnlyObject<SV>;
144
+ type ExpressLikeApplicationOptions<SV extends AnySchemaValidator, SessionSchema extends SessionObject<SV>> = Omit<ExpressLikeRouterOptions<SV, SessionSchema>, 'openapi' | 'mcp'> & {
145
+ /**
146
+ * Documentation configuration.
147
+ */
148
+ docs?: DocsConfiguration;
149
+ /**
150
+ * Hosting/server options.
151
+ */
152
+ hosting?: {
153
+ /**
154
+ * SSL configuration or boolean to enable/disable SSL.
155
+ */
156
+ ssl?: {
157
+ /**
158
+ * SSL certificate as a string.
159
+ */
160
+ certFile: string;
161
+ /**
162
+ * SSL key as a string.
163
+ */
164
+ keyFile: string;
165
+ /**
166
+ * SSL CA as a string.
167
+ */
168
+ caFile: string;
169
+ };
170
+ /**
171
+ * Number of worker processes to spawn.
172
+ */
173
+ workerCount?: number;
174
+ /**
175
+ * Routing strategy to use.
176
+ */
177
+ routingStrategy?: 'round-robin' | 'sticky' | 'random';
178
+ };
179
+ /**
180
+ * FastMCP (management/control plane) options.
181
+ * Can be `false` to disable, or an object to configure.
182
+ */
183
+ mcp?: false | {
184
+ /**
185
+ * Port for the MCP server.
186
+ */
187
+ port?: number;
188
+ /**
189
+ * Endpoint for the MCP server.
190
+ */
191
+ path?: `/${string}`;
192
+ /**
193
+ * Additional options for FastMCP.
194
+ */
195
+ options?: ConstructorParameters<typeof FastMCP>[0];
196
+ /**
197
+ * Optional authentication callback for validating MCP requests.
198
+ * Called by FastMCP for each request to verify the session token.
199
+ * Return user info object if authenticated, undefined otherwise.
200
+ * Example: { email: 'user@example.com', name: 'User' }
201
+ */
202
+ authenticate?: (request: http.IncomingMessage) => Promise<Record<string, unknown> | undefined>;
203
+ /**
204
+ * Additional tools to register with the MCP server.
205
+ */
206
+ additionalTools?: (mcpServer: FastMCP) => void;
207
+ /**
208
+ * Content type mapping for the MCP server.
209
+ */
210
+ contentTypeMapping?: Record<string, string>;
211
+ /**
212
+ * Version of the MCP server.
213
+ */
214
+ version?: `${number}.${number}.${number}`;
215
+ };
216
+ /**
217
+ * OpenAPI documentation options.
218
+ * Can be `false` to disable, or an object to configure.
219
+ */
220
+ openapi?: false | {
221
+ /**
222
+ * Path to serve the OpenAPI docs (e.g., '/openapi').
223
+ */
224
+ path?: `/${string}`;
225
+ /**
226
+ * Title for the OpenAPI documentation.
227
+ */
228
+ title?: string;
229
+ /**
230
+ * Description for the OpenAPI documentation.
231
+ */
232
+ description?: string;
233
+ /**
234
+ * Contact information for the API.
235
+ */
236
+ contact?: {
237
+ /**
238
+ * Contact name.
239
+ */
240
+ name?: string;
241
+ /**
242
+ * Contact email.
243
+ */
244
+ email?: string;
245
+ };
246
+ /**
247
+ * Whether to enable discrete versioning for OpenAPI docs.
248
+ */
249
+ discreteVersions?: boolean;
250
+ };
251
+ /**
252
+ * CORS configuration options.
253
+ */
254
+ cors?: CorsOptions;
255
+ };
256
+
90
257
  /**
91
- * Type representing the query object in a request.
92
- *
93
- * @template SV - A type that extends AnySchemaValidator.
258
+ * Interface representing the context of a request.
94
259
  */
95
- type QueryObject<SV extends AnySchemaValidator> = StringOnlyObject<SV>;
260
+ interface RequestContext {
261
+ /** Correlation ID for tracking requests */
262
+ correlationId: string;
263
+ /** Optional idempotency key for ensuring idempotent requests */
264
+ idempotencyKey?: string;
265
+ /** Active OpenTelemetry Span */
266
+ span?: Span;
267
+ }
268
+ interface ForklaunchBaseRequest<P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>> {
269
+ /** Request parameters */
270
+ params: P;
271
+ /** Request headers */
272
+ headers: ReqHeaders;
273
+ /** Request body */
274
+ body: ReqBody;
275
+ /** Request query */
276
+ query: ReqQuery;
277
+ /** Method */
278
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'CONNECT' | 'TRACE';
279
+ /** Request path */
280
+ path: string;
281
+ /** Original path */
282
+ originalPath: string;
283
+ /** OpenTelemetry Collector */
284
+ openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
285
+ }
96
286
  /**
97
- * Type representing the headers object in a request.
287
+ * Interface representing a Forklaunch request.
98
288
  *
99
289
  * @template SV - A type that extends AnySchemaValidator.
290
+ * @template P - A type for request parameters, defaulting to ParamsDictionary.
291
+ * @template ReqBody - A type for the request body, defaulting to unknown.
292
+ * @template ReqQuery - A type for the request query, defaulting to ParsedQs.
293
+ * @template Headers - A type for the request headers, defaulting to IncomingHttpHeaders.
100
294
  */
101
- type HeadersObject<SV extends AnySchemaValidator> = StringOnlyObject<SV>;
102
- type RawTypedResponseBody<SV extends AnySchemaValidator> = TextBody<SV> | JsonBody<SV> | FileBody<SV> | ServerSentEventBody<SV> | UnknownResponseBody<SV>;
103
- type ExclusiveResponseBodyBase<SV extends AnySchemaValidator> = {
104
- [K in keyof UnionToIntersection<RawTypedResponseBody<SV>>]?: undefined;
105
- };
106
- type ExclusiveSchemaCatchall<SV extends AnySchemaValidator> = {
107
- [K in keyof SV['_SchemaCatchall'] as string extends K ? never : number extends K ? never : symbol extends K ? never : K]?: undefined;
108
- };
109
- type TypedResponseBody<SV extends AnySchemaValidator> = {
110
- [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveResponseBodyBase<SV>)]?: K extends keyof TextBody<SV> ? TextBody<SV>[K] : undefined;
111
- } | {
112
- [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveResponseBodyBase<SV>)]?: K extends keyof JsonBody<SV> ? JsonBody<SV>[K] : undefined;
113
- } | {
114
- [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveResponseBodyBase<SV>)]?: K extends keyof FileBody<SV> ? FileBody<SV>[K] : undefined;
115
- } | {
116
- [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveResponseBodyBase<SV>)]?: K extends keyof ServerSentEventBody<SV> ? ServerSentEventBody<SV>[K] : undefined;
117
- } | {
118
- [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveResponseBodyBase<SV>)]?: K extends keyof UnknownResponseBody<SV> ? UnknownResponseBody<SV>[K] : undefined;
119
- };
120
- type ResponseBody<SV extends AnySchemaValidator> = TypedResponseBody<SV> | (ExclusiveResponseBodyBase<SV> & SV['_ValidSchemaObject']) | (ExclusiveResponseBodyBase<SV> & UnboxedObjectSchema<SV>) | (ExclusiveResponseBodyBase<SV> & SV['string']) | (ExclusiveResponseBodyBase<SV> & SV['number']) | (ExclusiveResponseBodyBase<SV> & SV['boolean']) | (ExclusiveResponseBodyBase<SV> & SV['date']) | (ExclusiveResponseBodyBase<SV> & SV['array']) | (ExclusiveResponseBodyBase<SV> & SV['file']);
295
+ interface ForklaunchRequest<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends Record<string, unknown>, ReqHeaders extends Record<string, unknown>, Version extends string, SessionSchema extends Record<string, unknown>> {
296
+ /** Context of the request */
297
+ context: Prettify<RequestContext>;
298
+ /** API Version of the request */
299
+ version: Version;
300
+ /** Request parameters */
301
+ params: P;
302
+ /** Request headers */
303
+ headers: ReqHeaders;
304
+ /** Request body */
305
+ body: ReqBody;
306
+ /** Request query */
307
+ query: ReqQuery;
308
+ /** Contract details for the request */
309
+ contractDetails: PathParamHttpContractDetails<SV> | HttpContractDetails<SV>;
310
+ /** Schema validator */
311
+ schemaValidator: SV;
312
+ /** Method */
313
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'CONNECT' | 'TRACE';
314
+ /** Request path */
315
+ path: string;
316
+ /** Request schema, compiled */
317
+ requestSchema: unknown | Record<string, unknown>;
318
+ /** Original path */
319
+ originalPath: string;
320
+ /** OpenTelemetry Collector */
321
+ openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
322
+ /** Session */
323
+ session: JWTPayload & SessionSchema;
324
+ /** Parsed versions */
325
+ _parsedVersions: string[] | number;
326
+ /** Raw body before schema validation (for HMAC verification) */
327
+ _rawBody?: unknown;
328
+ /** Global options */
329
+ _globalOptions: () => ExpressLikeRouterOptions<SV, SessionSchema> | undefined;
330
+ }
121
331
  /**
122
- * Type representing the responses object in a request.
123
- *
124
- * @template SV - A type that extends AnySchemaValidator.
332
+ * Represents the types of data that can be sent in a response.
125
333
  */
126
- type ResponsesObject<SV extends AnySchemaValidator> = {
127
- [K: number]: ResponseBody<SV>;
128
- };
129
- type JsonBody<SV extends AnySchemaValidator> = {
130
- contentType?: 'application/json' | string;
131
- json: BodyObject<SV> | SV['_ValidSchemaObject'] | SV['_SchemaCatchall'];
132
- };
334
+ type ForklaunchSendableData = Record<string, unknown> | string | Buffer | ArrayBuffer | NodeJS.ReadableStream | null | undefined;
133
335
  /**
134
- * Type representing the body in a request.
135
- *
136
- * @template SV - A type that extends AnySchemaValidator.
336
+ * Interface representing a Forklaunch response status.
337
+ * @template ResBody - A type for the response body.
137
338
  */
138
- type TextBody<SV extends AnySchemaValidator> = {
139
- contentType?: 'application/xml' | 'text/plain' | 'text/html' | 'text/css' | 'text/javascript' | 'text/csv' | 'text/markdown' | 'text/xml' | 'text/rtf' | 'text/x-yaml' | 'text/yaml' | string;
140
- text: SV['string'];
141
- };
142
- type FileBody<SV extends AnySchemaValidator> = {
143
- contentType?: 'application/octet-stream' | 'application/pdf' | 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/msword' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/zip' | 'image/jpeg' | 'image/png' | 'image/gif' | 'audio/mpeg' | 'audio/wav' | 'video/mp4' | string;
144
- file: SV['file'];
145
- };
339
+ interface ForklaunchStatusResponse<ResBody> {
340
+ /**
341
+ * Sends the response.
342
+ * @param {ResBodyMap} [body] - The response body.
343
+ * @param {boolean} [close_connection] - Whether to close the connection.
344
+ * @returns {T} - The sent response.
345
+ */
346
+ send: {
347
+ (body?: ResBody extends AsyncGenerator<unknown> ? never : ResBody extends Blob ? Blob | File | Buffer | ArrayBuffer | NodeJS.ReadableStream : ResBody | null, close_connection?: boolean): boolean;
348
+ <U>(body?: ResBody extends AsyncGenerator<unknown> ? never : ResBody extends Blob ? Blob | File | Buffer | ArrayBuffer | NodeJS.ReadableStream : ResBody | null, close_connection?: boolean): U;
349
+ };
350
+ /**
351
+ * Sends a JSON response.
352
+ * @param {ResBodyMap} [body] - The response body.
353
+ * @returns {boolean|T} - The JSON response.
354
+ */
355
+ json: {
356
+ (body: ResBody extends string | AsyncGenerator<unknown> ? never : ResBody | null): boolean;
357
+ <U>(body: ResBody extends string | AsyncGenerator<unknown> ? never : ResBody | null): U;
358
+ };
359
+ /**
360
+ * Sends a JSONP response.
361
+ * @param {ResBodyMap} [body] - The response body.
362
+ * @returns {boolean|T} - The JSONP response.
363
+ */
364
+ jsonp: {
365
+ (body: ResBody extends string | AsyncGenerator<unknown> ? never : ResBody | null): boolean;
366
+ <U>(body: ResBody extends string | AsyncGenerator<unknown> ? never : ResBody | null): U;
367
+ };
368
+ /**
369
+ * Sends a Server-Sent Event (SSE) response.
370
+ * @param {ResBodyMap} [body] - The response body.
371
+ * @param {number} interval - The interval between events.
372
+ */
373
+ sseEmitter: (generator: () => AsyncGenerator<ResBody extends AsyncGenerator<infer T> ? T : never, void, unknown>) => void;
374
+ }
375
+ type ToNumber<T extends string | number | symbol> = T extends number ? T : T extends `${infer N extends number}` ? N : never;
146
376
  /**
147
- * Type representing the body in a request.
377
+ * Interface representing a Forklaunch response.
148
378
  *
379
+ * @template ResBodyMap - A type for the response body, defaulting to common status code responses.
380
+ * @template StatusCode - A type for the status code, defaulting to number.
381
+ */
382
+ interface ForklaunchResponse<BaseResponse, ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, unknown>, LocalsObj extends Record<string, unknown>, Version extends string> {
383
+ /** Data of the response body */
384
+ bodyData: unknown;
385
+ /** Status code of the response */
386
+ statusCode: number;
387
+ /** Whether the response is finished */
388
+ headersSent: boolean;
389
+ /**
390
+ * Gets the headers of the response.
391
+ * @returns {Omit<ResHeaders, keyof ForklaunchResHeaders> & ForklaunchResHeaders} - The headers of the response.
392
+ */
393
+ getHeaders: () => Omit<ResHeaders, keyof ForklaunchResHeaders> & ForklaunchResHeaders;
394
+ /**
395
+ * Gets a header for the response.
396
+ * @param {string} key - The header key.
397
+ * @returns {string | string[] | undefined} The header value.
398
+ */
399
+ getHeader: (key: string) => string | string[] | undefined;
400
+ /**
401
+ * Sets a header for the response.
402
+ * @param {string} key - The header key.
403
+ * @param {string} value - The header value.
404
+ */
405
+ setHeader: {
406
+ <K extends keyof (ResHeaders & ForklaunchResHeaders)>(key: K, value: K extends keyof ForklaunchResHeaders ? ForklaunchResHeaders[K] : ResHeaders[K]): void;
407
+ <K extends keyof (ResHeaders & ForklaunchResHeaders)>(key: K, value: K extends keyof ForklaunchResHeaders ? ForklaunchResHeaders[K] : ResHeaders[K]): BaseResponse;
408
+ };
409
+ /**
410
+ * Adds an event listener to the response.
411
+ * @param {string} event - The event to listen for.
412
+ * @param {Function} listener - The listener function.
413
+ */
414
+ on(event: 'close', listener: () => void): BaseResponse & this;
415
+ on(event: 'drain', listener: () => void): BaseResponse & this;
416
+ on(event: 'error', listener: (err: Error) => void): BaseResponse & this;
417
+ on(event: 'finish', listener: () => void): BaseResponse & this;
418
+ on(event: 'pipe', listener: (src: Readable) => void): BaseResponse & this;
419
+ on(event: 'unpipe', listener: (src: Readable) => void): BaseResponse & this;
420
+ on(event: string | symbol, listener: (...args: unknown[]) => void): BaseResponse & this;
421
+ /**
422
+ * Sets the status of the response.
423
+ * @param {U} code - The status code.
424
+ * @param {string} [message] - Optional message.
425
+ * @returns {ForklaunchResponse<(ResBodyMap)[U], ResHeaders, U, LocalsObj>} - The response with the given status.
426
+ */
427
+ status: {
428
+ <U extends ToNumber<keyof (ResBodyMap & ForklaunchResErrors)>>(code: U): Omit<BaseResponse, keyof ForklaunchStatusResponse<(Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)[U]>> & ForklaunchStatusResponse<(Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)[U]>;
429
+ <U extends ToNumber<keyof (ResBodyMap & ForklaunchResErrors)>>(code: U, message?: string): Omit<BaseResponse, keyof ForklaunchStatusResponse<(Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)[U]>> & ForklaunchStatusResponse<(Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)[U]>;
430
+ };
431
+ /**
432
+ * Ends the response.
433
+ * @param {string} [data] - Optional data to send.
434
+ */
435
+ end: {
436
+ (data?: string): void;
437
+ (cb?: (() => void) | undefined): BaseResponse;
438
+ };
439
+ /**
440
+ * Sets the content type of the response.
441
+ * @param {string} type - The content type.
442
+ */
443
+ type: {
444
+ (type: string): void;
445
+ (type: string): BaseResponse;
446
+ };
447
+ /** Local variables */
448
+ locals: LocalsObj;
449
+ /** Cors */
450
+ cors: boolean;
451
+ /** Response schema, compiled */
452
+ responseSchemas: ResponseCompiledSchema | Record<string, ResponseCompiledSchema>;
453
+ /** Whether the metric has been recorded */
454
+ metricRecorded: boolean;
455
+ /** Whether the response has been sent */
456
+ sent: boolean;
457
+ /** Versioned responses */
458
+ version: Version;
459
+ }
460
+ /**
461
+ * Type representing the next function in a middleware.
462
+ * @param {unknown} [err] - Optional error parameter.
463
+ */
464
+ type ForklaunchNextFunction = (err?: unknown) => void;
465
+ type VersionedRequests = Record<string, {
466
+ requestHeaders?: Record<string, unknown>;
467
+ body?: Record<string, unknown>;
468
+ query?: Record<string, unknown>;
469
+ }>;
470
+ type ResolvedForklaunchRequestBase<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends Record<string, unknown>, ReqHeaders extends Record<string, unknown>, Version extends string, SessionSchema extends Record<string, unknown>, BaseRequest> = unknown extends BaseRequest ? ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Version, SessionSchema> : Omit<BaseRequest, keyof ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Version, SessionSchema>> & ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Version, SessionSchema>;
471
+ /**
472
+ * Type representing the resolved forklaunch request from a base request type.
149
473
  * @template SV - A type that extends AnySchemaValidator.
474
+ * @template P - A type for request parameters, defaulting to ParamsDictionary.
475
+ * @template ReqBody - A type for the request body, defaulting to Record<string, unknown>.
476
+ * @template ReqQuery - A type for the request query, defaulting to ParsedQs.
477
+ * @template ReqHeaders - A type for the request headers, defaulting to Record<string, unknown>.
478
+ * @template BaseRequest - A type for the base request.
150
479
  */
151
- type MultipartForm<SV extends AnySchemaValidator> = {
152
- contentType?: 'multipart/form-data' | 'multipart/mixed' | 'multipart/alternative' | 'multipart/related' | 'multipart/signed' | 'multipart/encrypted' | string;
153
- multipartForm: BodyObject<SV>;
480
+ type ResolvedForklaunchRequest<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends Record<string, unknown>, ReqHeaders extends Record<string, string>, VersionedReqs extends VersionedRequests, SessionSchema extends Record<string, unknown>, BaseRequest> = VersionedRequests extends VersionedReqs ? ResolvedForklaunchRequestBase<SV, P, ReqBody, ReqQuery, ReqHeaders, never, SessionSchema, BaseRequest> : {
481
+ [K in keyof VersionedReqs]: ResolvedForklaunchRequestBase<SV, P, VersionedReqs[K]['body'] extends Record<string, unknown> ? VersionedReqs[K]['body'] : Record<string, unknown>, VersionedReqs[K]['query'] extends Record<string, unknown> ? VersionedReqs[K]['query'] : ParsedQs, VersionedReqs[K]['requestHeaders'] extends Record<string, unknown> ? VersionedReqs[K]['requestHeaders'] : Record<string, string>, K extends string ? K : never, SessionSchema, BaseRequest>;
482
+ }[keyof VersionedReqs];
483
+ type ResolvedForklaunchAuthRequest<P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>, BaseRequest> = unknown extends BaseRequest ? ForklaunchBaseRequest<P, ReqBody, ReqQuery, ReqHeaders> : {
484
+ [key in keyof BaseRequest]: key extends keyof ForklaunchBaseRequest<P, ReqBody, ReqQuery, ReqHeaders> ? ForklaunchBaseRequest<P, ReqBody, ReqQuery, ReqHeaders>[key] : key extends keyof BaseRequest ? BaseRequest[key] : never;
485
+ };
486
+ type VersionedResponses = Record<string, {
487
+ responseHeaders?: Record<string, unknown>;
488
+ responses: Record<number, unknown>;
489
+ }>;
490
+ type ResolvedForklaunchResponseBase<ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, unknown>, LocalsObj extends Record<string, unknown>, Version extends string, BaseResponse> = unknown extends BaseResponse ? ForklaunchResponse<BaseResponse, ResBodyMap, ResHeaders, LocalsObj, Version> : (string extends Version ? unknown : {
491
+ version?: Version;
492
+ }) & {
493
+ [K in keyof BaseResponse | keyof ForklaunchResponse<BaseResponse, ResBodyMap, ResHeaders, LocalsObj, Version>]: K extends keyof ForklaunchResponse<BaseResponse, ResBodyMap, ResHeaders, LocalsObj, Version> ? ForklaunchResponse<BaseResponse, ResBodyMap, ResHeaders, LocalsObj, Version>[K] : K extends keyof BaseResponse ? BaseResponse[K] : never;
154
494
  };
495
+ type ResolvedForklaunchResponse<ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown>, VersionedResps extends VersionedResponses, BaseResponse> = VersionedResponses extends VersionedResps ? ResolvedForklaunchResponseBase<ResBodyMap, ResHeaders, LocalsObj, never, BaseResponse> : {
496
+ [K in keyof VersionedResps]: ResolvedForklaunchResponseBase<VersionedResps[K]['responses'], VersionedResps[K]['responseHeaders'] extends Record<string, unknown> ? VersionedResps[K]['responseHeaders'] : Record<string, string>, LocalsObj, K extends string ? K : never, BaseResponse>;
497
+ }[keyof VersionedResps];
155
498
  /**
156
- * Type representing the body in a request.
499
+ * Represents a middleware handler with schema validation.
157
500
  *
158
501
  * @template SV - A type that extends AnySchemaValidator.
502
+ * @template P - A type for request parameters, defaulting to ParamsDictionary.
503
+ * @template ResBodyMap - A type for the response body, defaulting to unknown.
504
+ * @template ReqBody - A type for the request body, defaulting to unknown.
505
+ * @template ReqQuery - A type for the request query, defaulting to ParsedQs.
506
+ * @template LocalsObj - A type for local variables, defaulting to an empty object.
507
+ * @template StatusCode - A type for the status code, defaulting to number.
159
508
  */
160
- type UrlEncodedForm<SV extends AnySchemaValidator> = {
161
- contentType?: 'application/x-www-form-urlencoded' | 'application/x-url-encoded' | 'application/x-www-url-encoded' | 'application/x-urlencode' | string;
162
- urlEncodedForm: BodyObject<SV>;
163
- };
164
- type ServerSentEventBody<SV extends AnySchemaValidator> = {
165
- contentType?: 'text/event-stream' | string;
166
- event: {
167
- id: SV['string'];
168
- data: SV['string'] | BodyObject<SV>;
169
- };
170
- };
171
- type UnknownBody<SV extends AnySchemaValidator> = {
172
- contentType?: string;
173
- schema: BodyObject<SV> | SV['_ValidSchemaObject'] | SV['_SchemaCatchall'];
509
+ interface ExpressLikeHandler<SV extends AnySchemaValidator, P extends ParamsDictionary, ResBodyMap extends Record<number, unknown>, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>, ResHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown>, VersionedReqs extends VersionedRequests, VersionedResps extends VersionedResponses, SessionSchema extends Record<string, unknown>, BaseRequest, BaseResponse, NextFunction> {
510
+ (req: ResolvedForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, SessionSchema, BaseRequest>, res: ResolvedForklaunchResponse<ResBodyMap, ResHeaders, LocalsObj, VersionedResps, BaseResponse>, next: NextFunction): unknown;
511
+ }
512
+ type MapParamsSchema<SV extends AnySchemaValidator, P extends ParamsObject<SV>> = MapSchema<SV, P> extends infer Params ? unknown extends Params ? ParamsDictionary : Params : ParamsDictionary;
513
+ type ExtractContentType<SV extends AnySchemaValidator, T extends ResponseBody<SV> | unknown> = T extends {
514
+ contentType: string;
515
+ } ? T['contentType'] : T extends JsonBody<SV> ? 'application/json' : T extends TextBody<SV> ? 'text/plain' : T extends FileBody<SV> ? 'application/octet-stream' : T extends ServerSentEventBody<SV> ? 'text/event-stream' : T extends UnknownResponseBody<SV> ? 'application/json' : T extends SV['file'] ? 'application/octet-stream' : 'text/plain';
516
+ type ExtractResponseBody<SV extends AnySchemaValidator, T extends ResponseBody<SV> | unknown> = T extends JsonBody<SV> ? MapSchema<SV, T['json']> : T extends TextBody<SV> ? MapSchema<SV, T['text']> : T extends FileBody<SV> ? File | Blob : T extends ServerSentEventBody<SV> ? AsyncGenerator<MapSchema<SV, T['event']>> : T extends UnknownResponseBody<SV> ? MapSchema<SV, T['schema']> : MapSchema<SV, T>;
517
+ type MapResBodyMapSchema<SV extends AnySchemaValidator, ResBodyMap extends ResponsesObject<SV>> = unknown extends ResBodyMap ? ForklaunchResErrors : {
518
+ [K in keyof ResBodyMap]: ExtractResponseBody<SV, ResBodyMap[K]>;
174
519
  };
175
- type UnknownResponseBody<SV extends AnySchemaValidator> = {
176
- contentType?: string;
177
- schema: BodyObject<SV> | SV['_ValidSchemaObject'] | SV['_SchemaCatchall'];
178
- };
179
- type ExclusiveRequestBodyBase<SV extends AnySchemaValidator> = {
180
- [K in keyof UnionToIntersection<TypedBody<SV>>]?: undefined;
520
+ type ExtractBody<SV extends AnySchemaValidator, T extends Body<SV>> = T extends JsonBody<SV> ? T['json'] : T extends TextBody<SV> ? T['text'] : T extends FileBody<SV> ? T['file'] : T extends MultipartForm<SV> ? T['multipartForm'] : T extends UrlEncodedForm<SV> ? T['urlEncodedForm'] : T extends UnknownBody<SV> ? T['schema'] : T;
521
+ type MapReqBodySchema<SV extends AnySchemaValidator, ReqBody extends Body<SV>> = MapSchema<SV, ExtractBody<SV, ReqBody>> extends infer Body ? unknown extends Body ? Record<string, unknown> : Body : Record<string, unknown>;
522
+ type MapReqQuerySchema<SV extends AnySchemaValidator, ReqQuery extends QueryObject<SV>> = MapSchema<SV, ReqQuery> extends infer Query ? unknown extends Query ? ParsedQs : Query : ParsedQs;
523
+ type MapReqHeadersSchema<SV extends AnySchemaValidator, ReqHeaders extends HeadersObject<SV>> = MapSchema<SV, ReqHeaders> extends infer RequestHeaders ? unknown extends RequestHeaders ? Record<string, string> : RequestHeaders : Record<string, string>;
524
+ type MapResHeadersSchema<SV extends AnySchemaValidator, ResHeaders extends HeadersObject<SV>> = MapSchema<SV, ResHeaders> extends infer ResponseHeaders ? unknown extends ResponseHeaders ? ForklaunchResHeaders : ResponseHeaders : ForklaunchResHeaders;
525
+ type MapVersionedReqsSchema<SV extends AnySchemaValidator, VersionedReqs extends VersionSchema<SV, Method>> = {
526
+ [K in keyof VersionedReqs]: (VersionedReqs[K]['requestHeaders'] extends HeadersObject<SV> ? {
527
+ requestHeaders: MapReqHeadersSchema<SV, VersionedReqs[K]['requestHeaders']>;
528
+ } : unknown) & (VersionedReqs[K]['body'] extends Body<SV> ? {
529
+ body: MapReqBodySchema<SV, VersionedReqs[K]['body']>;
530
+ } : unknown) & (VersionedReqs[K]['query'] extends QueryObject<SV> ? {
531
+ query: MapReqQuerySchema<SV, VersionedReqs[K]['query']>;
532
+ } : unknown);
533
+ } extends infer MappedVersionedReqs ? MappedVersionedReqs extends VersionedRequests ? MappedVersionedReqs : VersionedRequests : VersionedRequests;
534
+ type MapVersionedRespsSchema<SV extends AnySchemaValidator, VersionedResps extends VersionSchema<SV, Method>> = {
535
+ [K in keyof VersionedResps]: (VersionedResps[K]['responseHeaders'] extends HeadersObject<SV> ? {
536
+ responseHeaders: MapResHeadersSchema<SV, VersionedResps[K]['responseHeaders']>;
537
+ } : unknown) & (VersionedResps[K]['responses'] extends ResponsesObject<SV> ? {
538
+ responses: MapResBodyMapSchema<SV, VersionedResps[K]['responses']>;
539
+ } : unknown);
540
+ } extends infer MappedVersionedResps ? MappedVersionedResps extends VersionedResponses ? MappedVersionedResps : VersionedResponses : VersionedResponses;
541
+ type MapSessionSchema<SV extends AnySchemaValidator, SessionSchema extends SessionObject<SV>> = SessionSchema extends infer UnmappedSessionSchema ? UnmappedSessionSchema extends SessionObject<SV> ? MapSchema<SV, UnmappedSessionSchema> : never : never;
542
+ /**
543
+ * Represents a schema middleware handler with typed parameters, responses, body, and query.
544
+ *
545
+ * @template SV - A type that extends AnySchemaValidator.
546
+ * @template P - A type for parameter schemas, defaulting to ParamsObject.
547
+ * @template ResBodyMap - A type for response schemas, defaulting to ResponsesObject.
548
+ * @template ReqBody - A type for the request body, defaulting to Body.
549
+ * @template ReqQuery - A type for the request query, defaulting to QueryObject.
550
+ * @template LocalsObj - A type for local variables, defaulting to an empty object.
551
+ */
552
+ type ExpressLikeSchemaHandler<SV extends AnySchemaValidator, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, Method>, SessionSchema extends Record<string, unknown>, BaseRequest, BaseResponse, NextFunction> = ExpressLikeHandler<SV, MapParamsSchema<SV, P>, MapResBodyMapSchema<SV, ResBodyMap>, MapReqBodySchema<SV, ReqBody>, MapReqQuerySchema<SV, ReqQuery>, MapReqHeadersSchema<SV, ReqHeaders>, MapResHeadersSchema<SV, ResHeaders>, LocalsObj, MapVersionedReqsSchema<SV, VersionedApi>, MapVersionedRespsSchema<SV, VersionedApi>, MapSessionSchema<SV, SessionSchema>, BaseRequest, BaseResponse, NextFunction>;
553
+ /**
554
+ * Represents a function that maps an authenticated request with schema validation
555
+ * to a set of authorization strings, with request properties automatically inferred from the schema.
556
+ *
557
+ * @template SV - The type representing the schema validator.
558
+ * @template P - The type representing request parameters inferred from the schema.
559
+ * @template ReqBody - The type representing the request body inferred from the schema.
560
+ * @template ReqQuery - The type representing the request query parameters inferred from the schema.
561
+ * @template ReqHeaders - The type representing the request headers inferred from the schema.
562
+ *
563
+ * @param {ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>} req - The request object with schema validation.
564
+ * @returns {Set<string> | Promise<Set<string>>} - A set of authorization strings or a promise that resolves to it.
565
+ */
566
+ type ExpressLikeSchemaAuthMapper<SV extends AnySchemaValidator, P extends ParamsObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, VersionedReqs extends VersionSchema<SV, Method>, SessionSchema extends SessionObject<SV>, BaseRequest> = ExpressLikeAuthMapper<SV, P extends infer UnmappedParams ? UnmappedParams extends ParamsObject<SV> ? MapParamsSchema<SV, UnmappedParams> : never : never, ReqBody extends infer UnmappedReqBody ? UnmappedReqBody extends Body<SV> ? MapReqBodySchema<SV, UnmappedReqBody> : never : never, ReqQuery extends infer UnmappedReqQuery ? UnmappedReqQuery extends QueryObject<SV> ? MapReqQuerySchema<SV, UnmappedReqQuery> : never : never, ReqHeaders extends infer UnmappedReqHeaders ? UnmappedReqHeaders extends HeadersObject<SV> ? MapReqHeadersSchema<SV, UnmappedReqHeaders> : never : never, VersionedReqs extends infer UnmappedVersionedReqs ? UnmappedVersionedReqs extends VersionSchema<SV, Method> ? MapVersionedReqsSchema<SV, UnmappedVersionedReqs> : never : never, SessionSchema extends infer UnmappedSessionSchema ? UnmappedSessionSchema extends Record<string, unknown> ? MapSessionSchema<SV, UnmappedSessionSchema> : never : never, BaseRequest>;
567
+ type ExpressLikeAuthMapper<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends Record<string, unknown>, ReqHeaders extends Record<string, string>, VersionedReqs extends VersionedRequests, SessionSchema extends Record<string, unknown>, BaseRequest> = (payload: JWTPayload & SessionSchema, req?: ResolvedForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, SessionSchema, BaseRequest>) => Set<string> | Promise<Set<string>>;
568
+ type TokenPrefix<Auth extends AuthMethodsBase> = undefined extends Auth['tokenPrefix'] ? Auth extends BasicAuthMethods ? 'Basic ' : Auth extends HmacMethods ? 'HMAC ' : 'Bearer ' : `${Auth['tokenPrefix']} `;
569
+ type AuthHeaders<Auth extends AuthMethodsBase> = undefined extends Auth['headerName'] ? {
570
+ authorization: Auth extends HmacMethods ? `${TokenPrefix<Auth>}keyId=${string} ts=${string} nonce=${string} signature=${string}` : `${TokenPrefix<Auth>}${string}`;
571
+ } : {
572
+ [K in NonNullable<Auth['headerName']>]: `${TokenPrefix<Auth>}${string}`;
181
573
  };
182
- type TypedRequestBody<SV extends AnySchemaValidator> = {
183
- [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof TextBody<SV> ? TextBody<SV>[K] : undefined;
184
- } | {
185
- [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof JsonBody<SV> ? JsonBody<SV>[K] : undefined;
186
- } | {
187
- [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof FileBody<SV> ? FileBody<SV>[K] : undefined;
574
+ type AuthCollapse<Auth extends AuthMethodsBase> = undefined extends Auth['jwt'] ? undefined extends Auth['basic'] ? undefined extends Auth['hmac'] ? true : false : false : false;
575
+ type LiveTypeFunctionRequestInit<SV extends AnySchemaValidator, P extends ParamsObject<SV>, ReqBody extends Body<SV> | undefined, ReqQuery extends QueryObject<SV> | undefined, ReqHeaders extends HeadersObject<SV> | undefined, Auth extends AuthMethodsBase> = MakePropertyOptionalIfChildrenOptional<(Body<SV> extends ReqBody ? unknown : {
576
+ body: MapSchema<SV, ReqBody>;
577
+ }) & (QueryObject<SV> extends ReqQuery ? unknown : {
578
+ query: MapSchema<SV, ReqQuery>;
579
+ }) & (HeadersObject<SV> extends ReqHeaders ? true extends AuthCollapse<Auth> ? unknown : {
580
+ headers: AuthHeaders<Auth>;
581
+ } : true extends AuthCollapse<Auth> ? {
582
+ headers: MapSchema<SV, ReqHeaders>;
583
+ } : {
584
+ headers: MapSchema<SV, ReqHeaders> & AuthHeaders<Auth>;
585
+ }) & (ParamsObject<SV> extends P ? unknown : {
586
+ params: MapSchema<SV, P>;
587
+ })>;
588
+ /**
589
+ * Represents a live type function for the SDK.
590
+ *
591
+ * @template SV - A type that extends AnySchemaValidator.
592
+ * @template Path - A type for the route path.
593
+ * @template P - A type for request parameters.
594
+ * @template ResBodyMap - A type for response schemas.
595
+ * @template ReqBody - A type for the request body.
596
+ * @template ReqQuery - A type for the request query.
597
+ * @template ReqHeaders - A type for the request headers.
598
+ * @template ResHeaders - A type for the response headers.
599
+ *
600
+ */
601
+ type LiveTypeFunction<SV extends AnySchemaValidator, Route extends string, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, ContractMethod extends Method, VersionedApi extends VersionSchema<SV, ContractMethod>, Auth extends AuthMethodsBase> = string extends keyof VersionedApi ? (route: SanitizePathSlashes<Route>, ...reqInit: Prettify<Omit<RequestInit, 'method' | 'body' | 'query' | 'headers' | 'params'> & {
602
+ method: Uppercase<ContractMethod>;
603
+ } & LiveTypeFunctionRequestInit<SV, P, ReqBody, ReqQuery, ReqHeaders, Auth>> extends infer ReqInit ? ReqInit extends {
604
+ body: unknown;
188
605
  } | {
189
- [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof MultipartForm<SV> ? MultipartForm<SV>[K] : undefined;
606
+ params: unknown;
190
607
  } | {
191
- [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof UrlEncodedForm<SV> ? UrlEncodedForm<SV>[K] : undefined;
608
+ query: unknown;
192
609
  } | {
193
- [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof UnknownBody<SV> ? UnknownBody<SV>[K] : undefined;
194
- };
195
- type TypedBody<SV extends AnySchemaValidator> = JsonBody<SV> | TextBody<SV> | FileBody<SV> | MultipartForm<SV> | UrlEncodedForm<SV> | UnknownBody<SV>;
196
- type Body<SV extends AnySchemaValidator> = TypedRequestBody<SV> | (ExclusiveRequestBodyBase<SV> & SV['_ValidSchemaObject']) | (ExclusiveRequestBodyBase<SV> & UnboxedObjectSchema<SV>) | (ExclusiveRequestBodyBase<SV> & SV['string']) | (ExclusiveRequestBodyBase<SV> & SV['number']) | (ExclusiveRequestBodyBase<SV> & SV['boolean']) | (ExclusiveRequestBodyBase<SV> & SV['date']) | (ExclusiveRequestBodyBase<SV> & SV['array']) | (ExclusiveRequestBodyBase<SV> & SV['file']) | (ExclusiveRequestBodyBase<SV> & SV['any']) | (ExclusiveRequestBodyBase<SV> & SV['unknown']) | (ExclusiveRequestBodyBase<SV> & SV['binary']) | (ExclusiveRequestBodyBase<SV> & (SV['type'] extends TypeSafeFunction ? ReturnType<SV['type']> : never));
197
- type SessionObject<SV extends AnySchemaValidator> = StringOnlyObject<SV>;
198
- type BasicAuthMethods = {
199
- readonly basic: {
200
- readonly login: (username: string, password: string) => boolean;
201
- };
202
- readonly jwt?: never;
203
- readonly hmac?: never;
204
- };
205
- type JwtAuthMethods = {
206
- jwt: {
207
- readonly jwksPublicKey: JWK;
610
+ headers: unknown;
611
+ } ? [reqInit: Prettify<ReqInit>] : [reqInit?: Prettify<ReqInit>] : never) => Promise<Prettify<SdkResponse<SV, ResponsesObject<SV> extends ResBodyMap ? Record<number, unknown> : ResBodyMap, ForklaunchResHeaders extends ResHeaders ? unknown : MapSchema<SV, ResHeaders>>>> : {
612
+ [K in keyof VersionedApi]: (...reqInit: Prettify<Omit<RequestInit, 'method' | 'body' | 'query' | 'headers' | 'params'> & LiveTypeFunctionRequestInit<SV, P, VersionedApi[K]['body'] extends Body<SV> ? VersionedApi[K]['body'] : Body<SV>, VersionedApi[K]['query'] extends QueryObject<SV> ? VersionedApi[K]['query'] : QueryObject<SV>, VersionedApi[K]['requestHeaders'] extends HeadersObject<SV> ? VersionedApi[K]['requestHeaders'] : HeadersObject<SV>, Auth>> & {
613
+ version: K;
614
+ } extends infer ReqInit ? ReqInit extends {
615
+ body: unknown;
208
616
  } | {
209
- readonly jwksPublicKeyUrl: string;
617
+ params: unknown;
210
618
  } | {
211
- readonly signatureKey: string;
212
- };
213
- readonly basic?: never;
214
- readonly hmac?: never;
215
- };
216
- type HmacMethods = {
217
- readonly hmac: {
218
- readonly secretKeys: Record<string, string>;
219
- };
220
- readonly sessionSchema?: never;
221
- readonly basic?: never;
222
- readonly jwt?: never;
223
- };
224
- type TokenOptions = {
225
- readonly tokenPrefix?: string;
226
- readonly headerName?: string;
619
+ query: unknown;
620
+ } | {
621
+ headers: unknown;
622
+ } ? [reqInit: Prettify<ReqInit>] : [reqInit?: Prettify<ReqInit>] : never) => Promise<Prettify<SdkResponse<SV, ResponsesObject<SV> extends VersionedApi[K]['responses'] ? Record<number, unknown> : VersionedApi[K]['responses'], ForklaunchResHeaders extends VersionedApi[K]['responseHeaders'] ? unknown : MapSchema<SV, VersionedApi[K]['responseHeaders']>>>>;
227
623
  };
228
- type DecodeResource = (token: string) => JWTPayload | Promise<JWTPayload>;
229
- type AuthMethodsBase = TokenOptions & (HmacMethods | ({
230
- readonly decodeResource?: DecodeResource;
231
- } & (PermissionSet | RoleSet) & (BasicAuthMethods | JwtAuthMethods)));
232
- type PermissionSet = {
233
- readonly allowedPermissions: Set<string>;
624
+ /**
625
+ * Represents a live type function for the SDK.
626
+ *
627
+ * @template SV - A type that extends AnySchemaValidator.
628
+ * @template P - A type for request parameters.
629
+ * @template ResBodyMap - A type for response schemas.
630
+ * @template ReqBody - A type for the request body.
631
+ * @template ReqQuery - A type for the request query.
632
+ * @template ReqHeaders - A type for the request headers.
633
+ * @template ResHeaders - A type for the response headers.
634
+ *
635
+ */
636
+ type LiveSdkFunction<SV extends AnySchemaValidator, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method>, Auth extends AuthMethodsBase> = string extends keyof VersionedApi ? (...reqInit: Prettify<Omit<RequestInit, 'method' | 'body' | 'query' | 'headers' | 'params'> & LiveTypeFunctionRequestInit<SV, P, ReqBody, ReqQuery, ReqHeaders, Auth>> extends infer ReqInit ? ReqInit extends {
637
+ body: unknown;
234
638
  } | {
235
- readonly forbiddenPermissions: Set<string>;
236
- };
237
- type RoleSet = {
238
- readonly allowedRoles: Set<string>;
639
+ params: unknown;
239
640
  } | {
240
- readonly forbiddenRoles: Set<string>;
641
+ query: unknown;
642
+ } | {
643
+ headers: unknown;
644
+ } ? [reqInit: Prettify<ReqInit>] : [reqInit?: Prettify<ReqInit>] : never) => Promise<Prettify<SdkResponse<SV, ResponsesObject<SV> extends ResBodyMap ? Record<number, unknown> : ResBodyMap, ForklaunchResHeaders extends ResHeaders ? unknown : MapSchema<SV, ResHeaders>>>> : {
645
+ [K in keyof VersionedApi]: (...reqInit: Prettify<Omit<RequestInit, 'method' | 'body' | 'query' | 'headers' | 'params'> & LiveTypeFunctionRequestInit<SV, P, VersionedApi[K]['body'] extends Body<SV> ? VersionedApi[K]['body'] : Body<SV>, VersionedApi[K]['query'] extends QueryObject<SV> ? VersionedApi[K]['query'] : QueryObject<SV>, VersionedApi[K]['requestHeaders'] extends HeadersObject<SV> ? VersionedApi[K]['requestHeaders'] : HeadersObject<SV>, Auth>> extends infer ReqInit ? ReqInit extends {
646
+ body: unknown;
647
+ } | {
648
+ params: unknown;
649
+ } | {
650
+ query: unknown;
651
+ } | {
652
+ headers: unknown;
653
+ } ? [reqInit: Prettify<ReqInit>] : [reqInit?: Prettify<ReqInit>] : never) => Promise<Prettify<SdkResponse<SV, ResponsesObject<SV> extends VersionedApi[K]['responses'] ? Record<number, unknown> : VersionedApi[K]['responses'], ForklaunchResHeaders extends VersionedApi[K]['responseHeaders'] ? unknown : MapSchema<SV, VersionedApi[K]['responseHeaders']>>>>;
241
654
  };
242
655
  /**
243
- * Type representing the authentication methods.
656
+ * Represents a basic SDK Response object.
657
+ *
658
+ * @template ResBodyMap - A type for the response body.
659
+ * @template ResHeaders - A type for the response headers.
244
660
  */
245
- type SchemaAuthMethods<SV extends AnySchemaValidator, ParamsSchema extends ParamsObject<SV>, ReqBody extends Body<SV>, QuerySchema extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method>, BaseRequest> = AuthMethodsBase & {
246
- readonly sessionSchema?: SessionObject<SV>;
247
- readonly requiredScope?: string;
248
- readonly scopeHeirarchy?: string[];
249
- readonly surfaceScopes?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionObject<SV>, BaseRequest>;
250
- } & ({
251
- readonly surfacePermissions?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionObject<SV>, BaseRequest>;
252
- } | {
253
- readonly surfaceRoles?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionObject<SV>, BaseRequest>;
254
- });
255
- type AuthMethods<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends Record<string, unknown>, ReqHeaders extends Record<string, string>, VersionedReqs extends VersionedRequests, BaseRequest> = AuthMethodsBase & {
256
- readonly sessionSchema?: SessionObject<SV>;
257
- readonly requiredScope?: string;
258
- readonly scopeHeirarchy?: string[];
259
- readonly surfaceScopes?: ExpressLikeAuthMapper<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, SessionObject<SV>, BaseRequest>;
260
- } & (({
261
- readonly surfacePermissions?: ExpressLikeAuthMapper<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, SessionObject<SV>, BaseRequest>;
262
- } & PermissionSet) | ({
263
- readonly surfaceRoles?: ExpressLikeAuthMapper<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, SessionObject<SV>, BaseRequest>;
264
- } & RoleSet));
661
+ type SdkResponse<SV extends AnySchemaValidator, ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, unknown> | unknown> = ({
662
+ [K in keyof Omit<ForklaunchResErrors, keyof ResBodyMap>]: {
663
+ code: K;
664
+ contentType: 'text/plain';
665
+ response: ForklaunchResErrors[K];
666
+ };
667
+ } & {
668
+ [K in keyof ResBodyMap]: {
669
+ code: K;
670
+ contentType: ExtractContentType<SV, ResBodyMap[K]>;
671
+ response: ExtractResponseBody<SV, ResBodyMap[K]>;
672
+ } & (unknown extends ResHeaders ? unknown : {
673
+ headers: ResHeaders;
674
+ });
675
+ })[keyof (Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)];
265
676
  /**
266
- * Type representing a mapped schema.
267
- *s ParamsDictionary,
268
- // ReqBody extends Record<string, unknown>,
269
- //
270
- * @template SV - A type that extends AnySchemaValidator.
271
- * @template T - A type that extends IdiomaticSchema or a valid schema object.
677
+ * Represents the default error types for responses.
272
678
  */
273
- type MapSchema<SV extends AnySchemaValidator, T extends IdiomaticSchema<SV> | SV['_ValidSchemaObject']> = Schema<T, SV> extends infer U ? (T extends U ? unknown : U) : never;
679
+ type ForklaunchResErrors<BadRequest = string, Unauthorized = string, NotFound = string, Forbidden = string, InternalServerErrorType = string> = {
680
+ 400: BadRequest;
681
+ 401: Unauthorized;
682
+ 404: NotFound;
683
+ 403: Forbidden;
684
+ 500: InternalServerErrorType;
685
+ };
274
686
  /**
275
- * Type representing the parameters in a request.
687
+ * Represents the default header types for responses.
276
688
  */
277
- type ExtractParams<Path extends `/${string}`> = Path extends `${string}/:${infer Param}/${infer Rest}` ? Param | ExtractParams<`/${Rest}`> : Path extends `${string}/:${infer Param}` ? Param : never;
689
+ type ForklaunchResHeaders = {
690
+ 'x-correlation-id': string;
691
+ };
278
692
  /**
279
- * Type representing the parameters in a request.
693
+ * Represents the default error types for responses.
280
694
  */
281
- type ExtractedParamsObject<Path extends `/${string}`> = Record<ExtractParams<Path>, unknown>;
695
+ type ErrorContainer<Code extends number> = {
696
+ /** The error code */
697
+ code: Code;
698
+ /** The error message */
699
+ error: string;
700
+ };
282
701
  /**
283
- * Represents the path parameter methods.
702
+ * Represents a parsed response shape.
284
703
  */
285
- type PathParamMethod = 'get' | 'delete' | 'options' | 'head' | 'trace';
286
- /**
287
- * Represents the body parameter methods.
288
- */
289
- type HttpMethod = 'post' | 'patch' | 'put';
704
+ type ResponseShape<Params, Headers, Query, Body> = {
705
+ params: Params;
706
+ headers: Headers;
707
+ query: Query;
708
+ body: Body;
709
+ };
290
710
  /**
291
- * Represents all supported typed methods.
711
+ * Represents a path match.
292
712
  */
293
- type Method = PathParamMethod | HttpMethod | 'middleware';
713
+ type PathMatch<SuppliedPath extends `/${string}`, ActualPath extends `/${string}`> = ActualPath extends SuppliedPath ? SuppliedPath extends ActualPath ? SuppliedPath : never : never;
714
+
294
715
  /**
295
- * Interface representing a compiled schema for a response.
716
+ * Dictionary type for URL parameters.
296
717
  */
297
- type ResponseCompiledSchema = {
298
- headers?: unknown;
299
- responses: Record<number, unknown>;
300
- };
301
- type BasePathParamHttpContractDetailsIO<SV extends AnySchemaValidator, BodySchema extends Body<SV> | undefined = Body<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, QuerySchema extends QueryObject<SV> | undefined = QueryObject<SV>, ReqHeaders extends HeadersObject<SV> | undefined = HeadersObject<SV>, ResHeaders extends HeadersObject<SV> | undefined = HeadersObject<SV>> = {
302
- /** Optional body for the contract */
303
- readonly body?: BodySchema;
304
- /** Response schemas for the contract */
305
- readonly responses: ResponseSchemas;
306
- /** Optional request headers for the contract */
307
- readonly requestHeaders?: ReqHeaders;
308
- /** Optional response headers for the contract */
309
- readonly responseHeaders?: ResHeaders;
310
- /** Optional query schemas for the contract */
311
- readonly query?: QuerySchema;
312
- };
313
- type VersionedBasePathParamHttpContractDetailsIO<SV extends AnySchemaValidator, VersionedApi extends VersionSchema<SV, PathParamMethod>> = {
314
- readonly versions: VersionedApi;
718
+ type ParamsDictionary = {
719
+ [key: string]: string;
315
720
  };
316
- type BasePathParamHttpContractDetails<SV extends AnySchemaValidator, Name extends string = string, Path extends `/${string}` = `/${string}`, ParamsSchema extends ParamsObject<SV> = ParamsObject<SV>> = {
317
- /** Name of the contract */
318
- readonly name: StringWithoutSlash<Name>;
319
- /** Summary of the contract */
320
- readonly summary: string;
321
- /** Options for the contract */
322
- readonly options?: {
323
- /** Optional request validation for the contract */
324
- readonly requestValidation?: 'error' | 'warning' | 'none';
325
- /** Optional response validation for the contract */
326
- readonly responseValidation?: 'error' | 'warning' | 'none';
327
- /** Optional MCP details for the contract */
328
- readonly mcp?: boolean;
329
- /** Optional OpenAPI details for the contract */
330
- readonly openapi?: boolean;
331
- };
332
- } & (string | number | symbol extends ExtractedParamsObject<Path> ? {
333
- /** Optional parameters for the contract */
334
- readonly params?: ParamsSchema;
335
- } : {
336
- /** Required parameters for the contract */
337
- readonly params: {
338
- [K in keyof ExtractedParamsObject<Path>]: ParamsSchema[K];
339
- };
340
- });
341
721
  /**
342
- * Interface representing HTTP contract details for path parameters.
722
+ * Type representing an object with only string keys.
343
723
  *
344
724
  * @template SV - A type that extends AnySchemaValidator.
345
- * @template ParamsSchema - A type for parameter schemas, defaulting to ParamsObject.
346
- * @template ResponseSchemas - A type for response schemas, defaulting to ResponsesObject.
347
- * @template QuerySchema - A type for query schemas, defaulting to QueryObject.
348
725
  */
349
- type PathParamHttpContractDetails<SV extends AnySchemaValidator, Name extends string = string, Path extends `/${string}` = `/${string}`, ParamsSchema extends ParamsObject<SV> = ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, BodySchema extends Body<SV> = Body<SV>, QuerySchema extends QueryObject<SV> = QueryObject<SV>, ReqHeaders extends HeadersObject<SV> = HeadersObject<SV>, ResHeaders extends HeadersObject<SV> = HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method> = VersionSchema<SV, PathParamMethod>, BaseRequest = unknown, Auth extends SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest> = SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest>> = BasePathParamHttpContractDetails<SV, Name, Path, ParamsSchema> & ((BasePathParamHttpContractDetailsIO<SV, never, ResponseSchemas, QuerySchema, ReqHeaders, ResHeaders> & {
350
- readonly versions?: never;
351
- }) | (VersionedBasePathParamHttpContractDetailsIO<SV, VersionedApi> & {
352
- readonly query?: never;
353
- readonly requestHeaders?: never;
354
- readonly responseHeaders?: never;
355
- readonly responses?: never;
356
- })) & {
357
- /** Optional authentication details for the contract */
358
- readonly auth?: Auth;
359
- };
360
- type VersionedHttpContractDetailsIO<SV extends AnySchemaValidator, VersionedApi extends VersionSchema<SV, HttpMethod>> = {
361
- readonly versions: VersionedApi;
362
- };
726
+ type StringOnlyObject<SV extends AnySchemaValidator> = Omit<UnboxedObjectSchema<SV>, number | symbol>;
363
727
  /**
364
- * Interface representing HTTP contract details.
728
+ * Type representing an object with only number keys.
365
729
  *
366
730
  * @template SV - A type that extends AnySchemaValidator.
367
- * @template ParamsSchema - A type for parameter schemas, defaulting to ParamsObject.
368
- * @template ResponseSchemas - A type for response schemas, defaulting to ResponsesObject.
369
- * @template BodySchema - A type for the body schema, defaulting to Body.
370
- * @template QuerySchema - A type for query schemas, defaulting to QueryObject.
371
731
  */
372
- type HttpContractDetails<SV extends AnySchemaValidator, Name extends string = string, Path extends `/${string}` = `/${string}`, ParamsSchema extends ParamsObject<SV> = ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, BodySchema extends Body<SV> = Body<SV>, QuerySchema extends QueryObject<SV> = QueryObject<SV>, ReqHeaders extends HeadersObject<SV> = HeadersObject<SV>, ResHeaders extends HeadersObject<SV> = HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method> = VersionSchema<SV, HttpMethod>, BaseRequest = unknown, Auth extends SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest> = SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest>> = BasePathParamHttpContractDetails<SV, Name, Path, ParamsSchema> & ((BasePathParamHttpContractDetailsIO<SV, BodySchema, ResponseSchemas, QuerySchema, ReqHeaders, ResHeaders> & {
373
- readonly versions?: never;
374
- }) | (VersionedHttpContractDetailsIO<SV, VersionedApi> & {
375
- readonly query?: never;
376
- readonly requestHeaders?: never;
377
- readonly responseHeaders?: never;
378
- readonly body?: never;
379
- readonly responses?: never;
380
- })) & {
381
- readonly auth?: Auth;
382
- };
732
+ type NumberOnlyObject<SV extends AnySchemaValidator> = Omit<UnboxedObjectSchema<SV>, string | symbol>;
383
733
  /**
384
- * Interface representing HTTP contract details for middleware.
734
+ * Type representing the body object in a request.
385
735
  *
386
736
  * @template SV - A type that extends AnySchemaValidator.
387
- * @template ParamsSchema - A type for parameter schemas, defaulting to ParamsObject.
388
- * @template ResponseSchemas - A type for response schemas, defaulting to ResponsesObject.
389
- * @template QuerySchema - A type for query schemas, defaulting to QueryObject.
390
- * @template ReqHeaders - A type for request headers, defaulting to HeadersObject.
391
- * @template ResHeaders - A type for response headers, defaulting to HeadersObject.
392
737
  */
393
- type MiddlewareContractDetails<SV extends AnySchemaValidator, Name extends string = string, Path extends `/${string}` = `/${string}`, ParamsSchema extends ParamsObject<SV> = ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, BodySchema extends Body<SV> = Body<SV>, QuerySchema extends QueryObject<SV> = QueryObject<SV>, ReqHeaders extends HeadersObject<SV> = HeadersObject<SV>, ResHeaders extends HeadersObject<SV> = HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method> = VersionSchema<SV, 'middleware'>, BaseRequest = unknown, Auth extends SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest> = SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest>> = Omit<Partial<HttpContractDetails<SV, Name, Path, ParamsSchema, ResponseSchemas, BodySchema, QuerySchema, ReqHeaders, ResHeaders, VersionedApi, BaseRequest, Auth>>, 'responses'>;
394
- type VersionSchema<SV extends AnySchemaValidator, ContractMethod extends Method> = Record<string, BasePathParamHttpContractDetailsIO<SV, ContractMethod extends PathParamMethod ? never : Body<SV>, ResponsesObject<SV>, QueryObject<SV>, HeadersObject<SV>, HeadersObject<SV>>>;
738
+ type BodyObject<SV extends AnySchemaValidator> = StringOnlyObject<SV>;
395
739
  /**
396
- * Utility for different Contract Detail types
740
+ * Type representing the parameters object in a request.
741
+ *
742
+ * @template SV - A type that extends AnySchemaValidator.
397
743
  */
398
- type ContractDetails<SV extends AnySchemaValidator, Name extends string, ContractMethod extends Method, Path extends `/${string}`, ParamsSchema extends ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV>, BodySchema extends Body<SV>, QuerySchema extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, VersionedApi extends VersionSchema<SV, ContractMethod>, BaseRequest, Auth extends SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest>> = ContractMethod extends PathParamMethod ? PathParamHttpContractDetails<SV, Name, Path, ParamsSchema, ResponseSchemas, BodySchema, QuerySchema, ReqHeaders, ResHeaders, VersionedApi, BaseRequest, Auth> : ContractMethod extends HttpMethod ? HttpContractDetails<SV, Name, Path, ParamsSchema, ResponseSchemas, BodySchema, QuerySchema, ReqHeaders, ResHeaders, VersionedApi, BaseRequest, Auth> : ContractMethod extends 'middleware' ? MiddlewareContractDetails<SV, Name, Path, ParamsSchema, ResponseSchemas, BodySchema, QuerySchema, ReqHeaders, ResHeaders, VersionedApi, BaseRequest, Auth> : never;
744
+ type ParamsObject<SV extends AnySchemaValidator> = StringOnlyObject<SV>;
399
745
  /**
400
- * Resolves the session object type to use for authentication.
746
+ * Type representing the query object in a request.
401
747
  *
402
- * If `AuthSession` is provided and extends `SessionObject<SV>`, it is used as the session type.
403
- * Otherwise, the `FallbackSession` type is used.
748
+ * @template SV - A type that extends AnySchemaValidator.
749
+ */
750
+ type QueryObject<SV extends AnySchemaValidator> = StringOnlyObject<SV>;
751
+ /**
752
+ * Type representing the headers object in a request.
404
753
  *
405
- * @template SV - The schema validator type.
406
- * @template AuthSession - The session object type provided by the authentication method, or undefined.
407
- * @template FallbackSession - The fallback session object type to use if `AuthSession` is not provided.
754
+ * @template SV - A type that extends AnySchemaValidator.
408
755
  */
409
- type ResolvedSessionObject<SV extends AnySchemaValidator, AuthSession extends SessionObject<SV> | undefined, FallbackSession extends SessionObject<SV>> = AuthSession extends {
410
- readonly sessionSchema?: infer ResolvedSessionSchema | undefined;
411
- } | undefined ? ResolvedSessionSchema extends SessionObject<SV> ? ResolvedSessionSchema : FallbackSession : FallbackSession;
412
-
413
- type DocsConfiguration = ({
414
- type: 'scalar';
415
- } & Partial<Omit<ApiReferenceConfiguration, 'spec'>>) | {
416
- type: 'swagger';
756
+ type HeadersObject<SV extends AnySchemaValidator> = StringOnlyObject<SV>;
757
+ type RawTypedResponseBody<SV extends AnySchemaValidator> = TextBody<SV> | JsonBody<SV> | FileBody<SV> | ServerSentEventBody<SV> | UnknownResponseBody<SV>;
758
+ type ExclusiveResponseBodyBase<SV extends AnySchemaValidator> = {
759
+ [K in keyof UnionToIntersection<RawTypedResponseBody<SV>>]?: undefined;
417
760
  };
418
-
761
+ type ExclusiveSchemaCatchall<SV extends AnySchemaValidator> = {
762
+ [K in keyof SV['_SchemaCatchall'] as string extends K ? never : number extends K ? never : symbol extends K ? never : K]?: undefined;
763
+ };
764
+ type TypedResponseBody<SV extends AnySchemaValidator> = {
765
+ [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveResponseBodyBase<SV>)]?: K extends keyof TextBody<SV> ? TextBody<SV>[K] : undefined;
766
+ } | {
767
+ [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveResponseBodyBase<SV>)]?: K extends keyof JsonBody<SV> ? JsonBody<SV>[K] : undefined;
768
+ } | {
769
+ [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveResponseBodyBase<SV>)]?: K extends keyof FileBody<SV> ? FileBody<SV>[K] : undefined;
770
+ } | {
771
+ [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveResponseBodyBase<SV>)]?: K extends keyof ServerSentEventBody<SV> ? ServerSentEventBody<SV>[K] : undefined;
772
+ } | {
773
+ [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveResponseBodyBase<SV>)]?: K extends keyof UnknownResponseBody<SV> ? UnknownResponseBody<SV>[K] : undefined;
774
+ };
775
+ type ResponseBody<SV extends AnySchemaValidator> = TypedResponseBody<SV> | (ExclusiveResponseBodyBase<SV> & SV['_ValidSchemaObject']) | (ExclusiveResponseBodyBase<SV> & UnboxedObjectSchema<SV>) | (ExclusiveResponseBodyBase<SV> & SV['string']) | (ExclusiveResponseBodyBase<SV> & SV['number']) | (ExclusiveResponseBodyBase<SV> & SV['boolean']) | (ExclusiveResponseBodyBase<SV> & SV['date']) | (ExclusiveResponseBodyBase<SV> & SV['array']) | (ExclusiveResponseBodyBase<SV> & SV['file']);
419
776
  /**
420
- * Options for global authentication in Express-like applications.
421
- *
422
- * @template SV - The schema validator type.
423
- * @template SessionSchema - The session schema type.
777
+ * Type representing the responses object in a request.
424
778
  *
425
- * Can be `false` to disable authentication, or an object specifying session schema and
426
- * functions to surface scopes, permissions, and roles from the JWT/session.
779
+ * @template SV - A type that extends AnySchemaValidator.
427
780
  */
428
- type ExpressLikeGlobalAuthOptions<SV extends AnySchemaValidator, SessionSchema extends Record<string, unknown>> = false | {
429
- /**
430
- * Optional session schema for the authentication context.
431
- */
432
- sessionSchema?: SessionSchema;
433
- /**
434
- * Optional array describing the scope hierarchy for authorization.
435
- */
436
- scopeHeirarchy?: string[];
437
- /**
438
- * Function to extract a set of scopes from the JWT payload and request.
439
- */
440
- surfaceScopes?: (payload: JWTPayload & SessionSchema, req?: ForklaunchRequest<SV, Record<string, string>, Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, string, SessionSchema>) => Set<string> | Promise<Set<string>>;
441
- /**
442
- * Function to extract a set of permissions from the JWT payload and request.
443
- */
444
- surfacePermissions?: (payload: JWTPayload & SessionSchema, req?: ForklaunchRequest<SV, Record<string, string>, Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, string, SessionSchema>) => Set<string> | Promise<Set<string>>;
445
- /**
446
- * Function to extract a set of roles from the JWT payload and request.
447
- */
448
- surfaceRoles?: (payload: JWTPayload & SessionSchema, req?: ForklaunchRequest<SV, Record<string, string>, Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, string, SessionSchema>) => Set<string> | Promise<Set<string>>;
781
+ type ResponsesObject<SV extends AnySchemaValidator> = {
782
+ [K: number]: ResponseBody<SV>;
783
+ };
784
+ type JsonBody<SV extends AnySchemaValidator> = {
785
+ contentType?: 'application/json' | string;
786
+ json: BodyObject<SV> | SV['_ValidSchemaObject'] | SV['_SchemaCatchall'];
449
787
  };
450
788
  /**
451
- * Schema-aware version of ExpressLikeGlobalAuthOptions.
789
+ * Type representing the body in a request.
452
790
  *
453
- * @template SV - The schema validator type.
454
- * @template SessionSchema - The session object type.
791
+ * @template SV - A type that extends AnySchemaValidator.
455
792
  */
456
- type ExpressLikeSchemaGlobalAuthOptions<SV extends AnySchemaValidator, SessionSchema extends SessionObject<SV>> = ExpressLikeGlobalAuthOptions<SV, MapSessionSchema<SV, SessionSchema>>;
793
+ type TextBody<SV extends AnySchemaValidator> = {
794
+ contentType?: 'application/xml' | 'text/plain' | 'text/html' | 'text/css' | 'text/javascript' | 'text/csv' | 'text/markdown' | 'text/xml' | 'text/rtf' | 'text/x-yaml' | 'text/yaml' | string;
795
+ text: SV['string'];
796
+ };
797
+ type FileBody<SV extends AnySchemaValidator> = {
798
+ contentType?: 'application/octet-stream' | 'application/pdf' | 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/msword' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/zip' | 'image/jpeg' | 'image/png' | 'image/gif' | 'audio/mpeg' | 'audio/wav' | 'video/mp4' | string;
799
+ file: SV['file'];
800
+ };
457
801
  /**
458
- * Options for configuring an Express-like router.
802
+ * Type representing the body in a request.
459
803
  *
460
- * @template SV - The schema validator type.
461
- * @template SessionSchema - The session object type.
804
+ * @template SV - A type that extends AnySchemaValidator.
462
805
  */
463
- type ExpressLikeRouterOptions<SV extends AnySchemaValidator, SessionSchema extends SessionObject<SV>> = {
464
- /**
465
- * Authentication options for the router.
466
- */
467
- auth?: ExpressLikeSchemaGlobalAuthOptions<SV, SessionSchema>;
468
- /**
469
- * Validation options for request and response.
470
- * Can be `false` to disable validation, or an object to configure request/response validation levels.
471
- */
472
- validation?: false | {
473
- /**
474
- * Request validation mode: 'none', 'warning', or 'error'.
475
- */
476
- request?: 'none' | 'warning' | 'error';
477
- /**
478
- * Response validation mode: 'none', 'warning', or 'error'.
479
- */
480
- response?: 'none' | 'warning' | 'error';
481
- };
482
- /**
483
- * OpenAPI documentation options.
484
- */
485
- openapi?: boolean;
486
- /**
487
- * MCP options.
488
- */
489
- mcp?: boolean;
806
+ type MultipartForm<SV extends AnySchemaValidator> = {
807
+ contentType?: 'multipart/form-data' | 'multipart/mixed' | 'multipart/alternative' | 'multipart/related' | 'multipart/signed' | 'multipart/encrypted' | string;
808
+ multipartForm: BodyObject<SV>;
490
809
  };
491
810
  /**
492
- * Options for configuring an Express-like application.
811
+ * Type representing the body in a request.
493
812
  *
494
- * @template SV - The schema validator type.
495
- * @template SessionSchema - The session object type.
813
+ * @template SV - A type that extends AnySchemaValidator.
496
814
  */
497
- type ExpressLikeApplicationOptions<SV extends AnySchemaValidator, SessionSchema extends SessionObject<SV>> = Omit<ExpressLikeRouterOptions<SV, SessionSchema>, 'openapi' | 'mcp'> & {
498
- /**
499
- * Documentation configuration.
500
- */
501
- docs?: DocsConfiguration;
502
- /**
503
- * Hosting/server options.
504
- */
505
- hosting?: {
506
- /**
507
- * SSL configuration or boolean to enable/disable SSL.
508
- */
509
- ssl?: {
510
- /**
511
- * SSL certificate as a string.
512
- */
513
- certFile: string;
514
- /**
515
- * SSL key as a string.
516
- */
517
- keyFile: string;
518
- /**
519
- * SSL CA as a string.
520
- */
521
- caFile: string;
522
- };
523
- /**
524
- * Number of worker processes to spawn.
525
- */
526
- workerCount?: number;
527
- /**
528
- * Routing strategy to use.
529
- */
530
- routingStrategy?: 'round-robin' | 'sticky' | 'random';
531
- };
532
- /**
533
- * FastMCP (management/control plane) options.
534
- * Can be `false` to disable, or an object to configure.
535
- */
536
- mcp?: false | {
537
- /**
538
- * Port for the MCP server.
539
- */
540
- port?: number;
541
- /**
542
- * Endpoint for the MCP server.
543
- */
544
- path?: `/${string}`;
545
- /**
546
- * Additional options for FastMCP.
547
- */
548
- options?: ConstructorParameters<typeof FastMCP>[0];
549
- /**
550
- * Optional authentication callback for validating MCP requests.
551
- * Called by FastMCP for each request to verify the session token.
552
- * Return user info object if authenticated, undefined otherwise.
553
- * Example: { email: 'user@example.com', name: 'User' }
554
- */
555
- authenticate?: (request: http.IncomingMessage) => Promise<Record<string, unknown> | undefined>;
556
- /**
557
- * Additional tools to register with the MCP server.
558
- */
559
- additionalTools?: (mcpServer: FastMCP) => void;
560
- /**
561
- * Content type mapping for the MCP server.
562
- */
563
- contentTypeMapping?: Record<string, string>;
564
- /**
565
- * Version of the MCP server.
566
- */
567
- version?: `${number}.${number}.${number}`;
568
- };
569
- /**
570
- * OpenAPI documentation options.
571
- * Can be `false` to disable, or an object to configure.
572
- */
573
- openapi?: false | {
574
- /**
575
- * Path to serve the OpenAPI docs (e.g., '/openapi').
576
- */
577
- path?: `/${string}`;
578
- /**
579
- * Title for the OpenAPI documentation.
580
- */
581
- title?: string;
582
- /**
583
- * Description for the OpenAPI documentation.
584
- */
585
- description?: string;
586
- /**
587
- * Contact information for the API.
588
- */
589
- contact?: {
590
- /**
591
- * Contact name.
592
- */
593
- name?: string;
594
- /**
595
- * Contact email.
596
- */
597
- email?: string;
598
- };
599
- /**
600
- * Whether to enable discrete versioning for OpenAPI docs.
601
- */
602
- discreteVersions?: boolean;
815
+ type UrlEncodedForm<SV extends AnySchemaValidator> = {
816
+ contentType?: 'application/x-www-form-urlencoded' | 'application/x-url-encoded' | 'application/x-www-url-encoded' | 'application/x-urlencode' | string;
817
+ urlEncodedForm: BodyObject<SV>;
818
+ };
819
+ type ServerSentEventBody<SV extends AnySchemaValidator> = {
820
+ contentType?: 'text/event-stream' | string;
821
+ event: {
822
+ id: SV['string'];
823
+ data: SV['string'] | BodyObject<SV>;
603
824
  };
604
- /**
605
- * CORS configuration options.
606
- */
607
- cors?: CorsOptions;
608
825
  };
609
-
610
- /**
611
- * Interface representing the context of a request.
612
- */
613
- interface RequestContext {
614
- /** Correlation ID for tracking requests */
615
- correlationId: string;
616
- /** Optional idempotency key for ensuring idempotent requests */
617
- idempotencyKey?: string;
618
- /** Active OpenTelemetry Span */
619
- span?: Span;
620
- }
621
- interface ForklaunchBaseRequest<P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>> {
622
- /** Request parameters */
623
- params: P;
624
- /** Request headers */
625
- headers: ReqHeaders;
626
- /** Request body */
627
- body: ReqBody;
628
- /** Request query */
629
- query: ReqQuery;
630
- /** Method */
631
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'CONNECT' | 'TRACE';
632
- /** Request path */
633
- path: string;
634
- /** Original path */
635
- originalPath: string;
636
- /** OpenTelemetry Collector */
637
- openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
638
- }
639
- /**
640
- * Interface representing a Forklaunch request.
641
- *
642
- * @template SV - A type that extends AnySchemaValidator.
643
- * @template P - A type for request parameters, defaulting to ParamsDictionary.
644
- * @template ReqBody - A type for the request body, defaulting to unknown.
645
- * @template ReqQuery - A type for the request query, defaulting to ParsedQs.
646
- * @template Headers - A type for the request headers, defaulting to IncomingHttpHeaders.
647
- */
648
- interface ForklaunchRequest<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends Record<string, unknown>, ReqHeaders extends Record<string, unknown>, Version extends string, SessionSchema extends Record<string, unknown>> {
649
- /** Context of the request */
650
- context: Prettify<RequestContext>;
651
- /** API Version of the request */
652
- version: Version;
653
- /** Request parameters */
654
- params: P;
655
- /** Request headers */
656
- headers: ReqHeaders;
657
- /** Request body */
658
- body: ReqBody;
659
- /** Request query */
660
- query: ReqQuery;
661
- /** Contract details for the request */
662
- contractDetails: PathParamHttpContractDetails<SV> | HttpContractDetails<SV>;
663
- /** Schema validator */
664
- schemaValidator: SV;
665
- /** Method */
666
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'CONNECT' | 'TRACE';
667
- /** Request path */
668
- path: string;
669
- /** Request schema, compiled */
670
- requestSchema: unknown | Record<string, unknown>;
671
- /** Original path */
672
- originalPath: string;
673
- /** OpenTelemetry Collector */
674
- openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
675
- /** Session */
676
- session: JWTPayload & SessionSchema;
677
- /** Parsed versions */
678
- _parsedVersions: string[] | number;
679
- /** Raw body before schema validation (for HMAC verification) */
680
- _rawBody?: unknown;
681
- /** Global options */
682
- _globalOptions: () => ExpressLikeRouterOptions<SV, SessionSchema> | undefined;
683
- }
684
- /**
685
- * Represents the types of data that can be sent in a response.
686
- */
687
- type ForklaunchSendableData = Record<string, unknown> | string | Buffer | ArrayBuffer | NodeJS.ReadableStream | null | undefined;
688
- /**
689
- * Interface representing a Forklaunch response status.
690
- * @template ResBody - A type for the response body.
691
- */
692
- interface ForklaunchStatusResponse<ResBody> {
693
- /**
694
- * Sends the response.
695
- * @param {ResBodyMap} [body] - The response body.
696
- * @param {boolean} [close_connection] - Whether to close the connection.
697
- * @returns {T} - The sent response.
698
- */
699
- send: {
700
- (body?: ResBody extends AsyncGenerator<unknown> ? never : ResBody extends Blob ? Blob | File | Buffer | ArrayBuffer | NodeJS.ReadableStream : ResBody | null, close_connection?: boolean): boolean;
701
- <U>(body?: ResBody extends AsyncGenerator<unknown> ? never : ResBody extends Blob ? Blob | File | Buffer | ArrayBuffer | NodeJS.ReadableStream : ResBody | null, close_connection?: boolean): U;
826
+ type UnknownBody<SV extends AnySchemaValidator> = {
827
+ contentType?: string;
828
+ schema: BodyObject<SV> | SV['_ValidSchemaObject'] | SV['_SchemaCatchall'];
829
+ };
830
+ type UnknownResponseBody<SV extends AnySchemaValidator> = {
831
+ contentType?: string;
832
+ schema: BodyObject<SV> | SV['_ValidSchemaObject'] | SV['_SchemaCatchall'];
833
+ };
834
+ type ExclusiveRequestBodyBase<SV extends AnySchemaValidator> = {
835
+ [K in keyof UnionToIntersection<TypedBody<SV>>]?: undefined;
836
+ };
837
+ type TypedRequestBody<SV extends AnySchemaValidator> = {
838
+ [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof TextBody<SV> ? TextBody<SV>[K] : undefined;
839
+ } | {
840
+ [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof JsonBody<SV> ? JsonBody<SV>[K] : undefined;
841
+ } | {
842
+ [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof FileBody<SV> ? FileBody<SV>[K] : undefined;
843
+ } | {
844
+ [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof MultipartForm<SV> ? MultipartForm<SV>[K] : undefined;
845
+ } | {
846
+ [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof UrlEncodedForm<SV> ? UrlEncodedForm<SV>[K] : undefined;
847
+ } | {
848
+ [K in keyof (ExclusiveSchemaCatchall<SV> & ExclusiveRequestBodyBase<SV>)]?: K extends keyof UnknownBody<SV> ? UnknownBody<SV>[K] : undefined;
849
+ };
850
+ type TypedBody<SV extends AnySchemaValidator> = JsonBody<SV> | TextBody<SV> | FileBody<SV> | MultipartForm<SV> | UrlEncodedForm<SV> | UnknownBody<SV>;
851
+ type Body<SV extends AnySchemaValidator> = TypedRequestBody<SV> | (ExclusiveRequestBodyBase<SV> & SV['_ValidSchemaObject']) | (ExclusiveRequestBodyBase<SV> & UnboxedObjectSchema<SV>) | (ExclusiveRequestBodyBase<SV> & SV['string']) | (ExclusiveRequestBodyBase<SV> & SV['number']) | (ExclusiveRequestBodyBase<SV> & SV['boolean']) | (ExclusiveRequestBodyBase<SV> & SV['date']) | (ExclusiveRequestBodyBase<SV> & SV['array']) | (ExclusiveRequestBodyBase<SV> & SV['file']) | (ExclusiveRequestBodyBase<SV> & SV['any']) | (ExclusiveRequestBodyBase<SV> & SV['unknown']) | (ExclusiveRequestBodyBase<SV> & SV['binary']) | (ExclusiveRequestBodyBase<SV> & (SV['type'] extends TypeSafeFunction ? ReturnType<SV['type']> : never));
852
+ type SessionObject<SV extends AnySchemaValidator> = StringOnlyObject<SV>;
853
+ type BasicAuthMethods = {
854
+ readonly basic: {
855
+ readonly login: (username: string, password: string) => boolean;
702
856
  };
703
- /**
704
- * Sends a JSON response.
705
- * @param {ResBodyMap} [body] - The response body.
706
- * @returns {boolean|T} - The JSON response.
707
- */
708
- json: {
709
- (body: ResBody extends string | AsyncGenerator<unknown> ? never : ResBody | null): boolean;
710
- <U>(body: ResBody extends string | AsyncGenerator<unknown> ? never : ResBody | null): U;
857
+ readonly jwt?: never;
858
+ readonly hmac?: never;
859
+ };
860
+ type JwtAuthMethods = {
861
+ jwt: {
862
+ readonly jwksPublicKey: JWK;
863
+ } | {
864
+ readonly jwksPublicKeyUrl: string;
865
+ } | {
866
+ readonly signatureKey: string;
711
867
  };
712
- /**
713
- * Sends a JSONP response.
714
- * @param {ResBodyMap} [body] - The response body.
715
- * @returns {boolean|T} - The JSONP response.
716
- */
717
- jsonp: {
718
- (body: ResBody extends string | AsyncGenerator<unknown> ? never : ResBody | null): boolean;
719
- <U>(body: ResBody extends string | AsyncGenerator<unknown> ? never : ResBody | null): U;
868
+ readonly basic?: never;
869
+ readonly hmac?: never;
870
+ };
871
+ type HmacMethods = {
872
+ readonly hmac: {
873
+ readonly secretKeys: Record<string, string>;
720
874
  };
721
- /**
722
- * Sends a Server-Sent Event (SSE) response.
723
- * @param {ResBodyMap} [body] - The response body.
724
- * @param {number} interval - The interval between events.
725
- */
726
- sseEmitter: (generator: () => AsyncGenerator<ResBody extends AsyncGenerator<infer T> ? T : never, void, unknown>) => void;
727
- }
728
- type ToNumber<T extends string | number | symbol> = T extends number ? T : T extends `${infer N extends number}` ? N : never;
875
+ readonly sessionSchema?: never;
876
+ readonly basic?: never;
877
+ readonly jwt?: never;
878
+ };
879
+ type TokenOptions = {
880
+ readonly tokenPrefix?: string;
881
+ readonly headerName?: string;
882
+ };
883
+ type DecodeResource = (token: string) => JWTPayload | Promise<JWTPayload>;
884
+ type AuthMethodsBase = TokenOptions & (HmacMethods | ({
885
+ readonly decodeResource?: DecodeResource;
886
+ } & (PermissionSet | RoleSet) & (BasicAuthMethods | JwtAuthMethods)));
887
+ type PermissionSet = {
888
+ readonly allowedPermissions: Set<string>;
889
+ } | {
890
+ readonly forbiddenPermissions: Set<string>;
891
+ };
892
+ type RoleSet = {
893
+ readonly allowedRoles: Set<string>;
894
+ } | {
895
+ readonly forbiddenRoles: Set<string>;
896
+ };
729
897
  /**
730
- * Interface representing a Forklaunch response.
731
- *
732
- * @template ResBodyMap - A type for the response body, defaulting to common status code responses.
733
- * @template StatusCode - A type for the status code, defaulting to number.
898
+ * Type representing the authentication methods.
734
899
  */
735
- interface ForklaunchResponse<BaseResponse, ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, unknown>, LocalsObj extends Record<string, unknown>, Version extends string> {
736
- /** Data of the response body */
737
- bodyData: unknown;
738
- /** Status code of the response */
739
- statusCode: number;
740
- /** Whether the response is finished */
741
- headersSent: boolean;
742
- /**
743
- * Gets the headers of the response.
744
- * @returns {Omit<ResHeaders, keyof ForklaunchResHeaders> & ForklaunchResHeaders} - The headers of the response.
745
- */
746
- getHeaders: () => Omit<ResHeaders, keyof ForklaunchResHeaders> & ForklaunchResHeaders;
747
- /**
748
- * Gets a header for the response.
749
- * @param {string} key - The header key.
750
- * @returns {string | string[] | undefined} The header value.
751
- */
752
- getHeader: (key: string) => string | string[] | undefined;
753
- /**
754
- * Sets a header for the response.
755
- * @param {string} key - The header key.
756
- * @param {string} value - The header value.
757
- */
758
- setHeader: {
759
- <K extends keyof (ResHeaders & ForklaunchResHeaders)>(key: K, value: K extends keyof ForklaunchResHeaders ? ForklaunchResHeaders[K] : ResHeaders[K]): void;
760
- <K extends keyof (ResHeaders & ForklaunchResHeaders)>(key: K, value: K extends keyof ForklaunchResHeaders ? ForklaunchResHeaders[K] : ResHeaders[K]): BaseResponse;
761
- };
762
- /**
763
- * Adds an event listener to the response.
764
- * @param {string} event - The event to listen for.
765
- * @param {Function} listener - The listener function.
766
- */
767
- on(event: 'close', listener: () => void): BaseResponse & this;
768
- on(event: 'drain', listener: () => void): BaseResponse & this;
769
- on(event: 'error', listener: (err: Error) => void): BaseResponse & this;
770
- on(event: 'finish', listener: () => void): BaseResponse & this;
771
- on(event: 'pipe', listener: (src: Readable) => void): BaseResponse & this;
772
- on(event: 'unpipe', listener: (src: Readable) => void): BaseResponse & this;
773
- on(event: string | symbol, listener: (...args: unknown[]) => void): BaseResponse & this;
774
- /**
775
- * Sets the status of the response.
776
- * @param {U} code - The status code.
777
- * @param {string} [message] - Optional message.
778
- * @returns {ForklaunchResponse<(ResBodyMap)[U], ResHeaders, U, LocalsObj>} - The response with the given status.
779
- */
780
- status: {
781
- <U extends ToNumber<keyof (ResBodyMap & ForklaunchResErrors)>>(code: U): Omit<BaseResponse, keyof ForklaunchStatusResponse<(Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)[U]>> & ForklaunchStatusResponse<(Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)[U]>;
782
- <U extends ToNumber<keyof (ResBodyMap & ForklaunchResErrors)>>(code: U, message?: string): Omit<BaseResponse, keyof ForklaunchStatusResponse<(Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)[U]>> & ForklaunchStatusResponse<(Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)[U]>;
783
- };
784
- /**
785
- * Ends the response.
786
- * @param {string} [data] - Optional data to send.
787
- */
788
- end: {
789
- (data?: string): void;
790
- (cb?: (() => void) | undefined): BaseResponse;
791
- };
792
- /**
793
- * Sets the content type of the response.
794
- * @param {string} type - The content type.
795
- */
796
- type: {
797
- (type: string): void;
798
- (type: string): BaseResponse;
799
- };
800
- /** Local variables */
801
- locals: LocalsObj;
802
- /** Cors */
803
- cors: boolean;
804
- /** Response schema, compiled */
805
- responseSchemas: ResponseCompiledSchema | Record<string, ResponseCompiledSchema>;
806
- /** Whether the metric has been recorded */
807
- metricRecorded: boolean;
808
- /** Whether the response has been sent */
809
- sent: boolean;
810
- /** Versioned responses */
811
- version: Version;
812
- }
900
+ type SchemaAuthMethods<SV extends AnySchemaValidator, ParamsSchema extends ParamsObject<SV>, ReqBody extends Body<SV>, QuerySchema extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method>, BaseRequest> = AuthMethodsBase & {
901
+ readonly sessionSchema?: SessionObject<SV>;
902
+ readonly requiredScope?: string;
903
+ readonly scopeHeirarchy?: string[];
904
+ readonly surfaceScopes?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionObject<SV>, BaseRequest>;
905
+ } & ({
906
+ readonly surfacePermissions?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionObject<SV>, BaseRequest>;
907
+ } | {
908
+ readonly surfaceRoles?: ExpressLikeSchemaAuthMapper<SV, ParamsSchema, ReqBody, QuerySchema, ReqHeaders, VersionedApi, SessionObject<SV>, BaseRequest>;
909
+ });
910
+ type AuthMethods<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends Record<string, unknown>, ReqHeaders extends Record<string, string>, VersionedReqs extends VersionedRequests, BaseRequest> = AuthMethodsBase & {
911
+ readonly sessionSchema?: SessionObject<SV>;
912
+ readonly requiredScope?: string;
913
+ readonly scopeHeirarchy?: string[];
914
+ readonly surfaceScopes?: ExpressLikeAuthMapper<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, SessionObject<SV>, BaseRequest>;
915
+ } & (({
916
+ readonly surfacePermissions?: ExpressLikeAuthMapper<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, SessionObject<SV>, BaseRequest>;
917
+ } & PermissionSet) | ({
918
+ readonly surfaceRoles?: ExpressLikeAuthMapper<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, SessionObject<SV>, BaseRequest>;
919
+ } & RoleSet));
813
920
  /**
814
- * Type representing the next function in a middleware.
815
- * @param {unknown} [err] - Optional error parameter.
921
+ * Type representing a mapped schema.
922
+ *s ParamsDictionary,
923
+ // ReqBody extends Record<string, unknown>,
924
+ //
925
+ * @template SV - A type that extends AnySchemaValidator.
926
+ * @template T - A type that extends IdiomaticSchema or a valid schema object.
816
927
  */
817
- type ForklaunchNextFunction = (err?: unknown) => void;
818
- type VersionedRequests = Record<string, {
819
- requestHeaders?: Record<string, unknown>;
820
- body?: Record<string, unknown>;
821
- query?: Record<string, unknown>;
822
- }>;
823
- type ResolvedForklaunchRequestBase<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends Record<string, unknown>, ReqHeaders extends Record<string, unknown>, Version extends string, SessionSchema extends Record<string, unknown>, BaseRequest> = unknown extends BaseRequest ? ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Version, SessionSchema> : Omit<BaseRequest, keyof ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Version, SessionSchema>> & ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Version, SessionSchema>;
928
+ type MapSchema<SV extends AnySchemaValidator, T extends IdiomaticSchema<SV> | SV['_ValidSchemaObject']> = Schema<T, SV> extends infer U ? (T extends U ? unknown : U) : never;
824
929
  /**
825
- * Type representing the resolved forklaunch request from a base request type.
826
- * @template SV - A type that extends AnySchemaValidator.
827
- * @template P - A type for request parameters, defaulting to ParamsDictionary.
828
- * @template ReqBody - A type for the request body, defaulting to Record<string, unknown>.
829
- * @template ReqQuery - A type for the request query, defaulting to ParsedQs.
830
- * @template ReqHeaders - A type for the request headers, defaulting to Record<string, unknown>.
831
- * @template BaseRequest - A type for the base request.
930
+ * Type representing the parameters in a request.
832
931
  */
833
- type ResolvedForklaunchRequest<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends Record<string, unknown>, ReqHeaders extends Record<string, string>, VersionedReqs extends VersionedRequests, SessionSchema extends Record<string, unknown>, BaseRequest> = VersionedRequests extends VersionedReqs ? ResolvedForklaunchRequestBase<SV, P, ReqBody, ReqQuery, ReqHeaders, never, SessionSchema, BaseRequest> : {
834
- [K in keyof VersionedReqs]: ResolvedForklaunchRequestBase<SV, P, VersionedReqs[K]['body'] extends Record<string, unknown> ? VersionedReqs[K]['body'] : Record<string, unknown>, VersionedReqs[K]['query'] extends Record<string, unknown> ? VersionedReqs[K]['query'] : ParsedQs, VersionedReqs[K]['requestHeaders'] extends Record<string, unknown> ? VersionedReqs[K]['requestHeaders'] : Record<string, string>, K extends string ? K : never, SessionSchema, BaseRequest>;
835
- }[keyof VersionedReqs];
836
- type ResolvedForklaunchAuthRequest<P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>, BaseRequest> = unknown extends BaseRequest ? ForklaunchBaseRequest<P, ReqBody, ReqQuery, ReqHeaders> : {
837
- [key in keyof BaseRequest]: key extends keyof ForklaunchBaseRequest<P, ReqBody, ReqQuery, ReqHeaders> ? ForklaunchBaseRequest<P, ReqBody, ReqQuery, ReqHeaders>[key] : key extends keyof BaseRequest ? BaseRequest[key] : never;
838
- };
839
- type VersionedResponses = Record<string, {
840
- responseHeaders?: Record<string, unknown>;
841
- responses: Record<number, unknown>;
842
- }>;
843
- type ResolvedForklaunchResponseBase<ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, unknown>, LocalsObj extends Record<string, unknown>, Version extends string, BaseResponse> = unknown extends BaseResponse ? ForklaunchResponse<BaseResponse, ResBodyMap, ResHeaders, LocalsObj, Version> : (string extends Version ? unknown : {
844
- version?: Version;
845
- }) & {
846
- [K in keyof BaseResponse | keyof ForklaunchResponse<BaseResponse, ResBodyMap, ResHeaders, LocalsObj, Version>]: K extends keyof ForklaunchResponse<BaseResponse, ResBodyMap, ResHeaders, LocalsObj, Version> ? ForklaunchResponse<BaseResponse, ResBodyMap, ResHeaders, LocalsObj, Version>[K] : K extends keyof BaseResponse ? BaseResponse[K] : never;
847
- };
848
- type ResolvedForklaunchResponse<ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown>, VersionedResps extends VersionedResponses, BaseResponse> = VersionedResponses extends VersionedResps ? ResolvedForklaunchResponseBase<ResBodyMap, ResHeaders, LocalsObj, never, BaseResponse> : {
849
- [K in keyof VersionedResps]: ResolvedForklaunchResponseBase<VersionedResps[K]['responses'], VersionedResps[K]['responseHeaders'] extends Record<string, unknown> ? VersionedResps[K]['responseHeaders'] : Record<string, string>, LocalsObj, K extends string ? K : never, BaseResponse>;
850
- }[keyof VersionedResps];
932
+ type ExtractParams<Path extends `/${string}`> = Path extends `${string}/:${infer Param}/${infer Rest}` ? Param | ExtractParams<`/${Rest}`> : Path extends `${string}/:${infer Param}` ? Param : never;
851
933
  /**
852
- * Represents a middleware handler with schema validation.
853
- *
854
- * @template SV - A type that extends AnySchemaValidator.
855
- * @template P - A type for request parameters, defaulting to ParamsDictionary.
856
- * @template ResBodyMap - A type for the response body, defaulting to unknown.
857
- * @template ReqBody - A type for the request body, defaulting to unknown.
858
- * @template ReqQuery - A type for the request query, defaulting to ParsedQs.
859
- * @template LocalsObj - A type for local variables, defaulting to an empty object.
860
- * @template StatusCode - A type for the status code, defaulting to number.
934
+ * Type representing the parameters in a request.
861
935
  */
862
- interface ExpressLikeHandler<SV extends AnySchemaValidator, P extends ParamsDictionary, ResBodyMap extends Record<number, unknown>, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>, ResHeaders extends Record<string, string>, LocalsObj extends Record<string, unknown>, VersionedReqs extends VersionedRequests, VersionedResps extends VersionedResponses, SessionSchema extends Record<string, unknown>, BaseRequest, BaseResponse, NextFunction> {
863
- (req: ResolvedForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, SessionSchema, BaseRequest>, res: ResolvedForklaunchResponse<ResBodyMap, ResHeaders, LocalsObj, VersionedResps, BaseResponse>, next: NextFunction): unknown;
864
- }
865
- type MapParamsSchema<SV extends AnySchemaValidator, P extends ParamsObject<SV>> = MapSchema<SV, P> extends infer Params ? unknown extends Params ? ParamsDictionary : Params : ParamsDictionary;
866
- type ExtractContentType<SV extends AnySchemaValidator, T extends ResponseBody<SV> | unknown> = T extends {
867
- contentType: string;
868
- } ? T['contentType'] : T extends JsonBody<SV> ? 'application/json' : T extends TextBody<SV> ? 'text/plain' : T extends FileBody<SV> ? 'application/octet-stream' : T extends ServerSentEventBody<SV> ? 'text/event-stream' : T extends UnknownResponseBody<SV> ? 'application/json' : T extends SV['file'] ? 'application/octet-stream' : 'text/plain';
869
- type ExtractResponseBody<SV extends AnySchemaValidator, T extends ResponseBody<SV> | unknown> = T extends JsonBody<SV> ? MapSchema<SV, T['json']> : T extends TextBody<SV> ? MapSchema<SV, T['text']> : T extends FileBody<SV> ? File | Blob : T extends ServerSentEventBody<SV> ? AsyncGenerator<MapSchema<SV, T['event']>> : T extends UnknownResponseBody<SV> ? MapSchema<SV, T['schema']> : MapSchema<SV, T>;
870
- type MapResBodyMapSchema<SV extends AnySchemaValidator, ResBodyMap extends ResponsesObject<SV>> = unknown extends ResBodyMap ? ForklaunchResErrors : {
871
- [K in keyof ResBodyMap]: ExtractResponseBody<SV, ResBodyMap[K]>;
872
- };
873
- type ExtractBody<SV extends AnySchemaValidator, T extends Body<SV>> = T extends JsonBody<SV> ? T['json'] : T extends TextBody<SV> ? T['text'] : T extends FileBody<SV> ? T['file'] : T extends MultipartForm<SV> ? T['multipartForm'] : T extends UrlEncodedForm<SV> ? T['urlEncodedForm'] : T extends UnknownBody<SV> ? T['schema'] : T;
874
- type MapReqBodySchema<SV extends AnySchemaValidator, ReqBody extends Body<SV>> = MapSchema<SV, ExtractBody<SV, ReqBody>> extends infer Body ? unknown extends Body ? Record<string, unknown> : Body : Record<string, unknown>;
875
- type MapReqQuerySchema<SV extends AnySchemaValidator, ReqQuery extends QueryObject<SV>> = MapSchema<SV, ReqQuery> extends infer Query ? unknown extends Query ? ParsedQs : Query : ParsedQs;
876
- type MapReqHeadersSchema<SV extends AnySchemaValidator, ReqHeaders extends HeadersObject<SV>> = MapSchema<SV, ReqHeaders> extends infer RequestHeaders ? unknown extends RequestHeaders ? Record<string, string> : RequestHeaders : Record<string, string>;
877
- type MapResHeadersSchema<SV extends AnySchemaValidator, ResHeaders extends HeadersObject<SV>> = MapSchema<SV, ResHeaders> extends infer ResponseHeaders ? unknown extends ResponseHeaders ? ForklaunchResHeaders : ResponseHeaders : ForklaunchResHeaders;
878
- type MapVersionedReqsSchema<SV extends AnySchemaValidator, VersionedReqs extends VersionSchema<SV, Method>> = {
879
- [K in keyof VersionedReqs]: (VersionedReqs[K]['requestHeaders'] extends HeadersObject<SV> ? {
880
- requestHeaders: MapReqHeadersSchema<SV, VersionedReqs[K]['requestHeaders']>;
881
- } : unknown) & (VersionedReqs[K]['body'] extends Body<SV> ? {
882
- body: MapReqBodySchema<SV, VersionedReqs[K]['body']>;
883
- } : unknown) & (VersionedReqs[K]['query'] extends QueryObject<SV> ? {
884
- query: MapReqQuerySchema<SV, VersionedReqs[K]['query']>;
885
- } : unknown);
886
- } extends infer MappedVersionedReqs ? MappedVersionedReqs extends VersionedRequests ? MappedVersionedReqs : VersionedRequests : VersionedRequests;
887
- type MapVersionedRespsSchema<SV extends AnySchemaValidator, VersionedResps extends VersionSchema<SV, Method>> = {
888
- [K in keyof VersionedResps]: (VersionedResps[K]['responseHeaders'] extends HeadersObject<SV> ? {
889
- responseHeaders: MapResHeadersSchema<SV, VersionedResps[K]['responseHeaders']>;
890
- } : unknown) & (VersionedResps[K]['responses'] extends ResponsesObject<SV> ? {
891
- responses: MapResBodyMapSchema<SV, VersionedResps[K]['responses']>;
892
- } : unknown);
893
- } extends infer MappedVersionedResps ? MappedVersionedResps extends VersionedResponses ? MappedVersionedResps : VersionedResponses : VersionedResponses;
894
- type MapSessionSchema<SV extends AnySchemaValidator, SessionSchema extends SessionObject<SV>> = SessionSchema extends infer UnmappedSessionSchema ? UnmappedSessionSchema extends SessionObject<SV> ? MapSchema<SV, UnmappedSessionSchema> : never : never;
936
+ type ExtractedParamsObject<Path extends `/${string}`> = Record<ExtractParams<Path>, unknown>;
895
937
  /**
896
- * Represents a schema middleware handler with typed parameters, responses, body, and query.
897
- *
898
- * @template SV - A type that extends AnySchemaValidator.
899
- * @template P - A type for parameter schemas, defaulting to ParamsObject.
900
- * @template ResBodyMap - A type for response schemas, defaulting to ResponsesObject.
901
- * @template ReqBody - A type for the request body, defaulting to Body.
902
- * @template ReqQuery - A type for the request query, defaulting to QueryObject.
903
- * @template LocalsObj - A type for local variables, defaulting to an empty object.
938
+ * Represents the path parameter methods.
904
939
  */
905
- type ExpressLikeSchemaHandler<SV extends AnySchemaValidator, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, Method>, SessionSchema extends Record<string, unknown>, BaseRequest, BaseResponse, NextFunction> = ExpressLikeHandler<SV, MapParamsSchema<SV, P>, MapResBodyMapSchema<SV, ResBodyMap>, MapReqBodySchema<SV, ReqBody>, MapReqQuerySchema<SV, ReqQuery>, MapReqHeadersSchema<SV, ReqHeaders>, MapResHeadersSchema<SV, ResHeaders>, LocalsObj, MapVersionedReqsSchema<SV, VersionedApi>, MapVersionedRespsSchema<SV, VersionedApi>, MapSessionSchema<SV, SessionSchema>, BaseRequest, BaseResponse, NextFunction>;
940
+ type PathParamMethod = 'get' | 'delete' | 'options' | 'head' | 'trace';
906
941
  /**
907
- * Represents a function that maps an authenticated request with schema validation
908
- * to a set of authorization strings, with request properties automatically inferred from the schema.
909
- *
910
- * @template SV - The type representing the schema validator.
911
- * @template P - The type representing request parameters inferred from the schema.
912
- * @template ReqBody - The type representing the request body inferred from the schema.
913
- * @template ReqQuery - The type representing the request query parameters inferred from the schema.
914
- * @template ReqHeaders - The type representing the request headers inferred from the schema.
915
- *
916
- * @param {ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>} req - The request object with schema validation.
917
- * @returns {Set<string> | Promise<Set<string>>} - A set of authorization strings or a promise that resolves to it.
942
+ * Represents the body parameter methods.
918
943
  */
919
- type ExpressLikeSchemaAuthMapper<SV extends AnySchemaValidator, P extends ParamsObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, VersionedReqs extends VersionSchema<SV, Method>, SessionSchema extends SessionObject<SV>, BaseRequest> = ExpressLikeAuthMapper<SV, P extends infer UnmappedParams ? UnmappedParams extends ParamsObject<SV> ? MapParamsSchema<SV, UnmappedParams> : never : never, ReqBody extends infer UnmappedReqBody ? UnmappedReqBody extends Body<SV> ? MapReqBodySchema<SV, UnmappedReqBody> : never : never, ReqQuery extends infer UnmappedReqQuery ? UnmappedReqQuery extends QueryObject<SV> ? MapReqQuerySchema<SV, UnmappedReqQuery> : never : never, ReqHeaders extends infer UnmappedReqHeaders ? UnmappedReqHeaders extends HeadersObject<SV> ? MapReqHeadersSchema<SV, UnmappedReqHeaders> : never : never, VersionedReqs extends infer UnmappedVersionedReqs ? UnmappedVersionedReqs extends VersionSchema<SV, Method> ? MapVersionedReqsSchema<SV, UnmappedVersionedReqs> : never : never, SessionSchema extends infer UnmappedSessionSchema ? UnmappedSessionSchema extends Record<string, unknown> ? MapSessionSchema<SV, UnmappedSessionSchema> : never : never, BaseRequest>;
920
- type ExpressLikeAuthMapper<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends Record<string, unknown>, ReqHeaders extends Record<string, string>, VersionedReqs extends VersionedRequests, SessionSchema extends Record<string, unknown>, BaseRequest> = (payload: JWTPayload & SessionSchema, req?: ResolvedForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, SessionSchema, BaseRequest>) => Set<string> | Promise<Set<string>>;
921
- type TokenPrefix<Auth extends AuthMethodsBase> = undefined extends Auth['tokenPrefix'] ? Auth extends BasicAuthMethods ? 'Basic ' : Auth extends HmacMethods ? 'HMAC ' : 'Bearer ' : `${Auth['tokenPrefix']} `;
922
- type AuthHeaders<Auth extends AuthMethodsBase> = undefined extends Auth['headerName'] ? {
923
- authorization: Auth extends HmacMethods ? `${TokenPrefix<Auth>}keyId=${string} ts=${string} nonce=${string} signature=${string}` : `${TokenPrefix<Auth>}${string}`;
924
- } : {
925
- [K in NonNullable<Auth['headerName']>]: `${TokenPrefix<Auth>}${string}`;
944
+ type HttpMethod = 'post' | 'patch' | 'put';
945
+ /**
946
+ * Represents all supported typed methods.
947
+ */
948
+ type Method = PathParamMethod | HttpMethod | 'middleware';
949
+ /**
950
+ * Interface representing a compiled schema for a response.
951
+ */
952
+ type ResponseCompiledSchema = {
953
+ headers?: unknown;
954
+ responses: Record<number, unknown>;
926
955
  };
927
- type AuthCollapse<Auth extends AuthMethodsBase> = undefined extends Auth['jwt'] ? undefined extends Auth['basic'] ? undefined extends Auth['hmac'] ? true : false : false : false;
928
- type LiveTypeFunctionRequestInit<SV extends AnySchemaValidator, P extends ParamsObject<SV>, ReqBody extends Body<SV> | undefined, ReqQuery extends QueryObject<SV> | undefined, ReqHeaders extends HeadersObject<SV> | undefined, Auth extends AuthMethodsBase> = MakePropertyOptionalIfChildrenOptional<(Body<SV> extends ReqBody ? unknown : {
929
- body: MapSchema<SV, ReqBody>;
930
- }) & (QueryObject<SV> extends ReqQuery ? unknown : {
931
- query: MapSchema<SV, ReqQuery>;
932
- }) & (HeadersObject<SV> extends ReqHeaders ? true extends AuthCollapse<Auth> ? unknown : {
933
- headers: AuthHeaders<Auth>;
934
- } : true extends AuthCollapse<Auth> ? {
935
- headers: MapSchema<SV, ReqHeaders>;
956
+ type BasePathParamHttpContractDetailsIO<SV extends AnySchemaValidator, BodySchema extends Body<SV> | undefined = Body<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, QuerySchema extends QueryObject<SV> | undefined = QueryObject<SV>, ReqHeaders extends HeadersObject<SV> | undefined = HeadersObject<SV>, ResHeaders extends HeadersObject<SV> | undefined = HeadersObject<SV>> = {
957
+ /** Optional body for the contract */
958
+ readonly body?: BodySchema;
959
+ /** Response schemas for the contract */
960
+ readonly responses: ResponseSchemas;
961
+ /** Optional request headers for the contract */
962
+ readonly requestHeaders?: ReqHeaders;
963
+ /** Optional response headers for the contract */
964
+ readonly responseHeaders?: ResHeaders;
965
+ /** Optional query schemas for the contract */
966
+ readonly query?: QuerySchema;
967
+ };
968
+ type VersionedBasePathParamHttpContractDetailsIO<SV extends AnySchemaValidator, VersionedApi extends VersionSchema<SV, PathParamMethod>> = {
969
+ readonly versions: VersionedApi;
970
+ };
971
+ type BasePathParamHttpContractDetails<SV extends AnySchemaValidator, Name extends string = string, Path extends `/${string}` = `/${string}`, ParamsSchema extends ParamsObject<SV> = ParamsObject<SV>> = {
972
+ /** Name of the contract */
973
+ readonly name: StringWithoutSlash<Name>;
974
+ /** Summary of the contract */
975
+ readonly summary: string;
976
+ /** Options for the contract */
977
+ readonly options?: {
978
+ /** Optional request validation for the contract */
979
+ readonly requestValidation?: 'error' | 'warning' | 'none';
980
+ /** Optional response validation for the contract */
981
+ readonly responseValidation?: 'error' | 'warning' | 'none';
982
+ /** Optional MCP details for the contract */
983
+ readonly mcp?: boolean;
984
+ /** Optional OpenAPI details for the contract */
985
+ readonly openapi?: boolean;
986
+ };
987
+ } & (string | number | symbol extends ExtractedParamsObject<Path> ? {
988
+ /** Optional parameters for the contract */
989
+ readonly params?: ParamsSchema;
936
990
  } : {
937
- headers: MapSchema<SV, ReqHeaders> & AuthHeaders<Auth>;
938
- }) & (ParamsObject<SV> extends P ? unknown : {
939
- params: MapSchema<SV, P>;
940
- })>;
991
+ /** Required parameters for the contract */
992
+ readonly params: {
993
+ [K in keyof ExtractedParamsObject<Path>]: ParamsSchema[K];
994
+ };
995
+ });
941
996
  /**
942
- * Represents a live type function for the SDK.
997
+ * Interface representing HTTP contract details for path parameters.
943
998
  *
944
999
  * @template SV - A type that extends AnySchemaValidator.
945
- * @template Path - A type for the route path.
946
- * @template P - A type for request parameters.
947
- * @template ResBodyMap - A type for response schemas.
948
- * @template ReqBody - A type for the request body.
949
- * @template ReqQuery - A type for the request query.
950
- * @template ReqHeaders - A type for the request headers.
951
- * @template ResHeaders - A type for the response headers.
952
- *
1000
+ * @template ParamsSchema - A type for parameter schemas, defaulting to ParamsObject.
1001
+ * @template ResponseSchemas - A type for response schemas, defaulting to ResponsesObject.
1002
+ * @template QuerySchema - A type for query schemas, defaulting to QueryObject.
953
1003
  */
954
- type LiveTypeFunction<SV extends AnySchemaValidator, Route extends string, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, ContractMethod extends Method, VersionedApi extends VersionSchema<SV, ContractMethod>, Auth extends AuthMethodsBase> = string extends keyof VersionedApi ? (route: SanitizePathSlashes<Route>, ...reqInit: Prettify<Omit<RequestInit, 'method' | 'body' | 'query' | 'headers' | 'params'> & {
955
- method: Uppercase<ContractMethod>;
956
- } & LiveTypeFunctionRequestInit<SV, P, ReqBody, ReqQuery, ReqHeaders, Auth>> extends infer ReqInit ? ReqInit extends {
957
- body: unknown;
958
- } | {
959
- params: unknown;
960
- } | {
961
- query: unknown;
962
- } | {
963
- headers: unknown;
964
- } ? [reqInit: Prettify<ReqInit>] : [reqInit?: Prettify<ReqInit>] : never) => Promise<Prettify<SdkResponse<SV, ResponsesObject<SV> extends ResBodyMap ? Record<number, unknown> : ResBodyMap, ForklaunchResHeaders extends ResHeaders ? unknown : MapSchema<SV, ResHeaders>>>> : {
965
- [K in keyof VersionedApi]: (...reqInit: Prettify<Omit<RequestInit, 'method' | 'body' | 'query' | 'headers' | 'params'> & LiveTypeFunctionRequestInit<SV, P, VersionedApi[K]['body'] extends Body<SV> ? VersionedApi[K]['body'] : Body<SV>, VersionedApi[K]['query'] extends QueryObject<SV> ? VersionedApi[K]['query'] : QueryObject<SV>, VersionedApi[K]['requestHeaders'] extends HeadersObject<SV> ? VersionedApi[K]['requestHeaders'] : HeadersObject<SV>, Auth>> & {
966
- version: K;
967
- } extends infer ReqInit ? ReqInit extends {
968
- body: unknown;
969
- } | {
970
- params: unknown;
971
- } | {
972
- query: unknown;
973
- } | {
974
- headers: unknown;
975
- } ? [reqInit: Prettify<ReqInit>] : [reqInit?: Prettify<ReqInit>] : never) => Promise<Prettify<SdkResponse<SV, ResponsesObject<SV> extends VersionedApi[K]['responses'] ? Record<number, unknown> : VersionedApi[K]['responses'], ForklaunchResHeaders extends VersionedApi[K]['responseHeaders'] ? unknown : MapSchema<SV, VersionedApi[K]['responseHeaders']>>>>;
1004
+ type PathParamHttpContractDetails<SV extends AnySchemaValidator, Name extends string = string, Path extends `/${string}` = `/${string}`, ParamsSchema extends ParamsObject<SV> = ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, BodySchema extends Body<SV> = Body<SV>, QuerySchema extends QueryObject<SV> = QueryObject<SV>, ReqHeaders extends HeadersObject<SV> = HeadersObject<SV>, ResHeaders extends HeadersObject<SV> = HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method> = VersionSchema<SV, PathParamMethod>, BaseRequest = unknown, Auth extends SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest> = SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest>> = BasePathParamHttpContractDetails<SV, Name, Path, ParamsSchema> & ((BasePathParamHttpContractDetailsIO<SV, never, ResponseSchemas, QuerySchema, ReqHeaders, ResHeaders> & {
1005
+ readonly versions?: never;
1006
+ }) | (VersionedBasePathParamHttpContractDetailsIO<SV, VersionedApi> & {
1007
+ readonly query?: never;
1008
+ readonly requestHeaders?: never;
1009
+ readonly responseHeaders?: never;
1010
+ readonly responses?: never;
1011
+ })) & {
1012
+ /** Optional authentication details for the contract */
1013
+ readonly auth?: Auth;
1014
+ };
1015
+ type VersionedHttpContractDetailsIO<SV extends AnySchemaValidator, VersionedApi extends VersionSchema<SV, HttpMethod>> = {
1016
+ readonly versions: VersionedApi;
976
1017
  };
977
1018
  /**
978
- * Represents a live type function for the SDK.
1019
+ * Interface representing HTTP contract details.
979
1020
  *
980
1021
  * @template SV - A type that extends AnySchemaValidator.
981
- * @template P - A type for request parameters.
982
- * @template ResBodyMap - A type for response schemas.
983
- * @template ReqBody - A type for the request body.
984
- * @template ReqQuery - A type for the request query.
985
- * @template ReqHeaders - A type for the request headers.
986
- * @template ResHeaders - A type for the response headers.
987
- *
1022
+ * @template ParamsSchema - A type for parameter schemas, defaulting to ParamsObject.
1023
+ * @template ResponseSchemas - A type for response schemas, defaulting to ResponsesObject.
1024
+ * @template BodySchema - A type for the body schema, defaulting to Body.
1025
+ * @template QuerySchema - A type for query schemas, defaulting to QueryObject.
988
1026
  */
989
- type LiveSdkFunction<SV extends AnySchemaValidator, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method>, Auth extends AuthMethodsBase> = string extends keyof VersionedApi ? (...reqInit: Prettify<Omit<RequestInit, 'method' | 'body' | 'query' | 'headers' | 'params'> & LiveTypeFunctionRequestInit<SV, P, ReqBody, ReqQuery, ReqHeaders, Auth>> extends infer ReqInit ? ReqInit extends {
990
- body: unknown;
991
- } | {
992
- params: unknown;
993
- } | {
994
- query: unknown;
995
- } | {
996
- headers: unknown;
997
- } ? [reqInit: Prettify<ReqInit>] : [reqInit?: Prettify<ReqInit>] : never) => Promise<Prettify<SdkResponse<SV, ResponsesObject<SV> extends ResBodyMap ? Record<number, unknown> : ResBodyMap, ForklaunchResHeaders extends ResHeaders ? unknown : MapSchema<SV, ResHeaders>>>> : {
998
- [K in keyof VersionedApi]: (...reqInit: Prettify<Omit<RequestInit, 'method' | 'body' | 'query' | 'headers' | 'params'> & LiveTypeFunctionRequestInit<SV, P, VersionedApi[K]['body'] extends Body<SV> ? VersionedApi[K]['body'] : Body<SV>, VersionedApi[K]['query'] extends QueryObject<SV> ? VersionedApi[K]['query'] : QueryObject<SV>, VersionedApi[K]['requestHeaders'] extends HeadersObject<SV> ? VersionedApi[K]['requestHeaders'] : HeadersObject<SV>, Auth>> extends infer ReqInit ? ReqInit extends {
999
- body: unknown;
1000
- } | {
1001
- params: unknown;
1002
- } | {
1003
- query: unknown;
1004
- } | {
1005
- headers: unknown;
1006
- } ? [reqInit: Prettify<ReqInit>] : [reqInit?: Prettify<ReqInit>] : never) => Promise<Prettify<SdkResponse<SV, ResponsesObject<SV> extends VersionedApi[K]['responses'] ? Record<number, unknown> : VersionedApi[K]['responses'], ForklaunchResHeaders extends VersionedApi[K]['responseHeaders'] ? unknown : MapSchema<SV, VersionedApi[K]['responseHeaders']>>>>;
1027
+ type HttpContractDetails<SV extends AnySchemaValidator, Name extends string = string, Path extends `/${string}` = `/${string}`, ParamsSchema extends ParamsObject<SV> = ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, BodySchema extends Body<SV> = Body<SV>, QuerySchema extends QueryObject<SV> = QueryObject<SV>, ReqHeaders extends HeadersObject<SV> = HeadersObject<SV>, ResHeaders extends HeadersObject<SV> = HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method> = VersionSchema<SV, HttpMethod>, BaseRequest = unknown, Auth extends SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest> = SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest>> = BasePathParamHttpContractDetails<SV, Name, Path, ParamsSchema> & ((BasePathParamHttpContractDetailsIO<SV, BodySchema, ResponseSchemas, QuerySchema, ReqHeaders, ResHeaders> & {
1028
+ readonly versions?: never;
1029
+ }) | (VersionedHttpContractDetailsIO<SV, VersionedApi> & {
1030
+ readonly query?: never;
1031
+ readonly requestHeaders?: never;
1032
+ readonly responseHeaders?: never;
1033
+ readonly body?: never;
1034
+ readonly responses?: never;
1035
+ })) & {
1036
+ readonly auth?: Auth;
1007
1037
  };
1008
1038
  /**
1009
- * Represents a basic SDK Response object.
1039
+ * Interface representing HTTP contract details for middleware.
1010
1040
  *
1011
- * @template ResBodyMap - A type for the response body.
1012
- * @template ResHeaders - A type for the response headers.
1013
- */
1014
- type SdkResponse<SV extends AnySchemaValidator, ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, unknown> | unknown> = ({
1015
- [K in keyof Omit<ForklaunchResErrors, keyof ResBodyMap>]: {
1016
- code: K;
1017
- contentType: 'text/plain';
1018
- response: ForklaunchResErrors[K];
1019
- };
1020
- } & {
1021
- [K in keyof ResBodyMap]: {
1022
- code: K;
1023
- contentType: ExtractContentType<SV, ResBodyMap[K]>;
1024
- response: ExtractResponseBody<SV, ResBodyMap[K]>;
1025
- } & (unknown extends ResHeaders ? unknown : {
1026
- headers: ResHeaders;
1027
- });
1028
- })[keyof (Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)];
1029
- /**
1030
- * Represents the default error types for responses.
1031
- */
1032
- type ForklaunchResErrors<BadRequest = string, Unauthorized = string, NotFound = string, Forbidden = string, InternalServerErrorType = string> = {
1033
- 400: BadRequest;
1034
- 401: Unauthorized;
1035
- 404: NotFound;
1036
- 403: Forbidden;
1037
- 500: InternalServerErrorType;
1038
- };
1039
- /**
1040
- * Represents the default header types for responses.
1041
- */
1042
- type ForklaunchResHeaders = {
1043
- 'x-correlation-id': string;
1044
- };
1045
- /**
1046
- * Represents the default error types for responses.
1041
+ * @template SV - A type that extends AnySchemaValidator.
1042
+ * @template ParamsSchema - A type for parameter schemas, defaulting to ParamsObject.
1043
+ * @template ResponseSchemas - A type for response schemas, defaulting to ResponsesObject.
1044
+ * @template QuerySchema - A type for query schemas, defaulting to QueryObject.
1045
+ * @template ReqHeaders - A type for request headers, defaulting to HeadersObject.
1046
+ * @template ResHeaders - A type for response headers, defaulting to HeadersObject.
1047
1047
  */
1048
- type ErrorContainer<Code extends number> = {
1049
- /** The error code */
1050
- code: Code;
1051
- /** The error message */
1052
- error: string;
1053
- };
1048
+ type MiddlewareContractDetails<SV extends AnySchemaValidator, Name extends string = string, Path extends `/${string}` = `/${string}`, ParamsSchema extends ParamsObject<SV> = ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, BodySchema extends Body<SV> = Body<SV>, QuerySchema extends QueryObject<SV> = QueryObject<SV>, ReqHeaders extends HeadersObject<SV> = HeadersObject<SV>, ResHeaders extends HeadersObject<SV> = HeadersObject<SV>, VersionedApi extends VersionSchema<SV, Method> = VersionSchema<SV, 'middleware'>, BaseRequest = unknown, Auth extends SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest> = SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest>> = Omit<Partial<HttpContractDetails<SV, Name, Path, ParamsSchema, ResponseSchemas, BodySchema, QuerySchema, ReqHeaders, ResHeaders, VersionedApi, BaseRequest, Auth>>, 'responses'>;
1049
+ type VersionSchema<SV extends AnySchemaValidator, ContractMethod extends Method> = Record<string, BasePathParamHttpContractDetailsIO<SV, ContractMethod extends PathParamMethod ? never : Body<SV>, ResponsesObject<SV>, QueryObject<SV>, HeadersObject<SV>, HeadersObject<SV>>>;
1054
1050
  /**
1055
- * Represents a parsed response shape.
1051
+ * Utility for different Contract Detail types
1056
1052
  */
1057
- type ResponseShape<Params, Headers, Query, Body> = {
1058
- params: Params;
1059
- headers: Headers;
1060
- query: Query;
1061
- body: Body;
1062
- };
1053
+ type ContractDetails<SV extends AnySchemaValidator, Name extends string, ContractMethod extends Method, Path extends `/${string}`, ParamsSchema extends ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV>, BodySchema extends Body<SV>, QuerySchema extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, VersionedApi extends VersionSchema<SV, ContractMethod>, BaseRequest, Auth extends SchemaAuthMethods<SV, ParamsSchema, BodySchema, QuerySchema, ReqHeaders, VersionedApi, BaseRequest>> = ContractMethod extends PathParamMethod ? PathParamHttpContractDetails<SV, Name, Path, ParamsSchema, ResponseSchemas, BodySchema, QuerySchema, ReqHeaders, ResHeaders, VersionedApi, BaseRequest, Auth> : ContractMethod extends HttpMethod ? HttpContractDetails<SV, Name, Path, ParamsSchema, ResponseSchemas, BodySchema, QuerySchema, ReqHeaders, ResHeaders, VersionedApi, BaseRequest, Auth> : ContractMethod extends 'middleware' ? MiddlewareContractDetails<SV, Name, Path, ParamsSchema, ResponseSchemas, BodySchema, QuerySchema, ReqHeaders, ResHeaders, VersionedApi, BaseRequest, Auth> : never;
1063
1054
  /**
1064
- * Represents a path match.
1055
+ * Resolves the session object type to use for authentication.
1056
+ *
1057
+ * If `AuthSession` is provided and extends `SessionObject<SV>`, it is used as the session type.
1058
+ * Otherwise, the `FallbackSession` type is used.
1059
+ *
1060
+ * @template SV - The schema validator type.
1061
+ * @template AuthSession - The session object type provided by the authentication method, or undefined.
1062
+ * @template FallbackSession - The fallback session object type to use if `AuthSession` is not provided.
1065
1063
  */
1066
- type PathMatch<SuppliedPath extends `/${string}`, ActualPath extends `/${string}`> = ActualPath extends SuppliedPath ? SuppliedPath extends ActualPath ? SuppliedPath : never : never;
1064
+ type ResolvedSessionObject<SV extends AnySchemaValidator, AuthSession extends SessionObject<SV> | undefined, FallbackSession extends SessionObject<SV>> = AuthSession extends {
1065
+ readonly sessionSchema?: infer ResolvedSessionSchema | undefined;
1066
+ } | undefined ? ResolvedSessionSchema extends SessionObject<SV> ? ResolvedSessionSchema : FallbackSession : FallbackSession;
1067
1067
 
1068
- export { type MapReqBodySchema as $, type AuthMethodsBase as A, type Body as B, type ContractDetails as C, type DecodeResource as D, type ExpressLikeRouterOptions as E, type ForklaunchRequest as F, type ForklaunchBaseRequest as G, type HttpContractDetails as H, type ResolvedForklaunchRequest as I, type ResolvedForklaunchAuthRequest as J, type VersionedResponses as K, type LiveTypeFunction as L, type Method as M, type ResolvedForklaunchResponse as N, OpenTelemetryCollector as O, type PathParamHttpContractDetails as P, type QueryObject as Q, type ResponsesObject as R, type StringOnlyObject as S, type TelemetryOptions as T, type ExpressLikeHandler as U, type VersionSchema as V, type MapParamsSchema as W, type ExtractContentType as X, type ExtractResponseBody as Y, type MapResBodyMapSchema as Z, type ExtractBody as _, type SessionObject as a, type MapReqQuerySchema as a0, type MapReqHeadersSchema as a1, type MapResHeadersSchema as a2, type MapVersionedReqsSchema as a3, type MapVersionedRespsSchema as a4, type MapSessionSchema as a5, type ExpressLikeAuthMapper as a6, type LiveTypeFunctionRequestInit as a7, type ForklaunchResErrors as a8, type ErrorContainer as a9, type MetricType as aA, type ResponseShape as aa, type NumberOnlyObject as ab, type BodyObject as ac, type RawTypedResponseBody as ad, type TypedResponseBody as ae, type ResponseBody as af, type JsonBody as ag, type TextBody as ah, type FileBody as ai, type MultipartForm as aj, type UrlEncodedForm as ak, type ServerSentEventBody as al, type UnknownBody as am, type UnknownResponseBody as an, type TypedRequestBody as ao, type TypedBody as ap, type JwtAuthMethods as aq, type HmacMethods as ar, type MapSchema as as, type ExtractedParamsObject as at, type PathParamMethod as au, type HttpMethod as av, type ResponseCompiledSchema as aw, type DocsConfiguration as ax, type ExpressLikeGlobalAuthOptions as ay, type ExpressLikeSchemaGlobalAuthOptions as az, type ParamsObject as b, type HeadersObject as c, type SchemaAuthMethods as d, type ExpressLikeSchemaHandler as e, type ResolvedSessionObject as f, type PathMatch as g, type LiveSdkFunction as h, type MetricsDefinition as i, type ExpressLikeApplicationOptions as j, type ParamsDictionary as k, type VersionedRequests as l, type AuthMethods as m, type BasicAuthMethods as n, type MiddlewareContractDetails as o, type ExpressLikeSchemaAuthMapper as p, type ForklaunchNextFunction as q, type ForklaunchResponse as r, type ForklaunchResHeaders as s, type ForklaunchStatusResponse as t, type ForklaunchSendableData as u, type LoggerMeta as v, type LogFn as w, httpRequestsTotalCounter as x, httpServerDurationHistogram as y, type RequestContext as z };
1068
+ export { type HmacMethods as $, type AuthMethodsBase as A, type Body as B, type ContractDetails as C, type DecodeResource as D, type ExpressLikeRouterOptions as E, type ForklaunchRequest as F, type ExpressLikeAuthMapper as G, type HttpContractDetails as H, type ExpressLikeGlobalAuthOptions as I, type ExpressLikeHandler as J, type ExpressLikeSchemaGlobalAuthOptions as K, type LiveTypeFunction as L, type Method as M, type ExtractBody as N, OpenTelemetryCollector as O, type PathParamHttpContractDetails as P, type QueryObject as Q, type ResponsesObject as R, type StringOnlyObject as S, type TelemetryOptions as T, type ExtractContentType as U, type VersionSchema as V, type ExtractResponseBody as W, type ExtractedParamsObject as X, type FileBody as Y, type ForklaunchBaseRequest as Z, type ForklaunchResErrors as _, type SessionObject as a, type HttpMethod as a0, type JsonBody as a1, type JwtAuthMethods as a2, type LiveTypeFunctionRequestInit as a3, type MapParamsSchema as a4, type MapReqBodySchema as a5, type MapReqHeadersSchema as a6, type MapReqQuerySchema as a7, type MapResBodyMapSchema as a8, type MapResHeadersSchema as a9, httpServerDurationHistogram as aA, type MapSchema as aa, type MapSessionSchema as ab, type MapVersionedReqsSchema as ac, type MapVersionedRespsSchema as ad, type MetricType as ae, type MultipartForm as af, type NumberOnlyObject as ag, type PathParamMethod as ah, type RawTypedResponseBody as ai, type RequestContext as aj, type ResolvedForklaunchAuthRequest as ak, type ResolvedForklaunchRequest as al, type ResolvedForklaunchResponse as am, type ResponseBody as an, type ResponseCompiledSchema as ao, type ResponseShape as ap, type ServerSentEventBody as aq, type TextBody as ar, type TypedBody as as, type TypedRequestBody as at, type TypedResponseBody as au, type UnknownBody as av, type UnknownResponseBody as aw, type UrlEncodedForm as ax, type VersionedResponses as ay, httpRequestsTotalCounter as az, type ParamsObject as b, type HeadersObject as c, type SchemaAuthMethods as d, type ExpressLikeSchemaHandler as e, type ResolvedSessionObject as f, type PathMatch as g, type LiveSdkFunction as h, type MetricsDefinition as i, type ExpressLikeApplicationOptions as j, type ParamsDictionary as k, type VersionedRequests as l, type AuthMethods as m, type BasicAuthMethods as n, type MiddlewareContractDetails as o, type ExpressLikeSchemaAuthMapper as p, type ForklaunchNextFunction as q, type ForklaunchResponse as r, type ForklaunchResHeaders as s, type ForklaunchStatusResponse as t, type ForklaunchSendableData as u, type LoggerMeta as v, type LogFn as w, type BodyObject as x, type DocsConfiguration as y, type ErrorContainer as z };