rivetkit 0.0.0-sqlite-query-metrics-v3.1dff84f → 0.0.0-sqlite-sync-3-0-6-final.cf8679c
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/browser/client.d.ts +95 -20
- package/dist/browser/client.js +2 -2
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/{chunk-HXJ5U2ZI.cjs → chunk-275ZGRSG.cjs} +3 -3
- package/dist/tsup/{chunk-HXJ5U2ZI.cjs.map → chunk-275ZGRSG.cjs.map} +1 -1
- package/dist/tsup/{chunk-HFGXV2CC.cjs → chunk-E54YPM4V.cjs} +10 -10
- package/dist/tsup/{chunk-HFGXV2CC.cjs.map → chunk-E54YPM4V.cjs.map} +1 -1
- package/dist/tsup/{chunk-Y4QLVCCS.cjs → chunk-I26AW6BG.cjs} +2 -2
- package/dist/tsup/{chunk-Y4QLVCCS.cjs.map → chunk-I26AW6BG.cjs.map} +1 -1
- package/dist/tsup/{chunk-CWN7N5AF.cjs → chunk-JHHUCWBC.cjs} +7 -7
- package/dist/tsup/{chunk-CWN7N5AF.cjs.map → chunk-JHHUCWBC.cjs.map} +1 -1
- package/dist/tsup/{chunk-22S5RCCJ.cjs → chunk-LYXPQB6H.cjs} +3 -3
- package/dist/tsup/{chunk-22S5RCCJ.cjs.map → chunk-LYXPQB6H.cjs.map} +1 -1
- package/dist/tsup/{chunk-NNCL4IBC.js → chunk-M72ZKQ7R.js} +2 -2
- package/dist/tsup/{chunk-NNCL4IBC.js.map → chunk-M72ZKQ7R.js.map} +1 -1
- package/dist/tsup/{chunk-QQIFRR3B.js → chunk-ME74LHJM.js} +7 -7
- package/dist/tsup/chunk-ME74LHJM.js.map +1 -0
- package/dist/tsup/{chunk-UXDASKP6.js → chunk-PBIQPYE5.js} +12 -13
- package/dist/tsup/chunk-PBIQPYE5.js.map +1 -0
- package/dist/tsup/{chunk-2CTZU7GL.js → chunk-R4QCQBB4.js} +2 -2
- package/dist/tsup/{chunk-SW33HMM5.js → chunk-RJ7WDGOJ.js} +3 -3
- package/dist/tsup/{chunk-NG5CUXMM.cjs → chunk-SJJWJU26.cjs} +145 -145
- package/dist/tsup/chunk-SJJWJU26.cjs.map +1 -0
- package/dist/tsup/{chunk-HRKFVQPS.js → chunk-SSMFNH4N.js} +4 -4
- package/dist/tsup/{chunk-Y5CFDGPA.cjs → chunk-TKCX6KNZ.cjs} +4 -4
- package/dist/tsup/{chunk-Y5CFDGPA.cjs.map → chunk-TKCX6KNZ.cjs.map} +1 -1
- package/dist/tsup/{chunk-JJUSO7GJ.cjs → chunk-TVBQQXQE.cjs} +3 -3
- package/dist/tsup/{chunk-JJUSO7GJ.cjs.map → chunk-TVBQQXQE.cjs.map} +1 -1
- package/dist/tsup/{chunk-F5PWAGS7.js → chunk-VXVJHTW6.js} +2 -2
- package/dist/tsup/{chunk-FT6VRK4C.js → chunk-XATHAIZX.js} +2 -2
- package/dist/tsup/{chunk-D7DWNYEO.js → chunk-Y5TV6V5Z.js} +2 -2
- package/dist/tsup/{chunk-SSF2XC33.cjs → chunk-YWWDUC6D.cjs} +12 -13
- package/dist/tsup/chunk-YWWDUC6D.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.d.cts +3 -3
- package/dist/tsup/client/mod.d.ts +3 -3
- package/dist/tsup/client/mod.js +4 -4
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-BnMhcPHl.d.cts → config-5K0rzjv1.d.cts} +72 -25
- package/dist/tsup/{config-CBTr4IhE.d.cts → config-Df5jOcde.d.cts} +26 -0
- package/dist/tsup/{config-CBTr4IhE.d.ts → config-Df5jOcde.d.ts} +26 -0
- package/dist/tsup/{config-BiiS5T5M.d.ts → config-DsAjIyfZ.d.ts} +72 -25
- package/dist/tsup/{context-iMxXq_Lt.d.ts → context-B19Rx5Zg.d.cts} +5 -2
- package/dist/tsup/{context-DVE8XMm1.d.cts → context-BEh8x4jn.d.ts} +5 -2
- package/dist/tsup/db/drizzle.cjs +2 -2
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +3 -3
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +2 -2
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.d.cts +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +5 -5
- package/dist/tsup/inspector/mod.js +4 -4
- package/dist/tsup/inspector/workflow.cjs +4 -4
- package/dist/tsup/inspector/workflow.js +3 -3
- package/dist/tsup/inspector-tab/mod.cjs +2 -2
- package/dist/tsup/inspector-tab/mod.d.cts +3 -3
- package/dist/tsup/inspector-tab/mod.d.ts +3 -3
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/mod.cjs +548 -169
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +6 -4
- package/dist/tsup/mod.d.ts +6 -4
- package/dist/tsup/mod.js +447 -68
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +6 -6
- package/dist/tsup/test/mod.d.cts +2 -2
- package/dist/tsup/test/mod.d.ts +2 -2
- package/dist/tsup/test/mod.js +4 -4
- package/dist/tsup/unstable/migrations.d.cts +1 -1
- package/dist/tsup/unstable/migrations.d.ts +1 -1
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +13 -10
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +4 -4
- package/dist/tsup/workflow/mod.d.ts +4 -4
- package/dist/tsup/workflow/mod.js +8 -5
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +9 -9
- package/src/actor/config.ts +41 -29
- package/src/actor/contexts/index.ts +2 -0
- package/src/actor/definition.ts +33 -1
- package/src/actor/schema.ts +4 -0
- package/src/client/actor-common.ts +4 -0
- package/src/client/actor-conn.ts +2 -0
- package/src/client/actor-handle.ts +2 -0
- package/src/client/config.ts +1 -1
- package/src/client/queue.ts +2 -0
- package/src/common/database/config.ts +39 -0
- package/src/common/database/native-database.ts +230 -21
- package/src/registry/index.ts +142 -1
- package/src/registry/napi-runtime.ts +93 -4
- package/src/registry/native.ts +61 -28
- package/src/registry/runtime.ts +58 -8
- package/src/registry/wasm-runtime.ts +88 -14
- package/src/workflow/context.ts +3 -0
- package/dist/tsup/chunk-NG5CUXMM.cjs.map +0 -1
- package/dist/tsup/chunk-QQIFRR3B.js.map +0 -1
- package/dist/tsup/chunk-SSF2XC33.cjs.map +0 -1
- package/dist/tsup/chunk-UXDASKP6.js.map +0 -1
- package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +0 -848
- /package/dist/tsup/{chunk-2CTZU7GL.js.map → chunk-R4QCQBB4.js.map} +0 -0
- /package/dist/tsup/{chunk-SW33HMM5.js.map → chunk-RJ7WDGOJ.js.map} +0 -0
- /package/dist/tsup/{chunk-HRKFVQPS.js.map → chunk-SSMFNH4N.js.map} +0 -0
- /package/dist/tsup/{chunk-F5PWAGS7.js.map → chunk-VXVJHTW6.js.map} +0 -0
- /package/dist/tsup/{chunk-FT6VRK4C.js.map → chunk-XATHAIZX.js.map} +0 -0
- /package/dist/tsup/{chunk-D7DWNYEO.js.map → chunk-Y5TV6V5Z.js.map} +0 -0
package/dist/tsup/mod.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2; var _class3;
|
|
2
2
|
|
|
3
|
+
var _chunkTKCX6KNZcjs = require('./chunk-TKCX6KNZ.cjs');
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
@@ -14,10 +15,9 @@
|
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
|
|
17
|
-
var _chunkSSF2XC33cjs = require('./chunk-SSF2XC33.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkYWWDUC6Dcjs = require('./chunk-YWWDUC6D.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
@@ -35,18 +35,18 @@ var _chunkY5CFDGPAcjs = require('./chunk-Y5CFDGPA.cjs');
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var _chunkSJJWJU26cjs = require('./chunk-SJJWJU26.cjs');
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
var _chunkRTWH3AX3cjs = require('./chunk-RTWH3AX3.cjs');
|
|
43
|
-
require('./chunk-JJUSO7GJ.cjs');
|
|
44
43
|
|
|
45
44
|
|
|
46
45
|
|
|
47
46
|
|
|
48
|
-
var
|
|
47
|
+
var _chunkLYXPQB6Hcjs = require('./chunk-LYXPQB6H.cjs');
|
|
49
48
|
require('./chunk-KVFIONKQ.cjs');
|
|
49
|
+
require('./chunk-TVBQQXQE.cjs');
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
@@ -80,7 +80,7 @@ require('./chunk-KVFIONKQ.cjs');
|
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
var
|
|
83
|
+
var _chunkI26AW6BGcjs = require('./chunk-I26AW6BG.cjs');
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
@@ -98,7 +98,7 @@ var _chunkMGI2VVF6cjs = require('./chunk-MGI2VVF6.cjs');
|
|
|
98
98
|
|
|
99
99
|
// src/actor/log.ts
|
|
100
100
|
function loggerWithoutContext() {
|
|
101
|
-
return
|
|
101
|
+
return _chunkI26AW6BGcjs.getLogger.call(void 0, "actor-runtime");
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
// src/actor/definition.ts
|
|
@@ -116,11 +116,25 @@ function warnDeprecatedOptionKeys(options) {
|
|
|
116
116
|
if (opts[key] !== void 0 && !warnedDeprecatedOptionKeys.has(key)) {
|
|
117
117
|
warnedDeprecatedOptionKeys.add(key);
|
|
118
118
|
loggerWithoutContext().warn({
|
|
119
|
-
msg: `actor option \`${key}\` is deprecated and is now ignored. ${detail} Will be removed in
|
|
119
|
+
msg: `actor option \`${key}\` is deprecated and is now ignored. ${detail} Will be removed in 3.2.0.`
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
+
var warnedDeprecatedRun = false;
|
|
125
|
+
function warnDeprecatedRun(input) {
|
|
126
|
+
if (warnedDeprecatedRun || !input || typeof input !== "object") return;
|
|
127
|
+
const run = input.run;
|
|
128
|
+
if (run === void 0) return;
|
|
129
|
+
const runFunction = typeof run === "object" && run !== null ? run.run : run;
|
|
130
|
+
if (typeof runFunction === "function" && _chunkYWWDUC6Dcjs.getRunInspectorKind.call(void 0, runFunction) === "workflow") {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
warnedDeprecatedRun = true;
|
|
134
|
+
loggerWithoutContext().warn({
|
|
135
|
+
msg: "actor option `run` with a plain function was deprecated in 3.0 and will be removed in a future version. Start background work from `onWake` with `c.keepAwake` and track it in `c.vars`. `run: workflow(...)` is not deprecated. See https://rivet.dev/actors/docs/deprecated/run"
|
|
136
|
+
});
|
|
137
|
+
}
|
|
124
138
|
var ActorDefinition = class {
|
|
125
139
|
#config;
|
|
126
140
|
constructor(config) {
|
|
@@ -138,10 +152,11 @@ function actor(input) {
|
|
|
138
152
|
warnDeprecatedOptionKeys(
|
|
139
153
|
input == null ? void 0 : input.options
|
|
140
154
|
);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
warnDeprecatedRun(input);
|
|
156
|
+
const config = _chunkYWWDUC6Dcjs.ActorConfigSchema.parse(input);
|
|
157
|
+
_chunkYWWDUC6Dcjs.flattenActionHandlers.call(void 0, config.actions);
|
|
158
|
+
_chunkYWWDUC6Dcjs.flattenActionInputSchemas.call(void 0, config.actions, config.actionInputSchemas);
|
|
159
|
+
_chunkYWWDUC6Dcjs.flattenActionTraceSamplers.call(void 0, config.actions, (_a = config.tracing) == null ? void 0 : _a.actions);
|
|
145
160
|
return new ActorDefinition(config);
|
|
146
161
|
}
|
|
147
162
|
function isStaticActorDefinition(definition) {
|
|
@@ -240,7 +255,7 @@ function validateSchemaSync(schemas, key, data) {
|
|
|
240
255
|
var _virtualwebsocket = require('@rivetkit/virtual-websocket');
|
|
241
256
|
var _ws = require('hono/ws');
|
|
242
257
|
function logger() {
|
|
243
|
-
return
|
|
258
|
+
return _chunkI26AW6BGcjs.getLogger.call(void 0, "inline-websocket-adapter");
|
|
244
259
|
}
|
|
245
260
|
var InlineWebSocketAdapter = class {
|
|
246
261
|
#handler;
|
|
@@ -392,7 +407,7 @@ var InlineWebSocketAdapter = class {
|
|
|
392
407
|
|
|
393
408
|
// src/registry/log.ts
|
|
394
409
|
function logger2() {
|
|
395
|
-
return
|
|
410
|
+
return _chunkI26AW6BGcjs.getLogger.call(void 0, "registry");
|
|
396
411
|
}
|
|
397
412
|
|
|
398
413
|
// src/serverless/configure.ts
|
|
@@ -438,8 +453,8 @@ async function configureServerlessPool(config) {
|
|
|
438
453
|
);
|
|
439
454
|
}
|
|
440
455
|
const customConfig = config.configurePool;
|
|
441
|
-
const clientConfig =
|
|
442
|
-
const dcsRes = await
|
|
456
|
+
const clientConfig = _chunkSJJWJU26cjs.convertRegistryConfigToClientConfig.call(void 0, config);
|
|
457
|
+
const dcsRes = await _chunkSJJWJU26cjs.getDatacenters.call(void 0, clientConfig);
|
|
443
458
|
const poolName = _nullishCoalesce(customConfig.name, () => ( "default"));
|
|
444
459
|
const serverlessToken = _nullishCoalesce(config.token, () => ( config.publicToken));
|
|
445
460
|
const headers = {
|
|
@@ -461,7 +476,7 @@ async function configureServerlessPool(config) {
|
|
|
461
476
|
metadata: _nullishCoalesce(customConfig.metadata, () => ( {})),
|
|
462
477
|
drain_on_version_upgrade: _nullishCoalesce(customConfig.drainOnVersionUpgrade, () => ( true))
|
|
463
478
|
};
|
|
464
|
-
await
|
|
479
|
+
await _chunkSJJWJU26cjs.updateRunnerConfig.call(void 0, clientConfig, poolName, {
|
|
465
480
|
datacenters: Object.fromEntries(
|
|
466
481
|
dcsRes.datacenters.map((dc) => [dc.name, serverlessConfig])
|
|
467
482
|
)
|
|
@@ -478,7 +493,7 @@ async function configureServerlessPool(config) {
|
|
|
478
493
|
logger2().warn({
|
|
479
494
|
msg: "serverless pool configuration attempt failed",
|
|
480
495
|
attempts,
|
|
481
|
-
error:
|
|
496
|
+
error: _chunkI26AW6BGcjs.stringifyError.call(void 0, error)
|
|
482
497
|
});
|
|
483
498
|
await sleep(CONFIGURE_RETRY_DELAY_MS);
|
|
484
499
|
}
|
|
@@ -486,7 +501,7 @@ async function configureServerlessPool(config) {
|
|
|
486
501
|
logger2().error({
|
|
487
502
|
msg: "failed to configure serverless pool, validate endpoint is configured correctly then restart this process",
|
|
488
503
|
attempts,
|
|
489
|
-
error:
|
|
504
|
+
error: _chunkI26AW6BGcjs.stringifyError.call(void 0, lastError)
|
|
490
505
|
});
|
|
491
506
|
throw lastError;
|
|
492
507
|
}
|
|
@@ -497,10 +512,10 @@ var _zod = require('zod');
|
|
|
497
512
|
// src/registry/config/envoy.ts
|
|
498
513
|
var _v4 = require('zod/v4');
|
|
499
514
|
var EnvoyConfigSchema = _v4.z.object({
|
|
500
|
-
poolName: _v4.z.string().default(() => _nullishCoalesce(
|
|
501
|
-
version: _v4.z.number().default(() => _nullishCoalesce(
|
|
515
|
+
poolName: _v4.z.string().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetPool.call(void 0, ), () => ( "default"))),
|
|
516
|
+
version: _v4.z.number().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetEnvoyVersion.call(void 0, ), () => ( 1))),
|
|
502
517
|
// Deprecated.
|
|
503
|
-
totalSlots: _v4.z.number().default(() => _nullishCoalesce(
|
|
518
|
+
totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetTotalSlots.call(void 0, ), () => ( 1e5))),
|
|
504
519
|
nodeKey: _v4.z.string().optional()
|
|
505
520
|
});
|
|
506
521
|
|
|
@@ -538,7 +553,7 @@ var ServerlessConfigSchema = _v4.z.object({
|
|
|
538
553
|
*
|
|
539
554
|
* Can also be set via RIVET_PUBLIC_ENDPOINT environment variable.
|
|
540
555
|
*/
|
|
541
|
-
publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
556
|
+
publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetPublicEndpoint.call(void 0, )))),
|
|
542
557
|
/**
|
|
543
558
|
* Token that clients should use when connecting via the public endpoint.
|
|
544
559
|
*
|
|
@@ -546,7 +561,7 @@ var ServerlessConfigSchema = _v4.z.object({
|
|
|
546
561
|
*
|
|
547
562
|
* Can also be specified in the publicEndpoint URL as `https://namespace:token@host`.
|
|
548
563
|
*/
|
|
549
|
-
publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
564
|
+
publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetPublicToken.call(void 0, ))))
|
|
550
565
|
// There is no publicNamespace config option because the frontend and backend
|
|
551
566
|
// cannot use different namespaces. The namespace is extracted from the
|
|
552
567
|
// publicEndpoint URL auth syntax if provided.
|
|
@@ -600,7 +615,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
600
615
|
* Runtime binding to use for RivetKit core.
|
|
601
616
|
* */
|
|
602
617
|
runtime: RuntimeKindSchema.optional().transform((val, ctx) => {
|
|
603
|
-
const rawRuntime = _nullishCoalesce(val, () => (
|
|
618
|
+
const rawRuntime = _nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetkitRuntime.call(void 0, )));
|
|
604
619
|
if (rawRuntime === void 0) {
|
|
605
620
|
return "auto";
|
|
606
621
|
}
|
|
@@ -637,7 +652,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
637
652
|
* */
|
|
638
653
|
logging: _zod.z.object({
|
|
639
654
|
baseLogger: _zod.z.custom().optional(),
|
|
640
|
-
level:
|
|
655
|
+
level: _chunkI26AW6BGcjs.LogLevelSchema.optional()
|
|
641
656
|
}).optional().default(() => ({})),
|
|
642
657
|
// MARK: Routing
|
|
643
658
|
// // This is a function to allow for lazy configuration of upgradeWebSocket on the
|
|
@@ -655,9 +670,9 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
655
670
|
*
|
|
656
671
|
* Can also be set via RIVET_ENDPOINT environment variables.
|
|
657
672
|
*/
|
|
658
|
-
endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => (
|
|
659
|
-
token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
660
|
-
namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
673
|
+
endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetEngine.call(void 0, ))), () => ( _chunkI26AW6BGcjs.getRivetEndpoint.call(void 0, )))),
|
|
674
|
+
token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetToken.call(void 0, )))),
|
|
675
|
+
namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetNamespace.call(void 0, )))),
|
|
661
676
|
headers: _zod.z.record(_zod.z.string(), _zod.z.string()).optional().default({}),
|
|
662
677
|
// MARK: Client
|
|
663
678
|
// TODO:
|
|
@@ -697,21 +712,21 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
697
712
|
*
|
|
698
713
|
* Starts the full Rust engine process locally.
|
|
699
714
|
*/
|
|
700
|
-
startEngine: _zod.z.boolean().default(() =>
|
|
715
|
+
startEngine: _zod.z.boolean().default(() => _chunkI26AW6BGcjs.getRivetRunEngine.call(void 0, )),
|
|
701
716
|
/**
|
|
702
717
|
* @experimental
|
|
703
718
|
*
|
|
704
719
|
* Host to bind the spawned local engine process to.
|
|
705
720
|
*/
|
|
706
|
-
engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(
|
|
721
|
+
engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetRunEngineHost.call(void 0, ), () => ( _chunkSJJWJU26cjs.ENGINE_HOST))),
|
|
707
722
|
/**
|
|
708
723
|
* @experimental
|
|
709
724
|
*
|
|
710
725
|
* Port to bind the spawned local engine process to.
|
|
711
726
|
*/
|
|
712
|
-
enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(
|
|
727
|
+
enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetRunEnginePort.call(void 0, ), () => ( _chunkSJJWJU26cjs.ENGINE_PORT))),
|
|
713
728
|
/** @experimental */
|
|
714
|
-
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(
|
|
729
|
+
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunkI26AW6BGcjs.VERSION))),
|
|
715
730
|
/**
|
|
716
731
|
* Starts the first-party Services actor host when RivetKit manages
|
|
717
732
|
* a local engine. Enabled by default for a managed local Engine. Set
|
|
@@ -768,7 +783,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
768
783
|
}))
|
|
769
784
|
}).transform((config, ctx) => {
|
|
770
785
|
var _a, _b, _c;
|
|
771
|
-
const isDevEnv =
|
|
786
|
+
const isDevEnv = _chunkI26AW6BGcjs.isDev.call(void 0, );
|
|
772
787
|
const sqliteBackend = _nullishCoalesce(((_a = config.sqlite) == null ? void 0 : _a.backend), () => ( ((_b = config.test) == null ? void 0 : _b.sqliteBackend)));
|
|
773
788
|
if (config.runtime === "wasm" && sqliteBackend === "local") {
|
|
774
789
|
ctx.addIssue({
|
|
@@ -778,7 +793,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
778
793
|
});
|
|
779
794
|
}
|
|
780
795
|
const sqlite = config.runtime === "wasm" && config.sqlite === void 0 ? { backend: "remote" } : config.sqlite;
|
|
781
|
-
const parsedEndpoint = config.endpoint ?
|
|
796
|
+
const parsedEndpoint = config.endpoint ? _chunkSJJWJU26cjs.tryParseEndpoint.call(void 0, ctx, {
|
|
782
797
|
endpoint: config.endpoint,
|
|
783
798
|
path: ["endpoint"],
|
|
784
799
|
namespace: config.namespace,
|
|
@@ -797,19 +812,19 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
797
812
|
path: ["configurePool"]
|
|
798
813
|
});
|
|
799
814
|
}
|
|
800
|
-
const localEngineEndpoint =
|
|
815
|
+
const localEngineEndpoint = _chunkSJJWJU26cjs.buildEngineEndpoint.call(void 0,
|
|
801
816
|
config.engineHost,
|
|
802
817
|
config.enginePort
|
|
803
818
|
);
|
|
804
819
|
const endpoint = config.startEngine ? localEngineEndpoint : _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint), () => ( (isDevEnv ? localEngineEndpoint : void 0)));
|
|
805
820
|
const engineSpawn = !parsedEndpoint && Boolean(endpoint);
|
|
806
|
-
const startServices = _nullishCoalesce(_nullishCoalesce(config.startServices, () => (
|
|
821
|
+
const startServices = _nullishCoalesce(_nullishCoalesce(config.startServices, () => ( _chunkI26AW6BGcjs.getRivetRunServices.call(void 0, ))), () => ( engineSpawn));
|
|
807
822
|
const validateServerlessEndpoint = Boolean(
|
|
808
823
|
config.startEngine || parsedEndpoint
|
|
809
824
|
);
|
|
810
825
|
const namespace = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.namespace), () => ( config.namespace)), () => ( "default"));
|
|
811
|
-
const token = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token)), () => ( (endpoint &&
|
|
812
|
-
const parsedPublicEndpoint = config.serverless.publicEndpoint ?
|
|
826
|
+
const token = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token)), () => ( (endpoint && _chunkSJJWJU26cjs.isLocalEngineEndpoint.call(void 0, endpoint) ? "default" : void 0)));
|
|
827
|
+
const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunkSJJWJU26cjs.tryParseEndpoint.call(void 0, ctx, {
|
|
813
828
|
endpoint: config.serverless.publicEndpoint,
|
|
814
829
|
path: ["serverless", "publicEndpoint"]
|
|
815
830
|
}) : void 0;
|
|
@@ -846,7 +861,7 @@ function buildActorNames(config) {
|
|
|
846
861
|
Object.keys(config.use).map((actorName) => {
|
|
847
862
|
const definition = config.use[actorName];
|
|
848
863
|
const options = _nullishCoalesce(definition.config.options, () => ( {}));
|
|
849
|
-
const runMeta =
|
|
864
|
+
const runMeta = _chunkYWWDUC6Dcjs.getRunMetadata.call(void 0, definition.config.run);
|
|
850
865
|
const metadata = {};
|
|
851
866
|
metadata.icon = _nullishCoalesce(options.icon, () => ( runMeta.icon));
|
|
852
867
|
metadata.name = _nullishCoalesce(options.name, () => ( runMeta.name));
|
|
@@ -914,7 +929,7 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
914
929
|
noWelcome: _zod.z.boolean().optional().describe("Disable the welcome message on startup. Default: false"),
|
|
915
930
|
sqlite: DocSqliteConfigSchema,
|
|
916
931
|
logging: _zod.z.object({
|
|
917
|
-
level:
|
|
932
|
+
level: _chunkI26AW6BGcjs.LogLevelSchema.optional().describe(
|
|
918
933
|
"Log level for RivetKit. Default: 'warn'"
|
|
919
934
|
)
|
|
920
935
|
}).optional().describe("Logging configuration."),
|
|
@@ -956,6 +971,10 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
956
971
|
|
|
957
972
|
|
|
958
973
|
// src/common/database/native-database.ts
|
|
974
|
+
function isSynchronousTransaction(transaction) {
|
|
975
|
+
const candidate = transaction;
|
|
976
|
+
return typeof candidate.commitSync === "function" && typeof candidate.rollbackSync === "function";
|
|
977
|
+
}
|
|
959
978
|
function shouldAttachNativeKvError(message) {
|
|
960
979
|
return /i\/o error|unable to open database file/i.test(message);
|
|
961
980
|
}
|
|
@@ -976,13 +995,16 @@ function toNativeBinding(arg) {
|
|
|
976
995
|
if (arg === null || arg === void 0) {
|
|
977
996
|
return { kind: "null" };
|
|
978
997
|
}
|
|
979
|
-
if (typeof arg === "bigint") {
|
|
980
|
-
|
|
998
|
+
if (typeof arg === "bigint" || typeof arg === "number" && Number.isInteger(arg)) {
|
|
999
|
+
const value = Number(arg);
|
|
1000
|
+
if (!Number.isSafeInteger(value)) {
|
|
1001
|
+
throw new RangeError(
|
|
1002
|
+
"SQLite integer bindings must be within the JavaScript safe integer range."
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
return { kind: "int", intValue: value };
|
|
981
1006
|
}
|
|
982
1007
|
if (typeof arg === "number") {
|
|
983
|
-
if (Number.isInteger(arg)) {
|
|
984
|
-
return { kind: "int", intValue: arg };
|
|
985
|
-
}
|
|
986
1008
|
return { kind: "float", floatValue: arg };
|
|
987
1009
|
}
|
|
988
1010
|
if (typeof arg === "string") {
|
|
@@ -999,9 +1021,10 @@ function toNativeBinding(arg) {
|
|
|
999
1021
|
function extractNamedSqliteParameters(sql) {
|
|
1000
1022
|
const orderedNames = [];
|
|
1001
1023
|
const seen = /* @__PURE__ */ new Set();
|
|
1002
|
-
const pattern = /([:@$][A-Za-z_][
|
|
1024
|
+
const pattern = /'(?:''|[^'])*'|"(?:""|[^"])*"|`(?:``|[^`])*`|\[[^\]]*\]|--[^\n]*|\/\*[\s\S]*?(?:\*\/|$)|([:@$][\w$\u0080-\u{10FFFF}]+(?:::[\w$\u0080-\u{10FFFF}]+)*(?:\([^)]*\))?)|[A-Za-z_\u0080-\u{10FFFF}][\w$\u0080-\u{10FFFF}]*/gu;
|
|
1003
1025
|
for (const match of sql.matchAll(pattern)) {
|
|
1004
1026
|
const name = match[1];
|
|
1027
|
+
if (!name) continue;
|
|
1005
1028
|
if (seen.has(name)) {
|
|
1006
1029
|
continue;
|
|
1007
1030
|
}
|
|
@@ -1120,20 +1143,44 @@ function wrapJsNativeDatabase(database) {
|
|
|
1120
1143
|
let terminalPromise;
|
|
1121
1144
|
let lastInsertRowId = null;
|
|
1122
1145
|
const executeNative = async (sql, params) => {
|
|
1123
|
-
const lastInsertRowIdColumn = lastInsertRowIdColumnName(sql);
|
|
1124
|
-
if (lastInsertRowIdColumn) {
|
|
1125
|
-
return {
|
|
1126
|
-
columns: [lastInsertRowIdColumn],
|
|
1127
|
-
rows: [[_nullishCoalesce(lastInsertRowId, () => ( 0))]],
|
|
1128
|
-
changes: 0,
|
|
1129
|
-
lastInsertRowId
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
1146
|
const release = gate.enter();
|
|
1133
1147
|
try {
|
|
1148
|
+
const lastInsertRowIdColumn = lastInsertRowIdColumnName(sql);
|
|
1149
|
+
if (lastInsertRowIdColumn) {
|
|
1150
|
+
return {
|
|
1151
|
+
columns: [lastInsertRowIdColumn],
|
|
1152
|
+
rows: [[_nullishCoalesce(lastInsertRowId, () => ( 0))]],
|
|
1153
|
+
changes: 0,
|
|
1154
|
+
lastInsertRowId
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1134
1157
|
const nativeParams = toNativeBindings(sql, params);
|
|
1135
1158
|
const result = await database.execute(sql, nativeParams);
|
|
1136
|
-
if (result.lastInsertRowId
|
|
1159
|
+
if (result.lastInsertRowId != null) {
|
|
1160
|
+
lastInsertRowId = result.lastInsertRowId;
|
|
1161
|
+
}
|
|
1162
|
+
return result;
|
|
1163
|
+
} catch (error) {
|
|
1164
|
+
enrichNativeDatabaseError(database, error);
|
|
1165
|
+
} finally {
|
|
1166
|
+
release();
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1169
|
+
const executeNativeSync = (sql, params) => {
|
|
1170
|
+
const release = gate.enter();
|
|
1171
|
+
try {
|
|
1172
|
+
const nativeParams = toNativeBindings(sql, params);
|
|
1173
|
+
const result = database.executeSync(sql, nativeParams);
|
|
1174
|
+
const rowIdColumn = lastInsertRowIdColumnName(sql);
|
|
1175
|
+
if (rowIdColumn) {
|
|
1176
|
+
return {
|
|
1177
|
+
columns: [rowIdColumn],
|
|
1178
|
+
rows: [[_nullishCoalesce(lastInsertRowId, () => ( 0))]],
|
|
1179
|
+
changes: 0,
|
|
1180
|
+
lastInsertRowId
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
if (result.lastInsertRowId != null) {
|
|
1137
1184
|
lastInsertRowId = result.lastInsertRowId;
|
|
1138
1185
|
}
|
|
1139
1186
|
return result;
|
|
@@ -1161,9 +1208,28 @@ function wrapJsNativeDatabase(database) {
|
|
|
1161
1208
|
callback(row, result.columns);
|
|
1162
1209
|
}
|
|
1163
1210
|
},
|
|
1211
|
+
execSync(sql, callback) {
|
|
1212
|
+
const release = gate.enter();
|
|
1213
|
+
let result;
|
|
1214
|
+
try {
|
|
1215
|
+
result = database.execSync(sql);
|
|
1216
|
+
} catch (error) {
|
|
1217
|
+
enrichNativeDatabaseError(database, error);
|
|
1218
|
+
} finally {
|
|
1219
|
+
release();
|
|
1220
|
+
}
|
|
1221
|
+
if (callback) {
|
|
1222
|
+
for (const row of result.rows) {
|
|
1223
|
+
callback(row, result.columns);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
},
|
|
1164
1227
|
async execute(sql, params) {
|
|
1165
1228
|
return await executeNative(sql, params);
|
|
1166
1229
|
},
|
|
1230
|
+
executeSync(sql, params) {
|
|
1231
|
+
return executeNativeSync(sql, params);
|
|
1232
|
+
},
|
|
1167
1233
|
async executeBatch(statements) {
|
|
1168
1234
|
const nativeStatements = statements.map(toNativeBatchStatement);
|
|
1169
1235
|
const release = gate.enter();
|
|
@@ -1185,7 +1251,7 @@ function wrapJsNativeDatabase(database) {
|
|
|
1185
1251
|
return transactionResults;
|
|
1186
1252
|
})();
|
|
1187
1253
|
for (const result of results) {
|
|
1188
|
-
if (result.lastInsertRowId
|
|
1254
|
+
if (result.lastInsertRowId != null) {
|
|
1189
1255
|
lastInsertRowId = result.lastInsertRowId;
|
|
1190
1256
|
}
|
|
1191
1257
|
}
|
|
@@ -1213,7 +1279,23 @@ function wrapJsNativeDatabase(database) {
|
|
|
1213
1279
|
release();
|
|
1214
1280
|
}
|
|
1215
1281
|
return wrapTransaction(database, transaction, gate, (result) => {
|
|
1216
|
-
if (result.lastInsertRowId
|
|
1282
|
+
if (result.lastInsertRowId != null) {
|
|
1283
|
+
lastInsertRowId = result.lastInsertRowId;
|
|
1284
|
+
}
|
|
1285
|
+
});
|
|
1286
|
+
},
|
|
1287
|
+
beginTransactionSync(timeoutMs, name) {
|
|
1288
|
+
const release = gate.enter();
|
|
1289
|
+
let transaction;
|
|
1290
|
+
try {
|
|
1291
|
+
transaction = database.beginTransactionSync(timeoutMs, name);
|
|
1292
|
+
} catch (error) {
|
|
1293
|
+
enrichNativeDatabaseError(database, error);
|
|
1294
|
+
} finally {
|
|
1295
|
+
release();
|
|
1296
|
+
}
|
|
1297
|
+
return wrapTransaction(database, transaction, gate, (result) => {
|
|
1298
|
+
if (result.lastInsertRowId != null) {
|
|
1217
1299
|
lastInsertRowId = result.lastInsertRowId;
|
|
1218
1300
|
}
|
|
1219
1301
|
});
|
|
@@ -1235,7 +1317,7 @@ function wrapJsNativeDatabase(database) {
|
|
|
1235
1317
|
release();
|
|
1236
1318
|
}
|
|
1237
1319
|
return wrapTransaction(database, transaction, gate, (result) => {
|
|
1238
|
-
if (result.lastInsertRowId
|
|
1320
|
+
if (result.lastInsertRowId != null) {
|
|
1239
1321
|
lastInsertRowId = result.lastInsertRowId;
|
|
1240
1322
|
}
|
|
1241
1323
|
});
|
|
@@ -1251,6 +1333,25 @@ function wrapJsNativeDatabase(database) {
|
|
|
1251
1333
|
var _a;
|
|
1252
1334
|
return normalizeNativeMetrics((_a = database.metrics) == null ? void 0 : _a.call(database));
|
|
1253
1335
|
},
|
|
1336
|
+
async open() {
|
|
1337
|
+
const release = gate.enter();
|
|
1338
|
+
try {
|
|
1339
|
+
await database.open();
|
|
1340
|
+
} catch (error) {
|
|
1341
|
+
enrichNativeDatabaseError(database, error);
|
|
1342
|
+
} finally {
|
|
1343
|
+
release();
|
|
1344
|
+
}
|
|
1345
|
+
},
|
|
1346
|
+
commitTicket() {
|
|
1347
|
+
return database.commitTicket();
|
|
1348
|
+
},
|
|
1349
|
+
async whenDurable(ticket) {
|
|
1350
|
+
await database.whenDurable(ticket);
|
|
1351
|
+
},
|
|
1352
|
+
abortGeneration(reason) {
|
|
1353
|
+
database.abortGeneration(reason);
|
|
1354
|
+
},
|
|
1254
1355
|
async close() {
|
|
1255
1356
|
terminalPromise ??= gate.close(() => database.close());
|
|
1256
1357
|
await terminalPromise;
|
|
@@ -1262,7 +1363,7 @@ function wrapJsNativeDatabase(database) {
|
|
|
1262
1363
|
};
|
|
1263
1364
|
}
|
|
1264
1365
|
function wrapTransaction(database, transaction, gate, onExecute) {
|
|
1265
|
-
|
|
1366
|
+
const wrapped = {
|
|
1266
1367
|
async exec(sql, callback) {
|
|
1267
1368
|
const release = gate.enter();
|
|
1268
1369
|
let result;
|
|
@@ -1313,6 +1414,61 @@ function wrapTransaction(database, transaction, gate, onExecute) {
|
|
|
1313
1414
|
}
|
|
1314
1415
|
}
|
|
1315
1416
|
};
|
|
1417
|
+
if (isSynchronousTransaction(transaction)) {
|
|
1418
|
+
return Object.assign(wrapped, {
|
|
1419
|
+
execSync(sql, callback) {
|
|
1420
|
+
const release = gate.enter();
|
|
1421
|
+
let result;
|
|
1422
|
+
try {
|
|
1423
|
+
result = transaction.execSync(sql);
|
|
1424
|
+
} catch (error) {
|
|
1425
|
+
enrichNativeDatabaseError(database, error);
|
|
1426
|
+
} finally {
|
|
1427
|
+
release();
|
|
1428
|
+
}
|
|
1429
|
+
if (callback) {
|
|
1430
|
+
for (const row of result.rows)
|
|
1431
|
+
callback(row, result.columns);
|
|
1432
|
+
}
|
|
1433
|
+
},
|
|
1434
|
+
executeSync(sql, params) {
|
|
1435
|
+
const release = gate.enter();
|
|
1436
|
+
try {
|
|
1437
|
+
const result = transaction.executeSync(
|
|
1438
|
+
sql,
|
|
1439
|
+
toNativeBindings(sql, params)
|
|
1440
|
+
);
|
|
1441
|
+
onExecute(result);
|
|
1442
|
+
return result;
|
|
1443
|
+
} catch (error) {
|
|
1444
|
+
enrichNativeDatabaseError(database, error);
|
|
1445
|
+
} finally {
|
|
1446
|
+
release();
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
commitSync() {
|
|
1450
|
+
const release = gate.enter();
|
|
1451
|
+
try {
|
|
1452
|
+
transaction.commitSync();
|
|
1453
|
+
} catch (error) {
|
|
1454
|
+
enrichNativeDatabaseError(database, error);
|
|
1455
|
+
} finally {
|
|
1456
|
+
release();
|
|
1457
|
+
}
|
|
1458
|
+
},
|
|
1459
|
+
rollbackSync() {
|
|
1460
|
+
const release = gate.enter();
|
|
1461
|
+
try {
|
|
1462
|
+
transaction.rollbackSync();
|
|
1463
|
+
} catch (error) {
|
|
1464
|
+
enrichNativeDatabaseError(database, error);
|
|
1465
|
+
} finally {
|
|
1466
|
+
release();
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
return wrapped;
|
|
1316
1472
|
}
|
|
1317
1473
|
function lastInsertRowIdColumnName(sql) {
|
|
1318
1474
|
const match = sql.match(
|
|
@@ -1554,7 +1710,7 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1554
1710
|
if (!(active == null ? void 0 : active.sameActorInstance(ownerCtx))) {
|
|
1555
1711
|
return ownerCtx;
|
|
1556
1712
|
}
|
|
1557
|
-
const applicationSpan =
|
|
1713
|
+
const applicationSpan = _chunkSJJWJU26cjs.readActiveTraceHeaders.call(void 0, );
|
|
1558
1714
|
if (!applicationSpan) {
|
|
1559
1715
|
return active;
|
|
1560
1716
|
}
|
|
@@ -1599,6 +1755,15 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1599
1755
|
async registryActorStopThresholdMs(registry) {
|
|
1600
1756
|
return await _asyncNullishCoalesce(await asNativeRegistry(registry).actorStopThresholdMs(), async () => ( void 0));
|
|
1601
1757
|
}
|
|
1758
|
+
registryActiveActorCount(registry) {
|
|
1759
|
+
return asNativeRegistry(registry).activeActorCount();
|
|
1760
|
+
}
|
|
1761
|
+
onRegistryActiveActorCountChange(registry, callback, cancelToken) {
|
|
1762
|
+
asNativeRegistry(registry).onActiveActorCountChange(
|
|
1763
|
+
callback,
|
|
1764
|
+
asNativeCancellationToken(cancelToken)
|
|
1765
|
+
);
|
|
1766
|
+
}
|
|
1602
1767
|
async registryHealth(registry) {
|
|
1603
1768
|
const response = await asNativeRegistry(registry).health();
|
|
1604
1769
|
return {
|
|
@@ -1758,7 +1923,7 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1758
1923
|
const span = (_a = nativeCtx.invocationTraceContext()) == null ? void 0 : _a.span;
|
|
1759
1924
|
return this.#invocationContext.run(
|
|
1760
1925
|
nativeCtx,
|
|
1761
|
-
() =>
|
|
1926
|
+
() => _chunkSJJWJU26cjs.runWithActorInvocationSpan.call(void 0, span, run)
|
|
1762
1927
|
);
|
|
1763
1928
|
}
|
|
1764
1929
|
actorInvocationTraceContext(ctx) {
|
|
@@ -1897,6 +2062,9 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1897
2062
|
async actorSqlExec(ctx, sql) {
|
|
1898
2063
|
return await this.#actorSql(ctx).exec(sql);
|
|
1899
2064
|
}
|
|
2065
|
+
actorSqlExecSync(ctx, sql) {
|
|
2066
|
+
return this.#actorSql(ctx).execSync(sql);
|
|
2067
|
+
}
|
|
1900
2068
|
async actorSqlExecute(ctx, sql, params) {
|
|
1901
2069
|
const result = await this.#actorSql(ctx).execute(
|
|
1902
2070
|
sql,
|
|
@@ -1904,6 +2072,13 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1904
2072
|
);
|
|
1905
2073
|
return normalizeRuntimeSqlExecuteResult(result);
|
|
1906
2074
|
}
|
|
2075
|
+
actorSqlExecuteSync(ctx, sql, params) {
|
|
2076
|
+
const result = this.#actorSql(ctx).executeSync(
|
|
2077
|
+
sql,
|
|
2078
|
+
toNapiSqlBindParams(params)
|
|
2079
|
+
);
|
|
2080
|
+
return normalizeRuntimeSqlExecuteResult(result);
|
|
2081
|
+
}
|
|
1907
2082
|
async actorSqlExecuteBatch(ctx, statements) {
|
|
1908
2083
|
const results = await this.#actorSql(ctx).executeBatch(
|
|
1909
2084
|
statements.map(toNapiSqlBatchStatement)
|
|
@@ -1916,9 +2091,18 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1916
2091
|
name
|
|
1917
2092
|
);
|
|
1918
2093
|
}
|
|
2094
|
+
actorSqlBeginTransactionSync(ctx, timeoutMs, name) {
|
|
2095
|
+
return this.#actorSql(ctx).beginTransactionSync(
|
|
2096
|
+
timeoutMs,
|
|
2097
|
+
name
|
|
2098
|
+
);
|
|
2099
|
+
}
|
|
1919
2100
|
async actorSqlTransactionExec(transaction, sql) {
|
|
1920
2101
|
return await asNativeSqlTransaction(transaction).exec(sql);
|
|
1921
2102
|
}
|
|
2103
|
+
actorSqlTransactionExecSync(transaction, sql) {
|
|
2104
|
+
return asNativeSqlTransaction(transaction).execSync(sql);
|
|
2105
|
+
}
|
|
1922
2106
|
async actorSqlTransactionExecute(transaction, sql, params) {
|
|
1923
2107
|
const result = await asNativeSqlTransaction(transaction).execute(
|
|
1924
2108
|
sql,
|
|
@@ -1926,12 +2110,25 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1926
2110
|
);
|
|
1927
2111
|
return normalizeRuntimeSqlExecuteResult(result);
|
|
1928
2112
|
}
|
|
2113
|
+
actorSqlTransactionExecuteSync(transaction, sql, params) {
|
|
2114
|
+
const result = asNativeSqlTransaction(transaction).executeSync(
|
|
2115
|
+
sql,
|
|
2116
|
+
toNapiSqlBindParams(params)
|
|
2117
|
+
);
|
|
2118
|
+
return normalizeRuntimeSqlExecuteResult(result);
|
|
2119
|
+
}
|
|
1929
2120
|
async actorSqlTransactionCommit(transaction) {
|
|
1930
2121
|
await asNativeSqlTransaction(transaction).commit();
|
|
1931
2122
|
}
|
|
2123
|
+
actorSqlTransactionCommitSync(transaction) {
|
|
2124
|
+
asNativeSqlTransaction(transaction).commitSync();
|
|
2125
|
+
}
|
|
1932
2126
|
async actorSqlTransactionRollback(transaction) {
|
|
1933
2127
|
await asNativeSqlTransaction(transaction).rollback();
|
|
1934
2128
|
}
|
|
2129
|
+
actorSqlTransactionRollbackSync(transaction) {
|
|
2130
|
+
asNativeSqlTransaction(transaction).rollbackSync();
|
|
2131
|
+
}
|
|
1935
2132
|
async actorBeginStateTransaction(ctx, timeoutMs) {
|
|
1936
2133
|
return await this.#actorContextForOperation(ctx).beginStateTransaction(
|
|
1937
2134
|
timeoutMs
|
|
@@ -1969,6 +2166,18 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1969
2166
|
var _a, _b;
|
|
1970
2167
|
return _nullishCoalesce(((_b = (_a = this.#actorSql(ctx)).takeLastKvError) == null ? void 0 : _b.call(_a)), () => ( null));
|
|
1971
2168
|
}
|
|
2169
|
+
async actorSqlOpen(ctx) {
|
|
2170
|
+
await this.#actorSql(ctx).open();
|
|
2171
|
+
}
|
|
2172
|
+
actorSqlCommitTicket(ctx) {
|
|
2173
|
+
return this.#actorSql(ctx).commitTicket();
|
|
2174
|
+
}
|
|
2175
|
+
actorSqlAbortGeneration(ctx, reason) {
|
|
2176
|
+
this.#actorSql(ctx).abortGeneration(reason);
|
|
2177
|
+
}
|
|
2178
|
+
async actorSqlWhenDurable(ctx, ticket) {
|
|
2179
|
+
await this.#actorSql(ctx).whenDurable(ticket);
|
|
2180
|
+
}
|
|
1972
2181
|
async actorSqlClose(ctx) {
|
|
1973
2182
|
const nativeCtx = asNativeActorContext(ctx);
|
|
1974
2183
|
if (!this.#sqlOpened.delete(nativeCtx)) {
|
|
@@ -1976,9 +2185,6 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1976
2185
|
}
|
|
1977
2186
|
await nativeCtx.sql().close();
|
|
1978
2187
|
}
|
|
1979
|
-
async actorRuntimeSocketProvision(ctx) {
|
|
1980
|
-
return await asNativeActorContext(ctx).provisionActorRuntimeSocket();
|
|
1981
|
-
}
|
|
1982
2188
|
async actorQueueSend(ctx, name, body) {
|
|
1983
2189
|
return toNapiQueueMessage(
|
|
1984
2190
|
await this.#actorContextForOperation(ctx).queue().send(name, toNapiBuffer(body))
|
|
@@ -2133,8 +2339,8 @@ function runtimeBytesToArrayBuffer(value) {
|
|
|
2133
2339
|
function buildNativeHttpRequest(init) {
|
|
2134
2340
|
var _a;
|
|
2135
2341
|
const headers = new Headers(init.headers);
|
|
2136
|
-
const originalUrl = headers.get(
|
|
2137
|
-
headers.delete(
|
|
2342
|
+
const originalUrl = headers.get(_chunkSJJWJU26cjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2343
|
+
headers.delete(_chunkSJJWJU26cjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2138
2344
|
const url = _nullishCoalesce(originalUrl, () => ( (init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString())));
|
|
2139
2345
|
const method2 = init.method.toUpperCase();
|
|
2140
2346
|
const bodyForbidden = method2 === "GET" || method2 === "HEAD";
|
|
@@ -2213,7 +2419,7 @@ async function pumpResponseBody(reader, stream) {
|
|
|
2213
2419
|
}
|
|
2214
2420
|
} catch (error) {
|
|
2215
2421
|
try {
|
|
2216
|
-
await stream.error(
|
|
2422
|
+
await stream.error(_chunkI26AW6BGcjs.stringifyError.call(void 0, error));
|
|
2217
2423
|
} catch (streamError) {
|
|
2218
2424
|
logger2().debug({
|
|
2219
2425
|
msg: "failed to report native http response stream error",
|
|
@@ -2381,7 +2587,7 @@ var RunHandlerCoordinator = class {
|
|
|
2381
2587
|
this.#run = run;
|
|
2382
2588
|
}
|
|
2383
2589
|
get inspectorKind() {
|
|
2384
|
-
return
|
|
2590
|
+
return _chunkYWWDUC6Dcjs.getRunInspectorKind.call(void 0, this.#run);
|
|
2385
2591
|
}
|
|
2386
2592
|
async run(actorId, restart, callback) {
|
|
2387
2593
|
const state = this.#getOrCreate(actorId);
|
|
@@ -2489,7 +2695,7 @@ var RunHandlerCoordinator = class {
|
|
|
2489
2695
|
}
|
|
2490
2696
|
#initializeInspector(actorId, state) {
|
|
2491
2697
|
if (state.inspectorInitialized) return;
|
|
2492
|
-
const inspector =
|
|
2698
|
+
const inspector = _chunkYWWDUC6Dcjs.createRunInspector.call(void 0, this.#run, {
|
|
2493
2699
|
actorId,
|
|
2494
2700
|
control: this.#control(actorId, state)
|
|
2495
2701
|
});
|
|
@@ -2552,6 +2758,17 @@ function optionalWasmNumber(value) {
|
|
|
2552
2758
|
function wasmNumber(value) {
|
|
2553
2759
|
return typeof value === "bigint" ? Number(value) : value;
|
|
2554
2760
|
}
|
|
2761
|
+
function synchronousSqliteUnavailable() {
|
|
2762
|
+
throw new (0, _chunkMGI2VVF6cjs.RivetError)(
|
|
2763
|
+
"sqlite",
|
|
2764
|
+
"sync_unsupported",
|
|
2765
|
+
"Synchronous SQLite is unavailable because the actor runs on the wasm runtime.",
|
|
2766
|
+
{
|
|
2767
|
+
public: true,
|
|
2768
|
+
metadata: { runtime: "wasm" }
|
|
2769
|
+
}
|
|
2770
|
+
);
|
|
2771
|
+
}
|
|
2555
2772
|
function normalizeKvEntry(entry) {
|
|
2556
2773
|
return {
|
|
2557
2774
|
key: toBytes(entry.key),
|
|
@@ -2703,6 +2920,14 @@ var WasmCoreRuntime = (_class2 = class {
|
|
|
2703
2920
|
);
|
|
2704
2921
|
}
|
|
2705
2922
|
createActorFactory(callbacks, config) {
|
|
2923
|
+
if (config == null ? void 0 : config.sqliteDeferredCommits) {
|
|
2924
|
+
throw new (0, _chunkMGI2VVF6cjs.RivetError)(
|
|
2925
|
+
"sqlite",
|
|
2926
|
+
"deferred_commits_unsupported",
|
|
2927
|
+
"SQLite deferred commits require local native SQLite, but the wasm runtime uses remote SQLite.",
|
|
2928
|
+
{ metadata: { runtime: "wasm" } }
|
|
2929
|
+
);
|
|
2930
|
+
}
|
|
2706
2931
|
return callWasmSync(
|
|
2707
2932
|
() => asActorFactoryHandle2(
|
|
2708
2933
|
new this.#constructors.ActorFactory(callbacks, config)
|
|
@@ -2979,12 +3204,18 @@ var WasmCoreRuntime = (_class2 = class {
|
|
|
2979
3204
|
async actorSqlExec(ctx, sql) {
|
|
2980
3205
|
return await callWasm(() => this.#actorSql(ctx).exec(sql));
|
|
2981
3206
|
}
|
|
3207
|
+
actorSqlExecSync(_ctx, _sql) {
|
|
3208
|
+
return synchronousSqliteUnavailable();
|
|
3209
|
+
}
|
|
2982
3210
|
async actorSqlExecute(ctx, sql, params) {
|
|
2983
3211
|
const result = await callWasm(
|
|
2984
3212
|
() => this.#actorSql(ctx).execute(sql, params)
|
|
2985
3213
|
);
|
|
2986
3214
|
return normalizeRuntimeSqlExecuteResult(result);
|
|
2987
3215
|
}
|
|
3216
|
+
actorSqlExecuteSync(_ctx, _sql, _params) {
|
|
3217
|
+
return synchronousSqliteUnavailable();
|
|
3218
|
+
}
|
|
2988
3219
|
async actorSqlExecuteBatch(ctx, statements) {
|
|
2989
3220
|
const results = await callWasm(
|
|
2990
3221
|
() => this.#actorSql(ctx).executeBatch(statements)
|
|
@@ -2996,27 +3227,42 @@ var WasmCoreRuntime = (_class2 = class {
|
|
|
2996
3227
|
() => this.#actorSql(ctx).beginTransaction(timeoutMs, name)
|
|
2997
3228
|
);
|
|
2998
3229
|
}
|
|
3230
|
+
actorSqlBeginTransactionSync(_ctx, _timeoutMs, _name) {
|
|
3231
|
+
return synchronousSqliteUnavailable();
|
|
3232
|
+
}
|
|
2999
3233
|
async actorSqlTransactionExec(transaction, sql) {
|
|
3000
3234
|
return await callWasm(
|
|
3001
3235
|
() => transaction.exec(sql)
|
|
3002
3236
|
);
|
|
3003
3237
|
}
|
|
3238
|
+
actorSqlTransactionExecSync(_transaction, _sql) {
|
|
3239
|
+
return synchronousSqliteUnavailable();
|
|
3240
|
+
}
|
|
3004
3241
|
async actorSqlTransactionExecute(transaction, sql, params) {
|
|
3005
3242
|
const result = await callWasm(
|
|
3006
3243
|
() => transaction.execute(sql, params)
|
|
3007
3244
|
);
|
|
3008
3245
|
return normalizeRuntimeSqlExecuteResult(result);
|
|
3009
3246
|
}
|
|
3247
|
+
actorSqlTransactionExecuteSync(_transaction, _sql, _params) {
|
|
3248
|
+
return synchronousSqliteUnavailable();
|
|
3249
|
+
}
|
|
3010
3250
|
async actorSqlTransactionCommit(transaction) {
|
|
3011
3251
|
await callWasm(
|
|
3012
3252
|
() => transaction.commit()
|
|
3013
3253
|
);
|
|
3014
3254
|
}
|
|
3255
|
+
actorSqlTransactionCommitSync(_transaction) {
|
|
3256
|
+
synchronousSqliteUnavailable();
|
|
3257
|
+
}
|
|
3015
3258
|
async actorSqlTransactionRollback(transaction) {
|
|
3016
3259
|
await callWasm(
|
|
3017
3260
|
() => transaction.rollback()
|
|
3018
3261
|
);
|
|
3019
3262
|
}
|
|
3263
|
+
actorSqlTransactionRollbackSync(_transaction) {
|
|
3264
|
+
synchronousSqliteUnavailable();
|
|
3265
|
+
}
|
|
3020
3266
|
async actorBeginStateTransaction(ctx, timeoutMs) {
|
|
3021
3267
|
return await callWasm(
|
|
3022
3268
|
() => asWasmActorContext(ctx).beginStateTransaction(timeoutMs)
|
|
@@ -3052,6 +3298,17 @@ var WasmCoreRuntime = (_class2 = class {
|
|
|
3052
3298
|
var _a, _b;
|
|
3053
3299
|
return _nullishCoalesce(((_b = (_a = this.#actorSql(ctx)).takeLastKvError) == null ? void 0 : _b.call(_a)), () => ( null));
|
|
3054
3300
|
}
|
|
3301
|
+
async actorSqlOpen(_ctx) {
|
|
3302
|
+
}
|
|
3303
|
+
actorSqlCommitTicket(_ctx) {
|
|
3304
|
+
return synchronousSqliteUnavailable();
|
|
3305
|
+
}
|
|
3306
|
+
actorSqlAbortGeneration(_ctx, _reason) {
|
|
3307
|
+
synchronousSqliteUnavailable();
|
|
3308
|
+
}
|
|
3309
|
+
async actorSqlWhenDurable(_ctx, _ticket) {
|
|
3310
|
+
synchronousSqliteUnavailable();
|
|
3311
|
+
}
|
|
3055
3312
|
async actorSqlClose(ctx) {
|
|
3056
3313
|
const wasmCtx = asWasmActorContext(ctx);
|
|
3057
3314
|
const database = this.#sql.get(wasmCtx);
|
|
@@ -3061,17 +3318,6 @@ var WasmCoreRuntime = (_class2 = class {
|
|
|
3061
3318
|
this.#sql.delete(wasmCtx);
|
|
3062
3319
|
await callWasm(() => database.close());
|
|
3063
3320
|
}
|
|
3064
|
-
async actorRuntimeSocketProvision(_ctx) {
|
|
3065
|
-
throw new (0, _chunkMGI2VVF6cjs.RivetError)(
|
|
3066
|
-
"actor_runtime_socket",
|
|
3067
|
-
"unsupported",
|
|
3068
|
-
"Actor Runtime Socket is only available on Unix native runtimes.",
|
|
3069
|
-
{
|
|
3070
|
-
public: true,
|
|
3071
|
-
metadata: { runtime: "wasm" }
|
|
3072
|
-
}
|
|
3073
|
-
);
|
|
3074
|
-
}
|
|
3075
3321
|
async actorQueueSend(ctx, name, body) {
|
|
3076
3322
|
const queue2 = childHandle(asWasmActorContext(ctx), "queue");
|
|
3077
3323
|
return normalizeQueueMessage(
|
|
@@ -3452,7 +3698,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
|
|
|
3452
3698
|
nativeError = error;
|
|
3453
3699
|
logger2().warn({
|
|
3454
3700
|
msg: "native runtime failed to load; falling back to wasm",
|
|
3455
|
-
error:
|
|
3701
|
+
error: _chunkI26AW6BGcjs.stringifyError.call(void 0, error)
|
|
3456
3702
|
});
|
|
3457
3703
|
}
|
|
3458
3704
|
try {
|
|
@@ -3461,7 +3707,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
|
|
|
3461
3707
|
throw new (0, _chunkMGI2VVF6cjs.RivetError)(
|
|
3462
3708
|
"config",
|
|
3463
3709
|
"runtime_unavailable",
|
|
3464
|
-
`RivetKit could not load a core runtime. Native runtime: ${
|
|
3710
|
+
`RivetKit could not load a core runtime. Native runtime: ${_chunkI26AW6BGcjs.stringifyError.call(void 0, nativeError)} Wasm runtime: ${_chunkI26AW6BGcjs.stringifyError.call(void 0, wasmError)}`,
|
|
3465
3711
|
{
|
|
3466
3712
|
public: true,
|
|
3467
3713
|
statusCode: 500
|
|
@@ -3669,7 +3915,7 @@ async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrai
|
|
|
3669
3915
|
}).catch((error) => {
|
|
3670
3916
|
logger2().warn({
|
|
3671
3917
|
msg: "deferred native sleep cleanup failed",
|
|
3672
|
-
error:
|
|
3918
|
+
error: _chunkI26AW6BGcjs.stringifyError.call(void 0, error)
|
|
3673
3919
|
});
|
|
3674
3920
|
});
|
|
3675
3921
|
return;
|
|
@@ -3708,15 +3954,29 @@ async function closeNativeDatabaseClient(runtime, ctx) {
|
|
|
3708
3954
|
await entry.client.close();
|
|
3709
3955
|
}
|
|
3710
3956
|
}
|
|
3957
|
+
function createNativeSqlTransaction(runtime, transaction) {
|
|
3958
|
+
return {
|
|
3959
|
+
exec: (sql) => runtime.actorSqlTransactionExec(transaction, sql),
|
|
3960
|
+
execSync: (sql) => runtime.actorSqlTransactionExecSync(transaction, sql),
|
|
3961
|
+
execute: (sql, params) => runtime.actorSqlTransactionExecute(transaction, sql, params),
|
|
3962
|
+
executeSync: (sql, params) => runtime.actorSqlTransactionExecuteSync(transaction, sql, params),
|
|
3963
|
+
commit: () => runtime.actorSqlTransactionCommit(transaction),
|
|
3964
|
+
commitSync: () => runtime.actorSqlTransactionCommitSync(transaction),
|
|
3965
|
+
rollback: () => runtime.actorSqlTransactionRollback(transaction),
|
|
3966
|
+
rollbackSync: () => runtime.actorSqlTransactionRollbackSync(transaction)
|
|
3967
|
+
};
|
|
3968
|
+
}
|
|
3711
3969
|
function getOrCreateNativeSqlDatabase(runtime, ctx) {
|
|
3712
3970
|
const runtimeState = getNativeRuntimeState(runtime, ctx);
|
|
3713
3971
|
const cachedDatabase = runtimeState.sql;
|
|
3714
3972
|
if (cachedDatabase) {
|
|
3715
3973
|
return cachedDatabase;
|
|
3716
3974
|
}
|
|
3717
|
-
const
|
|
3975
|
+
const bindings = {
|
|
3718
3976
|
exec: (sql) => runtime.actorSqlExec(ctx, sql),
|
|
3977
|
+
execSync: (sql) => runtime.actorSqlExecSync(ctx, sql),
|
|
3719
3978
|
execute: (sql, params) => runtime.actorSqlExecute(ctx, sql, params),
|
|
3979
|
+
executeSync: (sql, params) => runtime.actorSqlExecuteSync(ctx, sql, params),
|
|
3720
3980
|
executeBatch: (statements) => runtime.actorSqlExecuteBatch(ctx, statements),
|
|
3721
3981
|
beginTransaction: async (timeoutMs, name) => {
|
|
3722
3982
|
const transaction = await runtime.actorSqlBeginTransaction(
|
|
@@ -3724,16 +3984,15 @@ function getOrCreateNativeSqlDatabase(runtime, ctx) {
|
|
|
3724
3984
|
timeoutMs,
|
|
3725
3985
|
name
|
|
3726
3986
|
);
|
|
3727
|
-
return
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
};
|
|
3987
|
+
return createNativeSqlTransaction(runtime, transaction);
|
|
3988
|
+
},
|
|
3989
|
+
beginTransactionSync: (timeoutMs, name) => {
|
|
3990
|
+
const transaction = runtime.actorSqlBeginTransactionSync(
|
|
3991
|
+
ctx,
|
|
3992
|
+
timeoutMs,
|
|
3993
|
+
name
|
|
3994
|
+
);
|
|
3995
|
+
return createNativeSqlTransaction(runtime, transaction);
|
|
3737
3996
|
},
|
|
3738
3997
|
beginStateTransaction: async (timeoutMs, context) => {
|
|
3739
3998
|
const scope = context;
|
|
@@ -3771,8 +4030,13 @@ function getOrCreateNativeSqlDatabase(runtime, ctx) {
|
|
|
3771
4030
|
run: (sql, params) => runtime.actorSqlRun(ctx, sql, params),
|
|
3772
4031
|
metrics: () => runtime.actorSqlMetrics(ctx),
|
|
3773
4032
|
takeLastKvError: () => runtime.actorSqlTakeLastKvError(ctx),
|
|
4033
|
+
open: () => runtime.actorSqlOpen(ctx),
|
|
4034
|
+
commitTicket: () => runtime.actorSqlCommitTicket(ctx),
|
|
4035
|
+
whenDurable: (ticket) => runtime.actorSqlWhenDurable(ctx, ticket),
|
|
4036
|
+
abortGeneration: (reason) => runtime.actorSqlAbortGeneration(ctx, reason),
|
|
3774
4037
|
close: () => runtime.actorSqlClose(ctx)
|
|
3775
|
-
}
|
|
4038
|
+
};
|
|
4039
|
+
const database = wrapJsNativeDatabase(bindings);
|
|
3776
4040
|
runtimeState.sql = database;
|
|
3777
4041
|
return database;
|
|
3778
4042
|
}
|
|
@@ -3841,10 +4105,10 @@ function decodeValue(value) {
|
|
|
3841
4105
|
if (!value || value.length === 0) {
|
|
3842
4106
|
return void 0;
|
|
3843
4107
|
}
|
|
3844
|
-
return
|
|
4108
|
+
return _chunkI26AW6BGcjs.decodeCborCompat.call(void 0, value);
|
|
3845
4109
|
}
|
|
3846
4110
|
function encodeValue(value) {
|
|
3847
|
-
return
|
|
4111
|
+
return _chunkI26AW6BGcjs.encodeCborCompat.call(void 0, value);
|
|
3848
4112
|
}
|
|
3849
4113
|
function normalizeArgs(value) {
|
|
3850
4114
|
return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
|
|
@@ -3880,7 +4144,7 @@ function isStructuredBridgeError(error) {
|
|
|
3880
4144
|
return _chunkMGI2VVF6cjs.isRivetErrorLike.call(void 0, error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
|
|
3881
4145
|
}
|
|
3882
4146
|
function encodeNativeCallbackError(error) {
|
|
3883
|
-
const structuredError = isStructuredBridgeError(error) ? error :
|
|
4147
|
+
const structuredError = isStructuredBridgeError(error) ? error : _chunkI26AW6BGcjs.deconstructError.call(void 0, error, true);
|
|
3884
4148
|
const { encoded, droppedMetadataCause } = _chunkMGI2VVF6cjs.encodeBridgeRivetError.call(void 0, structuredError);
|
|
3885
4149
|
if (droppedMetadataCause !== void 0) {
|
|
3886
4150
|
logger2().warn(
|
|
@@ -3942,7 +4206,7 @@ function decodeWorkflowCbor(data) {
|
|
|
3942
4206
|
return null;
|
|
3943
4207
|
}
|
|
3944
4208
|
try {
|
|
3945
|
-
return
|
|
4209
|
+
return _chunkI26AW6BGcjs.decodeCborCompat.call(void 0, new Uint8Array(data));
|
|
3946
4210
|
} catch (e3) {
|
|
3947
4211
|
return null;
|
|
3948
4212
|
}
|
|
@@ -4055,7 +4319,7 @@ function serializeWorkflowHistoryForJson(data) {
|
|
|
4055
4319
|
if (data === null) {
|
|
4056
4320
|
return null;
|
|
4057
4321
|
}
|
|
4058
|
-
const history =
|
|
4322
|
+
const history = _chunkTKCX6KNZcjs.decodeWorkflowHistoryTransport.call(void 0, data);
|
|
4059
4323
|
return jsonSafe({
|
|
4060
4324
|
nameRegistry: [...history.nameRegistry],
|
|
4061
4325
|
entries: history.entries.map((entry) => ({
|
|
@@ -4154,7 +4418,7 @@ var NativeConnAdapter = class {
|
|
|
4154
4418
|
this.#ctx = ctx;
|
|
4155
4419
|
this.#queueHibernationRemoval = queueHibernationRemoval;
|
|
4156
4420
|
this.#assertCanMutateState = assertCanMutateState;
|
|
4157
|
-
this[
|
|
4421
|
+
this[_chunkYWWDUC6Dcjs.CONN_STATE_MANAGER_SYMBOL] = {
|
|
4158
4422
|
stateEnabled: true,
|
|
4159
4423
|
get state() {
|
|
4160
4424
|
return thisConn.state;
|
|
@@ -4171,7 +4435,7 @@ var NativeConnAdapter = class {
|
|
|
4171
4435
|
decodeValue(this.#runtime.connParams(this.#conn))
|
|
4172
4436
|
);
|
|
4173
4437
|
}
|
|
4174
|
-
[
|
|
4438
|
+
[_chunkYWWDUC6Dcjs.RAW_STATE_SYMBOL]() {
|
|
4175
4439
|
return this.#readState();
|
|
4176
4440
|
}
|
|
4177
4441
|
get state() {
|
|
@@ -4201,7 +4465,7 @@ var NativeConnAdapter = class {
|
|
|
4201
4465
|
},
|
|
4202
4466
|
(newValue) => {
|
|
4203
4467
|
assertCurrentState();
|
|
4204
|
-
|
|
4468
|
+
_chunkI26AW6BGcjs.assertJsonCompatValue.call(void 0, newValue);
|
|
4205
4469
|
}
|
|
4206
4470
|
);
|
|
4207
4471
|
}
|
|
@@ -4209,7 +4473,7 @@ var NativeConnAdapter = class {
|
|
|
4209
4473
|
var _a;
|
|
4210
4474
|
(_a = this.#assertCanMutateState) == null ? void 0 : _a.call(this);
|
|
4211
4475
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
4212
|
-
|
|
4476
|
+
_chunkI26AW6BGcjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
4213
4477
|
this.#writeState(nextValue, { writeNative: true });
|
|
4214
4478
|
}
|
|
4215
4479
|
initializeState(value) {
|
|
@@ -5228,7 +5492,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5228
5492
|
this.#databaseProvider = databaseProvider;
|
|
5229
5493
|
}
|
|
5230
5494
|
this.#request = request;
|
|
5231
|
-
this[
|
|
5495
|
+
this[_chunkYWWDUC6Dcjs.ACTOR_CONTEXT_INTERNAL_SYMBOL] = new NativeWorkflowRuntimeAdapter(
|
|
5232
5496
|
this,
|
|
5233
5497
|
() => this.#logByInvocationScope.delete(
|
|
5234
5498
|
_nullishCoalesce(this.#runtime.currentInvocationScope(), () => ( NO_INVOCATION_SCOPE))
|
|
@@ -5241,11 +5505,6 @@ var ActorContextHandleAdapter = class {
|
|
|
5241
5505
|
}
|
|
5242
5506
|
return this.#kv;
|
|
5243
5507
|
}
|
|
5244
|
-
async actorRuntimeSocket() {
|
|
5245
|
-
return await callNative(
|
|
5246
|
-
() => this.#runtime.actorRuntimeSocketProvision(this.#ctx)
|
|
5247
|
-
);
|
|
5248
|
-
}
|
|
5249
5508
|
get db() {
|
|
5250
5509
|
if (!this.#databaseProvider) {
|
|
5251
5510
|
throw databaseNotConfiguredError();
|
|
@@ -5261,7 +5520,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5261
5520
|
}
|
|
5262
5521
|
throw databaseClientNotReadyError();
|
|
5263
5522
|
}
|
|
5264
|
-
[
|
|
5523
|
+
[_chunkYWWDUC6Dcjs.RAW_STATE_SYMBOL]() {
|
|
5265
5524
|
if (!this.#stateEnabled) {
|
|
5266
5525
|
throw stateNotEnabledError();
|
|
5267
5526
|
}
|
|
@@ -5288,7 +5547,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5288
5547
|
},
|
|
5289
5548
|
(newValue) => {
|
|
5290
5549
|
assertCurrentState();
|
|
5291
|
-
|
|
5550
|
+
_chunkI26AW6BGcjs.assertJsonCompatValue.call(void 0, newValue);
|
|
5292
5551
|
}
|
|
5293
5552
|
);
|
|
5294
5553
|
}
|
|
@@ -5300,7 +5559,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5300
5559
|
}
|
|
5301
5560
|
this.#assertCanMutateState();
|
|
5302
5561
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
5303
|
-
|
|
5562
|
+
_chunkI26AW6BGcjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
5304
5563
|
this.#writeState(nextValue, { scheduleSave: true });
|
|
5305
5564
|
}
|
|
5306
5565
|
initializeState(value) {
|
|
@@ -5514,14 +5773,16 @@ var ActorContextHandleAdapter = class {
|
|
|
5514
5773
|
log: {
|
|
5515
5774
|
debug: (obj) => logger2().debug(obj)
|
|
5516
5775
|
},
|
|
5517
|
-
nativeDatabaseProvider:
|
|
5776
|
+
nativeDatabaseProvider: _chunkLYXPQB6Hcjs.registerNativeStateTransactionOpener.call(void 0,
|
|
5518
5777
|
{
|
|
5519
5778
|
open: async (requestedActorId) => {
|
|
5520
5779
|
void requestedActorId;
|
|
5521
|
-
|
|
5780
|
+
const database = getOrCreateNativeSqlDatabase(
|
|
5522
5781
|
this.#runtime,
|
|
5523
5782
|
this.#ctx
|
|
5524
5783
|
);
|
|
5784
|
+
await database.open();
|
|
5785
|
+
return database;
|
|
5525
5786
|
}
|
|
5526
5787
|
},
|
|
5527
5788
|
async (timeoutMs, context) => await getOrCreateNativeSqlDatabase(
|
|
@@ -5537,7 +5798,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5537
5798
|
return this.#db;
|
|
5538
5799
|
}
|
|
5539
5800
|
#bindDatabaseClient(client) {
|
|
5540
|
-
return
|
|
5801
|
+
return _chunkLYXPQB6Hcjs.bindNativeStateTransactionContext.call(void 0, client, {
|
|
5541
5802
|
enter: async () => await this.#enterStateTransaction(),
|
|
5542
5803
|
exit: (scope) => this.#exitStateTransaction(
|
|
5543
5804
|
scope
|
|
@@ -5741,7 +6002,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5741
6002
|
const trackedPromise = Promise.resolve(promise).catch((error) => {
|
|
5742
6003
|
logger2().warn({
|
|
5743
6004
|
msg: "keepAwake promise rejected",
|
|
5744
|
-
error:
|
|
6005
|
+
error: _chunkI26AW6BGcjs.stringifyError.call(void 0, error)
|
|
5745
6006
|
});
|
|
5746
6007
|
}).then(() => null);
|
|
5747
6008
|
try {
|
|
@@ -5802,16 +6063,16 @@ var ActorContextHandleAdapter = class {
|
|
|
5802
6063
|
// need to keep an actor awake should use `keepAwake(promise)` or
|
|
5803
6064
|
// `waitUntil(promise)` so the native counter machinery in rivetkit-core
|
|
5804
6065
|
// owns the lifecycle.
|
|
5805
|
-
/** @deprecated Use `keepAwake(promise)` or `waitUntil(promise)
|
|
6066
|
+
/** @deprecated `setPreventSleep` was deprecated in 3.0 and will be removed in a future version. It is a no-op. Use `c.keepAwake(promise)` or `c.waitUntil(promise)`. See https://rivet.dev/actors/docs/deprecated/prevent-sleep */
|
|
5806
6067
|
setPreventSleep(_preventSleep) {
|
|
5807
6068
|
logger2().warn({
|
|
5808
|
-
msg: "setPreventSleep
|
|
6069
|
+
msg: "setPreventSleep was deprecated in 3.0 and will be removed in a future version. It is a no-op; use keepAwake(promise) or waitUntil(promise) instead. See https://rivet.dev/actors/docs/deprecated/prevent-sleep"
|
|
5809
6070
|
});
|
|
5810
6071
|
}
|
|
5811
|
-
/** @deprecated Use `keepAwake(promise)` or `waitUntil(promise)
|
|
6072
|
+
/** @deprecated `preventSleep` was deprecated in 3.0 and will be removed in a future version. It is a no-op that always returns `false`. Use `c.keepAwake(promise)` or `c.waitUntil(promise)`. See https://rivet.dev/actors/docs/deprecated/prevent-sleep */
|
|
5812
6073
|
get preventSleep() {
|
|
5813
6074
|
logger2().warn({
|
|
5814
|
-
msg: "preventSleep
|
|
6075
|
+
msg: "preventSleep was deprecated in 3.0 and will be removed in a future version. It always returns false; use keepAwake(promise) or waitUntil(promise) instead. See https://rivet.dev/actors/docs/deprecated/prevent-sleep"
|
|
5815
6076
|
});
|
|
5816
6077
|
return false;
|
|
5817
6078
|
}
|
|
@@ -6121,27 +6382,29 @@ function buildActorTracingConfig(actions, tracing) {
|
|
|
6121
6382
|
if (tracing === void 0) return void 0;
|
|
6122
6383
|
return {
|
|
6123
6384
|
sampler: tracing.sampler,
|
|
6124
|
-
actions:
|
|
6385
|
+
actions: _chunkYWWDUC6Dcjs.flattenActionTraceSamplers.call(void 0, actions, tracing.actions)
|
|
6125
6386
|
};
|
|
6126
6387
|
}
|
|
6388
|
+
var SQLITE_DEFERRED_COMMITS = /* @__PURE__ */ Symbol.for("rivetkit.sqlite.deferredCommits");
|
|
6127
6389
|
function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
6128
|
-
var _a;
|
|
6390
|
+
var _a, _b;
|
|
6129
6391
|
const config = definition.config;
|
|
6130
6392
|
const options = _nullishCoalesce(config.options, () => ( {}));
|
|
6131
6393
|
const canHibernate = options.canHibernateWebSocket;
|
|
6132
6394
|
const usesRemoteSqlite = sqliteBackendForConfig(registryConfig) === "remote";
|
|
6133
6395
|
const sqliteProfiling = (_a = config.db) == null ? void 0 : _a.sqliteProfiling;
|
|
6396
|
+
const sqliteDeferredCommits = ((_b = config.db) == null ? void 0 : _b[SQLITE_DEFERRED_COMMITS]) === true;
|
|
6134
6397
|
return {
|
|
6135
6398
|
name: options.name,
|
|
6136
6399
|
icon: options.icon,
|
|
6137
6400
|
hasDatabase: true,
|
|
6138
6401
|
remoteSqlite: usesRemoteSqlite,
|
|
6402
|
+
sqliteDeferredCommits: sqliteDeferredCommits || void 0,
|
|
6139
6403
|
sqliteProfiling,
|
|
6140
6404
|
tracing: buildActorTracingConfig(
|
|
6141
6405
|
definition.config.actions,
|
|
6142
6406
|
definition.config.tracing
|
|
6143
6407
|
),
|
|
6144
|
-
enableActorRuntimeSocket: options.enableActorRuntimeSocket === true,
|
|
6145
6408
|
hasState: config.state !== void 0 || typeof config.createState === "function",
|
|
6146
6409
|
canHibernateWebsocket: typeof canHibernate === "boolean" ? canHibernate : void 0,
|
|
6147
6410
|
stateSaveIntervalMs: options.stateSaveInterval,
|
|
@@ -6163,7 +6426,7 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
|
6163
6426
|
maxOutgoingMessageSize: registryConfig.maxOutgoingMessageSize,
|
|
6164
6427
|
preloadMaxWorkflowBytes: options.preloadMaxWorkflowBytes,
|
|
6165
6428
|
preloadMaxConnectionsBytes: options.preloadMaxConnectionsBytes,
|
|
6166
|
-
actions: Object.keys(
|
|
6429
|
+
actions: Object.keys(_chunkYWWDUC6Dcjs.flattenActionHandlers.call(void 0, config.actions)).sort().map((name) => ({ name })),
|
|
6167
6430
|
inspectorTabs: buildInspectorTabs(config.inspector, runtimeKind)
|
|
6168
6431
|
};
|
|
6169
6432
|
}
|
|
@@ -6239,10 +6502,10 @@ function validateInspectorTabSource(tabId, resolved) {
|
|
|
6239
6502
|
function buildNativeFactory(runtime, registryConfig, definition) {
|
|
6240
6503
|
var _a;
|
|
6241
6504
|
const config = definition.config;
|
|
6242
|
-
const databaseProvider = _nullishCoalesce(config.db, () => (
|
|
6243
|
-
const actionHandlers =
|
|
6505
|
+
const databaseProvider = _nullishCoalesce(config.db, () => ( _chunkLYXPQB6Hcjs.db.call(void 0, )));
|
|
6506
|
+
const actionHandlers = _chunkYWWDUC6Dcjs.flattenActionHandlers.call(void 0, config.actions);
|
|
6244
6507
|
const schemaConfig = {
|
|
6245
|
-
actionInputSchemas:
|
|
6508
|
+
actionInputSchemas: _chunkYWWDUC6Dcjs.flattenActionInputSchemas.call(void 0,
|
|
6246
6509
|
config.actions,
|
|
6247
6510
|
config.actionInputSchemas
|
|
6248
6511
|
),
|
|
@@ -6250,9 +6513,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6250
6513
|
events: config.events,
|
|
6251
6514
|
queues: config.queues
|
|
6252
6515
|
};
|
|
6253
|
-
const createClient = (ctx) =>
|
|
6254
|
-
new (0,
|
|
6255
|
-
|
|
6516
|
+
const createClient = (ctx) => _chunkSJJWJU26cjs.createClientWithDriver.call(void 0,
|
|
6517
|
+
new (0, _chunkSJJWJU26cjs.RemoteEngineControlClient)(
|
|
6518
|
+
_chunkSJJWJU26cjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
|
|
6256
6519
|
),
|
|
6257
6520
|
{
|
|
6258
6521
|
encoding: "bare",
|
|
@@ -6264,13 +6527,13 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6264
6527
|
)
|
|
6265
6528
|
}
|
|
6266
6529
|
);
|
|
6267
|
-
const run =
|
|
6268
|
-
const runHandlerCoordinator =
|
|
6530
|
+
const run = _chunkYWWDUC6Dcjs.getRunFunction.call(void 0, config.run);
|
|
6531
|
+
const runHandlerCoordinator = _chunkYWWDUC6Dcjs.getRunInspectorKind.call(void 0, config.run) === "workflow" ? new RunHandlerCoordinator(config.run) : void 0;
|
|
6269
6532
|
const getNativeWorkflowInspector = (ctx) => {
|
|
6270
6533
|
var _a2, _b;
|
|
6271
6534
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
6272
6535
|
const restart = () => callNativeSync(() => runtime.actorRestartRunHandler(ctx));
|
|
6273
|
-
return _nullishCoalesce(((_a2 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(actorId, restart)) == null ? void 0 : _a2.workflow), () => ( ((_b =
|
|
6536
|
+
return _nullishCoalesce(((_a2 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(actorId, restart)) == null ? void 0 : _a2.workflow), () => ( ((_b = _chunkYWWDUC6Dcjs.getRunInspectorConfig.call(void 0, config.run, actorId)) == null ? void 0 : _b.workflow)));
|
|
6274
6537
|
};
|
|
6275
6538
|
const onStateChange = typeof config.onStateChange === "function" ? (actorCtx, nextState) => {
|
|
6276
6539
|
config.onStateChange(actorCtx, nextState);
|
|
@@ -6444,7 +6707,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6444
6707
|
400
|
|
6445
6708
|
);
|
|
6446
6709
|
}
|
|
6447
|
-
const cbor =
|
|
6710
|
+
const cbor = _chunkI26AW6BGcjs.encodeCborCompat.call(void 0,
|
|
6448
6711
|
_nullishCoalesce(body.body, () => ( null))
|
|
6449
6712
|
);
|
|
6450
6713
|
const message = await runtime.actorQueueSend(ctx, name, cbor);
|
|
@@ -6812,7 +7075,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6812
7075
|
);
|
|
6813
7076
|
} finally {
|
|
6814
7077
|
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
|
|
6815
|
-
|
|
7078
|
+
_chunkYWWDUC6Dcjs.disposeRunInspector.call(void 0, config.run, actorId);
|
|
6816
7079
|
await actorCtx.dispose();
|
|
6817
7080
|
}
|
|
6818
7081
|
}
|
|
@@ -6824,7 +7087,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6824
7087
|
const actorCtx = makeActorCtx(ctx);
|
|
6825
7088
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
6826
7089
|
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
|
|
6827
|
-
|
|
7090
|
+
_chunkYWWDUC6Dcjs.disposeRunInspector.call(void 0, config.run, actorId);
|
|
6828
7091
|
try {
|
|
6829
7092
|
if (typeof config.onDestroy === "function") {
|
|
6830
7093
|
await config.onDestroy(actorCtx);
|
|
@@ -7041,7 +7304,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7041
7304
|
...request,
|
|
7042
7305
|
abortController: requestAbortController
|
|
7043
7306
|
});
|
|
7044
|
-
const rawConnParams = handlerRequest.headers.get(
|
|
7307
|
+
const rawConnParams = handlerRequest.headers.get(_chunkSJJWJU26cjs.HEADER_CONN_PARAMS);
|
|
7045
7308
|
let requestCtx;
|
|
7046
7309
|
let conn;
|
|
7047
7310
|
let removeRequestAbortListener;
|
|
@@ -7098,7 +7361,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7098
7361
|
requestCtx,
|
|
7099
7362
|
handlerRequest
|
|
7100
7363
|
);
|
|
7101
|
-
if (!
|
|
7364
|
+
if (!_chunkSJJWJU26cjs.isResponseLike.call(void 0, response)) {
|
|
7102
7365
|
throw new Error(
|
|
7103
7366
|
"onRequest handler must return a Response"
|
|
7104
7367
|
);
|
|
@@ -7188,15 +7451,15 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7188
7451
|
}
|
|
7189
7452
|
);
|
|
7190
7453
|
})(),
|
|
7191
|
-
getWorkflowHistory:
|
|
7454
|
+
getWorkflowHistory: _chunkYWWDUC6Dcjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
|
|
7192
7455
|
async (error, payload) => {
|
|
7193
7456
|
var _a2;
|
|
7194
7457
|
const { ctx } = unwrapTsfnPayload(error, payload);
|
|
7195
7458
|
const history = (_a2 = getNativeWorkflowInspector(ctx)) == null ? void 0 : _a2.getHistory();
|
|
7196
|
-
return history == null ? void 0 :
|
|
7459
|
+
return history == null ? void 0 : _chunkI26AW6BGcjs.toUint8Array.call(void 0, history);
|
|
7197
7460
|
}
|
|
7198
7461
|
) : void 0,
|
|
7199
|
-
replayWorkflow:
|
|
7462
|
+
replayWorkflow: _chunkYWWDUC6Dcjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
|
|
7200
7463
|
async (error, payload) => {
|
|
7201
7464
|
const { ctx, entryId } = unwrapTsfnPayload(
|
|
7202
7465
|
error,
|
|
@@ -7207,7 +7470,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7207
7470
|
return void 0;
|
|
7208
7471
|
}
|
|
7209
7472
|
const history = await _asyncNullishCoalesce(await workflowInspector.replayFromStep(entryId), async () => ( null));
|
|
7210
|
-
return history == null ? void 0 :
|
|
7473
|
+
return history == null ? void 0 : _chunkI26AW6BGcjs.toUint8Array.call(void 0, history);
|
|
7211
7474
|
}
|
|
7212
7475
|
) : void 0,
|
|
7213
7476
|
actions: Object.fromEntries(
|
|
@@ -7349,7 +7612,7 @@ async function buildServeConfig(config, resolveNativeBinaries = true) {
|
|
|
7349
7612
|
startServices: resolveNativeBinaries && config.startServices,
|
|
7350
7613
|
handleInspectorHttpInRuntime: true,
|
|
7351
7614
|
serverlessBasePath: config.serverless.basePath,
|
|
7352
|
-
serverlessPackageVersion:
|
|
7615
|
+
serverlessPackageVersion: _chunkI26AW6BGcjs.VERSION,
|
|
7353
7616
|
serverlessClientEndpoint: config.publicEndpoint,
|
|
7354
7617
|
serverlessClientNamespace: config.publicNamespace,
|
|
7355
7618
|
serverlessClientToken: config.publicToken,
|
|
@@ -7363,12 +7626,12 @@ async function buildServeConfig(config, resolveNativeBinaries = true) {
|
|
|
7363
7626
|
} catch (error) {
|
|
7364
7627
|
logger2().warn({
|
|
7365
7628
|
msg: "could not resolve a local engine binary; if a local engine must be spawned it will fail with engine.binary_unavailable \u2014 set RIVET_ENGINE_BINARY_PATH or install the @rivetkit/engine-cli platform package",
|
|
7366
|
-
error:
|
|
7629
|
+
error: _chunkI26AW6BGcjs.stringifyError.call(void 0, error)
|
|
7367
7630
|
});
|
|
7368
7631
|
}
|
|
7369
7632
|
}
|
|
7370
7633
|
if (resolveNativeBinaries && config.startServices) {
|
|
7371
|
-
const servicesBinary =
|
|
7634
|
+
const servicesBinary = _chunkI26AW6BGcjs.getEnvUniversal.call(void 0, "RIVET_SERVICES_BINARY");
|
|
7372
7635
|
if (servicesBinary) {
|
|
7373
7636
|
serveConfig.servicesBinaryPath = servicesBinary;
|
|
7374
7637
|
} else {
|
|
@@ -7383,13 +7646,13 @@ async function buildServeConfig(config, resolveNativeBinaries = true) {
|
|
|
7383
7646
|
serveConfig.engineHost = config.engineHost;
|
|
7384
7647
|
serveConfig.enginePort = config.enginePort;
|
|
7385
7648
|
if ((_a = config.test) == null ? void 0 : _a.enabled) {
|
|
7386
|
-
serveConfig.inspectorTestToken = _nullishCoalesce(
|
|
7649
|
+
serveConfig.inspectorTestToken = _nullishCoalesce(_chunkI26AW6BGcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
|
|
7387
7650
|
}
|
|
7388
7651
|
return serveConfig;
|
|
7389
7652
|
}
|
|
7390
7653
|
async function buildRegistryWithRuntime(config, runtime) {
|
|
7391
7654
|
var _a;
|
|
7392
|
-
if (((_a = config.test) == null ? void 0 : _a.enabled) &&
|
|
7655
|
+
if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunkI26AW6BGcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
|
|
7393
7656
|
trySetProcessEnv("_RIVET_TEST_INSPECTOR_TOKEN", "token");
|
|
7394
7657
|
}
|
|
7395
7658
|
if (runtime.kind === "napi") {
|
|
@@ -7421,6 +7684,7 @@ async function buildConfiguredRegistry(config) {
|
|
|
7421
7684
|
var REGISTRY_READY_TIMEOUT_MS = 3e4;
|
|
7422
7685
|
var LOCAL_ENGINE_READY_TIMEOUT_MS = 6e4;
|
|
7423
7686
|
var LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS = 4e3;
|
|
7687
|
+
var DEFAULT_ACTOR_STOP_THRESHOLD_MS = 3e4;
|
|
7424
7688
|
function rejectServerless() {
|
|
7425
7689
|
throw new Error("serverless is disabled in this version");
|
|
7426
7690
|
}
|
|
@@ -7461,7 +7725,7 @@ function createApplicationFetch(application, runtime) {
|
|
|
7461
7725
|
signal: abortController.signal
|
|
7462
7726
|
})
|
|
7463
7727
|
);
|
|
7464
|
-
if (!
|
|
7728
|
+
if (!_chunkSJJWJU26cjs.isResponseLike.call(void 0, response)) {
|
|
7465
7729
|
throw new TypeError(
|
|
7466
7730
|
"registry.listen() application fetch must return a Response"
|
|
7467
7731
|
);
|
|
@@ -7507,11 +7771,16 @@ var Registry = class {
|
|
|
7507
7771
|
#shutdownInstalled = false;
|
|
7508
7772
|
#shutdownInFlight = null;
|
|
7509
7773
|
#signalHandlers = {};
|
|
7774
|
+
#envoyConfiguredRegistry;
|
|
7775
|
+
#activeActorCountListeners = /* @__PURE__ */ new Set();
|
|
7776
|
+
#activeActorCountToken;
|
|
7777
|
+
#lastActiveActorCount;
|
|
7778
|
+
#activeActorCountSupported;
|
|
7510
7779
|
constructor(config, deps) {
|
|
7511
7780
|
var _a;
|
|
7512
7781
|
this.#config = config;
|
|
7513
7782
|
if ((_a = config.logging) == null ? void 0 : _a.baseLogger) {
|
|
7514
|
-
|
|
7783
|
+
_chunkI26AW6BGcjs.configureBaseLogger.call(void 0, config.logging.baseLogger);
|
|
7515
7784
|
}
|
|
7516
7785
|
this.#buildConfiguredRegistry = _nullishCoalesce((deps == null ? void 0 : deps.buildConfiguredRegistry), () => ( buildConfiguredRegistry));
|
|
7517
7786
|
this.routes = {
|
|
@@ -7743,10 +8012,10 @@ var Registry = class {
|
|
|
7743
8012
|
if (!opts.application) {
|
|
7744
8013
|
rejectServerless();
|
|
7745
8014
|
}
|
|
7746
|
-
const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => (
|
|
7747
|
-
const publicDir = _nullishCoalesce(opts.publicDir, () => (
|
|
8015
|
+
const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => ( _chunkI26AW6BGcjs.parsePortEnv.call(void 0, process.env.RIVET_PORT))), () => ( 3e3));
|
|
8016
|
+
const publicDir = _nullishCoalesce(opts.publicDir, () => ( _chunkI26AW6BGcjs.getRivetkitPublicDir.call(void 0, )));
|
|
7748
8017
|
const config = this.parseConfig();
|
|
7749
|
-
if (opts.application &&
|
|
8018
|
+
if (opts.application && _chunkI26AW6BGcjs.getRivetkitRuntimeMode.call(void 0, ) !== "serverless") {
|
|
7750
8019
|
if (config.runtime === "wasm") {
|
|
7751
8020
|
throw new Error(
|
|
7752
8021
|
"registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
|
|
@@ -7822,7 +8091,7 @@ var Registry = class {
|
|
|
7822
8091
|
return jsonRouteResponse(503, {
|
|
7823
8092
|
status: "not_started",
|
|
7824
8093
|
runtime: "rivetkit",
|
|
7825
|
-
version:
|
|
8094
|
+
version: _chunkI26AW6BGcjs.VERSION
|
|
7826
8095
|
});
|
|
7827
8096
|
}
|
|
7828
8097
|
const { runtime, registry } = configured;
|
|
@@ -7830,7 +8099,7 @@ var Registry = class {
|
|
|
7830
8099
|
return jsonRouteResponse(501, {
|
|
7831
8100
|
status: "unsupported",
|
|
7832
8101
|
runtime: "rivetkit",
|
|
7833
|
-
version:
|
|
8102
|
+
version: _chunkI26AW6BGcjs.VERSION
|
|
7834
8103
|
});
|
|
7835
8104
|
}
|
|
7836
8105
|
const response = await runtime.registryHealth(registry);
|
|
@@ -7905,14 +8174,14 @@ var Registry = class {
|
|
|
7905
8174
|
var _a;
|
|
7906
8175
|
if (!this.#runtimeServePromise) {
|
|
7907
8176
|
const configuredEnvoyVersion = (_a = this.#config.node) == null ? void 0 : _a.version;
|
|
7908
|
-
const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" :
|
|
8177
|
+
const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" : _chunkI26AW6BGcjs.getRivetEnvoyVersion.call(void 0, ) !== void 0 ? "environment" : "default";
|
|
7909
8178
|
logger2().info({
|
|
7910
8179
|
msg: "starting rivetkit envoy",
|
|
7911
|
-
rivetkitVersion:
|
|
8180
|
+
rivetkitVersion: _chunkI26AW6BGcjs.VERSION,
|
|
7912
8181
|
envoyVersion: config.node.version,
|
|
7913
8182
|
envoyVersionSource
|
|
7914
8183
|
});
|
|
7915
|
-
if (envoyVersionSource === "default" &&
|
|
8184
|
+
if (envoyVersionSource === "default" && _chunkI26AW6BGcjs.getNodeEnv.call(void 0, ) === "production") {
|
|
7916
8185
|
logger2().error({
|
|
7917
8186
|
msg: "node version defaulted because neither config.node.version nor RIVET_NODE_VERSION is set; actors will not drain automatically across deploys. See https://rivet.dev/docs/actors/versions",
|
|
7918
8187
|
envoyVersion: config.node.version,
|
|
@@ -7921,6 +8190,21 @@ var Registry = class {
|
|
|
7921
8190
|
}
|
|
7922
8191
|
const configuredRegistryPromise = this.#buildConfiguredRegistry(config);
|
|
7923
8192
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
8193
|
+
configuredRegistryPromise.then(
|
|
8194
|
+
(configured) => {
|
|
8195
|
+
this.#envoyConfiguredRegistry = configured;
|
|
8196
|
+
try {
|
|
8197
|
+
this.#syncActiveActorCountSubscription();
|
|
8198
|
+
} catch (error) {
|
|
8199
|
+
logger2().error(
|
|
8200
|
+
{ error },
|
|
8201
|
+
"failed to subscribe to the active actor count"
|
|
8202
|
+
);
|
|
8203
|
+
}
|
|
8204
|
+
},
|
|
8205
|
+
// The serve lifecycle below reports build failures.
|
|
8206
|
+
() => void 0
|
|
8207
|
+
);
|
|
7924
8208
|
this.#runtimeServeLifecyclePromise = configuredRegistryPromise.then(
|
|
7925
8209
|
async ({ runtime, registry, serveConfig }) => {
|
|
7926
8210
|
await runtime.serveRegistry(registry, serveConfig);
|
|
@@ -8001,12 +8285,12 @@ var Registry = class {
|
|
|
8001
8285
|
const modeAPromise = this.#runtimeServeConfiguredPromise;
|
|
8002
8286
|
const modeBPromise = this.#runtimeServerlessPromise;
|
|
8003
8287
|
const runtimes = /* @__PURE__ */ new Set();
|
|
8004
|
-
const localDevSignal = signalDriven &&
|
|
8288
|
+
const localDevSignal = signalDriven && _chunkI26AW6BGcjs.getNodeEnv.call(void 0, ) !== "production" && config.engineSpawn && config.endpoint !== void 0 && _chunkSJJWJU26cjs.isLocalEngineEndpoint.call(void 0, config.endpoint);
|
|
8005
8289
|
let gracePeriodMs = (_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs;
|
|
8006
8290
|
if (gracePeriodMs === void 0) {
|
|
8007
8291
|
gracePeriodMs = localDevSignal ? LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS : await _asyncNullishCoalesce(await this.#actorStopThresholdMs(
|
|
8008
8292
|
_nullishCoalesce(modeAPromise, () => ( modeBPromise))
|
|
8009
|
-
), async () => (
|
|
8293
|
+
), async () => ( DEFAULT_ACTOR_STOP_THRESHOLD_MS));
|
|
8010
8294
|
}
|
|
8011
8295
|
const drain = async () => {
|
|
8012
8296
|
const registries = [];
|
|
@@ -8113,7 +8397,7 @@ var Registry = class {
|
|
|
8113
8397
|
}
|
|
8114
8398
|
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
8115
8399
|
try {
|
|
8116
|
-
if (
|
|
8400
|
+
if (_chunkI26AW6BGcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
8117
8401
|
return Promise.reject(
|
|
8118
8402
|
new Error(
|
|
8119
8403
|
"registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
|
|
@@ -8137,7 +8421,7 @@ var Registry = class {
|
|
|
8137
8421
|
if (!configuredRegistryPromise || !serveLifecyclePromise) {
|
|
8138
8422
|
throw new Error("registry envoy startup did not initialize");
|
|
8139
8423
|
}
|
|
8140
|
-
const readyTimeoutMs = config.engineSpawn && config.endpoint !== void 0 &&
|
|
8424
|
+
const readyTimeoutMs = config.engineSpawn && config.endpoint !== void 0 && _chunkSJJWJU26cjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? LOCAL_ENGINE_READY_TIMEOUT_MS : REGISTRY_READY_TIMEOUT_MS;
|
|
8141
8425
|
let timeout;
|
|
8142
8426
|
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
8143
8427
|
var _a;
|
|
@@ -8187,8 +8471,8 @@ var Registry = class {
|
|
|
8187
8471
|
* ```
|
|
8188
8472
|
*/
|
|
8189
8473
|
start() {
|
|
8190
|
-
if (
|
|
8191
|
-
const publicDir = _nullishCoalesce(
|
|
8474
|
+
if (_chunkI26AW6BGcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
8475
|
+
const publicDir = _nullishCoalesce(_chunkI26AW6BGcjs.getRivetkitPublicDir.call(void 0, ), () => ( "/public"));
|
|
8192
8476
|
this.listen({ publicDir }).catch((error) => {
|
|
8193
8477
|
logger2().error({ error }, "auto-listen failed; exiting");
|
|
8194
8478
|
if (typeof process !== "undefined" && typeof process.exit === "function") {
|
|
@@ -8200,6 +8484,101 @@ var Registry = class {
|
|
|
8200
8484
|
const config = this.parseConfig();
|
|
8201
8485
|
this.#startEnvoy(config, true);
|
|
8202
8486
|
}
|
|
8487
|
+
/**
|
|
8488
|
+
* Returns the number of actors hosted by this process's envoy, which is zero
|
|
8489
|
+
* while it is not serving. Requires the native runtime.
|
|
8490
|
+
*/
|
|
8491
|
+
activeActorCount() {
|
|
8492
|
+
this.#assertActiveActorCountSupported("activeActorCount");
|
|
8493
|
+
const configured = this.#envoyConfiguredRegistry;
|
|
8494
|
+
if (!configured) return 0;
|
|
8495
|
+
const { runtime, registry } = configured;
|
|
8496
|
+
if (!runtime.registryActiveActorCount) {
|
|
8497
|
+
throw new Error(
|
|
8498
|
+
"registry.activeActorCount() is not supported by this runtime"
|
|
8499
|
+
);
|
|
8500
|
+
}
|
|
8501
|
+
return runtime.registryActiveActorCount(registry);
|
|
8502
|
+
}
|
|
8503
|
+
/**
|
|
8504
|
+
* Calls `callback` with the number of actors hosted by this process's envoy
|
|
8505
|
+
* and again whenever it changes. Rapid changes may coalesce.
|
|
8506
|
+
* Returns a function that unsubscribes. Requires the native runtime.
|
|
8507
|
+
*
|
|
8508
|
+
* @example
|
|
8509
|
+
* ```ts
|
|
8510
|
+
* const unsubscribe = registry.onActiveActorCountChange((count) => {
|
|
8511
|
+
* setTaskProtection(count > 0);
|
|
8512
|
+
* });
|
|
8513
|
+
* ```
|
|
8514
|
+
*/
|
|
8515
|
+
onActiveActorCountChange(callback) {
|
|
8516
|
+
this.#assertActiveActorCountSupported("onActiveActorCountChange");
|
|
8517
|
+
const listener = (count) => callback(count);
|
|
8518
|
+
this.#activeActorCountListeners.add(listener);
|
|
8519
|
+
this.#syncActiveActorCountSubscription();
|
|
8520
|
+
const lastCount = this.#lastActiveActorCount;
|
|
8521
|
+
if (lastCount !== void 0) {
|
|
8522
|
+
queueMicrotask(() => {
|
|
8523
|
+
if (this.#activeActorCountListeners.has(listener)) {
|
|
8524
|
+
this.#deliverActiveActorCount(listener, lastCount);
|
|
8525
|
+
}
|
|
8526
|
+
});
|
|
8527
|
+
}
|
|
8528
|
+
return () => {
|
|
8529
|
+
this.#activeActorCountListeners.delete(listener);
|
|
8530
|
+
this.#syncActiveActorCountSubscription();
|
|
8531
|
+
};
|
|
8532
|
+
}
|
|
8533
|
+
#assertActiveActorCountSupported(method2) {
|
|
8534
|
+
this.#activeActorCountSupported ??= this.parseConfig().runtime !== "wasm";
|
|
8535
|
+
if (!this.#activeActorCountSupported) {
|
|
8536
|
+
throw new Error(
|
|
8537
|
+
`registry.${method2}() requires the native runtime; WebAssembly registries do not host an envoy`
|
|
8538
|
+
);
|
|
8539
|
+
}
|
|
8540
|
+
}
|
|
8541
|
+
/** Holds one native subscription while any listener is registered. */
|
|
8542
|
+
#syncActiveActorCountSubscription() {
|
|
8543
|
+
const configured = this.#envoyConfiguredRegistry;
|
|
8544
|
+
if (!configured) return;
|
|
8545
|
+
const { runtime, registry } = configured;
|
|
8546
|
+
const token = this.#activeActorCountToken;
|
|
8547
|
+
if (this.#activeActorCountListeners.size === 0) {
|
|
8548
|
+
if (token !== void 0) {
|
|
8549
|
+
this.#activeActorCountToken = void 0;
|
|
8550
|
+
this.#lastActiveActorCount = void 0;
|
|
8551
|
+
runtime.cancelCancellationToken(token);
|
|
8552
|
+
}
|
|
8553
|
+
return;
|
|
8554
|
+
}
|
|
8555
|
+
if (token !== void 0) return;
|
|
8556
|
+
if (!runtime.onRegistryActiveActorCountChange) {
|
|
8557
|
+
throw new Error(
|
|
8558
|
+
"active actor count subscriptions are not supported by this runtime"
|
|
8559
|
+
);
|
|
8560
|
+
}
|
|
8561
|
+
const nextToken = runtime.createCancellationToken();
|
|
8562
|
+
this.#activeActorCountToken = nextToken;
|
|
8563
|
+
runtime.onRegistryActiveActorCountChange(
|
|
8564
|
+
registry,
|
|
8565
|
+
(count) => {
|
|
8566
|
+
if (this.#activeActorCountToken !== nextToken) return;
|
|
8567
|
+
this.#lastActiveActorCount = count;
|
|
8568
|
+
for (const listener of [...this.#activeActorCountListeners]) {
|
|
8569
|
+
this.#deliverActiveActorCount(listener, count);
|
|
8570
|
+
}
|
|
8571
|
+
},
|
|
8572
|
+
nextToken
|
|
8573
|
+
);
|
|
8574
|
+
}
|
|
8575
|
+
#deliverActiveActorCount(listener, count) {
|
|
8576
|
+
try {
|
|
8577
|
+
listener(count);
|
|
8578
|
+
} catch (error) {
|
|
8579
|
+
logger2().error({ error }, "active actor count listener threw");
|
|
8580
|
+
}
|
|
8581
|
+
}
|
|
8203
8582
|
#printWelcome(config, kind, listener) {
|
|
8204
8583
|
if (config.noWelcome || this.#welcomePrinted) return;
|
|
8205
8584
|
this.#welcomePrinted = true;
|
|
@@ -8209,13 +8588,13 @@ var Registry = class {
|
|
|
8209
8588
|
};
|
|
8210
8589
|
console.log();
|
|
8211
8590
|
console.log(
|
|
8212
|
-
` RivetKit ${
|
|
8591
|
+
` RivetKit ${_chunkI26AW6BGcjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
|
|
8213
8592
|
);
|
|
8214
8593
|
if (config.namespace !== "default") {
|
|
8215
8594
|
logLine("Namespace", config.namespace);
|
|
8216
8595
|
}
|
|
8217
8596
|
if (config.endpoint) {
|
|
8218
|
-
const endpointType = config.startEngine ||
|
|
8597
|
+
const endpointType = config.startEngine || _chunkSJJWJU26cjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? "local native" : "remote";
|
|
8219
8598
|
logLine("Endpoint", `${config.endpoint} (${endpointType})`);
|
|
8220
8599
|
}
|
|
8221
8600
|
if (kind === "serverless" && config.publicEndpoint) {
|
|
@@ -8285,5 +8664,5 @@ function setup(input) {
|
|
|
8285
8664
|
|
|
8286
8665
|
|
|
8287
8666
|
|
|
8288
|
-
exports.ALLOWED_PUBLIC_HEADERS =
|
|
8667
|
+
exports.ALLOWED_PUBLIC_HEADERS = _chunkSJJWJU26cjs.ALLOWED_PUBLIC_HEADERS; exports.ActorDefinition = ActorDefinition; exports.ActorError = _chunkMGI2VVF6cjs.RivetError; exports.ActorsSchema = ActorsSchema; exports.DocConfigurePoolSchema = DocConfigurePoolSchema; exports.DocEnvoyConfigSchema = DocEnvoyConfigSchema; exports.DocRegistryConfigSchema = DocRegistryConfigSchema; exports.DocServerlessConfigSchema = DocServerlessConfigSchema; exports.DocSqliteConfigSchema = DocSqliteConfigSchema; exports.InlineWebSocketAdapter = InlineWebSocketAdapter; exports.Registry = Registry; exports.RegistryConfigSchema = RegistryConfigSchema; exports.RivetError = _chunkMGI2VVF6cjs.RivetError; exports.RuntimeKindSchema = RuntimeKindSchema; exports.SqliteBackendSchema = SqliteBackendSchema; exports.SqliteConfigSchema = SqliteConfigSchema; exports.TestConfigSchema = TestConfigSchema; exports.UserError = _chunkMGI2VVF6cjs.UserError; exports.WasmRuntimeConfigSchema = WasmRuntimeConfigSchema; exports.actor = actor; exports.buildActorNames = buildActorNames; exports.createClientWithDriver = _chunkSJJWJU26cjs.createClientWithDriver; exports.defineRunHandler = _chunkYWWDUC6Dcjs.defineRunHandler; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunkI26AW6BGcjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunkI26AW6BGcjs.toUint8Array;
|
|
8289
8668
|
//# sourceMappingURL=mod.cjs.map
|