@rivetkit/supabase 2.3.11-rc.7 → 2.3.11-rc.9
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 +869 -769
- package/dist/mod.mjs +872 -772
- package/package.json +3 -3
package/dist/mod.js
CHANGED
|
@@ -334,6 +334,183 @@ __export(mod_exports, {
|
|
|
334
334
|
module.exports = __toCommonJS(mod_exports);
|
|
335
335
|
var wasmBindings = __toESM(require("@rivetkit/rivetkit-wasm"));
|
|
336
336
|
|
|
337
|
+
// ../rivetkit/dist/tsup/chunk-ZZ3WBRPD.js
|
|
338
|
+
var INTERNAL_ERROR_CODE = "internal_error";
|
|
339
|
+
var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
|
|
340
|
+
var USER_ERROR_CODE = "user_error";
|
|
341
|
+
var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
|
|
342
|
+
function looksLikeRivetErrorOptions(value) {
|
|
343
|
+
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "statusCode" in value || "actor" in value || "cause" in value);
|
|
344
|
+
}
|
|
345
|
+
function isTypedErrorTag(value) {
|
|
346
|
+
return value === "ActorError" || value === "RivetError";
|
|
347
|
+
}
|
|
348
|
+
function errorMessage(error46, fallback = String(error46)) {
|
|
349
|
+
if (error46 && typeof error46 === "object" && "message" in error46 && typeof error46.message === "string") {
|
|
350
|
+
return error46.message;
|
|
351
|
+
}
|
|
352
|
+
return fallback;
|
|
353
|
+
}
|
|
354
|
+
function isRivetErrorLike(error46) {
|
|
355
|
+
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" && (!("__type" in error46) || isTypedErrorTag(error46.__type));
|
|
356
|
+
}
|
|
357
|
+
function isActorAbortedError(error46) {
|
|
358
|
+
return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
|
|
359
|
+
}
|
|
360
|
+
function isActorSpecifier(value) {
|
|
361
|
+
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");
|
|
362
|
+
}
|
|
363
|
+
var RivetError = class extends Error {
|
|
364
|
+
__type = "RivetError";
|
|
365
|
+
public;
|
|
366
|
+
metadata;
|
|
367
|
+
statusCode;
|
|
368
|
+
actor;
|
|
369
|
+
group;
|
|
370
|
+
code;
|
|
371
|
+
static isRivetError(error46) {
|
|
372
|
+
return isRivetErrorLike(error46);
|
|
373
|
+
}
|
|
374
|
+
static isActorError(error46) {
|
|
375
|
+
return isRivetErrorLike(error46);
|
|
376
|
+
}
|
|
377
|
+
constructor(group, code, message, options) {
|
|
378
|
+
const normalized = looksLikeRivetErrorOptions(options) ? options : { metadata: options };
|
|
379
|
+
super(message, { cause: normalized.cause });
|
|
380
|
+
this.name = "RivetError";
|
|
381
|
+
this.group = group;
|
|
382
|
+
this.code = code;
|
|
383
|
+
this.public = normalized.public ?? false;
|
|
384
|
+
this.metadata = normalized.metadata;
|
|
385
|
+
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
386
|
+
this.actor = normalized.actor;
|
|
387
|
+
}
|
|
388
|
+
toString() {
|
|
389
|
+
return this.message;
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
var UserError = class extends RivetError {
|
|
393
|
+
constructor(message, options) {
|
|
394
|
+
super("user", (options == null ? void 0 : options.code) ?? USER_ERROR_CODE, message, {
|
|
395
|
+
public: true,
|
|
396
|
+
metadata: options == null ? void 0 : options.metadata,
|
|
397
|
+
cause: options == null ? void 0 : options.cause
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
function toRivetError(error46, fallback) {
|
|
402
|
+
if (typeof error46 === "string") {
|
|
403
|
+
const bridged = decodeBridgeRivetError(error46);
|
|
404
|
+
if (bridged) {
|
|
405
|
+
return bridged;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (error46 instanceof Error) {
|
|
409
|
+
const bridged = decodeBridgeRivetError(error46.message);
|
|
410
|
+
if (bridged) {
|
|
411
|
+
return bridged;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (isRivetErrorLike(error46)) {
|
|
415
|
+
return new RivetError(error46.group, error46.code, error46.message, {
|
|
416
|
+
public: error46.public,
|
|
417
|
+
statusCode: error46.statusCode,
|
|
418
|
+
metadata: error46.metadata,
|
|
419
|
+
actor: error46.actor,
|
|
420
|
+
cause: error46 instanceof Error ? error46.cause : void 0
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
return new RivetError(
|
|
424
|
+
(fallback == null ? void 0 : fallback.group) ?? "actor",
|
|
425
|
+
(fallback == null ? void 0 : fallback.code) ?? INTERNAL_ERROR_CODE,
|
|
426
|
+
errorMessage(error46, (fallback == null ? void 0 : fallback.message) ?? "Unknown error"),
|
|
427
|
+
{
|
|
428
|
+
public: fallback == null ? void 0 : fallback.public,
|
|
429
|
+
statusCode: fallback == null ? void 0 : fallback.statusCode,
|
|
430
|
+
metadata: fallback == null ? void 0 : fallback.metadata,
|
|
431
|
+
actor: fallback == null ? void 0 : fallback.actor,
|
|
432
|
+
cause: error46 instanceof Error ? error46 : void 0
|
|
433
|
+
}
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
function encodeBridgeRivetError(error46) {
|
|
437
|
+
return `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({
|
|
438
|
+
group: error46.group,
|
|
439
|
+
code: error46.code,
|
|
440
|
+
message: error46.message,
|
|
441
|
+
metadata: error46.metadata,
|
|
442
|
+
public: error46.public,
|
|
443
|
+
statusCode: error46.statusCode,
|
|
444
|
+
actor: error46.actor
|
|
445
|
+
})}`;
|
|
446
|
+
}
|
|
447
|
+
function decodeBridgeRivetErrorPayload(value) {
|
|
448
|
+
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
449
|
+
return void 0;
|
|
450
|
+
}
|
|
451
|
+
try {
|
|
452
|
+
const payload = JSON.parse(
|
|
453
|
+
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
|
|
454
|
+
);
|
|
455
|
+
if (!isRivetErrorLike(payload)) {
|
|
456
|
+
return void 0;
|
|
457
|
+
}
|
|
458
|
+
if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
|
|
459
|
+
return void 0;
|
|
460
|
+
}
|
|
461
|
+
return payload;
|
|
462
|
+
} catch {
|
|
463
|
+
return void 0;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
function decodeBridgeRivetError(value) {
|
|
467
|
+
const payload = decodeBridgeRivetErrorPayload(value);
|
|
468
|
+
if (!payload) {
|
|
469
|
+
return void 0;
|
|
470
|
+
}
|
|
471
|
+
return new RivetError(payload.group, payload.code, payload.message, {
|
|
472
|
+
metadata: payload.metadata,
|
|
473
|
+
public: payload.public,
|
|
474
|
+
statusCode: payload.statusCode,
|
|
475
|
+
actor: payload.actor ?? void 0
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
function invalidRequest(error46) {
|
|
479
|
+
return new RivetError(
|
|
480
|
+
"request",
|
|
481
|
+
"invalid",
|
|
482
|
+
`Invalid request: ${errorMessage(error46, String(error46))}`,
|
|
483
|
+
{
|
|
484
|
+
public: true,
|
|
485
|
+
cause: error46 instanceof Error ? error46 : void 0
|
|
486
|
+
}
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
function actorNotFound(identifier) {
|
|
490
|
+
return new RivetError(
|
|
491
|
+
"actor",
|
|
492
|
+
"not_found",
|
|
493
|
+
identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
|
|
494
|
+
{ public: true }
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
function forbiddenError() {
|
|
498
|
+
return new RivetError("auth", "forbidden", "Forbidden", {
|
|
499
|
+
public: true,
|
|
500
|
+
statusCode: 403
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
function unsupportedFeature(feature) {
|
|
504
|
+
return new RivetError(
|
|
505
|
+
"feature",
|
|
506
|
+
"unsupported",
|
|
507
|
+
`Unsupported feature: ${feature}`
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// ../rivetkit/dist/tsup/chunk-LZ4TSBIP.js
|
|
512
|
+
var import_pino = require("pino");
|
|
513
|
+
|
|
337
514
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
|
|
338
515
|
var external_exports = {};
|
|
339
516
|
__export(external_exports, {
|
|
@@ -13004,658 +13181,53 @@ var classic_default = external_exports;
|
|
|
13004
13181
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
|
|
13005
13182
|
var v4_default = classic_default;
|
|
13006
13183
|
|
|
13007
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13184
|
+
// ../rivetkit/dist/tsup/chunk-LZ4TSBIP.js
|
|
13185
|
+
var cbor = __toESM(require("cbor-x"), 1);
|
|
13186
|
+
var import_invariant = __toESM(require_invariant(), 1);
|
|
13187
|
+
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
13188
|
+
var getRivetEndpoint = () => getEnvUniversal("RIVET_ENDPOINT");
|
|
13189
|
+
var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
|
|
13190
|
+
var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
|
|
13191
|
+
var getRivetPool = () => getEnvUniversal("RIVET_POOL");
|
|
13192
|
+
var getRivetTotalSlots = () => {
|
|
13193
|
+
const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
|
|
13194
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13195
|
+
};
|
|
13196
|
+
var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
|
|
13197
|
+
var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
|
|
13198
|
+
var getRivetRunEnginePort = () => {
|
|
13199
|
+
const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
|
|
13200
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13201
|
+
};
|
|
13202
|
+
var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
|
|
13203
|
+
var getRivetEnvoyVersion = () => {
|
|
13204
|
+
const value = getEnvUniversal("RIVET_ENVOY_VERSION");
|
|
13205
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13206
|
+
};
|
|
13207
|
+
var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
|
|
13208
|
+
var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
|
|
13209
|
+
var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
|
|
13210
|
+
var getRivetkitRuntimeMode = () => {
|
|
13211
|
+
const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
|
|
13212
|
+
if (value === void 0) return "envoy";
|
|
13213
|
+
if (value === "envoy" || value === "serverless") return value;
|
|
13214
|
+
throw new Error(
|
|
13215
|
+
`RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
|
|
13216
|
+
);
|
|
13217
|
+
};
|
|
13218
|
+
var getRivetkitPublicDir = () => {
|
|
13219
|
+
const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
|
|
13220
|
+
return value === void 0 || value === "" ? void 0 : value;
|
|
13221
|
+
};
|
|
13222
|
+
function parsePortEnv(raw) {
|
|
13223
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
13224
|
+
const parsed = Number.parseInt(raw, 10);
|
|
13225
|
+
if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
|
|
13226
|
+
throw new Error(
|
|
13227
|
+
`RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
|
|
13228
|
+
);
|
|
13033
13229
|
}
|
|
13034
|
-
return
|
|
13035
|
-
}
|
|
13036
|
-
function collectActionEntries(actions) {
|
|
13037
|
-
const entries = [];
|
|
13038
|
-
const names = /* @__PURE__ */ new Set();
|
|
13039
|
-
visitActionGroup(actions ?? {}, [], entries, names);
|
|
13040
|
-
return entries;
|
|
13041
|
-
}
|
|
13042
|
-
function visitActionGroup(value, path2, entries, names) {
|
|
13043
|
-
if (!isRecord(value)) {
|
|
13044
|
-
throw new TypeError(
|
|
13045
|
-
`${formatActionPath(path2)} must be an action handler or group`
|
|
13046
|
-
);
|
|
13047
|
-
}
|
|
13048
|
-
for (const [segment, child] of Object.entries(value)) {
|
|
13049
|
-
const childPath = [...path2, segment];
|
|
13050
|
-
if (typeof child === "function") {
|
|
13051
|
-
const name = childPath.join(".");
|
|
13052
|
-
if (names.has(name)) {
|
|
13053
|
-
throw new TypeError(
|
|
13054
|
-
`Multiple action definitions flatten to \`${name}\``
|
|
13055
|
-
);
|
|
13056
|
-
}
|
|
13057
|
-
names.add(name);
|
|
13058
|
-
entries.push({
|
|
13059
|
-
name,
|
|
13060
|
-
path: childPath,
|
|
13061
|
-
handler: child
|
|
13062
|
-
});
|
|
13063
|
-
} else {
|
|
13064
|
-
visitActionGroup(child, childPath, entries, names);
|
|
13065
|
-
}
|
|
13066
|
-
}
|
|
13067
|
-
}
|
|
13068
|
-
function lookupNestedSchema(schemas, path2) {
|
|
13069
|
-
let value = schemas;
|
|
13070
|
-
for (const segment of path2) {
|
|
13071
|
-
if (!isRecord(value) || !Object.hasOwn(value, segment)) {
|
|
13072
|
-
return void 0;
|
|
13073
|
-
}
|
|
13074
|
-
value = value[segment];
|
|
13075
|
-
}
|
|
13076
|
-
return value;
|
|
13077
|
-
}
|
|
13078
|
-
function isRecord(value) {
|
|
13079
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
13080
|
-
return false;
|
|
13081
|
-
}
|
|
13082
|
-
const prototype = Object.getPrototypeOf(value);
|
|
13083
|
-
return prototype === Object.prototype || prototype === null;
|
|
13084
|
-
}
|
|
13085
|
-
function formatActionPath(path2) {
|
|
13086
|
-
return path2.length === 0 ? "actions" : `Action \`${path2.join(".")}\``;
|
|
13087
|
-
}
|
|
13088
|
-
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
13089
|
-
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
13090
|
-
"rivetkit.actor_context_internal"
|
|
13091
|
-
);
|
|
13092
|
-
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
13093
|
-
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
13094
|
-
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
13095
|
-
var zActionTree = external_exports.custom((value) => {
|
|
13096
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
13097
|
-
return false;
|
|
13098
|
-
}
|
|
13099
|
-
const prototype = Object.getPrototypeOf(value);
|
|
13100
|
-
return prototype === Object.prototype || prototype === null;
|
|
13101
|
-
}).superRefine((actions, ctx) => {
|
|
13102
|
-
try {
|
|
13103
|
-
flattenActionHandlers(actions);
|
|
13104
|
-
} catch (error46) {
|
|
13105
|
-
ctx.addIssue({
|
|
13106
|
-
code: "custom",
|
|
13107
|
-
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
13108
|
-
});
|
|
13109
|
-
}
|
|
13110
|
-
});
|
|
13111
|
-
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
13112
|
-
getHistory: zFunction(),
|
|
13113
|
-
onHistoryUpdated: zFunction().optional(),
|
|
13114
|
-
replayFromStep: zFunction().optional()
|
|
13115
|
-
});
|
|
13116
|
-
var RunInspectorConfigSchema = external_exports.object({
|
|
13117
|
-
workflow: WorkflowInspectorConfigSchema.optional()
|
|
13118
|
-
}).optional();
|
|
13119
|
-
var BUILTIN_INSPECTOR_TAB_IDS = [
|
|
13120
|
-
"workflow",
|
|
13121
|
-
"database",
|
|
13122
|
-
"state",
|
|
13123
|
-
"queue",
|
|
13124
|
-
"schedules",
|
|
13125
|
-
"connections",
|
|
13126
|
-
"console"
|
|
13127
|
-
];
|
|
13128
|
-
var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
|
|
13129
|
-
var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
13130
|
-
var CustomInspectorTabEntrySchema = external_exports.object({
|
|
13131
|
-
id: external_exports.string().regex(
|
|
13132
|
-
CUSTOM_INSPECTOR_TAB_ID_RE,
|
|
13133
|
-
"inspector.tabs[].id must contain only letters, digits, underscore, or dash"
|
|
13134
|
-
),
|
|
13135
|
-
label: external_exports.string().min(1),
|
|
13136
|
-
source: external_exports.string().min(1),
|
|
13137
|
-
/**
|
|
13138
|
-
* Optional icon id. The dashboard maps strings to glyphs (see its
|
|
13139
|
-
* icon registry); unknown ids fall back to a generic icon.
|
|
13140
|
-
*/
|
|
13141
|
-
icon: external_exports.string().min(1).optional(),
|
|
13142
|
-
hidden: external_exports.literal(false).optional()
|
|
13143
|
-
}).strict();
|
|
13144
|
-
var HideInspectorTabEntrySchema = external_exports.object({
|
|
13145
|
-
id: BuiltinInspectorTabIdSchema,
|
|
13146
|
-
hidden: external_exports.literal(true)
|
|
13147
|
-
}).strict();
|
|
13148
|
-
var InspectorTabEntrySchema = external_exports.union([
|
|
13149
|
-
CustomInspectorTabEntrySchema,
|
|
13150
|
-
HideInspectorTabEntrySchema
|
|
13151
|
-
]);
|
|
13152
|
-
var ActorInspectorConfigSchema = external_exports.object({
|
|
13153
|
-
tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
|
|
13154
|
-
}).strict().refine(
|
|
13155
|
-
(data) => {
|
|
13156
|
-
const ids = data.tabs.map((t) => t.id);
|
|
13157
|
-
return new Set(ids).size === ids.length;
|
|
13158
|
-
},
|
|
13159
|
-
{ message: "Duplicate id in inspector.tabs", path: ["tabs"] }
|
|
13160
|
-
).refine(
|
|
13161
|
-
(data) => {
|
|
13162
|
-
const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
|
|
13163
|
-
return data.tabs.every(
|
|
13164
|
-
(t) => t.hidden === true || !builtinSet.has(t.id)
|
|
13165
|
-
);
|
|
13166
|
-
},
|
|
13167
|
-
{
|
|
13168
|
-
message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
|
|
13169
|
-
path: ["tabs"]
|
|
13170
|
-
}
|
|
13171
|
-
);
|
|
13172
|
-
var RunConfigSchema = external_exports.object({
|
|
13173
|
-
/** Display name for the actor in the Inspector UI. */
|
|
13174
|
-
name: external_exports.string().optional(),
|
|
13175
|
-
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
13176
|
-
icon: external_exports.string().optional(),
|
|
13177
|
-
/** The run handler function. */
|
|
13178
|
-
run: zFunction(),
|
|
13179
|
-
/** Inspector integration for long-running run handlers. */
|
|
13180
|
-
inspector: RunInspectorConfigSchema.optional()
|
|
13181
|
-
});
|
|
13182
|
-
var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
13183
|
-
"rivetkit.run_function_config"
|
|
13184
|
-
);
|
|
13185
|
-
var zRunHandler = external_exports.union([zFunction(), RunConfigSchema]).optional();
|
|
13186
|
-
function getRunFunction(run) {
|
|
13187
|
-
if (!run) return void 0;
|
|
13188
|
-
if (typeof run === "function") return run;
|
|
13189
|
-
return run.run;
|
|
13190
|
-
}
|
|
13191
|
-
function getRunMetadata(run) {
|
|
13192
|
-
if (!run) return {};
|
|
13193
|
-
if (typeof run === "function") {
|
|
13194
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13195
|
-
if (!config3) return {};
|
|
13196
|
-
return { name: config3.name, icon: config3.icon };
|
|
13197
|
-
}
|
|
13198
|
-
return { name: run.name, icon: run.icon };
|
|
13199
|
-
}
|
|
13200
|
-
function getRunInspectorConfig(run, actor2) {
|
|
13201
|
-
if (!run) return void 0;
|
|
13202
|
-
if (typeof run === "function") {
|
|
13203
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13204
|
-
return (config3 == null ? void 0 : config3.inspectorFactory) ? config3.inspectorFactory(actor2) : config3 == null ? void 0 : config3.inspector;
|
|
13205
|
-
}
|
|
13206
|
-
return run.inspector;
|
|
13207
|
-
}
|
|
13208
|
-
function disposeRunInspector(run, actorId) {
|
|
13209
|
-
var _a2;
|
|
13210
|
-
if (!run || typeof run !== "function") {
|
|
13211
|
-
return;
|
|
13212
|
-
}
|
|
13213
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13214
|
-
(_a2 = config3 == null ? void 0 : config3.disposeInspector) == null ? void 0 : _a2.call(config3, actorId);
|
|
13215
|
-
}
|
|
13216
|
-
var GlobalActorOptionsBaseSchema = external_exports.object({
|
|
13217
|
-
/** Display name for the actor in the Inspector UI. */
|
|
13218
|
-
name: external_exports.string().optional(),
|
|
13219
|
-
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
13220
|
-
icon: external_exports.string().optional(),
|
|
13221
|
-
/** Enables the experimental Actor Runtime Socket for this actor. */
|
|
13222
|
-
enableActorRuntimeSocket: external_exports.boolean().default(false),
|
|
13223
|
-
/**
|
|
13224
|
-
* Can hibernate WebSockets for onWebSocket.
|
|
13225
|
-
*
|
|
13226
|
-
* WebSockets using actions/events are hibernatable by default.
|
|
13227
|
-
*
|
|
13228
|
-
* @experimental
|
|
13229
|
-
**/
|
|
13230
|
-
canHibernateWebSocket: external_exports.union([external_exports.boolean(), zFunction()]).default(false)
|
|
13231
|
-
}).strict();
|
|
13232
|
-
var GlobalActorOptionsSchema = GlobalActorOptionsBaseSchema.prefault(
|
|
13233
|
-
() => ({})
|
|
13234
|
-
);
|
|
13235
|
-
var InstanceActorOptionsBaseSchema = external_exports.object({
|
|
13236
|
-
createVarsTimeout: external_exports.number().positive().default(5e3),
|
|
13237
|
-
createConnStateTimeout: external_exports.number().positive().default(5e3),
|
|
13238
|
-
onBeforeConnectTimeout: external_exports.number().positive().default(5e3),
|
|
13239
|
-
onConnectTimeout: external_exports.number().positive().default(5e3),
|
|
13240
|
-
onMigrateTimeout: external_exports.number().positive().default(3e4),
|
|
13241
|
-
sleepGracePeriod: external_exports.number().positive().default(DEFAULT_SLEEP_GRACE_PERIOD),
|
|
13242
|
-
/** @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. */
|
|
13243
|
-
onDestroyTimeout: external_exports.number().positive().optional(),
|
|
13244
|
-
/** @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. */
|
|
13245
|
-
waitUntilTimeout: external_exports.number().positive().optional(),
|
|
13246
|
-
stateSaveInterval: external_exports.number().positive().default(1e3),
|
|
13247
|
-
actionTimeout: external_exports.number().positive().default(6e4),
|
|
13248
|
-
connectionLivenessTimeout: external_exports.number().positive().default(2500),
|
|
13249
|
-
connectionLivenessInterval: external_exports.number().positive().default(5e3),
|
|
13250
|
-
/** @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. */
|
|
13251
|
-
noSleep: external_exports.boolean().default(false),
|
|
13252
|
-
sleepTimeout: external_exports.number().positive().default(3e4),
|
|
13253
|
-
maxQueueSize: external_exports.number().positive().default(1e3),
|
|
13254
|
-
/** Maximum pending one-shot and recurring schedules. */
|
|
13255
|
-
maxSchedules: external_exports.number().int().nonnegative().default(1e3),
|
|
13256
|
-
maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
|
|
13257
|
-
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
13258
|
-
preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
|
|
13259
|
-
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
13260
|
-
preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
|
|
13261
|
-
}).strict();
|
|
13262
|
-
var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
|
|
13263
|
-
var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
|
|
13264
|
-
InstanceActorOptionsBaseSchema.shape
|
|
13265
|
-
).strict().prefault(() => ({}));
|
|
13266
|
-
var ActorConfigSchema = external_exports.object({
|
|
13267
|
-
onCreate: zFunction().optional(),
|
|
13268
|
-
onDestroy: zFunction().optional(),
|
|
13269
|
-
onMigrate: zFunction().optional(),
|
|
13270
|
-
onWake: zFunction().optional(),
|
|
13271
|
-
onSleep: zFunction().optional(),
|
|
13272
|
-
run: zRunHandler,
|
|
13273
|
-
onStateChange: zFunction().optional(),
|
|
13274
|
-
onBeforeConnect: zFunction().optional(),
|
|
13275
|
-
onConnect: zFunction().optional(),
|
|
13276
|
-
onDisconnect: zFunction().optional(),
|
|
13277
|
-
onBeforeActionResponse: zFunction().optional(),
|
|
13278
|
-
onRequest: zFunction().optional(),
|
|
13279
|
-
onWebSocket: zFunction().optional(),
|
|
13280
|
-
actions: zActionTree.default(() => ({})),
|
|
13281
|
-
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13282
|
-
connParamsSchema: external_exports.any().optional(),
|
|
13283
|
-
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13284
|
-
queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13285
|
-
state: external_exports.any().optional(),
|
|
13286
|
-
createState: zFunction().optional(),
|
|
13287
|
-
connState: external_exports.any().optional(),
|
|
13288
|
-
createConnState: zFunction().optional(),
|
|
13289
|
-
vars: external_exports.any().optional(),
|
|
13290
|
-
db: external_exports.any().optional(),
|
|
13291
|
-
createVars: zFunction().optional(),
|
|
13292
|
-
options: ActorOptionsSchema,
|
|
13293
|
-
inspector: ActorInspectorConfigSchema.optional()
|
|
13294
|
-
}).strict().refine(
|
|
13295
|
-
(data) => !(data.state !== void 0 && data.createState !== void 0),
|
|
13296
|
-
{
|
|
13297
|
-
message: "Cannot define both 'state' and 'createState'",
|
|
13298
|
-
path: ["state"]
|
|
13299
|
-
}
|
|
13300
|
-
).refine(
|
|
13301
|
-
(data) => !(data.connState !== void 0 && data.createConnState !== void 0),
|
|
13302
|
-
{
|
|
13303
|
-
message: "Cannot define both 'connState' and 'createConnState'",
|
|
13304
|
-
path: ["connState"]
|
|
13305
|
-
}
|
|
13306
|
-
).refine(
|
|
13307
|
-
(data) => !(data.vars !== void 0 && data.createVars !== void 0),
|
|
13308
|
-
{
|
|
13309
|
-
message: "Cannot define both 'vars' and 'createVars'",
|
|
13310
|
-
path: ["vars"]
|
|
13311
|
-
}
|
|
13312
|
-
);
|
|
13313
|
-
var DocActorOptionsSchema = external_exports.object({
|
|
13314
|
-
name: external_exports.string().optional().describe("Display name for the actor in the Inspector UI."),
|
|
13315
|
-
icon: external_exports.string().optional().describe(
|
|
13316
|
-
"Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
|
|
13317
|
-
),
|
|
13318
|
-
enableActorRuntimeSocket: external_exports.boolean().optional().describe(
|
|
13319
|
-
"Enables the experimental Actor Runtime Socket for this actor. Default: false"
|
|
13320
|
-
),
|
|
13321
|
-
createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
|
|
13322
|
-
createConnStateTimeout: external_exports.number().optional().describe(
|
|
13323
|
-
"Timeout in ms for createConnState handler. Default: 5000"
|
|
13324
|
-
),
|
|
13325
|
-
onMigrateTimeout: external_exports.number().optional().describe("Timeout in ms for onMigrate handler. Default: 30000"),
|
|
13326
|
-
onBeforeConnectTimeout: external_exports.number().optional().describe(
|
|
13327
|
-
"Timeout in ms for onBeforeConnect handler. Default: 5000"
|
|
13328
|
-
),
|
|
13329
|
-
onConnectTimeout: external_exports.number().optional().describe("Timeout in ms for onConnect handler. Default: 5000"),
|
|
13330
|
-
sleepGracePeriod: external_exports.number().optional().describe(
|
|
13331
|
-
`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}.`
|
|
13332
|
-
),
|
|
13333
|
-
onDestroyTimeout: 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
|
-
waitUntilTimeout: external_exports.number().optional().describe(
|
|
13337
|
-
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
13338
|
-
),
|
|
13339
|
-
stateSaveInterval: external_exports.number().optional().describe(
|
|
13340
|
-
"Interval in ms between automatic state saves. Default: 1000"
|
|
13341
|
-
),
|
|
13342
|
-
actionTimeout: external_exports.number().optional().describe("Timeout in ms for action handlers. Default: 60000"),
|
|
13343
|
-
connectionLivenessTimeout: external_exports.number().optional().describe(
|
|
13344
|
-
"Timeout in ms for connection liveness checks. Default: 2500"
|
|
13345
|
-
),
|
|
13346
|
-
connectionLivenessInterval: external_exports.number().optional().describe(
|
|
13347
|
-
"Interval in ms between connection liveness checks. Default: 5000"
|
|
13348
|
-
),
|
|
13349
|
-
noSleep: external_exports.boolean().optional().describe(
|
|
13350
|
-
"Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
|
|
13351
|
-
),
|
|
13352
|
-
sleepTimeout: external_exports.number().optional().describe(
|
|
13353
|
-
"Time in ms of inactivity before the actor sleeps. Default: 30000"
|
|
13354
|
-
),
|
|
13355
|
-
maxQueueSize: external_exports.number().optional().describe(
|
|
13356
|
-
"Maximum number of queue messages before rejecting new messages. Default: 1000"
|
|
13357
|
-
),
|
|
13358
|
-
maxSchedules: external_exports.number().int().nonnegative().optional().describe(
|
|
13359
|
-
"Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
|
|
13360
|
-
),
|
|
13361
|
-
maxQueueMessageSize: external_exports.number().optional().describe(
|
|
13362
|
-
"Maximum size of each queue message in bytes. Default: 65536"
|
|
13363
|
-
),
|
|
13364
|
-
canHibernateWebSocket: external_exports.boolean().optional().describe(
|
|
13365
|
-
"Whether WebSockets using onWebSocket can be hibernated. WebSockets using actions/events are hibernatable by default. Default: false"
|
|
13366
|
-
)
|
|
13367
|
-
}).describe("Actor options for timeouts and behavior configuration.");
|
|
13368
|
-
var DocActorConfigSchema = external_exports.object({
|
|
13369
|
-
state: external_exports.unknown().optional().describe(
|
|
13370
|
-
"Initial state value for the actor. Cannot be used with createState."
|
|
13371
|
-
),
|
|
13372
|
-
createState: external_exports.unknown().optional().describe(
|
|
13373
|
-
"Function to create initial state. Receives context and input. Cannot be used with state."
|
|
13374
|
-
),
|
|
13375
|
-
connState: external_exports.unknown().optional().describe(
|
|
13376
|
-
"Initial connection state value. Cannot be used with createConnState."
|
|
13377
|
-
),
|
|
13378
|
-
createConnState: external_exports.unknown().optional().describe(
|
|
13379
|
-
"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."
|
|
13380
|
-
),
|
|
13381
|
-
vars: external_exports.unknown().optional().describe(
|
|
13382
|
-
"Initial ephemeral variables value. Cannot be used with createVars."
|
|
13383
|
-
),
|
|
13384
|
-
createVars: external_exports.unknown().optional().describe(
|
|
13385
|
-
"Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
|
|
13386
|
-
),
|
|
13387
|
-
db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
|
|
13388
|
-
onCreate: external_exports.unknown().optional().describe(
|
|
13389
|
-
"Called when the actor is first initialized. Use to initialize state."
|
|
13390
|
-
),
|
|
13391
|
-
onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
|
|
13392
|
-
onMigrate: external_exports.unknown().optional().describe(
|
|
13393
|
-
"Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
|
|
13394
|
-
),
|
|
13395
|
-
onWake: external_exports.unknown().optional().describe(
|
|
13396
|
-
"Called when the actor wakes up and is ready to receive connections and actions."
|
|
13397
|
-
),
|
|
13398
|
-
onSleep: external_exports.unknown().optional().describe(
|
|
13399
|
-
"Called when the actor is stopping or sleeping. Use to clean up resources."
|
|
13400
|
-
),
|
|
13401
|
-
run: external_exports.unknown().optional().describe(
|
|
13402
|
-
"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."
|
|
13403
|
-
),
|
|
13404
|
-
onStateChange: external_exports.unknown().optional().describe(
|
|
13405
|
-
"Called when the actor's state changes. State changes within this hook won't trigger recursion."
|
|
13406
|
-
),
|
|
13407
|
-
onBeforeConnect: external_exports.unknown().optional().describe(
|
|
13408
|
-
"Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
|
|
13409
|
-
),
|
|
13410
|
-
onConnect: external_exports.unknown().optional().describe(
|
|
13411
|
-
"Called when a client successfully connects. The connection is visible in c.conns before this runs."
|
|
13412
|
-
),
|
|
13413
|
-
onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
|
|
13414
|
-
onBeforeActionResponse: external_exports.unknown().optional().describe(
|
|
13415
|
-
"Called before sending an action response. Use to transform output."
|
|
13416
|
-
),
|
|
13417
|
-
onRequest: external_exports.unknown().optional().describe(
|
|
13418
|
-
"Called for raw HTTP requests to /actors/{name}/http/* endpoints."
|
|
13419
|
-
),
|
|
13420
|
-
onWebSocket: external_exports.unknown().optional().describe(
|
|
13421
|
-
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
13422
|
-
),
|
|
13423
|
-
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
13424
|
-
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
13425
|
-
),
|
|
13426
|
-
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
13427
|
-
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
13428
|
-
),
|
|
13429
|
-
connParamsSchema: external_exports.unknown().optional().describe(
|
|
13430
|
-
"Optional schema for validating connection params in native runtimes."
|
|
13431
|
-
),
|
|
13432
|
-
events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
|
|
13433
|
-
queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
|
|
13434
|
-
options: DocActorOptionsSchema.optional()
|
|
13435
|
-
}).describe("Actor configuration passed to the actor() function.");
|
|
13436
|
-
|
|
13437
|
-
// ../rivetkit/dist/tsup/chunk-ZZ3WBRPD.js
|
|
13438
|
-
var INTERNAL_ERROR_CODE = "internal_error";
|
|
13439
|
-
var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
|
|
13440
|
-
var USER_ERROR_CODE = "user_error";
|
|
13441
|
-
var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
|
|
13442
|
-
function looksLikeRivetErrorOptions(value) {
|
|
13443
|
-
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "statusCode" in value || "actor" in value || "cause" in value);
|
|
13444
|
-
}
|
|
13445
|
-
function isTypedErrorTag(value) {
|
|
13446
|
-
return value === "ActorError" || value === "RivetError";
|
|
13447
|
-
}
|
|
13448
|
-
function errorMessage(error46, fallback = String(error46)) {
|
|
13449
|
-
if (error46 && typeof error46 === "object" && "message" in error46 && typeof error46.message === "string") {
|
|
13450
|
-
return error46.message;
|
|
13451
|
-
}
|
|
13452
|
-
return fallback;
|
|
13453
|
-
}
|
|
13454
|
-
function isRivetErrorLike(error46) {
|
|
13455
|
-
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" && (!("__type" in error46) || isTypedErrorTag(error46.__type));
|
|
13456
|
-
}
|
|
13457
|
-
function isActorAbortedError(error46) {
|
|
13458
|
-
return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
|
|
13459
|
-
}
|
|
13460
|
-
function isActorSpecifier(value) {
|
|
13461
|
-
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");
|
|
13462
|
-
}
|
|
13463
|
-
var RivetError = class extends Error {
|
|
13464
|
-
__type = "RivetError";
|
|
13465
|
-
public;
|
|
13466
|
-
metadata;
|
|
13467
|
-
statusCode;
|
|
13468
|
-
actor;
|
|
13469
|
-
group;
|
|
13470
|
-
code;
|
|
13471
|
-
static isRivetError(error46) {
|
|
13472
|
-
return isRivetErrorLike(error46);
|
|
13473
|
-
}
|
|
13474
|
-
static isActorError(error46) {
|
|
13475
|
-
return isRivetErrorLike(error46);
|
|
13476
|
-
}
|
|
13477
|
-
constructor(group, code, message, options) {
|
|
13478
|
-
const normalized = looksLikeRivetErrorOptions(options) ? options : { metadata: options };
|
|
13479
|
-
super(message, { cause: normalized.cause });
|
|
13480
|
-
this.name = "RivetError";
|
|
13481
|
-
this.group = group;
|
|
13482
|
-
this.code = code;
|
|
13483
|
-
this.public = normalized.public ?? false;
|
|
13484
|
-
this.metadata = normalized.metadata;
|
|
13485
|
-
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
13486
|
-
this.actor = normalized.actor;
|
|
13487
|
-
}
|
|
13488
|
-
toString() {
|
|
13489
|
-
return this.message;
|
|
13490
|
-
}
|
|
13491
|
-
};
|
|
13492
|
-
var UserError = class extends RivetError {
|
|
13493
|
-
constructor(message, options) {
|
|
13494
|
-
super("user", (options == null ? void 0 : options.code) ?? USER_ERROR_CODE, message, {
|
|
13495
|
-
public: true,
|
|
13496
|
-
metadata: options == null ? void 0 : options.metadata,
|
|
13497
|
-
cause: options == null ? void 0 : options.cause
|
|
13498
|
-
});
|
|
13499
|
-
}
|
|
13500
|
-
};
|
|
13501
|
-
function toRivetError(error46, fallback) {
|
|
13502
|
-
if (typeof error46 === "string") {
|
|
13503
|
-
const bridged = decodeBridgeRivetError(error46);
|
|
13504
|
-
if (bridged) {
|
|
13505
|
-
return bridged;
|
|
13506
|
-
}
|
|
13507
|
-
}
|
|
13508
|
-
if (error46 instanceof Error) {
|
|
13509
|
-
const bridged = decodeBridgeRivetError(error46.message);
|
|
13510
|
-
if (bridged) {
|
|
13511
|
-
return bridged;
|
|
13512
|
-
}
|
|
13513
|
-
}
|
|
13514
|
-
if (isRivetErrorLike(error46)) {
|
|
13515
|
-
return new RivetError(error46.group, error46.code, error46.message, {
|
|
13516
|
-
public: error46.public,
|
|
13517
|
-
statusCode: error46.statusCode,
|
|
13518
|
-
metadata: error46.metadata,
|
|
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
|
-
actor: fallback == null ? void 0 : fallback.actor,
|
|
13532
|
-
cause: error46 instanceof Error ? error46 : void 0
|
|
13533
|
-
}
|
|
13534
|
-
);
|
|
13535
|
-
}
|
|
13536
|
-
function encodeBridgeRivetError(error46) {
|
|
13537
|
-
return `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({
|
|
13538
|
-
group: error46.group,
|
|
13539
|
-
code: error46.code,
|
|
13540
|
-
message: error46.message,
|
|
13541
|
-
metadata: error46.metadata,
|
|
13542
|
-
public: error46.public,
|
|
13543
|
-
statusCode: error46.statusCode,
|
|
13544
|
-
actor: error46.actor
|
|
13545
|
-
})}`;
|
|
13546
|
-
}
|
|
13547
|
-
function decodeBridgeRivetErrorPayload(value) {
|
|
13548
|
-
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
13549
|
-
return void 0;
|
|
13550
|
-
}
|
|
13551
|
-
try {
|
|
13552
|
-
const payload = JSON.parse(
|
|
13553
|
-
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
|
|
13554
|
-
);
|
|
13555
|
-
if (!isRivetErrorLike(payload)) {
|
|
13556
|
-
return void 0;
|
|
13557
|
-
}
|
|
13558
|
-
if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
|
|
13559
|
-
return void 0;
|
|
13560
|
-
}
|
|
13561
|
-
return payload;
|
|
13562
|
-
} catch {
|
|
13563
|
-
return void 0;
|
|
13564
|
-
}
|
|
13565
|
-
}
|
|
13566
|
-
function decodeBridgeRivetError(value) {
|
|
13567
|
-
const payload = decodeBridgeRivetErrorPayload(value);
|
|
13568
|
-
if (!payload) {
|
|
13569
|
-
return void 0;
|
|
13570
|
-
}
|
|
13571
|
-
return new RivetError(payload.group, payload.code, payload.message, {
|
|
13572
|
-
metadata: payload.metadata,
|
|
13573
|
-
public: payload.public,
|
|
13574
|
-
statusCode: payload.statusCode,
|
|
13575
|
-
actor: payload.actor ?? void 0
|
|
13576
|
-
});
|
|
13577
|
-
}
|
|
13578
|
-
function invalidRequest(error46) {
|
|
13579
|
-
return new RivetError(
|
|
13580
|
-
"request",
|
|
13581
|
-
"invalid",
|
|
13582
|
-
`Invalid request: ${errorMessage(error46, String(error46))}`,
|
|
13583
|
-
{
|
|
13584
|
-
public: true,
|
|
13585
|
-
cause: error46 instanceof Error ? error46 : void 0
|
|
13586
|
-
}
|
|
13587
|
-
);
|
|
13588
|
-
}
|
|
13589
|
-
function actorNotFound(identifier) {
|
|
13590
|
-
return new RivetError(
|
|
13591
|
-
"actor",
|
|
13592
|
-
"not_found",
|
|
13593
|
-
identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
|
|
13594
|
-
{ public: true }
|
|
13595
|
-
);
|
|
13596
|
-
}
|
|
13597
|
-
function forbiddenError() {
|
|
13598
|
-
return new RivetError("auth", "forbidden", "Forbidden", {
|
|
13599
|
-
public: true,
|
|
13600
|
-
statusCode: 403
|
|
13601
|
-
});
|
|
13602
|
-
}
|
|
13603
|
-
function unsupportedFeature(feature) {
|
|
13604
|
-
return new RivetError(
|
|
13605
|
-
"feature",
|
|
13606
|
-
"unsupported",
|
|
13607
|
-
`Unsupported feature: ${feature}`
|
|
13608
|
-
);
|
|
13609
|
-
}
|
|
13610
|
-
|
|
13611
|
-
// ../rivetkit/dist/tsup/chunk-XAGDGH4O.js
|
|
13612
|
-
var import_pino = require("pino");
|
|
13613
|
-
var cbor = __toESM(require("cbor-x"), 1);
|
|
13614
|
-
var import_invariant = __toESM(require_invariant(), 1);
|
|
13615
|
-
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
13616
|
-
var getRivetEndpoint = () => getEnvUniversal("RIVET_ENDPOINT");
|
|
13617
|
-
var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
|
|
13618
|
-
var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
|
|
13619
|
-
var getRivetPool = () => getEnvUniversal("RIVET_POOL");
|
|
13620
|
-
var getRivetTotalSlots = () => {
|
|
13621
|
-
const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
|
|
13622
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13623
|
-
};
|
|
13624
|
-
var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
|
|
13625
|
-
var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
|
|
13626
|
-
var getRivetRunEnginePort = () => {
|
|
13627
|
-
const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
|
|
13628
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13629
|
-
};
|
|
13630
|
-
var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
|
|
13631
|
-
var getRivetEnvoyVersion = () => {
|
|
13632
|
-
const value = getEnvUniversal("RIVET_ENVOY_VERSION");
|
|
13633
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13634
|
-
};
|
|
13635
|
-
var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
|
|
13636
|
-
var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
|
|
13637
|
-
var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
|
|
13638
|
-
var getRivetkitRuntimeMode = () => {
|
|
13639
|
-
const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
|
|
13640
|
-
if (value === void 0) return "envoy";
|
|
13641
|
-
if (value === "envoy" || value === "serverless") return value;
|
|
13642
|
-
throw new Error(
|
|
13643
|
-
`RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
|
|
13644
|
-
);
|
|
13645
|
-
};
|
|
13646
|
-
var getRivetkitPublicDir = () => {
|
|
13647
|
-
const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
|
|
13648
|
-
return value === void 0 || value === "" ? void 0 : value;
|
|
13649
|
-
};
|
|
13650
|
-
function parsePortEnv(raw) {
|
|
13651
|
-
if (raw === void 0 || raw === "") return void 0;
|
|
13652
|
-
const parsed = Number.parseInt(raw, 10);
|
|
13653
|
-
if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
|
|
13654
|
-
throw new Error(
|
|
13655
|
-
`RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
|
|
13656
|
-
);
|
|
13657
|
-
}
|
|
13658
|
-
return parsed;
|
|
13230
|
+
return parsed;
|
|
13659
13231
|
}
|
|
13660
13232
|
var getLogLevel = () => getEnvUniversal("RIVET_LOG_LEVEL") ?? getEnvUniversal("LOG_LEVEL");
|
|
13661
13233
|
var getLogTarget = () => getEnvUniversal("RIVET_LOG_TARGET") === "1";
|
|
@@ -13774,7 +13346,7 @@ function noopNext() {
|
|
|
13774
13346
|
}
|
|
13775
13347
|
var package_default = {
|
|
13776
13348
|
name: "rivetkit",
|
|
13777
|
-
version: "2.3.11-rc.
|
|
13349
|
+
version: "2.3.11-rc.9",
|
|
13778
13350
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13779
13351
|
license: "Apache-2.0",
|
|
13780
13352
|
keywords: [
|
|
@@ -15067,7 +14639,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
|
|
|
15067
14639
|
};
|
|
15068
14640
|
}
|
|
15069
14641
|
|
|
15070
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14642
|
+
// ../rivetkit/dist/tsup/chunk-C5TORAVP.js
|
|
15071
14643
|
var config2 = /* @__PURE__ */ Config({});
|
|
15072
14644
|
function readWorkflowCbor(bc) {
|
|
15073
14645
|
return readData(bc);
|
|
@@ -15245,125 +14817,555 @@ function readWorkflowVersionCheckEntry(bc) {
|
|
|
15245
14817
|
latest: readU32(bc)
|
|
15246
14818
|
};
|
|
15247
14819
|
}
|
|
15248
|
-
function readWorkflowEntryKind(bc) {
|
|
15249
|
-
const offset = bc.offset;
|
|
15250
|
-
const tag = readU8(bc);
|
|
15251
|
-
switch (tag) {
|
|
15252
|
-
case 0:
|
|
15253
|
-
return { tag: "WorkflowStepEntry", val: readWorkflowStepEntry(bc) };
|
|
15254
|
-
case 1:
|
|
15255
|
-
return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
|
|
15256
|
-
case 2:
|
|
15257
|
-
return {
|
|
15258
|
-
tag: "WorkflowSleepEntry",
|
|
15259
|
-
val: readWorkflowSleepEntry(bc)
|
|
15260
|
-
};
|
|
15261
|
-
case 3:
|
|
15262
|
-
return {
|
|
15263
|
-
tag: "WorkflowMessageEntry",
|
|
15264
|
-
val: readWorkflowMessageEntry(bc)
|
|
15265
|
-
};
|
|
15266
|
-
case 4:
|
|
15267
|
-
return {
|
|
15268
|
-
tag: "WorkflowRollbackCheckpointEntry",
|
|
15269
|
-
val: readWorkflowRollbackCheckpointEntry(bc)
|
|
15270
|
-
};
|
|
15271
|
-
case 5:
|
|
15272
|
-
return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
|
|
15273
|
-
case 6:
|
|
15274
|
-
return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
|
|
15275
|
-
case 7:
|
|
15276
|
-
return {
|
|
15277
|
-
tag: "WorkflowRemovedEntry",
|
|
15278
|
-
val: readWorkflowRemovedEntry(bc)
|
|
15279
|
-
};
|
|
15280
|
-
case 8:
|
|
15281
|
-
return {
|
|
15282
|
-
tag: "WorkflowVersionCheckEntry",
|
|
15283
|
-
val: readWorkflowVersionCheckEntry(bc)
|
|
15284
|
-
};
|
|
15285
|
-
default: {
|
|
15286
|
-
bc.offset = offset;
|
|
15287
|
-
throw new BareError(offset, "invalid tag");
|
|
14820
|
+
function readWorkflowEntryKind(bc) {
|
|
14821
|
+
const offset = bc.offset;
|
|
14822
|
+
const tag = readU8(bc);
|
|
14823
|
+
switch (tag) {
|
|
14824
|
+
case 0:
|
|
14825
|
+
return { tag: "WorkflowStepEntry", val: readWorkflowStepEntry(bc) };
|
|
14826
|
+
case 1:
|
|
14827
|
+
return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
|
|
14828
|
+
case 2:
|
|
14829
|
+
return {
|
|
14830
|
+
tag: "WorkflowSleepEntry",
|
|
14831
|
+
val: readWorkflowSleepEntry(bc)
|
|
14832
|
+
};
|
|
14833
|
+
case 3:
|
|
14834
|
+
return {
|
|
14835
|
+
tag: "WorkflowMessageEntry",
|
|
14836
|
+
val: readWorkflowMessageEntry(bc)
|
|
14837
|
+
};
|
|
14838
|
+
case 4:
|
|
14839
|
+
return {
|
|
14840
|
+
tag: "WorkflowRollbackCheckpointEntry",
|
|
14841
|
+
val: readWorkflowRollbackCheckpointEntry(bc)
|
|
14842
|
+
};
|
|
14843
|
+
case 5:
|
|
14844
|
+
return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
|
|
14845
|
+
case 6:
|
|
14846
|
+
return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
|
|
14847
|
+
case 7:
|
|
14848
|
+
return {
|
|
14849
|
+
tag: "WorkflowRemovedEntry",
|
|
14850
|
+
val: readWorkflowRemovedEntry(bc)
|
|
14851
|
+
};
|
|
14852
|
+
case 8:
|
|
14853
|
+
return {
|
|
14854
|
+
tag: "WorkflowVersionCheckEntry",
|
|
14855
|
+
val: readWorkflowVersionCheckEntry(bc)
|
|
14856
|
+
};
|
|
14857
|
+
default: {
|
|
14858
|
+
bc.offset = offset;
|
|
14859
|
+
throw new BareError(offset, "invalid tag");
|
|
14860
|
+
}
|
|
14861
|
+
}
|
|
14862
|
+
}
|
|
14863
|
+
function readWorkflowEntry(bc) {
|
|
14864
|
+
return {
|
|
14865
|
+
id: readString(bc),
|
|
14866
|
+
location: readWorkflowLocation(bc),
|
|
14867
|
+
kind: readWorkflowEntryKind(bc)
|
|
14868
|
+
};
|
|
14869
|
+
}
|
|
14870
|
+
function read3(bc) {
|
|
14871
|
+
return readBool(bc) ? readU64(bc) : null;
|
|
14872
|
+
}
|
|
14873
|
+
function readWorkflowEntryMetadata(bc) {
|
|
14874
|
+
return {
|
|
14875
|
+
status: readWorkflowEntryStatus(bc),
|
|
14876
|
+
error: read1(bc),
|
|
14877
|
+
attempts: readU32(bc),
|
|
14878
|
+
lastAttemptAt: readU64(bc),
|
|
14879
|
+
createdAt: readU64(bc),
|
|
14880
|
+
completedAt: read3(bc),
|
|
14881
|
+
rollbackCompletedAt: read3(bc),
|
|
14882
|
+
rollbackError: read1(bc)
|
|
14883
|
+
};
|
|
14884
|
+
}
|
|
14885
|
+
function read4(bc) {
|
|
14886
|
+
const len = readUintSafe(bc);
|
|
14887
|
+
if (len === 0) {
|
|
14888
|
+
return [];
|
|
14889
|
+
}
|
|
14890
|
+
const result = [readString(bc)];
|
|
14891
|
+
for (let i = 1; i < len; i++) {
|
|
14892
|
+
result[i] = readString(bc);
|
|
14893
|
+
}
|
|
14894
|
+
return result;
|
|
14895
|
+
}
|
|
14896
|
+
function read5(bc) {
|
|
14897
|
+
const len = readUintSafe(bc);
|
|
14898
|
+
if (len === 0) {
|
|
14899
|
+
return [];
|
|
14900
|
+
}
|
|
14901
|
+
const result = [readWorkflowEntry(bc)];
|
|
14902
|
+
for (let i = 1; i < len; i++) {
|
|
14903
|
+
result[i] = readWorkflowEntry(bc);
|
|
14904
|
+
}
|
|
14905
|
+
return result;
|
|
14906
|
+
}
|
|
14907
|
+
function read6(bc) {
|
|
14908
|
+
const len = readUintSafe(bc);
|
|
14909
|
+
const result = /* @__PURE__ */ new Map();
|
|
14910
|
+
for (let i = 0; i < len; i++) {
|
|
14911
|
+
const offset = bc.offset;
|
|
14912
|
+
const key = readString(bc);
|
|
14913
|
+
if (result.has(key)) {
|
|
14914
|
+
bc.offset = offset;
|
|
14915
|
+
throw new BareError(offset, "duplicated key");
|
|
14916
|
+
}
|
|
14917
|
+
result.set(key, readWorkflowEntryMetadata(bc));
|
|
14918
|
+
}
|
|
14919
|
+
return result;
|
|
14920
|
+
}
|
|
14921
|
+
function readWorkflowHistory(bc) {
|
|
14922
|
+
return {
|
|
14923
|
+
nameRegistry: read4(bc),
|
|
14924
|
+
entries: read5(bc),
|
|
14925
|
+
entryMetadata: read6(bc)
|
|
14926
|
+
};
|
|
14927
|
+
}
|
|
14928
|
+
function decodeWorkflowHistory(bytes) {
|
|
14929
|
+
const bc = new ByteCursor(bytes, config2);
|
|
14930
|
+
const result = readWorkflowHistory(bc);
|
|
14931
|
+
if (bc.offset < bc.view.byteLength) {
|
|
14932
|
+
throw new BareError(bc.offset, "remaining bytes");
|
|
14933
|
+
}
|
|
14934
|
+
return result;
|
|
14935
|
+
}
|
|
14936
|
+
function decodeWorkflowHistoryTransport(data) {
|
|
14937
|
+
return decodeWorkflowHistory(toUint8Array(data));
|
|
14938
|
+
}
|
|
14939
|
+
|
|
14940
|
+
// ../rivetkit/dist/tsup/chunk-QWLJCP3X.js
|
|
14941
|
+
function flattenActionHandlers(actions) {
|
|
14942
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14943
|
+
for (const { name, handler } of collectActionEntries(actions)) {
|
|
14944
|
+
flattened[name] = handler;
|
|
14945
|
+
}
|
|
14946
|
+
return flattened;
|
|
14947
|
+
}
|
|
14948
|
+
function flattenActionInputSchemas(actions, schemas) {
|
|
14949
|
+
if (schemas === void 0) return void 0;
|
|
14950
|
+
if (!isRecord(schemas)) {
|
|
14951
|
+
throw new TypeError("actionInputSchemas must be an object");
|
|
14952
|
+
}
|
|
14953
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14954
|
+
for (const { name, path: path2 } of collectActionEntries(actions)) {
|
|
14955
|
+
const nestedSchema = lookupNestedSchema(schemas, path2);
|
|
14956
|
+
const flatSchema = schemas[name];
|
|
14957
|
+
if (nestedSchema !== void 0 && flatSchema !== void 0 && nestedSchema !== flatSchema) {
|
|
14958
|
+
throw new TypeError(
|
|
14959
|
+
`Action input schema \`${name}\` is defined by both a nested path and a dotted key`
|
|
14960
|
+
);
|
|
14961
|
+
}
|
|
14962
|
+
const schema = nestedSchema ?? flatSchema;
|
|
14963
|
+
if (schema !== void 0) {
|
|
14964
|
+
flattened[name] = schema;
|
|
14965
|
+
}
|
|
14966
|
+
}
|
|
14967
|
+
return flattened;
|
|
14968
|
+
}
|
|
14969
|
+
function collectActionEntries(actions) {
|
|
14970
|
+
const entries = [];
|
|
14971
|
+
const names = /* @__PURE__ */ new Set();
|
|
14972
|
+
visitActionGroup(actions ?? {}, [], entries, names);
|
|
14973
|
+
return entries;
|
|
14974
|
+
}
|
|
14975
|
+
function visitActionGroup(value, path2, entries, names) {
|
|
14976
|
+
if (!isRecord(value)) {
|
|
14977
|
+
throw new TypeError(
|
|
14978
|
+
`${formatActionPath(path2)} must be an action handler or group`
|
|
14979
|
+
);
|
|
14980
|
+
}
|
|
14981
|
+
for (const [segment, child] of Object.entries(value)) {
|
|
14982
|
+
const childPath = [...path2, segment];
|
|
14983
|
+
if (typeof child === "function") {
|
|
14984
|
+
const name = childPath.join(".");
|
|
14985
|
+
if (names.has(name)) {
|
|
14986
|
+
throw new TypeError(
|
|
14987
|
+
`Multiple action definitions flatten to \`${name}\``
|
|
14988
|
+
);
|
|
14989
|
+
}
|
|
14990
|
+
names.add(name);
|
|
14991
|
+
entries.push({
|
|
14992
|
+
name,
|
|
14993
|
+
path: childPath,
|
|
14994
|
+
handler: child
|
|
14995
|
+
});
|
|
14996
|
+
} else {
|
|
14997
|
+
visitActionGroup(child, childPath, entries, names);
|
|
14998
|
+
}
|
|
14999
|
+
}
|
|
15000
|
+
}
|
|
15001
|
+
function lookupNestedSchema(schemas, path2) {
|
|
15002
|
+
let value = schemas;
|
|
15003
|
+
for (const segment of path2) {
|
|
15004
|
+
if (!isRecord(value) || !Object.hasOwn(value, segment)) {
|
|
15005
|
+
return void 0;
|
|
15288
15006
|
}
|
|
15007
|
+
value = value[segment];
|
|
15289
15008
|
}
|
|
15009
|
+
return value;
|
|
15290
15010
|
}
|
|
15291
|
-
function
|
|
15292
|
-
|
|
15293
|
-
|
|
15294
|
-
|
|
15295
|
-
|
|
15296
|
-
|
|
15011
|
+
function isRecord(value) {
|
|
15012
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15013
|
+
return false;
|
|
15014
|
+
}
|
|
15015
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15016
|
+
return prototype === Object.prototype || prototype === null;
|
|
15297
15017
|
}
|
|
15298
|
-
function
|
|
15299
|
-
return
|
|
15018
|
+
function formatActionPath(path2) {
|
|
15019
|
+
return path2.length === 0 ? "actions" : `Action \`${path2.join(".")}\``;
|
|
15300
15020
|
}
|
|
15301
|
-
|
|
15302
|
-
|
|
15303
|
-
|
|
15304
|
-
|
|
15305
|
-
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
}
|
|
15021
|
+
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
15022
|
+
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
15023
|
+
"rivetkit.actor_context_internal"
|
|
15024
|
+
);
|
|
15025
|
+
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
15026
|
+
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
15027
|
+
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
15028
|
+
var zActionTree = external_exports.custom((value) => {
|
|
15029
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15030
|
+
return false;
|
|
15031
|
+
}
|
|
15032
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15033
|
+
return prototype === Object.prototype || prototype === null;
|
|
15034
|
+
}).superRefine((actions, ctx) => {
|
|
15035
|
+
try {
|
|
15036
|
+
flattenActionHandlers(actions);
|
|
15037
|
+
} catch (error46) {
|
|
15038
|
+
ctx.addIssue({
|
|
15039
|
+
code: "custom",
|
|
15040
|
+
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
15041
|
+
});
|
|
15042
|
+
}
|
|
15043
|
+
});
|
|
15044
|
+
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
15045
|
+
getHistory: zFunction(),
|
|
15046
|
+
onHistoryUpdated: zFunction().optional(),
|
|
15047
|
+
replayFromStep: zFunction().optional()
|
|
15048
|
+
});
|
|
15049
|
+
var RunInspectorConfigSchema = external_exports.object({
|
|
15050
|
+
workflow: WorkflowInspectorConfigSchema.optional()
|
|
15051
|
+
}).optional();
|
|
15052
|
+
var BUILTIN_INSPECTOR_TAB_IDS = [
|
|
15053
|
+
"workflow",
|
|
15054
|
+
"database",
|
|
15055
|
+
"state",
|
|
15056
|
+
"queue",
|
|
15057
|
+
"schedules",
|
|
15058
|
+
"connections",
|
|
15059
|
+
"console"
|
|
15060
|
+
];
|
|
15061
|
+
var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
|
|
15062
|
+
var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
15063
|
+
var CustomInspectorTabEntrySchema = external_exports.object({
|
|
15064
|
+
id: external_exports.string().regex(
|
|
15065
|
+
CUSTOM_INSPECTOR_TAB_ID_RE,
|
|
15066
|
+
"inspector.tabs[].id must contain only letters, digits, underscore, or dash"
|
|
15067
|
+
),
|
|
15068
|
+
label: external_exports.string().min(1),
|
|
15069
|
+
source: external_exports.string().min(1),
|
|
15070
|
+
/**
|
|
15071
|
+
* Optional icon id. The dashboard maps strings to glyphs (see its
|
|
15072
|
+
* icon registry); unknown ids fall back to a generic icon.
|
|
15073
|
+
*/
|
|
15074
|
+
icon: external_exports.string().min(1).optional(),
|
|
15075
|
+
hidden: external_exports.literal(false).optional()
|
|
15076
|
+
}).strict();
|
|
15077
|
+
var HideInspectorTabEntrySchema = external_exports.object({
|
|
15078
|
+
id: BuiltinInspectorTabIdSchema,
|
|
15079
|
+
hidden: external_exports.literal(true)
|
|
15080
|
+
}).strict();
|
|
15081
|
+
var InspectorTabEntrySchema = external_exports.union([
|
|
15082
|
+
CustomInspectorTabEntrySchema,
|
|
15083
|
+
HideInspectorTabEntrySchema
|
|
15084
|
+
]);
|
|
15085
|
+
var ActorInspectorConfigSchema = external_exports.object({
|
|
15086
|
+
tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
|
|
15087
|
+
}).strict().refine(
|
|
15088
|
+
(data) => {
|
|
15089
|
+
const ids = data.tabs.map((t) => t.id);
|
|
15090
|
+
return new Set(ids).size === ids.length;
|
|
15091
|
+
},
|
|
15092
|
+
{ message: "Duplicate id in inspector.tabs", path: ["tabs"] }
|
|
15093
|
+
).refine(
|
|
15094
|
+
(data) => {
|
|
15095
|
+
const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
|
|
15096
|
+
return data.tabs.every(
|
|
15097
|
+
(t) => t.hidden === true || !builtinSet.has(t.id)
|
|
15098
|
+
);
|
|
15099
|
+
},
|
|
15100
|
+
{
|
|
15101
|
+
message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
|
|
15102
|
+
path: ["tabs"]
|
|
15103
|
+
}
|
|
15104
|
+
);
|
|
15105
|
+
var RunConfigSchema = external_exports.object({
|
|
15106
|
+
/** Display name for the actor in the Inspector UI. */
|
|
15107
|
+
name: external_exports.string().optional(),
|
|
15108
|
+
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
15109
|
+
icon: external_exports.string().optional(),
|
|
15110
|
+
/** The run handler function. */
|
|
15111
|
+
run: zFunction(),
|
|
15112
|
+
/** Inspector integration for long-running run handlers. */
|
|
15113
|
+
inspector: RunInspectorConfigSchema.optional()
|
|
15114
|
+
});
|
|
15115
|
+
var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
15116
|
+
"rivetkit.run_function_config"
|
|
15117
|
+
);
|
|
15118
|
+
var zRunHandler = external_exports.union([zFunction(), RunConfigSchema]).optional();
|
|
15119
|
+
function getRunFunction(run) {
|
|
15120
|
+
if (!run) return void 0;
|
|
15121
|
+
if (typeof run === "function") return run;
|
|
15122
|
+
return run.run;
|
|
15312
15123
|
}
|
|
15313
|
-
function
|
|
15314
|
-
|
|
15315
|
-
if (
|
|
15316
|
-
|
|
15124
|
+
function getRunMetadata(run) {
|
|
15125
|
+
if (!run) return {};
|
|
15126
|
+
if (typeof run === "function") {
|
|
15127
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15128
|
+
if (!config3) return {};
|
|
15129
|
+
return { name: config3.name, icon: config3.icon };
|
|
15317
15130
|
}
|
|
15318
|
-
|
|
15319
|
-
|
|
15320
|
-
|
|
15131
|
+
return { name: run.name, icon: run.icon };
|
|
15132
|
+
}
|
|
15133
|
+
function getRunInspectorConfig(run, actor2) {
|
|
15134
|
+
if (!run) return void 0;
|
|
15135
|
+
if (typeof run === "function") {
|
|
15136
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15137
|
+
return (config3 == null ? void 0 : config3.inspectorFactory) ? config3.inspectorFactory(actor2) : config3 == null ? void 0 : config3.inspector;
|
|
15321
15138
|
}
|
|
15322
|
-
return
|
|
15139
|
+
return run.inspector;
|
|
15323
15140
|
}
|
|
15324
|
-
function
|
|
15325
|
-
|
|
15326
|
-
if (
|
|
15327
|
-
return
|
|
15141
|
+
function disposeRunInspector(run, actorId) {
|
|
15142
|
+
var _a2;
|
|
15143
|
+
if (!run || typeof run !== "function") {
|
|
15144
|
+
return;
|
|
15328
15145
|
}
|
|
15329
|
-
const
|
|
15330
|
-
|
|
15331
|
-
|
|
15146
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15147
|
+
(_a2 = config3 == null ? void 0 : config3.disposeInspector) == null ? void 0 : _a2.call(config3, actorId);
|
|
15148
|
+
}
|
|
15149
|
+
var GlobalActorOptionsBaseSchema = external_exports.object({
|
|
15150
|
+
/** Display name for the actor in the Inspector UI. */
|
|
15151
|
+
name: external_exports.string().optional(),
|
|
15152
|
+
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
15153
|
+
icon: external_exports.string().optional(),
|
|
15154
|
+
/** Enables the experimental Actor Runtime Socket for this actor. */
|
|
15155
|
+
enableActorRuntimeSocket: external_exports.boolean().default(false),
|
|
15156
|
+
/**
|
|
15157
|
+
* Can hibernate WebSockets for onWebSocket.
|
|
15158
|
+
*
|
|
15159
|
+
* WebSockets using actions/events are hibernatable by default.
|
|
15160
|
+
*
|
|
15161
|
+
* @experimental
|
|
15162
|
+
**/
|
|
15163
|
+
canHibernateWebSocket: external_exports.union([external_exports.boolean(), zFunction()]).default(false)
|
|
15164
|
+
}).strict();
|
|
15165
|
+
var GlobalActorOptionsSchema = GlobalActorOptionsBaseSchema.prefault(
|
|
15166
|
+
() => ({})
|
|
15167
|
+
);
|
|
15168
|
+
var InstanceActorOptionsBaseSchema = external_exports.object({
|
|
15169
|
+
createVarsTimeout: external_exports.number().positive().default(5e3),
|
|
15170
|
+
createConnStateTimeout: external_exports.number().positive().default(5e3),
|
|
15171
|
+
onBeforeConnectTimeout: external_exports.number().positive().default(5e3),
|
|
15172
|
+
onConnectTimeout: external_exports.number().positive().default(5e3),
|
|
15173
|
+
onMigrateTimeout: external_exports.number().positive().default(3e4),
|
|
15174
|
+
sleepGracePeriod: external_exports.number().positive().default(DEFAULT_SLEEP_GRACE_PERIOD),
|
|
15175
|
+
/** @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. */
|
|
15176
|
+
onDestroyTimeout: external_exports.number().positive().optional(),
|
|
15177
|
+
/** @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. */
|
|
15178
|
+
waitUntilTimeout: external_exports.number().positive().optional(),
|
|
15179
|
+
stateSaveInterval: external_exports.number().positive().default(1e3),
|
|
15180
|
+
actionTimeout: external_exports.number().positive().default(6e4),
|
|
15181
|
+
connectionLivenessTimeout: external_exports.number().positive().default(2500),
|
|
15182
|
+
connectionLivenessInterval: external_exports.number().positive().default(5e3),
|
|
15183
|
+
/** @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. */
|
|
15184
|
+
noSleep: external_exports.boolean().default(false),
|
|
15185
|
+
sleepTimeout: external_exports.number().positive().default(3e4),
|
|
15186
|
+
maxQueueSize: external_exports.number().positive().default(1e3),
|
|
15187
|
+
/** Maximum pending one-shot and recurring schedules. */
|
|
15188
|
+
maxSchedules: external_exports.number().int().nonnegative().default(1e3),
|
|
15189
|
+
maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
|
|
15190
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
15191
|
+
preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
|
|
15192
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
15193
|
+
preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
|
|
15194
|
+
}).strict();
|
|
15195
|
+
var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
|
|
15196
|
+
var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
|
|
15197
|
+
InstanceActorOptionsBaseSchema.shape
|
|
15198
|
+
).strict().prefault(() => ({}));
|
|
15199
|
+
var ActorConfigSchema = external_exports.object({
|
|
15200
|
+
onCreate: zFunction().optional(),
|
|
15201
|
+
onDestroy: zFunction().optional(),
|
|
15202
|
+
onMigrate: zFunction().optional(),
|
|
15203
|
+
onWake: zFunction().optional(),
|
|
15204
|
+
onSleep: zFunction().optional(),
|
|
15205
|
+
run: zRunHandler,
|
|
15206
|
+
onStateChange: zFunction().optional(),
|
|
15207
|
+
onBeforeConnect: zFunction().optional(),
|
|
15208
|
+
onConnect: zFunction().optional(),
|
|
15209
|
+
onDisconnect: zFunction().optional(),
|
|
15210
|
+
onBeforeActionResponse: zFunction().optional(),
|
|
15211
|
+
onRequest: zFunction().optional(),
|
|
15212
|
+
onWebSocket: zFunction().optional(),
|
|
15213
|
+
actions: zActionTree.default(() => ({})),
|
|
15214
|
+
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15215
|
+
connParamsSchema: external_exports.any().optional(),
|
|
15216
|
+
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15217
|
+
queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15218
|
+
state: external_exports.any().optional(),
|
|
15219
|
+
createState: zFunction().optional(),
|
|
15220
|
+
connState: external_exports.any().optional(),
|
|
15221
|
+
createConnState: zFunction().optional(),
|
|
15222
|
+
vars: external_exports.any().optional(),
|
|
15223
|
+
db: external_exports.any().optional(),
|
|
15224
|
+
createVars: zFunction().optional(),
|
|
15225
|
+
options: ActorOptionsSchema,
|
|
15226
|
+
inspector: ActorInspectorConfigSchema.optional()
|
|
15227
|
+
}).strict().refine(
|
|
15228
|
+
(data) => !(data.state !== void 0 && data.createState !== void 0),
|
|
15229
|
+
{
|
|
15230
|
+
message: "Cannot define both 'state' and 'createState'",
|
|
15231
|
+
path: ["state"]
|
|
15332
15232
|
}
|
|
15333
|
-
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
|
|
15337
|
-
|
|
15338
|
-
for (let i = 0; i < len; i++) {
|
|
15339
|
-
const offset = bc.offset;
|
|
15340
|
-
const key = readString(bc);
|
|
15341
|
-
if (result.has(key)) {
|
|
15342
|
-
bc.offset = offset;
|
|
15343
|
-
throw new BareError(offset, "duplicated key");
|
|
15344
|
-
}
|
|
15345
|
-
result.set(key, readWorkflowEntryMetadata(bc));
|
|
15233
|
+
).refine(
|
|
15234
|
+
(data) => !(data.connState !== void 0 && data.createConnState !== void 0),
|
|
15235
|
+
{
|
|
15236
|
+
message: "Cannot define both 'connState' and 'createConnState'",
|
|
15237
|
+
path: ["connState"]
|
|
15346
15238
|
}
|
|
15347
|
-
|
|
15348
|
-
|
|
15349
|
-
|
|
15350
|
-
|
|
15351
|
-
|
|
15352
|
-
entries: read5(bc),
|
|
15353
|
-
entryMetadata: read6(bc)
|
|
15354
|
-
};
|
|
15355
|
-
}
|
|
15356
|
-
function decodeWorkflowHistory(bytes) {
|
|
15357
|
-
const bc = new ByteCursor(bytes, config2);
|
|
15358
|
-
const result = readWorkflowHistory(bc);
|
|
15359
|
-
if (bc.offset < bc.view.byteLength) {
|
|
15360
|
-
throw new BareError(bc.offset, "remaining bytes");
|
|
15239
|
+
).refine(
|
|
15240
|
+
(data) => !(data.vars !== void 0 && data.createVars !== void 0),
|
|
15241
|
+
{
|
|
15242
|
+
message: "Cannot define both 'vars' and 'createVars'",
|
|
15243
|
+
path: ["vars"]
|
|
15361
15244
|
}
|
|
15362
|
-
|
|
15363
|
-
|
|
15364
|
-
|
|
15365
|
-
|
|
15366
|
-
}
|
|
15245
|
+
);
|
|
15246
|
+
var DocActorOptionsSchema = external_exports.object({
|
|
15247
|
+
name: external_exports.string().optional().describe("Display name for the actor in the Inspector UI."),
|
|
15248
|
+
icon: external_exports.string().optional().describe(
|
|
15249
|
+
"Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
|
|
15250
|
+
),
|
|
15251
|
+
enableActorRuntimeSocket: external_exports.boolean().optional().describe(
|
|
15252
|
+
"Enables the experimental Actor Runtime Socket for this actor. Default: false"
|
|
15253
|
+
),
|
|
15254
|
+
createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
|
|
15255
|
+
createConnStateTimeout: external_exports.number().optional().describe(
|
|
15256
|
+
"Timeout in ms for createConnState handler. Default: 5000"
|
|
15257
|
+
),
|
|
15258
|
+
onMigrateTimeout: external_exports.number().optional().describe("Timeout in ms for onMigrate handler. Default: 30000"),
|
|
15259
|
+
onBeforeConnectTimeout: external_exports.number().optional().describe(
|
|
15260
|
+
"Timeout in ms for onBeforeConnect handler. Default: 5000"
|
|
15261
|
+
),
|
|
15262
|
+
onConnectTimeout: external_exports.number().optional().describe("Timeout in ms for onConnect handler. Default: 5000"),
|
|
15263
|
+
sleepGracePeriod: external_exports.number().optional().describe(
|
|
15264
|
+
`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}.`
|
|
15265
|
+
),
|
|
15266
|
+
onDestroyTimeout: external_exports.number().optional().describe(
|
|
15267
|
+
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
15268
|
+
),
|
|
15269
|
+
waitUntilTimeout: external_exports.number().optional().describe(
|
|
15270
|
+
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
15271
|
+
),
|
|
15272
|
+
stateSaveInterval: external_exports.number().optional().describe(
|
|
15273
|
+
"Interval in ms between automatic state saves. Default: 1000"
|
|
15274
|
+
),
|
|
15275
|
+
actionTimeout: external_exports.number().optional().describe("Timeout in ms for action handlers. Default: 60000"),
|
|
15276
|
+
connectionLivenessTimeout: external_exports.number().optional().describe(
|
|
15277
|
+
"Timeout in ms for connection liveness checks. Default: 2500"
|
|
15278
|
+
),
|
|
15279
|
+
connectionLivenessInterval: external_exports.number().optional().describe(
|
|
15280
|
+
"Interval in ms between connection liveness checks. Default: 5000"
|
|
15281
|
+
),
|
|
15282
|
+
noSleep: external_exports.boolean().optional().describe(
|
|
15283
|
+
"Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
|
|
15284
|
+
),
|
|
15285
|
+
sleepTimeout: external_exports.number().optional().describe(
|
|
15286
|
+
"Time in ms of inactivity before the actor sleeps. Default: 30000"
|
|
15287
|
+
),
|
|
15288
|
+
maxQueueSize: external_exports.number().optional().describe(
|
|
15289
|
+
"Maximum number of queue messages before rejecting new messages. Default: 1000"
|
|
15290
|
+
),
|
|
15291
|
+
maxSchedules: external_exports.number().int().nonnegative().optional().describe(
|
|
15292
|
+
"Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
|
|
15293
|
+
),
|
|
15294
|
+
maxQueueMessageSize: external_exports.number().optional().describe(
|
|
15295
|
+
"Maximum size of each queue message in bytes. Default: 65536"
|
|
15296
|
+
),
|
|
15297
|
+
canHibernateWebSocket: external_exports.boolean().optional().describe(
|
|
15298
|
+
"Whether WebSockets using onWebSocket can be hibernated. WebSockets using actions/events are hibernatable by default. Default: false"
|
|
15299
|
+
)
|
|
15300
|
+
}).describe("Actor options for timeouts and behavior configuration.");
|
|
15301
|
+
var DocActorConfigSchema = external_exports.object({
|
|
15302
|
+
state: external_exports.unknown().optional().describe(
|
|
15303
|
+
"Initial state value for the actor. Cannot be used with createState."
|
|
15304
|
+
),
|
|
15305
|
+
createState: external_exports.unknown().optional().describe(
|
|
15306
|
+
"Function to create initial state. Receives context and input. Cannot be used with state."
|
|
15307
|
+
),
|
|
15308
|
+
connState: external_exports.unknown().optional().describe(
|
|
15309
|
+
"Initial connection state value. Cannot be used with createConnState."
|
|
15310
|
+
),
|
|
15311
|
+
createConnState: external_exports.unknown().optional().describe(
|
|
15312
|
+
"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."
|
|
15313
|
+
),
|
|
15314
|
+
vars: external_exports.unknown().optional().describe(
|
|
15315
|
+
"Initial ephemeral variables value. Cannot be used with createVars."
|
|
15316
|
+
),
|
|
15317
|
+
createVars: external_exports.unknown().optional().describe(
|
|
15318
|
+
"Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
|
|
15319
|
+
),
|
|
15320
|
+
db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
|
|
15321
|
+
onCreate: external_exports.unknown().optional().describe(
|
|
15322
|
+
"Called when the actor is first initialized. Use to initialize state."
|
|
15323
|
+
),
|
|
15324
|
+
onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
|
|
15325
|
+
onMigrate: external_exports.unknown().optional().describe(
|
|
15326
|
+
"Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
|
|
15327
|
+
),
|
|
15328
|
+
onWake: external_exports.unknown().optional().describe(
|
|
15329
|
+
"Called when the actor wakes up and is ready to receive connections and actions."
|
|
15330
|
+
),
|
|
15331
|
+
onSleep: external_exports.unknown().optional().describe(
|
|
15332
|
+
"Called when the actor is stopping or sleeping. Use to clean up resources."
|
|
15333
|
+
),
|
|
15334
|
+
run: external_exports.unknown().optional().describe(
|
|
15335
|
+
"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."
|
|
15336
|
+
),
|
|
15337
|
+
onStateChange: external_exports.unknown().optional().describe(
|
|
15338
|
+
"Called when the actor's state changes. State changes within this hook won't trigger recursion."
|
|
15339
|
+
),
|
|
15340
|
+
onBeforeConnect: external_exports.unknown().optional().describe(
|
|
15341
|
+
"Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
|
|
15342
|
+
),
|
|
15343
|
+
onConnect: external_exports.unknown().optional().describe(
|
|
15344
|
+
"Called when a client successfully connects. The connection is visible in c.conns before this runs."
|
|
15345
|
+
),
|
|
15346
|
+
onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
|
|
15347
|
+
onBeforeActionResponse: external_exports.unknown().optional().describe(
|
|
15348
|
+
"Called before sending an action response. Use to transform output."
|
|
15349
|
+
),
|
|
15350
|
+
onRequest: external_exports.unknown().optional().describe(
|
|
15351
|
+
"Called for raw HTTP requests to /actors/{name}/http/* endpoints."
|
|
15352
|
+
),
|
|
15353
|
+
onWebSocket: external_exports.unknown().optional().describe(
|
|
15354
|
+
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
15355
|
+
),
|
|
15356
|
+
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15357
|
+
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
15358
|
+
),
|
|
15359
|
+
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15360
|
+
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
15361
|
+
),
|
|
15362
|
+
connParamsSchema: external_exports.unknown().optional().describe(
|
|
15363
|
+
"Optional schema for validating connection params in native runtimes."
|
|
15364
|
+
),
|
|
15365
|
+
events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
|
|
15366
|
+
queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
|
|
15367
|
+
options: DocActorOptionsSchema.optional()
|
|
15368
|
+
}).describe("Actor configuration passed to the actor() function.");
|
|
15367
15369
|
|
|
15368
15370
|
// ../rivetkit/dist/tsup/chunk-JI6GZ2C2.js
|
|
15369
15371
|
var EMPTY_KEY = "/";
|
|
@@ -15482,7 +15484,7 @@ function removePrefixFromKey(prefixedKey) {
|
|
|
15482
15484
|
return prefixedKey.slice(KEYS.KV.length);
|
|
15483
15485
|
}
|
|
15484
15486
|
|
|
15485
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15487
|
+
// ../rivetkit/dist/tsup/chunk-XOOESJY7.js
|
|
15486
15488
|
function logger() {
|
|
15487
15489
|
return getLogger("actor-client");
|
|
15488
15490
|
}
|
|
@@ -15548,7 +15550,7 @@ var AsyncMutex = class {
|
|
|
15548
15550
|
}
|
|
15549
15551
|
};
|
|
15550
15552
|
|
|
15551
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15553
|
+
// ../rivetkit/dist/tsup/chunk-HOZ3ZLZ2.js
|
|
15552
15554
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15553
15555
|
|
|
15554
15556
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -15726,7 +15728,7 @@ function createVersionedDataHandler(config3) {
|
|
|
15726
15728
|
return new VersionedDataHandler(config3);
|
|
15727
15729
|
}
|
|
15728
15730
|
|
|
15729
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15731
|
+
// ../rivetkit/dist/tsup/chunk-HOZ3ZLZ2.js
|
|
15730
15732
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
15731
15733
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
15732
15734
|
var PATH_CONNECT = "/connect";
|
|
@@ -25350,6 +25352,83 @@ function createWriteThroughProxy(value, commit, beforeChange) {
|
|
|
25350
25352
|
}
|
|
25351
25353
|
);
|
|
25352
25354
|
}
|
|
25355
|
+
function unwrapProxy(value) {
|
|
25356
|
+
let current = value;
|
|
25357
|
+
while (current !== null && typeof current === "object") {
|
|
25358
|
+
const target = source_default.target(current);
|
|
25359
|
+
if (target === current) {
|
|
25360
|
+
break;
|
|
25361
|
+
}
|
|
25362
|
+
current = target;
|
|
25363
|
+
}
|
|
25364
|
+
return current;
|
|
25365
|
+
}
|
|
25366
|
+
function isPlainObject3(value) {
|
|
25367
|
+
const proto = Object.getPrototypeOf(value);
|
|
25368
|
+
return proto === Object.prototype || proto === null;
|
|
25369
|
+
}
|
|
25370
|
+
function unwrapDeep(value, seen) {
|
|
25371
|
+
const unwrapped = unwrapProxy(value);
|
|
25372
|
+
if (!unwrapped || typeof unwrapped !== "object") {
|
|
25373
|
+
return unwrapped;
|
|
25374
|
+
}
|
|
25375
|
+
if (seen.has(unwrapped)) {
|
|
25376
|
+
return unwrapped;
|
|
25377
|
+
}
|
|
25378
|
+
seen.add(unwrapped);
|
|
25379
|
+
if (Array.isArray(unwrapped)) {
|
|
25380
|
+
for (let i = 0; i < unwrapped.length; i++) {
|
|
25381
|
+
const child = unwrapDeep(unwrapped[i], seen);
|
|
25382
|
+
if (child !== unwrapped[i]) {
|
|
25383
|
+
unwrapped[i] = child;
|
|
25384
|
+
}
|
|
25385
|
+
}
|
|
25386
|
+
return unwrapped;
|
|
25387
|
+
}
|
|
25388
|
+
if (unwrapped instanceof Map) {
|
|
25389
|
+
const replacements = [];
|
|
25390
|
+
for (const [key, child] of unwrapped.entries()) {
|
|
25391
|
+
const nextKey = unwrapDeep(key, seen);
|
|
25392
|
+
const nextChild = unwrapDeep(child, seen);
|
|
25393
|
+
if (nextKey !== key || nextChild !== child) {
|
|
25394
|
+
replacements.push([key, nextKey, nextChild]);
|
|
25395
|
+
}
|
|
25396
|
+
}
|
|
25397
|
+
for (const [key, nextKey, nextChild] of replacements) {
|
|
25398
|
+
if (nextKey !== key) {
|
|
25399
|
+
unwrapped.delete(key);
|
|
25400
|
+
}
|
|
25401
|
+
unwrapped.set(nextKey, nextChild);
|
|
25402
|
+
}
|
|
25403
|
+
return unwrapped;
|
|
25404
|
+
}
|
|
25405
|
+
if (unwrapped instanceof Set) {
|
|
25406
|
+
const replacements = [];
|
|
25407
|
+
for (const child of unwrapped.values()) {
|
|
25408
|
+
const next = unwrapDeep(child, seen);
|
|
25409
|
+
if (next !== child) {
|
|
25410
|
+
replacements.push([child, next]);
|
|
25411
|
+
}
|
|
25412
|
+
}
|
|
25413
|
+
for (const [child, next] of replacements) {
|
|
25414
|
+
unwrapped.delete(child);
|
|
25415
|
+
unwrapped.add(next);
|
|
25416
|
+
}
|
|
25417
|
+
return unwrapped;
|
|
25418
|
+
}
|
|
25419
|
+
if (isPlainObject3(unwrapped)) {
|
|
25420
|
+
for (const key of Object.keys(unwrapped)) {
|
|
25421
|
+
const child = unwrapDeep(unwrapped[key], seen);
|
|
25422
|
+
if (child !== unwrapped[key]) {
|
|
25423
|
+
unwrapped[key] = child;
|
|
25424
|
+
}
|
|
25425
|
+
}
|
|
25426
|
+
}
|
|
25427
|
+
return unwrapped;
|
|
25428
|
+
}
|
|
25429
|
+
function unwrapWriteThroughProxy(value) {
|
|
25430
|
+
return unwrapDeep(value, /* @__PURE__ */ new Set());
|
|
25431
|
+
}
|
|
25353
25432
|
var textEncoder = new TextEncoder();
|
|
25354
25433
|
var textDecoder = new TextDecoder();
|
|
25355
25434
|
var defaultRuntimeLoaders = {
|
|
@@ -26036,8 +26115,23 @@ var NativeConnAdapter = class {
|
|
|
26036
26115
|
}
|
|
26037
26116
|
get state() {
|
|
26038
26117
|
const nextState = this.#readState();
|
|
26118
|
+
if (!this.#ctx) {
|
|
26119
|
+
return this.#createStateProxy(nextState);
|
|
26120
|
+
}
|
|
26121
|
+
const connState = getNativeConnPersistState(
|
|
26122
|
+
this.#runtime,
|
|
26123
|
+
this.#ctx,
|
|
26124
|
+
this.#conn
|
|
26125
|
+
);
|
|
26126
|
+
if (connState.stateProxy === void 0 || connState.stateProxyTarget !== nextState) {
|
|
26127
|
+
connState.stateProxyTarget = nextState;
|
|
26128
|
+
connState.stateProxy = this.#createStateProxy(nextState);
|
|
26129
|
+
}
|
|
26130
|
+
return connState.stateProxy;
|
|
26131
|
+
}
|
|
26132
|
+
#createStateProxy(state) {
|
|
26039
26133
|
return createWriteThroughProxy(
|
|
26040
|
-
|
|
26134
|
+
state,
|
|
26041
26135
|
(nextValue) => {
|
|
26042
26136
|
this.#writeState(nextValue, { writeNative: true });
|
|
26043
26137
|
},
|
|
@@ -26047,11 +26141,14 @@ var NativeConnAdapter = class {
|
|
|
26047
26141
|
);
|
|
26048
26142
|
}
|
|
26049
26143
|
set state(value) {
|
|
26050
|
-
|
|
26051
|
-
|
|
26144
|
+
const nextValue = unwrapWriteThroughProxy(value);
|
|
26145
|
+
assertJsonCompatValue(nextValue);
|
|
26146
|
+
this.#writeState(nextValue, { writeNative: true });
|
|
26052
26147
|
}
|
|
26053
26148
|
initializeState(value) {
|
|
26054
|
-
this.#writeState(value, {
|
|
26149
|
+
this.#writeState(unwrapWriteThroughProxy(value), {
|
|
26150
|
+
writeNative: false
|
|
26151
|
+
});
|
|
26055
26152
|
}
|
|
26056
26153
|
get isHibernatable() {
|
|
26057
26154
|
return callNativeSync(
|
|
@@ -27104,14 +27201,17 @@ var ActorContextHandleAdapter = class {
|
|
|
27104
27201
|
throw stateNotEnabledError();
|
|
27105
27202
|
}
|
|
27106
27203
|
this.#assertCanMutateState();
|
|
27107
|
-
|
|
27108
|
-
|
|
27204
|
+
const nextValue = unwrapWriteThroughProxy(value);
|
|
27205
|
+
assertJsonCompatValue(nextValue);
|
|
27206
|
+
this.#writeState(nextValue, { scheduleSave: true });
|
|
27109
27207
|
}
|
|
27110
27208
|
initializeState(value) {
|
|
27111
27209
|
if (!this.#stateEnabled) {
|
|
27112
27210
|
return;
|
|
27113
27211
|
}
|
|
27114
|
-
this.#writeState(value, {
|
|
27212
|
+
this.#writeState(unwrapWriteThroughProxy(value), {
|
|
27213
|
+
scheduleSave: false
|
|
27214
|
+
});
|
|
27115
27215
|
}
|
|
27116
27216
|
get vars() {
|
|
27117
27217
|
const runtimeState = getNativeRuntimeState(this.#runtime, this.#ctx);
|