@voltro/cli 0.12.0 → 0.13.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 +93 -0
- package/dist/{apiBuild-GefjNI5d.js → apiBuild-B6_ehbem.js} +3 -3
- package/dist/apiBuild-Bzpb383i.js +2 -0
- package/dist/bin.js +3 -3
- package/dist/{commands-BmNi1RgZ.js → commands-DYOuGlEC.js} +1668 -1371
- package/dist/dbCommand-ADD4mrTI.js +2 -0
- package/dist/{dbCommand-DNrkb58g.js → dbCommand-DIOJQwsq.js} +71 -57
- package/dist/{dev-d0LjACxE.js → dev-Fb9BmavX.js} +1483 -1414
- package/dist/dev-xdijqojc.js +3 -0
- package/dist/{seedRunner-DZmhoqNt.js → frameworkTableAssembly-CYlrafoK.js} +110 -331
- package/dist/frameworkTableAssembly-XvKO7wQt.js +2 -0
- package/dist/index.js +1 -1
- package/dist/{inspectMetrics-uEfIS1vp.js → inspectMetrics-DOiiII34.js} +302 -293
- package/dist/seedRunner-D6eu-u5U.js +229 -0
- package/dist/{serveCommand-B2-YV9TU.js → serveCommand-CqYxzBZR.js} +368 -367
- package/dist/serveEntry.js +3 -3
- package/dist/{start-DKcQd52a.js → start-CjG_0xhR.js} +1 -1
- package/dist/startEntry.js +2 -2
- package/package.json +17 -17
- package/templates/AGENTS.md +1 -1
- package/templates/agent-docs/_index.md +1 -1
- package/templates/agent-docs/authentication.md +36 -0
- package/templates/agent-docs/cli.md +78 -4
- package/templates/agent-docs/configuration.md +48 -0
- package/templates/agent-docs/database/migrations.md +32 -0
- package/templates/agent-docs/database/transactions.md +31 -0
- package/templates/agent-docs/testing.md +24 -0
- package/templates/agent-docs/whats-new.md +41 -137
- 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-deactivation/tests/users.deactivate.test.ts +1 -1
- 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-data-advanced/tests/queries.test.ts +6 -1
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-feature-flags/package.json +9 -9
- package/templates/apps/api-governance/app.config.ts +0 -1
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-kv/tests/sync.test.ts +2 -2
- 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/README.md +53 -14
- package/templates/apps/api-rbac/app.config.ts +24 -26
- package/templates/apps/api-rbac/authz.ts +76 -0
- package/templates/apps/api-rbac/database/schema.ts +23 -6
- package/templates/apps/api-rbac/mutations/notes.create.mutation.server.ts +7 -5
- package/templates/apps/api-rbac/mutations/notes.create.mutation.ts +15 -8
- package/templates/apps/api-rbac/mutations/notes.delete.mutation.server.ts +54 -0
- package/templates/apps/api-rbac/mutations/notes.delete.mutation.ts +43 -0
- package/templates/apps/api-rbac/mutations/teams.rename.mutation.server.ts +19 -0
- package/templates/apps/api-rbac/mutations/teams.rename.mutation.ts +37 -0
- package/templates/apps/api-rbac/package.json +8 -8
- package/templates/apps/api-rbac/queries/notes.list.query.server.ts +12 -0
- package/templates/apps/api-rbac/queries/notes.list.query.ts +26 -0
- package/templates/apps/api-rbac/template.json +2 -2
- package/templates/apps/api-rbac/tests/authz.test.ts +233 -0
- 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 +9 -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-s7swuEU5.js +0 -2
- package/dist/dbCommand-Bt6BCG7g.js +0 -2
- package/dist/dev-YHbHmeXt.js +0 -3
- package/templates/apps/api-rbac/tests/notes.create.test.ts +0 -80
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { at as e, t } from "./inspectMetrics-
|
|
2
|
-
import {
|
|
3
|
-
import { r
|
|
4
|
-
import { A as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
1
|
+
import { at as e, t } from "./inspectMetrics-DOiiII34.js";
|
|
2
|
+
import { s as n } from "./seedRunner-D6eu-u5U.js";
|
|
3
|
+
import { r, t as i } from "./appModuleLoader-C9r9mxZt.js";
|
|
4
|
+
import { A as a, D as o, a as s, j as c, k as l, n as u } from "./frameworkTableAssembly-CYlrafoK.js";
|
|
5
|
+
import { A as d, B as f, C as p, D as ee, E as te, F as m, G as ne, H as re, I as h, J as ie, K as g, L as ae, M as _, N as v, O as oe, P as y, S as b, T as se, V as ce, W as le, X as ue, Y as de, Z as fe, _ as pe, a as x, b as S, c as me, f as C, g as w, h as he, j as ge, k as _e, n as ve, p as T, q as ye, r as be, s as xe, v as Se, w as Ce, x as we, y as E, z as Te } from "./dev-Fb9BmavX.js";
|
|
6
|
+
import { c as D, r as Ee } from "./apiBuild-B6_ehbem.js";
|
|
7
|
+
import { t as De } from "./bootTiming-BdyP9nYw.js";
|
|
8
|
+
import { n as Oe } from "./cliArgs-qdZSElM3.js";
|
|
9
|
+
import { join as ke } from "node:path";
|
|
10
|
+
import { pathToFileURL as Ae } from "node:url";
|
|
11
|
+
import { Cause as je, Effect as O, Layer as k, ManagedRuntime as Me } from "effect";
|
|
12
|
+
import { createLogger as A } from "@voltro/logger";
|
|
13
|
+
import { existsSync as j } from "node:fs";
|
|
14
|
+
import { AggregateRegistry as M, Dispatcher as Ne, apiKeyManagementRoutes as N, applySoftDeleteScope as Pe, applyTenantScope as Fe, attachAnalyticsMirror as Ie, awaitServerListening as Le, bindMutation as P, bindStream as Re, bindSubscription as F, buildTracingLayer as ze, cancelWakeup as Be, compileCron as Ve, dataStoreApiKeyStore as He, dataStoreIdempotencyStore as Ue, frameworkApiKeyStrategy as We, installPolicyGuardResolver as Ge, loadResourceTuples as I, makeActionRunner as Ke, makeAdvisoryLockCoordinator as qe, makeApiKeyService as Je, makeApiKeyUsageBuffer as Ye, makeApiKeyUsageFlusher as L, makeAsyncKv as Xe, makeCoordinatedScheduler as Ze, makeEffectStoreLayer as R, makeLazyWorkflowFacade as Qe, makeMutationRunner as $e, makeOneShotQueryRunner as et, makeQueryDescriptorProducer as tt, makeQueryReauthorizer as nt, makeQuerySubscriber as rt, makeSchemaRegistry as it, makeWorkflowFacade as at, makeWorkflowFacadeWithCallerContext as ot, makeWorkflowLayers as z, noopKv as st, recordSubscriptionDelivery as ct, registerWakeup as lt, resolveSecretsBackend as ut, runProvidedEffect as dt, setSecretsBackend as ft, setSystemStoreHandle as pt, setTupleSource as mt, singleCoordinator as ht, startRpcServer as gt, startScheduler as B, workflowToRpc as _t } from "@voltro/runtime";
|
|
15
|
+
import { RpcGroup as vt } from "@effect/rpc";
|
|
16
|
+
import { SqlClient as yt } from "@effect/sql";
|
|
17
|
+
import { and as bt, ensureTableRegistered as xt, eq as V, or as St } from "@voltro/database";
|
|
18
|
+
import { appStorageProvider as H, fromNodeReadable as Ct, getObjectStream as U, putObjectStream as W, toNodeReadable as G } from "@voltro/plugin-storage";
|
|
19
|
+
import { AuthMiddleware as wt, ConnectionInfoMiddleware as Tt, actionToRpc as K, anonymousSubject as Et, mutationToRpc as Dt, queryToRpc as q, streamToRpc as Ot, workflowCancelDescriptor as kt, workflowDomainEventsQueryDescriptor as J, workflowEventDeliveriesQueryDescriptor as At, workflowResumeDescriptor as jt, workflowRunEventsQueryDescriptor as Y, workflowRunQueryDescriptor as X, workflowRunStepsQueryDescriptor as Mt, workflowRunsQueryDescriptor as Z, workflowSignalDescriptor as Nt, workflowUpdateDescriptor as Pt } from "@voltro/protocol";
|
|
19
20
|
import { assertProductionSessionSecret as Ft } from "@voltro/protocol/session";
|
|
20
21
|
import { createHash as It, timingSafeEqual as Lt } from "node:crypto";
|
|
21
22
|
import { declaredSnapshot as Rt, describeOutcome as zt, runPlannedMigrations as Bt } from "@voltro/database/sql";
|
|
@@ -36,7 +37,7 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
36
37
|
if (!t || t.length < 16) return Q(503, { error: "data transfer misconfigured (no/weak secret)" });
|
|
37
38
|
let n = an(e.headers);
|
|
38
39
|
return !n || !on(n, t) ? Q(401, { error: "unauthorized" }) : null;
|
|
39
|
-
}, cn =
|
|
40
|
+
}, cn = A({ scope: "voltro:admin-import" }), ln = "VBUNDLE2", un = async function* (e) {
|
|
40
41
|
yield e;
|
|
41
42
|
}, dn = (e) => async (t) => {
|
|
42
43
|
let n = sn(t, e.secret);
|
|
@@ -60,7 +61,7 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
60
61
|
dir: p,
|
|
61
62
|
blobs: e.assetSink
|
|
62
63
|
}) : await tn(c, p);
|
|
63
|
-
let t = await
|
|
64
|
+
let t = await O.runPromiseExit(Zt({
|
|
64
65
|
store: e.store,
|
|
65
66
|
bundleDir: p,
|
|
66
67
|
...r ? { mode: r } : {},
|
|
@@ -115,7 +116,7 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
115
116
|
force: !0
|
|
116
117
|
});
|
|
117
118
|
}
|
|
118
|
-
}, fn =
|
|
119
|
+
}, fn = A({ scope: "voltro:admin-export" }), pn = async (e) => {
|
|
119
120
|
let t = [];
|
|
120
121
|
for await (let n of e) t.push(Buffer.from(n));
|
|
121
122
|
return new Uint8Array(Buffer.concat(t));
|
|
@@ -148,7 +149,7 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
148
149
|
}
|
|
149
150
|
let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? mn(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = await import("node:os"), d = await import("node:fs/promises"), f = await import("node:path"), p = await d.mkdtemp(f.join(u.tmpdir(), "voltro-admin-export-"));
|
|
150
151
|
try {
|
|
151
|
-
let t = await
|
|
152
|
+
let t = await O.runPromise(Xt({
|
|
152
153
|
store: e.store,
|
|
153
154
|
snapshot: e.snapshot,
|
|
154
155
|
dialect: e.dialect,
|
|
@@ -224,7 +225,7 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
224
225
|
if (!o) throw Error(`data profile '${i}' has no default export`);
|
|
225
226
|
return o;
|
|
226
227
|
}, _n = (e, t, n = {}) => (async function* () {
|
|
227
|
-
let r = await
|
|
228
|
+
let r = await G((await O.runPromise(U(e, t).pipe(O.timeout(n.openTimeout ?? "30 seconds")))).stream), i = n.stallMs ?? 12e4, a, o = () => {
|
|
228
229
|
a && clearTimeout(a), a = setTimeout(() => r.destroy(/* @__PURE__ */ Error(`storage read stalled for ${i}ms reading '${t}'`)), i);
|
|
229
230
|
};
|
|
230
231
|
try {
|
|
@@ -243,20 +244,20 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
243
244
|
invalidateTag: async () => 0,
|
|
244
245
|
wrap: async (e, t, n) => n()
|
|
245
246
|
}, yn = async (e) => {
|
|
246
|
-
|
|
247
|
+
pt({
|
|
247
248
|
dataStore: e.store,
|
|
248
249
|
schemaRegistry: e.schemaRegistry
|
|
249
250
|
});
|
|
250
|
-
let t = new
|
|
251
|
+
let t = new Ne({
|
|
251
252
|
store: e.store,
|
|
252
253
|
...e.snapshotCache ? { cache: e.snapshotCache } : {},
|
|
253
|
-
recordDelivery: (e) =>
|
|
254
|
+
recordDelivery: (e) => ct({
|
|
254
255
|
label: e.label,
|
|
255
256
|
kind: e.kind,
|
|
256
257
|
durationMs: e.durationMs,
|
|
257
258
|
rowCount: e.rowCount
|
|
258
259
|
})
|
|
259
|
-
}), n = e.cache ?? vn, r = e.kv ??
|
|
260
|
+
}), n = e.cache ?? vn, r = e.kv ?? st, i, a, o, s = /* @__PURE__ */ new Map(), c = () => `wfctx_${globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`, l = async (t, n, r) => {
|
|
260
261
|
let i = {
|
|
261
262
|
...r,
|
|
262
263
|
source: r.source ?? `workflow:${t}`
|
|
@@ -266,7 +267,7 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
266
267
|
let r = await e.store.query({
|
|
267
268
|
table: "_voltro_workflow_start_contexts",
|
|
268
269
|
order: [],
|
|
269
|
-
predicate:
|
|
270
|
+
predicate: V("executionId", n),
|
|
270
271
|
projection: ["id"],
|
|
271
272
|
skip: void 0,
|
|
272
273
|
take: 1
|
|
@@ -294,7 +295,7 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
294
295
|
let t = (await e.store.query({
|
|
295
296
|
table: "_voltro_workflow_start_contexts",
|
|
296
297
|
order: [],
|
|
297
|
-
predicate:
|
|
298
|
+
predicate: V("executionId", n),
|
|
298
299
|
projection: void 0,
|
|
299
300
|
skip: void 0,
|
|
300
301
|
take: 1
|
|
@@ -312,17 +313,17 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
312
313
|
process.stderr.write(`[workflow] failed to load start context for ${n}: ${e?.message ?? String(e)}\n`);
|
|
313
314
|
return;
|
|
314
315
|
}
|
|
315
|
-
},
|
|
316
|
-
if (
|
|
317
|
-
let t = e.workflowEngineLayer, i =
|
|
316
|
+
}, f = (e.discovered.workflows?.length ?? 0) > 0 ? Qe(() => i) : void 0, p = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, ee = p || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", te = e.tenantIsolation === "namespace", ne = (e.log ?? A({ scope: "voltro:serve" })).child("webhooks"), re, g = e.discovered.webhooks;
|
|
317
|
+
if (g && g.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
|
|
318
|
+
let t = e.workflowEngineLayer, i = de({
|
|
318
319
|
store: e.store,
|
|
319
320
|
schemaRegistry: e.schemaRegistry,
|
|
320
321
|
cache: n,
|
|
321
322
|
kv: r
|
|
322
|
-
}), a =
|
|
323
|
+
}), a = g.outgoing.map((e) => e.descriptor);
|
|
323
324
|
re = Gt(i, async (e) => {
|
|
324
|
-
let n = qt.execute(e).pipe(
|
|
325
|
-
|
|
325
|
+
let n = qt.execute(e).pipe(O.provide(qt.toLayer(Wt(i, { events: a })).pipe(k.provideMerge(t))));
|
|
326
|
+
O.runPromise(n).catch((t) => {
|
|
326
327
|
ne.error("deliverWebhook workflow crashed", {
|
|
327
328
|
deliveryId: e.deliveryId,
|
|
328
329
|
targetId: e.targetId
|
|
@@ -331,10 +332,10 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
331
332
|
}, { events: a });
|
|
332
333
|
}
|
|
333
334
|
let ae = /* @__PURE__ */ new Map();
|
|
334
|
-
if (
|
|
335
|
+
if (g) for (let e of g.incoming) {
|
|
335
336
|
let t = e.descriptor.path ?? Kt(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = Jt(e.descriptor, {
|
|
336
337
|
resolveSecret: async () => process.env[n] ?? null,
|
|
337
|
-
resolveWorkflows: () =>
|
|
338
|
+
resolveWorkflows: () => f === void 0 ? void 0 : ot(f, {
|
|
338
339
|
traceId: `incoming:${e.descriptor.id}`,
|
|
339
340
|
source: `incoming:${e.descriptor.id}`
|
|
340
341
|
}),
|
|
@@ -351,140 +352,140 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
351
352
|
});
|
|
352
353
|
ae.set(t, { handle: r });
|
|
353
354
|
}
|
|
354
|
-
|
|
355
|
-
let oe = (e.discovered.outboxHandlers?.length ?? 0) > 0 ?
|
|
355
|
+
Ge(), mt((t) => I(e.store, t.subjectId, t.resourceType, t.resourceId));
|
|
356
|
+
let oe = (e.discovered.outboxHandlers?.length ?? 0) > 0 ? m({
|
|
356
357
|
handlers: e.discovered.outboxHandlers ?? [],
|
|
357
358
|
store: e.store,
|
|
358
|
-
log: (e.log ??
|
|
359
|
-
}) : void 0,
|
|
359
|
+
log: (e.log ?? A({ scope: "voltro:serve" })).child("outbox")
|
|
360
|
+
}) : void 0, y = v({
|
|
360
361
|
definitions: (e.discovered.connections ?? []).map((e) => e.definition),
|
|
361
362
|
store: e.store,
|
|
362
|
-
publicUrl:
|
|
363
|
-
log: (e.log ??
|
|
364
|
-
}),
|
|
363
|
+
publicUrl: _(e.port ?? 4e3),
|
|
364
|
+
log: (e.log ?? A({ scope: "voltro:serve" })).child("connections")
|
|
365
|
+
}), b = ie({
|
|
365
366
|
store: e.store,
|
|
366
367
|
schemaRegistry: e.schemaRegistry,
|
|
367
368
|
cache: n,
|
|
368
369
|
kv: r,
|
|
369
370
|
...re === void 0 ? {} : { webhooksService: re },
|
|
370
|
-
...
|
|
371
|
+
...f === void 0 ? {} : { workflowsProxy: f },
|
|
371
372
|
eventTriggers: e.discovered.eventTriggers ?? [],
|
|
372
373
|
namespaceIsolationOn: te,
|
|
373
374
|
...oe === void 0 ? {} : { outbox: { nudge: oe.nudge } },
|
|
374
|
-
...
|
|
375
|
-
}), ce =
|
|
376
|
-
let r = t.pipe(
|
|
377
|
-
return
|
|
378
|
-
},
|
|
375
|
+
...y.active ? { connections: { registry: y.registry } } : {}
|
|
376
|
+
}), ce = k.succeed(M, se), ue = (t, n) => {
|
|
377
|
+
let r = t.pipe(O.provide(R(n)));
|
|
378
|
+
return dt((e.baseLayer ? r.pipe(O.provide(e.baseLayer)) : r).pipe(O.provide(ce)));
|
|
379
|
+
}, fe = $e({
|
|
379
380
|
store: e.store,
|
|
380
|
-
buildContext: (e, t, n) =>
|
|
381
|
-
runEffect:
|
|
382
|
-
undoCapture:
|
|
383
|
-
}),
|
|
384
|
-
buildContext: (e) =>
|
|
385
|
-
runEffect:
|
|
386
|
-
}),
|
|
387
|
-
buildContext: (e) =>
|
|
388
|
-
finalize: (t, n) =>
|
|
389
|
-
provideEffect: (e, t) => e.pipe(
|
|
390
|
-
},
|
|
391
|
-
...
|
|
381
|
+
buildContext: (e, t, n) => b(e, t, n),
|
|
382
|
+
runEffect: ue,
|
|
383
|
+
undoCapture: S()
|
|
384
|
+
}), pe = E(), x = Ke({
|
|
385
|
+
buildContext: (e) => b(e),
|
|
386
|
+
runEffect: ue
|
|
387
|
+
}), me = {
|
|
388
|
+
buildContext: (e) => b(e),
|
|
389
|
+
finalize: (t, n) => Pe(Fe(t, e.tenantScopedTables, n.subject.tenantId), e.softDeleteScopedTables),
|
|
390
|
+
provideEffect: (e, t) => e.pipe(O.provide(R(t)))
|
|
391
|
+
}, C = tt(me), ge = et({
|
|
392
|
+
...me,
|
|
392
393
|
queryRows: (t) => e.store.query(t)
|
|
393
|
-
}),
|
|
394
|
-
...
|
|
394
|
+
}), ve = rt({
|
|
395
|
+
...me,
|
|
395
396
|
subscribeDescriptor: (e, n, r) => t.subscribe(e, n, r),
|
|
396
397
|
subscribeComputed: (e, n, r) => t.subscribeComputed(e, n, r)
|
|
397
|
-
}),
|
|
398
|
+
}), T = {};
|
|
398
399
|
for (let n of [
|
|
399
400
|
...e.discovered.queries,
|
|
400
|
-
...
|
|
401
|
-
...
|
|
402
|
-
])
|
|
401
|
+
...pe.queries,
|
|
402
|
+
...y.queries
|
|
403
|
+
]) T[n.descriptor.name] = (e) => F(C(n, e), t, `subscription.${n.descriptor.name}`, void 0, void 0, nt(n, e));
|
|
403
404
|
for (let t of [
|
|
404
405
|
...e.discovered.mutations,
|
|
405
|
-
...
|
|
406
|
-
...
|
|
407
|
-
])
|
|
408
|
-
for (let t of [...e.discovered.actions, ...
|
|
409
|
-
let
|
|
406
|
+
...pe.mutations,
|
|
407
|
+
...y.mutations
|
|
408
|
+
]) T[t.descriptor.name] = (e) => P(async (e, n) => fe(t, e, n), e, `mutation.${t.descriptor.name}`);
|
|
409
|
+
for (let t of [...e.discovered.actions, ...y.actions]) T[t.descriptor.name] = (e) => P(async (e, n) => x(t, e, n), e, `action.${t.descriptor.name}`);
|
|
410
|
+
let be = () => `public-${Math.random().toString(36).slice(2, 10)}`, xe = [
|
|
410
411
|
...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
411
412
|
descriptor: e.descriptor,
|
|
412
|
-
invoke: (t, n) =>
|
|
413
|
+
invoke: (t, n) => ge(e, t, {
|
|
413
414
|
subject: n.subject,
|
|
414
|
-
traceId:
|
|
415
|
+
traceId: be()
|
|
415
416
|
}),
|
|
416
|
-
subscribe: (t, n, r) =>
|
|
417
|
+
subscribe: (t, n, r) => ve(e, t, {
|
|
417
418
|
subject: n.subject,
|
|
418
|
-
traceId:
|
|
419
|
+
traceId: be()
|
|
419
420
|
}, r)
|
|
420
421
|
})),
|
|
421
422
|
...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
422
423
|
descriptor: e.descriptor,
|
|
423
|
-
invoke: (t, n) =>
|
|
424
|
+
invoke: (t, n) => fe(e, t, {
|
|
424
425
|
subject: n.subject,
|
|
425
|
-
traceId:
|
|
426
|
+
traceId: be()
|
|
426
427
|
})
|
|
427
428
|
})),
|
|
428
429
|
...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
429
430
|
descriptor: e.descriptor,
|
|
430
|
-
invoke: (t, n) =>
|
|
431
|
+
invoke: (t, n) => x(e, t, {
|
|
431
432
|
subject: n.subject,
|
|
432
|
-
traceId:
|
|
433
|
+
traceId: be()
|
|
433
434
|
})
|
|
434
435
|
}))
|
|
435
|
-
],
|
|
436
|
+
], Se = xe.length > 0 ? Ut(Ht(xe), {
|
|
436
437
|
store: e.store,
|
|
437
438
|
resolveSubject: (t) => e.resolveSubject(t, -1)
|
|
438
|
-
}) : [],
|
|
439
|
+
}) : [], we = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Te = we && we.length >= 16 ? [{
|
|
439
440
|
method: "POST",
|
|
440
441
|
path: nn,
|
|
441
442
|
handle: dn({
|
|
442
|
-
secret:
|
|
443
|
+
secret: we,
|
|
443
444
|
store: e.store,
|
|
444
445
|
...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
|
|
445
|
-
assetSink: Qt(
|
|
446
|
-
openArchive: (e) => _n(
|
|
446
|
+
assetSink: Qt(H()),
|
|
447
|
+
openArchive: (e) => _n(H(), e)
|
|
447
448
|
})
|
|
448
449
|
}, {
|
|
449
450
|
method: "POST",
|
|
450
451
|
path: rn,
|
|
451
452
|
handle: hn({
|
|
452
|
-
secret:
|
|
453
|
+
secret: we,
|
|
453
454
|
store: e.store,
|
|
454
455
|
snapshot: e.dataTransferSnapshot ?? { tables: [] },
|
|
455
456
|
dialect: e.dataTransferDialect ?? "memory",
|
|
456
457
|
tenantTables: [...e.tenantScopedTables],
|
|
457
458
|
loadProfile: gn,
|
|
458
|
-
assetSource: $t(
|
|
459
|
+
assetSource: $t(H(), e.store),
|
|
459
460
|
putArchive: async (e, t) => {
|
|
460
|
-
let { Readable: n } = await import("node:stream"), r =
|
|
461
|
-
await
|
|
461
|
+
let { Readable: n } = await import("node:stream"), r = H(), i = Ct("storage", () => n.from(t()));
|
|
462
|
+
await O.runPromise(W(r, e, i, { contentType: "application/octet-stream" }));
|
|
462
463
|
}
|
|
463
464
|
})
|
|
464
|
-
}] : [],
|
|
465
|
+
}] : [], D = [
|
|
465
466
|
...e.httpRoutes ?? [],
|
|
466
|
-
...
|
|
467
|
-
...
|
|
468
|
-
...
|
|
467
|
+
...Se,
|
|
468
|
+
...Te,
|
|
469
|
+
...y.httpRoutes
|
|
469
470
|
];
|
|
470
|
-
for (let t of e.discovered.streams ?? [])
|
|
471
|
-
let i =
|
|
472
|
-
if (
|
|
473
|
-
let t = a.pipe(
|
|
474
|
-
return (e.baseLayer ? t.pipe(
|
|
471
|
+
for (let t of e.discovered.streams ?? []) T[t.descriptor.name] = (n) => Re((r) => {
|
|
472
|
+
let i = b(r), a = t.executor(n, i);
|
|
473
|
+
if (O.isEffect(a)) {
|
|
474
|
+
let t = a.pipe(O.provide(R(i.store)));
|
|
475
|
+
return (e.baseLayer ? t.pipe(O.provide(e.baseLayer)) : t).pipe(O.provide(ce));
|
|
475
476
|
}
|
|
476
|
-
return typeof a == "object" && a && typeof a.then == "function" ?
|
|
477
|
+
return typeof a == "object" && a && typeof a.then == "function" ? O.promise(() => a) : a;
|
|
477
478
|
}, `stream.${t.descriptor.name}`);
|
|
478
|
-
for (let t of e.discovered.workflows ?? [])
|
|
479
|
+
for (let t of e.discovered.workflows ?? []) T[t.definition.name] = (e) => P(async (e, n) => {
|
|
479
480
|
let r = n;
|
|
480
|
-
return
|
|
481
|
+
return ot(f, {
|
|
481
482
|
subject: r.subject,
|
|
482
483
|
traceId: r.traceId,
|
|
483
484
|
source: "workflow-rpc"
|
|
484
485
|
}).start(t.definition.name, e);
|
|
485
486
|
}, e, `workflow.${t.definition.name}`);
|
|
486
|
-
|
|
487
|
-
descriptor:
|
|
487
|
+
p && (T[X.name] = (e) => F(C({
|
|
488
|
+
descriptor: X,
|
|
488
489
|
executor: (e) => {
|
|
489
490
|
let t = e.id;
|
|
490
491
|
return {
|
|
@@ -493,29 +494,29 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
493
494
|
column: "startedAt",
|
|
494
495
|
direction: "desc"
|
|
495
496
|
}],
|
|
496
|
-
predicate:
|
|
497
|
+
predicate: St(V("id", t), V("executionId", t)),
|
|
497
498
|
take: 1,
|
|
498
499
|
skip: void 0,
|
|
499
500
|
projection: void 0
|
|
500
501
|
};
|
|
501
502
|
}
|
|
502
|
-
}, e), t, `subscription.${
|
|
503
|
+
}, e), t, `subscription.${X.name}`), T[Z.name] = (e) => F(C({
|
|
503
504
|
descriptor: Z,
|
|
504
505
|
executor: (e) => {
|
|
505
|
-
let t = e, n = [...t.tag === void 0 ? [] : [
|
|
506
|
+
let t = e, n = [...t.tag === void 0 ? [] : [V("tag", t.tag)], ...t.status === void 0 ? [] : [V("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
|
|
506
507
|
return {
|
|
507
508
|
table: "_voltro_workflow_runs",
|
|
508
509
|
order: [{
|
|
509
510
|
column: "startedAt",
|
|
510
511
|
direction: "desc"
|
|
511
512
|
}],
|
|
512
|
-
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] :
|
|
513
|
+
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : bt(...n),
|
|
513
514
|
take: r,
|
|
514
515
|
skip: void 0,
|
|
515
516
|
projection: void 0
|
|
516
517
|
};
|
|
517
518
|
}
|
|
518
|
-
}, e), t, `subscription.${Z.name}`),
|
|
519
|
+
}, e), t, `subscription.${Z.name}`), T[Mt.name] = (e) => F(C({
|
|
519
520
|
descriptor: Mt,
|
|
520
521
|
executor: (e) => {
|
|
521
522
|
let t = e.runId;
|
|
@@ -525,14 +526,14 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
525
526
|
column: "startedAt",
|
|
526
527
|
direction: "asc"
|
|
527
528
|
}],
|
|
528
|
-
predicate:
|
|
529
|
+
predicate: V("runId", t),
|
|
529
530
|
take: 1e3,
|
|
530
531
|
skip: void 0,
|
|
531
532
|
projection: void 0
|
|
532
533
|
};
|
|
533
534
|
}
|
|
534
|
-
}, e), t, `subscription.${Mt.name}`),
|
|
535
|
-
descriptor:
|
|
535
|
+
}, e), t, `subscription.${Mt.name}`), T[Y.name] = (e) => F(C({
|
|
536
|
+
descriptor: Y,
|
|
536
537
|
executor: (e) => {
|
|
537
538
|
let t = e.runId;
|
|
538
539
|
return {
|
|
@@ -541,14 +542,14 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
541
542
|
column: "occurredAt",
|
|
542
543
|
direction: "asc"
|
|
543
544
|
}],
|
|
544
|
-
predicate:
|
|
545
|
+
predicate: V("runId", t),
|
|
545
546
|
take: 1e3,
|
|
546
547
|
skip: void 0,
|
|
547
548
|
projection: void 0
|
|
548
549
|
};
|
|
549
550
|
}
|
|
550
|
-
}, e), t, `subscription.${
|
|
551
|
-
descriptor:
|
|
551
|
+
}, e), t, `subscription.${Y.name}`), T[J.name] = (e) => F(C({
|
|
552
|
+
descriptor: J,
|
|
552
553
|
executor: (e) => {
|
|
553
554
|
let t = e;
|
|
554
555
|
return {
|
|
@@ -557,14 +558,14 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
557
558
|
column: "occurredAt",
|
|
558
559
|
direction: "desc"
|
|
559
560
|
}],
|
|
560
|
-
predicate: t.name === void 0 ? void 0 :
|
|
561
|
+
predicate: t.name === void 0 ? void 0 : V("name", t.name),
|
|
561
562
|
take: Math.max(1, Math.min(500, t.limit ?? 100)),
|
|
562
563
|
skip: void 0,
|
|
563
564
|
projection: void 0
|
|
564
565
|
};
|
|
565
566
|
}
|
|
566
|
-
}, e), t, `subscription.${
|
|
567
|
-
descriptor:
|
|
567
|
+
}, e), t, `subscription.${J.name}`), T[At.name] = (e) => F(C({
|
|
568
|
+
descriptor: At,
|
|
568
569
|
executor: (e) => {
|
|
569
570
|
let t = e.eventId;
|
|
570
571
|
return {
|
|
@@ -573,69 +574,69 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
573
574
|
column: "createdAt",
|
|
574
575
|
direction: "asc"
|
|
575
576
|
}],
|
|
576
|
-
predicate:
|
|
577
|
+
predicate: V("eventId", t),
|
|
577
578
|
take: 500,
|
|
578
579
|
skip: void 0,
|
|
579
580
|
projection: void 0
|
|
580
581
|
};
|
|
581
582
|
}
|
|
582
|
-
}, e), t, `subscription.${
|
|
583
|
+
}, e), t, `subscription.${At.name}`), T[kt.name] = (t) => P(async (t, n) => {
|
|
583
584
|
let r = t;
|
|
584
|
-
return await
|
|
585
|
-
}, t, `action.${
|
|
585
|
+
return await ye(e.store, n.subject, { executionId: r.executionId }), await f.cancel(r.workflowName, r.executionId), await Ve(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
|
|
586
|
+
}, t, `action.${kt.name}`), T[jt.name] = (t) => P(async (t, n) => {
|
|
586
587
|
let r = t;
|
|
587
|
-
return await
|
|
588
|
-
}, t, `action.${
|
|
588
|
+
return await ye(e.store, n.subject, { executionId: r.executionId }), await f.resume(r.workflowName, r.executionId), { ok: !0 };
|
|
589
|
+
}, t, `action.${jt.name}`), T[Nt.name] = (t) => P(async (t, n) => {
|
|
589
590
|
let r = t;
|
|
590
|
-
return await
|
|
591
|
-
}, t, `action.${Nt.name}`),
|
|
591
|
+
return await ye(e.store, n.subject, { id: r.id }), f.signal({ id: r.id }, r.signalName, r.payload);
|
|
592
|
+
}, t, `action.${Nt.name}`), T[Pt.name] = (t) => P(async (t, n) => {
|
|
592
593
|
let r = t;
|
|
593
|
-
return await
|
|
594
|
+
return await ye(e.store, n.subject, { id: r.id }), f.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
|
|
594
595
|
}, t, `action.${Pt.name}`));
|
|
595
|
-
let
|
|
596
|
-
...e.discovered.queries.map((e) =>
|
|
597
|
-
...e.discovered.mutations.map((e) =>
|
|
598
|
-
...e.discovered.actions.map((e) =>
|
|
599
|
-
...
|
|
600
|
-
...
|
|
601
|
-
...
|
|
602
|
-
...
|
|
603
|
-
...
|
|
604
|
-
...(e.discovered.streams ?? []).map((e) =>
|
|
605
|
-
...(e.discovered.workflows ?? []).map((e) =>
|
|
606
|
-
...
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
J
|
|
612
|
-
J(kt),
|
|
613
|
-
q(Ot),
|
|
596
|
+
let Ee = [
|
|
597
|
+
...e.discovered.queries.map((e) => q(e.descriptor)),
|
|
598
|
+
...e.discovered.mutations.map((e) => Dt(e.descriptor)),
|
|
599
|
+
...e.discovered.actions.map((e) => K(e.descriptor)),
|
|
600
|
+
...pe.queries.map((e) => q(e.descriptor)),
|
|
601
|
+
...pe.mutations.map((e) => Dt(e.descriptor)),
|
|
602
|
+
...y.queries.map((e) => q(e.descriptor)),
|
|
603
|
+
...y.mutations.map((e) => Dt(e.descriptor)),
|
|
604
|
+
...y.actions.map((e) => K(e.descriptor)),
|
|
605
|
+
...(e.discovered.streams ?? []).map((e) => Ot(e.descriptor)),
|
|
606
|
+
...(e.discovered.workflows ?? []).map((e) => _t(e.definition)),
|
|
607
|
+
...p ? [
|
|
608
|
+
q(X),
|
|
609
|
+
q(Z),
|
|
610
|
+
q(Mt),
|
|
611
|
+
q(Y),
|
|
612
|
+
q(J),
|
|
614
613
|
q(At),
|
|
615
|
-
|
|
616
|
-
|
|
614
|
+
K(kt),
|
|
615
|
+
K(jt),
|
|
616
|
+
K(Nt),
|
|
617
|
+
K(Pt)
|
|
617
618
|
] : []
|
|
618
|
-
],
|
|
619
|
-
register: (t, n, r) =>
|
|
620
|
-
tenantId: r ??
|
|
619
|
+
], De = vt.make(...Ee).middleware(wt).middleware(Tt), Oe = k.succeed(wt, wt.of(({ headers: t, clientId: n }) => O.promise(() => e.resolveSubject(t, n)))), ke = k.succeed(Tt, Tt.of(({ clientId: e }) => O.succeed({ clientId: e }))), Ae = e.dormancyTenantId ?? "default", je = e.dormancy === "sleep" ? {
|
|
620
|
+
register: (t, n, r) => lt(e.store, {
|
|
621
|
+
tenantId: r ?? Ae,
|
|
621
622
|
kind: "workflow",
|
|
622
623
|
refId: t,
|
|
623
624
|
wakeAt: n
|
|
624
625
|
}),
|
|
625
|
-
cancel: (t, n) =>
|
|
626
|
-
tenantId: n ??
|
|
626
|
+
cancel: (t, n) => Be(e.store, {
|
|
627
|
+
tenantId: n ?? Ae,
|
|
627
628
|
kind: "workflow",
|
|
628
629
|
refId: t
|
|
629
630
|
}).then(() => {})
|
|
630
|
-
} : void 0,
|
|
631
|
+
} : void 0, j = ee ? await import("@voltro/workflow") : void 0, N = j?.makeWorkflowRunRecorder({
|
|
631
632
|
store: e.store,
|
|
632
|
-
...
|
|
633
|
-
}),
|
|
634
|
-
await
|
|
633
|
+
...je === void 0 ? {} : { wakeups: je }
|
|
634
|
+
}), Ie = async (t, n) => {
|
|
635
|
+
await j.closeWorkflowChildrenForParent({
|
|
635
636
|
store: e.store,
|
|
636
637
|
parentExecutionId: t,
|
|
637
638
|
parentStatus: n,
|
|
638
|
-
recorder:
|
|
639
|
+
recorder: N,
|
|
639
640
|
log: { warn: (e, t) => {
|
|
640
641
|
process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
641
642
|
} },
|
|
@@ -646,11 +647,11 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
646
647
|
await a.runPromise(r.definition.interrupt(n));
|
|
647
648
|
}
|
|
648
649
|
});
|
|
649
|
-
},
|
|
650
|
+
}, Ve = async (t, n, r) => {
|
|
650
651
|
let i = (await e.store.query({
|
|
651
652
|
table: "_voltro_workflow_runs",
|
|
652
653
|
order: [],
|
|
653
|
-
predicate:
|
|
654
|
+
predicate: V("executionId", n),
|
|
654
655
|
projection: void 0,
|
|
655
656
|
skip: void 0,
|
|
656
657
|
take: 1
|
|
@@ -661,7 +662,7 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
661
662
|
cancelled: !0,
|
|
662
663
|
completedAt: /* @__PURE__ */ new Date()
|
|
663
664
|
}), o = i.subject?.tenantId ?? void 0;
|
|
664
|
-
a && await
|
|
665
|
+
a && await N.recordEvent({
|
|
665
666
|
runId: i.id,
|
|
666
667
|
eventType: "run-cancelled",
|
|
667
668
|
payload: {
|
|
@@ -670,16 +671,16 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
670
671
|
executionId: n,
|
|
671
672
|
...o == null ? {} : { tenantId: o }
|
|
672
673
|
}
|
|
673
|
-
}), a && await
|
|
674
|
-
},
|
|
675
|
-
buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ??
|
|
674
|
+
}), a && await Ie(n, "cancelled");
|
|
675
|
+
}, He = [...z(e.discovered.workflows ?? [], {
|
|
676
|
+
buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? b({
|
|
676
677
|
subject: t.subject,
|
|
677
678
|
traceId: t.traceId
|
|
678
679
|
}, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
|
|
679
680
|
resolveStartContext: u
|
|
680
681
|
}, (t, n, r) => {
|
|
681
|
-
let i =
|
|
682
|
-
return
|
|
682
|
+
let i = j.getWorkflowVersionMetadata(t.definition);
|
|
683
|
+
return j.wrapWorkflowExecuteWithRunRecording({
|
|
683
684
|
name: t.definition.name,
|
|
684
685
|
store: e.store,
|
|
685
686
|
subject: r.subject,
|
|
@@ -690,69 +691,69 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
690
691
|
workflowPatches: i.patches,
|
|
691
692
|
parentExecutionId: r?.parentExecutionId ?? null,
|
|
692
693
|
parentClosePolicy: r?.parentClosePolicy ?? null,
|
|
693
|
-
onParentClose: ({ executionId: e, status: t }) =>
|
|
694
|
-
recorder:
|
|
694
|
+
onParentClose: ({ executionId: e, status: t }) => Ie(e, t),
|
|
695
|
+
recorder: N
|
|
695
696
|
}, n);
|
|
696
|
-
}), ...e.discovered.workflowWorkers ?? []],
|
|
697
|
+
}), ...e.discovered.workflowWorkers ?? []], Ue = He.length > 0 ? k.mergeAll(...He) : k.empty;
|
|
697
698
|
if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster") && e.workflowEngineLayer !== void 0) {
|
|
698
|
-
let t =
|
|
699
|
-
a =
|
|
699
|
+
let t = Ue.pipe(k.provideMerge(e.workflowEngineLayer));
|
|
700
|
+
a = Me.make(e.baseLayer === void 0 ? t : t.pipe(k.provideMerge(e.baseLayer))), await a.runPromise(O.void), i = (e.discovered.workflows?.length ?? 0) > 0 ? at({
|
|
700
701
|
workflows: e.discovered.workflows ?? [],
|
|
701
702
|
runEffect: (e) => a.runPromise(e),
|
|
702
703
|
rememberStartContext: l,
|
|
703
704
|
signal: async (t, n, r) => {
|
|
704
|
-
let i = await
|
|
705
|
+
let i = await j.sendWorkflowSignal({
|
|
705
706
|
store: e.store,
|
|
706
|
-
recorder:
|
|
707
|
+
recorder: N,
|
|
707
708
|
target: t,
|
|
708
709
|
signalName: n,
|
|
709
710
|
payload: r
|
|
710
711
|
});
|
|
711
|
-
return await a.runPromise(
|
|
712
|
+
return await a.runPromise(j.completeSuspendingSignal({
|
|
712
713
|
store: e.store,
|
|
713
714
|
target: t,
|
|
714
715
|
signalName: n,
|
|
715
716
|
payload: r
|
|
716
717
|
})).catch(() => {}), i;
|
|
717
718
|
},
|
|
718
|
-
update: (t, n, r, i) =>
|
|
719
|
+
update: (t, n, r, i) => j.sendWorkflowUpdate({
|
|
719
720
|
store: e.store,
|
|
720
|
-
recorder:
|
|
721
|
+
recorder: N,
|
|
721
722
|
target: t,
|
|
722
723
|
updateName: n,
|
|
723
724
|
payload: r,
|
|
724
725
|
...i === void 0 ? {} : { options: i }
|
|
725
726
|
}),
|
|
726
|
-
listRuns: (t) =>
|
|
727
|
-
retry: (t, n) =>
|
|
727
|
+
listRuns: (t) => he(e.store, t),
|
|
728
|
+
retry: (t, n) => w({
|
|
728
729
|
store: e.store,
|
|
729
730
|
workflows: e.discovered.workflows ?? [],
|
|
730
731
|
runPromise: (e) => a.runPromise(e)
|
|
731
732
|
}, t, n)
|
|
732
733
|
}) : void 0;
|
|
733
734
|
}
|
|
734
|
-
let
|
|
735
|
-
...
|
|
736
|
-
...
|
|
737
|
-
...
|
|
738
|
-
...
|
|
739
|
-
}),
|
|
740
|
-
group:
|
|
741
|
-
handlersLayer:
|
|
742
|
-
httpHandlersLayer:
|
|
735
|
+
let We = k.mergeAll(De.toLayer(T), Oe, ke), Je = le(T, e.discovered.queries.map((e) => e.descriptor.name), p), Ye = k.mergeAll(De.toLayer(Je), Oe, ke), L = e.observability, Xe = await ze({
|
|
736
|
+
...L && L.spanProcessors.length > 0 ? { extraSpanProcessors: L.spanProcessors } : {},
|
|
737
|
+
...L && L.metricReaders.length > 0 ? { extraMetricReaders: L.metricReaders } : {},
|
|
738
|
+
...L && Object.keys(L.resourceAttributes).length > 0 ? { resourceAttributes: L.resourceAttributes } : {},
|
|
739
|
+
...L && L.sampler !== void 0 ? { sampler: L.sampler } : {}
|
|
740
|
+
}), Ze = !1, it = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: ut, shutdown: ft } = gt({
|
|
741
|
+
group: De,
|
|
742
|
+
handlersLayer: We,
|
|
743
|
+
httpHandlersLayer: Ye,
|
|
743
744
|
port: e.port ?? 4e3,
|
|
744
745
|
path: e.path ?? "/ws",
|
|
745
|
-
tracerLayer:
|
|
746
|
+
tracerLayer: Xe.layer,
|
|
746
747
|
healthCheck: {
|
|
747
|
-
isReady: () =>
|
|
748
|
-
...
|
|
748
|
+
isReady: () => Ze,
|
|
749
|
+
...it ? { ping: it } : {}
|
|
749
750
|
},
|
|
750
|
-
...
|
|
751
|
+
...D.length > 0 ? { httpRoutes: D } : {},
|
|
751
752
|
...ae.size > 0 ? { webhookRoutes: ae } : {}
|
|
752
753
|
});
|
|
753
|
-
if (await
|
|
754
|
-
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ?
|
|
755
|
-
o = await
|
|
754
|
+
if (await Le(ut), (e.discovered.schedules?.length ?? 0) > 0) {
|
|
755
|
+
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? qe(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ht;
|
|
756
|
+
o = await B(e.discovered.schedules ?? [], {
|
|
756
757
|
store: e.store,
|
|
757
758
|
coordinator: t,
|
|
758
759
|
defaultTrigger: e.scheduleDefaultTrigger ?? "self",
|
|
@@ -760,7 +761,7 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
760
761
|
armSelf: e.scheduleArmSelf ?? !0,
|
|
761
762
|
dormancy: e.dormancy ?? "always-on",
|
|
762
763
|
...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
|
|
763
|
-
buildContext: ({ traceId: t, scheduleName: n, subject: r }) =>
|
|
764
|
+
buildContext: ({ traceId: t, scheduleName: n, subject: r }) => b({
|
|
764
765
|
subject: r,
|
|
765
766
|
traceId: t
|
|
766
767
|
}, e.store, void 0, `schedule:${n}`),
|
|
@@ -780,27 +781,27 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
780
781
|
...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
|
|
781
782
|
}), e.onSchedulerReady?.(o);
|
|
782
783
|
}
|
|
783
|
-
let
|
|
784
|
-
if ((e.discovered.subscribers?.length ?? 0) > 0 && (
|
|
785
|
-
let t =
|
|
786
|
-
|
|
784
|
+
let yt = e.log ?? A({ scope: "voltro:serve" }), xt, U;
|
|
785
|
+
if ((e.discovered.subscribers?.length ?? 0) > 0 && (xt = h(e.discovered.subscribers ?? [], e.store, yt.child("subscribe"), e.schemaRegistry)), (e.discovered.reactions?.length ?? 0) > 0) {
|
|
786
|
+
let t = yt.child("reaction");
|
|
787
|
+
U = _e(e.discovered.reactions ?? [], e.store, {
|
|
787
788
|
runAct: async (n, r) => {
|
|
788
789
|
if (n.kind === "workflow") {
|
|
789
|
-
if (
|
|
790
|
+
if (f === void 0) {
|
|
790
791
|
t.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: n.workflow });
|
|
791
792
|
return;
|
|
792
793
|
}
|
|
793
794
|
let e = r.new ?? r.old ?? {};
|
|
794
|
-
await
|
|
795
|
+
await ot(f, {
|
|
795
796
|
traceId: `reaction:${n.workflow}`,
|
|
796
797
|
source: `reaction:${n.workflow}`
|
|
797
798
|
}).start(n.workflow, e);
|
|
798
799
|
return;
|
|
799
800
|
}
|
|
800
|
-
await
|
|
801
|
+
await d(n.agent, r, {
|
|
801
802
|
findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
|
|
802
|
-
runAction: (e, t, n) => Promise.resolve(
|
|
803
|
-
makeSubject: (e) =>
|
|
803
|
+
runAction: (e, t, n) => Promise.resolve(x(e, t, n)),
|
|
804
|
+
makeSubject: (e) => Et(e),
|
|
804
805
|
now: () => Date.now(),
|
|
805
806
|
log: t
|
|
806
807
|
});
|
|
@@ -808,7 +809,7 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
808
809
|
checkBudget: async (n, r) => {
|
|
809
810
|
try {
|
|
810
811
|
let { requireAiBudget: t } = await import("@voltro/ai");
|
|
811
|
-
return (await
|
|
812
|
+
return (await O.runPromise(O.either(t(e.store, {
|
|
812
813
|
tenantId: n,
|
|
813
814
|
limitUsd: r
|
|
814
815
|
}))))._tag === "Right";
|
|
@@ -818,28 +819,28 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
818
819
|
}
|
|
819
820
|
}, t);
|
|
820
821
|
}
|
|
821
|
-
let
|
|
822
|
-
return (e.discovered.aggregates?.length ?? 0) > 0 && (
|
|
822
|
+
let G;
|
|
823
|
+
return (e.discovered.aggregates?.length ?? 0) > 0 && (G = await Ce({
|
|
823
824
|
discovered: e.discovered.aggregates ?? [],
|
|
824
825
|
store: e.store,
|
|
825
|
-
log:
|
|
826
|
+
log: yt.child("aggregate"),
|
|
826
827
|
...e.analytics === void 0 ? {} : { analytics: e.analytics },
|
|
827
828
|
...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
|
|
828
829
|
...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
|
|
829
|
-
}), ce =
|
|
830
|
+
}), ce = k.succeed(M, G.registry)), Ze = !0, e.bootTiming?.mark("ready"), {
|
|
830
831
|
dispatcher: t,
|
|
831
|
-
server:
|
|
832
|
+
server: ut,
|
|
832
833
|
scheduler: o,
|
|
833
834
|
close: async () => {
|
|
834
|
-
|
|
835
|
+
Ze = !1, G?.detach(), U?.(), xt?.(), await o?.shutdown(), t.close(), await a?.dispose(), await new Promise((e) => ut.close(() => e())), await ft();
|
|
835
836
|
}
|
|
836
837
|
};
|
|
837
|
-
}, $ =
|
|
838
|
-
let t =
|
|
839
|
-
if (
|
|
838
|
+
}, $ = A({ scope: "voltro:serve" }), bn = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", xn = Oe, Sn = async (e) => {
|
|
839
|
+
let t = D(process.cwd());
|
|
840
|
+
if (j(t)) {
|
|
840
841
|
let n;
|
|
841
842
|
try {
|
|
842
|
-
let e = await import(
|
|
843
|
+
let e = await import(Ae(t).href);
|
|
843
844
|
typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
|
|
844
845
|
} catch (e) {
|
|
845
846
|
$.warn("serve bundle failed to load — using the standard serve path", {}, e);
|
|
@@ -847,92 +848,92 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
847
848
|
if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
|
|
848
849
|
}
|
|
849
850
|
return Cn(e);
|
|
850
|
-
}, Cn = async (
|
|
851
|
-
let m =
|
|
851
|
+
}, Cn = async (d) => {
|
|
852
|
+
let m = De();
|
|
852
853
|
process.env.NODE_ENV || (process.env.NODE_ENV = "production"), Ft();
|
|
853
|
-
let h = process.cwd(),
|
|
854
|
-
|
|
854
|
+
let h = process.cwd(), ie = Number(process.env.PORT ?? xn(d, "--port") ?? 4e3), _ = await xe(h);
|
|
855
|
+
ft(ut(_?.secrets)), await e({
|
|
855
856
|
rawEnv: _?.env,
|
|
856
857
|
appType: "api",
|
|
857
858
|
root: h,
|
|
858
859
|
log: $,
|
|
859
860
|
generateTypes: !1
|
|
860
861
|
}), m.mark("config");
|
|
861
|
-
let
|
|
862
|
-
if (!
|
|
863
|
-
let e = await import(
|
|
862
|
+
let v = (process.env.DB_DIALECT ?? _?.store ?? "memory").toLowerCase(), se = (v === "mariadb" || v === "postgres" || v === "mssql") && (process.env.CDC ?? "1") !== "0", le = v === "mariadb" ? "mariadb" : v === "mssql" ? "mssql" : void 0, de = Ee(h);
|
|
863
|
+
if (!i() && j(de)) try {
|
|
864
|
+
let e = await import(Ae(de).href);
|
|
864
865
|
if (e.modules) {
|
|
865
866
|
let t = {};
|
|
866
|
-
for (let [n, r] of Object.entries(e.modules)) t[
|
|
867
|
-
|
|
867
|
+
for (let [n, r] of Object.entries(e.modules)) t[ke(h, n)] = r;
|
|
868
|
+
r(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
|
|
868
869
|
}
|
|
869
870
|
} catch (e) {
|
|
870
871
|
$.warn("precompiled api bundle failed to load — falling back to source", {}, e);
|
|
871
872
|
}
|
|
872
|
-
let
|
|
873
|
-
mix:
|
|
873
|
+
let S = await C(h), w = await me(S, { cdc: se && le !== void 0 }), he = S.filter((e) => b.test(e)), _e = he.length > 0 ? await p(he, $.child("webhooks")) : void 0, ye = u({
|
|
874
|
+
mix: w.featureMix,
|
|
874
875
|
plugins: _?.plugins ?? [],
|
|
875
|
-
cdc:
|
|
876
|
-
...
|
|
877
|
-
}),
|
|
876
|
+
cdc: se && le !== void 0,
|
|
877
|
+
...le ? { cdcDialect: le } : {}
|
|
878
|
+
}), Ce = _?.analytics !== void 0 && _.analytics.kind !== "noop" && v !== "memory" ? (await n(v)).makeSqlLayer(x()) : void 0, E = await f({
|
|
878
879
|
spec: _?.analytics,
|
|
879
|
-
sqlLayer:
|
|
880
|
+
sqlLayer: Ce,
|
|
880
881
|
log: $
|
|
881
|
-
}),
|
|
882
|
-
let e = new Set(
|
|
883
|
-
for (let n of [...
|
|
882
|
+
}), D = (() => {
|
|
883
|
+
let e = new Set(w.tables.map((e) => e.tableName)), t = [...w.tables];
|
|
884
|
+
for (let n of [...ye, ...E.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
|
|
884
885
|
return t;
|
|
885
886
|
})();
|
|
886
|
-
for (let e of
|
|
887
|
-
let
|
|
888
|
-
if (bn(
|
|
889
|
-
let e = (await
|
|
890
|
-
appliedBy: `serve:${
|
|
887
|
+
for (let e of D) xt(e);
|
|
888
|
+
let Oe = (process.env.NODE_ENV ?? "").toLowerCase();
|
|
889
|
+
if (bn(Oe, v, process.env.VOLTRO_AUTO_MIGRATE)) {
|
|
890
|
+
let e = (await n(v)).makeSqlLayer(x()), t = await O.runPromise(yt.SqlClient.pipe(O.flatMap((e) => Bt(e, D, {
|
|
891
|
+
appliedBy: `serve:${Oe}`,
|
|
891
892
|
environment: "prod",
|
|
892
|
-
dialectId:
|
|
893
|
-
})),
|
|
894
|
-
t.kind === "prod-mismatch" && ($.error(zt(t,
|
|
893
|
+
dialectId: v
|
|
894
|
+
})), O.provide(e)));
|
|
895
|
+
t.kind === "prod-mismatch" && ($.error(zt(t, v)), $.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(zt(t, v));
|
|
895
896
|
}
|
|
896
|
-
let
|
|
897
|
+
let A = it(D);
|
|
897
898
|
m.mark("discover");
|
|
898
|
-
let
|
|
899
|
+
let M = await be(_, void 0);
|
|
899
900
|
_?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = _.cache), _?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = _.cacheRedisUrl), _?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = _.cacheRedisDriver), _?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = _.cacheKeyPrefix);
|
|
900
|
-
let { service:
|
|
901
|
-
$.info(`cache backend resolved: ${
|
|
902
|
-
|
|
901
|
+
let { service: Ne, invalidationBus: Pe, snapshotCache: Fe, cache: Le, backend: P, dispose: Re } = await fe({ env: process.env });
|
|
902
|
+
$.info(`cache backend resolved: ${P}` + (P === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), M.onChange((e) => {
|
|
903
|
+
O.runFork(Pe.publish(e.table));
|
|
903
904
|
}), _?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = _.kv), _?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = _.kvRedisUrl), _?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = _.kvKeyPrefix);
|
|
904
|
-
let { kv:
|
|
905
|
+
let { kv: F, service: ze } = await Xe({ store: M });
|
|
905
906
|
m.mark("store");
|
|
906
|
-
let
|
|
907
|
-
store:
|
|
908
|
-
sink:
|
|
907
|
+
let Be = Ie({
|
|
908
|
+
store: M,
|
|
909
|
+
sink: E.sink,
|
|
909
910
|
log: $
|
|
910
|
-
}),
|
|
911
|
-
store:
|
|
912
|
-
dialect:
|
|
913
|
-
}),
|
|
914
|
-
|
|
915
|
-
let
|
|
911
|
+
}), Ge = ue({
|
|
912
|
+
store: M,
|
|
913
|
+
dialect: v
|
|
914
|
+
}), I = _?.plugins ?? [], Ke = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, R, Qe;
|
|
915
|
+
v !== "memory" && (R = Me.make((await n(v)).makeSqlLayer(x())), Qe = await R.runPromise(yt.SqlClient));
|
|
916
|
+
let $e = Ze({
|
|
916
917
|
coordinator: [
|
|
917
918
|
"postgres",
|
|
918
919
|
"mariadb",
|
|
919
920
|
"mysql",
|
|
920
921
|
"mssql"
|
|
921
|
-
].includes(
|
|
922
|
-
replicaId:
|
|
922
|
+
].includes(v) ? qe(M, Ke, $) : ht,
|
|
923
|
+
replicaId: Ke,
|
|
923
924
|
log: $
|
|
924
|
-
}),
|
|
925
|
-
...
|
|
925
|
+
}), et = [], tt = {
|
|
926
|
+
...Qe ? { sql: Qe } : {},
|
|
926
927
|
scheduleCoordinated: (e, t, n) => {
|
|
927
|
-
let r =
|
|
928
|
-
return
|
|
928
|
+
let r = $e(e, t, n);
|
|
929
|
+
return et.push(r), r;
|
|
929
930
|
}
|
|
930
931
|
};
|
|
931
|
-
for (let e of
|
|
932
|
-
let
|
|
933
|
-
if (
|
|
934
|
-
let e =
|
|
935
|
-
|
|
932
|
+
for (let e of I) e.bindDataStore?.(M, tt);
|
|
933
|
+
let nt = I.filter((e) => typeof e.onChangeEvent == "function");
|
|
934
|
+
if (nt.length > 0) {
|
|
935
|
+
let e = M.changeScope ?? "local";
|
|
936
|
+
M.onChange((t) => {
|
|
936
937
|
let n = {
|
|
937
938
|
table: t.table,
|
|
938
939
|
op: t.op,
|
|
@@ -941,69 +942,69 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
941
942
|
...t.origin === void 0 ? {} : { origin: t.origin },
|
|
942
943
|
changeScope: e
|
|
943
944
|
};
|
|
944
|
-
for (let e of
|
|
945
|
+
for (let e of nt) O.runFork(e.onChangeEvent(n).pipe(O.catchAllCause((t) => O.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: je.pretty(t) })))));
|
|
945
946
|
});
|
|
946
947
|
}
|
|
947
|
-
let
|
|
948
|
-
plugins:
|
|
948
|
+
let rt = Se({
|
|
949
|
+
plugins: I,
|
|
949
950
|
appName: _?.name ?? "voltro-api",
|
|
950
951
|
appType: "api",
|
|
951
952
|
voltroVersion: process.env.npm_package_version ?? "0.0.0",
|
|
952
953
|
log: $
|
|
953
954
|
});
|
|
954
|
-
|
|
955
|
-
let
|
|
955
|
+
I.length && await rt.activate(), m.mark("plugins");
|
|
956
|
+
let at = await rt.gatherObservability(), ot = await T(M, _, v, {
|
|
956
957
|
info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
957
958
|
warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
958
959
|
debug: () => {}
|
|
959
|
-
}),
|
|
960
|
-
|
|
961
|
-
|
|
960
|
+
}), z = _?.apiKeys, st = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", ct = z ? He(M) : void 0, lt = ct ? Ye({ flush: L(ct) }) : void 0;
|
|
961
|
+
lt && process.once("exit", () => {
|
|
962
|
+
lt.shutdown();
|
|
962
963
|
});
|
|
963
|
-
let
|
|
964
|
-
prefix:
|
|
965
|
-
...
|
|
966
|
-
}) : void 0,
|
|
967
|
-
store:
|
|
968
|
-
header: (typeof
|
|
969
|
-
ttlMs: (typeof
|
|
970
|
-
} : void 0,
|
|
971
|
-
store:
|
|
972
|
-
resolveSubject: (e) =>
|
|
964
|
+
let dt = ct ? Je(ct, {
|
|
965
|
+
prefix: st,
|
|
966
|
+
...lt ? { usage: lt } : {}
|
|
967
|
+
}) : void 0, pt = dt ? [We(dt, { prefix: st })] : [], mt = ve([..._?.auth?.strategies ?? [], ...pt], Vt(_?.plugins ?? []), _?.auth?.anonymousTenantRequired ?? !1, _?.auth?.resolveScopes), gt = [..._?.restRoutes ?? [], ...dt ? N(dt, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], B = _?.idempotency, _t = B ? {
|
|
968
|
+
store: Ue(M),
|
|
969
|
+
header: (typeof B == "object" ? B.header : void 0) ?? "Idempotency-Key",
|
|
970
|
+
ttlMs: (typeof B == "object" ? B.ttlMs : void 0) ?? 864e5
|
|
971
|
+
} : void 0, vt = gt.length > 0 ? Ut(gt, {
|
|
972
|
+
store: M,
|
|
973
|
+
resolveSubject: (e) => mt({
|
|
973
974
|
headers: e,
|
|
974
975
|
clientId: -1
|
|
975
976
|
}),
|
|
976
|
-
...
|
|
977
|
-
}) : [],
|
|
978
|
-
analyticsLayer:
|
|
979
|
-
cacheService:
|
|
980
|
-
kvService:
|
|
981
|
-
pluginServices:
|
|
977
|
+
..._t ? { idempotency: _t } : {}
|
|
978
|
+
}) : [], bt = I.map((e) => e.services).filter((e) => e !== void 0), V = k.mergeAll(g({
|
|
979
|
+
analyticsLayer: E.layer,
|
|
980
|
+
cacheService: Ne,
|
|
981
|
+
kvService: ze,
|
|
982
|
+
pluginServices: bt,
|
|
982
983
|
userLayers: _?.layers ?? []
|
|
983
|
-
}),
|
|
984
|
+
}), ne(_?.http ?? {})), St = _?.scheduling ?? {}, H = St.trigger ?? "self", Ct = /* @__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
|
+
]), U = St.coordination ?? (Ct.has(v) ? "advisoryLock" : "single"), W = U === "cluster" && Ct.has(v), G = W ? "cluster" : U === "advisoryLock" && Ct.has(v) ? "advisoryLock" : "single";
|
|
990
|
+
U === "cluster" && !W && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), U === "advisoryLock" && !Ct.has(v) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
|
|
991
|
+
let wt, Tt = w.workflows.length > 0 || w.workflowWorkers.length > 0 || w.eventTriggers.length > 0 || (_e?.outgoing.length ?? 0) > 0 || W, K;
|
|
992
|
+
if (Tt) {
|
|
993
|
+
if (v === "mssql") {
|
|
994
|
+
let e = await Te(process.cwd());
|
|
994
995
|
e && $.warn(e);
|
|
995
996
|
}
|
|
996
|
-
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer:
|
|
997
|
+
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: r, resolveRunnerStorage: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = W ? w.schedules.filter((e) => (e.trigger ?? H) === "self").map((e) => t({
|
|
997
998
|
name: e.name,
|
|
998
|
-
cron:
|
|
999
|
+
cron: Ve(e),
|
|
999
1000
|
execute: async () => {
|
|
1000
|
-
await
|
|
1001
|
+
await wt?.fireFromCluster(e.name);
|
|
1001
1002
|
}
|
|
1002
1003
|
})) : [];
|
|
1003
|
-
|
|
1004
|
-
let e = await
|
|
1005
|
-
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)" : "") : "")),
|
|
1006
|
-
sqlClientLayer: e.makeSqlLayer(
|
|
1004
|
+
K = v === "memory" ? e.layerMemory : await (async () => {
|
|
1005
|
+
let e = await n(v), t = i({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
|
|
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)" : "") : "")), r({
|
|
1007
|
+
sqlClientLayer: e.makeSqlLayer(x()),
|
|
1007
1008
|
runnerStorage: t,
|
|
1008
1009
|
dialectId: e.id,
|
|
1009
1010
|
...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
|
|
@@ -1011,98 +1012,98 @@ var nn = "/_voltro/admin/import", rn = "/_voltro/admin/export", Q = (e, t) => ({
|
|
|
1011
1012
|
});
|
|
1012
1013
|
})();
|
|
1013
1014
|
}
|
|
1014
|
-
let
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1015
|
+
let Et = pe(I, t()), Dt = S.filter((e) => /\.subscribe\.tsx?$/.test(e)), q = Dt.length > 0 ? await ae(Dt, $) : [], Ot = S.filter((e) => /\.reaction\.tsx?$/.test(e)), kt = Ot.length > 0 ? await ge(Ot, $) : [], J = S.filter((e) => s.test(e)), At = J.length > 0 ? await y(J, $) : [], jt = S.filter((e) => /\.aggregate\.tsx?$/.test(e)), Y = jt.length > 0 ? await te(jt, $) : [], X = ee();
|
|
1016
|
+
if (Y.length > 0 && v !== "memory") try {
|
|
1017
|
+
X = oe((await n(v)).makeSqlLayer(x()));
|
|
1017
1018
|
} catch (e) {
|
|
1018
1019
|
$.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
|
|
1019
1020
|
}
|
|
1020
|
-
let Mt =
|
|
1021
|
+
let Mt = v === "memory" ? ht : qe(M, `aggregate@${process.pid}`, $), Z = [], Nt = [], Pt = S.filter((e) => o.test(e));
|
|
1021
1022
|
if (Pt.length > 0) {
|
|
1022
|
-
let e = $.child("agent"), t =
|
|
1023
|
-
t.length > 0 && await
|
|
1024
|
-
let
|
|
1025
|
-
for (let e of
|
|
1023
|
+
let e = $.child("agent"), t = S.filter((e) => l.test(e));
|
|
1024
|
+
t.length > 0 && await c(t, e);
|
|
1025
|
+
let n = await a(Pt, e);
|
|
1026
|
+
for (let e of n.agents) for (let t of we(e)) (t.kind === "action" ? Z : Nt).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
|
m.mark("workflow");
|
|
1033
1034
|
let It = await yn({
|
|
1034
1035
|
bootTiming: m,
|
|
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:
|
|
1049
|
-
...
|
|
1037
|
+
queries: [...w.queries, ...Nt],
|
|
1038
|
+
mutations: w.mutations,
|
|
1039
|
+
actions: [...w.actions, ...Z],
|
|
1040
|
+
streams: w.streams,
|
|
1041
|
+
workflows: w.workflows,
|
|
1042
|
+
workflowWorkers: w.workflowWorkers,
|
|
1043
|
+
eventTriggers: w.eventTriggers,
|
|
1044
|
+
schedules: w.schedules,
|
|
1045
|
+
subscribers: q,
|
|
1046
|
+
outboxHandlers: At,
|
|
1047
|
+
connections: w.connections,
|
|
1048
|
+
reactions: kt,
|
|
1049
|
+
aggregates: Y,
|
|
1050
|
+
..._e === void 0 ? {} : { webhooks: _e }
|
|
1050
1051
|
},
|
|
1051
1052
|
log: $,
|
|
1052
|
-
analytics:
|
|
1053
|
-
aggregateStorage:
|
|
1053
|
+
analytics: E.sink,
|
|
1054
|
+
aggregateStorage: X,
|
|
1054
1055
|
aggregateCoordinator: Mt,
|
|
1055
|
-
store:
|
|
1056
|
-
kv:
|
|
1057
|
-
cache:
|
|
1058
|
-
snapshotCache:
|
|
1059
|
-
schemaRegistry:
|
|
1060
|
-
tenantScopedTables:
|
|
1061
|
-
softDeleteScopedTables:
|
|
1062
|
-
dataTransferSnapshot: Rt(
|
|
1063
|
-
dataTransferDialect:
|
|
1056
|
+
store: M,
|
|
1057
|
+
kv: F,
|
|
1058
|
+
cache: Le,
|
|
1059
|
+
snapshotCache: Fe,
|
|
1060
|
+
schemaRegistry: A,
|
|
1061
|
+
tenantScopedTables: w.tenantScopedTables,
|
|
1062
|
+
softDeleteScopedTables: w.softDeleteScopedTables,
|
|
1063
|
+
dataTransferSnapshot: Rt(D),
|
|
1064
|
+
dataTransferDialect: v,
|
|
1064
1065
|
tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? _?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
|
|
1065
|
-
resolveSubject: (e, t) =>
|
|
1066
|
+
resolveSubject: (e, t) => mt({
|
|
1066
1067
|
headers: e,
|
|
1067
1068
|
clientId: t
|
|
1068
1069
|
}),
|
|
1069
|
-
httpRoutes: [...
|
|
1070
|
-
...
|
|
1071
|
-
...
|
|
1072
|
-
scheduleDefaultTrigger:
|
|
1073
|
-
scheduleCoordination:
|
|
1074
|
-
scheduleArmSelf: !
|
|
1070
|
+
httpRoutes: [...I.flatMap((e) => e.httpRoutes ?? []), ...vt],
|
|
1071
|
+
...V ? { baseLayer: V } : {},
|
|
1072
|
+
...K === void 0 ? {} : { workflowEngineLayer: K },
|
|
1073
|
+
scheduleDefaultTrigger: H,
|
|
1074
|
+
scheduleCoordination: G,
|
|
1075
|
+
scheduleArmSelf: !W,
|
|
1075
1076
|
dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : _?.dormancy ?? "always-on",
|
|
1076
1077
|
scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
|
|
1077
|
-
...
|
|
1078
|
+
...Et === void 0 ? {} : { scheduleFireInterceptor: Et },
|
|
1078
1079
|
onSchedulerReady: (e) => {
|
|
1079
|
-
|
|
1080
|
+
wt = e;
|
|
1080
1081
|
},
|
|
1081
|
-
observability:
|
|
1082
|
-
port:
|
|
1082
|
+
observability: at,
|
|
1083
|
+
port: ie,
|
|
1083
1084
|
..._?.transport?.wsPath ? { path: _.transport.wsPath } : {}
|
|
1084
1085
|
});
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1086
|
+
re(ce([
|
|
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:
|
|
1093
|
+
}), $.info(`API listening on :${ie}`, {
|
|
1094
|
+
dialect: v,
|
|
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: G
|
|
1102
1103
|
}), m.finish($);
|
|
1103
1104
|
let Lt = () => {
|
|
1104
|
-
for (let e of
|
|
1105
|
-
|
|
1105
|
+
for (let e of et) e.stop();
|
|
1106
|
+
Be.detach(), Ge.stop(), Re(), R?.dispose(), setTimeout(() => process.exit(0), 1e4).unref?.(), Promise.resolve(rt.deactivate()).then(() => ot?.close()).then(() => E.dispose()).then(() => It.close()).then(() => M.close?.()).then(() => process.exit(0)).catch((e) => {
|
|
1106
1107
|
console.error("serve: shutdown step failed, exiting anyway:", e), process.exit(0);
|
|
1107
1108
|
});
|
|
1108
1109
|
};
|