rivetkit 2.0.3 → 2.0.5

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 (237) hide show
  1. package/README.md +11 -0
  2. package/dist/schemas/actor-persist/v1.ts +21 -24
  3. package/dist/schemas/client-protocol/v1.ts +6 -0
  4. package/dist/tsup/actor/errors.cjs +10 -2
  5. package/dist/tsup/actor/errors.cjs.map +1 -1
  6. package/dist/tsup/actor/errors.d.cts +17 -4
  7. package/dist/tsup/actor/errors.d.ts +17 -4
  8. package/dist/tsup/actor/errors.js +11 -3
  9. package/dist/tsup/{chunk-4NSUQZ2H.js → chunk-2MD57QF4.js} +119 -115
  10. package/dist/tsup/chunk-2MD57QF4.js.map +1 -0
  11. package/dist/tsup/{chunk-GIR3AFFI.cjs → chunk-5QGQK44L.cjs} +103 -44
  12. package/dist/tsup/chunk-5QGQK44L.cjs.map +1 -0
  13. package/dist/tsup/chunk-5YTI25C3.cjs +250 -0
  14. package/dist/tsup/chunk-5YTI25C3.cjs.map +1 -0
  15. package/dist/tsup/chunk-B2QGJGZQ.js +338 -0
  16. package/dist/tsup/chunk-B2QGJGZQ.js.map +1 -0
  17. package/dist/tsup/{chunk-3H7O2A7I.js → chunk-CFFKMUYH.js} +61 -22
  18. package/dist/tsup/chunk-CFFKMUYH.js.map +1 -0
  19. package/dist/tsup/{chunk-FLMTTN27.js → chunk-CKA54YQN.js} +15 -8
  20. package/dist/tsup/chunk-CKA54YQN.js.map +1 -0
  21. package/dist/tsup/chunk-D7NWUCRK.cjs +20 -0
  22. package/dist/tsup/chunk-D7NWUCRK.cjs.map +1 -0
  23. package/dist/tsup/{chunk-FCCPJNMA.cjs → chunk-FGFT4FVX.cjs} +12 -27
  24. package/dist/tsup/chunk-FGFT4FVX.cjs.map +1 -0
  25. package/dist/tsup/chunk-I5VTWPHW.js +20 -0
  26. package/dist/tsup/chunk-I5VTWPHW.js.map +1 -0
  27. package/dist/tsup/{chunk-6WKQDDUD.cjs → chunk-IRMBWX36.cjs} +146 -142
  28. package/dist/tsup/chunk-IRMBWX36.cjs.map +1 -0
  29. package/dist/tsup/chunk-L7QRXNWP.js +6562 -0
  30. package/dist/tsup/chunk-L7QRXNWP.js.map +1 -0
  31. package/dist/tsup/{chunk-R2OPSKIV.cjs → chunk-LZIBTLEY.cjs} +20 -13
  32. package/dist/tsup/chunk-LZIBTLEY.cjs.map +1 -0
  33. package/dist/tsup/chunk-MRZS2J4X.cjs +6562 -0
  34. package/dist/tsup/chunk-MRZS2J4X.cjs.map +1 -0
  35. package/dist/tsup/{chunk-PO4VLDWA.js → chunk-PG3K2LI7.js} +3 -5
  36. package/dist/tsup/chunk-PG3K2LI7.js.map +1 -0
  37. package/dist/tsup/{chunk-TZJKSBUQ.cjs → chunk-PHSQJ6QI.cjs} +3 -5
  38. package/dist/tsup/chunk-PHSQJ6QI.cjs.map +1 -0
  39. package/dist/tsup/chunk-RM2SVURR.cjs +338 -0
  40. package/dist/tsup/chunk-RM2SVURR.cjs.map +1 -0
  41. package/dist/tsup/{chunk-OGAPU3UG.cjs → chunk-WADSS5X4.cjs} +66 -27
  42. package/dist/tsup/chunk-WADSS5X4.cjs.map +1 -0
  43. package/dist/tsup/chunk-WNGOBAA7.js +250 -0
  44. package/dist/tsup/chunk-WNGOBAA7.js.map +1 -0
  45. package/dist/tsup/{chunk-INGJP237.js → chunk-YPZFLUO6.js} +103 -44
  46. package/dist/tsup/chunk-YPZFLUO6.js.map +1 -0
  47. package/dist/tsup/{chunk-6PDXBYI5.js → chunk-YW6Y6VNE.js} +8 -23
  48. package/dist/tsup/chunk-YW6Y6VNE.js.map +1 -0
  49. package/dist/tsup/client/mod.cjs +10 -10
  50. package/dist/tsup/client/mod.d.cts +7 -13
  51. package/dist/tsup/client/mod.d.ts +7 -13
  52. package/dist/tsup/client/mod.js +9 -9
  53. package/dist/tsup/common/log.cjs +12 -4
  54. package/dist/tsup/common/log.cjs.map +1 -1
  55. package/dist/tsup/common/log.d.cts +23 -17
  56. package/dist/tsup/common/log.d.ts +23 -17
  57. package/dist/tsup/common/log.js +15 -7
  58. package/dist/tsup/common/websocket.cjs +5 -5
  59. package/dist/tsup/common/websocket.js +4 -4
  60. package/dist/tsup/{common-CpqORuCq.d.cts → common-CXCe7s6i.d.cts} +2 -2
  61. package/dist/tsup/{common-CpqORuCq.d.ts → common-CXCe7s6i.d.ts} +2 -2
  62. package/dist/tsup/{connection-BwUMoe6n.d.ts → connection-BvE-Oq7t.d.ts} +215 -234
  63. package/dist/tsup/{connection-BR_Ve4ku.d.cts → connection-DTzmWwU5.d.cts} +215 -234
  64. package/dist/tsup/driver-helpers/mod.cjs +6 -9
  65. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  66. package/dist/tsup/driver-helpers/mod.d.cts +5 -6
  67. package/dist/tsup/driver-helpers/mod.d.ts +5 -6
  68. package/dist/tsup/driver-helpers/mod.js +6 -9
  69. package/dist/tsup/driver-test-suite/mod.cjs +615 -1357
  70. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  71. package/dist/tsup/driver-test-suite/mod.d.cts +12 -6
  72. package/dist/tsup/driver-test-suite/mod.d.ts +12 -6
  73. package/dist/tsup/driver-test-suite/mod.js +1334 -2076
  74. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  75. package/dist/tsup/inspector/mod.cjs +6 -8
  76. package/dist/tsup/inspector/mod.cjs.map +1 -1
  77. package/dist/tsup/inspector/mod.d.cts +3 -3
  78. package/dist/tsup/inspector/mod.d.ts +3 -3
  79. package/dist/tsup/inspector/mod.js +8 -10
  80. package/dist/tsup/mod.cjs +9 -15
  81. package/dist/tsup/mod.cjs.map +1 -1
  82. package/dist/tsup/mod.d.cts +47 -42
  83. package/dist/tsup/mod.d.ts +47 -42
  84. package/dist/tsup/mod.js +10 -16
  85. package/dist/tsup/{router-endpoints-DAbqVFx2.d.ts → router-endpoints-CctffZNL.d.cts} +2 -3
  86. package/dist/tsup/{router-endpoints-AYkXG8Tl.d.cts → router-endpoints-DFm1BglJ.d.ts} +2 -3
  87. package/dist/tsup/test/mod.cjs +10 -14
  88. package/dist/tsup/test/mod.cjs.map +1 -1
  89. package/dist/tsup/test/mod.d.cts +4 -5
  90. package/dist/tsup/test/mod.d.ts +4 -5
  91. package/dist/tsup/test/mod.js +9 -13
  92. package/dist/tsup/{utils-CT0cv4jd.d.ts → utils-fwx3o3K9.d.cts} +1 -0
  93. package/dist/tsup/{utils-CT0cv4jd.d.cts → utils-fwx3o3K9.d.ts} +1 -0
  94. package/dist/tsup/utils.cjs +5 -3
  95. package/dist/tsup/utils.cjs.map +1 -1
  96. package/dist/tsup/utils.d.cts +19 -2
  97. package/dist/tsup/utils.d.ts +19 -2
  98. package/dist/tsup/utils.js +4 -2
  99. package/package.json +6 -6
  100. package/src/actor/action.ts +1 -5
  101. package/src/actor/config.ts +27 -295
  102. package/src/actor/connection.ts +9 -12
  103. package/src/actor/context.ts +1 -4
  104. package/src/actor/definition.ts +7 -11
  105. package/src/actor/errors.ts +98 -36
  106. package/src/actor/generic-conn-driver.ts +28 -16
  107. package/src/actor/instance.ts +177 -133
  108. package/src/actor/log.ts +4 -13
  109. package/src/actor/mod.ts +0 -5
  110. package/src/actor/protocol/old.ts +42 -26
  111. package/src/actor/protocol/serde.ts +1 -1
  112. package/src/actor/router-endpoints.ts +47 -39
  113. package/src/actor/router.ts +22 -19
  114. package/src/actor/unstable-react.ts +1 -1
  115. package/src/actor/utils.ts +6 -2
  116. package/src/client/actor-common.ts +1 -1
  117. package/src/client/actor-conn.ts +152 -91
  118. package/src/client/actor-handle.ts +85 -25
  119. package/src/client/actor-query.ts +65 -0
  120. package/src/client/client.ts +29 -98
  121. package/src/client/config.ts +44 -0
  122. package/src/client/errors.ts +1 -0
  123. package/src/client/log.ts +2 -4
  124. package/src/client/mod.ts +16 -12
  125. package/src/client/raw-utils.ts +82 -25
  126. package/src/client/utils.ts +5 -3
  127. package/src/common/fake-event-source.ts +10 -9
  128. package/src/common/inline-websocket-adapter2.ts +39 -30
  129. package/src/common/log.ts +176 -101
  130. package/src/common/logfmt.ts +21 -30
  131. package/src/common/router.ts +12 -19
  132. package/src/common/utils.ts +27 -13
  133. package/src/common/websocket.ts +0 -1
  134. package/src/driver-helpers/mod.ts +1 -1
  135. package/src/driver-test-suite/log.ts +1 -3
  136. package/src/driver-test-suite/mod.ts +87 -61
  137. package/src/driver-test-suite/test-inline-client-driver.ts +441 -255
  138. package/src/driver-test-suite/tests/actor-error-handling.ts +4 -12
  139. package/src/driver-test-suite/tests/actor-handle.ts +33 -0
  140. package/src/driver-test-suite/tests/actor-inspector.ts +2 -1
  141. package/src/driver-test-suite/tests/manager-driver.ts +5 -3
  142. package/src/driver-test-suite/tests/raw-http-direct-registry.ts +227 -226
  143. package/src/driver-test-suite/tests/raw-websocket-direct-registry.ts +393 -392
  144. package/src/driver-test-suite/tests/request-access.ts +112 -126
  145. package/src/driver-test-suite/utils.ts +10 -6
  146. package/src/drivers/default.ts +7 -4
  147. package/src/drivers/engine/actor-driver.ts +22 -13
  148. package/src/drivers/engine/config.ts +2 -10
  149. package/src/drivers/engine/kv.ts +1 -1
  150. package/src/drivers/engine/log.ts +1 -3
  151. package/src/drivers/engine/mod.ts +2 -3
  152. package/src/drivers/file-system/actor.ts +1 -1
  153. package/src/drivers/file-system/global-state.ts +36 -21
  154. package/src/drivers/file-system/log.ts +1 -3
  155. package/src/drivers/file-system/manager.ts +33 -15
  156. package/src/inspector/config.ts +9 -4
  157. package/src/inspector/log.ts +1 -1
  158. package/src/inspector/manager.ts +2 -2
  159. package/src/inspector/utils.ts +1 -1
  160. package/src/manager/driver.ts +10 -2
  161. package/src/manager/hono-websocket-adapter.ts +21 -12
  162. package/src/manager/log.ts +2 -4
  163. package/src/manager/mod.ts +1 -1
  164. package/src/manager/router.ts +378 -1390
  165. package/src/manager-api/routes/actors-create.ts +16 -0
  166. package/src/manager-api/routes/actors-delete.ts +4 -0
  167. package/src/manager-api/routes/actors-get-by-id.ts +7 -0
  168. package/src/manager-api/routes/actors-get-or-create-by-id.ts +29 -0
  169. package/src/manager-api/routes/actors-get.ts +7 -0
  170. package/src/manager-api/routes/common.ts +18 -0
  171. package/src/mod.ts +0 -2
  172. package/src/registry/config.ts +1 -1
  173. package/src/registry/log.ts +2 -4
  174. package/src/registry/mod.ts +63 -34
  175. package/src/registry/run-config.ts +39 -26
  176. package/src/registry/serve.ts +4 -5
  177. package/src/remote-manager-driver/actor-http-client.ts +74 -0
  178. package/src/remote-manager-driver/actor-websocket-client.ts +64 -0
  179. package/src/remote-manager-driver/api-endpoints.ts +79 -0
  180. package/src/remote-manager-driver/api-utils.ts +46 -0
  181. package/src/remote-manager-driver/log.ts +5 -0
  182. package/src/remote-manager-driver/mod.ts +275 -0
  183. package/src/{drivers/engine → remote-manager-driver}/ws-proxy.ts +24 -14
  184. package/src/serde.ts +8 -2
  185. package/src/test/log.ts +1 -3
  186. package/src/test/mod.ts +17 -16
  187. package/src/utils.ts +53 -0
  188. package/dist/tsup/chunk-2CRLFV6Z.cjs +0 -202
  189. package/dist/tsup/chunk-2CRLFV6Z.cjs.map +0 -1
  190. package/dist/tsup/chunk-3H7O2A7I.js.map +0 -1
  191. package/dist/tsup/chunk-42I3OZ3Q.js +0 -15
  192. package/dist/tsup/chunk-42I3OZ3Q.js.map +0 -1
  193. package/dist/tsup/chunk-4NSUQZ2H.js.map +0 -1
  194. package/dist/tsup/chunk-6PDXBYI5.js.map +0 -1
  195. package/dist/tsup/chunk-6WKQDDUD.cjs.map +0 -1
  196. package/dist/tsup/chunk-CTBOSFUH.cjs +0 -116
  197. package/dist/tsup/chunk-CTBOSFUH.cjs.map +0 -1
  198. package/dist/tsup/chunk-EGVZZFE2.js +0 -2857
  199. package/dist/tsup/chunk-EGVZZFE2.js.map +0 -1
  200. package/dist/tsup/chunk-FCCPJNMA.cjs.map +0 -1
  201. package/dist/tsup/chunk-FLMTTN27.js.map +0 -1
  202. package/dist/tsup/chunk-GIR3AFFI.cjs.map +0 -1
  203. package/dist/tsup/chunk-INGJP237.js.map +0 -1
  204. package/dist/tsup/chunk-KJCJLKRM.js +0 -116
  205. package/dist/tsup/chunk-KJCJLKRM.js.map +0 -1
  206. package/dist/tsup/chunk-KUPQZYUQ.cjs +0 -15
  207. package/dist/tsup/chunk-KUPQZYUQ.cjs.map +0 -1
  208. package/dist/tsup/chunk-O2MBYIXO.cjs +0 -2857
  209. package/dist/tsup/chunk-O2MBYIXO.cjs.map +0 -1
  210. package/dist/tsup/chunk-OGAPU3UG.cjs.map +0 -1
  211. package/dist/tsup/chunk-OV6AYD4S.js +0 -4406
  212. package/dist/tsup/chunk-OV6AYD4S.js.map +0 -1
  213. package/dist/tsup/chunk-PO4VLDWA.js.map +0 -1
  214. package/dist/tsup/chunk-R2OPSKIV.cjs.map +0 -1
  215. package/dist/tsup/chunk-TZJKSBUQ.cjs.map +0 -1
  216. package/dist/tsup/chunk-UBUC5C3G.cjs +0 -189
  217. package/dist/tsup/chunk-UBUC5C3G.cjs.map +0 -1
  218. package/dist/tsup/chunk-UIM22YJL.cjs +0 -4406
  219. package/dist/tsup/chunk-UIM22YJL.cjs.map +0 -1
  220. package/dist/tsup/chunk-URVFQMYI.cjs +0 -230
  221. package/dist/tsup/chunk-URVFQMYI.cjs.map +0 -1
  222. package/dist/tsup/chunk-UVUPOS46.js +0 -230
  223. package/dist/tsup/chunk-UVUPOS46.js.map +0 -1
  224. package/dist/tsup/chunk-VRRHBNJC.js +0 -189
  225. package/dist/tsup/chunk-VRRHBNJC.js.map +0 -1
  226. package/dist/tsup/chunk-XFSS33EQ.js +0 -202
  227. package/dist/tsup/chunk-XFSS33EQ.js.map +0 -1
  228. package/src/client/http-client-driver.ts +0 -326
  229. package/src/driver-test-suite/tests/actor-auth.ts +0 -591
  230. package/src/drivers/engine/api-endpoints.ts +0 -128
  231. package/src/drivers/engine/api-utils.ts +0 -70
  232. package/src/drivers/engine/manager-driver.ts +0 -391
  233. package/src/inline-client-driver/log.ts +0 -7
  234. package/src/inline-client-driver/mod.ts +0 -385
  235. package/src/manager/auth.ts +0 -121
  236. /package/src/{drivers/engine → actor}/keys.test.ts +0 -0
  237. /package/src/{drivers/engine → actor}/keys.ts +0 -0
@@ -63,18 +63,10 @@ export function runActorErrorHandlingTests(driverTestConfig: DriverTestConfig) {
63
63
  // If we get here, the test should fail
64
64
  expect(true).toBe(false); // This should not be reached
65
65
  } catch (error: any) {
66
- if (driverTestConfig.clientType === "http") {
67
- // Verify the error is converted to a safe format
68
- expect(error.code).toBe(INTERNAL_ERROR_CODE);
69
- // Original error details should not be exposed
70
- expect(error.message).toBe(INTERNAL_ERROR_DESCRIPTION);
71
- } else if (driverTestConfig.clientType === "inline") {
72
- // Verify that original error is preserved
73
- expect(error.code).toBe(INTERNAL_ERROR_CODE);
74
- expect(error.message).toBe("This is an internal error");
75
- } else {
76
- assertUnreachable(driverTestConfig.clientType);
77
- }
66
+ // Verify the error is converted to a safe format
67
+ expect(error.code).toBe(INTERNAL_ERROR_CODE);
68
+ // Original error details should not be exposed
69
+ expect(error.message).toBe(INTERNAL_ERROR_DESCRIPTION);
78
70
  }
79
71
  });
80
72
  });
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, test } from "vitest";
2
+ import type { ActorError } from "@/client/mod";
2
3
  import type { DriverTestConfig } from "../mod";
3
4
  import { setupDriverTest } from "../utils";
4
5
 
@@ -74,6 +75,38 @@ export function runActorHandleTests(driverTestConfig: DriverTestConfig) {
74
75
  const retrievedCount = await handle.getCount();
75
76
  expect(retrievedCount).toBe(9);
76
77
  });
78
+
79
+ test("errors when calling create twice with the same key", async (c) => {
80
+ const { client } = await setupDriverTest(c, driverTestConfig);
81
+
82
+ const key = ["duplicate-create-handle", crypto.randomUUID()];
83
+
84
+ // First create should succeed
85
+ await client.counter.create(key);
86
+
87
+ // Second create with same key should throw ActorAlreadyExists
88
+ try {
89
+ await client.counter.create(key);
90
+ expect.fail("did not error on duplicate create");
91
+ } catch (err) {
92
+ expect((err as ActorError).group).toBe("actor");
93
+ expect((err as ActorError).code).toBe("already_exists");
94
+ }
95
+ });
96
+
97
+ test(".get().resolve() errors for non-existent actor", async (c) => {
98
+ const { client } = await setupDriverTest(c, driverTestConfig);
99
+
100
+ const missingId = `nonexistent-${crypto.randomUUID()}`;
101
+
102
+ try {
103
+ await client.counter.get([missingId]).resolve();
104
+ expect.fail("did not error for get().resolve() on missing actor");
105
+ } catch (err) {
106
+ expect((err as ActorError).group).toBe("actor");
107
+ expect((err as ActorError).code).toBe("not_found");
108
+ }
109
+ });
77
110
  });
78
111
 
79
112
  describe("Action Functionality", () => {
@@ -9,7 +9,8 @@ import type { DriverTestConfig } from "../mod";
9
9
  import { setupDriverTest } from "../utils";
10
10
 
11
11
  export function runActorInspectorTests(driverTestConfig: DriverTestConfig) {
12
- describe("Actor Inspector Tests", () => {
12
+ // TODO: Add back
13
+ describe.skip("Actor Inspector Tests", () => {
13
14
  describe("Manager Inspector", () => {
14
15
  test("should respond to ping", async (c) => {
15
16
  const { endpoint } = await setupDriverTest(c, driverTestConfig);
@@ -39,7 +39,8 @@ export function runManagerDriverTests(driverTestConfig: DriverTestConfig) {
39
39
  await client.counter.create(uniqueKey);
40
40
  expect.fail("did not error on duplicate create");
41
41
  } catch (err) {
42
- expect((err as ActorError).code).toBe("actor_already_exists");
42
+ expect((err as ActorError).group).toBe("actor");
43
+ expect((err as ActorError).code).toBe("already_exists");
43
44
  }
44
45
 
45
46
  // Verify the original actor still works and has its state
@@ -60,7 +61,8 @@ export function runManagerDriverTests(driverTestConfig: DriverTestConfig) {
60
61
  await client.counter.get([nonexistentId]).resolve();
61
62
  expect.fail("did not error for get");
62
63
  } catch (err) {
63
- expect((err as ActorError).code).toBe("actor_not_found");
64
+ expect((err as ActorError).group).toBe("actor");
65
+ expect((err as ActorError).code).toBe("not_found");
64
66
  }
65
67
 
66
68
  // Create the actor
@@ -319,7 +321,7 @@ export function runManagerDriverTests(driverTestConfig: DriverTestConfig) {
319
321
  });
320
322
 
321
323
  describe("Multiple Actor Instances", () => {
322
- // TODO: This test is flakey https://github.com/rivet-gg/rivetkit/issues/873
324
+ // TODO: This test is flakey https://github.com/rivet-dev/rivetkit/issues/873
323
325
  test("creates multiple actor instances of the same type", async (c) => {
324
326
  const { client } = await setupDriverTest(c, driverTestConfig);
325
327
 
@@ -1,226 +1,227 @@
1
- import { describe, expect, test } from "vitest";
2
- import {
3
- HEADER_ACTOR_QUERY,
4
- HEADER_CONN_PARAMS,
5
- } from "@/actor/router-endpoints";
6
- import type { ActorQuery } from "@/manager/protocol/query";
7
- import type { DriverTestConfig } from "../mod";
8
- import { setupDriverTest } from "../utils";
9
-
10
- export function runRawHttpDirectRegistryTests(
11
- driverTestConfig: DriverTestConfig,
12
- ) {
13
- describe("raw http - direct registry access", () => {
14
- test("should handle direct fetch requests to registry with proper headers", async (c) => {
15
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
16
-
17
- // Build the actor query
18
- const actorQuery: ActorQuery = {
19
- getOrCreateForKey: {
20
- name: "rawHttpActor",
21
- key: ["direct-test"],
22
- },
23
- };
24
-
25
- // Make a direct fetch request to the registry
26
- const response = await fetch(
27
- `${endpoint}/registry/actors/raw/http/api/hello`,
28
- {
29
- method: "GET",
30
- headers: {
31
- [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
32
- },
33
- },
34
- );
35
-
36
- expect(response.ok).toBe(true);
37
- expect(response.status).toBe(200);
38
- const data = await response.json();
39
- expect(data).toEqual({ message: "Hello from actor!" });
40
- });
41
-
42
- test("should handle POST requests with body to registry", async (c) => {
43
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
44
-
45
- const actorQuery: ActorQuery = {
46
- getOrCreateForKey: {
47
- name: "rawHttpActor",
48
- key: ["direct-post-test"],
49
- },
50
- };
51
-
52
- const testData = { test: "direct", number: 456 };
53
- const response = await fetch(
54
- `${endpoint}/registry/actors/raw/http/api/echo`,
55
- {
56
- method: "POST",
57
- headers: {
58
- [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
59
- "Content-Type": "application/json",
60
- },
61
- body: JSON.stringify(testData),
62
- },
63
- );
64
-
65
- expect(response.ok).toBe(true);
66
- expect(response.status).toBe(200);
67
- const data = await response.json();
68
- expect(data).toEqual(testData);
69
- });
70
-
71
- test("should pass custom headers through to actor", async (c) => {
72
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
73
-
74
- const actorQuery: ActorQuery = {
75
- getOrCreateForKey: {
76
- name: "rawHttpActor",
77
- key: ["direct-headers-test"],
78
- },
79
- };
80
-
81
- const customHeaders = {
82
- "X-Custom-Header": "direct-test-value",
83
- "X-Another-Header": "another-direct-value",
84
- };
85
-
86
- const response = await fetch(
87
- `${endpoint}/registry/actors/raw/http/api/headers`,
88
- {
89
- method: "GET",
90
- headers: {
91
- [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
92
- ...customHeaders,
93
- },
94
- },
95
- );
96
-
97
- expect(response.ok).toBe(true);
98
- const headers = (await response.json()) as Record<string, string>;
99
- expect(headers["x-custom-header"]).toBe("direct-test-value");
100
- expect(headers["x-another-header"]).toBe("another-direct-value");
101
- });
102
-
103
- test("should handle connection parameters for authentication", async (c) => {
104
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
105
-
106
- const actorQuery: ActorQuery = {
107
- getOrCreateForKey: {
108
- name: "rawHttpActor",
109
- key: ["direct-auth-test"],
110
- },
111
- };
112
-
113
- const connParams = { token: "test-auth-token", userId: "user123" };
114
-
115
- const response = await fetch(
116
- `${endpoint}/registry/actors/raw/http/api/hello`,
117
- {
118
- method: "GET",
119
- headers: {
120
- [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
121
- [HEADER_CONN_PARAMS]: JSON.stringify(connParams),
122
- },
123
- },
124
- );
125
-
126
- expect(response.ok).toBe(true);
127
- const data = await response.json();
128
- expect(data).toEqual({ message: "Hello from actor!" });
129
- });
130
-
131
- test("should return 404 for actors without onFetch handler", async (c) => {
132
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
133
-
134
- const actorQuery: ActorQuery = {
135
- getOrCreateForKey: {
136
- name: "rawHttpNoHandlerActor",
137
- key: ["direct-no-handler"],
138
- },
139
- };
140
-
141
- const response = await fetch(
142
- `${endpoint}/registry/actors/raw/http/api/anything`,
143
- {
144
- method: "GET",
145
- headers: {
146
- [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
147
- },
148
- },
149
- );
150
-
151
- expect(response.ok).toBe(false);
152
- expect(response.status).toBe(404);
153
- });
154
-
155
- test("should handle different HTTP methods", async (c) => {
156
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
157
-
158
- const actorQuery: ActorQuery = {
159
- getOrCreateForKey: {
160
- name: "rawHttpActor",
161
- key: ["direct-methods-test"],
162
- },
163
- };
164
-
165
- // Test various HTTP methods
166
- const methods = ["GET", "POST", "PUT", "DELETE", "PATCH"] as const;
167
-
168
- for (const method of methods) {
169
- const response = await fetch(
170
- `${endpoint}/registry/actors/raw/http/api/echo`,
171
- {
172
- method,
173
- headers: {
174
- [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
175
- ...(method !== "GET"
176
- ? { "Content-Type": "application/json" }
177
- : {}),
178
- },
179
- body: ["POST", "PUT", "PATCH"].includes(method)
180
- ? JSON.stringify({ method })
181
- : undefined,
182
- },
183
- );
184
-
185
- // Echo endpoint only handles POST, others should fall through to 404
186
- if (method === "POST") {
187
- expect(response.ok).toBe(true);
188
- const data = await response.json();
189
- expect(data).toEqual({ method });
190
- } else {
191
- expect(response.status).toBe(404);
192
- }
193
- }
194
- });
195
-
196
- test("should handle binary data", async (c) => {
197
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
198
-
199
- const actorQuery: ActorQuery = {
200
- getOrCreateForKey: {
201
- name: "rawHttpActor",
202
- key: ["direct-binary-test"],
203
- },
204
- };
205
-
206
- // Send binary data
207
- const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
208
- const response = await fetch(
209
- `${endpoint}/registry/actors/raw/http/api/echo`,
210
- {
211
- method: "POST",
212
- headers: {
213
- [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
214
- "Content-Type": "application/octet-stream",
215
- },
216
- body: binaryData,
217
- },
218
- );
219
-
220
- expect(response.ok).toBe(true);
221
- const responseBuffer = await response.arrayBuffer();
222
- const responseArray = new Uint8Array(responseBuffer);
223
- expect(Array.from(responseArray)).toEqual([1, 2, 3, 4, 5]);
224
- });
225
- });
226
- }
1
+ // TODO: re-expose this once we can have actor queries on the gateway
2
+ // import { describe, expect, test } from "vitest";
3
+ // import {
4
+ // HEADER_ACTOR_QUERY,
5
+ // HEADER_CONN_PARAMS,
6
+ // } from "@/actor/router-endpoints";
7
+ // import type { ActorQuery } from "@/manager/protocol/query";
8
+ // import type { DriverTestConfig } from "../mod";
9
+ // import { setupDriverTest } from "../utils";
10
+ //
11
+ // export function runRawHttpDirectRegistryTests(
12
+ // driverTestConfig: DriverTestConfig,
13
+ // ) {
14
+ // describe("raw http - direct registry access", () => {
15
+ // test("should handle direct fetch requests to registry with proper headers", async (c) => {
16
+ // const { endpoint } = await setupDriverTest(c, driverTestConfig);
17
+ //
18
+ // // Build the actor query
19
+ // const actorQuery: ActorQuery = {
20
+ // getOrCreateForKey: {
21
+ // name: "rawHttpActor",
22
+ // key: ["direct-test"],
23
+ // },
24
+ // };
25
+ //
26
+ // // Make a direct fetch request to the registry
27
+ // const response = await fetch(
28
+ // `${endpoint}/registry/actors/raw/http/api/hello`,
29
+ // {
30
+ // method: "GET",
31
+ // headers: {
32
+ // [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
33
+ // },
34
+ // },
35
+ // );
36
+ //
37
+ // expect(response.ok).toBe(true);
38
+ // expect(response.status).toBe(200);
39
+ // const data = await response.json();
40
+ // expect(data).toEqual({ message: "Hello from actor!" });
41
+ // });
42
+ //
43
+ // test("should handle POST requests with body to registry", async (c) => {
44
+ // const { endpoint } = await setupDriverTest(c, driverTestConfig);
45
+ //
46
+ // const actorQuery: ActorQuery = {
47
+ // getOrCreateForKey: {
48
+ // name: "rawHttpActor",
49
+ // key: ["direct-post-test"],
50
+ // },
51
+ // };
52
+ //
53
+ // const testData = { test: "direct", number: 456 };
54
+ // const response = await fetch(
55
+ // `${endpoint}/registry/actors/raw/http/api/echo`,
56
+ // {
57
+ // method: "POST",
58
+ // headers: {
59
+ // [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
60
+ // "Content-Type": "application/json",
61
+ // },
62
+ // body: JSON.stringify(testData),
63
+ // },
64
+ // );
65
+ //
66
+ // expect(response.ok).toBe(true);
67
+ // expect(response.status).toBe(200);
68
+ // const data = await response.json();
69
+ // expect(data).toEqual(testData);
70
+ // });
71
+ //
72
+ // test("should pass custom headers through to actor", async (c) => {
73
+ // const { endpoint } = await setupDriverTest(c, driverTestConfig);
74
+ //
75
+ // const actorQuery: ActorQuery = {
76
+ // getOrCreateForKey: {
77
+ // name: "rawHttpActor",
78
+ // key: ["direct-headers-test"],
79
+ // },
80
+ // };
81
+ //
82
+ // const customHeaders = {
83
+ // "X-Custom-Header": "direct-test-value",
84
+ // "X-Another-Header": "another-direct-value",
85
+ // };
86
+ //
87
+ // const response = await fetch(
88
+ // `${endpoint}/registry/actors/raw/http/api/headers`,
89
+ // {
90
+ // method: "GET",
91
+ // headers: {
92
+ // [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
93
+ // ...customHeaders,
94
+ // },
95
+ // },
96
+ // );
97
+ //
98
+ // expect(response.ok).toBe(true);
99
+ // const headers = (await response.json()) as Record<string, string>;
100
+ // expect(headers["x-custom-header"]).toBe("direct-test-value");
101
+ // expect(headers["x-another-header"]).toBe("another-direct-value");
102
+ // });
103
+ //
104
+ // test("should handle connection parameters for authentication", async (c) => {
105
+ // const { endpoint } = await setupDriverTest(c, driverTestConfig);
106
+ //
107
+ // const actorQuery: ActorQuery = {
108
+ // getOrCreateForKey: {
109
+ // name: "rawHttpActor",
110
+ // key: ["direct-auth-test"],
111
+ // },
112
+ // };
113
+ //
114
+ // const connParams = { token: "test-auth-token", userId: "user123" };
115
+ //
116
+ // const response = await fetch(
117
+ // `${endpoint}/registry/actors/raw/http/api/hello`,
118
+ // {
119
+ // method: "GET",
120
+ // headers: {
121
+ // [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
122
+ // [HEADER_CONN_PARAMS]: JSON.stringify(connParams),
123
+ // },
124
+ // },
125
+ // );
126
+ //
127
+ // expect(response.ok).toBe(true);
128
+ // const data = await response.json();
129
+ // expect(data).toEqual({ message: "Hello from actor!" });
130
+ // });
131
+ //
132
+ // test("should return 404 for actors without onFetch handler", async (c) => {
133
+ // const { endpoint } = await setupDriverTest(c, driverTestConfig);
134
+ //
135
+ // const actorQuery: ActorQuery = {
136
+ // getOrCreateForKey: {
137
+ // name: "rawHttpNoHandlerActor",
138
+ // key: ["direct-no-handler"],
139
+ // },
140
+ // };
141
+ //
142
+ // const response = await fetch(
143
+ // `${endpoint}/registry/actors/raw/http/api/anything`,
144
+ // {
145
+ // method: "GET",
146
+ // headers: {
147
+ // [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
148
+ // },
149
+ // },
150
+ // );
151
+ //
152
+ // expect(response.ok).toBe(false);
153
+ // expect(response.status).toBe(404);
154
+ // });
155
+ //
156
+ // test("should handle different HTTP methods", async (c) => {
157
+ // const { endpoint } = await setupDriverTest(c, driverTestConfig);
158
+ //
159
+ // const actorQuery: ActorQuery = {
160
+ // getOrCreateForKey: {
161
+ // name: "rawHttpActor",
162
+ // key: ["direct-methods-test"],
163
+ // },
164
+ // };
165
+ //
166
+ // // Test various HTTP methods
167
+ // const methods = ["GET", "POST", "PUT", "DELETE", "PATCH"] as const;
168
+ //
169
+ // for (const method of methods) {
170
+ // const response = await fetch(
171
+ // `${endpoint}/registry/actors/raw/http/api/echo`,
172
+ // {
173
+ // method,
174
+ // headers: {
175
+ // [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
176
+ // ...(method !== "GET"
177
+ // ? { "Content-Type": "application/json" }
178
+ // : {}),
179
+ // },
180
+ // body: ["POST", "PUT", "PATCH"].includes(method)
181
+ // ? JSON.stringify({ method })
182
+ // : undefined,
183
+ // },
184
+ // );
185
+ //
186
+ // // Echo endpoint only handles POST, others should fall through to 404
187
+ // if (method === "POST") {
188
+ // expect(response.ok).toBe(true);
189
+ // const data = await response.json();
190
+ // expect(data).toEqual({ method });
191
+ // } else {
192
+ // expect(response.status).toBe(404);
193
+ // }
194
+ // }
195
+ // });
196
+ //
197
+ // test("should handle binary data", async (c) => {
198
+ // const { endpoint } = await setupDriverTest(c, driverTestConfig);
199
+ //
200
+ // const actorQuery: ActorQuery = {
201
+ // getOrCreateForKey: {
202
+ // name: "rawHttpActor",
203
+ // key: ["direct-binary-test"],
204
+ // },
205
+ // };
206
+ //
207
+ // // Send binary data
208
+ // const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
209
+ // const response = await fetch(
210
+ // `${endpoint}/registry/actors/raw/http/api/echo`,
211
+ // {
212
+ // method: "POST",
213
+ // headers: {
214
+ // [HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
215
+ // "Content-Type": "application/octet-stream",
216
+ // },
217
+ // body: binaryData,
218
+ // },
219
+ // );
220
+ //
221
+ // expect(response.ok).toBe(true);
222
+ // const responseBuffer = await response.arrayBuffer();
223
+ // const responseArray = new Uint8Array(responseBuffer);
224
+ // expect(Array.from(responseArray)).toEqual([1, 2, 3, 4, 5]);
225
+ // });
226
+ // });
227
+ // }