import { z } from 'zod'; import { type Application, type User } from '../db-entries/index.js'; import { type ExceptionHookEvent, type DataHookEvent, type InteractionHookEvent } from '../foundations/index.js'; import { type InteractionEvent } from './interactions.js'; import { type userInfoSelectFields } from './user.js'; declare const hookExecutionStatsGuard: z.ZodObject<{ successCount: z.ZodNumber; requestCount: z.ZodNumber; }, "strip", z.ZodTypeAny, { successCount: number; requestCount: number; }, { successCount: number; requestCount: number; }>; export type HookExecutionStats = z.infer; export declare const hookResponseGuard: z.ZodObject<{ tenantId: z.ZodType; id: z.ZodType; name: z.ZodType; event: z.ZodType<"User.Created" | "User.Deleted" | "Role.Created" | "Role.Deleted" | "Scope.Created" | "Scope.Deleted" | "Organization.Created" | "Organization.Deleted" | "OrganizationRole.Created" | "OrganizationRole.Deleted" | "OrganizationScope.Created" | "OrganizationScope.Deleted" | "User.Data.Updated" | "Role.Data.Updated" | "Scope.Data.Updated" | "Organization.Data.Updated" | "OrganizationRole.Data.Updated" | "OrganizationScope.Data.Updated" | "User.SuspensionStatus.Updated" | "Role.Scopes.Updated" | "Organization.Membership.Updated" | "OrganizationRole.Scopes.Updated" | InteractionHookEvent | "Identifier.Lockout" | null, z.ZodTypeDef, "User.Created" | "User.Deleted" | "Role.Created" | "Role.Deleted" | "Scope.Created" | "Scope.Deleted" | "Organization.Created" | "Organization.Deleted" | "OrganizationRole.Created" | "OrganizationRole.Deleted" | "OrganizationScope.Created" | "OrganizationScope.Deleted" | "User.Data.Updated" | "Role.Data.Updated" | "Scope.Data.Updated" | "Organization.Data.Updated" | "OrganizationRole.Data.Updated" | "OrganizationScope.Data.Updated" | "User.SuspensionStatus.Updated" | "Role.Scopes.Updated" | "Organization.Membership.Updated" | "OrganizationRole.Scopes.Updated" | InteractionHookEvent | "Identifier.Lockout" | null>; events: z.ZodType<("User.Created" | "User.Deleted" | "Role.Created" | "Role.Deleted" | "Scope.Created" | "Scope.Deleted" | "Organization.Created" | "Organization.Deleted" | "OrganizationRole.Created" | "OrganizationRole.Deleted" | "OrganizationScope.Created" | "OrganizationScope.Deleted" | "User.Data.Updated" | "Role.Data.Updated" | "Scope.Data.Updated" | "Organization.Data.Updated" | "OrganizationRole.Data.Updated" | "OrganizationScope.Data.Updated" | "User.SuspensionStatus.Updated" | "Role.Scopes.Updated" | "Organization.Membership.Updated" | "OrganizationRole.Scopes.Updated" | InteractionHookEvent | "Identifier.Lockout")[], z.ZodTypeDef, ("User.Created" | "User.Deleted" | "Role.Created" | "Role.Deleted" | "Scope.Created" | "Scope.Deleted" | "Organization.Created" | "Organization.Deleted" | "OrganizationRole.Created" | "OrganizationRole.Deleted" | "OrganizationScope.Created" | "OrganizationScope.Deleted" | "User.Data.Updated" | "Role.Data.Updated" | "Scope.Data.Updated" | "Organization.Data.Updated" | "OrganizationRole.Data.Updated" | "OrganizationScope.Data.Updated" | "User.SuspensionStatus.Updated" | "Role.Scopes.Updated" | "Organization.Membership.Updated" | "OrganizationRole.Scopes.Updated" | InteractionHookEvent | "Identifier.Lockout")[]>; config: z.ZodType<{ url: string; headers?: Record | undefined; retries?: number | undefined; }, z.ZodTypeDef, { url: string; headers?: Record | undefined; retries?: number | undefined; }>; signingKey: z.ZodType; enabled: z.ZodType; createdAt: z.ZodType; } & { executionStats: z.ZodObject<{ successCount: z.ZodNumber; requestCount: z.ZodNumber; }, "strip", z.ZodTypeAny, { successCount: number; requestCount: number; }, { successCount: number; requestCount: number; }>; }, "strip", z.ZodTypeAny, { name: string; id: string; tenantId: string; enabled: boolean; createdAt: number; config: import("../foundations/index.js").HookConfig; event: import("../foundations/index.js").HookEvent | null; events: import("../foundations/index.js").HookEvents; signingKey: string; executionStats: { successCount: number; requestCount: number; }; }, { name: string; id: string; tenantId: string; enabled: boolean; createdAt: number; config: import("../foundations/index.js").HookConfig; event: import("../foundations/index.js").HookEvent | null; events: import("../foundations/index.js").HookEvents; signingKey: string; executionStats: { successCount: number; requestCount: number; }; }>; export type HookResponse = z.infer; export declare const hookTestErrorResponseDataGuard: z.ZodObject<{ responseStatus: z.ZodNumber; responseBody: z.ZodString; }, "strip", z.ZodTypeAny, { responseStatus: number; responseBody: string; }, { responseStatus: number; responseBody: string; }>; export type HookTestErrorResponseData = z.infer; /** * The interaction API context for triggering InteractionHook and DataHook events. * In the `koaInteractionHooks` middleware, * we will store the context before processing the interaction and consume it after the interaction is processed if needed. */ export type InteractionApiMetadata = { /** The application ID if the hook is triggered by interaction API. */ applicationId?: string; /** The session ID if the hook is triggered by interaction API. */ sessionId?: string; /** The InteractionEvent if the hook is triggered by interaction API. */ interactionEvent: InteractionEvent; }; type InteractionApiContextPayload = { /** Fetch application detail by application ID before sending the hook event */ application?: Pick; sessionId?: string; interactionEvent?: InteractionEvent; }; export type InteractionHookEventPayload = { event: InteractionHookEvent; createdAt: string; hookId: string; userAgent?: string; userIp?: string; /** InteractionHook result */ userId?: string; /** Fetch user detail by user ID before sending the hook event */ user?: Pick; } & InteractionApiContextPayload & Record; /** * The API context for management API triggered data hooks. * In the `koaManagementApiHooks` middleware, * we will store the context of management API requests that triggers the DataHook events. * Can't put it in the DataHookMetadata because the matched API context is only available after the request is processed. */ export type ManagementApiContext = { /** Request route params. */ params?: Record; /** Request route path. */ path: string; /** Matched route used as the identifier to trigger the hook. */ matchedRoute?: string; /** Request method. */ method: string; /** Response status code. */ status: number; }; export type DataHookEventPayload = { event: DataHookEvent; createdAt: string; hookId: string; ip?: string; userAgent?: string; data?: unknown; } & Partial & Partial & Record; export type ExceptionHookEventPayload = Omit & { event: ExceptionHookEvent; }; export type HookEventPayload = InteractionHookEventPayload | DataHookEventPayload | ExceptionHookEventPayload; export {};