@voltro/cli 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/bin/voltro.mjs +15 -6
- package/dist/apiBuild-CmtI6Ygh.js +2 -0
- package/dist/{apiBuild-BxY44VGj.js → apiBuild-OrDkXGFX.js} +21 -20
- package/dist/bin.js +2 -2
- package/dist/{commands-My_YlUJV.js → commands-DT4PipBz.js} +2489 -2972
- package/dist/dev-Ca1jdwnt.js +2 -0
- package/dist/dev-Ga65K4jc.js +6492 -0
- package/dist/index.js +1 -1
- package/dist/inspectMetrics-EK0CcHyu.js +3929 -0
- package/dist/{serveCommand-C-XQ89NJ.js → serveCommand-CR5xnYZt.js} +209 -208
- package/dist/serveEntry.js +3 -2
- package/dist/start-DuyBQxW3.js +977 -0
- package/dist/startEntry.d.ts +5 -0
- package/dist/startEntry.js +3 -0
- package/package.json +17 -17
- package/templates/AGENTS.core.md +15 -4
- package/templates/AGENTS.md +15 -4
- package/templates/agent-docs/authentication.md +111 -13
- package/templates/agent-docs/cli.md +94 -6
- package/templates/agent-docs/data.md +99 -31
- package/templates/agent-docs/database/schema.md +1 -1
- package/templates/agent-docs/reference.md +20 -0
- package/templates/agent-docs/routing.md +158 -24
- package/templates/agent-docs/testing.md +82 -0
- package/templates/apps/api-ai/package.json +7 -7
- package/templates/apps/api-auth/package.json +8 -8
- 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 -9
- 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 -7
- package/templates/apps/api-saas/package.json +11 -11
- 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 -8
- 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/dist/apiBuild-Bk4JBt-i.js +0 -2
- package/dist/dev-Bjq-nIvH.js +0 -10186
- package/dist/dev-D6b74iXI.js +0 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as e, vt as t } from "./inspectMetrics-EK0CcHyu.js";
|
|
2
|
+
import { A as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as u, K as d, M as ee, N as f, O as p, P as m, Q as te, S as h, T as g, U as ne, W as re, X as ie, Y as _, Z as ae, _ as oe, at as v, b as se, ct as y, d as b, et as x, f as ce, g as le, h as ue, i as S, it as de, j as C, k as w, m as fe, n as pe, nt as T, o as E, q as me, rt as he, s as ge, t as D, v as _e, w as ve, x as ye, y as be } from "./dev-Ga65K4jc.js";
|
|
2
3
|
import { a as xe, r as Se } from "./startupRunner-DhlX9nqd.js";
|
|
3
|
-
import { a as O, t as Ce } from "./apiBuild-
|
|
4
|
+
import { a as O, t as Ce } from "./apiBuild-OrDkXGFX.js";
|
|
4
5
|
import { join as we } from "node:path";
|
|
5
6
|
import { pathToFileURL as Te } from "node:url";
|
|
6
7
|
import { Cause as Ee, Effect as k, Layer as A, ManagedRuntime as De } from "effect";
|
|
@@ -12,8 +13,8 @@ import { assertProductionSessionSecret as ut } from "@voltro/protocol/session";
|
|
|
12
13
|
import { RpcGroup as dt } from "@effect/rpc";
|
|
13
14
|
import { SqlClient as ft } from "@effect/sql";
|
|
14
15
|
import { and as pt, ensureTableRegistered as mt, eq as U, or as ht } from "@voltro/database";
|
|
15
|
-
import { fromNodeReadable as gt, getObjectStream as
|
|
16
|
-
import { AuthMiddleware as
|
|
16
|
+
import { fromNodeReadable as gt, getObjectStream as _t, putObjectStream as vt, resolveStorageProvider as W, toNodeReadable as yt } from "@voltro/plugin-storage";
|
|
17
|
+
import { AuthMiddleware as bt, ConnectionInfoMiddleware as xt, actionToRpc as G, anonymousSubject as St, mutationToRpc as Ct, queryToRpc as K, streamToRpc as wt, workflowCancelDescriptor as Tt, workflowDomainEventsQueryDescriptor as q, workflowEventDeliveriesQueryDescriptor as Et, workflowResumeDescriptor as Dt, workflowRunEventsQueryDescriptor as J, workflowRunQueryDescriptor as Y, workflowRunStepsQueryDescriptor as Ot, workflowRunsQueryDescriptor as X, workflowSignalDescriptor as Z, workflowUpdateDescriptor as kt } from "@voltro/protocol";
|
|
17
18
|
import { declaredSnapshot as At, describeOutcome as jt, runPlannedMigrations as Mt } from "@voltro/database/sql";
|
|
18
19
|
import { getAuthSessionStrategy as Nt } from "@voltro/plugin-auth";
|
|
19
20
|
import { collectPublicApiRoutes as Pt, restRoutesToHttpRoutes as Ft } from "@voltro/protocol/rest";
|
|
@@ -267,7 +268,7 @@ var Jt = () => {
|
|
|
267
268
|
durationMs: e.durationMs,
|
|
268
269
|
rowCount: e.rowCount
|
|
269
270
|
})
|
|
270
|
-
}),
|
|
271
|
+
}), n = e.cache ?? dn, i = e.kv ?? et, a, s, c, l = /* @__PURE__ */ new Map(), u = () => `wfctx_${globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`, f = async (t, n, r) => {
|
|
271
272
|
let i = {
|
|
272
273
|
...r,
|
|
273
274
|
source: r.source ?? `workflow:${t}`
|
|
@@ -292,13 +293,13 @@ var Jt = () => {
|
|
|
292
293
|
createdAt: /* @__PURE__ */ new Date()
|
|
293
294
|
};
|
|
294
295
|
r[0] === void 0 ? await e.store.insert("_voltro_workflow_start_contexts", {
|
|
295
|
-
id:
|
|
296
|
+
id: u(),
|
|
296
297
|
...a
|
|
297
298
|
}) : await e.store.update("_voltro_workflow_start_contexts", r[0].id, a);
|
|
298
299
|
} catch (e) {
|
|
299
300
|
process.stderr.write(`[workflow] failed to persist start context for ${t}/${n}: ${e?.message ?? String(e)}\n`);
|
|
300
301
|
}
|
|
301
|
-
},
|
|
302
|
+
}, te = async (t, n) => {
|
|
302
303
|
let r = l.get(n);
|
|
303
304
|
if (r !== void 0) return r;
|
|
304
305
|
try {
|
|
@@ -323,35 +324,35 @@ var Jt = () => {
|
|
|
323
324
|
process.stderr.write(`[workflow] failed to load start context for ${n}: ${e?.message ?? String(e)}\n`);
|
|
324
325
|
return;
|
|
325
326
|
}
|
|
326
|
-
},
|
|
327
|
+
}, h = (e.discovered.workflows?.length ?? 0) > 0 ? Ke(() => a) : void 0, g = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, ne = g || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", re = e.tenantIsolation === "namespace", ae = (e.log ?? j({ scope: "voltro:serve" })).child("webhooks"), oe, v = e.discovered.webhooks;
|
|
327
328
|
if (v && v.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
|
|
328
|
-
let t = e.workflowEngineLayer,
|
|
329
|
+
let t = e.workflowEngineLayer, r = {
|
|
329
330
|
store: lt(e.store, {
|
|
330
|
-
subject:
|
|
331
|
+
subject: St(null),
|
|
331
332
|
schemaRegistry: e.schemaRegistry
|
|
332
333
|
}),
|
|
333
334
|
request: {
|
|
334
|
-
subject:
|
|
335
|
+
subject: St(null),
|
|
335
336
|
traceId: "webhooks:trigger"
|
|
336
337
|
},
|
|
337
|
-
cache:
|
|
338
|
+
cache: n,
|
|
338
339
|
kv: i
|
|
339
340
|
}, a = v.outgoing.map((e) => e.descriptor);
|
|
340
|
-
oe = Lt(
|
|
341
|
-
let
|
|
342
|
-
k.runPromise(
|
|
343
|
-
|
|
341
|
+
oe = Lt(r, async (e) => {
|
|
342
|
+
let n = zt.execute(e).pipe(k.provide(zt.toLayer(It(r, { events: a })).pipe(A.provideMerge(t))));
|
|
343
|
+
k.runPromise(n).catch((t) => {
|
|
344
|
+
ae.error("deliverWebhook workflow crashed", {
|
|
344
345
|
deliveryId: e.deliveryId,
|
|
345
346
|
targetId: e.targetId
|
|
346
347
|
}, t);
|
|
347
348
|
});
|
|
348
349
|
}, { events: a });
|
|
349
350
|
}
|
|
350
|
-
let
|
|
351
|
+
let se = /* @__PURE__ */ new Map();
|
|
351
352
|
if (v) for (let e of v.incoming) {
|
|
352
353
|
let t = e.descriptor.path ?? Rt(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = Bt(e.descriptor, {
|
|
353
354
|
resolveSecret: async () => process.env[n] ?? null,
|
|
354
|
-
resolveWorkflows: () =>
|
|
355
|
+
resolveWorkflows: () => h === void 0 ? void 0 : Qe(h, {
|
|
355
356
|
traceId: `incoming:${e.descriptor.id}`,
|
|
356
357
|
source: `incoming:${e.descriptor.id}`
|
|
357
358
|
}),
|
|
@@ -363,31 +364,31 @@ var Jt = () => {
|
|
|
363
364
|
idempotency: e.idempotency,
|
|
364
365
|
durationMs: e.durationMs
|
|
365
366
|
};
|
|
366
|
-
e.status >= 500 ?
|
|
367
|
+
e.status >= 500 ? ae.error("incoming delivery failed", t) : e.status >= 400 ? ae.warn("incoming delivery rejected", t) : ae.info("incoming delivery handled", t);
|
|
367
368
|
}
|
|
368
369
|
});
|
|
369
|
-
|
|
370
|
+
se.set(t, { handle: r });
|
|
370
371
|
}
|
|
371
372
|
Be(), at((t) => Ve(e.store, t.subjectId, t.resourceType, t.resourceId));
|
|
372
|
-
let
|
|
373
|
+
let y = (e.discovered.outboxHandlers?.length ?? 0) > 0 ? m({
|
|
373
374
|
handlers: e.discovered.outboxHandlers ?? [],
|
|
374
375
|
store: e.store,
|
|
375
376
|
log: (e.log ?? j({ scope: "voltro:serve" })).child("outbox")
|
|
376
|
-
}) : void 0, b =
|
|
377
|
+
}) : void 0, b = ee({
|
|
377
378
|
definitions: (e.discovered.connections ?? []).map((e) => e.definition),
|
|
378
379
|
store: e.store,
|
|
379
|
-
publicUrl:
|
|
380
|
+
publicUrl: C(e.port ?? 4e3),
|
|
380
381
|
log: (e.log ?? j({ scope: "voltro:serve" })).child("connections")
|
|
381
382
|
}), x = ie({
|
|
382
383
|
store: e.store,
|
|
383
384
|
schemaRegistry: e.schemaRegistry,
|
|
384
|
-
cache:
|
|
385
|
+
cache: n,
|
|
385
386
|
kv: i,
|
|
386
387
|
...oe === void 0 ? {} : { webhooksService: oe },
|
|
387
|
-
...
|
|
388
|
+
...h === void 0 ? {} : { workflowsProxy: h },
|
|
388
389
|
eventTriggers: e.discovered.eventTriggers ?? [],
|
|
389
|
-
namespaceIsolationOn:
|
|
390
|
-
...
|
|
390
|
+
namespaceIsolationOn: re,
|
|
391
|
+
...y === void 0 ? {} : { outbox: { nudge: y.nudge } },
|
|
391
392
|
...b.active ? { connections: { registry: b.registry } } : {}
|
|
392
393
|
}), ce = A.succeed(Oe, ve), le = (t, n) => {
|
|
393
394
|
let r = t.pipe(k.provide(R(n)));
|
|
@@ -397,50 +398,50 @@ var Jt = () => {
|
|
|
397
398
|
buildContext: (e, t, n) => x(e, t, n),
|
|
398
399
|
runEffect: le,
|
|
399
400
|
undoCapture: be()
|
|
400
|
-
}),
|
|
401
|
+
}), de = _e(), pe = He({
|
|
401
402
|
buildContext: (e) => x(e),
|
|
402
403
|
runEffect: le
|
|
403
|
-
}),
|
|
404
|
+
}), T = Je({
|
|
404
405
|
buildContext: (e) => x(e),
|
|
405
406
|
finalize: (t, n) => P(Ae(t, e.tenantScopedTables, n.subject.tenantId), e.softDeleteScopedTables),
|
|
406
407
|
provideEffect: (e, t) => e.pipe(k.provide(R(t)))
|
|
407
|
-
}),
|
|
408
|
+
}), E = {};
|
|
408
409
|
for (let n of [
|
|
409
410
|
...e.discovered.queries,
|
|
410
|
-
...
|
|
411
|
+
...de.queries,
|
|
411
412
|
...b.queries
|
|
412
|
-
])
|
|
413
|
+
]) E[n.descriptor.name] = (e) => I(T(n, e), t, `subscription.${n.descriptor.name}`, void 0, void 0, Ye(n, e));
|
|
413
414
|
for (let t of [
|
|
414
415
|
...e.discovered.mutations,
|
|
415
|
-
...
|
|
416
|
+
...de.mutations,
|
|
416
417
|
...b.mutations
|
|
417
|
-
])
|
|
418
|
-
for (let t of [...e.discovered.actions, ...b.actions])
|
|
419
|
-
let
|
|
418
|
+
]) E[t.descriptor.name] = (e) => F(async (e, n) => S(t, e, n), e, `mutation.${t.descriptor.name}`);
|
|
419
|
+
for (let t of [...e.discovered.actions, ...b.actions]) E[t.descriptor.name] = (e) => F(async (e, n) => pe(t, e, n), e, `action.${t.descriptor.name}`);
|
|
420
|
+
let me = () => `public-${Math.random().toString(36).slice(2, 10)}`, he = [...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
420
421
|
descriptor: e.descriptor,
|
|
421
422
|
invoke: (t, n) => S(e, t, {
|
|
422
423
|
subject: n.subject,
|
|
423
|
-
traceId:
|
|
424
|
+
traceId: me()
|
|
424
425
|
})
|
|
425
426
|
})), ...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
426
427
|
descriptor: e.descriptor,
|
|
427
|
-
invoke: (t, n) =>
|
|
428
|
+
invoke: (t, n) => pe(e, t, {
|
|
428
429
|
subject: n.subject,
|
|
429
|
-
traceId:
|
|
430
|
+
traceId: me()
|
|
430
431
|
})
|
|
431
|
-
}))],
|
|
432
|
+
}))], ge = he.length > 0 ? Ft(Pt(he), {
|
|
432
433
|
store: e.store,
|
|
433
434
|
resolveSubject: (t) => e.resolveSubject(t, -1)
|
|
434
|
-
}) : [],
|
|
435
|
+
}) : [], D = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, ye = D && D.length >= 16 ? [{
|
|
435
436
|
method: "POST",
|
|
436
437
|
path: Xt,
|
|
437
438
|
handle: an({
|
|
438
|
-
secret:
|
|
439
|
+
secret: D,
|
|
439
440
|
store: e.store,
|
|
440
441
|
...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
|
|
441
|
-
assetSink: Wt(
|
|
442
|
+
assetSink: Wt(W({})),
|
|
442
443
|
openArchive: (e) => (async function* () {
|
|
443
|
-
let t =
|
|
444
|
+
let t = W({}), n = await yt((await k.runPromise(_t(t, e))).stream);
|
|
444
445
|
for await (let e of n) yield e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
445
446
|
})()
|
|
446
447
|
})
|
|
@@ -448,25 +449,25 @@ var Jt = () => {
|
|
|
448
449
|
method: "POST",
|
|
449
450
|
path: Zt,
|
|
450
451
|
handle: ln({
|
|
451
|
-
secret:
|
|
452
|
+
secret: D,
|
|
452
453
|
store: e.store,
|
|
453
454
|
snapshot: e.dataTransferSnapshot ?? { tables: [] },
|
|
454
455
|
dialect: e.dataTransferDialect ?? "memory",
|
|
455
456
|
tenantTables: [...e.tenantScopedTables],
|
|
456
457
|
loadProfile: un,
|
|
457
|
-
assetSource: Gt(
|
|
458
|
+
assetSource: Gt(W({}), e.store),
|
|
458
459
|
putArchive: async (e, t) => {
|
|
459
|
-
let { Readable: n } = await import("node:stream"), r =
|
|
460
|
-
await k.runPromise(
|
|
460
|
+
let { Readable: n } = await import("node:stream"), r = W({}), i = gt("storage", () => n.from(t()));
|
|
461
|
+
await k.runPromise(vt(r, e, i, { contentType: "application/octet-stream" }));
|
|
461
462
|
}
|
|
462
463
|
})
|
|
463
464
|
}] : [], xe = [
|
|
464
465
|
...e.httpRoutes ?? [],
|
|
465
|
-
...
|
|
466
|
+
...ge,
|
|
466
467
|
...ye,
|
|
467
468
|
...b.httpRoutes
|
|
468
469
|
];
|
|
469
|
-
for (let t of e.discovered.streams ?? [])
|
|
470
|
+
for (let t of e.discovered.streams ?? []) E[t.descriptor.name] = (n) => Ne((r) => {
|
|
470
471
|
let i = x(r), a = t.executor(n, i);
|
|
471
472
|
if (k.isEffect(a)) {
|
|
472
473
|
let t = a.pipe(k.provide(R(i.store)));
|
|
@@ -474,16 +475,16 @@ var Jt = () => {
|
|
|
474
475
|
}
|
|
475
476
|
return typeof a == "object" && a && typeof a.then == "function" ? k.promise(() => a) : a;
|
|
476
477
|
}, `stream.${t.descriptor.name}`);
|
|
477
|
-
for (let t of e.discovered.workflows ?? [])
|
|
478
|
+
for (let t of e.discovered.workflows ?? []) E[t.definition.name] = (e) => F(async (e, n) => {
|
|
478
479
|
let r = n;
|
|
479
|
-
return Qe(
|
|
480
|
+
return Qe(h, {
|
|
480
481
|
subject: r.subject,
|
|
481
482
|
traceId: r.traceId,
|
|
482
483
|
source: "workflow-rpc"
|
|
483
484
|
}).start(t.definition.name, e);
|
|
484
485
|
}, e, `workflow.${t.definition.name}`);
|
|
485
|
-
|
|
486
|
-
descriptor:
|
|
486
|
+
g && (E[Y.name] = (e) => I(T({
|
|
487
|
+
descriptor: Y,
|
|
487
488
|
executor: (e) => {
|
|
488
489
|
let t = e.id;
|
|
489
490
|
return {
|
|
@@ -498,8 +499,8 @@ var Jt = () => {
|
|
|
498
499
|
projection: void 0
|
|
499
500
|
};
|
|
500
501
|
}
|
|
501
|
-
}, e), t, `subscription.${
|
|
502
|
-
descriptor:
|
|
502
|
+
}, e), t, `subscription.${Y.name}`), E[X.name] = (e) => I(T({
|
|
503
|
+
descriptor: X,
|
|
503
504
|
executor: (e) => {
|
|
504
505
|
let t = e, n = [...t.tag === void 0 ? [] : [U("tag", t.tag)], ...t.status === void 0 ? [] : [U("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
|
|
505
506
|
return {
|
|
@@ -514,8 +515,8 @@ var Jt = () => {
|
|
|
514
515
|
projection: void 0
|
|
515
516
|
};
|
|
516
517
|
}
|
|
517
|
-
}, e), t, `subscription.${
|
|
518
|
-
descriptor:
|
|
518
|
+
}, e), t, `subscription.${X.name}`), E[Ot.name] = (e) => I(T({
|
|
519
|
+
descriptor: Ot,
|
|
519
520
|
executor: (e) => {
|
|
520
521
|
let t = e.runId;
|
|
521
522
|
return {
|
|
@@ -530,8 +531,8 @@ var Jt = () => {
|
|
|
530
531
|
projection: void 0
|
|
531
532
|
};
|
|
532
533
|
}
|
|
533
|
-
}, e), t, `subscription.${
|
|
534
|
-
descriptor:
|
|
534
|
+
}, e), t, `subscription.${Ot.name}`), E[J.name] = (e) => I(T({
|
|
535
|
+
descriptor: J,
|
|
535
536
|
executor: (e) => {
|
|
536
537
|
let t = e.runId;
|
|
537
538
|
return {
|
|
@@ -546,8 +547,8 @@ var Jt = () => {
|
|
|
546
547
|
projection: void 0
|
|
547
548
|
};
|
|
548
549
|
}
|
|
549
|
-
}, e), t, `subscription.${
|
|
550
|
-
descriptor:
|
|
550
|
+
}, e), t, `subscription.${J.name}`), E[q.name] = (e) => I(T({
|
|
551
|
+
descriptor: q,
|
|
551
552
|
executor: (e) => {
|
|
552
553
|
let t = e;
|
|
553
554
|
return {
|
|
@@ -562,8 +563,8 @@ var Jt = () => {
|
|
|
562
563
|
projection: void 0
|
|
563
564
|
};
|
|
564
565
|
}
|
|
565
|
-
}, e), t, `subscription.${
|
|
566
|
-
descriptor:
|
|
566
|
+
}, e), t, `subscription.${q.name}`), E[Et.name] = (e) => I(T({
|
|
567
|
+
descriptor: Et,
|
|
567
568
|
executor: (e) => {
|
|
568
569
|
let t = e.eventId;
|
|
569
570
|
return {
|
|
@@ -578,43 +579,43 @@ var Jt = () => {
|
|
|
578
579
|
projection: void 0
|
|
579
580
|
};
|
|
580
581
|
}
|
|
581
|
-
}, e), t, `subscription.${
|
|
582
|
+
}, e), t, `subscription.${Et.name}`), E[Tt.name] = (t) => F(async (t, n) => {
|
|
582
583
|
let r = t;
|
|
583
|
-
return await
|
|
584
|
-
}, t, `action.${
|
|
584
|
+
return await _(e.store, n.subject, { executionId: r.executionId }), await h.cancel(r.workflowName, r.executionId), await Ie(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
|
|
585
|
+
}, t, `action.${Tt.name}`), E[Dt.name] = (t) => F(async (t, n) => {
|
|
585
586
|
let r = t;
|
|
586
|
-
return await
|
|
587
|
-
}, t, `action.${
|
|
587
|
+
return await _(e.store, n.subject, { executionId: r.executionId }), await h.resume(r.workflowName, r.executionId), { ok: !0 };
|
|
588
|
+
}, t, `action.${Dt.name}`), E[Z.name] = (t) => F(async (t, n) => {
|
|
588
589
|
let r = t;
|
|
589
|
-
return await
|
|
590
|
-
}, t, `action.${
|
|
590
|
+
return await _(e.store, n.subject, { id: r.id }), h.signal({ id: r.id }, r.signalName, r.payload);
|
|
591
|
+
}, t, `action.${Z.name}`), E[kt.name] = (t) => F(async (t, n) => {
|
|
591
592
|
let r = t;
|
|
592
|
-
return await
|
|
593
|
+
return await _(e.store, n.subject, { id: r.id }), h.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
|
|
593
594
|
}, t, `action.${kt.name}`));
|
|
594
595
|
let Se = [
|
|
595
|
-
...e.discovered.queries.map((e) =>
|
|
596
|
-
...e.discovered.mutations.map((e) =>
|
|
597
|
-
...e.discovered.actions.map((e) =>
|
|
598
|
-
...
|
|
599
|
-
...
|
|
600
|
-
...b.queries.map((e) =>
|
|
601
|
-
...b.mutations.map((e) =>
|
|
602
|
-
...b.actions.map((e) =>
|
|
603
|
-
...(e.discovered.streams ?? []).map((e) =>
|
|
596
|
+
...e.discovered.queries.map((e) => K(e.descriptor)),
|
|
597
|
+
...e.discovered.mutations.map((e) => Ct(e.descriptor)),
|
|
598
|
+
...e.discovered.actions.map((e) => G(e.descriptor)),
|
|
599
|
+
...de.queries.map((e) => K(e.descriptor)),
|
|
600
|
+
...de.mutations.map((e) => Ct(e.descriptor)),
|
|
601
|
+
...b.queries.map((e) => K(e.descriptor)),
|
|
602
|
+
...b.mutations.map((e) => Ct(e.descriptor)),
|
|
603
|
+
...b.actions.map((e) => G(e.descriptor)),
|
|
604
|
+
...(e.discovered.streams ?? []).map((e) => wt(e.descriptor)),
|
|
604
605
|
...(e.discovered.workflows ?? []).map((e) => ct(e.definition)),
|
|
605
|
-
...
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
q(Dt),
|
|
609
|
-
q(Y),
|
|
610
|
-
q(J),
|
|
611
|
-
q(Tt),
|
|
612
|
-
K(wt),
|
|
613
|
-
K(Et),
|
|
606
|
+
...g ? [
|
|
607
|
+
K(Y),
|
|
608
|
+
K(X),
|
|
614
609
|
K(Ot),
|
|
615
|
-
K(
|
|
610
|
+
K(J),
|
|
611
|
+
K(q),
|
|
612
|
+
K(Et),
|
|
613
|
+
G(Tt),
|
|
614
|
+
G(Dt),
|
|
615
|
+
G(Z),
|
|
616
|
+
G(kt)
|
|
616
617
|
] : []
|
|
617
|
-
], O = dt.make(...Se).middleware(
|
|
618
|
+
], O = dt.make(...Se).middleware(bt).middleware(xt), Ce = A.succeed(bt, bt.of(({ headers: t, clientId: n }) => k.promise(() => e.resolveSubject(t, n)))), we = A.succeed(xt, xt.of(({ clientId: e }) => k.succeed({ clientId: e }))), Te = e.dormancyTenantId ?? "default", Ee = e.dormancy === "sleep" ? {
|
|
618
619
|
register: (t, n, r) => nt(e.store, {
|
|
619
620
|
tenantId: r ?? Te,
|
|
620
621
|
kind: "workflow",
|
|
@@ -626,7 +627,7 @@ var Jt = () => {
|
|
|
626
627
|
kind: "workflow",
|
|
627
628
|
refId: t
|
|
628
629
|
}).then(() => {})
|
|
629
|
-
} : void 0, M =
|
|
630
|
+
} : void 0, M = ne ? await import("@voltro/workflow") : void 0, N = M?.makeWorkflowRunRecorder({
|
|
630
631
|
store: e.store,
|
|
631
632
|
...Ee === void 0 ? {} : { wakeups: Ee }
|
|
632
633
|
}), je = async (t, n) => {
|
|
@@ -682,7 +683,7 @@ var Jt = () => {
|
|
|
682
683
|
traceId: t?.traceId ?? "workflow-bootstrap"
|
|
683
684
|
}, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId });
|
|
684
685
|
},
|
|
685
|
-
resolveStartContext:
|
|
686
|
+
resolveStartContext: te
|
|
686
687
|
}, (t, n, r) => {
|
|
687
688
|
let i = M.getWorkflowVersionMetadata(t.definition);
|
|
688
689
|
return M.wrapWorkflowExecuteWithRunRecording({
|
|
@@ -700,10 +701,10 @@ var Jt = () => {
|
|
|
700
701
|
recorder: N
|
|
701
702
|
}, n);
|
|
702
703
|
}), ...e.discovered.workflowWorkers ?? []], Re = Le.length > 0 ? A.mergeAll(...Le) : A.empty;
|
|
703
|
-
((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster") && e.workflowEngineLayer !== void 0 && (s = De.make(Re.pipe(A.provideMerge(e.workflowEngineLayer))), await s.runPromise(k.void),
|
|
704
|
+
((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster") && e.workflowEngineLayer !== void 0 && (s = De.make(Re.pipe(A.provideMerge(e.workflowEngineLayer))), await s.runPromise(k.void), a = (e.discovered.workflows?.length ?? 0) > 0 ? Ze({
|
|
704
705
|
workflows: e.discovered.workflows ?? [],
|
|
705
706
|
runEffect: (e) => s.runPromise(e),
|
|
706
|
-
rememberStartContext:
|
|
707
|
+
rememberStartContext: f,
|
|
707
708
|
signal: async (t, n, r) => {
|
|
708
709
|
let i = await M.sendWorkflowSignal({
|
|
709
710
|
store: e.store,
|
|
@@ -727,14 +728,14 @@ var Jt = () => {
|
|
|
727
728
|
payload: r,
|
|
728
729
|
...i === void 0 ? {} : { options: i }
|
|
729
730
|
}),
|
|
730
|
-
listRuns: (t) =>
|
|
731
|
+
listRuns: (t) => fe(e.store, t),
|
|
731
732
|
retry: (t, n) => ue({
|
|
732
733
|
store: e.store,
|
|
733
734
|
workflows: e.discovered.workflows ?? [],
|
|
734
735
|
runPromise: (e) => s.runPromise(e)
|
|
735
736
|
}, t, n)
|
|
736
737
|
}) : void 0);
|
|
737
|
-
let ze = A.mergeAll(O.toLayer(
|
|
738
|
+
let ze = A.mergeAll(O.toLayer(E), Ce, we), We = d(E, e.discovered.queries.map((e) => e.descriptor.name), g), Ge = A.mergeAll(O.toLayer(We), Ce, we), L = e.observability, Xe = await Pe({
|
|
738
739
|
...L && L.spanProcessors.length > 0 ? { extraSpanProcessors: L.spanProcessors } : {},
|
|
739
740
|
...L && L.metricReaders.length > 0 ? { extraMetricReaders: L.metricReaders } : {},
|
|
740
741
|
...L && Object.keys(L.resourceAttributes).length > 0 ? { resourceAttributes: L.resourceAttributes } : {},
|
|
@@ -751,7 +752,7 @@ var Jt = () => {
|
|
|
751
752
|
...it ? { ping: it } : {}
|
|
752
753
|
},
|
|
753
754
|
...xe.length > 0 ? { httpRoutes: xe } : {},
|
|
754
|
-
...
|
|
755
|
+
...se.size > 0 ? { webhookRoutes: se } : {}
|
|
755
756
|
});
|
|
756
757
|
if (await Me(V), (e.discovered.schedules?.length ?? 0) > 0) {
|
|
757
758
|
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Ue(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ot;
|
|
@@ -785,26 +786,26 @@ var Jt = () => {
|
|
|
785
786
|
}), e.onSchedulerReady?.(c);
|
|
786
787
|
}
|
|
787
788
|
let H = e.log ?? j({ scope: "voltro:serve" }), ut, ft;
|
|
788
|
-
if ((e.discovered.subscribers?.length ?? 0) > 0 && (ut =
|
|
789
|
+
if ((e.discovered.subscribers?.length ?? 0) > 0 && (ut = o(e.discovered.subscribers ?? [], e.store, H.child("subscribe"))), (e.discovered.reactions?.length ?? 0) > 0) {
|
|
789
790
|
let t = H.child("reaction");
|
|
790
|
-
ft =
|
|
791
|
+
ft = p(e.discovered.reactions ?? [], e.store, {
|
|
791
792
|
runAct: async (n, r) => {
|
|
792
793
|
if (n.kind === "workflow") {
|
|
793
|
-
if (
|
|
794
|
+
if (h === void 0) {
|
|
794
795
|
t.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: n.workflow });
|
|
795
796
|
return;
|
|
796
797
|
}
|
|
797
798
|
let e = r.new ?? r.old ?? {};
|
|
798
|
-
await Qe(
|
|
799
|
+
await Qe(h, {
|
|
799
800
|
traceId: `reaction:${n.workflow}`,
|
|
800
801
|
source: `reaction:${n.workflow}`
|
|
801
802
|
}).start(n.workflow, e);
|
|
802
803
|
return;
|
|
803
804
|
}
|
|
804
|
-
await
|
|
805
|
+
await w(n.agent, r, {
|
|
805
806
|
findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
|
|
806
|
-
runAction: (e, t, n) => Promise.resolve(
|
|
807
|
-
makeSubject: (e) =>
|
|
807
|
+
runAction: (e, t, n) => Promise.resolve(pe(e, t, n)),
|
|
808
|
+
makeSubject: (e) => St(e),
|
|
808
809
|
now: () => Date.now(),
|
|
809
810
|
log: t
|
|
810
811
|
});
|
|
@@ -823,7 +824,7 @@ var Jt = () => {
|
|
|
823
824
|
}, t);
|
|
824
825
|
}
|
|
825
826
|
let mt;
|
|
826
|
-
return (e.discovered.aggregates?.length ?? 0) > 0 && (mt = await
|
|
827
|
+
return (e.discovered.aggregates?.length ?? 0) > 0 && (mt = await r({
|
|
827
828
|
discovered: e.discovered.aggregates ?? [],
|
|
828
829
|
store: e.store,
|
|
829
830
|
log: H.child("aggregate"),
|
|
@@ -854,78 +855,78 @@ var Jt = () => {
|
|
|
854
855
|
if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
|
|
855
856
|
}
|
|
856
857
|
return gn(e);
|
|
857
|
-
}, gn = async (
|
|
858
|
-
let
|
|
858
|
+
}, gn = async (r) => {
|
|
859
|
+
let o = Yt();
|
|
859
860
|
process.env.NODE_ENV || (process.env.NODE_ENV = "production"), ut();
|
|
860
|
-
let
|
|
861
|
-
it(rt(
|
|
862
|
-
rawEnv:
|
|
861
|
+
let d = process.cwd(), ee = Number(process.env.PORT ?? mn(r, "--port") ?? 4e3), p = await E(d);
|
|
862
|
+
it(rt(p?.secrets)), await t({
|
|
863
|
+
rawEnv: p?.env,
|
|
863
864
|
appType: "api",
|
|
864
|
-
root:
|
|
865
|
+
root: d,
|
|
865
866
|
log: $,
|
|
866
867
|
generateTypes: !1
|
|
867
|
-
}),
|
|
868
|
-
let
|
|
868
|
+
}), o.mark("config");
|
|
869
|
+
let m = (process.env.DB_DIALECT ?? p?.store ?? "memory").toLowerCase(), ie = (m === "mariadb" || m === "postgres" || m === "mssql") && (process.env.CDC ?? "1") !== "0", _ = m === "mariadb" ? "mariadb" : m === "mssql" ? "mssql" : void 0, ue = Ce(d);
|
|
869
870
|
if (!Se() && M(ue)) try {
|
|
870
871
|
let e = await import(Te(ue).href);
|
|
871
872
|
if (e.modules) {
|
|
872
873
|
let t = {};
|
|
873
|
-
for (let [n, r] of Object.entries(e.modules)) t[we(
|
|
874
|
+
for (let [n, r] of Object.entries(e.modules)) t[we(d, n)] = r;
|
|
874
875
|
xe(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
|
|
875
876
|
}
|
|
876
877
|
} catch (e) {
|
|
877
878
|
$.warn("precompiled api bundle failed to load — falling back to source", {}, e);
|
|
878
879
|
}
|
|
879
|
-
let
|
|
880
|
-
mix:
|
|
881
|
-
plugins:
|
|
882
|
-
cdc: ie &&
|
|
883
|
-
...
|
|
884
|
-
}), be =
|
|
885
|
-
spec:
|
|
880
|
+
let C = await b(d), w = await ge(C, { cdc: ie && _ !== void 0 }), fe = C.filter((e) => ye.test(e)), _e = fe.length > 0 ? await h(fe, $.child("webhooks")) : void 0, ve = x({
|
|
881
|
+
mix: w.featureMix,
|
|
882
|
+
plugins: p?.plugins ?? [],
|
|
883
|
+
cdc: ie && _ !== void 0,
|
|
884
|
+
..._ ? { cdcDialect: _ } : {}
|
|
885
|
+
}), be = p?.analytics !== void 0 && p.analytics.kind !== "noop" && m !== "memory" ? (await y(m)).makeSqlLayer(S()) : void 0, O = await ne({
|
|
886
|
+
spec: p?.analytics,
|
|
886
887
|
sqlLayer: be,
|
|
887
888
|
log: $
|
|
888
889
|
}), j = (() => {
|
|
889
|
-
let e = new Set(
|
|
890
|
+
let e = new Set(w.tables.map((e) => e.tableName)), t = [...w.tables];
|
|
890
891
|
for (let n of [...ve, ...O.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
|
|
891
892
|
return t;
|
|
892
893
|
})();
|
|
893
894
|
for (let e of j) mt(e);
|
|
894
895
|
let Oe = (process.env.NODE_ENV ?? "").toLowerCase();
|
|
895
|
-
if (pn(Oe,
|
|
896
|
-
let e = (await y(
|
|
896
|
+
if (pn(Oe, m, process.env.VOLTRO_AUTO_MIGRATE)) {
|
|
897
|
+
let e = (await y(m)).makeSqlLayer(S()), t = await k.runPromise(ft.SqlClient.pipe(k.flatMap((e) => Mt(e, j, {
|
|
897
898
|
appliedBy: `serve:${Oe}`,
|
|
898
899
|
environment: "prod",
|
|
899
|
-
dialectId:
|
|
900
|
+
dialectId: m
|
|
900
901
|
})), k.provide(e)));
|
|
901
|
-
t.kind === "prod-mismatch" && ($.error(jt(t,
|
|
902
|
+
t.kind === "prod-mismatch" && ($.error(jt(t, m)), $.error("serve: refusing to boot — apply the schema first (voltro db apply in a pre-deploy step), or set VOLTRO_AUTO_MIGRATE=0 to bypass this check."), process.exit(1)), $.info(jt(t, m));
|
|
902
903
|
}
|
|
903
904
|
let ke = Xe(j);
|
|
904
|
-
|
|
905
|
-
let P = await
|
|
906
|
-
|
|
905
|
+
o.mark("discover");
|
|
906
|
+
let P = await pe(p, void 0);
|
|
907
|
+
p?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = p.cache), p?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = p.cacheRedisUrl), p?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = p.cacheRedisDriver), p?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = p.cacheKeyPrefix);
|
|
907
908
|
let { service: Ae, invalidationBus: Me, snapshotCache: F, cache: Ne, backend: I, dispose: Pe } = await te({ env: process.env });
|
|
908
909
|
$.info(`cache backend resolved: ${I}` + (I === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), P.onChange((e) => {
|
|
909
910
|
k.runFork(Me.publish(e.table));
|
|
910
|
-
}),
|
|
911
|
+
}), p?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = p.kv), p?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = p.kvRedisUrl), p?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = p.kvKeyPrefix);
|
|
911
912
|
let { kv: Fe, service: Be } = await Ge({ store: P });
|
|
912
|
-
|
|
913
|
+
o.mark("store");
|
|
913
914
|
let Ve = je({
|
|
914
915
|
store: P,
|
|
915
916
|
sink: O.sink,
|
|
916
917
|
log: $
|
|
917
918
|
}), He = ae({
|
|
918
919
|
store: P,
|
|
919
|
-
dialect:
|
|
920
|
-
}), R =
|
|
921
|
-
|
|
920
|
+
dialect: m
|
|
921
|
+
}), R = p?.plugins ?? [], Ke = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, qe, Je;
|
|
922
|
+
m !== "memory" && (qe = De.make((await y(m)).makeSqlLayer(S())), Je = await qe.runPromise(ft.SqlClient));
|
|
922
923
|
let Ye = L({
|
|
923
924
|
coordinator: [
|
|
924
925
|
"postgres",
|
|
925
926
|
"mariadb",
|
|
926
927
|
"mysql",
|
|
927
928
|
"mssql"
|
|
928
|
-
].includes(
|
|
929
|
+
].includes(m) ? Ue(P, Ke, $) : ot,
|
|
929
930
|
replicaId: Ke,
|
|
930
931
|
log: $
|
|
931
932
|
}), Ze = [], Qe = {
|
|
@@ -951,19 +952,19 @@ var Jt = () => {
|
|
|
951
952
|
for (let e of $e) k.runFork(e.onChangeEvent(n).pipe(k.catchAllCause((t) => k.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: Ee.pretty(t) })))));
|
|
952
953
|
});
|
|
953
954
|
}
|
|
954
|
-
let et =
|
|
955
|
+
let et = oe({
|
|
955
956
|
plugins: R,
|
|
956
|
-
appName:
|
|
957
|
+
appName: p?.name ?? "voltro-api",
|
|
957
958
|
appType: "api",
|
|
958
959
|
voltroVersion: process.env.npm_package_version ?? "0.0.0",
|
|
959
960
|
log: $
|
|
960
961
|
});
|
|
961
|
-
R.length && await et.activate(),
|
|
962
|
-
let tt = await et.gatherObservability(), nt = await ce(P,
|
|
962
|
+
R.length && await et.activate(), o.mark("plugins");
|
|
963
|
+
let tt = await et.gatherObservability(), nt = await ce(P, p, m, {
|
|
963
964
|
info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
964
965
|
warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
965
966
|
debug: () => {}
|
|
966
|
-
}), z =
|
|
967
|
+
}), z = p?.apiKeys, at = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", B = z ? We(Le(P), { prefix: at }) : void 0, st = B ? [ze(B, { prefix: at })] : [], ct = D([...p?.auth?.strategies ?? [], ...st], Nt(p?.plugins ?? []), p?.auth?.anonymousTenantRequired ?? !1), lt = [...p?.restRoutes ?? [], ...B ? N(B, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], V = p?.idempotency, H = V ? {
|
|
967
968
|
store: Re(P),
|
|
968
969
|
header: (typeof V == "object" ? V.header : void 0) ?? "Idempotency-Key",
|
|
969
970
|
ttlMs: (typeof V == "object" ? V.ttlMs : void 0) ?? 864e5
|
|
@@ -974,34 +975,34 @@ var Jt = () => {
|
|
|
974
975
|
clientId: -1
|
|
975
976
|
}),
|
|
976
977
|
...H ? { idempotency: H } : {}
|
|
977
|
-
}) : [], pt = R.map((e) => e.services).filter((e) => e !== void 0), U = A.mergeAll(
|
|
978
|
+
}) : [], pt = R.map((e) => e.services).filter((e) => e !== void 0), U = A.mergeAll(u({
|
|
978
979
|
analyticsLayer: O.layer,
|
|
979
980
|
cacheService: Ae,
|
|
980
981
|
kvService: Be,
|
|
981
982
|
pluginServices: pt,
|
|
982
|
-
userLayers:
|
|
983
|
-
}),
|
|
983
|
+
userLayers: p?.layers ?? []
|
|
984
|
+
}), me), ht = p?.scheduling ?? {}, gt = ht.trigger ?? "self", _t = /* @__PURE__ */ new Set([
|
|
984
985
|
"postgres",
|
|
985
986
|
"mysql",
|
|
986
987
|
"mariadb",
|
|
987
988
|
"mssql"
|
|
988
|
-
]),
|
|
989
|
-
|
|
990
|
-
let
|
|
991
|
-
if (
|
|
992
|
-
if (
|
|
993
|
-
let e = await
|
|
989
|
+
]), vt = ht.coordination ?? (_t.has(m) ? "advisoryLock" : "single"), W = vt === "cluster" && _t.has(m), yt = W ? "cluster" : vt === "advisoryLock" && _t.has(m) ? "advisoryLock" : "single";
|
|
990
|
+
vt === "cluster" && !W && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), vt === "advisoryLock" && !_t.has(m) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
|
|
991
|
+
let bt, xt = w.workflows.length > 0 || w.workflowWorkers.length > 0 || w.eventTriggers.length > 0 || (_e?.outgoing.length ?? 0) > 0 || W, G;
|
|
992
|
+
if (xt) {
|
|
993
|
+
if (m === "mssql") {
|
|
994
|
+
let e = await c(process.cwd());
|
|
994
995
|
e && $.warn(e);
|
|
995
996
|
}
|
|
996
|
-
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), i =
|
|
997
|
+
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), i = W ? w.schedules.filter((e) => (e.trigger ?? gt) === "self").map((e) => t({
|
|
997
998
|
name: e.name,
|
|
998
999
|
cron: Ie(e),
|
|
999
1000
|
execute: async () => {
|
|
1000
|
-
await
|
|
1001
|
+
await bt?.fireFromCluster(e.name);
|
|
1001
1002
|
}
|
|
1002
1003
|
})) : [];
|
|
1003
|
-
|
|
1004
|
-
let e = await y(
|
|
1004
|
+
G = m === "memory" ? e.layerMemory : await (async () => {
|
|
1005
|
+
let e = await y(m), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
|
|
1005
1006
|
return $.info(`workflow engine: cluster-${t}, dialect=${e.id}` + (t === "memory" ? " — single-process durable replay, no cross-pod shard handoff" + (e.id !== "sqlite" && e.id !== "turso" ? " (VOLTRO_WORKFLOW_RUNNER_STORAGE=memory: SqlRunnerStorage/cluster_runners + GET_LOCK skipped)" : "") : "")), n({
|
|
1006
1007
|
sqlClientLayer: e.makeSqlLayer(S()),
|
|
1007
1008
|
runnerStorage: t,
|
|
@@ -1011,95 +1012,95 @@ var Jt = () => {
|
|
|
1011
1012
|
});
|
|
1012
1013
|
})();
|
|
1013
1014
|
}
|
|
1014
|
-
let
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1015
|
+
let St = le(R, e()), Ct = C.filter((e) => /\.subscribe\.tsx?$/.test(e)), K = Ct.length > 0 ? await l(Ct, $) : [], wt = C.filter((e) => /\.reaction\.tsx?$/.test(e)), Tt = wt.length > 0 ? await n(wt, $) : [], q = C.filter((e) => /\.outbox\.tsx?$/.test(e)), Et = q.length > 0 ? await f(q, $) : [], Dt = C.filter((e) => /\.aggregate\.tsx?$/.test(e)), J = Dt.length > 0 ? await g(Dt, $) : [], Y = a();
|
|
1016
|
+
if (J.length > 0 && m !== "memory") try {
|
|
1017
|
+
Y = i((await y(m)).makeSqlLayer(S()));
|
|
1017
1018
|
} catch (e) {
|
|
1018
1019
|
$.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
|
|
1019
1020
|
}
|
|
1020
|
-
let
|
|
1021
|
+
let Ot = m === "memory" ? ot : Ue(P, `aggregate@${process.pid}`, $), X = [], Z = [], kt = C.filter((e) => T.test(e));
|
|
1021
1022
|
if (kt.length > 0) {
|
|
1022
|
-
let e = $.child("agent"), t =
|
|
1023
|
-
t.length > 0 && await
|
|
1024
|
-
let n = await
|
|
1025
|
-
for (let e of n.agents) for (let t of
|
|
1023
|
+
let e = $.child("agent"), t = C.filter((e) => he.test(e));
|
|
1024
|
+
t.length > 0 && await v(t, e);
|
|
1025
|
+
let n = await de(kt, e);
|
|
1026
|
+
for (let e of n.agents) for (let t of se(e)) (t.kind === "action" ? X : Z).push({
|
|
1026
1027
|
file: t.file,
|
|
1027
1028
|
descriptor: t.descriptor,
|
|
1028
1029
|
executor: t.executor
|
|
1029
1030
|
});
|
|
1030
1031
|
n.agents.length > 0 && e.info("synthesized agent routes", { agents: n.agents.map((e) => e.descriptor.name) });
|
|
1031
1032
|
}
|
|
1032
|
-
|
|
1033
|
+
o.mark("workflow");
|
|
1033
1034
|
let Pt = await fn({
|
|
1034
|
-
bootTiming:
|
|
1035
|
+
bootTiming: o,
|
|
1035
1036
|
discovered: {
|
|
1036
|
-
queries: [...
|
|
1037
|
-
mutations:
|
|
1038
|
-
actions: [...
|
|
1039
|
-
streams:
|
|
1040
|
-
workflows:
|
|
1041
|
-
workflowWorkers:
|
|
1042
|
-
eventTriggers:
|
|
1043
|
-
schedules:
|
|
1044
|
-
subscribers:
|
|
1045
|
-
outboxHandlers:
|
|
1046
|
-
connections:
|
|
1047
|
-
reactions:
|
|
1048
|
-
aggregates:
|
|
1037
|
+
queries: [...w.queries, ...Z],
|
|
1038
|
+
mutations: w.mutations,
|
|
1039
|
+
actions: [...w.actions, ...X],
|
|
1040
|
+
streams: w.streams,
|
|
1041
|
+
workflows: w.workflows,
|
|
1042
|
+
workflowWorkers: w.workflowWorkers,
|
|
1043
|
+
eventTriggers: w.eventTriggers,
|
|
1044
|
+
schedules: w.schedules,
|
|
1045
|
+
subscribers: K,
|
|
1046
|
+
outboxHandlers: Et,
|
|
1047
|
+
connections: w.connections,
|
|
1048
|
+
reactions: Tt,
|
|
1049
|
+
aggregates: J,
|
|
1049
1050
|
..._e === void 0 ? {} : { webhooks: _e }
|
|
1050
1051
|
},
|
|
1051
1052
|
log: $,
|
|
1052
1053
|
analytics: O.sink,
|
|
1053
|
-
aggregateStorage:
|
|
1054
|
-
aggregateCoordinator:
|
|
1054
|
+
aggregateStorage: Y,
|
|
1055
|
+
aggregateCoordinator: Ot,
|
|
1055
1056
|
store: P,
|
|
1056
1057
|
kv: Fe,
|
|
1057
1058
|
cache: Ne,
|
|
1058
1059
|
snapshotCache: F,
|
|
1059
1060
|
schemaRegistry: ke,
|
|
1060
|
-
tenantScopedTables:
|
|
1061
|
-
softDeleteScopedTables:
|
|
1061
|
+
tenantScopedTables: w.tenantScopedTables,
|
|
1062
|
+
softDeleteScopedTables: w.softDeleteScopedTables,
|
|
1062
1063
|
dataTransferSnapshot: At(j),
|
|
1063
|
-
dataTransferDialect:
|
|
1064
|
-
tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ??
|
|
1064
|
+
dataTransferDialect: m,
|
|
1065
|
+
tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? p?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
|
|
1065
1066
|
resolveSubject: (e, t) => ct({
|
|
1066
1067
|
headers: e,
|
|
1067
1068
|
clientId: t
|
|
1068
1069
|
}),
|
|
1069
1070
|
httpRoutes: [...R.flatMap((e) => e.httpRoutes ?? []), ...dt],
|
|
1070
1071
|
...U ? { baseLayer: U } : {},
|
|
1071
|
-
...
|
|
1072
|
+
...G === void 0 ? {} : { workflowEngineLayer: G },
|
|
1072
1073
|
scheduleDefaultTrigger: gt,
|
|
1073
|
-
scheduleCoordination:
|
|
1074
|
-
scheduleArmSelf: !
|
|
1075
|
-
dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY :
|
|
1074
|
+
scheduleCoordination: yt,
|
|
1075
|
+
scheduleArmSelf: !W,
|
|
1076
|
+
dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : p?.dormancy ?? "always-on",
|
|
1076
1077
|
scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
|
|
1077
|
-
...
|
|
1078
|
+
...St === void 0 ? {} : { scheduleFireInterceptor: St },
|
|
1078
1079
|
onSchedulerReady: (e) => {
|
|
1079
|
-
|
|
1080
|
+
bt = e;
|
|
1080
1081
|
},
|
|
1081
1082
|
observability: tt,
|
|
1082
|
-
port:
|
|
1083
|
-
...
|
|
1083
|
+
port: ee,
|
|
1084
|
+
...p?.transport?.wsPath ? { path: p.transport.wsPath } : {}
|
|
1084
1085
|
});
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1086
|
+
s(re([
|
|
1087
|
+
w.queries,
|
|
1088
|
+
w.mutations,
|
|
1089
|
+
w.actions,
|
|
1090
|
+
w.streams
|
|
1090
1091
|
]), (e) => {
|
|
1091
1092
|
$.warn(e);
|
|
1092
|
-
}), $.info(`API listening on :${
|
|
1093
|
-
dialect:
|
|
1094
|
-
queries:
|
|
1095
|
-
mutations:
|
|
1096
|
-
actions:
|
|
1097
|
-
streams:
|
|
1098
|
-
workflows:
|
|
1099
|
-
workflowWorkers:
|
|
1100
|
-
schedules:
|
|
1101
|
-
scheduleCoordination:
|
|
1102
|
-
}),
|
|
1093
|
+
}), $.info(`API listening on :${ee}`, {
|
|
1094
|
+
dialect: m,
|
|
1095
|
+
queries: w.queries.length,
|
|
1096
|
+
mutations: w.mutations.length,
|
|
1097
|
+
actions: w.actions.length,
|
|
1098
|
+
streams: w.streams.length,
|
|
1099
|
+
workflows: w.workflows.length,
|
|
1100
|
+
workflowWorkers: w.workflowWorkers.length,
|
|
1101
|
+
schedules: w.schedules.length,
|
|
1102
|
+
scheduleCoordination: yt
|
|
1103
|
+
}), o.finish($);
|
|
1103
1104
|
let It = () => {
|
|
1104
1105
|
for (let e of Ze) e.stop();
|
|
1105
1106
|
Ve.detach(), He.stop(), Pe(), qe?.dispose(), Promise.resolve(et.deactivate()).then(() => nt?.close()).then(() => O.dispose()).then(() => Pt.close()).then(() => P.close?.()).then(() => process.exit(0));
|