rivetkit 2.0.20 → 2.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/{chunk-L3YPHXPE.js → chunk-2POQCWMA.js} +481 -100
- package/dist/tsup/chunk-2POQCWMA.js.map +1 -0
- package/dist/tsup/{chunk-5F6X4AFU.js → chunk-3UIGKLZW.js} +6 -6
- package/dist/tsup/chunk-3UIGKLZW.js.map +1 -0
- package/dist/tsup/{chunk-M6LIJ6BK.js → chunk-4OINFQBR.js} +3 -3
- package/dist/tsup/{chunk-ZODINJWN.cjs → chunk-65SAIRRY.cjs} +12 -12
- package/dist/tsup/chunk-65SAIRRY.cjs.map +1 -0
- package/dist/tsup/{chunk-RI4YHZZW.js → chunk-6G76WIWL.js} +2 -2
- package/dist/tsup/{chunk-RI4YHZZW.js.map → chunk-6G76WIWL.js.map} +1 -1
- package/dist/tsup/{chunk-YFFCPYHY.js → chunk-D2LS4X6E.js} +11 -5
- package/dist/tsup/chunk-D2LS4X6E.js.map +1 -0
- package/dist/tsup/{chunk-QRUGCDA5.js → chunk-DYA34FHW.js} +2 -2
- package/dist/tsup/{chunk-KUZWEM23.cjs → chunk-ELDFBXDV.cjs} +8 -4
- package/dist/tsup/chunk-ELDFBXDV.cjs.map +1 -0
- package/dist/tsup/{chunk-FYP3TZXD.cjs → chunk-FDJ3AVNB.cjs} +32 -26
- package/dist/tsup/chunk-FDJ3AVNB.cjs.map +1 -0
- package/dist/tsup/{chunk-ER5OT3SQ.js → chunk-FUX6U6TL.js} +2 -2
- package/dist/tsup/chunk-FUX6U6TL.js.map +1 -0
- package/dist/tsup/{chunk-RJVSNJO7.cjs → chunk-HN7UXCYQ.cjs} +7 -7
- package/dist/tsup/chunk-HN7UXCYQ.cjs.map +1 -0
- package/dist/tsup/{chunk-QMVCFQ37.js → chunk-HUGSRAGL.js} +8 -4
- package/dist/tsup/chunk-HUGSRAGL.js.map +1 -0
- package/dist/tsup/{chunk-PV22ZBDE.cjs → chunk-JKOUXDK6.cjs} +16 -10
- package/dist/tsup/chunk-JKOUXDK6.cjs.map +1 -0
- package/dist/tsup/{chunk-2I6L3VRO.cjs → chunk-JTIBPF7N.cjs} +14 -14
- package/dist/tsup/chunk-JTIBPF7N.cjs.map +1 -0
- package/dist/tsup/chunk-KSRXX3Z4.cjs.map +1 -1
- package/dist/tsup/{chunk-JZD6FEOE.cjs → chunk-LMJHBF26.cjs} +455 -289
- package/dist/tsup/chunk-LMJHBF26.cjs.map +1 -0
- package/dist/tsup/{chunk-KKRR7DSG.cjs → chunk-LWGCMELP.cjs} +3 -3
- package/dist/tsup/chunk-LWGCMELP.cjs.map +1 -0
- package/dist/tsup/{chunk-2S7HJMMY.cjs → chunk-M5BHNJHB.cjs} +630 -249
- package/dist/tsup/chunk-M5BHNJHB.cjs.map +1 -0
- package/dist/tsup/{chunk-G6JGHCG4.cjs → chunk-O4GUKGK4.cjs} +6 -6
- package/dist/tsup/chunk-O4GUKGK4.cjs.map +1 -0
- package/dist/tsup/{chunk-7ACKZS3T.js → chunk-RZZDFDB6.js} +13 -7
- package/dist/tsup/chunk-RZZDFDB6.js.map +1 -0
- package/dist/tsup/{chunk-MGHPBNWB.js → chunk-VLR3TDHT.js} +2 -2
- package/dist/tsup/{chunk-GQ5WTE64.js → chunk-Y2QONT7B.js} +263 -97
- package/dist/tsup/chunk-Y2QONT7B.js.map +1 -0
- package/dist/tsup/{chunk-DUOTOMP7.cjs → chunk-ZNWE3XBT.cjs} +3 -3
- package/dist/tsup/chunk-ZNWE3XBT.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.cjs.map +1 -1
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{conn-CmPcqOCF.d.ts → conn-Clu655RU.d.ts} +72 -71
- package/dist/tsup/{conn-DU5EbfCu.d.cts → conn-lUvFLo_q.d.cts} +72 -71
- package/dist/tsup/driver-helpers/mod.cjs +5 -5
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +1 -1
- package/dist/tsup/driver-helpers/mod.d.ts +1 -1
- package/dist/tsup/driver-helpers/mod.js +4 -4
- package/dist/tsup/driver-test-suite/mod.cjs +603 -294
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +1 -1
- package/dist/tsup/driver-test-suite/mod.d.ts +1 -1
- package/dist/tsup/driver-test-suite/mod.js +574 -265
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +68 -7
- package/dist/tsup/inspector/mod.d.ts +68 -7
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/mod.cjs +10 -10
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +2 -2
- package/dist/tsup/mod.d.ts +2 -2
- package/dist/tsup/mod.js +9 -9
- package/dist/tsup/test/mod.cjs +11 -11
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +10 -10
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.js +1 -1
- package/package.json +4 -3
- package/src/actor/config.ts +108 -15
- package/src/actor/conn-drivers.ts +2 -1
- package/src/actor/instance.ts +119 -35
- package/src/actor/keys.test.ts +13 -4
- package/src/actor/protocol/old.ts +10 -3
- package/src/actor/router-endpoints.ts +26 -16
- package/src/actor/router.ts +41 -13
- package/src/actor/unstable-react.ts +1 -1
- package/src/client/actor-common.ts +3 -1
- package/src/client/actor-conn.ts +44 -12
- package/src/client/actor-handle.ts +4 -1
- package/src/client/client.ts +32 -18
- package/src/client/utils.ts +21 -8
- package/src/common/actor-router-consts.ts +2 -0
- package/src/common/inline-websocket-adapter2.ts +24 -6
- package/src/common/log.ts +6 -2
- package/src/common/logfmt.ts +3 -1
- package/src/common/router.ts +3 -1
- package/src/common/utils.ts +6 -2
- package/src/driver-helpers/utils.ts +4 -1
- package/src/driver-test-suite/mod.ts +15 -4
- package/src/driver-test-suite/test-inline-client-driver.ts +35 -13
- package/src/driver-test-suite/tests/action-features.ts +6 -2
- package/src/driver-test-suite/tests/actor-conn-state.ts +18 -8
- package/src/driver-test-suite/tests/actor-conn.ts +35 -13
- package/src/driver-test-suite/tests/actor-handle.ts +35 -15
- package/src/driver-test-suite/tests/actor-inline-client.ts +34 -23
- package/src/driver-test-suite/tests/actor-inspector.ts +241 -131
- package/src/driver-test-suite/tests/actor-reconnect.ts +14 -4
- package/src/driver-test-suite/tests/actor-schedule.ts +12 -3
- package/src/driver-test-suite/tests/actor-sleep.ts +6 -3
- package/src/driver-test-suite/tests/actor-vars.ts +6 -2
- package/src/driver-test-suite/tests/manager-driver.ts +16 -6
- package/src/driver-test-suite/tests/raw-http-request-properties.ts +64 -25
- package/src/driver-test-suite/tests/raw-http.ts +17 -5
- package/src/driver-test-suite/tests/raw-websocket.ts +36 -12
- package/src/driver-test-suite/tests/request-access.ts +18 -8
- package/src/drivers/engine/actor-driver.ts +46 -25
- package/src/drivers/engine/config.ts +2 -1
- package/src/drivers/file-system/global-state.ts +58 -16
- package/src/drivers/file-system/manager.ts +35 -12
- package/src/drivers/file-system/mod.ts +6 -1
- package/src/drivers/file-system/utils.ts +8 -2
- package/src/engine-process/mod.ts +15 -4
- package/src/inspector/actor.ts +63 -23
- package/src/inspector/config.ts +2 -1
- package/src/inspector/manager.ts +10 -3
- package/src/inspector/utils.ts +2 -1
- package/src/manager/driver.ts +4 -1
- package/src/manager/gateway.ts +278 -8
- package/src/manager/hono-websocket-adapter.ts +33 -10
- package/src/manager/router-schema.ts +4 -2
- package/src/manager/router.ts +78 -12
- package/src/manager-api/actors.ts +2 -0
- package/src/registry/mod.ts +31 -9
- package/src/registry/run-config.ts +3 -1
- package/src/remote-manager-driver/api-endpoints.ts +2 -2
- package/src/remote-manager-driver/mod.ts +23 -7
- package/src/remote-manager-driver/ws-proxy.ts +21 -5
- package/src/serde.ts +6 -2
- package/src/test/mod.ts +2 -1
- package/src/utils.ts +6 -2
- package/dist/tsup/chunk-2I6L3VRO.cjs.map +0 -1
- package/dist/tsup/chunk-2S7HJMMY.cjs.map +0 -1
- package/dist/tsup/chunk-5F6X4AFU.js.map +0 -1
- package/dist/tsup/chunk-7ACKZS3T.js.map +0 -1
- package/dist/tsup/chunk-DUOTOMP7.cjs.map +0 -1
- package/dist/tsup/chunk-ER5OT3SQ.js.map +0 -1
- package/dist/tsup/chunk-FYP3TZXD.cjs.map +0 -1
- package/dist/tsup/chunk-G6JGHCG4.cjs.map +0 -1
- package/dist/tsup/chunk-GQ5WTE64.js.map +0 -1
- package/dist/tsup/chunk-JZD6FEOE.cjs.map +0 -1
- package/dist/tsup/chunk-KKRR7DSG.cjs.map +0 -1
- package/dist/tsup/chunk-KUZWEM23.cjs.map +0 -1
- package/dist/tsup/chunk-L3YPHXPE.js.map +0 -1
- package/dist/tsup/chunk-PV22ZBDE.cjs.map +0 -1
- package/dist/tsup/chunk-QMVCFQ37.js.map +0 -1
- package/dist/tsup/chunk-RJVSNJO7.cjs.map +0 -1
- package/dist/tsup/chunk-YFFCPYHY.js.map +0 -1
- package/dist/tsup/chunk-ZODINJWN.cjs.map +0 -1
- /package/dist/tsup/{chunk-M6LIJ6BK.js.map → chunk-4OINFQBR.js.map} +0 -0
- /package/dist/tsup/{chunk-QRUGCDA5.js.map → chunk-DYA34FHW.js.map} +0 -0
- /package/dist/tsup/{chunk-MGHPBNWB.js.map → chunk-VLR3TDHT.js.map} +0 -0
|
@@ -64,7 +64,8 @@ export function runActorSleepTests(driverTestConfig: DriverTestConfig) {
|
|
|
64
64
|
// Reconnect to get sleep count after restore
|
|
65
65
|
const sleepActor2 = client.sleep.getOrCreate();
|
|
66
66
|
{
|
|
67
|
-
const { startCount, sleepCount } =
|
|
67
|
+
const { startCount, sleepCount } =
|
|
68
|
+
await sleepActor2.getCounts();
|
|
68
69
|
expect(sleepCount).toBe(1);
|
|
69
70
|
expect(startCount).toBe(2);
|
|
70
71
|
}
|
|
@@ -116,7 +117,8 @@ export function runActorSleepTests(driverTestConfig: DriverTestConfig) {
|
|
|
116
117
|
// Reconnect to get sleep count after restore
|
|
117
118
|
const sleepActor2 = client.sleep.getOrCreate();
|
|
118
119
|
{
|
|
119
|
-
const { startCount, sleepCount } =
|
|
120
|
+
const { startCount, sleepCount } =
|
|
121
|
+
await sleepActor2.getCounts();
|
|
120
122
|
expect(sleepCount).toBe(1);
|
|
121
123
|
expect(startCount).toBe(2);
|
|
122
124
|
}
|
|
@@ -257,7 +259,8 @@ export function runActorSleepTests(driverTestConfig: DriverTestConfig) {
|
|
|
257
259
|
// Actor should have slept after the timeout
|
|
258
260
|
const sleepActor2 = client.sleepWithLongRpc.getOrCreate();
|
|
259
261
|
{
|
|
260
|
-
const { startCount, sleepCount } =
|
|
262
|
+
const { startCount, sleepCount } =
|
|
263
|
+
await sleepActor2.getCounts();
|
|
261
264
|
expect(sleepCount).toBe(1); // Slept once
|
|
262
265
|
expect(startCount).toBe(2); // New instance after sleep
|
|
263
266
|
}
|
|
@@ -25,8 +25,12 @@ export function runActorVarsTests(driverTestConfig: DriverTestConfig) {
|
|
|
25
25
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
26
26
|
|
|
27
27
|
// Create two separate instances
|
|
28
|
-
const instance1 = client.nestedVarActor.getOrCreate([
|
|
29
|
-
|
|
28
|
+
const instance1 = client.nestedVarActor.getOrCreate([
|
|
29
|
+
"instance1",
|
|
30
|
+
]);
|
|
31
|
+
const instance2 = client.nestedVarActor.getOrCreate([
|
|
32
|
+
"instance2",
|
|
33
|
+
]);
|
|
30
34
|
|
|
31
35
|
// Modify vars in the first instance
|
|
32
36
|
const modifiedVars = await instance1.modifyNested();
|
|
@@ -19,7 +19,10 @@ export function runManagerDriverTests(driverTestConfig: DriverTestConfig) {
|
|
|
19
19
|
expect(count).toBe(5);
|
|
20
20
|
|
|
21
21
|
// Connect with key creates a new actor with specific parameters
|
|
22
|
-
const counterB = client.counter.getOrCreate([
|
|
22
|
+
const counterB = client.counter.getOrCreate([
|
|
23
|
+
"counter-b",
|
|
24
|
+
"testing",
|
|
25
|
+
]);
|
|
23
26
|
|
|
24
27
|
await counterB.increment(10);
|
|
25
28
|
const countB = await counterB.increment(0);
|
|
@@ -66,7 +69,8 @@ export function runManagerDriverTests(driverTestConfig: DriverTestConfig) {
|
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
// Create the actor
|
|
69
|
-
const createdCounter =
|
|
72
|
+
const createdCounter =
|
|
73
|
+
client.counter.getOrCreate(nonexistentId);
|
|
70
74
|
await createdCounter.increment(3);
|
|
71
75
|
|
|
72
76
|
// Now no create should work since the actor exists
|
|
@@ -249,7 +253,9 @@ export function runManagerDriverTests(driverTestConfig: DriverTestConfig) {
|
|
|
249
253
|
expect(subsetMatchCount).toBe(0); // Should be a new counter with 0
|
|
250
254
|
|
|
251
255
|
// Should NOT match with just one key - should create new actor
|
|
252
|
-
const singleKeyCounter = client.counter.getOrCreate([
|
|
256
|
+
const singleKeyCounter = client.counter.getOrCreate([
|
|
257
|
+
"counter-match",
|
|
258
|
+
]);
|
|
253
259
|
const singleKeyCount = await singleKeyCounter.increment(0);
|
|
254
260
|
expect(singleKeyCount).toBe(0); // Should be a new counter with 0
|
|
255
261
|
});
|
|
@@ -258,11 +264,14 @@ export function runManagerDriverTests(driverTestConfig: DriverTestConfig) {
|
|
|
258
264
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
259
265
|
|
|
260
266
|
// Create actor with string key
|
|
261
|
-
const stringKeyCounter =
|
|
267
|
+
const stringKeyCounter =
|
|
268
|
+
client.counter.getOrCreate("string-key-test");
|
|
262
269
|
await stringKeyCounter.increment(7);
|
|
263
270
|
|
|
264
271
|
// Should match with equivalent array key
|
|
265
|
-
const arrayKeyCounter = client.counter.getOrCreate([
|
|
272
|
+
const arrayKeyCounter = client.counter.getOrCreate([
|
|
273
|
+
"string-key-test",
|
|
274
|
+
]);
|
|
266
275
|
const count = await arrayKeyCounter.increment(0);
|
|
267
276
|
expect(count).toBe(7);
|
|
268
277
|
});
|
|
@@ -271,7 +280,8 @@ export function runManagerDriverTests(driverTestConfig: DriverTestConfig) {
|
|
|
271
280
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
272
281
|
|
|
273
282
|
// Create actor with undefined key
|
|
274
|
-
const undefinedKeyCounter =
|
|
283
|
+
const undefinedKeyCounter =
|
|
284
|
+
client.counter.getOrCreate(undefined);
|
|
275
285
|
await undefinedKeyCounter.increment(12);
|
|
276
286
|
|
|
277
287
|
// Should match with empty array key
|
|
@@ -10,7 +10,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
10
10
|
describe("raw http request properties", () => {
|
|
11
11
|
test("should pass all Request properties correctly to onFetch", async (c) => {
|
|
12
12
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
13
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
13
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
14
|
+
"test",
|
|
15
|
+
]);
|
|
14
16
|
|
|
15
17
|
// Test basic request properties
|
|
16
18
|
const response = await actor.fetch("test/path?foo=bar&baz=qux", {
|
|
@@ -49,7 +51,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
49
51
|
|
|
50
52
|
test("should handle GET requests with no body", async (c) => {
|
|
51
53
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
52
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
54
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
55
|
+
"test",
|
|
56
|
+
]);
|
|
53
57
|
|
|
54
58
|
const response = await actor.fetch("test/get", {
|
|
55
59
|
method: "GET",
|
|
@@ -64,7 +68,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
64
68
|
|
|
65
69
|
test("should handle different content types", async (c) => {
|
|
66
70
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
67
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
71
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
72
|
+
"test",
|
|
73
|
+
]);
|
|
68
74
|
|
|
69
75
|
// Test form data
|
|
70
76
|
const formData = new URLSearchParams();
|
|
@@ -103,7 +109,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
103
109
|
|
|
104
110
|
test("should preserve all header casing and values", async (c) => {
|
|
105
111
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
106
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
112
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
113
|
+
"test",
|
|
114
|
+
]);
|
|
107
115
|
|
|
108
116
|
const response = await actor.fetch("test/headers", {
|
|
109
117
|
headers: {
|
|
@@ -129,7 +137,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
129
137
|
|
|
130
138
|
test("should handle empty and special URL paths", async (c) => {
|
|
131
139
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
132
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
140
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
141
|
+
"test",
|
|
142
|
+
]);
|
|
133
143
|
|
|
134
144
|
// Test root path
|
|
135
145
|
const rootResponse = await actor.fetch("");
|
|
@@ -145,7 +155,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
145
155
|
const specialData = (await specialResponse.json()) as any;
|
|
146
156
|
// Note: The URL path may or may not be decoded depending on the HTTP client/server
|
|
147
157
|
// Just verify it contains the expected segments
|
|
148
|
-
expect(specialData.pathname).toMatch(
|
|
158
|
+
expect(specialData.pathname).toMatch(
|
|
159
|
+
/path.*with.*spaces.*and.*slashes/,
|
|
160
|
+
);
|
|
149
161
|
|
|
150
162
|
// Test path with fragment (should be ignored in server-side)
|
|
151
163
|
const fragmentResponse = await actor.fetch("test/path#fragment");
|
|
@@ -157,7 +169,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
157
169
|
|
|
158
170
|
test("should handle request properties for all HTTP methods", async (c) => {
|
|
159
171
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
160
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
172
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
173
|
+
"test",
|
|
174
|
+
]);
|
|
161
175
|
|
|
162
176
|
const methods = [
|
|
163
177
|
"GET",
|
|
@@ -170,13 +184,16 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
170
184
|
];
|
|
171
185
|
|
|
172
186
|
for (const method of methods) {
|
|
173
|
-
const response = await actor.fetch(
|
|
174
|
-
method
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
:
|
|
179
|
-
|
|
187
|
+
const response = await actor.fetch(
|
|
188
|
+
`test/${method.toLowerCase()}`,
|
|
189
|
+
{
|
|
190
|
+
method,
|
|
191
|
+
// Only include body for methods that support it
|
|
192
|
+
body: ["POST", "PUT", "PATCH"].includes(method)
|
|
193
|
+
? JSON.stringify({ method })
|
|
194
|
+
: undefined,
|
|
195
|
+
},
|
|
196
|
+
);
|
|
180
197
|
|
|
181
198
|
// HEAD responses have no body
|
|
182
199
|
if (method === "HEAD") {
|
|
@@ -197,7 +214,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
197
214
|
|
|
198
215
|
test("should handle complex query parameters", async (c) => {
|
|
199
216
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
200
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
217
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
218
|
+
"test",
|
|
219
|
+
]);
|
|
201
220
|
|
|
202
221
|
// Test multiple values for same key
|
|
203
222
|
const response = await actor.fetch(
|
|
@@ -214,7 +233,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
214
233
|
|
|
215
234
|
test("should handle multipart form data", async (c) => {
|
|
216
235
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
217
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
236
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
237
|
+
"test",
|
|
238
|
+
]);
|
|
218
239
|
|
|
219
240
|
// Create multipart boundary
|
|
220
241
|
const boundary = "----RivetKitBoundary";
|
|
@@ -240,14 +261,18 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
240
261
|
|
|
241
262
|
expect(response.ok).toBe(true);
|
|
242
263
|
const data = (await response.json()) as any;
|
|
243
|
-
expect(data.headers["content-type"]).toContain(
|
|
264
|
+
expect(data.headers["content-type"]).toContain(
|
|
265
|
+
"multipart/form-data",
|
|
266
|
+
);
|
|
244
267
|
expect(data.bodyText).toContain("field1");
|
|
245
268
|
expect(data.bodyText).toContain("value1");
|
|
246
269
|
});
|
|
247
270
|
|
|
248
271
|
test("should handle very long URLs", async (c) => {
|
|
249
272
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
250
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
273
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
274
|
+
"test",
|
|
275
|
+
]);
|
|
251
276
|
|
|
252
277
|
// Create a very long query string
|
|
253
278
|
const longValue = "x".repeat(1000);
|
|
@@ -261,7 +286,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
261
286
|
|
|
262
287
|
test("should handle large request bodies", async (c) => {
|
|
263
288
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
264
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
289
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
290
|
+
"test",
|
|
291
|
+
]);
|
|
265
292
|
|
|
266
293
|
// Create a large JSON body (1MB+)
|
|
267
294
|
const largeArray = new Array(10000).fill({
|
|
@@ -285,7 +312,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
285
312
|
|
|
286
313
|
test("should handle missing content-type header", async (c) => {
|
|
287
314
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
288
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
315
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
316
|
+
"test",
|
|
317
|
+
]);
|
|
289
318
|
|
|
290
319
|
const response = await actor.fetch("test/no-content-type", {
|
|
291
320
|
method: "POST",
|
|
@@ -299,7 +328,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
299
328
|
|
|
300
329
|
test("should handle empty request body", async (c) => {
|
|
301
330
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
302
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
331
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
332
|
+
"test",
|
|
333
|
+
]);
|
|
303
334
|
|
|
304
335
|
const response = await actor.fetch("test/empty", {
|
|
305
336
|
method: "POST",
|
|
@@ -317,7 +348,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
317
348
|
|
|
318
349
|
test("should handle custom HTTP methods", async (c) => {
|
|
319
350
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
320
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
351
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
352
|
+
"test",
|
|
353
|
+
]);
|
|
321
354
|
|
|
322
355
|
// Test a custom method (though most HTTP clients may not support this)
|
|
323
356
|
try {
|
|
@@ -338,7 +371,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
338
371
|
|
|
339
372
|
test("should handle cookies in headers", async (c) => {
|
|
340
373
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
341
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
374
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
375
|
+
"test",
|
|
376
|
+
]);
|
|
342
377
|
|
|
343
378
|
const response = await actor.fetch("test/cookies", {
|
|
344
379
|
headers: {
|
|
@@ -355,7 +390,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
355
390
|
|
|
356
391
|
test("should handle URL encoding properly", async (c) => {
|
|
357
392
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
358
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
393
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
394
|
+
"test",
|
|
395
|
+
]);
|
|
359
396
|
|
|
360
397
|
// Test various encoded characters
|
|
361
398
|
const response = await actor.fetch(
|
|
@@ -373,7 +410,9 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
373
410
|
|
|
374
411
|
test("should handle concurrent requests maintaining separate contexts", async (c) => {
|
|
375
412
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
376
|
-
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
413
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
414
|
+
"test",
|
|
415
|
+
]);
|
|
377
416
|
|
|
378
417
|
// Send multiple concurrent requests with different data
|
|
379
418
|
const requests = [
|
|
@@ -81,7 +81,9 @@ export function runRawHttpTests(driverTestConfig: DriverTestConfig) {
|
|
|
81
81
|
|
|
82
82
|
test("should return 404 when no onFetch handler defined", async (c) => {
|
|
83
83
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
84
|
-
const actor = client.rawHttpNoHandlerActor.getOrCreate([
|
|
84
|
+
const actor = client.rawHttpNoHandlerActor.getOrCreate([
|
|
85
|
+
"no-handler",
|
|
86
|
+
]);
|
|
85
87
|
|
|
86
88
|
const response = await actor.fetch("api/anything");
|
|
87
89
|
expect(response.ok).toBe(false);
|
|
@@ -92,7 +94,9 @@ export function runRawHttpTests(driverTestConfig: DriverTestConfig) {
|
|
|
92
94
|
|
|
93
95
|
test("should return 500 error when onFetch returns void", async (c) => {
|
|
94
96
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
95
|
-
const actor = client.rawHttpVoidReturnActor.getOrCreate([
|
|
97
|
+
const actor = client.rawHttpVoidReturnActor.getOrCreate([
|
|
98
|
+
"void-return",
|
|
99
|
+
]);
|
|
96
100
|
|
|
97
101
|
const response = await actor.fetch("api/anything");
|
|
98
102
|
expect(response.ok).toBe(false);
|
|
@@ -100,7 +104,9 @@ export function runRawHttpTests(driverTestConfig: DriverTestConfig) {
|
|
|
100
104
|
|
|
101
105
|
// Check error message - response might be CBOR encoded
|
|
102
106
|
try {
|
|
103
|
-
const errorData = (await response.json()) as {
|
|
107
|
+
const errorData = (await response.json()) as {
|
|
108
|
+
message: string;
|
|
109
|
+
};
|
|
104
110
|
expect(errorData.message).toContain(
|
|
105
111
|
"onFetch handler must return a Response",
|
|
106
112
|
);
|
|
@@ -276,7 +282,10 @@ export function runRawHttpTests(driverTestConfig: DriverTestConfig) {
|
|
|
276
282
|
|
|
277
283
|
// This simulates calling actor.fetch(truncatedPath, newRequest)
|
|
278
284
|
// which was causing double slashes in the example
|
|
279
|
-
const response = await actor.fetch(
|
|
285
|
+
const response = await actor.fetch(
|
|
286
|
+
truncatedPath,
|
|
287
|
+
newRequest as any,
|
|
288
|
+
);
|
|
280
289
|
expect(response.ok).toBe(true);
|
|
281
290
|
const users = await response.json();
|
|
282
291
|
expect(users).toEqual([
|
|
@@ -338,7 +347,10 @@ export function runRawHttpTests(driverTestConfig: DriverTestConfig) {
|
|
|
338
347
|
headers: { "X-Override": "init-header" },
|
|
339
348
|
});
|
|
340
349
|
expect(overrideResponse.ok).toBe(true);
|
|
341
|
-
const headers = (await overrideResponse.json()) as Record<
|
|
350
|
+
const headers = (await overrideResponse.json()) as Record<
|
|
351
|
+
string,
|
|
352
|
+
string
|
|
353
|
+
>;
|
|
342
354
|
expect(headers["x-override"]).toBe("init-header");
|
|
343
355
|
// Original headers should be present too
|
|
344
356
|
expect(headers["x-original"]).toBe("request-header");
|
|
@@ -55,7 +55,9 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
55
55
|
// Check if WebSocket is already open
|
|
56
56
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
57
57
|
await new Promise<void>((resolve, reject) => {
|
|
58
|
-
ws.addEventListener("open", () => resolve(), {
|
|
58
|
+
ws.addEventListener("open", () => resolve(), {
|
|
59
|
+
once: true,
|
|
60
|
+
});
|
|
59
61
|
ws.addEventListener("close", reject);
|
|
60
62
|
});
|
|
61
63
|
}
|
|
@@ -95,7 +97,9 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
95
97
|
// Check if WebSocket is already open
|
|
96
98
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
97
99
|
await new Promise<void>((resolve, reject) => {
|
|
98
|
-
ws.addEventListener("open", () => resolve(), {
|
|
100
|
+
ws.addEventListener("open", () => resolve(), {
|
|
101
|
+
once: true,
|
|
102
|
+
});
|
|
99
103
|
ws.addEventListener("close", reject);
|
|
100
104
|
});
|
|
101
105
|
}
|
|
@@ -132,7 +136,9 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
132
136
|
// Create first connection to ensure actor exists
|
|
133
137
|
const ws1 = await actor1.websocket();
|
|
134
138
|
const ws1MessagePromise = new Promise<void>((resolve, reject) => {
|
|
135
|
-
ws1.addEventListener("message", () => resolve(), {
|
|
139
|
+
ws1.addEventListener("message", () => resolve(), {
|
|
140
|
+
once: true,
|
|
141
|
+
});
|
|
136
142
|
ws1.addEventListener("close", reject);
|
|
137
143
|
});
|
|
138
144
|
|
|
@@ -143,7 +149,9 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
143
149
|
const actor2 = client.rawWebSocketActor.get(["stats"]);
|
|
144
150
|
const ws2 = await actor2.websocket();
|
|
145
151
|
const ws2MessagePromise = new Promise<void>((resolve, reject) => {
|
|
146
|
-
ws2.addEventListener("message", () => resolve(), {
|
|
152
|
+
ws2.addEventListener("message", () => resolve(), {
|
|
153
|
+
once: true,
|
|
154
|
+
});
|
|
147
155
|
ws2.addEventListener("close", reject);
|
|
148
156
|
});
|
|
149
157
|
|
|
@@ -191,14 +199,18 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
191
199
|
|
|
192
200
|
test("should handle binary data", async (c) => {
|
|
193
201
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
194
|
-
const actor = client.rawWebSocketBinaryActor.getOrCreate([
|
|
202
|
+
const actor = client.rawWebSocketBinaryActor.getOrCreate([
|
|
203
|
+
"binary",
|
|
204
|
+
]);
|
|
195
205
|
|
|
196
206
|
const ws = await actor.websocket();
|
|
197
207
|
|
|
198
208
|
// Check if WebSocket is already open
|
|
199
209
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
200
210
|
await new Promise<void>((resolve, reject) => {
|
|
201
|
-
ws.addEventListener("open", () => resolve(), {
|
|
211
|
+
ws.addEventListener("open", () => resolve(), {
|
|
212
|
+
once: true,
|
|
213
|
+
});
|
|
202
214
|
ws.addEventListener("close", reject);
|
|
203
215
|
});
|
|
204
216
|
}
|
|
@@ -220,7 +232,9 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
220
232
|
|
|
221
233
|
// Convert Blob to ArrayBuffer if needed
|
|
222
234
|
const buffer =
|
|
223
|
-
response instanceof Blob
|
|
235
|
+
response instanceof Blob
|
|
236
|
+
? await response.arrayBuffer()
|
|
237
|
+
: response;
|
|
224
238
|
|
|
225
239
|
return new Uint8Array(buffer);
|
|
226
240
|
};
|
|
@@ -241,7 +255,9 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
241
255
|
|
|
242
256
|
// Verify it's reversed correctly
|
|
243
257
|
for (let i = 0; i < largeData.length; i++) {
|
|
244
|
-
expect(largeReversed[i]).toBe(
|
|
258
|
+
expect(largeReversed[i]).toBe(
|
|
259
|
+
largeData[largeData.length - 1 - i],
|
|
260
|
+
);
|
|
245
261
|
}
|
|
246
262
|
|
|
247
263
|
ws.close();
|
|
@@ -286,7 +302,9 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
286
302
|
// Check if WebSocket is already open
|
|
287
303
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
288
304
|
await new Promise<void>((resolve, reject) => {
|
|
289
|
-
ws.addEventListener("open", () => resolve(), {
|
|
305
|
+
ws.addEventListener("open", () => resolve(), {
|
|
306
|
+
once: true,
|
|
307
|
+
});
|
|
290
308
|
ws.addEventListener("close", reject);
|
|
291
309
|
});
|
|
292
310
|
}
|
|
@@ -320,7 +338,9 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
320
338
|
|
|
321
339
|
test("should properly handle onWebSocket open and close events", async (c) => {
|
|
322
340
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
323
|
-
const actor = client.rawWebSocketActor.getOrCreate([
|
|
341
|
+
const actor = client.rawWebSocketActor.getOrCreate([
|
|
342
|
+
"open-close-test",
|
|
343
|
+
]);
|
|
324
344
|
|
|
325
345
|
// Create first connection
|
|
326
346
|
const ws1 = await actor.websocket();
|
|
@@ -413,10 +433,14 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
413
433
|
|
|
414
434
|
test("should handle query parameters in websocket paths", async (c) => {
|
|
415
435
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
416
|
-
const actor = client.rawWebSocketActor.getOrCreate([
|
|
436
|
+
const actor = client.rawWebSocketActor.getOrCreate([
|
|
437
|
+
"query-params",
|
|
438
|
+
]);
|
|
417
439
|
|
|
418
440
|
// Test WebSocket with query parameters
|
|
419
|
-
const ws = await actor.websocket(
|
|
441
|
+
const ws = await actor.websocket(
|
|
442
|
+
"api/v1/stream?token=abc123&user=test",
|
|
443
|
+
);
|
|
420
444
|
|
|
421
445
|
await new Promise<void>((resolve, reject) => {
|
|
422
446
|
ws.addEventListener("open", () => resolve(), { once: true });
|
|
@@ -8,9 +8,12 @@ export function runRequestAccessTests(driverTestConfig: DriverTestConfig) {
|
|
|
8
8
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
9
9
|
|
|
10
10
|
// Create actor with request tracking enabled
|
|
11
|
-
const handle = client.requestAccessActor.getOrCreate(
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const handle = client.requestAccessActor.getOrCreate(
|
|
12
|
+
["test-request"],
|
|
13
|
+
{
|
|
14
|
+
params: { trackRequest: true },
|
|
15
|
+
},
|
|
16
|
+
);
|
|
14
17
|
const connection = handle.connect();
|
|
15
18
|
|
|
16
19
|
// Get request info that was captured in onBeforeConnect
|
|
@@ -22,13 +25,17 @@ export function runRequestAccessTests(driverTestConfig: DriverTestConfig) {
|
|
|
22
25
|
expect(requestInfo.onBeforeConnect.hasRequest).toBe(true);
|
|
23
26
|
expect(requestInfo.onBeforeConnect.requestUrl).toBeDefined();
|
|
24
27
|
expect(requestInfo.onBeforeConnect.requestMethod).toBeDefined();
|
|
25
|
-
expect(
|
|
28
|
+
expect(
|
|
29
|
+
requestInfo.onBeforeConnect.requestHeaders,
|
|
30
|
+
).toBeDefined();
|
|
26
31
|
|
|
27
32
|
// Check createConnState
|
|
28
33
|
expect(requestInfo.createConnState.hasRequest).toBe(true);
|
|
29
34
|
expect(requestInfo.createConnState.requestUrl).toBeDefined();
|
|
30
35
|
expect(requestInfo.createConnState.requestMethod).toBeDefined();
|
|
31
|
-
expect(
|
|
36
|
+
expect(
|
|
37
|
+
requestInfo.createConnState.requestHeaders,
|
|
38
|
+
).toBeDefined();
|
|
32
39
|
} else {
|
|
33
40
|
// Inline client may or may not have request object depending on the driver
|
|
34
41
|
//
|
|
@@ -79,9 +86,12 @@ export function runRequestAccessTests(driverTestConfig: DriverTestConfig) {
|
|
|
79
86
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
80
87
|
|
|
81
88
|
// Create actor and connect with request tracking
|
|
82
|
-
const handle = client.requestAccessActor.getOrCreate(
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
const handle = client.requestAccessActor.getOrCreate(
|
|
90
|
+
["test-headers"],
|
|
91
|
+
{
|
|
92
|
+
params: { trackRequest: true },
|
|
93
|
+
},
|
|
94
|
+
);
|
|
85
95
|
const connection = handle.connect();
|
|
86
96
|
|
|
87
97
|
// Get request info
|