@forklaunch/core 1.5.1 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cache/{index.d.mts → cacheKey.d.ts} +2 -6
- package/lib/cache/cacheKey.d.ts.map +1 -0
- package/lib/cache/index.d.ts +4 -15
- package/lib/cache/index.d.ts.map +1 -0
- package/lib/{ttlCache.interface-B3xaLT00.d.ts → cache/interfaces/ttlCache.interface.d.ts} +3 -5
- package/lib/cache/interfaces/ttlCache.interface.d.ts.map +1 -0
- package/lib/{ttlCacheRecord.types-oX0ti5SP.d.mts → cache/types/ttlCacheRecord.types.d.ts} +3 -4
- package/lib/cache/types/ttlCacheRecord.types.d.ts.map +1 -0
- package/lib/controllers/index.d.ts +2 -13
- package/lib/controllers/index.d.ts.map +1 -0
- package/lib/controllers/{index.d.mts → interfaces/controller.interface.d.ts} +2 -3
- package/lib/controllers/interfaces/controller.interface.d.ts.map +1 -0
- package/lib/environment/index.d.ts +2 -28
- package/lib/environment/index.d.ts.map +1 -0
- package/lib/environment/{index.d.mts → loadCascadingEnv.d.ts} +4 -5
- package/lib/environment/loadCascadingEnv.d.ts.map +1 -0
- package/lib/http/application/expressLikeApplication.d.ts +34 -0
- package/lib/http/application/expressLikeApplication.d.ts.map +1 -0
- package/lib/http/bootstrap/listen.d.ts +2 -0
- package/lib/http/bootstrap/listen.d.ts.map +1 -0
- package/lib/http/cluster/cluster.types.d.ts +17 -0
- package/lib/http/cluster/cluster.types.d.ts.map +1 -0
- package/lib/http/cluster/isPortBound.d.ts +2 -0
- package/lib/http/cluster/isPortBound.d.ts.map +1 -0
- package/lib/http/createHmacToken.d.ts +19 -0
- package/lib/http/createHmacToken.d.ts.map +1 -0
- package/lib/http/discriminateAuthMethod.d.ts +85 -0
- package/lib/http/discriminateAuthMethod.d.ts.map +1 -0
- package/lib/http/generateHmacAuthHeaders.d.ts +31 -0
- package/lib/http/generateHmacAuthHeaders.d.ts.map +1 -0
- package/lib/http/guards/hasFeatureChecks.d.ts +2 -0
- package/lib/http/guards/hasFeatureChecks.d.ts.map +1 -0
- package/lib/http/guards/hasPermissionChecks.d.ts +2 -0
- package/lib/http/guards/hasPermissionChecks.d.ts.map +1 -0
- package/lib/http/guards/hasRoleChecks.d.ts +2 -0
- package/lib/http/guards/hasRoleChecks.d.ts.map +1 -0
- package/lib/http/guards/hasScopeChecks.d.ts +2 -0
- package/lib/http/guards/hasScopeChecks.d.ts.map +1 -0
- package/lib/http/guards/hasSend.d.ts +17 -0
- package/lib/http/guards/hasSend.d.ts.map +1 -0
- package/lib/http/guards/hasSubscriptionChecks.d.ts +2 -0
- package/lib/http/guards/hasSubscriptionChecks.d.ts.map +1 -0
- package/lib/http/guards/hasVersionedSchema.d.ts +2 -0
- package/lib/http/guards/hasVersionedSchema.d.ts.map +1 -0
- package/lib/http/guards/isBasicAuthMethod.d.ts +3 -0
- package/lib/http/guards/isBasicAuthMethod.d.ts.map +1 -0
- package/lib/http/guards/isConstrainedForklaunchRouter.d.ts +21 -0
- package/lib/http/guards/isConstrainedForklaunchRouter.d.ts.map +1 -0
- package/lib/http/guards/isExpressLikeSchemaHandler.d.ts +32 -0
- package/lib/http/guards/isExpressLikeSchemaHandler.d.ts.map +1 -0
- package/lib/http/guards/isForklaunchExpressLikeRouter.d.ts +28 -0
- package/lib/http/guards/isForklaunchExpressLikeRouter.d.ts.map +1 -0
- package/lib/http/guards/isForklaunchRequest.d.ts +26 -0
- package/lib/http/guards/isForklaunchRequest.d.ts.map +1 -0
- package/lib/http/guards/isForklaunchResponse.d.ts +23 -0
- package/lib/http/guards/isForklaunchResponse.d.ts.map +1 -0
- package/lib/http/guards/isForklaunchRouter.d.ts +21 -0
- package/lib/http/guards/isForklaunchRouter.d.ts.map +1 -0
- package/lib/http/guards/isHmacMethod.d.ts +9 -0
- package/lib/http/guards/isHmacMethod.d.ts.map +1 -0
- package/lib/http/guards/isHttpContractDetails.d.ts +29 -0
- package/lib/http/guards/isHttpContractDetails.d.ts.map +1 -0
- package/lib/http/guards/isJwtAuthMethod.d.ts +3 -0
- package/lib/http/guards/isJwtAuthMethod.d.ts.map +1 -0
- package/lib/http/guards/isLoggerMeta.d.ts +3 -0
- package/lib/http/guards/isLoggerMeta.d.ts.map +1 -0
- package/lib/http/guards/isPath.d.ts +2 -0
- package/lib/http/guards/isPath.d.ts.map +1 -0
- package/lib/http/guards/isPathParamContractDetails.d.ts +4 -0
- package/lib/http/guards/isPathParamContractDetails.d.ts.map +1 -0
- package/lib/http/guards/isRequestShape.d.ts +3 -0
- package/lib/http/guards/isRequestShape.d.ts.map +1 -0
- package/lib/http/guards/isResponseCompiledSchema.d.ts +3 -0
- package/lib/http/guards/isResponseCompiledSchema.d.ts.map +1 -0
- package/lib/http/guards/isSdkHandler.d.ts +9 -0
- package/lib/http/guards/isSdkHandler.d.ts.map +1 -0
- package/lib/http/guards/isSdkRouter.d.ts +9 -0
- package/lib/http/guards/isSdkRouter.d.ts.map +1 -0
- package/lib/http/guards/isTypedHandler.d.ts +5 -0
- package/lib/http/guards/isTypedHandler.d.ts.map +1 -0
- package/lib/http/guards/isVersionedInputSchema.d.ts +3 -0
- package/lib/http/guards/isVersionedInputSchema.d.ts.map +1 -0
- package/lib/http/handlers/delete.d.ts +5 -0
- package/lib/http/handlers/delete.d.ts.map +1 -0
- package/lib/http/handlers/get.d.ts +5 -0
- package/lib/http/handlers/get.d.ts.map +1 -0
- package/lib/http/handlers/head.d.ts +5 -0
- package/lib/http/handlers/head.d.ts.map +1 -0
- package/lib/http/handlers/middleware.d.ts +10 -0
- package/lib/http/handlers/middleware.d.ts.map +1 -0
- package/lib/http/handlers/options.d.ts +5 -0
- package/lib/http/handlers/options.d.ts.map +1 -0
- package/lib/http/handlers/patch.d.ts +5 -0
- package/lib/http/handlers/patch.d.ts.map +1 -0
- package/lib/http/handlers/post.d.ts +5 -0
- package/lib/http/handlers/post.d.ts.map +1 -0
- package/lib/http/handlers/put.d.ts +5 -0
- package/lib/http/handlers/put.d.ts.map +1 -0
- package/lib/http/handlers/trace.d.ts +5 -0
- package/lib/http/handlers/trace.d.ts.map +1 -0
- package/lib/http/handlers/typedAuthHandler.d.ts +5 -0
- package/lib/http/handlers/typedAuthHandler.d.ts.map +1 -0
- package/lib/http/handlers/typedHandler.d.ts +14 -0
- package/lib/http/handlers/typedHandler.d.ts.map +1 -0
- package/lib/http/httpStatusCodes.d.ts +75 -0
- package/lib/http/httpStatusCodes.d.ts.map +1 -0
- package/lib/http/index.d.ts +47 -1244
- package/lib/http/index.d.ts.map +1 -0
- package/lib/http/index.js +445 -410
- package/lib/http/index.js.map +1 -1
- package/lib/http/index.mjs +439 -407
- package/lib/http/index.mjs.map +1 -1
- package/lib/http/interfaces/expressLikeRouter.interface.d.ts +25 -0
- package/lib/http/interfaces/expressLikeRouter.interface.d.ts.map +1 -0
- package/lib/http/mcpGenerator/mcpGenerator.d.ts +17 -0
- package/lib/http/mcpGenerator/mcpGenerator.d.ts.map +1 -0
- package/lib/http/middleware/request/auth.middleware.d.ts +16 -0
- package/lib/http/middleware/request/auth.middleware.d.ts.map +1 -0
- package/lib/http/middleware/request/cors.middleware.d.ts +13 -0
- package/lib/http/middleware/request/cors.middleware.d.ts.map +1 -0
- package/lib/http/middleware/request/createContext.middleware.d.ts +15 -0
- package/lib/http/middleware/request/createContext.middleware.d.ts.map +1 -0
- package/lib/http/middleware/request/enrichDetails.middleware.d.ts +18 -0
- package/lib/http/middleware/request/enrichDetails.middleware.d.ts.map +1 -0
- package/lib/http/middleware/request/parse.middleware.d.ts +17 -0
- package/lib/http/middleware/request/parse.middleware.d.ts.map +1 -0
- package/lib/http/middleware/request/tenantContext.middleware.d.ts +41 -0
- package/lib/http/middleware/request/tenantContext.middleware.d.ts.map +1 -0
- package/lib/http/middleware/response/enrichExpressLikeSend.middleware.d.ts +32 -0
- package/lib/http/middleware/response/enrichExpressLikeSend.middleware.d.ts.map +1 -0
- package/lib/http/middleware/response/parse.middleware.d.ts +31 -0
- package/lib/http/middleware/response/parse.middleware.d.ts.map +1 -0
- package/lib/http/openApiV3Generator/openApiV3Generator.d.ts +17 -0
- package/lib/http/openApiV3Generator/openApiV3Generator.d.ts.map +1 -0
- package/lib/http/rateLimit/index.d.ts +2 -0
- package/lib/http/rateLimit/index.d.ts.map +1 -0
- package/lib/http/rateLimit/rateLimiter.d.ts +66 -0
- package/lib/http/rateLimit/rateLimiter.d.ts.map +1 -0
- package/lib/http/router/discriminateBody.d.ts +43 -0
- package/lib/http/router/discriminateBody.d.ts.map +1 -0
- package/lib/http/router/expressLikeRouter.d.ts +240 -0
- package/lib/http/router/expressLikeRouter.d.ts.map +1 -0
- package/lib/http/router/routerSharedLogic.d.ts +50 -0
- package/lib/http/router/routerSharedLogic.d.ts.map +1 -0
- package/lib/http/router/unpackRouters.d.ts +7 -0
- package/lib/http/router/unpackRouters.d.ts.map +1 -0
- package/lib/http/telemetry/auditLogger.d.ts +21 -0
- package/lib/http/telemetry/auditLogger.d.ts.map +1 -0
- package/lib/http/telemetry/constants.d.ts +6 -0
- package/lib/http/telemetry/constants.d.ts.map +1 -0
- package/lib/http/telemetry/evaluateTelemetryOptions.d.ts +11 -0
- package/lib/http/telemetry/evaluateTelemetryOptions.d.ts.map +1 -0
- package/lib/http/telemetry/metricsDefinition.d.ts +3 -0
- package/lib/http/telemetry/metricsDefinition.d.ts.map +1 -0
- package/lib/http/telemetry/openTelemetryCollector.d.ts +53 -0
- package/lib/http/telemetry/openTelemetryCollector.d.ts.map +1 -0
- package/lib/http/telemetry/pinoLogger.d.ts +20 -0
- package/lib/http/telemetry/pinoLogger.d.ts.map +1 -0
- package/lib/http/telemetry/recordMetric.d.ts +5 -0
- package/lib/http/telemetry/recordMetric.d.ts.map +1 -0
- package/lib/http/types/apiDefinition.types.d.ts +471 -0
- package/lib/http/types/apiDefinition.types.d.ts.map +1 -0
- package/lib/http/types/contractDetails.types.d.ts +404 -0
- package/lib/http/types/contractDetails.types.d.ts.map +1 -0
- package/lib/http/types/docsConfiguration.types.d.ts +7 -0
- package/lib/http/types/docsConfiguration.types.d.ts.map +1 -0
- package/lib/http/types/expressLikeOptions.d.ts +224 -0
- package/lib/http/types/expressLikeOptions.d.ts.map +1 -0
- package/lib/http/types/expressLikeRouter.types.d.ts +127 -0
- package/lib/http/types/expressLikeRouter.types.d.ts.map +1 -0
- package/lib/http/types/openTelemetryCollector.types.d.ts +21 -0
- package/lib/http/types/openTelemetryCollector.types.d.ts.map +1 -0
- package/lib/http/types/router.types.d.ts +52 -0
- package/lib/http/types/router.types.d.ts.map +1 -0
- package/lib/http/types/sdk.types.d.ts +259 -0
- package/lib/http/types/sdk.types.d.ts.map +1 -0
- package/lib/http/types/typedHandler.types.d.ts +18 -0
- package/lib/http/types/typedHandler.types.d.ts.map +1 -0
- package/lib/mappers/guards/isSchemaResolutionFunction.d.ts +10 -0
- package/lib/mappers/guards/isSchemaResolutionFunction.d.ts.map +1 -0
- package/lib/mappers/index.d.ts +3 -68
- package/lib/mappers/index.d.ts.map +1 -0
- package/lib/mappers/mapServiceSchemas.d.ts +33 -0
- package/lib/mappers/mapServiceSchemas.d.ts.map +1 -0
- package/lib/mappers/mapper.d.ts +26 -0
- package/lib/mappers/mapper.d.ts.map +1 -0
- package/lib/mappers/types/schemaResolution.types.d.ts +9 -0
- package/lib/mappers/types/schemaResolution.types.d.ts.map +1 -0
- package/lib/objectstore/index.d.ts +3 -71
- package/lib/objectstore/index.d.ts.map +1 -0
- package/lib/objectstore/{index.d.mts → interfaces/objectstore.interface.d.ts} +3 -16
- package/lib/objectstore/interfaces/objectstore.interface.d.ts.map +1 -0
- package/lib/objectstore/objectstoreKey.d.ts +11 -0
- package/lib/objectstore/objectstoreKey.d.ts.map +1 -0
- package/lib/persistence/complianceEventSubscriber.d.ts +13 -0
- package/lib/persistence/complianceEventSubscriber.d.ts.map +1 -0
- package/lib/persistence/compliancePropertyBuilder.d.ts +26 -0
- package/lib/persistence/compliancePropertyBuilder.d.ts.map +1 -0
- package/lib/persistence/complianceTypes.d.ts +64 -0
- package/lib/persistence/complianceTypes.d.ts.map +1 -0
- package/lib/persistence/defineComplianceEntity.d.ts +19 -0
- package/lib/persistence/defineComplianceEntity.d.ts.map +1 -0
- package/lib/persistence/encryptedType.d.ts +85 -0
- package/lib/persistence/encryptedType.d.ts.map +1 -0
- package/lib/persistence/fieldEncryptor.d.ts +48 -0
- package/lib/persistence/fieldEncryptor.d.ts.map +1 -0
- package/lib/persistence/index.d.ts +10 -403
- package/lib/persistence/index.d.ts.map +1 -0
- package/lib/persistence/index.js.map +1 -1
- package/lib/persistence/index.mjs.map +1 -1
- package/lib/persistence/rls.d.ts +56 -0
- package/lib/persistence/rls.d.ts.map +1 -0
- package/lib/persistence/tenantEm.d.ts +60 -0
- package/lib/persistence/tenantEm.d.ts.map +1 -0
- package/lib/persistence/tenantFilter.d.ts +47 -0
- package/lib/persistence/tenantFilter.d.ts.map +1 -0
- package/lib/secrets/index.d.ts +2 -0
- package/lib/secrets/index.d.ts.map +1 -0
- package/lib/secrets/secretsAccessor.d.ts +17 -0
- package/lib/secrets/secretsAccessor.d.ts.map +1 -0
- package/lib/services/complianceDataService.d.ts +47 -0
- package/lib/services/complianceDataService.d.ts.map +1 -0
- package/lib/services/configInjector.d.ts +43 -0
- package/lib/services/configInjector.d.ts.map +1 -0
- package/lib/services/guards/isConstructed.d.ts +3 -0
- package/lib/services/guards/isConstructed.d.ts.map +1 -0
- package/lib/services/guards/isConstructedSingleton.d.ts +3 -0
- package/lib/services/guards/isConstructedSingleton.d.ts.map +1 -0
- package/lib/services/guards/isConstructor.d.ts +3 -0
- package/lib/services/guards/isConstructor.d.ts.map +1 -0
- package/lib/services/index.d.ts +10 -184
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/retentionService.d.ts +31 -0
- package/lib/services/retentionService.d.ts.map +1 -0
- package/lib/services/runRetentionEnforcement.d.ts +19 -0
- package/lib/services/runRetentionEnforcement.d.ts.map +1 -0
- package/lib/services/types/configInjector.types.d.ts +39 -0
- package/lib/services/types/configInjector.types.d.ts.map +1 -0
- package/lib/services/types/entityManager.types.d.ts +4 -0
- package/lib/services/types/entityManager.types.d.ts.map +1 -0
- package/lib/services/types/service.types.d.ts +5 -0
- package/lib/services/types/service.types.d.ts.map +1 -0
- package/lib/ws/asyncApiV3Generator/asyncApiV3Generator.d.ts +12 -0
- package/lib/ws/asyncApiV3Generator/asyncApiV3Generator.d.ts.map +1 -0
- package/lib/ws/index.d.ts +4 -67
- package/lib/ws/index.d.ts.map +1 -0
- package/lib/ws/index.js.map +1 -1
- package/lib/ws/index.mjs.map +1 -1
- package/lib/ws/types/eventSchema.types.d.ts +28 -0
- package/lib/ws/types/eventSchema.types.d.ts.map +1 -0
- package/lib/ws/webSocketLike.d.ts +18 -0
- package/lib/ws/webSocketLike.d.ts.map +1 -0
- package/package.json +47 -46
- package/LICENSE +0 -21
- package/lib/apiDefinition.types-DF_crhB0.d.mts +0 -1092
- package/lib/apiDefinition.types-DW4lfZqy.d.ts +0 -1092
- package/lib/http/index.d.mts +0 -1244
- package/lib/mappers/index.d.mts +0 -68
- package/lib/openTelemetryCollector-BS-ej09T.d.mts +0 -70
- package/lib/openTelemetryCollector-BS-ej09T.d.ts +0 -70
- package/lib/persistence/index.d.mts +0 -403
- package/lib/services/index.d.mts +0 -185
- package/lib/ttlCache.interface-CEOkrt8d.d.mts +0 -77
- package/lib/ttlCacheRecord.types-oX0ti5SP.d.ts +0 -25
- package/lib/ws/index.d.mts +0 -67
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IncomingMessage, ServerOptions, ServerResponse } from 'node:http';
|
|
2
|
+
export interface PathBasedHandler<RouterHandler> {
|
|
3
|
+
(path: string, ...handlers: RouterHandler[]): unknown;
|
|
4
|
+
}
|
|
5
|
+
export interface PathOrMiddlewareBasedHandler<RouterHandler> extends PathBasedHandler<RouterHandler> {
|
|
6
|
+
(...args: RouterHandler[]): unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface NestableRouterBasedHandler<RouterHandler, Router> extends PathOrMiddlewareBasedHandler<RouterHandler> {
|
|
9
|
+
(...args: (Router | RouterHandler)[]): unknown;
|
|
10
|
+
(path: string, ...handlers: (Router | RouterHandler)[]): unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface ExpressLikeRouter<RouterHandler, Router> extends ServerOptions<typeof IncomingMessage, typeof ServerResponse> {
|
|
13
|
+
use: NestableRouterBasedHandler<RouterHandler, Router>;
|
|
14
|
+
all: PathOrMiddlewareBasedHandler<RouterHandler>;
|
|
15
|
+
connect: PathOrMiddlewareBasedHandler<RouterHandler>;
|
|
16
|
+
get: PathBasedHandler<RouterHandler>;
|
|
17
|
+
post: PathBasedHandler<RouterHandler>;
|
|
18
|
+
put: PathBasedHandler<RouterHandler>;
|
|
19
|
+
patch: PathBasedHandler<RouterHandler>;
|
|
20
|
+
delete: PathBasedHandler<RouterHandler>;
|
|
21
|
+
options: PathBasedHandler<RouterHandler>;
|
|
22
|
+
head: PathBasedHandler<RouterHandler>;
|
|
23
|
+
trace: PathBasedHandler<RouterHandler>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=expressLikeRouter.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expressLikeRouter.interface.d.ts","sourceRoot":"","sources":["../../../src/http/interfaces/expressLikeRouter.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3E,MAAM,WAAW,gBAAgB,CAAC,aAAa;IAC7C,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;CACvD;AAED,MAAM,WAAW,4BAA4B,CAC3C,aAAa,CACb,SAAQ,gBAAgB,CAAC,aAAa,CAAC;IACvC,CAAC,GAAG,IAAI,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,0BAA0B,CACzC,aAAa,EACb,MAAM,CACN,SAAQ,4BAA4B,CAAC,aAAa,CAAC;IACnD,CAAC,GAAG,IAAI,EAAE,CAAC,MAAM,GAAG,aAAa,CAAC,EAAE,GAAG,OAAO,CAAC;IAC/C,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC,MAAM,GAAG,aAAa,CAAC,EAAE,GAAG,OAAO,CAAC;CAClE;AAED,MAAM,WAAW,iBAAiB,CAAC,aAAa,EAAE,MAAM,CAAE,SAAQ,aAAa,CAC7E,OAAO,eAAe,EACtB,OAAO,cAAc,CACtB;IACC,GAAG,EAAE,0BAA0B,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACvD,GAAG,EAAE,4BAA4B,CAAC,aAAa,CAAC,CAAC;IACjD,OAAO,EAAE,4BAA4B,CAAC,aAAa,CAAC,CAAC;IACrD,GAAG,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACrC,IAAI,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACtC,GAAG,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACrC,KAAK,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACvC,MAAM,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACzC,IAAI,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACtC,KAAK,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CACxC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ZodSchemaValidator } from '@forklaunch/validator/zod';
|
|
2
|
+
import { FastMCP } from 'fastmcp';
|
|
3
|
+
import http from 'http';
|
|
4
|
+
import { SessionObject } from '../types/contractDetails.types';
|
|
5
|
+
import { ExpressLikeApplicationOptions } from '../types/expressLikeOptions';
|
|
6
|
+
import { ForklaunchRouter } from '../types/router.types';
|
|
7
|
+
/**
|
|
8
|
+
* Generates a ModelContextProtocol server from given routers.
|
|
9
|
+
*
|
|
10
|
+
* @template SV - A type that extends AnySchemaValidator.
|
|
11
|
+
* @param {SV} schemaValidator - The schema validator.
|
|
12
|
+
* @param {string | number} port - The port on which the server is running.
|
|
13
|
+
* @param {ForklaunchRouter<SV>[]} routers - The routers to include in the server.
|
|
14
|
+
* @returns {McpServer} - The generated ModelContextProtocol server.
|
|
15
|
+
*/
|
|
16
|
+
export 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>;
|
|
17
|
+
//# sourceMappingURL=mcpGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpGenerator.d.ts","sourceRoot":"","sources":["../../../src/http/mcpGenerator/mcpGenerator.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,kBAAkB,EAAW,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,MAAM,CAAC;AAMxB,OAAO,EAOL,aAAa,EAEd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAyDzD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC3C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAErC,eAAe,EAAE,kBAAkB,EACnC,QAAQ,EAAE,MAAM,GAAG,OAAO,EAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,EACxC,WAAW,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,EACjD,UAAU,CAAC,EAAE,6BAA6B,CACxC,kBAAkB,EAClB,aAAa,CAAC,kBAAkB,CAAC,CAClC,CAAC,KAAK,CAAC,EACR,OAAO,CAAC,EAAE,qBAAqB,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACrD,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACvC,YAAY,CAAC,EAAE,CACb,OAAO,EAAE,IAAI,CAAC,eAAe,KAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,gDAuQlD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
2
|
+
import { ForklaunchNextFunction, ForklaunchRequest, ForklaunchResponse, MapParamsSchema, MapReqBodySchema, MapReqHeadersSchema, MapReqQuerySchema, MapResBodyMapSchema, MapResHeadersSchema, MapSessionSchema, MapVersionedReqsSchema } from '../../types/apiDefinition.types';
|
|
3
|
+
import { Body, HeadersObject, Method, ParamsObject, QueryObject, ResponsesObject, SessionObject, VersionSchema } from '../../types/contractDetails.types';
|
|
4
|
+
/**
|
|
5
|
+
* Middleware to parse request authorization.
|
|
6
|
+
*
|
|
7
|
+
* @template SV - A type that extends AnySchemaValidator.
|
|
8
|
+
* @template Request - A type that extends ForklaunchRequest.
|
|
9
|
+
* @template Response - A type that extends ForklaunchResponse.
|
|
10
|
+
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
|
11
|
+
* @param {Request} req - The request object.
|
|
12
|
+
* @param {Response} res - The response object.
|
|
13
|
+
* @param {NextFunction} [next] - The next middleware function.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseRequestAuth<SV extends AnySchemaValidator, ContractMethod extends Method, 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>, SessionSchema extends SessionObject<SV>>(req: ForklaunchRequest<SV, MapParamsSchema<SV, P>, MapReqBodySchema<SV, ReqBody>, MapReqQuerySchema<SV, ReqQuery>, MapReqHeadersSchema<SV, ReqHeaders>, Extract<keyof MapVersionedReqsSchema<SV, VersionedApi>, string>, MapSessionSchema<SV, SessionSchema>>, res: ForklaunchResponse<unknown, MapResBodyMapSchema<SV, ResBodyMap>, MapResHeadersSchema<SV, ResHeaders>, LocalsObj, Extract<keyof MapVersionedReqsSchema<SV, VersionedApi>, string>>, next?: ForklaunchNextFunction): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=auth.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.middleware.d.ts","sourceRoot":"","sources":["../../../../src/http/middleware/request/auth.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAGnB,MAAM,uBAAuB,CAAC;AAW/B,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EAGvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,IAAI,EACJ,aAAa,EACb,MAAM,EAEN,YAAY,EACZ,WAAW,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,mCAAmC,CAAC;AAqe3C;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,SAAS,kBAAkB,EAC7B,cAAc,SAAS,MAAM,EAC7B,CAAC,SAAS,YAAY,CAAC,EAAE,CAAC,EAC1B,UAAU,SAAS,eAAe,CAAC,EAAE,CAAC,EACtC,OAAO,SAAS,IAAI,CAAC,EAAE,CAAC,EACxB,QAAQ,SAAS,WAAW,CAAC,EAAE,CAAC,EAChC,UAAU,SAAS,aAAa,CAAC,EAAE,CAAC,EACpC,UAAU,SAAS,aAAa,CAAC,EAAE,CAAC,EACpC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,YAAY,SAAS,aAAa,CAAC,EAAE,EAAE,cAAc,CAAC,EACtD,aAAa,SAAS,aAAa,CAAC,EAAE,CAAC,EAEvC,GAAG,EAAE,iBAAiB,CACpB,EAAE,EACF,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC,EACtB,gBAAgB,CAAC,EAAE,EAAE,OAAO,CAAC,EAC7B,iBAAiB,CAAC,EAAE,EAAE,QAAQ,CAAC,EAC/B,mBAAmB,CAAC,EAAE,EAAE,UAAU,CAAC,EACnC,OAAO,CAAC,MAAM,sBAAsB,CAAC,EAAE,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,EAC/D,gBAAgB,CAAC,EAAE,EAAE,aAAa,CAAC,CACpC,EACD,GAAG,EAAE,kBAAkB,CACrB,OAAO,EACP,mBAAmB,CAAC,EAAE,EAAE,UAAU,CAAC,EACnC,mBAAmB,CAAC,EAAE,EAAE,UAAU,CAAC,EACnC,SAAS,EACT,OAAO,CAAC,MAAM,sBAAsB,CAAC,EAAE,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,CAChE,EACD,IAAI,CAAC,EAAE,sBAAsB,iBAsD9B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CorsOptions } from 'cors';
|
|
2
|
+
import { ParsedQs } from 'qs';
|
|
3
|
+
import { ForklaunchBaseRequest, ForklaunchNextFunction, ForklaunchResHeaders, ForklaunchResponse } from '../../types/apiDefinition.types';
|
|
4
|
+
import { ParamsDictionary } from '../../types/contractDetails.types';
|
|
5
|
+
/**
|
|
6
|
+
* Cors middleware handler
|
|
7
|
+
*
|
|
8
|
+
* @param req - Express-like request object
|
|
9
|
+
* @param res - Express-like response object
|
|
10
|
+
* @param next - Express-like next function
|
|
11
|
+
*/
|
|
12
|
+
export declare function cors<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, unknown>, LocalsObj extends Record<string, unknown>>(corsOptions: CorsOptions): (req: ForklaunchBaseRequest<P, ReqBody, ReqQuery, ReqHeaders>, res: ForklaunchResponse<unknown, ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj, never>, next?: ForklaunchNextFunction) => void;
|
|
13
|
+
//# sourceMappingURL=cors.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cors.middleware.d.ts","sourceRoot":"","sources":["../../../../src/http/middleware/request/cors.middleware.ts"],"names":[],"mappings":"AAAA,OAAuB,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE;;;;;;GAMG;AACH,wBAAgB,IAAI,CAClB,CAAC,SAAS,gBAAgB,EAC1B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,QAAQ,SAAS,QAAQ,EACzB,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,WAAW,EAAE,WAAW,SAEjB,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,OACvD,kBAAkB,CACrB,OAAO,EACP,UAAU,EACV,oBAAoB,GAAG,UAAU,EACjC,SAAS,EACT,KAAK,CACN,SACM,sBAAsB,UAgBhC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
2
|
+
import { ExpressLikeSchemaHandler, ForklaunchNextFunction } from '../../types/apiDefinition.types';
|
|
3
|
+
import { Body, HeadersObject, ParamsObject, QueryObject, ResponsesObject, SessionObject, VersionSchema } from '../../types/contractDetails.types';
|
|
4
|
+
/**
|
|
5
|
+
* Middleware to create and add a request context.
|
|
6
|
+
*
|
|
7
|
+
* @template SV - A type that extends AnySchemaValidator.
|
|
8
|
+
* @template Request - A type that extends ForklaunchRequest.
|
|
9
|
+
* @template Response - A type that extends ForklaunchResponse.
|
|
10
|
+
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
|
11
|
+
* @param {SV} schemaValidator - The schema validator.
|
|
12
|
+
* @returns {Function} - Middleware function to create request context.
|
|
13
|
+
*/
|
|
14
|
+
export 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>;
|
|
15
|
+
//# sourceMappingURL=createContext.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContext.middleware.d.ts","sourceRoot":"","sources":["../../../../src/http/middleware/request/createContext.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAS3D,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EAGvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,mCAAmC,CAAC;AAE3C;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,EAAE,SAAS,kBAAkB,EAC7B,CAAC,SAAS,YAAY,CAAC,EAAE,CAAC,EAC1B,UAAU,SAAS,eAAe,CAAC,EAAE,CAAC,EACtC,OAAO,SAAS,IAAI,CAAC,EAAE,CAAC,EACxB,QAAQ,SAAS,WAAW,CAAC,EAAE,CAAC,EAChC,UAAU,SAAS,aAAa,CAAC,EAAE,CAAC,EACpC,UAAU,SAAS,aAAa,CAAC,EAAE,CAAC,EACpC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,YAAY,SAAS,aAAa,CAAC,EAAE,EAAE,YAAY,CAAC,EACpD,aAAa,SAAS,aAAa,CAAC,EAAE,CAAC,EAEvC,eAAe,EAAE,EAAE,GAClB,wBAAwB,CACzB,EAAE,EACF,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,OAAO,EACP,OAAO,EACP,sBAAsB,CACvB,CAsDA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
2
|
+
import { OpenTelemetryCollector } from '../../telemetry/openTelemetryCollector';
|
|
3
|
+
import { ExpressLikeSchemaHandler, ForklaunchNextFunction } from '../../types/apiDefinition.types';
|
|
4
|
+
import { Body, HeadersObject, HttpContractDetails, Method, ParamsObject, PathParamHttpContractDetails, QueryObject, ResponseCompiledSchema, ResponsesObject, SessionObject, VersionSchema } from '../../types/contractDetails.types';
|
|
5
|
+
import { ExpressLikeRouterOptions } from '../../types/expressLikeOptions';
|
|
6
|
+
import { MetricsDefinition } from '../../types/openTelemetryCollector.types';
|
|
7
|
+
/**
|
|
8
|
+
* Middleware to enrich the request details with contract details.
|
|
9
|
+
*
|
|
10
|
+
* @template SV - A type that extends AnySchemaValidator.
|
|
11
|
+
* @template Request - A type that extends ForklaunchRequest.
|
|
12
|
+
* @template Response - A type that extends ForklaunchResponse.
|
|
13
|
+
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
|
14
|
+
* @param {PathParamHttpContractDetails<SV> | HttpContractDetails<SV>} contractDetails - The contract details.
|
|
15
|
+
* @returns {Function} - Middleware function to enrich request details.
|
|
16
|
+
*/
|
|
17
|
+
export declare function enrichDetails<SV extends AnySchemaValidator, ContractMethod extends Method, 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>, SessionSchema extends SessionObject<SV>>(path: string, contractDetails: HttpContractDetails<SV> | PathParamHttpContractDetails<SV>, requestSchema: unknown | Record<string, unknown>, responseSchemas: ResponseCompiledSchema | Record<string, ResponseCompiledSchema>, openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>, globalOptions?: () => ExpressLikeRouterOptions<SV, SessionSchema> | undefined): ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, SessionSchema, unknown, unknown, ForklaunchNextFunction>;
|
|
18
|
+
//# sourceMappingURL=enrichDetails.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichDetails.middleware.d.ts","sourceRoot":"","sources":["../../../../src/http/middleware/request/enrichDetails.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAS3D,OAAO,EAEL,sBAAsB,EACvB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,IAAI,EACJ,aAAa,EACb,mBAAmB,EACnB,MAAM,EACN,YAAY,EACZ,4BAA4B,EAC5B,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,EAAE,SAAS,kBAAkB,EAC7B,cAAc,SAAS,MAAM,EAC7B,CAAC,SAAS,YAAY,CAAC,EAAE,CAAC,EAC1B,UAAU,SAAS,eAAe,CAAC,EAAE,CAAC,EACtC,OAAO,SAAS,IAAI,CAAC,EAAE,CAAC,EACxB,QAAQ,SAAS,WAAW,CAAC,EAAE,CAAC,EAChC,UAAU,SAAS,aAAa,CAAC,EAAE,CAAC,EACpC,UAAU,SAAS,aAAa,CAAC,EAAE,CAAC,EACpC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,YAAY,SAAS,aAAa,CAAC,EAAE,EAAE,cAAc,CAAC,EACtD,aAAa,SAAS,aAAa,CAAC,EAAE,CAAC,EAEvC,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,mBAAmB,CAAC,EAAE,CAAC,GAAG,4BAA4B,CAAC,EAAE,CAAC,EAC3E,aAAa,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChD,eAAe,EACb,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,EACjE,sBAAsB,CAAC,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,EAClE,aAAa,CAAC,EAAE,MAAM,wBAAwB,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,SAAS,GAC5E,wBAAwB,CACzB,EAAE,EACF,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,OAAO,EACP,OAAO,EACP,sBAAsB,CACvB,CA4BA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
2
|
+
import { ParsedQs } from 'qs';
|
|
3
|
+
import { ForklaunchNextFunction, ForklaunchRequest, ForklaunchResponse, VersionedRequests } from '../../types/apiDefinition.types';
|
|
4
|
+
import { ParamsDictionary } from '../../types/contractDetails.types';
|
|
5
|
+
/**
|
|
6
|
+
* Pre-handler function to parse and validate input.
|
|
7
|
+
*
|
|
8
|
+
* @template SV - A type that extends AnySchemaValidator.
|
|
9
|
+
* @template Request - A type that extends ForklaunchRequest.
|
|
10
|
+
* @template Response - A type that extends ForklaunchResponse.
|
|
11
|
+
* @template NextFunction - A type that extends ForklaunchNextFunction.
|
|
12
|
+
* @param {Request} req - The request object.
|
|
13
|
+
* @param {Response} res - The response object.
|
|
14
|
+
* @param {NextFunction} [next] - The next middleware function.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parse<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, 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>>, next?: ForklaunchNextFunction): void;
|
|
17
|
+
//# sourceMappingURL=parse.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.middleware.d.ts","sourceRoot":"","sources":["../../../../src/http/middleware/request/parse.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAInB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAG9B,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CACnB,EAAE,SAAS,kBAAkB,EAC7B,CAAC,SAAS,gBAAgB,EAC1B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,QAAQ,SAAS,QAAQ,EACzB,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,SAAS,iBAAiB,EACvC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE7C,GAAG,EAAE,iBAAiB,CACpB,EAAE,EACF,CAAC,EACD,OAAO,EACP,QAAQ,EACR,UAAU,EACV,OAAO,CAAC,MAAM,aAAa,EAAE,MAAM,CAAC,EACpC,aAAa,CACd,EACD,GAAG,EAAE,kBAAkB,CACrB,OAAO,EACP,UAAU,EACV,UAAU,EACV,SAAS,EACT,OAAO,CAAC,MAAM,aAAa,EAAE,MAAM,CAAC,CACrC,EACD,IAAI,CAAC,EAAE,sBAAsB,QAuI9B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural request type for tenant context middleware.
|
|
3
|
+
* Accepts any object with the properties the middleware actually reads.
|
|
4
|
+
*/
|
|
5
|
+
export interface TenantContextRequest {
|
|
6
|
+
contractDetails: Record<string, unknown>;
|
|
7
|
+
session?: Record<string, unknown>;
|
|
8
|
+
headers: Record<string, unknown>;
|
|
9
|
+
em?: TenantFilterable;
|
|
10
|
+
schemaValidator?: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Structural response type for tenant context middleware.
|
|
14
|
+
* Only `status` and `send` are used (for 403 responses).
|
|
15
|
+
*/
|
|
16
|
+
export interface TenantContextResponse {
|
|
17
|
+
status(code: number): TenantContextResponse;
|
|
18
|
+
send(body?: unknown): TenantContextResponse;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Middleware that establishes tenant context on the request-scoped
|
|
22
|
+
* EntityManager. Runs after auth middleware.
|
|
23
|
+
*
|
|
24
|
+
* - For `'protected'`/`'authenticated'` routes: reads tenant ID from
|
|
25
|
+
* `req.session.organizationId` or `req.session.activeOrganizationId`.
|
|
26
|
+
* Returns 403 if missing.
|
|
27
|
+
* - For `'internal'` routes: reads tenant ID from `X-Tenant-Id` header
|
|
28
|
+
* or from the session if available.
|
|
29
|
+
* - For `'public'` routes: skips tenant context — filter remains unset.
|
|
30
|
+
*
|
|
31
|
+
* The middleware:
|
|
32
|
+
* 1. Sets the tenant filter params on the EM: `em.setFilterParams('tenant', { tenantId })`
|
|
33
|
+
* 2. Wraps the EM with native query blocking for compliance entities
|
|
34
|
+
*/
|
|
35
|
+
export declare function setTenantContext(req: TenantContextRequest, res: TenantContextResponse, next?: (() => void) | undefined): Promise<void>;
|
|
36
|
+
/** Minimal interface for setting filter params — avoids importing full EntityManager. */
|
|
37
|
+
interface TenantFilterable {
|
|
38
|
+
setFilterParams(name: string, params: Record<string, unknown>): void;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=tenantContext.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenantContext.middleware.d.ts","sourceRoot":"","sources":["../../../../src/http/middleware/request/tenantContext.middleware.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,EAAE,CAAC,EAAE,gBAAgB,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAC;IAC5C,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,qBAAqB,CAAC;CAC7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,oBAAoB,EACzB,GAAG,EAAE,qBAAqB,EAC1B,IAAI,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,GAC9B,OAAO,CAAC,IAAI,CAAC,CAgCf;AAED,yFAAyF;AACzF,UAAU,gBAAgB;IACxB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACtE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
2
|
+
import { ParsedQs } from 'qs';
|
|
3
|
+
import { ForklaunchRequest, ForklaunchResHeaders, ForklaunchResponse, ForklaunchSendableData, ForklaunchStatusResponse, VersionedRequests } from '../../types/apiDefinition.types';
|
|
4
|
+
import { ParamsDictionary } from '../../types/contractDetails.types';
|
|
5
|
+
/**
|
|
6
|
+
* Enhances the Express-like `send` method with additional logic for response handling and validation.
|
|
7
|
+
*
|
|
8
|
+
* This function intercepts the `send` method to provide custom behavior, including response validation
|
|
9
|
+
* through the `parseResponse` middleware. If the response status is 404, it sends a "Not Found" message.
|
|
10
|
+
* If the response validation fails, it sends a parsing error message. Otherwise, it calls the original `send`
|
|
11
|
+
* method with the provided data.
|
|
12
|
+
*
|
|
13
|
+
* @template SV - The type of the schema validator used in the request.
|
|
14
|
+
* @template P - The type of the parameters dictionary used in the request.
|
|
15
|
+
* @template ResBodyMap - A record type mapping status codes to response body types.
|
|
16
|
+
* @template ReqBody - The type of the request body.
|
|
17
|
+
* @template ReqQuery - The type of the parsed query string.
|
|
18
|
+
* @template ReqHeaders - The type of the request headers.
|
|
19
|
+
* @template ResHeaders - The type of the response headers, extended from `ForklaunchResHeaders`.
|
|
20
|
+
* @template LocalsObj - The type of the locals object in the response.
|
|
21
|
+
*
|
|
22
|
+
* @param {unknown} instance - The context (typically `this`) in which the original `send` method is called.
|
|
23
|
+
* @param {ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>} req - The request object, containing the schema validator and other request data.
|
|
24
|
+
* @param {ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>} res - The response object, including headers and body data.
|
|
25
|
+
* @param {Function} originalSend - The original `send` method from the response object, to be called after custom logic.
|
|
26
|
+
* @param {string | ArrayBuffer | ArrayBufferView | NodeJS.ReadableStream | null | undefined} data - The data to be sent as the response body.
|
|
27
|
+
* @param {boolean} shouldEnrich - A flag indicating whether the response should be sent immediately.
|
|
28
|
+
*
|
|
29
|
+
* @returns {unknown} The return value of the original `send` method, typically the response itself.
|
|
30
|
+
*/
|
|
31
|
+
export declare function enrichExpressLikeSend<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, unknown>, LocalsObj extends Record<string, unknown>, VersionedReqs extends VersionedRequests, SessionSchema extends Record<string, unknown>>(instance: unknown, req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders, Extract<keyof VersionedReqs, string>, SessionSchema>, res: ForklaunchResponse<unknown, ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj, Extract<keyof VersionedReqs, string>>, originalOperation: ForklaunchStatusResponse<ForklaunchSendableData>['json'] | ForklaunchStatusResponse<ForklaunchSendableData>['jsonp'], originalSend: ForklaunchStatusResponse<ForklaunchSendableData>['send'], data: ForklaunchSendableData | File | Blob | AsyncGenerator<Record<string, unknown>> | null | undefined, shouldEnrich: boolean): void;
|
|
32
|
+
//# sourceMappingURL=enrichExpressLikeSend.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichExpressLikeSend.middleware.d.ts","sourceRoot":"","sources":["../../../../src/http/middleware/response/enrichExpressLikeSend.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAc9B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,SAAS,kBAAkB,EAC7B,CAAC,SAAS,gBAAgB,EAC1B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,QAAQ,SAAS,QAAQ,EACzB,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,SAAS,iBAAiB,EACvC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE7C,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,iBAAiB,CACpB,EAAE,EACF,CAAC,EACD,OAAO,EACP,QAAQ,EACR,UAAU,EACV,OAAO,CAAC,MAAM,aAAa,EAAE,MAAM,CAAC,EACpC,aAAa,CACd,EACD,GAAG,EAAE,kBAAkB,CACrB,OAAO,EACP,UAAU,EACV,oBAAoB,GAAG,UAAU,EACjC,SAAS,EACT,OAAO,CAAC,MAAM,aAAa,EAAE,MAAM,CAAC,CACrC,EACD,iBAAiB,EACb,wBAAwB,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,GACxD,wBAAwB,CAAC,sBAAsB,CAAC,CAAC,OAAO,CAAC,EAC7D,YAAY,EAAE,wBAAwB,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,EACtE,IAAI,EACA,sBAAsB,GACtB,IAAI,GACJ,IAAI,GACJ,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACvC,IAAI,GACJ,SAAS,EACb,YAAY,EAAE,OAAO,QA8KtB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
2
|
+
import { ParsedQs } from 'qs';
|
|
3
|
+
import { ForklaunchNextFunction, ForklaunchRequest, ForklaunchResHeaders, ForklaunchResponse, VersionedRequests } from '../../types/apiDefinition.types';
|
|
4
|
+
import { ParamsDictionary } from '../../types/contractDetails.types';
|
|
5
|
+
/**
|
|
6
|
+
* Middleware to parse and validate the response according to the provided schema.
|
|
7
|
+
*
|
|
8
|
+
* This function validates the response against a schema provided by the request's schema validator.
|
|
9
|
+
* If the response does not conform to the schema, the behavior is determined by the `responseValidation`
|
|
10
|
+
* option in `req.contractDetails.options`:
|
|
11
|
+
* - `'error'` (default): Calls `next` with an error.
|
|
12
|
+
* - `'warning'`: Logs a warning to the console.
|
|
13
|
+
* - `'none'`: Silently continues without action.
|
|
14
|
+
*
|
|
15
|
+
* @template SV - The type of the schema validator used in the request.
|
|
16
|
+
* @template P - The type of the parameters dictionary used in the request.
|
|
17
|
+
* @template ResBodyMap - A record type mapping status codes to response body types.
|
|
18
|
+
* @template ReqBody - The type of the request body.
|
|
19
|
+
* @template ReqQuery - The type of the parsed query string.
|
|
20
|
+
* @template ReqHeaders - The type of the request headers.
|
|
21
|
+
* @template ResHeaders - The type of the response headers, extended from `ForklaunchResHeaders`.
|
|
22
|
+
* @template LocalsObj - The type of the locals object in the response.
|
|
23
|
+
*
|
|
24
|
+
* @param {ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>} req - The request object, containing the schema validator and other request data.
|
|
25
|
+
* @param {ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>} res - The response object, including headers and body data.
|
|
26
|
+
* @param {ForklaunchNextFunction} [next] - The next middleware function to be called. If not provided, the function will return after processing.
|
|
27
|
+
*
|
|
28
|
+
* @returns {void} This function does not return a value.
|
|
29
|
+
*/
|
|
30
|
+
export declare function parse<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, 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, ForklaunchResHeaders & ResHeaders, LocalsObj, Extract<keyof VersionedReqs, string>>, next?: ForklaunchNextFunction): void;
|
|
31
|
+
//# sourceMappingURL=parse.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.middleware.d.ts","sourceRoot":"","sources":["../../../../src/http/middleware/response/parse.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAG9B,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,KAAK,CACnB,EAAE,SAAS,kBAAkB,EAC7B,CAAC,SAAS,gBAAgB,EAC1B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,QAAQ,SAAS,QAAQ,EACzB,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,SAAS,iBAAiB,EACvC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE7C,GAAG,EAAE,iBAAiB,CACpB,EAAE,EACF,CAAC,EACD,OAAO,EACP,QAAQ,EACR,UAAU,EACV,OAAO,CAAC,MAAM,aAAa,EAAE,MAAM,CAAC,EACpC,aAAa,CACd,EACD,GAAG,EAAE,kBAAkB,CACrB,OAAO,EACP,UAAU,EACV,oBAAoB,GAAG,UAAU,EACjC,SAAS,EACT,OAAO,CAAC,MAAM,aAAa,EAAE,MAAM,CAAC,CACrC,EACD,IAAI,CAAC,EAAE,sBAAsB,QAoH9B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
2
|
+
import { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
3
|
+
import { SessionObject } from '../types/contractDetails.types';
|
|
4
|
+
import { ExpressLikeApplicationOptions } from '../types/expressLikeOptions';
|
|
5
|
+
import { ForklaunchRouter } from '../types/router.types';
|
|
6
|
+
export declare const OPENAPI_DEFAULT_VERSION: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* Generates a Swagger document from given routers.
|
|
9
|
+
*
|
|
10
|
+
* @template SV - A type that extends AnySchemaValidator.
|
|
11
|
+
* @param {SV} schemaValidator - The schema validator.
|
|
12
|
+
* @param {string | number} port - The port on which the server is running.
|
|
13
|
+
* @param {ForklaunchRouter<SV>[]} routers - The routers to include in the Swagger document.
|
|
14
|
+
* @returns {OpenAPIObject} - The generated Swagger document.
|
|
15
|
+
*/
|
|
16
|
+
export declare function generateOpenApiSpecs<SV extends AnySchemaValidator>(schemaValidator: SV, serverUrls: string[], serverDescriptions: string[], application: ForklaunchRouter<SV>, appOptions?: ExpressLikeApplicationOptions<SV, SessionObject<SV>>['openapi']): Record<string | symbol, OpenAPIObject>;
|
|
17
|
+
//# sourceMappingURL=openApiV3Generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openApiV3Generator.d.ts","sourceRoot":"","sources":["../../../src/http/openApiV3Generator/openApiV3Generator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAGnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,aAAa,EAOd,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAQL,aAAa,EAEd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,eAAO,MAAM,uBAAuB,eAAoB,CAAC;AAiTzD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,SAAS,kBAAkB,EAChE,eAAe,EAAE,EAAE,EACnB,UAAU,EAAE,MAAM,EAAE,EACpB,kBAAkB,EAAE,MAAM,EAAE,EAC5B,WAAW,EAAE,gBAAgB,CAAC,EAAE,CAAC,EACjC,UAAU,CAAC,EAAE,6BAA6B,CAAC,EAAE,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,GAC3E,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,aAAa,CAAC,CAsJxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/http/rateLimit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { TtlCache } from '../../cache/interfaces/ttlCache.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for rate limiting with separate read/write limits.
|
|
4
|
+
*/
|
|
5
|
+
export type RateLimitConfig = {
|
|
6
|
+
/** Max requests per window for GET/HEAD/OPTIONS */
|
|
7
|
+
read: number;
|
|
8
|
+
/** Max requests per window for POST/PUT/PATCH/DELETE */
|
|
9
|
+
write: number;
|
|
10
|
+
/** Window duration in milliseconds */
|
|
11
|
+
windowMs: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Result of a rate limit check.
|
|
15
|
+
*/
|
|
16
|
+
export type RateLimitResult = {
|
|
17
|
+
/** Whether the request is allowed */
|
|
18
|
+
allowed: boolean;
|
|
19
|
+
/** Number of remaining requests in the current window */
|
|
20
|
+
remaining: number;
|
|
21
|
+
/** Unix timestamp (ms) when the current window resets */
|
|
22
|
+
resetAt: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Rate limiter backed by a TtlCache.
|
|
26
|
+
*
|
|
27
|
+
* Uses a sliding-window counter pattern: each unique key maps to a
|
|
28
|
+
* {@link RateLimitCounter} stored in the cache with a TTL equal to the
|
|
29
|
+
* configured window duration.
|
|
30
|
+
*/
|
|
31
|
+
export declare class RateLimiter {
|
|
32
|
+
private cache;
|
|
33
|
+
constructor(cache: TtlCache);
|
|
34
|
+
/**
|
|
35
|
+
* Check whether the given key is within its rate limit.
|
|
36
|
+
*
|
|
37
|
+
* The counter is read from the cache, incremented, and written back.
|
|
38
|
+
* If the cache is unreachable the limiter **fails open** (allows the
|
|
39
|
+
* request) so that a cache outage does not take down the service.
|
|
40
|
+
*
|
|
41
|
+
* @param key - The rate limit key (see {@link RateLimiter.buildKey}).
|
|
42
|
+
* @param limit - Maximum number of requests allowed in the window.
|
|
43
|
+
* @param windowMs - Window duration in milliseconds.
|
|
44
|
+
*/
|
|
45
|
+
check(key: string, limit: number, windowMs: number): Promise<RateLimitResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Build a rate limit key from request context parts.
|
|
48
|
+
*
|
|
49
|
+
* Format: `ratelimit:{tenantId}:{route}:{userId}:{operationType}`
|
|
50
|
+
*
|
|
51
|
+
* When `tenantId` or `userId` is `null`, the placeholder `"anon"` is used.
|
|
52
|
+
*/
|
|
53
|
+
static buildKey(parts: {
|
|
54
|
+
tenantId: string | null;
|
|
55
|
+
route: string;
|
|
56
|
+
userId: string | null;
|
|
57
|
+
operationType: 'read' | 'write';
|
|
58
|
+
}): string;
|
|
59
|
+
/**
|
|
60
|
+
* Determine whether an HTTP method is a read or write operation.
|
|
61
|
+
*
|
|
62
|
+
* GET, HEAD, and OPTIONS are reads; everything else is a write.
|
|
63
|
+
*/
|
|
64
|
+
static operationType(method: string): 'read' | 'write';
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=rateLimiter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimiter.d.ts","sourceRoot":"","sources":["../../../src/http/rateLimit/rateLimiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2CAA2C,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,qCAAqC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AASF;;;;;;GAMG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,KAAK;IAAzB,YAAoB,KAAK,EAAE,QAAQ,EAAI;IAEvC;;;;;;;;;;OAUG;IACG,KAAK,CACT,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC,CAqC1B;IAED;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE;QACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;KACjC,GAAG,MAAM,CAIT;IAED;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAErD;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
2
|
+
import { Body, ResponsesObject } from '../types/contractDetails.types';
|
|
3
|
+
/**
|
|
4
|
+
* Discriminates the body type from the given contract details and returns information
|
|
5
|
+
* necessary for parsing and validation.
|
|
6
|
+
*
|
|
7
|
+
* @template SV - Schema validator type.
|
|
8
|
+
* @template Path - Route path type.
|
|
9
|
+
* @template P - Params schema type.
|
|
10
|
+
* @template ResBodyMap - Response body map type.
|
|
11
|
+
* @template ReqBody - Request body type.
|
|
12
|
+
* @template ReqQuery - Request query object type.
|
|
13
|
+
* @template ReqHeaders - Request headers object type.
|
|
14
|
+
* @template ResHeaders - Response headers object type.
|
|
15
|
+
* @param contractDetails - The HTTP contract details.
|
|
16
|
+
* @returns An object containing the content type, parser type, and schema.
|
|
17
|
+
* @throws If no body-related information is found in the contract details.
|
|
18
|
+
*/
|
|
19
|
+
export declare function discriminateBody<SV extends AnySchemaValidator>(schemaValidator: SV, body: Body<SV> | undefined): {
|
|
20
|
+
contentType: string;
|
|
21
|
+
parserType: 'json' | 'text' | 'multipart' | 'urlEncoded' | 'file';
|
|
22
|
+
schema: SV['_ValidSchemaObject'];
|
|
23
|
+
} | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Discriminates all response body types from the given contract details and returns
|
|
26
|
+
* information necessary for parsing and validation for each status code.
|
|
27
|
+
*
|
|
28
|
+
* @template SV - Schema validator type.
|
|
29
|
+
* @template Path - Route path type.
|
|
30
|
+
* @template P - Params schema type.
|
|
31
|
+
* @template ResBodyMap - Response body map type.
|
|
32
|
+
* @template ReqQuery - Request query object type.
|
|
33
|
+
* @template ReqHeaders - Request headers object type.
|
|
34
|
+
* @template ResHeaders - Response headers object type.
|
|
35
|
+
* @param contractDetails - The contract details containing response schemas.
|
|
36
|
+
* @returns A record mapping status codes to content type, parser type, and schema info.
|
|
37
|
+
*/
|
|
38
|
+
export declare function discriminateResponseBodies<SV extends AnySchemaValidator>(schemaValidator: SV, responses: ResponsesObject<SV>): Record<number, {
|
|
39
|
+
contentType: string;
|
|
40
|
+
parserType: 'json' | 'text' | 'serverSentEvent' | 'file' | 'multipart';
|
|
41
|
+
schema: SV['_ValidSchemaObject'];
|
|
42
|
+
}>;
|
|
43
|
+
//# sourceMappingURL=discriminateBody.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discriminateBody.d.ts","sourceRoot":"","sources":["../../../src/http/router/discriminateBody.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAmB,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EACL,IAAI,EACJ,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAExC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,kBAAkB,EAC5D,eAAe,EAAE,EAAE,EACnB,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,SAAS,GAExB;IACE,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,YAAY,GAAG,MAAM,CAAC;IAClE,MAAM,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC;CAClC,GACD,SAAS,CA6EZ;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,SAAS,kBAAkB,EACtE,eAAe,EAAE,EAAE,EACnB,SAAS,EAAE,eAAe,CAAC,EAAE,CAAC;iBAKb,MAAM;gBACP,MAAM,GAAG,MAAM,GAAG,iBAAiB,GAAG,MAAM,GAAG,WAAW;YAC9D,EAAE,CAAC,oBAAoB,CAAC;GA2FrC"}
|