@geekmidas/constructs 9.2.0 → 9.3.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.
- package/CHANGELOG.md +62 -0
- package/README.md +1 -1
- package/dist/{AWSScheduledFunction-B0thZRJU.d.cts → AWSScheduledFunction-DAGP_vz5.d.cts} +43 -11
- package/dist/AWSScheduledFunction-DAGP_vz5.d.cts.map +1 -0
- package/dist/{AWSScheduledFunction-a6hRp3nk.d.mts → AWSScheduledFunction-Dg6TPIxn.d.mts} +42 -10
- package/dist/AWSScheduledFunction-Dg6TPIxn.d.mts.map +1 -0
- package/dist/{Endpoint-BmnuNbF1.d.cts → Endpoint-CxBdXNZm.d.cts} +2 -2
- package/dist/{Endpoint-BmnuNbF1.d.cts.map → Endpoint-CxBdXNZm.d.cts.map} +1 -1
- package/dist/Endpoint-DEydLuBs.d.mts.map +1 -1
- package/dist/{HonoEndpointAdaptor-Dd-S7gV_.mjs → HonoEndpointAdaptor-CJfFQ5KR.mjs} +2 -2
- package/dist/{HonoEndpointAdaptor-Dd-S7gV_.mjs.map → HonoEndpointAdaptor-CJfFQ5KR.mjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-INisd3XZ.cjs → HonoEndpointAdaptor-DCD0rhFg.cjs} +2 -2
- package/dist/{HonoEndpointAdaptor-INisd3XZ.cjs.map → HonoEndpointAdaptor-DCD0rhFg.cjs.map} +1 -1
- package/dist/adaptors/aws.cjs +8 -7
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +3 -3
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +1 -1
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +9 -8
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +2 -2
- package/dist/adaptors/hono.d.cts +2 -2
- package/dist/adaptors/hono.mjs +2 -2
- package/dist/adaptors/testing.cjs +2 -2
- package/dist/adaptors/testing.d.cts +2 -2
- package/dist/adaptors/testing.mjs +2 -2
- package/dist/crons/index.cjs +4 -0
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +8 -4
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +7 -3
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +4 -0
- package/dist/crons/index.mjs.map +1 -1
- package/dist/endpoints/index.cjs +1 -1
- package/dist/endpoints/index.d.cts +4 -4
- package/dist/endpoints/index.mjs +1 -1
- package/dist/functions/index.d.cts +1 -1
- package/dist/{index-HWHPZv8u.d.cts → index-CeoLMr7c.d.cts} +5 -5
- package/dist/{index-HWHPZv8u.d.cts.map → index-CeoLMr7c.d.cts.map} +1 -1
- package/dist/lazyAccessors-C1n1QfEj.cjs +653 -0
- package/dist/lazyAccessors-C1n1QfEj.cjs.map +1 -0
- package/dist/lazyAccessors-fFIQrblM.mjs +594 -0
- package/dist/lazyAccessors-fFIQrblM.mjs.map +1 -0
- package/dist/monitors/index.cjs +1 -1
- package/dist/monitors/index.cjs.map +1 -1
- package/dist/monitors/index.d.cts +1 -1
- package/dist/monitors/index.d.mts +1 -1
- package/dist/monitors/index.mjs +1 -1
- package/dist/monitors/index.mjs.map +1 -1
- package/package.json +23 -27
- package/src/__tests__/Construct.environment.spec.ts +2 -2
- package/src/__tests__/builder-reuse.spec.ts +2 -2
- package/src/__tests__/monitor.spec.ts +16 -16
- package/src/crons/Cron.ts +187 -60
- package/src/crons/CronBuilder.ts +10 -4
- package/src/crons/__tests__/AWSScheduledFunction.spec.ts +8 -6
- package/src/crons/__tests__/Cron.spec.ts +53 -91
- package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +28 -28
- package/src/crons/index.ts +2 -1
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +7 -15
- package/src/endpoints/Endpoint.ts +12 -15
- package/src/monitors/heartbeat.ts +1 -1
- package/tsdown.config.ts +1 -7
- package/dist/AWSScheduledFunction-B0thZRJU.d.cts.map +0 -1
- package/dist/AWSScheduledFunction-a6hRp3nk.d.mts.map +0 -1
- package/dist/lazyAccessors-DzxZVtPR.mjs +0 -1855
- package/dist/lazyAccessors-DzxZVtPR.mjs.map +0 -1
- package/dist/lazyAccessors-iwvg1Pv4.cjs +0 -1920
- package/dist/lazyAccessors-iwvg1Pv4.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aws.mjs","names":["envParser: EnvironmentParser<{}>","endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTAuditStorage,\n\t\t\tTAuditStorageServiceName,\n\t\t\tTAuditAction\n\t\t>","options: AmazonApiGatewayEndpointOptions","body: string | undefined | null","isBase64Encoded: boolean | undefined","contentType: string | undefined","e: TEvent","event: Event<TEvent, TInput, TServices, TLogger, TSession>","db: any","metadata","output","trx: any","result","lambdaResponse: AmazonApiGatewayEndpointHandlerResponse","baseHeaders: Record<string, string> | undefined","setCookieHeaders: string[]","ctx: any","event: TEvent","context: Context","queryParams: Record<string, string | string[] | undefined> | null","parts: string[]","e: APIGatewayProxyEvent","mergedParams: Record<string, string | string[]>","data: APIGatewayProxyEvent","context: Context","envParser: EnvironmentParser<{}>","endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher\n\t\t>","options: AmazonApiGatewayEndpointOptions","e: APIGatewayProxyEventV2","event: APIGatewayProxyEventV2","context: Context","envParser: EnvironmentParser<{}>","endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher\n\t\t>","options: AmazonApiGatewayEndpointOptions","envParser: EnvironmentParser<{}>","queue: Queue<TName, TMessage, TServices, TLogger>","value: string","record: SQSRecord","event: SQSEvent","context: Context","batchItemFailures: { itemIdentifier: string }[]","messages: InferStandardSchema<TMessage>[]","envParser: EnvironmentParser<{}>","subscriber: Subscriber<\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTSubscribedEvents\n\t\t>","events: any[]","event: SQSEvent | SNSEvent","record: SNSEventRecord","record: SQSRecord","value: string","event: any","event: SubscriberEvent<TServices, TLogger>","event: unknown","context: Context"],"sources":["../../src/endpoints/AmazonApiGatewayEndpointAdaptor.ts","../../src/endpoints/parseQueryParams.ts","../../src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts","../../src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts","../../src/queue/AWSLambdaQueueAdaptor.ts","../../src/subscribers/AWSLambdaSubscriberAdaptor.ts"],"sourcesContent":["import type { AuditableAction, AuditStorage } from '@geekmidas/audit';\nimport { withRlsContext } from '@geekmidas/db/rls';\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Logger } from '@geekmidas/logger';\nimport middy, { type MiddlewareObj } from '@middy/core';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type {\n\tAPIGatewayProxyEvent,\n\tAPIGatewayProxyEventV2,\n\tContext,\n} from 'aws-lambda';\nimport set from 'lodash.set';\nimport type { Telemetry } from '../telemetry';\nimport type { HttpMethod } from '../types';\nimport { Endpoint, type EndpointSchemas, ResponseBuilder } from './Endpoint';\n\n/**\n * Telescope integration for request recording.\n * Uses Middy middleware pattern for compatibility with existing telescope package.\n */\nexport interface TelescopeIntegration {\n\tmiddleware: MiddlewareObj<any, any, Error, Context>;\n}\n\nimport {\n\tForbiddenError,\n\tUnprocessableEntityError,\n\twrapError,\n} from '@geekmidas/errors';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type {\n\tInferComposableStandardSchema,\n\tInferStandardSchema,\n} from '@geekmidas/schema';\nimport {\n\trunWithRequestContext,\n\ttype Service,\n\tServiceDiscovery,\n\ttype ServiceRecord,\n} from '@geekmidas/services';\nimport { startMonitors } from '../monitor';\nimport { publishConstructEvents } from '../publisher';\nimport type { MappedAudit } from './audit';\nimport type { CookieFn, HeaderFn } from './Endpoint';\nimport {\n\tcreateAuditContext,\n\texecuteWithAuditTransaction,\n} from './processAudits';\n\n// Helper function to publish events\n\n/**\n * Options for Amazon API Gateway endpoint adaptors\n */\nexport interface AmazonApiGatewayEndpointOptions {\n\t/**\n\t * Telescope integration for request recording and monitoring.\n\t *\n\t * @example\n\t * ```typescript\n\t * import { telescopeMiddleware } from '@geekmidas/telescope/lambda';\n\t *\n\t * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n\t * telescope: { middleware: telescopeMiddleware(telescope) },\n\t * });\n\t * ```\n\t */\n\ttelescope?: TelescopeIntegration;\n\n\t/**\n\t * Telemetry integration for distributed tracing.\n\t * Works with any OpenTelemetry-compatible backend.\n\t *\n\t * @example\n\t * ```typescript\n\t * import { OTelTelemetry } from '@geekmidas/telescope/instrumentation';\n\t *\n\t * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n\t * telemetry: new OTelTelemetry(),\n\t * });\n\t * ```\n\t */\n\ttelemetry?: Telemetry;\n}\n\nexport abstract class AmazonApiGatewayEndpoint<\n\tTHandler extends\n\t\t| AmazonApiGatewayV1EndpointHandler\n\t\t| AmazonApiGatewayV2EndpointHandler,\n\tTEvent extends HandlerEvent<THandler>,\n\tTRoute extends string,\n\tTMethod extends HttpMethod,\n\tTInput extends EndpointSchemas = {},\n\tTOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTAuditStorage extends AuditStorage | undefined = undefined,\n\tTAuditStorageServiceName extends string = string,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n> {\n\tprotected options: AmazonApiGatewayEndpointOptions;\n\n\tconstructor(\n\t\tprotected envParser: EnvironmentParser<{}>,\n\t\tprotected readonly endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTAuditStorage,\n\t\t\tTAuditStorageServiceName,\n\t\t\tTAuditAction\n\t\t>,\n\t\toptions: AmazonApiGatewayEndpointOptions = {},\n\t) {\n\t\tthis.options = options;\n\t}\n\n\tprivate error(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tonError: (req) => {\n\t\t\t\t(req.event.logger || this.endpoint.logger).error(\n\t\t\t\t\treq.error || {},\n\t\t\t\t\t'Error processing request',\n\t\t\t\t);\n\t\t\t\tconst wrappedError = wrapError(req.error);\n\t\t\t\t// Kept for the monitors, which only see the response otherwise.\n\t\t\t\t(req.event as any).__error = req.error;\n\n\t\t\t\t// Set the response with the proper status code from the HttpError\n\t\t\t\treq.response = {\n\t\t\t\t\tstatusCode: wrappedError.statusCode,\n\t\t\t\t\tbody: wrappedError.body,\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t}\n\tabstract getInput(e: TEvent): GetInputResponse;\n\n\t/**\n\t * Decodes the raw body from an API Gateway event.\n\t * Uses Content-Type to decide parsing strategy (like Express/Fastify/Hono):\n\t * - `application/json` (or missing) → JSON.parse the decoded string\n\t * - Anything else → return decoded string as-is, let the schema handle it\n\t *\n\t * Defaults to JSON when no Content-Type is provided for backwards compatibility.\n\t */\n\tstatic decodeBody(\n\t\tbody: string | undefined | null,\n\t\tisBase64Encoded: boolean | undefined,\n\t\tcontentType: string | undefined,\n\t): any {\n\t\tif (!body) return undefined;\n\n\t\tconst raw = isBase64Encoded\n\t\t\t? Buffer.from(body, 'base64').toString('utf-8')\n\t\t\t: body;\n\n\t\tconst isJson =\n\t\t\t!contentType || contentType.toLowerCase().includes('application/json');\n\t\tif (isJson) {\n\t\t\treturn JSON.parse(raw);\n\t\t}\n\n\t\treturn raw;\n\t}\n\n\tprotected getCookies(e: TEvent): CookieFn {\n\t\tconst headers = e.headers as Record<string, string>;\n\t\treturn Endpoint.createCookies(headers?.cookie);\n\t}\n\n\tprivate input(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { body, query, params } = this.getInput(req.event);\n\t\t\t\t\tconst headers = req.event.headers as Record<string, string>;\n\t\t\t\t\tconst header = Endpoint.createHeaders(headers);\n\t\t\t\t\tconst cookie = this.getCookies(req.event);\n\n\t\t\t\t\tset(req.event, 'body', await this.endpoint.parseInput(body, 'body'));\n\n\t\t\t\t\tset(\n\t\t\t\t\t\treq.event,\n\t\t\t\t\t\t'query',\n\t\t\t\t\t\tawait this.endpoint.parseInput(query, 'query'),\n\t\t\t\t\t);\n\t\t\t\t\tset(\n\t\t\t\t\t\treq.event,\n\t\t\t\t\t\t'params',\n\t\t\t\t\t\tawait this.endpoint.parseInput(params, 'params'),\n\t\t\t\t\t);\n\t\t\t\t\tset(req.event, 'header', header);\n\t\t\t\t\tset(req.event, 'cookie', cookie);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Convert validation errors to 422 Unprocessable Entity\n\t\t\t\t\tif (error && typeof error === 'object' && Array.isArray(error)) {\n\t\t\t\t\t\tthrow new UnprocessableEntityError('Validation failed', error);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tabstract getLoggerContext(data: TEvent, context: Context): LoggerContext;\n\n\tprivate logger(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: (req) => {\n\t\t\t\treq.event.logger = this.endpoint.logger.child({\n\t\t\t\t\troute: this.endpoint.route,\n\t\t\t\t\thost: req.event.headers?.host,\n\t\t\t\t\tmethod: this.endpoint.method,\n\t\t\t\t\t...this.getLoggerContext(req.event, req.context),\n\t\t\t\t}) as TLogger;\n\t\t\t},\n\t\t};\n\t}\n\tprivate services(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\tconst _logger = req.event.logger as TLogger;\n\t\t\t\tconst serviceDiscovery = ServiceDiscovery.getInstance<\n\t\t\t\t\tServiceRecord<TServices>\n\t\t\t\t>(this.envParser);\n\n\t\t\t\tconst services = await serviceDiscovery.register(\n\t\t\t\t\tthis.endpoint.services,\n\t\t\t\t);\n\n\t\t\t\treq.event.services = services;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate authorize(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\tconst logger = req.event.logger as TLogger;\n\t\t\t\tconst services = req.event.services;\n\t\t\t\tconst header = req.event.header;\n\t\t\t\tconst cookie = req.event.cookie;\n\t\t\t\tconst session = req.event.session as TSession;\n\n\t\t\t\tconst isAuthorized = await this.endpoint.authorize({\n\t\t\t\t\theader,\n\t\t\t\t\tcookie,\n\t\t\t\t\tservices,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsession,\n\t\t\t\t\t...((req.event as any).db !== undefined && {\n\t\t\t\t\t\tdb: (req.event as any).db,\n\t\t\t\t\t}),\n\t\t\t\t\tbody: (req.event as any).body,\n\t\t\t\t\tquery: (req.event as any).query,\n\t\t\t\t\tparams: (req.event as any).params,\n\t\t\t\t} as any);\n\n\t\t\t\tif (!isAuthorized) {\n\t\t\t\t\tlogger.warn('Forbidden access attempt');\n\t\t\t\t\tthrow new ForbiddenError(\n\t\t\t\t\t\t'Forbidden access to the endpoint',\n\t\t\t\t\t\t'You do not have permission to access this resource.',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate database(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\tif (!this.endpoint.databaseService) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst _logger = req.event.logger as TLogger;\n\t\t\t\tconst serviceDiscovery = ServiceDiscovery.getInstance<\n\t\t\t\t\tServiceRecord<TServices>\n\t\t\t\t>(this.envParser);\n\n\t\t\t\tconst db = await serviceDiscovery\n\t\t\t\t\t.register([this.endpoint.databaseService])\n\t\t\t\t\t.then(\n\t\t\t\t\t\t(s) =>\n\t\t\t\t\t\t\ts[this.endpoint.databaseService?.serviceName as keyof typeof s],\n\t\t\t\t\t);\n\n\t\t\t\t(req.event as any).db = db;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate session(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\tconst logger = req.event.logger as TLogger;\n\t\t\t\tconst services = req.event.services;\n\t\t\t\tconst db = (req.event as any).db;\n\t\t\t\treq.event.session = (await this.endpoint.getSession({\n\t\t\t\t\tlogger,\n\t\t\t\t\tservices,\n\t\t\t\t\theader: req.event.header,\n\t\t\t\t\tcookie: req.event.cookie,\n\t\t\t\t\t...(db !== undefined && { db }),\n\t\t\t\t} as any)) as TSession;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate events(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tafter: async (req) => {\n\t\t\t\tconst event = req.event;\n\t\t\t\tconst response = (event as any)\n\t\t\t\t\t.__response as InferStandardSchema<TOutSchema>;\n\t\t\t\tconst statusCode = req.response?.statusCode ?? this.endpoint.status;\n\n\t\t\t\t// Only publish events on successful responses (2xx status codes)\n\t\t\t\t// Note: Audits are processed inside the handler's transaction\n\t\t\t\tif (Endpoint.isSuccessStatus(statusCode)) {\n\t\t\t\t\tconst logger = event.logger as TLogger;\n\t\t\t\t\tconst serviceDiscovery = ServiceDiscovery.getInstance<\n\t\t\t\t\t\tServiceRecord<TServices>\n\t\t\t\t\t>(this.envParser);\n\n\t\t\t\t\t// Publish events\n\t\t\t\t\tawait publishConstructEvents(\n\t\t\t\t\t\tthis.endpoint,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t\tserviceDiscovery,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate async _handler(\n\t\tevent: Event<TEvent, TInput, TServices, TLogger, TSession>,\n\t) {\n\t\tconst input = this.endpoint.refineInput(event);\n\t\tconst logger = event.logger as TLogger;\n\t\tconst serviceDiscovery = ServiceDiscovery.getInstance<\n\t\t\tServiceRecord<TServices>\n\t\t>(this.envParser);\n\n\t\t// Create audit context if audit storage is configured\n\t\tconst auditContext = await createAuditContext(\n\t\t\tthis.endpoint,\n\t\t\tserviceDiscovery,\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\tsession: event.session,\n\t\t\t\theader: event.header,\n\t\t\t\tcookie: event.cookie,\n\t\t\t\tservices: event.services as Record<string, unknown>,\n\t\t\t},\n\t\t);\n\n\t\t// Warn if declarative audits are configured but no audit storage\n\t\tconst audits = this.endpoint.audits as MappedAudit<\n\t\t\tTAuditAction,\n\t\t\tTOutSchema\n\t\t>[];\n\t\tif (!auditContext && audits?.length) {\n\t\t\tlogger.warn('No auditor storage service available');\n\t\t}\n\n\t\t// Get pre-resolved database from middleware\n\t\tconst rawDb = (event as any).db;\n\n\t\t// Extract RLS context if configured and not bypassed\n\t\tconst rlsActive =\n\t\t\tthis.endpoint.rlsConfig &&\n\t\t\t!this.endpoint.rlsBypass &&\n\t\t\trawDb !== undefined;\n\t\tconst rlsContext = rlsActive\n\t\t\t? await this.endpoint.rlsConfig?.extractor({\n\t\t\t\t\tservices: event.services as ServiceRecord<TServices>,\n\t\t\t\t\tsession: event.session,\n\t\t\t\t\theader: event.header,\n\t\t\t\t\tcookie: event.cookie,\n\t\t\t\t\tlogger,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\t\t// Execute handler with automatic audit transaction support\n\t\tconst result = await executeWithAuditTransaction(\n\t\t\tauditContext,\n\t\t\tasync (auditor) => {\n\t\t\t\t// Use audit transaction as db only if the storage uses the same database service\n\t\t\t\tconst sameDatabase =\n\t\t\t\t\tauditContext?.storage?.databaseServiceName &&\n\t\t\t\t\tauditContext.storage.databaseServiceName ===\n\t\t\t\t\t\tthis.endpoint.databaseService?.serviceName;\n\t\t\t\tconst baseDb = sameDatabase\n\t\t\t\t\t? (auditor?.getTransaction?.() ?? rawDb)\n\t\t\t\t\t: rawDb;\n\n\t\t\t\t// Helper to execute handler with given db\n\t\t\t\tconst executeHandler = async (db: any) => {\n\t\t\t\t\tconst responseBuilder = new ResponseBuilder();\n\t\t\t\t\tconst response = await this.endpoint.handler(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\theader: event.header,\n\t\t\t\t\t\t\tcookie: event.cookie,\n\t\t\t\t\t\t\tlogger: event.logger,\n\t\t\t\t\t\t\tservices: event.services,\n\t\t\t\t\t\t\tsession: event.session,\n\t\t\t\t\t\t\tauditor,\n\t\t\t\t\t\t\tdb,\n\t\t\t\t\t\t\t...input,\n\t\t\t\t\t\t} as any,\n\t\t\t\t\t\tresponseBuilder,\n\t\t\t\t\t);\n\n\t\t\t\t\t// Check if response has metadata\n\t\t\t\t\tlet data = response;\n\t\t\t\t\tlet metadata = responseBuilder.getMetadata();\n\n\t\t\t\t\tif (Endpoint.hasMetadata(response)) {\n\t\t\t\t\t\tdata = response.data;\n\t\t\t\t\t\tmetadata = response.metadata;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst output = this.endpoint.outputSchema\n\t\t\t\t\t\t? await this.endpoint.parseOutput(data)\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\treturn { output, metadata, responseBuilder };\n\t\t\t\t};\n\n\t\t\t\t// If RLS is active, wrap handler with RLS context\n\t\t\t\tif (rlsActive && rlsContext && baseDb) {\n\t\t\t\t\treturn withRlsContext(\n\t\t\t\t\t\tbaseDb,\n\t\t\t\t\t\trlsContext,\n\t\t\t\t\t\tasync (trx: any) => executeHandler(trx),\n\t\t\t\t\t\t{ prefix: this.endpoint.rlsConfig?.prefix },\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn executeHandler(baseDb);\n\t\t\t},\n\t\t\t// Process declarative audits after handler (inside transaction)\n\t\t\tasync (result, auditor) => {\n\t\t\t\tif (!audits?.length) return;\n\n\t\t\t\tfor (const audit of audits) {\n\t\t\t\t\tif (audit.when && !audit.when(result.output as any)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst payload = audit.payload(result.output as any);\n\t\t\t\t\tconst entityId = audit.entityId?.(result.output as any);\n\t\t\t\t\tauditor.audit(audit.type as any, payload as any, {\n\t\t\t\t\t\ttable: audit.table,\n\t\t\t\t\t\tentityId,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Pass rawDb so storage can reuse existing transactions\n\t\t\t{ db: rawDb },\n\t\t);\n\n\t\tconst { output, metadata } = result;\n\t\tconst isJsonResponse = this.endpoint.responseType === 'application/json';\n\t\tconst body =\n\t\t\toutput === undefined\n\t\t\t\t? undefined\n\t\t\t\t: isJsonResponse\n\t\t\t\t\t? JSON.stringify(output)\n\t\t\t\t\t: typeof output === 'string'\n\t\t\t\t\t\t? output\n\t\t\t\t\t\t: String(output);\n\n\t\t// Store response for middleware access\n\t\t(event as any).__response = output;\n\n\t\t// Build response with metadata\n\t\tconst lambdaResponse: AmazonApiGatewayEndpointHandlerResponse = {\n\t\t\tstatusCode: metadata.status ?? this.endpoint.status,\n\t\t\tbody,\n\t\t};\n\n\t\t// Compose headers. For non-JSON responseType, emit a default\n\t\t// Content-Type header which metadata.headers (r.header()) can override.\n\t\tconst baseHeaders: Record<string, string> | undefined = isJsonResponse\n\t\t\t? undefined\n\t\t\t: { 'content-type': this.endpoint.responseType };\n\n\t\tif (\n\t\t\tbaseHeaders ||\n\t\t\t(metadata.headers && Object.keys(metadata.headers).length > 0)\n\t\t) {\n\t\t\tlambdaResponse.headers = {\n\t\t\t\t...(baseHeaders ?? {}),\n\t\t\t\t...(metadata.headers ?? {}),\n\t\t\t};\n\t\t}\n\n\t\t// Format cookies as Set-Cookie headers\n\t\tif (metadata.cookies && metadata.cookies.size > 0) {\n\t\t\tconst setCookieHeaders: string[] = [];\n\t\t\tfor (const [name, { value, options }] of metadata.cookies) {\n\t\t\t\tsetCookieHeaders.push(\n\t\t\t\t\tEndpoint.formatCookieHeader(name, value, options),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (setCookieHeaders.length > 0) {\n\t\t\t\tlambdaResponse.multiValueHeaders = {\n\t\t\t\t\t...lambdaResponse.multiValueHeaders,\n\t\t\t\t\t'Set-Cookie': setCookieHeaders,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn lambdaResponse;\n\t}\n\n\t/**\n\t * Convert Telemetry interface to Middy middleware\n\t */\n\tprivate telemetry(): Middleware<TEvent, TInput, TServices, TLogger> | null {\n\t\tif (!this.options.telemetry) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst telemetry = this.options.telemetry;\n\t\tlet ctx: any;\n\n\t\treturn {\n\t\t\tbefore: (request) => {\n\t\t\t\tctx = telemetry.onRequestStart({\n\t\t\t\t\tevent: request.event,\n\t\t\t\t\tcontext: request.context,\n\t\t\t\t});\n\t\t\t},\n\t\t\tafter: (request) => {\n\t\t\t\tif (ctx) {\n\t\t\t\t\ttelemetry.onRequestEnd(ctx, {\n\t\t\t\t\t\tstatusCode: request.response?.statusCode ?? 200,\n\t\t\t\t\t\tbody: request.response?.body,\n\t\t\t\t\t\theaders: request.response?.headers,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t\tonError: (request) => {\n\t\t\t\tif (ctx && request.error) {\n\t\t\t\t\ttelemetry.onRequestError(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\trequest.error instanceof Error\n\t\t\t\t\t\t\t? request.error\n\t\t\t\t\t\t\t: new Error(String(request.error)),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tget handler() {\n\t\tconst handler = this._handler.bind(this);\n\t\tlet chain = middy(handler)\n\t\t\t.use(this.logger())\n\t\t\t.use(this.error())\n\t\t\t.use(this.services())\n\t\t\t.use(this.input())\n\t\t\t.use(this.database())\n\t\t\t.use(this.session())\n\t\t\t.use(this.authorize())\n\t\t\t.use(this.events());\n\n\t\t// Add telemetry middleware if configured (runs early for span creation)\n\t\tconst telemetryMiddleware = this.telemetry();\n\t\tif (telemetryMiddleware) {\n\t\t\tchain = chain.use(telemetryMiddleware);\n\t\t}\n\n\t\t// Add Telescope middleware if configured (runs first/last in chain)\n\t\tif (this.options.telescope?.middleware) {\n\t\t\tchain = chain.use(this.options.telescope.middleware);\n\t\t}\n\n\t\t// Wrap entire Middy chain in request context for service access\n\t\tconst wrappedHandler = async (event: TEvent, context: Context) => {\n\t\t\tconst startTime = Date.now();\n\t\t\tconst requestId = context.awsRequestId;\n\t\t\tconst logger = this.endpoint.logger.child({ requestId }) as TLogger;\n\n\t\t\t// Cast event to any since Middy middlewares enrich the event with\n\t\t\t// services, logger, session, etc. during the middleware chain execution\n\t\t\treturn runWithRequestContext(\n\t\t\t\t{ logger, requestId, startTime },\n\t\t\t\tasync () => {\n\t\t\t\t\tconst monitor = await startMonitors(\n\t\t\t\t\t\tthis.endpoint,\n\t\t\t\t\t\tServiceDiscovery.getInstance(this.envParser),\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t);\n\t\t\t\t\tconst response = await chain(\n\t\t\t\t\t\tevent as unknown as Parameters<typeof chain>[0],\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t);\n\t\t\t\t\t// Awaited: Lambda freezes the process once the response is\n\t\t\t\t\t// returned, so an unawaited ping may never be sent.\n\t\t\t\t\tawait monitor.settle(\n\t\t\t\t\t\t(response as any)?.statusCode ?? 200,\n\t\t\t\t\t\t(event as any).__error,\n\t\t\t\t\t);\n\t\t\t\t\treturn response;\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\treturn wrappedHandler as unknown as THandler;\n\t}\n}\n\nexport type Event<\n\tTEvent extends APIGatewayProxyEvent | APIGatewayProxyEventV2,\n\tTInput extends EndpointSchemas = {},\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n> = {\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n\theader: HeaderFn;\n\tcookie: CookieFn;\n\tsession: TSession;\n} & TEvent &\n\tInferComposableStandardSchema<TInput>;\n\ntype Middleware<\n\tTEvent extends APIGatewayProxyEvent | APIGatewayProxyEventV2,\n\tTInput extends EndpointSchemas = {},\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n> = MiddlewareObj<Event<TEvent, TInput, TServices, TLogger, TSession>>;\n\nexport type AmazonApiGatewayEndpointHandlerResponse = {\n\tstatusCode: number;\n\tbody: string | undefined;\n\theaders?: Record<string, string>;\n\tmultiValueHeaders?: Record<string, string[]>;\n};\n\nexport type LoggerContext = {\n\tfn: {\n\t\tname: string;\n\t\tversion: string;\n\t};\n\treq: {\n\t\tid: string | undefined;\n\t\tawsRequestId: string;\n\t\tpath: string;\n\t\tip: string | undefined;\n\t\tuserAgent: string | undefined;\n\t};\n};\n\nexport type GetInputResponse = {\n\tbody: any;\n\tquery: any;\n\tparams: any;\n};\n\nexport type AmazonApiGatewayV1EndpointHandler = (\n\tevent: APIGatewayProxyEvent,\n\tcontext: Context,\n) => Promise<AmazonApiGatewayEndpointHandlerResponse>;\n\nexport type AmazonApiGatewayV2EndpointHandler = (\n\tevent: APIGatewayProxyEventV2,\n\tcontext: Context,\n) => Promise<AmazonApiGatewayEndpointHandlerResponse>;\n\nexport type HandlerEvent<T extends Function> = T extends (\n\tevent: infer E,\n\tcontext: Context,\n) => any\n\t? E\n\t: never;\n","import qs from 'qs';\n\n/**\n * Parse query parameters from a flat object into a nested structure\n * Uses qs bracket notation for standard interoperability\n *\n * @example\n * parseQueryParams({ 'tags[]': ['a', 'b'], 'filter[name]': 'john' })\n * // Returns: { tags: ['a', 'b'], filter: { name: 'john' } }\n */\nexport function parseQueryParams(\n\tqueryParams: Record<string, string | string[] | undefined> | null,\n): Record<string, any> {\n\tif (!queryParams) {\n\t\treturn {};\n\t}\n\n\t// Reconstruct a query string from the flat object so qs can parse bracket notation\n\tconst parts: string[] = [];\n\tfor (const [key, value] of Object.entries(queryParams)) {\n\t\tif (value === undefined) continue;\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (const v of value) {\n\t\t\t\tparts.push(`${encodeURIComponent(key)}=${encodeURIComponent(v)}`);\n\t\t\t}\n\t\t} else {\n\t\t\tparts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);\n\t\t}\n\t}\n\n\treturn qs.parse(parts.join('&')) as Record<string, any>;\n}\n","import type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { APIGatewayProxyEvent, Context } from 'aws-lambda';\nimport type { HttpMethod } from '../types';\nimport {\n\tAmazonApiGatewayEndpoint,\n\ttype AmazonApiGatewayEndpointOptions,\n\ttype AmazonApiGatewayV1EndpointHandler,\n\ttype GetInputResponse,\n\ttype LoggerContext,\n} from './AmazonApiGatewayEndpointAdaptor';\nimport type { Endpoint, EndpointSchemas } from './Endpoint';\nimport { parseQueryParams } from './parseQueryParams';\n\nexport class AmazonApiGatewayV1Endpoint<\n\tTRoute extends string,\n\tTMethod extends HttpMethod,\n\tTInput extends EndpointSchemas = {},\n\tTOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n> extends AmazonApiGatewayEndpoint<\n\tAmazonApiGatewayV1EndpointHandler,\n\tAPIGatewayProxyEvent,\n\tTRoute,\n\tTMethod,\n\tTInput,\n\tTOutSchema,\n\tTServices,\n\tTLogger,\n\tTSession,\n\tTEventPublisher\n> {\n\toverride getInput(e: APIGatewayProxyEvent): GetInputResponse {\n\t\t// For arrays, AWS API Gateway V1 provides multiValueQueryStringParameters\n\t\tconst multiValueParams = e.multiValueQueryStringParameters || {};\n\t\tconst singleValueParams = e.queryStringParameters || {};\n\n\t\t// Merge single and multi-value parameters\n\t\tconst mergedParams: Record<string, string | string[]> = {};\n\n\t\t// Add single value parameters\n\t\tfor (const [key, value] of Object.entries(singleValueParams)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tmergedParams[key] = value;\n\t\t\t}\n\t\t}\n\n\t\t// Override with multi-value parameters where applicable\n\t\tfor (const [key, values] of Object.entries(multiValueParams)) {\n\t\t\tif (values && values.length > 1) {\n\t\t\t\tmergedParams[key] = values;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tbody: AmazonApiGatewayEndpoint.decodeBody(\n\t\t\t\te.body,\n\t\t\t\te.isBase64Encoded,\n\t\t\t\te.headers?.['Content-Type'] ?? e.headers?.['content-type'],\n\t\t\t),\n\t\t\tquery: parseQueryParams(mergedParams),\n\t\t\tparams: e.pathParameters || {},\n\t\t};\n\t}\n\toverride getLoggerContext(\n\t\tdata: APIGatewayProxyEvent,\n\t\tcontext: Context,\n\t): LoggerContext {\n\t\treturn {\n\t\t\tfn: {\n\t\t\t\tname: context.functionName,\n\t\t\t\tversion: context.functionVersion,\n\t\t\t},\n\t\t\treq: {\n\t\t\t\tid: data.requestContext.requestId,\n\t\t\t\tawsRequestId: context.awsRequestId,\n\t\t\t\tip: data.requestContext.identity.sourceIp,\n\t\t\t\tuserAgent: data.requestContext.identity.userAgent || undefined,\n\t\t\t\tpath: data.requestContext.path,\n\t\t\t},\n\t\t};\n\t}\n\tconstructor(\n\t\tprotected override envParser: EnvironmentParser<{}>,\n\t\tprotected override readonly endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher\n\t\t>,\n\t\toptions: AmazonApiGatewayEndpointOptions = {},\n\t) {\n\t\tsuper(envParser, endpoint, options);\n\t}\n}\n","import type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { APIGatewayProxyEventV2, Context } from 'aws-lambda';\nimport qs from 'qs';\nimport type { HttpMethod } from '../types';\nimport {\n\tAmazonApiGatewayEndpoint,\n\ttype AmazonApiGatewayEndpointOptions,\n\ttype AmazonApiGatewayV2EndpointHandler,\n\ttype GetInputResponse,\n\ttype LoggerContext,\n} from './AmazonApiGatewayEndpointAdaptor';\nimport type { CookieFn, Endpoint, EndpointSchemas } from './Endpoint';\nimport { createApiGatewayCookies } from './lazyAccessors';\n\nexport class AmazonApiGatewayV2Endpoint<\n\tTRoute extends string,\n\tTMethod extends HttpMethod,\n\tTInput extends EndpointSchemas = {},\n\tTOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n> extends AmazonApiGatewayEndpoint<\n\tAmazonApiGatewayV2EndpointHandler,\n\tAPIGatewayProxyEventV2,\n\tTRoute,\n\tTMethod,\n\tTInput,\n\tTOutSchema,\n\tTServices,\n\tTLogger,\n\tTSession,\n\tTEventPublisher\n> {\n\toverride getCookies(e: APIGatewayProxyEventV2): CookieFn {\n\t\treturn createApiGatewayCookies(\n\t\t\te.cookies,\n\t\t\t(e.headers as Record<string, string>)?.cookie,\n\t\t);\n\t}\n\n\toverride getInput(e: APIGatewayProxyEventV2): GetInputResponse {\n\t\tconst raw = AmazonApiGatewayEndpoint.decodeBody(\n\t\t\te.body,\n\t\t\te.isBase64Encoded,\n\t\t\te.headers?.['content-type'],\n\t\t);\n\n\t\treturn {\n\t\t\tbody: raw,\n\t\t\tquery: qs.parse(e.rawQueryString) as Record<string, any>,\n\t\t\tparams: e.pathParameters || {},\n\t\t};\n\t}\n\toverride getLoggerContext(\n\t\tevent: APIGatewayProxyEventV2,\n\t\tcontext: Context,\n\t): LoggerContext {\n\t\treturn {\n\t\t\tfn: {\n\t\t\t\tname: context.functionName,\n\t\t\t\tversion: context.functionVersion,\n\t\t\t},\n\t\t\treq: {\n\t\t\t\tid: event.requestContext.requestId,\n\t\t\t\tawsRequestId: context.awsRequestId,\n\t\t\t\tip: event.requestContext.http.sourceIp,\n\t\t\t\tuserAgent: event.requestContext.http.userAgent || undefined,\n\t\t\t\tpath: event.requestContext.http.path,\n\t\t\t},\n\t\t};\n\t}\n\tconstructor(\n\t\tprotected override envParser: EnvironmentParser<{}>,\n\t\tprotected override readonly endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher\n\t\t>,\n\t\toptions: AmazonApiGatewayEndpointOptions = {},\n\t) {\n\t\tsuper(envParser, endpoint, options);\n\t}\n}\n\n// Re-export options type for convenience\nexport type { AmazonApiGatewayEndpointOptions };\n","import type { EnvironmentParser } from '@geekmidas/envkit';\nimport { wrapError } from '@geekmidas/errors';\nimport type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport { runWithRequestContext, ServiceDiscovery } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type {\n\tContext,\n\tHandler,\n\tSQSBatchResponse,\n\tSQSEvent,\n\tSQSRecord,\n} from 'aws-lambda';\nimport type { Queue } from './Queue';\n\nexport type AWSLambdaHandler<TEvent = any, TResult = any> = Handler<\n\tTEvent,\n\tTResult\n>;\n\n/**\n * Runs a {@link Queue} worker as an AWS Lambda backed by an SQS event-source\n * mapping. Unlike a subscriber, a queue drains *every* record (no type filter):\n * each record body (`{ type, payload }`, as written by the SQS publisher) is\n * unwrapped to its `payload`, validated against the queue's `messageSchema`, and\n * the whole batch is handed to the handler as `messages`.\n *\n * Uses SQS partial-batch responses: a record that fails to parse, validate, or\n * (when the handler throws) process is returned in `batchItemFailures` so SQS\n * retries only those records.\n */\nexport class AWSLambdaQueue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _services?: ServiceRecord<TServices>;\n\n\tconstructor(\n\t\tprivate readonly envParser: EnvironmentParser<{}>,\n\t\treadonly queue: Queue<TName, TMessage, TServices, TLogger>,\n\t) {}\n\n\tget logger(): TLogger {\n\t\treturn this.queue.logger;\n\t}\n\n\tprivate async getServices(): Promise<ServiceRecord<TServices>> {\n\t\tif (this._services) {\n\t\t\treturn this._services;\n\t\t}\n\n\t\tconst serviceDiscovery = ServiceDiscovery.getInstance(this.envParser);\n\n\t\tthis._services =\n\t\t\tthis.queue.services.length > 0\n\t\t\t\t? ((await serviceDiscovery.register(\n\t\t\t\t\t\tthis.queue.services,\n\t\t\t\t\t)) as ServiceRecord<TServices>)\n\t\t\t\t: ({} as ServiceRecord<TServices>);\n\n\t\treturn this._services;\n\t}\n\n\tprivate safeJsonParse(value: string): unknown {\n\t\ttry {\n\t\t\treturn JSON.parse(value);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Unwrap the queue payload from an SQS record. The SQS publisher writes\n\t * `{ type, payload }`; a payload-only body is also accepted as-is.\n\t */\n\tprivate extractPayload(record: SQSRecord): unknown {\n\t\tconst body = this.safeJsonParse(record.body);\n\t\tif (body && typeof body === 'object' && 'payload' in body) {\n\t\t\treturn (body as { payload: unknown }).payload;\n\t\t}\n\t\treturn body ?? record.body;\n\t}\n\n\tprivate async _handler(\n\t\tevent: SQSEvent,\n\t\tcontext: Context,\n\t): Promise<SQSBatchResponse> {\n\t\tconst logger = this.queue.logger.child({\n\t\t\tqueue: {\n\t\t\t\tname: this.queue.name,\n\t\t\t\tfn: context.functionName,\n\t\t\t},\n\t\t\treq: { id: context.awsRequestId },\n\t\t}) as TLogger;\n\n\t\tconst services = await this.getServices();\n\t\tconst schema = this.queue.messageSchema;\n\n\t\tconst batchItemFailures: { itemIdentifier: string }[] = [];\n\t\tconst messages: InferStandardSchema<TMessage>[] = [];\n\n\t\tfor (const record of event.Records) {\n\t\t\ttry {\n\t\t\t\tconst payload = this.extractPayload(record);\n\t\t\t\tconst validation = await schema['~standard'].validate(payload);\n\t\t\t\tif (validation.issues) {\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t{ issues: validation.issues, messageId: record.messageId },\n\t\t\t\t\t\t'Queue message failed validation',\n\t\t\t\t\t);\n\t\t\t\t\tbatchItemFailures.push({ itemIdentifier: record.messageId });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tmessages.push(validation.value as InferStandardSchema<TMessage>);\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(\n\t\t\t\t\t{ error, messageId: record.messageId },\n\t\t\t\t\t'Failed to parse SQS record',\n\t\t\t\t);\n\t\t\t\tbatchItemFailures.push({ itemIdentifier: record.messageId });\n\t\t\t}\n\t\t}\n\n\t\tif (messages.length === 0) {\n\t\t\treturn { batchItemFailures };\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.queue.handler({ messages, services, logger });\n\t\t} catch (error) {\n\t\t\tlogger.error(wrapError(error), 'Queue handler failed; retrying batch');\n\t\t\t// Handler processes the batch atomically — fail the whole batch so SQS\n\t\t\t// retries every (valid) record.\n\t\t\tfor (const record of event.Records) {\n\t\t\t\tif (\n\t\t\t\t\t!batchItemFailures.some((f) => f.itemIdentifier === record.messageId)\n\t\t\t\t) {\n\t\t\t\t\tbatchItemFailures.push({ itemIdentifier: record.messageId });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { batchItemFailures };\n\t}\n\n\tget handler(): AWSLambdaHandler<SQSEvent, SQSBatchResponse> {\n\t\tconst handler = this._handler.bind(this);\n\n\t\treturn (async (event: SQSEvent, context: Context) => {\n\t\t\tconst startTime = Date.now();\n\t\t\tconst requestId = context.awsRequestId;\n\t\t\tconst logger = this.queue.logger.child({ requestId }) as TLogger;\n\n\t\t\treturn runWithRequestContext({ logger, requestId, startTime }, () =>\n\t\t\t\thandler(event, context),\n\t\t\t);\n\t\t}) as unknown as AWSLambdaHandler<SQSEvent, SQSBatchResponse>;\n\t}\n}\n","import type { EnvironmentParser } from '@geekmidas/envkit';\nimport { wrapError } from '@geekmidas/errors';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport { runWithRequestContext, ServiceDiscovery } from '@geekmidas/services';\nimport middy, { type MiddlewareObj } from '@middy/core';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type {\n\tContext,\n\tHandler,\n\tSNSEvent,\n\tSNSEventRecord,\n\tSQSEvent,\n\tSQSRecord,\n} from 'aws-lambda';\nimport type { Subscriber } from './Subscriber';\n\nexport type AWSLambdaHandler<TEvent = any, TResult = any> = Handler<\n\tTEvent,\n\tTResult\n>;\n\ntype SubscriberEvent<TServices extends Service[], TLogger extends Logger> = {\n\tevents: any[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\ntype Middleware<\n\tTServices extends Service[],\n\tTLogger extends Logger,\n\tTOutSchema extends StandardSchemaV1 | undefined,\n> = MiddlewareObj<\n\tSubscriberEvent<TServices, TLogger>,\n\tInferStandardSchema<TOutSchema>,\n\tError,\n\tContext\n>;\n\nexport class AWSLambdaSubscriber<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTSubscribedEvents extends any[] = [],\n> {\n\tprivate _logger!: TLogger;\n\tprivate _services!: ServiceRecord<TServices>;\n\n\tconstructor(\n\t\tprivate envParser: EnvironmentParser<{}>,\n\t\treadonly subscriber: Subscriber<\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTSubscribedEvents\n\t\t>,\n\t) {\n\t\tthis._logger = subscriber.logger;\n\t}\n\n\tget logger(): TLogger {\n\t\treturn this._logger;\n\t}\n\n\tprivate async getServices(): Promise<ServiceRecord<TServices>> {\n\t\tif (this._services) {\n\t\t\treturn this._services;\n\t\t}\n\n\t\tconst serviceDiscovery = ServiceDiscovery.getInstance(this.envParser);\n\n\t\tif (this.subscriber.services.length > 0) {\n\t\t\tconst registered = await serviceDiscovery.register(\n\t\t\t\tthis.subscriber.services,\n\t\t\t);\n\t\t\tthis._services = registered as ServiceRecord<TServices>;\n\t\t} else {\n\t\t\tthis._services = {} as ServiceRecord<TServices>;\n\t\t}\n\n\t\treturn this._services;\n\t}\n\n\tprivate error(): Middleware<TServices, TLogger, OutSchema> {\n\t\treturn {\n\t\t\tonError: (req) => {\n\t\t\t\tconst logger = req.event?.logger || this.subscriber.logger;\n\t\t\t\tlogger.error(req.error || {}, 'Error processing subscriber');\n\n\t\t\t\t// Re-throw the wrapped error to let Lambda handle it\n\t\t\t\tthrow wrapError(req.error);\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate loggerMiddleware(): Middleware<TServices, TLogger, OutSchema> {\n\t\treturn {\n\t\t\tbefore: (req) => {\n\t\t\t\tthis._logger = this.subscriber.logger.child({\n\t\t\t\t\tsubscriber: {\n\t\t\t\t\t\tname: req.context.functionName,\n\t\t\t\t\t\tversion: req.context.functionVersion,\n\t\t\t\t\t\tmemory: req.context.memoryLimitInMB,\n\t\t\t\t\t},\n\t\t\t\t\treq: {\n\t\t\t\t\t\tid: req.context.awsRequestId,\n\t\t\t\t\t},\n\t\t\t\t}) as TLogger;\n\n\t\t\t\treq.event.logger = this._logger;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate services(): Middleware<TServices, TLogger, OutSchema> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\treq.event.services = await this.getServices();\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate parseEvents(): Middleware<TServices, TLogger, OutSchema> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\tconst { logger, ...e } = req.event;\n\t\t\t\tconst rawEvent = e as any as SQSEvent | SNSEvent;\n\n\t\t\t\tlogger.info({\n\t\t\t\t\trawEvent,\n\t\t\t\t});\n\n\t\t\t\t// Parse events based on the event type\n\t\t\t\tconst events: any[] = [];\n\n\t\t\t\tif ('Records' in rawEvent) {\n\t\t\t\t\tif (this.isSQSEvent(rawEvent)) {\n\t\t\t\t\t\t// SQS Event\n\t\t\t\t\t\tfor (const record of rawEvent.Records) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst event = this.parseSQSRecord(record);\n\t\t\t\t\t\t\t\tif (this.shouldIncludeEvent(event)) {\n\t\t\t\t\t\t\t\t\tevents.push(event);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t\t\t\t{ error, record },\n\t\t\t\t\t\t\t\t\t'Failed to parse SQS record',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (this.isSNSEvent(rawEvent)) {\n\t\t\t\t\t\t// SNS Event\n\t\t\t\t\t\tfor (const record of rawEvent.Records) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst event = this.parseSNSRecord(record);\n\t\t\t\t\t\t\t\tif (this.shouldIncludeEvent(event)) {\n\t\t\t\t\t\t\t\t\tevents.push(event);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t\t\t\t{ error, record },\n\t\t\t\t\t\t\t\t\t'Failed to parse SNS record',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t(req.event as any).events = events;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate isSQSEvent(event: SQSEvent | SNSEvent): event is SQSEvent {\n\t\tconst firstRecord = event.Records[0];\n\t\treturn (\n\t\t\t'Records' in event &&\n\t\t\tevent.Records.length > 0 &&\n\t\t\tfirstRecord !== undefined &&\n\t\t\t'eventSource' in firstRecord &&\n\t\t\tfirstRecord.eventSource === 'aws:sqs'\n\t\t);\n\t}\n\n\tprivate isSNSEvent(event: SQSEvent | SNSEvent): event is SNSEvent {\n\t\tconst firstRecord = event.Records[0];\n\t\treturn (\n\t\t\t'Records' in event &&\n\t\t\tevent.Records.length > 0 &&\n\t\t\tfirstRecord !== undefined &&\n\t\t\t'EventSource' in firstRecord &&\n\t\t\tfirstRecord.EventSource === 'aws:sns'\n\t\t);\n\t}\n\n\tprivate parseSNSRecord(record: SNSEventRecord): any {\n\t\tconst message = this.safeJsonParse(record.Sns.Message);\n\t\tconst messageType = record.Sns.MessageAttributes?.type?.Value;\n\n\t\t// Not JSON — wrap raw string with type from MessageAttributes if available\n\t\tif (message === null) {\n\t\t\treturn messageType\n\t\t\t\t? { type: messageType, payload: record.Sns.Message }\n\t\t\t\t: record.Sns.Message;\n\t\t}\n\n\t\t// Resolve type from MessageAttributes (preferred) or message body\n\t\tconst resolvedType = messageType ?? message.type;\n\n\t\tif (message.type) {\n\t\t\treturn message; // Full event format: { type, payload }\n\t\t}\n\n\t\t// Payload-only format: type is in MessageAttributes\n\t\treturn resolvedType ? { type: resolvedType, payload: message } : message;\n\t}\n\n\tprivate parseSQSRecord(record: SQSRecord): any {\n\t\tconst body = this.safeJsonParse(record.body);\n\n\t\t// Not JSON — return raw body as-is\n\t\tif (body === null) {\n\t\t\treturn record.body;\n\t\t}\n\n\t\t// Check if this is an SNS message wrapped in SQS\n\t\tif (body.Type === 'Notification' && body.Message) {\n\t\t\tconst snsMessage = this.safeJsonParse(body.Message);\n\t\t\tconst messageType = body.MessageAttributes?.type?.Value;\n\n\t\t\t// SNS Message not JSON — wrap with type from MessageAttributes if available\n\t\t\tif (snsMessage === null) {\n\t\t\t\treturn messageType\n\t\t\t\t\t? { type: messageType, payload: body.Message }\n\t\t\t\t\t: body.Message;\n\t\t\t}\n\n\t\t\tif (snsMessage.type) {\n\t\t\t\treturn snsMessage; // Full event format: { type, payload }\n\t\t\t}\n\n\t\t\t// Payload-only format: type is in MessageAttributes\n\t\t\tconst resolvedType = messageType ?? snsMessage.type;\n\t\t\treturn resolvedType\n\t\t\t\t? { type: resolvedType, payload: snsMessage }\n\t\t\t\t: snsMessage;\n\t\t}\n\n\t\t// Direct SQS message\n\t\treturn body;\n\t}\n\n\tprivate safeJsonParse(value: string): any | null {\n\t\ttry {\n\t\t\treturn JSON.parse(value);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate shouldIncludeEvent(event: any): boolean {\n\t\t// No event type (raw string/non-object) — always include\n\t\tif (typeof event !== 'object' || !event?.type) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// No filter configured — accept all\n\t\tif (!this.subscriber.subscribedEvents) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn this.subscriber.subscribedEvents.includes(event.type as any);\n\t}\n\n\tprivate async _handler(event: SubscriberEvent<TServices, TLogger>) {\n\t\t// If no events after filtering, return early\n\t\tif (event.events.length === 0) {\n\t\t\tthis.logger.info('No subscribed events to process');\n\t\t\treturn {\n\t\t\t\tbatchItemFailures: [],\n\t\t\t};\n\t\t}\n\n\t\t// Execute the subscriber with the parsed context\n\t\tconst result = await this.subscriber.handler({\n\t\t\tevents: event.events,\n\t\t\tservices: event.services,\n\t\t\tlogger: event.logger,\n\t\t});\n\n\t\t// Parse output if schema is provided\n\t\tif (this.subscriber.outputSchema && result) {\n\t\t\tconst validationResult =\n\t\t\t\tawait this.subscriber.outputSchema['~standard'].validate(result);\n\n\t\t\tif (validationResult.issues) {\n\t\t\t\tthis.logger.error(\n\t\t\t\t\t{ issues: validationResult.issues },\n\t\t\t\t\t'Subscriber output validation failed',\n\t\t\t\t);\n\t\t\t\tthrow new Error('Subscriber output validation failed');\n\t\t\t}\n\n\t\t\treturn validationResult.value;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tget handler(): AWSLambdaHandler {\n\t\tconst handler = this._handler.bind(this);\n\n\t\t// Apply middleware in order\n\t\tconst chain = middy(handler)\n\t\t\t.use(this.loggerMiddleware())\n\t\t\t.use(this.parseEvents())\n\t\t\t.use(this.error())\n\t\t\t.use(this.services());\n\n\t\t// Wrap entire Middy chain in request context for service access\n\t\tconst wrappedHandler = async (event: unknown, context: Context) => {\n\t\t\tconst startTime = Date.now();\n\t\t\tconst requestId = context.awsRequestId;\n\t\t\tconst logger = this.subscriber.logger.child({\n\t\t\t\trequestId,\n\t\t\t}) as TLogger;\n\n\t\t\treturn runWithRequestContext({ logger, requestId, startTime }, () =>\n\t\t\t\tchain(event as Parameters<typeof chain>[0], context),\n\t\t\t);\n\t\t};\n\n\t\treturn wrappedHandler as unknown as AWSLambdaHandler;\n\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AAO,KAAK,kCAAkC;AACnD,UAAO,EACN,mBAAmB,CAAE,EACrB;EACD;EAGD,MAAM,SAAS,MAAM,KAAK,WAAW,QAAQ;GAC5C,QAAQ,MAAM;GACd,UAAU,MAAM;GAChB,QAAQ,MAAM;EACd,EAAC;AAGF,MAAI,KAAK,WAAW,gBAAgB,QAAQ;GAC3C,MAAM,mBACL,MAAM,KAAK,WAAW,aAAa,aAAa,SAAS,OAAO;AAEjE,OAAI,iBAAiB,QAAQ;AAC5B,SAAK,OAAO,MACX,EAAE,QAAQ,iBAAiB,OAAQ,GACnC,sCACA;AACD,UAAM,IAAI,MAAM;GAChB;AAED,UAAO,iBAAiB;EACxB;AAED,SAAO;CACP;CAED,IAAI,UAA4B;EAC/B,MAAM,UAAU,KAAK,SAAS,KAAK,KAAK;EAGxC,MAAM,QAAQ,MAAM,QAAQ,CAC1B,IAAI,KAAK,kBAAkB,CAAC,CAC5B,IAAI,KAAK,aAAa,CAAC,CACvB,IAAI,KAAK,OAAO,CAAC,CACjB,IAAI,KAAK,UAAU,CAAC;EAGtB,MAAM,iBAAiB,OAAOC,OAAgBC,YAAqB;GAClE,MAAM,YAAY,KAAK,KAAK;GAC5B,MAAM,YAAY,QAAQ;GAC1B,MAAM,SAAS,KAAK,WAAW,OAAO,MAAM,EAC3C,UACA,EAAC;AAEF,UAAO,sBAAsB;IAAE;IAAQ;IAAW;GAAW,GAAE,MAC9D,MAAM,OAAsC,QAAQ,CACpD;EACD;AAED,SAAO;CACP;AACD"}
|
|
1
|
+
{"version":3,"file":"aws.mjs","names":["envParser: EnvironmentParser<{}>","endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTAuditStorage,\n\t\t\tTAuditStorageServiceName,\n\t\t\tTAuditAction\n\t\t>","options: AmazonApiGatewayEndpointOptions","body: string | undefined | null","isBase64Encoded: boolean | undefined","contentType: string | undefined","e: TEvent","event: Event<TEvent, TInput, TServices, TLogger, TSession>","db: any","metadata","output","trx: any","result","lambdaResponse: AmazonApiGatewayEndpointHandlerResponse","baseHeaders: Record<string, string> | undefined","setCookieHeaders: string[]","ctx: any","event: TEvent","context: Context","queryParams: Record<string, string | string[] | undefined> | null","parts: string[]","e: APIGatewayProxyEvent","mergedParams: Record<string, string | string[]>","data: APIGatewayProxyEvent","context: Context","envParser: EnvironmentParser<{}>","endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher\n\t\t>","options: AmazonApiGatewayEndpointOptions","e: APIGatewayProxyEventV2","event: APIGatewayProxyEventV2","context: Context","envParser: EnvironmentParser<{}>","endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher\n\t\t>","options: AmazonApiGatewayEndpointOptions","envParser: EnvironmentParser<{}>","queue: Queue<TName, TMessage, TServices, TLogger>","value: string","record: SQSRecord","event: SQSEvent","context: Context","batchItemFailures: { itemIdentifier: string }[]","messages: InferStandardSchema<TMessage>[]","envParser: EnvironmentParser<{}>","subscriber: Subscriber<\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTSubscribedEvents\n\t\t>","events: any[]","event: SQSEvent | SNSEvent","record: SNSEventRecord","record: SQSRecord","value: string","event: any","event: SubscriberEvent<TServices, TLogger>","event: unknown","context: Context"],"sources":["../../src/endpoints/AmazonApiGatewayEndpointAdaptor.ts","../../src/endpoints/parseQueryParams.ts","../../src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts","../../src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts","../../src/queue/AWSLambdaQueueAdaptor.ts","../../src/subscribers/AWSLambdaSubscriberAdaptor.ts"],"sourcesContent":["import type { AuditableAction, AuditStorage } from '@geekmidas/audit';\nimport { withRlsContext } from '@geekmidas/db/rls';\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Logger } from '@geekmidas/logger';\nimport middy, { type MiddlewareObj } from '@middy/core';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type {\n\tAPIGatewayProxyEvent,\n\tAPIGatewayProxyEventV2,\n\tContext,\n} from 'aws-lambda';\nimport type { Telemetry } from '../telemetry';\nimport type { HttpMethod } from '../types';\nimport { Endpoint, type EndpointSchemas, ResponseBuilder } from './Endpoint';\n\n/**\n * Telescope integration for request recording.\n * Uses Middy middleware pattern for compatibility with existing telescope package.\n */\nexport interface TelescopeIntegration {\n\tmiddleware: MiddlewareObj<any, any, Error, Context>;\n}\n\nimport {\n\tForbiddenError,\n\tUnprocessableEntityError,\n\twrapError,\n} from '@geekmidas/errors';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type {\n\tInferComposableStandardSchema,\n\tInferStandardSchema,\n} from '@geekmidas/schema';\nimport {\n\trunWithRequestContext,\n\ttype Service,\n\tServiceDiscovery,\n\ttype ServiceRecord,\n} from '@geekmidas/services';\nimport { startMonitors } from '../monitor';\nimport { publishConstructEvents } from '../publisher';\nimport type { MappedAudit } from './audit';\nimport type { CookieFn, HeaderFn } from './Endpoint';\nimport {\n\tcreateAuditContext,\n\texecuteWithAuditTransaction,\n} from './processAudits';\n\n// Helper function to publish events\n\n/**\n * Options for Amazon API Gateway endpoint adaptors\n */\nexport interface AmazonApiGatewayEndpointOptions {\n\t/**\n\t * Telescope integration for request recording and monitoring.\n\t *\n\t * @example\n\t * ```typescript\n\t * import { telescopeMiddleware } from '@geekmidas/telescope/lambda';\n\t *\n\t * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n\t * telescope: { middleware: telescopeMiddleware(telescope) },\n\t * });\n\t * ```\n\t */\n\ttelescope?: TelescopeIntegration;\n\n\t/**\n\t * Telemetry integration for distributed tracing.\n\t * Works with any OpenTelemetry-compatible backend.\n\t *\n\t * @example\n\t * ```typescript\n\t * import { OTelTelemetry } from '@geekmidas/telescope/instrumentation';\n\t *\n\t * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n\t * telemetry: new OTelTelemetry(),\n\t * });\n\t * ```\n\t */\n\ttelemetry?: Telemetry;\n}\n\nexport abstract class AmazonApiGatewayEndpoint<\n\tTHandler extends\n\t\t| AmazonApiGatewayV1EndpointHandler\n\t\t| AmazonApiGatewayV2EndpointHandler,\n\tTEvent extends HandlerEvent<THandler>,\n\tTRoute extends string,\n\tTMethod extends HttpMethod,\n\tTInput extends EndpointSchemas = {},\n\tTOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTAuditStorage extends AuditStorage | undefined = undefined,\n\tTAuditStorageServiceName extends string = string,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n> {\n\tprotected options: AmazonApiGatewayEndpointOptions;\n\n\tconstructor(\n\t\tprotected envParser: EnvironmentParser<{}>,\n\t\tprotected readonly endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTAuditStorage,\n\t\t\tTAuditStorageServiceName,\n\t\t\tTAuditAction\n\t\t>,\n\t\toptions: AmazonApiGatewayEndpointOptions = {},\n\t) {\n\t\tthis.options = options;\n\t}\n\n\tprivate error(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tonError: (req) => {\n\t\t\t\t(req.event.logger || this.endpoint.logger).error(\n\t\t\t\t\treq.error || {},\n\t\t\t\t\t'Error processing request',\n\t\t\t\t);\n\t\t\t\tconst wrappedError = wrapError(req.error);\n\t\t\t\t// Kept for the monitors, which only see the response otherwise.\n\t\t\t\t(req.event as any).__error = req.error;\n\n\t\t\t\t// Set the response with the proper status code from the HttpError\n\t\t\t\treq.response = {\n\t\t\t\t\tstatusCode: wrappedError.statusCode,\n\t\t\t\t\tbody: wrappedError.body,\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t}\n\tabstract getInput(e: TEvent): GetInputResponse;\n\n\t/**\n\t * Decodes the raw body from an API Gateway event.\n\t * Uses Content-Type to decide parsing strategy (like Express/Fastify/Hono):\n\t * - `application/json` (or missing) → JSON.parse the decoded string\n\t * - Anything else → return decoded string as-is, let the schema handle it\n\t *\n\t * Defaults to JSON when no Content-Type is provided for backwards compatibility.\n\t */\n\tstatic decodeBody(\n\t\tbody: string | undefined | null,\n\t\tisBase64Encoded: boolean | undefined,\n\t\tcontentType: string | undefined,\n\t): any {\n\t\tif (!body) return undefined;\n\n\t\tconst raw = isBase64Encoded\n\t\t\t? Buffer.from(body, 'base64').toString('utf-8')\n\t\t\t: body;\n\n\t\tconst isJson =\n\t\t\t!contentType || contentType.toLowerCase().includes('application/json');\n\t\tif (isJson) {\n\t\t\treturn JSON.parse(raw);\n\t\t}\n\n\t\treturn raw;\n\t}\n\n\tprotected getCookies(e: TEvent): CookieFn {\n\t\tconst headers = e.headers as Record<string, string>;\n\t\treturn Endpoint.createCookies(headers?.cookie);\n\t}\n\n\tprivate input(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { body, query, params } = this.getInput(req.event);\n\t\t\t\t\tconst headers = req.event.headers as Record<string, string>;\n\t\t\t\t\tconst header = Endpoint.createHeaders(headers);\n\t\t\t\t\tconst cookie = this.getCookies(req.event);\n\n\t\t\t\t\tObject.assign(req.event, {\n\t\t\t\t\t\tbody: await this.endpoint.parseInput(body, 'body'),\n\t\t\t\t\t\tquery: await this.endpoint.parseInput(query, 'query'),\n\t\t\t\t\t\tparams: await this.endpoint.parseInput(params, 'params'),\n\t\t\t\t\t\theader,\n\t\t\t\t\t\tcookie,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Convert validation errors to 422 Unprocessable Entity\n\t\t\t\t\tif (error && typeof error === 'object' && Array.isArray(error)) {\n\t\t\t\t\t\tthrow new UnprocessableEntityError('Validation failed', error);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tabstract getLoggerContext(data: TEvent, context: Context): LoggerContext;\n\n\tprivate logger(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: (req) => {\n\t\t\t\treq.event.logger = this.endpoint.logger.child({\n\t\t\t\t\troute: this.endpoint.route,\n\t\t\t\t\thost: req.event.headers?.host,\n\t\t\t\t\tmethod: this.endpoint.method,\n\t\t\t\t\t...this.getLoggerContext(req.event, req.context),\n\t\t\t\t}) as TLogger;\n\t\t\t},\n\t\t};\n\t}\n\tprivate services(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\tconst _logger = req.event.logger as TLogger;\n\t\t\t\tconst serviceDiscovery = ServiceDiscovery.getInstance<\n\t\t\t\t\tServiceRecord<TServices>\n\t\t\t\t>(this.envParser);\n\n\t\t\t\tconst services = await serviceDiscovery.register(\n\t\t\t\t\tthis.endpoint.services,\n\t\t\t\t);\n\n\t\t\t\treq.event.services = services;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate authorize(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\tconst logger = req.event.logger as TLogger;\n\t\t\t\tconst services = req.event.services;\n\t\t\t\tconst header = req.event.header;\n\t\t\t\tconst cookie = req.event.cookie;\n\t\t\t\tconst session = req.event.session as TSession;\n\n\t\t\t\tconst isAuthorized = await this.endpoint.authorize({\n\t\t\t\t\theader,\n\t\t\t\t\tcookie,\n\t\t\t\t\tservices,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsession,\n\t\t\t\t\t...((req.event as any).db !== undefined && {\n\t\t\t\t\t\tdb: (req.event as any).db,\n\t\t\t\t\t}),\n\t\t\t\t\tbody: (req.event as any).body,\n\t\t\t\t\tquery: (req.event as any).query,\n\t\t\t\t\tparams: (req.event as any).params,\n\t\t\t\t} as any);\n\n\t\t\t\tif (!isAuthorized) {\n\t\t\t\t\tlogger.warn('Forbidden access attempt');\n\t\t\t\t\tthrow new ForbiddenError(\n\t\t\t\t\t\t'Forbidden access to the endpoint',\n\t\t\t\t\t\t'You do not have permission to access this resource.',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate database(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\tif (!this.endpoint.databaseService) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst _logger = req.event.logger as TLogger;\n\t\t\t\tconst serviceDiscovery = ServiceDiscovery.getInstance<\n\t\t\t\t\tServiceRecord<TServices>\n\t\t\t\t>(this.envParser);\n\n\t\t\t\tconst db = await serviceDiscovery\n\t\t\t\t\t.register([this.endpoint.databaseService])\n\t\t\t\t\t.then(\n\t\t\t\t\t\t(s) =>\n\t\t\t\t\t\t\ts[this.endpoint.databaseService?.serviceName as keyof typeof s],\n\t\t\t\t\t);\n\n\t\t\t\t(req.event as any).db = db;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate session(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\tconst logger = req.event.logger as TLogger;\n\t\t\t\tconst services = req.event.services;\n\t\t\t\tconst db = (req.event as any).db;\n\t\t\t\treq.event.session = (await this.endpoint.getSession({\n\t\t\t\t\tlogger,\n\t\t\t\t\tservices,\n\t\t\t\t\theader: req.event.header,\n\t\t\t\t\tcookie: req.event.cookie,\n\t\t\t\t\t...(db !== undefined && { db }),\n\t\t\t\t} as any)) as TSession;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate events(): Middleware<TEvent, TInput, TServices, TLogger> {\n\t\treturn {\n\t\t\tafter: async (req) => {\n\t\t\t\tconst event = req.event;\n\t\t\t\tconst response = (event as any)\n\t\t\t\t\t.__response as InferStandardSchema<TOutSchema>;\n\t\t\t\tconst statusCode = req.response?.statusCode ?? this.endpoint.status;\n\n\t\t\t\t// Only publish events on successful responses (2xx status codes)\n\t\t\t\t// Note: Audits are processed inside the handler's transaction\n\t\t\t\tif (Endpoint.isSuccessStatus(statusCode)) {\n\t\t\t\t\tconst logger = event.logger as TLogger;\n\t\t\t\t\tconst serviceDiscovery = ServiceDiscovery.getInstance<\n\t\t\t\t\t\tServiceRecord<TServices>\n\t\t\t\t\t>(this.envParser);\n\n\t\t\t\t\t// Publish events\n\t\t\t\t\tawait publishConstructEvents(\n\t\t\t\t\t\tthis.endpoint,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t\tserviceDiscovery,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate async _handler(\n\t\tevent: Event<TEvent, TInput, TServices, TLogger, TSession>,\n\t) {\n\t\tconst input = this.endpoint.refineInput(event);\n\t\tconst logger = event.logger as TLogger;\n\t\tconst serviceDiscovery = ServiceDiscovery.getInstance<\n\t\t\tServiceRecord<TServices>\n\t\t>(this.envParser);\n\n\t\t// Create audit context if audit storage is configured\n\t\tconst auditContext = await createAuditContext(\n\t\t\tthis.endpoint,\n\t\t\tserviceDiscovery,\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\tsession: event.session,\n\t\t\t\theader: event.header,\n\t\t\t\tcookie: event.cookie,\n\t\t\t\tservices: event.services as Record<string, unknown>,\n\t\t\t},\n\t\t);\n\n\t\t// Warn if declarative audits are configured but no audit storage\n\t\tconst audits = this.endpoint.audits as MappedAudit<\n\t\t\tTAuditAction,\n\t\t\tTOutSchema\n\t\t>[];\n\t\tif (!auditContext && audits?.length) {\n\t\t\tlogger.warn('No auditor storage service available');\n\t\t}\n\n\t\t// Get pre-resolved database from middleware\n\t\tconst rawDb = (event as any).db;\n\n\t\t// Extract RLS context if configured and not bypassed\n\t\tconst rlsActive =\n\t\t\tthis.endpoint.rlsConfig &&\n\t\t\t!this.endpoint.rlsBypass &&\n\t\t\trawDb !== undefined;\n\t\tconst rlsContext = rlsActive\n\t\t\t? await this.endpoint.rlsConfig?.extractor({\n\t\t\t\t\tservices: event.services as ServiceRecord<TServices>,\n\t\t\t\t\tsession: event.session,\n\t\t\t\t\theader: event.header,\n\t\t\t\t\tcookie: event.cookie,\n\t\t\t\t\tlogger,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\t\t// Execute handler with automatic audit transaction support\n\t\tconst result = await executeWithAuditTransaction(\n\t\t\tauditContext,\n\t\t\tasync (auditor) => {\n\t\t\t\t// Use audit transaction as db only if the storage uses the same database service\n\t\t\t\tconst sameDatabase =\n\t\t\t\t\tauditContext?.storage?.databaseServiceName &&\n\t\t\t\t\tauditContext.storage.databaseServiceName ===\n\t\t\t\t\t\tthis.endpoint.databaseService?.serviceName;\n\t\t\t\tconst baseDb = sameDatabase\n\t\t\t\t\t? (auditor?.getTransaction?.() ?? rawDb)\n\t\t\t\t\t: rawDb;\n\n\t\t\t\t// Helper to execute handler with given db\n\t\t\t\tconst executeHandler = async (db: any) => {\n\t\t\t\t\tconst responseBuilder = new ResponseBuilder();\n\t\t\t\t\tconst response = await this.endpoint.handler(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\theader: event.header,\n\t\t\t\t\t\t\tcookie: event.cookie,\n\t\t\t\t\t\t\tlogger: event.logger,\n\t\t\t\t\t\t\tservices: event.services,\n\t\t\t\t\t\t\tsession: event.session,\n\t\t\t\t\t\t\tauditor,\n\t\t\t\t\t\t\tdb,\n\t\t\t\t\t\t\t...input,\n\t\t\t\t\t\t} as any,\n\t\t\t\t\t\tresponseBuilder,\n\t\t\t\t\t);\n\n\t\t\t\t\t// Check if response has metadata\n\t\t\t\t\tlet data = response;\n\t\t\t\t\tlet metadata = responseBuilder.getMetadata();\n\n\t\t\t\t\tif (Endpoint.hasMetadata(response)) {\n\t\t\t\t\t\tdata = response.data;\n\t\t\t\t\t\tmetadata = response.metadata;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst output = this.endpoint.outputSchema\n\t\t\t\t\t\t? await this.endpoint.parseOutput(data)\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\treturn { output, metadata, responseBuilder };\n\t\t\t\t};\n\n\t\t\t\t// If RLS is active, wrap handler with RLS context\n\t\t\t\tif (rlsActive && rlsContext && baseDb) {\n\t\t\t\t\treturn withRlsContext(\n\t\t\t\t\t\tbaseDb,\n\t\t\t\t\t\trlsContext,\n\t\t\t\t\t\tasync (trx: any) => executeHandler(trx),\n\t\t\t\t\t\t{ prefix: this.endpoint.rlsConfig?.prefix },\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn executeHandler(baseDb);\n\t\t\t},\n\t\t\t// Process declarative audits after handler (inside transaction)\n\t\t\tasync (result, auditor) => {\n\t\t\t\tif (!audits?.length) return;\n\n\t\t\t\tfor (const audit of audits) {\n\t\t\t\t\tif (audit.when && !audit.when(result.output as any)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst payload = audit.payload(result.output as any);\n\t\t\t\t\tconst entityId = audit.entityId?.(result.output as any);\n\t\t\t\t\tauditor.audit(audit.type as any, payload as any, {\n\t\t\t\t\t\ttable: audit.table,\n\t\t\t\t\t\tentityId,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Pass rawDb so storage can reuse existing transactions\n\t\t\t{ db: rawDb },\n\t\t);\n\n\t\tconst { output, metadata } = result;\n\t\tconst isJsonResponse = this.endpoint.responseType === 'application/json';\n\t\tconst body =\n\t\t\toutput === undefined\n\t\t\t\t? undefined\n\t\t\t\t: isJsonResponse\n\t\t\t\t\t? JSON.stringify(output)\n\t\t\t\t\t: typeof output === 'string'\n\t\t\t\t\t\t? output\n\t\t\t\t\t\t: String(output);\n\n\t\t// Store response for middleware access\n\t\t(event as any).__response = output;\n\n\t\t// Build response with metadata\n\t\tconst lambdaResponse: AmazonApiGatewayEndpointHandlerResponse = {\n\t\t\tstatusCode: metadata.status ?? this.endpoint.status,\n\t\t\tbody,\n\t\t};\n\n\t\t// Compose headers. For non-JSON responseType, emit a default\n\t\t// Content-Type header which metadata.headers (r.header()) can override.\n\t\tconst baseHeaders: Record<string, string> | undefined = isJsonResponse\n\t\t\t? undefined\n\t\t\t: { 'content-type': this.endpoint.responseType };\n\n\t\tif (\n\t\t\tbaseHeaders ||\n\t\t\t(metadata.headers && Object.keys(metadata.headers).length > 0)\n\t\t) {\n\t\t\tlambdaResponse.headers = {\n\t\t\t\t...(baseHeaders ?? {}),\n\t\t\t\t...(metadata.headers ?? {}),\n\t\t\t};\n\t\t}\n\n\t\t// Format cookies as Set-Cookie headers\n\t\tif (metadata.cookies && metadata.cookies.size > 0) {\n\t\t\tconst setCookieHeaders: string[] = [];\n\t\t\tfor (const [name, { value, options }] of metadata.cookies) {\n\t\t\t\tsetCookieHeaders.push(\n\t\t\t\t\tEndpoint.formatCookieHeader(name, value, options),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (setCookieHeaders.length > 0) {\n\t\t\t\tlambdaResponse.multiValueHeaders = {\n\t\t\t\t\t...lambdaResponse.multiValueHeaders,\n\t\t\t\t\t'Set-Cookie': setCookieHeaders,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn lambdaResponse;\n\t}\n\n\t/**\n\t * Convert Telemetry interface to Middy middleware\n\t */\n\tprivate telemetry(): Middleware<TEvent, TInput, TServices, TLogger> | null {\n\t\tif (!this.options.telemetry) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst telemetry = this.options.telemetry;\n\t\tlet ctx: any;\n\n\t\treturn {\n\t\t\tbefore: (request) => {\n\t\t\t\tctx = telemetry.onRequestStart({\n\t\t\t\t\tevent: request.event,\n\t\t\t\t\tcontext: request.context,\n\t\t\t\t});\n\t\t\t},\n\t\t\tafter: (request) => {\n\t\t\t\tif (ctx) {\n\t\t\t\t\ttelemetry.onRequestEnd(ctx, {\n\t\t\t\t\t\tstatusCode: request.response?.statusCode ?? 200,\n\t\t\t\t\t\tbody: request.response?.body,\n\t\t\t\t\t\theaders: request.response?.headers,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t\tonError: (request) => {\n\t\t\t\tif (ctx && request.error) {\n\t\t\t\t\ttelemetry.onRequestError(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\trequest.error instanceof Error\n\t\t\t\t\t\t\t? request.error\n\t\t\t\t\t\t\t: new Error(String(request.error)),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tget handler() {\n\t\tconst handler = this._handler.bind(this);\n\t\tlet chain = middy(handler)\n\t\t\t.use(this.logger())\n\t\t\t.use(this.error())\n\t\t\t.use(this.services())\n\t\t\t.use(this.input())\n\t\t\t.use(this.database())\n\t\t\t.use(this.session())\n\t\t\t.use(this.authorize())\n\t\t\t.use(this.events());\n\n\t\t// Add telemetry middleware if configured (runs early for span creation)\n\t\tconst telemetryMiddleware = this.telemetry();\n\t\tif (telemetryMiddleware) {\n\t\t\tchain = chain.use(telemetryMiddleware);\n\t\t}\n\n\t\t// Add Telescope middleware if configured (runs first/last in chain)\n\t\tif (this.options.telescope?.middleware) {\n\t\t\tchain = chain.use(this.options.telescope.middleware);\n\t\t}\n\n\t\t// Wrap entire Middy chain in request context for service access\n\t\tconst wrappedHandler = async (event: TEvent, context: Context) => {\n\t\t\tconst startTime = Date.now();\n\t\t\tconst requestId = context.awsRequestId;\n\t\t\tconst logger = this.endpoint.logger.child({ requestId }) as TLogger;\n\n\t\t\t// Cast event to any since Middy middlewares enrich the event with\n\t\t\t// services, logger, session, etc. during the middleware chain execution\n\t\t\treturn runWithRequestContext(\n\t\t\t\t{ logger, requestId, startTime },\n\t\t\t\tasync () => {\n\t\t\t\t\tconst monitor = await startMonitors(\n\t\t\t\t\t\tthis.endpoint,\n\t\t\t\t\t\tServiceDiscovery.getInstance(this.envParser),\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t);\n\t\t\t\t\tconst response = await chain(\n\t\t\t\t\t\tevent as unknown as Parameters<typeof chain>[0],\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t);\n\t\t\t\t\t// Awaited: Lambda freezes the process once the response is\n\t\t\t\t\t// returned, so an unawaited ping may never be sent.\n\t\t\t\t\tawait monitor.settle(\n\t\t\t\t\t\t(response as any)?.statusCode ?? 200,\n\t\t\t\t\t\t(event as any).__error,\n\t\t\t\t\t);\n\t\t\t\t\treturn response;\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\treturn wrappedHandler as unknown as THandler;\n\t}\n}\n\nexport type Event<\n\tTEvent extends APIGatewayProxyEvent | APIGatewayProxyEventV2,\n\tTInput extends EndpointSchemas = {},\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n> = {\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n\theader: HeaderFn;\n\tcookie: CookieFn;\n\tsession: TSession;\n} & TEvent &\n\tInferComposableStandardSchema<TInput>;\n\ntype Middleware<\n\tTEvent extends APIGatewayProxyEvent | APIGatewayProxyEventV2,\n\tTInput extends EndpointSchemas = {},\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n> = MiddlewareObj<Event<TEvent, TInput, TServices, TLogger, TSession>>;\n\nexport type AmazonApiGatewayEndpointHandlerResponse = {\n\tstatusCode: number;\n\tbody: string | undefined;\n\theaders?: Record<string, string>;\n\tmultiValueHeaders?: Record<string, string[]>;\n};\n\nexport type LoggerContext = {\n\tfn: {\n\t\tname: string;\n\t\tversion: string;\n\t};\n\treq: {\n\t\tid: string | undefined;\n\t\tawsRequestId: string;\n\t\tpath: string;\n\t\tip: string | undefined;\n\t\tuserAgent: string | undefined;\n\t};\n};\n\nexport type GetInputResponse = {\n\tbody: any;\n\tquery: any;\n\tparams: any;\n};\n\nexport type AmazonApiGatewayV1EndpointHandler = (\n\tevent: APIGatewayProxyEvent,\n\tcontext: Context,\n) => Promise<AmazonApiGatewayEndpointHandlerResponse>;\n\nexport type AmazonApiGatewayV2EndpointHandler = (\n\tevent: APIGatewayProxyEventV2,\n\tcontext: Context,\n) => Promise<AmazonApiGatewayEndpointHandlerResponse>;\n\nexport type HandlerEvent<T extends Function> = T extends (\n\tevent: infer E,\n\tcontext: Context,\n) => any\n\t? E\n\t: never;\n","import qs from 'qs';\n\n/**\n * Parse query parameters from a flat object into a nested structure\n * Uses qs bracket notation for standard interoperability\n *\n * @example\n * parseQueryParams({ 'tags[]': ['a', 'b'], 'filter[name]': 'john' })\n * // Returns: { tags: ['a', 'b'], filter: { name: 'john' } }\n */\nexport function parseQueryParams(\n\tqueryParams: Record<string, string | string[] | undefined> | null,\n): Record<string, any> {\n\tif (!queryParams) {\n\t\treturn {};\n\t}\n\n\t// Reconstruct a query string from the flat object so qs can parse bracket notation\n\tconst parts: string[] = [];\n\tfor (const [key, value] of Object.entries(queryParams)) {\n\t\tif (value === undefined) continue;\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (const v of value) {\n\t\t\t\tparts.push(`${encodeURIComponent(key)}=${encodeURIComponent(v)}`);\n\t\t\t}\n\t\t} else {\n\t\t\tparts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);\n\t\t}\n\t}\n\n\treturn qs.parse(parts.join('&')) as Record<string, any>;\n}\n","import type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { APIGatewayProxyEvent, Context } from 'aws-lambda';\nimport type { HttpMethod } from '../types';\nimport {\n\tAmazonApiGatewayEndpoint,\n\ttype AmazonApiGatewayEndpointOptions,\n\ttype AmazonApiGatewayV1EndpointHandler,\n\ttype GetInputResponse,\n\ttype LoggerContext,\n} from './AmazonApiGatewayEndpointAdaptor';\nimport type { Endpoint, EndpointSchemas } from './Endpoint';\nimport { parseQueryParams } from './parseQueryParams';\n\nexport class AmazonApiGatewayV1Endpoint<\n\tTRoute extends string,\n\tTMethod extends HttpMethod,\n\tTInput extends EndpointSchemas = {},\n\tTOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n> extends AmazonApiGatewayEndpoint<\n\tAmazonApiGatewayV1EndpointHandler,\n\tAPIGatewayProxyEvent,\n\tTRoute,\n\tTMethod,\n\tTInput,\n\tTOutSchema,\n\tTServices,\n\tTLogger,\n\tTSession,\n\tTEventPublisher\n> {\n\toverride getInput(e: APIGatewayProxyEvent): GetInputResponse {\n\t\t// For arrays, AWS API Gateway V1 provides multiValueQueryStringParameters\n\t\tconst multiValueParams = e.multiValueQueryStringParameters || {};\n\t\tconst singleValueParams = e.queryStringParameters || {};\n\n\t\t// Merge single and multi-value parameters\n\t\tconst mergedParams: Record<string, string | string[]> = {};\n\n\t\t// Add single value parameters\n\t\tfor (const [key, value] of Object.entries(singleValueParams)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tmergedParams[key] = value;\n\t\t\t}\n\t\t}\n\n\t\t// Override with multi-value parameters where applicable\n\t\tfor (const [key, values] of Object.entries(multiValueParams)) {\n\t\t\tif (values && values.length > 1) {\n\t\t\t\tmergedParams[key] = values;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tbody: AmazonApiGatewayEndpoint.decodeBody(\n\t\t\t\te.body,\n\t\t\t\te.isBase64Encoded,\n\t\t\t\te.headers?.['Content-Type'] ?? e.headers?.['content-type'],\n\t\t\t),\n\t\t\tquery: parseQueryParams(mergedParams),\n\t\t\tparams: e.pathParameters || {},\n\t\t};\n\t}\n\toverride getLoggerContext(\n\t\tdata: APIGatewayProxyEvent,\n\t\tcontext: Context,\n\t): LoggerContext {\n\t\treturn {\n\t\t\tfn: {\n\t\t\t\tname: context.functionName,\n\t\t\t\tversion: context.functionVersion,\n\t\t\t},\n\t\t\treq: {\n\t\t\t\tid: data.requestContext.requestId,\n\t\t\t\tawsRequestId: context.awsRequestId,\n\t\t\t\tip: data.requestContext.identity.sourceIp,\n\t\t\t\tuserAgent: data.requestContext.identity.userAgent || undefined,\n\t\t\t\tpath: data.requestContext.path,\n\t\t\t},\n\t\t};\n\t}\n\tconstructor(\n\t\tprotected override envParser: EnvironmentParser<{}>,\n\t\tprotected override readonly endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher\n\t\t>,\n\t\toptions: AmazonApiGatewayEndpointOptions = {},\n\t) {\n\t\tsuper(envParser, endpoint, options);\n\t}\n}\n","import type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { APIGatewayProxyEventV2, Context } from 'aws-lambda';\nimport qs from 'qs';\nimport type { HttpMethod } from '../types';\nimport {\n\tAmazonApiGatewayEndpoint,\n\ttype AmazonApiGatewayEndpointOptions,\n\ttype AmazonApiGatewayV2EndpointHandler,\n\ttype GetInputResponse,\n\ttype LoggerContext,\n} from './AmazonApiGatewayEndpointAdaptor';\nimport type { CookieFn, Endpoint, EndpointSchemas } from './Endpoint';\nimport { createApiGatewayCookies } from './lazyAccessors';\n\nexport class AmazonApiGatewayV2Endpoint<\n\tTRoute extends string,\n\tTMethod extends HttpMethod,\n\tTInput extends EndpointSchemas = {},\n\tTOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n> extends AmazonApiGatewayEndpoint<\n\tAmazonApiGatewayV2EndpointHandler,\n\tAPIGatewayProxyEventV2,\n\tTRoute,\n\tTMethod,\n\tTInput,\n\tTOutSchema,\n\tTServices,\n\tTLogger,\n\tTSession,\n\tTEventPublisher\n> {\n\toverride getCookies(e: APIGatewayProxyEventV2): CookieFn {\n\t\treturn createApiGatewayCookies(\n\t\t\te.cookies,\n\t\t\t(e.headers as Record<string, string>)?.cookie,\n\t\t);\n\t}\n\n\toverride getInput(e: APIGatewayProxyEventV2): GetInputResponse {\n\t\tconst raw = AmazonApiGatewayEndpoint.decodeBody(\n\t\t\te.body,\n\t\t\te.isBase64Encoded,\n\t\t\te.headers?.['content-type'],\n\t\t);\n\n\t\treturn {\n\t\t\tbody: raw,\n\t\t\tquery: qs.parse(e.rawQueryString) as Record<string, any>,\n\t\t\tparams: e.pathParameters || {},\n\t\t};\n\t}\n\toverride getLoggerContext(\n\t\tevent: APIGatewayProxyEventV2,\n\t\tcontext: Context,\n\t): LoggerContext {\n\t\treturn {\n\t\t\tfn: {\n\t\t\t\tname: context.functionName,\n\t\t\t\tversion: context.functionVersion,\n\t\t\t},\n\t\t\treq: {\n\t\t\t\tid: event.requestContext.requestId,\n\t\t\t\tawsRequestId: context.awsRequestId,\n\t\t\t\tip: event.requestContext.http.sourceIp,\n\t\t\t\tuserAgent: event.requestContext.http.userAgent || undefined,\n\t\t\t\tpath: event.requestContext.http.path,\n\t\t\t},\n\t\t};\n\t}\n\tconstructor(\n\t\tprotected override envParser: EnvironmentParser<{}>,\n\t\tprotected override readonly endpoint: Endpoint<\n\t\t\tTRoute,\n\t\t\tTMethod,\n\t\t\tTInput,\n\t\t\tTOutSchema,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTEventPublisher\n\t\t>,\n\t\toptions: AmazonApiGatewayEndpointOptions = {},\n\t) {\n\t\tsuper(envParser, endpoint, options);\n\t}\n}\n\n// Re-export options type for convenience\nexport type { AmazonApiGatewayEndpointOptions };\n","import type { EnvironmentParser } from '@geekmidas/envkit';\nimport { wrapError } from '@geekmidas/errors';\nimport type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport { runWithRequestContext, ServiceDiscovery } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type {\n\tContext,\n\tHandler,\n\tSQSBatchResponse,\n\tSQSEvent,\n\tSQSRecord,\n} from 'aws-lambda';\nimport type { Queue } from './Queue';\n\nexport type AWSLambdaHandler<TEvent = any, TResult = any> = Handler<\n\tTEvent,\n\tTResult\n>;\n\n/**\n * Runs a {@link Queue} worker as an AWS Lambda backed by an SQS event-source\n * mapping. Unlike a subscriber, a queue drains *every* record (no type filter):\n * each record body (`{ type, payload }`, as written by the SQS publisher) is\n * unwrapped to its `payload`, validated against the queue's `messageSchema`, and\n * the whole batch is handed to the handler as `messages`.\n *\n * Uses SQS partial-batch responses: a record that fails to parse, validate, or\n * (when the handler throws) process is returned in `batchItemFailures` so SQS\n * retries only those records.\n */\nexport class AWSLambdaQueue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _services?: ServiceRecord<TServices>;\n\n\tconstructor(\n\t\tprivate readonly envParser: EnvironmentParser<{}>,\n\t\treadonly queue: Queue<TName, TMessage, TServices, TLogger>,\n\t) {}\n\n\tget logger(): TLogger {\n\t\treturn this.queue.logger;\n\t}\n\n\tprivate async getServices(): Promise<ServiceRecord<TServices>> {\n\t\tif (this._services) {\n\t\t\treturn this._services;\n\t\t}\n\n\t\tconst serviceDiscovery = ServiceDiscovery.getInstance(this.envParser);\n\n\t\tthis._services =\n\t\t\tthis.queue.services.length > 0\n\t\t\t\t? ((await serviceDiscovery.register(\n\t\t\t\t\t\tthis.queue.services,\n\t\t\t\t\t)) as ServiceRecord<TServices>)\n\t\t\t\t: ({} as ServiceRecord<TServices>);\n\n\t\treturn this._services;\n\t}\n\n\tprivate safeJsonParse(value: string): unknown {\n\t\ttry {\n\t\t\treturn JSON.parse(value);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Unwrap the queue payload from an SQS record. The SQS publisher writes\n\t * `{ type, payload }`; a payload-only body is also accepted as-is.\n\t */\n\tprivate extractPayload(record: SQSRecord): unknown {\n\t\tconst body = this.safeJsonParse(record.body);\n\t\tif (body && typeof body === 'object' && 'payload' in body) {\n\t\t\treturn (body as { payload: unknown }).payload;\n\t\t}\n\t\treturn body ?? record.body;\n\t}\n\n\tprivate async _handler(\n\t\tevent: SQSEvent,\n\t\tcontext: Context,\n\t): Promise<SQSBatchResponse> {\n\t\tconst logger = this.queue.logger.child({\n\t\t\tqueue: {\n\t\t\t\tname: this.queue.name,\n\t\t\t\tfn: context.functionName,\n\t\t\t},\n\t\t\treq: { id: context.awsRequestId },\n\t\t}) as TLogger;\n\n\t\tconst services = await this.getServices();\n\t\tconst schema = this.queue.messageSchema;\n\n\t\tconst batchItemFailures: { itemIdentifier: string }[] = [];\n\t\tconst messages: InferStandardSchema<TMessage>[] = [];\n\n\t\tfor (const record of event.Records) {\n\t\t\ttry {\n\t\t\t\tconst payload = this.extractPayload(record);\n\t\t\t\tconst validation = await schema['~standard'].validate(payload);\n\t\t\t\tif (validation.issues) {\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t{ issues: validation.issues, messageId: record.messageId },\n\t\t\t\t\t\t'Queue message failed validation',\n\t\t\t\t\t);\n\t\t\t\t\tbatchItemFailures.push({ itemIdentifier: record.messageId });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tmessages.push(validation.value as InferStandardSchema<TMessage>);\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(\n\t\t\t\t\t{ error, messageId: record.messageId },\n\t\t\t\t\t'Failed to parse SQS record',\n\t\t\t\t);\n\t\t\t\tbatchItemFailures.push({ itemIdentifier: record.messageId });\n\t\t\t}\n\t\t}\n\n\t\tif (messages.length === 0) {\n\t\t\treturn { batchItemFailures };\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.queue.handler({ messages, services, logger });\n\t\t} catch (error) {\n\t\t\tlogger.error(wrapError(error), 'Queue handler failed; retrying batch');\n\t\t\t// Handler processes the batch atomically — fail the whole batch so SQS\n\t\t\t// retries every (valid) record.\n\t\t\tfor (const record of event.Records) {\n\t\t\t\tif (\n\t\t\t\t\t!batchItemFailures.some((f) => f.itemIdentifier === record.messageId)\n\t\t\t\t) {\n\t\t\t\t\tbatchItemFailures.push({ itemIdentifier: record.messageId });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { batchItemFailures };\n\t}\n\n\tget handler(): AWSLambdaHandler<SQSEvent, SQSBatchResponse> {\n\t\tconst handler = this._handler.bind(this);\n\n\t\treturn (async (event: SQSEvent, context: Context) => {\n\t\t\tconst startTime = Date.now();\n\t\t\tconst requestId = context.awsRequestId;\n\t\t\tconst logger = this.queue.logger.child({ requestId }) as TLogger;\n\n\t\t\treturn runWithRequestContext({ logger, requestId, startTime }, () =>\n\t\t\t\thandler(event, context),\n\t\t\t);\n\t\t}) as unknown as AWSLambdaHandler<SQSEvent, SQSBatchResponse>;\n\t}\n}\n","import type { EnvironmentParser } from '@geekmidas/envkit';\nimport { wrapError } from '@geekmidas/errors';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport { runWithRequestContext, ServiceDiscovery } from '@geekmidas/services';\nimport middy, { type MiddlewareObj } from '@middy/core';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type {\n\tContext,\n\tHandler,\n\tSNSEvent,\n\tSNSEventRecord,\n\tSQSEvent,\n\tSQSRecord,\n} from 'aws-lambda';\nimport type { Subscriber } from './Subscriber';\n\nexport type AWSLambdaHandler<TEvent = any, TResult = any> = Handler<\n\tTEvent,\n\tTResult\n>;\n\ntype SubscriberEvent<TServices extends Service[], TLogger extends Logger> = {\n\tevents: any[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\ntype Middleware<\n\tTServices extends Service[],\n\tTLogger extends Logger,\n\tTOutSchema extends StandardSchemaV1 | undefined,\n> = MiddlewareObj<\n\tSubscriberEvent<TServices, TLogger>,\n\tInferStandardSchema<TOutSchema>,\n\tError,\n\tContext\n>;\n\nexport class AWSLambdaSubscriber<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTSubscribedEvents extends any[] = [],\n> {\n\tprivate _logger!: TLogger;\n\tprivate _services!: ServiceRecord<TServices>;\n\n\tconstructor(\n\t\tprivate envParser: EnvironmentParser<{}>,\n\t\treadonly subscriber: Subscriber<\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTSubscribedEvents\n\t\t>,\n\t) {\n\t\tthis._logger = subscriber.logger;\n\t}\n\n\tget logger(): TLogger {\n\t\treturn this._logger;\n\t}\n\n\tprivate async getServices(): Promise<ServiceRecord<TServices>> {\n\t\tif (this._services) {\n\t\t\treturn this._services;\n\t\t}\n\n\t\tconst serviceDiscovery = ServiceDiscovery.getInstance(this.envParser);\n\n\t\tif (this.subscriber.services.length > 0) {\n\t\t\tconst registered = await serviceDiscovery.register(\n\t\t\t\tthis.subscriber.services,\n\t\t\t);\n\t\t\tthis._services = registered as ServiceRecord<TServices>;\n\t\t} else {\n\t\t\tthis._services = {} as ServiceRecord<TServices>;\n\t\t}\n\n\t\treturn this._services;\n\t}\n\n\tprivate error(): Middleware<TServices, TLogger, OutSchema> {\n\t\treturn {\n\t\t\tonError: (req) => {\n\t\t\t\tconst logger = req.event?.logger || this.subscriber.logger;\n\t\t\t\tlogger.error(req.error || {}, 'Error processing subscriber');\n\n\t\t\t\t// Re-throw the wrapped error to let Lambda handle it\n\t\t\t\tthrow wrapError(req.error);\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate loggerMiddleware(): Middleware<TServices, TLogger, OutSchema> {\n\t\treturn {\n\t\t\tbefore: (req) => {\n\t\t\t\tthis._logger = this.subscriber.logger.child({\n\t\t\t\t\tsubscriber: {\n\t\t\t\t\t\tname: req.context.functionName,\n\t\t\t\t\t\tversion: req.context.functionVersion,\n\t\t\t\t\t\tmemory: req.context.memoryLimitInMB,\n\t\t\t\t\t},\n\t\t\t\t\treq: {\n\t\t\t\t\t\tid: req.context.awsRequestId,\n\t\t\t\t\t},\n\t\t\t\t}) as TLogger;\n\n\t\t\t\treq.event.logger = this._logger;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate services(): Middleware<TServices, TLogger, OutSchema> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\treq.event.services = await this.getServices();\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate parseEvents(): Middleware<TServices, TLogger, OutSchema> {\n\t\treturn {\n\t\t\tbefore: async (req) => {\n\t\t\t\tconst { logger, ...e } = req.event;\n\t\t\t\tconst rawEvent = e as any as SQSEvent | SNSEvent;\n\n\t\t\t\tlogger.info({\n\t\t\t\t\trawEvent,\n\t\t\t\t});\n\n\t\t\t\t// Parse events based on the event type\n\t\t\t\tconst events: any[] = [];\n\n\t\t\t\tif ('Records' in rawEvent) {\n\t\t\t\t\tif (this.isSQSEvent(rawEvent)) {\n\t\t\t\t\t\t// SQS Event\n\t\t\t\t\t\tfor (const record of rawEvent.Records) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst event = this.parseSQSRecord(record);\n\t\t\t\t\t\t\t\tif (this.shouldIncludeEvent(event)) {\n\t\t\t\t\t\t\t\t\tevents.push(event);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t\t\t\t{ error, record },\n\t\t\t\t\t\t\t\t\t'Failed to parse SQS record',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (this.isSNSEvent(rawEvent)) {\n\t\t\t\t\t\t// SNS Event\n\t\t\t\t\t\tfor (const record of rawEvent.Records) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst event = this.parseSNSRecord(record);\n\t\t\t\t\t\t\t\tif (this.shouldIncludeEvent(event)) {\n\t\t\t\t\t\t\t\t\tevents.push(event);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t\t\t\t{ error, record },\n\t\t\t\t\t\t\t\t\t'Failed to parse SNS record',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t(req.event as any).events = events;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate isSQSEvent(event: SQSEvent | SNSEvent): event is SQSEvent {\n\t\tconst firstRecord = event.Records[0];\n\t\treturn (\n\t\t\t'Records' in event &&\n\t\t\tevent.Records.length > 0 &&\n\t\t\tfirstRecord !== undefined &&\n\t\t\t'eventSource' in firstRecord &&\n\t\t\tfirstRecord.eventSource === 'aws:sqs'\n\t\t);\n\t}\n\n\tprivate isSNSEvent(event: SQSEvent | SNSEvent): event is SNSEvent {\n\t\tconst firstRecord = event.Records[0];\n\t\treturn (\n\t\t\t'Records' in event &&\n\t\t\tevent.Records.length > 0 &&\n\t\t\tfirstRecord !== undefined &&\n\t\t\t'EventSource' in firstRecord &&\n\t\t\tfirstRecord.EventSource === 'aws:sns'\n\t\t);\n\t}\n\n\tprivate parseSNSRecord(record: SNSEventRecord): any {\n\t\tconst message = this.safeJsonParse(record.Sns.Message);\n\t\tconst messageType = record.Sns.MessageAttributes?.type?.Value;\n\n\t\t// Not JSON — wrap raw string with type from MessageAttributes if available\n\t\tif (message === null) {\n\t\t\treturn messageType\n\t\t\t\t? { type: messageType, payload: record.Sns.Message }\n\t\t\t\t: record.Sns.Message;\n\t\t}\n\n\t\t// Resolve type from MessageAttributes (preferred) or message body\n\t\tconst resolvedType = messageType ?? message.type;\n\n\t\tif (message.type) {\n\t\t\treturn message; // Full event format: { type, payload }\n\t\t}\n\n\t\t// Payload-only format: type is in MessageAttributes\n\t\treturn resolvedType ? { type: resolvedType, payload: message } : message;\n\t}\n\n\tprivate parseSQSRecord(record: SQSRecord): any {\n\t\tconst body = this.safeJsonParse(record.body);\n\n\t\t// Not JSON — return raw body as-is\n\t\tif (body === null) {\n\t\t\treturn record.body;\n\t\t}\n\n\t\t// Check if this is an SNS message wrapped in SQS\n\t\tif (body.Type === 'Notification' && body.Message) {\n\t\t\tconst snsMessage = this.safeJsonParse(body.Message);\n\t\t\tconst messageType = body.MessageAttributes?.type?.Value;\n\n\t\t\t// SNS Message not JSON — wrap with type from MessageAttributes if available\n\t\t\tif (snsMessage === null) {\n\t\t\t\treturn messageType\n\t\t\t\t\t? { type: messageType, payload: body.Message }\n\t\t\t\t\t: body.Message;\n\t\t\t}\n\n\t\t\tif (snsMessage.type) {\n\t\t\t\treturn snsMessage; // Full event format: { type, payload }\n\t\t\t}\n\n\t\t\t// Payload-only format: type is in MessageAttributes\n\t\t\tconst resolvedType = messageType ?? snsMessage.type;\n\t\t\treturn resolvedType\n\t\t\t\t? { type: resolvedType, payload: snsMessage }\n\t\t\t\t: snsMessage;\n\t\t}\n\n\t\t// Direct SQS message\n\t\treturn body;\n\t}\n\n\tprivate safeJsonParse(value: string): any | null {\n\t\ttry {\n\t\t\treturn JSON.parse(value);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate shouldIncludeEvent(event: any): boolean {\n\t\t// No event type (raw string/non-object) — always include\n\t\tif (typeof event !== 'object' || !event?.type) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// No filter configured — accept all\n\t\tif (!this.subscriber.subscribedEvents) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn this.subscriber.subscribedEvents.includes(event.type as any);\n\t}\n\n\tprivate async _handler(event: SubscriberEvent<TServices, TLogger>) {\n\t\t// If no events after filtering, return early\n\t\tif (event.events.length === 0) {\n\t\t\tthis.logger.info('No subscribed events to process');\n\t\t\treturn {\n\t\t\t\tbatchItemFailures: [],\n\t\t\t};\n\t\t}\n\n\t\t// Execute the subscriber with the parsed context\n\t\tconst result = await this.subscriber.handler({\n\t\t\tevents: event.events,\n\t\t\tservices: event.services,\n\t\t\tlogger: event.logger,\n\t\t});\n\n\t\t// Parse output if schema is provided\n\t\tif (this.subscriber.outputSchema && result) {\n\t\t\tconst validationResult =\n\t\t\t\tawait this.subscriber.outputSchema['~standard'].validate(result);\n\n\t\t\tif (validationResult.issues) {\n\t\t\t\tthis.logger.error(\n\t\t\t\t\t{ issues: validationResult.issues },\n\t\t\t\t\t'Subscriber output validation failed',\n\t\t\t\t);\n\t\t\t\tthrow new Error('Subscriber output validation failed');\n\t\t\t}\n\n\t\t\treturn validationResult.value;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tget handler(): AWSLambdaHandler {\n\t\tconst handler = this._handler.bind(this);\n\n\t\t// Apply middleware in order\n\t\tconst chain = middy(handler)\n\t\t\t.use(this.loggerMiddleware())\n\t\t\t.use(this.parseEvents())\n\t\t\t.use(this.error())\n\t\t\t.use(this.services());\n\n\t\t// Wrap entire Middy chain in request context for service access\n\t\tconst wrappedHandler = async (event: unknown, context: Context) => {\n\t\t\tconst startTime = Date.now();\n\t\t\tconst requestId = context.awsRequestId;\n\t\t\tconst logger = this.subscriber.logger.child({\n\t\t\t\trequestId,\n\t\t\t}) as TLogger;\n\n\t\t\treturn runWithRequestContext({ logger, requestId, startTime }, () =>\n\t\t\t\tchain(event as Parameters<typeof chain>[0], context),\n\t\t\t);\n\t\t};\n\n\t\treturn wrappedHandler as unknown as AWSLambdaHandler;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAoFA,IAAsB,2BAAtB,MAoBE;CACD,AAAU;CAEV,YACWA,WACSC,UAcnBC,UAA2C,CAAE,GAC5C;EAhBS;EACS;AAgBnB,OAAK,UAAU;CACf;CAED,AAAQ,QAAwD;AAC/D,SAAO,EACN,SAAS,CAAC,QAAQ;AACjB,IAAC,IAAI,MAAM,UAAU,KAAK,SAAS,QAAQ,MAC1C,IAAI,SAAS,CAAE,GACf,2BACA;GACD,MAAM,eAAe,UAAU,IAAI,MAAM;AAEzC,GAAC,IAAI,MAAc,UAAU,IAAI;AAGjC,OAAI,WAAW;IACd,YAAY,aAAa;IACzB,MAAM,aAAa;GACnB;EACD,EACD;CACD;;;;;;;;;CAWD,OAAO,WACNC,MACAC,iBACAC,aACM;AACN,OAAK,KAAM;EAEX,MAAM,MAAM,kBACT,OAAO,KAAK,MAAM,SAAS,CAAC,SAAS,QAAQ,GAC7C;EAEH,MAAM,UACJ,eAAe,YAAY,aAAa,CAAC,SAAS,mBAAmB;AACvE,MAAI,OACH,QAAO,KAAK,MAAM,IAAI;AAGvB,SAAO;CACP;CAED,AAAU,WAAWC,GA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C;AAEF,UAAO,sBAAsB;IAAE;IAAQ;IAAW;GAAW,GAAE,MAC9D,MAAM,OAAsC,QAAQ,CACpD;EACD;AAED,SAAO;CACP;AACD"}
|
package/dist/adaptors/hono.cjs
CHANGED
|
@@ -2,8 +2,8 @@ require('../Construct-D09WUUOf.cjs');
|
|
|
2
2
|
require('../functions-B3OFv3QV.cjs');
|
|
3
3
|
require('../clone-I_WIpiFf.cjs');
|
|
4
4
|
require('../publisher-BZgcrVPy.cjs');
|
|
5
|
-
require('../lazyAccessors-
|
|
5
|
+
require('../lazyAccessors-C1n1QfEj.cjs');
|
|
6
6
|
require('../processAudits-94Ar_EJF.cjs');
|
|
7
|
-
const require_HonoEndpointAdaptor = require('../HonoEndpointAdaptor-
|
|
7
|
+
const require_HonoEndpointAdaptor = require('../HonoEndpointAdaptor-DCD0rhFg.cjs');
|
|
8
8
|
|
|
9
9
|
exports.HonoEndpoint = require_HonoEndpointAdaptor.HonoEndpoint;
|
package/dist/adaptors/hono.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../Construct-D_3yZ9m5.cjs";
|
|
2
|
-
import "../index-
|
|
2
|
+
import "../index-CeoLMr7c.cjs";
|
|
3
3
|
import { HttpMethod } from "../types-BdAaYDvd.cjs";
|
|
4
|
-
import { Endpoint, EndpointSchemas } from "../Endpoint-
|
|
4
|
+
import { Endpoint, EndpointSchemas } from "../Endpoint-CxBdXNZm.cjs";
|
|
5
5
|
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
6
6
|
import { EventPublisher } from "@geekmidas/events";
|
|
7
7
|
import { Logger } from "@geekmidas/logger";
|
package/dist/adaptors/hono.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import "../Construct-D0uZvbr3.mjs";
|
|
|
2
2
|
import "../functions-DhkDodl0.mjs";
|
|
3
3
|
import "../clone-pdXxc0t3.mjs";
|
|
4
4
|
import "../publisher-CnpeMv-r.mjs";
|
|
5
|
-
import "../lazyAccessors-
|
|
5
|
+
import "../lazyAccessors-fFIQrblM.mjs";
|
|
6
6
|
import "../processAudits-CwyaaSQc.mjs";
|
|
7
|
-
import { HonoEndpoint } from "../HonoEndpointAdaptor-
|
|
7
|
+
import { HonoEndpoint } from "../HonoEndpointAdaptor-CJfFQ5KR.mjs";
|
|
8
8
|
|
|
9
9
|
export { HonoEndpoint };
|
|
@@ -2,9 +2,9 @@ const require_Construct = require('../Construct-D09WUUOf.cjs');
|
|
|
2
2
|
const require_functions = require('../functions-B3OFv3QV.cjs');
|
|
3
3
|
require('../clone-I_WIpiFf.cjs');
|
|
4
4
|
const require_publisher = require('../publisher-BZgcrVPy.cjs');
|
|
5
|
-
const require_lazyAccessors = require('../lazyAccessors-
|
|
5
|
+
const require_lazyAccessors = require('../lazyAccessors-C1n1QfEj.cjs');
|
|
6
6
|
const require_processAudits = require('../processAudits-94Ar_EJF.cjs');
|
|
7
|
-
const require_HonoEndpointAdaptor = require('../HonoEndpointAdaptor-
|
|
7
|
+
const require_HonoEndpointAdaptor = require('../HonoEndpointAdaptor-DCD0rhFg.cjs');
|
|
8
8
|
const __geekmidas_errors = require_Construct.__toESM(require("@geekmidas/errors"));
|
|
9
9
|
const __geekmidas_services = require_Construct.__toESM(require("@geekmidas/services"));
|
|
10
10
|
const __geekmidas_audit = require_Construct.__toESM(require("@geekmidas/audit"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../Construct-D_3yZ9m5.cjs";
|
|
2
|
-
import { Function } from "../index-
|
|
2
|
+
import { Function } from "../index-CeoLMr7c.cjs";
|
|
3
3
|
import { HttpMethod } from "../types-BdAaYDvd.cjs";
|
|
4
|
-
import { Endpoint, EndpointSchemas } from "../Endpoint-
|
|
4
|
+
import { Endpoint, EndpointSchemas } from "../Endpoint-CxBdXNZm.cjs";
|
|
5
5
|
import { Queue } from "../Queue-Brw--scg.cjs";
|
|
6
6
|
import { Subscriber } from "../Subscriber-DvKSp0N4.cjs";
|
|
7
7
|
import { EventPublisher, ExtractPublisherMessage } from "@geekmidas/events";
|
|
@@ -2,9 +2,9 @@ import "../Construct-D0uZvbr3.mjs";
|
|
|
2
2
|
import { FunctionBuilder, startMonitors } from "../functions-DhkDodl0.mjs";
|
|
3
3
|
import "../clone-pdXxc0t3.mjs";
|
|
4
4
|
import { publishConstructEvents, publishEvents } from "../publisher-CnpeMv-r.mjs";
|
|
5
|
-
import { Endpoint, ResponseBuilder, createCookieHeaderAccessor, createObjectHeaders } from "../lazyAccessors-
|
|
5
|
+
import { Endpoint, ResponseBuilder, createCookieHeaderAccessor, createObjectHeaders } from "../lazyAccessors-fFIQrblM.mjs";
|
|
6
6
|
import { executeWithAuditTransaction } from "../processAudits-CwyaaSQc.mjs";
|
|
7
|
-
import { HonoEndpoint } from "../HonoEndpointAdaptor-
|
|
7
|
+
import { HonoEndpoint } from "../HonoEndpointAdaptor-CJfFQ5KR.mjs";
|
|
8
8
|
import { ForbiddenError, wrapError } from "@geekmidas/errors";
|
|
9
9
|
import { ServiceDiscovery, runWithRequestContext } from "@geekmidas/services";
|
|
10
10
|
import { DefaultAuditor } from "@geekmidas/audit";
|
package/dist/crons/index.cjs
CHANGED
|
@@ -29,6 +29,10 @@ var CronBuilder = class extends require_functions.FunctionBuilder {
|
|
|
29
29
|
memorySize(memorySize) {
|
|
30
30
|
return require_clone.cloneWith(this, { _memorySize: memorySize });
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* When the cron runs: a five-field Unix `cron(…)` or a six-field AWS one.
|
|
34
|
+
* `gkm build` writes it to the manifest in the AWS form.
|
|
35
|
+
*/
|
|
32
36
|
schedule(_expression) {
|
|
33
37
|
return require_clone.cloneWith(this, { _schedule: _expression });
|
|
34
38
|
}
|
package/dist/crons/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["Function","obj: any","ConstructType","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>","timeout?: number","_schedule?: ScheduleExpression","input?: TInput","outputSchema?: OutSchema","services: TServices","logger?: TLogger","publisherService?: Service<TEventPublisherServiceName, TEventPublisher>","events: any[]","memorySize?: number","databaseService?: Service<TDatabaseServiceName, TDatabase>","FunctionBuilder","ConstructType","memorySize: number","_expression: ScheduleExpression","schema: T","services: T","logger: T","publisher: Service<TName, T>","service: Service<TName, T>","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>"],"sources":["../../src/crons/Cron.ts","../../src/crons/CronBuilder.ts","../../src/crons/index.ts"],"sourcesContent":["import type { AuditableAction } from '@geekmidas/audit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\nimport { ConstructType } from '../Construct';\nimport { Function, type FunctionHandler } from '../functions';\n\nexport class Cron<\n\tTInput extends ComposableStandardSchema | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends Function<\n\tTInput,\n\tTServices,\n\tTLogger,\n\tOutSchema,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName,\n\tAuditableAction<string, unknown>,\n\tFunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>\n> {\n\tstatic isCron(obj: any): obj is Cron<any, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as Function).__IS_FUNCTION__ === true &&\n\t\t\t\tobj.type === ConstructType.Cron,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t\ttimeout?: number,\n\t\tprotected _schedule?: ScheduleExpression,\n\t\tinput?: TInput,\n\t\toutputSchema?: OutSchema,\n\t\tservices: TServices = [] as unknown as TServices,\n\t\tlogger?: TLogger,\n\t\tpublisherService?: Service<TEventPublisherServiceName, TEventPublisher>,\n\t\tevents: any[] = [],\n\t\tmemorySize?: number,\n\t\tdatabaseService?: Service<TDatabaseServiceName, TDatabase>,\n\t) {\n\t\tsuper(\n\t\t\tfn,\n\t\t\ttimeout,\n\t\t\tConstructType.Cron,\n\t\t\tinput,\n\t\t\toutputSchema,\n\t\t\tservices,\n\t\t\tlogger,\n\t\t\tpublisherService,\n\t\t\tevents,\n\t\t\tmemorySize,\n\t\t\tundefined, // auditorStorageService\n\t\t\tdatabaseService,\n\t\t);\n\t}\n\n\tget schedule(): ScheduleExpression | undefined {\n\t\treturn this._schedule;\n\t}\n}\n\nexport type RateExpression = `rate(${string})`;\n\ntype CronMinute =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronHour =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronDay =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| `${number},${number}`\n\t| string; // Allow more complex patterns\n\ntype CronMonth =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| 'JAN'\n\t| 'FEB'\n\t| 'MAR'\n\t| 'APR'\n\t| 'MAY'\n\t| 'JUN'\n\t| 'JUL'\n\t| 'AUG'\n\t| 'SEP'\n\t| 'OCT'\n\t| 'NOV'\n\t| 'DEC'\n\t| string; // Allow more complex patterns\n\ntype CronWeekday =\n\t| '*'\n\t| number\n\t| `${number}`\n\t| `${number}-${number}`\n\t| `${number}/${number}`\n\t| `*/${number}`\n\t| 'SUN'\n\t| 'MON'\n\t| 'TUE'\n\t| 'WED'\n\t| 'THU'\n\t| 'FRI'\n\t| 'SAT'\n\t| `${string}-${string}` // Allow patterns like MON-FRI\n\t| string; // Allow more complex patterns\n\nexport type CronExpression =\n\t`cron(${CronMinute} ${CronHour} ${CronDay} ${CronMonth} ${CronWeekday})`;\n\nexport type ScheduleExpression = RateExpression | CronExpression;\n","import type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport uniqBy from 'lodash.uniqby';\nimport { ConstructType } from '../Construct';\nimport { cloneWith } from '../clone';\nimport { FunctionBuilder, type FunctionHandler } from '../functions';\nimport { Cron, type ScheduleExpression } from './Cron';\n\nexport class CronBuilder<\n\tTInput extends ComposableStandardSchema,\n\tTServices extends Service[],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends FunctionBuilder<\n\tTInput,\n\tOutSchema,\n\tTServices,\n\tTLogger,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName\n> {\n\tprivate _schedule?: ScheduleExpression;\n\n\tconstructor() {\n\t\tsuper(ConstructType.Cron);\n\t}\n\n\toverride memorySize(memorySize: number): this {\n\t\treturn cloneWith(this, { _memorySize: memorySize });\n\t}\n\n\tschedule(\n\t\t_expression: ScheduleExpression,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, { _schedule: _expression });\n\t}\n\n\toverride input<T extends ComposableStandardSchema>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\tinputSchema: schema as unknown as TInput,\n\t\t}) as unknown as CronBuilder<\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride output<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tT,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\toutputSchema: schema as unknown as OutSchema,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride services<T extends Service[]>(\n\t\tservices: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: uniqBy(\n\t\t\t\t[...this._services, ...services],\n\t\t\t\t(s) => s.serviceName,\n\t\t\t) as TServices,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride logger<T extends Logger>(\n\t\tlogger: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tT,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride publisher<T extends EventPublisher<any>, TName extends string>(\n\t\tpublisher: Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tT,\n\t\tTName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_publisher: publisher as unknown as Service<\n\t\t\t\tTEventPublisherServiceName,\n\t\t\t\tTEventPublisher\n\t\t\t>,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tT,\n\t\t\tTName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * Set the database service for this cron job.\n\t * The database will be available in the handler context as `db`.\n\t */\n\toverride database<T, TName extends string>(\n\t\tservice: Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tT,\n\t\tTName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_databaseService: service as unknown as Service<\n\t\t\t\tTDatabaseServiceName,\n\t\t\t\tTDatabase\n\t\t\t>,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tT,\n\t\t\tTName\n\t\t>;\n\t}\n\n\toverride handle(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t): Cron<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tconst cron = new Cron(\n\t\t\tfn,\n\t\t\tthis._timeout,\n\t\t\tthis._schedule,\n\t\t\tthis.inputSchema,\n\t\t\tthis.outputSchema,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._publisher,\n\t\t\tthis._events,\n\t\t\tthis._memorySize,\n\t\t\tthis._databaseService,\n\t\t);\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base keeps its configuration for every construct built\n\t\t// from it. The reset that used to be here wiped the base on first use.\n\n\t\tcron.monitors = this._monitors;\n\n\t\treturn cron;\n\t}\n}\n","export { AWSScheduledFunction } from './AWSScheduledFunction';\nexport {\n\tCron,\n\ttype CronExpression,\n\ttype RateExpression,\n\ttype ScheduleExpression,\n} from './Cron';\nexport { CronBuilder } from './CronBuilder';\n\nimport { CronBuilder } from './CronBuilder';\n\nexport const c = new CronBuilder();\n"],"mappings":";;;;;;;AAUA,IAAa,OAAb,cASUA,2BAaR;CACD,OAAO,OAAOC,KAA2C;AACxD,SAAO,QACN,OACE,IAAiB,oBAAoB,QACtC,IAAI,SAASC,gCAAc,KAC5B;CACD;CAED,YACCC,IACAC,SACUC,WAC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AAI"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Function","obj: any","ConstructType","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>","timeout?: number","_schedule?: ScheduleExpression","input?: TInput","outputSchema?: OutSchema","services: TServices","logger?: TLogger","publisherService?: Service<TEventPublisherServiceName, TEventPublisher>","events: any[]","memorySize?: number","databaseService?: Service<TDatabaseServiceName, TDatabase>","FunctionBuilder","ConstructType","memorySize: number","_expression: CronExpression<T>","schema: T","services: T","logger: T","publisher: Service<TName, T>","service: Service<TName, T>","fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>"],"sources":["../../src/crons/Cron.ts","../../src/crons/CronBuilder.ts","../../src/crons/index.ts"],"sourcesContent":["import type { AuditableAction } from '@geekmidas/audit';\nimport type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\nimport { ConstructType } from '../Construct';\nimport { Function, type FunctionHandler } from '../functions';\n\nexport class Cron<\n\tTInput extends ComposableStandardSchema | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends Function<\n\tTInput,\n\tTServices,\n\tTLogger,\n\tOutSchema,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName,\n\tAuditableAction<string, unknown>,\n\tFunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>\n> {\n\tstatic isCron(obj: any): obj is Cron<any, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as Function).__IS_FUNCTION__ === true &&\n\t\t\t\tobj.type === ConstructType.Cron,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t\ttimeout?: number,\n\t\tprotected _schedule?: ScheduleExpression,\n\t\tinput?: TInput,\n\t\toutputSchema?: OutSchema,\n\t\tservices: TServices = [] as unknown as TServices,\n\t\tlogger?: TLogger,\n\t\tpublisherService?: Service<TEventPublisherServiceName, TEventPublisher>,\n\t\tevents: any[] = [],\n\t\tmemorySize?: number,\n\t\tdatabaseService?: Service<TDatabaseServiceName, TDatabase>,\n\t) {\n\t\tsuper(\n\t\t\tfn,\n\t\t\ttimeout,\n\t\t\tConstructType.Cron,\n\t\t\tinput,\n\t\t\toutputSchema,\n\t\t\tservices,\n\t\t\tlogger,\n\t\t\tpublisherService,\n\t\t\tevents,\n\t\t\tmemorySize,\n\t\t\tundefined, // auditorStorageService\n\t\t\tdatabaseService,\n\t\t);\n\t}\n\n\tget schedule(): ScheduleExpression | undefined {\n\t\treturn this._schedule;\n\t}\n}\n\n// ---- Cron expression types ------------------------------------------------\n//\n// `.schedule()` takes a `cron(…)` in either of two dialects, told apart by the\n// field count, and checks each by its own rules:\n//\n// - Unix, five fields: `min hour day-of-month month day-of-week`, with\n// day-of-week 0–7 (SUN = 0 or 7) and no `?`.\n// - AWS, six fields: `min hour day-of-month month day-of-week year`, with\n// day-of-week 1–7 (SUN = 1), `?` in exactly one day field, and `L`, `W`\n// and `#` where EventBridge allows them.\n//\n// The types are generic because a plain union of every field's forms is too\n// large for TypeScript, so the literal is checked field by field instead.\n// `@geekmidas/manifest`'s `parseCron` applies the same rules at build time.\n\ntype Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';\n\n/** `'0'`…`'99'`, with an optional leading zero (`'08'`). */\ntype UpTo99 = Digit | `${Digit}${Digit}`;\n\ntype ToNumber<S extends string> = S extends `0${infer R extends `${number}`}`\n\t? R extends ''\n\t\t? 0\n\t\t: ToNumber<R>\n\t: S extends `${infer N extends number}`\n\t\t? N\n\t\t: never;\n\ntype Range<\n\tN extends number,\n\tAcc extends number[] = [],\n> = Acc['length'] extends N ? Acc[number] : Range<N, [...Acc, Acc['length']]>;\n\n/** Numbers from `Min` to `Max` inclusive. */\ntype Between<Min extends number, Max extends number> =\n\t| Exclude<Range<Max>, Range<Min>>\n\t| Max;\n\n/** A single value: a number in range, or one of the field's names. */\ntype IsValue<\n\tS extends string,\n\tMin extends number,\n\tMax extends number,\n\tNames extends string,\n> = S extends Names\n\t? true\n\t: S extends UpTo99\n\t\t? ToNumber<S> extends Between<Min, Max>\n\t\t\t? true\n\t\t\t: false\n\t\t: false;\n\n/** `v`, `a-b` or `*`, with an optional `/step`. */\ntype IsAtom<\n\tS extends string,\n\tMin extends number,\n\tMax extends number,\n\tNames extends string,\n> = S extends `${infer Base}/${infer Step}`\n\t? Step extends UpTo99\n\t\t? Base extends '*'\n\t\t\t? true\n\t\t\t: IsAtom<Base, Min, Max, Names>\n\t\t: false\n\t: S extends '*'\n\t\t? true\n\t\t: S extends `${infer A}-${infer B}`\n\t\t\t? [IsValue<A, Min, Max, Names>, IsValue<B, Min, Max, Names>] extends [\n\t\t\t\t\ttrue,\n\t\t\t\t\ttrue,\n\t\t\t\t]\n\t\t\t\t? true\n\t\t\t\t: false\n\t\t\t: IsValue<S, Min, Max, Names>;\n\n/** A comma-separated list of atoms. */\ntype IsField<\n\tS extends string,\n\tMin extends number,\n\tMax extends number,\n\tNames extends string = never,\n> = S extends `${infer Head},${infer Rest}`\n\t? IsAtom<Head, Min, Max, Names> extends true\n\t\t? IsField<Rest, Min, Max, Names>\n\t\t: false\n\t: IsAtom<S, Min, Max, Names>;\n\ntype MonthName =\n\t| 'JAN'\n\t| 'FEB'\n\t| 'MAR'\n\t| 'APR'\n\t| 'MAY'\n\t| 'JUN'\n\t| 'JUL'\n\t| 'AUG'\n\t| 'SEP'\n\t| 'OCT'\n\t| 'NOV'\n\t| 'DEC';\ntype DayName = 'SUN' | 'MON' | 'TUE' | 'WED' | 'THU' | 'FRI' | 'SAT';\n\ntype AllTrue<T extends boolean[]> = T extends true[] ? true : false;\n\ntype IsUnix<S extends string> =\n\tS extends `${infer Mi} ${infer H} ${infer Dom} ${infer Mo} ${infer Dow}`\n\t\t? AllTrue<\n\t\t\t\t[\n\t\t\t\t\tIsField<Mi, 0, 59>,\n\t\t\t\t\tIsField<H, 0, 23>,\n\t\t\t\t\tIsField<Dom, 1, 31>,\n\t\t\t\t\tIsField<Mo, 1, 12, MonthName>,\n\t\t\t\t\tIsField<Dow, 0, 7, DayName>,\n\t\t\t\t]\n\t\t\t>\n\t\t: false;\n\ntype IsAwsDayOfMonth<S extends string> = S extends 'L' | `L-${UpTo99}` | 'LW'\n\t? true\n\t: S extends `${infer D}W`\n\t\t? IsValue<D, 1, 31, never>\n\t\t: IsField<S, 1, 31>;\n\ntype IsAwsDayOfWeek<S extends string> = S extends `${infer D}L`\n\t? IsValue<D, 1, 7, DayName>\n\t: S extends `${infer D}#${infer N}`\n\t\t? AllTrue<[IsValue<D, 1, 7, DayName>, IsValue<N, 1, 5, never>]>\n\t\t: IsField<S, 1, 7, DayName>;\n\n/** 1970–2199, EventBridge's range. */\ntype Year = `19${'7' | '8' | '9'}${Digit}` | `${'20' | '21'}${Digit}${Digit}`;\n\ntype IsYearAtom<S extends string> = S extends\n\t| '*'\n\t| Year\n\t| `${'*' | Year}/${UpTo99}`\n\t| `${Year}-${Year}`\n\t? true\n\t: false;\n\ntype IsAwsYear<S extends string> = S extends `${infer Head},${infer Rest}`\n\t? IsYearAtom<Head> extends true\n\t\t? IsAwsYear<Rest>\n\t\t: false\n\t: IsYearAtom<S>;\n\ntype IsAws<S extends string> =\n\tS extends `${infer Mi} ${infer H} ${infer Dom} ${infer Mo} ${infer Dow} ${infer Y}`\n\t\t? AllTrue<\n\t\t\t\t[\n\t\t\t\t\tIsField<Mi, 0, 59>,\n\t\t\t\t\tIsField<H, 0, 23>,\n\t\t\t\t\tIsField<Mo, 1, 12, MonthName>,\n\t\t\t\t\tIsAwsYear<Y>,\n\t\t\t\t\tDom extends '?'\n\t\t\t\t\t\t? Dow extends '?'\n\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t: IsAwsDayOfWeek<Dow>\n\t\t\t\t\t\t: Dow extends '?'\n\t\t\t\t\t\t\t? IsAwsDayOfMonth<Dom>\n\t\t\t\t\t\t\t: false,\n\t\t\t\t]\n\t\t\t>\n\t\t: false;\n\n/** `T` when it is a valid five-field Unix `cron(…)`. */\nexport type UnixCronExpression<T extends string> = T extends `cron(${infer S})`\n\t? IsUnix<S> extends true\n\t\t? T\n\t\t: never\n\t: never;\n\n/** `T` when it is a valid six-field AWS (EventBridge) `cron(…)`. */\nexport type AwsCronExpression<T extends string> = T extends `cron(${infer S})`\n\t? IsAws<S> extends true\n\t\t? T\n\t\t: never\n\t: never;\n\n/**\n * `T` when it is a valid cron expression in either dialect, otherwise a\n * message saying what's expected. A schedule built at runtime can be cast to\n * {@link ScheduleExpression}, which `gkm build` then checks.\n */\nexport type CronExpression<T extends string> = [T] extends [ScheduleExpression]\n\t? [ScheduleExpression] extends [T]\n\t\t? T\n\t\t: CheckedCronExpression<T>\n\t: CheckedCronExpression<T>;\n\ntype CheckedCronExpression<T extends string> = [\n\tUnixCronExpression<T> | AwsCronExpression<T>,\n] extends [never]\n\t? 'Expected cron(…) with 5 fields (Unix) or 6 fields (AWS)'\n\t: T;\n\n/**\n * A cron's schedule once set. Literals are checked by {@link CronExpression};\n * every schedule is checked again by `gkm build`.\n */\nexport type ScheduleExpression = `cron(${string})`;\n","import type { EventPublisher } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { ComposableStandardSchema } from '@geekmidas/schema';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport uniqBy from 'lodash.uniqby';\nimport { ConstructType } from '../Construct';\nimport { cloneWith } from '../clone';\nimport { FunctionBuilder, type FunctionHandler } from '../functions';\nimport { Cron, type CronExpression, type ScheduleExpression } from './Cron';\n\nexport class CronBuilder<\n\tTInput extends ComposableStandardSchema,\n\tTServices extends Service[],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends FunctionBuilder<\n\tTInput,\n\tOutSchema,\n\tTServices,\n\tTLogger,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tundefined,\n\tstring,\n\tTDatabase,\n\tTDatabaseServiceName\n> {\n\tprivate _schedule?: ScheduleExpression;\n\n\tconstructor() {\n\t\tsuper(ConstructType.Cron);\n\t}\n\n\toverride memorySize(memorySize: number): this {\n\t\treturn cloneWith(this, { _memorySize: memorySize });\n\t}\n\n\t/**\n\t * When the cron runs: a five-field Unix `cron(…)` or a six-field AWS one.\n\t * `gkm build` writes it to the manifest in the AWS form.\n\t */\n\tschedule<const T extends string>(\n\t\t_expression: CronExpression<T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_schedule: _expression as ScheduleExpression,\n\t\t});\n\t}\n\n\toverride input<T extends ComposableStandardSchema>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\tinputSchema: schema as unknown as TInput,\n\t\t}) as unknown as CronBuilder<\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride output<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tT,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\toutputSchema: schema as unknown as OutSchema,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride services<T extends Service[]>(\n\t\tservices: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: uniqBy(\n\t\t\t\t[...this._services, ...services],\n\t\t\t\t(s) => s.serviceName,\n\t\t\t) as TServices,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride logger<T extends Logger>(\n\t\tlogger: T,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tT,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\toverride publisher<T extends EventPublisher<any>, TName extends string>(\n\t\tpublisher: Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tT,\n\t\tTName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_publisher: publisher as unknown as Service<\n\t\t\t\tTEventPublisherServiceName,\n\t\t\t\tTEventPublisher\n\t\t\t>,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tT,\n\t\t\tTName,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * Set the database service for this cron job.\n\t * The database will be available in the handler context as `db`.\n\t */\n\toverride database<T, TName extends string>(\n\t\tservice: Service<TName, T>,\n\t): CronBuilder<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tT,\n\t\tTName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_databaseService: service as unknown as Service<\n\t\t\t\tTDatabaseServiceName,\n\t\t\t\tTDatabase\n\t\t\t>,\n\t\t}) as unknown as CronBuilder<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tT,\n\t\t\tTName\n\t\t>;\n\t}\n\n\toverride handle(\n\t\tfn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase>,\n\t): Cron<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tconst cron = new Cron(\n\t\t\tfn,\n\t\t\tthis._timeout,\n\t\t\tthis._schedule,\n\t\t\tthis.inputSchema,\n\t\t\tthis.outputSchema,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._publisher,\n\t\t\tthis._events,\n\t\t\tthis._memorySize,\n\t\t\tthis._databaseService,\n\t\t);\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base keeps its configuration for every construct built\n\t\t// from it. The reset that used to be here wiped the base on first use.\n\n\t\tcron.monitors = this._monitors;\n\n\t\treturn cron;\n\t}\n}\n","export { AWSScheduledFunction } from './AWSScheduledFunction';\nexport {\n\ttype AwsCronExpression,\n\tCron,\n\ttype CronExpression,\n\ttype ScheduleExpression,\n\ttype UnixCronExpression,\n} from './Cron';\nexport { CronBuilder } from './CronBuilder';\n\nimport { CronBuilder } from './CronBuilder';\n\nexport const c = new CronBuilder();\n"],"mappings":";;;;;;;AAUA,IAAa,OAAb,cASUA,2BAaR;CACD,OAAO,OAAOC,KAA2C;AACxD,SAAO,QACN,OACE,IAAiB,oBAAoB,QACtC,IAAI,SAASC,gCAAc,KAC5B;CACD;CAED,YACCC,IACAC,SACUC,WACVC,OACAC,cACAC,WAAsB,CAAE,GACxBC,QACAC,kBACAC,SAAgB,CAAE,GAClBC,YACAC,iBACC;AACD,QACC,IACA,SACAX,gCAAc,MACd,OACA,cACA,UACA,QACA,kBACA,QACA,oBAEA,gBACA;EAvBS;CAwBV;CAED,IAAI,WAA2C;AAC9C,SAAO,KAAK;CACZ;AACD;;;;;AC9DD,IAAa,cAAb,cASUY,kCAWR;CACD,AAAQ;CAER,cAAc;AACb,QAAMC,gCAAc,KAAK;CACzB;CAED,AAAS,WAAWC,YAA0B;AAC7C,SAAO,wBAAU,MAAM,EAAE,aAAa,WAAY,EAAC;CACnD;;;;;CAMD,SACCC,aAUC;AACD,SAAO,wBAAU,MAAM,EACtB,WAAW,YACX,EAAC;CACF;CAED,AAAS,MACRC,QAUC;AACD,SAAO,wBAAU,MAAM,EACtB,aAAa,OACb,EAAC;CAUF;CAED,AAAS,OACRA,QAUC;AACD,SAAO,wBAAU,MAAM,EACtB,cAAc,OACd,EAAC;CAUF;CAED,AAAS,SACRC,UAUC;AACD,SAAO,wBAAU,MAAM,EACtB,WAAW,2BACV,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,GAChC,CAAC,MAAM,EAAE,YACT,CACD,EAAC;CAUF;CAED,AAAS,OACRC,QAUC;AACD,SAAO,wBAAU,MAAM,EACtB,SAAS,OACT,EAAC;CAUF;CAED,AAAS,UACRC,WAUC;AACD,SAAO,wBAAU,MAAM,EACtB,YAAY,UAIZ,EAAC;CAUF;;;;;CAMD,AAAS,SACRC,SAUC;AACD,SAAO,wBAAU,MAAM,EACtB,kBAAkB,QAIlB,EAAC;CAUF;CAED,AAAS,OACRC,IAUC;EACD,MAAM,OAAO,IAAI,KAChB,IACA,KAAK,UACL,KAAK,WACL,KAAK,aACL,KAAK,cACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,SACL,KAAK,aACL,KAAK;AAON,OAAK,WAAW,KAAK;AAErB,SAAO;CACP;AACD;;;;AC9PD,MAAa,IAAI,IAAI"}
|
package/dist/crons/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../Construct-D_3yZ9m5.cjs";
|
|
2
|
-
import { FunctionBuilder, FunctionHandler } from "../index-
|
|
3
|
-
import { AWSScheduledFunction, Cron, CronExpression,
|
|
2
|
+
import { FunctionBuilder, FunctionHandler } from "../index-CeoLMr7c.cjs";
|
|
3
|
+
import { AWSScheduledFunction, AwsCronExpression, Cron, CronExpression, ScheduleExpression, UnixCronExpression } from "../AWSScheduledFunction-DAGP_vz5.cjs";
|
|
4
4
|
import { EventPublisher } from "@geekmidas/events";
|
|
5
5
|
import * as _geekmidas_logger2 from "@geekmidas/logger";
|
|
6
6
|
import { Logger } from "@geekmidas/logger";
|
|
@@ -15,7 +15,11 @@ declare class CronBuilder<TInput extends ComposableStandardSchema, TServices ext
|
|
|
15
15
|
private _schedule?;
|
|
16
16
|
constructor();
|
|
17
17
|
memorySize(memorySize: number): this;
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* When the cron runs: a five-field Unix `cron(…)` or a six-field AWS one.
|
|
20
|
+
* `gkm build` writes it to the manifest in the AWS form.
|
|
21
|
+
*/
|
|
22
|
+
schedule<const T extends string>(_expression: CronExpression<T>): CronBuilder<TInput, TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
|
|
19
23
|
input<T extends ComposableStandardSchema>(schema: T): CronBuilder<T, TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
|
|
20
24
|
output<T extends StandardSchemaV1>(schema: T): CronBuilder<TInput, TServices, TLogger, T, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
|
|
21
25
|
services<T extends Service[]>(services: T): CronBuilder<TInput, [...TServices, ...T], TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
|
|
@@ -35,5 +39,5 @@ declare const c: CronBuilder<_geekmidas_schema0.ComposableStandardSchema, _geekm
|
|
|
35
39
|
//# sourceMappingURL=index.d.ts.map
|
|
36
40
|
|
|
37
41
|
//#endregion
|
|
38
|
-
export { AWSScheduledFunction, Cron, CronBuilder, CronExpression,
|
|
42
|
+
export { AWSScheduledFunction, AwsCronExpression, Cron, CronBuilder, CronExpression, ScheduleExpression, UnixCronExpression, c };
|
|
39
43
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/crons/CronBuilder.ts","../../src/crons/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;cAWa,2BACG,4CACG,2BACF,SAAS,0BACP,kEACM,8KAIf,gBACT,QACA,WACA,WACA,SACA,iBACA,+CAGA,WACA
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/crons/CronBuilder.ts","../../src/crons/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;cAWa,2BACG,4CACG,2BACF,SAAS,0BACP,kEACM,8KAIf,gBACT,QACA,WACA,WACA,SACA,iBACA,+CAGA,WACA;;;;;;AAnBD;;EAAwB,QACR,CAAA,gBAAA,MAAA,CAAA,CAAA,WAAA,EAmCD,cAnCC,CAmCc,CAnCd,CAAA,CAAA,EAoCZ,WApCY,CAqCd,MArCc,EAsCd,SAtCc,EAuCd,OAvCc,EAwCd,SAxCc,EAyCd,eAzCc,EA0Cd,0BA1Cc,EA2Cd,SA3Cc,EA4Cd,oBA5Cc,CAAA;EAAwB,KACrB,CAAA,UAkDO,wBAlDP,CAAA,CAAA,MAAA,EAmDT,CAnDS,CAAA,EAoDf,WApDe,CAqDjB,CArDiB,EAsDjB,SAtDiB,EAuDjB,OAvDiB,EAwDjB,SAxDiB,EAyDjB,eAzDiB,EA0DjB,0BA1DiB,EA2DjB,SA3DiB,EA4DjB,oBA5DiB,CAAA;EAAO,MACT,CAAA,UA2EU,gBA3EV,CAAA,CAAA,MAAA,EA4EP,CA5EO,CAAA,EA6Eb,WA7Ea,CA8Ef,MA9Ee,EA+Ef,SA/Ee,EAgFf,OAhFe,EAiFf,CAjFe,EAkFf,eAlFe,EAmFf,0BAnFe,EAoFf,SApFe,EAqFf,oBArFe,CAAA;EAAM,QAAG,CAAA,UAqGG,OArGH,EAAA,CAAA,CAAA,QAAA,EAsGd,CAtGc,CAAA,EAuGtB,WAvGsB,CAwGxB,MAxGwB,EAAA,CACP,GAwGb,SAxGa,EACM,GAuGL,CAvGK,CAAc,EAwGrC,OAnGD,EAoGC,SApGD,EAqGC,eArGD,EAsGC,0BAtGD,EAu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
1
|
import "../Construct-DsqpiAym.mjs";
|
|
2
2
|
import { FunctionBuilder, FunctionHandler } from "../index-B8LNLQXD.mjs";
|
|
3
|
-
import { AWSScheduledFunction, Cron, CronExpression,
|
|
3
|
+
import { AWSScheduledFunction, AwsCronExpression, Cron, CronExpression, ScheduleExpression, UnixCronExpression } from "../AWSScheduledFunction-Dg6TPIxn.mjs";
|
|
4
4
|
import { Service as Service$1 } from "@geekmidas/services";
|
|
5
5
|
import { EventPublisher } from "@geekmidas/events";
|
|
6
6
|
import { Logger as Logger$1 } from "@geekmidas/logger";
|
|
@@ -12,7 +12,11 @@ declare class CronBuilder<TInput extends ComposableStandardSchema$1, TServices e
|
|
|
12
12
|
private _schedule?;
|
|
13
13
|
constructor();
|
|
14
14
|
memorySize(memorySize: number): this;
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* When the cron runs: a five-field Unix `cron(…)` or a six-field AWS one.
|
|
17
|
+
* `gkm build` writes it to the manifest in the AWS form.
|
|
18
|
+
*/
|
|
19
|
+
schedule<const T extends string>(_expression: CronExpression<T>): CronBuilder<TInput, TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
|
|
16
20
|
input<T extends ComposableStandardSchema$1>(schema: T): CronBuilder<T, TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
|
|
17
21
|
output<T extends StandardSchemaV1>(schema: T): CronBuilder<TInput, TServices, TLogger, T, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
|
|
18
22
|
services<T extends Service$1[]>(services: T): CronBuilder<TInput, [...TServices, ...T], TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TDatabase, TDatabaseServiceName>;
|
|
@@ -32,5 +36,5 @@ declare const c: CronBuilder<ComposableStandardSchema, Service[], Logger, undefi
|
|
|
32
36
|
//# sourceMappingURL=index.d.ts.map
|
|
33
37
|
|
|
34
38
|
//#endregion
|
|
35
|
-
export { AWSScheduledFunction, Cron, CronBuilder, CronExpression,
|
|
39
|
+
export { AWSScheduledFunction, AwsCronExpression, Cron, CronBuilder, CronExpression, ScheduleExpression, UnixCronExpression, c };
|
|
36
40
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/crons/CronBuilder.ts","../../src/crons/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAWa,2BACG,8CACG,6BACF,WAAS,4BACP,kEACM,8KAIf,gBACT,QACA,WACA,WACA,SACA,iBACA,+CAGA,WACA;;;EAnBY,UAAA,CAAA,UAAW,EAAA,MAAA,CAAA,EAAA,IAAA;EAAA,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/crons/CronBuilder.ts","../../src/crons/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAWa,2BACG,8CACG,6BACF,WAAS,4BACP,kEACM,8KAIf,gBACT,QACA,WACA,WACA,SACA,iBACA,+CAGA,WACA;;;EAnBY,UAAA,CAAA,UAAW,EAAA,MAAA,CAAA,EAAA,IAAA;EAAA;;;;EAGD,QAAG,CAAA,gBAAA,MAAA,CAAA,CAAA,WAAA,EAiCX,cAjCW,CAiCI,CAjCJ,CAAA,CAAA,EAkCtB,WAlCsB,CAmCxB,MAnCwB,EAoCxB,SApCwB,EAqCxB,OArCwB,EAsCxB,SAtCwB,EAuCxB,eAvCwB,EAwCxB,0BAxCwB,EAyCxB,SAzCwB,EA0CxB,oBA1CwB,CAAA;EAAM,KACb,CAAA,UAgDO,0BAhDP,CAAA,CAAA,MAAA,EAiDT,CAjDS,CAAA,EAkDf,WAlDe,CAmDjB,CAnDiB,EAoDjB,SApDiB,EAqDjB,OArDiB,EAsDjB,SAtDiB,EAuDjB,eAvDiB,EAwDjB,0BAxDiB,EAyDjB,SAzDiB,EA0DjB,oBA1DiB,CAAA;EAAgB,MACV,CAAA,UAyEE,gBAzEF,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,CAAA,EAAA,EAuLI,eAvLJ,CAuLoB,MAvLpB,EAuL4B,SAvL5B,EAuLuC,OAvLvC,EAuLgD,SAvLhD,EAuL2D,SAvL3D,CAAA,CAAA,EAwLE,IAxLF,CAyLA,MAzLA,EA0LA,SA1LA,EA2LA,OA3LA,EA4LA,SA5LA,EA6LA,eA7LA,EA8LA,0BA9LA,EA+LA,SA/LA,EAgMA,oBAhMA,CAAA;;;;;cCtCW,GAAC,YAAA,0BAAA,WAAA"}
|
package/dist/crons/index.mjs
CHANGED
|
@@ -29,6 +29,10 @@ var CronBuilder = class extends FunctionBuilder {
|
|
|
29
29
|
memorySize(memorySize) {
|
|
30
30
|
return cloneWith(this, { _memorySize: memorySize });
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* When the cron runs: a five-field Unix `cron(…)` or a six-field AWS one.
|
|
34
|
+
* `gkm build` writes it to the manifest in the AWS form.
|
|
35
|
+
*/
|
|
32
36
|
schedule(_expression) {
|
|
33
37
|
return cloneWith(this, { _schedule: _expression });
|
|
34
38
|
}
|