yamchart 0.10.2 → 0.10.3
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/{advisor-5F73GF54.js → advisor-XTJQU7E4.js} +12 -12
- package/dist/{chunk-5CRXV5PQ.js → chunk-2XJZJ6IA.js} +2 -2
- package/dist/{chunk-X3UG6T3Q.js → chunk-6ELSQNIH.js} +2 -2
- package/dist/{chunk-UOSOZT47.js → chunk-KDDO4UII.js} +57 -5
- package/dist/chunk-KDDO4UII.js.map +1 -0
- package/dist/{chunk-25ES7MGF.js → chunk-ODSPBOJW.js} +4 -4
- package/dist/{chunk-7HWFVUGP.js → chunk-OYBI433Z.js} +59 -2
- package/dist/chunk-OYBI433Z.js.map +1 -0
- package/dist/{chunk-WVSDQNAN.js → chunk-PXFTWXSV.js} +2 -2
- package/dist/{chunk-PYVROL7Z.js → chunk-XNMB25GT.js} +4 -4
- package/dist/{connection-utils-HNX3473B.js → connection-utils-S7EFPTLY.js} +5 -5
- package/dist/{describe-KDGXFPDQ.js → describe-TA2CTODC.js} +6 -6
- package/dist/{dev-KOWFGDOP.js → dev-PHFYLJPJ.js} +1336 -796
- package/dist/dev-PHFYLJPJ.js.map +1 -0
- package/dist/{dist-WMP7BFKP.js → dist-F6TVLP6C.js} +12 -4
- package/dist/{dist-YB5RBWCC.js → dist-Q5ETETUU.js} +4 -4
- package/dist/{dist-LK3ZG74Q.js → dist-YJOOH65Y.js} +9 -5
- package/dist/index.js +26 -26
- package/dist/public/assets/DataView-V-E6oxy6.js +9 -0
- package/dist/public/assets/{EventManagement-BIkVUSCe.js → EventManagement-Do2xU5lV.js} +1 -1
- package/dist/public/assets/{ExplorePage-CeaAulqT.js → ExplorePage-Dg50mvGB.js} +1 -1
- package/dist/public/assets/{LoginPage-4WeNcdRi.js → LoginPage-DmYGIXcu.js} +1 -1
- package/dist/public/assets/{PublicViewer-CkW-G56D.js → PublicViewer-CJTgc9OF.js} +1 -1
- package/dist/public/assets/{SetupWizard-CwTr3PCy.js → SetupWizard-Bo-zmh43.js} +1 -1
- package/dist/public/assets/{ShareManagement-DSon6CoC.js → ShareManagement-6Wp6b2Gp.js} +1 -1
- package/dist/public/assets/{SourceDetailView-BA4XVKqV.js → SourceDetailView-CTzSXhZc.js} +1 -1
- package/dist/public/assets/{UserManagement-BWD2Ugkv.js → UserManagement-DQhB13T0.js} +1 -1
- package/dist/public/assets/{index-iR9gLdl9.js → index-CY8xsfQH.js} +31 -31
- package/dist/public/assets/{index-Cb4omrVn.css → index-Dkn-tJCT.css} +1 -1
- package/dist/public/assets/{index.es-BuEtjxhO.js → index.es-Bc3yys5L.js} +1 -1
- package/dist/public/assets/{jspdf.es.min-CScx2_oK.js → jspdf.es.min-D94JEH-J.js} +3 -3
- package/dist/public/index.html +2 -2
- package/dist/{query-7XHKSZ5H.js → query-AX4BOPMH.js} +5 -5
- package/dist/{sample-YNSJ3I3T.js → sample-4NUBJGIL.js} +5 -5
- package/dist/{search-NKRXXLRS.js → search-IBVVYN4I.js} +6 -6
- package/dist/{semantic-NBAX4WU4.js → semantic-33YIUMUV.js} +3 -3
- package/dist/{semantic-DD7P4634.js → semantic-5WGVZ7HY.js} +3 -3
- package/dist/{source-resolver-7NY3KEZ2.js → source-resolver-GYXIRIVK.js} +6 -6
- package/dist/{sync-warehouse-PK7HXW7U.js → sync-warehouse-5NKENCOZ.js} +5 -5
- package/dist/{tables-WQTRZSXR.js → tables-QMZMYYV5.js} +6 -6
- package/dist/{test-MKNKUR3N.js → test-6MCPGXJP.js} +5 -5
- package/package.json +5 -5
- package/dist/chunk-7HWFVUGP.js.map +0 -1
- package/dist/chunk-UOSOZT47.js.map +0 -1
- package/dist/dev-KOWFGDOP.js.map +0 -1
- package/dist/public/assets/DataView-BfwnWnLH.js +0 -9
- /package/dist/{advisor-5F73GF54.js.map → advisor-XTJQU7E4.js.map} +0 -0
- /package/dist/{chunk-5CRXV5PQ.js.map → chunk-2XJZJ6IA.js.map} +0 -0
- /package/dist/{chunk-X3UG6T3Q.js.map → chunk-6ELSQNIH.js.map} +0 -0
- /package/dist/{chunk-25ES7MGF.js.map → chunk-ODSPBOJW.js.map} +0 -0
- /package/dist/{chunk-WVSDQNAN.js.map → chunk-PXFTWXSV.js.map} +0 -0
- /package/dist/{chunk-PYVROL7Z.js.map → chunk-XNMB25GT.js.map} +0 -0
- /package/dist/{connection-utils-HNX3473B.js.map → connection-utils-S7EFPTLY.js.map} +0 -0
- /package/dist/{describe-KDGXFPDQ.js.map → describe-TA2CTODC.js.map} +0 -0
- /package/dist/{dist-LK3ZG74Q.js.map → dist-F6TVLP6C.js.map} +0 -0
- /package/dist/{dist-WMP7BFKP.js.map → dist-Q5ETETUU.js.map} +0 -0
- /package/dist/{dist-YB5RBWCC.js.map → dist-YJOOH65Y.js.map} +0 -0
- /package/dist/{query-7XHKSZ5H.js.map → query-AX4BOPMH.js.map} +0 -0
- /package/dist/{sample-YNSJ3I3T.js.map → sample-4NUBJGIL.js.map} +0 -0
- /package/dist/{search-NKRXXLRS.js.map → search-IBVVYN4I.js.map} +0 -0
- /package/dist/{semantic-NBAX4WU4.js.map → semantic-33YIUMUV.js.map} +0 -0
- /package/dist/{semantic-DD7P4634.js.map → semantic-5WGVZ7HY.js.map} +0 -0
- /package/dist/{source-resolver-7NY3KEZ2.js.map → source-resolver-GYXIRIVK.js.map} +0 -0
- /package/dist/{sync-warehouse-PK7HXW7U.js.map → sync-warehouse-5NKENCOZ.js.map} +0 -0
- /package/dist/{tables-WQTRZSXR.js.map → tables-QMZMYYV5.js.map} +0 -0
- /package/dist/{test-MKNKUR3N.js.map → test-6MCPGXJP.js.map} +0 -0
|
@@ -38,9 +38,11 @@ import {
|
|
|
38
38
|
ProjectSchema,
|
|
39
39
|
ProviderConfigSchema,
|
|
40
40
|
QueryConfigSchema,
|
|
41
|
+
RESERVED_SLUGS,
|
|
41
42
|
RelationshipSchema,
|
|
42
43
|
RuntimeConfigSchema,
|
|
43
44
|
RuntimeConnectionSchema,
|
|
45
|
+
SLUG_REGEX,
|
|
44
46
|
SQLiteConfigSchema,
|
|
45
47
|
ScheduleSchema,
|
|
46
48
|
SemanticConfigSchema,
|
|
@@ -56,8 +58,10 @@ import {
|
|
|
56
58
|
TableProfileSchema,
|
|
57
59
|
VERSION,
|
|
58
60
|
deepMerge,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
deriveSlug,
|
|
62
|
+
resolveProjectConfig,
|
|
63
|
+
validateSlug
|
|
64
|
+
} from "./chunk-OYBI433Z.js";
|
|
61
65
|
import "./chunk-7D4SUZUM.js";
|
|
62
66
|
export {
|
|
63
67
|
AgentDefinitionSchema,
|
|
@@ -98,9 +102,11 @@ export {
|
|
|
98
102
|
ProjectSchema,
|
|
99
103
|
ProviderConfigSchema,
|
|
100
104
|
QueryConfigSchema,
|
|
105
|
+
RESERVED_SLUGS,
|
|
101
106
|
RelationshipSchema,
|
|
102
107
|
RuntimeConfigSchema,
|
|
103
108
|
RuntimeConnectionSchema,
|
|
109
|
+
SLUG_REGEX,
|
|
104
110
|
SQLiteConfigSchema,
|
|
105
111
|
ScheduleSchema,
|
|
106
112
|
SemanticConfigSchema,
|
|
@@ -116,6 +122,8 @@ export {
|
|
|
116
122
|
TableProfileSchema,
|
|
117
123
|
VERSION,
|
|
118
124
|
deepMerge,
|
|
119
|
-
|
|
125
|
+
deriveSlug,
|
|
126
|
+
resolveProjectConfig,
|
|
127
|
+
validateSlug
|
|
120
128
|
};
|
|
121
|
-
//# sourceMappingURL=dist-
|
|
129
|
+
//# sourceMappingURL=dist-F6TVLP6C.js.map
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
runModel,
|
|
32
32
|
serializeDateValue,
|
|
33
33
|
templateHasVariable
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-2XJZJ6IA.js";
|
|
35
35
|
import {
|
|
36
36
|
DATE_PRESETS,
|
|
37
37
|
SemanticModelBuilder,
|
|
@@ -53,8 +53,8 @@ import {
|
|
|
53
53
|
isRelativeDateRange,
|
|
54
54
|
loadSemanticDefinitions,
|
|
55
55
|
validateSemanticQuery
|
|
56
|
-
} from "./chunk-
|
|
57
|
-
import "./chunk-
|
|
56
|
+
} from "./chunk-6ELSQNIH.js";
|
|
57
|
+
import "./chunk-OYBI433Z.js";
|
|
58
58
|
import "./chunk-7D4SUZUM.js";
|
|
59
59
|
export {
|
|
60
60
|
BigQueryConnector,
|
|
@@ -109,4 +109,4 @@ export {
|
|
|
109
109
|
templateHasVariable,
|
|
110
110
|
validateSemanticQuery
|
|
111
111
|
};
|
|
112
|
-
//# sourceMappingURL=dist-
|
|
112
|
+
//# sourceMappingURL=dist-Q5ETETUU.js.map
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
OpenAICompatibleProvider,
|
|
7
7
|
SYSTEM_PROMPT,
|
|
8
8
|
TOOL_DEFINITIONS,
|
|
9
|
+
buildMartFiles,
|
|
9
10
|
buildModelPath,
|
|
10
11
|
buildProvider,
|
|
11
12
|
buildSchemaYmlEntry,
|
|
@@ -17,12 +18,13 @@ import {
|
|
|
17
18
|
listDbtModels,
|
|
18
19
|
loadKnowledge,
|
|
19
20
|
readDbtModel,
|
|
21
|
+
scaffoldModelSql,
|
|
20
22
|
updateSchemaYml,
|
|
21
23
|
writeDbtModel
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-KDDO4UII.js";
|
|
25
|
+
import "./chunk-2XJZJ6IA.js";
|
|
26
|
+
import "./chunk-6ELSQNIH.js";
|
|
27
|
+
import "./chunk-OYBI433Z.js";
|
|
26
28
|
import "./chunk-7D4SUZUM.js";
|
|
27
29
|
export {
|
|
28
30
|
AdvisorAgent,
|
|
@@ -31,6 +33,7 @@ export {
|
|
|
31
33
|
OpenAICompatibleProvider,
|
|
32
34
|
SYSTEM_PROMPT,
|
|
33
35
|
TOOL_DEFINITIONS,
|
|
36
|
+
buildMartFiles,
|
|
34
37
|
buildModelPath,
|
|
35
38
|
buildProvider,
|
|
36
39
|
buildSchemaYmlEntry,
|
|
@@ -42,7 +45,8 @@ export {
|
|
|
42
45
|
listDbtModels,
|
|
43
46
|
loadKnowledge,
|
|
44
47
|
readDbtModel,
|
|
48
|
+
scaffoldModelSql,
|
|
45
49
|
updateSchemaYml,
|
|
46
50
|
writeDbtModel
|
|
47
51
|
};
|
|
48
|
-
//# sourceMappingURL=dist-
|
|
52
|
+
//# sourceMappingURL=dist-YJOOH65Y.js.map
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
findProjectRoot,
|
|
5
5
|
loadEnvFile,
|
|
6
6
|
validateProject
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ODSPBOJW.js";
|
|
8
8
|
import {
|
|
9
9
|
checkForUpdate
|
|
10
10
|
} from "./chunk-TZKNU5TD.js";
|
|
@@ -18,9 +18,9 @@ import {
|
|
|
18
18
|
success,
|
|
19
19
|
warning
|
|
20
20
|
} from "./chunk-HJVVHYVN.js";
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-2XJZJ6IA.js";
|
|
22
|
+
import "./chunk-6ELSQNIH.js";
|
|
23
|
+
import "./chunk-OYBI433Z.js";
|
|
24
24
|
import "./chunk-7D4SUZUM.js";
|
|
25
25
|
|
|
26
26
|
// src/index.ts
|
|
@@ -111,7 +111,7 @@ program.command("dev").description("Start development server with hot reload").a
|
|
|
111
111
|
process.exit(2);
|
|
112
112
|
}
|
|
113
113
|
const globalOpts = program.opts();
|
|
114
|
-
const { runDevServer } = await import("./dev-
|
|
114
|
+
const { runDevServer } = await import("./dev-PHFYLJPJ.js");
|
|
115
115
|
await runDevServer(projectDir, {
|
|
116
116
|
port: parseInt(options.port, 10),
|
|
117
117
|
apiOnly: options.apiOnly ?? false,
|
|
@@ -185,7 +185,7 @@ program.command("sync-dbt").description("Sync dbt project metadata into AI-reada
|
|
|
185
185
|
if (!options.targetDatabase) {
|
|
186
186
|
try {
|
|
187
187
|
const { readFile } = await import("fs/promises");
|
|
188
|
-
const { resolveConnection } = await import("./connection-utils-
|
|
188
|
+
const { resolveConnection } = await import("./connection-utils-S7EFPTLY.js");
|
|
189
189
|
const { detectDatabaseMismatch } = await import("./rewrite-database-BOA4QPUR.js");
|
|
190
190
|
const catalogJsonStr = await readFile(join(projectDir, ".yamchart", "catalog.json"), "utf-8");
|
|
191
191
|
const catalogData = JSON.parse(catalogJsonStr);
|
|
@@ -239,7 +239,7 @@ program.command("test").description("Run model tests (@returns schema checks and
|
|
|
239
239
|
}
|
|
240
240
|
loadEnvFile(projectDir);
|
|
241
241
|
try {
|
|
242
|
-
const { testProject, formatTestOutput } = await import("./test-
|
|
242
|
+
const { testProject, formatTestOutput } = await import("./test-6MCPGXJP.js");
|
|
243
243
|
const result = await testProject(projectDir, model, {
|
|
244
244
|
connection: options.connection,
|
|
245
245
|
json: options.json
|
|
@@ -288,7 +288,7 @@ program.command("tables").description("List tables and views in the connected da
|
|
|
288
288
|
loadEnvFile(projectDir);
|
|
289
289
|
try {
|
|
290
290
|
if (options.compare) {
|
|
291
|
-
const { resolveTablesSource } = await import("./source-resolver-
|
|
291
|
+
const { resolveTablesSource } = await import("./source-resolver-GYXIRIVK.js");
|
|
292
292
|
const { compareTables, formatCompareTables } = await import("./compare-RQFCEZIK.js");
|
|
293
293
|
let localResult;
|
|
294
294
|
try {
|
|
@@ -319,7 +319,7 @@ program.command("tables").description("List tables and views in the connected da
|
|
|
319
319
|
}
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
|
-
const { listTables } = await import("./tables-
|
|
322
|
+
const { listTables } = await import("./tables-QMZMYYV5.js");
|
|
323
323
|
const result = await listTables(projectDir, {
|
|
324
324
|
...options,
|
|
325
325
|
source: options.source || "auto"
|
|
@@ -357,7 +357,7 @@ program.command("describe").description("Show columns and types for a table").ar
|
|
|
357
357
|
loadEnvFile(projectDir);
|
|
358
358
|
try {
|
|
359
359
|
if (options.compare) {
|
|
360
|
-
const { resolveDescribeSource } = await import("./source-resolver-
|
|
360
|
+
const { resolveDescribeSource } = await import("./source-resolver-GYXIRIVK.js");
|
|
361
361
|
const { compareColumns, formatCompareColumns } = await import("./compare-RQFCEZIK.js");
|
|
362
362
|
let localResult;
|
|
363
363
|
try {
|
|
@@ -379,7 +379,7 @@ program.command("describe").description("Show columns and types for a table").ar
|
|
|
379
379
|
}
|
|
380
380
|
return;
|
|
381
381
|
}
|
|
382
|
-
const { describeTable } = await import("./describe-
|
|
382
|
+
const { describeTable } = await import("./describe-TA2CTODC.js");
|
|
383
383
|
const result = await describeTable(projectDir, table, {
|
|
384
384
|
...options,
|
|
385
385
|
source: options.source || "auto"
|
|
@@ -418,8 +418,8 @@ program.command("query").description("Execute SQL against a connection").argumen
|
|
|
418
418
|
}
|
|
419
419
|
loadEnvFile(projectDir);
|
|
420
420
|
try {
|
|
421
|
-
const { executeQuery } = await import("./query-
|
|
422
|
-
const { formatTable, formatJSON } = await import("./connection-utils-
|
|
421
|
+
const { executeQuery } = await import("./query-AX4BOPMH.js");
|
|
422
|
+
const { formatTable, formatJSON } = await import("./connection-utils-S7EFPTLY.js");
|
|
423
423
|
const limit = options.limit ? parseInt(options.limit, 10) : void 0;
|
|
424
424
|
const result = await executeQuery(projectDir, sql, {
|
|
425
425
|
connection: options.connection,
|
|
@@ -446,8 +446,8 @@ program.command("sample").description("Show sample rows from a table or dbt mode
|
|
|
446
446
|
}
|
|
447
447
|
loadEnvFile(projectDir);
|
|
448
448
|
try {
|
|
449
|
-
const { sampleTable } = await import("./sample-
|
|
450
|
-
const { formatTable, formatJSON } = await import("./connection-utils-
|
|
449
|
+
const { sampleTable } = await import("./sample-4NUBJGIL.js");
|
|
450
|
+
const { formatTable, formatJSON } = await import("./connection-utils-S7EFPTLY.js");
|
|
451
451
|
const limit = options.limit ? parseInt(options.limit, 10) : void 0;
|
|
452
452
|
const result = await sampleTable(projectDir, table, {
|
|
453
453
|
connection: options.connection,
|
|
@@ -477,7 +477,7 @@ program.command("search").description("Search for tables and columns by keyword"
|
|
|
477
477
|
}
|
|
478
478
|
loadEnvFile(projectDir);
|
|
479
479
|
try {
|
|
480
|
-
const { searchDatabase } = await import("./search-
|
|
480
|
+
const { searchDatabase } = await import("./search-IBVVYN4I.js");
|
|
481
481
|
const result = await searchDatabase(projectDir, keyword, {
|
|
482
482
|
...options,
|
|
483
483
|
source: options.source || "auto"
|
|
@@ -531,7 +531,7 @@ catalogCmd.command("tables").description("List tables from cached catalog").opti
|
|
|
531
531
|
process.exit(2);
|
|
532
532
|
}
|
|
533
533
|
try {
|
|
534
|
-
const { listTables } = await import("./tables-
|
|
534
|
+
const { listTables } = await import("./tables-QMZMYYV5.js");
|
|
535
535
|
const result = await listTables(projectDir, {
|
|
536
536
|
source: "catalog",
|
|
537
537
|
schema: options.schema
|
|
@@ -573,7 +573,7 @@ catalogCmd.command("describe").description("Show cached columns and types for a
|
|
|
573
573
|
process.exit(2);
|
|
574
574
|
}
|
|
575
575
|
try {
|
|
576
|
-
const { describeTable } = await import("./describe-
|
|
576
|
+
const { describeTable } = await import("./describe-TA2CTODC.js");
|
|
577
577
|
const result = await describeTable(projectDir, table, { source: "catalog" });
|
|
578
578
|
if (options.json) {
|
|
579
579
|
console.log(JSON.stringify(result.columns, null, 2));
|
|
@@ -615,7 +615,7 @@ catalogCmd.command("search").description("Search cached metadata for tables and
|
|
|
615
615
|
process.exit(2);
|
|
616
616
|
}
|
|
617
617
|
try {
|
|
618
|
-
const { searchDatabase } = await import("./search-
|
|
618
|
+
const { searchDatabase } = await import("./search-IBVVYN4I.js");
|
|
619
619
|
const result = await searchDatabase(projectDir, keyword, { source: "catalog" });
|
|
620
620
|
if (options.json) {
|
|
621
621
|
console.log(JSON.stringify(result.results, null, 2));
|
|
@@ -740,7 +740,7 @@ program.command("sync-warehouse").description("Sync warehouse table metadata int
|
|
|
740
740
|
}
|
|
741
741
|
loadEnvFile(projectDir);
|
|
742
742
|
try {
|
|
743
|
-
const { runSyncWarehouse } = await import("./sync-warehouse-
|
|
743
|
+
const { runSyncWarehouse } = await import("./sync-warehouse-5NKENCOZ.js");
|
|
744
744
|
await runSyncWarehouse(projectDir, options);
|
|
745
745
|
} catch (err) {
|
|
746
746
|
error(err instanceof Error ? err.message : String(err));
|
|
@@ -791,7 +791,7 @@ program.command("advisor").description("AI-powered dbt model advisor \u2014 sugg
|
|
|
791
791
|
process.exit(2);
|
|
792
792
|
}
|
|
793
793
|
loadEnvFile(projectDir);
|
|
794
|
-
const { runAdvisor } = await import("./advisor-
|
|
794
|
+
const { runAdvisor } = await import("./advisor-XTJQU7E4.js");
|
|
795
795
|
await runAdvisor(projectDir, question, {
|
|
796
796
|
top: options.top ? parseInt(options.top, 10) : 5,
|
|
797
797
|
json: options.json,
|
|
@@ -809,8 +809,8 @@ var semanticCmd = program.command("semantic").description("Explore the semantic
|
|
|
809
809
|
}
|
|
810
810
|
loadEnvFile(projectDir);
|
|
811
811
|
try {
|
|
812
|
-
const { loadSemanticDefinitions } = await import("./semantic-
|
|
813
|
-
const { listSemanticDefinitions, listSemanticEntities } = await import("./semantic-
|
|
812
|
+
const { loadSemanticDefinitions } = await import("./semantic-5WGVZ7HY.js");
|
|
813
|
+
const { listSemanticDefinitions, listSemanticEntities } = await import("./semantic-33YIUMUV.js");
|
|
814
814
|
const defs = loadSemanticDefinitions(projectDir);
|
|
815
815
|
let result;
|
|
816
816
|
let source;
|
|
@@ -866,8 +866,8 @@ semanticCmd.command("query").description("Run a structured query against the sem
|
|
|
866
866
|
}
|
|
867
867
|
loadEnvFile(projectDir);
|
|
868
868
|
try {
|
|
869
|
-
const { loadSemanticDefinitions } = await import("./semantic-
|
|
870
|
-
const { querySemanticDefinition, querySemanticEntity } = await import("./semantic-
|
|
869
|
+
const { loadSemanticDefinitions } = await import("./semantic-5WGVZ7HY.js");
|
|
870
|
+
const { querySemanticDefinition, querySemanticEntity } = await import("./semantic-33YIUMUV.js");
|
|
871
871
|
const filters = (options.filter || []).map((f) => {
|
|
872
872
|
const eqIdx = f.indexOf("=");
|
|
873
873
|
if (eqIdx === -1) throw new Error(`Invalid filter format: "${f}". Use dimension=value`);
|
|
@@ -899,7 +899,7 @@ semanticCmd.command("query").description("Run a structured query against the sem
|
|
|
899
899
|
console.log(result.sql);
|
|
900
900
|
return;
|
|
901
901
|
}
|
|
902
|
-
const { resolveConnection, createConnector, formatTable, formatJSON } = await import("./connection-utils-
|
|
902
|
+
const { resolveConnection, createConnector, formatTable, formatJSON } = await import("./connection-utils-S7EFPTLY.js");
|
|
903
903
|
const connection = await resolveConnection(projectDir, options.connection, program.opts().env);
|
|
904
904
|
const connector = createConnector(connection, projectDir);
|
|
905
905
|
const start = performance.now();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{R as N,j as e,v as I,u as J,U as M,w as P,A as X,V,f as z,a as Z}from"./index-CY8xsfQH.js";import{a as v}from"./echarts-DtOYsfLX.js";import{l as Q}from"./data-3vtzSuAZ.js";async function G(){return N("/admin/config")}const ee=o=>N("/admin/connections/test",{method:"POST",body:JSON.stringify(o)}),oe=(o,t)=>N(t?`/admin/connections/${encodeURIComponent(o.name)}`:"/admin/connections",{method:t?"PUT":"POST",body:JSON.stringify(o)}),te=o=>N(`/admin/connections/${encodeURIComponent(o)}`,{method:"DELETE"}),se=o=>N("/admin/knowledge-db/test",{method:"POST",body:JSON.stringify({url:o})}),re=o=>N("/admin/knowledge-db",{method:"PUT",body:JSON.stringify({url:o})}),ne=o=>N("/admin/knowledge-db/migrate",{method:"POST",body:JSON.stringify({url:o})}),ae=()=>N("/admin/knowledge-db/reembed",{method:"POST",body:JSON.stringify({})}),ce=o=>N("/admin/ai",{method:"PUT",body:JSON.stringify(o)}),le=(o,t)=>N("/admin/ai/test",{method:"POST",body:JSON.stringify({provider:o,kind:t})}),ie=["postgres","mysql","bigquery","snowflake","duckdb","sqlite"],q={postgres:[{key:"config.host",label:"Host"},{key:"config.port",label:"Port",numeric:!0},{key:"config.database",label:"Database"},{key:"config.schema",label:"Schema"},{key:"secrets.user",label:"User"},{key:"secrets.password",label:"Password",secret:!0}],mysql:[{key:"config.host",label:"Host"},{key:"config.port",label:"Port",numeric:!0},{key:"config.database",label:"Database"},{key:"secrets.user",label:"User"},{key:"secrets.password",label:"Password",secret:!0}],bigquery:[{key:"config.project_id",label:"Project ID"},{key:"config.dataset",label:"Dataset"},{key:"config.location",label:"Location"},{key:"secrets.credentials_json",label:"Service Account JSON",secret:!0}],snowflake:[{key:"config.account",label:"Account"},{key:"config.warehouse",label:"Warehouse"},{key:"config.database",label:"Database"},{key:"config.schema",label:"Schema"},{key:"config.role",label:"Role"},{key:"secrets.user",label:"User"},{key:"secrets.password",label:"Password",secret:!0}],duckdb:[{key:"config.path",label:"Path"}],sqlite:[{key:"config.path",label:"Path"}]};function de(o,t,r){const[s,a]=t.split(".");!s||!a||(o[s]=o[s]??{},o[s][a]=r)}function pe(o){if(!o)return{};const t={},r=q[o.type]??[];for(const s of r){if(s.secret)continue;const[a,l]=s.key.split(".");if(!a||!l)continue;const i=o[a],c=i==null?void 0:i[l];c!=null&&(t[s.key]=String(c))}return t}function ue({mode:o,initial:t,onClose:r,onApplying:s}){const[a,l]=v.useState((t==null?void 0:t.type)??"postgres"),[i,c]=v.useState((t==null?void 0:t.name)??""),[p,g]=v.useState(()=>pe(t)),[u,k]=v.useState(null),[j,n]=v.useState(!1),[m,y]=v.useState(null);v.useEffect(()=>{const d=w=>{w.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]);const h=()=>{const d={name:i,type:a,config:{},secrets:{}};for(const w of q[a]){const S=p[w.key];S===void 0||S===""||de(d,w.key,w.numeric?Number(S):S)}return Object.keys(d.secrets).length===0&&delete d.secrets,d},x=async()=>{n(!0),y(null);try{k(await ee(h()))}catch(d){y(d instanceof Error?d.message:"Test failed")}finally{n(!1)}},f=async()=>{n(!0),y(null);try{await oe(h(),o==="edit"),s(),r()}catch(d){y(d instanceof Error?d.message:"Save failed")}finally{n(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:r,children:e.jsxs("div",{className:"bg-[var(--surface)] rounded-lg p-6 w-[480px] max-h-[85vh] overflow-auto",onClick:d=>d.stopPropagation(),style:{backgroundColor:"var(--yc-color-surface)",color:"var(--yc-color-text)"},children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:o==="add"?"Add data source":"Edit data source"}),e.jsxs("label",{className:"block text-sm mb-2",children:["Name",e.jsx("input",{"aria-label":"Name",className:"mt-1 w-full border rounded px-2 py-1",value:i,disabled:o==="edit",onChange:d=>c(d.target.value),style:{borderColor:"var(--yc-color-border)",backgroundColor:"var(--yc-color-bg)"}})]}),e.jsxs("label",{className:"block text-sm mb-2",children:["Type",e.jsx("select",{"aria-label":"Type",className:"mt-1 w-full border rounded px-2 py-1",value:a,disabled:o==="edit",onChange:d=>{l(d.target.value),k(null)},style:{borderColor:"var(--yc-color-border)",backgroundColor:"var(--yc-color-bg)"},children:ie.map(d=>e.jsx("option",{value:d,children:d},d))})]}),q[a].map(d=>e.jsxs("label",{className:"block text-sm mb-2",children:[d.label,e.jsx("input",{"aria-label":d.label,type:d.secret?"password":"text",className:"mt-1 w-full border rounded px-2 py-1",placeholder:o==="edit"&&d.secret?"Leave blank to keep current":void 0,value:p[d.key]??"",onChange:w=>g(S=>({...S,[d.key]:w.target.value})),style:{borderColor:"var(--yc-color-border)",backgroundColor:"var(--yc-color-bg)"}})]},d.key)),u&&e.jsx("p",{className:u.status==="healthy"?"text-green-600":"text-red-600",children:u.status==="healthy"?`Healthy (${u.latencyMs}ms)`:`Unhealthy: ${u.error}`}),m&&e.jsx("p",{className:"text-red-600 text-sm",children:m}),e.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[e.jsx("button",{className:"px-3 py-1",onClick:r,children:"Cancel"}),e.jsx("button",{className:"px-3 py-1 border rounded",disabled:j,onClick:x,children:"Test"}),e.jsx("button",{className:"px-3 py-1 bg-blue-600 text-white rounded",disabled:j,onClick:f,children:"Save"})]})]})})}function D({label:o,value:t}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx("span",{style:{fontSize:"18px",fontWeight:600,color:"var(--yc-color-text)"},children:t}),e.jsx("span",{style:{fontSize:"12px",color:"var(--yc-color-text-secondary)"},children:o})]})}const E={fontSize:"13px",fontWeight:500,background:"none",border:"none",padding:0,cursor:"pointer"};function ye({source:o,onOpen:t,admin:r,onEdit:s,onDelete:a}){const l=(r==null?void 0:r.source)==="runtime",i=(r==null?void 0:r.source)==="git";return e.jsxs("div",{onClick:()=>t(o.name),style:{border:"1px solid var(--yc-color-border)",borderRadius:"8px",padding:"16px",background:"var(--yc-color-surface)",cursor:"pointer",display:"flex",flexDirection:"column",gap:"12px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:"var(--yc-color-text)"},children:o.name}),e.jsx("span",{style:{fontSize:"11px",fontWeight:500,padding:"2px 8px",borderRadius:"9999px",background:"var(--yc-color-bg)",color:"var(--yc-color-text-secondary)",border:"1px solid var(--yc-color-border)",letterSpacing:"0.04em"},children:o.type.toUpperCase()})]}),e.jsxs("div",{style:{display:"flex",gap:"24px"},children:[e.jsx(D,{label:"Tables",value:o.counts.tables}),e.jsx(D,{label:"Hunches",value:o.counts.pendingHunches}),e.jsx(D,{label:"Blindspots",value:o.counts.openBlindspots})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px"},children:[e.jsx("button",{onClick:c=>{c.stopPropagation(),t(o.name)},style:{...E,color:"var(--yc-color-primary)"},children:"Open →"}),l&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:c=>{c.stopPropagation(),s==null||s(r)},style:{...E,color:"var(--yc-color-text-secondary)"},children:"Edit"}),e.jsx("button",{onClick:c=>{c.stopPropagation(),a==null||a(r)},style:{...E,color:"var(--yc-color-danger)"},children:"Delete"})]}),i&&e.jsx("span",{title:"Defined in your project's connections/ directory — edit it in Git.",style:{fontSize:"11px",color:"var(--yc-color-text-secondary)",border:"1px solid var(--yc-color-border)",borderRadius:"9999px",padding:"2px 8px"},children:"managed in Git"})]})]})}function xe(o){if(o&&typeof o=="object"&&"data"in o){const t=o.data;if(Array.isArray(t==null?void 0:t.references))return t.references}return[]}function me(o){return{name:o.name,type:o.type,config:o.config??{},secrets:o.secrets}}function he(){const o=I(),t=J(h=>h.auth),r=M(h=>h.setApplying),s=t.status==="disabled"||t.status==="authenticated"&&t.user.role==="admin",[a,l]=v.useState(null),[i,c]=v.useState(null),{data:p,isLoading:g,error:u}=P({queryKey:["sources"],queryFn:Q}),{data:k}=P({queryKey:["admin","config"],queryFn:G,enabled:s}),j={};for(const h of(k==null?void 0:k.connections)??[])j[h.name]=h;const n=h=>{window.location.hash=`/data/sources/${encodeURIComponent(h)}`},m=()=>{r(!0),o.invalidateQueries({queryKey:["sources"]}),o.invalidateQueries({queryKey:["admin","config"]})},y=async h=>{if(c(null),!!window.confirm(`Delete data source "${h.name}"? This applies on restart.`))try{await te(h.name),m()}catch(x){if(x instanceof X&&x.status===409){const f=xe(x);c(f.length?`In use by ${f.map(d=>`${d.kind} "${d.name}"`).join(", ")} — remove or update these first.`:x.message||`"${h.name}" is in use by charts or models — remove or update those first.`)}else c(x instanceof Error?x.message:"Delete failed")}};return e.jsxs("div",{className:"p-6 w-full",children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-1",style:{color:"var(--yc-color-text)"},children:"Data Sources"}),e.jsx("p",{className:"text-sm mb-4",style:{color:"var(--yc-color-text-secondary)"},children:"Your connected data sources. Open one to browse its tables and add business context."})]}),s&&e.jsx("button",{onClick:()=>l({mode:"add"}),className:"text-sm font-medium rounded px-3 py-1.5",style:{backgroundColor:"var(--yc-color-primary)",color:"#fff"},children:"Add data source"})]}),i&&e.jsx("p",{className:"text-sm mb-3",style:{color:"var(--yc-color-danger)"},children:i}),u&&e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-danger)"},children:"Failed to load sources."}),g?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Loading…"}):!p||p.length===0?e.jsxs("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:["No connections configured. Add one in your project's ",e.jsx("code",{children:"connections/"})," directory."]}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"16px"},children:p.map(h=>e.jsx(ye,{source:h,onOpen:n,admin:s?j[h.name]:void 0,onEdit:x=>l({mode:"edit",initial:me(x)}),onDelete:y},h.name))}),a&&e.jsx(ue,{mode:a.mode,initial:a.mode==="edit"?a.initial:void 0,onClose:()=>l(null),onApplying:m})]})}function Y(o){const t=o.match(/event:\s*(\w+)\s*\ndata:\s*(\{[\s\S]*\})/);if(!t)return null;try{return{event:t[1],data:JSON.parse(t[2])}}catch{return null}}async function R(o,t="pending"){const r=new URLSearchParams({status:t,...o?{connection:o}:{}}),s=await fetch(`/api/hunches?${r}`);if(!s.ok)throw new Error("Failed to load hunches");return s.json()}async function ge(o,t){return(await fetch(`/api/hunches/${o}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{sql:t}:{})})).json()}async function fe(o){return(await fetch(`/api/hunches/${o}/reject`,{method:"POST"})).json()}async function be(o){return(await fetch(`/api/hunches/${o}/run`,{method:"POST"})).json()}async function ve(o,t){const s=(await fetch("/api/learn",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connection:o})})).body.getReader(),a=new TextDecoder;let l="";for(;;){const{done:i,value:c}=await s.read();if(i)break;l+=a.decode(c,{stream:!0});const p=l.split(`
|
|
2
|
+
|
|
3
|
+
`);l=p.pop()??"";for(const g of p){const u=Y(g+`
|
|
4
|
+
|
|
5
|
+
`);u&&t(u)}}}async function A(o="open",t){const r=new URLSearchParams({status:o});return t&&r.set("connection",t),(await fetch(`/api/blindspots?${r}`)).json()}async function je(o,t){return(await fetch(`/api/blindspots/${o}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({answer:t})})).json()}async function ke(o){return(await fetch(`/api/blindspots/${o}/dismiss`,{method:"POST"})).json()}async function Se(o){const t=await fetch(`/api/blindspots/${o}/accept`,{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r.error??"Could not scaffold the model.")}return t.json()}async function we(o,t){const s=(await fetch("/api/blindspots/scan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connection:o})})).body.getReader(),a=new TextDecoder;let l="";for(;;){const{done:i,value:c}=await s.read();if(i)break;l+=a.decode(c,{stream:!0});const p=l.split(`
|
|
6
|
+
|
|
7
|
+
`);l=p.pop()??"";for(const g of p){const u=Y(g+`
|
|
8
|
+
|
|
9
|
+
`);u&&t(u)}}}const B=V(o=>({learning:!1,hunches:[],setLearning:t=>o({learning:t}),setPhase:t=>o({phase:t}),setHunches:t=>o({hunches:t}),removeHunch:t=>o(r=>({hunches:r.hunches.filter(s=>s.id!==t)}))}));function K({hunch:o,onConfirm:t,onReject:r,onRun:s,running:a,runError:l}){const[i,c]=v.useState(o.sql);return e.jsxs("div",{className:"rounded-lg p-4 mb-3",style:{border:"1px solid var(--yc-color-border)",backgroundColor:"var(--yc-color-surface)"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h3",{className:"font-medium",style:{color:"var(--yc-color-text)"},children:o.question}),o.confidence!=null&&e.jsxs("span",{className:"text-xs whitespace-nowrap",style:{color:"var(--yc-color-text-muted)"},children:[Math.round(o.confidence*100),"%"]})]}),o.rationale&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--yc-color-text-secondary)"},children:o.rationale}),e.jsx("textarea",{className:"w-full font-mono text-sm mt-2 p-2 rounded",style:{backgroundColor:"var(--yc-color-input-bg)",border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text)"},rows:3,value:i,onChange:p=>c(p.target.value),spellCheck:!1}),l&&e.jsx("p",{className:"text-xs mt-2",style:{color:"var(--yc-color-danger)"},children:l}),o.lastRunSample&&e.jsx("div",{className:"text-xs mt-2 overflow-auto max-h-40 rounded p-2",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text-secondary)"},children:e.jsx("pre",{className:"font-mono",children:JSON.stringify(o.lastRunSample.rows.slice(0,5),null,2)})}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx("button",{onClick:()=>t(o.id,i),className:"px-3 py-1 rounded text-white text-sm hover:opacity-90",style:{backgroundColor:"var(--yc-color-primary)"},children:"Confirm"}),e.jsx("button",{onClick:()=>s(o.id,i),disabled:a,className:"px-3 py-1 rounded text-sm hover:opacity-80 disabled:opacity-50",style:{border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text)"},children:a?"Running…":"Run"}),e.jsx("button",{onClick:()=>r(o.id),className:"px-3 py-1 rounded text-sm hover:opacity-80",style:{border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:"Reject"})]})]})}function Ce({connection:o}={}){var F,H,W;const{data:t}=z(),r=((F=t==null?void 0:t.defaults)==null?void 0:F.connection)??((W=(H=t==null?void 0:t.connections)==null?void 0:H[0])==null?void 0:W.name)??"",s=o??r,[a,l]=v.useState("pending"),i=B(b=>b.hunches),c=B(b=>b.setHunches),p=B(b=>b.removeHunch),[g,u]=v.useState(null),[k,j]=v.useState({}),{data:n,isLoading:m,error:y}=P({queryKey:["hunches",s,"pending"],queryFn:()=>R(s||void 0,"pending"),enabled:!!s&&a==="pending"}),{data:h,isLoading:x,error:f}=P({queryKey:["hunches",s,"confirmed"],queryFn:()=>R(s||void 0,"confirmed"),enabled:!!s&&a==="approved"});v.useEffect(()=>{n&&c(n)},[n,c]);const d=async(b,C)=>{p(b);try{await ge(b,C)}catch{c(await R(s||void 0,"pending"))}},w=async b=>{p(b);try{await fe(b)}catch{c(await R(s||void 0,"pending"))}},S=async b=>{u(b),j(C=>{const T={...C};return delete T[b],T});try{const C=await be(b);C.error?j(T=>({...T,[b]:C.error})):C.sample&&c(B.getState().hunches.map(T=>T.id===b?{...T,lastRunSample:C.sample}:T))}finally{u(null)}},L=(b,C)=>e.jsx("button",{onClick:()=>l(b),style:{color:a===b?"var(--yc-color-primary)":"var(--yc-color-text-secondary)",borderBottom:a===b?"2px solid var(--yc-color-primary)":"2px solid transparent",paddingBottom:"6px",marginRight:"16px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:a===b?600:400},children:C});return e.jsxs("div",{className:"p-6 max-w-3xl mx-auto w-full",children:[e.jsx("h2",{className:"text-lg font-semibold mb-1",style:{color:"var(--yc-color-text)"},children:"Hunches"}),e.jsx("p",{className:"text-sm mb-4",style:{color:"var(--yc-color-text-secondary)"},children:"Confirm, edit, run, or reject the questions learned from your source."}),e.jsxs("div",{style:{display:"flex",borderBottom:"1px solid var(--yc-color-border)",marginBottom:"16px"},children:[L("pending","Pending"),L("approved","Approved")]}),a==="pending"&&e.jsxs(e.Fragment,{children:[!s&&e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No connection configured."}),y&&e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-danger)"},children:"Failed to load hunches."}),m?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Loading…"}):i.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No pending hunches. Learn this source to generate some."}):i.map(b=>e.jsx(K,{hunch:b,onConfirm:d,onReject:w,onRun:S,running:g===b.id,runError:k[b.id]},b.id))]}),a==="approved"&&e.jsxs(e.Fragment,{children:[f&&e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-danger)"},children:"Failed to load approved hunches."}),x?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Loading…"}):!h||h.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No approved hunches yet. Confirm some from the Pending tab."}):h.map(b=>e.jsx(K,{hunch:b,onConfirm:d,onReject:w,onRun:S,running:g===b.id},b.id))]})]})}const O=V(o=>({scanning:!1,blindspots:[],setScanning:t=>o({scanning:t}),setPhase:t=>o({phase:t}),setBlindspots:t=>o({blindspots:t}),removeBlindspot:t=>o(r=>({blindspots:r.blindspots.filter(s=>s.id!==t)}))}));function Ne({blindspot:o,onAnswer:t,onDismiss:r,onAccept:s}){const[a,l]=v.useState(""),i=o.kind==="opportunity";return e.jsxs("div",{className:"rounded-lg p-4 mb-3",style:{border:"1px solid var(--yc-color-border)",backgroundColor:"var(--yc-color-surface)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:i?"opportunity":"context"}),e.jsx("h3",{className:"font-medium",style:{color:"var(--yc-color-text)"},children:o.title})]}),e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--yc-color-text-secondary)"},children:o.detail}),i&&o.suggestedModel&&e.jsxs("div",{className:"text-xs mt-2 p-2 rounded",style:{backgroundColor:"var(--yc-color-input-bg)"},children:[e.jsx("div",{className:"font-mono",style:{color:"var(--yc-color-text)"},children:o.suggestedModel.name}),e.jsx("div",{style:{color:"var(--yc-color-text-secondary)"},children:o.suggestedModel.description}),o.suggestedModel.columns.length>0&&e.jsxs("div",{className:"mt-1",style:{color:"var(--yc-color-text-secondary)"},children:["cols: ",o.suggestedModel.columns.map(c=>c.name).join(", ")]})]}),!i&&e.jsx("textarea",{className:"w-full text-sm mt-2 p-2 rounded",style:{backgroundColor:"var(--yc-color-input-bg)",border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text)"},rows:2,placeholder:"Explain this in business terms…",value:a,onChange:c=>l(c.target.value)}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[i?e.jsx("button",{onClick:()=>s(o.id),className:"px-3 py-1 rounded text-white text-sm hover:opacity-90",style:{backgroundColor:"var(--yc-color-primary)"},children:"Accept"}):e.jsx("button",{onClick:()=>t(o.id,a),className:"px-3 py-1 rounded text-white text-sm hover:opacity-90",style:{backgroundColor:"var(--yc-color-primary)"},children:"Save"}),e.jsx("button",{onClick:()=>r(o.id),className:"px-3 py-1 rounded text-sm hover:opacity-80",style:{border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:"Dismiss"})]})]})}function Te({connection:o}={}){var y,h,x;const{data:t}=z(),r=((y=t==null?void 0:t.defaults)==null?void 0:y.connection)??((x=(h=t==null?void 0:t.connections)==null?void 0:h[0])==null?void 0:x.name)??"",s=o??r,a=O(f=>f.blindspots),l=O(f=>f.setBlindspots),i=O(f=>f.removeBlindspot),c=Z(f=>f.addToast),p=v.useRef(new Set),{data:g,isLoading:u,error:k}=P({queryKey:["blindspots",s,"open"],queryFn:()=>A("open",s||void 0),enabled:!!s});v.useEffect(()=>{g&&l(g)},[g,l]);const j=async(f,d)=>{if(d.trim()){i(f);try{await je(f,d)}catch{l(await A("open",s||void 0))}}},n=async f=>{i(f);try{await ke(f)}catch{l(await A("open",s||void 0))}},m=async f=>{if(!p.current.has(f)){p.current.add(f),i(f);try{const d=await Se(f);c(`Scaffolded dbt model: ${d.modelPath}`,"success")}catch(d){l(await A("open",s||void 0)),c(d instanceof Error?d.message:"Could not scaffold the model.","error")}finally{p.current.delete(f)}}};return e.jsxs("div",{className:"p-6 max-w-3xl mx-auto w-full",children:[e.jsx("h2",{className:"text-lg font-semibold mb-1",style:{color:"var(--yc-color-text)"},children:"Blindspots"}),e.jsx("p",{className:"text-sm mb-4",style:{color:"var(--yc-color-text-secondary)"},children:"Where the system lacks business context, plus useful marts it thinks are missing."}),k&&e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-danger)"},children:"Failed to load blindspots."}),u?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Loading…"}):a.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:'No open blindspots. Use "Scan Data Source" to find some.'}):a.map(f=>e.jsx(Ne,{blindspot:f,onAnswer:j,onDismiss:n,onAccept:m},f.id))]})}function Be({connection:o}={}){var i,c,p;const{data:t}=z(),r=((i=t==null?void 0:t.defaults)==null?void 0:i.connection)??((p=(c=t==null?void 0:t.connections)==null?void 0:c[0])==null?void 0:p.name)??"",s=o??r,{data:a,isLoading:l}=P({queryKey:["coverage",s],queryFn:async()=>{const g=s?`?connection=${encodeURIComponent(s)}`:"";return(await fetch(`/api/coverage${g}`)).json()},enabled:!!s});return e.jsxs("div",{className:"p-6 max-w-3xl mx-auto w-full",children:[e.jsx("h2",{className:"text-lg font-semibold mb-1",style:{color:"var(--yc-color-text)"},children:"Coverage"}),e.jsx("p",{className:"text-sm mb-4",style:{color:"var(--yc-color-text-secondary)"},children:"How many hunches and blindspots each warehouse table has."}),l?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Loading…"}):!a||a.length===0?e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"No profile data yet. Run a scan to see coverage."}):e.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--yc-color-border)"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{backgroundColor:"var(--yc-color-surface)"},children:[e.jsx("th",{style:{padding:"10px 16px",textAlign:"left",fontSize:"12px",fontWeight:600,color:"var(--yc-color-text-secondary)",borderBottom:"1px solid var(--yc-color-border)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Table"}),e.jsx("th",{style:{padding:"10px 16px",textAlign:"center",fontSize:"12px",fontWeight:600,color:"var(--yc-color-text-secondary)",borderBottom:"1px solid var(--yc-color-border)",textTransform:"uppercase",letterSpacing:"0.05em",width:"120px"},children:"Hunches"}),e.jsx("th",{style:{padding:"10px 16px",textAlign:"center",fontSize:"12px",fontWeight:600,color:"var(--yc-color-text-secondary)",borderBottom:"1px solid var(--yc-color-border)",textTransform:"uppercase",letterSpacing:"0.05em",width:"120px"},children:"Blindspots"})]})}),e.jsx("tbody",{children:a.map((g,u)=>e.jsxs("tr",{style:{borderBottom:u<a.length-1?"1px solid var(--yc-color-border)":"none"},children:[e.jsx("td",{style:{padding:"10px 16px",fontFamily:"monospace",fontSize:"13px",color:"var(--yc-color-text)"},children:g.name}),e.jsx("td",{style:{padding:"10px 16px",textAlign:"center"},children:e.jsx(U,{count:g.hunches,color:"green"})}),e.jsx("td",{style:{padding:"10px 16px",textAlign:"center"},children:e.jsx(U,{count:g.blindspots,color:"amber"})})]},g.name))})]})})]})}function U({count:o,color:t}){if(o===0)return e.jsx("span",{style:{display:"inline-block",minWidth:"28px",padding:"2px 8px",borderRadius:"9999px",fontSize:"12px",fontWeight:500,textAlign:"center",backgroundColor:"var(--yc-color-surface)",color:"var(--yc-color-text-secondary)",border:"1px solid var(--yc-color-border)"},children:"0"});const r=t==="green"?{backgroundColor:"rgba(34, 197, 94, 0.15)",color:"#15803d",border:"1px solid rgba(34, 197, 94, 0.3)"}:{backgroundColor:"rgba(245, 158, 11, 0.15)",color:"#b45309",border:"1px solid rgba(245, 158, 11, 0.3)"};return e.jsx("span",{style:{display:"inline-block",minWidth:"28px",padding:"2px 8px",borderRadius:"9999px",fontSize:"12px",fontWeight:600,textAlign:"center",...r},children:o})}function Pe(o){return o==="profiling"?"Profiling source…":o==="generating"?"Generating hunches…":o==="blindspots"?"Scanning for blindspots…":o==="error"?"Something went wrong.":"Scanning…"}function _({connection:o,onComplete:t}){const[r,s]=v.useState(!1),[a,l]=v.useState(void 0),i=async()=>{if(!o)return;s(!0),l("profiling");let c=[],p=!1;try{if(await ve(o,u=>{u.event==="status"?u.data.phase==="generating"&&l("generating"):u.event==="done"?c=u.data.hunches??[]:u.event==="error"&&(p=!0,l("error"))}),p)return;l("blindspots");let g=[];await we(o,u=>{u.event==="done"?g=u.data.blindspots??[]:u.event==="error"&&(p=!0,l("error"))}),p||t(c,g)}catch{l("error")}finally{s(!1)}};return e.jsxs("div",{className:"rounded-lg p-5 mb-4 flex items-center justify-between gap-4",style:{border:"1px solid var(--yc-color-border)",backgroundColor:"var(--yc-color-surface)"},children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium",style:{color:"var(--yc-color-text)"},children:"Scan Data Source"}),e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--yc-color-text-secondary)"},children:o?e.jsxs(e.Fragment,{children:["Profile ",e.jsx("span",{className:"font-mono",children:o}),", generate hunches, and scan for blindspots."]}):"No connection configured."}),r&&e.jsx("p",{className:"text-sm mt-2",style:{color:"var(--yc-color-primary)"},children:Pe(a)}),a==="error"&&!r&&e.jsx("p",{className:"text-sm mt-2",style:{color:"var(--yc-color-danger)"},children:"Something went wrong. Please try again."})]}),e.jsx("button",{onClick:i,disabled:r||!o,className:"px-4 py-2 rounded text-white text-sm whitespace-nowrap hover:opacity-90 disabled:opacity-50",style:{backgroundColor:"var(--yc-color-primary)"},children:r?"Scanning…":"Scan Data Source"})]})}function Re({onApplying:o}){const[t,r]=v.useState(""),[s,a]=v.useState(!1),[l,i]=v.useState(null),c=async j=>{a(!0),i(null);try{await j()}catch(n){i({kind:"err",text:n instanceof Error?n.message:"Failed"})}finally{a(!1)}},p=()=>c(async()=>{const j=await se(t);i(j.ok?{kind:"ok",text:"Connection OK — schema ready."}:{kind:"err",text:j.error??"Connection failed"})}),g=()=>c(async()=>{const n=(await ne(t)).migrated;i({kind:"ok",text:`Copied ${n.hunches} hunches, ${n.blindspots} blindspots, ${n.knowledgeDocs} docs, ${n.embeddings} embeddings.`})}),u=()=>c(async()=>{const j=await ae();i({kind:"ok",text:`Rebuilt ${j.embedded} embeddings.`})}),k=()=>c(async()=>{await re(t),o()});return e.jsxs("div",{style:{padding:"24px",maxWidth:640},children:[e.jsx("h3",{style:{fontSize:16,fontWeight:600,marginBottom:8},children:"Knowledge database"}),e.jsx("p",{style:{fontSize:13,color:"var(--yc-color-text-secondary)",marginBottom:16},children:"Postgres connection for learned Hunches, Blindspots, knowledge docs, and embeddings. Changing it restarts the server."}),e.jsx("label",{htmlFor:"kdb-url",style:{display:"block",fontSize:13,marginBottom:4},children:"Database URL"}),e.jsx("input",{id:"kdb-url","aria-label":"Database URL",type:"password",value:t,onChange:j=>r(j.target.value),placeholder:"postgres://user:pass@host:5432/db",style:{width:"100%",padding:"6px 8px",borderRadius:6,border:"1px solid var(--yc-color-border)",backgroundColor:"var(--yc-color-surface)",color:"var(--yc-color-text)"}}),l&&e.jsx("p",{style:{marginTop:12,fontSize:13,color:l.kind==="ok"?"var(--yc-color-success, #16a34a)":"var(--yc-color-danger, #dc2626)"},children:l.text}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:16,flexWrap:"wrap"},children:[e.jsx("button",{disabled:s||!t.trim(),onClick:p,children:"Test"}),e.jsx("button",{disabled:s||!t.trim(),onClick:g,children:"Copy existing knowledge →"}),e.jsx("button",{disabled:s,onClick:u,children:"Rebuild embeddings now"}),e.jsx("button",{disabled:s||!t.trim(),onClick:k,style:{marginLeft:"auto",background:"var(--yc-color-primary)",color:"#fff",padding:"6px 14px",borderRadius:6},children:"Save & restart"})]})]})}const Ae=["anthropic","openai","gemini","ollama","ollama_cloud","openai_compatible"],Oe=["hunch_generation","blindspot_scan","answer","advisor"];function De({onApplying:o}){const[t,r]=v.useState(null),[s,a]=v.useState(!1),[l,i]=v.useState(null);if(v.useEffect(()=>{G().then(n=>r(n.ai??{providers:{}}))},[]),!t)return e.jsx("div",{style:{padding:24},children:"Loading…"});const c=t.providers??{},p=n=>r({...n}),g=(n,m)=>{const y=c[n]??{provider:"anthropic"};p({...t,providers:{...c,[n]:{...y,...m}}})},u=async n=>{a(!0),i(null);try{await n()}catch(m){i({kind:"err",text:m instanceof Error?m.message:"Failed"})}finally{a(!1)}},k=n=>u(async()=>{const m=c[n],y=m.api_key&&m.api_key.startsWith("••••")?{...m,api_key:void 0}:m,h=await le(y,"llm");i(h.ok?{kind:"ok",text:`${n}: OK`}:{kind:"err",text:`${n}: ${h.error??"failed"}`})}),j=()=>u(async()=>{var m,y,h;const n=JSON.parse(JSON.stringify(t));for(const x of Object.values(n.providers??{}))(m=x.api_key)!=null&&m.startsWith("••••")&&delete x.api_key;(h=(y=n.embedding)==null?void 0:y.api_key)!=null&&h.startsWith("••••")&&delete n.embedding.api_key,n.tasks&&(n.tasks=Object.fromEntries(Object.entries(n.tasks).filter(([,x])=>x))),await ce(n),o()});return e.jsxs("div",{style:{padding:24,maxWidth:720},children:[e.jsx("h3",{style:{fontSize:16,fontWeight:600,marginBottom:8},children:"AI providers"}),e.jsx("p",{style:{fontSize:13,color:"var(--yc-color-text-secondary)",marginBottom:16},children:"Configure the LLM providers, per-task routing, and the embedding model. API keys are encrypted at rest; saving restarts the server."}),e.jsxs("label",{style:{display:"block",fontSize:13,marginBottom:12},children:["Default provider",e.jsx("input",{"aria-label":"Default provider",value:t.default??"",onChange:n=>p({...t,default:n.target.value}),style:{display:"block",marginTop:4,padding:"6px 8px",borderRadius:6,border:"1px solid var(--yc-color-border)",background:"var(--yc-color-surface)",color:"var(--yc-color-text)"}})]}),Object.entries(c).map(([n,m])=>e.jsxs("div",{style:{border:"1px solid var(--yc-color-border)",borderRadius:8,padding:12,marginBottom:12},children:[e.jsx("strong",{style:{fontSize:14},children:n}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,marginTop:8},children:[e.jsxs("label",{style:{fontSize:12},children:["Type",e.jsx("select",{"aria-label":`${n} type`,value:m.provider,onChange:y=>g(n,{provider:y.target.value}),style:{display:"block",width:"100%",marginTop:2},children:Ae.map(y=>e.jsx("option",{value:y,children:y},y))})]}),e.jsxs("label",{style:{fontSize:12},children:["Model",e.jsx("input",{"aria-label":`${n} model`,value:m.model??"",onChange:y=>g(n,{model:y.target.value}),style:{display:"block",width:"100%",marginTop:2}})]}),e.jsxs("label",{style:{fontSize:12},children:["Base URL",e.jsx("input",{"aria-label":`${n} base_url`,value:m.base_url??"",onChange:y=>g(n,{base_url:y.target.value}),style:{display:"block",width:"100%",marginTop:2}})]}),e.jsxs("label",{style:{fontSize:12},children:["API key",e.jsx("input",{"aria-label":`${n} api_key`,type:"password",placeholder:"leave blank to keep current",value:m.api_key??"",onChange:y=>g(n,{api_key:y.target.value}),style:{display:"block",width:"100%",marginTop:2}})]})]}),e.jsx("button",{disabled:s,onClick:()=>k(n),style:{marginTop:8},children:"Test"})]},n)),e.jsx("h4",{style:{fontSize:14,fontWeight:600,margin:"16px 0 8px"},children:"Task routing"}),Oe.map(n=>{var m;return e.jsxs("label",{style:{display:"block",fontSize:13,marginBottom:6},children:[n,e.jsxs("select",{"aria-label":`route ${n}`,value:((m=t.tasks)==null?void 0:m[n])??"",onChange:y=>p({...t,tasks:{...t.tasks,[n]:y.target.value}}),style:{marginLeft:8},children:[e.jsx("option",{value:"",children:"(default)"}),Object.keys(c).map(y=>e.jsx("option",{value:y,children:y},y))]})]},n)}),l&&e.jsx("p",{style:{marginTop:12,fontSize:13,color:l.kind==="ok"?"var(--yc-color-success, #16a34a)":"var(--yc-color-danger, #dc2626)"},children:l.text}),e.jsx("div",{style:{marginTop:16},children:e.jsx("button",{disabled:s,onClick:j,style:{background:"var(--yc-color-primary)",color:"#fff",padding:"6px 14px",borderRadius:6},children:"Save & restart"})})]})}const Ee=[{id:"sources",label:"Data Sources"},{id:"hunches",label:"Hunches"},{id:"blindspots",label:"Blindspots"},{id:"coverage",label:"Coverage"}];function $({value:o,onChange:t}){const{data:r}=P({queryKey:["sources"],queryFn:Q});return e.jsxs("div",{style:{padding:"12px 24px 0",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("label",{htmlFor:"source-selector",style:{fontSize:"13px",color:"var(--yc-color-text-secondary)",whiteSpace:"nowrap"},children:"Source:"}),e.jsxs("select",{id:"source-selector",value:o,onChange:s=>t(s.target.value),style:{fontSize:"13px",padding:"4px 8px",borderRadius:"6px",border:"1px solid var(--yc-color-border)",backgroundColor:"var(--yc-color-surface)",color:"var(--yc-color-text)",cursor:"pointer"},children:[e.jsx("option",{value:"",children:"All sources"}),r==null?void 0:r.map(s=>e.jsx("option",{value:s.name,children:s.name},s.name))]})]})}function Le({tab:o,onTabChange:t}){const[r,s]=v.useState(""),[a,l]=v.useState(""),[i,c]=v.useState(""),p=J(x=>x.auth),g=p.status==="disabled"||p.status==="authenticated"&&p.user.role==="admin",u=M(x=>x.setApplying),k=I(),j=B(x=>x.setHunches),n=O(x=>x.setBlindspots),m=o==="blindspots"?a:r,y=(x,f)=>{const d=new Set(B.getState().hunches.map(S=>S.id)),w=x.filter(S=>!d.has(S.id));j([...w,...B.getState().hunches]),n(f),k.invalidateQueries({queryKey:["hunches"]}),k.invalidateQueries({queryKey:["blindspots"]})},h=(x,f)=>e.jsx("button",{onClick:()=>t(x),style:{color:o===x?"var(--yc-color-primary)":"var(--yc-color-text-secondary)",borderBottom:o===x?"2px solid var(--yc-color-primary)":"2px solid transparent",paddingBottom:"6px",marginRight:"16px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:o===x?600:400},children:f},x);return e.jsxs("div",{className:"flex flex-col h-full w-full",children:[e.jsxs("div",{style:{display:"flex",borderBottom:"1px solid var(--yc-color-border)",padding:"16px 24px 0"},children:[Ee.map(x=>h(x.id,x.label)),g&&h("settings","Settings")]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o==="sources"&&e.jsx(he,{}),o==="hunches"&&e.jsxs(e.Fragment,{children:[e.jsx($,{value:r,onChange:s}),m&&e.jsx("div",{className:"px-6 pt-4",children:e.jsx(_,{connection:m,onComplete:y})}),e.jsx(Ce,{connection:r||void 0})]}),o==="blindspots"&&e.jsxs(e.Fragment,{children:[e.jsx($,{value:a,onChange:l}),m&&e.jsx("div",{className:"px-6 pt-4",children:e.jsx(_,{connection:m,onComplete:y})}),e.jsx(Te,{connection:a||void 0})]}),o==="coverage"&&e.jsxs(e.Fragment,{children:[e.jsx($,{value:i,onChange:c}),e.jsx(Be,{connection:i||void 0})]}),o==="settings"&&g&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{onApplying:()=>u(!0)}),e.jsx(De,{onApplying:()=>u(!0)})]})]})]})}export{Le as DataView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{v as xe,u as he,w as me,f as be,x as J,j as t,y as E,E as ce,M as fe,z as ve,I as je,J as Ce,b as S}from"./index-
|
|
1
|
+
import{v as xe,u as he,w as me,f as be,x as J,j as t,y as E,E as ce,M as fe,z as ve,I as je,J as Ce,b as S}from"./index-CY8xsfQH.js";import{a as s}from"./echarts-DtOYsfLX.js";const ge=`
|
|
2
2
|
.rdp-root {
|
|
3
3
|
--rdp-accent-color: var(--yc-color-primary, #2563eb);
|
|
4
4
|
--rdp-accent-background-color: color-mix(in srgb, var(--yc-color-primary, #2563eb) 15%, transparent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,k,K as E,N as B,w as M,O as W,Q as $,b as D}from"./index-iR9gLdl9.js";import{a}from"./echarts-DtOYsfLX.js";const T=["What data do I have?","Show me recent trends","What are the top items by revenue?","Compare this month to last month"];function P({summary:t,onPromptClick:i}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-6 py-12 gap-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",style:{color:"var(--yc-color-text)"},children:"Data Explorer"}),e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Ask questions about your data in plain English"})]}),t&&(t.tableCount>0||t.modelCount>0)&&e.jsxs("div",{className:"rounded-xl px-5 py-4 w-full max-w-md flex flex-col gap-3",style:{background:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Connected data"}),e.jsxs("div",{className:"flex gap-6",children:[t.tableCount>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xl font-bold",style:{color:"var(--yc-color-text)"},children:t.tableCount}),e.jsx("span",{className:"text-xs ml-1",style:{color:"var(--yc-color-text-secondary)"},children:t.tableCount===1?"table":"tables"})]}),t.modelCount>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xl font-bold",style:{color:"var(--yc-color-text)"},children:t.modelCount}),e.jsx("span",{className:"text-xs ml-1",style:{color:"var(--yc-color-text-secondary)"},children:t.modelCount===1?"model":"models"})]})]}),t.connections.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.connections.map(l=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"var(--yc-color-bg)",color:"var(--yc-color-text-secondary)",border:"1px solid var(--yc-color-border)"},children:l.name},l.name))})]}),e.jsx("div",{className:"flex flex-wrap gap-2 justify-center max-w-lg",children:T.map(l=>e.jsx("button",{onClick:()=>i(l),className:"text-sm px-3 py-1.5 rounded-full transition-opacity hover:opacity-80",style:{background:"var(--yc-color-surface)",color:"var(--yc-color-text)",border:"1px solid var(--yc-color-border)"},children:l},l))})]})}function R({summary:t,onTableClick:i}){const[l,x]=a.useState(new Set),[n,h]=a.useState(new Set),v=s=>{x(o=>{const c=new Set(o);return c.has(s)?c.delete(s):c.add(s),c})},f=s=>{h(o=>{const c=new Set(o);return c.has(s)?c.delete(s):c.add(s),c})},y=((t==null?void 0:t.connections)??[]).map(s=>({connection:s.name,tables:((t==null?void 0:t.tables)??[]).filter(o=>o.connection===s.name)})),u=(t==null?void 0:t.models)??[];return e.jsxs("div",{className:"w-64 flex-shrink-0 flex flex-col h-full overflow-y-auto",style:{borderRight:"1px solid var(--yc-color-border)",background:"var(--yc-color-surface)"},children:[e.jsx("div",{className:"px-3 py-2 flex items-center",style:{borderBottom:"1px solid var(--yc-color-border)"},children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Catalog"})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-2",children:[y.map(s=>e.jsxs("div",{children:[e.jsxs("button",{className:"w-full flex items-center gap-1.5 px-3 py-1.5 hover:opacity-80 text-left",onClick:()=>v(s.connection),children:[e.jsx(g,{expanded:l.has(s.connection)}),e.jsx(I,{}),e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"var(--yc-color-text)"},children:s.connection}),e.jsx("span",{className:"ml-auto text-xs",style:{color:"var(--yc-color-text-secondary)"},children:s.tables.length})]}),l.has(s.connection)&&e.jsx("div",{children:s.tables.map(o=>{const c=`${s.connection}:${o.name}`,m=n.has(c);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 pl-6 pr-2 py-1 group",children:[e.jsxs("button",{className:"flex items-center gap-1 flex-1 min-w-0 hover:opacity-80 text-left",onClick:()=>f(c),children:[e.jsx(g,{expanded:m}),e.jsx(A,{}),e.jsx("span",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:o.schema?`${o.schema}.${o.name}`:o.name})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-xs px-1.5 py-0.5 rounded transition-opacity flex-shrink-0",style:{background:"var(--yc-color-primary)",color:"#fff"},onClick:()=>i(o.schema?`${o.schema}.${o.name}`:o.name),title:`Ask about ${o.name}`,children:"Ask"})]}),m&&o.columns.length>0&&e.jsx("div",{className:"pl-12 pb-1",children:o.columns.map(d=>e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 pr-2",children:[e.jsx("span",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:d.name}),d.type&&e.jsx("span",{className:"text-xs ml-auto flex-shrink-0",style:{color:"var(--yc-color-text-secondary)"},children:d.type})]},d.name))})]},c)})})]},s.connection)),u.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-3 py-1.5",style:{borderTop:"1px solid var(--yc-color-border)"},children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Models"})}),u.map(s=>e.jsxs("div",{className:"flex items-center gap-1.5 pl-3 pr-2 py-1.5 group",children:[e.jsx(O,{}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:s.name}),s.description&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--yc-color-text-secondary)"},children:s.description})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-xs px-1.5 py-0.5 rounded transition-opacity flex-shrink-0",style:{background:"var(--yc-color-primary)",color:"#fff"},onClick:()=>i(s.name),title:`Ask about ${s.name}`,children:"Ask"})]},s.name))]}),!t||y.length===0&&u.length===0?e.jsx("div",{className:"px-3 py-4 text-center",children:e.jsxs("p",{className:"text-xs",style:{color:"var(--yc-color-text-secondary)"},children:["No catalog data available. Run ",e.jsx("code",{className:"font-mono",children:"yamchart sync-warehouse"})," to populate."]})}):null]})]})}function g({expanded:t}){return e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0},children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}function I(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),e.jsx("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function A(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M3 9h18M3 15h18M9 3v18"})]})}function O(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function q(){const t=k(n=>n.savedCharts),[i,l]=a.useState(!1),x=a.useRef(null);return a.useEffect(()=>{if(!i)return;function n(h){x.current&&!x.current.contains(h.target)&&l(!1)}return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[i]),t.length===0?null:e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>l(n=>!n),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-opacity hover:opacity-80",style:{background:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text)"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),e.jsxs("span",{children:[t.length," saved ",t.length===1?"chart":"charts"]}),e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold text-white",style:{background:"var(--yc-color-primary)"},children:t.length})]}),i&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-56 rounded-lg shadow-lg z-50 py-1",style:{background:"var(--yc-color-bg)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("p",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Saved charts"}),t.map(n=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-primary)",flexShrink:0},children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),e.jsx("span",{className:"text-sm truncate",style:{color:"var(--yc-color-text)"},children:n})]},n))]})]})}function V(){const t=E(),{messages:i,isStreaming:l,savedCharts:x,openPanel:n,setPanelMode:h,snapshotExploreHistory:v,clearConversation:f}=k(),[y,u]=a.useState(!0),[s,o]=a.useState(void 0),c=a.useRef(null);a.useEffect(()=>(h("explore"),n({type:"explore"}),()=>{h("panel")}),[h,n]),a.useEffect(()=>{var r;(r=c.current)==null||r.scrollIntoView({behavior:"smooth"})},[i]);const m=a.useCallback((r,p,S)=>{v(p),h("panel");const L=r==="chart"?"charts":"dashboards";window.location.hash=`/${L}/${encodeURIComponent(p)}${S?"?edit=true":""}`,n({type:r==="chart"?"chart":"dashboard",name:p})},[v,h,n]),{sendMessage:d}=B(m),{data:j}=M({queryKey:["catalog-summary"],queryFn:()=>D.getCatalogSummary(),staleTime:6e4,retry:!1}),b=a.useCallback(r=>{o(`Tell me about the ${r} table`)},[]),w=a.useCallback(r=>{d(r)},[d]),N=a.useCallback(r=>{d(r),o(void 0)},[d]),C=a.useCallback(()=>{const r=x.join(", ");d(`Build a dashboard using these charts: ${r}. Arrange them in a logical layout.`)},[x,d]);return t==="sm"?e.jsx("div",{className:"flex items-center justify-center h-screen px-6",style:{background:"var(--yc-color-bg)"},children:e.jsxs("div",{className:"text-center max-w-xs",children:[e.jsx("p",{className:"text-lg font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Desktop required"}),e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Data Explorer is designed for larger screens. Please open it on a desktop or laptop."})]})}):e.jsxs("div",{className:"flex h-screen overflow-hidden",style:{background:"var(--yc-color-bg)"},children:[y&&e.jsx(R,{summary:j??null,onTableClick:b}),e.jsxs("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 flex-shrink-0",style:{borderBottom:"1px solid var(--yc-color-border)"},children:[e.jsxs("a",{href:"#/",className:"flex items-center gap-1.5 text-sm hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:r=>{r.preventDefault(),window.location.hash="/"},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Dashboards"]}),e.jsx("div",{className:"w-px h-4 mx-1",style:{background:"var(--yc-color-border)"}}),e.jsx("button",{className:"p-1.5 rounded hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:()=>u(r=>!r),title:y?"Hide catalog":"Show catalog",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"})]})}),e.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--yc-color-text)"},children:"Data Explorer"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx(q,{}),e.jsxs("button",{disabled:x.length===0||l,onClick:C,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-opacity disabled:opacity-40",style:{background:"var(--yc-color-primary)",color:"#fff"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),"Build Dashboard"]}),i.length>0&&e.jsx("button",{className:"p-1.5 rounded hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:f,title:"New conversation",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 flex flex-col gap-3 min-h-0",children:i.length===0?e.jsx(P,{summary:j??null,onPromptClick:w}):e.jsxs(e.Fragment,{children:[i.map((r,p)=>e.jsx(W,{message:r,isStreaming:l&&p===i.length-1&&r.role==="assistant",onSendMessage:d},p)),e.jsx("div",{ref:c})]})}),e.jsx("div",{className:"px-6 py-3 flex-shrink-0",style:{borderTop:"1px solid var(--yc-color-border)"},children:e.jsx($,{onSend:N,placeholder:"Ask about your data...",disabled:l,initialValue:s})})]})]})}export{V as default};
|
|
1
|
+
import{j as e,k,K as E,N as B,w as M,O as W,Q as $,b as D}from"./index-CY8xsfQH.js";import{a}from"./echarts-DtOYsfLX.js";const T=["What data do I have?","Show me recent trends","What are the top items by revenue?","Compare this month to last month"];function P({summary:t,onPromptClick:i}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-6 py-12 gap-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",style:{color:"var(--yc-color-text)"},children:"Data Explorer"}),e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Ask questions about your data in plain English"})]}),t&&(t.tableCount>0||t.modelCount>0)&&e.jsxs("div",{className:"rounded-xl px-5 py-4 w-full max-w-md flex flex-col gap-3",style:{background:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Connected data"}),e.jsxs("div",{className:"flex gap-6",children:[t.tableCount>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xl font-bold",style:{color:"var(--yc-color-text)"},children:t.tableCount}),e.jsx("span",{className:"text-xs ml-1",style:{color:"var(--yc-color-text-secondary)"},children:t.tableCount===1?"table":"tables"})]}),t.modelCount>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xl font-bold",style:{color:"var(--yc-color-text)"},children:t.modelCount}),e.jsx("span",{className:"text-xs ml-1",style:{color:"var(--yc-color-text-secondary)"},children:t.modelCount===1?"model":"models"})]})]}),t.connections.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.connections.map(l=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"var(--yc-color-bg)",color:"var(--yc-color-text-secondary)",border:"1px solid var(--yc-color-border)"},children:l.name},l.name))})]}),e.jsx("div",{className:"flex flex-wrap gap-2 justify-center max-w-lg",children:T.map(l=>e.jsx("button",{onClick:()=>i(l),className:"text-sm px-3 py-1.5 rounded-full transition-opacity hover:opacity-80",style:{background:"var(--yc-color-surface)",color:"var(--yc-color-text)",border:"1px solid var(--yc-color-border)"},children:l},l))})]})}function R({summary:t,onTableClick:i}){const[l,x]=a.useState(new Set),[n,h]=a.useState(new Set),v=s=>{x(o=>{const c=new Set(o);return c.has(s)?c.delete(s):c.add(s),c})},f=s=>{h(o=>{const c=new Set(o);return c.has(s)?c.delete(s):c.add(s),c})},y=((t==null?void 0:t.connections)??[]).map(s=>({connection:s.name,tables:((t==null?void 0:t.tables)??[]).filter(o=>o.connection===s.name)})),u=(t==null?void 0:t.models)??[];return e.jsxs("div",{className:"w-64 flex-shrink-0 flex flex-col h-full overflow-y-auto",style:{borderRight:"1px solid var(--yc-color-border)",background:"var(--yc-color-surface)"},children:[e.jsx("div",{className:"px-3 py-2 flex items-center",style:{borderBottom:"1px solid var(--yc-color-border)"},children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Catalog"})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-2",children:[y.map(s=>e.jsxs("div",{children:[e.jsxs("button",{className:"w-full flex items-center gap-1.5 px-3 py-1.5 hover:opacity-80 text-left",onClick:()=>v(s.connection),children:[e.jsx(g,{expanded:l.has(s.connection)}),e.jsx(I,{}),e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"var(--yc-color-text)"},children:s.connection}),e.jsx("span",{className:"ml-auto text-xs",style:{color:"var(--yc-color-text-secondary)"},children:s.tables.length})]}),l.has(s.connection)&&e.jsx("div",{children:s.tables.map(o=>{const c=`${s.connection}:${o.name}`,m=n.has(c);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 pl-6 pr-2 py-1 group",children:[e.jsxs("button",{className:"flex items-center gap-1 flex-1 min-w-0 hover:opacity-80 text-left",onClick:()=>f(c),children:[e.jsx(g,{expanded:m}),e.jsx(A,{}),e.jsx("span",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:o.schema?`${o.schema}.${o.name}`:o.name})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-xs px-1.5 py-0.5 rounded transition-opacity flex-shrink-0",style:{background:"var(--yc-color-primary)",color:"#fff"},onClick:()=>i(o.schema?`${o.schema}.${o.name}`:o.name),title:`Ask about ${o.name}`,children:"Ask"})]}),m&&o.columns.length>0&&e.jsx("div",{className:"pl-12 pb-1",children:o.columns.map(d=>e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 pr-2",children:[e.jsx("span",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:d.name}),d.type&&e.jsx("span",{className:"text-xs ml-auto flex-shrink-0",style:{color:"var(--yc-color-text-secondary)"},children:d.type})]},d.name))})]},c)})})]},s.connection)),u.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"px-3 py-1.5",style:{borderTop:"1px solid var(--yc-color-border)"},children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Models"})}),u.map(s=>e.jsxs("div",{className:"flex items-center gap-1.5 pl-3 pr-2 py-1.5 group",children:[e.jsx(O,{}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs truncate",style:{color:"var(--yc-color-text)"},children:s.name}),s.description&&e.jsx("p",{className:"text-xs truncate",style:{color:"var(--yc-color-text-secondary)"},children:s.description})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-xs px-1.5 py-0.5 rounded transition-opacity flex-shrink-0",style:{background:"var(--yc-color-primary)",color:"#fff"},onClick:()=>i(s.name),title:`Ask about ${s.name}`,children:"Ask"})]},s.name))]}),!t||y.length===0&&u.length===0?e.jsx("div",{className:"px-3 py-4 text-center",children:e.jsxs("p",{className:"text-xs",style:{color:"var(--yc-color-text-secondary)"},children:["No catalog data available. Run ",e.jsx("code",{className:"font-mono",children:"yamchart sync-warehouse"})," to populate."]})}):null]})]})}function g({expanded:t}){return e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0},children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}function I(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),e.jsx("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function A(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M3 9h18M3 15h18M9 3v18"})]})}function O(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-text-secondary)",flexShrink:0},children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function q(){const t=k(n=>n.savedCharts),[i,l]=a.useState(!1),x=a.useRef(null);return a.useEffect(()=>{if(!i)return;function n(h){x.current&&!x.current.contains(h.target)&&l(!1)}return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[i]),t.length===0?null:e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>l(n=>!n),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-opacity hover:opacity-80",style:{background:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text)"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),e.jsxs("span",{children:[t.length," saved ",t.length===1?"chart":"charts"]}),e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold text-white",style:{background:"var(--yc-color-primary)"},children:t.length})]}),i&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-56 rounded-lg shadow-lg z-50 py-1",style:{background:"var(--yc-color-bg)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("p",{className:"px-3 py-1.5 text-xs font-semibold uppercase tracking-wide",style:{color:"var(--yc-color-text-secondary)"},children:"Saved charts"}),t.map(n=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--yc-color-primary)",flexShrink:0},children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),e.jsx("span",{className:"text-sm truncate",style:{color:"var(--yc-color-text)"},children:n})]},n))]})]})}function V(){const t=E(),{messages:i,isStreaming:l,savedCharts:x,openPanel:n,setPanelMode:h,snapshotExploreHistory:v,clearConversation:f}=k(),[y,u]=a.useState(!0),[s,o]=a.useState(void 0),c=a.useRef(null);a.useEffect(()=>(h("explore"),n({type:"explore"}),()=>{h("panel")}),[h,n]),a.useEffect(()=>{var r;(r=c.current)==null||r.scrollIntoView({behavior:"smooth"})},[i]);const m=a.useCallback((r,p,S)=>{v(p),h("panel");const L=r==="chart"?"charts":"dashboards";window.location.hash=`/${L}/${encodeURIComponent(p)}${S?"?edit=true":""}`,n({type:r==="chart"?"chart":"dashboard",name:p})},[v,h,n]),{sendMessage:d}=B(m),{data:j}=M({queryKey:["catalog-summary"],queryFn:()=>D.getCatalogSummary(),staleTime:6e4,retry:!1}),b=a.useCallback(r=>{o(`Tell me about the ${r} table`)},[]),w=a.useCallback(r=>{d(r)},[d]),N=a.useCallback(r=>{d(r),o(void 0)},[d]),C=a.useCallback(()=>{const r=x.join(", ");d(`Build a dashboard using these charts: ${r}. Arrange them in a logical layout.`)},[x,d]);return t==="sm"?e.jsx("div",{className:"flex items-center justify-center h-screen px-6",style:{background:"var(--yc-color-bg)"},children:e.jsxs("div",{className:"text-center max-w-xs",children:[e.jsx("p",{className:"text-lg font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Desktop required"}),e.jsx("p",{className:"text-sm",style:{color:"var(--yc-color-text-secondary)"},children:"Data Explorer is designed for larger screens. Please open it on a desktop or laptop."})]})}):e.jsxs("div",{className:"flex h-screen overflow-hidden",style:{background:"var(--yc-color-bg)"},children:[y&&e.jsx(R,{summary:j??null,onTableClick:b}),e.jsxs("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 flex-shrink-0",style:{borderBottom:"1px solid var(--yc-color-border)"},children:[e.jsxs("a",{href:"#/",className:"flex items-center gap-1.5 text-sm hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:r=>{r.preventDefault(),window.location.hash="/"},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Dashboards"]}),e.jsx("div",{className:"w-px h-4 mx-1",style:{background:"var(--yc-color-border)"}}),e.jsx("button",{className:"p-1.5 rounded hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:()=>u(r=>!r),title:y?"Hide catalog":"Show catalog",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18"})]})}),e.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--yc-color-text)"},children:"Data Explorer"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx(q,{}),e.jsxs("button",{disabled:x.length===0||l,onClick:C,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-opacity disabled:opacity-40",style:{background:"var(--yc-color-primary)",color:"#fff"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),"Build Dashboard"]}),i.length>0&&e.jsx("button",{className:"p-1.5 rounded hover:opacity-80",style:{color:"var(--yc-color-text-secondary)"},onClick:f,title:"New conversation",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 flex flex-col gap-3 min-h-0",children:i.length===0?e.jsx(P,{summary:j??null,onPromptClick:w}):e.jsxs(e.Fragment,{children:[i.map((r,p)=>e.jsx(W,{message:r,isStreaming:l&&p===i.length-1&&r.role==="assistant",onSendMessage:d},p)),e.jsx("div",{ref:c})]})}),e.jsx("div",{className:"px-6 py-3 flex-shrink-0",style:{borderTop:"1px solid var(--yc-color-border)"},children:e.jsx($,{onSend:N,placeholder:"Ask about your data...",disabled:l,initialValue:s})})]})]})}export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u,j as e,A as p}from"./index-
|
|
1
|
+
import{u,j as e,A as p}from"./index-CY8xsfQH.js";import{a as r}from"./echarts-DtOYsfLX.js";const f="",g={google:"Google",microsoft:"Microsoft",oidc:"SSO"};function j(){const m=u(o=>o.login),l=u(o=>o.providers),[a,x]=r.useState(""),[t,b]=r.useState(""),[c,s]=r.useState(""),[n,d]=r.useState(!1);r.useEffect(()=>{window.location.hash.includes("error=account_conflict")&&(s("An account with this email already exists. Please sign in with your password."),window.location.hash="#/")},[]);const y=async o=>{o.preventDefault(),s(""),d(!0);try{await m(a,t)}catch(i){i instanceof p?s(i.message):s("An unexpected error occurred")}finally{d(!1)}},h=o=>{window.location.href=`${f}/api/auth/sso/${o}`};return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:"var(--yc-color-background)"},children:e.jsxs("div",{className:"rounded-lg shadow-sm p-8 w-full max-w-md",style:{backgroundColor:"var(--yc-color-surface)",border:"1px solid var(--yc-color-border)"},children:[e.jsx("h1",{className:"text-2xl font-semibold mb-2",style:{color:"var(--yc-color-text)"},children:"Sign in to Yamchart"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"var(--yc-color-text-secondary)"},children:"Enter your credentials to access dashboards."}),c&&e.jsx("div",{className:"text-sm rounded-md px-4 py-3 mb-4",style:{backgroundColor:"color-mix(in srgb, var(--yc-color-danger) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--yc-color-danger) 30%, transparent)",color:"var(--yc-color-danger)"},children:c}),l.length>0&&e.jsxs("div",{className:"space-y-2 mb-6",children:[l.map(o=>e.jsxs("button",{onClick:()=>h(o),className:"w-full py-2 px-4 text-sm font-medium rounded-md hover:bg-black/5",style:{border:"1px solid var(--yc-color-border)",color:"var(--yc-color-text-secondary)"},children:["Sign in with ",g[o]??o]},o)),e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t",style:{borderColor:"var(--yc-color-border)"}})}),e.jsx("div",{className:"relative flex justify-center text-xs",style:{color:"var(--yc-color-text-muted)"},children:e.jsx("span",{className:"px-2",style:{backgroundColor:"var(--yc-color-surface)"},children:"or"})})]})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Email"}),e.jsx("input",{id:"email",type:"email",value:a,onChange:o=>x(o.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium mb-1",style:{color:"var(--yc-color-text-secondary)"},children:"Password"}),e.jsx("input",{id:"password",type:"password",value:t,onChange:o=>b(o.target.value),required:!0,className:"w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",style:{backgroundColor:"var(--yc-color-input-bg)",color:"var(--yc-color-text)",borderColor:"var(--yc-color-border)"},placeholder:"Password"})]}),e.jsx("button",{type:"submit",disabled:n,className:"w-full py-2 px-4 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:n?"Signing in...":"Sign in"})]})]})})}export{j as LoginPage};
|