rivetkit 2.0.42 → 2.1.0-rc.1
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/{tsup/config-CLnylLYY.d.ts → browser/client.d.ts} +2127 -1910
- package/dist/browser/client.js +5182 -0
- package/dist/browser/client.js.map +1 -0
- package/dist/browser/inspector/client.d.ts +130 -0
- package/dist/browser/inspector/client.js +2854 -0
- package/dist/browser/inspector/client.js.map +1 -0
- package/dist/browser/v3-DnYObHH3.d.ts +279 -0
- package/dist/schemas/actor-inspector/v2.ts +796 -0
- package/dist/schemas/actor-inspector/v3.ts +899 -0
- package/dist/schemas/actor-persist/v4.ts +406 -0
- package/dist/schemas/client-protocol/v3.ts +554 -0
- package/dist/schemas/persist/v1.ts +781 -0
- package/dist/schemas/transport/v1.ts +697 -0
- package/dist/tsup/actor/errors.cjs +27 -3
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +37 -1
- package/dist/tsup/actor/errors.d.ts +37 -1
- package/dist/tsup/actor/errors.js +26 -1
- package/dist/tsup/{actor-router-consts-DzI2szci.d.cts → actor-router-consts-D29T1Z-K.d.cts} +1 -1
- package/dist/tsup/{actor-router-consts-DzI2szci.d.ts → actor-router-consts-D29T1Z-K.d.ts} +1 -1
- package/dist/tsup/chunk-424PT5DM.js +23 -0
- package/dist/tsup/chunk-424PT5DM.js.map +1 -0
- package/dist/tsup/{chunk-JDAD2YFA.js → chunk-5ESWDTHJ.js} +148 -273
- package/dist/tsup/chunk-5ESWDTHJ.js.map +1 -0
- package/dist/tsup/{chunk-FJ3KTN4V.js → chunk-6LIBPELE.js} +119 -11
- package/dist/tsup/chunk-6LIBPELE.js.map +1 -0
- package/dist/tsup/chunk-6LJAZ5R4.cjs +96 -0
- package/dist/tsup/chunk-6LJAZ5R4.cjs.map +1 -0
- package/dist/tsup/{chunk-LFVF5SCU.js → chunk-7HTNH26M.js} +126 -1
- package/dist/tsup/chunk-7HTNH26M.js.map +1 -0
- package/dist/tsup/chunk-7K4CYDGD.js +630 -0
- package/dist/tsup/chunk-7K4CYDGD.js.map +1 -0
- package/dist/tsup/{chunk-XXGJCOL6.js → chunk-A6YIZWTK.js} +2 -2
- package/dist/tsup/chunk-AIYEYMX5.cjs +630 -0
- package/dist/tsup/chunk-AIYEYMX5.cjs.map +1 -0
- package/dist/tsup/{chunk-Q6W7RJJP.js → chunk-DIGBC2VI.js} +211 -2316
- package/dist/tsup/chunk-DIGBC2VI.js.map +1 -0
- package/dist/tsup/{chunk-RZW2DNND.cjs → chunk-F6JYU5IK.cjs} +1957 -1039
- package/dist/tsup/chunk-F6JYU5IK.cjs.map +1 -0
- package/dist/tsup/chunk-HAZL2EPK.cjs +534 -0
- package/dist/tsup/chunk-HAZL2EPK.cjs.map +1 -0
- package/dist/tsup/chunk-HDQ2JUQT.cjs +23 -0
- package/dist/tsup/chunk-HDQ2JUQT.cjs.map +1 -0
- package/dist/tsup/chunk-HIDX4C5Y.cjs +1036 -0
- package/dist/tsup/chunk-HIDX4C5Y.cjs.map +1 -0
- package/dist/tsup/chunk-IVG73YCW.js +534 -0
- package/dist/tsup/chunk-IVG73YCW.js.map +1 -0
- package/dist/tsup/chunk-KJSYAUOM.js +96 -0
- package/dist/tsup/chunk-KJSYAUOM.js.map +1 -0
- package/dist/tsup/{chunk-2XQS746M.cjs → chunk-L47L3ZWJ.cjs} +127 -2
- package/dist/tsup/chunk-L47L3ZWJ.cjs.map +1 -0
- package/dist/tsup/{chunk-H4TB4X25.cjs → chunk-LW6KLR7A.cjs} +126 -18
- package/dist/tsup/chunk-LW6KLR7A.cjs.map +1 -0
- package/dist/tsup/chunk-LXUQ667X.js +2006 -0
- package/dist/tsup/chunk-LXUQ667X.js.map +1 -0
- package/dist/tsup/{chunk-GMAVRZSF.js → chunk-M2T62AZQ.js} +1790 -872
- package/dist/tsup/chunk-M2T62AZQ.js.map +1 -0
- package/dist/tsup/chunk-MZ37VV3P.js +5974 -0
- package/dist/tsup/chunk-MZ37VV3P.js.map +1 -0
- package/dist/tsup/chunk-N4KRDJ56.js +72 -0
- package/dist/tsup/chunk-N4KRDJ56.js.map +1 -0
- package/dist/tsup/chunk-NIYZDWMW.cjs +2006 -0
- package/dist/tsup/chunk-NIYZDWMW.cjs.map +1 -0
- package/dist/tsup/chunk-OMEPCQK2.js +649 -0
- package/dist/tsup/chunk-OMEPCQK2.js.map +1 -0
- package/dist/tsup/chunk-SR3KQE7Q.cjs +72 -0
- package/dist/tsup/chunk-SR3KQE7Q.cjs.map +1 -0
- package/dist/tsup/chunk-SSEP6DHP.cjs +2657 -0
- package/dist/tsup/chunk-SSEP6DHP.cjs.map +1 -0
- package/dist/tsup/chunk-T5YCUGVS.js +1036 -0
- package/dist/tsup/chunk-T5YCUGVS.js.map +1 -0
- package/dist/tsup/{chunk-EJVBH5VF.cjs → chunk-TPGXWFQT.cjs} +3 -3
- package/dist/tsup/{chunk-EJVBH5VF.cjs.map → chunk-TPGXWFQT.cjs.map} +1 -1
- package/dist/tsup/{chunk-X35U3YNX.cjs → chunk-TYLXNCA5.cjs} +214 -339
- package/dist/tsup/chunk-TYLXNCA5.cjs.map +1 -0
- package/dist/tsup/chunk-VKVNIQRQ.js +257 -0
- package/dist/tsup/chunk-VKVNIQRQ.js.map +1 -0
- package/dist/tsup/chunk-XWBAQO5H.cjs +649 -0
- package/dist/tsup/chunk-XWBAQO5H.cjs.map +1 -0
- package/dist/tsup/chunk-YQ4LDVD6.cjs +5974 -0
- package/dist/tsup/chunk-YQ4LDVD6.cjs.map +1 -0
- package/dist/tsup/chunk-ZFY5J2EP.cjs +257 -0
- package/dist/tsup/chunk-ZFY5J2EP.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -10
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +11 -5
- package/dist/tsup/client/mod.d.ts +11 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +4 -4
- package/dist/tsup/common/log.d.cts +2 -2
- package/dist/tsup/common/log.d.ts +2 -2
- package/dist/tsup/common/log.js +3 -2
- package/dist/tsup/common/websocket.cjs +5 -5
- package/dist/tsup/common/websocket.js +4 -3
- package/dist/tsup/config-BFqid9Gr.d.ts +2574 -0
- package/dist/tsup/config-BiNoIHRs.d.cts +80 -0
- package/dist/tsup/config-BiNoIHRs.d.ts +80 -0
- package/dist/tsup/{config-CZB2-W8x.d.cts → config-CAZphOS1.d.cts} +681 -355
- package/dist/tsup/db/drizzle/mod.cjs +49 -0
- package/dist/tsup/db/drizzle/mod.cjs.map +1 -0
- package/dist/tsup/db/drizzle/mod.d.cts +17 -0
- package/dist/tsup/db/drizzle/mod.d.ts +17 -0
- package/dist/tsup/db/drizzle/mod.js +49 -0
- package/dist/tsup/db/drizzle/mod.js.map +1 -0
- package/dist/tsup/db/mod.cjs +9 -0
- package/dist/tsup/db/mod.cjs.map +1 -0
- package/dist/tsup/db/mod.d.cts +9 -0
- package/dist/tsup/db/mod.d.ts +9 -0
- package/dist/tsup/db/mod.js +9 -0
- package/dist/tsup/db/mod.js.map +1 -0
- package/dist/tsup/{driver-D0QX9M11.d.ts → driver-Bxv62E2p.d.ts} +2 -2
- package/dist/tsup/{driver-q-zqG7fc.d.cts → driver-DYXwJR5D.d.cts} +2 -2
- package/dist/tsup/driver-helpers/mod.cjs +12 -6
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +12 -5
- package/dist/tsup/driver-helpers/mod.d.ts +12 -5
- package/dist/tsup/driver-helpers/mod.js +12 -5
- package/dist/tsup/driver-test-suite/mod.cjs +1370 -116
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +10 -4
- package/dist/tsup/driver-test-suite/mod.d.ts +10 -4
- package/dist/tsup/driver-test-suite/mod.js +2093 -838
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +29 -3
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +124 -3
- package/dist/tsup/inspector/mod.d.ts +124 -3
- package/dist/tsup/inspector/mod.js +72 -45
- package/dist/tsup/keys-CydblqMh.d.cts +13 -0
- package/dist/tsup/keys-CydblqMh.d.ts +13 -0
- package/dist/tsup/mod.cjs +16 -10
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +26 -14
- package/dist/tsup/mod.d.ts +26 -14
- package/dist/tsup/mod.js +20 -13
- package/dist/tsup/serve-test-suite/mod.cjs +1165 -83
- package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/serve-test-suite/mod.js +1114 -29
- package/dist/tsup/serve-test-suite/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +84 -11
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +10 -5
- package/dist/tsup/test/mod.d.ts +10 -5
- package/dist/tsup/test/mod.js +85 -11
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/utils.cjs +10 -4
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +72 -2
- package/dist/tsup/utils.d.ts +72 -2
- package/dist/tsup/utils.js +9 -2
- package/dist/tsup/v3-DnYObHH3.d.cts +279 -0
- package/dist/tsup/v3-DnYObHH3.d.ts +279 -0
- package/dist/tsup/workflow/mod.cjs +16 -0
- package/dist/tsup/workflow/mod.cjs.map +1 -0
- package/dist/tsup/workflow/mod.d.cts +83 -0
- package/dist/tsup/workflow/mod.d.ts +83 -0
- package/dist/tsup/workflow/mod.js +16 -0
- package/dist/tsup/workflow/mod.js.map +1 -0
- package/package.json +62 -5
- package/src/actor/config.ts +478 -68
- package/src/actor/conn/mod.ts +68 -16
- package/src/actor/conn/state-manager.ts +2 -2
- package/src/actor/contexts/action.ts +20 -12
- package/src/actor/contexts/base/actor.ts +137 -7
- package/src/actor/contexts/base/conn-init.ts +27 -7
- package/src/actor/contexts/base/conn.ts +27 -18
- package/src/actor/contexts/before-action-response.ts +9 -2
- package/src/actor/contexts/before-connect.ts +7 -2
- package/src/actor/contexts/connect.ts +9 -2
- package/src/actor/contexts/create-conn-state.ts +7 -2
- package/src/actor/contexts/create-vars.ts +16 -3
- package/src/actor/contexts/create.ts +16 -3
- package/src/actor/contexts/destroy.ts +9 -3
- package/src/actor/contexts/disconnect.ts +10 -4
- package/src/actor/contexts/index.ts +4 -3
- package/src/actor/contexts/request.ts +23 -6
- package/src/actor/contexts/run.ts +47 -0
- package/src/actor/contexts/sleep.ts +9 -3
- package/src/actor/contexts/state-change.ts +9 -3
- package/src/actor/contexts/wake.ts +9 -3
- package/src/actor/contexts/websocket.ts +23 -6
- package/src/actor/database.ts +8 -18
- package/src/actor/definition.ts +20 -6
- package/src/actor/driver.ts +32 -3
- package/src/actor/errors.ts +127 -0
- package/src/actor/instance/connection-manager.ts +183 -80
- package/src/actor/instance/event-manager.ts +26 -15
- package/src/actor/instance/keys.ts +117 -0
- package/src/actor/instance/mod.ts +784 -174
- package/src/actor/instance/queue-manager.ts +603 -0
- package/src/actor/instance/queue.ts +287 -0
- package/src/actor/instance/schedule-manager.ts +49 -7
- package/src/actor/instance/state-manager.ts +35 -11
- package/src/actor/instance/traces-driver.ts +128 -0
- package/src/actor/mod.ts +26 -2
- package/src/actor/protocol/old.ts +28 -13
- package/src/actor/protocol/serde.ts +1 -1
- package/src/actor/router-endpoints.ts +177 -21
- package/src/actor/router-websocket-endpoints.ts +18 -29
- package/src/actor/router.ts +177 -0
- package/src/actor/schema.ts +291 -0
- package/src/actor/utils.ts +40 -0
- package/src/client/actor-common.ts +1 -1
- package/src/client/actor-conn.ts +100 -33
- package/src/client/actor-handle.ts +61 -33
- package/src/client/client.ts +2 -4
- package/src/client/config.ts +1 -1
- package/src/client/mod.browser.ts +2 -0
- package/src/client/mod.ts +1 -4
- package/src/client/queue.ts +146 -0
- package/src/client/utils.ts +1 -1
- package/src/common/log.ts +1 -1
- package/src/common/utils.ts +3 -3
- package/src/db/config.ts +100 -0
- package/src/db/drizzle/mod.ts +226 -0
- package/src/db/drizzle/sqlite-core.ts +22 -0
- package/src/db/mod.ts +125 -0
- package/src/db/shared.ts +92 -0
- package/src/db/sqlite-vfs.ts +12 -0
- package/src/driver-helpers/mod.ts +1 -0
- package/src/driver-test-suite/mod.ts +69 -43
- package/src/driver-test-suite/tests/access-control.ts +218 -0
- package/src/driver-test-suite/tests/actor-db-raw.ts +73 -0
- package/src/driver-test-suite/tests/actor-db.ts +394 -0
- package/src/driver-test-suite/tests/actor-inspector.ts +259 -358
- package/src/driver-test-suite/tests/actor-kv.ts +41 -20
- package/src/driver-test-suite/tests/actor-queue.ts +324 -0
- package/src/driver-test-suite/tests/actor-run.ts +181 -0
- package/src/driver-test-suite/tests/actor-schedule.ts +5 -2
- package/src/driver-test-suite/tests/actor-sleep.ts +3 -3
- package/src/driver-test-suite/tests/actor-stateless.ts +70 -0
- package/src/driver-test-suite/tests/actor-workflow.ts +108 -0
- package/src/driver-test-suite/tests/manager-driver.ts +11 -0
- package/src/driver-test-suite/tests/raw-http-request-properties.ts +1 -1
- package/src/driver-test-suite/tests/raw-websocket.ts +12 -12
- package/src/drivers/default.ts +7 -2
- package/src/drivers/engine/actor-driver.ts +45 -37
- package/src/drivers/engine/config.ts +1 -1
- package/src/drivers/file-system/actor.ts +20 -2
- package/src/drivers/file-system/global-state.ts +569 -258
- package/src/drivers/file-system/kv-limits.ts +70 -0
- package/src/drivers/file-system/manager.ts +22 -6
- package/src/drivers/file-system/mod.ts +39 -16
- package/src/drivers/file-system/sqlite-runtime.ts +210 -0
- package/src/inspector/actor-inspector.ts +224 -102
- package/src/inspector/config.ts +1 -1
- package/src/inspector/handler.ts +102 -20
- package/src/inspector/mod.browser.ts +8 -0
- package/src/inspector/mod.ts +2 -0
- package/src/inspector/serve-ui.ts +40 -0
- package/src/inspector/transport.ts +18 -0
- package/src/inspector/utils.ts +5 -39
- package/src/manager/gateway.ts +1 -1
- package/src/manager/protocol/mod.ts +1 -1
- package/src/manager/protocol/query.ts +1 -1
- package/src/manager/router-schema.ts +1 -1
- package/src/manager/router.ts +38 -12
- package/src/manager-api/actors.ts +1 -1
- package/src/manager-api/common.ts +1 -1
- package/src/registry/config/driver.ts +1 -1
- package/src/registry/config/index.ts +212 -43
- package/src/registry/config/legacy-runner.ts +1 -1
- package/src/registry/config/runner.ts +1 -1
- package/src/registry/config/serverless.ts +1 -1
- package/src/registry/index.ts +7 -5
- package/src/remote-manager-driver/api-utils.ts +1 -1
- package/src/schemas/actor-inspector/mod.ts +1 -1
- package/src/schemas/actor-inspector/versioned.ts +195 -8
- package/src/schemas/actor-persist/versioned.ts +87 -7
- package/src/schemas/client-protocol/mod.ts +1 -1
- package/src/schemas/client-protocol/versioned.ts +127 -11
- package/src/schemas/client-protocol-zod/mod.ts +16 -1
- package/src/schemas/persist/mod.ts +1 -0
- package/src/schemas/transport/mod.ts +1 -0
- package/src/serde.ts +1 -1
- package/src/serve-test-suite/mod.ts +10 -9
- package/src/test/mod.ts +15 -56
- package/src/utils/endpoint-parser.test.ts +1 -1
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +12 -1
- package/src/utils/node.ts +15 -2
- package/src/utils.test.ts +34 -0
- package/src/utils.ts +140 -6
- package/src/workflow/constants.ts +2 -0
- package/src/workflow/context.ts +532 -0
- package/src/workflow/driver.ts +191 -0
- package/src/workflow/inspector.ts +268 -0
- package/src/workflow/mod.ts +122 -0
- package/dist/tsup/chunk-2IJTYN6K.cjs +0 -278
- package/dist/tsup/chunk-2IJTYN6K.cjs.map +0 -1
- package/dist/tsup/chunk-2XQS746M.cjs.map +0 -1
- package/dist/tsup/chunk-3VP5CSHV.cjs +0 -114
- package/dist/tsup/chunk-3VP5CSHV.cjs.map +0 -1
- package/dist/tsup/chunk-AQFSQMBG.js +0 -114
- package/dist/tsup/chunk-AQFSQMBG.js.map +0 -1
- package/dist/tsup/chunk-E6ZE2YEA.js +0 -664
- package/dist/tsup/chunk-E6ZE2YEA.js.map +0 -1
- package/dist/tsup/chunk-FJ3KTN4V.js.map +0 -1
- package/dist/tsup/chunk-GBENOENJ.cjs +0 -8
- package/dist/tsup/chunk-GBENOENJ.cjs.map +0 -1
- package/dist/tsup/chunk-GD7UXGOE.cjs +0 -4762
- package/dist/tsup/chunk-GD7UXGOE.cjs.map +0 -1
- package/dist/tsup/chunk-GMAVRZSF.js.map +0 -1
- package/dist/tsup/chunk-H4TB4X25.cjs.map +0 -1
- package/dist/tsup/chunk-JDAD2YFA.js.map +0 -1
- package/dist/tsup/chunk-KCOVZOPS.js +0 -1946
- package/dist/tsup/chunk-KCOVZOPS.js.map +0 -1
- package/dist/tsup/chunk-KDFWJKMJ.cjs +0 -664
- package/dist/tsup/chunk-KDFWJKMJ.cjs.map +0 -1
- package/dist/tsup/chunk-LFVF5SCU.js.map +0 -1
- package/dist/tsup/chunk-Q6W7RJJP.js.map +0 -1
- package/dist/tsup/chunk-RUW5CZ5Z.cjs +0 -1949
- package/dist/tsup/chunk-RUW5CZ5Z.cjs.map +0 -1
- package/dist/tsup/chunk-RZW2DNND.cjs.map +0 -1
- package/dist/tsup/chunk-TCOEBUUE.js +0 -278
- package/dist/tsup/chunk-TCOEBUUE.js.map +0 -1
- package/dist/tsup/chunk-X35U3YNX.cjs.map +0 -1
- package/dist/tsup/keys-Chhy4ylv.d.cts +0 -8
- package/dist/tsup/keys-Chhy4ylv.d.ts +0 -8
- package/dist/tsup/v1-Gq4avTK3.d.cts +0 -240
- package/dist/tsup/v1-Gq4avTK3.d.ts +0 -240
- /package/dist/tsup/{chunk-XXGJCOL6.js.map → chunk-A6YIZWTK.js.map} +0 -0
package/src/actor/conn/mod.ts
CHANGED
|
@@ -10,15 +10,23 @@ import {
|
|
|
10
10
|
} from "@/schemas/client-protocol-zod/mod";
|
|
11
11
|
import { bufferToArrayBuffer } from "@/utils";
|
|
12
12
|
import type { AnyDatabaseProvider } from "../database";
|
|
13
|
-
import { InternalError } from "../errors";
|
|
13
|
+
import { EventPayloadInvalid, InternalError } from "../errors";
|
|
14
14
|
import type { ActorInstance } from "../instance/mod";
|
|
15
15
|
import { CachedSerializer } from "../protocol/serde";
|
|
16
|
+
import {
|
|
17
|
+
type EventSchemaConfig,
|
|
18
|
+
hasSchemaConfigKey,
|
|
19
|
+
type InferEventArgs,
|
|
20
|
+
type InferSchemaMap,
|
|
21
|
+
type QueueSchemaConfig,
|
|
22
|
+
validateSchemaSync,
|
|
23
|
+
} from "../schema";
|
|
16
24
|
import type { ConnDriver } from "./driver";
|
|
17
25
|
import { type ConnDataInput, StateManager } from "./state-manager";
|
|
18
26
|
|
|
19
27
|
export type ConnId = string;
|
|
20
28
|
|
|
21
|
-
export type AnyConn = Conn<any, any, any, any, any, any>;
|
|
29
|
+
export type AnyConn = Conn<any, any, any, any, any, any, any, any>;
|
|
22
30
|
|
|
23
31
|
export const CONN_CONNECTED_SYMBOL = Symbol("connected");
|
|
24
32
|
export const CONN_SPEAKS_RIVETKIT_SYMBOL = Symbol("speaksRivetKit");
|
|
@@ -34,10 +42,19 @@ export const CONN_SEND_MESSAGE_SYMBOL = Symbol("sendMessage");
|
|
|
34
42
|
*
|
|
35
43
|
* @see {@link https://rivet.dev/docs/connections|Connection Documentation}
|
|
36
44
|
*/
|
|
37
|
-
export class Conn<
|
|
38
|
-
|
|
45
|
+
export class Conn<
|
|
46
|
+
S,
|
|
47
|
+
CP,
|
|
48
|
+
CS,
|
|
49
|
+
V,
|
|
50
|
+
I,
|
|
51
|
+
DB extends AnyDatabaseProvider,
|
|
52
|
+
E extends EventSchemaConfig = Record<never, never>,
|
|
53
|
+
Q extends QueueSchemaConfig = Record<never, never>,
|
|
54
|
+
> {
|
|
55
|
+
#actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>;
|
|
39
56
|
|
|
40
|
-
get [CONN_ACTOR_SYMBOL](): ActorInstance<S, CP, CS, V, I, DB> {
|
|
57
|
+
get [CONN_ACTOR_SYMBOL](): ActorInstance<S, CP, CS, V, I, DB, E, Q> {
|
|
41
58
|
return this.#actor;
|
|
42
59
|
}
|
|
43
60
|
|
|
@@ -111,7 +128,7 @@ export class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
111
128
|
* If the underlying connection can hibernate.
|
|
112
129
|
*/
|
|
113
130
|
get isHibernatable(): boolean {
|
|
114
|
-
return this
|
|
131
|
+
return this.#stateManager.hibernatableDataRaw !== undefined;
|
|
115
132
|
}
|
|
116
133
|
|
|
117
134
|
/**
|
|
@@ -122,7 +139,7 @@ export class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
122
139
|
* @protected
|
|
123
140
|
*/
|
|
124
141
|
constructor(
|
|
125
|
-
actor: ActorInstance<S, CP, CS, V, I, DB>,
|
|
142
|
+
actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>,
|
|
126
143
|
data: ConnDataInput<CP, CS>,
|
|
127
144
|
) {
|
|
128
145
|
this.#actor = actor;
|
|
@@ -159,6 +176,14 @@ export class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
159
176
|
* @param args - The arguments for the event.
|
|
160
177
|
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
161
178
|
*/
|
|
179
|
+
send<K extends keyof E & string>(
|
|
180
|
+
eventName: K,
|
|
181
|
+
...args: InferEventArgs<InferSchemaMap<E>[K]>
|
|
182
|
+
): void;
|
|
183
|
+
send(
|
|
184
|
+
eventName: keyof E extends never ? string : never,
|
|
185
|
+
...args: unknown[]
|
|
186
|
+
): void;
|
|
162
187
|
send(eventName: string, ...args: unknown[]) {
|
|
163
188
|
this.#assertConnected();
|
|
164
189
|
if (!this[CONN_SPEAKS_RIVETKIT_SYMBOL]) {
|
|
@@ -169,13 +194,37 @@ export class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
169
194
|
});
|
|
170
195
|
}
|
|
171
196
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
eventName
|
|
175
|
-
|
|
176
|
-
|
|
197
|
+
if (
|
|
198
|
+
this.#actor.config.events !== undefined &&
|
|
199
|
+
!hasSchemaConfigKey(this.#actor.config.events, eventName)
|
|
200
|
+
) {
|
|
201
|
+
this.#actor.rLog.warn({
|
|
202
|
+
msg: "sending event not defined in actor events config",
|
|
203
|
+
eventName,
|
|
204
|
+
connId: this.id,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const payload = args.length === 1 ? args[0] : args;
|
|
209
|
+
const result = validateSchemaSync(
|
|
210
|
+
this.#actor.config.events,
|
|
211
|
+
eventName as keyof E & string,
|
|
212
|
+
payload,
|
|
213
|
+
);
|
|
214
|
+
if (!result.success) {
|
|
215
|
+
throw new EventPayloadInvalid(eventName, result.issues);
|
|
216
|
+
}
|
|
217
|
+
const eventArgs =
|
|
218
|
+
args.length === 1
|
|
219
|
+
? [result.data]
|
|
220
|
+
: Array.isArray(result.data)
|
|
221
|
+
? (result.data as unknown[])
|
|
222
|
+
: args;
|
|
223
|
+
this.#actor.emitTraceEvent("message.send", {
|
|
224
|
+
"rivet.event.name": eventName,
|
|
225
|
+
"rivet.conn.id": this.id,
|
|
177
226
|
});
|
|
178
|
-
const eventData = { name: eventName, args };
|
|
227
|
+
const eventData = { name: eventName, args: eventArgs };
|
|
179
228
|
this[CONN_SEND_MESSAGE_SYMBOL](
|
|
180
229
|
new CachedSerializer(
|
|
181
230
|
eventData,
|
|
@@ -223,14 +272,17 @@ export class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
223
272
|
});
|
|
224
273
|
}
|
|
225
274
|
|
|
226
|
-
|
|
275
|
+
try {
|
|
276
|
+
await this.#actor.connectionManager.connDisconnected(this);
|
|
277
|
+
} finally {
|
|
278
|
+
this[CONN_DRIVER_SYMBOL] = undefined;
|
|
279
|
+
}
|
|
227
280
|
} else {
|
|
228
281
|
this.#actor.rLog.warn({
|
|
229
282
|
msg: "missing connection driver state for disconnect",
|
|
230
283
|
conn: this.id,
|
|
231
284
|
});
|
|
285
|
+
this[CONN_DRIVER_SYMBOL] = undefined;
|
|
232
286
|
}
|
|
233
|
-
|
|
234
|
-
this[CONN_DRIVER_SYMBOL] = undefined;
|
|
235
287
|
}
|
|
236
288
|
}
|
|
@@ -39,7 +39,7 @@ export type ConnData<CP, CS> =
|
|
|
39
39
|
* Handles automatic state change detection for connection-specific state.
|
|
40
40
|
*/
|
|
41
41
|
export class StateManager<CP, CS> {
|
|
42
|
-
#conn: Conn<any, CP, CS, any, any, any>;
|
|
42
|
+
#conn: Conn<any, CP, CS, any, any, any, any, any>;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Data representing this connection.
|
|
@@ -50,7 +50,7 @@ export class StateManager<CP, CS> {
|
|
|
50
50
|
#data!: ConnData<CP, CS>;
|
|
51
51
|
|
|
52
52
|
constructor(
|
|
53
|
-
conn: Conn<any, CP, CS, any, any, any>,
|
|
53
|
+
conn: Conn<any, CP, CS, any, any, any, any, any>,
|
|
54
54
|
data: ConnDataInput<CP, CS>,
|
|
55
55
|
) {
|
|
56
56
|
this.#conn = conn;
|
|
@@ -2,6 +2,7 @@ import type { Conn } from "../conn/mod";
|
|
|
2
2
|
import type { AnyDatabaseProvider } from "../database";
|
|
3
3
|
import type { ActorDefinition, AnyActorDefinition } from "../definition";
|
|
4
4
|
import type { ActorInstance } from "../instance/mod";
|
|
5
|
+
import type { EventSchemaConfig, QueueSchemaConfig } from "../schema";
|
|
5
6
|
import { ConnContext } from "./base/conn";
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -14,26 +15,33 @@ export class ActionContext<
|
|
|
14
15
|
TVars,
|
|
15
16
|
TInput,
|
|
16
17
|
TDatabase extends AnyDatabaseProvider,
|
|
18
|
+
TEvents extends EventSchemaConfig = Record<never, never>,
|
|
19
|
+
TQueues extends QueueSchemaConfig = Record<never, never>,
|
|
17
20
|
> extends ConnContext<
|
|
18
21
|
TState,
|
|
19
22
|
TConnParams,
|
|
20
23
|
TConnState,
|
|
21
24
|
TVars,
|
|
22
25
|
TInput,
|
|
23
|
-
TDatabase
|
|
26
|
+
TDatabase,
|
|
27
|
+
TEvents,
|
|
28
|
+
TQueues
|
|
24
29
|
> {}
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
32
|
* Extracts the ActionContext type from an ActorDefinition.
|
|
28
33
|
*/
|
|
29
|
-
export type ActionContextOf<AD extends AnyActorDefinition> =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
export type ActionContextOf<AD extends AnyActorDefinition> =
|
|
35
|
+
AD extends ActorDefinition<
|
|
36
|
+
infer S,
|
|
37
|
+
infer CP,
|
|
38
|
+
infer CS,
|
|
39
|
+
infer V,
|
|
40
|
+
infer I,
|
|
41
|
+
infer DB extends AnyDatabaseProvider,
|
|
42
|
+
infer E extends EventSchemaConfig,
|
|
43
|
+
infer Q extends QueueSchemaConfig,
|
|
44
|
+
any
|
|
45
|
+
>
|
|
46
|
+
? ActionContext<S, CP, CS, V, I, DB, E, Q>
|
|
47
|
+
: never;
|
|
@@ -5,9 +5,27 @@ import type { Registry } from "@/registry";
|
|
|
5
5
|
import type { Conn, ConnId } from "../../conn/mod";
|
|
6
6
|
import type { AnyDatabaseProvider, InferDatabaseClient } from "../../database";
|
|
7
7
|
import type { ActorDefinition, AnyActorDefinition } from "../../definition";
|
|
8
|
-
import
|
|
8
|
+
import * as errors from "../../errors";
|
|
9
9
|
import { ActorKv } from "../../instance/kv";
|
|
10
|
+
import type {
|
|
11
|
+
ActorInstance,
|
|
12
|
+
AnyActorInstance,
|
|
13
|
+
SaveStateOptions,
|
|
14
|
+
} from "../../instance/mod";
|
|
15
|
+
import { ActorQueue } from "../../instance/queue";
|
|
10
16
|
import type { Schedule } from "../../schedule";
|
|
17
|
+
import {
|
|
18
|
+
type EventSchemaConfig,
|
|
19
|
+
type InferEventArgs,
|
|
20
|
+
type InferSchemaMap,
|
|
21
|
+
type QueueSchemaConfig,
|
|
22
|
+
hasSchemaConfigKey,
|
|
23
|
+
validateSchemaSync,
|
|
24
|
+
} from "../../schema";
|
|
25
|
+
|
|
26
|
+
export const ACTOR_CONTEXT_INTERNAL_SYMBOL = Symbol.for(
|
|
27
|
+
"rivetkit.actorContextInternal",
|
|
28
|
+
);
|
|
11
29
|
|
|
12
30
|
/**
|
|
13
31
|
* ActorContext class that provides access to actor methods and state
|
|
@@ -19,16 +37,33 @@ export class ActorContext<
|
|
|
19
37
|
TVars,
|
|
20
38
|
TInput,
|
|
21
39
|
TDatabase extends AnyDatabaseProvider,
|
|
40
|
+
TEvents extends EventSchemaConfig = Record<never, never>,
|
|
41
|
+
TQueues extends QueueSchemaConfig = Record<never, never>,
|
|
22
42
|
> {
|
|
43
|
+
[ACTOR_CONTEXT_INTERNAL_SYMBOL]!: AnyActorInstance;
|
|
23
44
|
#actor: ActorInstance<
|
|
24
45
|
TState,
|
|
25
46
|
TConnParams,
|
|
26
47
|
TConnState,
|
|
27
48
|
TVars,
|
|
28
49
|
TInput,
|
|
29
|
-
TDatabase
|
|
50
|
+
TDatabase,
|
|
51
|
+
TEvents,
|
|
52
|
+
TQueues
|
|
30
53
|
>;
|
|
31
54
|
#kv: ActorKv | undefined;
|
|
55
|
+
#queue:
|
|
56
|
+
| ActorQueue<
|
|
57
|
+
TState,
|
|
58
|
+
TConnParams,
|
|
59
|
+
TConnState,
|
|
60
|
+
TVars,
|
|
61
|
+
TInput,
|
|
62
|
+
TDatabase,
|
|
63
|
+
TEvents,
|
|
64
|
+
TQueues
|
|
65
|
+
>
|
|
66
|
+
| undefined;
|
|
32
67
|
|
|
33
68
|
constructor(
|
|
34
69
|
actor: ActorInstance<
|
|
@@ -37,10 +72,13 @@ export class ActorContext<
|
|
|
37
72
|
TConnState,
|
|
38
73
|
TVars,
|
|
39
74
|
TInput,
|
|
40
|
-
TDatabase
|
|
75
|
+
TDatabase,
|
|
76
|
+
TEvents,
|
|
77
|
+
TQueues
|
|
41
78
|
>,
|
|
42
79
|
) {
|
|
43
80
|
this.#actor = actor;
|
|
81
|
+
this[ACTOR_CONTEXT_INTERNAL_SYMBOL] = actor as AnyActorInstance;
|
|
44
82
|
}
|
|
45
83
|
|
|
46
84
|
/**
|
|
@@ -79,9 +117,46 @@ export class ActorContext<
|
|
|
79
117
|
* @param name - The name of the event.
|
|
80
118
|
* @param args - The arguments to send with the event.
|
|
81
119
|
*/
|
|
82
|
-
broadcast<
|
|
120
|
+
broadcast<K extends keyof TEvents & string>(
|
|
121
|
+
name: K,
|
|
122
|
+
...args: InferEventArgs<InferSchemaMap<TEvents>[K]>
|
|
123
|
+
): void;
|
|
124
|
+
broadcast(
|
|
125
|
+
name: keyof TEvents extends never ? string : never,
|
|
126
|
+
...args: Array<unknown>
|
|
127
|
+
): void;
|
|
128
|
+
broadcast(name: string, ...args: Array<unknown>): void {
|
|
129
|
+
if (
|
|
130
|
+
this.#actor.config.events !== undefined &&
|
|
131
|
+
!hasSchemaConfigKey(this.#actor.config.events, name)
|
|
132
|
+
) {
|
|
133
|
+
this.#actor.rLog.warn({
|
|
134
|
+
msg: "broadcasting event not defined in actor events config",
|
|
135
|
+
eventName: name,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const payload = args.length === 1 ? args[0] : args;
|
|
140
|
+
const result = validateSchemaSync(
|
|
141
|
+
this.#actor.config.events,
|
|
142
|
+
name as keyof TEvents & string,
|
|
143
|
+
payload,
|
|
144
|
+
);
|
|
145
|
+
if (!result.success) {
|
|
146
|
+
throw new errors.EventPayloadInvalid(name, result.issues);
|
|
147
|
+
}
|
|
148
|
+
if (args.length === 1) {
|
|
149
|
+
this.#actor.eventManager.broadcast(name, result.data);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (Array.isArray(result.data)) {
|
|
153
|
+
this.#actor.eventManager.broadcast(
|
|
154
|
+
name,
|
|
155
|
+
...(result.data as unknown[]),
|
|
156
|
+
);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
83
159
|
this.#actor.eventManager.broadcast(name, ...args);
|
|
84
|
-
return;
|
|
85
160
|
}
|
|
86
161
|
|
|
87
162
|
/**
|
|
@@ -91,6 +166,28 @@ export class ActorContext<
|
|
|
91
166
|
return this.#actor.log;
|
|
92
167
|
}
|
|
93
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Access to queue receive helpers.
|
|
171
|
+
*/
|
|
172
|
+
get queue(): ActorQueue<
|
|
173
|
+
TState,
|
|
174
|
+
TConnParams,
|
|
175
|
+
TConnState,
|
|
176
|
+
TVars,
|
|
177
|
+
TInput,
|
|
178
|
+
TDatabase,
|
|
179
|
+
TEvents,
|
|
180
|
+
TQueues
|
|
181
|
+
> {
|
|
182
|
+
if (!this.#queue) {
|
|
183
|
+
this.#queue = new ActorQueue(
|
|
184
|
+
this.#actor.queueManager,
|
|
185
|
+
this.#actor.abortSignal,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
return this.#queue;
|
|
189
|
+
}
|
|
190
|
+
|
|
94
191
|
/**
|
|
95
192
|
* Gets actor ID.
|
|
96
193
|
*/
|
|
@@ -131,7 +228,16 @@ export class ActorContext<
|
|
|
131
228
|
*/
|
|
132
229
|
get conns(): Map<
|
|
133
230
|
ConnId,
|
|
134
|
-
Conn<
|
|
231
|
+
Conn<
|
|
232
|
+
TState,
|
|
233
|
+
TConnParams,
|
|
234
|
+
TConnState,
|
|
235
|
+
TVars,
|
|
236
|
+
TInput,
|
|
237
|
+
TDatabase,
|
|
238
|
+
TEvents,
|
|
239
|
+
TQueues
|
|
240
|
+
>
|
|
135
241
|
> {
|
|
136
242
|
return this.#actor.conns;
|
|
137
243
|
}
|
|
@@ -173,6 +279,19 @@ export class ActorContext<
|
|
|
173
279
|
this.#actor.waitUntil(promise);
|
|
174
280
|
}
|
|
175
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Prevents the actor from sleeping while the given promise is running.
|
|
284
|
+
*
|
|
285
|
+
* Use this when performing async operations in the `run` handler or other
|
|
286
|
+
* background contexts where you need to ensure the actor stays awake.
|
|
287
|
+
*
|
|
288
|
+
* Returns the resolved value and resets the sleep timer on completion.
|
|
289
|
+
* Errors are propagated to the caller.
|
|
290
|
+
*/
|
|
291
|
+
keepAwake<T>(promise: Promise<T>): Promise<T> {
|
|
292
|
+
return this.#actor.keepAwake(promise);
|
|
293
|
+
}
|
|
294
|
+
|
|
176
295
|
/**
|
|
177
296
|
* AbortSignal that fires when the actor is stopping.
|
|
178
297
|
*/
|
|
@@ -180,6 +299,15 @@ export class ActorContext<
|
|
|
180
299
|
return this.#actor.abortSignal;
|
|
181
300
|
}
|
|
182
301
|
|
|
302
|
+
/**
|
|
303
|
+
* True when the actor is stopping.
|
|
304
|
+
*
|
|
305
|
+
* Alias for `c.abortSignal.aborted`.
|
|
306
|
+
*/
|
|
307
|
+
get aborted(): boolean {
|
|
308
|
+
return this.#actor.abortSignal.aborted;
|
|
309
|
+
}
|
|
310
|
+
|
|
183
311
|
/**
|
|
184
312
|
* Forces the actor to sleep.
|
|
185
313
|
*
|
|
@@ -211,7 +339,9 @@ export type ActorContextOf<AD extends AnyActorDefinition> =
|
|
|
211
339
|
infer V,
|
|
212
340
|
infer I,
|
|
213
341
|
infer DB extends AnyDatabaseProvider,
|
|
342
|
+
infer E extends EventSchemaConfig,
|
|
343
|
+
infer Q extends QueueSchemaConfig,
|
|
214
344
|
any
|
|
215
345
|
>
|
|
216
|
-
? ActorContext<S, CP, CS, V, I, DB>
|
|
346
|
+
? ActorContext<S, CP, CS, V, I, DB, E, Q>
|
|
217
347
|
: never;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { AnyDatabaseProvider } from "../../database";
|
|
2
|
-
import type {
|
|
3
|
-
ActorDefinition,
|
|
4
|
-
AnyActorDefinition,
|
|
5
|
-
} from "../../definition";
|
|
2
|
+
import type { ActorDefinition, AnyActorDefinition } from "../../definition";
|
|
6
3
|
import type { ActorInstance } from "../../instance/mod";
|
|
4
|
+
import type { EventSchemaConfig, QueueSchemaConfig } from "../../schema";
|
|
7
5
|
import { ActorContext } from "./actor";
|
|
8
6
|
|
|
9
7
|
/**
|
|
@@ -15,7 +13,18 @@ export abstract class ConnInitContext<
|
|
|
15
13
|
TVars,
|
|
16
14
|
TInput,
|
|
17
15
|
TDatabase extends AnyDatabaseProvider,
|
|
18
|
-
|
|
16
|
+
TEvents extends EventSchemaConfig = Record<never, never>,
|
|
17
|
+
TQueues extends QueueSchemaConfig = Record<never, never>,
|
|
18
|
+
> extends ActorContext<
|
|
19
|
+
TState,
|
|
20
|
+
never,
|
|
21
|
+
never,
|
|
22
|
+
TVars,
|
|
23
|
+
TInput,
|
|
24
|
+
TDatabase,
|
|
25
|
+
TEvents,
|
|
26
|
+
TQueues
|
|
27
|
+
> {
|
|
19
28
|
/**
|
|
20
29
|
* The incoming request that initiated the connection.
|
|
21
30
|
* May be undefined for connections initiated without a direct HTTP request.
|
|
@@ -26,7 +35,16 @@ export abstract class ConnInitContext<
|
|
|
26
35
|
* @internal
|
|
27
36
|
*/
|
|
28
37
|
constructor(
|
|
29
|
-
actor: ActorInstance<
|
|
38
|
+
actor: ActorInstance<
|
|
39
|
+
TState,
|
|
40
|
+
any,
|
|
41
|
+
any,
|
|
42
|
+
TVars,
|
|
43
|
+
TInput,
|
|
44
|
+
TDatabase,
|
|
45
|
+
TEvents,
|
|
46
|
+
TQueues
|
|
47
|
+
>,
|
|
30
48
|
request: Request | undefined,
|
|
31
49
|
) {
|
|
32
50
|
super(actor as any);
|
|
@@ -42,7 +60,9 @@ export type ConnInitContextOf<AD extends AnyActorDefinition> =
|
|
|
42
60
|
infer V,
|
|
43
61
|
infer I,
|
|
44
62
|
infer DB extends AnyDatabaseProvider,
|
|
63
|
+
infer E extends EventSchemaConfig,
|
|
64
|
+
infer Q extends QueueSchemaConfig,
|
|
45
65
|
any
|
|
46
66
|
>
|
|
47
|
-
? ConnInitContext<S, V, I, DB>
|
|
67
|
+
? ConnInitContext<S, V, I, DB, E, Q>
|
|
48
68
|
: never;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { Conn } from "../../conn/mod";
|
|
2
2
|
import type { AnyDatabaseProvider } from "../../database";
|
|
3
|
-
import type {
|
|
4
|
-
ActorDefinition,
|
|
5
|
-
AnyActorDefinition,
|
|
6
|
-
} from "../../definition";
|
|
3
|
+
import type { ActorDefinition, AnyActorDefinition } from "../../definition";
|
|
7
4
|
import type { ActorInstance } from "../../instance/mod";
|
|
5
|
+
import type { EventSchemaConfig, QueueSchemaConfig } from "../../schema";
|
|
8
6
|
import { ActorContext } from "./actor";
|
|
9
7
|
|
|
10
8
|
/**
|
|
@@ -18,13 +16,17 @@ export abstract class ConnContext<
|
|
|
18
16
|
TVars,
|
|
19
17
|
TInput,
|
|
20
18
|
TDatabase extends AnyDatabaseProvider,
|
|
19
|
+
TEvents extends EventSchemaConfig = Record<never, never>,
|
|
20
|
+
TQueues extends QueueSchemaConfig = Record<never, never>,
|
|
21
21
|
> extends ActorContext<
|
|
22
22
|
TState,
|
|
23
23
|
TConnParams,
|
|
24
24
|
TConnState,
|
|
25
25
|
TVars,
|
|
26
26
|
TInput,
|
|
27
|
-
TDatabase
|
|
27
|
+
TDatabase,
|
|
28
|
+
TEvents,
|
|
29
|
+
TQueues
|
|
28
30
|
> {
|
|
29
31
|
/**
|
|
30
32
|
* @internal
|
|
@@ -36,7 +38,9 @@ export abstract class ConnContext<
|
|
|
36
38
|
TConnState,
|
|
37
39
|
TVars,
|
|
38
40
|
TInput,
|
|
39
|
-
TDatabase
|
|
41
|
+
TDatabase,
|
|
42
|
+
TEvents,
|
|
43
|
+
TQueues
|
|
40
44
|
>,
|
|
41
45
|
public readonly conn: Conn<
|
|
42
46
|
TState,
|
|
@@ -44,21 +48,26 @@ export abstract class ConnContext<
|
|
|
44
48
|
TConnState,
|
|
45
49
|
TVars,
|
|
46
50
|
TInput,
|
|
47
|
-
TDatabase
|
|
51
|
+
TDatabase,
|
|
52
|
+
TEvents,
|
|
53
|
+
TQueues
|
|
48
54
|
>,
|
|
49
55
|
) {
|
|
50
56
|
super(actor);
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
|
|
54
|
-
export type ConnContextOf<AD extends AnyActorDefinition> =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
export type ConnContextOf<AD extends AnyActorDefinition> =
|
|
61
|
+
AD extends ActorDefinition<
|
|
62
|
+
infer S,
|
|
63
|
+
infer CP,
|
|
64
|
+
infer CS,
|
|
65
|
+
infer V,
|
|
66
|
+
infer I,
|
|
67
|
+
infer DB extends AnyDatabaseProvider,
|
|
68
|
+
infer E extends EventSchemaConfig,
|
|
69
|
+
infer Q extends QueueSchemaConfig,
|
|
70
|
+
any
|
|
71
|
+
>
|
|
72
|
+
? ConnContext<S, CP, CS, V, I, DB, E, Q>
|
|
73
|
+
: never;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AnyDatabaseProvider } from "../database";
|
|
2
2
|
import type { ActorDefinition, AnyActorDefinition } from "../definition";
|
|
3
|
+
import type { EventSchemaConfig, QueueSchemaConfig } from "../schema";
|
|
3
4
|
import { ActorContext } from "./base/actor";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -12,13 +13,17 @@ export class BeforeActionResponseContext<
|
|
|
12
13
|
TVars,
|
|
13
14
|
TInput,
|
|
14
15
|
TDatabase extends AnyDatabaseProvider,
|
|
16
|
+
TEvents extends EventSchemaConfig = Record<never, never>,
|
|
17
|
+
TQueues extends QueueSchemaConfig = Record<never, never>,
|
|
15
18
|
> extends ActorContext<
|
|
16
19
|
TState,
|
|
17
20
|
TConnParams,
|
|
18
21
|
TConnState,
|
|
19
22
|
TVars,
|
|
20
23
|
TInput,
|
|
21
|
-
TDatabase
|
|
24
|
+
TDatabase,
|
|
25
|
+
TEvents,
|
|
26
|
+
TQueues
|
|
22
27
|
> {}
|
|
23
28
|
|
|
24
29
|
export type BeforeActionResponseContextOf<AD extends AnyActorDefinition> =
|
|
@@ -29,7 +34,9 @@ export type BeforeActionResponseContextOf<AD extends AnyActorDefinition> =
|
|
|
29
34
|
infer V,
|
|
30
35
|
infer I,
|
|
31
36
|
infer DB extends AnyDatabaseProvider,
|
|
37
|
+
infer E extends EventSchemaConfig,
|
|
38
|
+
infer Q extends QueueSchemaConfig,
|
|
32
39
|
any
|
|
33
40
|
>
|
|
34
|
-
? BeforeActionResponseContext<S, CP, CS, V, I, DB>
|
|
41
|
+
? BeforeActionResponseContext<S, CP, CS, V, I, DB, E, Q>
|
|
35
42
|
: never;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AnyDatabaseProvider } from "../database";
|
|
2
2
|
import type { ActorDefinition, AnyActorDefinition } from "../definition";
|
|
3
|
+
import type { EventSchemaConfig, QueueSchemaConfig } from "../schema";
|
|
3
4
|
import { ConnInitContext } from "./base/conn-init";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -10,7 +11,9 @@ export class BeforeConnectContext<
|
|
|
10
11
|
TVars,
|
|
11
12
|
TInput,
|
|
12
13
|
TDatabase extends AnyDatabaseProvider,
|
|
13
|
-
|
|
14
|
+
TEvents extends EventSchemaConfig = Record<never, never>,
|
|
15
|
+
TQueues extends QueueSchemaConfig = Record<never, never>,
|
|
16
|
+
> extends ConnInitContext<TState, TVars, TInput, TDatabase, TEvents, TQueues> {}
|
|
14
17
|
|
|
15
18
|
export type BeforeConnectContextOf<AD extends AnyActorDefinition> =
|
|
16
19
|
AD extends ActorDefinition<
|
|
@@ -20,7 +23,9 @@ export type BeforeConnectContextOf<AD extends AnyActorDefinition> =
|
|
|
20
23
|
infer V,
|
|
21
24
|
infer I,
|
|
22
25
|
infer DB extends AnyDatabaseProvider,
|
|
26
|
+
infer E extends EventSchemaConfig,
|
|
27
|
+
infer Q extends QueueSchemaConfig,
|
|
23
28
|
any
|
|
24
29
|
>
|
|
25
|
-
? BeforeConnectContext<S, V, I, DB>
|
|
30
|
+
? BeforeConnectContext<S, V, I, DB, E, Q>
|
|
26
31
|
: never;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AnyDatabaseProvider } from "../database";
|
|
2
2
|
import type { ActorDefinition, AnyActorDefinition } from "../definition";
|
|
3
|
+
import type { EventSchemaConfig, QueueSchemaConfig } from "../schema";
|
|
3
4
|
import { ConnContext } from "./base/conn";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -12,13 +13,17 @@ export class ConnectContext<
|
|
|
12
13
|
TVars,
|
|
13
14
|
TInput,
|
|
14
15
|
TDatabase extends AnyDatabaseProvider,
|
|
16
|
+
TEvents extends EventSchemaConfig = Record<never, never>,
|
|
17
|
+
TQueues extends QueueSchemaConfig = Record<never, never>,
|
|
15
18
|
> extends ConnContext<
|
|
16
19
|
TState,
|
|
17
20
|
TConnParams,
|
|
18
21
|
TConnState,
|
|
19
22
|
TVars,
|
|
20
23
|
TInput,
|
|
21
|
-
TDatabase
|
|
24
|
+
TDatabase,
|
|
25
|
+
TEvents,
|
|
26
|
+
TQueues
|
|
22
27
|
> {}
|
|
23
28
|
|
|
24
29
|
export type ConnectContextOf<AD extends AnyActorDefinition> =
|
|
@@ -29,7 +34,9 @@ export type ConnectContextOf<AD extends AnyActorDefinition> =
|
|
|
29
34
|
infer V,
|
|
30
35
|
infer I,
|
|
31
36
|
infer DB extends AnyDatabaseProvider,
|
|
37
|
+
infer E extends EventSchemaConfig,
|
|
38
|
+
infer Q extends QueueSchemaConfig,
|
|
32
39
|
any
|
|
33
40
|
>
|
|
34
|
-
? ConnectContext<S, CP, CS, V, I, DB>
|
|
41
|
+
? ConnectContext<S, CP, CS, V, I, DB, E, Q>
|
|
35
42
|
: never;
|