@rivetkit/supabase 2.3.18-rc.1 → 2.3.18-rc.3
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 +1021 -1019
- package/dist/mod.mjs +1023 -1021
- package/package.json +3 -3
package/dist/mod.mjs
CHANGED
|
@@ -297,6 +297,196 @@ var require_retry2 = __commonJS({
|
|
|
297
297
|
// src/mod.ts
|
|
298
298
|
import * as wasmBindings from "@rivetkit/rivetkit-wasm";
|
|
299
299
|
|
|
300
|
+
// ../rivetkit/dist/tsup/chunk-OUQUIBVW.js
|
|
301
|
+
var INTERNAL_ERROR_CODE = "internal_error";
|
|
302
|
+
var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
|
|
303
|
+
var USER_ERROR_CODE = "user_error";
|
|
304
|
+
var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
|
|
305
|
+
function looksLikeRivetErrorOptions(value) {
|
|
306
|
+
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "rayId" in value || "statusCode" in value || "actor" in value || "cause" in value);
|
|
307
|
+
}
|
|
308
|
+
function isTypedErrorTag(value) {
|
|
309
|
+
return value === "ActorError" || value === "RivetError";
|
|
310
|
+
}
|
|
311
|
+
function errorMessage(error46, fallback = String(error46)) {
|
|
312
|
+
if (error46 && typeof error46 === "object" && "message" in error46 && typeof error46.message === "string") {
|
|
313
|
+
return error46.message;
|
|
314
|
+
}
|
|
315
|
+
return fallback;
|
|
316
|
+
}
|
|
317
|
+
function isRivetErrorLike(error46) {
|
|
318
|
+
return typeof error46 === "object" && error46 !== null && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string" && (!("rayId" in error46) || error46.rayId === void 0 || typeof error46.rayId === "string") && (!("__type" in error46) || isTypedErrorTag(error46.__type));
|
|
319
|
+
}
|
|
320
|
+
function isActorAbortedError(error46) {
|
|
321
|
+
return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
|
|
322
|
+
}
|
|
323
|
+
function isActorSpecifier(value) {
|
|
324
|
+
return typeof value === "object" && value !== null && "actorId" in value && typeof value.actorId === "string" && "generation" in value && typeof value.generation === "number" && (!("key" in value) || value.key === void 0 || typeof value.key === "string");
|
|
325
|
+
}
|
|
326
|
+
var RivetError = class extends Error {
|
|
327
|
+
__type = "RivetError";
|
|
328
|
+
public;
|
|
329
|
+
metadata;
|
|
330
|
+
rayId;
|
|
331
|
+
statusCode;
|
|
332
|
+
actor;
|
|
333
|
+
group;
|
|
334
|
+
code;
|
|
335
|
+
static isRivetError(error46) {
|
|
336
|
+
return isRivetErrorLike(error46);
|
|
337
|
+
}
|
|
338
|
+
static isActorError(error46) {
|
|
339
|
+
return isRivetErrorLike(error46);
|
|
340
|
+
}
|
|
341
|
+
constructor(group, code, message, options) {
|
|
342
|
+
const normalized = looksLikeRivetErrorOptions(options) ? options : { metadata: options };
|
|
343
|
+
super(message, { cause: normalized.cause });
|
|
344
|
+
this.name = "RivetError";
|
|
345
|
+
this.group = group;
|
|
346
|
+
this.code = code;
|
|
347
|
+
this.public = normalized.public ?? false;
|
|
348
|
+
this.metadata = normalized.metadata;
|
|
349
|
+
this.rayId = normalized.rayId ?? void 0;
|
|
350
|
+
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
351
|
+
this.actor = normalized.actor;
|
|
352
|
+
}
|
|
353
|
+
toString() {
|
|
354
|
+
return this.message;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
var UserError = class extends RivetError {
|
|
358
|
+
constructor(message, options) {
|
|
359
|
+
super("user", (options == null ? void 0 : options.code) ?? USER_ERROR_CODE, message, {
|
|
360
|
+
public: true,
|
|
361
|
+
metadata: options == null ? void 0 : options.metadata,
|
|
362
|
+
cause: options == null ? void 0 : options.cause
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
function toRivetError(error46, fallback) {
|
|
367
|
+
if (typeof error46 === "string") {
|
|
368
|
+
const bridged = decodeBridgeRivetError(error46);
|
|
369
|
+
if (bridged) {
|
|
370
|
+
return bridged;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (error46 instanceof Error) {
|
|
374
|
+
const bridged = decodeBridgeRivetError(error46.message);
|
|
375
|
+
if (bridged) {
|
|
376
|
+
return bridged;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (isRivetErrorLike(error46)) {
|
|
380
|
+
return new RivetError(error46.group, error46.code, error46.message, {
|
|
381
|
+
public: error46.public,
|
|
382
|
+
statusCode: error46.statusCode,
|
|
383
|
+
metadata: error46.metadata,
|
|
384
|
+
rayId: error46.rayId,
|
|
385
|
+
actor: error46.actor,
|
|
386
|
+
cause: error46 instanceof Error ? error46.cause : void 0
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
return new RivetError(
|
|
390
|
+
(fallback == null ? void 0 : fallback.group) ?? "actor",
|
|
391
|
+
(fallback == null ? void 0 : fallback.code) ?? INTERNAL_ERROR_CODE,
|
|
392
|
+
errorMessage(error46, (fallback == null ? void 0 : fallback.message) ?? "Unknown error"),
|
|
393
|
+
{
|
|
394
|
+
public: fallback == null ? void 0 : fallback.public,
|
|
395
|
+
statusCode: fallback == null ? void 0 : fallback.statusCode,
|
|
396
|
+
metadata: fallback == null ? void 0 : fallback.metadata,
|
|
397
|
+
rayId: fallback == null ? void 0 : fallback.rayId,
|
|
398
|
+
actor: fallback == null ? void 0 : fallback.actor,
|
|
399
|
+
cause: error46 instanceof Error ? error46 : void 0
|
|
400
|
+
}
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
function encodeBridgeRivetError(error46) {
|
|
404
|
+
return `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({
|
|
405
|
+
group: error46.group,
|
|
406
|
+
code: error46.code,
|
|
407
|
+
message: error46.message,
|
|
408
|
+
metadata: error46.metadata,
|
|
409
|
+
rayId: error46.rayId,
|
|
410
|
+
public: error46.public,
|
|
411
|
+
statusCode: error46.statusCode,
|
|
412
|
+
actor: error46.actor
|
|
413
|
+
})}`;
|
|
414
|
+
}
|
|
415
|
+
function decodeBridgeRivetErrorPayload(value) {
|
|
416
|
+
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
417
|
+
return void 0;
|
|
418
|
+
}
|
|
419
|
+
try {
|
|
420
|
+
const raw = JSON.parse(
|
|
421
|
+
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
|
|
422
|
+
);
|
|
423
|
+
const payload = {
|
|
424
|
+
...raw,
|
|
425
|
+
rayId: raw.rayId ?? void 0
|
|
426
|
+
};
|
|
427
|
+
if (!isRivetErrorLike(payload)) {
|
|
428
|
+
return void 0;
|
|
429
|
+
}
|
|
430
|
+
if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
|
|
431
|
+
return void 0;
|
|
432
|
+
}
|
|
433
|
+
return payload;
|
|
434
|
+
} catch {
|
|
435
|
+
return void 0;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function decodeBridgeRivetError(value) {
|
|
439
|
+
const payload = decodeBridgeRivetErrorPayload(value);
|
|
440
|
+
if (!payload) {
|
|
441
|
+
return void 0;
|
|
442
|
+
}
|
|
443
|
+
return new RivetError(payload.group, payload.code, payload.message, {
|
|
444
|
+
metadata: payload.metadata,
|
|
445
|
+
rayId: payload.rayId,
|
|
446
|
+
public: payload.public,
|
|
447
|
+
statusCode: payload.statusCode,
|
|
448
|
+
actor: payload.actor ?? void 0
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
function invalidRequest(error46) {
|
|
452
|
+
return new RivetError(
|
|
453
|
+
"request",
|
|
454
|
+
"invalid",
|
|
455
|
+
`Invalid request: ${errorMessage(error46, String(error46))}`,
|
|
456
|
+
{
|
|
457
|
+
public: true,
|
|
458
|
+
cause: error46 instanceof Error ? error46 : void 0
|
|
459
|
+
}
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
function actorNotFound(identifier) {
|
|
463
|
+
return new RivetError(
|
|
464
|
+
"actor",
|
|
465
|
+
"not_found",
|
|
466
|
+
identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
|
|
467
|
+
{ public: true }
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
function forbiddenError() {
|
|
471
|
+
return new RivetError("auth", "forbidden", "Forbidden", {
|
|
472
|
+
public: true,
|
|
473
|
+
statusCode: 403
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
function unsupportedFeature(feature) {
|
|
477
|
+
return new RivetError(
|
|
478
|
+
"feature",
|
|
479
|
+
"unsupported",
|
|
480
|
+
`Unsupported feature: ${feature}`
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// ../rivetkit/dist/tsup/chunk-KGARR4E2.js
|
|
485
|
+
import {
|
|
486
|
+
pino,
|
|
487
|
+
stdTimeFunctions
|
|
488
|
+
} from "pino";
|
|
489
|
+
|
|
300
490
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
|
|
301
491
|
var external_exports = {};
|
|
302
492
|
__export(external_exports, {
|
|
@@ -12967,833 +13157,181 @@ var classic_default = external_exports;
|
|
|
12967
13157
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
|
|
12968
13158
|
var v4_default = classic_default;
|
|
12969
13159
|
|
|
12970
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
12971
|
-
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
|
|
13160
|
+
// ../rivetkit/dist/tsup/chunk-KGARR4E2.js
|
|
13161
|
+
var import_invariant = __toESM(require_invariant(), 1);
|
|
13162
|
+
import * as cbor from "cbor-x";
|
|
13163
|
+
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
13164
|
+
var getRivetEndpoint = () => getEnvUniversal("RIVET_ENDPOINT");
|
|
13165
|
+
var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
|
|
13166
|
+
var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
|
|
13167
|
+
var getRivetPool = () => getEnvUniversal("RIVET_POOL");
|
|
13168
|
+
var getRivetTotalSlots = () => {
|
|
13169
|
+
const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
|
|
13170
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13171
|
+
};
|
|
13172
|
+
var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
|
|
13173
|
+
var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
|
|
13174
|
+
var getRivetRunEnginePort = () => {
|
|
13175
|
+
const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
|
|
13176
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13177
|
+
};
|
|
13178
|
+
var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
|
|
13179
|
+
var getRivetRunServices = () => {
|
|
13180
|
+
const value = getEnvUniversal("RIVET_RUN_SERVICES");
|
|
13181
|
+
return value === void 0 ? void 0 : value === "1";
|
|
13182
|
+
};
|
|
13183
|
+
var getRivetEnvoyVersion = () => {
|
|
13184
|
+
const value = getEnvUniversal("RIVET_ENVOY_VERSION");
|
|
13185
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13186
|
+
};
|
|
13187
|
+
var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
|
|
13188
|
+
var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
|
|
13189
|
+
var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
|
|
13190
|
+
var getRivetkitRuntimeMode = () => {
|
|
13191
|
+
const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
|
|
13192
|
+
if (value === void 0) return "envoy";
|
|
13193
|
+
if (value === "envoy" || value === "serverless") return value;
|
|
13194
|
+
throw new Error(
|
|
13195
|
+
`RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
|
|
13196
|
+
);
|
|
13197
|
+
};
|
|
13198
|
+
var getRivetkitPublicDir = () => {
|
|
13199
|
+
const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
|
|
13200
|
+
return value === void 0 || value === "" ? void 0 : value;
|
|
13201
|
+
};
|
|
13202
|
+
function parsePortEnv(raw) {
|
|
13203
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
13204
|
+
const parsed = Number.parseInt(raw, 10);
|
|
13205
|
+
if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
|
|
13206
|
+
throw new Error(
|
|
13207
|
+
`RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
|
|
13208
|
+
);
|
|
12975
13209
|
}
|
|
12976
|
-
return
|
|
13210
|
+
return parsed;
|
|
12977
13211
|
}
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
13212
|
+
var getLogLevel = () => getEnvUniversal("RIVET_LOG_LEVEL") ?? getEnvUniversal("LOG_LEVEL");
|
|
13213
|
+
var getLogTarget = () => getEnvUniversal("RIVET_LOG_TARGET") === "1";
|
|
13214
|
+
var getLogTimestamp = () => getEnvUniversal("RIVET_LOG_TIMESTAMP") === "1";
|
|
13215
|
+
var getLogMessage = () => getEnvUniversal("RIVET_LOG_MESSAGE") === "1";
|
|
13216
|
+
var getLogErrorStack = () => getEnvUniversal("RIVET_LOG_ERROR_STACK") === "1";
|
|
13217
|
+
var getNodeEnv = () => getEnvUniversal("NODE_ENV");
|
|
13218
|
+
var getNextPhase = () => getEnvUniversal("NEXT_PHASE");
|
|
13219
|
+
var isDev = () => getNodeEnv() !== "production";
|
|
13220
|
+
function assertUnreachable(x) {
|
|
13221
|
+
throw new Error(`Unreachable case: ${x}`);
|
|
13222
|
+
}
|
|
13223
|
+
function isCanonicalStructuredRivetError(error46) {
|
|
13224
|
+
return error46 instanceof RivetError || typeof error46 === "object" && error46 !== null && "__type" in error46 && error46.__type === "RivetError" && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string";
|
|
13225
|
+
}
|
|
13226
|
+
function deconstructError(error46, exposeInternalError = false) {
|
|
13227
|
+
let statusCode;
|
|
13228
|
+
let public_;
|
|
13229
|
+
let group;
|
|
13230
|
+
let code;
|
|
13231
|
+
let message;
|
|
13232
|
+
let metadata;
|
|
13233
|
+
let rayId;
|
|
13234
|
+
let actor2;
|
|
13235
|
+
if (isCanonicalStructuredRivetError(error46)) {
|
|
13236
|
+
statusCode = typeof error46.statusCode === "number" ? error46.statusCode : error46.public ? 400 : 500;
|
|
13237
|
+
public_ = error46.public ?? false;
|
|
13238
|
+
group = error46.group;
|
|
13239
|
+
code = error46.code;
|
|
13240
|
+
message = error46.message;
|
|
13241
|
+
metadata = error46.metadata;
|
|
13242
|
+
rayId = error46.rayId;
|
|
13243
|
+
actor2 = error46.actor;
|
|
13244
|
+
} else if (RivetError.isActorError(error46) && error46.public) {
|
|
13245
|
+
statusCode = "statusCode" in error46 && error46.statusCode ? error46.statusCode : 400;
|
|
13246
|
+
public_ = true;
|
|
13247
|
+
group = error46.group;
|
|
13248
|
+
code = error46.code;
|
|
13249
|
+
message = getErrorMessage(error46);
|
|
13250
|
+
metadata = error46.metadata;
|
|
13251
|
+
rayId = error46.rayId;
|
|
13252
|
+
actor2 = error46.actor;
|
|
13253
|
+
} else if (exposeInternalError) {
|
|
13254
|
+
if (RivetError.isActorError(error46)) {
|
|
13255
|
+
statusCode = 500;
|
|
13256
|
+
public_ = false;
|
|
13257
|
+
group = error46.group;
|
|
13258
|
+
code = error46.code;
|
|
13259
|
+
message = getErrorMessage(error46);
|
|
13260
|
+
metadata = error46.metadata;
|
|
13261
|
+
rayId = error46.rayId;
|
|
13262
|
+
actor2 = error46.actor;
|
|
13263
|
+
} else {
|
|
13264
|
+
statusCode = 500;
|
|
13265
|
+
public_ = false;
|
|
13266
|
+
group = "rivetkit";
|
|
13267
|
+
code = INTERNAL_ERROR_CODE;
|
|
13268
|
+
message = getErrorMessage(error46);
|
|
12991
13269
|
}
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
13270
|
+
} else {
|
|
13271
|
+
statusCode = 500;
|
|
13272
|
+
public_ = false;
|
|
13273
|
+
group = "rivetkit";
|
|
13274
|
+
code = INTERNAL_ERROR_CODE;
|
|
13275
|
+
message = INTERNAL_ERROR_DESCRIPTION;
|
|
13276
|
+
if (RivetError.isActorError(error46)) {
|
|
13277
|
+
actor2 = error46.actor;
|
|
12995
13278
|
}
|
|
13279
|
+
metadata = {
|
|
13280
|
+
//url: `https://dashboard.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,
|
|
13281
|
+
};
|
|
12996
13282
|
}
|
|
12997
|
-
return
|
|
12998
|
-
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
|
|
13002
|
-
|
|
13003
|
-
|
|
13283
|
+
return {
|
|
13284
|
+
__type: "ActorError",
|
|
13285
|
+
statusCode,
|
|
13286
|
+
public: public_,
|
|
13287
|
+
group,
|
|
13288
|
+
code,
|
|
13289
|
+
message,
|
|
13290
|
+
metadata,
|
|
13291
|
+
rayId,
|
|
13292
|
+
actor: actor2
|
|
13293
|
+
};
|
|
13004
13294
|
}
|
|
13005
|
-
function
|
|
13006
|
-
if (
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
if (typeof child === "function") {
|
|
13014
|
-
const name = childPath.join(".");
|
|
13015
|
-
if (names.has(name)) {
|
|
13016
|
-
throw new TypeError(
|
|
13017
|
-
`Multiple action definitions flatten to \`${name}\``
|
|
13018
|
-
);
|
|
13295
|
+
function stringifyError(error46) {
|
|
13296
|
+
if (error46 instanceof Error) {
|
|
13297
|
+
if (typeof process !== "undefined" && getLogErrorStack()) {
|
|
13298
|
+
let stack;
|
|
13299
|
+
try {
|
|
13300
|
+
stack = error46.stack;
|
|
13301
|
+
} catch {
|
|
13302
|
+
stack = void 0;
|
|
13019
13303
|
}
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
name,
|
|
13023
|
-
path: childPath,
|
|
13024
|
-
handler: child
|
|
13025
|
-
});
|
|
13304
|
+
return `${error46.name}: ${error46.message}${stack ? `
|
|
13305
|
+
${stack}` : ""}`;
|
|
13026
13306
|
} else {
|
|
13027
|
-
|
|
13307
|
+
return `${error46.name}: ${error46.message}`;
|
|
13028
13308
|
}
|
|
13029
|
-
}
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
return
|
|
13309
|
+
} else if (typeof error46 === "string") {
|
|
13310
|
+
return error46;
|
|
13311
|
+
} else if (typeof error46 === "object" && error46 !== null) {
|
|
13312
|
+
try {
|
|
13313
|
+
return `${JSON.stringify(error46)}`;
|
|
13314
|
+
} catch {
|
|
13315
|
+
return "[cannot stringify error]";
|
|
13036
13316
|
}
|
|
13037
|
-
|
|
13317
|
+
} else {
|
|
13318
|
+
return `Unknown error: ${getErrorMessage(error46)}`;
|
|
13038
13319
|
}
|
|
13039
|
-
return value;
|
|
13040
13320
|
}
|
|
13041
|
-
function
|
|
13042
|
-
if (typeof
|
|
13043
|
-
return
|
|
13321
|
+
function getErrorMessage(err) {
|
|
13322
|
+
if (err && typeof err === "object" && "message" in err && typeof err.message === "string") {
|
|
13323
|
+
return err.message;
|
|
13324
|
+
} else {
|
|
13325
|
+
return String(err);
|
|
13044
13326
|
}
|
|
13045
|
-
const prototype = Object.getPrototypeOf(value);
|
|
13046
|
-
return prototype === Object.prototype || prototype === null;
|
|
13047
13327
|
}
|
|
13048
|
-
function
|
|
13049
|
-
return
|
|
13050
|
-
}
|
|
13051
|
-
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
13052
|
-
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
13053
|
-
"rivetkit.actor_context_internal"
|
|
13054
|
-
);
|
|
13055
|
-
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
13056
|
-
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
13057
|
-
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
13058
|
-
var zActionTree = external_exports.custom((value) => {
|
|
13059
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
13060
|
-
return false;
|
|
13061
|
-
}
|
|
13062
|
-
const prototype = Object.getPrototypeOf(value);
|
|
13063
|
-
return prototype === Object.prototype || prototype === null;
|
|
13064
|
-
}).superRefine((actions, ctx) => {
|
|
13065
|
-
try {
|
|
13066
|
-
flattenActionHandlers(actions);
|
|
13067
|
-
} catch (error46) {
|
|
13068
|
-
ctx.addIssue({
|
|
13069
|
-
code: "custom",
|
|
13070
|
-
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
13071
|
-
});
|
|
13072
|
-
}
|
|
13073
|
-
});
|
|
13074
|
-
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
13075
|
-
getHistory: zFunction(),
|
|
13076
|
-
getState: zFunction().optional(),
|
|
13077
|
-
onHistoryUpdated: zFunction().optional(),
|
|
13078
|
-
replayFromStep: zFunction().optional()
|
|
13079
|
-
});
|
|
13080
|
-
var RunInspectorConfigSchema = external_exports.object({
|
|
13081
|
-
workflow: WorkflowInspectorConfigSchema.optional()
|
|
13082
|
-
}).optional();
|
|
13083
|
-
var BUILTIN_INSPECTOR_TAB_IDS = [
|
|
13084
|
-
"workflow",
|
|
13085
|
-
"database",
|
|
13086
|
-
"state",
|
|
13087
|
-
"queue",
|
|
13088
|
-
"schedules",
|
|
13089
|
-
"connections",
|
|
13090
|
-
"console"
|
|
13091
|
-
];
|
|
13092
|
-
var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
|
|
13093
|
-
var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
13094
|
-
var CustomInspectorTabEntrySchema = external_exports.object({
|
|
13095
|
-
id: external_exports.string().regex(
|
|
13096
|
-
CUSTOM_INSPECTOR_TAB_ID_RE,
|
|
13097
|
-
"inspector.tabs[].id must contain only letters, digits, underscore, or dash"
|
|
13098
|
-
),
|
|
13099
|
-
label: external_exports.string().min(1),
|
|
13100
|
-
source: external_exports.string().min(1),
|
|
13101
|
-
/**
|
|
13102
|
-
* Optional icon id. The dashboard maps strings to glyphs (see its
|
|
13103
|
-
* icon registry); unknown ids fall back to a generic icon.
|
|
13104
|
-
*/
|
|
13105
|
-
icon: external_exports.string().min(1).optional(),
|
|
13106
|
-
hidden: external_exports.literal(false).optional()
|
|
13107
|
-
}).strict();
|
|
13108
|
-
var HideInspectorTabEntrySchema = external_exports.object({
|
|
13109
|
-
id: BuiltinInspectorTabIdSchema,
|
|
13110
|
-
hidden: external_exports.literal(true)
|
|
13111
|
-
}).strict();
|
|
13112
|
-
var InspectorTabEntrySchema = external_exports.union([
|
|
13113
|
-
CustomInspectorTabEntrySchema,
|
|
13114
|
-
HideInspectorTabEntrySchema
|
|
13115
|
-
]);
|
|
13116
|
-
var ActorInspectorConfigSchema = external_exports.object({
|
|
13117
|
-
tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
|
|
13118
|
-
}).strict().refine(
|
|
13119
|
-
(data) => {
|
|
13120
|
-
const ids = data.tabs.map((t) => t.id);
|
|
13121
|
-
return new Set(ids).size === ids.length;
|
|
13122
|
-
},
|
|
13123
|
-
{ message: "Duplicate id in inspector.tabs", path: ["tabs"] }
|
|
13124
|
-
).refine(
|
|
13125
|
-
(data) => {
|
|
13126
|
-
const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
|
|
13127
|
-
return data.tabs.every(
|
|
13128
|
-
(t) => t.hidden === true || !builtinSet.has(t.id)
|
|
13129
|
-
);
|
|
13130
|
-
},
|
|
13131
|
-
{
|
|
13132
|
-
message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
|
|
13133
|
-
path: ["tabs"]
|
|
13134
|
-
}
|
|
13135
|
-
);
|
|
13136
|
-
var RunConfigSchema = external_exports.object({
|
|
13137
|
-
/** Display name for the actor in the Inspector UI. */
|
|
13138
|
-
name: external_exports.string().optional(),
|
|
13139
|
-
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
13140
|
-
icon: external_exports.string().optional(),
|
|
13141
|
-
/** The run handler function. */
|
|
13142
|
-
run: zFunction(),
|
|
13143
|
-
/** Inspector integration for long-running run handlers. */
|
|
13144
|
-
inspector: RunInspectorConfigSchema.optional()
|
|
13145
|
-
});
|
|
13146
|
-
var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for("rivetkit.run_function_config");
|
|
13147
|
-
function defineRunHandler(run, options) {
|
|
13148
|
-
if (options.inspectorKind === void 0 !== (options.createInspector === void 0)) {
|
|
13149
|
-
throw new TypeError(
|
|
13150
|
-
"defineRunHandler requires inspectorKind and createInspector together"
|
|
13151
|
-
);
|
|
13152
|
-
}
|
|
13153
|
-
Object.defineProperty(run, RUN_FUNCTION_CONFIG_SYMBOL, {
|
|
13154
|
-
configurable: false,
|
|
13155
|
-
enumerable: false,
|
|
13156
|
-
writable: false,
|
|
13157
|
-
value: {
|
|
13158
|
-
name: options.name,
|
|
13159
|
-
icon: options.icon,
|
|
13160
|
-
inspectorKind: options.inspectorKind,
|
|
13161
|
-
createInspector: options.createInspector
|
|
13162
|
-
}
|
|
13163
|
-
});
|
|
13164
|
-
return run;
|
|
13165
|
-
}
|
|
13166
|
-
function getRunInspectorKind(run) {
|
|
13167
|
-
var _a2;
|
|
13168
|
-
if (!run || typeof run !== "function") return void 0;
|
|
13169
|
-
return (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.inspectorKind;
|
|
13170
|
-
}
|
|
13171
|
-
function createRunInspector(run, context) {
|
|
13172
|
-
var _a2, _b;
|
|
13173
|
-
if (!run || typeof run !== "function") return void 0;
|
|
13174
|
-
return (_b = (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.createInspector) == null ? void 0 : _b.call(_a2, context);
|
|
13175
|
-
}
|
|
13176
|
-
var zRunHandler = external_exports.union([zFunction(), RunConfigSchema]).optional();
|
|
13177
|
-
function getRunFunction(run) {
|
|
13178
|
-
if (!run) return void 0;
|
|
13179
|
-
if (typeof run === "function") return run;
|
|
13180
|
-
return run.run;
|
|
13181
|
-
}
|
|
13182
|
-
function getRunMetadata(run) {
|
|
13183
|
-
if (!run) return {};
|
|
13184
|
-
if (typeof run === "function") {
|
|
13185
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13186
|
-
if (!config3) return {};
|
|
13187
|
-
return { name: config3.name, icon: config3.icon };
|
|
13188
|
-
}
|
|
13189
|
-
return { name: run.name, icon: run.icon };
|
|
13190
|
-
}
|
|
13191
|
-
function getRunInspectorConfig(run, actor2) {
|
|
13192
|
-
if (!run) return void 0;
|
|
13193
|
-
if (typeof run === "function") {
|
|
13194
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13195
|
-
return (config3 == null ? void 0 : config3.inspectorFactory) ? config3.inspectorFactory(actor2) : config3 == null ? void 0 : config3.inspector;
|
|
13196
|
-
}
|
|
13197
|
-
return run.inspector;
|
|
13198
|
-
}
|
|
13199
|
-
function hasRunInspectorConfig(run) {
|
|
13200
|
-
if (!run) return false;
|
|
13201
|
-
if (typeof run !== "function") return run.inspector !== void 0;
|
|
13202
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13203
|
-
return (config3 == null ? void 0 : config3.inspectorKind) !== void 0 || (config3 == null ? void 0 : config3.createInspector) !== void 0 || (config3 == null ? void 0 : config3.inspector) !== void 0 || (config3 == null ? void 0 : config3.inspectorFactory) !== void 0;
|
|
13204
|
-
}
|
|
13205
|
-
function disposeRunInspector(run, actorId) {
|
|
13206
|
-
var _a2;
|
|
13207
|
-
if (!run || typeof run !== "function") {
|
|
13208
|
-
return;
|
|
13209
|
-
}
|
|
13210
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13211
|
-
(_a2 = config3 == null ? void 0 : config3.disposeInspector) == null ? void 0 : _a2.call(config3, actorId);
|
|
13212
|
-
}
|
|
13213
|
-
var GlobalActorOptionsBaseSchema = external_exports.object({
|
|
13214
|
-
/** Display name for the actor in the Inspector UI. */
|
|
13215
|
-
name: external_exports.string().optional(),
|
|
13216
|
-
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
13217
|
-
icon: external_exports.string().optional(),
|
|
13218
|
-
/** Enables the experimental Actor Runtime Socket for this actor. */
|
|
13219
|
-
enableActorRuntimeSocket: external_exports.boolean().default(false),
|
|
13220
|
-
/**
|
|
13221
|
-
* Can hibernate WebSockets for onWebSocket.
|
|
13222
|
-
*
|
|
13223
|
-
* WebSockets using actions/events are hibernatable by default.
|
|
13224
|
-
*
|
|
13225
|
-
* @experimental
|
|
13226
|
-
**/
|
|
13227
|
-
canHibernateWebSocket: external_exports.union([external_exports.boolean(), zFunction()]).default(false)
|
|
13228
|
-
}).strict();
|
|
13229
|
-
var GlobalActorOptionsSchema = GlobalActorOptionsBaseSchema.prefault(
|
|
13230
|
-
() => ({})
|
|
13231
|
-
);
|
|
13232
|
-
var InstanceActorOptionsBaseSchema = external_exports.object({
|
|
13233
|
-
createVarsTimeout: external_exports.number().positive().default(5e3),
|
|
13234
|
-
createConnStateTimeout: external_exports.number().positive().default(5e3),
|
|
13235
|
-
onBeforeConnectTimeout: external_exports.number().positive().default(5e3),
|
|
13236
|
-
onConnectTimeout: external_exports.number().positive().default(5e3),
|
|
13237
|
-
onMigrateTimeout: external_exports.number().positive().default(3e4),
|
|
13238
|
-
sleepGracePeriod: external_exports.number().positive().default(DEFAULT_SLEEP_GRACE_PERIOD),
|
|
13239
|
-
/** @deprecated `onDestroyTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
|
|
13240
|
-
onDestroyTimeout: external_exports.number().positive().optional(),
|
|
13241
|
-
/** @deprecated `waitUntilTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
|
|
13242
|
-
waitUntilTimeout: external_exports.number().positive().optional(),
|
|
13243
|
-
stateSaveInterval: external_exports.number().positive().default(1e3),
|
|
13244
|
-
actionTimeout: external_exports.number().positive().default(6e4),
|
|
13245
|
-
connectionLivenessTimeout: external_exports.number().positive().default(2500),
|
|
13246
|
-
connectionLivenessInterval: external_exports.number().positive().default(5e3),
|
|
13247
|
-
/** @deprecated Use `c.keepAwake(promise)` to scope keep-awake to a specific operation, or keep `noSleep` for actors that must stay awake indefinitely. Will be removed in 2.2.0. */
|
|
13248
|
-
noSleep: external_exports.boolean().default(false),
|
|
13249
|
-
sleepTimeout: external_exports.number().positive().default(3e4),
|
|
13250
|
-
maxQueueSize: external_exports.number().positive().default(1e3),
|
|
13251
|
-
/** Maximum pending one-shot and recurring schedules. */
|
|
13252
|
-
maxSchedules: external_exports.number().int().nonnegative().default(1e3),
|
|
13253
|
-
maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
|
|
13254
|
-
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
13255
|
-
preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
|
|
13256
|
-
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
13257
|
-
preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
|
|
13258
|
-
}).strict();
|
|
13259
|
-
var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
|
|
13260
|
-
var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
|
|
13261
|
-
InstanceActorOptionsBaseSchema.shape
|
|
13262
|
-
).strict().prefault(() => ({}));
|
|
13263
|
-
var ActorConfigSchema = external_exports.object({
|
|
13264
|
-
onCreate: zFunction().optional(),
|
|
13265
|
-
onDestroy: zFunction().optional(),
|
|
13266
|
-
onMigrate: zFunction().optional(),
|
|
13267
|
-
onWake: zFunction().optional(),
|
|
13268
|
-
onSleep: zFunction().optional(),
|
|
13269
|
-
run: zRunHandler,
|
|
13270
|
-
onStateChange: zFunction().optional(),
|
|
13271
|
-
onBeforeConnect: zFunction().optional(),
|
|
13272
|
-
onConnect: zFunction().optional(),
|
|
13273
|
-
onDisconnect: zFunction().optional(),
|
|
13274
|
-
onBeforeActionResponse: zFunction().optional(),
|
|
13275
|
-
onRequest: zFunction().optional(),
|
|
13276
|
-
onWebSocket: zFunction().optional(),
|
|
13277
|
-
actions: zActionTree.default(() => ({})),
|
|
13278
|
-
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13279
|
-
connParamsSchema: external_exports.any().optional(),
|
|
13280
|
-
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13281
|
-
queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13282
|
-
state: external_exports.any().optional(),
|
|
13283
|
-
createState: zFunction().optional(),
|
|
13284
|
-
connState: external_exports.any().optional(),
|
|
13285
|
-
createConnState: zFunction().optional(),
|
|
13286
|
-
vars: external_exports.any().optional(),
|
|
13287
|
-
db: external_exports.any().optional(),
|
|
13288
|
-
createVars: zFunction().optional(),
|
|
13289
|
-
options: ActorOptionsSchema,
|
|
13290
|
-
inspector: ActorInspectorConfigSchema.optional()
|
|
13291
|
-
}).strict().refine(
|
|
13292
|
-
(data) => !(data.state !== void 0 && data.createState !== void 0),
|
|
13293
|
-
{
|
|
13294
|
-
message: "Cannot define both 'state' and 'createState'",
|
|
13295
|
-
path: ["state"]
|
|
13296
|
-
}
|
|
13297
|
-
).refine(
|
|
13298
|
-
(data) => !(data.connState !== void 0 && data.createConnState !== void 0),
|
|
13299
|
-
{
|
|
13300
|
-
message: "Cannot define both 'connState' and 'createConnState'",
|
|
13301
|
-
path: ["connState"]
|
|
13302
|
-
}
|
|
13303
|
-
).refine(
|
|
13304
|
-
(data) => !(data.vars !== void 0 && data.createVars !== void 0),
|
|
13305
|
-
{
|
|
13306
|
-
message: "Cannot define both 'vars' and 'createVars'",
|
|
13307
|
-
path: ["vars"]
|
|
13308
|
-
}
|
|
13309
|
-
);
|
|
13310
|
-
var DocActorOptionsSchema = external_exports.object({
|
|
13311
|
-
name: external_exports.string().optional().describe("Display name for the actor in the Inspector UI."),
|
|
13312
|
-
icon: external_exports.string().optional().describe(
|
|
13313
|
-
"Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
|
|
13314
|
-
),
|
|
13315
|
-
enableActorRuntimeSocket: external_exports.boolean().optional().describe(
|
|
13316
|
-
"Enables the experimental Actor Runtime Socket for this actor. Default: false"
|
|
13317
|
-
),
|
|
13318
|
-
createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
|
|
13319
|
-
createConnStateTimeout: external_exports.number().optional().describe(
|
|
13320
|
-
"Timeout in ms for createConnState handler. Default: 5000"
|
|
13321
|
-
),
|
|
13322
|
-
onMigrateTimeout: external_exports.number().optional().describe("Timeout in ms for onMigrate handler. Default: 30000"),
|
|
13323
|
-
onBeforeConnectTimeout: external_exports.number().optional().describe(
|
|
13324
|
-
"Timeout in ms for onBeforeConnect handler. Default: 5000"
|
|
13325
|
-
),
|
|
13326
|
-
onConnectTimeout: external_exports.number().optional().describe("Timeout in ms for onConnect handler. Default: 5000"),
|
|
13327
|
-
sleepGracePeriod: external_exports.number().optional().describe(
|
|
13328
|
-
`Max time in ms for the graceful shutdown window. Covers lifecycle hooks (onSleep, onDestroy), the run handler wait, async raw WebSocket handlers, disconnect callbacks, and final state serialization. Default: ${DEFAULT_SLEEP_GRACE_PERIOD}.`
|
|
13329
|
-
),
|
|
13330
|
-
onDestroyTimeout: external_exports.number().optional().describe(
|
|
13331
|
-
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
13332
|
-
),
|
|
13333
|
-
waitUntilTimeout: external_exports.number().optional().describe(
|
|
13334
|
-
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
13335
|
-
),
|
|
13336
|
-
stateSaveInterval: external_exports.number().optional().describe(
|
|
13337
|
-
"Interval in ms between automatic state saves. Default: 1000"
|
|
13338
|
-
),
|
|
13339
|
-
actionTimeout: external_exports.number().optional().describe("Timeout in ms for action handlers. Default: 60000"),
|
|
13340
|
-
connectionLivenessTimeout: external_exports.number().optional().describe(
|
|
13341
|
-
"Timeout in ms for connection liveness checks. Default: 2500"
|
|
13342
|
-
),
|
|
13343
|
-
connectionLivenessInterval: external_exports.number().optional().describe(
|
|
13344
|
-
"Interval in ms between connection liveness checks. Default: 5000"
|
|
13345
|
-
),
|
|
13346
|
-
noSleep: external_exports.boolean().optional().describe(
|
|
13347
|
-
"Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
|
|
13348
|
-
),
|
|
13349
|
-
sleepTimeout: external_exports.number().optional().describe(
|
|
13350
|
-
"Time in ms of inactivity before the actor sleeps. Default: 30000"
|
|
13351
|
-
),
|
|
13352
|
-
maxQueueSize: external_exports.number().optional().describe(
|
|
13353
|
-
"Maximum number of queue messages before rejecting new messages. Default: 1000"
|
|
13354
|
-
),
|
|
13355
|
-
maxSchedules: external_exports.number().int().nonnegative().optional().describe(
|
|
13356
|
-
"Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
|
|
13357
|
-
),
|
|
13358
|
-
maxQueueMessageSize: external_exports.number().optional().describe(
|
|
13359
|
-
"Maximum size of each queue message in bytes. Default: 65536"
|
|
13360
|
-
),
|
|
13361
|
-
canHibernateWebSocket: external_exports.boolean().optional().describe(
|
|
13362
|
-
"Whether WebSockets using onWebSocket can be hibernated. WebSockets using actions/events are hibernatable by default. Default: false"
|
|
13363
|
-
)
|
|
13364
|
-
}).describe("Actor options for timeouts and behavior configuration.");
|
|
13365
|
-
var DocActorConfigSchema = external_exports.object({
|
|
13366
|
-
state: external_exports.unknown().optional().describe(
|
|
13367
|
-
"Initial state value for the actor. Cannot be used with createState."
|
|
13368
|
-
),
|
|
13369
|
-
createState: external_exports.unknown().optional().describe(
|
|
13370
|
-
"Function to create initial state. Receives context and input. Cannot be used with state."
|
|
13371
|
-
),
|
|
13372
|
-
connState: external_exports.unknown().optional().describe(
|
|
13373
|
-
"Initial connection state value. Cannot be used with createConnState."
|
|
13374
|
-
),
|
|
13375
|
-
createConnState: external_exports.unknown().optional().describe(
|
|
13376
|
-
"Function to create connection state. Receives context and connection params. The pending connection is not visible in c.conns until this succeeds. Cannot be used with connState."
|
|
13377
|
-
),
|
|
13378
|
-
vars: external_exports.unknown().optional().describe(
|
|
13379
|
-
"Initial ephemeral variables value. Cannot be used with createVars."
|
|
13380
|
-
),
|
|
13381
|
-
createVars: external_exports.unknown().optional().describe(
|
|
13382
|
-
"Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
|
|
13383
|
-
),
|
|
13384
|
-
db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
|
|
13385
|
-
onCreate: external_exports.unknown().optional().describe(
|
|
13386
|
-
"Called when the actor is first initialized. Use to initialize state."
|
|
13387
|
-
),
|
|
13388
|
-
onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
|
|
13389
|
-
onMigrate: external_exports.unknown().optional().describe(
|
|
13390
|
-
"Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
|
|
13391
|
-
),
|
|
13392
|
-
onWake: external_exports.unknown().optional().describe(
|
|
13393
|
-
"Called when the actor wakes up and is ready to receive connections and actions."
|
|
13394
|
-
),
|
|
13395
|
-
onSleep: external_exports.unknown().optional().describe(
|
|
13396
|
-
"Called when the actor is stopping or sleeping. Use to clean up resources."
|
|
13397
|
-
),
|
|
13398
|
-
run: external_exports.unknown().optional().describe(
|
|
13399
|
-
"Called after actor starts. Does not block startup. Use for background tasks like queue processing or tick loops. If it exits, the actor follows the normal idle sleep timeout once idle. If it throws, the actor logs the error and then follows the normal idle sleep timeout once idle."
|
|
13400
|
-
),
|
|
13401
|
-
onStateChange: external_exports.unknown().optional().describe(
|
|
13402
|
-
"Called when the actor's state changes. State changes within this hook won't trigger recursion."
|
|
13403
|
-
),
|
|
13404
|
-
onBeforeConnect: external_exports.unknown().optional().describe(
|
|
13405
|
-
"Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
|
|
13406
|
-
),
|
|
13407
|
-
onConnect: external_exports.unknown().optional().describe(
|
|
13408
|
-
"Called when a client successfully connects. The connection is visible in c.conns before this runs."
|
|
13409
|
-
),
|
|
13410
|
-
onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
|
|
13411
|
-
onBeforeActionResponse: external_exports.unknown().optional().describe(
|
|
13412
|
-
"Called before sending an action response. Use to transform output."
|
|
13413
|
-
),
|
|
13414
|
-
onRequest: external_exports.unknown().optional().describe(
|
|
13415
|
-
"Called for raw HTTP requests to /actors/{name}/http/* endpoints."
|
|
13416
|
-
),
|
|
13417
|
-
onWebSocket: external_exports.unknown().optional().describe(
|
|
13418
|
-
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
13419
|
-
),
|
|
13420
|
-
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
13421
|
-
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
13422
|
-
),
|
|
13423
|
-
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
13424
|
-
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
13425
|
-
),
|
|
13426
|
-
connParamsSchema: external_exports.unknown().optional().describe(
|
|
13427
|
-
"Optional schema for validating connection params in native runtimes."
|
|
13428
|
-
),
|
|
13429
|
-
events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
|
|
13430
|
-
queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
|
|
13431
|
-
options: DocActorOptionsSchema.optional()
|
|
13432
|
-
}).describe("Actor configuration passed to the actor() function.");
|
|
13433
|
-
|
|
13434
|
-
// ../rivetkit/dist/tsup/chunk-OUQUIBVW.js
|
|
13435
|
-
var INTERNAL_ERROR_CODE = "internal_error";
|
|
13436
|
-
var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
|
|
13437
|
-
var USER_ERROR_CODE = "user_error";
|
|
13438
|
-
var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
|
|
13439
|
-
function looksLikeRivetErrorOptions(value) {
|
|
13440
|
-
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "rayId" in value || "statusCode" in value || "actor" in value || "cause" in value);
|
|
13441
|
-
}
|
|
13442
|
-
function isTypedErrorTag(value) {
|
|
13443
|
-
return value === "ActorError" || value === "RivetError";
|
|
13444
|
-
}
|
|
13445
|
-
function errorMessage(error46, fallback = String(error46)) {
|
|
13446
|
-
if (error46 && typeof error46 === "object" && "message" in error46 && typeof error46.message === "string") {
|
|
13447
|
-
return error46.message;
|
|
13448
|
-
}
|
|
13449
|
-
return fallback;
|
|
13450
|
-
}
|
|
13451
|
-
function isRivetErrorLike(error46) {
|
|
13452
|
-
return typeof error46 === "object" && error46 !== null && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string" && (!("rayId" in error46) || error46.rayId === void 0 || typeof error46.rayId === "string") && (!("__type" in error46) || isTypedErrorTag(error46.__type));
|
|
13453
|
-
}
|
|
13454
|
-
function isActorAbortedError(error46) {
|
|
13455
|
-
return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
|
|
13456
|
-
}
|
|
13457
|
-
function isActorSpecifier(value) {
|
|
13458
|
-
return typeof value === "object" && value !== null && "actorId" in value && typeof value.actorId === "string" && "generation" in value && typeof value.generation === "number" && (!("key" in value) || value.key === void 0 || typeof value.key === "string");
|
|
13459
|
-
}
|
|
13460
|
-
var RivetError = class extends Error {
|
|
13461
|
-
__type = "RivetError";
|
|
13462
|
-
public;
|
|
13463
|
-
metadata;
|
|
13464
|
-
rayId;
|
|
13465
|
-
statusCode;
|
|
13466
|
-
actor;
|
|
13467
|
-
group;
|
|
13468
|
-
code;
|
|
13469
|
-
static isRivetError(error46) {
|
|
13470
|
-
return isRivetErrorLike(error46);
|
|
13471
|
-
}
|
|
13472
|
-
static isActorError(error46) {
|
|
13473
|
-
return isRivetErrorLike(error46);
|
|
13474
|
-
}
|
|
13475
|
-
constructor(group, code, message, options) {
|
|
13476
|
-
const normalized = looksLikeRivetErrorOptions(options) ? options : { metadata: options };
|
|
13477
|
-
super(message, { cause: normalized.cause });
|
|
13478
|
-
this.name = "RivetError";
|
|
13479
|
-
this.group = group;
|
|
13480
|
-
this.code = code;
|
|
13481
|
-
this.public = normalized.public ?? false;
|
|
13482
|
-
this.metadata = normalized.metadata;
|
|
13483
|
-
this.rayId = normalized.rayId ?? void 0;
|
|
13484
|
-
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
13485
|
-
this.actor = normalized.actor;
|
|
13486
|
-
}
|
|
13487
|
-
toString() {
|
|
13488
|
-
return this.message;
|
|
13489
|
-
}
|
|
13490
|
-
};
|
|
13491
|
-
var UserError = class extends RivetError {
|
|
13492
|
-
constructor(message, options) {
|
|
13493
|
-
super("user", (options == null ? void 0 : options.code) ?? USER_ERROR_CODE, message, {
|
|
13494
|
-
public: true,
|
|
13495
|
-
metadata: options == null ? void 0 : options.metadata,
|
|
13496
|
-
cause: options == null ? void 0 : options.cause
|
|
13497
|
-
});
|
|
13498
|
-
}
|
|
13499
|
-
};
|
|
13500
|
-
function toRivetError(error46, fallback) {
|
|
13501
|
-
if (typeof error46 === "string") {
|
|
13502
|
-
const bridged = decodeBridgeRivetError(error46);
|
|
13503
|
-
if (bridged) {
|
|
13504
|
-
return bridged;
|
|
13505
|
-
}
|
|
13506
|
-
}
|
|
13507
|
-
if (error46 instanceof Error) {
|
|
13508
|
-
const bridged = decodeBridgeRivetError(error46.message);
|
|
13509
|
-
if (bridged) {
|
|
13510
|
-
return bridged;
|
|
13511
|
-
}
|
|
13512
|
-
}
|
|
13513
|
-
if (isRivetErrorLike(error46)) {
|
|
13514
|
-
return new RivetError(error46.group, error46.code, error46.message, {
|
|
13515
|
-
public: error46.public,
|
|
13516
|
-
statusCode: error46.statusCode,
|
|
13517
|
-
metadata: error46.metadata,
|
|
13518
|
-
rayId: error46.rayId,
|
|
13519
|
-
actor: error46.actor,
|
|
13520
|
-
cause: error46 instanceof Error ? error46.cause : void 0
|
|
13521
|
-
});
|
|
13522
|
-
}
|
|
13523
|
-
return new RivetError(
|
|
13524
|
-
(fallback == null ? void 0 : fallback.group) ?? "actor",
|
|
13525
|
-
(fallback == null ? void 0 : fallback.code) ?? INTERNAL_ERROR_CODE,
|
|
13526
|
-
errorMessage(error46, (fallback == null ? void 0 : fallback.message) ?? "Unknown error"),
|
|
13527
|
-
{
|
|
13528
|
-
public: fallback == null ? void 0 : fallback.public,
|
|
13529
|
-
statusCode: fallback == null ? void 0 : fallback.statusCode,
|
|
13530
|
-
metadata: fallback == null ? void 0 : fallback.metadata,
|
|
13531
|
-
rayId: fallback == null ? void 0 : fallback.rayId,
|
|
13532
|
-
actor: fallback == null ? void 0 : fallback.actor,
|
|
13533
|
-
cause: error46 instanceof Error ? error46 : void 0
|
|
13534
|
-
}
|
|
13535
|
-
);
|
|
13536
|
-
}
|
|
13537
|
-
function encodeBridgeRivetError(error46) {
|
|
13538
|
-
return `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({
|
|
13539
|
-
group: error46.group,
|
|
13540
|
-
code: error46.code,
|
|
13541
|
-
message: error46.message,
|
|
13542
|
-
metadata: error46.metadata,
|
|
13543
|
-
rayId: error46.rayId,
|
|
13544
|
-
public: error46.public,
|
|
13545
|
-
statusCode: error46.statusCode,
|
|
13546
|
-
actor: error46.actor
|
|
13547
|
-
})}`;
|
|
13548
|
-
}
|
|
13549
|
-
function decodeBridgeRivetErrorPayload(value) {
|
|
13550
|
-
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
13551
|
-
return void 0;
|
|
13552
|
-
}
|
|
13553
|
-
try {
|
|
13554
|
-
const raw = JSON.parse(
|
|
13555
|
-
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
|
|
13556
|
-
);
|
|
13557
|
-
const payload = {
|
|
13558
|
-
...raw,
|
|
13559
|
-
rayId: raw.rayId ?? void 0
|
|
13560
|
-
};
|
|
13561
|
-
if (!isRivetErrorLike(payload)) {
|
|
13562
|
-
return void 0;
|
|
13563
|
-
}
|
|
13564
|
-
if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
|
|
13565
|
-
return void 0;
|
|
13566
|
-
}
|
|
13567
|
-
return payload;
|
|
13568
|
-
} catch {
|
|
13569
|
-
return void 0;
|
|
13570
|
-
}
|
|
13571
|
-
}
|
|
13572
|
-
function decodeBridgeRivetError(value) {
|
|
13573
|
-
const payload = decodeBridgeRivetErrorPayload(value);
|
|
13574
|
-
if (!payload) {
|
|
13575
|
-
return void 0;
|
|
13576
|
-
}
|
|
13577
|
-
return new RivetError(payload.group, payload.code, payload.message, {
|
|
13578
|
-
metadata: payload.metadata,
|
|
13579
|
-
rayId: payload.rayId,
|
|
13580
|
-
public: payload.public,
|
|
13581
|
-
statusCode: payload.statusCode,
|
|
13582
|
-
actor: payload.actor ?? void 0
|
|
13583
|
-
});
|
|
13584
|
-
}
|
|
13585
|
-
function invalidRequest(error46) {
|
|
13586
|
-
return new RivetError(
|
|
13587
|
-
"request",
|
|
13588
|
-
"invalid",
|
|
13589
|
-
`Invalid request: ${errorMessage(error46, String(error46))}`,
|
|
13590
|
-
{
|
|
13591
|
-
public: true,
|
|
13592
|
-
cause: error46 instanceof Error ? error46 : void 0
|
|
13593
|
-
}
|
|
13594
|
-
);
|
|
13595
|
-
}
|
|
13596
|
-
function actorNotFound(identifier) {
|
|
13597
|
-
return new RivetError(
|
|
13598
|
-
"actor",
|
|
13599
|
-
"not_found",
|
|
13600
|
-
identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
|
|
13601
|
-
{ public: true }
|
|
13602
|
-
);
|
|
13603
|
-
}
|
|
13604
|
-
function forbiddenError() {
|
|
13605
|
-
return new RivetError("auth", "forbidden", "Forbidden", {
|
|
13606
|
-
public: true,
|
|
13607
|
-
statusCode: 403
|
|
13608
|
-
});
|
|
13609
|
-
}
|
|
13610
|
-
function unsupportedFeature(feature) {
|
|
13611
|
-
return new RivetError(
|
|
13612
|
-
"feature",
|
|
13613
|
-
"unsupported",
|
|
13614
|
-
`Unsupported feature: ${feature}`
|
|
13615
|
-
);
|
|
13616
|
-
}
|
|
13617
|
-
|
|
13618
|
-
// ../rivetkit/dist/tsup/chunk-O237EWVO.js
|
|
13619
|
-
import {
|
|
13620
|
-
pino,
|
|
13621
|
-
stdTimeFunctions
|
|
13622
|
-
} from "pino";
|
|
13623
|
-
var import_invariant = __toESM(require_invariant(), 1);
|
|
13624
|
-
import * as cbor from "cbor-x";
|
|
13625
|
-
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
13626
|
-
var getRivetEndpoint = () => getEnvUniversal("RIVET_ENDPOINT");
|
|
13627
|
-
var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
|
|
13628
|
-
var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
|
|
13629
|
-
var getRivetPool = () => getEnvUniversal("RIVET_POOL");
|
|
13630
|
-
var getRivetTotalSlots = () => {
|
|
13631
|
-
const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
|
|
13632
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13633
|
-
};
|
|
13634
|
-
var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
|
|
13635
|
-
var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
|
|
13636
|
-
var getRivetRunEnginePort = () => {
|
|
13637
|
-
const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
|
|
13638
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13639
|
-
};
|
|
13640
|
-
var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
|
|
13641
|
-
var getRivetRunServices = () => {
|
|
13642
|
-
const value = getEnvUniversal("RIVET_RUN_SERVICES");
|
|
13643
|
-
return value === void 0 ? void 0 : value === "1";
|
|
13644
|
-
};
|
|
13645
|
-
var getRivetEnvoyVersion = () => {
|
|
13646
|
-
const value = getEnvUniversal("RIVET_ENVOY_VERSION");
|
|
13647
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13648
|
-
};
|
|
13649
|
-
var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
|
|
13650
|
-
var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
|
|
13651
|
-
var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
|
|
13652
|
-
var getRivetkitRuntimeMode = () => {
|
|
13653
|
-
const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
|
|
13654
|
-
if (value === void 0) return "envoy";
|
|
13655
|
-
if (value === "envoy" || value === "serverless") return value;
|
|
13656
|
-
throw new Error(
|
|
13657
|
-
`RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
|
|
13658
|
-
);
|
|
13659
|
-
};
|
|
13660
|
-
var getRivetkitPublicDir = () => {
|
|
13661
|
-
const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
|
|
13662
|
-
return value === void 0 || value === "" ? void 0 : value;
|
|
13663
|
-
};
|
|
13664
|
-
function parsePortEnv(raw) {
|
|
13665
|
-
if (raw === void 0 || raw === "") return void 0;
|
|
13666
|
-
const parsed = Number.parseInt(raw, 10);
|
|
13667
|
-
if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
|
|
13668
|
-
throw new Error(
|
|
13669
|
-
`RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
|
|
13670
|
-
);
|
|
13671
|
-
}
|
|
13672
|
-
return parsed;
|
|
13673
|
-
}
|
|
13674
|
-
var getLogLevel = () => getEnvUniversal("RIVET_LOG_LEVEL") ?? getEnvUniversal("LOG_LEVEL");
|
|
13675
|
-
var getLogTarget = () => getEnvUniversal("RIVET_LOG_TARGET") === "1";
|
|
13676
|
-
var getLogTimestamp = () => getEnvUniversal("RIVET_LOG_TIMESTAMP") === "1";
|
|
13677
|
-
var getLogMessage = () => getEnvUniversal("RIVET_LOG_MESSAGE") === "1";
|
|
13678
|
-
var getLogErrorStack = () => getEnvUniversal("RIVET_LOG_ERROR_STACK") === "1";
|
|
13679
|
-
var getNodeEnv = () => getEnvUniversal("NODE_ENV");
|
|
13680
|
-
var getNextPhase = () => getEnvUniversal("NEXT_PHASE");
|
|
13681
|
-
var isDev = () => getNodeEnv() !== "production";
|
|
13682
|
-
function assertUnreachable(x) {
|
|
13683
|
-
throw new Error(`Unreachable case: ${x}`);
|
|
13684
|
-
}
|
|
13685
|
-
function isCanonicalStructuredRivetError(error46) {
|
|
13686
|
-
return error46 instanceof RivetError || typeof error46 === "object" && error46 !== null && "__type" in error46 && error46.__type === "RivetError" && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string";
|
|
13687
|
-
}
|
|
13688
|
-
function deconstructError(error46, exposeInternalError = false) {
|
|
13689
|
-
let statusCode;
|
|
13690
|
-
let public_;
|
|
13691
|
-
let group;
|
|
13692
|
-
let code;
|
|
13693
|
-
let message;
|
|
13694
|
-
let metadata;
|
|
13695
|
-
let rayId;
|
|
13696
|
-
let actor2;
|
|
13697
|
-
if (isCanonicalStructuredRivetError(error46)) {
|
|
13698
|
-
statusCode = typeof error46.statusCode === "number" ? error46.statusCode : error46.public ? 400 : 500;
|
|
13699
|
-
public_ = error46.public ?? false;
|
|
13700
|
-
group = error46.group;
|
|
13701
|
-
code = error46.code;
|
|
13702
|
-
message = error46.message;
|
|
13703
|
-
metadata = error46.metadata;
|
|
13704
|
-
rayId = error46.rayId;
|
|
13705
|
-
actor2 = error46.actor;
|
|
13706
|
-
} else if (RivetError.isActorError(error46) && error46.public) {
|
|
13707
|
-
statusCode = "statusCode" in error46 && error46.statusCode ? error46.statusCode : 400;
|
|
13708
|
-
public_ = true;
|
|
13709
|
-
group = error46.group;
|
|
13710
|
-
code = error46.code;
|
|
13711
|
-
message = getErrorMessage(error46);
|
|
13712
|
-
metadata = error46.metadata;
|
|
13713
|
-
rayId = error46.rayId;
|
|
13714
|
-
actor2 = error46.actor;
|
|
13715
|
-
} else if (exposeInternalError) {
|
|
13716
|
-
if (RivetError.isActorError(error46)) {
|
|
13717
|
-
statusCode = 500;
|
|
13718
|
-
public_ = false;
|
|
13719
|
-
group = error46.group;
|
|
13720
|
-
code = error46.code;
|
|
13721
|
-
message = getErrorMessage(error46);
|
|
13722
|
-
metadata = error46.metadata;
|
|
13723
|
-
rayId = error46.rayId;
|
|
13724
|
-
actor2 = error46.actor;
|
|
13725
|
-
} else {
|
|
13726
|
-
statusCode = 500;
|
|
13727
|
-
public_ = false;
|
|
13728
|
-
group = "rivetkit";
|
|
13729
|
-
code = INTERNAL_ERROR_CODE;
|
|
13730
|
-
message = getErrorMessage(error46);
|
|
13731
|
-
}
|
|
13732
|
-
} else {
|
|
13733
|
-
statusCode = 500;
|
|
13734
|
-
public_ = false;
|
|
13735
|
-
group = "rivetkit";
|
|
13736
|
-
code = INTERNAL_ERROR_CODE;
|
|
13737
|
-
message = INTERNAL_ERROR_DESCRIPTION;
|
|
13738
|
-
if (RivetError.isActorError(error46)) {
|
|
13739
|
-
actor2 = error46.actor;
|
|
13740
|
-
}
|
|
13741
|
-
metadata = {
|
|
13742
|
-
//url: `https://dashboard.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,
|
|
13743
|
-
};
|
|
13744
|
-
}
|
|
13745
|
-
return {
|
|
13746
|
-
__type: "ActorError",
|
|
13747
|
-
statusCode,
|
|
13748
|
-
public: public_,
|
|
13749
|
-
group,
|
|
13750
|
-
code,
|
|
13751
|
-
message,
|
|
13752
|
-
metadata,
|
|
13753
|
-
rayId,
|
|
13754
|
-
actor: actor2
|
|
13755
|
-
};
|
|
13756
|
-
}
|
|
13757
|
-
function stringifyError(error46) {
|
|
13758
|
-
if (error46 instanceof Error) {
|
|
13759
|
-
if (typeof process !== "undefined" && getLogErrorStack()) {
|
|
13760
|
-
let stack;
|
|
13761
|
-
try {
|
|
13762
|
-
stack = error46.stack;
|
|
13763
|
-
} catch {
|
|
13764
|
-
stack = void 0;
|
|
13765
|
-
}
|
|
13766
|
-
return `${error46.name}: ${error46.message}${stack ? `
|
|
13767
|
-
${stack}` : ""}`;
|
|
13768
|
-
} else {
|
|
13769
|
-
return `${error46.name}: ${error46.message}`;
|
|
13770
|
-
}
|
|
13771
|
-
} else if (typeof error46 === "string") {
|
|
13772
|
-
return error46;
|
|
13773
|
-
} else if (typeof error46 === "object" && error46 !== null) {
|
|
13774
|
-
try {
|
|
13775
|
-
return `${JSON.stringify(error46)}`;
|
|
13776
|
-
} catch {
|
|
13777
|
-
return "[cannot stringify error]";
|
|
13778
|
-
}
|
|
13779
|
-
} else {
|
|
13780
|
-
return `Unknown error: ${getErrorMessage(error46)}`;
|
|
13781
|
-
}
|
|
13782
|
-
}
|
|
13783
|
-
function getErrorMessage(err) {
|
|
13784
|
-
if (err && typeof err === "object" && "message" in err && typeof err.message === "string") {
|
|
13785
|
-
return err.message;
|
|
13786
|
-
} else {
|
|
13787
|
-
return String(err);
|
|
13788
|
-
}
|
|
13789
|
-
}
|
|
13790
|
-
function noopNext() {
|
|
13791
|
-
return async () => {
|
|
13792
|
-
};
|
|
13328
|
+
function noopNext() {
|
|
13329
|
+
return async () => {
|
|
13330
|
+
};
|
|
13793
13331
|
}
|
|
13794
13332
|
var package_default = {
|
|
13795
13333
|
name: "rivetkit",
|
|
13796
|
-
version: "2.3.18-rc.
|
|
13334
|
+
version: "2.3.18-rc.3",
|
|
13797
13335
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13798
13336
|
license: "Apache-2.0",
|
|
13799
13337
|
keywords: [
|
|
@@ -15097,7 +14635,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
|
|
|
15097
14635
|
};
|
|
15098
14636
|
}
|
|
15099
14637
|
|
|
15100
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14638
|
+
// ../rivetkit/dist/tsup/chunk-LWGP653X.js
|
|
15101
14639
|
var config2 = /* @__PURE__ */ Config({});
|
|
15102
14640
|
function readWorkflowCbor(bc) {
|
|
15103
14641
|
return readData(bc);
|
|
@@ -15188,57 +14726,181 @@ function readWorkflowBranchStatusType(bc) {
|
|
|
15188
14726
|
case 3:
|
|
15189
14727
|
return "FAILED";
|
|
15190
14728
|
case 4:
|
|
15191
|
-
return "CANCELLED";
|
|
14729
|
+
return "CANCELLED";
|
|
14730
|
+
default: {
|
|
14731
|
+
bc.offset = offset;
|
|
14732
|
+
throw new BareError(offset, "invalid tag");
|
|
14733
|
+
}
|
|
14734
|
+
}
|
|
14735
|
+
}
|
|
14736
|
+
function read0(bc) {
|
|
14737
|
+
return readBool(bc) ? readWorkflowCbor(bc) : null;
|
|
14738
|
+
}
|
|
14739
|
+
function read1(bc) {
|
|
14740
|
+
return readBool(bc) ? readString(bc) : null;
|
|
14741
|
+
}
|
|
14742
|
+
function readWorkflowStepEntry(bc) {
|
|
14743
|
+
return {
|
|
14744
|
+
output: read0(bc),
|
|
14745
|
+
error: read1(bc)
|
|
14746
|
+
};
|
|
14747
|
+
}
|
|
14748
|
+
function readWorkflowLoopEntry(bc) {
|
|
14749
|
+
return {
|
|
14750
|
+
state: readWorkflowCbor(bc),
|
|
14751
|
+
iteration: readU32(bc),
|
|
14752
|
+
output: read0(bc)
|
|
14753
|
+
};
|
|
14754
|
+
}
|
|
14755
|
+
function readWorkflowSleepEntry(bc) {
|
|
14756
|
+
return {
|
|
14757
|
+
deadline: readU64(bc),
|
|
14758
|
+
state: readWorkflowSleepState(bc)
|
|
14759
|
+
};
|
|
14760
|
+
}
|
|
14761
|
+
function readWorkflowMessageEntry(bc) {
|
|
14762
|
+
return {
|
|
14763
|
+
name: readString(bc),
|
|
14764
|
+
messageData: readWorkflowCbor(bc)
|
|
14765
|
+
};
|
|
14766
|
+
}
|
|
14767
|
+
function readWorkflowRollbackCheckpointEntry(bc) {
|
|
14768
|
+
return {
|
|
14769
|
+
name: readString(bc)
|
|
14770
|
+
};
|
|
14771
|
+
}
|
|
14772
|
+
function readWorkflowBranchStatus(bc) {
|
|
14773
|
+
return {
|
|
14774
|
+
status: readWorkflowBranchStatusType(bc),
|
|
14775
|
+
output: read0(bc),
|
|
14776
|
+
error: read1(bc)
|
|
14777
|
+
};
|
|
14778
|
+
}
|
|
14779
|
+
function read2(bc) {
|
|
14780
|
+
const len = readUintSafe(bc);
|
|
14781
|
+
const result = /* @__PURE__ */ new Map();
|
|
14782
|
+
for (let i = 0; i < len; i++) {
|
|
14783
|
+
const offset = bc.offset;
|
|
14784
|
+
const key = readString(bc);
|
|
14785
|
+
if (result.has(key)) {
|
|
14786
|
+
bc.offset = offset;
|
|
14787
|
+
throw new BareError(offset, "duplicated key");
|
|
14788
|
+
}
|
|
14789
|
+
result.set(key, readWorkflowBranchStatus(bc));
|
|
14790
|
+
}
|
|
14791
|
+
return result;
|
|
14792
|
+
}
|
|
14793
|
+
function readWorkflowJoinEntry(bc) {
|
|
14794
|
+
return {
|
|
14795
|
+
branches: read2(bc)
|
|
14796
|
+
};
|
|
14797
|
+
}
|
|
14798
|
+
function readWorkflowRaceEntry(bc) {
|
|
14799
|
+
return {
|
|
14800
|
+
winner: read1(bc),
|
|
14801
|
+
branches: read2(bc)
|
|
14802
|
+
};
|
|
14803
|
+
}
|
|
14804
|
+
function readWorkflowRemovedEntry(bc) {
|
|
14805
|
+
return {
|
|
14806
|
+
originalType: readString(bc),
|
|
14807
|
+
originalName: read1(bc)
|
|
14808
|
+
};
|
|
14809
|
+
}
|
|
14810
|
+
function readWorkflowVersionCheckEntry(bc) {
|
|
14811
|
+
return {
|
|
14812
|
+
resolved: readU32(bc),
|
|
14813
|
+
latest: readU32(bc)
|
|
14814
|
+
};
|
|
14815
|
+
}
|
|
14816
|
+
function readWorkflowEntryKind(bc) {
|
|
14817
|
+
const offset = bc.offset;
|
|
14818
|
+
const tag = readU8(bc);
|
|
14819
|
+
switch (tag) {
|
|
14820
|
+
case 0:
|
|
14821
|
+
return { tag: "WorkflowStepEntry", val: readWorkflowStepEntry(bc) };
|
|
14822
|
+
case 1:
|
|
14823
|
+
return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
|
|
14824
|
+
case 2:
|
|
14825
|
+
return {
|
|
14826
|
+
tag: "WorkflowSleepEntry",
|
|
14827
|
+
val: readWorkflowSleepEntry(bc)
|
|
14828
|
+
};
|
|
14829
|
+
case 3:
|
|
14830
|
+
return {
|
|
14831
|
+
tag: "WorkflowMessageEntry",
|
|
14832
|
+
val: readWorkflowMessageEntry(bc)
|
|
14833
|
+
};
|
|
14834
|
+
case 4:
|
|
14835
|
+
return {
|
|
14836
|
+
tag: "WorkflowRollbackCheckpointEntry",
|
|
14837
|
+
val: readWorkflowRollbackCheckpointEntry(bc)
|
|
14838
|
+
};
|
|
14839
|
+
case 5:
|
|
14840
|
+
return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
|
|
14841
|
+
case 6:
|
|
14842
|
+
return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
|
|
14843
|
+
case 7:
|
|
14844
|
+
return {
|
|
14845
|
+
tag: "WorkflowRemovedEntry",
|
|
14846
|
+
val: readWorkflowRemovedEntry(bc)
|
|
14847
|
+
};
|
|
14848
|
+
case 8:
|
|
14849
|
+
return {
|
|
14850
|
+
tag: "WorkflowVersionCheckEntry",
|
|
14851
|
+
val: readWorkflowVersionCheckEntry(bc)
|
|
14852
|
+
};
|
|
15192
14853
|
default: {
|
|
15193
14854
|
bc.offset = offset;
|
|
15194
14855
|
throw new BareError(offset, "invalid tag");
|
|
15195
14856
|
}
|
|
15196
14857
|
}
|
|
15197
14858
|
}
|
|
15198
|
-
function
|
|
15199
|
-
return readBool(bc) ? readWorkflowCbor(bc) : null;
|
|
15200
|
-
}
|
|
15201
|
-
function read1(bc) {
|
|
15202
|
-
return readBool(bc) ? readString(bc) : null;
|
|
15203
|
-
}
|
|
15204
|
-
function readWorkflowStepEntry(bc) {
|
|
15205
|
-
return {
|
|
15206
|
-
output: read0(bc),
|
|
15207
|
-
error: read1(bc)
|
|
15208
|
-
};
|
|
15209
|
-
}
|
|
15210
|
-
function readWorkflowLoopEntry(bc) {
|
|
14859
|
+
function readWorkflowEntry(bc) {
|
|
15211
14860
|
return {
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
14861
|
+
id: readString(bc),
|
|
14862
|
+
location: readWorkflowLocation(bc),
|
|
14863
|
+
kind: readWorkflowEntryKind(bc)
|
|
15215
14864
|
};
|
|
15216
14865
|
}
|
|
15217
|
-
function
|
|
15218
|
-
return
|
|
15219
|
-
deadline: readU64(bc),
|
|
15220
|
-
state: readWorkflowSleepState(bc)
|
|
15221
|
-
};
|
|
14866
|
+
function read3(bc) {
|
|
14867
|
+
return readBool(bc) ? readU64(bc) : null;
|
|
15222
14868
|
}
|
|
15223
|
-
function
|
|
14869
|
+
function readWorkflowEntryMetadata(bc) {
|
|
15224
14870
|
return {
|
|
15225
|
-
|
|
15226
|
-
|
|
14871
|
+
status: readWorkflowEntryStatus(bc),
|
|
14872
|
+
error: read1(bc),
|
|
14873
|
+
attempts: readU32(bc),
|
|
14874
|
+
lastAttemptAt: readU64(bc),
|
|
14875
|
+
createdAt: readU64(bc),
|
|
14876
|
+
completedAt: read3(bc),
|
|
14877
|
+
rollbackCompletedAt: read3(bc),
|
|
14878
|
+
rollbackError: read1(bc)
|
|
15227
14879
|
};
|
|
15228
14880
|
}
|
|
15229
|
-
function
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
14881
|
+
function read4(bc) {
|
|
14882
|
+
const len = readUintSafe(bc);
|
|
14883
|
+
if (len === 0) {
|
|
14884
|
+
return [];
|
|
14885
|
+
}
|
|
14886
|
+
const result = [readString(bc)];
|
|
14887
|
+
for (let i = 1; i < len; i++) {
|
|
14888
|
+
result[i] = readString(bc);
|
|
14889
|
+
}
|
|
14890
|
+
return result;
|
|
15233
14891
|
}
|
|
15234
|
-
function
|
|
15235
|
-
|
|
15236
|
-
|
|
15237
|
-
|
|
15238
|
-
|
|
15239
|
-
|
|
14892
|
+
function read5(bc) {
|
|
14893
|
+
const len = readUintSafe(bc);
|
|
14894
|
+
if (len === 0) {
|
|
14895
|
+
return [];
|
|
14896
|
+
}
|
|
14897
|
+
const result = [readWorkflowEntry(bc)];
|
|
14898
|
+
for (let i = 1; i < len; i++) {
|
|
14899
|
+
result[i] = readWorkflowEntry(bc);
|
|
14900
|
+
}
|
|
14901
|
+
return result;
|
|
15240
14902
|
}
|
|
15241
|
-
function
|
|
14903
|
+
function read6(bc) {
|
|
15242
14904
|
const len = readUintSafe(bc);
|
|
15243
14905
|
const result = /* @__PURE__ */ new Map();
|
|
15244
14906
|
for (let i = 0; i < len; i++) {
|
|
@@ -15248,152 +14910,492 @@ function read2(bc) {
|
|
|
15248
14910
|
bc.offset = offset;
|
|
15249
14911
|
throw new BareError(offset, "duplicated key");
|
|
15250
14912
|
}
|
|
15251
|
-
result.set(key,
|
|
14913
|
+
result.set(key, readWorkflowEntryMetadata(bc));
|
|
14914
|
+
}
|
|
14915
|
+
return result;
|
|
14916
|
+
}
|
|
14917
|
+
function readWorkflowHistory(bc) {
|
|
14918
|
+
return {
|
|
14919
|
+
nameRegistry: read4(bc),
|
|
14920
|
+
entries: read5(bc),
|
|
14921
|
+
entryMetadata: read6(bc)
|
|
14922
|
+
};
|
|
14923
|
+
}
|
|
14924
|
+
function decodeWorkflowHistory(bytes) {
|
|
14925
|
+
const bc = new ByteCursor(bytes, config2);
|
|
14926
|
+
const result = readWorkflowHistory(bc);
|
|
14927
|
+
if (bc.offset < bc.view.byteLength) {
|
|
14928
|
+
throw new BareError(bc.offset, "remaining bytes");
|
|
14929
|
+
}
|
|
14930
|
+
return result;
|
|
14931
|
+
}
|
|
14932
|
+
function decodeWorkflowHistoryTransport(data) {
|
|
14933
|
+
return decodeWorkflowHistory(toUint8Array(data));
|
|
14934
|
+
}
|
|
14935
|
+
|
|
14936
|
+
// ../rivetkit/dist/tsup/chunk-6W5VGLFT.js
|
|
14937
|
+
function flattenActionHandlers(actions) {
|
|
14938
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14939
|
+
for (const { name, handler } of collectActionEntries(actions)) {
|
|
14940
|
+
flattened[name] = handler;
|
|
14941
|
+
}
|
|
14942
|
+
return flattened;
|
|
14943
|
+
}
|
|
14944
|
+
function flattenActionInputSchemas(actions, schemas) {
|
|
14945
|
+
if (schemas === void 0) return void 0;
|
|
14946
|
+
if (!isRecord(schemas)) {
|
|
14947
|
+
throw new TypeError("actionInputSchemas must be an object");
|
|
14948
|
+
}
|
|
14949
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14950
|
+
for (const { name, path: path2 } of collectActionEntries(actions)) {
|
|
14951
|
+
const nestedSchema = lookupNestedSchema(schemas, path2);
|
|
14952
|
+
const flatSchema = schemas[name];
|
|
14953
|
+
if (nestedSchema !== void 0 && flatSchema !== void 0 && nestedSchema !== flatSchema) {
|
|
14954
|
+
throw new TypeError(
|
|
14955
|
+
`Action input schema \`${name}\` is defined by both a nested path and a dotted key`
|
|
14956
|
+
);
|
|
14957
|
+
}
|
|
14958
|
+
const schema = nestedSchema ?? flatSchema;
|
|
14959
|
+
if (schema !== void 0) {
|
|
14960
|
+
flattened[name] = schema;
|
|
14961
|
+
}
|
|
14962
|
+
}
|
|
14963
|
+
return flattened;
|
|
14964
|
+
}
|
|
14965
|
+
function collectActionEntries(actions) {
|
|
14966
|
+
const entries = [];
|
|
14967
|
+
const names = /* @__PURE__ */ new Set();
|
|
14968
|
+
visitActionGroup(actions ?? {}, [], entries, names);
|
|
14969
|
+
return entries;
|
|
14970
|
+
}
|
|
14971
|
+
function visitActionGroup(value, path2, entries, names) {
|
|
14972
|
+
if (!isRecord(value)) {
|
|
14973
|
+
throw new TypeError(
|
|
14974
|
+
`${formatActionPath(path2)} must be an action handler or group`
|
|
14975
|
+
);
|
|
14976
|
+
}
|
|
14977
|
+
for (const [segment, child] of Object.entries(value)) {
|
|
14978
|
+
const childPath = [...path2, segment];
|
|
14979
|
+
if (typeof child === "function") {
|
|
14980
|
+
const name = childPath.join(".");
|
|
14981
|
+
if (names.has(name)) {
|
|
14982
|
+
throw new TypeError(
|
|
14983
|
+
`Multiple action definitions flatten to \`${name}\``
|
|
14984
|
+
);
|
|
14985
|
+
}
|
|
14986
|
+
names.add(name);
|
|
14987
|
+
entries.push({
|
|
14988
|
+
name,
|
|
14989
|
+
path: childPath,
|
|
14990
|
+
handler: child
|
|
14991
|
+
});
|
|
14992
|
+
} else {
|
|
14993
|
+
visitActionGroup(child, childPath, entries, names);
|
|
14994
|
+
}
|
|
14995
|
+
}
|
|
14996
|
+
}
|
|
14997
|
+
function lookupNestedSchema(schemas, path2) {
|
|
14998
|
+
let value = schemas;
|
|
14999
|
+
for (const segment of path2) {
|
|
15000
|
+
if (!isRecord(value) || !Object.hasOwn(value, segment)) {
|
|
15001
|
+
return void 0;
|
|
15002
|
+
}
|
|
15003
|
+
value = value[segment];
|
|
15004
|
+
}
|
|
15005
|
+
return value;
|
|
15006
|
+
}
|
|
15007
|
+
function isRecord(value) {
|
|
15008
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15009
|
+
return false;
|
|
15010
|
+
}
|
|
15011
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15012
|
+
return prototype === Object.prototype || prototype === null;
|
|
15013
|
+
}
|
|
15014
|
+
function formatActionPath(path2) {
|
|
15015
|
+
return path2.length === 0 ? "actions" : `Action \`${path2.join(".")}\``;
|
|
15016
|
+
}
|
|
15017
|
+
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
15018
|
+
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
15019
|
+
"rivetkit.actor_context_internal"
|
|
15020
|
+
);
|
|
15021
|
+
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
15022
|
+
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
15023
|
+
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
15024
|
+
var zActionTree = external_exports.custom((value) => {
|
|
15025
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15026
|
+
return false;
|
|
15027
|
+
}
|
|
15028
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15029
|
+
return prototype === Object.prototype || prototype === null;
|
|
15030
|
+
}).superRefine((actions, ctx) => {
|
|
15031
|
+
try {
|
|
15032
|
+
flattenActionHandlers(actions);
|
|
15033
|
+
} catch (error46) {
|
|
15034
|
+
ctx.addIssue({
|
|
15035
|
+
code: "custom",
|
|
15036
|
+
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
15037
|
+
});
|
|
15038
|
+
}
|
|
15039
|
+
});
|
|
15040
|
+
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
15041
|
+
getHistory: zFunction(),
|
|
15042
|
+
getState: zFunction().optional(),
|
|
15043
|
+
onHistoryUpdated: zFunction().optional(),
|
|
15044
|
+
replayFromStep: zFunction().optional()
|
|
15045
|
+
});
|
|
15046
|
+
var RunInspectorConfigSchema = external_exports.object({
|
|
15047
|
+
workflow: WorkflowInspectorConfigSchema.optional()
|
|
15048
|
+
}).optional();
|
|
15049
|
+
var BUILTIN_INSPECTOR_TAB_IDS = [
|
|
15050
|
+
"workflow",
|
|
15051
|
+
"database",
|
|
15052
|
+
"state",
|
|
15053
|
+
"queue",
|
|
15054
|
+
"schedules",
|
|
15055
|
+
"connections",
|
|
15056
|
+
"console"
|
|
15057
|
+
];
|
|
15058
|
+
var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
|
|
15059
|
+
var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
15060
|
+
var CustomInspectorTabEntrySchema = external_exports.object({
|
|
15061
|
+
id: external_exports.string().regex(
|
|
15062
|
+
CUSTOM_INSPECTOR_TAB_ID_RE,
|
|
15063
|
+
"inspector.tabs[].id must contain only letters, digits, underscore, or dash"
|
|
15064
|
+
),
|
|
15065
|
+
label: external_exports.string().min(1),
|
|
15066
|
+
source: external_exports.string().min(1),
|
|
15067
|
+
/**
|
|
15068
|
+
* Optional icon id. The dashboard maps strings to glyphs (see its
|
|
15069
|
+
* icon registry); unknown ids fall back to a generic icon.
|
|
15070
|
+
*/
|
|
15071
|
+
icon: external_exports.string().min(1).optional(),
|
|
15072
|
+
hidden: external_exports.literal(false).optional()
|
|
15073
|
+
}).strict();
|
|
15074
|
+
var HideInspectorTabEntrySchema = external_exports.object({
|
|
15075
|
+
id: BuiltinInspectorTabIdSchema,
|
|
15076
|
+
hidden: external_exports.literal(true)
|
|
15077
|
+
}).strict();
|
|
15078
|
+
var InspectorTabEntrySchema = external_exports.union([
|
|
15079
|
+
CustomInspectorTabEntrySchema,
|
|
15080
|
+
HideInspectorTabEntrySchema
|
|
15081
|
+
]);
|
|
15082
|
+
var ActorInspectorConfigSchema = external_exports.object({
|
|
15083
|
+
tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
|
|
15084
|
+
}).strict().refine(
|
|
15085
|
+
(data) => {
|
|
15086
|
+
const ids = data.tabs.map((t) => t.id);
|
|
15087
|
+
return new Set(ids).size === ids.length;
|
|
15088
|
+
},
|
|
15089
|
+
{ message: "Duplicate id in inspector.tabs", path: ["tabs"] }
|
|
15090
|
+
).refine(
|
|
15091
|
+
(data) => {
|
|
15092
|
+
const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
|
|
15093
|
+
return data.tabs.every(
|
|
15094
|
+
(t) => t.hidden === true || !builtinSet.has(t.id)
|
|
15095
|
+
);
|
|
15096
|
+
},
|
|
15097
|
+
{
|
|
15098
|
+
message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
|
|
15099
|
+
path: ["tabs"]
|
|
15252
15100
|
}
|
|
15253
|
-
|
|
15254
|
-
|
|
15255
|
-
|
|
15256
|
-
|
|
15257
|
-
|
|
15258
|
-
|
|
15101
|
+
);
|
|
15102
|
+
var RunConfigSchema = external_exports.object({
|
|
15103
|
+
/** Display name for the actor in the Inspector UI. */
|
|
15104
|
+
name: external_exports.string().optional(),
|
|
15105
|
+
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
15106
|
+
icon: external_exports.string().optional(),
|
|
15107
|
+
/** The run handler function. */
|
|
15108
|
+
run: zFunction(),
|
|
15109
|
+
/** Inspector integration for long-running run handlers. */
|
|
15110
|
+
inspector: RunInspectorConfigSchema.optional()
|
|
15111
|
+
});
|
|
15112
|
+
var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for("rivetkit.run_function_config");
|
|
15113
|
+
function defineRunHandler(run, options) {
|
|
15114
|
+
if (options.inspectorKind === void 0 !== (options.createInspector === void 0)) {
|
|
15115
|
+
throw new TypeError(
|
|
15116
|
+
"defineRunHandler requires inspectorKind and createInspector together"
|
|
15117
|
+
);
|
|
15118
|
+
}
|
|
15119
|
+
Object.defineProperty(run, RUN_FUNCTION_CONFIG_SYMBOL, {
|
|
15120
|
+
configurable: false,
|
|
15121
|
+
enumerable: false,
|
|
15122
|
+
writable: false,
|
|
15123
|
+
value: {
|
|
15124
|
+
name: options.name,
|
|
15125
|
+
icon: options.icon,
|
|
15126
|
+
inspectorKind: options.inspectorKind,
|
|
15127
|
+
createInspector: options.createInspector
|
|
15128
|
+
}
|
|
15129
|
+
});
|
|
15130
|
+
return run;
|
|
15259
15131
|
}
|
|
15260
|
-
function
|
|
15261
|
-
|
|
15262
|
-
|
|
15263
|
-
|
|
15264
|
-
};
|
|
15132
|
+
function getRunInspectorKind(run) {
|
|
15133
|
+
var _a2;
|
|
15134
|
+
if (!run || typeof run !== "function") return void 0;
|
|
15135
|
+
return (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.inspectorKind;
|
|
15265
15136
|
}
|
|
15266
|
-
function
|
|
15267
|
-
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
};
|
|
15137
|
+
function createRunInspector(run, context) {
|
|
15138
|
+
var _a2, _b;
|
|
15139
|
+
if (!run || typeof run !== "function") return void 0;
|
|
15140
|
+
return (_b = (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.createInspector) == null ? void 0 : _b.call(_a2, context);
|
|
15271
15141
|
}
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15142
|
+
var zRunHandler = external_exports.union([zFunction(), RunConfigSchema]).optional();
|
|
15143
|
+
function getRunFunction(run) {
|
|
15144
|
+
if (!run) return void 0;
|
|
15145
|
+
if (typeof run === "function") return run;
|
|
15146
|
+
return run.run;
|
|
15277
15147
|
}
|
|
15278
|
-
function
|
|
15279
|
-
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15284
|
-
case 1:
|
|
15285
|
-
return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
|
|
15286
|
-
case 2:
|
|
15287
|
-
return {
|
|
15288
|
-
tag: "WorkflowSleepEntry",
|
|
15289
|
-
val: readWorkflowSleepEntry(bc)
|
|
15290
|
-
};
|
|
15291
|
-
case 3:
|
|
15292
|
-
return {
|
|
15293
|
-
tag: "WorkflowMessageEntry",
|
|
15294
|
-
val: readWorkflowMessageEntry(bc)
|
|
15295
|
-
};
|
|
15296
|
-
case 4:
|
|
15297
|
-
return {
|
|
15298
|
-
tag: "WorkflowRollbackCheckpointEntry",
|
|
15299
|
-
val: readWorkflowRollbackCheckpointEntry(bc)
|
|
15300
|
-
};
|
|
15301
|
-
case 5:
|
|
15302
|
-
return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
|
|
15303
|
-
case 6:
|
|
15304
|
-
return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
|
|
15305
|
-
case 7:
|
|
15306
|
-
return {
|
|
15307
|
-
tag: "WorkflowRemovedEntry",
|
|
15308
|
-
val: readWorkflowRemovedEntry(bc)
|
|
15309
|
-
};
|
|
15310
|
-
case 8:
|
|
15311
|
-
return {
|
|
15312
|
-
tag: "WorkflowVersionCheckEntry",
|
|
15313
|
-
val: readWorkflowVersionCheckEntry(bc)
|
|
15314
|
-
};
|
|
15315
|
-
default: {
|
|
15316
|
-
bc.offset = offset;
|
|
15317
|
-
throw new BareError(offset, "invalid tag");
|
|
15318
|
-
}
|
|
15148
|
+
function getRunMetadata(run) {
|
|
15149
|
+
if (!run) return {};
|
|
15150
|
+
if (typeof run === "function") {
|
|
15151
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15152
|
+
if (!config3) return {};
|
|
15153
|
+
return { name: config3.name, icon: config3.icon };
|
|
15319
15154
|
}
|
|
15155
|
+
return { name: run.name, icon: run.icon };
|
|
15320
15156
|
}
|
|
15321
|
-
function
|
|
15322
|
-
return
|
|
15323
|
-
|
|
15324
|
-
|
|
15325
|
-
|
|
15326
|
-
}
|
|
15327
|
-
|
|
15328
|
-
function read3(bc) {
|
|
15329
|
-
return readBool(bc) ? readU64(bc) : null;
|
|
15157
|
+
function getRunInspectorConfig(run, actor2) {
|
|
15158
|
+
if (!run) return void 0;
|
|
15159
|
+
if (typeof run === "function") {
|
|
15160
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15161
|
+
return (config3 == null ? void 0 : config3.inspectorFactory) ? config3.inspectorFactory(actor2) : config3 == null ? void 0 : config3.inspector;
|
|
15162
|
+
}
|
|
15163
|
+
return run.inspector;
|
|
15330
15164
|
}
|
|
15331
|
-
function
|
|
15332
|
-
return
|
|
15333
|
-
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
lastAttemptAt: readU64(bc),
|
|
15337
|
-
createdAt: readU64(bc),
|
|
15338
|
-
completedAt: read3(bc),
|
|
15339
|
-
rollbackCompletedAt: read3(bc),
|
|
15340
|
-
rollbackError: read1(bc)
|
|
15341
|
-
};
|
|
15165
|
+
function hasRunInspectorConfig(run) {
|
|
15166
|
+
if (!run) return false;
|
|
15167
|
+
if (typeof run !== "function") return run.inspector !== void 0;
|
|
15168
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15169
|
+
return (config3 == null ? void 0 : config3.inspectorKind) !== void 0 || (config3 == null ? void 0 : config3.createInspector) !== void 0 || (config3 == null ? void 0 : config3.inspector) !== void 0 || (config3 == null ? void 0 : config3.inspectorFactory) !== void 0;
|
|
15342
15170
|
}
|
|
15343
|
-
function
|
|
15344
|
-
|
|
15345
|
-
if (
|
|
15346
|
-
return
|
|
15347
|
-
}
|
|
15348
|
-
const result = [readString(bc)];
|
|
15349
|
-
for (let i = 1; i < len; i++) {
|
|
15350
|
-
result[i] = readString(bc);
|
|
15171
|
+
function disposeRunInspector(run, actorId) {
|
|
15172
|
+
var _a2;
|
|
15173
|
+
if (!run || typeof run !== "function") {
|
|
15174
|
+
return;
|
|
15351
15175
|
}
|
|
15352
|
-
|
|
15176
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15177
|
+
(_a2 = config3 == null ? void 0 : config3.disposeInspector) == null ? void 0 : _a2.call(config3, actorId);
|
|
15353
15178
|
}
|
|
15354
|
-
|
|
15355
|
-
|
|
15356
|
-
|
|
15357
|
-
|
|
15358
|
-
|
|
15359
|
-
|
|
15360
|
-
|
|
15361
|
-
|
|
15179
|
+
var GlobalActorOptionsBaseSchema = external_exports.object({
|
|
15180
|
+
/** Display name for the actor in the Inspector UI. */
|
|
15181
|
+
name: external_exports.string().optional(),
|
|
15182
|
+
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
15183
|
+
icon: external_exports.string().optional(),
|
|
15184
|
+
/** Enables the experimental Actor Runtime Socket for this actor. */
|
|
15185
|
+
enableActorRuntimeSocket: external_exports.boolean().default(false),
|
|
15186
|
+
/**
|
|
15187
|
+
* Can hibernate WebSockets for onWebSocket.
|
|
15188
|
+
*
|
|
15189
|
+
* WebSockets using actions/events are hibernatable by default.
|
|
15190
|
+
*
|
|
15191
|
+
* @experimental
|
|
15192
|
+
**/
|
|
15193
|
+
canHibernateWebSocket: external_exports.union([external_exports.boolean(), zFunction()]).default(false)
|
|
15194
|
+
}).strict();
|
|
15195
|
+
var GlobalActorOptionsSchema = GlobalActorOptionsBaseSchema.prefault(
|
|
15196
|
+
() => ({})
|
|
15197
|
+
);
|
|
15198
|
+
var InstanceActorOptionsBaseSchema = external_exports.object({
|
|
15199
|
+
createVarsTimeout: external_exports.number().positive().default(5e3),
|
|
15200
|
+
createConnStateTimeout: external_exports.number().positive().default(5e3),
|
|
15201
|
+
onBeforeConnectTimeout: external_exports.number().positive().default(5e3),
|
|
15202
|
+
onConnectTimeout: external_exports.number().positive().default(5e3),
|
|
15203
|
+
onMigrateTimeout: external_exports.number().positive().default(3e4),
|
|
15204
|
+
sleepGracePeriod: external_exports.number().positive().default(DEFAULT_SLEEP_GRACE_PERIOD),
|
|
15205
|
+
/** @deprecated `onDestroyTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
|
|
15206
|
+
onDestroyTimeout: external_exports.number().positive().optional(),
|
|
15207
|
+
/** @deprecated `waitUntilTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
|
|
15208
|
+
waitUntilTimeout: external_exports.number().positive().optional(),
|
|
15209
|
+
stateSaveInterval: external_exports.number().positive().default(1e3),
|
|
15210
|
+
actionTimeout: external_exports.number().positive().default(6e4),
|
|
15211
|
+
connectionLivenessTimeout: external_exports.number().positive().default(2500),
|
|
15212
|
+
connectionLivenessInterval: external_exports.number().positive().default(5e3),
|
|
15213
|
+
/** @deprecated Use `c.keepAwake(promise)` to scope keep-awake to a specific operation, or keep `noSleep` for actors that must stay awake indefinitely. Will be removed in 2.2.0. */
|
|
15214
|
+
noSleep: external_exports.boolean().default(false),
|
|
15215
|
+
sleepTimeout: external_exports.number().positive().default(3e4),
|
|
15216
|
+
maxQueueSize: external_exports.number().positive().default(1e3),
|
|
15217
|
+
/** Maximum pending one-shot and recurring schedules. */
|
|
15218
|
+
maxSchedules: external_exports.number().int().nonnegative().default(1e3),
|
|
15219
|
+
maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
|
|
15220
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
15221
|
+
preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
|
|
15222
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
15223
|
+
preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
|
|
15224
|
+
}).strict();
|
|
15225
|
+
var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
|
|
15226
|
+
var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
|
|
15227
|
+
InstanceActorOptionsBaseSchema.shape
|
|
15228
|
+
).strict().prefault(() => ({}));
|
|
15229
|
+
var ActorConfigSchema = external_exports.object({
|
|
15230
|
+
onCreate: zFunction().optional(),
|
|
15231
|
+
onDestroy: zFunction().optional(),
|
|
15232
|
+
onMigrate: zFunction().optional(),
|
|
15233
|
+
onWake: zFunction().optional(),
|
|
15234
|
+
onSleep: zFunction().optional(),
|
|
15235
|
+
run: zRunHandler,
|
|
15236
|
+
onStateChange: zFunction().optional(),
|
|
15237
|
+
onBeforeConnect: zFunction().optional(),
|
|
15238
|
+
onConnect: zFunction().optional(),
|
|
15239
|
+
onDisconnect: zFunction().optional(),
|
|
15240
|
+
onBeforeActionResponse: zFunction().optional(),
|
|
15241
|
+
onRequest: zFunction().optional(),
|
|
15242
|
+
onWebSocket: zFunction().optional(),
|
|
15243
|
+
actions: zActionTree.default(() => ({})),
|
|
15244
|
+
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15245
|
+
connParamsSchema: external_exports.any().optional(),
|
|
15246
|
+
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15247
|
+
queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15248
|
+
state: external_exports.any().optional(),
|
|
15249
|
+
createState: zFunction().optional(),
|
|
15250
|
+
connState: external_exports.any().optional(),
|
|
15251
|
+
createConnState: zFunction().optional(),
|
|
15252
|
+
vars: external_exports.any().optional(),
|
|
15253
|
+
db: external_exports.any().optional(),
|
|
15254
|
+
createVars: zFunction().optional(),
|
|
15255
|
+
options: ActorOptionsSchema,
|
|
15256
|
+
inspector: ActorInspectorConfigSchema.optional()
|
|
15257
|
+
}).strict().refine(
|
|
15258
|
+
(data) => !(data.state !== void 0 && data.createState !== void 0),
|
|
15259
|
+
{
|
|
15260
|
+
message: "Cannot define both 'state' and 'createState'",
|
|
15261
|
+
path: ["state"]
|
|
15362
15262
|
}
|
|
15363
|
-
|
|
15364
|
-
|
|
15365
|
-
|
|
15366
|
-
|
|
15367
|
-
|
|
15368
|
-
for (let i = 0; i < len; i++) {
|
|
15369
|
-
const offset = bc.offset;
|
|
15370
|
-
const key = readString(bc);
|
|
15371
|
-
if (result.has(key)) {
|
|
15372
|
-
bc.offset = offset;
|
|
15373
|
-
throw new BareError(offset, "duplicated key");
|
|
15374
|
-
}
|
|
15375
|
-
result.set(key, readWorkflowEntryMetadata(bc));
|
|
15263
|
+
).refine(
|
|
15264
|
+
(data) => !(data.connState !== void 0 && data.createConnState !== void 0),
|
|
15265
|
+
{
|
|
15266
|
+
message: "Cannot define both 'connState' and 'createConnState'",
|
|
15267
|
+
path: ["connState"]
|
|
15376
15268
|
}
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
entries: read5(bc),
|
|
15383
|
-
entryMetadata: read6(bc)
|
|
15384
|
-
};
|
|
15385
|
-
}
|
|
15386
|
-
function decodeWorkflowHistory(bytes) {
|
|
15387
|
-
const bc = new ByteCursor(bytes, config2);
|
|
15388
|
-
const result = readWorkflowHistory(bc);
|
|
15389
|
-
if (bc.offset < bc.view.byteLength) {
|
|
15390
|
-
throw new BareError(bc.offset, "remaining bytes");
|
|
15269
|
+
).refine(
|
|
15270
|
+
(data) => !(data.vars !== void 0 && data.createVars !== void 0),
|
|
15271
|
+
{
|
|
15272
|
+
message: "Cannot define both 'vars' and 'createVars'",
|
|
15273
|
+
path: ["vars"]
|
|
15391
15274
|
}
|
|
15392
|
-
|
|
15393
|
-
|
|
15394
|
-
|
|
15395
|
-
|
|
15396
|
-
}
|
|
15275
|
+
);
|
|
15276
|
+
var DocActorOptionsSchema = external_exports.object({
|
|
15277
|
+
name: external_exports.string().optional().describe("Display name for the actor in the Inspector UI."),
|
|
15278
|
+
icon: external_exports.string().optional().describe(
|
|
15279
|
+
"Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
|
|
15280
|
+
),
|
|
15281
|
+
enableActorRuntimeSocket: external_exports.boolean().optional().describe(
|
|
15282
|
+
"Enables the experimental Actor Runtime Socket for this actor. Default: false"
|
|
15283
|
+
),
|
|
15284
|
+
createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
|
|
15285
|
+
createConnStateTimeout: external_exports.number().optional().describe(
|
|
15286
|
+
"Timeout in ms for createConnState handler. Default: 5000"
|
|
15287
|
+
),
|
|
15288
|
+
onMigrateTimeout: external_exports.number().optional().describe("Timeout in ms for onMigrate handler. Default: 30000"),
|
|
15289
|
+
onBeforeConnectTimeout: external_exports.number().optional().describe(
|
|
15290
|
+
"Timeout in ms for onBeforeConnect handler. Default: 5000"
|
|
15291
|
+
),
|
|
15292
|
+
onConnectTimeout: external_exports.number().optional().describe("Timeout in ms for onConnect handler. Default: 5000"),
|
|
15293
|
+
sleepGracePeriod: external_exports.number().optional().describe(
|
|
15294
|
+
`Max time in ms for the graceful shutdown window. Covers lifecycle hooks (onSleep, onDestroy), the run handler wait, async raw WebSocket handlers, disconnect callbacks, and final state serialization. Default: ${DEFAULT_SLEEP_GRACE_PERIOD}.`
|
|
15295
|
+
),
|
|
15296
|
+
onDestroyTimeout: external_exports.number().optional().describe(
|
|
15297
|
+
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
15298
|
+
),
|
|
15299
|
+
waitUntilTimeout: external_exports.number().optional().describe(
|
|
15300
|
+
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
15301
|
+
),
|
|
15302
|
+
stateSaveInterval: external_exports.number().optional().describe(
|
|
15303
|
+
"Interval in ms between automatic state saves. Default: 1000"
|
|
15304
|
+
),
|
|
15305
|
+
actionTimeout: external_exports.number().optional().describe("Timeout in ms for action handlers. Default: 60000"),
|
|
15306
|
+
connectionLivenessTimeout: external_exports.number().optional().describe(
|
|
15307
|
+
"Timeout in ms for connection liveness checks. Default: 2500"
|
|
15308
|
+
),
|
|
15309
|
+
connectionLivenessInterval: external_exports.number().optional().describe(
|
|
15310
|
+
"Interval in ms between connection liveness checks. Default: 5000"
|
|
15311
|
+
),
|
|
15312
|
+
noSleep: external_exports.boolean().optional().describe(
|
|
15313
|
+
"Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
|
|
15314
|
+
),
|
|
15315
|
+
sleepTimeout: external_exports.number().optional().describe(
|
|
15316
|
+
"Time in ms of inactivity before the actor sleeps. Default: 30000"
|
|
15317
|
+
),
|
|
15318
|
+
maxQueueSize: external_exports.number().optional().describe(
|
|
15319
|
+
"Maximum number of queue messages before rejecting new messages. Default: 1000"
|
|
15320
|
+
),
|
|
15321
|
+
maxSchedules: external_exports.number().int().nonnegative().optional().describe(
|
|
15322
|
+
"Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
|
|
15323
|
+
),
|
|
15324
|
+
maxQueueMessageSize: external_exports.number().optional().describe(
|
|
15325
|
+
"Maximum size of each queue message in bytes. Default: 65536"
|
|
15326
|
+
),
|
|
15327
|
+
canHibernateWebSocket: external_exports.boolean().optional().describe(
|
|
15328
|
+
"Whether WebSockets using onWebSocket can be hibernated. WebSockets using actions/events are hibernatable by default. Default: false"
|
|
15329
|
+
)
|
|
15330
|
+
}).describe("Actor options for timeouts and behavior configuration.");
|
|
15331
|
+
var DocActorConfigSchema = external_exports.object({
|
|
15332
|
+
state: external_exports.unknown().optional().describe(
|
|
15333
|
+
"Initial state value for the actor. Cannot be used with createState."
|
|
15334
|
+
),
|
|
15335
|
+
createState: external_exports.unknown().optional().describe(
|
|
15336
|
+
"Function to create initial state. Receives context and input. Cannot be used with state."
|
|
15337
|
+
),
|
|
15338
|
+
connState: external_exports.unknown().optional().describe(
|
|
15339
|
+
"Initial connection state value. Cannot be used with createConnState."
|
|
15340
|
+
),
|
|
15341
|
+
createConnState: external_exports.unknown().optional().describe(
|
|
15342
|
+
"Function to create connection state. Receives context and connection params. The pending connection is not visible in c.conns until this succeeds. Cannot be used with connState."
|
|
15343
|
+
),
|
|
15344
|
+
vars: external_exports.unknown().optional().describe(
|
|
15345
|
+
"Initial ephemeral variables value. Cannot be used with createVars."
|
|
15346
|
+
),
|
|
15347
|
+
createVars: external_exports.unknown().optional().describe(
|
|
15348
|
+
"Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
|
|
15349
|
+
),
|
|
15350
|
+
db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
|
|
15351
|
+
onCreate: external_exports.unknown().optional().describe(
|
|
15352
|
+
"Called when the actor is first initialized. Use to initialize state."
|
|
15353
|
+
),
|
|
15354
|
+
onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
|
|
15355
|
+
onMigrate: external_exports.unknown().optional().describe(
|
|
15356
|
+
"Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
|
|
15357
|
+
),
|
|
15358
|
+
onWake: external_exports.unknown().optional().describe(
|
|
15359
|
+
"Called when the actor wakes up and is ready to receive connections and actions."
|
|
15360
|
+
),
|
|
15361
|
+
onSleep: external_exports.unknown().optional().describe(
|
|
15362
|
+
"Called when the actor is stopping or sleeping. Use to clean up resources."
|
|
15363
|
+
),
|
|
15364
|
+
run: external_exports.unknown().optional().describe(
|
|
15365
|
+
"Called after actor starts. Does not block startup. Use for background tasks like queue processing or tick loops. If it exits, the actor follows the normal idle sleep timeout once idle. If it throws, the actor logs the error and then follows the normal idle sleep timeout once idle."
|
|
15366
|
+
),
|
|
15367
|
+
onStateChange: external_exports.unknown().optional().describe(
|
|
15368
|
+
"Called when the actor's state changes. State changes within this hook won't trigger recursion."
|
|
15369
|
+
),
|
|
15370
|
+
onBeforeConnect: external_exports.unknown().optional().describe(
|
|
15371
|
+
"Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
|
|
15372
|
+
),
|
|
15373
|
+
onConnect: external_exports.unknown().optional().describe(
|
|
15374
|
+
"Called when a client successfully connects. The connection is visible in c.conns before this runs."
|
|
15375
|
+
),
|
|
15376
|
+
onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
|
|
15377
|
+
onBeforeActionResponse: external_exports.unknown().optional().describe(
|
|
15378
|
+
"Called before sending an action response. Use to transform output."
|
|
15379
|
+
),
|
|
15380
|
+
onRequest: external_exports.unknown().optional().describe(
|
|
15381
|
+
"Called for raw HTTP requests to /actors/{name}/http/* endpoints."
|
|
15382
|
+
),
|
|
15383
|
+
onWebSocket: external_exports.unknown().optional().describe(
|
|
15384
|
+
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
15385
|
+
),
|
|
15386
|
+
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15387
|
+
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
15388
|
+
),
|
|
15389
|
+
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15390
|
+
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
15391
|
+
),
|
|
15392
|
+
connParamsSchema: external_exports.unknown().optional().describe(
|
|
15393
|
+
"Optional schema for validating connection params in native runtimes."
|
|
15394
|
+
),
|
|
15395
|
+
events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
|
|
15396
|
+
queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
|
|
15397
|
+
options: DocActorOptionsSchema.optional()
|
|
15398
|
+
}).describe("Actor configuration passed to the actor() function.");
|
|
15397
15399
|
|
|
15398
15400
|
// ../rivetkit/dist/tsup/chunk-JI6GZ2C2.js
|
|
15399
15401
|
var EMPTY_KEY = "/";
|
|
@@ -15512,44 +15514,6 @@ function removePrefixFromKey(prefixedKey) {
|
|
|
15512
15514
|
return prefixedKey.slice(KEYS.KV.length);
|
|
15513
15515
|
}
|
|
15514
15516
|
|
|
15515
|
-
// ../rivetkit/dist/tsup/chunk-RSPJ6UQF.js
|
|
15516
|
-
function logger() {
|
|
15517
|
-
return getLogger("actor-client");
|
|
15518
|
-
}
|
|
15519
|
-
var webSocketPromise = null;
|
|
15520
|
-
async function importWebSocket() {
|
|
15521
|
-
if (webSocketPromise !== null) {
|
|
15522
|
-
return webSocketPromise;
|
|
15523
|
-
}
|
|
15524
|
-
webSocketPromise = (async () => {
|
|
15525
|
-
let _WebSocket;
|
|
15526
|
-
if (typeof WebSocket !== "undefined") {
|
|
15527
|
-
_WebSocket = WebSocket;
|
|
15528
|
-
} else {
|
|
15529
|
-
try {
|
|
15530
|
-
const moduleName = "ws";
|
|
15531
|
-
const ws = await import(
|
|
15532
|
-
/* webpackIgnore: true */
|
|
15533
|
-
moduleName
|
|
15534
|
-
);
|
|
15535
|
-
_WebSocket = ws.default;
|
|
15536
|
-
logger().debug("using websocket from npm");
|
|
15537
|
-
} catch {
|
|
15538
|
-
_WebSocket = class MockWebSocket {
|
|
15539
|
-
constructor() {
|
|
15540
|
-
throw new Error(
|
|
15541
|
-
'WebSocket support requires installing the "ws" peer dependency.'
|
|
15542
|
-
);
|
|
15543
|
-
}
|
|
15544
|
-
};
|
|
15545
|
-
logger().debug("using mock websocket");
|
|
15546
|
-
}
|
|
15547
|
-
}
|
|
15548
|
-
return _WebSocket;
|
|
15549
|
-
})();
|
|
15550
|
-
return webSocketPromise;
|
|
15551
|
-
}
|
|
15552
|
-
|
|
15553
15517
|
// ../rivetkit/dist/tsup/chunk-JTHHCZCZ.js
|
|
15554
15518
|
var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
|
|
15555
15519
|
function isManualTransactionControl(query) {
|
|
@@ -15633,7 +15597,45 @@ var AsyncMutex = class {
|
|
|
15633
15597
|
}
|
|
15634
15598
|
};
|
|
15635
15599
|
|
|
15636
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15600
|
+
// ../rivetkit/dist/tsup/chunk-ABQUEXF4.js
|
|
15601
|
+
function logger() {
|
|
15602
|
+
return getLogger("actor-client");
|
|
15603
|
+
}
|
|
15604
|
+
var webSocketPromise = null;
|
|
15605
|
+
async function importWebSocket() {
|
|
15606
|
+
if (webSocketPromise !== null) {
|
|
15607
|
+
return webSocketPromise;
|
|
15608
|
+
}
|
|
15609
|
+
webSocketPromise = (async () => {
|
|
15610
|
+
let _WebSocket;
|
|
15611
|
+
if (typeof WebSocket !== "undefined") {
|
|
15612
|
+
_WebSocket = WebSocket;
|
|
15613
|
+
} else {
|
|
15614
|
+
try {
|
|
15615
|
+
const moduleName = "ws";
|
|
15616
|
+
const ws = await import(
|
|
15617
|
+
/* webpackIgnore: true */
|
|
15618
|
+
moduleName
|
|
15619
|
+
);
|
|
15620
|
+
_WebSocket = ws.default;
|
|
15621
|
+
logger().debug("using websocket from npm");
|
|
15622
|
+
} catch {
|
|
15623
|
+
_WebSocket = class MockWebSocket {
|
|
15624
|
+
constructor() {
|
|
15625
|
+
throw new Error(
|
|
15626
|
+
'WebSocket support requires installing the "ws" peer dependency.'
|
|
15627
|
+
);
|
|
15628
|
+
}
|
|
15629
|
+
};
|
|
15630
|
+
logger().debug("using mock websocket");
|
|
15631
|
+
}
|
|
15632
|
+
}
|
|
15633
|
+
return _WebSocket;
|
|
15634
|
+
})();
|
|
15635
|
+
return webSocketPromise;
|
|
15636
|
+
}
|
|
15637
|
+
|
|
15638
|
+
// ../rivetkit/dist/tsup/chunk-W4HOK4YC.js
|
|
15637
15639
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15638
15640
|
|
|
15639
15641
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -15811,7 +15813,7 @@ function createVersionedDataHandler(config3) {
|
|
|
15811
15813
|
return new VersionedDataHandler(config3);
|
|
15812
15814
|
}
|
|
15813
15815
|
|
|
15814
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15816
|
+
// ../rivetkit/dist/tsup/chunk-W4HOK4YC.js
|
|
15815
15817
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
15816
15818
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
15817
15819
|
var PATH_CONNECT = "/connect";
|
|
@@ -21604,7 +21606,7 @@ function apiActorToOutput(actor2) {
|
|
|
21604
21606
|
};
|
|
21605
21607
|
}
|
|
21606
21608
|
|
|
21607
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
21609
|
+
// ../rivetkit/dist/tsup/chunk-EVYJ3P3V.js
|
|
21608
21610
|
var nativeStateTransactionOpeners = /* @__PURE__ */ new WeakMap();
|
|
21609
21611
|
var nativeStateTransactionClientBinders = /* @__PURE__ */ new WeakMap();
|
|
21610
21612
|
function registerNativeStateTransactionOpener(provider, opener) {
|
|
@@ -23771,7 +23773,7 @@ var RegistryConfigSchema = external_exports.object({
|
|
|
23771
23773
|
config3.startEngine || parsedEndpoint
|
|
23772
23774
|
);
|
|
23773
23775
|
const namespace = (parsedEndpoint == null ? void 0 : parsedEndpoint.namespace) ?? config3.namespace ?? "default";
|
|
23774
|
-
const token = (parsedEndpoint == null ? void 0 : parsedEndpoint.token) ?? config3.token;
|
|
23776
|
+
const token = (parsedEndpoint == null ? void 0 : parsedEndpoint.token) ?? config3.token ?? "dev";
|
|
23775
23777
|
const parsedPublicEndpoint = config3.serverless.publicEndpoint ? tryParseEndpoint(ctx, {
|
|
23776
23778
|
endpoint: config3.serverless.publicEndpoint,
|
|
23777
23779
|
path: ["serverless", "publicEndpoint"]
|