@rivetkit/supabase 2.3.24-rc.1 → 2.3.24
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 +154 -363
- package/dist/mod.mjs +154 -363
- package/package.json +3 -3
package/dist/mod.mjs
CHANGED
|
@@ -500,7 +500,7 @@ function unsupportedFeature(feature) {
|
|
|
500
500
|
);
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
503
|
+
// ../rivetkit/dist/tsup/chunk-YH2CAWLD.js
|
|
504
504
|
import {
|
|
505
505
|
pino,
|
|
506
506
|
stdTimeFunctions
|
|
@@ -13176,7 +13176,7 @@ var classic_default = external_exports;
|
|
|
13176
13176
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
|
|
13177
13177
|
var v4_default = classic_default;
|
|
13178
13178
|
|
|
13179
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
13179
|
+
// ../rivetkit/dist/tsup/chunk-YH2CAWLD.js
|
|
13180
13180
|
var import_invariant = __toESM(require_invariant(), 1);
|
|
13181
13181
|
import * as cbor from "cbor-x";
|
|
13182
13182
|
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
@@ -13347,7 +13347,7 @@ function noopNext() {
|
|
|
13347
13347
|
}
|
|
13348
13348
|
var package_default = {
|
|
13349
13349
|
name: "rivetkit",
|
|
13350
|
-
version: "2.3.24
|
|
13350
|
+
version: "2.3.24",
|
|
13351
13351
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13352
13352
|
license: "Apache-2.0",
|
|
13353
13353
|
keywords: [
|
|
@@ -14654,7 +14654,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
|
|
|
14654
14654
|
};
|
|
14655
14655
|
}
|
|
14656
14656
|
|
|
14657
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14657
|
+
// ../rivetkit/dist/tsup/chunk-QMR2J7PT.js
|
|
14658
14658
|
var config2 = /* @__PURE__ */ Config({});
|
|
14659
14659
|
function readWorkflowCbor(bc) {
|
|
14660
14660
|
return readData(bc);
|
|
@@ -14952,7 +14952,7 @@ function decodeWorkflowHistoryTransport(data) {
|
|
|
14952
14952
|
return decodeWorkflowHistory(toUint8Array(data));
|
|
14953
14953
|
}
|
|
14954
14954
|
|
|
14955
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14955
|
+
// ../rivetkit/dist/tsup/chunk-CSOHAAZK.js
|
|
14956
14956
|
function flattenActionHandlers(actions) {
|
|
14957
14957
|
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14958
14958
|
for (const { name, handler } of collectActionEntries(actions)) {
|
|
@@ -15564,6 +15564,44 @@ function removePrefixFromKey(prefixedKey) {
|
|
|
15564
15564
|
return prefixedKey.slice(KEYS.KV.length);
|
|
15565
15565
|
}
|
|
15566
15566
|
|
|
15567
|
+
// ../rivetkit/dist/tsup/chunk-NSNBWLCG.js
|
|
15568
|
+
function logger() {
|
|
15569
|
+
return getLogger("actor-client");
|
|
15570
|
+
}
|
|
15571
|
+
var webSocketPromise = null;
|
|
15572
|
+
async function importWebSocket() {
|
|
15573
|
+
if (webSocketPromise !== null) {
|
|
15574
|
+
return webSocketPromise;
|
|
15575
|
+
}
|
|
15576
|
+
webSocketPromise = (async () => {
|
|
15577
|
+
let _WebSocket;
|
|
15578
|
+
if (typeof WebSocket !== "undefined") {
|
|
15579
|
+
_WebSocket = WebSocket;
|
|
15580
|
+
} else {
|
|
15581
|
+
try {
|
|
15582
|
+
const moduleName = "ws";
|
|
15583
|
+
const ws = await import(
|
|
15584
|
+
/* webpackIgnore: true */
|
|
15585
|
+
moduleName
|
|
15586
|
+
);
|
|
15587
|
+
_WebSocket = ws.default;
|
|
15588
|
+
logger().debug("using websocket from npm");
|
|
15589
|
+
} catch {
|
|
15590
|
+
_WebSocket = class MockWebSocket {
|
|
15591
|
+
constructor() {
|
|
15592
|
+
throw new Error(
|
|
15593
|
+
'WebSocket support requires installing the "ws" peer dependency.'
|
|
15594
|
+
);
|
|
15595
|
+
}
|
|
15596
|
+
};
|
|
15597
|
+
logger().debug("using mock websocket");
|
|
15598
|
+
}
|
|
15599
|
+
}
|
|
15600
|
+
return _WebSocket;
|
|
15601
|
+
})();
|
|
15602
|
+
return webSocketPromise;
|
|
15603
|
+
}
|
|
15604
|
+
|
|
15567
15605
|
// ../rivetkit/dist/tsup/chunk-JTHHCZCZ.js
|
|
15568
15606
|
var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
|
|
15569
15607
|
function isManualTransactionControl(query) {
|
|
@@ -15647,45 +15685,7 @@ var AsyncMutex = class {
|
|
|
15647
15685
|
}
|
|
15648
15686
|
};
|
|
15649
15687
|
|
|
15650
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15651
|
-
function logger() {
|
|
15652
|
-
return getLogger("actor-client");
|
|
15653
|
-
}
|
|
15654
|
-
var webSocketPromise = null;
|
|
15655
|
-
async function importWebSocket() {
|
|
15656
|
-
if (webSocketPromise !== null) {
|
|
15657
|
-
return webSocketPromise;
|
|
15658
|
-
}
|
|
15659
|
-
webSocketPromise = (async () => {
|
|
15660
|
-
let _WebSocket;
|
|
15661
|
-
if (typeof WebSocket !== "undefined") {
|
|
15662
|
-
_WebSocket = WebSocket;
|
|
15663
|
-
} else {
|
|
15664
|
-
try {
|
|
15665
|
-
const moduleName = "ws";
|
|
15666
|
-
const ws = await import(
|
|
15667
|
-
/* webpackIgnore: true */
|
|
15668
|
-
moduleName
|
|
15669
|
-
);
|
|
15670
|
-
_WebSocket = ws.default;
|
|
15671
|
-
logger().debug("using websocket from npm");
|
|
15672
|
-
} catch {
|
|
15673
|
-
_WebSocket = class MockWebSocket {
|
|
15674
|
-
constructor() {
|
|
15675
|
-
throw new Error(
|
|
15676
|
-
'WebSocket support requires installing the "ws" peer dependency.'
|
|
15677
|
-
);
|
|
15678
|
-
}
|
|
15679
|
-
};
|
|
15680
|
-
logger().debug("using mock websocket");
|
|
15681
|
-
}
|
|
15682
|
-
}
|
|
15683
|
-
return _WebSocket;
|
|
15684
|
-
})();
|
|
15685
|
-
return webSocketPromise;
|
|
15686
|
-
}
|
|
15687
|
-
|
|
15688
|
-
// ../rivetkit/dist/tsup/chunk-B6WTPGOR.js
|
|
15688
|
+
// ../rivetkit/dist/tsup/chunk-SW22GCYF.js
|
|
15689
15689
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15690
15690
|
|
|
15691
15691
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -16900,7 +16900,7 @@ var TraceAPI = (
|
|
|
16900
16900
|
// ../../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace-api.js
|
|
16901
16901
|
var trace = TraceAPI.getInstance();
|
|
16902
16902
|
|
|
16903
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
16903
|
+
// ../rivetkit/dist/tsup/chunk-SW22GCYF.js
|
|
16904
16904
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
16905
16905
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
16906
16906
|
var PATH_CONNECT = "/connect";
|
|
@@ -18983,6 +18983,14 @@ function isResponseLike(value) {
|
|
|
18983
18983
|
function isHeadersLike(value) {
|
|
18984
18984
|
return typeof value === "object" && value !== null && typeof value.entries === "function";
|
|
18985
18985
|
}
|
|
18986
|
+
function readRequestBody(request) {
|
|
18987
|
+
if (!request.body) return request.arrayBuffer();
|
|
18988
|
+
return new Response(
|
|
18989
|
+
request.body.pipeThrough(new TransformStream(), {
|
|
18990
|
+
signal: request.signal
|
|
18991
|
+
})
|
|
18992
|
+
).arrayBuffer();
|
|
18993
|
+
}
|
|
18986
18994
|
function* walkErrorChain(error46, maxDepth = 8) {
|
|
18987
18995
|
let current = error46;
|
|
18988
18996
|
let depth = 0;
|
|
@@ -19511,9 +19519,10 @@ async function rawHttpFetch(driver, target, params, input, init, options = {}, t
|
|
|
19511
19519
|
initHeaders.forEach((value, key) => {
|
|
19512
19520
|
mergedHeaders.set(key, value);
|
|
19513
19521
|
});
|
|
19522
|
+
const readsInputBody = (init == null ? void 0 : init.body) === void 0 && input.method !== "GET" && input.method !== "HEAD";
|
|
19514
19523
|
mergedInit = {
|
|
19515
19524
|
method: input.method,
|
|
19516
|
-
body: input
|
|
19525
|
+
body: readsInputBody ? await readRequestBody(input) : void 0,
|
|
19517
19526
|
mode: input.mode,
|
|
19518
19527
|
credentials: input.credentials,
|
|
19519
19528
|
redirect: input.redirect,
|
|
@@ -21932,6 +21941,8 @@ var ClientConfigSchemaBase = v4_default.object({
|
|
|
21932
21941
|
// This is required in the client config in order to support
|
|
21933
21942
|
// `proxyWebSocket`
|
|
21934
21943
|
getUpgradeWebSocket: v4_default.custom().optional(),
|
|
21944
|
+
/** Replaces global fetch for actor HTTP gateway requests. */
|
|
21945
|
+
fetch: v4_default.custom().optional(),
|
|
21935
21946
|
/** Whether to automatically perform health checks when the client is created. */
|
|
21936
21947
|
disableMetadataLookup: v4_default.boolean().optional().default(false),
|
|
21937
21948
|
/**
|
|
@@ -21993,18 +22004,26 @@ async function sendHttpRequestToGateway(runConfig, gatewayUrl, actorRequest, opt
|
|
|
21993
22004
|
if (actorRequest.bodyUsed) {
|
|
21994
22005
|
throw new Error("Request body has already been consumed");
|
|
21995
22006
|
}
|
|
21996
|
-
|
|
21997
|
-
|
|
22007
|
+
const bytes = await readRequestBody(actorRequest);
|
|
22008
|
+
if (bytes.byteLength > 0) {
|
|
22009
|
+
bodyToSend = bytes;
|
|
21998
22010
|
guardHeaders.delete("transfer-encoding");
|
|
21999
22011
|
guardHeaders.delete("content-length");
|
|
22000
22012
|
}
|
|
22001
22013
|
}
|
|
22002
|
-
|
|
22014
|
+
const fetchImpl = runConfig.fetch ?? fetch;
|
|
22015
|
+
return fetchImpl(gatewayUrl, {
|
|
22003
22016
|
method: actorRequest.method,
|
|
22004
22017
|
headers: guardHeaders,
|
|
22005
22018
|
body: bodyToSend,
|
|
22006
22019
|
signal: actorRequest.signal,
|
|
22007
|
-
|
|
22020
|
+
mode: actorRequest.mode,
|
|
22021
|
+
credentials: actorRequest.credentials,
|
|
22022
|
+
redirect: actorRequest.redirect,
|
|
22023
|
+
referrer: actorRequest.referrer,
|
|
22024
|
+
referrerPolicy: actorRequest.referrerPolicy,
|
|
22025
|
+
integrity: actorRequest.integrity,
|
|
22026
|
+
keepalive: actorRequest.keepalive
|
|
22008
22027
|
});
|
|
22009
22028
|
}
|
|
22010
22029
|
function buildGuardHeaders(runConfig, actorRequest, options) {
|
|
@@ -23077,7 +23096,7 @@ function apiActorToOutput(actor2) {
|
|
|
23077
23096
|
};
|
|
23078
23097
|
}
|
|
23079
23098
|
|
|
23080
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
23099
|
+
// ../rivetkit/dist/tsup/chunk-QZQE75U2.js
|
|
23081
23100
|
var nativeStateTransactionOpeners = /* @__PURE__ */ new WeakMap();
|
|
23082
23101
|
var nativeStateTransactionClientBinders = /* @__PURE__ */ new WeakMap();
|
|
23083
23102
|
function registerNativeStateTransactionOpener(provider, opener) {
|
|
@@ -26136,12 +26155,6 @@ var NapiCoreRuntime = class {
|
|
|
26136
26155
|
actorId(ctx) {
|
|
26137
26156
|
return asNativeActorContext(ctx).actorId();
|
|
26138
26157
|
}
|
|
26139
|
-
actorGeneration(ctx) {
|
|
26140
|
-
return asNativeActorContext(ctx).generation() ?? void 0;
|
|
26141
|
-
}
|
|
26142
|
-
actorIsLost(ctx) {
|
|
26143
|
-
return asNativeActorContext(ctx).isLost();
|
|
26144
|
-
}
|
|
26145
26158
|
runWithActorInvocationContext(ctx, run) {
|
|
26146
26159
|
return this.#runAs(asNativeActorContext(ctx), run);
|
|
26147
26160
|
}
|
|
@@ -26755,27 +26768,6 @@ function notifyStateChanged(state) {
|
|
|
26755
26768
|
waiter();
|
|
26756
26769
|
}
|
|
26757
26770
|
}
|
|
26758
|
-
function createRunState(actorGeneration) {
|
|
26759
|
-
return {
|
|
26760
|
-
actorGeneration,
|
|
26761
|
-
active: false,
|
|
26762
|
-
closed: false,
|
|
26763
|
-
exclusive: false,
|
|
26764
|
-
exclusiveGeneration: 0,
|
|
26765
|
-
inspectorInitialized: false,
|
|
26766
|
-
queued: 0,
|
|
26767
|
-
waiters: /* @__PURE__ */ new Set()
|
|
26768
|
-
};
|
|
26769
|
-
}
|
|
26770
|
-
function closeRunState(state, disposeInspector = true) {
|
|
26771
|
-
var _a2, _b;
|
|
26772
|
-
state.closed = true;
|
|
26773
|
-
if (disposeInspector) {
|
|
26774
|
-
(_b = (_a2 = state.inspector) == null ? void 0 : _a2.dispose) == null ? void 0 : _b.call(_a2);
|
|
26775
|
-
}
|
|
26776
|
-
state.inspector = void 0;
|
|
26777
|
-
notifyStateChanged(state);
|
|
26778
|
-
}
|
|
26779
26771
|
function waitForStateChange(state) {
|
|
26780
26772
|
return new Promise((resolve) => {
|
|
26781
26773
|
state.waiters.add(resolve);
|
|
@@ -26790,11 +26782,8 @@ var RunHandlerCoordinator = class {
|
|
|
26790
26782
|
get inspectorKind() {
|
|
26791
26783
|
return getRunInspectorKind(this.#run);
|
|
26792
26784
|
}
|
|
26793
|
-
async run(actorId, restart, callback
|
|
26794
|
-
const state = this.#getOrCreate(actorId
|
|
26795
|
-
if (state.closed) {
|
|
26796
|
-
return "closed";
|
|
26797
|
-
}
|
|
26785
|
+
async run(actorId, restart, callback) {
|
|
26786
|
+
const state = this.#getOrCreate(actorId);
|
|
26798
26787
|
state.restart = restart;
|
|
26799
26788
|
this.#initializeInspector(actorId, state);
|
|
26800
26789
|
state.queued += 1;
|
|
@@ -26821,27 +26810,21 @@ var RunHandlerCoordinator = class {
|
|
|
26821
26810
|
notifyStateChanged(state);
|
|
26822
26811
|
}
|
|
26823
26812
|
}
|
|
26824
|
-
getInspector(actorId, restart
|
|
26813
|
+
getInspector(actorId, restart) {
|
|
26825
26814
|
var _a2;
|
|
26826
|
-
const state = this.#getOrCreate(actorId
|
|
26827
|
-
if (state.closed) {
|
|
26828
|
-
return void 0;
|
|
26829
|
-
}
|
|
26815
|
+
const state = this.#getOrCreate(actorId);
|
|
26830
26816
|
state.restart = restart;
|
|
26831
26817
|
this.#initializeInspector(actorId, state);
|
|
26832
26818
|
return (_a2 = state.inspector) == null ? void 0 : _a2.inspector;
|
|
26833
26819
|
}
|
|
26834
|
-
|
|
26835
|
-
|
|
26836
|
-
* generation is closed, so an older generation's late cleanup cannot close a newer one.
|
|
26837
|
-
*/
|
|
26838
|
-
destroy(actorId, actorGeneration, options = {}) {
|
|
26820
|
+
destroy(actorId) {
|
|
26821
|
+
var _a2, _b;
|
|
26839
26822
|
const state = this.#states.get(actorId);
|
|
26840
26823
|
if (!state) return;
|
|
26841
|
-
|
|
26842
|
-
|
|
26843
|
-
|
|
26844
|
-
|
|
26824
|
+
state.closed = true;
|
|
26825
|
+
(_b = (_a2 = state.inspector) == null ? void 0 : _a2.dispose) == null ? void 0 : _b.call(_a2);
|
|
26826
|
+
state.inspector = void 0;
|
|
26827
|
+
notifyStateChanged(state);
|
|
26845
26828
|
this.#states.delete(actorId);
|
|
26846
26829
|
}
|
|
26847
26830
|
#control(actorId, state) {
|
|
@@ -26887,20 +26870,18 @@ var RunHandlerCoordinator = class {
|
|
|
26887
26870
|
}
|
|
26888
26871
|
};
|
|
26889
26872
|
}
|
|
26890
|
-
#getOrCreate(actorId
|
|
26873
|
+
#getOrCreate(actorId) {
|
|
26891
26874
|
let state = this.#states.get(actorId);
|
|
26892
|
-
if (state && actorGeneration !== void 0 && state.actorGeneration !== void 0 && state.actorGeneration !== actorGeneration) {
|
|
26893
|
-
if (actorGeneration < state.actorGeneration) {
|
|
26894
|
-
const detached = createRunState(actorGeneration);
|
|
26895
|
-
detached.closed = true;
|
|
26896
|
-
return detached;
|
|
26897
|
-
}
|
|
26898
|
-
closeRunState(state, false);
|
|
26899
|
-
this.#states.delete(actorId);
|
|
26900
|
-
state = void 0;
|
|
26901
|
-
}
|
|
26902
26875
|
if (!state) {
|
|
26903
|
-
state =
|
|
26876
|
+
state = {
|
|
26877
|
+
active: false,
|
|
26878
|
+
closed: false,
|
|
26879
|
+
exclusive: false,
|
|
26880
|
+
exclusiveGeneration: 0,
|
|
26881
|
+
inspectorInitialized: false,
|
|
26882
|
+
queued: 0,
|
|
26883
|
+
waiters: /* @__PURE__ */ new Set()
|
|
26884
|
+
};
|
|
26904
26885
|
this.#states.set(actorId, state);
|
|
26905
26886
|
}
|
|
26906
26887
|
return state;
|
|
@@ -26909,7 +26890,6 @@ var RunHandlerCoordinator = class {
|
|
|
26909
26890
|
if (state.inspectorInitialized) return;
|
|
26910
26891
|
const inspector = createRunInspector(this.#run, {
|
|
26911
26892
|
actorId,
|
|
26912
|
-
actorGeneration: state.actorGeneration,
|
|
26913
26893
|
control: this.#control(actorId, state)
|
|
26914
26894
|
});
|
|
26915
26895
|
if (this.inspectorKind === "workflow") {
|
|
@@ -27235,12 +27215,6 @@ var WasmCoreRuntime = class {
|
|
|
27235
27215
|
actorId(ctx) {
|
|
27236
27216
|
return callHandle(asWasmActorContext(ctx), "actorId");
|
|
27237
27217
|
}
|
|
27238
|
-
actorGeneration(ctx) {
|
|
27239
|
-
return callHandle(asWasmActorContext(ctx), "generation") ?? void 0;
|
|
27240
|
-
}
|
|
27241
|
-
actorIsLost(ctx) {
|
|
27242
|
-
return callHandle(asWasmActorContext(ctx), "isLost");
|
|
27243
|
-
}
|
|
27244
27218
|
runWithActorInvocationContext(_ctx, run) {
|
|
27245
27219
|
return run();
|
|
27246
27220
|
}
|
|
@@ -28067,11 +28041,8 @@ async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrai
|
|
|
28067
28041
|
await closeNativeDatabaseClient(runtime, ctx);
|
|
28068
28042
|
await closeNativeSqlDatabase(runtime, ctx);
|
|
28069
28043
|
void runtime.actorWaitForTrackedShutdownWorkUnbounded(ctx).then(async () => {
|
|
28070
|
-
|
|
28071
|
-
|
|
28072
|
-
} finally {
|
|
28073
|
-
clearNativeRuntimeState(runtime, ctx);
|
|
28074
|
-
}
|
|
28044
|
+
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
28045
|
+
clearNativeRuntimeState(runtime, ctx);
|
|
28075
28046
|
}).catch((error46) => {
|
|
28076
28047
|
logger22().warn({
|
|
28077
28048
|
msg: "deferred native sleep cleanup failed",
|
|
@@ -28080,24 +28051,10 @@ async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrai
|
|
|
28080
28051
|
});
|
|
28081
28052
|
return;
|
|
28082
28053
|
}
|
|
28083
|
-
|
|
28084
|
-
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
28085
|
-
} finally {
|
|
28086
|
-
try {
|
|
28087
|
-
await closeNativeDatabaseClient(runtime, ctx);
|
|
28088
|
-
await closeNativeSqlDatabase(runtime, ctx);
|
|
28089
|
-
} finally {
|
|
28090
|
-
clearNativeRuntimeState(runtime, ctx);
|
|
28091
|
-
}
|
|
28092
|
-
}
|
|
28093
|
-
}
|
|
28094
|
-
async function cleanupNativeLostRuntimeState(runtime, ctx) {
|
|
28054
|
+
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
28095
28055
|
await closeNativeDatabaseClient(runtime, ctx);
|
|
28096
|
-
|
|
28097
|
-
|
|
28098
|
-
} finally {
|
|
28099
|
-
clearNativeRuntimeState(runtime, ctx);
|
|
28100
|
-
}
|
|
28056
|
+
await closeNativeSqlDatabase(runtime, ctx);
|
|
28057
|
+
clearNativeRuntimeState(runtime, ctx);
|
|
28101
28058
|
}
|
|
28102
28059
|
function closeNativeSqlDatabase(runtime, ctx) {
|
|
28103
28060
|
const runtimeState = getNativeRuntimeState(runtime, ctx);
|
|
@@ -28115,9 +28072,6 @@ async function closeNativeDatabaseClient(runtime, ctx) {
|
|
|
28115
28072
|
return;
|
|
28116
28073
|
}
|
|
28117
28074
|
runtimeState.databaseClient = void 0;
|
|
28118
|
-
if (callNativeSync(() => runtime.actorIsLost(ctx))) {
|
|
28119
|
-
return;
|
|
28120
|
-
}
|
|
28121
28075
|
if (entry.client && typeof entry.client === "object" && "close" in entry.client && typeof entry.client.close === "function") {
|
|
28122
28076
|
await entry.client.close();
|
|
28123
28077
|
}
|
|
@@ -28543,49 +28497,6 @@ function wrapNativeCallback(callback) {
|
|
|
28543
28497
|
}
|
|
28544
28498
|
};
|
|
28545
28499
|
}
|
|
28546
|
-
var LOST_GENERATION_CLEANUP_CALLBACKS = /* @__PURE__ */ new Set(["onSleep", "onDestroy"]);
|
|
28547
|
-
function throwIfActorLost(runtime, ctx) {
|
|
28548
|
-
if (callNativeSync(() => runtime.actorIsLost(ctx))) {
|
|
28549
|
-
throw actorGenerationLostError();
|
|
28550
|
-
}
|
|
28551
|
-
}
|
|
28552
|
-
function actorGenerationLostError() {
|
|
28553
|
-
return new RivetError(
|
|
28554
|
-
"actor",
|
|
28555
|
-
"stopping",
|
|
28556
|
-
"Actor generation was declared lost; it starts no new user callbacks."
|
|
28557
|
-
);
|
|
28558
|
-
}
|
|
28559
|
-
function refuseCallbacksAfterLost(runtime, callbacks) {
|
|
28560
|
-
const guard = (callback) => {
|
|
28561
|
-
return async (...args) => {
|
|
28562
|
-
var _a2;
|
|
28563
|
-
const ctx = (_a2 = args[1]) == null ? void 0 : _a2.ctx;
|
|
28564
|
-
if (ctx !== void 0 && callNativeSync(() => runtime.actorIsLost(ctx))) {
|
|
28565
|
-
throw encodeNativeCallbackError(actorGenerationLostError());
|
|
28566
|
-
}
|
|
28567
|
-
return await callback(...args);
|
|
28568
|
-
};
|
|
28569
|
-
};
|
|
28570
|
-
const guarded = {};
|
|
28571
|
-
for (const [name, value] of Object.entries(callbacks)) {
|
|
28572
|
-
if (LOST_GENERATION_CLEANUP_CALLBACKS.has(name)) {
|
|
28573
|
-
guarded[name] = value;
|
|
28574
|
-
} else if (typeof value === "function") {
|
|
28575
|
-
guarded[name] = guard(value);
|
|
28576
|
-
} else if (name === "actions" && value !== null && typeof value === "object") {
|
|
28577
|
-
guarded[name] = Object.fromEntries(
|
|
28578
|
-
Object.entries(value).map(([actionName, handler]) => [
|
|
28579
|
-
actionName,
|
|
28580
|
-
guard(handler)
|
|
28581
|
-
])
|
|
28582
|
-
);
|
|
28583
|
-
} else {
|
|
28584
|
-
guarded[name] = value;
|
|
28585
|
-
}
|
|
28586
|
-
}
|
|
28587
|
-
return guarded;
|
|
28588
|
-
}
|
|
28589
28500
|
function decodeArgs(value) {
|
|
28590
28501
|
const decoded = decodeValue(value);
|
|
28591
28502
|
return normalizeArgs(decoded);
|
|
@@ -29023,30 +28934,17 @@ var NativeQueueAdapter = class {
|
|
|
29023
28934
|
this.#ctx = ctx;
|
|
29024
28935
|
this.#schemas = schemas;
|
|
29025
28936
|
}
|
|
29026
|
-
// Queue results arrive after awaits, and their schema validation is user code, so each
|
|
29027
|
-
// validation checks that the generation was not lost first.
|
|
29028
|
-
#validateBody(name, body) {
|
|
29029
|
-
throwIfActorLost(this.#runtime, this.#ctx);
|
|
29030
|
-
return validateQueueBody(this.#schemas, name, body);
|
|
29031
|
-
}
|
|
29032
|
-
#validateComplete(name, response) {
|
|
29033
|
-
throwIfActorLost(this.#runtime, this.#ctx);
|
|
29034
|
-
return validateQueueComplete(this.#schemas, name, response);
|
|
29035
|
-
}
|
|
29036
|
-
#wrap(message) {
|
|
29037
|
-
throwIfActorLost(this.#runtime, this.#ctx);
|
|
29038
|
-
return wrapQueueMessage(message, this.#schemas);
|
|
29039
|
-
}
|
|
29040
28937
|
async send(name, body) {
|
|
29041
|
-
const validatedBody = this.#
|
|
29042
|
-
return
|
|
28938
|
+
const validatedBody = validateQueueBody(this.#schemas, name, body);
|
|
28939
|
+
return wrapQueueMessage(
|
|
29043
28940
|
await callNative(
|
|
29044
28941
|
() => this.#runtime.actorQueueSend(
|
|
29045
28942
|
this.#ctx,
|
|
29046
28943
|
name,
|
|
29047
28944
|
encodeValue(validatedBody)
|
|
29048
28945
|
)
|
|
29049
|
-
)
|
|
28946
|
+
),
|
|
28947
|
+
this.#schemas
|
|
29050
28948
|
);
|
|
29051
28949
|
}
|
|
29052
28950
|
async next(options) {
|
|
@@ -29089,7 +28987,9 @@ var NativeQueueAdapter = class {
|
|
|
29089
28987
|
token
|
|
29090
28988
|
)
|
|
29091
28989
|
);
|
|
29092
|
-
const wrapped = messages.map(
|
|
28990
|
+
const wrapped = messages.map(
|
|
28991
|
+
(message) => wrapQueueMessage(message, this.#schemas)
|
|
28992
|
+
);
|
|
29093
28993
|
return completable ? wrapped.map(
|
|
29094
28994
|
(message) => this.#makeCompletableMessage(message)
|
|
29095
28995
|
) : wrapped;
|
|
@@ -29103,7 +29003,7 @@ var NativeQueueAdapter = class {
|
|
|
29103
29003
|
options == null ? void 0 : options.signal
|
|
29104
29004
|
);
|
|
29105
29005
|
try {
|
|
29106
|
-
return
|
|
29006
|
+
return wrapQueueMessage(
|
|
29107
29007
|
await callNative(
|
|
29108
29008
|
() => this.#runtime.actorQueueWaitForNames(
|
|
29109
29009
|
this.#ctx,
|
|
@@ -29114,7 +29014,8 @@ var NativeQueueAdapter = class {
|
|
|
29114
29014
|
},
|
|
29115
29015
|
token
|
|
29116
29016
|
)
|
|
29117
|
-
)
|
|
29017
|
+
),
|
|
29018
|
+
this.#schemas
|
|
29118
29019
|
);
|
|
29119
29020
|
} finally {
|
|
29120
29021
|
cleanup == null ? void 0 : cleanup();
|
|
@@ -29144,7 +29045,8 @@ var NativeQueueAdapter = class {
|
|
|
29144
29045
|
await this.waitForNamesAvailable(names ?? [], options);
|
|
29145
29046
|
}
|
|
29146
29047
|
async complete(message, response) {
|
|
29147
|
-
const validatedResponse =
|
|
29048
|
+
const validatedResponse = validateQueueComplete(
|
|
29049
|
+
this.#schemas,
|
|
29148
29050
|
message.name,
|
|
29149
29051
|
response
|
|
29150
29052
|
);
|
|
@@ -29159,7 +29061,7 @@ var NativeQueueAdapter = class {
|
|
|
29159
29061
|
this.#pendingCompletableMessageIds.delete(message.id.toString());
|
|
29160
29062
|
}
|
|
29161
29063
|
async enqueueAndWait(name, body, options) {
|
|
29162
|
-
const validatedBody = this.#
|
|
29064
|
+
const validatedBody = validateQueueBody(this.#schemas, name, body);
|
|
29163
29065
|
const { token, cleanup } = await createCancellationTokenHandle(
|
|
29164
29066
|
this.#runtime,
|
|
29165
29067
|
options == null ? void 0 : options.signal
|
|
@@ -29176,7 +29078,11 @@ var NativeQueueAdapter = class {
|
|
|
29176
29078
|
token
|
|
29177
29079
|
)
|
|
29178
29080
|
);
|
|
29179
|
-
return response === void 0 || response === null ? void 0 :
|
|
29081
|
+
return response === void 0 || response === null ? void 0 : validateQueueComplete(
|
|
29082
|
+
this.#schemas,
|
|
29083
|
+
name,
|
|
29084
|
+
decodeValue(response)
|
|
29085
|
+
);
|
|
29180
29086
|
} finally {
|
|
29181
29087
|
cleanup == null ? void 0 : cleanup();
|
|
29182
29088
|
}
|
|
@@ -29557,9 +29463,6 @@ var TrackedWebSocketHandleAdapter = class {
|
|
|
29557
29463
|
}
|
|
29558
29464
|
}
|
|
29559
29465
|
#callHandler(type, handler, event2) {
|
|
29560
|
-
if ((type === "message" || type === "open") && this.#ctx.isLost) {
|
|
29561
|
-
return;
|
|
29562
|
-
}
|
|
29563
29466
|
try {
|
|
29564
29467
|
const result = handler(event2);
|
|
29565
29468
|
if (!this.#isPromiseLike(result)) {
|
|
@@ -29842,13 +29745,6 @@ var ActorContextHandleAdapter = class {
|
|
|
29842
29745
|
get actorId() {
|
|
29843
29746
|
return callNativeSync(() => this.#runtime.actorId(this.#ctx));
|
|
29844
29747
|
}
|
|
29845
|
-
get actorGeneration() {
|
|
29846
|
-
return callNativeSync(() => this.#runtime.actorGeneration(this.#ctx));
|
|
29847
|
-
}
|
|
29848
|
-
/** Whether this generation was declared lost. A lost generation starts no new user code. */
|
|
29849
|
-
get isLost() {
|
|
29850
|
-
return callNativeSync(() => this.#runtime.actorIsLost(this.#ctx));
|
|
29851
|
-
}
|
|
29852
29748
|
get name() {
|
|
29853
29749
|
return callNativeSync(() => this.#runtime.actorName(this.#ctx));
|
|
29854
29750
|
}
|
|
@@ -29963,9 +29859,6 @@ var ActorContextHandleAdapter = class {
|
|
|
29963
29859
|
return this.#db;
|
|
29964
29860
|
}
|
|
29965
29861
|
const actorId = this.actorId;
|
|
29966
|
-
if (this.isLost) {
|
|
29967
|
-
throw actorGenerationLostError();
|
|
29968
|
-
}
|
|
29969
29862
|
const createdClient = await this.#databaseProvider.createClient({
|
|
29970
29863
|
actorId,
|
|
29971
29864
|
kv: {
|
|
@@ -30118,11 +30011,9 @@ var ActorContextHandleAdapter = class {
|
|
|
30118
30011
|
if (!this.#databaseProvider) {
|
|
30119
30012
|
return;
|
|
30120
30013
|
}
|
|
30121
|
-
|
|
30122
|
-
|
|
30123
|
-
|
|
30124
|
-
}
|
|
30125
|
-
await this.#databaseProvider.onMigrate(client);
|
|
30014
|
+
await this.#databaseProvider.onMigrate(
|
|
30015
|
+
await this.ensureDatabaseClient()
|
|
30016
|
+
);
|
|
30126
30017
|
}
|
|
30127
30018
|
async closeDatabase() {
|
|
30128
30019
|
this.#db = void 0;
|
|
@@ -30394,7 +30285,7 @@ var ActorContextHandleAdapter = class {
|
|
|
30394
30285
|
callNativeSync(
|
|
30395
30286
|
() => this.#runtime.actorRequestSave(this.#ctx, { immediate: false })
|
|
30396
30287
|
);
|
|
30397
|
-
if (!this.#onStateChange
|
|
30288
|
+
if (!this.#onStateChange) {
|
|
30398
30289
|
return;
|
|
30399
30290
|
}
|
|
30400
30291
|
actorState.isInOnStateChange = true;
|
|
@@ -30434,12 +30325,6 @@ var NativeWorkflowRuntimeAdapter = class {
|
|
|
30434
30325
|
#onMessagesReceived;
|
|
30435
30326
|
#completions = /* @__PURE__ */ new Map();
|
|
30436
30327
|
id;
|
|
30437
|
-
/** Actor generation, used to keep workflow registrations of different generations apart. */
|
|
30438
|
-
generation;
|
|
30439
|
-
/** Whether this generation was declared lost. Workflow code checks it before each user callback. */
|
|
30440
|
-
get isLost() {
|
|
30441
|
-
return this.#ctx.isLost;
|
|
30442
|
-
}
|
|
30443
30328
|
driver;
|
|
30444
30329
|
queueManager;
|
|
30445
30330
|
stateManager;
|
|
@@ -30447,7 +30332,6 @@ var NativeWorkflowRuntimeAdapter = class {
|
|
|
30447
30332
|
this.#ctx = ctx;
|
|
30448
30333
|
this.#onMessagesReceived = onMessagesReceived;
|
|
30449
30334
|
this.id = ctx.actorId;
|
|
30450
|
-
this.generation = ctx.actorGeneration;
|
|
30451
30335
|
this.driver = {
|
|
30452
30336
|
kvBatchGet: async (actorId, keys) => {
|
|
30453
30337
|
this.#assertActorId(actorId);
|
|
@@ -30730,23 +30614,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
30730
30614
|
const runHandlerCoordinator = getRunInspectorKind(config3.run) === "workflow" ? new RunHandlerCoordinator(config3.run) : void 0;
|
|
30731
30615
|
const getNativeWorkflowInspector = (ctx) => {
|
|
30732
30616
|
var _a22, _b;
|
|
30733
|
-
if (callNativeSync(() => runtime.actorIsLost(ctx))) {
|
|
30734
|
-
return void 0;
|
|
30735
|
-
}
|
|
30736
30617
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
30737
30618
|
const restart = () => callNativeSync(() => runtime.actorRestartRunHandler(ctx));
|
|
30738
|
-
|
|
30739
|
-
() => runtime.actorGeneration(ctx)
|
|
30740
|
-
);
|
|
30741
|
-
const inspector = ((_a22 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(
|
|
30742
|
-
actorId,
|
|
30743
|
-
restart,
|
|
30744
|
-
actorGeneration
|
|
30745
|
-
)) == null ? void 0 : _a22.workflow) ?? ((_b = getRunInspectorConfig(config3.run, actorId)) == null ? void 0 : _b.workflow);
|
|
30746
|
-
if (callNativeSync(() => runtime.actorIsLost(ctx))) {
|
|
30747
|
-
return void 0;
|
|
30748
|
-
}
|
|
30749
|
-
return inspector;
|
|
30619
|
+
return ((_a22 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(actorId, restart)) == null ? void 0 : _a22.workflow) ?? ((_b = getRunInspectorConfig(config3.run, actorId)) == null ? void 0 : _b.workflow);
|
|
30750
30620
|
};
|
|
30751
30621
|
const onStateChange = typeof config3.onStateChange === "function" ? (actorCtx, nextState) => {
|
|
30752
30622
|
config3.onStateChange(actorCtx, nextState);
|
|
@@ -30823,10 +30693,6 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
30823
30693
|
return errorResponse(error46, 401);
|
|
30824
30694
|
}
|
|
30825
30695
|
}
|
|
30826
|
-
const inspectorConnParams = (conn) => {
|
|
30827
|
-
throwIfActorLost(runtime, ctx);
|
|
30828
|
-
return conn.params;
|
|
30829
|
-
};
|
|
30830
30696
|
const workflowHistory = () => {
|
|
30831
30697
|
var _a3;
|
|
30832
30698
|
return serializeWorkflowHistoryForJson(
|
|
@@ -30860,7 +30726,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
30860
30726
|
id: conn.id,
|
|
30861
30727
|
details: {
|
|
30862
30728
|
type: null,
|
|
30863
|
-
params:
|
|
30729
|
+
params: conn.params,
|
|
30864
30730
|
stateEnabled: true,
|
|
30865
30731
|
state: conn.state,
|
|
30866
30732
|
subscriptions: 0,
|
|
@@ -31064,7 +30930,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31064
30930
|
id: conn.id,
|
|
31065
30931
|
details: {
|
|
31066
30932
|
type: null,
|
|
31067
|
-
params:
|
|
30933
|
+
params: conn.params,
|
|
31068
30934
|
stateEnabled: true,
|
|
31069
30935
|
state: conn.state,
|
|
31070
30936
|
subscriptions: 0,
|
|
@@ -31111,20 +30977,15 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31111
30977
|
);
|
|
31112
30978
|
}
|
|
31113
30979
|
const args = body.properties !== void 0 ? [body.properties] : normalizeArgs(body.args);
|
|
31114
|
-
if (callNativeSync(() => runtime.actorIsLost(ctx))) {
|
|
31115
|
-
return jsonResponse(
|
|
31116
|
-
{ error: "actor generation was declared lost" },
|
|
31117
|
-
{ status: 503 }
|
|
31118
|
-
);
|
|
31119
|
-
}
|
|
31120
30980
|
try {
|
|
31121
|
-
const
|
|
31122
|
-
|
|
31123
|
-
|
|
31124
|
-
|
|
30981
|
+
const output = await action(
|
|
30982
|
+
actorCtx,
|
|
30983
|
+
...validateActionArgs(
|
|
30984
|
+
schemaConfig.actionInputSchemas,
|
|
30985
|
+
actionName,
|
|
30986
|
+
args
|
|
30987
|
+
)
|
|
31125
30988
|
);
|
|
31126
|
-
throwIfActorLost(runtime, ctx);
|
|
31127
|
-
const output = await action(actorCtx, ...validatedArgs);
|
|
31128
30989
|
return jsonResponse({ output });
|
|
31129
30990
|
} catch (error46) {
|
|
31130
30991
|
logger22().error({
|
|
@@ -31228,9 +31089,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31228
31089
|
await actorCtx.closeDatabase();
|
|
31229
31090
|
}
|
|
31230
31091
|
await actorCtx.runDatabaseMigrations();
|
|
31231
|
-
if (typeof config3.onMigrate === "function"
|
|
31232
|
-
() => runtime.actorIsLost(ctx)
|
|
31233
|
-
)) {
|
|
31092
|
+
if (typeof config3.onMigrate === "function") {
|
|
31234
31093
|
await config3.onMigrate(actorCtx, isNew);
|
|
31235
31094
|
}
|
|
31236
31095
|
} catch (error210) {
|
|
@@ -31273,29 +31132,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31273
31132
|
const { ctx } = unwrapTsfnPayload(error46, payload);
|
|
31274
31133
|
const actorCtx = makeActorCtx(ctx);
|
|
31275
31134
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
31276
|
-
const actorGeneration = callNativeSync(
|
|
31277
|
-
() => runtime.actorGeneration(ctx)
|
|
31278
|
-
);
|
|
31279
|
-
const isLost = () => callNativeSync(() => runtime.actorIsLost(ctx));
|
|
31280
|
-
if (isLost()) {
|
|
31281
|
-
try {
|
|
31282
|
-
await cleanupNativeLostRuntimeState(runtime, ctx);
|
|
31283
|
-
} finally {
|
|
31284
|
-
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(
|
|
31285
|
-
actorId,
|
|
31286
|
-
actorGeneration,
|
|
31287
|
-
{
|
|
31288
|
-
disposeInspector: false
|
|
31289
|
-
}
|
|
31290
|
-
);
|
|
31291
|
-
await actorCtx.dispose();
|
|
31292
|
-
}
|
|
31293
|
-
return;
|
|
31294
|
-
}
|
|
31295
31135
|
const saveActorState = async () => {
|
|
31296
|
-
if (isLost()) {
|
|
31297
|
-
return;
|
|
31298
|
-
}
|
|
31299
31136
|
if (runtime.kind === "wasm") {
|
|
31300
31137
|
await runtime.actorSaveState(
|
|
31301
31138
|
ctx,
|
|
@@ -31314,26 +31151,14 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31314
31151
|
await saveActorState();
|
|
31315
31152
|
} finally {
|
|
31316
31153
|
try {
|
|
31317
|
-
|
|
31318
|
-
|
|
31319
|
-
|
|
31320
|
-
|
|
31321
|
-
runtime,
|
|
31322
|
-
ctx,
|
|
31323
|
-
saveActorState
|
|
31324
|
-
);
|
|
31325
|
-
}
|
|
31326
|
-
} finally {
|
|
31327
|
-
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(
|
|
31328
|
-
actorId,
|
|
31329
|
-
actorGeneration,
|
|
31330
|
-
{
|
|
31331
|
-
disposeInspector: !isLost()
|
|
31332
|
-
}
|
|
31154
|
+
await cleanupNativeSleepRuntimeState(
|
|
31155
|
+
runtime,
|
|
31156
|
+
ctx,
|
|
31157
|
+
saveActorState
|
|
31333
31158
|
);
|
|
31334
|
-
|
|
31335
|
-
|
|
31336
|
-
|
|
31159
|
+
} finally {
|
|
31160
|
+
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
|
|
31161
|
+
disposeRunInspector(config3.run, actorId);
|
|
31337
31162
|
await actorCtx.dispose();
|
|
31338
31163
|
}
|
|
31339
31164
|
}
|
|
@@ -31344,17 +31169,10 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31344
31169
|
const { ctx } = unwrapTsfnPayload(error46, payload);
|
|
31345
31170
|
const actorCtx = makeActorCtx(ctx);
|
|
31346
31171
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
31347
|
-
|
|
31348
|
-
|
|
31349
|
-
actorId,
|
|
31350
|
-
callNativeSync(() => runtime.actorGeneration(ctx)),
|
|
31351
|
-
{ disposeInspector: !isLost() }
|
|
31352
|
-
);
|
|
31353
|
-
if (!isLost()) {
|
|
31354
|
-
disposeRunInspector(config3.run, actorId);
|
|
31355
|
-
}
|
|
31172
|
+
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
|
|
31173
|
+
disposeRunInspector(config3.run, actorId);
|
|
31356
31174
|
try {
|
|
31357
|
-
if (typeof config3.onDestroy === "function"
|
|
31175
|
+
if (typeof config3.onDestroy === "function") {
|
|
31358
31176
|
await config3.onDestroy(actorCtx);
|
|
31359
31177
|
}
|
|
31360
31178
|
} finally {
|
|
@@ -31376,14 +31194,12 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31376
31194
|
request ? buildNativeHttpRequest(request) : void 0
|
|
31377
31195
|
);
|
|
31378
31196
|
try {
|
|
31379
|
-
const validatedParams = validateConnParams(
|
|
31380
|
-
schemaConfig.connParamsSchema,
|
|
31381
|
-
decodeValue(params)
|
|
31382
|
-
);
|
|
31383
|
-
throwIfActorLost(runtime, ctx);
|
|
31384
31197
|
await config3.onBeforeConnect(
|
|
31385
31198
|
actorCtx,
|
|
31386
|
-
|
|
31199
|
+
validateConnParams(
|
|
31200
|
+
schemaConfig.connParamsSchema,
|
|
31201
|
+
decodeValue(params)
|
|
31202
|
+
)
|
|
31387
31203
|
);
|
|
31388
31204
|
} finally {
|
|
31389
31205
|
await actorCtx.dispose();
|
|
@@ -31411,22 +31227,13 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31411
31227
|
() => actorCtx.assertCanMutateState()
|
|
31412
31228
|
);
|
|
31413
31229
|
try {
|
|
31414
|
-
|
|
31415
|
-
|
|
31416
|
-
|
|
31417
|
-
config3.connState
|
|
31418
|
-
);
|
|
31419
|
-
} else {
|
|
31420
|
-
const validatedParams = validateConnParams(
|
|
31230
|
+
const nextConnState = hasStaticConnState ? structuredClone(config3.connState) : await config3.createConnState(
|
|
31231
|
+
actorCtx,
|
|
31232
|
+
validateConnParams(
|
|
31421
31233
|
schemaConfig.connParamsSchema,
|
|
31422
31234
|
decodeValue(params)
|
|
31423
|
-
)
|
|
31424
|
-
|
|
31425
|
-
nextConnState = await config3.createConnState(
|
|
31426
|
-
actorCtx,
|
|
31427
|
-
validatedParams
|
|
31428
|
-
);
|
|
31429
|
-
}
|
|
31235
|
+
)
|
|
31236
|
+
);
|
|
31430
31237
|
connAdapter.initializeState(nextConnState);
|
|
31431
31238
|
return encodeValue(nextConnState);
|
|
31432
31239
|
} finally {
|
|
@@ -31531,9 +31338,6 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31531
31338
|
onBeforeActionResponse: typeof config3.onBeforeActionResponse === "function" ? wrapNativeCallback(
|
|
31532
31339
|
async (error46, payload) => {
|
|
31533
31340
|
const { ctx, name, args, output } = unwrapTsfnPayload(error46, payload);
|
|
31534
|
-
if (callNativeSync(() => runtime.actorIsLost(ctx))) {
|
|
31535
|
-
return output;
|
|
31536
|
-
}
|
|
31537
31341
|
const actorCtx = makeActorCtx(ctx);
|
|
31538
31342
|
try {
|
|
31539
31343
|
return encodeValue(
|
|
@@ -31602,7 +31406,6 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31602
31406
|
}
|
|
31603
31407
|
};
|
|
31604
31408
|
try {
|
|
31605
|
-
throwIfActorLost(runtime, ctx);
|
|
31606
31409
|
const connParams = validateConnParams(
|
|
31607
31410
|
schemaConfig.connParamsSchema,
|
|
31608
31411
|
rawConnParams ? JSON.parse(rawConnParams) : void 0
|
|
@@ -31637,11 +31440,6 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31637
31440
|
abortRequest
|
|
31638
31441
|
);
|
|
31639
31442
|
}
|
|
31640
|
-
if (callNativeSync(
|
|
31641
|
-
() => runtime.actorIsLost(ctx)
|
|
31642
|
-
)) {
|
|
31643
|
-
throw actorGenerationLostError();
|
|
31644
|
-
}
|
|
31645
31443
|
const response = await config3.onRequest(
|
|
31646
31444
|
requestCtx,
|
|
31647
31445
|
handlerRequest
|
|
@@ -31714,9 +31512,6 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31714
31512
|
const { ctx } = unwrapTsfnPayload(error46, payload);
|
|
31715
31513
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
31716
31514
|
const executeRun = async () => {
|
|
31717
|
-
if (callNativeSync(() => runtime.actorIsLost(ctx))) {
|
|
31718
|
-
return;
|
|
31719
|
-
}
|
|
31720
31515
|
const actorCtx = makeActorCtx(ctx);
|
|
31721
31516
|
try {
|
|
31722
31517
|
await run(actorCtx);
|
|
@@ -31730,8 +31525,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31730
31525
|
() => callNativeSync(
|
|
31731
31526
|
() => runtime.actorRestartRunHandler(ctx)
|
|
31732
31527
|
),
|
|
31733
|
-
executeRun
|
|
31734
|
-
callNativeSync(() => runtime.actorGeneration(ctx))
|
|
31528
|
+
executeRun
|
|
31735
31529
|
);
|
|
31736
31530
|
return outcome !== "suppressed";
|
|
31737
31531
|
}
|
|
@@ -31771,16 +31565,14 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31771
31565
|
const actorCtx = conn != null ? makeConnCtx(ctx, conn, void 0, cancelToken) : makeActorCtx(ctx, void 0, cancelToken);
|
|
31772
31566
|
const runAction = async () => {
|
|
31773
31567
|
try {
|
|
31774
|
-
const validatedArgs = validateActionArgs(
|
|
31775
|
-
schemaConfig.actionInputSchemas,
|
|
31776
|
-
name,
|
|
31777
|
-
decodeArgs(args)
|
|
31778
|
-
);
|
|
31779
|
-
throwIfActorLost(runtime, ctx);
|
|
31780
31568
|
return encodeValue(
|
|
31781
31569
|
await handler(
|
|
31782
31570
|
actorCtx,
|
|
31783
|
-
...
|
|
31571
|
+
...validateActionArgs(
|
|
31572
|
+
schemaConfig.actionInputSchemas,
|
|
31573
|
+
name,
|
|
31574
|
+
decodeArgs(args)
|
|
31575
|
+
),
|
|
31784
31576
|
...scheduledFire ? [scheduledFire] : []
|
|
31785
31577
|
)
|
|
31786
31578
|
);
|
|
@@ -31836,7 +31628,6 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31836
31628
|
if (canPublish && !await canPublish(actorCtx)) {
|
|
31837
31629
|
throw forbiddenError();
|
|
31838
31630
|
}
|
|
31839
|
-
throwIfActorLost(runtime, ctx);
|
|
31840
31631
|
const decodedBody = decodeValue(body);
|
|
31841
31632
|
if (wait) {
|
|
31842
31633
|
try {
|
|
@@ -31880,7 +31671,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
31880
31671
|
)
|
|
31881
31672
|
};
|
|
31882
31673
|
return runtime.createActorFactory(
|
|
31883
|
-
|
|
31674
|
+
callbacks,
|
|
31884
31675
|
buildActorConfig(definition, registryConfig, runtime.kind)
|
|
31885
31676
|
);
|
|
31886
31677
|
}
|