rivetkit 2.3.0-rc.10 → 2.3.0-rc.11
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/dist/browser/client.d.ts +105 -56
- package/dist/browser/client.js +128 -87
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +40 -20
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/agent-os/index.cjs +2103 -2090
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +106 -66
- package/dist/tsup/agent-os/index.d.ts +106 -66
- package/dist/tsup/agent-os/index.js +2102 -2089
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-4K3MV2MW.cjs → chunk-2NXFKPRB.cjs} +10 -10
- package/dist/tsup/chunk-2NXFKPRB.cjs.map +1 -0
- package/dist/tsup/{chunk-6BI2MS3S.js → chunk-3P2JUHWJ.js} +2 -2
- package/dist/tsup/{chunk-KU6VKVEK.js → chunk-4FP4FFB5.js} +18 -6
- package/dist/tsup/chunk-4FP4FFB5.js.map +1 -0
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-BRP62GZC.js} +3 -3
- package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
- package/dist/tsup/{chunk-G34LIR7S.js → chunk-GRFBV2U7.js} +22 -7
- package/dist/tsup/chunk-GRFBV2U7.js.map +1 -0
- package/dist/tsup/{chunk-PWFGP2US.cjs → chunk-GX6W4MW3.cjs} +138 -24
- package/dist/tsup/chunk-GX6W4MW3.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-KORQB2IR.cjs} +3 -3
- package/dist/tsup/{chunk-QAZLM4WT.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
- package/dist/tsup/{chunk-BM3EOY7M.js → chunk-KRC4L3YB.js} +134 -20
- package/dist/tsup/chunk-KRC4L3YB.js.map +1 -0
- package/dist/tsup/{chunk-G5RULGYQ.cjs → chunk-LNP7Q6I6.cjs} +24 -9
- package/dist/tsup/chunk-LNP7Q6I6.cjs.map +1 -0
- package/dist/tsup/{chunk-Z4C3W2CQ.cjs → chunk-LW5HNCWD.cjs} +3 -3
- package/dist/tsup/{chunk-Z4C3W2CQ.cjs.map → chunk-LW5HNCWD.cjs.map} +1 -1
- package/dist/tsup/{chunk-J5P6S2LC.cjs → chunk-RDBGKI66.cjs} +25 -13
- package/dist/tsup/chunk-RDBGKI66.cjs.map +1 -0
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-T3VCJ4PV.js} +3 -1
- package/dist/tsup/chunk-T3VCJ4PV.js.map +1 -0
- package/dist/tsup/{chunk-WU2O2KIE.js → chunk-TTLUIDVH.js} +61 -77
- package/dist/tsup/chunk-TTLUIDVH.js.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
- package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
- package/dist/tsup/{chunk-XV52XUWU.js → chunk-WXYWDLJY.js} +4 -4
- package/dist/tsup/chunk-WXYWDLJY.js.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-XCDCURZ4.cjs} +4 -2
- package/dist/tsup/chunk-XCDCURZ4.cjs.map +1 -0
- package/dist/tsup/{chunk-TE4VCDNY.cjs → chunk-XG25CGSW.cjs} +217 -233
- package/dist/tsup/chunk-XG25CGSW.cjs.map +1 -0
- package/dist/tsup/{chunk-3LGP4JSO.cjs → chunk-Y3JBOFBG.cjs} +8 -8
- package/dist/tsup/{chunk-3LGP4JSO.cjs.map → chunk-Y3JBOFBG.cjs.map} +1 -1
- package/dist/tsup/{chunk-CMYS77J6.js → chunk-YRQ4F5CD.js} +3 -3
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +4 -4
- package/dist/tsup/client/mod.d.ts +4 -4
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-Ca8dN4cS.d.cts → config-CTwe3WwC.d.cts} +69 -19
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.cts} +1 -2
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.ts} +1 -2
- package/dist/tsup/{config-0Ta55UV0.d.ts → config-De5UVu0V.d.ts} +69 -19
- package/dist/tsup/{context-B_IWbWne.d.ts → context-DPHISlUi.d.ts} +8 -8
- package/dist/tsup/{context-CUrQ9MHc.d.cts → context-Dmj477Uh.d.cts} +8 -8
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +37 -0
- package/dist/tsup/dynamic/mod.d.ts +37 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/mod.cjs +501 -315
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -4
- package/dist/tsup/mod.d.ts +4 -4
- package/dist/tsup/mod.js +405 -219
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +21 -18
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +3 -3
- package/dist/tsup/test/mod.d.ts +3 -3
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- 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/dist/tsup/workflow/mod.cjs +307 -282
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +5 -5
- package/dist/tsup/workflow/mod.d.ts +5 -5
- package/dist/tsup/workflow/mod.js +501 -476
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +22 -11
- package/src/actor/config.ts +48 -41
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +11 -14
- package/src/actor/driver.ts +3 -3
- package/src/actor/errors.ts +9 -3
- package/src/actor/instance/mod.ts +22 -30
- package/src/actor/keys.ts +1 -1
- package/src/actor/mod.ts +20 -20
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/index.ts +38 -18
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/actor/session.ts +2 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/client/actor-common.ts +90 -54
- package/src/client/actor-conn.ts +8 -36
- package/src/client/actor-handle.ts +67 -50
- package/src/client/actor-query.ts +5 -5
- package/src/client/errors.ts +1 -1
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +1 -1
- package/src/client/queue.ts +8 -3
- package/src/client/raw-utils.ts +8 -6
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +2 -7
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/transport/v1.ts +659 -543
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +2 -8
- package/src/common/database/native-database.ts +1 -1
- package/src/common/database/shared.ts +1 -0
- package/src/common/encoding.ts +250 -16
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/log.ts +1 -0
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +0 -149
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/mod.ts +1 -1
- package/src/drivers/engine/actor-driver.ts +63 -72
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +66 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +1 -1
- package/src/engine-client/actor-websocket-client.ts +6 -5
- package/src/engine-client/api-endpoints.ts +47 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +1 -1
- package/src/engine-client/mod.ts +6 -3
- package/src/engine-client/ws-proxy.ts +4 -4
- package/src/inspector/client.browser.ts +5 -11
- package/src/inspector/mod.ts +1 -3
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +7 -7
- package/src/registry/index.ts +70 -71
- package/src/registry/napi-runtime.ts +7 -2
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +179 -153
- package/src/registry/process-metrics.ts +238 -0
- package/src/registry/runtime.ts +1 -3
- package/src/registry/wasm-runtime.ts +3 -2
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +11 -8
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/router.ts +1 -1
- package/src/utils/serve.ts +4 -5
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +61 -33
- package/src/workflow/driver.ts +4 -6
- package/src/workflow/inspector.ts +4 -3
- package/src/workflow/mod.ts +15 -17
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-4K3MV2MW.cjs.map +0 -1
- package/dist/tsup/chunk-BM3EOY7M.js.map +0 -1
- package/dist/tsup/chunk-G34LIR7S.js.map +0 -1
- package/dist/tsup/chunk-G5RULGYQ.cjs.map +0 -1
- package/dist/tsup/chunk-J5P6S2LC.cjs.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-KU6VKVEK.js.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-PWFGP2US.cjs.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-TE4VCDNY.cjs.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/chunk-WU2O2KIE.js.map +0 -1
- package/dist/tsup/chunk-XV52XUWU.js.map +0 -1
- /package/dist/tsup/{chunk-6BI2MS3S.js.map → chunk-3P2JUHWJ.js.map} +0 -0
- /package/dist/tsup/{chunk-CMYS77J6.js.map → chunk-YRQ4F5CD.js.map} +0 -0
package/dist/browser/client.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _rivetkit_rivetkit_wasm from '@rivetkit/rivetkit-wasm';
|
|
2
2
|
import { z as z$2 } from 'zod';
|
|
3
3
|
import z$1, { z } from 'zod/v4';
|
|
4
|
-
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
5
4
|
import { Context, Handler, Hono } from 'hono';
|
|
5
|
+
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
6
6
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
7
7
|
import { ContentfulStatusCode } from 'hono/utils/http-status';
|
|
8
8
|
import { Logger } from 'pino';
|
|
@@ -103,8 +103,7 @@ type DatabaseProvider<DB extends RawAccess> = {
|
|
|
103
103
|
/**
|
|
104
104
|
* Drizzle database client interface (will be extended by drizzle-orm types)
|
|
105
105
|
*/
|
|
106
|
-
|
|
107
|
-
}
|
|
106
|
+
type DrizzleDatabaseClient = {};
|
|
108
107
|
type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
|
|
109
108
|
type RawAccess = {
|
|
110
109
|
/**
|
|
@@ -182,6 +181,44 @@ type ActorQuery = z.infer<typeof ActorQuerySchema>;
|
|
|
182
181
|
*/
|
|
183
182
|
type CreateRequest = z.infer<typeof CreateRequestSchema>;
|
|
184
183
|
|
|
184
|
+
type SchemaHookResult = boolean | Promise<boolean>;
|
|
185
|
+
type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
|
|
186
|
+
interface EventTypeToken<T, TContext = any> {
|
|
187
|
+
readonly _eventType?: T;
|
|
188
|
+
readonly canSubscribe?: SchemaHook<TContext>;
|
|
189
|
+
readonly schema?: PrimitiveSchema;
|
|
190
|
+
}
|
|
191
|
+
interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
|
|
192
|
+
readonly _queueMessage?: TMessage;
|
|
193
|
+
readonly _queueComplete?: TComplete;
|
|
194
|
+
readonly canPublish?: SchemaHook<TContext>;
|
|
195
|
+
readonly message?: PrimitiveSchema;
|
|
196
|
+
readonly complete?: PrimitiveSchema;
|
|
197
|
+
}
|
|
198
|
+
type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
|
|
199
|
+
interface EventSchemaDefinition<TContext = any> {
|
|
200
|
+
schema: PrimitiveSchema;
|
|
201
|
+
canSubscribe?: SchemaHook<TContext>;
|
|
202
|
+
}
|
|
203
|
+
interface QueueSchemaDefinition<TContext = any> {
|
|
204
|
+
message: PrimitiveSchema;
|
|
205
|
+
complete?: PrimitiveSchema;
|
|
206
|
+
canPublish?: SchemaHook<TContext>;
|
|
207
|
+
}
|
|
208
|
+
type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
|
|
209
|
+
type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
|
|
210
|
+
type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
|
|
211
|
+
type QueueSchemaConfig<_TContext = any> = Record<string, QueueSchema>;
|
|
212
|
+
type InferSchema<T> = T extends QueueSchemaDefinition<any> ? InferSchema<T["message"]> : T extends QueueTypeToken<infer M, unknown, any> ? M : T extends EventSchemaDefinition<any> ? InferSchema<T["schema"]> : T extends StandardSchemaV1<any, infer O> ? O : T extends EventTypeToken<infer R, any> ? R : never;
|
|
213
|
+
type InferSchemaMap<T extends Record<string, unknown>> = {
|
|
214
|
+
[K in keyof T]: InferSchema<T[K]>;
|
|
215
|
+
};
|
|
216
|
+
type InferQueueComplete<T> = T extends QueueTypeToken<unknown, infer C, any> ? [C] extends [never] ? never : C : T extends QueueSchemaDefinition<any> ? T["complete"] extends PrimitiveSchema ? InferSchema<T["complete"]> : never : never;
|
|
217
|
+
type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
|
|
218
|
+
[K in keyof T]: InferQueueComplete<T[K]>;
|
|
219
|
+
};
|
|
220
|
+
type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
|
|
221
|
+
|
|
185
222
|
interface DeconstructedError {
|
|
186
223
|
__type: "ActorError";
|
|
187
224
|
statusCode: ContentfulStatusCode;
|
|
@@ -239,44 +276,6 @@ declare class UserError extends RivetError {
|
|
|
239
276
|
constructor(message: string, options?: UserErrorOptions);
|
|
240
277
|
}
|
|
241
278
|
|
|
242
|
-
type SchemaHookResult = boolean | Promise<boolean>;
|
|
243
|
-
type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
|
|
244
|
-
interface EventTypeToken<T, TContext = any> {
|
|
245
|
-
readonly _eventType?: T;
|
|
246
|
-
readonly canSubscribe?: SchemaHook<TContext>;
|
|
247
|
-
readonly schema?: PrimitiveSchema;
|
|
248
|
-
}
|
|
249
|
-
interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
|
|
250
|
-
readonly _queueMessage?: TMessage;
|
|
251
|
-
readonly _queueComplete?: TComplete;
|
|
252
|
-
readonly canPublish?: SchemaHook<TContext>;
|
|
253
|
-
readonly message?: PrimitiveSchema;
|
|
254
|
-
readonly complete?: PrimitiveSchema;
|
|
255
|
-
}
|
|
256
|
-
type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
|
|
257
|
-
interface EventSchemaDefinition<TContext = any> {
|
|
258
|
-
schema: PrimitiveSchema;
|
|
259
|
-
canSubscribe?: SchemaHook<TContext>;
|
|
260
|
-
}
|
|
261
|
-
interface QueueSchemaDefinition<TContext = any> {
|
|
262
|
-
message: PrimitiveSchema;
|
|
263
|
-
complete?: PrimitiveSchema;
|
|
264
|
-
canPublish?: SchemaHook<TContext>;
|
|
265
|
-
}
|
|
266
|
-
type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
|
|
267
|
-
type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
|
|
268
|
-
type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
|
|
269
|
-
type QueueSchemaConfig<TContext = any> = Record<string, QueueSchema>;
|
|
270
|
-
type InferSchema<T> = T extends QueueSchemaDefinition<any> ? InferSchema<T["message"]> : T extends QueueTypeToken<infer M, unknown, any> ? M : T extends EventSchemaDefinition<any> ? InferSchema<T["schema"]> : T extends StandardSchemaV1<any, infer O> ? O : T extends EventTypeToken<infer R, any> ? R : never;
|
|
271
|
-
type InferSchemaMap<T extends Record<string, unknown>> = {
|
|
272
|
-
[K in keyof T]: InferSchema<T[K]>;
|
|
273
|
-
};
|
|
274
|
-
type InferQueueComplete<T> = T extends QueueTypeToken<unknown, infer C, any> ? [C] extends [never] ? never : C : T extends QueueSchemaDefinition<any> ? T["complete"] extends PrimitiveSchema ? InferSchema<T["complete"]> : never : never;
|
|
275
|
-
type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
|
|
276
|
-
[K in keyof T]: InferQueueComplete<T[K]>;
|
|
277
|
-
};
|
|
278
|
-
type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
|
|
279
|
-
|
|
280
279
|
type UpgradeWebSocket = (createEvents: (c: Context) => any) => Handler;
|
|
281
280
|
type GetUpgradeWebSocket = () => UpgradeWebSocket;
|
|
282
281
|
|
|
@@ -384,6 +383,8 @@ interface QueueSendResult<TResponse = unknown> {
|
|
|
384
383
|
* @returns {Promise<Response>}
|
|
385
384
|
*/
|
|
386
385
|
type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
|
|
386
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
387
|
+
type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
|
|
387
388
|
interface ActorGatewayOptions {
|
|
388
389
|
skipReadyWait?: boolean;
|
|
389
390
|
}
|
|
@@ -396,9 +397,15 @@ type ActorWebSocketOptions = ActorGatewayOptions;
|
|
|
396
397
|
/**
|
|
397
398
|
* Maps action methods from actor definition to typed function signatures.
|
|
398
399
|
*/
|
|
399
|
-
type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends
|
|
400
|
+
type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : AD extends {
|
|
401
|
+
config: {
|
|
402
|
+
actions?: infer R;
|
|
403
|
+
};
|
|
404
|
+
} ? {
|
|
405
|
+
[K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
|
|
406
|
+
} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, infer R> ? {
|
|
400
407
|
[K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
|
|
401
|
-
} :
|
|
408
|
+
} : {};
|
|
402
409
|
type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
|
|
403
410
|
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
|
|
404
411
|
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
|
|
@@ -409,13 +416,31 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
|
|
|
409
416
|
<K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
|
|
410
417
|
(eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
|
|
411
418
|
};
|
|
412
|
-
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = AD
|
|
419
|
+
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
420
|
+
send: ActorQueueSend<Record<string, any>>;
|
|
421
|
+
} : AD extends {
|
|
422
|
+
config: {
|
|
423
|
+
queues?: infer Q;
|
|
424
|
+
};
|
|
425
|
+
} ? Q extends QueueSchemaConfig ? {
|
|
426
|
+
send: ActorQueueSend<Q>;
|
|
427
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
|
|
413
428
|
send: ActorQueueSend<Q>;
|
|
414
|
-
} :
|
|
415
|
-
type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = AD
|
|
429
|
+
} : {} : {};
|
|
430
|
+
type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
431
|
+
on: LooseEventSubscribe;
|
|
432
|
+
once: LooseEventSubscribe;
|
|
433
|
+
} : AD extends {
|
|
434
|
+
config: {
|
|
435
|
+
events?: infer E;
|
|
436
|
+
};
|
|
437
|
+
} ? E extends EventSchemaConfig ? {
|
|
416
438
|
on: ActorEventSubscribe<E>;
|
|
417
439
|
once: ActorEventSubscribe<E>;
|
|
418
|
-
} :
|
|
440
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
|
|
441
|
+
on: ActorEventSubscribe<E>;
|
|
442
|
+
once: ActorEventSubscribe<E>;
|
|
443
|
+
} : {} : {};
|
|
419
444
|
|
|
420
445
|
declare class ActorClientError extends Error {
|
|
421
446
|
}
|
|
@@ -929,6 +954,7 @@ type Client<A extends Registry<any>> = ClientRaw & {
|
|
|
929
954
|
};
|
|
930
955
|
|
|
931
956
|
declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
|
|
957
|
+
declare const RAW_STATE_SYMBOL: unique symbol;
|
|
932
958
|
interface ActorLogger {
|
|
933
959
|
level: any;
|
|
934
960
|
fatal: any;
|
|
@@ -1037,7 +1063,7 @@ interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
|
1037
1063
|
iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
|
|
1038
1064
|
[key: string]: any;
|
|
1039
1065
|
}
|
|
1040
|
-
interface Conn<
|
|
1066
|
+
interface Conn<_TState = unknown, TConnParams = unknown, TConnState = unknown, _TVars = unknown, _TInput = unknown, _TDatabase extends AnyDatabaseProvider = AnyDatabaseProvider, _TEvents extends EventSchemaConfig = Record<never, never>, _TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1041
1067
|
id: string;
|
|
1042
1068
|
params: TConnParams;
|
|
1043
1069
|
state: TConnState;
|
|
@@ -1048,6 +1074,8 @@ interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
|
|
|
1048
1074
|
}
|
|
1049
1075
|
interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1050
1076
|
[ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
|
|
1077
|
+
/** Returns the raw unwrapped state without the write-through proxy. */
|
|
1078
|
+
[RAW_STATE_SYMBOL](): TState;
|
|
1051
1079
|
state: TState;
|
|
1052
1080
|
vars: TVars;
|
|
1053
1081
|
readonly kv: ActorKv;
|
|
@@ -1175,7 +1203,7 @@ declare const ActorConfigSchema: z.ZodObject<{
|
|
|
1175
1203
|
preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
|
|
1176
1204
|
}, z.core.$strict>>;
|
|
1177
1205
|
}, z.core.$strict>;
|
|
1178
|
-
type CreateState<TState,
|
|
1206
|
+
type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
1179
1207
|
state: TState;
|
|
1180
1208
|
} | {
|
|
1181
1209
|
createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
|
|
@@ -1188,7 +1216,7 @@ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
|
|
|
1188
1216
|
/**
|
|
1189
1217
|
* @experimental
|
|
1190
1218
|
*/
|
|
1191
|
-
type CreateVars<TState,
|
|
1219
|
+
type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
1192
1220
|
/**
|
|
1193
1221
|
* @experimental
|
|
1194
1222
|
*/
|
|
@@ -1376,17 +1404,19 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
|
|
|
1376
1404
|
} | Record<never, never>;
|
|
1377
1405
|
type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = Omit<z.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "onWake" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & ActorDatabaseConfig<TDatabase>;
|
|
1378
1406
|
|
|
1379
|
-
interface BaseActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>,
|
|
1407
|
+
interface BaseActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>, _R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<S, CP, CS, V, I, DB, E, Q>> {
|
|
1380
1408
|
readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
1381
1409
|
}
|
|
1382
|
-
|
|
1410
|
+
interface AnyActorDefinition {
|
|
1411
|
+
readonly config: any;
|
|
1412
|
+
}
|
|
1383
1413
|
declare class ActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>, R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<S, CP, CS, V, I, DB, E, Q>> implements BaseActorDefinition<S, CP, CS, V, I, DB, E, Q, R> {
|
|
1384
1414
|
#private;
|
|
1385
1415
|
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
|
|
1386
1416
|
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
1387
1417
|
}
|
|
1388
1418
|
|
|
1389
|
-
declare const ActorsSchema: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<
|
|
1419
|
+
declare const ActorsSchema: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
1390
1420
|
type RegistryActors = z$2.infer<typeof ActorsSchema>;
|
|
1391
1421
|
declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
1392
1422
|
use: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
@@ -1467,7 +1497,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
|
1467
1497
|
envoyKey: z$2.ZodOptional<z$2.ZodString>;
|
|
1468
1498
|
}, z$2.core.$strip>>>;
|
|
1469
1499
|
shutdown: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
|
|
1470
|
-
gracePeriodMs: z$2.ZodOptional<z$2.ZodNumber
|
|
1500
|
+
gracePeriodMs: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
|
|
1471
1501
|
disableSignalHandlers: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
|
|
1472
1502
|
}, z$2.core.$strip>>>;
|
|
1473
1503
|
}, z$2.core.$strip>, z$2.ZodTransform<{
|
|
@@ -1516,8 +1546,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
|
1516
1546
|
envoyKey?: string | undefined;
|
|
1517
1547
|
};
|
|
1518
1548
|
shutdown: {
|
|
1549
|
+
gracePeriodMs: number;
|
|
1519
1550
|
disableSignalHandlers: boolean;
|
|
1520
|
-
gracePeriodMs?: number | undefined;
|
|
1521
1551
|
};
|
|
1522
1552
|
staticDir?: string | undefined;
|
|
1523
1553
|
httpHost?: string | undefined;
|
|
@@ -1573,8 +1603,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
|
1573
1603
|
envoyKey?: string | undefined;
|
|
1574
1604
|
};
|
|
1575
1605
|
shutdown: {
|
|
1606
|
+
gracePeriodMs: number;
|
|
1576
1607
|
disableSignalHandlers: boolean;
|
|
1577
|
-
gracePeriodMs?: number | undefined;
|
|
1578
1608
|
};
|
|
1579
1609
|
staticDir?: string | undefined;
|
|
1580
1610
|
httpHost?: string | undefined;
|
|
@@ -1629,6 +1659,25 @@ declare class Registry<A extends RegistryActors> {
|
|
|
1629
1659
|
* ```
|
|
1630
1660
|
*/
|
|
1631
1661
|
serve(): ServerlessHandler;
|
|
1662
|
+
/**
|
|
1663
|
+
* Starts an HTTP server that dispatches every request through the
|
|
1664
|
+
* serverless handler. Uses `crossPlatformServe` to pick the right
|
|
1665
|
+
* runtime (Node, Bun, Deno).
|
|
1666
|
+
*
|
|
1667
|
+
* @param opts.port Port to listen on. Defaults to 3000.
|
|
1668
|
+
* @param opts.publicDir If set, serves static files from this directory
|
|
1669
|
+
* before falling through to the registry handler.
|
|
1670
|
+
*
|
|
1671
|
+
* @example
|
|
1672
|
+
* ```ts
|
|
1673
|
+
* await registry.listen();
|
|
1674
|
+
* await registry.listen({ port: 8080, publicDir: "./public" });
|
|
1675
|
+
* ```
|
|
1676
|
+
*/
|
|
1677
|
+
listen(opts?: {
|
|
1678
|
+
port?: number;
|
|
1679
|
+
publicDir?: string;
|
|
1680
|
+
}): Promise<void>;
|
|
1632
1681
|
startEnvoy(): void;
|
|
1633
1682
|
/**
|
|
1634
1683
|
* Starts the actor envoy for standalone server deployments.
|