import { z } from "zod"; import { Operation } from "fast-json-patch"; import { AnyEventObject, AnyStateMachine, SnapshotFrom, StateMachine, StateValueFrom } from "xstate"; import { DurableObject } from "cloudflare:workers"; //#region src/schemas.d.ts declare const BotManagementSchema: z.ZodObject<{ corporateProxy: z.ZodBoolean; verifiedBot: z.ZodBoolean; jsDetection: z.ZodObject<{ passed: z.ZodBoolean; }, "strip", z.ZodTypeAny, { passed: boolean; }, { passed: boolean; }>; staticResource: z.ZodBoolean; detectionIds: z.ZodRecord; score: z.ZodNumber; }, "strip", z.ZodTypeAny, { corporateProxy: boolean; verifiedBot: boolean; jsDetection: { passed: boolean; }; staticResource: boolean; detectionIds: Record; score: number; }, { corporateProxy: boolean; verifiedBot: boolean; jsDetection: { passed: boolean; }; staticResource: boolean; detectionIds: Record; score: number; }>; declare const EnvironmentSchema: z.ZodObject<{ ACTOR_KIT_SECRET: z.ZodString; ACTOR_KIT_HOST: z.ZodString; }, "strip", z.ZodTypeAny, { ACTOR_KIT_SECRET: string; ACTOR_KIT_HOST: string; }, { ACTOR_KIT_SECRET: string; ACTOR_KIT_HOST: string; }>; declare const RequestInfoSchema: z.ZodObject<{ longitude: z.ZodString; latitude: z.ZodString; continent: z.ZodString; country: z.ZodString; city: z.ZodString; timezone: z.ZodString; postalCode: z.ZodString; region: z.ZodString; regionCode: z.ZodString; metroCode: z.ZodString; botManagement: z.ZodObject<{ corporateProxy: z.ZodBoolean; verifiedBot: z.ZodBoolean; jsDetection: z.ZodObject<{ passed: z.ZodBoolean; }, "strip", z.ZodTypeAny, { passed: boolean; }, { passed: boolean; }>; staticResource: z.ZodBoolean; detectionIds: z.ZodRecord; score: z.ZodNumber; }, "strip", z.ZodTypeAny, { corporateProxy: boolean; verifiedBot: boolean; jsDetection: { passed: boolean; }; staticResource: boolean; detectionIds: Record; score: number; }, { corporateProxy: boolean; verifiedBot: boolean; jsDetection: { passed: boolean; }; staticResource: boolean; detectionIds: Record; score: number; }>; }, "strip", z.ZodTypeAny, { longitude: string; latitude: string; continent: string; country: string; city: string; timezone: string; postalCode: string; region: string; regionCode: string; metroCode: string; botManagement: { corporateProxy: boolean; verifiedBot: boolean; jsDetection: { passed: boolean; }; staticResource: boolean; detectionIds: Record; score: number; }; }, { longitude: string; latitude: string; continent: string; country: string; city: string; timezone: string; postalCode: string; region: string; regionCode: string; metroCode: string; botManagement: { corporateProxy: boolean; verifiedBot: boolean; jsDetection: { passed: boolean; }; staticResource: boolean; detectionIds: Record; score: number; }; }>; declare const CallerSchema: z.ZodObject<{ id: z.ZodString; type: z.ZodEnum<["client", "system", "service"]>; }, "strip", z.ZodTypeAny, { type: "client" | "system" | "service"; id: string; }, { type: "client" | "system" | "service"; id: string; }>; declare const AnyEventSchema: z.ZodObject<{ type: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ type: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ type: z.ZodString; }, z.ZodTypeAny, "passthrough">>; declare const SystemEventSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{ type: z.ZodLiteral<"INITIALIZE">; caller: z.ZodObject<{ type: z.ZodLiteral<"system">; id: z.ZodString; }, "strip", z.ZodTypeAny, { type: "system"; id: string; }, { type: "system"; id: string; }>; }, "strip", z.ZodTypeAny, { type: "INITIALIZE"; caller: { type: "system"; id: string; }; }, { type: "INITIALIZE"; caller: { type: "system"; id: string; }; }>, z.ZodObject<{ type: z.ZodLiteral<"CONNECT">; caller: z.ZodObject<{ type: z.ZodLiteral<"system">; id: z.ZodString; }, "strip", z.ZodTypeAny, { type: "system"; id: string; }, { type: "system"; id: string; }>; connectingCaller: z.ZodObject<{ id: z.ZodString; type: z.ZodEnum<["client", "system", "service"]>; }, "strip", z.ZodTypeAny, { type: "client" | "system" | "service"; id: string; }, { type: "client" | "system" | "service"; id: string; }>; }, "strip", z.ZodTypeAny, { type: "CONNECT"; caller: { type: "system"; id: string; }; connectingCaller: { type: "client" | "system" | "service"; id: string; }; }, { type: "CONNECT"; caller: { type: "system"; id: string; }; connectingCaller: { type: "client" | "system" | "service"; id: string; }; }>, z.ZodObject<{ type: z.ZodLiteral<"DISCONNECT">; caller: z.ZodObject<{ type: z.ZodLiteral<"system">; id: z.ZodString; }, "strip", z.ZodTypeAny, { type: "system"; id: string; }, { type: "system"; id: string; }>; disconnectingCaller: z.ZodObject<{ id: z.ZodString; type: z.ZodEnum<["client", "system", "service"]>; }, "strip", z.ZodTypeAny, { type: "client" | "system" | "service"; id: string; }, { type: "client" | "system" | "service"; id: string; }>; }, "strip", z.ZodTypeAny, { type: "DISCONNECT"; caller: { type: "system"; id: string; }; disconnectingCaller: { type: "client" | "system" | "service"; id: string; }; }, { type: "DISCONNECT"; caller: { type: "system"; id: string; }; disconnectingCaller: { type: "client" | "system" | "service"; id: string; }; }>, z.ZodObject<{ type: z.ZodLiteral<"RESUME">; caller: z.ZodObject<{ type: z.ZodLiteral<"system">; id: z.ZodString; }, "strip", z.ZodTypeAny, { type: "system"; id: string; }, { type: "system"; id: string; }>; }, "strip", z.ZodTypeAny, { type: "RESUME"; caller: { type: "system"; id: string; }; }, { type: "RESUME"; caller: { type: "system"; id: string; }; }>, z.ZodObject<{ type: z.ZodLiteral<"MIGRATE">; caller: z.ZodObject<{ type: z.ZodLiteral<"system">; id: z.ZodString; }, "strip", z.ZodTypeAny, { type: "system"; id: string; }, { type: "system"; id: string; }>; operations: z.ZodArray; }, "strip", z.ZodTypeAny, { type: "MIGRATE"; caller: { type: "system"; id: string; }; operations: any[]; }, { type: "MIGRATE"; caller: { type: "system"; id: string; }; operations: any[]; }>]>; declare const EmittedEventSchema: z.ZodObject<{ operations: z.ZodEffects; path: z.ZodString; value: z.ZodOptional; from: z.ZodOptional; }, "strip", z.ZodTypeAny, { path: string; op: "add" | "remove" | "replace" | "move" | "copy" | "test" | "_get"; value?: unknown; from?: string | undefined; }, { path: string; op: "add" | "remove" | "replace" | "move" | "copy" | "test" | "_get"; value?: unknown; from?: string | undefined; }>, "many">, Operation[], { path: string; op: "add" | "remove" | "replace" | "move" | "copy" | "test" | "_get"; value?: unknown; from?: string | undefined; }[]>; checksum: z.ZodString; }, "strip", z.ZodTypeAny, { operations: Operation[]; checksum: string; }, { operations: { path: string; op: "add" | "remove" | "replace" | "move" | "copy" | "test" | "_get"; value?: unknown; from?: string | undefined; }[]; checksum: string; }>; declare const CallerIdTypeSchema: z.ZodEnum<["client", "service", "system"]>; declare const CallerStringSchema: z.ZodEffects; //#endregion //#region src/types.d.ts type ActorKitStorage = DurableObjectStorage; interface ActorKitEnv { ACTOR_KIT_SECRET: string; [key: string]: DurableObjectNamespace | unknown; } type EnvWithDurableObjects = ActorKitEnv; type AnyEvent = z.infer; interface ActorServerMethods { fetch(request: Request): Promise; spawn(props: { actorType: string; actorId: string; caller: Caller; input: Record; }): void; send(event: ClientEventFrom | ServiceEventFrom): void; getSnapshot(caller: Caller, options?: { waitForEvent?: ClientEventFrom; waitForState?: StateValueFrom; timeout?: number; errorOnWaitTimeout?: boolean; }): Promise<{ checksum: string; snapshot: CallerSnapshotFrom; }>; } type ActorServer = DurableObject & ActorServerMethods; type AnyActorServer = ActorServer; type Caller = z.infer; type RequestInfo = z.infer; type ActorKitInputProps = { id: string; caller: Caller; storage: ActorKitStorage; [key: string]: unknown; }; type CallerType = "client" | "system" | "service"; type EventObject = { type: string; }; type EventSchemaUnion = z.ZodDiscriminatedUnion<"type", [z.ZodObject, ...z.ZodObject[]]>; type EventSchemas = { client: EventSchemaUnion; service: EventSchemaUnion; }; type BaseActorKitContext = { public: TPublicProps; private: Record; }; type ActorKitStateMachine, TInput extends { id: string; caller: Caller; storage: ActorKitStorage; }, TContext extends BaseActorKitContext & { [key: string]: unknown; }> = StateMachine; type BaseActorKitInput = { id: string; caller: Caller; env: TEnv; storage: ActorKitStorage; }; type WithActorKitInput = TInputProps & BaseActorKitInput; type AnyActorKitStateMachine = ActorKitStateMachine; type AnyActorKitEvent = (WithActorKitEvent | WithActorKitEvent | ActorKitSystemEvent) & BaseActorKitEvent; type AnyActorKitInput = WithActorKitInput<{ [key: string]: unknown; }, ActorKitEnv> & { storage: ActorKitStorage; }; type AnyActorKitContext = { public: { [key: string]: unknown; }; private: Record; }; type BaseActorKitStateMachine = ActorKitStateMachine; type MachineServerOptions = { persisted?: boolean; }; type ExtraContext = { requestId: string; }; interface BaseActorKitEvent { caller: Caller; storage: ActorKitStorage; requestInfo?: RequestInfo; env: TEnv; } type ActorKitSystemEvent = z.infer; type WithActorKitEvent = T & BaseActorKitEvent & { caller: { type: C; }; }; type WithActorKitContext = TExtraProps & { public: TPublicProps; private: Record; }; type CallerSnapshotFrom = { public: SnapshotFrom extends { context: { public: infer P; }; } ? P : unknown; private: SnapshotFrom extends { context: { private: Partial>; }; } ? PR : unknown; value: SnapshotFrom extends { value: infer V; } ? V : unknown; }; type ClientEventFrom = T extends StateMachine ? TEvent extends WithActorKitEvent ? Omit> : never : never; type ServiceEventFrom = T extends StateMachine ? TEvent extends WithActorKitEvent ? Omit> : never : never; type ScreamingSnakeToKebab = S extends `${infer T}_${infer U}` ? `${Lowercase}-${ScreamingSnakeToKebab}` : Lowercase; type DurableObjectActor = ActorServer; type CamelToSnakeCase = S extends `${infer T}${infer U}` ? U extends Uncapitalize ? `${Lowercase}${CamelToSnakeCase}` : `${Lowercase}_${CamelToSnakeCase}` : S; type KebabToCamelCase = S extends `${infer T}-${infer U}` ? `${T}${Capitalize>}` : S; type KebabToScreamingSnake = Uppercase>>; interface MatchesProps { state: StateValueFrom; and?: StateValueFrom; or?: StateValueFrom; not?: boolean; initialValueOverride?: boolean; } type MachineFromServer = T extends ActorServer ? M : never; type ActorKitEmittedEvent = { operations: Operation[]; checksum: string; }; type ActorKitClient = { connect: () => Promise; disconnect: () => void; send: (event: ClientEventFrom) => void; getState: () => CallerSnapshotFrom; subscribe: (listener: (state: CallerSnapshotFrom) => void) => () => void; waitFor: (predicateFn: (state: CallerSnapshotFrom) => boolean, timeoutMs?: number) => Promise; }; type ExtractEventType = TMachine extends ActorKitStateMachine ? TEvent : never; type ExtractEnvType = TEvent extends { env: infer TEnv; } ? TEnv : never; type EnvFromMachine = ExtractEnvType> extends never ? ActorKitEnv : ExtractEnvType> & ActorKitEnv; //#endregion export { RequestInfo as A, CallerStringSchema as B, EnvWithDurableObjects as C, MachineFromServer as D, KebabToScreamingSnake as E, WithActorKitInput as F, EnvironmentSchema as H, AnyEventSchema as I, BotManagementSchema as L, ServiceEventFrom as M, WithActorKitContext as N, MachineServerOptions as O, WithActorKitEvent as P, CallerIdTypeSchema as R, EnvFromMachine as S, ExtraContext as T, RequestInfoSchema as U, EmittedEventSchema as V, SystemEventSchema as W, Caller as _, ActorKitStateMachine as a, ClientEventFrom as b, ActorServer as c, AnyActorServer as d, AnyEvent as f, BaseActorKitStateMachine as g, BaseActorKitInput as h, ActorKitInputProps as i, ScreamingSnakeToKebab as j, MatchesProps as k, ActorServerMethods as l, BaseActorKitEvent as m, ActorKitEmittedEvent as n, ActorKitStorage as o, BaseActorKitContext as p, ActorKitEnv as r, ActorKitSystemEvent as s, ActorKitClient as t, AnyActorKitStateMachine as u, CallerSnapshotFrom as v, EventSchemas as w, DurableObjectActor as x, CallerType as y, CallerSchema as z }; //# sourceMappingURL=types-C31KX9CW.d.mts.map