@rivetkit/supabase 2.3.10 → 2.3.11-rc.1
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 +149 -20
- package/dist/mod.mjs +149 -20
- 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-ET2F6BXK.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-ET2F6BXK.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.11-rc.1",
|
|
13350
13350
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13351
13351
|
license: "Apache-2.0",
|
|
13352
13352
|
keywords: [
|
|
@@ -14097,7 +14097,10 @@ function jsonStringifyCompat(input, space) {
|
|
|
14097
14097
|
return [JSON_COMPAT_BIGINT, value.toString()];
|
|
14098
14098
|
}
|
|
14099
14099
|
if (value instanceof ArrayBuffer) {
|
|
14100
|
-
return [
|
|
14100
|
+
return [
|
|
14101
|
+
JSON_COMPAT_ARRAY_BUFFER,
|
|
14102
|
+
base64EncodeArrayBuffer(value)
|
|
14103
|
+
];
|
|
14101
14104
|
}
|
|
14102
14105
|
if (value instanceof Uint8Array) {
|
|
14103
14106
|
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(value)];
|
|
@@ -14636,7 +14639,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
|
|
|
14636
14639
|
};
|
|
14637
14640
|
}
|
|
14638
14641
|
|
|
14639
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14642
|
+
// ../rivetkit/dist/tsup/chunk-6ZPMYIZ6.js
|
|
14640
14643
|
var config2 = /* @__PURE__ */ Config({});
|
|
14641
14644
|
function readWorkflowCbor(bc) {
|
|
14642
14645
|
return readData(bc);
|
|
@@ -15509,7 +15512,7 @@ var AsyncMutex = class {
|
|
|
15509
15512
|
}
|
|
15510
15513
|
};
|
|
15511
15514
|
|
|
15512
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15515
|
+
// ../rivetkit/dist/tsup/chunk-5FVMFSBH.js
|
|
15513
15516
|
function logger() {
|
|
15514
15517
|
return getLogger("actor-client");
|
|
15515
15518
|
}
|
|
@@ -15547,7 +15550,7 @@ async function importWebSocket() {
|
|
|
15547
15550
|
return webSocketPromise;
|
|
15548
15551
|
}
|
|
15549
15552
|
|
|
15550
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15553
|
+
// ../rivetkit/dist/tsup/chunk-MMPE77KO.js
|
|
15551
15554
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15552
15555
|
|
|
15553
15556
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -15725,7 +15728,7 @@ function createVersionedDataHandler(config3) {
|
|
|
15725
15728
|
return new VersionedDataHandler(config3);
|
|
15726
15729
|
}
|
|
15727
15730
|
|
|
15728
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15731
|
+
// ../rivetkit/dist/tsup/chunk-MMPE77KO.js
|
|
15729
15732
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
15730
15733
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
15731
15734
|
var PATH_CONNECT = "/connect";
|
|
@@ -18209,14 +18212,26 @@ function createQueueSender(senderOptions) {
|
|
|
18209
18212
|
send
|
|
18210
18213
|
};
|
|
18211
18214
|
}
|
|
18215
|
+
function isUrlLike(value) {
|
|
18216
|
+
return typeof value === "object" && value !== null && typeof value.href === "string" && typeof value.pathname === "string" && typeof value.search === "string";
|
|
18217
|
+
}
|
|
18218
|
+
function isRequestLike(value) {
|
|
18219
|
+
return typeof value === "object" && value !== null && typeof value.url === "string" && typeof value.method === "string" && isHeadersLike(value.headers);
|
|
18220
|
+
}
|
|
18221
|
+
function isResponseLike(value) {
|
|
18222
|
+
return typeof value === "object" && value !== null && typeof value.status === "number" && isHeadersLike(value.headers) && typeof value.arrayBuffer === "function";
|
|
18223
|
+
}
|
|
18224
|
+
function isHeadersLike(value) {
|
|
18225
|
+
return typeof value === "object" && value !== null && typeof value.entries === "function";
|
|
18226
|
+
}
|
|
18212
18227
|
async function rawHttpFetch(driver, target, params, input, init, options = {}) {
|
|
18213
18228
|
let path2;
|
|
18214
18229
|
let mergedInit = init || {};
|
|
18215
18230
|
if (typeof input === "string") {
|
|
18216
18231
|
path2 = input;
|
|
18217
|
-
} else if (input
|
|
18232
|
+
} else if (isUrlLike(input)) {
|
|
18218
18233
|
path2 = input.pathname + input.search;
|
|
18219
|
-
} else if (input
|
|
18234
|
+
} else if (isRequestLike(input)) {
|
|
18220
18235
|
const url2 = new URL(input.url);
|
|
18221
18236
|
path2 = url2.pathname + url2.search;
|
|
18222
18237
|
const requestHeaders = new Headers(input.headers);
|
|
@@ -23971,6 +23986,22 @@ function toNapiSqlBatchStatement(statement) {
|
|
|
23971
23986
|
function toNapiBuffer(value) {
|
|
23972
23987
|
return Buffer.from(value);
|
|
23973
23988
|
}
|
|
23989
|
+
function toNapiApplication(application) {
|
|
23990
|
+
return async (error46, request) => {
|
|
23991
|
+
if (error46) throw error46;
|
|
23992
|
+
if (!request) {
|
|
23993
|
+
throw new Error("application fetch callback received no request");
|
|
23994
|
+
}
|
|
23995
|
+
const response = await application({
|
|
23996
|
+
...request,
|
|
23997
|
+
body: new Uint8Array(request.body)
|
|
23998
|
+
});
|
|
23999
|
+
return {
|
|
24000
|
+
...response,
|
|
24001
|
+
body: toNapiBuffer(response.body)
|
|
24002
|
+
};
|
|
24003
|
+
};
|
|
24004
|
+
}
|
|
23974
24005
|
function toNapiHttpRequest(request) {
|
|
23975
24006
|
if (!request) {
|
|
23976
24007
|
return request;
|
|
@@ -24077,12 +24108,25 @@ var NapiCoreRuntime = class {
|
|
|
24077
24108
|
);
|
|
24078
24109
|
}
|
|
24079
24110
|
async serveListener(registry2, listener, config3) {
|
|
24111
|
+
const application = listener.application ? toNapiApplication(listener.application) : void 0;
|
|
24080
24112
|
await asNativeRegistry(registry2).serveListener(
|
|
24081
24113
|
{
|
|
24082
24114
|
port: listener.port,
|
|
24083
24115
|
host: listener.host,
|
|
24084
24116
|
publicDir: listener.publicDir
|
|
24085
24117
|
},
|
|
24118
|
+
config3,
|
|
24119
|
+
application
|
|
24120
|
+
);
|
|
24121
|
+
}
|
|
24122
|
+
async serveApplicationListener(registry2, listener, config3) {
|
|
24123
|
+
await asNativeRegistry(registry2).serveApplicationListener(
|
|
24124
|
+
{
|
|
24125
|
+
port: listener.port,
|
|
24126
|
+
host: listener.host,
|
|
24127
|
+
publicDir: listener.publicDir
|
|
24128
|
+
},
|
|
24129
|
+
toNapiApplication(listener.application),
|
|
24086
24130
|
config3
|
|
24087
24131
|
);
|
|
24088
24132
|
}
|
|
@@ -24738,6 +24782,11 @@ var WasmCoreRuntime = class {
|
|
|
24738
24782
|
"registry.listen() is not supported on the wasm runtime; use registry.serve() and mount the handler in your platform's HTTP server instead"
|
|
24739
24783
|
);
|
|
24740
24784
|
}
|
|
24785
|
+
async serveApplicationListener(_registry, _listener, _config) {
|
|
24786
|
+
throw new Error(
|
|
24787
|
+
"registry.listen() is not supported on the wasm runtime; use an application-owned HTTP server instead"
|
|
24788
|
+
);
|
|
24789
|
+
}
|
|
24741
24790
|
createActorFactory(callbacks, config3) {
|
|
24742
24791
|
return callWasmSync(
|
|
24743
24792
|
() => asActorFactoryHandle2(
|
|
@@ -28575,7 +28624,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28575
28624
|
requestCtx,
|
|
28576
28625
|
jsRequest
|
|
28577
28626
|
);
|
|
28578
|
-
if (!(response
|
|
28627
|
+
if (!isResponseLike(response)) {
|
|
28579
28628
|
throw new Error(
|
|
28580
28629
|
"onRequest handler must return a Response"
|
|
28581
28630
|
);
|
|
@@ -28845,6 +28894,29 @@ function finishShutdownSignal(signal) {
|
|
|
28845
28894
|
}
|
|
28846
28895
|
process.kill(process.pid, signal);
|
|
28847
28896
|
}
|
|
28897
|
+
function createApplicationFetch(application) {
|
|
28898
|
+
return async (request) => {
|
|
28899
|
+
const method2 = request.method.toUpperCase();
|
|
28900
|
+
const body = method2 === "GET" || method2 === "HEAD" || request.body.length === 0 ? void 0 : Uint8Array.from(request.body).buffer;
|
|
28901
|
+
const response = await application.fetch(
|
|
28902
|
+
new Request(request.url, {
|
|
28903
|
+
method: method2,
|
|
28904
|
+
headers: request.headers,
|
|
28905
|
+
body
|
|
28906
|
+
})
|
|
28907
|
+
);
|
|
28908
|
+
if (!isResponseLike(response)) {
|
|
28909
|
+
throw new TypeError(
|
|
28910
|
+
"registry.listen() application fetch must return a Response"
|
|
28911
|
+
);
|
|
28912
|
+
}
|
|
28913
|
+
return {
|
|
28914
|
+
status: response.status,
|
|
28915
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
28916
|
+
body: new Uint8Array(await response.arrayBuffer())
|
|
28917
|
+
};
|
|
28918
|
+
};
|
|
28919
|
+
}
|
|
28848
28920
|
var Registry = class {
|
|
28849
28921
|
#config;
|
|
28850
28922
|
#buildConfiguredRegistry;
|
|
@@ -28860,6 +28932,7 @@ var Registry = class {
|
|
|
28860
28932
|
#runtimeReadyPromise;
|
|
28861
28933
|
#runtimeServeConfiguredPromise;
|
|
28862
28934
|
#runtimeServerlessPromise;
|
|
28935
|
+
#applicationListenerPromise;
|
|
28863
28936
|
#configureServerlessPoolPromise;
|
|
28864
28937
|
#welcomePrinted = false;
|
|
28865
28938
|
#shutdownInstalled = false;
|
|
@@ -29085,17 +29158,63 @@ var Registry = class {
|
|
|
29085
29158
|
* @param opts.host Address to bind. Defaults to `0.0.0.0`.
|
|
29086
29159
|
* @param opts.publicDir If set, serves static files from this directory
|
|
29087
29160
|
* as a fallback below the framework routes.
|
|
29161
|
+
* @param opts.application If set, handles requests that do not match a
|
|
29162
|
+
* framework route.
|
|
29088
29163
|
*
|
|
29089
29164
|
* @example
|
|
29090
29165
|
* ```ts
|
|
29091
29166
|
* await registry.listen();
|
|
29092
|
-
* await registry.listen({
|
|
29167
|
+
* await registry.listen({ application: app });
|
|
29093
29168
|
* ```
|
|
29094
29169
|
*/
|
|
29095
29170
|
async listen(opts = {}) {
|
|
29096
29171
|
const port = opts.port ?? parsePortEnv(process.env.RIVET_PORT) ?? 3e3;
|
|
29097
29172
|
const publicDir = opts.publicDir ?? getRivetkitPublicDir();
|
|
29098
29173
|
const config3 = this.parseConfig();
|
|
29174
|
+
const application = opts.application ? createApplicationFetch(opts.application) : void 0;
|
|
29175
|
+
if (application && getRivetkitRuntimeMode() !== "serverless") {
|
|
29176
|
+
if (config3.runtime === "wasm") {
|
|
29177
|
+
throw new Error(
|
|
29178
|
+
"registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
|
|
29179
|
+
);
|
|
29180
|
+
}
|
|
29181
|
+
this.#installSignalHandlers(config3);
|
|
29182
|
+
this.#printWelcome(config3, "serverful", {
|
|
29183
|
+
port,
|
|
29184
|
+
host: opts.host,
|
|
29185
|
+
publicDir
|
|
29186
|
+
});
|
|
29187
|
+
this.#startEnvoy(config3, true);
|
|
29188
|
+
const readyPromise = this.startAndWait();
|
|
29189
|
+
const configuredRegistryPromise2 = this.#runtimeServeConfiguredPromise;
|
|
29190
|
+
if (!configuredRegistryPromise2) {
|
|
29191
|
+
throw new Error("registry envoy startup did not initialize");
|
|
29192
|
+
}
|
|
29193
|
+
const { runtime: runtime2, registry: registry22, serveConfig: serveConfig2 } = await configuredRegistryPromise2;
|
|
29194
|
+
const listenerPromise = runtime2.serveApplicationListener(
|
|
29195
|
+
registry22,
|
|
29196
|
+
{
|
|
29197
|
+
port,
|
|
29198
|
+
host: opts.host,
|
|
29199
|
+
publicDir,
|
|
29200
|
+
application
|
|
29201
|
+
},
|
|
29202
|
+
serveConfig2
|
|
29203
|
+
);
|
|
29204
|
+
this.#applicationListenerPromise = listenerPromise;
|
|
29205
|
+
const serveLifecyclePromise = this.#runtimeServeLifecyclePromise;
|
|
29206
|
+
if (!serveLifecyclePromise) {
|
|
29207
|
+
throw new Error(
|
|
29208
|
+
"registry envoy serve lifecycle did not initialize"
|
|
29209
|
+
);
|
|
29210
|
+
}
|
|
29211
|
+
await Promise.all([
|
|
29212
|
+
readyPromise,
|
|
29213
|
+
listenerPromise,
|
|
29214
|
+
serveLifecyclePromise
|
|
29215
|
+
]);
|
|
29216
|
+
return;
|
|
29217
|
+
}
|
|
29099
29218
|
const configuredRegistryPromise = buildConfiguredRegistry(config3);
|
|
29100
29219
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
29101
29220
|
this.#runtimeServerlessPromise = configuredRegistryPromise;
|
|
@@ -29109,7 +29228,12 @@ var Registry = class {
|
|
|
29109
29228
|
const { runtime, registry: registry2, serveConfig } = await configuredRegistryPromise;
|
|
29110
29229
|
await runtime.serveListener(
|
|
29111
29230
|
registry2,
|
|
29112
|
-
{
|
|
29231
|
+
{
|
|
29232
|
+
port,
|
|
29233
|
+
host: opts.host,
|
|
29234
|
+
publicDir,
|
|
29235
|
+
application
|
|
29236
|
+
},
|
|
29113
29237
|
serveConfig
|
|
29114
29238
|
);
|
|
29115
29239
|
}
|
|
@@ -29209,11 +29333,9 @@ var Registry = class {
|
|
|
29209
29333
|
await runtime.serveRegistry(registry2, serveConfig);
|
|
29210
29334
|
}
|
|
29211
29335
|
);
|
|
29212
|
-
this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch(
|
|
29213
|
-
(
|
|
29214
|
-
|
|
29215
|
-
}
|
|
29216
|
-
);
|
|
29336
|
+
this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch((error46) => {
|
|
29337
|
+
logger22().warn({ error: error46 }, "runtime registry serve errored");
|
|
29338
|
+
});
|
|
29217
29339
|
this.#installSignalHandlers(config3);
|
|
29218
29340
|
}
|
|
29219
29341
|
if (printWelcome) {
|
|
@@ -29320,6 +29442,9 @@ var Registry = class {
|
|
|
29320
29442
|
if (runtimeServePromise !== void 0) {
|
|
29321
29443
|
await runtimeServePromise.catch(() => void 0);
|
|
29322
29444
|
}
|
|
29445
|
+
if (this.#applicationListenerPromise !== void 0) {
|
|
29446
|
+
await this.#applicationListenerPromise.catch(() => void 0);
|
|
29447
|
+
}
|
|
29323
29448
|
};
|
|
29324
29449
|
await Promise.race([
|
|
29325
29450
|
drain(),
|
|
@@ -29370,7 +29495,9 @@ var Registry = class {
|
|
|
29370
29495
|
startAndWait() {
|
|
29371
29496
|
if (this.#shutdownInFlight !== null) {
|
|
29372
29497
|
return Promise.reject(
|
|
29373
|
-
new Error(
|
|
29498
|
+
new Error(
|
|
29499
|
+
"registry.startAndWait() cannot run after shutdown has begun"
|
|
29500
|
+
)
|
|
29374
29501
|
);
|
|
29375
29502
|
}
|
|
29376
29503
|
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
@@ -29411,7 +29538,9 @@ var Registry = class {
|
|
|
29411
29538
|
const readinessPromise = (async () => {
|
|
29412
29539
|
const { runtime, registry: registry2 } = await configuredRegistryPromise;
|
|
29413
29540
|
const stoppedBeforeReady = serveLifecyclePromise.then(() => {
|
|
29414
|
-
throw new Error(
|
|
29541
|
+
throw new Error(
|
|
29542
|
+
"RivetKit registry stopped before becoming ready"
|
|
29543
|
+
);
|
|
29415
29544
|
});
|
|
29416
29545
|
await Promise.race([
|
|
29417
29546
|
runtime.waitRegistryReady(registry2),
|
package/dist/mod.mjs
CHANGED
|
@@ -471,7 +471,7 @@ function unsupportedFeature(feature) {
|
|
|
471
471
|
);
|
|
472
472
|
}
|
|
473
473
|
|
|
474
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
474
|
+
// ../rivetkit/dist/tsup/chunk-ET2F6BXK.js
|
|
475
475
|
import {
|
|
476
476
|
pino,
|
|
477
477
|
stdTimeFunctions
|
|
@@ -13147,7 +13147,7 @@ var classic_default = external_exports;
|
|
|
13147
13147
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
|
|
13148
13148
|
var v4_default = classic_default;
|
|
13149
13149
|
|
|
13150
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
13150
|
+
// ../rivetkit/dist/tsup/chunk-ET2F6BXK.js
|
|
13151
13151
|
var import_invariant = __toESM(require_invariant(), 1);
|
|
13152
13152
|
import * as cbor from "cbor-x";
|
|
13153
13153
|
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
@@ -13312,7 +13312,7 @@ function noopNext() {
|
|
|
13312
13312
|
}
|
|
13313
13313
|
var package_default = {
|
|
13314
13314
|
name: "rivetkit",
|
|
13315
|
-
version: "2.3.
|
|
13315
|
+
version: "2.3.11-rc.1",
|
|
13316
13316
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13317
13317
|
license: "Apache-2.0",
|
|
13318
13318
|
keywords: [
|
|
@@ -14063,7 +14063,10 @@ function jsonStringifyCompat(input, space) {
|
|
|
14063
14063
|
return [JSON_COMPAT_BIGINT, value.toString()];
|
|
14064
14064
|
}
|
|
14065
14065
|
if (value instanceof ArrayBuffer) {
|
|
14066
|
-
return [
|
|
14066
|
+
return [
|
|
14067
|
+
JSON_COMPAT_ARRAY_BUFFER,
|
|
14068
|
+
base64EncodeArrayBuffer(value)
|
|
14069
|
+
];
|
|
14067
14070
|
}
|
|
14068
14071
|
if (value instanceof Uint8Array) {
|
|
14069
14072
|
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(value)];
|
|
@@ -14602,7 +14605,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
|
|
|
14602
14605
|
};
|
|
14603
14606
|
}
|
|
14604
14607
|
|
|
14605
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14608
|
+
// ../rivetkit/dist/tsup/chunk-6ZPMYIZ6.js
|
|
14606
14609
|
var config2 = /* @__PURE__ */ Config({});
|
|
14607
14610
|
function readWorkflowCbor(bc) {
|
|
14608
14611
|
return readData(bc);
|
|
@@ -15475,7 +15478,7 @@ var AsyncMutex = class {
|
|
|
15475
15478
|
}
|
|
15476
15479
|
};
|
|
15477
15480
|
|
|
15478
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15481
|
+
// ../rivetkit/dist/tsup/chunk-5FVMFSBH.js
|
|
15479
15482
|
function logger() {
|
|
15480
15483
|
return getLogger("actor-client");
|
|
15481
15484
|
}
|
|
@@ -15513,7 +15516,7 @@ async function importWebSocket() {
|
|
|
15513
15516
|
return webSocketPromise;
|
|
15514
15517
|
}
|
|
15515
15518
|
|
|
15516
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15519
|
+
// ../rivetkit/dist/tsup/chunk-MMPE77KO.js
|
|
15517
15520
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15518
15521
|
|
|
15519
15522
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -15691,7 +15694,7 @@ function createVersionedDataHandler(config3) {
|
|
|
15691
15694
|
return new VersionedDataHandler(config3);
|
|
15692
15695
|
}
|
|
15693
15696
|
|
|
15694
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15697
|
+
// ../rivetkit/dist/tsup/chunk-MMPE77KO.js
|
|
15695
15698
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
15696
15699
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
15697
15700
|
var PATH_CONNECT = "/connect";
|
|
@@ -18175,14 +18178,26 @@ function createQueueSender(senderOptions) {
|
|
|
18175
18178
|
send
|
|
18176
18179
|
};
|
|
18177
18180
|
}
|
|
18181
|
+
function isUrlLike(value) {
|
|
18182
|
+
return typeof value === "object" && value !== null && typeof value.href === "string" && typeof value.pathname === "string" && typeof value.search === "string";
|
|
18183
|
+
}
|
|
18184
|
+
function isRequestLike(value) {
|
|
18185
|
+
return typeof value === "object" && value !== null && typeof value.url === "string" && typeof value.method === "string" && isHeadersLike(value.headers);
|
|
18186
|
+
}
|
|
18187
|
+
function isResponseLike(value) {
|
|
18188
|
+
return typeof value === "object" && value !== null && typeof value.status === "number" && isHeadersLike(value.headers) && typeof value.arrayBuffer === "function";
|
|
18189
|
+
}
|
|
18190
|
+
function isHeadersLike(value) {
|
|
18191
|
+
return typeof value === "object" && value !== null && typeof value.entries === "function";
|
|
18192
|
+
}
|
|
18178
18193
|
async function rawHttpFetch(driver, target, params, input, init, options = {}) {
|
|
18179
18194
|
let path2;
|
|
18180
18195
|
let mergedInit = init || {};
|
|
18181
18196
|
if (typeof input === "string") {
|
|
18182
18197
|
path2 = input;
|
|
18183
|
-
} else if (input
|
|
18198
|
+
} else if (isUrlLike(input)) {
|
|
18184
18199
|
path2 = input.pathname + input.search;
|
|
18185
|
-
} else if (input
|
|
18200
|
+
} else if (isRequestLike(input)) {
|
|
18186
18201
|
const url2 = new URL(input.url);
|
|
18187
18202
|
path2 = url2.pathname + url2.search;
|
|
18188
18203
|
const requestHeaders = new Headers(input.headers);
|
|
@@ -23936,6 +23951,22 @@ function toNapiSqlBatchStatement(statement) {
|
|
|
23936
23951
|
function toNapiBuffer(value) {
|
|
23937
23952
|
return Buffer.from(value);
|
|
23938
23953
|
}
|
|
23954
|
+
function toNapiApplication(application) {
|
|
23955
|
+
return async (error46, request) => {
|
|
23956
|
+
if (error46) throw error46;
|
|
23957
|
+
if (!request) {
|
|
23958
|
+
throw new Error("application fetch callback received no request");
|
|
23959
|
+
}
|
|
23960
|
+
const response = await application({
|
|
23961
|
+
...request,
|
|
23962
|
+
body: new Uint8Array(request.body)
|
|
23963
|
+
});
|
|
23964
|
+
return {
|
|
23965
|
+
...response,
|
|
23966
|
+
body: toNapiBuffer(response.body)
|
|
23967
|
+
};
|
|
23968
|
+
};
|
|
23969
|
+
}
|
|
23939
23970
|
function toNapiHttpRequest(request) {
|
|
23940
23971
|
if (!request) {
|
|
23941
23972
|
return request;
|
|
@@ -24042,12 +24073,25 @@ var NapiCoreRuntime = class {
|
|
|
24042
24073
|
);
|
|
24043
24074
|
}
|
|
24044
24075
|
async serveListener(registry2, listener, config3) {
|
|
24076
|
+
const application = listener.application ? toNapiApplication(listener.application) : void 0;
|
|
24045
24077
|
await asNativeRegistry(registry2).serveListener(
|
|
24046
24078
|
{
|
|
24047
24079
|
port: listener.port,
|
|
24048
24080
|
host: listener.host,
|
|
24049
24081
|
publicDir: listener.publicDir
|
|
24050
24082
|
},
|
|
24083
|
+
config3,
|
|
24084
|
+
application
|
|
24085
|
+
);
|
|
24086
|
+
}
|
|
24087
|
+
async serveApplicationListener(registry2, listener, config3) {
|
|
24088
|
+
await asNativeRegistry(registry2).serveApplicationListener(
|
|
24089
|
+
{
|
|
24090
|
+
port: listener.port,
|
|
24091
|
+
host: listener.host,
|
|
24092
|
+
publicDir: listener.publicDir
|
|
24093
|
+
},
|
|
24094
|
+
toNapiApplication(listener.application),
|
|
24051
24095
|
config3
|
|
24052
24096
|
);
|
|
24053
24097
|
}
|
|
@@ -24703,6 +24747,11 @@ var WasmCoreRuntime = class {
|
|
|
24703
24747
|
"registry.listen() is not supported on the wasm runtime; use registry.serve() and mount the handler in your platform's HTTP server instead"
|
|
24704
24748
|
);
|
|
24705
24749
|
}
|
|
24750
|
+
async serveApplicationListener(_registry, _listener, _config) {
|
|
24751
|
+
throw new Error(
|
|
24752
|
+
"registry.listen() is not supported on the wasm runtime; use an application-owned HTTP server instead"
|
|
24753
|
+
);
|
|
24754
|
+
}
|
|
24706
24755
|
createActorFactory(callbacks, config3) {
|
|
24707
24756
|
return callWasmSync(
|
|
24708
24757
|
() => asActorFactoryHandle2(
|
|
@@ -28540,7 +28589,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
28540
28589
|
requestCtx,
|
|
28541
28590
|
jsRequest
|
|
28542
28591
|
);
|
|
28543
|
-
if (!(response
|
|
28592
|
+
if (!isResponseLike(response)) {
|
|
28544
28593
|
throw new Error(
|
|
28545
28594
|
"onRequest handler must return a Response"
|
|
28546
28595
|
);
|
|
@@ -28810,6 +28859,29 @@ function finishShutdownSignal(signal) {
|
|
|
28810
28859
|
}
|
|
28811
28860
|
process.kill(process.pid, signal);
|
|
28812
28861
|
}
|
|
28862
|
+
function createApplicationFetch(application) {
|
|
28863
|
+
return async (request) => {
|
|
28864
|
+
const method2 = request.method.toUpperCase();
|
|
28865
|
+
const body = method2 === "GET" || method2 === "HEAD" || request.body.length === 0 ? void 0 : Uint8Array.from(request.body).buffer;
|
|
28866
|
+
const response = await application.fetch(
|
|
28867
|
+
new Request(request.url, {
|
|
28868
|
+
method: method2,
|
|
28869
|
+
headers: request.headers,
|
|
28870
|
+
body
|
|
28871
|
+
})
|
|
28872
|
+
);
|
|
28873
|
+
if (!isResponseLike(response)) {
|
|
28874
|
+
throw new TypeError(
|
|
28875
|
+
"registry.listen() application fetch must return a Response"
|
|
28876
|
+
);
|
|
28877
|
+
}
|
|
28878
|
+
return {
|
|
28879
|
+
status: response.status,
|
|
28880
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
28881
|
+
body: new Uint8Array(await response.arrayBuffer())
|
|
28882
|
+
};
|
|
28883
|
+
};
|
|
28884
|
+
}
|
|
28813
28885
|
var Registry = class {
|
|
28814
28886
|
#config;
|
|
28815
28887
|
#buildConfiguredRegistry;
|
|
@@ -28825,6 +28897,7 @@ var Registry = class {
|
|
|
28825
28897
|
#runtimeReadyPromise;
|
|
28826
28898
|
#runtimeServeConfiguredPromise;
|
|
28827
28899
|
#runtimeServerlessPromise;
|
|
28900
|
+
#applicationListenerPromise;
|
|
28828
28901
|
#configureServerlessPoolPromise;
|
|
28829
28902
|
#welcomePrinted = false;
|
|
28830
28903
|
#shutdownInstalled = false;
|
|
@@ -29050,17 +29123,63 @@ var Registry = class {
|
|
|
29050
29123
|
* @param opts.host Address to bind. Defaults to `0.0.0.0`.
|
|
29051
29124
|
* @param opts.publicDir If set, serves static files from this directory
|
|
29052
29125
|
* as a fallback below the framework routes.
|
|
29126
|
+
* @param opts.application If set, handles requests that do not match a
|
|
29127
|
+
* framework route.
|
|
29053
29128
|
*
|
|
29054
29129
|
* @example
|
|
29055
29130
|
* ```ts
|
|
29056
29131
|
* await registry.listen();
|
|
29057
|
-
* await registry.listen({
|
|
29132
|
+
* await registry.listen({ application: app });
|
|
29058
29133
|
* ```
|
|
29059
29134
|
*/
|
|
29060
29135
|
async listen(opts = {}) {
|
|
29061
29136
|
const port = opts.port ?? parsePortEnv(process.env.RIVET_PORT) ?? 3e3;
|
|
29062
29137
|
const publicDir = opts.publicDir ?? getRivetkitPublicDir();
|
|
29063
29138
|
const config3 = this.parseConfig();
|
|
29139
|
+
const application = opts.application ? createApplicationFetch(opts.application) : void 0;
|
|
29140
|
+
if (application && getRivetkitRuntimeMode() !== "serverless") {
|
|
29141
|
+
if (config3.runtime === "wasm") {
|
|
29142
|
+
throw new Error(
|
|
29143
|
+
"registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
|
|
29144
|
+
);
|
|
29145
|
+
}
|
|
29146
|
+
this.#installSignalHandlers(config3);
|
|
29147
|
+
this.#printWelcome(config3, "serverful", {
|
|
29148
|
+
port,
|
|
29149
|
+
host: opts.host,
|
|
29150
|
+
publicDir
|
|
29151
|
+
});
|
|
29152
|
+
this.#startEnvoy(config3, true);
|
|
29153
|
+
const readyPromise = this.startAndWait();
|
|
29154
|
+
const configuredRegistryPromise2 = this.#runtimeServeConfiguredPromise;
|
|
29155
|
+
if (!configuredRegistryPromise2) {
|
|
29156
|
+
throw new Error("registry envoy startup did not initialize");
|
|
29157
|
+
}
|
|
29158
|
+
const { runtime: runtime2, registry: registry22, serveConfig: serveConfig2 } = await configuredRegistryPromise2;
|
|
29159
|
+
const listenerPromise = runtime2.serveApplicationListener(
|
|
29160
|
+
registry22,
|
|
29161
|
+
{
|
|
29162
|
+
port,
|
|
29163
|
+
host: opts.host,
|
|
29164
|
+
publicDir,
|
|
29165
|
+
application
|
|
29166
|
+
},
|
|
29167
|
+
serveConfig2
|
|
29168
|
+
);
|
|
29169
|
+
this.#applicationListenerPromise = listenerPromise;
|
|
29170
|
+
const serveLifecyclePromise = this.#runtimeServeLifecyclePromise;
|
|
29171
|
+
if (!serveLifecyclePromise) {
|
|
29172
|
+
throw new Error(
|
|
29173
|
+
"registry envoy serve lifecycle did not initialize"
|
|
29174
|
+
);
|
|
29175
|
+
}
|
|
29176
|
+
await Promise.all([
|
|
29177
|
+
readyPromise,
|
|
29178
|
+
listenerPromise,
|
|
29179
|
+
serveLifecyclePromise
|
|
29180
|
+
]);
|
|
29181
|
+
return;
|
|
29182
|
+
}
|
|
29064
29183
|
const configuredRegistryPromise = buildConfiguredRegistry(config3);
|
|
29065
29184
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
29066
29185
|
this.#runtimeServerlessPromise = configuredRegistryPromise;
|
|
@@ -29074,7 +29193,12 @@ var Registry = class {
|
|
|
29074
29193
|
const { runtime, registry: registry2, serveConfig } = await configuredRegistryPromise;
|
|
29075
29194
|
await runtime.serveListener(
|
|
29076
29195
|
registry2,
|
|
29077
|
-
{
|
|
29196
|
+
{
|
|
29197
|
+
port,
|
|
29198
|
+
host: opts.host,
|
|
29199
|
+
publicDir,
|
|
29200
|
+
application
|
|
29201
|
+
},
|
|
29078
29202
|
serveConfig
|
|
29079
29203
|
);
|
|
29080
29204
|
}
|
|
@@ -29174,11 +29298,9 @@ var Registry = class {
|
|
|
29174
29298
|
await runtime.serveRegistry(registry2, serveConfig);
|
|
29175
29299
|
}
|
|
29176
29300
|
);
|
|
29177
|
-
this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch(
|
|
29178
|
-
(
|
|
29179
|
-
|
|
29180
|
-
}
|
|
29181
|
-
);
|
|
29301
|
+
this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch((error46) => {
|
|
29302
|
+
logger22().warn({ error: error46 }, "runtime registry serve errored");
|
|
29303
|
+
});
|
|
29182
29304
|
this.#installSignalHandlers(config3);
|
|
29183
29305
|
}
|
|
29184
29306
|
if (printWelcome) {
|
|
@@ -29285,6 +29407,9 @@ var Registry = class {
|
|
|
29285
29407
|
if (runtimeServePromise !== void 0) {
|
|
29286
29408
|
await runtimeServePromise.catch(() => void 0);
|
|
29287
29409
|
}
|
|
29410
|
+
if (this.#applicationListenerPromise !== void 0) {
|
|
29411
|
+
await this.#applicationListenerPromise.catch(() => void 0);
|
|
29412
|
+
}
|
|
29288
29413
|
};
|
|
29289
29414
|
await Promise.race([
|
|
29290
29415
|
drain(),
|
|
@@ -29335,7 +29460,9 @@ var Registry = class {
|
|
|
29335
29460
|
startAndWait() {
|
|
29336
29461
|
if (this.#shutdownInFlight !== null) {
|
|
29337
29462
|
return Promise.reject(
|
|
29338
|
-
new Error(
|
|
29463
|
+
new Error(
|
|
29464
|
+
"registry.startAndWait() cannot run after shutdown has begun"
|
|
29465
|
+
)
|
|
29339
29466
|
);
|
|
29340
29467
|
}
|
|
29341
29468
|
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
@@ -29376,7 +29503,9 @@ var Registry = class {
|
|
|
29376
29503
|
const readinessPromise = (async () => {
|
|
29377
29504
|
const { runtime, registry: registry2 } = await configuredRegistryPromise;
|
|
29378
29505
|
const stoppedBeforeReady = serveLifecyclePromise.then(() => {
|
|
29379
|
-
throw new Error(
|
|
29506
|
+
throw new Error(
|
|
29507
|
+
"RivetKit registry stopped before becoming ready"
|
|
29508
|
+
);
|
|
29380
29509
|
});
|
|
29381
29510
|
await Promise.race([
|
|
29382
29511
|
runtime.waitRegistryReady(registry2),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivetkit/supabase",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.11-rc.1",
|
|
4
4
|
"description": "Supabase Edge Functions integration for RivetKit actors",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"check-edge-closure": "node ../../../scripts/ci/check-edge-native-closure.mjs"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@rivetkit/rivetkit-wasm": "2.3.
|
|
42
|
+
"@rivetkit/rivetkit-wasm": "2.3.11-rc.1",
|
|
43
43
|
"cbor-x": "^1.6.0",
|
|
44
44
|
"pino": "^9.5.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@size-limit/file": "^11.1.6",
|
|
48
48
|
"@types/node": "^22.0.0",
|
|
49
|
-
"rivetkit": "2.3.
|
|
49
|
+
"rivetkit": "2.3.11-rc.1",
|
|
50
50
|
"size-limit": "^11.1.6",
|
|
51
51
|
"tsup": "^8.4.0",
|
|
52
52
|
"typescript": "^5.5.2"
|