rivetkit 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) 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-6PDXBYI5.js → chunk-3F2YSRJL.js} +8 -23
  10. package/dist/tsup/chunk-3F2YSRJL.js.map +1 -0
  11. package/dist/tsup/chunk-4CXBCT26.cjs +250 -0
  12. package/dist/tsup/chunk-4CXBCT26.cjs.map +1 -0
  13. package/dist/tsup/chunk-4R73YDN3.cjs +20 -0
  14. package/dist/tsup/chunk-4R73YDN3.cjs.map +1 -0
  15. package/dist/tsup/{chunk-OGAPU3UG.cjs → chunk-6LJT3QRL.cjs} +39 -25
  16. package/dist/tsup/chunk-6LJT3QRL.cjs.map +1 -0
  17. package/dist/tsup/{chunk-6WKQDDUD.cjs → chunk-GICQ3YCU.cjs} +143 -141
  18. package/dist/tsup/chunk-GICQ3YCU.cjs.map +1 -0
  19. package/dist/tsup/{chunk-FLMTTN27.js → chunk-H26RP6GD.js} +15 -8
  20. package/dist/tsup/chunk-H26RP6GD.js.map +1 -0
  21. package/dist/tsup/chunk-HI3HWJRC.js +20 -0
  22. package/dist/tsup/chunk-HI3HWJRC.js.map +1 -0
  23. package/dist/tsup/{chunk-4NSUQZ2H.js → chunk-HLLF4B4Q.js} +116 -114
  24. package/dist/tsup/chunk-HLLF4B4Q.js.map +1 -0
  25. package/dist/tsup/{chunk-FCCPJNMA.cjs → chunk-IH6CKNDW.cjs} +12 -27
  26. package/dist/tsup/chunk-IH6CKNDW.cjs.map +1 -0
  27. package/dist/tsup/chunk-LV2S3OU3.js +250 -0
  28. package/dist/tsup/chunk-LV2S3OU3.js.map +1 -0
  29. package/dist/tsup/{chunk-R2OPSKIV.cjs → chunk-LWNKVZG5.cjs} +20 -13
  30. package/dist/tsup/chunk-LWNKVZG5.cjs.map +1 -0
  31. package/dist/tsup/{chunk-INGJP237.js → chunk-NFU2BBT5.js} +102 -43
  32. package/dist/tsup/chunk-NFU2BBT5.js.map +1 -0
  33. package/dist/tsup/{chunk-3H7O2A7I.js → chunk-PQY7KKTL.js} +33 -19
  34. package/dist/tsup/chunk-PQY7KKTL.js.map +1 -0
  35. package/dist/tsup/{chunk-PO4VLDWA.js → chunk-QK72M5JB.js} +3 -5
  36. package/dist/tsup/chunk-QK72M5JB.js.map +1 -0
  37. package/dist/tsup/{chunk-TZJKSBUQ.cjs → chunk-QNNXFOQV.cjs} +3 -5
  38. package/dist/tsup/chunk-QNNXFOQV.cjs.map +1 -0
  39. package/dist/tsup/{chunk-GIR3AFFI.cjs → chunk-SBHHJ6QS.cjs} +102 -43
  40. package/dist/tsup/chunk-SBHHJ6QS.cjs.map +1 -0
  41. package/dist/tsup/chunk-TQ62L3X7.js +325 -0
  42. package/dist/tsup/chunk-TQ62L3X7.js.map +1 -0
  43. package/dist/tsup/chunk-VO7ZRVVD.cjs +6293 -0
  44. package/dist/tsup/chunk-VO7ZRVVD.cjs.map +1 -0
  45. package/dist/tsup/chunk-WHBPJNGW.cjs +325 -0
  46. package/dist/tsup/chunk-WHBPJNGW.cjs.map +1 -0
  47. package/dist/tsup/chunk-XJQHKJ4P.js +6293 -0
  48. package/dist/tsup/chunk-XJQHKJ4P.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-BI-6UIBJ.d.ts} +196 -226
  63. package/dist/tsup/{connection-BR_Ve4ku.d.cts → connection-Dyd4NLGW.d.cts} +196 -226
  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 +155 -1363
  70. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  71. package/dist/tsup/driver-test-suite/mod.d.cts +11 -5
  72. package/dist/tsup/driver-test-suite/mod.d.ts +11 -5
  73. package/dist/tsup/driver-test-suite/mod.js +876 -2084
  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-BTe_Rsdn.d.cts} +2 -3
  86. package/dist/tsup/{router-endpoints-AYkXG8Tl.d.cts → router-endpoints-CBSrKHmo.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 +3 -3
  95. package/dist/tsup/utils.d.cts +1 -1
  96. package/dist/tsup/utils.d.ts +1 -1
  97. package/dist/tsup/utils.js +2 -2
  98. package/package.json +4 -4
  99. package/src/actor/action.ts +1 -5
  100. package/src/actor/config.ts +27 -295
  101. package/src/actor/connection.ts +9 -12
  102. package/src/actor/context.ts +1 -4
  103. package/src/actor/definition.ts +7 -11
  104. package/src/actor/errors.ts +97 -35
  105. package/src/actor/generic-conn-driver.ts +28 -16
  106. package/src/actor/instance.ts +177 -133
  107. package/src/actor/log.ts +4 -13
  108. package/src/actor/mod.ts +0 -5
  109. package/src/actor/protocol/old.ts +42 -26
  110. package/src/actor/protocol/serde.ts +1 -1
  111. package/src/actor/router-endpoints.ts +41 -38
  112. package/src/actor/router.ts +20 -18
  113. package/src/actor/unstable-react.ts +1 -1
  114. package/src/actor/utils.ts +6 -2
  115. package/src/client/actor-common.ts +1 -1
  116. package/src/client/actor-conn.ts +152 -91
  117. package/src/client/actor-handle.ts +85 -25
  118. package/src/client/actor-query.ts +65 -0
  119. package/src/client/client.ts +29 -98
  120. package/src/client/config.ts +44 -0
  121. package/src/client/errors.ts +1 -0
  122. package/src/client/log.ts +2 -4
  123. package/src/client/mod.ts +16 -12
  124. package/src/client/raw-utils.ts +82 -25
  125. package/src/client/utils.ts +5 -3
  126. package/src/common/fake-event-source.ts +10 -9
  127. package/src/common/inline-websocket-adapter2.ts +39 -30
  128. package/src/common/log.ts +176 -101
  129. package/src/common/logfmt.ts +21 -30
  130. package/src/common/router.ts +12 -19
  131. package/src/common/utils.ts +27 -13
  132. package/src/common/websocket.ts +0 -1
  133. package/src/driver-helpers/mod.ts +1 -1
  134. package/src/driver-test-suite/log.ts +1 -3
  135. package/src/driver-test-suite/mod.ts +86 -60
  136. package/src/driver-test-suite/tests/actor-handle.ts +33 -0
  137. package/src/driver-test-suite/tests/manager-driver.ts +5 -3
  138. package/src/driver-test-suite/tests/raw-http-direct-registry.ts +227 -226
  139. package/src/driver-test-suite/tests/raw-websocket-direct-registry.ts +393 -392
  140. package/src/driver-test-suite/tests/request-access.ts +112 -126
  141. package/src/driver-test-suite/utils.ts +13 -10
  142. package/src/drivers/default.ts +7 -4
  143. package/src/drivers/engine/actor-driver.ts +22 -13
  144. package/src/drivers/engine/config.ts +2 -10
  145. package/src/drivers/engine/kv.ts +1 -1
  146. package/src/drivers/engine/log.ts +1 -3
  147. package/src/drivers/engine/mod.ts +2 -3
  148. package/src/drivers/file-system/actor.ts +1 -1
  149. package/src/drivers/file-system/global-state.ts +33 -20
  150. package/src/drivers/file-system/log.ts +1 -3
  151. package/src/drivers/file-system/manager.ts +31 -8
  152. package/src/inspector/config.ts +9 -4
  153. package/src/inspector/log.ts +1 -1
  154. package/src/inspector/manager.ts +2 -2
  155. package/src/inspector/utils.ts +1 -1
  156. package/src/manager/driver.ts +10 -2
  157. package/src/manager/hono-websocket-adapter.ts +21 -12
  158. package/src/manager/log.ts +2 -4
  159. package/src/manager/mod.ts +1 -1
  160. package/src/manager/router.ts +277 -1657
  161. package/src/manager-api/routes/actors-create.ts +16 -0
  162. package/src/manager-api/routes/actors-delete.ts +4 -0
  163. package/src/manager-api/routes/actors-get-by-id.ts +7 -0
  164. package/src/manager-api/routes/actors-get-or-create-by-id.ts +29 -0
  165. package/src/manager-api/routes/actors-get.ts +7 -0
  166. package/src/manager-api/routes/common.ts +18 -0
  167. package/src/mod.ts +0 -2
  168. package/src/registry/config.ts +1 -1
  169. package/src/registry/log.ts +2 -4
  170. package/src/registry/mod.ts +57 -24
  171. package/src/registry/run-config.ts +31 -33
  172. package/src/registry/serve.ts +4 -5
  173. package/src/remote-manager-driver/actor-http-client.ts +72 -0
  174. package/src/remote-manager-driver/actor-websocket-client.ts +63 -0
  175. package/src/remote-manager-driver/api-endpoints.ts +79 -0
  176. package/src/remote-manager-driver/api-utils.ts +43 -0
  177. package/src/remote-manager-driver/log.ts +5 -0
  178. package/src/remote-manager-driver/mod.ts +274 -0
  179. package/src/{drivers/engine → remote-manager-driver}/ws-proxy.ts +24 -14
  180. package/src/serde.ts +8 -2
  181. package/src/test/log.ts +1 -3
  182. package/src/test/mod.ts +17 -16
  183. package/dist/tsup/chunk-2CRLFV6Z.cjs +0 -202
  184. package/dist/tsup/chunk-2CRLFV6Z.cjs.map +0 -1
  185. package/dist/tsup/chunk-3H7O2A7I.js.map +0 -1
  186. package/dist/tsup/chunk-42I3OZ3Q.js +0 -15
  187. package/dist/tsup/chunk-42I3OZ3Q.js.map +0 -1
  188. package/dist/tsup/chunk-4NSUQZ2H.js.map +0 -1
  189. package/dist/tsup/chunk-6PDXBYI5.js.map +0 -1
  190. package/dist/tsup/chunk-6WKQDDUD.cjs.map +0 -1
  191. package/dist/tsup/chunk-CTBOSFUH.cjs +0 -116
  192. package/dist/tsup/chunk-CTBOSFUH.cjs.map +0 -1
  193. package/dist/tsup/chunk-EGVZZFE2.js +0 -2857
  194. package/dist/tsup/chunk-EGVZZFE2.js.map +0 -1
  195. package/dist/tsup/chunk-FCCPJNMA.cjs.map +0 -1
  196. package/dist/tsup/chunk-FLMTTN27.js.map +0 -1
  197. package/dist/tsup/chunk-GIR3AFFI.cjs.map +0 -1
  198. package/dist/tsup/chunk-INGJP237.js.map +0 -1
  199. package/dist/tsup/chunk-KJCJLKRM.js +0 -116
  200. package/dist/tsup/chunk-KJCJLKRM.js.map +0 -1
  201. package/dist/tsup/chunk-KUPQZYUQ.cjs +0 -15
  202. package/dist/tsup/chunk-KUPQZYUQ.cjs.map +0 -1
  203. package/dist/tsup/chunk-O2MBYIXO.cjs +0 -2857
  204. package/dist/tsup/chunk-O2MBYIXO.cjs.map +0 -1
  205. package/dist/tsup/chunk-OGAPU3UG.cjs.map +0 -1
  206. package/dist/tsup/chunk-OV6AYD4S.js +0 -4406
  207. package/dist/tsup/chunk-OV6AYD4S.js.map +0 -1
  208. package/dist/tsup/chunk-PO4VLDWA.js.map +0 -1
  209. package/dist/tsup/chunk-R2OPSKIV.cjs.map +0 -1
  210. package/dist/tsup/chunk-TZJKSBUQ.cjs.map +0 -1
  211. package/dist/tsup/chunk-UBUC5C3G.cjs +0 -189
  212. package/dist/tsup/chunk-UBUC5C3G.cjs.map +0 -1
  213. package/dist/tsup/chunk-UIM22YJL.cjs +0 -4406
  214. package/dist/tsup/chunk-UIM22YJL.cjs.map +0 -1
  215. package/dist/tsup/chunk-URVFQMYI.cjs +0 -230
  216. package/dist/tsup/chunk-URVFQMYI.cjs.map +0 -1
  217. package/dist/tsup/chunk-UVUPOS46.js +0 -230
  218. package/dist/tsup/chunk-UVUPOS46.js.map +0 -1
  219. package/dist/tsup/chunk-VRRHBNJC.js +0 -189
  220. package/dist/tsup/chunk-VRRHBNJC.js.map +0 -1
  221. package/dist/tsup/chunk-XFSS33EQ.js +0 -202
  222. package/dist/tsup/chunk-XFSS33EQ.js.map +0 -1
  223. package/src/client/http-client-driver.ts +0 -326
  224. package/src/driver-test-suite/test-inline-client-driver.ts +0 -402
  225. package/src/driver-test-suite/tests/actor-auth.ts +0 -591
  226. package/src/drivers/engine/api-endpoints.ts +0 -128
  227. package/src/drivers/engine/api-utils.ts +0 -70
  228. package/src/drivers/engine/manager-driver.ts +0 -391
  229. package/src/inline-client-driver/log.ts +0 -7
  230. package/src/inline-client-driver/mod.ts +0 -385
  231. package/src/manager/auth.ts +0 -121
  232. /package/src/{drivers/engine → actor}/keys.test.ts +0 -0
  233. /package/src/{drivers/engine → actor}/keys.ts +0 -0
@@ -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
+ // }