@voltro/cli 0.17.0 → 0.18.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 +268 -0
- package/bin/voltro.mjs +6 -1
- package/dist/{apiBuild-ChdlLqGv.js → apiBuild-CPDTJHkH.js} +2 -2
- package/dist/apiBuild-D1UBJ4TM.js +2 -0
- package/dist/bin.js +2 -2
- package/dist/{commands-DYQbv-DG.js → commands-laJDMj2m.js} +1899 -1700
- package/dist/{dev-DB7pbLob.js → dev-BOFxC21E.js} +993 -930
- package/dist/{dev-BCmoJfBm.js → dev-DOK0w6ZW.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{inspectMetrics-DWh56Qas.js → inspectMetrics-D1DmLeJs.js} +507 -494
- package/dist/{serveCommand-DO6qr5Ok.js → serveCommand-CxcxHc9Y.js} +320 -320
- package/dist/serveEntry.js +2 -2
- package/dist/{start-ksY0wMZG.js → start-Clvz4IJb.js} +1 -1
- package/dist/startEntry.js +2 -2
- package/package.json +17 -17
- package/templates/AGENTS.core.md +38 -0
- package/templates/AGENTS.md +39 -1
- package/templates/agent-docs/_index.md +1 -1
- package/templates/agent-docs/authentication.md +48 -0
- package/templates/agent-docs/cli.md +9 -5
- package/templates/agent-docs/database/querying.md +6 -2
- package/templates/agent-docs/introduction.md +15 -1
- package/templates/agent-docs/routing.md +2 -0
- package/templates/agent-docs/schema-driven-ui.md +6 -3
- package/templates/agent-docs/whats-new.md +199 -30
- 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 +9 -9
- 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-D5WB119b.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as e, A as t, B as n, C as r, E as i, G as a, H as o, K as s, O as c, U as l, W as u, Z as d, at as f, ft as p, ht as m, it as h, j as g, l as _, q as ee, st as te, t as ne, w as re } from "./inspectMetrics-
|
|
1
|
+
import { $ as e, A as t, B as n, C as r, E as i, G as a, H as o, K as s, O as c, U as l, W as u, Z as d, at as f, ft as p, ht as m, it as h, j as g, l as _, q as ee, st as te, t as ne, w as re } from "./inspectMetrics-D1DmLeJs.js";
|
|
2
2
|
import { i as ie, n as ae, o as v, r as oe, s as y } from "./seedRunner-D6eu-u5U.js";
|
|
3
3
|
import { n as b } from "./appModuleLoader-C9r9mxZt.js";
|
|
4
4
|
import { r as se } from "./devActivity-BhIu6ncs.js";
|
|
@@ -14,34 +14,35 @@ import { FetchHttpClient as ft } from "@effect/platform";
|
|
|
14
14
|
import { Cause as pt, Cron as mt, Deferred as M, Duration as ht, Effect as N, Fiber as gt, Layer as P, ManagedRuntime as _t, Option as vt, Ref as yt, Schema as bt, Stream as xt } from "effect";
|
|
15
15
|
import { createLogger as F, printAppSurface as St, printReadyBlock as Ct } from "@voltro/logger";
|
|
16
16
|
import { appendFileSync as wt, chownSync as I, existsSync as L, promises as R, readFileSync as Tt, readdirSync as Et, statSync as Dt, writeFileSync as Ot } from "node:fs";
|
|
17
|
-
import { AggregateError as kt, AggregateMaintainer as At, AggregateNotFound as jt, AggregateRegistry as Mt, AggregateStale as Nt, AnalyticsSink as z, DORMANCY_WAKEUP_TENANT as Pt, Dispatcher as Ft, InMemoryDataStore as It, ReactionRateLimiter as Lt, ReplicatedDataStore as Rt, SYSTEM_SUBJECT as zt, apiKeyManagementRoutes as Bt, applySoftDeleteScope as Vt, applyTenantScope as Ht, applyUndoInvocation as Ut, assertConnectionCipherConfigured as Wt, attachAnalyticsMirror as Gt, awaitServerListening as Kt, bindMutation as qt, bindStream as Jt, bindSubscription as Yt, buildTracingLayer as Xt, cancelWakeup as Zt, compileCron as Qt, completeOAuthConnect as $t, dataStoreApiKeyStore as en, dataStoreIdempotencyStore as tn, drainOutbox as nn, enableGraphObservation as rn, extractDbCause as an, formatServerOnlyLeaks as on, frameworkApiKeyStrategy as sn, getConnectionSubject as cn, getTimelineRecorder as ln, installPolicyGuardResolver as un, isAggregateDefinition as dn, isEmptyTenantScopedRead as fn, isOrglessUserSubject as pn, isScheduleDefinition as mn, isWorkflowEventTriggerDefinition as hn, listRetentions as gn, loadResourceTuples as _n, localityAwareSelector as vn, makeActionRunner as yn, makeAdvisoryLockCoordinator as bn, makeApiKeyService as xn, makeApiKeyUsageBuffer as Sn, makeApiKeyUsageFlusher as Cn, makeAppAccess as wn, makeAsyncKv as Tn, makeBufferingSpanProcessor as En, makeConnectionRegistry as Dn, makeConnectionResolver as On, makeConnectionsFacade as kn, makeCoordinatedScheduler as An, makeDataLoader as jn, makeDisconnectConnectionExecutor as Mn, makeEffectStoreLayer as Nn, makeEventsFacade as Pn, makeLazyWorkflowFacade as Fn, makeListConnectionsExecutor as In, makeMutationRunner as Ln, makeOneShotQueryRunner as Rn, makeOutboxFacade as zn, makePostCommitWorkflowFacade as Bn, makeQueryDescriptorProducer as Vn, makeQueryReauthorizer as Hn, makeQuerySubscriber as Un, makeSchemaRegistry as Wn, makeStartConnectionExecutor as Gn, makeSubmitTokenExecutor as Kn, makeUndoCapture as qn, makeWorkflowFacade as Jn, makeWorkflowFacadeWithCallerContext as Yn, makeWorkflowLayers as Xn, memoryRywPositionStore as Zn, nextFiring as Qn, noopAnalytics as B, noopAnalyticsSpec as $n, observedGraph as er, powerOfTwoSelector as tr, recordSubscriptionDelivery as nr, recordTimelineEvent as rr, redisRywPositionStore as ir, redoUndoInvocation as ar, registerRetention as or, registerWakeup as sr, resolveCurrentRegion as cr, resolveSecretsBackend as lr, retentionTtlMsFromEnv as ur, runProvidedEffect as dr, runReaction as fr, sanitizeRedirectTo as pr, serverOnlyLeaks as mr, setConnectionResolver as hr, setSecretsBackend as gr, setSystemStoreHandle as _r, setTupleSource as vr, singleCoordinator as yr, ssrfGuardHttpClientLayer as br, startRpcServer as xr, startScheduler as Sr, sweepRetention as Cr, tracingHttpClientLayer as wr, undoCaptureEnabled as Tr, undoLogExecutor as Er,
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
17
|
+
import { AggregateError as kt, AggregateMaintainer as At, AggregateNotFound as jt, AggregateRegistry as Mt, AggregateStale as Nt, AnalyticsSink as z, DORMANCY_WAKEUP_TENANT as Pt, Dispatcher as Ft, InMemoryDataStore as It, ReactionRateLimiter as Lt, ReplicatedDataStore as Rt, SYSTEM_SUBJECT as zt, apiKeyManagementRoutes as Bt, applySoftDeleteScope as Vt, applyTenantScope as Ht, applyUndoInvocation as Ut, assertConnectionCipherConfigured as Wt, attachAnalyticsMirror as Gt, awaitServerListening as Kt, bindMutation as qt, bindStream as Jt, bindSubscription as Yt, buildTracingLayer as Xt, cancelWakeup as Zt, compileCron as Qt, completeOAuthConnect as $t, dataStoreApiKeyStore as en, dataStoreIdempotencyStore as tn, drainOutbox as nn, enableGraphObservation as rn, extractDbCause as an, formatServerOnlyLeaks as on, frameworkApiKeyStrategy as sn, getConnectionSubject as cn, getTimelineRecorder as ln, installPolicyGuardResolver as un, isAggregateDefinition as dn, isEmptyTenantScopedRead as fn, isOrglessUserSubject as pn, isScheduleDefinition as mn, isWorkflowEventTriggerDefinition as hn, listRetentions as gn, loadResourceTuples as _n, localityAwareSelector as vn, makeActionRunner as yn, makeAdvisoryLockCoordinator as bn, makeApiKeyService as xn, makeApiKeyUsageBuffer as Sn, makeApiKeyUsageFlusher as Cn, makeAppAccess as wn, makeAsyncKv as Tn, makeBufferingSpanProcessor as En, makeConnectionRegistry as Dn, makeConnectionResolver as On, makeConnectionsFacade as kn, makeCoordinatedScheduler as An, makeDataLoader as jn, makeDisconnectConnectionExecutor as Mn, makeEffectStoreLayer as Nn, makeEventsFacade as Pn, makeLazyWorkflowFacade as Fn, makeListConnectionsExecutor as In, makeMutationRunner as Ln, makeOneShotQueryRunner as Rn, makeOutboxFacade as zn, makePostCommitWorkflowFacade as Bn, makeQueryDescriptorProducer as Vn, makeQueryReauthorizer as Hn, makeQuerySubscriber as Un, makeSchemaRegistry as Wn, makeStartConnectionExecutor as Gn, makeSubmitTokenExecutor as Kn, makeUndoCapture as qn, makeWorkflowFacade as Jn, makeWorkflowFacadeWithCallerContext as Yn, makeWorkflowLayers as Xn, memoryRywPositionStore as Zn, nextFiring as Qn, noopAnalytics as B, noopAnalyticsSpec as $n, observedGraph as er, powerOfTwoSelector as tr, recordSubscriptionDelivery as nr, recordTimelineEvent as rr, redisRywPositionStore as ir, redoUndoInvocation as ar, registerRetention as or, registerWakeup as sr, resolveCurrentRegion as cr, resolveSecretsBackend as lr, retentionTtlMsFromEnv as ur, runProvidedEffect as dr, runReaction as fr, sanitizeRedirectTo as pr, serverOnlyLeaks as mr, setConnectionResolver as hr, setSecretsBackend as gr, setSystemStoreHandle as _r, setTupleSource as vr, singleCoordinator as yr, ssrfGuardHttpClientLayer as br, startRpcServer as xr, startScheduler as Sr, sweepRetention as Cr, tracingHttpClientLayer as wr, undoCaptureEnabled as Tr, undoLogExecutor as Er, wrapStoreWithBootCodec as Dr, wrapStoreWithMixinBehaviour as Or } from "@voltro/runtime";
|
|
18
|
+
import { createRequire as kr } from "node:module";
|
|
19
|
+
import { Rpc as Ar, RpcGroup as jr } from "@effect/rpc";
|
|
20
|
+
import { SqlClient as Mr } from "@effect/sql";
|
|
21
|
+
import { WorkflowEngine as Nr } from "@effect/workflow";
|
|
22
|
+
import { WorkflowStepInterceptorTag as Pr, closeWorkflowChildrenForParent as Fr, completeSuspendingSignal as Ir, getWorkflowVersionMetadata as Lr, isWorkflowWorkerLayer as Rr, makeWorkflowRunRecorder as zr, sendWorkflowSignal as Br, sendWorkflowUpdate as Vr, serialiseWorkflowRowForWire as Hr, wrapWorkflowExecuteWithRunRecording as Ur } from "@voltro/workflow";
|
|
23
|
+
import { makeClusterCronLayer as Wr, parseShardLockMode as Gr, resolveRunnerIdentity as Kr, resolveRunnerStorage as qr, workflowEngineLayer as Jr } from "@voltro/workflow/cluster";
|
|
24
|
+
import { loadAgentMessages as Yr, runAgentTurn as Xr } from "@voltro/ai";
|
|
25
|
+
import { actorsTable as Zr, allRegisteredTables as Qr, and as $r, auditAllTableIndexes as ei, drainIdentifierWarnings as ti, ensureTableRegistered as ni, eq as V, formatIndexAuditIssue as ri, isSqliteFamily as ii, lt as ai, or as oi, registerCoreTables as si, registerDiscoveredRelations as ci, resolveTenantNamespace as li, serverOnlyColumns as ui, validateRegisteredRelations as di, walkLeaves as fi } from "@voltro/database";
|
|
26
|
+
import { AuthMiddleware as pi, ConnectionInfoMiddleware as mi, Unauthenticated as hi, WorkflowRunHandleSchema as gi, actionToRpc as _i, advisoryResourceGuardWarning as vi, anonymousSubject as yi, checkFrameworkCompat as bi, composeAuthStrategies as xi, composeRpcInterceptors as Si, connectionDisconnectDescriptor as Ci, connectionStartDescriptor as wi, connectionSubmitTokenDescriptor as Ti, connectionsListQueryDescriptor as Ei, findAdvisoryResourceGuards as Di, mutationToRpc as Oi, publishServerError as ki, queryToRpc as Ai, streamToRpc as ji, tenantScopedSubject as Mi, undoApplyDescriptor as Ni, undoLogQueryDescriptor as Pi, undoRedoDescriptor as Fi, workflowCancelDescriptor as Ii, workflowDomainEventsQueryDescriptor as Li, workflowEventDeliveriesQueryDescriptor as Ri, workflowResumeDescriptor as zi, workflowRunEventsQueryDescriptor as Bi, workflowRunQueryDescriptor as Vi, workflowRunStepsQueryDescriptor as Hi, workflowRunsQueryDescriptor as Ui, workflowSignalDescriptor as Wi, workflowUpdateDescriptor as Gi } from "@voltro/protocol";
|
|
27
|
+
import { isEnvContract as Ki } from "@voltro/env";
|
|
28
|
+
import { readCookie as qi, resolveOptionalSessionSecrets as Ji, verifySessionKeyed as Yi } from "@voltro/protocol/session";
|
|
29
|
+
import { createHash as Xi, randomBytes as Zi } from "node:crypto";
|
|
30
|
+
import { declaredSnapshot as Qi, describeOutcome as $i, fingerprintSchema as ea, introspectSchema as ta, pendingFileMigrationIds as na, planMigrations as ra, runFileBasedMigrations as ia, runFrameworkBootstrap as aa, runPlannedMigrations as oa } from "@voltro/database/sql";
|
|
31
|
+
import { Cache as sa, CacheLayer as H, InvalidationBus as ca } from "@voltro/cache";
|
|
32
|
+
import { Kv as la } from "@voltro/kv";
|
|
33
|
+
import { getAuthSessionStrategy as ua } from "@voltro/plugin-auth";
|
|
34
|
+
import { collectPublicApiRoutes as da, restRoutesToHttpRoutes as fa } from "@voltro/protocol/rest";
|
|
35
|
+
import { spawn as pa } from "node:child_process";
|
|
36
|
+
import { watch as ma } from "chokidar";
|
|
37
|
+
import { agentRouteDescriptors as ha, isAgentDescriptor as ga } from "@voltro/ai/agent";
|
|
38
|
+
import { ArrayFormatter as _a } from "effect/ParseResult";
|
|
39
|
+
import { buildDeliverWebhookExecute as va, buildWebhooksService as ya, defaultIncomingPath as ba, deliverWebhookWorkflow as xa, isWebhookDescriptor as Sa, mountIncomingWebhook as Ca } from "@voltro/plugin-webhooks";
|
|
40
|
+
import { isEmailTemplate as wa, registerEmailTemplates as Ta } from "@voltro/plugin-mail";
|
|
41
|
+
import { attachBroadcastBus as Ea, getBroadcastPlugin as Da } from "@voltro/plugin-broadcast";
|
|
42
|
+
import { runImport as Oa } from "@voltro/data-transfer";
|
|
43
|
+
import { createServer as ka } from "node:http";
|
|
43
44
|
//#region src/envSecretMint.ts
|
|
44
|
-
var
|
|
45
|
+
var U = (e, t) => {
|
|
45
46
|
if (typeof process.getuid != "function") return;
|
|
46
47
|
let n;
|
|
47
48
|
try {
|
|
@@ -56,7 +57,7 @@ var Da = (e, t) => {
|
|
|
56
57
|
} catch (t) {
|
|
57
58
|
return `${e} was written as uid ${r} but the workspace is owned by uid ${n.uid}, and it could not be handed over (${t.message}). The file is mode 0600, so tools running as uid ${n.uid} — your tests, your editor, \`voltro doctor\` — will fail to read it with EACCES. Run this container as the workspace owner (docker \`--user ${n.uid}:${n.gid}\`), or set the variable(s) yourself so nothing needs minting.`;
|
|
58
59
|
}
|
|
59
|
-
}, W = ".env.local",
|
|
60
|
+
}, W = ".env.local", Aa = (e) => {
|
|
60
61
|
let t = O(e, ".gitignore"), n = "";
|
|
61
62
|
try {
|
|
62
63
|
L(t) && (n = Tt(t, "utf8"));
|
|
@@ -69,17 +70,17 @@ var Da = (e, t) => {
|
|
|
69
70
|
} catch {
|
|
70
71
|
return !1;
|
|
71
72
|
}
|
|
72
|
-
},
|
|
73
|
+
}, G = (e) => Zi(32).toString(e), ja = [{
|
|
73
74
|
key: "VOLTRO_INSPECT_TOKEN",
|
|
74
75
|
encoding: "base64url",
|
|
75
76
|
description: "Bearer token for /_voltro/inspect/* — minted so the dev inspect surface is not open to the network."
|
|
76
|
-
}],
|
|
77
|
+
}], Ma = (e, t, n = process.env) => {
|
|
77
78
|
let r = [];
|
|
78
|
-
for (let e of
|
|
79
|
+
for (let e of ja) {
|
|
79
80
|
let t = n[e.key];
|
|
80
81
|
t !== void 0 && t.trim() !== "" || r.push({
|
|
81
82
|
key: e.key,
|
|
82
|
-
value:
|
|
83
|
+
value: G(e.encoding),
|
|
83
84
|
description: e.description
|
|
84
85
|
});
|
|
85
86
|
}
|
|
@@ -88,12 +89,12 @@ var Da = (e, t) => {
|
|
|
88
89
|
let e = n[t];
|
|
89
90
|
e !== void 0 && e.trim() !== "" || r.push({
|
|
90
91
|
key: t,
|
|
91
|
-
value:
|
|
92
|
+
value: G(i.generate),
|
|
92
93
|
description: i.description
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
96
|
if (r.length === 0) return { minted: [] };
|
|
96
|
-
if (!
|
|
97
|
+
if (!Aa(t)) throw Error(`cannot mint ${r.map((e) => e.key).join(", ")}: failed to add "${W}" to ${O(t, ".gitignore")}. Refusing to write a secret to a path that might be committed — add the entry by hand, or set the variable(s) yourself (\`voltro secret generate\`).`);
|
|
97
98
|
let i = O(t, W), a = r.map((e) => `${e.description ? `# ${e.description}\n` : ""}${e.key}=${e.value}`).join("\n"), o;
|
|
98
99
|
try {
|
|
99
100
|
if (L(i)) {
|
|
@@ -105,7 +106,7 @@ var Da = (e, t) => {
|
|
|
105
106
|
\n${a}\n`, {
|
|
106
107
|
encoding: "utf8",
|
|
107
108
|
mode: 384
|
|
108
|
-
}), o =
|
|
109
|
+
}), o = U(i, t);
|
|
109
110
|
} catch (e) {
|
|
110
111
|
throw Error(`cannot mint ${r.map((e) => e.key).join(", ")}: failed to write ${i} — ${e.message}`);
|
|
111
112
|
}
|
|
@@ -115,7 +116,7 @@ var Da = (e, t) => {
|
|
|
115
116
|
file: i,
|
|
116
117
|
...o ? { ownershipWarning: o } : {}
|
|
117
118
|
};
|
|
118
|
-
},
|
|
119
|
+
}, Na = [".framework", ".env.local"], Pa = /\.generated\./i, Fa = (e) => {
|
|
119
120
|
try {
|
|
120
121
|
let t = Dt(e);
|
|
121
122
|
return {
|
|
@@ -125,7 +126,7 @@ var Da = (e, t) => {
|
|
|
125
126
|
} catch {
|
|
126
127
|
return;
|
|
127
128
|
}
|
|
128
|
-
},
|
|
129
|
+
}, Ia = (e, t, n) => {
|
|
129
130
|
let r = !0;
|
|
130
131
|
try {
|
|
131
132
|
I(e, t, n);
|
|
@@ -139,44 +140,44 @@ var Da = (e, t) => {
|
|
|
139
140
|
} catch {
|
|
140
141
|
return r;
|
|
141
142
|
}
|
|
142
|
-
for (let a of i)
|
|
143
|
+
for (let a of i) Ia(O(e, a), t, n) || (r = !1);
|
|
143
144
|
return r;
|
|
144
|
-
},
|
|
145
|
+
}, La = (e) => {
|
|
145
146
|
if (typeof process.getuid != "function") return { adopted: [] };
|
|
146
|
-
let t =
|
|
147
|
+
let t = Fa(e);
|
|
147
148
|
if (t === void 0) return { adopted: [] };
|
|
148
149
|
let n = process.getuid();
|
|
149
150
|
if (t.uid === n) return { adopted: [] };
|
|
150
|
-
let r = [...
|
|
151
|
+
let r = [...Na];
|
|
151
152
|
try {
|
|
152
|
-
for (let t of Et(e))
|
|
153
|
+
for (let t of Et(e)) Pa.test(t) && r.push(t);
|
|
153
154
|
} catch {}
|
|
154
155
|
let i = [], a = !1;
|
|
155
156
|
for (let n of r) {
|
|
156
157
|
let r = O(e, n);
|
|
157
|
-
|
|
158
|
+
Fa(r) !== void 0 && (Ia(r, t.uid, t.gid) ? i.push(n) : a = !0);
|
|
158
159
|
}
|
|
159
160
|
return a ? {
|
|
160
161
|
adopted: i,
|
|
161
162
|
warning: `generated files under ${e} are owned by uid ${n} but the workspace is owned by uid ${t.uid}, and they could not be handed over. On the host, tools running as uid ${t.uid} will fail with EACCES — \`voltro build\` cannot read \`.framework\`, and \`vitest\` cannot read \`.env.local\`. Run this container as the workspace owner (docker \`--user ${t.uid}:${t.gid}\`).`
|
|
162
163
|
} : { adopted: i };
|
|
163
|
-
},
|
|
164
|
-
if (e.dialect === "turso" &&
|
|
164
|
+
}, Ra = (e) => e.startsWith("_voltro_"), za = (e) => e === void 0 || e === "" || !/^file:/i.test(e) || (process.env.TURSO_SYNC_URL ?? "") !== "", Ba = (e) => {
|
|
165
|
+
if (e.dialect === "turso" && za(e.dbUrl)) return [{
|
|
165
166
|
level: "warn",
|
|
166
167
|
message: "turso is configured against a shared primary, but this dialect has no NATIVE cross-instance change capture: it reuses the SQLite store, which emits inline only. Subscribers see writes made by THEIR OWN instance and never another's — for every table, regardless of .nonReactive(). Add @voltro/plugin-broadcast (Redis / NATS) to fan changes out between instances, or run a single instance."
|
|
167
168
|
}];
|
|
168
169
|
if (e.changeStrategy !== "cdc" || e.dialect === "sqlite" || e.dialect === "turso") return [];
|
|
169
|
-
let t = new Set(e.querySources.filter((e) => !
|
|
170
|
+
let t = new Set(e.querySources.filter((e) => !Ra(e))), n = e.tables.filter((e) => !Ra(e.tableName)).filter((e) => e.isReactive === !1 && t.has(e.tableName)).map((e) => e.tableName).sort();
|
|
170
171
|
if (n.length === 0) return [];
|
|
171
172
|
let r = n.slice(0, 8).join(", "), i = n.length > 8 ? `, … (+${n.length - 8})` : "";
|
|
172
173
|
return [{
|
|
173
174
|
level: "warn",
|
|
174
175
|
message: `${n.length} table(s) are .nonReactive() but a query declares them as a source — ${r}${i}. Those subscriptions will NEVER fire: a non-reactive table emits no change events at all, in this process or any other, so the query returns its first snapshot and then goes quiet forever. Either drop .nonReactive() from the table, or stop subscribing to it.`
|
|
175
176
|
}];
|
|
176
|
-
},
|
|
177
|
+
}, Va = "VOLTRO_REMOTE_MIGRATIONS_OK", K = /^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/, Ha = (e) => {
|
|
177
178
|
let t = e.toLowerCase().replace(/^\[|\]$/g, "");
|
|
178
|
-
return !!(t === "" || t === "localhost" || t === "ip6-localhost" || t === "::1" || t === "0.0.0.0" || t === "::" || t.startsWith("127.") || t === "host.docker.internal" || t === "gateway.docker.internal" || t.endsWith(".localhost") || t.endsWith(".local") ||
|
|
179
|
-
},
|
|
179
|
+
return !!(t === "" || t === "localhost" || t === "ip6-localhost" || t === "::1" || t === "0.0.0.0" || t === "::" || t.startsWith("127.") || t === "host.docker.internal" || t === "gateway.docker.internal" || t.endsWith(".localhost") || t.endsWith(".local") || K.test(t) || !t.includes(".") && !t.includes(":"));
|
|
180
|
+
}, Ua = (e) => {
|
|
180
181
|
if (e.url !== void 0 && e.url !== "") {
|
|
181
182
|
if (/^(file|sqlite):/i.test(e.url)) return {
|
|
182
183
|
kind: "local",
|
|
@@ -185,7 +186,7 @@ var Da = (e, t) => {
|
|
|
185
186
|
try {
|
|
186
187
|
let t = new URL(e.url).hostname;
|
|
187
188
|
return {
|
|
188
|
-
kind:
|
|
189
|
+
kind: Ha(t) ? "local" : "remote",
|
|
189
190
|
host: t
|
|
190
191
|
};
|
|
191
192
|
} catch {
|
|
@@ -197,12 +198,12 @@ var Da = (e, t) => {
|
|
|
197
198
|
}
|
|
198
199
|
let t = e.host ?? "localhost";
|
|
199
200
|
return {
|
|
200
|
-
kind:
|
|
201
|
+
kind: Ha(t) ? "local" : "remote",
|
|
201
202
|
host: t
|
|
202
203
|
};
|
|
203
|
-
},
|
|
204
|
+
}, Wa = (e) => {
|
|
204
205
|
if (e.pendingIds.length === 0 || e.optIn) return { allowed: !0 };
|
|
205
|
-
let t =
|
|
206
|
+
let t = Ua(e.conn);
|
|
206
207
|
if (t.kind === "local") return { allowed: !0 };
|
|
207
208
|
let n = e.pendingIds.map((e) => ` • ${e}`).join("\n");
|
|
208
209
|
return {
|
|
@@ -221,11 +222,11 @@ var Da = (e, t) => {
|
|
|
221
222
|
" Choose one:",
|
|
222
223
|
" • Point the app at a local database (DB_URL), which is what dev boot assumes.",
|
|
223
224
|
" • Apply them deliberately, once: voltro db files .",
|
|
224
|
-
` • Accept it for this environment: ${
|
|
225
|
+
` • Accept it for this environment: ${Va}=1`
|
|
225
226
|
].join("\n")
|
|
226
227
|
};
|
|
227
|
-
},
|
|
228
|
-
let t = _t.make(P.mergeAll(
|
|
228
|
+
}, Ga = async ({ env: e = process.env } = {}) => {
|
|
229
|
+
let t = _t.make(P.mergeAll(H.layer, ca.Default)), n = await t.runPromise(sa), r = await t.runPromise(ca), i = (e.CACHE_BACKEND ?? "memory").toLowerCase();
|
|
229
230
|
return await t.runPromise(r.addSink((e) => n.invalidateTag(e))), {
|
|
230
231
|
service: n,
|
|
231
232
|
invalidationBus: r,
|
|
@@ -257,7 +258,7 @@ var Da = (e, t) => {
|
|
|
257
258
|
stats: () => t.runSync(n.stats()),
|
|
258
259
|
dispose: () => t.dispose()
|
|
259
260
|
};
|
|
260
|
-
},
|
|
261
|
+
}, Ka = ({ store: e, dialect: t, env: n = process.env }) => {
|
|
261
262
|
if (t !== "postgres") return { stop: () => {} };
|
|
262
263
|
or({
|
|
263
264
|
table: "_voltro_schedule_runs",
|
|
@@ -267,7 +268,7 @@ var Da = (e, t) => {
|
|
|
267
268
|
table: "_voltro_workflow_runs",
|
|
268
269
|
timeColumn: "completedAt",
|
|
269
270
|
ttlMs: ur(n.VOLTRO_WORKFLOW_RUNS_TTL_HOURS, 720),
|
|
270
|
-
where:
|
|
271
|
+
where: oi(V("status", "succeeded"), V("status", "failed"), V("status", "cancelled"))
|
|
271
272
|
}), or({
|
|
272
273
|
table: "_voltro_outbox_attempts",
|
|
273
274
|
timeColumn: "startedAt",
|
|
@@ -276,7 +277,7 @@ var Da = (e, t) => {
|
|
|
276
277
|
table: "_voltro_outbox",
|
|
277
278
|
timeColumn: "deliveredAt",
|
|
278
279
|
ttlMs: ur(n.VOLTRO_OUTBOX_TTL_HOURS, 720),
|
|
279
|
-
where:
|
|
280
|
+
where: V("status", "delivered")
|
|
280
281
|
});
|
|
281
282
|
let r = e.raw?.bind(e), i = (e) => {
|
|
282
283
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)) throw Error(`retention: unsafe identifier "${e}"`);
|
|
@@ -291,7 +292,7 @@ var Da = (e, t) => {
|
|
|
291
292
|
};
|
|
292
293
|
return (await r(e)).length;
|
|
293
294
|
}
|
|
294
|
-
let d =
|
|
295
|
+
let d = ai(l, a), f = s === void 0 ? d : $r(d, s), p = await e.query({
|
|
295
296
|
table: c,
|
|
296
297
|
order: [],
|
|
297
298
|
predicate: f,
|
|
@@ -312,14 +313,14 @@ var Da = (e, t) => {
|
|
|
312
313
|
o();
|
|
313
314
|
}, 5 * 6e4);
|
|
314
315
|
return s.unref?.(), { stop: () => clearInterval(s) };
|
|
315
|
-
},
|
|
316
|
+
}, qa = (e) => {
|
|
316
317
|
let t = jn({ store: e.store });
|
|
317
318
|
return {
|
|
318
|
-
storeForTenant: (t) =>
|
|
319
|
-
subject:
|
|
319
|
+
storeForTenant: (t) => Or(e.store, {
|
|
320
|
+
subject: Mi(zt, t),
|
|
320
321
|
schemaRegistry: e.schemaRegistry
|
|
321
322
|
}),
|
|
322
|
-
store:
|
|
323
|
+
store: Or(e.store, {
|
|
323
324
|
subject: zt,
|
|
324
325
|
schemaRegistry: e.schemaRegistry
|
|
325
326
|
}),
|
|
@@ -333,11 +334,11 @@ var Da = (e, t) => {
|
|
|
333
334
|
cache: e.cache,
|
|
334
335
|
kv: e.kv
|
|
335
336
|
};
|
|
336
|
-
},
|
|
337
|
+
}, Ja = (e) => {
|
|
337
338
|
let { store: t, schemaRegistry: n, cache: r, kv: i, webhooksService: a, workflowsProxy: o, eventTriggers: s, namespaceIsolationOn: c, onEventEmit: l, outbox: u, connections: d } = e, f = (e, t) => {
|
|
338
339
|
if (!c) return e;
|
|
339
340
|
if (e.withNamespace === void 0) throw Error("tenantIsolation=namespace is set but the active store has no physical-namespace support (withNamespace).");
|
|
340
|
-
return e.withNamespace(
|
|
341
|
+
return e.withNamespace(li(t.tenantId));
|
|
341
342
|
};
|
|
342
343
|
return (e, c = t, p, m = "app-context", h) => {
|
|
343
344
|
let g = f(c, e.subject), _ = o === void 0 ? void 0 : Yn(o, {
|
|
@@ -371,14 +372,14 @@ var Da = (e, t) => {
|
|
|
371
372
|
}), re = jn({ store: g }), ie = e.rowFilter === void 0 ? {} : { rowFilter: e.rowFilter };
|
|
372
373
|
return {
|
|
373
374
|
storeForTenant: (t) => {
|
|
374
|
-
let r =
|
|
375
|
-
return
|
|
375
|
+
let r = Mi(e.subject, t);
|
|
376
|
+
return Or(f(c, r), {
|
|
376
377
|
subject: r,
|
|
377
378
|
schemaRegistry: n,
|
|
378
379
|
...ie
|
|
379
380
|
});
|
|
380
381
|
},
|
|
381
|
-
store:
|
|
382
|
+
store: Or(g, {
|
|
382
383
|
subject: e.subject,
|
|
383
384
|
schemaRegistry: n,
|
|
384
385
|
...e.rowFilter === void 0 ? {} : { rowFilter: e.rowFilter }
|
|
@@ -396,9 +397,9 @@ var Da = (e, t) => {
|
|
|
396
397
|
..._ === void 0 ? {} : { workflows: p ? Bn(_, p.afterCommit) : _ }
|
|
397
398
|
};
|
|
398
399
|
};
|
|
399
|
-
},
|
|
400
|
-
if (t.type === "anonymous" || t.id == null) throw new
|
|
401
|
-
let r = "id" in n ?
|
|
400
|
+
}, Ya = async (e, t, n) => {
|
|
401
|
+
if (t.type === "anonymous" || t.id == null) throw new hi({ reason: "workflow control requires an authenticated subject" });
|
|
402
|
+
let r = "id" in n ? V("id", n.id) : V("executionId", n.executionId), i = (await e.query({
|
|
402
403
|
table: "_voltro_workflow_runs",
|
|
403
404
|
order: [],
|
|
404
405
|
predicate: r,
|
|
@@ -406,9 +407,9 @@ var Da = (e, t) => {
|
|
|
406
407
|
skip: void 0,
|
|
407
408
|
take: 1
|
|
408
409
|
}))[0], a = i?.subject?.tenantId ?? null, o = t.tenantId ?? null;
|
|
409
|
-
if (i === void 0 || a !== o) throw new
|
|
410
|
-
},
|
|
411
|
-
let t = P.succeed(
|
|
410
|
+
if (i === void 0 || a !== o) throw new hi({ reason: "not authorized for this workflow run" });
|
|
411
|
+
}, Xa = (e = {}) => wr.pipe(P.provide(br(e)), P.provide(ft.layer), P.provide(P.succeed(ft.RequestInit, { redirect: "manual" }))), Za = (e) => {
|
|
412
|
+
let t = P.succeed(sa, e.cacheService), n = P.succeed(la, e.kvService), r = [
|
|
412
413
|
e.analyticsLayer,
|
|
413
414
|
t,
|
|
414
415
|
n,
|
|
@@ -416,57 +417,101 @@ var Da = (e, t) => {
|
|
|
416
417
|
...e.userLayers
|
|
417
418
|
];
|
|
418
419
|
return P.mergeAll(...r);
|
|
419
|
-
},
|
|
420
|
-
|
|
420
|
+
}, Qa = [
|
|
421
|
+
Vi,
|
|
422
|
+
Ui,
|
|
423
|
+
Hi,
|
|
421
424
|
Bi,
|
|
422
|
-
zi,
|
|
423
425
|
Li,
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
], Za = (e, t, n) => {
|
|
426
|
+
Ri
|
|
427
|
+
], $a = (e, t, n) => {
|
|
427
428
|
let r = new Set(t);
|
|
428
|
-
if (n) for (let e of
|
|
429
|
+
if (n) for (let e of Qa) r.add(e.name);
|
|
429
430
|
let i = {};
|
|
430
431
|
for (let [t, n] of Object.entries(e)) i[t] = r.has(t) ? (e) => n(e).pipe(xt.take(1)) : n;
|
|
431
432
|
return i;
|
|
432
|
-
},
|
|
433
|
+
}, eo = "VOLTRO_TSX_IMPORT", to = /^--(?:import|loader|experimental-loader|require)(?:=|$)/, no = (e) => /(?:^|[/\\])tsx(?:$|[/\\])/.test(e), ro = (e) => e.some((t, n) => {
|
|
434
|
+
if (!to.test(t)) return !1;
|
|
435
|
+
let r = t.indexOf("=");
|
|
436
|
+
return no(r === -1 ? e[n + 1] ?? "" : t.slice(r + 1));
|
|
437
|
+
}), io = () => {
|
|
438
|
+
try {
|
|
439
|
+
return import.meta.resolve("tsx");
|
|
440
|
+
} catch {
|
|
441
|
+
try {
|
|
442
|
+
return j(kr(import.meta.url).resolve("tsx")).href;
|
|
443
|
+
} catch {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}, ao = (e = {}) => {
|
|
448
|
+
let t = e.env ?? process.env, n = e.execArgv ?? process.execArgv;
|
|
449
|
+
if (ro(n)) return {
|
|
450
|
+
execArgv: [...n],
|
|
451
|
+
source: "inherited"
|
|
452
|
+
};
|
|
453
|
+
let r = t[eo];
|
|
454
|
+
if (r !== void 0 && r !== "") return {
|
|
455
|
+
execArgv: [
|
|
456
|
+
...n,
|
|
457
|
+
"--import",
|
|
458
|
+
r
|
|
459
|
+
],
|
|
460
|
+
source: "shim-env"
|
|
461
|
+
};
|
|
462
|
+
let i = (e.resolve ?? io)();
|
|
463
|
+
return i === void 0 ? {
|
|
464
|
+
execArgv: [
|
|
465
|
+
...n,
|
|
466
|
+
"--import",
|
|
467
|
+
"tsx"
|
|
468
|
+
],
|
|
469
|
+
source: "unresolved"
|
|
470
|
+
} : {
|
|
471
|
+
execArgv: [
|
|
472
|
+
...n,
|
|
473
|
+
"--import",
|
|
474
|
+
i
|
|
475
|
+
],
|
|
476
|
+
source: "resolved"
|
|
477
|
+
};
|
|
478
|
+
}, oo = (e) => e.source === "unresolved" ? "could not resolve the tsx loader from @voltro/cli — falling back to a bare `--import tsx`, which Node resolves against the working directory. If the child dies with \"Cannot find package 'tsx'\", reinstall @voltro/cli with its optional dependencies (a `--no-optional` install omits tsx, which `voltro dev` needs to load your `.ts` sources)." : void 0, q = F({ scope: "voltro:dev:supervisor" }), so = /\.generated\./, co = /\.([cm]?[jt]sx?|json)$/, lo = (e) => {
|
|
433
479
|
let t = E(e);
|
|
434
|
-
return
|
|
435
|
-
},
|
|
436
|
-
let n = A(e), r = (e) => k(n, e), i =
|
|
480
|
+
return !so.test(t) && co.test(t);
|
|
481
|
+
}, uo = (e) => e.startsWith("node_modules") || e.startsWith(".framework") || e.startsWith(".turbo") || e.startsWith(".vite") || e.startsWith("dist") || e.startsWith(".git"), J = process.env.WATCH_POLL === "1" || process.env.CHOKIDAR_USEPOLLING === "1", fo = 1e3, po = (e) => xt.async((t) => {
|
|
482
|
+
let n = A(e), r = (e) => k(n, e), i = ma(n, {
|
|
437
483
|
persistent: !0,
|
|
438
484
|
ignoreInitial: !0,
|
|
439
485
|
atomic: !0,
|
|
440
|
-
usePolling:
|
|
441
|
-
interval:
|
|
442
|
-
binaryInterval:
|
|
486
|
+
usePolling: J,
|
|
487
|
+
interval: fo,
|
|
488
|
+
binaryInterval: fo,
|
|
443
489
|
ignored: (e) => {
|
|
444
490
|
let t = r(e);
|
|
445
|
-
return t === "" ? !1 :
|
|
491
|
+
return t === "" ? !1 : uo(t) || so.test(E(e));
|
|
446
492
|
}
|
|
447
493
|
});
|
|
448
494
|
return i.on("all", (e, n) => {
|
|
449
495
|
let i = r(n);
|
|
450
|
-
process.env.WATCH_DEBUG === "1" &&
|
|
496
|
+
process.env.WATCH_DEBUG === "1" && q.trace("watcher fired", {
|
|
451
497
|
event: e,
|
|
452
498
|
file: i
|
|
453
|
-
}), !
|
|
499
|
+
}), !uo(i) && lo(i) && t.single({ file: i });
|
|
454
500
|
}), i.on("error", (e) => {
|
|
455
|
-
|
|
501
|
+
q.error("watcher error", { hint: J ? void 0 : "on a bind-mount (k8s hostPath / Docker volume) set WATCH_POLL=1" }, e);
|
|
456
502
|
}), N.sync(() => {
|
|
457
503
|
i.close();
|
|
458
504
|
});
|
|
459
|
-
}),
|
|
505
|
+
}), mo = (e) => N.async((t) => {
|
|
460
506
|
if (e.exitCode !== null) {
|
|
461
507
|
t(N.succeed(e.exitCode));
|
|
462
508
|
return;
|
|
463
509
|
}
|
|
464
510
|
e.once("exit", (e, n) => t(N.succeed(e ?? +!!n)));
|
|
465
|
-
}),
|
|
466
|
-
let t = process.argv[1] ?? "";
|
|
467
|
-
return
|
|
468
|
-
|
|
469
|
-
"tsx",
|
|
511
|
+
}), Y = (e) => N.acquireUseRelease(N.sync(() => {
|
|
512
|
+
let t = process.argv[1] ?? "", n = ao(), r = oo(n);
|
|
513
|
+
return r !== void 0 && q.warn(r), pa(process.execPath, [
|
|
514
|
+
...n.execArgv,
|
|
470
515
|
t,
|
|
471
516
|
"dev",
|
|
472
517
|
e
|
|
@@ -477,7 +522,7 @@ var Da = (e, t) => {
|
|
|
477
522
|
FRAMEWORK_DEV_INNER: "1"
|
|
478
523
|
}
|
|
479
524
|
});
|
|
480
|
-
}),
|
|
525
|
+
}), mo, (e) => N.async((t) => {
|
|
481
526
|
if (e.exitCode !== null || e.killed) {
|
|
482
527
|
t(N.void);
|
|
483
528
|
return;
|
|
@@ -489,20 +534,20 @@ var Da = (e, t) => {
|
|
|
489
534
|
e.once("exit", () => {
|
|
490
535
|
clearTimeout(n), t(N.void);
|
|
491
536
|
});
|
|
492
|
-
})),
|
|
493
|
-
|
|
537
|
+
})), ho = (e) => e.exitCode === 0 ? "stop" : e.keepAlive === "1" ? "wait-for-fix" : e.keepAlive === "0" ? "stop" : e.interactive ? "wait-for-fix" : "stop", go = (e) => N.gen(function* () {
|
|
538
|
+
q.info("supervisor active — watching project root", {
|
|
494
539
|
root: e.root,
|
|
495
540
|
patterns: ["**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs,json} (excl. *.generated.*)"],
|
|
496
|
-
watcher:
|
|
541
|
+
watcher: J ? "chokidar (polling)" : "chokidar (native)",
|
|
497
542
|
hint: "WATCH=0 disables, WATCH_DEBUG=1 traces every event, WATCH_POLL=1 for bind-mounts (k8s/Docker)"
|
|
498
543
|
});
|
|
499
544
|
let t = yield* yt.make(vt.none()), n = yield* M.make(), r = N.gen(function* () {
|
|
500
|
-
let r = yield* N.fork(
|
|
545
|
+
let r = yield* N.fork(Y(e.root).pipe(N.flatMap((e) => ho({
|
|
501
546
|
exitCode: e,
|
|
502
547
|
interactive: process.stdout.isTTY === !0,
|
|
503
548
|
keepAlive: process.env.VOLTRO_DEV_KEEP_ALIVE
|
|
504
549
|
}) === "stop" ? M.succeed(n, e) : N.sync(() => {
|
|
505
|
-
|
|
550
|
+
q.error("dev server crashed — waiting for a file change", {
|
|
506
551
|
exitCode: e,
|
|
507
552
|
hint: "fix the cause and save; Ctrl-C to stop. VOLTRO_DEV_KEEP_ALIVE=0 exits instead."
|
|
508
553
|
});
|
|
@@ -516,14 +561,14 @@ var Da = (e, t) => {
|
|
|
516
561
|
}), yield* yt.set(t, vt.none());
|
|
517
562
|
});
|
|
518
563
|
yield* r;
|
|
519
|
-
let a =
|
|
564
|
+
let a = po(e.root).pipe(xt.debounce(ht.millis(80)), xt.runForEach((e) => N.gen(function* () {
|
|
520
565
|
let t = Date.now();
|
|
521
|
-
|
|
566
|
+
q.info("file changed — restarting", { file: e.file }), yield* i, yield* r, q.info("restart complete", { ms: Date.now() - t });
|
|
522
567
|
})), N.andThen(N.never), N.as(0)), o = yield* N.raceFirst(a, M.await(n));
|
|
523
|
-
o === 0 ?
|
|
568
|
+
o === 0 ? q.info("dev server exited — supervisor stopping") : q.error("dev server exited — supervisor stopping", { exitCode: o }), yield* N.sync(() => {
|
|
524
569
|
process.exitCode = o;
|
|
525
570
|
});
|
|
526
|
-
}),
|
|
571
|
+
}), _o = /* @__PURE__ */ new Set(/* @__PURE__ */ "crypto.fs.path.os.net.http.https.http2.tls.dns.dgram.stream.zlib.child_process.worker_threads.cluster.readline.vm.module.perf_hooks.async_hooks.inspector.v8.process.tty.repl.constants.sys.string_decoder".split(".")), vo = (e) => e.startsWith("node:") || _o.has(e) || e === "@voltro/workflow" ? !0 : e === "@voltro/database/wire" ? !1 : e === "@voltro/database" || e.startsWith("@voltro/database/") || e === "@voltro/runtime" || e.startsWith("@voltro/runtime/") ? !0 : e === "@voltro/ai/agent" || e === "@voltro/ai/events" ? !1 : !!(e === "@voltro/ai" || e.startsWith("@voltro/ai/") || [
|
|
527
572
|
"@voltro/protocol/session",
|
|
528
573
|
"@voltro/protocol/jwt",
|
|
529
574
|
"@voltro/protocol/apikey"
|
|
@@ -542,8 +587,8 @@ var Da = (e, t) => {
|
|
|
542
587
|
"@prisma/client",
|
|
543
588
|
"nodemailer",
|
|
544
589
|
"jose"
|
|
545
|
-
].includes(e)),
|
|
546
|
-
let t =
|
|
590
|
+
].includes(e)), yo = (e) => e.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:])\/\/[^\n]*/g, "$1"), bo = (e) => {
|
|
591
|
+
let t = yo(e), n = [], r = /(?:^|[\n;}])\s*(?:import|export)\s+([^;'"]*?)\s+from\s+['"]([^'"]+)['"]/g, i;
|
|
547
592
|
for (; (i = r.exec(t)) !== null;) {
|
|
548
593
|
let e = i[1].trim();
|
|
549
594
|
if (e === "type" || e.startsWith("type ")) continue;
|
|
@@ -559,8 +604,8 @@ var Da = (e, t) => {
|
|
|
559
604
|
let o = /\bimport\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
560
605
|
for (; (i = o.exec(t)) !== null;) n.push(i[1]);
|
|
561
606
|
return n;
|
|
562
|
-
},
|
|
563
|
-
let t =
|
|
607
|
+
}, xo = (e) => e.endsWith(".ts") || e.endsWith(".tsx"), So = async (e) => {
|
|
608
|
+
let t = xo(e) ? [e] : [
|
|
564
609
|
`${e}.ts`,
|
|
565
610
|
`${e}.tsx`,
|
|
566
611
|
O(e, "index.ts"),
|
|
@@ -570,7 +615,7 @@ var Da = (e, t) => {
|
|
|
570
615
|
if ((await R.stat(e)).isFile()) return e;
|
|
571
616
|
} catch {}
|
|
572
617
|
return null;
|
|
573
|
-
},
|
|
618
|
+
}, Co = async (e, t) => {
|
|
574
619
|
let n = t;
|
|
575
620
|
for (;;) {
|
|
576
621
|
let t = O(n, "node_modules", e);
|
|
@@ -581,7 +626,7 @@ var Da = (e, t) => {
|
|
|
581
626
|
if (r === n) return null;
|
|
582
627
|
n = r;
|
|
583
628
|
}
|
|
584
|
-
},
|
|
629
|
+
}, wo = (e) => {
|
|
585
630
|
if (typeof e == "string") return e;
|
|
586
631
|
if (typeof e == "object" && e) {
|
|
587
632
|
let t = e;
|
|
@@ -591,23 +636,23 @@ var Da = (e, t) => {
|
|
|
591
636
|
"node",
|
|
592
637
|
"default"
|
|
593
638
|
]) if (e in t) {
|
|
594
|
-
let n =
|
|
639
|
+
let n = wo(t[e]);
|
|
595
640
|
if (n !== void 0) return n;
|
|
596
641
|
}
|
|
597
642
|
}
|
|
598
|
-
},
|
|
599
|
-
if (e.startsWith(".")) return
|
|
600
|
-
let n = e.split("/"), r = e.startsWith("@"), i = r ? `${n[0]}/${n[1]}` : n[0], a = r ? n.slice(2) : n.slice(1), o = a.length > 0 ? `./${a.join("/")}` : ".", s = await
|
|
643
|
+
}, To = async (e, t) => {
|
|
644
|
+
if (e.startsWith(".")) return So(A(D(t), e));
|
|
645
|
+
let n = e.split("/"), r = e.startsWith("@"), i = r ? `${n[0]}/${n[1]}` : n[0], a = r ? n.slice(2) : n.slice(1), o = a.length > 0 ? `./${a.join("/")}` : ".", s = await Co(i, D(t));
|
|
601
646
|
if (!s) return null;
|
|
602
647
|
try {
|
|
603
|
-
let e = JSON.parse(await R.readFile(O(s, "package.json"), "utf8")), t =
|
|
604
|
-
if (typeof t == "string") return
|
|
648
|
+
let e = JSON.parse(await R.readFile(O(s, "package.json"), "utf8")), t = wo(e.exports?.[o]) ?? (o === "." ? e.module ?? e.main : void 0);
|
|
649
|
+
if (typeof t == "string") return So(A(s, t));
|
|
605
650
|
} catch {}
|
|
606
651
|
return null;
|
|
607
|
-
},
|
|
652
|
+
}, Eo = (e, t) => e.startsWith(t) ? e.slice(t.length).replace(/^[/\\]/, "") : e, Do = async (e, t) => {
|
|
608
653
|
let n = /* @__PURE__ */ new Set(), r = [{
|
|
609
654
|
file: e,
|
|
610
|
-
chain: [
|
|
655
|
+
chain: [Eo(e, t)]
|
|
611
656
|
}];
|
|
612
657
|
for (; r.length > 0;) {
|
|
613
658
|
let { file: e, chain: i } = r.shift();
|
|
@@ -619,37 +664,37 @@ var Da = (e, t) => {
|
|
|
619
664
|
} catch {
|
|
620
665
|
continue;
|
|
621
666
|
}
|
|
622
|
-
for (let o of
|
|
623
|
-
if (
|
|
667
|
+
for (let o of bo(a)) {
|
|
668
|
+
if (vo(o)) return {
|
|
624
669
|
specifier: o,
|
|
625
670
|
chain: [...i, o]
|
|
626
671
|
};
|
|
627
|
-
let a = await
|
|
672
|
+
let a = await To(o, e);
|
|
628
673
|
a && !n.has(a) && r.push({
|
|
629
674
|
file: a,
|
|
630
|
-
chain: [...i, `${o} (${
|
|
675
|
+
chain: [...i, `${o} (${Eo(a, t)})`]
|
|
631
676
|
});
|
|
632
677
|
}
|
|
633
678
|
}
|
|
634
679
|
return null;
|
|
635
|
-
},
|
|
680
|
+
}, Oo = /\.client\.tsx?$/, ko = async (e, t) => {
|
|
636
681
|
let n = [];
|
|
637
682
|
for (let r of t) {
|
|
638
|
-
if (!
|
|
639
|
-
let t = await
|
|
683
|
+
if (!Oo.test(r)) continue;
|
|
684
|
+
let t = await Do(r, e);
|
|
640
685
|
t !== null && n.push({
|
|
641
|
-
file:
|
|
686
|
+
file: Eo(r, e),
|
|
642
687
|
violation: t
|
|
643
688
|
});
|
|
644
689
|
}
|
|
645
690
|
return n;
|
|
646
|
-
},
|
|
691
|
+
}, Ao = (e) => `browser-safety violation — ${e.file} declares itself browser-safe (.client.ts) and is not.\n\n '${e.violation.specifier}' is server-only (node:* / database / ai / cluster / protocol session / db driver).\n\n import chain:\n → ${e.violation.chain.join("\n → ")}\n\n The .client suffix is a claim the framework checks, not a hint. Either move the server-only\n code behind a *.server.ts and keep this file pure, or drop the suffix — an unmarked file\n makes no claim, and only the rpcGroup guard will judge it (later, and with a longer chain).`, jo = async (e) => {
|
|
647
692
|
if (process.env.VOLTRO_BROWSER_SAFETY === "off") return;
|
|
648
|
-
let t = await
|
|
693
|
+
let t = await Do(e, D(e));
|
|
649
694
|
if (!t) return;
|
|
650
695
|
let n = t.chain.join("\n → ");
|
|
651
696
|
throw Error(`browser-safety violation — the generated rpcGroup pulls a SERVER-ONLY module into the client bundle.\n\n '${t.specifier}' is server-only (node:* / database / ai / cluster / protocol session / db driver),\n and the web client loads rpcGroup VALUE-LEVEL — this crashes the browser with\n "Module …node:crypto… has been externalized for browser compatibility", or bloats the\n bundle with the whole server graph.\n\n import chain:\n → ${n}\n\n Fix: keep the descriptor (*.query/.mutation/.action.ts), the workflow descriptor\n (*.workflow.tsx, import from @voltro/workflow/define), AND any plugin error schema\n browser-safe. Move DB-backed / node: code behind a *.server.ts file or a browser-safe\n subpath (e.g. a plugin's '/errors' export). Escape hatch (not recommended):\n VOLTRO_BROWSER_SAFETY=off.`);
|
|
652
|
-
},
|
|
697
|
+
}, Mo = /\.(query|mutation|action|stream)\.ts$/, No = /\.(query|mutation|action|stream)\.server\.ts$/, Po = /\.workflow\.tsx$/, Fo = /(?<!\.server)\.agent\.tsx?$/, Io = /\.connection\.tsx?$/, Lo = /* @__PURE__ */ new Set([
|
|
653
698
|
"node_modules",
|
|
654
699
|
"dist",
|
|
655
700
|
"build",
|
|
@@ -657,37 +702,37 @@ var Da = (e, t) => {
|
|
|
657
702
|
".vite",
|
|
658
703
|
".next",
|
|
659
704
|
".git"
|
|
660
|
-
]),
|
|
705
|
+
]), Ro = async (e) => {
|
|
661
706
|
let t = async (e) => {
|
|
662
707
|
let n = await R.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
663
|
-
for (let r of n) if (!
|
|
708
|
+
for (let r of n) if (!Lo.has(r.name)) {
|
|
664
709
|
if (r.isDirectory()) {
|
|
665
710
|
if (await t(O(e, r.name))) return !0;
|
|
666
|
-
} else if (r.isFile() &&
|
|
711
|
+
} else if (r.isFile() && Io.test(r.name)) return !0;
|
|
667
712
|
}
|
|
668
713
|
return !1;
|
|
669
714
|
};
|
|
670
715
|
return t(e);
|
|
671
|
-
},
|
|
716
|
+
}, zo = async (e) => {
|
|
672
717
|
let t = [], n = async (e) => {
|
|
673
718
|
let r = await R.readdir(e, { withFileTypes: !0 });
|
|
674
719
|
for (let i of r) {
|
|
675
|
-
if (
|
|
720
|
+
if (Lo.has(i.name)) continue;
|
|
676
721
|
let r = O(e, i.name);
|
|
677
|
-
i.isDirectory() ? await n(r) : i.isFile() && (
|
|
722
|
+
i.isDirectory() ? await n(r) : i.isFile() && (Mo.test(i.name) && !No.test(i.name) || Po.test(i.name) || Fo.test(i.name)) && t.push(r);
|
|
678
723
|
}
|
|
679
724
|
};
|
|
680
725
|
return await n(e), t;
|
|
681
|
-
},
|
|
726
|
+
}, Bo = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && (e.kind === "query" || e.kind === "mutation" || e.kind === "action" || e.kind === "stream"), Vo = Symbol.for("@effect/workflow/Workflow"), Ho = (e) => typeof e == "object" && !!e && Vo in e && "name" in e && typeof e.name == "string", Uo = async (e) => {
|
|
682
727
|
let t = [];
|
|
683
728
|
for (let n of e) {
|
|
684
729
|
let e = await import(j(n).href);
|
|
685
|
-
for (let [r, i] of Object.entries(e))
|
|
730
|
+
for (let [r, i] of Object.entries(e)) Bo(i) ? t.push({
|
|
686
731
|
file: n,
|
|
687
732
|
exportName: r,
|
|
688
733
|
rpcTag: i.name,
|
|
689
734
|
kind: i.kind
|
|
690
|
-
}) :
|
|
735
|
+
}) : Ho(i) && t.push({
|
|
691
736
|
file: n,
|
|
692
737
|
exportName: r,
|
|
693
738
|
rpcTag: i.name,
|
|
@@ -695,23 +740,23 @@ var Da = (e, t) => {
|
|
|
695
740
|
});
|
|
696
741
|
}
|
|
697
742
|
return t;
|
|
698
|
-
},
|
|
743
|
+
}, Wo = async (e) => {
|
|
699
744
|
let t = [];
|
|
700
745
|
for (let n of e) {
|
|
701
|
-
if (!
|
|
746
|
+
if (!Fo.test(n)) continue;
|
|
702
747
|
let e = await import(j(n).href);
|
|
703
|
-
for (let [r, i] of Object.entries(e))
|
|
748
|
+
for (let [r, i] of Object.entries(e)) ga(i) && t.push({
|
|
704
749
|
file: n,
|
|
705
750
|
exportName: r,
|
|
706
751
|
name: i.name
|
|
707
752
|
});
|
|
708
753
|
}
|
|
709
754
|
return t;
|
|
710
|
-
},
|
|
755
|
+
}, X = (e) => {
|
|
711
756
|
let t = (e, t) => e.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((e, n) => (n === 0 && !t ? e.charAt(0).toLowerCase() : e.charAt(0).toUpperCase()) + e.slice(1)).join(""), n = e.split(".");
|
|
712
757
|
return `${t(n[0] ?? "rpc", !1)}${n.slice(1).map((e) => t(e, !0)).join("")}Rpc`;
|
|
713
|
-
},
|
|
714
|
-
let n = (e) => k(t, e.file).replace(/\\/g, "/"), r = e.filter((e) => !
|
|
758
|
+
}, Go = /^[A-Za-z][A-Za-z0-9]*([._-][A-Za-z0-9]+)*$/, Ko = (e, t) => {
|
|
759
|
+
let n = (e) => k(t, e.file).replace(/\\/g, "/"), r = e.filter((e) => !Go.test(e.rpcTag));
|
|
715
760
|
if (r.length > 0) throw Error(`invalid rpc tag — a procedure/workflow \`name\` must start with a letter and
|
|
716
761
|
use only letters, digits, and \`.\` \`-\` \`_\` separators (the tag becomes a JS
|
|
717
762
|
identifier in the generated rpcGroup):
|
|
@@ -719,7 +764,7 @@ identifier in the generated rpcGroup):
|
|
|
719
764
|
${r.map((e) => ` • "${e.rpcTag}" (${n(e)})`).join("\n")}\n`);
|
|
720
765
|
let i = /* @__PURE__ */ new Map();
|
|
721
766
|
for (let t of e) {
|
|
722
|
-
let e =
|
|
767
|
+
let e = X(t.rpcTag), n = i.get(e);
|
|
723
768
|
n ? n.push(t) : i.set(e, [t]);
|
|
724
769
|
}
|
|
725
770
|
let a = [...i.values()].filter((e) => new Set(e.map((e) => e.rpcTag)).size > 1);
|
|
@@ -727,8 +772,8 @@ ${r.map((e) => ` • "${e.rpcTag}" (${n(e)})`).join("\n")}\n`);
|
|
|
727
772
|
generated identifier (separators are normalized away). Rename one so they
|
|
728
773
|
differ by more than a \`.\`/\`-\`/\`_\`:
|
|
729
774
|
|
|
730
|
-
${a.map((e) => ` ${
|
|
731
|
-
},
|
|
775
|
+
${a.map((e) => ` ${X(e[0].rpcTag)}:\n` + e.map((e) => ` - "${e.rpcTag}" (${n(e)})`).join("\n")).join("\n\n")}\n`);
|
|
776
|
+
}, qo = (e) => {
|
|
732
777
|
switch (e) {
|
|
733
778
|
case "query": return 0;
|
|
734
779
|
case "mutation": return 1;
|
|
@@ -736,7 +781,7 @@ ${a.map((e) => ` ${Y(e[0].rpcTag)}:\n` + e.map((e) => ` - "${e.rpcTag}" (${
|
|
|
736
781
|
case "stream": return 3;
|
|
737
782
|
case "workflow": return 4;
|
|
738
783
|
}
|
|
739
|
-
},
|
|
784
|
+
}, Jo = (e, t) => {
|
|
740
785
|
let n = /* @__PURE__ */ new Map();
|
|
741
786
|
for (let t of e) n.has(t.rpcTag) || n.set(t.rpcTag, t);
|
|
742
787
|
let r = [...n.keys()], i = (e) => k(t, n.get(e).file).replace(/\\/g, "/"), a = [];
|
|
@@ -751,7 +796,7 @@ can't be both a leaf and a namespace. Rename one side (e.g. give the
|
|
|
751
796
|
workflow/procedure a nested name like "<prefix>.run"):
|
|
752
797
|
|
|
753
798
|
${a.join("\n\n")}\n`);
|
|
754
|
-
},
|
|
799
|
+
}, Yo = (e, t, n, r = [], i = [], a = !1, o = !1, s = []) => {
|
|
755
800
|
let c = i.length > 0, l = i.flatMap((e) => [{
|
|
756
801
|
file: e.file,
|
|
757
802
|
exportName: e.exportName,
|
|
@@ -768,20 +813,20 @@ ${a.join("\n\n")}\n`);
|
|
|
768
813
|
rpcTag: e.tag,
|
|
769
814
|
kind: e.kind
|
|
770
815
|
}));
|
|
771
|
-
|
|
816
|
+
Jo([
|
|
772
817
|
...n,
|
|
773
818
|
...l,
|
|
774
819
|
...d
|
|
775
|
-
], e),
|
|
820
|
+
], e), Ko([
|
|
776
821
|
...n,
|
|
777
822
|
...l,
|
|
778
823
|
...d
|
|
779
824
|
], e);
|
|
780
|
-
let f = (e) => e.replace(/[^a-zA-Z0-9_$]/g, "_"), p = (e) => `__src_agent_${f(e.name)}`, m = (e) => `__agentRoutes_${f(e.name)}`, h = r.length > 0, g = r.map((e, t) => `import { ${e.name} as __pe${t} } from '${e.module}'`), _ = h ? ", __voltroPluginErrors" : "", ee = u.length > 0, te = u.map((e, t) => `import { ${e.name} as __prpc${t} } from '${e.module}'`), ne = (e) => e === "query" ? "queryToRpc" : e === "mutation" ? "mutationToRpc" : "actionToRpc", re = u.map((e, t) => `export const ${
|
|
825
|
+
let f = (e) => e.replace(/[^a-zA-Z0-9_$]/g, "_"), p = (e) => `__src_agent_${f(e.name)}`, m = (e) => `__agentRoutes_${f(e.name)}`, h = r.length > 0, g = r.map((e, t) => `import { ${e.name} as __pe${t} } from '${e.module}'`), _ = h ? ", __voltroPluginErrors" : "", ee = u.length > 0, te = u.map((e, t) => `import { ${e.name} as __prpc${t} } from '${e.module}'`), ne = (e) => e === "query" ? "queryToRpc" : e === "mutation" ? "mutationToRpc" : "actionToRpc", re = u.map((e, t) => `export const ${X(e.tag)} = ${ne(e.kind)}(__prpc${t}${_})`), ie = u.map((e) => ` ${X(e.tag)},`), ae = u.map((e, t) => ` ${JSON.stringify(e.tag)}: normalizeDescriptor(__prpc${t}),`), v = [...n].sort((e, t) => e.kind === t.kind ? e.rpcTag < t.rpcTag ? -1 : 1 : qo(e.kind) - qo(t.kind)), oe = D(t), y = (e) => `__src_${X(e.rpcTag)}`, b = (e) => {
|
|
781
826
|
let t = `./${k(oe, e.file).replace(/\\/g, "/").replace(/\.tsx?$/, "")}`;
|
|
782
827
|
return `import { ${e.exportName} as ${y(e)} } from '${t}'`;
|
|
783
828
|
}, se = (e) => {
|
|
784
|
-
let t =
|
|
829
|
+
let t = X(e.rpcTag), n = y(e);
|
|
785
830
|
return e.kind === "query" ? `export const ${t} = queryToRpc(${n}${_})` : e.kind === "mutation" ? `export const ${t} = mutationToRpc(${n}${_})` : e.kind === "action" ? `export const ${t} = actionToRpc(${n}${_})` : e.kind === "stream" ? `export const ${t} = streamToRpc(${n}${_})` : [
|
|
786
831
|
`export const ${t} = Rpc.make('${e.rpcTag}', {`,
|
|
787
832
|
` payload: ${n}.payloadSchema,`,
|
|
@@ -810,8 +855,8 @@ ${a.join("\n\n")}\n`);
|
|
|
810
855
|
"__voltroConnectionSubmitToken",
|
|
811
856
|
"__voltroConnectionDisconnect"
|
|
812
857
|
] : [], fe = [
|
|
813
|
-
...v.map((e) => ` ${
|
|
814
|
-
...i.flatMap((e) => [` ${
|
|
858
|
+
...v.map((e) => ` ${X(e.rpcTag)},`),
|
|
859
|
+
...i.flatMap((e) => [` ${X(`${e.name}.send`)},`, ` ${X(`${e.name}.messages`)},`]),
|
|
815
860
|
...ue.map((e) => ` ${e},`),
|
|
816
861
|
...S.map((e) => ` ${e},`),
|
|
817
862
|
...de.map((e) => ` ${e},`),
|
|
@@ -858,7 +903,7 @@ ${a.join("\n\n")}\n`);
|
|
|
858
903
|
return [
|
|
859
904
|
"// THIS FILE IS GENERATED — DO NOT EDIT BY HAND.",
|
|
860
905
|
"// Re-emitted by `voltro dev` whenever query/mutation/action/stream/workflow files change.",
|
|
861
|
-
`// descriptor-fingerprint: ${
|
|
906
|
+
`// descriptor-fingerprint: ${Xi("sha1").update(Se.map((e) => {
|
|
862
907
|
let t = "";
|
|
863
908
|
try {
|
|
864
909
|
t = Tt(e.file, "utf8");
|
|
@@ -922,7 +967,7 @@ ${a.join("\n\n")}\n`);
|
|
|
922
967
|
""
|
|
923
968
|
] : [],
|
|
924
969
|
...v.map(se),
|
|
925
|
-
...i.flatMap((e) => [`export const ${
|
|
970
|
+
...i.flatMap((e) => [`export const ${X(`${e.name}.send`)} = actionToRpc(${m(e)}.send${_})`, `export const ${X(`${e.name}.messages`)} = queryToRpc(${m(e)}.messages${_})`]),
|
|
926
971
|
...x ? [
|
|
927
972
|
"export const __voltroWorkflowRun = queryToRpc(workflowRunQueryDescriptor)",
|
|
928
973
|
"export const __voltroWorkflowRuns = queryToRpc(workflowRunsQueryDescriptor)",
|
|
@@ -997,8 +1042,8 @@ ${a.join("\n\n")}\n`);
|
|
|
997
1042
|
""
|
|
998
1043
|
] : []
|
|
999
1044
|
].join("\n");
|
|
1000
|
-
},
|
|
1001
|
-
let t = A(e.root), n = await
|
|
1045
|
+
}, Xo = async (e) => {
|
|
1046
|
+
let t = A(e.root), n = await zo(t), r = await Uo(n), i = await Wo(n), a = await Ro(t);
|
|
1002
1047
|
if (r.length === 0 && i.length === 0 && !a && (e.pluginRpcImports?.length ?? 0) === 0) return;
|
|
1003
1048
|
let o = ((e) => {
|
|
1004
1049
|
if (e.length === 0) return t;
|
|
@@ -1017,7 +1062,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1017
1062
|
"workflows"
|
|
1018
1063
|
]), c = (e) => e.slice(e.lastIndexOf("/") + 1), l = o;
|
|
1019
1064
|
for (; l !== t && s.has(c(l));) l = l.slice(0, l.lastIndexOf("/")) || "/";
|
|
1020
|
-
let u = A(e.outputFile ?? O(l, "rpcGroup.generated.ts")), d = [...new Map((e.pluginErrorImports ?? []).map((e) => [`${e.module}#${e.name}`, e])).values()], f = [...new Map((e.pluginRpcImports ?? []).map((e) => [e.tag, e])).values()], p =
|
|
1065
|
+
let u = A(e.outputFile ?? O(l, "rpcGroup.generated.ts")), d = [...new Map((e.pluginErrorImports ?? []).map((e) => [`${e.module}#${e.name}`, e])).values()], f = [...new Map((e.pluginRpcImports ?? []).map((e) => [e.tag, e])).values()], p = Yo(t, u, r, d, i, Tr(), a, f), m = [];
|
|
1021
1066
|
for (let t of e.pluginContributions ?? []) {
|
|
1022
1067
|
let e = null;
|
|
1023
1068
|
try {
|
|
@@ -1036,8 +1081,8 @@ ${a.join("\n\n")}\n`);
|
|
|
1036
1081
|
try {
|
|
1037
1082
|
g = await R.readFile(u, "utf8");
|
|
1038
1083
|
} catch {}
|
|
1039
|
-
return g !== h && await R.writeFile(u, h, "utf8"), await
|
|
1040
|
-
},
|
|
1084
|
+
return g !== h && await R.writeFile(u, h, "utf8"), await jo(u), u;
|
|
1085
|
+
}, Zo = (e) => {
|
|
1041
1086
|
let t = [];
|
|
1042
1087
|
for (let n of e) for (let e of n) {
|
|
1043
1088
|
let n = e.descriptor?.tag;
|
|
@@ -1049,13 +1094,13 @@ ${a.join("\n\n")}\n`);
|
|
|
1049
1094
|
} : { tag: n });
|
|
1050
1095
|
}
|
|
1051
1096
|
return t;
|
|
1052
|
-
},
|
|
1053
|
-
let n =
|
|
1054
|
-
return n.length === 0 ? 0 : (t(
|
|
1055
|
-
},
|
|
1097
|
+
}, Qo = (e, t) => {
|
|
1098
|
+
let n = Di(e);
|
|
1099
|
+
return n.length === 0 ? 0 : (t(vi(n)), n.length);
|
|
1100
|
+
}, $o = async (e) => {
|
|
1056
1101
|
let t = e.spec ?? $n, n;
|
|
1057
1102
|
return t.kind !== "noop" && e.sqlLayer !== void 0 ? n = await N.runPromise(N.gen(function* () {
|
|
1058
|
-
let n = yield*
|
|
1103
|
+
let n = yield* Mr.SqlClient, r = t.build(n);
|
|
1059
1104
|
return t.initialize && (yield* t.initialize(r).pipe(N.catchAll((t) => N.sync(() => e.log.warn("analytics sink initialize failed", {
|
|
1060
1105
|
provider: r.info.provider,
|
|
1061
1106
|
err: String(t)
|
|
@@ -1073,14 +1118,14 @@ ${a.join("\n\n")}\n`);
|
|
|
1073
1118
|
t.dispose && await N.runPromise(t.dispose(n).pipe(N.timeout("1200 millis"), N.ignore));
|
|
1074
1119
|
}
|
|
1075
1120
|
};
|
|
1076
|
-
},
|
|
1077
|
-
for (let e of
|
|
1078
|
-
throw Error(`@effect/cluster patch asset not found (looked in: ${
|
|
1079
|
-
},
|
|
1080
|
-
if (
|
|
1081
|
-
let t = ` '${
|
|
1121
|
+
}, es = "@effect/cluster@0.59.0", ts = "@effect__cluster@0.59.0.patch", ns = `patches/${ts}`, Z = D(dt(import.meta.url)), rs = [A(Z, "..", "templates", "patches", ts), A(Z, "..", "..", "templates", "patches", ts)], is = async () => {
|
|
1122
|
+
for (let e of rs) if (L(e)) return R.readFile(e, "utf8");
|
|
1123
|
+
throw Error(`@effect/cluster patch asset not found (looked in: ${rs.join(", ")}). This is a packaging bug — the CLI should ship it under templates/patches/.`);
|
|
1124
|
+
}, as = (e) => RegExp(`['"]?${es.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}['"]?\\s*:`).test(e), os = (e) => {
|
|
1125
|
+
if (as(e)) return null;
|
|
1126
|
+
let t = ` '${es}': ${ns}`, n = /^patchedDependencies:[ \t]*\n/m;
|
|
1082
1127
|
return n.test(e) ? e.replace(n, (e) => `${e}${t}\n`) : `${e}${e.endsWith("\n") ? "" : "\n"}\npatchedDependencies:\n${t}\n`;
|
|
1083
|
-
},
|
|
1128
|
+
}, ss = (e) => {
|
|
1084
1129
|
let t = A(e);
|
|
1085
1130
|
for (let e = 0; e < 12; e++) {
|
|
1086
1131
|
if (L(O(t, "pnpm-workspace.yaml"))) return t;
|
|
@@ -1089,28 +1134,28 @@ ${a.join("\n\n")}\n`);
|
|
|
1089
1134
|
t = e;
|
|
1090
1135
|
}
|
|
1091
1136
|
return null;
|
|
1092
|
-
},
|
|
1093
|
-
let t =
|
|
1137
|
+
}, cs = async (e) => {
|
|
1138
|
+
let t = ss(e);
|
|
1094
1139
|
if (!t) return null;
|
|
1095
|
-
let n = await
|
|
1096
|
-
return n.fullyWired ? null : `mssql + durable cluster workflows need the @effect/cluster patch, which a plain install cannot carry. Run \`voltro add mssql\` then \`pnpm install\` to wire it (missing: ${[n.patchFilePresent ? null :
|
|
1097
|
-
},
|
|
1098
|
-
let t = L(O(e,
|
|
1140
|
+
let n = await ls(t);
|
|
1141
|
+
return n.fullyWired ? null : `mssql + durable cluster workflows need the @effect/cluster patch, which a plain install cannot carry. Run \`voltro add mssql\` then \`pnpm install\` to wire it (missing: ${[n.patchFilePresent ? null : ns, n.pnpmEntryPresent ? null : "patchedDependencies in pnpm-workspace.yaml"].filter(Boolean).join(" + ")}). Without it, workflow message/runner storage misbehaves on SQL Server.`;
|
|
1142
|
+
}, ls = async (e) => {
|
|
1143
|
+
let t = L(O(e, ns)), n = O(e, "pnpm-workspace.yaml"), r = L(n) && as(await R.readFile(n, "utf8"));
|
|
1099
1144
|
return {
|
|
1100
1145
|
patchFilePresent: t,
|
|
1101
1146
|
pnpmEntryPresent: r,
|
|
1102
1147
|
fullyWired: t && r
|
|
1103
1148
|
};
|
|
1104
|
-
},
|
|
1105
|
-
let t = [], n = O(e,
|
|
1106
|
-
(L(n) ? await R.readFile(n, "utf8") : null) !== r && (await R.mkdir(D(n), { recursive: !0 }), await R.writeFile(n, r, "utf8"), t.push(`patch file → ${
|
|
1149
|
+
}, us = async (e) => {
|
|
1150
|
+
let t = [], n = O(e, ns), r = await is();
|
|
1151
|
+
(L(n) ? await R.readFile(n, "utf8") : null) !== r && (await R.mkdir(D(n), { recursive: !0 }), await R.writeFile(n, r, "utf8"), t.push(`patch file → ${ns}`));
|
|
1107
1152
|
let i = O(e, "pnpm-workspace.yaml");
|
|
1108
1153
|
if (L(i)) {
|
|
1109
|
-
let e =
|
|
1110
|
-
e !== null && (await R.writeFile(i, e, "utf8"), t.push(`patchedDependencies['${
|
|
1154
|
+
let e = os(await R.readFile(i, "utf8"));
|
|
1155
|
+
e !== null && (await R.writeFile(i, e, "utf8"), t.push(`patchedDependencies['${es}'] → pnpm-workspace.yaml`));
|
|
1111
1156
|
}
|
|
1112
1157
|
return t;
|
|
1113
|
-
},
|
|
1158
|
+
}, ds = (e) => e.replace(/\.subscribe\.tsx?$/, ""), fs = async (e, t) => {
|
|
1114
1159
|
let n = [];
|
|
1115
1160
|
for (let r of e) {
|
|
1116
1161
|
let e;
|
|
@@ -1136,14 +1181,14 @@ ${a.join("\n\n")}\n`);
|
|
|
1136
1181
|
}
|
|
1137
1182
|
n.push({
|
|
1138
1183
|
file: r,
|
|
1139
|
-
id:
|
|
1184
|
+
id: ds(E(r)),
|
|
1140
1185
|
definition: a
|
|
1141
1186
|
});
|
|
1142
1187
|
}
|
|
1143
1188
|
return n;
|
|
1144
|
-
},
|
|
1189
|
+
}, ps = (e, t, n, r) => {
|
|
1145
1190
|
if (e.length === 0) return () => {};
|
|
1146
|
-
let i =
|
|
1191
|
+
let i = Or(t, {
|
|
1147
1192
|
subject: zt,
|
|
1148
1193
|
schemaRegistry: r
|
|
1149
1194
|
}), a = [];
|
|
@@ -1161,7 +1206,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1161
1206
|
e.warn("subscriber: handler rejected", {
|
|
1162
1207
|
table: o,
|
|
1163
1208
|
op: t.op
|
|
1164
|
-
}, n),
|
|
1209
|
+
}, n), ki({
|
|
1165
1210
|
error: n,
|
|
1166
1211
|
source: "subscriber",
|
|
1167
1212
|
name: o,
|
|
@@ -1175,7 +1220,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1175
1220
|
e.warn("subscriber: handler threw synchronously", {
|
|
1176
1221
|
table: o,
|
|
1177
1222
|
op: t.op
|
|
1178
|
-
}, n),
|
|
1223
|
+
}, n), ki({
|
|
1179
1224
|
error: n,
|
|
1180
1225
|
source: "subscriber",
|
|
1181
1226
|
name: o,
|
|
@@ -1196,7 +1241,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1196
1241
|
e();
|
|
1197
1242
|
} catch {}
|
|
1198
1243
|
};
|
|
1199
|
-
},
|
|
1244
|
+
}, ms = (e) => e.replace(/\.outbox\.tsx?$/, ""), hs = async (e, t) => {
|
|
1200
1245
|
let n = [], r = /* @__PURE__ */ new Map();
|
|
1201
1246
|
for (let i of e) {
|
|
1202
1247
|
let e;
|
|
@@ -1231,12 +1276,12 @@ ${a.join("\n\n")}\n`);
|
|
|
1231
1276
|
}
|
|
1232
1277
|
r.set(o.effect, i), n.push({
|
|
1233
1278
|
file: i,
|
|
1234
|
-
id:
|
|
1279
|
+
id: ms(E(i)),
|
|
1235
1280
|
definition: o
|
|
1236
1281
|
});
|
|
1237
1282
|
}
|
|
1238
1283
|
return n;
|
|
1239
|
-
},
|
|
1284
|
+
}, gs = (e) => {
|
|
1240
1285
|
let { handlers: t, store: n, log: r } = e, i = new Map(t.map((e) => [e.definition.effect, e.definition])), a = !1, o = !1, s = !1, c = async () => {
|
|
1241
1286
|
if (a) {
|
|
1242
1287
|
o = !0;
|
|
@@ -1270,16 +1315,16 @@ ${a.join("\n\n")}\n`);
|
|
|
1270
1315
|
},
|
|
1271
1316
|
drainOnce: c
|
|
1272
1317
|
};
|
|
1273
|
-
},
|
|
1318
|
+
}, _s = "<builtin:connections>", Q = {
|
|
1274
1319
|
registry: Dn([]),
|
|
1275
1320
|
queries: [],
|
|
1276
1321
|
mutations: [],
|
|
1277
1322
|
actions: [],
|
|
1278
1323
|
httpRoutes: [],
|
|
1279
1324
|
active: !1
|
|
1280
|
-
},
|
|
1325
|
+
}, vs = (e) => {
|
|
1281
1326
|
let { definitions: t, store: n, publicUrl: r, log: i } = e;
|
|
1282
|
-
if (t.length === 0) return
|
|
1327
|
+
if (t.length === 0) return Q;
|
|
1283
1328
|
Wt(t);
|
|
1284
1329
|
let a = Dn(t), o = {
|
|
1285
1330
|
registry: a,
|
|
@@ -1303,7 +1348,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1303
1348
|
if (l !== null) return i.info("connection consent declined", {
|
|
1304
1349
|
connectionId: t[1],
|
|
1305
1350
|
error: l
|
|
1306
|
-
}),
|
|
1351
|
+
}), ys(`/?connection=${encodeURIComponent(t[1] ?? "")}&error=${encodeURIComponent(l)}`);
|
|
1307
1352
|
if (s === "" || c === "") return {
|
|
1308
1353
|
status: 400,
|
|
1309
1354
|
body: "missing code or state",
|
|
@@ -1317,13 +1362,13 @@ ${a.join("\n\n")}\n`);
|
|
|
1317
1362
|
code: c,
|
|
1318
1363
|
publicUrl: r
|
|
1319
1364
|
});
|
|
1320
|
-
return i.info("connection established", { connectionId: e.connectionId }),
|
|
1365
|
+
return i.info("connection established", { connectionId: e.connectionId }), ys(e.redirectTo);
|
|
1321
1366
|
} catch (e) {
|
|
1322
1367
|
let n = e instanceof Error ? e.message : String(e);
|
|
1323
1368
|
return i.warn("connection callback failed", {
|
|
1324
1369
|
connectionId: t[1],
|
|
1325
1370
|
reason: n
|
|
1326
|
-
}),
|
|
1371
|
+
}), ys(`/?connection=${encodeURIComponent(t[1] ?? "")}&error=handshake_failed`);
|
|
1327
1372
|
}
|
|
1328
1373
|
}
|
|
1329
1374
|
}] : [];
|
|
@@ -1331,40 +1376,40 @@ ${a.join("\n\n")}\n`);
|
|
|
1331
1376
|
connections: t.map((e) => `${e.id} (${e.kind})`),
|
|
1332
1377
|
callback: d ? "/_voltro/connections/<id>/callback" : "(no oauth2 connection declared)",
|
|
1333
1378
|
routes: [
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1379
|
+
Ei.name,
|
|
1380
|
+
wi.name,
|
|
1381
|
+
Ti.name,
|
|
1382
|
+
Ci.name
|
|
1338
1383
|
]
|
|
1339
1384
|
}), {
|
|
1340
1385
|
registry: a,
|
|
1341
1386
|
queries: [{
|
|
1342
|
-
file:
|
|
1343
|
-
descriptor:
|
|
1387
|
+
file: _s,
|
|
1388
|
+
descriptor: Ei,
|
|
1344
1389
|
executor: (e, t) => s(e, t)
|
|
1345
1390
|
}],
|
|
1346
1391
|
mutations: [{
|
|
1347
|
-
file:
|
|
1348
|
-
descriptor:
|
|
1392
|
+
file: _s,
|
|
1393
|
+
descriptor: Ti,
|
|
1349
1394
|
executor: (e, t) => l(e, t)
|
|
1350
1395
|
}, {
|
|
1351
|
-
file:
|
|
1352
|
-
descriptor:
|
|
1396
|
+
file: _s,
|
|
1397
|
+
descriptor: Ci,
|
|
1353
1398
|
executor: (e, t) => u(e, t)
|
|
1354
1399
|
}],
|
|
1355
1400
|
actions: [{
|
|
1356
|
-
file:
|
|
1357
|
-
descriptor:
|
|
1401
|
+
file: _s,
|
|
1402
|
+
descriptor: wi,
|
|
1358
1403
|
executor: (e, t) => c(e, t)
|
|
1359
1404
|
}],
|
|
1360
1405
|
httpRoutes: f,
|
|
1361
1406
|
active: !0
|
|
1362
1407
|
};
|
|
1363
|
-
},
|
|
1408
|
+
}, ys = (e) => ({
|
|
1364
1409
|
status: 302,
|
|
1365
1410
|
headers: { location: pr(e.startsWith("/") ? e : `/${e}`) },
|
|
1366
1411
|
body: ""
|
|
1367
|
-
}),
|
|
1412
|
+
}), bs = (e) => process.env.VOLTRO_PUBLIC_URL?.replace(/\/+$/, "") ?? `http://localhost:${e}`, xs = (e) => e.replace(/\.reaction\.tsx?$/, ""), Ss = async (e, t) => {
|
|
1368
1413
|
let n = [];
|
|
1369
1414
|
for (let r of e) {
|
|
1370
1415
|
let e;
|
|
@@ -1398,12 +1443,12 @@ ${a.join("\n\n")}\n`);
|
|
|
1398
1443
|
}
|
|
1399
1444
|
n.push({
|
|
1400
1445
|
file: r,
|
|
1401
|
-
id:
|
|
1446
|
+
id: xs(E(r)),
|
|
1402
1447
|
definition: a
|
|
1403
1448
|
});
|
|
1404
1449
|
}
|
|
1405
1450
|
return n;
|
|
1406
|
-
},
|
|
1451
|
+
}, Cs = async (e, t, n) => {
|
|
1407
1452
|
let r = n.findAgentSend(e);
|
|
1408
1453
|
if (r === void 0) {
|
|
1409
1454
|
n.log.warn("reaction agent act — no synthesized agent found (declare a `*.agent.tsx` named this)", { agent: e });
|
|
@@ -1418,7 +1463,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1418
1463
|
subject: n.makeSubject(a),
|
|
1419
1464
|
traceId: `reaction:${e}`
|
|
1420
1465
|
});
|
|
1421
|
-
},
|
|
1466
|
+
}, ws = (e, t, n, r) => {
|
|
1422
1467
|
if (e.length === 0) return () => {};
|
|
1423
1468
|
let i = /* @__PURE__ */ new Set(), a = {
|
|
1424
1469
|
has: (e) => i.has(e),
|
|
@@ -1455,7 +1500,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1455
1500
|
r.warn("reaction: dispatch failed", {
|
|
1456
1501
|
table: e.table,
|
|
1457
1502
|
op: e.op
|
|
1458
|
-
}, t),
|
|
1503
|
+
}, t), ki({
|
|
1459
1504
|
error: t,
|
|
1460
1505
|
source: "reaction",
|
|
1461
1506
|
name: n.name,
|
|
@@ -1468,7 +1513,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1468
1513
|
l();
|
|
1469
1514
|
} catch {}
|
|
1470
1515
|
};
|
|
1471
|
-
},
|
|
1516
|
+
}, Ts = "_voltro_aggregate_meta", Es = "_voltro_aggregate_rows", Ds = () => {
|
|
1472
1517
|
let e = /* @__PURE__ */ new Map(), t = {
|
|
1473
1518
|
refreshedAt: null,
|
|
1474
1519
|
rowCount: 0,
|
|
@@ -1513,8 +1558,8 @@ ${a.join("\n\n")}\n`);
|
|
|
1513
1558
|
},
|
|
1514
1559
|
refreshMirror: async () => {}
|
|
1515
1560
|
};
|
|
1516
|
-
},
|
|
1517
|
-
CREATE TABLE IF NOT EXISTS ${
|
|
1561
|
+
}, Os = `
|
|
1562
|
+
CREATE TABLE IF NOT EXISTS ${Ts} (
|
|
1518
1563
|
name TEXT PRIMARY KEY,
|
|
1519
1564
|
generation INTEGER NOT NULL DEFAULT 0,
|
|
1520
1565
|
refreshed_at TEXT,
|
|
@@ -1523,24 +1568,24 @@ ${a.join("\n\n")}\n`);
|
|
|
1523
1568
|
last_error TEXT,
|
|
1524
1569
|
next_refresh_at TEXT
|
|
1525
1570
|
);
|
|
1526
|
-
`.trim(),
|
|
1527
|
-
CREATE TABLE IF NOT EXISTS ${
|
|
1571
|
+
`.trim(), ks = `
|
|
1572
|
+
CREATE TABLE IF NOT EXISTS ${Es} (
|
|
1528
1573
|
aggregate_name TEXT NOT NULL,
|
|
1529
1574
|
generation INTEGER NOT NULL,
|
|
1530
1575
|
row_index INTEGER NOT NULL,
|
|
1531
1576
|
row_data TEXT NOT NULL,
|
|
1532
1577
|
PRIMARY KEY (aggregate_name, generation, row_index)
|
|
1533
1578
|
);
|
|
1534
|
-
`.trim(),
|
|
1535
|
-
CREATE INDEX IF NOT EXISTS ${
|
|
1536
|
-
ON ${
|
|
1537
|
-
`.trim(),
|
|
1579
|
+
`.trim(), As = `
|
|
1580
|
+
CREATE INDEX IF NOT EXISTS ${Es}_lookup
|
|
1581
|
+
ON ${Es} (aggregate_name, generation, row_index);
|
|
1582
|
+
`.trim(), js = (e) => ({
|
|
1538
1583
|
refreshedAt: e.refreshed_at === null ? null : new Date(e.refreshed_at),
|
|
1539
1584
|
rowCount: e.row_count,
|
|
1540
1585
|
durationMs: e.duration_ms,
|
|
1541
1586
|
lastError: e.last_error,
|
|
1542
1587
|
nextRefreshAt: e.next_refresh_at === null ? null : new Date(e.next_refresh_at)
|
|
1543
|
-
}),
|
|
1588
|
+
}), Ms = (e) => {
|
|
1544
1589
|
let t = /* @__PURE__ */ new Map(), n = {
|
|
1545
1590
|
refreshedAt: null,
|
|
1546
1591
|
rowCount: 0,
|
|
@@ -1548,14 +1593,14 @@ ${a.join("\n\n")}\n`);
|
|
|
1548
1593
|
lastError: null,
|
|
1549
1594
|
nextRefreshAt: null
|
|
1550
1595
|
}, r = (t) => N.runPromise(t.pipe(N.provide(e))), i = () => N.gen(function* () {
|
|
1551
|
-
let e = yield*
|
|
1552
|
-
yield* e.unsafe(
|
|
1596
|
+
let e = yield* Mr.SqlClient;
|
|
1597
|
+
yield* e.unsafe(Os).pipe(N.orDie), yield* e.unsafe(ks).pipe(N.orDie), yield* e.unsafe(As).pipe(N.orDie);
|
|
1553
1598
|
}), a = () => N.gen(function* () {
|
|
1554
|
-
let e = yield*
|
|
1599
|
+
let e = yield* Mr.SqlClient, n = yield* e`SELECT * FROM ${e(Ts)}`.pipe(N.orElseSucceed(() => []));
|
|
1555
1600
|
for (let r of n) {
|
|
1556
1601
|
let n = yield* e`
|
|
1557
1602
|
SELECT ${e("row_index")} AS row_index, ${e("row_data")} AS row_data
|
|
1558
|
-
FROM ${e(
|
|
1603
|
+
FROM ${e(Es)}
|
|
1559
1604
|
WHERE ${e("aggregate_name")} = ${r.name}
|
|
1560
1605
|
AND ${e("generation")} = ${r.generation}
|
|
1561
1606
|
ORDER BY ${e("row_index")} ASC
|
|
@@ -1565,17 +1610,17 @@ ${a.join("\n\n")}\n`);
|
|
|
1565
1610
|
} catch {}
|
|
1566
1611
|
t.set(r.name, {
|
|
1567
1612
|
rows: i,
|
|
1568
|
-
meta:
|
|
1613
|
+
meta: js(r)
|
|
1569
1614
|
});
|
|
1570
1615
|
}
|
|
1571
1616
|
}), o = (e, t) => N.gen(function* () {
|
|
1572
|
-
let n = yield*
|
|
1617
|
+
let n = yield* Mr.SqlClient, r = (yield* n`
|
|
1573
1618
|
SELECT ${n("generation")} AS generation
|
|
1574
|
-
FROM ${n(
|
|
1619
|
+
FROM ${n(Ts)}
|
|
1575
1620
|
WHERE ${n("name")} = ${e}
|
|
1576
1621
|
`.pipe(N.orElseSucceed(() => [])))[0]?.generation ?? 0, i = r + 1;
|
|
1577
1622
|
yield* n`
|
|
1578
|
-
UPDATE ${n(
|
|
1623
|
+
UPDATE ${n(Ts)} SET
|
|
1579
1624
|
${n("generation")} = ${i},
|
|
1580
1625
|
${n("refreshed_at")} = ${t.meta.refreshedAt ? t.meta.refreshedAt.toISOString() : null},
|
|
1581
1626
|
${n("duration_ms")} = ${t.meta.durationMs},
|
|
@@ -1584,7 +1629,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1584
1629
|
${n("next_refresh_at")} = ${t.meta.nextRefreshAt ? t.meta.nextRefreshAt.toISOString() : null}
|
|
1585
1630
|
WHERE ${n("name")} = ${e}
|
|
1586
1631
|
`.pipe(N.orDie), r === 0 && (yield* n`
|
|
1587
|
-
INSERT INTO ${n(
|
|
1632
|
+
INSERT INTO ${n(Ts)}
|
|
1588
1633
|
(${n("name")}, ${n("generation")}, ${n("refreshed_at")},
|
|
1589
1634
|
${n("duration_ms")}, ${n("row_count")}, ${n("last_error")}, ${n("next_refresh_at")})
|
|
1590
1635
|
VALUES
|
|
@@ -1595,21 +1640,21 @@ ${a.join("\n\n")}\n`);
|
|
|
1595
1640
|
for (let r = 0; r < t.rows.length; r++) {
|
|
1596
1641
|
let a = JSON.stringify(t.rows[r]);
|
|
1597
1642
|
yield* n`
|
|
1598
|
-
INSERT INTO ${n(
|
|
1643
|
+
INSERT INTO ${n(Es)}
|
|
1599
1644
|
(${n("aggregate_name")}, ${n("generation")}, ${n("row_index")}, ${n("row_data")})
|
|
1600
1645
|
VALUES
|
|
1601
1646
|
(${e}, ${i}, ${r}, ${a})
|
|
1602
1647
|
`.pipe(N.orDie);
|
|
1603
1648
|
}
|
|
1604
1649
|
r > 0 && (yield* n`
|
|
1605
|
-
DELETE FROM ${n(
|
|
1650
|
+
DELETE FROM ${n(Es)}
|
|
1606
1651
|
WHERE ${n("aggregate_name")} = ${e}
|
|
1607
1652
|
AND ${n("generation")} < ${i}
|
|
1608
1653
|
`.pipe(N.orDie));
|
|
1609
1654
|
}), s = (e, t) => N.gen(function* () {
|
|
1610
|
-
let n = yield*
|
|
1655
|
+
let n = yield* Mr.SqlClient;
|
|
1611
1656
|
yield* n`
|
|
1612
|
-
UPDATE ${n(
|
|
1657
|
+
UPDATE ${n(Ts)} SET
|
|
1613
1658
|
${n("refreshed_at")} = ${t.refreshedAt ? t.refreshedAt.toISOString() : null},
|
|
1614
1659
|
${n("duration_ms")} = ${t.durationMs},
|
|
1615
1660
|
${n("row_count")} = ${t.rowCount},
|
|
@@ -1617,10 +1662,10 @@ ${a.join("\n\n")}\n`);
|
|
|
1617
1662
|
${n("next_refresh_at")} = ${t.nextRefreshAt ? t.nextRefreshAt.toISOString() : null}
|
|
1618
1663
|
WHERE ${n("name")} = ${e}
|
|
1619
1664
|
`.pipe(N.orDie), (yield* n`
|
|
1620
|
-
SELECT ${n("name")} FROM ${n(
|
|
1665
|
+
SELECT ${n("name")} FROM ${n(Ts)}
|
|
1621
1666
|
WHERE ${n("name")} = ${e}
|
|
1622
1667
|
`.pipe(N.orElseSucceed(() => []))).length === 0 && (yield* n`
|
|
1623
|
-
INSERT INTO ${n(
|
|
1668
|
+
INSERT INTO ${n(Ts)}
|
|
1624
1669
|
(${n("name")}, ${n("generation")}, ${n("refreshed_at")},
|
|
1625
1670
|
${n("duration_ms")}, ${n("row_count")}, ${n("last_error")}, ${n("next_refresh_at")})
|
|
1626
1671
|
VALUES
|
|
@@ -1668,14 +1713,14 @@ ${a.join("\n\n")}\n`);
|
|
|
1668
1713
|
},
|
|
1669
1714
|
refreshMirror: async (e) => {
|
|
1670
1715
|
await r(N.gen(function* () {
|
|
1671
|
-
let n = yield*
|
|
1672
|
-
SELECT * FROM ${n(
|
|
1716
|
+
let n = yield* Mr.SqlClient, r = (yield* n`
|
|
1717
|
+
SELECT * FROM ${n(Ts)}
|
|
1673
1718
|
WHERE ${n("name")} = ${e}
|
|
1674
1719
|
`.pipe(N.orElseSucceed(() => [])))[0];
|
|
1675
1720
|
if (!r) return;
|
|
1676
1721
|
let i = yield* n`
|
|
1677
1722
|
SELECT ${n("row_index")} AS row_index, ${n("row_data")} AS row_data
|
|
1678
|
-
FROM ${n(
|
|
1723
|
+
FROM ${n(Es)}
|
|
1679
1724
|
WHERE ${n("aggregate_name")} = ${e}
|
|
1680
1725
|
AND ${n("generation")} = ${r.generation}
|
|
1681
1726
|
ORDER BY ${n("row_index")} ASC
|
|
@@ -1685,12 +1730,12 @@ ${a.join("\n\n")}\n`);
|
|
|
1685
1730
|
} catch {}
|
|
1686
1731
|
t.set(e, {
|
|
1687
1732
|
rows: a,
|
|
1688
|
-
meta:
|
|
1733
|
+
meta: js(r)
|
|
1689
1734
|
});
|
|
1690
1735
|
}));
|
|
1691
1736
|
}
|
|
1692
1737
|
};
|
|
1693
|
-
},
|
|
1738
|
+
}, Ns = (e) => e.replace(/\.aggregate\.tsx?$/, ""), Ps = async (e, t) => {
|
|
1694
1739
|
let n = [], r = /* @__PURE__ */ new Set();
|
|
1695
1740
|
for (let i of e) {
|
|
1696
1741
|
let e;
|
|
@@ -1709,11 +1754,11 @@ ${a.join("\n\n")}\n`);
|
|
|
1709
1754
|
r.add(a.name), n.push({
|
|
1710
1755
|
file: i,
|
|
1711
1756
|
definition: a
|
|
1712
|
-
}),
|
|
1757
|
+
}), Ns(E(i));
|
|
1713
1758
|
}
|
|
1714
1759
|
return n;
|
|
1715
|
-
},
|
|
1716
|
-
let t =
|
|
1760
|
+
}, Fs = /^(\d+)(ms|s|m|h|d)$/, Is = (e) => {
|
|
1761
|
+
let t = Fs.exec(e.trim());
|
|
1717
1762
|
if (!t) throw Error(`aggregate: invalid refresh interval '${e}' — expected '<n><ms|s|m|h|d>' (e.g. '5m', '1h', '500ms')`);
|
|
1718
1763
|
let n = Number(t[1]);
|
|
1719
1764
|
switch (t[2]) {
|
|
@@ -1724,7 +1769,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1724
1769
|
case "d": return n * 864e5;
|
|
1725
1770
|
}
|
|
1726
1771
|
throw Error("unreachable");
|
|
1727
|
-
},
|
|
1772
|
+
}, Ls = (e, t) => {
|
|
1728
1773
|
if (t === void 0) return e;
|
|
1729
1774
|
let n = Object.entries(t);
|
|
1730
1775
|
return n.length === 0 ? e : e.filter((e) => {
|
|
@@ -1737,23 +1782,23 @@ ${a.join("\n\n")}\n`);
|
|
|
1737
1782
|
}
|
|
1738
1783
|
return !0;
|
|
1739
1784
|
});
|
|
1740
|
-
},
|
|
1785
|
+
}, Rs = (e, t, n) => {
|
|
1741
1786
|
if (t === void 0) return e;
|
|
1742
1787
|
let r = n === "desc" ? -1 : 1;
|
|
1743
1788
|
return [...e].sort((e, n) => {
|
|
1744
1789
|
let i = e[t], a = n[t];
|
|
1745
1790
|
return i === a ? 0 : i == null ? -1 * r : a == null ? 1 * r : i < a ? -1 * r : i > a ? 1 * r : 0;
|
|
1746
1791
|
});
|
|
1747
|
-
},
|
|
1792
|
+
}, zs = (e, t, n) => {
|
|
1748
1793
|
if (n === void 0 && t === void 0) return e;
|
|
1749
1794
|
let r = n ?? 0, i = t === void 0 ? e.length : r + t;
|
|
1750
1795
|
return e.slice(r, i);
|
|
1751
|
-
},
|
|
1796
|
+
}, Bs = (e, t) => {
|
|
1752
1797
|
let n = bt.decodeUnknownEither(e.output), r = [];
|
|
1753
1798
|
for (let e = 0; e < t.length; e++) {
|
|
1754
1799
|
let i = n(t[e]);
|
|
1755
1800
|
if (i._tag === "Left") {
|
|
1756
|
-
let t =
|
|
1801
|
+
let t = _a.formatErrorSync(i.left)[0], n = t?.path?.length ? t.path.join(".") : "<root>";
|
|
1757
1802
|
return {
|
|
1758
1803
|
ok: !1,
|
|
1759
1804
|
reason: `row[${e}] failed output-schema decode at ${n}: ${t?.message ?? "unknown"}`
|
|
@@ -1765,7 +1810,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1765
1810
|
ok: !0,
|
|
1766
1811
|
rows: r
|
|
1767
1812
|
};
|
|
1768
|
-
},
|
|
1813
|
+
}, Vs = (e, t) => {
|
|
1769
1814
|
let n = e.refresh;
|
|
1770
1815
|
if (n.cron) {
|
|
1771
1816
|
let e = n.timezone ?? "UTC", r = mt.unsafeParse(n.cron, e);
|
|
@@ -1776,7 +1821,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1776
1821
|
};
|
|
1777
1822
|
}
|
|
1778
1823
|
if (n.interval) {
|
|
1779
|
-
let e =
|
|
1824
|
+
let e = Is(n.interval);
|
|
1780
1825
|
return {
|
|
1781
1826
|
intervalMs: e,
|
|
1782
1827
|
nextAt: new Date(t.getTime() + e),
|
|
@@ -1792,7 +1837,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1792
1837
|
nextAt: null,
|
|
1793
1838
|
kind: "none"
|
|
1794
1839
|
};
|
|
1795
|
-
},
|
|
1840
|
+
}, Hs = async (e) => {
|
|
1796
1841
|
let { definition: t, store: n, analytics: r, storage: i, coordinator: a, log: o, refreshState: s, scheduledAt: c } = e;
|
|
1797
1842
|
if (s.inFlight) {
|
|
1798
1843
|
o.warn("aggregate: refresh overlap, skipping", { name: t.name });
|
|
@@ -1803,7 +1848,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1803
1848
|
try {
|
|
1804
1849
|
if (!await a.tryClaim(t.name, c)) {
|
|
1805
1850
|
l.info("refresh skipped — coordination claim lost");
|
|
1806
|
-
let { nextAt: e } =
|
|
1851
|
+
let { nextAt: e } = Vs(t, /* @__PURE__ */ new Date()), n = i.get(t.name);
|
|
1807
1852
|
await i.updateMeta(t.name, {
|
|
1808
1853
|
...n.meta,
|
|
1809
1854
|
nextRefreshAt: e
|
|
@@ -1815,7 +1860,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1815
1860
|
analytics: r,
|
|
1816
1861
|
log: l,
|
|
1817
1862
|
id: t.name
|
|
1818
|
-
}), o =
|
|
1863
|
+
}), o = Bs(t, e instanceof Promise ? await e : await N.runPromise(e));
|
|
1819
1864
|
if (!o.ok) throw Error(`output schema mismatch: ${o.reason}`);
|
|
1820
1865
|
let s = o.rows;
|
|
1821
1866
|
if (t.strategy === "merge") {
|
|
@@ -1841,7 +1886,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1841
1886
|
droppedCount: a
|
|
1842
1887
|
}), s = Array.from(r.values());
|
|
1843
1888
|
}
|
|
1844
|
-
let d = Date.now() - u, { nextAt: f } =
|
|
1889
|
+
let d = Date.now() - u, { nextAt: f } = Vs(t, /* @__PURE__ */ new Date()), p = {
|
|
1845
1890
|
refreshedAt: /* @__PURE__ */ new Date(),
|
|
1846
1891
|
rowCount: s.length,
|
|
1847
1892
|
durationMs: d,
|
|
@@ -1858,12 +1903,12 @@ ${a.join("\n\n")}\n`);
|
|
|
1858
1903
|
durationMs: d
|
|
1859
1904
|
});
|
|
1860
1905
|
} catch (e) {
|
|
1861
|
-
let n = e instanceof Error ? `${e.name}: ${e.message}` : String(e), r = i.get(t.name), { nextAt: a } =
|
|
1906
|
+
let n = e instanceof Error ? `${e.name}: ${e.message}` : String(e), r = i.get(t.name), { nextAt: a } = Vs(t, /* @__PURE__ */ new Date());
|
|
1862
1907
|
await i.updateMeta(t.name, {
|
|
1863
1908
|
...r.meta,
|
|
1864
1909
|
lastError: n,
|
|
1865
1910
|
nextRefreshAt: a
|
|
1866
|
-
}), l.warn("refresh failed — last-good rows preserved", { err: n }),
|
|
1911
|
+
}), l.warn("refresh failed — last-good rows preserved", { err: n }), ki({
|
|
1867
1912
|
error: e,
|
|
1868
1913
|
source: "aggregate",
|
|
1869
1914
|
name: t.name
|
|
@@ -1871,23 +1916,23 @@ ${a.join("\n\n")}\n`);
|
|
|
1871
1916
|
} finally {
|
|
1872
1917
|
s.inFlight = !1;
|
|
1873
1918
|
}
|
|
1874
|
-
},
|
|
1919
|
+
}, Us = (e) => {
|
|
1875
1920
|
let { definition: t, schedule: n } = e;
|
|
1876
1921
|
n.scheduleTimer !== null && clearTimeout(n.scheduleTimer);
|
|
1877
|
-
let r = /* @__PURE__ */ new Date(), { intervalMs: i, nextAt: a, kind: o } =
|
|
1922
|
+
let r = /* @__PURE__ */ new Date(), { intervalMs: i, nextAt: a, kind: o } = Vs(t, r);
|
|
1878
1923
|
if (o === "none" && !t.refresh.onChange) {
|
|
1879
1924
|
e.log.warn("aggregate: no refresh policy that auto-fires", { name: t.name });
|
|
1880
1925
|
return;
|
|
1881
1926
|
}
|
|
1882
1927
|
if (a === null) return;
|
|
1883
1928
|
let s = Math.max(0, a.getTime() - r.getTime()), c = setTimeout(async () => {
|
|
1884
|
-
await
|
|
1929
|
+
await Hs({
|
|
1885
1930
|
...e,
|
|
1886
1931
|
scheduledAt: a
|
|
1887
|
-
}),
|
|
1932
|
+
}), Us(e);
|
|
1888
1933
|
}, s);
|
|
1889
1934
|
c.unref(), n.scheduleTimer = c;
|
|
1890
|
-
},
|
|
1935
|
+
}, Ws = (e) => {
|
|
1891
1936
|
let { definition: t, store: n, schedule: r, log: i } = e, a = t.refresh.onChange;
|
|
1892
1937
|
if (!a || a.length === 0) return;
|
|
1893
1938
|
let o = t.refresh.debounceMs ?? 3e4, s = new Set(a);
|
|
@@ -1895,7 +1940,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1895
1940
|
if (!s.has(t.table)) return;
|
|
1896
1941
|
r.debounceTimer !== null && clearTimeout(r.debounceTimer);
|
|
1897
1942
|
let n = setTimeout(async () => {
|
|
1898
|
-
r.debounceTimer = null, await
|
|
1943
|
+
r.debounceTimer = null, await Hs({
|
|
1899
1944
|
...e,
|
|
1900
1945
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
1901
1946
|
});
|
|
@@ -1906,7 +1951,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1906
1951
|
tables: a,
|
|
1907
1952
|
debounceMs: o
|
|
1908
1953
|
});
|
|
1909
|
-
},
|
|
1954
|
+
}, Gs = (e) => {
|
|
1910
1955
|
let { definition: t, store: n, storage: r, log: i, schedule: a } = e, o = t.incremental;
|
|
1911
1956
|
if (o === void 0) return;
|
|
1912
1957
|
let s = i.child(`aggregate:${t.name}`), c = new At({
|
|
@@ -1921,7 +1966,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1921
1966
|
skip: void 0,
|
|
1922
1967
|
projection: void 0
|
|
1923
1968
|
}), u = async () => {
|
|
1924
|
-
let e = c.materialize().map((e) => o.toRow(e)), n =
|
|
1969
|
+
let e = c.materialize().map((e) => o.toRow(e)), n = Bs(t, e);
|
|
1925
1970
|
if (!n.ok) {
|
|
1926
1971
|
s.warn("incremental: output schema mismatch — keeping last-good", { reason: n.reason });
|
|
1927
1972
|
return;
|
|
@@ -1965,12 +2010,12 @@ ${a.join("\n\n")}\n`);
|
|
|
1965
2010
|
op: o.op
|
|
1966
2011
|
});
|
|
1967
2012
|
})();
|
|
1968
|
-
let p = t.refresh, m = p.interval === void 0 ? 5 * 6e4 :
|
|
2013
|
+
let p = t.refresh, m = p.interval === void 0 ? 5 * 6e4 : Is(p.interval), h = setInterval(() => {
|
|
1969
2014
|
d().catch(() => void 0);
|
|
1970
2015
|
}, m);
|
|
1971
2016
|
h.unref(), a.scheduleTimer = h;
|
|
1972
|
-
},
|
|
1973
|
-
let t = e.storage ??
|
|
2017
|
+
}, Ks = async (e) => {
|
|
2018
|
+
let t = e.storage ?? Ds(), n = e.coordinator ?? yr, r = e.analytics ?? B(), i = e.log;
|
|
1974
2019
|
await t.initialize();
|
|
1975
2020
|
let a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = {
|
|
1976
2021
|
refreshedAt: null,
|
|
@@ -1989,7 +2034,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1989
2034
|
detachOnChange: null
|
|
1990
2035
|
};
|
|
1991
2036
|
a.set(u.name, f), u.incremental !== void 0 || (u.bootRefresh === "async" ? (await t.updateMeta(u.name, c), setImmediate(async () => {
|
|
1992
|
-
await
|
|
2037
|
+
await Hs({
|
|
1993
2038
|
definition: u,
|
|
1994
2039
|
store: e.store,
|
|
1995
2040
|
analytics: r,
|
|
@@ -2000,7 +2045,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2000
2045
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
2001
2046
|
});
|
|
2002
2047
|
})) : u.bootRefresh === "sync" ? l.push(async () => {
|
|
2003
|
-
await
|
|
2048
|
+
await Hs({
|
|
2004
2049
|
definition: u,
|
|
2005
2050
|
store: e.store,
|
|
2006
2051
|
analytics: r,
|
|
@@ -2011,7 +2056,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2011
2056
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
2012
2057
|
});
|
|
2013
2058
|
}) : await t.load(u.name) === null && setImmediate(async () => {
|
|
2014
|
-
await
|
|
2059
|
+
await Hs({
|
|
2015
2060
|
definition: u,
|
|
2016
2061
|
store: e.store,
|
|
2017
2062
|
analytics: r,
|
|
@@ -2021,7 +2066,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2021
2066
|
refreshState: d,
|
|
2022
2067
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
2023
2068
|
});
|
|
2024
|
-
})), u.incremental === void 0 ? (
|
|
2069
|
+
})), u.incremental === void 0 ? (Us({
|
|
2025
2070
|
definition: u,
|
|
2026
2071
|
store: e.store,
|
|
2027
2072
|
analytics: r,
|
|
@@ -2030,7 +2075,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2030
2075
|
log: i,
|
|
2031
2076
|
schedule: f,
|
|
2032
2077
|
refreshState: d
|
|
2033
|
-
}),
|
|
2078
|
+
}), Ws({
|
|
2034
2079
|
definition: u,
|
|
2035
2080
|
store: e.store,
|
|
2036
2081
|
analytics: r,
|
|
@@ -2039,7 +2084,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2039
2084
|
log: i,
|
|
2040
2085
|
schedule: f,
|
|
2041
2086
|
refreshState: d
|
|
2042
|
-
})) :
|
|
2087
|
+
})) : Gs({
|
|
2043
2088
|
definition: u,
|
|
2044
2089
|
store: e.store,
|
|
2045
2090
|
storage: t,
|
|
@@ -2063,11 +2108,11 @@ ${a.join("\n\n")}\n`);
|
|
|
2063
2108
|
maxAgeMs: e.maxAgeMs
|
|
2064
2109
|
}));
|
|
2065
2110
|
}
|
|
2066
|
-
return
|
|
2111
|
+
return zs(Rs(Ls(n.rows, e?.where), e?.orderBy, e?.direction), e?.limit, e?.offset);
|
|
2067
2112
|
}),
|
|
2068
2113
|
meta: () => N.succeed(t.get(a.name).meta),
|
|
2069
2114
|
refresh: () => N.tryPromise({
|
|
2070
|
-
try: () =>
|
|
2115
|
+
try: () => Hs({
|
|
2071
2116
|
definition: s.get(a.name),
|
|
2072
2117
|
store: e.store,
|
|
2073
2118
|
analytics: r,
|
|
@@ -2095,7 +2140,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2095
2140
|
})),
|
|
2096
2141
|
refreshByName: async (a) => {
|
|
2097
2142
|
let c = s.get(a);
|
|
2098
|
-
return c ? (await
|
|
2143
|
+
return c ? (await Hs({
|
|
2099
2144
|
definition: c,
|
|
2100
2145
|
store: e.store,
|
|
2101
2146
|
analytics: r,
|
|
@@ -2117,7 +2162,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2117
2162
|
},
|
|
2118
2163
|
registered: Array.from(s.keys())
|
|
2119
2164
|
};
|
|
2120
|
-
},
|
|
2165
|
+
}, qs = {
|
|
2121
2166
|
getHandle: (e) => ({
|
|
2122
2167
|
read: () => N.fail(new jt({ name: e.name })),
|
|
2123
2168
|
meta: () => N.succeed({
|
|
@@ -2131,52 +2176,52 @@ ${a.join("\n\n")}\n`);
|
|
|
2131
2176
|
}),
|
|
2132
2177
|
snapshot: () => [],
|
|
2133
2178
|
refreshByName: async () => !1
|
|
2134
|
-
},
|
|
2179
|
+
}, Js = "/_voltro/inspect/aggregates", Ys = /^\/_voltro\/inspect\/aggregates\/([^/]+)\/refresh$/, Xs = (e, t, n) => ({
|
|
2135
2180
|
status: e,
|
|
2136
2181
|
contentType: "application/json; charset=utf-8",
|
|
2137
2182
|
body: JSON.stringify(t),
|
|
2138
2183
|
...n ? { headers: n } : {}
|
|
2139
|
-
}),
|
|
2184
|
+
}), Zs = (e) => ({
|
|
2140
2185
|
refreshedAt: e.refreshedAt === null ? null : e.refreshedAt.toISOString(),
|
|
2141
2186
|
rowCount: e.rowCount,
|
|
2142
2187
|
durationMs: e.durationMs,
|
|
2143
2188
|
lastError: e.lastError,
|
|
2144
2189
|
nextRefreshAt: e.nextRefreshAt === null ? null : e.nextRefreshAt.toISOString()
|
|
2145
|
-
}),
|
|
2146
|
-
if (!e.startsWith(
|
|
2190
|
+
}), Qs = async (e, t, n, r) => {
|
|
2191
|
+
if (!e.startsWith(Js)) return null;
|
|
2147
2192
|
if (t === "POST") {
|
|
2148
|
-
let t =
|
|
2193
|
+
let t = Ys.exec(e);
|
|
2149
2194
|
if (t) {
|
|
2150
2195
|
let e = decodeURIComponent(t[1]);
|
|
2151
|
-
if (!await n.refreshByName(e)) return
|
|
2196
|
+
if (!await n.refreshByName(e)) return Xs(404, {
|
|
2152
2197
|
error: "aggregate not found",
|
|
2153
2198
|
name: e
|
|
2154
2199
|
}, r);
|
|
2155
2200
|
let i = n.snapshot().find((t) => t.name === e);
|
|
2156
|
-
return
|
|
2201
|
+
return Xs(200, {
|
|
2157
2202
|
ok: !0,
|
|
2158
2203
|
name: e,
|
|
2159
|
-
meta: i ?
|
|
2204
|
+
meta: i ? Zs(i.meta) : null
|
|
2160
2205
|
}, r);
|
|
2161
2206
|
}
|
|
2162
|
-
return
|
|
2207
|
+
return Xs(405, {
|
|
2163
2208
|
error: "method not allowed",
|
|
2164
2209
|
allow: "GET, POST <name>/refresh"
|
|
2165
2210
|
}, r);
|
|
2166
2211
|
}
|
|
2167
|
-
return t === "GET" && (e ===
|
|
2212
|
+
return t === "GET" && (e === Js || e.startsWith(`${Js}?`)) ? Xs(200, {
|
|
2168
2213
|
aggregates: n.snapshot().map((e) => ({
|
|
2169
2214
|
name: e.name,
|
|
2170
|
-
meta:
|
|
2215
|
+
meta: Zs(e.meta)
|
|
2171
2216
|
})),
|
|
2172
2217
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2173
2218
|
}, r) : null;
|
|
2174
|
-
},
|
|
2219
|
+
}, $s = "/_voltro/inspect/analytics", ec = (e, t, n) => ({
|
|
2175
2220
|
status: e,
|
|
2176
2221
|
contentType: "application/json; charset=utf-8",
|
|
2177
2222
|
body: JSON.stringify(t),
|
|
2178
2223
|
...n ? { headers: n } : {}
|
|
2179
|
-
}),
|
|
2224
|
+
}), tc = (e, t) => {
|
|
2180
2225
|
let n = e.snapshot(t).buckets.filter((e) => e.kind === "plugin"), r = 0, i = 0, a = n.map((e) => (r += e.count, i += e.errorCount, {
|
|
2181
2226
|
tag: e.tag,
|
|
2182
2227
|
count: e.count,
|
|
@@ -2189,9 +2234,9 @@ ${a.join("\n\n")}\n`);
|
|
|
2189
2234
|
errorCount: i,
|
|
2190
2235
|
tags: a
|
|
2191
2236
|
};
|
|
2192
|
-
},
|
|
2193
|
-
if (e !==
|
|
2194
|
-
if (t !== "GET") return
|
|
2237
|
+
}, nc = (e, t, n, r) => {
|
|
2238
|
+
if (e !== $s && !e.startsWith(`${$s}?`)) return null;
|
|
2239
|
+
if (t !== "GET") return ec(405, {
|
|
2195
2240
|
error: "method not allowed",
|
|
2196
2241
|
allow: "GET"
|
|
2197
2242
|
}, r);
|
|
@@ -2200,8 +2245,8 @@ ${a.join("\n\n")}\n`);
|
|
|
2200
2245
|
if (e === null) return 6e4;
|
|
2201
2246
|
let t = Number(e);
|
|
2202
2247
|
return Number.isFinite(t) && t > 0 ? Math.min(t, 1440 * 6e4) : 6e4;
|
|
2203
|
-
})(), s =
|
|
2204
|
-
return
|
|
2248
|
+
})(), s = tc(n.metricsCollector, o);
|
|
2249
|
+
return ec(200, {
|
|
2205
2250
|
provider: n.sink.info.provider,
|
|
2206
2251
|
capabilities: n.sink.info.capabilities,
|
|
2207
2252
|
detail: n.sink.info.detail ?? null,
|
|
@@ -2213,40 +2258,40 @@ ${a.join("\n\n")}\n`);
|
|
|
2213
2258
|
},
|
|
2214
2259
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2215
2260
|
}, r);
|
|
2216
|
-
},
|
|
2261
|
+
}, rc = "/_voltro/inspect/timeline", ic = "/_voltro/inspect/timeline/replay", ac = (e, t, n) => ({
|
|
2217
2262
|
status: e,
|
|
2218
2263
|
contentType: "application/json; charset=utf-8",
|
|
2219
2264
|
body: JSON.stringify(t),
|
|
2220
2265
|
...n ? { headers: n } : {}
|
|
2221
|
-
}),
|
|
2266
|
+
}), oc = (e) => {
|
|
2222
2267
|
let t = e.indexOf("?");
|
|
2223
2268
|
return new URLSearchParams(t >= 0 ? e.slice(t + 1) : "");
|
|
2224
|
-
},
|
|
2269
|
+
}, sc = (e, t) => {
|
|
2225
2270
|
let n = e.get(t);
|
|
2226
2271
|
if (n === null) return;
|
|
2227
2272
|
let r = Number(n);
|
|
2228
2273
|
return Number.isFinite(r) ? r : void 0;
|
|
2229
|
-
},
|
|
2230
|
-
if (!e.startsWith(
|
|
2231
|
-
if (t !== "GET") return
|
|
2274
|
+
}, cc = async (e, t, n, r) => {
|
|
2275
|
+
if (!e.startsWith(rc)) return null;
|
|
2276
|
+
if (t !== "GET") return ac(405, {
|
|
2232
2277
|
error: "method not allowed",
|
|
2233
2278
|
allow: "GET"
|
|
2234
2279
|
}, r);
|
|
2235
|
-
let i =
|
|
2236
|
-
if (e ===
|
|
2237
|
-
let e = i.get("table"), t =
|
|
2238
|
-
if (e === null || t === void 0) return
|
|
2280
|
+
let i = oc(e);
|
|
2281
|
+
if (e === ic || e.startsWith(`${ic}?`)) {
|
|
2282
|
+
let e = i.get("table"), t = sc(i, "seq");
|
|
2283
|
+
if (e === null || t === void 0) return ac(400, { error: "replay requires ?table=<name>&seq=<n>" }, r);
|
|
2239
2284
|
let a;
|
|
2240
2285
|
try {
|
|
2241
2286
|
a = await n.readCurrentRows(e);
|
|
2242
2287
|
} catch (t) {
|
|
2243
|
-
return
|
|
2288
|
+
return ac(404, {
|
|
2244
2289
|
error: "unknown or unreadable table",
|
|
2245
2290
|
table: e,
|
|
2246
2291
|
reason: String(t?.message ?? t)
|
|
2247
2292
|
}, r);
|
|
2248
2293
|
}
|
|
2249
|
-
return
|
|
2294
|
+
return ac(200, {
|
|
2250
2295
|
table: e,
|
|
2251
2296
|
asOfSeq: t,
|
|
2252
2297
|
currentSeq: n.recorder.currentSeq(),
|
|
@@ -2254,15 +2299,15 @@ ${a.join("\n\n")}\n`);
|
|
|
2254
2299
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2255
2300
|
}, r);
|
|
2256
2301
|
}
|
|
2257
|
-
if (e ===
|
|
2258
|
-
let e = i.get("table"), t = i.get("tenantId"), a =
|
|
2302
|
+
if (e === rc || e.startsWith(`${rc}?`)) {
|
|
2303
|
+
let e = i.get("table"), t = i.get("tenantId"), a = sc(i, "from"), o = sc(i, "to"), s = sc(i, "limit"), c = {
|
|
2259
2304
|
...e === null ? {} : { table: e },
|
|
2260
2305
|
...t === null ? {} : { tenantId: t },
|
|
2261
2306
|
...a === void 0 ? {} : { from: a },
|
|
2262
2307
|
...o === void 0 ? {} : { to: o },
|
|
2263
2308
|
...s === void 0 ? {} : { limit: s }
|
|
2264
2309
|
};
|
|
2265
|
-
return
|
|
2310
|
+
return ac(200, {
|
|
2266
2311
|
enabled: n.recorder.enabled,
|
|
2267
2312
|
currentSeq: n.recorder.currentSeq(),
|
|
2268
2313
|
events: n.recorder.snapshot(c),
|
|
@@ -2270,7 +2315,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2270
2315
|
}, r);
|
|
2271
2316
|
}
|
|
2272
2317
|
return null;
|
|
2273
|
-
},
|
|
2318
|
+
}, lc = /\.webhook\.tsx?$/, uc = async (e, t) => {
|
|
2274
2319
|
let n = [], r = [], i = [];
|
|
2275
2320
|
for (let a of e) {
|
|
2276
2321
|
let e;
|
|
@@ -2280,7 +2325,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2280
2325
|
t.warn("webhook: failed to import", { file: a }, e);
|
|
2281
2326
|
continue;
|
|
2282
2327
|
}
|
|
2283
|
-
let o = (e.default &&
|
|
2328
|
+
let o = (e.default && Sa(e.default) ? e.default : void 0) ?? Object.values(e).find(Sa);
|
|
2284
2329
|
if (!o) {
|
|
2285
2330
|
t.warn("webhook: no descriptor default-exported", { file: a });
|
|
2286
2331
|
continue;
|
|
@@ -2311,7 +2356,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2311
2356
|
incoming: r,
|
|
2312
2357
|
providers: i
|
|
2313
2358
|
};
|
|
2314
|
-
},
|
|
2359
|
+
}, dc = /\.email\.tsx?$/, fc = async (e, t) => {
|
|
2315
2360
|
let n = [];
|
|
2316
2361
|
for (let r of e) {
|
|
2317
2362
|
let e;
|
|
@@ -2321,7 +2366,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2321
2366
|
t.warn("email: failed to import", { file: r }, e);
|
|
2322
2367
|
continue;
|
|
2323
2368
|
}
|
|
2324
|
-
let i = Object.values(e).filter(
|
|
2369
|
+
let i = Object.values(e).filter(wa);
|
|
2325
2370
|
if (i.length === 0) {
|
|
2326
2371
|
t.warn("email: no defineEmail export found", { file: r });
|
|
2327
2372
|
continue;
|
|
@@ -2332,15 +2377,15 @@ ${a.join("\n\n")}\n`);
|
|
|
2332
2377
|
});
|
|
2333
2378
|
}
|
|
2334
2379
|
return { templates: n };
|
|
2335
|
-
},
|
|
2336
|
-
let { descriptor: t, executor: n, file: r } = e, { send: i, messages: a } =
|
|
2380
|
+
}, pc = (e) => N.map(e, (e) => ({ text: e })), mc = (e) => {
|
|
2381
|
+
let { descriptor: t, executor: n, file: r } = e, { send: i, messages: a } = ha(t);
|
|
2337
2382
|
return [{
|
|
2338
2383
|
kind: "action",
|
|
2339
2384
|
file: r,
|
|
2340
2385
|
descriptor: i,
|
|
2341
2386
|
executor: (e, t) => {
|
|
2342
2387
|
let { threadId: r, order: i } = e, a = t.request?.subject?.tenantId ?? null;
|
|
2343
|
-
return
|
|
2388
|
+
return Xr(n, t.store, {
|
|
2344
2389
|
threadId: r,
|
|
2345
2390
|
input: e,
|
|
2346
2391
|
tenantId: a,
|
|
@@ -2349,36 +2394,36 @@ ${a.join("\n\n")}\n`);
|
|
|
2349
2394
|
store: t.store,
|
|
2350
2395
|
request: t.request
|
|
2351
2396
|
}
|
|
2352
|
-
}).pipe(
|
|
2397
|
+
}).pipe(pc);
|
|
2353
2398
|
}
|
|
2354
2399
|
}, {
|
|
2355
2400
|
kind: "query",
|
|
2356
2401
|
file: r,
|
|
2357
2402
|
descriptor: a,
|
|
2358
|
-
executor: (e, t) =>
|
|
2403
|
+
executor: (e, t) => Yr(t.store, e.threadId)
|
|
2359
2404
|
}];
|
|
2360
|
-
},
|
|
2405
|
+
}, hc = "<builtin:undo>", gc = () => Tr() ? {
|
|
2361
2406
|
queries: [{
|
|
2362
|
-
file:
|
|
2363
|
-
descriptor:
|
|
2407
|
+
file: hc,
|
|
2408
|
+
descriptor: Pi,
|
|
2364
2409
|
executor: (e, t) => Er(e, t)
|
|
2365
2410
|
}],
|
|
2366
2411
|
mutations: [{
|
|
2367
|
-
file:
|
|
2368
|
-
descriptor:
|
|
2412
|
+
file: hc,
|
|
2413
|
+
descriptor: Ni,
|
|
2369
2414
|
executor: (e, t) => Ut(e, t)
|
|
2370
2415
|
}, {
|
|
2371
|
-
file:
|
|
2372
|
-
descriptor:
|
|
2416
|
+
file: hc,
|
|
2417
|
+
descriptor: Fi,
|
|
2373
2418
|
executor: (e, t) => ar(e, t)
|
|
2374
2419
|
}]
|
|
2375
2420
|
} : {
|
|
2376
2421
|
queries: [],
|
|
2377
2422
|
mutations: []
|
|
2378
|
-
},
|
|
2423
|
+
}, _c = () => Tr() ? (e) => qn(e) : (e) => ({
|
|
2379
2424
|
tx: e,
|
|
2380
2425
|
persist: async () => {}
|
|
2381
|
-
}),
|
|
2426
|
+
}), vc = {
|
|
2382
2427
|
interceptMutation: "rpc:intercept:mutation",
|
|
2383
2428
|
interceptQuery: "rpc:intercept:query",
|
|
2384
2429
|
interceptAction: "rpc:intercept:action",
|
|
@@ -2388,38 +2433,38 @@ ${a.join("\n\n")}\n`);
|
|
|
2388
2433
|
onChangeEvent: "store:changes:read",
|
|
2389
2434
|
inspectEndpoints: "inspect:read",
|
|
2390
2435
|
dashboard: "dashboard:mount"
|
|
2391
|
-
},
|
|
2436
|
+
}, yc = {
|
|
2392
2437
|
tables: "store:write",
|
|
2393
2438
|
migrations: "migration:run"
|
|
2394
|
-
},
|
|
2439
|
+
}, bc = (e) => {
|
|
2395
2440
|
let t = new Set(e.permissions ?? []), n = [];
|
|
2396
|
-
for (let [r, i] of Object.entries(
|
|
2441
|
+
for (let [r, i] of Object.entries(vc)) {
|
|
2397
2442
|
let a = e[r];
|
|
2398
2443
|
a !== void 0 && (Array.isArray(a) && a.length === 0 || t.has(i) || n.push({
|
|
2399
2444
|
hook: r,
|
|
2400
2445
|
required: i
|
|
2401
2446
|
}));
|
|
2402
2447
|
}
|
|
2403
|
-
return e.extendSchema !== void 0 && (e.extendSchema.tables && e.extendSchema.tables.length > 0 && (t.has(
|
|
2448
|
+
return e.extendSchema !== void 0 && (e.extendSchema.tables && e.extendSchema.tables.length > 0 && (t.has(yc.tables) || n.push({
|
|
2404
2449
|
hook: "extendSchema.tables",
|
|
2405
|
-
required:
|
|
2406
|
-
})), e.extendSchema.migrations && e.extendSchema.migrations.length > 0 && (t.has(
|
|
2450
|
+
required: yc.tables
|
|
2451
|
+
})), e.extendSchema.migrations && e.extendSchema.migrations.length > 0 && (t.has(yc.migrations) || n.push({
|
|
2407
2452
|
hook: "extendSchema.migrations",
|
|
2408
|
-
required:
|
|
2453
|
+
required: yc.migrations
|
|
2409
2454
|
}))), {
|
|
2410
2455
|
pluginName: e.name,
|
|
2411
2456
|
missing: n
|
|
2412
2457
|
};
|
|
2413
|
-
},
|
|
2414
|
-
let t = e.map(
|
|
2458
|
+
}, xc = (e) => {
|
|
2459
|
+
let t = e.map(bc);
|
|
2415
2460
|
return {
|
|
2416
2461
|
ok: t.every((e) => e.missing.length === 0),
|
|
2417
2462
|
reports: t
|
|
2418
2463
|
};
|
|
2419
|
-
},
|
|
2464
|
+
}, Sc = (e) => {
|
|
2420
2465
|
let t = e.reports.filter((e) => e.missing.length > 0);
|
|
2421
2466
|
return [`Plugin permission audit failed — ${t.length} plugin(s) ship hooks without the matching declared permission. Add the missing scopes to each plugin's manifest.permissions array:`, ...t.map((e) => ` • ${e.pluginName}:\n` + e.missing.map((e) => ` - ${e.hook} → needs '${e.required}'`).join("\n"))].join("\n");
|
|
2422
|
-
},
|
|
2467
|
+
}, Cc = 5e3, wc = 3e4, Tc = async (e, t) => {
|
|
2423
2468
|
let n, r = new Promise((e) => {
|
|
2424
2469
|
n = setTimeout(() => e({ kind: "timeout" }), t);
|
|
2425
2470
|
});
|
|
@@ -2434,7 +2479,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2434
2479
|
} finally {
|
|
2435
2480
|
n && clearTimeout(n);
|
|
2436
2481
|
}
|
|
2437
|
-
},
|
|
2482
|
+
}, Ec = async (e) => {
|
|
2438
2483
|
if (e !== void 0) {
|
|
2439
2484
|
if (typeof e == "object" && e && N.isEffect(e)) {
|
|
2440
2485
|
await N.runPromise(e);
|
|
@@ -2442,8 +2487,8 @@ ${a.join("\n\n")}\n`);
|
|
|
2442
2487
|
}
|
|
2443
2488
|
await Promise.resolve(e);
|
|
2444
2489
|
}
|
|
2445
|
-
},
|
|
2446
|
-
let t = e.deactivateTimeoutMs ??
|
|
2490
|
+
}, Dc = /* @__PURE__ */ new Set(), Oc = (e) => `${e.name}@${e.version ?? "*"}`, kc = (e) => {
|
|
2491
|
+
let t = e.deactivateTimeoutMs ?? Cc, n = e.deactivateTotalBudgetMs ?? wc, r = /* @__PURE__ */ new Set(), i = !1, a = /* @__PURE__ */ new Map();
|
|
2447
2492
|
for (let t of e.plugins) {
|
|
2448
2493
|
if (!t.configSchema) {
|
|
2449
2494
|
a.set(t.name, e.pluginConfigs?.[t.name]);
|
|
@@ -2469,14 +2514,14 @@ ${a.join("\n\n")}\n`);
|
|
|
2469
2514
|
});
|
|
2470
2515
|
return {
|
|
2471
2516
|
async activate() {
|
|
2472
|
-
let t =
|
|
2517
|
+
let t = xc(e.plugins);
|
|
2473
2518
|
if (!t.ok) {
|
|
2474
|
-
let n =
|
|
2519
|
+
let n = Sc(t);
|
|
2475
2520
|
throw e.log.error(n), Error(n);
|
|
2476
2521
|
}
|
|
2477
2522
|
let n = (process.env.VOLTRO_STRICT_PLUGIN_COMPAT ?? "").toLowerCase(), i = n === "1" || n === "true";
|
|
2478
2523
|
for (let t of e.plugins) {
|
|
2479
|
-
let n =
|
|
2524
|
+
let n = bi(t.name, t.framework, e.voltroVersion);
|
|
2480
2525
|
if (!n.ok) {
|
|
2481
2526
|
if (i) {
|
|
2482
2527
|
let r = `plugin "${t.name}" is incompatible with framework ${e.voltroVersion}: ${n.reason}. Pin a compatible plugin version, or unset VOLTRO_STRICT_PLUGIN_COMPAT to downgrade this to a warning.`;
|
|
@@ -2486,10 +2531,10 @@ ${a.join("\n\n")}\n`);
|
|
|
2486
2531
|
}
|
|
2487
2532
|
}
|
|
2488
2533
|
for (let t of e.plugins) {
|
|
2489
|
-
let n =
|
|
2490
|
-
if (!
|
|
2534
|
+
let n = Oc(t);
|
|
2535
|
+
if (!Dc.has(n) && typeof t.onInstall == "function") try {
|
|
2491
2536
|
let e = o(t);
|
|
2492
|
-
await Promise.resolve().then(() =>
|
|
2537
|
+
await Promise.resolve().then(() => Ec(t.onInstall(e))), Dc.add(n);
|
|
2493
2538
|
} catch (n) {
|
|
2494
2539
|
throw e.log.error("plugin onInstall threw — aborting boot", {
|
|
2495
2540
|
plugin: t.name,
|
|
@@ -2503,7 +2548,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2503
2548
|
}
|
|
2504
2549
|
try {
|
|
2505
2550
|
let e = o(t);
|
|
2506
|
-
await Promise.resolve().then(() =>
|
|
2551
|
+
await Promise.resolve().then(() => Ec(t.onActivate(e))), r.add(t.name);
|
|
2507
2552
|
} catch (n) {
|
|
2508
2553
|
throw e.log.error("plugin onActivate threw — aborting boot", {
|
|
2509
2554
|
plugin: t.name,
|
|
@@ -2526,7 +2571,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2526
2571
|
});
|
|
2527
2572
|
break;
|
|
2528
2573
|
}
|
|
2529
|
-
let c = o(i), l = i.onDeactivate, u = await
|
|
2574
|
+
let c = o(i), l = i.onDeactivate, u = await Tc(Promise.resolve().then(() => Ec(l(c))), t);
|
|
2530
2575
|
u.kind === "rejected" ? e.log.warn("plugin onDeactivate threw", {
|
|
2531
2576
|
plugin: i.name,
|
|
2532
2577
|
err: u.err
|
|
@@ -2603,16 +2648,16 @@ ${a.join("\n\n")}\n`);
|
|
|
2603
2648
|
services: e.services !== void 0,
|
|
2604
2649
|
hasConfigSchema: e.configSchema !== void 0,
|
|
2605
2650
|
activated: r.has(e.name),
|
|
2606
|
-
installed:
|
|
2651
|
+
installed: Dc.has(Oc(e))
|
|
2607
2652
|
}));
|
|
2608
2653
|
}
|
|
2609
2654
|
};
|
|
2610
|
-
},
|
|
2655
|
+
}, Ac = {
|
|
2611
2656
|
mutation: "intercept-mutation",
|
|
2612
2657
|
query: "intercept-query",
|
|
2613
2658
|
action: "intercept-action"
|
|
2614
|
-
},
|
|
2615
|
-
let i =
|
|
2659
|
+
}, jc = (e, t, n, r) => {
|
|
2660
|
+
let i = Ac[t], a = `plugin.${e}.${i}`, o = a;
|
|
2616
2661
|
return (t, s) => N.suspend(() => {
|
|
2617
2662
|
let c = Date.now();
|
|
2618
2663
|
return n(t, s).pipe(N.withSpan(a, { attributes: {
|
|
@@ -2636,17 +2681,17 @@ ${a.join("\n\n")}\n`);
|
|
|
2636
2681
|
});
|
|
2637
2682
|
})));
|
|
2638
2683
|
});
|
|
2639
|
-
},
|
|
2684
|
+
}, Mc = (e, t, n) => {
|
|
2640
2685
|
let r = t === "mutation" ? "interceptMutation" : t === "query" ? "interceptQuery" : "interceptAction", i = [];
|
|
2641
2686
|
for (let a of e) {
|
|
2642
2687
|
let e = a[r];
|
|
2643
|
-
typeof e == "function" && i.push(
|
|
2688
|
+
typeof e == "function" && i.push(jc(a.name, t, e, n));
|
|
2644
2689
|
}
|
|
2645
2690
|
return i;
|
|
2646
|
-
},
|
|
2691
|
+
}, Nc = `${w}/plugins/`, Pc = (e) => e.startsWith("/") ? e : `/${e}`, Fc = (e) => {
|
|
2647
2692
|
let t = e.indexOf("?");
|
|
2648
2693
|
return t >= 0 ? e.slice(0, t) : e;
|
|
2649
|
-
},
|
|
2694
|
+
}, Ic = (e, t) => e.kind === "json" ? {
|
|
2650
2695
|
status: e.status ?? 200,
|
|
2651
2696
|
contentType: "application/json; charset=utf-8",
|
|
2652
2697
|
body: JSON.stringify(e.data),
|
|
@@ -2656,12 +2701,12 @@ ${a.join("\n\n")}\n`);
|
|
|
2656
2701
|
contentType: e.contentType ?? "text/plain; charset=utf-8",
|
|
2657
2702
|
body: e.body,
|
|
2658
2703
|
headers: t
|
|
2659
|
-
},
|
|
2704
|
+
}, Lc = (e) => {
|
|
2660
2705
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
2661
2706
|
for (let r of e) {
|
|
2662
2707
|
let e = r.inspectEndpoints ?? [], i = x(r.name);
|
|
2663
2708
|
for (let a of e) {
|
|
2664
|
-
let e = `${
|
|
2709
|
+
let e = `${Nc}${i}${Pc(a.path)}`, o = `${a.method} ${e}`, s = t.get(o);
|
|
2665
2710
|
if (s !== void 0) throw Error(`plugin inspect endpoint collision: "${a.method} ${e}" declared by plugin "${r.name}" but already claimed by ${s}`);
|
|
2666
2711
|
t.set(o, `plugin "${r.name}"`), n.push({
|
|
2667
2712
|
method: a.method,
|
|
@@ -2675,8 +2720,8 @@ ${a.join("\n\n")}\n`);
|
|
|
2675
2720
|
return {
|
|
2676
2721
|
endpoints: n,
|
|
2677
2722
|
async dispatch(e, t, r, i, a) {
|
|
2678
|
-
let o =
|
|
2679
|
-
if (!o.startsWith(
|
|
2723
|
+
let o = Fc(e);
|
|
2724
|
+
if (!o.startsWith(Nc)) return null;
|
|
2680
2725
|
let s = T(r.origin ?? r.Origin), c = t.toUpperCase();
|
|
2681
2726
|
if (c === "OPTIONS") return {
|
|
2682
2727
|
status: 204,
|
|
@@ -2703,7 +2748,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2703
2748
|
let u = n.find((e) => e.method === c && e.path === o);
|
|
2704
2749
|
if (!u) return null;
|
|
2705
2750
|
try {
|
|
2706
|
-
return
|
|
2751
|
+
return Ic(await N.runPromise(u.handler({
|
|
2707
2752
|
method: c,
|
|
2708
2753
|
url: e,
|
|
2709
2754
|
headers: r,
|
|
@@ -2723,7 +2768,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2723
2768
|
}
|
|
2724
2769
|
}
|
|
2725
2770
|
};
|
|
2726
|
-
},
|
|
2771
|
+
}, Rc = (e, t, n) => {
|
|
2727
2772
|
let r = `plugin.${e}.schedule-fire`;
|
|
2728
2773
|
return async (i, a) => {
|
|
2729
2774
|
let o = Date.now();
|
|
@@ -2751,9 +2796,9 @@ ${a.join("\n\n")}\n`);
|
|
|
2751
2796
|
}), e;
|
|
2752
2797
|
}
|
|
2753
2798
|
};
|
|
2754
|
-
},
|
|
2799
|
+
}, zc = (e, t) => {
|
|
2755
2800
|
let n = [];
|
|
2756
|
-
for (let r of e) typeof r.onScheduleFire == "function" && n.push(
|
|
2801
|
+
for (let r of e) typeof r.onScheduleFire == "function" && n.push(Rc(r.name, r.onScheduleFire, t));
|
|
2757
2802
|
if (n.length !== 0) return async (e, t) => {
|
|
2758
2803
|
let r = e;
|
|
2759
2804
|
for (let e = n.length - 1; e >= 0; e--) {
|
|
@@ -2762,7 +2807,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2762
2807
|
}
|
|
2763
2808
|
return r();
|
|
2764
2809
|
};
|
|
2765
|
-
},
|
|
2810
|
+
}, Bc = (e, t, n) => ((r, i) => {
|
|
2766
2811
|
let a = `plugin.${e}.workflow-step`, o = a, s = Date.now();
|
|
2767
2812
|
return t(r, i).pipe(N.withSpan(a, { attributes: {
|
|
2768
2813
|
"plugin.name": e,
|
|
@@ -2785,16 +2830,16 @@ ${a.join("\n\n")}\n`);
|
|
|
2785
2830
|
status: "error"
|
|
2786
2831
|
});
|
|
2787
2832
|
})));
|
|
2788
|
-
}),
|
|
2833
|
+
}), Vc = (e, t) => {
|
|
2789
2834
|
let n = [];
|
|
2790
|
-
for (let r of e) typeof r.onWorkflowStep == "function" && n.push(
|
|
2791
|
-
return n.length === 0 ? P.succeed(
|
|
2792
|
-
},
|
|
2835
|
+
for (let r of e) typeof r.onWorkflowStep == "function" && n.push(Bc(r.name, r.onWorkflowStep, t));
|
|
2836
|
+
return n.length === 0 ? P.succeed(Pr, { interceptor: ((e) => e) }) : P.succeed(Pr, { interceptor: ((e, t) => n.reduceRight((e, n) => n(e, t), e)) });
|
|
2837
|
+
}, Hc = (e) => {
|
|
2793
2838
|
if (!e) return;
|
|
2794
2839
|
let t = e.workflowName ?? e.tag, n = [];
|
|
2795
|
-
if (t !== void 0 && n.push(
|
|
2796
|
-
},
|
|
2797
|
-
let n = Math.max(0, t?.offset ?? 0), r = Math.max(1, Math.min(500, t?.limit ?? 50)), i =
|
|
2840
|
+
if (t !== void 0 && n.push(V("tag", t)), e.status !== void 0 && n.push(V("status", e.status)), n.length !== 0) return n.length === 1 ? n[0] : $r(...n);
|
|
2841
|
+
}, Uc = async (e, t) => {
|
|
2842
|
+
let n = Math.max(0, t?.offset ?? 0), r = Math.max(1, Math.min(500, t?.limit ?? 50)), i = Hc(t);
|
|
2798
2843
|
return {
|
|
2799
2844
|
rows: await e.query({
|
|
2800
2845
|
table: "_voltro_workflow_runs",
|
|
@@ -2818,7 +2863,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2818
2863
|
offset: n,
|
|
2819
2864
|
limit: r
|
|
2820
2865
|
};
|
|
2821
|
-
},
|
|
2866
|
+
}, Wc = (e) => ({
|
|
2822
2867
|
id: e.id,
|
|
2823
2868
|
workflowName: e.tag,
|
|
2824
2869
|
executionId: e.executionId,
|
|
@@ -2833,14 +2878,14 @@ ${a.join("\n\n")}\n`);
|
|
|
2833
2878
|
durationMs: e.durationMs,
|
|
2834
2879
|
traceId: e.traceId,
|
|
2835
2880
|
parentExecutionId: e.parentExecutionId
|
|
2836
|
-
}),
|
|
2837
|
-
let { rows: n } = await
|
|
2838
|
-
return n.map(
|
|
2839
|
-
},
|
|
2881
|
+
}), Gc = async (e, t) => {
|
|
2882
|
+
let { rows: n } = await Uc(e, t);
|
|
2883
|
+
return n.map(Wc);
|
|
2884
|
+
}, Kc = async (e, t, n) => {
|
|
2840
2885
|
let r = (await e.store.query({
|
|
2841
2886
|
table: "_voltro_workflow_runs",
|
|
2842
2887
|
order: [],
|
|
2843
|
-
predicate:
|
|
2888
|
+
predicate: V("id", t),
|
|
2844
2889
|
projection: void 0,
|
|
2845
2890
|
skip: void 0,
|
|
2846
2891
|
take: 1
|
|
@@ -2850,7 +2895,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2850
2895
|
if (!i) throw Error(`retry: no workflow registered with tag '${r.tag}'`);
|
|
2851
2896
|
let a = n?.payloadOverride === void 0 ? r.payload : n.payloadOverride, o = await e.runPromise(i.definition.execute(a));
|
|
2852
2897
|
return { executionId: typeof o == "string" ? o : "started" };
|
|
2853
|
-
},
|
|
2898
|
+
}, qc = (e, t) => {
|
|
2854
2899
|
let n = e.filter((e) => typeof e.onHttpRequest == "function");
|
|
2855
2900
|
if (n.length !== 0) return n.reduceRight((e, n) => {
|
|
2856
2901
|
let r = n.onHttpRequest, i = `plugin.${n.name}.http-intercept`;
|
|
@@ -2871,7 +2916,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2871
2916
|
}
|
|
2872
2917
|
};
|
|
2873
2918
|
}, (e) => e());
|
|
2874
|
-
},
|
|
2919
|
+
}, Jc = (e) => {
|
|
2875
2920
|
let t = [];
|
|
2876
2921
|
for (let n of e) {
|
|
2877
2922
|
let e = n.dashboard ?? [];
|
|
@@ -2895,7 +2940,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2895
2940
|
}
|
|
2896
2941
|
}
|
|
2897
2942
|
return t;
|
|
2898
|
-
},
|
|
2943
|
+
}, Yc = /\.(query|mutation|action|stream)\.ts$/, Xc = /\.(query|mutation|action|stream)\.server\.ts$/, Zc = /* @__PURE__ */ new Set([
|
|
2899
2944
|
"node_modules",
|
|
2900
2945
|
"dist",
|
|
2901
2946
|
"build",
|
|
@@ -2903,7 +2948,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2903
2948
|
".vite",
|
|
2904
2949
|
".next",
|
|
2905
2950
|
".git"
|
|
2906
|
-
]),
|
|
2951
|
+
]), Qc = async (e) => {
|
|
2907
2952
|
let t = [], n = async (e) => {
|
|
2908
2953
|
let r;
|
|
2909
2954
|
try {
|
|
@@ -2912,14 +2957,14 @@ ${a.join("\n\n")}\n`);
|
|
|
2912
2957
|
return;
|
|
2913
2958
|
}
|
|
2914
2959
|
for (let i of r) {
|
|
2915
|
-
if (
|
|
2960
|
+
if (Zc.has(i.name)) continue;
|
|
2916
2961
|
let r = O(e, i.name);
|
|
2917
|
-
i.isDirectory() ? await n(r) : i.isFile() && (
|
|
2962
|
+
i.isDirectory() ? await n(r) : i.isFile() && (Yc.test(i.name) && !Xc.test(i.name) || C.test(i.name)) && t.push(r);
|
|
2918
2963
|
}
|
|
2919
2964
|
};
|
|
2920
2965
|
return await n(e), t;
|
|
2921
|
-
},
|
|
2922
|
-
let t = await
|
|
2966
|
+
}, $c = async (e) => {
|
|
2967
|
+
let t = await Qc(e), n = [];
|
|
2923
2968
|
for (let e of t) try {
|
|
2924
2969
|
let t = await import(j(e).href);
|
|
2925
2970
|
for (let r of Object.values(t)) {
|
|
@@ -2944,10 +2989,10 @@ ${a.join("\n\n")}\n`);
|
|
|
2944
2989
|
let t = `${e.kind}:${e.tag}`;
|
|
2945
2990
|
return r.has(t) ? !1 : (r.add(t), !0);
|
|
2946
2991
|
});
|
|
2947
|
-
},
|
|
2992
|
+
}, el = async (e, t, n) => {
|
|
2948
2993
|
let r = e.filter((e) => typeof e.codegen == "function");
|
|
2949
2994
|
if (r.length === 0) return [];
|
|
2950
|
-
let i = await
|
|
2995
|
+
let i = await $c(n);
|
|
2951
2996
|
return r.map((e) => {
|
|
2952
2997
|
let n = we(e.name), r = {
|
|
2953
2998
|
pluginName: e.name,
|
|
@@ -2961,8 +3006,8 @@ ${a.join("\n\n")}\n`);
|
|
|
2961
3006
|
emit: () => e.codegen(r)
|
|
2962
3007
|
};
|
|
2963
3008
|
});
|
|
2964
|
-
},
|
|
2965
|
-
pluginContributions: await
|
|
3009
|
+
}, tl = async (e, t, n) => ({
|
|
3010
|
+
pluginContributions: await el(e, t, n),
|
|
2966
3011
|
pluginErrorImports: e.flatMap((e) => (e.errorSchemas ?? []).map((e) => e.import)),
|
|
2967
3012
|
pluginRpcImports: e.flatMap((e) => (e.rpcClientDescriptors ?? []).map((e) => ({
|
|
2968
3013
|
tag: e.tag,
|
|
@@ -2970,19 +3015,19 @@ ${a.join("\n\n")}\n`);
|
|
|
2970
3015
|
module: e.import.module,
|
|
2971
3016
|
name: e.import.name
|
|
2972
3017
|
})))
|
|
2973
|
-
}),
|
|
3018
|
+
}), nl = class extends Error {
|
|
2974
3019
|
constructor(e) {
|
|
2975
3020
|
super(e), this.name = "InspectQueryError";
|
|
2976
3021
|
}
|
|
2977
|
-
},
|
|
3022
|
+
}, rl = /* @__PURE__ */ new Set([
|
|
2978
3023
|
"text",
|
|
2979
3024
|
"id",
|
|
2980
3025
|
"reference"
|
|
2981
|
-
]),
|
|
3026
|
+
]), il = /* @__PURE__ */ new Set([
|
|
2982
3027
|
"integer",
|
|
2983
3028
|
"timestamp",
|
|
2984
3029
|
"date"
|
|
2985
|
-
]),
|
|
3030
|
+
]), al = (e, t) => {
|
|
2986
3031
|
switch (e) {
|
|
2987
3032
|
case "isNull":
|
|
2988
3033
|
case "isNotNull":
|
|
@@ -2990,54 +3035,54 @@ ${a.join("\n\n")}\n`);
|
|
|
2990
3035
|
case "neq":
|
|
2991
3036
|
case "in":
|
|
2992
3037
|
case "notIn": return !0;
|
|
2993
|
-
case "contains": return
|
|
3038
|
+
case "contains": return rl.has(t);
|
|
2994
3039
|
case "gt":
|
|
2995
3040
|
case "gte":
|
|
2996
3041
|
case "lt":
|
|
2997
|
-
case "lte": return
|
|
3042
|
+
case "lte": return il.has(t);
|
|
2998
3043
|
}
|
|
2999
|
-
},
|
|
3044
|
+
}, ol = (e, t, n) => {
|
|
3000
3045
|
if (e == null) return e;
|
|
3001
3046
|
switch (t) {
|
|
3002
3047
|
case "integer": {
|
|
3003
3048
|
let t = typeof e == "number" ? e : Number(e);
|
|
3004
|
-
if (!Number.isFinite(t)) throw new
|
|
3049
|
+
if (!Number.isFinite(t)) throw new nl(`filter on "${n}": "${String(e)}" is not a number`);
|
|
3005
3050
|
return t;
|
|
3006
3051
|
}
|
|
3007
3052
|
case "boolean":
|
|
3008
3053
|
if (typeof e == "boolean") return e;
|
|
3009
3054
|
if (e === "true") return !0;
|
|
3010
3055
|
if (e === "false") return !1;
|
|
3011
|
-
throw new
|
|
3056
|
+
throw new nl(`filter on "${n}": "${String(e)}" is not a boolean`);
|
|
3012
3057
|
default: return e;
|
|
3013
3058
|
}
|
|
3014
|
-
},
|
|
3059
|
+
}, sl = (e, t) => {
|
|
3015
3060
|
let n = t.get(e.column);
|
|
3016
|
-
if (!n) throw new
|
|
3017
|
-
if (!
|
|
3061
|
+
if (!n) throw new nl(`unknown filter column "${e.column}"`);
|
|
3062
|
+
if (!al(e.op, n.type)) throw new nl(`operator "${e.op}" is not valid for ${n.type} column "${e.column}"`);
|
|
3018
3063
|
if (e.op === "isNull" || e.op === "isNotNull") return {
|
|
3019
3064
|
column: e.column,
|
|
3020
3065
|
op: e.op
|
|
3021
3066
|
};
|
|
3022
3067
|
if (e.op === "in" || e.op === "notIn") {
|
|
3023
|
-
if (!Array.isArray(e.value)) throw new
|
|
3068
|
+
if (!Array.isArray(e.value)) throw new nl(`operator "${e.op}" on "${e.column}" requires an array value`);
|
|
3024
3069
|
return {
|
|
3025
3070
|
column: e.column,
|
|
3026
3071
|
op: e.op,
|
|
3027
|
-
value: e.value.map((t) =>
|
|
3072
|
+
value: e.value.map((t) => ol(t, n.type, e.column))
|
|
3028
3073
|
};
|
|
3029
3074
|
}
|
|
3030
3075
|
return {
|
|
3031
3076
|
column: e.column,
|
|
3032
3077
|
op: e.op,
|
|
3033
|
-
value:
|
|
3078
|
+
value: ol(e.value, n.type, e.column)
|
|
3034
3079
|
};
|
|
3035
|
-
},
|
|
3036
|
-
if (++n.n >
|
|
3037
|
-
if (e.kind === "leaf") return
|
|
3038
|
-
let r = e.children.map((e) =>
|
|
3080
|
+
}, cl = 200, ll = (e, t, n) => {
|
|
3081
|
+
if (++n.n > cl) throw new nl("filter tree too large");
|
|
3082
|
+
if (e.kind === "leaf") return sl(e, t);
|
|
3083
|
+
let r = e.children.map((e) => ll(e, t, n));
|
|
3039
3084
|
return e.kind === "and" ? { and: r } : { or: r };
|
|
3040
|
-
},
|
|
3085
|
+
}, ul = (e, t) => {
|
|
3041
3086
|
let n = e?.trim();
|
|
3042
3087
|
if (!n) return null;
|
|
3043
3088
|
let r = t.filter((e) => e.type === "text" || (e.oneOf?.length ?? 0) > 0);
|
|
@@ -3046,16 +3091,16 @@ ${a.join("\n\n")}\n`);
|
|
|
3046
3091
|
op: "contains",
|
|
3047
3092
|
value: n
|
|
3048
3093
|
})) };
|
|
3049
|
-
},
|
|
3094
|
+
}, dl = (e) => {
|
|
3050
3095
|
let t = new Map(e.columns.map((e) => [e.name, e])), n = [];
|
|
3051
|
-
e.filter && n.push(
|
|
3052
|
-
let r =
|
|
3096
|
+
e.filter && n.push(ll(e.filter, t, { n: 0 }));
|
|
3097
|
+
let r = ul(e.quickSearch, e.columns);
|
|
3053
3098
|
if (r && n.push(r), n.length !== 0) return n.length === 1 ? n[0] : { and: n };
|
|
3054
|
-
},
|
|
3099
|
+
}, fl = (e, t) => {
|
|
3055
3100
|
let n = new Set(t.map((e) => e.name)), r = [], i = /* @__PURE__ */ new Set();
|
|
3056
3101
|
for (let t of e ?? []) {
|
|
3057
|
-
if (!n.has(t.column)) throw new
|
|
3058
|
-
if (t.direction !== "asc" && t.direction !== "desc") throw new
|
|
3102
|
+
if (!n.has(t.column)) throw new nl(`unknown sort column "${t.column}"`);
|
|
3103
|
+
if (t.direction !== "asc" && t.direction !== "desc") throw new nl(`invalid sort direction "${t.direction}"`);
|
|
3059
3104
|
i.has(t.column) || (i.add(t.column), r.push({
|
|
3060
3105
|
column: t.column,
|
|
3061
3106
|
direction: t.direction
|
|
@@ -3065,16 +3110,16 @@ ${a.join("\n\n")}\n`);
|
|
|
3065
3110
|
column: "id",
|
|
3066
3111
|
direction: "asc"
|
|
3067
3112
|
}), r;
|
|
3068
|
-
},
|
|
3113
|
+
}, pl = 150, ml = 200, hl = (e) => e instanceof Date ? e.toISOString() : typeof e == "bigint" ? e.toString() : e, gl = (e) => {
|
|
3069
3114
|
if (!e) return null;
|
|
3070
3115
|
let t = {};
|
|
3071
|
-
for (let [n, r] of Object.entries(e)) t[n] =
|
|
3116
|
+
for (let [n, r] of Object.entries(e)) t[n] = hl(r);
|
|
3072
3117
|
return t;
|
|
3073
|
-
},
|
|
3118
|
+
}, _l = (e, t) => {
|
|
3074
3119
|
let n = /* @__PURE__ */ new Map(), r, i = () => {
|
|
3075
3120
|
r = void 0;
|
|
3076
3121
|
for (let [e, r] of n) {
|
|
3077
|
-
if (r.size >
|
|
3122
|
+
if (r.size > ml) {
|
|
3078
3123
|
t.emit("cdc", {
|
|
3079
3124
|
op: "resync",
|
|
3080
3125
|
table: e
|
|
@@ -3096,17 +3141,17 @@ ${a.join("\n\n")}\n`);
|
|
|
3096
3141
|
let o = n.get(e.table);
|
|
3097
3142
|
o || (o = /* @__PURE__ */ new Map(), n.set(e.table, o)), o.set(a, {
|
|
3098
3143
|
op: e.op,
|
|
3099
|
-
row: e.op === "delete" ? null :
|
|
3100
|
-
}), r === void 0 && (r = setTimeout(i,
|
|
3144
|
+
row: e.op === "delete" ? null : gl(t)
|
|
3145
|
+
}), r === void 0 && (r = setTimeout(i, pl));
|
|
3101
3146
|
});
|
|
3102
3147
|
return () => {
|
|
3103
3148
|
r !== void 0 && clearTimeout(r), a();
|
|
3104
3149
|
};
|
|
3105
|
-
},
|
|
3150
|
+
}, vl = [
|
|
3106
3151
|
"ok",
|
|
3107
3152
|
"error",
|
|
3108
3153
|
"unset"
|
|
3109
|
-
],
|
|
3154
|
+
], yl = (e, t) => {
|
|
3110
3155
|
let n = e.indexOf("?"), r = n === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(n + 1)), i = (() => {
|
|
3111
3156
|
let e = r.get("since");
|
|
3112
3157
|
if (e === null) return;
|
|
@@ -3127,9 +3172,9 @@ ${a.join("\n\n")}\n`);
|
|
|
3127
3172
|
Number.isFinite(t) && (e.minDurationMs = t);
|
|
3128
3173
|
}
|
|
3129
3174
|
let s = r.get("status");
|
|
3130
|
-
s !== null &&
|
|
3175
|
+
s !== null && vl.includes(s) && (e.status = s);
|
|
3131
3176
|
let c = t.query(e);
|
|
3132
|
-
return
|
|
3177
|
+
return bl({
|
|
3133
3178
|
capturedAt: Date.now(),
|
|
3134
3179
|
bufferCapacity: t.capacityHint(),
|
|
3135
3180
|
bufferSize: t.size(),
|
|
@@ -3141,22 +3186,22 @@ ${a.join("\n\n")}\n`);
|
|
|
3141
3186
|
let s = {};
|
|
3142
3187
|
i !== void 0 && (s.since = i), a !== void 0 && (s.maxTraces = a), r.get("onlyErrors") === "1" && (s.onlyErrors = !0);
|
|
3143
3188
|
let c = t.queryGrouped(s);
|
|
3144
|
-
return
|
|
3189
|
+
return bl({
|
|
3145
3190
|
capturedAt: Date.now(),
|
|
3146
3191
|
bufferCapacity: t.capacityHint(),
|
|
3147
3192
|
bufferSize: t.size(),
|
|
3148
3193
|
returned: c.length,
|
|
3149
3194
|
traces: c
|
|
3150
3195
|
});
|
|
3151
|
-
},
|
|
3196
|
+
}, bl = (e) => ({
|
|
3152
3197
|
status: 200,
|
|
3153
3198
|
contentType: "application/json; charset=utf-8",
|
|
3154
3199
|
body: JSON.stringify(e)
|
|
3155
|
-
}),
|
|
3200
|
+
}), xl = (e) => {
|
|
3156
3201
|
let t = e.now ?? Date.now, n = {
|
|
3157
3202
|
phase: "booting",
|
|
3158
3203
|
startedAt: t()
|
|
3159
|
-
}, r =
|
|
3204
|
+
}, r = ka((e, r) => {
|
|
3160
3205
|
let i = (e.url ?? "/").split("?")[0], a = n.phase === "ready";
|
|
3161
3206
|
if (i === "/internal/liveness") {
|
|
3162
3207
|
r.writeHead(200, {
|
|
@@ -3211,28 +3256,28 @@ ${a.join("\n\n")}\n`);
|
|
|
3211
3256
|
e.log?.info("dev health server listening", { port: a }), t(i(a));
|
|
3212
3257
|
});
|
|
3213
3258
|
});
|
|
3214
|
-
}, $ = F({ scope: "voltro:dev" }),
|
|
3259
|
+
}, $ = F({ scope: "voltro:dev" }), Sl = await (async () => {
|
|
3215
3260
|
try {
|
|
3216
3261
|
let e = O(D(dt(import.meta.url)), "..", "package.json"), t = await R.readFile(e, "utf8");
|
|
3217
3262
|
return JSON.parse(t).version ?? "0.0.0";
|
|
3218
3263
|
} catch {
|
|
3219
3264
|
return "0.0.0";
|
|
3220
3265
|
}
|
|
3221
|
-
})(),
|
|
3266
|
+
})(), Cl = process.env.TENANT ?? "acme", wl = process.env.VOLTRO_SESSION_COOKIE ?? "voltro:session", Tl = {
|
|
3222
3267
|
id: "voltro-password",
|
|
3223
3268
|
resolve: (e) => {
|
|
3224
|
-
let t =
|
|
3269
|
+
let t = qi(e.headers.cookie ?? e.headers.Cookie, wl);
|
|
3225
3270
|
if (!t) return { kind: "skip" };
|
|
3226
|
-
let n =
|
|
3271
|
+
let n = Ji();
|
|
3227
3272
|
if (!n) return { kind: "skip" };
|
|
3228
|
-
let r =
|
|
3273
|
+
let r = Yi(t, n);
|
|
3229
3274
|
return r ? {
|
|
3230
3275
|
kind: "matched",
|
|
3231
3276
|
subject: r.subject
|
|
3232
3277
|
} : { kind: "skip" };
|
|
3233
3278
|
}
|
|
3234
|
-
},
|
|
3235
|
-
...n ? { anonymousTenantRequired: !0 } : { fallback: (e) =>
|
|
3279
|
+
}, El = (e = [], t, n = !1, r, i) => (Dl([t ?? Tl, ...e]), xi([t ?? Tl, ...e], {
|
|
3280
|
+
...n ? { anonymousTenantRequired: !0 } : { fallback: (e) => yi(e.headers["x-tenant"] ?? Cl) },
|
|
3236
3281
|
onStrategyFailed: ({ strategyId: e, reason: t }) => {
|
|
3237
3282
|
$.warn(`auth strategy "${e}" rejected request: ${t}`);
|
|
3238
3283
|
},
|
|
@@ -3241,17 +3286,17 @@ ${a.join("\n\n")}\n`);
|
|
|
3241
3286
|
...t,
|
|
3242
3287
|
store: i?.()
|
|
3243
3288
|
}) }
|
|
3244
|
-
})),
|
|
3289
|
+
})), Dl = (e) => {
|
|
3245
3290
|
let t = /* @__PURE__ */ new Map();
|
|
3246
3291
|
for (let n of e) {
|
|
3247
3292
|
let e = n.claimsBearerPrefix;
|
|
3248
3293
|
e === void 0 || e === "" || t.set(e, [...t.get(e) ?? [], n.id]);
|
|
3249
3294
|
}
|
|
3250
3295
|
for (let [e, n] of t) n.length < 2 || $.warn(`auth: ${n.length} strategies claim the bearer prefix "${e}" (${n.join(", ")}). The chain is first-match-wins, so the FIRST one decides the Subject for every token with this shape — if they resolve to different authority, which one answered decides whether authorization works. If this is \`apiKeys: true\` alongside your own key strategy, either drop one or give them distinct prefixes (\`apiKeys: { prefix: "…" }\`).`);
|
|
3251
|
-
},
|
|
3296
|
+
}, Ol = (e) => P.succeed(pi, pi.of(({ headers: t, clientId: n }) => N.promise(async () => cn(n) || e({
|
|
3252
3297
|
headers: t,
|
|
3253
3298
|
clientId: n
|
|
3254
|
-
})))),
|
|
3299
|
+
})))), kl = P.succeed(mi, mi.of(({ clientId: e }) => N.succeed({ clientId: e }))), Al = (e) => {
|
|
3255
3300
|
if (pt.isCause(e)) return e;
|
|
3256
3301
|
if (typeof e != "object" || !e) return;
|
|
3257
3302
|
for (let t of Object.getOwnPropertySymbols(e)) if (t.description === "effect/Runtime/FiberFailure/Cause") {
|
|
@@ -3260,17 +3305,17 @@ ${a.join("\n\n")}\n`);
|
|
|
3260
3305
|
}
|
|
3261
3306
|
let t = e.cause;
|
|
3262
3307
|
return pt.isCause(t) ? t : void 0;
|
|
3263
|
-
},
|
|
3264
|
-
let t =
|
|
3308
|
+
}, jl = (e) => {
|
|
3309
|
+
let t = Al(e);
|
|
3265
3310
|
if (t === void 0) return;
|
|
3266
3311
|
let n = pt.failureOption(t);
|
|
3267
3312
|
if (vt.isSome(n)) return n.value;
|
|
3268
3313
|
let r = pt.dieOption(t);
|
|
3269
3314
|
if (vt.isSome(r)) return r.value;
|
|
3270
|
-
},
|
|
3315
|
+
}, Ml = (e) => {
|
|
3271
3316
|
if (e == null) return { message: "unknown error" };
|
|
3272
|
-
let t =
|
|
3273
|
-
if (t !== void 0 && t !== e) return
|
|
3317
|
+
let t = jl(e);
|
|
3318
|
+
if (t !== void 0 && t !== e) return Ml(t);
|
|
3274
3319
|
let n = an(e), r = (n.dbCode ?? n.dbSqlState ?? n.dbErrno ?? n.dbConstraint) === void 0 ? {} : n;
|
|
3275
3320
|
if (typeof e == "object" && "_tag" in e) return {
|
|
3276
3321
|
...e,
|
|
@@ -3287,7 +3332,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3287
3332
|
} catch {
|
|
3288
3333
|
return { message: String(e) };
|
|
3289
3334
|
}
|
|
3290
|
-
},
|
|
3335
|
+
}, Nl = /* @__PURE__ */ new Set([
|
|
3291
3336
|
"node_modules",
|
|
3292
3337
|
"dist",
|
|
3293
3338
|
"build",
|
|
@@ -3295,21 +3340,21 @@ ${a.join("\n\n")}\n`);
|
|
|
3295
3340
|
".vite",
|
|
3296
3341
|
".next",
|
|
3297
3342
|
".git"
|
|
3298
|
-
]),
|
|
3343
|
+
]), Pl = async (e) => {
|
|
3299
3344
|
let t = [], n = async (e) => {
|
|
3300
3345
|
let r = await R.readdir(e, { withFileTypes: !0 });
|
|
3301
3346
|
for (let i of r) {
|
|
3302
|
-
if (
|
|
3347
|
+
if (Nl.has(i.name)) continue;
|
|
3303
3348
|
let r = O(e, i.name);
|
|
3304
|
-
i.isDirectory() ? await n(r) : i.isFile() && (je.test(i.name) && !Le.test(i.name) || Le.test(i.name) || C.test(i.name) || De.test(i.name) || Ee.test(i.name) || Me.test(i.name) || Ne.test(i.name) || ke.test(i.name) || ze.test(i.name) || Pe.test(i.name) || Oe.test(i.name) ||
|
|
3349
|
+
i.isDirectory() ? await n(r) : i.isFile() && (je.test(i.name) && !Le.test(i.name) || Le.test(i.name) || C.test(i.name) || De.test(i.name) || Ee.test(i.name) || Me.test(i.name) || Ne.test(i.name) || ke.test(i.name) || ze.test(i.name) || Pe.test(i.name) || Oe.test(i.name) || dc.test(i.name) || Se.test(i.name) || S.test(i.name) || Ae.test(i.name) || Fe.test(i.name) || Ie.test(i.name) || Re.test(i.name)) && t.push(r);
|
|
3305
3350
|
}
|
|
3306
3351
|
};
|
|
3307
3352
|
return await n(e), t;
|
|
3308
|
-
},
|
|
3353
|
+
}, Fl = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "query", Il = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "mutation", Ll = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "action", Rl = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "stream", zl = Symbol.for("@effect/workflow/Workflow"), Bl = (e) => typeof e == "object" && !!e && zl in e, Vl = (e) => {
|
|
3309
3354
|
let t = {};
|
|
3310
3355
|
for (let [n, r] of Object.entries(e)) r instanceof Date ? t[n] = r.toISOString() : typeof r == "bigint" ? t[n] = r.toString() : t[n] = r;
|
|
3311
3356
|
return t;
|
|
3312
|
-
},
|
|
3357
|
+
}, Hl = (e) => Object.entries(e.fields).map(([e, t]) => {
|
|
3313
3358
|
let n = t, r = n.references?.()?.tableName;
|
|
3314
3359
|
return {
|
|
3315
3360
|
name: e,
|
|
@@ -3320,11 +3365,11 @@ ${a.join("\n\n")}\n`);
|
|
|
3320
3365
|
...r === void 0 ? {} : { referencesTable: r },
|
|
3321
3366
|
...n.oneOf === void 0 ? {} : { oneOf: [...n.oneOf] }
|
|
3322
3367
|
};
|
|
3323
|
-
}),
|
|
3368
|
+
}), Ul = (e) => e.some((e) => e.name === "id") ? "id" : e.find((e) => e.type === "id")?.name, Wl = (e) => typeof e == "object" && !!e && "tableName" in e && "fields" in e && typeof e.tableName == "string" && typeof e.fields == "object" && e.fields !== null, Gl = (e, t) => {
|
|
3324
3369
|
let n = /* @__PURE__ */ new Map();
|
|
3325
|
-
for (let e of t)
|
|
3370
|
+
for (let e of t) Wl(e) && n.set(e.tableName, e);
|
|
3326
3371
|
let r = /* @__PURE__ */ new Set(), i = [], a = (e) => {
|
|
3327
|
-
if (!(!
|
|
3372
|
+
if (!(!Wl(e) || r.has(e.tableName))) {
|
|
3328
3373
|
r.add(e.tableName);
|
|
3329
3374
|
for (let t of Object.values(e.fields)) {
|
|
3330
3375
|
let e = t.references?.()?.tableName;
|
|
@@ -3337,7 +3382,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3337
3382
|
};
|
|
3338
3383
|
for (let t of e) a(t);
|
|
3339
3384
|
return i;
|
|
3340
|
-
},
|
|
3385
|
+
}, Kl = "voltro/tenant", ql = (e) => Wl(e) && (e.appliedMixins ?? []).some((e) => e.id === Kl), Jl = "voltro/softDelete", Yl = (e) => Wl(e) && (e.appliedMixins ?? []).some((e) => e.id === Jl), Xl = (e) => {
|
|
3341
3386
|
let t = e.traceId, n = e.spanId;
|
|
3342
3387
|
if (typeof t != "string" || typeof n != "string") return null;
|
|
3343
3388
|
let r = (e) => e instanceof Date ? e.getTime() : typeof e == "string" ? new Date(e).getTime() : typeof e == "number" ? e : 0, i = r(e.startedAt), a = r(e.endedAt);
|
|
@@ -3355,7 +3400,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3355
3400
|
...typeof e.statusMessage == "string" ? { statusMessage: e.statusMessage } : {},
|
|
3356
3401
|
...Array.isArray(e.events) ? { events: e.events } : {}
|
|
3357
3402
|
};
|
|
3358
|
-
},
|
|
3403
|
+
}, Zl = async (e, t, n) => {
|
|
3359
3404
|
let r = e.indexOf("?"), i = (r === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(r + 1))).get("traceId"), a = [];
|
|
3360
3405
|
try {
|
|
3361
3406
|
a = await n.query({
|
|
@@ -3364,7 +3409,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3364
3409
|
column: "startedAt",
|
|
3365
3410
|
direction: "desc"
|
|
3366
3411
|
}],
|
|
3367
|
-
predicate: i !== null && i.length > 0 ?
|
|
3412
|
+
predicate: i !== null && i.length > 0 ? V("traceId", i) : void 0,
|
|
3368
3413
|
projection: void 0,
|
|
3369
3414
|
skip: void 0,
|
|
3370
3415
|
take: i !== null && i.length > 0 ? 1e3 : 2e3
|
|
@@ -3374,25 +3419,25 @@ ${a.join("\n\n")}\n`);
|
|
|
3374
3419
|
}
|
|
3375
3420
|
let o = /* @__PURE__ */ new Map();
|
|
3376
3421
|
for (let e of a) {
|
|
3377
|
-
let t =
|
|
3422
|
+
let t = Xl(e);
|
|
3378
3423
|
t && o.set(`${t.traceId}:${t.spanId}`, t);
|
|
3379
3424
|
}
|
|
3380
3425
|
for (let e of t.query({ max: t.capacityHint() })) o.set(`${e.traceId}:${e.spanId}`, e);
|
|
3381
3426
|
let s = new le(Math.max(o.size + 16, 1024));
|
|
3382
3427
|
for (let e of [...o.values()].sort((e, t) => e.startMs - t.startMs)) s.append(e);
|
|
3383
3428
|
return s;
|
|
3384
|
-
},
|
|
3429
|
+
}, Ql = async (e, t) => {
|
|
3385
3430
|
let n = [], r = [], i = [], a = [], o = [], s = [], c = [], l = [], u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Map(), p = [], m = /* @__PURE__ */ new Map();
|
|
3386
3431
|
for (let t of e) {
|
|
3387
3432
|
let e = E(t);
|
|
3388
3433
|
if (Me.test(e)) {
|
|
3389
3434
|
let e = await b(t);
|
|
3390
|
-
for (let t of Object.values(e))
|
|
3391
|
-
|
|
3435
|
+
for (let t of Object.values(e)) Wl(t) && (f.set(t.tableName, t), ql(t) && u.add(t.tableName), Yl(t) && d.add(t.tableName));
|
|
3436
|
+
ci(e);
|
|
3392
3437
|
continue;
|
|
3393
3438
|
}
|
|
3394
3439
|
if (Ne.test(e)) {
|
|
3395
|
-
|
|
3440
|
+
ci(await b(t)) === 0 && $.warn("skipping relations file — no relations(...) export found", { file: t });
|
|
3396
3441
|
continue;
|
|
3397
3442
|
}
|
|
3398
3443
|
if (Te(e)) {
|
|
@@ -3403,7 +3448,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3403
3448
|
continue;
|
|
3404
3449
|
}
|
|
3405
3450
|
if (C.test(e)) {
|
|
3406
|
-
let e = await b(t), n = Object.values(e).find(
|
|
3451
|
+
let e = await b(t), n = Object.values(e).find(Bl);
|
|
3407
3452
|
if (!n) {
|
|
3408
3453
|
$.warn("skipping workflow — no workflow(...) export", { file: t });
|
|
3409
3454
|
continue;
|
|
@@ -3428,7 +3473,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3428
3473
|
definition: n,
|
|
3429
3474
|
buildExecute: a
|
|
3430
3475
|
});
|
|
3431
|
-
for (let t of [...Object.values(e), ...Object.values(i)])
|
|
3476
|
+
for (let t of [...Object.values(e), ...Object.values(i)]) Rr(t) && s.push(t);
|
|
3432
3477
|
continue;
|
|
3433
3478
|
}
|
|
3434
3479
|
if (Ee.test(e)) {
|
|
@@ -3475,7 +3520,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3475
3520
|
}
|
|
3476
3521
|
}
|
|
3477
3522
|
for (let e of p) {
|
|
3478
|
-
let t = await b(e), o = Object.values(t).find(
|
|
3523
|
+
let t = await b(e), o = Object.values(t).find(Fl) ?? Object.values(t).find(Il) ?? Object.values(t).find(Ll) ?? Object.values(t).find(Rl);
|
|
3479
3524
|
if (!o) {
|
|
3480
3525
|
$.warn("skipping procedure descriptor — no defineQuery / defineMutation / defineAction / defineStream export", { file: e });
|
|
3481
3526
|
continue;
|
|
@@ -3513,7 +3558,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3513
3558
|
}
|
|
3514
3559
|
let h = /* @__PURE__ */ new Map();
|
|
3515
3560
|
for (let [e, t] of f) {
|
|
3516
|
-
let n =
|
|
3561
|
+
let n = ui(t);
|
|
3517
3562
|
n.length > 0 && h.set(e, n);
|
|
3518
3563
|
}
|
|
3519
3564
|
if (h.size > 0) {
|
|
@@ -3524,9 +3569,9 @@ ${a.join("\n\n")}\n`);
|
|
|
3524
3569
|
}, h)));
|
|
3525
3570
|
e !== void 0 && $.warn(`[serverOnly] ${e}`);
|
|
3526
3571
|
}
|
|
3527
|
-
f.has("actors") || f.set("actors",
|
|
3572
|
+
f.has("actors") || f.set("actors", Zr);
|
|
3528
3573
|
let g = f.get("actors"), _ = f.get("tenants");
|
|
3529
|
-
(g !== void 0 || _ !== void 0) &&
|
|
3574
|
+
(g !== void 0 || _ !== void 0) && si({
|
|
3530
3575
|
...g === void 0 ? {} : { actors: () => g },
|
|
3531
3576
|
..._ === void 0 ? {} : { tenants: () => _ }
|
|
3532
3577
|
});
|
|
@@ -3538,7 +3583,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3538
3583
|
outbox: e.some((e) => Fe.test(E(e))),
|
|
3539
3584
|
connections: ee.length > 0
|
|
3540
3585
|
};
|
|
3541
|
-
return
|
|
3586
|
+
return di(), {
|
|
3542
3587
|
queries: n,
|
|
3543
3588
|
mutations: r,
|
|
3544
3589
|
actions: i,
|
|
@@ -3553,7 +3598,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3553
3598
|
tenantScopedTables: u,
|
|
3554
3599
|
softDeleteScopedTables: d
|
|
3555
3600
|
};
|
|
3556
|
-
},
|
|
3601
|
+
}, $l = async (e) => {
|
|
3557
3602
|
let t = O(e, "app.config.ts");
|
|
3558
3603
|
try {
|
|
3559
3604
|
let e = (await b(t)).default;
|
|
@@ -3561,8 +3606,8 @@ ${a.join("\n\n")}\n`);
|
|
|
3561
3606
|
} catch {
|
|
3562
3607
|
return null;
|
|
3563
3608
|
}
|
|
3564
|
-
},
|
|
3565
|
-
let e =
|
|
3609
|
+
}, eu = () => {
|
|
3610
|
+
let e = nu(), t = process.env.DB_SCHEMA, n = t && t.length > 0 ? { schema: t } : {}, r = tu(), i = r === void 0 ? {} : { ssl: r }, a = process.env.DB_URL ?? process.env.DB_PRIMARY_URL;
|
|
3566
3611
|
return a ? {
|
|
3567
3612
|
url: a,
|
|
3568
3613
|
...e === void 0 ? {} : { maxConnections: e },
|
|
@@ -3578,19 +3623,19 @@ ${a.join("\n\n")}\n`);
|
|
|
3578
3623
|
...i,
|
|
3579
3624
|
...n
|
|
3580
3625
|
};
|
|
3581
|
-
},
|
|
3626
|
+
}, tu = () => {
|
|
3582
3627
|
let e = process.env.PG_SSL;
|
|
3583
3628
|
if (!(e === void 0 || e === "")) {
|
|
3584
3629
|
if (e === "require") return !0;
|
|
3585
3630
|
if (e === "disable") return !1;
|
|
3586
3631
|
throw Error(`PG_SSL '${e}' is not supported — use 'require' (TLS without certificate verification) or 'disable' (plaintext).`);
|
|
3587
3632
|
}
|
|
3588
|
-
},
|
|
3633
|
+
}, nu = () => {
|
|
3589
3634
|
let e = process.env.DB_MAX_CONNECTIONS ?? process.env.PG_MAX_CONNECTIONS;
|
|
3590
3635
|
if (e === void 0 || e === "") return;
|
|
3591
3636
|
let t = Number(e);
|
|
3592
3637
|
return Number.isInteger(t) && t > 0 ? t : void 0;
|
|
3593
|
-
},
|
|
3638
|
+
}, ru = (e) => {
|
|
3594
3639
|
let t = process.env.DB_URL !== void 0 || process.env.DB_PRIMARY_URL !== void 0 || process.env.DB_HOST !== void 0 || process.env.PG_HOST !== void 0;
|
|
3595
3640
|
if ("url" in e && e.url) try {
|
|
3596
3641
|
let n = new URL(e.url), r = n.username ? `${n.username}@` : "", i = n.port ? `:${n.port}` : "";
|
|
@@ -3609,25 +3654,25 @@ ${a.join("\n\n")}\n`);
|
|
|
3609
3654
|
summary: `postgres://${n.username}@${n.host}:${n.port}/${n.database}`,
|
|
3610
3655
|
fromEnv: t
|
|
3611
3656
|
};
|
|
3612
|
-
},
|
|
3657
|
+
}, iu = () => {
|
|
3613
3658
|
let e = process.env.DB_REPLICA_URLS;
|
|
3614
3659
|
return e === void 0 || e.trim() === "" ? [] : e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
3615
|
-
},
|
|
3660
|
+
}, au = (e) => {
|
|
3616
3661
|
let t = 2166136261;
|
|
3617
3662
|
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
3618
3663
|
return 1e3 + (t >>> 0) % 2147482647;
|
|
3619
|
-
},
|
|
3620
|
-
let n =
|
|
3664
|
+
}, ou = (e) => (process.env.DB_DIALECT ?? e?.store ?? "memory").toLowerCase(), su = async (e, t) => {
|
|
3665
|
+
let n = ou(e);
|
|
3621
3666
|
if (n === "memory") return $.info("sql dialect resolved: memory — in-process store, no persistence"), new It({});
|
|
3622
|
-
let r = (process.env.CDC ?? "1") !== "0", i = await y(n), a = i.id === "postgres" ? "LISTEN/NOTIFY" :
|
|
3667
|
+
let r = (process.env.CDC ?? "1") !== "0", i = await y(n), a = i.id === "postgres" ? "LISTEN/NOTIFY" : ii(i.id) ? "in-process bus" : i.id === "mariadb" ? "binlog CDC (ROW)" : i.id === "mssql" ? "Change Tracking (polled)" : i.id === "mysql" ? "binlog CDC (ROW)" : "inline only", o = i.id === "postgres" ? "native" : i.id === "mysql" ? "INSERT/UPDATE/DELETE then SELECT (no RETURNING)" : i.id === "mariadb" ? "native (INSERT/DELETE); UPDATE then SELECT" : i.id === "mssql" ? "OUTPUT INSERTED/DELETED" : ii(i.id) ? "native" : "unknown";
|
|
3623
3668
|
$.info(`sql dialect resolved: ${i.id} — CDC: ${r ? a : "inline emit (CDC=0)"}, RETURNING: ${o}`);
|
|
3624
|
-
let s =
|
|
3669
|
+
let s = eu(), { summary: c, fromEnv: l } = ru(s);
|
|
3625
3670
|
$.info(`db connection: ${c}${l ? "" : " (DEFAULT FALLBACK — no DB_URL / PG_HOST set)"}`), l || $.warn("db connection: falling back to localhost:5432/app — no DB_URL or PG_HOST env var set.\n If this app should run against its OWN postgres (e.g. its docker-compose), set DB_URL.\n Copy `.env.example` to `.env` in the app dir, or set DB_URL in the shell.\n Otherwise this app is silently using whatever DB is at localhost:5432/app — which is\n voltro-starter's docker default + may carry foreign tables that confuse the planner.");
|
|
3626
3671
|
let u;
|
|
3627
3672
|
if (r && (i.id === "mysql" || i.id === "mariadb")) {
|
|
3628
|
-
let { connectionFromConfig: e } = await v("@voltro/sql-mysql"), t = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, n =
|
|
3673
|
+
let { connectionFromConfig: e } = await v("@voltro/sql-mysql"), t = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, n = Qr().filter((e) => e.isReactive !== !1).map((e) => e.tableName).filter((e) => !e.startsWith("_voltro_"));
|
|
3629
3674
|
u = {
|
|
3630
|
-
serverId:
|
|
3675
|
+
serverId: au(t),
|
|
3631
3676
|
replicaId: t,
|
|
3632
3677
|
connection: e(s),
|
|
3633
3678
|
includeTables: n
|
|
@@ -3637,7 +3682,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3637
3682
|
tables: n.length
|
|
3638
3683
|
});
|
|
3639
3684
|
} else if (r && i.id === "mssql") {
|
|
3640
|
-
let { connectionFromConfig: e } = await v("@voltro/sql-mssql"), t = e(s), n = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, i =
|
|
3685
|
+
let { connectionFromConfig: e } = await v("@voltro/sql-mssql"), t = e(s), n = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, i = Qr().filter((e) => e.isReactive !== !1).map((e) => e.tableName).filter((e) => !e.startsWith("_voltro_"));
|
|
3641
3686
|
u = {
|
|
3642
3687
|
serverId: 0,
|
|
3643
3688
|
replicaId: n,
|
|
@@ -3659,7 +3704,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3659
3704
|
...t ? { tracerLayer: t } : {},
|
|
3660
3705
|
changeStrategy: r ? "cdc" : "inline",
|
|
3661
3706
|
...u ? { cdcConfig: u } : {}
|
|
3662
|
-
}), f =
|
|
3707
|
+
}), f = iu();
|
|
3663
3708
|
if (f.length === 0) return $.info("read replicas: none configured (DB_REPLICA_URLS unset) — all queries → primary"), ut.recordReplication({
|
|
3664
3709
|
replicaCount: 0,
|
|
3665
3710
|
rywPolicy: "off",
|
|
@@ -3667,14 +3712,14 @@ ${a.join("\n\n")}\n`);
|
|
|
3667
3712
|
region: null,
|
|
3668
3713
|
localityEnabled: !1
|
|
3669
3714
|
}), d;
|
|
3670
|
-
if (
|
|
3715
|
+
if (ii(i.id)) return $.warn(`read replicas: not applicable (${i.id} is single-process); ignoring DB_REPLICA_URLS`), ut.recordReplication({
|
|
3671
3716
|
replicaCount: 0,
|
|
3672
3717
|
rywPolicy: "off",
|
|
3673
3718
|
rywStore: "memory",
|
|
3674
3719
|
region: null,
|
|
3675
3720
|
localityEnabled: !1
|
|
3676
3721
|
}), d;
|
|
3677
|
-
let p = await
|
|
3722
|
+
let p = await fu(i.id);
|
|
3678
3723
|
if (p === null) return $.warn(`read replicas: no replication adapter for dialect ${i.id}; falling back to primary-only routing`), ut.recordReplication({
|
|
3679
3724
|
replicaCount: 0,
|
|
3680
3725
|
rywPolicy: "off",
|
|
@@ -3700,15 +3745,15 @@ ${a.join("\n\n")}\n`);
|
|
|
3700
3745
|
_ = ir({
|
|
3701
3746
|
client: n,
|
|
3702
3747
|
subscriber: n.duplicate()
|
|
3703
|
-
}), ee = "redis", $.info(`read replicas: ryw store = redis @ ${
|
|
3748
|
+
}), ee = "redis", $.info(`read replicas: ryw store = redis @ ${lu(e)}`);
|
|
3704
3749
|
} catch (e) {
|
|
3705
3750
|
$.warn("RYW_STORE=redis but ioredis import / connect failed — falling back to memory store", { err: e });
|
|
3706
3751
|
}
|
|
3707
3752
|
}
|
|
3708
3753
|
_ ||= Zn();
|
|
3709
|
-
let te =
|
|
3754
|
+
let te = uu(f.length), ne = cr(), re = ne && te.length > 0 ? vn({
|
|
3710
3755
|
currentRegion: ne,
|
|
3711
|
-
replicaRegions:
|
|
3756
|
+
replicaRegions: du(m, te),
|
|
3712
3757
|
inner: tr()
|
|
3713
3758
|
}) : tr();
|
|
3714
3759
|
return $.info(`read replicas: ${m.length} configured, ryw policy '${h}', dialect=${i.id}, region=${ne ?? "unknown"}` + (te.length > 0 ? ", replica-locality=on" : "")), ut.recordReplication({
|
|
@@ -3725,33 +3770,33 @@ ${a.join("\n\n")}\n`);
|
|
|
3725
3770
|
rywStore: _,
|
|
3726
3771
|
replicaSelector: re
|
|
3727
3772
|
});
|
|
3728
|
-
},
|
|
3729
|
-
let i =
|
|
3773
|
+
}, cu = async (e, t, n, r) => {
|
|
3774
|
+
let i = Da(t?.plugins ?? []), a = n === "postgres" || n === "mysql" || n === "mariadb", o = n === "postgres" ? "LISTEN/NOTIFY" : "binlog CDC";
|
|
3730
3775
|
if (!i) return n === "memory" || n === "sqlite" || n === "turso" ? r.info(`reactivity: single-instance (${n}) — no cross-replica fan-out needed`) : a ? r.info(`reactivity: cross-instance via native ${o} (${n})`) : r.warn(`reactivity: cross-instance fan-out is OFF for dialect '${n}'. A write on one replica will NOT reach clients on other replicas. Add @voltro/plugin-broadcast (Redis / NATS) to close the gap, or use postgres (LISTEN/NOTIFY) / mariadb (binlog CDC).`), null;
|
|
3731
3776
|
let s = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`;
|
|
3732
|
-
return i.broadcast.crossReplica ? a ? r.info(`reactivity: native ${o} (${n}) + @voltro/plugin-broadcast (${i.broadcast.provider.name}) — both paths active (own-origin skip dedups)`) : r.info(`reactivity: cross-instance via @voltro/plugin-broadcast (${i.broadcast.provider.name}) for dialect '${n}'`) : r.warn("reactivity: @voltro/plugin-broadcast resolved to the in-process memory provider — NO real cross-replica fan-out. Set BROADCAST_URL (redis:// or nats://) for a real bus."), await
|
|
3777
|
+
return i.broadcast.crossReplica ? a ? r.info(`reactivity: native ${o} (${n}) + @voltro/plugin-broadcast (${i.broadcast.provider.name}) — both paths active (own-origin skip dedups)`) : r.info(`reactivity: cross-instance via @voltro/plugin-broadcast (${i.broadcast.provider.name}) for dialect '${n}'`) : r.warn("reactivity: @voltro/plugin-broadcast resolved to the in-process memory provider — NO real cross-replica fan-out. Set BROADCAST_URL (redis:// or nats://) for a real bus."), await Ea({
|
|
3733
3778
|
store: e,
|
|
3734
3779
|
provider: i.broadcast.provider,
|
|
3735
3780
|
replicaId: s,
|
|
3736
3781
|
logger: r
|
|
3737
3782
|
});
|
|
3738
|
-
},
|
|
3783
|
+
}, lu = (e) => {
|
|
3739
3784
|
try {
|
|
3740
3785
|
let t = new URL(e);
|
|
3741
3786
|
return t.password &&= "***", t.toString();
|
|
3742
3787
|
} catch {
|
|
3743
3788
|
return "***";
|
|
3744
3789
|
}
|
|
3745
|
-
},
|
|
3790
|
+
}, uu = (e) => {
|
|
3746
3791
|
let t = process.env.DB_REPLICA_REGIONS;
|
|
3747
3792
|
if (!t) return [];
|
|
3748
3793
|
let n = t.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
3749
3794
|
return n.length === e ? n : ($.warn(`DB_REPLICA_REGIONS has ${n.length} entries but DB_REPLICA_URLS has ${e} — region awareness disabled. Provide one region per replica in the same order.`), []);
|
|
3750
|
-
},
|
|
3795
|
+
}, du = (e, t) => {
|
|
3751
3796
|
let n = /* @__PURE__ */ new Map();
|
|
3752
3797
|
for (let r = 0; r < e.length && r < t.length; r++) n.set(e[r], t[r]);
|
|
3753
3798
|
return n;
|
|
3754
|
-
},
|
|
3799
|
+
}, fu = async (e) => {
|
|
3755
3800
|
switch (e) {
|
|
3756
3801
|
case "postgres": return (await v("@voltro/sql-postgres")).postgresReplicationAdapter();
|
|
3757
3802
|
case "mysql":
|
|
@@ -3759,11 +3804,11 @@ ${a.join("\n\n")}\n`);
|
|
|
3759
3804
|
case "mssql": return (await v("@voltro/sql-mssql")).mssqlReplicationAdapter();
|
|
3760
3805
|
default: return null;
|
|
3761
3806
|
}
|
|
3762
|
-
},
|
|
3807
|
+
}, pu = async (e) => {
|
|
3763
3808
|
let t = A(e.find((e) => !e.startsWith("-")) ?? process.cwd()), n = await _(t);
|
|
3764
|
-
return n.ran ? n.exitCode : process.env.FRAMEWORK_DEV_INNER !== "1" && process.env.WATCH !== "0" ? (m(
|
|
3765
|
-
},
|
|
3766
|
-
let _ = Date.now(), v = await
|
|
3809
|
+
return n.ran ? n.exitCode : process.env.FRAMEWORK_DEV_INNER !== "1" && process.env.WATCH !== "0" ? (m(go({ root: t }), { scope: "voltro:dev" }), new Promise(() => {})) : mu(t);
|
|
3810
|
+
}, mu = async (m) => {
|
|
3811
|
+
let _ = Date.now(), v = await $l(m), b = Number(process.env.PORT ?? v?.port ?? 4e3), le = v?.name ?? E(m), x = c("api", le, b), ue = i(le);
|
|
3767
3812
|
await g({
|
|
3768
3813
|
id: x,
|
|
3769
3814
|
name: le,
|
|
@@ -3776,18 +3821,18 @@ ${a.join("\n\n")}\n`);
|
|
|
3776
3821
|
let S = s();
|
|
3777
3822
|
l(S), $.info("booting voltro dev", {
|
|
3778
3823
|
root: m,
|
|
3779
|
-
version:
|
|
3824
|
+
version: Sl,
|
|
3780
3825
|
logFile: ue.path
|
|
3781
3826
|
});
|
|
3782
3827
|
let he = await se({
|
|
3783
3828
|
project: E(m),
|
|
3784
|
-
cliVersion:
|
|
3829
|
+
cliVersion: Sl
|
|
3785
3830
|
});
|
|
3786
3831
|
if (he.kind === "not-personal") return $.error(`voltro dev needs a personal login — the stored credential belongs to no user.
|
|
3787
3832
|
${he.message}`), 1;
|
|
3788
3833
|
he.kind === "reported" && he.seat === "claimed" && $.info("cloud: this machine now counts toward your organisation's seats (voltro cloud whoami)");
|
|
3789
3834
|
let we = process.env.VOLTRO_DEV_HEALTH_PORT, Te = we === void 0 ? b + 1 : Number(we), Ee;
|
|
3790
|
-
Te > 0 && Number.isFinite(Te) && (Ee = await
|
|
3835
|
+
Te > 0 && Number.isFinite(Te) && (Ee = await xl({
|
|
3791
3836
|
port: Te,
|
|
3792
3837
|
log: {
|
|
3793
3838
|
info: (e, t) => $.debug(e, t),
|
|
@@ -3801,22 +3846,22 @@ ${a.join("\n\n")}\n`);
|
|
|
3801
3846
|
}).catch((e) => {
|
|
3802
3847
|
$.warn("agent-instructions seed failed (non-fatal)", {}, e);
|
|
3803
3848
|
});
|
|
3804
|
-
let C = await
|
|
3849
|
+
let C = await Pl(m);
|
|
3805
3850
|
$.info(`discovered ${C.length} files`, { count: C.length });
|
|
3806
|
-
let { pluginContributions: De, pluginErrorImports: ke, pluginRpcImports: je } = await
|
|
3851
|
+
let { pluginContributions: De, pluginErrorImports: ke, pluginRpcImports: je } = await tl(v?.plugins ?? [], v?.name ?? E(m), m), Me = await Xo({
|
|
3807
3852
|
root: m,
|
|
3808
3853
|
...De.length > 0 ? { pluginContributions: De } : {},
|
|
3809
3854
|
...ke.length > 0 ? { pluginErrorImports: ke } : {},
|
|
3810
3855
|
...je.length > 0 ? { pluginRpcImports: je } : {},
|
|
3811
3856
|
...v?.name === void 0 ? {} : { apiName: v.name }
|
|
3812
3857
|
});
|
|
3813
|
-
if (Me ? ($.info("codegen wrote rpcGroup", { path: k(m, Me) }), await
|
|
3814
|
-
let e = await
|
|
3815
|
-
if (e.length > 0) throw Error(e.map(
|
|
3858
|
+
if (Me ? ($.info("codegen wrote rpcGroup", { path: k(m, Me) }), await jo(Me)) : $.debug("codegen skipped — no descriptors discovered"), process.env.VOLTRO_BROWSER_SAFETY !== "off") {
|
|
3859
|
+
let e = await ko(m, C);
|
|
3860
|
+
if (e.length > 0) throw Error(e.map(Ao).join("\n\n"));
|
|
3816
3861
|
}
|
|
3817
|
-
let Ne =
|
|
3862
|
+
let Ne = ou(v ?? null), Pe = Ne === "mariadb" ? "mariadb" : Ne === "mssql" ? "mssql" : void 0, Le = Pe !== void 0 && (process.env.CDC ?? "1") !== "0", { queries: w, mutations: D, actions: A, streams: dt, workflows: j, workflowWorkers: ft, eventTriggers: mt, schedules: M, connections: ht, tables: gt, featureMix: vt, tenantScopedTables: yt, softDeleteScopedTables: bt } = await Ql(C, { cdc: Le }), xt = j.length > 0 || mt.length > 0, F = await $l(m), wt = Xa(F?.http ?? {});
|
|
3818
3863
|
gr(lr(F?.secrets));
|
|
3819
|
-
let I =
|
|
3864
|
+
let I = Ma(Ki(F?.env) ? F.env : void 0, m);
|
|
3820
3865
|
I.minted.length > 0 && I.file !== void 0 && ($.warn(`minted ${I.minted.length} project secret(s) into ${k(m, I.file)} — unique to this project, gitignored. Your DEPLOYMENT needs its own values (\`voltro secret generate\`).`, {
|
|
3821
3866
|
keys: I.minted,
|
|
3822
3867
|
file: k(m, I.file)
|
|
@@ -3836,7 +3881,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3836
3881
|
"apikeys:issue:other"
|
|
3837
3882
|
].some((t) => e.has(t)) && !e.has("admin:full") && $.warn("apiKeys is enabled but no role declares any of apikeys:issue:self / :org / :other. The management routes are mounted and every issue request will fail its guard — the capability is on and reachable by nobody. Grant the right one in your role map (`:self` lets a user mint their own key, `:org` a shared one, `:other` on behalf of a colleague).");
|
|
3838
3883
|
}
|
|
3839
|
-
let Et = (typeof Tt == "object" ? Tt.prefix : void 0) ?? "voltro_", Dt, Ot = Tt ? [sn({ resolveByHash: (e, t) => Dt ? Dt.resolveByHash(e, t) : Promise.resolve(null) }, { prefix: Et })] : [], kt =
|
|
3884
|
+
let Et = (typeof Tt == "object" ? Tt.prefix : void 0) ?? "voltro_", Dt, Ot = Tt ? [sn({ resolveByHash: (e, t) => Dt ? Dt.resolveByHash(e, t) : Promise.resolve(null) }, { prefix: Et })] : [], kt = El([...F?.auth?.strategies ?? [], ...Ot], ua(F?.plugins ?? []), F?.auth?.anonymousTenantRequired ?? !1, F?.auth?.resolveScopes, () => L.current), At = Ol(kt), jt = _e({
|
|
3840
3885
|
mix: vt,
|
|
3841
3886
|
plugins: F?.plugins ?? [],
|
|
3842
3887
|
cdc: Le,
|
|
@@ -3849,8 +3894,8 @@ ${a.join("\n\n")}\n`);
|
|
|
3849
3894
|
}
|
|
3850
3895
|
return t;
|
|
3851
3896
|
})();
|
|
3852
|
-
for (let e of z)
|
|
3853
|
-
let It =
|
|
3897
|
+
for (let e of z) ni(e);
|
|
3898
|
+
let It = kc({
|
|
3854
3899
|
plugins: F?.plugins ?? [],
|
|
3855
3900
|
appName: F?.name ?? E(m),
|
|
3856
3901
|
appType: "api",
|
|
@@ -3858,12 +3903,12 @@ ${a.join("\n\n")}\n`);
|
|
|
3858
3903
|
log: $
|
|
3859
3904
|
});
|
|
3860
3905
|
F?.plugins?.length && ($.info("plugins loaded", { plugins: F.plugins.map((e) => e.name) }), await It.activate());
|
|
3861
|
-
let Lt = await It.gatherObservability(), Rt =
|
|
3906
|
+
let Lt = await It.gatherObservability(), Rt = Lc(F?.plugins ?? []);
|
|
3862
3907
|
Rt.endpoints.length > 0 && $.info("plugin inspect endpoints registered", {
|
|
3863
3908
|
count: Rt.endpoints.length,
|
|
3864
3909
|
endpoints: Rt.endpoints.map((e) => `${e.method} ${e.path}`)
|
|
3865
3910
|
});
|
|
3866
|
-
let zt =
|
|
3911
|
+
let zt = Jc(F?.plugins ?? []);
|
|
3867
3912
|
zt.length > 0 && $.info("plugin dashboard mounts registered", {
|
|
3868
3913
|
count: zt.length,
|
|
3869
3914
|
mounts: zt.map((e) => `${e.fullId} (${e.slot})`)
|
|
@@ -3905,7 +3950,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3905
3950
|
if (an.length > 0) {
|
|
3906
3951
|
let e = await ye(an, $t);
|
|
3907
3952
|
on = e.agents.map((e) => e.descriptor.name);
|
|
3908
|
-
for (let t of e.agents) for (let e of
|
|
3953
|
+
for (let t of e.agents) for (let e of mc(t)) e.kind === "action" ? A.push({
|
|
3909
3954
|
file: e.file,
|
|
3910
3955
|
descriptor: e.descriptor,
|
|
3911
3956
|
executor: e.executor
|
|
@@ -3919,16 +3964,16 @@ ${a.join("\n\n")}\n`);
|
|
|
3919
3964
|
routes: e.agents.flatMap((e) => [`${e.descriptor.name}.send`, `${e.descriptor.name}.messages`])
|
|
3920
3965
|
});
|
|
3921
3966
|
}
|
|
3922
|
-
let cn =
|
|
3967
|
+
let cn = gc();
|
|
3923
3968
|
(cn.queries.length > 0 || cn.mutations.length > 0) && (w.push(...cn.queries), D.push(...cn.mutations), $.info("undo built-ins registered", { routes: [
|
|
3924
3969
|
"__voltro.undo.log",
|
|
3925
3970
|
"__voltro.undo.apply",
|
|
3926
3971
|
"__voltro.undo.redo"
|
|
3927
3972
|
] }));
|
|
3928
|
-
let dn = $.child("aggregate"), mn = C.filter((e) => Re.test(e)), hn = mn.length > 0 ? await
|
|
3929
|
-
for (let e of
|
|
3930
|
-
let vn = F?.restRoutes ?? [], wn = C.filter((e) => Ae.test(e)).length, Dn = C.filter((e) => ze.test(e)).length, On = C.filter((e) => /\.seed\.ts$/.test(e)).length, kn = C.filter((e) => Oe.test(e)).length, jn = C.filter((e) =>
|
|
3931
|
-
|
|
3973
|
+
let dn = $.child("aggregate"), mn = C.filter((e) => Re.test(e)), hn = mn.length > 0 ? await Ps(mn, dn) : [], gn = hn.map((e) => e.definition.name);
|
|
3974
|
+
for (let e of ti()) $.warn(`identifier length · ${e}`);
|
|
3975
|
+
let vn = F?.restRoutes ?? [], wn = C.filter((e) => Ae.test(e)).length, Dn = C.filter((e) => ze.test(e)).length, On = C.filter((e) => /\.seed\.ts$/.test(e)).length, kn = C.filter((e) => Oe.test(e)).length, jn = C.filter((e) => dc.test(e)).length;
|
|
3976
|
+
Qo(Zo([
|
|
3932
3977
|
w,
|
|
3933
3978
|
D,
|
|
3934
3979
|
A,
|
|
@@ -3989,13 +4034,13 @@ ${a.join("\n\n")}\n`);
|
|
|
3989
4034
|
...Lt.sampler === void 0 ? {} : { sampler: Lt.sampler }
|
|
3990
4035
|
});
|
|
3991
4036
|
qn.mode === "off" ? qn.bufferOnly || $.info("tracing disabled", { reason: "buffer off" }) : $.info("tracing enabled", { mode: qn.mode });
|
|
3992
|
-
let Zn = qn.mode === "off" && qn.bufferOnly === !1 ? void 0 : qn.layer, B = await
|
|
3993
|
-
L.current = B;
|
|
3994
|
-
for (let e of
|
|
3995
|
-
dialect:
|
|
4037
|
+
let Zn = qn.mode === "off" && qn.bufferOnly === !1 ? void 0 : qn.layer, B = await su(F, Zn);
|
|
4038
|
+
L.current = Dr(B, ou(F ?? null));
|
|
4039
|
+
for (let e of Ba({
|
|
4040
|
+
dialect: ou(F ?? null),
|
|
3996
4041
|
changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
|
|
3997
4042
|
dbUrl: process.env.DB_URL,
|
|
3998
|
-
tables:
|
|
4043
|
+
tables: Qr().map((e) => ({
|
|
3999
4044
|
tableName: e.tableName,
|
|
4000
4045
|
isReactive: e.isReactive === !0
|
|
4001
4046
|
})),
|
|
@@ -4013,17 +4058,17 @@ ${a.join("\n\n")}\n`);
|
|
|
4013
4058
|
usage: t
|
|
4014
4059
|
}), $.info("api keys active", { prefix: Et });
|
|
4015
4060
|
}
|
|
4016
|
-
let $n =
|
|
4061
|
+
let $n = vs({
|
|
4017
4062
|
definitions: ht.map((e) => e.definition),
|
|
4018
4063
|
store: B,
|
|
4019
|
-
publicUrl:
|
|
4064
|
+
publicUrl: bs(b),
|
|
4020
4065
|
log: $.child("connections")
|
|
4021
4066
|
});
|
|
4022
4067
|
w.push(...$n.queries), D.push(...$n.mutations), A.push(...$n.actions);
|
|
4023
|
-
let tr =
|
|
4068
|
+
let tr = ou(F), ir = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, ar, or;
|
|
4024
4069
|
if (tr !== "memory") {
|
|
4025
4070
|
let e = await y(tr);
|
|
4026
|
-
ar = _t.make(e.makeSqlLayer(
|
|
4071
|
+
ar = _t.make(e.makeSqlLayer(eu())), or = await ar.runPromise(Mr.SqlClient);
|
|
4027
4072
|
}
|
|
4028
4073
|
let cr = An({
|
|
4029
4074
|
coordinator: [
|
|
@@ -4042,34 +4087,34 @@ ${a.join("\n\n")}\n`);
|
|
|
4042
4087
|
}
|
|
4043
4088
|
};
|
|
4044
4089
|
for (let e of F?.plugins ?? []) e.bindDataStore?.(B, fr);
|
|
4045
|
-
let pr = await
|
|
4090
|
+
let pr = await cu(B, F, ou(F), $);
|
|
4046
4091
|
F?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = F.cache), F?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = F.cacheRedisUrl), F?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = F.cacheRedisDriver), F?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = F.cacheKeyPrefix);
|
|
4047
|
-
let { service: mr, invalidationBus: hr, snapshotCache: br, cache: Cr, backend: wr, stats: Tr, dispose: Er } = await
|
|
4092
|
+
let { service: mr, invalidationBus: hr, snapshotCache: br, cache: Cr, backend: wr, stats: Tr, dispose: Er } = await Ga({ env: process.env });
|
|
4048
4093
|
$.info(`cache backend resolved: ${wr}` + (wr === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), F?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = F.kv), F?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = F.kvRedisUrl), F?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = F.kvKeyPrefix);
|
|
4049
|
-
let { kv:
|
|
4050
|
-
$.info(`kv backend resolved: ${
|
|
4051
|
-
let
|
|
4094
|
+
let { kv: Or, service: kr, backend: Pr } = await Tn({ store: B });
|
|
4095
|
+
$.info(`kv backend resolved: ${Pr}` + (Pr === "database" ? " (durable, _voltro_kv)" : Pr === "memory" ? " — in-process, non-durable" : ` (driver ${process.env.KV_REDIS_DRIVER ?? "resp"}, non-durable)`));
|
|
4096
|
+
let Rr = ou(F), Yr = F?.analytics !== void 0 && F.analytics.kind !== "noop" && Rr !== "memory" ? (await y(Rr)).makeSqlLayer(eu()) : void 0, Xr = await $o({
|
|
4052
4097
|
spec: F?.analytics,
|
|
4053
|
-
sqlLayer:
|
|
4098
|
+
sqlLayer: Yr,
|
|
4054
4099
|
log: $
|
|
4055
4100
|
});
|
|
4056
|
-
|
|
4057
|
-
let
|
|
4101
|
+
Xr.spec;
|
|
4102
|
+
let Zr = Xr.sink, ai = Gt({
|
|
4058
4103
|
store: B,
|
|
4059
|
-
sink:
|
|
4104
|
+
sink: Zr,
|
|
4060
4105
|
log: $
|
|
4061
4106
|
});
|
|
4062
|
-
|
|
4063
|
-
provider:
|
|
4064
|
-
tables:
|
|
4107
|
+
ai.tables.length > 0 && $.info("analytics mirror", {
|
|
4108
|
+
provider: Zr.info.provider,
|
|
4109
|
+
tables: ai.tables
|
|
4065
4110
|
}), process.on("beforeExit", () => {
|
|
4066
|
-
|
|
4111
|
+
ai.detach();
|
|
4067
4112
|
});
|
|
4068
|
-
let
|
|
4069
|
-
if (
|
|
4113
|
+
let si = Xr.dispose, ci = ou(F), li;
|
|
4114
|
+
if (ci !== "memory" && process.env.VOLTRO_AUTO_MIGRATE !== "0") {
|
|
4070
4115
|
let e = Date.now(), t = (process.env.NODE_ENV ?? "").toLowerCase() === "production" ? "prod" : (process.env.NODE_ENV ?? "").toLowerCase() === "staging" ? "staging" : "dev";
|
|
4071
4116
|
$.info("auto-migrate: planning schema", {
|
|
4072
|
-
dialect:
|
|
4117
|
+
dialect: ci,
|
|
4073
4118
|
env: t,
|
|
4074
4119
|
tables: z.length
|
|
4075
4120
|
}), Ee?.set({
|
|
@@ -4077,37 +4122,37 @@ ${a.join("\n\n")}\n`);
|
|
|
4077
4122
|
tablesTotal: z.length
|
|
4078
4123
|
});
|
|
4079
4124
|
try {
|
|
4080
|
-
let n = await y(
|
|
4081
|
-
|
|
4082
|
-
let i =
|
|
4083
|
-
conn:
|
|
4084
|
-
pendingIds: await N.runPromise(
|
|
4085
|
-
optIn: process.env[
|
|
4125
|
+
let n = await y(ci), r = n.makeSqlLayer(eu());
|
|
4126
|
+
li = r, await aa(Gl(z.filter((e) => e.tableName.startsWith("_voltro_") || e.tableName === "voltro_isr_cache"), z), r, n.id);
|
|
4127
|
+
let i = Wa({
|
|
4128
|
+
conn: eu(),
|
|
4129
|
+
pendingIds: await N.runPromise(Mr.SqlClient.pipe(N.flatMap((e) => na(e, m)), N.provide(r))),
|
|
4130
|
+
optIn: process.env[Va] === "1"
|
|
4086
4131
|
});
|
|
4087
4132
|
if (!i.allowed) throw $.error(`file-based migrations: ${i.message}`), Error("file-based migrations refused — see error above");
|
|
4088
|
-
let a = await N.runPromise(
|
|
4133
|
+
let a = await N.runPromise(Mr.SqlClient.pipe(N.flatMap((e) => ia(e, {
|
|
4089
4134
|
projectRoot: m,
|
|
4090
4135
|
env: t,
|
|
4091
4136
|
appliedBy: `boot:${t}`
|
|
4092
4137
|
})), N.provide(r)));
|
|
4093
4138
|
a.applied.length > 0 && $.info(`file-based migrations: applied ${a.applied.length}`, { applied: a.applied.map((e) => `${e.id} (${e.durationMs}ms)`) });
|
|
4094
|
-
let o = await N.runPromise(
|
|
4139
|
+
let o = await N.runPromise(Mr.SqlClient.pipe(N.flatMap((e) => oa(e, z, {
|
|
4095
4140
|
appliedBy: `boot:${t}`,
|
|
4096
4141
|
environment: t,
|
|
4097
4142
|
dialectId: n.id
|
|
4098
4143
|
})), N.provide(r)));
|
|
4099
|
-
if (o.kind === "refused-blocked" || o.kind === "prod-mismatch") throw $.error(
|
|
4100
|
-
$.info(
|
|
4144
|
+
if (o.kind === "refused-blocked" || o.kind === "prod-mismatch") throw $.error($i(o, n.id)), Error("auto-migrate refused — see error above");
|
|
4145
|
+
$.info($i(o, n.id), { durationMs: Date.now() - e });
|
|
4101
4146
|
} catch (e) {
|
|
4102
4147
|
throw $.error("auto-migrate failed — aborting boot", { err: e }), Ee?.set({
|
|
4103
4148
|
phase: "error",
|
|
4104
4149
|
error: e instanceof Error ? e.message : String(e)
|
|
4105
4150
|
}), e;
|
|
4106
4151
|
}
|
|
4107
|
-
} else
|
|
4108
|
-
let
|
|
4109
|
-
if ((F?.plugins ?? []).some((e) => (e.extendSchema?.migrations?.length ?? 0) > 0) &&
|
|
4110
|
-
let e = (await y(
|
|
4152
|
+
} else ci !== "memory" && $.info("auto-migrate: skipped (VOLTRO_AUTO_MIGRATE=0)");
|
|
4153
|
+
let ui = ou(F);
|
|
4154
|
+
if ((F?.plugins ?? []).some((e) => (e.extendSchema?.migrations?.length ?? 0) > 0) && ui !== "memory") {
|
|
4155
|
+
let e = (await y(ui)).makeSqlLayer(eu());
|
|
4111
4156
|
try {
|
|
4112
4157
|
let t = await N.runPromise(pe(F.plugins).pipe(N.provide(e))), n = t.filter((e) => e.status === "applied"), r = t.filter((e) => e.status === "skipped");
|
|
4113
4158
|
$.info("plugin migrations complete", {
|
|
@@ -4118,108 +4163,108 @@ ${a.join("\n\n")}\n`);
|
|
|
4118
4163
|
throw $.error("plugin migrations failed — aborting boot", { err: e }), e;
|
|
4119
4164
|
}
|
|
4120
4165
|
}
|
|
4121
|
-
let
|
|
4166
|
+
let di = _l(B, S);
|
|
4122
4167
|
process.on("beforeExit", () => {
|
|
4123
|
-
|
|
4168
|
+
di();
|
|
4124
4169
|
});
|
|
4125
4170
|
let hi = Wn(z);
|
|
4126
4171
|
_r({
|
|
4127
4172
|
dataStore: B,
|
|
4128
4173
|
schemaRegistry: hi
|
|
4129
4174
|
});
|
|
4130
|
-
let
|
|
4131
|
-
if (
|
|
4132
|
-
|
|
4133
|
-
for (let e of
|
|
4134
|
-
let e = await oe(
|
|
4175
|
+
let vi = $.child("seeds"), bi = C.filter((e) => /\.seed\.ts$/.test(e)), xi = bi.length > 0 ? await ae(bi, vi) : [];
|
|
4176
|
+
if (xi.length > 0) {
|
|
4177
|
+
vi.info("discovered seeds", { ids: xi.map((e) => e.definition.id) });
|
|
4178
|
+
for (let e of xi) ut.registerSeed(e);
|
|
4179
|
+
let e = await oe(xi, B, vi);
|
|
4135
4180
|
for (let t of e) ut.recordSeedResult(t);
|
|
4136
4181
|
let t = e.filter((e) => e.status === "failed");
|
|
4137
|
-
t.length > 0 &&
|
|
4182
|
+
t.length > 0 && vi.warn("one or more seeds failed (server continues)", { failedIds: t.map((e) => e.seedId) });
|
|
4138
4183
|
}
|
|
4139
|
-
let
|
|
4140
|
-
|
|
4141
|
-
|
|
4184
|
+
let Ci = $.child("startup"), wi = C.filter((e) => ze.test(e)), Ti = wi.length > 0 ? await lt(wi, Ci) : [], Ei;
|
|
4185
|
+
Ti.length > 0 && (Ci.info("discovered startups", { ids: Ti.map((e) => e.id) }), Ei = await ct(Ti, B, Ci)), Ei && process.on("beforeExit", () => {
|
|
4186
|
+
Ei.shutdown();
|
|
4142
4187
|
});
|
|
4143
|
-
let
|
|
4144
|
-
|
|
4145
|
-
|
|
4188
|
+
let Di = $.child("subscribe"), ki = C.filter((e) => Ae.test(e)), Mi = ki.length > 0 ? await fs(ki, Di) : [], Ni;
|
|
4189
|
+
Mi.length > 0 && (Di.info("discovered subscribers", { subscribers: Mi.map((e) => `${e.id}@${e.definition.table}`) }), Ni = ps(Mi, B, Di, hi)), Ni && process.on("beforeExit", () => {
|
|
4190
|
+
Ni();
|
|
4146
4191
|
}), un(), vr((e) => _n(B, e.subjectId, e.resourceType, e.resourceId));
|
|
4147
|
-
let
|
|
4148
|
-
handlers:
|
|
4192
|
+
let Pi = $.child("outbox"), Fi = C.filter((e) => Fe.test(e)), qi = Fi.length > 0 ? await hs(Fi, Pi) : [], Ji = qi.length > 0 ? gs({
|
|
4193
|
+
handlers: qi,
|
|
4149
4194
|
store: B,
|
|
4150
|
-
log:
|
|
4195
|
+
log: Pi
|
|
4151
4196
|
}) : void 0;
|
|
4152
|
-
|
|
4153
|
-
|
|
4197
|
+
Ji && process.on("beforeExit", () => {
|
|
4198
|
+
Ji.stop();
|
|
4154
4199
|
});
|
|
4155
|
-
let
|
|
4156
|
-
if (hn.length > 0 &&
|
|
4157
|
-
|
|
4200
|
+
let Yi = Ds(), Xi = ou(F);
|
|
4201
|
+
if (hn.length > 0 && Xi !== "memory") try {
|
|
4202
|
+
Yi = Ms((await y(Xi)).makeSqlLayer(eu()));
|
|
4158
4203
|
} catch (e) {
|
|
4159
4204
|
dn.warn("aggregate: SQL storage init failed — falling back to in-process", { err: e });
|
|
4160
4205
|
}
|
|
4161
|
-
let
|
|
4206
|
+
let Zi = Xi === "memory" ? yr : bn(B, `aggregate@${process.pid}`, dn), sa = hn.length > 0 ? await Ks({
|
|
4162
4207
|
discovered: hn,
|
|
4163
4208
|
store: B,
|
|
4164
|
-
analytics:
|
|
4165
|
-
storage:
|
|
4166
|
-
coordinator:
|
|
4209
|
+
analytics: Zr,
|
|
4210
|
+
storage: Yi,
|
|
4211
|
+
coordinator: Zi,
|
|
4167
4212
|
log: dn
|
|
4168
4213
|
}) : {
|
|
4169
|
-
registry:
|
|
4214
|
+
registry: qs,
|
|
4170
4215
|
detach: () => {},
|
|
4171
4216
|
registered: []
|
|
4172
4217
|
};
|
|
4173
|
-
|
|
4174
|
-
names:
|
|
4175
|
-
storage:
|
|
4176
|
-
coordination:
|
|
4218
|
+
sa.registered.length > 0 && dn.info("aggregates registered", {
|
|
4219
|
+
names: sa.registered,
|
|
4220
|
+
storage: Xi === "memory" ? "in-process" : "sql-backed",
|
|
4221
|
+
coordination: Zi.kind
|
|
4177
4222
|
}), process.on("beforeExit", () => {
|
|
4178
|
-
|
|
4223
|
+
sa.detach();
|
|
4179
4224
|
});
|
|
4180
|
-
let
|
|
4225
|
+
let H = ou(F), ca, la = F?.scheduling ?? {}, pa = la.trigger ?? "self", ma = la.coordination ?? ([
|
|
4181
4226
|
"postgres",
|
|
4182
4227
|
"mariadb",
|
|
4183
4228
|
"mysql",
|
|
4184
4229
|
"mssql"
|
|
4185
|
-
].includes(
|
|
4230
|
+
].includes(H) ? "advisoryLock" : "single"), ha = ma === "cluster" && (/* @__PURE__ */ new Set([
|
|
4186
4231
|
"postgres",
|
|
4187
4232
|
"mysql",
|
|
4188
4233
|
"mariadb",
|
|
4189
4234
|
"mssql"
|
|
4190
|
-
])).has(
|
|
4235
|
+
])).has(H), ga = ha ? M.filter((e) => (e.trigger ?? pa) === "self").map((e) => Wr({
|
|
4191
4236
|
name: e.name,
|
|
4192
4237
|
cron: Qt(e),
|
|
4193
4238
|
execute: async () => {
|
|
4194
|
-
await
|
|
4239
|
+
await ca?.fireFromCluster(e.name);
|
|
4195
4240
|
}
|
|
4196
|
-
})) : [],
|
|
4197
|
-
if (
|
|
4198
|
-
let e = await y(
|
|
4199
|
-
if ($.info(`workflow engine: cluster-${n}, dialect=${e.id}` + (n === "memory" ? " — single-process durable replay, no horizontal scaling" + (
|
|
4200
|
-
let e = await
|
|
4241
|
+
})) : [], _a = await (async () => {
|
|
4242
|
+
if (H === "memory") return Nr.layerMemory;
|
|
4243
|
+
let e = await y(H), t = e.makeSqlLayer(eu()), n = qr({ sqliteFamily: ii(e.id) });
|
|
4244
|
+
if ($.info(`workflow engine: cluster-${n}, dialect=${e.id}` + (n === "memory" ? " — single-process durable replay, no horizontal scaling" + (ii(e.id) ? "" : " (VOLTRO_WORKFLOW_RUNNER_STORAGE=memory: SqlRunnerStorage/cluster_runners + GET_LOCK skipped)") : "")), e.id === "mssql") {
|
|
4245
|
+
let e = await cs(process.cwd());
|
|
4201
4246
|
e && $.warn(e);
|
|
4202
4247
|
}
|
|
4203
|
-
return
|
|
4248
|
+
return Jr({
|
|
4204
4249
|
sqlClientLayer: t,
|
|
4205
4250
|
runnerStorage: n,
|
|
4206
4251
|
dialectId: e.id,
|
|
4207
4252
|
...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
|
|
4208
|
-
...
|
|
4253
|
+
...ga.length > 0 ? { extraShardingLayers: ga } : {}
|
|
4209
4254
|
});
|
|
4210
4255
|
})();
|
|
4211
|
-
$.info("workflow engine selected", { engine:
|
|
4212
|
-
let
|
|
4256
|
+
$.info("workflow engine selected", { engine: H === "postgres" ? "cluster-postgres" : "in-memory" });
|
|
4257
|
+
let Sa, wa = /* @__PURE__ */ new Map(), Ea = () => `wfctx_${globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`, Da = async (e, t, n) => {
|
|
4213
4258
|
let r = {
|
|
4214
4259
|
...n,
|
|
4215
4260
|
source: n.source ?? `workflow:${e}`
|
|
4216
4261
|
};
|
|
4217
|
-
|
|
4262
|
+
wa.set(t, r);
|
|
4218
4263
|
try {
|
|
4219
4264
|
let n = await B.query({
|
|
4220
4265
|
table: "_voltro_workflow_start_contexts",
|
|
4221
4266
|
order: [],
|
|
4222
|
-
predicate:
|
|
4267
|
+
predicate: V("executionId", t),
|
|
4223
4268
|
projection: ["id"],
|
|
4224
4269
|
skip: void 0,
|
|
4225
4270
|
take: 1
|
|
@@ -4234,7 +4279,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4234
4279
|
createdAt: /* @__PURE__ */ new Date()
|
|
4235
4280
|
};
|
|
4236
4281
|
n[0] === void 0 ? await B.insert("_voltro_workflow_start_contexts", {
|
|
4237
|
-
id:
|
|
4282
|
+
id: Ea(),
|
|
4238
4283
|
...i
|
|
4239
4284
|
}) : await B.update("_voltro_workflow_start_contexts", n[0].id, i);
|
|
4240
4285
|
} catch (n) {
|
|
@@ -4244,14 +4289,14 @@ ${a.join("\n\n")}\n`);
|
|
|
4244
4289
|
reason: n?.message ?? String(n)
|
|
4245
4290
|
});
|
|
4246
4291
|
}
|
|
4247
|
-
},
|
|
4248
|
-
let n =
|
|
4292
|
+
}, ka = async (e, t) => {
|
|
4293
|
+
let n = wa.get(t);
|
|
4249
4294
|
if (n !== void 0) return n;
|
|
4250
4295
|
try {
|
|
4251
4296
|
let e = (await B.query({
|
|
4252
4297
|
table: "_voltro_workflow_start_contexts",
|
|
4253
4298
|
order: [],
|
|
4254
|
-
predicate:
|
|
4299
|
+
predicate: V("executionId", t),
|
|
4255
4300
|
projection: void 0,
|
|
4256
4301
|
skip: void 0,
|
|
4257
4302
|
take: 1
|
|
@@ -4270,7 +4315,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4270
4315
|
...e.parentExecutionId === null ? {} : { parentExecutionId: e.parentExecutionId },
|
|
4271
4316
|
...e.parentClosePolicy === null ? {} : { parentClosePolicy: e.parentClosePolicy }
|
|
4272
4317
|
};
|
|
4273
|
-
return
|
|
4318
|
+
return wa.set(t, r), r;
|
|
4274
4319
|
} catch (e) {
|
|
4275
4320
|
$.warn("workflow.startContext.resolve failed", {
|
|
4276
4321
|
executionId: t,
|
|
@@ -4278,26 +4323,26 @@ ${a.join("\n\n")}\n`);
|
|
|
4278
4323
|
});
|
|
4279
4324
|
return;
|
|
4280
4325
|
}
|
|
4281
|
-
},
|
|
4326
|
+
}, U = j.length > 0 ? Fn(() => Sa) : void 0, W = $.child("webhooks"), Aa = C.filter((e) => Oe.test(e)), G = Aa.length > 0 ? await uc(Aa, W) : {
|
|
4282
4327
|
outgoing: [],
|
|
4283
4328
|
incoming: [],
|
|
4284
4329
|
providers: []
|
|
4285
4330
|
};
|
|
4286
|
-
G.outgoing.length + G.incoming.length + G.providers.length > 0 &&
|
|
4331
|
+
G.outgoing.length + G.incoming.length + G.providers.length > 0 && W.info("discovered webhooks", {
|
|
4287
4332
|
outgoing: G.outgoing.map((e) => e.descriptor.id),
|
|
4288
4333
|
incoming: G.incoming.map((e) => e.descriptor.id),
|
|
4289
4334
|
providers: G.providers.map((e) => e.descriptor.id)
|
|
4290
4335
|
});
|
|
4291
|
-
let ja = C.filter((e) =>
|
|
4336
|
+
let ja = C.filter((e) => dc.test(e));
|
|
4292
4337
|
if (ja.length > 0) {
|
|
4293
|
-
let e = $.child("mail"), t = await
|
|
4294
|
-
t.templates.length > 0 && (
|
|
4338
|
+
let e = $.child("mail"), t = await fc(ja, e);
|
|
4339
|
+
t.templates.length > 0 && (Ta(t.templates.map((e) => e.template)), e.info("discovered email templates", { templates: t.templates.map((e) => e.template.name) }));
|
|
4295
4340
|
}
|
|
4296
|
-
let
|
|
4341
|
+
let Na = /* @__PURE__ */ new Map();
|
|
4297
4342
|
for (let e of G.incoming) {
|
|
4298
|
-
let t = e.descriptor.path ??
|
|
4343
|
+
let t = e.descriptor.path ?? ba(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = Ca(e.descriptor, {
|
|
4299
4344
|
resolveSecret: async () => process.env[n] ?? null,
|
|
4300
|
-
resolveWorkflows: () =>
|
|
4345
|
+
resolveWorkflows: () => U === void 0 ? void 0 : Yn(U, {
|
|
4301
4346
|
traceId: `incoming:${e.descriptor.id}`,
|
|
4302
4347
|
source: `incoming:${e.descriptor.id}`
|
|
4303
4348
|
}),
|
|
@@ -4309,36 +4354,36 @@ ${a.join("\n\n")}\n`);
|
|
|
4309
4354
|
idempotency: e.idempotency,
|
|
4310
4355
|
durationMs: e.durationMs
|
|
4311
4356
|
};
|
|
4312
|
-
e.status >= 500 ?
|
|
4357
|
+
e.status >= 500 ? W.error("incoming delivery failed", t) : e.status >= 400 ? W.warn("incoming delivery rejected", t) : W.info("incoming delivery handled", t);
|
|
4313
4358
|
}
|
|
4314
4359
|
});
|
|
4315
|
-
|
|
4360
|
+
Na.set(t, r), W.info("mounted incoming webhook", {
|
|
4316
4361
|
id: e.descriptor.id,
|
|
4317
4362
|
path: t,
|
|
4318
4363
|
secretEnvKey: n
|
|
4319
4364
|
});
|
|
4320
4365
|
}
|
|
4321
|
-
let
|
|
4322
|
-
Ia.length > 0 && (
|
|
4366
|
+
let Pa = $.child("reaction"), Fa = C.filter((e) => Ie.test(e)), Ia = Fa.length > 0 ? await Ss(Fa, Pa) : [], Ra;
|
|
4367
|
+
Ia.length > 0 && (Pa.info("discovered reactions", { reactions: Ia.map((e) => `${e.definition.name}@${e.definition.watch.table}`) }), Ra = ws(Ia, B, {
|
|
4323
4368
|
runAct: async (e, t) => {
|
|
4324
4369
|
if (e.kind === "workflow") {
|
|
4325
|
-
if (
|
|
4326
|
-
|
|
4370
|
+
if (U === void 0) {
|
|
4371
|
+
Pa.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: e.workflow });
|
|
4327
4372
|
return;
|
|
4328
4373
|
}
|
|
4329
4374
|
let n = t.new ?? t.old ?? {};
|
|
4330
|
-
await Yn(
|
|
4375
|
+
await Yn(U, {
|
|
4331
4376
|
traceId: `reaction:${e.workflow}`,
|
|
4332
4377
|
source: `reaction:${e.workflow}`
|
|
4333
4378
|
}).start(e.workflow, n);
|
|
4334
4379
|
return;
|
|
4335
4380
|
}
|
|
4336
|
-
await
|
|
4381
|
+
await Cs(e.agent, t, {
|
|
4337
4382
|
findAgentSend: (e) => A.find((t) => t.descriptor.name === `${e}.send`),
|
|
4338
4383
|
runAction: (e, t, n) => Promise.resolve(Po(e, t, n)),
|
|
4339
|
-
makeSubject: (e) =>
|
|
4384
|
+
makeSubject: (e) => yi(e),
|
|
4340
4385
|
now: () => Date.now(),
|
|
4341
|
-
log:
|
|
4386
|
+
log: Pa
|
|
4342
4387
|
});
|
|
4343
4388
|
},
|
|
4344
4389
|
checkBudget: async (e, t) => {
|
|
@@ -4349,13 +4394,13 @@ ${a.join("\n\n")}\n`);
|
|
|
4349
4394
|
limitUsd: t
|
|
4350
4395
|
}))))._tag === "Right";
|
|
4351
4396
|
} catch (t) {
|
|
4352
|
-
return
|
|
4397
|
+
return Pa.warn("reaction budget check failed — refusing the act", { tenantId: e }, t), !1;
|
|
4353
4398
|
}
|
|
4354
4399
|
}
|
|
4355
|
-
},
|
|
4356
|
-
|
|
4400
|
+
}, Pa)), Ra && process.on("beforeExit", () => {
|
|
4401
|
+
Ra();
|
|
4357
4402
|
});
|
|
4358
|
-
let
|
|
4403
|
+
let za = 0, K = new Ft({
|
|
4359
4404
|
store: B,
|
|
4360
4405
|
cache: br,
|
|
4361
4406
|
recordDelivery: (e) => {
|
|
@@ -4366,7 +4411,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4366
4411
|
rowCount: e.rowCount
|
|
4367
4412
|
}), Gn({
|
|
4368
4413
|
traceId: e.traceId,
|
|
4369
|
-
spanId: (
|
|
4414
|
+
spanId: (za++).toString(16).padStart(16, "0"),
|
|
4370
4415
|
parentSpanId: e.parentSpanId ?? null,
|
|
4371
4416
|
name: `${e.label}.${e.kind}`,
|
|
4372
4417
|
kind: "internal",
|
|
@@ -4380,10 +4425,10 @@ ${a.join("\n\n")}\n`);
|
|
|
4380
4425
|
status: "ok"
|
|
4381
4426
|
});
|
|
4382
4427
|
}
|
|
4383
|
-
}),
|
|
4428
|
+
}), Ha = () => {
|
|
4384
4429
|
let e = K.subscriptionSnapshot(), t = K.matcherStats(), n = e.map((e) => {
|
|
4385
4430
|
let t = [];
|
|
4386
|
-
for (let n of
|
|
4431
|
+
for (let n of fi(e.predicate)) n.conjunctive && t.push(n.column);
|
|
4387
4432
|
return {
|
|
4388
4433
|
fingerprint: e.fingerprint,
|
|
4389
4434
|
table: e.table,
|
|
@@ -4399,10 +4444,10 @@ ${a.join("\n\n")}\n`);
|
|
|
4399
4444
|
capturedAt: Date.now()
|
|
4400
4445
|
});
|
|
4401
4446
|
};
|
|
4402
|
-
K.onSubscriptionsChange(
|
|
4403
|
-
let
|
|
4447
|
+
K.onSubscriptionsChange(Ha), Ha();
|
|
4448
|
+
let Ua = $.child("store"), Qa = (F?.plugins ?? []).filter((e) => typeof e.onChangeEvent == "function"), eo = B.changeScope ?? "local";
|
|
4404
4449
|
B.onChange((e) => {
|
|
4405
|
-
if (
|
|
4450
|
+
if (Ua.debug(`${e.op} on ${e.table}`, {
|
|
4406
4451
|
op: e.op,
|
|
4407
4452
|
table: e.table
|
|
4408
4453
|
}), rr({
|
|
@@ -4417,10 +4462,10 @@ ${a.join("\n\n")}\n`);
|
|
|
4417
4462
|
new: e.new ?? null,
|
|
4418
4463
|
old: e.old ?? null,
|
|
4419
4464
|
...e.origin === void 0 ? {} : { origin: e.origin },
|
|
4420
|
-
changeScope:
|
|
4465
|
+
changeScope: eo
|
|
4421
4466
|
};
|
|
4422
4467
|
for (let n of Qa) {
|
|
4423
|
-
let r =
|
|
4468
|
+
let r = Ua.child(`plugin:${n.name}`);
|
|
4424
4469
|
N.runFork(n.onChangeEvent(t).pipe(N.catchAllCause((t) => N.sync(() => r.warn("onChangeEvent failed", {
|
|
4425
4470
|
table: e.table,
|
|
4426
4471
|
op: e.op
|
|
@@ -4428,59 +4473,59 @@ ${a.join("\n\n")}\n`);
|
|
|
4428
4473
|
}
|
|
4429
4474
|
}
|
|
4430
4475
|
});
|
|
4431
|
-
let
|
|
4476
|
+
let to = j.map((e) => Ar.make(e.definition.name, {
|
|
4432
4477
|
payload: e.definition.payloadSchema,
|
|
4433
|
-
success:
|
|
4478
|
+
success: gi,
|
|
4434
4479
|
error: e.definition.errorSchema
|
|
4435
|
-
})),
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
] : [],
|
|
4447
|
-
...w.map((e) =>
|
|
4448
|
-
...D.map((e) =>
|
|
4449
|
-
...A.map((e) =>
|
|
4450
|
-
...dt.map((e) =>
|
|
4451
|
-
...
|
|
4452
|
-
...
|
|
4453
|
-
],
|
|
4454
|
-
analyticsLayer:
|
|
4480
|
+
})), no = xt ? [
|
|
4481
|
+
Ai(Vi),
|
|
4482
|
+
Ai(Ui),
|
|
4483
|
+
Ai(Hi),
|
|
4484
|
+
Ai(Bi),
|
|
4485
|
+
Ai(Li),
|
|
4486
|
+
Ai(Ri),
|
|
4487
|
+
_i(Ii),
|
|
4488
|
+
_i(zi),
|
|
4489
|
+
_i(Wi),
|
|
4490
|
+
_i(Gi)
|
|
4491
|
+
] : [], ro = (F?.plugins ?? []).flatMap((e) => (e.errorSchemas ?? []).map((e) => e.schema)), io = ro.length > 0 ? ro : void 0, ao = [
|
|
4492
|
+
...w.map((e) => Ai(e.descriptor, io)),
|
|
4493
|
+
...D.map((e) => Oi(e.descriptor, io)),
|
|
4494
|
+
...A.map((e) => _i(e.descriptor, io)),
|
|
4495
|
+
...dt.map((e) => ji(e.descriptor, io)),
|
|
4496
|
+
...to,
|
|
4497
|
+
...no
|
|
4498
|
+
], oo = jr.make(...ao).middleware(pi).middleware(mi), q = F?.layers ?? [], so = (F?.plugins ?? []).map((e) => e.services).filter((e) => e !== void 0), co = P.succeed(Mt, sa.registry), lo = P.mergeAll(Za({
|
|
4499
|
+
analyticsLayer: Xr.layer,
|
|
4455
4500
|
cacheService: mr,
|
|
4456
|
-
kvService:
|
|
4501
|
+
kvService: kr,
|
|
4457
4502
|
pluginServices: so,
|
|
4458
|
-
userLayers:
|
|
4503
|
+
userLayers: q
|
|
4459
4504
|
}), co);
|
|
4460
|
-
(
|
|
4461
|
-
userLayers:
|
|
4505
|
+
(q.length > 0 || so.length > 0) && $.info("layers loaded", {
|
|
4506
|
+
userLayers: q.length,
|
|
4462
4507
|
pluginLayers: so.length
|
|
4463
4508
|
});
|
|
4464
4509
|
let uo = (e, t) => dr(e.pipe(N.provide(Nn(t)), N.provide(lo), N.provide(wt)));
|
|
4465
4510
|
if ((process.env.VOLTRO_INDEX_AUDIT ?? "on") !== "off") {
|
|
4466
|
-
let e =
|
|
4467
|
-
for (let n of e) $.warn("\n" +
|
|
4511
|
+
let e = ei(z), t = process.stdout.isTTY === !0 && (process.env.NO_COLOR ?? "") === "";
|
|
4512
|
+
for (let n of e) $.warn("\n" + ri(n, {
|
|
4468
4513
|
color: t,
|
|
4469
4514
|
indent: " "
|
|
4470
4515
|
}));
|
|
4471
4516
|
}
|
|
4472
|
-
let
|
|
4517
|
+
let J;
|
|
4473
4518
|
if (G.outgoing.length > 0) {
|
|
4474
|
-
let e =
|
|
4519
|
+
let e = qa({
|
|
4475
4520
|
store: B,
|
|
4476
4521
|
schemaRegistry: hi,
|
|
4477
4522
|
cache: Cr,
|
|
4478
|
-
kv:
|
|
4523
|
+
kv: Or
|
|
4479
4524
|
}), t = G.outgoing.map((e) => e.descriptor);
|
|
4480
|
-
|
|
4481
|
-
let r =
|
|
4525
|
+
J = ya(e, async (n) => {
|
|
4526
|
+
let r = xa.execute(n).pipe(N.provide(xa.toLayer(va(e, { events: t })).pipe(P.provideMerge(_a))));
|
|
4482
4527
|
N.runPromise(r).catch((e) => {
|
|
4483
|
-
|
|
4528
|
+
W.error("deliverWebhook workflow crashed", {
|
|
4484
4529
|
deliveryId: n.deliveryId,
|
|
4485
4530
|
targetId: n.targetId
|
|
4486
4531
|
}, e);
|
|
@@ -4489,32 +4534,32 @@ ${a.join("\n\n")}\n`);
|
|
|
4489
4534
|
}
|
|
4490
4535
|
let fo = (process.env.VOLTRO_TENANT_ISOLATION ?? F?.tenancy?.isolation) === "namespace";
|
|
4491
4536
|
fo && $.info("multi-tenancy: PHYSICAL namespace isolation ON — each request runs against its tenant's own namespace (schema/database/attached file). Requests without a resolvable tenant fail closed.");
|
|
4492
|
-
let po =
|
|
4537
|
+
let po = Ja({
|
|
4493
4538
|
store: B,
|
|
4494
4539
|
schemaRegistry: hi,
|
|
4495
4540
|
cache: Cr,
|
|
4496
|
-
kv:
|
|
4497
|
-
...
|
|
4498
|
-
...
|
|
4541
|
+
kv: Or,
|
|
4542
|
+
...J === void 0 ? {} : { webhooksService: J },
|
|
4543
|
+
...U === void 0 ? {} : { workflowsProxy: U },
|
|
4499
4544
|
eventTriggers: mt,
|
|
4500
4545
|
namespaceIsolationOn: fo,
|
|
4501
4546
|
onEventEmit: (e, t) => S.emit(e, t),
|
|
4502
|
-
...
|
|
4547
|
+
...Ji === void 0 ? {} : { outbox: { nudge: Ji.nudge } },
|
|
4503
4548
|
...$n.active ? { connections: { registry: $n.registry } } : {}
|
|
4504
4549
|
}), mo = async () => {
|
|
4505
4550
|
if (M.length === 0) return;
|
|
4506
4551
|
let e = process.env.HOSTNAME ?? `pid-${process.pid}`, t;
|
|
4507
|
-
|
|
4552
|
+
ha ? t = yr : ma === "cluster" ? ($.warn("scheduling.coordination=cluster needs store=postgres — falling back to single (dev/memory)"), t = yr) : ma === "advisoryLock" ? H === "memory" ? ($.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single (memory)"), t = yr) : t = bn(B, e, {
|
|
4508
4553
|
info: (e, t) => $.info(e, t ?? {}),
|
|
4509
4554
|
warn: (e, t) => $.warn(e, t ?? {})
|
|
4510
4555
|
}) : t = yr;
|
|
4511
|
-
let n =
|
|
4512
|
-
|
|
4556
|
+
let n = zc(F?.plugins ?? [], To);
|
|
4557
|
+
ca = await Sr(M, {
|
|
4513
4558
|
store: B,
|
|
4514
4559
|
coordinator: t,
|
|
4515
|
-
defaultTrigger:
|
|
4560
|
+
defaultTrigger: pa,
|
|
4516
4561
|
replicaId: e,
|
|
4517
|
-
armSelf: !
|
|
4562
|
+
armSelf: !ha,
|
|
4518
4563
|
dormancy: F?.dormancy ?? "always-on",
|
|
4519
4564
|
buildContext: ({ traceId: e, scheduleName: t, subject: n }) => po({
|
|
4520
4565
|
subject: n,
|
|
@@ -4533,12 +4578,12 @@ ${a.join("\n\n")}\n`);
|
|
|
4533
4578
|
...n === void 0 ? {} : { interceptFire: n }
|
|
4534
4579
|
}), $.info("scheduler ready", {
|
|
4535
4580
|
schedules: M.length,
|
|
4536
|
-
coordination:
|
|
4537
|
-
clusterCrons:
|
|
4581
|
+
coordination: ha ? "cluster" : t.kind,
|
|
4582
|
+
clusterCrons: ga.length
|
|
4538
4583
|
}), process.on("beforeExit", () => {
|
|
4539
|
-
|
|
4584
|
+
ca?.shutdown();
|
|
4540
4585
|
});
|
|
4541
|
-
},
|
|
4586
|
+
}, Y = {}, ho = /* @__PURE__ */ new Set(), go = (e, t) => {
|
|
4542
4587
|
fn(e, yt, t) && (ho.has(e.table) || (ho.add(e.table), $.warn("tenant-scoped read with an EMPTY tenant — every row is filtered out", {
|
|
4543
4588
|
table: e.table,
|
|
4544
4589
|
tenantId: "",
|
|
@@ -4551,10 +4596,10 @@ ${a.join("\n\n")}\n`);
|
|
|
4551
4596
|
cause: "the session resolved a user but no organization/tenant; the empty-string sentinel fails closed",
|
|
4552
4597
|
fix: "resolve the user to an active org during auth, or route org-less users to an onboarding flow"
|
|
4553
4598
|
}));
|
|
4554
|
-
}, yo = (e, t) => (vo(t.subject), go(e, t.subject.tenantId), Vt(Ht(e, yt, t.subject.tenantId), bt)), bo = /* @__PURE__ */ new Set(),
|
|
4599
|
+
}, yo = (e, t) => (vo(t.subject), go(e, t.subject.tenantId), Vt(Ht(e, yt, t.subject.tenantId), bt)), bo = /* @__PURE__ */ new Set(), xo = (e) => {
|
|
4555
4600
|
if (e.usingIndex !== void 0 || e.predicate === void 0) return;
|
|
4556
4601
|
let t = /* @__PURE__ */ new Set();
|
|
4557
|
-
for (let n of
|
|
4602
|
+
for (let n of fi(e.predicate)) n.conjunctive && t.add(n.column);
|
|
4558
4603
|
if (t.size === 0 || hi.anyFieldIndexed(e.table, t)) return;
|
|
4559
4604
|
let n = `${e.table}::${[...t].sort().join(",")}`;
|
|
4560
4605
|
bo.has(n) || (bo.add(n), $.warn("non-indexed predicate — slow at scale", {
|
|
@@ -4562,7 +4607,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4562
4607
|
fields: [...t],
|
|
4563
4608
|
hint: "declare `.index()` on a column, add `.index(name, [...fields])` to the table, or annotate the query with `.using('indexName')` if a covering index exists"
|
|
4564
4609
|
}));
|
|
4565
|
-
},
|
|
4610
|
+
}, So = (e) => {
|
|
4566
4611
|
if (e.usingIndex === void 0) return;
|
|
4567
4612
|
let t = hi.tables.get(e.table);
|
|
4568
4613
|
if (!t) return;
|
|
@@ -4571,7 +4616,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4571
4616
|
name: n.name,
|
|
4572
4617
|
fields: n.fields
|
|
4573
4618
|
};
|
|
4574
|
-
},
|
|
4619
|
+
}, Co = (e) => JSON.stringify(e, (e, t) => typeof t == "object" && t && !Array.isArray(t) ? Object.fromEntries(Object.entries(t).sort(([e], [t]) => e.localeCompare(t))) : t), wo = (e, t) => {
|
|
4575
4620
|
let n = e.cache;
|
|
4576
4621
|
if (n === void 0) return;
|
|
4577
4622
|
let r = h(n.ttl);
|
|
@@ -4579,54 +4624,54 @@ ${a.join("\n\n")}\n`);
|
|
|
4579
4624
|
ttlMs: r,
|
|
4580
4625
|
swrMs: n.swr === void 0 ? void 0 : h(n.swr) ?? void 0,
|
|
4581
4626
|
scope: n.scope,
|
|
4582
|
-
baseKey: `q:${e.name}:${
|
|
4627
|
+
baseKey: `q:${e.name}:${Co(t)}`
|
|
4583
4628
|
};
|
|
4584
|
-
},
|
|
4629
|
+
}, To = ne(), Eo = F?.plugins ?? [], Do = Si(Mc(Eo, "mutation", To)), Oo = Si(Mc(Eo, "action", To)), Mo = Si(Mc(Eo, "query", To)), No = Ln({
|
|
4585
4630
|
store: B,
|
|
4586
4631
|
buildContext: (e, t, n) => po(e, t, n),
|
|
4587
4632
|
runEffect: (e, t) => uo(e, t),
|
|
4588
|
-
...
|
|
4589
|
-
recordMetric: (e) =>
|
|
4590
|
-
undoCapture:
|
|
4633
|
+
...Do ? { interceptor: Do } : {},
|
|
4634
|
+
recordMetric: (e) => To.record(e),
|
|
4635
|
+
undoCapture: _c()
|
|
4591
4636
|
}), Po = yn({
|
|
4592
4637
|
buildContext: (e) => po(e),
|
|
4593
4638
|
runEffect: (e, t) => uo(e, t),
|
|
4594
|
-
...
|
|
4595
|
-
recordMetric: (e) =>
|
|
4639
|
+
...Oo ? { interceptor: Oo } : {},
|
|
4640
|
+
recordMetric: (e) => To.record(e)
|
|
4596
4641
|
}), Fo = {
|
|
4597
4642
|
buildContext: (e) => po(e),
|
|
4598
4643
|
finalize: (e, t) => {
|
|
4599
4644
|
let n = yo(e, t);
|
|
4600
|
-
return
|
|
4645
|
+
return xo(n), n;
|
|
4601
4646
|
},
|
|
4602
4647
|
provideEffect: (e, t) => e.pipe(N.provide(Nn(t)), N.provide(wt)),
|
|
4603
4648
|
...Mo ? { interceptor: Mo } : {}
|
|
4604
|
-
}, Io = Vn(Fo),
|
|
4649
|
+
}, Io = Vn(Fo), Lo = Rn({
|
|
4605
4650
|
...Fo,
|
|
4606
4651
|
queryRows: (e) => B.query(e)
|
|
4607
|
-
}),
|
|
4652
|
+
}), Ro = Un({
|
|
4608
4653
|
...Fo,
|
|
4609
4654
|
subscribeDescriptor: (e, t, n) => K.subscribe(e, t, n),
|
|
4610
4655
|
subscribeComputed: (e, t, n) => K.subscribeComputed(e, t, n)
|
|
4611
4656
|
});
|
|
4612
|
-
for (let e of w)
|
|
4657
|
+
for (let e of w) Y[e.descriptor.name] = (t) => Yt(Io(e, t), K, `subscription.${e.descriptor.name}`, So, wo(e.descriptor, t), Hn(e, t));
|
|
4613
4658
|
for (let e of D) {
|
|
4614
4659
|
let t = `mutation.${e.descriptor.name}`;
|
|
4615
|
-
|
|
4660
|
+
Y[e.descriptor.name] = (n) => qt(async (t, n) => No(e, t, n), n, t);
|
|
4616
4661
|
}
|
|
4617
4662
|
for (let e of A) {
|
|
4618
4663
|
let t = `action.${e.descriptor.name}`;
|
|
4619
|
-
|
|
4664
|
+
Y[e.descriptor.name] = (n) => qt(async (t, n) => Po(e, t, n), n, t);
|
|
4620
4665
|
}
|
|
4621
4666
|
for (let e of dt) {
|
|
4622
4667
|
let t = `stream.${e.descriptor.name}`;
|
|
4623
|
-
|
|
4668
|
+
Y[e.descriptor.name] = (n) => Jt((t) => {
|
|
4624
4669
|
let r = po(t), i = e.executor(n, r);
|
|
4625
4670
|
return N.isEffect(i) ? i.pipe(N.provide(Nn(r.store)), N.provide(lo), N.provide(wt)) : typeof i == "object" && i && typeof i.then == "function" ? N.promise(() => i) : i;
|
|
4626
4671
|
}, t);
|
|
4627
4672
|
}
|
|
4628
|
-
xt && (
|
|
4629
|
-
descriptor:
|
|
4673
|
+
xt && (Y[Vi.name] = (e) => Yt(Io({
|
|
4674
|
+
descriptor: Vi,
|
|
4630
4675
|
executor: (e) => {
|
|
4631
4676
|
let t = e.id;
|
|
4632
4677
|
return {
|
|
@@ -4635,30 +4680,30 @@ ${a.join("\n\n")}\n`);
|
|
|
4635
4680
|
column: "startedAt",
|
|
4636
4681
|
direction: "desc"
|
|
4637
4682
|
}],
|
|
4638
|
-
predicate:
|
|
4683
|
+
predicate: oi(V("id", t), V("executionId", t)),
|
|
4639
4684
|
take: 1,
|
|
4640
4685
|
skip: void 0,
|
|
4641
4686
|
projection: void 0
|
|
4642
4687
|
};
|
|
4643
4688
|
}
|
|
4644
|
-
}, e), K, `subscription.${
|
|
4645
|
-
descriptor:
|
|
4689
|
+
}, e), K, `subscription.${Vi.name}`), Y[Ui.name] = (e) => Yt(Io({
|
|
4690
|
+
descriptor: Ui,
|
|
4646
4691
|
executor: (e) => {
|
|
4647
|
-
let t = e, n = [...t.tag === void 0 ? [] : [
|
|
4692
|
+
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;
|
|
4648
4693
|
return {
|
|
4649
4694
|
table: "_voltro_workflow_runs",
|
|
4650
4695
|
order: [{
|
|
4651
4696
|
column: "startedAt",
|
|
4652
4697
|
direction: "desc"
|
|
4653
4698
|
}],
|
|
4654
|
-
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] :
|
|
4699
|
+
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : $r(...n),
|
|
4655
4700
|
take: r,
|
|
4656
4701
|
skip: void 0,
|
|
4657
4702
|
projection: void 0
|
|
4658
4703
|
};
|
|
4659
4704
|
}
|
|
4660
|
-
}, e), K, `subscription.${
|
|
4661
|
-
descriptor:
|
|
4705
|
+
}, e), K, `subscription.${Ui.name}`), Y[Hi.name] = (e) => Yt(Io({
|
|
4706
|
+
descriptor: Hi,
|
|
4662
4707
|
executor: (e) => {
|
|
4663
4708
|
let t = e.runId;
|
|
4664
4709
|
return {
|
|
@@ -4667,14 +4712,14 @@ ${a.join("\n\n")}\n`);
|
|
|
4667
4712
|
column: "startedAt",
|
|
4668
4713
|
direction: "asc"
|
|
4669
4714
|
}],
|
|
4670
|
-
predicate:
|
|
4715
|
+
predicate: V("runId", t),
|
|
4671
4716
|
take: 1e3,
|
|
4672
4717
|
skip: void 0,
|
|
4673
4718
|
projection: void 0
|
|
4674
4719
|
};
|
|
4675
4720
|
}
|
|
4676
|
-
}, e), K, `subscription.${
|
|
4677
|
-
descriptor:
|
|
4721
|
+
}, e), K, `subscription.${Hi.name}`), Y[Bi.name] = (e) => Yt(Io({
|
|
4722
|
+
descriptor: Bi,
|
|
4678
4723
|
executor: (e) => {
|
|
4679
4724
|
let t = e.runId;
|
|
4680
4725
|
return {
|
|
@@ -4683,14 +4728,14 @@ ${a.join("\n\n")}\n`);
|
|
|
4683
4728
|
column: "occurredAt",
|
|
4684
4729
|
direction: "asc"
|
|
4685
4730
|
}],
|
|
4686
|
-
predicate:
|
|
4731
|
+
predicate: V("runId", t),
|
|
4687
4732
|
take: 1e3,
|
|
4688
4733
|
skip: void 0,
|
|
4689
4734
|
projection: void 0
|
|
4690
4735
|
};
|
|
4691
4736
|
}
|
|
4692
|
-
}, e), K, `subscription.${
|
|
4693
|
-
descriptor:
|
|
4737
|
+
}, e), K, `subscription.${Bi.name}`), Y[Li.name] = (e) => Yt(Io({
|
|
4738
|
+
descriptor: Li,
|
|
4694
4739
|
executor: (e) => {
|
|
4695
4740
|
let t = e;
|
|
4696
4741
|
return {
|
|
@@ -4699,14 +4744,14 @@ ${a.join("\n\n")}\n`);
|
|
|
4699
4744
|
column: "occurredAt",
|
|
4700
4745
|
direction: "desc"
|
|
4701
4746
|
}],
|
|
4702
|
-
predicate: t.name === void 0 ? void 0 :
|
|
4747
|
+
predicate: t.name === void 0 ? void 0 : V("name", t.name),
|
|
4703
4748
|
take: Math.max(1, Math.min(500, t.limit ?? 100)),
|
|
4704
4749
|
skip: void 0,
|
|
4705
4750
|
projection: void 0
|
|
4706
4751
|
};
|
|
4707
4752
|
}
|
|
4708
|
-
}, e), K, `subscription.${
|
|
4709
|
-
descriptor:
|
|
4753
|
+
}, e), K, `subscription.${Li.name}`), Y[Ri.name] = (e) => Yt(Io({
|
|
4754
|
+
descriptor: Ri,
|
|
4710
4755
|
executor: (e) => {
|
|
4711
4756
|
let t = e.eventId;
|
|
4712
4757
|
return {
|
|
@@ -4715,37 +4760,37 @@ ${a.join("\n\n")}\n`);
|
|
|
4715
4760
|
column: "createdAt",
|
|
4716
4761
|
direction: "asc"
|
|
4717
4762
|
}],
|
|
4718
|
-
predicate:
|
|
4763
|
+
predicate: V("eventId", t),
|
|
4719
4764
|
take: 500,
|
|
4720
4765
|
skip: void 0,
|
|
4721
4766
|
projection: void 0
|
|
4722
4767
|
};
|
|
4723
4768
|
}
|
|
4724
|
-
}, e), K, `subscription.${
|
|
4769
|
+
}, e), K, `subscription.${Ri.name}`), Y[Ii.name] = (e) => qt(async (e, t) => {
|
|
4725
4770
|
let n = e;
|
|
4726
|
-
return await
|
|
4727
|
-
}, e, `action.${
|
|
4771
|
+
return await Ya(B, t.subject, { executionId: n.executionId }), await U.cancel(n.workflowName, n.executionId), await Go(n.workflowName, n.executionId, "workflow.cancel"), { ok: !0 };
|
|
4772
|
+
}, e, `action.${Ii.name}`), Y[zi.name] = (e) => qt(async (e, t) => {
|
|
4728
4773
|
let n = e;
|
|
4729
|
-
return await
|
|
4730
|
-
}, e, `action.${
|
|
4774
|
+
return await Ya(B, t.subject, { executionId: n.executionId }), await U.resume(n.workflowName, n.executionId), { ok: !0 };
|
|
4775
|
+
}, e, `action.${zi.name}`), Y[Wi.name] = (e) => qt(async (e, t) => {
|
|
4731
4776
|
let n = e;
|
|
4732
|
-
return await
|
|
4733
|
-
}, e, `action.${
|
|
4777
|
+
return await Ya(B, t.subject, { id: n.id }), U.signal({ id: n.id }, n.signalName, n.payload);
|
|
4778
|
+
}, e, `action.${Wi.name}`), Y[Gi.name] = (e) => qt(async (e, t) => {
|
|
4734
4779
|
let n = e;
|
|
4735
|
-
return await
|
|
4736
|
-
}, e, `action.${
|
|
4737
|
-
for (let e of j)
|
|
4780
|
+
return await Ya(B, t.subject, { id: n.id }), U.update({ id: n.id }, n.updateName, n.payload, n.timeoutMs === void 0 ? void 0 : { timeoutMs: n.timeoutMs });
|
|
4781
|
+
}, e, `action.${Gi.name}`));
|
|
4782
|
+
for (let e of j) Y[e.definition.name] = (t) => qt(async (t, n) => {
|
|
4738
4783
|
let r = n;
|
|
4739
|
-
return Yn(
|
|
4784
|
+
return Yn(U, {
|
|
4740
4785
|
subject: r.subject,
|
|
4741
4786
|
traceId: r.traceId,
|
|
4742
4787
|
source: "workflow-rpc"
|
|
4743
4788
|
}).start(e.definition.name, t);
|
|
4744
4789
|
}, t, `workflow.${e.definition.name}`);
|
|
4745
|
-
let
|
|
4790
|
+
let zo = (e, t) => po({
|
|
4746
4791
|
subject: e.subject,
|
|
4747
4792
|
traceId: e.traceId
|
|
4748
|
-
}, B, void 0, `workflow:${t.workflowName}`, { parentExecutionId: t.executionId }),
|
|
4793
|
+
}, B, void 0, `workflow:${t.workflowName}`, { parentExecutionId: t.executionId }), Bo = Vc(F?.plugins ?? [], To), Vo = Hr, Ho = (e, t) => S.emit(e, t), Uo = F?.dormancy === "sleep" ? {
|
|
4749
4794
|
register: (e, t, n) => sr(B, {
|
|
4750
4795
|
tenantId: n ?? Pt,
|
|
4751
4796
|
kind: "workflow",
|
|
@@ -4757,23 +4802,23 @@ ${a.join("\n\n")}\n`);
|
|
|
4757
4802
|
kind: "workflow",
|
|
4758
4803
|
refId: e
|
|
4759
4804
|
}).then(() => {})
|
|
4760
|
-
} : void 0,
|
|
4805
|
+
} : void 0, Wo = zr({
|
|
4761
4806
|
store: B,
|
|
4762
|
-
emit:
|
|
4807
|
+
emit: Ho,
|
|
4763
4808
|
log: $,
|
|
4764
|
-
...
|
|
4765
|
-
}),
|
|
4766
|
-
await
|
|
4809
|
+
...Uo === void 0 ? {} : { wakeups: Uo }
|
|
4810
|
+
}), X = async (e, t) => {
|
|
4811
|
+
await Fr({
|
|
4767
4812
|
store: B,
|
|
4768
4813
|
parentExecutionId: e,
|
|
4769
4814
|
parentStatus: t,
|
|
4770
|
-
recorder:
|
|
4771
|
-
emit:
|
|
4815
|
+
recorder: Wo,
|
|
4816
|
+
emit: Ho,
|
|
4772
4817
|
log: $,
|
|
4773
4818
|
interruptChild: async (t, n, r) => {
|
|
4774
4819
|
let i = j.find((e) => e.definition.name === t);
|
|
4775
4820
|
if (!i) throw Error(`Unknown child workflow: ${t}`);
|
|
4776
|
-
await
|
|
4821
|
+
await Yo.runPromise(i.definition.interrupt(n)), $.info("workflow.parentClose.childInterrupted", {
|
|
4777
4822
|
parentExecutionId: e,
|
|
4778
4823
|
childWorkflowName: t,
|
|
4779
4824
|
childExecutionId: n,
|
|
@@ -4781,11 +4826,11 @@ ${a.join("\n\n")}\n`);
|
|
|
4781
4826
|
});
|
|
4782
4827
|
}
|
|
4783
4828
|
});
|
|
4784
|
-
},
|
|
4829
|
+
}, Go = async (e, t, n) => {
|
|
4785
4830
|
let r = (await B.query({
|
|
4786
4831
|
table: "_voltro_workflow_runs",
|
|
4787
4832
|
order: [],
|
|
4788
|
-
predicate:
|
|
4833
|
+
predicate: V("executionId", t),
|
|
4789
4834
|
projection: void 0,
|
|
4790
4835
|
skip: void 0,
|
|
4791
4836
|
take: 1
|
|
@@ -4798,10 +4843,10 @@ ${a.join("\n\n")}\n`);
|
|
|
4798
4843
|
});
|
|
4799
4844
|
i && S.emit("workflowRuns", {
|
|
4800
4845
|
op: "update",
|
|
4801
|
-
row:
|
|
4846
|
+
row: Vo(i)
|
|
4802
4847
|
});
|
|
4803
4848
|
let a = r.subject?.tenantId ?? void 0;
|
|
4804
|
-
i && await
|
|
4849
|
+
i && await Wo.recordEvent({
|
|
4805
4850
|
runId: r.id,
|
|
4806
4851
|
eventType: "run-cancelled",
|
|
4807
4852
|
payload: {
|
|
@@ -4810,10 +4855,10 @@ ${a.join("\n\n")}\n`);
|
|
|
4810
4855
|
executionId: t,
|
|
4811
4856
|
...a == null ? {} : { tenantId: a }
|
|
4812
4857
|
}
|
|
4813
|
-
}), i && await
|
|
4814
|
-
},
|
|
4815
|
-
let i =
|
|
4816
|
-
return
|
|
4858
|
+
}), i && await X(t, "cancelled");
|
|
4859
|
+
}, Ko = (e, t, n, r) => {
|
|
4860
|
+
let i = Lr(t);
|
|
4861
|
+
return Ur({
|
|
4817
4862
|
name: e,
|
|
4818
4863
|
store: B,
|
|
4819
4864
|
subject: r.subject,
|
|
@@ -4824,68 +4869,68 @@ ${a.join("\n\n")}\n`);
|
|
|
4824
4869
|
workflowPatches: i.patches,
|
|
4825
4870
|
parentExecutionId: r?.parentExecutionId ?? null,
|
|
4826
4871
|
parentClosePolicy: r?.parentClosePolicy ?? null,
|
|
4827
|
-
onParentClose: ({ executionId: e, status: t }) =>
|
|
4828
|
-
recorder:
|
|
4829
|
-
pluginWorkflowStepLayer:
|
|
4830
|
-
emit:
|
|
4872
|
+
onParentClose: ({ executionId: e, status: t }) => X(e, t),
|
|
4873
|
+
recorder: Wo,
|
|
4874
|
+
pluginWorkflowStepLayer: Bo,
|
|
4875
|
+
emit: Ho,
|
|
4831
4876
|
log: $
|
|
4832
4877
|
}, n);
|
|
4833
|
-
},
|
|
4834
|
-
buildContext:
|
|
4835
|
-
resolveStartContext:
|
|
4836
|
-
}, (e, t, n) =>
|
|
4878
|
+
}, qo = [...Xn(j, {
|
|
4879
|
+
buildContext: zo,
|
|
4880
|
+
resolveStartContext: ka
|
|
4881
|
+
}, (e, t, n) => Ko(e.definition.name, e.definition, t, n)), ...ft], Jo = qo.length > 0 ? P.mergeAll(...qo) : P.empty, Yo = _t.make(Jo.pipe(P.provideMerge(_a), P.provideMerge(lo), P.provideMerge(wt)));
|
|
4837
4882
|
process.on("beforeExit", () => {
|
|
4838
|
-
|
|
4839
|
-
}),
|
|
4883
|
+
Yo.dispose();
|
|
4884
|
+
}), Sa = j.length > 0 ? Jn({
|
|
4840
4885
|
workflows: j,
|
|
4841
|
-
runEffect: (e) =>
|
|
4842
|
-
rememberStartContext:
|
|
4886
|
+
runEffect: (e) => Yo.runPromise(e),
|
|
4887
|
+
rememberStartContext: Da,
|
|
4843
4888
|
signal: async (e, t, n) => {
|
|
4844
|
-
let r = await
|
|
4889
|
+
let r = await Br({
|
|
4845
4890
|
store: B,
|
|
4846
|
-
recorder:
|
|
4891
|
+
recorder: Wo,
|
|
4847
4892
|
target: e,
|
|
4848
4893
|
signalName: t,
|
|
4849
4894
|
payload: n
|
|
4850
4895
|
});
|
|
4851
|
-
return await
|
|
4896
|
+
return await Yo.runPromise(Ir({
|
|
4852
4897
|
store: B,
|
|
4853
4898
|
target: e,
|
|
4854
4899
|
signalName: t,
|
|
4855
4900
|
payload: n
|
|
4856
4901
|
})).catch(() => {}), r;
|
|
4857
4902
|
},
|
|
4858
|
-
update: (e, t, n, r) =>
|
|
4903
|
+
update: (e, t, n, r) => Vr({
|
|
4859
4904
|
store: B,
|
|
4860
|
-
recorder:
|
|
4905
|
+
recorder: Wo,
|
|
4861
4906
|
target: e,
|
|
4862
4907
|
updateName: t,
|
|
4863
4908
|
payload: n,
|
|
4864
4909
|
...r === void 0 ? {} : { options: r }
|
|
4865
4910
|
}),
|
|
4866
|
-
listRuns: (e) =>
|
|
4867
|
-
retry: (e, t) =>
|
|
4911
|
+
listRuns: (e) => Gc(B, e),
|
|
4912
|
+
retry: (e, t) => Kc({
|
|
4868
4913
|
store: B,
|
|
4869
4914
|
workflows: j,
|
|
4870
|
-
runPromise: (e) =>
|
|
4915
|
+
runPromise: (e) => Yo.runPromise(e)
|
|
4871
4916
|
}, e, t)
|
|
4872
4917
|
}) : void 0;
|
|
4873
|
-
let
|
|
4874
|
-
if (
|
|
4918
|
+
let es = P.mergeAll(oo.toLayer(Y), At, kl), ts = $a(Y, w.map((e) => e.descriptor.name), xt), ns = P.mergeAll(oo.toLayer(ts), At, kl), Z = H, rs = (Z === "postgres" || Z === "mysql" || Z === "mariadb" || Z === "mssql") && (process.env.CDC ?? "1") !== "0";
|
|
4919
|
+
if (Z === "postgres" && me()) {
|
|
4875
4920
|
let e = be({
|
|
4876
4921
|
store: B,
|
|
4877
4922
|
log: $
|
|
4878
4923
|
});
|
|
4879
4924
|
zn = e.persistTraceSpan, process.on("beforeExit", e.stop);
|
|
4880
4925
|
}
|
|
4881
|
-
let
|
|
4926
|
+
let is = Ka({
|
|
4882
4927
|
store: B,
|
|
4883
|
-
dialect:
|
|
4928
|
+
dialect: Z
|
|
4884
4929
|
});
|
|
4885
4930
|
process.on("beforeExit", () => {
|
|
4886
|
-
|
|
4931
|
+
is.stop();
|
|
4887
4932
|
});
|
|
4888
|
-
let
|
|
4933
|
+
let as = [
|
|
4889
4934
|
...w.map((e) => st(e.descriptor, "query", k(m, e.file))),
|
|
4890
4935
|
...D.map((e) => st(e.descriptor, "mutation", k(m, e.file))),
|
|
4891
4936
|
...A.map((e) => st(e.descriptor, "action", k(m, e.file))),
|
|
@@ -4895,11 +4940,11 @@ ${a.join("\n\n")}\n`);
|
|
|
4895
4940
|
output: e.descriptor.element,
|
|
4896
4941
|
error: e.descriptor.error
|
|
4897
4942
|
}, "stream", k(m, e.file)))
|
|
4898
|
-
],
|
|
4943
|
+
], os = j.map((e) => ({
|
|
4899
4944
|
tag: e.definition.name,
|
|
4900
4945
|
file: k(m, e.file)
|
|
4901
4946
|
}));
|
|
4902
|
-
R.writeFile(O(m, "app.manifest.generated.json"), `${JSON.stringify(tt(
|
|
4947
|
+
R.writeFile(O(m, "app.manifest.generated.json"), `${JSON.stringify(tt(as, os, [], F?.plugins ?? []), null, 2)}\n`, "utf8").catch(() => {}), (async () => {
|
|
4903
4948
|
let e = O(m, ".gitignore"), t = "";
|
|
4904
4949
|
try {
|
|
4905
4950
|
t = await R.readFile(e, "utf8");
|
|
@@ -4907,19 +4952,19 @@ ${a.join("\n\n")}\n`);
|
|
|
4907
4952
|
let n = t.split("\n").filter((e) => e.trim() !== "");
|
|
4908
4953
|
n.includes("app.manifest.generated.json") || (n.push("app.manifest.generated.json"), await R.writeFile(e, `${n.join("\n")}\n`, "utf8"));
|
|
4909
4954
|
})().catch(() => {}), rn();
|
|
4910
|
-
let
|
|
4955
|
+
let ss = O(m, "app.graph.observed.generated.json");
|
|
4911
4956
|
R.rm(O(m, "app.graph.observed.json"), { force: !0 }).catch(() => {});
|
|
4912
|
-
let
|
|
4913
|
-
|
|
4914
|
-
let
|
|
4957
|
+
let ls = La(m);
|
|
4958
|
+
ls.warning === void 0 ? ls.adopted.length > 0 && $.debug("handed generated output to the workspace owner", { paths: ls.adopted.join(", ") }) : $.warn(ls.warning);
|
|
4959
|
+
let us = async () => {
|
|
4915
4960
|
try {
|
|
4916
|
-
await R.writeFile(
|
|
4961
|
+
await R.writeFile(ss, `${JSON.stringify(er(), null, 2)}\n`, "utf8");
|
|
4917
4962
|
} catch {}
|
|
4918
4963
|
};
|
|
4919
4964
|
setInterval(() => {
|
|
4920
|
-
|
|
4965
|
+
us();
|
|
4921
4966
|
}, 1e4).unref(), process.once("exit", () => {
|
|
4922
|
-
|
|
4967
|
+
us();
|
|
4923
4968
|
}), (async () => {
|
|
4924
4969
|
let e = O(m, ".gitignore"), t = "";
|
|
4925
4970
|
try {
|
|
@@ -4928,8 +4973,8 @@ ${a.join("\n\n")}\n`);
|
|
|
4928
4973
|
let n = t.split("\n").filter((e) => e.trim() !== "");
|
|
4929
4974
|
n.includes("app.graph.observed.generated.json") || (n.push("app.graph.observed.generated.json"), await R.writeFile(e, `${n.join("\n")}\n`, "utf8"));
|
|
4930
4975
|
})().catch(() => {});
|
|
4931
|
-
let
|
|
4932
|
-
for (let e of D)
|
|
4976
|
+
let ds = /* @__PURE__ */ new Map();
|
|
4977
|
+
for (let e of D) ds.set(e.descriptor.name, async (t, n) => {
|
|
4933
4978
|
let r = {
|
|
4934
4979
|
subject: await kt({
|
|
4935
4980
|
headers: n,
|
|
@@ -4943,7 +4988,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4943
4988
|
result: await No(e, t, r)
|
|
4944
4989
|
};
|
|
4945
4990
|
} catch (t) {
|
|
4946
|
-
let n =
|
|
4991
|
+
let n = Ml(t);
|
|
4947
4992
|
return $.warn(`inspect invoke failed: ${e.descriptor.name}`, {
|
|
4948
4993
|
tag: e.descriptor.name,
|
|
4949
4994
|
error: n
|
|
@@ -4953,7 +4998,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4953
4998
|
};
|
|
4954
4999
|
}
|
|
4955
5000
|
});
|
|
4956
|
-
for (let e of A)
|
|
5001
|
+
for (let e of A) ds.set(e.descriptor.name, async (t, n) => {
|
|
4957
5002
|
let r = {
|
|
4958
5003
|
subject: await kt({
|
|
4959
5004
|
headers: n,
|
|
@@ -4967,7 +5012,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4967
5012
|
result: await Po(e, t, r)
|
|
4968
5013
|
};
|
|
4969
5014
|
} catch (t) {
|
|
4970
|
-
let n =
|
|
5015
|
+
let n = Ml(t);
|
|
4971
5016
|
return $.warn(`inspect invoke failed: ${e.descriptor.name}`, {
|
|
4972
5017
|
tag: e.descriptor.name,
|
|
4973
5018
|
error: n
|
|
@@ -4977,8 +5022,8 @@ ${a.join("\n\n")}\n`);
|
|
|
4977
5022
|
};
|
|
4978
5023
|
}
|
|
4979
5024
|
});
|
|
4980
|
-
let
|
|
4981
|
-
dialect:
|
|
5025
|
+
let ms = () => ({
|
|
5026
|
+
dialect: H,
|
|
4982
5027
|
replication: ut.replicationSnapshot() ?? {
|
|
4983
5028
|
replicaCount: 0,
|
|
4984
5029
|
rywPolicy: "off",
|
|
@@ -5009,7 +5054,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5009
5054
|
...e.lastRunRowsTouched === void 0 ? {} : { lastRunRowsTouched: e.lastRunRowsTouched },
|
|
5010
5055
|
...e.lastError ? { lastError: e.lastError } : {}
|
|
5011
5056
|
}))
|
|
5012
|
-
}),
|
|
5057
|
+
}), _s = async () => {
|
|
5013
5058
|
let e = {
|
|
5014
5059
|
drift: {
|
|
5015
5060
|
isDrifted: !1,
|
|
@@ -5020,9 +5065,9 @@ ${a.join("\n\n")}\n`);
|
|
|
5020
5065
|
history: [],
|
|
5021
5066
|
softDropSnapshots: []
|
|
5022
5067
|
};
|
|
5023
|
-
if (!
|
|
5068
|
+
if (!li) return e;
|
|
5024
5069
|
let t = N.gen(function* () {
|
|
5025
|
-
let e = yield*
|
|
5070
|
+
let e = yield* Mr.SqlClient, t = yield* e`
|
|
5026
5071
|
SELECT ${e("id")}, ${e("fingerprint")},
|
|
5027
5072
|
${e("appliedAt")}::text AS ${e("appliedAt")},
|
|
5028
5073
|
${e("appliedBy")}, ${e("environment")}, ${e("source")},
|
|
@@ -5031,17 +5076,17 @@ ${a.join("\n\n")}\n`);
|
|
|
5031
5076
|
FROM ${e("_voltro_migration_plans")}
|
|
5032
5077
|
ORDER BY ${e("appliedAt")} DESC
|
|
5033
5078
|
LIMIT 20
|
|
5034
|
-
`.pipe(N.orElseSucceed(() => [])), n = yield*
|
|
5079
|
+
`.pipe(N.orElseSucceed(() => [])), n = yield* ta(e), r = ea({ tables: n.tables.filter((e) => !e.name.startsWith("_voltro_")) }), i = t[0], a = {
|
|
5035
5080
|
isDrifted: i ? i.fingerprint !== r : !1,
|
|
5036
5081
|
liveFingerprint: r,
|
|
5037
5082
|
liveSnapshot: n
|
|
5038
5083
|
};
|
|
5039
5084
|
i && (a.lastAppliedFingerprint = i.fingerprint, a.lastAppliedAt = i.appliedAt, a.lastAppliedId = i.id);
|
|
5040
|
-
let o = z, s =
|
|
5085
|
+
let o = z, s = ra({
|
|
5041
5086
|
declared: o,
|
|
5042
5087
|
live: n
|
|
5043
5088
|
});
|
|
5044
|
-
return
|
|
5089
|
+
return ea(Qi(o)), {
|
|
5045
5090
|
drift: a,
|
|
5046
5091
|
pending: {
|
|
5047
5092
|
operations: s.operations.map((e) => {
|
|
@@ -5080,7 +5125,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5080
5125
|
};
|
|
5081
5126
|
});
|
|
5082
5127
|
try {
|
|
5083
|
-
return await N.runPromise(t.pipe(N.provide(
|
|
5128
|
+
return await N.runPromise(t.pipe(N.provide(li)));
|
|
5084
5129
|
} catch (t) {
|
|
5085
5130
|
return $.warn("inspect.migrations: snapshot build failed", { err: String(t) }), e;
|
|
5086
5131
|
}
|
|
@@ -5088,15 +5133,15 @@ ${a.join("\n\n")}\n`);
|
|
|
5088
5133
|
kind: "api",
|
|
5089
5134
|
meta: {
|
|
5090
5135
|
name: F?.name ?? E(m),
|
|
5091
|
-
voltroVersion:
|
|
5136
|
+
voltroVersion: Sl,
|
|
5092
5137
|
port: b,
|
|
5093
5138
|
mode: "dev",
|
|
5094
|
-
store:
|
|
5095
|
-
cdc:
|
|
5139
|
+
store: Z,
|
|
5140
|
+
cdc: rs ? "on" : "off"
|
|
5096
5141
|
},
|
|
5097
|
-
rpc:
|
|
5098
|
-
workflows:
|
|
5099
|
-
metrics: (e) =>
|
|
5142
|
+
rpc: as,
|
|
5143
|
+
workflows: os,
|
|
5144
|
+
metrics: (e) => To.snapshot(e),
|
|
5100
5145
|
dataCache: () => {
|
|
5101
5146
|
let e = Tr(), t = (process.env.CACHE_REDIS_DRIVER ?? "resp") === "http" ? "http" : "resp", n = wr === "redis" ? (process.env.CACHE_REDIS_URL ?? process.env.REDIS_URL ?? "").includes("upstash") ? "upstash" : "redis" : "memory";
|
|
5102
5147
|
return {
|
|
@@ -5108,13 +5153,13 @@ ${a.join("\n\n")}\n`);
|
|
|
5108
5153
|
hitRate: e.hitRate
|
|
5109
5154
|
};
|
|
5110
5155
|
},
|
|
5111
|
-
invokers:
|
|
5156
|
+
invokers: ds,
|
|
5112
5157
|
plugins: () => ({
|
|
5113
5158
|
plugins: It.snapshot(),
|
|
5114
5159
|
capturedAt: Date.now()
|
|
5115
5160
|
}),
|
|
5116
5161
|
env: () => f(F?.name ?? E(m), {
|
|
5117
|
-
contract:
|
|
5162
|
+
contract: Ki(F?.env) ? F.env : void 0,
|
|
5118
5163
|
plugins: F?.plugins ?? []
|
|
5119
5164
|
}),
|
|
5120
5165
|
subscriptions: () => {
|
|
@@ -5122,7 +5167,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5122
5167
|
return {
|
|
5123
5168
|
subscriptions: e.map((e) => {
|
|
5124
5169
|
let t = [];
|
|
5125
|
-
for (let n of
|
|
5170
|
+
for (let n of fi(e.predicate)) n.conjunctive && t.push(n.column);
|
|
5126
5171
|
return {
|
|
5127
5172
|
fingerprint: e.fingerprint,
|
|
5128
5173
|
table: e.table,
|
|
@@ -5136,10 +5181,10 @@ ${a.join("\n\n")}\n`);
|
|
|
5136
5181
|
capturedAt: Date.now()
|
|
5137
5182
|
};
|
|
5138
5183
|
},
|
|
5139
|
-
database:
|
|
5140
|
-
migrations: async () =>
|
|
5184
|
+
database: ms,
|
|
5185
|
+
migrations: async () => _s(),
|
|
5141
5186
|
inspectTables: () => ({ tables: z.map((e) => {
|
|
5142
|
-
let t =
|
|
5187
|
+
let t = Hl(e), n = Ul(t);
|
|
5143
5188
|
return {
|
|
5144
5189
|
name: e.tableName,
|
|
5145
5190
|
isFrameworkTable: e.tableName.startsWith("_voltro_"),
|
|
@@ -5152,11 +5197,11 @@ ${a.join("\n\n")}\n`);
|
|
|
5152
5197
|
inspectRows: async (e) => {
|
|
5153
5198
|
let t = Math.max(0, e.offset ?? 0), n = Math.max(1, Math.min(500, e.limit ?? 50)), r = z.find((t) => t.tableName === e.table);
|
|
5154
5199
|
if (!r) throw Error(`unknown table: ${e.table}`);
|
|
5155
|
-
let i =
|
|
5200
|
+
let i = Hl(r), a = dl({
|
|
5156
5201
|
filter: e.filter,
|
|
5157
5202
|
quickSearch: e.quickSearch,
|
|
5158
5203
|
columns: i
|
|
5159
|
-
}), o =
|
|
5204
|
+
}), o = fl(e.sort, i), s = await B.query({
|
|
5160
5205
|
table: e.table,
|
|
5161
5206
|
order: o,
|
|
5162
5207
|
skip: t,
|
|
@@ -5172,7 +5217,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5172
5217
|
skip: void 0,
|
|
5173
5218
|
take: void 0
|
|
5174
5219
|
})).length, u = "exact"), {
|
|
5175
|
-
rows: s.map(
|
|
5220
|
+
rows: s.map(Vl),
|
|
5176
5221
|
total: l,
|
|
5177
5222
|
countMode: u,
|
|
5178
5223
|
offset: t,
|
|
@@ -5186,7 +5231,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5186
5231
|
return $.info("inspect.data.insert", {
|
|
5187
5232
|
table: e.table,
|
|
5188
5233
|
id: t?.id ?? null
|
|
5189
|
-
}), { row:
|
|
5234
|
+
}), { row: Vl(t) };
|
|
5190
5235
|
},
|
|
5191
5236
|
inspectUpdateRow: async (e) => {
|
|
5192
5237
|
if (e.table.startsWith("_voltro_")) throw Error(`inspect data viewer cannot write to framework-internal table: ${e.table}`);
|
|
@@ -5196,7 +5241,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5196
5241
|
table: e.table,
|
|
5197
5242
|
id: e.id,
|
|
5198
5243
|
patch: Object.keys(e.patch)
|
|
5199
|
-
}), { row: t ?
|
|
5244
|
+
}), { row: t ? Vl(t) : null };
|
|
5200
5245
|
},
|
|
5201
5246
|
inspectDeleteRow: async (e) => {
|
|
5202
5247
|
if (e.table.startsWith("_voltro_")) throw Error(`inspect data viewer cannot delete from framework-internal table: ${e.table}`);
|
|
@@ -5209,7 +5254,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5209
5254
|
}), { deleted: t };
|
|
5210
5255
|
},
|
|
5211
5256
|
inspectImport: async (e) => {
|
|
5212
|
-
let t = await N.runPromise(
|
|
5257
|
+
let t = await N.runPromise(Oa({
|
|
5213
5258
|
store: B,
|
|
5214
5259
|
bundleDir: e.bundleDir,
|
|
5215
5260
|
...e.mode ? { mode: e.mode } : {},
|
|
@@ -5228,14 +5273,14 @@ ${a.join("\n\n")}\n`);
|
|
|
5228
5273
|
},
|
|
5229
5274
|
...xt ? {
|
|
5230
5275
|
inspectStartWorkflow: async (e) => {
|
|
5231
|
-
if (
|
|
5232
|
-
return Yn(
|
|
5276
|
+
if (U === void 0) throw Error("workflow runtime is not configured");
|
|
5277
|
+
return Yn(U, {
|
|
5233
5278
|
traceId: `inspect-workflow-start-${Date.now()}`,
|
|
5234
5279
|
source: "inspect"
|
|
5235
5280
|
}).start(e.name, e.payload);
|
|
5236
5281
|
},
|
|
5237
5282
|
inspectWorkflowRuns: async (e) => {
|
|
5238
|
-
let { rows: t, total: n, offset: r, limit: i } = await
|
|
5283
|
+
let { rows: t, total: n, offset: r, limit: i } = await Uc(B, {
|
|
5239
5284
|
...e.tag === void 0 ? {} : { tag: e.tag },
|
|
5240
5285
|
...e.status === void 0 ? {} : { status: e.status },
|
|
5241
5286
|
...e.offset === void 0 ? {} : { offset: e.offset },
|
|
@@ -5271,7 +5316,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5271
5316
|
let t = (await B.query({
|
|
5272
5317
|
table: "_voltro_workflow_runs",
|
|
5273
5318
|
order: [],
|
|
5274
|
-
predicate:
|
|
5319
|
+
predicate: V("id", e.runId),
|
|
5275
5320
|
projection: void 0,
|
|
5276
5321
|
skip: void 0,
|
|
5277
5322
|
take: 1
|
|
@@ -5279,7 +5324,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5279
5324
|
if (!t) return $.warn("inspect.workflow.cancel: run not found", { runId: e.runId }), { cancelled: !1 };
|
|
5280
5325
|
let n = j.find((e) => e.definition.name === t.tag);
|
|
5281
5326
|
if (n && t.status === "running") try {
|
|
5282
|
-
await
|
|
5327
|
+
await Yo.runPromise(n.definition.interrupt(t.executionId)), $.info("inspect.workflow.interrupt: engine notified", {
|
|
5283
5328
|
runId: e.runId,
|
|
5284
5329
|
tag: t.tag,
|
|
5285
5330
|
executionId: t.executionId
|
|
@@ -5297,17 +5342,17 @@ ${a.join("\n\n")}\n`);
|
|
|
5297
5342
|
});
|
|
5298
5343
|
r && S.emit("workflowRuns", {
|
|
5299
5344
|
op: "update",
|
|
5300
|
-
row:
|
|
5345
|
+
row: Vo(r)
|
|
5301
5346
|
});
|
|
5302
5347
|
let i = r?.subject?.tenantId ?? void 0;
|
|
5303
|
-
return r && await
|
|
5348
|
+
return r && await Wo.recordEvent({
|
|
5304
5349
|
runId: e.runId,
|
|
5305
5350
|
eventType: "run-cancelled",
|
|
5306
5351
|
payload: {
|
|
5307
5352
|
reason: "inspect.cancel",
|
|
5308
5353
|
...i == null ? {} : { tenantId: i }
|
|
5309
5354
|
}
|
|
5310
|
-
}), r && await
|
|
5355
|
+
}), r && await X(t.executionId, "cancelled"), $.info("inspect.workflow.cancel", {
|
|
5311
5356
|
runId: e.runId,
|
|
5312
5357
|
didUpdate: r !== null
|
|
5313
5358
|
}), { cancelled: r !== null };
|
|
@@ -5318,7 +5363,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5318
5363
|
column: "startedAt",
|
|
5319
5364
|
direction: "asc"
|
|
5320
5365
|
}],
|
|
5321
|
-
predicate:
|
|
5366
|
+
predicate: V("runId", e.runId),
|
|
5322
5367
|
projection: void 0,
|
|
5323
5368
|
skip: void 0,
|
|
5324
5369
|
take: 1e3
|
|
@@ -5344,7 +5389,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5344
5389
|
column: "occurredAt",
|
|
5345
5390
|
direction: "asc"
|
|
5346
5391
|
}],
|
|
5347
|
-
predicate:
|
|
5392
|
+
predicate: V("runId", e.runId),
|
|
5348
5393
|
projection: void 0,
|
|
5349
5394
|
skip: void 0,
|
|
5350
5395
|
take: 2e3
|
|
@@ -5358,7 +5403,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5358
5403
|
attempt: e.attempt
|
|
5359
5404
|
})) }),
|
|
5360
5405
|
inspectWorkflowDomainEvents: async (e) => {
|
|
5361
|
-
let t = Math.max(0, e.offset ?? 0), n = Math.max(1, Math.min(500, e.limit ?? 100)), r = e.name === void 0 ? void 0 :
|
|
5406
|
+
let t = Math.max(0, e.offset ?? 0), n = Math.max(1, Math.min(500, e.limit ?? 100)), r = e.name === void 0 ? void 0 : V("name", e.name), i = await B.query({
|
|
5362
5407
|
table: "_voltro_workflow_events",
|
|
5363
5408
|
order: [{
|
|
5364
5409
|
column: "occurredAt",
|
|
@@ -5397,7 +5442,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5397
5442
|
column: "createdAt",
|
|
5398
5443
|
direction: "asc"
|
|
5399
5444
|
}],
|
|
5400
|
-
predicate:
|
|
5445
|
+
predicate: V("eventId", e.eventId),
|
|
5401
5446
|
projection: void 0,
|
|
5402
5447
|
skip: void 0,
|
|
5403
5448
|
take: 500
|
|
@@ -5422,7 +5467,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5422
5467
|
column: "startedAt",
|
|
5423
5468
|
direction: "asc"
|
|
5424
5469
|
}],
|
|
5425
|
-
predicate:
|
|
5470
|
+
predicate: V("parentExecutionId", e.parentExecutionId),
|
|
5426
5471
|
projection: void 0,
|
|
5427
5472
|
skip: void 0,
|
|
5428
5473
|
take: 200
|
|
@@ -5457,7 +5502,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5457
5502
|
let t = (await B.query({
|
|
5458
5503
|
table: "_voltro_workflow_runs",
|
|
5459
5504
|
order: [],
|
|
5460
|
-
predicate:
|
|
5505
|
+
predicate: V("id", e.runId),
|
|
5461
5506
|
projection: void 0,
|
|
5462
5507
|
skip: void 0,
|
|
5463
5508
|
take: 1
|
|
@@ -5465,7 +5510,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5465
5510
|
if (!t || t.status !== "running") return { suspended: !1 };
|
|
5466
5511
|
let n = j.find((e) => e.definition.name === t.tag);
|
|
5467
5512
|
if (n) try {
|
|
5468
|
-
await
|
|
5513
|
+
await Yo.runPromise(n.definition.interrupt(t.executionId));
|
|
5469
5514
|
} catch (t) {
|
|
5470
5515
|
$.warn("inspect.workflow.suspend: interrupt failed (continuing)", {
|
|
5471
5516
|
runId: e.runId,
|
|
@@ -5478,8 +5523,8 @@ ${a.join("\n\n")}\n`);
|
|
|
5478
5523
|
});
|
|
5479
5524
|
return r && S.emit("workflowRuns", {
|
|
5480
5525
|
op: "update",
|
|
5481
|
-
row:
|
|
5482
|
-
}), r && await
|
|
5526
|
+
row: Vo(r)
|
|
5527
|
+
}), r && await Wo.recordEvent({
|
|
5483
5528
|
runId: e.runId,
|
|
5484
5529
|
eventType: "run-suspended",
|
|
5485
5530
|
payload: { reason: "inspect.suspend" }
|
|
@@ -5489,7 +5534,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5489
5534
|
let t = (await B.query({
|
|
5490
5535
|
table: "_voltro_workflow_runs",
|
|
5491
5536
|
order: [],
|
|
5492
|
-
predicate:
|
|
5537
|
+
predicate: V("id", e.runId),
|
|
5493
5538
|
projection: void 0,
|
|
5494
5539
|
skip: void 0,
|
|
5495
5540
|
take: 1
|
|
@@ -5497,7 +5542,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5497
5542
|
if (!t) return { resumed: !1 };
|
|
5498
5543
|
let n = j.find((e) => e.definition.name === t.tag);
|
|
5499
5544
|
if (n) try {
|
|
5500
|
-
await
|
|
5545
|
+
await Yo.runPromise(n.definition.resume(t.executionId));
|
|
5501
5546
|
} catch (t) {
|
|
5502
5547
|
return $.warn("inspect.workflow.resume: engine.resume failed", {
|
|
5503
5548
|
runId: e.runId,
|
|
@@ -5510,8 +5555,8 @@ ${a.join("\n\n")}\n`);
|
|
|
5510
5555
|
});
|
|
5511
5556
|
return r && S.emit("workflowRuns", {
|
|
5512
5557
|
op: "update",
|
|
5513
|
-
row:
|
|
5514
|
-
}), r && await
|
|
5558
|
+
row: Vo(r)
|
|
5559
|
+
}), r && await Wo.recordEvent({
|
|
5515
5560
|
runId: e.runId,
|
|
5516
5561
|
eventType: "run-resumed",
|
|
5517
5562
|
payload: { reason: "inspect.resume" }
|
|
@@ -5520,10 +5565,10 @@ ${a.join("\n\n")}\n`);
|
|
|
5520
5565
|
inspectRetryWorkflowRun: async (e) => {
|
|
5521
5566
|
let t = e.payloadOverride !== void 0;
|
|
5522
5567
|
try {
|
|
5523
|
-
let n = await
|
|
5568
|
+
let n = await Kc({
|
|
5524
5569
|
store: B,
|
|
5525
5570
|
workflows: j,
|
|
5526
|
-
runPromise: (e) =>
|
|
5571
|
+
runPromise: (e) => Yo.runPromise(e)
|
|
5527
5572
|
}, e.runId, t ? { payloadOverride: e.payloadOverride } : void 0);
|
|
5528
5573
|
return $.info("inspect.workflow.retry", {
|
|
5529
5574
|
runId: e.runId,
|
|
@@ -5537,9 +5582,9 @@ ${a.join("\n\n")}\n`);
|
|
|
5537
5582
|
}
|
|
5538
5583
|
},
|
|
5539
5584
|
inspectSignalWorkflowRun: async (e) => {
|
|
5540
|
-
let t = await
|
|
5585
|
+
let t = await Br({
|
|
5541
5586
|
store: B,
|
|
5542
|
-
recorder:
|
|
5587
|
+
recorder: Wo,
|
|
5543
5588
|
target: { id: e.runId },
|
|
5544
5589
|
signalName: e.signalName,
|
|
5545
5590
|
payload: e.payload
|
|
@@ -5551,9 +5596,9 @@ ${a.join("\n\n")}\n`);
|
|
|
5551
5596
|
}), t;
|
|
5552
5597
|
},
|
|
5553
5598
|
inspectUpdateWorkflowRun: async (e) => {
|
|
5554
|
-
let t = await
|
|
5599
|
+
let t = await Vr({
|
|
5555
5600
|
store: B,
|
|
5556
|
-
recorder:
|
|
5601
|
+
recorder: Wo,
|
|
5557
5602
|
target: { id: e.runId },
|
|
5558
5603
|
updateName: e.updateName,
|
|
5559
5604
|
payload: e.payload,
|
|
@@ -5574,17 +5619,17 @@ ${a.join("\n\n")}\n`);
|
|
|
5574
5619
|
name: e.name,
|
|
5575
5620
|
cron: e.cron,
|
|
5576
5621
|
timezone: e.timezone,
|
|
5577
|
-
trigger: e.trigger ??
|
|
5622
|
+
trigger: e.trigger ?? pa,
|
|
5578
5623
|
onOverlap: e.onOverlap ?? "skip",
|
|
5579
5624
|
backfill: e.backfill ?? "skip",
|
|
5580
5625
|
maxRuntimeMs: e.maxRuntimeMs ?? 30 * 6e4,
|
|
5581
5626
|
...e.description === void 0 ? {} : { description: e.description },
|
|
5582
5627
|
nextFiringAt: Qn(e).toISOString()
|
|
5583
5628
|
})),
|
|
5584
|
-
coordination:
|
|
5629
|
+
coordination: ha ? "cluster" : ma === "advisoryLock" && H === "postgres" ? "advisoryLock" : "single"
|
|
5585
5630
|
}),
|
|
5586
5631
|
inspectScheduleRuns: async (e) => {
|
|
5587
|
-
let t = Math.max(0, e.offset ?? 0), n = Math.max(1, Math.min(500, e.limit ?? 50)), r = e.name === void 0 ? void 0 :
|
|
5632
|
+
let t = Math.max(0, e.offset ?? 0), n = Math.max(1, Math.min(500, e.limit ?? 50)), r = e.name === void 0 ? void 0 : V("name", e.name), i = await B.query({
|
|
5588
5633
|
table: "_voltro_schedule_runs",
|
|
5589
5634
|
order: [{
|
|
5590
5635
|
column: "scheduledAt",
|
|
@@ -5623,21 +5668,21 @@ ${a.join("\n\n")}\n`);
|
|
|
5623
5668
|
};
|
|
5624
5669
|
},
|
|
5625
5670
|
inspectFireSchedule: async (e) => {
|
|
5626
|
-
if (!
|
|
5627
|
-
return { runId: await
|
|
5671
|
+
if (!ca) throw Error("scheduler not started (no self-triggered schedules?)");
|
|
5672
|
+
return { runId: await ca.fireNow(e.name, e.trigger) ?? null };
|
|
5628
5673
|
}
|
|
5629
5674
|
} : {},
|
|
5630
5675
|
cluster: async () => {
|
|
5631
|
-
let e = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, t =
|
|
5676
|
+
let e = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, t = H, n = t === "memory", r = n ? "none" : qr({ sqliteFamily: t === "sqlite" || t === "turso" }), i = Kr({
|
|
5632
5677
|
runnerStorage: r === "sql" ? "sql" : "memory",
|
|
5633
5678
|
...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {}
|
|
5634
|
-
}), a = !n && (process.env.CDC ?? "1") !== "0", o = t === "postgres" ? "LISTEN/NOTIFY" : t === "sqlite" || t === "turso" ? "in-process bus" : t === "mariadb" || t === "mysql" ? "binlog CDC (ROW)" : t === "mssql" ? "inline only" : t === "memory" ? "none (single-process)" : "inline only", s = t === "postgres" || t === "mariadb" || t === "mssql" ? "full" : t === "mysql" ? "inline-only" : t === "sqlite" || t === "turso" ? "single-process" : "none", c =
|
|
5679
|
+
}), a = !n && (process.env.CDC ?? "1") !== "0", o = t === "postgres" ? "LISTEN/NOTIFY" : t === "sqlite" || t === "turso" ? "in-process bus" : t === "mariadb" || t === "mysql" ? "binlog CDC (ROW)" : t === "mssql" ? "inline only" : t === "memory" ? "none (single-process)" : "inline only", s = t === "postgres" || t === "mariadb" || t === "mssql" ? "full" : t === "mysql" ? "inline-only" : t === "sqlite" || t === "turso" ? "single-process" : "none", c = ha ? "cluster" : ma === "advisoryLock" && H === "postgres" ? "advisoryLock" : "single", l = a && t === "mariadb" ? au(e) : void 0, u = {
|
|
5635
5680
|
replicaId: e,
|
|
5636
5681
|
dialect: t,
|
|
5637
5682
|
runnerHost: i.host,
|
|
5638
5683
|
runnerPort: r === "none" ? 0 : i.port,
|
|
5639
5684
|
runnerStorage: r,
|
|
5640
|
-
shardLock: r === "sql" ?
|
|
5685
|
+
shardLock: r === "sql" ? Gr() : "none",
|
|
5641
5686
|
coordination: c,
|
|
5642
5687
|
cdc: {
|
|
5643
5688
|
enabled: a,
|
|
@@ -5684,7 +5729,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5684
5729
|
runningWorkflowRuns: (await d({
|
|
5685
5730
|
table: "_voltro_workflow_runs",
|
|
5686
5731
|
order: [],
|
|
5687
|
-
predicate:
|
|
5732
|
+
predicate: V("status", "running"),
|
|
5688
5733
|
projection: ["id"],
|
|
5689
5734
|
skip: void 0,
|
|
5690
5735
|
take: void 0
|
|
@@ -5694,10 +5739,10 @@ ${a.join("\n\n")}\n`);
|
|
|
5694
5739
|
};
|
|
5695
5740
|
},
|
|
5696
5741
|
runSeed: async (e) => {
|
|
5697
|
-
let t = await ie(
|
|
5698
|
-
return ut.recordSeedResult(t),
|
|
5742
|
+
let t = await ie(xi, e, B, vi);
|
|
5743
|
+
return ut.recordSeedResult(t), ms();
|
|
5699
5744
|
},
|
|
5700
|
-
rollbackMigration: async (e) => (
|
|
5745
|
+
rollbackMigration: async (e) => (vi.warn("rollbackMigration called but only memory store is wired — no-op"), ms()),
|
|
5701
5746
|
webhooks: async () => {
|
|
5702
5747
|
let e = G.outgoing.map((e) => ({
|
|
5703
5748
|
id: e.descriptor.id,
|
|
@@ -5750,84 +5795,102 @@ ${a.join("\n\n")}\n`);
|
|
|
5750
5795
|
deliveries: r
|
|
5751
5796
|
};
|
|
5752
5797
|
},
|
|
5753
|
-
...
|
|
5754
|
-
subscribe: (e) =>
|
|
5798
|
+
...J === void 0 ? {} : { webhookActions: {
|
|
5799
|
+
subscribe: (e) => J.subscribe(e).then((e) => ({
|
|
5755
5800
|
id: e.id,
|
|
5756
5801
|
event: e.event,
|
|
5757
5802
|
url: e.url,
|
|
5758
5803
|
secret: e.secret
|
|
5759
5804
|
})),
|
|
5760
|
-
pause: (e) =>
|
|
5761
|
-
resume: (e) =>
|
|
5762
|
-
delete: (e) =>
|
|
5763
|
-
rotateSecret: (e) =>
|
|
5764
|
-
replay: (e) =>
|
|
5765
|
-
updateTargetPayloadVersion: (e, t) =>
|
|
5805
|
+
pause: (e) => J.pauseTarget(e),
|
|
5806
|
+
resume: (e) => J.resumeTarget(e),
|
|
5807
|
+
delete: (e) => J.deleteTarget(e),
|
|
5808
|
+
rotateSecret: (e) => J.rotateSecret(e),
|
|
5809
|
+
replay: (e) => J.replay(e),
|
|
5810
|
+
updateTargetPayloadVersion: (e, t) => J.updateTargetPayloadVersion(e, t)
|
|
5766
5811
|
} }
|
|
5767
|
-
},
|
|
5768
|
-
|
|
5769
|
-
let
|
|
5812
|
+
}, ys = qc(F?.plugins ?? [], To);
|
|
5813
|
+
ys !== void 0 && $.info("plugin http-request interceptor active", { plugins: (F?.plugins ?? []).filter((e) => typeof e.onHttpRequest == "function").map((e) => e.name) });
|
|
5814
|
+
let xs = (F?.plugins ?? []).flatMap((e) => e.httpRoutes ?? []), Ts = typeof Tt == "object" ? Tt.managementPath : void 0, Es = () => `public-${Math.random().toString(36).slice(2, 10)}`, Os = da([
|
|
5770
5815
|
...w.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
5771
5816
|
descriptor: e.descriptor,
|
|
5772
|
-
invoke: (t, n) =>
|
|
5817
|
+
invoke: (t, n) => Lo(e, t, {
|
|
5773
5818
|
subject: n.subject,
|
|
5774
|
-
traceId:
|
|
5819
|
+
traceId: Es()
|
|
5775
5820
|
}),
|
|
5776
|
-
subscribe: (t, n, r) =>
|
|
5821
|
+
subscribe: (t, n, r) => Ro(e, t, {
|
|
5777
5822
|
subject: n.subject,
|
|
5778
|
-
traceId:
|
|
5823
|
+
traceId: Es()
|
|
5779
5824
|
}, r)
|
|
5780
5825
|
})),
|
|
5781
5826
|
...D.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
5782
5827
|
descriptor: e.descriptor,
|
|
5783
5828
|
invoke: (t, n) => No(e, t, {
|
|
5784
5829
|
subject: n.subject,
|
|
5785
|
-
traceId:
|
|
5830
|
+
traceId: Es()
|
|
5786
5831
|
})
|
|
5787
5832
|
})),
|
|
5788
5833
|
...A.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
5789
5834
|
descriptor: e.descriptor,
|
|
5790
5835
|
invoke: (t, n) => Po(e, t, {
|
|
5791
5836
|
subject: n.subject,
|
|
5792
|
-
traceId:
|
|
5837
|
+
traceId: Es()
|
|
5793
5838
|
})
|
|
5794
5839
|
}))
|
|
5795
|
-
]),
|
|
5840
|
+
]), ks = [
|
|
5796
5841
|
...F?.restRoutes ?? [],
|
|
5797
|
-
...Dt ? Bt(Dt,
|
|
5798
|
-
...
|
|
5842
|
+
...Dt ? Bt(Dt, Ts ?? "/v1/api-keys") : [],
|
|
5843
|
+
...Os
|
|
5799
5844
|
];
|
|
5800
|
-
|
|
5801
|
-
let
|
|
5845
|
+
Os.length > 0 && $.info("public-api routes projected from descriptors", { routes: Os.map((e) => `${e.method} ${e.path}`) });
|
|
5846
|
+
let As = F?.idempotency, js = As ? {
|
|
5802
5847
|
store: tn(B),
|
|
5803
|
-
header: (typeof
|
|
5804
|
-
ttlMs: (typeof
|
|
5805
|
-
} : void 0, Ns =
|
|
5848
|
+
header: (typeof As == "object" ? As.header : void 0) ?? "Idempotency-Key",
|
|
5849
|
+
ttlMs: (typeof As == "object" ? As.ttlMs : void 0) ?? 864e5
|
|
5850
|
+
} : void 0, Ns = ks.length > 0 ? fa(ks, {
|
|
5806
5851
|
store: B,
|
|
5807
5852
|
resolveSubject: (e) => kt({
|
|
5808
5853
|
headers: e,
|
|
5809
5854
|
clientId: -1
|
|
5810
5855
|
}),
|
|
5811
|
-
...
|
|
5856
|
+
...js ? { idempotency: js } : {}
|
|
5812
5857
|
}) : [];
|
|
5813
|
-
|
|
5814
|
-
header:
|
|
5815
|
-
ttlMs:
|
|
5816
|
-
}), Ns.length > 0 && $.info("rest routes mounted", { routes:
|
|
5817
|
-
let
|
|
5818
|
-
...
|
|
5858
|
+
js && ks.length > 0 && $.info("rest idempotency active", {
|
|
5859
|
+
header: js.header,
|
|
5860
|
+
ttlMs: js.ttlMs
|
|
5861
|
+
}), Ns.length > 0 && $.info("rest routes mounted", { routes: ks.map((e) => `${e.method} ${e.path}`) });
|
|
5862
|
+
let Fs = [
|
|
5863
|
+
...xs,
|
|
5819
5864
|
...Ns,
|
|
5820
5865
|
...$n.httpRoutes
|
|
5821
|
-
], { server:
|
|
5822
|
-
group:
|
|
5823
|
-
handlersLayer:
|
|
5866
|
+
], { server: Is } = xr({
|
|
5867
|
+
group: oo,
|
|
5868
|
+
handlersLayer: es,
|
|
5824
5869
|
httpHandlersLayer: ns,
|
|
5825
5870
|
port: b,
|
|
5826
5871
|
path: F?.transport?.wsPath ?? "/ws",
|
|
5827
|
-
...
|
|
5828
|
-
...
|
|
5872
|
+
...ys ? { pluginHttpInterceptor: ys } : {},
|
|
5873
|
+
...Fs.length > 0 ? { httpRoutes: Fs } : {},
|
|
5829
5874
|
getStore: () => L.current,
|
|
5830
5875
|
inspectRoute: { handle: async (e, t, r, i) => {
|
|
5876
|
+
if (r !== "OPTIONS") {
|
|
5877
|
+
if (Ve()) return {
|
|
5878
|
+
status: 503,
|
|
5879
|
+
contentType: "application/json",
|
|
5880
|
+
body: JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }),
|
|
5881
|
+
headers: T(t.origin)
|
|
5882
|
+
};
|
|
5883
|
+
let e = We(t);
|
|
5884
|
+
if (!e.ok) return {
|
|
5885
|
+
status: 401,
|
|
5886
|
+
contentType: "application/json",
|
|
5887
|
+
body: JSON.stringify({
|
|
5888
|
+
error: "unauthorized",
|
|
5889
|
+
reason: e.reason
|
|
5890
|
+
}),
|
|
5891
|
+
headers: T(t.origin)
|
|
5892
|
+
};
|
|
5893
|
+
}
|
|
5831
5894
|
if (r === "GET" && e === "/_voltro/inspect/plugins/dashboard-mounts") return {
|
|
5832
5895
|
status: 200,
|
|
5833
5896
|
contentType: "application/json; charset=utf-8",
|
|
@@ -5858,7 +5921,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5858
5921
|
if (r === "GET" && (e === "/_voltro/inspect/traces" || e.startsWith("/_voltro/inspect/traces?"))) {
|
|
5859
5922
|
let n = ve();
|
|
5860
5923
|
return {
|
|
5861
|
-
...
|
|
5924
|
+
...yl(e, Z === "postgres" && me() ? await Zl(e, n, B) : n),
|
|
5862
5925
|
headers: T(t.origin)
|
|
5863
5926
|
};
|
|
5864
5927
|
}
|
|
@@ -5919,11 +5982,11 @@ ${a.join("\n\n")}\n`);
|
|
|
5919
5982
|
if (n) return n;
|
|
5920
5983
|
}
|
|
5921
5984
|
if (e.startsWith("/_voltro/inspect/aggregates")) {
|
|
5922
|
-
let n = await
|
|
5985
|
+
let n = await Qs(e, r, sa.registry, T(t.origin));
|
|
5923
5986
|
if (n) return n;
|
|
5924
5987
|
}
|
|
5925
5988
|
if (e.startsWith("/_voltro/inspect/timeline")) {
|
|
5926
|
-
let n = await
|
|
5989
|
+
let n = await cc(e, r, {
|
|
5927
5990
|
recorder: ln(),
|
|
5928
5991
|
readCurrentRows: async (e) => Q.inspectRows === void 0 ? [] : (await Q.inspectRows({
|
|
5929
5992
|
table: e,
|
|
@@ -5935,9 +5998,9 @@ ${a.join("\n\n")}\n`);
|
|
|
5935
5998
|
if (n) return n;
|
|
5936
5999
|
}
|
|
5937
6000
|
if (e.startsWith("/_voltro/inspect/analytics")) {
|
|
5938
|
-
let n =
|
|
5939
|
-
sink:
|
|
5940
|
-
metricsCollector:
|
|
6001
|
+
let n = nc(e, r, {
|
|
6002
|
+
sink: Zr,
|
|
6003
|
+
metricsCollector: To
|
|
5941
6004
|
}, T(t.origin));
|
|
5942
6005
|
if (n) return n;
|
|
5943
6006
|
}
|
|
@@ -5971,19 +6034,19 @@ ${a.join("\n\n")}\n`);
|
|
|
5971
6034
|
corsHeaders: (e) => T(e),
|
|
5972
6035
|
keepAlive: () => ee()
|
|
5973
6036
|
},
|
|
5974
|
-
webhookRoutes: new Map(Array.from(
|
|
6037
|
+
webhookRoutes: new Map(Array.from(Na.entries()).map(([e, t]) => [e, { handle: t }])),
|
|
5975
6038
|
...Zn ? { tracerLayer: Zn } : {}
|
|
5976
6039
|
});
|
|
5977
6040
|
try {
|
|
5978
|
-
await Kt(
|
|
6041
|
+
await Kt(Is);
|
|
5979
6042
|
} catch (e) {
|
|
5980
6043
|
$.error(`rpc server failed to bind on port ${b} — aborting boot`, { port: b }, e), process.exit(1);
|
|
5981
6044
|
}
|
|
5982
6045
|
$.info(`listening on http://localhost:${b}`, {
|
|
5983
6046
|
port: b,
|
|
5984
6047
|
ws: `ws://localhost:${b}/ws`,
|
|
5985
|
-
store:
|
|
5986
|
-
}), Ee?.set({ phase: "ready" }),
|
|
6048
|
+
store: Z
|
|
6049
|
+
}), Ee?.set({ phase: "ready" }), Z === "postgres" && $.info("postgres change-data-capture", { enabled: (process.env.CDC ?? "1") !== "0" }), await mo();
|
|
5987
6050
|
try {
|
|
5988
6051
|
await g({
|
|
5989
6052
|
id: x,
|
|
@@ -6013,7 +6076,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6013
6076
|
let n = async () => {
|
|
6014
6077
|
It.deactivate();
|
|
6015
6078
|
for (let e of ur) e.stop();
|
|
6016
|
-
ar?.dispose(), t(x), ue.dispose(), Er(), pr?.close(), await
|
|
6079
|
+
ar?.dispose(), t(x), ue.dispose(), Er(), pr?.close(), await si();
|
|
6017
6080
|
};
|
|
6018
6081
|
process.on("SIGINT", () => {
|
|
6019
6082
|
n();
|
|
@@ -6034,9 +6097,9 @@ ${a.join("\n\n")}\n`);
|
|
|
6034
6097
|
root: m,
|
|
6035
6098
|
onBeforeRestart: () => {
|
|
6036
6099
|
try {
|
|
6037
|
-
|
|
6100
|
+
Is.closeAllConnections?.();
|
|
6038
6101
|
} catch {}
|
|
6039
|
-
|
|
6102
|
+
Is.close();
|
|
6040
6103
|
}
|
|
6041
6104
|
}), Ct({
|
|
6042
6105
|
app: le,
|
|
@@ -6050,4 +6113,4 @@ ${a.join("\n\n")}\n`);
|
|
|
6050
6113
|
}), new Promise(() => {});
|
|
6051
6114
|
};
|
|
6052
6115
|
//#endregion
|
|
6053
|
-
export {
|
|
6116
|
+
export { qa as $, Cs as A, $o as B, uc as C, Ds as D, Ps as E, gs as F, ko as G, Qo as H, ps as I, $a as J, ao as K, fs as L, bs as M, vs as N, Ms as O, hs as P, Ja as Q, us as R, lc as S, qs as T, Xo as U, Zo as V, Oo as W, Za as X, Xa as Y, Ya as Z, zc as _, eu as a, _c as b, Ql as c, tu as d, Ka as et, Pl as f, Kc as g, Gc as h, Gl as i, Ss as j, ws as k, nu as l, tl as m, El as n, Ba as nt, Ml as o, cu as p, oo as q, su as r, La as rt, $l as s, Dl as t, Ga as tt, pu as u, kc as v, Ks as w, mc as x, gc as y, cs as z };
|