rivetkit 2.0.37 → 2.0.39
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/{chunk-G4N7FZMM.cjs → chunk-7E3RWMR6.cjs} +195 -93
- package/dist/tsup/chunk-7E3RWMR6.cjs.map +1 -0
- package/dist/tsup/{chunk-J6TX5EFW.js → chunk-BQ36VTSB.js} +108 -6
- package/dist/tsup/chunk-BQ36VTSB.js.map +1 -0
- package/dist/tsup/{chunk-4V7MS7SO.cjs → chunk-C64FV764.cjs} +3 -3
- package/dist/tsup/{chunk-4V7MS7SO.cjs.map → chunk-C64FV764.cjs.map} +1 -1
- package/dist/tsup/{chunk-XI335ZED.js → chunk-CDK6DRO2.js} +6 -4
- package/dist/tsup/chunk-CDK6DRO2.js.map +1 -0
- package/dist/tsup/{chunk-LYYTV7DN.cjs → chunk-DY4H3ASE.cjs} +50 -46
- package/dist/tsup/chunk-DY4H3ASE.cjs.map +1 -0
- package/dist/tsup/{chunk-B6BP74X3.cjs → chunk-KMYFL3OL.cjs} +318 -92
- package/dist/tsup/chunk-KMYFL3OL.cjs.map +1 -0
- package/dist/tsup/{chunk-22NKW7F5.cjs → chunk-MZPYVTVG.cjs} +9 -9
- package/dist/tsup/{chunk-22NKW7F5.cjs.map → chunk-MZPYVTVG.cjs.map} +1 -1
- package/dist/tsup/{chunk-RBA5AQTB.js → chunk-OJZRCEIA.js} +5 -5
- package/dist/tsup/{chunk-RXA3ZMCL.js → chunk-PHCD25XO.js} +2 -2
- package/dist/tsup/{chunk-5XGZXH74.js → chunk-PVKUXMOA.js} +264 -38
- package/dist/tsup/chunk-PVKUXMOA.js.map +1 -0
- package/dist/tsup/{chunk-FIUSIG6J.js → chunk-T7IPDBWH.js} +8 -4
- package/dist/tsup/{chunk-FIUSIG6J.js.map → chunk-T7IPDBWH.js.map} +1 -1
- package/dist/tsup/{chunk-5VVIFC6M.cjs → chunk-UAX5E3EU.cjs} +443 -369
- package/dist/tsup/chunk-UAX5E3EU.cjs.map +1 -0
- package/dist/tsup/{chunk-X5IX3YPO.cjs → chunk-X72X7I7T.cjs} +6 -4
- package/dist/tsup/chunk-X72X7I7T.cjs.map +1 -0
- package/dist/tsup/{chunk-ZQBSQ6H3.js → chunk-XU74APB4.js} +208 -134
- package/dist/tsup/chunk-XU74APB4.js.map +1 -0
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.d.cts +3 -3
- package/dist/tsup/client/mod.d.ts +3 -3
- package/dist/tsup/client/mod.js +4 -4
- 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--NjwiYlS.d.cts → config-BuBlMs6C.d.cts} +238 -60
- package/dist/tsup/{config-CRuzI6n4.d.ts → config-CBwo4ooA.d.ts} +238 -60
- package/dist/tsup/{driver-yKjYx9Yy.d.cts → driver-CPXmh8f8.d.cts} +1 -1
- package/dist/tsup/{driver-BcmckRaF.d.ts → driver-DxWa6HUO.d.ts} +1 -1
- package/dist/tsup/driver-helpers/mod.cjs +3 -3
- package/dist/tsup/driver-helpers/mod.d.cts +2 -2
- package/dist/tsup/driver-helpers/mod.d.ts +2 -2
- package/dist/tsup/driver-helpers/mod.js +2 -2
- package/dist/tsup/driver-test-suite/mod.cjs +81 -35
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +2 -2
- package/dist/tsup/driver-test-suite/mod.d.ts +2 -2
- package/dist/tsup/driver-test-suite/mod.js +407 -361
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/{kv-CTM8sCvx.d.cts → keys-Chhy4ylv.d.cts} +1 -0
- package/dist/tsup/{kv-CTM8sCvx.d.ts → keys-Chhy4ylv.d.ts} +1 -0
- package/dist/tsup/mod.cjs +19 -7
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +18 -6
- package/dist/tsup/test/mod.cjs +7 -7
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/package.json +6 -4
- package/src/actor/config.ts +198 -2
- package/src/actor/contexts/base/actor.ts +12 -0
- package/src/actor/instance/connection-manager.ts +1 -1
- package/src/actor/instance/keys.ts +29 -0
- package/src/actor/instance/kv.ts +240 -14
- package/src/actor/instance/mod.ts +5 -4
- package/src/actor/instance/state-manager.ts +1 -1
- package/src/actor/mod.ts +2 -1
- package/src/actor/router-websocket-endpoints.ts +2 -1
- package/src/client/actor-conn.ts +70 -81
- package/src/client/actor-handle.ts +35 -15
- package/src/client/actor-query.ts +47 -0
- package/src/client/errors.ts +22 -58
- package/src/client/mod.ts +1 -1
- package/src/client/utils.ts +33 -0
- package/src/driver-helpers/utils.ts +1 -1
- package/src/driver-test-suite/mod.ts +3 -0
- package/src/driver-test-suite/test-inline-client-driver.ts +3 -0
- package/src/driver-test-suite/tests/actor-kv.ts +44 -0
- package/src/driver-test-suite/utils.ts +4 -0
- package/src/drivers/engine/actor-driver.ts +3 -3
- package/src/drivers/file-system/manager.ts +5 -0
- package/src/manager/driver.ts +8 -3
- package/src/manager-api/actors.ts +1 -20
- package/src/registry/config/index.ts +68 -0
- package/src/remote-manager-driver/actor-http-client.ts +5 -3
- package/src/remote-manager-driver/actor-websocket-client.ts +18 -7
- package/src/remote-manager-driver/mod.ts +21 -1
- package/src/serverless/router.test.ts +166 -0
- package/src/serverless/router.ts +58 -5
- package/src/utils/env-vars.ts +4 -1
- package/dist/tsup/chunk-5VVIFC6M.cjs.map +0 -1
- package/dist/tsup/chunk-5XGZXH74.js.map +0 -1
- package/dist/tsup/chunk-B6BP74X3.cjs.map +0 -1
- package/dist/tsup/chunk-G4N7FZMM.cjs.map +0 -1
- package/dist/tsup/chunk-J6TX5EFW.js.map +0 -1
- package/dist/tsup/chunk-LYYTV7DN.cjs.map +0 -1
- package/dist/tsup/chunk-X5IX3YPO.cjs.map +0 -1
- package/dist/tsup/chunk-XI335ZED.js.map +0 -1
- package/dist/tsup/chunk-ZQBSQ6H3.js.map +0 -1
- /package/dist/tsup/{chunk-RBA5AQTB.js.map → chunk-OJZRCEIA.js.map} +0 -0
- /package/dist/tsup/{chunk-RXA3ZMCL.js.map → chunk-PHCD25XO.js.map} +0 -0
|
@@ -26,6 +26,12 @@ describe("normalizeEndpointUrl", () => {
|
|
|
26
26
|
);
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
+
test("normalizes IPv6 loopback [::1] to localhost", () => {
|
|
30
|
+
expect(normalizeEndpointUrl("http://[::1]:6420")).toBe(
|
|
31
|
+
"http://localhost:6420/",
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
29
35
|
test("preserves path without trailing slash", () => {
|
|
30
36
|
expect(normalizeEndpointUrl("http://example.com/api/v1")).toBe(
|
|
31
37
|
"http://example.com/api/v1",
|
|
@@ -69,6 +75,50 @@ describe("normalizeEndpointUrl", () => {
|
|
|
69
75
|
test("returns null for empty string", () => {
|
|
70
76
|
expect(normalizeEndpointUrl("")).toBeNull();
|
|
71
77
|
});
|
|
78
|
+
|
|
79
|
+
describe("regional endpoint normalization", () => {
|
|
80
|
+
test("normalizes api-us-west-1.rivet.dev to api.rivet.dev", () => {
|
|
81
|
+
expect(normalizeEndpointUrl("https://api-us-west-1.rivet.dev")).toBe(
|
|
82
|
+
"https://api.rivet.dev/",
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("normalizes api-lax.staging.rivet.dev to api.staging.rivet.dev", () => {
|
|
87
|
+
expect(
|
|
88
|
+
normalizeEndpointUrl("https://api-lax.staging.rivet.dev"),
|
|
89
|
+
).toBe("https://api.staging.rivet.dev/");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("preserves api.rivet.dev unchanged", () => {
|
|
93
|
+
expect(normalizeEndpointUrl("https://api.rivet.dev")).toBe(
|
|
94
|
+
"https://api.rivet.dev/",
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("does not normalize non-api prefixed hostnames", () => {
|
|
99
|
+
expect(normalizeEndpointUrl("https://foo-bar.rivet.dev")).toBe(
|
|
100
|
+
"https://foo-bar.rivet.dev/",
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("does not normalize non-rivet.dev domains", () => {
|
|
105
|
+
expect(normalizeEndpointUrl("https://api-us-west-1.example.com")).toBe(
|
|
106
|
+
"https://api-us-west-1.example.com/",
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("preserves path when normalizing regional endpoint", () => {
|
|
111
|
+
expect(
|
|
112
|
+
normalizeEndpointUrl("https://api-us-west-1.rivet.dev/v1/actors"),
|
|
113
|
+
).toBe("https://api.rivet.dev/v1/actors");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test("preserves port when normalizing regional endpoint", () => {
|
|
117
|
+
expect(
|
|
118
|
+
normalizeEndpointUrl("https://api-us-west-1.rivet.dev:8080"),
|
|
119
|
+
).toBe("https://api.rivet.dev:8080/");
|
|
120
|
+
});
|
|
121
|
+
});
|
|
72
122
|
});
|
|
73
123
|
|
|
74
124
|
describe("endpointsMatch", () => {
|
|
@@ -102,6 +152,12 @@ describe("endpointsMatch", () => {
|
|
|
102
152
|
).toBe(true);
|
|
103
153
|
});
|
|
104
154
|
|
|
155
|
+
test("matches localhost and IPv6 loopback [::1]", () => {
|
|
156
|
+
expect(
|
|
157
|
+
endpointsMatch("http://localhost:6420", "http://[::1]:6420"),
|
|
158
|
+
).toBe(true);
|
|
159
|
+
});
|
|
160
|
+
|
|
105
161
|
test("does not match different hosts", () => {
|
|
106
162
|
expect(
|
|
107
163
|
endpointsMatch("http://localhost:6420", "http://example.com:6420"),
|
|
@@ -130,4 +186,114 @@ describe("endpointsMatch", () => {
|
|
|
130
186
|
expect(endpointsMatch("not-a-url", "not-a-url")).toBe(true);
|
|
131
187
|
expect(endpointsMatch("not-a-url", "different")).toBe(false);
|
|
132
188
|
});
|
|
189
|
+
|
|
190
|
+
describe("regional endpoint matching", () => {
|
|
191
|
+
test("matches api.rivet.dev with api-us-west-1.rivet.dev", () => {
|
|
192
|
+
expect(
|
|
193
|
+
endpointsMatch(
|
|
194
|
+
"https://api.rivet.dev",
|
|
195
|
+
"https://api-us-west-1.rivet.dev",
|
|
196
|
+
),
|
|
197
|
+
).toBe(true);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test("matches api-us-west-1.rivet.dev with api.rivet.dev (reverse order)", () => {
|
|
201
|
+
expect(
|
|
202
|
+
endpointsMatch(
|
|
203
|
+
"https://api-us-west-1.rivet.dev",
|
|
204
|
+
"https://api.rivet.dev",
|
|
205
|
+
),
|
|
206
|
+
).toBe(true);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test("matches api.staging.rivet.dev with api-lax.staging.rivet.dev", () => {
|
|
210
|
+
expect(
|
|
211
|
+
endpointsMatch(
|
|
212
|
+
"https://api.staging.rivet.dev",
|
|
213
|
+
"https://api-lax.staging.rivet.dev",
|
|
214
|
+
),
|
|
215
|
+
).toBe(true);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test("matches api-lax.staging.rivet.dev with api.staging.rivet.dev (reverse order)", () => {
|
|
219
|
+
expect(
|
|
220
|
+
endpointsMatch(
|
|
221
|
+
"https://api-lax.staging.rivet.dev",
|
|
222
|
+
"https://api.staging.rivet.dev",
|
|
223
|
+
),
|
|
224
|
+
).toBe(true);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
test("matches with paths", () => {
|
|
228
|
+
expect(
|
|
229
|
+
endpointsMatch(
|
|
230
|
+
"https://api.rivet.dev/v1/actors",
|
|
231
|
+
"https://api-us-west-1.rivet.dev/v1/actors",
|
|
232
|
+
),
|
|
233
|
+
).toBe(true);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test("does not match different domains", () => {
|
|
237
|
+
expect(
|
|
238
|
+
endpointsMatch(
|
|
239
|
+
"https://api.rivet.dev",
|
|
240
|
+
"https://api-us-west-1.example.com",
|
|
241
|
+
),
|
|
242
|
+
).toBe(false);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test("does not match different protocols", () => {
|
|
246
|
+
expect(
|
|
247
|
+
endpointsMatch(
|
|
248
|
+
"http://api.rivet.dev",
|
|
249
|
+
"https://api-us-west-1.rivet.dev",
|
|
250
|
+
),
|
|
251
|
+
).toBe(false);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
test("does not match different paths", () => {
|
|
255
|
+
expect(
|
|
256
|
+
endpointsMatch(
|
|
257
|
+
"https://api.rivet.dev/v1",
|
|
258
|
+
"https://api-us-west-1.rivet.dev/v2",
|
|
259
|
+
),
|
|
260
|
+
).toBe(false);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test("does not match different ports", () => {
|
|
264
|
+
expect(
|
|
265
|
+
endpointsMatch(
|
|
266
|
+
"https://api.rivet.dev:8080",
|
|
267
|
+
"https://api-us-west-1.rivet.dev:9090",
|
|
268
|
+
),
|
|
269
|
+
).toBe(false);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
test("matches with same port", () => {
|
|
273
|
+
expect(
|
|
274
|
+
endpointsMatch(
|
|
275
|
+
"https://api.rivet.dev:8080",
|
|
276
|
+
"https://api-us-west-1.rivet.dev:8080",
|
|
277
|
+
),
|
|
278
|
+
).toBe(true);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test("does not match non-api prefixed hosts", () => {
|
|
282
|
+
expect(
|
|
283
|
+
endpointsMatch(
|
|
284
|
+
"https://foo.rivet.dev",
|
|
285
|
+
"https://foo-us-west-1.rivet.dev",
|
|
286
|
+
),
|
|
287
|
+
).toBe(false);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test("does not match api.staging.rivet.dev with api-us-west-1.rivet.dev (different base domains)", () => {
|
|
291
|
+
expect(
|
|
292
|
+
endpointsMatch(
|
|
293
|
+
"https://api.staging.rivet.dev",
|
|
294
|
+
"https://api-us-west-1.rivet.dev",
|
|
295
|
+
),
|
|
296
|
+
).toBe(false);
|
|
297
|
+
});
|
|
298
|
+
});
|
|
133
299
|
});
|
package/src/serverless/router.ts
CHANGED
|
@@ -124,7 +124,8 @@ export function buildServerlessRouter(
|
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* Normalizes a URL for comparison by extracting protocol, host, port, and pathname.
|
|
127
|
-
* Normalizes 127.0.0.1
|
|
127
|
+
* Normalizes loopback addresses (127.0.0.1, 0.0.0.0, ::1) to localhost for consistent comparison.
|
|
128
|
+
* Normalizes regional endpoints (api-*.domain) to base endpoints (api.domain).
|
|
128
129
|
* Returns null if the URL is invalid.
|
|
129
130
|
*/
|
|
130
131
|
export function normalizeEndpointUrl(url: string): string | null {
|
|
@@ -133,13 +134,20 @@ export function normalizeEndpointUrl(url: string): string | null {
|
|
|
133
134
|
// Normalize pathname by removing trailing slash (except for root)
|
|
134
135
|
const pathname =
|
|
135
136
|
parsed.pathname === "/" ? "/" : parsed.pathname.replace(/\/+$/, "");
|
|
137
|
+
|
|
136
138
|
// Normalize loopback addresses to localhost
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
let hostname = isLoopbackAddress(parsed.hostname)
|
|
140
|
+
? "localhost"
|
|
141
|
+
: parsed.hostname;
|
|
142
|
+
|
|
143
|
+
// Normalize regional endpoints (api-region.domain) to base endpoints (api.domain)
|
|
144
|
+
// HACK: This is specific to Rivet Cloud and will not work for self-hosted
|
|
145
|
+
// engines with different regional endpoint naming conventions.
|
|
146
|
+
hostname = normalizeRegionalHostname(hostname);
|
|
147
|
+
|
|
141
148
|
// Reconstruct host with normalized hostname and port
|
|
142
149
|
const host = parsed.port ? `${hostname}:${parsed.port}` : hostname;
|
|
150
|
+
|
|
143
151
|
// Reconstruct normalized URL with protocol, host, and pathname
|
|
144
152
|
return `${parsed.protocol}//${host}${pathname}`;
|
|
145
153
|
} catch {
|
|
@@ -147,6 +155,39 @@ export function normalizeEndpointUrl(url: string): string | null {
|
|
|
147
155
|
}
|
|
148
156
|
}
|
|
149
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Normalizes regional hostnames (api-region.domain) to base hostnames (api.domain).
|
|
160
|
+
* Only applies to rivet.dev domains.
|
|
161
|
+
*
|
|
162
|
+
* Examples:
|
|
163
|
+
* - api-us-west-1.rivet.dev -> api.rivet.dev
|
|
164
|
+
* - api-lax.staging.rivet.dev -> api.staging.rivet.dev
|
|
165
|
+
* - api.rivet.dev -> api.rivet.dev (unchanged)
|
|
166
|
+
* - api-us-west-1.example.com -> api-us-west-1.example.com (unchanged, not rivet.dev)
|
|
167
|
+
* - foo-bar.rivet.dev -> foo-bar.rivet.dev (unchanged, not api- prefix)
|
|
168
|
+
*/
|
|
169
|
+
function normalizeRegionalHostname(hostname: string): string {
|
|
170
|
+
// Only apply to rivet.dev domains
|
|
171
|
+
if (!hostname.endsWith(".rivet.dev")) {
|
|
172
|
+
return hostname;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (!hostname.startsWith("api-")) {
|
|
176
|
+
return hostname;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Find the first dot after "api-"
|
|
180
|
+
const withoutPrefix = hostname.slice(4); // Remove "api-"
|
|
181
|
+
const firstDotIndex = withoutPrefix.indexOf(".");
|
|
182
|
+
if (firstDotIndex === -1) {
|
|
183
|
+
return hostname;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Extract the domain part and prepend "api."
|
|
187
|
+
const domain = withoutPrefix.slice(firstDotIndex + 1);
|
|
188
|
+
return `api.${domain}`;
|
|
189
|
+
}
|
|
190
|
+
|
|
150
191
|
/**
|
|
151
192
|
* Compares two endpoint URLs after normalization.
|
|
152
193
|
* Returns true if they match (same protocol, host, port, and path).
|
|
@@ -160,3 +201,15 @@ export function endpointsMatch(a: string, b: string): boolean {
|
|
|
160
201
|
}
|
|
161
202
|
return normalizedA === normalizedB;
|
|
162
203
|
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Checks if a hostname is a loopback address that should be normalized to localhost.
|
|
207
|
+
*/
|
|
208
|
+
function isLoopbackAddress(hostname: string): boolean {
|
|
209
|
+
return (
|
|
210
|
+
hostname === "127.0.0.1" ||
|
|
211
|
+
hostname === "0.0.0.0" ||
|
|
212
|
+
hostname === "::1" ||
|
|
213
|
+
hostname === "[::1]"
|
|
214
|
+
);
|
|
215
|
+
}
|
package/src/utils/env-vars.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
//
|
|
1
|
+
// This file consolidates all environment variables that affect RivetKit's behavior.
|
|
2
|
+
//
|
|
3
|
+
// IMPORTANT: When adding or modifying environment variables here, also update the
|
|
4
|
+
// documentation at: docs/general/registry-configuration.mdx
|
|
2
5
|
|
|
3
6
|
import { getEnvUniversal } from "@/utils";
|
|
4
7
|
|