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