drizzle-cube 0.4.10 → 0.4.13
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/dist/adapters/express/index.cjs +1 -1
- package/dist/adapters/express/index.js +2 -2
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.js +2 -2
- package/dist/adapters/{handler-CySCodwi.js → handler-CQkIwtxp.js} +97 -65
- package/dist/adapters/{handler-e6zofK2k.cjs → handler-dnkqpznh.cjs} +11 -11
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +2 -2
- package/dist/adapters/{mcp-transport-KX92EgkF.cjs → mcp-transport-8u9G5oNa.cjs} +9 -9
- package/dist/adapters/{mcp-transport-CU5g9bxj.js → mcp-transport-m1X1GtwG.js} +13 -4
- package/dist/adapters/nextjs/index.cjs +2 -2
- package/dist/adapters/nextjs/index.js +2 -2
- package/dist/client/hooks/useAgentChat.d.ts +1 -1
- package/dist/client/index.js +563 -521
- package/dist/client/index.js.map +1 -1
- package/dist/client/stores/notebookStore.d.ts +3 -0
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.cjs +15 -15
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +110 -69
- package/package.json +1 -1
package/dist/server/index.d.ts
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -2050,14 +2050,14 @@ function B(r, e) {
|
|
|
2050
2050
|
const t = typeof r == "function" ? r(e) : r;
|
|
2051
2051
|
return lt(t);
|
|
2052
2052
|
}
|
|
2053
|
-
function
|
|
2053
|
+
function zT(r, e, t) {
|
|
2054
2054
|
return {
|
|
2055
2055
|
...r,
|
|
2056
2056
|
cubes: e,
|
|
2057
2057
|
currentCube: t
|
|
2058
2058
|
};
|
|
2059
2059
|
}
|
|
2060
|
-
function
|
|
2060
|
+
function eA(r, e) {
|
|
2061
2061
|
return {
|
|
2062
2062
|
name: r,
|
|
2063
2063
|
...e
|
|
@@ -2291,7 +2291,7 @@ function gt(r) {
|
|
|
2291
2291
|
e ^= r.charCodeAt(t), e = e * 16777619 >>> 0;
|
|
2292
2292
|
return e.toString(16).padStart(8, "0");
|
|
2293
2293
|
}
|
|
2294
|
-
function
|
|
2294
|
+
function tA(r, e) {
|
|
2295
2295
|
return `${e ?? "drizzle-cube:"}*${r}*`;
|
|
2296
2296
|
}
|
|
2297
2297
|
class Oe {
|
|
@@ -7545,7 +7545,7 @@ class Vn {
|
|
|
7545
7545
|
return e;
|
|
7546
7546
|
}
|
|
7547
7547
|
}
|
|
7548
|
-
class
|
|
7548
|
+
class sA {
|
|
7549
7549
|
name = "pipeline";
|
|
7550
7550
|
passes;
|
|
7551
7551
|
constructor(e = []) {
|
|
@@ -29594,7 +29594,10 @@ function ws(r, e) {
|
|
|
29594
29594
|
t.push(`Cube '${a}' not found (referenced in measure '${E}')`);
|
|
29595
29595
|
continue;
|
|
29596
29596
|
}
|
|
29597
|
-
o.measures[A]
|
|
29597
|
+
if (!o.measures[A]) {
|
|
29598
|
+
const R = A === a ? `. Did you mean one of: ${Object.keys(o.measures).slice(0, 5).map((S) => `'${a}.${S}'`).join(", ")}?` : "";
|
|
29599
|
+
t.push(`Measure '${A}' not found on cube '${a}'${R}`);
|
|
29600
|
+
}
|
|
29598
29601
|
}
|
|
29599
29602
|
if (e.dimensions)
|
|
29600
29603
|
for (const E of e.dimensions) {
|
|
@@ -29609,7 +29612,10 @@ function ws(r, e) {
|
|
|
29609
29612
|
t.push(`Cube '${a}' not found (referenced in dimension '${E}')`);
|
|
29610
29613
|
continue;
|
|
29611
29614
|
}
|
|
29612
|
-
o.dimensions[A]
|
|
29615
|
+
if (!o.dimensions[A]) {
|
|
29616
|
+
const R = A === a ? `. Did you mean one of: ${Object.keys(o.dimensions).slice(0, 5).map((S) => `'${a}.${S}'`).join(", ")}?` : "";
|
|
29617
|
+
t.push(`Dimension '${A}' not found on cube '${a}'${R}`);
|
|
29618
|
+
}
|
|
29613
29619
|
}
|
|
29614
29620
|
if (e.timeDimensions)
|
|
29615
29621
|
for (const E of e.timeDimensions) {
|
|
@@ -29656,7 +29662,10 @@ function $s(r, e, t, s) {
|
|
|
29656
29662
|
t.push(`Cube '${n}' not found (referenced in filter '${r.member}')`);
|
|
29657
29663
|
return;
|
|
29658
29664
|
}
|
|
29659
|
-
!E.dimensions[i] && !E.measures[i]
|
|
29665
|
+
if (!E.dimensions[i] && !E.measures[i]) {
|
|
29666
|
+
const a = i === n ? `. Did you mean one of: ${[...Object.keys(E.dimensions), ...Object.keys(E.measures)].slice(0, 5).map((A) => `'${n}.${A}'`).join(", ")}?` : "";
|
|
29667
|
+
t.push(`Filter field '${i}' not found on cube '${n}' (must be a dimension or measure)${a}`);
|
|
29668
|
+
}
|
|
29660
29669
|
}
|
|
29661
29670
|
function zo(r) {
|
|
29662
29671
|
if (typeof r == "string") {
|
|
@@ -29665,7 +29674,7 @@ function zo(r) {
|
|
|
29665
29674
|
}
|
|
29666
29675
|
return r.cube;
|
|
29667
29676
|
}
|
|
29668
|
-
class
|
|
29677
|
+
class nA {
|
|
29669
29678
|
cache = /* @__PURE__ */ new Map();
|
|
29670
29679
|
defaultTtlMs;
|
|
29671
29680
|
maxEntries;
|
|
@@ -29854,7 +29863,7 @@ Return ONLY valid JSON with no explanations:
|
|
|
29854
29863
|
}
|
|
29855
29864
|
|
|
29856
29865
|
CRITICAL: Be strict. When in doubt, reject. False positives are better than security breaches.`;
|
|
29857
|
-
function
|
|
29866
|
+
function iA(r) {
|
|
29858
29867
|
return eT.replace("{USER_PROMPT}", r);
|
|
29859
29868
|
}
|
|
29860
29869
|
const tT = `You are a helpful AI assistant for analyzing business data using Cube.js/Drizzle-Cube semantic layer.
|
|
@@ -29994,7 +30003,7 @@ USER QUERY:
|
|
|
29994
30003
|
{USER_PROMPT}
|
|
29995
30004
|
|
|
29996
30005
|
Return the JSON response:`;
|
|
29997
|
-
function
|
|
30006
|
+
function rA(r, e) {
|
|
29998
30007
|
return tT.replace("{CUBE_SCHEMA}", r).replace("{USER_PROMPT}", e);
|
|
29999
30008
|
}
|
|
30000
30009
|
const sT = `You are analyzing a data query request to determine its structure.
|
|
@@ -30026,7 +30035,7 @@ USER QUERY:
|
|
|
30026
30035
|
{USER_PROMPT}
|
|
30027
30036
|
|
|
30028
30037
|
Return ONLY valid JSON - no explanations or markdown:`;
|
|
30029
|
-
function
|
|
30038
|
+
function EA(r, e) {
|
|
30030
30039
|
return sT.replace("{CUBE_SCHEMA}", r).replace("{USER_PROMPT}", e);
|
|
30031
30040
|
}
|
|
30032
30041
|
const nT = `Complete the data query using actual dimension values from the database.
|
|
@@ -30086,7 +30095,7 @@ CRITICAL FILTER FORMAT RULES:
|
|
|
30086
30095
|
- The time filter (inDateRange) goes ONLY on step 0's filter, not on other steps.
|
|
30087
30096
|
|
|
30088
30097
|
Return ONLY valid JSON - no explanations or markdown:`;
|
|
30089
|
-
function
|
|
30098
|
+
function aA(r, e, t) {
|
|
30090
30099
|
const s = JSON.stringify(t, null, 2);
|
|
30091
30100
|
return nT.replace("{CUBE_SCHEMA}", r).replace("{USER_PROMPT}", e).replace("{DIMENSION_VALUES}", s);
|
|
30092
30101
|
}
|
|
@@ -30333,10 +30342,10 @@ RESPONSE FORMAT (JSON):
|
|
|
30333
30342
|
}
|
|
30334
30343
|
|
|
30335
30344
|
CRITICAL: Return ONLY valid JSON. No markdown, no explanations outside JSON.`;
|
|
30336
|
-
function
|
|
30345
|
+
function oA(r, e, t, s, n, i, E) {
|
|
30337
30346
|
return iT.replace("{DATABASE_TYPE}", r).replaceAll("{DATABASE_TYPE}", r).replace("{CUBE_SCHEMA}", e).replace("{SEMANTIC_QUERY}", t).replace("{SQL_QUERY}", s).replace("{NORMALIZED_PLAN}", n).replace("{RAW_EXPLAIN}", i).replace("{EXISTING_INDEXES}", E || "No index information available");
|
|
30338
30347
|
}
|
|
30339
|
-
function
|
|
30348
|
+
function TA(r) {
|
|
30340
30349
|
const e = {};
|
|
30341
30350
|
for (const t of r) {
|
|
30342
30351
|
e[t.name] = {
|
|
@@ -30365,7 +30374,7 @@ function oA(r) {
|
|
|
30365
30374
|
}
|
|
30366
30375
|
return JSON.stringify({ cubes: e }, null, 2);
|
|
30367
30376
|
}
|
|
30368
|
-
function
|
|
30377
|
+
function AA(r) {
|
|
30369
30378
|
if (!r || r.length === 0)
|
|
30370
30379
|
return "No indexes found on the queried tables.";
|
|
30371
30380
|
const e = {};
|
|
@@ -30433,7 +30442,7 @@ const rT = {
|
|
|
30433
30442
|
type: "text",
|
|
30434
30443
|
text: [
|
|
30435
30444
|
"Rules (keep JSON only):",
|
|
30436
|
-
"- Use only measures/dimensions/timeDimensions from schema.",
|
|
30445
|
+
"- Use only measures/dimensions/timeDimensions from schema. Fields are always `CubeName.fieldName` — never use just the cube name (e.g. `PullRequests.count` not `PullRequests`).",
|
|
30437
30446
|
"- timeDimensions: include granularity when grouping; use inDateRange filter for relative windows; combine when both requested.",
|
|
30438
30447
|
"- Funnel detection keywords: funnel, conversion, journey, drop off, step by step; use funnel format only if eventStream metadata exists.",
|
|
30439
30448
|
"- Funnel rules: bindingKey/timeDimension from cube metadata; include time filter on step 0 (default last 6 months) using inDateRange; steps ordered; flat filters.",
|
|
@@ -30774,6 +30783,7 @@ function AT(r) {
|
|
|
30774
30783
|
"## Important Guidelines",
|
|
30775
30784
|
"",
|
|
30776
30785
|
"- ALWAYS discover cubes first before attempting queries",
|
|
30786
|
+
"- Field names MUST be `CubeName.fieldName` (e.g. `PullRequests.count`, `Teams.name`). NEVER use just the cube name as a field — `PullRequests.PullRequests` is WRONG.",
|
|
30777
30787
|
"- Use `add_portlet` to create visualizations after getting query results",
|
|
30778
30788
|
"- Use `add_markdown` to explain your findings, methodology, and insights",
|
|
30779
30789
|
"- Choose appropriate chart types: bar for categories, line for trends, table for detailed data",
|
|
@@ -30785,15 +30795,20 @@ function AT(r) {
|
|
|
30785
30795
|
"### CRITICAL: Always think before acting",
|
|
30786
30796
|
"- EVERY single turn MUST begin with a text message (1-2 sentences) BEFORE any tool calls. This is your #1 rule — never violate it.",
|
|
30787
30797
|
"- This applies to EVERY turn, including turns where you are adding visualizations or explanations to the notebook.",
|
|
30788
|
-
`- Even when adding multiple
|
|
30789
|
-
'- Example good turn: "Let me
|
|
30790
|
-
`- Example good turn: "I'll add a
|
|
30798
|
+
`- Even when adding multiple charts in sequence, each turn must start with a brief status like "Now I'll chart the productivity breakdown." or "Next, let me show the department comparison."`,
|
|
30799
|
+
'- Example good turn: "Let me see what data is available." → discover_cubes',
|
|
30800
|
+
`- Example good turn: "I'll add a chart showing the top employees." → add_markdown → add_portlet`,
|
|
30791
30801
|
"- Example bad turn: (no text) → add_portlet ← NEVER do this",
|
|
30792
30802
|
"",
|
|
30793
30803
|
"### Text vs Notebook",
|
|
30794
30804
|
"- ALL analysis, findings, methodology, and insights MUST go through `add_markdown` tool calls — never in your text responses",
|
|
30795
30805
|
"- Your text responses must be 1-2 short sentences (under 50 words) summarizing what you are about to do next — status updates only",
|
|
30796
30806
|
"- Never use markdown formatting (headers, bullets, bold, code blocks) in text responses — plain sentences only",
|
|
30807
|
+
"- Write text responses as a friendly analyst would — use plain business language the user understands",
|
|
30808
|
+
'- NEVER mention internal terms like "cube", "query syntax", "field names", "measures", "dimensions", "portlet", "prefix format", or tool names in text responses',
|
|
30809
|
+
'- Instead of "Let me correct the query syntax and retry" → "Let me fix that and try again"',
|
|
30810
|
+
`- Instead of "I'll query the PullRequests cube" → "I'll look at the pull request data"`,
|
|
30811
|
+
`- Instead of "Adding a portlet with the results" → "Here's a chart of the results"`,
|
|
30797
30812
|
"",
|
|
30798
30813
|
"### Notebook content rules",
|
|
30799
30814
|
"- Before each `add_portlet`, ALWAYS call `add_markdown` first to explain WHY you are adding this visualization and what it shows",
|
|
@@ -32597,7 +32612,7 @@ ${I.errors.join(`
|
|
|
32597
32612
|
};
|
|
32598
32613
|
}), s;
|
|
32599
32614
|
}
|
|
32600
|
-
async function*
|
|
32615
|
+
async function* RA(r) {
|
|
32601
32616
|
const { message: e, sessionId: t, semanticLayer: s, securityContext: n, agentConfig: i, apiKey: E } = r;
|
|
32602
32617
|
let a;
|
|
32603
32618
|
try {
|
|
@@ -32680,7 +32695,7 @@ async function* AA(r) {
|
|
|
32680
32695
|
is_error: !0
|
|
32681
32696
|
}), yield {
|
|
32682
32697
|
type: "tool_use_result",
|
|
32683
|
-
data: { id: w, name: U, result: `Unknown tool: ${U}
|
|
32698
|
+
data: { id: w, name: U, result: `Unknown tool: ${U}`, isError: !0 }
|
|
32684
32699
|
};
|
|
32685
32700
|
continue;
|
|
32686
32701
|
}
|
|
@@ -32693,7 +32708,7 @@ async function* AA(r) {
|
|
|
32693
32708
|
...x.isError ? { is_error: !0 } : {}
|
|
32694
32709
|
}), yield {
|
|
32695
32710
|
type: "tool_use_result",
|
|
32696
|
-
data: { id: w, name: U, result: x.result }
|
|
32711
|
+
data: { id: w, name: U, result: x.result, ...x.isError ? { isError: !0 } : {} }
|
|
32697
32712
|
};
|
|
32698
32713
|
} catch (x) {
|
|
32699
32714
|
const k = x instanceof Error ? x.message : "Tool execution failed";
|
|
@@ -32704,7 +32719,7 @@ async function* AA(r) {
|
|
|
32704
32719
|
is_error: !0
|
|
32705
32720
|
}), yield {
|
|
32706
32721
|
type: "tool_use_result",
|
|
32707
|
-
data: { id: w, name: U, result: k }
|
|
32722
|
+
data: { id: w, name: U, result: k, isError: !0 }
|
|
32708
32723
|
};
|
|
32709
32724
|
}
|
|
32710
32725
|
}
|
|
@@ -32718,11 +32733,37 @@ async function* AA(r) {
|
|
|
32718
32733
|
yield {
|
|
32719
32734
|
type: "error",
|
|
32720
32735
|
data: {
|
|
32721
|
-
message: u
|
|
32736
|
+
message: YT(u)
|
|
32722
32737
|
}
|
|
32723
32738
|
};
|
|
32724
32739
|
}
|
|
32725
32740
|
}
|
|
32741
|
+
function YT(r) {
|
|
32742
|
+
if (!r || !(r instanceof Error))
|
|
32743
|
+
return "Something went wrong. Please try again.";
|
|
32744
|
+
const e = r.message || "", t = {
|
|
32745
|
+
overloaded_error: "The AI service is temporarily overloaded. Please try again in a moment.",
|
|
32746
|
+
rate_limit_error: "Too many requests. Please wait a moment and try again.",
|
|
32747
|
+
api_error: "The AI service encountered an error. Please try again.",
|
|
32748
|
+
authentication_error: "Authentication failed. Please check your API key configuration.",
|
|
32749
|
+
invalid_request_error: "There was a problem with the request. Please try again."
|
|
32750
|
+
}, s = r;
|
|
32751
|
+
if (s.status || s.type) {
|
|
32752
|
+
const n = s.error?.type || s.type || "";
|
|
32753
|
+
if (t[n])
|
|
32754
|
+
return t[n];
|
|
32755
|
+
}
|
|
32756
|
+
if (e.startsWith("{") || e.startsWith("Error: {")) {
|
|
32757
|
+
try {
|
|
32758
|
+
const n = JSON.parse(e.replace(/^Error:\s*/, "")), i = n.error?.type || n.type || "";
|
|
32759
|
+
if (t[i])
|
|
32760
|
+
return t[i];
|
|
32761
|
+
} catch {
|
|
32762
|
+
}
|
|
32763
|
+
return "The AI service encountered an error. Please try again.";
|
|
32764
|
+
}
|
|
32765
|
+
return e;
|
|
32766
|
+
}
|
|
32726
32767
|
const cs = {
|
|
32727
32768
|
funnel: {
|
|
32728
32769
|
description: "Track conversion through sequential steps. Entities (identified by bindingKey) move through ordered steps.",
|
|
@@ -32774,7 +32815,7 @@ const cs = {
|
|
|
32774
32815
|
}
|
|
32775
32816
|
}
|
|
32776
32817
|
};
|
|
32777
|
-
function
|
|
32818
|
+
function wT(r, e) {
|
|
32778
32819
|
const t = [];
|
|
32779
32820
|
for (let s = 0; s <= e.length; s++)
|
|
32780
32821
|
t[s] = [s];
|
|
@@ -32798,7 +32839,7 @@ function X(r, e) {
|
|
|
32798
32839
|
if (A === t) return 0.85;
|
|
32799
32840
|
if (A.startsWith(t)) return 0.75;
|
|
32800
32841
|
}
|
|
32801
|
-
const i =
|
|
32842
|
+
const i = wT(t, s), E = Math.max(t.length, s.length), a = 1 - i / E;
|
|
32802
32843
|
return a > 0.5 ? a * 0.7 : 0;
|
|
32803
32844
|
}
|
|
32804
32845
|
function Me(r, e) {
|
|
@@ -32809,7 +32850,7 @@ function Me(r, e) {
|
|
|
32809
32850
|
}
|
|
32810
32851
|
return t;
|
|
32811
32852
|
}
|
|
32812
|
-
function
|
|
32853
|
+
function $T(r) {
|
|
32813
32854
|
const e = /* @__PURE__ */ new Set([
|
|
32814
32855
|
"a",
|
|
32815
32856
|
"an",
|
|
@@ -32903,7 +32944,7 @@ function wT(r) {
|
|
|
32903
32944
|
]);
|
|
32904
32945
|
return r.toLowerCase().replace(/[^\w\s]/g, " ").split(/\s+/).filter((t) => t.length > 2 && !e.has(t));
|
|
32905
32946
|
}
|
|
32906
|
-
function
|
|
32947
|
+
function vT(r, e) {
|
|
32907
32948
|
let t = 0;
|
|
32908
32949
|
const s = [], n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
32909
32950
|
for (const o of e) {
|
|
@@ -33025,12 +33066,12 @@ function vs(r, e = {}) {
|
|
|
33025
33066
|
querySchemas: N ? cs : void 0
|
|
33026
33067
|
};
|
|
33027
33068
|
});
|
|
33028
|
-
const a =
|
|
33069
|
+
const a = $T(E);
|
|
33029
33070
|
if (a.length === 0)
|
|
33030
33071
|
return [];
|
|
33031
33072
|
const A = [];
|
|
33032
33073
|
for (const o of r) {
|
|
33033
|
-
const { score: R, matchedOn: S, suggestedMeasures: l, suggestedDimensions: N } =
|
|
33074
|
+
const { score: R, matchedOn: S, suggestedMeasures: l, suggestedDimensions: N } = vT(o, a);
|
|
33034
33075
|
if (R >= i) {
|
|
33035
33076
|
const I = Ot(o), O = Cs(o), c = ds(o, O), u = I.funnel || I.flow || I.retention;
|
|
33036
33077
|
A.push({
|
|
@@ -33068,7 +33109,7 @@ function mt(r, e, t) {
|
|
|
33068
33109
|
}
|
|
33069
33110
|
return s;
|
|
33070
33111
|
}
|
|
33071
|
-
function
|
|
33112
|
+
function VT() {
|
|
33072
33113
|
const r = /* @__PURE__ */ new Date(), e = r.toISOString().split("T")[0], t = (a) => a.toISOString().split("T")[0], s = (a) => new Date(a.getFullYear(), a.getMonth(), 1), n = (a) => new Date(a.getFullYear(), 0, 1), i = (a) => {
|
|
33073
33114
|
const A = Math.floor(a.getMonth() / 3);
|
|
33074
33115
|
return new Date(a.getFullYear(), A * 3, 1);
|
|
@@ -33198,7 +33239,7 @@ const At = {
|
|
|
33198
33239
|
flow: /\b(flows?|paths?|sequence|before|after|next|previous|user.?journey)\b/i,
|
|
33199
33240
|
retention: /\b(retention|cohort|return|churn|comeback|retained|day.?\d+)\b/i
|
|
33200
33241
|
};
|
|
33201
|
-
function
|
|
33242
|
+
function WT(r) {
|
|
33202
33243
|
const e = r.toLowerCase();
|
|
33203
33244
|
return At.funnel.test(e) ? "funnel" : At.flow.test(e) ? "flow" : At.retention.test(e) ? "retention" : "query";
|
|
33204
33245
|
}
|
|
@@ -33224,8 +33265,8 @@ function ms(r, e) {
|
|
|
33224
33265
|
];
|
|
33225
33266
|
}
|
|
33226
33267
|
}
|
|
33227
|
-
function
|
|
33228
|
-
const e =
|
|
33268
|
+
function xT(r) {
|
|
33269
|
+
const e = VT(), t = r.toLowerCase();
|
|
33229
33270
|
for (const s of e) {
|
|
33230
33271
|
const n = t.match(s.pattern);
|
|
33231
33272
|
if (n) {
|
|
@@ -33253,7 +33294,7 @@ function WT(r) {
|
|
|
33253
33294
|
}
|
|
33254
33295
|
return null;
|
|
33255
33296
|
}
|
|
33256
|
-
function
|
|
33297
|
+
function XT(r) {
|
|
33257
33298
|
const e = r.toLowerCase(), t = [
|
|
33258
33299
|
{ pattern: /\b(total|sum|combined)\b/i, type: "sum" },
|
|
33259
33300
|
{ pattern: /\b(count|number of|how many)\b/i, type: "count" },
|
|
@@ -33266,7 +33307,7 @@ function xT(r) {
|
|
|
33266
33307
|
return { type: n, confidence: 0.8 };
|
|
33267
33308
|
return null;
|
|
33268
33309
|
}
|
|
33269
|
-
function
|
|
33310
|
+
function KT(r) {
|
|
33270
33311
|
const e = r.toLowerCase(), t = [], s = /\bby\s+(\w+(?:\s+\w+)?)/gi;
|
|
33271
33312
|
let n;
|
|
33272
33313
|
for (; (n = s.exec(e)) !== null; )
|
|
@@ -33279,8 +33320,8 @@ function XT(r) {
|
|
|
33279
33320
|
t.push(n[1].trim());
|
|
33280
33321
|
return t;
|
|
33281
33322
|
}
|
|
33282
|
-
function
|
|
33283
|
-
const s = [], n = [], i = {}, E =
|
|
33323
|
+
function SA(r, e, t) {
|
|
33324
|
+
const s = [], n = [], i = {}, E = WT(e);
|
|
33284
33325
|
let a;
|
|
33285
33326
|
if (t) {
|
|
33286
33327
|
const c = r.find((u) => u.name === t);
|
|
@@ -33300,7 +33341,7 @@ function RA(r, e, t) {
|
|
|
33300
33341
|
}
|
|
33301
33342
|
const A = a[0];
|
|
33302
33343
|
let o = 0.5;
|
|
33303
|
-
const R =
|
|
33344
|
+
const R = XT(e);
|
|
33304
33345
|
R && (s.push(`Detected ${R.type} aggregation intent`), o += 0.1);
|
|
33305
33346
|
const S = [], l = e.toLowerCase();
|
|
33306
33347
|
for (const c of A.measures) {
|
|
@@ -33327,7 +33368,7 @@ function RA(r, e, t) {
|
|
|
33327
33368
|
}
|
|
33328
33369
|
}
|
|
33329
33370
|
S.length === 0 && A.measures.length > 0 && (S.push(A.measures[0].name), s.push(`Using default measure: ${A.measures[0].name}`), n.push("Could not determine specific measure from query, using default")), i.measures = S;
|
|
33330
|
-
const N =
|
|
33371
|
+
const N = KT(e), I = [];
|
|
33331
33372
|
for (const c of N) {
|
|
33332
33373
|
const u = mt(a, c, "dimension");
|
|
33333
33374
|
u && (I.push(u.field), s.push(`Matched dimension '${u.field}' from grouping keyword '${c}'`), o += 0.1);
|
|
@@ -33346,7 +33387,7 @@ function RA(r, e, t) {
|
|
|
33346
33387
|
}
|
|
33347
33388
|
}
|
|
33348
33389
|
I.length > 0 && (i.dimensions = I);
|
|
33349
|
-
const O =
|
|
33390
|
+
const O = xT(e);
|
|
33350
33391
|
if (O) {
|
|
33351
33392
|
const c = A.dimensions.find((u) => u.type === "time");
|
|
33352
33393
|
if (c) {
|
|
@@ -33380,7 +33421,7 @@ function RA(r, e, t) {
|
|
|
33380
33421
|
analysisMode: "query"
|
|
33381
33422
|
};
|
|
33382
33423
|
}
|
|
33383
|
-
function
|
|
33424
|
+
function kT(r, e) {
|
|
33384
33425
|
const t = [];
|
|
33385
33426
|
for (let s = 0; s <= e.length; s++)
|
|
33386
33427
|
t[s] = [s];
|
|
@@ -33398,12 +33439,12 @@ function KT(r, e) {
|
|
|
33398
33439
|
function Se(r, e) {
|
|
33399
33440
|
let t = null;
|
|
33400
33441
|
for (const s of e) {
|
|
33401
|
-
const n =
|
|
33442
|
+
const n = kT(r.toLowerCase(), s.toLowerCase());
|
|
33402
33443
|
n <= 3 && (!t || n < t.distance) && (t = { field: s, distance: n });
|
|
33403
33444
|
}
|
|
33404
33445
|
return t;
|
|
33405
33446
|
}
|
|
33406
|
-
function
|
|
33447
|
+
function JT(r, e, t, s) {
|
|
33407
33448
|
const n = r.split(".");
|
|
33408
33449
|
if (n.length !== 2) {
|
|
33409
33450
|
t.push({
|
|
@@ -33576,7 +33617,7 @@ function Ue(r, e, t, s) {
|
|
|
33576
33617
|
}
|
|
33577
33618
|
}
|
|
33578
33619
|
}
|
|
33579
|
-
function
|
|
33620
|
+
function QT(r, e, t, s, n) {
|
|
33580
33621
|
const i = r.funnel;
|
|
33581
33622
|
if (i)
|
|
33582
33623
|
if (i.bindingKey ? typeof i.bindingKey == "string" && te(i.bindingKey, e, t, n) : t.push({
|
|
@@ -33605,7 +33646,7 @@ function JT(r, e, t, s, n) {
|
|
|
33605
33646
|
}), a.filter && "member" in a.filter && Ue([a.filter], e, t, n);
|
|
33606
33647
|
}
|
|
33607
33648
|
}
|
|
33608
|
-
function
|
|
33649
|
+
function qT(r, e, t, s, n) {
|
|
33609
33650
|
const i = r.flow;
|
|
33610
33651
|
i && (i.bindingKey ? typeof i.bindingKey == "string" && te(i.bindingKey, e, t, n) : t.push({
|
|
33611
33652
|
type: "syntax_error",
|
|
@@ -33622,7 +33663,7 @@ function QT(r, e, t, s, n) {
|
|
|
33622
33663
|
suggestion: "Set stepsBefore and/or stepsAfter to see event sequences"
|
|
33623
33664
|
}));
|
|
33624
33665
|
}
|
|
33625
|
-
function
|
|
33666
|
+
function jT(r, e, t, s, n) {
|
|
33626
33667
|
const i = r.retention;
|
|
33627
33668
|
i && (i.bindingKey ? typeof i.bindingKey == "string" && te(i.bindingKey, e, t, n) : t.push({
|
|
33628
33669
|
type: "syntax_error",
|
|
@@ -33640,10 +33681,10 @@ function qT(r, e, t, s, n) {
|
|
|
33640
33681
|
suggestion: "Specify number of periods to analyze"
|
|
33641
33682
|
}));
|
|
33642
33683
|
}
|
|
33643
|
-
function
|
|
33684
|
+
function lA(r, e) {
|
|
33644
33685
|
const t = [], s = [], n = /* @__PURE__ */ new Map();
|
|
33645
33686
|
if (r.funnel)
|
|
33646
|
-
return
|
|
33687
|
+
return QT(r, e, t, s, n), {
|
|
33647
33688
|
isValid: t.length === 0,
|
|
33648
33689
|
errors: t,
|
|
33649
33690
|
warnings: s,
|
|
@@ -33651,14 +33692,14 @@ function SA(r, e) {
|
|
|
33651
33692
|
// Funnel corrections not implemented yet
|
|
33652
33693
|
};
|
|
33653
33694
|
if (r.flow)
|
|
33654
|
-
return
|
|
33695
|
+
return qT(r, e, t, s, n), {
|
|
33655
33696
|
isValid: t.length === 0,
|
|
33656
33697
|
errors: t,
|
|
33657
33698
|
warnings: s,
|
|
33658
33699
|
correctedQuery: void 0
|
|
33659
33700
|
};
|
|
33660
33701
|
if (r.retention)
|
|
33661
|
-
return
|
|
33702
|
+
return jT(r, e, t, s, n), {
|
|
33662
33703
|
isValid: t.length === 0,
|
|
33663
33704
|
errors: t,
|
|
33664
33705
|
warnings: s,
|
|
@@ -33666,7 +33707,7 @@ function SA(r, e) {
|
|
|
33666
33707
|
};
|
|
33667
33708
|
if (r.measures)
|
|
33668
33709
|
for (const E of r.measures)
|
|
33669
|
-
|
|
33710
|
+
JT(E, e, t, n);
|
|
33670
33711
|
if (r.dimensions)
|
|
33671
33712
|
for (const E of r.dimensions)
|
|
33672
33713
|
te(E, e, t, n);
|
|
@@ -33711,7 +33752,7 @@ function SA(r, e) {
|
|
|
33711
33752
|
correctedQuery: n.size > 0 ? i : void 0
|
|
33712
33753
|
};
|
|
33713
33754
|
}
|
|
33714
|
-
function
|
|
33755
|
+
function NA(r) {
|
|
33715
33756
|
return new Ct({
|
|
33716
33757
|
drizzle: r.drizzle,
|
|
33717
33758
|
schema: r.schema
|
|
@@ -33732,9 +33773,9 @@ export {
|
|
|
33732
33773
|
me as JoinPathResolver,
|
|
33733
33774
|
vn as LogicalPlanBuilder,
|
|
33734
33775
|
Mn as LogicalPlanner,
|
|
33735
|
-
|
|
33776
|
+
nA as MemoryCacheProvider,
|
|
33736
33777
|
_s as MySQLExecutor,
|
|
33737
|
-
|
|
33778
|
+
sA as OptimiserPipeline,
|
|
33738
33779
|
nn as PostgresExecutor,
|
|
33739
33780
|
Zn as QueryExecutor,
|
|
33740
33781
|
$n as RetentionQueryBuilder,
|
|
@@ -33744,34 +33785,34 @@ export {
|
|
|
33744
33785
|
nT as STEP2_SYSTEM_PROMPT,
|
|
33745
33786
|
tT as SYSTEM_PROMPT_TEMPLATE,
|
|
33746
33787
|
Ct as SemanticLayerCompiler,
|
|
33747
|
-
|
|
33788
|
+
lA as aiValidateQuery,
|
|
33748
33789
|
AT as buildAgentSystemPrompt,
|
|
33749
|
-
|
|
33750
|
-
|
|
33751
|
-
|
|
33752
|
-
|
|
33753
|
-
|
|
33790
|
+
oA as buildExplainAnalysisPrompt,
|
|
33791
|
+
iA as buildStep0Prompt,
|
|
33792
|
+
EA as buildStep1Prompt,
|
|
33793
|
+
aA as buildStep2Prompt,
|
|
33794
|
+
rA as buildSystemPrompt,
|
|
33754
33795
|
yt as createDatabaseExecutor,
|
|
33755
|
-
|
|
33796
|
+
NA as createDrizzleSemanticLayer,
|
|
33756
33797
|
un as createDuckDBExecutor,
|
|
33757
|
-
|
|
33798
|
+
zT as createMultiCubeContext,
|
|
33758
33799
|
an as createMySQLExecutor,
|
|
33759
33800
|
Mt as createPostgresExecutor,
|
|
33760
33801
|
Ut as createSQLiteExecutor,
|
|
33761
33802
|
HT as createToolExecutor,
|
|
33762
|
-
|
|
33803
|
+
eA as defineCube,
|
|
33763
33804
|
vs as discoverCubes,
|
|
33764
33805
|
mt as findBestFieldMatch,
|
|
33765
33806
|
gt as fnv1aHash,
|
|
33766
|
-
|
|
33767
|
-
|
|
33807
|
+
TA as formatCubeSchemaForExplain,
|
|
33808
|
+
AA as formatExistingIndexes,
|
|
33768
33809
|
Cn as generateCacheKey,
|
|
33769
|
-
|
|
33810
|
+
tA as getCubeInvalidationPattern,
|
|
33770
33811
|
St as getJoinType,
|
|
33771
33812
|
BT as getToolDefinitions,
|
|
33772
|
-
|
|
33813
|
+
RA as handleAgentChat,
|
|
33773
33814
|
dn as normalizeQuery,
|
|
33774
33815
|
J as resolveCubeReference,
|
|
33775
33816
|
B as resolveSqlExpression,
|
|
33776
|
-
|
|
33817
|
+
SA as suggestQuery
|
|
33777
33818
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-cube",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"description": "Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.",
|
|
5
5
|
"main": "./dist/server/index.js",
|
|
6
6
|
"types": "./dist/server/index.d.ts",
|