@rivetkit/supabase 2.3.9 → 2.3.10
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/mod.js +79 -420
- package/dist/mod.mjs +79 -420
- package/package.json +3 -3
package/dist/mod.js
CHANGED
|
@@ -508,7 +508,7 @@ function unsupportedFeature(feature) {
|
|
|
508
508
|
);
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
511
|
+
// ../rivetkit/dist/tsup/chunk-X7XY6NCU.js
|
|
512
512
|
var import_pino = require("pino");
|
|
513
513
|
|
|
514
514
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
|
|
@@ -13181,7 +13181,7 @@ var classic_default = external_exports;
|
|
|
13181
13181
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
|
|
13182
13182
|
var v4_default = classic_default;
|
|
13183
13183
|
|
|
13184
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
13184
|
+
// ../rivetkit/dist/tsup/chunk-X7XY6NCU.js
|
|
13185
13185
|
var cbor = __toESM(require("cbor-x"), 1);
|
|
13186
13186
|
var import_invariant = __toESM(require_invariant(), 1);
|
|
13187
13187
|
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
@@ -13346,7 +13346,7 @@ function noopNext() {
|
|
|
13346
13346
|
}
|
|
13347
13347
|
var package_default = {
|
|
13348
13348
|
name: "rivetkit",
|
|
13349
|
-
version: "2.3.
|
|
13349
|
+
version: "2.3.10",
|
|
13350
13350
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13351
13351
|
license: "Apache-2.0",
|
|
13352
13352
|
keywords: [
|
|
@@ -14097,10 +14097,7 @@ function jsonStringifyCompat(input, space) {
|
|
|
14097
14097
|
return [JSON_COMPAT_BIGINT, value.toString()];
|
|
14098
14098
|
}
|
|
14099
14099
|
if (value instanceof ArrayBuffer) {
|
|
14100
|
-
return [
|
|
14101
|
-
JSON_COMPAT_ARRAY_BUFFER,
|
|
14102
|
-
base64EncodeArrayBuffer(value)
|
|
14103
|
-
];
|
|
14100
|
+
return [JSON_COMPAT_ARRAY_BUFFER, base64EncodeArrayBuffer(value)];
|
|
14104
14101
|
}
|
|
14105
14102
|
if (value instanceof Uint8Array) {
|
|
14106
14103
|
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(value)];
|
|
@@ -14639,7 +14636,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
|
|
|
14639
14636
|
};
|
|
14640
14637
|
}
|
|
14641
14638
|
|
|
14642
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14639
|
+
// ../rivetkit/dist/tsup/chunk-XSPAARQ5.js
|
|
14643
14640
|
var config2 = /* @__PURE__ */ Config({});
|
|
14644
14641
|
function readWorkflowCbor(bc) {
|
|
14645
14642
|
return readData(bc);
|
|
@@ -15512,7 +15509,7 @@ var AsyncMutex = class {
|
|
|
15512
15509
|
}
|
|
15513
15510
|
};
|
|
15514
15511
|
|
|
15515
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15512
|
+
// ../rivetkit/dist/tsup/chunk-Q5H37KNQ.js
|
|
15516
15513
|
function logger() {
|
|
15517
15514
|
return getLogger("actor-client");
|
|
15518
15515
|
}
|
|
@@ -15550,7 +15547,7 @@ async function importWebSocket() {
|
|
|
15550
15547
|
return webSocketPromise;
|
|
15551
15548
|
}
|
|
15552
15549
|
|
|
15553
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15550
|
+
// ../rivetkit/dist/tsup/chunk-DPM73GAL.js
|
|
15554
15551
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15555
15552
|
|
|
15556
15553
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -15728,7 +15725,7 @@ function createVersionedDataHandler(config3) {
|
|
|
15728
15725
|
return new VersionedDataHandler(config3);
|
|
15729
15726
|
}
|
|
15730
15727
|
|
|
15731
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15728
|
+
// ../rivetkit/dist/tsup/chunk-DPM73GAL.js
|
|
15732
15729
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
15733
15730
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
15734
15731
|
var PATH_CONNECT = "/connect";
|
|
@@ -15737,7 +15734,6 @@ var PATH_WEBSOCKET_PREFIX = "/websocket/";
|
|
|
15737
15734
|
var HEADER_ACTOR_QUERY = "x-rivet-query";
|
|
15738
15735
|
var HEADER_ENCODING = "x-rivet-encoding";
|
|
15739
15736
|
var HEADER_CONN_PARAMS = "x-rivet-conn-params";
|
|
15740
|
-
var HEADER_ORIGINAL_REQUEST_URL = "x-rivet-internal-original-request-url";
|
|
15741
15737
|
var HEADER_ACTOR_ID = "x-rivet-actor";
|
|
15742
15738
|
var HEADER_ACTOR_GENERATION = "x-rivet-actor-generation";
|
|
15743
15739
|
var HEADER_ACTOR_KEY = "x-rivet-actor-key";
|
|
@@ -17790,18 +17786,6 @@ async function checkForSchedulingError(group, code, actorId, query, driver) {
|
|
|
17790
17786
|
}
|
|
17791
17787
|
return null;
|
|
17792
17788
|
}
|
|
17793
|
-
function isUrlLike(value) {
|
|
17794
|
-
return typeof value === "object" && value !== null && typeof value.href === "string" && typeof value.pathname === "string" && typeof value.search === "string";
|
|
17795
|
-
}
|
|
17796
|
-
function isRequestLike(value) {
|
|
17797
|
-
return typeof value === "object" && value !== null && typeof value.url === "string" && typeof value.method === "string" && isHeadersLike(value.headers);
|
|
17798
|
-
}
|
|
17799
|
-
function isResponseLike(value) {
|
|
17800
|
-
return typeof value === "object" && value !== null && typeof value.status === "number" && isHeadersLike(value.headers) && typeof value.arrayBuffer === "function";
|
|
17801
|
-
}
|
|
17802
|
-
function isHeadersLike(value) {
|
|
17803
|
-
return typeof value === "object" && value !== null && typeof value.entries === "function";
|
|
17804
|
-
}
|
|
17805
17789
|
function* walkErrorChain(error46, maxDepth = 8) {
|
|
17806
17790
|
let current = error46;
|
|
17807
17791
|
let depth = 0;
|
|
@@ -18227,17 +18211,14 @@ function createQueueSender(senderOptions) {
|
|
|
18227
18211
|
}
|
|
18228
18212
|
async function rawHttpFetch(driver, target, params, input, init, options = {}) {
|
|
18229
18213
|
let path2;
|
|
18230
|
-
let originalUrl;
|
|
18231
18214
|
let mergedInit = init || {};
|
|
18232
18215
|
if (typeof input === "string") {
|
|
18233
18216
|
path2 = input;
|
|
18234
|
-
} else if (
|
|
18217
|
+
} else if (input instanceof URL) {
|
|
18235
18218
|
path2 = input.pathname + input.search;
|
|
18236
|
-
|
|
18237
|
-
} else if (isRequestLike(input)) {
|
|
18219
|
+
} else if (input instanceof Request) {
|
|
18238
18220
|
const url2 = new URL(input.url);
|
|
18239
18221
|
path2 = url2.pathname + url2.search;
|
|
18240
|
-
originalUrl = url2.toString();
|
|
18241
18222
|
const requestHeaders = new Headers(input.headers);
|
|
18242
18223
|
const initHeaders = new Headers((init == null ? void 0 : init.headers) || {});
|
|
18243
18224
|
const mergedHeaders = new Headers(requestHeaders);
|
|
@@ -18279,10 +18260,6 @@ async function rawHttpFetch(driver, target, params, input, init, options = {}) {
|
|
|
18279
18260
|
const normalizedPath = path2.startsWith("/") ? path2.slice(1) : path2;
|
|
18280
18261
|
const url2 = new URL(`http://actor/request/${normalizedPath}`);
|
|
18281
18262
|
const proxyRequestHeaders = new Headers(mergedInit.headers);
|
|
18282
|
-
proxyRequestHeaders.delete(HEADER_ORIGINAL_REQUEST_URL);
|
|
18283
|
-
if (originalUrl) {
|
|
18284
|
-
proxyRequestHeaders.set(HEADER_ORIGINAL_REQUEST_URL, originalUrl);
|
|
18285
|
-
}
|
|
18286
18263
|
if (params) {
|
|
18287
18264
|
proxyRequestHeaders.set(HEADER_CONN_PARAMS, JSON.stringify(params));
|
|
18288
18265
|
}
|
|
@@ -18751,7 +18728,6 @@ var ActorHandleRaw = class {
|
|
|
18751
18728
|
async #fetchWithResolvedActor(input, init) {
|
|
18752
18729
|
const maxAttempts = this.#getDynamicQueryMaxAttempts();
|
|
18753
18730
|
let useQueryTarget = false;
|
|
18754
|
-
const retryableRequest = isRequestLike(input) ? input.clone() : void 0;
|
|
18755
18731
|
const { skipReadyWait, ...requestInit } = init ?? {};
|
|
18756
18732
|
const gatewayOptions = resolveActorGatewayOptions(
|
|
18757
18733
|
this.#gatewayOptions,
|
|
@@ -18771,7 +18747,7 @@ var ActorHandleRaw = class {
|
|
|
18771
18747
|
this.#driver,
|
|
18772
18748
|
target,
|
|
18773
18749
|
this.#params,
|
|
18774
|
-
|
|
18750
|
+
input,
|
|
18775
18751
|
requestInit,
|
|
18776
18752
|
gatewayOptions
|
|
18777
18753
|
);
|
|
@@ -20504,19 +20480,23 @@ async function sendHttpRequestToGateway(runConfig, gatewayUrl, actorRequest, opt
|
|
|
20504
20480
|
if (actorRequest.bodyUsed) {
|
|
20505
20481
|
throw new Error("Request body has already been consumed");
|
|
20506
20482
|
}
|
|
20507
|
-
|
|
20508
|
-
|
|
20483
|
+
const reqBody = await actorRequest.arrayBuffer();
|
|
20484
|
+
if (reqBody.byteLength !== 0) {
|
|
20485
|
+
bodyToSend = reqBody;
|
|
20509
20486
|
guardHeaders.delete("transfer-encoding");
|
|
20510
20487
|
guardHeaders.delete("content-length");
|
|
20511
20488
|
}
|
|
20512
20489
|
}
|
|
20513
|
-
|
|
20490
|
+
const guardRequest = new Request(gatewayUrl, {
|
|
20514
20491
|
method: actorRequest.method,
|
|
20515
20492
|
headers: guardHeaders,
|
|
20516
20493
|
body: bodyToSend,
|
|
20517
|
-
signal: actorRequest.signal
|
|
20518
|
-
...bodyToSend ? { duplex: "half" } : {}
|
|
20494
|
+
signal: actorRequest.signal
|
|
20519
20495
|
});
|
|
20496
|
+
return mutableResponse(await fetch(guardRequest));
|
|
20497
|
+
}
|
|
20498
|
+
function mutableResponse(fetchRes) {
|
|
20499
|
+
return new Response(fetchRes.body, fetchRes);
|
|
20520
20500
|
}
|
|
20521
20501
|
function buildGuardHeaders(runConfig, actorRequest, options) {
|
|
20522
20502
|
const headers = new Headers();
|
|
@@ -23991,36 +23971,6 @@ function toNapiSqlBatchStatement(statement) {
|
|
|
23991
23971
|
function toNapiBuffer(value) {
|
|
23992
23972
|
return Buffer.from(value);
|
|
23993
23973
|
}
|
|
23994
|
-
function toNapiApplication(application) {
|
|
23995
|
-
return async (error46, request) => {
|
|
23996
|
-
if (error46) throw error46;
|
|
23997
|
-
if (!request) {
|
|
23998
|
-
throw new Error("application fetch callback received no request");
|
|
23999
|
-
}
|
|
24000
|
-
const response = await application(
|
|
24001
|
-
{
|
|
24002
|
-
...request,
|
|
24003
|
-
body: new Uint8Array(request.body),
|
|
24004
|
-
cancelToken: request.cancelToken
|
|
24005
|
-
},
|
|
24006
|
-
request.responseBodyStream ? fromNapiHttpResponseBodyStream(
|
|
24007
|
-
request.responseBodyStream
|
|
24008
|
-
) : void 0
|
|
24009
|
-
);
|
|
24010
|
-
return {
|
|
24011
|
-
...response,
|
|
24012
|
-
body: response.body === void 0 ? void 0 : toNapiBuffer(response.body)
|
|
24013
|
-
};
|
|
24014
|
-
};
|
|
24015
|
-
}
|
|
24016
|
-
function fromNapiHttpResponseBodyStream(stream) {
|
|
24017
|
-
return {
|
|
24018
|
-
cancelled: () => stream.cancelled(),
|
|
24019
|
-
write: (chunk) => stream.write(Buffer.from(chunk)),
|
|
24020
|
-
end: () => stream.end(),
|
|
24021
|
-
error: (message) => stream.error(message)
|
|
24022
|
-
};
|
|
24023
|
-
}
|
|
24024
23974
|
function toNapiHttpRequest(request) {
|
|
24025
23975
|
if (!request) {
|
|
24026
23976
|
return request;
|
|
@@ -24127,25 +24077,12 @@ var NapiCoreRuntime = class {
|
|
|
24127
24077
|
);
|
|
24128
24078
|
}
|
|
24129
24079
|
async serveListener(registry2, listener, config3) {
|
|
24130
|
-
const application = listener.application ? toNapiApplication(listener.application) : void 0;
|
|
24131
24080
|
await asNativeRegistry(registry2).serveListener(
|
|
24132
24081
|
{
|
|
24133
24082
|
port: listener.port,
|
|
24134
24083
|
host: listener.host,
|
|
24135
24084
|
publicDir: listener.publicDir
|
|
24136
24085
|
},
|
|
24137
|
-
config3,
|
|
24138
|
-
application
|
|
24139
|
-
);
|
|
24140
|
-
}
|
|
24141
|
-
async serveApplicationListener(registry2, listener, config3) {
|
|
24142
|
-
await asNativeRegistry(registry2).serveApplicationListener(
|
|
24143
|
-
{
|
|
24144
|
-
port: listener.port,
|
|
24145
|
-
host: listener.host,
|
|
24146
|
-
publicDir: listener.publicDir
|
|
24147
|
-
},
|
|
24148
|
-
toNapiApplication(listener.application),
|
|
24149
24086
|
config3
|
|
24150
24087
|
);
|
|
24151
24088
|
}
|
|
@@ -24532,135 +24469,6 @@ async function loadNapiRuntime() {
|
|
|
24532
24469
|
runtime: new NapiCoreRuntime(bindings)
|
|
24533
24470
|
};
|
|
24534
24471
|
}
|
|
24535
|
-
var HTTP_BODY_CHUNK_SIZE = 64 * 1024;
|
|
24536
|
-
function runtimeBytesToArrayBuffer(value) {
|
|
24537
|
-
return value.buffer.slice(
|
|
24538
|
-
value.byteOffset,
|
|
24539
|
-
value.byteOffset + value.byteLength
|
|
24540
|
-
);
|
|
24541
|
-
}
|
|
24542
|
-
function buildNativeHttpRequest(init) {
|
|
24543
|
-
var _a2;
|
|
24544
|
-
const headers = new Headers(init.headers);
|
|
24545
|
-
const originalUrl = headers.get(HEADER_ORIGINAL_REQUEST_URL);
|
|
24546
|
-
headers.delete(HEADER_ORIGINAL_REQUEST_URL);
|
|
24547
|
-
const url2 = originalUrl ?? (init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString());
|
|
24548
|
-
const method2 = init.method.toUpperCase();
|
|
24549
|
-
const bodyForbidden = method2 === "GET" || method2 === "HEAD";
|
|
24550
|
-
const body = bodyForbidden ? void 0 : init.bodyStream ? new ReadableStream({
|
|
24551
|
-
async pull(controller) {
|
|
24552
|
-
var _a22, _b;
|
|
24553
|
-
try {
|
|
24554
|
-
if (init.body && init.body.length > 0) {
|
|
24555
|
-
controller.enqueue(new Uint8Array(init.body));
|
|
24556
|
-
init.body = void 0;
|
|
24557
|
-
return;
|
|
24558
|
-
}
|
|
24559
|
-
const chunk = await ((_a22 = init.bodyStream) == null ? void 0 : _a22.read());
|
|
24560
|
-
if (!chunk) {
|
|
24561
|
-
controller.close();
|
|
24562
|
-
} else {
|
|
24563
|
-
controller.enqueue(new Uint8Array(chunk));
|
|
24564
|
-
}
|
|
24565
|
-
} catch (error46) {
|
|
24566
|
-
(_b = init.abortController) == null ? void 0 : _b.abort(error46);
|
|
24567
|
-
controller.error(error46);
|
|
24568
|
-
}
|
|
24569
|
-
},
|
|
24570
|
-
async cancel() {
|
|
24571
|
-
var _a22;
|
|
24572
|
-
await ((_a22 = init.bodyStream) == null ? void 0 : _a22.cancel());
|
|
24573
|
-
}
|
|
24574
|
-
}) : init.body && init.body.length > 0 ? runtimeBytesToArrayBuffer(init.body) : void 0;
|
|
24575
|
-
const streamInit = init.bodyStream && !bodyForbidden ? { duplex: "half" } : {};
|
|
24576
|
-
return new Request(url2, {
|
|
24577
|
-
method: method2,
|
|
24578
|
-
headers,
|
|
24579
|
-
body,
|
|
24580
|
-
signal: ((_a2 = init.abortController) == null ? void 0 : _a2.signal) ?? init.signal,
|
|
24581
|
-
...streamInit
|
|
24582
|
-
});
|
|
24583
|
-
}
|
|
24584
|
-
async function cancelNativeHttpRequestBody(bodyStream) {
|
|
24585
|
-
await (bodyStream == null ? void 0 : bodyStream.cancel());
|
|
24586
|
-
}
|
|
24587
|
-
async function writeResponseChunk(stream, chunk) {
|
|
24588
|
-
for (let offset = 0; offset < chunk.byteLength; offset += HTTP_BODY_CHUNK_SIZE) {
|
|
24589
|
-
await stream.write(
|
|
24590
|
-
chunk.subarray(offset, offset + HTTP_BODY_CHUNK_SIZE)
|
|
24591
|
-
);
|
|
24592
|
-
}
|
|
24593
|
-
}
|
|
24594
|
-
async function pumpResponseBody(reader, stream) {
|
|
24595
|
-
var _a2;
|
|
24596
|
-
const cancelled = stream.cancelled().then(() => ({ cancelled: true }));
|
|
24597
|
-
try {
|
|
24598
|
-
for (; ; ) {
|
|
24599
|
-
const read = reader.read().then((next2) => ({ cancelled: false, next: next2 }));
|
|
24600
|
-
const result = await Promise.race([read, cancelled]);
|
|
24601
|
-
if (result.cancelled) {
|
|
24602
|
-
await reader.cancel(
|
|
24603
|
-
new Error("native http response stream receiver dropped")
|
|
24604
|
-
);
|
|
24605
|
-
return;
|
|
24606
|
-
}
|
|
24607
|
-
const { next } = result;
|
|
24608
|
-
if (next.done) {
|
|
24609
|
-
await stream.end();
|
|
24610
|
-
return;
|
|
24611
|
-
}
|
|
24612
|
-
if ((_a2 = next.value) == null ? void 0 : _a2.byteLength) {
|
|
24613
|
-
await writeResponseChunk(stream, next.value);
|
|
24614
|
-
}
|
|
24615
|
-
}
|
|
24616
|
-
} catch (error46) {
|
|
24617
|
-
try {
|
|
24618
|
-
await stream.error(stringifyError(error46));
|
|
24619
|
-
} catch (streamError) {
|
|
24620
|
-
logger22().debug({
|
|
24621
|
-
msg: "failed to report native http response stream error",
|
|
24622
|
-
error: streamError
|
|
24623
|
-
});
|
|
24624
|
-
}
|
|
24625
|
-
try {
|
|
24626
|
-
await reader.cancel(error46);
|
|
24627
|
-
} catch {
|
|
24628
|
-
}
|
|
24629
|
-
} finally {
|
|
24630
|
-
reader.releaseLock();
|
|
24631
|
-
}
|
|
24632
|
-
}
|
|
24633
|
-
async function convertNativeHttpResponse(response, responseBodyStream) {
|
|
24634
|
-
const headers = Object.fromEntries(response.headers.entries());
|
|
24635
|
-
if (!response.body) {
|
|
24636
|
-
return {
|
|
24637
|
-
response: {
|
|
24638
|
-
status: response.status,
|
|
24639
|
-
headers,
|
|
24640
|
-
body: new Uint8Array()
|
|
24641
|
-
}
|
|
24642
|
-
};
|
|
24643
|
-
}
|
|
24644
|
-
if (responseBodyStream) {
|
|
24645
|
-
const reader = response.body.getReader();
|
|
24646
|
-
const bodyCompletion = pumpResponseBody(reader, responseBodyStream);
|
|
24647
|
-
return {
|
|
24648
|
-
response: {
|
|
24649
|
-
status: response.status,
|
|
24650
|
-
headers,
|
|
24651
|
-
stream: true
|
|
24652
|
-
},
|
|
24653
|
-
bodyCompletion
|
|
24654
|
-
};
|
|
24655
|
-
}
|
|
24656
|
-
return {
|
|
24657
|
-
response: {
|
|
24658
|
-
status: response.status,
|
|
24659
|
-
headers,
|
|
24660
|
-
body: new Uint8Array(await response.arrayBuffer())
|
|
24661
|
-
}
|
|
24662
|
-
};
|
|
24663
|
-
}
|
|
24664
24472
|
var CONN_PARAMS_KEY = "__conn_params__";
|
|
24665
24473
|
function validateActionArgs(schemas, name, args) {
|
|
24666
24474
|
if (!(schemas == null ? void 0 : schemas[name])) {
|
|
@@ -24930,11 +24738,6 @@ var WasmCoreRuntime = class {
|
|
|
24930
24738
|
"registry.listen() is not supported on the wasm runtime; use registry.serve() and mount the handler in your platform's HTTP server instead"
|
|
24931
24739
|
);
|
|
24932
24740
|
}
|
|
24933
|
-
async serveApplicationListener(_registry, _listener, _config) {
|
|
24934
|
-
throw new Error(
|
|
24935
|
-
"registry.listen() is not supported on the wasm runtime; use an application-owned HTTP server instead"
|
|
24936
|
-
);
|
|
24937
|
-
}
|
|
24938
24741
|
createActorFactory(callbacks, config3) {
|
|
24939
24742
|
return callWasmSync(
|
|
24940
24743
|
() => asActorFactoryHandle2(
|
|
@@ -25787,7 +25590,7 @@ function toRuntimeBytes(value) {
|
|
|
25787
25590
|
function arrayBufferViewToRuntimeBytes(value) {
|
|
25788
25591
|
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
25789
25592
|
}
|
|
25790
|
-
function
|
|
25593
|
+
function runtimeBytesToArrayBuffer(value) {
|
|
25791
25594
|
return value.buffer.slice(
|
|
25792
25595
|
value.byteOffset,
|
|
25793
25596
|
value.byteOffset + value.byteLength
|
|
@@ -26117,6 +25920,24 @@ function decodeArgs(value) {
|
|
|
26117
25920
|
const decoded = decodeValue(value);
|
|
26118
25921
|
return normalizeArgs(decoded);
|
|
26119
25922
|
}
|
|
25923
|
+
function buildRequest(init) {
|
|
25924
|
+
const url2 = init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString();
|
|
25925
|
+
const body = init.body && init.body.length > 0 ? runtimeBytesToArrayBuffer(init.body) : void 0;
|
|
25926
|
+
return new Request(url2, {
|
|
25927
|
+
method: init.method,
|
|
25928
|
+
headers: init.headers,
|
|
25929
|
+
body
|
|
25930
|
+
});
|
|
25931
|
+
}
|
|
25932
|
+
async function toRuntimeHttpResponse(response) {
|
|
25933
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
25934
|
+
const body = new Uint8Array(await response.arrayBuffer());
|
|
25935
|
+
return {
|
|
25936
|
+
status: response.status,
|
|
25937
|
+
headers,
|
|
25938
|
+
body
|
|
25939
|
+
};
|
|
25940
|
+
}
|
|
26120
25941
|
function toActorKey(segments) {
|
|
26121
25942
|
return segments.map(
|
|
26122
25943
|
(segment) => segment.kind === "number" ? String(segment.numberValue ?? 0) : segment.stringValue ?? ""
|
|
@@ -26781,7 +26602,7 @@ var NativeWebSocketAdapter = class {
|
|
|
26781
26602
|
this.#runtime.webSocketSetEventCallback(this.#ws, (event2) => {
|
|
26782
26603
|
if (event2.kind === "message") {
|
|
26783
26604
|
this.#virtual.triggerMessage(
|
|
26784
|
-
event2.binary ?
|
|
26605
|
+
event2.binary ? runtimeBytesToArrayBuffer(event2.data) : event2.data,
|
|
26785
26606
|
event2.messageIndex
|
|
26786
26607
|
);
|
|
26787
26608
|
return;
|
|
@@ -28013,14 +27834,12 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28013
27834
|
onStateChange,
|
|
28014
27835
|
cancelToken
|
|
28015
27836
|
);
|
|
28016
|
-
const maybeHandleNativeInspectorRequest = async (ctx,
|
|
27837
|
+
const maybeHandleNativeInspectorRequest = async (ctx, _rawRequest, jsRequest) => {
|
|
28017
27838
|
var _a22, _b, _c, _d;
|
|
28018
|
-
const
|
|
28019
|
-
const url2 = new URL(rawUrl);
|
|
27839
|
+
const url2 = new URL(jsRequest.url);
|
|
28020
27840
|
if (!url2.pathname.startsWith("/inspector/")) {
|
|
28021
27841
|
return void 0;
|
|
28022
27842
|
}
|
|
28023
|
-
const jsRequest = buildNativeHttpRequest(rawRequest);
|
|
28024
27843
|
const jsonResponse = (body, init) => new Response(JSON.stringify(body), {
|
|
28025
27844
|
status: (init == null ? void 0 : init.status) ?? 200,
|
|
28026
27845
|
headers: {
|
|
@@ -28551,7 +28370,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28551
28370
|
);
|
|
28552
28371
|
const actorCtx = makeActorCtx(
|
|
28553
28372
|
ctx,
|
|
28554
|
-
request ?
|
|
28373
|
+
request ? buildRequest(request) : void 0
|
|
28555
28374
|
);
|
|
28556
28375
|
try {
|
|
28557
28376
|
await config3.onBeforeConnect(
|
|
@@ -28571,7 +28390,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28571
28390
|
const { ctx, conn, params, request } = unwrapTsfnPayload(error46, payload);
|
|
28572
28391
|
const actorCtx = makeActorCtx(
|
|
28573
28392
|
ctx,
|
|
28574
|
-
request ?
|
|
28393
|
+
request ? buildRequest(request) : void 0
|
|
28575
28394
|
);
|
|
28576
28395
|
const connAdapter = new NativeConnAdapter(
|
|
28577
28396
|
runtime,
|
|
@@ -28608,7 +28427,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28608
28427
|
);
|
|
28609
28428
|
const actorCtx = makeActorCtx(
|
|
28610
28429
|
ctx,
|
|
28611
|
-
request ?
|
|
28430
|
+
request ? buildRequest(request) : void 0
|
|
28612
28431
|
);
|
|
28613
28432
|
const connAdapter = new NativeConnAdapter(
|
|
28614
28433
|
runtime,
|
|
@@ -28713,45 +28532,27 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28713
28532
|
onRequest: wrapNativeCallback(
|
|
28714
28533
|
async (error46, payload) => {
|
|
28715
28534
|
try {
|
|
28716
|
-
const { ctx, request, cancelToken
|
|
28717
|
-
|
|
28535
|
+
const { ctx, request, cancelToken } = unwrapTsfnPayload(
|
|
28536
|
+
error46,
|
|
28537
|
+
payload
|
|
28538
|
+
);
|
|
28539
|
+
const jsRequest = buildRequest(request);
|
|
28540
|
+
const inspectorResponse = await maybeHandleNativeInspectorRequest(
|
|
28541
|
+
ctx,
|
|
28542
|
+
request,
|
|
28543
|
+
jsRequest
|
|
28544
|
+
);
|
|
28718
28545
|
if (inspectorResponse) {
|
|
28719
|
-
await
|
|
28720
|
-
return (await convertNativeHttpResponse(
|
|
28721
|
-
inspectorResponse,
|
|
28722
|
-
responseBodyStream
|
|
28723
|
-
)).response;
|
|
28546
|
+
return await toRuntimeHttpResponse(inspectorResponse);
|
|
28724
28547
|
}
|
|
28725
28548
|
if (typeof config3.onRequest !== "function") {
|
|
28726
|
-
await
|
|
28727
|
-
|
|
28728
|
-
|
|
28729
|
-
responseBodyStream
|
|
28730
|
-
)).response;
|
|
28549
|
+
return await toRuntimeHttpResponse(
|
|
28550
|
+
new Response(null, { status: 404 })
|
|
28551
|
+
);
|
|
28731
28552
|
}
|
|
28732
|
-
const
|
|
28733
|
-
const handlerRequest = buildNativeHttpRequest({
|
|
28734
|
-
...request,
|
|
28735
|
-
abortController: requestAbortController
|
|
28736
|
-
});
|
|
28737
|
-
const rawConnParams = handlerRequest.headers.get(HEADER_CONN_PARAMS);
|
|
28553
|
+
const rawConnParams = jsRequest.headers.get(HEADER_CONN_PARAMS);
|
|
28738
28554
|
let requestCtx;
|
|
28739
28555
|
let conn;
|
|
28740
|
-
let removeRequestAbortListener;
|
|
28741
|
-
let cleanupDeferredToBody = false;
|
|
28742
|
-
let cleanedUp = false;
|
|
28743
|
-
const cleanupRequest = async () => {
|
|
28744
|
-
if (cleanedUp) return;
|
|
28745
|
-
cleanedUp = true;
|
|
28746
|
-
removeRequestAbortListener == null ? void 0 : removeRequestAbortListener();
|
|
28747
|
-
try {
|
|
28748
|
-
await (requestCtx == null ? void 0 : requestCtx.dispose());
|
|
28749
|
-
} finally {
|
|
28750
|
-
if (conn) {
|
|
28751
|
-
await runtime.connDisconnect(conn);
|
|
28752
|
-
}
|
|
28753
|
-
}
|
|
28754
|
-
};
|
|
28755
28556
|
try {
|
|
28756
28557
|
const connParams = validateConnParams(
|
|
28757
28558
|
schemaConfig.connParamsSchema,
|
|
@@ -28767,56 +28568,23 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28767
28568
|
requestCtx = makeConnCtx(
|
|
28768
28569
|
ctx,
|
|
28769
28570
|
conn,
|
|
28770
|
-
|
|
28571
|
+
jsRequest,
|
|
28771
28572
|
cancelToken
|
|
28772
28573
|
);
|
|
28773
|
-
const ctxAbortSignal = requestCtx.abortSignal;
|
|
28774
|
-
const abortRequest = () => requestAbortController.abort(ctxAbortSignal.reason);
|
|
28775
|
-
if (ctxAbortSignal.aborted) {
|
|
28776
|
-
abortRequest();
|
|
28777
|
-
} else {
|
|
28778
|
-
ctxAbortSignal.addEventListener(
|
|
28779
|
-
"abort",
|
|
28780
|
-
abortRequest,
|
|
28781
|
-
{ once: true }
|
|
28782
|
-
);
|
|
28783
|
-
removeRequestAbortListener = () => ctxAbortSignal.removeEventListener(
|
|
28784
|
-
"abort",
|
|
28785
|
-
abortRequest
|
|
28786
|
-
);
|
|
28787
|
-
}
|
|
28788
28574
|
const response = await config3.onRequest(
|
|
28789
28575
|
requestCtx,
|
|
28790
|
-
|
|
28576
|
+
jsRequest
|
|
28791
28577
|
);
|
|
28792
|
-
if (!
|
|
28578
|
+
if (!(response instanceof Response)) {
|
|
28793
28579
|
throw new Error(
|
|
28794
28580
|
"onRequest handler must return a Response"
|
|
28795
28581
|
);
|
|
28796
28582
|
}
|
|
28797
|
-
|
|
28798
|
-
response,
|
|
28799
|
-
responseBodyStream
|
|
28800
|
-
);
|
|
28801
|
-
if (conversion.bodyCompletion) {
|
|
28802
|
-
cleanupDeferredToBody = true;
|
|
28803
|
-
void conversion.bodyCompletion.then(cleanupRequest).catch((cleanupError) => {
|
|
28804
|
-
logger22().error({
|
|
28805
|
-
msg: "failed to clean up native streaming http request",
|
|
28806
|
-
error: cleanupError
|
|
28807
|
-
});
|
|
28808
|
-
});
|
|
28809
|
-
}
|
|
28810
|
-
return conversion.response;
|
|
28583
|
+
return await toRuntimeHttpResponse(response);
|
|
28811
28584
|
} finally {
|
|
28812
|
-
|
|
28813
|
-
|
|
28814
|
-
|
|
28815
|
-
);
|
|
28816
|
-
} finally {
|
|
28817
|
-
if (!cleanupDeferredToBody) {
|
|
28818
|
-
await cleanupRequest();
|
|
28819
|
-
}
|
|
28585
|
+
await (requestCtx == null ? void 0 : requestCtx.dispose());
|
|
28586
|
+
if (conn) {
|
|
28587
|
+
await runtime.connDisconnect(conn);
|
|
28820
28588
|
}
|
|
28821
28589
|
}
|
|
28822
28590
|
} catch (error210) {
|
|
@@ -28831,7 +28599,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28831
28599
|
onWebSocket: typeof config3.onWebSocket === "function" ? wrapNativeCallback(
|
|
28832
28600
|
async (error46, payload) => {
|
|
28833
28601
|
const { ctx, conn, ws, request } = unwrapTsfnPayload(error46, payload);
|
|
28834
|
-
const jsRequest = request ?
|
|
28602
|
+
const jsRequest = request ? buildRequest(request) : void 0;
|
|
28835
28603
|
const actorCtx = makeConnCtx(ctx, conn, jsRequest);
|
|
28836
28604
|
try {
|
|
28837
28605
|
await config3.onWebSocket(
|
|
@@ -28928,7 +28696,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28928
28696
|
timeoutMs,
|
|
28929
28697
|
cancelToken
|
|
28930
28698
|
} = unwrapTsfnPayload(error46, payload);
|
|
28931
|
-
const jsRequest =
|
|
28699
|
+
const jsRequest = buildRequest(request);
|
|
28932
28700
|
const actorCtx = withConnContext(
|
|
28933
28701
|
runtime,
|
|
28934
28702
|
ctx,
|
|
@@ -29077,54 +28845,6 @@ function finishShutdownSignal(signal) {
|
|
|
29077
28845
|
}
|
|
29078
28846
|
process.kill(process.pid, signal);
|
|
29079
28847
|
}
|
|
29080
|
-
function createApplicationFetch(application, runtime) {
|
|
29081
|
-
return async (request, responseBodyStream) => {
|
|
29082
|
-
const method2 = request.method.toUpperCase();
|
|
29083
|
-
const body = method2 === "GET" || method2 === "HEAD" || request.body.length === 0 ? void 0 : Uint8Array.from(request.body).buffer;
|
|
29084
|
-
const abortController = new AbortController();
|
|
29085
|
-
if (request.cancelToken) {
|
|
29086
|
-
if (runtime.cancellationTokenAborted(request.cancelToken)) {
|
|
29087
|
-
abortController.abort();
|
|
29088
|
-
} else {
|
|
29089
|
-
runtime.onCancellationTokenCancelled(
|
|
29090
|
-
request.cancelToken,
|
|
29091
|
-
() => abortController.abort()
|
|
29092
|
-
);
|
|
29093
|
-
}
|
|
29094
|
-
}
|
|
29095
|
-
const response = await application.fetch(
|
|
29096
|
-
new Request(request.url, {
|
|
29097
|
-
method: method2,
|
|
29098
|
-
headers: request.headers,
|
|
29099
|
-
body,
|
|
29100
|
-
signal: abortController.signal
|
|
29101
|
-
})
|
|
29102
|
-
);
|
|
29103
|
-
if (!isResponseLike(response)) {
|
|
29104
|
-
throw new TypeError(
|
|
29105
|
-
"registry.listen() application fetch must return a Response"
|
|
29106
|
-
);
|
|
29107
|
-
}
|
|
29108
|
-
const conversion = await convertNativeHttpResponse(
|
|
29109
|
-
response,
|
|
29110
|
-
responseBodyStream
|
|
29111
|
-
);
|
|
29112
|
-
if (conversion.bodyCompletion) {
|
|
29113
|
-
void conversion.bodyCompletion.catch((error46) => {
|
|
29114
|
-
logger22().error({
|
|
29115
|
-
msg: "application response stream failed",
|
|
29116
|
-
error: error46
|
|
29117
|
-
});
|
|
29118
|
-
});
|
|
29119
|
-
}
|
|
29120
|
-
return {
|
|
29121
|
-
status: conversion.response.status ?? response.status,
|
|
29122
|
-
headers: conversion.response.headers ?? Object.fromEntries(response.headers.entries()),
|
|
29123
|
-
body: conversion.response.body,
|
|
29124
|
-
stream: conversion.response.stream
|
|
29125
|
-
};
|
|
29126
|
-
};
|
|
29127
|
-
}
|
|
29128
28848
|
var Registry = class {
|
|
29129
28849
|
#config;
|
|
29130
28850
|
#buildConfiguredRegistry;
|
|
@@ -29140,7 +28860,6 @@ var Registry = class {
|
|
|
29140
28860
|
#runtimeReadyPromise;
|
|
29141
28861
|
#runtimeServeConfiguredPromise;
|
|
29142
28862
|
#runtimeServerlessPromise;
|
|
29143
|
-
#applicationListenerPromise;
|
|
29144
28863
|
#configureServerlessPoolPromise;
|
|
29145
28864
|
#welcomePrinted = false;
|
|
29146
28865
|
#shutdownInstalled = false;
|
|
@@ -29366,67 +29085,18 @@ var Registry = class {
|
|
|
29366
29085
|
* @param opts.host Address to bind. Defaults to `0.0.0.0`.
|
|
29367
29086
|
* @param opts.publicDir If set, serves static files from this directory
|
|
29368
29087
|
* as a fallback below the framework routes.
|
|
29369
|
-
* @param opts.application If set, handles requests that do not match a
|
|
29370
|
-
* framework route.
|
|
29371
29088
|
*
|
|
29372
29089
|
* @example
|
|
29373
29090
|
* ```ts
|
|
29374
29091
|
* await registry.listen();
|
|
29375
|
-
* await registry.listen({
|
|
29092
|
+
* await registry.listen({ port: 8080, publicDir: "./public" });
|
|
29376
29093
|
* ```
|
|
29377
29094
|
*/
|
|
29378
29095
|
async listen(opts = {}) {
|
|
29379
29096
|
const port = opts.port ?? parsePortEnv(process.env.RIVET_PORT) ?? 3e3;
|
|
29380
29097
|
const publicDir = opts.publicDir ?? getRivetkitPublicDir();
|
|
29381
29098
|
const config3 = this.parseConfig();
|
|
29382
|
-
|
|
29383
|
-
if (config3.runtime === "wasm") {
|
|
29384
|
-
throw new Error(
|
|
29385
|
-
"registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
|
|
29386
|
-
);
|
|
29387
|
-
}
|
|
29388
|
-
this.#installSignalHandlers(config3);
|
|
29389
|
-
this.#printWelcome(config3, "serverful", {
|
|
29390
|
-
port,
|
|
29391
|
-
host: opts.host,
|
|
29392
|
-
publicDir
|
|
29393
|
-
});
|
|
29394
|
-
this.#startEnvoy(config3, true);
|
|
29395
|
-
const readyPromise = this.startAndWait();
|
|
29396
|
-
const configuredRegistryPromise2 = this.#runtimeServeConfiguredPromise;
|
|
29397
|
-
if (!configuredRegistryPromise2) {
|
|
29398
|
-
throw new Error("registry envoy startup did not initialize");
|
|
29399
|
-
}
|
|
29400
|
-
const { runtime: runtime2, registry: registry22, serveConfig: serveConfig2 } = await configuredRegistryPromise2;
|
|
29401
|
-
const application2 = createApplicationFetch(
|
|
29402
|
-
opts.application,
|
|
29403
|
-
runtime2
|
|
29404
|
-
);
|
|
29405
|
-
await readyPromise;
|
|
29406
|
-
const listenerPromise = runtime2.serveApplicationListener(
|
|
29407
|
-
registry22,
|
|
29408
|
-
{
|
|
29409
|
-
port,
|
|
29410
|
-
host: opts.host,
|
|
29411
|
-
publicDir,
|
|
29412
|
-
application: application2
|
|
29413
|
-
},
|
|
29414
|
-
serveConfig2
|
|
29415
|
-
);
|
|
29416
|
-
this.#applicationListenerPromise = listenerPromise;
|
|
29417
|
-
const serveLifecyclePromise = this.#runtimeServeLifecyclePromise;
|
|
29418
|
-
if (!serveLifecyclePromise) {
|
|
29419
|
-
throw new Error(
|
|
29420
|
-
"registry envoy serve lifecycle did not initialize"
|
|
29421
|
-
);
|
|
29422
|
-
}
|
|
29423
|
-
await Promise.all([
|
|
29424
|
-
listenerPromise,
|
|
29425
|
-
serveLifecyclePromise
|
|
29426
|
-
]);
|
|
29427
|
-
return;
|
|
29428
|
-
}
|
|
29429
|
-
const configuredRegistryPromise = this.#buildConfiguredRegistry(config3);
|
|
29099
|
+
const configuredRegistryPromise = buildConfiguredRegistry(config3);
|
|
29430
29100
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
29431
29101
|
this.#runtimeServerlessPromise = configuredRegistryPromise;
|
|
29432
29102
|
this.#installSignalHandlers(config3);
|
|
@@ -29437,15 +29107,9 @@ var Registry = class {
|
|
|
29437
29107
|
});
|
|
29438
29108
|
this.#ensureServerlessPoolConfigured(config3);
|
|
29439
29109
|
const { runtime, registry: registry2, serveConfig } = await configuredRegistryPromise;
|
|
29440
|
-
const application = opts.application ? createApplicationFetch(opts.application, runtime) : void 0;
|
|
29441
29110
|
await runtime.serveListener(
|
|
29442
29111
|
registry2,
|
|
29443
|
-
{
|
|
29444
|
-
port,
|
|
29445
|
-
host: opts.host,
|
|
29446
|
-
publicDir,
|
|
29447
|
-
application
|
|
29448
|
-
},
|
|
29112
|
+
{ port, host: opts.host, publicDir },
|
|
29449
29113
|
serveConfig
|
|
29450
29114
|
);
|
|
29451
29115
|
}
|
|
@@ -29545,9 +29209,11 @@ var Registry = class {
|
|
|
29545
29209
|
await runtime.serveRegistry(registry2, serveConfig);
|
|
29546
29210
|
}
|
|
29547
29211
|
);
|
|
29548
|
-
this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch(
|
|
29549
|
-
|
|
29550
|
-
|
|
29212
|
+
this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch(
|
|
29213
|
+
(error46) => {
|
|
29214
|
+
logger22().warn({ error: error46 }, "runtime registry serve errored");
|
|
29215
|
+
}
|
|
29216
|
+
);
|
|
29551
29217
|
this.#installSignalHandlers(config3);
|
|
29552
29218
|
}
|
|
29553
29219
|
if (printWelcome) {
|
|
@@ -29654,9 +29320,6 @@ var Registry = class {
|
|
|
29654
29320
|
if (runtimeServePromise !== void 0) {
|
|
29655
29321
|
await runtimeServePromise.catch(() => void 0);
|
|
29656
29322
|
}
|
|
29657
|
-
if (this.#applicationListenerPromise !== void 0) {
|
|
29658
|
-
await this.#applicationListenerPromise.catch(() => void 0);
|
|
29659
|
-
}
|
|
29660
29323
|
};
|
|
29661
29324
|
await Promise.race([
|
|
29662
29325
|
drain(),
|
|
@@ -29707,9 +29370,7 @@ var Registry = class {
|
|
|
29707
29370
|
startAndWait() {
|
|
29708
29371
|
if (this.#shutdownInFlight !== null) {
|
|
29709
29372
|
return Promise.reject(
|
|
29710
|
-
new Error(
|
|
29711
|
-
"registry.startAndWait() cannot run after shutdown has begun"
|
|
29712
|
-
)
|
|
29373
|
+
new Error("registry.startAndWait() cannot run after shutdown has begun")
|
|
29713
29374
|
);
|
|
29714
29375
|
}
|
|
29715
29376
|
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
@@ -29750,9 +29411,7 @@ var Registry = class {
|
|
|
29750
29411
|
const readinessPromise = (async () => {
|
|
29751
29412
|
const { runtime, registry: registry2 } = await configuredRegistryPromise;
|
|
29752
29413
|
const stoppedBeforeReady = serveLifecyclePromise.then(() => {
|
|
29753
|
-
throw new Error(
|
|
29754
|
-
"RivetKit registry stopped before becoming ready"
|
|
29755
|
-
);
|
|
29414
|
+
throw new Error("RivetKit registry stopped before becoming ready");
|
|
29756
29415
|
});
|
|
29757
29416
|
await Promise.race([
|
|
29758
29417
|
runtime.waitRegistryReady(registry2),
|