@voltro/cli 0.1.5 → 0.2.0
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/CHANGELOG.md +16 -0
- package/THIRD-PARTY-NOTICES.md +1154 -4635
- package/dist/apiBuild-CRV5VLc-.js +2 -0
- package/dist/{apiBuild-B-SMjwR_.js → apiBuild-CnF3GAcP.js} +1 -1
- package/dist/bin.js +2 -2
- package/dist/{commands-BHIaKj-w.js → commands-5AlC8Udj.js} +1341 -1318
- package/dist/{dev-BhBMpHkm.js → dev-CZ2WE3zn.js} +531 -513
- package/dist/dev-DFhyP4GC.js +2 -0
- package/dist/index.js +1 -1
- package/package.json +17 -23
- package/templates/agent-docs/ai.md +21 -21
- package/templates/agent-docs/authentication.md +9 -9
- package/templates/agent-docs/cli.md +1 -1
- package/templates/agent-docs/data.md +7 -7
- package/templates/agent-docs/database/hosting.md +18 -0
- package/templates/agent-docs/database/migrations.md +13 -13
- package/templates/agent-docs/database/querying.md +6 -6
- package/templates/agent-docs/deployment.md +28 -0
- package/templates/apps/api-ai/package.json +7 -7
- package/templates/apps/api-auth/package.json +8 -7
- package/templates/apps/api-backend/package.json +7 -7
- package/templates/apps/api-backend-deactivation/package.json +7 -7
- package/templates/apps/api-backend-mail/package.json +8 -8
- package/templates/apps/api-backend-mariadb/package.json +9 -9
- package/templates/apps/api-backend-storage/package.json +8 -8
- package/templates/apps/api-data-advanced/package.json +8 -8
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-feature-flags/package.json +9 -8
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-moderation/package.json +8 -8
- package/templates/apps/api-observability/package.json +8 -8
- package/templates/apps/api-ratelimit/package.json +8 -8
- package/templates/apps/api-rbac/package.json +8 -8
- package/templates/apps/api-rest/package.json +7 -6
- package/templates/apps/api-saas/package.json +11 -10
- package/templates/apps/api-search/package.json +8 -8
- package/templates/apps/api-versioning/package.json +8 -8
- package/templates/apps/api-webhooks/package.json +8 -7
- package/templates/apps/changelog/package.json +6 -6
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +8 -8
- package/templates/apps/frontend-app/package.json +8 -8
- package/templates/apps/frontend-blank/package.json +7 -7
- package/templates/apps/frontend-contact/package.json +7 -7
- package/templates/apps/frontend-dashboard/package.json +7 -7
- package/templates/apps/frontend-docs/package.json +7 -7
- package/templates/apps/frontend-i18n/package.json +6 -6
- package/templates/apps/frontend-landing/package.json +7 -7
- package/templates/apps/frontend-spa/package.json +7 -7
- package/templates/apps/frontend-ssr/package.json +7 -7
- package/templates/apps/frontend-ssr-api/package.json +8 -8
- package/templates/apps/frontend-static-blog/package.json +6 -6
- package/templates/baselines/compose/docker/api.Dockerfile +10 -6
- package/templates/baselines/compose-mariadb/docker/api.Dockerfile +10 -6
- package/dist/apiBuild-Blk0vma3.js +0 -2
- package/dist/dev-BjylpfGQ.js +0 -2
|
@@ -4152,7 +4152,35 @@ ${a.join("\n\n")}\n`);
|
|
|
4152
4152
|
catch: (e) => e
|
|
4153
4153
|
}).pipe(y.orDie);
|
|
4154
4154
|
return yield* y.logDebug("wrote rpcGroup", { path: t }), 0;
|
|
4155
|
-
}), Ic = async (e) => W(Fc(e.find((e) => !e.startsWith("-")) ?? process.cwd()), { scope: "voltro:codegen" }), Lc =
|
|
4155
|
+
}), Ic = async (e) => W(Fc(e.find((e) => !e.startsWith("-")) ?? process.cwd()), { scope: "voltro:codegen" }), Lc = {
|
|
4156
|
+
postgres: "@voltro/sql-postgres",
|
|
4157
|
+
sqlite: "@voltro/sql-sqlite",
|
|
4158
|
+
mysql: "@voltro/sql-mysql",
|
|
4159
|
+
mariadb: "@voltro/sql-mysql",
|
|
4160
|
+
mssql: "@voltro/sql-mssql",
|
|
4161
|
+
turso: "@voltro/sql-turso"
|
|
4162
|
+
}, Rc = {
|
|
4163
|
+
postgres: "postgresDialect",
|
|
4164
|
+
sqlite: "sqliteDialect",
|
|
4165
|
+
mysql: "mysqlDialect",
|
|
4166
|
+
mariadb: "mariadbDialect",
|
|
4167
|
+
mssql: "mssqlDialect",
|
|
4168
|
+
turso: "tursoDialect"
|
|
4169
|
+
}, zc = async (e) => {
|
|
4170
|
+
try {
|
|
4171
|
+
return await import(d(sn(s(process.cwd(), "package.json")).resolve(e)).href);
|
|
4172
|
+
} catch {
|
|
4173
|
+
try {
|
|
4174
|
+
return await import(e);
|
|
4175
|
+
} catch {
|
|
4176
|
+
throw Error(`The '${e}' database driver is not installed.\n\nEvery Voltro app declares the driver for its DB dialect as a dependency (a memory store needs none). Install it in the app:\n\n pnpm add ${e}\n`);
|
|
4177
|
+
}
|
|
4178
|
+
}
|
|
4179
|
+
}, Bc = async (e) => {
|
|
4180
|
+
let t = Lc[e];
|
|
4181
|
+
if (!t) throw Error(`Unsupported DB_DIALECT='${e}'. Supported: memory, postgres, sqlite, mysql, mariadb, mssql, turso.`);
|
|
4182
|
+
return (await zc(t))[Rc[e]];
|
|
4183
|
+
}, Vc = [
|
|
4156
4184
|
{
|
|
4157
4185
|
table: Gn,
|
|
4158
4186
|
when: "always"
|
|
@@ -4245,16 +4273,16 @@ ${a.join("\n\n")}\n`);
|
|
|
4245
4273
|
table: Wn,
|
|
4246
4274
|
when: "always"
|
|
4247
4275
|
}
|
|
4248
|
-
],
|
|
4249
|
-
let t =
|
|
4276
|
+
], Hc = (e) => {
|
|
4277
|
+
let t = Vc.filter((t) => t.when === "always" || t.when === "workflows" && e.workflows || t.when === "schedules" && e.schedules || t.when === "webhooks" && e.webhooks || t.when === "traces" && e.traces || t.when === "undo" && e.undo === !0).map((e) => e.table);
|
|
4250
4278
|
return e.cdc === !0 && t.push(e.cdcDialect === "mssql" ? V : ur), t;
|
|
4251
|
-
},
|
|
4279
|
+
}, Uc = (e) => {
|
|
4252
4280
|
let t = e.startsWith("@") ? e.replace(/^@[^/]+\//, "") : e;
|
|
4253
4281
|
return (t.startsWith("plugin-") ? t.slice(7) : t).replace(/-([a-zA-Z0-9])/g, (e, t) => t.toUpperCase());
|
|
4254
|
-
},
|
|
4282
|
+
}, Wc = (e) => {
|
|
4255
4283
|
let t = e.startsWith("@") ? e.replace(/^@[^/]+\//, "") : e;
|
|
4256
4284
|
return (t.startsWith("plugin-") ? t.slice(7) : t).replace(/#/g, "--").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
4257
|
-
},
|
|
4285
|
+
}, Gc = (e, t) => t.name.includes(".") ? t.name : `${Uc(e.name)}.${t.name}`, Kc = (e, t, n) => {
|
|
4258
4286
|
switch (e) {
|
|
4259
4287
|
case "query": return Tr({
|
|
4260
4288
|
name: t,
|
|
@@ -4276,23 +4304,23 @@ ${a.join("\n\n")}\n`);
|
|
|
4276
4304
|
...n.error === void 0 ? {} : { error: n.error }
|
|
4277
4305
|
});
|
|
4278
4306
|
}
|
|
4279
|
-
},
|
|
4307
|
+
}, qc = (e) => (t, n) => y.suspend(() => {
|
|
4280
4308
|
let r = { request: {
|
|
4281
4309
|
subject: n.request.subject,
|
|
4282
4310
|
traceId: n.request.traceId
|
|
4283
4311
|
} };
|
|
4284
4312
|
return e.execute(t, r);
|
|
4285
|
-
}),
|
|
4313
|
+
}), Jc = (e) => {
|
|
4286
4314
|
let t = [];
|
|
4287
4315
|
for (let n of e) {
|
|
4288
4316
|
let e = n.routes ?? [];
|
|
4289
4317
|
for (let r of e) {
|
|
4290
|
-
let e =
|
|
4318
|
+
let e = Gc(n, r), i = Kc(r.kind, e, r);
|
|
4291
4319
|
t.push({
|
|
4292
4320
|
kind: r.kind,
|
|
4293
4321
|
file: `plugin:${n.name}`,
|
|
4294
4322
|
descriptor: i,
|
|
4295
|
-
executor:
|
|
4323
|
+
executor: qc(r),
|
|
4296
4324
|
plugin: {
|
|
4297
4325
|
name: n.name,
|
|
4298
4326
|
version: n.version
|
|
@@ -4301,7 +4329,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4301
4329
|
}
|
|
4302
4330
|
}
|
|
4303
4331
|
return t;
|
|
4304
|
-
},
|
|
4332
|
+
}, Yc = (e, t) => {
|
|
4305
4333
|
let n = /* @__PURE__ */ new Map();
|
|
4306
4334
|
for (let e of t) n.set(e, "user-route");
|
|
4307
4335
|
for (let t of e) {
|
|
@@ -4309,9 +4337,9 @@ ${a.join("\n\n")}\n`);
|
|
|
4309
4337
|
if (r !== void 0) throw Error(`plugin route tag collision: "${e}" declared by plugin "${t.plugin.name}" but already claimed by ${r === "user-route" ? "a user-authored route" : `plugin "${r}"`}`);
|
|
4310
4338
|
n.set(e, t.plugin.name);
|
|
4311
4339
|
}
|
|
4312
|
-
},
|
|
4340
|
+
}, Xc = "_voltro_plugin_migrations", Zc = () => y.gen(function* () {
|
|
4313
4341
|
yield* (yield* R.SqlClient).unsafe(`
|
|
4314
|
-
CREATE TABLE IF NOT EXISTS ${
|
|
4342
|
+
CREATE TABLE IF NOT EXISTS ${Xc} (
|
|
4315
4343
|
id TEXT PRIMARY KEY,
|
|
4316
4344
|
plugin_name TEXT NOT NULL,
|
|
4317
4345
|
migration_id TEXT NOT NULL,
|
|
@@ -4319,25 +4347,25 @@ ${a.join("\n\n")}\n`);
|
|
|
4319
4347
|
applied_at TEXT NOT NULL
|
|
4320
4348
|
);
|
|
4321
4349
|
`).pipe(y.orDie);
|
|
4322
|
-
}),
|
|
4323
|
-
let e = yield* R.SqlClient, t = yield* e`SELECT id FROM ${e(
|
|
4350
|
+
}), Qc = (e, t) => `${Uc(e)}__${t}`, $c = () => y.gen(function* () {
|
|
4351
|
+
let e = yield* R.SqlClient, t = yield* e`SELECT id FROM ${e(Xc)}`.pipe(y.orDie);
|
|
4324
4352
|
return new Set(t.map((e) => e.id));
|
|
4325
|
-
}),
|
|
4353
|
+
}), el = (e) => y.gen(function* () {
|
|
4326
4354
|
let t = yield* R.SqlClient, n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4327
4355
|
yield* t`
|
|
4328
|
-
INSERT INTO ${t(
|
|
4356
|
+
INSERT INTO ${t(Xc)} (id, plugin_name, migration_id, description, applied_at)
|
|
4329
4357
|
VALUES (${e.key}, ${e.pluginName}, ${e.migration.id}, ${e.migration.description ?? null}, ${n})
|
|
4330
4358
|
`.pipe(y.orDie);
|
|
4331
|
-
}),
|
|
4359
|
+
}), tl = (e) => y.gen(function* () {
|
|
4332
4360
|
let t = e.flatMap((e) => (e.extendSchema?.migrations ?? []).map((t) => ({
|
|
4333
4361
|
plugin: e,
|
|
4334
4362
|
migration: t
|
|
4335
4363
|
})));
|
|
4336
4364
|
if (t.length === 0) return [];
|
|
4337
|
-
yield*
|
|
4338
|
-
let n = yield*
|
|
4365
|
+
yield* Zc();
|
|
4366
|
+
let n = yield* $c(), r = [];
|
|
4339
4367
|
for (let { plugin: e, migration: i } of t) {
|
|
4340
|
-
let t =
|
|
4368
|
+
let t = Qc(e.name, i.id), a = Date.now();
|
|
4341
4369
|
if (n.has(t)) {
|
|
4342
4370
|
r.push({
|
|
4343
4371
|
pluginName: e.name,
|
|
@@ -4349,7 +4377,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4349
4377
|
}
|
|
4350
4378
|
let o = yield* R.SqlClient;
|
|
4351
4379
|
try {
|
|
4352
|
-
yield* i.up(o).pipe(y.mapError((e) => e)), yield*
|
|
4380
|
+
yield* i.up(o).pipe(y.mapError((e) => e)), yield* el({
|
|
4353
4381
|
key: t,
|
|
4354
4382
|
pluginName: e.name,
|
|
4355
4383
|
migration: i
|
|
@@ -4370,24 +4398,24 @@ ${a.join("\n\n")}\n`);
|
|
|
4370
4398
|
}
|
|
4371
4399
|
}
|
|
4372
4400
|
return r;
|
|
4373
|
-
}),
|
|
4401
|
+
}), nl = (e) => e.filter((e) => e.extendSchema && (e.extendSchema.tables?.length ?? 0) + (e.extendSchema.migrations?.length ?? 0) > 0).map((e) => ({
|
|
4374
4402
|
pluginName: e.name,
|
|
4375
|
-
pluginAlias:
|
|
4403
|
+
pluginAlias: Uc(e.name),
|
|
4376
4404
|
tables: e.extendSchema.tables?.length ?? 0,
|
|
4377
4405
|
migrations: e.extendSchema.migrations?.length ?? 0
|
|
4378
|
-
})),
|
|
4406
|
+
})), rl = (e) => e.flatMap((e) => e.extendSchema?.tables ?? []), il = /(?<!\.server)\.agent\.tsx?$/, al = /\.agent\.server\.tsx?$/, ol = /\.tool\.tsx?$/, sl = async (e, n) => {
|
|
4379
4407
|
let r = 0;
|
|
4380
|
-
for (let i of e) if (
|
|
4408
|
+
for (let i of e) if (ol.test(i)) try {
|
|
4381
4409
|
let e = await t(i);
|
|
4382
4410
|
r += hn(e);
|
|
4383
4411
|
} catch (e) {
|
|
4384
4412
|
n.warn("tool: failed to import — handler not wired", { file: i }, e);
|
|
4385
4413
|
}
|
|
4386
4414
|
return r;
|
|
4387
|
-
},
|
|
4415
|
+
}, cl = (e) => e.replace(/\.agent\.(tsx?)$/, ".agent.server.$1"), ll = async (e, n) => {
|
|
4388
4416
|
let r = [], i = /* @__PURE__ */ new Set();
|
|
4389
4417
|
for (let a of e) {
|
|
4390
|
-
if (!
|
|
4418
|
+
if (!il.test(a)) continue;
|
|
4391
4419
|
let e;
|
|
4392
4420
|
try {
|
|
4393
4421
|
e = await t(a);
|
|
@@ -4407,7 +4435,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4407
4435
|
});
|
|
4408
4436
|
continue;
|
|
4409
4437
|
}
|
|
4410
|
-
let s =
|
|
4438
|
+
let s = cl(a), c;
|
|
4411
4439
|
try {
|
|
4412
4440
|
c = await t(s);
|
|
4413
4441
|
} catch (e) {
|
|
@@ -4434,24 +4462,24 @@ ${a.join("\n\n")}\n`);
|
|
|
4434
4462
|
});
|
|
4435
4463
|
}
|
|
4436
4464
|
return { agents: r };
|
|
4437
|
-
},
|
|
4465
|
+
}, ul = (e) => typeof e.attributes["framework.kind"] == "string" && e.attributes["framework.kind"].startsWith("subscription."), dl = (e) => {
|
|
4438
4466
|
if (e.name.includes("_voltro_traces")) return !0;
|
|
4439
4467
|
for (let t in e.attributes) {
|
|
4440
4468
|
let n = e.attributes[t];
|
|
4441
4469
|
if (typeof n == "string" && n.includes("_voltro_traces")) return !0;
|
|
4442
4470
|
}
|
|
4443
4471
|
return !1;
|
|
4444
|
-
},
|
|
4472
|
+
}, fl = (e) => typeof e.attributes["framework.kind"] == "string" && e.attributes["framework.kind"].startsWith("subscription"), pl = 1e3, ml = 500, hl = 50, gl = class {
|
|
4445
4473
|
capacity;
|
|
4446
4474
|
buffer = [];
|
|
4447
|
-
constructor(e =
|
|
4475
|
+
constructor(e = pl) {
|
|
4448
4476
|
this.capacity = e;
|
|
4449
4477
|
}
|
|
4450
4478
|
append(e) {
|
|
4451
4479
|
this.buffer.push(e), this.buffer.length > this.capacity && this.buffer.shift();
|
|
4452
4480
|
}
|
|
4453
4481
|
query(e = {}) {
|
|
4454
|
-
let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ??
|
|
4482
|
+
let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ?? ml, this.capacity), i = e.traceId, a = e.minDurationMs, o = e.status, s = e.name?.toLowerCase(), c = [];
|
|
4455
4483
|
for (let e = this.buffer.length - 1; e >= 0 && c.length < r; e--) {
|
|
4456
4484
|
let r = this.buffer[e];
|
|
4457
4485
|
r.startMs < t || r.startMs > n || i !== void 0 && r.traceId !== i || a !== void 0 && r.durationMs < a || o !== void 0 && r.status !== o || s !== void 0 && !r.name.toLowerCase().includes(s) || c.push(r);
|
|
@@ -4459,7 +4487,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4459
4487
|
return c.reverse();
|
|
4460
4488
|
}
|
|
4461
4489
|
queryGrouped(e = {}) {
|
|
4462
|
-
let t = e.since ?? 0, n = e.maxTraces ??
|
|
4490
|
+
let t = e.since ?? 0, n = e.maxTraces ?? hl, r = e.onlyErrors ?? !1, i = /* @__PURE__ */ new Map();
|
|
4463
4491
|
for (let e of this.buffer) {
|
|
4464
4492
|
if (e.startMs < t) continue;
|
|
4465
4493
|
let n = i.get(e.traceId);
|
|
@@ -4470,7 +4498,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4470
4498
|
t.sort((e, t) => e.startMs - t.startMs);
|
|
4471
4499
|
let n = t.some((e) => e.status === "error");
|
|
4472
4500
|
if (r && !n) continue;
|
|
4473
|
-
let i = t[0].startMs, o = t.reduce((e, t) => t.endMs > e ? t.endMs : e, i), s = t.filter(
|
|
4501
|
+
let i = t[0].startMs, o = t.reduce((e, t) => t.endMs > e ? t.endMs : e, i), s = t.filter(ul), c = s.length > 0 || t.some(fl), l = s.reduce((e, t) => e === void 0 || t.startMs > e.startMs ? t : e, void 0);
|
|
4474
4502
|
a.push({
|
|
4475
4503
|
traceId: e,
|
|
4476
4504
|
rootName: t[0].name,
|
|
@@ -4495,69 +4523,69 @@ ${a.join("\n\n")}\n`);
|
|
|
4495
4523
|
clear() {
|
|
4496
4524
|
this.buffer = [];
|
|
4497
4525
|
}
|
|
4498
|
-
},
|
|
4526
|
+
}, _l = null, vl = () => (_l === null && (_l = new gl()), _l), yl = /* @__PURE__ */ new Set([
|
|
4499
4527
|
"off",
|
|
4500
4528
|
"errors",
|
|
4501
4529
|
"interesting",
|
|
4502
4530
|
"all"
|
|
4503
|
-
]),
|
|
4531
|
+
]), bl = (e, t, n, r) => {
|
|
4504
4532
|
let i = Number(e);
|
|
4505
4533
|
return Number.isFinite(i) ? Math.min(r, Math.max(n, i)) : t;
|
|
4506
|
-
},
|
|
4534
|
+
}, xl = (e) => e !== void 0 && [
|
|
4507
4535
|
"1",
|
|
4508
4536
|
"true",
|
|
4509
4537
|
"yes",
|
|
4510
4538
|
"on"
|
|
4511
|
-
].includes(e.toLowerCase()),
|
|
4539
|
+
].includes(e.toLowerCase()), Sl = (e) => {
|
|
4512
4540
|
let t = Number(e);
|
|
4513
4541
|
return Number.isFinite(t) && t > 0 ? t : 24;
|
|
4514
|
-
},
|
|
4515
|
-
let t = (e.VOLTRO_TRACING_BUFFER ?? "").toLowerCase() === "off", n =
|
|
4542
|
+
}, Cl = (e = process.env) => {
|
|
4543
|
+
let t = (e.VOLTRO_TRACING_BUFFER ?? "").toLowerCase() === "off", n = bl(e.VOLTRO_TRACING_SAMPLE, 1, 0, 1), r = (e.VOLTRO_TRACING_PERSIST ?? "").toLowerCase(), i = e.NODE_ENV === "production" ? "off" : "interesting";
|
|
4516
4544
|
return {
|
|
4517
|
-
mode:
|
|
4545
|
+
mode: yl.has(r) ? r : n <= 0 ? "off" : i,
|
|
4518
4546
|
sampleRate: n,
|
|
4519
|
-
slowMs:
|
|
4520
|
-
ttlHours:
|
|
4521
|
-
persistDelivery:
|
|
4547
|
+
slowMs: bl(e.VOLTRO_TRACING_SLOW_MS, 500, 0, 2 ** 53 - 1),
|
|
4548
|
+
ttlHours: Sl(e.VOLTRO_TRACING_TTL_HOURS),
|
|
4549
|
+
persistDelivery: xl(e.VOLTRO_TRACING_PERSIST_DELIVERY),
|
|
4522
4550
|
bufferDisabled: t
|
|
4523
4551
|
};
|
|
4524
|
-
},
|
|
4525
|
-
let t =
|
|
4552
|
+
}, wl = (e = process.env) => {
|
|
4553
|
+
let t = Cl(e);
|
|
4526
4554
|
return !t.bufferDisabled && t.mode !== "off";
|
|
4527
|
-
},
|
|
4555
|
+
}, Tl = (e, t) => {
|
|
4528
4556
|
if (t >= 1) return !0;
|
|
4529
4557
|
if (t <= 0) return !1;
|
|
4530
4558
|
let n = 2166136261;
|
|
4531
4559
|
for (let t = 0; t < e.length; t++) n ^= e.charCodeAt(t), n = Math.imul(n, 16777619);
|
|
4532
4560
|
return (n >>> 0) % 1e3 < t * 1e3;
|
|
4533
|
-
},
|
|
4534
|
-
if (t.mode === "off" ||
|
|
4561
|
+
}, El = (e, t) => {
|
|
4562
|
+
if (t.mode === "off" || dl(e) || ul(e) && !t.persistDelivery) return !1;
|
|
4535
4563
|
let n = e.status === "error";
|
|
4536
4564
|
if (t.mode === "errors") return n;
|
|
4537
4565
|
if (n) return !0;
|
|
4538
|
-
if (!
|
|
4566
|
+
if (!Tl(e.traceId, t.sampleRate)) return !1;
|
|
4539
4567
|
if (t.mode === "all") return !0;
|
|
4540
4568
|
let r = e.parentSpanId === null || e.parentSpanId === void 0 || e.parentSpanId === "", i = typeof e.durationMs == "number" && e.durationMs >= t.slowMs;
|
|
4541
4569
|
return r || i;
|
|
4542
|
-
},
|
|
4570
|
+
}, Dl = (e) => {
|
|
4543
4571
|
if (e.bufferDisabled) return "durable traces: OFF (VOLTRO_TRACING_BUFFER=off)";
|
|
4544
4572
|
if (e.mode === "off") return "durable traces: OFF — _voltro_traces not created (prod default; set VOLTRO_TRACING_PERSIST=interesting to enable, or use OTLP)";
|
|
4545
4573
|
let t = e.mode === "interesting" ? ` (errors + slow≥${e.slowMs}ms + roots)` : e.mode === "errors" ? " (errors only)" : "";
|
|
4546
4574
|
return `durable traces: mode=${e.mode}${t}` + (e.sampleRate < 1 ? ` · sample=${e.sampleRate}` : "") + (e.persistDelivery ? " · +delivery" : "") + ` · ttl=${e.ttlHours}h`;
|
|
4547
|
-
},
|
|
4575
|
+
}, Ol = (e = 30 * 6e4) => {
|
|
4548
4576
|
let t = /* @__PURE__ */ new Map();
|
|
4549
4577
|
return (n, r) => {
|
|
4550
4578
|
let i = t.get(n);
|
|
4551
4579
|
return i !== void 0 && r - i < e ? !1 : (t.set(n, r), !0);
|
|
4552
4580
|
};
|
|
4553
|
-
},
|
|
4554
|
-
let { store: t, log: n } = e, r = e.policy ??
|
|
4555
|
-
n.info(
|
|
4556
|
-
let i =
|
|
4581
|
+
}, kl = (e) => {
|
|
4582
|
+
let { store: t, log: n } = e, r = e.policy ?? Cl();
|
|
4583
|
+
n.info(Dl(r));
|
|
4584
|
+
let i = Ol(), a = [], o = () => {};
|
|
4557
4585
|
if (r.mode !== "off") {
|
|
4558
4586
|
let e = [], s = 0;
|
|
4559
4587
|
o = (t) => {
|
|
4560
|
-
|
|
4588
|
+
El(t, r) && (e.length >= 5e3 && (e.shift(), s += 1, i("flush-drop", Date.now()) && (n.warn(`trace flush queue saturated — dropping durable spans (${s}+ since last warning). Durable inflow exceeds write throughput; reduce it with VOLTRO_TRACING_PERSIST=errors|interesting or VOLTRO_TRACING_SAMPLE<1.`), s = 0)), e.push(t));
|
|
4561
4589
|
};
|
|
4562
4590
|
let c = async () => {
|
|
4563
4591
|
if (e.length === 0) return;
|
|
@@ -4623,7 +4651,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4623
4651
|
for (let e of a) clearInterval(e);
|
|
4624
4652
|
}
|
|
4625
4653
|
};
|
|
4626
|
-
},
|
|
4654
|
+
}, Al = /\.workflow\.tsx?$/, jl = /\.trigger\.tsx?$/, Ml = /\.cron\.tsx?$/, Nl = /\.webhook\.tsx?$/, Pl = async (e) => {
|
|
4627
4655
|
let t = !1, n = !1, r = !1, i = !1, a = async (e) => {
|
|
4628
4656
|
let o = await N.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
4629
4657
|
for (let c of o) if (c.isDirectory()) {
|
|
@@ -4631,7 +4659,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4631
4659
|
await a(s(e, c.name));
|
|
4632
4660
|
} else {
|
|
4633
4661
|
let e = c.name;
|
|
4634
|
-
(
|
|
4662
|
+
(Al.test(e) || jl.test(e)) && (t = !0), Ml.test(e) && (n = !0), Nl.test(e) && (r = !0), il.test(e) && (i = !0);
|
|
4635
4663
|
}
|
|
4636
4664
|
};
|
|
4637
4665
|
return await a(e), {
|
|
@@ -4640,37 +4668,37 @@ ${a.join("\n\n")}\n`);
|
|
|
4640
4668
|
webhooks: r,
|
|
4641
4669
|
agents: i
|
|
4642
4670
|
};
|
|
4643
|
-
},
|
|
4671
|
+
}, Fl = async (e) => {
|
|
4644
4672
|
try {
|
|
4645
4673
|
return (await import(d(s(e, "app.config.ts")).href)).default?.plugins ?? [];
|
|
4646
4674
|
} catch {
|
|
4647
4675
|
return [];
|
|
4648
4676
|
}
|
|
4649
|
-
},
|
|
4677
|
+
}, Il = (e) => {
|
|
4650
4678
|
let t = /* @__PURE__ */ new Map(), n = (e) => {
|
|
4651
4679
|
e?.tableName && !t.has(e.tableName) && t.set(e.tableName, e);
|
|
4652
4680
|
};
|
|
4653
|
-
for (let t of
|
|
4681
|
+
for (let t of Hc({
|
|
4654
4682
|
workflows: e.mix.workflows,
|
|
4655
4683
|
schedules: e.mix.schedules,
|
|
4656
4684
|
webhooks: e.mix.webhooks,
|
|
4657
|
-
traces:
|
|
4685
|
+
traces: wl(),
|
|
4658
4686
|
cdc: e.cdc,
|
|
4659
4687
|
...e.cdcDialect ? { cdcDialect: e.cdcDialect } : {},
|
|
4660
4688
|
undo: Lt()
|
|
4661
4689
|
})) n(t);
|
|
4662
4690
|
e.mix.agents && (n(ln), n(cn), n(dn), n(un));
|
|
4663
|
-
for (let t of
|
|
4691
|
+
for (let t of rl(e.plugins)) n(t);
|
|
4664
4692
|
return [...t.values()];
|
|
4665
|
-
},
|
|
4666
|
-
let t = await
|
|
4667
|
-
return
|
|
4693
|
+
}, Ll = async (e) => {
|
|
4694
|
+
let t = await Pl(e.root), n = await Fl(e.root), r = (process.env.DB_DIALECT ?? "postgres").toLowerCase(), i = r === "mariadb" ? "mariadb" : r === "mssql" ? "mssql" : void 0;
|
|
4695
|
+
return Il({
|
|
4668
4696
|
mix: t,
|
|
4669
4697
|
plugins: n,
|
|
4670
4698
|
cdc: e.cdc ?? (i !== void 0 && (process.env.CDC ?? "1") !== "0"),
|
|
4671
4699
|
...i ? { cdcDialect: i } : {}
|
|
4672
4700
|
});
|
|
4673
|
-
},
|
|
4701
|
+
}, Rl = async ({ env: e = process.env } = {}) => {
|
|
4674
4702
|
let t = C.make(S.mergeAll(Zr.layer, Qr.Default)), n = await t.runPromise(Xr), r = await t.runPromise(Qr), i = (e.CACHE_BACKEND ?? "memory").toLowerCase();
|
|
4675
4703
|
return await t.runPromise(r.addSink((e) => n.invalidateTag(e))), {
|
|
4676
4704
|
service: n,
|
|
@@ -4703,7 +4731,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4703
4731
|
stats: () => t.runSync(n.stats()),
|
|
4704
4732
|
dispose: () => t.dispose()
|
|
4705
4733
|
};
|
|
4706
|
-
},
|
|
4734
|
+
}, zl = ({ store: e, dialect: t, env: n = process.env }) => {
|
|
4707
4735
|
if (t !== "postgres") return { stop: () => {} };
|
|
4708
4736
|
Ct({
|
|
4709
4737
|
table: "_voltro_schedule_runs",
|
|
@@ -4749,7 +4777,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4749
4777
|
o();
|
|
4750
4778
|
}, 5 * 6e4);
|
|
4751
4779
|
return s.unref?.(), { stop: () => clearInterval(s) };
|
|
4752
|
-
},
|
|
4780
|
+
}, Bl = (e) => {
|
|
4753
4781
|
let { store: t, schemaRegistry: n, cache: r, kv: i, webhooksService: a, workflowsProxy: o, eventTriggers: s, namespaceIsolationOn: c, onEventEmit: l } = e, u = (e, t) => {
|
|
4754
4782
|
if (!c) return e;
|
|
4755
4783
|
if (e.withNamespace === void 0) throw Error("tenantIsolation=namespace is set but the active store has no physical-namespace support (withNamespace).");
|
|
@@ -4788,7 +4816,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4788
4816
|
...h === void 0 ? {} : { workflows: d ? ot(h, d.afterCommit) : h }
|
|
4789
4817
|
};
|
|
4790
4818
|
};
|
|
4791
|
-
},
|
|
4819
|
+
}, Vl = async (e, t, n) => {
|
|
4792
4820
|
if (t.type === "anonymous" || t.id == null) throw new gr({ reason: "workflow control requires an authenticated subject" });
|
|
4793
4821
|
let r = "id" in n ? B("id", n.id) : B("executionId", n.executionId), i = (await e.query({
|
|
4794
4822
|
table: "_voltro_workflow_runs",
|
|
@@ -4799,7 +4827,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4799
4827
|
take: 1
|
|
4800
4828
|
}))[0], a = i?.subject?.tenantId ?? null, o = t.tenantId ?? null;
|
|
4801
4829
|
if (i === void 0 || a !== o) throw new gr({ reason: "not authorized for this workflow run" });
|
|
4802
|
-
},
|
|
4830
|
+
}, Hl = L.pipe(S.provide(f.layer)), Ul = (e) => {
|
|
4803
4831
|
let t = S.succeed(Xr, e.cacheService), n = S.succeed($r, e.kvService), r = [
|
|
4804
4832
|
e.analyticsLayer,
|
|
4805
4833
|
t,
|
|
@@ -4808,47 +4836,47 @@ ${a.join("\n\n")}\n`);
|
|
|
4808
4836
|
...e.userLayers
|
|
4809
4837
|
];
|
|
4810
4838
|
return S.mergeAll(...r);
|
|
4811
|
-
},
|
|
4839
|
+
}, Wl = [
|
|
4812
4840
|
Lr,
|
|
4813
4841
|
zr,
|
|
4814
4842
|
Rr,
|
|
4815
4843
|
Ir,
|
|
4816
4844
|
Nr,
|
|
4817
4845
|
Pr
|
|
4818
|
-
],
|
|
4846
|
+
], Gl = (e, t, n) => {
|
|
4819
4847
|
let r = new Set(t);
|
|
4820
|
-
if (n) for (let e of
|
|
4848
|
+
if (n) for (let e of Wl) r.add(e.name);
|
|
4821
4849
|
let i = {};
|
|
4822
4850
|
for (let [t, n] of Object.entries(e)) i[t] = r.has(t) ? (e) => n(e).pipe(D.take(1)) : n;
|
|
4823
4851
|
return i;
|
|
4824
|
-
},
|
|
4852
|
+
}, Kl = O({ scope: "voltro:dev:supervisor" }), ql = /\.generated\./, Jl = /\.([cm]?[jt]sx?|json)$/, Yl = (e) => {
|
|
4825
4853
|
let t = i(e);
|
|
4826
|
-
return !
|
|
4827
|
-
},
|
|
4854
|
+
return !ql.test(t) && Jl.test(t);
|
|
4855
|
+
}, Xl = (e) => e.startsWith("node_modules") || e.startsWith(".framework") || e.startsWith(".turbo") || e.startsWith(".vite") || e.startsWith("dist") || e.startsWith(".git"), Zl = process.env.WATCH_POLL === "1" || process.env.CHOKIDAR_USEPOLLING === "1", Ql = 1e3, $l = (e) => D.async((t) => {
|
|
4828
4856
|
let n = l(e), r = (e) => c(n, e), a = ri(n, {
|
|
4829
4857
|
persistent: !0,
|
|
4830
4858
|
ignoreInitial: !0,
|
|
4831
4859
|
atomic: !0,
|
|
4832
|
-
usePolling:
|
|
4833
|
-
interval:
|
|
4834
|
-
binaryInterval:
|
|
4860
|
+
usePolling: Zl,
|
|
4861
|
+
interval: Ql,
|
|
4862
|
+
binaryInterval: Ql,
|
|
4835
4863
|
ignored: (e) => {
|
|
4836
4864
|
let t = r(e);
|
|
4837
|
-
return t === "" ? !1 :
|
|
4865
|
+
return t === "" ? !1 : Xl(t) || ql.test(i(e));
|
|
4838
4866
|
}
|
|
4839
4867
|
});
|
|
4840
4868
|
return a.on("all", (e, n) => {
|
|
4841
4869
|
let i = r(n);
|
|
4842
|
-
process.env.WATCH_DEBUG === "1" &&
|
|
4870
|
+
process.env.WATCH_DEBUG === "1" && Kl.trace("watcher fired", {
|
|
4843
4871
|
event: e,
|
|
4844
4872
|
file: i
|
|
4845
|
-
}), !
|
|
4873
|
+
}), !Xl(i) && Yl(i) && t.single({ file: i });
|
|
4846
4874
|
}), a.on("error", (e) => {
|
|
4847
|
-
|
|
4875
|
+
Kl.error("watcher error", { hint: Zl ? void 0 : "on a bind-mount (k8s hostPath / Docker volume) set WATCH_POLL=1" }, e);
|
|
4848
4876
|
}), y.sync(() => {
|
|
4849
4877
|
a.close();
|
|
4850
4878
|
});
|
|
4851
|
-
}),
|
|
4879
|
+
}), eu = (e) => y.acquireUseRelease(y.sync(() => {
|
|
4852
4880
|
let t = process.argv[1] ?? "";
|
|
4853
4881
|
return $t(process.execPath, [
|
|
4854
4882
|
"--import",
|
|
@@ -4875,15 +4903,15 @@ ${a.join("\n\n")}\n`);
|
|
|
4875
4903
|
e.once("exit", () => {
|
|
4876
4904
|
clearTimeout(n), t(y.void);
|
|
4877
4905
|
});
|
|
4878
|
-
})),
|
|
4879
|
-
|
|
4906
|
+
})), tu = (e) => y.gen(function* () {
|
|
4907
|
+
Kl.info("supervisor active — watching project root", {
|
|
4880
4908
|
root: e.root,
|
|
4881
4909
|
patterns: ["**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs,json} (excl. *.generated.*)"],
|
|
4882
|
-
watcher:
|
|
4910
|
+
watcher: Zl ? "chokidar (polling)" : "chokidar (native)",
|
|
4883
4911
|
hint: "WATCH=0 disables, WATCH_DEBUG=1 traces every event, WATCH_POLL=1 for bind-mounts (k8s/Docker)"
|
|
4884
4912
|
});
|
|
4885
4913
|
let t = yield* T.make(w.none()), n = y.gen(function* () {
|
|
4886
|
-
let n = yield* y.fork(
|
|
4914
|
+
let n = yield* y.fork(eu(e.root));
|
|
4887
4915
|
yield* T.set(t, w.some(n));
|
|
4888
4916
|
}), r = y.gen(function* () {
|
|
4889
4917
|
let e = yield* T.get(t);
|
|
@@ -4892,11 +4920,11 @@ ${a.join("\n\n")}\n`);
|
|
|
4892
4920
|
onSome: (e) => b.interrupt(e)
|
|
4893
4921
|
}), yield* T.set(t, w.none());
|
|
4894
4922
|
});
|
|
4895
|
-
return yield* n, yield*
|
|
4923
|
+
return yield* n, yield* $l(e.root).pipe(D.debounce(v.millis(80)), D.runForEach((e) => y.gen(function* () {
|
|
4896
4924
|
let t = Date.now();
|
|
4897
|
-
|
|
4925
|
+
Kl.info("file changed — restarting", { file: e.file }), yield* r, yield* n, Kl.info("restart complete", { ms: Date.now() - t });
|
|
4898
4926
|
}))), yield* y.never;
|
|
4899
|
-
}),
|
|
4927
|
+
}), nu = async (e) => {
|
|
4900
4928
|
let t = e.spec ?? gt, n;
|
|
4901
4929
|
return t.kind !== "noop" && e.sqlLayer !== void 0 ? n = await y.runPromise(y.gen(function* () {
|
|
4902
4930
|
let n = yield* R.SqlClient, r = t.build(n);
|
|
@@ -4917,14 +4945,14 @@ ${a.join("\n\n")}\n`);
|
|
|
4917
4945
|
t.dispose && await y.runPromise(t.dispose(n).pipe(y.timeout("1200 millis"), y.ignore));
|
|
4918
4946
|
}
|
|
4919
4947
|
};
|
|
4920
|
-
},
|
|
4921
|
-
for (let e of
|
|
4922
|
-
throw Error(`@effect/cluster patch asset not found (looked in: ${
|
|
4923
|
-
},
|
|
4924
|
-
if (
|
|
4925
|
-
let t = ` '${
|
|
4948
|
+
}, ru = "@effect/cluster@0.59.0", iu = "@effect__cluster@0.59.0.patch", au = `patches/${iu}`, ou = a(u(import.meta.url)), su = [l(ou, "..", "templates", "patches", iu), l(ou, "..", "..", "templates", "patches", iu)], cu = async () => {
|
|
4949
|
+
for (let e of su) if (A(e)) return N.readFile(e, "utf8");
|
|
4950
|
+
throw Error(`@effect/cluster patch asset not found (looked in: ${su.join(", ")}). This is a packaging bug — the CLI should ship it under templates/patches/.`);
|
|
4951
|
+
}, lu = (e) => RegExp(`['"]?${ru.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}['"]?\\s*:`).test(e), uu = (e) => {
|
|
4952
|
+
if (lu(e)) return null;
|
|
4953
|
+
let t = ` '${ru}': ${au}`, n = /^patchedDependencies:[ \t]*\n/m;
|
|
4926
4954
|
return n.test(e) ? e.replace(n, (e) => `${e}${t}\n`) : `${e}${e.endsWith("\n") ? "" : "\n"}\npatchedDependencies:\n${t}\n`;
|
|
4927
|
-
},
|
|
4955
|
+
}, du = (e) => {
|
|
4928
4956
|
let t = l(e);
|
|
4929
4957
|
for (let e = 0; e < 12; e++) {
|
|
4930
4958
|
if (A(s(t, "pnpm-workspace.yaml"))) return t;
|
|
@@ -4933,28 +4961,28 @@ ${a.join("\n\n")}\n`);
|
|
|
4933
4961
|
t = e;
|
|
4934
4962
|
}
|
|
4935
4963
|
return null;
|
|
4936
|
-
},
|
|
4937
|
-
let t =
|
|
4964
|
+
}, fu = async (e) => {
|
|
4965
|
+
let t = du(e);
|
|
4938
4966
|
if (!t) return null;
|
|
4939
|
-
let n = await
|
|
4940
|
-
return n.fullyWired ? null : `mssql + durable cluster workflows need the @effect/cluster patch, which a plain install cannot carry. Run \`voltro add mssql\` then \`pnpm install\` to wire it (missing: ${[n.patchFilePresent ? null :
|
|
4941
|
-
},
|
|
4942
|
-
let t = A(s(e,
|
|
4967
|
+
let n = await pu(t);
|
|
4968
|
+
return n.fullyWired ? null : `mssql + durable cluster workflows need the @effect/cluster patch, which a plain install cannot carry. Run \`voltro add mssql\` then \`pnpm install\` to wire it (missing: ${[n.patchFilePresent ? null : au, n.pnpmEntryPresent ? null : "patchedDependencies in pnpm-workspace.yaml"].filter(Boolean).join(" + ")}). Without it, workflow message/runner storage misbehaves on SQL Server.`;
|
|
4969
|
+
}, pu = async (e) => {
|
|
4970
|
+
let t = A(s(e, au)), n = s(e, "pnpm-workspace.yaml"), r = A(n) && lu(await N.readFile(n, "utf8"));
|
|
4943
4971
|
return {
|
|
4944
4972
|
patchFilePresent: t,
|
|
4945
4973
|
pnpmEntryPresent: r,
|
|
4946
4974
|
fullyWired: t && r
|
|
4947
4975
|
};
|
|
4948
|
-
},
|
|
4949
|
-
let t = [], n = s(e,
|
|
4950
|
-
(A(n) ? await N.readFile(n, "utf8") : null) !== r && (await N.mkdir(a(n), { recursive: !0 }), await N.writeFile(n, r, "utf8"), t.push(`patch file → ${
|
|
4976
|
+
}, mu = async (e) => {
|
|
4977
|
+
let t = [], n = s(e, au), r = await cu();
|
|
4978
|
+
(A(n) ? await N.readFile(n, "utf8") : null) !== r && (await N.mkdir(a(n), { recursive: !0 }), await N.writeFile(n, r, "utf8"), t.push(`patch file → ${au}`));
|
|
4951
4979
|
let i = s(e, "pnpm-workspace.yaml");
|
|
4952
4980
|
if (A(i)) {
|
|
4953
|
-
let e =
|
|
4954
|
-
e !== null && (await N.writeFile(i, e, "utf8"), t.push(`patchedDependencies['${
|
|
4981
|
+
let e = uu(await N.readFile(i, "utf8"));
|
|
4982
|
+
e !== null && (await N.writeFile(i, e, "utf8"), t.push(`patchedDependencies['${ru}'] → pnpm-workspace.yaml`));
|
|
4955
4983
|
}
|
|
4956
4984
|
return t;
|
|
4957
|
-
},
|
|
4985
|
+
}, hu = async (e, t) => {
|
|
4958
4986
|
let n = [];
|
|
4959
4987
|
for (let r of e) {
|
|
4960
4988
|
let e;
|
|
@@ -4977,7 +5005,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4977
5005
|
});
|
|
4978
5006
|
}
|
|
4979
5007
|
return n;
|
|
4980
|
-
},
|
|
5008
|
+
}, gu = (e) => ({
|
|
4981
5009
|
query: (t) => e.query({
|
|
4982
5010
|
table: t.table,
|
|
4983
5011
|
order: [],
|
|
@@ -4986,7 +5014,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4986
5014
|
insert: (t, n) => e.insert(t, n),
|
|
4987
5015
|
update: (t, n, r) => e.update(t, n, r),
|
|
4988
5016
|
delete: (t, n) => e.delete(t, n)
|
|
4989
|
-
}),
|
|
5017
|
+
}), _u = (e) => async (t, n, r) => {
|
|
4990
5018
|
let i = Object.keys(n);
|
|
4991
5019
|
if (i.length === 0) throw Error("upsertByUnique: matchFields must have at least one key");
|
|
4992
5020
|
let a;
|
|
@@ -5010,18 +5038,18 @@ ${a.join("\n\n")}\n`);
|
|
|
5010
5038
|
row: await e.insert(t, r),
|
|
5011
5039
|
created: !0
|
|
5012
5040
|
};
|
|
5013
|
-
},
|
|
5014
|
-
let n =
|
|
5041
|
+
}, vu = (e, t) => {
|
|
5042
|
+
let n = _u(e);
|
|
5015
5043
|
return {
|
|
5016
|
-
store:
|
|
5044
|
+
store: gu(e),
|
|
5017
5045
|
upsertByUnique: n,
|
|
5018
5046
|
progress: (e, n) => t.debug("seed progress", {
|
|
5019
5047
|
done: e,
|
|
5020
5048
|
total: n
|
|
5021
5049
|
})
|
|
5022
5050
|
};
|
|
5023
|
-
},
|
|
5024
|
-
let r = Date.now(), i =
|
|
5051
|
+
}, yu = async (e, t, n) => {
|
|
5052
|
+
let r = Date.now(), i = vu(t, n), a = 0;
|
|
5025
5053
|
for (let t of e.definition.steps) try {
|
|
5026
5054
|
let e = await t.body(i);
|
|
5027
5055
|
e && typeof e.rowsTouched == "number" && (a += e.rowsTouched);
|
|
@@ -5048,13 +5076,13 @@ ${a.join("\n\n")}\n`);
|
|
|
5048
5076
|
durationMs: Date.now() - r,
|
|
5049
5077
|
rowsTouched: a
|
|
5050
5078
|
};
|
|
5051
|
-
},
|
|
5079
|
+
}, bu = async (e, t, n) => {
|
|
5052
5080
|
let r = e.filter((e) => e.definition.lifecycle === "boot");
|
|
5053
5081
|
if (r.length === 0) return [];
|
|
5054
5082
|
n.info("seeds: running boot-lifecycle seeds", { count: r.length });
|
|
5055
5083
|
let i = [];
|
|
5056
5084
|
for (let e of r) {
|
|
5057
|
-
let r = await
|
|
5085
|
+
let r = await yu(e, t, n);
|
|
5058
5086
|
r.status === "succeeded" && n.info(`seed "${r.seedId}" applied`, {
|
|
5059
5087
|
durationMs: r.durationMs,
|
|
5060
5088
|
rowsTouched: r.rowsTouched,
|
|
@@ -5062,11 +5090,11 @@ ${a.join("\n\n")}\n`);
|
|
|
5062
5090
|
}), i.push(r);
|
|
5063
5091
|
}
|
|
5064
5092
|
return i;
|
|
5065
|
-
},
|
|
5093
|
+
}, xu = async (e, t, n, r) => {
|
|
5066
5094
|
let i = e.find((e) => e.definition.id === t);
|
|
5067
5095
|
if (!i) throw Error(`seed not found: ${t}`);
|
|
5068
|
-
return
|
|
5069
|
-
},
|
|
5096
|
+
return yu(i, n, r);
|
|
5097
|
+
}, Su = /\.seed\.ts$/, Cu = (e) => e.replace(/\.subscribe\.tsx?$/, ""), wu = async (e, n) => {
|
|
5070
5098
|
let r = [];
|
|
5071
5099
|
for (let a of e) {
|
|
5072
5100
|
let e;
|
|
@@ -5092,12 +5120,12 @@ ${a.join("\n\n")}\n`);
|
|
|
5092
5120
|
}
|
|
5093
5121
|
r.push({
|
|
5094
5122
|
file: a,
|
|
5095
|
-
id:
|
|
5123
|
+
id: Cu(i(a)),
|
|
5096
5124
|
definition: s
|
|
5097
5125
|
});
|
|
5098
5126
|
}
|
|
5099
5127
|
return r;
|
|
5100
|
-
},
|
|
5128
|
+
}, Tu = (e, t, n) => {
|
|
5101
5129
|
if (e.length === 0) return () => {};
|
|
5102
5130
|
let r = [];
|
|
5103
5131
|
for (let i of e) {
|
|
@@ -5148,7 +5176,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5148
5176
|
e();
|
|
5149
5177
|
} catch {}
|
|
5150
5178
|
};
|
|
5151
|
-
},
|
|
5179
|
+
}, Eu = (e) => e.replace(/\.reaction\.tsx?$/, ""), Du = async (e, n) => {
|
|
5152
5180
|
let r = [];
|
|
5153
5181
|
for (let a of e) {
|
|
5154
5182
|
let e;
|
|
@@ -5182,12 +5210,12 @@ ${a.join("\n\n")}\n`);
|
|
|
5182
5210
|
}
|
|
5183
5211
|
r.push({
|
|
5184
5212
|
file: a,
|
|
5185
|
-
id:
|
|
5213
|
+
id: Eu(i(a)),
|
|
5186
5214
|
definition: s
|
|
5187
5215
|
});
|
|
5188
5216
|
}
|
|
5189
5217
|
return r;
|
|
5190
|
-
},
|
|
5218
|
+
}, Ou = async (e, t, n) => {
|
|
5191
5219
|
let r = n.findAgentSend(e);
|
|
5192
5220
|
if (r === void 0) {
|
|
5193
5221
|
n.log.warn("reaction agent act — no synthesized agent found (declare a `*.agent.tsx` named this)", { agent: e });
|
|
@@ -5202,7 +5230,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5202
5230
|
subject: n.makeSubject(a),
|
|
5203
5231
|
traceId: `reaction:${e}`
|
|
5204
5232
|
});
|
|
5205
|
-
},
|
|
5233
|
+
}, ku = (e, t, n, r) => {
|
|
5206
5234
|
if (e.length === 0) return () => {};
|
|
5207
5235
|
let i = /* @__PURE__ */ new Set(), a = {
|
|
5208
5236
|
has: (e) => i.has(e),
|
|
@@ -5252,7 +5280,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5252
5280
|
l();
|
|
5253
5281
|
} catch {}
|
|
5254
5282
|
};
|
|
5255
|
-
},
|
|
5283
|
+
}, Au = "_voltro_aggregate_meta", ju = "_voltro_aggregate_rows", Mu = () => {
|
|
5256
5284
|
let e = /* @__PURE__ */ new Map(), t = {
|
|
5257
5285
|
refreshedAt: null,
|
|
5258
5286
|
rowCount: 0,
|
|
@@ -5297,8 +5325,8 @@ ${a.join("\n\n")}\n`);
|
|
|
5297
5325
|
},
|
|
5298
5326
|
refreshMirror: async () => {}
|
|
5299
5327
|
};
|
|
5300
|
-
},
|
|
5301
|
-
CREATE TABLE IF NOT EXISTS ${
|
|
5328
|
+
}, Nu = `
|
|
5329
|
+
CREATE TABLE IF NOT EXISTS ${Au} (
|
|
5302
5330
|
name TEXT PRIMARY KEY,
|
|
5303
5331
|
generation INTEGER NOT NULL DEFAULT 0,
|
|
5304
5332
|
refreshed_at TEXT,
|
|
@@ -5307,24 +5335,24 @@ ${a.join("\n\n")}\n`);
|
|
|
5307
5335
|
last_error TEXT,
|
|
5308
5336
|
next_refresh_at TEXT
|
|
5309
5337
|
);
|
|
5310
|
-
`.trim(),
|
|
5311
|
-
CREATE TABLE IF NOT EXISTS ${
|
|
5338
|
+
`.trim(), Pu = `
|
|
5339
|
+
CREATE TABLE IF NOT EXISTS ${ju} (
|
|
5312
5340
|
aggregate_name TEXT NOT NULL,
|
|
5313
5341
|
generation INTEGER NOT NULL,
|
|
5314
5342
|
row_index INTEGER NOT NULL,
|
|
5315
5343
|
row_data TEXT NOT NULL,
|
|
5316
5344
|
PRIMARY KEY (aggregate_name, generation, row_index)
|
|
5317
5345
|
);
|
|
5318
|
-
`.trim(),
|
|
5319
|
-
CREATE INDEX IF NOT EXISTS ${
|
|
5320
|
-
ON ${
|
|
5321
|
-
`.trim(),
|
|
5346
|
+
`.trim(), Fu = `
|
|
5347
|
+
CREATE INDEX IF NOT EXISTS ${ju}_lookup
|
|
5348
|
+
ON ${ju} (aggregate_name, generation, row_index);
|
|
5349
|
+
`.trim(), Iu = (e) => ({
|
|
5322
5350
|
refreshedAt: e.refreshed_at === null ? null : new Date(e.refreshed_at),
|
|
5323
5351
|
rowCount: e.row_count,
|
|
5324
5352
|
durationMs: e.duration_ms,
|
|
5325
5353
|
lastError: e.last_error,
|
|
5326
5354
|
nextRefreshAt: e.next_refresh_at === null ? null : new Date(e.next_refresh_at)
|
|
5327
|
-
}),
|
|
5355
|
+
}), Lu = (e) => {
|
|
5328
5356
|
let t = /* @__PURE__ */ new Map(), n = {
|
|
5329
5357
|
refreshedAt: null,
|
|
5330
5358
|
rowCount: 0,
|
|
@@ -5333,13 +5361,13 @@ ${a.join("\n\n")}\n`);
|
|
|
5333
5361
|
nextRefreshAt: null
|
|
5334
5362
|
}, r = (t) => y.runPromise(t.pipe(y.provide(e))), i = () => y.gen(function* () {
|
|
5335
5363
|
let e = yield* R.SqlClient;
|
|
5336
|
-
yield* e.unsafe(
|
|
5364
|
+
yield* e.unsafe(Nu).pipe(y.orDie), yield* e.unsafe(Pu).pipe(y.orDie), yield* e.unsafe(Fu).pipe(y.orDie);
|
|
5337
5365
|
}), a = () => y.gen(function* () {
|
|
5338
|
-
let e = yield* R.SqlClient, n = yield* e`SELECT * FROM ${e(
|
|
5366
|
+
let e = yield* R.SqlClient, n = yield* e`SELECT * FROM ${e(Au)}`.pipe(y.orElseSucceed(() => []));
|
|
5339
5367
|
for (let r of n) {
|
|
5340
5368
|
let n = yield* e`
|
|
5341
5369
|
SELECT ${e("row_index")} AS row_index, ${e("row_data")} AS row_data
|
|
5342
|
-
FROM ${e(
|
|
5370
|
+
FROM ${e(ju)}
|
|
5343
5371
|
WHERE ${e("aggregate_name")} = ${r.name}
|
|
5344
5372
|
AND ${e("generation")} = ${r.generation}
|
|
5345
5373
|
ORDER BY ${e("row_index")} ASC
|
|
@@ -5349,17 +5377,17 @@ ${a.join("\n\n")}\n`);
|
|
|
5349
5377
|
} catch {}
|
|
5350
5378
|
t.set(r.name, {
|
|
5351
5379
|
rows: i,
|
|
5352
|
-
meta:
|
|
5380
|
+
meta: Iu(r)
|
|
5353
5381
|
});
|
|
5354
5382
|
}
|
|
5355
5383
|
}), o = (e, t) => y.gen(function* () {
|
|
5356
5384
|
let n = yield* R.SqlClient, r = (yield* n`
|
|
5357
5385
|
SELECT ${n("generation")} AS generation
|
|
5358
|
-
FROM ${n(
|
|
5386
|
+
FROM ${n(Au)}
|
|
5359
5387
|
WHERE ${n("name")} = ${e}
|
|
5360
5388
|
`.pipe(y.orElseSucceed(() => [])))[0]?.generation ?? 0, i = r + 1;
|
|
5361
5389
|
yield* n`
|
|
5362
|
-
UPDATE ${n(
|
|
5390
|
+
UPDATE ${n(Au)} SET
|
|
5363
5391
|
${n("generation")} = ${i},
|
|
5364
5392
|
${n("refreshed_at")} = ${t.meta.refreshedAt ? t.meta.refreshedAt.toISOString() : null},
|
|
5365
5393
|
${n("duration_ms")} = ${t.meta.durationMs},
|
|
@@ -5368,7 +5396,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5368
5396
|
${n("next_refresh_at")} = ${t.meta.nextRefreshAt ? t.meta.nextRefreshAt.toISOString() : null}
|
|
5369
5397
|
WHERE ${n("name")} = ${e}
|
|
5370
5398
|
`.pipe(y.orDie), r === 0 && (yield* n`
|
|
5371
|
-
INSERT INTO ${n(
|
|
5399
|
+
INSERT INTO ${n(Au)}
|
|
5372
5400
|
(${n("name")}, ${n("generation")}, ${n("refreshed_at")},
|
|
5373
5401
|
${n("duration_ms")}, ${n("row_count")}, ${n("last_error")}, ${n("next_refresh_at")})
|
|
5374
5402
|
VALUES
|
|
@@ -5379,21 +5407,21 @@ ${a.join("\n\n")}\n`);
|
|
|
5379
5407
|
for (let r = 0; r < t.rows.length; r++) {
|
|
5380
5408
|
let a = JSON.stringify(t.rows[r]);
|
|
5381
5409
|
yield* n`
|
|
5382
|
-
INSERT INTO ${n(
|
|
5410
|
+
INSERT INTO ${n(ju)}
|
|
5383
5411
|
(${n("aggregate_name")}, ${n("generation")}, ${n("row_index")}, ${n("row_data")})
|
|
5384
5412
|
VALUES
|
|
5385
5413
|
(${e}, ${i}, ${r}, ${a})
|
|
5386
5414
|
`.pipe(y.orDie);
|
|
5387
5415
|
}
|
|
5388
5416
|
r > 0 && (yield* n`
|
|
5389
|
-
DELETE FROM ${n(
|
|
5417
|
+
DELETE FROM ${n(ju)}
|
|
5390
5418
|
WHERE ${n("aggregate_name")} = ${e}
|
|
5391
5419
|
AND ${n("generation")} < ${i}
|
|
5392
5420
|
`.pipe(y.orDie));
|
|
5393
5421
|
}), s = (e, t) => y.gen(function* () {
|
|
5394
5422
|
let n = yield* R.SqlClient;
|
|
5395
5423
|
yield* n`
|
|
5396
|
-
UPDATE ${n(
|
|
5424
|
+
UPDATE ${n(Au)} SET
|
|
5397
5425
|
${n("refreshed_at")} = ${t.refreshedAt ? t.refreshedAt.toISOString() : null},
|
|
5398
5426
|
${n("duration_ms")} = ${t.durationMs},
|
|
5399
5427
|
${n("row_count")} = ${t.rowCount},
|
|
@@ -5401,10 +5429,10 @@ ${a.join("\n\n")}\n`);
|
|
|
5401
5429
|
${n("next_refresh_at")} = ${t.nextRefreshAt ? t.nextRefreshAt.toISOString() : null}
|
|
5402
5430
|
WHERE ${n("name")} = ${e}
|
|
5403
5431
|
`.pipe(y.orDie), (yield* n`
|
|
5404
|
-
SELECT ${n("name")} FROM ${n(
|
|
5432
|
+
SELECT ${n("name")} FROM ${n(Au)}
|
|
5405
5433
|
WHERE ${n("name")} = ${e}
|
|
5406
5434
|
`.pipe(y.orElseSucceed(() => []))).length === 0 && (yield* n`
|
|
5407
|
-
INSERT INTO ${n(
|
|
5435
|
+
INSERT INTO ${n(Au)}
|
|
5408
5436
|
(${n("name")}, ${n("generation")}, ${n("refreshed_at")},
|
|
5409
5437
|
${n("duration_ms")}, ${n("row_count")}, ${n("last_error")}, ${n("next_refresh_at")})
|
|
5410
5438
|
VALUES
|
|
@@ -5453,13 +5481,13 @@ ${a.join("\n\n")}\n`);
|
|
|
5453
5481
|
refreshMirror: async (e) => {
|
|
5454
5482
|
await r(y.gen(function* () {
|
|
5455
5483
|
let n = yield* R.SqlClient, r = (yield* n`
|
|
5456
|
-
SELECT * FROM ${n(
|
|
5484
|
+
SELECT * FROM ${n(Au)}
|
|
5457
5485
|
WHERE ${n("name")} = ${e}
|
|
5458
5486
|
`.pipe(y.orElseSucceed(() => [])))[0];
|
|
5459
5487
|
if (!r) return;
|
|
5460
5488
|
let i = yield* n`
|
|
5461
5489
|
SELECT ${n("row_index")} AS row_index, ${n("row_data")} AS row_data
|
|
5462
|
-
FROM ${n(
|
|
5490
|
+
FROM ${n(ju)}
|
|
5463
5491
|
WHERE ${n("aggregate_name")} = ${e}
|
|
5464
5492
|
AND ${n("generation")} = ${r.generation}
|
|
5465
5493
|
ORDER BY ${n("row_index")} ASC
|
|
@@ -5469,12 +5497,12 @@ ${a.join("\n\n")}\n`);
|
|
|
5469
5497
|
} catch {}
|
|
5470
5498
|
t.set(e, {
|
|
5471
5499
|
rows: a,
|
|
5472
|
-
meta:
|
|
5500
|
+
meta: Iu(r)
|
|
5473
5501
|
});
|
|
5474
5502
|
}));
|
|
5475
5503
|
}
|
|
5476
5504
|
};
|
|
5477
|
-
},
|
|
5505
|
+
}, Ru = (e) => e.replace(/\.aggregate\.tsx?$/, ""), zu = async (e, n) => {
|
|
5478
5506
|
let r = [], a = /* @__PURE__ */ new Set();
|
|
5479
5507
|
for (let o of e) {
|
|
5480
5508
|
let e;
|
|
@@ -5493,11 +5521,11 @@ ${a.join("\n\n")}\n`);
|
|
|
5493
5521
|
a.add(s.name), r.push({
|
|
5494
5522
|
file: o,
|
|
5495
5523
|
definition: s
|
|
5496
|
-
}),
|
|
5524
|
+
}), Ru(i(o));
|
|
5497
5525
|
}
|
|
5498
5526
|
return r;
|
|
5499
|
-
},
|
|
5500
|
-
let t =
|
|
5527
|
+
}, Bu = /^(\d+)(ms|s|m|h|d)$/, Vu = (e) => {
|
|
5528
|
+
let t = Bu.exec(e.trim());
|
|
5501
5529
|
if (!t) throw Error(`aggregate: invalid refresh interval '${e}' — expected '<n><ms|s|m|h|d>' (e.g. '5m', '1h', '500ms')`);
|
|
5502
5530
|
let n = Number(t[1]);
|
|
5503
5531
|
switch (t[2]) {
|
|
@@ -5508,18 +5536,18 @@ ${a.join("\n\n")}\n`);
|
|
|
5508
5536
|
case "d": return n * 864e5;
|
|
5509
5537
|
}
|
|
5510
5538
|
throw Error("unreachable");
|
|
5511
|
-
},
|
|
5539
|
+
}, Hu = (e, t, n) => {
|
|
5512
5540
|
if (t === void 0) return e;
|
|
5513
5541
|
let r = n === "desc" ? -1 : 1;
|
|
5514
5542
|
return [...e].sort((e, n) => {
|
|
5515
5543
|
let i = e[t], a = n[t];
|
|
5516
5544
|
return i === a ? 0 : i == null ? -1 * r : a == null ? 1 * r : i < a ? -1 * r : i > a ? 1 * r : 0;
|
|
5517
5545
|
});
|
|
5518
|
-
},
|
|
5546
|
+
}, Uu = (e, t, n) => {
|
|
5519
5547
|
if (n === void 0 && t === void 0) return e;
|
|
5520
5548
|
let r = n ?? 0, i = t === void 0 ? e.length : r + t;
|
|
5521
5549
|
return e.slice(r, i);
|
|
5522
|
-
},
|
|
5550
|
+
}, Wu = (e, t) => {
|
|
5523
5551
|
let n = E.decodeUnknownEither(e.output), r = [];
|
|
5524
5552
|
for (let e = 0; e < t.length; e++) {
|
|
5525
5553
|
let i = n(t[e]);
|
|
@@ -5536,7 +5564,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5536
5564
|
ok: !0,
|
|
5537
5565
|
rows: r
|
|
5538
5566
|
};
|
|
5539
|
-
},
|
|
5567
|
+
}, Gu = (e, t) => {
|
|
5540
5568
|
let n = e.refresh;
|
|
5541
5569
|
if (n.cron) {
|
|
5542
5570
|
let e = n.timezone ?? "UTC", r = _.unsafeParse(n.cron, e);
|
|
@@ -5547,7 +5575,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5547
5575
|
};
|
|
5548
5576
|
}
|
|
5549
5577
|
if (n.interval) {
|
|
5550
|
-
let e =
|
|
5578
|
+
let e = Vu(n.interval);
|
|
5551
5579
|
return {
|
|
5552
5580
|
intervalMs: e,
|
|
5553
5581
|
nextAt: new Date(t.getTime() + e),
|
|
@@ -5563,7 +5591,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5563
5591
|
nextAt: null,
|
|
5564
5592
|
kind: "none"
|
|
5565
5593
|
};
|
|
5566
|
-
},
|
|
5594
|
+
}, Ku = async (e) => {
|
|
5567
5595
|
let { definition: t, store: n, analytics: r, storage: i, coordinator: a, log: o, refreshState: s, scheduledAt: c } = e;
|
|
5568
5596
|
if (s.inFlight) {
|
|
5569
5597
|
o.warn("aggregate: refresh overlap, skipping", { name: t.name });
|
|
@@ -5574,7 +5602,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5574
5602
|
try {
|
|
5575
5603
|
if (!await a.tryClaim(t.name, c)) {
|
|
5576
5604
|
l.info("refresh skipped — coordination claim lost");
|
|
5577
|
-
let { nextAt: e } =
|
|
5605
|
+
let { nextAt: e } = Gu(t, /* @__PURE__ */ new Date()), n = i.get(t.name);
|
|
5578
5606
|
await i.updateMeta(t.name, {
|
|
5579
5607
|
...n.meta,
|
|
5580
5608
|
nextRefreshAt: e
|
|
@@ -5586,7 +5614,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5586
5614
|
analytics: r,
|
|
5587
5615
|
log: l,
|
|
5588
5616
|
id: t.name
|
|
5589
|
-
}), o =
|
|
5617
|
+
}), o = Wu(t, e instanceof Promise ? await e : await y.runPromise(e));
|
|
5590
5618
|
if (!o.ok) throw Error(`output schema mismatch: ${o.reason}`);
|
|
5591
5619
|
let s = o.rows;
|
|
5592
5620
|
if (t.strategy === "merge") {
|
|
@@ -5612,7 +5640,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5612
5640
|
droppedCount: a
|
|
5613
5641
|
}), s = Array.from(r.values());
|
|
5614
5642
|
}
|
|
5615
|
-
let d = Date.now() - u, { nextAt: f } =
|
|
5643
|
+
let d = Date.now() - u, { nextAt: f } = Gu(t, /* @__PURE__ */ new Date()), p = {
|
|
5616
5644
|
refreshedAt: /* @__PURE__ */ new Date(),
|
|
5617
5645
|
rowCount: s.length,
|
|
5618
5646
|
durationMs: d,
|
|
@@ -5629,7 +5657,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5629
5657
|
durationMs: d
|
|
5630
5658
|
});
|
|
5631
5659
|
} catch (e) {
|
|
5632
|
-
let n = e instanceof Error ? `${e.name}: ${e.message}` : String(e), r = i.get(t.name), { nextAt: a } =
|
|
5660
|
+
let n = e instanceof Error ? `${e.name}: ${e.message}` : String(e), r = i.get(t.name), { nextAt: a } = Gu(t, /* @__PURE__ */ new Date());
|
|
5633
5661
|
await i.updateMeta(t.name, {
|
|
5634
5662
|
...r.meta,
|
|
5635
5663
|
lastError: n,
|
|
@@ -5642,23 +5670,23 @@ ${a.join("\n\n")}\n`);
|
|
|
5642
5670
|
} finally {
|
|
5643
5671
|
s.inFlight = !1;
|
|
5644
5672
|
}
|
|
5645
|
-
},
|
|
5673
|
+
}, qu = (e) => {
|
|
5646
5674
|
let { definition: t, schedule: n } = e;
|
|
5647
5675
|
n.scheduleTimer !== null && clearTimeout(n.scheduleTimer);
|
|
5648
|
-
let r = /* @__PURE__ */ new Date(), { intervalMs: i, nextAt: a, kind: o } =
|
|
5676
|
+
let r = /* @__PURE__ */ new Date(), { intervalMs: i, nextAt: a, kind: o } = Gu(t, r);
|
|
5649
5677
|
if (o === "none" && !t.refresh.onChange) {
|
|
5650
5678
|
e.log.warn("aggregate: no refresh policy that auto-fires", { name: t.name });
|
|
5651
5679
|
return;
|
|
5652
5680
|
}
|
|
5653
5681
|
if (a === null) return;
|
|
5654
5682
|
let s = Math.max(0, a.getTime() - r.getTime()), c = setTimeout(async () => {
|
|
5655
|
-
await
|
|
5683
|
+
await Ku({
|
|
5656
5684
|
...e,
|
|
5657
5685
|
scheduledAt: a
|
|
5658
|
-
}),
|
|
5686
|
+
}), qu(e);
|
|
5659
5687
|
}, s);
|
|
5660
5688
|
c.unref(), n.scheduleTimer = c;
|
|
5661
|
-
},
|
|
5689
|
+
}, Ju = (e) => {
|
|
5662
5690
|
let { definition: t, store: n, schedule: r, log: i } = e, a = t.refresh.onChange;
|
|
5663
5691
|
if (!a || a.length === 0) return;
|
|
5664
5692
|
let o = t.refresh.debounceMs ?? 3e4, s = new Set(a);
|
|
@@ -5666,7 +5694,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5666
5694
|
if (!s.has(t.table)) return;
|
|
5667
5695
|
r.debounceTimer !== null && clearTimeout(r.debounceTimer);
|
|
5668
5696
|
let n = setTimeout(async () => {
|
|
5669
|
-
r.debounceTimer = null, await
|
|
5697
|
+
r.debounceTimer = null, await Ku({
|
|
5670
5698
|
...e,
|
|
5671
5699
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
5672
5700
|
});
|
|
@@ -5677,7 +5705,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5677
5705
|
tables: a,
|
|
5678
5706
|
debounceMs: o
|
|
5679
5707
|
});
|
|
5680
|
-
},
|
|
5708
|
+
}, Yu = (e) => {
|
|
5681
5709
|
let { definition: t, store: n, storage: r, log: i, schedule: a } = e, o = t.incremental;
|
|
5682
5710
|
if (o === void 0) return;
|
|
5683
5711
|
let s = i.child(`aggregate:${t.name}`), c = new F({
|
|
@@ -5692,7 +5720,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5692
5720
|
skip: void 0,
|
|
5693
5721
|
projection: void 0
|
|
5694
5722
|
}), u = async () => {
|
|
5695
|
-
let e = c.materialize().map((e) => o.toRow(e)), n =
|
|
5723
|
+
let e = c.materialize().map((e) => o.toRow(e)), n = Wu(t, e);
|
|
5696
5724
|
if (!n.ok) {
|
|
5697
5725
|
s.warn("incremental: output schema mismatch — keeping last-good", { reason: n.reason });
|
|
5698
5726
|
return;
|
|
@@ -5736,12 +5764,12 @@ ${a.join("\n\n")}\n`);
|
|
|
5736
5764
|
op: o.op
|
|
5737
5765
|
});
|
|
5738
5766
|
})();
|
|
5739
|
-
let p = t.refresh, m = p.interval === void 0 ? 5 * 6e4 :
|
|
5767
|
+
let p = t.refresh, m = p.interval === void 0 ? 5 * 6e4 : Vu(p.interval), h = setInterval(() => {
|
|
5740
5768
|
d().catch(() => void 0);
|
|
5741
5769
|
}, m);
|
|
5742
5770
|
h.unref(), a.scheduleTimer = h;
|
|
5743
|
-
},
|
|
5744
|
-
let t = e.storage ??
|
|
5771
|
+
}, Xu = async (e) => {
|
|
5772
|
+
let t = e.storage ?? Mu(), n = e.coordinator ?? Mt, r = e.analytics ?? ht(), i = e.log;
|
|
5745
5773
|
await t.initialize();
|
|
5746
5774
|
let a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = {
|
|
5747
5775
|
refreshedAt: null,
|
|
@@ -5760,7 +5788,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5760
5788
|
detachOnChange: null
|
|
5761
5789
|
};
|
|
5762
5790
|
a.set(u.name, f), u.incremental !== void 0 || (u.bootRefresh === "async" ? (await t.updateMeta(u.name, c), setImmediate(async () => {
|
|
5763
|
-
await
|
|
5791
|
+
await Ku({
|
|
5764
5792
|
definition: u,
|
|
5765
5793
|
store: e.store,
|
|
5766
5794
|
analytics: r,
|
|
@@ -5771,7 +5799,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5771
5799
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
5772
5800
|
});
|
|
5773
5801
|
})) : u.bootRefresh === "sync" ? l.push(async () => {
|
|
5774
|
-
await
|
|
5802
|
+
await Ku({
|
|
5775
5803
|
definition: u,
|
|
5776
5804
|
store: e.store,
|
|
5777
5805
|
analytics: r,
|
|
@@ -5782,7 +5810,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5782
5810
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
5783
5811
|
});
|
|
5784
5812
|
}) : await t.load(u.name) === null && setImmediate(async () => {
|
|
5785
|
-
await
|
|
5813
|
+
await Ku({
|
|
5786
5814
|
definition: u,
|
|
5787
5815
|
store: e.store,
|
|
5788
5816
|
analytics: r,
|
|
@@ -5792,7 +5820,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5792
5820
|
refreshState: d,
|
|
5793
5821
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
5794
5822
|
});
|
|
5795
|
-
})), u.incremental === void 0 ? (
|
|
5823
|
+
})), u.incremental === void 0 ? (qu({
|
|
5796
5824
|
definition: u,
|
|
5797
5825
|
store: e.store,
|
|
5798
5826
|
analytics: r,
|
|
@@ -5801,7 +5829,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5801
5829
|
log: i,
|
|
5802
5830
|
schedule: f,
|
|
5803
5831
|
refreshState: d
|
|
5804
|
-
}),
|
|
5832
|
+
}), Ju({
|
|
5805
5833
|
definition: u,
|
|
5806
5834
|
store: e.store,
|
|
5807
5835
|
analytics: r,
|
|
@@ -5810,7 +5838,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5810
5838
|
log: i,
|
|
5811
5839
|
schedule: f,
|
|
5812
5840
|
refreshState: d
|
|
5813
|
-
})) :
|
|
5841
|
+
})) : Yu({
|
|
5814
5842
|
definition: u,
|
|
5815
5843
|
store: e.store,
|
|
5816
5844
|
storage: t,
|
|
@@ -5834,11 +5862,11 @@ ${a.join("\n\n")}\n`);
|
|
|
5834
5862
|
maxAgeMs: e.maxAgeMs
|
|
5835
5863
|
}));
|
|
5836
5864
|
}
|
|
5837
|
-
return
|
|
5865
|
+
return Uu(Hu(n.rows, e?.orderBy, e?.direction), e?.limit, e?.offset);
|
|
5838
5866
|
}),
|
|
5839
5867
|
meta: () => y.succeed(t.get(a.name).meta),
|
|
5840
5868
|
refresh: () => y.tryPromise({
|
|
5841
|
-
try: () =>
|
|
5869
|
+
try: () => Ku({
|
|
5842
5870
|
definition: s.get(a.name),
|
|
5843
5871
|
store: e.store,
|
|
5844
5872
|
analytics: r,
|
|
@@ -5866,7 +5894,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5866
5894
|
})),
|
|
5867
5895
|
refreshByName: async (a) => {
|
|
5868
5896
|
let c = s.get(a);
|
|
5869
|
-
return c ? (await
|
|
5897
|
+
return c ? (await Ku({
|
|
5870
5898
|
definition: c,
|
|
5871
5899
|
store: e.store,
|
|
5872
5900
|
analytics: r,
|
|
@@ -5888,7 +5916,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5888
5916
|
},
|
|
5889
5917
|
registered: Array.from(s.keys())
|
|
5890
5918
|
};
|
|
5891
|
-
},
|
|
5919
|
+
}, Zu = {
|
|
5892
5920
|
getHandle: (e) => ({
|
|
5893
5921
|
read: () => y.fail(new de({ name: e.name })),
|
|
5894
5922
|
meta: () => y.succeed({
|
|
@@ -5902,52 +5930,52 @@ ${a.join("\n\n")}\n`);
|
|
|
5902
5930
|
}),
|
|
5903
5931
|
snapshot: () => [],
|
|
5904
5932
|
refreshByName: async () => !1
|
|
5905
|
-
},
|
|
5933
|
+
}, Qu = "/_voltro/inspect/aggregates", $u = /^\/_voltro\/inspect\/aggregates\/([^/]+)\/refresh$/, ed = (e, t, n) => ({
|
|
5906
5934
|
status: e,
|
|
5907
5935
|
contentType: "application/json; charset=utf-8",
|
|
5908
5936
|
body: JSON.stringify(t),
|
|
5909
5937
|
...n ? { headers: n } : {}
|
|
5910
|
-
}),
|
|
5938
|
+
}), td = (e) => ({
|
|
5911
5939
|
refreshedAt: e.refreshedAt === null ? null : e.refreshedAt.toISOString(),
|
|
5912
5940
|
rowCount: e.rowCount,
|
|
5913
5941
|
durationMs: e.durationMs,
|
|
5914
5942
|
lastError: e.lastError,
|
|
5915
5943
|
nextRefreshAt: e.nextRefreshAt === null ? null : e.nextRefreshAt.toISOString()
|
|
5916
|
-
}),
|
|
5917
|
-
if (!e.startsWith(
|
|
5944
|
+
}), nd = async (e, t, n, r) => {
|
|
5945
|
+
if (!e.startsWith(Qu)) return null;
|
|
5918
5946
|
if (t === "POST") {
|
|
5919
|
-
let t =
|
|
5947
|
+
let t = $u.exec(e);
|
|
5920
5948
|
if (t) {
|
|
5921
5949
|
let e = decodeURIComponent(t[1]);
|
|
5922
|
-
if (!await n.refreshByName(e)) return
|
|
5950
|
+
if (!await n.refreshByName(e)) return ed(404, {
|
|
5923
5951
|
error: "aggregate not found",
|
|
5924
5952
|
name: e
|
|
5925
5953
|
}, r);
|
|
5926
5954
|
let i = n.snapshot().find((t) => t.name === e);
|
|
5927
|
-
return
|
|
5955
|
+
return ed(200, {
|
|
5928
5956
|
ok: !0,
|
|
5929
5957
|
name: e,
|
|
5930
|
-
meta: i ?
|
|
5958
|
+
meta: i ? td(i.meta) : null
|
|
5931
5959
|
}, r);
|
|
5932
5960
|
}
|
|
5933
|
-
return
|
|
5961
|
+
return ed(405, {
|
|
5934
5962
|
error: "method not allowed",
|
|
5935
5963
|
allow: "GET, POST <name>/refresh"
|
|
5936
5964
|
}, r);
|
|
5937
5965
|
}
|
|
5938
|
-
return t === "GET" && (e ===
|
|
5966
|
+
return t === "GET" && (e === Qu || e.startsWith(`${Qu}?`)) ? ed(200, {
|
|
5939
5967
|
aggregates: n.snapshot().map((e) => ({
|
|
5940
5968
|
name: e.name,
|
|
5941
|
-
meta:
|
|
5969
|
+
meta: td(e.meta)
|
|
5942
5970
|
})),
|
|
5943
5971
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5944
5972
|
}, r) : null;
|
|
5945
|
-
},
|
|
5973
|
+
}, rd = "/_voltro/inspect/analytics", id = (e, t, n) => ({
|
|
5946
5974
|
status: e,
|
|
5947
5975
|
contentType: "application/json; charset=utf-8",
|
|
5948
5976
|
body: JSON.stringify(t),
|
|
5949
5977
|
...n ? { headers: n } : {}
|
|
5950
|
-
}),
|
|
5978
|
+
}), ad = (e, t) => {
|
|
5951
5979
|
let n = e.snapshot(t).buckets.filter((e) => e.kind === "plugin"), r = 0, i = 0, a = n.map((e) => (r += e.count, i += e.errorCount, {
|
|
5952
5980
|
tag: e.tag,
|
|
5953
5981
|
count: e.count,
|
|
@@ -5960,9 +5988,9 @@ ${a.join("\n\n")}\n`);
|
|
|
5960
5988
|
errorCount: i,
|
|
5961
5989
|
tags: a
|
|
5962
5990
|
};
|
|
5963
|
-
},
|
|
5964
|
-
if (e !==
|
|
5965
|
-
if (t !== "GET") return
|
|
5991
|
+
}, od = (e, t, n, r) => {
|
|
5992
|
+
if (e !== rd && !e.startsWith(`${rd}?`)) return null;
|
|
5993
|
+
if (t !== "GET") return id(405, {
|
|
5966
5994
|
error: "method not allowed",
|
|
5967
5995
|
allow: "GET"
|
|
5968
5996
|
}, r);
|
|
@@ -5971,8 +5999,8 @@ ${a.join("\n\n")}\n`);
|
|
|
5971
5999
|
if (e === null) return 6e4;
|
|
5972
6000
|
let t = Number(e);
|
|
5973
6001
|
return Number.isFinite(t) && t > 0 ? Math.min(t, 1440 * 6e4) : 6e4;
|
|
5974
|
-
})(), s =
|
|
5975
|
-
return
|
|
6002
|
+
})(), s = ad(n.metricsCollector, o);
|
|
6003
|
+
return id(200, {
|
|
5976
6004
|
provider: n.sink.info.provider,
|
|
5977
6005
|
capabilities: n.sink.info.capabilities,
|
|
5978
6006
|
detail: n.sink.info.detail ?? null,
|
|
@@ -5984,40 +6012,40 @@ ${a.join("\n\n")}\n`);
|
|
|
5984
6012
|
},
|
|
5985
6013
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5986
6014
|
}, r);
|
|
5987
|
-
},
|
|
6015
|
+
}, sd = "/_voltro/inspect/timeline", cd = "/_voltro/inspect/timeline/replay", ld = (e, t, n) => ({
|
|
5988
6016
|
status: e,
|
|
5989
6017
|
contentType: "application/json; charset=utf-8",
|
|
5990
6018
|
body: JSON.stringify(t),
|
|
5991
6019
|
...n ? { headers: n } : {}
|
|
5992
|
-
}),
|
|
6020
|
+
}), ud = (e) => {
|
|
5993
6021
|
let t = e.indexOf("?");
|
|
5994
6022
|
return new URLSearchParams(t >= 0 ? e.slice(t + 1) : "");
|
|
5995
|
-
},
|
|
6023
|
+
}, dd = (e, t) => {
|
|
5996
6024
|
let n = e.get(t);
|
|
5997
6025
|
if (n === null) return;
|
|
5998
6026
|
let r = Number(n);
|
|
5999
6027
|
return Number.isFinite(r) ? r : void 0;
|
|
6000
|
-
},
|
|
6001
|
-
if (!e.startsWith(
|
|
6002
|
-
if (t !== "GET") return
|
|
6028
|
+
}, fd = async (e, t, n, r) => {
|
|
6029
|
+
if (!e.startsWith(sd)) return null;
|
|
6030
|
+
if (t !== "GET") return ld(405, {
|
|
6003
6031
|
error: "method not allowed",
|
|
6004
6032
|
allow: "GET"
|
|
6005
6033
|
}, r);
|
|
6006
|
-
let i =
|
|
6007
|
-
if (e ===
|
|
6008
|
-
let e = i.get("table"), t =
|
|
6009
|
-
if (e === null || t === void 0) return
|
|
6034
|
+
let i = ud(e);
|
|
6035
|
+
if (e === cd || e.startsWith(`${cd}?`)) {
|
|
6036
|
+
let e = i.get("table"), t = dd(i, "seq");
|
|
6037
|
+
if (e === null || t === void 0) return ld(400, { error: "replay requires ?table=<name>&seq=<n>" }, r);
|
|
6010
6038
|
let a;
|
|
6011
6039
|
try {
|
|
6012
6040
|
a = await n.readCurrentRows(e);
|
|
6013
6041
|
} catch (t) {
|
|
6014
|
-
return
|
|
6042
|
+
return ld(404, {
|
|
6015
6043
|
error: "unknown or unreadable table",
|
|
6016
6044
|
table: e,
|
|
6017
6045
|
reason: String(t?.message ?? t)
|
|
6018
6046
|
}, r);
|
|
6019
6047
|
}
|
|
6020
|
-
return
|
|
6048
|
+
return ld(200, {
|
|
6021
6049
|
table: e,
|
|
6022
6050
|
asOfSeq: t,
|
|
6023
6051
|
currentSeq: n.recorder.currentSeq(),
|
|
@@ -6025,15 +6053,15 @@ ${a.join("\n\n")}\n`);
|
|
|
6025
6053
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6026
6054
|
}, r);
|
|
6027
6055
|
}
|
|
6028
|
-
if (e ===
|
|
6029
|
-
let e = i.get("table"), t = i.get("tenantId"), a =
|
|
6056
|
+
if (e === sd || e.startsWith(`${sd}?`)) {
|
|
6057
|
+
let e = i.get("table"), t = i.get("tenantId"), a = dd(i, "from"), o = dd(i, "to"), s = dd(i, "limit"), c = {
|
|
6030
6058
|
...e === null ? {} : { table: e },
|
|
6031
6059
|
...t === null ? {} : { tenantId: t },
|
|
6032
6060
|
...a === void 0 ? {} : { from: a },
|
|
6033
6061
|
...o === void 0 ? {} : { to: o },
|
|
6034
6062
|
...s === void 0 ? {} : { limit: s }
|
|
6035
6063
|
};
|
|
6036
|
-
return
|
|
6064
|
+
return ld(200, {
|
|
6037
6065
|
enabled: n.recorder.enabled,
|
|
6038
6066
|
currentSeq: n.recorder.currentSeq(),
|
|
6039
6067
|
events: n.recorder.snapshot(c),
|
|
@@ -6041,7 +6069,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6041
6069
|
}, r);
|
|
6042
6070
|
}
|
|
6043
6071
|
return null;
|
|
6044
|
-
},
|
|
6072
|
+
}, pd = /\.webhook\.tsx?$/, md = async (e, n) => {
|
|
6045
6073
|
let r = [], i = [], a = [];
|
|
6046
6074
|
for (let o of e) {
|
|
6047
6075
|
let e;
|
|
@@ -6082,7 +6110,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6082
6110
|
incoming: i,
|
|
6083
6111
|
providers: a
|
|
6084
6112
|
};
|
|
6085
|
-
},
|
|
6113
|
+
}, hd = /\.email\.tsx?$/, gd = async (e, t) => {
|
|
6086
6114
|
let n = [];
|
|
6087
6115
|
for (let r of e) {
|
|
6088
6116
|
let e;
|
|
@@ -6103,7 +6131,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6103
6131
|
});
|
|
6104
6132
|
}
|
|
6105
6133
|
return { templates: n };
|
|
6106
|
-
},
|
|
6134
|
+
}, _d = (e) => y.map(e, (e) => ({ text: e })), vd = (e) => {
|
|
6107
6135
|
let { descriptor: t, executor: n, file: r } = e, { send: i, messages: a } = vn(t);
|
|
6108
6136
|
return [{
|
|
6109
6137
|
kind: "action",
|
|
@@ -6120,7 +6148,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6120
6148
|
store: t.store,
|
|
6121
6149
|
request: t.request
|
|
6122
6150
|
}
|
|
6123
|
-
}).pipe(
|
|
6151
|
+
}).pipe(_d);
|
|
6124
6152
|
}
|
|
6125
6153
|
}, {
|
|
6126
6154
|
kind: "query",
|
|
@@ -6128,28 +6156,28 @@ ${a.join("\n\n")}\n`);
|
|
|
6128
6156
|
descriptor: a,
|
|
6129
6157
|
executor: (e, t) => mn(t.store, e.threadId)
|
|
6130
6158
|
}];
|
|
6131
|
-
},
|
|
6159
|
+
}, yd = "<builtin:undo>", bd = () => Lt() ? {
|
|
6132
6160
|
queries: [{
|
|
6133
|
-
file:
|
|
6161
|
+
file: yd,
|
|
6134
6162
|
descriptor: Ar,
|
|
6135
6163
|
executor: (e, t) => Rt(e, t)
|
|
6136
6164
|
}],
|
|
6137
6165
|
mutations: [{
|
|
6138
|
-
file:
|
|
6166
|
+
file: yd,
|
|
6139
6167
|
descriptor: kr,
|
|
6140
6168
|
executor: (e, t) => Oe(e, t)
|
|
6141
6169
|
}, {
|
|
6142
|
-
file:
|
|
6170
|
+
file: yd,
|
|
6143
6171
|
descriptor: jr,
|
|
6144
6172
|
executor: (e, t) => St(e, t)
|
|
6145
6173
|
}]
|
|
6146
6174
|
} : {
|
|
6147
6175
|
queries: [],
|
|
6148
6176
|
mutations: []
|
|
6149
|
-
},
|
|
6177
|
+
}, xd = () => Lt() ? (e) => lt(e) : (e) => ({
|
|
6150
6178
|
tx: e,
|
|
6151
6179
|
persist: async () => {}
|
|
6152
|
-
}),
|
|
6180
|
+
}), Sd = {
|
|
6153
6181
|
interceptMutation: "rpc:intercept:mutation",
|
|
6154
6182
|
interceptQuery: "rpc:intercept:query",
|
|
6155
6183
|
interceptAction: "rpc:intercept:action",
|
|
@@ -6159,38 +6187,38 @@ ${a.join("\n\n")}\n`);
|
|
|
6159
6187
|
onChangeEvent: "store:changes:read",
|
|
6160
6188
|
inspectEndpoints: "inspect:read",
|
|
6161
6189
|
dashboard: "dashboard:mount"
|
|
6162
|
-
},
|
|
6190
|
+
}, Cd = {
|
|
6163
6191
|
tables: "store:write",
|
|
6164
6192
|
migrations: "migration:run"
|
|
6165
|
-
},
|
|
6193
|
+
}, wd = (e) => {
|
|
6166
6194
|
let t = new Set(e.permissions ?? []), n = [];
|
|
6167
|
-
for (let [r, i] of Object.entries(
|
|
6195
|
+
for (let [r, i] of Object.entries(Sd)) {
|
|
6168
6196
|
let a = e[r];
|
|
6169
6197
|
a !== void 0 && (Array.isArray(a) && a.length === 0 || t.has(i) || n.push({
|
|
6170
6198
|
hook: r,
|
|
6171
6199
|
required: i
|
|
6172
6200
|
}));
|
|
6173
6201
|
}
|
|
6174
|
-
return e.extendSchema !== void 0 && (e.extendSchema.tables && e.extendSchema.tables.length > 0 && (t.has(
|
|
6202
|
+
return e.extendSchema !== void 0 && (e.extendSchema.tables && e.extendSchema.tables.length > 0 && (t.has(Cd.tables) || n.push({
|
|
6175
6203
|
hook: "extendSchema.tables",
|
|
6176
|
-
required:
|
|
6177
|
-
})), e.extendSchema.migrations && e.extendSchema.migrations.length > 0 && (t.has(
|
|
6204
|
+
required: Cd.tables
|
|
6205
|
+
})), e.extendSchema.migrations && e.extendSchema.migrations.length > 0 && (t.has(Cd.migrations) || n.push({
|
|
6178
6206
|
hook: "extendSchema.migrations",
|
|
6179
|
-
required:
|
|
6207
|
+
required: Cd.migrations
|
|
6180
6208
|
}))), {
|
|
6181
6209
|
pluginName: e.name,
|
|
6182
6210
|
missing: n
|
|
6183
6211
|
};
|
|
6184
|
-
},
|
|
6185
|
-
let t = e.map(
|
|
6212
|
+
}, Td = (e) => {
|
|
6213
|
+
let t = e.map(wd);
|
|
6186
6214
|
return {
|
|
6187
6215
|
ok: t.every((e) => e.missing.length === 0),
|
|
6188
6216
|
reports: t
|
|
6189
6217
|
};
|
|
6190
|
-
},
|
|
6218
|
+
}, Ed = (e) => {
|
|
6191
6219
|
let t = e.reports.filter((e) => e.missing.length > 0);
|
|
6192
6220
|
return [`Plugin permission audit failed — ${t.length} plugin(s) ship hooks without the matching declared permission. Add the missing scopes to each plugin's manifest.permissions array:`, ...t.map((e) => ` • ${e.pluginName}:\n` + e.missing.map((e) => ` - ${e.hook} → needs '${e.required}'`).join("\n"))].join("\n");
|
|
6193
|
-
},
|
|
6221
|
+
}, Dd = 5e3, Od = 3e4, kd = async (e, t) => {
|
|
6194
6222
|
let n, r = new Promise((e) => {
|
|
6195
6223
|
n = setTimeout(() => e({ kind: "timeout" }), t);
|
|
6196
6224
|
});
|
|
@@ -6205,7 +6233,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6205
6233
|
} finally {
|
|
6206
6234
|
n && clearTimeout(n);
|
|
6207
6235
|
}
|
|
6208
|
-
},
|
|
6236
|
+
}, Ad = async (e) => {
|
|
6209
6237
|
if (e !== void 0) {
|
|
6210
6238
|
if (typeof e == "object" && e && y.isEffect(e)) {
|
|
6211
6239
|
await y.runPromise(e);
|
|
@@ -6213,8 +6241,8 @@ ${a.join("\n\n")}\n`);
|
|
|
6213
6241
|
}
|
|
6214
6242
|
await Promise.resolve(e);
|
|
6215
6243
|
}
|
|
6216
|
-
},
|
|
6217
|
-
let t = e.deactivateTimeoutMs ??
|
|
6244
|
+
}, jd = /* @__PURE__ */ new Set(), Md = (e) => `${e.name}@${e.version ?? "*"}`, Nd = (e) => {
|
|
6245
|
+
let t = e.deactivateTimeoutMs ?? Dd, n = e.deactivateTotalBudgetMs ?? Od, r = /* @__PURE__ */ new Set(), i = !1, a = /* @__PURE__ */ new Map();
|
|
6218
6246
|
for (let t of e.plugins) {
|
|
6219
6247
|
if (!t.configSchema) {
|
|
6220
6248
|
a.set(t.name, e.pluginConfigs?.[t.name]);
|
|
@@ -6240,9 +6268,9 @@ ${a.join("\n\n")}\n`);
|
|
|
6240
6268
|
});
|
|
6241
6269
|
return {
|
|
6242
6270
|
async activate() {
|
|
6243
|
-
let t =
|
|
6271
|
+
let t = Td(e.plugins);
|
|
6244
6272
|
if (!t.ok) {
|
|
6245
|
-
let n =
|
|
6273
|
+
let n = Ed(t);
|
|
6246
6274
|
throw e.log.error(n), Error(n);
|
|
6247
6275
|
}
|
|
6248
6276
|
let n = (process.env.VOLTRO_STRICT_PLUGIN_COMPAT ?? "").toLowerCase(), i = n === "1" || n === "true";
|
|
@@ -6257,10 +6285,10 @@ ${a.join("\n\n")}\n`);
|
|
|
6257
6285
|
}
|
|
6258
6286
|
}
|
|
6259
6287
|
for (let t of e.plugins) {
|
|
6260
|
-
let n =
|
|
6261
|
-
if (!
|
|
6288
|
+
let n = Md(t);
|
|
6289
|
+
if (!jd.has(n) && typeof t.onInstall == "function") try {
|
|
6262
6290
|
let e = o(t);
|
|
6263
|
-
await Promise.resolve().then(() =>
|
|
6291
|
+
await Promise.resolve().then(() => Ad(t.onInstall(e))), jd.add(n);
|
|
6264
6292
|
} catch (n) {
|
|
6265
6293
|
throw e.log.error("plugin onInstall threw — aborting boot", {
|
|
6266
6294
|
plugin: t.name,
|
|
@@ -6274,7 +6302,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6274
6302
|
}
|
|
6275
6303
|
try {
|
|
6276
6304
|
let e = o(t);
|
|
6277
|
-
await Promise.resolve().then(() =>
|
|
6305
|
+
await Promise.resolve().then(() => Ad(t.onActivate(e))), r.add(t.name);
|
|
6278
6306
|
} catch (n) {
|
|
6279
6307
|
throw e.log.error("plugin onActivate threw — aborting boot", {
|
|
6280
6308
|
plugin: t.name,
|
|
@@ -6297,7 +6325,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6297
6325
|
});
|
|
6298
6326
|
break;
|
|
6299
6327
|
}
|
|
6300
|
-
let c = o(i), l = i.onDeactivate, u = await
|
|
6328
|
+
let c = o(i), l = i.onDeactivate, u = await kd(Promise.resolve().then(() => Ad(l(c))), t);
|
|
6301
6329
|
u.kind === "rejected" ? e.log.warn("plugin onDeactivate threw", {
|
|
6302
6330
|
plugin: i.name,
|
|
6303
6331
|
err: u.err
|
|
@@ -6373,16 +6401,16 @@ ${a.join("\n\n")}\n`);
|
|
|
6373
6401
|
services: e.services !== void 0,
|
|
6374
6402
|
hasConfigSchema: e.configSchema !== void 0,
|
|
6375
6403
|
activated: r.has(e.name),
|
|
6376
|
-
installed:
|
|
6404
|
+
installed: jd.has(Md(e))
|
|
6377
6405
|
}));
|
|
6378
6406
|
}
|
|
6379
6407
|
};
|
|
6380
|
-
},
|
|
6408
|
+
}, Pd = {
|
|
6381
6409
|
mutation: "intercept-mutation",
|
|
6382
6410
|
query: "intercept-query",
|
|
6383
6411
|
action: "intercept-action"
|
|
6384
|
-
},
|
|
6385
|
-
let i =
|
|
6412
|
+
}, Fd = (e, t, n, r) => {
|
|
6413
|
+
let i = Pd[t], a = `plugin.${e}.${i}`, o = a;
|
|
6386
6414
|
return (t, s) => y.suspend(() => {
|
|
6387
6415
|
let c = Date.now();
|
|
6388
6416
|
return n(t, s).pipe(y.withSpan(a, { attributes: {
|
|
@@ -6406,17 +6434,17 @@ ${a.join("\n\n")}\n`);
|
|
|
6406
6434
|
});
|
|
6407
6435
|
})));
|
|
6408
6436
|
});
|
|
6409
|
-
},
|
|
6437
|
+
}, Id = (e, t, n) => {
|
|
6410
6438
|
let r = t === "mutation" ? "interceptMutation" : t === "query" ? "interceptQuery" : "interceptAction", i = [];
|
|
6411
6439
|
for (let a of e) {
|
|
6412
6440
|
let e = a[r];
|
|
6413
|
-
typeof e == "function" && i.push(
|
|
6441
|
+
typeof e == "function" && i.push(Fd(a.name, t, e, n));
|
|
6414
6442
|
}
|
|
6415
6443
|
return i;
|
|
6416
|
-
},
|
|
6444
|
+
}, Ld = `${ba}/plugins/`, Rd = (e) => e.startsWith("/") ? e : `/${e}`, zd = (e) => {
|
|
6417
6445
|
let t = e.indexOf("?");
|
|
6418
6446
|
return t >= 0 ? e.slice(0, t) : e;
|
|
6419
|
-
},
|
|
6447
|
+
}, Bd = (e, t) => e.kind === "json" ? {
|
|
6420
6448
|
status: e.status ?? 200,
|
|
6421
6449
|
contentType: "application/json; charset=utf-8",
|
|
6422
6450
|
body: JSON.stringify(e.data),
|
|
@@ -6426,12 +6454,12 @@ ${a.join("\n\n")}\n`);
|
|
|
6426
6454
|
contentType: e.contentType ?? "text/plain; charset=utf-8",
|
|
6427
6455
|
body: e.body,
|
|
6428
6456
|
headers: t
|
|
6429
|
-
},
|
|
6457
|
+
}, Vd = (e) => {
|
|
6430
6458
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
6431
6459
|
for (let r of e) {
|
|
6432
|
-
let e = r.inspectEndpoints ?? [], i =
|
|
6460
|
+
let e = r.inspectEndpoints ?? [], i = Wc(r.name);
|
|
6433
6461
|
for (let a of e) {
|
|
6434
|
-
let e = `${
|
|
6462
|
+
let e = `${Ld}${i}${Rd(a.path)}`, o = `${a.method} ${e}`, s = t.get(o);
|
|
6435
6463
|
if (s !== void 0) throw Error(`plugin inspect endpoint collision: "${a.method} ${e}" declared by plugin "${r.name}" but already claimed by ${s}`);
|
|
6436
6464
|
t.set(o, `plugin "${r.name}"`), n.push({
|
|
6437
6465
|
method: a.method,
|
|
@@ -6445,8 +6473,8 @@ ${a.join("\n\n")}\n`);
|
|
|
6445
6473
|
return {
|
|
6446
6474
|
endpoints: n,
|
|
6447
6475
|
async dispatch(e, t, r, i, a) {
|
|
6448
|
-
let o =
|
|
6449
|
-
if (!o.startsWith(
|
|
6476
|
+
let o = zd(e);
|
|
6477
|
+
if (!o.startsWith(Ld)) return null;
|
|
6450
6478
|
let s = X(r.origin ?? r.Origin), c = t.toUpperCase();
|
|
6451
6479
|
if (c === "OPTIONS") return {
|
|
6452
6480
|
status: 204,
|
|
@@ -6473,7 +6501,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6473
6501
|
let u = n.find((e) => e.method === c && e.path === o);
|
|
6474
6502
|
if (!u) return null;
|
|
6475
6503
|
try {
|
|
6476
|
-
return
|
|
6504
|
+
return Bd(await y.runPromise(u.handler({
|
|
6477
6505
|
method: c,
|
|
6478
6506
|
url: e,
|
|
6479
6507
|
headers: r,
|
|
@@ -6493,7 +6521,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6493
6521
|
}
|
|
6494
6522
|
}
|
|
6495
6523
|
};
|
|
6496
|
-
},
|
|
6524
|
+
}, Hd = (e, t, n) => {
|
|
6497
6525
|
let r = `plugin.${e}.schedule-fire`;
|
|
6498
6526
|
return async (i, a) => {
|
|
6499
6527
|
let o = Date.now();
|
|
@@ -6521,9 +6549,9 @@ ${a.join("\n\n")}\n`);
|
|
|
6521
6549
|
}), e;
|
|
6522
6550
|
}
|
|
6523
6551
|
};
|
|
6524
|
-
},
|
|
6552
|
+
}, Ud = (e, t) => {
|
|
6525
6553
|
let n = [];
|
|
6526
|
-
for (let r of e) typeof r.onScheduleFire == "function" && n.push(
|
|
6554
|
+
for (let r of e) typeof r.onScheduleFire == "function" && n.push(Hd(r.name, r.onScheduleFire, t));
|
|
6527
6555
|
if (n.length !== 0) return async (e, t) => {
|
|
6528
6556
|
let r = e;
|
|
6529
6557
|
for (let e = n.length - 1; e >= 0; e--) {
|
|
@@ -6532,7 +6560,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6532
6560
|
}
|
|
6533
6561
|
return r();
|
|
6534
6562
|
};
|
|
6535
|
-
},
|
|
6563
|
+
}, Wd = (e, t, n) => ((r, i) => {
|
|
6536
6564
|
let a = `plugin.${e}.workflow-step`, o = a, s = Date.now();
|
|
6537
6565
|
return t(r, i).pipe(y.withSpan(a, { attributes: {
|
|
6538
6566
|
"plugin.name": e,
|
|
@@ -6555,16 +6583,16 @@ ${a.join("\n\n")}\n`);
|
|
|
6555
6583
|
status: "error"
|
|
6556
6584
|
});
|
|
6557
6585
|
})));
|
|
6558
|
-
}),
|
|
6586
|
+
}), Gd = (e, t) => {
|
|
6559
6587
|
let n = [];
|
|
6560
|
-
for (let r of e) typeof r.onWorkflowStep == "function" && n.push(
|
|
6588
|
+
for (let r of e) typeof r.onWorkflowStep == "function" && n.push(Wd(r.name, r.onWorkflowStep, t));
|
|
6561
6589
|
return n.length === 0 ? S.succeed(Cn, { interceptor: ((e) => e) }) : S.succeed(Cn, { interceptor: ((e, t) => n.reduceRight((e, n) => n(e, t), e)) });
|
|
6562
|
-
},
|
|
6590
|
+
}, Kd = (e) => {
|
|
6563
6591
|
if (!e) return;
|
|
6564
6592
|
let t = e.workflowName ?? e.tag, n = [];
|
|
6565
6593
|
if (t !== void 0 && n.push(B("tag", t)), e.status !== void 0 && n.push(B("status", e.status)), n.length !== 0) return n.length === 1 ? n[0] : Yn(...n);
|
|
6566
|
-
},
|
|
6567
|
-
let n = Math.max(0, t?.offset ?? 0), r = Math.max(1, Math.min(500, t?.limit ?? 50)), i =
|
|
6594
|
+
}, qd = async (e, t) => {
|
|
6595
|
+
let n = Math.max(0, t?.offset ?? 0), r = Math.max(1, Math.min(500, t?.limit ?? 50)), i = Kd(t);
|
|
6568
6596
|
return {
|
|
6569
6597
|
rows: await e.query({
|
|
6570
6598
|
table: "_voltro_workflow_runs",
|
|
@@ -6588,7 +6616,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6588
6616
|
offset: n,
|
|
6589
6617
|
limit: r
|
|
6590
6618
|
};
|
|
6591
|
-
},
|
|
6619
|
+
}, Jd = (e) => ({
|
|
6592
6620
|
id: e.id,
|
|
6593
6621
|
workflowName: e.tag,
|
|
6594
6622
|
executionId: e.executionId,
|
|
@@ -6603,10 +6631,10 @@ ${a.join("\n\n")}\n`);
|
|
|
6603
6631
|
durationMs: e.durationMs,
|
|
6604
6632
|
traceId: e.traceId,
|
|
6605
6633
|
parentExecutionId: e.parentExecutionId
|
|
6606
|
-
}),
|
|
6607
|
-
let { rows: n } = await
|
|
6608
|
-
return n.map(
|
|
6609
|
-
},
|
|
6634
|
+
}), Yd = async (e, t) => {
|
|
6635
|
+
let { rows: n } = await qd(e, t);
|
|
6636
|
+
return n.map(Jd);
|
|
6637
|
+
}, Xd = async (e, t, n) => {
|
|
6610
6638
|
let r = (await e.store.query({
|
|
6611
6639
|
table: "_voltro_workflow_runs",
|
|
6612
6640
|
order: [],
|
|
@@ -6620,7 +6648,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6620
6648
|
if (!i) throw Error(`retry: no workflow registered with tag '${r.tag}'`);
|
|
6621
6649
|
let a = n?.payloadOverride === void 0 ? r.payload : n.payloadOverride, o = await e.runPromise(i.definition.execute(a));
|
|
6622
6650
|
return { executionId: typeof o == "string" ? o : "started" };
|
|
6623
|
-
},
|
|
6651
|
+
}, Zd = (e, t) => {
|
|
6624
6652
|
let n = e.filter((e) => typeof e.onHttpRequest == "function");
|
|
6625
6653
|
if (n.length !== 0) return n.reduceRight((e, n) => {
|
|
6626
6654
|
let r = n.onHttpRequest, i = `plugin.${n.name}.http-intercept`;
|
|
@@ -6641,12 +6669,12 @@ ${a.join("\n\n")}\n`);
|
|
|
6641
6669
|
}
|
|
6642
6670
|
};
|
|
6643
6671
|
}, (e) => e());
|
|
6644
|
-
},
|
|
6672
|
+
}, Qd = (e) => {
|
|
6645
6673
|
let t = [];
|
|
6646
6674
|
for (let n of e) {
|
|
6647
6675
|
let e = n.dashboard ?? [];
|
|
6648
6676
|
if (e.length === 0) continue;
|
|
6649
|
-
let r =
|
|
6677
|
+
let r = Uc(n.name), i = /* @__PURE__ */ new Set();
|
|
6650
6678
|
for (let a of e) {
|
|
6651
6679
|
if (i.has(a.id)) throw Error(`plugin "${n.name}" declares duplicate dashboard mount id "${a.id}"`);
|
|
6652
6680
|
i.add(a.id), t.push({
|
|
@@ -6665,7 +6693,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6665
6693
|
}
|
|
6666
6694
|
}
|
|
6667
6695
|
return t;
|
|
6668
|
-
},
|
|
6696
|
+
}, $d = /\.(query|mutation|action|stream)\.ts$/, ef = /\.(query|mutation|action|stream)\.server\.ts$/, tf = /\.workflow\.tsx$/, nf = /* @__PURE__ */ new Set([
|
|
6669
6697
|
"node_modules",
|
|
6670
6698
|
"dist",
|
|
6671
6699
|
"build",
|
|
@@ -6673,7 +6701,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6673
6701
|
".vite",
|
|
6674
6702
|
".next",
|
|
6675
6703
|
".git"
|
|
6676
|
-
]),
|
|
6704
|
+
]), rf = async (e) => {
|
|
6677
6705
|
let t = [], n = async (e) => {
|
|
6678
6706
|
let r;
|
|
6679
6707
|
try {
|
|
@@ -6682,14 +6710,14 @@ ${a.join("\n\n")}\n`);
|
|
|
6682
6710
|
return;
|
|
6683
6711
|
}
|
|
6684
6712
|
for (let i of r) {
|
|
6685
|
-
if (
|
|
6713
|
+
if (nf.has(i.name)) continue;
|
|
6686
6714
|
let r = s(e, i.name);
|
|
6687
|
-
i.isDirectory() ? await n(r) : i.isFile() && (
|
|
6715
|
+
i.isDirectory() ? await n(r) : i.isFile() && ($d.test(i.name) && !ef.test(i.name) || tf.test(i.name)) && t.push(r);
|
|
6688
6716
|
}
|
|
6689
6717
|
};
|
|
6690
6718
|
return await n(e), t;
|
|
6691
|
-
},
|
|
6692
|
-
let t = await
|
|
6719
|
+
}, af = async (e) => {
|
|
6720
|
+
let t = await rf(e), n = [];
|
|
6693
6721
|
for (let e of t) try {
|
|
6694
6722
|
let t = await import(d(e).href);
|
|
6695
6723
|
for (let r of Object.values(t)) {
|
|
@@ -6700,7 +6728,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6700
6728
|
tag: e.name
|
|
6701
6729
|
});
|
|
6702
6730
|
}
|
|
6703
|
-
if (r && typeof r == "object" &&
|
|
6731
|
+
if (r && typeof r == "object" && tf.test(e) && "name" in r) {
|
|
6704
6732
|
let e = r;
|
|
6705
6733
|
typeof e.name == "string" && n.push({
|
|
6706
6734
|
kind: "workflow",
|
|
@@ -6714,12 +6742,12 @@ ${a.join("\n\n")}\n`);
|
|
|
6714
6742
|
let t = `${e.kind}:${e.tag}`;
|
|
6715
6743
|
return r.has(t) ? !1 : (r.add(t), !0);
|
|
6716
6744
|
});
|
|
6717
|
-
},
|
|
6745
|
+
}, of = async (e, t, n) => {
|
|
6718
6746
|
let r = e.filter((e) => typeof e.codegen == "function");
|
|
6719
6747
|
if (r.length === 0) return [];
|
|
6720
|
-
let i = await
|
|
6748
|
+
let i = await af(n);
|
|
6721
6749
|
return r.map((e) => {
|
|
6722
|
-
let n =
|
|
6750
|
+
let n = Uc(e.name), r = {
|
|
6723
6751
|
pluginName: e.name,
|
|
6724
6752
|
pluginAlias: n,
|
|
6725
6753
|
apiName: t,
|
|
@@ -6731,19 +6759,19 @@ ${a.join("\n\n")}\n`);
|
|
|
6731
6759
|
emit: () => e.codegen(r)
|
|
6732
6760
|
};
|
|
6733
6761
|
});
|
|
6734
|
-
},
|
|
6762
|
+
}, sf = class extends Error {
|
|
6735
6763
|
constructor(e) {
|
|
6736
6764
|
super(e), this.name = "InspectQueryError";
|
|
6737
6765
|
}
|
|
6738
|
-
},
|
|
6766
|
+
}, cf = /* @__PURE__ */ new Set([
|
|
6739
6767
|
"text",
|
|
6740
6768
|
"id",
|
|
6741
6769
|
"reference"
|
|
6742
|
-
]),
|
|
6770
|
+
]), lf = /* @__PURE__ */ new Set([
|
|
6743
6771
|
"integer",
|
|
6744
6772
|
"timestamp",
|
|
6745
6773
|
"date"
|
|
6746
|
-
]),
|
|
6774
|
+
]), uf = (e, t) => {
|
|
6747
6775
|
switch (e) {
|
|
6748
6776
|
case "isNull":
|
|
6749
6777
|
case "isNotNull":
|
|
@@ -6751,54 +6779,54 @@ ${a.join("\n\n")}\n`);
|
|
|
6751
6779
|
case "neq":
|
|
6752
6780
|
case "in":
|
|
6753
6781
|
case "notIn": return !0;
|
|
6754
|
-
case "contains": return
|
|
6782
|
+
case "contains": return cf.has(t);
|
|
6755
6783
|
case "gt":
|
|
6756
6784
|
case "gte":
|
|
6757
6785
|
case "lt":
|
|
6758
|
-
case "lte": return
|
|
6786
|
+
case "lte": return lf.has(t);
|
|
6759
6787
|
}
|
|
6760
|
-
},
|
|
6788
|
+
}, df = (e, t, n) => {
|
|
6761
6789
|
if (e == null) return e;
|
|
6762
6790
|
switch (t) {
|
|
6763
6791
|
case "integer": {
|
|
6764
6792
|
let t = typeof e == "number" ? e : Number(e);
|
|
6765
|
-
if (!Number.isFinite(t)) throw new
|
|
6793
|
+
if (!Number.isFinite(t)) throw new sf(`filter on "${n}": "${String(e)}" is not a number`);
|
|
6766
6794
|
return t;
|
|
6767
6795
|
}
|
|
6768
6796
|
case "boolean":
|
|
6769
6797
|
if (typeof e == "boolean") return e;
|
|
6770
6798
|
if (e === "true") return !0;
|
|
6771
6799
|
if (e === "false") return !1;
|
|
6772
|
-
throw new
|
|
6800
|
+
throw new sf(`filter on "${n}": "${String(e)}" is not a boolean`);
|
|
6773
6801
|
default: return e;
|
|
6774
6802
|
}
|
|
6775
|
-
},
|
|
6803
|
+
}, ff = (e, t) => {
|
|
6776
6804
|
let n = t.get(e.column);
|
|
6777
|
-
if (!n) throw new
|
|
6778
|
-
if (!
|
|
6805
|
+
if (!n) throw new sf(`unknown filter column "${e.column}"`);
|
|
6806
|
+
if (!uf(e.op, n.type)) throw new sf(`operator "${e.op}" is not valid for ${n.type} column "${e.column}"`);
|
|
6779
6807
|
if (e.op === "isNull" || e.op === "isNotNull") return {
|
|
6780
6808
|
column: e.column,
|
|
6781
6809
|
op: e.op
|
|
6782
6810
|
};
|
|
6783
6811
|
if (e.op === "in" || e.op === "notIn") {
|
|
6784
|
-
if (!Array.isArray(e.value)) throw new
|
|
6812
|
+
if (!Array.isArray(e.value)) throw new sf(`operator "${e.op}" on "${e.column}" requires an array value`);
|
|
6785
6813
|
return {
|
|
6786
6814
|
column: e.column,
|
|
6787
6815
|
op: e.op,
|
|
6788
|
-
value: e.value.map((t) =>
|
|
6816
|
+
value: e.value.map((t) => df(t, n.type, e.column))
|
|
6789
6817
|
};
|
|
6790
6818
|
}
|
|
6791
6819
|
return {
|
|
6792
6820
|
column: e.column,
|
|
6793
6821
|
op: e.op,
|
|
6794
|
-
value:
|
|
6822
|
+
value: df(e.value, n.type, e.column)
|
|
6795
6823
|
};
|
|
6796
|
-
},
|
|
6797
|
-
if (++n.n >
|
|
6798
|
-
if (e.kind === "leaf") return
|
|
6799
|
-
let r = e.children.map((e) =>
|
|
6824
|
+
}, pf = 200, mf = (e, t, n) => {
|
|
6825
|
+
if (++n.n > pf) throw new sf("filter tree too large");
|
|
6826
|
+
if (e.kind === "leaf") return ff(e, t);
|
|
6827
|
+
let r = e.children.map((e) => mf(e, t, n));
|
|
6800
6828
|
return e.kind === "and" ? { and: r } : { or: r };
|
|
6801
|
-
},
|
|
6829
|
+
}, hf = (e, t) => {
|
|
6802
6830
|
let n = e?.trim();
|
|
6803
6831
|
if (!n) return null;
|
|
6804
6832
|
let r = t.filter((e) => e.type === "text" || (e.oneOf?.length ?? 0) > 0);
|
|
@@ -6807,16 +6835,16 @@ ${a.join("\n\n")}\n`);
|
|
|
6807
6835
|
op: "contains",
|
|
6808
6836
|
value: n
|
|
6809
6837
|
})) };
|
|
6810
|
-
},
|
|
6838
|
+
}, gf = (e) => {
|
|
6811
6839
|
let t = new Map(e.columns.map((e) => [e.name, e])), n = [];
|
|
6812
|
-
e.filter && n.push(
|
|
6813
|
-
let r =
|
|
6840
|
+
e.filter && n.push(mf(e.filter, t, { n: 0 }));
|
|
6841
|
+
let r = hf(e.quickSearch, e.columns);
|
|
6814
6842
|
if (r && n.push(r), n.length !== 0) return n.length === 1 ? n[0] : { and: n };
|
|
6815
|
-
},
|
|
6843
|
+
}, _f = (e, t) => {
|
|
6816
6844
|
let n = new Set(t.map((e) => e.name)), r = [], i = /* @__PURE__ */ new Set();
|
|
6817
6845
|
for (let t of e ?? []) {
|
|
6818
|
-
if (!n.has(t.column)) throw new
|
|
6819
|
-
if (t.direction !== "asc" && t.direction !== "desc") throw new
|
|
6846
|
+
if (!n.has(t.column)) throw new sf(`unknown sort column "${t.column}"`);
|
|
6847
|
+
if (t.direction !== "asc" && t.direction !== "desc") throw new sf(`invalid sort direction "${t.direction}"`);
|
|
6820
6848
|
i.has(t.column) || (i.add(t.column), r.push({
|
|
6821
6849
|
column: t.column,
|
|
6822
6850
|
direction: t.direction
|
|
@@ -6826,16 +6854,16 @@ ${a.join("\n\n")}\n`);
|
|
|
6826
6854
|
column: "id",
|
|
6827
6855
|
direction: "asc"
|
|
6828
6856
|
}), r;
|
|
6829
|
-
},
|
|
6857
|
+
}, vf = 150, yf = 200, bf = (e) => e instanceof Date ? e.toISOString() : typeof e == "bigint" ? e.toString() : e, xf = (e) => {
|
|
6830
6858
|
if (!e) return null;
|
|
6831
6859
|
let t = {};
|
|
6832
|
-
for (let [n, r] of Object.entries(e)) t[n] =
|
|
6860
|
+
for (let [n, r] of Object.entries(e)) t[n] = bf(r);
|
|
6833
6861
|
return t;
|
|
6834
|
-
},
|
|
6862
|
+
}, Sf = (e, t) => {
|
|
6835
6863
|
let n = /* @__PURE__ */ new Map(), r, i = () => {
|
|
6836
6864
|
r = void 0;
|
|
6837
6865
|
for (let [e, r] of n) {
|
|
6838
|
-
if (r.size >
|
|
6866
|
+
if (r.size > yf) {
|
|
6839
6867
|
t.emit("cdc", {
|
|
6840
6868
|
op: "resync",
|
|
6841
6869
|
table: e
|
|
@@ -6857,17 +6885,17 @@ ${a.join("\n\n")}\n`);
|
|
|
6857
6885
|
let o = n.get(e.table);
|
|
6858
6886
|
o || (o = /* @__PURE__ */ new Map(), n.set(e.table, o)), o.set(a, {
|
|
6859
6887
|
op: e.op,
|
|
6860
|
-
row: e.op === "delete" ? null :
|
|
6861
|
-
}), r === void 0 && (r = setTimeout(i,
|
|
6888
|
+
row: e.op === "delete" ? null : xf(t)
|
|
6889
|
+
}), r === void 0 && (r = setTimeout(i, vf));
|
|
6862
6890
|
});
|
|
6863
6891
|
return () => {
|
|
6864
6892
|
r !== void 0 && clearTimeout(r), a();
|
|
6865
6893
|
};
|
|
6866
|
-
},
|
|
6894
|
+
}, Cf = [
|
|
6867
6895
|
"ok",
|
|
6868
6896
|
"error",
|
|
6869
6897
|
"unset"
|
|
6870
|
-
],
|
|
6898
|
+
], wf = (e, t) => {
|
|
6871
6899
|
let n = e.indexOf("?"), r = n === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(n + 1)), i = (() => {
|
|
6872
6900
|
let e = r.get("since");
|
|
6873
6901
|
if (e === null) return;
|
|
@@ -6888,9 +6916,9 @@ ${a.join("\n\n")}\n`);
|
|
|
6888
6916
|
Number.isFinite(t) && (e.minDurationMs = t);
|
|
6889
6917
|
}
|
|
6890
6918
|
let s = r.get("status");
|
|
6891
|
-
s !== null &&
|
|
6919
|
+
s !== null && Cf.includes(s) && (e.status = s);
|
|
6892
6920
|
let c = t.query(e);
|
|
6893
|
-
return
|
|
6921
|
+
return Tf({
|
|
6894
6922
|
capturedAt: Date.now(),
|
|
6895
6923
|
bufferCapacity: t.capacityHint(),
|
|
6896
6924
|
bufferSize: t.size(),
|
|
@@ -6902,18 +6930,18 @@ ${a.join("\n\n")}\n`);
|
|
|
6902
6930
|
let s = {};
|
|
6903
6931
|
i !== void 0 && (s.since = i), a !== void 0 && (s.maxTraces = a), r.get("onlyErrors") === "1" && (s.onlyErrors = !0);
|
|
6904
6932
|
let c = t.queryGrouped(s);
|
|
6905
|
-
return
|
|
6933
|
+
return Tf({
|
|
6906
6934
|
capturedAt: Date.now(),
|
|
6907
6935
|
bufferCapacity: t.capacityHint(),
|
|
6908
6936
|
bufferSize: t.size(),
|
|
6909
6937
|
returned: c.length,
|
|
6910
6938
|
traces: c
|
|
6911
6939
|
});
|
|
6912
|
-
},
|
|
6940
|
+
}, Tf = (e) => ({
|
|
6913
6941
|
status: 200,
|
|
6914
6942
|
contentType: "application/json; charset=utf-8",
|
|
6915
6943
|
body: JSON.stringify(e)
|
|
6916
|
-
}),
|
|
6944
|
+
}), Ef = (e) => {
|
|
6917
6945
|
let t = e.now ?? Date.now, n = {
|
|
6918
6946
|
phase: "booting",
|
|
6919
6947
|
startedAt: t()
|
|
@@ -6970,19 +6998,19 @@ ${a.join("\n\n")}\n`);
|
|
|
6970
6998
|
r.removeListener("error", n), r.unref(), e.log?.info("dev health server listening", { port: e.port }), t(i(!0));
|
|
6971
6999
|
});
|
|
6972
7000
|
});
|
|
6973
|
-
},
|
|
7001
|
+
}, Df = Hl, $ = O({ scope: "voltro:dev" }), Of = await (async () => {
|
|
6974
7002
|
try {
|
|
6975
7003
|
let e = s(a(u(import.meta.url)), "..", "package.json"), t = await N.readFile(e, "utf8");
|
|
6976
7004
|
return JSON.parse(t).version ?? "0.0.0";
|
|
6977
7005
|
} catch {
|
|
6978
7006
|
return "0.0.0";
|
|
6979
7007
|
}
|
|
6980
|
-
})(),
|
|
7008
|
+
})(), kf = process.env.TENANT ?? "acme", Af = process.env.VOLTRO_SESSION_COOKIE ?? "voltro:session", jf = {
|
|
6981
7009
|
id: "voltro-password",
|
|
6982
7010
|
resolve: (e) => {
|
|
6983
7011
|
let t = tn();
|
|
6984
7012
|
if (t.current.secret.length === 0) return { kind: "skip" };
|
|
6985
|
-
let n = en(e.headers.cookie ?? e.headers.Cookie,
|
|
7013
|
+
let n = en(e.headers.cookie ?? e.headers.Cookie, Af);
|
|
6986
7014
|
if (!n) return { kind: "skip" };
|
|
6987
7015
|
let r = rn(n, t);
|
|
6988
7016
|
return r ? {
|
|
@@ -6990,20 +7018,20 @@ ${a.join("\n\n")}\n`);
|
|
|
6990
7018
|
subject: r.subject
|
|
6991
7019
|
} : { kind: "skip" };
|
|
6992
7020
|
}
|
|
6993
|
-
},
|
|
7021
|
+
}, Mf = (e = [], t, n = !1) => xr([t ?? jf, ...e], n ? {
|
|
6994
7022
|
anonymousTenantRequired: !0,
|
|
6995
7023
|
onStrategyFailed: ({ strategyId: e, reason: t }) => {
|
|
6996
7024
|
$.warn(`auth strategy "${e}" rejected request: ${t}`);
|
|
6997
7025
|
}
|
|
6998
7026
|
} : {
|
|
6999
|
-
fallback: (e) => yr(e.headers["x-tenant"] ??
|
|
7027
|
+
fallback: (e) => yr(e.headers["x-tenant"] ?? kf),
|
|
7000
7028
|
onStrategyFailed: ({ strategyId: e, reason: t }) => {
|
|
7001
7029
|
$.warn(`auth strategy "${e}" rejected request: ${t}`);
|
|
7002
7030
|
}
|
|
7003
|
-
}),
|
|
7031
|
+
}), Nf = (e) => S.succeed(mr, mr.of(({ headers: t, clientId: n }) => y.promise(async () => He(n) || e({
|
|
7004
7032
|
headers: t,
|
|
7005
7033
|
clientId: n
|
|
7006
|
-
})))),
|
|
7034
|
+
})))), Pf = S.succeed(hr, hr.of(({ clientId: e }) => y.succeed({ clientId: e }))), Ff = (e) => {
|
|
7007
7035
|
if (g.isCause(e)) return e;
|
|
7008
7036
|
if (typeof e != "object" || !e) return;
|
|
7009
7037
|
for (let t of Object.getOwnPropertySymbols(e)) if (t.description === "effect/Runtime/FiberFailure/Cause") {
|
|
@@ -7012,17 +7040,17 @@ ${a.join("\n\n")}\n`);
|
|
|
7012
7040
|
}
|
|
7013
7041
|
let t = e.cause;
|
|
7014
7042
|
return g.isCause(t) ? t : void 0;
|
|
7015
|
-
},
|
|
7016
|
-
let t =
|
|
7043
|
+
}, If = (e) => {
|
|
7044
|
+
let t = Ff(e);
|
|
7017
7045
|
if (t === void 0) return;
|
|
7018
7046
|
let n = g.failureOption(t);
|
|
7019
7047
|
if (w.isSome(n)) return n.value;
|
|
7020
7048
|
let r = g.dieOption(t);
|
|
7021
7049
|
if (w.isSome(r)) return r.value;
|
|
7022
|
-
},
|
|
7050
|
+
}, Lf = (e) => {
|
|
7023
7051
|
if (e == null) return { message: "unknown error" };
|
|
7024
|
-
let t =
|
|
7025
|
-
if (t !== void 0 && t !== e) return
|
|
7052
|
+
let t = If(e);
|
|
7053
|
+
if (t !== void 0 && t !== e) return Lf(t);
|
|
7026
7054
|
let n = Be(e), r = (n.dbCode ?? n.dbSqlState ?? n.dbErrno ?? n.dbConstraint) === void 0 ? {} : n;
|
|
7027
7055
|
if (typeof e == "object" && "_tag" in e) return {
|
|
7028
7056
|
...e,
|
|
@@ -7039,7 +7067,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7039
7067
|
} catch {
|
|
7040
7068
|
return { message: String(e) };
|
|
7041
7069
|
}
|
|
7042
|
-
},
|
|
7070
|
+
}, Rf = /\.(query|mutation|action|stream)\.ts$/, zf = /\.(query|mutation|action|stream)\.server\.ts$/, Bf = /\.workflow\.tsx$/, Vf = /\.workflow\.server\.tsx$/, Hf = /\.trigger\.tsx?$/, Uf = /\.seed\.ts$/, Wf = /\.startup\.tsx?$/, Gf = /\.cron\.tsx?$/, Kf = /\.webhook\.tsx?$/, qf = /\.subscribe\.tsx?$/, Jf = /\.reaction\.tsx?$/, Yf = /\.aggregate\.tsx?$/, Xf = /\.entity\.ts$|\.schema\.ts$|^schema\.ts$/, Zf = /\.relations\.ts$/, Qf = /* @__PURE__ */ new Set([
|
|
7043
7071
|
"node_modules",
|
|
7044
7072
|
"dist",
|
|
7045
7073
|
"build",
|
|
@@ -7047,21 +7075,21 @@ ${a.join("\n\n")}\n`);
|
|
|
7047
7075
|
".vite",
|
|
7048
7076
|
".next",
|
|
7049
7077
|
".git"
|
|
7050
|
-
]),
|
|
7078
|
+
]), $f = async (e) => {
|
|
7051
7079
|
let t = [], n = async (e) => {
|
|
7052
7080
|
let r = await N.readdir(e, { withFileTypes: !0 });
|
|
7053
7081
|
for (let i of r) {
|
|
7054
|
-
if (
|
|
7082
|
+
if (Qf.has(i.name)) continue;
|
|
7055
7083
|
let r = s(e, i.name);
|
|
7056
|
-
i.isDirectory() ? await n(r) : i.isFile() && (
|
|
7084
|
+
i.isDirectory() ? await n(r) : i.isFile() && (Rf.test(i.name) && !zf.test(i.name) || zf.test(i.name) || Bf.test(i.name) || Vf.test(i.name) || Hf.test(i.name) || Xf.test(i.name) || Zf.test(i.name) || Uf.test(i.name) || Wf.test(i.name) || Gf.test(i.name) || Kf.test(i.name) || hd.test(i.name) || il.test(i.name) || al.test(i.name) || qf.test(i.name) || Jf.test(i.name) || Yf.test(i.name)) && t.push(r);
|
|
7057
7085
|
}
|
|
7058
7086
|
};
|
|
7059
7087
|
return await n(e), t;
|
|
7060
|
-
},
|
|
7088
|
+
}, ep = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "query", tp = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "mutation", np = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "action", rp = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "stream", ip = Symbol.for("@effect/workflow/Workflow"), ap = (e) => typeof e == "object" && !!e && ip in e, op = (e) => {
|
|
7061
7089
|
let t = {};
|
|
7062
7090
|
for (let [n, r] of Object.entries(e)) r instanceof Date ? t[n] = r.toISOString() : typeof r == "bigint" ? t[n] = r.toString() : t[n] = r;
|
|
7063
7091
|
return t;
|
|
7064
|
-
},
|
|
7092
|
+
}, sp = (e) => Object.entries(e.fields).map(([e, t]) => {
|
|
7065
7093
|
let n = t, r = n.references?.()?.tableName;
|
|
7066
7094
|
return {
|
|
7067
7095
|
name: e,
|
|
@@ -7072,11 +7100,11 @@ ${a.join("\n\n")}\n`);
|
|
|
7072
7100
|
...r === void 0 ? {} : { referencesTable: r },
|
|
7073
7101
|
...n.oneOf === void 0 ? {} : { oneOf: [...n.oneOf] }
|
|
7074
7102
|
};
|
|
7075
|
-
}),
|
|
7103
|
+
}), cp = (e) => e.some((e) => e.name === "id") ? "id" : e.find((e) => e.type === "id")?.name, lp = (e) => typeof e == "object" && !!e && "tableName" in e && "fields" in e && typeof e.tableName == "string" && typeof e.fields == "object" && e.fields !== null, up = (e, t) => {
|
|
7076
7104
|
let n = /* @__PURE__ */ new Map();
|
|
7077
|
-
for (let e of t)
|
|
7105
|
+
for (let e of t) lp(e) && n.set(e.tableName, e);
|
|
7078
7106
|
let r = /* @__PURE__ */ new Set(), i = [], a = (e) => {
|
|
7079
|
-
if (!(!
|
|
7107
|
+
if (!(!lp(e) || r.has(e.tableName))) {
|
|
7080
7108
|
r.add(e.tableName);
|
|
7081
7109
|
for (let t of Object.values(e.fields)) {
|
|
7082
7110
|
let e = t.references?.()?.tableName;
|
|
@@ -7089,7 +7117,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7089
7117
|
};
|
|
7090
7118
|
for (let t of e) a(t);
|
|
7091
7119
|
return i;
|
|
7092
|
-
},
|
|
7120
|
+
}, dp = "voltro/tenant", fp = (e) => lp(e) && (e.appliedMixins ?? []).some((e) => e.id === dp), pp = "voltro/softDelete", mp = (e) => lp(e) && (e.appliedMixins ?? []).some((e) => e.id === pp), hp = (e) => {
|
|
7093
7121
|
let t = e.traceId, n = e.spanId;
|
|
7094
7122
|
if (typeof t != "string" || typeof n != "string") return null;
|
|
7095
7123
|
let r = (e) => e instanceof Date ? e.getTime() : typeof e == "string" ? new Date(e).getTime() : typeof e == "number" ? e : 0, i = r(e.startedAt), a = r(e.endedAt);
|
|
@@ -7107,7 +7135,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7107
7135
|
...typeof e.statusMessage == "string" ? { statusMessage: e.statusMessage } : {},
|
|
7108
7136
|
...Array.isArray(e.events) ? { events: e.events } : {}
|
|
7109
7137
|
};
|
|
7110
|
-
},
|
|
7138
|
+
}, gp = async (e, t, n) => {
|
|
7111
7139
|
let r = e.indexOf("?"), i = (r === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(r + 1))).get("traceId"), a = [];
|
|
7112
7140
|
try {
|
|
7113
7141
|
a = await n.query({
|
|
@@ -7126,29 +7154,29 @@ ${a.join("\n\n")}\n`);
|
|
|
7126
7154
|
}
|
|
7127
7155
|
let o = /* @__PURE__ */ new Map();
|
|
7128
7156
|
for (let e of a) {
|
|
7129
|
-
let t =
|
|
7157
|
+
let t = hp(e);
|
|
7130
7158
|
t && o.set(`${t.traceId}:${t.spanId}`, t);
|
|
7131
7159
|
}
|
|
7132
7160
|
for (let e of t.query({ max: t.capacityHint() })) o.set(`${e.traceId}:${e.spanId}`, e);
|
|
7133
|
-
let s = new
|
|
7161
|
+
let s = new gl(Math.max(o.size + 16, 1024));
|
|
7134
7162
|
for (let e of [...o.values()].sort((e, t) => e.startMs - t.startMs)) s.append(e);
|
|
7135
7163
|
return s;
|
|
7136
|
-
},
|
|
7164
|
+
}, _p = async (e, n) => {
|
|
7137
7165
|
let r = [], a = [], o = [], s = [], c = [], l = [], u = [], d = [], f = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Map(), h = [], g = /* @__PURE__ */ new Map();
|
|
7138
7166
|
for (let n of e) {
|
|
7139
7167
|
let e = i(n);
|
|
7140
|
-
if (
|
|
7168
|
+
if (Xf.test(e)) {
|
|
7141
7169
|
let e = await t(n);
|
|
7142
|
-
for (let t of Object.values(e))
|
|
7170
|
+
for (let t of Object.values(e)) lp(t) && (m.set(t.tableName, t), fp(t) && f.add(t.tableName), mp(t) && p.add(t.tableName));
|
|
7143
7171
|
ar(e);
|
|
7144
7172
|
continue;
|
|
7145
7173
|
}
|
|
7146
|
-
if (
|
|
7174
|
+
if (Zf.test(e)) {
|
|
7147
7175
|
ar(await t(n)) === 0 && $.warn("skipping relations file — no relations(...) export found", { file: n });
|
|
7148
7176
|
continue;
|
|
7149
7177
|
}
|
|
7150
|
-
if (
|
|
7151
|
-
let e = await t(n), r = Object.values(e).find(
|
|
7178
|
+
if (Bf.test(e)) {
|
|
7179
|
+
let e = await t(n), r = Object.values(e).find(ap);
|
|
7152
7180
|
if (!r) {
|
|
7153
7181
|
$.warn("skipping workflow — no workflow(...) export", { file: n });
|
|
7154
7182
|
continue;
|
|
@@ -7176,7 +7204,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7176
7204
|
for (let t of [...Object.values(e), ...Object.values(a)]) jn(t) && l.push(t);
|
|
7177
7205
|
continue;
|
|
7178
7206
|
}
|
|
7179
|
-
if (
|
|
7207
|
+
if (Hf.test(e)) {
|
|
7180
7208
|
let r = await t(n), i = r.default ?? Object.values(r).find(Ke);
|
|
7181
7209
|
if (!Ke(i)) {
|
|
7182
7210
|
$.warn("skipping trigger — default export is not triggerWorkflow(...)", { file: n });
|
|
@@ -7193,7 +7221,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7193
7221
|
});
|
|
7194
7222
|
continue;
|
|
7195
7223
|
}
|
|
7196
|
-
if (
|
|
7224
|
+
if (Gf.test(e)) {
|
|
7197
7225
|
let e = (await t(n)).default;
|
|
7198
7226
|
if (!Ge(e)) {
|
|
7199
7227
|
$.warn("skipping cron — default export is not defineSchedule(...)", { file: n });
|
|
@@ -7209,18 +7237,18 @@ ${a.join("\n\n")}\n`);
|
|
|
7209
7237
|
d.push(e);
|
|
7210
7238
|
continue;
|
|
7211
7239
|
}
|
|
7212
|
-
if (
|
|
7240
|
+
if (zf.test(e)) {
|
|
7213
7241
|
let t = n.slice(0, -e.length), r = e.replace(/\.server\.ts$/, ".ts");
|
|
7214
7242
|
g.set(t + r, n);
|
|
7215
7243
|
continue;
|
|
7216
7244
|
}
|
|
7217
|
-
if (
|
|
7245
|
+
if (Rf.test(e)) {
|
|
7218
7246
|
h.push(n);
|
|
7219
7247
|
continue;
|
|
7220
7248
|
}
|
|
7221
7249
|
}
|
|
7222
7250
|
for (let e of h) {
|
|
7223
|
-
let n = await t(e), i = Object.values(n).find(
|
|
7251
|
+
let n = await t(e), i = Object.values(n).find(ep) ?? Object.values(n).find(tp) ?? Object.values(n).find(np) ?? Object.values(n).find(rp);
|
|
7224
7252
|
if (!i) {
|
|
7225
7253
|
$.warn("skipping procedure descriptor — no defineQuery / defineMutation / defineAction / defineStream export", { file: e });
|
|
7226
7254
|
continue;
|
|
@@ -7265,8 +7293,8 @@ ${a.join("\n\n")}\n`);
|
|
|
7265
7293
|
let y = {
|
|
7266
7294
|
workflows: c.length > 0 || u.length > 0,
|
|
7267
7295
|
schedules: d.length > 0,
|
|
7268
|
-
webhooks: e.some((e) =>
|
|
7269
|
-
agents: e.some((e) =>
|
|
7296
|
+
webhooks: e.some((e) => Kf.test(i(e))),
|
|
7297
|
+
agents: e.some((e) => il.test(i(e)))
|
|
7270
7298
|
};
|
|
7271
7299
|
return {
|
|
7272
7300
|
queries: r,
|
|
@@ -7282,7 +7310,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7282
7310
|
tenantScopedTables: f,
|
|
7283
7311
|
softDeleteScopedTables: p
|
|
7284
7312
|
};
|
|
7285
|
-
},
|
|
7313
|
+
}, vp = async (e) => {
|
|
7286
7314
|
let n = s(e, "app.config.ts");
|
|
7287
7315
|
try {
|
|
7288
7316
|
let e = (await t(n)).default;
|
|
@@ -7290,8 +7318,8 @@ ${a.join("\n\n")}\n`);
|
|
|
7290
7318
|
} catch {
|
|
7291
7319
|
return null;
|
|
7292
7320
|
}
|
|
7293
|
-
},
|
|
7294
|
-
let e =
|
|
7321
|
+
}, yp = () => {
|
|
7322
|
+
let e = xp(), t = process.env.DB_SCHEMA, n = t && t.length > 0 ? { schema: t } : {}, r = bp(), i = r === void 0 ? {} : { ssl: r }, a = process.env.DB_URL ?? process.env.DB_PRIMARY_URL;
|
|
7295
7323
|
return a ? {
|
|
7296
7324
|
url: a,
|
|
7297
7325
|
...e === void 0 ? {} : { maxConnections: e },
|
|
@@ -7307,19 +7335,19 @@ ${a.join("\n\n")}\n`);
|
|
|
7307
7335
|
...i,
|
|
7308
7336
|
...n
|
|
7309
7337
|
};
|
|
7310
|
-
},
|
|
7338
|
+
}, bp = () => {
|
|
7311
7339
|
let e = process.env.PG_SSL;
|
|
7312
7340
|
if (!(e === void 0 || e === "")) {
|
|
7313
7341
|
if (e === "require") return !0;
|
|
7314
7342
|
if (e === "disable") return !1;
|
|
7315
7343
|
throw Error(`PG_SSL '${e}' is not supported — use 'require' (TLS without certificate verification) or 'disable' (plaintext).`);
|
|
7316
7344
|
}
|
|
7317
|
-
},
|
|
7345
|
+
}, xp = () => {
|
|
7318
7346
|
let e = process.env.DB_MAX_CONNECTIONS ?? process.env.PG_MAX_CONNECTIONS;
|
|
7319
7347
|
if (e === void 0 || e === "") return;
|
|
7320
7348
|
let t = Number(e);
|
|
7321
7349
|
return Number.isInteger(t) && t > 0 ? t : void 0;
|
|
7322
|
-
},
|
|
7350
|
+
}, Sp = (e) => {
|
|
7323
7351
|
let t = process.env.DB_URL !== void 0 || process.env.DB_PRIMARY_URL !== void 0 || process.env.DB_HOST !== void 0 || process.env.PG_HOST !== void 0;
|
|
7324
7352
|
if ("url" in e && e.url) try {
|
|
7325
7353
|
let n = new URL(e.url), r = n.username ? `${n.username}@` : "", i = n.port ? `:${n.port}` : "";
|
|
@@ -7338,35 +7366,25 @@ ${a.join("\n\n")}\n`);
|
|
|
7338
7366
|
summary: `postgres://${n.username}@${n.host}:${n.port}/${n.database}`,
|
|
7339
7367
|
fromEnv: t
|
|
7340
7368
|
};
|
|
7341
|
-
},
|
|
7369
|
+
}, Cp = () => {
|
|
7342
7370
|
let e = process.env.DB_REPLICA_URLS;
|
|
7343
7371
|
return e === void 0 || e.trim() === "" ? [] : e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
7344
|
-
},
|
|
7345
|
-
switch (e) {
|
|
7346
|
-
case "postgres": return (await import("@voltro/sql-postgres")).postgresDialect;
|
|
7347
|
-
case "sqlite": return (await import("@voltro/sql-sqlite")).sqliteDialect;
|
|
7348
|
-
case "mysql": return (await import("@voltro/sql-mysql")).mysqlDialect;
|
|
7349
|
-
case "mariadb": return (await import("@voltro/sql-mysql")).mariadbDialect;
|
|
7350
|
-
case "mssql": return (await import("@voltro/sql-mssql")).mssqlDialect;
|
|
7351
|
-
case "turso": return (await import("@voltro/sql-turso")).tursoDialect;
|
|
7352
|
-
default: throw Error(`Unsupported DB_DIALECT='${e}'. Supported: memory, postgres, sqlite, mysql, mariadb, mssql, turso.`);
|
|
7353
|
-
}
|
|
7354
|
-
}, xp = (e) => {
|
|
7372
|
+
}, wp = (e) => {
|
|
7355
7373
|
let t = 2166136261;
|
|
7356
7374
|
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
7357
7375
|
return 1e3 + (t >>> 0) % 2147482647;
|
|
7358
|
-
},
|
|
7359
|
-
let n =
|
|
7376
|
+
}, Tp = (e) => (process.env.DB_DIALECT ?? e?.store ?? "memory").toLowerCase(), Ep = async (e, t) => {
|
|
7377
|
+
let n = Tp(e);
|
|
7360
7378
|
if (n === "memory") return $.info("sql dialect resolved: memory — in-process store, no persistence"), new ge({});
|
|
7361
|
-
let i = (process.env.CDC ?? "1") !== "0", a = await
|
|
7379
|
+
let i = (process.env.CDC ?? "1") !== "0", a = await Bc(n), o = a.id === "postgres" ? "LISTEN/NOTIFY" : tr(a.id) ? "in-process bus" : a.id === "mariadb" ? "binlog CDC (ROW)" : a.id === "mssql" ? "Change Tracking (polled)" : a.id === "mysql" ? "binlog CDC (ROW)" : "inline only", s = a.id === "postgres" ? "native" : a.id === "mysql" ? "INSERT/UPDATE/DELETE then SELECT (no RETURNING)" : a.id === "mariadb" ? "native (INSERT/DELETE); UPDATE then SELECT" : a.id === "mssql" ? "OUTPUT INSERTED/DELETED" : tr(a.id) ? "native" : "unknown";
|
|
7362
7380
|
$.info(`sql dialect resolved: ${a.id} — CDC: ${i ? o : "inline emit (CDC=0)"}, RETURNING: ${s}`);
|
|
7363
|
-
let c =
|
|
7381
|
+
let c = yp(), { summary: l, fromEnv: u } = Sp(c);
|
|
7364
7382
|
$.info(`db connection: ${l}${u ? "" : " (DEFAULT FALLBACK — no DB_URL / PG_HOST set)"}`), u || $.warn("db connection: falling back to localhost:5432/app — no DB_URL or PG_HOST env var set.\n If this app should run against its OWN postgres (e.g. its docker-compose), set DB_URL.\n Copy `.env.example` to `.env` in the app dir, or set DB_URL in the shell.\n Otherwise this app is silently using whatever DB is at localhost:5432/app — which is\n voltro-starter's docker default + may carry foreign tables that confuse the planner.");
|
|
7365
7383
|
let d;
|
|
7366
7384
|
if (i && (a.id === "mysql" || a.id === "mariadb")) {
|
|
7367
|
-
let { connectionFromConfig: e } = await
|
|
7385
|
+
let { connectionFromConfig: e } = await zc("@voltro/sql-mysql"), t = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, n = Jn().map((e) => e.tableName).filter((e) => !e.startsWith("_voltro_"));
|
|
7368
7386
|
d = {
|
|
7369
|
-
serverId:
|
|
7387
|
+
serverId: wp(t),
|
|
7370
7388
|
replicaId: t,
|
|
7371
7389
|
connection: e(c),
|
|
7372
7390
|
...n.length > 0 ? { includeTables: n } : {}
|
|
@@ -7376,7 +7394,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7376
7394
|
reactiveTables: n.length
|
|
7377
7395
|
});
|
|
7378
7396
|
} else if (i && a.id === "mssql") {
|
|
7379
|
-
let { connectionFromConfig: e } = await
|
|
7397
|
+
let { connectionFromConfig: e } = await zc("@voltro/sql-mssql"), t = e(c), n = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, r = Jn().map((e) => e.tableName).filter((e) => !e.startsWith("_voltro_"));
|
|
7380
7398
|
d = {
|
|
7381
7399
|
serverId: 0,
|
|
7382
7400
|
replicaId: n,
|
|
@@ -7398,7 +7416,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7398
7416
|
...t ? { tracerLayer: t } : {},
|
|
7399
7417
|
changeStrategy: i ? "cdc" : "inline",
|
|
7400
7418
|
...d ? { cdcConfig: d } : {}
|
|
7401
|
-
}), p =
|
|
7419
|
+
}), p = Cp();
|
|
7402
7420
|
if (p.length === 0) return $.info("read replicas: none configured (DB_REPLICA_URLS unset) — all queries → primary"), r.recordReplication({
|
|
7403
7421
|
replicaCount: 0,
|
|
7404
7422
|
rywPolicy: "off",
|
|
@@ -7413,7 +7431,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7413
7431
|
region: null,
|
|
7414
7432
|
localityEnabled: !1
|
|
7415
7433
|
}), f;
|
|
7416
|
-
let m = await
|
|
7434
|
+
let m = await jp(a.id);
|
|
7417
7435
|
if (m === null) return $.warn(`read replicas: no replication adapter for dialect ${a.id}; falling back to primary-only routing`), r.recordReplication({
|
|
7418
7436
|
replicaCount: 0,
|
|
7419
7437
|
rywPolicy: "off",
|
|
@@ -7439,15 +7457,15 @@ ${a.join("\n\n")}\n`);
|
|
|
7439
7457
|
v = xt({
|
|
7440
7458
|
client: n,
|
|
7441
7459
|
subscriber: n.duplicate()
|
|
7442
|
-
}), y = "redis", $.info(`read replicas: ryw store = redis @ ${
|
|
7460
|
+
}), y = "redis", $.info(`read replicas: ryw store = redis @ ${Op(e)}`);
|
|
7443
7461
|
} catch (e) {
|
|
7444
7462
|
$.warn("RYW_STORE=redis but ioredis import / connect failed — falling back to memory store", { err: e });
|
|
7445
7463
|
}
|
|
7446
7464
|
}
|
|
7447
7465
|
v ||= pt();
|
|
7448
|
-
let b =
|
|
7466
|
+
let b = kp(p.length), x = Tt(), S = x && b.length > 0 ? Ye({
|
|
7449
7467
|
currentRegion: x,
|
|
7450
|
-
replicaRegions:
|
|
7468
|
+
replicaRegions: Ap(h, b),
|
|
7451
7469
|
inner: _t()
|
|
7452
7470
|
}) : _t();
|
|
7453
7471
|
return $.info(`read replicas: ${h.length} configured, ryw policy '${g}', dialect=${a.id}, region=${x ?? "unknown"}` + (b.length > 0 ? ", replica-locality=on" : "")), r.recordReplication({
|
|
@@ -7464,7 +7482,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7464
7482
|
rywStore: v,
|
|
7465
7483
|
replicaSelector: S
|
|
7466
7484
|
});
|
|
7467
|
-
},
|
|
7485
|
+
}, Dp = async (e, t, n, r) => {
|
|
7468
7486
|
let i = mi(t?.plugins ?? []), a = n === "postgres" || n === "mysql" || n === "mariadb", o = n === "postgres" ? "LISTEN/NOTIFY" : "binlog CDC";
|
|
7469
7487
|
if (!i) return n === "memory" || n === "sqlite" || n === "turso" ? r.info(`reactivity: single-instance (${n}) — no cross-replica fan-out needed`) : a ? r.info(`reactivity: cross-instance via native ${o} (${n})`) : r.warn(`reactivity: cross-instance fan-out is OFF for dialect '${n}'. A write on one replica will NOT reach clients on other replicas. Add @voltro/plugin-broadcast (Redis / NATS) to close the gap, or use postgres (LISTEN/NOTIFY) / mariadb (binlog CDC).`), null;
|
|
7470
7488
|
let s = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`;
|
|
@@ -7474,35 +7492,35 @@ ${a.join("\n\n")}\n`);
|
|
|
7474
7492
|
replicaId: s,
|
|
7475
7493
|
logger: r
|
|
7476
7494
|
});
|
|
7477
|
-
},
|
|
7495
|
+
}, Op = (e) => {
|
|
7478
7496
|
try {
|
|
7479
7497
|
let t = new URL(e);
|
|
7480
7498
|
return t.password &&= "***", t.toString();
|
|
7481
7499
|
} catch {
|
|
7482
7500
|
return "***";
|
|
7483
7501
|
}
|
|
7484
|
-
},
|
|
7502
|
+
}, kp = (e) => {
|
|
7485
7503
|
let t = process.env.DB_REPLICA_REGIONS;
|
|
7486
7504
|
if (!t) return [];
|
|
7487
7505
|
let n = t.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
7488
7506
|
return n.length === e ? n : ($.warn(`DB_REPLICA_REGIONS has ${n.length} entries but DB_REPLICA_URLS has ${e} — region awareness disabled. Provide one region per replica in the same order.`), []);
|
|
7489
|
-
},
|
|
7507
|
+
}, Ap = (e, t) => {
|
|
7490
7508
|
let n = /* @__PURE__ */ new Map();
|
|
7491
7509
|
for (let r = 0; r < e.length && r < t.length; r++) n.set(e[r], t[r]);
|
|
7492
7510
|
return n;
|
|
7493
|
-
},
|
|
7511
|
+
}, jp = async (e) => {
|
|
7494
7512
|
switch (e) {
|
|
7495
|
-
case "postgres": return (await
|
|
7513
|
+
case "postgres": return (await zc("@voltro/sql-postgres")).postgresReplicationAdapter();
|
|
7496
7514
|
case "mysql":
|
|
7497
|
-
case "mariadb": return (await
|
|
7498
|
-
case "mssql": return (await
|
|
7515
|
+
case "mariadb": return (await zc("@voltro/sql-mysql")).mysqlReplicationAdapter();
|
|
7516
|
+
case "mssql": return (await zc("@voltro/sql-mssql")).mssqlReplicationAdapter();
|
|
7499
7517
|
default: return null;
|
|
7500
7518
|
}
|
|
7501
|
-
},
|
|
7519
|
+
}, Mp = async (e) => {
|
|
7502
7520
|
let t = l(e.find((e) => !e.startsWith("-")) ?? process.cwd()), n = await Qs(t);
|
|
7503
|
-
return n.ran ? n.exitCode : process.env.FRAMEWORK_DEV_INNER !== "1" && process.env.WATCH !== "0" ? (yi(
|
|
7504
|
-
},
|
|
7505
|
-
let a = Date.now(), o = await
|
|
7521
|
+
return n.ran ? n.exitCode : process.env.FRAMEWORK_DEV_INNER !== "1" && process.env.WATCH !== "0" ? (yi(tu({ root: t }), { scope: "voltro:dev" }), new Promise(() => {})) : Np(t);
|
|
7522
|
+
}, Np = async (t) => {
|
|
7523
|
+
let a = Date.now(), o = await vp(t), l = Number(process.env.PORT ?? o?.port ?? 4e3), u = o?.name ?? i(t), d = Ko("api", u, l), f = es(u);
|
|
7506
7524
|
await Wo({
|
|
7507
7525
|
id: d,
|
|
7508
7526
|
name: u,
|
|
@@ -7515,11 +7533,11 @@ ${a.join("\n\n")}\n`);
|
|
|
7515
7533
|
let p = Ka();
|
|
7516
7534
|
no(p), $.info("booting voltro dev", {
|
|
7517
7535
|
root: t,
|
|
7518
|
-
version:
|
|
7536
|
+
version: Of,
|
|
7519
7537
|
logFile: f.path
|
|
7520
7538
|
});
|
|
7521
7539
|
let m = process.env.VOLTRO_DEV_HEALTH_PORT, h = m === void 0 ? l + 1 : Number(m), _;
|
|
7522
|
-
h > 0 && Number.isFinite(h) && (_ = await
|
|
7540
|
+
h > 0 && Number.isFinite(h) && (_ = await Ef({
|
|
7523
7541
|
port: h,
|
|
7524
7542
|
log: {
|
|
7525
7543
|
info: (e, t) => $.debug(e, t),
|
|
@@ -7533,9 +7551,9 @@ ${a.join("\n\n")}\n`);
|
|
|
7533
7551
|
}).catch((e) => {
|
|
7534
7552
|
$.warn("agent-instructions seed failed (non-fatal)", {}, e);
|
|
7535
7553
|
});
|
|
7536
|
-
let v = await
|
|
7554
|
+
let v = await $f(t);
|
|
7537
7555
|
$.info(`discovered ${v.length} files`, { count: v.length });
|
|
7538
|
-
let b = await
|
|
7556
|
+
let b = await of(o?.plugins ?? [], o?.name ?? i(t), t), w = (o?.plugins ?? []).flatMap((e) => (e.errorSchemas ?? []).map((e) => e.import)), T = (o?.plugins ?? []).flatMap((e) => (e.rpcClientDescriptors ?? []).map((e) => ({
|
|
7539
7557
|
tag: e.tag,
|
|
7540
7558
|
kind: e.kind,
|
|
7541
7559
|
module: e.import.module,
|
|
@@ -7548,7 +7566,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7548
7566
|
...o?.name === void 0 ? {} : { apiName: o.name }
|
|
7549
7567
|
});
|
|
7550
7568
|
E ? ($.info("codegen wrote rpcGroup", { path: c(t, E) }), await gc(E)) : $.debug("codegen skipped — no descriptors discovered");
|
|
7551
|
-
let D =
|
|
7569
|
+
let D = Tp(o ?? null), ee = D === "mariadb" ? "mariadb" : D === "mssql" ? "mssql" : void 0, te = ee !== void 0 && (process.env.CDC ?? "1") !== "0", { queries: O, mutations: k, actions: A, streams: j, workflows: M, workflowWorkers: ie, eventTriggers: ae, schedules: P, tables: oe, featureMix: se, tenantScopedTables: ce, softDeleteScopedTables: le } = await _p(v, { cdc: te }), ue = M.length > 0 || ae.length > 0, F = await vp(t);
|
|
7552
7570
|
jt(Dt(F?.secrets)), await Qi({
|
|
7553
7571
|
rawEnv: F?.env,
|
|
7554
7572
|
appType: "api",
|
|
@@ -7556,7 +7574,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7556
7574
|
log: $,
|
|
7557
7575
|
generateTypes: !0
|
|
7558
7576
|
});
|
|
7559
|
-
let de = F?.apiKeys, pe = (typeof de == "object" ? de.prefix : void 0) ?? "voltro_", me, ge = de ? [Ve({ resolveByHash: (e, t) => me ? me.resolveByHash(e, t) : Promise.resolve(null) }, { prefix: pe })] : [], _e =
|
|
7577
|
+
let de = F?.apiKeys, pe = (typeof de == "object" ? de.prefix : void 0) ?? "voltro_", me, ge = de ? [Ve({ resolveByHash: (e, t) => me ? me.resolveByHash(e, t) : Promise.resolve(null) }, { prefix: pe })] : [], _e = Mf([...F?.auth?.strategies ?? [], ...ge], ei(F?.plugins ?? []), F?.auth?.anonymousTenantRequired ?? !1), ve = Nf(_e), ye = Il({
|
|
7560
7578
|
mix: se,
|
|
7561
7579
|
plugins: F?.plugins ?? [],
|
|
7562
7580
|
cdc: te,
|
|
@@ -7570,7 +7588,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7570
7588
|
return t;
|
|
7571
7589
|
})();
|
|
7572
7590
|
for (let e of I) Qn(e);
|
|
7573
|
-
let xe =
|
|
7591
|
+
let xe = Nd({
|
|
7574
7592
|
plugins: F?.plugins ?? [],
|
|
7575
7593
|
appName: F?.name ?? i(t),
|
|
7576
7594
|
appType: "api",
|
|
@@ -7578,21 +7596,21 @@ ${a.join("\n\n")}\n`);
|
|
|
7578
7596
|
log: $
|
|
7579
7597
|
});
|
|
7580
7598
|
F?.plugins?.length && ($.info("plugins loaded", { plugins: F.plugins.map((e) => e.name) }), await xe.activate());
|
|
7581
|
-
let Se = await xe.gatherObservability(), Ce =
|
|
7599
|
+
let Se = await xe.gatherObservability(), Ce = Vd(F?.plugins ?? []);
|
|
7582
7600
|
Ce.endpoints.length > 0 && $.info("plugin inspect endpoints registered", {
|
|
7583
7601
|
count: Ce.endpoints.length,
|
|
7584
7602
|
endpoints: Ce.endpoints.map((e) => `${e.method} ${e.path}`)
|
|
7585
7603
|
});
|
|
7586
|
-
let we =
|
|
7604
|
+
let we = Qd(F?.plugins ?? []);
|
|
7587
7605
|
we.length > 0 && $.info("plugin dashboard mounts registered", {
|
|
7588
7606
|
count: we.length,
|
|
7589
7607
|
mounts: we.map((e) => `${e.fullId} (${e.slot})`)
|
|
7590
7608
|
});
|
|
7591
|
-
let Oe =
|
|
7609
|
+
let Oe = nl(F?.plugins ?? []);
|
|
7592
7610
|
Oe.length > 0 && $.info("plugin schema contributions", { plugins: Oe.map((e) => `${e.pluginName}: ${e.tables}t/${e.migrations}m`) });
|
|
7593
|
-
let Le =
|
|
7611
|
+
let Le = Jc(F?.plugins ?? []);
|
|
7594
7612
|
if (Le.length > 0) {
|
|
7595
|
-
|
|
7613
|
+
Yc(Le, [
|
|
7596
7614
|
...O.map((e) => e.descriptor.name),
|
|
7597
7615
|
...k.map((e) => e.descriptor.name),
|
|
7598
7616
|
...A.map((e) => e.descriptor.name),
|
|
@@ -7616,16 +7634,16 @@ ${a.join("\n\n")}\n`);
|
|
|
7616
7634
|
routes: Le.map((e) => `${e.plugin.name}:${e.descriptor.name} (${e.kind})`)
|
|
7617
7635
|
});
|
|
7618
7636
|
}
|
|
7619
|
-
let Be = $.child("agent"), He = v.filter((e) =>
|
|
7637
|
+
let Be = $.child("agent"), He = v.filter((e) => ol.test(i(e)));
|
|
7620
7638
|
if (He.length > 0) {
|
|
7621
|
-
let e = await
|
|
7639
|
+
let e = await sl(He, Be);
|
|
7622
7640
|
e > 0 && Be.info("wired tool handlers", { tools: e });
|
|
7623
7641
|
}
|
|
7624
|
-
let We = v.filter((e) =>
|
|
7642
|
+
let We = v.filter((e) => il.test(i(e))), Ge = [];
|
|
7625
7643
|
if (We.length > 0) {
|
|
7626
|
-
let e = await
|
|
7644
|
+
let e = await ll(We, Be);
|
|
7627
7645
|
Ge = e.agents.map((e) => e.descriptor.name);
|
|
7628
|
-
for (let t of e.agents) for (let e of
|
|
7646
|
+
for (let t of e.agents) for (let e of vd(t)) e.kind === "action" ? A.push({
|
|
7629
7647
|
file: e.file,
|
|
7630
7648
|
descriptor: e.descriptor,
|
|
7631
7649
|
executor: e.executor
|
|
@@ -7639,15 +7657,15 @@ ${a.join("\n\n")}\n`);
|
|
|
7639
7657
|
routes: e.agents.flatMap((e) => [`${e.descriptor.name}.send`, `${e.descriptor.name}.messages`])
|
|
7640
7658
|
});
|
|
7641
7659
|
}
|
|
7642
|
-
let Ke =
|
|
7660
|
+
let Ke = bd();
|
|
7643
7661
|
(Ke.queries.length > 0 || Ke.mutations.length > 0) && (O.push(...Ke.queries), k.push(...Ke.mutations), $.info("undo built-ins registered", { routes: [
|
|
7644
7662
|
"__voltro.undo.log",
|
|
7645
7663
|
"__voltro.undo.apply",
|
|
7646
7664
|
"__voltro.undo.redo"
|
|
7647
7665
|
] }));
|
|
7648
|
-
let qe = $.child("aggregate"), Je = v.filter((e) =>
|
|
7666
|
+
let qe = $.child("aggregate"), Je = v.filter((e) => Yf.test(e)), Ye = Je.length > 0 ? await zu(Je, qe) : [], rt = Ye.map((e) => e.definition.name);
|
|
7649
7667
|
for (let e of Zn()) $.warn(`identifier length · ${e}`);
|
|
7650
|
-
let ot = F?.restRoutes ?? [], lt = v.filter((e) =>
|
|
7668
|
+
let ot = F?.restRoutes ?? [], lt = v.filter((e) => qf.test(e)).length, pt = v.filter((e) => Wf.test(e)).length, ht = v.filter((e) => /\.seed\.ts$/.test(e)).length, gt = v.filter((e) => Kf.test(e)).length, _t = v.filter((e) => hd.test(e)).length;
|
|
7651
7669
|
$.info("app surface", {
|
|
7652
7670
|
queryCount: O.length,
|
|
7653
7671
|
mutationCount: k.length,
|
|
@@ -7687,12 +7705,12 @@ ${a.join("\n\n")}\n`);
|
|
|
7687
7705
|
},
|
|
7688
7706
|
tenantTables: [...ce]
|
|
7689
7707
|
});
|
|
7690
|
-
let vt =
|
|
7708
|
+
let vt = vl(), xt = (process.env.VOLTRO_TRACING_BUFFER ?? "").toLowerCase() === "off", St = (process.env.VOLTRO_TRACING_STREAM ?? "").toLowerCase() === "all", Ct = () => {}, Tt = (e) => {
|
|
7691
7709
|
if (!e.name.startsWith("http.server")) return !1;
|
|
7692
7710
|
let t = e.attributes, n = String(t["url.path"] ?? t["http.route"] ?? t["http.target"] ?? "");
|
|
7693
7711
|
return n.startsWith("/_voltro/") || n === "/ws" || n.startsWith("/ws/") || n.startsWith("/ws?");
|
|
7694
7712
|
}, Et = (e) => {
|
|
7695
|
-
Tt(e) ||
|
|
7713
|
+
Tt(e) || dl(e) || e.name.startsWith("RpcServer.") || (vt.append(e), (St || e.status === "error") && p.emit("trace", e), Ct(e));
|
|
7696
7714
|
}, Ot = xt ? void 0 : et(Et), At = await Pe({
|
|
7697
7715
|
serviceName: process.env.OTEL_SERVICE_NAME ?? F?.name ?? "voltro-api",
|
|
7698
7716
|
...Ot ? { traceSink: Ot } : {},
|
|
@@ -7702,12 +7720,12 @@ ${a.join("\n\n")}\n`);
|
|
|
7702
7720
|
...Se.sampler === void 0 ? {} : { sampler: Se.sampler }
|
|
7703
7721
|
});
|
|
7704
7722
|
At.mode === "off" ? At.bufferOnly || $.info("tracing disabled", { reason: "buffer off" }) : $.info("tracing enabled", { mode: At.mode });
|
|
7705
|
-
let It = At.mode === "off" && At.bufferOnly === !1 ? void 0 : At.layer, L = await
|
|
7723
|
+
let It = At.mode === "off" && At.bufferOnly === !1 ? void 0 : At.layer, L = await Ep(F, It);
|
|
7706
7724
|
de && (me = Qe(Re(L), { prefix: pe }), $.info("api keys active", { prefix: pe }));
|
|
7707
|
-
let Lt =
|
|
7725
|
+
let Lt = Tp(F), Rt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, Bt, Vt;
|
|
7708
7726
|
if (Lt !== "memory") {
|
|
7709
|
-
let e = await
|
|
7710
|
-
Bt = C.make(e.makeSqlLayer(
|
|
7727
|
+
let e = await Bc(Lt);
|
|
7728
|
+
Bt = C.make(e.makeSqlLayer(yp())), Vt = await Bt.runPromise(R.SqlClient);
|
|
7711
7729
|
}
|
|
7712
7730
|
let Ht = tt({
|
|
7713
7731
|
coordinator: [
|
|
@@ -7726,13 +7744,13 @@ ${a.join("\n\n")}\n`);
|
|
|
7726
7744
|
}
|
|
7727
7745
|
};
|
|
7728
7746
|
for (let e of F?.plugins ?? []) e.bindDataStore?.(L, Wt);
|
|
7729
|
-
let Gt = await
|
|
7747
|
+
let Gt = await Dp(L, F, Tp(F), $);
|
|
7730
7748
|
F?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = F.cache), F?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = F.cacheRedisUrl), F?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = F.cacheRedisDriver), F?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = F.cacheKeyPrefix);
|
|
7731
|
-
let { service: Kt, invalidationBus: Jt, snapshotCache: Yt, cache: Xt, backend: Zt, stats: Qt, dispose: $t } = await
|
|
7749
|
+
let { service: Kt, invalidationBus: Jt, snapshotCache: Yt, cache: Xt, backend: Zt, stats: Qt, dispose: $t } = await Rl({ env: process.env });
|
|
7732
7750
|
$.info(`cache backend resolved: ${Zt}` + (Zt === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), F?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = F.kv), F?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = F.kvRedisUrl), F?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = F.kvKeyPrefix);
|
|
7733
7751
|
let { kv: en, service: tn, backend: nn } = await $e({ store: L });
|
|
7734
7752
|
$.info(`kv backend resolved: ${nn}` + (nn === "database" ? " (durable, _voltro_kv)" : nn === "memory" ? " — in-process, non-durable" : ` (driver ${process.env.KV_REDIS_DRIVER ?? "resp"}, non-durable)`));
|
|
7735
|
-
let rn =
|
|
7753
|
+
let rn = Tp(F), an = F?.analytics !== void 0 && F.analytics.kind !== "noop" && rn !== "memory" ? (await Bc(rn)).makeSqlLayer(yp()) : void 0, on = await nu({
|
|
7736
7754
|
spec: F?.analytics,
|
|
7737
7755
|
sqlLayer: an,
|
|
7738
7756
|
log: $
|
|
@@ -7749,7 +7767,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7749
7767
|
}), process.on("beforeExit", () => {
|
|
7750
7768
|
cn.detach();
|
|
7751
7769
|
});
|
|
7752
|
-
let ln = on.dispose, un =
|
|
7770
|
+
let ln = on.dispose, un = Tp(F), dn;
|
|
7753
7771
|
if (un !== "memory" && process.env.VOLTRO_AUTO_MIGRATE !== "0") {
|
|
7754
7772
|
let e = Date.now(), n = (process.env.NODE_ENV ?? "").toLowerCase() === "production" ? "prod" : (process.env.NODE_ENV ?? "").toLowerCase() === "staging" ? "staging" : "dev";
|
|
7755
7773
|
$.info("auto-migrate: planning schema", {
|
|
@@ -7761,8 +7779,8 @@ ${a.join("\n\n")}\n`);
|
|
|
7761
7779
|
tablesTotal: I.length
|
|
7762
7780
|
});
|
|
7763
7781
|
try {
|
|
7764
|
-
let r = await
|
|
7765
|
-
dn = i, await Jr(
|
|
7782
|
+
let r = await Bc(un), i = r.makeSqlLayer(yp());
|
|
7783
|
+
dn = i, await Jr(up(I.filter((e) => e.tableName.startsWith("_voltro_") || e.tableName === "voltro_isr_cache"), I), i, r.id);
|
|
7766
7784
|
let a = await y.runPromise(R.SqlClient.pipe(y.flatMap((e) => qr(e, {
|
|
7767
7785
|
projectRoot: t,
|
|
7768
7786
|
env: n,
|
|
@@ -7783,11 +7801,11 @@ ${a.join("\n\n")}\n`);
|
|
|
7783
7801
|
}), e;
|
|
7784
7802
|
}
|
|
7785
7803
|
} else un !== "memory" && $.info("auto-migrate: skipped (VOLTRO_AUTO_MIGRATE=0)");
|
|
7786
|
-
let fn =
|
|
7804
|
+
let fn = Tp(F);
|
|
7787
7805
|
if ((F?.plugins ?? []).some((e) => (e.extendSchema?.migrations?.length ?? 0) > 0) && fn !== "memory") {
|
|
7788
|
-
let e = (await
|
|
7806
|
+
let e = (await Bc(fn)).makeSqlLayer(yp());
|
|
7789
7807
|
try {
|
|
7790
|
-
let t = await y.runPromise(
|
|
7808
|
+
let t = await y.runPromise(tl(F.plugins).pipe(y.provide(e))), n = t.filter((e) => e.status === "applied"), r = t.filter((e) => e.status === "skipped");
|
|
7791
7809
|
$.info("plugin migrations complete", {
|
|
7792
7810
|
applied: n.map((e) => `${e.pluginName}:${e.migrationId} (${e.durationMs}ms)`),
|
|
7793
7811
|
skippedCount: r.length
|
|
@@ -7796,34 +7814,34 @@ ${a.join("\n\n")}\n`);
|
|
|
7796
7814
|
throw $.error("plugin migrations failed — aborting boot", { err: e }), e;
|
|
7797
7815
|
}
|
|
7798
7816
|
}
|
|
7799
|
-
let pn =
|
|
7817
|
+
let pn = Sf(L, p);
|
|
7800
7818
|
process.on("beforeExit", () => {
|
|
7801
7819
|
pn();
|
|
7802
7820
|
});
|
|
7803
|
-
let mn = $.child("seeds"), hn = v.filter((e) => /\.seed\.ts$/.test(e)), gn = hn.length > 0 ? await
|
|
7821
|
+
let mn = $.child("seeds"), hn = v.filter((e) => /\.seed\.ts$/.test(e)), gn = hn.length > 0 ? await hu(hn, mn) : [];
|
|
7804
7822
|
if (gn.length > 0) {
|
|
7805
7823
|
mn.info("discovered seeds", { ids: gn.map((e) => e.definition.id) });
|
|
7806
7824
|
for (let e of gn) r.registerSeed(e);
|
|
7807
|
-
let e = await
|
|
7825
|
+
let e = await bu(gn, L, mn);
|
|
7808
7826
|
for (let t of e) r.recordSeedResult(t);
|
|
7809
7827
|
let t = e.filter((e) => e.status === "failed");
|
|
7810
7828
|
t.length > 0 && mn.warn("one or more seeds failed (server continues)", { failedIds: t.map((e) => e.seedId) });
|
|
7811
7829
|
}
|
|
7812
|
-
let _n = $.child("startup"), vn = v.filter((e) =>
|
|
7830
|
+
let _n = $.child("startup"), vn = v.filter((e) => Wf.test(e)), yn = vn.length > 0 ? await n(vn, _n) : [], Cn;
|
|
7813
7831
|
yn.length > 0 && (_n.info("discovered startups", { ids: yn.map((e) => e.id) }), Cn = await e(yn, L, _n)), Cn && process.on("beforeExit", () => {
|
|
7814
7832
|
Cn.shutdown();
|
|
7815
7833
|
});
|
|
7816
|
-
let wn = $.child("subscribe"), Tn = v.filter((e) =>
|
|
7817
|
-
En.length > 0 && (wn.info("discovered subscribers", { subscribers: En.map((e) => `${e.id}@${e.definition.table}`) }), Dn =
|
|
7834
|
+
let wn = $.child("subscribe"), Tn = v.filter((e) => qf.test(e)), En = Tn.length > 0 ? await wu(Tn, wn) : [], Dn;
|
|
7835
|
+
En.length > 0 && (wn.info("discovered subscribers", { subscribers: En.map((e) => `${e.id}@${e.definition.table}`) }), Dn = Tu(En, L, wn)), Dn && process.on("beforeExit", () => {
|
|
7818
7836
|
Dn();
|
|
7819
7837
|
});
|
|
7820
|
-
let jn =
|
|
7838
|
+
let jn = Mu(), Hn = Tp(F);
|
|
7821
7839
|
if (Ye.length > 0 && Hn !== "memory") try {
|
|
7822
|
-
jn =
|
|
7840
|
+
jn = Lu((await Bc(Hn)).makeSqlLayer(yp()));
|
|
7823
7841
|
} catch (e) {
|
|
7824
7842
|
qe.warn("aggregate: SQL storage init failed — falling back to in-process", { err: e });
|
|
7825
7843
|
}
|
|
7826
|
-
let Un = Hn === "memory" ? Mt : Ze(L, `aggregate@${process.pid}`, qe), Wn = Ye.length > 0 ? await
|
|
7844
|
+
let Un = Hn === "memory" ? Mt : Ze(L, `aggregate@${process.pid}`, qe), Wn = Ye.length > 0 ? await Xu({
|
|
7827
7845
|
discovered: Ye,
|
|
7828
7846
|
store: L,
|
|
7829
7847
|
analytics: sn,
|
|
@@ -7831,7 +7849,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7831
7849
|
coordinator: Un,
|
|
7832
7850
|
log: qe
|
|
7833
7851
|
}) : {
|
|
7834
|
-
registry:
|
|
7852
|
+
registry: Zu,
|
|
7835
7853
|
detach: () => {},
|
|
7836
7854
|
registered: []
|
|
7837
7855
|
};
|
|
@@ -7842,7 +7860,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7842
7860
|
}), process.on("beforeExit", () => {
|
|
7843
7861
|
Wn.detach();
|
|
7844
7862
|
});
|
|
7845
|
-
let z =
|
|
7863
|
+
let z = Tp(F), Gn, Kn = F?.scheduling ?? {}, qn = Kn.trigger ?? "self", Jn = Kn.coordination ?? ([
|
|
7846
7864
|
"postgres",
|
|
7847
7865
|
"mariadb",
|
|
7848
7866
|
"mysql",
|
|
@@ -7860,9 +7878,9 @@ ${a.join("\n\n")}\n`);
|
|
|
7860
7878
|
}
|
|
7861
7879
|
})) : [], ir = await (async () => {
|
|
7862
7880
|
if (z === "memory") return Sn.layerMemory;
|
|
7863
|
-
let e = await
|
|
7881
|
+
let e = await Bc(z), t = e.makeSqlLayer(yp()), n = Bn({ sqliteFamily: tr(e.id) });
|
|
7864
7882
|
if ($.info(`workflow engine: cluster-${n}, dialect=${e.id}` + (n === "memory" ? " — single-process durable replay, no horizontal scaling" + (tr(e.id) ? "" : " (VOLTRO_WORKFLOW_RUNNER_STORAGE=memory: SqlRunnerStorage/cluster_runners + GET_LOCK skipped)") : "")), e.id === "mssql") {
|
|
7865
|
-
let e = await
|
|
7883
|
+
let e = await fu(process.cwd());
|
|
7866
7884
|
e && $.warn(e);
|
|
7867
7885
|
}
|
|
7868
7886
|
return Vn({
|
|
@@ -7943,7 +7961,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7943
7961
|
});
|
|
7944
7962
|
return;
|
|
7945
7963
|
}
|
|
7946
|
-
}, V = M.length > 0 ? it(() => ar) : void 0, dr = $.child("webhooks"), fr = v.filter((e) =>
|
|
7964
|
+
}, V = M.length > 0 ? it(() => ar) : void 0, dr = $.child("webhooks"), fr = v.filter((e) => Kf.test(e)), H = fr.length > 0 ? await md(fr, dr) : {
|
|
7947
7965
|
outgoing: [],
|
|
7948
7966
|
incoming: [],
|
|
7949
7967
|
providers: []
|
|
@@ -7953,9 +7971,9 @@ ${a.join("\n\n")}\n`);
|
|
|
7953
7971
|
incoming: H.incoming.map((e) => e.descriptor.id),
|
|
7954
7972
|
providers: H.providers.map((e) => e.descriptor.id)
|
|
7955
7973
|
});
|
|
7956
|
-
let pr = v.filter((e) =>
|
|
7974
|
+
let pr = v.filter((e) => hd.test(e));
|
|
7957
7975
|
if (pr.length > 0) {
|
|
7958
|
-
let e = $.child("mail"), t = await
|
|
7976
|
+
let e = $.child("mail"), t = await gd(pr, e);
|
|
7959
7977
|
t.templates.length > 0 && (fi(t.templates.map((e) => e.template)), e.info("discovered email templates", { templates: t.templates.map((e) => e.template.name) }));
|
|
7960
7978
|
}
|
|
7961
7979
|
let gr = /* @__PURE__ */ new Map();
|
|
@@ -7983,8 +8001,8 @@ ${a.join("\n\n")}\n`);
|
|
|
7983
8001
|
secretEnvKey: n
|
|
7984
8002
|
});
|
|
7985
8003
|
}
|
|
7986
|
-
let br = $.child("reaction"), xr = v.filter((e) =>
|
|
7987
|
-
Cr.length > 0 && (br.info("discovered reactions", { reactions: Cr.map((e) => `${e.definition.name}@${e.definition.watch.table}`) }), wr =
|
|
8004
|
+
let br = $.child("reaction"), xr = v.filter((e) => Jf.test(e)), Cr = xr.length > 0 ? await Du(xr, br) : [], wr;
|
|
8005
|
+
Cr.length > 0 && (br.info("discovered reactions", { reactions: Cr.map((e) => `${e.definition.name}@${e.definition.watch.table}`) }), wr = ku(Cr, L, {
|
|
7988
8006
|
runAct: async (e, t) => {
|
|
7989
8007
|
if (e.kind === "workflow") {
|
|
7990
8008
|
if (V === void 0) {
|
|
@@ -7998,7 +8016,7 @@ ${a.join("\n\n")}\n`);
|
|
|
7998
8016
|
}).start(e.workflow, n);
|
|
7999
8017
|
return;
|
|
8000
8018
|
}
|
|
8001
|
-
await
|
|
8019
|
+
await Ou(e.agent, t, {
|
|
8002
8020
|
findAgentSend: (e) => A.find((t) => t.descriptor.name === `${e}.send`),
|
|
8003
8021
|
runAction: (e, t, n) => Promise.resolve(Pi(e, t, n)),
|
|
8004
8022
|
makeSubject: (e) => yr(e),
|
|
@@ -8115,7 +8133,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8115
8133
|
...j.map((e) => Or(e.descriptor, ri)),
|
|
8116
8134
|
...Zr,
|
|
8117
8135
|
...Qr
|
|
8118
|
-
], li = xn.make(...ii).middleware(mr).middleware(hr), di = F?.layers ?? [], pi = (F?.plugins ?? []).map((e) => e.services).filter((e) => e !== void 0), mi = S.succeed(fe, Wn.registry), gi = S.mergeAll(
|
|
8136
|
+
], li = xn.make(...ii).middleware(mr).middleware(hr), di = F?.layers ?? [], pi = (F?.plugins ?? []).map((e) => e.services).filter((e) => e !== void 0), mi = S.succeed(fe, Wn.registry), gi = S.mergeAll(Ul({
|
|
8119
8137
|
analyticsLayer: on.layer,
|
|
8120
8138
|
cacheService: Kt,
|
|
8121
8139
|
kvService: tn,
|
|
@@ -8126,7 +8144,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8126
8144
|
userLayers: di.length,
|
|
8127
8145
|
pluginLayers: pi.length
|
|
8128
8146
|
});
|
|
8129
|
-
let _i = (e, t) => kt(e.pipe(y.provide(nt(t)), y.provide(gi), y.provide(
|
|
8147
|
+
let _i = (e, t) => kt(e.pipe(y.provide(nt(t)), y.provide(gi), y.provide(Df))), vi = ct(I);
|
|
8130
8148
|
if ((process.env.VOLTRO_INDEX_AUDIT ?? "on") !== "off") {
|
|
8131
8149
|
let e = Xn(I), t = process.stdout.isTTY === !0 && (process.env.NO_COLOR ?? "") === "";
|
|
8132
8150
|
for (let n of e) $.warn("\n" + $n(n, {
|
|
@@ -8160,7 +8178,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8160
8178
|
}
|
|
8161
8179
|
let yi = (process.env.VOLTRO_TENANT_ISOLATION ?? F?.tenancy?.isolation) === "namespace";
|
|
8162
8180
|
yi && $.info("multi-tenancy: PHYSICAL namespace isolation ON — each request runs against its tenant's own namespace (schema/database/attached file). Requests without a resolvable tenant fail closed.");
|
|
8163
|
-
let bi =
|
|
8181
|
+
let bi = Bl({
|
|
8164
8182
|
store: L,
|
|
8165
8183
|
schemaRegistry: vi,
|
|
8166
8184
|
cache: Xt,
|
|
@@ -8177,7 +8195,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8177
8195
|
info: (e, t) => $.info(e, t ?? {}),
|
|
8178
8196
|
warn: (e, t) => $.warn(e, t ?? {})
|
|
8179
8197
|
}) : t = Mt;
|
|
8180
|
-
let n =
|
|
8198
|
+
let n = Ud(F?.plugins ?? [], Oi);
|
|
8181
8199
|
Gn = await Ft(P, {
|
|
8182
8200
|
store: L,
|
|
8183
8201
|
coordinator: t,
|
|
@@ -8185,9 +8203,9 @@ ${a.join("\n\n")}\n`);
|
|
|
8185
8203
|
replicaId: e,
|
|
8186
8204
|
armSelf: !er,
|
|
8187
8205
|
dormancy: F?.dormancy ?? "always-on",
|
|
8188
|
-
dormancyTenantId:
|
|
8206
|
+
dormancyTenantId: kf,
|
|
8189
8207
|
buildContext: ({ traceId: e, scheduleName: t }) => bi({
|
|
8190
|
-
subject: yr(
|
|
8208
|
+
subject: yr(kf),
|
|
8191
8209
|
traceId: e
|
|
8192
8210
|
}, L, void 0, `schedule:${t}`),
|
|
8193
8211
|
log: {
|
|
@@ -8237,13 +8255,13 @@ ${a.join("\n\n")}\n`);
|
|
|
8237
8255
|
scope: n.scope,
|
|
8238
8256
|
baseKey: `q:${e.name}:${Ei(t)}`
|
|
8239
8257
|
};
|
|
8240
|
-
}, Oi = ic(), ki = F?.plugins ?? [], Ai = Sr(
|
|
8258
|
+
}, Oi = ic(), ki = F?.plugins ?? [], Ai = Sr(Id(ki, "mutation", Oi)), ji = Sr(Id(ki, "action", Oi)), Mi = Sr(Id(ki, "query", Oi)), Ni = at({
|
|
8241
8259
|
store: L,
|
|
8242
8260
|
buildContext: (e, t, n) => bi(e, t, n),
|
|
8243
8261
|
runEffect: (e, t) => _i(e, t),
|
|
8244
8262
|
...Ai ? { interceptor: Ai } : {},
|
|
8245
8263
|
recordMetric: (e) => Oi.record(e),
|
|
8246
|
-
undoCapture:
|
|
8264
|
+
undoCapture: xd()
|
|
8247
8265
|
}), Pi = Xe({
|
|
8248
8266
|
buildContext: (e) => bi(e),
|
|
8249
8267
|
runEffect: (e, t) => _i(e, t),
|
|
@@ -8255,7 +8273,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8255
8273
|
let n = Si(e, t);
|
|
8256
8274
|
return wi(n), n;
|
|
8257
8275
|
},
|
|
8258
|
-
provideEffect: (e, t) => e.pipe(y.provide(nt(t)), y.provide(
|
|
8276
|
+
provideEffect: (e, t) => e.pipe(y.provide(nt(t)), y.provide(Df)),
|
|
8259
8277
|
...Mi ? { interceptor: Mi } : {}
|
|
8260
8278
|
});
|
|
8261
8279
|
for (let e of O) G[e.descriptor.name] = (t) => Ne(Fi(e, t), U, `subscription.${e.descriptor.name}`, Ti, Di(e.descriptor, t));
|
|
@@ -8271,7 +8289,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8271
8289
|
let t = `stream.${e.descriptor.name}`;
|
|
8272
8290
|
G[e.descriptor.name] = (n) => Me((t) => {
|
|
8273
8291
|
let r = bi(t), i = e.executor(n, r);
|
|
8274
|
-
return y.isEffect(i) ? i.pipe(y.provide(nt(r.store)), y.provide(gi), y.provide(
|
|
8292
|
+
return y.isEffect(i) ? i.pipe(y.provide(nt(r.store)), y.provide(gi), y.provide(Df)) : typeof i == "object" && i && typeof i.then == "function" ? y.promise(() => i) : i;
|
|
8275
8293
|
}, t);
|
|
8276
8294
|
}
|
|
8277
8295
|
ue && (G[Lr.name] = (e) => Ne(Fi({
|
|
@@ -8372,16 +8390,16 @@ ${a.join("\n\n")}\n`);
|
|
|
8372
8390
|
}
|
|
8373
8391
|
}, e), U, `subscription.${Pr.name}`), G[Mr.name] = (e) => je(async (e, t) => {
|
|
8374
8392
|
let n = e;
|
|
8375
|
-
return await
|
|
8393
|
+
return await Vl(L, t.subject, { executionId: n.executionId }), await V.cancel(n.workflowName, n.executionId), await Gi(n.workflowName, n.executionId, "workflow.cancel"), { ok: !0 };
|
|
8376
8394
|
}, e, `action.${Mr.name}`), G[Fr.name] = (e) => je(async (e, t) => {
|
|
8377
8395
|
let n = e;
|
|
8378
|
-
return await
|
|
8396
|
+
return await Vl(L, t.subject, { executionId: n.executionId }), await V.resume(n.workflowName, n.executionId), { ok: !0 };
|
|
8379
8397
|
}, e, `action.${Fr.name}`), G[Br.name] = (e) => je(async (e, t) => {
|
|
8380
8398
|
let n = e;
|
|
8381
|
-
return await
|
|
8399
|
+
return await Vl(L, t.subject, { id: n.id }), V.signal({ id: n.id }, n.signalName, n.payload);
|
|
8382
8400
|
}, e, `action.${Br.name}`), G[Vr.name] = (e) => je(async (e, t) => {
|
|
8383
8401
|
let n = e;
|
|
8384
|
-
return await
|
|
8402
|
+
return await Vl(L, t.subject, { id: n.id }), V.update({ id: n.id }, n.updateName, n.payload, n.timeoutMs === void 0 ? void 0 : { timeoutMs: n.timeoutMs });
|
|
8385
8403
|
}, e, `action.${Vr.name}`));
|
|
8386
8404
|
for (let e of M) G[e.definition.name] = (t) => je(async (t, n) => {
|
|
8387
8405
|
let r = n;
|
|
@@ -8391,18 +8409,18 @@ ${a.join("\n\n")}\n`);
|
|
|
8391
8409
|
source: "workflow-rpc"
|
|
8392
8410
|
}).start(e.definition.name, t);
|
|
8393
8411
|
}, t, `workflow.${e.definition.name}`);
|
|
8394
|
-
let Ii = yr(
|
|
8412
|
+
let Ii = yr(kf), Li = (e, t) => bi({
|
|
8395
8413
|
subject: e?.subject ?? Ii,
|
|
8396
8414
|
traceId: e?.traceId ?? "workflow-bootstrap"
|
|
8397
|
-
}, L, void 0, `workflow:${t.workflowName}`, { parentExecutionId: t.executionId }), Ri =
|
|
8415
|
+
}, L, void 0, `workflow:${t.workflowName}`, { parentExecutionId: t.executionId }), Ri = Gd(F?.plugins ?? [], Oi), zi = Fn, Bi = (e, t) => p.emit(e, t), Vi = F?.dormancy === "sleep" ? {
|
|
8398
8416
|
register: (e, t, n) => wt(L, {
|
|
8399
|
-
tenantId: n ??
|
|
8417
|
+
tenantId: n ?? kf,
|
|
8400
8418
|
kind: "workflow",
|
|
8401
8419
|
refId: e,
|
|
8402
8420
|
wakeAt: t
|
|
8403
8421
|
}),
|
|
8404
8422
|
cancel: (e, t) => Fe(L, {
|
|
8405
|
-
tenantId: t ??
|
|
8423
|
+
tenantId: t ?? kf,
|
|
8406
8424
|
kind: "workflow",
|
|
8407
8425
|
refId: e
|
|
8408
8426
|
}).then(() => {})
|
|
@@ -8512,22 +8530,22 @@ ${a.join("\n\n")}\n`);
|
|
|
8512
8530
|
payload: n,
|
|
8513
8531
|
...r === void 0 ? {} : { options: r }
|
|
8514
8532
|
}),
|
|
8515
|
-
listRuns: (e) =>
|
|
8516
|
-
retry: (e, t) =>
|
|
8533
|
+
listRuns: (e) => Yd(L, e),
|
|
8534
|
+
retry: (e, t) => Xd({
|
|
8517
8535
|
store: L,
|
|
8518
8536
|
workflows: M,
|
|
8519
8537
|
runPromise: (e) => Yi.runPromise(e)
|
|
8520
8538
|
}, e, t)
|
|
8521
8539
|
}) : void 0;
|
|
8522
|
-
let Xi = S.mergeAll(li.toLayer(G), ve,
|
|
8523
|
-
if (ea === "postgres" &&
|
|
8524
|
-
let e =
|
|
8540
|
+
let Xi = S.mergeAll(li.toLayer(G), ve, Pf), Zi = Gl(G, O.map((e) => e.descriptor.name), ue), $i = S.mergeAll(li.toLayer(Zi), ve, Pf), ea = z, ta = (ea === "postgres" || ea === "mysql" || ea === "mariadb" || ea === "mssql") && (process.env.CDC ?? "1") !== "0";
|
|
8541
|
+
if (ea === "postgres" && wl()) {
|
|
8542
|
+
let e = kl({
|
|
8525
8543
|
store: L,
|
|
8526
8544
|
log: $
|
|
8527
8545
|
});
|
|
8528
8546
|
Ct = e.persistTraceSpan, process.on("beforeExit", e.stop);
|
|
8529
8547
|
}
|
|
8530
|
-
let na =
|
|
8548
|
+
let na = zl({
|
|
8531
8549
|
store: L,
|
|
8532
8550
|
dialect: ea
|
|
8533
8551
|
});
|
|
@@ -8604,7 +8622,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8604
8622
|
result: await Ni(e, t, r)
|
|
8605
8623
|
};
|
|
8606
8624
|
} catch (t) {
|
|
8607
|
-
let n =
|
|
8625
|
+
let n = Lf(t);
|
|
8608
8626
|
return $.warn(`inspect invoke failed: ${e.descriptor.name}`, {
|
|
8609
8627
|
tag: e.descriptor.name,
|
|
8610
8628
|
error: n
|
|
@@ -8628,7 +8646,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8628
8646
|
result: await Pi(e, t, r)
|
|
8629
8647
|
};
|
|
8630
8648
|
} catch (t) {
|
|
8631
|
-
let n =
|
|
8649
|
+
let n = Lf(t);
|
|
8632
8650
|
return $.warn(`inspect invoke failed: ${e.descriptor.name}`, {
|
|
8633
8651
|
tag: e.descriptor.name,
|
|
8634
8652
|
error: n
|
|
@@ -8749,7 +8767,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8749
8767
|
kind: "api",
|
|
8750
8768
|
meta: {
|
|
8751
8769
|
name: F?.name ?? i(t),
|
|
8752
|
-
voltroVersion:
|
|
8770
|
+
voltroVersion: Of,
|
|
8753
8771
|
port: l,
|
|
8754
8772
|
mode: "dev",
|
|
8755
8773
|
store: ea,
|
|
@@ -8800,7 +8818,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8800
8818
|
database: la,
|
|
8801
8819
|
migrations: async () => ua(),
|
|
8802
8820
|
inspectTables: () => ({ tables: I.map((e) => {
|
|
8803
|
-
let t =
|
|
8821
|
+
let t = sp(e), n = cp(t);
|
|
8804
8822
|
return {
|
|
8805
8823
|
name: e.tableName,
|
|
8806
8824
|
isFrameworkTable: e.tableName.startsWith("_voltro_"),
|
|
@@ -8813,11 +8831,11 @@ ${a.join("\n\n")}\n`);
|
|
|
8813
8831
|
inspectRows: async (e) => {
|
|
8814
8832
|
let t = Math.max(0, e.offset ?? 0), n = Math.max(1, Math.min(500, e.limit ?? 50)), r = I.find((t) => t.tableName === e.table);
|
|
8815
8833
|
if (!r) throw Error(`unknown table: ${e.table}`);
|
|
8816
|
-
let i =
|
|
8834
|
+
let i = sp(r), a = gf({
|
|
8817
8835
|
filter: e.filter,
|
|
8818
8836
|
quickSearch: e.quickSearch,
|
|
8819
8837
|
columns: i
|
|
8820
|
-
}), o =
|
|
8838
|
+
}), o = _f(e.sort, i), s = await L.query({
|
|
8821
8839
|
table: e.table,
|
|
8822
8840
|
order: o,
|
|
8823
8841
|
skip: t,
|
|
@@ -8833,7 +8851,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8833
8851
|
skip: void 0,
|
|
8834
8852
|
take: void 0
|
|
8835
8853
|
})).length, u = "exact"), {
|
|
8836
|
-
rows: s.map(
|
|
8854
|
+
rows: s.map(op),
|
|
8837
8855
|
total: l,
|
|
8838
8856
|
countMode: u,
|
|
8839
8857
|
offset: t,
|
|
@@ -8847,7 +8865,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8847
8865
|
return $.info("inspect.data.insert", {
|
|
8848
8866
|
table: e.table,
|
|
8849
8867
|
id: t?.id ?? null
|
|
8850
|
-
}), { row:
|
|
8868
|
+
}), { row: op(t) };
|
|
8851
8869
|
},
|
|
8852
8870
|
inspectUpdateRow: async (e) => {
|
|
8853
8871
|
if (e.table.startsWith("_voltro_")) throw Error(`inspect data viewer cannot write to framework-internal table: ${e.table}`);
|
|
@@ -8857,7 +8875,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8857
8875
|
table: e.table,
|
|
8858
8876
|
id: e.id,
|
|
8859
8877
|
patch: Object.keys(e.patch)
|
|
8860
|
-
}), { row: t ?
|
|
8878
|
+
}), { row: t ? op(t) : null };
|
|
8861
8879
|
},
|
|
8862
8880
|
inspectDeleteRow: async (e) => {
|
|
8863
8881
|
if (e.table.startsWith("_voltro_")) throw Error(`inspect data viewer cannot delete from framework-internal table: ${e.table}`);
|
|
@@ -8896,7 +8914,7 @@ ${a.join("\n\n")}\n`);
|
|
|
8896
8914
|
}).start(e.name, e.payload);
|
|
8897
8915
|
},
|
|
8898
8916
|
inspectWorkflowRuns: async (e) => {
|
|
8899
|
-
let { rows: t, total: n, offset: r, limit: i } = await
|
|
8917
|
+
let { rows: t, total: n, offset: r, limit: i } = await qd(L, {
|
|
8900
8918
|
...e.tag === void 0 ? {} : { tag: e.tag },
|
|
8901
8919
|
...e.status === void 0 ? {} : { status: e.status },
|
|
8902
8920
|
...e.offset === void 0 ? {} : { offset: e.offset },
|
|
@@ -9181,7 +9199,7 @@ ${a.join("\n\n")}\n`);
|
|
|
9181
9199
|
inspectRetryWorkflowRun: async (e) => {
|
|
9182
9200
|
let t = e.payloadOverride !== void 0;
|
|
9183
9201
|
try {
|
|
9184
|
-
let n = await
|
|
9202
|
+
let n = await Xd({
|
|
9185
9203
|
store: L,
|
|
9186
9204
|
workflows: M,
|
|
9187
9205
|
runPromise: (e) => Yi.runPromise(e)
|
|
@@ -9292,7 +9310,7 @@ ${a.join("\n\n")}\n`);
|
|
|
9292
9310
|
let e = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, t = z, n = t === "memory", r = n ? "none" : Bn({ sqliteFamily: t === "sqlite" || t === "turso" }), i = zn({
|
|
9293
9311
|
runnerStorage: r === "sql" ? "sql" : "memory",
|
|
9294
9312
|
...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {}
|
|
9295
|
-
}), a = !n && (process.env.CDC ?? "1") !== "0", o = t === "postgres" ? "LISTEN/NOTIFY" : t === "sqlite" || t === "turso" ? "in-process bus" : t === "mariadb" || t === "mysql" ? "binlog CDC (ROW)" : t === "mssql" ? "inline only" : t === "memory" ? "none (single-process)" : "inline only", s = t === "postgres" || t === "mariadb" || t === "mssql" ? "full" : t === "mysql" ? "inline-only" : t === "sqlite" || t === "turso" ? "single-process" : "none", c = er ? "cluster" : Jn === "advisoryLock" && z === "postgres" ? "advisoryLock" : "single", l = a && t === "mariadb" ?
|
|
9313
|
+
}), a = !n && (process.env.CDC ?? "1") !== "0", o = t === "postgres" ? "LISTEN/NOTIFY" : t === "sqlite" || t === "turso" ? "in-process bus" : t === "mariadb" || t === "mysql" ? "binlog CDC (ROW)" : t === "mssql" ? "inline only" : t === "memory" ? "none (single-process)" : "inline only", s = t === "postgres" || t === "mariadb" || t === "mssql" ? "full" : t === "mysql" ? "inline-only" : t === "sqlite" || t === "turso" ? "single-process" : "none", c = er ? "cluster" : Jn === "advisoryLock" && z === "postgres" ? "advisoryLock" : "single", l = a && t === "mariadb" ? wp(e) : void 0, u = {
|
|
9296
9314
|
replicaId: e,
|
|
9297
9315
|
dialect: t,
|
|
9298
9316
|
runnerHost: i.host,
|
|
@@ -9355,7 +9373,7 @@ ${a.join("\n\n")}\n`);
|
|
|
9355
9373
|
};
|
|
9356
9374
|
},
|
|
9357
9375
|
runSeed: async (e) => {
|
|
9358
|
-
let t = await
|
|
9376
|
+
let t = await xu(gn, e, L, mn);
|
|
9359
9377
|
return r.recordSeedResult(t), la();
|
|
9360
9378
|
},
|
|
9361
9379
|
rollbackMigration: async (e) => (mn.warn("rollbackMigration called but only memory store is wired — no-op"), la()),
|
|
@@ -9425,7 +9443,7 @@ ${a.join("\n\n")}\n`);
|
|
|
9425
9443
|
replay: (e) => W.replay(e),
|
|
9426
9444
|
updateTargetPayloadVersion: (e, t) => W.updateTargetPayloadVersion(e, t)
|
|
9427
9445
|
} }
|
|
9428
|
-
}, da =
|
|
9446
|
+
}, da = Zd(F?.plugins ?? [], Oi);
|
|
9429
9447
|
da !== void 0 && $.info("plugin http-request interceptor active", { plugins: (F?.plugins ?? []).filter((e) => typeof e.onHttpRequest == "function").map((e) => e.name) });
|
|
9430
9448
|
let fa = (F?.plugins ?? []).flatMap((e) => e.httpRoutes ?? []), pa = typeof de == "object" ? de.managementPath : void 0, ma = () => `public-${Math.random().toString(36).slice(2, 10)}`, ha = ti([...k.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
9431
9449
|
descriptor: e.descriptor,
|
|
@@ -9498,9 +9516,9 @@ ${a.join("\n\n")}\n`);
|
|
|
9498
9516
|
headers: X(t.origin)
|
|
9499
9517
|
};
|
|
9500
9518
|
if (n === "GET" && (e === "/_voltro/inspect/traces" || e.startsWith("/_voltro/inspect/traces?"))) {
|
|
9501
|
-
let n =
|
|
9519
|
+
let n = vl();
|
|
9502
9520
|
return {
|
|
9503
|
-
...
|
|
9521
|
+
...wf(e, ea === "postgres" && wl() ? await gp(e, n, L) : n),
|
|
9504
9522
|
headers: X(t.origin)
|
|
9505
9523
|
};
|
|
9506
9524
|
}
|
|
@@ -9561,11 +9579,11 @@ ${a.join("\n\n")}\n`);
|
|
|
9561
9579
|
if (r) return r;
|
|
9562
9580
|
}
|
|
9563
9581
|
if (e.startsWith("/_voltro/inspect/aggregates")) {
|
|
9564
|
-
let r = await
|
|
9582
|
+
let r = await nd(e, n, Wn.registry, X(t.origin));
|
|
9565
9583
|
if (r) return r;
|
|
9566
9584
|
}
|
|
9567
9585
|
if (e.startsWith("/_voltro/inspect/timeline")) {
|
|
9568
|
-
let r = await
|
|
9586
|
+
let r = await fd(e, n, {
|
|
9569
9587
|
recorder: Ue(),
|
|
9570
9588
|
readCurrentRows: async (e) => K.inspectRows === void 0 ? [] : (await K.inspectRows({
|
|
9571
9589
|
table: e,
|
|
@@ -9577,7 +9595,7 @@ ${a.join("\n\n")}\n`);
|
|
|
9577
9595
|
if (r) return r;
|
|
9578
9596
|
}
|
|
9579
9597
|
if (e.startsWith("/_voltro/inspect/analytics")) {
|
|
9580
|
-
let r =
|
|
9598
|
+
let r = od(e, n, {
|
|
9581
9599
|
sink: sn,
|
|
9582
9600
|
metricsCollector: Oi
|
|
9583
9601
|
}, X(t.origin));
|
|
@@ -9692,4 +9710,4 @@ ${a.join("\n\n")}\n`);
|
|
|
9692
9710
|
}), new Promise(() => {});
|
|
9693
9711
|
};
|
|
9694
9712
|
//#endregion
|
|
9695
|
-
export {
|
|
9713
|
+
export { Hc as $, Tu as A, go as At, Hl as B, q as Bt, Zu as C, jo as Ct, ku as D, Ao as Dt, Lu as E, ko as Et, xu as F, Ja as Ft, Rl as G, Xi as Gt, Vl as H, ya as Ht, mu as I, ba as It, wl as J, Hi as Jt, Ll as K, Yi as Kt, fu as L, J as Lt, Su as M, eo as Mt, hu as N, qa as Nt, Ou as O, wo as Ot, bu as P, Ka as Pt, sl as Q, nu as R, Ta as Rt, Xu as S, Wo as St, Mu as T, No as Tt, Bl as U, ga as Ut, Ul as V, va as Vt, zl as W, Qi as Wt, ol as X, W as Xt, il as Y, Ui as Yt, ll as Z, bd as _, es as _t, Lf as a, Fs as at, pd as b, Uo as bt, xp as c, $s as ct, $f as d, Ys as dt, Bc as et, Dp as f, os as ft, Nd as g, $o as gt, Ud as h, as as ht, yp as i, Js as it, wu as j, no as jt, Du as k, xo as kt, Mp as l, Ds as lt, Xd as m, hs as mt, Ep as n, ic as nt, vp as o, Zs as ot, Yd as p, is as pt, Il as q, Gi as qt, up as r, qs as rt, _p as s, Ks as st, Mf as t, Ic as tt, bp as u, Ps as ut, xd as v, ts as vt, zu as w, Mo as wt, md as x, Go as xt, vd as y, Ko as yt, Gl as z, X as zt };
|