@trilogy-data/trilogy-studio-components 0.1.26 → 0.1.28

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.
Files changed (145) hide show
  1. package/dist/AssetAutoImporter-C_7Ms9xe.js +403 -0
  2. package/dist/{ChatCreatorModal-CL-jBnc3.js → ChatCreatorModal-Cd40SvdM.js} +3 -3
  3. package/dist/{ChatModelSelect-Do-VRUFc.js → ChatModelSelect-Cz7axWjP.js} +1 -1
  4. package/dist/{CodeBlock-PT4no49I.js → CodeBlock-Dj-GfTbW.js} +4 -4
  5. package/dist/{CommunityModels-Cmro0hV3.js → CommunityModels-lX2RhHCG.js} +7 -7
  6. package/dist/{ConnectionErrorPopup-FSs7U-Yl.js → ConnectionErrorPopup-7vpqgF0s.js} +1 -1
  7. package/dist/{ConnectionView-COnTTuA4.js → ConnectionView-CZ06qjjE.js} +49 -49
  8. package/dist/{CreateEditorFromDatasourcePopup-snOh1d5h.js → CreateEditorFromDatasourcePopup-DwA938kf.js} +4 -4
  9. package/dist/{Dashboard-BH9ZwMVJ.js → Dashboard-CQsIqWZC.js} +276 -280
  10. package/dist/{DashboardImportSelector-DQSvu9T-.js → DashboardImportSelector-CkqH52FX.js} +2 -2
  11. package/dist/{DashboardMobile-BUPtdN2V.js → DashboardMobile-DWFlel5p.js} +39 -39
  12. package/dist/{DrilldownPane-CBs5ZojS.js → DrilldownPane-BheRHJMs.js} +5 -7
  13. package/dist/{Editor-DQsYpkwl.js → Editor-DQ66Vp6v.js} +105 -103
  14. package/dist/{ErrorMessage-XMn_08gJ.js → ErrorMessage-D5JeF3Iz.js} +4 -4
  15. package/dist/{GlobalChatPanel-DhnOaige.js → GlobalChatPanel-B_s3COHE.js} +20 -21
  16. package/dist/{IDE-HLa8vybk.js → IDE-4-Jg6gsM.js} +200 -203
  17. package/dist/{JobsView-B97HBoIE.js → JobsView-B5NWDUgP.js} +13 -14
  18. package/dist/{LLMChat-CxJcPLEG.js → LLMChat-eKgEc-I3.js} +3 -3
  19. package/dist/{LLMView-C1MUf0c2.js → LLMView-CdTwMLVV.js} +23 -23
  20. package/dist/{LoadingView-s1uznGwG.js → LoadingView-Bu3wLJ7J.js} +2 -2
  21. package/dist/{MarkdownRenderer-BNDuEyG-.js → MarkdownRenderer-B6lqdkgc.js} +531 -430
  22. package/dist/{MobileIDE-BpqXoaMR.js → MobileIDE-CZlg20oa.js} +179 -182
  23. package/dist/{ModelCard-BhN25jaV.js → ModelCard-Bs_d7Jis.js} +12 -13
  24. package/dist/{ModelView-DUDA_PtZ.js → ModelView-BP5yyecx.js} +7 -7
  25. package/dist/PageLoading-DKFeqkmK.js +5937 -0
  26. package/dist/{ResultComponent-CAn_r3BL.js → ResultComponent-BaDheojB.js} +8 -8
  27. package/dist/{Results-BJtlwebY.js → Results-CrpHB101.js} +17 -19
  28. package/dist/{StatusIcon-BylPx2EO.js → StatusIcon-Clfyy-Yn.js} +2 -2
  29. package/dist/{StoreTokenModal-zCSYhfrw.js → StoreTokenModal-CO5hXMs3.js} +2 -2
  30. package/dist/{SymbolsPane-KYSwN9Sv.js → SymbolsPane-XFVErDFb.js} +6 -3
  31. package/dist/{TrilogyEmbedProvider-WA_dlv9e.js → TrilogyEmbedProvider-D3h0gYnX.js} +9 -9
  32. package/dist/{TutorialPage-NRcee6Dx.js → TutorialPage-CMcTYDOV.js} +27 -28
  33. package/dist/{VegaLiteChart-D1slfOUY.js → VegaLiteChart-DX_LbF3g.js} +12131 -10947
  34. package/dist/{WelcomePage-D5mU2x1L.js → WelcomePage-B6E35FUa.js} +5 -5
  35. package/dist/{embedTheme-Bub46ILG.js → _plugin-vue_export-helper-f9Rw-Il4.js} +14 -6
  36. package/dist/assets/{css.worker-9aDGcEUy.js → css.worker-niORQtzO.js} +14 -14
  37. package/dist/assets/{html.worker-D2LKDpnG.js → html.worker-CO5LvJpF.js} +17 -17
  38. package/dist/assets/json.worker-BezHzWUV.js +58 -0
  39. package/dist/assets/{ts.worker-Bz0-EaKK.js → ts.worker-CYhxGg0r.js} +107 -107
  40. package/dist/{results-DTgAKr5j.js → base-DuKnVD-A.js} +216 -45
  41. package/dist/components/FeedbackBanner.vue.d.ts +4 -0
  42. package/dist/components/FeedbackBanner.vue.d.ts.map +1 -0
  43. package/dist/components/dashboard/DashboardCreatorIcon.vue.d.ts +54 -0
  44. package/dist/components/dashboard/DashboardCreatorIcon.vue.d.ts.map +1 -0
  45. package/dist/components/dashboard/DashboardProvenance.vue.d.ts +30 -0
  46. package/dist/components/dashboard/DashboardProvenance.vue.d.ts.map +1 -0
  47. package/dist/components/dashboard/ReportLayout.vue.d.ts +19 -0
  48. package/dist/components/dashboard/ReportLayout.vue.d.ts.map +1 -0
  49. package/dist/components/editor/Editor.vue.d.ts +3 -3
  50. package/dist/components/editor/EditorCreatorIcon.vue.d.ts +62 -0
  51. package/dist/components/editor/EditorCreatorIcon.vue.d.ts.map +1 -0
  52. package/dist/components/editor/ValidationComponent.vue.d.ts +50 -0
  53. package/dist/components/editor/ValidationComponent.vue.d.ts.map +1 -0
  54. package/dist/components/model/ModelCard.vue.d.ts +3 -3
  55. package/dist/components/sidebar/LLMConnectionList.vue.d.ts.map +1 -1
  56. package/dist/components/sidebar/Sidebar.vue.d.ts.map +1 -1
  57. package/dist/components/tutorial/TutorialPrompt.vue.d.ts +3 -3
  58. package/dist/components/tutorial/TutorialPrompt.vue.d.ts.map +1 -1
  59. package/dist/{remoteWorker-Dkv3TJ0j.js → connections-CWH3zwH2.js} +4544 -4126
  60. package/dist/connections.js +3 -4
  61. package/dist/{cssMode-D4Rzr1Cu.js → cssMode-zpO2ap2B.js} +5 -6
  62. package/dist/dashboard.js +28 -31
  63. package/dist/dashboards/dashboardQueryExecutor.d.ts +9 -0
  64. package/dist/dashboards/dashboardQueryExecutor.d.ts.map +1 -1
  65. package/dist/{dist-CXoL8kXK.js → dist-1z5KURzS.js} +55 -50
  66. package/dist/{dist-DKkuvbPb.js → dist-Bv3D2p5A.js} +20 -18
  67. package/dist/{editor.main-Cl8i7rHY.js → editor.main-BQh6DxDB.js} +33 -33
  68. package/dist/{editorRefinementRuntime-DoP9P5J2.js → editorStore-CiWH_nGN.js} +1692 -575
  69. package/dist/embed.js +2 -2
  70. package/dist/{freemarker2-fW5NBILf.js → freemarker2-DQBqlEXc.js} +1 -1
  71. package/dist/{globalChatRuntime-DWZxeS57.js → globalChatRuntime-DAERmOdu.js} +16 -16
  72. package/dist/{handlebars-dG4w8UUY.js → handlebars-tgYxaM70.js} +1 -1
  73. package/dist/{helpers-BLQAgX3C.js → helpers-C2pARJoZ.js} +34 -35
  74. package/dist/{html-1Dq70BdU.js → html-jJahD3Mi.js} +1 -1
  75. package/dist/{htmlMode--IQmLBeh.js → htmlMode-BA1-8l2e.js} +5 -6
  76. package/dist/{javascript-CTzBM4sF.js → javascript-Cypfo7va.js} +1 -1
  77. package/dist/{jsonMode-DzeJjIEH.js → jsonMode-xJye8PWS.js} +25 -25
  78. package/dist/{liquid-DlHThiki.js → liquid-BGDrv5da.js} +1 -1
  79. package/dist/llm/data/prompts.d.ts +1 -1
  80. package/dist/llm/data/prompts.d.ts.map +1 -1
  81. package/dist/llm/data/trilogySyntax.generated.d.ts +3 -3
  82. package/dist/llm/data/trilogySyntax.generated.d.ts.map +1 -1
  83. package/dist/llm-Wf4Etiu9.js +18493 -0
  84. package/dist/llm.js +2 -3
  85. package/dist/{localStorage-D9uyOFEO.js → localStorage-C3xms-ab.js} +40 -43
  86. package/dist/{lspLanguageFeatures-Cdfs3EKq.js → lspLanguageFeatures-V3e_p9oN.js} +32 -32
  87. package/dist/{mdx-fn3g4PH5.js → mdx-BUR1aImW.js} +1 -1
  88. package/dist/monaco.js +4 -4
  89. package/dist/{python-CCVj0pFt.js → python-YLkl0pc6.js} +1 -1
  90. package/dist/{razor-Cj3flYnk.js → razor-BP8TRMDY.js} +1 -1
  91. package/dist/{reconcile-Dyf4UZmj.js → reconcile-BH_ReGDR.js} +1 -1
  92. package/dist/{remoteStoreSync-Z-yjlYtI.js → remoteStoreSync-B0K8QScO.js} +3 -3
  93. package/dist/{rolldown-runtime-Dqa2HsxW.js → rolldown-runtime-B0aSnxlc.js} +2 -2
  94. package/dist/static/test_import.vue.d.ts +4 -0
  95. package/dist/static/test_import.vue.d.ts.map +1 -0
  96. package/dist/stores-DTGQZ4_B.js +2612 -0
  97. package/dist/stores.js +4 -7
  98. package/dist/trilogy-studio-components.css +1 -1
  99. package/dist/{tsMode-GI4xMYAl.js → tsMode-BH9HS_sH.js} +64 -66
  100. package/dist/{typescript-CPibXi3J.js → typescript-BM-ynfk9.js} +1 -1
  101. package/dist/{useChatWithTools-B0HZ_DVh.js → useChatWithTools-BSrzJtYI.js} +11 -11
  102. package/dist/{useDashboard-CdSnPe_6.js → useDashboard-CGeIdDuX.js} +1014 -1022
  103. package/dist/{tabulator_esm-CxLvGDp8.js → useGlobalChatPanel-D9kMZLeF.js} +1729 -711
  104. package/dist/{useResizableDialog-B0ePSts4.js → useResizableDialog-Cs90WJdF.js} +2 -2
  105. package/dist/views/ModelView.vue.d.ts +6 -6
  106. package/dist/views/ModelView.vue.d.ts.map +1 -1
  107. package/dist/views/TutorialPage.vue.d.ts +9 -9
  108. package/dist/views/TutorialPage.vue.d.ts.map +1 -1
  109. package/dist/views.js +192 -194
  110. package/dist/{vocabulary-CKLGILtR.js → vocabulary-DQK5jB7m.js} +3 -1
  111. package/dist/{editor.api2-ClD5pp8H.js → workers-B9Eybl-M.js} +16252 -15926
  112. package/dist/{xml-BNyphceI.js → xml-M5WFPSpA.js} +1 -1
  113. package/dist/{yaml-DE5Vz0PH.js → yaml-CEeFwjz9.js} +1 -1
  114. package/package.json +29 -20
  115. package/dist/AssetAutoImporter-CBzvBaOt.js +0 -405
  116. package/dist/DashboardCreatorInline-CDU7kLy3.js +0 -129
  117. package/dist/DataTable-DoRDynP1.js +0 -365
  118. package/dist/EditorCreatorInline-D6_y1H_h.js +0 -125
  119. package/dist/LoadingButton-OH3frQuO.js +0 -138
  120. package/dist/ModalDialog-D1EOG4rl.js +0 -42
  121. package/dist/ModelCreator-CCdC7EXt.js +0 -253
  122. package/dist/PageLoading-BzniJM0C.js +0 -2669
  123. package/dist/Tooltip-Dihir4zs.js +0 -103
  124. package/dist/_plugin-vue_export-helper-B3ysoDQm.js +0 -8
  125. package/dist/assets/json.worker-CJ5MmO5Q.js +0 -58
  126. package/dist/base-C8IuZWqY.js +0 -164
  127. package/dist/connectionHistoryStorage-DKJHiKJY.js +0 -111
  128. package/dist/connectionHistoryStore-DQeBvStZ.js +0 -61
  129. package/dist/connections-CJSb1TZl.js +0 -229
  130. package/dist/constants-DgFEYN2b.js +0 -7
  131. package/dist/dashboardStore-ppM6nGks.js +0 -641
  132. package/dist/demoSetup-mwa-RDC6.js +0 -2942
  133. package/dist/editorRefinementToolExecutor-CVY3FA7k.js +0 -4624
  134. package/dist/editorStore-BhhmXbi-.js +0 -1019
  135. package/dist/formatting-BbJ5ICgh.js +0 -6
  136. package/dist/llm-BBOVWb-F.js +0 -11967
  137. package/dist/llmStore-DJM2JhzY.js +0 -153
  138. package/dist/monaco.contribution-ikesdolO.js +0 -128
  139. package/dist/stores-BT9hTLny.js +0 -1708
  140. package/dist/trilogy-BroD2Qmp.js +0 -4
  141. package/dist/urlStore-52HG6lsX.js +0 -55
  142. package/dist/useGlobalChatPanel-D_0luajQ.js +0 -85
  143. package/dist/useIsMobile-CNpUQAvk.js +0 -8
  144. package/dist/usePrismHighlight-DVyDiDAL.js +0 -183
  145. package/dist/workers-Br7ThUKL.js +0 -47
@@ -1,641 +0,0 @@
1
- import { Ot as e, kt as t, yt as n } from "./editorRefinementToolExecutor-CVY3FA7k.js";
2
- import { r } from "./editorStore-BhhmXbi-.js";
3
- import { s as i } from "./llm-BBOVWb-F.js";
4
- import { defineStore as a } from "pinia";
5
- //#region dashboards/dashboardQueryExecutor.ts
6
- function o(e) {
7
- return typeof e == "string" ? e : typeof e?.error == "string" && e.error ? e.error : typeof e?.message == "string" && e.message ? e.message : "Unknown error occurred";
8
- }
9
- var s = class {
10
- queryQueue = /* @__PURE__ */ new Map();
11
- activeQueries = /* @__PURE__ */ new Set();
12
- queryWaiters = /* @__PURE__ */ new Map();
13
- latestQueryByItemId = /* @__PURE__ */ new Map();
14
- itemIdsByQueryId = /* @__PURE__ */ new Map();
15
- queryExecutionService;
16
- connectionName;
17
- dashboardId;
18
- getItemData;
19
- setItemData;
20
- getDashboardData;
21
- maxConcurrentQueries;
22
- retryAttempts;
23
- batchDelay;
24
- batchTimeout = null;
25
- constructor(e, t, n, r, i, a, o = {}) {
26
- this.queryExecutionService = e, this.connectionName = t, this.maxConcurrentQueries = o.maxConcurrentQueries || 10, this.retryAttempts = o.retryAttempts || 2, this.batchDelay = o.batchDelay || 0, this.dashboardId = n, this.getItemData = i, this.setItemData = a, this.getDashboardData = r;
27
- }
28
- cancelPendingQueriesForItem(e) {
29
- let t = this.latestQueryByItemId.get(e), n = [];
30
- this.queryQueue.forEach((r, i) => {
31
- r.itemId === e && i !== t && n.push(i);
32
- }), this.activeQueries.forEach((r) => {
33
- let i = this.itemIdsByQueryId.get(r);
34
- !i?.has(e) || r === t || [...i].some((t) => t !== e && this.latestQueryByItemId.get(t) === r) || n.push(r);
35
- }), n.forEach((t) => {
36
- console.log(`Cancelling outdated query ${t} for itemId ${e}`), this.cancelQuery(t);
37
- });
38
- }
39
- trackQueryForItem(e, t) {
40
- this.latestQueryByItemId.set(e, t);
41
- let n = this.itemIdsByQueryId.get(t);
42
- n ? n.add(e) : this.itemIdsByQueryId.set(t, /* @__PURE__ */ new Set([e]));
43
- }
44
- isLatestQueryForItem(e, t) {
45
- return this.latestQueryByItemId.get(e) === t;
46
- }
47
- isQueryInFlight(e) {
48
- return this.queryQueue.has(e) || this.activeQueries.has(e);
49
- }
50
- settleQueryLoading(e) {
51
- let t = this.itemIdsByQueryId.get(e);
52
- if (t) for (let e of t) {
53
- let t = this.latestQueryByItemId.get(e);
54
- t && this.isQueryInFlight(t) || this.setItemData(e, this.dashboardId, { loading: !1 });
55
- }
56
- }
57
- cleanupQueryTracking(e) {
58
- let t = this.itemIdsByQueryId.get(e);
59
- if (t) {
60
- for (let n of t) this.latestQueryByItemId.get(n) === e && this.latestQueryByItemId.delete(n);
61
- this.itemIdsByQueryId.delete(e);
62
- }
63
- }
64
- getDefaultPriority(e) {
65
- return this.getDashboardData(this.dashboardId).layout.find((t) => t.i === e)?.y || 0;
66
- }
67
- setConnection(e) {
68
- this.connectionName = e;
69
- }
70
- getDashboardImports() {
71
- return this.getDashboardData(this.dashboardId).imports.map((e) => ({
72
- name: e.name,
73
- alias: e.alias
74
- }));
75
- }
76
- waitForQuery(e) {
77
- return new Promise((t, n) => {
78
- if (!this.queryQueue.has(e) && !this.activeQueries.has(e)) {
79
- n(/* @__PURE__ */ Error(`Query ${e} not found or already completed`));
80
- return;
81
- }
82
- this.queryWaiters.set(e, {
83
- resolve: t,
84
- reject: n
85
- });
86
- });
87
- }
88
- getItemQueryText(e) {
89
- return (e.structured_content ? e.structured_content.query : e.content) || "";
90
- }
91
- enqueueItemQuery(e, t) {
92
- let n = this.getItemData(e, this.dashboardId), r = this.getItemQueryText(n);
93
- if (r.trim().length === 0) return this.setItemData(e, this.dashboardId, {
94
- error: null,
95
- loading: !1
96
- }), null;
97
- let i = n.filters || [], a = Object.assign({}, ...i.map((e) => e.parameters || {}));
98
- this.setItemData(e, this.dashboardId, {
99
- loading: !0,
100
- error: null
101
- });
102
- let o, s = () => this.isLatestQueryForItem(e, o), c = {
103
- dashboardId: this.dashboardId,
104
- queryInput: {
105
- text: r,
106
- extraFilters: i.map((e) => e.value),
107
- parameters: {
108
- ...n.parameters || {},
109
- ...a
110
- },
111
- extraContent: n.rootContent || []
112
- },
113
- priority: this.getDefaultPriority(e),
114
- itemId: e,
115
- onSuccess: (t) => {
116
- s() ? this.setItemData(e, this.dashboardId, { results: t.results }) : console.log(`Ignoring outdated query result for itemId ${e}`);
117
- },
118
- onError: (t) => {
119
- s() ? this.setItemData(e, this.dashboardId, { error: t }) : console.log(`Ignoring outdated query error for itemId ${e}`);
120
- },
121
- onProgress: (e) => {}
122
- }, l = this.generateQueryId(c);
123
- this.cancelPendingQueriesForItem(e);
124
- let u = this.findDuplicateQuery(c);
125
- if (u) console.log(`Deduplicating query for ${e}`), o = u.id, this.addCallbacksToExistingQuery(u, c);
126
- else {
127
- o = l;
128
- let n = {
129
- ...c,
130
- id: o,
131
- timestamp: Date.now(),
132
- retryCount: 0
133
- };
134
- this.queryQueue.set(o, n), t && this.activeQueries.size < this.maxConcurrentQueries && (console.log(`Executing query immediately for ${e}`), this.executeQuery(o));
135
- }
136
- return this.trackQueryForItem(e, o), o;
137
- }
138
- runSingle(e) {
139
- return this.enqueueItemQuery(e, !0);
140
- }
141
- runBatch(e) {
142
- this.batchTimeout && clearTimeout(this.batchTimeout);
143
- let t = e.map((e) => this.enqueueItemQuery(e, !1)).filter((e) => e !== null);
144
- return this.batchTimeout = setTimeout(() => {
145
- this.processBatch();
146
- }, this.batchDelay), t;
147
- }
148
- cancelQuery(e) {
149
- let t = this.queryWaiters.get(e);
150
- return t && (t.reject("Query was cancelled"), this.queryWaiters.delete(e)), this.cleanupQueryTracking(e), this.queryQueue.has(e) ? (this.queryQueue.delete(e), !0) : this.activeQueries.has(e) ? (this.activeQueries.delete(e), !0) : !1;
151
- }
152
- clearQueue() {
153
- this.queryWaiters.forEach((e, t) => {
154
- e.reject("Queue was cleared");
155
- }), this.queryWaiters.clear(), this.queryQueue.clear(), this.latestQueryByItemId.clear(), this.itemIdsByQueryId.clear(), this.batchTimeout &&= (clearTimeout(this.batchTimeout), null);
156
- }
157
- getStatus() {
158
- return {
159
- queued: this.queryQueue.size,
160
- active: this.activeQueries.size,
161
- queuedQueries: Array.from(this.queryQueue.values()),
162
- latestQueryByItemId: Object.fromEntries(this.latestQueryByItemId)
163
- };
164
- }
165
- async createDrilldownQuery(e, t, n, r, i = [], a = this.getDashboardImports()) {
166
- return await this.queryExecutionService.createConnectionDrilldownQuery(this.connectionName, e, "trilogy", a, t, n, r, i);
167
- }
168
- generateQueryId(e) {
169
- return `${e.dashboardId}-${e.itemId}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
170
- }
171
- findDuplicateQuery(e) {
172
- for (let [, t] of this.queryQueue) if (t.dashboardId === e.dashboardId && t.queryInput.text === e.queryInput.text && JSON.stringify(t.queryInput.extraFilters) === JSON.stringify(e.queryInput.extraFilters) && JSON.stringify(t.queryInput.parameters) === JSON.stringify(e.queryInput.parameters)) return t;
173
- return null;
174
- }
175
- addCallbacksToExistingQuery(e, t) {
176
- let n = e.onSuccess, r = e.onError, i = e.onProgress;
177
- e.onSuccess = (e) => {
178
- n(e), t.onSuccess(e);
179
- }, e.onError = (e) => {
180
- r(e), t.onError(e);
181
- }, e.onProgress = (e) => {
182
- i(e), t.onProgress(e);
183
- }, e.priority = Math.min(e.priority, t.priority);
184
- }
185
- processBatch() {
186
- if (this.queryQueue.size === 0) return;
187
- let e = Array.from(this.queryQueue.values()).sort((e, t) => e.priority === t.priority ? e.timestamp - t.timestamp : e.priority - t.priority), t = this.maxConcurrentQueries - this.activeQueries.size, n = e.slice(0, t);
188
- this.executeBatchQueries(n);
189
- }
190
- async executeBatchQueries(e) {
191
- if (e.length !== 0) try {
192
- let t = this.getDashboardImports(), n = [], r = [];
193
- for (let t of e) {
194
- let e = t.id;
195
- this.activeQueries.has(e) || this.queryQueue.has(e) && (this.queryQueue.delete(e), this.activeQueries.add(e), n.push({
196
- query: t.queryInput.text,
197
- label: e,
198
- extra_filters: t.queryInput.extraFilters,
199
- parameters: t.queryInput.parameters
200
- }), r.push(t));
201
- }
202
- if (n.length === 0) return;
203
- let i = Object.fromEntries(n.map((e) => [e.label, (t) => {
204
- r.find((t) => t.id === e.label)?.onSuccess(t);
205
- let n = this.queryWaiters.get(e.label);
206
- n && (n.resolve(t), this.queryWaiters.delete(e.label)), this.activeQueries.delete(e.label), this.settleQueryLoading(e.label), this.cleanupQueryTracking(e.label);
207
- }])), a = Object.fromEntries(n.map((e) => [e.label, (t) => {
208
- let n = o(t), i = r.find((t) => t.id === e.label);
209
- i && this.handleQueryError(i, n), this.activeQueries.delete(e.label), this.settleQueryLoading(e.label), this.cleanupQueryTracking(e.label);
210
- }])), { resultPromise: s } = await this.queryExecutionService.executeQueriesBatch(this.connectionName, n, "trilogy", t, [], {}, () => {}, () => {}, a, i, !1, r[0]?.queryInput.extraContent || []), c = await s;
211
- console.log(`Batch query executed successfully with ${c.results.length} results`);
212
- } catch (t) {
213
- let n = t instanceof Error ? t.message : "Unknown error occurred";
214
- for (let t of e) {
215
- let e = t.id;
216
- this.activeQueries.has(e) && (t.retryCount < this.retryAttempts ? (console.log(`Retrying query ${e} (attempt ${t.retryCount + 1})`), t.retryCount++, t.timestamp = Date.now(), this.activeQueries.delete(e), this.queryQueue.set(e, t), setTimeout(() => {
217
- this.queryQueue.has(e) && this.executeQuery(e);
218
- }, 1e3 * t.retryCount)) : (this.handleQueryError(t, n), this.activeQueries.delete(e), this.settleQueryLoading(e), this.cleanupQueryTracking(e)));
219
- }
220
- } finally {
221
- this.processBatch();
222
- }
223
- }
224
- handleQueryError(e, t) {
225
- let n = e.id;
226
- e.onError(t);
227
- let r = this.queryWaiters.get(n);
228
- r && (r.reject(t), this.queryWaiters.delete(n));
229
- }
230
- async executeQuery(e) {
231
- let t = this.queryQueue.get(e);
232
- if (t) try {
233
- this.queryQueue.delete(e), this.activeQueries.add(e);
234
- let n = this.getDashboardImports(), r = {
235
- ...t.queryInput,
236
- imports: n,
237
- editorType: "trilogy"
238
- }, { resultPromise: i } = await this.queryExecutionService.executeQuery(this.connectionName, r, () => {}, (e) => {
239
- e.error && t.onProgress(e);
240
- }), a = await i;
241
- if (a.success && a.results) {
242
- t.onSuccess(a);
243
- let n = this.queryWaiters.get(e);
244
- n && (n.resolve(a), this.queryWaiters.delete(e));
245
- } else if (a.error) {
246
- t.onError(a.error);
247
- let n = this.queryWaiters.get(e);
248
- n && (n.reject(a.error), this.queryWaiters.delete(e));
249
- }
250
- } catch (n) {
251
- let r = n instanceof Error ? n.message : "Unknown error occurred";
252
- if (t.retryCount < this.retryAttempts) console.log(`Retrying query ${e} (attempt ${t.retryCount + 1})`), t.retryCount++, t.timestamp = Date.now(), this.queryQueue.set(e, t), setTimeout(() => {
253
- this.queryQueue.has(e) && this.executeQuery(e);
254
- }, 1e3 * t.retryCount);
255
- else {
256
- t.onError(r);
257
- let n = this.queryWaiters.get(e);
258
- n && (n.reject(r), this.queryWaiters.delete(e));
259
- }
260
- } finally {
261
- this.activeQueries.delete(e), this.settleQueryLoading(e), this.cleanupQueryTracking(e), this.processBatch();
262
- }
263
- }
264
- }, c = (e) => e.replace(/\s+/g, "");
265
- function l(e) {
266
- if (!e) return;
267
- let t = r();
268
- return t.connections[e] || t.connectionByName(e);
269
- }
270
- var u = a("dashboards", {
271
- state: () => ({
272
- dashboards: {},
273
- activeDashboardId: "",
274
- queryExecutors: {},
275
- pendingChatPrompts: {}
276
- }),
277
- getters: {
278
- dashboardList: (e) => Object.values(e.dashboards),
279
- activeDashboard: (e) => e.activeDashboardId ? e.dashboards[e.activeDashboardId] : null,
280
- getConnectionDashboards: (e) => (t) => Object.values(e.dashboards).filter((e) => e.connectionId === t),
281
- unsavedDashboards: (e) => Object.values(e.dashboards).filter((e) => e.changed).length,
282
- activeQueryExecutor: (e) => e.activeDashboardId ? e.queryExecutors[e.activeDashboardId] : null,
283
- hasQueryExecutor: (e) => (t) => !!e.queryExecutors[t]
284
- },
285
- actions: {
286
- getOrCreateQueryExecutor(e, t) {
287
- if (!this.dashboards[e]) throw Error(`Dashboard with ID "${e}" not found.`);
288
- if (this.queryExecutors[e]) {
289
- let n = this.queryExecutors[e];
290
- return t.connectionName && n.connectionName !== t.connectionName && n.setConnection(t.connectionName), n;
291
- }
292
- let n = new s(t.queryExecutionService, t.connectionName, t.dashboardId, t.getDashboardData, t.getItemData, t.setItemData, t.options || {});
293
- return this.queryExecutors[e] = n, console.log(`Created new query executor for dashboard: ${e}`), n;
294
- },
295
- getQueryExecutor(e) {
296
- return this.queryExecutors[e] || null;
297
- },
298
- removeQueryExecutor(e) {
299
- return this.queryExecutors[e] ? (this.queryExecutors[e].clearQueue(), delete this.queryExecutors[e], console.log(`Removed query executor for dashboard: ${e}`), !0) : !1;
300
- },
301
- clearAllQueryExecutors() {
302
- Object.keys(this.queryExecutors).forEach((e) => {
303
- this.queryExecutors[e].clearQueue();
304
- }), this.queryExecutors = {}, console.log("Cleared all query executors");
305
- },
306
- getQueryExecutorStatuses() {
307
- let e = {};
308
- return Object.entries(this.queryExecutors).forEach(([t, n]) => {
309
- e[t] = {
310
- dashboardName: this.dashboards[t]?.name || "Unknown",
311
- ...n.getStatus()
312
- };
313
- }), e;
314
- },
315
- getDashboardByName(e) {
316
- return Object.values(this.dashboards).find((t) => t.name === e) || null;
317
- },
318
- newDashboard(e, n) {
319
- let r = e;
320
- if (Object.values(this.dashboards).some((t) => t.name === e)) throw Error(`A dashboard with name ${e} already exists.`);
321
- let i = l(n), a = new t({
322
- id: r,
323
- name: e,
324
- connection: i?.name || n,
325
- connectionId: i?.id || n,
326
- storage: "local",
327
- state: "editing"
328
- });
329
- return this.dashboards[r] = a, a;
330
- },
331
- newReport(e, t) {
332
- let n = this.newDashboard(e, t);
333
- return n.setLayoutType("report"), n;
334
- },
335
- cloneDashboard(e) {
336
- let n = this.dashboards[e];
337
- if (!n) throw Error(`Dashboard with ID "${e}" not found.`);
338
- let r = `${n.name} (copy)`, i = 1;
339
- for (; Object.values(this.dashboards).some((e) => e.name === r);) r = `${n.name} (copy ${i})`, i++;
340
- let a = new t({
341
- id: r,
342
- name: r,
343
- connection: n.connection,
344
- connectionId: n.connectionId,
345
- storage: n.storage,
346
- state: "editing"
347
- });
348
- return a.gridItems = Object.fromEntries(Object.entries(n.gridItems).map(([e, t]) => [e, {
349
- ...t,
350
- chartFilters: [],
351
- conceptFilters: [],
352
- filters: []
353
- }])), a.layout = n.layout.map((e) => ({ ...e })), a.imports = n.imports.map((e) => ({ ...e })), a.filter = n.filter, a.description = n.description, a.updatedAt = /* @__PURE__ */ new Date(), a.nextId = n.nextId, a.changed = !0, this.addDashboard(a), this.activeDashboardId = r, a;
354
- },
355
- forkDashboard(e, n) {
356
- let r = this.dashboards[e];
357
- if (!r) throw Error(`Dashboard with ID "${e}" not found.`);
358
- let i = `${r.name} / ${n}`, a = 1;
359
- for (; this.dashboards[i];) i = `${r.name} / ${n} (${a})`, a++;
360
- let o = new t({
361
- id: i,
362
- name: i,
363
- connection: r.connection,
364
- connectionId: r.connectionId,
365
- storage: r.storage,
366
- state: "editing",
367
- parentDashboardId: e,
368
- investigationName: n,
369
- investigationCreatedFrom: { timestamp: /* @__PURE__ */ new Date() },
370
- description: r.description
371
- });
372
- return o.gridItems = Object.fromEntries(Object.entries(r.gridItems).map(([e, t]) => [e, {
373
- ...t,
374
- chartFilters: [],
375
- conceptFilters: [],
376
- filters: []
377
- }])), o.layout = r.layout.map((e) => ({ ...e })), o.imports = r.imports.map((e) => ({ ...e })), o.filter = r.filter, o.nextId = r.nextId, o.changed = !0, r.children ||= [], r.children.push(i), r.changed = !0, this.addDashboard(o), this.activeDashboardId = i, o;
378
- },
379
- promoteDashboard(e) {
380
- let t = this.dashboards[e];
381
- if (!t) throw Error(`Dashboard with ID "${e}" not found.`);
382
- if (t.parentDashboardId) {
383
- let n = this.dashboards[t.parentDashboardId];
384
- n?.children && (n.children = n.children.filter((t) => t !== e), n.changed = !0);
385
- }
386
- return t.parentDashboardId = null, t.investigationName = void 0, t.investigationCreatedFrom = void 0, t.changed = !0, t;
387
- },
388
- getInvestigations(e) {
389
- return Object.values(this.dashboards).filter((t) => t.parentDashboardId === e && !t.deleted);
390
- },
391
- getRootDashboards() {
392
- return Object.values(this.dashboards).filter((e) => !e.parentDashboardId && !e.deleted);
393
- },
394
- addDashboard(e) {
395
- this.dashboards[e.id] = e;
396
- },
397
- loadDashboards(e) {
398
- Object.entries(e).forEach(([e, n]) => {
399
- this.dashboards[e] = t.fromSerialized(n);
400
- });
401
- },
402
- removeAllFilters(e) {
403
- if (this.dashboards[e]) return this.dashboards[e].removeAllFilters();
404
- throw Error(`Dashboard with ID "${e}" not found.`);
405
- },
406
- getConnectionDashboardsSync(e) {
407
- return Object.values(this.dashboards).filter((t) => t.connectionId === e);
408
- },
409
- setPendingChatPrompt(e, t) {
410
- this.pendingChatPrompts[e] = t;
411
- },
412
- consumePendingChatPrompt(e) {
413
- let t = this.pendingChatPrompts[e];
414
- return t === void 0 ? null : (delete this.pendingChatPrompts[e], t);
415
- },
416
- setActiveDashboard(e) {
417
- if (this.dashboards[e]) this.activeDashboardId = e;
418
- else throw Error(`Dashboard with ID "${e}" not found.`);
419
- },
420
- setDashboardState(e, t) {
421
- if (this.dashboards[e]) this.dashboards[e].state = t;
422
- else throw Error(`Dashboard with ID "${e}" not found.`);
423
- },
424
- updateDashboardName(e, t) {
425
- if (this.dashboards[e]) this.dashboards[e].name = t, this.dashboards[e].updatedAt = /* @__PURE__ */ new Date();
426
- else throw Error(`Dashboard with ID "${e}" not found.`);
427
- },
428
- updateDashboardFilter(e, t) {
429
- if (this.dashboards[e]) {
430
- let n = this.dashboards[e].filter;
431
- return (!t || c(t) === "") && (this.dashboards[e].filter = null, n != null) || (this.dashboards[e].filter = t, n !== t) ? Object.entries(this.dashboards[e].gridItems).map(([e, t]) => e) : [];
432
- } else throw Error(`Dashboard with ID "${e}" not found.`);
433
- },
434
- updateDashboardImports(e, t) {
435
- if (this.dashboards[e]) this.dashboards[e].imports = t;
436
- else throw Error(`Dashboard with ID "${e}" not found.`);
437
- },
438
- removeDashboard(e) {
439
- if (this.dashboards[e]) this.removeQueryExecutor(e), delete this.dashboards[e], this.activeDashboardId === e && (this.activeDashboardId = "");
440
- else throw Error(`Dashboard with ID "${e}" not found.`);
441
- },
442
- purgeDeletedDashboards() {
443
- for (let e of Object.keys(this.dashboards)) this.dashboards[e].deleted && (this.removeQueryExecutor(e), delete this.dashboards[e], this.activeDashboardId === e && (this.activeDashboardId = ""));
444
- },
445
- setState(e, t) {
446
- this.dashboards[e] && (this.dashboards[e].state = t);
447
- },
448
- setDashboardLayoutType(e, t) {
449
- let n = this.dashboards[e];
450
- if (!n) throw Error(`Dashboard with ID "${e}" not found.`);
451
- n.setLayoutType(t);
452
- },
453
- setDashboardTheme(e, t) {
454
- let n = this.dashboards[e];
455
- if (!n) throw Error(`Dashboard with ID "${e}" not found.`);
456
- n.setTheme(t);
457
- },
458
- addItemToDashboard(e, t, n = 0, r = 0, i = 5, a = null, o = null, s = null) {
459
- if (this.dashboards[e]) return this.dashboards[e].addItem(t, n, r, i, a, o, s);
460
- throw Error(`Dashboard with ID "${e}" not found.`);
461
- },
462
- updateDashboardTitle(e, t) {
463
- if (this.dashboards[e]) this.dashboards[e].name = t, this.dashboards[e].updatedAt = /* @__PURE__ */ new Date();
464
- else throw Error(`Dashboard with ID "${e}" not found.`);
465
- },
466
- updateItemContent(e, t, n) {
467
- if (this.dashboards[e]) this.dashboards[e].updateItemContent(t, n);
468
- else throw Error(`Dashboard with ID "${e}" not found.`);
469
- },
470
- updateItemCrossFilterEligibility(e, t, n) {
471
- if (this.dashboards[e]) this.dashboards[e].updateItemCrossFilterEligibility(t, n);
472
- else throw Error(`Dashboard with ID "${e}" not found.`);
473
- },
474
- updateItemResults(e, t, n) {
475
- if (this.dashboards[e]) this.dashboards[e].updateItemResults(t, n);
476
- else throw Error(`Dashboard with ID "${e}" not found.`);
477
- },
478
- updateItemLoading(e, t, n) {
479
- if (this.dashboards[e]) this.dashboards[e].updateItemLoading(t, n);
480
- else throw Error(`Dashboard with ID "${e}" not found.`);
481
- },
482
- updateItemError(e, t, n) {
483
- if (this.dashboards[e]) this.dashboards[e].updateItemError(t, n);
484
- else throw Error(`Dashboard with ID "${e}" not found.`);
485
- },
486
- updateItemDrilldown(e, t, n) {
487
- if (this.dashboards[e]) this.dashboards[e].updateItemDrilldown(t, n);
488
- else throw Error(`Dashboard with ID "${e}" not found.`);
489
- },
490
- updateItemDrilldownChartConfig(e, t, n) {
491
- if (this.dashboards[e]) this.dashboards[e].updateItemDrilldownChartConfig(t, n);
492
- else throw Error(`Dashboard with ID "${e}" not found.`);
493
- },
494
- updateItemType(e, t, n) {
495
- if (this.dashboards[e]) this.dashboards[e].updateItemType(t, n);
496
- else throw Error(`Dashboard with ID "${e} not found`);
497
- },
498
- updateItemCrossFilters(e, t, n, r, i) {
499
- if (this.dashboards[e]) return this.dashboards[e].updateItemCrossFilters(t, n, r, i);
500
- throw Error(`Dashboard with ID "${e}" not found.`);
501
- },
502
- removeItemCrossFilter(e, t, n) {
503
- if (this.dashboards[e]) return this.dashboards[e].removeItemCrossFilter(t, n), t;
504
- throw Error(`Dashboard with ID "${e}" not found.`);
505
- },
506
- removeItemCrossFilterSource(e, t) {
507
- if (this.dashboards[e]) return this.dashboards[e].removeItemCrossFilterSource(t);
508
- throw Error(`Dashboard with ID "${e}" not found.`);
509
- },
510
- updateItemName(e, t, n) {
511
- if (this.dashboards[e]) this.dashboards[e].updateItemName(t, n);
512
- else throw Error(`Dashboard with ID "${e}" not found.`);
513
- },
514
- updateItemChartConfig(e, t, n) {
515
- if (this.dashboards[e]) this.dashboards[e].updateItemChartConfig(t, n);
516
- else throw Error(`Dashboard with ID "${e}" not found.`);
517
- },
518
- updateMultipleItemProperties(e, t, n) {
519
- if (!this.dashboards[e]) throw Error(`Dashboard with ID "${e}" not found.`);
520
- this.dashboards[e].updateItemMultipleProperties(t, n);
521
- },
522
- updateDashboardConnection(e, t) {
523
- if (this.dashboards[e]) {
524
- let n = l(t);
525
- this.dashboards[e].connection = n?.name || t, this.dashboards[e].connectionId = n?.id || t, this.dashboards[e].changed = !0;
526
- } else throw Error(`Dashboard with ID "${e}" not found.`);
527
- },
528
- updateDashboardDescription(e, t) {
529
- if (this.dashboards[e]) this.dashboards[e].description = t;
530
- else throw Error(`Dashboard with ID "${e}" not found.`);
531
- },
532
- updateDashboardLayout(e, t) {
533
- if (this.dashboards[e]) this.dashboards[e].updateLayout(t);
534
- else throw Error(`Dashboard with ID "${e}" not found.`);
535
- },
536
- updateItemDimensions(e, t, n, r) {
537
- if (this.dashboards[e]) this.dashboards[e].updateItemDimensions(t, n, r);
538
- else throw Error(`Dashboard with ID "${e}" not found.`);
539
- },
540
- updateItemLayoutDimensions(e, t, n = null, r = null, i = null, a = null) {
541
- if (this.dashboards[e]) this.dashboards[e].updateItemLayoutDimensions(t, n, r, i, a);
542
- else throw Error(`Dashboard with ID "${e}" not found.`);
543
- },
544
- removeItemFromDashboard(e, t) {
545
- if (this.dashboards[e]) this.dashboards[e].removeItem(t);
546
- else throw Error(`Dashboard with ID "${e}" not found.`);
547
- },
548
- copyItemInDashboard(e, t) {
549
- if (this.dashboards[e]) return this.dashboards[e].copyItem(t);
550
- throw Error(`Dashboard with ID "${e}" not found.`);
551
- },
552
- clearDashboardItems(e) {
553
- if (this.dashboards[e]) this.dashboards[e].clearItems();
554
- else throw Error(`Dashboard with ID "${e}" not found.`);
555
- },
556
- serializeDashboards() {
557
- let e = {};
558
- return Object.entries(this.dashboards).forEach(([t, n]) => {
559
- n.storage === "local" && (e[t] = n.serialize());
560
- }), e;
561
- },
562
- async warmDashboardQueries(t, n, r) {
563
- let i = this.dashboards[t];
564
- if (i) {
565
- for (let t of Object.values(i.gridItems)) if (t.type === e.CHART || t.type === e.TABLE) {
566
- let e = typeof t.content == "string" ? t.content : t.content?.query || "";
567
- await n?.generateQuery(i.connectionId || i.connection, {
568
- text: e,
569
- editorType: "trilogy",
570
- imports: i.imports,
571
- extraContent: i.imports.map((e) => ({
572
- alias: e.name,
573
- contents: r.editors[e.id]?.contents || r.editors[e.name]?.contents || ""
574
- }))
575
- });
576
- }
577
- }
578
- },
579
- async populateCompletion(e, t, n) {
580
- let r = this.dashboards[e];
581
- if (r) {
582
- let i = await t?.validateQuery(r.connectionId || r.connection, {
583
- text: "select 1 as test;",
584
- editorType: "trilogy",
585
- imports: r.imports,
586
- extraContent: r.imports.map((e) => ({
587
- alias: e.name,
588
- contents: n.editors[e.id]?.contents || n.editors[e.name]?.contents || ""
589
- }))
590
- });
591
- return i ? i.data.completion_items : (console.log(`No results returned from validateQuery for dashboard ID "${e}".`), []);
592
- } else throw Error(`Dashboard with ID "${e}" not found.`);
593
- },
594
- async populateAIConcepts(e, t, n) {
595
- let r = await this.populateCompletion(e, t, n);
596
- if (!r) throw Error(`No completion items found for dashboard ID "${e}".`);
597
- return i(r);
598
- },
599
- async generatePromptSpec(e, t, r, i) {
600
- let a = await this.populateAIConcepts(this.activeDashboardId, r, i), o = await t.generateDashboardCompletion(e, n, a, 3);
601
- if (!o) throw Error("No response from LLM");
602
- return n(o);
603
- },
604
- async populateFromPromptSpec(t, n, r, i, a) {
605
- let o = this.dashboards[t];
606
- if (!o) throw Error(`Dashboard with ID "${t}" not found.`);
607
- o.name = n.name, o.description = n.description;
608
- let s = await this.populateAIConcepts(t, i, a);
609
- if (!s) throw Error(`No completion items found for dashboard ID "${t}".`);
610
- let c = async (e) => {
611
- let t = {
612
- text: e,
613
- editorType: "trilogy",
614
- imports: o.imports,
615
- extraContent: o.imports.map((e) => ({
616
- alias: e.name,
617
- contents: a.editors[e.id]?.contents || a.editors[e.name]?.contents || ""
618
- }))
619
- };
620
- return await (await i.executeQuery(o.connectionId || o.connection, t, () => {}, () => {}, (e) => {
621
- throw e;
622
- }, () => !0, !0)).resultPromise, !0;
623
- }, l = /* @__PURE__ */ new Map();
624
- for (let r of n.layout) {
625
- let i = n.gridItems[r.id], a = i.content, o = i.type.toLowerCase();
626
- [e.CHART, e.TABLE].includes(o) && (a = `Placeholder, prompt: ${a}`);
627
- let s = this.addItemToDashboard(t, "markdown", r.x, r.y, r.w, r.h, a, i.name);
628
- l.set(s, {
629
- type: o,
630
- content: a
631
- });
632
- }
633
- for (let n of l) {
634
- let i = n[0], a = n[1], o = a.content;
635
- [e.CHART, e.TABLE].includes(a.type) && (o = (await r.generateQueryCompletion(a.content, s, c)).content || "No query could be generated"), await this.updateItemContent(t, i, o), await this.updateItemType(t, i, a.type);
636
- }
637
- }
638
- }
639
- });
640
- //#endregion
641
- export { u as n, s as r, c as t };