rivetkit 2.0.24-rc.1 → 2.0.24

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.
Files changed (228) hide show
  1. package/dist/schemas/actor-persist/v2.ts +3 -3
  2. package/dist/schemas/actor-persist/v3.ts +274 -0
  3. package/dist/schemas/client-protocol/v2.ts +432 -0
  4. package/dist/schemas/file-system-driver/v2.ts +136 -0
  5. package/dist/tsup/actor/errors.cjs +2 -4
  6. package/dist/tsup/actor/errors.cjs.map +1 -1
  7. package/dist/tsup/actor/errors.d.cts +7 -10
  8. package/dist/tsup/actor/errors.d.ts +7 -10
  9. package/dist/tsup/actor/errors.js +9 -11
  10. package/dist/tsup/{actor-router-consts-B3Lu87yJ.d.cts → actor-router-consts-DzI2szci.d.cts} +5 -9
  11. package/dist/tsup/{actor-router-consts-B3Lu87yJ.d.ts → actor-router-consts-DzI2szci.d.ts} +5 -9
  12. package/dist/tsup/{chunk-HHFKKVLR.cjs → chunk-3543NCSN.cjs} +45 -57
  13. package/dist/tsup/chunk-3543NCSN.cjs.map +1 -0
  14. package/dist/tsup/chunk-4SHILYS5.cjs +5694 -0
  15. package/dist/tsup/chunk-4SHILYS5.cjs.map +1 -0
  16. package/dist/tsup/{chunk-ZTH3KYFH.cjs → chunk-5BZO5XPS.cjs} +3 -3
  17. package/dist/tsup/{chunk-ZTH3KYFH.cjs.map → chunk-5BZO5XPS.cjs.map} +1 -1
  18. package/dist/tsup/{chunk-PLUN2NQT.js → chunk-BAIGSF64.js} +189 -187
  19. package/dist/tsup/chunk-BAIGSF64.js.map +1 -0
  20. package/dist/tsup/{chunk-SHVX2QUR.cjs → chunk-CHLZBSI2.cjs} +17 -17
  21. package/dist/tsup/chunk-CHLZBSI2.cjs.map +1 -0
  22. package/dist/tsup/chunk-D3SLADUD.cjs +512 -0
  23. package/dist/tsup/chunk-D3SLADUD.cjs.map +1 -0
  24. package/dist/tsup/{chunk-KSRXX3Z4.cjs → chunk-D6762AOA.cjs} +20 -25
  25. package/dist/tsup/chunk-D6762AOA.cjs.map +1 -0
  26. package/dist/tsup/{chunk-7L65NNWP.cjs → chunk-DLK5YCTN.cjs} +187 -185
  27. package/dist/tsup/chunk-DLK5YCTN.cjs.map +1 -0
  28. package/dist/tsup/{chunk-YBG6R7LX.js → chunk-DUJQWGYD.js} +3 -7
  29. package/dist/tsup/chunk-DUJQWGYD.js.map +1 -0
  30. package/dist/tsup/{chunk-CD33GT6Z.js → chunk-EIPANQMF.js} +2 -2
  31. package/dist/tsup/{chunk-2JYPS5YM.cjs → chunk-ESMTDP7G.cjs} +6 -6
  32. package/dist/tsup/chunk-ESMTDP7G.cjs.map +1 -0
  33. package/dist/tsup/{chunk-VHGY7PU5.cjs → chunk-FVAKREFB.cjs} +1900 -1737
  34. package/dist/tsup/chunk-FVAKREFB.cjs.map +1 -0
  35. package/dist/tsup/{chunk-BLK27ES3.js → chunk-I3XT7WOF.js} +44 -56
  36. package/dist/tsup/chunk-I3XT7WOF.js.map +1 -0
  37. package/dist/tsup/{chunk-YBHYXIP6.js → chunk-IMDS5T42.js} +3 -3
  38. package/dist/tsup/chunk-IMDS5T42.js.map +1 -0
  39. package/dist/tsup/{chunk-INNFK746.cjs → chunk-J3HZJF2P.cjs} +10 -14
  40. package/dist/tsup/chunk-J3HZJF2P.cjs.map +1 -0
  41. package/dist/tsup/{chunk-BYMKMOBS.js → chunk-MBBJUHSP.js} +1844 -1681
  42. package/dist/tsup/chunk-MBBJUHSP.js.map +1 -0
  43. package/dist/tsup/{chunk-BOMZS2TJ.js → chunk-MO5CB6MD.js} +9 -9
  44. package/dist/tsup/chunk-MO5CB6MD.js.map +1 -0
  45. package/dist/tsup/chunk-OFOTPKAH.js +512 -0
  46. package/dist/tsup/chunk-OFOTPKAH.js.map +1 -0
  47. package/dist/tsup/{chunk-G64QUEDJ.js → chunk-W6RDS6NW.js} +23 -28
  48. package/dist/tsup/chunk-W6RDS6NW.js.map +1 -0
  49. package/dist/tsup/{chunk-36JJ4IQB.cjs → chunk-YC5DUHPM.cjs} +4 -8
  50. package/dist/tsup/chunk-YC5DUHPM.cjs.map +1 -0
  51. package/dist/tsup/{chunk-FX7TWFQR.js → chunk-YC7YPM2T.js} +2 -6
  52. package/dist/tsup/chunk-YC7YPM2T.js.map +1 -0
  53. package/dist/tsup/{chunk-227FEWMB.js → chunk-ZSPU5R4C.js} +3322 -2251
  54. package/dist/tsup/chunk-ZSPU5R4C.js.map +1 -0
  55. package/dist/tsup/client/mod.cjs +9 -9
  56. package/dist/tsup/client/mod.d.cts +5 -7
  57. package/dist/tsup/client/mod.d.ts +5 -7
  58. package/dist/tsup/client/mod.js +8 -8
  59. package/dist/tsup/common/log.cjs +3 -3
  60. package/dist/tsup/common/log.js +2 -2
  61. package/dist/tsup/common/websocket.cjs +4 -4
  62. package/dist/tsup/common/websocket.js +3 -3
  63. package/dist/tsup/{conn-B3Vhbgnd.d.ts → config-BRDYDraU.d.cts} +1119 -1047
  64. package/dist/tsup/{conn-DJWL3nGx.d.cts → config-Bo-blHpJ.d.ts} +1119 -1047
  65. package/dist/tsup/driver-helpers/mod.cjs +5 -13
  66. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  67. package/dist/tsup/driver-helpers/mod.d.cts +11 -9
  68. package/dist/tsup/driver-helpers/mod.d.ts +11 -9
  69. package/dist/tsup/driver-helpers/mod.js +14 -22
  70. package/dist/tsup/driver-test-suite/mod.cjs +474 -303
  71. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  72. package/dist/tsup/driver-test-suite/mod.d.cts +6 -9
  73. package/dist/tsup/driver-test-suite/mod.d.ts +6 -9
  74. package/dist/tsup/driver-test-suite/mod.js +1085 -914
  75. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  76. package/dist/tsup/inspector/mod.cjs +6 -6
  77. package/dist/tsup/inspector/mod.d.cts +5 -7
  78. package/dist/tsup/inspector/mod.d.ts +5 -7
  79. package/dist/tsup/inspector/mod.js +5 -5
  80. package/dist/tsup/mod.cjs +10 -16
  81. package/dist/tsup/mod.cjs.map +1 -1
  82. package/dist/tsup/mod.d.cts +23 -25
  83. package/dist/tsup/mod.d.ts +23 -25
  84. package/dist/tsup/mod.js +17 -23
  85. package/dist/tsup/test/mod.cjs +11 -11
  86. package/dist/tsup/test/mod.d.cts +4 -6
  87. package/dist/tsup/test/mod.d.ts +4 -6
  88. package/dist/tsup/test/mod.js +10 -10
  89. package/dist/tsup/utils.cjs +3 -5
  90. package/dist/tsup/utils.cjs.map +1 -1
  91. package/dist/tsup/utils.d.cts +1 -2
  92. package/dist/tsup/utils.d.ts +1 -2
  93. package/dist/tsup/utils.js +2 -4
  94. package/package.json +13 -6
  95. package/src/actor/config.ts +56 -44
  96. package/src/actor/conn/driver.ts +61 -0
  97. package/src/actor/conn/drivers/http.ts +17 -0
  98. package/src/actor/conn/drivers/raw-request.ts +24 -0
  99. package/src/actor/conn/drivers/raw-websocket.ts +65 -0
  100. package/src/actor/conn/drivers/websocket.ts +129 -0
  101. package/src/actor/conn/mod.ts +232 -0
  102. package/src/actor/conn/persisted.ts +81 -0
  103. package/src/actor/conn/state-manager.ts +196 -0
  104. package/src/actor/contexts/action.ts +23 -0
  105. package/src/actor/{context.ts → contexts/actor.ts} +19 -8
  106. package/src/actor/contexts/conn-init.ts +31 -0
  107. package/src/actor/contexts/conn.ts +48 -0
  108. package/src/actor/contexts/create-conn-state.ts +13 -0
  109. package/src/actor/contexts/on-before-connect.ts +13 -0
  110. package/src/actor/contexts/on-connect.ts +22 -0
  111. package/src/actor/contexts/request.ts +48 -0
  112. package/src/actor/contexts/websocket.ts +48 -0
  113. package/src/actor/definition.ts +3 -3
  114. package/src/actor/driver.ts +36 -5
  115. package/src/actor/errors.ts +19 -24
  116. package/src/actor/instance/connection-manager.ts +465 -0
  117. package/src/actor/instance/event-manager.ts +292 -0
  118. package/src/actor/instance/kv.ts +15 -0
  119. package/src/actor/instance/mod.ts +1107 -0
  120. package/src/actor/instance/persisted.ts +67 -0
  121. package/src/actor/instance/schedule-manager.ts +349 -0
  122. package/src/actor/instance/state-manager.ts +502 -0
  123. package/src/actor/mod.ts +13 -16
  124. package/src/actor/protocol/old.ts +131 -43
  125. package/src/actor/protocol/serde.ts +19 -4
  126. package/src/actor/router-endpoints.ts +61 -586
  127. package/src/actor/router-websocket-endpoints.ts +408 -0
  128. package/src/actor/router.ts +63 -197
  129. package/src/actor/schedule.ts +1 -1
  130. package/src/client/actor-conn.ts +183 -249
  131. package/src/client/actor-handle.ts +29 -6
  132. package/src/client/client.ts +0 -4
  133. package/src/client/config.ts +1 -4
  134. package/src/client/mod.ts +0 -1
  135. package/src/client/raw-utils.ts +3 -3
  136. package/src/client/utils.ts +85 -39
  137. package/src/common/actor-router-consts.ts +5 -12
  138. package/src/common/{inline-websocket-adapter2.ts → inline-websocket-adapter.ts} +26 -48
  139. package/src/common/log.ts +1 -1
  140. package/src/common/router.ts +28 -17
  141. package/src/common/utils.ts +2 -0
  142. package/src/driver-helpers/mod.ts +7 -10
  143. package/src/driver-helpers/utils.ts +18 -9
  144. package/src/driver-test-suite/mod.ts +26 -50
  145. package/src/driver-test-suite/test-inline-client-driver.ts +27 -51
  146. package/src/driver-test-suite/tests/actor-conn-hibernation.ts +150 -0
  147. package/src/driver-test-suite/tests/actor-conn-state.ts +1 -4
  148. package/src/driver-test-suite/tests/actor-conn.ts +5 -9
  149. package/src/driver-test-suite/tests/actor-destroy.ts +294 -0
  150. package/src/driver-test-suite/tests/actor-driver.ts +0 -7
  151. package/src/driver-test-suite/tests/actor-handle.ts +12 -12
  152. package/src/driver-test-suite/tests/actor-metadata.ts +1 -1
  153. package/src/driver-test-suite/tests/manager-driver.ts +1 -1
  154. package/src/driver-test-suite/tests/raw-http-direct-registry.ts +8 -8
  155. package/src/driver-test-suite/tests/raw-http-request-properties.ts +6 -5
  156. package/src/driver-test-suite/tests/raw-http.ts +5 -5
  157. package/src/driver-test-suite/tests/raw-websocket-direct-registry.ts +7 -7
  158. package/src/driver-test-suite/tests/request-access.ts +4 -4
  159. package/src/driver-test-suite/utils.ts +6 -10
  160. package/src/drivers/engine/actor-driver.ts +614 -424
  161. package/src/drivers/engine/mod.ts +0 -1
  162. package/src/drivers/file-system/actor.ts +24 -12
  163. package/src/drivers/file-system/global-state.ts +427 -37
  164. package/src/drivers/file-system/manager.ts +71 -83
  165. package/src/drivers/file-system/mod.ts +3 -0
  166. package/src/drivers/file-system/utils.ts +18 -8
  167. package/src/engine-process/mod.ts +38 -38
  168. package/src/inspector/utils.ts +7 -5
  169. package/src/manager/driver.ts +11 -4
  170. package/src/manager/gateway.ts +4 -29
  171. package/src/manager/protocol/mod.ts +0 -2
  172. package/src/manager/protocol/query.ts +0 -4
  173. package/src/manager/router.ts +67 -64
  174. package/src/manager-api/actors.ts +13 -0
  175. package/src/mod.ts +1 -3
  176. package/src/registry/mod.ts +20 -20
  177. package/src/registry/serve.ts +9 -14
  178. package/src/remote-manager-driver/actor-websocket-client.ts +1 -16
  179. package/src/remote-manager-driver/api-endpoints.ts +13 -1
  180. package/src/remote-manager-driver/api-utils.ts +8 -0
  181. package/src/remote-manager-driver/metadata.ts +58 -0
  182. package/src/remote-manager-driver/mod.ts +47 -62
  183. package/src/remote-manager-driver/ws-proxy.ts +1 -1
  184. package/src/schemas/actor-persist/mod.ts +1 -1
  185. package/src/schemas/actor-persist/versioned.ts +56 -31
  186. package/src/schemas/client-protocol/mod.ts +1 -1
  187. package/src/schemas/client-protocol/versioned.ts +41 -21
  188. package/src/schemas/client-protocol-zod/mod.ts +103 -0
  189. package/src/schemas/file-system-driver/mod.ts +1 -1
  190. package/src/schemas/file-system-driver/versioned.ts +42 -19
  191. package/src/serde.ts +33 -11
  192. package/src/test/mod.ts +7 -3
  193. package/src/utils/node.ts +173 -0
  194. package/src/utils.ts +0 -4
  195. package/dist/tsup/chunk-227FEWMB.js.map +0 -1
  196. package/dist/tsup/chunk-2JYPS5YM.cjs.map +0 -1
  197. package/dist/tsup/chunk-36JJ4IQB.cjs.map +0 -1
  198. package/dist/tsup/chunk-7L65NNWP.cjs.map +0 -1
  199. package/dist/tsup/chunk-BLK27ES3.js.map +0 -1
  200. package/dist/tsup/chunk-BOMZS2TJ.js.map +0 -1
  201. package/dist/tsup/chunk-BYMKMOBS.js.map +0 -1
  202. package/dist/tsup/chunk-FX7TWFQR.js.map +0 -1
  203. package/dist/tsup/chunk-G64QUEDJ.js.map +0 -1
  204. package/dist/tsup/chunk-HHFKKVLR.cjs.map +0 -1
  205. package/dist/tsup/chunk-INNFK746.cjs.map +0 -1
  206. package/dist/tsup/chunk-KSRXX3Z4.cjs.map +0 -1
  207. package/dist/tsup/chunk-O44LFKSB.cjs +0 -4623
  208. package/dist/tsup/chunk-O44LFKSB.cjs.map +0 -1
  209. package/dist/tsup/chunk-PLUN2NQT.js.map +0 -1
  210. package/dist/tsup/chunk-S4UJG7ZE.js +0 -1119
  211. package/dist/tsup/chunk-S4UJG7ZE.js.map +0 -1
  212. package/dist/tsup/chunk-SHVX2QUR.cjs.map +0 -1
  213. package/dist/tsup/chunk-VFB23BYZ.cjs +0 -1119
  214. package/dist/tsup/chunk-VFB23BYZ.cjs.map +0 -1
  215. package/dist/tsup/chunk-VHGY7PU5.cjs.map +0 -1
  216. package/dist/tsup/chunk-YBG6R7LX.js.map +0 -1
  217. package/dist/tsup/chunk-YBHYXIP6.js.map +0 -1
  218. package/src/actor/action.ts +0 -178
  219. package/src/actor/conn-drivers.ts +0 -216
  220. package/src/actor/conn-socket.ts +0 -8
  221. package/src/actor/conn.ts +0 -272
  222. package/src/actor/instance.ts +0 -2336
  223. package/src/actor/persisted.ts +0 -49
  224. package/src/actor/unstable-react.ts +0 -110
  225. package/src/driver-test-suite/tests/actor-reconnect.ts +0 -170
  226. package/src/drivers/engine/kv.ts +0 -3
  227. package/src/manager/hono-websocket-adapter.ts +0 -393
  228. /package/dist/tsup/{chunk-CD33GT6Z.js.map → chunk-EIPANQMF.js.map} +0 -0
@@ -0,0 +1,22 @@
1
+ import type { AnyDatabaseProvider } from "../database";
2
+ import { ConnContext } from "./conn";
3
+
4
+ /**
5
+ * Context for the onConnect lifecycle hook.
6
+ * Called when a connection is successfully established.
7
+ */
8
+ export class OnConnectContext<
9
+ TState,
10
+ TConnParams,
11
+ TConnState,
12
+ TVars,
13
+ TInput,
14
+ TDatabase extends AnyDatabaseProvider,
15
+ > extends ConnContext<
16
+ TState,
17
+ TConnParams,
18
+ TConnState,
19
+ TVars,
20
+ TInput,
21
+ TDatabase
22
+ > {}
@@ -0,0 +1,48 @@
1
+ import type { Conn } from "../conn/mod";
2
+ import type { AnyDatabaseProvider } from "../database";
3
+ import type { ActorInstance } from "../instance/mod";
4
+ import { ConnContext } from "./conn";
5
+
6
+ /**
7
+ * Context for raw HTTP request handlers (onRequest).
8
+ */
9
+ export class RequestContext<
10
+ TState,
11
+ TConnParams,
12
+ TConnState,
13
+ TVars,
14
+ TInput,
15
+ TDatabase extends AnyDatabaseProvider,
16
+ > extends ConnContext<
17
+ TState,
18
+ TConnParams,
19
+ TConnState,
20
+ TVars,
21
+ TInput,
22
+ TDatabase
23
+ > {
24
+ /**
25
+ * The incoming HTTP request.
26
+ * May be undefined for request contexts initiated without a direct HTTP request.
27
+ */
28
+ public readonly request: Request | undefined;
29
+
30
+ /**
31
+ * @internal
32
+ */
33
+ constructor(
34
+ actor: ActorInstance<
35
+ TState,
36
+ TConnParams,
37
+ TConnState,
38
+ TVars,
39
+ TInput,
40
+ TDatabase
41
+ >,
42
+ conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>,
43
+ request?: Request,
44
+ ) {
45
+ super(actor, conn);
46
+ this.request = request;
47
+ }
48
+ }
@@ -0,0 +1,48 @@
1
+ import type { Conn } from "../conn/mod";
2
+ import type { AnyDatabaseProvider } from "../database";
3
+ import type { ActorInstance } from "../instance/mod";
4
+ import { ConnContext } from "./conn";
5
+
6
+ /**
7
+ * Context for raw WebSocket handlers (onWebSocket).
8
+ */
9
+ export class WebSocketContext<
10
+ TState,
11
+ TConnParams,
12
+ TConnState,
13
+ TVars,
14
+ TInput,
15
+ TDatabase extends AnyDatabaseProvider,
16
+ > extends ConnContext<
17
+ TState,
18
+ TConnParams,
19
+ TConnState,
20
+ TVars,
21
+ TInput,
22
+ TDatabase
23
+ > {
24
+ /**
25
+ * The incoming HTTP request that initiated the WebSocket upgrade.
26
+ * May be undefined for WebSocket connections initiated without a direct HTTP request.
27
+ */
28
+ public readonly request: Request | undefined;
29
+
30
+ /**
31
+ * @internal
32
+ */
33
+ constructor(
34
+ actor: ActorInstance<
35
+ TState,
36
+ TConnParams,
37
+ TConnState,
38
+ TVars,
39
+ TInput,
40
+ TDatabase
41
+ >,
42
+ conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>,
43
+ request?: Request,
44
+ ) {
45
+ super(actor, conn);
46
+ this.request = request;
47
+ }
48
+ }
@@ -1,9 +1,9 @@
1
1
  import type { RegistryConfig } from "@/registry/config";
2
- import type { ActionContext } from "./action";
3
2
  import type { Actions, ActorConfig } from "./config";
4
- import type { ActorContext } from "./context";
3
+ import type { ActionContext } from "./contexts/action";
4
+ import type { ActorContext } from "./contexts/actor";
5
5
  import type { AnyDatabaseProvider } from "./database";
6
- import { ActorInstance } from "./instance";
6
+ import { ActorInstance } from "./instance/mod";
7
7
 
8
8
  export type AnyActorDefinition = ActorDefinition<
9
9
  any,
@@ -3,7 +3,8 @@ import type { AnyClient } from "@/client/client";
3
3
  import type { ManagerDriver } from "@/manager/driver";
4
4
  import type { RegistryConfig } from "@/registry/config";
5
5
  import type { RunnerConfig } from "@/registry/run-config";
6
- import type { AnyActorInstance } from "./instance";
6
+ import { type AnyConn, Conn } from "./conn/mod";
7
+ import type { AnyActorInstance } from "./instance/mod";
7
8
 
8
9
  export type ActorDriverBuilder = (
9
10
  registryConfig: RegistryConfig,
@@ -19,10 +20,27 @@ export interface ActorDriver {
19
20
 
20
21
  getContext(actorId: string): unknown;
21
22
 
22
- readPersistedData(actorId: string): Promise<Uint8Array | undefined>;
23
+ // Batch KV operations
24
+ /** Batch write multiple key-value pairs. Keys and values are Uint8Arrays. */
25
+ kvBatchPut(
26
+ actorId: string,
27
+ entries: [Uint8Array, Uint8Array][],
28
+ ): Promise<void>;
23
29
 
24
- /** ActorInstance ensure that only one instance of writePersistedData is called in parallel at a time. */
25
- writePersistedData(actorId: string, data: Uint8Array): Promise<void>;
30
+ /** Batch read multiple keys. Returns null for keys that don't exist. */
31
+ kvBatchGet(
32
+ actorId: string,
33
+ keys: Uint8Array[],
34
+ ): Promise<(Uint8Array | null)[]>;
35
+
36
+ /** Batch delete multiple keys. */
37
+ kvBatchDelete(actorId: string, keys: Uint8Array[]): Promise<void>;
38
+
39
+ /** List all keys with a given prefix. */
40
+ kvListPrefix(
41
+ actorId: string,
42
+ prefix: Uint8Array,
43
+ ): Promise<[Uint8Array, Uint8Array][]>;
26
44
 
27
45
  // Schedule
28
46
  /** ActorInstance ensure that only one instance of setAlarm is called in parallel at a time. */
@@ -38,10 +56,17 @@ export interface ActorDriver {
38
56
  /**
39
57
  * Requests the actor to go to sleep.
40
58
  *
41
- * This will call `_stop` independently.
59
+ * This will call `ActorInstance.onStop` independently.
42
60
  */
43
61
  startSleep?(actorId: string): void;
44
62
 
63
+ /**
64
+ * Destroys the actor and its associated data.
65
+ *
66
+ * This will call `ActorInstance.onStop` independently.
67
+ */
68
+ startDestroy(actorId: string): void;
69
+
45
70
  /**
46
71
  * Shuts down the actor runner.
47
72
  */
@@ -53,4 +78,10 @@ export interface ActorDriver {
53
78
 
54
79
  /** Extra properties to add to logs for each actor. */
55
80
  getExtraActorLogParams?(): Record<string, string>;
81
+
82
+ onBeforeActorStart?(actor: AnyActorInstance): Promise<void>;
83
+ onCreateConn?(conn: AnyConn): void;
84
+ onDestroyConn?(conn: AnyConn): void;
85
+ onBeforePersistConn?(conn: AnyConn): void;
86
+ onAfterPersistConn?(conn: AnyConn): void;
56
87
  }
@@ -133,22 +133,6 @@ export class InvalidEncoding extends ActorError {
133
133
  }
134
134
  }
135
135
 
136
- export class ConnNotFound extends ActorError {
137
- constructor(id?: string) {
138
- super("connection", "not_found", `Connection not found for ID: ${id}`, {
139
- public: true,
140
- });
141
- }
142
- }
143
-
144
- export class IncorrectConnToken extends ActorError {
145
- constructor() {
146
- super("connection", "incorrect_token", "Incorrect connection token.", {
147
- public: true,
148
- });
149
- }
150
- }
151
-
152
136
  export class MessageTooLong extends ActorError {
153
137
  constructor() {
154
138
  super(
@@ -255,17 +239,28 @@ export class ActorNotFound extends ActorError {
255
239
  }
256
240
  }
257
241
 
258
- export class ActorAlreadyExists extends ActorError {
242
+ export class ActorDuplicateKey extends ActorError {
259
243
  constructor(name: string, key: string[]) {
260
244
  super(
261
245
  "actor",
262
- "already_exists",
246
+ "duplicate_key",
263
247
  `Actor already exists with name '${name}' and key '${JSON.stringify(key)}' (https://www.rivet.dev/docs/actors/clients/#actor-client)`,
264
248
  { public: true },
265
249
  );
266
250
  }
267
251
  }
268
252
 
253
+ export class ActorStopping extends ActorError {
254
+ constructor(identifier?: string) {
255
+ super(
256
+ "actor",
257
+ "stopping",
258
+ identifier ? `Actor stopping: ${identifier}` : "Actor stopping",
259
+ { public: true },
260
+ );
261
+ }
262
+ }
263
+
269
264
  export class ProxyError extends ActorError {
270
265
  constructor(operation: string, error?: unknown) {
271
266
  super(
@@ -333,12 +328,12 @@ export class DatabaseNotEnabled extends ActorError {
333
328
  }
334
329
  }
335
330
 
336
- export class FetchHandlerNotDefined extends ActorError {
331
+ export class RequestHandlerNotDfeined extends ActorError {
337
332
  constructor() {
338
333
  super(
339
334
  "handler",
340
- "fetch_not_defined",
341
- "Raw HTTP handler not defined. Actor must implement `onFetch` to handle raw HTTP requests. (https://www.rivet.dev/docs/actors/fetch-and-websocket-handler/)",
335
+ "request_not_defined",
336
+ "Raw request handler not defined. Actor must implement `onRequest` to handle raw HTTP requests. (https://www.rivet.dev/docs/actors/fetch-and-websocket-handler/)",
342
337
  { public: true },
343
338
  );
344
339
  this.statusCode = 404;
@@ -357,12 +352,12 @@ export class WebSocketHandlerNotDefined extends ActorError {
357
352
  }
358
353
  }
359
354
 
360
- export class InvalidFetchResponse extends ActorError {
355
+ export class InvalidRequestHandlerResponse extends ActorError {
361
356
  constructor() {
362
357
  super(
363
358
  "handler",
364
- "invalid_fetch_response",
365
- "Actor's onFetch handler must return a Response object. Returning void/undefined is not allowed. (https://www.rivet.dev/docs/actors/fetch-and-websocket-handler/)",
359
+ "invalid_request_handler_response",
360
+ "Actor's onRequest handler must return a Response object. Returning void/undefined is not allowed. (https://www.rivet.dev/docs/actors/fetch-and-websocket-handler/)",
366
361
  { public: true },
367
362
  );
368
363
  this.statusCode = 500;