@forklaunch/core 0.17.3 → 0.18.1

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