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