@hamak/smart-data-dico 1.24.6 → 1.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/backend/dist/server.mjs +266 -49
- package/frontend/dist/assets/{abnfDiagram-VRR7QNED-1ac4ac09.js → abnfDiagram-VRR7QNED-8c74b88a.js} +1 -1
- package/frontend/dist/assets/{arc-3ae26e11.js → arc-1a67ee2c.js} +1 -1
- package/frontend/dist/assets/architecture-TIHT7OUA-f0da3ef3.js +1 -0
- package/frontend/dist/assets/{architectureDiagram-ZJ3FMSHR-b3b10999.js → architectureDiagram-ZJ3FMSHR-b031b1c6.js} +1 -1
- package/frontend/dist/assets/{blockDiagram-677ZJIJ3-a9c6d500.js → blockDiagram-677ZJIJ3-4391ac97.js} +1 -1
- package/frontend/dist/assets/{c4Diagram-LMCZKHZV-0d6e31ec.js → c4Diagram-LMCZKHZV-1a4a6a8a.js} +1 -1
- package/frontend/dist/assets/channel-f32c5a6b.js +1 -0
- package/frontend/dist/assets/{chunk-2Q5K7J3B-1bf25556.js → chunk-2Q5K7J3B-f61d268b.js} +1 -1
- package/frontend/dist/assets/{chunk-32BRIVSS-dd1657ef.js → chunk-32BRIVSS-700be561.js} +1 -1
- package/frontend/dist/assets/{chunk-5VM5RSS4-7c52339a.js → chunk-5VM5RSS4-7ba27baa.js} +1 -1
- package/frontend/dist/assets/{chunk-EX3LRPZG-df1e795c.js → chunk-EX3LRPZG-e8565fc3.js} +1 -1
- package/frontend/dist/assets/{chunk-JWPE2WC7-70a42b42.js → chunk-JWPE2WC7-a2b75edb.js} +1 -1
- package/frontend/dist/assets/{chunk-MOJQB5TN-5c44f824.js → chunk-MOJQB5TN-84f3f036.js} +1 -1
- package/frontend/dist/assets/{chunk-PUDLZKDR-23b0a6e3.js → chunk-PUDLZKDR-c1698276.js} +1 -1
- package/frontend/dist/assets/{chunk-RYQCIY6F-249010cc.js → chunk-RYQCIY6F-338d70e8.js} +1 -1
- package/frontend/dist/assets/{chunk-V7JOEXUC-dd86c2ff.js → chunk-V7JOEXUC-45b55353.js} +1 -1
- package/frontend/dist/assets/{chunk-VR4S4FIN-8b06fb56.js → chunk-VR4S4FIN-ca1ba46c.js} +1 -1
- package/frontend/dist/assets/{chunk-XXDRQBXY-39da8a47.js → chunk-XXDRQBXY-31ce50a0.js} +1 -1
- package/frontend/dist/assets/classDiagram-OUVF2IWQ-b541802f.js +1 -0
- package/frontend/dist/assets/classDiagram-v2-EOCWNBFH-b541802f.js +1 -0
- package/frontend/dist/assets/{cose-bilkent-JH36ORCC-d3c69454.js → cose-bilkent-JH36ORCC-28a6eeba.js} +1 -1
- package/frontend/dist/assets/cynefin-VYW2F7L2-9ed9de71.js +1 -0
- package/frontend/dist/assets/{cynefinDiagram-TSTJHNR4-3a7797a0.js → cynefinDiagram-TSTJHNR4-ec06737e.js} +1 -1
- package/frontend/dist/assets/{dagre-VKFMJZFB-d5cef451.js → dagre-VKFMJZFB-39b41721.js} +1 -1
- package/frontend/dist/assets/{diagram-FQU43EPY-4c8edea0.js → diagram-FQU43EPY-2c8eb7c5.js} +1 -1
- package/frontend/dist/assets/{diagram-G47NLZAW-560ab6da.js → diagram-G47NLZAW-0366146d.js} +1 -1
- package/frontend/dist/assets/{diagram-NH7WQ7WH-97ef586e.js → diagram-NH7WQ7WH-17b48109.js} +1 -1
- package/frontend/dist/assets/{diagram-OA4YK3LP-f42e2ff5.js → diagram-OA4YK3LP-cac765dd.js} +1 -1
- package/frontend/dist/assets/{diagram-WEI45ONY-54d3e8ad.js → diagram-WEI45ONY-e1ab9086.js} +1 -1
- package/frontend/dist/assets/{ebnfDiagram-CCIWWBDH-fc5b1100.js → ebnfDiagram-CCIWWBDH-ef384212.js} +1 -1
- package/frontend/dist/assets/{erDiagram-Q63AITRT-a20ccda1.js → erDiagram-Q63AITRT-4d70bc48.js} +1 -1
- package/frontend/dist/assets/eventmodeling-45OFAUF4-c9cd1bb1.js +1 -0
- package/frontend/dist/assets/flowDiagram-23GEKE2U-b87aebe2.js +1 -0
- package/frontend/dist/assets/{ganttDiagram-NO4QXBWP-21e9f3d7.js → ganttDiagram-NO4QXBWP-881a1dee.js} +1 -1
- package/frontend/dist/assets/gitGraph-TEB2WS4Q-37937275.js +1 -0
- package/frontend/dist/assets/{gitGraphDiagram-IHSO6WYX-a4ef9947.js → gitGraphDiagram-IHSO6WYX-d9bafa3f.js} +1 -1
- package/frontend/dist/assets/index-28d0efa6.js +574 -0
- package/frontend/dist/assets/{index-60d9dbb0.css → index-3097dd1f.css} +1 -1
- package/frontend/dist/assets/info-DKCQHKI2-2c371861.js +1 -0
- package/frontend/dist/assets/{infoDiagram-FWYZ7A6U-0ddf01b3.js → infoDiagram-FWYZ7A6U-0743b1dd.js} +1 -1
- package/frontend/dist/assets/{ishikawaDiagram-FXEZZL3T-b100c8bf.js → ishikawaDiagram-FXEZZL3T-effd744c.js} +1 -1
- package/frontend/dist/assets/{journeyDiagram-5HDEW3XC-277cde84.js → journeyDiagram-5HDEW3XC-93366564.js} +1 -1
- package/frontend/dist/assets/{kanban-definition-HUTT4EX6-0493c7ae.js → kanban-definition-HUTT4EX6-5b225bff.js} +1 -1
- package/frontend/dist/assets/{linear-38755882.js → linear-706ff254.js} +1 -1
- package/frontend/dist/assets/{mermaid-parser.core-432f6fdd.js → mermaid-parser.core-8b2bc368.js} +2 -2
- package/frontend/dist/assets/{mermaid.core-6a67b6b8.js → mermaid.core-955570af.js} +3 -3
- package/frontend/dist/assets/{mindmap-definition-LN4V7U3C-087cb2dc.js → mindmap-definition-LN4V7U3C-69c42d83.js} +1 -1
- package/frontend/dist/assets/packet-7NZHBO7P-7488d661.js +1 -0
- package/frontend/dist/assets/{pegDiagram-2B236MQR-d0c9d90f.js → pegDiagram-2B236MQR-a94d2327.js} +1 -1
- package/frontend/dist/assets/pie-RZYD4A2V-a1c34657.js +1 -0
- package/frontend/dist/assets/{pieDiagram-ENE6RG2P-83755113.js → pieDiagram-ENE6RG2P-bdb7b57a.js} +1 -1
- package/frontend/dist/assets/{quadrantDiagram-ABIIQ3AL-5f18b4fd.js → quadrantDiagram-ABIIQ3AL-5abf740b.js} +1 -1
- package/frontend/dist/assets/radar-I7S5WNFK-1e0e8e8e.js +1 -0
- package/frontend/dist/assets/railroad-3IZDKUUU-105b240a.js +1 -0
- package/frontend/dist/assets/railroad-abnf-AHOZXSZD-08d2a53f.js +1 -0
- package/frontend/dist/assets/railroad-ebnf-EBAXGLYW-18ec4e5d.js +1 -0
- package/frontend/dist/assets/railroad-peg-LSFZ7HO6-d3f4e772.js +1 -0
- package/frontend/dist/assets/{railroadDiagram-RFXS5EU6-2268aa66.js → railroadDiagram-RFXS5EU6-e164d78c.js} +1 -1
- package/frontend/dist/assets/{requirementDiagram-TGXJPOKE-942a8f35.js → requirementDiagram-TGXJPOKE-1b8f475a.js} +1 -1
- package/frontend/dist/assets/{sankeyDiagram-HTMAVEWB-504dd8aa.js → sankeyDiagram-HTMAVEWB-0fea3994.js} +1 -1
- package/frontend/dist/assets/{sequenceDiagram-DBY2YBRQ-a402da2a.js → sequenceDiagram-DBY2YBRQ-e8cc741c.js} +1 -1
- package/frontend/dist/assets/{sizeCapture-X5ZJPWSS-2776eb4d.js → sizeCapture-X5ZJPWSS-20aa2a4d.js} +1 -1
- package/frontend/dist/assets/{stateDiagram-2N3HPSRC-1b9cfcbe.js → stateDiagram-2N3HPSRC-589d5255.js} +1 -1
- package/frontend/dist/assets/stateDiagram-v2-6OUMAXLB-17aa9373.js +1 -0
- package/frontend/dist/assets/{swimlanes-5IMT3BWC-7a3d33f8.js → swimlanes-5IMT3BWC-e06948c8.js} +1 -1
- package/frontend/dist/assets/swimlanesDiagram-G3AALYLV-6da994bb.js +8 -0
- package/frontend/dist/assets/{timeline-definition-FHXFAJF6-9c4d37aa.js → timeline-definition-FHXFAJF6-6caf640a.js} +1 -1
- package/frontend/dist/assets/treeView-QDETBFTQ-ccf50be1.js +1 -0
- package/frontend/dist/assets/treemap-6X3UGDF4-c94a0470.js +1 -0
- package/frontend/dist/assets/{vennDiagram-L72KCM5P-b7968cac.js → vennDiagram-L72KCM5P-d8538bef.js} +1 -1
- package/frontend/dist/assets/wardley-OPB4EBWU-bd04de26.js +1 -0
- package/frontend/dist/assets/{wardleyDiagram-EHGQE667-b1013425.js → wardleyDiagram-EHGQE667-826be320.js} +1 -1
- package/frontend/dist/assets/{xychartDiagram-FW5EYKEG-da024ff1.js → xychartDiagram-FW5EYKEG-f28358aa.js} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/frontend/dist/assets/architecture-TIHT7OUA-df38565f.js +0 -1
- package/frontend/dist/assets/channel-254433c0.js +0 -1
- package/frontend/dist/assets/classDiagram-OUVF2IWQ-7ece20ed.js +0 -1
- package/frontend/dist/assets/classDiagram-v2-EOCWNBFH-7ece20ed.js +0 -1
- package/frontend/dist/assets/cynefin-VYW2F7L2-5a01171d.js +0 -1
- package/frontend/dist/assets/eventmodeling-45OFAUF4-22c14824.js +0 -1
- package/frontend/dist/assets/flowDiagram-23GEKE2U-32449f05.js +0 -1
- package/frontend/dist/assets/gitGraph-TEB2WS4Q-17d6e4af.js +0 -1
- package/frontend/dist/assets/index-02f83d95.js +0 -575
- package/frontend/dist/assets/info-DKCQHKI2-ac7cfe65.js +0 -1
- package/frontend/dist/assets/packet-7NZHBO7P-36f37972.js +0 -1
- package/frontend/dist/assets/pie-RZYD4A2V-61794516.js +0 -1
- package/frontend/dist/assets/radar-I7S5WNFK-034b88d9.js +0 -1
- package/frontend/dist/assets/railroad-3IZDKUUU-a4892ed9.js +0 -1
- package/frontend/dist/assets/railroad-abnf-AHOZXSZD-1dfb3444.js +0 -1
- package/frontend/dist/assets/railroad-ebnf-EBAXGLYW-877c30ab.js +0 -1
- package/frontend/dist/assets/railroad-peg-LSFZ7HO6-3e0fcace.js +0 -1
- package/frontend/dist/assets/stateDiagram-v2-6OUMAXLB-f1a8ebdf.js +0 -1
- package/frontend/dist/assets/swimlanesDiagram-G3AALYLV-2e2afd36.js +0 -8
- package/frontend/dist/assets/treeView-QDETBFTQ-fa371c45.js +0 -1
- package/frontend/dist/assets/treemap-6X3UGDF4-d781249a.js +0 -1
- package/frontend/dist/assets/wardley-OPB4EBWU-b96ca787.js +0 -1
package/README.md
CHANGED
|
@@ -243,6 +243,31 @@ All files are git-tracked for versioning, branching, and collaboration.
|
|
|
243
243
|
| **Git** | 2.x+ | Required — dictionaries are versioned in a git repository |
|
|
244
244
|
| **Docker** | 20+ | Optional, only for the containerized deployment path |
|
|
245
245
|
|
|
246
|
+
#### Verify FTS5 search-index support
|
|
247
|
+
|
|
248
|
+
Dico's persistent full-text search index uses SQLite FTS5 through Node's built-in
|
|
249
|
+
`node:sqlite` module. The application still runs on Node 18 or 20, but indexed
|
|
250
|
+
search requires Node 22.5 or newer. Official Node 22.20.0 binaries include FTS5.
|
|
251
|
+
|
|
252
|
+
Check the exact Node binary that will run Dico before starting the application:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
node -e "const { DatabaseSync } = require('node:sqlite'); const db = new DatabaseSync(':memory:'); db.exec('CREATE VIRTUAL TABLE test USING fts5(content)'); console.log('FTS5 supported')"
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Expected output:
|
|
259
|
+
|
|
260
|
+
```text
|
|
261
|
+
FTS5 supported
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
If the command reports `No such built-in module: node:sqlite`, upgrade to Node
|
|
265
|
+
22.5 or newer. If it reports `no such module: fts5`, the installed Node binary
|
|
266
|
+
was built without FTS5; use an official Node distribution or another build with
|
|
267
|
+
`SQLITE_ENABLE_FTS5`. When FTS5 is unavailable, Dico disables the persistent
|
|
268
|
+
index and falls back to the slower non-indexed search. The running index state
|
|
269
|
+
is also shown in the application status bar.
|
|
270
|
+
|
|
246
271
|
#### Database drivers (optional)
|
|
247
272
|
|
|
248
273
|
Connecting to a live database — for **Physical Sync** (schema introspection) or the **SQL Console / AI ▶ Run** (running read-only queries) — needs the driver for your dialect. They are **optional peer dependencies**: a default install pulls **none** of them, so install only the one(s) you use:
|
package/backend/dist/server.mjs
CHANGED
|
@@ -84386,6 +84386,21 @@ function jsonByteLength(value) {
|
|
|
84386
84386
|
return -1;
|
|
84387
84387
|
}
|
|
84388
84388
|
}
|
|
84389
|
+
function providerPayloadBreakdown(body) {
|
|
84390
|
+
try {
|
|
84391
|
+
const parsed = JSON.parse(body);
|
|
84392
|
+
const messages = Array.isArray(parsed.messages) ? parsed.messages : [];
|
|
84393
|
+
const tools = Array.isArray(parsed.tools) ? parsed.tools : [];
|
|
84394
|
+
return {
|
|
84395
|
+
messagesBytes: jsonByteLength(messages),
|
|
84396
|
+
toolsBytes: jsonByteLength(tools),
|
|
84397
|
+
messageCount: messages.length,
|
|
84398
|
+
toolCount: tools.length
|
|
84399
|
+
};
|
|
84400
|
+
} catch {
|
|
84401
|
+
return {};
|
|
84402
|
+
}
|
|
84403
|
+
}
|
|
84389
84404
|
function createMeasuredProviderFetch(provider, model, diagnosticId) {
|
|
84390
84405
|
return async (input, init) => {
|
|
84391
84406
|
const body = init?.body;
|
|
@@ -84401,13 +84416,15 @@ function createMeasuredProviderFetch(provider, model, diagnosticId) {
|
|
|
84401
84416
|
endpoint = `${url2.host}${url2.pathname}`;
|
|
84402
84417
|
} catch {
|
|
84403
84418
|
}
|
|
84419
|
+
const breakdown = typeof body === "string" ? providerPayloadBreakdown(body) : {};
|
|
84404
84420
|
recordProviderRequestMeasurement({
|
|
84405
84421
|
provider,
|
|
84406
84422
|
model,
|
|
84407
84423
|
diagnosticId: diagnosticId ?? null,
|
|
84408
84424
|
endpoint,
|
|
84409
84425
|
requestBodyBytes,
|
|
84410
|
-
contentLengthHeader: new Headers(init?.headers).get("content-length")
|
|
84426
|
+
contentLengthHeader: new Headers(init?.headers).get("content-length"),
|
|
84427
|
+
...breakdown
|
|
84411
84428
|
});
|
|
84412
84429
|
return fetch(input, init);
|
|
84413
84430
|
};
|
|
@@ -84422,6 +84439,7 @@ var init_aiPayloadMetrics = __esm({
|
|
|
84422
84439
|
__name(getProviderRequestMeasurement, "getProviderRequestMeasurement");
|
|
84423
84440
|
__name(utf8ByteLength, "utf8ByteLength");
|
|
84424
84441
|
__name(jsonByteLength, "jsonByteLength");
|
|
84442
|
+
__name(providerPayloadBreakdown, "providerPayloadBreakdown");
|
|
84425
84443
|
__name(createMeasuredProviderFetch, "createMeasuredProviderFetch");
|
|
84426
84444
|
}
|
|
84427
84445
|
});
|
|
@@ -117672,6 +117690,76 @@ __export(aiDirectClient_exports, {
|
|
|
117672
117690
|
boundLiveToolResult: () => boundLiveToolResult,
|
|
117673
117691
|
callWithTools: () => callWithTools
|
|
117674
117692
|
});
|
|
117693
|
+
async function readCompletion(response, onTextDelta) {
|
|
117694
|
+
const contentType = response.headers.get("content-type") || "";
|
|
117695
|
+
if (!contentType.includes("text/event-stream") || !response.body) {
|
|
117696
|
+
const data = await response.json();
|
|
117697
|
+
const choice2 = data.choices?.[0];
|
|
117698
|
+
if (!choice2) throw new Error("No response from model");
|
|
117699
|
+
return {
|
|
117700
|
+
message: {
|
|
117701
|
+
content: choice2.message?.content || "",
|
|
117702
|
+
tool_calls: choice2.message?.tool_calls || []
|
|
117703
|
+
},
|
|
117704
|
+
usage: data.usage,
|
|
117705
|
+
textStreamed: false
|
|
117706
|
+
};
|
|
117707
|
+
}
|
|
117708
|
+
const reader = response.body.getReader();
|
|
117709
|
+
const decoder = new TextDecoder();
|
|
117710
|
+
const toolCalls = [];
|
|
117711
|
+
let buffer = "";
|
|
117712
|
+
let content = "";
|
|
117713
|
+
let usage;
|
|
117714
|
+
let textStreamed = false;
|
|
117715
|
+
const processLine = /* @__PURE__ */ __name((line) => {
|
|
117716
|
+
if (!line.startsWith("data:")) return;
|
|
117717
|
+
const payload = line.slice(5).trimStart();
|
|
117718
|
+
if (!payload || payload === "[DONE]") return;
|
|
117719
|
+
const data = JSON.parse(payload);
|
|
117720
|
+
if (data.usage) usage = data.usage;
|
|
117721
|
+
const choice2 = data.choices?.[0];
|
|
117722
|
+
if (!choice2) return;
|
|
117723
|
+
const delta = choice2.delta ?? choice2.message ?? {};
|
|
117724
|
+
if (Array.isArray(delta.tool_calls)) {
|
|
117725
|
+
for (const fragment of delta.tool_calls) {
|
|
117726
|
+
const index2 = typeof fragment.index === "number" ? fragment.index : 0;
|
|
117727
|
+
const current = toolCalls[index2] ?? {
|
|
117728
|
+
id: "",
|
|
117729
|
+
type: "function",
|
|
117730
|
+
function: { name: "", arguments: "" }
|
|
117731
|
+
};
|
|
117732
|
+
if (fragment.id) current.id += fragment.id;
|
|
117733
|
+
if (fragment.type) current.type = fragment.type;
|
|
117734
|
+
if (fragment.function?.name) current.function.name += fragment.function.name;
|
|
117735
|
+
if (fragment.function?.arguments) current.function.arguments += fragment.function.arguments;
|
|
117736
|
+
toolCalls[index2] = current;
|
|
117737
|
+
}
|
|
117738
|
+
}
|
|
117739
|
+
const text3 = typeof delta.content === "string" ? delta.content : "";
|
|
117740
|
+
content += text3;
|
|
117741
|
+
if (text3 && !Array.isArray(delta.tool_calls) && onTextDelta) {
|
|
117742
|
+
textStreamed = true;
|
|
117743
|
+
onTextDelta(text3);
|
|
117744
|
+
}
|
|
117745
|
+
}, "processLine");
|
|
117746
|
+
for (; ; ) {
|
|
117747
|
+
const { done, value } = await reader.read();
|
|
117748
|
+
buffer += decoder.decode(value, { stream: !done });
|
|
117749
|
+
const lines = buffer.split(/\r?\n/);
|
|
117750
|
+
buffer = done ? "" : lines.pop() ?? "";
|
|
117751
|
+
for (const line of lines) processLine(line);
|
|
117752
|
+
if (done) {
|
|
117753
|
+
if (buffer) processLine(buffer);
|
|
117754
|
+
break;
|
|
117755
|
+
}
|
|
117756
|
+
}
|
|
117757
|
+
return {
|
|
117758
|
+
message: { content, tool_calls: toolCalls.filter(Boolean) },
|
|
117759
|
+
usage,
|
|
117760
|
+
textStreamed
|
|
117761
|
+
};
|
|
117762
|
+
}
|
|
117675
117763
|
function boundLiveToolResult(result, maxChars = LIVE_TOOL_RESULT_MAX_CHARS) {
|
|
117676
117764
|
const serialized = JSON.stringify(result ?? {});
|
|
117677
117765
|
if (serialized.length <= maxChars) return result;
|
|
@@ -117690,9 +117778,10 @@ async function callWithTools(config3, messages, tools, executeToolFn, maxSteps =
|
|
|
117690
117778
|
const callSeq = {};
|
|
117691
117779
|
const usage = { inputTokens: 0, outputTokens: 0 };
|
|
117692
117780
|
let stoppedAtStepLimit = true;
|
|
117781
|
+
let textStreamed = false;
|
|
117693
117782
|
for (let step = 0; step < maxSteps; step++) {
|
|
117694
117783
|
if (signal?.aborted) {
|
|
117695
|
-
return { text: finalText, toolCalls: allToolCalls, aborted: true, usage, stoppedAtStepLimit: false };
|
|
117784
|
+
return { text: finalText, toolCalls: allToolCalls, aborted: true, usage, stoppedAtStepLimit: false, textStreamed };
|
|
117696
117785
|
}
|
|
117697
117786
|
let response;
|
|
117698
117787
|
try {
|
|
@@ -117701,7 +117790,9 @@ async function callWithTools(config3, messages, tools, executeToolFn, maxSteps =
|
|
|
117701
117790
|
messages: currentMessages,
|
|
117702
117791
|
tools: tools.length > 0 ? tools : void 0,
|
|
117703
117792
|
tool_choice: tools.length > 0 ? "auto" : void 0,
|
|
117704
|
-
max_tokens: 4096
|
|
117793
|
+
max_tokens: 4096,
|
|
117794
|
+
stream: true,
|
|
117795
|
+
stream_options: { include_usage: true }
|
|
117705
117796
|
};
|
|
117706
117797
|
const requestBody = JSON.stringify(requestPayload);
|
|
117707
117798
|
recordProviderRequestMeasurement({
|
|
@@ -117727,7 +117818,7 @@ async function callWithTools(config3, messages, tools, executeToolFn, maxSteps =
|
|
|
117727
117818
|
});
|
|
117728
117819
|
} catch (err) {
|
|
117729
117820
|
if (err?.name === "AbortError" || signal?.aborted) {
|
|
117730
|
-
return { text: finalText, toolCalls: allToolCalls, aborted: true, usage, stoppedAtStepLimit: false };
|
|
117821
|
+
return { text: finalText, toolCalls: allToolCalls, aborted: true, usage, stoppedAtStepLimit: false, textStreamed };
|
|
117731
117822
|
}
|
|
117732
117823
|
throw err;
|
|
117733
117824
|
}
|
|
@@ -117755,17 +117846,18 @@ async function callWithTools(config3, messages, tools, executeToolFn, maxSteps =
|
|
|
117755
117846
|
});
|
|
117756
117847
|
throw err;
|
|
117757
117848
|
}
|
|
117758
|
-
const
|
|
117759
|
-
|
|
117760
|
-
|
|
117761
|
-
|
|
117762
|
-
|
|
117849
|
+
const completion = await readCompletion(response, onEvent ? (delta) => {
|
|
117850
|
+
textStreamed = true;
|
|
117851
|
+
onEvent({ type: "text", delta });
|
|
117852
|
+
} : void 0);
|
|
117853
|
+
if (completion.usage) {
|
|
117854
|
+
const u = completion.usage;
|
|
117763
117855
|
const inTok = typeof u.prompt_tokens === "number" ? u.prompt_tokens : typeof u.input_tokens === "number" ? u.input_tokens : 0;
|
|
117764
117856
|
const outTok = typeof u.completion_tokens === "number" ? u.completion_tokens : typeof u.output_tokens === "number" ? u.output_tokens : 0;
|
|
117765
117857
|
usage.inputTokens += inTok;
|
|
117766
117858
|
usage.outputTokens += outTok;
|
|
117767
117859
|
}
|
|
117768
|
-
const msg =
|
|
117860
|
+
const msg = completion.message;
|
|
117769
117861
|
finalText = msg.content || "";
|
|
117770
117862
|
if (msg.tool_calls && msg.tool_calls.length > 0) {
|
|
117771
117863
|
currentMessages.push({
|
|
@@ -117775,7 +117867,7 @@ async function callWithTools(config3, messages, tools, executeToolFn, maxSteps =
|
|
|
117775
117867
|
});
|
|
117776
117868
|
for (const tc of msg.tool_calls) {
|
|
117777
117869
|
if (signal?.aborted) {
|
|
117778
|
-
return { text: finalText, toolCalls: allToolCalls, aborted: true, usage, stoppedAtStepLimit: false };
|
|
117870
|
+
return { text: finalText, toolCalls: allToolCalls, aborted: true, usage, stoppedAtStepLimit: false, textStreamed };
|
|
117779
117871
|
}
|
|
117780
117872
|
const toolName = tc.function.name;
|
|
117781
117873
|
let toolArgs = {};
|
|
@@ -117820,7 +117912,9 @@ async function callWithTools(config3, messages, tools, executeToolFn, maxSteps =
|
|
|
117820
117912
|
const requestPayload = {
|
|
117821
117913
|
model: config3.model,
|
|
117822
117914
|
messages: nudgeMessages,
|
|
117823
|
-
max_tokens: 4096
|
|
117915
|
+
max_tokens: 4096,
|
|
117916
|
+
stream: true,
|
|
117917
|
+
stream_options: { include_usage: true }
|
|
117824
117918
|
};
|
|
117825
117919
|
const requestBody = JSON.stringify(requestPayload);
|
|
117826
117920
|
recordProviderRequestMeasurement({
|
|
@@ -117845,15 +117939,18 @@ async function callWithTools(config3, messages, tools, executeToolFn, maxSteps =
|
|
|
117845
117939
|
signal
|
|
117846
117940
|
});
|
|
117847
117941
|
if (response.ok) {
|
|
117848
|
-
const
|
|
117849
|
-
|
|
117850
|
-
|
|
117942
|
+
const completion = await readCompletion(response, onEvent ? (delta) => {
|
|
117943
|
+
textStreamed = true;
|
|
117944
|
+
onEvent({ type: "text", delta });
|
|
117945
|
+
} : void 0);
|
|
117946
|
+
if (completion.usage) {
|
|
117947
|
+
const u = completion.usage;
|
|
117851
117948
|
const inTok = typeof u.prompt_tokens === "number" ? u.prompt_tokens : typeof u.input_tokens === "number" ? u.input_tokens : 0;
|
|
117852
117949
|
const outTok = typeof u.completion_tokens === "number" ? u.completion_tokens : typeof u.output_tokens === "number" ? u.output_tokens : 0;
|
|
117853
117950
|
usage.inputTokens += inTok;
|
|
117854
117951
|
usage.outputTokens += outTok;
|
|
117855
117952
|
}
|
|
117856
|
-
const summary =
|
|
117953
|
+
const summary = completion.message.content || "";
|
|
117857
117954
|
if (summary) {
|
|
117858
117955
|
finalText = summary;
|
|
117859
117956
|
}
|
|
@@ -117864,7 +117961,7 @@ async function callWithTools(config3, messages, tools, executeToolFn, maxSteps =
|
|
|
117864
117961
|
}
|
|
117865
117962
|
}
|
|
117866
117963
|
}
|
|
117867
|
-
return { text: finalText, toolCalls: allToolCalls, usage, stoppedAtStepLimit };
|
|
117964
|
+
return { text: finalText, toolCalls: allToolCalls, usage, stoppedAtStepLimit, textStreamed };
|
|
117868
117965
|
}
|
|
117869
117966
|
var AbortError, LIVE_TOOL_RESULT_MAX_CHARS;
|
|
117870
117967
|
var init_aiDirectClient = __esm({
|
|
@@ -117881,6 +117978,7 @@ var init_aiDirectClient = __esm({
|
|
|
117881
117978
|
this.name = "AbortError";
|
|
117882
117979
|
}
|
|
117883
117980
|
};
|
|
117981
|
+
__name(readCompletion, "readCompletion");
|
|
117884
117982
|
LIVE_TOOL_RESULT_MAX_CHARS = 5e4;
|
|
117885
117983
|
__name(boundLiveToolResult, "boundLiveToolResult");
|
|
117886
117984
|
__name(callWithTools, "callWithTools");
|
|
@@ -118096,6 +118194,20 @@ function buildAiErrorDiagnostics(req, cfg, diagnosticId, rawMessages, pageContex
|
|
|
118096
118194
|
providerRequest: getProviderRequestMeasurement(diagnosticId) ?? null
|
|
118097
118195
|
};
|
|
118098
118196
|
}
|
|
118197
|
+
function providerRequestTelemetry(diagnosticId) {
|
|
118198
|
+
if (!diagnosticId) return null;
|
|
118199
|
+
const measurement = getProviderRequestMeasurement(diagnosticId);
|
|
118200
|
+
if (!measurement) return null;
|
|
118201
|
+
return {
|
|
118202
|
+
requestBodyBytes: measurement.requestBodyBytes,
|
|
118203
|
+
messagesBytes: measurement.messagesBytes,
|
|
118204
|
+
toolsBytes: measurement.toolsBytes,
|
|
118205
|
+
messageCount: measurement.messageCount,
|
|
118206
|
+
toolCount: measurement.toolCount,
|
|
118207
|
+
step: measurement.step,
|
|
118208
|
+
phase: measurement.phase
|
|
118209
|
+
};
|
|
118210
|
+
}
|
|
118099
118211
|
function claimsMutation(text3) {
|
|
118100
118212
|
if (!text3) return false;
|
|
118101
118213
|
if (/✅|☑|\bdone!/i.test(text3)) return true;
|
|
@@ -118698,6 +118810,8 @@ async function handleDirectChat(req, res, cfg, rawMessages, services, pageContex
|
|
|
118698
118810
|
res.setHeader("Content-Type", "text/event-stream");
|
|
118699
118811
|
res.setHeader("Cache-Control", "no-cache");
|
|
118700
118812
|
res.setHeader("Connection", "keep-alive");
|
|
118813
|
+
res.setHeader("X-Accel-Buffering", "no");
|
|
118814
|
+
res.flushHeaders?.();
|
|
118701
118815
|
const sendEvent = /* @__PURE__ */ __name((data) => {
|
|
118702
118816
|
res.write(`data: ${JSON.stringify(data)}
|
|
118703
118817
|
|
|
@@ -118710,6 +118824,8 @@ async function handleDirectChat(req, res, cfg, rawMessages, services, pageContex
|
|
|
118710
118824
|
} catch {
|
|
118711
118825
|
}
|
|
118712
118826
|
let assistantText = "";
|
|
118827
|
+
const textPartId = crypto.randomUUID();
|
|
118828
|
+
let textStarted = false;
|
|
118713
118829
|
try {
|
|
118714
118830
|
const result = await callWithTools2(
|
|
118715
118831
|
{ apiKey: cfg.apiKey, baseURL: cfg.baseURL, model: cfg.model, diagnosticId },
|
|
@@ -118718,6 +118834,14 @@ async function handleDirectChat(req, res, cfg, rawMessages, services, pageContex
|
|
|
118718
118834
|
executeTool2,
|
|
118719
118835
|
AI_MAX_STEPS,
|
|
118720
118836
|
(event) => {
|
|
118837
|
+
if (event.type === "text" && typeof event.delta === "string" && event.delta) {
|
|
118838
|
+
if (!textStarted) {
|
|
118839
|
+
textStarted = true;
|
|
118840
|
+
sendEvent({ type: "text-start", id: textPartId });
|
|
118841
|
+
}
|
|
118842
|
+
assistantText += event.delta;
|
|
118843
|
+
sendEvent({ type: "text-delta", id: textPartId, delta: event.delta });
|
|
118844
|
+
}
|
|
118721
118845
|
if (event.type === "tool-start") {
|
|
118722
118846
|
const category = resolveToolCategory(event.name, mcpTrust);
|
|
118723
118847
|
sendEvent({ type: "tool-input-start", toolCallId: event.toolCallId, toolName: event.name, category });
|
|
@@ -118732,13 +118856,12 @@ async function handleDirectChat(req, res, cfg, rawMessages, services, pageContex
|
|
|
118732
118856
|
if (result.aborted) {
|
|
118733
118857
|
sendEvent({ type: "cancelled" });
|
|
118734
118858
|
} else {
|
|
118735
|
-
if (result.text) {
|
|
118736
|
-
|
|
118737
|
-
sendEvent({ type: "text-start", id });
|
|
118859
|
+
if (result.text && !result.textStreamed) {
|
|
118860
|
+
sendEvent({ type: "text-start", id: textPartId });
|
|
118738
118861
|
for (const word of result.text.split(" ")) {
|
|
118739
|
-
sendEvent({ type: "text-delta", id, delta: word + " " });
|
|
118862
|
+
sendEvent({ type: "text-delta", id: textPartId, delta: word + " " });
|
|
118740
118863
|
}
|
|
118741
|
-
assistantText +=
|
|
118864
|
+
assistantText += result.text;
|
|
118742
118865
|
}
|
|
118743
118866
|
if (mutatingSuccessCount === 0 && claimsMutation(assistantText)) {
|
|
118744
118867
|
sendEvent({
|
|
@@ -118758,6 +118881,15 @@ async function handleDirectChat(req, res, cfg, rawMessages, services, pageContex
|
|
|
118758
118881
|
...cost !== void 0 ? { cost } : {}
|
|
118759
118882
|
});
|
|
118760
118883
|
}
|
|
118884
|
+
const requestMetrics = providerRequestTelemetry(diagnosticId);
|
|
118885
|
+
if (requestMetrics) {
|
|
118886
|
+
sendEvent({
|
|
118887
|
+
type: "request-metrics",
|
|
118888
|
+
model: cfg.model,
|
|
118889
|
+
provider: cfg.provider,
|
|
118890
|
+
...requestMetrics
|
|
118891
|
+
});
|
|
118892
|
+
}
|
|
118761
118893
|
if (result.stoppedAtStepLimit) {
|
|
118762
118894
|
sendEvent({ type: "step-limit-reached", limit: AI_MAX_STEPS });
|
|
118763
118895
|
}
|
|
@@ -118905,6 +119037,7 @@ For a complete documentation review, never load a large document body in one cal
|
|
|
118905
119037
|
__name(filterToolsForMode, "filterToolsForMode");
|
|
118906
119038
|
__name(enrichErrorEvent, "enrichErrorEvent");
|
|
118907
119039
|
__name(buildAiErrorDiagnostics, "buildAiErrorDiagnostics");
|
|
119040
|
+
__name(providerRequestTelemetry, "providerRequestTelemetry");
|
|
118908
119041
|
GATED_CATEGORIES = /* @__PURE__ */ new Set([
|
|
118909
119042
|
"create",
|
|
118910
119043
|
"modify",
|
|
@@ -119387,6 +119520,7 @@ Be concise in your responses. Show a summary of what you created.`;
|
|
|
119387
119520
|
const reader = response.body.getReader();
|
|
119388
119521
|
const decoder = new TextDecoder();
|
|
119389
119522
|
const seenTextParts = /* @__PURE__ */ new Set();
|
|
119523
|
+
let upstreamSseBuffer = "";
|
|
119390
119524
|
const cleanup = /* @__PURE__ */ __name(() => {
|
|
119391
119525
|
req.off("close", onAbort);
|
|
119392
119526
|
req.off("aborted", onAbort);
|
|
@@ -119481,6 +119615,20 @@ Be concise in your responses. Show a summary of what you created.`;
|
|
|
119481
119615
|
...cost !== void 0 ? { cost } : {}
|
|
119482
119616
|
})}
|
|
119483
119617
|
|
|
119618
|
+
`);
|
|
119619
|
+
} catch {
|
|
119620
|
+
}
|
|
119621
|
+
}
|
|
119622
|
+
const requestMetrics = providerRequestTelemetry(diagnosticId);
|
|
119623
|
+
if (requestMetrics) {
|
|
119624
|
+
try {
|
|
119625
|
+
res.write(`data: ${JSON.stringify({
|
|
119626
|
+
type: "request-metrics",
|
|
119627
|
+
model: cfg.model,
|
|
119628
|
+
provider: cfg.provider,
|
|
119629
|
+
...requestMetrics
|
|
119630
|
+
})}
|
|
119631
|
+
|
|
119484
119632
|
`);
|
|
119485
119633
|
} catch {
|
|
119486
119634
|
}
|
|
@@ -119497,8 +119645,9 @@ Be concise in your responses. Show a summary of what you created.`;
|
|
|
119497
119645
|
cleanup();
|
|
119498
119646
|
break;
|
|
119499
119647
|
}
|
|
119500
|
-
|
|
119501
|
-
const lines =
|
|
119648
|
+
upstreamSseBuffer += decoder.decode(value, { stream: true });
|
|
119649
|
+
const lines = upstreamSseBuffer.split(/\r?\n/);
|
|
119650
|
+
upstreamSseBuffer = lines.pop() ?? "";
|
|
119502
119651
|
const output = [];
|
|
119503
119652
|
for (const line of lines) {
|
|
119504
119653
|
if (line.startsWith("data: ")) {
|
|
@@ -119537,7 +119686,8 @@ Be concise in your responses. Show a summary of what you created.`;
|
|
|
119537
119686
|
}
|
|
119538
119687
|
output.push(line);
|
|
119539
119688
|
}
|
|
119540
|
-
res.write(output.join("\n")
|
|
119689
|
+
if (output.length > 0) res.write(`${output.join("\n")}
|
|
119690
|
+
`);
|
|
119541
119691
|
}
|
|
119542
119692
|
}, "pump");
|
|
119543
119693
|
pump().catch((err) => {
|
|
@@ -161993,8 +162143,12 @@ function diffModels(left, right) {
|
|
|
161993
162143
|
const rightByName = new Map(right.packages.map((p) => [p.packageName, p]));
|
|
161994
162144
|
const leftEntityPkg = /* @__PURE__ */ new Map();
|
|
161995
162145
|
const rightEntityPkg = /* @__PURE__ */ new Map();
|
|
162146
|
+
const leftEntityByUuid = /* @__PURE__ */ new Map();
|
|
161996
162147
|
for (const pkg of left.packages) {
|
|
161997
|
-
for (const e of pkg.entities)
|
|
162148
|
+
for (const e of pkg.entities) {
|
|
162149
|
+
leftEntityPkg.set(e.uuid, pkg.packageName);
|
|
162150
|
+
leftEntityByUuid.set(e.uuid, e);
|
|
162151
|
+
}
|
|
161998
162152
|
}
|
|
161999
162153
|
for (const pkg of right.packages) {
|
|
162000
162154
|
for (const e of pkg.entities) rightEntityPkg.set(e.uuid, pkg.packageName);
|
|
@@ -162003,7 +162157,8 @@ function diffModels(left, right) {
|
|
|
162003
162157
|
for (const [uuid3, rightPkg] of rightEntityPkg) {
|
|
162004
162158
|
const leftPkg = leftEntityPkg.get(uuid3);
|
|
162005
162159
|
if (leftPkg && leftPkg !== rightPkg) {
|
|
162006
|
-
|
|
162160
|
+
const leftEntity = leftEntityByUuid.get(uuid3);
|
|
162161
|
+
if (leftEntity) movedEntities.set(uuid3, { from: leftPkg, to: rightPkg, left: leftEntity });
|
|
162007
162162
|
}
|
|
162008
162163
|
}
|
|
162009
162164
|
const allPackageNames = /* @__PURE__ */ new Set([...leftByName.keys(), ...rightByName.keys()]);
|
|
@@ -162073,10 +162228,10 @@ function diffEntityLists(leftEntities, rightEntities, movedEntities, currentPkg)
|
|
|
162073
162228
|
const moveInfo = movedEntities.get(uuid3);
|
|
162074
162229
|
if (moveInfo && moveInfo.to === currentPkg) {
|
|
162075
162230
|
matched.add(uuid3);
|
|
162076
|
-
const left2 =
|
|
162077
|
-
const attrs2 =
|
|
162078
|
-
const constraints2 =
|
|
162079
|
-
const changedFields2 =
|
|
162231
|
+
const left2 = moveInfo.left;
|
|
162232
|
+
const attrs2 = diffAttributeLists(left2.attributes, right.attributes);
|
|
162233
|
+
const constraints2 = diffConstraintLists(left2.constraints, right.constraints);
|
|
162234
|
+
const changedFields2 = diffEntityFields(left2, right);
|
|
162080
162235
|
diffs.push({
|
|
162081
162236
|
status: "moved",
|
|
162082
162237
|
entityUuid: uuid3,
|
|
@@ -163107,8 +163262,7 @@ function diffEntityOrphaned(modelEntity, tableName) {
|
|
|
163107
163262
|
};
|
|
163108
163263
|
});
|
|
163109
163264
|
return {
|
|
163110
|
-
status: "
|
|
163111
|
-
// entity exists in model with physical mapping, just table missing
|
|
163265
|
+
status: "modelOnly",
|
|
163112
163266
|
entityName: modelEntity.name,
|
|
163113
163267
|
entityUuid: modelEntity.uuid,
|
|
163114
163268
|
physicalTableName: tableName,
|
|
@@ -163219,22 +163373,36 @@ function diffConstraints(model, source) {
|
|
|
163219
163373
|
const modelByKey = new Map(modelList.map((c) => [constraintKey3(c), c]));
|
|
163220
163374
|
const sourceByKey = new Map(sourceList.map((c) => [constraintKey3(c), c]));
|
|
163221
163375
|
const matched = /* @__PURE__ */ new Set();
|
|
163222
|
-
for (const [key2,
|
|
163223
|
-
const
|
|
163224
|
-
if (!
|
|
163225
|
-
diffs.push({ status: "added", key: key2,
|
|
163376
|
+
for (const [key2, m] of modelByKey) {
|
|
163377
|
+
const s = sourceByKey.get(key2);
|
|
163378
|
+
if (!s) {
|
|
163379
|
+
diffs.push({ status: "added", key: key2, model: m });
|
|
163226
163380
|
continue;
|
|
163227
163381
|
}
|
|
163228
163382
|
matched.add(key2);
|
|
163229
|
-
diffs.push({
|
|
163383
|
+
diffs.push({
|
|
163384
|
+
status: constraintsEqual2(m, s) ? "matched" : "drifted",
|
|
163385
|
+
key: key2,
|
|
163386
|
+
model: m,
|
|
163387
|
+
source: s
|
|
163388
|
+
});
|
|
163230
163389
|
}
|
|
163231
|
-
for (const [key2,
|
|
163390
|
+
for (const [key2, s] of sourceByKey) {
|
|
163232
163391
|
if (matched.has(key2)) continue;
|
|
163233
|
-
diffs.push({ status: "removed", key: key2,
|
|
163392
|
+
diffs.push({ status: "removed", key: key2, source: s });
|
|
163234
163393
|
}
|
|
163235
163394
|
return diffs;
|
|
163236
163395
|
}
|
|
163237
163396
|
__name(diffConstraints, "diffConstraints");
|
|
163397
|
+
function constraintsEqual2(model, source) {
|
|
163398
|
+
if (model.kind !== source.kind) return false;
|
|
163399
|
+
if ((model.columns || []).join(",") !== (source.columns || []).join(",")) return false;
|
|
163400
|
+
if ((model.expression || "").replace(/\s+/g, " ").trim() !== (source.expression || "").replace(/\s+/g, " ").trim()) return false;
|
|
163401
|
+
const modelRef = model.references ? `${model.references.table}|${(model.references.columns || []).join(",")}` : "";
|
|
163402
|
+
const sourceRef = source.references ? `${source.references.table}|${(source.references.columns || []).join(",")}` : "";
|
|
163403
|
+
return modelRef === sourceRef;
|
|
163404
|
+
}
|
|
163405
|
+
__name(constraintsEqual2, "constraintsEqual");
|
|
163238
163406
|
function buildSummary2(entities) {
|
|
163239
163407
|
const summary = {
|
|
163240
163408
|
matched: 0,
|
|
@@ -163242,13 +163410,17 @@ function buildSummary2(entities) {
|
|
|
163242
163410
|
orphaned: 0,
|
|
163243
163411
|
dbOnly: 0,
|
|
163244
163412
|
drifted: 0,
|
|
163245
|
-
entities: { matched: 0, modelOnly: 0, dbOnly: 0 }
|
|
163413
|
+
entities: { matched: 0, modelOnly: 0, dbOnly: 0 },
|
|
163414
|
+
constraints: { matched: 0, added: 0, removed: 0, drifted: 0 }
|
|
163246
163415
|
};
|
|
163247
163416
|
for (const e of entities) {
|
|
163248
163417
|
summary.entities[e.status]++;
|
|
163249
163418
|
for (const a of e.attributes) {
|
|
163250
163419
|
summary[a.status]++;
|
|
163251
163420
|
}
|
|
163421
|
+
for (const constraint of e.constraints) {
|
|
163422
|
+
summary.constraints[constraint.status]++;
|
|
163423
|
+
}
|
|
163252
163424
|
}
|
|
163253
163425
|
return summary;
|
|
163254
163426
|
}
|
|
@@ -163356,28 +163528,49 @@ function buildImpactDiff(physicalDiff2, dialect = "postgres") {
|
|
|
163356
163528
|
}
|
|
163357
163529
|
}
|
|
163358
163530
|
for (const c of entity.constraints) {
|
|
163359
|
-
if (c.status === "added" && c.
|
|
163360
|
-
const isFK = c.
|
|
163531
|
+
if (c.status === "added" && c.model) {
|
|
163532
|
+
const isFK = c.model.kind === "foreignKey";
|
|
163361
163533
|
ops.push({
|
|
163362
163534
|
order: 0,
|
|
163363
163535
|
type: isFK ? "ADD_FOREIGN_KEY" : "ADD_CONSTRAINT",
|
|
163364
163536
|
table,
|
|
163365
|
-
details: { kind: c.
|
|
163537
|
+
details: { kind: c.model.kind, key: c.key },
|
|
163366
163538
|
destructive: false,
|
|
163367
163539
|
risk: isFK ? "caution" : "safe",
|
|
163368
163540
|
riskReason: isFK ? "May fail if orphan rows exist" : void 0
|
|
163369
163541
|
});
|
|
163370
|
-
} else if (c.status === "removed" && c.
|
|
163371
|
-
const isFK = c.
|
|
163542
|
+
} else if (c.status === "removed" && c.source) {
|
|
163543
|
+
const isFK = c.source.kind === "foreignKey";
|
|
163372
163544
|
ops.push({
|
|
163373
163545
|
order: 0,
|
|
163374
163546
|
type: isFK ? "DROP_FOREIGN_KEY" : "DROP_CONSTRAINT",
|
|
163375
163547
|
table,
|
|
163376
|
-
details: { kind: c.
|
|
163548
|
+
details: { kind: c.source.kind, key: c.key },
|
|
163377
163549
|
destructive: false,
|
|
163378
163550
|
risk: "caution",
|
|
163379
163551
|
riskReason: isFK ? "Removing FK relaxes referential integrity" : "Constraint removal"
|
|
163380
163552
|
});
|
|
163553
|
+
} else if (c.status === "drifted" && c.model && c.source) {
|
|
163554
|
+
const sourceIsFK = c.source.kind === "foreignKey";
|
|
163555
|
+
const modelIsFK = c.model.kind === "foreignKey";
|
|
163556
|
+
ops.push({
|
|
163557
|
+
order: 0,
|
|
163558
|
+
type: sourceIsFK ? "DROP_FOREIGN_KEY" : "DROP_CONSTRAINT",
|
|
163559
|
+
table,
|
|
163560
|
+
details: { kind: c.source.kind, key: c.key },
|
|
163561
|
+
destructive: false,
|
|
163562
|
+
risk: "caution",
|
|
163563
|
+
riskReason: "Constraint definition changed"
|
|
163564
|
+
});
|
|
163565
|
+
ops.push({
|
|
163566
|
+
order: 0,
|
|
163567
|
+
type: modelIsFK ? "ADD_FOREIGN_KEY" : "ADD_CONSTRAINT",
|
|
163568
|
+
table,
|
|
163569
|
+
details: { kind: c.model.kind, key: c.key },
|
|
163570
|
+
destructive: false,
|
|
163571
|
+
risk: modelIsFK ? "caution" : "safe",
|
|
163572
|
+
riskReason: modelIsFK ? "May fail if orphan rows exist" : void 0
|
|
163573
|
+
});
|
|
163381
163574
|
}
|
|
163382
163575
|
}
|
|
163383
163576
|
}
|
|
@@ -165370,8 +165563,17 @@ var physicalDiff = /* @__PURE__ */ __name(async (req, res) => {
|
|
|
165370
165563
|
return res.status(400).json({ message: parsed.errors[0], data: parsed });
|
|
165371
165564
|
}
|
|
165372
165565
|
sourceEntities = parsed.entities;
|
|
165566
|
+
} else if (source.type === "live") {
|
|
165567
|
+
if (!source.credentials?.user || !source.credentials?.password) {
|
|
165568
|
+
return res.status(400).json({ message: "source.credentials.user and password are required for type live" });
|
|
165569
|
+
}
|
|
165570
|
+
sourceEntities = await introspectServiceLive(
|
|
165571
|
+
service,
|
|
165572
|
+
source.credentials,
|
|
165573
|
+
source.connectionOverrides
|
|
165574
|
+
);
|
|
165373
165575
|
} else {
|
|
165374
|
-
return res.status(400).json({ message: `Unsupported source type: ${source.type}. Supported: ddl` });
|
|
165576
|
+
return res.status(400).json({ message: `Unsupported source type: ${source.type}. Supported: ddl, live` });
|
|
165375
165577
|
}
|
|
165376
165578
|
const diff = diffPhysicalModel(modelEntities, sourceEntities);
|
|
165377
165579
|
res.json({
|
|
@@ -165398,6 +165600,15 @@ var impactDiffEndpoint = /* @__PURE__ */ __name(async (req, res) => {
|
|
|
165398
165600
|
if (!source.sql) return res.status(400).json({ message: "source.sql is required" });
|
|
165399
165601
|
const parsed = importService.parseSqlDdl(source.sql, source.options || {});
|
|
165400
165602
|
sourceEntities = parsed.entities;
|
|
165603
|
+
} else if (source.type === "live") {
|
|
165604
|
+
if (!source.credentials?.user || !source.credentials?.password) {
|
|
165605
|
+
return res.status(400).json({ message: "source.credentials.user and password are required for type live" });
|
|
165606
|
+
}
|
|
165607
|
+
sourceEntities = await introspectServiceLive(
|
|
165608
|
+
service,
|
|
165609
|
+
source.credentials,
|
|
165610
|
+
source.connectionOverrides
|
|
165611
|
+
);
|
|
165401
165612
|
} else {
|
|
165402
165613
|
return res.status(400).json({ message: `Unsupported source type: ${source.type}` });
|
|
165403
165614
|
}
|
|
@@ -165516,6 +165727,7 @@ var physicalDiffAll = /* @__PURE__ */ __name(async (req, res) => {
|
|
|
165516
165727
|
const serviceList = services && services.length > 0 ? services : await listMicroservices();
|
|
165517
165728
|
const byService = {};
|
|
165518
165729
|
const agg = { matched: 0, drifted: 0, modelOnly: 0, orphaned: 0, dbOnly: 0 };
|
|
165730
|
+
const constraintAgg = { matched: 0, added: 0, removed: 0, drifted: 0 };
|
|
165519
165731
|
let ok2 = 0;
|
|
165520
165732
|
let failed = 0;
|
|
165521
165733
|
for (const serviceName of serviceList) {
|
|
@@ -165540,6 +165752,10 @@ var physicalDiffAll = /* @__PURE__ */ __name(async (req, res) => {
|
|
|
165540
165752
|
agg.modelOnly += diff.summary.modelOnly;
|
|
165541
165753
|
agg.orphaned += diff.summary.orphaned;
|
|
165542
165754
|
agg.dbOnly += diff.summary.dbOnly;
|
|
165755
|
+
constraintAgg.matched += diff.summary.constraints.matched;
|
|
165756
|
+
constraintAgg.added += diff.summary.constraints.added;
|
|
165757
|
+
constraintAgg.removed += diff.summary.constraints.removed;
|
|
165758
|
+
constraintAgg.drifted += diff.summary.constraints.drifted;
|
|
165543
165759
|
}
|
|
165544
165760
|
res.json({
|
|
165545
165761
|
message: `Physical diff (all): ${ok2} ok, ${failed} failed across ${serviceList.length} services`,
|
|
@@ -165549,7 +165765,8 @@ var physicalDiffAll = /* @__PURE__ */ __name(async (req, res) => {
|
|
|
165549
165765
|
services: serviceList.length,
|
|
165550
165766
|
ok: ok2,
|
|
165551
165767
|
failed,
|
|
165552
|
-
...agg
|
|
165768
|
+
...agg,
|
|
165769
|
+
constraints: constraintAgg
|
|
165553
165770
|
}
|
|
165554
165771
|
}
|
|
165555
165772
|
});
|
package/frontend/dist/assets/{abnfDiagram-VRR7QNED-1ac4ac09.js → abnfDiagram-VRR7QNED-8c74b88a.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as a,r as p,g as u}from"./chunk-MOJQB5TN-
|
|
1
|
+
import{d as a,r as p,g as u}from"./chunk-MOJQB5TN-84f3f036.js";import{p as f}from"./chunk-JWPE2WC7-a2b75edb.js";import{_ as n,l as o}from"./mermaid.core-955570af.js";import{o as c,M as d}from"./mermaid-parser.core-8b2bc368.js";import"./index-28d0efa6.js";var v=c().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new d(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:p,styles:u};export{B as diagram};
|