@geekmidas/constructs 9.1.0 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -0
- package/dist/{AWSScheduledFunction-C42adp8A.cjs → AWSScheduledFunction-CKhVurOa.cjs} +3 -3
- package/dist/{AWSScheduledFunction-C42adp8A.cjs.map → AWSScheduledFunction-CKhVurOa.cjs.map} +1 -1
- package/dist/{AWSScheduledFunction-KP6lqbsW.mjs → AWSScheduledFunction-CU7mMGFA.mjs} +2 -2
- package/dist/{AWSScheduledFunction-KP6lqbsW.mjs.map → AWSScheduledFunction-CU7mMGFA.mjs.map} +1 -1
- package/dist/{AWSScheduledFunction-BHHlWlfV.d.cts → AWSScheduledFunction-DPMzOjZP.d.cts} +2 -2
- package/dist/{AWSScheduledFunction-BHHlWlfV.d.cts.map → AWSScheduledFunction-DPMzOjZP.d.cts.map} +1 -1
- package/dist/{AWSScheduledFunction-BzGCUbkk.d.mts → AWSScheduledFunction-a6hRp3nk.d.mts} +2 -2
- package/dist/{AWSScheduledFunction-BzGCUbkk.d.mts.map → AWSScheduledFunction-a6hRp3nk.d.mts.map} +1 -1
- package/dist/{Construct-TGIM_E4o.cjs → Construct-D09WUUOf.cjs} +9 -1
- package/dist/Construct-D09WUUOf.cjs.map +1 -0
- package/dist/{Construct-BWF5HxaM.mjs → Construct-D0uZvbr3.mjs} +9 -1
- package/dist/Construct-D0uZvbr3.mjs.map +1 -0
- package/dist/{Construct-JlyQkBkv.d.cts → Construct-D_3yZ9m5.d.cts} +23 -3
- package/dist/Construct-D_3yZ9m5.d.cts.map +1 -0
- package/dist/{Construct-pxwC6fDD.d.mts → Construct-DsqpiAym.d.mts} +23 -3
- package/dist/Construct-DsqpiAym.d.mts.map +1 -0
- package/dist/{Endpoint-B0P_pEMr.d.mts → Endpoint-DEydLuBs.d.mts} +2 -2
- package/dist/{Endpoint-B0P_pEMr.d.mts.map → Endpoint-DEydLuBs.d.mts.map} +1 -1
- package/dist/{Endpoint-Cwjhc1Hl.d.cts → Endpoint-nhjtdDL3.d.cts} +2 -2
- package/dist/{Endpoint-Cwjhc1Hl.d.cts.map → Endpoint-nhjtdDL3.d.cts.map} +1 -1
- package/dist/{HonoEndpointAdaptor-BMVwx2cz.mjs → HonoEndpointAdaptor-CJfFQ5KR.mjs} +3 -3
- package/dist/{HonoEndpointAdaptor-BMVwx2cz.mjs.map → HonoEndpointAdaptor-CJfFQ5KR.mjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-DPDsDi-D.cjs → HonoEndpointAdaptor-DCD0rhFg.cjs} +5 -5
- package/dist/{HonoEndpointAdaptor-DPDsDi-D.cjs.map → HonoEndpointAdaptor-DCD0rhFg.cjs.map} +1 -1
- package/dist/{Queue-BL68oDJ-.d.mts → Queue-Brw--scg.d.cts} +3 -3
- package/dist/{Queue-BL68oDJ-.d.mts.map → Queue-Brw--scg.d.cts.map} +1 -1
- package/dist/{Queue-DxJ6btRE.d.cts → Queue-D5z1bwFu.d.mts} +3 -3
- package/dist/{Queue-DxJ6btRE.d.cts.map → Queue-D5z1bwFu.d.mts.map} +1 -1
- package/dist/{Subscriber-DF6xsBAJ.d.mts → Subscriber-CJ22tp8r.d.mts} +2 -2
- package/dist/{Subscriber-DF6xsBAJ.d.mts.map → Subscriber-CJ22tp8r.d.mts.map} +1 -1
- package/dist/{Subscriber-BpVhcGhX.d.cts → Subscriber-DvKSp0N4.d.cts} +2 -2
- package/dist/{Subscriber-BpVhcGhX.d.cts.map → Subscriber-DvKSp0N4.d.cts.map} +1 -1
- package/dist/{Topic-DJXoDeMP.d.cts → Topic-B-fxOsR2.d.mts} +3 -3
- package/dist/{Topic-DJXoDeMP.d.cts.map → Topic-B-fxOsR2.d.mts.map} +1 -1
- package/dist/{Topic-DxWQBgMN.d.mts → Topic-BMfrIFdX.d.cts} +3 -3
- package/dist/{Topic-DxWQBgMN.d.mts.map → Topic-BMfrIFdX.d.cts.map} +1 -1
- package/dist/adaptors/aws.cjs +12 -11
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +6 -6
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +6 -6
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +11 -10
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +5 -5
- package/dist/adaptors/hono.d.cts +3 -3
- package/dist/adaptors/hono.d.mts +3 -3
- package/dist/adaptors/hono.mjs +4 -4
- package/dist/adaptors/testing.cjs +5 -5
- package/dist/adaptors/testing.d.cts +5 -5
- package/dist/adaptors/testing.d.mts +5 -5
- package/dist/adaptors/testing.mjs +4 -4
- package/dist/crons/index.cjs +3 -3
- package/dist/crons/index.d.cts +7 -7
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +3 -3
- package/dist/crons/index.mjs +3 -3
- package/dist/endpoints/index.cjs +3 -3
- package/dist/endpoints/index.d.cts +5 -5
- package/dist/endpoints/index.d.mts +3 -3
- package/dist/endpoints/index.mjs +3 -3
- package/dist/functions/index.cjs +2 -2
- package/dist/functions/index.d.cts +2 -2
- package/dist/functions/index.d.mts +2 -2
- package/dist/functions/index.mjs +2 -2
- package/dist/{functions-SqtCDc9c.cjs → functions-B3OFv3QV.cjs} +2 -2
- package/dist/functions-B3OFv3QV.cjs.map +1 -0
- package/dist/{functions-EqTloHjo.mjs → functions-DhkDodl0.mjs} +2 -2
- package/dist/functions-DhkDodl0.mjs.map +1 -0
- package/dist/{index-C7iynzLI.d.mts → index-B8LNLQXD.d.mts} +2 -2
- package/dist/{index-C7iynzLI.d.mts.map → index-B8LNLQXD.d.mts.map} +1 -1
- package/dist/{index-DdgJRm4q.d.cts → index-CXpim5mV.d.cts} +6 -6
- package/dist/{index-DdgJRm4q.d.cts.map → index-CXpim5mV.d.cts.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +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 +9 -2
- package/dist/monitors/index.cjs.map +1 -1
- package/dist/monitors/index.d.cts +19 -6
- package/dist/monitors/index.d.cts.map +1 -1
- package/dist/monitors/index.d.mts +15 -6
- package/dist/monitors/index.d.mts.map +1 -1
- package/dist/monitors/index.mjs +9 -2
- package/dist/monitors/index.mjs.map +1 -1
- package/dist/{processAudits-BJZT5gmy.cjs → processAudits-94Ar_EJF.cjs} +2 -2
- package/dist/{processAudits-BJZT5gmy.cjs.map → processAudits-94Ar_EJF.cjs.map} +1 -1
- package/dist/queue/index.cjs +1 -1
- package/dist/queue/index.d.cts +4 -4
- package/dist/queue/index.d.mts +2 -2
- package/dist/queue/index.mjs +1 -1
- package/dist/subscribers/index.cjs +1 -1
- package/dist/subscribers/index.d.cts +5 -5
- package/dist/subscribers/index.d.mts +3 -3
- package/dist/subscribers/index.mjs +1 -1
- package/dist/topic/index.cjs +1 -1
- package/dist/topic/index.d.cts +2 -2
- package/dist/topic/index.d.mts +2 -2
- package/dist/topic/index.mjs +1 -1
- package/package.json +23 -27
- package/src/Construct.ts +12 -1
- package/src/__tests__/monitor.spec.ts +67 -7
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +7 -15
- package/src/endpoints/Endpoint.ts +12 -15
- package/src/index.ts +1 -0
- package/src/monitor.ts +17 -1
- package/src/monitors/heartbeat.ts +16 -6
- package/tsdown.config.ts +1 -7
- package/dist/Construct-BWF5HxaM.mjs.map +0 -1
- package/dist/Construct-JlyQkBkv.d.cts.map +0 -1
- package/dist/Construct-TGIM_E4o.cjs.map +0 -1
- package/dist/Construct-pxwC6fDD.d.mts.map +0 -1
- package/dist/functions-EqTloHjo.mjs.map +0 -1
- package/dist/functions-SqtCDc9c.cjs.map +0 -1
- package/dist/lazyAccessors-CCTK19xj.mjs +0 -1855
- package/dist/lazyAccessors-CCTK19xj.mjs.map +0 -1
- package/dist/lazyAccessors-D04oftGw.cjs +0 -1920
- package/dist/lazyAccessors-D04oftGw.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazyAccessors-fFIQrblM.mjs","names":["endpoints: Endpoint<any, any, any, any, any, any>[]","options?: OpenApiSchemaOptions","input: unknown","key: K","body: unknown","status: number","headers: Record<string, string>","key?: string","cookieHeader: string | undefined","name?: string","name: string","value: string","options?: CookieOptions","ctx: EndpointContext<TInput, TServices, TLogger, TSession>","input: Record<string, unknown>","ctx: EndpointContext<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTAuditAction,\n\t\t\tTDatabase,\n\t\t\tTAuditStorage\n\t\t>","response: ResponseBuilder","obj: any","response: T | ResponseWithMetadata<T>","componentCollector?: ComponentCollector","operation: OpenAPIV3_1.OperationObject","pathParameters: OpenAPIV3_1.ParameterObject[]","queryParameters: OpenAPIV3_1.ParameterObject[]","routeObject: any","key: string","options?: Pick<CookieOptions, 'domain' | 'path'>","code: SuccessStatus","data: T","c: Context","allHeaders: Record<string, string> | null","key?: string","allCookies: Record<string, string> | null","name?: string","headers: Record<string, string | undefined> | null | undefined","normalizedHeaders: Record<string, string> | null","cookies: string[] | undefined","cookieHeader: string | undefined","parsed: Record<string, string> | null","headers: Record<string, string> | undefined","normalized: Record<string, string> | null"],"sources":["../src/endpoints/Endpoint.ts","../src/endpoints/lazyAccessors.ts"],"sourcesContent":["import type { AuditableAction, Auditor, AuditStorage } from '@geekmidas/audit';\nimport type {\n\tEventPublisher,\n\tExtractPublisherMessage,\n\tMappedEvent,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { RateLimitConfig } from '@geekmidas/rate-limit';\nimport type {\n\tInferComposableStandardSchema,\n\tInferStandardSchema,\n\tInferStandardSchemaInput,\n} from '@geekmidas/schema';\nimport {\n\tconvertSchemaWithComponents,\n\tconvertStandardSchemaToJsonSchema,\n} from '@geekmidas/schema/conversion';\nimport {\n\tbuildOpenApiSchema,\n\ttype ComponentCollector,\n\ttype OpenApiSchemaOptions,\n} from '@geekmidas/schema/openapi';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport { ConstructType } from '../Construct';\nimport { Function, type FunctionHandler } from '../functions';\nimport type { HttpMethod, LowerHttpMethod, RemoveUndefined } from '../types';\nimport type { Authorizer } from './Authorizer';\nimport type { ActorExtractor, MappedAudit } from './audit';\nimport type { RlsConfig } from './rls';\n\n/**\n * Represents an HTTP endpoint that can handle requests with type-safe input/output validation,\n * dependency injection, session management, and authorization.\n *\n * @template TRoute - The route path string with parameter placeholders (e.g., '/users/:id')\n * @template TMethod - The HTTP method (GET, POST, PUT, DELETE, PATCH)\n * @template TInput - The input schema definition for body, query, and path parameters\n * @template OutSchema - The output schema for response validation\n * @template TServices - Array of service dependencies to inject\n * @template TLogger - The logger instance type\n * @template TSession - The session data type\n *\n * @extends Function - Base function construct for handler execution\n *\n * @example\n * ```typescript\n * const endpoint = new Endpoint({\n * route: '/users/:id',\n * method: 'GET',\n * input: { params: userIdSchema },\n * output: userSchema,\n * fn: async ({ params }) => getUserById(params.id)\n * });\n * ```\n */\nexport class Endpoint<\n\tTRoute extends string,\n\tTMethod extends HttpMethod,\n\tTInput extends EndpointSchemas = {},\n\tOutSchema 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\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends Function<\n\tTInput,\n\tTServices,\n\tTLogger,\n\tOutSchema,\n\tTEventPublisher,\n\tTEventPublisherServiceName,\n\tTAuditStorage,\n\tTAuditStorageServiceName,\n\tTDatabase,\n\tTDatabaseServiceName,\n\tTAuditAction,\n\tFunctionHandler<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTDatabase,\n\t\tTAuditStorage,\n\t\tTAuditAction\n\t>\n> {\n\toperationId?: string;\n\t/** The route path pattern with parameter placeholders */\n\troute: TRoute;\n\t/** The HTTP method for this endpoint */\n\tmethod: TMethod;\n\t/** Optional description for OpenAPI documentation */\n\tdescription?: string;\n\t/** Optional tags for OpenAPI documentation */\n\ttags?: string[];\n\t/** The HTTP success status code to return (default: 200) */\n\tpublic readonly status: SuccessStatus;\n\t/**\n\t * Response content type for this endpoint. Defaults to `'application/json'`.\n\t * Non-JSON types cause adaptors to emit the body as-is with the declared\n\t * Content-Type header instead of JSON-serializing.\n\t */\n\tpublic readonly responseType: string;\n\t/** Default headers to apply to all responses */\n\tpublic readonly defaultHeaders: Record<string, string> = {};\n\t/** Function to extract session data from the request context */\n\tpublic getSession: SessionFn<TServices, TLogger, TSession, TDatabase> = () =>\n\t\t({}) as TSession;\n\t/** Function to determine if the request is authorized */\n\tpublic authorize: AuthorizeFn<\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tTInput,\n\t\tTDatabase\n\t> = () => true;\n\t/** Optional rate limiting configuration */\n\tpublic rateLimit?: RateLimitConfig;\n\t/** Optional authorizer for this endpoint */\n\tpublic authorizer?: Authorizer;\n\t/** Optional actor extractor for audit records */\n\tpublic actorExtractor?: ActorExtractor<TServices, TSession, TLogger>;\n\t/** Declarative audit definitions */\n\tpublic audits: MappedAudit<TAuditAction, OutSchema>[] = [];\n\t/** Database service for this endpoint */\n\tpublic declare databaseService?: Service<TDatabaseServiceName, TDatabase>;\n\t/** RLS configuration for this endpoint */\n\tpublic rlsConfig?: RlsConfig<TServices, TSession, TLogger>;\n\t/** Whether to bypass RLS for this endpoint */\n\tpublic rlsBypass?: boolean;\n\t/** The endpoint handler function */\n\tprivate endpointFn!: EndpointHandler<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTSession,\n\t\tTDatabase,\n\t\tTAuditStorage,\n\t\tTAuditAction\n\t>;\n\n\t/**\n\t * Builds a complete OpenAPI 3.1 schema from an array of endpoints.\n\t *\n\t * @param endpoints - Array of endpoint instances to document\n\t * @param options - Optional configuration for OpenAPI generation\n\t * @returns OpenAPI 3.1 specification object\n\t *\n\t * @example\n\t * ```typescript\n\t * const schema = await Endpoint.buildOpenApiSchema([\n\t * getUserEndpoint,\n\t * createUserEndpoint\n\t * ], {\n\t * title: 'User API',\n\t * version: '1.0.0'\n\t * });\n\t * ```\n\t */\n\tstatic async buildOpenApiSchema(\n\t\tendpoints: Endpoint<any, any, any, any, any, any>[],\n\t\toptions?: OpenApiSchemaOptions,\n\t) {\n\t\treturn buildOpenApiSchema(endpoints, options);\n\t}\n\n\t/**\n\t * Gets the full path including HTTP method and route.\n\t * @returns Formatted string like 'GET /users/{id}'\n\t */\n\tget fullPath() {\n\t\treturn `${this.method} ${this._path}` as const;\n\t}\n\n\t/**\n\t * Parses and validates input data for a specific input type (body, query, params).\n\t *\n\t * @param input - The raw input data to validate\n\t * @param key - The input type key ('body', 'query', or 'params')\n\t * @returns The validated input data for the specified key\n\t * @throws {UnprocessableEntityError} When validation fails\n\t */\n\tasync parseInput<K extends keyof TInput>(\n\t\tinput: unknown,\n\t\tkey: K,\n\t): Promise<InferComposableStandardSchema<TInput[K]>> {\n\t\tconst schema = this.input?.[key];\n\t\treturn Endpoint.parseSchema(schema as StandardSchemaV1, input) as Promise<\n\t\t\tInferComposableStandardSchema<TInput[K]>\n\t\t>;\n\t}\n\n\t/**\n\t * Parses and validates the request body against the body schema.\n\t *\n\t * @param body - The raw request body to validate\n\t * @returns The validated body data\n\t * @throws {UnprocessableEntityError} When body validation fails\n\t */\n\tasync parseBody(body: unknown): Promise<InferStandardSchema<TInput['body']>> {\n\t\treturn this.parseInput(body, 'body') as Promise<\n\t\t\tInferStandardSchema<TInput['body']>\n\t\t>;\n\t}\n\n\tstatic isSuccessStatus(status: number): boolean {\n\t\treturn status >= 200 && status < 300;\n\t}\n\n\t/**\n\t * Creates a case-insensitive header lookup function from a headers object.\n\t *\n\t * @param headers - Object containing header key-value pairs\n\t * @returns Function to retrieve header values by case-insensitive key, or all headers\n\t *\n\t * @example\n\t * ```typescript\n\t * const headerFn = Endpoint.createHeaders({ 'Content-Type': 'application/json' });\n\t * headerFn('content-type'); // Returns 'application/json'\n\t * headerFn(); // Returns { 'content-type': 'application/json' }\n\t * ```\n\t */\n\tstatic createHeaders(headers: Record<string, string>): HeaderFn {\n\t\tconst headerMap = new Map<string, string>();\n\t\tfor (const [k, v] of Object.entries(headers)) {\n\t\t\tconst key = k.toLowerCase();\n\t\t\theaderMap.set(key, v);\n\t\t}\n\n\t\tfunction get(): Record<string, string>;\n\t\tfunction get(key: string): string | undefined;\n\t\tfunction get(key?: string): string | undefined | Record<string, string> {\n\t\t\tif (key === undefined) {\n\t\t\t\t// Return all headers as plain object\n\t\t\t\treturn Object.fromEntries(headerMap.entries());\n\t\t\t}\n\t\t\treturn headerMap.get(key.toLowerCase());\n\t\t}\n\n\t\treturn get;\n\t}\n\n\t/**\n\t * Parses cookie string and creates a cookie lookup function.\n\t *\n\t * @param cookieHeader - The Cookie header value\n\t * @returns Function to retrieve cookie values by name, or all cookies\n\t *\n\t * @example\n\t * ```typescript\n\t * const cookieFn = Endpoint.createCookies('session=abc123; theme=dark');\n\t * cookieFn('session'); // Returns 'abc123'\n\t * cookieFn(); // Returns { session: 'abc123', theme: 'dark' }\n\t * ```\n\t */\n\tstatic createCookies(cookieHeader: string | undefined): CookieFn {\n\t\tconst cookieMap = new Map<string, string>();\n\n\t\tif (cookieHeader) {\n\t\t\t// Parse cookie string: \"name1=value1; name2=value2\"\n\t\t\tconst cookies = cookieHeader.split(';');\n\t\t\tfor (const cookie of cookies) {\n\t\t\t\tconst [name, ...valueParts] = cookie.trim().split('=');\n\t\t\t\tif (name) {\n\t\t\t\t\tconst value = valueParts.join('='); // Handle values with = in them\n\t\t\t\t\tcookieMap.set(name, decodeURIComponent(value));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction get(): Record<string, string>;\n\t\tfunction get(name: string): string | undefined;\n\t\tfunction get(name?: string): string | undefined | Record<string, string> {\n\t\t\tif (name === undefined) {\n\t\t\t\t// Return all cookies as plain object\n\t\t\t\treturn Object.fromEntries(cookieMap.entries());\n\t\t\t}\n\t\t\treturn cookieMap.get(name);\n\t\t}\n\n\t\treturn get;\n\t}\n\n\t/**\n\t * Formats a cookie as a Set-Cookie header string.\n\t *\n\t * @param name - Cookie name\n\t * @param value - Cookie value\n\t * @param options - Cookie options (httpOnly, secure, sameSite, etc.)\n\t * @returns Formatted Set-Cookie header string\n\t *\n\t * @example\n\t * ```typescript\n\t * const header = Endpoint.formatCookieHeader('session', 'abc123', {\n\t * httpOnly: true,\n\t * secure: true,\n\t * sameSite: 'strict',\n\t * maxAge: 3600\n\t * });\n\t * // Returns: \"session=abc123; Max-Age=3600; HttpOnly; Secure; SameSite=Strict\"\n\t * ```\n\t */\n\tstatic formatCookieHeader(\n\t\tname: string,\n\t\tvalue: string,\n\t\toptions?: CookieOptions,\n\t): string {\n\t\tlet cookie = `${name}=${value}`;\n\n\t\tif (options) {\n\t\t\tif (options.domain) cookie += `; Domain=${options.domain}`;\n\t\t\tif (options.path) cookie += `; Path=${options.path}`;\n\t\t\tif (options.expires)\n\t\t\t\tcookie += `; Expires=${options.expires.toUTCString()}`;\n\t\t\tif (options.maxAge !== undefined) cookie += `; Max-Age=${options.maxAge}`;\n\t\t\tif (options.httpOnly) cookie += '; HttpOnly';\n\t\t\tif (options.secure) cookie += '; Secure';\n\t\t\tif (options.sameSite) {\n\t\t\t\tcookie += `; SameSite=${options.sameSite.charAt(0).toUpperCase() + options.sameSite.slice(1)}`;\n\t\t\t}\n\t\t}\n\n\t\treturn cookie;\n\t}\n\n\t/**\n\t * Extracts and refines input data from the endpoint context.\n\t *\n\t * @param ctx - The endpoint execution context\n\t * @returns Object containing only the input data (body, query, params)\n\t * @internal\n\t */\n\trefineInput(\n\t\tctx: EndpointContext<TInput, TServices, TLogger, TSession>,\n\t): InferComposableStandardSchema<TInput> {\n\t\tconst input: Record<string, unknown> = {};\n\t\tfor (const key of ['body', 'query', 'params'] as const) {\n\t\t\tif (key in ctx) {\n\t\t\t\tinput[key] = (ctx as Record<string, unknown>)[key];\n\t\t\t}\n\t\t}\n\n\t\treturn input as InferComposableStandardSchema<TInput>;\n\t}\n\n\thandler = (\n\t\tctx: EndpointContext<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTAuditAction,\n\t\t\tTDatabase,\n\t\t\tTAuditStorage\n\t\t>,\n\t\tresponse: ResponseBuilder,\n\t): OutSchema extends StandardSchemaV1\n\t\t? // Handler produces the output schema's INPUT type (the schema\n\t\t\t// may coerce it on the way out — see EndpointHandler).\n\t\t\t\t| InferStandardSchemaInput<OutSchema>\n\t\t\t\t| ResponseWithMetadata<InferStandardSchemaInput<OutSchema>>\n\t\t\t\t| Promise<InferStandardSchemaInput<OutSchema>>\n\t\t\t\t| Promise<ResponseWithMetadata<InferStandardSchemaInput<OutSchema>>>\n\t\t:\n\t\t\t\t| any\n\t\t\t\t| ResponseWithMetadata<any>\n\t\t\t\t| Promise<any>\n\t\t\t\t| Promise<ResponseWithMetadata<any>> => {\n\t\t// Apply default headers to response builder\n\t\tfor (const [key, value] of Object.entries(this.defaultHeaders)) {\n\t\t\tresponse.header(key, value);\n\t\t}\n\n\t\t// Build context object, conditionally including auditor and db\n\t\tconst handlerCtx = {\n\t\t\t...this.refineInput(ctx),\n\t\t\tservices: ctx.services,\n\t\t\tlogger: ctx.logger,\n\t\t\theader: ctx.header,\n\t\t\tcookie: ctx.cookie,\n\t\t\tsession: ctx.session,\n\t\t\t// These are conditionally present based on configuration\n\t\t\t...('auditor' in ctx && { auditor: ctx.auditor }),\n\t\t\t...('db' in ctx && { db: ctx.db }),\n\t\t} as EndpointContext<\n\t\t\tTInput,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTSession,\n\t\t\tTAuditAction,\n\t\t\tTDatabase,\n\t\t\tTAuditStorage\n\t\t>;\n\n\t\treturn this.endpointFn(handlerCtx, response);\n\t};\n\n\t/**\n\t * Type guard to check if an object is an Endpoint instance.\n\t *\n\t * @param obj - The object to check\n\t * @returns True if the object is an Endpoint\n\t */\n\tstatic isEndpoint(obj: any): obj is Endpoint<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.Endpoint,\n\t\t);\n\t}\n\n\t/**\n\t * Helper to check if response has metadata\n\t */\n\tstatic hasMetadata<T>(\n\t\tresponse: T | ResponseWithMetadata<T>,\n\t): response is ResponseWithMetadata<T> {\n\t\treturn (\n\t\t\tresponse !== null &&\n\t\t\ttypeof response === 'object' &&\n\t\t\t'data' in response &&\n\t\t\t'metadata' in response\n\t\t);\n\t}\n\n\t/**\n\t * Converts Express-style route params to OpenAPI format.\n\t * @returns Route with ':param' converted to '{param}'\n\t * @internal\n\t */\n\tget _path() {\n\t\treturn this.route.replace(/:(\\w+)/g, '{$1}') as ConvertRouteParams<TRoute>;\n\t}\n\n\t/**\n\t * Generates OpenAPI 3.1 schema for this endpoint.\n\t *\n\t * @returns OpenAPI route definition with operation details\n\t */\n\tasync toOpenApi3Route(\n\t\tcomponentCollector?: ComponentCollector,\n\t): Promise<EndpointOpenApiSchema<TRoute, TMethod>> {\n\t\tconst operation: OpenAPIV3_1.OperationObject = {\n\t\t\toperationId: this.operationId,\n\t\t\t...(this.description && { description: this.description }),\n\t\t\t...(this.tags && this.tags.length > 0 && { tags: this.tags }),\n\t\t\tresponses: {\n\t\t\t\t'200': {\n\t\t\t\t\tdescription: 'Successful response',\n\t\t\t\t} as OpenAPIV3_1.ResponseObject,\n\t\t\t},\n\t\t};\n\n\t\t// Add response schema\n\t\tif (this.outputSchema) {\n\t\t\tconst responseSchema = await convertSchemaWithComponents(\n\t\t\t\tthis.outputSchema,\n\t\t\t\tcomponentCollector,\n\t\t\t);\n\t\t\tif (responseSchema) {\n\t\t\t\t(operation.responses!['200'] as OpenAPIV3_1.ResponseObject).content = {\n\t\t\t\t\t[this.responseType]: { schema: responseSchema },\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Separate path and query parameters\n\t\tconst pathParameters: OpenAPIV3_1.ParameterObject[] = [];\n\t\tconst queryParameters: OpenAPIV3_1.ParameterObject[] = [];\n\n\t\t// Since the EndpointBuilder doesn't have body/search/params methods yet,\n\t\t// and the input is a composite type, we need to check if input exists\n\t\t// and has the expected shape\n\t\tif (this.input && typeof this.input === 'object') {\n\t\t\t// Add request body for methods that support it\n\t\t\tif (\n\t\t\t\t['POST', 'PUT', 'PATCH'].includes(this.method) &&\n\t\t\t\t'body' in this.input &&\n\t\t\t\tthis.input.body\n\t\t\t) {\n\t\t\t\tconst bodySchema = await convertSchemaWithComponents(\n\t\t\t\t\tthis.input.body as StandardSchemaV1,\n\t\t\t\t\tcomponentCollector,\n\t\t\t\t);\n\t\t\t\tif (bodySchema) {\n\t\t\t\t\toperation.requestBody = {\n\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t'application/json': {\n\t\t\t\t\t\t\t\tschema: bodySchema,\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\t\t\t}\n\n\t\t\t// Add path parameters\n\t\t\tif ('params' in this.input && this.input.params) {\n\t\t\t\tconst paramsSchema = await convertStandardSchemaToJsonSchema(\n\t\t\t\t\tthis.input.params as StandardSchemaV1,\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tparamsSchema &&\n\t\t\t\t\tparamsSchema.type === 'object' &&\n\t\t\t\t\tparamsSchema.properties\n\t\t\t\t) {\n\t\t\t\t\tfor (const [name, schema] of Object.entries(\n\t\t\t\t\t\tparamsSchema.properties,\n\t\t\t\t\t)) {\n\t\t\t\t\t\tpathParameters.push({\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tin: 'path',\n\t\t\t\t\t\t\trequired: paramsSchema.required?.includes(name) ?? true,\n\t\t\t\t\t\t\tschema: schema as any,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add query parameters\n\t\t\tif ('query' in this.input && this.input.query) {\n\t\t\t\tconst querySchema = await convertStandardSchemaToJsonSchema(\n\t\t\t\t\tthis.input.query,\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tquerySchema &&\n\t\t\t\t\tquerySchema.type === 'object' &&\n\t\t\t\t\tquerySchema.properties\n\t\t\t\t) {\n\t\t\t\t\tfor (const [name, schema] of Object.entries(querySchema.properties)) {\n\t\t\t\t\t\tqueryParameters.push({\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tin: 'query',\n\t\t\t\t\t\t\trequired: querySchema.required?.includes(name) ?? false,\n\t\t\t\t\t\t\tschema: schema as any,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Only add query parameters to the operation\n\t\tif (queryParameters.length > 0) {\n\t\t\toperation.parameters = queryParameters;\n\t\t}\n\n\t\t// Build the route object with path parameters at the route level\n\t\tconst routeObject: any = {};\n\t\tif (pathParameters.length > 0) {\n\t\t\trouteObject.parameters = pathParameters;\n\t\t}\n\t\trouteObject[this.method.toLowerCase()] = operation;\n\n\t\treturn {\n\t\t\t[this._path]: routeObject,\n\t\t} as EndpointOpenApiSchema<TRoute, TMethod>;\n\t}\n\n\t/**\n\t * Creates a new Endpoint instance.\n\t *\n\t * @param options - Configuration options for the endpoint\n\t * @param options.fn - The handler function to execute\n\t * @param options.method - HTTP method\n\t * @param options.route - Route path with parameter placeholders\n\t * @param options.description - Optional description for documentation\n\t * @param options.input - Input schemas for validation\n\t * @param options.logger - Logger instance\n\t * @param options.output - Output schema for response validation\n\t * @param options.services - Service dependencies\n\t * @param options.timeout - Execution timeout in milliseconds\n\t * @param options.getSession - Session extraction function\n\t * @param options.authorize - Authorization check function\n\t * @param options.status - Success HTTP status code (default: 200)\n\t * @param options.authorizer - Optional authorizer configuration\n\t */\n\tconstructor({\n\t\tfn,\n\t\tmethod,\n\t\troute,\n\t\tdescription,\n\t\ttags,\n\t\tinput,\n\t\tlogger,\n\t\toutput: outputSchema,\n\t\tservices,\n\t\ttimeout,\n\t\tmemorySize,\n\t\tgetSession,\n\t\tauthorize,\n\t\trateLimit,\n\t\tstatus = SuccessStatus.OK,\n\t\tpublisherService,\n\t\tevents,\n\t\tauthorizer,\n\t\tauditorStorageService,\n\t\tactorExtractor,\n\t\taudits,\n\t\tdatabaseService,\n\t\trlsConfig,\n\t\trlsBypass,\n\t\tresponseType,\n\t}: EndpointOptions<\n\t\tTRoute,\n\t\tTMethod,\n\t\tTInput,\n\t\tOutSchema,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTAuditStorage,\n\t\tTAuditStorageServiceName,\n\t\tTAuditAction,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t>) {\n\t\tsuper(\n\t\t\tfn as unknown as FunctionHandler<TInput, TServices, TLogger, OutSchema>,\n\t\t\ttimeout,\n\t\t\tConstructType.Endpoint,\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\tauditorStorageService,\n\t\t);\n\n\t\tthis.route = route;\n\t\tthis.method = method;\n\t\tthis.description = description;\n\t\tthis.tags = tags;\n\t\tthis.status = status;\n\t\tthis.responseType = responseType ?? 'application/json';\n\t\tthis.endpointFn = fn;\n\n\t\tif (getSession) {\n\t\t\tthis.getSession = getSession;\n\t\t}\n\n\t\tif (authorize) {\n\t\t\tthis.authorize = authorize;\n\t\t}\n\n\t\tif (rateLimit) {\n\t\t\tthis.rateLimit = rateLimit;\n\t\t}\n\n\t\tif (authorizer) {\n\t\t\tthis.authorizer = authorizer;\n\t\t}\n\n\t\tif (actorExtractor) {\n\t\t\tthis.actorExtractor = actorExtractor;\n\t\t}\n\n\t\tif (audits) {\n\t\t\tthis.audits = audits;\n\t\t}\n\n\t\tif (databaseService) {\n\t\t\tthis.databaseService = databaseService;\n\t\t}\n\n\t\tif (rlsConfig) {\n\t\t\tthis.rlsConfig = rlsConfig;\n\t\t}\n\n\t\tif (rlsBypass) {\n\t\t\tthis.rlsBypass = rlsBypass;\n\t\t}\n\t}\n}\n\n/**\n * Defines the input schema structure for an endpoint.\n *\n * @template TBody - Schema for request body validation\n * @template TSearch - Schema for query string validation\n * @template TParams - Schema for URL path parameters validation\n *\n * @example\n * ```typescript\n * type UserInput = EndpointInput<\n * typeof createUserBodySchema,\n * typeof userQuerySchema,\n * typeof userParamsSchema\n * >;\n * ```\n */\nexport type EndpointInput<\n\tTBody extends StandardSchemaV1 | undefined = undefined,\n\tTSearch extends StandardSchemaV1 | undefined = undefined,\n\tTParams extends StandardSchemaV1 | undefined = undefined,\n> = RemoveUndefined<{\n\tbody: TBody;\n\tsearch: TSearch;\n\tparams: TParams;\n}>;\n\n/**\n * Configuration options for creating an Endpoint instance.\n *\n * @template TRoute - The route path string\n * @template TMethod - The HTTP method\n * @template TInput - Input schema definitions\n * @template TOutput - Output schema definition\n * @template TServices - Service dependencies array\n * @template TLogger - Logger type\n * @template TSession - Session data type\n */\nexport interface EndpointOptions<\n\tTRoute extends string,\n\tTMethod extends HttpMethod,\n\tTInput extends EndpointSchemas = {},\n\tTOutput extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\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\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> {\n\t/** The route path with parameter placeholders */\n\troute: TRoute;\n\t/** The HTTP method for this endpoint */\n\tmethod: TMethod;\n\t/** The handler function that implements the endpoint logic */\n\tfn: EndpointHandler<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tTOutput,\n\t\tTSession,\n\t\tTDatabase,\n\t\tTAuditStorage,\n\t\tTAuditAction\n\t>;\n\t/** Optional authorization check function */\n\tauthorize:\n\t\t| AuthorizeFn<TServices, TLogger, TSession, TInput, TDatabase>\n\t\t| undefined;\n\t/** Optional description for documentation */\n\tdescription: string | undefined;\n\t/** Optional tags for OpenAPI documentation */\n\ttags?: string[];\n\t/** Optional execution timeout in milliseconds */\n\ttimeout: number | undefined;\n\t/** Optional memory size in MB for serverless deployments */\n\tmemorySize: number | undefined;\n\t/** Input validation schemas */\n\tinput: TInput | undefined;\n\t/** Output validation schema */\n\toutput: TOutput | undefined;\n\t/** Service dependencies to inject */\n\tservices: TServices;\n\t/** Logger instance */\n\tlogger: TLogger;\n\t/** Optional session extraction function */\n\tgetSession: SessionFn<TServices, TLogger, TSession, TDatabase> | undefined;\n\t/** Optional rate limiting configuration */\n\trateLimit?: RateLimitConfig;\n\t/** Success HTTP status code */\n\tstatus: SuccessStatus | undefined;\n\t/**\n\t * Event publisher service for publishing events from this endpoint\n\t */\n\tpublisherService?: Service<TEventPublisherServiceName, TEventPublisher>;\n\n\tevents?: MappedEvent<TEventPublisher, OutSchema>[];\n\t/** Optional authorizer configuration */\n\tauthorizer?: Authorizer;\n\t/**\n\t * Auditor storage service for persisting audit records from this endpoint\n\t */\n\tauditorStorageService?: Service<TAuditStorageServiceName, TAuditStorage>;\n\t/** Optional actor extractor function for audit records */\n\tactorExtractor?: ActorExtractor<TServices, TSession, TLogger>;\n\t/** Declarative audit definitions */\n\taudits?: MappedAudit<TAuditAction, OutSchema>[];\n\t/** Database service for this endpoint */\n\tdatabaseService?: Service<TDatabaseServiceName, TDatabase>;\n\t/** RLS configuration for this endpoint */\n\trlsConfig?: RlsConfig<TServices, TSession, TLogger>;\n\t/** Whether to bypass RLS for this endpoint */\n\trlsBypass?: boolean;\n\t/**\n\t * Response content type (e.g. `'application/json'`, `'text/html'`).\n\t * Defaults to `'application/json'` when omitted.\n\t */\n\tresponseType?: string;\n}\n\n/**\n * Defines the possible input schema types for an endpoint.\n * Each property represents a different part of the HTTP request.\n */\nexport type EndpointSchemas = Partial<{\n\t/** Schema for URL path parameters (e.g., /users/:id) */\n\tparams: StandardSchemaV1;\n\t/** Schema for query string parameters */\n\tquery: StandardSchemaV1;\n\t/** Schema for request body (POST, PUT, PATCH) */\n\tbody: StandardSchemaV1;\n}>;\n\nexport type AuthorizeContext<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n\tTInput extends EndpointSchemas | undefined = undefined,\n\tTDatabase = undefined,\n> = {\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n\theader: HeaderFn;\n\tcookie: CookieFn;\n\tsession: TSession;\n} & InferComposableStandardSchema<TInput> &\n\tSessionDatabaseContext<TDatabase>;\n/**\n * Function type for endpoint authorization checks.\n *\n * @template TServices - Available service dependencies\n * @template TLogger - Logger type\n * @template TSession - Session data type\n *\n * @param ctx - Context containing services, logger, headers, and session\n * @returns Boolean indicating if the request is authorized\n *\n * @example\n * ```typescript\n * const authorize: AuthorizeFn = ({ session }) => {\n * return session.userId !== undefined;\n * };\n * ```\n */\nexport type AuthorizeFn<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n\tTInput extends EndpointSchemas | undefined = undefined,\n\tTDatabase = undefined,\n> = (\n\tctx: AuthorizeContext<TServices, TLogger, TSession, TInput, TDatabase>,\n) => Promise<boolean> | boolean;\n\n/**\n * Base session context without database\n */\ntype BaseSessionContext<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n\theader: HeaderFn;\n\tcookie: CookieFn;\n};\n\n/**\n * Conditional database context for session - only present when database service is configured\n */\ntype SessionDatabaseContext<TDatabase = undefined> = TDatabase extends undefined\n\t? {}\n\t: {\n\t\t\t/**\n\t\t\t * Database instance for session extraction.\n\t\t\t * Available when a database service is configured via `.database()`.\n\t\t\t * Useful for looking up user data from the database based on auth tokens.\n\t\t\t */\n\t\t\tdb: TDatabase;\n\t\t};\n\nexport type SessionContext<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n> = BaseSessionContext<TServices, TLogger> & SessionDatabaseContext<TDatabase>;\n/**\n * Function type for extracting session data from a request.\n *\n * @template TServices - Available service dependencies\n * @template TLogger - Logger type\n * @template TSession - Session data type to extract\n * @template TDatabase - Database type (when database service is configured)\n *\n * @param ctx - Context containing services, logger, headers, and optionally database\n * @returns The extracted session data\n *\n * @example\n * ```typescript\n * // Without database\n * const getSession: SessionFn<Services, Logger, UserSession> = async ({ header, services }) => {\n * const token = header('authorization');\n * return await services.auth.verifyToken(token);\n * };\n *\n * // With database\n * const getSession: SessionFn<Services, Logger, UserSession, Database> = async ({ header, db }) => {\n * const token = header('authorization');\n * const user = await db.selectFrom('users').where('token', '=', token).executeTakeFirst();\n * return { userId: user?.id };\n * };\n * ```\n */\nexport type SessionFn<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n\tTDatabase = undefined,\n> = (\n\tctx: SessionContext<TServices, TLogger, TDatabase>,\n) => Promise<TSession> | TSession;\n\n/**\n * Utility type that converts Express-style route parameters to OpenAPI format.\n * Transforms ':param' syntax to '{param}' syntax.\n *\n * @template T - The route string to convert\n *\n * @example\n * ```typescript\n * type Route1 = ConvertRouteParams<'/users/:id'>; // '/users/{id}'\n * type Route2 = ConvertRouteParams<'/users/:userId/posts/:postId'>; // '/users/{userId}/posts/{postId}'\n * ```\n */\nexport type ConvertRouteParams<T extends string> =\n\tT extends `${infer Start}:${infer Param}/${infer Rest}`\n\t\t? `${Start}{${Param}}/${ConvertRouteParams<Rest>}`\n\t\t: T extends `${infer Start}:${infer Param}`\n\t\t\t? `${Start}{${Param}}`\n\t\t\t: T;\n\n/**\n * Type representing the OpenAPI schema structure for an endpoint.\n *\n * @template TRoute - The route path\n * @template TMethod - The HTTP method\n *\n * @example\n * ```typescript\n * type Schema = EndpointOpenApiSchema<'/users/:id', 'GET'>;\n * // Results in: { '/users/{id}': { get: OperationObject, parameters?: ParameterObject[] } }\n * ```\n */\nexport type EndpointOpenApiSchema<\n\tTRoute extends string,\n\tTMethod extends HttpMethod,\n> = {\n\t[key in ConvertRouteParams<TRoute>]: {\n\t\t[key in LowerHttpMethod<TMethod>]: OpenAPIV3_1.OperationObject<{}>;\n\t} & {\n\t\tparameters?: OpenAPIV3_1.ParameterObject[];\n\t};\n};\n\nexport type SingleHeaderFn = (key: string) => string | undefined;\nexport type MultiHeaderFn = () => EndpointHeaders;\n/**\n * Type representing HTTP headers as a Map.\n */\nexport type EndpointHeaders = Map<string, string>;\n\n/**\n * Function type for retrieving HTTP header values.\n * Supports two calling patterns:\n * - `header(key)` - Get a single header value (case-insensitive)\n * - `header()` - Get all headers as a plain object\n *\n * @example\n * ```typescript\n * // Get single header\n * const contentType = header('content-type');\n *\n * // Get all headers\n * const allHeaders = header();\n * // { 'content-type': 'application/json', 'host': 'example.com', ... }\n * ```\n */\nexport interface HeaderFn {\n\t(): Record<string, string>;\n\t(key: string): string | undefined;\n}\n\n/**\n * Function type for retrieving cookie values.\n * Supports two calling patterns:\n * - `cookie(name)` - Get a single cookie value\n * - `cookie()` - Get all cookies as a plain object\n *\n * @example\n * ```typescript\n * // Get single cookie\n * const sessionId = cookie('session');\n *\n * // Get all cookies\n * const allCookies = cookie();\n * // { session: 'abc123', theme: 'dark', ... }\n * ```\n */\nexport interface CookieFn {\n\t(): Record<string, string>;\n\t(name: string): string | undefined;\n}\n\n/**\n * Cookie options matching standard Set-Cookie attributes\n */\nexport interface CookieOptions {\n\tdomain?: string;\n\tpath?: string;\n\texpires?: Date;\n\tmaxAge?: number;\n\thttpOnly?: boolean;\n\tsecure?: boolean;\n\tsameSite?: 'strict' | 'lax' | 'none';\n}\n\n/**\n * Response metadata that handlers can set\n */\nexport interface ResponseMetadata {\n\theaders?: Record<string, string>;\n\tcookies?: Map<string, { value: string; options?: CookieOptions }>;\n\tstatus?: SuccessStatus;\n}\n\n/**\n * Return type for handlers that want to set response metadata\n */\nexport interface ResponseWithMetadata<T> {\n\tdata: T;\n\tmetadata: ResponseMetadata;\n}\n\n/**\n * Response builder for fluent API in handlers\n */\nexport class ResponseBuilder {\n\tprivate metadata: ResponseMetadata = {\n\t\theaders: {},\n\t\tcookies: new Map(),\n\t};\n\n\theader(key: string, value: string): this {\n\t\tthis.metadata.headers![key] = value;\n\t\treturn this;\n\t}\n\n\tcookie(name: string, value: string, options?: CookieOptions): this {\n\t\tthis.metadata.cookies?.set(name, { value, options });\n\t\treturn this;\n\t}\n\n\tdeleteCookie(\n\t\tname: string,\n\t\toptions?: Pick<CookieOptions, 'domain' | 'path'>,\n\t): this {\n\t\tthis.metadata.cookies?.set(name, {\n\t\t\tvalue: '',\n\t\t\toptions: { ...options, maxAge: 0, expires: new Date(0) },\n\t\t});\n\t\treturn this;\n\t}\n\n\tstatus(code: SuccessStatus): this {\n\t\tthis.metadata.status = code;\n\t\treturn this;\n\t}\n\n\tsend<T>(data: T): ResponseWithMetadata<T> {\n\t\treturn { data, metadata: this.metadata };\n\t}\n\n\tgetMetadata(): ResponseMetadata {\n\t\treturn this.metadata;\n\t}\n}\n\n/**\n * Base context properties that are always available\n */\ntype BaseEndpointContext<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n> = {\n\t/** Injected service instances */\n\tservices: ServiceRecord<TServices>;\n\t/** Logger instance for this request */\n\tlogger: TLogger;\n\t/** Function to retrieve request headers */\n\theader: HeaderFn;\n\t/** Function to retrieve request cookies */\n\tcookie: CookieFn;\n\t/** Session data extracted by getSession */\n\tsession: TSession;\n};\n\n/**\n * Conditional auditor context - only present when audit storage is configured\n */\ntype AuditorContext<\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n\tTAuditStorage = undefined,\n> = TAuditStorage extends undefined\n\t? {}\n\t: {\n\t\t\t/**\n\t\t\t * Auditor instance for recording audit events.\n\t\t\t * Only present when audit storage is configured on the endpoint.\n\t\t\t * When a transactional database is used for audit storage,\n\t\t\t * the auditor is pre-configured with the transaction context.\n\t\t\t */\n\t\t\tauditor: Auditor<TAuditAction>;\n\t\t};\n\n/**\n * Conditional database context - only present when database service is configured\n */\ntype DatabaseContext<TDatabase = undefined> = TDatabase extends undefined\n\t? {}\n\t: {\n\t\t\t/**\n\t\t\t * Database instance for this request.\n\t\t\t * When audit storage is configured and uses the same database,\n\t\t\t * this will be the transaction for ACID compliance.\n\t\t\t * Otherwise, it's the raw database connection.\n\t\t\t */\n\t\t\tdb: TDatabase;\n\t\t};\n\n/**\n * The execution context provided to endpoint handlers.\n * Contains all parsed input data, services, logger, headers, cookies, and session.\n *\n * @template Input - The input schemas (body, query, params)\n * @template TServices - Available service dependencies\n * @template TLogger - Logger type\n * @template TSession - Session data type\n * @template TAuditAction - Audit action types (when auditor is configured)\n * @template TDatabase - Database type (when database service is configured)\n * @template TAuditStorage - Audit storage type (determines if auditor is present)\n */\nexport type EndpointContext<\n\tInput extends EndpointSchemas | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTSession = unknown,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n\tTDatabase = undefined,\n\tTAuditStorage = undefined,\n> = BaseEndpointContext<TServices, TLogger, TSession> &\n\tInferComposableStandardSchema<Input> &\n\tAuditorContext<TAuditAction, TAuditStorage> &\n\tDatabaseContext<TDatabase>;\n\n/**\n * Handler function type for endpoint implementations.\n *\n * @template TInput - Input schemas for validation\n * @template TServices - Available service dependencies\n * @template TLogger - Logger type\n * @template OutSchema - Output schema for response validation\n * @template TSession - Session data type\n *\n * @param ctx - The endpoint execution context\n * @param response - Response builder for setting cookies, headers, and status\n * @returns The response data (validated if OutSchema is provided) or ResponseWithMetadata\n *\n * @example\n * ```typescript\n * // Simple response\n * const handler: EndpointHandler<Input, [UserService], Logger, UserSchema> =\n * async ({ params, services }) => {\n * return await services.users.findById(params.id);\n * };\n *\n * // With response builder\n * const handler: EndpointHandler<Input, [UserService], Logger, UserSchema> =\n * async ({ params, services }, response) => {\n * const user = await services.users.findById(params.id);\n * return response.header('X-User-Id', user.id).send(user);\n * };\n * ```\n */\nexport type EndpointHandler<\n\tTInput extends EndpointSchemas | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTSession = unknown,\n\tTDatabase = undefined,\n\tTAuditStorage = undefined,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n> = (\n\tctx: EndpointContext<\n\t\tTInput,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tTAuditAction,\n\t\tTDatabase,\n\t\tTAuditStorage\n\t>,\n\tresponse: ResponseBuilder,\n) => OutSchema extends StandardSchemaV1\n\t? // The handler must produce the schema's INPUT type — the output\n\t\t// schema is allowed to coerce it (e.g. a `Date` → ISO `string`),\n\t\t// so the handler may return the looser input while consumers\n\t\t// (EndpointOutput / the generated client) still see the parsed\n\t\t// output type.\n\t\t\t| InferStandardSchemaInput<OutSchema>\n\t\t\t| ResponseWithMetadata<InferStandardSchemaInput<OutSchema>>\n\t\t\t| Promise<InferStandardSchemaInput<OutSchema>>\n\t\t\t| Promise<ResponseWithMetadata<InferStandardSchemaInput<OutSchema>>>\n\t:\n\t\t\t| unknown\n\t\t\t| ResponseWithMetadata<unknown>\n\t\t\t| Promise<unknown>\n\t\t\t| Promise<ResponseWithMetadata<unknown>>;\n\n/**\n * HTTP success status codes that can be returned by endpoints.\n */\nexport enum SuccessStatus {\n\t/** Standard response for successful HTTP requests */\n\tOK = 200,\n\t/** Request has been fulfilled and resulted in a new resource being created */\n\tCreated = 201,\n\t/** Request has been accepted for processing, but processing is not complete */\n\tAccepted = 202,\n\t/** Server successfully processed the request but is not returning any content */\n\tNoContent = 204,\n\t/** Server successfully processed the request and is not returning any content, client should reset the document view */\n\tResetContent = 205,\n\t/** Server is delivering only part of the resource due to a range header */\n\tPartialContent = 206,\n}\n\nexport type EndpointOutput<T> =\n\tT extends Endpoint<any, any, any, infer OutSchema, any, any, any, any>\n\t\t? InferStandardSchema<OutSchema>\n\t\t: never;\n\nexport type EndpointEvent<T> =\n\tT extends Endpoint<any, any, any, any, any, any, any, infer TEventPublisher>\n\t\t? ExtractPublisherMessage<TEventPublisher>\n\t\t: never;\n","/**\n * Lazy header and cookie accessors for different adaptors.\n *\n * Instead of parsing all headers/cookies upfront, these accessors\n * use native adaptor methods for single lookups and only parse\n * everything when `header()` or `cookie()` is called without arguments.\n */\nimport type { Context } from 'hono';\nimport { getCookie } from 'hono/cookie';\nimport type { CookieFn, HeaderFn } from './Endpoint';\n\n/**\n * Create a lazy header accessor for Hono.\n * Uses `c.req.header(name)` for single lookups (native, case-insensitive).\n * Only calls `c.req.header()` to get all headers when needed.\n */\nexport function createHonoHeaders(c: Context): HeaderFn {\n\tlet allHeaders: Record<string, string> | null = null;\n\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) {\n\t\t\t// Single header lookup - use native Hono method (case-insensitive)\n\t\t\treturn c.req.header(key);\n\t\t}\n\t\t// Get all headers - cache the result\n\t\tif (!allHeaders) {\n\t\t\tallHeaders = c.req.header();\n\t\t}\n\t\treturn allHeaders;\n\t}) as HeaderFn;\n}\n\n/**\n * Create a lazy cookie accessor for Hono.\n * Uses `getCookie(c, name)` for single lookups (native).\n * Only parses the cookie header when all cookies are requested.\n */\nexport function createHonoCookies(c: Context): CookieFn {\n\tlet allCookies: Record<string, string> | null = null;\n\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) {\n\t\t\t// Single cookie lookup - use native Hono method\n\t\t\treturn getCookie(c, name);\n\t\t}\n\t\t// Get all cookies - parse and cache\n\t\tif (!allCookies) {\n\t\t\tallCookies = {};\n\t\t\tconst cookieHeader = c.req.header('cookie');\n\t\t\tif (cookieHeader) {\n\t\t\t\tfor (const part of cookieHeader.split(';')) {\n\t\t\t\t\tconst trimmed = part.trim();\n\t\t\t\t\tconst eqIndex = trimmed.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = trimmed.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = trimmed.slice(eqIndex + 1);\n\t\t\t\t\t\tallCookies[key] = value;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn allCookies;\n\t}) as CookieFn;\n}\n\n/**\n * Create a lazy header accessor for API Gateway events.\n * Handles case-insensitive lookups.\n */\nexport function createApiGatewayHeaders(\n\theaders: Record<string, string | undefined> | null | undefined,\n): HeaderFn {\n\tlet normalizedHeaders: Record<string, string> | null = null;\n\n\tconst normalize = () => {\n\t\tif (!normalizedHeaders) {\n\t\t\tnormalizedHeaders = {};\n\t\t\tif (headers) {\n\t\t\t\tfor (const [k, v] of Object.entries(headers)) {\n\t\t\t\t\tif (v !== undefined) {\n\t\t\t\t\t\tnormalizedHeaders[k.toLowerCase()] = v;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn normalizedHeaders;\n\t};\n\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) {\n\t\t\t// Try direct lookup first (common case: headers already lowercase)\n\t\t\tif (headers) {\n\t\t\t\tconst direct = headers[key] ?? headers[key.toLowerCase()];\n\t\t\t\tif (direct !== undefined) return direct;\n\t\t\t\t// Fall back to normalized lookup\n\t\t\t\treturn normalize()[key.toLowerCase()];\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\treturn normalize();\n\t}) as HeaderFn;\n}\n\n/**\n * Create a lazy cookie accessor for API Gateway events.\n * Decodes URL-encoded values to match browser behavior.\n */\nexport function createApiGatewayCookies(\n\tcookies: string[] | undefined,\n\tcookieHeader: string | undefined,\n): CookieFn {\n\tlet parsed: Record<string, string> | null = null;\n\n\tconst parse = () => {\n\t\tif (!parsed) {\n\t\t\tparsed = {};\n\t\t\t// API Gateway v2 provides cookies as array\n\t\t\tif (cookies) {\n\t\t\t\tfor (const cookie of cookies) {\n\t\t\t\t\tconst eqIndex = cookie.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = cookie.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = cookie.slice(eqIndex + 1);\n\t\t\t\t\t\tparsed[key] = decodeURIComponent(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (cookieHeader) {\n\t\t\t\t// Fall back to parsing cookie header\n\t\t\t\tfor (const part of cookieHeader.split(';')) {\n\t\t\t\t\tconst trimmed = part.trim();\n\t\t\t\t\tconst eqIndex = trimmed.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = trimmed.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = trimmed.slice(eqIndex + 1);\n\t\t\t\t\t\tparsed[key] = decodeURIComponent(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn parsed;\n\t};\n\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) {\n\t\t\treturn parse()[name];\n\t\t}\n\t\treturn parse();\n\t}) as CookieFn;\n}\n\n/**\n * Create a lazy header accessor for plain object headers (test adaptor, etc).\n * Headers are already available as an object, just provide lazy access.\n */\nexport function createObjectHeaders(\n\theaders: Record<string, string> | undefined,\n): HeaderFn {\n\tlet normalized: Record<string, string> | null = null;\n\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) {\n\t\t\t// Try direct lookup first (common case)\n\t\t\tif (headers) {\n\t\t\t\tconst direct = headers[key] ?? headers[key.toLowerCase()];\n\t\t\t\tif (direct !== undefined) return direct;\n\t\t\t}\n\t\t\t// Fall back to normalized lookup for case-insensitivity\n\t\t\tif (!normalized && headers) {\n\t\t\t\tnormalized = {};\n\t\t\t\tfor (const [k, v] of Object.entries(headers)) {\n\t\t\t\t\tnormalized[k.toLowerCase()] = v;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn normalized?.[key.toLowerCase()];\n\t\t}\n\t\t// Return all headers\n\t\tif (!normalized && headers) {\n\t\t\tnormalized = {};\n\t\t\tfor (const [k, v] of Object.entries(headers)) {\n\t\t\t\tnormalized[k.toLowerCase()] = v;\n\t\t\t}\n\t\t}\n\t\treturn normalized ?? {};\n\t}) as HeaderFn;\n}\n\n/**\n * Create a lazy cookie accessor from a cookie header string.\n * Decodes URL-encoded values to match browser behavior.\n */\nexport function createCookieHeaderAccessor(\n\tcookieHeader: string | undefined,\n): CookieFn {\n\tlet parsed: Record<string, string> | null = null;\n\n\tconst parse = () => {\n\t\tif (!parsed) {\n\t\t\tparsed = {};\n\t\t\tif (cookieHeader) {\n\t\t\t\tfor (const part of cookieHeader.split(';')) {\n\t\t\t\t\tconst trimmed = part.trim();\n\t\t\t\t\tconst eqIndex = trimmed.indexOf('=');\n\t\t\t\t\tif (eqIndex > 0) {\n\t\t\t\t\t\tconst key = trimmed.slice(0, eqIndex);\n\t\t\t\t\t\tconst value = trimmed.slice(eqIndex + 1);\n\t\t\t\t\t\t// Decode URL-encoded values to match Endpoint.createCookies behavior\n\t\t\t\t\t\tparsed[key] = decodeURIComponent(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn parsed;\n\t};\n\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) {\n\t\t\treturn parse()[name];\n\t\t}\n\t\treturn parse();\n\t}) as CookieFn;\n}\n\n/**\n * Create a no-op header accessor (for minimal endpoints that don't use headers).\n */\nexport function createNoopHeaders(): HeaderFn {\n\treturn ((key?: string) => {\n\t\tif (key !== undefined) return undefined;\n\t\treturn {};\n\t}) as HeaderFn;\n}\n\n/**\n * Create a no-op cookie accessor (for minimal endpoints that don't use cookies).\n */\nexport function createNoopCookies(): CookieFn {\n\treturn ((name?: string) => {\n\t\tif (name !== undefined) return undefined;\n\t\treturn {};\n\t}) as CookieFn;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,IAAa,WAAb,MAAa,iBAkBH,SAqBR;CACD;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA,AAAgB;;;;;;CAMhB,AAAgB;;CAEhB,AAAgB,iBAAyC,CAAE;;CAE3D,AAAO,aAAiE,OACtE,CAAE;;CAEJ,AAAO,YAMH,MAAM;;CAEV,AAAO;;CAEP,AAAO;;CAEP,AAAO;;CAEP,AAAO,SAAiD,CAAE;;CAI1D,AAAO;;CAEP,AAAO;;CAEP,AAAQ;;;;;;;;;;;;;;;;;;;CA6BR,aAAa,mBACZA,WACAC,SACC;AACD,SAAO,mBAAmB,WAAW,QAAQ;CAC7C;;;;;CAMD,IAAI,WAAW;AACd,UAAQ,EAAE,KAAK,OAAO,GAAG,KAAK,MAAM;CACpC;;;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,SAAO,CAAE;CACT;AACD"}
|
package/dist/monitors/index.cjs
CHANGED
|
@@ -14,11 +14,16 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
function heartbeat(options = {}) {
|
|
17
|
-
const { env = "HEARTBEAT_URL", start, success = (url) => url, failure, timeout = 3e3 } = options;
|
|
17
|
+
const { env = "HEARTBEAT_URL", start, success = (url) => url, failure, timeout = 3e3, provider } = options;
|
|
18
18
|
return {
|
|
19
19
|
serviceName: `heartbeat:${env}`,
|
|
20
|
+
monitor: {
|
|
21
|
+
type: "heartbeat",
|
|
22
|
+
...provider ? { provider } : {},
|
|
23
|
+
env
|
|
24
|
+
},
|
|
20
25
|
async register({ envParser }) {
|
|
21
|
-
const { url } = envParser.create((get) => ({ url: get(env).string()
|
|
26
|
+
const { url } = envParser.create((get) => ({ url: get(env).string() })).parse();
|
|
22
27
|
const ping = async (target) => {
|
|
23
28
|
if (!url || !target) return;
|
|
24
29
|
const response = await fetch(target(url), { signal: AbortSignal.timeout(timeout) });
|
|
@@ -35,11 +40,13 @@ function heartbeat(options = {}) {
|
|
|
35
40
|
/** Better Stack heartbeats: `{url}` on success, `{url}/fail` on failure. */
|
|
36
41
|
heartbeat.betterStack = (env) => heartbeat({
|
|
37
42
|
env,
|
|
43
|
+
provider: "betterStack",
|
|
38
44
|
failure: (url) => `${url}/fail`
|
|
39
45
|
});
|
|
40
46
|
/** Healthchecks.io: `{url}/start`, `{url}` and `{url}/fail`. */
|
|
41
47
|
heartbeat.healthchecks = (env) => heartbeat({
|
|
42
48
|
env,
|
|
49
|
+
provider: "healthchecks",
|
|
43
50
|
start: (url) => `${url}/start`,
|
|
44
51
|
failure: (url) => `${url}/fail`
|
|
45
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["options: HeartbeatOptions","target?: (url: string) => string","env?: string"],"sources":["../../src/monitors/heartbeat.ts"],"sourcesContent":["import type { Service } from '@geekmidas/services';\nimport type { ConstructMonitor } from '../monitor';\n\nexport interface HeartbeatOptions {\n\t/**\n\t * The environment variable holding the heartbeat URL.
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["options: HeartbeatOptions","target?: (url: string) => string","env?: string"],"sources":["../../src/monitors/heartbeat.ts"],"sourcesContent":["import type { Service } from '@geekmidas/services';\nimport type { ConstructMonitor, MonitorInfo } from '../monitor';\n\nexport interface HeartbeatOptions {\n\t/**\n\t * The environment variable holding the heartbeat URL. Required: the manifest\n\t * lists it so infrastructure sets it wherever the construct is deployed. If\n\t * it is missing at runtime the monitor is skipped with a warning, and the\n\t * run goes on.\n\t * @default 'HEARTBEAT_URL'\n\t */\n\tenv?: string;\n\t/** The URL to request when a run starts. Omit for providers without one. */\n\tstart?: (url: string) => string;\n\t/** The URL to request when a run succeeds. @default the URL itself */\n\tsuccess?: (url: string) => string;\n\t/**\n\t * The URL to request when a run fails. Omit to send nothing, and let the\n\t * provider alert on the missed success ping instead.\n\t */\n\tfailure?: (url: string) => string;\n\t/** Milliseconds to wait for the provider. @default 3000 */\n\ttimeout?: number;\n\t/**\n\t * The service the URL belongs to, recorded in the manifest so infrastructure\n\t * knows which kind of heartbeat to create. Set by the presets.\n\t */\n\tprovider?: string;\n}\n\n/**\n * A monitor that pings a URL when a run succeeds, and optionally when it\n * starts or fails — the shape most heartbeat and cron-monitoring services\n * share.\n *\n * @example\n * ```typescript\n * cron\n * .schedule('rate(1 day)')\n * .monitor(heartbeat.betterStack())\n * .handle(async () => {});\n * ```\n */\nexport function heartbeat(\n\toptions: HeartbeatOptions = {},\n): Service<`heartbeat:${string}`, ConstructMonitor> & { monitor: MonitorInfo } {\n\tconst {\n\t\tenv = 'HEARTBEAT_URL',\n\t\tstart,\n\t\tsuccess = (url) => url,\n\t\tfailure,\n\t\ttimeout = 3000,\n\t\tprovider,\n\t} = options;\n\n\treturn {\n\t\tserviceName: `heartbeat:${env}`,\n\t\tmonitor: { type: 'heartbeat', ...(provider ? { provider } : {}), env },\n\t\tasync register({ envParser }) {\n\t\t\tconst { url } = envParser\n\t\t\t\t.create((get) => ({ url: get(env).string() }))\n\t\t\t\t.parse();\n\n\t\t\tconst ping = async (target?: (url: string) => string) => {\n\t\t\t\tif (!url || !target) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst response = await fetch(target(url), {\n\t\t\t\t\tsignal: AbortSignal.timeout(timeout),\n\t\t\t\t});\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(`Heartbeat responded with ${response.status}`);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tstart: () => ping(start),\n\t\t\t\tsuccess: () => ping(success),\n\t\t\t\tfailure: () => ping(failure),\n\t\t\t};\n\t\t},\n\t};\n}\n\n/** Better Stack heartbeats: `{url}` on success, `{url}/fail` on failure. */\nheartbeat.betterStack = (env?: string) =>\n\theartbeat({ env, provider: 'betterStack', failure: (url) => `${url}/fail` });\n\n/** Healthchecks.io: `{url}/start`, `{url}` and `{url}/fail`. */\nheartbeat.healthchecks = (env?: string) =>\n\theartbeat({\n\t\tenv,\n\t\tprovider: 'healthchecks',\n\t\tstart: (url) => `${url}/start`,\n\t\tfailure: (url) => `${url}/fail`,\n\t});\n"],"mappings":";;;;;;;;;;;;;;;AA2CA,SAAgB,UACfA,UAA4B,CAAE,GACgD;CAC9E,MAAM,EACL,MAAM,iBACN,OACA,UAAU,CAAC,QAAQ,KACnB,SACA,UAAU,KACV,UACA,GAAG;AAEJ,QAAO;EACN,cAAc,YAAY,IAAI;EAC9B,SAAS;GAAE,MAAM;GAAa,GAAI,WAAW,EAAE,SAAU,IAAG,CAAE;GAAG;EAAK;EACtE,MAAM,SAAS,EAAE,WAAW,EAAE;GAC7B,MAAM,EAAE,KAAK,GAAG,UACd,OAAO,CAAC,SAAS,EAAE,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAE,GAAE,CAC7C,OAAO;GAET,MAAM,OAAO,OAAOC,WAAqC;AACxD,SAAK,QAAQ,OACZ;IAED,MAAM,WAAW,MAAM,MAAM,OAAO,IAAI,EAAE,EACzC,QAAQ,YAAY,QAAQ,QAAQ,CACpC,EAAC;AACF,SAAK,SAAS,GACb,OAAM,IAAI,OAAO,2BAA2B,SAAS,OAAO;GAE7D;AAED,UAAO;IACN,OAAO,MAAM,KAAK,MAAM;IACxB,SAAS,MAAM,KAAK,QAAQ;IAC5B,SAAS,MAAM,KAAK,QAAQ;GAC5B;EACD;CACD;AACD;;AAGD,UAAU,cAAc,CAACC,QACxB,UAAU;CAAE;CAAK,UAAU;CAAe,SAAS,CAAC,SAAS,EAAE,IAAI;AAAQ,EAAC;;AAG7E,UAAU,eAAe,CAACA,QACzB,UAAU;CACT;CACA,UAAU;CACV,OAAO,CAAC,SAAS,EAAE,IAAI;CACvB,SAAS,CAAC,SAAS,EAAE,IAAI;AACzB,EAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { ConstructMonitor, MonitorContext, MonitorService } from "../Construct-
|
|
1
|
+
import { ConstructMonitor, MonitorContext, MonitorInfo, MonitorService } from "../Construct-D_3yZ9m5.cjs";
|
|
2
2
|
import { Service } from "@geekmidas/services";
|
|
3
3
|
|
|
4
4
|
//#region src/monitors/heartbeat.d.ts
|
|
5
5
|
interface HeartbeatOptions {
|
|
6
6
|
/**
|
|
7
|
-
* The environment variable holding the heartbeat URL.
|
|
8
|
-
*
|
|
7
|
+
* The environment variable holding the heartbeat URL. Required: the manifest
|
|
8
|
+
* lists it so infrastructure sets it wherever the construct is deployed. If
|
|
9
|
+
* it is missing at runtime the monitor is skipped with a warning, and the
|
|
10
|
+
* run goes on.
|
|
9
11
|
* @default 'HEARTBEAT_URL'
|
|
10
12
|
*/
|
|
11
13
|
env?: string;
|
|
@@ -20,6 +22,11 @@ interface HeartbeatOptions {
|
|
|
20
22
|
failure?: (url: string) => string;
|
|
21
23
|
/** Milliseconds to wait for the provider. @default 3000 */
|
|
22
24
|
timeout?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The service the URL belongs to, recorded in the manifest so infrastructure
|
|
27
|
+
* knows which kind of heartbeat to create. Set by the presets.
|
|
28
|
+
*/
|
|
29
|
+
provider?: string;
|
|
23
30
|
}
|
|
24
31
|
/**
|
|
25
32
|
* A monitor that pings a URL when a run succeeds, and optionally when it
|
|
@@ -34,10 +41,16 @@ interface HeartbeatOptions {
|
|
|
34
41
|
* .handle(async () => {});
|
|
35
42
|
* ```
|
|
36
43
|
*/
|
|
37
|
-
declare function heartbeat(options?: HeartbeatOptions): Service<`heartbeat:${string}`, ConstructMonitor
|
|
44
|
+
declare function heartbeat(options?: HeartbeatOptions): Service<`heartbeat:${string}`, ConstructMonitor> & {
|
|
45
|
+
monitor: MonitorInfo;
|
|
46
|
+
};
|
|
38
47
|
declare namespace heartbeat {
|
|
39
|
-
var betterStack: (env?: string) => Service<`heartbeat:${string}`, ConstructMonitor<unknown
|
|
40
|
-
|
|
48
|
+
var betterStack: (env?: string) => Service<`heartbeat:${string}`, ConstructMonitor<unknown>> & {
|
|
49
|
+
monitor: MonitorInfo;
|
|
50
|
+
};
|
|
51
|
+
var healthchecks: (env?: string) => Service<`heartbeat:${string}`, ConstructMonitor<unknown>> & {
|
|
52
|
+
monitor: MonitorInfo;
|
|
53
|
+
};
|
|
41
54
|
}
|
|
42
55
|
//# sourceMappingURL=heartbeat.d.ts.map
|
|
43
56
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/monitors/heartbeat.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,gBAAA;;AAAjB;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/monitors/heartbeat.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,gBAAA;;AAAjB;AAwCA;;;;;EAEU,GAAuD,CAAA,EAAA,MAAA;EAAW;EAF5D,KAAA,CAAA,EAAA,CAAA,GAAS,EAAA,MAAA,EAAA,GAAA,MAAA;EAAA;EAAA,OA0CY,CAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,MAAA;EAAA;;;;EAIC,OA5C2B,CAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,MAAA;EAAW;;;;;;;;;;;;;;;;;;;;;iBAF5D,SAAA,WACN,mBACP,+BAA+B;WAA+B;;kBAFjD,SAAA;qCA0CqB,+BAAA;aAxC4B;;sCA4C3B,+BAAA;aA5C2B"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { ConstructMonitor, MonitorContext, MonitorService } from "../Construct-
|
|
1
|
+
import { ConstructMonitor, MonitorContext, MonitorInfo, MonitorService } from "../Construct-DsqpiAym.mjs";
|
|
2
2
|
import { Service } from "@geekmidas/services";
|
|
3
3
|
|
|
4
4
|
//#region src/monitors/heartbeat.d.ts
|
|
5
5
|
interface HeartbeatOptions {
|
|
6
6
|
/**
|
|
7
|
-
* The environment variable holding the heartbeat URL.
|
|
8
|
-
*
|
|
7
|
+
* The environment variable holding the heartbeat URL. Required: the manifest
|
|
8
|
+
* lists it so infrastructure sets it wherever the construct is deployed. If
|
|
9
|
+
* it is missing at runtime the monitor is skipped with a warning, and the
|
|
10
|
+
* run goes on.
|
|
9
11
|
* @default 'HEARTBEAT_URL'
|
|
10
12
|
*/
|
|
11
13
|
env?: string;
|
|
@@ -20,6 +22,11 @@ interface HeartbeatOptions {
|
|
|
20
22
|
failure?: (url: string) => string;
|
|
21
23
|
/** Milliseconds to wait for the provider. @default 3000 */
|
|
22
24
|
timeout?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The service the URL belongs to, recorded in the manifest so infrastructure
|
|
27
|
+
* knows which kind of heartbeat to create. Set by the presets.
|
|
28
|
+
*/
|
|
29
|
+
provider?: string;
|
|
23
30
|
}
|
|
24
31
|
/**
|
|
25
32
|
* A monitor that pings a URL when a run succeeds, and optionally when it
|
|
@@ -34,10 +41,12 @@ interface HeartbeatOptions {
|
|
|
34
41
|
* .handle(async () => {});
|
|
35
42
|
* ```
|
|
36
43
|
*/
|
|
37
|
-
declare function heartbeat(options?: HeartbeatOptions): Service<`heartbeat:${string}`, ConstructMonitor
|
|
44
|
+
declare function heartbeat(options?: HeartbeatOptions): Service<`heartbeat:${string}`, ConstructMonitor> & {
|
|
45
|
+
monitor: MonitorInfo;
|
|
46
|
+
};
|
|
38
47
|
declare namespace heartbeat {
|
|
39
|
-
var betterStack: (env?: string) =>
|
|
40
|
-
var healthchecks: (env?: string) =>
|
|
48
|
+
var betterStack: (env?: string) => any;
|
|
49
|
+
var healthchecks: (env?: string) => any;
|
|
41
50
|
}
|
|
42
51
|
//# sourceMappingURL=heartbeat.d.ts.map
|
|
43
52
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/monitors/heartbeat.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,gBAAA;;AAAjB;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/monitors/heartbeat.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,gBAAA;;AAAjB;AAwCA;;;;;EAEU,GAAuD,CAAA,EAAA,MAAA;EAAW;EAF5D,KAAA,CAAA,EAAA,CAAA,GAAS,EAAA,MAAA,EAAA,GAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAT,SAAA,WACN,mBACP,+BAA+B;WAA+B;;kBAFjD,SAAA"}
|
package/dist/monitors/index.mjs
CHANGED
|
@@ -13,11 +13,16 @@
|
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
15
|
function heartbeat(options = {}) {
|
|
16
|
-
const { env = "HEARTBEAT_URL", start, success = (url) => url, failure, timeout = 3e3 } = options;
|
|
16
|
+
const { env = "HEARTBEAT_URL", start, success = (url) => url, failure, timeout = 3e3, provider } = options;
|
|
17
17
|
return {
|
|
18
18
|
serviceName: `heartbeat:${env}`,
|
|
19
|
+
monitor: {
|
|
20
|
+
type: "heartbeat",
|
|
21
|
+
...provider ? { provider } : {},
|
|
22
|
+
env
|
|
23
|
+
},
|
|
19
24
|
async register({ envParser }) {
|
|
20
|
-
const { url } = envParser.create((get) => ({ url: get(env).string()
|
|
25
|
+
const { url } = envParser.create((get) => ({ url: get(env).string() })).parse();
|
|
21
26
|
const ping = async (target) => {
|
|
22
27
|
if (!url || !target) return;
|
|
23
28
|
const response = await fetch(target(url), { signal: AbortSignal.timeout(timeout) });
|
|
@@ -34,11 +39,13 @@ function heartbeat(options = {}) {
|
|
|
34
39
|
/** Better Stack heartbeats: `{url}` on success, `{url}/fail` on failure. */
|
|
35
40
|
heartbeat.betterStack = (env) => heartbeat({
|
|
36
41
|
env,
|
|
42
|
+
provider: "betterStack",
|
|
37
43
|
failure: (url) => `${url}/fail`
|
|
38
44
|
});
|
|
39
45
|
/** Healthchecks.io: `{url}/start`, `{url}` and `{url}/fail`. */
|
|
40
46
|
heartbeat.healthchecks = (env) => heartbeat({
|
|
41
47
|
env,
|
|
48
|
+
provider: "healthchecks",
|
|
42
49
|
start: (url) => `${url}/start`,
|
|
43
50
|
failure: (url) => `${url}/fail`
|
|
44
51
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["options: HeartbeatOptions","target?: (url: string) => string","env?: string"],"sources":["../../src/monitors/heartbeat.ts"],"sourcesContent":["import type { Service } from '@geekmidas/services';\nimport type { ConstructMonitor } from '../monitor';\n\nexport interface HeartbeatOptions {\n\t/**\n\t * The environment variable holding the heartbeat URL.
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["options: HeartbeatOptions","target?: (url: string) => string","env?: string"],"sources":["../../src/monitors/heartbeat.ts"],"sourcesContent":["import type { Service } from '@geekmidas/services';\nimport type { ConstructMonitor, MonitorInfo } from '../monitor';\n\nexport interface HeartbeatOptions {\n\t/**\n\t * The environment variable holding the heartbeat URL. Required: the manifest\n\t * lists it so infrastructure sets it wherever the construct is deployed. If\n\t * it is missing at runtime the monitor is skipped with a warning, and the\n\t * run goes on.\n\t * @default 'HEARTBEAT_URL'\n\t */\n\tenv?: string;\n\t/** The URL to request when a run starts. Omit for providers without one. */\n\tstart?: (url: string) => string;\n\t/** The URL to request when a run succeeds. @default the URL itself */\n\tsuccess?: (url: string) => string;\n\t/**\n\t * The URL to request when a run fails. Omit to send nothing, and let the\n\t * provider alert on the missed success ping instead.\n\t */\n\tfailure?: (url: string) => string;\n\t/** Milliseconds to wait for the provider. @default 3000 */\n\ttimeout?: number;\n\t/**\n\t * The service the URL belongs to, recorded in the manifest so infrastructure\n\t * knows which kind of heartbeat to create. Set by the presets.\n\t */\n\tprovider?: string;\n}\n\n/**\n * A monitor that pings a URL when a run succeeds, and optionally when it\n * starts or fails — the shape most heartbeat and cron-monitoring services\n * share.\n *\n * @example\n * ```typescript\n * cron\n * .schedule('rate(1 day)')\n * .monitor(heartbeat.betterStack())\n * .handle(async () => {});\n * ```\n */\nexport function heartbeat(\n\toptions: HeartbeatOptions = {},\n): Service<`heartbeat:${string}`, ConstructMonitor> & { monitor: MonitorInfo } {\n\tconst {\n\t\tenv = 'HEARTBEAT_URL',\n\t\tstart,\n\t\tsuccess = (url) => url,\n\t\tfailure,\n\t\ttimeout = 3000,\n\t\tprovider,\n\t} = options;\n\n\treturn {\n\t\tserviceName: `heartbeat:${env}`,\n\t\tmonitor: { type: 'heartbeat', ...(provider ? { provider } : {}), env },\n\t\tasync register({ envParser }) {\n\t\t\tconst { url } = envParser\n\t\t\t\t.create((get) => ({ url: get(env).string() }))\n\t\t\t\t.parse();\n\n\t\t\tconst ping = async (target?: (url: string) => string) => {\n\t\t\t\tif (!url || !target) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst response = await fetch(target(url), {\n\t\t\t\t\tsignal: AbortSignal.timeout(timeout),\n\t\t\t\t});\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(`Heartbeat responded with ${response.status}`);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tstart: () => ping(start),\n\t\t\t\tsuccess: () => ping(success),\n\t\t\t\tfailure: () => ping(failure),\n\t\t\t};\n\t\t},\n\t};\n}\n\n/** Better Stack heartbeats: `{url}` on success, `{url}/fail` on failure. */\nheartbeat.betterStack = (env?: string) =>\n\theartbeat({ env, provider: 'betterStack', failure: (url) => `${url}/fail` });\n\n/** Healthchecks.io: `{url}/start`, `{url}` and `{url}/fail`. */\nheartbeat.healthchecks = (env?: string) =>\n\theartbeat({\n\t\tenv,\n\t\tprovider: 'healthchecks',\n\t\tstart: (url) => `${url}/start`,\n\t\tfailure: (url) => `${url}/fail`,\n\t});\n"],"mappings":";;;;;;;;;;;;;;AA2CA,SAAgB,UACfA,UAA4B,CAAE,GACgD;CAC9E,MAAM,EACL,MAAM,iBACN,OACA,UAAU,CAAC,QAAQ,KACnB,SACA,UAAU,KACV,UACA,GAAG;AAEJ,QAAO;EACN,cAAc,YAAY,IAAI;EAC9B,SAAS;GAAE,MAAM;GAAa,GAAI,WAAW,EAAE,SAAU,IAAG,CAAE;GAAG;EAAK;EACtE,MAAM,SAAS,EAAE,WAAW,EAAE;GAC7B,MAAM,EAAE,KAAK,GAAG,UACd,OAAO,CAAC,SAAS,EAAE,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAE,GAAE,CAC7C,OAAO;GAET,MAAM,OAAO,OAAOC,WAAqC;AACxD,SAAK,QAAQ,OACZ;IAED,MAAM,WAAW,MAAM,MAAM,OAAO,IAAI,EAAE,EACzC,QAAQ,YAAY,QAAQ,QAAQ,CACpC,EAAC;AACF,SAAK,SAAS,GACb,OAAM,IAAI,OAAO,2BAA2B,SAAS,OAAO;GAE7D;AAED,UAAO;IACN,OAAO,MAAM,KAAK,MAAM;IACxB,SAAS,MAAM,KAAK,QAAQ;IAC5B,SAAS,MAAM,KAAK,QAAQ;GAC5B;EACD;CACD;AACD;;AAGD,UAAU,cAAc,CAACC,QACxB,UAAU;CAAE;CAAK,UAAU;CAAe,SAAS,CAAC,SAAS,EAAE,IAAI;AAAQ,EAAC;;AAG7E,UAAU,eAAe,CAACA,QACzB,UAAU;CACT;CACA,UAAU;CACV,OAAO,CAAC,SAAS,EAAE,IAAI;CACvB,SAAS,CAAC,SAAS,EAAE,IAAI;AACzB,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_Construct = require('./Construct-
|
|
1
|
+
const require_Construct = require('./Construct-D09WUUOf.cjs');
|
|
2
2
|
const __geekmidas_audit = require_Construct.__toESM(require("@geekmidas/audit"));
|
|
3
3
|
|
|
4
4
|
//#region src/endpoints/processAudits.ts
|
|
@@ -89,4 +89,4 @@ Object.defineProperty(exports, 'executeWithAuditTransaction', {
|
|
|
89
89
|
return executeWithAuditTransaction;
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
|
-
//# sourceMappingURL=processAudits-
|
|
92
|
+
//# sourceMappingURL=processAudits-94Ar_EJF.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processAudits-BJZT5gmy.cjs","names":["endpoint: Endpoint<\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tany,\n\t\tany,\n\t\tTAuditStorage,\n\t\tTAuditStorageServiceName,\n\t\tTAuditAction,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t>","serviceDiscovery: ServiceDiscovery<any>","logger: TLogger","ctx: {\n\t\tsession: TSession;\n\t\theader: HeaderFn;\n\t\tcookie: CookieFn;\n\t\tservices: Record<string, unknown>;\n\t}","actor: AuditActor","DefaultAuditor","auditContext: AuditExecutionContext<TAuditAction> | undefined","handler: (auditor?: Auditor<TAuditAction>) => Promise<T>","onComplete?: (response: T, auditor: Auditor<TAuditAction>) => Promise<void>","options?: ExecuteWithAuditTransactionOptions","response"],"sources":["../src/endpoints/processAudits.ts"],"sourcesContent":["import type {\n\tAuditActor,\n\tAuditableAction,\n\tAuditor,\n\tAuditStorage,\n} from '@geekmidas/audit';\nimport { DefaultAuditor } from '@geekmidas/audit';\nimport type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceDiscovery } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { ActorExtractor, MappedAudit } from './audit';\nimport type { CookieFn, Endpoint, HeaderFn } from './Endpoint';\n\n/**\n * Process declarative audit definitions after successful endpoint execution.\n * Similar to publishConstructEvents for events.\n *\n * @param endpoint - The endpoint with audit configuration\n * @param response - The handler response to generate audit payloads from\n * @param serviceDiscovery - Service discovery for registering audit storage\n * @param logger - Logger for debug/error messages\n * @param ctx - Request context (session, headers, cookies, services)\n * @param existingAuditor - Optional existing auditor instance (e.g., from handler context).\n * If provided, uses this auditor (with its stored transaction).\n * If not provided, creates a new auditor.\n */\nexport async function processEndpointAudits<\n\tTServices extends Service[] = [],\n\tTSession = unknown,\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\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\tendpoint: Endpoint<\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tOutSchema,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tany,\n\t\tany,\n\t\tTAuditStorage,\n\t\tTAuditStorageServiceName,\n\t\tTAuditAction\n\t>,\n\tresponse: InferStandardSchema<OutSchema>,\n\tserviceDiscovery: ServiceDiscovery<any>,\n\tlogger: TLogger,\n\tctx: {\n\t\tsession: TSession;\n\t\theader: HeaderFn;\n\t\tcookie: CookieFn;\n\t\tservices: Record<string, unknown>;\n\t},\n\texistingAuditor?: Auditor<TAuditAction>,\n): Promise<void> {\n\ttry {\n\t\tconst audits = endpoint.audits as MappedAudit<TAuditAction, OutSchema>[];\n\n\t\t// If we have an existing auditor (from handler context), we need to flush\n\t\t// any manual audits it collected, even if there are no declarative audits\n\t\tconst hasExistingRecords =\n\t\t\texistingAuditor && existingAuditor.getRecords().length > 0;\n\n\t\t// Skip if no declarative audits and no existing records to flush\n\t\tif (!audits?.length && !hasExistingRecords) {\n\t\t\tlogger.debug('No audits to process');\n\t\t\treturn;\n\t\t}\n\n\t\t// If no auditor storage service and we have things to process, warn\n\t\tif (!endpoint.auditorStorageService) {\n\t\t\tif (hasExistingRecords || audits?.length) {\n\t\t\t\tlogger.warn('No auditor storage service available');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Get or create auditor\n\t\tlet auditor: Auditor<TAuditAction>;\n\n\t\tif (existingAuditor) {\n\t\t\t// Use existing auditor (preserves stored transaction and manual audits)\n\t\t\tauditor = existingAuditor;\n\t\t\tlogger.debug('Using existing auditor from handler context');\n\t\t} else {\n\t\t\t// Create new auditor (backward compatibility)\n\t\t\tconst services = await serviceDiscovery.register([\n\t\t\t\tendpoint.auditorStorageService,\n\t\t\t]);\n\t\t\tconst storage = services[\n\t\t\t\tendpoint.auditorStorageService.serviceName\n\t\t\t] as AuditStorage;\n\n\t\t\t// Extract actor if configured\n\t\t\tlet actor: AuditActor = { id: 'system', type: 'system' };\n\t\t\tif (endpoint.actorExtractor) {\n\t\t\t\ttry {\n\t\t\t\t\tactor = await (\n\t\t\t\t\t\tendpoint.actorExtractor as ActorExtractor<\n\t\t\t\t\t\t\tTServices,\n\t\t\t\t\t\t\tTSession,\n\t\t\t\t\t\t\tTLogger\n\t\t\t\t\t\t>\n\t\t\t\t\t)({\n\t\t\t\t\t\tservices: ctx.services as any,\n\t\t\t\t\t\tsession: ctx.session,\n\t\t\t\t\t\theader: ctx.header,\n\t\t\t\t\t\tcookie: ctx.cookie,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error(error as Error, 'Failed to extract actor for audits');\n\t\t\t\t\t// Continue with system actor\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tauditor = new DefaultAuditor<TAuditAction>({\n\t\t\t\tactor,\n\t\t\t\tstorage,\n\t\t\t\tmetadata: {\n\t\t\t\t\tendpoint: endpoint.route,\n\t\t\t\t\tmethod: endpoint.method,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Process each declarative audit\n\t\tif (audits?.length) {\n\t\t\tfor (const audit of audits) {\n\t\t\t\tlogger.debug({ audit: audit.type }, 'Processing declarative audit');\n\n\t\t\t\t// Check when condition\n\t\t\t\tif (audit.when && !audit.when(response as any)) {\n\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t{ audit: audit.type },\n\t\t\t\t\t\t'Audit skipped due to when condition',\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Extract payload\n\t\t\t\tconst payload = audit.payload(response as any);\n\n\t\t\t\t// Extract entityId if configured\n\t\t\t\tconst entityId = audit.entityId?.(response as any);\n\n\t\t\t\t// Record the audit\n\t\t\t\tauditor.audit(audit.type as any, payload as any, {\n\t\t\t\t\ttable: audit.table,\n\t\t\t\t\tentityId,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Flush audits to storage\n\t\t// Note: If existingAuditor has a stored transaction (via setTransaction),\n\t\t// flush() will use it automatically\n\t\tconst recordCount = auditor.getRecords().length;\n\t\tif (recordCount > 0) {\n\t\t\t// Check if auditor has a stored transaction (for logging purposes)\n\t\t\tconst trx =\n\t\t\t\t'getTransaction' in auditor\n\t\t\t\t\t? (auditor as { getTransaction(): unknown }).getTransaction()\n\t\t\t\t\t: undefined;\n\t\t\tlogger.debug(\n\t\t\t\t{ auditCount: recordCount, hasTransaction: !!trx },\n\t\t\t\t'Flushing audits',\n\t\t\t);\n\t\t\tawait auditor.flush();\n\t\t}\n\t} catch (error) {\n\t\tlogger.error(error as Error, 'Failed to process audits');\n\t\t// Don't rethrow - audit failures shouldn't fail the request\n\t}\n}\n\n/**\n * Context for audit-aware handler execution.\n */\nexport interface AuditExecutionContext<\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n> {\n\t/** The auditor instance for recording audits */\n\tauditor: Auditor<TAuditAction>;\n\t/** The audit storage instance */\n\tstorage: AuditStorage;\n}\n\n/**\n * Create audit context for handler execution.\n * Returns the auditor and storage for use in the handler.\n *\n * @param endpoint - The endpoint with audit configuration\n * @param serviceDiscovery - Service discovery for getting audit storage\n * @param logger - Logger for debug/error messages\n * @param ctx - Request context for actor extraction\n * @returns Audit context with auditor and storage, or undefined if not configured\n */\nexport async function createAuditContext<\n\tTServices extends Service[] = [],\n\tTSession = unknown,\n\tTLogger extends Logger = Logger,\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\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n>(\n\tendpoint: Endpoint<\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tany,\n\t\tany,\n\t\tTAuditStorage,\n\t\tTAuditStorageServiceName,\n\t\tTAuditAction,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t>,\n\tserviceDiscovery: ServiceDiscovery<any>,\n\tlogger: TLogger,\n\tctx: {\n\t\tsession: TSession;\n\t\theader: HeaderFn;\n\t\tcookie: CookieFn;\n\t\tservices: Record<string, unknown>;\n\t},\n): Promise<AuditExecutionContext<TAuditAction> | undefined> {\n\tif (!endpoint.auditorStorageService) {\n\t\treturn undefined;\n\t}\n\n\tconst services = await serviceDiscovery.register([\n\t\tendpoint.auditorStorageService,\n\t]);\n\tconst storage = services[\n\t\tendpoint.auditorStorageService.serviceName\n\t] as AuditStorage;\n\n\t// Extract actor if configured\n\tlet actor: AuditActor = { id: 'system', type: 'system' };\n\tif (endpoint.actorExtractor) {\n\t\ttry {\n\t\t\tactor = await (\n\t\t\t\tendpoint.actorExtractor as ActorExtractor<TServices, TSession, TLogger>\n\t\t\t)({\n\t\t\t\tservices: ctx.services as any,\n\t\t\t\tsession: ctx.session,\n\t\t\t\theader: ctx.header,\n\t\t\t\tcookie: ctx.cookie,\n\t\t\t\tlogger,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlogger.error(error as Error, 'Failed to extract actor for audits');\n\t\t}\n\t}\n\n\tconst auditor = new DefaultAuditor<TAuditAction>({\n\t\tactor,\n\t\tstorage,\n\t\tmetadata: {\n\t\t\tendpoint: endpoint.route,\n\t\t\tmethod: endpoint.method,\n\t\t},\n\t});\n\n\treturn { auditor, storage };\n}\n\n/**\n * Options for executeWithAuditTransaction.\n */\nexport interface ExecuteWithAuditTransactionOptions {\n\t/**\n\t * Database connection to use for the transaction.\n\t * If this is already a transaction, it will be reused instead of creating a nested one.\n\t * If not provided, the storage's internal database is used.\n\t */\n\tdb?: unknown;\n}\n\n/**\n * Execute a handler with automatic audit transaction support.\n * If the audit storage provides a withTransaction method, wraps execution\n * in a transaction so audits are atomic with handler's database operations.\n *\n * This is database-agnostic - each storage implementation provides its own\n * transaction handling based on the underlying database (Kysely, Drizzle, etc.).\n *\n * If the db parameter is provided and is already a transaction, the storage\n * will reuse it instead of creating a nested transaction (similar to\n * packages/db/src/kysely.ts#withTransaction).\n *\n * @param auditContext - The audit context from createAuditContext\n * @param handler - The handler function to execute (receives auditor)\n * @param onComplete - Called after handler with response, to process declarative audits\n * @param options - Optional configuration including database connection\n * @returns The handler result\n */\nexport async function executeWithAuditTransaction<\n\tT,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n>(\n\tauditContext: AuditExecutionContext<TAuditAction> | undefined,\n\thandler: (auditor?: Auditor<TAuditAction>) => Promise<T>,\n\tonComplete?: (response: T, auditor: Auditor<TAuditAction>) => Promise<void>,\n\toptions?: ExecuteWithAuditTransactionOptions,\n): Promise<T> {\n\t// No audit context - just run handler\n\tif (!auditContext) {\n\t\treturn handler(undefined);\n\t}\n\n\tconst { auditor, storage } = auditContext;\n\n\t// Check if storage provides a transaction wrapper\n\tif (storage.withTransaction) {\n\t\t// Wrap in transaction - audits are atomic with handler operations\n\t\t// The storage's withTransaction handles setTransaction and flush\n\t\t// Pass db so existing transactions are reused\n\t\treturn storage.withTransaction(\n\t\t\tauditor,\n\t\t\tasync () => {\n\t\t\t\tconst response = await handler(auditor);\n\n\t\t\t\t// Process declarative audits within the transaction\n\t\t\t\tif (onComplete) {\n\t\t\t\t\tawait onComplete(response, auditor);\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t},\n\t\t\toptions?.db,\n\t\t);\n\t}\n\n\t// No transaction support - run handler and flush audits after\n\tconst response = await handler(auditor);\n\n\tif (onComplete) {\n\t\tawait onComplete(response, auditor);\n\t}\n\n\t// Flush audits (no transaction)\n\tawait auditor.flush();\n\n\treturn response;\n}\n"],"mappings":";;;;;;;;;;;;;;AAkNA,eAAsB,mBAarBA,UAgBAC,kBACAC,QACAC,KAM2D;AAC3D,MAAK,SAAS,sBACb;CAGD,MAAM,WAAW,MAAM,iBAAiB,SAAS,CAChD,SAAS,qBACT,EAAC;CACF,MAAM,UAAU,SACf,SAAS,sBAAsB;CAIhC,IAAIC,QAAoB;EAAE,IAAI;EAAU,MAAM;CAAU;AACxD,KAAI,SAAS,eACZ,KAAI;AACH,UAAQ,MAAM,AACb,SAAS,eACR;GACD,UAAU,IAAI;GACd,SAAS,IAAI;GACb,QAAQ,IAAI;GACZ,QAAQ,IAAI;GACZ;EACA,EAAC;CACF,SAAQ,OAAO;AACf,SAAO,MAAM,OAAgB,qCAAqC;CAClE;CAGF,MAAM,UAAU,IAAIC,iCAA6B;EAChD;EACA;EACA,UAAU;GACT,UAAU,SAAS;GACnB,QAAQ,SAAS;EACjB;CACD;AAED,QAAO;EAAE;EAAS;CAAS;AAC3B;;;;;;;;;;;;;;;;;;;AAgCD,eAAsB,4BAOrBC,cACAC,SACAC,YACAC,SACa;AAEb,MAAK,aACJ,QAAO,eAAkB;CAG1B,MAAM,EAAE,SAAS,SAAS,GAAG;AAG7B,KAAI,QAAQ,gBAIX,QAAO,QAAQ,gBACd,SACA,YAAY;EACX,MAAMC,aAAW,MAAM,QAAQ,QAAQ;AAGvC,MAAI,WACH,OAAM,WAAWA,YAAU,QAAQ;AAGpC,SAAOA;CACP,GACD,SAAS,GACT;CAIF,MAAM,WAAW,MAAM,QAAQ,QAAQ;AAEvC,KAAI,WACH,OAAM,WAAW,UAAU,QAAQ;AAIpC,OAAM,QAAQ,OAAO;AAErB,QAAO;AACP"}
|
|
1
|
+
{"version":3,"file":"processAudits-94Ar_EJF.cjs","names":["endpoint: Endpoint<\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tany,\n\t\tany,\n\t\tTAuditStorage,\n\t\tTAuditStorageServiceName,\n\t\tTAuditAction,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t>","serviceDiscovery: ServiceDiscovery<any>","logger: TLogger","ctx: {\n\t\tsession: TSession;\n\t\theader: HeaderFn;\n\t\tcookie: CookieFn;\n\t\tservices: Record<string, unknown>;\n\t}","actor: AuditActor","DefaultAuditor","auditContext: AuditExecutionContext<TAuditAction> | undefined","handler: (auditor?: Auditor<TAuditAction>) => Promise<T>","onComplete?: (response: T, auditor: Auditor<TAuditAction>) => Promise<void>","options?: ExecuteWithAuditTransactionOptions","response"],"sources":["../src/endpoints/processAudits.ts"],"sourcesContent":["import type {\n\tAuditActor,\n\tAuditableAction,\n\tAuditor,\n\tAuditStorage,\n} from '@geekmidas/audit';\nimport { DefaultAuditor } from '@geekmidas/audit';\nimport type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceDiscovery } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { ActorExtractor, MappedAudit } from './audit';\nimport type { CookieFn, Endpoint, HeaderFn } from './Endpoint';\n\n/**\n * Process declarative audit definitions after successful endpoint execution.\n * Similar to publishConstructEvents for events.\n *\n * @param endpoint - The endpoint with audit configuration\n * @param response - The handler response to generate audit payloads from\n * @param serviceDiscovery - Service discovery for registering audit storage\n * @param logger - Logger for debug/error messages\n * @param ctx - Request context (session, headers, cookies, services)\n * @param existingAuditor - Optional existing auditor instance (e.g., from handler context).\n * If provided, uses this auditor (with its stored transaction).\n * If not provided, creates a new auditor.\n */\nexport async function processEndpointAudits<\n\tTServices extends Service[] = [],\n\tTSession = unknown,\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\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\tendpoint: Endpoint<\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tOutSchema,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tany,\n\t\tany,\n\t\tTAuditStorage,\n\t\tTAuditStorageServiceName,\n\t\tTAuditAction\n\t>,\n\tresponse: InferStandardSchema<OutSchema>,\n\tserviceDiscovery: ServiceDiscovery<any>,\n\tlogger: TLogger,\n\tctx: {\n\t\tsession: TSession;\n\t\theader: HeaderFn;\n\t\tcookie: CookieFn;\n\t\tservices: Record<string, unknown>;\n\t},\n\texistingAuditor?: Auditor<TAuditAction>,\n): Promise<void> {\n\ttry {\n\t\tconst audits = endpoint.audits as MappedAudit<TAuditAction, OutSchema>[];\n\n\t\t// If we have an existing auditor (from handler context), we need to flush\n\t\t// any manual audits it collected, even if there are no declarative audits\n\t\tconst hasExistingRecords =\n\t\t\texistingAuditor && existingAuditor.getRecords().length > 0;\n\n\t\t// Skip if no declarative audits and no existing records to flush\n\t\tif (!audits?.length && !hasExistingRecords) {\n\t\t\tlogger.debug('No audits to process');\n\t\t\treturn;\n\t\t}\n\n\t\t// If no auditor storage service and we have things to process, warn\n\t\tif (!endpoint.auditorStorageService) {\n\t\t\tif (hasExistingRecords || audits?.length) {\n\t\t\t\tlogger.warn('No auditor storage service available');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Get or create auditor\n\t\tlet auditor: Auditor<TAuditAction>;\n\n\t\tif (existingAuditor) {\n\t\t\t// Use existing auditor (preserves stored transaction and manual audits)\n\t\t\tauditor = existingAuditor;\n\t\t\tlogger.debug('Using existing auditor from handler context');\n\t\t} else {\n\t\t\t// Create new auditor (backward compatibility)\n\t\t\tconst services = await serviceDiscovery.register([\n\t\t\t\tendpoint.auditorStorageService,\n\t\t\t]);\n\t\t\tconst storage = services[\n\t\t\t\tendpoint.auditorStorageService.serviceName\n\t\t\t] as AuditStorage;\n\n\t\t\t// Extract actor if configured\n\t\t\tlet actor: AuditActor = { id: 'system', type: 'system' };\n\t\t\tif (endpoint.actorExtractor) {\n\t\t\t\ttry {\n\t\t\t\t\tactor = await (\n\t\t\t\t\t\tendpoint.actorExtractor as ActorExtractor<\n\t\t\t\t\t\t\tTServices,\n\t\t\t\t\t\t\tTSession,\n\t\t\t\t\t\t\tTLogger\n\t\t\t\t\t\t>\n\t\t\t\t\t)({\n\t\t\t\t\t\tservices: ctx.services as any,\n\t\t\t\t\t\tsession: ctx.session,\n\t\t\t\t\t\theader: ctx.header,\n\t\t\t\t\t\tcookie: ctx.cookie,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error(error as Error, 'Failed to extract actor for audits');\n\t\t\t\t\t// Continue with system actor\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tauditor = new DefaultAuditor<TAuditAction>({\n\t\t\t\tactor,\n\t\t\t\tstorage,\n\t\t\t\tmetadata: {\n\t\t\t\t\tendpoint: endpoint.route,\n\t\t\t\t\tmethod: endpoint.method,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Process each declarative audit\n\t\tif (audits?.length) {\n\t\t\tfor (const audit of audits) {\n\t\t\t\tlogger.debug({ audit: audit.type }, 'Processing declarative audit');\n\n\t\t\t\t// Check when condition\n\t\t\t\tif (audit.when && !audit.when(response as any)) {\n\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t{ audit: audit.type },\n\t\t\t\t\t\t'Audit skipped due to when condition',\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Extract payload\n\t\t\t\tconst payload = audit.payload(response as any);\n\n\t\t\t\t// Extract entityId if configured\n\t\t\t\tconst entityId = audit.entityId?.(response as any);\n\n\t\t\t\t// Record the audit\n\t\t\t\tauditor.audit(audit.type as any, payload as any, {\n\t\t\t\t\ttable: audit.table,\n\t\t\t\t\tentityId,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Flush audits to storage\n\t\t// Note: If existingAuditor has a stored transaction (via setTransaction),\n\t\t// flush() will use it automatically\n\t\tconst recordCount = auditor.getRecords().length;\n\t\tif (recordCount > 0) {\n\t\t\t// Check if auditor has a stored transaction (for logging purposes)\n\t\t\tconst trx =\n\t\t\t\t'getTransaction' in auditor\n\t\t\t\t\t? (auditor as { getTransaction(): unknown }).getTransaction()\n\t\t\t\t\t: undefined;\n\t\t\tlogger.debug(\n\t\t\t\t{ auditCount: recordCount, hasTransaction: !!trx },\n\t\t\t\t'Flushing audits',\n\t\t\t);\n\t\t\tawait auditor.flush();\n\t\t}\n\t} catch (error) {\n\t\tlogger.error(error as Error, 'Failed to process audits');\n\t\t// Don't rethrow - audit failures shouldn't fail the request\n\t}\n}\n\n/**\n * Context for audit-aware handler execution.\n */\nexport interface AuditExecutionContext<\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n> {\n\t/** The auditor instance for recording audits */\n\tauditor: Auditor<TAuditAction>;\n\t/** The audit storage instance */\n\tstorage: AuditStorage;\n}\n\n/**\n * Create audit context for handler execution.\n * Returns the auditor and storage for use in the handler.\n *\n * @param endpoint - The endpoint with audit configuration\n * @param serviceDiscovery - Service discovery for getting audit storage\n * @param logger - Logger for debug/error messages\n * @param ctx - Request context for actor extraction\n * @returns Audit context with auditor and storage, or undefined if not configured\n */\nexport async function createAuditContext<\n\tTServices extends Service[] = [],\n\tTSession = unknown,\n\tTLogger extends Logger = Logger,\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\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n>(\n\tendpoint: Endpoint<\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tany,\n\t\tany,\n\t\tTAuditStorage,\n\t\tTAuditStorageServiceName,\n\t\tTAuditAction,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t>,\n\tserviceDiscovery: ServiceDiscovery<any>,\n\tlogger: TLogger,\n\tctx: {\n\t\tsession: TSession;\n\t\theader: HeaderFn;\n\t\tcookie: CookieFn;\n\t\tservices: Record<string, unknown>;\n\t},\n): Promise<AuditExecutionContext<TAuditAction> | undefined> {\n\tif (!endpoint.auditorStorageService) {\n\t\treturn undefined;\n\t}\n\n\tconst services = await serviceDiscovery.register([\n\t\tendpoint.auditorStorageService,\n\t]);\n\tconst storage = services[\n\t\tendpoint.auditorStorageService.serviceName\n\t] as AuditStorage;\n\n\t// Extract actor if configured\n\tlet actor: AuditActor = { id: 'system', type: 'system' };\n\tif (endpoint.actorExtractor) {\n\t\ttry {\n\t\t\tactor = await (\n\t\t\t\tendpoint.actorExtractor as ActorExtractor<TServices, TSession, TLogger>\n\t\t\t)({\n\t\t\t\tservices: ctx.services as any,\n\t\t\t\tsession: ctx.session,\n\t\t\t\theader: ctx.header,\n\t\t\t\tcookie: ctx.cookie,\n\t\t\t\tlogger,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlogger.error(error as Error, 'Failed to extract actor for audits');\n\t\t}\n\t}\n\n\tconst auditor = new DefaultAuditor<TAuditAction>({\n\t\tactor,\n\t\tstorage,\n\t\tmetadata: {\n\t\t\tendpoint: endpoint.route,\n\t\t\tmethod: endpoint.method,\n\t\t},\n\t});\n\n\treturn { auditor, storage };\n}\n\n/**\n * Options for executeWithAuditTransaction.\n */\nexport interface ExecuteWithAuditTransactionOptions {\n\t/**\n\t * Database connection to use for the transaction.\n\t * If this is already a transaction, it will be reused instead of creating a nested one.\n\t * If not provided, the storage's internal database is used.\n\t */\n\tdb?: unknown;\n}\n\n/**\n * Execute a handler with automatic audit transaction support.\n * If the audit storage provides a withTransaction method, wraps execution\n * in a transaction so audits are atomic with handler's database operations.\n *\n * This is database-agnostic - each storage implementation provides its own\n * transaction handling based on the underlying database (Kysely, Drizzle, etc.).\n *\n * If the db parameter is provided and is already a transaction, the storage\n * will reuse it instead of creating a nested transaction (similar to\n * packages/db/src/kysely.ts#withTransaction).\n *\n * @param auditContext - The audit context from createAuditContext\n * @param handler - The handler function to execute (receives auditor)\n * @param onComplete - Called after handler with response, to process declarative audits\n * @param options - Optional configuration including database connection\n * @returns The handler result\n */\nexport async function executeWithAuditTransaction<\n\tT,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n>(\n\tauditContext: AuditExecutionContext<TAuditAction> | undefined,\n\thandler: (auditor?: Auditor<TAuditAction>) => Promise<T>,\n\tonComplete?: (response: T, auditor: Auditor<TAuditAction>) => Promise<void>,\n\toptions?: ExecuteWithAuditTransactionOptions,\n): Promise<T> {\n\t// No audit context - just run handler\n\tif (!auditContext) {\n\t\treturn handler(undefined);\n\t}\n\n\tconst { auditor, storage } = auditContext;\n\n\t// Check if storage provides a transaction wrapper\n\tif (storage.withTransaction) {\n\t\t// Wrap in transaction - audits are atomic with handler operations\n\t\t// The storage's withTransaction handles setTransaction and flush\n\t\t// Pass db so existing transactions are reused\n\t\treturn storage.withTransaction(\n\t\t\tauditor,\n\t\t\tasync () => {\n\t\t\t\tconst response = await handler(auditor);\n\n\t\t\t\t// Process declarative audits within the transaction\n\t\t\t\tif (onComplete) {\n\t\t\t\t\tawait onComplete(response, auditor);\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t},\n\t\t\toptions?.db,\n\t\t);\n\t}\n\n\t// No transaction support - run handler and flush audits after\n\tconst response = await handler(auditor);\n\n\tif (onComplete) {\n\t\tawait onComplete(response, auditor);\n\t}\n\n\t// Flush audits (no transaction)\n\tawait auditor.flush();\n\n\treturn response;\n}\n"],"mappings":";;;;;;;;;;;;;;AAkNA,eAAsB,mBAarBA,UAgBAC,kBACAC,QACAC,KAM2D;AAC3D,MAAK,SAAS,sBACb;CAGD,MAAM,WAAW,MAAM,iBAAiB,SAAS,CAChD,SAAS,qBACT,EAAC;CACF,MAAM,UAAU,SACf,SAAS,sBAAsB;CAIhC,IAAIC,QAAoB;EAAE,IAAI;EAAU,MAAM;CAAU;AACxD,KAAI,SAAS,eACZ,KAAI;AACH,UAAQ,MAAM,AACb,SAAS,eACR;GACD,UAAU,IAAI;GACd,SAAS,IAAI;GACb,QAAQ,IAAI;GACZ,QAAQ,IAAI;GACZ;EACA,EAAC;CACF,SAAQ,OAAO;AACf,SAAO,MAAM,OAAgB,qCAAqC;CAClE;CAGF,MAAM,UAAU,IAAIC,iCAA6B;EAChD;EACA;EACA,UAAU;GACT,UAAU,SAAS;GACnB,QAAQ,SAAS;EACjB;CACD;AAED,QAAO;EAAE;EAAS;CAAS;AAC3B;;;;;;;;;;;;;;;;;;;AAgCD,eAAsB,4BAOrBC,cACAC,SACAC,YACAC,SACa;AAEb,MAAK,aACJ,QAAO,eAAkB;CAG1B,MAAM,EAAE,SAAS,SAAS,GAAG;AAG7B,KAAI,QAAQ,gBAIX,QAAO,QAAQ,gBACd,SACA,YAAY;EACX,MAAMC,aAAW,MAAM,QAAQ,QAAQ;AAGvC,MAAI,WACH,OAAM,WAAWA,YAAU,QAAQ;AAGpC,SAAOA;CACP,GACD,SAAS,GACT;CAIF,MAAM,WAAW,MAAM,QAAQ,QAAQ;AAEvC,KAAI,WACH,OAAM,WAAW,UAAU,QAAQ;AAIpC,OAAM,QAAQ,OAAO;AAErB,QAAO;AACP"}
|
package/dist/queue/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_Construct = require('../Construct-
|
|
1
|
+
const require_Construct = require('../Construct-D09WUUOf.cjs');
|
|
2
2
|
const require_clone = require('../clone-I_WIpiFf.cjs');
|
|
3
3
|
const __geekmidas_logger_console = require_Construct.__toESM(require("@geekmidas/logger/console"));
|
|
4
4
|
const __geekmidas_envkit = require_Construct.__toESM(require("@geekmidas/envkit"));
|
package/dist/queue/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-
|
|
3
|
-
import * as
|
|
1
|
+
import "../Construct-D_3yZ9m5.cjs";
|
|
2
|
+
import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-Brw--scg.cjs";
|
|
3
|
+
import * as _geekmidas_logger5 from "@geekmidas/logger";
|
|
4
4
|
import { Logger } from "@geekmidas/logger";
|
|
5
5
|
import { Service } from "@geekmidas/services";
|
|
6
6
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -37,7 +37,7 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
|
|
|
37
37
|
//# sourceMappingURL=QueueBuilder.d.ts.map
|
|
38
38
|
//#endregion
|
|
39
39
|
//#region src/queue/index.d.ts
|
|
40
|
-
declare const q: QueueBuilder<string, undefined, [],
|
|
40
|
+
declare const q: QueueBuilder<string, undefined, [], _geekmidas_logger5.Logger>;
|
|
41
41
|
//# sourceMappingURL=index.d.ts.map
|
|
42
42
|
|
|
43
43
|
//#endregion
|
package/dist/queue/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-
|
|
1
|
+
import "../Construct-DsqpiAym.mjs";
|
|
2
|
+
import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-D5z1bwFu.mjs";
|
|
3
3
|
import { Service } from "@geekmidas/services";
|
|
4
4
|
import { Logger as Logger$1 } from "@geekmidas/logger";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
package/dist/queue/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Construct, ConstructType } from "../Construct-
|
|
1
|
+
import { Construct, ConstructType } from "../Construct-D0uZvbr3.mjs";
|
|
2
2
|
import { cloneWith } from "../clone-pdXxc0t3.mjs";
|
|
3
3
|
import { ConsoleLogger, DEFAULT_LOGGER } from "@geekmidas/logger/console";
|
|
4
4
|
import { environmentCase } from "@geekmidas/envkit";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_Construct = require('../Construct-
|
|
1
|
+
const require_Construct = require('../Construct-D09WUUOf.cjs');
|
|
2
2
|
const require_clone = require('../clone-I_WIpiFf.cjs');
|
|
3
3
|
const __geekmidas_logger_console = require_Construct.__toESM(require("@geekmidas/logger/console"));
|
|
4
4
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Subscriber, SubscriberHandler } from "../Subscriber-
|
|
3
|
-
import { Topic, TopicEvents, TopicMessage } from "../Topic-
|
|
1
|
+
import "../Construct-D_3yZ9m5.cjs";
|
|
2
|
+
import { Subscriber, SubscriberHandler } from "../Subscriber-DvKSp0N4.cjs";
|
|
3
|
+
import { Topic, TopicEvents, TopicMessage } from "../Topic-BMfrIFdX.cjs";
|
|
4
4
|
import { EventPublisher, ExtractPublisherMessage } from "@geekmidas/events";
|
|
5
|
-
import * as
|
|
5
|
+
import * as _geekmidas_logger6 from "@geekmidas/logger";
|
|
6
6
|
import { Logger } from "@geekmidas/logger";
|
|
7
7
|
import { Service } from "@geekmidas/services";
|
|
8
8
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -40,7 +40,7 @@ declare class SubscriberBuilder<TServices extends Service[] = [], TLogger extend
|
|
|
40
40
|
//# sourceMappingURL=SubscriberBuilder.d.ts.map
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/subscribers/index.d.ts
|
|
43
|
-
declare const s: SubscriberBuilder<[],
|
|
43
|
+
declare const s: SubscriberBuilder<[], _geekmidas_logger6.Logger, undefined, undefined, string, []>;
|
|
44
44
|
//# sourceMappingURL=index.d.ts.map
|
|
45
45
|
|
|
46
46
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Subscriber, SubscriberHandler } from "../Subscriber-
|
|
3
|
-
import { Topic, TopicEvents, TopicMessage } from "../Topic-
|
|
1
|
+
import "../Construct-DsqpiAym.mjs";
|
|
2
|
+
import { Subscriber, SubscriberHandler } from "../Subscriber-CJ22tp8r.mjs";
|
|
3
|
+
import { Topic, TopicEvents, TopicMessage } from "../Topic-B-fxOsR2.mjs";
|
|
4
4
|
import { Service } from "@geekmidas/services";
|
|
5
5
|
import { EventPublisher, ExtractPublisherMessage } from "@geekmidas/events";
|
|
6
6
|
import { Logger as Logger$1 } from "@geekmidas/logger";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Construct, ConstructType } from "../Construct-
|
|
1
|
+
import { Construct, ConstructType } from "../Construct-D0uZvbr3.mjs";
|
|
2
2
|
import { cloneWith } from "../clone-pdXxc0t3.mjs";
|
|
3
3
|
import { ConsoleLogger, DEFAULT_LOGGER } from "@geekmidas/logger/console";
|
|
4
4
|
|
package/dist/topic/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_Construct = require('../Construct-
|
|
1
|
+
const require_Construct = require('../Construct-D09WUUOf.cjs');
|
|
2
2
|
const require_clone = require('../clone-I_WIpiFf.cjs');
|
|
3
3
|
const __geekmidas_logger_console = require_Construct.__toESM(require("@geekmidas/logger/console"));
|
|
4
4
|
const __geekmidas_envkit = require_Construct.__toESM(require("@geekmidas/envkit"));
|
package/dist/topic/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Topic, TopicEvents, TopicMessage } from "../Topic-
|
|
1
|
+
import "../Construct-D_3yZ9m5.cjs";
|
|
2
|
+
import { Topic, TopicEvents, TopicMessage } from "../Topic-BMfrIFdX.cjs";
|
|
3
3
|
import { Logger } from "@geekmidas/logger";
|
|
4
4
|
|
|
5
5
|
//#region src/topic/TopicBuilder.d.ts
|
package/dist/topic/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Topic, TopicEvents, TopicMessage } from "../Topic-
|
|
1
|
+
import "../Construct-DsqpiAym.mjs";
|
|
2
|
+
import { Topic, TopicEvents, TopicMessage } from "../Topic-B-fxOsR2.mjs";
|
|
3
3
|
import { Logger } from "@geekmidas/logger";
|
|
4
4
|
|
|
5
5
|
//#region src/topic/TopicBuilder.d.ts
|
package/dist/topic/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Construct, ConstructType } from "../Construct-
|
|
1
|
+
import { Construct, ConstructType } from "../Construct-D0uZvbr3.mjs";
|
|
2
2
|
import { cloneWith } from "../clone-pdXxc0t3.mjs";
|
|
3
3
|
import { ConsoleLogger, DEFAULT_LOGGER } from "@geekmidas/logger/console";
|
|
4
4
|
import { environmentCase } from "@geekmidas/envkit";
|