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,44 +1,33 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunkFCCPJNMAcjs = require('../chunk-FCCPJNMA.cjs');
3
+ var _chunkIH6CKNDWcjs = require('../chunk-IH6CKNDW.cjs');
4
4
 
5
5
 
6
+ var _chunk4R73YDN3cjs = require('../chunk-4R73YDN3.cjs');
6
7
 
7
8
 
8
- var _chunkUIM22YJLcjs = require('../chunk-UIM22YJL.cjs');
9
9
 
10
+ var _chunkVO7ZRVVDcjs = require('../chunk-VO7ZRVVD.cjs');
10
11
 
11
12
 
12
- var _chunkKUPQZYUQcjs = require('../chunk-KUPQZYUQ.cjs');
13
13
 
14
+ var _chunkLWNKVZG5cjs = require('../chunk-LWNKVZG5.cjs');
15
+ require('../chunk-QNNXFOQV.cjs');
14
16
 
15
- var _chunkURVFQMYIcjs = require('../chunk-URVFQMYI.cjs');
16
17
 
18
+ var _chunkWHBPJNGWcjs = require('../chunk-WHBPJNGW.cjs');
17
19
 
18
20
 
19
- var _chunkO2MBYIXOcjs = require('../chunk-O2MBYIXO.cjs');
20
- require('../chunk-R2OPSKIV.cjs');
21
21
 
22
+ var _chunkGICQ3YCUcjs = require('../chunk-GICQ3YCU.cjs');
22
23
 
23
- var _chunkTZJKSBUQcjs = require('../chunk-TZJKSBUQ.cjs');
24
24
 
25
+ var _chunk4CXBCT26cjs = require('../chunk-4CXBCT26.cjs');
26
+ require('../chunk-6LJT3QRL.cjs');
25
27
 
26
- var _chunkCTBOSFUHcjs = require('../chunk-CTBOSFUH.cjs');
27
- require('../chunk-UBUC5C3G.cjs');
28
28
 
29
29
 
30
-
31
-
32
-
33
- var _chunk6WKQDDUDcjs = require('../chunk-6WKQDDUD.cjs');
34
-
35
-
36
- var _chunk2CRLFV6Zcjs = require('../chunk-2CRLFV6Z.cjs');
37
- require('../chunk-OGAPU3UG.cjs');
38
-
39
-
40
-
41
- var _chunkGIR3AFFIcjs = require('../chunk-GIR3AFFI.cjs');
30
+ var _chunkSBHHJ6QScjs = require('../chunk-SBHHJ6QS.cjs');
42
31
 
43
32
  // src/driver-test-suite/mod.ts
44
33
  var _nodeserver = require('@hono/node-server');
@@ -47,268 +36,17 @@ var _bundlerequire = require('bundle-require');
47
36
  var _invariant = require('invariant'); var _invariant2 = _interopRequireDefault(_invariant);
48
37
  var _vitest = require('vitest');
49
38
 
50
- // src/driver-test-suite/tests/action-features.ts
51
-
52
-
53
- // src/driver-test-suite/utils.ts
54
- var _path = require('path');
55
-
56
-
57
- // src/driver-test-suite/test-inline-client-driver.ts
58
- var _cborx = require('cbor-x'); var cbor = _interopRequireWildcard(_cborx);
59
-
60
39
  // src/driver-test-suite/log.ts
61
- var LOGGER_NAME = "test-suite";
62
40
  function logger() {
63
- return _chunk2CRLFV6Zcjs.getLogger.call(void 0, LOGGER_NAME);
41
+ return _chunk4CXBCT26cjs.getLogger.call(void 0, "test-suite");
64
42
  }
65
43
 
66
- // src/driver-test-suite/test-inline-client-driver.ts
67
- function createTestInlineClientDriver(endpoint, transport) {
68
- return {
69
- action: async (_c, actorQuery, encoding, params, name, args) => {
70
- return makeInlineRequest(
71
- endpoint,
72
- encoding,
73
- transport,
74
- "action",
75
- [void 0, actorQuery, encoding, params, name, args]
76
- );
77
- },
78
- resolveActorId: async (_c, actorQuery, encodingKind, params) => {
79
- return makeInlineRequest(
80
- endpoint,
81
- encodingKind,
82
- transport,
83
- "resolveActorId",
84
- [void 0, actorQuery, encodingKind, params]
85
- );
86
- },
87
- connectWebSocket: async (_c, actorQuery, encodingKind, params) => {
88
- const WebSocket2 = await _chunkTZJKSBUQcjs.importWebSocket.call(void 0, );
89
- logger().debug("creating websocket connection via test inline driver", {
90
- actorQuery,
91
- encodingKind
92
- });
93
- const wsUrl = new URL(
94
- `${endpoint}/registry/.test/inline-driver/connect-websocket`
95
- );
96
- wsUrl.searchParams.set("actorQuery", JSON.stringify(actorQuery));
97
- if (params !== void 0)
98
- wsUrl.searchParams.set("params", JSON.stringify(params));
99
- wsUrl.searchParams.set("encodingKind", encodingKind);
100
- const wsProtocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
101
- const finalWsUrl = `${wsProtocol}//${wsUrl.host}${wsUrl.pathname}${wsUrl.search}`;
102
- logger().debug("connecting to websocket", { url: finalWsUrl });
103
- const ws = new WebSocket2(finalWsUrl, [
104
- // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
105
- "rivetkit"
106
- ]);
107
- return ws;
108
- },
109
- connectSse: async (_c, actorQuery, encodingKind, params) => {
110
- logger().debug("creating sse connection via test inline driver", {
111
- actorQuery,
112
- encodingKind,
113
- params
114
- });
115
- const EventSourceImport = await Promise.resolve().then(() => _interopRequireWildcard(require("eventsource")));
116
- const EventSourceConstructor = EventSourceImport.default || EventSourceImport;
117
- const actorQueryParam = encodeURIComponent(JSON.stringify(actorQuery));
118
- const encodingParam = encodeURIComponent(encodingKind);
119
- const paramsParam = params ? encodeURIComponent(JSON.stringify(params)) : null;
120
- const sseUrl = new URL(
121
- `${endpoint}/registry/.test/inline-driver/connect-sse`
122
- );
123
- sseUrl.searchParams.set("actorQueryRaw", actorQueryParam);
124
- sseUrl.searchParams.set("encodingKind", encodingParam);
125
- if (paramsParam) {
126
- sseUrl.searchParams.set("params", paramsParam);
127
- }
128
- logger().debug("connecting to sse", { url: sseUrl.toString() });
129
- const eventSource = new EventSourceConstructor(sseUrl.toString());
130
- await new Promise((resolve2, reject) => {
131
- eventSource.onopen = () => {
132
- logger().debug("sse connection established");
133
- resolve2();
134
- };
135
- eventSource.onerror = (event) => {
136
- logger().error("sse connection failed", { event });
137
- reject(new Error("Failed to establish SSE connection"));
138
- };
139
- setTimeout(() => {
140
- if (eventSource.readyState !== EventSourceConstructor.OPEN) {
141
- reject(new Error("SSE connection timed out"));
142
- }
143
- }, 1e4);
144
- });
145
- return eventSource;
146
- },
147
- sendHttpMessage: async (_c, actorId, encoding, connectionId, connectionToken, message) => {
148
- var _a;
149
- logger().debug("sending http message via test inline driver", {
150
- actorId,
151
- encoding,
152
- connectionId,
153
- transport
154
- });
155
- const result = await fetch(
156
- `${endpoint}/registry/.test/inline-driver/call`,
157
- {
158
- method: "POST",
159
- headers: {
160
- "Content-Type": "application/json"
161
- },
162
- body: JSON.stringify({
163
- encoding,
164
- transport,
165
- method: "sendHttpMessage",
166
- args: [
167
- void 0,
168
- actorId,
169
- encoding,
170
- connectionId,
171
- connectionToken,
172
- message
173
- ]
174
- })
175
- }
176
- );
177
- if (!result.ok) {
178
- throw new Error(`Failed to send HTTP message: ${result.statusText}`);
179
- }
180
- await ((_a = result.body) == null ? void 0 : _a.cancel());
181
- },
182
- rawHttpRequest: async (_c, actorQuery, encoding, params, path, init) => {
183
- var _a;
184
- const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
185
- logger().debug("sending raw http request via test inline driver", {
186
- actorQuery,
187
- encoding,
188
- path: normalizedPath
189
- });
190
- const url = `${endpoint}/registry/.test/inline-driver/raw-http/${normalizedPath}`;
191
- logger().debug("rewriting http url", {
192
- from: path,
193
- to: url
194
- });
195
- const headers = new Headers(init.headers);
196
- headers.set(_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY, JSON.stringify(actorQuery));
197
- headers.set(_chunk6WKQDDUDcjs.HEADER_ENCODING, encoding);
198
- if (params !== void 0) {
199
- headers.set(_chunk6WKQDDUDcjs.HEADER_CONN_PARAMS, JSON.stringify(params));
200
- }
201
- const response = await fetch(url, {
202
- ...init,
203
- headers
204
- });
205
- if (!response.ok && ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json"))) {
206
- try {
207
- const clonedResponse = response.clone();
208
- const errorData = await clonedResponse.json();
209
- if (errorData.error) {
210
- if (typeof errorData.error === "object") {
211
- throw new (0, _chunkO2MBYIXOcjs.ActorError)(
212
- errorData.error.code,
213
- errorData.error.message,
214
- errorData.error.metadata
215
- );
216
- }
217
- }
218
- } catch (e) {
219
- if (!(e instanceof _chunkO2MBYIXOcjs.ActorError)) {
220
- return response;
221
- }
222
- throw e;
223
- }
224
- }
225
- return response;
226
- },
227
- rawWebSocket: async (_c, actorQuery, encoding, params, path, protocols) => {
228
- logger().debug("test inline driver rawWebSocket called");
229
- const WebSocket2 = await _chunkTZJKSBUQcjs.importWebSocket.call(void 0, );
230
- const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
231
- logger().debug(
232
- "creating raw websocket connection via test inline driver",
233
- {
234
- actorQuery,
235
- encoding,
236
- path: normalizedPath,
237
- protocols
238
- }
239
- );
240
- const wsUrl = new URL(
241
- `${endpoint}/registry/.test/inline-driver/raw-websocket`
242
- );
243
- wsUrl.searchParams.set("actorQuery", JSON.stringify(actorQuery));
244
- if (params !== void 0)
245
- wsUrl.searchParams.set("params", JSON.stringify(params));
246
- wsUrl.searchParams.set("encodingKind", encoding);
247
- wsUrl.searchParams.set("path", normalizedPath);
248
- if (protocols !== void 0)
249
- wsUrl.searchParams.set("protocols", JSON.stringify(protocols));
250
- const wsProtocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
251
- const finalWsUrl = `${wsProtocol}//${wsUrl.host}${wsUrl.pathname}${wsUrl.search}`;
252
- logger().debug("connecting to raw websocket", { url: finalWsUrl });
253
- logger().debug("rewriting websocket url", {
254
- from: path,
255
- to: finalWsUrl
256
- });
257
- const ws = new WebSocket2(finalWsUrl, [
258
- // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
259
- "rivetkit"
260
- ]);
261
- logger().debug("test inline driver created websocket", {
262
- readyState: ws.readyState,
263
- url: ws.url
264
- });
265
- return ws;
266
- }
267
- };
268
- }
269
- async function makeInlineRequest(endpoint, encoding, transport, method, args) {
270
- logger().debug("sending inline request", {
271
- encoding,
272
- transport,
273
- method,
274
- args
275
- });
276
- const response = await fetch(
277
- `${endpoint}/registry/.test/inline-driver/call`,
278
- {
279
- method: "POST",
280
- headers: {
281
- "Content-Type": "application/json"
282
- },
283
- body: cbor.encode({
284
- encoding,
285
- transport,
286
- method,
287
- args
288
- })
289
- }
290
- );
291
- if (!response.ok) {
292
- throw new Error(`Failed to call inline ${method}: ${response.statusText}`);
293
- }
294
- const buffer = await response.arrayBuffer();
295
- const callResponse = cbor.decode(
296
- new Uint8Array(buffer)
297
- );
298
- if ("ok" in callResponse) {
299
- return callResponse.ok;
300
- } else if ("err" in callResponse) {
301
- throw new (0, _chunkO2MBYIXOcjs.ActorError)(
302
- callResponse.err.code,
303
- callResponse.err.message,
304
- callResponse.err.metadata
305
- );
306
- } else {
307
- _chunk6WKQDDUDcjs.assertUnreachable.call(void 0, callResponse);
308
- }
309
- }
44
+ // src/driver-test-suite/tests/action-features.ts
45
+
310
46
 
311
47
  // src/driver-test-suite/utils.ts
48
+ var _path = require('path');
49
+
312
50
  var FAKE_TIME = /* @__PURE__ */ new Date("2024-01-01T00:00:00.000Z");
313
51
  async function setupDriverTest(c, driverTestConfig) {
314
52
  if (!driverTestConfig.useRealTimers) {
@@ -316,21 +54,20 @@ async function setupDriverTest(c, driverTestConfig) {
316
54
  _vitest.vi.setSystemTime(FAKE_TIME);
317
55
  }
318
56
  const projectPath = _path.resolve.call(void 0, __dirname, "../../fixtures/driver-test-suite");
319
- const { endpoint, cleanup } = await driverTestConfig.start(projectPath);
57
+ const { endpoint, namespace, runnerName, cleanup } = await driverTestConfig.start(projectPath);
320
58
  c.onTestFinished(cleanup);
321
59
  let client;
322
60
  if (driverTestConfig.clientType === "http") {
323
- client = _chunkURVFQMYIcjs.createClient.call(void 0, endpoint, {
61
+ client = _chunk4R73YDN3cjs.createClient.call(void 0, {
62
+ endpoint,
63
+ namespace,
64
+ runnerName,
324
65
  transport: driverTestConfig.transport
325
66
  });
326
67
  } else if (driverTestConfig.clientType === "inline") {
327
- const clientDriver = createTestInlineClientDriver(
328
- endpoint,
329
- _nullishCoalesce(driverTestConfig.transport, () => ( "websocket"))
330
- );
331
- client = _chunkO2MBYIXOcjs.createClientWithDriver.call(void 0, clientDriver);
68
+ throw "TODO";
332
69
  } else {
333
- _chunk6WKQDDUDcjs.assertUnreachable.call(void 0, driverTestConfig.clientType);
70
+ _chunkGICQ3YCUcjs.assertUnreachable.call(void 0, driverTestConfig.clientType);
334
71
  }
335
72
  if (!driverTestConfig.HACK_skipCleanupNet) {
336
73
  c.onTestFinished(async () => await client.dispose());
@@ -430,432 +167,6 @@ function runActionFeaturesTests(driverTestConfig) {
430
167
  });
431
168
  }
432
169
 
433
- // src/driver-test-suite/tests/actor-auth.ts
434
-
435
- function runActorAuthTests(driverTestConfig) {
436
- _vitest.describe.call(void 0, "Actor Authentication Tests", () => {
437
- _vitest.describe.call(void 0, "Basic Authentication", () => {
438
- _vitest.test.call(void 0, "should allow access with valid auth", async (c) => {
439
- const { client } = await setupDriverTest(c, driverTestConfig);
440
- const instance = client.authActor.getOrCreate(void 0, {
441
- params: { apiKey: "valid-api-key" }
442
- });
443
- const authData = await instance.getUserAuth();
444
- if (driverTestConfig.clientType === "inline") {
445
- _vitest.expect.call(void 0, authData).toBeUndefined();
446
- } else {
447
- _vitest.expect.call(void 0, authData).toEqual({
448
- userId: "user123",
449
- token: "valid-api-key"
450
- });
451
- }
452
- const requests = await instance.getRequests();
453
- _vitest.expect.call(void 0, requests).toBe(1);
454
- });
455
- _vitest.test.call(void 0, "should deny access with invalid auth", async (c) => {
456
- const { client } = await setupDriverTest(c, driverTestConfig);
457
- const instance = client.authActor.getOrCreate();
458
- if (driverTestConfig.clientType === "inline") {
459
- const requests = await instance.getRequests();
460
- _vitest.expect.call(void 0, typeof requests).toBe("number");
461
- } else {
462
- try {
463
- await instance.getRequests();
464
- _vitest.expect.fail("Expected authentication error");
465
- } catch (error) {
466
- _vitest.expect.call(void 0, error.code).toBe("missing_auth");
467
- }
468
- }
469
- });
470
- _vitest.test.call(void 0, "should expose auth data on connection", async (c) => {
471
- const { client } = await setupDriverTest(c, driverTestConfig);
472
- const instance = client.authActor.getOrCreate(void 0, {
473
- params: { apiKey: "valid-api-key" }
474
- });
475
- const authData = await instance.getUserAuth();
476
- if (driverTestConfig.clientType === "inline") {
477
- _vitest.expect.call(void 0, authData).toBeUndefined();
478
- } else {
479
- _vitest.expect.call(void 0, authData).toBeDefined();
480
- _vitest.expect.call(void 0, authData.userId).toBe("user123");
481
- _vitest.expect.call(void 0, authData.token).toBe("valid-api-key");
482
- }
483
- });
484
- });
485
- _vitest.describe.call(void 0, "Intent-Based Authentication", () => {
486
- _vitest.test.call(void 0, "should allow get operations for any role", async (c) => {
487
- const { client } = await setupDriverTest(c, driverTestConfig);
488
- const createdInstance = await client.intentAuthActor.create(["foo"], {
489
- params: { role: "admin" }
490
- });
491
- const actorId = await createdInstance.resolve();
492
- if (driverTestConfig.clientType === "inline") {
493
- const instance = client.intentAuthActor.getForId(actorId);
494
- const value = await instance.getValue();
495
- _vitest.expect.call(void 0, value).toBe(0);
496
- } else {
497
- const instance = client.intentAuthActor.getForId(actorId, {
498
- params: { role: "user" }
499
- // Actions require user or admin role
500
- });
501
- const value = await instance.getValue();
502
- _vitest.expect.call(void 0, value).toBe(0);
503
- }
504
- });
505
- _vitest.test.call(void 0, "should require admin role for create operations", async (c) => {
506
- const { client } = await setupDriverTest(c, driverTestConfig);
507
- if (driverTestConfig.clientType === "inline") {
508
- const instance = client.intentAuthActor.getOrCreate(void 0, {
509
- params: { role: "user" }
510
- });
511
- const value = await instance.getValue();
512
- _vitest.expect.call(void 0, value).toBe(0);
513
- } else {
514
- try {
515
- const instance = client.intentAuthActor.getOrCreate(void 0, {
516
- params: { role: "user" }
517
- });
518
- await instance.getValue();
519
- _vitest.expect.fail("Expected permission error for create operation");
520
- } catch (error) {
521
- _vitest.expect.call(void 0, error.code).toBe("insufficient_permissions");
522
- _vitest.expect.call(void 0, error.message).toContain(
523
- "Admin role required"
524
- );
525
- }
526
- }
527
- });
528
- _vitest.test.call(void 0, "should allow actions for user and admin roles", async (c) => {
529
- const { client } = await setupDriverTest(c, driverTestConfig);
530
- const createdInstance = await client.intentAuthActor.create(["foo"], {
531
- params: { role: "admin" }
532
- });
533
- const actorId = await createdInstance.resolve();
534
- const instance = client.intentAuthActor.getForId(actorId, {
535
- params: { role: "guest" }
536
- });
537
- if (driverTestConfig.clientType === "inline") {
538
- const result = await instance.setValue(42);
539
- _vitest.expect.call(void 0, result).toBe(42);
540
- } else {
541
- try {
542
- await instance.setValue(42);
543
- _vitest.expect.fail("Expected permission error for action");
544
- } catch (error) {
545
- _vitest.expect.call(void 0, error.code).toBe("insufficient_permissions");
546
- _vitest.expect.call(void 0, error.message).toContain(
547
- "User or admin role required"
548
- );
549
- }
550
- }
551
- });
552
- });
553
- _vitest.describe.call(void 0, "Public Access", () => {
554
- _vitest.test.call(void 0, "should allow access with empty onAuth", async (c) => {
555
- const { client } = await setupDriverTest(c, driverTestConfig);
556
- const instance = client.publicActor.getOrCreate();
557
- const visitors = await instance.visit();
558
- _vitest.expect.call(void 0, visitors).toBe(1);
559
- const visitors2 = await instance.visit();
560
- _vitest.expect.call(void 0, visitors2).toBe(2);
561
- });
562
- _vitest.test.call(void 0, "should deny access without onAuth defined", async (c) => {
563
- const { client } = await setupDriverTest(c, driverTestConfig);
564
- const instance = client.noAuthActor.getOrCreate();
565
- if (driverTestConfig.clientType === "inline") {
566
- const value = await instance.getValue();
567
- _vitest.expect.call(void 0, value).toBe(42);
568
- } else {
569
- try {
570
- await instance.getValue();
571
- _vitest.expect.fail(
572
- "Expected access to be denied for actor without onAuth"
573
- );
574
- } catch (error) {
575
- _vitest.expect.call(void 0, error.code).toBe("forbidden");
576
- }
577
- }
578
- });
579
- });
580
- _vitest.describe.call(void 0, "Async Authentication", () => {
581
- _vitest.test.call(void 0, "should handle promise-based auth", async (c) => {
582
- const { client } = await setupDriverTest(c, driverTestConfig);
583
- const instance = client.asyncAuthActor.getOrCreate(void 0, {
584
- params: { token: "valid" }
585
- });
586
- const result = await instance.increment();
587
- _vitest.expect.call(void 0, result).toBe(1);
588
- const authData = await instance.getAuthData();
589
- if (driverTestConfig.clientType === "inline") {
590
- _vitest.expect.call(void 0, authData).toBeUndefined();
591
- } else {
592
- _vitest.expect.call(void 0, authData).toBeDefined();
593
- _vitest.expect.call(void 0, authData.userId).toBe("user-valid");
594
- _vitest.expect.call(void 0, authData.validated).toBe(true);
595
- }
596
- });
597
- _vitest.test.call(void 0, "should handle async auth failures", async (c) => {
598
- const { client } = await setupDriverTest(c, driverTestConfig);
599
- const instance = client.asyncAuthActor.getOrCreate();
600
- if (driverTestConfig.clientType === "inline") {
601
- const result = await instance.increment();
602
- _vitest.expect.call(void 0, result).toBe(1);
603
- } else {
604
- try {
605
- await instance.increment();
606
- _vitest.expect.fail("Expected async auth failure");
607
- } catch (error) {
608
- _vitest.expect.call(void 0, error.code).toBe("missing_token");
609
- }
610
- }
611
- });
612
- });
613
- _vitest.describe.call(void 0, "Authentication Across Transports", () => {
614
- if (driverTestConfig.transport === "websocket") {
615
- _vitest.test.call(void 0, "should authenticate WebSocket connections", async (c) => {
616
- const { client } = await setupDriverTest(c, driverTestConfig);
617
- const instance = client.authActor.getOrCreate(void 0, {
618
- params: { apiKey: "valid-api-key" }
619
- });
620
- const authData = await instance.getUserAuth();
621
- _vitest.expect.call(void 0, authData).toBeDefined();
622
- _vitest.expect.call(void 0, authData.userId).toBe("user123");
623
- });
624
- }
625
- _vitest.test.call(void 0, "should authenticate HTTP actions", async (c) => {
626
- const { client } = await setupDriverTest(c, driverTestConfig);
627
- const instance = client.authActor.getOrCreate(void 0, {
628
- params: { apiKey: "valid-api-key" }
629
- });
630
- const requests = await instance.getRequests();
631
- _vitest.expect.call(void 0, typeof requests).toBe("number");
632
- });
633
- });
634
- _vitest.describe.call(void 0, "Error Handling", () => {
635
- _vitest.test.call(void 0, "should handle auth errors gracefully", async (c) => {
636
- const { client } = await setupDriverTest(c, driverTestConfig);
637
- const instance = client.authActor.getOrCreate();
638
- if (driverTestConfig.clientType === "inline") {
639
- const requests = await instance.getRequests();
640
- _vitest.expect.call(void 0, typeof requests).toBe("number");
641
- } else {
642
- try {
643
- await instance.getRequests();
644
- _vitest.expect.fail("Expected authentication error");
645
- } catch (error) {
646
- const actorError = error;
647
- _vitest.expect.call(void 0, actorError.code).toBeDefined();
648
- _vitest.expect.call(void 0, actorError.message).toBeDefined();
649
- }
650
- }
651
- });
652
- _vitest.test.call(void 0, "should preserve error details for debugging", async (c) => {
653
- const { client } = await setupDriverTest(c, driverTestConfig);
654
- const instance = client.asyncAuthActor.getOrCreate();
655
- if (driverTestConfig.clientType === "inline") {
656
- const result = await instance.increment();
657
- _vitest.expect.call(void 0, result).toBe(1);
658
- } else {
659
- try {
660
- await instance.increment();
661
- _vitest.expect.fail("Expected token error");
662
- } catch (error) {
663
- const actorError = error;
664
- _vitest.expect.call(void 0, actorError.code).toBe("missing_token");
665
- _vitest.expect.call(void 0, actorError.message).toBe("Token required");
666
- }
667
- }
668
- });
669
- });
670
- _vitest.describe.call(void 0, "Raw HTTP Authentication", () => {
671
- _vitest.test.call(void 0, "should allow raw HTTP access with valid auth", async (c) => {
672
- const { client } = await setupDriverTest(c, driverTestConfig);
673
- const instance = client.rawHttpAuthActor.getOrCreate(void 0, {
674
- params: { apiKey: "valid-api-key" }
675
- });
676
- const response = await instance.fetch("api/auth-info");
677
- _vitest.expect.call(void 0, response.ok).toBe(true);
678
- const data = await response.json();
679
- _vitest.expect.call(void 0, data.message).toBe("Authenticated request");
680
- _vitest.expect.call(void 0, data.requestCount).toBe(1);
681
- const count = await instance.getRequestCount();
682
- _vitest.expect.call(void 0, count).toBe(1);
683
- });
684
- _vitest.test.call(void 0, "should deny raw HTTP access without auth", async (c) => {
685
- const { client } = await setupDriverTest(c, driverTestConfig);
686
- const instance = client.rawHttpAuthActor.getOrCreate();
687
- const response = await instance.fetch("api/protected");
688
- if (driverTestConfig.clientType === "inline") {
689
- _vitest.expect.call(void 0, response.ok).toBe(true);
690
- _vitest.expect.call(void 0, response.status).toBe(200);
691
- } else {
692
- _vitest.expect.call(void 0, response.ok).toBe(false);
693
- _vitest.expect.call(void 0, response.status).toBe(400);
694
- }
695
- try {
696
- const errorData = await response.json();
697
- _vitest.expect.call(void 0, errorData.c || errorData.code).toBe("missing_auth");
698
- } catch (e2) {
699
- }
700
- });
701
- _vitest.test.call(void 0, "should deny raw HTTP for actors without onAuth", async (c) => {
702
- const { client } = await setupDriverTest(c, driverTestConfig);
703
- const instance = client.rawHttpNoAuthActor.getOrCreate();
704
- const response = await instance.fetch("api/test");
705
- if (driverTestConfig.clientType === "inline") {
706
- _vitest.expect.call(void 0, response.ok).toBe(true);
707
- _vitest.expect.call(void 0, response.status).toBe(200);
708
- } else {
709
- _vitest.expect.call(void 0, response.ok).toBe(false);
710
- _vitest.expect.call(void 0, response.status).toBe(403);
711
- }
712
- try {
713
- const errorData = await response.json();
714
- _vitest.expect.call(void 0, errorData.c || errorData.code).toBe("forbidden");
715
- } catch (e3) {
716
- }
717
- });
718
- _vitest.test.call(void 0, "should allow public raw HTTP access", async (c) => {
719
- const { client } = await setupDriverTest(c, driverTestConfig);
720
- const instance = client.rawHttpPublicActor.getOrCreate();
721
- const response = await instance.fetch("api/visit");
722
- _vitest.expect.call(void 0, response.ok).toBe(true);
723
- const data = await response.json();
724
- _vitest.expect.call(void 0, data.message).toBe("Welcome visitor!");
725
- _vitest.expect.call(void 0, data.count).toBe(1);
726
- const response2 = await instance.fetch("api/visit");
727
- const data2 = await response2.json();
728
- _vitest.expect.call(void 0, data2.count).toBe(2);
729
- });
730
- _vitest.test.call(void 0, "should handle custom auth in onFetch", async (c) => {
731
- const { client } = await setupDriverTest(c, driverTestConfig);
732
- const instance = client.rawHttpCustomAuthActor.getOrCreate();
733
- const response1 = await instance.fetch("api/data");
734
- _vitest.expect.call(void 0, response1.ok).toBe(false);
735
- _vitest.expect.call(void 0, response1.status).toBe(401);
736
- const error1 = await response1.json();
737
- _vitest.expect.call(void 0, error1.error).toBe("Unauthorized");
738
- const response2 = await instance.fetch("api/data", {
739
- headers: {
740
- Authorization: "Bearer wrong-token"
741
- }
742
- });
743
- _vitest.expect.call(void 0, response2.ok).toBe(false);
744
- _vitest.expect.call(void 0, response2.status).toBe(403);
745
- const response3 = await instance.fetch("api/data", {
746
- headers: {
747
- Authorization: "Bearer custom-token"
748
- }
749
- });
750
- _vitest.expect.call(void 0, response3.ok).toBe(true);
751
- const data = await response3.json();
752
- _vitest.expect.call(void 0, data.message).toBe("Authorized!");
753
- _vitest.expect.call(void 0, data.authorized).toBe(1);
754
- const stats = await instance.getStats();
755
- _vitest.expect.call(void 0, stats.authorized).toBe(1);
756
- _vitest.expect.call(void 0, stats.unauthorized).toBe(2);
757
- });
758
- });
759
- _vitest.describe.call(void 0, "Raw WebSocket Authentication", () => {
760
- _vitest.test.call(void 0, "should allow raw WebSocket access with valid auth", async (c) => {
761
- const { client } = await setupDriverTest(c, driverTestConfig);
762
- const instance = client.rawWebSocketAuthActor.getOrCreate(void 0, {
763
- params: { apiKey: "valid-api-key" }
764
- });
765
- const ws = await instance.websocket();
766
- const welcomePromise = new Promise((resolve2, reject) => {
767
- ws.addEventListener("message", (event) => {
768
- const data = JSON.parse(event.data);
769
- if (data.type === "welcome") {
770
- resolve2(data);
771
- }
772
- });
773
- ws.addEventListener("close", () => reject("closed"));
774
- });
775
- const welcomeData = await welcomePromise;
776
- _vitest.expect.call(void 0, welcomeData.message).toBe("Authenticated WebSocket connection");
777
- _vitest.expect.call(void 0, welcomeData.connectionCount).toBe(1);
778
- ws.close();
779
- });
780
- _vitest.test.call(void 0, "should deny raw WebSocket access without auth", async (c) => {
781
- const { client } = await setupDriverTest(c, driverTestConfig);
782
- const instance = client.rawWebSocketAuthActor.getOrCreate();
783
- try {
784
- await instance.websocket();
785
- _vitest.expect.fail("Expected authentication error");
786
- } catch (error) {
787
- _vitest.expect.call(void 0, error).toBeDefined();
788
- }
789
- });
790
- _vitest.test.call(void 0, "should deny raw WebSocket for actors without onAuth", async (c) => {
791
- const { client } = await setupDriverTest(c, driverTestConfig);
792
- const instance = client.rawWebSocketNoAuthActor.getOrCreate();
793
- try {
794
- await instance.websocket();
795
- _vitest.expect.fail("Expected forbidden error");
796
- } catch (error) {
797
- _vitest.expect.call(void 0, error).toBeDefined();
798
- }
799
- });
800
- _vitest.test.call(void 0, "should allow public raw WebSocket access", async (c) => {
801
- const { client } = await setupDriverTest(c, driverTestConfig);
802
- const instance = client.rawWebSocketPublicActor.getOrCreate();
803
- const ws = await instance.websocket();
804
- const welcomePromise = new Promise((resolve2, reject) => {
805
- ws.addEventListener("message", (event) => {
806
- const data = JSON.parse(event.data);
807
- if (data.type === "welcome") {
808
- resolve2(data);
809
- }
810
- });
811
- ws.addEventListener("close", reject);
812
- });
813
- const welcomeData = await welcomePromise;
814
- _vitest.expect.call(void 0, welcomeData.message).toBe("Public WebSocket connection");
815
- _vitest.expect.call(void 0, welcomeData.visitorNumber).toBe(1);
816
- ws.close();
817
- });
818
- _vitest.test.call(void 0, "should handle custom auth in onWebSocket", async (c) => {
819
- const { client } = await setupDriverTest(c, driverTestConfig);
820
- const instance = client.rawWebSocketCustomAuthActor.getOrCreate();
821
- try {
822
- const ws1 = await instance.websocket();
823
- const errorPromise = new Promise((resolve2, reject) => {
824
- ws1.addEventListener("message", (event) => {
825
- const data = JSON.parse(event.data);
826
- if (data.type === "error") {
827
- resolve2(data);
828
- }
829
- });
830
- ws1.addEventListener("close", reject);
831
- });
832
- const errorData = await errorPromise;
833
- _vitest.expect.call(void 0, errorData.type).toBe("error");
834
- _vitest.expect.call(void 0, errorData.message).toBe("Unauthorized");
835
- } catch (error) {
836
- _vitest.expect.call(void 0, error).toBeDefined();
837
- }
838
- const ws2 = await instance.websocket("?token=custom-ws-token");
839
- const authPromise = new Promise((resolve2, reject) => {
840
- ws2.addEventListener("message", (event) => {
841
- const data = JSON.parse(event.data);
842
- if (data.type === "authorized") {
843
- resolve2(data);
844
- }
845
- });
846
- ws2.addEventListener("close", reject);
847
- });
848
- const authData = await authPromise;
849
- _vitest.expect.call(void 0, authData.message).toBe("Welcome authenticated user!");
850
- ws2.close();
851
- const stats = await instance.getStats();
852
- _vitest.expect.call(void 0, stats.authorized).toBeGreaterThanOrEqual(1);
853
- _vitest.expect.call(void 0, stats.unauthorized).toBeGreaterThanOrEqual(1);
854
- });
855
- });
856
- });
857
- }
858
-
859
170
  // src/driver-test-suite/tests/actor-conn.ts
860
171
 
861
172
  function runActorConnTests(driverTestConfig) {
@@ -1287,9 +598,7 @@ function runActorScheduleTests(driverTestConfig) {
1287
598
 
1288
599
  // fixtures/driver-test-suite/sleep.ts
1289
600
  var SLEEP_TIMEOUT = 500;
1290
- var sleep = _chunkUIM22YJLcjs.actor.call(void 0, {
1291
- onAuth: () => {
1292
- },
601
+ var sleep = _chunkVO7ZRVVDcjs.actor.call(void 0, {
1293
602
  state: { startCount: 0, sleepCount: 0 },
1294
603
  onStart: (c) => {
1295
604
  c.state.startCount += 1;
@@ -1315,9 +624,7 @@ var sleep = _chunkUIM22YJLcjs.actor.call(void 0, {
1315
624
  sleepTimeout: SLEEP_TIMEOUT
1316
625
  }
1317
626
  });
1318
- var sleepWithLongRpc = _chunkUIM22YJLcjs.actor.call(void 0, {
1319
- onAuth: () => {
1320
- },
627
+ var sleepWithLongRpc = _chunkVO7ZRVVDcjs.actor.call(void 0, {
1321
628
  state: { startCount: 0, sleepCount: 0 },
1322
629
  createVars: () => ({}),
1323
630
  onStart: (c) => {
@@ -1346,9 +653,7 @@ var sleepWithLongRpc = _chunkUIM22YJLcjs.actor.call(void 0, {
1346
653
  sleepTimeout: SLEEP_TIMEOUT
1347
654
  }
1348
655
  });
1349
- var sleepWithRawHttp = _chunkUIM22YJLcjs.actor.call(void 0, {
1350
- onAuth: () => {
1351
- },
656
+ var sleepWithRawHttp = _chunkVO7ZRVVDcjs.actor.call(void 0, {
1352
657
  state: { startCount: 0, sleepCount: 0, requestCount: 0 },
1353
658
  onStart: (c) => {
1354
659
  c.state.startCount += 1;
@@ -1361,7 +666,7 @@ var sleepWithRawHttp = _chunkUIM22YJLcjs.actor.call(void 0, {
1361
666
  const url = new URL(request.url);
1362
667
  if (url.pathname === "/long-request") {
1363
668
  const duration = parseInt(url.searchParams.get("duration") || "1000");
1364
- c.log.info("starting long fetch request", { duration });
669
+ c.log.info({ msg: "starting long fetch request", duration });
1365
670
  await new Promise((resolve2) => setTimeout(resolve2, duration));
1366
671
  c.log.info("finished long fetch request");
1367
672
  return new Response(JSON.stringify({ completed: true }), {
@@ -1383,9 +688,7 @@ var sleepWithRawHttp = _chunkUIM22YJLcjs.actor.call(void 0, {
1383
688
  sleepTimeout: SLEEP_TIMEOUT
1384
689
  }
1385
690
  });
1386
- var sleepWithRawWebSocket = _chunkUIM22YJLcjs.actor.call(void 0, {
1387
- onAuth: () => {
1388
- },
691
+ var sleepWithRawWebSocket = _chunkVO7ZRVVDcjs.actor.call(void 0, {
1389
692
  state: { startCount: 0, sleepCount: 0, connectionCount: 0 },
1390
693
  onStart: (c) => {
1391
694
  c.state.startCount += 1;
@@ -1395,7 +698,8 @@ var sleepWithRawWebSocket = _chunkUIM22YJLcjs.actor.call(void 0, {
1395
698
  },
1396
699
  onWebSocket: (c, websocket, opts) => {
1397
700
  c.state.connectionCount += 1;
1398
- c.log.info("websocket connected", {
701
+ c.log.info({
702
+ msg: "websocket connected",
1399
703
  connectionCount: c.state.connectionCount
1400
704
  });
1401
705
  websocket.send(
@@ -1421,14 +725,15 @@ var sleepWithRawWebSocket = _chunkUIM22YJLcjs.actor.call(void 0, {
1421
725
  } else if (parsed.type === "keepAlive") {
1422
726
  websocket.send(JSON.stringify({ type: "ack" }));
1423
727
  }
1424
- } catch (e4) {
728
+ } catch (e2) {
1425
729
  websocket.send(data);
1426
730
  }
1427
731
  }
1428
732
  });
1429
733
  websocket.addEventListener("close", () => {
1430
734
  c.state.connectionCount -= 1;
1431
- c.log.info("websocket disconnected", {
735
+ c.log.info({
736
+ msg: "websocket disconnected",
1432
737
  connectionCount: c.state.connectionCount
1433
738
  });
1434
739
  });
@@ -1446,9 +751,7 @@ var sleepWithRawWebSocket = _chunkUIM22YJLcjs.actor.call(void 0, {
1446
751
  sleepTimeout: SLEEP_TIMEOUT
1447
752
  }
1448
753
  });
1449
- var sleepWithNoSleepOption = _chunkUIM22YJLcjs.actor.call(void 0, {
1450
- onAuth: () => {
1451
- },
754
+ var sleepWithNoSleepOption = _chunkVO7ZRVVDcjs.actor.call(void 0, {
1452
755
  state: { startCount: 0, sleepCount: 0 },
1453
756
  onStart: (c) => {
1454
757
  c.state.startCount += 1;
@@ -1817,13 +1120,13 @@ function runActorErrorHandlingTests(driverTestConfig) {
1817
1120
  _vitest.expect.call(void 0, true).toBe(false);
1818
1121
  } catch (error) {
1819
1122
  if (driverTestConfig.clientType === "http") {
1820
- _vitest.expect.call(void 0, error.code).toBe(_chunkGIR3AFFIcjs.INTERNAL_ERROR_CODE);
1821
- _vitest.expect.call(void 0, error.message).toBe(_chunkGIR3AFFIcjs.INTERNAL_ERROR_DESCRIPTION);
1123
+ _vitest.expect.call(void 0, error.code).toBe(_chunkSBHHJ6QScjs.INTERNAL_ERROR_CODE);
1124
+ _vitest.expect.call(void 0, error.message).toBe(_chunkSBHHJ6QScjs.INTERNAL_ERROR_DESCRIPTION);
1822
1125
  } else if (driverTestConfig.clientType === "inline") {
1823
- _vitest.expect.call(void 0, error.code).toBe(_chunkGIR3AFFIcjs.INTERNAL_ERROR_CODE);
1126
+ _vitest.expect.call(void 0, error.code).toBe(_chunkSBHHJ6QScjs.INTERNAL_ERROR_CODE);
1824
1127
  _vitest.expect.call(void 0, error.message).toBe("This is an internal error");
1825
1128
  } else {
1826
- _chunk6WKQDDUDcjs.assertUnreachable.call(void 0, driverTestConfig.clientType);
1129
+ _chunkGICQ3YCUcjs.assertUnreachable.call(void 0, driverTestConfig.clientType);
1827
1130
  }
1828
1131
  }
1829
1132
  });
@@ -1919,6 +1222,29 @@ function runActorHandleTests(driverTestConfig) {
1919
1222
  const retrievedCount = await handle.getCount();
1920
1223
  _vitest.expect.call(void 0, retrievedCount).toBe(9);
1921
1224
  });
1225
+ _vitest.test.call(void 0, "errors when calling create twice with the same key", async (c) => {
1226
+ const { client } = await setupDriverTest(c, driverTestConfig);
1227
+ const key = ["duplicate-create-handle", crypto.randomUUID()];
1228
+ await client.counter.create(key);
1229
+ try {
1230
+ await client.counter.create(key);
1231
+ _vitest.expect.fail("did not error on duplicate create");
1232
+ } catch (err) {
1233
+ _vitest.expect.call(void 0, err.group).toBe("actor");
1234
+ _vitest.expect.call(void 0, err.code).toBe("already_exists");
1235
+ }
1236
+ });
1237
+ _vitest.test.call(void 0, ".get().resolve() errors for non-existent actor", async (c) => {
1238
+ const { client } = await setupDriverTest(c, driverTestConfig);
1239
+ const missingId = `nonexistent-${crypto.randomUUID()}`;
1240
+ try {
1241
+ await client.counter.get([missingId]).resolve();
1242
+ _vitest.expect.fail("did not error for get().resolve() on missing actor");
1243
+ } catch (err) {
1244
+ _vitest.expect.call(void 0, err.group).toBe("actor");
1245
+ _vitest.expect.call(void 0, err.code).toBe("not_found");
1246
+ }
1247
+ });
1922
1248
  });
1923
1249
  _vitest.describe.call(void 0, "Action Functionality", () => {
1924
1250
  _vitest.test.call(void 0, "should call actions directly on the handle", async (c) => {
@@ -2143,7 +1469,7 @@ function runActorInspectorTests(driverTestConfig) {
2143
1469
  _vitest.describe.call(void 0, "Manager Inspector", () => {
2144
1470
  _vitest.test.call(void 0, "should respond to ping", async (c) => {
2145
1471
  const { endpoint } = await setupDriverTest(c, driverTestConfig);
2146
- const http = _chunkKUPQZYUQcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
1472
+ const http = _chunkLWNKVZG5cjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
2147
1473
  headers: {
2148
1474
  Authorization: `Bearer token`
2149
1475
  }
@@ -2157,7 +1483,7 @@ function runActorInspectorTests(driverTestConfig) {
2157
1483
  const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2158
1484
  await client.counter.create(["test-actor-1"]);
2159
1485
  await client.counter.create(["test-actor-2"]);
2160
- const http = _chunkKUPQZYUQcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
1486
+ const http = _chunkLWNKVZG5cjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
2161
1487
  headers: {
2162
1488
  Authorization: `Bearer token`
2163
1489
  }
@@ -2180,7 +1506,7 @@ function runActorInspectorTests(driverTestConfig) {
2180
1506
  const actorKey2 = ["test-cursor-2"];
2181
1507
  await client.counter.create(actorKey1);
2182
1508
  await client.counter.create(actorKey2);
2183
- const http = _chunkKUPQZYUQcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
1509
+ const http = _chunkLWNKVZG5cjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
2184
1510
  headers: {
2185
1511
  Authorization: `Bearer token`
2186
1512
  }
@@ -2205,7 +1531,7 @@ function runActorInspectorTests(driverTestConfig) {
2205
1531
  });
2206
1532
  _vitest.test.call(void 0, "should handle invalid limit parameter", async (c) => {
2207
1533
  const { endpoint } = await setupDriverTest(c, driverTestConfig);
2208
- const http = _chunkKUPQZYUQcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
1534
+ const http = _chunkLWNKVZG5cjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
2209
1535
  headers: {
2210
1536
  Authorization: `Bearer token`
2211
1537
  }
@@ -2217,7 +1543,7 @@ function runActorInspectorTests(driverTestConfig) {
2217
1543
  });
2218
1544
  _vitest.test.call(void 0, "should create a new actor", async (c) => {
2219
1545
  const { endpoint } = await setupDriverTest(c, driverTestConfig);
2220
- const http = _chunkKUPQZYUQcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
1546
+ const http = _chunkLWNKVZG5cjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
2221
1547
  headers: {
2222
1548
  Authorization: `Bearer token`
2223
1549
  }
@@ -2241,7 +1567,7 @@ function runActorInspectorTests(driverTestConfig) {
2241
1567
  });
2242
1568
  _vitest.test.call(void 0, "should get builds", async (c) => {
2243
1569
  const { endpoint } = await setupDriverTest(c, driverTestConfig);
2244
- const http = _chunkKUPQZYUQcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
1570
+ const http = _chunkLWNKVZG5cjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
2245
1571
  headers: {
2246
1572
  Authorization: `Bearer token`
2247
1573
  }
@@ -2259,7 +1585,7 @@ function runActorInspectorTests(driverTestConfig) {
2259
1585
  const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2260
1586
  const handle = await client.counter.create(["test-get-by-id"]);
2261
1587
  const actorId = await handle.resolve();
2262
- const http = _chunkKUPQZYUQcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
1588
+ const http = _chunkLWNKVZG5cjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
2263
1589
  headers: {
2264
1590
  Authorization: `Bearer token`
2265
1591
  }
@@ -2273,7 +1599,7 @@ function runActorInspectorTests(driverTestConfig) {
2273
1599
  });
2274
1600
  _vitest.test.call(void 0, "should return 404 for non-existent actor", async (c) => {
2275
1601
  const { endpoint } = await setupDriverTest(c, driverTestConfig);
2276
- const http = _chunkKUPQZYUQcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
1602
+ const http = _chunkLWNKVZG5cjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
2277
1603
  headers: {
2278
1604
  Authorization: `Bearer token`
2279
1605
  }
@@ -2289,7 +1615,7 @@ function runActorInspectorTests(driverTestConfig) {
2289
1615
  const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2290
1616
  const handle = await client.counter.create(["test-bootstrap"]);
2291
1617
  await handle.resolve();
2292
- const http = _chunkKUPQZYUQcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
1618
+ const http = _chunkLWNKVZG5cjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
2293
1619
  headers: {
2294
1620
  Authorization: `Bearer token`
2295
1621
  }
@@ -2311,10 +1637,10 @@ function runActorInspectorTests(driverTestConfig) {
2311
1637
  _vitest.test.call(void 0, "should handle actor not found", async (c) => {
2312
1638
  const { endpoint } = await setupDriverTest(c, driverTestConfig);
2313
1639
  const actorId = "non-existing";
2314
- const http = _chunkKUPQZYUQcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
1640
+ const http = _chunkLWNKVZG5cjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
2315
1641
  headers: {
2316
1642
  Authorization: `Bearer token`,
2317
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
1643
+ [_chunkGICQ3YCUcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
2318
1644
  getForId: { name: "counter", actorId }
2319
1645
  })
2320
1646
  }
@@ -2326,10 +1652,10 @@ function runActorInspectorTests(driverTestConfig) {
2326
1652
  const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2327
1653
  const handle = await client.counter.create(["test-ping"]);
2328
1654
  const actorId = await handle.resolve();
2329
- const http = _chunkKUPQZYUQcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
1655
+ const http = _chunkLWNKVZG5cjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
2330
1656
  headers: {
2331
1657
  Authorization: `Bearer token`,
2332
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
1658
+ [_chunkGICQ3YCUcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
2333
1659
  getForId: { name: "counter", actorId }
2334
1660
  })
2335
1661
  }
@@ -2344,10 +1670,10 @@ function runActorInspectorTests(driverTestConfig) {
2344
1670
  const handle = await client.counter.create(["test-state"]);
2345
1671
  const actorId = await handle.resolve();
2346
1672
  await handle.increment(5);
2347
- const http = _chunkKUPQZYUQcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
1673
+ const http = _chunkLWNKVZG5cjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
2348
1674
  headers: {
2349
1675
  Authorization: `Bearer token`,
2350
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
1676
+ [_chunkGICQ3YCUcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
2351
1677
  getForId: { name: "counter", actorId }
2352
1678
  })
2353
1679
  }
@@ -2366,10 +1692,10 @@ function runActorInspectorTests(driverTestConfig) {
2366
1692
  const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2367
1693
  const handle = await client.counter.create(["test-state-replace"]);
2368
1694
  const actorId = await handle.resolve();
2369
- const http = _chunkKUPQZYUQcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
1695
+ const http = _chunkLWNKVZG5cjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
2370
1696
  headers: {
2371
1697
  Authorization: `Bearer token`,
2372
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
1698
+ [_chunkGICQ3YCUcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
2373
1699
  getForId: { name: "counter", actorId }
2374
1700
  })
2375
1701
  }
@@ -2391,10 +1717,10 @@ function runActorInspectorTests(driverTestConfig) {
2391
1717
  const handle = await client.counter.create(["test-state-patch"]);
2392
1718
  const actorId = await handle.resolve();
2393
1719
  await handle.increment(3);
2394
- const http = _chunkKUPQZYUQcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
1720
+ const http = _chunkLWNKVZG5cjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
2395
1721
  headers: {
2396
1722
  Authorization: `Bearer token`,
2397
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
1723
+ [_chunkGICQ3YCUcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
2398
1724
  getForId: { name: "counter", actorId }
2399
1725
  })
2400
1726
  }
@@ -2425,10 +1751,10 @@ function runActorInspectorTests(driverTestConfig) {
2425
1751
  const actorId = await handle.resolve();
2426
1752
  handle.connect();
2427
1753
  await handle.increment(10);
2428
- const http = _chunkKUPQZYUQcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
1754
+ const http = _chunkLWNKVZG5cjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
2429
1755
  headers: {
2430
1756
  Authorization: `Bearer token`,
2431
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
1757
+ [_chunkGICQ3YCUcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
2432
1758
  getForId: { name: "counter", actorId }
2433
1759
  })
2434
1760
  }
@@ -2450,10 +1776,10 @@ function runActorInspectorTests(driverTestConfig) {
2450
1776
  const actorId = await handle.resolve();
2451
1777
  handle.connect();
2452
1778
  await handle.increment(10);
2453
- const http = _chunkKUPQZYUQcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
1779
+ const http = _chunkLWNKVZG5cjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
2454
1780
  headers: {
2455
1781
  Authorization: `Bearer token`,
2456
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
1782
+ [_chunkGICQ3YCUcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
2457
1783
  getForId: { name: "counter", actorId }
2458
1784
  })
2459
1785
  }
@@ -2476,10 +1802,10 @@ function runActorInspectorTests(driverTestConfig) {
2476
1802
  const actorId = await handle.resolve();
2477
1803
  handle.connect();
2478
1804
  await handle.increment(10);
2479
- const http = _chunkKUPQZYUQcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
1805
+ const http = _chunkLWNKVZG5cjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
2480
1806
  headers: {
2481
1807
  Authorization: `Bearer token`,
2482
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
1808
+ [_chunkGICQ3YCUcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
2483
1809
  getForId: { name: "counter", actorId }
2484
1810
  })
2485
1811
  }
@@ -2504,10 +1830,10 @@ function runActorInspectorTests(driverTestConfig) {
2504
1830
  const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2505
1831
  const handle = await client.counter.create(["test-rpcs"]);
2506
1832
  const actorId = await handle.resolve();
2507
- const http = _chunkKUPQZYUQcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
1833
+ const http = _chunkLWNKVZG5cjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
2508
1834
  headers: {
2509
1835
  Authorization: `Bearer token`,
2510
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
1836
+ [_chunkGICQ3YCUcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
2511
1837
  getForId: { name: "counter", actorId }
2512
1838
  })
2513
1839
  }
@@ -2525,10 +1851,10 @@ function runActorInspectorTests(driverTestConfig) {
2525
1851
  const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2526
1852
  const handle = await client.counter.create(["test-db"]);
2527
1853
  const actorId = await handle.resolve();
2528
- const http = _chunkKUPQZYUQcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
1854
+ const http = _chunkLWNKVZG5cjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
2529
1855
  headers: {
2530
1856
  Authorization: `Bearer token`,
2531
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
1857
+ [_chunkGICQ3YCUcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
2532
1858
  getForId: { name: "counter", actorId }
2533
1859
  })
2534
1860
  }
@@ -2549,10 +1875,10 @@ function runActorInspectorTests(driverTestConfig) {
2549
1875
  const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2550
1876
  const handle = await client.counter.create(["test-db-query"]);
2551
1877
  const actorId = await handle.resolve();
2552
- const http = _chunkKUPQZYUQcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
1878
+ const http = _chunkLWNKVZG5cjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
2553
1879
  headers: {
2554
1880
  Authorization: `Bearer token`,
2555
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
1881
+ [_chunkGICQ3YCUcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
2556
1882
  getForId: { name: "counter", actorId }
2557
1883
  })
2558
1884
  }
@@ -2801,7 +2127,8 @@ function runManagerDriverTests(driverTestConfig) {
2801
2127
  await client.counter.create(uniqueKey);
2802
2128
  _vitest.expect.fail("did not error on duplicate create");
2803
2129
  } catch (err) {
2804
- _vitest.expect.call(void 0, err.code).toBe("actor_already_exists");
2130
+ _vitest.expect.call(void 0, err.group).toBe("actor");
2131
+ _vitest.expect.call(void 0, err.code).toBe("already_exists");
2805
2132
  }
2806
2133
  const count = await counter.increment(0);
2807
2134
  _vitest.expect.call(void 0, count).toBe(5);
@@ -2815,7 +2142,8 @@ function runManagerDriverTests(driverTestConfig) {
2815
2142
  await client.counter.get([nonexistentId]).resolve();
2816
2143
  _vitest.expect.fail("did not error for get");
2817
2144
  } catch (err) {
2818
- _vitest.expect.call(void 0, err.code).toBe("actor_not_found");
2145
+ _vitest.expect.call(void 0, err.group).toBe("actor");
2146
+ _vitest.expect.call(void 0, err.code).toBe("not_found");
2819
2147
  }
2820
2148
  const createdCounter = client.counter.getOrCreate(nonexistentId);
2821
2149
  await createdCounter.increment(3);
@@ -3062,7 +2390,7 @@ function runRawHttpTests(driverTestConfig) {
3062
2390
  _vitest.expect.call(void 0, errorData.message).toContain(
3063
2391
  "onFetch handler must return a Response"
3064
2392
  );
3065
- } catch (e5) {
2393
+ } catch (e3) {
3066
2394
  }
3067
2395
  });
3068
2396
  _vitest.test.call(void 0, "should handle different HTTP methods", async (c) => {
@@ -3236,186 +2564,7 @@ function runRawHttpTests(driverTestConfig) {
3236
2564
  });
3237
2565
  }
3238
2566
 
3239
- // src/driver-test-suite/tests/raw-http-direct-registry.ts
3240
-
3241
- function runRawHttpDirectRegistryTests(driverTestConfig) {
3242
- _vitest.describe.call(void 0, "raw http - direct registry access", () => {
3243
- _vitest.test.call(void 0, "should handle direct fetch requests to registry with proper headers", async (c) => {
3244
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
3245
- const actorQuery = {
3246
- getOrCreateForKey: {
3247
- name: "rawHttpActor",
3248
- key: ["direct-test"]
3249
- }
3250
- };
3251
- const response = await fetch(
3252
- `${endpoint}/registry/actors/raw/http/api/hello`,
3253
- {
3254
- method: "GET",
3255
- headers: {
3256
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery)
3257
- }
3258
- }
3259
- );
3260
- _vitest.expect.call(void 0, response.ok).toBe(true);
3261
- _vitest.expect.call(void 0, response.status).toBe(200);
3262
- const data = await response.json();
3263
- _vitest.expect.call(void 0, data).toEqual({ message: "Hello from actor!" });
3264
- });
3265
- _vitest.test.call(void 0, "should handle POST requests with body to registry", async (c) => {
3266
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
3267
- const actorQuery = {
3268
- getOrCreateForKey: {
3269
- name: "rawHttpActor",
3270
- key: ["direct-post-test"]
3271
- }
3272
- };
3273
- const testData = { test: "direct", number: 456 };
3274
- const response = await fetch(
3275
- `${endpoint}/registry/actors/raw/http/api/echo`,
3276
- {
3277
- method: "POST",
3278
- headers: {
3279
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
3280
- "Content-Type": "application/json"
3281
- },
3282
- body: JSON.stringify(testData)
3283
- }
3284
- );
3285
- _vitest.expect.call(void 0, response.ok).toBe(true);
3286
- _vitest.expect.call(void 0, response.status).toBe(200);
3287
- const data = await response.json();
3288
- _vitest.expect.call(void 0, data).toEqual(testData);
3289
- });
3290
- _vitest.test.call(void 0, "should pass custom headers through to actor", async (c) => {
3291
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
3292
- const actorQuery = {
3293
- getOrCreateForKey: {
3294
- name: "rawHttpActor",
3295
- key: ["direct-headers-test"]
3296
- }
3297
- };
3298
- const customHeaders = {
3299
- "X-Custom-Header": "direct-test-value",
3300
- "X-Another-Header": "another-direct-value"
3301
- };
3302
- const response = await fetch(
3303
- `${endpoint}/registry/actors/raw/http/api/headers`,
3304
- {
3305
- method: "GET",
3306
- headers: {
3307
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
3308
- ...customHeaders
3309
- }
3310
- }
3311
- );
3312
- _vitest.expect.call(void 0, response.ok).toBe(true);
3313
- const headers = await response.json();
3314
- _vitest.expect.call(void 0, headers["x-custom-header"]).toBe("direct-test-value");
3315
- _vitest.expect.call(void 0, headers["x-another-header"]).toBe("another-direct-value");
3316
- });
3317
- _vitest.test.call(void 0, "should handle connection parameters for authentication", async (c) => {
3318
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
3319
- const actorQuery = {
3320
- getOrCreateForKey: {
3321
- name: "rawHttpActor",
3322
- key: ["direct-auth-test"]
3323
- }
3324
- };
3325
- const connParams = { token: "test-auth-token", userId: "user123" };
3326
- const response = await fetch(
3327
- `${endpoint}/registry/actors/raw/http/api/hello`,
3328
- {
3329
- method: "GET",
3330
- headers: {
3331
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
3332
- [_chunk6WKQDDUDcjs.HEADER_CONN_PARAMS]: JSON.stringify(connParams)
3333
- }
3334
- }
3335
- );
3336
- _vitest.expect.call(void 0, response.ok).toBe(true);
3337
- const data = await response.json();
3338
- _vitest.expect.call(void 0, data).toEqual({ message: "Hello from actor!" });
3339
- });
3340
- _vitest.test.call(void 0, "should return 404 for actors without onFetch handler", async (c) => {
3341
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
3342
- const actorQuery = {
3343
- getOrCreateForKey: {
3344
- name: "rawHttpNoHandlerActor",
3345
- key: ["direct-no-handler"]
3346
- }
3347
- };
3348
- const response = await fetch(
3349
- `${endpoint}/registry/actors/raw/http/api/anything`,
3350
- {
3351
- method: "GET",
3352
- headers: {
3353
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery)
3354
- }
3355
- }
3356
- );
3357
- _vitest.expect.call(void 0, response.ok).toBe(false);
3358
- _vitest.expect.call(void 0, response.status).toBe(404);
3359
- });
3360
- _vitest.test.call(void 0, "should handle different HTTP methods", async (c) => {
3361
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
3362
- const actorQuery = {
3363
- getOrCreateForKey: {
3364
- name: "rawHttpActor",
3365
- key: ["direct-methods-test"]
3366
- }
3367
- };
3368
- const methods = ["GET", "POST", "PUT", "DELETE", "PATCH"];
3369
- for (const method of methods) {
3370
- const response = await fetch(
3371
- `${endpoint}/registry/actors/raw/http/api/echo`,
3372
- {
3373
- method,
3374
- headers: {
3375
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
3376
- ...method !== "GET" ? { "Content-Type": "application/json" } : {}
3377
- },
3378
- body: ["POST", "PUT", "PATCH"].includes(method) ? JSON.stringify({ method }) : void 0
3379
- }
3380
- );
3381
- if (method === "POST") {
3382
- _vitest.expect.call(void 0, response.ok).toBe(true);
3383
- const data = await response.json();
3384
- _vitest.expect.call(void 0, data).toEqual({ method });
3385
- } else {
3386
- _vitest.expect.call(void 0, response.status).toBe(404);
3387
- }
3388
- }
3389
- });
3390
- _vitest.test.call(void 0, "should handle binary data", async (c) => {
3391
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
3392
- const actorQuery = {
3393
- getOrCreateForKey: {
3394
- name: "rawHttpActor",
3395
- key: ["direct-binary-test"]
3396
- }
3397
- };
3398
- const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
3399
- const response = await fetch(
3400
- `${endpoint}/registry/actors/raw/http/api/echo`,
3401
- {
3402
- method: "POST",
3403
- headers: {
3404
- [_chunk6WKQDDUDcjs.HEADER_ACTOR_QUERY]: JSON.stringify(actorQuery),
3405
- "Content-Type": "application/octet-stream"
3406
- },
3407
- body: binaryData
3408
- }
3409
- );
3410
- _vitest.expect.call(void 0, response.ok).toBe(true);
3411
- const responseBuffer = await response.arrayBuffer();
3412
- const responseArray = new Uint8Array(responseBuffer);
3413
- _vitest.expect.call(void 0, Array.from(responseArray)).toEqual([1, 2, 3, 4, 5]);
3414
- });
3415
- });
3416
- }
3417
-
3418
- // src/driver-test-suite/tests/raw-http-request-properties.ts
2567
+ // src/driver-test-suite/tests/raw-http-request-properties.ts
3419
2568
 
3420
2569
  function runRawHttpRequestPropertiesTests(driverTestConfig) {
3421
2570
  _vitest.describe.call(void 0, "raw http request properties", () => {
@@ -4077,289 +3226,6 @@ function runRawWebSocketTests(driverTestConfig) {
4077
3226
  });
4078
3227
  }
4079
3228
 
4080
- // src/driver-test-suite/tests/raw-websocket-direct-registry.ts
4081
-
4082
- function runRawWebSocketDirectRegistryTests(driverTestConfig) {
4083
- _vitest.describe.call(void 0, "raw websocket - direct registry access", () => {
4084
- _vitest.test.call(void 0, "should establish vanilla WebSocket connection with proper subprotocols", async (c) => {
4085
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
4086
- const WebSocket2 = await _chunkTZJKSBUQcjs.importWebSocket.call(void 0, );
4087
- const actorQuery = {
4088
- getOrCreateForKey: {
4089
- name: "rawWebSocketActor",
4090
- key: ["vanilla-test"]
4091
- }
4092
- };
4093
- const queryProtocol = `query.${encodeURIComponent(JSON.stringify(actorQuery))}`;
4094
- const wsEndpoint = endpoint.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
4095
- const wsUrl = `${wsEndpoint}/registry/actors/raw/websocket/`;
4096
- const ws = new WebSocket2(wsUrl, [
4097
- queryProtocol,
4098
- // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
4099
- "rivetkit"
4100
- ]);
4101
- await new Promise((resolve2, reject) => {
4102
- ws.addEventListener("open", () => {
4103
- resolve2();
4104
- });
4105
- ws.addEventListener("error", reject);
4106
- ws.addEventListener("close", reject);
4107
- });
4108
- const welcomeMessage = await new Promise((resolve2, reject) => {
4109
- ws.addEventListener(
4110
- "message",
4111
- (event) => {
4112
- resolve2(JSON.parse(event.data));
4113
- },
4114
- { once: true }
4115
- );
4116
- ws.addEventListener("close", reject);
4117
- });
4118
- _vitest.expect.call(void 0, welcomeMessage.type).toBe("welcome");
4119
- _vitest.expect.call(void 0, welcomeMessage.connectionCount).toBe(1);
4120
- ws.close();
4121
- });
4122
- _vitest.test.call(void 0, "should echo messages with vanilla WebSocket", async (c) => {
4123
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
4124
- const WebSocket2 = await _chunkTZJKSBUQcjs.importWebSocket.call(void 0, );
4125
- const actorQuery = {
4126
- getOrCreateForKey: {
4127
- name: "rawWebSocketActor",
4128
- key: ["vanilla-echo"]
4129
- }
4130
- };
4131
- const queryProtocol = `query.${encodeURIComponent(JSON.stringify(actorQuery))}`;
4132
- const wsEndpoint = endpoint.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
4133
- const wsUrl = `${wsEndpoint}/registry/actors/raw/websocket/`;
4134
- const ws = new WebSocket2(wsUrl, [
4135
- queryProtocol,
4136
- // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
4137
- "rivetkit"
4138
- ]);
4139
- await new Promise((resolve2, reject) => {
4140
- ws.addEventListener("open", () => resolve2(), { once: true });
4141
- ws.addEventListener("close", reject);
4142
- });
4143
- await new Promise((resolve2, reject) => {
4144
- ws.addEventListener("message", () => resolve2(), { once: true });
4145
- ws.addEventListener("close", reject);
4146
- });
4147
- const testMessage = { test: "vanilla", timestamp: Date.now() };
4148
- ws.send(JSON.stringify(testMessage));
4149
- const echoMessage = await new Promise((resolve2, reject) => {
4150
- ws.addEventListener(
4151
- "message",
4152
- (event) => {
4153
- resolve2(JSON.parse(event.data));
4154
- },
4155
- { once: true }
4156
- );
4157
- ws.addEventListener("close", reject);
4158
- });
4159
- _vitest.expect.call(void 0, echoMessage).toEqual(testMessage);
4160
- ws.close();
4161
- });
4162
- _vitest.test.call(void 0, "should handle connection parameters for authentication", async (c) => {
4163
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
4164
- const WebSocket2 = await _chunkTZJKSBUQcjs.importWebSocket.call(void 0, );
4165
- const actorQuery = {
4166
- getOrCreateForKey: {
4167
- name: "rawWebSocketActor",
4168
- key: ["vanilla-auth"]
4169
- }
4170
- };
4171
- const connParams = { token: "ws-auth-token", userId: "ws-user123" };
4172
- const queryProtocol = `query.${encodeURIComponent(JSON.stringify(actorQuery))}`;
4173
- const connParamsProtocol = `conn_params.${encodeURIComponent(JSON.stringify(connParams))}`;
4174
- const wsEndpoint = endpoint.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
4175
- const wsUrl = `${wsEndpoint}/registry/actors/raw/websocket/`;
4176
- const ws = new WebSocket2(wsUrl, [
4177
- queryProtocol,
4178
- connParamsProtocol,
4179
- // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
4180
- "rivetkit"
4181
- ]);
4182
- await new Promise((resolve2, reject) => {
4183
- ws.addEventListener("open", () => {
4184
- resolve2();
4185
- });
4186
- ws.addEventListener("error", reject);
4187
- ws.addEventListener("close", reject);
4188
- });
4189
- const welcomeMessage = await new Promise((resolve2, reject) => {
4190
- ws.addEventListener(
4191
- "message",
4192
- (event) => {
4193
- resolve2(JSON.parse(event.data));
4194
- },
4195
- { once: true }
4196
- );
4197
- ws.addEventListener("close", reject);
4198
- });
4199
- _vitest.expect.call(void 0, welcomeMessage.type).toBe("welcome");
4200
- ws.close();
4201
- });
4202
- _vitest.test.call(void 0, "should handle custom user protocols alongside rivetkit protocols", async (c) => {
4203
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
4204
- const WebSocket2 = await _chunkTZJKSBUQcjs.importWebSocket.call(void 0, );
4205
- const actorQuery = {
4206
- getOrCreateForKey: {
4207
- name: "rawWebSocketActor",
4208
- key: ["vanilla-protocols"]
4209
- }
4210
- };
4211
- const queryProtocol = `query.${encodeURIComponent(JSON.stringify(actorQuery))}`;
4212
- const userProtocol1 = "chat-v1";
4213
- const userProtocol2 = "custom-protocol";
4214
- const wsEndpoint = endpoint.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
4215
- const wsUrl = `${wsEndpoint}/registry/actors/raw/websocket/`;
4216
- const ws = new WebSocket2(wsUrl, [
4217
- queryProtocol,
4218
- userProtocol1,
4219
- userProtocol2,
4220
- // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
4221
- "rivetkit"
4222
- ]);
4223
- await new Promise((resolve2, reject) => {
4224
- ws.addEventListener("open", () => {
4225
- resolve2();
4226
- });
4227
- ws.addEventListener("error", reject);
4228
- ws.addEventListener("close", reject);
4229
- });
4230
- const welcomeMessage = await new Promise((resolve2, reject) => {
4231
- ws.addEventListener(
4232
- "message",
4233
- (event) => {
4234
- resolve2(JSON.parse(event.data));
4235
- },
4236
- { once: true }
4237
- );
4238
- ws.addEventListener("close", reject);
4239
- });
4240
- _vitest.expect.call(void 0, welcomeMessage.type).toBe("welcome");
4241
- ws.close();
4242
- });
4243
- _vitest.test.call(void 0, "should handle different paths for WebSocket routes", async (c) => {
4244
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
4245
- const WebSocket2 = await _chunkTZJKSBUQcjs.importWebSocket.call(void 0, );
4246
- const actorQuery = {
4247
- getOrCreateForKey: {
4248
- name: "rawWebSocketActor",
4249
- key: ["vanilla-paths"]
4250
- }
4251
- };
4252
- const queryProtocol = `query.${encodeURIComponent(JSON.stringify(actorQuery))}`;
4253
- const wsEndpoint = endpoint.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
4254
- const paths = ["chat/room1", "updates/feed", "stream/events"];
4255
- for (const path of paths) {
4256
- const wsUrl = `${wsEndpoint}/registry/actors/raw/websocket/${path}`;
4257
- const ws = new WebSocket2(wsUrl, [
4258
- queryProtocol,
4259
- // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
4260
- "rivetkit"
4261
- ]);
4262
- await new Promise((resolve2, reject) => {
4263
- ws.addEventListener("open", () => {
4264
- resolve2();
4265
- });
4266
- ws.addEventListener("error", reject);
4267
- });
4268
- const welcomeMessage = await new Promise((resolve2, reject) => {
4269
- ws.addEventListener(
4270
- "message",
4271
- (event) => {
4272
- resolve2(JSON.parse(event.data));
4273
- },
4274
- { once: true }
4275
- );
4276
- ws.addEventListener("close", reject);
4277
- });
4278
- _vitest.expect.call(void 0, welcomeMessage.type).toBe("welcome");
4279
- ws.close();
4280
- }
4281
- });
4282
- _vitest.test.call(void 0, "should return error for actors without onWebSocket handler", async (c) => {
4283
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
4284
- const WebSocket2 = await _chunkTZJKSBUQcjs.importWebSocket.call(void 0, );
4285
- const actorQuery = {
4286
- getOrCreateForKey: {
4287
- name: "rawWebSocketNoHandlerActor",
4288
- key: ["vanilla-no-handler"]
4289
- }
4290
- };
4291
- const queryProtocol = `query.${encodeURIComponent(JSON.stringify(actorQuery))}`;
4292
- const wsEndpoint = endpoint.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
4293
- const wsUrl = `${wsEndpoint}/registry/actors/raw/websocket/`;
4294
- const ws = new WebSocket2(wsUrl, [
4295
- queryProtocol,
4296
- // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
4297
- "rivetkit"
4298
- ]);
4299
- await new Promise((resolve2) => {
4300
- ws.addEventListener("error", () => resolve2(), { once: true });
4301
- ws.addEventListener("close", () => resolve2(), { once: true });
4302
- });
4303
- _vitest.expect.call(void 0, ws.readyState).toBe(ws.CLOSED || 3);
4304
- });
4305
- _vitest.test.call(void 0, "should handle binary data over vanilla WebSocket", async (c) => {
4306
- const { endpoint } = await setupDriverTest(c, driverTestConfig);
4307
- const WebSocket2 = await _chunkTZJKSBUQcjs.importWebSocket.call(void 0, );
4308
- const actorQuery = {
4309
- getOrCreateForKey: {
4310
- name: "rawWebSocketActor",
4311
- key: ["vanilla-binary"]
4312
- }
4313
- };
4314
- const queryProtocol = `query.${encodeURIComponent(JSON.stringify(actorQuery))}`;
4315
- const wsEndpoint = endpoint.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
4316
- const wsUrl = `${wsEndpoint}/registry/actors/raw/websocket/`;
4317
- const ws = new WebSocket2(wsUrl, [
4318
- queryProtocol,
4319
- // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
4320
- "rivetkit"
4321
- ]);
4322
- ws.binaryType = "arraybuffer";
4323
- await new Promise((resolve2, reject) => {
4324
- ws.addEventListener("open", () => resolve2(), { once: true });
4325
- ws.addEventListener("close", reject);
4326
- });
4327
- await new Promise((resolve2, reject) => {
4328
- ws.addEventListener("message", () => resolve2(), { once: true });
4329
- ws.addEventListener("close", reject);
4330
- });
4331
- const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
4332
- ws.send(binaryData.buffer);
4333
- const echoedData = await new Promise((resolve2, reject) => {
4334
- ws.addEventListener(
4335
- "message",
4336
- (event) => {
4337
- resolve2(event.data);
4338
- },
4339
- { once: true }
4340
- );
4341
- ws.addEventListener("close", reject);
4342
- });
4343
- const echoedArray = new Uint8Array(echoedData);
4344
- _vitest.expect.call(void 0, Array.from(echoedArray)).toEqual([1, 2, 3, 4, 5]);
4345
- ws.send(JSON.stringify({ type: "binary-test", size: binaryData.length }));
4346
- const echoMessage = await new Promise((resolve2, reject) => {
4347
- ws.addEventListener(
4348
- "message",
4349
- (event) => {
4350
- resolve2(JSON.parse(event.data));
4351
- },
4352
- { once: true }
4353
- );
4354
- ws.addEventListener("close", reject);
4355
- });
4356
- _vitest.expect.call(void 0, echoMessage.type).toBe("binary-test");
4357
- _vitest.expect.call(void 0, echoMessage.size).toBe(5);
4358
- ws.close();
4359
- });
4360
- });
4361
- }
4362
-
4363
3229
  // src/driver-test-suite/tests/request-access.ts
4364
3230
 
4365
3231
  function runRequestAccessTests(driverTestConfig) {
@@ -4434,95 +3300,6 @@ function runRequestAccessTests(driverTestConfig) {
4434
3300
  }
4435
3301
  await connection.dispose();
4436
3302
  });
4437
- _vitest.test.call(void 0, "should have access to request object in onAuth", async (c) => {
4438
- const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
4439
- if (driverTestConfig.clientType === "http") {
4440
- console.log("Skipping onAuth test - requires public endpoint setup");
4441
- }
4442
- });
4443
- _vitest.test.call(void 0, "should have access to request object in onFetch", async (c) => {
4444
- const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
4445
- const handle = client.requestAccessActor.getOrCreate(["test-fetch"]);
4446
- await handle.resolve();
4447
- const actorQuery = {
4448
- getOrCreateForKey: {
4449
- name: "requestAccessActor",
4450
- key: ["test-fetch"]
4451
- }
4452
- };
4453
- const url = `${endpoint}/registry/actors/raw/http/test-path`;
4454
- const response = await fetch(url, {
4455
- method: "POST",
4456
- headers: {
4457
- "Content-Type": "application/json",
4458
- "X-Test-Header": "test-value",
4459
- "X-RivetKit-Query": JSON.stringify(actorQuery)
4460
- },
4461
- body: JSON.stringify({ test: "data" })
4462
- });
4463
- if (!response.ok) {
4464
- const errorText = await response.text();
4465
- console.error(
4466
- `HTTP request failed: ${response.status} ${response.statusText}`,
4467
- errorText
4468
- );
4469
- }
4470
- _vitest.expect.call(void 0, response.ok).toBe(true);
4471
- const data = await response.json();
4472
- _vitest.expect.call(void 0, data.hasRequest).toBe(true);
4473
- _vitest.expect.call(void 0, data.requestUrl).toContain("/test-path");
4474
- _vitest.expect.call(void 0, data.requestMethod).toBe("POST");
4475
- _vitest.expect.call(void 0, data.requestHeaders).toBeDefined();
4476
- _vitest.expect.call(void 0, data.requestHeaders["content-type"]).toBe(
4477
- "application/json"
4478
- );
4479
- _vitest.expect.call(void 0, data.requestHeaders["x-test-header"]).toBe("test-value");
4480
- });
4481
- _vitest.test.call(void 0, "should have access to request object in onWebSocket", async (c) => {
4482
- const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
4483
- if (typeof WebSocket !== "undefined") {
4484
- const handle = client.requestAccessActor.getOrCreate([
4485
- "test-websocket"
4486
- ]);
4487
- await handle.resolve();
4488
- const actorQuery = {
4489
- getOrCreateForKey: {
4490
- name: "requestAccessActor",
4491
- key: ["test-websocket"]
4492
- }
4493
- };
4494
- const queryProtocol = `query.${encodeURIComponent(JSON.stringify(actorQuery))}`;
4495
- const wsUrl = endpoint.replace("http://", "ws://").replace("https://", "wss://");
4496
- const ws = new WebSocket(
4497
- `${wsUrl}/registry/actors/raw/websocket/test-path`,
4498
- [
4499
- queryProtocol,
4500
- "rivetkit"
4501
- // Required protocol
4502
- ]
4503
- );
4504
- await new Promise((resolve2, reject) => {
4505
- ws.onopen = () => {
4506
- };
4507
- ws.onmessage = (event) => {
4508
- try {
4509
- const data = JSON.parse(event.data);
4510
- _vitest.expect.call(void 0, data.hasRequest).toBe(true);
4511
- _vitest.expect.call(void 0, data.requestUrl).toContain("/test-path");
4512
- _vitest.expect.call(void 0, data.requestMethod).toBe("GET");
4513
- _vitest.expect.call(void 0, data.requestHeaders).toBeDefined();
4514
- ws.close();
4515
- resolve2();
4516
- } catch (error) {
4517
- reject(error);
4518
- }
4519
- };
4520
- ws.onerror = (error) => {
4521
- reject(error);
4522
- };
4523
- });
4524
- }
4525
- });
4526
3303
  });
4527
3304
  }
4528
3305
 
@@ -4553,13 +3330,10 @@ function runDriverTests(driverTestConfigPartial) {
4553
3330
  runActorMetadataTests(driverTestConfig);
4554
3331
  runActorOnStateChangeTests(driverTestConfig);
4555
3332
  runActorErrorHandlingTests(driverTestConfig);
4556
- runActorAuthTests(driverTestConfig);
4557
3333
  runActorInlineClientTests(driverTestConfig);
4558
3334
  runRawHttpTests(driverTestConfig);
4559
3335
  runRawHttpRequestPropertiesTests(driverTestConfig);
4560
3336
  runRawWebSocketTests(driverTestConfig);
4561
- runRawHttpDirectRegistryTests(driverTestConfig);
4562
- runRawWebSocketDirectRegistryTests(driverTestConfig);
4563
3337
  runActorInspectorTests(driverTestConfig);
4564
3338
  });
4565
3339
  }
@@ -4571,46 +3345,64 @@ async function createTestRuntime(registryPath, driverFactory) {
4571
3345
  filepath: registryPath
4572
3346
  });
4573
3347
  registry.config.test.enabled = true;
4574
- const { driver, cleanup: driverCleanup } = await driverFactory(registry);
4575
- let injectWebSocket;
4576
- let upgradeWebSocket;
4577
- const config = _chunkCTBOSFUHcjs.RunConfigSchema.parse({
3348
+ const {
4578
3349
  driver,
4579
- getUpgradeWebSocket: () => upgradeWebSocket,
4580
- inspector: {
4581
- enabled: true,
4582
- token: () => "token"
4583
- }
4584
- });
4585
- const managerDriver = driver.manager(registry.config, config);
4586
- const inlineDriver = _chunkUIM22YJLcjs.createInlineClientDriver.call(void 0, managerDriver);
4587
- const { router } = _chunkUIM22YJLcjs.createManagerRouter.call(void 0,
4588
- registry.config,
4589
- config,
4590
- inlineDriver,
4591
- managerDriver,
4592
- false
4593
- );
4594
- const nodeWebSocket = _nodews.createNodeWebSocket.call(void 0, { app: router });
4595
- upgradeWebSocket = nodeWebSocket.upgradeWebSocket;
4596
- injectWebSocket = nodeWebSocket.injectWebSocket;
4597
- const port = await _chunkFCCPJNMAcjs.getPort.call(void 0, );
4598
- const server = _nodeserver.serve.call(void 0, {
4599
- fetch: router.fetch,
4600
- hostname: "127.0.0.1",
4601
- port
4602
- });
4603
- _invariant2.default.call(void 0, injectWebSocket !== void 0, "should have injectWebSocket");
4604
- injectWebSocket(server);
4605
- const endpoint = `http://127.0.0.1:${port}`;
4606
- const cleanup = async () => {
4607
- await new Promise((resolve2) => server.close(() => resolve2(void 0)));
4608
- await (driverCleanup == null ? void 0 : driverCleanup());
4609
- };
4610
- return {
4611
- endpoint,
4612
- cleanup
4613
- };
3350
+ cleanup: driverCleanup,
3351
+ rivetEngine
3352
+ } = await driverFactory(registry);
3353
+ if (rivetEngine) {
3354
+ const cleanup = async () => {
3355
+ await (driverCleanup == null ? void 0 : driverCleanup());
3356
+ };
3357
+ return {
3358
+ endpoint: rivetEngine.endpoint,
3359
+ namespace: rivetEngine.namespace,
3360
+ runnerName: rivetEngine.runnerName,
3361
+ cleanup
3362
+ };
3363
+ } else {
3364
+ let upgradeWebSocket;
3365
+ const config = _chunkWHBPJNGWcjs.RunConfigSchema.parse({
3366
+ driver,
3367
+ getUpgradeWebSocket: () => upgradeWebSocket,
3368
+ inspector: {
3369
+ enabled: true,
3370
+ token: () => "token"
3371
+ }
3372
+ });
3373
+ const managerDriver = driver.manager(registry.config, config);
3374
+ const { router } = _chunkVO7ZRVVDcjs.createManagerRouter.call(void 0,
3375
+ registry.config,
3376
+ config,
3377
+ managerDriver,
3378
+ false
3379
+ );
3380
+ const nodeWebSocket = _nodews.createNodeWebSocket.call(void 0, { app: router });
3381
+ upgradeWebSocket = nodeWebSocket.upgradeWebSocket;
3382
+ const port = await _chunkIH6CKNDWcjs.getPort.call(void 0, );
3383
+ const server = _nodeserver.serve.call(void 0, {
3384
+ fetch: router.fetch,
3385
+ hostname: "127.0.0.1",
3386
+ port
3387
+ });
3388
+ _invariant2.default.call(void 0,
3389
+ nodeWebSocket.injectWebSocket !== void 0,
3390
+ "should have injectWebSocket"
3391
+ );
3392
+ nodeWebSocket.injectWebSocket(server);
3393
+ const serverEndpoint = `http://127.0.0.1:${port}`;
3394
+ logger().info({ msg: "test serer listening", port });
3395
+ const cleanup = async () => {
3396
+ await new Promise((resolve2) => server.close(() => resolve2(void 0)));
3397
+ await (driverCleanup == null ? void 0 : driverCleanup());
3398
+ };
3399
+ return {
3400
+ endpoint: serverEndpoint,
3401
+ namespace: "default",
3402
+ runnerName: "rivetkit",
3403
+ cleanup
3404
+ };
3405
+ }
4614
3406
  }
4615
3407
 
4616
3408