@forklaunch/core 0.16.1 → 0.17.0

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.
@@ -42,6 +42,7 @@ declare class OpenTelemetryCollector<AppliedMetricsDefinition extends MetricsDef
42
42
  }
43
43
  declare const httpRequestsTotalCounter: Counter<{
44
44
  "service.name": string;
45
+ application_id?: string;
45
46
  "api.name": string;
46
47
  "http.request.method": string;
47
48
  "http.route": string;
@@ -49,6 +50,7 @@ declare const httpRequestsTotalCounter: Counter<{
49
50
  }>;
50
51
  declare const httpServerDurationHistogram: Histogram<{
51
52
  "service.name": string;
53
+ application_id?: string;
52
54
  "api.name": string;
53
55
  "http.request.method": string;
54
56
  "http.route": string;
@@ -632,7 +634,7 @@ interface ForklaunchBaseRequest<P extends ParamsDictionary, ReqBody extends Reco
632
634
  /** Original path */
633
635
  originalPath: string;
634
636
  /** OpenTelemetry Collector */
635
- openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
637
+ openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
636
638
  }
637
639
  /**
638
640
  * Interface representing a Forklaunch request.
@@ -669,11 +671,13 @@ interface ForklaunchRequest<SV extends AnySchemaValidator, P extends ParamsDicti
669
671
  /** Original path */
670
672
  originalPath: string;
671
673
  /** OpenTelemetry Collector */
672
- openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
674
+ openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
673
675
  /** Session */
674
676
  session: JWTPayload & SessionSchema;
675
677
  /** Parsed versions */
676
678
  _parsedVersions: string[] | number;
679
+ /** Raw body before schema validation (for HMAC verification) */
680
+ _rawBody?: unknown;
677
681
  /** Global options */
678
682
  _globalOptions: () => ExpressLikeRouterOptions<SV, SessionSchema> | undefined;
679
683
  }
@@ -1008,7 +1012,7 @@ type LiveSdkFunction<SV extends AnySchemaValidator, P extends ParamsObject<SV>,
1008
1012
  * @template ResHeaders - A type for the response headers.
1009
1013
  */
1010
1014
  type SdkResponse<SV extends AnySchemaValidator, ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, unknown> | unknown> = ({
1011
- [K in keyof ForklaunchResErrors]: {
1015
+ [K in keyof Omit<ForklaunchResErrors, keyof ResBodyMap>]: {
1012
1016
  code: K;
1013
1017
  contentType: 'text/plain';
1014
1018
  response: ForklaunchResErrors[K];
@@ -1021,7 +1025,7 @@ type SdkResponse<SV extends AnySchemaValidator, ResBodyMap extends Record<number
1021
1025
  } & (unknown extends ResHeaders ? unknown : {
1022
1026
  headers: ResHeaders;
1023
1027
  });
1024
- })[keyof (ForklaunchResErrors & ResBodyMap)];
1028
+ })[keyof (Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)];
1025
1029
  /**
1026
1030
  * Represents the default error types for responses.
1027
1031
  */
@@ -1061,4 +1065,4 @@ type ResponseShape<Params, Headers, Query, Body> = {
1061
1065
  */
1062
1066
  type PathMatch<SuppliedPath extends `/${string}`, ActualPath extends `/${string}`> = ActualPath extends SuppliedPath ? SuppliedPath extends ActualPath ? SuppliedPath : never : never;
1063
1067
 
1064
- export { type MapReqBodySchema as $, type AuthMethodsBase as A, type Body as B, type ContractDetails as C, type DecodeResource as D, type ExpressLikeRouterOptions as E, type ForklaunchRequest as F, type ForklaunchNextFunction as G, type HttpContractDetails as H, type ResolvedForklaunchRequest as I, type ResolvedForklaunchAuthRequest as J, type VersionedResponses as K, type LiveTypeFunction as L, type Method as M, type ResolvedForklaunchResponse as N, OpenTelemetryCollector as O, type PathParamHttpContractDetails as P, type QueryObject as Q, type ResponsesObject as R, type StringOnlyObject as S, type TelemetryOptions as T, type ExpressLikeHandler as U, type VersionSchema as V, type MapParamsSchema as W, type ExtractContentType as X, type ExtractResponseBody as Y, type MapResBodyMapSchema as Z, type ExtractBody as _, type SessionObject as a, type MapReqQuerySchema as a0, type MapReqHeadersSchema as a1, type MapResHeadersSchema as a2, type MapVersionedReqsSchema as a3, type MapVersionedRespsSchema as a4, type MapSessionSchema as a5, type ExpressLikeAuthMapper as a6, type LiveTypeFunctionRequestInit as a7, type ForklaunchResErrors as a8, type ErrorContainer as a9, type MetricType as aA, type ResponseShape as aa, type NumberOnlyObject as ab, type BodyObject as ac, type RawTypedResponseBody as ad, type TypedResponseBody as ae, type ResponseBody as af, type JsonBody as ag, type TextBody as ah, type FileBody as ai, type MultipartForm as aj, type UrlEncodedForm as ak, type ServerSentEventBody as al, type UnknownBody as am, type UnknownResponseBody as an, type TypedRequestBody as ao, type TypedBody as ap, type JwtAuthMethods as aq, type HmacMethods as ar, type MapSchema as as, type ExtractedParamsObject as at, type PathParamMethod as au, type HttpMethod as av, type ResponseCompiledSchema as aw, type DocsConfiguration as ax, type ExpressLikeGlobalAuthOptions as ay, type ExpressLikeSchemaGlobalAuthOptions as az, type ParamsObject as b, type HeadersObject as c, type SchemaAuthMethods as d, type ExpressLikeSchemaHandler as e, type ResolvedSessionObject as f, type PathMatch as g, type LiveSdkFunction as h, type MetricsDefinition as i, type ExpressLikeApplicationOptions as j, type ParamsDictionary as k, type VersionedRequests as l, type AuthMethods as m, type BasicAuthMethods as n, type MiddlewareContractDetails as o, type ExpressLikeSchemaAuthMapper as p, type ForklaunchResponse as q, type ForklaunchResHeaders as r, type ForklaunchStatusResponse as s, type ForklaunchSendableData as t, type LoggerMeta as u, type LogFn as v, httpRequestsTotalCounter as w, httpServerDurationHistogram as x, type RequestContext as y, type ForklaunchBaseRequest as z };
1068
+ export { type MapReqBodySchema as $, type AuthMethodsBase as A, type Body as B, type ContractDetails as C, type DecodeResource as D, type ExpressLikeRouterOptions as E, type ForklaunchRequest as F, type ForklaunchBaseRequest as G, type HttpContractDetails as H, type ResolvedForklaunchRequest as I, type ResolvedForklaunchAuthRequest as J, type VersionedResponses as K, type LiveTypeFunction as L, type Method as M, type ResolvedForklaunchResponse as N, OpenTelemetryCollector as O, type PathParamHttpContractDetails as P, type QueryObject as Q, type ResponsesObject as R, type StringOnlyObject as S, type TelemetryOptions as T, type ExpressLikeHandler as U, type VersionSchema as V, type MapParamsSchema as W, type ExtractContentType as X, type ExtractResponseBody as Y, type MapResBodyMapSchema as Z, type ExtractBody as _, type SessionObject as a, type MapReqQuerySchema as a0, type MapReqHeadersSchema as a1, type MapResHeadersSchema as a2, type MapVersionedReqsSchema as a3, type MapVersionedRespsSchema as a4, type MapSessionSchema as a5, type ExpressLikeAuthMapper as a6, type LiveTypeFunctionRequestInit as a7, type ForklaunchResErrors as a8, type ErrorContainer as a9, type MetricType as aA, type ResponseShape as aa, type NumberOnlyObject as ab, type BodyObject as ac, type RawTypedResponseBody as ad, type TypedResponseBody as ae, type ResponseBody as af, type JsonBody as ag, type TextBody as ah, type FileBody as ai, type MultipartForm as aj, type UrlEncodedForm as ak, type ServerSentEventBody as al, type UnknownBody as am, type UnknownResponseBody as an, type TypedRequestBody as ao, type TypedBody as ap, type JwtAuthMethods as aq, type HmacMethods as ar, type MapSchema as as, type ExtractedParamsObject as at, type PathParamMethod as au, type HttpMethod as av, type ResponseCompiledSchema as aw, type DocsConfiguration as ax, type ExpressLikeGlobalAuthOptions as ay, type ExpressLikeSchemaGlobalAuthOptions as az, type ParamsObject as b, type HeadersObject as c, type SchemaAuthMethods as d, type ExpressLikeSchemaHandler as e, type ResolvedSessionObject as f, type PathMatch as g, type LiveSdkFunction as h, type MetricsDefinition as i, type ExpressLikeApplicationOptions as j, type ParamsDictionary as k, type VersionedRequests as l, type AuthMethods as m, type BasicAuthMethods as n, type MiddlewareContractDetails as o, type ExpressLikeSchemaAuthMapper as p, type ForklaunchNextFunction as q, type ForklaunchResponse as r, type ForklaunchResHeaders as s, type ForklaunchStatusResponse as t, type ForklaunchSendableData as u, type LoggerMeta as v, type LogFn as w, httpRequestsTotalCounter as x, httpServerDurationHistogram as y, type RequestContext as z };
@@ -42,6 +42,7 @@ declare class OpenTelemetryCollector<AppliedMetricsDefinition extends MetricsDef
42
42
  }
43
43
  declare const httpRequestsTotalCounter: Counter<{
44
44
  "service.name": string;
45
+ application_id?: string;
45
46
  "api.name": string;
46
47
  "http.request.method": string;
47
48
  "http.route": string;
@@ -49,6 +50,7 @@ declare const httpRequestsTotalCounter: Counter<{
49
50
  }>;
50
51
  declare const httpServerDurationHistogram: Histogram<{
51
52
  "service.name": string;
53
+ application_id?: string;
52
54
  "api.name": string;
53
55
  "http.request.method": string;
54
56
  "http.route": string;
@@ -632,7 +634,7 @@ interface ForklaunchBaseRequest<P extends ParamsDictionary, ReqBody extends Reco
632
634
  /** Original path */
633
635
  originalPath: string;
634
636
  /** OpenTelemetry Collector */
635
- openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
637
+ openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
636
638
  }
637
639
  /**
638
640
  * Interface representing a Forklaunch request.
@@ -669,11 +671,13 @@ interface ForklaunchRequest<SV extends AnySchemaValidator, P extends ParamsDicti
669
671
  /** Original path */
670
672
  originalPath: string;
671
673
  /** OpenTelemetry Collector */
672
- openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
674
+ openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
673
675
  /** Session */
674
676
  session: JWTPayload & SessionSchema;
675
677
  /** Parsed versions */
676
678
  _parsedVersions: string[] | number;
679
+ /** Raw body before schema validation (for HMAC verification) */
680
+ _rawBody?: unknown;
677
681
  /** Global options */
678
682
  _globalOptions: () => ExpressLikeRouterOptions<SV, SessionSchema> | undefined;
679
683
  }
@@ -1008,7 +1012,7 @@ type LiveSdkFunction<SV extends AnySchemaValidator, P extends ParamsObject<SV>,
1008
1012
  * @template ResHeaders - A type for the response headers.
1009
1013
  */
1010
1014
  type SdkResponse<SV extends AnySchemaValidator, ResBodyMap extends Record<number, unknown>, ResHeaders extends Record<string, unknown> | unknown> = ({
1011
- [K in keyof ForklaunchResErrors]: {
1015
+ [K in keyof Omit<ForklaunchResErrors, keyof ResBodyMap>]: {
1012
1016
  code: K;
1013
1017
  contentType: 'text/plain';
1014
1018
  response: ForklaunchResErrors[K];
@@ -1021,7 +1025,7 @@ type SdkResponse<SV extends AnySchemaValidator, ResBodyMap extends Record<number
1021
1025
  } & (unknown extends ResHeaders ? unknown : {
1022
1026
  headers: ResHeaders;
1023
1027
  });
1024
- })[keyof (ForklaunchResErrors & ResBodyMap)];
1028
+ })[keyof (Omit<ForklaunchResErrors, keyof ResBodyMap> & ResBodyMap)];
1025
1029
  /**
1026
1030
  * Represents the default error types for responses.
1027
1031
  */
@@ -1061,4 +1065,4 @@ type ResponseShape<Params, Headers, Query, Body> = {
1061
1065
  */
1062
1066
  type PathMatch<SuppliedPath extends `/${string}`, ActualPath extends `/${string}`> = ActualPath extends SuppliedPath ? SuppliedPath extends ActualPath ? SuppliedPath : never : never;
1063
1067
 
1064
- export { type MapReqBodySchema as $, type AuthMethodsBase as A, type Body as B, type ContractDetails as C, type DecodeResource as D, type ExpressLikeRouterOptions as E, type ForklaunchRequest as F, type ForklaunchNextFunction as G, type HttpContractDetails as H, type ResolvedForklaunchRequest as I, type ResolvedForklaunchAuthRequest as J, type VersionedResponses as K, type LiveTypeFunction as L, type Method as M, type ResolvedForklaunchResponse as N, OpenTelemetryCollector as O, type PathParamHttpContractDetails as P, type QueryObject as Q, type ResponsesObject as R, type StringOnlyObject as S, type TelemetryOptions as T, type ExpressLikeHandler as U, type VersionSchema as V, type MapParamsSchema as W, type ExtractContentType as X, type ExtractResponseBody as Y, type MapResBodyMapSchema as Z, type ExtractBody as _, type SessionObject as a, type MapReqQuerySchema as a0, type MapReqHeadersSchema as a1, type MapResHeadersSchema as a2, type MapVersionedReqsSchema as a3, type MapVersionedRespsSchema as a4, type MapSessionSchema as a5, type ExpressLikeAuthMapper as a6, type LiveTypeFunctionRequestInit as a7, type ForklaunchResErrors as a8, type ErrorContainer as a9, type MetricType as aA, type ResponseShape as aa, type NumberOnlyObject as ab, type BodyObject as ac, type RawTypedResponseBody as ad, type TypedResponseBody as ae, type ResponseBody as af, type JsonBody as ag, type TextBody as ah, type FileBody as ai, type MultipartForm as aj, type UrlEncodedForm as ak, type ServerSentEventBody as al, type UnknownBody as am, type UnknownResponseBody as an, type TypedRequestBody as ao, type TypedBody as ap, type JwtAuthMethods as aq, type HmacMethods as ar, type MapSchema as as, type ExtractedParamsObject as at, type PathParamMethod as au, type HttpMethod as av, type ResponseCompiledSchema as aw, type DocsConfiguration as ax, type ExpressLikeGlobalAuthOptions as ay, type ExpressLikeSchemaGlobalAuthOptions as az, type ParamsObject as b, type HeadersObject as c, type SchemaAuthMethods as d, type ExpressLikeSchemaHandler as e, type ResolvedSessionObject as f, type PathMatch as g, type LiveSdkFunction as h, type MetricsDefinition as i, type ExpressLikeApplicationOptions as j, type ParamsDictionary as k, type VersionedRequests as l, type AuthMethods as m, type BasicAuthMethods as n, type MiddlewareContractDetails as o, type ExpressLikeSchemaAuthMapper as p, type ForklaunchResponse as q, type ForklaunchResHeaders as r, type ForklaunchStatusResponse as s, type ForklaunchSendableData as t, type LoggerMeta as u, type LogFn as v, httpRequestsTotalCounter as w, httpServerDurationHistogram as x, type RequestContext as y, type ForklaunchBaseRequest as z };
1068
+ export { type MapReqBodySchema as $, type AuthMethodsBase as A, type Body as B, type ContractDetails as C, type DecodeResource as D, type ExpressLikeRouterOptions as E, type ForklaunchRequest as F, type ForklaunchBaseRequest as G, type HttpContractDetails as H, type ResolvedForklaunchRequest as I, type ResolvedForklaunchAuthRequest as J, type VersionedResponses as K, type LiveTypeFunction as L, type Method as M, type ResolvedForklaunchResponse as N, OpenTelemetryCollector as O, type PathParamHttpContractDetails as P, type QueryObject as Q, type ResponsesObject as R, type StringOnlyObject as S, type TelemetryOptions as T, type ExpressLikeHandler as U, type VersionSchema as V, type MapParamsSchema as W, type ExtractContentType as X, type ExtractResponseBody as Y, type MapResBodyMapSchema as Z, type ExtractBody as _, type SessionObject as a, type MapReqQuerySchema as a0, type MapReqHeadersSchema as a1, type MapResHeadersSchema as a2, type MapVersionedReqsSchema as a3, type MapVersionedRespsSchema as a4, type MapSessionSchema as a5, type ExpressLikeAuthMapper as a6, type LiveTypeFunctionRequestInit as a7, type ForklaunchResErrors as a8, type ErrorContainer as a9, type MetricType as aA, type ResponseShape as aa, type NumberOnlyObject as ab, type BodyObject as ac, type RawTypedResponseBody as ad, type TypedResponseBody as ae, type ResponseBody as af, type JsonBody as ag, type TextBody as ah, type FileBody as ai, type MultipartForm as aj, type UrlEncodedForm as ak, type ServerSentEventBody as al, type UnknownBody as am, type UnknownResponseBody as an, type TypedRequestBody as ao, type TypedBody as ap, type JwtAuthMethods as aq, type HmacMethods as ar, type MapSchema as as, type ExtractedParamsObject as at, type PathParamMethod as au, type HttpMethod as av, type ResponseCompiledSchema as aw, type DocsConfiguration as ax, type ExpressLikeGlobalAuthOptions as ay, type ExpressLikeSchemaGlobalAuthOptions as az, type ParamsObject as b, type HeadersObject as c, type SchemaAuthMethods as d, type ExpressLikeSchemaHandler as e, type ResolvedSessionObject as f, type PathMatch as g, type LiveSdkFunction as h, type MetricsDefinition as i, type ExpressLikeApplicationOptions as j, type ParamsDictionary as k, type VersionedRequests as l, type AuthMethods as m, type BasicAuthMethods as n, type MiddlewareContractDetails as o, type ExpressLikeSchemaAuthMapper as p, type ForklaunchNextFunction as q, type ForklaunchResponse as r, type ForklaunchResHeaders as s, type ForklaunchStatusResponse as t, type ForklaunchSendableData as u, type LoggerMeta as v, type LogFn as w, httpRequestsTotalCounter as x, httpServerDurationHistogram as y, type RequestContext as z };
@@ -3,8 +3,8 @@ export { ParsedQs } from 'qs';
3
3
  import { Prettify, SanitizePathSlashes, PrettyCamelCase, TypeSafeFunction, UnionToIntersection, EmptyObject } from '@forklaunch/common';
4
4
  import { AnySchemaValidator } from '@forklaunch/validator';
5
5
  import { ServerOptions, IncomingMessage, ServerResponse } from 'node:http';
6
- import { M as Method, P as PathParamHttpContractDetails, H as HttpContractDetails, E as ExpressLikeRouterOptions, a as SessionObject, b as ParamsObject, R as ResponsesObject, B as Body, Q as QueryObject, c as HeadersObject, V as VersionSchema, d as SchemaAuthMethods, C as ContractDetails, e as ExpressLikeSchemaHandler, f as ResolvedSessionObject, g as PathMatch, L as LiveTypeFunction, h as LiveSdkFunction, A as AuthMethodsBase, O as OpenTelemetryCollector, i as MetricsDefinition, j as ExpressLikeApplicationOptions, k as ParamsDictionary, l as VersionedRequests, m as AuthMethods, D as DecodeResource, n as BasicAuthMethods, F as ForklaunchRequest, o as MiddlewareContractDetails, p as ExpressLikeSchemaAuthMapper, q as ForklaunchResponse, r as ForklaunchResHeaders, s as ForklaunchStatusResponse, t as ForklaunchSendableData, T as TelemetryOptions, u as LoggerMeta, v as LogFn } from '../apiDefinition.types-BYizofKE.mjs';
7
- export { ac as BodyObject, ax as DocsConfiguration, a9 as ErrorContainer, a6 as ExpressLikeAuthMapper, ay as ExpressLikeGlobalAuthOptions, U as ExpressLikeHandler, az as ExpressLikeSchemaGlobalAuthOptions, _ as ExtractBody, X as ExtractContentType, Y as ExtractResponseBody, at as ExtractedParamsObject, ai as FileBody, z as ForklaunchBaseRequest, G as ForklaunchNextFunction, a8 as ForklaunchResErrors, ar as HmacMethods, av as HttpMethod, ag as JsonBody, aq as JwtAuthMethods, a7 as LiveTypeFunctionRequestInit, W as MapParamsSchema, $ as MapReqBodySchema, a1 as MapReqHeadersSchema, a0 as MapReqQuerySchema, Z as MapResBodyMapSchema, a2 as MapResHeadersSchema, as as MapSchema, a5 as MapSessionSchema, a3 as MapVersionedReqsSchema, a4 as MapVersionedRespsSchema, aA as MetricType, aj as MultipartForm, ab as NumberOnlyObject, au as PathParamMethod, ad as RawTypedResponseBody, y as RequestContext, J as ResolvedForklaunchAuthRequest, I as ResolvedForklaunchRequest, N as ResolvedForklaunchResponse, af as ResponseBody, aw as ResponseCompiledSchema, aa as ResponseShape, al as ServerSentEventBody, S as StringOnlyObject, ah as TextBody, ap as TypedBody, ao as TypedRequestBody, ae as TypedResponseBody, am as UnknownBody, an as UnknownResponseBody, ak as UrlEncodedForm, K as VersionedResponses, w as httpRequestsTotalCounter, x as httpServerDurationHistogram } from '../apiDefinition.types-BYizofKE.mjs';
6
+ import { M as Method, P as PathParamHttpContractDetails, H as HttpContractDetails, E as ExpressLikeRouterOptions, a as SessionObject, b as ParamsObject, R as ResponsesObject, B as Body, Q as QueryObject, c as HeadersObject, V as VersionSchema, d as SchemaAuthMethods, C as ContractDetails, e as ExpressLikeSchemaHandler, f as ResolvedSessionObject, g as PathMatch, L as LiveTypeFunction, h as LiveSdkFunction, A as AuthMethodsBase, O as OpenTelemetryCollector, i as MetricsDefinition, j as ExpressLikeApplicationOptions, k as ParamsDictionary, l as VersionedRequests, m as AuthMethods, D as DecodeResource, n as BasicAuthMethods, F as ForklaunchRequest, o as MiddlewareContractDetails, p as ExpressLikeSchemaAuthMapper, q as ForklaunchNextFunction, r as ForklaunchResponse, s as ForklaunchResHeaders, t as ForklaunchStatusResponse, u as ForklaunchSendableData, T as TelemetryOptions, v as LoggerMeta, w as LogFn } from '../apiDefinition.types--RSi8f6C.mjs';
7
+ export { ac as BodyObject, ax as DocsConfiguration, a9 as ErrorContainer, a6 as ExpressLikeAuthMapper, ay as ExpressLikeGlobalAuthOptions, U as ExpressLikeHandler, az as ExpressLikeSchemaGlobalAuthOptions, _ as ExtractBody, X as ExtractContentType, Y as ExtractResponseBody, at as ExtractedParamsObject, ai as FileBody, G as ForklaunchBaseRequest, a8 as ForklaunchResErrors, ar as HmacMethods, av as HttpMethod, ag as JsonBody, aq as JwtAuthMethods, a7 as LiveTypeFunctionRequestInit, W as MapParamsSchema, $ as MapReqBodySchema, a1 as MapReqHeadersSchema, a0 as MapReqQuerySchema, Z as MapResBodyMapSchema, a2 as MapResHeadersSchema, as as MapSchema, a5 as MapSessionSchema, a3 as MapVersionedReqsSchema, a4 as MapVersionedRespsSchema, aA as MetricType, aj as MultipartForm, ab as NumberOnlyObject, au as PathParamMethod, ad as RawTypedResponseBody, z as RequestContext, J as ResolvedForklaunchAuthRequest, I as ResolvedForklaunchRequest, N as ResolvedForklaunchResponse, af as ResponseBody, aw as ResponseCompiledSchema, aa as ResponseShape, al as ServerSentEventBody, S as StringOnlyObject, ah as TextBody, ap as TypedBody, ao as TypedRequestBody, ae as TypedResponseBody, am as UnknownBody, an as UnknownResponseBody, ak as UrlEncodedForm, K as VersionedResponses, x as httpRequestsTotalCounter, y as httpServerDurationHistogram } from '../apiDefinition.types--RSi8f6C.mjs';
8
8
  import { JWK, JWTPayload } from 'jose';
9
9
  import { FastMCP } from '@forklaunch/fastmcp-fork';
10
10
  import { ZodSchemaValidator } from '@forklaunch/validator/zod';
@@ -482,6 +482,55 @@ type ToFetchMap<T extends Record<string, SdkHandler>, SV extends AnySchemaValida
482
482
  };
483
483
  }>;
484
484
 
485
+ /**
486
+ * Extracts route middleware and handlers from route registration arguments.
487
+ * This is a port function that converts typed handlers into Express middleware
488
+ * without actually registering them on a router.
489
+ *
490
+ * @template SV - The schema validator type.
491
+ * @template Name - The route name.
492
+ * @template ContractMethod - The HTTP method.
493
+ * @template Path - The route path.
494
+ * @template P - The type of request parameters.
495
+ * @template ResBodyMap - The type of response body map.
496
+ * @template ReqBody - The type of request body.
497
+ * @template ReqQuery - The type of request query.
498
+ * @template ReqHeaders - The type of request headers.
499
+ * @template ResHeaders - The type of response headers.
500
+ * @template LocalsObj - The type of local variables.
501
+ * @template VersionedApi - The versioned API schema.
502
+ * @template RouterSession - The router session type.
503
+ * @template BaseRequest - The base request type.
504
+ * @template BaseResponse - The base response type.
505
+ * @template NextFunction - The next function type.
506
+ * @template Auth - The auth schema.
507
+ * @template RouterHandler - The router handler type.
508
+ * @param {object} params - The parameters for extracting route handlers.
509
+ * @param {ContractMethod} params.method - The HTTP method.
510
+ * @param {Path} params.path - The route path.
511
+ * @param {string} params.basePath - The base path for the router.
512
+ * @param {SV} params.schemaValidator - The schema validator.
513
+ * @param {ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>} params.contractDetailsOrMiddlewareOrTypedHandler - The contract details or typed handler.
514
+ * @param {MiddlewareOrMiddlewareWithTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>[]} params.middlewareOrMiddlewareAndTypedHandler - Additional middleware or typed handlers.
515
+ * @param {OpenTelemetryCollector<MetricsDefinition>} params.openTelemetryCollector - The OpenTelemetry collector.
516
+ * @param {RouterHandler[]} params.postEnrichMiddleware - Additional middleware to run after enrichment.
517
+ * @param {ExpressLikeRouterOptions<SV, RouterSession> | undefined} params.routerOptions - Router options.
518
+ * @returns {{ middlewares: RouterHandler[]; controllerHandler: ExpressLikeHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedRequests, VersionedResponses, RouterSession, BaseRequest, BaseResponse, NextFunction> }} - The extracted middlewares and controller handler.
519
+ */
520
+ declare function extractRouteHandlers<SV extends AnySchemaValidator, Name extends string, ContractMethod extends Method, Path 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>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, ContractMethod>, RouterSession extends SessionObject<SV>, BaseRequest, BaseResponse, NextFunction, Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>, RouterHandler>(params: {
521
+ method: ContractMethod;
522
+ path: Path;
523
+ basePath: string;
524
+ schemaValidator: SV;
525
+ contractDetailsOrMiddlewareOrTypedHandler: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>;
526
+ middlewareOrMiddlewareAndTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>[];
527
+ openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
528
+ postEnrichMiddleware?: RouterHandler[];
529
+ routerOptions?: ExpressLikeRouterOptions<SV, RouterSession>;
530
+ }): {
531
+ middlewares: RouterHandler[];
532
+ controllerHandler: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, RouterSession, BaseRequest, BaseResponse, NextFunction>;
533
+ };
485
534
  /**
486
535
  * A class that represents an Express-like router.
487
536
  */
@@ -500,6 +549,18 @@ declare class ForklaunchExpressLikeRouter<SV extends AnySchemaValidator, BasePat
500
549
  sdk: Sdk;
501
550
  sdkPaths: Record<string, string>;
502
551
  constructor(basePath: BasePath, schemaValidator: SV, internal: Internal, postEnrichMiddleware: RouterHandler[], openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, routerOptions?: ExpressLikeRouterOptions<SV, RouterSession> | undefined);
552
+ /**
553
+ * Extracts the controller handler from the provided handlers.
554
+ *
555
+ * @template P - The type of request parameters.
556
+ * @template ResBodyMap - The type of response body.
557
+ * @template ReqBody - The type of request body.
558
+ * @template ReqQuery - The type of request query.
559
+ * @template LocalsObj - The type of local variables.
560
+ * @param {MiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} handlers - The provided handlers.
561
+ * @returns {MiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>} - The extracted controller handler.
562
+ * @throws {Error} - Throws an error if the last argument is not a handler.
563
+ */
503
564
  /**
504
565
  * Fetches a route from the route map and executes it with the given parameters.
505
566
  *
@@ -509,13 +570,13 @@ declare class ForklaunchExpressLikeRouter<SV extends AnySchemaValidator, BasePat
509
570
  * @returns {Promise<ReturnType<_fetchMap[Path]>>} - The result of executing the route handler.
510
571
  */
511
572
  fetch: FetchFunction<this['_fetchMap']>;
512
- registerRoute<Name extends string, ContractMethod extends Method, Path 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>, LocalsObj extends Record<string, unknown>, const VersionedApi extends VersionSchema<SV, ContractMethod>, const Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(method: ContractMethod, path: Path, registrationMethod: PathBasedHandler<RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>, ...middlewareOrMiddlewareAndTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>[]): this & {
573
+ registerRoute<Name extends string, ContractMethod extends Method, Path 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>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, ContractMethod>, Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(method: ContractMethod, path: Path, registrationMethod: PathBasedHandler<RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>, ...middlewareOrMiddlewareAndTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>[]): this & {
513
574
  _fetchMap: Prettify<FetchMap extends Record<SanitizePathSlashes<`${BasePath}${Path}`>, unknown> ? FetchMap & Record<SanitizePathSlashes<`${BasePath}${Path}`>, FetchMap[SanitizePathSlashes<`${BasePath}${Path}`>] & Record<Uppercase<ContractMethod>, LiveTypeFunction<SV, SanitizePathSlashes<`${BasePath}${Path}`>, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, ContractMethod, VersionedApi, Auth>>> : FetchMap & Record<SanitizePathSlashes<`${BasePath}${Path}`>, Record<Uppercase<ContractMethod>, LiveTypeFunction<SV, SanitizePathSlashes<`${BasePath}${Path}`>, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, ContractMethod, VersionedApi, Auth>>>>;
514
575
  sdk: Prettify<Sdk & Record<PrettyCamelCase<Name extends string ? Name : SanitizePathSlashes<`${BasePath}${Path}`>>, LiveSdkFunction<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, VersionedApi, Auth>>>;
515
576
  };
516
- registerMiddlewareHandler<Name extends string, Path 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>, LocalsObj extends Record<string, unknown>, const VersionedApi extends VersionSchema<SV, 'middleware'>, const Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(registrationMethod: PathOrMiddlewareBasedHandler<RouterHandler>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler, ...middlewareOrMiddlewareWithTypedHandler: (MiddlewareOrMiddlewareWithTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler)[]): this;
577
+ registerMiddlewareHandler<Name extends string, Path 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>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, 'middleware'>, Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(registrationMethod: PathOrMiddlewareBasedHandler<RouterHandler>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler, ...middlewareOrMiddlewareWithTypedHandler: (MiddlewareOrMiddlewareWithTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler)[]): this;
517
578
  private addRouterToSdk;
518
- registerNestableMiddlewareHandler<Name extends string, Path 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>, LocalsObj extends Record<string, unknown>, const VersionedApi extends VersionSchema<SV, 'middleware'>, const SessionSchema extends SessionObject<SV>, const Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(registrationMethod: NestableRouterBasedHandler<RouterHandler, Internal>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>, ...middlewareOrMiddlewareWithTypedHandler: (MiddlewareOrMiddlewareWithTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>)[]): this;
579
+ registerNestableMiddlewareHandler<Name extends string, Path 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>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, 'middleware'>, const SessionSchema extends SessionObject<SV>, Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(registrationMethod: NestableRouterBasedHandler<RouterHandler, Internal>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>, ...middlewareOrMiddlewareWithTypedHandler: (MiddlewareOrMiddlewareWithTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>)[]): this;
519
580
  private addRouterOptions;
520
581
  use: TypedNestableMiddlewareDefinition<this, RouterHandler, Internal, SV, RouterSession, BaseRequest, BaseResponse, NextFunction>;
521
582
  all: TypedMiddlewareDefinition<this, SV, RouterSession, BaseRequest, BaseResponse, NextFunction, RouterHandler>;
@@ -701,6 +762,37 @@ declare function createHmacToken({ method, path, body, timestamp, nonce, secretK
701
762
  secretKey: string;
702
763
  }): string;
703
764
 
765
+ /**
766
+ * Generate HMAC authorization headers for service-to-service authentication.
767
+ *
768
+ * @param secretKey - The shared HMAC secret key
769
+ * @param method - HTTP method (GET, POST, etc.)
770
+ * @param path - The API path
771
+ * @param body - Optional request body
772
+ * @param keyId - Optional key identifier (defaults to 'default')
773
+ * @returns Authorization header object
774
+ *
775
+ * @example
776
+ * ```typescript
777
+ * const headers = generateHmacAuthHeaders({
778
+ * secretKey: 'my-secret-key',
779
+ * method: 'POST',
780
+ * path: '/api/users',
781
+ * body: { name: 'John' }
782
+ * });
783
+ * // headers.authorization = 'HMAC keyId=default ts=2024-01-16T12:00:00.000Z nonce=... signature=...'
784
+ * ```
785
+ */
786
+ declare function generateHmacAuthHeaders({ secretKey, method, path, body, keyId }: {
787
+ secretKey: string;
788
+ method: string;
789
+ path: string;
790
+ body?: unknown;
791
+ keyId?: string;
792
+ }): {
793
+ authorization: `HMAC keyId=${string} ts=${string} nonce=${string} signature=${string}`;
794
+ };
795
+
704
796
  /**
705
797
  * Retrieves and caches the JSON Web Key Set (JWKS) from a given public key URL.
706
798
  *
@@ -750,7 +842,7 @@ declare function getCachedJwks(jwksPublicKeyUrl: string): Promise<JWK[]>;
750
842
  * // result.auth === authConfig.basic
751
843
  * ```
752
844
  */
753
- declare function discriminateAuthMethod<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>, VersionedReqs extends VersionedRequests, BaseRequest>(auth: AuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, BaseRequest>): Promise<{
845
+ declare function discriminateAuthMethod<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>, VersionedReqs extends VersionedRequests, BaseRequest>(auth: AuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, BaseRequest>, openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>): Promise<{
754
846
  type: 'basic';
755
847
  auth: {
756
848
  decodeResource?: DecodeResource;
@@ -940,6 +1032,18 @@ declare const getCodeForStatus: (status: string) => null | StatusCode;
940
1032
  */
941
1033
  declare function generateMcpServer<T extends Record<string, unknown> | undefined = Record<string, unknown> | undefined>(schemaValidator: ZodSchemaValidator, protocol: 'http' | 'https', host: string, port: number, version: `${number}.${number}.${number}`, application: ForklaunchRouter<ZodSchemaValidator>, appOptions?: ExpressLikeApplicationOptions<ZodSchemaValidator, SessionObject<ZodSchemaValidator>>['mcp'], options?: ConstructorParameters<typeof FastMCP<T>>[0], contentTypeMap?: Record<string, string>, authenticate?: (request: http.IncomingMessage) => Promise<Record<string, unknown> | undefined>): FastMCP<Record<string, unknown> | undefined>;
942
1034
 
1035
+ /**
1036
+ * Middleware to create and add a request context.
1037
+ *
1038
+ * @template SV - A type that extends AnySchemaValidator.
1039
+ * @template Request - A type that extends ForklaunchRequest.
1040
+ * @template Response - A type that extends ForklaunchResponse.
1041
+ * @template NextFunction - A type that extends ForklaunchNextFunction.
1042
+ * @param {SV} schemaValidator - The schema validator.
1043
+ * @returns {Function} - Middleware function to create request context.
1044
+ */
1045
+ declare function createContext<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, 'middleware'>, SessionSchema extends SessionObject<SV>>(schemaValidator: SV): ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, SessionSchema, unknown, unknown, ForklaunchNextFunction>;
1046
+
943
1047
  /**
944
1048
  * Enhances the Express-like `send` method with additional logic for response handling and validation.
945
1049
  *
@@ -1023,6 +1127,7 @@ declare function discriminateResponseBodies<SV extends AnySchemaValidator>(schem
1023
1127
 
1024
1128
  declare const ATTR_API_NAME = "api.name";
1025
1129
  declare const ATTR_CORRELATION_ID = "correlation.id";
1130
+ declare const ATTR_APPLICATION_ID = "application_id";
1026
1131
 
1027
1132
  declare function evaluateTelemetryOptions(telemetryOptions: TelemetryOptions): {
1028
1133
  enabled: {
@@ -1053,4 +1158,4 @@ declare function logger(level: LevelWithSilentOrString, meta?: AnyValueMap): Pin
1053
1158
 
1054
1159
  declare function recordMetric<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ResBodyMap extends Record<string, unknown>, ReqHeaders extends Record<string, string>, ResHeaders extends Record<string, unknown>, LocalsObj extends Record<string, unknown>, VersionedReqs extends VersionedRequests, SessionSchema extends Record<string, unknown>>(req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Extract<keyof VersionedReqs, string>, SessionSchema>, res: ForklaunchResponse<unknown, ResBodyMap, ResHeaders, LocalsObj, Extract<keyof VersionedReqs, string>>): void;
1055
1160
 
1056
- export { ATTR_API_NAME, ATTR_CORRELATION_ID, AuthMethods, AuthMethodsBase, BasicAuthMethods, Body, type ClusterConfig, type ConstrainedForklaunchRouter, ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, DecodeResource, ExpressLikeApplicationOptions, type ExpressLikeRouter, ExpressLikeRouterOptions, ExpressLikeSchemaAuthMapper, ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractLiveTypeFn, type FetchFunction, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, ForklaunchRequest, ForklaunchResHeaders, ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, ForklaunchSendableData, ForklaunchStatusResponse, HTTPStatuses, HeadersObject, HttpContractDetails, LiveSdkFunction, LiveTypeFunction, type LiveTypeRouteDefinition, LogFn, LoggerMeta, type MapHandlerToLiveSdk, type MapToFetch, type MapToSdk, Method, MetricsDefinition, MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type NestableRouterBasedHandler, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, ParamsDictionary, ParamsObject, type PathBasedHandler, PathMatch, type PathOrMiddlewareBasedHandler, PathParamHttpContractDetails, PinoLogger, QueryObject, ResolvedSessionObject, ResponsesObject, type RouterMap, type RoutingStrategy, SchemaAuthMethods, type SdkHandler, type SdkHandlerObject, type SdkRouter, SessionObject, type StatusCode, TelemetryOptions, type ToFetchMap, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, VersionSchema, VersionedRequests, createHmacToken, delete_, discriminateAuthMethod, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, generateMcpServer, generateOpenApiSpecs, get, getCachedJwks, getCodeForStatus, head, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, trace, typedAuthHandler, typedHandler };
1161
+ export { ATTR_API_NAME, ATTR_APPLICATION_ID, ATTR_CORRELATION_ID, AuthMethods, AuthMethodsBase, BasicAuthMethods, Body, type ClusterConfig, type ConstrainedForklaunchRouter, ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, DecodeResource, ExpressLikeApplicationOptions, type ExpressLikeRouter, ExpressLikeRouterOptions, ExpressLikeSchemaAuthMapper, ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractLiveTypeFn, type FetchFunction, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, ForklaunchNextFunction, ForklaunchRequest, ForklaunchResHeaders, ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, ForklaunchSendableData, ForklaunchStatusResponse, HTTPStatuses, HeadersObject, HttpContractDetails, LiveSdkFunction, LiveTypeFunction, type LiveTypeRouteDefinition, LogFn, LoggerMeta, type MapHandlerToLiveSdk, type MapToFetch, type MapToSdk, Method, MetricsDefinition, MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type NestableRouterBasedHandler, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, ParamsDictionary, ParamsObject, type PathBasedHandler, PathMatch, type PathOrMiddlewareBasedHandler, PathParamHttpContractDetails, PinoLogger, QueryObject, ResolvedSessionObject, ResponsesObject, type RouterMap, type RoutingStrategy, SchemaAuthMethods, type SdkHandler, type SdkHandlerObject, type SdkRouter, SessionObject, type StatusCode, TelemetryOptions, type ToFetchMap, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, VersionSchema, VersionedRequests, createContext, createHmacToken, delete_, discriminateAuthMethod, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, extractRouteHandlers, generateHmacAuthHeaders, generateMcpServer, generateOpenApiSpecs, get, getCachedJwks, getCodeForStatus, head, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, trace, typedAuthHandler, typedHandler };
@@ -3,8 +3,8 @@ export { ParsedQs } from 'qs';
3
3
  import { Prettify, SanitizePathSlashes, PrettyCamelCase, TypeSafeFunction, UnionToIntersection, EmptyObject } from '@forklaunch/common';
4
4
  import { AnySchemaValidator } from '@forklaunch/validator';
5
5
  import { ServerOptions, IncomingMessage, ServerResponse } from 'node:http';
6
- import { M as Method, P as PathParamHttpContractDetails, H as HttpContractDetails, E as ExpressLikeRouterOptions, a as SessionObject, b as ParamsObject, R as ResponsesObject, B as Body, Q as QueryObject, c as HeadersObject, V as VersionSchema, d as SchemaAuthMethods, C as ContractDetails, e as ExpressLikeSchemaHandler, f as ResolvedSessionObject, g as PathMatch, L as LiveTypeFunction, h as LiveSdkFunction, A as AuthMethodsBase, O as OpenTelemetryCollector, i as MetricsDefinition, j as ExpressLikeApplicationOptions, k as ParamsDictionary, l as VersionedRequests, m as AuthMethods, D as DecodeResource, n as BasicAuthMethods, F as ForklaunchRequest, o as MiddlewareContractDetails, p as ExpressLikeSchemaAuthMapper, q as ForklaunchResponse, r as ForklaunchResHeaders, s as ForklaunchStatusResponse, t as ForklaunchSendableData, T as TelemetryOptions, u as LoggerMeta, v as LogFn } from '../apiDefinition.types-BYizofKE.js';
7
- export { ac as BodyObject, ax as DocsConfiguration, a9 as ErrorContainer, a6 as ExpressLikeAuthMapper, ay as ExpressLikeGlobalAuthOptions, U as ExpressLikeHandler, az as ExpressLikeSchemaGlobalAuthOptions, _ as ExtractBody, X as ExtractContentType, Y as ExtractResponseBody, at as ExtractedParamsObject, ai as FileBody, z as ForklaunchBaseRequest, G as ForklaunchNextFunction, a8 as ForklaunchResErrors, ar as HmacMethods, av as HttpMethod, ag as JsonBody, aq as JwtAuthMethods, a7 as LiveTypeFunctionRequestInit, W as MapParamsSchema, $ as MapReqBodySchema, a1 as MapReqHeadersSchema, a0 as MapReqQuerySchema, Z as MapResBodyMapSchema, a2 as MapResHeadersSchema, as as MapSchema, a5 as MapSessionSchema, a3 as MapVersionedReqsSchema, a4 as MapVersionedRespsSchema, aA as MetricType, aj as MultipartForm, ab as NumberOnlyObject, au as PathParamMethod, ad as RawTypedResponseBody, y as RequestContext, J as ResolvedForklaunchAuthRequest, I as ResolvedForklaunchRequest, N as ResolvedForklaunchResponse, af as ResponseBody, aw as ResponseCompiledSchema, aa as ResponseShape, al as ServerSentEventBody, S as StringOnlyObject, ah as TextBody, ap as TypedBody, ao as TypedRequestBody, ae as TypedResponseBody, am as UnknownBody, an as UnknownResponseBody, ak as UrlEncodedForm, K as VersionedResponses, w as httpRequestsTotalCounter, x as httpServerDurationHistogram } from '../apiDefinition.types-BYizofKE.js';
6
+ import { M as Method, P as PathParamHttpContractDetails, H as HttpContractDetails, E as ExpressLikeRouterOptions, a as SessionObject, b as ParamsObject, R as ResponsesObject, B as Body, Q as QueryObject, c as HeadersObject, V as VersionSchema, d as SchemaAuthMethods, C as ContractDetails, e as ExpressLikeSchemaHandler, f as ResolvedSessionObject, g as PathMatch, L as LiveTypeFunction, h as LiveSdkFunction, A as AuthMethodsBase, O as OpenTelemetryCollector, i as MetricsDefinition, j as ExpressLikeApplicationOptions, k as ParamsDictionary, l as VersionedRequests, m as AuthMethods, D as DecodeResource, n as BasicAuthMethods, F as ForklaunchRequest, o as MiddlewareContractDetails, p as ExpressLikeSchemaAuthMapper, q as ForklaunchNextFunction, r as ForklaunchResponse, s as ForklaunchResHeaders, t as ForklaunchStatusResponse, u as ForklaunchSendableData, T as TelemetryOptions, v as LoggerMeta, w as LogFn } from '../apiDefinition.types--RSi8f6C.js';
7
+ export { ac as BodyObject, ax as DocsConfiguration, a9 as ErrorContainer, a6 as ExpressLikeAuthMapper, ay as ExpressLikeGlobalAuthOptions, U as ExpressLikeHandler, az as ExpressLikeSchemaGlobalAuthOptions, _ as ExtractBody, X as ExtractContentType, Y as ExtractResponseBody, at as ExtractedParamsObject, ai as FileBody, G as ForklaunchBaseRequest, a8 as ForklaunchResErrors, ar as HmacMethods, av as HttpMethod, ag as JsonBody, aq as JwtAuthMethods, a7 as LiveTypeFunctionRequestInit, W as MapParamsSchema, $ as MapReqBodySchema, a1 as MapReqHeadersSchema, a0 as MapReqQuerySchema, Z as MapResBodyMapSchema, a2 as MapResHeadersSchema, as as MapSchema, a5 as MapSessionSchema, a3 as MapVersionedReqsSchema, a4 as MapVersionedRespsSchema, aA as MetricType, aj as MultipartForm, ab as NumberOnlyObject, au as PathParamMethod, ad as RawTypedResponseBody, z as RequestContext, J as ResolvedForklaunchAuthRequest, I as ResolvedForklaunchRequest, N as ResolvedForklaunchResponse, af as ResponseBody, aw as ResponseCompiledSchema, aa as ResponseShape, al as ServerSentEventBody, S as StringOnlyObject, ah as TextBody, ap as TypedBody, ao as TypedRequestBody, ae as TypedResponseBody, am as UnknownBody, an as UnknownResponseBody, ak as UrlEncodedForm, K as VersionedResponses, x as httpRequestsTotalCounter, y as httpServerDurationHistogram } from '../apiDefinition.types--RSi8f6C.js';
8
8
  import { JWK, JWTPayload } from 'jose';
9
9
  import { FastMCP } from '@forklaunch/fastmcp-fork';
10
10
  import { ZodSchemaValidator } from '@forklaunch/validator/zod';
@@ -482,6 +482,55 @@ type ToFetchMap<T extends Record<string, SdkHandler>, SV extends AnySchemaValida
482
482
  };
483
483
  }>;
484
484
 
485
+ /**
486
+ * Extracts route middleware and handlers from route registration arguments.
487
+ * This is a port function that converts typed handlers into Express middleware
488
+ * without actually registering them on a router.
489
+ *
490
+ * @template SV - The schema validator type.
491
+ * @template Name - The route name.
492
+ * @template ContractMethod - The HTTP method.
493
+ * @template Path - The route path.
494
+ * @template P - The type of request parameters.
495
+ * @template ResBodyMap - The type of response body map.
496
+ * @template ReqBody - The type of request body.
497
+ * @template ReqQuery - The type of request query.
498
+ * @template ReqHeaders - The type of request headers.
499
+ * @template ResHeaders - The type of response headers.
500
+ * @template LocalsObj - The type of local variables.
501
+ * @template VersionedApi - The versioned API schema.
502
+ * @template RouterSession - The router session type.
503
+ * @template BaseRequest - The base request type.
504
+ * @template BaseResponse - The base response type.
505
+ * @template NextFunction - The next function type.
506
+ * @template Auth - The auth schema.
507
+ * @template RouterHandler - The router handler type.
508
+ * @param {object} params - The parameters for extracting route handlers.
509
+ * @param {ContractMethod} params.method - The HTTP method.
510
+ * @param {Path} params.path - The route path.
511
+ * @param {string} params.basePath - The base path for the router.
512
+ * @param {SV} params.schemaValidator - The schema validator.
513
+ * @param {ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>} params.contractDetailsOrMiddlewareOrTypedHandler - The contract details or typed handler.
514
+ * @param {MiddlewareOrMiddlewareWithTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>[]} params.middlewareOrMiddlewareAndTypedHandler - Additional middleware or typed handlers.
515
+ * @param {OpenTelemetryCollector<MetricsDefinition>} params.openTelemetryCollector - The OpenTelemetry collector.
516
+ * @param {RouterHandler[]} params.postEnrichMiddleware - Additional middleware to run after enrichment.
517
+ * @param {ExpressLikeRouterOptions<SV, RouterSession> | undefined} params.routerOptions - Router options.
518
+ * @returns {{ middlewares: RouterHandler[]; controllerHandler: ExpressLikeHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedRequests, VersionedResponses, RouterSession, BaseRequest, BaseResponse, NextFunction> }} - The extracted middlewares and controller handler.
519
+ */
520
+ declare function extractRouteHandlers<SV extends AnySchemaValidator, Name extends string, ContractMethod extends Method, Path 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>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, ContractMethod>, RouterSession extends SessionObject<SV>, BaseRequest, BaseResponse, NextFunction, Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>, RouterHandler>(params: {
521
+ method: ContractMethod;
522
+ path: Path;
523
+ basePath: string;
524
+ schemaValidator: SV;
525
+ contractDetailsOrMiddlewareOrTypedHandler: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>;
526
+ middlewareOrMiddlewareAndTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>[];
527
+ openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
528
+ postEnrichMiddleware?: RouterHandler[];
529
+ routerOptions?: ExpressLikeRouterOptions<SV, RouterSession>;
530
+ }): {
531
+ middlewares: RouterHandler[];
532
+ controllerHandler: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, RouterSession, BaseRequest, BaseResponse, NextFunction>;
533
+ };
485
534
  /**
486
535
  * A class that represents an Express-like router.
487
536
  */
@@ -500,6 +549,18 @@ declare class ForklaunchExpressLikeRouter<SV extends AnySchemaValidator, BasePat
500
549
  sdk: Sdk;
501
550
  sdkPaths: Record<string, string>;
502
551
  constructor(basePath: BasePath, schemaValidator: SV, internal: Internal, postEnrichMiddleware: RouterHandler[], openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, routerOptions?: ExpressLikeRouterOptions<SV, RouterSession> | undefined);
552
+ /**
553
+ * Extracts the controller handler from the provided handlers.
554
+ *
555
+ * @template P - The type of request parameters.
556
+ * @template ResBodyMap - The type of response body.
557
+ * @template ReqBody - The type of request body.
558
+ * @template ReqQuery - The type of request query.
559
+ * @template LocalsObj - The type of local variables.
560
+ * @param {MiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} handlers - The provided handlers.
561
+ * @returns {MiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>} - The extracted controller handler.
562
+ * @throws {Error} - Throws an error if the last argument is not a handler.
563
+ */
503
564
  /**
504
565
  * Fetches a route from the route map and executes it with the given parameters.
505
566
  *
@@ -509,13 +570,13 @@ declare class ForklaunchExpressLikeRouter<SV extends AnySchemaValidator, BasePat
509
570
  * @returns {Promise<ReturnType<_fetchMap[Path]>>} - The result of executing the route handler.
510
571
  */
511
572
  fetch: FetchFunction<this['_fetchMap']>;
512
- registerRoute<Name extends string, ContractMethod extends Method, Path 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>, LocalsObj extends Record<string, unknown>, const VersionedApi extends VersionSchema<SV, ContractMethod>, const Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(method: ContractMethod, path: Path, registrationMethod: PathBasedHandler<RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>, ...middlewareOrMiddlewareAndTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>[]): this & {
573
+ registerRoute<Name extends string, ContractMethod extends Method, Path 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>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, ContractMethod>, Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(method: ContractMethod, path: Path, registrationMethod: PathBasedHandler<RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>, ...middlewareOrMiddlewareAndTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>[]): this & {
513
574
  _fetchMap: Prettify<FetchMap extends Record<SanitizePathSlashes<`${BasePath}${Path}`>, unknown> ? FetchMap & Record<SanitizePathSlashes<`${BasePath}${Path}`>, FetchMap[SanitizePathSlashes<`${BasePath}${Path}`>] & Record<Uppercase<ContractMethod>, LiveTypeFunction<SV, SanitizePathSlashes<`${BasePath}${Path}`>, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, ContractMethod, VersionedApi, Auth>>> : FetchMap & Record<SanitizePathSlashes<`${BasePath}${Path}`>, Record<Uppercase<ContractMethod>, LiveTypeFunction<SV, SanitizePathSlashes<`${BasePath}${Path}`>, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, ContractMethod, VersionedApi, Auth>>>>;
514
575
  sdk: Prettify<Sdk & Record<PrettyCamelCase<Name extends string ? Name : SanitizePathSlashes<`${BasePath}${Path}`>>, LiveSdkFunction<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, VersionedApi, Auth>>>;
515
576
  };
516
- registerMiddlewareHandler<Name extends string, Path 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>, LocalsObj extends Record<string, unknown>, const VersionedApi extends VersionSchema<SV, 'middleware'>, const Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(registrationMethod: PathOrMiddlewareBasedHandler<RouterHandler>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler, ...middlewareOrMiddlewareWithTypedHandler: (MiddlewareOrMiddlewareWithTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler)[]): this;
577
+ registerMiddlewareHandler<Name extends string, Path 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>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, 'middleware'>, Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(registrationMethod: PathOrMiddlewareBasedHandler<RouterHandler>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler, ...middlewareOrMiddlewareWithTypedHandler: (MiddlewareOrMiddlewareWithTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | RouterHandler)[]): this;
517
578
  private addRouterToSdk;
518
- registerNestableMiddlewareHandler<Name extends string, Path 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>, LocalsObj extends Record<string, unknown>, const VersionedApi extends VersionSchema<SV, 'middleware'>, const SessionSchema extends SessionObject<SV>, const Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(registrationMethod: NestableRouterBasedHandler<RouterHandler, Internal>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>, ...middlewareOrMiddlewareWithTypedHandler: (MiddlewareOrMiddlewareWithTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>)[]): this;
579
+ registerNestableMiddlewareHandler<Name extends string, Path 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>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, 'middleware'>, const SessionSchema extends SessionObject<SV>, Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>>(registrationMethod: NestableRouterBasedHandler<RouterHandler, Internal>, pathOrContractDetailsOrMiddlewareOrTypedHandler: Path | ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>, contractDetailsOrMiddlewareOrTypedHandler?: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>, ...middlewareOrMiddlewareWithTypedHandler: (MiddlewareOrMiddlewareWithTypedHandler<SV, Name, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth> | ConstrainedForklaunchRouter<SV, RouterHandler>)[]): this;
519
580
  private addRouterOptions;
520
581
  use: TypedNestableMiddlewareDefinition<this, RouterHandler, Internal, SV, RouterSession, BaseRequest, BaseResponse, NextFunction>;
521
582
  all: TypedMiddlewareDefinition<this, SV, RouterSession, BaseRequest, BaseResponse, NextFunction, RouterHandler>;
@@ -701,6 +762,37 @@ declare function createHmacToken({ method, path, body, timestamp, nonce, secretK
701
762
  secretKey: string;
702
763
  }): string;
703
764
 
765
+ /**
766
+ * Generate HMAC authorization headers for service-to-service authentication.
767
+ *
768
+ * @param secretKey - The shared HMAC secret key
769
+ * @param method - HTTP method (GET, POST, etc.)
770
+ * @param path - The API path
771
+ * @param body - Optional request body
772
+ * @param keyId - Optional key identifier (defaults to 'default')
773
+ * @returns Authorization header object
774
+ *
775
+ * @example
776
+ * ```typescript
777
+ * const headers = generateHmacAuthHeaders({
778
+ * secretKey: 'my-secret-key',
779
+ * method: 'POST',
780
+ * path: '/api/users',
781
+ * body: { name: 'John' }
782
+ * });
783
+ * // headers.authorization = 'HMAC keyId=default ts=2024-01-16T12:00:00.000Z nonce=... signature=...'
784
+ * ```
785
+ */
786
+ declare function generateHmacAuthHeaders({ secretKey, method, path, body, keyId }: {
787
+ secretKey: string;
788
+ method: string;
789
+ path: string;
790
+ body?: unknown;
791
+ keyId?: string;
792
+ }): {
793
+ authorization: `HMAC keyId=${string} ts=${string} nonce=${string} signature=${string}`;
794
+ };
795
+
704
796
  /**
705
797
  * Retrieves and caches the JSON Web Key Set (JWKS) from a given public key URL.
706
798
  *
@@ -750,7 +842,7 @@ declare function getCachedJwks(jwksPublicKeyUrl: string): Promise<JWK[]>;
750
842
  * // result.auth === authConfig.basic
751
843
  * ```
752
844
  */
753
- declare function discriminateAuthMethod<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>, VersionedReqs extends VersionedRequests, BaseRequest>(auth: AuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, BaseRequest>): Promise<{
845
+ declare function discriminateAuthMethod<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ReqHeaders extends Record<string, string>, VersionedReqs extends VersionedRequests, BaseRequest>(auth: AuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedReqs, BaseRequest>, openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>): Promise<{
754
846
  type: 'basic';
755
847
  auth: {
756
848
  decodeResource?: DecodeResource;
@@ -940,6 +1032,18 @@ declare const getCodeForStatus: (status: string) => null | StatusCode;
940
1032
  */
941
1033
  declare function generateMcpServer<T extends Record<string, unknown> | undefined = Record<string, unknown> | undefined>(schemaValidator: ZodSchemaValidator, protocol: 'http' | 'https', host: string, port: number, version: `${number}.${number}.${number}`, application: ForklaunchRouter<ZodSchemaValidator>, appOptions?: ExpressLikeApplicationOptions<ZodSchemaValidator, SessionObject<ZodSchemaValidator>>['mcp'], options?: ConstructorParameters<typeof FastMCP<T>>[0], contentTypeMap?: Record<string, string>, authenticate?: (request: http.IncomingMessage) => Promise<Record<string, unknown> | undefined>): FastMCP<Record<string, unknown> | undefined>;
942
1034
 
1035
+ /**
1036
+ * Middleware to create and add a request context.
1037
+ *
1038
+ * @template SV - A type that extends AnySchemaValidator.
1039
+ * @template Request - A type that extends ForklaunchRequest.
1040
+ * @template Response - A type that extends ForklaunchResponse.
1041
+ * @template NextFunction - A type that extends ForklaunchNextFunction.
1042
+ * @param {SV} schemaValidator - The schema validator.
1043
+ * @returns {Function} - Middleware function to create request context.
1044
+ */
1045
+ declare function createContext<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, 'middleware'>, SessionSchema extends SessionObject<SV>>(schemaValidator: SV): ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, SessionSchema, unknown, unknown, ForklaunchNextFunction>;
1046
+
943
1047
  /**
944
1048
  * Enhances the Express-like `send` method with additional logic for response handling and validation.
945
1049
  *
@@ -1023,6 +1127,7 @@ declare function discriminateResponseBodies<SV extends AnySchemaValidator>(schem
1023
1127
 
1024
1128
  declare const ATTR_API_NAME = "api.name";
1025
1129
  declare const ATTR_CORRELATION_ID = "correlation.id";
1130
+ declare const ATTR_APPLICATION_ID = "application_id";
1026
1131
 
1027
1132
  declare function evaluateTelemetryOptions(telemetryOptions: TelemetryOptions): {
1028
1133
  enabled: {
@@ -1053,4 +1158,4 @@ declare function logger(level: LevelWithSilentOrString, meta?: AnyValueMap): Pin
1053
1158
 
1054
1159
  declare function recordMetric<SV extends AnySchemaValidator, P extends ParamsDictionary, ReqBody extends Record<string, unknown>, ReqQuery extends ParsedQs, ResBodyMap extends Record<string, unknown>, ReqHeaders extends Record<string, string>, ResHeaders extends Record<string, unknown>, LocalsObj extends Record<string, unknown>, VersionedReqs extends VersionedRequests, SessionSchema extends Record<string, unknown>>(req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Extract<keyof VersionedReqs, string>, SessionSchema>, res: ForklaunchResponse<unknown, ResBodyMap, ResHeaders, LocalsObj, Extract<keyof VersionedReqs, string>>): void;
1055
1160
 
1056
- export { ATTR_API_NAME, ATTR_CORRELATION_ID, AuthMethods, AuthMethodsBase, BasicAuthMethods, Body, type ClusterConfig, type ConstrainedForklaunchRouter, ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, DecodeResource, ExpressLikeApplicationOptions, type ExpressLikeRouter, ExpressLikeRouterOptions, ExpressLikeSchemaAuthMapper, ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractLiveTypeFn, type FetchFunction, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, ForklaunchRequest, ForklaunchResHeaders, ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, ForklaunchSendableData, ForklaunchStatusResponse, HTTPStatuses, HeadersObject, HttpContractDetails, LiveSdkFunction, LiveTypeFunction, type LiveTypeRouteDefinition, LogFn, LoggerMeta, type MapHandlerToLiveSdk, type MapToFetch, type MapToSdk, Method, MetricsDefinition, MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type NestableRouterBasedHandler, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, ParamsDictionary, ParamsObject, type PathBasedHandler, PathMatch, type PathOrMiddlewareBasedHandler, PathParamHttpContractDetails, PinoLogger, QueryObject, ResolvedSessionObject, ResponsesObject, type RouterMap, type RoutingStrategy, SchemaAuthMethods, type SdkHandler, type SdkHandlerObject, type SdkRouter, SessionObject, type StatusCode, TelemetryOptions, type ToFetchMap, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, VersionSchema, VersionedRequests, createHmacToken, delete_, discriminateAuthMethod, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, generateMcpServer, generateOpenApiSpecs, get, getCachedJwks, getCodeForStatus, head, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, trace, typedAuthHandler, typedHandler };
1161
+ export { ATTR_API_NAME, ATTR_APPLICATION_ID, ATTR_CORRELATION_ID, AuthMethods, AuthMethodsBase, BasicAuthMethods, Body, type ClusterConfig, type ConstrainedForklaunchRouter, ContractDetails, type ContractDetailsExpressLikeSchemaHandler, type ContractDetailsOrMiddlewareOrTypedHandler, DecodeResource, ExpressLikeApplicationOptions, type ExpressLikeRouter, ExpressLikeRouterOptions, ExpressLikeSchemaAuthMapper, ExpressLikeSchemaHandler, type ExpressLikeTypedHandler, type ExtractLiveTypeFn, type FetchFunction, ForklaunchExpressLikeApplication, ForklaunchExpressLikeRouter, ForklaunchNextFunction, ForklaunchRequest, ForklaunchResHeaders, ForklaunchResponse, type ForklaunchRoute, type ForklaunchRouter, ForklaunchSendableData, ForklaunchStatusResponse, HTTPStatuses, HeadersObject, HttpContractDetails, LiveSdkFunction, LiveTypeFunction, type LiveTypeRouteDefinition, LogFn, LoggerMeta, type MapHandlerToLiveSdk, type MapToFetch, type MapToSdk, Method, MetricsDefinition, MiddlewareContractDetails, type MiddlewareOrMiddlewareWithTypedHandler, type NestableRouterBasedHandler, OPENAPI_DEFAULT_VERSION, OpenTelemetryCollector, ParamsDictionary, ParamsObject, type PathBasedHandler, PathMatch, type PathOrMiddlewareBasedHandler, PathParamHttpContractDetails, PinoLogger, QueryObject, ResolvedSessionObject, ResponsesObject, type RouterMap, type RoutingStrategy, SchemaAuthMethods, type SdkHandler, type SdkHandlerObject, type SdkRouter, SessionObject, type StatusCode, TelemetryOptions, type ToFetchMap, type TypedHandler, type TypedMiddlewareDefinition, type TypedNestableMiddlewareDefinition, VersionSchema, VersionedRequests, createContext, createHmacToken, delete_, discriminateAuthMethod, discriminateBody, discriminateResponseBodies, enrichExpressLikeSend, evaluateTelemetryOptions, extractRouteHandlers, generateHmacAuthHeaders, generateMcpServer, generateOpenApiSpecs, get, getCachedJwks, getCodeForStatus, head, isClientError, isForklaunchRequest, isForklaunchRouter, isInformational, isPortBound, isRedirection, isServerError, isSuccessful, isValidStatusCode, logger, meta, metricsDefinitions, middleware, options, patch, post, put, recordMetric, trace, typedAuthHandler, typedHandler };