rivetkit 2.0.2 → 2.0.4
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/README.md +3 -5
- package/dist/schemas/actor-persist/v1.ts +225 -0
- package/dist/schemas/client-protocol/v1.ts +435 -0
- package/dist/schemas/file-system-driver/v1.ts +102 -0
- package/dist/tsup/actor/errors.cjs +77 -0
- package/dist/tsup/actor/errors.cjs.map +1 -0
- package/dist/tsup/actor/errors.d.cts +156 -0
- package/dist/tsup/actor/errors.d.ts +156 -0
- package/dist/tsup/actor/errors.js +77 -0
- package/dist/tsup/actor/errors.js.map +1 -0
- package/dist/tsup/chunk-3F2YSRJL.js +117 -0
- package/dist/tsup/chunk-3F2YSRJL.js.map +1 -0
- package/dist/tsup/chunk-4CXBCT26.cjs +250 -0
- package/dist/tsup/chunk-4CXBCT26.cjs.map +1 -0
- package/dist/tsup/chunk-4R73YDN3.cjs +20 -0
- package/dist/tsup/chunk-4R73YDN3.cjs.map +1 -0
- package/dist/tsup/chunk-6LJT3QRL.cjs +539 -0
- package/dist/tsup/chunk-6LJT3QRL.cjs.map +1 -0
- package/dist/tsup/chunk-GICQ3YCU.cjs +1792 -0
- package/dist/tsup/chunk-GICQ3YCU.cjs.map +1 -0
- package/dist/tsup/chunk-H26RP6GD.js +251 -0
- package/dist/tsup/chunk-H26RP6GD.js.map +1 -0
- package/dist/tsup/chunk-HI3HWJRC.js +20 -0
- package/dist/tsup/chunk-HI3HWJRC.js.map +1 -0
- package/dist/tsup/chunk-HLLF4B4Q.js +1792 -0
- package/dist/tsup/chunk-HLLF4B4Q.js.map +1 -0
- package/dist/tsup/chunk-IH6CKNDW.cjs +117 -0
- package/dist/tsup/chunk-IH6CKNDW.cjs.map +1 -0
- package/dist/tsup/chunk-LV2S3OU3.js +250 -0
- package/dist/tsup/chunk-LV2S3OU3.js.map +1 -0
- package/dist/tsup/chunk-LWNKVZG5.cjs +251 -0
- package/dist/tsup/chunk-LWNKVZG5.cjs.map +1 -0
- package/dist/tsup/chunk-NFU2BBT5.js +374 -0
- package/dist/tsup/chunk-NFU2BBT5.js.map +1 -0
- package/dist/tsup/chunk-PQY7KKTL.js +539 -0
- package/dist/tsup/chunk-PQY7KKTL.js.map +1 -0
- package/dist/tsup/chunk-QK72M5JB.js +45 -0
- package/dist/tsup/chunk-QK72M5JB.js.map +1 -0
- package/dist/tsup/chunk-QNNXFOQV.cjs +45 -0
- package/dist/tsup/chunk-QNNXFOQV.cjs.map +1 -0
- package/dist/tsup/chunk-SBHHJ6QS.cjs +374 -0
- package/dist/tsup/chunk-SBHHJ6QS.cjs.map +1 -0
- package/dist/tsup/chunk-TQ62L3X7.js +325 -0
- package/dist/tsup/chunk-TQ62L3X7.js.map +1 -0
- package/dist/tsup/chunk-VO7ZRVVD.cjs +6293 -0
- package/dist/tsup/chunk-VO7ZRVVD.cjs.map +1 -0
- package/dist/tsup/chunk-WHBPJNGW.cjs +325 -0
- package/dist/tsup/chunk-WHBPJNGW.cjs.map +1 -0
- package/dist/tsup/chunk-XJQHKJ4P.js +6293 -0
- package/dist/tsup/chunk-XJQHKJ4P.js.map +1 -0
- package/dist/tsup/client/mod.cjs +32 -0
- package/dist/tsup/client/mod.cjs.map +1 -0
- package/dist/tsup/client/mod.d.cts +20 -0
- package/dist/tsup/client/mod.d.ts +20 -0
- package/dist/tsup/client/mod.js +32 -0
- package/dist/tsup/client/mod.js.map +1 -0
- package/dist/tsup/common/log.cjs +21 -0
- package/dist/tsup/common/log.cjs.map +1 -0
- package/dist/tsup/common/log.d.cts +26 -0
- package/dist/tsup/common/log.d.ts +26 -0
- package/dist/tsup/common/log.js +21 -0
- package/dist/tsup/common/log.js.map +1 -0
- package/dist/tsup/common/websocket.cjs +10 -0
- package/dist/tsup/common/websocket.cjs.map +1 -0
- package/dist/tsup/common/websocket.d.cts +3 -0
- package/dist/tsup/common/websocket.d.ts +3 -0
- package/dist/tsup/common/websocket.js +10 -0
- package/dist/tsup/common/websocket.js.map +1 -0
- package/dist/tsup/common-CXCe7s6i.d.cts +218 -0
- package/dist/tsup/common-CXCe7s6i.d.ts +218 -0
- package/dist/tsup/connection-BI-6UIBJ.d.ts +2087 -0
- package/dist/tsup/connection-Dyd4NLGW.d.cts +2087 -0
- package/dist/tsup/driver-helpers/mod.cjs +30 -0
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -0
- package/dist/tsup/driver-helpers/mod.d.cts +17 -0
- package/dist/tsup/driver-helpers/mod.d.ts +17 -0
- package/dist/tsup/driver-helpers/mod.js +30 -0
- package/dist/tsup/driver-helpers/mod.js.map +1 -0
- package/dist/tsup/driver-test-suite/mod.cjs +3411 -0
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -0
- package/dist/tsup/driver-test-suite/mod.d.cts +63 -0
- package/dist/tsup/driver-test-suite/mod.d.ts +63 -0
- package/dist/tsup/driver-test-suite/mod.js +3411 -0
- package/dist/tsup/driver-test-suite/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +51 -0
- package/dist/tsup/inspector/mod.cjs.map +1 -0
- package/dist/tsup/inspector/mod.d.cts +408 -0
- package/dist/tsup/inspector/mod.d.ts +408 -0
- package/dist/tsup/inspector/mod.js +51 -0
- package/dist/tsup/inspector/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +67 -0
- package/dist/tsup/mod.cjs.map +1 -0
- package/dist/tsup/mod.d.cts +105 -0
- package/dist/tsup/mod.d.ts +105 -0
- package/dist/tsup/mod.js +67 -0
- package/dist/tsup/mod.js.map +1 -0
- package/dist/tsup/router-endpoints-BTe_Rsdn.d.cts +65 -0
- package/dist/tsup/router-endpoints-CBSrKHmo.d.ts +65 -0
- package/dist/tsup/test/mod.cjs +17 -0
- package/dist/tsup/test/mod.cjs.map +1 -0
- package/dist/tsup/test/mod.d.cts +26 -0
- package/dist/tsup/test/mod.d.ts +26 -0
- package/dist/tsup/test/mod.js +17 -0
- package/dist/tsup/test/mod.js.map +1 -0
- package/dist/tsup/utils-fwx3o3K9.d.cts +18 -0
- package/dist/tsup/utils-fwx3o3K9.d.ts +18 -0
- package/dist/tsup/utils.cjs +26 -0
- package/dist/tsup/utils.cjs.map +1 -0
- package/dist/tsup/utils.d.cts +36 -0
- package/dist/tsup/utils.d.ts +36 -0
- package/dist/tsup/utils.js +26 -0
- package/dist/tsup/utils.js.map +1 -0
- package/package.json +208 -5
- package/src/actor/action.ts +178 -0
- package/src/actor/config.ts +497 -0
- package/src/actor/connection.ts +257 -0
- package/src/actor/context.ts +168 -0
- package/src/actor/database.ts +23 -0
- package/src/actor/definition.ts +82 -0
- package/src/actor/driver.ts +84 -0
- package/src/actor/errors.ts +422 -0
- package/src/actor/generic-conn-driver.ts +246 -0
- package/src/actor/instance.ts +1844 -0
- package/src/actor/keys.test.ts +266 -0
- package/src/actor/keys.ts +89 -0
- package/src/actor/log.ts +6 -0
- package/src/actor/mod.ts +108 -0
- package/src/actor/persisted.ts +42 -0
- package/src/actor/protocol/old.ts +297 -0
- package/src/actor/protocol/serde.ts +131 -0
- package/src/actor/router-endpoints.ts +688 -0
- package/src/actor/router.ts +265 -0
- package/src/actor/schedule.ts +17 -0
- package/src/actor/unstable-react.ts +110 -0
- package/src/actor/utils.ts +102 -0
- package/src/client/actor-common.ts +30 -0
- package/src/client/actor-conn.ts +865 -0
- package/src/client/actor-handle.ts +268 -0
- package/src/client/actor-query.ts +65 -0
- package/src/client/client.ts +554 -0
- package/src/client/config.ts +44 -0
- package/src/client/errors.ts +42 -0
- package/src/client/log.ts +5 -0
- package/src/client/mod.ts +60 -0
- package/src/client/raw-utils.ts +149 -0
- package/src/client/test.ts +44 -0
- package/src/client/utils.ts +152 -0
- package/src/common/eventsource-interface.ts +47 -0
- package/src/common/eventsource.ts +80 -0
- package/src/common/fake-event-source.ts +267 -0
- package/src/common/inline-websocket-adapter2.ts +454 -0
- package/src/common/log-levels.ts +27 -0
- package/src/common/log.ts +214 -0
- package/src/common/logfmt.ts +219 -0
- package/src/common/network.ts +2 -0
- package/src/common/router.ts +80 -0
- package/src/common/utils.ts +336 -0
- package/src/common/versioned-data.ts +95 -0
- package/src/common/websocket-interface.ts +49 -0
- package/src/common/websocket.ts +42 -0
- package/src/driver-helpers/mod.ts +22 -0
- package/src/driver-helpers/utils.ts +17 -0
- package/src/driver-test-suite/log.ts +5 -0
- package/src/driver-test-suite/mod.ts +239 -0
- package/src/driver-test-suite/tests/action-features.ts +136 -0
- package/src/driver-test-suite/tests/actor-conn-state.ts +249 -0
- package/src/driver-test-suite/tests/actor-conn.ts +349 -0
- package/src/driver-test-suite/tests/actor-driver.ts +25 -0
- package/src/driver-test-suite/tests/actor-error-handling.ts +158 -0
- package/src/driver-test-suite/tests/actor-handle.ts +292 -0
- package/src/driver-test-suite/tests/actor-inline-client.ts +152 -0
- package/src/driver-test-suite/tests/actor-inspector.ts +570 -0
- package/src/driver-test-suite/tests/actor-metadata.ts +116 -0
- package/src/driver-test-suite/tests/actor-onstatechange.ts +95 -0
- package/src/driver-test-suite/tests/actor-schedule.ts +108 -0
- package/src/driver-test-suite/tests/actor-sleep.ts +413 -0
- package/src/driver-test-suite/tests/actor-state.ts +54 -0
- package/src/driver-test-suite/tests/actor-vars.ts +93 -0
- package/src/driver-test-suite/tests/manager-driver.ts +367 -0
- package/src/driver-test-suite/tests/raw-http-direct-registry.ts +227 -0
- package/src/driver-test-suite/tests/raw-http-request-properties.ts +414 -0
- package/src/driver-test-suite/tests/raw-http.ts +347 -0
- package/src/driver-test-suite/tests/raw-websocket-direct-registry.ts +393 -0
- package/src/driver-test-suite/tests/raw-websocket.ts +484 -0
- package/src/driver-test-suite/tests/request-access.ts +230 -0
- package/src/driver-test-suite/utils.ts +71 -0
- package/src/drivers/default.ts +34 -0
- package/src/drivers/engine/actor-driver.ts +369 -0
- package/src/drivers/engine/config.ts +31 -0
- package/src/drivers/engine/kv.ts +3 -0
- package/src/drivers/engine/log.ts +5 -0
- package/src/drivers/engine/mod.ts +35 -0
- package/src/drivers/file-system/actor.ts +91 -0
- package/src/drivers/file-system/global-state.ts +686 -0
- package/src/drivers/file-system/log.ts +5 -0
- package/src/drivers/file-system/manager.ts +329 -0
- package/src/drivers/file-system/mod.ts +48 -0
- package/src/drivers/file-system/utils.ts +109 -0
- package/src/globals.d.ts +6 -0
- package/src/inspector/actor.ts +298 -0
- package/src/inspector/config.ts +88 -0
- package/src/inspector/log.ts +5 -0
- package/src/inspector/manager.ts +86 -0
- package/src/inspector/mod.ts +2 -0
- package/src/inspector/protocol/actor.ts +10 -0
- package/src/inspector/protocol/common.ts +196 -0
- package/src/inspector/protocol/manager.ts +10 -0
- package/src/inspector/protocol/mod.ts +2 -0
- package/src/inspector/utils.ts +76 -0
- package/src/manager/driver.ts +88 -0
- package/src/manager/hono-websocket-adapter.ts +342 -0
- package/src/manager/log.ts +5 -0
- package/src/manager/mod.ts +2 -0
- package/src/manager/protocol/mod.ts +24 -0
- package/src/manager/protocol/query.ts +89 -0
- package/src/manager/router.ts +412 -0
- package/src/manager-api/routes/actors-create.ts +16 -0
- package/src/manager-api/routes/actors-delete.ts +4 -0
- package/src/manager-api/routes/actors-get-by-id.ts +7 -0
- package/src/manager-api/routes/actors-get-or-create-by-id.ts +29 -0
- package/src/manager-api/routes/actors-get.ts +7 -0
- package/src/manager-api/routes/common.ts +18 -0
- package/src/mod.ts +18 -0
- package/src/registry/config.ts +32 -0
- package/src/registry/log.ts +5 -0
- package/src/registry/mod.ts +157 -0
- package/src/registry/run-config.ts +52 -0
- package/src/registry/serve.ts +52 -0
- package/src/remote-manager-driver/actor-http-client.ts +72 -0
- package/src/remote-manager-driver/actor-websocket-client.ts +63 -0
- package/src/remote-manager-driver/api-endpoints.ts +79 -0
- package/src/remote-manager-driver/api-utils.ts +43 -0
- package/src/remote-manager-driver/log.ts +5 -0
- package/src/remote-manager-driver/mod.ts +274 -0
- package/src/remote-manager-driver/ws-proxy.ts +180 -0
- package/src/schemas/actor-persist/mod.ts +1 -0
- package/src/schemas/actor-persist/versioned.ts +25 -0
- package/src/schemas/client-protocol/mod.ts +1 -0
- package/src/schemas/client-protocol/versioned.ts +63 -0
- package/src/schemas/file-system-driver/mod.ts +1 -0
- package/src/schemas/file-system-driver/versioned.ts +28 -0
- package/src/serde.ts +90 -0
- package/src/test/config.ts +16 -0
- package/src/test/log.ts +5 -0
- package/src/test/mod.ts +154 -0
- package/src/utils.ts +172 -0
|
@@ -0,0 +1,2087 @@
|
|
|
1
|
+
import z$1, { z } from 'zod';
|
|
2
|
+
import { Logger } from 'pino';
|
|
3
|
+
import * as hono from 'hono';
|
|
4
|
+
import { Env, Context, Hono } from 'hono';
|
|
5
|
+
import { UpgradeWebSocket } from './utils.cjs';
|
|
6
|
+
import * as nanoevents from 'nanoevents';
|
|
7
|
+
import { g as Connection, h as RealtimeEvent } from './common-CXCe7s6i.cjs';
|
|
8
|
+
import { SSEStreamingApi } from 'hono/streaming';
|
|
9
|
+
import { WSContext } from 'hono/ws';
|
|
10
|
+
|
|
11
|
+
type uint = bigint;
|
|
12
|
+
type Init = {
|
|
13
|
+
readonly actorId: string;
|
|
14
|
+
readonly connectionId: string;
|
|
15
|
+
readonly connectionToken: string;
|
|
16
|
+
};
|
|
17
|
+
type Error$1 = {
|
|
18
|
+
readonly group: string;
|
|
19
|
+
readonly code: string;
|
|
20
|
+
readonly message: string;
|
|
21
|
+
readonly metadata: ArrayBuffer | null;
|
|
22
|
+
readonly actionId: uint | null;
|
|
23
|
+
};
|
|
24
|
+
type ActionResponse = {
|
|
25
|
+
readonly id: uint;
|
|
26
|
+
readonly output: ArrayBuffer;
|
|
27
|
+
};
|
|
28
|
+
type Event = {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly args: ArrayBuffer;
|
|
31
|
+
};
|
|
32
|
+
type ToClientBody = {
|
|
33
|
+
readonly tag: "Init";
|
|
34
|
+
readonly val: Init;
|
|
35
|
+
} | {
|
|
36
|
+
readonly tag: "Error";
|
|
37
|
+
readonly val: Error$1;
|
|
38
|
+
} | {
|
|
39
|
+
readonly tag: "ActionResponse";
|
|
40
|
+
readonly val: ActionResponse;
|
|
41
|
+
} | {
|
|
42
|
+
readonly tag: "Event";
|
|
43
|
+
readonly val: Event;
|
|
44
|
+
};
|
|
45
|
+
type ToClient = {
|
|
46
|
+
readonly body: ToClientBody;
|
|
47
|
+
};
|
|
48
|
+
type ActionRequest = {
|
|
49
|
+
readonly id: uint;
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly args: ArrayBuffer;
|
|
52
|
+
};
|
|
53
|
+
type SubscriptionRequest = {
|
|
54
|
+
readonly eventName: string;
|
|
55
|
+
readonly subscribe: boolean;
|
|
56
|
+
};
|
|
57
|
+
type ToServerBody = {
|
|
58
|
+
readonly tag: "ActionRequest";
|
|
59
|
+
readonly val: ActionRequest;
|
|
60
|
+
} | {
|
|
61
|
+
readonly tag: "SubscriptionRequest";
|
|
62
|
+
readonly val: SubscriptionRequest;
|
|
63
|
+
};
|
|
64
|
+
type ToServer = {
|
|
65
|
+
readonly body: ToServerBody;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : never;
|
|
69
|
+
type AnyDatabaseProvider = DatabaseProvider<any> | undefined;
|
|
70
|
+
type DatabaseProvider<DB extends {
|
|
71
|
+
execute: (query: string) => any;
|
|
72
|
+
}> = {
|
|
73
|
+
/**
|
|
74
|
+
* Creates a new database client for the actor.
|
|
75
|
+
* The result is passed to the actor context as `c.db`.
|
|
76
|
+
* @experimental
|
|
77
|
+
*/
|
|
78
|
+
createClient: (ctx: {
|
|
79
|
+
getDatabase: () => Promise<string | unknown>;
|
|
80
|
+
}) => Promise<DB>;
|
|
81
|
+
/**
|
|
82
|
+
* Runs before the actor has started.
|
|
83
|
+
* Use this to run migrations or other setup tasks.
|
|
84
|
+
* @experimental
|
|
85
|
+
*/
|
|
86
|
+
onMigrate: (client: DB) => void | Promise<void>;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
type MigrationFn<TFrom, TTo> = (data: TFrom) => TTo;
|
|
90
|
+
interface VersionedDataConfig<T> {
|
|
91
|
+
currentVersion: number;
|
|
92
|
+
migrations: Map<number, MigrationFn<any, any>>;
|
|
93
|
+
serializeVersion: (data: T) => Uint8Array;
|
|
94
|
+
deserializeVersion: (bytes: Uint8Array) => T;
|
|
95
|
+
}
|
|
96
|
+
declare class VersionedDataHandler<T> {
|
|
97
|
+
private config;
|
|
98
|
+
constructor(config: VersionedDataConfig<T>);
|
|
99
|
+
serializeWithEmbeddedVersion(data: T): Uint8Array;
|
|
100
|
+
deserializeWithEmbeddedVersion(bytes: Uint8Array): T;
|
|
101
|
+
serialize(data: T, version: number): Uint8Array;
|
|
102
|
+
deserialize(bytes: Uint8Array, version: number): T;
|
|
103
|
+
private embedVersion;
|
|
104
|
+
private extractVersion;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Data that's been serialized. */
|
|
108
|
+
type OutputData = string | Uint8Array;
|
|
109
|
+
declare const EncodingSchema: z.ZodEnum<["json", "cbor", "bare"]>;
|
|
110
|
+
/**
|
|
111
|
+
* Encoding used to communicate between the client & actor.
|
|
112
|
+
*/
|
|
113
|
+
type Encoding = z.infer<typeof EncodingSchema>;
|
|
114
|
+
/**
|
|
115
|
+
* Helper class that helps serialize data without re-serializing for the same encoding.
|
|
116
|
+
*/
|
|
117
|
+
declare class CachedSerializer<T> {
|
|
118
|
+
#private;
|
|
119
|
+
constructor(data: T, versionedDataHandler: VersionedDataHandler<T>);
|
|
120
|
+
get rawData(): T;
|
|
121
|
+
serialize(encoding: Encoding): OutputData;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare const ActorsSchema: z.ZodRecord<z.ZodString, z.ZodType<ActorDefinition<any, any, any, any, any, any, any>, z.ZodTypeDef, ActorDefinition<any, any, any, any, any, any, any>>>;
|
|
125
|
+
type RegistryActors = z.infer<typeof ActorsSchema>;
|
|
126
|
+
/** Base config used for the actor config across all platforms. */
|
|
127
|
+
declare const RegistryConfigSchema: z.ZodObject<{
|
|
128
|
+
use: z.ZodRecord<z.ZodString, z.ZodType<AnyActorDefinition, z.ZodTypeDef, AnyActorDefinition>>;
|
|
129
|
+
/**
|
|
130
|
+
* Test configuration.
|
|
131
|
+
*
|
|
132
|
+
* DO NOT MANUALLY ENABLE. THIS IS USED INTERNALLY.
|
|
133
|
+
* @internal
|
|
134
|
+
**/
|
|
135
|
+
test: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
136
|
+
enabled: z.ZodBoolean;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
enabled: boolean;
|
|
139
|
+
}, {
|
|
140
|
+
enabled: boolean;
|
|
141
|
+
}>>>;
|
|
142
|
+
}, "strip", z.ZodTypeAny, {
|
|
143
|
+
use: Record<string, AnyActorDefinition>;
|
|
144
|
+
test: {
|
|
145
|
+
enabled: boolean;
|
|
146
|
+
};
|
|
147
|
+
}, {
|
|
148
|
+
use: Record<string, AnyActorDefinition>;
|
|
149
|
+
test?: {
|
|
150
|
+
enabled: boolean;
|
|
151
|
+
} | undefined;
|
|
152
|
+
}>;
|
|
153
|
+
type RegistryConfig = z.infer<typeof RegistryConfigSchema>;
|
|
154
|
+
type RegistryConfigInput<A extends RegistryActors> = Omit<z.input<typeof RegistryConfigSchema>, "use"> & {
|
|
155
|
+
use: A;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
interface RivetEvent {
|
|
159
|
+
type: string;
|
|
160
|
+
target?: any;
|
|
161
|
+
currentTarget?: any;
|
|
162
|
+
}
|
|
163
|
+
interface RivetMessageEvent extends RivetEvent {
|
|
164
|
+
data: any;
|
|
165
|
+
}
|
|
166
|
+
interface RivetCloseEvent extends RivetEvent {
|
|
167
|
+
code: number;
|
|
168
|
+
reason: string;
|
|
169
|
+
wasClean: boolean;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Common WebSocket interface that can be implemented by different WebSocket-like classes
|
|
173
|
+
* This is compatible with the standard WebSocket API but allows for custom implementations
|
|
174
|
+
*/
|
|
175
|
+
interface UniversalWebSocket {
|
|
176
|
+
readonly CONNECTING: 0;
|
|
177
|
+
readonly OPEN: 1;
|
|
178
|
+
readonly CLOSING: 2;
|
|
179
|
+
readonly CLOSED: 3;
|
|
180
|
+
readonly readyState: 0 | 1 | 2 | 3;
|
|
181
|
+
binaryType: "arraybuffer" | "blob";
|
|
182
|
+
readonly bufferedAmount: number;
|
|
183
|
+
readonly extensions: string;
|
|
184
|
+
readonly protocol: string;
|
|
185
|
+
readonly url: string;
|
|
186
|
+
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
|
|
187
|
+
close(code?: number, reason?: string): void;
|
|
188
|
+
addEventListener(type: string, listener: (event: any) => void): void;
|
|
189
|
+
removeEventListener(type: string, listener: (event: any) => void): void;
|
|
190
|
+
dispatchEvent(event: RivetEvent): boolean;
|
|
191
|
+
onopen?: ((event: RivetEvent) => void) | null;
|
|
192
|
+
onclose?: ((event: RivetCloseEvent) => void) | null;
|
|
193
|
+
onerror?: ((event: RivetEvent) => void) | null;
|
|
194
|
+
onmessage?: ((event: RivetMessageEvent) => void) | null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
type GetUpgradeWebSocket = () => UpgradeWebSocket;
|
|
198
|
+
declare const ClientConfigSchema: z$1.ZodObject<{
|
|
199
|
+
/** Configure serving the API */
|
|
200
|
+
api: z$1.ZodDefault<z$1.ZodObject<{
|
|
201
|
+
host: z$1.ZodDefault<z$1.ZodString>;
|
|
202
|
+
port: z$1.ZodDefault<z$1.ZodNumber>;
|
|
203
|
+
}, "strip", z$1.ZodTypeAny, {
|
|
204
|
+
host: string;
|
|
205
|
+
port: number;
|
|
206
|
+
}, {
|
|
207
|
+
host?: string | undefined;
|
|
208
|
+
port?: number | undefined;
|
|
209
|
+
}>>;
|
|
210
|
+
/** Endpoint to connect to the Rivet engine. Can be configured via RIVET_ENGINE env var. */
|
|
211
|
+
endpoint: z$1.ZodDefault<z$1.ZodNullable<z$1.ZodString>>;
|
|
212
|
+
namespace: z$1.ZodDefault<z$1.ZodString>;
|
|
213
|
+
runnerName: z$1.ZodDefault<z$1.ZodString>;
|
|
214
|
+
encoding: z$1.ZodDefault<z$1.ZodEnum<["json", "cbor", "bare"]>>;
|
|
215
|
+
transport: z$1.ZodDefault<z$1.ZodEnum<["websocket", "sse"]>>;
|
|
216
|
+
getUpgradeWebSocket: z$1.ZodOptional<z$1.ZodType<GetUpgradeWebSocket, z$1.ZodTypeDef, GetUpgradeWebSocket>>;
|
|
217
|
+
}, "strip", z$1.ZodTypeAny, {
|
|
218
|
+
encoding: "json" | "cbor" | "bare";
|
|
219
|
+
api: {
|
|
220
|
+
host: string;
|
|
221
|
+
port: number;
|
|
222
|
+
};
|
|
223
|
+
endpoint: string | null;
|
|
224
|
+
namespace: string;
|
|
225
|
+
runnerName: string;
|
|
226
|
+
transport: "websocket" | "sse";
|
|
227
|
+
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
228
|
+
}, {
|
|
229
|
+
encoding?: "json" | "cbor" | "bare" | undefined;
|
|
230
|
+
api?: {
|
|
231
|
+
host?: string | undefined;
|
|
232
|
+
port?: number | undefined;
|
|
233
|
+
} | undefined;
|
|
234
|
+
endpoint?: string | null | undefined;
|
|
235
|
+
namespace?: string | undefined;
|
|
236
|
+
runnerName?: string | undefined;
|
|
237
|
+
transport?: "websocket" | "sse" | undefined;
|
|
238
|
+
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
239
|
+
}>;
|
|
240
|
+
type ClientConfig = z$1.infer<typeof ClientConfigSchema>;
|
|
241
|
+
type ClientConfigInput = z$1.input<typeof ClientConfigSchema>;
|
|
242
|
+
|
|
243
|
+
type ManagerDriverBuilder = (registryConfig: RegistryConfig, runConfig: RunConfig) => ManagerDriver;
|
|
244
|
+
interface ManagerDriver {
|
|
245
|
+
getForId(input: GetForIdInput): Promise<ActorOutput | undefined>;
|
|
246
|
+
getWithKey(input: GetWithKeyInput): Promise<ActorOutput | undefined>;
|
|
247
|
+
getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise<ActorOutput>;
|
|
248
|
+
createActor(input: CreateInput): Promise<ActorOutput>;
|
|
249
|
+
sendRequest(actorId: string, actorRequest: Request): Promise<Response>;
|
|
250
|
+
openWebSocket(path: string, actorId: string, encoding: Encoding, params: unknown): Promise<UniversalWebSocket>;
|
|
251
|
+
proxyRequest(c: Context, actorRequest: Request, actorId: string): Promise<Response>;
|
|
252
|
+
proxyWebSocket(c: Context, path: string, actorId: string, encoding: Encoding, params: unknown, authData: unknown): Promise<Response>;
|
|
253
|
+
displayInformation(): ManagerDisplayInformation;
|
|
254
|
+
extraStartupLog?: () => Record<string, unknown>;
|
|
255
|
+
modifyManagerRouter?: (registryConfig: RegistryConfig, router: Hono) => void;
|
|
256
|
+
}
|
|
257
|
+
interface ManagerDisplayInformation {
|
|
258
|
+
name: string;
|
|
259
|
+
properties: Record<string, string>;
|
|
260
|
+
}
|
|
261
|
+
interface GetForIdInput<E extends Env = any> {
|
|
262
|
+
c?: Context | undefined;
|
|
263
|
+
name: string;
|
|
264
|
+
actorId: string;
|
|
265
|
+
}
|
|
266
|
+
interface GetWithKeyInput<E extends Env = any> {
|
|
267
|
+
c?: Context | undefined;
|
|
268
|
+
name: string;
|
|
269
|
+
key: ActorKey;
|
|
270
|
+
}
|
|
271
|
+
interface GetOrCreateWithKeyInput<E extends Env = any> {
|
|
272
|
+
c?: Context | undefined;
|
|
273
|
+
name: string;
|
|
274
|
+
key: ActorKey;
|
|
275
|
+
input?: unknown;
|
|
276
|
+
region?: string;
|
|
277
|
+
}
|
|
278
|
+
interface CreateInput<E extends Env = any> {
|
|
279
|
+
c?: Context | undefined;
|
|
280
|
+
name: string;
|
|
281
|
+
key: ActorKey;
|
|
282
|
+
input?: unknown;
|
|
283
|
+
region?: string;
|
|
284
|
+
}
|
|
285
|
+
interface ActorOutput {
|
|
286
|
+
actorId: string;
|
|
287
|
+
name: string;
|
|
288
|
+
key: ActorKey;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
declare const DriverConfigSchema: z.ZodObject<{
|
|
292
|
+
/** Machine-readable name to identify this driver by. */
|
|
293
|
+
name: z.ZodString;
|
|
294
|
+
manager: z.ZodType<ManagerDriverBuilder, z.ZodTypeDef, ManagerDriverBuilder>;
|
|
295
|
+
actor: z.ZodType<ActorDriverBuilder, z.ZodTypeDef, ActorDriverBuilder>;
|
|
296
|
+
}, "strip", z.ZodTypeAny, {
|
|
297
|
+
actor: ActorDriverBuilder;
|
|
298
|
+
name: string;
|
|
299
|
+
manager: ManagerDriverBuilder;
|
|
300
|
+
}, {
|
|
301
|
+
actor: ActorDriverBuilder;
|
|
302
|
+
name: string;
|
|
303
|
+
manager: ManagerDriverBuilder;
|
|
304
|
+
}>;
|
|
305
|
+
type DriverConfig = z.infer<typeof DriverConfigSchema>;
|
|
306
|
+
/** Base config used for the actor config across all platforms. */
|
|
307
|
+
declare const RunConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
308
|
+
api: z.ZodDefault<z.ZodObject<{
|
|
309
|
+
host: z.ZodDefault<z.ZodString>;
|
|
310
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
311
|
+
}, "strip", z.ZodTypeAny, {
|
|
312
|
+
host: string;
|
|
313
|
+
port: number;
|
|
314
|
+
}, {
|
|
315
|
+
host?: string | undefined;
|
|
316
|
+
port?: number | undefined;
|
|
317
|
+
}>>;
|
|
318
|
+
endpoint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
319
|
+
namespace: z.ZodDefault<z.ZodString>;
|
|
320
|
+
runnerName: z.ZodDefault<z.ZodString>;
|
|
321
|
+
encoding: z.ZodDefault<z.ZodEnum<["json", "cbor", "bare"]>>;
|
|
322
|
+
transport: z.ZodDefault<z.ZodEnum<["websocket", "sse"]>>;
|
|
323
|
+
getUpgradeWebSocket: z.ZodOptional<z.ZodType<GetUpgradeWebSocket, z.ZodTypeDef, GetUpgradeWebSocket>>;
|
|
324
|
+
} & {
|
|
325
|
+
driver: z.ZodOptional<z.ZodObject<{
|
|
326
|
+
/** Machine-readable name to identify this driver by. */
|
|
327
|
+
name: z.ZodString;
|
|
328
|
+
manager: z.ZodType<ManagerDriverBuilder, z.ZodTypeDef, ManagerDriverBuilder>;
|
|
329
|
+
actor: z.ZodType<ActorDriverBuilder, z.ZodTypeDef, ActorDriverBuilder>;
|
|
330
|
+
}, "strip", z.ZodTypeAny, {
|
|
331
|
+
actor: ActorDriverBuilder;
|
|
332
|
+
name: string;
|
|
333
|
+
manager: ManagerDriverBuilder;
|
|
334
|
+
}, {
|
|
335
|
+
actor: ActorDriverBuilder;
|
|
336
|
+
name: string;
|
|
337
|
+
manager: ManagerDriverBuilder;
|
|
338
|
+
}>>;
|
|
339
|
+
/** CORS configuration for the router. Uses Hono's CORS middleware options. */
|
|
340
|
+
cors: z.ZodOptional<z.ZodType<{
|
|
341
|
+
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
342
|
+
allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
|
|
343
|
+
allowHeaders?: string[];
|
|
344
|
+
maxAge?: number;
|
|
345
|
+
credentials?: boolean;
|
|
346
|
+
exposeHeaders?: string[];
|
|
347
|
+
}, z.ZodTypeDef, {
|
|
348
|
+
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
349
|
+
allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
|
|
350
|
+
allowHeaders?: string[];
|
|
351
|
+
maxAge?: number;
|
|
352
|
+
credentials?: boolean;
|
|
353
|
+
exposeHeaders?: string[];
|
|
354
|
+
}>>;
|
|
355
|
+
maxIncomingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
356
|
+
inspector: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
357
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
358
|
+
cors: z.ZodDefault<z.ZodOptional<z.ZodType<{
|
|
359
|
+
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
360
|
+
allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
|
|
361
|
+
allowHeaders?: string[];
|
|
362
|
+
maxAge?: number;
|
|
363
|
+
credentials?: boolean;
|
|
364
|
+
exposeHeaders?: string[];
|
|
365
|
+
}, z.ZodTypeDef, {
|
|
366
|
+
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
367
|
+
allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
|
|
368
|
+
allowHeaders?: string[];
|
|
369
|
+
maxAge?: number;
|
|
370
|
+
credentials?: boolean;
|
|
371
|
+
exposeHeaders?: string[];
|
|
372
|
+
}>>>;
|
|
373
|
+
token: z.ZodDefault<z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodString>>>;
|
|
374
|
+
defaultEndpoint: z.ZodOptional<z.ZodString>;
|
|
375
|
+
}, "strip", z.ZodTypeAny, {
|
|
376
|
+
enabled: boolean;
|
|
377
|
+
cors: {
|
|
378
|
+
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
379
|
+
allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
|
|
380
|
+
allowHeaders?: string[];
|
|
381
|
+
maxAge?: number;
|
|
382
|
+
credentials?: boolean;
|
|
383
|
+
exposeHeaders?: string[];
|
|
384
|
+
};
|
|
385
|
+
token: (...args: unknown[]) => string;
|
|
386
|
+
defaultEndpoint?: string | undefined;
|
|
387
|
+
}, {
|
|
388
|
+
enabled?: boolean | undefined;
|
|
389
|
+
cors?: {
|
|
390
|
+
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
391
|
+
allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
|
|
392
|
+
allowHeaders?: string[];
|
|
393
|
+
maxAge?: number;
|
|
394
|
+
credentials?: boolean;
|
|
395
|
+
exposeHeaders?: string[];
|
|
396
|
+
} | undefined;
|
|
397
|
+
token?: ((...args: unknown[]) => string) | undefined;
|
|
398
|
+
defaultEndpoint?: string | undefined;
|
|
399
|
+
}>>>;
|
|
400
|
+
/**
|
|
401
|
+
* Base path for the router. This is used to prefix all routes.
|
|
402
|
+
* For example, if the base path is `/api`, then the route `/actors` will be
|
|
403
|
+
* available at `/api/actors`.
|
|
404
|
+
*/
|
|
405
|
+
basePath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
406
|
+
/** Disable welcome message. */
|
|
407
|
+
noWelcome: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
408
|
+
logging: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
409
|
+
baseLogger: z.ZodOptional<z.ZodType<Logger, z.ZodTypeDef, Logger>>;
|
|
410
|
+
level: z.ZodOptional<z.ZodEnum<["trace", "debug", "info", "warn", "error", "fatal", "silent"]>>;
|
|
411
|
+
}, "strip", z.ZodTypeAny, {
|
|
412
|
+
level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
|
|
413
|
+
baseLogger?: Logger | undefined;
|
|
414
|
+
}, {
|
|
415
|
+
level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
|
|
416
|
+
baseLogger?: Logger | undefined;
|
|
417
|
+
}>>>;
|
|
418
|
+
}, "strip", z.ZodTypeAny, {
|
|
419
|
+
encoding: "json" | "cbor" | "bare";
|
|
420
|
+
inspector: {
|
|
421
|
+
enabled: boolean;
|
|
422
|
+
cors: {
|
|
423
|
+
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
424
|
+
allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
|
|
425
|
+
allowHeaders?: string[];
|
|
426
|
+
maxAge?: number;
|
|
427
|
+
credentials?: boolean;
|
|
428
|
+
exposeHeaders?: string[];
|
|
429
|
+
};
|
|
430
|
+
token: (...args: unknown[]) => string;
|
|
431
|
+
defaultEndpoint?: string | undefined;
|
|
432
|
+
};
|
|
433
|
+
api: {
|
|
434
|
+
host: string;
|
|
435
|
+
port: number;
|
|
436
|
+
};
|
|
437
|
+
endpoint: string | null;
|
|
438
|
+
namespace: string;
|
|
439
|
+
runnerName: string;
|
|
440
|
+
transport: "websocket" | "sse";
|
|
441
|
+
maxIncomingMessageSize: number;
|
|
442
|
+
basePath: string;
|
|
443
|
+
noWelcome: boolean;
|
|
444
|
+
logging: {
|
|
445
|
+
level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
|
|
446
|
+
baseLogger?: Logger | undefined;
|
|
447
|
+
};
|
|
448
|
+
driver?: {
|
|
449
|
+
actor: ActorDriverBuilder;
|
|
450
|
+
name: string;
|
|
451
|
+
manager: ManagerDriverBuilder;
|
|
452
|
+
} | undefined;
|
|
453
|
+
cors?: {
|
|
454
|
+
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
455
|
+
allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
|
|
456
|
+
allowHeaders?: string[];
|
|
457
|
+
maxAge?: number;
|
|
458
|
+
credentials?: boolean;
|
|
459
|
+
exposeHeaders?: string[];
|
|
460
|
+
} | undefined;
|
|
461
|
+
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
462
|
+
}, {
|
|
463
|
+
encoding?: "json" | "cbor" | "bare" | undefined;
|
|
464
|
+
driver?: {
|
|
465
|
+
actor: ActorDriverBuilder;
|
|
466
|
+
name: string;
|
|
467
|
+
manager: ManagerDriverBuilder;
|
|
468
|
+
} | undefined;
|
|
469
|
+
inspector?: {
|
|
470
|
+
enabled?: boolean | undefined;
|
|
471
|
+
cors?: {
|
|
472
|
+
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
473
|
+
allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
|
|
474
|
+
allowHeaders?: string[];
|
|
475
|
+
maxAge?: number;
|
|
476
|
+
credentials?: boolean;
|
|
477
|
+
exposeHeaders?: string[];
|
|
478
|
+
} | undefined;
|
|
479
|
+
token?: ((...args: unknown[]) => string) | undefined;
|
|
480
|
+
defaultEndpoint?: string | undefined;
|
|
481
|
+
} | undefined;
|
|
482
|
+
cors?: {
|
|
483
|
+
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
484
|
+
allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
|
|
485
|
+
allowHeaders?: string[];
|
|
486
|
+
maxAge?: number;
|
|
487
|
+
credentials?: boolean;
|
|
488
|
+
exposeHeaders?: string[];
|
|
489
|
+
} | undefined;
|
|
490
|
+
api?: {
|
|
491
|
+
host?: string | undefined;
|
|
492
|
+
port?: number | undefined;
|
|
493
|
+
} | undefined;
|
|
494
|
+
endpoint?: string | null | undefined;
|
|
495
|
+
namespace?: string | undefined;
|
|
496
|
+
runnerName?: string | undefined;
|
|
497
|
+
transport?: "websocket" | "sse" | undefined;
|
|
498
|
+
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
499
|
+
maxIncomingMessageSize?: number | undefined;
|
|
500
|
+
basePath?: string | undefined;
|
|
501
|
+
noWelcome?: boolean | undefined;
|
|
502
|
+
logging?: {
|
|
503
|
+
level?: "error" | "trace" | "fatal" | "warn" | "info" | "debug" | "silent" | undefined;
|
|
504
|
+
baseLogger?: Logger | undefined;
|
|
505
|
+
} | undefined;
|
|
506
|
+
}>>;
|
|
507
|
+
type RunConfig = z.infer<typeof RunConfigSchema>;
|
|
508
|
+
type RunConfigInput = z.input<typeof RunConfigSchema>;
|
|
509
|
+
|
|
510
|
+
interface ServerOutput<A extends Registry<any>> {
|
|
511
|
+
config: RunConfig;
|
|
512
|
+
driver: DriverConfig;
|
|
513
|
+
client: Client<A>;
|
|
514
|
+
hono: Hono;
|
|
515
|
+
handler: (req: Request) => Promise<Response>;
|
|
516
|
+
serve: (hono?: Hono) => void;
|
|
517
|
+
}
|
|
518
|
+
declare class Registry<A extends RegistryActors> {
|
|
519
|
+
#private;
|
|
520
|
+
get config(): RegistryConfig;
|
|
521
|
+
constructor(config: RegistryConfig);
|
|
522
|
+
/**
|
|
523
|
+
* Runs the registry for a server.
|
|
524
|
+
*/
|
|
525
|
+
createServer(inputConfig?: RunConfigInput): ServerOutput<this>;
|
|
526
|
+
/**
|
|
527
|
+
* Runs the registry as a standalone server.
|
|
528
|
+
*/
|
|
529
|
+
runServer(inputConfig?: RunConfigInput): Promise<void>;
|
|
530
|
+
}
|
|
531
|
+
declare function setup<A extends RegistryActors>(input: RegistryConfigInput<A>): Registry<A>;
|
|
532
|
+
|
|
533
|
+
interface ActorInspectorAccessors {
|
|
534
|
+
isStateEnabled: () => Promise<boolean>;
|
|
535
|
+
getState: () => Promise<unknown>;
|
|
536
|
+
setState: (state: unknown) => Promise<void>;
|
|
537
|
+
isDbEnabled: () => Promise<boolean>;
|
|
538
|
+
getDb: () => Promise<InferDatabaseClient<AnyDatabaseProvider>>;
|
|
539
|
+
getRpcs: () => Promise<string[]>;
|
|
540
|
+
getConnections: () => Promise<Connection[]>;
|
|
541
|
+
}
|
|
542
|
+
interface ActorInspectorEmitterEvents {
|
|
543
|
+
stateUpdated: (state: unknown) => void;
|
|
544
|
+
connectionUpdated: () => void;
|
|
545
|
+
eventFired: (event: RealtimeEvent) => void;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Provides a unified interface for inspecting actor external and internal state.
|
|
549
|
+
*/
|
|
550
|
+
declare class ActorInspector {
|
|
551
|
+
#private;
|
|
552
|
+
readonly accessors: ActorInspectorAccessors;
|
|
553
|
+
readonly emitter: nanoevents.Emitter<ActorInspectorEmitterEvents>;
|
|
554
|
+
get lastRealtimeEvents(): (({
|
|
555
|
+
type: "action";
|
|
556
|
+
name: string;
|
|
557
|
+
args: any[];
|
|
558
|
+
connId: string;
|
|
559
|
+
} | {
|
|
560
|
+
type: "broadcast";
|
|
561
|
+
eventName: string;
|
|
562
|
+
args: any[];
|
|
563
|
+
} | {
|
|
564
|
+
type: "subscribe";
|
|
565
|
+
eventName: string;
|
|
566
|
+
connId: string;
|
|
567
|
+
} | {
|
|
568
|
+
type: "unsubscribe";
|
|
569
|
+
eventName: string;
|
|
570
|
+
connId: string;
|
|
571
|
+
} | {
|
|
572
|
+
type: "event";
|
|
573
|
+
eventName: string;
|
|
574
|
+
args: any[];
|
|
575
|
+
connId: string;
|
|
576
|
+
}) & {
|
|
577
|
+
id: string;
|
|
578
|
+
timestamp: number;
|
|
579
|
+
})[];
|
|
580
|
+
constructor(accessors: () => ActorInspectorAccessors);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
declare class Schedule {
|
|
584
|
+
#private;
|
|
585
|
+
constructor(actor: AnyActorInstance);
|
|
586
|
+
after(duration: number, fn: string, ...args: unknown[]): Promise<void>;
|
|
587
|
+
at(timestamp: number, fn: string, ...args: unknown[]): Promise<void>;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Options for the `_saveState` method.
|
|
592
|
+
*/
|
|
593
|
+
interface SaveStateOptions {
|
|
594
|
+
/**
|
|
595
|
+
* Forces the state to be saved immediately. This function will return when the state has saved successfully.
|
|
596
|
+
*/
|
|
597
|
+
immediate?: boolean;
|
|
598
|
+
/** Bypass ready check for stopping. */
|
|
599
|
+
allowStoppingState?: boolean;
|
|
600
|
+
}
|
|
601
|
+
/** Actor type alias with all `any` types. Used for `extends` in classes referencing this actor. */
|
|
602
|
+
type AnyActorInstance = ActorInstance<any, any, any, any, any, any>;
|
|
603
|
+
declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
604
|
+
#private;
|
|
605
|
+
actorContext: ActorContext<S, CP, CS, V, I, DB>;
|
|
606
|
+
get isStopping(): boolean;
|
|
607
|
+
get id(): string;
|
|
608
|
+
get inlineClient(): Client<Registry<any>>;
|
|
609
|
+
get inspector(): ActorInspector;
|
|
610
|
+
/**
|
|
611
|
+
* This constructor should never be used directly.
|
|
612
|
+
*
|
|
613
|
+
* Constructed in {@link ActorInstance.start}.
|
|
614
|
+
*
|
|
615
|
+
* @private
|
|
616
|
+
*/
|
|
617
|
+
constructor(config: ActorConfig<S, CP, CS, V, I, DB>);
|
|
618
|
+
start(connectionDrivers: ConnectionDriversMap, actorDriver: ActorDriver, inlineClient: Client<Registry<any>>, actorId: string, name: string, key: ActorKey, region: string): Promise<void>;
|
|
619
|
+
_onAlarm(): Promise<void>;
|
|
620
|
+
scheduleEvent(timestamp: number, action: string, args: unknown[]): Promise<void>;
|
|
621
|
+
get stateEnabled(): boolean;
|
|
622
|
+
__getConnForId(id: string): Conn<S, CP, CS, V, I, DB> | undefined;
|
|
623
|
+
/**
|
|
624
|
+
* Removes a connection and cleans up its resources.
|
|
625
|
+
*/
|
|
626
|
+
__removeConn(conn: Conn<S, CP, CS, V, I, DB> | undefined): void;
|
|
627
|
+
prepareConn(params: any, request?: Request): Promise<CS>;
|
|
628
|
+
__getConnDriver(driverId: ConnectionDriver): ConnDriver;
|
|
629
|
+
/**
|
|
630
|
+
* Called after establishing a connection handshake.
|
|
631
|
+
*/
|
|
632
|
+
createConn(connectionId: string, connectionToken: string, params: CP, state: CS, driverId: ConnectionDriver, driverState: unknown, authData: unknown): Promise<Conn<S, CP, CS, V, I, DB>>;
|
|
633
|
+
processMessage(message: ToServer, conn: Conn<S, CP, CS, V, I, DB>): Promise<void>;
|
|
634
|
+
/**
|
|
635
|
+
* Check if the actor is ready to handle requests.
|
|
636
|
+
*/
|
|
637
|
+
isReady(): boolean;
|
|
638
|
+
/**
|
|
639
|
+
* Returns a list of action methods available on this actor.
|
|
640
|
+
*/
|
|
641
|
+
get actions(): string[];
|
|
642
|
+
/**
|
|
643
|
+
* Handles raw HTTP requests to the actor.
|
|
644
|
+
*/
|
|
645
|
+
handleFetch(request: Request, opts: {}): Promise<Response>;
|
|
646
|
+
/**
|
|
647
|
+
* Handles raw WebSocket connections to the actor.
|
|
648
|
+
*/
|
|
649
|
+
handleWebSocket(websocket: UniversalWebSocket, opts: {
|
|
650
|
+
request: Request;
|
|
651
|
+
}): Promise<void>;
|
|
652
|
+
get log(): Logger;
|
|
653
|
+
get rLog(): Logger;
|
|
654
|
+
/**
|
|
655
|
+
* Gets the name.
|
|
656
|
+
*/
|
|
657
|
+
get name(): string;
|
|
658
|
+
/**
|
|
659
|
+
* Gets the key.
|
|
660
|
+
*/
|
|
661
|
+
get key(): ActorKey;
|
|
662
|
+
/**
|
|
663
|
+
* Gets the region.
|
|
664
|
+
*/
|
|
665
|
+
get region(): string;
|
|
666
|
+
/**
|
|
667
|
+
* Gets the scheduler.
|
|
668
|
+
*/
|
|
669
|
+
get schedule(): Schedule;
|
|
670
|
+
/**
|
|
671
|
+
* Gets the map of connections.
|
|
672
|
+
*/
|
|
673
|
+
get conns(): Map<ConnId, Conn<S, CP, CS, V, I, DB>>;
|
|
674
|
+
/**
|
|
675
|
+
* Gets the current state.
|
|
676
|
+
*
|
|
677
|
+
* Changing properties of this value will automatically be persisted.
|
|
678
|
+
*/
|
|
679
|
+
get state(): S;
|
|
680
|
+
/**
|
|
681
|
+
* Gets the database.
|
|
682
|
+
* @experimental
|
|
683
|
+
* @throws {DatabaseNotEnabled} If the database is not enabled.
|
|
684
|
+
*/
|
|
685
|
+
get db(): InferDatabaseClient<DB>;
|
|
686
|
+
/**
|
|
687
|
+
* Sets the current state.
|
|
688
|
+
*
|
|
689
|
+
* This property will automatically be persisted.
|
|
690
|
+
*/
|
|
691
|
+
set state(value: S);
|
|
692
|
+
get vars(): V;
|
|
693
|
+
/**
|
|
694
|
+
* Broadcasts an event to all connected clients.
|
|
695
|
+
* @param name - The name of the event.
|
|
696
|
+
* @param args - The arguments to send with the event.
|
|
697
|
+
*/
|
|
698
|
+
_broadcast<Args extends Array<unknown>>(name: string, ...args: Args): void;
|
|
699
|
+
/**
|
|
700
|
+
* Prevents the actor from sleeping until promise is complete.
|
|
701
|
+
*
|
|
702
|
+
* This allows the actor runtime to ensure that a promise completes while
|
|
703
|
+
* returning from an action request early.
|
|
704
|
+
*
|
|
705
|
+
* @param promise - The promise to run in the background.
|
|
706
|
+
*/
|
|
707
|
+
_waitUntil(promise: Promise<void>): void;
|
|
708
|
+
/**
|
|
709
|
+
* Forces the state to get saved.
|
|
710
|
+
*
|
|
711
|
+
* This is helpful if running a long task that may fail later or when
|
|
712
|
+
* running a background job that updates the state.
|
|
713
|
+
*
|
|
714
|
+
* @param opts - Options for saving the state.
|
|
715
|
+
*/
|
|
716
|
+
saveState(opts: SaveStateOptions): Promise<void>;
|
|
717
|
+
/** Puts an actor to sleep. This should just start the sleep sequence, most shutdown logic should be in _stop (which is called by the ActorDriver when sleeping). */
|
|
718
|
+
_sleep(): Promise<void>;
|
|
719
|
+
_stop(): Promise<void>;
|
|
720
|
+
/** Abort signal that fires when the actor is stopping. */
|
|
721
|
+
get abortSignal(): AbortSignal;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* ActorContext class that provides access to actor methods and state
|
|
726
|
+
*/
|
|
727
|
+
declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> {
|
|
728
|
+
#private;
|
|
729
|
+
constructor(actor: ActorInstance<TState, TConnParams, TConnState, TVars, TInput, TDatabase>);
|
|
730
|
+
/**
|
|
731
|
+
* Get the actor state
|
|
732
|
+
*/
|
|
733
|
+
get state(): TState;
|
|
734
|
+
/**
|
|
735
|
+
* Get the actor variables
|
|
736
|
+
*/
|
|
737
|
+
get vars(): TVars;
|
|
738
|
+
/**
|
|
739
|
+
* Broadcasts an event to all connected clients.
|
|
740
|
+
* @param name - The name of the event.
|
|
741
|
+
* @param args - The arguments to send with the event.
|
|
742
|
+
*/
|
|
743
|
+
broadcast<Args extends Array<unknown>>(name: string, ...args: Args): void;
|
|
744
|
+
/**
|
|
745
|
+
* Gets the logger instance.
|
|
746
|
+
*/
|
|
747
|
+
get log(): Logger;
|
|
748
|
+
/**
|
|
749
|
+
* Gets actor ID.
|
|
750
|
+
*/
|
|
751
|
+
get actorId(): string;
|
|
752
|
+
/**
|
|
753
|
+
* Gets the actor name.
|
|
754
|
+
*/
|
|
755
|
+
get name(): string;
|
|
756
|
+
/**
|
|
757
|
+
* Gets the actor key.
|
|
758
|
+
*/
|
|
759
|
+
get key(): ActorKey;
|
|
760
|
+
/**
|
|
761
|
+
* Gets the region.
|
|
762
|
+
*/
|
|
763
|
+
get region(): string;
|
|
764
|
+
/**
|
|
765
|
+
* Gets the scheduler.
|
|
766
|
+
*/
|
|
767
|
+
get schedule(): Schedule;
|
|
768
|
+
/**
|
|
769
|
+
* Gets the map of connections.
|
|
770
|
+
*/
|
|
771
|
+
get conns(): Map<ConnId, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>>;
|
|
772
|
+
/**
|
|
773
|
+
* Returns the client for the given registry.
|
|
774
|
+
*/
|
|
775
|
+
client<R extends Registry<any>>(): Client<R>;
|
|
776
|
+
/**
|
|
777
|
+
* Gets the database.
|
|
778
|
+
* @experimental
|
|
779
|
+
* @throws {DatabaseNotEnabled} If the database is not enabled.
|
|
780
|
+
*/
|
|
781
|
+
get db(): InferDatabaseClient<TDatabase>;
|
|
782
|
+
/**
|
|
783
|
+
* Forces the state to get saved.
|
|
784
|
+
*
|
|
785
|
+
* @param opts - Options for saving the state.
|
|
786
|
+
*/
|
|
787
|
+
saveState(opts: SaveStateOptions): Promise<void>;
|
|
788
|
+
/**
|
|
789
|
+
* Prevents the actor from sleeping until promise is complete.
|
|
790
|
+
*/
|
|
791
|
+
waitUntil(promise: Promise<void>): void;
|
|
792
|
+
/**
|
|
793
|
+
* AbortSignal that fires when the actor is stopping.
|
|
794
|
+
*/
|
|
795
|
+
get abortSignal(): AbortSignal;
|
|
796
|
+
/**
|
|
797
|
+
* Forces the actor to sleep.
|
|
798
|
+
*
|
|
799
|
+
* Not supported on all drivers.
|
|
800
|
+
*
|
|
801
|
+
* @experimental
|
|
802
|
+
*/
|
|
803
|
+
sleep(): void;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
type InitContext = ActorContext<undefined, undefined, undefined, undefined, undefined, undefined>;
|
|
807
|
+
interface ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> {
|
|
808
|
+
state?: TState;
|
|
809
|
+
connParams?: TConnParams;
|
|
810
|
+
connState?: TConnState;
|
|
811
|
+
vars?: TVars;
|
|
812
|
+
input?: TInput;
|
|
813
|
+
database?: TDatabase;
|
|
814
|
+
}
|
|
815
|
+
declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
816
|
+
onCreate: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
817
|
+
onStart: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
818
|
+
onStop: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
819
|
+
onStateChange: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
820
|
+
onBeforeConnect: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
821
|
+
onConnect: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
822
|
+
onDisconnect: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
823
|
+
onBeforeActionResponse: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
824
|
+
onFetch: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
825
|
+
onWebSocket: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
826
|
+
actions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>>;
|
|
827
|
+
state: z.ZodOptional<z.ZodAny>;
|
|
828
|
+
createState: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
829
|
+
connState: z.ZodOptional<z.ZodAny>;
|
|
830
|
+
createConnState: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
831
|
+
vars: z.ZodOptional<z.ZodAny>;
|
|
832
|
+
db: z.ZodOptional<z.ZodAny>;
|
|
833
|
+
createVars: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
834
|
+
options: z.ZodDefault<z.ZodObject<{
|
|
835
|
+
createVarsTimeout: z.ZodDefault<z.ZodNumber>;
|
|
836
|
+
createConnStateTimeout: z.ZodDefault<z.ZodNumber>;
|
|
837
|
+
onConnectTimeout: z.ZodDefault<z.ZodNumber>;
|
|
838
|
+
onStopTimeout: z.ZodDefault<z.ZodNumber>;
|
|
839
|
+
stateSaveInterval: z.ZodDefault<z.ZodNumber>;
|
|
840
|
+
actionTimeout: z.ZodDefault<z.ZodNumber>;
|
|
841
|
+
waitUntilTimeout: z.ZodDefault<z.ZodNumber>;
|
|
842
|
+
connectionLivenessTimeout: z.ZodDefault<z.ZodNumber>;
|
|
843
|
+
connectionLivenessInterval: z.ZodDefault<z.ZodNumber>;
|
|
844
|
+
noSleep: z.ZodDefault<z.ZodBoolean>;
|
|
845
|
+
sleepTimeout: z.ZodDefault<z.ZodNumber>;
|
|
846
|
+
}, "strict", z.ZodTypeAny, {
|
|
847
|
+
createVarsTimeout: number;
|
|
848
|
+
createConnStateTimeout: number;
|
|
849
|
+
onConnectTimeout: number;
|
|
850
|
+
onStopTimeout: number;
|
|
851
|
+
stateSaveInterval: number;
|
|
852
|
+
actionTimeout: number;
|
|
853
|
+
waitUntilTimeout: number;
|
|
854
|
+
connectionLivenessTimeout: number;
|
|
855
|
+
connectionLivenessInterval: number;
|
|
856
|
+
noSleep: boolean;
|
|
857
|
+
sleepTimeout: number;
|
|
858
|
+
}, {
|
|
859
|
+
createVarsTimeout?: number | undefined;
|
|
860
|
+
createConnStateTimeout?: number | undefined;
|
|
861
|
+
onConnectTimeout?: number | undefined;
|
|
862
|
+
onStopTimeout?: number | undefined;
|
|
863
|
+
stateSaveInterval?: number | undefined;
|
|
864
|
+
actionTimeout?: number | undefined;
|
|
865
|
+
waitUntilTimeout?: number | undefined;
|
|
866
|
+
connectionLivenessTimeout?: number | undefined;
|
|
867
|
+
connectionLivenessInterval?: number | undefined;
|
|
868
|
+
noSleep?: boolean | undefined;
|
|
869
|
+
sleepTimeout?: number | undefined;
|
|
870
|
+
}>>;
|
|
871
|
+
}, "strict", z.ZodTypeAny, {
|
|
872
|
+
options: {
|
|
873
|
+
createVarsTimeout: number;
|
|
874
|
+
createConnStateTimeout: number;
|
|
875
|
+
onConnectTimeout: number;
|
|
876
|
+
onStopTimeout: number;
|
|
877
|
+
stateSaveInterval: number;
|
|
878
|
+
actionTimeout: number;
|
|
879
|
+
waitUntilTimeout: number;
|
|
880
|
+
connectionLivenessTimeout: number;
|
|
881
|
+
connectionLivenessInterval: number;
|
|
882
|
+
noSleep: boolean;
|
|
883
|
+
sleepTimeout: number;
|
|
884
|
+
};
|
|
885
|
+
actions: Record<string, (...args: unknown[]) => unknown>;
|
|
886
|
+
state?: any;
|
|
887
|
+
db?: any;
|
|
888
|
+
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
889
|
+
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
890
|
+
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
891
|
+
onStateChange?: ((...args: unknown[]) => unknown) | undefined;
|
|
892
|
+
onBeforeConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
893
|
+
onConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
894
|
+
onDisconnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
895
|
+
onBeforeActionResponse?: ((...args: unknown[]) => unknown) | undefined;
|
|
896
|
+
onFetch?: ((...args: unknown[]) => unknown) | undefined;
|
|
897
|
+
onWebSocket?: ((...args: unknown[]) => unknown) | undefined;
|
|
898
|
+
createState?: ((...args: unknown[]) => unknown) | undefined;
|
|
899
|
+
connState?: any;
|
|
900
|
+
createConnState?: ((...args: unknown[]) => unknown) | undefined;
|
|
901
|
+
vars?: any;
|
|
902
|
+
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
903
|
+
}, {
|
|
904
|
+
state?: any;
|
|
905
|
+
options?: {
|
|
906
|
+
createVarsTimeout?: number | undefined;
|
|
907
|
+
createConnStateTimeout?: number | undefined;
|
|
908
|
+
onConnectTimeout?: number | undefined;
|
|
909
|
+
onStopTimeout?: number | undefined;
|
|
910
|
+
stateSaveInterval?: number | undefined;
|
|
911
|
+
actionTimeout?: number | undefined;
|
|
912
|
+
waitUntilTimeout?: number | undefined;
|
|
913
|
+
connectionLivenessTimeout?: number | undefined;
|
|
914
|
+
connectionLivenessInterval?: number | undefined;
|
|
915
|
+
noSleep?: boolean | undefined;
|
|
916
|
+
sleepTimeout?: number | undefined;
|
|
917
|
+
} | undefined;
|
|
918
|
+
db?: any;
|
|
919
|
+
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
920
|
+
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
921
|
+
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
922
|
+
onStateChange?: ((...args: unknown[]) => unknown) | undefined;
|
|
923
|
+
onBeforeConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
924
|
+
onConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
925
|
+
onDisconnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
926
|
+
onBeforeActionResponse?: ((...args: unknown[]) => unknown) | undefined;
|
|
927
|
+
onFetch?: ((...args: unknown[]) => unknown) | undefined;
|
|
928
|
+
onWebSocket?: ((...args: unknown[]) => unknown) | undefined;
|
|
929
|
+
actions?: Record<string, (...args: unknown[]) => unknown> | undefined;
|
|
930
|
+
createState?: ((...args: unknown[]) => unknown) | undefined;
|
|
931
|
+
connState?: any;
|
|
932
|
+
createConnState?: ((...args: unknown[]) => unknown) | undefined;
|
|
933
|
+
vars?: any;
|
|
934
|
+
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
935
|
+
}>, {
|
|
936
|
+
options: {
|
|
937
|
+
createVarsTimeout: number;
|
|
938
|
+
createConnStateTimeout: number;
|
|
939
|
+
onConnectTimeout: number;
|
|
940
|
+
onStopTimeout: number;
|
|
941
|
+
stateSaveInterval: number;
|
|
942
|
+
actionTimeout: number;
|
|
943
|
+
waitUntilTimeout: number;
|
|
944
|
+
connectionLivenessTimeout: number;
|
|
945
|
+
connectionLivenessInterval: number;
|
|
946
|
+
noSleep: boolean;
|
|
947
|
+
sleepTimeout: number;
|
|
948
|
+
};
|
|
949
|
+
actions: Record<string, (...args: unknown[]) => unknown>;
|
|
950
|
+
state?: any;
|
|
951
|
+
db?: any;
|
|
952
|
+
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
953
|
+
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
954
|
+
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
955
|
+
onStateChange?: ((...args: unknown[]) => unknown) | undefined;
|
|
956
|
+
onBeforeConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
957
|
+
onConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
958
|
+
onDisconnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
959
|
+
onBeforeActionResponse?: ((...args: unknown[]) => unknown) | undefined;
|
|
960
|
+
onFetch?: ((...args: unknown[]) => unknown) | undefined;
|
|
961
|
+
onWebSocket?: ((...args: unknown[]) => unknown) | undefined;
|
|
962
|
+
createState?: ((...args: unknown[]) => unknown) | undefined;
|
|
963
|
+
connState?: any;
|
|
964
|
+
createConnState?: ((...args: unknown[]) => unknown) | undefined;
|
|
965
|
+
vars?: any;
|
|
966
|
+
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
967
|
+
}, {
|
|
968
|
+
state?: any;
|
|
969
|
+
options?: {
|
|
970
|
+
createVarsTimeout?: number | undefined;
|
|
971
|
+
createConnStateTimeout?: number | undefined;
|
|
972
|
+
onConnectTimeout?: number | undefined;
|
|
973
|
+
onStopTimeout?: number | undefined;
|
|
974
|
+
stateSaveInterval?: number | undefined;
|
|
975
|
+
actionTimeout?: number | undefined;
|
|
976
|
+
waitUntilTimeout?: number | undefined;
|
|
977
|
+
connectionLivenessTimeout?: number | undefined;
|
|
978
|
+
connectionLivenessInterval?: number | undefined;
|
|
979
|
+
noSleep?: boolean | undefined;
|
|
980
|
+
sleepTimeout?: number | undefined;
|
|
981
|
+
} | undefined;
|
|
982
|
+
db?: any;
|
|
983
|
+
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
984
|
+
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
985
|
+
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
986
|
+
onStateChange?: ((...args: unknown[]) => unknown) | undefined;
|
|
987
|
+
onBeforeConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
988
|
+
onConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
989
|
+
onDisconnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
990
|
+
onBeforeActionResponse?: ((...args: unknown[]) => unknown) | undefined;
|
|
991
|
+
onFetch?: ((...args: unknown[]) => unknown) | undefined;
|
|
992
|
+
onWebSocket?: ((...args: unknown[]) => unknown) | undefined;
|
|
993
|
+
actions?: Record<string, (...args: unknown[]) => unknown> | undefined;
|
|
994
|
+
createState?: ((...args: unknown[]) => unknown) | undefined;
|
|
995
|
+
connState?: any;
|
|
996
|
+
createConnState?: ((...args: unknown[]) => unknown) | undefined;
|
|
997
|
+
vars?: any;
|
|
998
|
+
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
999
|
+
}>, {
|
|
1000
|
+
options: {
|
|
1001
|
+
createVarsTimeout: number;
|
|
1002
|
+
createConnStateTimeout: number;
|
|
1003
|
+
onConnectTimeout: number;
|
|
1004
|
+
onStopTimeout: number;
|
|
1005
|
+
stateSaveInterval: number;
|
|
1006
|
+
actionTimeout: number;
|
|
1007
|
+
waitUntilTimeout: number;
|
|
1008
|
+
connectionLivenessTimeout: number;
|
|
1009
|
+
connectionLivenessInterval: number;
|
|
1010
|
+
noSleep: boolean;
|
|
1011
|
+
sleepTimeout: number;
|
|
1012
|
+
};
|
|
1013
|
+
actions: Record<string, (...args: unknown[]) => unknown>;
|
|
1014
|
+
state?: any;
|
|
1015
|
+
db?: any;
|
|
1016
|
+
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
1017
|
+
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
1018
|
+
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
1019
|
+
onStateChange?: ((...args: unknown[]) => unknown) | undefined;
|
|
1020
|
+
onBeforeConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1021
|
+
onConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1022
|
+
onDisconnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1023
|
+
onBeforeActionResponse?: ((...args: unknown[]) => unknown) | undefined;
|
|
1024
|
+
onFetch?: ((...args: unknown[]) => unknown) | undefined;
|
|
1025
|
+
onWebSocket?: ((...args: unknown[]) => unknown) | undefined;
|
|
1026
|
+
createState?: ((...args: unknown[]) => unknown) | undefined;
|
|
1027
|
+
connState?: any;
|
|
1028
|
+
createConnState?: ((...args: unknown[]) => unknown) | undefined;
|
|
1029
|
+
vars?: any;
|
|
1030
|
+
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
1031
|
+
}, {
|
|
1032
|
+
state?: any;
|
|
1033
|
+
options?: {
|
|
1034
|
+
createVarsTimeout?: number | undefined;
|
|
1035
|
+
createConnStateTimeout?: number | undefined;
|
|
1036
|
+
onConnectTimeout?: number | undefined;
|
|
1037
|
+
onStopTimeout?: number | undefined;
|
|
1038
|
+
stateSaveInterval?: number | undefined;
|
|
1039
|
+
actionTimeout?: number | undefined;
|
|
1040
|
+
waitUntilTimeout?: number | undefined;
|
|
1041
|
+
connectionLivenessTimeout?: number | undefined;
|
|
1042
|
+
connectionLivenessInterval?: number | undefined;
|
|
1043
|
+
noSleep?: boolean | undefined;
|
|
1044
|
+
sleepTimeout?: number | undefined;
|
|
1045
|
+
} | undefined;
|
|
1046
|
+
db?: any;
|
|
1047
|
+
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
1048
|
+
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
1049
|
+
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
1050
|
+
onStateChange?: ((...args: unknown[]) => unknown) | undefined;
|
|
1051
|
+
onBeforeConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1052
|
+
onConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1053
|
+
onDisconnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1054
|
+
onBeforeActionResponse?: ((...args: unknown[]) => unknown) | undefined;
|
|
1055
|
+
onFetch?: ((...args: unknown[]) => unknown) | undefined;
|
|
1056
|
+
onWebSocket?: ((...args: unknown[]) => unknown) | undefined;
|
|
1057
|
+
actions?: Record<string, (...args: unknown[]) => unknown> | undefined;
|
|
1058
|
+
createState?: ((...args: unknown[]) => unknown) | undefined;
|
|
1059
|
+
connState?: any;
|
|
1060
|
+
createConnState?: ((...args: unknown[]) => unknown) | undefined;
|
|
1061
|
+
vars?: any;
|
|
1062
|
+
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
1063
|
+
}>, {
|
|
1064
|
+
options: {
|
|
1065
|
+
createVarsTimeout: number;
|
|
1066
|
+
createConnStateTimeout: number;
|
|
1067
|
+
onConnectTimeout: number;
|
|
1068
|
+
onStopTimeout: number;
|
|
1069
|
+
stateSaveInterval: number;
|
|
1070
|
+
actionTimeout: number;
|
|
1071
|
+
waitUntilTimeout: number;
|
|
1072
|
+
connectionLivenessTimeout: number;
|
|
1073
|
+
connectionLivenessInterval: number;
|
|
1074
|
+
noSleep: boolean;
|
|
1075
|
+
sleepTimeout: number;
|
|
1076
|
+
};
|
|
1077
|
+
actions: Record<string, (...args: unknown[]) => unknown>;
|
|
1078
|
+
state?: any;
|
|
1079
|
+
db?: any;
|
|
1080
|
+
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
1081
|
+
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
1082
|
+
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
1083
|
+
onStateChange?: ((...args: unknown[]) => unknown) | undefined;
|
|
1084
|
+
onBeforeConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1085
|
+
onConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1086
|
+
onDisconnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1087
|
+
onBeforeActionResponse?: ((...args: unknown[]) => unknown) | undefined;
|
|
1088
|
+
onFetch?: ((...args: unknown[]) => unknown) | undefined;
|
|
1089
|
+
onWebSocket?: ((...args: unknown[]) => unknown) | undefined;
|
|
1090
|
+
createState?: ((...args: unknown[]) => unknown) | undefined;
|
|
1091
|
+
connState?: any;
|
|
1092
|
+
createConnState?: ((...args: unknown[]) => unknown) | undefined;
|
|
1093
|
+
vars?: any;
|
|
1094
|
+
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
1095
|
+
}, {
|
|
1096
|
+
state?: any;
|
|
1097
|
+
options?: {
|
|
1098
|
+
createVarsTimeout?: number | undefined;
|
|
1099
|
+
createConnStateTimeout?: number | undefined;
|
|
1100
|
+
onConnectTimeout?: number | undefined;
|
|
1101
|
+
onStopTimeout?: number | undefined;
|
|
1102
|
+
stateSaveInterval?: number | undefined;
|
|
1103
|
+
actionTimeout?: number | undefined;
|
|
1104
|
+
waitUntilTimeout?: number | undefined;
|
|
1105
|
+
connectionLivenessTimeout?: number | undefined;
|
|
1106
|
+
connectionLivenessInterval?: number | undefined;
|
|
1107
|
+
noSleep?: boolean | undefined;
|
|
1108
|
+
sleepTimeout?: number | undefined;
|
|
1109
|
+
} | undefined;
|
|
1110
|
+
db?: any;
|
|
1111
|
+
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
1112
|
+
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
1113
|
+
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
1114
|
+
onStateChange?: ((...args: unknown[]) => unknown) | undefined;
|
|
1115
|
+
onBeforeConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1116
|
+
onConnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1117
|
+
onDisconnect?: ((...args: unknown[]) => unknown) | undefined;
|
|
1118
|
+
onBeforeActionResponse?: ((...args: unknown[]) => unknown) | undefined;
|
|
1119
|
+
onFetch?: ((...args: unknown[]) => unknown) | undefined;
|
|
1120
|
+
onWebSocket?: ((...args: unknown[]) => unknown) | undefined;
|
|
1121
|
+
actions?: Record<string, (...args: unknown[]) => unknown> | undefined;
|
|
1122
|
+
createState?: ((...args: unknown[]) => unknown) | undefined;
|
|
1123
|
+
connState?: any;
|
|
1124
|
+
createConnState?: ((...args: unknown[]) => unknown) | undefined;
|
|
1125
|
+
vars?: any;
|
|
1126
|
+
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
1127
|
+
}>;
|
|
1128
|
+
interface OnConnectOptions {
|
|
1129
|
+
/**
|
|
1130
|
+
* The request object associated with the connection.
|
|
1131
|
+
*
|
|
1132
|
+
* @experimental
|
|
1133
|
+
*/
|
|
1134
|
+
request?: Request;
|
|
1135
|
+
}
|
|
1136
|
+
type CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> = {
|
|
1137
|
+
state: TState;
|
|
1138
|
+
} | {
|
|
1139
|
+
createState: (c: InitContext, input: TInput) => TState | Promise<TState>;
|
|
1140
|
+
} | Record<never, never>;
|
|
1141
|
+
type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> = {
|
|
1142
|
+
connState: TConnState;
|
|
1143
|
+
} | {
|
|
1144
|
+
createConnState: (c: InitContext, opts: OnConnectOptions, params: TConnParams) => TConnState | Promise<TConnState>;
|
|
1145
|
+
} | Record<never, never>;
|
|
1146
|
+
/**
|
|
1147
|
+
* @experimental
|
|
1148
|
+
*/
|
|
1149
|
+
type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase> = {
|
|
1150
|
+
/**
|
|
1151
|
+
* @experimental
|
|
1152
|
+
*/
|
|
1153
|
+
vars: TVars;
|
|
1154
|
+
} | {
|
|
1155
|
+
/**
|
|
1156
|
+
* @experimental
|
|
1157
|
+
*/
|
|
1158
|
+
createVars: (c: InitContext, driverCtx: any) => TVars | Promise<TVars>;
|
|
1159
|
+
} | Record<never, never>;
|
|
1160
|
+
interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> {
|
|
1161
|
+
[Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, ...args: any[]) => any;
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* @experimental
|
|
1165
|
+
*/
|
|
1166
|
+
type AuthIntent = "get" | "create" | "connect" | "action" | "message";
|
|
1167
|
+
interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase>> {
|
|
1168
|
+
/**
|
|
1169
|
+
* Called when the actor is first initialized.
|
|
1170
|
+
*
|
|
1171
|
+
* Use this hook to initialize your actor's state.
|
|
1172
|
+
* This is called before any other lifecycle hooks.
|
|
1173
|
+
*/
|
|
1174
|
+
onCreate?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, input: TInput) => void | Promise<void>;
|
|
1175
|
+
/**
|
|
1176
|
+
* Called when the actor is started and ready to receive connections and action.
|
|
1177
|
+
*
|
|
1178
|
+
* Use this hook to initialize resources needed for the actor's operation
|
|
1179
|
+
* (timers, external connections, etc.)
|
|
1180
|
+
*
|
|
1181
|
+
* @returns Void or a Promise that resolves when startup is complete
|
|
1182
|
+
*/
|
|
1183
|
+
onStart?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
1184
|
+
/**
|
|
1185
|
+
* Called when the actor is stopping or sleeping.
|
|
1186
|
+
*
|
|
1187
|
+
* Use this hook to clean up resources, save state, or perform
|
|
1188
|
+
* any shutdown operations before the actor sleeps or stops.
|
|
1189
|
+
*
|
|
1190
|
+
* Not supported on all platforms.
|
|
1191
|
+
*
|
|
1192
|
+
* @returns Void or a Promise that resolves when shutdown is complete
|
|
1193
|
+
*/
|
|
1194
|
+
onStop?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
1195
|
+
/**
|
|
1196
|
+
* Called when the actor's state changes.
|
|
1197
|
+
*
|
|
1198
|
+
* Use this hook to react to state changes, such as updating
|
|
1199
|
+
* external systems or triggering events.
|
|
1200
|
+
*
|
|
1201
|
+
* State changes made within this hook will NOT trigger
|
|
1202
|
+
* another onStateChange call, preventing infinite recursion.
|
|
1203
|
+
*
|
|
1204
|
+
* @param newState The updated state
|
|
1205
|
+
*/
|
|
1206
|
+
onStateChange?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, newState: TState) => void;
|
|
1207
|
+
/**
|
|
1208
|
+
* Called before a client connects to the actor.
|
|
1209
|
+
*
|
|
1210
|
+
* Use this hook to determine if a connection should be accepted
|
|
1211
|
+
* and to initialize connection-specific state.
|
|
1212
|
+
*
|
|
1213
|
+
* @param opts Connection parameters including client-provided data
|
|
1214
|
+
* @returns The initial connection state or a Promise that resolves to it
|
|
1215
|
+
* @throws Throw an error to reject the connection
|
|
1216
|
+
*/
|
|
1217
|
+
onBeforeConnect?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, opts: OnConnectOptions, params: TConnParams) => void | Promise<void>;
|
|
1218
|
+
/**
|
|
1219
|
+
* Called when a client successfully connects to the actor.
|
|
1220
|
+
*
|
|
1221
|
+
* Use this hook to perform actions when a connection is established,
|
|
1222
|
+
* such as sending initial data or updating the actor's state.
|
|
1223
|
+
*
|
|
1224
|
+
* @param conn The connection object
|
|
1225
|
+
* @returns Void or a Promise that resolves when connection handling is complete
|
|
1226
|
+
*/
|
|
1227
|
+
onConnect?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Called when a client disconnects from the actor.
|
|
1230
|
+
*
|
|
1231
|
+
* Use this hook to clean up resources associated with the connection
|
|
1232
|
+
* or update the actor's state.
|
|
1233
|
+
*
|
|
1234
|
+
* @param conn The connection that is being closed
|
|
1235
|
+
* @returns Void or a Promise that resolves when disconnect handling is complete
|
|
1236
|
+
*/
|
|
1237
|
+
onDisconnect?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
1238
|
+
/**
|
|
1239
|
+
* Called before sending an action response to the client.
|
|
1240
|
+
*
|
|
1241
|
+
* Use this hook to modify or transform the output of an action before it's sent
|
|
1242
|
+
* to the client. This is useful for formatting responses, adding metadata,
|
|
1243
|
+
* or applying transformations to the output.
|
|
1244
|
+
*
|
|
1245
|
+
* @param name The name of the action that was called
|
|
1246
|
+
* @param args The arguments that were passed to the action
|
|
1247
|
+
* @param output The output that will be sent to the client
|
|
1248
|
+
* @returns The modified output to send to the client
|
|
1249
|
+
*/
|
|
1250
|
+
onBeforeActionResponse?: <Out>(c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, name: string, args: unknown[], output: Out) => Out | Promise<Out>;
|
|
1251
|
+
/**
|
|
1252
|
+
* Called when a raw HTTP request is made to the actor.
|
|
1253
|
+
*
|
|
1254
|
+
* This handler receives raw HTTP requests made to `/actors/{actorName}/http/*` endpoints.
|
|
1255
|
+
* Use this hook to handle custom HTTP patterns, REST APIs, or other HTTP-based protocols.
|
|
1256
|
+
*
|
|
1257
|
+
* @param request The raw HTTP request object
|
|
1258
|
+
* @returns A Response object to send back, or void to continue with default routing
|
|
1259
|
+
*/
|
|
1260
|
+
onFetch?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, request: Request, opts: {}) => Response | Promise<Response>;
|
|
1261
|
+
/**
|
|
1262
|
+
* Called when a raw WebSocket connection is established to the actor.
|
|
1263
|
+
*
|
|
1264
|
+
* This handler receives WebSocket connections made to `/actors/{actorName}/websocket/*` endpoints.
|
|
1265
|
+
* Use this hook to handle custom WebSocket protocols, binary streams, or other WebSocket-based communication.
|
|
1266
|
+
*
|
|
1267
|
+
* @param websocket The raw WebSocket connection
|
|
1268
|
+
* @param request The original HTTP upgrade request
|
|
1269
|
+
*/
|
|
1270
|
+
onWebSocket?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, websocket: UniversalWebSocket, opts: {
|
|
1271
|
+
request: Request;
|
|
1272
|
+
}) => void | Promise<void>;
|
|
1273
|
+
actions: TActions;
|
|
1274
|
+
}
|
|
1275
|
+
type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
|
|
1276
|
+
/**
|
|
1277
|
+
* @experimental
|
|
1278
|
+
*/
|
|
1279
|
+
db: TDatabase;
|
|
1280
|
+
} | Record<never, never>;
|
|
1281
|
+
type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> = Omit<z.infer<typeof ActorConfigSchema>, "actions" | "onCreate" | "onStart" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onFetch" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase>> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & ActorDatabaseConfig<TDatabase>;
|
|
1282
|
+
type ActorConfigInput<TState = undefined, TConnParams = undefined, TConnState = undefined, TVars = undefined, TInput = undefined, TDatabase extends AnyDatabaseProvider = undefined, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase> = Record<never, never>> = {
|
|
1283
|
+
types?: ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
|
|
1284
|
+
} & Omit<z.input<typeof ActorConfigSchema>, "actions" | "onCreate" | "onStart" | "onStop" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onFetch" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TActions> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & ActorDatabaseConfig<TDatabase>;
|
|
1285
|
+
declare function test<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase>>(input: ActorConfigInput<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TActions>): ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
|
|
1286
|
+
|
|
1287
|
+
declare const ActorKeySchema: z.ZodArray<z.ZodString, "many">;
|
|
1288
|
+
type ActorKey = z.infer<typeof ActorKeySchema>;
|
|
1289
|
+
declare const CreateRequestSchema: z.ZodObject<{
|
|
1290
|
+
name: z.ZodString;
|
|
1291
|
+
key: z.ZodArray<z.ZodString, "many">;
|
|
1292
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
1293
|
+
region: z.ZodOptional<z.ZodString>;
|
|
1294
|
+
}, "strip", z.ZodTypeAny, {
|
|
1295
|
+
key: string[];
|
|
1296
|
+
name: string;
|
|
1297
|
+
input?: unknown;
|
|
1298
|
+
region?: string | undefined;
|
|
1299
|
+
}, {
|
|
1300
|
+
key: string[];
|
|
1301
|
+
name: string;
|
|
1302
|
+
input?: unknown;
|
|
1303
|
+
region?: string | undefined;
|
|
1304
|
+
}>;
|
|
1305
|
+
declare const ActorQuerySchema: z.ZodUnion<[z.ZodObject<{
|
|
1306
|
+
getForId: z.ZodObject<{
|
|
1307
|
+
name: z.ZodString;
|
|
1308
|
+
actorId: z.ZodString;
|
|
1309
|
+
}, "strip", z.ZodTypeAny, {
|
|
1310
|
+
name: string;
|
|
1311
|
+
actorId: string;
|
|
1312
|
+
}, {
|
|
1313
|
+
name: string;
|
|
1314
|
+
actorId: string;
|
|
1315
|
+
}>;
|
|
1316
|
+
}, "strip", z.ZodTypeAny, {
|
|
1317
|
+
getForId: {
|
|
1318
|
+
name: string;
|
|
1319
|
+
actorId: string;
|
|
1320
|
+
};
|
|
1321
|
+
}, {
|
|
1322
|
+
getForId: {
|
|
1323
|
+
name: string;
|
|
1324
|
+
actorId: string;
|
|
1325
|
+
};
|
|
1326
|
+
}>, z.ZodObject<{
|
|
1327
|
+
getForKey: z.ZodObject<{
|
|
1328
|
+
name: z.ZodString;
|
|
1329
|
+
key: z.ZodArray<z.ZodString, "many">;
|
|
1330
|
+
}, "strip", z.ZodTypeAny, {
|
|
1331
|
+
key: string[];
|
|
1332
|
+
name: string;
|
|
1333
|
+
}, {
|
|
1334
|
+
key: string[];
|
|
1335
|
+
name: string;
|
|
1336
|
+
}>;
|
|
1337
|
+
}, "strip", z.ZodTypeAny, {
|
|
1338
|
+
getForKey: {
|
|
1339
|
+
key: string[];
|
|
1340
|
+
name: string;
|
|
1341
|
+
};
|
|
1342
|
+
}, {
|
|
1343
|
+
getForKey: {
|
|
1344
|
+
key: string[];
|
|
1345
|
+
name: string;
|
|
1346
|
+
};
|
|
1347
|
+
}>, z.ZodObject<{
|
|
1348
|
+
getOrCreateForKey: z.ZodObject<{
|
|
1349
|
+
name: z.ZodString;
|
|
1350
|
+
key: z.ZodArray<z.ZodString, "many">;
|
|
1351
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
1352
|
+
region: z.ZodOptional<z.ZodString>;
|
|
1353
|
+
}, "strip", z.ZodTypeAny, {
|
|
1354
|
+
key: string[];
|
|
1355
|
+
name: string;
|
|
1356
|
+
input?: unknown;
|
|
1357
|
+
region?: string | undefined;
|
|
1358
|
+
}, {
|
|
1359
|
+
key: string[];
|
|
1360
|
+
name: string;
|
|
1361
|
+
input?: unknown;
|
|
1362
|
+
region?: string | undefined;
|
|
1363
|
+
}>;
|
|
1364
|
+
}, "strip", z.ZodTypeAny, {
|
|
1365
|
+
getOrCreateForKey: {
|
|
1366
|
+
key: string[];
|
|
1367
|
+
name: string;
|
|
1368
|
+
input?: unknown;
|
|
1369
|
+
region?: string | undefined;
|
|
1370
|
+
};
|
|
1371
|
+
}, {
|
|
1372
|
+
getOrCreateForKey: {
|
|
1373
|
+
key: string[];
|
|
1374
|
+
name: string;
|
|
1375
|
+
input?: unknown;
|
|
1376
|
+
region?: string | undefined;
|
|
1377
|
+
};
|
|
1378
|
+
}>, z.ZodObject<{
|
|
1379
|
+
create: z.ZodObject<{
|
|
1380
|
+
name: z.ZodString;
|
|
1381
|
+
key: z.ZodArray<z.ZodString, "many">;
|
|
1382
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
1383
|
+
region: z.ZodOptional<z.ZodString>;
|
|
1384
|
+
}, "strip", z.ZodTypeAny, {
|
|
1385
|
+
key: string[];
|
|
1386
|
+
name: string;
|
|
1387
|
+
input?: unknown;
|
|
1388
|
+
region?: string | undefined;
|
|
1389
|
+
}, {
|
|
1390
|
+
key: string[];
|
|
1391
|
+
name: string;
|
|
1392
|
+
input?: unknown;
|
|
1393
|
+
region?: string | undefined;
|
|
1394
|
+
}>;
|
|
1395
|
+
}, "strip", z.ZodTypeAny, {
|
|
1396
|
+
create: {
|
|
1397
|
+
key: string[];
|
|
1398
|
+
name: string;
|
|
1399
|
+
input?: unknown;
|
|
1400
|
+
region?: string | undefined;
|
|
1401
|
+
};
|
|
1402
|
+
}, {
|
|
1403
|
+
create: {
|
|
1404
|
+
key: string[];
|
|
1405
|
+
name: string;
|
|
1406
|
+
input?: unknown;
|
|
1407
|
+
region?: string | undefined;
|
|
1408
|
+
};
|
|
1409
|
+
}>]>;
|
|
1410
|
+
type ActorQuery = z.infer<typeof ActorQuerySchema>;
|
|
1411
|
+
/**
|
|
1412
|
+
* Interface representing a request to create a actor.
|
|
1413
|
+
*/
|
|
1414
|
+
type CreateRequest = z.infer<typeof CreateRequestSchema>;
|
|
1415
|
+
|
|
1416
|
+
declare class GenericConnGlobalState {
|
|
1417
|
+
websockets: Map<string, WSContext<unknown>>;
|
|
1418
|
+
sseStreams: Map<string, SSEStreamingApi>;
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Exposes connection drivers for platforms that support vanilla WebSocket, SSE, and HTTP.
|
|
1422
|
+
*/
|
|
1423
|
+
declare function createGenericConnDrivers(globalState: GenericConnGlobalState): ConnectionDriversMap;
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* Context for a remote procedure call.
|
|
1427
|
+
*
|
|
1428
|
+
* @typeParam A Actor this action belongs to
|
|
1429
|
+
*/
|
|
1430
|
+
declare class ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> {
|
|
1431
|
+
#private;
|
|
1432
|
+
readonly conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
|
|
1433
|
+
/**
|
|
1434
|
+
* Should not be called directly.
|
|
1435
|
+
*
|
|
1436
|
+
* @param actorContext - The actor context
|
|
1437
|
+
* @param conn - The connection associated with the action
|
|
1438
|
+
*/
|
|
1439
|
+
constructor(actorContext: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>);
|
|
1440
|
+
/**
|
|
1441
|
+
* Get the actor state
|
|
1442
|
+
*/
|
|
1443
|
+
get state(): TState;
|
|
1444
|
+
/**
|
|
1445
|
+
* Get the actor variables
|
|
1446
|
+
*/
|
|
1447
|
+
get vars(): TVars;
|
|
1448
|
+
/**
|
|
1449
|
+
* Broadcasts an event to all connected clients.
|
|
1450
|
+
*/
|
|
1451
|
+
broadcast(name: string, ...args: any[]): void;
|
|
1452
|
+
/**
|
|
1453
|
+
* Gets the logger instance.
|
|
1454
|
+
*/
|
|
1455
|
+
get log(): Logger;
|
|
1456
|
+
/**
|
|
1457
|
+
* Gets actor ID.
|
|
1458
|
+
*/
|
|
1459
|
+
get actorId(): string;
|
|
1460
|
+
/**
|
|
1461
|
+
* Gets the actor name.
|
|
1462
|
+
*/
|
|
1463
|
+
get name(): string;
|
|
1464
|
+
/**
|
|
1465
|
+
* Gets the actor key.
|
|
1466
|
+
*/
|
|
1467
|
+
get key(): ActorKey;
|
|
1468
|
+
/**
|
|
1469
|
+
* Gets the region.
|
|
1470
|
+
*/
|
|
1471
|
+
get region(): string;
|
|
1472
|
+
/**
|
|
1473
|
+
* Gets the scheduler.
|
|
1474
|
+
*/
|
|
1475
|
+
get schedule(): Schedule;
|
|
1476
|
+
/**
|
|
1477
|
+
* Gets the map of connections.
|
|
1478
|
+
*/
|
|
1479
|
+
get conns(): Map<ConnId, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>>;
|
|
1480
|
+
/**
|
|
1481
|
+
* Returns the client for the given registry.
|
|
1482
|
+
*/
|
|
1483
|
+
client<R extends Registry<any>>(): Client<R>;
|
|
1484
|
+
/**
|
|
1485
|
+
* @experimental
|
|
1486
|
+
*/
|
|
1487
|
+
get db(): InferDatabaseClient<TDatabase>;
|
|
1488
|
+
/**
|
|
1489
|
+
* Forces the state to get saved.
|
|
1490
|
+
*/
|
|
1491
|
+
saveState(opts: SaveStateOptions): Promise<void>;
|
|
1492
|
+
/**
|
|
1493
|
+
* Prevents the actor from sleeping until promise is complete.
|
|
1494
|
+
*/
|
|
1495
|
+
waitUntil(promise: Promise<void>): void;
|
|
1496
|
+
/**
|
|
1497
|
+
* AbortSignal that fires when the actor is stopping.
|
|
1498
|
+
*/
|
|
1499
|
+
get abortSignal(): AbortSignal;
|
|
1500
|
+
/**
|
|
1501
|
+
* Forces the actor to sleep.
|
|
1502
|
+
*
|
|
1503
|
+
* Not supported on all drivers.
|
|
1504
|
+
*
|
|
1505
|
+
* @experimental
|
|
1506
|
+
*/
|
|
1507
|
+
sleep(): void;
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
type AnyActorDefinition = ActorDefinition<any, any, any, any, any, any, any>;
|
|
1511
|
+
/**
|
|
1512
|
+
* Extracts the context type from an ActorDefinition
|
|
1513
|
+
*/
|
|
1514
|
+
type ActorContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB, any> ? ActorContext<S, CP, CS, V, I, DB> : never;
|
|
1515
|
+
/**
|
|
1516
|
+
* Extracts the context type from an ActorDefinition
|
|
1517
|
+
*/
|
|
1518
|
+
type ActionContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB, any> ? ActionContext<S, CP, CS, V, I, DB> : never;
|
|
1519
|
+
declare class ActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, R extends Actions<S, CP, CS, V, I, DB>> {
|
|
1520
|
+
#private;
|
|
1521
|
+
constructor(config: ActorConfig<S, CP, CS, V, I, DB>);
|
|
1522
|
+
get config(): ActorConfig<S, CP, CS, V, I, DB>;
|
|
1523
|
+
instantiate(): ActorInstance<S, CP, CS, V, I, DB>;
|
|
1524
|
+
}
|
|
1525
|
+
declare function lookupInRegistry(registryConfig: RegistryConfig, name: string): AnyActorDefinition;
|
|
1526
|
+
|
|
1527
|
+
declare const TransportSchema: z.ZodEnum<["websocket", "sse"]>;
|
|
1528
|
+
/**
|
|
1529
|
+
* Transport mechanism used to communicate between client & actor.
|
|
1530
|
+
*/
|
|
1531
|
+
type Transport = z.infer<typeof TransportSchema>;
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Action function returned by Actor connections and handles.
|
|
1535
|
+
*
|
|
1536
|
+
* @typedef {Function} ActorActionFunction
|
|
1537
|
+
* @template Args
|
|
1538
|
+
* @template Response
|
|
1539
|
+
* @param {...Args} args - Arguments for the action function.
|
|
1540
|
+
* @returns {Promise<Response>}
|
|
1541
|
+
*/
|
|
1542
|
+
type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
|
|
1543
|
+
/**
|
|
1544
|
+
* Maps action methods from actor definition to typed function signatures.
|
|
1545
|
+
*/
|
|
1546
|
+
type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends ActorDefinition<any, any, any, any, any, any, infer R> ? {
|
|
1547
|
+
[K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
|
|
1548
|
+
} : never;
|
|
1549
|
+
|
|
1550
|
+
declare class ActorClientError extends Error {
|
|
1551
|
+
}
|
|
1552
|
+
declare class InternalError extends ActorClientError {
|
|
1553
|
+
}
|
|
1554
|
+
declare class ManagerError extends ActorClientError {
|
|
1555
|
+
constructor(error: string, opts?: ErrorOptions);
|
|
1556
|
+
}
|
|
1557
|
+
declare class MalformedResponseMessage extends ActorClientError {
|
|
1558
|
+
constructor(cause?: unknown);
|
|
1559
|
+
}
|
|
1560
|
+
declare class ActorError extends ActorClientError {
|
|
1561
|
+
readonly group: string;
|
|
1562
|
+
readonly code: string;
|
|
1563
|
+
readonly metadata?: unknown | undefined;
|
|
1564
|
+
__type: string;
|
|
1565
|
+
constructor(group: string, code: string, message: string, metadata?: unknown | undefined);
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
/**
|
|
1569
|
+
* A function that unsubscribes from an event.
|
|
1570
|
+
*
|
|
1571
|
+
* @typedef {Function} EventUnsubscribe
|
|
1572
|
+
*/
|
|
1573
|
+
type EventUnsubscribe = () => void;
|
|
1574
|
+
/**
|
|
1575
|
+
* A function that handles connection errors.
|
|
1576
|
+
*
|
|
1577
|
+
* @typedef {Function} ActorErrorCallback
|
|
1578
|
+
*/
|
|
1579
|
+
type ActorErrorCallback = (error: ActorError) => void;
|
|
1580
|
+
declare const CONNECT_SYMBOL: unique symbol;
|
|
1581
|
+
/**
|
|
1582
|
+
* Provides underlying functions for {@link ActorConn}. See {@link ActorConn} for using type-safe remote procedure calls.
|
|
1583
|
+
*
|
|
1584
|
+
* @see {@link ActorConn}
|
|
1585
|
+
*/
|
|
1586
|
+
declare class ActorConnRaw {
|
|
1587
|
+
#private;
|
|
1588
|
+
/**
|
|
1589
|
+
* Do not call this directly.
|
|
1590
|
+
*
|
|
1591
|
+
* Creates an instance of ActorConnRaw.
|
|
1592
|
+
*
|
|
1593
|
+
* @protected
|
|
1594
|
+
*/
|
|
1595
|
+
constructor(client: ClientRaw, driver: ManagerDriver, params: unknown, encoding: Encoding, actorQuery: ActorQuery);
|
|
1596
|
+
/**
|
|
1597
|
+
* Call a raw action connection. See {@link ActorConn} for type-safe action calls.
|
|
1598
|
+
*
|
|
1599
|
+
* @see {@link ActorConn}
|
|
1600
|
+
* @template Args - The type of arguments to pass to the action function.
|
|
1601
|
+
* @template Response - The type of the response returned by the action function.
|
|
1602
|
+
* @param {string} name - The name of the action function to call.
|
|
1603
|
+
* @param {...Args} args - The arguments to pass to the action function.
|
|
1604
|
+
* @returns {Promise<Response>} - A promise that resolves to the response of the action function.
|
|
1605
|
+
*/
|
|
1606
|
+
action<Args extends Array<unknown> = unknown[], Response = unknown>(opts: {
|
|
1607
|
+
name: string;
|
|
1608
|
+
args: Args;
|
|
1609
|
+
signal?: AbortSignal;
|
|
1610
|
+
}): Promise<Response>;
|
|
1611
|
+
/**
|
|
1612
|
+
* Do not call this directly.
|
|
1613
|
+
enc
|
|
1614
|
+
* Establishes a connection to the server using the specified endpoint & encoding & driver.
|
|
1615
|
+
*
|
|
1616
|
+
* @protected
|
|
1617
|
+
*/
|
|
1618
|
+
[CONNECT_SYMBOL](): void;
|
|
1619
|
+
/**
|
|
1620
|
+
* Subscribes to an event that will happen repeatedly.
|
|
1621
|
+
*
|
|
1622
|
+
* @template Args - The type of arguments the event callback will receive.
|
|
1623
|
+
* @param {string} eventName - The name of the event to subscribe to.
|
|
1624
|
+
* @param {(...args: Args) => void} callback - The callback function to execute when the event is triggered.
|
|
1625
|
+
* @returns {EventUnsubscribe} - A function to unsubscribe from the event.
|
|
1626
|
+
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
1627
|
+
*/
|
|
1628
|
+
on<Args extends Array<unknown> = unknown[]>(eventName: string, callback: (...args: Args) => void): EventUnsubscribe;
|
|
1629
|
+
/**
|
|
1630
|
+
* Subscribes to an event that will be triggered only once.
|
|
1631
|
+
*
|
|
1632
|
+
* @template Args - The type of arguments the event callback will receive.
|
|
1633
|
+
* @param {string} eventName - The name of the event to subscribe to.
|
|
1634
|
+
* @param {(...args: Args) => void} callback - The callback function to execute when the event is triggered.
|
|
1635
|
+
* @returns {EventUnsubscribe} - A function to unsubscribe from the event.
|
|
1636
|
+
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
1637
|
+
*/
|
|
1638
|
+
once<Args extends Array<unknown> = unknown[]>(eventName: string, callback: (...args: Args) => void): EventUnsubscribe;
|
|
1639
|
+
/**
|
|
1640
|
+
* Subscribes to connection errors.
|
|
1641
|
+
*
|
|
1642
|
+
* @param {ActorErrorCallback} callback - The callback function to execute when a connection error occurs.
|
|
1643
|
+
* @returns {() => void} - A function to unsubscribe from the error handler.
|
|
1644
|
+
*/
|
|
1645
|
+
onError(callback: ActorErrorCallback): () => void;
|
|
1646
|
+
/**
|
|
1647
|
+
* Disconnects from the actor.
|
|
1648
|
+
*
|
|
1649
|
+
* @returns {Promise<void>} A promise that resolves when the socket is gracefully closed.
|
|
1650
|
+
*/
|
|
1651
|
+
dispose(): Promise<void>;
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Connection to a actor. Allows calling actor's remote procedure calls with inferred types. See {@link ActorConnRaw} for underlying methods.
|
|
1655
|
+
*
|
|
1656
|
+
* @example
|
|
1657
|
+
* ```
|
|
1658
|
+
* const room = client.connect<ChatRoom>(...etc...);
|
|
1659
|
+
* // This calls the action named `sendMessage` on the `ChatRoom` actor.
|
|
1660
|
+
* await room.sendMessage('Hello, world!');
|
|
1661
|
+
* ```
|
|
1662
|
+
*
|
|
1663
|
+
* Private methods (e.g. those starting with `_`) are automatically excluded.
|
|
1664
|
+
*
|
|
1665
|
+
* @template AD The actor class that this connection is for.
|
|
1666
|
+
* @see {@link ActorConnRaw}
|
|
1667
|
+
*/
|
|
1668
|
+
type ActorConn<AD extends AnyActorDefinition> = ActorConnRaw & ActorDefinitionActions<AD>;
|
|
1669
|
+
|
|
1670
|
+
/**
|
|
1671
|
+
* Provides underlying functions for stateless {@link ActorHandle} for action calls.
|
|
1672
|
+
* Similar to ActorConnRaw but doesn't maintain a connection.
|
|
1673
|
+
*
|
|
1674
|
+
* @see {@link ActorHandle}
|
|
1675
|
+
*/
|
|
1676
|
+
declare class ActorHandleRaw {
|
|
1677
|
+
#private;
|
|
1678
|
+
/**
|
|
1679
|
+
* Do not call this directly.
|
|
1680
|
+
*
|
|
1681
|
+
* Creates an instance of ActorHandleRaw.
|
|
1682
|
+
*
|
|
1683
|
+
* @protected
|
|
1684
|
+
*/
|
|
1685
|
+
constructor(client: any, driver: ManagerDriver, params: unknown, encoding: Encoding, actorQuery: ActorQuery);
|
|
1686
|
+
/**
|
|
1687
|
+
* Call a raw action. This method sends an HTTP request to invoke the named action.
|
|
1688
|
+
*
|
|
1689
|
+
* @see {@link ActorHandle}
|
|
1690
|
+
* @template Args - The type of arguments to pass to the action function.
|
|
1691
|
+
* @template Response - The type of the response returned by the action function.
|
|
1692
|
+
*/
|
|
1693
|
+
action<Args extends Array<unknown> = unknown[], Response = unknown>(opts: {
|
|
1694
|
+
name: string;
|
|
1695
|
+
args: Args;
|
|
1696
|
+
signal?: AbortSignal;
|
|
1697
|
+
}): Promise<Response>;
|
|
1698
|
+
/**
|
|
1699
|
+
* Establishes a persistent connection to the actor.
|
|
1700
|
+
*
|
|
1701
|
+
* @template AD The actor class that this connection is for.
|
|
1702
|
+
* @returns {ActorConn<AD>} A connection to the actor.
|
|
1703
|
+
*/
|
|
1704
|
+
connect(): ActorConn<AnyActorDefinition>;
|
|
1705
|
+
/**
|
|
1706
|
+
* Makes a raw HTTP request to the actor.
|
|
1707
|
+
*
|
|
1708
|
+
* @param input - The URL, path, or Request object
|
|
1709
|
+
* @param init - Standard fetch RequestInit options
|
|
1710
|
+
* @returns Promise<Response> - The raw HTTP response
|
|
1711
|
+
*/
|
|
1712
|
+
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
1713
|
+
/**
|
|
1714
|
+
* Creates a raw WebSocket connection to the actor.
|
|
1715
|
+
*
|
|
1716
|
+
* @param path - The path for the WebSocket connection (e.g., "stream")
|
|
1717
|
+
* @param protocols - Optional WebSocket subprotocols
|
|
1718
|
+
* @returns WebSocket - A raw WebSocket connection
|
|
1719
|
+
*/
|
|
1720
|
+
websocket(path?: string, protocols?: string | string[]): Promise<WebSocket>;
|
|
1721
|
+
/**
|
|
1722
|
+
* Resolves the actor to get its unique actor ID
|
|
1723
|
+
*
|
|
1724
|
+
* @returns {Promise<string>} - A promise that resolves to the actor's ID
|
|
1725
|
+
*/
|
|
1726
|
+
resolve({ signal }?: {
|
|
1727
|
+
signal?: AbortSignal;
|
|
1728
|
+
}): Promise<string>;
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Stateless handle to a actor. Allows calling actor's remote procedure calls with inferred types
|
|
1732
|
+
* without establishing a persistent connection.
|
|
1733
|
+
*
|
|
1734
|
+
* @example
|
|
1735
|
+
* ```
|
|
1736
|
+
* const room = client.get<ChatRoom>(...etc...);
|
|
1737
|
+
* // This calls the action named `sendMessage` on the `ChatRoom` actor without a connection.
|
|
1738
|
+
* await room.sendMessage('Hello, world!');
|
|
1739
|
+
* ```
|
|
1740
|
+
*
|
|
1741
|
+
* Private methods (e.g. those starting with `_`) are automatically excluded.
|
|
1742
|
+
*
|
|
1743
|
+
* @template AD The actor class that this handle is for.
|
|
1744
|
+
* @see {@link ActorHandleRaw}
|
|
1745
|
+
*/
|
|
1746
|
+
type ActorHandle<AD extends AnyActorDefinition> = Omit<ActorHandleRaw, "connect"> & {
|
|
1747
|
+
connect(): ActorConn<AD>;
|
|
1748
|
+
resolve(): Promise<string>;
|
|
1749
|
+
} & ActorDefinitionActions<AD>;
|
|
1750
|
+
|
|
1751
|
+
/** Extract the actor registry from the registry definition. */
|
|
1752
|
+
type ExtractActorsFromRegistry<A extends Registry<any>> = A extends Registry<infer Actors> ? Actors : never;
|
|
1753
|
+
/** Extract the registry definition from the client. */
|
|
1754
|
+
type ExtractRegistryFromClient<C extends Client<Registry<{}>>> = C extends Client<infer A> ? A : never;
|
|
1755
|
+
/**
|
|
1756
|
+
* Represents a actor accessor that provides methods to interact with a specific actor.
|
|
1757
|
+
*/
|
|
1758
|
+
interface ActorAccessor<AD extends AnyActorDefinition> {
|
|
1759
|
+
/**
|
|
1760
|
+
* Gets a stateless handle to a actor by its key, but does not create the actor if it doesn't exist.
|
|
1761
|
+
* The actor name is automatically injected from the property accessor.
|
|
1762
|
+
*
|
|
1763
|
+
* @template AD The actor class that this handle is for.
|
|
1764
|
+
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
1765
|
+
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
1766
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1767
|
+
*/
|
|
1768
|
+
get(key?: string | string[], opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
1769
|
+
/**
|
|
1770
|
+
* Gets a stateless handle to a actor by its key, creating it if necessary.
|
|
1771
|
+
* The actor name is automatically injected from the property accessor.
|
|
1772
|
+
*
|
|
1773
|
+
* @template AD The actor class that this handle is for.
|
|
1774
|
+
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
1775
|
+
* @param {GetOptions} [opts] - Options for getting the actor.
|
|
1776
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1777
|
+
*/
|
|
1778
|
+
getOrCreate(key?: string | string[], opts?: GetOrCreateOptions): ActorHandle<AD>;
|
|
1779
|
+
/**
|
|
1780
|
+
* Gets a stateless handle to a actor by its ID.
|
|
1781
|
+
*
|
|
1782
|
+
* @template AD The actor class that this handle is for.
|
|
1783
|
+
* @param {string} actorId - The ID of the actor.
|
|
1784
|
+
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
1785
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1786
|
+
*/
|
|
1787
|
+
getForId(actorId: string, opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
1788
|
+
/**
|
|
1789
|
+
* Creates a new actor with the name automatically injected from the property accessor,
|
|
1790
|
+
* and returns a stateless handle to it with the actor ID resolved.
|
|
1791
|
+
*
|
|
1792
|
+
* @template AD The actor class that this handle is for.
|
|
1793
|
+
* @param {string | string[]} key - The key to identify the actor. Can be a single string or an array of strings.
|
|
1794
|
+
* @param {CreateOptions} [opts] - Options for creating the actor (excluding name and key).
|
|
1795
|
+
* @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the actor.
|
|
1796
|
+
*/
|
|
1797
|
+
create(key?: string | string[], opts?: CreateOptions): Promise<ActorHandle<AD>>;
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* Options for querying actors.
|
|
1801
|
+
* @typedef {Object} QueryOptions
|
|
1802
|
+
* @property {unknown} [parameters] - Parameters to pass to the connection.
|
|
1803
|
+
*/
|
|
1804
|
+
interface QueryOptions {
|
|
1805
|
+
/** Parameters to pass to the connection. */
|
|
1806
|
+
params?: unknown;
|
|
1807
|
+
/** Signal to abort the request. */
|
|
1808
|
+
signal?: AbortSignal;
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* Options for getting a actor by ID.
|
|
1812
|
+
* @typedef {QueryOptions} GetWithIdOptions
|
|
1813
|
+
*/
|
|
1814
|
+
interface GetWithIdOptions extends QueryOptions {
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Options for getting a actor.
|
|
1818
|
+
* @typedef {QueryOptions} GetOptions
|
|
1819
|
+
*/
|
|
1820
|
+
interface GetOptions extends QueryOptions {
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Options for getting or creating a actor.
|
|
1824
|
+
* @typedef {QueryOptions} GetOrCreateOptions
|
|
1825
|
+
* @property {string} [createInRegion] - Region to create the actor in if it doesn't exist.
|
|
1826
|
+
*/
|
|
1827
|
+
interface GetOrCreateOptions extends QueryOptions {
|
|
1828
|
+
/** Region to create the actor in if it doesn't exist. */
|
|
1829
|
+
createInRegion?: string;
|
|
1830
|
+
/** Input data to pass to the actor. */
|
|
1831
|
+
createWithInput?: unknown;
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Options for creating a actor.
|
|
1835
|
+
* @typedef {QueryOptions} CreateOptions
|
|
1836
|
+
* @property {string} [region] - The region to create the actor in.
|
|
1837
|
+
*/
|
|
1838
|
+
interface CreateOptions extends QueryOptions {
|
|
1839
|
+
/** The region to create the actor in. */
|
|
1840
|
+
region?: string;
|
|
1841
|
+
/** Input data to pass to the actor. */
|
|
1842
|
+
input?: unknown;
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* Represents a region to connect to.
|
|
1846
|
+
* @typedef {Object} Region
|
|
1847
|
+
* @property {string} id - The region ID.
|
|
1848
|
+
* @property {string} name - The region name.
|
|
1849
|
+
* @see {@link https://rivet.dev/docs/edge|Edge Networking}
|
|
1850
|
+
* @see {@link https://rivet.dev/docs/regions|Available Regions}
|
|
1851
|
+
*/
|
|
1852
|
+
interface Region {
|
|
1853
|
+
/**
|
|
1854
|
+
* The region slug.
|
|
1855
|
+
*/
|
|
1856
|
+
id: string;
|
|
1857
|
+
/**
|
|
1858
|
+
* The human-friendly region name.
|
|
1859
|
+
*/
|
|
1860
|
+
name: string;
|
|
1861
|
+
}
|
|
1862
|
+
declare const ACTOR_CONNS_SYMBOL: unique symbol;
|
|
1863
|
+
declare const CREATE_ACTOR_CONN_PROXY: unique symbol;
|
|
1864
|
+
declare const TRANSPORT_SYMBOL: unique symbol;
|
|
1865
|
+
/**
|
|
1866
|
+
* Client for managing & connecting to actors.
|
|
1867
|
+
*
|
|
1868
|
+
* @template A The actors map type that defines the available actors.
|
|
1869
|
+
* @see {@link https://rivet.dev/docs/manage|Create & Manage Actors}
|
|
1870
|
+
*/
|
|
1871
|
+
declare class ClientRaw {
|
|
1872
|
+
#private;
|
|
1873
|
+
[ACTOR_CONNS_SYMBOL]: Set<ActorConnRaw>;
|
|
1874
|
+
[TRANSPORT_SYMBOL]: Transport;
|
|
1875
|
+
/**
|
|
1876
|
+
* Creates an instance of Client.
|
|
1877
|
+
*
|
|
1878
|
+
* @param {string} managerEndpoint - The manager endpoint. See {@link https://rivet.dev/docs/setup|Initial Setup} for instructions on getting the manager endpoint.
|
|
1879
|
+
* @param {ClientConfig} [opts] - Options for configuring the client.
|
|
1880
|
+
* @see {@link https://rivet.dev/docs/setup|Initial Setup}
|
|
1881
|
+
*/
|
|
1882
|
+
constructor(driver: ManagerDriver, opts?: ClientConfig);
|
|
1883
|
+
/**
|
|
1884
|
+
* Gets a stateless handle to a actor by its ID.
|
|
1885
|
+
*
|
|
1886
|
+
* @template AD The actor class that this handle is for.
|
|
1887
|
+
* @param {string} name - The name of the actor.
|
|
1888
|
+
* @param {string} actorId - The ID of the actor.
|
|
1889
|
+
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
1890
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1891
|
+
*/
|
|
1892
|
+
getForId<AD extends AnyActorDefinition>(name: string, actorId: string, opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
1893
|
+
/**
|
|
1894
|
+
* Gets a stateless handle to a actor by its key, but does not create the actor if it doesn't exist.
|
|
1895
|
+
*
|
|
1896
|
+
* @template AD The actor class that this handle is for.
|
|
1897
|
+
* @param {string} name - The name of the actor.
|
|
1898
|
+
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
1899
|
+
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
1900
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1901
|
+
*/
|
|
1902
|
+
get<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
1903
|
+
/**
|
|
1904
|
+
* Gets a stateless handle to a actor by its key, creating it if necessary.
|
|
1905
|
+
*
|
|
1906
|
+
* @template AD The actor class that this handle is for.
|
|
1907
|
+
* @param {string} name - The name of the actor.
|
|
1908
|
+
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
1909
|
+
* @param {GetOptions} [opts] - Options for getting the actor.
|
|
1910
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1911
|
+
*/
|
|
1912
|
+
getOrCreate<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: GetOrCreateOptions): ActorHandle<AD>;
|
|
1913
|
+
/**
|
|
1914
|
+
* Creates a new actor with the provided key and returns a stateless handle to it.
|
|
1915
|
+
* Resolves the actor ID and returns a handle with getForId query.
|
|
1916
|
+
*
|
|
1917
|
+
* @template AD The actor class that this handle is for.
|
|
1918
|
+
* @param {string} name - The name of the actor.
|
|
1919
|
+
* @param {string | string[]} key - The key to identify the actor. Can be a single string or an array of strings.
|
|
1920
|
+
* @param {CreateOptions} [opts] - Options for creating the actor (excluding name and key).
|
|
1921
|
+
* @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the actor.
|
|
1922
|
+
*/
|
|
1923
|
+
create<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: CreateOptions): Promise<ActorHandle<AD>>;
|
|
1924
|
+
[CREATE_ACTOR_CONN_PROXY]<AD extends AnyActorDefinition>(conn: ActorConnRaw): ActorConn<AD>;
|
|
1925
|
+
/**
|
|
1926
|
+
* Disconnects from all actors.
|
|
1927
|
+
*
|
|
1928
|
+
* @returns {Promise<void>} A promise that resolves when all connections are closed.
|
|
1929
|
+
*/
|
|
1930
|
+
dispose(): Promise<void>;
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Client type with actor accessors.
|
|
1934
|
+
* This adds property accessors for actor names to the ClientRaw base class.
|
|
1935
|
+
*
|
|
1936
|
+
* @template A The actor registry type.
|
|
1937
|
+
*/
|
|
1938
|
+
type Client<A extends Registry<any>> = ClientRaw & {
|
|
1939
|
+
[K in keyof ExtractActorsFromRegistry<A>]: ActorAccessor<ExtractActorsFromRegistry<A>[K]>;
|
|
1940
|
+
};
|
|
1941
|
+
type AnyClient = Client<Registry<any>>;
|
|
1942
|
+
declare function createClientWithDriver<A extends Registry<any>>(driver: ManagerDriver, config?: ClientConfig): Client<A>;
|
|
1943
|
+
|
|
1944
|
+
type ConnectionDriversMap = Record<ConnectionDriver, ConnDriver>;
|
|
1945
|
+
type ActorDriverBuilder = (registryConfig: RegistryConfig, runConfig: RunConfig, managerDriver: ManagerDriver, inlineClient: AnyClient) => ActorDriver;
|
|
1946
|
+
interface ActorDriver {
|
|
1947
|
+
loadActor(actorId: string): Promise<AnyActorInstance>;
|
|
1948
|
+
getGenericConnGlobalState(actorId: string): GenericConnGlobalState;
|
|
1949
|
+
getContext(actorId: string): unknown;
|
|
1950
|
+
readPersistedData(actorId: string): Promise<Uint8Array | undefined>;
|
|
1951
|
+
/** ActorInstance ensure that only one instance of writePersistedData is called in parallel at a time. */
|
|
1952
|
+
writePersistedData(actorId: string, data: Uint8Array): Promise<void>;
|
|
1953
|
+
/** ActorInstance ensure that only one instance of setAlarm is called in parallel at a time. */
|
|
1954
|
+
setAlarm(actor: AnyActorInstance, timestamp: number): Promise<void>;
|
|
1955
|
+
/**
|
|
1956
|
+
* @experimental
|
|
1957
|
+
* This is an experimental API that may change in the future.
|
|
1958
|
+
*/
|
|
1959
|
+
getDatabase(actorId: string): Promise<unknown | undefined>;
|
|
1960
|
+
sleep?(actorId: string): Promise<void>;
|
|
1961
|
+
shutdown?(immediate: boolean): Promise<void>;
|
|
1962
|
+
}
|
|
1963
|
+
declare enum ConnectionReadyState {
|
|
1964
|
+
UNKNOWN = -1,
|
|
1965
|
+
CONNECTING = 0,
|
|
1966
|
+
OPEN = 1,
|
|
1967
|
+
CLOSING = 2,
|
|
1968
|
+
CLOSED = 3
|
|
1969
|
+
}
|
|
1970
|
+
interface ConnDriver<ConnDriverState = unknown> {
|
|
1971
|
+
sendMessage?(actor: AnyActorInstance, conn: AnyConn, state: ConnDriverState, message: CachedSerializer<ToClient>): void;
|
|
1972
|
+
/**
|
|
1973
|
+
* This returns a promise since we commonly disconnect at the end of a program, and not waiting will cause the socket to not close cleanly.
|
|
1974
|
+
*/
|
|
1975
|
+
disconnect(actor: AnyActorInstance, conn: AnyConn, state: ConnDriverState, reason?: string): Promise<void>;
|
|
1976
|
+
/**
|
|
1977
|
+
* Returns the ready state of the connection.
|
|
1978
|
+
* This is used to determine if the connection is ready to send messages, or if the connection is stale.
|
|
1979
|
+
*/
|
|
1980
|
+
getConnectionReadyState(actor: AnyActorInstance, conn: AnyConn): ConnectionReadyState | undefined;
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
/** Object representing connection that gets persisted to storage. */
|
|
1984
|
+
interface PersistedConn<CP, CS> {
|
|
1985
|
+
connId: string;
|
|
1986
|
+
token: string;
|
|
1987
|
+
connDriver: ConnectionDriver;
|
|
1988
|
+
connDriverState: unknown;
|
|
1989
|
+
params: CP;
|
|
1990
|
+
state: CS;
|
|
1991
|
+
authData?: unknown;
|
|
1992
|
+
subscriptions: PersistedSubscription[];
|
|
1993
|
+
lastSeen: number;
|
|
1994
|
+
}
|
|
1995
|
+
interface PersistedSubscription {
|
|
1996
|
+
eventName: string;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
declare function generateConnId(): string;
|
|
2000
|
+
declare function generateConnToken(): string;
|
|
2001
|
+
type ConnId = string;
|
|
2002
|
+
type AnyConn = Conn<any, any, any, any, any, any>;
|
|
2003
|
+
declare const CONNECTION_DRIVER_WEBSOCKET = "webSocket";
|
|
2004
|
+
declare const CONNECTION_DRIVER_SSE = "sse";
|
|
2005
|
+
declare const CONNECTION_DRIVER_HTTP = "http";
|
|
2006
|
+
type ConnectionDriver = typeof CONNECTION_DRIVER_WEBSOCKET | typeof CONNECTION_DRIVER_SSE | typeof CONNECTION_DRIVER_HTTP;
|
|
2007
|
+
type ConnectionStatus = "connected" | "reconnecting";
|
|
2008
|
+
/**
|
|
2009
|
+
* Represents a client connection to a actor.
|
|
2010
|
+
*
|
|
2011
|
+
* Manages connection-specific data and controls the connection lifecycle.
|
|
2012
|
+
*
|
|
2013
|
+
* @see {@link https://rivet.dev/docs/connections|Connection Documentation}
|
|
2014
|
+
*/
|
|
2015
|
+
declare class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
2016
|
+
#private;
|
|
2017
|
+
subscriptions: Set<string>;
|
|
2018
|
+
/**
|
|
2019
|
+
* The proxied state that notifies of changes automatically.
|
|
2020
|
+
*
|
|
2021
|
+
* Any data that should be stored indefinitely should be held within this object.
|
|
2022
|
+
*/
|
|
2023
|
+
__persist: PersistedConn<CP, CS>;
|
|
2024
|
+
get params(): CP;
|
|
2025
|
+
get driver(): ConnectionDriver;
|
|
2026
|
+
get _stateEnabled(): boolean;
|
|
2027
|
+
/**
|
|
2028
|
+
* Gets the current state of the connection.
|
|
2029
|
+
*
|
|
2030
|
+
* Throws an error if the state is not enabled.
|
|
2031
|
+
*/
|
|
2032
|
+
get state(): CS;
|
|
2033
|
+
/**
|
|
2034
|
+
* Sets the state of the connection.
|
|
2035
|
+
*
|
|
2036
|
+
* Throws an error if the state is not enabled.
|
|
2037
|
+
*/
|
|
2038
|
+
set state(value: CS);
|
|
2039
|
+
/**
|
|
2040
|
+
* Unique identifier for the connection.
|
|
2041
|
+
*/
|
|
2042
|
+
get id(): ConnId;
|
|
2043
|
+
/**
|
|
2044
|
+
* Token used to authenticate this request.
|
|
2045
|
+
*/
|
|
2046
|
+
get _token(): string;
|
|
2047
|
+
/**
|
|
2048
|
+
* Status of the connection.
|
|
2049
|
+
*/
|
|
2050
|
+
get status(): ConnectionStatus;
|
|
2051
|
+
/**
|
|
2052
|
+
* Timestamp of the last time the connection was seen, i.e. the last time the connection was active and checked for liveness.
|
|
2053
|
+
*/
|
|
2054
|
+
get lastSeen(): number;
|
|
2055
|
+
/**
|
|
2056
|
+
* Initializes a new instance of the Connection class.
|
|
2057
|
+
*
|
|
2058
|
+
* This should only be constructed by {@link Actor}.
|
|
2059
|
+
*
|
|
2060
|
+
* @protected
|
|
2061
|
+
*/
|
|
2062
|
+
constructor(actor: ActorInstance<S, CP, CS, V, I, DB>, persist: PersistedConn<CP, CS>, driver: ConnDriver, stateEnabled: boolean);
|
|
2063
|
+
/**
|
|
2064
|
+
* Sends a WebSocket message to the client.
|
|
2065
|
+
*
|
|
2066
|
+
* @param message - The message to send.
|
|
2067
|
+
*
|
|
2068
|
+
* @protected
|
|
2069
|
+
*/
|
|
2070
|
+
_sendMessage(message: CachedSerializer<ToClient>): void;
|
|
2071
|
+
/**
|
|
2072
|
+
* Sends an event with arguments to the client.
|
|
2073
|
+
*
|
|
2074
|
+
* @param eventName - The name of the event.
|
|
2075
|
+
* @param args - The arguments for the event.
|
|
2076
|
+
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
2077
|
+
*/
|
|
2078
|
+
send(eventName: string, ...args: unknown[]): void;
|
|
2079
|
+
/**
|
|
2080
|
+
* Disconnects the client with an optional reason.
|
|
2081
|
+
*
|
|
2082
|
+
* @param reason - The reason for disconnection.
|
|
2083
|
+
*/
|
|
2084
|
+
disconnect(reason?: string): Promise<void>;
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
export { type CreateRequest as $, type ActorDriver as A, type AnyActorInstance as B, type Client as C, type DriverConfig as D, type Encoding as E, type ActorTypes as F, GenericConnGlobalState as G, ActorConfigSchema as H, type InitContext as I, type AuthIntent as J, type ActorConfig as K, test as L, type RegistryConfig as M, type RegistryActors as N, type OnConnectOptions as O, RegistryConfigSchema as P, Registry as Q, type RunConfig as R, setup as S, type ClientConfigInput as T, type UniversalWebSocket as U, type Transport as V, ActorClientError as W, ActorError as X, InternalError as Y, MalformedResponseMessage as Z, ManagerError as _, type AnyDatabaseProvider as a, type ActorActionFunction as a0, type ActorConn as a1, type EventUnsubscribe as a2, ActorConnRaw as a3, type ActorHandle as a4, ActorHandleRaw as a5, type ActorAccessor as a6, ClientRaw as a7, type CreateOptions as a8, type ExtractActorsFromRegistry as a9, type ExtractRegistryFromClient as aa, type GetOptions as ab, type GetWithIdOptions as ac, type QueryOptions as ad, type Region as ae, ActorInstance as af, type ActorOutput as ag, type CreateInput as ah, type GetForIdInput as ai, type GetOrCreateWithKeyInput as aj, type GetWithKeyInput as ak, type ManagerDisplayInformation as al, type ManagerDriver as am, DriverConfigSchema as an, RunConfigSchema as ao, type Actions as b, type ActorConfigInput as c, ActorDefinition as d, generateConnToken as e, type AnyClient as f, generateConnId as g, createClientWithDriver as h, type ActorQuery as i, type RivetCloseEvent as j, type RivetEvent as k, type RivetMessageEvent as l, type ActorKey as m, ActionContext as n, Conn as o, type ConnectionDriver as p, type ConnectionStatus as q, CONNECTION_DRIVER_HTTP as r, CONNECTION_DRIVER_SSE as s, CONNECTION_DRIVER_WEBSOCKET as t, ActorContext as u, type ActionContextOf as v, type ActorContextOf as w, type AnyActorDefinition as x, lookupInRegistry as y, createGenericConnDrivers as z };
|