@karmaniverous/smoz
    Preparing search index...

    Function wrapHandler

    • Wrap a business handler with SMOZ runtime. *

      • HTTP event tokens receive the full Middy pipeline (validation, shaping, CORS, etc.)
      • Non‑HTTP tokens bypass Middy and call the business function directly.

      Type Parameters

      • GlobalParamsSchema extends ZodObject<
            Readonly<
                {
                    [k: string]: $ZodType<
                        unknown,
                        unknown,
                        $ZodTypeInternals<unknown, unknown>,
                    >;
                },
            >,
            $strip,
        >

        global params schema type

      • StageParamsSchema extends ZodObject<
            Readonly<
                {
                    [k: string]: $ZodType<
                        unknown,
                        unknown,
                        $ZodTypeInternals<unknown, unknown>,
                    >;
                },
            >,
            $strip,
        >

        stage params schema type

      • EventTypeMap extends {
            alb: ALBEvent;
            cloudfront: CloudFrontRequestEvent;
            "cloudwatch-logs": CloudWatchLogsEvent;
            "cognito-userpool": CognitoUserPoolTriggerEvent;
            dynamodb: DynamoDBStreamEvent;
            eventbridge: EventBridgeEvent<string, unknown>;
            firehose: FirehoseTransformationEvent;
            http: APIGatewayProxyEventV2;
            kinesis: KinesisStreamEvent;
            rest: APIGatewayProxyEvent;
            s3: S3Event;
            ses: SESEvent;
            sns: SNSEvent;
            sqs: SQSEvent;
            step: { Payload?: unknown; [key: string]: unknown };
        }

        event token → runtime type map

      • EventType extends string | number | symbol

        a key of EventTypeMap

      • EventSchema extends undefined | ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

        optional Zod schema for event (validated before handler)

      • ResponseSchema extends undefined | ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

        optional Zod schema for response (validated after handler)

      Parameters

      • functionConfig: {
            events?: (
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
                | {}
            )[];
            eventSchema?: EventSchema;
            eventType: EventType;
            fnEnvKeys?: readonly (
                keyof output<GlobalParamsSchema>
                | keyof output<StageParamsSchema>
            )[];
            functionName: string;
            logger?: ConsoleLogger;
            responseSchema?: ResponseSchema;
        } & (
            EventType extends "rest"
            | "http"
                ? {
                    basePath?: string;
                    contentType?: string;
                    httpContexts?: readonly HttpContext[];
                    method?:
                        | "options"
                        | "head"
                        | "trace"
                        | "get"
                        | "put"
                        | "post"
                        | "delete"
                        | "patch"
                        | `x-${string}`
                        | "$ref"
                        | "summary"
                        | "description"
                        | "servers"
                        | "parameters";
                }
                : {
                    basePath?: undefined;
                    contentType?: undefined;
                    httpContexts?: undefined;
                    method?: undefined;
                }
        ) & EnvAttached<GlobalParamsSchema, StageParamsSchema>

        per‑function configuration (branded with env nodes)

        • Optionalevents?: (
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
              | {}
          )[]

          Optional extra serverless events (e.g., SQS triggers).

        • OptionaleventSchema?: EventSchema

          Optional Zod schemas applied uniformly across all handlers.

        • eventType: EventType

          Compile-time token selecting the runtime event type (e.g., 'rest' | 'http' | 'sqs').

        • OptionalfnEnvKeys?: readonly (keyof output<GlobalParamsSchema> | keyof output<StageParamsSchema>)[]

          Optional; defaults to [] wherever consumed.

        • functionName: string

          Unique function name; used across serverless/OpenAPI outputs.

        • Optionallogger?: ConsoleLogger

          Optional logger; wrapper will default to console.

        • OptionalresponseSchema?: ResponseSchema
      • business: Handler<EventSchema, ResponseSchema, EventTypeMap[EventType]>

        the business handler implementation

      • Optionalopts: { httpConfig?: AppHttpConfig; httpEventTypeTokens?: readonly string[] }

        optional runtime overrides (e.g., widen HTTP tokens)

      Returns (
          event: unknown,
          context: Context,
      ) => Promise<
          ResponseSchema extends ZodType<
              unknown,
              unknown,
              $ZodTypeInternals<unknown, unknown>,
          >
              ? output<ResponseSchema<ResponseSchema>>
              : unknown,
      >

      a Lambda‑compatible handler function