@voltro/cli 0.23.0 → 0.24.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 +111 -0
- package/bin/voltro.mjs +39 -4
- package/dist/{apiBuild-JQtIhZPy.js → apiBuild-B2m4XK_8.js} +44 -22
- package/dist/apiBuild-UEM3QBke.js +2 -0
- package/dist/bin.js +2 -2
- package/dist/{commands-Bsu9Buln.js → commands-CaIhTsC2.js} +2565 -2444
- package/dist/{dbCommand-GI7-BVZt.js → dbCommand-CC61CsAc.js} +248 -218
- package/dist/dbCommand-Cr__4ATv.js +2 -0
- package/dist/{dev-DRxF_qOB.js → dev-DPkQVUTP.js} +1 -1
- package/dist/{dev-jM07kq_D.js → dev-NCuEhNxs.js} +1039 -1021
- package/dist/index.js +1 -1
- package/dist/{serveCommand-Cl8sicD5.js → serveCommand-C4gzDZzc.js} +349 -336
- package/dist/serveEntry.js +1 -1
- package/package.json +17 -17
- package/templates/agent-docs/authentication.md +21 -0
- package/templates/agent-docs/cli.md +17 -0
- package/templates/agent-docs/data.md +185 -165
- package/templates/agent-docs/database/migrations.md +92 -63
- package/templates/agent-docs/database/seedsdialects.md +12 -0
- package/templates/agent-docs/deployment.md +66 -1
- package/templates/agent-docs/workflows.md +30 -0
- package/templates/apps/api-ai/package.json +8 -7
- package/templates/apps/api-auth/package.json +9 -8
- package/templates/apps/api-backend/package.json +8 -7
- package/templates/apps/api-backend-deactivation/package.json +8 -7
- package/templates/apps/api-backend-mail/package.json +9 -8
- package/templates/apps/api-backend-mariadb/package.json +10 -9
- package/templates/apps/api-backend-storage/package.json +9 -8
- package/templates/apps/api-data-advanced/package.json +9 -8
- package/templates/apps/api-durable/package.json +9 -8
- package/templates/apps/api-feature-flags/package.json +10 -9
- package/templates/apps/api-governance/package.json +9 -8
- package/templates/apps/api-kv/package.json +9 -8
- package/templates/apps/api-moderation/package.json +9 -8
- package/templates/apps/api-observability/package.json +9 -8
- package/templates/apps/api-ratelimit/package.json +9 -8
- package/templates/apps/api-rbac/package.json +9 -8
- package/templates/apps/api-rest/package.json +8 -7
- package/templates/apps/api-saas/package.json +12 -11
- package/templates/apps/api-search/package.json +9 -8
- package/templates/apps/api-versioning/package.json +9 -8
- package/templates/apps/api-webhooks/package.json +10 -9
- package/templates/apps/changelog/package.json +7 -6
- package/templates/apps/edge-functions/package.json +3 -2
- package/templates/apps/frontend-admin/package.json +9 -8
- package/templates/apps/frontend-app/package.json +9 -8
- package/templates/apps/frontend-blank/package.json +8 -7
- package/templates/apps/frontend-contact/package.json +8 -7
- package/templates/apps/frontend-contact/src/globals.d.ts +6 -0
- package/templates/apps/frontend-dashboard/package.json +8 -7
- package/templates/apps/frontend-docs/package.json +8 -7
- package/templates/apps/frontend-docs/src/globals.d.ts +6 -0
- package/templates/apps/frontend-i18n/package.json +7 -6
- package/templates/apps/frontend-landing/package.json +8 -7
- package/templates/apps/frontend-landing/src/globals.d.ts +6 -0
- package/templates/apps/frontend-spa/package.json +8 -7
- package/templates/apps/frontend-spa/src/globals.d.ts +6 -0
- package/templates/apps/frontend-ssr/package.json +8 -7
- package/templates/apps/frontend-ssr/src/globals.d.ts +6 -0
- package/templates/apps/frontend-ssr-api/package.json +9 -8
- package/templates/apps/frontend-static-blog/package.json +7 -6
- package/templates/apps/frontend-static-blog/src/globals.d.ts +6 -0
- package/dist/apiBuild-CD-4JLLA.js +0 -2
- package/dist/dbCommand-CSguuUQn.js +0 -2
|
@@ -14,35 +14,35 @@ import { FetchHttpClient as ut } from "@effect/platform";
|
|
|
14
14
|
import { Cause as dt, Cron as ft, Deferred as pt, Duration as mt, Effect as P, Fiber as ht, Layer as F, ManagedRuntime as gt, Option as _t, Ref as vt, Schema as yt, Stream as bt } from "effect";
|
|
15
15
|
import { createLogger as xt, printAppSurface as St, printReadyBlock as Ct } from "@voltro/logger";
|
|
16
16
|
import { appendFileSync as I, chownSync as wt, 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 Pt, DORMANCY_WAKEUP_TENANT as Ft, Dispatcher as It, InMemoryDataStore as z, ReactionRateLimiter as Lt, ReplicatedDataStore as Rt, SYSTEM_SUBJECT as zt, actingUserId as Bt, apiKeyManagementRoutes as Vt, applySoftDeleteScope as Ht, applyTenantScope as Ut, applyUndoInvocation as Wt, assertConnectionCipherConfigured as Gt, attachAnalyticsMirror as Kt, awaitServerListening as qt, bindMutation as Jt, bindStream as Yt, bindSubscription as Xt, buildTracingLayer as Zt, cacheScopeLeaks as Qt, cancelWakeup as $t, compileCron as en, completeOAuthConnect as tn, dataStoreApiKeyStore as nn, dataStoreIdempotencyStore as rn, drainOutbox as an, enableGraphObservation as on, enterRequestLoader as sn, extractDbCause as cn, formatCacheScopeLeaks as ln, formatServerOnlyLeaks as un, frameworkApiKeyStrategy as dn, getConnectionSubject as fn, getTimelineRecorder as pn, installPolicyGuardResolver as mn, isAggregateDefinition as hn, isEmptyTenantScopedRead as gn, isOrglessUserSubject as _n, isScheduleDefinition as vn, isWorkflowEventTriggerDefinition as yn, listRetentions as bn, loadResourceTuples as xn, localityAwareSelector as Sn, makeActionRunner as Cn, makeAdvisoryLockCoordinator as wn, makeApiKeyService as Tn, makeApiKeyUsageBuffer as En, makeApiKeyUsageFlusher as Dn, makeAppAccess as On, makeAsyncKv as kn, makeBufferingSpanProcessor as An, makeConnectionRegistry as jn, makeConnectionResolver as Mn, makeConnectionsFacade as Nn, makeCoordinatedScheduler as Pn, makeDataLoader as Fn, makeDisconnectConnectionExecutor as In, makeEffectStoreLayer as Ln, makeEventsFacade as Rn, makeLazyWorkflowFacade as zn, makeListConnectionsExecutor as Bn,
|
|
18
|
-
import { createRequire as
|
|
19
|
-
import { Rpc as
|
|
20
|
-
import { SqlClient as
|
|
21
|
-
import { WorkflowEngine as
|
|
22
|
-
import { WorkflowStepInterceptorTag as
|
|
23
|
-
import { makeClusterCronLayer as
|
|
24
|
-
import { loadAgentMessages as
|
|
25
|
-
import { actorsTable as
|
|
26
|
-
import { AuthMiddleware as
|
|
27
|
-
import { isEnvContract as
|
|
28
|
-
import { readCookie as
|
|
29
|
-
import { createHash as
|
|
30
|
-
import { declaredSnapshot as
|
|
31
|
-
import { Cache as
|
|
32
|
-
import { Kv as
|
|
33
|
-
import { getAuthSessionStrategy as
|
|
34
|
-
import { collectPublicApiRoutes as
|
|
35
|
-
import { spawn as
|
|
36
|
-
import { watch as
|
|
37
|
-
import { agentRouteDescriptors as
|
|
38
|
-
import { ArrayFormatter as
|
|
39
|
-
import { buildDeliverWebhookExecute as
|
|
40
|
-
import { isEmailTemplate as
|
|
41
|
-
import { attachBroadcastBus as
|
|
42
|
-
import { runImport as
|
|
43
|
-
import { createServer as
|
|
17
|
+
import { AggregateError as kt, AggregateMaintainer as At, AggregateNotFound as jt, AggregateRegistry as Mt, AggregateStale as Nt, AnalyticsSink as Pt, DORMANCY_WAKEUP_TENANT as Ft, Dispatcher as It, InMemoryDataStore as z, ReactionRateLimiter as Lt, ReplicatedDataStore as Rt, SYSTEM_SUBJECT as zt, actingUserId as Bt, apiKeyManagementRoutes as Vt, applySoftDeleteScope as Ht, applyTenantScope as Ut, applyUndoInvocation as Wt, assertConnectionCipherConfigured as Gt, attachAnalyticsMirror as Kt, awaitServerListening as qt, bindMutation as Jt, bindStream as Yt, bindSubscription as Xt, buildTracingLayer as Zt, cacheScopeLeaks as Qt, cancelWakeup as $t, compileCron as en, completeOAuthConnect as tn, dataStoreApiKeyStore as nn, dataStoreIdempotencyStore as rn, drainOutbox as an, enableGraphObservation as on, enterRequestLoader as sn, extractDbCause as cn, formatCacheScopeLeaks as ln, formatServerOnlyLeaks as un, frameworkApiKeyStrategy as dn, getConnectionSubject as fn, getTimelineRecorder as pn, installPolicyGuardResolver as mn, isAggregateDefinition as hn, isEmptyTenantScopedRead as gn, isOrglessUserSubject as _n, isScheduleDefinition as vn, isWorkflowEventTriggerDefinition as yn, listRetentions as bn, loadResourceTuples as xn, localityAwareSelector as Sn, makeActionRunner as Cn, makeAdvisoryLockCoordinator as wn, makeApiKeyService as Tn, makeApiKeyUsageBuffer as En, makeApiKeyUsageFlusher as Dn, makeAppAccess as On, makeAsyncKv as kn, makeBufferingSpanProcessor as An, makeConnectionRegistry as jn, makeConnectionResolver as Mn, makeConnectionsFacade as Nn, makeCoordinatedScheduler as Pn, makeDataLoader as Fn, makeDisconnectConnectionExecutor as In, makeEffectStoreLayer as Ln, makeEventsFacade as Rn, makeLazyWorkflowFacade as zn, makeListConnectionsExecutor as Bn, makeMutationOutputCodec as Vn, makeMutationRunner as Hn, makeOneShotQueryRunner as Un, makeOutboxFacade as Wn, makePostCommitWorkflowFacade as Gn, makeQueryDescriptorProducer as Kn, makeQueryReauthorizer as qn, makeQuerySubscriber as Jn, makeSchemaRegistry as Yn, makeStartConnectionExecutor as Xn, makeSubmitTokenExecutor as Zn, makeUndoCapture as Qn, makeWorkflowFacade as $n, makeWorkflowFacadeWithCallerContext as er, makeWorkflowLayers as tr, memoryRywPositionStore as nr, nextFiring as rr, noopAnalytics as B, noopAnalyticsSpec as ir, observedGraph as ar, onProcessShutdown as V, powerOfTwoSelector as or, recordSubscriptionDelivery as sr, recordTimelineEvent as cr, redisRywPositionStore as lr, redoUndoInvocation as ur, registerRetention as dr, registerWakeup as fr, resolveCurrentRegion as pr, resolveSecretsBackend as mr, retentionTtlMsFromEnv as hr, runProvidedEffect as gr, runReaction as _r, sanitizeRedirectTo as vr, serverOnlyLeaks as yr, setConnectionResolver as br, setSecretsBackend as xr, setSystemStoreHandle as Sr, setTupleSource as Cr, settleHandlerBody as wr, singleCoordinator as Tr, ssrfGuardHttpClientLayer as Er, startRpcServer as Dr, startScheduler as Or, sweepRetention as kr, tracingHttpClientLayer as Ar, undoCaptureEnabled as jr, undoLogExecutor as Mr, wrapStoreWithBootCodec as Nr, wrapStoreWithMixinBehaviour as Pr } from "@voltro/runtime";
|
|
18
|
+
import { createRequire as Fr } from "node:module";
|
|
19
|
+
import { Rpc as Ir, RpcGroup as Lr } from "@effect/rpc";
|
|
20
|
+
import { SqlClient as Rr } from "@effect/sql";
|
|
21
|
+
import { WorkflowEngine as zr } from "@effect/workflow";
|
|
22
|
+
import { WorkflowStepInterceptorTag as Br, closeWorkflowChildrenForParent as Vr, completeSuspendingSignal as Hr, getWorkflowVersionMetadata as Ur, isWorkflowWorkerLayer as Wr, makeWorkflowRunRecorder as Gr, sendWorkflowSignal as Kr, sendWorkflowUpdate as qr, serialiseWorkflowRowForWire as Jr, wrapWorkflowExecuteWithRunRecording as Yr } from "@voltro/workflow";
|
|
23
|
+
import { makeClusterCronLayer as Xr, parseShardLockMode as Zr, resolveRunnerIdentity as Qr, resolveRunnerStorage as $r, workflowEngineLayer as ei } from "@voltro/workflow/cluster";
|
|
24
|
+
import { loadAgentMessages as ti, runAgentTurn as ni } from "@voltro/ai";
|
|
25
|
+
import { actorsTable as ri, allRegisteredTables as ii, and as ai, auditAllTableIndexes as oi, drainIdentifierWarnings as si, ensureTableRegistered as ci, eq as H, formatIndexAuditIssue as li, isEmptyRelationsSpec as ui, isSqliteFamily as di, lt as fi, or as pi, registerCoreTables as mi, registerDiscoveredRelations as hi, resolveTenantNamespace as gi, runWithWriteAttribution as _i, serverOnlyColumns as vi, validateRegisteredRelations as yi, walkLeaves as bi } from "@voltro/database";
|
|
26
|
+
import { AuthMiddleware as xi, ConnectionInfoMiddleware as Si, Unauthenticated as Ci, WorkflowRunHandleSchema as wi, actionToRpc as Ti, advisoryResourceGuardWarning as Ei, anonymousSubject as Di, checkFrameworkCompat as Oi, composeAuthStrategies as ki, composeRpcInterceptors as Ai, connectionDisconnectDescriptor as ji, connectionStartDescriptor as Mi, connectionSubmitTokenDescriptor as Ni, connectionsListQueryDescriptor as Pi, findAdvisoryResourceGuards as Fi, isWireReachable as Ii, mutationToRpc as Li, publishServerError as Ri, queryToRpc as zi, streamToRpc as Bi, tenantScopedSubject as Vi, undoApplyDescriptor as Hi, undoLogQueryDescriptor as Ui, undoRedoDescriptor as Wi, workflowCancelDescriptor as Gi, workflowDomainEventsQueryDescriptor as Ki, workflowEventDeliveriesQueryDescriptor as qi, workflowResumeDescriptor as Ji, workflowRunEventsQueryDescriptor as Yi, workflowRunQueryDescriptor as Xi, workflowRunStepsQueryDescriptor as Zi, workflowRunsQueryDescriptor as Qi, workflowSignalDescriptor as $i, workflowUpdateDescriptor as ea } from "@voltro/protocol";
|
|
27
|
+
import { isEnvContract as ta } from "@voltro/env";
|
|
28
|
+
import { readCookie as na, resolveOptionalSessionSecrets as ra, verifySessionKeyed as ia } from "@voltro/protocol/session";
|
|
29
|
+
import { createHash as aa, randomBytes as U } from "node:crypto";
|
|
30
|
+
import { declaredSnapshot as oa, describeOutcome as sa, fingerprintSchema as ca, introspectSchema as la, pendingFileMigrationIds as ua, planMigrations as da, runFileBasedMigrations as fa, runFrameworkBootstrap as pa, runPlannedMigrations as ma } from "@voltro/database/sql";
|
|
31
|
+
import { Cache as ha, CacheLayer as ga, InvalidationBus as _a } from "@voltro/cache";
|
|
32
|
+
import { Kv as va } from "@voltro/kv";
|
|
33
|
+
import { getAuthSessionStrategy as ya } from "@voltro/plugin-auth";
|
|
34
|
+
import { collectPublicApiRoutes as ba, restRoutesToHttpRoutes as xa } from "@voltro/protocol/rest";
|
|
35
|
+
import { spawn as Sa } from "node:child_process";
|
|
36
|
+
import { watch as Ca } from "chokidar";
|
|
37
|
+
import { agentRouteDescriptors as wa, isAgentDescriptor as Ta } from "@voltro/ai/agent";
|
|
38
|
+
import { ArrayFormatter as Ea } from "effect/ParseResult";
|
|
39
|
+
import { buildDeliverWebhookExecute as Da, buildWebhooksService as Oa, defaultIncomingPath as ka, deliverWebhookWorkflow as Aa, isWebhookDescriptor as ja, mountIncomingWebhook as Ma } from "@voltro/plugin-webhooks";
|
|
40
|
+
import { isEmailTemplate as Na, registerEmailTemplates as Pa } from "@voltro/plugin-mail";
|
|
41
|
+
import { attachBroadcastBus as Fa, getBroadcastPlugin as W } from "@voltro/plugin-broadcast";
|
|
42
|
+
import { runImport as Ia } from "@voltro/data-transfer";
|
|
43
|
+
import { createServer as La } from "node:http";
|
|
44
44
|
//#region src/inspectEntries.ts
|
|
45
|
-
var
|
|
45
|
+
var Ra = (e) => {
|
|
46
46
|
let t = e;
|
|
47
47
|
return {
|
|
48
48
|
name: t.name,
|
|
@@ -50,15 +50,15 @@ var Ia = (e) => {
|
|
|
50
50
|
output: t.element,
|
|
51
51
|
error: t.error
|
|
52
52
|
};
|
|
53
|
-
},
|
|
53
|
+
}, za = (e, t) => [
|
|
54
54
|
...e.queries.map((e) => D(e.descriptor, "query", j(t, e.file))),
|
|
55
55
|
...e.mutations.map((e) => D(e.descriptor, "mutation", j(t, e.file))),
|
|
56
56
|
...e.actions.map((e) => D(e.descriptor, "action", j(t, e.file))),
|
|
57
|
-
...(e.streams ?? []).map((e) => D(
|
|
58
|
-
],
|
|
57
|
+
...(e.streams ?? []).map((e) => D(Ra(e.descriptor), "stream", j(t, e.file)))
|
|
58
|
+
], Ba = (e, t) => e.workflows.map((e) => ({
|
|
59
59
|
tag: String(e.definition.name),
|
|
60
60
|
file: j(t, e.file)
|
|
61
|
-
})),
|
|
61
|
+
})), G = (e, t) => {
|
|
62
62
|
if (typeof process.getuid != "function") return;
|
|
63
63
|
let n;
|
|
64
64
|
try {
|
|
@@ -73,20 +73,20 @@ var Ia = (e) => {
|
|
|
73
73
|
} catch (t) {
|
|
74
74
|
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.`;
|
|
75
75
|
}
|
|
76
|
-
},
|
|
76
|
+
}, Va = ".env.local", Ha = (e) => {
|
|
77
77
|
let t = A(e, ".gitignore"), n = "";
|
|
78
78
|
try {
|
|
79
79
|
L(t) && (n = Tt(t, "utf8"));
|
|
80
80
|
} catch {
|
|
81
81
|
return !1;
|
|
82
82
|
}
|
|
83
|
-
if (n.split(/\r?\n/).map((e) => e.trim()).some((e) => e ===
|
|
83
|
+
if (n.split(/\r?\n/).map((e) => e.trim()).some((e) => e === Va || e === `/${Va}` || e === ".env*" || e === ".env.*" || e === ".env.local*")) return !0;
|
|
84
84
|
try {
|
|
85
|
-
return I(t, `${n === "" || n.endsWith("\n") ? "" : "\n"}\n# Local secrets minted by \`voltro dev\` — machine-specific, never commit.\n${
|
|
85
|
+
return I(t, `${n === "" || n.endsWith("\n") ? "" : "\n"}\n# Local secrets minted by \`voltro dev\` — machine-specific, never commit.\n${Va}\n`, "utf8"), !0;
|
|
86
86
|
} catch {
|
|
87
87
|
return !1;
|
|
88
88
|
}
|
|
89
|
-
},
|
|
89
|
+
}, Ua = (e) => U(32).toString(e), Wa = [{
|
|
90
90
|
key: "VOLTRO_INSPECT_TOKEN",
|
|
91
91
|
encoding: "base64url",
|
|
92
92
|
description: "Bearer token for /_voltro/inspect/* — minted so the dev inspect surface is not open to the network."
|
|
@@ -94,13 +94,13 @@ var Ia = (e) => {
|
|
|
94
94
|
key: "VOLTRO_INSPECT_WRITE_TOKEN",
|
|
95
95
|
encoding: "base64url",
|
|
96
96
|
description: "Second factor for MUTATING /_voltro/inspect/* endpoints (GDPR erase/export, storage share/revoke)."
|
|
97
|
-
}],
|
|
97
|
+
}], Ga = (e, t, n = process.env) => {
|
|
98
98
|
let r = [];
|
|
99
|
-
for (let e of
|
|
99
|
+
for (let e of Wa) {
|
|
100
100
|
let t = n[e.key];
|
|
101
101
|
t !== void 0 && t.trim() !== "" || r.push({
|
|
102
102
|
key: e.key,
|
|
103
|
-
value:
|
|
103
|
+
value: Ua(e.encoding),
|
|
104
104
|
description: e.description
|
|
105
105
|
});
|
|
106
106
|
}
|
|
@@ -109,13 +109,13 @@ var Ia = (e) => {
|
|
|
109
109
|
let e = n[t];
|
|
110
110
|
e !== void 0 && e.trim() !== "" || r.push({
|
|
111
111
|
key: t,
|
|
112
|
-
value:
|
|
112
|
+
value: Ua(i.generate),
|
|
113
113
|
description: i.description
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
if (r.length === 0) return { minted: [] };
|
|
117
|
-
if (!
|
|
118
|
-
let i = A(t,
|
|
117
|
+
if (!Ha(t)) throw Error(`cannot mint ${r.map((e) => e.key).join(", ")}: failed to add "${Va}" to ${A(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\`).`);
|
|
118
|
+
let i = A(t, Va), a = r.map((e) => `${e.description ? `# ${e.description}\n` : ""}${e.key}=${e.value}`).join("\n"), o;
|
|
119
119
|
try {
|
|
120
120
|
if (L(i)) {
|
|
121
121
|
let e = Tt(i, "utf8");
|
|
@@ -126,7 +126,7 @@ var Ia = (e) => {
|
|
|
126
126
|
\n${a}\n`, {
|
|
127
127
|
encoding: "utf8",
|
|
128
128
|
mode: 384
|
|
129
|
-
}), o =
|
|
129
|
+
}), o = G(i, t);
|
|
130
130
|
} catch (e) {
|
|
131
131
|
throw Error(`cannot mint ${r.map((e) => e.key).join(", ")}: failed to write ${i} — ${e.message}`);
|
|
132
132
|
}
|
|
@@ -136,7 +136,7 @@ var Ia = (e) => {
|
|
|
136
136
|
file: i,
|
|
137
137
|
...o ? { ownershipWarning: o } : {}
|
|
138
138
|
};
|
|
139
|
-
},
|
|
139
|
+
}, Ka = [".framework", ".env.local"], qa = /\.generated\./i, Ja = (e) => {
|
|
140
140
|
try {
|
|
141
141
|
let t = Dt(e);
|
|
142
142
|
return {
|
|
@@ -146,7 +146,7 @@ var Ia = (e) => {
|
|
|
146
146
|
} catch {
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
},
|
|
149
|
+
}, K = (e, t, n) => {
|
|
150
150
|
let r = !0;
|
|
151
151
|
try {
|
|
152
152
|
wt(e, t, n);
|
|
@@ -160,44 +160,44 @@ var Ia = (e) => {
|
|
|
160
160
|
} catch {
|
|
161
161
|
return r;
|
|
162
162
|
}
|
|
163
|
-
for (let a of i)
|
|
163
|
+
for (let a of i) K(A(e, a), t, n) || (r = !1);
|
|
164
164
|
return r;
|
|
165
|
-
},
|
|
165
|
+
}, Ya = (e) => {
|
|
166
166
|
if (typeof process.getuid != "function") return { adopted: [] };
|
|
167
|
-
let t =
|
|
167
|
+
let t = Ja(e);
|
|
168
168
|
if (t === void 0) return { adopted: [] };
|
|
169
169
|
let n = process.getuid();
|
|
170
170
|
if (t.uid === n) return { adopted: [] };
|
|
171
|
-
let r = [...
|
|
171
|
+
let r = [...Ka];
|
|
172
172
|
try {
|
|
173
|
-
for (let t of Et(e))
|
|
173
|
+
for (let t of Et(e)) qa.test(t) && r.push(t);
|
|
174
174
|
} catch {}
|
|
175
175
|
let i = [], a = !1;
|
|
176
176
|
for (let n of r) {
|
|
177
177
|
let r = A(e, n);
|
|
178
|
-
|
|
178
|
+
Ja(r) !== void 0 && (K(r, t.uid, t.gid) ? i.push(n) : a = !0);
|
|
179
179
|
}
|
|
180
180
|
return a ? {
|
|
181
181
|
adopted: i,
|
|
182
182
|
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}\`).`
|
|
183
183
|
} : { adopted: i };
|
|
184
|
-
},
|
|
185
|
-
if (e.dialect === "turso" &&
|
|
184
|
+
}, Xa = (e) => e.startsWith("_voltro_"), Za = (e) => e === void 0 || e === "" || !/^file:/i.test(e) || (process.env.TURSO_SYNC_URL ?? "") !== "", Qa = (e) => {
|
|
185
|
+
if (e.dialect === "turso" && Za(e.dbUrl)) return [{
|
|
186
186
|
level: "warn",
|
|
187
187
|
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."
|
|
188
188
|
}];
|
|
189
189
|
if (e.changeStrategy !== "cdc" || e.dialect === "sqlite" || e.dialect === "turso") return [];
|
|
190
|
-
let t = new Set(e.querySources.filter((e) => !
|
|
190
|
+
let t = new Set(e.querySources.filter((e) => !Xa(e))), n = e.tables.filter((e) => !Xa(e.tableName)).filter((e) => e.isReactive === !1 && t.has(e.tableName)).map((e) => e.tableName).sort();
|
|
191
191
|
if (n.length === 0) return [];
|
|
192
192
|
let r = n.slice(0, 8).join(", "), i = n.length > 8 ? `, … (+${n.length - 8})` : "";
|
|
193
193
|
return [{
|
|
194
194
|
level: "warn",
|
|
195
195
|
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.`
|
|
196
196
|
}];
|
|
197
|
-
},
|
|
197
|
+
}, $a = "VOLTRO_REMOTE_MIGRATIONS_OK", eo = /^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/, to = (e) => {
|
|
198
198
|
let t = e.toLowerCase().replace(/^\[|\]$/g, "");
|
|
199
|
-
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") ||
|
|
200
|
-
},
|
|
199
|
+
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") || eo.test(t) || !t.includes(".") && !t.includes(":"));
|
|
200
|
+
}, no = (e) => {
|
|
201
201
|
if (e.url !== void 0 && e.url !== "") {
|
|
202
202
|
if (/^(file|sqlite):/i.test(e.url)) return {
|
|
203
203
|
kind: "local",
|
|
@@ -206,7 +206,7 @@ var Ia = (e) => {
|
|
|
206
206
|
try {
|
|
207
207
|
let t = new URL(e.url).hostname;
|
|
208
208
|
return {
|
|
209
|
-
kind:
|
|
209
|
+
kind: to(t) ? "local" : "remote",
|
|
210
210
|
host: t
|
|
211
211
|
};
|
|
212
212
|
} catch {
|
|
@@ -218,12 +218,12 @@ var Ia = (e) => {
|
|
|
218
218
|
}
|
|
219
219
|
let t = e.host ?? "localhost";
|
|
220
220
|
return {
|
|
221
|
-
kind:
|
|
221
|
+
kind: to(t) ? "local" : "remote",
|
|
222
222
|
host: t
|
|
223
223
|
};
|
|
224
|
-
},
|
|
224
|
+
}, ro = (e) => {
|
|
225
225
|
if (e.pendingIds.length === 0 || e.optIn) return { allowed: !0 };
|
|
226
|
-
let t =
|
|
226
|
+
let t = no(e.conn);
|
|
227
227
|
if (t.kind === "local") return { allowed: !0 };
|
|
228
228
|
let n = e.pendingIds.map((e) => ` • ${e}`).join("\n");
|
|
229
229
|
return {
|
|
@@ -242,11 +242,11 @@ var Ia = (e) => {
|
|
|
242
242
|
" Choose one:",
|
|
243
243
|
" • Point the app at a local database (DB_URL), which is what dev boot assumes.",
|
|
244
244
|
" • Apply them deliberately, once: voltro db files .",
|
|
245
|
-
` • Accept it for this environment: ${
|
|
245
|
+
` • Accept it for this environment: ${$a}=1`
|
|
246
246
|
].join("\n")
|
|
247
247
|
};
|
|
248
|
-
},
|
|
249
|
-
let t = gt.make(F.mergeAll(
|
|
248
|
+
}, io = async ({ env: e = process.env } = {}) => {
|
|
249
|
+
let t = gt.make(F.mergeAll(ga.layer, _a.Default)), n = await t.runPromise(ha), r = await t.runPromise(_a), i = (e.CACHE_BACKEND ?? "memory").toLowerCase();
|
|
250
250
|
return await t.runPromise(r.addSink((e) => n.invalidateTag(e))), {
|
|
251
251
|
service: n,
|
|
252
252
|
invalidationBus: r,
|
|
@@ -278,25 +278,29 @@ var Ia = (e) => {
|
|
|
278
278
|
stats: () => t.runSync(n.stats()),
|
|
279
279
|
dispose: () => t.dispose()
|
|
280
280
|
};
|
|
281
|
-
},
|
|
281
|
+
}, ao = ({ store: e, dialect: t, env: n = process.env }) => {
|
|
282
282
|
if (t !== "postgres") return { stop: () => {} };
|
|
283
|
-
|
|
283
|
+
dr({
|
|
284
284
|
table: "_voltro_schedule_runs",
|
|
285
285
|
timeColumn: "scheduledAt",
|
|
286
|
-
ttlMs:
|
|
287
|
-
}),
|
|
286
|
+
ttlMs: hr(n.VOLTRO_SCHEDULE_RUNS_TTL_HOURS, 720)
|
|
287
|
+
}), dr({
|
|
288
|
+
table: "_voltro_schedule_claims",
|
|
289
|
+
timeColumn: "claimedAt",
|
|
290
|
+
ttlMs: hr(n.VOLTRO_SCHEDULE_CLAIMS_TTL_HOURS, 720)
|
|
291
|
+
}), dr({
|
|
288
292
|
table: "_voltro_workflow_runs",
|
|
289
293
|
timeColumn: "completedAt",
|
|
290
|
-
ttlMs:
|
|
291
|
-
where:
|
|
292
|
-
}),
|
|
294
|
+
ttlMs: hr(n.VOLTRO_WORKFLOW_RUNS_TTL_HOURS, 720),
|
|
295
|
+
where: pi(H("status", "succeeded"), H("status", "failed"), H("status", "cancelled"))
|
|
296
|
+
}), dr({
|
|
293
297
|
table: "_voltro_outbox_attempts",
|
|
294
298
|
timeColumn: "startedAt",
|
|
295
|
-
ttlMs:
|
|
296
|
-
}),
|
|
299
|
+
ttlMs: hr(n.VOLTRO_OUTBOX_ATTEMPTS_TTL_HOURS, 720)
|
|
300
|
+
}), dr({
|
|
297
301
|
table: "_voltro_outbox",
|
|
298
302
|
timeColumn: "deliveredAt",
|
|
299
|
-
ttlMs:
|
|
303
|
+
ttlMs: hr(n.VOLTRO_OUTBOX_TTL_HOURS, 720),
|
|
300
304
|
where: H("status", "delivered")
|
|
301
305
|
});
|
|
302
306
|
let r = e.raw?.bind(e), i = (e) => {
|
|
@@ -312,7 +316,7 @@ var Ia = (e) => {
|
|
|
312
316
|
};
|
|
313
317
|
return (await r(e)).length;
|
|
314
318
|
}
|
|
315
|
-
let d =
|
|
319
|
+
let d = fi(l, a), f = s === void 0 ? d : ai(d, s), p = await e.query({
|
|
316
320
|
table: c,
|
|
317
321
|
order: [],
|
|
318
322
|
predicate: f,
|
|
@@ -327,20 +331,20 @@ var Ia = (e) => {
|
|
|
327
331
|
}, o = async () => {
|
|
328
332
|
let e = Date.now();
|
|
329
333
|
for (let t of bn()) try {
|
|
330
|
-
await
|
|
334
|
+
await kr(t, e, a, 2e4);
|
|
331
335
|
} catch {}
|
|
332
336
|
}, s = setInterval(() => {
|
|
333
337
|
o();
|
|
334
338
|
}, 5 * 6e4);
|
|
335
339
|
return s.unref?.(), { stop: () => clearInterval(s) };
|
|
336
|
-
},
|
|
340
|
+
}, oo = (e) => {
|
|
337
341
|
let t = Fn({ store: e.store });
|
|
338
342
|
return sn(t), {
|
|
339
|
-
storeForTenant: (t) =>
|
|
340
|
-
subject:
|
|
343
|
+
storeForTenant: (t) => Pr(e.store, {
|
|
344
|
+
subject: Vi(zt, t),
|
|
341
345
|
schemaRegistry: e.schemaRegistry
|
|
342
346
|
}),
|
|
343
|
-
store:
|
|
347
|
+
store: Pr(e.store, {
|
|
344
348
|
subject: zt,
|
|
345
349
|
schemaRegistry: e.schemaRegistry
|
|
346
350
|
}),
|
|
@@ -354,14 +358,14 @@ var Ia = (e) => {
|
|
|
354
358
|
cache: e.cache,
|
|
355
359
|
kv: e.kv
|
|
356
360
|
};
|
|
357
|
-
},
|
|
361
|
+
}, so = (e) => {
|
|
358
362
|
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) => {
|
|
359
363
|
if (!c) return e;
|
|
360
364
|
if (e.withNamespace === void 0) throw Error("tenantIsolation=namespace is set but the active store has no physical-namespace support (withNamespace).");
|
|
361
|
-
return e.withNamespace(
|
|
365
|
+
return e.withNamespace(gi(t.tenantId));
|
|
362
366
|
};
|
|
363
367
|
return (e, c = t, p, m = "app-context", h) => {
|
|
364
|
-
let ee = f(c, e.subject), g = o === void 0 ? void 0 :
|
|
368
|
+
let ee = f(c, e.subject), g = o === void 0 ? void 0 : er(o, {
|
|
365
369
|
subject: e.subject,
|
|
366
370
|
traceId: e.traceId,
|
|
367
371
|
source: m,
|
|
@@ -376,10 +380,10 @@ var Ia = (e) => {
|
|
|
376
380
|
...l === void 0 ? {} : { emit: l },
|
|
377
381
|
...h?.parentExecutionId === void 0 ? {} : { parentExecutionId: h.parentExecutionId },
|
|
378
382
|
startWorkflow: (e, t, n) => {
|
|
379
|
-
let r =
|
|
380
|
-
return (p ?
|
|
383
|
+
let r = er(o, n);
|
|
384
|
+
return (p ? Gn(r, p.afterCommit) : r).start(e, t);
|
|
381
385
|
}
|
|
382
|
-
}), _ = u === void 0 ? void 0 :
|
|
386
|
+
}), _ = u === void 0 ? void 0 : Wn({
|
|
383
387
|
store: ee,
|
|
384
388
|
subject: e.subject,
|
|
385
389
|
traceId: e.traceId,
|
|
@@ -394,14 +398,14 @@ var Ia = (e) => {
|
|
|
394
398
|
let re = e.rowFilter === void 0 ? {} : { rowFilter: e.rowFilter };
|
|
395
399
|
return {
|
|
396
400
|
storeForTenant: (t) => {
|
|
397
|
-
let r =
|
|
398
|
-
return
|
|
401
|
+
let r = Vi(e.subject, t);
|
|
402
|
+
return Pr(f(c, r), {
|
|
399
403
|
subject: r,
|
|
400
404
|
schemaRegistry: n,
|
|
401
405
|
...re
|
|
402
406
|
});
|
|
403
407
|
},
|
|
404
|
-
store:
|
|
408
|
+
store: Pr(ee, {
|
|
405
409
|
subject: e.subject,
|
|
406
410
|
schemaRegistry: n,
|
|
407
411
|
...e.rowFilter === void 0 ? {} : { rowFilter: e.rowFilter }
|
|
@@ -416,11 +420,11 @@ var Ia = (e) => {
|
|
|
416
420
|
...te === void 0 ? {} : { events: te },
|
|
417
421
|
..._ === void 0 ? {} : { outbox: _ },
|
|
418
422
|
...v === void 0 ? {} : { connections: v },
|
|
419
|
-
...g === void 0 ? {} : { workflows: p ?
|
|
423
|
+
...g === void 0 ? {} : { workflows: p ? Gn(g, p.afterCommit) : g }
|
|
420
424
|
};
|
|
421
425
|
};
|
|
422
|
-
},
|
|
423
|
-
if (t.type === "anonymous" || t.id == null) throw new
|
|
426
|
+
}, co = async (e, t, n) => {
|
|
427
|
+
if (t.type === "anonymous" || t.id == null) throw new Ci({ reason: "workflow control requires an authenticated subject" });
|
|
424
428
|
let r = "id" in n ? H("id", n.id) : H("executionId", n.executionId), i = (await e.query({
|
|
425
429
|
table: "_voltro_workflow_runs",
|
|
426
430
|
order: [],
|
|
@@ -429,9 +433,9 @@ var Ia = (e) => {
|
|
|
429
433
|
skip: void 0,
|
|
430
434
|
take: 1
|
|
431
435
|
}))[0], a = i?.subject?.tenantId ?? null, o = t.tenantId ?? null;
|
|
432
|
-
if (i === void 0 || a !== o) throw new
|
|
433
|
-
},
|
|
434
|
-
let t = F.succeed(
|
|
436
|
+
if (i === void 0 || a !== o) throw new Ci({ reason: "not authorized for this workflow run" });
|
|
437
|
+
}, lo = (e = {}) => Ar.pipe(F.provide(Er(e)), F.provide(ut.layer), F.provide(F.succeed(ut.RequestInit, { redirect: "manual" }))), uo = (e) => {
|
|
438
|
+
let t = F.succeed(ha, e.cacheService), n = F.succeed(va, e.kvService), r = [
|
|
435
439
|
e.analyticsLayer,
|
|
436
440
|
t,
|
|
437
441
|
n,
|
|
@@ -439,40 +443,40 @@ var Ia = (e) => {
|
|
|
439
443
|
...e.userLayers
|
|
440
444
|
];
|
|
441
445
|
return F.mergeAll(...r);
|
|
442
|
-
},
|
|
443
|
-
Ji,
|
|
446
|
+
}, fo = [
|
|
444
447
|
Xi,
|
|
448
|
+
Qi,
|
|
449
|
+
Zi,
|
|
445
450
|
Yi,
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
], uo = (e, t, n) => {
|
|
451
|
+
Ki,
|
|
452
|
+
qi
|
|
453
|
+
], po = (e, t, n) => {
|
|
450
454
|
let r = new Set(t);
|
|
451
|
-
if (n) for (let e of
|
|
455
|
+
if (n) for (let e of fo) r.add(e.name);
|
|
452
456
|
let i = {};
|
|
453
457
|
for (let [t, n] of Object.entries(e)) i[t] = r.has(t) ? (e) => n(e).pipe(bt.take(1)) : n;
|
|
454
458
|
return i;
|
|
455
|
-
},
|
|
456
|
-
if (!
|
|
459
|
+
}, mo = "VOLTRO_TSX_IMPORT", ho = /^--(?:import|loader|experimental-loader|require)(?:=|$)/, go = (e) => /(?:^|[/\\])tsx(?:$|[/\\])/.test(e), _o = (e) => e.some((t, n) => {
|
|
460
|
+
if (!ho.test(t)) return !1;
|
|
457
461
|
let r = t.indexOf("=");
|
|
458
|
-
return
|
|
459
|
-
}),
|
|
462
|
+
return go(r === -1 ? e[n + 1] ?? "" : t.slice(r + 1));
|
|
463
|
+
}), vo = () => {
|
|
460
464
|
try {
|
|
461
465
|
return import.meta.resolve("tsx");
|
|
462
466
|
} catch {
|
|
463
467
|
try {
|
|
464
|
-
return lt(
|
|
468
|
+
return lt(Fr(import.meta.url).resolve("tsx")).href;
|
|
465
469
|
} catch {
|
|
466
470
|
return;
|
|
467
471
|
}
|
|
468
472
|
}
|
|
469
|
-
},
|
|
473
|
+
}, yo = (e = {}) => {
|
|
470
474
|
let t = e.env ?? process.env, n = e.execArgv ?? process.execArgv;
|
|
471
|
-
if (
|
|
475
|
+
if (_o(n)) return {
|
|
472
476
|
execArgv: [...n],
|
|
473
477
|
source: "inherited"
|
|
474
478
|
};
|
|
475
|
-
let r = t[
|
|
479
|
+
let r = t[mo];
|
|
476
480
|
if (r !== void 0 && r !== "") return {
|
|
477
481
|
execArgv: [
|
|
478
482
|
...n,
|
|
@@ -481,7 +485,7 @@ var Ia = (e) => {
|
|
|
481
485
|
],
|
|
482
486
|
source: "shim-env"
|
|
483
487
|
};
|
|
484
|
-
let i = (e.resolve ??
|
|
488
|
+
let i = (e.resolve ?? vo)();
|
|
485
489
|
return i === void 0 ? {
|
|
486
490
|
execArgv: [
|
|
487
491
|
...n,
|
|
@@ -497,20 +501,20 @@ var Ia = (e) => {
|
|
|
497
501
|
],
|
|
498
502
|
source: "resolved"
|
|
499
503
|
};
|
|
500
|
-
},
|
|
504
|
+
}, bo = (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 = xt({ scope: "voltro:dev:supervisor" }), xo = /\.generated\./, So = /\.([cm]?[jt]sx?|json)$/, Co = (e) => {
|
|
501
505
|
let t = O(e);
|
|
502
|
-
return !
|
|
503
|
-
},
|
|
504
|
-
let n = M(e), r = (e) => j(n, e), i =
|
|
506
|
+
return !xo.test(t) && So.test(t);
|
|
507
|
+
}, wo = (e) => e.startsWith("node_modules") || e.startsWith(".framework") || e.startsWith(".turbo") || e.startsWith(".vite") || e.startsWith("dist") || e.startsWith(".git"), To = process.env.WATCH_POLL === "1" || process.env.CHOKIDAR_USEPOLLING === "1", Eo = 1e3, J = (e) => bt.async((t) => {
|
|
508
|
+
let n = M(e), r = (e) => j(n, e), i = Ca(n, {
|
|
505
509
|
persistent: !0,
|
|
506
510
|
ignoreInitial: !0,
|
|
507
511
|
atomic: !0,
|
|
508
|
-
usePolling:
|
|
509
|
-
interval:
|
|
510
|
-
binaryInterval:
|
|
512
|
+
usePolling: To,
|
|
513
|
+
interval: Eo,
|
|
514
|
+
binaryInterval: Eo,
|
|
511
515
|
ignored: (e) => {
|
|
512
516
|
let t = r(e);
|
|
513
|
-
return t === "" ? !1 :
|
|
517
|
+
return t === "" ? !1 : wo(t) || xo.test(O(e));
|
|
514
518
|
}
|
|
515
519
|
});
|
|
516
520
|
return i.on("all", (e, n) => {
|
|
@@ -518,20 +522,20 @@ var Ia = (e) => {
|
|
|
518
522
|
process.env.WATCH_DEBUG === "1" && q.trace("watcher fired", {
|
|
519
523
|
event: e,
|
|
520
524
|
file: i
|
|
521
|
-
}), !
|
|
525
|
+
}), !wo(i) && Co(i) && t.single({ file: i });
|
|
522
526
|
}), i.on("error", (e) => {
|
|
523
|
-
q.error("watcher error", { hint:
|
|
527
|
+
q.error("watcher error", { hint: To ? void 0 : "on a bind-mount (k8s hostPath / Docker volume) set WATCH_POLL=1" }, e);
|
|
524
528
|
}), P.sync(() => {
|
|
525
529
|
i.close();
|
|
526
530
|
});
|
|
527
|
-
}),
|
|
531
|
+
}), Do = (e) => P.async((t) => {
|
|
528
532
|
if (e.exitCode !== null) {
|
|
529
533
|
t(P.succeed(e.exitCode));
|
|
530
534
|
return;
|
|
531
535
|
}
|
|
532
536
|
e.once("exit", (e, n) => t(P.succeed(e ?? +!!n)));
|
|
533
|
-
}),
|
|
534
|
-
if (!
|
|
537
|
+
}), Oo = (e) => e.exitCode === null && e.signalCode === null, ko = (e, t = {}) => P.async((n) => {
|
|
538
|
+
if (!Oo(e)) {
|
|
535
539
|
n(P.succeed("already-exited"));
|
|
536
540
|
return;
|
|
537
541
|
}
|
|
@@ -546,17 +550,17 @@ var Ia = (e) => {
|
|
|
546
550
|
c(s ? "killed" : "terminated");
|
|
547
551
|
}
|
|
548
552
|
e.once("exit", l), e.kill("SIGTERM"), a.push(setTimeout(() => {
|
|
549
|
-
if (!
|
|
553
|
+
if (!Oo(e)) {
|
|
550
554
|
c("terminated");
|
|
551
555
|
return;
|
|
552
556
|
}
|
|
553
557
|
s = !0, e.kill("SIGKILL"), a.push(setTimeout(() => {
|
|
554
|
-
c(
|
|
558
|
+
c(Oo(e) ? "abandoned" : "killed");
|
|
555
559
|
}, i));
|
|
556
560
|
}, r));
|
|
557
|
-
}),
|
|
558
|
-
let t = process.argv[1] ?? "", n =
|
|
559
|
-
return r !== void 0 && q.warn(r),
|
|
561
|
+
}), Y = (e) => P.acquireUseRelease(P.sync(() => {
|
|
562
|
+
let t = process.argv[1] ?? "", n = yo(), r = bo(n);
|
|
563
|
+
return r !== void 0 && q.warn(r), Sa(process.execPath, [
|
|
560
564
|
...n.execArgv,
|
|
561
565
|
t,
|
|
562
566
|
"dev",
|
|
@@ -568,7 +572,7 @@ var Ia = (e) => {
|
|
|
568
572
|
FRAMEWORK_DEV_INNER: "1"
|
|
569
573
|
}
|
|
570
574
|
});
|
|
571
|
-
}),
|
|
575
|
+
}), Do, (e) => ko(e).pipe(P.tap((t) => P.sync(() => {
|
|
572
576
|
t === "killed" && q.warn("child ignored SIGTERM — escalated to SIGKILL", {
|
|
573
577
|
pid: e.pid,
|
|
574
578
|
hint: "a shutdown hook or a pool drain is not completing"
|
|
@@ -576,15 +580,15 @@ var Ia = (e) => {
|
|
|
576
580
|
pid: e.pid,
|
|
577
581
|
hint: "it still holds the port; the next boot will fail to bind. kill -9 it by hand"
|
|
578
582
|
});
|
|
579
|
-
})), P.asVoid)),
|
|
583
|
+
})), P.asVoid)), Ao = (e) => e.exitCode === 0 ? "stop" : e.keepAlive === "1" ? "wait-for-fix" : e.keepAlive === "0" ? "stop" : e.interactive ? "wait-for-fix" : "stop", jo = (e) => P.gen(function* () {
|
|
580
584
|
q.info("supervisor active — watching project root", {
|
|
581
585
|
root: e.root,
|
|
582
586
|
patterns: ["**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs,json} (excl. *.generated.*)"],
|
|
583
|
-
watcher:
|
|
587
|
+
watcher: To ? "chokidar (polling)" : "chokidar (native)",
|
|
584
588
|
hint: "WATCH=0 disables, WATCH_DEBUG=1 traces every event, WATCH_POLL=1 for bind-mounts (k8s/Docker)"
|
|
585
589
|
});
|
|
586
590
|
let t = yield* vt.make(_t.none()), n = yield* pt.make(), r = P.gen(function* () {
|
|
587
|
-
let r = yield* P.fork(
|
|
591
|
+
let r = yield* P.fork(Y(e.root).pipe(P.flatMap((e) => Ao({
|
|
588
592
|
exitCode: e,
|
|
589
593
|
interactive: process.stdout.isTTY === !0,
|
|
590
594
|
keepAlive: process.env.VOLTRO_DEV_KEEP_ALIVE
|
|
@@ -603,14 +607,14 @@ var Ia = (e) => {
|
|
|
603
607
|
}), yield* vt.set(t, _t.none());
|
|
604
608
|
});
|
|
605
609
|
yield* r;
|
|
606
|
-
let a =
|
|
610
|
+
let a = J(e.root).pipe(bt.debounce(mt.millis(80)), bt.runForEach((e) => P.gen(function* () {
|
|
607
611
|
let t = Date.now();
|
|
608
612
|
q.info("file changed — restarting", { file: e.file }), yield* i, yield* r, q.info("restart complete", { ms: Date.now() - t });
|
|
609
613
|
})), P.andThen(P.never), P.as(0)), o = yield* P.raceFirst(a, pt.await(n));
|
|
610
614
|
o === 0 ? q.info("dev server exited — supervisor stopping") : q.error("dev server exited — supervisor stopping", { exitCode: o }), yield* P.sync(() => {
|
|
611
615
|
process.exitCode = o;
|
|
612
616
|
});
|
|
613
|
-
}),
|
|
617
|
+
}), Mo = /* @__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(".")), No = (e) => e.startsWith("node:") || Mo.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/") || [
|
|
614
618
|
"@voltro/protocol/session",
|
|
615
619
|
"@voltro/protocol/jwt",
|
|
616
620
|
"@voltro/protocol/apikey"
|
|
@@ -629,8 +633,8 @@ var Ia = (e) => {
|
|
|
629
633
|
"@prisma/client",
|
|
630
634
|
"nodemailer",
|
|
631
635
|
"jose"
|
|
632
|
-
].includes(e)),
|
|
633
|
-
let t =
|
|
636
|
+
].includes(e)), Po = (e) => e.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:])\/\/[^\n]*/g, "$1"), Fo = (e) => {
|
|
637
|
+
let t = Po(e), n = [], r = /(?:^|[\n;}])\s*(?:import|export)\s+([^;'"]*?)\s+from\s+['"]([^'"]+)['"]/g, i;
|
|
634
638
|
for (; (i = r.exec(t)) !== null;) {
|
|
635
639
|
let e = i[1].trim();
|
|
636
640
|
if (e === "type" || e.startsWith("type ")) continue;
|
|
@@ -646,8 +650,8 @@ var Ia = (e) => {
|
|
|
646
650
|
let o = /\bimport\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
647
651
|
for (; (i = o.exec(t)) !== null;) n.push(i[1]);
|
|
648
652
|
return n;
|
|
649
|
-
},
|
|
650
|
-
let t =
|
|
653
|
+
}, Io = (e) => e.endsWith(".ts") || e.endsWith(".tsx"), Lo = async (e) => {
|
|
654
|
+
let t = Io(e) ? [e] : [
|
|
651
655
|
`${e}.ts`,
|
|
652
656
|
`${e}.tsx`,
|
|
653
657
|
A(e, "index.ts"),
|
|
@@ -657,7 +661,7 @@ var Ia = (e) => {
|
|
|
657
661
|
if ((await R.stat(e)).isFile()) return e;
|
|
658
662
|
} catch {}
|
|
659
663
|
return null;
|
|
660
|
-
},
|
|
664
|
+
}, Ro = async (e, t) => {
|
|
661
665
|
let n = t;
|
|
662
666
|
for (;;) {
|
|
663
667
|
let t = A(n, "node_modules", e);
|
|
@@ -668,7 +672,7 @@ var Ia = (e) => {
|
|
|
668
672
|
if (r === n) return null;
|
|
669
673
|
n = r;
|
|
670
674
|
}
|
|
671
|
-
},
|
|
675
|
+
}, zo = (e) => {
|
|
672
676
|
if (typeof e == "string") return e;
|
|
673
677
|
if (typeof e == "object" && e) {
|
|
674
678
|
let t = e;
|
|
@@ -678,23 +682,23 @@ var Ia = (e) => {
|
|
|
678
682
|
"node",
|
|
679
683
|
"default"
|
|
680
684
|
]) if (e in t) {
|
|
681
|
-
let n =
|
|
685
|
+
let n = zo(t[e]);
|
|
682
686
|
if (n !== void 0) return n;
|
|
683
687
|
}
|
|
684
688
|
}
|
|
685
|
-
},
|
|
686
|
-
if (e.startsWith(".")) return
|
|
687
|
-
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
|
|
689
|
+
}, Bo = async (e, t) => {
|
|
690
|
+
if (e.startsWith(".")) return Lo(M(k(t), e));
|
|
691
|
+
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 Ro(i, k(t));
|
|
688
692
|
if (!s) return null;
|
|
689
693
|
try {
|
|
690
|
-
let e = JSON.parse(await R.readFile(A(s, "package.json"), "utf8")), t =
|
|
691
|
-
if (typeof t == "string") return
|
|
694
|
+
let e = JSON.parse(await R.readFile(A(s, "package.json"), "utf8")), t = zo(e.exports?.[o]) ?? (o === "." ? e.module ?? e.main : void 0);
|
|
695
|
+
if (typeof t == "string") return Lo(M(s, t));
|
|
692
696
|
} catch {}
|
|
693
697
|
return null;
|
|
694
|
-
},
|
|
698
|
+
}, Vo = (e, t) => e.startsWith(t) ? e.slice(t.length).replace(/^[/\\]/, "") : e, Ho = async (e, t) => {
|
|
695
699
|
let n = /* @__PURE__ */ new Set(), r = [{
|
|
696
700
|
file: e,
|
|
697
|
-
chain: [
|
|
701
|
+
chain: [Vo(e, t)]
|
|
698
702
|
}];
|
|
699
703
|
for (; r.length > 0;) {
|
|
700
704
|
let { file: e, chain: i } = r.shift();
|
|
@@ -706,37 +710,37 @@ var Ia = (e) => {
|
|
|
706
710
|
} catch {
|
|
707
711
|
continue;
|
|
708
712
|
}
|
|
709
|
-
for (let o of
|
|
710
|
-
if (
|
|
713
|
+
for (let o of Fo(a)) {
|
|
714
|
+
if (No(o)) return {
|
|
711
715
|
specifier: o,
|
|
712
716
|
chain: [...i, o]
|
|
713
717
|
};
|
|
714
|
-
let a = await
|
|
718
|
+
let a = await Bo(o, e);
|
|
715
719
|
a && !n.has(a) && r.push({
|
|
716
720
|
file: a,
|
|
717
|
-
chain: [...i, `${o} (${
|
|
721
|
+
chain: [...i, `${o} (${Vo(a, t)})`]
|
|
718
722
|
});
|
|
719
723
|
}
|
|
720
724
|
}
|
|
721
725
|
return null;
|
|
722
|
-
},
|
|
726
|
+
}, Uo = /\.client\.tsx?$/, Wo = async (e, t) => {
|
|
723
727
|
let n = [];
|
|
724
728
|
for (let r of t) {
|
|
725
|
-
if (!
|
|
726
|
-
let t = await
|
|
729
|
+
if (!Uo.test(r)) continue;
|
|
730
|
+
let t = await Ho(r, e);
|
|
727
731
|
t !== null && n.push({
|
|
728
|
-
file:
|
|
732
|
+
file: Vo(r, e),
|
|
729
733
|
violation: t
|
|
730
734
|
});
|
|
731
735
|
}
|
|
732
736
|
return n;
|
|
733
|
-
},
|
|
737
|
+
}, Go = (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).`, Ko = async (e) => {
|
|
734
738
|
if (process.env.VOLTRO_BROWSER_SAFETY === "off") return;
|
|
735
|
-
let t = await
|
|
739
|
+
let t = await Ho(e, k(e));
|
|
736
740
|
if (!t) return;
|
|
737
741
|
let n = t.chain.join("\n → ");
|
|
738
742
|
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.`);
|
|
739
|
-
},
|
|
743
|
+
}, qo = /\.(query|mutation|action|stream)\.ts$/, Jo = /\.(query|mutation|action|stream)\.server\.ts$/, Yo = /\.workflow\.tsx$/, Xo = /(?<!\.server)\.agent\.tsx?$/, Zo = /\.connection\.tsx?$/, Qo = /* @__PURE__ */ new Set([
|
|
740
744
|
"node_modules",
|
|
741
745
|
"dist",
|
|
742
746
|
"build",
|
|
@@ -744,40 +748,40 @@ var Ia = (e) => {
|
|
|
744
748
|
".vite",
|
|
745
749
|
".next",
|
|
746
750
|
".git"
|
|
747
|
-
]),
|
|
751
|
+
]), $o = async (e) => {
|
|
748
752
|
let t = async (e) => {
|
|
749
753
|
let n = await R.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
750
|
-
for (let r of n) if (!
|
|
754
|
+
for (let r of n) if (!Qo.has(r.name)) {
|
|
751
755
|
if (r.isDirectory()) {
|
|
752
756
|
if (await t(A(e, r.name))) return !0;
|
|
753
|
-
} else if (r.isFile() &&
|
|
757
|
+
} else if (r.isFile() && Zo.test(r.name)) return !0;
|
|
754
758
|
}
|
|
755
759
|
return !1;
|
|
756
760
|
};
|
|
757
761
|
return t(e);
|
|
758
|
-
},
|
|
762
|
+
}, es = async (e) => {
|
|
759
763
|
let t = [], n = async (e) => {
|
|
760
764
|
let r = await R.readdir(e, { withFileTypes: !0 });
|
|
761
765
|
for (let i of r) {
|
|
762
|
-
if (
|
|
766
|
+
if (Qo.has(i.name)) continue;
|
|
763
767
|
let r = A(e, i.name);
|
|
764
|
-
i.isDirectory() ? await n(r) : i.isFile() && (
|
|
768
|
+
i.isDirectory() ? await n(r) : i.isFile() && (qo.test(i.name) && !Jo.test(i.name) || Yo.test(i.name) || Xo.test(i.name)) && t.push(r);
|
|
765
769
|
}
|
|
766
770
|
};
|
|
767
771
|
return await n(e), t;
|
|
768
|
-
},
|
|
772
|
+
}, ts = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && (e.kind === "query" || e.kind === "mutation" || e.kind === "action" || e.kind === "stream"), ns = Symbol.for("@effect/workflow/Workflow"), rs = (e) => typeof e == "object" && !!e && ns in e && "name" in e && typeof e.name == "string", is = async (e) => {
|
|
769
773
|
let t = [];
|
|
770
774
|
for (let n of e) {
|
|
771
775
|
let e = await import(lt(n).href);
|
|
772
|
-
for (let [r, i] of Object.entries(e)) if (
|
|
773
|
-
if (!
|
|
776
|
+
for (let [r, i] of Object.entries(e)) if (ts(i)) {
|
|
777
|
+
if (!Ii(i)) continue;
|
|
774
778
|
t.push({
|
|
775
779
|
file: n,
|
|
776
780
|
exportName: r,
|
|
777
781
|
rpcTag: i.name,
|
|
778
782
|
kind: i.kind
|
|
779
783
|
});
|
|
780
|
-
} else
|
|
784
|
+
} else rs(i) && t.push({
|
|
781
785
|
file: n,
|
|
782
786
|
exportName: r,
|
|
783
787
|
rpcTag: i.name,
|
|
@@ -785,23 +789,23 @@ var Ia = (e) => {
|
|
|
785
789
|
});
|
|
786
790
|
}
|
|
787
791
|
return t;
|
|
788
|
-
},
|
|
792
|
+
}, as = async (e) => {
|
|
789
793
|
let t = [];
|
|
790
794
|
for (let n of e) {
|
|
791
|
-
if (!
|
|
795
|
+
if (!Xo.test(n)) continue;
|
|
792
796
|
let e = await import(lt(n).href);
|
|
793
|
-
for (let [r, i] of Object.entries(e))
|
|
797
|
+
for (let [r, i] of Object.entries(e)) Ta(i) && t.push({
|
|
794
798
|
file: n,
|
|
795
799
|
exportName: r,
|
|
796
800
|
name: i.name
|
|
797
801
|
});
|
|
798
802
|
}
|
|
799
803
|
return t;
|
|
800
|
-
},
|
|
804
|
+
}, X = (e) => {
|
|
801
805
|
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(".");
|
|
802
806
|
return `${t(n[0] ?? "rpc", !1)}${n.slice(1).map((e) => t(e, !0)).join("")}Rpc`;
|
|
803
|
-
},
|
|
804
|
-
let n = (e) => j(t, e.file).replace(/\\/g, "/"), r = e.filter((e) => !
|
|
807
|
+
}, os = /^[A-Za-z][A-Za-z0-9]*([._-][A-Za-z0-9]+)*$/, ss = (e, t) => {
|
|
808
|
+
let n = (e) => j(t, e.file).replace(/\\/g, "/"), r = e.filter((e) => !os.test(e.rpcTag));
|
|
805
809
|
if (r.length > 0) throw Error(`invalid rpc tag — a procedure/workflow \`name\` must start with a letter and
|
|
806
810
|
use only letters, digits, and \`.\` \`-\` \`_\` separators (the tag becomes a JS
|
|
807
811
|
identifier in the generated rpcGroup):
|
|
@@ -809,7 +813,7 @@ identifier in the generated rpcGroup):
|
|
|
809
813
|
${r.map((e) => ` • "${e.rpcTag}" (${n(e)})`).join("\n")}\n`);
|
|
810
814
|
let i = /* @__PURE__ */ new Map();
|
|
811
815
|
for (let t of e) {
|
|
812
|
-
let e =
|
|
816
|
+
let e = X(t.rpcTag), n = i.get(e);
|
|
813
817
|
n ? n.push(t) : i.set(e, [t]);
|
|
814
818
|
}
|
|
815
819
|
let a = [...i.values()].filter((e) => new Set(e.map((e) => e.rpcTag)).size > 1);
|
|
@@ -817,8 +821,8 @@ ${r.map((e) => ` • "${e.rpcTag}" (${n(e)})`).join("\n")}\n`);
|
|
|
817
821
|
generated identifier (separators are normalized away). Rename one so they
|
|
818
822
|
differ by more than a \`.\`/\`-\`/\`_\`:
|
|
819
823
|
|
|
820
|
-
${a.map((e) => ` ${
|
|
821
|
-
},
|
|
824
|
+
${a.map((e) => ` ${X(e[0].rpcTag)}:\n` + e.map((e) => ` - "${e.rpcTag}" (${n(e)})`).join("\n")).join("\n\n")}\n`);
|
|
825
|
+
}, cs = (e) => {
|
|
822
826
|
switch (e) {
|
|
823
827
|
case "query": return 0;
|
|
824
828
|
case "mutation": return 1;
|
|
@@ -826,7 +830,7 @@ ${a.map((e) => ` ${Z(e[0].rpcTag)}:\n` + e.map((e) => ` - "${e.rpcTag}" (${
|
|
|
826
830
|
case "stream": return 3;
|
|
827
831
|
case "workflow": return 4;
|
|
828
832
|
}
|
|
829
|
-
},
|
|
833
|
+
}, ls = (e, t) => {
|
|
830
834
|
let n = /* @__PURE__ */ new Map();
|
|
831
835
|
for (let t of e) n.has(t.rpcTag) || n.set(t.rpcTag, t);
|
|
832
836
|
let r = [...n.keys()], i = (e) => j(t, n.get(e).file).replace(/\\/g, "/"), a = [];
|
|
@@ -841,7 +845,7 @@ can't be both a leaf and a namespace. Rename one side (e.g. give the
|
|
|
841
845
|
workflow/procedure a nested name like "<prefix>.run"):
|
|
842
846
|
|
|
843
847
|
${a.join("\n\n")}\n`);
|
|
844
|
-
},
|
|
848
|
+
}, us = (e, t, n, r = [], i = [], a = !1, o = !1, s = []) => {
|
|
845
849
|
let c = i.length > 0, l = i.flatMap((e) => [{
|
|
846
850
|
file: e.file,
|
|
847
851
|
exportName: e.exportName,
|
|
@@ -858,20 +862,20 @@ ${a.join("\n\n")}\n`);
|
|
|
858
862
|
rpcTag: e.tag,
|
|
859
863
|
kind: e.kind
|
|
860
864
|
}));
|
|
861
|
-
|
|
865
|
+
ls([
|
|
862
866
|
...n,
|
|
863
867
|
...l,
|
|
864
868
|
...d
|
|
865
|
-
], e),
|
|
869
|
+
], e), ss([
|
|
866
870
|
...n,
|
|
867
871
|
...l,
|
|
868
872
|
...d
|
|
869
873
|
], e);
|
|
870
|
-
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, ee = r.map((e, t) => `import { ${e.name} as __pe${t} } from '${e.module}'`), g = h ? ", __voltroPluginErrors" : "", te = u.length > 0, _ = u.map((e, t) => `import { ${e.name} as __prpc${t} } from '${e.module}'`), v = (e) => e === "query" ? "queryToRpc" : e === "mutation" ? "mutationToRpc" : "actionToRpc", ne = u.map((e, t) => `export const ${
|
|
874
|
+
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, ee = r.map((e, t) => `import { ${e.name} as __pe${t} } from '${e.module}'`), g = h ? ", __voltroPluginErrors" : "", te = u.length > 0, _ = u.map((e, t) => `import { ${e.name} as __prpc${t} } from '${e.module}'`), v = (e) => e === "query" ? "queryToRpc" : e === "mutation" ? "mutationToRpc" : "actionToRpc", ne = u.map((e, t) => `export const ${X(e.tag)} = ${v(e.kind)}(__prpc${t}${g})`), re = u.map((e) => ` ${X(e.tag)},`), ie = u.map((e, t) => ` ${JSON.stringify(e.tag)}: normalizeDescriptor(__prpc${t}),`), y = [...n].sort((e, t) => e.kind === t.kind ? e.rpcTag < t.rpcTag ? -1 : 1 : cs(e.kind) - cs(t.kind)), ae = k(t), b = (e) => `__src_${X(e.rpcTag)}`, x = (e) => {
|
|
871
875
|
let t = `./${j(ae, e.file).replace(/\\/g, "/").replace(/\.tsx?$/, "")}`;
|
|
872
876
|
return `import { ${e.exportName} as ${b(e)} } from '${t}'`;
|
|
873
877
|
}, oe = (e) => {
|
|
874
|
-
let t =
|
|
878
|
+
let t = X(e.rpcTag), n = b(e);
|
|
875
879
|
return e.kind === "query" ? `export const ${t} = queryToRpc(${n}${g})` : e.kind === "mutation" ? `export const ${t} = mutationToRpc(${n}${g})` : e.kind === "action" ? `export const ${t} = actionToRpc(${n}${g})` : e.kind === "stream" ? `export const ${t} = streamToRpc(${n}${g})` : [
|
|
876
880
|
`export const ${t} = Rpc.make('${e.rpcTag}', {`,
|
|
877
881
|
` payload: ${n}.payloadSchema,`,
|
|
@@ -900,8 +904,8 @@ ${a.join("\n\n")}\n`);
|
|
|
900
904
|
"__voltroConnectionSubmitToken",
|
|
901
905
|
"__voltroConnectionDisconnect"
|
|
902
906
|
] : [], de = [
|
|
903
|
-
...y.map((e) => ` ${
|
|
904
|
-
...i.flatMap((e) => [` ${
|
|
907
|
+
...y.map((e) => ` ${X(e.rpcTag)},`),
|
|
908
|
+
...i.flatMap((e) => [` ${X(`${e.name}.send`)},`, ` ${X(`${e.name}.messages`)},`]),
|
|
905
909
|
...le.map((e) => ` ${e},`),
|
|
906
910
|
...C.map((e) => ` ${e},`),
|
|
907
911
|
...ue.map((e) => ` ${e},`),
|
|
@@ -948,7 +952,7 @@ ${a.join("\n\n")}\n`);
|
|
|
948
952
|
return [
|
|
949
953
|
"// THIS FILE IS GENERATED — DO NOT EDIT BY HAND.",
|
|
950
954
|
"// Re-emitted by `voltro dev` whenever query/mutation/action/stream/workflow files change.",
|
|
951
|
-
`// descriptor-fingerprint: ${
|
|
955
|
+
`// descriptor-fingerprint: ${aa("sha1").update(xe.map((e) => {
|
|
952
956
|
let t = "";
|
|
953
957
|
try {
|
|
954
958
|
t = Tt(e.file, "utf8");
|
|
@@ -1012,7 +1016,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1012
1016
|
""
|
|
1013
1017
|
] : [],
|
|
1014
1018
|
...y.map(oe),
|
|
1015
|
-
...i.flatMap((e) => [`export const ${
|
|
1019
|
+
...i.flatMap((e) => [`export const ${X(`${e.name}.send`)} = actionToRpc(${m(e)}.send${g})`, `export const ${X(`${e.name}.messages`)} = queryToRpc(${m(e)}.messages${g})`]),
|
|
1016
1020
|
...S ? [
|
|
1017
1021
|
"export const __voltroWorkflowRun = queryToRpc(workflowRunQueryDescriptor)",
|
|
1018
1022
|
"export const __voltroWorkflowRuns = queryToRpc(workflowRunsQueryDescriptor)",
|
|
@@ -1087,8 +1091,8 @@ ${a.join("\n\n")}\n`);
|
|
|
1087
1091
|
""
|
|
1088
1092
|
] : []
|
|
1089
1093
|
].join("\n");
|
|
1090
|
-
},
|
|
1091
|
-
let t = M(e.root), n = await
|
|
1094
|
+
}, ds = async (e) => {
|
|
1095
|
+
let t = M(e.root), n = await es(t), r = await is(n), i = await as(n), a = await $o(t);
|
|
1092
1096
|
if (r.length === 0 && i.length === 0 && !a && (e.pluginRpcImports?.length ?? 0) === 0) return;
|
|
1093
1097
|
let o = ((e) => {
|
|
1094
1098
|
if (e.length === 0) return t;
|
|
@@ -1107,7 +1111,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1107
1111
|
"workflows"
|
|
1108
1112
|
]), c = (e) => e.slice(e.lastIndexOf("/") + 1), l = o;
|
|
1109
1113
|
for (; l !== t && s.has(c(l));) l = l.slice(0, l.lastIndexOf("/")) || "/";
|
|
1110
|
-
let u = M(e.outputFile ?? A(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 =
|
|
1114
|
+
let u = M(e.outputFile ?? A(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 = us(t, u, r, d, i, jr(), a, f), m = [];
|
|
1111
1115
|
for (let t of e.pluginContributions ?? []) {
|
|
1112
1116
|
let e = null;
|
|
1113
1117
|
try {
|
|
@@ -1126,8 +1130,8 @@ ${a.join("\n\n")}\n`);
|
|
|
1126
1130
|
try {
|
|
1127
1131
|
ee = await R.readFile(u, "utf8");
|
|
1128
1132
|
} catch {}
|
|
1129
|
-
return ee !== h && await R.writeFile(u, h, "utf8"), await
|
|
1130
|
-
},
|
|
1133
|
+
return ee !== h && await R.writeFile(u, h, "utf8"), await Ko(u), u;
|
|
1134
|
+
}, fs = (e) => {
|
|
1131
1135
|
let t = [];
|
|
1132
1136
|
for (let n of e) for (let e of n) {
|
|
1133
1137
|
let n = e.descriptor?.tag;
|
|
@@ -1139,13 +1143,13 @@ ${a.join("\n\n")}\n`);
|
|
|
1139
1143
|
} : { tag: n });
|
|
1140
1144
|
}
|
|
1141
1145
|
return t;
|
|
1142
|
-
},
|
|
1143
|
-
let n =
|
|
1144
|
-
return n.length === 0 ? 0 : (t(
|
|
1145
|
-
},
|
|
1146
|
-
let t = e.spec ??
|
|
1146
|
+
}, ps = (e, t) => {
|
|
1147
|
+
let n = Fi(e);
|
|
1148
|
+
return n.length === 0 ? 0 : (t(Ei(n)), n.length);
|
|
1149
|
+
}, ms = async (e) => {
|
|
1150
|
+
let t = e.spec ?? ir, n;
|
|
1147
1151
|
return t.kind !== "noop" && e.sqlLayer !== void 0 ? n = await P.runPromise(P.gen(function* () {
|
|
1148
|
-
let n = yield*
|
|
1152
|
+
let n = yield* Rr.SqlClient, r = t.build(n);
|
|
1149
1153
|
return t.initialize && (yield* t.initialize(r).pipe(P.catchAll((t) => P.sync(() => e.log.warn("analytics sink initialize failed", {
|
|
1150
1154
|
provider: r.info.provider,
|
|
1151
1155
|
err: String(t)
|
|
@@ -1163,14 +1167,14 @@ ${a.join("\n\n")}\n`);
|
|
|
1163
1167
|
t.dispose && await P.runPromise(t.dispose(n).pipe(P.timeout("1200 millis"), P.ignore));
|
|
1164
1168
|
}
|
|
1165
1169
|
};
|
|
1166
|
-
},
|
|
1167
|
-
for (let e of
|
|
1168
|
-
throw Error(`@effect/cluster patch asset not found (looked in: ${
|
|
1169
|
-
},
|
|
1170
|
-
if (
|
|
1171
|
-
let t = ` '${
|
|
1170
|
+
}, hs = "@effect/cluster@0.60.0", Z = "@effect__cluster@0.60.0.patch", gs = `patches/${Z}`, _s = k(N(import.meta.url)), vs = [M(_s, "..", "templates", "patches", Z), M(_s, "..", "..", "templates", "patches", Z)], ys = async () => {
|
|
1171
|
+
for (let e of vs) if (L(e)) return R.readFile(e, "utf8");
|
|
1172
|
+
throw Error(`@effect/cluster patch asset not found (looked in: ${vs.join(", ")}). This is a packaging bug — the CLI should ship it under templates/patches/.`);
|
|
1173
|
+
}, bs = (e) => RegExp(`['"]?${hs.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}['"]?\\s*:`).test(e), xs = (e) => {
|
|
1174
|
+
if (bs(e)) return null;
|
|
1175
|
+
let t = ` '${hs}': ${gs}`, n = /^patchedDependencies:[ \t]*\n/m;
|
|
1172
1176
|
return n.test(e) ? e.replace(n, (e) => `${e}${t}\n`) : `${e}${e.endsWith("\n") ? "" : "\n"}\npatchedDependencies:\n${t}\n`;
|
|
1173
|
-
},
|
|
1177
|
+
}, Ss = (e) => {
|
|
1174
1178
|
let t = M(e);
|
|
1175
1179
|
for (let e = 0; e < 12; e++) {
|
|
1176
1180
|
if (L(A(t, "pnpm-workspace.yaml"))) return t;
|
|
@@ -1179,28 +1183,28 @@ ${a.join("\n\n")}\n`);
|
|
|
1179
1183
|
t = e;
|
|
1180
1184
|
}
|
|
1181
1185
|
return null;
|
|
1182
|
-
},
|
|
1183
|
-
let t =
|
|
1186
|
+
}, Cs = async (e) => {
|
|
1187
|
+
let t = Ss(e);
|
|
1184
1188
|
if (!t) return null;
|
|
1185
|
-
let n = await
|
|
1186
|
-
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 :
|
|
1187
|
-
},
|
|
1188
|
-
let t = L(A(e,
|
|
1189
|
+
let n = await ws(t);
|
|
1190
|
+
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 : gs, n.pnpmEntryPresent ? null : "patchedDependencies in pnpm-workspace.yaml"].filter(Boolean).join(" + ")}). Without it, workflow message/runner storage misbehaves on SQL Server.`;
|
|
1191
|
+
}, ws = async (e) => {
|
|
1192
|
+
let t = L(A(e, gs)), n = A(e, "pnpm-workspace.yaml"), r = L(n) && bs(await R.readFile(n, "utf8"));
|
|
1189
1193
|
return {
|
|
1190
1194
|
patchFilePresent: t,
|
|
1191
1195
|
pnpmEntryPresent: r,
|
|
1192
1196
|
fullyWired: t && r
|
|
1193
1197
|
};
|
|
1194
|
-
},
|
|
1195
|
-
let t = [], n = A(e,
|
|
1196
|
-
(L(n) ? await R.readFile(n, "utf8") : null) !== r && (await R.mkdir(k(n), { recursive: !0 }), await R.writeFile(n, r, "utf8"), t.push(`patch file → ${
|
|
1198
|
+
}, Ts = async (e) => {
|
|
1199
|
+
let t = [], n = A(e, gs), r = await ys();
|
|
1200
|
+
(L(n) ? await R.readFile(n, "utf8") : null) !== r && (await R.mkdir(k(n), { recursive: !0 }), await R.writeFile(n, r, "utf8"), t.push(`patch file → ${gs}`));
|
|
1197
1201
|
let i = A(e, "pnpm-workspace.yaml");
|
|
1198
1202
|
if (L(i)) {
|
|
1199
|
-
let e =
|
|
1200
|
-
e !== null && (await R.writeFile(i, e, "utf8"), t.push(`patchedDependencies['${
|
|
1203
|
+
let e = xs(await R.readFile(i, "utf8"));
|
|
1204
|
+
e !== null && (await R.writeFile(i, e, "utf8"), t.push(`patchedDependencies['${hs}'] → pnpm-workspace.yaml`));
|
|
1201
1205
|
}
|
|
1202
1206
|
return t;
|
|
1203
|
-
},
|
|
1207
|
+
}, Es = (e) => e.replace(/\.subscribe\.tsx?$/, ""), Ds = async (e, t) => {
|
|
1204
1208
|
let n = [];
|
|
1205
1209
|
for (let r of e) {
|
|
1206
1210
|
let e;
|
|
@@ -1226,14 +1230,14 @@ ${a.join("\n\n")}\n`);
|
|
|
1226
1230
|
}
|
|
1227
1231
|
n.push({
|
|
1228
1232
|
file: r,
|
|
1229
|
-
id:
|
|
1233
|
+
id: Es(O(r)),
|
|
1230
1234
|
definition: a
|
|
1231
1235
|
});
|
|
1232
1236
|
}
|
|
1233
1237
|
return n;
|
|
1234
|
-
},
|
|
1238
|
+
}, Os = (e, t, n, r) => {
|
|
1235
1239
|
if (e.length === 0) return () => {};
|
|
1236
|
-
let i =
|
|
1240
|
+
let i = Pr(t, {
|
|
1237
1241
|
subject: zt,
|
|
1238
1242
|
schemaRegistry: r
|
|
1239
1243
|
}), a = [];
|
|
@@ -1246,12 +1250,12 @@ ${a.join("\n\n")}\n`);
|
|
|
1246
1250
|
store: i
|
|
1247
1251
|
};
|
|
1248
1252
|
try {
|
|
1249
|
-
let i = s(t, n);
|
|
1250
|
-
i
|
|
1253
|
+
let i = wr(s(t, n));
|
|
1254
|
+
i !== void 0 && i.catch((n) => {
|
|
1251
1255
|
e.warn("subscriber: handler rejected", {
|
|
1252
1256
|
table: o,
|
|
1253
1257
|
op: t.op
|
|
1254
|
-
}, n),
|
|
1258
|
+
}, n), Ri({
|
|
1255
1259
|
error: n,
|
|
1256
1260
|
source: "subscriber",
|
|
1257
1261
|
name: o,
|
|
@@ -1265,7 +1269,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1265
1269
|
e.warn("subscriber: handler threw synchronously", {
|
|
1266
1270
|
table: o,
|
|
1267
1271
|
op: t.op
|
|
1268
|
-
}, n),
|
|
1272
|
+
}, n), Ri({
|
|
1269
1273
|
error: n,
|
|
1270
1274
|
source: "subscriber",
|
|
1271
1275
|
name: o,
|
|
@@ -1286,7 +1290,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1286
1290
|
e();
|
|
1287
1291
|
} catch {}
|
|
1288
1292
|
};
|
|
1289
|
-
},
|
|
1293
|
+
}, ks = (e) => e.replace(/\.outbox\.tsx?$/, ""), As = async (e, t) => {
|
|
1290
1294
|
let n = [], r = /* @__PURE__ */ new Map();
|
|
1291
1295
|
for (let i of e) {
|
|
1292
1296
|
let e;
|
|
@@ -1321,12 +1325,12 @@ ${a.join("\n\n")}\n`);
|
|
|
1321
1325
|
}
|
|
1322
1326
|
r.set(o.effect, i), n.push({
|
|
1323
1327
|
file: i,
|
|
1324
|
-
id:
|
|
1328
|
+
id: ks(O(i)),
|
|
1325
1329
|
definition: o
|
|
1326
1330
|
});
|
|
1327
1331
|
}
|
|
1328
1332
|
return n;
|
|
1329
|
-
},
|
|
1333
|
+
}, js = (e) => {
|
|
1330
1334
|
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 () => {
|
|
1331
1335
|
if (a) {
|
|
1332
1336
|
o = !0;
|
|
@@ -1360,26 +1364,26 @@ ${a.join("\n\n")}\n`);
|
|
|
1360
1364
|
},
|
|
1361
1365
|
drainOnce: c
|
|
1362
1366
|
};
|
|
1363
|
-
},
|
|
1367
|
+
}, Ms = "<builtin:connections>", Ns = {
|
|
1364
1368
|
registry: jn([]),
|
|
1365
1369
|
queries: [],
|
|
1366
1370
|
mutations: [],
|
|
1367
1371
|
actions: [],
|
|
1368
1372
|
httpRoutes: [],
|
|
1369
1373
|
active: !1
|
|
1370
|
-
},
|
|
1374
|
+
}, Ps = (e) => {
|
|
1371
1375
|
let { definitions: t, store: n, publicUrl: r, log: i } = e;
|
|
1372
|
-
if (t.length === 0) return
|
|
1376
|
+
if (t.length === 0) return Ns;
|
|
1373
1377
|
Gt(t);
|
|
1374
1378
|
let a = jn(t), o = {
|
|
1375
1379
|
registry: a,
|
|
1376
1380
|
publicUrl: r
|
|
1377
1381
|
};
|
|
1378
|
-
|
|
1382
|
+
br(Mn({
|
|
1379
1383
|
store: n,
|
|
1380
1384
|
registry: a
|
|
1381
1385
|
}));
|
|
1382
|
-
let s = Bn(o), c =
|
|
1386
|
+
let s = Bn(o), c = Xn(o), l = Zn(o), u = In(o), d = t.some((e) => e.kind === "oauth2"), f = d ? [{
|
|
1383
1387
|
method: "GET",
|
|
1384
1388
|
path: "/_voltro/connections",
|
|
1385
1389
|
handle: async (e) => {
|
|
@@ -1393,7 +1397,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1393
1397
|
if (l !== null) return i.info("connection consent declined", {
|
|
1394
1398
|
connectionId: t[1],
|
|
1395
1399
|
error: l
|
|
1396
|
-
}),
|
|
1400
|
+
}), Fs(`/?connection=${encodeURIComponent(t[1] ?? "")}&error=${encodeURIComponent(l)}`);
|
|
1397
1401
|
if (s === "" || c === "") return {
|
|
1398
1402
|
status: 400,
|
|
1399
1403
|
body: "missing code or state",
|
|
@@ -1407,13 +1411,13 @@ ${a.join("\n\n")}\n`);
|
|
|
1407
1411
|
code: c,
|
|
1408
1412
|
publicUrl: r
|
|
1409
1413
|
});
|
|
1410
|
-
return i.info("connection established", { connectionId: e.connectionId }),
|
|
1414
|
+
return i.info("connection established", { connectionId: e.connectionId }), Fs(e.redirectTo);
|
|
1411
1415
|
} catch (e) {
|
|
1412
1416
|
let n = e instanceof Error ? e.message : String(e);
|
|
1413
1417
|
return i.warn("connection callback failed", {
|
|
1414
1418
|
connectionId: t[1],
|
|
1415
1419
|
reason: n
|
|
1416
|
-
}),
|
|
1420
|
+
}), Fs(`/?connection=${encodeURIComponent(t[1] ?? "")}&error=handshake_failed`);
|
|
1417
1421
|
}
|
|
1418
1422
|
}
|
|
1419
1423
|
}] : [];
|
|
@@ -1421,53 +1425,53 @@ ${a.join("\n\n")}\n`);
|
|
|
1421
1425
|
connections: t.map((e) => `${e.id} (${e.kind})`),
|
|
1422
1426
|
callback: d ? "/_voltro/connections/<id>/callback" : "(no oauth2 connection declared)",
|
|
1423
1427
|
routes: [
|
|
1428
|
+
Pi.name,
|
|
1424
1429
|
Mi.name,
|
|
1425
|
-
|
|
1426
|
-
ji.name
|
|
1427
|
-
ki.name
|
|
1430
|
+
Ni.name,
|
|
1431
|
+
ji.name
|
|
1428
1432
|
]
|
|
1429
1433
|
}), {
|
|
1430
1434
|
registry: a,
|
|
1431
1435
|
queries: [{
|
|
1432
|
-
file:
|
|
1433
|
-
descriptor:
|
|
1436
|
+
file: Ms,
|
|
1437
|
+
descriptor: Pi,
|
|
1434
1438
|
executor: (e, t) => s(e, t)
|
|
1435
1439
|
}],
|
|
1436
1440
|
mutations: [{
|
|
1437
|
-
file:
|
|
1438
|
-
descriptor:
|
|
1441
|
+
file: Ms,
|
|
1442
|
+
descriptor: Ni,
|
|
1439
1443
|
executor: (e, t) => l(e, t)
|
|
1440
1444
|
}, {
|
|
1441
|
-
file:
|
|
1442
|
-
descriptor:
|
|
1445
|
+
file: Ms,
|
|
1446
|
+
descriptor: ji,
|
|
1443
1447
|
executor: (e, t) => u(e, t)
|
|
1444
1448
|
}],
|
|
1445
1449
|
actions: [{
|
|
1446
|
-
file:
|
|
1447
|
-
descriptor:
|
|
1450
|
+
file: Ms,
|
|
1451
|
+
descriptor: Mi,
|
|
1448
1452
|
executor: (e, t) => c(e, t)
|
|
1449
1453
|
}],
|
|
1450
1454
|
httpRoutes: f,
|
|
1451
1455
|
active: !0
|
|
1452
1456
|
};
|
|
1453
|
-
},
|
|
1457
|
+
}, Fs = (e) => ({
|
|
1454
1458
|
status: 302,
|
|
1455
|
-
headers: { location:
|
|
1459
|
+
headers: { location: vr(e.startsWith("/") ? e : `/${e}`) },
|
|
1456
1460
|
body: ""
|
|
1457
|
-
}),
|
|
1461
|
+
}), Is = (e) => process.env.VOLTRO_PUBLIC_URL?.replace(/\/+$/, "") ?? `http://localhost:${e}`, Q = /* @__PURE__ */ new Set([
|
|
1458
1462
|
"strict",
|
|
1459
1463
|
"warn",
|
|
1460
1464
|
"off"
|
|
1461
|
-
]),
|
|
1465
|
+
]), Ls = (e, t) => {
|
|
1462
1466
|
let n = e.VOLTRO_SERVER_ONLY?.trim().toLowerCase();
|
|
1463
|
-
return n !== void 0 &&
|
|
1467
|
+
return n !== void 0 && Q.has(n) ? {
|
|
1464
1468
|
mode: n,
|
|
1465
1469
|
source: "env"
|
|
1466
1470
|
} : {
|
|
1467
1471
|
mode: t,
|
|
1468
1472
|
source: "default"
|
|
1469
1473
|
};
|
|
1470
|
-
},
|
|
1474
|
+
}, Rs = (e, t, n, r) => {
|
|
1471
1475
|
let i = typeof t == "string" ? {
|
|
1472
1476
|
mode: t,
|
|
1473
1477
|
source: "default"
|
|
@@ -1480,7 +1484,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1480
1484
|
action: o,
|
|
1481
1485
|
message: `[serverOnly] ${a}${o === "fail" ? `\nThis is a boot failure in ${r}. VOLTRO_SERVER_ONLY=warn downgrades it to a warning; VOLTRO_SERVER_ONLY=off silences it. Both are worse than fixing the output schema.` : i.source === "env" ? `\nThis is only a warning because VOLTRO_SERVER_ONLY=warn is set. Unset it and ${r} refuses to boot — which is the behaviour the marker is for.` : `\nThis is a WARNING in ${r} and a boot FAILURE in \`voltro serve\` and \`voltro doctor\`. Set VOLTRO_SERVER_ONLY=strict to fail here too.`}`
|
|
1482
1486
|
};
|
|
1483
|
-
},
|
|
1487
|
+
}, zs = (e, t) => ({
|
|
1484
1488
|
table: e.table,
|
|
1485
1489
|
op: e.op,
|
|
1486
1490
|
new: e.new ?? null,
|
|
@@ -1489,7 +1493,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1489
1493
|
...e.traceId === void 0 ? {} : { traceId: e.traceId },
|
|
1490
1494
|
...e.subjectId === void 0 ? {} : { subjectId: e.subjectId },
|
|
1491
1495
|
changeScope: t
|
|
1492
|
-
}),
|
|
1496
|
+
}), Bs = (e) => e.replace(/\.reaction\.tsx?$/, ""), Vs = async (e, t) => {
|
|
1493
1497
|
let n = [];
|
|
1494
1498
|
for (let r of e) {
|
|
1495
1499
|
let e;
|
|
@@ -1523,12 +1527,12 @@ ${a.join("\n\n")}\n`);
|
|
|
1523
1527
|
}
|
|
1524
1528
|
n.push({
|
|
1525
1529
|
file: r,
|
|
1526
|
-
id:
|
|
1530
|
+
id: Bs(O(r)),
|
|
1527
1531
|
definition: a
|
|
1528
1532
|
});
|
|
1529
1533
|
}
|
|
1530
1534
|
return n;
|
|
1531
|
-
},
|
|
1535
|
+
}, Hs = async (e, t, n) => {
|
|
1532
1536
|
let r = n.findAgentSend(e);
|
|
1533
1537
|
if (r === void 0) {
|
|
1534
1538
|
n.log.warn("reaction agent act — no synthesized agent found (declare a `*.agent.tsx` named this)", { agent: e });
|
|
@@ -1543,7 +1547,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1543
1547
|
subject: n.makeSubject(a),
|
|
1544
1548
|
traceId: `reaction:${e}`
|
|
1545
1549
|
});
|
|
1546
|
-
},
|
|
1550
|
+
}, Us = (e, t, n, r) => {
|
|
1547
1551
|
if (e.length === 0) return () => {};
|
|
1548
1552
|
let i = /* @__PURE__ */ new Set(), a = {
|
|
1549
1553
|
has: (e) => i.has(e),
|
|
@@ -1571,7 +1575,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1571
1575
|
...e
|
|
1572
1576
|
}), l = t.onChange((e) => {
|
|
1573
1577
|
let t = s.get(e.table);
|
|
1574
|
-
if (t !== void 0) for (let { reaction: n, log: r } of t)
|
|
1578
|
+
if (t !== void 0) for (let { reaction: n, log: r } of t) _r(n, e, c()).then((t) => {
|
|
1575
1579
|
t === "acted" && r.info("reaction: acted", {
|
|
1576
1580
|
table: e.table,
|
|
1577
1581
|
op: e.op
|
|
@@ -1580,7 +1584,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1580
1584
|
r.warn("reaction: dispatch failed", {
|
|
1581
1585
|
table: e.table,
|
|
1582
1586
|
op: e.op
|
|
1583
|
-
}, t),
|
|
1587
|
+
}, t), Ri({
|
|
1584
1588
|
error: t,
|
|
1585
1589
|
source: "reaction",
|
|
1586
1590
|
name: n.name,
|
|
@@ -1593,7 +1597,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1593
1597
|
l();
|
|
1594
1598
|
} catch {}
|
|
1595
1599
|
};
|
|
1596
|
-
},
|
|
1600
|
+
}, Ws = "_voltro_aggregate_meta", Gs = "_voltro_aggregate_rows", Ks = () => {
|
|
1597
1601
|
let e = /* @__PURE__ */ new Map(), t = {
|
|
1598
1602
|
refreshedAt: null,
|
|
1599
1603
|
rowCount: 0,
|
|
@@ -1638,8 +1642,8 @@ ${a.join("\n\n")}\n`);
|
|
|
1638
1642
|
},
|
|
1639
1643
|
refreshMirror: async () => {}
|
|
1640
1644
|
};
|
|
1641
|
-
},
|
|
1642
|
-
CREATE TABLE IF NOT EXISTS ${
|
|
1645
|
+
}, qs = `
|
|
1646
|
+
CREATE TABLE IF NOT EXISTS ${Ws} (
|
|
1643
1647
|
name TEXT PRIMARY KEY,
|
|
1644
1648
|
generation INTEGER NOT NULL DEFAULT 0,
|
|
1645
1649
|
refreshed_at TEXT,
|
|
@@ -1648,24 +1652,24 @@ ${a.join("\n\n")}\n`);
|
|
|
1648
1652
|
last_error TEXT,
|
|
1649
1653
|
next_refresh_at TEXT
|
|
1650
1654
|
);
|
|
1651
|
-
`.trim(),
|
|
1652
|
-
CREATE TABLE IF NOT EXISTS ${
|
|
1655
|
+
`.trim(), Js = `
|
|
1656
|
+
CREATE TABLE IF NOT EXISTS ${Gs} (
|
|
1653
1657
|
aggregate_name TEXT NOT NULL,
|
|
1654
1658
|
generation INTEGER NOT NULL,
|
|
1655
1659
|
row_index INTEGER NOT NULL,
|
|
1656
1660
|
row_data TEXT NOT NULL,
|
|
1657
1661
|
PRIMARY KEY (aggregate_name, generation, row_index)
|
|
1658
1662
|
);
|
|
1659
|
-
`.trim(),
|
|
1660
|
-
CREATE INDEX IF NOT EXISTS ${
|
|
1661
|
-
ON ${
|
|
1662
|
-
`.trim(),
|
|
1663
|
+
`.trim(), Ys = `
|
|
1664
|
+
CREATE INDEX IF NOT EXISTS ${Gs}_lookup
|
|
1665
|
+
ON ${Gs} (aggregate_name, generation, row_index);
|
|
1666
|
+
`.trim(), Xs = (e) => ({
|
|
1663
1667
|
refreshedAt: e.refreshed_at === null ? null : new Date(e.refreshed_at),
|
|
1664
1668
|
rowCount: e.row_count,
|
|
1665
1669
|
durationMs: e.duration_ms,
|
|
1666
1670
|
lastError: e.last_error,
|
|
1667
1671
|
nextRefreshAt: e.next_refresh_at === null ? null : new Date(e.next_refresh_at)
|
|
1668
|
-
}),
|
|
1672
|
+
}), Zs = (e) => {
|
|
1669
1673
|
let t = /* @__PURE__ */ new Map(), n = {
|
|
1670
1674
|
refreshedAt: null,
|
|
1671
1675
|
rowCount: 0,
|
|
@@ -1673,14 +1677,14 @@ ${a.join("\n\n")}\n`);
|
|
|
1673
1677
|
lastError: null,
|
|
1674
1678
|
nextRefreshAt: null
|
|
1675
1679
|
}, r = (t) => P.runPromise(t.pipe(P.provide(e))), i = () => P.gen(function* () {
|
|
1676
|
-
let e = yield*
|
|
1677
|
-
yield* e.unsafe(
|
|
1680
|
+
let e = yield* Rr.SqlClient;
|
|
1681
|
+
yield* e.unsafe(qs).pipe(P.orDie), yield* e.unsafe(Js).pipe(P.orDie), yield* e.unsafe(Ys).pipe(P.orDie);
|
|
1678
1682
|
}), a = () => P.gen(function* () {
|
|
1679
|
-
let e = yield*
|
|
1683
|
+
let e = yield* Rr.SqlClient, n = yield* e`SELECT * FROM ${e(Ws)}`.pipe(P.orElseSucceed(() => []));
|
|
1680
1684
|
for (let r of n) {
|
|
1681
1685
|
let n = yield* e`
|
|
1682
1686
|
SELECT ${e("row_index")} AS row_index, ${e("row_data")} AS row_data
|
|
1683
|
-
FROM ${e(
|
|
1687
|
+
FROM ${e(Gs)}
|
|
1684
1688
|
WHERE ${e("aggregate_name")} = ${r.name}
|
|
1685
1689
|
AND ${e("generation")} = ${r.generation}
|
|
1686
1690
|
ORDER BY ${e("row_index")} ASC
|
|
@@ -1690,17 +1694,17 @@ ${a.join("\n\n")}\n`);
|
|
|
1690
1694
|
} catch {}
|
|
1691
1695
|
t.set(r.name, {
|
|
1692
1696
|
rows: i,
|
|
1693
|
-
meta:
|
|
1697
|
+
meta: Xs(r)
|
|
1694
1698
|
});
|
|
1695
1699
|
}
|
|
1696
1700
|
}), o = (e, t) => P.gen(function* () {
|
|
1697
|
-
let n = yield*
|
|
1701
|
+
let n = yield* Rr.SqlClient, r = (yield* n`
|
|
1698
1702
|
SELECT ${n("generation")} AS generation
|
|
1699
|
-
FROM ${n(
|
|
1703
|
+
FROM ${n(Ws)}
|
|
1700
1704
|
WHERE ${n("name")} = ${e}
|
|
1701
1705
|
`.pipe(P.orElseSucceed(() => [])))[0]?.generation ?? 0, i = r + 1;
|
|
1702
1706
|
yield* n`
|
|
1703
|
-
UPDATE ${n(
|
|
1707
|
+
UPDATE ${n(Ws)} SET
|
|
1704
1708
|
${n("generation")} = ${i},
|
|
1705
1709
|
${n("refreshed_at")} = ${t.meta.refreshedAt ? t.meta.refreshedAt.toISOString() : null},
|
|
1706
1710
|
${n("duration_ms")} = ${t.meta.durationMs},
|
|
@@ -1709,7 +1713,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1709
1713
|
${n("next_refresh_at")} = ${t.meta.nextRefreshAt ? t.meta.nextRefreshAt.toISOString() : null}
|
|
1710
1714
|
WHERE ${n("name")} = ${e}
|
|
1711
1715
|
`.pipe(P.orDie), r === 0 && (yield* n`
|
|
1712
|
-
INSERT INTO ${n(
|
|
1716
|
+
INSERT INTO ${n(Ws)}
|
|
1713
1717
|
(${n("name")}, ${n("generation")}, ${n("refreshed_at")},
|
|
1714
1718
|
${n("duration_ms")}, ${n("row_count")}, ${n("last_error")}, ${n("next_refresh_at")})
|
|
1715
1719
|
VALUES
|
|
@@ -1720,21 +1724,21 @@ ${a.join("\n\n")}\n`);
|
|
|
1720
1724
|
for (let r = 0; r < t.rows.length; r++) {
|
|
1721
1725
|
let a = JSON.stringify(t.rows[r]);
|
|
1722
1726
|
yield* n`
|
|
1723
|
-
INSERT INTO ${n(
|
|
1727
|
+
INSERT INTO ${n(Gs)}
|
|
1724
1728
|
(${n("aggregate_name")}, ${n("generation")}, ${n("row_index")}, ${n("row_data")})
|
|
1725
1729
|
VALUES
|
|
1726
1730
|
(${e}, ${i}, ${r}, ${a})
|
|
1727
1731
|
`.pipe(P.orDie);
|
|
1728
1732
|
}
|
|
1729
1733
|
r > 0 && (yield* n`
|
|
1730
|
-
DELETE FROM ${n(
|
|
1734
|
+
DELETE FROM ${n(Gs)}
|
|
1731
1735
|
WHERE ${n("aggregate_name")} = ${e}
|
|
1732
1736
|
AND ${n("generation")} < ${i}
|
|
1733
1737
|
`.pipe(P.orDie));
|
|
1734
1738
|
}), s = (e, t) => P.gen(function* () {
|
|
1735
|
-
let n = yield*
|
|
1739
|
+
let n = yield* Rr.SqlClient;
|
|
1736
1740
|
yield* n`
|
|
1737
|
-
UPDATE ${n(
|
|
1741
|
+
UPDATE ${n(Ws)} SET
|
|
1738
1742
|
${n("refreshed_at")} = ${t.refreshedAt ? t.refreshedAt.toISOString() : null},
|
|
1739
1743
|
${n("duration_ms")} = ${t.durationMs},
|
|
1740
1744
|
${n("row_count")} = ${t.rowCount},
|
|
@@ -1742,10 +1746,10 @@ ${a.join("\n\n")}\n`);
|
|
|
1742
1746
|
${n("next_refresh_at")} = ${t.nextRefreshAt ? t.nextRefreshAt.toISOString() : null}
|
|
1743
1747
|
WHERE ${n("name")} = ${e}
|
|
1744
1748
|
`.pipe(P.orDie), (yield* n`
|
|
1745
|
-
SELECT ${n("name")} FROM ${n(
|
|
1749
|
+
SELECT ${n("name")} FROM ${n(Ws)}
|
|
1746
1750
|
WHERE ${n("name")} = ${e}
|
|
1747
1751
|
`.pipe(P.orElseSucceed(() => []))).length === 0 && (yield* n`
|
|
1748
|
-
INSERT INTO ${n(
|
|
1752
|
+
INSERT INTO ${n(Ws)}
|
|
1749
1753
|
(${n("name")}, ${n("generation")}, ${n("refreshed_at")},
|
|
1750
1754
|
${n("duration_ms")}, ${n("row_count")}, ${n("last_error")}, ${n("next_refresh_at")})
|
|
1751
1755
|
VALUES
|
|
@@ -1793,14 +1797,14 @@ ${a.join("\n\n")}\n`);
|
|
|
1793
1797
|
},
|
|
1794
1798
|
refreshMirror: async (e) => {
|
|
1795
1799
|
await r(P.gen(function* () {
|
|
1796
|
-
let n = yield*
|
|
1797
|
-
SELECT * FROM ${n(
|
|
1800
|
+
let n = yield* Rr.SqlClient, r = (yield* n`
|
|
1801
|
+
SELECT * FROM ${n(Ws)}
|
|
1798
1802
|
WHERE ${n("name")} = ${e}
|
|
1799
1803
|
`.pipe(P.orElseSucceed(() => [])))[0];
|
|
1800
1804
|
if (!r) return;
|
|
1801
1805
|
let i = yield* n`
|
|
1802
1806
|
SELECT ${n("row_index")} AS row_index, ${n("row_data")} AS row_data
|
|
1803
|
-
FROM ${n(
|
|
1807
|
+
FROM ${n(Gs)}
|
|
1804
1808
|
WHERE ${n("aggregate_name")} = ${e}
|
|
1805
1809
|
AND ${n("generation")} = ${r.generation}
|
|
1806
1810
|
ORDER BY ${n("row_index")} ASC
|
|
@@ -1810,12 +1814,12 @@ ${a.join("\n\n")}\n`);
|
|
|
1810
1814
|
} catch {}
|
|
1811
1815
|
t.set(e, {
|
|
1812
1816
|
rows: a,
|
|
1813
|
-
meta:
|
|
1817
|
+
meta: Xs(r)
|
|
1814
1818
|
});
|
|
1815
1819
|
}));
|
|
1816
1820
|
}
|
|
1817
1821
|
};
|
|
1818
|
-
},
|
|
1822
|
+
}, Qs = (e) => e.replace(/\.aggregate\.tsx?$/, ""), $s = async (e, t) => {
|
|
1819
1823
|
let n = [], r = /* @__PURE__ */ new Set();
|
|
1820
1824
|
for (let i of e) {
|
|
1821
1825
|
let e;
|
|
@@ -1834,11 +1838,11 @@ ${a.join("\n\n")}\n`);
|
|
|
1834
1838
|
r.add(a.name), n.push({
|
|
1835
1839
|
file: i,
|
|
1836
1840
|
definition: a
|
|
1837
|
-
}),
|
|
1841
|
+
}), Qs(O(i));
|
|
1838
1842
|
}
|
|
1839
1843
|
return n;
|
|
1840
|
-
},
|
|
1841
|
-
let t =
|
|
1844
|
+
}, ec = /^(\d+)(ms|s|m|h|d)$/, tc = (e) => {
|
|
1845
|
+
let t = ec.exec(e.trim());
|
|
1842
1846
|
if (!t) throw Error(`aggregate: invalid refresh interval '${e}' — expected '<n><ms|s|m|h|d>' (e.g. '5m', '1h', '500ms')`);
|
|
1843
1847
|
let n = Number(t[1]);
|
|
1844
1848
|
switch (t[2]) {
|
|
@@ -1849,7 +1853,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1849
1853
|
case "d": return n * 864e5;
|
|
1850
1854
|
}
|
|
1851
1855
|
throw Error("unreachable");
|
|
1852
|
-
},
|
|
1856
|
+
}, nc = (e, t) => {
|
|
1853
1857
|
if (t === void 0) return e;
|
|
1854
1858
|
let n = Object.entries(t);
|
|
1855
1859
|
return n.length === 0 ? e : e.filter((e) => {
|
|
@@ -1862,23 +1866,23 @@ ${a.join("\n\n")}\n`);
|
|
|
1862
1866
|
}
|
|
1863
1867
|
return !0;
|
|
1864
1868
|
});
|
|
1865
|
-
},
|
|
1869
|
+
}, rc = (e, t, n) => {
|
|
1866
1870
|
if (t === void 0) return e;
|
|
1867
1871
|
let r = n === "desc" ? -1 : 1;
|
|
1868
1872
|
return [...e].sort((e, n) => {
|
|
1869
1873
|
let i = e[t], a = n[t];
|
|
1870
1874
|
return i === a ? 0 : i == null ? -1 * r : a == null ? 1 * r : i < a ? -1 * r : i > a ? 1 * r : 0;
|
|
1871
1875
|
});
|
|
1872
|
-
},
|
|
1876
|
+
}, ic = (e, t, n) => {
|
|
1873
1877
|
if (n === void 0 && t === void 0) return e;
|
|
1874
1878
|
let r = n ?? 0, i = t === void 0 ? e.length : r + t;
|
|
1875
1879
|
return e.slice(r, i);
|
|
1876
|
-
},
|
|
1880
|
+
}, ac = (e, t) => {
|
|
1877
1881
|
let n = yt.decodeUnknownEither(e.output), r = [];
|
|
1878
1882
|
for (let e = 0; e < t.length; e++) {
|
|
1879
1883
|
let i = n(t[e]);
|
|
1880
1884
|
if (i._tag === "Left") {
|
|
1881
|
-
let t =
|
|
1885
|
+
let t = Ea.formatErrorSync(i.left)[0], n = t?.path?.length ? t.path.join(".") : "<root>";
|
|
1882
1886
|
return {
|
|
1883
1887
|
ok: !1,
|
|
1884
1888
|
reason: `row[${e}] failed output-schema decode at ${n}: ${t?.message ?? "unknown"}`
|
|
@@ -1890,7 +1894,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1890
1894
|
ok: !0,
|
|
1891
1895
|
rows: r
|
|
1892
1896
|
};
|
|
1893
|
-
},
|
|
1897
|
+
}, oc = (e, t) => {
|
|
1894
1898
|
let n = e.refresh;
|
|
1895
1899
|
if (n.cron) {
|
|
1896
1900
|
let e = n.timezone ?? "UTC", r = ft.unsafeParse(n.cron, e);
|
|
@@ -1901,7 +1905,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1901
1905
|
};
|
|
1902
1906
|
}
|
|
1903
1907
|
if (n.interval) {
|
|
1904
|
-
let e =
|
|
1908
|
+
let e = tc(n.interval);
|
|
1905
1909
|
return {
|
|
1906
1910
|
intervalMs: e,
|
|
1907
1911
|
nextAt: new Date(t.getTime() + e),
|
|
@@ -1917,7 +1921,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1917
1921
|
nextAt: null,
|
|
1918
1922
|
kind: "none"
|
|
1919
1923
|
};
|
|
1920
|
-
},
|
|
1924
|
+
}, sc = async (e) => {
|
|
1921
1925
|
let { definition: t, store: n, analytics: r, storage: i, coordinator: a, log: o, refreshState: s, scheduledAt: c } = e;
|
|
1922
1926
|
if (s.inFlight) {
|
|
1923
1927
|
o.warn("aggregate: refresh overlap, skipping", { name: t.name });
|
|
@@ -1928,7 +1932,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1928
1932
|
try {
|
|
1929
1933
|
if (!await a.tryClaim(t.name, c)) {
|
|
1930
1934
|
l.info("refresh skipped — coordination claim lost");
|
|
1931
|
-
let { nextAt: e } =
|
|
1935
|
+
let { nextAt: e } = oc(t, /* @__PURE__ */ new Date()), n = i.get(t.name);
|
|
1932
1936
|
await i.updateMeta(t.name, {
|
|
1933
1937
|
...n.meta,
|
|
1934
1938
|
nextRefreshAt: e
|
|
@@ -1940,7 +1944,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1940
1944
|
analytics: r,
|
|
1941
1945
|
log: l,
|
|
1942
1946
|
id: t.name
|
|
1943
|
-
}), o =
|
|
1947
|
+
}), o = ac(t, e instanceof Promise ? await e : await P.runPromise(e));
|
|
1944
1948
|
if (!o.ok) throw Error(`output schema mismatch: ${o.reason}`);
|
|
1945
1949
|
let s = o.rows;
|
|
1946
1950
|
if (t.strategy === "merge") {
|
|
@@ -1966,7 +1970,7 @@ ${a.join("\n\n")}\n`);
|
|
|
1966
1970
|
droppedCount: a
|
|
1967
1971
|
}), s = Array.from(r.values());
|
|
1968
1972
|
}
|
|
1969
|
-
let d = Date.now() - u, { nextAt: f } =
|
|
1973
|
+
let d = Date.now() - u, { nextAt: f } = oc(t, /* @__PURE__ */ new Date()), p = {
|
|
1970
1974
|
refreshedAt: /* @__PURE__ */ new Date(),
|
|
1971
1975
|
rowCount: s.length,
|
|
1972
1976
|
durationMs: d,
|
|
@@ -1983,12 +1987,12 @@ ${a.join("\n\n")}\n`);
|
|
|
1983
1987
|
durationMs: d
|
|
1984
1988
|
});
|
|
1985
1989
|
} catch (e) {
|
|
1986
|
-
let n = e instanceof Error ? `${e.name}: ${e.message}` : String(e), r = i.get(t.name), { nextAt: a } =
|
|
1990
|
+
let n = e instanceof Error ? `${e.name}: ${e.message}` : String(e), r = i.get(t.name), { nextAt: a } = oc(t, /* @__PURE__ */ new Date());
|
|
1987
1991
|
await i.updateMeta(t.name, {
|
|
1988
1992
|
...r.meta,
|
|
1989
1993
|
lastError: n,
|
|
1990
1994
|
nextRefreshAt: a
|
|
1991
|
-
}), l.warn("refresh failed — last-good rows preserved", { err: n }),
|
|
1995
|
+
}), l.warn("refresh failed — last-good rows preserved", { err: n }), Ri({
|
|
1992
1996
|
error: e,
|
|
1993
1997
|
source: "aggregate",
|
|
1994
1998
|
name: t.name
|
|
@@ -1996,23 +2000,23 @@ ${a.join("\n\n")}\n`);
|
|
|
1996
2000
|
} finally {
|
|
1997
2001
|
s.inFlight = !1;
|
|
1998
2002
|
}
|
|
1999
|
-
},
|
|
2003
|
+
}, cc = (e) => {
|
|
2000
2004
|
let { definition: t, schedule: n } = e;
|
|
2001
2005
|
n.scheduleTimer !== null && clearTimeout(n.scheduleTimer);
|
|
2002
|
-
let r = /* @__PURE__ */ new Date(), { intervalMs: i, nextAt: a, kind: o } =
|
|
2006
|
+
let r = /* @__PURE__ */ new Date(), { intervalMs: i, nextAt: a, kind: o } = oc(t, r);
|
|
2003
2007
|
if (o === "none" && !t.refresh.onChange) {
|
|
2004
2008
|
e.log.warn("aggregate: no refresh policy that auto-fires", { name: t.name });
|
|
2005
2009
|
return;
|
|
2006
2010
|
}
|
|
2007
2011
|
if (a === null) return;
|
|
2008
2012
|
let s = Math.max(0, a.getTime() - r.getTime()), c = setTimeout(async () => {
|
|
2009
|
-
await
|
|
2013
|
+
await sc({
|
|
2010
2014
|
...e,
|
|
2011
2015
|
scheduledAt: a
|
|
2012
|
-
}),
|
|
2016
|
+
}), cc(e);
|
|
2013
2017
|
}, s);
|
|
2014
2018
|
c.unref(), n.scheduleTimer = c;
|
|
2015
|
-
},
|
|
2019
|
+
}, lc = (e) => {
|
|
2016
2020
|
let { definition: t, store: n, schedule: r, log: i } = e, a = t.refresh.onChange;
|
|
2017
2021
|
if (!a || a.length === 0) return;
|
|
2018
2022
|
let o = t.refresh.debounceMs ?? 3e4, s = new Set(a);
|
|
@@ -2020,7 +2024,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2020
2024
|
if (!s.has(t.table)) return;
|
|
2021
2025
|
r.debounceTimer !== null && clearTimeout(r.debounceTimer);
|
|
2022
2026
|
let n = setTimeout(async () => {
|
|
2023
|
-
r.debounceTimer = null, await
|
|
2027
|
+
r.debounceTimer = null, await sc({
|
|
2024
2028
|
...e,
|
|
2025
2029
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
2026
2030
|
});
|
|
@@ -2031,7 +2035,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2031
2035
|
tables: a,
|
|
2032
2036
|
debounceMs: o
|
|
2033
2037
|
});
|
|
2034
|
-
},
|
|
2038
|
+
}, uc = (e) => {
|
|
2035
2039
|
let { definition: t, store: n, storage: r, log: i, schedule: a } = e, o = t.incremental;
|
|
2036
2040
|
if (o === void 0) return;
|
|
2037
2041
|
let s = i.child(`aggregate:${t.name}`), c = new At({
|
|
@@ -2046,7 +2050,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2046
2050
|
skip: void 0,
|
|
2047
2051
|
projection: void 0
|
|
2048
2052
|
}), u = async () => {
|
|
2049
|
-
let e = c.materialize().map((e) => o.toRow(e)), n =
|
|
2053
|
+
let e = c.materialize().map((e) => o.toRow(e)), n = ac(t, e);
|
|
2050
2054
|
if (!n.ok) {
|
|
2051
2055
|
s.warn("incremental: output schema mismatch — keeping last-good", { reason: n.reason });
|
|
2052
2056
|
return;
|
|
@@ -2090,12 +2094,12 @@ ${a.join("\n\n")}\n`);
|
|
|
2090
2094
|
op: o.op
|
|
2091
2095
|
});
|
|
2092
2096
|
})();
|
|
2093
|
-
let p = t.refresh, m = p.interval === void 0 ? 5 * 6e4 :
|
|
2097
|
+
let p = t.refresh, m = p.interval === void 0 ? 5 * 6e4 : tc(p.interval), h = setInterval(() => {
|
|
2094
2098
|
d().catch(() => void 0);
|
|
2095
2099
|
}, m);
|
|
2096
2100
|
h.unref(), a.scheduleTimer = h;
|
|
2097
|
-
},
|
|
2098
|
-
let t = e.storage ??
|
|
2101
|
+
}, dc = async (e) => {
|
|
2102
|
+
let t = e.storage ?? Ks(), n = e.coordinator ?? Tr, r = e.analytics ?? B(), i = e.log;
|
|
2099
2103
|
await t.initialize();
|
|
2100
2104
|
let a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = {
|
|
2101
2105
|
refreshedAt: null,
|
|
@@ -2114,7 +2118,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2114
2118
|
detachOnChange: null
|
|
2115
2119
|
};
|
|
2116
2120
|
a.set(u.name, f), u.incremental !== void 0 || (u.bootRefresh === "async" ? (await t.updateMeta(u.name, c), setImmediate(async () => {
|
|
2117
|
-
await
|
|
2121
|
+
await sc({
|
|
2118
2122
|
definition: u,
|
|
2119
2123
|
store: e.store,
|
|
2120
2124
|
analytics: r,
|
|
@@ -2125,7 +2129,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2125
2129
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
2126
2130
|
});
|
|
2127
2131
|
})) : u.bootRefresh === "sync" ? l.push(async () => {
|
|
2128
|
-
await
|
|
2132
|
+
await sc({
|
|
2129
2133
|
definition: u,
|
|
2130
2134
|
store: e.store,
|
|
2131
2135
|
analytics: r,
|
|
@@ -2136,7 +2140,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2136
2140
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
2137
2141
|
});
|
|
2138
2142
|
}) : await t.load(u.name) === null && setImmediate(async () => {
|
|
2139
|
-
await
|
|
2143
|
+
await sc({
|
|
2140
2144
|
definition: u,
|
|
2141
2145
|
store: e.store,
|
|
2142
2146
|
analytics: r,
|
|
@@ -2146,7 +2150,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2146
2150
|
refreshState: d,
|
|
2147
2151
|
scheduledAt: /* @__PURE__ */ new Date()
|
|
2148
2152
|
});
|
|
2149
|
-
})), u.incremental === void 0 ? (
|
|
2153
|
+
})), u.incremental === void 0 ? (cc({
|
|
2150
2154
|
definition: u,
|
|
2151
2155
|
store: e.store,
|
|
2152
2156
|
analytics: r,
|
|
@@ -2155,7 +2159,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2155
2159
|
log: i,
|
|
2156
2160
|
schedule: f,
|
|
2157
2161
|
refreshState: d
|
|
2158
|
-
}),
|
|
2162
|
+
}), lc({
|
|
2159
2163
|
definition: u,
|
|
2160
2164
|
store: e.store,
|
|
2161
2165
|
analytics: r,
|
|
@@ -2164,7 +2168,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2164
2168
|
log: i,
|
|
2165
2169
|
schedule: f,
|
|
2166
2170
|
refreshState: d
|
|
2167
|
-
})) :
|
|
2171
|
+
})) : uc({
|
|
2168
2172
|
definition: u,
|
|
2169
2173
|
store: e.store,
|
|
2170
2174
|
storage: t,
|
|
@@ -2188,11 +2192,11 @@ ${a.join("\n\n")}\n`);
|
|
|
2188
2192
|
maxAgeMs: e.maxAgeMs
|
|
2189
2193
|
}));
|
|
2190
2194
|
}
|
|
2191
|
-
return
|
|
2195
|
+
return ic(rc(nc(n.rows, e?.where), e?.orderBy, e?.direction), e?.limit, e?.offset);
|
|
2192
2196
|
}),
|
|
2193
2197
|
meta: () => P.succeed(t.get(a.name).meta),
|
|
2194
2198
|
refresh: () => P.tryPromise({
|
|
2195
|
-
try: () =>
|
|
2199
|
+
try: () => sc({
|
|
2196
2200
|
definition: s.get(a.name),
|
|
2197
2201
|
store: e.store,
|
|
2198
2202
|
analytics: r,
|
|
@@ -2220,7 +2224,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2220
2224
|
})),
|
|
2221
2225
|
refreshByName: async (a) => {
|
|
2222
2226
|
let c = s.get(a);
|
|
2223
|
-
return c ? (await
|
|
2227
|
+
return c ? (await sc({
|
|
2224
2228
|
definition: c,
|
|
2225
2229
|
store: e.store,
|
|
2226
2230
|
analytics: r,
|
|
@@ -2242,7 +2246,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2242
2246
|
},
|
|
2243
2247
|
registered: Array.from(s.keys())
|
|
2244
2248
|
};
|
|
2245
|
-
},
|
|
2249
|
+
}, fc = {
|
|
2246
2250
|
getHandle: (e) => ({
|
|
2247
2251
|
read: () => P.fail(new jt({ name: e.name })),
|
|
2248
2252
|
meta: () => P.succeed({
|
|
@@ -2256,52 +2260,52 @@ ${a.join("\n\n")}\n`);
|
|
|
2256
2260
|
}),
|
|
2257
2261
|
snapshot: () => [],
|
|
2258
2262
|
refreshByName: async () => !1
|
|
2259
|
-
},
|
|
2263
|
+
}, pc = "/_voltro/inspect/aggregates", mc = /^\/_voltro\/inspect\/aggregates\/([^/]+)\/refresh$/, hc = (e, t, n) => ({
|
|
2260
2264
|
status: e,
|
|
2261
2265
|
contentType: "application/json; charset=utf-8",
|
|
2262
2266
|
body: JSON.stringify(t),
|
|
2263
2267
|
...n ? { headers: n } : {}
|
|
2264
|
-
}),
|
|
2268
|
+
}), gc = (e) => ({
|
|
2265
2269
|
refreshedAt: e.refreshedAt === null ? null : e.refreshedAt.toISOString(),
|
|
2266
2270
|
rowCount: e.rowCount,
|
|
2267
2271
|
durationMs: e.durationMs,
|
|
2268
2272
|
lastError: e.lastError,
|
|
2269
2273
|
nextRefreshAt: e.nextRefreshAt === null ? null : e.nextRefreshAt.toISOString()
|
|
2270
|
-
}),
|
|
2271
|
-
if (!e.startsWith(
|
|
2274
|
+
}), _c = async (e, t, n, r) => {
|
|
2275
|
+
if (!e.startsWith(pc)) return null;
|
|
2272
2276
|
if (t === "POST") {
|
|
2273
|
-
let t =
|
|
2277
|
+
let t = mc.exec(e);
|
|
2274
2278
|
if (t) {
|
|
2275
2279
|
let e = decodeURIComponent(t[1]);
|
|
2276
|
-
if (!await n.refreshByName(e)) return
|
|
2280
|
+
if (!await n.refreshByName(e)) return hc(404, {
|
|
2277
2281
|
error: "aggregate not found",
|
|
2278
2282
|
name: e
|
|
2279
2283
|
}, r);
|
|
2280
2284
|
let i = n.snapshot().find((t) => t.name === e);
|
|
2281
|
-
return
|
|
2285
|
+
return hc(200, {
|
|
2282
2286
|
ok: !0,
|
|
2283
2287
|
name: e,
|
|
2284
|
-
meta: i ?
|
|
2288
|
+
meta: i ? gc(i.meta) : null
|
|
2285
2289
|
}, r);
|
|
2286
2290
|
}
|
|
2287
|
-
return
|
|
2291
|
+
return hc(405, {
|
|
2288
2292
|
error: "method not allowed",
|
|
2289
2293
|
allow: "GET, POST <name>/refresh"
|
|
2290
2294
|
}, r);
|
|
2291
2295
|
}
|
|
2292
|
-
return t === "GET" && (e ===
|
|
2296
|
+
return t === "GET" && (e === pc || e.startsWith(`${pc}?`)) ? hc(200, {
|
|
2293
2297
|
aggregates: n.snapshot().map((e) => ({
|
|
2294
2298
|
name: e.name,
|
|
2295
|
-
meta:
|
|
2299
|
+
meta: gc(e.meta)
|
|
2296
2300
|
})),
|
|
2297
2301
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2298
2302
|
}, r) : null;
|
|
2299
|
-
},
|
|
2303
|
+
}, vc = "/_voltro/inspect/analytics", yc = (e, t, n) => ({
|
|
2300
2304
|
status: e,
|
|
2301
2305
|
contentType: "application/json; charset=utf-8",
|
|
2302
2306
|
body: JSON.stringify(t),
|
|
2303
2307
|
...n ? { headers: n } : {}
|
|
2304
|
-
}),
|
|
2308
|
+
}), bc = (e, t) => {
|
|
2305
2309
|
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, {
|
|
2306
2310
|
tag: e.tag,
|
|
2307
2311
|
count: e.count,
|
|
@@ -2314,9 +2318,9 @@ ${a.join("\n\n")}\n`);
|
|
|
2314
2318
|
errorCount: i,
|
|
2315
2319
|
tags: a
|
|
2316
2320
|
};
|
|
2317
|
-
},
|
|
2318
|
-
if (e !==
|
|
2319
|
-
if (t !== "GET") return
|
|
2321
|
+
}, xc = (e, t, n, r) => {
|
|
2322
|
+
if (e !== vc && !e.startsWith(`${vc}?`)) return null;
|
|
2323
|
+
if (t !== "GET") return yc(405, {
|
|
2320
2324
|
error: "method not allowed",
|
|
2321
2325
|
allow: "GET"
|
|
2322
2326
|
}, r);
|
|
@@ -2325,8 +2329,8 @@ ${a.join("\n\n")}\n`);
|
|
|
2325
2329
|
if (e === null) return 6e4;
|
|
2326
2330
|
let t = Number(e);
|
|
2327
2331
|
return Number.isFinite(t) && t > 0 ? Math.min(t, 1440 * 6e4) : 6e4;
|
|
2328
|
-
})(), s =
|
|
2329
|
-
return
|
|
2332
|
+
})(), s = bc(n.metricsCollector, o);
|
|
2333
|
+
return yc(200, {
|
|
2330
2334
|
provider: n.sink.info.provider,
|
|
2331
2335
|
capabilities: n.sink.info.capabilities,
|
|
2332
2336
|
detail: n.sink.info.detail ?? null,
|
|
@@ -2338,40 +2342,40 @@ ${a.join("\n\n")}\n`);
|
|
|
2338
2342
|
},
|
|
2339
2343
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2340
2344
|
}, r);
|
|
2341
|
-
},
|
|
2345
|
+
}, Sc = "/_voltro/inspect/timeline", Cc = "/_voltro/inspect/timeline/replay", wc = (e, t, n) => ({
|
|
2342
2346
|
status: e,
|
|
2343
2347
|
contentType: "application/json; charset=utf-8",
|
|
2344
2348
|
body: JSON.stringify(t),
|
|
2345
2349
|
...n ? { headers: n } : {}
|
|
2346
|
-
}),
|
|
2350
|
+
}), Tc = (e) => {
|
|
2347
2351
|
let t = e.indexOf("?");
|
|
2348
2352
|
return new URLSearchParams(t >= 0 ? e.slice(t + 1) : "");
|
|
2349
|
-
},
|
|
2353
|
+
}, Ec = (e, t) => {
|
|
2350
2354
|
let n = e.get(t);
|
|
2351
2355
|
if (n === null) return;
|
|
2352
2356
|
let r = Number(n);
|
|
2353
2357
|
return Number.isFinite(r) ? r : void 0;
|
|
2354
|
-
},
|
|
2355
|
-
if (!e.startsWith(
|
|
2356
|
-
if (t !== "GET") return
|
|
2358
|
+
}, Dc = async (e, t, n, r) => {
|
|
2359
|
+
if (!e.startsWith(Sc)) return null;
|
|
2360
|
+
if (t !== "GET") return wc(405, {
|
|
2357
2361
|
error: "method not allowed",
|
|
2358
2362
|
allow: "GET"
|
|
2359
2363
|
}, r);
|
|
2360
|
-
let i =
|
|
2361
|
-
if (e ===
|
|
2362
|
-
let e = i.get("table"), t =
|
|
2363
|
-
if (e === null || t === void 0) return
|
|
2364
|
+
let i = Tc(e);
|
|
2365
|
+
if (e === Cc || e.startsWith(`${Cc}?`)) {
|
|
2366
|
+
let e = i.get("table"), t = Ec(i, "seq");
|
|
2367
|
+
if (e === null || t === void 0) return wc(400, { error: "replay requires ?table=<name>&seq=<n>" }, r);
|
|
2364
2368
|
let a;
|
|
2365
2369
|
try {
|
|
2366
2370
|
a = await n.readCurrentRows(e);
|
|
2367
2371
|
} catch (t) {
|
|
2368
|
-
return
|
|
2372
|
+
return wc(404, {
|
|
2369
2373
|
error: "unknown or unreadable table",
|
|
2370
2374
|
table: e,
|
|
2371
2375
|
reason: String(t?.message ?? t)
|
|
2372
2376
|
}, r);
|
|
2373
2377
|
}
|
|
2374
|
-
return
|
|
2378
|
+
return wc(200, {
|
|
2375
2379
|
table: e,
|
|
2376
2380
|
asOfSeq: t,
|
|
2377
2381
|
currentSeq: n.recorder.currentSeq(),
|
|
@@ -2379,15 +2383,15 @@ ${a.join("\n\n")}\n`);
|
|
|
2379
2383
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2380
2384
|
}, r);
|
|
2381
2385
|
}
|
|
2382
|
-
if (e ===
|
|
2383
|
-
let e = i.get("table"), t = i.get("tenantId"), a =
|
|
2386
|
+
if (e === Sc || e.startsWith(`${Sc}?`)) {
|
|
2387
|
+
let e = i.get("table"), t = i.get("tenantId"), a = Ec(i, "from"), o = Ec(i, "to"), s = Ec(i, "limit"), c = {
|
|
2384
2388
|
...e === null ? {} : { table: e },
|
|
2385
2389
|
...t === null ? {} : { tenantId: t },
|
|
2386
2390
|
...a === void 0 ? {} : { from: a },
|
|
2387
2391
|
...o === void 0 ? {} : { to: o },
|
|
2388
2392
|
...s === void 0 ? {} : { limit: s }
|
|
2389
2393
|
};
|
|
2390
|
-
return
|
|
2394
|
+
return wc(200, {
|
|
2391
2395
|
enabled: n.recorder.enabled,
|
|
2392
2396
|
currentSeq: n.recorder.currentSeq(),
|
|
2393
2397
|
events: n.recorder.snapshot(c),
|
|
@@ -2395,7 +2399,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2395
2399
|
}, r);
|
|
2396
2400
|
}
|
|
2397
2401
|
return null;
|
|
2398
|
-
},
|
|
2402
|
+
}, Oc = /\.webhook\.tsx?$/, kc = async (e, t) => {
|
|
2399
2403
|
let n = [], r = [], i = [];
|
|
2400
2404
|
for (let a of e) {
|
|
2401
2405
|
let e;
|
|
@@ -2405,7 +2409,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2405
2409
|
t.warn("webhook: failed to import", { file: a }, e);
|
|
2406
2410
|
continue;
|
|
2407
2411
|
}
|
|
2408
|
-
let o = (e.default &&
|
|
2412
|
+
let o = (e.default && ja(e.default) ? e.default : void 0) ?? Object.values(e).find(ja);
|
|
2409
2413
|
if (!o) {
|
|
2410
2414
|
t.warn("webhook: no descriptor default-exported", { file: a });
|
|
2411
2415
|
continue;
|
|
@@ -2436,7 +2440,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2436
2440
|
incoming: r,
|
|
2437
2441
|
providers: i
|
|
2438
2442
|
};
|
|
2439
|
-
},
|
|
2443
|
+
}, Ac = /\.email\.tsx?$/, jc = async (e, t) => {
|
|
2440
2444
|
let n = [];
|
|
2441
2445
|
for (let r of e) {
|
|
2442
2446
|
let e;
|
|
@@ -2446,7 +2450,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2446
2450
|
t.warn("email: failed to import", { file: r }, e);
|
|
2447
2451
|
continue;
|
|
2448
2452
|
}
|
|
2449
|
-
let i = Object.values(e).filter(
|
|
2453
|
+
let i = Object.values(e).filter(Na);
|
|
2450
2454
|
if (i.length === 0) {
|
|
2451
2455
|
t.warn("email: no defineEmail export found", { file: r });
|
|
2452
2456
|
continue;
|
|
@@ -2457,15 +2461,15 @@ ${a.join("\n\n")}\n`);
|
|
|
2457
2461
|
});
|
|
2458
2462
|
}
|
|
2459
2463
|
return { templates: n };
|
|
2460
|
-
},
|
|
2461
|
-
let { descriptor: t, executor: n, file: r } = e, { send: i, messages: a } =
|
|
2464
|
+
}, Mc = (e) => P.map(e, (e) => ({ text: e })), Nc = (e) => {
|
|
2465
|
+
let { descriptor: t, executor: n, file: r } = e, { send: i, messages: a } = wa(t);
|
|
2462
2466
|
return [{
|
|
2463
2467
|
kind: "action",
|
|
2464
2468
|
file: r,
|
|
2465
2469
|
descriptor: i,
|
|
2466
2470
|
executor: (e, t) => {
|
|
2467
2471
|
let { threadId: r, order: i } = e, a = t.request?.subject?.tenantId ?? null;
|
|
2468
|
-
return
|
|
2472
|
+
return ni(n, t.store, {
|
|
2469
2473
|
threadId: r,
|
|
2470
2474
|
input: e,
|
|
2471
2475
|
tenantId: a,
|
|
@@ -2474,36 +2478,36 @@ ${a.join("\n\n")}\n`);
|
|
|
2474
2478
|
store: t.store,
|
|
2475
2479
|
request: t.request
|
|
2476
2480
|
}
|
|
2477
|
-
}).pipe(
|
|
2481
|
+
}).pipe(Mc);
|
|
2478
2482
|
}
|
|
2479
2483
|
}, {
|
|
2480
2484
|
kind: "query",
|
|
2481
2485
|
file: r,
|
|
2482
2486
|
descriptor: a,
|
|
2483
|
-
executor: (e, t) =>
|
|
2487
|
+
executor: (e, t) => ti(t.store, e.threadId)
|
|
2484
2488
|
}];
|
|
2485
|
-
},
|
|
2489
|
+
}, Pc = "<builtin:undo>", Fc = () => jr() ? {
|
|
2486
2490
|
queries: [{
|
|
2487
|
-
file:
|
|
2488
|
-
descriptor:
|
|
2489
|
-
executor: (e, t) =>
|
|
2491
|
+
file: Pc,
|
|
2492
|
+
descriptor: Ui,
|
|
2493
|
+
executor: (e, t) => Mr(e, t)
|
|
2490
2494
|
}],
|
|
2491
2495
|
mutations: [{
|
|
2492
|
-
file:
|
|
2493
|
-
descriptor:
|
|
2496
|
+
file: Pc,
|
|
2497
|
+
descriptor: Hi,
|
|
2494
2498
|
executor: (e, t) => Wt(e, t)
|
|
2495
2499
|
}, {
|
|
2496
|
-
file:
|
|
2497
|
-
descriptor:
|
|
2498
|
-
executor: (e, t) =>
|
|
2500
|
+
file: Pc,
|
|
2501
|
+
descriptor: Wi,
|
|
2502
|
+
executor: (e, t) => ur(e, t)
|
|
2499
2503
|
}]
|
|
2500
2504
|
} : {
|
|
2501
2505
|
queries: [],
|
|
2502
2506
|
mutations: []
|
|
2503
|
-
},
|
|
2507
|
+
}, Ic = () => jr() ? (e) => Qn(e) : (e) => ({
|
|
2504
2508
|
tx: e,
|
|
2505
2509
|
persist: async () => {}
|
|
2506
|
-
}),
|
|
2510
|
+
}), Lc = {
|
|
2507
2511
|
interceptMutation: "rpc:intercept:mutation",
|
|
2508
2512
|
interceptQuery: "rpc:intercept:query",
|
|
2509
2513
|
interceptAction: "rpc:intercept:action",
|
|
@@ -2513,12 +2517,12 @@ ${a.join("\n\n")}\n`);
|
|
|
2513
2517
|
onChangeEvent: "store:changes:read",
|
|
2514
2518
|
inspectEndpoints: "inspect:read",
|
|
2515
2519
|
dashboard: "dashboard:mount"
|
|
2516
|
-
},
|
|
2520
|
+
}, Rc = {
|
|
2517
2521
|
tables: "store:write",
|
|
2518
2522
|
migrations: "migration:run"
|
|
2519
|
-
},
|
|
2523
|
+
}, zc = (e) => {
|
|
2520
2524
|
let t = new Set(e.permissions ?? []), n = [];
|
|
2521
|
-
for (let [r, i] of Object.entries(
|
|
2525
|
+
for (let [r, i] of Object.entries(Lc)) {
|
|
2522
2526
|
let a = e[r];
|
|
2523
2527
|
a !== void 0 && (Array.isArray(a) && a.length === 0 || t.has(i) || n.push({
|
|
2524
2528
|
hook: r,
|
|
@@ -2533,26 +2537,26 @@ ${a.join("\n\n")}\n`);
|
|
|
2533
2537
|
return r.length > 0 && !t.has("inspect:write") && n.push({
|
|
2534
2538
|
hook: `inspectEndpoints (${r.map((e) => `${e.method} ${e.path}`).join(", ")})`,
|
|
2535
2539
|
required: "inspect:write"
|
|
2536
|
-
}), e.extendSchema !== void 0 && (e.extendSchema.tables && e.extendSchema.tables.length > 0 && (t.has(
|
|
2540
|
+
}), e.extendSchema !== void 0 && (e.extendSchema.tables && e.extendSchema.tables.length > 0 && (t.has(Rc.tables) || n.push({
|
|
2537
2541
|
hook: "extendSchema.tables",
|
|
2538
|
-
required:
|
|
2539
|
-
})), e.extendSchema.migrations && e.extendSchema.migrations.length > 0 && (t.has(
|
|
2542
|
+
required: Rc.tables
|
|
2543
|
+
})), e.extendSchema.migrations && e.extendSchema.migrations.length > 0 && (t.has(Rc.migrations) || n.push({
|
|
2540
2544
|
hook: "extendSchema.migrations",
|
|
2541
|
-
required:
|
|
2545
|
+
required: Rc.migrations
|
|
2542
2546
|
}))), {
|
|
2543
2547
|
pluginName: e.name,
|
|
2544
2548
|
missing: n
|
|
2545
2549
|
};
|
|
2546
|
-
},
|
|
2547
|
-
let t = e.map(
|
|
2550
|
+
}, Bc = (e) => {
|
|
2551
|
+
let t = e.map(zc);
|
|
2548
2552
|
return {
|
|
2549
2553
|
ok: t.every((e) => e.missing.length === 0),
|
|
2550
2554
|
reports: t
|
|
2551
2555
|
};
|
|
2552
|
-
},
|
|
2556
|
+
}, Vc = (e) => {
|
|
2553
2557
|
let t = e.reports.filter((e) => e.missing.length > 0);
|
|
2554
2558
|
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");
|
|
2555
|
-
},
|
|
2559
|
+
}, Hc = 5e3, Uc = 3e4, Wc = async (e, t) => {
|
|
2556
2560
|
let n, r = new Promise((e) => {
|
|
2557
2561
|
n = setTimeout(() => e({ kind: "timeout" }), t);
|
|
2558
2562
|
});
|
|
@@ -2567,7 +2571,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2567
2571
|
} finally {
|
|
2568
2572
|
n && clearTimeout(n);
|
|
2569
2573
|
}
|
|
2570
|
-
},
|
|
2574
|
+
}, Gc = async (e) => {
|
|
2571
2575
|
if (e !== void 0) {
|
|
2572
2576
|
if (typeof e == "object" && e && P.isEffect(e)) {
|
|
2573
2577
|
await P.runPromise(e);
|
|
@@ -2575,8 +2579,8 @@ ${a.join("\n\n")}\n`);
|
|
|
2575
2579
|
}
|
|
2576
2580
|
await Promise.resolve(e);
|
|
2577
2581
|
}
|
|
2578
|
-
},
|
|
2579
|
-
let t = e.deactivateTimeoutMs ??
|
|
2582
|
+
}, Kc = /* @__PURE__ */ new Set(), qc = (e) => `${e.name}@${e.version ?? "*"}`, Jc = (e) => {
|
|
2583
|
+
let t = e.deactivateTimeoutMs ?? Hc, n = e.deactivateTotalBudgetMs ?? Uc, r = /* @__PURE__ */ new Set(), i = !1, a = /* @__PURE__ */ new Map();
|
|
2580
2584
|
for (let t of e.plugins) {
|
|
2581
2585
|
if (!t.configSchema) {
|
|
2582
2586
|
a.set(t.name, e.pluginConfigs?.[t.name]);
|
|
@@ -2602,14 +2606,14 @@ ${a.join("\n\n")}\n`);
|
|
|
2602
2606
|
});
|
|
2603
2607
|
return {
|
|
2604
2608
|
async activate() {
|
|
2605
|
-
let t =
|
|
2609
|
+
let t = Bc(e.plugins);
|
|
2606
2610
|
if (!t.ok) {
|
|
2607
|
-
let n =
|
|
2611
|
+
let n = Vc(t);
|
|
2608
2612
|
throw e.log.error(n), Error(n);
|
|
2609
2613
|
}
|
|
2610
2614
|
let n = (process.env.VOLTRO_STRICT_PLUGIN_COMPAT ?? "").toLowerCase(), i = n === "1" || n === "true";
|
|
2611
2615
|
for (let t of e.plugins) {
|
|
2612
|
-
let n =
|
|
2616
|
+
let n = Oi(t.name, t.framework, e.voltroVersion);
|
|
2613
2617
|
if (!n.ok) {
|
|
2614
2618
|
if (i) {
|
|
2615
2619
|
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.`;
|
|
@@ -2619,10 +2623,10 @@ ${a.join("\n\n")}\n`);
|
|
|
2619
2623
|
}
|
|
2620
2624
|
}
|
|
2621
2625
|
for (let t of e.plugins) {
|
|
2622
|
-
let n =
|
|
2623
|
-
if (!
|
|
2626
|
+
let n = qc(t);
|
|
2627
|
+
if (!Kc.has(n) && typeof t.onInstall == "function") try {
|
|
2624
2628
|
let e = o(t);
|
|
2625
|
-
await Promise.resolve().then(() =>
|
|
2629
|
+
await Promise.resolve().then(() => Gc(t.onInstall(e))), Kc.add(n);
|
|
2626
2630
|
} catch (n) {
|
|
2627
2631
|
throw e.log.error("plugin onInstall threw — aborting boot", {
|
|
2628
2632
|
plugin: t.name,
|
|
@@ -2636,7 +2640,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2636
2640
|
}
|
|
2637
2641
|
try {
|
|
2638
2642
|
let e = o(t);
|
|
2639
|
-
await Promise.resolve().then(() =>
|
|
2643
|
+
await Promise.resolve().then(() => Gc(t.onActivate(e))), r.add(t.name);
|
|
2640
2644
|
} catch (n) {
|
|
2641
2645
|
throw e.log.error("plugin onActivate threw — aborting boot", {
|
|
2642
2646
|
plugin: t.name,
|
|
@@ -2659,7 +2663,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2659
2663
|
});
|
|
2660
2664
|
break;
|
|
2661
2665
|
}
|
|
2662
|
-
let c = o(i), l = i.onDeactivate, u = await
|
|
2666
|
+
let c = o(i), l = i.onDeactivate, u = await Wc(Promise.resolve().then(() => Gc(l(c))), t);
|
|
2663
2667
|
u.kind === "rejected" ? e.log.warn("plugin onDeactivate threw", {
|
|
2664
2668
|
plugin: i.name,
|
|
2665
2669
|
err: u.err
|
|
@@ -2736,16 +2740,16 @@ ${a.join("\n\n")}\n`);
|
|
|
2736
2740
|
services: e.services !== void 0,
|
|
2737
2741
|
hasConfigSchema: e.configSchema !== void 0,
|
|
2738
2742
|
activated: r.has(e.name),
|
|
2739
|
-
installed:
|
|
2743
|
+
installed: Kc.has(qc(e))
|
|
2740
2744
|
}));
|
|
2741
2745
|
}
|
|
2742
2746
|
};
|
|
2743
|
-
},
|
|
2747
|
+
}, Yc = {
|
|
2744
2748
|
mutation: "intercept-mutation",
|
|
2745
2749
|
query: "intercept-query",
|
|
2746
2750
|
action: "intercept-action"
|
|
2747
|
-
},
|
|
2748
|
-
let i =
|
|
2751
|
+
}, Xc = (e, t, n, r) => {
|
|
2752
|
+
let i = Yc[t], a = `plugin.${e}.${i}`, o = a;
|
|
2749
2753
|
return (t, s) => P.suspend(() => {
|
|
2750
2754
|
let c = Date.now();
|
|
2751
2755
|
return n(t, s).pipe(P.withSpan(a, { attributes: {
|
|
@@ -2769,17 +2773,17 @@ ${a.join("\n\n")}\n`);
|
|
|
2769
2773
|
});
|
|
2770
2774
|
})));
|
|
2771
2775
|
});
|
|
2772
|
-
},
|
|
2776
|
+
}, Zc = (e, t, n) => {
|
|
2773
2777
|
let r = t === "mutation" ? "interceptMutation" : t === "query" ? "interceptQuery" : "interceptAction", i = [];
|
|
2774
2778
|
for (let a of e) {
|
|
2775
2779
|
let e = a[r];
|
|
2776
|
-
typeof e == "function" && i.push(
|
|
2780
|
+
typeof e == "function" && i.push(Xc(a.name, t, e, n));
|
|
2777
2781
|
}
|
|
2778
2782
|
return i;
|
|
2779
|
-
},
|
|
2783
|
+
}, Qc = `${T}/plugins/`, $c = (e) => e.startsWith("/") ? e : `/${e}`, el = (e) => {
|
|
2780
2784
|
let t = e.indexOf("?");
|
|
2781
2785
|
return t >= 0 ? e.slice(0, t) : e;
|
|
2782
|
-
},
|
|
2786
|
+
}, tl = (e, t) => e.kind === "json" ? {
|
|
2783
2787
|
status: e.status ?? 200,
|
|
2784
2788
|
contentType: "application/json; charset=utf-8",
|
|
2785
2789
|
body: JSON.stringify(e.data),
|
|
@@ -2789,12 +2793,12 @@ ${a.join("\n\n")}\n`);
|
|
|
2789
2793
|
contentType: e.contentType ?? "text/plain; charset=utf-8",
|
|
2790
2794
|
body: e.body,
|
|
2791
2795
|
headers: t
|
|
2792
|
-
},
|
|
2796
|
+
}, nl = (e) => {
|
|
2793
2797
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
2794
2798
|
for (let r of e) {
|
|
2795
2799
|
let e = r.inspectEndpoints ?? [], i = S(r.name);
|
|
2796
2800
|
for (let a of e) {
|
|
2797
|
-
let e = `${
|
|
2801
|
+
let e = `${Qc}${i}${$c(a.path)}`, o = `${a.method} ${e}`, s = t.get(o);
|
|
2798
2802
|
if (s !== void 0) throw Error(`plugin inspect endpoint collision: "${a.method} ${e}" declared by plugin "${r.name}" but already claimed by ${s}`);
|
|
2799
2803
|
t.set(o, `plugin "${r.name}"`), n.push({
|
|
2800
2804
|
method: a.method,
|
|
@@ -2808,8 +2812,8 @@ ${a.join("\n\n")}\n`);
|
|
|
2808
2812
|
return {
|
|
2809
2813
|
endpoints: n,
|
|
2810
2814
|
async dispatch(e, t, r, i, a) {
|
|
2811
|
-
let o =
|
|
2812
|
-
if (!o.startsWith(
|
|
2815
|
+
let o = el(e);
|
|
2816
|
+
if (!o.startsWith(Qc)) return null;
|
|
2813
2817
|
let s = E(r.origin ?? r.Origin), c = t.toUpperCase();
|
|
2814
2818
|
if (c === "OPTIONS") return {
|
|
2815
2819
|
status: 204,
|
|
@@ -2836,7 +2840,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2836
2840
|
let u = n.find((e) => e.method === c && e.path === o);
|
|
2837
2841
|
if (!u) return null;
|
|
2838
2842
|
try {
|
|
2839
|
-
return
|
|
2843
|
+
return tl(await P.runPromise(u.handler({
|
|
2840
2844
|
method: c,
|
|
2841
2845
|
url: e,
|
|
2842
2846
|
headers: r,
|
|
@@ -2856,7 +2860,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2856
2860
|
}
|
|
2857
2861
|
}
|
|
2858
2862
|
};
|
|
2859
|
-
},
|
|
2863
|
+
}, rl = (e, t, n) => {
|
|
2860
2864
|
let r = `plugin.${e}.schedule-fire`;
|
|
2861
2865
|
return async (i, a) => {
|
|
2862
2866
|
let o = Date.now();
|
|
@@ -2884,9 +2888,9 @@ ${a.join("\n\n")}\n`);
|
|
|
2884
2888
|
}), e;
|
|
2885
2889
|
}
|
|
2886
2890
|
};
|
|
2887
|
-
},
|
|
2891
|
+
}, il = (e, t) => {
|
|
2888
2892
|
let n = [];
|
|
2889
|
-
for (let r of e) typeof r.onScheduleFire == "function" && n.push(
|
|
2893
|
+
for (let r of e) typeof r.onScheduleFire == "function" && n.push(rl(r.name, r.onScheduleFire, t));
|
|
2890
2894
|
if (n.length !== 0) return async (e, t) => {
|
|
2891
2895
|
let r = e;
|
|
2892
2896
|
for (let e = n.length - 1; e >= 0; e--) {
|
|
@@ -2895,7 +2899,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2895
2899
|
}
|
|
2896
2900
|
return r();
|
|
2897
2901
|
};
|
|
2898
|
-
},
|
|
2902
|
+
}, al = (e, t, n) => ((r, i) => {
|
|
2899
2903
|
let a = `plugin.${e}.workflow-step`, o = a, s = Date.now();
|
|
2900
2904
|
return t(r, i).pipe(P.withSpan(a, { attributes: {
|
|
2901
2905
|
"plugin.name": e,
|
|
@@ -2918,16 +2922,16 @@ ${a.join("\n\n")}\n`);
|
|
|
2918
2922
|
status: "error"
|
|
2919
2923
|
});
|
|
2920
2924
|
})));
|
|
2921
|
-
}),
|
|
2925
|
+
}), ol = (e, t) => {
|
|
2922
2926
|
let n = [];
|
|
2923
|
-
for (let r of e) typeof r.onWorkflowStep == "function" && n.push(
|
|
2924
|
-
return n.length === 0 ? F.succeed(
|
|
2925
|
-
},
|
|
2927
|
+
for (let r of e) typeof r.onWorkflowStep == "function" && n.push(al(r.name, r.onWorkflowStep, t));
|
|
2928
|
+
return n.length === 0 ? F.succeed(Br, { interceptor: ((e) => e) }) : F.succeed(Br, { interceptor: ((e, t) => n.reduceRight((e, n) => n(e, t), e)) });
|
|
2929
|
+
}, sl = (e) => {
|
|
2926
2930
|
if (!e) return;
|
|
2927
2931
|
let t = e.workflowName ?? e.tag, n = [];
|
|
2928
|
-
if (t !== void 0 && n.push(H("tag", t)), e.status !== void 0 && n.push(H("status", e.status)), n.length !== 0) return n.length === 1 ? n[0] :
|
|
2929
|
-
},
|
|
2930
|
-
let n = Math.max(0, t?.offset ?? 0), r = Math.max(1, Math.min(500, t?.limit ?? 50)), i =
|
|
2932
|
+
if (t !== void 0 && n.push(H("tag", t)), e.status !== void 0 && n.push(H("status", e.status)), n.length !== 0) return n.length === 1 ? n[0] : ai(...n);
|
|
2933
|
+
}, cl = async (e, t) => {
|
|
2934
|
+
let n = Math.max(0, t?.offset ?? 0), r = Math.max(1, Math.min(500, t?.limit ?? 50)), i = sl(t);
|
|
2931
2935
|
return {
|
|
2932
2936
|
rows: await e.query({
|
|
2933
2937
|
table: "_voltro_workflow_runs",
|
|
@@ -2951,7 +2955,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2951
2955
|
offset: n,
|
|
2952
2956
|
limit: r
|
|
2953
2957
|
};
|
|
2954
|
-
},
|
|
2958
|
+
}, ll = (e) => ({
|
|
2955
2959
|
id: e.id,
|
|
2956
2960
|
workflowName: e.tag,
|
|
2957
2961
|
executionId: e.executionId,
|
|
@@ -2966,10 +2970,10 @@ ${a.join("\n\n")}\n`);
|
|
|
2966
2970
|
durationMs: e.durationMs,
|
|
2967
2971
|
traceId: e.traceId,
|
|
2968
2972
|
parentExecutionId: e.parentExecutionId
|
|
2969
|
-
}),
|
|
2970
|
-
let { rows: n } = await
|
|
2971
|
-
return n.map(
|
|
2972
|
-
},
|
|
2973
|
+
}), ul = async (e, t) => {
|
|
2974
|
+
let { rows: n } = await cl(e, t);
|
|
2975
|
+
return n.map(ll);
|
|
2976
|
+
}, dl = async (e, t, n) => {
|
|
2973
2977
|
let r = (await e.store.query({
|
|
2974
2978
|
table: "_voltro_workflow_runs",
|
|
2975
2979
|
order: [],
|
|
@@ -2983,7 +2987,7 @@ ${a.join("\n\n")}\n`);
|
|
|
2983
2987
|
if (!i) throw Error(`retry: no workflow registered with tag '${r.tag}'`);
|
|
2984
2988
|
let a = n?.payloadOverride === void 0 ? r.payload : n.payloadOverride, o = await e.runPromise(i.definition.execute(a));
|
|
2985
2989
|
return { executionId: typeof o == "string" ? o : "started" };
|
|
2986
|
-
},
|
|
2990
|
+
}, fl = (e, t) => {
|
|
2987
2991
|
let n = e.filter((e) => typeof e.onHttpRequest == "function");
|
|
2988
2992
|
if (n.length !== 0) return n.reduceRight((e, n) => {
|
|
2989
2993
|
let r = n.onHttpRequest, i = `plugin.${n.name}.http-intercept`;
|
|
@@ -3004,7 +3008,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3004
3008
|
}
|
|
3005
3009
|
};
|
|
3006
3010
|
}, (e) => e());
|
|
3007
|
-
},
|
|
3011
|
+
}, pl = (e) => {
|
|
3008
3012
|
let t = [];
|
|
3009
3013
|
for (let n of e) {
|
|
3010
3014
|
let e = n.dashboard ?? [];
|
|
@@ -3028,7 +3032,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3028
3032
|
}
|
|
3029
3033
|
}
|
|
3030
3034
|
return t;
|
|
3031
|
-
},
|
|
3035
|
+
}, ml = /\.(query|mutation|action|stream)\.ts$/, hl = /\.(query|mutation|action|stream)\.server\.ts$/, gl = /* @__PURE__ */ new Set([
|
|
3032
3036
|
"node_modules",
|
|
3033
3037
|
"dist",
|
|
3034
3038
|
"build",
|
|
@@ -3036,7 +3040,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3036
3040
|
".vite",
|
|
3037
3041
|
".next",
|
|
3038
3042
|
".git"
|
|
3039
|
-
]),
|
|
3043
|
+
]), _l = async (e) => {
|
|
3040
3044
|
let t = [], n = async (e) => {
|
|
3041
3045
|
let r;
|
|
3042
3046
|
try {
|
|
@@ -3045,14 +3049,14 @@ ${a.join("\n\n")}\n`);
|
|
|
3045
3049
|
return;
|
|
3046
3050
|
}
|
|
3047
3051
|
for (let i of r) {
|
|
3048
|
-
if (
|
|
3052
|
+
if (gl.has(i.name)) continue;
|
|
3049
3053
|
let r = A(e, i.name);
|
|
3050
|
-
i.isDirectory() ? await n(r) : i.isFile() && (
|
|
3054
|
+
i.isDirectory() ? await n(r) : i.isFile() && (ml.test(i.name) && !hl.test(i.name) || w.test(i.name)) && t.push(r);
|
|
3051
3055
|
}
|
|
3052
3056
|
};
|
|
3053
3057
|
return await n(e), t;
|
|
3054
|
-
},
|
|
3055
|
-
let t = await
|
|
3058
|
+
}, vl = async (e) => {
|
|
3059
|
+
let t = await _l(e), n = [];
|
|
3056
3060
|
for (let e of t) try {
|
|
3057
3061
|
let t = await import(lt(e).href);
|
|
3058
3062
|
for (let r of Object.values(t)) {
|
|
@@ -3077,10 +3081,10 @@ ${a.join("\n\n")}\n`);
|
|
|
3077
3081
|
let t = `${e.kind}:${e.tag}`;
|
|
3078
3082
|
return r.has(t) ? !1 : (r.add(t), !0);
|
|
3079
3083
|
});
|
|
3080
|
-
},
|
|
3084
|
+
}, yl = async (e, t, n) => {
|
|
3081
3085
|
let r = e.filter((e) => typeof e.codegen == "function");
|
|
3082
3086
|
if (r.length === 0) return [];
|
|
3083
|
-
let i = await
|
|
3087
|
+
let i = await vl(n);
|
|
3084
3088
|
return r.map((e) => {
|
|
3085
3089
|
let n = Ce(e.name), r = {
|
|
3086
3090
|
pluginName: e.name,
|
|
@@ -3094,8 +3098,8 @@ ${a.join("\n\n")}\n`);
|
|
|
3094
3098
|
emit: () => e.codegen(r)
|
|
3095
3099
|
};
|
|
3096
3100
|
});
|
|
3097
|
-
},
|
|
3098
|
-
pluginContributions: await
|
|
3101
|
+
}, bl = async (e, t, n) => ({
|
|
3102
|
+
pluginContributions: await yl(e, t, n),
|
|
3099
3103
|
pluginErrorImports: e.flatMap((e) => (e.errorSchemas ?? []).map((e) => e.import)),
|
|
3100
3104
|
pluginRpcImports: e.flatMap((e) => (e.rpcClientDescriptors ?? []).map((e) => ({
|
|
3101
3105
|
tag: e.tag,
|
|
@@ -3103,19 +3107,19 @@ ${a.join("\n\n")}\n`);
|
|
|
3103
3107
|
module: e.import.module,
|
|
3104
3108
|
name: e.import.name
|
|
3105
3109
|
})))
|
|
3106
|
-
}),
|
|
3110
|
+
}), xl = class extends Error {
|
|
3107
3111
|
constructor(e) {
|
|
3108
3112
|
super(e), this.name = "InspectQueryError";
|
|
3109
3113
|
}
|
|
3110
|
-
},
|
|
3114
|
+
}, Sl = /* @__PURE__ */ new Set([
|
|
3111
3115
|
"text",
|
|
3112
3116
|
"id",
|
|
3113
3117
|
"reference"
|
|
3114
|
-
]),
|
|
3118
|
+
]), Cl = /* @__PURE__ */ new Set([
|
|
3115
3119
|
"integer",
|
|
3116
3120
|
"timestamp",
|
|
3117
3121
|
"date"
|
|
3118
|
-
]),
|
|
3122
|
+
]), wl = (e, t) => {
|
|
3119
3123
|
switch (e) {
|
|
3120
3124
|
case "isNull":
|
|
3121
3125
|
case "isNotNull":
|
|
@@ -3123,54 +3127,54 @@ ${a.join("\n\n")}\n`);
|
|
|
3123
3127
|
case "neq":
|
|
3124
3128
|
case "in":
|
|
3125
3129
|
case "notIn": return !0;
|
|
3126
|
-
case "contains": return
|
|
3130
|
+
case "contains": return Sl.has(t);
|
|
3127
3131
|
case "gt":
|
|
3128
3132
|
case "gte":
|
|
3129
3133
|
case "lt":
|
|
3130
|
-
case "lte": return
|
|
3134
|
+
case "lte": return Cl.has(t);
|
|
3131
3135
|
}
|
|
3132
|
-
},
|
|
3136
|
+
}, Tl = (e, t, n) => {
|
|
3133
3137
|
if (e == null) return e;
|
|
3134
3138
|
switch (t) {
|
|
3135
3139
|
case "integer": {
|
|
3136
3140
|
let t = typeof e == "number" ? e : Number(e);
|
|
3137
|
-
if (!Number.isFinite(t)) throw new
|
|
3141
|
+
if (!Number.isFinite(t)) throw new xl(`filter on "${n}": "${String(e)}" is not a number`);
|
|
3138
3142
|
return t;
|
|
3139
3143
|
}
|
|
3140
3144
|
case "boolean":
|
|
3141
3145
|
if (typeof e == "boolean") return e;
|
|
3142
3146
|
if (e === "true") return !0;
|
|
3143
3147
|
if (e === "false") return !1;
|
|
3144
|
-
throw new
|
|
3148
|
+
throw new xl(`filter on "${n}": "${String(e)}" is not a boolean`);
|
|
3145
3149
|
default: return e;
|
|
3146
3150
|
}
|
|
3147
|
-
},
|
|
3151
|
+
}, El = (e, t) => {
|
|
3148
3152
|
let n = t.get(e.column);
|
|
3149
|
-
if (!n) throw new
|
|
3150
|
-
if (!
|
|
3153
|
+
if (!n) throw new xl(`unknown filter column "${e.column}"`);
|
|
3154
|
+
if (!wl(e.op, n.type)) throw new xl(`operator "${e.op}" is not valid for ${n.type} column "${e.column}"`);
|
|
3151
3155
|
if (e.op === "isNull" || e.op === "isNotNull") return {
|
|
3152
3156
|
column: e.column,
|
|
3153
3157
|
op: e.op
|
|
3154
3158
|
};
|
|
3155
3159
|
if (e.op === "in" || e.op === "notIn") {
|
|
3156
|
-
if (!Array.isArray(e.value)) throw new
|
|
3160
|
+
if (!Array.isArray(e.value)) throw new xl(`operator "${e.op}" on "${e.column}" requires an array value`);
|
|
3157
3161
|
return {
|
|
3158
3162
|
column: e.column,
|
|
3159
3163
|
op: e.op,
|
|
3160
|
-
value: e.value.map((t) =>
|
|
3164
|
+
value: e.value.map((t) => Tl(t, n.type, e.column))
|
|
3161
3165
|
};
|
|
3162
3166
|
}
|
|
3163
3167
|
return {
|
|
3164
3168
|
column: e.column,
|
|
3165
3169
|
op: e.op,
|
|
3166
|
-
value:
|
|
3170
|
+
value: Tl(e.value, n.type, e.column)
|
|
3167
3171
|
};
|
|
3168
|
-
},
|
|
3169
|
-
if (++n.n >
|
|
3170
|
-
if (e.kind === "leaf") return
|
|
3171
|
-
let r = e.children.map((e) =>
|
|
3172
|
+
}, Dl = 200, Ol = (e, t, n) => {
|
|
3173
|
+
if (++n.n > Dl) throw new xl("filter tree too large");
|
|
3174
|
+
if (e.kind === "leaf") return El(e, t);
|
|
3175
|
+
let r = e.children.map((e) => Ol(e, t, n));
|
|
3172
3176
|
return e.kind === "and" ? { and: r } : { or: r };
|
|
3173
|
-
},
|
|
3177
|
+
}, kl = (e, t) => {
|
|
3174
3178
|
let n = e?.trim();
|
|
3175
3179
|
if (!n) return null;
|
|
3176
3180
|
let r = t.filter((e) => e.type === "text" || (e.oneOf?.length ?? 0) > 0);
|
|
@@ -3179,16 +3183,16 @@ ${a.join("\n\n")}\n`);
|
|
|
3179
3183
|
op: "contains",
|
|
3180
3184
|
value: n
|
|
3181
3185
|
})) };
|
|
3182
|
-
},
|
|
3186
|
+
}, Al = (e) => {
|
|
3183
3187
|
let t = new Map(e.columns.map((e) => [e.name, e])), n = [];
|
|
3184
|
-
e.filter && n.push(
|
|
3185
|
-
let r =
|
|
3188
|
+
e.filter && n.push(Ol(e.filter, t, { n: 0 }));
|
|
3189
|
+
let r = kl(e.quickSearch, e.columns);
|
|
3186
3190
|
if (r && n.push(r), n.length !== 0) return n.length === 1 ? n[0] : { and: n };
|
|
3187
|
-
},
|
|
3191
|
+
}, jl = (e, t) => {
|
|
3188
3192
|
let n = new Set(t.map((e) => e.name)), r = [], i = /* @__PURE__ */ new Set();
|
|
3189
3193
|
for (let t of e ?? []) {
|
|
3190
|
-
if (!n.has(t.column)) throw new
|
|
3191
|
-
if (t.direction !== "asc" && t.direction !== "desc") throw new
|
|
3194
|
+
if (!n.has(t.column)) throw new xl(`unknown sort column "${t.column}"`);
|
|
3195
|
+
if (t.direction !== "asc" && t.direction !== "desc") throw new xl(`invalid sort direction "${t.direction}"`);
|
|
3192
3196
|
i.has(t.column) || (i.add(t.column), r.push({
|
|
3193
3197
|
column: t.column,
|
|
3194
3198
|
direction: t.direction
|
|
@@ -3198,16 +3202,16 @@ ${a.join("\n\n")}\n`);
|
|
|
3198
3202
|
column: "id",
|
|
3199
3203
|
direction: "asc"
|
|
3200
3204
|
}), r;
|
|
3201
|
-
},
|
|
3205
|
+
}, Ml = 150, Nl = 200, Pl = (e) => e instanceof Date ? e.toISOString() : typeof e == "bigint" ? e.toString() : e, Fl = (e) => {
|
|
3202
3206
|
if (!e) return null;
|
|
3203
3207
|
let t = {};
|
|
3204
|
-
for (let [n, r] of Object.entries(e)) t[n] =
|
|
3208
|
+
for (let [n, r] of Object.entries(e)) t[n] = Pl(r);
|
|
3205
3209
|
return t;
|
|
3206
|
-
},
|
|
3210
|
+
}, Il = (e, t) => {
|
|
3207
3211
|
let n = /* @__PURE__ */ new Map(), r, i = () => {
|
|
3208
3212
|
r = void 0;
|
|
3209
3213
|
for (let [e, r] of n) {
|
|
3210
|
-
if (r.size >
|
|
3214
|
+
if (r.size > Nl) {
|
|
3211
3215
|
t.emit("cdc", {
|
|
3212
3216
|
op: "resync",
|
|
3213
3217
|
table: e
|
|
@@ -3229,17 +3233,17 @@ ${a.join("\n\n")}\n`);
|
|
|
3229
3233
|
let o = n.get(e.table);
|
|
3230
3234
|
o || (o = /* @__PURE__ */ new Map(), n.set(e.table, o)), o.set(a, {
|
|
3231
3235
|
op: e.op,
|
|
3232
|
-
row: e.op === "delete" ? null :
|
|
3233
|
-
}), r === void 0 && (r = setTimeout(i,
|
|
3236
|
+
row: e.op === "delete" ? null : Fl(t)
|
|
3237
|
+
}), r === void 0 && (r = setTimeout(i, Ml));
|
|
3234
3238
|
});
|
|
3235
3239
|
return () => {
|
|
3236
3240
|
r !== void 0 && clearTimeout(r), a();
|
|
3237
3241
|
};
|
|
3238
|
-
},
|
|
3242
|
+
}, Ll = [
|
|
3239
3243
|
"ok",
|
|
3240
3244
|
"error",
|
|
3241
3245
|
"unset"
|
|
3242
|
-
],
|
|
3246
|
+
], Rl = (e, t) => {
|
|
3243
3247
|
let n = e.indexOf("?"), r = n === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(n + 1)), i = (() => {
|
|
3244
3248
|
let e = r.get("since");
|
|
3245
3249
|
if (e === null) return;
|
|
@@ -3260,9 +3264,9 @@ ${a.join("\n\n")}\n`);
|
|
|
3260
3264
|
Number.isFinite(t) && (e.minDurationMs = t);
|
|
3261
3265
|
}
|
|
3262
3266
|
let s = r.get("status");
|
|
3263
|
-
s !== null &&
|
|
3267
|
+
s !== null && Ll.includes(s) && (e.status = s);
|
|
3264
3268
|
let c = t.query(e);
|
|
3265
|
-
return
|
|
3269
|
+
return zl({
|
|
3266
3270
|
capturedAt: Date.now(),
|
|
3267
3271
|
bufferCapacity: t.capacityHint(),
|
|
3268
3272
|
bufferSize: t.size(),
|
|
@@ -3274,22 +3278,22 @@ ${a.join("\n\n")}\n`);
|
|
|
3274
3278
|
let s = {};
|
|
3275
3279
|
i !== void 0 && (s.since = i), a !== void 0 && (s.maxTraces = a), r.get("onlyErrors") === "1" && (s.onlyErrors = !0);
|
|
3276
3280
|
let c = t.queryGrouped(s);
|
|
3277
|
-
return
|
|
3281
|
+
return zl({
|
|
3278
3282
|
capturedAt: Date.now(),
|
|
3279
3283
|
bufferCapacity: t.capacityHint(),
|
|
3280
3284
|
bufferSize: t.size(),
|
|
3281
3285
|
returned: c.length,
|
|
3282
3286
|
traces: c
|
|
3283
3287
|
});
|
|
3284
|
-
},
|
|
3288
|
+
}, zl = (e) => ({
|
|
3285
3289
|
status: 200,
|
|
3286
3290
|
contentType: "application/json; charset=utf-8",
|
|
3287
3291
|
body: JSON.stringify(e)
|
|
3288
|
-
}),
|
|
3292
|
+
}), Bl = (e) => {
|
|
3289
3293
|
let t = e.now ?? Date.now, n = {
|
|
3290
3294
|
phase: "booting",
|
|
3291
3295
|
startedAt: t()
|
|
3292
|
-
}, r =
|
|
3296
|
+
}, r = La((e, r) => {
|
|
3293
3297
|
let i = (e.url ?? "/").split("?")[0], a = n.phase === "ready";
|
|
3294
3298
|
if (i === "/internal/liveness") {
|
|
3295
3299
|
r.writeHead(200, {
|
|
@@ -3344,31 +3348,31 @@ ${a.join("\n\n")}\n`);
|
|
|
3344
3348
|
e.log?.info("dev health server listening", { port: a }), t(i(a));
|
|
3345
3349
|
});
|
|
3346
3350
|
});
|
|
3347
|
-
},
|
|
3351
|
+
}, Vl = () => {
|
|
3348
3352
|
let e = globalThis.crypto?.randomUUID?.();
|
|
3349
3353
|
return e === void 0 ? `${Date.now().toString(16)}${Math.random().toString(16).slice(2)}`.padEnd(32, "0").slice(0, 32) : e.replace(/-/g, "");
|
|
3350
|
-
}, $ = xt({ scope: "voltro:dev" }),
|
|
3354
|
+
}, $ = xt({ scope: "voltro:dev" }), Hl = await (async () => {
|
|
3351
3355
|
try {
|
|
3352
3356
|
let e = A(k(N(import.meta.url)), "..", "package.json"), t = await R.readFile(e, "utf8");
|
|
3353
3357
|
return JSON.parse(t).version ?? "0.0.0";
|
|
3354
3358
|
} catch {
|
|
3355
3359
|
return "0.0.0";
|
|
3356
3360
|
}
|
|
3357
|
-
})(),
|
|
3361
|
+
})(), Ul = process.env.TENANT ?? "acme", Wl = process.env.VOLTRO_SESSION_COOKIE ?? "voltro:session", Gl = {
|
|
3358
3362
|
id: "voltro-password",
|
|
3359
3363
|
resolve: (e) => {
|
|
3360
|
-
let t =
|
|
3364
|
+
let t = na(e.headers.cookie ?? e.headers.Cookie, Wl);
|
|
3361
3365
|
if (!t) return { kind: "skip" };
|
|
3362
|
-
let n =
|
|
3366
|
+
let n = ra();
|
|
3363
3367
|
if (!n) return { kind: "skip" };
|
|
3364
|
-
let r =
|
|
3368
|
+
let r = ia(t, n);
|
|
3365
3369
|
return r ? {
|
|
3366
3370
|
kind: "matched",
|
|
3367
3371
|
subject: r.subject
|
|
3368
3372
|
} : { kind: "skip" };
|
|
3369
3373
|
}
|
|
3370
|
-
},
|
|
3371
|
-
...n ? { anonymousTenantRequired: !0 } : { fallback: (e) =>
|
|
3374
|
+
}, Kl = (e = [], t, n = !1, r, i) => (ql([t ?? Gl, ...e]), ki([t ?? Gl, ...e], {
|
|
3375
|
+
...n ? { anonymousTenantRequired: !0 } : { fallback: (e) => Di(e.headers["x-tenant"] ?? Ul) },
|
|
3372
3376
|
onStrategyFailed: ({ strategyId: e, reason: t }) => {
|
|
3373
3377
|
$.warn(`auth strategy "${e}" rejected request: ${t}`);
|
|
3374
3378
|
},
|
|
@@ -3377,17 +3381,20 @@ ${a.join("\n\n")}\n`);
|
|
|
3377
3381
|
...t,
|
|
3378
3382
|
store: i?.()
|
|
3379
3383
|
}) }
|
|
3380
|
-
})),
|
|
3384
|
+
})), ql = (e) => {
|
|
3381
3385
|
let t = /* @__PURE__ */ new Map();
|
|
3382
3386
|
for (let n of e) {
|
|
3383
3387
|
let e = n.claimsBearerPrefix;
|
|
3384
3388
|
e === void 0 || e === "" || t.set(e, [...t.get(e) ?? [], n.id]);
|
|
3385
3389
|
}
|
|
3386
3390
|
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: "…" }\`).`);
|
|
3387
|
-
},
|
|
3391
|
+
}, Jl = (e) => F.succeed(xi, xi.of(({ headers: t, clientId: n }) => P.promise(async () => fn(n) || e({
|
|
3388
3392
|
headers: t,
|
|
3389
3393
|
clientId: n
|
|
3390
|
-
})))),
|
|
3394
|
+
})))), Yl = F.succeed(Si, Si.of(({ headers: e, clientId: t }) => P.succeed({
|
|
3395
|
+
clientId: t,
|
|
3396
|
+
...e["idempotency-key"] ? { idempotencyKey: e["idempotency-key"] } : {}
|
|
3397
|
+
}))), Xl = (e) => {
|
|
3391
3398
|
if (dt.isCause(e)) return e;
|
|
3392
3399
|
if (typeof e != "object" || !e) return;
|
|
3393
3400
|
for (let t of Object.getOwnPropertySymbols(e)) if (t.description === "effect/Runtime/FiberFailure/Cause") {
|
|
@@ -3396,17 +3403,17 @@ ${a.join("\n\n")}\n`);
|
|
|
3396
3403
|
}
|
|
3397
3404
|
let t = e.cause;
|
|
3398
3405
|
return dt.isCause(t) ? t : void 0;
|
|
3399
|
-
},
|
|
3400
|
-
let t =
|
|
3406
|
+
}, Zl = (e) => {
|
|
3407
|
+
let t = Xl(e);
|
|
3401
3408
|
if (t === void 0) return;
|
|
3402
3409
|
let n = dt.failureOption(t);
|
|
3403
3410
|
if (_t.isSome(n)) return n.value;
|
|
3404
3411
|
let r = dt.dieOption(t);
|
|
3405
3412
|
if (_t.isSome(r)) return r.value;
|
|
3406
|
-
},
|
|
3413
|
+
}, Ql = (e) => {
|
|
3407
3414
|
if (e == null) return { message: "unknown error" };
|
|
3408
|
-
let t =
|
|
3409
|
-
if (t !== void 0 && t !== e) return
|
|
3415
|
+
let t = Zl(e);
|
|
3416
|
+
if (t !== void 0 && t !== e) return Ql(t);
|
|
3410
3417
|
let n = cn(e), r = (n.dbCode ?? n.dbSqlState ?? n.dbErrno ?? n.dbConstraint) === void 0 ? {} : n;
|
|
3411
3418
|
if (typeof e == "object" && "_tag" in e) return {
|
|
3412
3419
|
...e,
|
|
@@ -3423,7 +3430,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3423
3430
|
} catch {
|
|
3424
3431
|
return { message: String(e) };
|
|
3425
3432
|
}
|
|
3426
|
-
},
|
|
3433
|
+
}, $l = /* @__PURE__ */ new Set([
|
|
3427
3434
|
"node_modules",
|
|
3428
3435
|
"dist",
|
|
3429
3436
|
"build",
|
|
@@ -3431,21 +3438,21 @@ ${a.join("\n\n")}\n`);
|
|
|
3431
3438
|
".vite",
|
|
3432
3439
|
".next",
|
|
3433
3440
|
".git"
|
|
3434
|
-
]),
|
|
3441
|
+
]), eu = async (e) => {
|
|
3435
3442
|
let t = [], n = async (e) => {
|
|
3436
3443
|
let r = await R.readdir(e, { withFileTypes: !0 });
|
|
3437
3444
|
for (let i of r) {
|
|
3438
|
-
if (
|
|
3445
|
+
if ($l.has(i.name)) continue;
|
|
3439
3446
|
let r = A(e, i.name);
|
|
3440
|
-
i.isDirectory() ? await n(r) : i.isFile() && (Ae.test(i.name) && !Ie.test(i.name) || Ie.test(i.name) || w.test(i.name) || Ee.test(i.name) || Te.test(i.name) || je.test(i.name) || Me.test(i.name) || Oe.test(i.name) || Re.test(i.name) || Ne.test(i.name) || De.test(i.name) ||
|
|
3447
|
+
i.isDirectory() ? await n(r) : i.isFile() && (Ae.test(i.name) && !Ie.test(i.name) || Ie.test(i.name) || w.test(i.name) || Ee.test(i.name) || Te.test(i.name) || je.test(i.name) || Me.test(i.name) || Oe.test(i.name) || Re.test(i.name) || Ne.test(i.name) || De.test(i.name) || Ac.test(i.name) || xe.test(i.name) || C.test(i.name) || ke.test(i.name) || Pe.test(i.name) || Fe.test(i.name) || Le.test(i.name)) && t.push(r);
|
|
3441
3448
|
}
|
|
3442
3449
|
};
|
|
3443
3450
|
return await n(e), t;
|
|
3444
|
-
},
|
|
3451
|
+
}, tu = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "query", nu = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "mutation", ru = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "action", iu = (e) => typeof e == "object" && !!e && "kind" in e && "name" in e && e.kind === "stream", au = Symbol.for("@effect/workflow/Workflow"), ou = (e) => typeof e == "object" && !!e && au in e, su = (e) => {
|
|
3445
3452
|
let t = {};
|
|
3446
3453
|
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;
|
|
3447
3454
|
return t;
|
|
3448
|
-
},
|
|
3455
|
+
}, cu = (e) => Object.entries(e.fields).map(([e, t]) => {
|
|
3449
3456
|
let n = t, r = n.references?.()?.tableName;
|
|
3450
3457
|
return {
|
|
3451
3458
|
name: e,
|
|
@@ -3456,11 +3463,11 @@ ${a.join("\n\n")}\n`);
|
|
|
3456
3463
|
...r === void 0 ? {} : { referencesTable: r },
|
|
3457
3464
|
...n.oneOf === void 0 ? {} : { oneOf: [...n.oneOf] }
|
|
3458
3465
|
};
|
|
3459
|
-
}),
|
|
3466
|
+
}), lu = (e) => e.some((e) => e.name === "id") ? "id" : e.find((e) => e.type === "id")?.name, uu = (e) => typeof e == "object" && !!e && "tableName" in e && "fields" in e && typeof e.tableName == "string" && typeof e.fields == "object" && e.fields !== null, du = (e, t) => {
|
|
3460
3467
|
let n = /* @__PURE__ */ new Map();
|
|
3461
|
-
for (let e of t)
|
|
3468
|
+
for (let e of t) uu(e) && n.set(e.tableName, e);
|
|
3462
3469
|
let r = /* @__PURE__ */ new Set(), i = [], a = (e) => {
|
|
3463
|
-
if (!(!
|
|
3470
|
+
if (!(!uu(e) || r.has(e.tableName))) {
|
|
3464
3471
|
r.add(e.tableName);
|
|
3465
3472
|
for (let t of Object.values(e.fields)) {
|
|
3466
3473
|
let e = t.references?.()?.tableName;
|
|
@@ -3473,7 +3480,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3473
3480
|
};
|
|
3474
3481
|
for (let t of e) a(t);
|
|
3475
3482
|
return i;
|
|
3476
|
-
},
|
|
3483
|
+
}, fu = "voltro/tenant", pu = (e) => uu(e) && (e.appliedMixins ?? []).some((e) => e.id === fu), mu = "voltro/softDelete", hu = (e) => uu(e) && (e.appliedMixins ?? []).some((e) => e.id === mu), gu = (e) => {
|
|
3477
3484
|
let t = e.traceId, n = e.spanId;
|
|
3478
3485
|
if (typeof t != "string" || typeof n != "string") return null;
|
|
3479
3486
|
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);
|
|
@@ -3491,7 +3498,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3491
3498
|
...typeof e.statusMessage == "string" ? { statusMessage: e.statusMessage } : {},
|
|
3492
3499
|
...Array.isArray(e.events) ? { events: e.events } : {}
|
|
3493
3500
|
};
|
|
3494
|
-
},
|
|
3501
|
+
}, _u = async (e, t, n) => {
|
|
3495
3502
|
let r = e.indexOf("?"), i = (r === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(r + 1))).get("traceId"), a = [];
|
|
3496
3503
|
try {
|
|
3497
3504
|
a = await n.query({
|
|
@@ -3510,27 +3517,27 @@ ${a.join("\n\n")}\n`);
|
|
|
3510
3517
|
}
|
|
3511
3518
|
let o = /* @__PURE__ */ new Map();
|
|
3512
3519
|
for (let e of a) {
|
|
3513
|
-
let t =
|
|
3520
|
+
let t = gu(e);
|
|
3514
3521
|
t && o.set(`${t.traceId}:${t.spanId}`, t);
|
|
3515
3522
|
}
|
|
3516
3523
|
for (let e of t.query({ max: t.capacityHint() })) o.set(`${e.traceId}:${e.spanId}`, e);
|
|
3517
3524
|
let s = new ce(Math.max(o.size + 16, 1024));
|
|
3518
3525
|
for (let e of [...o.values()].sort((e, t) => e.startMs - t.startMs)) s.append(e);
|
|
3519
3526
|
return s;
|
|
3520
|
-
},
|
|
3527
|
+
}, vu = async (e, t) => {
|
|
3521
3528
|
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();
|
|
3522
3529
|
for (let t of e) {
|
|
3523
3530
|
let e = O(t);
|
|
3524
3531
|
if (je.test(e)) {
|
|
3525
3532
|
let e = await x(t);
|
|
3526
|
-
for (let t of Object.values(e))
|
|
3527
|
-
|
|
3533
|
+
for (let t of Object.values(e)) uu(t) && (f.set(t.tableName, t), pu(t) && u.add(t.tableName), hu(t) && d.add(t.tableName));
|
|
3534
|
+
hi(e);
|
|
3528
3535
|
continue;
|
|
3529
3536
|
}
|
|
3530
3537
|
if (Me.test(e)) {
|
|
3531
3538
|
let e = await x(t);
|
|
3532
|
-
if (
|
|
3533
|
-
let n = Object.entries(e).filter(([, e]) =>
|
|
3539
|
+
if (hi(e) === 0) {
|
|
3540
|
+
let n = Object.entries(e).filter(([, e]) => ui(e)).map(([e]) => e);
|
|
3534
3541
|
n.length > 0 ? $.warn(`relations file declares nothing — ${n.join(", ")} call relations(...) with an empty map, so no relation is registered and .with() cannot resolve one. Fill it in or delete the file.`, {
|
|
3535
3542
|
file: t,
|
|
3536
3543
|
exports: n
|
|
@@ -3546,7 +3553,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3546
3553
|
continue;
|
|
3547
3554
|
}
|
|
3548
3555
|
if (w.test(e)) {
|
|
3549
|
-
let e = await x(t), n = Object.values(e).find(
|
|
3556
|
+
let e = await x(t), n = Object.values(e).find(ou);
|
|
3550
3557
|
if (!n) {
|
|
3551
3558
|
$.warn("skipping workflow — no workflow(...) export", { file: t });
|
|
3552
3559
|
continue;
|
|
@@ -3571,7 +3578,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3571
3578
|
definition: n,
|
|
3572
3579
|
buildExecute: a
|
|
3573
3580
|
});
|
|
3574
|
-
for (let t of [...Object.values(e), ...Object.values(i)])
|
|
3581
|
+
for (let t of [...Object.values(e), ...Object.values(i)]) Wr(t) && s.push(t);
|
|
3575
3582
|
continue;
|
|
3576
3583
|
}
|
|
3577
3584
|
if (Te.test(e)) {
|
|
@@ -3618,7 +3625,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3618
3625
|
}
|
|
3619
3626
|
}
|
|
3620
3627
|
for (let e of p) {
|
|
3621
|
-
let t = await x(e), o = Object.values(t).find(
|
|
3628
|
+
let t = await x(e), o = Object.values(t).find(tu) ?? Object.values(t).find(nu) ?? Object.values(t).find(ru) ?? Object.values(t).find(iu);
|
|
3622
3629
|
if (!o) {
|
|
3623
3630
|
$.warn("skipping procedure descriptor — no defineQuery / defineMutation / defineAction / defineStream export", { file: e });
|
|
3624
3631
|
continue;
|
|
@@ -3656,10 +3663,10 @@ ${a.join("\n\n")}\n`);
|
|
|
3656
3663
|
}
|
|
3657
3664
|
let h = /* @__PURE__ */ new Map();
|
|
3658
3665
|
for (let [e, t] of f) {
|
|
3659
|
-
let n =
|
|
3666
|
+
let n = vi(t);
|
|
3660
3667
|
n.length > 0 && h.set(e, n);
|
|
3661
3668
|
}
|
|
3662
|
-
let ee = h.size === 0 ? [] : n.flatMap((e) =>
|
|
3669
|
+
let ee = h.size === 0 ? [] : n.flatMap((e) => yr({
|
|
3663
3670
|
name: e.descriptor.name,
|
|
3664
3671
|
output: e.descriptor.output,
|
|
3665
3672
|
source: e.descriptor.source
|
|
@@ -3669,9 +3676,9 @@ ${a.join("\n\n")}\n`);
|
|
|
3669
3676
|
source: e.descriptor.source,
|
|
3670
3677
|
...e.descriptor.cache === void 0 ? {} : { cache: e.descriptor.cache }
|
|
3671
3678
|
}, u));
|
|
3672
|
-
f.has("actors") || f.set("actors",
|
|
3679
|
+
f.has("actors") || f.set("actors", ri);
|
|
3673
3680
|
let te = f.get("actors"), _ = f.get("tenants");
|
|
3674
|
-
(te !== void 0 || _ !== void 0) &&
|
|
3681
|
+
(te !== void 0 || _ !== void 0) && mi({
|
|
3675
3682
|
...te === void 0 ? {} : { actors: () => te },
|
|
3676
3683
|
..._ === void 0 ? {} : { tenants: () => _ }
|
|
3677
3684
|
});
|
|
@@ -3683,7 +3690,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3683
3690
|
outbox: e.some((e) => Pe.test(O(e))),
|
|
3684
3691
|
connections: v.length > 0
|
|
3685
3692
|
};
|
|
3686
|
-
return
|
|
3693
|
+
return yi(), {
|
|
3687
3694
|
queries: n,
|
|
3688
3695
|
mutations: r,
|
|
3689
3696
|
actions: i,
|
|
@@ -3700,7 +3707,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3700
3707
|
serverOnlyLeaks: ee,
|
|
3701
3708
|
cacheScopeLeaks: g
|
|
3702
3709
|
};
|
|
3703
|
-
},
|
|
3710
|
+
}, yu = async (e) => {
|
|
3704
3711
|
let t = A(e, "app.config.ts"), n = L(t);
|
|
3705
3712
|
try {
|
|
3706
3713
|
let e = (await x(t)).default;
|
|
@@ -3718,13 +3725,14 @@ ${a.join("\n\n")}\n`);
|
|
|
3718
3725
|
...n ? { error: e } : {}
|
|
3719
3726
|
};
|
|
3720
3727
|
}
|
|
3721
|
-
},
|
|
3722
|
-
let e =
|
|
3723
|
-
return
|
|
3724
|
-
url:
|
|
3728
|
+
}, bu = async (e) => (await yu(e)).config, xu = () => {
|
|
3729
|
+
let e = wu(), t = process.env.DB_SCHEMA, n = t && t.length > 0 ? { schema: t } : {}, r = Cu(), i = r === void 0 ? {} : { ssl: r }, a = Su(), o = a === void 0 ? {} : { statementTimeoutMs: a }, s = process.env.DB_URL ?? process.env.DB_PRIMARY_URL;
|
|
3730
|
+
return s ? {
|
|
3731
|
+
url: s,
|
|
3725
3732
|
...e === void 0 ? {} : { maxConnections: e },
|
|
3726
3733
|
...i,
|
|
3727
|
-
...n
|
|
3734
|
+
...n,
|
|
3735
|
+
...o
|
|
3728
3736
|
} : {
|
|
3729
3737
|
host: process.env.DB_HOST ?? process.env.PG_HOST ?? "localhost",
|
|
3730
3738
|
port: Number(process.env.DB_PORT ?? process.env.PG_PORT ?? 5432),
|
|
@@ -3733,21 +3741,27 @@ ${a.join("\n\n")}\n`);
|
|
|
3733
3741
|
database: process.env.DB_DATABASE ?? process.env.PG_DATABASE ?? "app",
|
|
3734
3742
|
...e === void 0 ? {} : { maxConnections: e },
|
|
3735
3743
|
...i,
|
|
3736
|
-
...n
|
|
3744
|
+
...n,
|
|
3745
|
+
...o
|
|
3737
3746
|
};
|
|
3738
|
-
},
|
|
3747
|
+
}, Su = () => {
|
|
3748
|
+
let e = process.env.DB_STATEMENT_TIMEOUT_MS;
|
|
3749
|
+
if (e === void 0 || e === "") return;
|
|
3750
|
+
let t = Number(e);
|
|
3751
|
+
return Number.isInteger(t) && t > 0 ? t : void 0;
|
|
3752
|
+
}, Cu = () => {
|
|
3739
3753
|
let e = process.env.PG_SSL;
|
|
3740
3754
|
if (!(e === void 0 || e === "")) {
|
|
3741
3755
|
if (e === "require") return !0;
|
|
3742
3756
|
if (e === "disable") return !1;
|
|
3743
3757
|
throw Error(`PG_SSL '${e}' is not supported — use 'require' (TLS without certificate verification) or 'disable' (plaintext).`);
|
|
3744
3758
|
}
|
|
3745
|
-
},
|
|
3759
|
+
}, wu = () => {
|
|
3746
3760
|
let e = process.env.DB_MAX_CONNECTIONS ?? process.env.PG_MAX_CONNECTIONS;
|
|
3747
3761
|
if (e === void 0 || e === "") return;
|
|
3748
3762
|
let t = Number(e);
|
|
3749
3763
|
return Number.isInteger(t) && t > 0 ? t : void 0;
|
|
3750
|
-
},
|
|
3764
|
+
}, Tu = (e) => {
|
|
3751
3765
|
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;
|
|
3752
3766
|
if ("url" in e && e.url) try {
|
|
3753
3767
|
let n = new URL(e.url), r = n.username ? `${n.username}@` : "", i = n.port ? `:${n.port}` : "";
|
|
@@ -3766,25 +3780,25 @@ ${a.join("\n\n")}\n`);
|
|
|
3766
3780
|
summary: `postgres://${n.username}@${n.host}:${n.port}/${n.database}`,
|
|
3767
3781
|
fromEnv: t
|
|
3768
3782
|
};
|
|
3769
|
-
},
|
|
3783
|
+
}, Eu = () => {
|
|
3770
3784
|
let e = process.env.DB_REPLICA_URLS;
|
|
3771
3785
|
return e === void 0 || e.trim() === "" ? [] : e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
3772
|
-
},
|
|
3786
|
+
}, Du = (e) => {
|
|
3773
3787
|
let t = 2166136261;
|
|
3774
3788
|
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
3775
3789
|
return 1e3 + (t >>> 0) % 2147482647;
|
|
3776
|
-
},
|
|
3777
|
-
let n =
|
|
3790
|
+
}, Ou = (e) => (process.env.DB_DIALECT ?? e?.store ?? "memory").toLowerCase(), ku = async (e, t) => {
|
|
3791
|
+
let n = Ou(e);
|
|
3778
3792
|
if (n === "memory") return $.info("sql dialect resolved: memory — in-process store, no persistence"), new z({});
|
|
3779
|
-
let r = (process.env.CDC ?? "1") !== "0", i = await b(n), a = i.id === "postgres" ? "LISTEN/NOTIFY" :
|
|
3793
|
+
let r = (process.env.CDC ?? "1") !== "0", i = await b(n), a = i.id === "postgres" ? "LISTEN/NOTIFY" : di(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" : di(i.id) ? "native" : "unknown";
|
|
3780
3794
|
$.info(`sql dialect resolved: ${i.id} — CDC: ${r ? a : "inline emit (CDC=0)"}, RETURNING: ${o}`);
|
|
3781
|
-
let s =
|
|
3795
|
+
let s = xu(), { summary: c, fromEnv: l } = Tu(s);
|
|
3782
3796
|
$.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.");
|
|
3783
3797
|
let u;
|
|
3784
3798
|
if (r && (i.id === "mysql" || i.id === "mariadb")) {
|
|
3785
|
-
let { connectionFromConfig: e } = await y("@voltro/sql-mysql"), t = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, n =
|
|
3799
|
+
let { connectionFromConfig: e } = await y("@voltro/sql-mysql"), t = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, n = ii().filter((e) => e.isReactive !== !1).map((e) => e.tableName).filter((e) => !e.startsWith("_voltro_"));
|
|
3786
3800
|
u = {
|
|
3787
|
-
serverId:
|
|
3801
|
+
serverId: Du(t),
|
|
3788
3802
|
replicaId: t,
|
|
3789
3803
|
connection: e(s),
|
|
3790
3804
|
includeTables: n
|
|
@@ -3794,7 +3808,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3794
3808
|
tables: n.length
|
|
3795
3809
|
});
|
|
3796
3810
|
} else if (r && i.id === "mssql") {
|
|
3797
|
-
let { connectionFromConfig: e } = await y("@voltro/sql-mssql"), t = e(s), n = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, i =
|
|
3811
|
+
let { connectionFromConfig: e } = await y("@voltro/sql-mssql"), t = e(s), n = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, i = ii().filter((e) => e.isReactive !== !1).map((e) => e.tableName).filter((e) => !e.startsWith("_voltro_"));
|
|
3798
3812
|
u = {
|
|
3799
3813
|
serverId: 0,
|
|
3800
3814
|
replicaId: n,
|
|
@@ -3816,7 +3830,7 @@ ${a.join("\n\n")}\n`);
|
|
|
3816
3830
|
...t ? { tracerLayer: t } : {},
|
|
3817
3831
|
changeStrategy: r ? "cdc" : "inline",
|
|
3818
3832
|
...u ? { cdcConfig: u } : {}
|
|
3819
|
-
}), f =
|
|
3833
|
+
}), f = Eu();
|
|
3820
3834
|
if (f.length === 0) return $.info("read replicas: none configured (DB_REPLICA_URLS unset) — all queries → primary"), ct.recordReplication({
|
|
3821
3835
|
replicaCount: 0,
|
|
3822
3836
|
rywPolicy: "off",
|
|
@@ -3824,14 +3838,14 @@ ${a.join("\n\n")}\n`);
|
|
|
3824
3838
|
region: null,
|
|
3825
3839
|
localityEnabled: !1
|
|
3826
3840
|
}), d;
|
|
3827
|
-
if (
|
|
3841
|
+
if (di(i.id)) return $.warn(`read replicas: not applicable (${i.id} is single-process); ignoring DB_REPLICA_URLS`), ct.recordReplication({
|
|
3828
3842
|
replicaCount: 0,
|
|
3829
3843
|
rywPolicy: "off",
|
|
3830
3844
|
rywStore: "memory",
|
|
3831
3845
|
region: null,
|
|
3832
3846
|
localityEnabled: !1
|
|
3833
3847
|
}), d;
|
|
3834
|
-
let p = await
|
|
3848
|
+
let p = await Pu(i.id);
|
|
3835
3849
|
if (p === null) return $.warn(`read replicas: no replication adapter for dialect ${i.id}; falling back to primary-only routing`), ct.recordReplication({
|
|
3836
3850
|
replicaCount: 0,
|
|
3837
3851
|
rywPolicy: "off",
|
|
@@ -3854,20 +3868,20 @@ ${a.join("\n\n")}\n`);
|
|
|
3854
3868
|
if (!e) $.warn("RYW_STORE=redis set but REDIS_URL is empty — falling back to memory store");
|
|
3855
3869
|
else try {
|
|
3856
3870
|
let { default: t } = await import("ioredis"), n = new t(e);
|
|
3857
|
-
g =
|
|
3871
|
+
g = lr({
|
|
3858
3872
|
client: n,
|
|
3859
3873
|
subscriber: n.duplicate()
|
|
3860
|
-
}), te = "redis", $.info(`read replicas: ryw store = redis @ ${
|
|
3874
|
+
}), te = "redis", $.info(`read replicas: ryw store = redis @ ${ju(e)}`);
|
|
3861
3875
|
} catch (e) {
|
|
3862
3876
|
$.warn("RYW_STORE=redis but ioredis import / connect failed — falling back to memory store", { err: e });
|
|
3863
3877
|
}
|
|
3864
3878
|
}
|
|
3865
|
-
g ||=
|
|
3866
|
-
let _ =
|
|
3879
|
+
g ||= nr();
|
|
3880
|
+
let _ = Mu(f.length), v = pr(), ne = v && _.length > 0 ? Sn({
|
|
3867
3881
|
currentRegion: v,
|
|
3868
|
-
replicaRegions:
|
|
3869
|
-
inner:
|
|
3870
|
-
}) :
|
|
3882
|
+
replicaRegions: Nu(m, _),
|
|
3883
|
+
inner: or()
|
|
3884
|
+
}) : or();
|
|
3871
3885
|
return $.info(`read replicas: ${m.length} configured, ryw policy '${h}', dialect=${i.id}, region=${v ?? "unknown"}` + (_.length > 0 ? ", replica-locality=on" : "")), ct.recordReplication({
|
|
3872
3886
|
replicaCount: m.length,
|
|
3873
3887
|
rywPolicy: h,
|
|
@@ -3882,33 +3896,33 @@ ${a.join("\n\n")}\n`);
|
|
|
3882
3896
|
rywStore: g,
|
|
3883
3897
|
replicaSelector: ne
|
|
3884
3898
|
});
|
|
3885
|
-
},
|
|
3886
|
-
let i =
|
|
3899
|
+
}, Au = async (e, t, n, r) => {
|
|
3900
|
+
let i = W(t?.plugins ?? []), a = n === "postgres" || n === "mysql" || n === "mariadb", o = n === "postgres" ? "LISTEN/NOTIFY" : "binlog CDC";
|
|
3887
3901
|
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;
|
|
3888
3902
|
let s = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`;
|
|
3889
|
-
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
|
|
3903
|
+
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 Fa({
|
|
3890
3904
|
store: e,
|
|
3891
3905
|
provider: i.broadcast.provider,
|
|
3892
3906
|
replicaId: s,
|
|
3893
3907
|
logger: r
|
|
3894
3908
|
});
|
|
3895
|
-
},
|
|
3909
|
+
}, ju = (e) => {
|
|
3896
3910
|
try {
|
|
3897
3911
|
let t = new URL(e);
|
|
3898
3912
|
return t.password &&= "***", t.toString();
|
|
3899
3913
|
} catch {
|
|
3900
3914
|
return "***";
|
|
3901
3915
|
}
|
|
3902
|
-
},
|
|
3916
|
+
}, Mu = (e) => {
|
|
3903
3917
|
let t = process.env.DB_REPLICA_REGIONS;
|
|
3904
3918
|
if (!t) return [];
|
|
3905
3919
|
let n = t.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
3906
3920
|
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.`), []);
|
|
3907
|
-
},
|
|
3921
|
+
}, Nu = (e, t) => {
|
|
3908
3922
|
let n = /* @__PURE__ */ new Map();
|
|
3909
3923
|
for (let r = 0; r < e.length && r < t.length; r++) n.set(e[r], t[r]);
|
|
3910
3924
|
return n;
|
|
3911
|
-
},
|
|
3925
|
+
}, Pu = async (e) => {
|
|
3912
3926
|
switch (e) {
|
|
3913
3927
|
case "postgres": return (await y("@voltro/sql-postgres")).postgresReplicationAdapter();
|
|
3914
3928
|
case "mysql":
|
|
@@ -3916,11 +3930,11 @@ ${a.join("\n\n")}\n`);
|
|
|
3916
3930
|
case "mssql": return (await y("@voltro/sql-mssql")).mssqlReplicationAdapter();
|
|
3917
3931
|
default: return null;
|
|
3918
3932
|
}
|
|
3919
|
-
},
|
|
3933
|
+
}, Fu = async (e) => {
|
|
3920
3934
|
let t = M(e.find((e) => !e.startsWith("-")) ?? process.cwd()), n = await p(t);
|
|
3921
|
-
return n.ran ? n.exitCode : process.env.FRAMEWORK_DEV_INNER !== "1" && process.env.WATCH !== "0" ? (_(
|
|
3922
|
-
},
|
|
3923
|
-
let _ = Date.now(), y = await
|
|
3935
|
+
return n.ran ? n.exitCode : process.env.FRAMEWORK_DEV_INNER !== "1" && process.env.WATCH !== "0" ? (_(jo({ root: t }), { scope: "voltro:dev" }), new Promise(() => {})) : Iu(t);
|
|
3936
|
+
}, Iu = async (p) => {
|
|
3937
|
+
let _ = Date.now(), y = await bu(p), x = Number(process.env.PORT ?? y?.port ?? 4e3), ce = y?.name ?? O(p), S = u("api", ce, x), le = e(ce);
|
|
3924
3938
|
await m({
|
|
3925
3939
|
id: S,
|
|
3926
3940
|
name: ce,
|
|
@@ -3933,18 +3947,18 @@ ${a.join("\n\n")}\n`);
|
|
|
3933
3947
|
let C = t();
|
|
3934
3948
|
n(C), $.info("booting voltro dev", {
|
|
3935
3949
|
root: p,
|
|
3936
|
-
version:
|
|
3950
|
+
version: Hl,
|
|
3937
3951
|
logFile: le.path
|
|
3938
3952
|
});
|
|
3939
3953
|
let me = await oe({
|
|
3940
3954
|
project: O(p),
|
|
3941
|
-
cliVersion:
|
|
3955
|
+
cliVersion: Hl
|
|
3942
3956
|
});
|
|
3943
3957
|
if (me.kind === "not-personal") return $.error(`voltro dev needs a personal login — the stored credential belongs to no user.
|
|
3944
3958
|
${me.message}`), 1;
|
|
3945
3959
|
me.kind === "reported" && me.seat === "claimed" && $.info("cloud: this machine now counts toward your organisation's seats (voltro cloud whoami)");
|
|
3946
3960
|
let Ce = process.env.VOLTRO_DEV_HEALTH_PORT, we = Ce === void 0 ? x + 1 : Number(Ce), Te;
|
|
3947
|
-
we > 0 && Number.isFinite(we) && (Te = await
|
|
3961
|
+
we > 0 && Number.isFinite(we) && (Te = await Bl({
|
|
3948
3962
|
port: we,
|
|
3949
3963
|
log: {
|
|
3950
3964
|
info: (e, t) => $.debug(e, t),
|
|
@@ -3958,33 +3972,33 @@ ${a.join("\n\n")}\n`);
|
|
|
3958
3972
|
}).catch((e) => {
|
|
3959
3973
|
$.warn("agent-instructions seed failed (non-fatal)", {}, e);
|
|
3960
3974
|
});
|
|
3961
|
-
let w = await
|
|
3975
|
+
let w = await eu(p);
|
|
3962
3976
|
$.info(`discovered ${w.length} files`, { count: w.length });
|
|
3963
|
-
let { pluginContributions: Ee, pluginErrorImports: Oe, pluginRpcImports: Ae } = await
|
|
3977
|
+
let { pluginContributions: Ee, pluginErrorImports: Oe, pluginRpcImports: Ae } = await bl(y?.plugins ?? [], y?.name ?? O(p), p), je = await ds({
|
|
3964
3978
|
root: p,
|
|
3965
3979
|
...Ee.length > 0 ? { pluginContributions: Ee } : {},
|
|
3966
3980
|
...Oe.length > 0 ? { pluginErrorImports: Oe } : {},
|
|
3967
3981
|
...Ae.length > 0 ? { pluginRpcImports: Ae } : {},
|
|
3968
3982
|
...y?.name === void 0 ? {} : { apiName: y.name }
|
|
3969
3983
|
});
|
|
3970
|
-
if (je ? ($.info("codegen wrote rpcGroup", { path: j(p, je) }), await
|
|
3971
|
-
let e = await
|
|
3972
|
-
if (e.length > 0) throw Error(e.map(
|
|
3984
|
+
if (je ? ($.info("codegen wrote rpcGroup", { path: j(p, je) }), await Ko(je)) : $.debug("codegen skipped — no descriptors discovered"), process.env.VOLTRO_BROWSER_SAFETY !== "off") {
|
|
3985
|
+
let e = await Wo(p, w);
|
|
3986
|
+
if (e.length > 0) throw Error(e.map(Go).join("\n\n"));
|
|
3973
3987
|
}
|
|
3974
|
-
let Me =
|
|
3988
|
+
let Me = Ou(y ?? null), Ne = Me === "mariadb" ? "mariadb" : Me === "mssql" ? "mssql" : void 0, Ie = Ne !== void 0 && (process.env.CDC ?? "1") !== "0", { queries: T, mutations: D, actions: k, streams: M, workflows: N, workflowWorkers: lt, eventTriggers: ut, schedules: ft, connections: pt, tables: mt, featureMix: ht, tenantScopedTables: _t, softDeleteScopedTables: vt, serverOnlyLeaks: yt, cacheScopeLeaks: bt } = await vu(w, { cdc: Ie });
|
|
3975
3989
|
{
|
|
3976
|
-
let e =
|
|
3990
|
+
let e = Rs(yt, Ls(process.env, "warn"), un, "`voltro dev`");
|
|
3977
3991
|
if (e.action === "fail") throw Error(e.message);
|
|
3978
3992
|
e.action === "warn" && $.warn(e.message ?? "");
|
|
3979
3993
|
}
|
|
3980
3994
|
{
|
|
3981
|
-
let e =
|
|
3995
|
+
let e = Rs(bt, Ls(process.env, "warn"), ln, "`voltro dev`");
|
|
3982
3996
|
if (e.action === "fail") throw Error(e.message);
|
|
3983
3997
|
e.action === "warn" && $.warn(e.message ?? "");
|
|
3984
3998
|
}
|
|
3985
|
-
let xt = N.length > 0 || ut.length > 0, I = await
|
|
3986
|
-
|
|
3987
|
-
let L =
|
|
3999
|
+
let xt = N.length > 0 || ut.length > 0, I = await bu(p), wt = lo(I?.http ?? {});
|
|
4000
|
+
xr(mr(I?.secrets));
|
|
4001
|
+
let L = Ga(ta(I?.env) ? I.env : void 0, p);
|
|
3988
4002
|
L.minted.length > 0 && L.file !== void 0 && ($.warn(`minted ${L.minted.length} project secret(s) into ${j(p, L.file)} — unique to this project, gitignored. Your DEPLOYMENT needs its own values (\`voltro secret generate\`).`, {
|
|
3989
4003
|
keys: L.minted,
|
|
3990
4004
|
file: j(p, L.file)
|
|
@@ -4004,7 +4018,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4004
4018
|
"apikeys:issue:other"
|
|
4005
4019
|
].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).");
|
|
4006
4020
|
}
|
|
4007
|
-
let Dt = (typeof Et == "object" ? Et.prefix : void 0) ?? "voltro_", Ot, kt = Et ? [dn({ resolveByHash: (e, t) => Ot ? Ot.resolveByHash(e, t) : Promise.resolve(null) }, { prefix: Dt })] : [], At =
|
|
4021
|
+
let Dt = (typeof Et == "object" ? Et.prefix : void 0) ?? "voltro_", Ot, kt = Et ? [dn({ resolveByHash: (e, t) => Ot ? Ot.resolveByHash(e, t) : Promise.resolve(null) }, { prefix: Dt })] : [], At = Kl([...I?.auth?.strategies ?? [], ...kt], ya(I?.plugins ?? []), I?.auth?.anonymousTenantRequired ?? !1, I?.auth?.resolveScopes, () => Tt.current), jt = Jl(At), Nt = ge({
|
|
4008
4022
|
mix: ht,
|
|
4009
4023
|
plugins: I?.plugins ?? [],
|
|
4010
4024
|
cdc: Ie,
|
|
@@ -4017,8 +4031,8 @@ ${a.join("\n\n")}\n`);
|
|
|
4017
4031
|
}
|
|
4018
4032
|
return t;
|
|
4019
4033
|
})();
|
|
4020
|
-
for (let e of z)
|
|
4021
|
-
let Lt =
|
|
4034
|
+
for (let e of z) ci(e);
|
|
4035
|
+
let Lt = Jc({
|
|
4022
4036
|
plugins: I?.plugins ?? [],
|
|
4023
4037
|
appName: I?.name ?? O(p),
|
|
4024
4038
|
appType: "api",
|
|
@@ -4026,12 +4040,12 @@ ${a.join("\n\n")}\n`);
|
|
|
4026
4040
|
log: $
|
|
4027
4041
|
});
|
|
4028
4042
|
I?.plugins?.length && ($.info("plugins loaded", { plugins: I.plugins.map((e) => e.name) }), await Lt.activate());
|
|
4029
|
-
let Rt = await Lt.gatherObservability(), zt =
|
|
4043
|
+
let Rt = await Lt.gatherObservability(), zt = nl(I?.plugins ?? []);
|
|
4030
4044
|
zt.endpoints.length > 0 && $.info("plugin inspect endpoints registered", {
|
|
4031
4045
|
count: zt.endpoints.length,
|
|
4032
4046
|
endpoints: zt.endpoints.map((e) => `${e.method} ${e.path}`)
|
|
4033
4047
|
});
|
|
4034
|
-
let Wt =
|
|
4048
|
+
let Wt = pl(I?.plugins ?? []);
|
|
4035
4049
|
Wt.length > 0 && $.info("plugin dashboard mounts registered", {
|
|
4036
4050
|
count: Wt.length,
|
|
4037
4051
|
mounts: Wt.map((e) => `${e.fullId} (${e.slot})`)
|
|
@@ -4073,7 +4087,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4073
4087
|
if (sn.length > 0) {
|
|
4074
4088
|
let e = await ve(sn, tn);
|
|
4075
4089
|
cn = e.agents.map((e) => e.descriptor.name);
|
|
4076
|
-
for (let t of e.agents) for (let e of
|
|
4090
|
+
for (let t of e.agents) for (let e of Nc(t)) e.kind === "action" ? k.push({
|
|
4077
4091
|
file: e.file,
|
|
4078
4092
|
descriptor: e.descriptor,
|
|
4079
4093
|
executor: e.executor
|
|
@@ -4087,16 +4101,16 @@ ${a.join("\n\n")}\n`);
|
|
|
4087
4101
|
routes: e.agents.flatMap((e) => [`${e.descriptor.name}.send`, `${e.descriptor.name}.messages`])
|
|
4088
4102
|
});
|
|
4089
4103
|
}
|
|
4090
|
-
let fn =
|
|
4104
|
+
let fn = Fc();
|
|
4091
4105
|
(fn.queries.length > 0 || fn.mutations.length > 0) && (T.push(...fn.queries), D.push(...fn.mutations), $.info("undo built-ins registered", { routes: [
|
|
4092
4106
|
"__voltro.undo.log",
|
|
4093
4107
|
"__voltro.undo.apply",
|
|
4094
4108
|
"__voltro.undo.redo"
|
|
4095
4109
|
] }));
|
|
4096
|
-
let hn = $.child("aggregate"), vn = w.filter((e) => Le.test(e)), yn = vn.length > 0 ? await
|
|
4097
|
-
for (let e of
|
|
4098
|
-
let Sn = I?.restRoutes ?? [], On = w.filter((e) => ke.test(e)).length, jn = w.filter((e) => Re.test(e)).length, Mn = w.filter((e) => /\.seed\.ts$/.test(e)).length, Nn = w.filter((e) => De.test(e)).length, Fn = w.filter((e) =>
|
|
4099
|
-
|
|
4110
|
+
let hn = $.child("aggregate"), vn = w.filter((e) => Le.test(e)), yn = vn.length > 0 ? await $s(vn, hn) : [], bn = yn.map((e) => e.definition.name);
|
|
4111
|
+
for (let e of si()) $.warn(`identifier length · ${e}`);
|
|
4112
|
+
let Sn = I?.restRoutes ?? [], On = w.filter((e) => ke.test(e)).length, jn = w.filter((e) => Re.test(e)).length, Mn = w.filter((e) => /\.seed\.ts$/.test(e)).length, Nn = w.filter((e) => De.test(e)).length, Fn = w.filter((e) => Ac.test(e)).length;
|
|
4113
|
+
ps(fs([
|
|
4100
4114
|
T,
|
|
4101
4115
|
D,
|
|
4102
4116
|
k,
|
|
@@ -4142,28 +4156,28 @@ ${a.join("\n\n")}\n`);
|
|
|
4142
4156
|
},
|
|
4143
4157
|
tenantTables: [..._t]
|
|
4144
4158
|
});
|
|
4145
|
-
let In = _e(), Rn = (process.env.VOLTRO_TRACING_BUFFER ?? "").toLowerCase() === "off", Bn = (process.env.VOLTRO_TRACING_STREAM ?? "").toLowerCase() === "all",
|
|
4159
|
+
let In = _e(), Rn = (process.env.VOLTRO_TRACING_BUFFER ?? "").toLowerCase() === "off", Bn = (process.env.VOLTRO_TRACING_STREAM ?? "").toLowerCase() === "all", Wn = () => {}, Gn = (e) => {
|
|
4146
4160
|
if (!e.name.startsWith("http.server")) return !1;
|
|
4147
4161
|
let t = e.attributes, n = String(t["url.path"] ?? t["http.route"] ?? t["http.target"] ?? "");
|
|
4148
4162
|
return n.startsWith("/_voltro/") || n === "/ws" || n.startsWith("/ws/") || n.startsWith("/ws?");
|
|
4149
|
-
},
|
|
4150
|
-
|
|
4151
|
-
},
|
|
4163
|
+
}, Xn = (e) => {
|
|
4164
|
+
Gn(e) || be(e) || e.name.startsWith("RpcServer.") || (In.append(e), (Bn || e.status === "error") && C.emit("trace", e), Wn(e));
|
|
4165
|
+
}, Zn = Rn ? void 0 : An(Xn), Qn = await Zt({
|
|
4152
4166
|
serviceName: process.env.OTEL_SERVICE_NAME ?? I?.name ?? "voltro-api",
|
|
4153
|
-
...
|
|
4167
|
+
...Zn ? { traceSink: Zn } : {},
|
|
4154
4168
|
...Rt.spanProcessors.length > 0 ? { extraSpanProcessors: Rt.spanProcessors } : {},
|
|
4155
4169
|
...Rt.metricReaders.length > 0 ? { extraMetricReaders: Rt.metricReaders } : {},
|
|
4156
4170
|
...Object.keys(Rt.resourceAttributes).length > 0 ? { resourceAttributes: Rt.resourceAttributes } : {},
|
|
4157
4171
|
...Rt.sampler === void 0 ? {} : { sampler: Rt.sampler }
|
|
4158
4172
|
});
|
|
4159
|
-
|
|
4160
|
-
let
|
|
4161
|
-
Tt.current =
|
|
4162
|
-
for (let e of
|
|
4163
|
-
dialect:
|
|
4173
|
+
Qn.mode === "off" ? Qn.bufferOnly || $.info("tracing disabled", { reason: "buffer off" }) : $.info("tracing enabled", { mode: Qn.mode });
|
|
4174
|
+
let nr = Qn.mode === "off" && Qn.bufferOnly === !1 ? void 0 : Qn.layer, B = await ku(I, nr);
|
|
4175
|
+
Tt.current = Nr(B, Ou(I ?? null));
|
|
4176
|
+
for (let e of Qa({
|
|
4177
|
+
dialect: Ou(I ?? null),
|
|
4164
4178
|
changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
|
|
4165
4179
|
dbUrl: process.env.DB_URL,
|
|
4166
|
-
tables:
|
|
4180
|
+
tables: ii().map((e) => ({
|
|
4167
4181
|
tableName: e.tableName,
|
|
4168
4182
|
isReactive: e.isReactive === !0
|
|
4169
4183
|
})),
|
|
@@ -4179,59 +4193,59 @@ ${a.join("\n\n")}\n`);
|
|
|
4179
4193
|
usage: t
|
|
4180
4194
|
}), $.info("api keys active", { prefix: Dt });
|
|
4181
4195
|
}
|
|
4182
|
-
let
|
|
4196
|
+
let ir = Ps({
|
|
4183
4197
|
definitions: pt.map((e) => e.definition),
|
|
4184
4198
|
store: B,
|
|
4185
|
-
publicUrl:
|
|
4199
|
+
publicUrl: Is(x),
|
|
4186
4200
|
log: $.child("connections")
|
|
4187
4201
|
});
|
|
4188
|
-
T.push(...
|
|
4189
|
-
let
|
|
4190
|
-
if (
|
|
4191
|
-
let e = await b(
|
|
4192
|
-
|
|
4202
|
+
T.push(...ir.queries), D.push(...ir.mutations), k.push(...ir.actions);
|
|
4203
|
+
let or = Ou(I), lr = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, ur, dr;
|
|
4204
|
+
if (or !== "memory") {
|
|
4205
|
+
let e = await b(or);
|
|
4206
|
+
ur = gt.make(e.makeSqlLayer(xu())), dr = await ur.runPromise(Rr.SqlClient);
|
|
4193
4207
|
}
|
|
4194
|
-
let
|
|
4208
|
+
let pr = Pn({
|
|
4195
4209
|
coordinator: [
|
|
4196
4210
|
"postgres",
|
|
4197
4211
|
"mariadb",
|
|
4198
4212
|
"mysql",
|
|
4199
4213
|
"mssql"
|
|
4200
|
-
].includes(
|
|
4201
|
-
replicaId:
|
|
4214
|
+
].includes(or) ? wn(B, lr, $) : Tr,
|
|
4215
|
+
replicaId: lr,
|
|
4202
4216
|
log: $
|
|
4203
|
-
}),
|
|
4204
|
-
...
|
|
4217
|
+
}), hr = [], _r = {
|
|
4218
|
+
...dr ? { sql: dr } : {},
|
|
4205
4219
|
scheduleCoordinated: (e, t, n) => {
|
|
4206
|
-
let r =
|
|
4207
|
-
return
|
|
4220
|
+
let r = pr(e, t, n);
|
|
4221
|
+
return hr.push(r), r;
|
|
4208
4222
|
}
|
|
4209
4223
|
};
|
|
4210
|
-
for (let e of I?.plugins ?? []) e.bindDataStore?.(B,
|
|
4211
|
-
let
|
|
4224
|
+
for (let e of I?.plugins ?? []) e.bindDataStore?.(B, _r);
|
|
4225
|
+
let vr = await Au(B, I, Ou(I), $);
|
|
4212
4226
|
I?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = I.cache), I?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = I.cacheRedisUrl), I?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = I.cacheRedisDriver), I?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = I.cacheKeyPrefix);
|
|
4213
|
-
let { service:
|
|
4214
|
-
$.info(`cache backend resolved: ${
|
|
4215
|
-
let { kv: Mr, service:
|
|
4216
|
-
$.info(`kv backend resolved: ${
|
|
4217
|
-
let
|
|
4227
|
+
let { service: yr, invalidationBus: br, snapshotCache: wr, cache: Er, backend: kr, stats: Ar, dispose: jr } = await io({ env: process.env });
|
|
4228
|
+
$.info(`cache backend resolved: ${kr}` + (kr === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), I?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = I.kv), I?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = I.kvRedisUrl), I?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = I.kvKeyPrefix);
|
|
4229
|
+
let { kv: Mr, service: Pr, backend: Fr } = await kn({ store: B });
|
|
4230
|
+
$.info(`kv backend resolved: ${Fr}` + (Fr === "database" ? " (durable, _voltro_kv)" : Fr === "memory" ? " — in-process, non-durable" : ` (driver ${process.env.KV_REDIS_DRIVER ?? "resp"}, non-durable)`));
|
|
4231
|
+
let Br = Ou(I), Wr = I?.analytics !== void 0 && I.analytics.kind !== "noop" && Br !== "memory" ? (await b(Br)).makeSqlLayer(xu()) : void 0, ti = await ms({
|
|
4218
4232
|
spec: I?.analytics,
|
|
4219
|
-
sqlLayer:
|
|
4233
|
+
sqlLayer: Wr,
|
|
4220
4234
|
log: $
|
|
4221
4235
|
});
|
|
4222
|
-
|
|
4223
|
-
let
|
|
4236
|
+
ti.spec;
|
|
4237
|
+
let ni = ti.sink, ri = Kt({
|
|
4224
4238
|
store: B,
|
|
4225
|
-
sink:
|
|
4239
|
+
sink: ni,
|
|
4226
4240
|
log: $
|
|
4227
4241
|
});
|
|
4228
|
-
|
|
4229
|
-
provider:
|
|
4230
|
-
tables:
|
|
4242
|
+
ri.tables.length > 0 && $.info("analytics mirror", {
|
|
4243
|
+
provider: ni.info.provider,
|
|
4244
|
+
tables: ri.tables
|
|
4231
4245
|
}), V(() => {
|
|
4232
|
-
|
|
4246
|
+
ri.detach();
|
|
4233
4247
|
});
|
|
4234
|
-
let ui =
|
|
4248
|
+
let ui = ti.dispose, fi = Ou(I), mi;
|
|
4235
4249
|
if (fi !== "memory" && process.env.VOLTRO_AUTO_MIGRATE !== "0") {
|
|
4236
4250
|
let e = Date.now(), t = (process.env.NODE_ENV ?? "").toLowerCase() === "production" ? "prod" : (process.env.NODE_ENV ?? "").toLowerCase() === "staging" ? "staging" : "dev";
|
|
4237
4251
|
$.info("auto-migrate: planning schema", {
|
|
@@ -4243,27 +4257,27 @@ ${a.join("\n\n")}\n`);
|
|
|
4243
4257
|
tablesTotal: z.length
|
|
4244
4258
|
});
|
|
4245
4259
|
try {
|
|
4246
|
-
let n = await b(fi), r = n.makeSqlLayer(
|
|
4247
|
-
|
|
4248
|
-
let i =
|
|
4249
|
-
conn:
|
|
4250
|
-
pendingIds: await P.runPromise(
|
|
4251
|
-
optIn: process.env[
|
|
4260
|
+
let n = await b(fi), r = n.makeSqlLayer(xu());
|
|
4261
|
+
mi = r, await pa(du(z.filter((e) => e.tableName.startsWith("_voltro_") || e.tableName === "voltro_isr_cache"), z), r, n.id);
|
|
4262
|
+
let i = ro({
|
|
4263
|
+
conn: xu(),
|
|
4264
|
+
pendingIds: await P.runPromise(Rr.SqlClient.pipe(P.flatMap((e) => ua(e, p)), P.provide(r))),
|
|
4265
|
+
optIn: process.env[$a] === "1"
|
|
4252
4266
|
});
|
|
4253
4267
|
if (!i.allowed) throw $.error(`file-based migrations: ${i.message}`), Error("file-based migrations refused — see error above");
|
|
4254
|
-
let a = await P.runPromise(
|
|
4268
|
+
let a = await P.runPromise(Rr.SqlClient.pipe(P.flatMap((e) => fa(e, {
|
|
4255
4269
|
projectRoot: p,
|
|
4256
4270
|
env: t,
|
|
4257
4271
|
appliedBy: `boot:${t}`
|
|
4258
4272
|
})), P.provide(r)));
|
|
4259
4273
|
a.applied.length > 0 && $.info(`file-based migrations: applied ${a.applied.length}`, { applied: a.applied.map((e) => `${e.id} (${e.durationMs}ms)`) });
|
|
4260
|
-
let o = await P.runPromise(
|
|
4274
|
+
let o = await P.runPromise(Rr.SqlClient.pipe(P.flatMap((e) => ma(e, z, {
|
|
4261
4275
|
appliedBy: `boot:${t}`,
|
|
4262
4276
|
environment: t,
|
|
4263
4277
|
dialectId: n.id
|
|
4264
4278
|
})), P.provide(r)));
|
|
4265
|
-
if (o.kind === "refused-blocked" || o.kind === "prod-mismatch") throw $.error(
|
|
4266
|
-
$.info(
|
|
4279
|
+
if (o.kind === "refused-blocked" || o.kind === "prod-mismatch") throw $.error(sa(o, n.id)), Error("auto-migrate refused — see error above");
|
|
4280
|
+
$.info(sa(o, n.id), { durationMs: Date.now() - e });
|
|
4267
4281
|
} catch (e) {
|
|
4268
4282
|
throw $.error("auto-migrate failed — aborting boot", { err: e }), Te?.set({
|
|
4269
4283
|
phase: "error",
|
|
@@ -4271,9 +4285,9 @@ ${a.join("\n\n")}\n`);
|
|
|
4271
4285
|
}), e;
|
|
4272
4286
|
}
|
|
4273
4287
|
} else fi !== "memory" && $.info("auto-migrate: skipped (VOLTRO_AUTO_MIGRATE=0)");
|
|
4274
|
-
let
|
|
4275
|
-
if ((I?.plugins ?? []).some((e) => (e.extendSchema?.migrations?.length ?? 0) > 0) &&
|
|
4276
|
-
let e = (await b(
|
|
4288
|
+
let hi = Ou(I);
|
|
4289
|
+
if ((I?.plugins ?? []).some((e) => (e.extendSchema?.migrations?.length ?? 0) > 0) && hi !== "memory") {
|
|
4290
|
+
let e = (await b(hi)).makeSqlLayer(xu());
|
|
4277
4291
|
try {
|
|
4278
4292
|
let t = await P.runPromise(fe(I.plugins).pipe(P.provide(e))), n = t.filter((e) => e.status === "applied"), r = t.filter((e) => e.status === "skipped");
|
|
4279
4293
|
$.info("plugin migrations complete", {
|
|
@@ -4284,101 +4298,101 @@ ${a.join("\n\n")}\n`);
|
|
|
4284
4298
|
throw $.error("plugin migrations failed — aborting boot", { err: e }), e;
|
|
4285
4299
|
}
|
|
4286
4300
|
}
|
|
4287
|
-
let gi =
|
|
4301
|
+
let gi = Il(B, C);
|
|
4288
4302
|
V(() => {
|
|
4289
4303
|
gi();
|
|
4290
4304
|
});
|
|
4291
|
-
let
|
|
4292
|
-
|
|
4305
|
+
let vi = Yn(z);
|
|
4306
|
+
Sr({
|
|
4293
4307
|
dataStore: B,
|
|
4294
|
-
schemaRegistry:
|
|
4308
|
+
schemaRegistry: vi
|
|
4295
4309
|
});
|
|
4296
|
-
let
|
|
4310
|
+
let yi = $.child("seeds"), Ci = w.filter((e) => /\.seed\.ts$/.test(e)), Ei = Ci.length > 0 ? await ie(Ci, yi) : [];
|
|
4297
4311
|
if (Ei.length > 0) {
|
|
4298
|
-
|
|
4312
|
+
yi.info("discovered seeds", { ids: Ei.map((e) => e.definition.id) });
|
|
4299
4313
|
for (let e of Ei) ct.registerSeed(e);
|
|
4300
|
-
let e = await ae(Ei, B,
|
|
4314
|
+
let e = await ae(Ei, B, yi);
|
|
4301
4315
|
for (let t of e) ct.recordSeedResult(t);
|
|
4302
4316
|
let t = e.filter((e) => e.status === "failed");
|
|
4303
|
-
t.length > 0 &&
|
|
4317
|
+
t.length > 0 && yi.warn("one or more seeds failed (server continues)", { failedIds: t.map((e) => e.seedId) });
|
|
4304
4318
|
}
|
|
4305
|
-
let
|
|
4306
|
-
|
|
4307
|
-
let
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
}), mn(),
|
|
4311
|
-
let
|
|
4312
|
-
handlers:
|
|
4319
|
+
let Oi = $.child("startup"), ki = w.filter((e) => Re.test(e)), ji = ki.length > 0 ? await st(ki, Oi) : [], Mi;
|
|
4320
|
+
ji.length > 0 && (Oi.info("discovered startups", { ids: ji.map((e) => e.id) }), Mi = await ot(ji, B, Oi)), Mi && V(() => Mi.shutdown());
|
|
4321
|
+
let Ni = $.child("subscribe"), Pi = w.filter((e) => ke.test(e)), Fi = Pi.length > 0 ? await Ds(Pi, Ni) : [], Ri;
|
|
4322
|
+
Fi.length > 0 && (Ni.info("discovered subscribers", { subscribers: Fi.map((e) => `${e.id}@${e.definition.table}`) }), Ri = Os(Fi, B, Ni, vi)), Ri && V(() => {
|
|
4323
|
+
Ri();
|
|
4324
|
+
}), mn(), Cr((e) => xn(B, e.subjectId, e.resourceType, e.resourceId));
|
|
4325
|
+
let Vi = $.child("outbox"), Hi = w.filter((e) => Pe.test(e)), Ui = Hi.length > 0 ? await As(Hi, Vi) : [], Wi = Ui.length > 0 ? js({
|
|
4326
|
+
handlers: Ui,
|
|
4313
4327
|
store: B,
|
|
4314
|
-
log:
|
|
4328
|
+
log: Vi
|
|
4315
4329
|
}) : void 0;
|
|
4316
|
-
|
|
4317
|
-
|
|
4330
|
+
Wi && V(() => {
|
|
4331
|
+
Wi.stop();
|
|
4318
4332
|
});
|
|
4319
|
-
let
|
|
4320
|
-
if (yn.length > 0 &&
|
|
4321
|
-
|
|
4333
|
+
let na = Ks(), ra = Ou(I);
|
|
4334
|
+
if (yn.length > 0 && ra !== "memory") try {
|
|
4335
|
+
na = Zs((await b(ra)).makeSqlLayer(xu()));
|
|
4322
4336
|
} catch (e) {
|
|
4323
4337
|
hn.warn("aggregate: SQL storage init failed — falling back to in-process", { err: e });
|
|
4324
4338
|
}
|
|
4325
|
-
let
|
|
4339
|
+
let ia = ra === "memory" ? Tr : wn(B, `aggregate@${process.pid}`, hn), aa = yn.length > 0 ? await dc({
|
|
4326
4340
|
discovered: yn,
|
|
4327
4341
|
store: B,
|
|
4328
|
-
analytics:
|
|
4329
|
-
storage:
|
|
4330
|
-
coordinator:
|
|
4342
|
+
analytics: ni,
|
|
4343
|
+
storage: na,
|
|
4344
|
+
coordinator: ia,
|
|
4331
4345
|
log: hn
|
|
4332
4346
|
}) : {
|
|
4333
|
-
registry:
|
|
4347
|
+
registry: fc,
|
|
4334
4348
|
detach: () => {},
|
|
4335
4349
|
registered: []
|
|
4336
4350
|
};
|
|
4337
|
-
|
|
4338
|
-
names:
|
|
4339
|
-
storage:
|
|
4340
|
-
coordination:
|
|
4351
|
+
aa.registered.length > 0 && hn.info("aggregates registered", {
|
|
4352
|
+
names: aa.registered,
|
|
4353
|
+
storage: ra === "memory" ? "in-process" : "sql-backed",
|
|
4354
|
+
coordination: ia.kind
|
|
4341
4355
|
}), V(() => {
|
|
4342
|
-
|
|
4356
|
+
aa.detach();
|
|
4343
4357
|
});
|
|
4344
|
-
let U =
|
|
4358
|
+
let U = Ou(I), ha, ga = I?.scheduling ?? {}, _a = ga.trigger ?? "self", va = ga.coordination ?? ([
|
|
4345
4359
|
"postgres",
|
|
4346
4360
|
"mariadb",
|
|
4347
4361
|
"mysql",
|
|
4348
4362
|
"mssql"
|
|
4349
|
-
].includes(U) ? "advisoryLock" : "single"),
|
|
4363
|
+
].includes(U) ? "advisoryLock" : "single"), Sa = va === "cluster" && (/* @__PURE__ */ new Set([
|
|
4350
4364
|
"postgres",
|
|
4351
4365
|
"mysql",
|
|
4352
4366
|
"mariadb",
|
|
4353
4367
|
"mssql"
|
|
4354
|
-
])).has(U),
|
|
4368
|
+
])).has(U), Ca = Sa ? ft.filter((e) => (e.trigger ?? _a) === "self").map((e) => Xr({
|
|
4355
4369
|
name: e.name,
|
|
4356
4370
|
cron: en(e),
|
|
4357
4371
|
execute: async () => {
|
|
4358
|
-
await
|
|
4372
|
+
await ha?.fireFromCluster(e.name);
|
|
4359
4373
|
}
|
|
4360
|
-
})) : [],
|
|
4361
|
-
if (U === "memory") return
|
|
4362
|
-
let e = await b(U), t = e.makeSqlLayer(
|
|
4363
|
-
if ($.info(`workflow engine: cluster-${n}, dialect=${e.id}` + (n === "memory" ? " — single-process durable replay, no horizontal scaling" + (
|
|
4364
|
-
let e = await
|
|
4374
|
+
})) : [], wa = await (async () => {
|
|
4375
|
+
if (U === "memory") return zr.layerMemory;
|
|
4376
|
+
let e = await b(U), t = e.makeSqlLayer(xu()), n = $r({ sqliteFamily: di(e.id) });
|
|
4377
|
+
if ($.info(`workflow engine: cluster-${n}, dialect=${e.id}` + (n === "memory" ? " — single-process durable replay, no horizontal scaling" + (di(e.id) ? "" : " (VOLTRO_WORKFLOW_RUNNER_STORAGE=memory: SqlRunnerStorage/cluster_runners + GET_LOCK skipped)") : "")), e.id === "mssql") {
|
|
4378
|
+
let e = await Cs(process.cwd());
|
|
4365
4379
|
e && $.warn(e);
|
|
4366
4380
|
}
|
|
4367
|
-
return
|
|
4381
|
+
return ei({
|
|
4368
4382
|
sqlClientLayer: t,
|
|
4369
4383
|
runnerStorage: n,
|
|
4370
4384
|
dialectId: e.id,
|
|
4371
4385
|
...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
|
|
4372
|
-
...
|
|
4386
|
+
...Ca.length > 0 ? { extraShardingLayers: Ca } : {}
|
|
4373
4387
|
});
|
|
4374
4388
|
})();
|
|
4375
4389
|
$.info("workflow engine selected", { engine: U === "postgres" ? "cluster-postgres" : "in-memory" });
|
|
4376
|
-
let
|
|
4390
|
+
let Ta, Ea = /* @__PURE__ */ new Map(), ja = () => `wfctx_${globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`, Na = async (e, t, n) => {
|
|
4377
4391
|
let r = {
|
|
4378
4392
|
...n,
|
|
4379
4393
|
source: n.source ?? `workflow:${e}`
|
|
4380
4394
|
};
|
|
4381
|
-
|
|
4395
|
+
Ea.set(t, r);
|
|
4382
4396
|
try {
|
|
4383
4397
|
let n = await B.query({
|
|
4384
4398
|
table: "_voltro_workflow_start_contexts",
|
|
@@ -4408,8 +4422,8 @@ ${a.join("\n\n")}\n`);
|
|
|
4408
4422
|
reason: n?.message ?? String(n)
|
|
4409
4423
|
});
|
|
4410
4424
|
}
|
|
4411
|
-
},
|
|
4412
|
-
let n =
|
|
4425
|
+
}, Fa = async (e, t) => {
|
|
4426
|
+
let n = Ea.get(t);
|
|
4413
4427
|
if (n !== void 0) return n;
|
|
4414
4428
|
try {
|
|
4415
4429
|
let e = (await B.query({
|
|
@@ -4434,7 +4448,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4434
4448
|
...e.parentExecutionId === null ? {} : { parentExecutionId: e.parentExecutionId },
|
|
4435
4449
|
...e.parentClosePolicy === null ? {} : { parentClosePolicy: e.parentClosePolicy }
|
|
4436
4450
|
};
|
|
4437
|
-
return
|
|
4451
|
+
return Ea.set(t, r), r;
|
|
4438
4452
|
} catch (e) {
|
|
4439
4453
|
$.warn("workflow.startContext.resolve failed", {
|
|
4440
4454
|
executionId: t,
|
|
@@ -4442,26 +4456,26 @@ ${a.join("\n\n")}\n`);
|
|
|
4442
4456
|
});
|
|
4443
4457
|
return;
|
|
4444
4458
|
}
|
|
4445
|
-
}, W = N.length > 0 ? zn(() =>
|
|
4459
|
+
}, W = N.length > 0 ? zn(() => Ta) : void 0, La = $.child("webhooks"), Ra = w.filter((e) => De.test(e)), G = Ra.length > 0 ? await kc(Ra, La) : {
|
|
4446
4460
|
outgoing: [],
|
|
4447
4461
|
incoming: [],
|
|
4448
4462
|
providers: []
|
|
4449
4463
|
};
|
|
4450
|
-
G.outgoing.length + G.incoming.length + G.providers.length > 0 &&
|
|
4464
|
+
G.outgoing.length + G.incoming.length + G.providers.length > 0 && La.info("discovered webhooks", {
|
|
4451
4465
|
outgoing: G.outgoing.map((e) => e.descriptor.id),
|
|
4452
4466
|
incoming: G.incoming.map((e) => e.descriptor.id),
|
|
4453
4467
|
providers: G.providers.map((e) => e.descriptor.id)
|
|
4454
4468
|
});
|
|
4455
|
-
let
|
|
4456
|
-
if (
|
|
4457
|
-
let e = $.child("mail"), t = await
|
|
4458
|
-
t.templates.length > 0 && (
|
|
4469
|
+
let Va = w.filter((e) => Ac.test(e));
|
|
4470
|
+
if (Va.length > 0) {
|
|
4471
|
+
let e = $.child("mail"), t = await jc(Va, e);
|
|
4472
|
+
t.templates.length > 0 && (Pa(t.templates.map((e) => e.template)), e.info("discovered email templates", { templates: t.templates.map((e) => e.template.name) }));
|
|
4459
4473
|
}
|
|
4460
|
-
let
|
|
4474
|
+
let Ha = /* @__PURE__ */ new Map();
|
|
4461
4475
|
for (let e of G.incoming) {
|
|
4462
|
-
let t = e.descriptor.path ??
|
|
4476
|
+
let t = e.descriptor.path ?? ka(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = Ma(e.descriptor, {
|
|
4463
4477
|
resolveSecret: async () => process.env[n] ?? null,
|
|
4464
|
-
resolveWorkflows: () => W === void 0 ? void 0 :
|
|
4478
|
+
resolveWorkflows: () => W === void 0 ? void 0 : er(W, {
|
|
4465
4479
|
traceId: `incoming:${e.descriptor.id}`,
|
|
4466
4480
|
source: `incoming:${e.descriptor.id}`
|
|
4467
4481
|
}),
|
|
@@ -4473,36 +4487,36 @@ ${a.join("\n\n")}\n`);
|
|
|
4473
4487
|
idempotency: e.idempotency,
|
|
4474
4488
|
durationMs: e.durationMs
|
|
4475
4489
|
};
|
|
4476
|
-
e.status >= 500 ?
|
|
4490
|
+
e.status >= 500 ? La.error("incoming delivery failed", t) : e.status >= 400 ? La.warn("incoming delivery rejected", t) : La.info("incoming delivery handled", t);
|
|
4477
4491
|
}
|
|
4478
4492
|
});
|
|
4479
|
-
|
|
4493
|
+
Ha.set(t, r), La.info("mounted incoming webhook", {
|
|
4480
4494
|
id: e.descriptor.id,
|
|
4481
4495
|
path: t,
|
|
4482
4496
|
secretEnvKey: n
|
|
4483
4497
|
});
|
|
4484
4498
|
}
|
|
4485
|
-
let
|
|
4486
|
-
|
|
4499
|
+
let Ua = $.child("reaction"), Wa = w.filter((e) => Fe.test(e)), Ka = Wa.length > 0 ? await Vs(Wa, Ua) : [], qa;
|
|
4500
|
+
Ka.length > 0 && (Ua.info("discovered reactions", { reactions: Ka.map((e) => `${e.definition.name}@${e.definition.watch.table}`) }), qa = Us(Ka, B, {
|
|
4487
4501
|
runAct: async (e, t) => {
|
|
4488
4502
|
if (e.kind === "workflow") {
|
|
4489
4503
|
if (W === void 0) {
|
|
4490
|
-
|
|
4504
|
+
Ua.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: e.workflow });
|
|
4491
4505
|
return;
|
|
4492
4506
|
}
|
|
4493
4507
|
let n = t.new ?? t.old ?? {};
|
|
4494
|
-
await
|
|
4508
|
+
await er(W, {
|
|
4495
4509
|
traceId: `reaction:${e.workflow}`,
|
|
4496
4510
|
source: `reaction:${e.workflow}`
|
|
4497
4511
|
}).start(e.workflow, n);
|
|
4498
4512
|
return;
|
|
4499
4513
|
}
|
|
4500
|
-
await
|
|
4514
|
+
await Hs(e.agent, t, {
|
|
4501
4515
|
findAgentSend: (e) => k.find((t) => t.descriptor.name === `${e}.send`),
|
|
4502
|
-
runAction: (e, t, n) => Promise.resolve(
|
|
4503
|
-
makeSubject: (e) =>
|
|
4516
|
+
runAction: (e, t, n) => Promise.resolve(Yo(e, t, n)),
|
|
4517
|
+
makeSubject: (e) => Di(e),
|
|
4504
4518
|
now: () => Date.now(),
|
|
4505
|
-
log:
|
|
4519
|
+
log: Ua
|
|
4506
4520
|
});
|
|
4507
4521
|
},
|
|
4508
4522
|
checkBudget: async (e, t) => {
|
|
@@ -4513,24 +4527,24 @@ ${a.join("\n\n")}\n`);
|
|
|
4513
4527
|
limitUsd: t
|
|
4514
4528
|
}))))._tag === "Right";
|
|
4515
4529
|
} catch (t) {
|
|
4516
|
-
return
|
|
4530
|
+
return Ua.warn("reaction budget check failed — refusing the act", { tenantId: e }, t), !1;
|
|
4517
4531
|
}
|
|
4518
4532
|
}
|
|
4519
|
-
},
|
|
4520
|
-
|
|
4533
|
+
}, Ua)), qa && V(() => {
|
|
4534
|
+
qa();
|
|
4521
4535
|
});
|
|
4522
|
-
let
|
|
4536
|
+
let Ja = 0, K = new It({
|
|
4523
4537
|
store: B,
|
|
4524
4538
|
cache: wr,
|
|
4525
4539
|
recordDelivery: (e) => {
|
|
4526
|
-
|
|
4540
|
+
sr({
|
|
4527
4541
|
label: e.label,
|
|
4528
4542
|
kind: e.kind,
|
|
4529
4543
|
durationMs: e.durationMs,
|
|
4530
4544
|
rowCount: e.rowCount
|
|
4531
|
-
}),
|
|
4545
|
+
}), Xn({
|
|
4532
4546
|
traceId: e.traceId,
|
|
4533
|
-
spanId: (
|
|
4547
|
+
spanId: (Ja++).toString(16).padStart(16, "0"),
|
|
4534
4548
|
parentSpanId: e.parentSpanId ?? null,
|
|
4535
4549
|
name: `${e.label}.${e.kind}`,
|
|
4536
4550
|
kind: "internal",
|
|
@@ -4544,10 +4558,10 @@ ${a.join("\n\n")}\n`);
|
|
|
4544
4558
|
status: "ok"
|
|
4545
4559
|
});
|
|
4546
4560
|
}
|
|
4547
|
-
}),
|
|
4561
|
+
}), Xa = () => {
|
|
4548
4562
|
let e = K.subscriptionSnapshot(), t = K.matcherStats(), n = e.map((e) => {
|
|
4549
4563
|
let t = [];
|
|
4550
|
-
for (let n of
|
|
4564
|
+
for (let n of bi(e.predicate)) n.conjunctive && t.push(n.column);
|
|
4551
4565
|
return {
|
|
4552
4566
|
fingerprint: e.fingerprint,
|
|
4553
4567
|
table: e.table,
|
|
@@ -4563,21 +4577,21 @@ ${a.join("\n\n")}\n`);
|
|
|
4563
4577
|
capturedAt: Date.now()
|
|
4564
4578
|
});
|
|
4565
4579
|
};
|
|
4566
|
-
K.onSubscriptionsChange(
|
|
4567
|
-
let
|
|
4580
|
+
K.onSubscriptionsChange(Xa), Xa();
|
|
4581
|
+
let Za = $.child("store"), eo = (I?.plugins ?? []).filter((e) => typeof e.onChangeEvent == "function"), to = B.changeScope ?? "local";
|
|
4568
4582
|
B.onChange((e) => {
|
|
4569
|
-
if (
|
|
4583
|
+
if (Za.debug(`${e.op} on ${e.table}`, {
|
|
4570
4584
|
op: e.op,
|
|
4571
4585
|
table: e.table
|
|
4572
|
-
}),
|
|
4586
|
+
}), cr({
|
|
4573
4587
|
table: e.table,
|
|
4574
4588
|
op: e.op,
|
|
4575
4589
|
old: e.old ?? null,
|
|
4576
4590
|
new: e.new ?? null
|
|
4577
|
-
}), P.runFork(
|
|
4578
|
-
let t =
|
|
4579
|
-
for (let n of
|
|
4580
|
-
let r =
|
|
4591
|
+
}), P.runFork(br.publish(e.table)), eo.length > 0) {
|
|
4592
|
+
let t = zs(e, to);
|
|
4593
|
+
for (let n of eo) {
|
|
4594
|
+
let r = Za.child(`plugin:${n.name}`);
|
|
4581
4595
|
P.runFork(n.onChangeEvent(t).pipe(P.catchAllCause((t) => P.sync(() => r.warn("onChangeEvent failed", {
|
|
4582
4596
|
table: e.table,
|
|
4583
4597
|
op: e.op
|
|
@@ -4585,95 +4599,95 @@ ${a.join("\n\n")}\n`);
|
|
|
4585
4599
|
}
|
|
4586
4600
|
}
|
|
4587
4601
|
});
|
|
4588
|
-
let
|
|
4602
|
+
let no = N.map((e) => Ir.make(e.definition.name, {
|
|
4589
4603
|
payload: e.definition.payloadSchema,
|
|
4590
|
-
success:
|
|
4604
|
+
success: wi,
|
|
4591
4605
|
error: e.definition.errorSchema
|
|
4592
4606
|
})), fo = xt ? [
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
] : [],
|
|
4604
|
-
...
|
|
4605
|
-
...
|
|
4606
|
-
...
|
|
4607
|
-
...
|
|
4608
|
-
...
|
|
4607
|
+
zi(Xi),
|
|
4608
|
+
zi(Qi),
|
|
4609
|
+
zi(Zi),
|
|
4610
|
+
zi(Yi),
|
|
4611
|
+
zi(Ki),
|
|
4612
|
+
zi(qi),
|
|
4613
|
+
Ti(Gi),
|
|
4614
|
+
Ti(Ji),
|
|
4615
|
+
Ti($i),
|
|
4616
|
+
Ti(ea)
|
|
4617
|
+
] : [], mo = (I?.plugins ?? []).flatMap((e) => (e.errorSchemas ?? []).map((e) => e.schema)), ho = mo.length > 0 ? mo : void 0, go = (e) => e.filter((e) => Ii(e.descriptor)), _o = go(T), vo = go(D), yo = go(k), bo = go(M), q = [
|
|
4618
|
+
..._o.map((e) => zi(e.descriptor, ho)),
|
|
4619
|
+
...vo.map((e) => Li(e.descriptor, ho)),
|
|
4620
|
+
...yo.map((e) => Ti(e.descriptor, ho)),
|
|
4621
|
+
...bo.map((e) => Bi(e.descriptor, ho)),
|
|
4622
|
+
...no,
|
|
4609
4623
|
...fo
|
|
4610
|
-
],
|
|
4611
|
-
analyticsLayer:
|
|
4612
|
-
cacheService:
|
|
4613
|
-
kvService:
|
|
4614
|
-
pluginServices:
|
|
4615
|
-
userLayers:
|
|
4616
|
-
}),
|
|
4617
|
-
(
|
|
4618
|
-
userLayers:
|
|
4619
|
-
pluginLayers:
|
|
4624
|
+
], xo = Lr.make(...q).middleware(xi).middleware(Si), So = I?.layers ?? [], Co = (I?.plugins ?? []).map((e) => e.services).filter((e) => e !== void 0), wo = F.succeed(Mt, aa.registry), To = F.mergeAll(uo({
|
|
4625
|
+
analyticsLayer: ti.layer,
|
|
4626
|
+
cacheService: yr,
|
|
4627
|
+
kvService: Pr,
|
|
4628
|
+
pluginServices: Co,
|
|
4629
|
+
userLayers: So
|
|
4630
|
+
}), wo);
|
|
4631
|
+
(So.length > 0 || Co.length > 0) && $.info("layers loaded", {
|
|
4632
|
+
userLayers: So.length,
|
|
4633
|
+
pluginLayers: Co.length
|
|
4620
4634
|
});
|
|
4621
|
-
let
|
|
4635
|
+
let Eo = (e, t) => gr(e.pipe(P.provide(Ln(t)), P.provide(To), P.provide(wt)));
|
|
4622
4636
|
if ((process.env.VOLTRO_INDEX_AUDIT ?? "on") !== "off") {
|
|
4623
|
-
let e =
|
|
4624
|
-
for (let n of e) $.warn("\n" +
|
|
4637
|
+
let e = oi(z), t = process.stdout.isTTY === !0 && (process.env.NO_COLOR ?? "") === "";
|
|
4638
|
+
for (let n of e) $.warn("\n" + li(n, {
|
|
4625
4639
|
color: t,
|
|
4626
4640
|
indent: " "
|
|
4627
4641
|
}));
|
|
4628
4642
|
}
|
|
4629
4643
|
let J;
|
|
4630
4644
|
if (G.outgoing.length > 0) {
|
|
4631
|
-
let e =
|
|
4645
|
+
let e = oo({
|
|
4632
4646
|
store: B,
|
|
4633
|
-
schemaRegistry:
|
|
4634
|
-
cache:
|
|
4647
|
+
schemaRegistry: vi,
|
|
4648
|
+
cache: Er,
|
|
4635
4649
|
kv: Mr
|
|
4636
4650
|
}), t = G.outgoing.map((e) => e.descriptor);
|
|
4637
|
-
J =
|
|
4638
|
-
let r =
|
|
4651
|
+
J = Oa(e, async (n) => {
|
|
4652
|
+
let r = Aa.execute(n).pipe(P.provide(Aa.toLayer(Da(e, { events: t })).pipe(F.provideMerge(wa))));
|
|
4639
4653
|
P.runPromise(r).catch((e) => {
|
|
4640
|
-
|
|
4654
|
+
La.error("deliverWebhook workflow crashed", {
|
|
4641
4655
|
deliveryId: n.deliveryId,
|
|
4642
4656
|
targetId: n.targetId
|
|
4643
4657
|
}, e);
|
|
4644
4658
|
});
|
|
4645
4659
|
}, { events: t });
|
|
4646
4660
|
}
|
|
4647
|
-
let
|
|
4648
|
-
|
|
4649
|
-
let
|
|
4661
|
+
let Do = (process.env.VOLTRO_TENANT_ISOLATION ?? I?.tenancy?.isolation) === "namespace";
|
|
4662
|
+
Do && $.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.");
|
|
4663
|
+
let Oo = so({
|
|
4650
4664
|
store: B,
|
|
4651
|
-
schemaRegistry:
|
|
4652
|
-
cache:
|
|
4665
|
+
schemaRegistry: vi,
|
|
4666
|
+
cache: Er,
|
|
4653
4667
|
kv: Mr,
|
|
4654
4668
|
...J === void 0 ? {} : { webhooksService: J },
|
|
4655
4669
|
...W === void 0 ? {} : { workflowsProxy: W },
|
|
4656
4670
|
eventTriggers: ut,
|
|
4657
|
-
namespaceIsolationOn:
|
|
4671
|
+
namespaceIsolationOn: Do,
|
|
4658
4672
|
onEventEmit: (e, t) => C.emit(e, t),
|
|
4659
|
-
...
|
|
4660
|
-
...
|
|
4661
|
-
}),
|
|
4673
|
+
...Wi === void 0 ? {} : { outbox: { nudge: Wi.nudge } },
|
|
4674
|
+
...ir.active ? { connections: { registry: ir.registry } } : {}
|
|
4675
|
+
}), ko = async () => {
|
|
4662
4676
|
if (ft.length === 0) return;
|
|
4663
4677
|
let e = process.env.HOSTNAME ?? `pid-${process.pid}`, t;
|
|
4664
|
-
|
|
4678
|
+
Sa ? t = Tr : va === "cluster" ? ($.warn("scheduling.coordination=cluster needs store=postgres — falling back to single (dev/memory)"), t = Tr) : va === "advisoryLock" ? U === "memory" ? ($.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single (memory)"), t = Tr) : t = wn(B, e, {
|
|
4665
4679
|
info: (e, t) => $.info(e, t ?? {}),
|
|
4666
4680
|
warn: (e, t) => $.warn(e, t ?? {})
|
|
4667
|
-
}) : t =
|
|
4668
|
-
let n =
|
|
4669
|
-
|
|
4681
|
+
}) : t = Tr;
|
|
4682
|
+
let n = il(I?.plugins ?? [], Bo);
|
|
4683
|
+
ha = await Or(ft, {
|
|
4670
4684
|
store: B,
|
|
4671
4685
|
coordinator: t,
|
|
4672
|
-
defaultTrigger:
|
|
4686
|
+
defaultTrigger: _a,
|
|
4673
4687
|
replicaId: e,
|
|
4674
|
-
armSelf: !
|
|
4688
|
+
armSelf: !Sa,
|
|
4675
4689
|
dormancy: I?.dormancy ?? "always-on",
|
|
4676
|
-
buildContext: ({ traceId: e, scheduleName: t, subject: n }) =>
|
|
4690
|
+
buildContext: ({ traceId: e, scheduleName: t, subject: n }) => Oo({
|
|
4677
4691
|
subject: n,
|
|
4678
4692
|
traceId: e
|
|
4679
4693
|
}, B, void 0, `schedule:${t}`),
|
|
@@ -4690,43 +4704,43 @@ ${a.join("\n\n")}\n`);
|
|
|
4690
4704
|
...n === void 0 ? {} : { interceptFire: n }
|
|
4691
4705
|
}), $.info("scheduler ready", {
|
|
4692
4706
|
schedules: ft.length,
|
|
4693
|
-
coordination:
|
|
4694
|
-
clusterCrons:
|
|
4695
|
-
}), V(() =>
|
|
4696
|
-
}, Y = {},
|
|
4697
|
-
gn(e, _t, t) && (
|
|
4707
|
+
coordination: Sa ? "cluster" : t.kind,
|
|
4708
|
+
clusterCrons: Ca.length
|
|
4709
|
+
}), V(() => ha?.shutdown());
|
|
4710
|
+
}, Y = {}, Ao = /* @__PURE__ */ new Set(), jo = (e, t) => {
|
|
4711
|
+
gn(e, _t, t) && (Ao.has(e.table) || (Ao.add(e.table), $.warn("tenant-scoped read with an EMPTY tenant — every row is filtered out", {
|
|
4698
4712
|
table: e.table,
|
|
4699
4713
|
tenantId: "",
|
|
4700
4714
|
cause: "the subject authenticated but has no resolved org (tenantId=''), so the auto-merged `eq('tenantId', '')` matches no real row — this is NOT 'no such row'",
|
|
4701
4715
|
fix: "resolve the subject to an active org before the read, or mark the query `.unscoped()` if it is deliberately cross-tenant"
|
|
4702
4716
|
})));
|
|
4703
|
-
},
|
|
4704
|
-
|
|
4717
|
+
}, Mo = !1, No = (e) => {
|
|
4718
|
+
Mo || !_n(e) || (Mo = !0, $.warn("authenticated subject has NO active org (tenantId='') — every tenant-scoped read will be empty", {
|
|
4705
4719
|
subjectType: "user",
|
|
4706
4720
|
cause: "the session resolved a user but no organization/tenant; the empty-string sentinel fails closed",
|
|
4707
4721
|
fix: "resolve the user to an active org during auth, or route org-less users to an onboarding flow"
|
|
4708
4722
|
}));
|
|
4709
|
-
},
|
|
4723
|
+
}, Po = (e, t) => (No(t.subject), jo(e, t.subject.tenantId), Ht(Ut(e, _t, t.subject.tenantId), vt)), Fo = /* @__PURE__ */ new Set(), Io = (e) => {
|
|
4710
4724
|
if (e.usingIndex !== void 0 || e.predicate === void 0) return;
|
|
4711
4725
|
let t = /* @__PURE__ */ new Set();
|
|
4712
|
-
for (let n of
|
|
4713
|
-
if (t.size === 0 ||
|
|
4726
|
+
for (let n of bi(e.predicate)) n.conjunctive && t.add(n.column);
|
|
4727
|
+
if (t.size === 0 || vi.anyFieldIndexed(e.table, t)) return;
|
|
4714
4728
|
let n = `${e.table}::${[...t].sort().join(",")}`;
|
|
4715
|
-
|
|
4729
|
+
Fo.has(n) || (Fo.add(n), $.warn("non-indexed predicate — slow at scale", {
|
|
4716
4730
|
table: e.table,
|
|
4717
4731
|
fields: [...t],
|
|
4718
4732
|
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"
|
|
4719
4733
|
}));
|
|
4720
|
-
},
|
|
4734
|
+
}, Lo = (e) => {
|
|
4721
4735
|
if (e.usingIndex === void 0) return;
|
|
4722
|
-
let t =
|
|
4736
|
+
let t = vi.tables.get(e.table);
|
|
4723
4737
|
if (!t) return;
|
|
4724
4738
|
let n = t.compositeIndexes.find((t) => t.name === e.usingIndex);
|
|
4725
4739
|
if (n) return {
|
|
4726
4740
|
name: n.name,
|
|
4727
4741
|
fields: n.fields
|
|
4728
4742
|
};
|
|
4729
|
-
},
|
|
4743
|
+
}, Ro = (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), zo = (e, t) => {
|
|
4730
4744
|
let n = e.cache;
|
|
4731
4745
|
if (n === void 0) return;
|
|
4732
4746
|
let r = g(n.ttl);
|
|
@@ -4734,54 +4748,58 @@ ${a.join("\n\n")}\n`);
|
|
|
4734
4748
|
ttlMs: r,
|
|
4735
4749
|
swrMs: n.swr === void 0 ? void 0 : g(n.swr) ?? void 0,
|
|
4736
4750
|
scope: n.scope,
|
|
4737
|
-
baseKey: `q:${e.name}:${
|
|
4751
|
+
baseKey: `q:${e.name}:${Ro(t)}`
|
|
4738
4752
|
};
|
|
4739
|
-
},
|
|
4753
|
+
}, Bo = te(), Vo = I?.plugins ?? [], Ho = Ai(Zc(Vo, "mutation", Bo)), Uo = Ai(Zc(Vo, "action", Bo)), qo = Ai(Zc(Vo, "query", Bo)), Jo = Hn({
|
|
4740
4754
|
store: B,
|
|
4741
|
-
buildContext: (e, t, n) =>
|
|
4742
|
-
runEffect: (e, t) =>
|
|
4743
|
-
...
|
|
4744
|
-
recordMetric: (e) =>
|
|
4745
|
-
undoCapture:
|
|
4746
|
-
}),
|
|
4747
|
-
buildContext: (e) =>
|
|
4748
|
-
runEffect: (e, t) =>
|
|
4749
|
-
...
|
|
4750
|
-
recordMetric: (e) =>
|
|
4751
|
-
}),
|
|
4752
|
-
buildContext: (e) =>
|
|
4755
|
+
buildContext: (e, t, n) => Oo(e, t, n),
|
|
4756
|
+
runEffect: (e, t) => Eo(e, t),
|
|
4757
|
+
...Ho ? { interceptor: Ho } : {},
|
|
4758
|
+
recordMetric: (e) => Bo.record(e),
|
|
4759
|
+
undoCapture: Ic()
|
|
4760
|
+
}), Yo = Cn({
|
|
4761
|
+
buildContext: (e) => Oo(e),
|
|
4762
|
+
runEffect: (e, t) => Eo(e, t),
|
|
4763
|
+
...Uo ? { interceptor: Uo } : {},
|
|
4764
|
+
recordMetric: (e) => Bo.record(e)
|
|
4765
|
+
}), Xo = {
|
|
4766
|
+
buildContext: (e) => Oo(e),
|
|
4753
4767
|
finalize: (e, t) => {
|
|
4754
|
-
let n =
|
|
4755
|
-
return
|
|
4768
|
+
let n = Po(e, t);
|
|
4769
|
+
return Io(n), n;
|
|
4756
4770
|
},
|
|
4757
|
-
provideEffect: (e, t) => e.pipe(P.provide(Ln(t)), P.provide(
|
|
4758
|
-
...
|
|
4759
|
-
},
|
|
4760
|
-
...
|
|
4771
|
+
provideEffect: (e, t) => e.pipe(P.provide(Ln(t)), P.provide(To), P.provide(wt)),
|
|
4772
|
+
...qo ? { interceptor: qo } : {}
|
|
4773
|
+
}, Zo = Kn(Xo), Qo = Un({
|
|
4774
|
+
...Xo,
|
|
4761
4775
|
queryRows: (e) => B.query(e)
|
|
4762
|
-
}),
|
|
4763
|
-
...
|
|
4776
|
+
}), $o = Jn({
|
|
4777
|
+
...Xo,
|
|
4764
4778
|
subscribeDescriptor: (e, t, n) => K.subscribe(e, t, n),
|
|
4765
4779
|
subscribeComputed: (e, t, n) => K.subscribeComputed(e, t, n)
|
|
4766
4780
|
});
|
|
4767
|
-
for (let e of
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
}
|
|
4781
|
+
for (let e of _o) Y[e.descriptor.name] = (t) => Xt(Zo(e, t), K, `subscription.${e.descriptor.name}`, Lo, zo(e.descriptor, t), qn(e, t));
|
|
4782
|
+
let es = I?.idempotency, ts = es ? {
|
|
4783
|
+
store: rn(B),
|
|
4784
|
+
ttlMs: (typeof es == "object" ? es.ttlMs : void 0) ?? 864e5
|
|
4785
|
+
} : void 0;
|
|
4772
4786
|
for (let e of vo) {
|
|
4773
|
-
let t = `
|
|
4774
|
-
Y[e.descriptor.name] = (
|
|
4787
|
+
let t = `mutation.${e.descriptor.name}`, n = Vn(e.descriptor.output);
|
|
4788
|
+
Y[e.descriptor.name] = (r) => Jt(async (t, n) => Jo(e, t, n), r, t, n, ts);
|
|
4789
|
+
}
|
|
4790
|
+
for (let e of yo) {
|
|
4791
|
+
let t = `action.${e.descriptor.name}`, n = Vn(e.descriptor.output);
|
|
4792
|
+
Y[e.descriptor.name] = (r) => Jt(async (t, n) => Yo(e, t, n), r, t, n, ts);
|
|
4775
4793
|
}
|
|
4776
|
-
for (let e of
|
|
4794
|
+
for (let e of bo) {
|
|
4777
4795
|
let t = `stream.${e.descriptor.name}`;
|
|
4778
4796
|
Y[e.descriptor.name] = (n) => Yt((t) => {
|
|
4779
|
-
let r =
|
|
4780
|
-
return P.isEffect(i) ? i.pipe(P.provide(Ln(r.store)), P.provide(
|
|
4797
|
+
let r = Oo(t), i = e.executor(n, r);
|
|
4798
|
+
return P.isEffect(i) ? i.pipe(P.provide(Ln(r.store)), P.provide(To), P.provide(wt)) : typeof i == "object" && i && typeof i.then == "function" ? P.promise(() => i) : i;
|
|
4781
4799
|
}, t);
|
|
4782
4800
|
}
|
|
4783
|
-
xt && (Y[
|
|
4784
|
-
descriptor:
|
|
4801
|
+
xt && (Y[Xi.name] = (e) => Xt(Zo({
|
|
4802
|
+
descriptor: Xi,
|
|
4785
4803
|
executor: (e) => {
|
|
4786
4804
|
let t = e.id;
|
|
4787
4805
|
return {
|
|
@@ -4790,14 +4808,14 @@ ${a.join("\n\n")}\n`);
|
|
|
4790
4808
|
column: "startedAt",
|
|
4791
4809
|
direction: "desc"
|
|
4792
4810
|
}],
|
|
4793
|
-
predicate:
|
|
4811
|
+
predicate: pi(H("id", t), H("executionId", t)),
|
|
4794
4812
|
take: 1,
|
|
4795
4813
|
skip: void 0,
|
|
4796
4814
|
projection: void 0
|
|
4797
4815
|
};
|
|
4798
4816
|
}
|
|
4799
|
-
}, e), K, `subscription.${
|
|
4800
|
-
descriptor:
|
|
4817
|
+
}, e), K, `subscription.${Xi.name}`), Y[Qi.name] = (e) => Xt(Zo({
|
|
4818
|
+
descriptor: Qi,
|
|
4801
4819
|
executor: (e) => {
|
|
4802
4820
|
let t = e, n = [...t.tag === void 0 ? [] : [H("tag", t.tag)], ...t.status === void 0 ? [] : [H("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
|
|
4803
4821
|
return {
|
|
@@ -4806,14 +4824,14 @@ ${a.join("\n\n")}\n`);
|
|
|
4806
4824
|
column: "startedAt",
|
|
4807
4825
|
direction: "desc"
|
|
4808
4826
|
}],
|
|
4809
|
-
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] :
|
|
4827
|
+
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : ai(...n),
|
|
4810
4828
|
take: r,
|
|
4811
4829
|
skip: void 0,
|
|
4812
4830
|
projection: void 0
|
|
4813
4831
|
};
|
|
4814
4832
|
}
|
|
4815
|
-
}, e), K, `subscription.${
|
|
4816
|
-
descriptor:
|
|
4833
|
+
}, e), K, `subscription.${Qi.name}`), Y[Zi.name] = (e) => Xt(Zo({
|
|
4834
|
+
descriptor: Zi,
|
|
4817
4835
|
executor: (e) => {
|
|
4818
4836
|
let t = e.runId;
|
|
4819
4837
|
return {
|
|
@@ -4828,8 +4846,8 @@ ${a.join("\n\n")}\n`);
|
|
|
4828
4846
|
projection: void 0
|
|
4829
4847
|
};
|
|
4830
4848
|
}
|
|
4831
|
-
}, e), K, `subscription.${
|
|
4832
|
-
descriptor:
|
|
4849
|
+
}, e), K, `subscription.${Zi.name}`), Y[Yi.name] = (e) => Xt(Zo({
|
|
4850
|
+
descriptor: Yi,
|
|
4833
4851
|
executor: (e) => {
|
|
4834
4852
|
let t = e.runId;
|
|
4835
4853
|
return {
|
|
@@ -4844,8 +4862,8 @@ ${a.join("\n\n")}\n`);
|
|
|
4844
4862
|
projection: void 0
|
|
4845
4863
|
};
|
|
4846
4864
|
}
|
|
4847
|
-
}, e), K, `subscription.${
|
|
4848
|
-
descriptor:
|
|
4865
|
+
}, e), K, `subscription.${Yi.name}`), Y[Ki.name] = (e) => Xt(Zo({
|
|
4866
|
+
descriptor: Ki,
|
|
4849
4867
|
executor: (e) => {
|
|
4850
4868
|
let t = e;
|
|
4851
4869
|
return {
|
|
@@ -4860,8 +4878,8 @@ ${a.join("\n\n")}\n`);
|
|
|
4860
4878
|
projection: void 0
|
|
4861
4879
|
};
|
|
4862
4880
|
}
|
|
4863
|
-
}, e), K, `subscription.${
|
|
4864
|
-
descriptor:
|
|
4881
|
+
}, e), K, `subscription.${Ki.name}`), Y[qi.name] = (e) => Xt(Zo({
|
|
4882
|
+
descriptor: qi,
|
|
4865
4883
|
executor: (e) => {
|
|
4866
4884
|
let t = e.eventId;
|
|
4867
4885
|
return {
|
|
@@ -4876,32 +4894,32 @@ ${a.join("\n\n")}\n`);
|
|
|
4876
4894
|
projection: void 0
|
|
4877
4895
|
};
|
|
4878
4896
|
}
|
|
4879
|
-
}, e), K, `subscription.${
|
|
4897
|
+
}, e), K, `subscription.${qi.name}`), Y[Gi.name] = (e) => Jt(async (e, t) => {
|
|
4880
4898
|
let n = e;
|
|
4881
|
-
return await
|
|
4882
|
-
}, e, `action.${
|
|
4899
|
+
return await co(B, t.subject, { executionId: n.executionId }), await W.cancel(n.workflowName, n.executionId), await cs(n.workflowName, n.executionId, "workflow.cancel"), { ok: !0 };
|
|
4900
|
+
}, e, `action.${Gi.name}`), Y[Ji.name] = (e) => Jt(async (e, t) => {
|
|
4883
4901
|
let n = e;
|
|
4884
|
-
return await
|
|
4885
|
-
}, e, `action.${
|
|
4902
|
+
return await co(B, t.subject, { executionId: n.executionId }), await W.resume(n.workflowName, n.executionId), { ok: !0 };
|
|
4903
|
+
}, e, `action.${Ji.name}`), Y[$i.name] = (e) => Jt(async (e, t) => {
|
|
4886
4904
|
let n = e;
|
|
4887
|
-
return await
|
|
4888
|
-
}, e, `action.${
|
|
4905
|
+
return await co(B, t.subject, { id: n.id }), W.signal({ id: n.id }, n.signalName, n.payload);
|
|
4906
|
+
}, e, `action.${$i.name}`), Y[ea.name] = (e) => Jt(async (e, t) => {
|
|
4889
4907
|
let n = e;
|
|
4890
|
-
return await
|
|
4891
|
-
}, e, `action.${
|
|
4908
|
+
return await co(B, t.subject, { id: n.id }), W.update({ id: n.id }, n.updateName, n.payload, n.timeoutMs === void 0 ? void 0 : { timeoutMs: n.timeoutMs });
|
|
4909
|
+
}, e, `action.${ea.name}`));
|
|
4892
4910
|
for (let e of N) Y[e.definition.name] = (t) => Jt(async (t, n) => {
|
|
4893
4911
|
let r = n;
|
|
4894
|
-
return
|
|
4912
|
+
return er(W, {
|
|
4895
4913
|
subject: r.subject,
|
|
4896
4914
|
traceId: r.traceId,
|
|
4897
4915
|
source: "workflow-rpc"
|
|
4898
4916
|
}).start(e.definition.name, t);
|
|
4899
4917
|
}, t, `workflow.${e.definition.name}`);
|
|
4900
|
-
let
|
|
4918
|
+
let ns = (e, t) => Oo({
|
|
4901
4919
|
subject: e.subject,
|
|
4902
4920
|
traceId: e.traceId
|
|
4903
|
-
}, B, void 0, `workflow:${t.workflowName}`, { parentExecutionId: t.executionId }),
|
|
4904
|
-
register: (e, t, n) =>
|
|
4921
|
+
}, B, void 0, `workflow:${t.workflowName}`, { parentExecutionId: t.executionId }), rs = ol(I?.plugins ?? [], Bo), is = Jr, as = (e, t) => C.emit(e, t), X = I?.dormancy === "sleep" ? {
|
|
4922
|
+
register: (e, t, n) => fr(B, {
|
|
4905
4923
|
tenantId: n ?? Ft,
|
|
4906
4924
|
kind: "workflow",
|
|
4907
4925
|
refId: e,
|
|
@@ -4912,23 +4930,23 @@ ${a.join("\n\n")}\n`);
|
|
|
4912
4930
|
kind: "workflow",
|
|
4913
4931
|
refId: e
|
|
4914
4932
|
}).then(() => {})
|
|
4915
|
-
} : void 0,
|
|
4933
|
+
} : void 0, os = Gr({
|
|
4916
4934
|
store: B,
|
|
4917
|
-
emit:
|
|
4935
|
+
emit: as,
|
|
4918
4936
|
log: $,
|
|
4919
|
-
...
|
|
4920
|
-
}),
|
|
4921
|
-
await
|
|
4937
|
+
...X === void 0 ? {} : { wakeups: X }
|
|
4938
|
+
}), ss = async (e, t) => {
|
|
4939
|
+
await Vr({
|
|
4922
4940
|
store: B,
|
|
4923
4941
|
parentExecutionId: e,
|
|
4924
4942
|
parentStatus: t,
|
|
4925
|
-
recorder:
|
|
4926
|
-
emit:
|
|
4943
|
+
recorder: os,
|
|
4944
|
+
emit: as,
|
|
4927
4945
|
log: $,
|
|
4928
4946
|
interruptChild: async (t, n, r) => {
|
|
4929
4947
|
let i = N.find((e) => e.definition.name === t);
|
|
4930
4948
|
if (!i) throw Error(`Unknown child workflow: ${t}`);
|
|
4931
|
-
await
|
|
4949
|
+
await Z.runPromise(i.definition.interrupt(n)), $.info("workflow.parentClose.childInterrupted", {
|
|
4932
4950
|
parentExecutionId: e,
|
|
4933
4951
|
childWorkflowName: t,
|
|
4934
4952
|
childExecutionId: n,
|
|
@@ -4936,7 +4954,7 @@ ${a.join("\n\n")}\n`);
|
|
|
4936
4954
|
});
|
|
4937
4955
|
}
|
|
4938
4956
|
});
|
|
4939
|
-
},
|
|
4957
|
+
}, cs = async (e, t, n) => {
|
|
4940
4958
|
let r = (await B.query({
|
|
4941
4959
|
table: "_voltro_workflow_runs",
|
|
4942
4960
|
order: [],
|
|
@@ -4953,10 +4971,10 @@ ${a.join("\n\n")}\n`);
|
|
|
4953
4971
|
});
|
|
4954
4972
|
i && C.emit("workflowRuns", {
|
|
4955
4973
|
op: "update",
|
|
4956
|
-
row:
|
|
4974
|
+
row: is(i)
|
|
4957
4975
|
});
|
|
4958
4976
|
let a = r.subject?.tenantId ?? void 0;
|
|
4959
|
-
i && await
|
|
4977
|
+
i && await os.recordEvent({
|
|
4960
4978
|
runId: r.id,
|
|
4961
4979
|
eventType: "run-cancelled",
|
|
4962
4980
|
payload: {
|
|
@@ -4965,10 +4983,10 @@ ${a.join("\n\n")}\n`);
|
|
|
4965
4983
|
executionId: t,
|
|
4966
4984
|
...a == null ? {} : { tenantId: a }
|
|
4967
4985
|
}
|
|
4968
|
-
}), i && await
|
|
4969
|
-
},
|
|
4970
|
-
let i =
|
|
4971
|
-
return
|
|
4986
|
+
}), i && await ss(t, "cancelled");
|
|
4987
|
+
}, ls = (e, t, n, r) => {
|
|
4988
|
+
let i = Ur(t);
|
|
4989
|
+
return Yr({
|
|
4972
4990
|
name: e,
|
|
4973
4991
|
store: B,
|
|
4974
4992
|
subject: r.subject,
|
|
@@ -4979,79 +4997,79 @@ ${a.join("\n\n")}\n`);
|
|
|
4979
4997
|
workflowPatches: i.patches,
|
|
4980
4998
|
parentExecutionId: r?.parentExecutionId ?? null,
|
|
4981
4999
|
parentClosePolicy: r?.parentClosePolicy ?? null,
|
|
4982
|
-
onParentClose: ({ executionId: e, status: t }) =>
|
|
4983
|
-
recorder:
|
|
4984
|
-
pluginWorkflowStepLayer:
|
|
4985
|
-
emit:
|
|
5000
|
+
onParentClose: ({ executionId: e, status: t }) => ss(e, t),
|
|
5001
|
+
recorder: os,
|
|
5002
|
+
pluginWorkflowStepLayer: rs,
|
|
5003
|
+
emit: as,
|
|
4986
5004
|
log: $
|
|
4987
5005
|
}, n);
|
|
4988
|
-
},
|
|
4989
|
-
buildContext:
|
|
4990
|
-
resolveStartContext:
|
|
4991
|
-
}, (e, t, n) =>
|
|
4992
|
-
V(() =>
|
|
5006
|
+
}, us = [...tr(N, {
|
|
5007
|
+
buildContext: ns,
|
|
5008
|
+
resolveStartContext: Fa
|
|
5009
|
+
}, (e, t, n) => ls(e.definition.name, e.definition, t, n)), ...lt], hs = us.length > 0 ? F.mergeAll(...us) : F.empty, Z = gt.make(hs.pipe(F.provideMerge(wa), F.provideMerge(To), F.provideMerge(wt)));
|
|
5010
|
+
V(() => Z.dispose()), Ta = N.length > 0 ? $n({
|
|
4993
5011
|
workflows: N,
|
|
4994
|
-
runEffect: (e) =>
|
|
5012
|
+
runEffect: (e) => Z.runPromise(e),
|
|
4995
5013
|
rememberStartContext: Na,
|
|
4996
5014
|
signal: async (e, t, n) => {
|
|
4997
|
-
let r = await
|
|
5015
|
+
let r = await Kr({
|
|
4998
5016
|
store: B,
|
|
4999
|
-
recorder:
|
|
5017
|
+
recorder: os,
|
|
5000
5018
|
target: e,
|
|
5001
5019
|
signalName: t,
|
|
5002
5020
|
payload: n
|
|
5003
5021
|
});
|
|
5004
|
-
return await
|
|
5022
|
+
return await Z.runPromise(Hr({
|
|
5005
5023
|
store: B,
|
|
5006
5024
|
target: e,
|
|
5007
5025
|
signalName: t,
|
|
5008
5026
|
payload: n
|
|
5009
5027
|
})).catch(() => {}), r;
|
|
5010
5028
|
},
|
|
5011
|
-
update: (e, t, n, r) =>
|
|
5029
|
+
update: (e, t, n, r) => qr({
|
|
5012
5030
|
store: B,
|
|
5013
|
-
recorder:
|
|
5031
|
+
recorder: os,
|
|
5014
5032
|
target: e,
|
|
5015
5033
|
updateName: t,
|
|
5016
5034
|
payload: n,
|
|
5017
5035
|
...r === void 0 ? {} : { options: r }
|
|
5018
5036
|
}),
|
|
5019
|
-
listRuns: (e) =>
|
|
5020
|
-
retry: (e, t) =>
|
|
5037
|
+
listRuns: (e) => ul(B, e),
|
|
5038
|
+
retry: (e, t) => dl({
|
|
5021
5039
|
store: B,
|
|
5022
5040
|
workflows: N,
|
|
5023
|
-
runPromise: (e) =>
|
|
5041
|
+
runPromise: (e) => Z.runPromise(e)
|
|
5024
5042
|
}, e, t)
|
|
5025
5043
|
}) : void 0;
|
|
5026
|
-
let
|
|
5027
|
-
if (
|
|
5044
|
+
let gs = F.mergeAll(xo.toLayer(Y), jt, Yl), _s = po(Y, T.map((e) => e.descriptor.name), xt), vs = F.mergeAll(xo.toLayer(_s), jt, Yl), ys = U, bs = (ys === "postgres" || ys === "mysql" || ys === "mariadb" || ys === "mssql") && (process.env.CDC ?? "1") !== "0";
|
|
5045
|
+
if (ys === "postgres" && pe()) {
|
|
5028
5046
|
let e = ye({
|
|
5029
5047
|
store: B,
|
|
5030
5048
|
log: $
|
|
5031
5049
|
});
|
|
5032
|
-
|
|
5050
|
+
Wn = e.persistTraceSpan, V(e.stop);
|
|
5033
5051
|
}
|
|
5034
|
-
let
|
|
5052
|
+
let xs = ao({
|
|
5035
5053
|
store: B,
|
|
5036
|
-
dialect:
|
|
5054
|
+
dialect: ys
|
|
5037
5055
|
});
|
|
5038
5056
|
V(() => {
|
|
5039
|
-
|
|
5057
|
+
xs.stop();
|
|
5040
5058
|
});
|
|
5041
|
-
let
|
|
5059
|
+
let Ss = za({
|
|
5042
5060
|
queries: T,
|
|
5043
5061
|
mutations: D,
|
|
5044
5062
|
actions: k,
|
|
5045
5063
|
streams: M,
|
|
5046
5064
|
workflows: N
|
|
5047
|
-
}, p),
|
|
5065
|
+
}, p), ws = Ba({
|
|
5048
5066
|
queries: T,
|
|
5049
5067
|
mutations: D,
|
|
5050
5068
|
actions: k,
|
|
5051
5069
|
streams: M,
|
|
5052
5070
|
workflows: N
|
|
5053
5071
|
}, p);
|
|
5054
|
-
R.writeFile(A(p, "app.manifest.generated.json"), `${JSON.stringify(et(
|
|
5072
|
+
R.writeFile(A(p, "app.manifest.generated.json"), `${JSON.stringify(et(Ss, ws, [], I?.plugins ?? []), null, 2)}\n`, "utf8").catch(() => {}), (async () => {
|
|
5055
5073
|
let e = A(p, ".gitignore"), t = "";
|
|
5056
5074
|
try {
|
|
5057
5075
|
t = await R.readFile(e, "utf8");
|
|
@@ -5059,18 +5077,18 @@ ${a.join("\n\n")}\n`);
|
|
|
5059
5077
|
let n = t.split("\n").filter((e) => e.trim() !== "");
|
|
5060
5078
|
n.includes("app.manifest.generated.json") || (n.push("app.manifest.generated.json"), await R.writeFile(e, `${n.join("\n")}\n`, "utf8"));
|
|
5061
5079
|
})().catch(() => {}), on();
|
|
5062
|
-
let
|
|
5080
|
+
let Ts = A(p, "app.graph.observed.generated.json");
|
|
5063
5081
|
R.rm(A(p, "app.graph.observed.json"), { force: !0 }).catch(() => {});
|
|
5064
|
-
let
|
|
5065
|
-
|
|
5066
|
-
let
|
|
5082
|
+
let Es = Ya(p);
|
|
5083
|
+
Es.warning === void 0 ? Es.adopted.length > 0 && $.debug("handed generated output to the workspace owner", { paths: Es.adopted.join(", ") }) : $.warn(Es.warning);
|
|
5084
|
+
let ks = async () => {
|
|
5067
5085
|
try {
|
|
5068
|
-
await R.writeFile(
|
|
5086
|
+
await R.writeFile(Ts, `${JSON.stringify(ar(), null, 2)}\n`, "utf8");
|
|
5069
5087
|
} catch {}
|
|
5070
5088
|
};
|
|
5071
5089
|
setInterval(() => {
|
|
5072
|
-
|
|
5073
|
-
}, 1e4).unref(), V(() =>
|
|
5090
|
+
ks();
|
|
5091
|
+
}, 1e4).unref(), V(() => ks()), (async () => {
|
|
5074
5092
|
let e = A(p, ".gitignore"), t = "";
|
|
5075
5093
|
try {
|
|
5076
5094
|
t = await R.readFile(e, "utf8");
|
|
@@ -5078,26 +5096,26 @@ ${a.join("\n\n")}\n`);
|
|
|
5078
5096
|
let n = t.split("\n").filter((e) => e.trim() !== "");
|
|
5079
5097
|
n.includes("app.graph.observed.generated.json") || (n.push("app.graph.observed.generated.json"), await R.writeFile(e, `${n.join("\n")}\n`, "utf8"));
|
|
5080
5098
|
})().catch(() => {});
|
|
5081
|
-
let
|
|
5082
|
-
for (let e of
|
|
5099
|
+
let Ms = /* @__PURE__ */ new Map();
|
|
5100
|
+
for (let e of vo) Ms.set(e.descriptor.name, async (t, n) => {
|
|
5083
5101
|
let r = {
|
|
5084
5102
|
subject: await At({
|
|
5085
5103
|
headers: n,
|
|
5086
5104
|
clientId: -1
|
|
5087
5105
|
}),
|
|
5088
|
-
traceId:
|
|
5106
|
+
traceId: Vl()
|
|
5089
5107
|
};
|
|
5090
5108
|
try {
|
|
5091
5109
|
return {
|
|
5092
5110
|
ok: !0,
|
|
5093
|
-
result: await
|
|
5111
|
+
result: await _i({
|
|
5094
5112
|
traceId: r.traceId,
|
|
5095
5113
|
subjectId: Bt(r.subject),
|
|
5096
5114
|
procedure: e.descriptor.name
|
|
5097
|
-
}, () =>
|
|
5115
|
+
}, () => Jo(e, t, r))
|
|
5098
5116
|
};
|
|
5099
5117
|
} catch (t) {
|
|
5100
|
-
let n =
|
|
5118
|
+
let n = Ql(t);
|
|
5101
5119
|
return $.warn(`inspect invoke failed: ${e.descriptor.name}`, {
|
|
5102
5120
|
tag: e.descriptor.name,
|
|
5103
5121
|
error: n
|
|
@@ -5107,25 +5125,25 @@ ${a.join("\n\n")}\n`);
|
|
|
5107
5125
|
};
|
|
5108
5126
|
}
|
|
5109
5127
|
});
|
|
5110
|
-
for (let e of
|
|
5128
|
+
for (let e of yo) Ms.set(e.descriptor.name, async (t, n) => {
|
|
5111
5129
|
let r = {
|
|
5112
5130
|
subject: await At({
|
|
5113
5131
|
headers: n,
|
|
5114
5132
|
clientId: -1
|
|
5115
5133
|
}),
|
|
5116
|
-
traceId:
|
|
5134
|
+
traceId: Vl()
|
|
5117
5135
|
};
|
|
5118
5136
|
try {
|
|
5119
5137
|
return {
|
|
5120
5138
|
ok: !0,
|
|
5121
|
-
result: await
|
|
5139
|
+
result: await _i({
|
|
5122
5140
|
traceId: r.traceId,
|
|
5123
5141
|
subjectId: Bt(r.subject),
|
|
5124
5142
|
procedure: e.descriptor.name
|
|
5125
|
-
}, () =>
|
|
5143
|
+
}, () => Yo(e, t, r))
|
|
5126
5144
|
};
|
|
5127
5145
|
} catch (t) {
|
|
5128
|
-
let n =
|
|
5146
|
+
let n = Ql(t);
|
|
5129
5147
|
return $.warn(`inspect invoke failed: ${e.descriptor.name}`, {
|
|
5130
5148
|
tag: e.descriptor.name,
|
|
5131
5149
|
error: n
|
|
@@ -5135,7 +5153,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5135
5153
|
};
|
|
5136
5154
|
}
|
|
5137
5155
|
});
|
|
5138
|
-
let
|
|
5156
|
+
let Ns = () => ({
|
|
5139
5157
|
dialect: U,
|
|
5140
5158
|
replication: ct.replicationSnapshot() ?? {
|
|
5141
5159
|
replicaCount: 0,
|
|
@@ -5167,7 +5185,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5167
5185
|
...e.lastRunRowsTouched === void 0 ? {} : { lastRunRowsTouched: e.lastRunRowsTouched },
|
|
5168
5186
|
...e.lastError ? { lastError: e.lastError } : {}
|
|
5169
5187
|
}))
|
|
5170
|
-
}),
|
|
5188
|
+
}), Fs = async () => {
|
|
5171
5189
|
let e = {
|
|
5172
5190
|
drift: {
|
|
5173
5191
|
isDrifted: !1,
|
|
@@ -5178,23 +5196,23 @@ ${a.join("\n\n")}\n`);
|
|
|
5178
5196
|
history: [],
|
|
5179
5197
|
softDropSnapshots: []
|
|
5180
5198
|
};
|
|
5181
|
-
if (!
|
|
5199
|
+
if (!mi) return e;
|
|
5182
5200
|
let t = (e) => typeof e == "string" ? e : e instanceof Date ? e.toISOString() : e == null ? "" : JSON.stringify(e), n = P.gen(function* () {
|
|
5183
|
-
let e = yield*
|
|
5201
|
+
let e = yield* Rr.SqlClient, n = yield* e`
|
|
5184
5202
|
SELECT * FROM ${e("_voltro_migration_plans")}
|
|
5185
5203
|
ORDER BY ${e("appliedAt")} DESC
|
|
5186
5204
|
LIMIT 20
|
|
5187
|
-
`.pipe(P.orElseSucceed(() => [])), r = yield*
|
|
5205
|
+
`.pipe(P.orElseSucceed(() => [])), r = yield* la(e), i = ca(r), a = n[0], o = a?.liveFingerprint ?? null, s = {
|
|
5188
5206
|
isDrifted: o !== null && o !== i,
|
|
5189
5207
|
liveFingerprint: i,
|
|
5190
5208
|
liveSnapshot: r
|
|
5191
5209
|
};
|
|
5192
5210
|
a && (o !== null && (s.lastAppliedFingerprint = o), s.lastAppliedAt = t(a.appliedAt), s.lastAppliedId = a.id);
|
|
5193
|
-
let c = z, l =
|
|
5211
|
+
let c = z, l = da({
|
|
5194
5212
|
declared: c,
|
|
5195
5213
|
live: r
|
|
5196
5214
|
});
|
|
5197
|
-
return
|
|
5215
|
+
return ca(oa(c)), {
|
|
5198
5216
|
drift: s,
|
|
5199
5217
|
pending: {
|
|
5200
5218
|
operations: l.operations.map((e) => {
|
|
@@ -5233,7 +5251,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5233
5251
|
};
|
|
5234
5252
|
});
|
|
5235
5253
|
try {
|
|
5236
|
-
return await P.runPromise(n.pipe(P.provide(
|
|
5254
|
+
return await P.runPromise(n.pipe(P.provide(mi)));
|
|
5237
5255
|
} catch (t) {
|
|
5238
5256
|
return $.warn("inspect.migrations: snapshot build failed", { err: String(t) }), e;
|
|
5239
5257
|
}
|
|
@@ -5241,19 +5259,19 @@ ${a.join("\n\n")}\n`);
|
|
|
5241
5259
|
kind: "api",
|
|
5242
5260
|
meta: {
|
|
5243
5261
|
name: I?.name ?? O(p),
|
|
5244
|
-
voltroVersion:
|
|
5262
|
+
voltroVersion: Hl,
|
|
5245
5263
|
port: x,
|
|
5246
5264
|
mode: "dev",
|
|
5247
|
-
store:
|
|
5248
|
-
cdc:
|
|
5265
|
+
store: ys,
|
|
5266
|
+
cdc: bs ? "on" : "off"
|
|
5249
5267
|
},
|
|
5250
|
-
rpc:
|
|
5251
|
-
workflows:
|
|
5252
|
-
metrics: (e) =>
|
|
5268
|
+
rpc: Ss,
|
|
5269
|
+
workflows: ws,
|
|
5270
|
+
metrics: (e) => Bo.snapshot(e),
|
|
5253
5271
|
dataCache: () => {
|
|
5254
|
-
let e =
|
|
5272
|
+
let e = Ar(), t = (process.env.CACHE_REDIS_DRIVER ?? "resp") === "http" ? "http" : "resp", n = kr === "redis" ? (process.env.CACHE_REDIS_URL ?? process.env.REDIS_URL ?? "").includes("upstash") ? "upstash" : "redis" : "memory";
|
|
5255
5273
|
return {
|
|
5256
|
-
backend:
|
|
5274
|
+
backend: kr === "redis" ? "redis" : "memory",
|
|
5257
5275
|
engine: n,
|
|
5258
5276
|
driver: t,
|
|
5259
5277
|
hits: e.hits,
|
|
@@ -5261,13 +5279,13 @@ ${a.join("\n\n")}\n`);
|
|
|
5261
5279
|
hitRate: e.hitRate
|
|
5262
5280
|
};
|
|
5263
5281
|
},
|
|
5264
|
-
invokers:
|
|
5282
|
+
invokers: Ms,
|
|
5265
5283
|
plugins: () => ({
|
|
5266
5284
|
plugins: Lt.snapshot(),
|
|
5267
5285
|
capturedAt: Date.now()
|
|
5268
5286
|
}),
|
|
5269
5287
|
env: () => f(I?.name ?? O(p), {
|
|
5270
|
-
contract:
|
|
5288
|
+
contract: ta(I?.env) ? I.env : void 0,
|
|
5271
5289
|
plugins: I?.plugins ?? []
|
|
5272
5290
|
}),
|
|
5273
5291
|
subscriptions: () => {
|
|
@@ -5275,7 +5293,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5275
5293
|
return {
|
|
5276
5294
|
subscriptions: e.map((e) => {
|
|
5277
5295
|
let t = [];
|
|
5278
|
-
for (let n of
|
|
5296
|
+
for (let n of bi(e.predicate)) n.conjunctive && t.push(n.column);
|
|
5279
5297
|
return {
|
|
5280
5298
|
fingerprint: e.fingerprint,
|
|
5281
5299
|
table: e.table,
|
|
@@ -5289,10 +5307,10 @@ ${a.join("\n\n")}\n`);
|
|
|
5289
5307
|
capturedAt: Date.now()
|
|
5290
5308
|
};
|
|
5291
5309
|
},
|
|
5292
|
-
database:
|
|
5293
|
-
migrations: async () =>
|
|
5310
|
+
database: Ns,
|
|
5311
|
+
migrations: async () => Fs(),
|
|
5294
5312
|
inspectTables: () => ({ tables: z.map((e) => {
|
|
5295
|
-
let t =
|
|
5313
|
+
let t = cu(e), n = lu(t);
|
|
5296
5314
|
return {
|
|
5297
5315
|
name: e.tableName,
|
|
5298
5316
|
isFrameworkTable: e.tableName.startsWith("_voltro_"),
|
|
@@ -5305,11 +5323,11 @@ ${a.join("\n\n")}\n`);
|
|
|
5305
5323
|
inspectRows: async (e) => {
|
|
5306
5324
|
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);
|
|
5307
5325
|
if (!r) throw Error(`unknown table: ${e.table}`);
|
|
5308
|
-
let i =
|
|
5326
|
+
let i = cu(r), a = Al({
|
|
5309
5327
|
filter: e.filter,
|
|
5310
5328
|
quickSearch: e.quickSearch,
|
|
5311
5329
|
columns: i
|
|
5312
|
-
}), o =
|
|
5330
|
+
}), o = jl(e.sort, i), s = await B.query({
|
|
5313
5331
|
table: e.table,
|
|
5314
5332
|
order: o,
|
|
5315
5333
|
skip: t,
|
|
@@ -5325,7 +5343,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5325
5343
|
skip: void 0,
|
|
5326
5344
|
take: void 0
|
|
5327
5345
|
})).length, u = "exact"), {
|
|
5328
|
-
rows: s.map(
|
|
5346
|
+
rows: s.map(su),
|
|
5329
5347
|
total: l,
|
|
5330
5348
|
countMode: u,
|
|
5331
5349
|
offset: t,
|
|
@@ -5339,7 +5357,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5339
5357
|
return $.info("inspect.data.insert", {
|
|
5340
5358
|
table: e.table,
|
|
5341
5359
|
id: t?.id ?? null
|
|
5342
|
-
}), { row:
|
|
5360
|
+
}), { row: su(t) };
|
|
5343
5361
|
},
|
|
5344
5362
|
inspectUpdateRow: async (e) => {
|
|
5345
5363
|
if (e.table.startsWith("_voltro_")) throw Error(`inspect data viewer cannot write to framework-internal table: ${e.table}`);
|
|
@@ -5349,7 +5367,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5349
5367
|
table: e.table,
|
|
5350
5368
|
id: e.id,
|
|
5351
5369
|
patch: Object.keys(e.patch)
|
|
5352
|
-
}), { row: t ?
|
|
5370
|
+
}), { row: t ? su(t) : null };
|
|
5353
5371
|
},
|
|
5354
5372
|
inspectDeleteRow: async (e) => {
|
|
5355
5373
|
if (e.table.startsWith("_voltro_")) throw Error(`inspect data viewer cannot delete from framework-internal table: ${e.table}`);
|
|
@@ -5362,7 +5380,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5362
5380
|
}), { deleted: t };
|
|
5363
5381
|
},
|
|
5364
5382
|
inspectImport: async (e) => {
|
|
5365
|
-
let t = await P.runPromise(
|
|
5383
|
+
let t = await P.runPromise(Ia({
|
|
5366
5384
|
store: B,
|
|
5367
5385
|
bundleDir: e.bundleDir,
|
|
5368
5386
|
...e.mode ? { mode: e.mode } : {},
|
|
@@ -5382,13 +5400,13 @@ ${a.join("\n\n")}\n`);
|
|
|
5382
5400
|
...xt ? {
|
|
5383
5401
|
inspectStartWorkflow: async (e) => {
|
|
5384
5402
|
if (W === void 0) throw Error("workflow runtime is not configured");
|
|
5385
|
-
return
|
|
5403
|
+
return er(W, {
|
|
5386
5404
|
traceId: `inspect-workflow-start-${Date.now()}`,
|
|
5387
5405
|
source: "inspect"
|
|
5388
5406
|
}).start(e.name, e.payload);
|
|
5389
5407
|
},
|
|
5390
5408
|
inspectWorkflowRuns: async (e) => {
|
|
5391
|
-
let { rows: t, total: n, offset: r, limit: i } = await
|
|
5409
|
+
let { rows: t, total: n, offset: r, limit: i } = await cl(B, {
|
|
5392
5410
|
...e.tag === void 0 ? {} : { tag: e.tag },
|
|
5393
5411
|
...e.status === void 0 ? {} : { status: e.status },
|
|
5394
5412
|
...e.offset === void 0 ? {} : { offset: e.offset },
|
|
@@ -5432,7 +5450,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5432
5450
|
if (!t) return $.warn("inspect.workflow.cancel: run not found", { runId: e.runId }), { cancelled: !1 };
|
|
5433
5451
|
let n = N.find((e) => e.definition.name === t.tag);
|
|
5434
5452
|
if (n && t.status === "running") try {
|
|
5435
|
-
await
|
|
5453
|
+
await Z.runPromise(n.definition.interrupt(t.executionId)), $.info("inspect.workflow.interrupt: engine notified", {
|
|
5436
5454
|
runId: e.runId,
|
|
5437
5455
|
tag: t.tag,
|
|
5438
5456
|
executionId: t.executionId
|
|
@@ -5450,17 +5468,17 @@ ${a.join("\n\n")}\n`);
|
|
|
5450
5468
|
});
|
|
5451
5469
|
r && C.emit("workflowRuns", {
|
|
5452
5470
|
op: "update",
|
|
5453
|
-
row:
|
|
5471
|
+
row: is(r)
|
|
5454
5472
|
});
|
|
5455
5473
|
let i = r?.subject?.tenantId ?? void 0;
|
|
5456
|
-
return r && await
|
|
5474
|
+
return r && await os.recordEvent({
|
|
5457
5475
|
runId: e.runId,
|
|
5458
5476
|
eventType: "run-cancelled",
|
|
5459
5477
|
payload: {
|
|
5460
5478
|
reason: "inspect.cancel",
|
|
5461
5479
|
...i == null ? {} : { tenantId: i }
|
|
5462
5480
|
}
|
|
5463
|
-
}), r && await
|
|
5481
|
+
}), r && await ss(t.executionId, "cancelled"), $.info("inspect.workflow.cancel", {
|
|
5464
5482
|
runId: e.runId,
|
|
5465
5483
|
didUpdate: r !== null
|
|
5466
5484
|
}), { cancelled: r !== null };
|
|
@@ -5618,7 +5636,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5618
5636
|
if (!t || t.status !== "running") return { suspended: !1 };
|
|
5619
5637
|
let n = N.find((e) => e.definition.name === t.tag);
|
|
5620
5638
|
if (n) try {
|
|
5621
|
-
await
|
|
5639
|
+
await Z.runPromise(n.definition.interrupt(t.executionId));
|
|
5622
5640
|
} catch (t) {
|
|
5623
5641
|
$.warn("inspect.workflow.suspend: interrupt failed (continuing)", {
|
|
5624
5642
|
runId: e.runId,
|
|
@@ -5631,8 +5649,8 @@ ${a.join("\n\n")}\n`);
|
|
|
5631
5649
|
});
|
|
5632
5650
|
return r && C.emit("workflowRuns", {
|
|
5633
5651
|
op: "update",
|
|
5634
|
-
row:
|
|
5635
|
-
}), r && await
|
|
5652
|
+
row: is(r)
|
|
5653
|
+
}), r && await os.recordEvent({
|
|
5636
5654
|
runId: e.runId,
|
|
5637
5655
|
eventType: "run-suspended",
|
|
5638
5656
|
payload: { reason: "inspect.suspend" }
|
|
@@ -5650,7 +5668,7 @@ ${a.join("\n\n")}\n`);
|
|
|
5650
5668
|
if (!t) return { resumed: !1 };
|
|
5651
5669
|
let n = N.find((e) => e.definition.name === t.tag);
|
|
5652
5670
|
if (n) try {
|
|
5653
|
-
await
|
|
5671
|
+
await Z.runPromise(n.definition.resume(t.executionId));
|
|
5654
5672
|
} catch (t) {
|
|
5655
5673
|
return $.warn("inspect.workflow.resume: engine.resume failed", {
|
|
5656
5674
|
runId: e.runId,
|
|
@@ -5663,8 +5681,8 @@ ${a.join("\n\n")}\n`);
|
|
|
5663
5681
|
});
|
|
5664
5682
|
return r && C.emit("workflowRuns", {
|
|
5665
5683
|
op: "update",
|
|
5666
|
-
row:
|
|
5667
|
-
}), r && await
|
|
5684
|
+
row: is(r)
|
|
5685
|
+
}), r && await os.recordEvent({
|
|
5668
5686
|
runId: e.runId,
|
|
5669
5687
|
eventType: "run-resumed",
|
|
5670
5688
|
payload: { reason: "inspect.resume" }
|
|
@@ -5673,10 +5691,10 @@ ${a.join("\n\n")}\n`);
|
|
|
5673
5691
|
inspectRetryWorkflowRun: async (e) => {
|
|
5674
5692
|
let t = e.payloadOverride !== void 0;
|
|
5675
5693
|
try {
|
|
5676
|
-
let n = await
|
|
5694
|
+
let n = await dl({
|
|
5677
5695
|
store: B,
|
|
5678
5696
|
workflows: N,
|
|
5679
|
-
runPromise: (e) =>
|
|
5697
|
+
runPromise: (e) => Z.runPromise(e)
|
|
5680
5698
|
}, e.runId, t ? { payloadOverride: e.payloadOverride } : void 0);
|
|
5681
5699
|
return $.info("inspect.workflow.retry", {
|
|
5682
5700
|
runId: e.runId,
|
|
@@ -5690,9 +5708,9 @@ ${a.join("\n\n")}\n`);
|
|
|
5690
5708
|
}
|
|
5691
5709
|
},
|
|
5692
5710
|
inspectSignalWorkflowRun: async (e) => {
|
|
5693
|
-
let t = await
|
|
5711
|
+
let t = await Kr({
|
|
5694
5712
|
store: B,
|
|
5695
|
-
recorder:
|
|
5713
|
+
recorder: os,
|
|
5696
5714
|
target: { id: e.runId },
|
|
5697
5715
|
signalName: e.signalName,
|
|
5698
5716
|
payload: e.payload
|
|
@@ -5704,9 +5722,9 @@ ${a.join("\n\n")}\n`);
|
|
|
5704
5722
|
}), t;
|
|
5705
5723
|
},
|
|
5706
5724
|
inspectUpdateWorkflowRun: async (e) => {
|
|
5707
|
-
let t = await
|
|
5725
|
+
let t = await qr({
|
|
5708
5726
|
store: B,
|
|
5709
|
-
recorder:
|
|
5727
|
+
recorder: os,
|
|
5710
5728
|
target: { id: e.runId },
|
|
5711
5729
|
updateName: e.updateName,
|
|
5712
5730
|
payload: e.payload,
|
|
@@ -5727,14 +5745,14 @@ ${a.join("\n\n")}\n`);
|
|
|
5727
5745
|
name: e.name,
|
|
5728
5746
|
cron: e.cron,
|
|
5729
5747
|
timezone: e.timezone,
|
|
5730
|
-
trigger: e.trigger ??
|
|
5748
|
+
trigger: e.trigger ?? _a,
|
|
5731
5749
|
onOverlap: e.onOverlap ?? "skip",
|
|
5732
5750
|
backfill: e.backfill ?? "skip",
|
|
5733
5751
|
maxRuntimeMs: e.maxRuntimeMs ?? 30 * 6e4,
|
|
5734
5752
|
...e.description === void 0 ? {} : { description: e.description },
|
|
5735
|
-
nextFiringAt:
|
|
5753
|
+
nextFiringAt: rr(e).toISOString()
|
|
5736
5754
|
})),
|
|
5737
|
-
coordination:
|
|
5755
|
+
coordination: Sa ? "cluster" : va === "advisoryLock" && U === "postgres" ? "advisoryLock" : "single"
|
|
5738
5756
|
}),
|
|
5739
5757
|
inspectScheduleRuns: async (e) => {
|
|
5740
5758
|
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 : H("name", e.name), i = await B.query({
|
|
@@ -5776,21 +5794,21 @@ ${a.join("\n\n")}\n`);
|
|
|
5776
5794
|
};
|
|
5777
5795
|
},
|
|
5778
5796
|
inspectFireSchedule: async (e) => {
|
|
5779
|
-
if (!
|
|
5780
|
-
return { runId: await
|
|
5797
|
+
if (!ha) throw Error("scheduler not started (no self-triggered schedules?)");
|
|
5798
|
+
return { runId: await ha.fireNow(e.name, e.trigger) ?? null };
|
|
5781
5799
|
}
|
|
5782
5800
|
} : {},
|
|
5783
5801
|
cluster: async () => {
|
|
5784
|
-
let e = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, t = U, n = t === "memory", r = n ? "none" :
|
|
5802
|
+
let e = process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`, t = U, n = t === "memory", r = n ? "none" : $r({ sqliteFamily: t === "sqlite" || t === "turso" }), i = Qr({
|
|
5785
5803
|
runnerStorage: r === "sql" ? "sql" : "memory",
|
|
5786
5804
|
...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {}
|
|
5787
|
-
}), 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 =
|
|
5805
|
+
}), 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 = Sa ? "cluster" : va === "advisoryLock" && U === "postgres" ? "advisoryLock" : "single", l = a && t === "mariadb" ? Du(e) : void 0, u = {
|
|
5788
5806
|
replicaId: e,
|
|
5789
5807
|
dialect: t,
|
|
5790
5808
|
runnerHost: i.host,
|
|
5791
5809
|
runnerPort: r === "none" ? 0 : i.port,
|
|
5792
5810
|
runnerStorage: r,
|
|
5793
|
-
shardLock: r === "sql" ?
|
|
5811
|
+
shardLock: r === "sql" ? Zr() : "none",
|
|
5794
5812
|
coordination: c,
|
|
5795
5813
|
cdc: {
|
|
5796
5814
|
enabled: a,
|
|
@@ -5847,10 +5865,10 @@ ${a.join("\n\n")}\n`);
|
|
|
5847
5865
|
};
|
|
5848
5866
|
},
|
|
5849
5867
|
runSeed: async (e) => {
|
|
5850
|
-
let t = await re(Ei, e, B,
|
|
5851
|
-
return ct.recordSeedResult(t),
|
|
5868
|
+
let t = await re(Ei, e, B, yi);
|
|
5869
|
+
return ct.recordSeedResult(t), Ns();
|
|
5852
5870
|
},
|
|
5853
|
-
rollbackMigration: async (e) => (
|
|
5871
|
+
rollbackMigration: async (e) => (yi.warn("rollbackMigration called but only memory store is wired — no-op"), Ns()),
|
|
5854
5872
|
webhooks: async () => {
|
|
5855
5873
|
let e = G.outgoing.map((e) => ({
|
|
5856
5874
|
id: e.descriptor.id,
|
|
@@ -5917,68 +5935,68 @@ ${a.join("\n\n")}\n`);
|
|
|
5917
5935
|
replay: (e) => J.replay(e),
|
|
5918
5936
|
updateTargetPayloadVersion: (e, t) => J.updateTargetPayloadVersion(e, t)
|
|
5919
5937
|
} }
|
|
5920
|
-
},
|
|
5921
|
-
|
|
5922
|
-
let
|
|
5938
|
+
}, Bs = fl(I?.plugins ?? [], Bo);
|
|
5939
|
+
Bs !== void 0 && $.info("plugin http-request interceptor active", { plugins: (I?.plugins ?? []).filter((e) => typeof e.onHttpRequest == "function").map((e) => e.name) });
|
|
5940
|
+
let Ws = (I?.plugins ?? []).flatMap((e) => e.httpRoutes ?? []), Gs = typeof Et == "object" ? Et.managementPath : void 0, qs = () => `public-${Math.random().toString(36).slice(2, 10)}`, Js = ba([
|
|
5923
5941
|
...T.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
5924
5942
|
descriptor: e.descriptor,
|
|
5925
|
-
invoke: (t, n) =>
|
|
5943
|
+
invoke: (t, n) => Qo(e, t, {
|
|
5926
5944
|
subject: n.subject,
|
|
5927
|
-
traceId:
|
|
5945
|
+
traceId: qs()
|
|
5928
5946
|
}),
|
|
5929
|
-
subscribe: (t, n, r) =>
|
|
5947
|
+
subscribe: (t, n, r) => $o(e, t, {
|
|
5930
5948
|
subject: n.subject,
|
|
5931
|
-
traceId:
|
|
5949
|
+
traceId: qs()
|
|
5932
5950
|
}, r)
|
|
5933
5951
|
})),
|
|
5934
5952
|
...D.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
5935
5953
|
descriptor: e.descriptor,
|
|
5936
|
-
invoke: (t, n) =>
|
|
5954
|
+
invoke: (t, n) => Jo(e, t, {
|
|
5937
5955
|
subject: n.subject,
|
|
5938
|
-
traceId:
|
|
5956
|
+
traceId: qs()
|
|
5939
5957
|
})
|
|
5940
5958
|
})),
|
|
5941
5959
|
...k.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
5942
5960
|
descriptor: e.descriptor,
|
|
5943
|
-
invoke: (t, n) =>
|
|
5961
|
+
invoke: (t, n) => Yo(e, t, {
|
|
5944
5962
|
subject: n.subject,
|
|
5945
|
-
traceId:
|
|
5963
|
+
traceId: qs()
|
|
5946
5964
|
})
|
|
5947
5965
|
}))
|
|
5948
|
-
]),
|
|
5966
|
+
]), Ys = [
|
|
5949
5967
|
...I?.restRoutes ?? [],
|
|
5950
|
-
...Ot ? Vt(Ot,
|
|
5951
|
-
...
|
|
5968
|
+
...Ot ? Vt(Ot, Gs ?? "/v1/api-keys") : [],
|
|
5969
|
+
...Js
|
|
5952
5970
|
];
|
|
5953
|
-
|
|
5954
|
-
let
|
|
5971
|
+
Js.length > 0 && $.info("public-api routes projected from descriptors", { routes: Js.map((e) => `${e.method} ${e.path}`) });
|
|
5972
|
+
let Xs = I?.idempotency, Qs = Xs ? {
|
|
5955
5973
|
store: rn(B),
|
|
5956
|
-
header: (typeof
|
|
5957
|
-
ttlMs: (typeof
|
|
5958
|
-
} : void 0,
|
|
5974
|
+
header: (typeof Xs == "object" ? Xs.header : void 0) ?? "Idempotency-Key",
|
|
5975
|
+
ttlMs: (typeof Xs == "object" ? Xs.ttlMs : void 0) ?? 864e5
|
|
5976
|
+
} : void 0, ec = Ys.length > 0 ? xa(Ys, {
|
|
5959
5977
|
store: B,
|
|
5960
5978
|
resolveSubject: (e) => At({
|
|
5961
5979
|
headers: e,
|
|
5962
5980
|
clientId: -1
|
|
5963
5981
|
}),
|
|
5964
|
-
...
|
|
5982
|
+
...Qs ? { idempotency: Qs } : {}
|
|
5965
5983
|
}) : [];
|
|
5966
|
-
|
|
5967
|
-
header:
|
|
5968
|
-
ttlMs:
|
|
5969
|
-
}),
|
|
5970
|
-
let
|
|
5971
|
-
...
|
|
5972
|
-
...
|
|
5973
|
-
...
|
|
5974
|
-
], { server:
|
|
5975
|
-
group:
|
|
5976
|
-
handlersLayer:
|
|
5977
|
-
httpHandlersLayer:
|
|
5984
|
+
Qs && Ys.length > 0 && $.info("rest idempotency active", {
|
|
5985
|
+
header: Qs.header,
|
|
5986
|
+
ttlMs: Qs.ttlMs
|
|
5987
|
+
}), ec.length > 0 && $.info("rest routes mounted", { routes: Ys.map((e) => `${e.method} ${e.path}`) });
|
|
5988
|
+
let tc = [
|
|
5989
|
+
...Ws,
|
|
5990
|
+
...ec,
|
|
5991
|
+
...ir.httpRoutes
|
|
5992
|
+
], { server: nc } = Dr({
|
|
5993
|
+
group: xo,
|
|
5994
|
+
handlersLayer: gs,
|
|
5995
|
+
httpHandlersLayer: vs,
|
|
5978
5996
|
port: x,
|
|
5979
5997
|
path: I?.transport?.wsPath ?? "/ws",
|
|
5980
|
-
...
|
|
5981
|
-
...
|
|
5998
|
+
...Bs ? { pluginHttpInterceptor: Bs } : {},
|
|
5999
|
+
...tc.length > 0 ? { httpRoutes: tc } : {},
|
|
5982
6000
|
getStore: () => Tt.current,
|
|
5983
6001
|
inspectRoute: { handle: async (e, t, n, r) => {
|
|
5984
6002
|
if (n !== "OPTIONS") {
|
|
@@ -6029,7 +6047,7 @@ ${a.join("\n\n")}\n`);
|
|
|
6029
6047
|
if (n === "GET" && (e === "/_voltro/inspect/traces" || e.startsWith("/_voltro/inspect/traces?"))) {
|
|
6030
6048
|
let n = _e();
|
|
6031
6049
|
return {
|
|
6032
|
-
...
|
|
6050
|
+
...Rl(e, ys === "postgres" && pe() ? await _u(e, n, B) : n),
|
|
6033
6051
|
headers: E(t.origin)
|
|
6034
6052
|
};
|
|
6035
6053
|
}
|
|
@@ -6090,11 +6108,11 @@ ${a.join("\n\n")}\n`);
|
|
|
6090
6108
|
if (r) return r;
|
|
6091
6109
|
}
|
|
6092
6110
|
if (e.startsWith("/_voltro/inspect/aggregates")) {
|
|
6093
|
-
let r = await
|
|
6111
|
+
let r = await _c(e, n, aa.registry, E(t.origin));
|
|
6094
6112
|
if (r) return r;
|
|
6095
6113
|
}
|
|
6096
6114
|
if (e.startsWith("/_voltro/inspect/timeline")) {
|
|
6097
|
-
let r = await
|
|
6115
|
+
let r = await Dc(e, n, {
|
|
6098
6116
|
recorder: pn(),
|
|
6099
6117
|
readCurrentRows: async (e) => Q.inspectRows === void 0 ? [] : (await Q.inspectRows({
|
|
6100
6118
|
table: e,
|
|
@@ -6106,9 +6124,9 @@ ${a.join("\n\n")}\n`);
|
|
|
6106
6124
|
if (r) return r;
|
|
6107
6125
|
}
|
|
6108
6126
|
if (e.startsWith("/_voltro/inspect/analytics")) {
|
|
6109
|
-
let r =
|
|
6110
|
-
sink:
|
|
6111
|
-
metricsCollector:
|
|
6127
|
+
let r = xc(e, n, {
|
|
6128
|
+
sink: ni,
|
|
6129
|
+
metricsCollector: Bo
|
|
6112
6130
|
}, E(t.origin));
|
|
6113
6131
|
if (r) return r;
|
|
6114
6132
|
}
|
|
@@ -6142,19 +6160,19 @@ ${a.join("\n\n")}\n`);
|
|
|
6142
6160
|
corsHeaders: (e) => E(e),
|
|
6143
6161
|
keepAlive: () => r()
|
|
6144
6162
|
},
|
|
6145
|
-
webhookRoutes: new Map(Array.from(
|
|
6146
|
-
...
|
|
6163
|
+
webhookRoutes: new Map(Array.from(Ha.entries()).map(([e, t]) => [e, { handle: t }])),
|
|
6164
|
+
...nr ? { tracerLayer: nr } : {}
|
|
6147
6165
|
});
|
|
6148
6166
|
try {
|
|
6149
|
-
await qt(
|
|
6167
|
+
await qt(nc);
|
|
6150
6168
|
} catch (e) {
|
|
6151
6169
|
$.error(`rpc server failed to bind on port ${x} — aborting boot`, { port: x }, e), process.exit(1);
|
|
6152
6170
|
}
|
|
6153
6171
|
$.info(`listening on http://localhost:${x}`, {
|
|
6154
6172
|
port: x,
|
|
6155
6173
|
ws: `ws://localhost:${x}/ws`,
|
|
6156
|
-
store:
|
|
6157
|
-
}), Te?.set({ phase: "ready" }),
|
|
6174
|
+
store: ys
|
|
6175
|
+
}), Te?.set({ phase: "ready" }), ys === "postgres" && $.info("postgres change-data-capture", { enabled: (process.env.CDC ?? "1") !== "0" }), await ko();
|
|
6158
6176
|
try {
|
|
6159
6177
|
await m({
|
|
6160
6178
|
id: S,
|
|
@@ -6183,8 +6201,8 @@ ${a.join("\n\n")}\n`);
|
|
|
6183
6201
|
}, 1e4).unref();
|
|
6184
6202
|
let t = async () => {
|
|
6185
6203
|
Lt.deactivate();
|
|
6186
|
-
for (let e of
|
|
6187
|
-
|
|
6204
|
+
for (let e of hr) e.stop();
|
|
6205
|
+
ur?.dispose(), ee(S), le.dispose(), jr(), vr?.close(), await ui();
|
|
6188
6206
|
};
|
|
6189
6207
|
V(t);
|
|
6190
6208
|
let n = process.ppid;
|
|
@@ -6201,9 +6219,9 @@ ${a.join("\n\n")}\n`);
|
|
|
6201
6219
|
root: p,
|
|
6202
6220
|
onBeforeRestart: () => {
|
|
6203
6221
|
try {
|
|
6204
|
-
|
|
6222
|
+
nc.closeAllConnections?.();
|
|
6205
6223
|
} catch {}
|
|
6206
|
-
|
|
6224
|
+
nc.close();
|
|
6207
6225
|
}
|
|
6208
6226
|
}), Ct({
|
|
6209
6227
|
app: ce,
|
|
@@ -6217,4 +6235,4 @@ ${a.join("\n\n")}\n`);
|
|
|
6217
6235
|
}), new Promise(() => {});
|
|
6218
6236
|
};
|
|
6219
6237
|
//#endregion
|
|
6220
|
-
export {
|
|
6238
|
+
export { bo as $, Ks as A, As as B, Ic as C, dc as D, kc as E, zs as F, Cs as G, Os as H, Ls as I, ps as J, ms as K, Rs as L, Us as M, Hs as N, fc as O, Vs as P, yo as Q, Is as R, Fc as S, Oc as T, Ds as U, js as V, Ts as W, Uo as X, ds as Y, Wo as Z, bl as _, du as a, oo as at, il as b, bu as c, Qa as ct, wu as d, Ba as dt, po as et, Fu as f, Au as g, eu as h, ku as i, so as it, Zs as j, $s as k, yu as l, Ya as lt, Su as m, ql as n, uo as nt, xu as o, ao as ot, Cu as p, fs as q, Kl as r, co as rt, Ql as s, io as st, Hl as t, lo as tt, vu as u, za as ut, ul as v, Nc as w, Jc as x, dl as y, Ps as z };
|