rivetkit 0.0.0-feat-sqlite-sync.a2b9069 → 0.0.0-feat-sqlite-sync-3x.a00b07f
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/browser/client.d.ts +58 -9
- package/dist/browser/client.js +193 -23
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -5
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/agent-os/index.cjs +3 -2652
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +1 -2758
- package/dist/tsup/agent-os/index.d.ts +1 -2758
- package/dist/tsup/agent-os/index.js +3 -2652
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-PFLHGSS7.cjs → chunk-3JPXBFED.cjs} +4 -4
- package/dist/tsup/{chunk-PFLHGSS7.cjs.map → chunk-3JPXBFED.cjs.map} +1 -1
- package/dist/tsup/{chunk-VZPQBM4T.js → chunk-5X35FD2T.js} +4 -4
- package/dist/tsup/{chunk-62NMENN2.js → chunk-6QNBANXM.js} +3 -3
- package/dist/tsup/{chunk-TBVEI4CG.js → chunk-7HILY7QU.js} +185 -25
- package/dist/tsup/chunk-7HILY7QU.js.map +1 -0
- package/dist/tsup/{chunk-JI6GZ2C2.js → chunk-A2CF6PFH.js} +18 -1
- package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
- package/dist/tsup/{chunk-XU5FXL53.cjs → chunk-CT6GQRUN.cjs} +3 -3
- package/dist/tsup/{chunk-XU5FXL53.cjs.map → chunk-CT6GQRUN.cjs.map} +1 -1
- package/dist/tsup/{chunk-3XABSX7Z.js → chunk-DRZTELHJ.js} +10 -14
- package/dist/tsup/chunk-DRZTELHJ.js.map +1 -0
- package/dist/tsup/{chunk-S4JJAPRX.js → chunk-DUGEPEJO.js} +2 -2
- package/dist/tsup/{chunk-E443NPGV.cjs → chunk-EA6P3N4I.cjs} +3 -3
- package/dist/tsup/{chunk-E443NPGV.cjs.map → chunk-EA6P3N4I.cjs.map} +1 -1
- package/dist/tsup/{chunk-KNVSGCHJ.cjs → chunk-ERZDCOQ3.cjs} +10 -10
- package/dist/tsup/{chunk-KNVSGCHJ.cjs.map → chunk-ERZDCOQ3.cjs.map} +1 -1
- package/dist/tsup/{chunk-PFOK45LA.js → chunk-GHTA76HT.js} +2 -2
- package/dist/tsup/{chunk-74MPKC4U.js → chunk-ID5VJNZY.js} +2 -2
- package/dist/tsup/{chunk-FKJJX36M.cjs → chunk-PXIOH445.cjs} +326 -166
- package/dist/tsup/chunk-PXIOH445.cjs.map +1 -0
- package/dist/tsup/{chunk-MYWZCDML.cjs → chunk-RTWH3AX3.cjs} +19 -2
- package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
- package/dist/tsup/{chunk-WMBIR2SY.cjs → chunk-UV4KDO4W.cjs} +3 -3
- package/dist/tsup/{chunk-WMBIR2SY.cjs.map → chunk-UV4KDO4W.cjs.map} +1 -1
- package/dist/tsup/{chunk-4G6WPUYN.js → chunk-VI2S336K.js} +2 -2
- package/dist/tsup/{chunk-4AIU4P2C.cjs → chunk-W7NPIYWC.cjs} +10 -14
- package/dist/tsup/chunk-W7NPIYWC.cjs.map +1 -0
- package/dist/tsup/{chunk-BO74QMUL.cjs → chunk-ZZQM77UA.cjs} +7 -7
- package/dist/tsup/{chunk-BO74QMUL.cjs.map → chunk-ZZQM77UA.cjs.map} +1 -1
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.d.cts +15 -3
- package/dist/tsup/client/mod.d.ts +15 -3
- package/dist/tsup/client/mod.js +5 -5
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-DfVrAigH.d.ts → config-B4erdavw.d.ts} +43 -12
- package/dist/tsup/{config-BaUctMNL.d.cts → config-BfG1qpYz.d.cts} +7 -1
- package/dist/tsup/{config-BaUctMNL.d.ts → config-BfG1qpYz.d.ts} +7 -1
- package/dist/tsup/{config-D6T6Ud_V.d.cts → config-DK144OAw.d.cts} +43 -12
- package/dist/tsup/{context-CowF_zyQ.d.cts → context-Cvnf3BRe.d.cts} +2 -2
- package/dist/tsup/{context-BsFWwi3i.d.ts → context-Oxi6YWcG.d.ts} +2 -2
- package/dist/tsup/db/drizzle.cjs +2 -2
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +3 -3
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +2 -2
- package/dist/tsup/dynamic/mod.d.cts +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- package/dist/tsup/inspector/mod.cjs +5 -5
- package/dist/tsup/inspector/mod.js +4 -4
- package/dist/tsup/inspector/workflow.cjs +4 -4
- package/dist/tsup/inspector/workflow.js +3 -3
- package/dist/tsup/inspector-tab/mod.d.cts +3 -3
- package/dist/tsup/inspector-tab/mod.d.ts +3 -3
- package/dist/tsup/mod.cjs +256 -174
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -4
- package/dist/tsup/mod.d.ts +4 -4
- package/dist/tsup/mod.js +170 -88
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +7 -7
- package/dist/tsup/test/mod.d.cts +2 -2
- package/dist/tsup/test/mod.d.ts +2 -2
- package/dist/tsup/test/mod.js +5 -5
- package/dist/tsup/unstable/migrations.d.cts +1 -1
- package/dist/tsup/unstable/migrations.d.ts +1 -1
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +17 -17
- package/dist/tsup/workflow/mod.d.cts +4 -4
- package/dist/tsup/workflow/mod.d.ts +4 -4
- package/dist/tsup/workflow/mod.js +5 -5
- package/package.json +9 -13
- package/src/actor/keys.ts +86 -0
- package/src/agent-os/index.ts +5 -65
- package/src/client/actor-conn.ts +92 -6
- package/src/client/actor-handle.ts +24 -4
- package/src/client/client.ts +14 -4
- package/src/client/config.ts +12 -1
- package/src/client/lifecycle-errors.ts +16 -1
- package/src/client/retry-budget.ts +78 -0
- package/src/client/utils.ts +13 -2
- package/src/common/database/config.ts +7 -1
- package/src/common/database/native-database.ts +17 -9
- package/src/common/router.ts +1 -1
- package/src/engine-api/actors.ts +3 -3
- package/src/engine-client/actor-websocket-client.ts +4 -2
- package/src/engine-client/api-endpoints.ts +44 -14
- package/src/engine-client/mod.ts +2 -2
- package/src/registry/config/envoy.ts +1 -1
- package/src/registry/config/index.ts +28 -31
- package/src/registry/index.ts +51 -19
- package/src/registry/napi-runtime.ts +3 -2
- package/src/registry/native.ts +129 -40
- package/src/registry/runtime.ts +27 -10
- package/src/registry/wasm-runtime.ts +6 -3
- package/src/utils/env-vars.ts +15 -10
- package/dist/tsup/chunk-3XABSX7Z.js.map +0 -1
- package/dist/tsup/chunk-4AIU4P2C.cjs.map +0 -1
- package/dist/tsup/chunk-FKJJX36M.cjs.map +0 -1
- package/dist/tsup/chunk-JI6GZ2C2.js.map +0 -1
- package/dist/tsup/chunk-MYWZCDML.cjs.map +0 -1
- package/dist/tsup/chunk-TBVEI4CG.js.map +0 -1
- package/src/actor/config.test.ts +0 -78
- package/src/actor/keys.test.ts +0 -275
- package/src/actor/utils.test.ts +0 -48
- package/src/agent-os/actor/cron.ts +0 -84
- package/src/agent-os/actor/db.ts +0 -54
- package/src/agent-os/actor/filesystem.ts +0 -131
- package/src/agent-os/actor/index.ts +0 -285
- package/src/agent-os/actor/network.ts +0 -58
- package/src/agent-os/actor/preview.ts +0 -190
- package/src/agent-os/actor/process.ts +0 -177
- package/src/agent-os/actor/session.ts +0 -518
- package/src/agent-os/actor/shell.ts +0 -60
- package/src/agent-os/config.ts +0 -79
- package/src/agent-os/fs/database-vfs.ts +0 -624
- package/src/agent-os/types.ts +0 -148
- package/src/client/test.ts +0 -44
- package/src/client/token-provider.test.ts +0 -86
- package/src/common/database/mod.test.ts +0 -364
- package/src/common/database/native-database.test.ts +0 -241
- package/src/common/inline-websocket-adapter.test.ts +0 -51
- package/src/db/drizzle.test.ts +0 -164
- package/src/registry/config/index.test.ts +0 -25
- package/src/registry/run-handler-coordinator.test.ts +0 -252
- package/src/registry/runtime.test.ts +0 -124
- package/src/unstable/migrations.test.ts +0 -170
- package/src/utils/endpoint-parser.test.ts +0 -206
- package/src/utils.test.ts +0 -34
- package/src/workflow/driver.test.ts +0 -62
- /package/dist/tsup/{chunk-VZPQBM4T.js.map → chunk-5X35FD2T.js.map} +0 -0
- /package/dist/tsup/{chunk-62NMENN2.js.map → chunk-6QNBANXM.js.map} +0 -0
- /package/dist/tsup/{chunk-S4JJAPRX.js.map → chunk-DUGEPEJO.js.map} +0 -0
- /package/dist/tsup/{chunk-PFOK45LA.js.map → chunk-GHTA76HT.js.map} +0 -0
- /package/dist/tsup/{chunk-74MPKC4U.js.map → chunk-ID5VJNZY.js.map} +0 -0
- /package/dist/tsup/{chunk-4G6WPUYN.js.map → chunk-VI2S336K.js.map} +0 -0
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import type { z } from "zod/v4";
|
|
3
|
-
import { tryParseEndpoint } from "./endpoint-parser";
|
|
4
|
-
|
|
5
|
-
// Helper to create a mock Zod refinement context for testing
|
|
6
|
-
function createMockCtx(): { ctx: z.RefinementCtx; issues: z.ZodIssue[] } {
|
|
7
|
-
const issues: z.ZodIssue[] = [];
|
|
8
|
-
const ctx = {
|
|
9
|
-
addIssue: (issue: z.IssueData) => {
|
|
10
|
-
issues.push(issue as z.ZodIssue);
|
|
11
|
-
},
|
|
12
|
-
path: [],
|
|
13
|
-
value: undefined,
|
|
14
|
-
issues: [],
|
|
15
|
-
} as unknown as z.RefinementCtx;
|
|
16
|
-
return { ctx, issues };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
describe("tryParseEndpoint", () => {
|
|
20
|
-
describe("basic parsing", () => {
|
|
21
|
-
test("parses endpoint with full auth", () => {
|
|
22
|
-
const { ctx, issues } = createMockCtx();
|
|
23
|
-
const result = tryParseEndpoint(ctx, {
|
|
24
|
-
endpoint: "https://foo:bar@api.rivet.dev",
|
|
25
|
-
});
|
|
26
|
-
expect(issues).toHaveLength(0);
|
|
27
|
-
expect(result).toEqual({
|
|
28
|
-
endpoint: "https://api.rivet.dev/",
|
|
29
|
-
namespace: "foo",
|
|
30
|
-
token: "bar",
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test("parses endpoint with namespace only", () => {
|
|
35
|
-
const { ctx, issues } = createMockCtx();
|
|
36
|
-
const result = tryParseEndpoint(ctx, {
|
|
37
|
-
endpoint: "https://foo@api.rivet.dev",
|
|
38
|
-
});
|
|
39
|
-
expect(issues).toHaveLength(0);
|
|
40
|
-
expect(result).toEqual({
|
|
41
|
-
endpoint: "https://api.rivet.dev/",
|
|
42
|
-
namespace: "foo",
|
|
43
|
-
token: undefined,
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test("parses endpoint without auth", () => {
|
|
48
|
-
const { ctx, issues } = createMockCtx();
|
|
49
|
-
const result = tryParseEndpoint(ctx, {
|
|
50
|
-
endpoint: "https://api.rivet.dev",
|
|
51
|
-
});
|
|
52
|
-
expect(issues).toHaveLength(0);
|
|
53
|
-
expect(result).toEqual({
|
|
54
|
-
endpoint: "https://api.rivet.dev/",
|
|
55
|
-
namespace: undefined,
|
|
56
|
-
token: undefined,
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("preserves path", () => {
|
|
61
|
-
const { ctx, issues } = createMockCtx();
|
|
62
|
-
const result = tryParseEndpoint(ctx, {
|
|
63
|
-
endpoint: "https://foo:bar@api.rivet.dev/v1/actors",
|
|
64
|
-
});
|
|
65
|
-
expect(issues).toHaveLength(0);
|
|
66
|
-
expect(result).toEqual({
|
|
67
|
-
endpoint: "https://api.rivet.dev/v1/actors",
|
|
68
|
-
namespace: "foo",
|
|
69
|
-
token: "bar",
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe("validation errors", () => {
|
|
75
|
-
test("adds issue for invalid URL", () => {
|
|
76
|
-
const { ctx, issues } = createMockCtx();
|
|
77
|
-
const result = tryParseEndpoint(ctx, { endpoint: "not-a-url" });
|
|
78
|
-
expect(result).toBeUndefined();
|
|
79
|
-
expect(issues).toHaveLength(1);
|
|
80
|
-
expect(issues[0]?.message).toContain("invalid URL");
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test("adds issue for query string", () => {
|
|
84
|
-
const { ctx, issues } = createMockCtx();
|
|
85
|
-
const result = tryParseEndpoint(ctx, {
|
|
86
|
-
endpoint: "https://foo:bar@api.rivet.dev?region=us",
|
|
87
|
-
});
|
|
88
|
-
expect(result).toBeUndefined();
|
|
89
|
-
expect(issues).toHaveLength(1);
|
|
90
|
-
expect(issues[0]?.message).toBe(
|
|
91
|
-
"endpoint cannot contain a query string",
|
|
92
|
-
);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test("adds issue for fragment", () => {
|
|
96
|
-
const { ctx, issues } = createMockCtx();
|
|
97
|
-
const result = tryParseEndpoint(ctx, {
|
|
98
|
-
endpoint: "https://foo:bar@api.rivet.dev#section",
|
|
99
|
-
});
|
|
100
|
-
expect(result).toBeUndefined();
|
|
101
|
-
expect(issues).toHaveLength(1);
|
|
102
|
-
expect(issues[0]?.message).toBe(
|
|
103
|
-
"endpoint cannot contain a fragment",
|
|
104
|
-
);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test("adds issue for token without namespace", () => {
|
|
108
|
-
const { ctx, issues } = createMockCtx();
|
|
109
|
-
const result = tryParseEndpoint(ctx, {
|
|
110
|
-
endpoint: "https://:token@api.rivet.dev",
|
|
111
|
-
});
|
|
112
|
-
expect(result).toBeUndefined();
|
|
113
|
-
expect(issues).toHaveLength(1);
|
|
114
|
-
expect(issues[0]?.message).toBe(
|
|
115
|
-
"endpoint cannot have a token without a namespace",
|
|
116
|
-
);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe("duplicate credential checking", () => {
|
|
121
|
-
test("adds issue when namespace in URL and config", () => {
|
|
122
|
-
const { ctx, issues } = createMockCtx();
|
|
123
|
-
const result = tryParseEndpoint(ctx, {
|
|
124
|
-
endpoint: "https://url-ns@api.rivet.dev",
|
|
125
|
-
path: ["endpoint"],
|
|
126
|
-
namespace: "config-ns",
|
|
127
|
-
});
|
|
128
|
-
// Still returns result, but adds issue
|
|
129
|
-
expect(result).toEqual({
|
|
130
|
-
endpoint: "https://api.rivet.dev/",
|
|
131
|
-
namespace: "url-ns",
|
|
132
|
-
token: undefined,
|
|
133
|
-
});
|
|
134
|
-
expect(issues).toHaveLength(1);
|
|
135
|
-
expect(issues[0]?.message).toContain(
|
|
136
|
-
"cannot specify namespace both in endpoint URL and as a separate config option",
|
|
137
|
-
);
|
|
138
|
-
expect(issues[0]?.path).toEqual(["namespace"]);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
test("adds issue when token in URL and config", () => {
|
|
142
|
-
const { ctx, issues } = createMockCtx();
|
|
143
|
-
const result = tryParseEndpoint(ctx, {
|
|
144
|
-
endpoint: "https://ns:url-token@api.rivet.dev",
|
|
145
|
-
path: ["endpoint"],
|
|
146
|
-
token: "config-token",
|
|
147
|
-
});
|
|
148
|
-
// Still returns result, but adds issue
|
|
149
|
-
expect(result).toEqual({
|
|
150
|
-
endpoint: "https://api.rivet.dev/",
|
|
151
|
-
namespace: "ns",
|
|
152
|
-
token: "url-token",
|
|
153
|
-
});
|
|
154
|
-
expect(issues).toHaveLength(1);
|
|
155
|
-
expect(issues[0]?.message).toContain(
|
|
156
|
-
"cannot specify token both in endpoint URL and as a separate config option",
|
|
157
|
-
);
|
|
158
|
-
expect(issues[0]?.path).toEqual(["token"]);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test("adds issues for both namespace and token duplicates", () => {
|
|
162
|
-
const { ctx, issues } = createMockCtx();
|
|
163
|
-
const result = tryParseEndpoint(ctx, {
|
|
164
|
-
endpoint: "https://url-ns:url-token@api.rivet.dev",
|
|
165
|
-
path: ["endpoint"],
|
|
166
|
-
namespace: "config-ns",
|
|
167
|
-
token: "config-token",
|
|
168
|
-
});
|
|
169
|
-
expect(result).toBeDefined();
|
|
170
|
-
expect(issues).toHaveLength(2);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
test("no issue when namespace only in URL", () => {
|
|
174
|
-
const { ctx, issues } = createMockCtx();
|
|
175
|
-
const result = tryParseEndpoint(ctx, {
|
|
176
|
-
endpoint: "https://url-ns@api.rivet.dev",
|
|
177
|
-
path: ["endpoint"],
|
|
178
|
-
token: "config-token",
|
|
179
|
-
});
|
|
180
|
-
expect(result).toBeDefined();
|
|
181
|
-
expect(issues).toHaveLength(0);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
test("no issue when namespace only in config", () => {
|
|
185
|
-
const { ctx, issues } = createMockCtx();
|
|
186
|
-
const result = tryParseEndpoint(ctx, {
|
|
187
|
-
endpoint: "https://api.rivet.dev",
|
|
188
|
-
path: ["endpoint"],
|
|
189
|
-
namespace: "config-ns",
|
|
190
|
-
});
|
|
191
|
-
expect(result).toBeDefined();
|
|
192
|
-
expect(issues).toHaveLength(0);
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
describe("custom path", () => {
|
|
197
|
-
test("uses custom path in error issues", () => {
|
|
198
|
-
const { ctx, issues } = createMockCtx();
|
|
199
|
-
tryParseEndpoint(ctx, {
|
|
200
|
-
endpoint: "not-a-url",
|
|
201
|
-
path: ["serverless", "publicEndpoint"],
|
|
202
|
-
});
|
|
203
|
-
expect(issues[0]?.path).toEqual(["serverless", "publicEndpoint"]);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
});
|
package/src/utils.test.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { joinSignals } from "./utils";
|
|
3
|
-
|
|
4
|
-
describe("joinSignals", () => {
|
|
5
|
-
test("returns a non-aborted signal when no inputs are provided", () => {
|
|
6
|
-
const signal = joinSignals();
|
|
7
|
-
expect(signal.aborted).toBe(false);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test("returns the same signal when only one input is provided", () => {
|
|
11
|
-
const controller = new AbortController();
|
|
12
|
-
const signal = joinSignals(controller.signal);
|
|
13
|
-
expect(signal).toBe(controller.signal);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test("aborts immediately when any input signal is already aborted", () => {
|
|
17
|
-
const controllerA = new AbortController();
|
|
18
|
-
const controllerB = new AbortController();
|
|
19
|
-
controllerA.abort("already-aborted");
|
|
20
|
-
|
|
21
|
-
const signal = joinSignals(controllerA.signal, controllerB.signal);
|
|
22
|
-
expect(signal.aborted).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test("aborts when one of the joined signals aborts", () => {
|
|
26
|
-
const controllerA = new AbortController();
|
|
27
|
-
const controllerB = new AbortController();
|
|
28
|
-
const signal = joinSignals(controllerA.signal, controllerB.signal);
|
|
29
|
-
|
|
30
|
-
expect(signal.aborted).toBe(false);
|
|
31
|
-
controllerB.abort("stopped");
|
|
32
|
-
expect(signal.aborted).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { ActorWorkflowDriver, chunkWorkflowWrites } from "./driver";
|
|
3
|
-
|
|
4
|
-
function write(keyBytes: number, valueBytes: number) {
|
|
5
|
-
return {
|
|
6
|
-
key: new Uint8Array(keyBytes),
|
|
7
|
-
value: new Uint8Array(valueBytes),
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
describe("workflow sqlite batching", () => {
|
|
12
|
-
test.each([
|
|
13
|
-
[127, 1],
|
|
14
|
-
[128, 1],
|
|
15
|
-
[129, 2],
|
|
16
|
-
])("chunks %i rows into %i transaction(s)", (rowCount, chunkCount) => {
|
|
17
|
-
const chunks = chunkWorkflowWrites(
|
|
18
|
-
Array.from({ length: rowCount }, () => write(1, 1)),
|
|
19
|
-
);
|
|
20
|
-
expect(chunks).toHaveLength(chunkCount);
|
|
21
|
-
expect(chunks.flat()).toHaveLength(rowCount);
|
|
22
|
-
expect(chunks.every((chunk) => chunk.length <= 128)).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test("splits immediately above the 512 KiB payload budget", () => {
|
|
26
|
-
// Each persisted key also includes the two-byte workflow namespace.
|
|
27
|
-
const exact = [write(1, 256 * 1024 - 3), write(1, 256 * 1024 - 3)];
|
|
28
|
-
expect(chunkWorkflowWrites(exact)).toHaveLength(1);
|
|
29
|
-
|
|
30
|
-
const over = [write(1, 256 * 1024 - 3), write(1, 256 * 1024 - 2)];
|
|
31
|
-
expect(chunkWorkflowWrites(over)).toHaveLength(2);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test("delegates actor state and the whole workflow batch to one atomic runtime call", async () => {
|
|
35
|
-
let receivedWrites: Array<{ key: Uint8Array; value: Uint8Array }> = [];
|
|
36
|
-
const sql = {
|
|
37
|
-
query: async () => ({ columns: [], rows: [] }),
|
|
38
|
-
execute: async () => [],
|
|
39
|
-
run: async () => ({ changes: 0 }),
|
|
40
|
-
executeBatch: async () => [],
|
|
41
|
-
};
|
|
42
|
-
const actor = {
|
|
43
|
-
stateManager: {
|
|
44
|
-
saveStateAndWorkflowBatch: async (
|
|
45
|
-
writes: Array<{ key: Uint8Array; value: Uint8Array }>,
|
|
46
|
-
) => {
|
|
47
|
-
receivedWrites = writes;
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
queueManager: {},
|
|
51
|
-
};
|
|
52
|
-
const runCtx = {
|
|
53
|
-
sql,
|
|
54
|
-
internalKeepAwake: async <T>(promise: Promise<T>) => await promise,
|
|
55
|
-
};
|
|
56
|
-
const driver = new ActorWorkflowDriver(actor as never, runCtx as never);
|
|
57
|
-
const writes = [write(1, 1), write(2, 2)];
|
|
58
|
-
await driver.batch(writes);
|
|
59
|
-
expect(driver.atomicBatch).toBe(true);
|
|
60
|
-
expect(receivedWrites).toBe(writes);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|