rivetkit 2.0.3 → 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 +11 -0
- package/dist/schemas/actor-persist/v1.ts +21 -24
- package/dist/schemas/client-protocol/v1.ts +6 -0
- package/dist/tsup/actor/errors.cjs +10 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +17 -4
- package/dist/tsup/actor/errors.d.ts +17 -4
- package/dist/tsup/actor/errors.js +11 -3
- package/dist/tsup/{chunk-6PDXBYI5.js → chunk-3F2YSRJL.js} +8 -23
- 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-OGAPU3UG.cjs → chunk-6LJT3QRL.cjs} +39 -25
- package/dist/tsup/chunk-6LJT3QRL.cjs.map +1 -0
- package/dist/tsup/{chunk-6WKQDDUD.cjs → chunk-GICQ3YCU.cjs} +143 -141
- package/dist/tsup/chunk-GICQ3YCU.cjs.map +1 -0
- package/dist/tsup/{chunk-FLMTTN27.js → chunk-H26RP6GD.js} +15 -8
- 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-4NSUQZ2H.js → chunk-HLLF4B4Q.js} +116 -114
- package/dist/tsup/chunk-HLLF4B4Q.js.map +1 -0
- package/dist/tsup/{chunk-FCCPJNMA.cjs → chunk-IH6CKNDW.cjs} +12 -27
- 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-R2OPSKIV.cjs → chunk-LWNKVZG5.cjs} +20 -13
- package/dist/tsup/chunk-LWNKVZG5.cjs.map +1 -0
- package/dist/tsup/{chunk-INGJP237.js → chunk-NFU2BBT5.js} +102 -43
- package/dist/tsup/chunk-NFU2BBT5.js.map +1 -0
- package/dist/tsup/{chunk-3H7O2A7I.js → chunk-PQY7KKTL.js} +33 -19
- package/dist/tsup/chunk-PQY7KKTL.js.map +1 -0
- package/dist/tsup/{chunk-PO4VLDWA.js → chunk-QK72M5JB.js} +3 -5
- package/dist/tsup/chunk-QK72M5JB.js.map +1 -0
- package/dist/tsup/{chunk-TZJKSBUQ.cjs → chunk-QNNXFOQV.cjs} +3 -5
- package/dist/tsup/chunk-QNNXFOQV.cjs.map +1 -0
- package/dist/tsup/{chunk-GIR3AFFI.cjs → chunk-SBHHJ6QS.cjs} +102 -43
- 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 +10 -10
- package/dist/tsup/client/mod.d.cts +7 -13
- package/dist/tsup/client/mod.d.ts +7 -13
- package/dist/tsup/client/mod.js +9 -9
- package/dist/tsup/common/log.cjs +12 -4
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.d.cts +23 -17
- package/dist/tsup/common/log.d.ts +23 -17
- package/dist/tsup/common/log.js +15 -7
- package/dist/tsup/common/websocket.cjs +5 -5
- package/dist/tsup/common/websocket.js +4 -4
- package/dist/tsup/{common-CpqORuCq.d.cts → common-CXCe7s6i.d.cts} +2 -2
- package/dist/tsup/{common-CpqORuCq.d.ts → common-CXCe7s6i.d.ts} +2 -2
- package/dist/tsup/{connection-BwUMoe6n.d.ts → connection-BI-6UIBJ.d.ts} +196 -226
- package/dist/tsup/{connection-BR_Ve4ku.d.cts → connection-Dyd4NLGW.d.cts} +196 -226
- package/dist/tsup/driver-helpers/mod.cjs +6 -9
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +5 -6
- package/dist/tsup/driver-helpers/mod.d.ts +5 -6
- package/dist/tsup/driver-helpers/mod.js +6 -9
- package/dist/tsup/driver-test-suite/mod.cjs +155 -1363
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +11 -5
- package/dist/tsup/driver-test-suite/mod.d.ts +11 -5
- package/dist/tsup/driver-test-suite/mod.js +876 -2084
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +6 -8
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +3 -3
- package/dist/tsup/inspector/mod.d.ts +3 -3
- package/dist/tsup/inspector/mod.js +8 -10
- package/dist/tsup/mod.cjs +9 -15
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +47 -42
- package/dist/tsup/mod.d.ts +47 -42
- package/dist/tsup/mod.js +10 -16
- package/dist/tsup/{router-endpoints-DAbqVFx2.d.ts → router-endpoints-BTe_Rsdn.d.cts} +2 -3
- package/dist/tsup/{router-endpoints-AYkXG8Tl.d.cts → router-endpoints-CBSrKHmo.d.ts} +2 -3
- package/dist/tsup/test/mod.cjs +10 -14
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -5
- package/dist/tsup/test/mod.d.ts +4 -5
- package/dist/tsup/test/mod.js +9 -13
- package/dist/tsup/{utils-CT0cv4jd.d.ts → utils-fwx3o3K9.d.cts} +1 -0
- package/dist/tsup/{utils-CT0cv4jd.d.cts → utils-fwx3o3K9.d.ts} +1 -0
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/package.json +4 -4
- package/src/actor/action.ts +1 -5
- package/src/actor/config.ts +27 -295
- package/src/actor/connection.ts +9 -12
- package/src/actor/context.ts +1 -4
- package/src/actor/definition.ts +7 -11
- package/src/actor/errors.ts +97 -35
- package/src/actor/generic-conn-driver.ts +28 -16
- package/src/actor/instance.ts +177 -133
- package/src/actor/log.ts +4 -13
- package/src/actor/mod.ts +0 -5
- package/src/actor/protocol/old.ts +42 -26
- package/src/actor/protocol/serde.ts +1 -1
- package/src/actor/router-endpoints.ts +41 -38
- package/src/actor/router.ts +20 -18
- package/src/actor/unstable-react.ts +1 -1
- package/src/actor/utils.ts +6 -2
- package/src/client/actor-common.ts +1 -1
- package/src/client/actor-conn.ts +152 -91
- package/src/client/actor-handle.ts +85 -25
- package/src/client/actor-query.ts +65 -0
- package/src/client/client.ts +29 -98
- package/src/client/config.ts +44 -0
- package/src/client/errors.ts +1 -0
- package/src/client/log.ts +2 -4
- package/src/client/mod.ts +16 -12
- package/src/client/raw-utils.ts +82 -25
- package/src/client/utils.ts +5 -3
- package/src/common/fake-event-source.ts +10 -9
- package/src/common/inline-websocket-adapter2.ts +39 -30
- package/src/common/log.ts +176 -101
- package/src/common/logfmt.ts +21 -30
- package/src/common/router.ts +12 -19
- package/src/common/utils.ts +27 -13
- package/src/common/websocket.ts +0 -1
- package/src/driver-helpers/mod.ts +1 -1
- package/src/driver-test-suite/log.ts +1 -3
- package/src/driver-test-suite/mod.ts +86 -60
- package/src/driver-test-suite/tests/actor-handle.ts +33 -0
- package/src/driver-test-suite/tests/manager-driver.ts +5 -3
- package/src/driver-test-suite/tests/raw-http-direct-registry.ts +227 -226
- package/src/driver-test-suite/tests/raw-websocket-direct-registry.ts +393 -392
- package/src/driver-test-suite/tests/request-access.ts +112 -126
- package/src/driver-test-suite/utils.ts +13 -10
- package/src/drivers/default.ts +7 -4
- package/src/drivers/engine/actor-driver.ts +22 -13
- package/src/drivers/engine/config.ts +2 -10
- package/src/drivers/engine/kv.ts +1 -1
- package/src/drivers/engine/log.ts +1 -3
- package/src/drivers/engine/mod.ts +2 -3
- package/src/drivers/file-system/actor.ts +1 -1
- package/src/drivers/file-system/global-state.ts +33 -20
- package/src/drivers/file-system/log.ts +1 -3
- package/src/drivers/file-system/manager.ts +31 -8
- package/src/inspector/config.ts +9 -4
- package/src/inspector/log.ts +1 -1
- package/src/inspector/manager.ts +2 -2
- package/src/inspector/utils.ts +1 -1
- package/src/manager/driver.ts +10 -2
- package/src/manager/hono-websocket-adapter.ts +21 -12
- package/src/manager/log.ts +2 -4
- package/src/manager/mod.ts +1 -1
- package/src/manager/router.ts +277 -1657
- 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 +0 -2
- package/src/registry/config.ts +1 -1
- package/src/registry/log.ts +2 -4
- package/src/registry/mod.ts +57 -24
- package/src/registry/run-config.ts +31 -33
- package/src/registry/serve.ts +4 -5
- 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/{drivers/engine → remote-manager-driver}/ws-proxy.ts +24 -14
- package/src/serde.ts +8 -2
- package/src/test/log.ts +1 -3
- package/src/test/mod.ts +17 -16
- package/dist/tsup/chunk-2CRLFV6Z.cjs +0 -202
- package/dist/tsup/chunk-2CRLFV6Z.cjs.map +0 -1
- package/dist/tsup/chunk-3H7O2A7I.js.map +0 -1
- package/dist/tsup/chunk-42I3OZ3Q.js +0 -15
- package/dist/tsup/chunk-42I3OZ3Q.js.map +0 -1
- package/dist/tsup/chunk-4NSUQZ2H.js.map +0 -1
- package/dist/tsup/chunk-6PDXBYI5.js.map +0 -1
- package/dist/tsup/chunk-6WKQDDUD.cjs.map +0 -1
- package/dist/tsup/chunk-CTBOSFUH.cjs +0 -116
- package/dist/tsup/chunk-CTBOSFUH.cjs.map +0 -1
- package/dist/tsup/chunk-EGVZZFE2.js +0 -2857
- package/dist/tsup/chunk-EGVZZFE2.js.map +0 -1
- package/dist/tsup/chunk-FCCPJNMA.cjs.map +0 -1
- package/dist/tsup/chunk-FLMTTN27.js.map +0 -1
- package/dist/tsup/chunk-GIR3AFFI.cjs.map +0 -1
- package/dist/tsup/chunk-INGJP237.js.map +0 -1
- package/dist/tsup/chunk-KJCJLKRM.js +0 -116
- package/dist/tsup/chunk-KJCJLKRM.js.map +0 -1
- package/dist/tsup/chunk-KUPQZYUQ.cjs +0 -15
- package/dist/tsup/chunk-KUPQZYUQ.cjs.map +0 -1
- package/dist/tsup/chunk-O2MBYIXO.cjs +0 -2857
- package/dist/tsup/chunk-O2MBYIXO.cjs.map +0 -1
- package/dist/tsup/chunk-OGAPU3UG.cjs.map +0 -1
- package/dist/tsup/chunk-OV6AYD4S.js +0 -4406
- package/dist/tsup/chunk-OV6AYD4S.js.map +0 -1
- package/dist/tsup/chunk-PO4VLDWA.js.map +0 -1
- package/dist/tsup/chunk-R2OPSKIV.cjs.map +0 -1
- package/dist/tsup/chunk-TZJKSBUQ.cjs.map +0 -1
- package/dist/tsup/chunk-UBUC5C3G.cjs +0 -189
- package/dist/tsup/chunk-UBUC5C3G.cjs.map +0 -1
- package/dist/tsup/chunk-UIM22YJL.cjs +0 -4406
- package/dist/tsup/chunk-UIM22YJL.cjs.map +0 -1
- package/dist/tsup/chunk-URVFQMYI.cjs +0 -230
- package/dist/tsup/chunk-URVFQMYI.cjs.map +0 -1
- package/dist/tsup/chunk-UVUPOS46.js +0 -230
- package/dist/tsup/chunk-UVUPOS46.js.map +0 -1
- package/dist/tsup/chunk-VRRHBNJC.js +0 -189
- package/dist/tsup/chunk-VRRHBNJC.js.map +0 -1
- package/dist/tsup/chunk-XFSS33EQ.js +0 -202
- package/dist/tsup/chunk-XFSS33EQ.js.map +0 -1
- package/src/client/http-client-driver.ts +0 -326
- package/src/driver-test-suite/test-inline-client-driver.ts +0 -402
- package/src/driver-test-suite/tests/actor-auth.ts +0 -591
- package/src/drivers/engine/api-endpoints.ts +0 -128
- package/src/drivers/engine/api-utils.ts +0 -70
- package/src/drivers/engine/manager-driver.ts +0 -391
- package/src/inline-client-driver/log.ts +0 -7
- package/src/inline-client-driver/mod.ts +0 -385
- package/src/manager/auth.ts +0 -121
- /package/src/{drivers/engine → actor}/keys.test.ts +0 -0
- /package/src/{drivers/engine → actor}/keys.ts +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import z$1, { z } from 'zod';
|
|
2
|
+
import { Logger } from 'pino';
|
|
2
3
|
import * as hono from 'hono';
|
|
3
4
|
import { Env, Context, Hono } from 'hono';
|
|
4
|
-
import { WebSocket as WebSocket$1 } from 'ws';
|
|
5
|
-
import { Logger } from './common/log.js';
|
|
6
5
|
import { UpgradeWebSocket } from './utils.js';
|
|
7
6
|
import * as nanoevents from 'nanoevents';
|
|
8
|
-
import { g as Connection, h as RealtimeEvent } from './common-
|
|
7
|
+
import { g as Connection, h as RealtimeEvent } from './common-CXCe7s6i.js';
|
|
9
8
|
import { SSEStreamingApi } from 'hono/streaming';
|
|
10
9
|
import { WSContext } from 'hono/ws';
|
|
11
10
|
|
|
@@ -16,6 +15,7 @@ type Init = {
|
|
|
16
15
|
readonly connectionToken: string;
|
|
17
16
|
};
|
|
18
17
|
type Error$1 = {
|
|
18
|
+
readonly group: string;
|
|
19
19
|
readonly code: string;
|
|
20
20
|
readonly message: string;
|
|
21
21
|
readonly metadata: ArrayBuffer | null;
|
|
@@ -121,7 +121,7 @@ declare class CachedSerializer<T> {
|
|
|
121
121
|
serialize(encoding: Encoding): OutputData;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
declare const ActorsSchema: z.ZodRecord<z.ZodString, z.ZodType<ActorDefinition<any, any, any, any, any, any, any
|
|
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
125
|
type RegistryActors = z.infer<typeof ActorsSchema>;
|
|
126
126
|
/** Base config used for the actor config across all platforms. */
|
|
127
127
|
declare const RegistryConfigSchema: z.ZodObject<{
|
|
@@ -194,6 +194,52 @@ interface UniversalWebSocket {
|
|
|
194
194
|
onmessage?: ((event: RivetMessageEvent) => void) | null;
|
|
195
195
|
}
|
|
196
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
|
+
|
|
197
243
|
type ManagerDriverBuilder = (registryConfig: RegistryConfig, runConfig: RunConfig) => ManagerDriver;
|
|
198
244
|
interface ManagerDriver {
|
|
199
245
|
getForId(input: GetForIdInput): Promise<ActorOutput | undefined>;
|
|
@@ -201,12 +247,17 @@ interface ManagerDriver {
|
|
|
201
247
|
getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise<ActorOutput>;
|
|
202
248
|
createActor(input: CreateInput): Promise<ActorOutput>;
|
|
203
249
|
sendRequest(actorId: string, actorRequest: Request): Promise<Response>;
|
|
204
|
-
openWebSocket(path: string, actorId: string, encoding: Encoding, params: unknown): Promise<
|
|
250
|
+
openWebSocket(path: string, actorId: string, encoding: Encoding, params: unknown): Promise<UniversalWebSocket>;
|
|
205
251
|
proxyRequest(c: Context, actorRequest: Request, actorId: string): Promise<Response>;
|
|
206
252
|
proxyWebSocket(c: Context, path: string, actorId: string, encoding: Encoding, params: unknown, authData: unknown): Promise<Response>;
|
|
253
|
+
displayInformation(): ManagerDisplayInformation;
|
|
207
254
|
extraStartupLog?: () => Record<string, unknown>;
|
|
208
255
|
modifyManagerRouter?: (registryConfig: RegistryConfig, router: Hono) => void;
|
|
209
256
|
}
|
|
257
|
+
interface ManagerDisplayInformation {
|
|
258
|
+
name: string;
|
|
259
|
+
properties: Record<string, string>;
|
|
260
|
+
}
|
|
210
261
|
interface GetForIdInput<E extends Env = any> {
|
|
211
262
|
c?: Context | undefined;
|
|
212
263
|
name: string;
|
|
@@ -237,7 +288,6 @@ interface ActorOutput {
|
|
|
237
288
|
key: ActorKey;
|
|
238
289
|
}
|
|
239
290
|
|
|
240
|
-
type GetUpgradeWebSocket = () => UpgradeWebSocket;
|
|
241
291
|
declare const DriverConfigSchema: z.ZodObject<{
|
|
242
292
|
/** Machine-readable name to identify this driver by. */
|
|
243
293
|
name: z.ZodString;
|
|
@@ -255,6 +305,23 @@ declare const DriverConfigSchema: z.ZodObject<{
|
|
|
255
305
|
type DriverConfig = z.infer<typeof DriverConfigSchema>;
|
|
256
306
|
/** Base config used for the actor config across all platforms. */
|
|
257
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
|
+
} & {
|
|
258
325
|
driver: z.ZodOptional<z.ZodObject<{
|
|
259
326
|
/** Machine-readable name to identify this driver by. */
|
|
260
327
|
name: z.ZodString;
|
|
@@ -269,10 +336,6 @@ declare const RunConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
269
336
|
name: string;
|
|
270
337
|
manager: ManagerDriverBuilder;
|
|
271
338
|
}>>;
|
|
272
|
-
/** Endpoint to connect to the Rivet engine. Can be configured via RIVET_ENGINE env var. */
|
|
273
|
-
engine: z.ZodOptional<z.ZodString>;
|
|
274
|
-
getUpgradeWebSocket: z.ZodOptional<z.ZodType<GetUpgradeWebSocket, z.ZodTypeDef, GetUpgradeWebSocket>>;
|
|
275
|
-
role: z.ZodDefault<z.ZodOptional<z.ZodEnum<["all", "server", "runner"]>>>;
|
|
276
339
|
/** CORS configuration for the router. Uses Hono's CORS middleware options. */
|
|
277
340
|
cors: z.ZodOptional<z.ZodType<{
|
|
278
341
|
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
@@ -340,7 +403,20 @@ declare const RunConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
340
403
|
* available at `/api/actors`.
|
|
341
404
|
*/
|
|
342
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
|
+
}>>>;
|
|
343
418
|
}, "strip", z.ZodTypeAny, {
|
|
419
|
+
encoding: "json" | "cbor" | "bare";
|
|
344
420
|
inspector: {
|
|
345
421
|
enabled: boolean;
|
|
346
422
|
cors: {
|
|
@@ -354,9 +430,26 @@ declare const RunConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
354
430
|
token: (...args: unknown[]) => string;
|
|
355
431
|
defaultEndpoint?: string | undefined;
|
|
356
432
|
};
|
|
357
|
-
|
|
433
|
+
api: {
|
|
434
|
+
host: string;
|
|
435
|
+
port: number;
|
|
436
|
+
};
|
|
437
|
+
endpoint: string | null;
|
|
438
|
+
namespace: string;
|
|
439
|
+
runnerName: string;
|
|
440
|
+
transport: "websocket" | "sse";
|
|
358
441
|
maxIncomingMessageSize: number;
|
|
359
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;
|
|
360
453
|
cors?: {
|
|
361
454
|
origin: string | string[] | ((origin: string, c: hono.Context) => string | undefined | null);
|
|
362
455
|
allowMethods?: string[] | ((origin: string, c: hono.Context) => string[]);
|
|
@@ -365,14 +458,14 @@ declare const RunConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
365
458
|
credentials?: boolean;
|
|
366
459
|
exposeHeaders?: string[];
|
|
367
460
|
} | undefined;
|
|
461
|
+
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
462
|
+
}, {
|
|
463
|
+
encoding?: "json" | "cbor" | "bare" | undefined;
|
|
368
464
|
driver?: {
|
|
369
465
|
actor: ActorDriverBuilder;
|
|
370
466
|
name: string;
|
|
371
467
|
manager: ManagerDriverBuilder;
|
|
372
468
|
} | undefined;
|
|
373
|
-
engine?: string | undefined;
|
|
374
|
-
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
375
|
-
}, {
|
|
376
469
|
inspector?: {
|
|
377
470
|
enabled?: boolean | undefined;
|
|
378
471
|
cors?: {
|
|
@@ -394,21 +487,29 @@ declare const RunConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
394
487
|
credentials?: boolean;
|
|
395
488
|
exposeHeaders?: string[];
|
|
396
489
|
} | undefined;
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
manager: ManagerDriverBuilder;
|
|
490
|
+
api?: {
|
|
491
|
+
host?: string | undefined;
|
|
492
|
+
port?: number | undefined;
|
|
401
493
|
} | undefined;
|
|
402
|
-
|
|
494
|
+
endpoint?: string | null | undefined;
|
|
495
|
+
namespace?: string | undefined;
|
|
496
|
+
runnerName?: string | undefined;
|
|
497
|
+
transport?: "websocket" | "sse" | undefined;
|
|
403
498
|
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
404
|
-
role?: "all" | "server" | "runner" | undefined;
|
|
405
499
|
maxIncomingMessageSize?: number | undefined;
|
|
406
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;
|
|
407
506
|
}>>;
|
|
408
507
|
type RunConfig = z.infer<typeof RunConfigSchema>;
|
|
409
508
|
type RunConfigInput = z.input<typeof RunConfigSchema>;
|
|
410
509
|
|
|
411
510
|
interface ServerOutput<A extends Registry<any>> {
|
|
511
|
+
config: RunConfig;
|
|
512
|
+
driver: DriverConfig;
|
|
412
513
|
client: Client<A>;
|
|
413
514
|
hono: Hono;
|
|
414
515
|
handler: (req: Request) => Promise<Response>;
|
|
@@ -498,10 +599,10 @@ interface SaveStateOptions {
|
|
|
498
599
|
allowStoppingState?: boolean;
|
|
499
600
|
}
|
|
500
601
|
/** Actor type alias with all `any` types. Used for `extends` in classes referencing this actor. */
|
|
501
|
-
type AnyActorInstance = ActorInstance<any, any, any, any, any, any
|
|
502
|
-
declare class ActorInstance<S, CP, CS, V, I,
|
|
602
|
+
type AnyActorInstance = ActorInstance<any, any, any, any, any, any>;
|
|
603
|
+
declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
503
604
|
#private;
|
|
504
|
-
actorContext: ActorContext<S, CP, CS, V, I,
|
|
605
|
+
actorContext: ActorContext<S, CP, CS, V, I, DB>;
|
|
505
606
|
get isStopping(): boolean;
|
|
506
607
|
get id(): string;
|
|
507
608
|
get inlineClient(): Client<Registry<any>>;
|
|
@@ -513,23 +614,23 @@ declare class ActorInstance<S, CP, CS, V, I, AD, DB extends AnyDatabaseProvider>
|
|
|
513
614
|
*
|
|
514
615
|
* @private
|
|
515
616
|
*/
|
|
516
|
-
constructor(config: ActorConfig<S, CP, CS, V, I,
|
|
617
|
+
constructor(config: ActorConfig<S, CP, CS, V, I, DB>);
|
|
517
618
|
start(connectionDrivers: ConnectionDriversMap, actorDriver: ActorDriver, inlineClient: Client<Registry<any>>, actorId: string, name: string, key: ActorKey, region: string): Promise<void>;
|
|
518
619
|
_onAlarm(): Promise<void>;
|
|
519
620
|
scheduleEvent(timestamp: number, action: string, args: unknown[]): Promise<void>;
|
|
520
621
|
get stateEnabled(): boolean;
|
|
521
|
-
__getConnForId(id: string): Conn<S, CP, CS, V, I,
|
|
622
|
+
__getConnForId(id: string): Conn<S, CP, CS, V, I, DB> | undefined;
|
|
522
623
|
/**
|
|
523
624
|
* Removes a connection and cleans up its resources.
|
|
524
625
|
*/
|
|
525
|
-
__removeConn(conn: Conn<S, CP, CS, V, I,
|
|
626
|
+
__removeConn(conn: Conn<S, CP, CS, V, I, DB> | undefined): void;
|
|
526
627
|
prepareConn(params: any, request?: Request): Promise<CS>;
|
|
527
628
|
__getConnDriver(driverId: ConnectionDriver): ConnDriver;
|
|
528
629
|
/**
|
|
529
630
|
* Called after establishing a connection handshake.
|
|
530
631
|
*/
|
|
531
|
-
createConn(connectionId: string, connectionToken: string, params: CP, state: CS, driverId: ConnectionDriver, driverState: unknown, authData: unknown): Promise<Conn<S, CP, CS, V, I,
|
|
532
|
-
processMessage(message: ToServer, conn: Conn<S, CP, CS, V, I,
|
|
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>;
|
|
533
634
|
/**
|
|
534
635
|
* Check if the actor is ready to handle requests.
|
|
535
636
|
*/
|
|
@@ -541,20 +642,15 @@ declare class ActorInstance<S, CP, CS, V, I, AD, DB extends AnyDatabaseProvider>
|
|
|
541
642
|
/**
|
|
542
643
|
* Handles raw HTTP requests to the actor.
|
|
543
644
|
*/
|
|
544
|
-
handleFetch(request: Request, opts: {
|
|
545
|
-
auth: AD;
|
|
546
|
-
}): Promise<Response>;
|
|
645
|
+
handleFetch(request: Request, opts: {}): Promise<Response>;
|
|
547
646
|
/**
|
|
548
647
|
* Handles raw WebSocket connections to the actor.
|
|
549
648
|
*/
|
|
550
649
|
handleWebSocket(websocket: UniversalWebSocket, opts: {
|
|
551
650
|
request: Request;
|
|
552
|
-
auth: AD;
|
|
553
651
|
}): Promise<void>;
|
|
554
|
-
/**
|
|
555
|
-
* Gets the logger instance.
|
|
556
|
-
*/
|
|
557
652
|
get log(): Logger;
|
|
653
|
+
get rLog(): Logger;
|
|
558
654
|
/**
|
|
559
655
|
* Gets the name.
|
|
560
656
|
*/
|
|
@@ -574,7 +670,7 @@ declare class ActorInstance<S, CP, CS, V, I, AD, DB extends AnyDatabaseProvider>
|
|
|
574
670
|
/**
|
|
575
671
|
* Gets the map of connections.
|
|
576
672
|
*/
|
|
577
|
-
get conns(): Map<ConnId, Conn<S, CP, CS, V, I,
|
|
673
|
+
get conns(): Map<ConnId, Conn<S, CP, CS, V, I, DB>>;
|
|
578
674
|
/**
|
|
579
675
|
* Gets the current state.
|
|
580
676
|
*
|
|
@@ -628,9 +724,9 @@ declare class ActorInstance<S, CP, CS, V, I, AD, DB extends AnyDatabaseProvider>
|
|
|
628
724
|
/**
|
|
629
725
|
* ActorContext class that provides access to actor methods and state
|
|
630
726
|
*/
|
|
631
|
-
declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
727
|
+
declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> {
|
|
632
728
|
#private;
|
|
633
|
-
constructor(actor: ActorInstance<TState, TConnParams, TConnState, TVars, TInput,
|
|
729
|
+
constructor(actor: ActorInstance<TState, TConnParams, TConnState, TVars, TInput, TDatabase>);
|
|
634
730
|
/**
|
|
635
731
|
* Get the actor state
|
|
636
732
|
*/
|
|
@@ -672,7 +768,7 @@ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TAuth
|
|
|
672
768
|
/**
|
|
673
769
|
* Gets the map of connections.
|
|
674
770
|
*/
|
|
675
|
-
get conns(): Map<ConnId, Conn<TState, TConnParams, TConnState, TVars, TInput,
|
|
771
|
+
get conns(): Map<ConnId, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>>;
|
|
676
772
|
/**
|
|
677
773
|
* Returns the client for the given registry.
|
|
678
774
|
*/
|
|
@@ -707,18 +803,16 @@ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TAuth
|
|
|
707
803
|
sleep(): void;
|
|
708
804
|
}
|
|
709
805
|
|
|
710
|
-
type InitContext = ActorContext<undefined, undefined, undefined, undefined, undefined, undefined
|
|
711
|
-
interface ActorTypes<TState, TConnParams, TConnState, TVars, TInput,
|
|
806
|
+
type InitContext = ActorContext<undefined, undefined, undefined, undefined, undefined, undefined>;
|
|
807
|
+
interface ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> {
|
|
712
808
|
state?: TState;
|
|
713
809
|
connParams?: TConnParams;
|
|
714
810
|
connState?: TConnState;
|
|
715
811
|
vars?: TVars;
|
|
716
812
|
input?: TInput;
|
|
717
|
-
authData?: TAuthData;
|
|
718
813
|
database?: TDatabase;
|
|
719
814
|
}
|
|
720
815
|
declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
721
|
-
onAuth: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
722
816
|
onCreate: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
723
817
|
onStart: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
724
818
|
onStop: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
@@ -791,7 +885,6 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
791
885
|
actions: Record<string, (...args: unknown[]) => unknown>;
|
|
792
886
|
state?: any;
|
|
793
887
|
db?: any;
|
|
794
|
-
onAuth?: ((...args: unknown[]) => unknown) | undefined;
|
|
795
888
|
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
796
889
|
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
797
890
|
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
@@ -808,6 +901,7 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
808
901
|
vars?: any;
|
|
809
902
|
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
810
903
|
}, {
|
|
904
|
+
state?: any;
|
|
811
905
|
options?: {
|
|
812
906
|
createVarsTimeout?: number | undefined;
|
|
813
907
|
createConnStateTimeout?: number | undefined;
|
|
@@ -821,9 +915,7 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
821
915
|
noSleep?: boolean | undefined;
|
|
822
916
|
sleepTimeout?: number | undefined;
|
|
823
917
|
} | undefined;
|
|
824
|
-
state?: any;
|
|
825
918
|
db?: any;
|
|
826
|
-
onAuth?: ((...args: unknown[]) => unknown) | undefined;
|
|
827
919
|
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
828
920
|
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
829
921
|
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
@@ -857,7 +949,6 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
857
949
|
actions: Record<string, (...args: unknown[]) => unknown>;
|
|
858
950
|
state?: any;
|
|
859
951
|
db?: any;
|
|
860
|
-
onAuth?: ((...args: unknown[]) => unknown) | undefined;
|
|
861
952
|
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
862
953
|
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
863
954
|
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
@@ -874,6 +965,7 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
874
965
|
vars?: any;
|
|
875
966
|
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
876
967
|
}, {
|
|
968
|
+
state?: any;
|
|
877
969
|
options?: {
|
|
878
970
|
createVarsTimeout?: number | undefined;
|
|
879
971
|
createConnStateTimeout?: number | undefined;
|
|
@@ -887,9 +979,7 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
887
979
|
noSleep?: boolean | undefined;
|
|
888
980
|
sleepTimeout?: number | undefined;
|
|
889
981
|
} | undefined;
|
|
890
|
-
state?: any;
|
|
891
982
|
db?: any;
|
|
892
|
-
onAuth?: ((...args: unknown[]) => unknown) | undefined;
|
|
893
983
|
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
894
984
|
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
895
985
|
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
@@ -923,7 +1013,6 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
923
1013
|
actions: Record<string, (...args: unknown[]) => unknown>;
|
|
924
1014
|
state?: any;
|
|
925
1015
|
db?: any;
|
|
926
|
-
onAuth?: ((...args: unknown[]) => unknown) | undefined;
|
|
927
1016
|
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
928
1017
|
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
929
1018
|
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
@@ -940,6 +1029,7 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
940
1029
|
vars?: any;
|
|
941
1030
|
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
942
1031
|
}, {
|
|
1032
|
+
state?: any;
|
|
943
1033
|
options?: {
|
|
944
1034
|
createVarsTimeout?: number | undefined;
|
|
945
1035
|
createConnStateTimeout?: number | undefined;
|
|
@@ -953,9 +1043,7 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
953
1043
|
noSleep?: boolean | undefined;
|
|
954
1044
|
sleepTimeout?: number | undefined;
|
|
955
1045
|
} | undefined;
|
|
956
|
-
state?: any;
|
|
957
1046
|
db?: any;
|
|
958
|
-
onAuth?: ((...args: unknown[]) => unknown) | undefined;
|
|
959
1047
|
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
960
1048
|
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
961
1049
|
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
@@ -989,7 +1077,6 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
989
1077
|
actions: Record<string, (...args: unknown[]) => unknown>;
|
|
990
1078
|
state?: any;
|
|
991
1079
|
db?: any;
|
|
992
|
-
onAuth?: ((...args: unknown[]) => unknown) | undefined;
|
|
993
1080
|
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
994
1081
|
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
995
1082
|
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
@@ -1006,6 +1093,7 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
1006
1093
|
vars?: any;
|
|
1007
1094
|
createVars?: ((...args: unknown[]) => unknown) | undefined;
|
|
1008
1095
|
}, {
|
|
1096
|
+
state?: any;
|
|
1009
1097
|
options?: {
|
|
1010
1098
|
createVarsTimeout?: number | undefined;
|
|
1011
1099
|
createConnStateTimeout?: number | undefined;
|
|
@@ -1019,9 +1107,7 @@ declare const ActorConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObj
|
|
|
1019
1107
|
noSleep?: boolean | undefined;
|
|
1020
1108
|
sleepTimeout?: number | undefined;
|
|
1021
1109
|
} | undefined;
|
|
1022
|
-
state?: any;
|
|
1023
1110
|
db?: any;
|
|
1024
|
-
onAuth?: ((...args: unknown[]) => unknown) | undefined;
|
|
1025
1111
|
onCreate?: ((...args: unknown[]) => unknown) | undefined;
|
|
1026
1112
|
onStart?: ((...args: unknown[]) => unknown) | undefined;
|
|
1027
1113
|
onStop?: ((...args: unknown[]) => unknown) | undefined;
|
|
@@ -1047,12 +1133,12 @@ interface OnConnectOptions {
|
|
|
1047
1133
|
*/
|
|
1048
1134
|
request?: Request;
|
|
1049
1135
|
}
|
|
1050
|
-
type CreateState<TState, TConnParams, TConnState, TVars, TInput,
|
|
1136
|
+
type CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> = {
|
|
1051
1137
|
state: TState;
|
|
1052
1138
|
} | {
|
|
1053
1139
|
createState: (c: InitContext, input: TInput) => TState | Promise<TState>;
|
|
1054
1140
|
} | Record<never, never>;
|
|
1055
|
-
type CreateConnState<TState, TConnParams, TConnState, TVars, TInput,
|
|
1141
|
+
type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> = {
|
|
1056
1142
|
connState: TConnState;
|
|
1057
1143
|
} | {
|
|
1058
1144
|
createConnState: (c: InitContext, opts: OnConnectOptions, params: TConnParams) => TConnState | Promise<TConnState>;
|
|
@@ -1060,7 +1146,7 @@ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TAuthData,
|
|
|
1060
1146
|
/**
|
|
1061
1147
|
* @experimental
|
|
1062
1148
|
*/
|
|
1063
|
-
type CreateVars<TState, TConnParams, TConnState, TVars, TInput,
|
|
1149
|
+
type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase> = {
|
|
1064
1150
|
/**
|
|
1065
1151
|
* @experimental
|
|
1066
1152
|
*/
|
|
@@ -1071,56 +1157,21 @@ type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TAuthData, TData
|
|
|
1071
1157
|
*/
|
|
1072
1158
|
createVars: (c: InitContext, driverCtx: any) => TVars | Promise<TVars>;
|
|
1073
1159
|
} | Record<never, never>;
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
* Called on the HTTP server before clients can interact with the actor.
|
|
1077
|
-
*
|
|
1078
|
-
* Only called for public endpoints. Calls to actors from within the backend
|
|
1079
|
-
* do not trigger this handler.
|
|
1080
|
-
*
|
|
1081
|
-
* Data returned from this handler will be available on `c.conn.auth`.
|
|
1082
|
-
*
|
|
1083
|
-
* This function is required for any public HTTP endpoint access. Use this hook
|
|
1084
|
-
* to validate client credentials and return authentication data that will be
|
|
1085
|
-
* available on connections. This runs on the HTTP server (not the actor)
|
|
1086
|
-
* in order to reduce load on the actor & prevent denial of server attacks
|
|
1087
|
-
* against individual actors.
|
|
1088
|
-
*
|
|
1089
|
-
* If you need access to actor state for authentication, use onBeforeConnect
|
|
1090
|
-
* with an empty onAuth function instead.
|
|
1091
|
-
*
|
|
1092
|
-
* You can also provide your own authentication middleware on your router if you
|
|
1093
|
-
* choose, then use onAuth to pass the authentication data (e.g. user ID) to the
|
|
1094
|
-
* actor itself.
|
|
1095
|
-
*
|
|
1096
|
-
* @param opts Authentication options including request and intent
|
|
1097
|
-
* @returns Authentication data to attach to connections (must be serializable)
|
|
1098
|
-
* @throws Throw an error to deny access to the actor
|
|
1099
|
-
*/
|
|
1100
|
-
onAuth: (opts: OnAuthOptions, params: TConnParams) => TAuthData | Promise<TAuthData>;
|
|
1101
|
-
} | Record<never, never>;
|
|
1102
|
-
interface Actions<TState, TConnParams, TConnState, TVars, TInput, TAuthData, TDatabase extends AnyDatabaseProvider> {
|
|
1103
|
-
[Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TAuthData, TDatabase>, ...args: any[]) => any;
|
|
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;
|
|
1104
1162
|
}
|
|
1105
1163
|
/**
|
|
1106
1164
|
* @experimental
|
|
1107
1165
|
*/
|
|
1108
1166
|
type AuthIntent = "get" | "create" | "connect" | "action" | "message";
|
|
1109
|
-
interface
|
|
1110
|
-
request: Request;
|
|
1111
|
-
/**
|
|
1112
|
-
* @experimental
|
|
1113
|
-
*/
|
|
1114
|
-
intents: Set<AuthIntent>;
|
|
1115
|
-
}
|
|
1116
|
-
interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TAuthData, TDatabase extends AnyDatabaseProvider, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TAuthData, TDatabase>> {
|
|
1167
|
+
interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase>> {
|
|
1117
1168
|
/**
|
|
1118
1169
|
* Called when the actor is first initialized.
|
|
1119
1170
|
*
|
|
1120
1171
|
* Use this hook to initialize your actor's state.
|
|
1121
1172
|
* This is called before any other lifecycle hooks.
|
|
1122
1173
|
*/
|
|
1123
|
-
onCreate?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1174
|
+
onCreate?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, input: TInput) => void | Promise<void>;
|
|
1124
1175
|
/**
|
|
1125
1176
|
* Called when the actor is started and ready to receive connections and action.
|
|
1126
1177
|
*
|
|
@@ -1129,7 +1180,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TAuthD
|
|
|
1129
1180
|
*
|
|
1130
1181
|
* @returns Void or a Promise that resolves when startup is complete
|
|
1131
1182
|
*/
|
|
1132
|
-
onStart?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1183
|
+
onStart?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
1133
1184
|
/**
|
|
1134
1185
|
* Called when the actor is stopping or sleeping.
|
|
1135
1186
|
*
|
|
@@ -1140,7 +1191,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TAuthD
|
|
|
1140
1191
|
*
|
|
1141
1192
|
* @returns Void or a Promise that resolves when shutdown is complete
|
|
1142
1193
|
*/
|
|
1143
|
-
onStop?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1194
|
+
onStop?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
1144
1195
|
/**
|
|
1145
1196
|
* Called when the actor's state changes.
|
|
1146
1197
|
*
|
|
@@ -1152,28 +1203,18 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TAuthD
|
|
|
1152
1203
|
*
|
|
1153
1204
|
* @param newState The updated state
|
|
1154
1205
|
*/
|
|
1155
|
-
onStateChange?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1206
|
+
onStateChange?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, newState: TState) => void;
|
|
1156
1207
|
/**
|
|
1157
1208
|
* Called before a client connects to the actor.
|
|
1158
1209
|
*
|
|
1159
|
-
* Unlike onAuth, this handler is still called for both internal and
|
|
1160
|
-
* public clients.
|
|
1161
|
-
*
|
|
1162
1210
|
* Use this hook to determine if a connection should be accepted
|
|
1163
|
-
* and to initialize connection-specific state.
|
|
1164
|
-
* on the actor and has access to actor state, but uses slightly
|
|
1165
|
-
* more resources on the actor rather than authenticating with onAuth.
|
|
1166
|
-
*
|
|
1167
|
-
* For authentication without actor state access, prefer onAuth.
|
|
1168
|
-
*
|
|
1169
|
-
* For authentication with actor state, use onBeforeConnect with an empty
|
|
1170
|
-
* onAuth handler.
|
|
1211
|
+
* and to initialize connection-specific state.
|
|
1171
1212
|
*
|
|
1172
1213
|
* @param opts Connection parameters including client-provided data
|
|
1173
1214
|
* @returns The initial connection state or a Promise that resolves to it
|
|
1174
1215
|
* @throws Throw an error to reject the connection
|
|
1175
1216
|
*/
|
|
1176
|
-
onBeforeConnect?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1217
|
+
onBeforeConnect?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, opts: OnConnectOptions, params: TConnParams) => void | Promise<void>;
|
|
1177
1218
|
/**
|
|
1178
1219
|
* Called when a client successfully connects to the actor.
|
|
1179
1220
|
*
|
|
@@ -1183,7 +1224,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TAuthD
|
|
|
1183
1224
|
* @param conn The connection object
|
|
1184
1225
|
* @returns Void or a Promise that resolves when connection handling is complete
|
|
1185
1226
|
*/
|
|
1186
|
-
onConnect?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1227
|
+
onConnect?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
1187
1228
|
/**
|
|
1188
1229
|
* Called when a client disconnects from the actor.
|
|
1189
1230
|
*
|
|
@@ -1193,7 +1234,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TAuthD
|
|
|
1193
1234
|
* @param conn The connection that is being closed
|
|
1194
1235
|
* @returns Void or a Promise that resolves when disconnect handling is complete
|
|
1195
1236
|
*/
|
|
1196
|
-
onDisconnect?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1237
|
+
onDisconnect?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
1197
1238
|
/**
|
|
1198
1239
|
* Called before sending an action response to the client.
|
|
1199
1240
|
*
|
|
@@ -1206,7 +1247,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TAuthD
|
|
|
1206
1247
|
* @param output The output that will be sent to the client
|
|
1207
1248
|
* @returns The modified output to send to the client
|
|
1208
1249
|
*/
|
|
1209
|
-
onBeforeActionResponse?: <Out>(c: ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1250
|
+
onBeforeActionResponse?: <Out>(c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, name: string, args: unknown[], output: Out) => Out | Promise<Out>;
|
|
1210
1251
|
/**
|
|
1211
1252
|
* Called when a raw HTTP request is made to the actor.
|
|
1212
1253
|
*
|
|
@@ -1216,9 +1257,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TAuthD
|
|
|
1216
1257
|
* @param request The raw HTTP request object
|
|
1217
1258
|
* @returns A Response object to send back, or void to continue with default routing
|
|
1218
1259
|
*/
|
|
1219
|
-
onFetch?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1220
|
-
auth: TAuthData;
|
|
1221
|
-
}) => Response | Promise<Response>;
|
|
1260
|
+
onFetch?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, request: Request, opts: {}) => Response | Promise<Response>;
|
|
1222
1261
|
/**
|
|
1223
1262
|
* Called when a raw WebSocket connection is established to the actor.
|
|
1224
1263
|
*
|
|
@@ -1228,9 +1267,8 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TAuthD
|
|
|
1228
1267
|
* @param websocket The raw WebSocket connection
|
|
1229
1268
|
* @param request The original HTTP upgrade request
|
|
1230
1269
|
*/
|
|
1231
|
-
onWebSocket?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1270
|
+
onWebSocket?: (c: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, websocket: UniversalWebSocket, opts: {
|
|
1232
1271
|
request: Request;
|
|
1233
|
-
auth: TAuthData;
|
|
1234
1272
|
}) => void | Promise<void>;
|
|
1235
1273
|
actions: TActions;
|
|
1236
1274
|
}
|
|
@@ -1240,48 +1278,11 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
|
|
|
1240
1278
|
*/
|
|
1241
1279
|
db: TDatabase;
|
|
1242
1280
|
} | Record<never, never>;
|
|
1243
|
-
type ActorConfig<TState, TConnParams, TConnState, TVars, TInput,
|
|
1244
|
-
type ActorConfigInput<TState = undefined, TConnParams = undefined, TConnState = undefined, TVars = undefined, TInput = undefined,
|
|
1245
|
-
types?: ActorTypes<TState, TConnParams, TConnState, TVars, TInput,
|
|
1246
|
-
} & Omit<z.input<typeof ActorConfigSchema>, "actions" | "
|
|
1247
|
-
declare function test<TState, TConnParams, TConnState, TVars, TInput,
|
|
1248
|
-
|
|
1249
|
-
interface UniversalEvent {
|
|
1250
|
-
type: string;
|
|
1251
|
-
target?: any;
|
|
1252
|
-
currentTarget?: any;
|
|
1253
|
-
}
|
|
1254
|
-
interface UniversalMessageEvent extends UniversalEvent {
|
|
1255
|
-
data: string;
|
|
1256
|
-
lastEventId: string;
|
|
1257
|
-
origin: string;
|
|
1258
|
-
}
|
|
1259
|
-
interface UniversalErrorEvent extends UniversalEvent {
|
|
1260
|
-
message: string;
|
|
1261
|
-
filename?: string;
|
|
1262
|
-
lineno?: number;
|
|
1263
|
-
colno?: number;
|
|
1264
|
-
error?: any;
|
|
1265
|
-
}
|
|
1266
|
-
/**
|
|
1267
|
-
* Common EventSource interface that can be implemented by different EventSource-like classes
|
|
1268
|
-
* This is compatible with the standard EventSource API but allows for custom implementations
|
|
1269
|
-
*/
|
|
1270
|
-
interface UniversalEventSource {
|
|
1271
|
-
readonly CONNECTING: 0;
|
|
1272
|
-
readonly OPEN: 1;
|
|
1273
|
-
readonly CLOSED: 2;
|
|
1274
|
-
readonly readyState: 0 | 1 | 2;
|
|
1275
|
-
readonly url: string;
|
|
1276
|
-
readonly withCredentials: boolean;
|
|
1277
|
-
close(): void;
|
|
1278
|
-
addEventListener(type: string, listener: (event: any) => void): void;
|
|
1279
|
-
removeEventListener(type: string, listener: (event: any) => void): void;
|
|
1280
|
-
dispatchEvent(event: UniversalEvent): boolean;
|
|
1281
|
-
onopen?: ((event: UniversalEvent) => void) | null;
|
|
1282
|
-
onmessage?: ((event: UniversalMessageEvent) => void) | null;
|
|
1283
|
-
onerror?: ((event: UniversalErrorEvent) => void) | null;
|
|
1284
|
-
}
|
|
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>;
|
|
1285
1286
|
|
|
1286
1287
|
declare const ActorKeySchema: z.ZodArray<z.ZodString, "many">;
|
|
1287
1288
|
type ActorKey = z.infer<typeof ActorKeySchema>;
|
|
@@ -1426,16 +1427,16 @@ declare function createGenericConnDrivers(globalState: GenericConnGlobalState):
|
|
|
1426
1427
|
*
|
|
1427
1428
|
* @typeParam A Actor this action belongs to
|
|
1428
1429
|
*/
|
|
1429
|
-
declare class ActionContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1430
|
+
declare class ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> {
|
|
1430
1431
|
#private;
|
|
1431
|
-
readonly conn: Conn<TState, TConnParams, TConnState, TVars, TInput,
|
|
1432
|
+
readonly conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
|
|
1432
1433
|
/**
|
|
1433
1434
|
* Should not be called directly.
|
|
1434
1435
|
*
|
|
1435
1436
|
* @param actorContext - The actor context
|
|
1436
1437
|
* @param conn - The connection associated with the action
|
|
1437
1438
|
*/
|
|
1438
|
-
constructor(actorContext: ActorContext<TState, TConnParams, TConnState, TVars, TInput,
|
|
1439
|
+
constructor(actorContext: ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>);
|
|
1439
1440
|
/**
|
|
1440
1441
|
* Get the actor state
|
|
1441
1442
|
*/
|
|
@@ -1475,7 +1476,7 @@ declare class ActionContext<TState, TConnParams, TConnState, TVars, TInput, TAut
|
|
|
1475
1476
|
/**
|
|
1476
1477
|
* Gets the map of connections.
|
|
1477
1478
|
*/
|
|
1478
|
-
get conns(): Map<ConnId, Conn<TState, TConnParams, TConnState, TVars, TInput,
|
|
1479
|
+
get conns(): Map<ConnId, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>>;
|
|
1479
1480
|
/**
|
|
1480
1481
|
* Returns the client for the given registry.
|
|
1481
1482
|
*/
|
|
@@ -1506,20 +1507,20 @@ declare class ActionContext<TState, TConnParams, TConnState, TVars, TInput, TAut
|
|
|
1506
1507
|
sleep(): void;
|
|
1507
1508
|
}
|
|
1508
1509
|
|
|
1509
|
-
type AnyActorDefinition = ActorDefinition<any, any, any, any, any, any, any
|
|
1510
|
+
type AnyActorDefinition = ActorDefinition<any, any, any, any, any, any, any>;
|
|
1510
1511
|
/**
|
|
1511
1512
|
* Extracts the context type from an ActorDefinition
|
|
1512
1513
|
*/
|
|
1513
|
-
type ActorContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer
|
|
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;
|
|
1514
1515
|
/**
|
|
1515
1516
|
* Extracts the context type from an ActorDefinition
|
|
1516
1517
|
*/
|
|
1517
|
-
type ActionContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer
|
|
1518
|
-
declare class ActorDefinition<S, CP, CS, V, I,
|
|
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>> {
|
|
1519
1520
|
#private;
|
|
1520
|
-
constructor(config: ActorConfig<S, CP, CS, V, I,
|
|
1521
|
-
get config(): ActorConfig<S, CP, CS, V, I,
|
|
1522
|
-
instantiate(): ActorInstance<S, CP, CS, V, I,
|
|
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>;
|
|
1523
1524
|
}
|
|
1524
1525
|
declare function lookupInRegistry(registryConfig: RegistryConfig, name: string): AnyActorDefinition;
|
|
1525
1526
|
|
|
@@ -1542,7 +1543,7 @@ type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unk
|
|
|
1542
1543
|
/**
|
|
1543
1544
|
* Maps action methods from actor definition to typed function signatures.
|
|
1544
1545
|
*/
|
|
1545
|
-
type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends ActorDefinition<any, any, any, any, any, any,
|
|
1546
|
+
type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends ActorDefinition<any, any, any, any, any, any, infer R> ? {
|
|
1546
1547
|
[K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
|
|
1547
1548
|
} : never;
|
|
1548
1549
|
|
|
@@ -1557,10 +1558,11 @@ declare class MalformedResponseMessage extends ActorClientError {
|
|
|
1557
1558
|
constructor(cause?: unknown);
|
|
1558
1559
|
}
|
|
1559
1560
|
declare class ActorError extends ActorClientError {
|
|
1561
|
+
readonly group: string;
|
|
1560
1562
|
readonly code: string;
|
|
1561
1563
|
readonly metadata?: unknown | undefined;
|
|
1562
1564
|
__type: string;
|
|
1563
|
-
constructor(code: string, message: string, metadata?: unknown | undefined);
|
|
1565
|
+
constructor(group: string, code: string, message: string, metadata?: unknown | undefined);
|
|
1564
1566
|
}
|
|
1565
1567
|
|
|
1566
1568
|
/**
|
|
@@ -1590,7 +1592,7 @@ declare class ActorConnRaw {
|
|
|
1590
1592
|
*
|
|
1591
1593
|
* @protected
|
|
1592
1594
|
*/
|
|
1593
|
-
constructor(client: ClientRaw, driver:
|
|
1595
|
+
constructor(client: ClientRaw, driver: ManagerDriver, params: unknown, encoding: Encoding, actorQuery: ActorQuery);
|
|
1594
1596
|
/**
|
|
1595
1597
|
* Call a raw action connection. See {@link ActorConn} for type-safe action calls.
|
|
1596
1598
|
*
|
|
@@ -1621,7 +1623,7 @@ enc
|
|
|
1621
1623
|
* @param {string} eventName - The name of the event to subscribe to.
|
|
1622
1624
|
* @param {(...args: Args) => void} callback - The callback function to execute when the event is triggered.
|
|
1623
1625
|
* @returns {EventUnsubscribe} - A function to unsubscribe from the event.
|
|
1624
|
-
* @see {@link https://rivet.
|
|
1626
|
+
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
1625
1627
|
*/
|
|
1626
1628
|
on<Args extends Array<unknown> = unknown[]>(eventName: string, callback: (...args: Args) => void): EventUnsubscribe;
|
|
1627
1629
|
/**
|
|
@@ -1631,7 +1633,7 @@ enc
|
|
|
1631
1633
|
* @param {string} eventName - The name of the event to subscribe to.
|
|
1632
1634
|
* @param {(...args: Args) => void} callback - The callback function to execute when the event is triggered.
|
|
1633
1635
|
* @returns {EventUnsubscribe} - A function to unsubscribe from the event.
|
|
1634
|
-
* @see {@link https://rivet.
|
|
1636
|
+
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
1635
1637
|
*/
|
|
1636
1638
|
once<Args extends Array<unknown> = unknown[]>(eventName: string, callback: (...args: Args) => void): EventUnsubscribe;
|
|
1637
1639
|
/**
|
|
@@ -1680,7 +1682,7 @@ declare class ActorHandleRaw {
|
|
|
1680
1682
|
*
|
|
1681
1683
|
* @protected
|
|
1682
1684
|
*/
|
|
1683
|
-
constructor(client: any, driver:
|
|
1685
|
+
constructor(client: any, driver: ManagerDriver, params: unknown, encoding: Encoding, actorQuery: ActorQuery);
|
|
1684
1686
|
/**
|
|
1685
1687
|
* Call a raw action. This method sends an HTTP request to invoke the named action.
|
|
1686
1688
|
*
|
|
@@ -1794,14 +1796,6 @@ interface ActorAccessor<AD extends AnyActorDefinition> {
|
|
|
1794
1796
|
*/
|
|
1795
1797
|
create(key?: string | string[], opts?: CreateOptions): Promise<ActorHandle<AD>>;
|
|
1796
1798
|
}
|
|
1797
|
-
/**
|
|
1798
|
-
* Options for configuring the client.
|
|
1799
|
-
* @typedef {Object} ClientOptions
|
|
1800
|
-
*/
|
|
1801
|
-
interface ClientOptions {
|
|
1802
|
-
encoding?: Encoding;
|
|
1803
|
-
transport?: Transport;
|
|
1804
|
-
}
|
|
1805
1799
|
/**
|
|
1806
1800
|
* Options for querying actors.
|
|
1807
1801
|
* @typedef {Object} QueryOptions
|
|
@@ -1852,8 +1846,8 @@ interface CreateOptions extends QueryOptions {
|
|
|
1852
1846
|
* @typedef {Object} Region
|
|
1853
1847
|
* @property {string} id - The region ID.
|
|
1854
1848
|
* @property {string} name - The region name.
|
|
1855
|
-
* @see {@link https://rivet.
|
|
1856
|
-
* @see {@link https://rivet.
|
|
1849
|
+
* @see {@link https://rivet.dev/docs/edge|Edge Networking}
|
|
1850
|
+
* @see {@link https://rivet.dev/docs/regions|Available Regions}
|
|
1857
1851
|
*/
|
|
1858
1852
|
interface Region {
|
|
1859
1853
|
/**
|
|
@@ -1868,34 +1862,11 @@ interface Region {
|
|
|
1868
1862
|
declare const ACTOR_CONNS_SYMBOL: unique symbol;
|
|
1869
1863
|
declare const CREATE_ACTOR_CONN_PROXY: unique symbol;
|
|
1870
1864
|
declare const TRANSPORT_SYMBOL: unique symbol;
|
|
1871
|
-
interface ClientDriver {
|
|
1872
|
-
action<Args extends Array<unknown> = unknown[], Response = unknown>(c: Context | undefined, actorQuery: ActorQuery, encoding: Encoding, params: unknown, name: string, args: Args, opts: {
|
|
1873
|
-
signal?: AbortSignal;
|
|
1874
|
-
} | undefined): Promise<Response>;
|
|
1875
|
-
resolveActorId(c: Context | undefined, actorQuery: ActorQuery, encodingKind: Encoding, params: unknown, opts: {
|
|
1876
|
-
signal?: AbortSignal;
|
|
1877
|
-
} | undefined): Promise<string>;
|
|
1878
|
-
connectWebSocket(c: Context | undefined, actorQuery: ActorQuery, encodingKind: Encoding, params: unknown, opts: {
|
|
1879
|
-
signal?: AbortSignal;
|
|
1880
|
-
} | undefined): Promise<WebSocket$1>;
|
|
1881
|
-
connectSse(c: Context | undefined, actorQuery: ActorQuery, encodingKind: Encoding, params: unknown, opts: {
|
|
1882
|
-
signal?: AbortSignal;
|
|
1883
|
-
} | undefined): Promise<UniversalEventSource>;
|
|
1884
|
-
sendHttpMessage(c: Context | undefined, actorId: string, encoding: Encoding, connectionId: string, connectionToken: string, message: ToServer, opts: {
|
|
1885
|
-
signal?: AbortSignal;
|
|
1886
|
-
} | undefined): Promise<void>;
|
|
1887
|
-
rawHttpRequest(c: Context | undefined, actorQuery: ActorQuery, encoding: Encoding, params: unknown, path: string, init: RequestInit, opts: {
|
|
1888
|
-
signal?: AbortSignal;
|
|
1889
|
-
} | undefined): Promise<Response>;
|
|
1890
|
-
rawWebSocket(c: Context | undefined, actorQuery: ActorQuery, encoding: Encoding, params: unknown, path: string, protocols: string | string[] | undefined, opts: {
|
|
1891
|
-
signal?: AbortSignal;
|
|
1892
|
-
} | undefined): Promise<WebSocket$1>;
|
|
1893
|
-
}
|
|
1894
1865
|
/**
|
|
1895
1866
|
* Client for managing & connecting to actors.
|
|
1896
1867
|
*
|
|
1897
1868
|
* @template A The actors map type that defines the available actors.
|
|
1898
|
-
* @see {@link https://rivet.
|
|
1869
|
+
* @see {@link https://rivet.dev/docs/manage|Create & Manage Actors}
|
|
1899
1870
|
*/
|
|
1900
1871
|
declare class ClientRaw {
|
|
1901
1872
|
#private;
|
|
@@ -1904,11 +1875,11 @@ declare class ClientRaw {
|
|
|
1904
1875
|
/**
|
|
1905
1876
|
* Creates an instance of Client.
|
|
1906
1877
|
*
|
|
1907
|
-
* @param {string} managerEndpoint - The manager endpoint. See {@link https://rivet.
|
|
1908
|
-
* @param {
|
|
1909
|
-
* @see {@link https://rivet.
|
|
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}
|
|
1910
1881
|
*/
|
|
1911
|
-
constructor(driver:
|
|
1882
|
+
constructor(driver: ManagerDriver, opts?: ClientConfig);
|
|
1912
1883
|
/**
|
|
1913
1884
|
* Gets a stateless handle to a actor by its ID.
|
|
1914
1885
|
*
|
|
@@ -1968,7 +1939,7 @@ type Client<A extends Registry<any>> = ClientRaw & {
|
|
|
1968
1939
|
[K in keyof ExtractActorsFromRegistry<A>]: ActorAccessor<ExtractActorsFromRegistry<A>[K]>;
|
|
1969
1940
|
};
|
|
1970
1941
|
type AnyClient = Client<Registry<any>>;
|
|
1971
|
-
declare function createClientWithDriver<A extends Registry<any>>(driver:
|
|
1942
|
+
declare function createClientWithDriver<A extends Registry<any>>(driver: ManagerDriver, config?: ClientConfig): Client<A>;
|
|
1972
1943
|
|
|
1973
1944
|
type ConnectionDriversMap = Record<ConnectionDriver, ConnDriver>;
|
|
1974
1945
|
type ActorDriverBuilder = (registryConfig: RegistryConfig, runConfig: RunConfig, managerDriver: ManagerDriver, inlineClient: AnyClient) => ActorDriver;
|
|
@@ -2028,7 +1999,7 @@ interface PersistedSubscription {
|
|
|
2028
1999
|
declare function generateConnId(): string;
|
|
2029
2000
|
declare function generateConnToken(): string;
|
|
2030
2001
|
type ConnId = string;
|
|
2031
|
-
type AnyConn = Conn<any, any, any, any, any, any
|
|
2002
|
+
type AnyConn = Conn<any, any, any, any, any, any>;
|
|
2032
2003
|
declare const CONNECTION_DRIVER_WEBSOCKET = "webSocket";
|
|
2033
2004
|
declare const CONNECTION_DRIVER_SSE = "sse";
|
|
2034
2005
|
declare const CONNECTION_DRIVER_HTTP = "http";
|
|
@@ -2039,9 +2010,9 @@ type ConnectionStatus = "connected" | "reconnecting";
|
|
|
2039
2010
|
*
|
|
2040
2011
|
* Manages connection-specific data and controls the connection lifecycle.
|
|
2041
2012
|
*
|
|
2042
|
-
* @see {@link https://rivet.
|
|
2013
|
+
* @see {@link https://rivet.dev/docs/connections|Connection Documentation}
|
|
2043
2014
|
*/
|
|
2044
|
-
declare class Conn<S, CP, CS, V, I,
|
|
2015
|
+
declare class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
2045
2016
|
#private;
|
|
2046
2017
|
subscriptions: Set<string>;
|
|
2047
2018
|
/**
|
|
@@ -2051,7 +2022,6 @@ declare class Conn<S, CP, CS, V, I, AD, DB extends AnyDatabaseProvider> {
|
|
|
2051
2022
|
*/
|
|
2052
2023
|
__persist: PersistedConn<CP, CS>;
|
|
2053
2024
|
get params(): CP;
|
|
2054
|
-
get auth(): AD;
|
|
2055
2025
|
get driver(): ConnectionDriver;
|
|
2056
2026
|
get _stateEnabled(): boolean;
|
|
2057
2027
|
/**
|
|
@@ -2089,7 +2059,7 @@ declare class Conn<S, CP, CS, V, I, AD, DB extends AnyDatabaseProvider> {
|
|
|
2089
2059
|
*
|
|
2090
2060
|
* @protected
|
|
2091
2061
|
*/
|
|
2092
|
-
constructor(actor: ActorInstance<S, CP, CS, V, I,
|
|
2062
|
+
constructor(actor: ActorInstance<S, CP, CS, V, I, DB>, persist: PersistedConn<CP, CS>, driver: ConnDriver, stateEnabled: boolean);
|
|
2093
2063
|
/**
|
|
2094
2064
|
* Sends a WebSocket message to the client.
|
|
2095
2065
|
*
|
|
@@ -2103,7 +2073,7 @@ declare class Conn<S, CP, CS, V, I, AD, DB extends AnyDatabaseProvider> {
|
|
|
2103
2073
|
*
|
|
2104
2074
|
* @param eventName - The name of the event.
|
|
2105
2075
|
* @param args - The arguments for the event.
|
|
2106
|
-
* @see {@link https://rivet.
|
|
2076
|
+
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
2107
2077
|
*/
|
|
2108
2078
|
send(eventName: string, ...args: unknown[]): void;
|
|
2109
2079
|
/**
|
|
@@ -2114,4 +2084,4 @@ declare class Conn<S, CP, CS, V, I, AD, DB extends AnyDatabaseProvider> {
|
|
|
2114
2084
|
disconnect(reason?: string): Promise<void>;
|
|
2115
2085
|
}
|
|
2116
2086
|
|
|
2117
|
-
export { type
|
|
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 };
|