@quillsql/admin 1.8.7 → 1.8.8
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/index.cjs +591 -218
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +486 -115
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -47,9 +47,11 @@ __export(index_exports, {
|
|
|
47
47
|
SecondaryButtonPrimitive: () => SecondaryButtonPrimitive_default,
|
|
48
48
|
TextInputPrimitive: () => TextInputPrimitive_default,
|
|
49
49
|
VirtualTableManager: () => VirtualTableManager,
|
|
50
|
+
clearQuillSandboxStorage: () => clearQuillSandboxStorage,
|
|
50
51
|
exportChatAsMarkdown: () => exportChatAsMarkdown,
|
|
51
52
|
useAdmin: () => useAdmin,
|
|
52
|
-
useAgentChat: () => useAgentChat
|
|
53
|
+
useAgentChat: () => useAgentChat,
|
|
54
|
+
useSandboxSession: () => useSandboxSession
|
|
53
55
|
});
|
|
54
56
|
module.exports = __toCommonJS(index_exports);
|
|
55
57
|
|
|
@@ -8175,32 +8177,140 @@ var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
|
|
|
8175
8177
|
|
|
8176
8178
|
// src/components/AgentChat/AgentChatContext.tsx
|
|
8177
8179
|
var import_react24 = require("react");
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
var
|
|
8181
|
-
|
|
8180
|
+
|
|
8181
|
+
// src/utils/sandboxStorage.ts
|
|
8182
|
+
var SANDBOX_STORAGE_KEY = "quill-sandbox-session";
|
|
8183
|
+
var LEGACY_SESSION_STORAGE_KEY = "quill-agent-session";
|
|
8184
|
+
function parsePersistedSandbox(raw) {
|
|
8185
|
+
if (!raw) return null;
|
|
8186
|
+
try {
|
|
8187
|
+
const parsed = JSON.parse(raw);
|
|
8188
|
+
if (parsed?.clerkOrgId && parsed?.sandboxSessionId && parsed?.sandboxClientId && parsed?.session?.sessionId) {
|
|
8189
|
+
return parsed;
|
|
8190
|
+
}
|
|
8191
|
+
} catch {
|
|
8192
|
+
}
|
|
8193
|
+
return null;
|
|
8194
|
+
}
|
|
8195
|
+
function readPersistedSandboxRaw() {
|
|
8182
8196
|
if (typeof window === "undefined") {
|
|
8183
8197
|
return null;
|
|
8184
8198
|
}
|
|
8199
|
+
return parsePersistedSandbox(
|
|
8200
|
+
window.localStorage.getItem(SANDBOX_STORAGE_KEY)
|
|
8201
|
+
);
|
|
8202
|
+
}
|
|
8203
|
+
function readLegacySandboxSession(clerkOrgId) {
|
|
8185
8204
|
try {
|
|
8186
|
-
const
|
|
8187
|
-
if (!
|
|
8188
|
-
const
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8205
|
+
const legacyRaw = window.sessionStorage.getItem(LEGACY_SESSION_STORAGE_KEY);
|
|
8206
|
+
if (!legacyRaw) return null;
|
|
8207
|
+
const legacy = JSON.parse(legacyRaw);
|
|
8208
|
+
const session = legacy?.session;
|
|
8209
|
+
if (!session?.sessionId || !session.sandboxClientId) return null;
|
|
8210
|
+
return {
|
|
8211
|
+
clerkOrgId,
|
|
8212
|
+
sandboxParentClientId: session.sourceClientId,
|
|
8213
|
+
sandboxClientId: session.sandboxClientId,
|
|
8214
|
+
sandboxSessionId: session.sessionId,
|
|
8215
|
+
session,
|
|
8216
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8217
|
+
};
|
|
8192
8218
|
} catch {
|
|
8219
|
+
return null;
|
|
8220
|
+
}
|
|
8221
|
+
}
|
|
8222
|
+
function resolveSandboxSession(clerkOrgId) {
|
|
8223
|
+
if (typeof window === "undefined") {
|
|
8224
|
+
return null;
|
|
8225
|
+
}
|
|
8226
|
+
const fromLocal = readPersistedSandboxRaw();
|
|
8227
|
+
if (fromLocal) {
|
|
8228
|
+
if (!clerkOrgId || fromLocal.clerkOrgId === clerkOrgId) {
|
|
8229
|
+
return fromLocal;
|
|
8230
|
+
}
|
|
8231
|
+
return null;
|
|
8232
|
+
}
|
|
8233
|
+
if (!clerkOrgId) {
|
|
8234
|
+
return null;
|
|
8235
|
+
}
|
|
8236
|
+
return readLegacySandboxSession(clerkOrgId);
|
|
8237
|
+
}
|
|
8238
|
+
function writeSandboxSession(payload) {
|
|
8239
|
+
if (typeof window === "undefined") return;
|
|
8240
|
+
window.localStorage.setItem(
|
|
8241
|
+
SANDBOX_STORAGE_KEY,
|
|
8242
|
+
JSON.stringify({ ...payload, updatedAt: (/* @__PURE__ */ new Date()).toISOString() })
|
|
8243
|
+
);
|
|
8244
|
+
window.sessionStorage.removeItem(LEGACY_SESSION_STORAGE_KEY);
|
|
8245
|
+
}
|
|
8246
|
+
function clearSandboxSession() {
|
|
8247
|
+
if (typeof window === "undefined") return;
|
|
8248
|
+
window.localStorage.removeItem(SANDBOX_STORAGE_KEY);
|
|
8249
|
+
window.sessionStorage.removeItem(LEGACY_SESSION_STORAGE_KEY);
|
|
8250
|
+
}
|
|
8251
|
+
function clearQuillSandboxStorage() {
|
|
8252
|
+
clearSandboxSession();
|
|
8253
|
+
}
|
|
8254
|
+
function subscribeSandboxSession(onChange) {
|
|
8255
|
+
if (typeof window === "undefined") {
|
|
8256
|
+
return () => {
|
|
8257
|
+
};
|
|
8258
|
+
}
|
|
8259
|
+
const handler = (event) => {
|
|
8260
|
+
if (event.key !== SANDBOX_STORAGE_KEY) return;
|
|
8261
|
+
onChange(parsePersistedSandbox(event.newValue));
|
|
8262
|
+
};
|
|
8263
|
+
window.addEventListener("storage", handler);
|
|
8264
|
+
return () => window.removeEventListener("storage", handler);
|
|
8265
|
+
}
|
|
8266
|
+
function sandboxFieldsFromSession(sessionInfo, resultClient) {
|
|
8267
|
+
return {
|
|
8268
|
+
sandboxParentClientId: String(
|
|
8269
|
+
resultClient?.sandboxParentClientId ?? sessionInfo.sourceClientId
|
|
8270
|
+
),
|
|
8271
|
+
sandboxClientId: String(sessionInfo.sandboxClientId),
|
|
8272
|
+
sandboxSessionId: String(sessionInfo.sessionId)
|
|
8273
|
+
};
|
|
8274
|
+
}
|
|
8275
|
+
function persistSandboxFromSessionInfo(scopeId, sessionInfo, resultClient) {
|
|
8276
|
+
if (!scopeId) return;
|
|
8277
|
+
const fields = sandboxFieldsFromSession(sessionInfo, resultClient);
|
|
8278
|
+
writeSandboxSession({
|
|
8279
|
+
clerkOrgId: scopeId,
|
|
8280
|
+
...fields,
|
|
8281
|
+
session: sessionInfo,
|
|
8282
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8283
|
+
});
|
|
8284
|
+
}
|
|
8285
|
+
function getSandboxStorageScopeId(...candidates) {
|
|
8286
|
+
for (const candidate of candidates) {
|
|
8287
|
+
if (candidate) return candidate;
|
|
8193
8288
|
}
|
|
8194
8289
|
return null;
|
|
8195
8290
|
}
|
|
8196
|
-
|
|
8291
|
+
|
|
8292
|
+
// src/components/AgentChat/AgentChatContext.tsx
|
|
8293
|
+
var AgentChatContext = (0, import_react24.createContext)(null);
|
|
8294
|
+
var WELCOME_MESSAGE = "I'm your Quill BI Agent. I can create dashboards, reports, virtual tables, run queries, and manage environments \u2014 all through conversation.\n\nI'm working in a sandbox copy of your environment, so nothing affects production until you promote your changes.";
|
|
8295
|
+
function hydrateSessionFromStorage(clerkOrgId) {
|
|
8296
|
+
return resolveSandboxSession(clerkOrgId)?.session ?? null;
|
|
8297
|
+
}
|
|
8298
|
+
function useAgentChatRootState(clerkOrgId) {
|
|
8197
8299
|
const [messages, setMessages] = (0, import_react24.useState)([
|
|
8198
8300
|
{ role: "assistant", content: WELCOME_MESSAGE, isWelcome: true }
|
|
8199
8301
|
]);
|
|
8200
|
-
const [
|
|
8201
|
-
|
|
8302
|
+
const [session, setSessionRaw] = (0, import_react24.useState)(
|
|
8303
|
+
() => hydrateSessionFromStorage(clerkOrgId)
|
|
8304
|
+
);
|
|
8202
8305
|
const [showToolOutputs, setShowToolOutputs] = (0, import_react24.useState)(false);
|
|
8203
8306
|
const [changelogEntries, setChangelogEntriesState] = (0, import_react24.useState)([]);
|
|
8307
|
+
(0, import_react24.useEffect)(() => {
|
|
8308
|
+
if (!clerkOrgId) return;
|
|
8309
|
+
const stored = resolveSandboxSession(clerkOrgId);
|
|
8310
|
+
if (stored?.session) {
|
|
8311
|
+
setSessionRaw((prev) => prev ?? stored.session);
|
|
8312
|
+
}
|
|
8313
|
+
}, [clerkOrgId]);
|
|
8204
8314
|
const setChangelogEntries = (0, import_react24.useCallback)((entries) => {
|
|
8205
8315
|
setChangelogEntriesState(entries);
|
|
8206
8316
|
}, []);
|
|
@@ -8213,17 +8323,6 @@ function useAgentChatRootState() {
|
|
|
8213
8323
|
return next;
|
|
8214
8324
|
});
|
|
8215
8325
|
}, []);
|
|
8216
|
-
(0, import_react24.useEffect)(() => {
|
|
8217
|
-
if (typeof window === "undefined") return;
|
|
8218
|
-
if (session) {
|
|
8219
|
-
window.sessionStorage.setItem(
|
|
8220
|
-
SESSION_STORAGE_KEY,
|
|
8221
|
-
JSON.stringify({ session })
|
|
8222
|
-
);
|
|
8223
|
-
} else {
|
|
8224
|
-
window.sessionStorage.removeItem(SESSION_STORAGE_KEY);
|
|
8225
|
-
}
|
|
8226
|
-
}, [session]);
|
|
8227
8326
|
return {
|
|
8228
8327
|
messages,
|
|
8229
8328
|
setMessages,
|
|
@@ -8480,7 +8579,7 @@ function AdminProvider({
|
|
|
8480
8579
|
onRequestAddVirtualTable,
|
|
8481
8580
|
hideEnvDropdown
|
|
8482
8581
|
}) {
|
|
8483
|
-
const agentChatState = useAgentChatRootState();
|
|
8582
|
+
const agentChatState = useAgentChatRootState(clerkOrgId);
|
|
8484
8583
|
const refreshChangelogRef = (0, import_react27.useRef)(null);
|
|
8485
8584
|
const registerChangelogRefresh = (0, import_react27.useCallback)(
|
|
8486
8585
|
(fn) => {
|
|
@@ -8490,6 +8589,7 @@ function AdminProvider({
|
|
|
8490
8589
|
);
|
|
8491
8590
|
const [clientLoading, setClientLoading] = (0, import_react27.useState)(true);
|
|
8492
8591
|
const currentFetchingClientRef = (0, import_react27.useRef)(void 0);
|
|
8592
|
+
const previousClerkOrgIdRef = (0, import_react27.useRef)(void 0);
|
|
8493
8593
|
const [schemaLoading, setSchemaLoading] = (0, import_react27.useState)(false);
|
|
8494
8594
|
const [error, setError] = (0, import_react27.useState)(null);
|
|
8495
8595
|
const publicKeyRef = (0, import_react27.useRef)(void 0);
|
|
@@ -8564,6 +8664,21 @@ function AdminProvider({
|
|
|
8564
8664
|
sandboxSessionId: null
|
|
8565
8665
|
};
|
|
8566
8666
|
};
|
|
8667
|
+
const mergeSandboxIntoState = (baseState, orgId) => {
|
|
8668
|
+
const storedSandbox = resolveSandboxSession(
|
|
8669
|
+
orgId ?? clerkOrgId ?? baseState.clerkOrgId
|
|
8670
|
+
);
|
|
8671
|
+
if (!storedSandbox) {
|
|
8672
|
+
return baseState;
|
|
8673
|
+
}
|
|
8674
|
+
return {
|
|
8675
|
+
...baseState,
|
|
8676
|
+
clerkOrgId: storedSandbox.clerkOrgId || baseState.clerkOrgId,
|
|
8677
|
+
sandboxParentClientId: storedSandbox.sandboxParentClientId,
|
|
8678
|
+
sandboxClientId: storedSandbox.sandboxClientId,
|
|
8679
|
+
sandboxSessionId: storedSandbox.sandboxSessionId
|
|
8680
|
+
};
|
|
8681
|
+
};
|
|
8567
8682
|
const hydrateStateFromSessionStorage = () => {
|
|
8568
8683
|
if (typeof window === "undefined") {
|
|
8569
8684
|
return null;
|
|
@@ -8574,7 +8689,8 @@ function AdminProvider({
|
|
|
8574
8689
|
);
|
|
8575
8690
|
if (clerkOrgId && localState?.clerkOrgId === clerkOrgId) {
|
|
8576
8691
|
const parsedState = parsedSessionStorageAdminState(localState);
|
|
8577
|
-
|
|
8692
|
+
const storedSandbox2 = resolveSandboxSession(clerkOrgId);
|
|
8693
|
+
return mergeSandboxIntoState({
|
|
8578
8694
|
...parsedState,
|
|
8579
8695
|
queryEndpoint,
|
|
8580
8696
|
isSelfHosted: !QUILL_ENDPOINTS.includes(
|
|
@@ -8583,10 +8699,14 @@ function AdminProvider({
|
|
|
8583
8699
|
queryHeaders: queryHeaders !== void 0 ? queryHeaders : parsedState.queryHeaders,
|
|
8584
8700
|
withCredentials: withCredentials !== void 0 ? withCredentials : parsedState.withCredentials,
|
|
8585
8701
|
hideEnvDropdown: hideEnvDropdown !== void 0 ? hideEnvDropdown : parsedState.hideEnvDropdown ?? false,
|
|
8586
|
-
sandboxParentClientId: parsedState.sandboxParentClientId ?? null,
|
|
8587
|
-
sandboxClientId: parsedState.sandboxClientId ?? null,
|
|
8588
|
-
sandboxSessionId: parsedState.sandboxSessionId ?? null
|
|
8589
|
-
};
|
|
8702
|
+
sandboxParentClientId: storedSandbox2?.sandboxParentClientId ?? parsedState.sandboxParentClientId ?? null,
|
|
8703
|
+
sandboxClientId: storedSandbox2?.sandboxClientId ?? parsedState.sandboxClientId ?? null,
|
|
8704
|
+
sandboxSessionId: storedSandbox2?.sandboxSessionId ?? parsedState.sandboxSessionId ?? null
|
|
8705
|
+
});
|
|
8706
|
+
}
|
|
8707
|
+
if (clerkOrgId && localState?.clerkOrgId && localState.clerkOrgId !== clerkOrgId) {
|
|
8708
|
+
window.sessionStorage.removeItem("quill-adminState");
|
|
8709
|
+
window.sessionStorage.removeItem("quill-client");
|
|
8590
8710
|
}
|
|
8591
8711
|
} catch (error2) {
|
|
8592
8712
|
console.warn(
|
|
@@ -8594,8 +8714,14 @@ function AdminProvider({
|
|
|
8594
8714
|
error2
|
|
8595
8715
|
);
|
|
8596
8716
|
}
|
|
8597
|
-
|
|
8598
|
-
|
|
8717
|
+
const storedSandbox = resolveSandboxSession(clerkOrgId);
|
|
8718
|
+
if (storedSandbox) {
|
|
8719
|
+
return mergeSandboxIntoState(buildDefaultState());
|
|
8720
|
+
}
|
|
8721
|
+
const storedWithoutOrg = resolveSandboxSession(null);
|
|
8722
|
+
if (storedWithoutOrg) {
|
|
8723
|
+
return mergeSandboxIntoState(buildDefaultState());
|
|
8724
|
+
}
|
|
8599
8725
|
return null;
|
|
8600
8726
|
};
|
|
8601
8727
|
const initialState = (0, import_react27.useMemo)(() => {
|
|
@@ -8639,7 +8765,12 @@ function AdminProvider({
|
|
|
8639
8765
|
return;
|
|
8640
8766
|
}
|
|
8641
8767
|
const activeClientId = state.client?._id ?? state.client?.id ?? state.client?.publicKey ?? state.client?.clientId;
|
|
8642
|
-
|
|
8768
|
+
const targetClientIdString = String(targetClientId);
|
|
8769
|
+
const sandboxClientId = state.sandboxClientId ? String(state.sandboxClientId) : null;
|
|
8770
|
+
const sandboxParentClientId = state.sandboxParentClientId ? String(state.sandboxParentClientId) : null;
|
|
8771
|
+
const switchingOutsideSandbox = !!state.sandboxSessionId && targetClientIdString !== sandboxClientId && targetClientIdString !== sandboxParentClientId;
|
|
8772
|
+
const shouldResetSandbox = !!resetSandbox || switchingOutsideSandbox;
|
|
8773
|
+
if (!forceRefresh && !shouldResetSandbox && activeClientId != null && String(activeClientId) === String(targetClientId)) {
|
|
8643
8774
|
return;
|
|
8644
8775
|
}
|
|
8645
8776
|
setClientLoading(true);
|
|
@@ -8647,7 +8778,7 @@ function AdminProvider({
|
|
|
8647
8778
|
targetClientId,
|
|
8648
8779
|
false,
|
|
8649
8780
|
preserveSelectedDashboard,
|
|
8650
|
-
|
|
8781
|
+
shouldResetSandbox
|
|
8651
8782
|
);
|
|
8652
8783
|
return;
|
|
8653
8784
|
}
|
|
@@ -8784,11 +8915,15 @@ function AdminProvider({
|
|
|
8784
8915
|
setClientLoading(true);
|
|
8785
8916
|
currentFetchingClientRef.current = publicKey2;
|
|
8786
8917
|
const requestedClientId = String(publicKey2);
|
|
8787
|
-
const
|
|
8788
|
-
const
|
|
8789
|
-
const
|
|
8918
|
+
const storedSandbox = resolveSandboxSession(clerkOrgId ?? state.clerkOrgId);
|
|
8919
|
+
const sandboxClientId = state.sandboxClientId != null ? String(state.sandboxClientId) : storedSandbox?.sandboxClientId ?? null;
|
|
8920
|
+
const sandboxParentClientId = state.sandboxParentClientId != null ? String(state.sandboxParentClientId) : storedSandbox?.sandboxParentClientId ?? null;
|
|
8921
|
+
const sandboxSessionId = state.sandboxSessionId ?? storedSandbox?.sandboxSessionId ?? null;
|
|
8922
|
+
const loadingExistingSandbox = loadSandbox && !resetSandbox && !!sandboxClientId && !!sandboxSessionId && (requestedClientId === sandboxClientId || requestedClientId === sandboxParentClientId);
|
|
8923
|
+
const requestClientId = loadingExistingSandbox ? sandboxParentClientId ?? publicKey2 : publicKey2;
|
|
8790
8924
|
if (resetSandbox) {
|
|
8791
8925
|
agentChatState.clearChangelogEntries();
|
|
8926
|
+
clearSandboxSession();
|
|
8792
8927
|
}
|
|
8793
8928
|
try {
|
|
8794
8929
|
const data = await quillFetchWithToken({
|
|
@@ -8796,14 +8931,14 @@ function AdminProvider({
|
|
|
8796
8931
|
queryEndpoint,
|
|
8797
8932
|
queryHeaders,
|
|
8798
8933
|
withCredentials: !!state.withCredentials,
|
|
8799
|
-
clientId:
|
|
8934
|
+
clientId: requestClientId
|
|
8800
8935
|
},
|
|
8801
8936
|
task: "client",
|
|
8802
8937
|
metadata: {
|
|
8803
|
-
clientId: loadingExistingSandbox ? sandboxParentClientId ??
|
|
8938
|
+
clientId: loadingExistingSandbox ? sandboxParentClientId ?? requestClientId : requestClientId,
|
|
8804
8939
|
fetchDefaultDashboard: true,
|
|
8805
8940
|
sandboxClientId: loadingExistingSandbox ? sandboxClientId : void 0,
|
|
8806
|
-
sandboxSessionId: loadingExistingSandbox ?
|
|
8941
|
+
sandboxSessionId: loadingExistingSandbox ? sandboxSessionId ?? void 0 : void 0,
|
|
8807
8942
|
...loadSandbox ? { loadSandbox: true } : {},
|
|
8808
8943
|
...resetSandbox ? { resetSandbox: true } : {}
|
|
8809
8944
|
},
|
|
@@ -8837,11 +8972,11 @@ function AdminProvider({
|
|
|
8837
8972
|
queryEndpoint,
|
|
8838
8973
|
queryHeaders,
|
|
8839
8974
|
withCredentials: !!state.withCredentials,
|
|
8840
|
-
clientId:
|
|
8975
|
+
clientId: requestClientId
|
|
8841
8976
|
},
|
|
8842
8977
|
task: "clients",
|
|
8843
8978
|
metadata: {
|
|
8844
|
-
clientId:
|
|
8979
|
+
clientId: requestClientId
|
|
8845
8980
|
},
|
|
8846
8981
|
adminMode: true
|
|
8847
8982
|
}) : Promise.resolve(void 0)
|
|
@@ -8860,9 +8995,48 @@ function AdminProvider({
|
|
|
8860
8995
|
});
|
|
8861
8996
|
}
|
|
8862
8997
|
const sessionInfo = buildSessionInfo(result, publicKey2);
|
|
8863
|
-
|
|
8998
|
+
if (sessionInfo) {
|
|
8999
|
+
agentChatState.setSession(sessionInfo);
|
|
9000
|
+
const sandboxFields = sandboxFieldsFromSession(sessionInfo, result.client);
|
|
9001
|
+
dispatch({
|
|
9002
|
+
type: "SET_SANDBOX_FIELDS",
|
|
9003
|
+
payload: sandboxFields
|
|
9004
|
+
});
|
|
9005
|
+
persistSandboxFromSessionInfo(
|
|
9006
|
+
getSandboxStorageScopeId(
|
|
9007
|
+
clerkOrgId,
|
|
9008
|
+
state.clerkOrgId,
|
|
9009
|
+
publicKey2
|
|
9010
|
+
),
|
|
9011
|
+
sessionInfo,
|
|
9012
|
+
result.client
|
|
9013
|
+
);
|
|
9014
|
+
} else if (resetSandbox) {
|
|
9015
|
+
agentChatState.setSession(null);
|
|
9016
|
+
dispatch({
|
|
9017
|
+
type: "SET_SANDBOX_FIELDS",
|
|
9018
|
+
payload: {
|
|
9019
|
+
sandboxParentClientId: null,
|
|
9020
|
+
sandboxClientId: null,
|
|
9021
|
+
sandboxSessionId: null
|
|
9022
|
+
}
|
|
9023
|
+
});
|
|
9024
|
+
} else {
|
|
9025
|
+
const preservedSandbox = storedSandbox ?? resolveSandboxSession(clerkOrgId ?? state.clerkOrgId);
|
|
9026
|
+
if (preservedSandbox) {
|
|
9027
|
+
dispatch({
|
|
9028
|
+
type: "SET_SANDBOX_FIELDS",
|
|
9029
|
+
payload: {
|
|
9030
|
+
sandboxParentClientId: preservedSandbox.sandboxParentClientId,
|
|
9031
|
+
sandboxClientId: preservedSandbox.sandboxClientId,
|
|
9032
|
+
sandboxSessionId: preservedSandbox.sandboxSessionId
|
|
9033
|
+
}
|
|
9034
|
+
});
|
|
9035
|
+
agentChatState.setSession((prev) => prev ?? preservedSandbox.session);
|
|
9036
|
+
}
|
|
9037
|
+
}
|
|
8864
9038
|
if (typeof window !== "undefined" && clerkOrgId) {
|
|
8865
|
-
const sourceClientId = sessionInfo?.sourceClientId ?? requestedClientId;
|
|
9039
|
+
const sourceClientId = sessionInfo?.sourceClientId ?? storedSandbox?.sandboxParentClientId ?? requestedClientId;
|
|
8866
9040
|
window.sessionStorage.setItem(
|
|
8867
9041
|
"quill-client",
|
|
8868
9042
|
JSON.stringify({
|
|
@@ -8871,16 +9045,6 @@ function AdminProvider({
|
|
|
8871
9045
|
})
|
|
8872
9046
|
);
|
|
8873
9047
|
}
|
|
8874
|
-
dispatch({
|
|
8875
|
-
type: "SET_SANDBOX_FIELDS",
|
|
8876
|
-
payload: {
|
|
8877
|
-
sandboxParentClientId: sessionInfo ? String(
|
|
8878
|
-
result.client.sandboxParentClientId ?? sessionInfo.sourceClientId
|
|
8879
|
-
) : null,
|
|
8880
|
-
sandboxClientId: sessionInfo?.sandboxClientId ?? null,
|
|
8881
|
-
sandboxSessionId: sessionInfo?.sessionId ?? null
|
|
8882
|
-
}
|
|
8883
|
-
});
|
|
8884
9048
|
setClient({
|
|
8885
9049
|
...result.client,
|
|
8886
9050
|
queryEndpoint: result.client.queryEndpoint ?? queryEndpoint,
|
|
@@ -8950,12 +9114,123 @@ function AdminProvider({
|
|
|
8950
9114
|
dispatch({ type: "SET_CLERK_ORG_ID", payload: clerkOrgId });
|
|
8951
9115
|
}
|
|
8952
9116
|
}, [clerkOrgId]);
|
|
9117
|
+
(0, import_react27.useEffect)(() => {
|
|
9118
|
+
const previousClerkOrgId = previousClerkOrgIdRef.current;
|
|
9119
|
+
const currentClerkOrgId = clerkOrgId ?? null;
|
|
9120
|
+
if (previousClerkOrgId !== void 0 && previousClerkOrgId !== currentClerkOrgId) {
|
|
9121
|
+
clearSandboxSession();
|
|
9122
|
+
agentChatState.setSession(null);
|
|
9123
|
+
agentChatState.clearChangelogEntries();
|
|
9124
|
+
dispatch({
|
|
9125
|
+
type: "SET_SANDBOX_FIELDS",
|
|
9126
|
+
payload: {
|
|
9127
|
+
sandboxParentClientId: null,
|
|
9128
|
+
sandboxClientId: null,
|
|
9129
|
+
sandboxSessionId: null
|
|
9130
|
+
}
|
|
9131
|
+
});
|
|
9132
|
+
}
|
|
9133
|
+
previousClerkOrgIdRef.current = currentClerkOrgId;
|
|
9134
|
+
}, [clerkOrgId, agentChatState.setSession, agentChatState.clearChangelogEntries]);
|
|
9135
|
+
(0, import_react27.useEffect)(() => {
|
|
9136
|
+
if (!clerkOrgId) return;
|
|
9137
|
+
const storedSandbox = resolveSandboxSession(clerkOrgId);
|
|
9138
|
+
if (!storedSandbox) return;
|
|
9139
|
+
if (!state.sandboxSessionId || state.sandboxSessionId !== storedSandbox.sandboxSessionId) {
|
|
9140
|
+
dispatch({
|
|
9141
|
+
type: "SET_SANDBOX_FIELDS",
|
|
9142
|
+
payload: {
|
|
9143
|
+
sandboxParentClientId: storedSandbox.sandboxParentClientId,
|
|
9144
|
+
sandboxClientId: storedSandbox.sandboxClientId,
|
|
9145
|
+
sandboxSessionId: storedSandbox.sandboxSessionId
|
|
9146
|
+
}
|
|
9147
|
+
});
|
|
9148
|
+
}
|
|
9149
|
+
agentChatState.setSession((prev) => prev ?? storedSandbox.session);
|
|
9150
|
+
}, [clerkOrgId]);
|
|
9151
|
+
(0, import_react27.useEffect)(() => {
|
|
9152
|
+
if (!clerkOrgId) return;
|
|
9153
|
+
return subscribeSandboxSession((stored) => {
|
|
9154
|
+
if (!stored || stored.clerkOrgId !== clerkOrgId) {
|
|
9155
|
+
dispatch({
|
|
9156
|
+
type: "SET_SANDBOX_FIELDS",
|
|
9157
|
+
payload: {
|
|
9158
|
+
sandboxParentClientId: null,
|
|
9159
|
+
sandboxClientId: null,
|
|
9160
|
+
sandboxSessionId: null
|
|
9161
|
+
}
|
|
9162
|
+
});
|
|
9163
|
+
agentChatState.setSession(null);
|
|
9164
|
+
agentChatState.clearChangelogEntries();
|
|
9165
|
+
return;
|
|
9166
|
+
}
|
|
9167
|
+
dispatch({
|
|
9168
|
+
type: "SET_SANDBOX_FIELDS",
|
|
9169
|
+
payload: {
|
|
9170
|
+
sandboxParentClientId: stored.sandboxParentClientId,
|
|
9171
|
+
sandboxClientId: stored.sandboxClientId,
|
|
9172
|
+
sandboxSessionId: stored.sandboxSessionId
|
|
9173
|
+
}
|
|
9174
|
+
});
|
|
9175
|
+
agentChatState.setSession(stored.session);
|
|
9176
|
+
});
|
|
9177
|
+
}, [clerkOrgId, agentChatState.setSession, agentChatState.clearChangelogEntries]);
|
|
9178
|
+
(0, import_react27.useEffect)(() => {
|
|
9179
|
+
const scopeId = getSandboxStorageScopeId(
|
|
9180
|
+
clerkOrgId,
|
|
9181
|
+
state.clerkOrgId,
|
|
9182
|
+
publicKey
|
|
9183
|
+
);
|
|
9184
|
+
const session = agentChatState.session;
|
|
9185
|
+
const sessionId = session?.sessionId ?? state.sandboxSessionId;
|
|
9186
|
+
const sandboxClientId = session?.sandboxClientId ?? state.sandboxClientId ?? null;
|
|
9187
|
+
const sourceClientId = session?.sourceClientId ?? state.sandboxParentClientId ?? null;
|
|
9188
|
+
if (!scopeId || !sessionId || !sandboxClientId || !sourceClientId) {
|
|
9189
|
+
return;
|
|
9190
|
+
}
|
|
9191
|
+
const sessionPayload = session ?? {
|
|
9192
|
+
sessionId,
|
|
9193
|
+
sourceClientId,
|
|
9194
|
+
sourceClientName: "",
|
|
9195
|
+
sandboxClientId,
|
|
9196
|
+
sandboxClientName: "",
|
|
9197
|
+
status: "active"
|
|
9198
|
+
};
|
|
9199
|
+
persistSandboxFromSessionInfo(scopeId, sessionPayload, {
|
|
9200
|
+
sandboxParentClientId: sourceClientId
|
|
9201
|
+
});
|
|
9202
|
+
}, [
|
|
9203
|
+
clerkOrgId,
|
|
9204
|
+
publicKey,
|
|
9205
|
+
state.clerkOrgId,
|
|
9206
|
+
state.sandboxParentClientId,
|
|
9207
|
+
state.sandboxClientId,
|
|
9208
|
+
state.sandboxSessionId,
|
|
9209
|
+
agentChatState.session
|
|
9210
|
+
]);
|
|
8953
9211
|
(0, import_react27.useEffect)(() => {
|
|
8954
9212
|
if (typeof window === "undefined") {
|
|
8955
9213
|
return;
|
|
8956
9214
|
}
|
|
9215
|
+
const storedSandbox = resolveSandboxSession(clerkOrgId ?? state.clerkOrgId);
|
|
9216
|
+
if (storedSandbox) {
|
|
9217
|
+
if (!state.sandboxSessionId || state.sandboxSessionId !== storedSandbox.sandboxSessionId) {
|
|
9218
|
+
dispatch({
|
|
9219
|
+
type: "SET_SANDBOX_FIELDS",
|
|
9220
|
+
payload: {
|
|
9221
|
+
sandboxParentClientId: storedSandbox.sandboxParentClientId,
|
|
9222
|
+
sandboxClientId: storedSandbox.sandboxClientId,
|
|
9223
|
+
sandboxSessionId: storedSandbox.sandboxSessionId
|
|
9224
|
+
}
|
|
9225
|
+
});
|
|
9226
|
+
}
|
|
9227
|
+
agentChatState.setSession((prev) => prev ?? storedSandbox.session);
|
|
9228
|
+
}
|
|
8957
9229
|
if (publicKeyRef.current !== publicKey) {
|
|
8958
|
-
dispatch({
|
|
9230
|
+
dispatch({
|
|
9231
|
+
type: "SET_ALL_STATE",
|
|
9232
|
+
payload: storedSandbox ? mergeSandboxIntoState(initialState, clerkOrgId) : initialState
|
|
9233
|
+
});
|
|
8959
9234
|
publicKeyRef.current = publicKey;
|
|
8960
9235
|
}
|
|
8961
9236
|
const client = JSON.parse(
|
|
@@ -8965,8 +9240,7 @@ function AdminProvider({
|
|
|
8965
9240
|
if (client && client.clerkOrgId === clerkOrgId) {
|
|
8966
9241
|
overridePublicKey = client.id || client._id || client.publicKey;
|
|
8967
9242
|
}
|
|
8968
|
-
const
|
|
8969
|
-
const fetchPublicKey = overridePublicKey || hydratedClientId || publicKey;
|
|
9243
|
+
const fetchPublicKey = overridePublicKey || storedSandbox?.sandboxParentClientId || state.sandboxParentClientId || state.client?.id || state.client?._id || state.client?.clientId || state.client?.publicKey || publicKey;
|
|
8970
9244
|
if (!fetchPublicKey) {
|
|
8971
9245
|
setClientLoading(false);
|
|
8972
9246
|
currentFetchingClientRef.current = void 0;
|
|
@@ -8974,7 +9248,7 @@ function AdminProvider({
|
|
|
8974
9248
|
if (currentFetchingClientRef.current === fetchPublicKey) return;
|
|
8975
9249
|
fetchClient(fetchPublicKey, true);
|
|
8976
9250
|
}
|
|
8977
|
-
}, [publicKey]);
|
|
9251
|
+
}, [publicKey, clerkOrgId]);
|
|
8978
9252
|
(0, import_react27.useEffect)(() => {
|
|
8979
9253
|
if (typeof window === "undefined") {
|
|
8980
9254
|
return;
|
|
@@ -9239,8 +9513,8 @@ async function getClientTenantIds({
|
|
|
9239
9513
|
}
|
|
9240
9514
|
|
|
9241
9515
|
// src/public_components/DashboardManager.tsx
|
|
9242
|
-
var
|
|
9243
|
-
var
|
|
9516
|
+
var import_react67 = require("react");
|
|
9517
|
+
var import_react68 = require("@quillsql/react");
|
|
9244
9518
|
|
|
9245
9519
|
// src/Admin.tsx
|
|
9246
9520
|
var import_react31 = require("react");
|
|
@@ -26445,11 +26719,42 @@ function DashboardSelectPopover({
|
|
|
26445
26719
|
}
|
|
26446
26720
|
|
|
26447
26721
|
// src/components/AgentChat/AgentChatPanel.tsx
|
|
26448
|
-
var
|
|
26722
|
+
var import_react65 = require("react");
|
|
26449
26723
|
var import_re_resizable2 = require("re-resizable");
|
|
26450
26724
|
|
|
26451
|
-
// src/
|
|
26725
|
+
// src/hooks/useSandboxSession.ts
|
|
26452
26726
|
var import_react62 = require("react");
|
|
26727
|
+
function useSandboxSession() {
|
|
26728
|
+
const { state } = useAdmin();
|
|
26729
|
+
const { session } = useAgentChat();
|
|
26730
|
+
return (0, import_react62.useMemo)(() => {
|
|
26731
|
+
const sessionId = session?.sessionId ?? state.sandboxSessionId ?? null;
|
|
26732
|
+
const sandboxClientId = session?.sandboxClientId ?? state.sandboxClientId ?? null;
|
|
26733
|
+
const sourceClientId = session?.sourceClientId ?? state.sandboxParentClientId ?? null;
|
|
26734
|
+
const mergedSession = session ?? (sessionId && sandboxClientId && sourceClientId ? {
|
|
26735
|
+
sessionId,
|
|
26736
|
+
sourceClientId,
|
|
26737
|
+
sourceClientName: "",
|
|
26738
|
+
sandboxClientId,
|
|
26739
|
+
sandboxClientName: "",
|
|
26740
|
+
status: "active"
|
|
26741
|
+
} : null);
|
|
26742
|
+
return {
|
|
26743
|
+
sessionId,
|
|
26744
|
+
sandboxClientId,
|
|
26745
|
+
sourceClientId,
|
|
26746
|
+
session: mergedSession
|
|
26747
|
+
};
|
|
26748
|
+
}, [
|
|
26749
|
+
session,
|
|
26750
|
+
state.sandboxSessionId,
|
|
26751
|
+
state.sandboxClientId,
|
|
26752
|
+
state.sandboxParentClientId
|
|
26753
|
+
]);
|
|
26754
|
+
}
|
|
26755
|
+
|
|
26756
|
+
// src/components/AgentChat/AgentChat.tsx
|
|
26757
|
+
var import_react63 = require("react");
|
|
26453
26758
|
|
|
26454
26759
|
// src/components/AgentChat/agentChatMarkdownCss.ts
|
|
26455
26760
|
var AGENT_CHAT_MARKDOWN_STYLE_ID = "quillsql-agent-chat-markdown";
|
|
@@ -26708,9 +27013,9 @@ async function* streamResponseHandler(response) {
|
|
|
26708
27013
|
}
|
|
26709
27014
|
|
|
26710
27015
|
// src/components/AgentChat/AgentChat.tsx
|
|
26711
|
-
var
|
|
27016
|
+
var import_react64 = require("@quillsql/react");
|
|
26712
27017
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
26713
|
-
var MarkdownContent = (0,
|
|
27018
|
+
var MarkdownContent = (0, import_react63.memo)(function MarkdownContent2({
|
|
26714
27019
|
content
|
|
26715
27020
|
}) {
|
|
26716
27021
|
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_react_markdown.default, { remarkPlugins: [import_remark_gfm.default], children: content });
|
|
@@ -26952,7 +27257,7 @@ function ToolCallBlock({ toolCall }) {
|
|
|
26952
27257
|
);
|
|
26953
27258
|
}
|
|
26954
27259
|
function ToolCallResult({ content }) {
|
|
26955
|
-
const [expanded, setExpanded] = (0,
|
|
27260
|
+
const [expanded, setExpanded] = (0, import_react63.useState)(false);
|
|
26956
27261
|
if (!content) return null;
|
|
26957
27262
|
const isLong = content.length > 300;
|
|
26958
27263
|
const displayed = isLong && !expanded ? content.slice(0, 300) + "..." : content;
|
|
@@ -27417,7 +27722,7 @@ function AgentChat({
|
|
|
27417
27722
|
sourceClientId,
|
|
27418
27723
|
getToken
|
|
27419
27724
|
}) {
|
|
27420
|
-
(0,
|
|
27725
|
+
(0, import_react63.useEffect)(() => {
|
|
27421
27726
|
ensureAgentChatMarkdownStylesInjected();
|
|
27422
27727
|
}, []);
|
|
27423
27728
|
const {
|
|
@@ -27431,9 +27736,9 @@ function AgentChat({
|
|
|
27431
27736
|
} = useAgentChat();
|
|
27432
27737
|
const { state, setClient, quillFetchWithToken, refreshClientsList } = useAdmin();
|
|
27433
27738
|
const { schema: allTableData } = useDatabaseSchema();
|
|
27434
|
-
const { allReportsById } = (0,
|
|
27435
|
-
const { data: virtualTables } = (0,
|
|
27436
|
-
const changelogDiffs = (0,
|
|
27739
|
+
const { allReportsById } = (0, import_react64.useAllReports)();
|
|
27740
|
+
const { data: virtualTables } = (0, import_react64.useVirtualTables)();
|
|
27741
|
+
const changelogDiffs = (0, import_react63.useMemo)(
|
|
27437
27742
|
() => changelogEntries.flatMap((entry) => {
|
|
27438
27743
|
const diff = parseDiffEntry(entry);
|
|
27439
27744
|
return diff ? [diff] : [];
|
|
@@ -27464,17 +27769,17 @@ function AgentChat({
|
|
|
27464
27769
|
console.warn("[agent] fetch-changelog-list failed:", err);
|
|
27465
27770
|
}
|
|
27466
27771
|
};
|
|
27467
|
-
const [input, setInput] = (0,
|
|
27468
|
-
const [inputError, setInputError] = (0,
|
|
27469
|
-
const [isLoading, setIsLoading] = (0,
|
|
27470
|
-
const [isPromoting, setIsPromoting] = (0,
|
|
27471
|
-
const [isDiscarding, setIsDiscarding] = (0,
|
|
27472
|
-
const [confirmAction, setConfirmAction] = (0,
|
|
27473
|
-
const containerRef = (0,
|
|
27474
|
-
const textareaRef = (0,
|
|
27475
|
-
const abortControllerRef = (0,
|
|
27476
|
-
const lastScrolled = (0,
|
|
27477
|
-
(0,
|
|
27772
|
+
const [input, setInput] = (0, import_react63.useState)("");
|
|
27773
|
+
const [inputError, setInputError] = (0, import_react63.useState)("");
|
|
27774
|
+
const [isLoading, setIsLoading] = (0, import_react63.useState)(false);
|
|
27775
|
+
const [isPromoting, setIsPromoting] = (0, import_react63.useState)(false);
|
|
27776
|
+
const [isDiscarding, setIsDiscarding] = (0, import_react63.useState)(false);
|
|
27777
|
+
const [confirmAction, setConfirmAction] = (0, import_react63.useState)(null);
|
|
27778
|
+
const containerRef = (0, import_react63.useRef)(null);
|
|
27779
|
+
const textareaRef = (0, import_react63.useRef)(null);
|
|
27780
|
+
const abortControllerRef = (0, import_react63.useRef)(null);
|
|
27781
|
+
const lastScrolled = (0, import_react63.useRef)(Date.now());
|
|
27782
|
+
(0, import_react63.useEffect)(() => {
|
|
27478
27783
|
const run = async () => {
|
|
27479
27784
|
if (!sandboxClientId || !agentSessionId) {
|
|
27480
27785
|
return;
|
|
@@ -27483,7 +27788,7 @@ function AgentChat({
|
|
|
27483
27788
|
};
|
|
27484
27789
|
run();
|
|
27485
27790
|
}, [sandboxClientId, agentSessionId]);
|
|
27486
|
-
(0,
|
|
27791
|
+
(0, import_react63.useEffect)(() => {
|
|
27487
27792
|
const delay2 = Math.max(0, 500 - (Date.now() - lastScrolled.current));
|
|
27488
27793
|
const timer = setTimeout(() => {
|
|
27489
27794
|
const el = containerRef.current;
|
|
@@ -27501,7 +27806,7 @@ function AgentChat({
|
|
|
27501
27806
|
abortControllerRef.current = null;
|
|
27502
27807
|
setIsLoading(false);
|
|
27503
27808
|
};
|
|
27504
|
-
(0,
|
|
27809
|
+
(0, import_react63.useEffect)(() => {
|
|
27505
27810
|
if (!abortControllerRef.current) return;
|
|
27506
27811
|
abortControllerRef.current.abort();
|
|
27507
27812
|
abortControllerRef.current = null;
|
|
@@ -27517,6 +27822,7 @@ function AgentChat({
|
|
|
27517
27822
|
setMessages((prev) => prev.filter((m3) => m3.isWelcome));
|
|
27518
27823
|
setSession(null);
|
|
27519
27824
|
clearChangelogEntries();
|
|
27825
|
+
clearSandboxSession();
|
|
27520
27826
|
const activeClientId = getActiveClientId(state.client);
|
|
27521
27827
|
const sourceId = sourceClientId || state.sandboxParentClientId || activeClientId || null;
|
|
27522
27828
|
if (!sourceId) return;
|
|
@@ -28264,38 +28570,48 @@ function AgentChatPanel() {
|
|
|
28264
28570
|
const {
|
|
28265
28571
|
messages,
|
|
28266
28572
|
setMessages,
|
|
28267
|
-
session,
|
|
28268
28573
|
setSession,
|
|
28269
28574
|
showToolOutputs,
|
|
28270
28575
|
setShowToolOutputs,
|
|
28271
28576
|
clearChangelogEntries
|
|
28272
28577
|
} = useAgentChat();
|
|
28273
|
-
const
|
|
28274
|
-
|
|
28275
|
-
|
|
28578
|
+
const {
|
|
28579
|
+
sessionId,
|
|
28580
|
+
sandboxClientId,
|
|
28581
|
+
sourceClientId,
|
|
28582
|
+
session
|
|
28583
|
+
} = useSandboxSession();
|
|
28584
|
+
const [collapsed, setCollapsed] = (0, import_react65.useState)(false);
|
|
28276
28585
|
const minWidth = typeof window !== "undefined" ? Math.max(DEFAULT_MIN_WIDTH, window.innerWidth * DEFAULT_WIDTH_FRACTION) : 480;
|
|
28277
|
-
const [width, setWidth] = (0,
|
|
28586
|
+
const [width, setWidth] = (0, import_react65.useState)(
|
|
28278
28587
|
() => getInitialWidth(DEFAULT_STORAGE_KEY, minWidth)
|
|
28279
28588
|
);
|
|
28280
28589
|
const maxWidth = typeof window !== "undefined" ? window.innerWidth * DEFAULT_MAX_WIDTH_FRACTION : 1200;
|
|
28281
|
-
(0,
|
|
28590
|
+
(0, import_react65.useEffect)(() => {
|
|
28282
28591
|
if (typeof window === "undefined") return;
|
|
28283
28592
|
window.localStorage.setItem(DEFAULT_STORAGE_KEY, String(Math.round(width)));
|
|
28284
28593
|
}, [width]);
|
|
28285
|
-
const prevClientIdRef = (0,
|
|
28286
|
-
(0,
|
|
28594
|
+
const prevClientIdRef = (0, import_react65.useRef)(clientId);
|
|
28595
|
+
(0, import_react65.useEffect)(() => {
|
|
28287
28596
|
const prev = prevClientIdRef.current;
|
|
28288
28597
|
prevClientIdRef.current = clientId;
|
|
28289
28598
|
if (!prev || !clientId || prev === clientId) return;
|
|
28290
28599
|
if (sandboxClientId && clientId === sandboxClientId) return;
|
|
28291
28600
|
if (sourceClientId && clientId === sourceClientId) return;
|
|
28601
|
+
if (state.sandboxSessionId && (clientId === state.sandboxClientId || clientId === state.sandboxParentClientId)) {
|
|
28602
|
+
return;
|
|
28603
|
+
}
|
|
28292
28604
|
setMessages((prev2) => prev2.filter((m3) => m3.isWelcome));
|
|
28293
28605
|
setSession(null);
|
|
28294
28606
|
clearChangelogEntries();
|
|
28607
|
+
clearSandboxSession();
|
|
28295
28608
|
}, [
|
|
28296
28609
|
clientId,
|
|
28297
28610
|
sandboxClientId,
|
|
28298
28611
|
sourceClientId,
|
|
28612
|
+
state.sandboxSessionId,
|
|
28613
|
+
state.sandboxClientId,
|
|
28614
|
+
state.sandboxParentClientId,
|
|
28299
28615
|
setMessages,
|
|
28300
28616
|
setSession,
|
|
28301
28617
|
clearChangelogEntries
|
|
@@ -28595,9 +28911,9 @@ function AgentChatPanel() {
|
|
|
28595
28911
|
children: clientId && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
28596
28912
|
AgentChat,
|
|
28597
28913
|
{
|
|
28598
|
-
agentSessionId:
|
|
28914
|
+
agentSessionId: sessionId ?? "",
|
|
28599
28915
|
sandboxClientId: sandboxClientId ?? "",
|
|
28600
|
-
sourceClientId:
|
|
28916
|
+
sourceClientId: sourceClientId ?? "",
|
|
28601
28917
|
getToken: async () => await getToken() || ""
|
|
28602
28918
|
}
|
|
28603
28919
|
)
|
|
@@ -28613,13 +28929,13 @@ function AgentChatPanel() {
|
|
|
28613
28929
|
}
|
|
28614
28930
|
|
|
28615
28931
|
// src/components/EnvironmentSwitcherWithModals.tsx
|
|
28616
|
-
var
|
|
28932
|
+
var import_react66 = require("react");
|
|
28617
28933
|
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
28618
28934
|
function EnvironmentSwitcherWithModals() {
|
|
28619
28935
|
const { state, setClient, clientLoading } = useAdmin();
|
|
28620
|
-
const envSelectRef = (0,
|
|
28621
|
-
const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0,
|
|
28622
|
-
const [showCreateEnvironmentModal, setShowCreateEnvironmentModal] = (0,
|
|
28936
|
+
const envSelectRef = (0, import_react66.useRef)(null);
|
|
28937
|
+
const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0, import_react66.useState)(false);
|
|
28938
|
+
const [showCreateEnvironmentModal, setShowCreateEnvironmentModal] = (0, import_react66.useState)(false);
|
|
28623
28939
|
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
|
|
28624
28940
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { ref: envSelectRef, className: "flex flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
28625
28941
|
EnvSelectPopover,
|
|
@@ -28744,14 +29060,14 @@ function DashboardManager({
|
|
|
28744
29060
|
quillFetchWithToken,
|
|
28745
29061
|
eventTracking
|
|
28746
29062
|
} = useAdmin();
|
|
28747
|
-
const parentRef = (0,
|
|
28748
|
-
const dashboardSelectPopoverRef = (0,
|
|
28749
|
-
const [newDashboardModalIsOpen, setNewDashboardModalIsOpen] = (0,
|
|
28750
|
-
const [editFilterModalIsOpen, setEditFilterModalIsOpen] = (0,
|
|
28751
|
-
const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0,
|
|
28752
|
-
const [userFilters, setUserFilters] = (0,
|
|
29063
|
+
const parentRef = (0, import_react67.useRef)(null);
|
|
29064
|
+
const dashboardSelectPopoverRef = (0, import_react67.useRef)(null);
|
|
29065
|
+
const [newDashboardModalIsOpen, setNewDashboardModalIsOpen] = (0, import_react67.useState)(false);
|
|
29066
|
+
const [editFilterModalIsOpen, setEditFilterModalIsOpen] = (0, import_react67.useState)(false);
|
|
29067
|
+
const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0, import_react67.useState)(false);
|
|
29068
|
+
const [userFilters, setUserFilters] = (0, import_react67.useState)([]);
|
|
28753
29069
|
const showCreateEnvironmentModal = state.activeComponent === "CreateEnvironment";
|
|
28754
|
-
const setShowCreateEnvironmentModal = (0,
|
|
29070
|
+
const setShowCreateEnvironmentModal = (0, import_react67.useCallback)(
|
|
28755
29071
|
(show) => {
|
|
28756
29072
|
dispatch({
|
|
28757
29073
|
type: "SET_ACTIVE_COMPONENT",
|
|
@@ -28760,8 +29076,8 @@ function DashboardManager({
|
|
|
28760
29076
|
},
|
|
28761
29077
|
[dispatch]
|
|
28762
29078
|
);
|
|
28763
|
-
const { data: dashboardConfig, reload: reloadDashboard } = (0,
|
|
28764
|
-
const { dashboards, isLoading: dashboardsLoading } = (0,
|
|
29079
|
+
const { data: dashboardConfig, reload: reloadDashboard } = (0, import_react68.useDashboardInternal)(state.selectedDashboard, userFilters);
|
|
29080
|
+
const { dashboards, isLoading: dashboardsLoading } = (0, import_react68.useDashboards)();
|
|
28765
29081
|
useLongLoading(dashboardsLoading, {
|
|
28766
29082
|
origin: "DashboardManager",
|
|
28767
29083
|
loadDescription: "Loading dashboards"
|
|
@@ -28770,7 +29086,7 @@ function DashboardManager({
|
|
|
28770
29086
|
const visibleDashboards = dashboards?.filter(
|
|
28771
29087
|
(dashboard) => dashboard.name !== SAVED_QUERIES_DASHBOARD
|
|
28772
29088
|
) ?? [];
|
|
28773
|
-
(0,
|
|
29089
|
+
(0, import_react67.useEffect)(() => {
|
|
28774
29090
|
if (navigateToVirtualTableManager) {
|
|
28775
29091
|
dispatch({
|
|
28776
29092
|
type: "SET_NAVIGATE_TO_VIRTUAL_TABLE_BUILDER",
|
|
@@ -28780,7 +29096,7 @@ function DashboardManager({
|
|
|
28780
29096
|
console.warn("navigateToDashboardBuilder is not defined");
|
|
28781
29097
|
}
|
|
28782
29098
|
}, []);
|
|
28783
|
-
(0,
|
|
29099
|
+
(0, import_react67.useEffect)(() => {
|
|
28784
29100
|
if (clientLoading || dashboardsLoading) {
|
|
28785
29101
|
return;
|
|
28786
29102
|
}
|
|
@@ -28821,7 +29137,7 @@ function DashboardManager({
|
|
|
28821
29137
|
setSelectedDashboard,
|
|
28822
29138
|
dispatch
|
|
28823
29139
|
]);
|
|
28824
|
-
const handleClickReport = (0,
|
|
29140
|
+
const handleClickReport = (0, import_react67.useCallback)(
|
|
28825
29141
|
(elem) => {
|
|
28826
29142
|
dispatch({ type: "SET_REPORT_ID", payload: elem.id });
|
|
28827
29143
|
dispatch({
|
|
@@ -29527,12 +29843,12 @@ function DashboardManager({
|
|
|
29527
29843
|
}
|
|
29528
29844
|
|
|
29529
29845
|
// src/public_components/VirtualTableManager.tsx
|
|
29530
|
-
var
|
|
29846
|
+
var import_react71 = require("react");
|
|
29531
29847
|
var import_react_dom9 = require("react-dom");
|
|
29532
29848
|
|
|
29533
29849
|
// src/forms/virtual_tables/CreateEditVirtualTable.tsx
|
|
29534
|
-
var
|
|
29535
|
-
var
|
|
29850
|
+
var import_react69 = require("@quillsql/react");
|
|
29851
|
+
var import_react70 = require("react");
|
|
29536
29852
|
|
|
29537
29853
|
// src/modals/TenantFieldModal.tsx
|
|
29538
29854
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
@@ -29740,31 +30056,31 @@ function CreateEditVirtualTable({
|
|
|
29740
30056
|
client
|
|
29741
30057
|
}) {
|
|
29742
30058
|
const name = initialVirtualTable?.name || "";
|
|
29743
|
-
const [editVirtualTableQuery, setEditVirtualTableQuery] = (0,
|
|
30059
|
+
const [editVirtualTableQuery, setEditVirtualTableQuery] = (0, import_react70.useState)(
|
|
29744
30060
|
initialVirtualTable?.viewQuery || ""
|
|
29745
30061
|
);
|
|
29746
|
-
const [ranVirtualTableQuery, setRanVirtualTableQuery] = (0,
|
|
30062
|
+
const [ranVirtualTableQuery, setRanVirtualTableQuery] = (0, import_react70.useState)(
|
|
29747
30063
|
initialVirtualTable?.viewQuery || ""
|
|
29748
30064
|
);
|
|
29749
|
-
const [askAIButtonLoading, setAskAIButtonLoading] = (0,
|
|
29750
|
-
const [aiPrompt, setAIPrompt] = (0,
|
|
29751
|
-
const [virtualTableAddable, setVirtualTableAddable] = (0,
|
|
29752
|
-
const [virtualTableOwners, setVirtualTableOwners] = (0,
|
|
30065
|
+
const [askAIButtonLoading, setAskAIButtonLoading] = (0, import_react70.useState)(false);
|
|
30066
|
+
const [aiPrompt, setAIPrompt] = (0, import_react70.useState)("");
|
|
30067
|
+
const [virtualTableAddable, setVirtualTableAddable] = (0, import_react70.useState)(false);
|
|
30068
|
+
const [virtualTableOwners, setVirtualTableOwners] = (0, import_react70.useState)(
|
|
29753
30069
|
initialVirtualTable?.ownerTenantFields ?? client.ownerTenantFields?.filter((f) => f !== SINGLE_TENANT) ?? []
|
|
29754
30070
|
);
|
|
29755
|
-
const [failingTenant, setFailingTenant] = (0,
|
|
30071
|
+
const [failingTenant, setFailingTenant] = (0, import_react70.useState)(
|
|
29756
30072
|
void 0
|
|
29757
30073
|
);
|
|
29758
|
-
const [failingTenantErrorType, setFailingTenantErrorType] = (0,
|
|
29759
|
-
const [isLoading, setIsLoading] = (0,
|
|
29760
|
-
const [tableSearchQuery, setTableSearchQuery] = (0,
|
|
29761
|
-
const [editorMounted, setEditorMounted] = (0,
|
|
29762
|
-
const [displayedTableData, setDisplayedTableData] = (0,
|
|
29763
|
-
const [errorInfo, setErrorInfo] = (0,
|
|
29764
|
-
const [tableData, setTableData] = (0,
|
|
29765
|
-
const [runningQuery, setRunningQuery] = (0,
|
|
30074
|
+
const [failingTenantErrorType, setFailingTenantErrorType] = (0, import_react70.useState)(void 0);
|
|
30075
|
+
const [isLoading, setIsLoading] = (0, import_react70.useState)(false);
|
|
30076
|
+
const [tableSearchQuery, setTableSearchQuery] = (0, import_react70.useState)("");
|
|
30077
|
+
const [editorMounted, setEditorMounted] = (0, import_react70.useState)(false);
|
|
30078
|
+
const [displayedTableData, setDisplayedTableData] = (0, import_react70.useState)(allTableData);
|
|
30079
|
+
const [errorInfo, setErrorInfo] = (0, import_react70.useState)({ show: false, message: "" });
|
|
30080
|
+
const [tableData, setTableData] = (0, import_react70.useState)(void 0);
|
|
30081
|
+
const [runningQuery, setRunningQuery] = (0, import_react70.useState)(false);
|
|
29766
30082
|
const { state, getToken, quillFetchWithToken, eventTracking } = useAdmin();
|
|
29767
|
-
const containerRef = (0,
|
|
30083
|
+
const containerRef = (0, import_react70.useRef)(null);
|
|
29768
30084
|
const addEditProcessVirtualTable = async (override = false) => {
|
|
29769
30085
|
const missingTenantField = virtualTableOwners?.find(
|
|
29770
30086
|
(field) => tableData && !tableData.fields.find(
|
|
@@ -29809,13 +30125,13 @@ function CreateEditVirtualTable({
|
|
|
29809
30125
|
override
|
|
29810
30126
|
);
|
|
29811
30127
|
};
|
|
29812
|
-
const dashboardOwnerTenants = (0,
|
|
30128
|
+
const dashboardOwnerTenants = (0, import_react70.useMemo)(() => {
|
|
29813
30129
|
return client.allTenantTypes?.filter((t2) => client.ownerTenantFields?.includes(t2.tenantField)).filter((t2) => t2.tenantField !== SINGLE_TENANT);
|
|
29814
30130
|
}, [client.ownerTenantFields, client.allTenantTypes]);
|
|
29815
|
-
(0,
|
|
30131
|
+
(0, import_react70.useEffect)(() => {
|
|
29816
30132
|
setDisplayedTableData(allTableData);
|
|
29817
30133
|
}, [allTableData]);
|
|
29818
|
-
(0,
|
|
30134
|
+
(0, import_react70.useEffect)(() => {
|
|
29819
30135
|
if (initialVirtualTable) {
|
|
29820
30136
|
eventTracking?.addBreadcrumb?.({
|
|
29821
30137
|
message: "Initial Query Run on CreateEditVirtualTable load",
|
|
@@ -30035,7 +30351,7 @@ function CreateEditVirtualTable({
|
|
|
30035
30351
|
}
|
|
30036
30352
|
),
|
|
30037
30353
|
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
30038
|
-
|
|
30354
|
+
import_react69.SchemaListComponent,
|
|
30039
30355
|
{
|
|
30040
30356
|
schema: displayedTableData,
|
|
30041
30357
|
theme: state.theme,
|
|
@@ -30212,7 +30528,7 @@ function CreateEditVirtualTable({
|
|
|
30212
30528
|
}
|
|
30213
30529
|
) : null,
|
|
30214
30530
|
(tableData || runningQuery) && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
30215
|
-
|
|
30531
|
+
import_react69.Table,
|
|
30216
30532
|
{
|
|
30217
30533
|
containerStyle: {
|
|
30218
30534
|
minHeight: 260,
|
|
@@ -30352,7 +30668,7 @@ ${duplicateColumns.join("\n")}`
|
|
|
30352
30668
|
}
|
|
30353
30669
|
|
|
30354
30670
|
// src/utils/dataEditor.tsx
|
|
30355
|
-
var editVirtualTable = async (editName, editViewQuery, editViewId, customFieldInfo, state, ownerTenantFields, getToken, noCustomerField) => {
|
|
30671
|
+
var editVirtualTable = async (editName, editViewQuery, editViewId, description, customFieldInfo, state, ownerTenantFields, getToken, noCustomerField) => {
|
|
30356
30672
|
if (!editName.length) {
|
|
30357
30673
|
alert("Please enter a table name.");
|
|
30358
30674
|
return;
|
|
@@ -30378,6 +30694,7 @@ var editVirtualTable = async (editName, editViewQuery, editViewId, customFieldIn
|
|
|
30378
30694
|
name: editName,
|
|
30379
30695
|
customFieldInfo,
|
|
30380
30696
|
id: editViewId,
|
|
30697
|
+
description,
|
|
30381
30698
|
clientId: state.client._id,
|
|
30382
30699
|
runQueryConfig: { getColumns: true },
|
|
30383
30700
|
databaseType: state.client.databaseType,
|
|
@@ -30388,7 +30705,7 @@ var editVirtualTable = async (editName, editViewQuery, editViewId, customFieldIn
|
|
|
30388
30705
|
getToken
|
|
30389
30706
|
});
|
|
30390
30707
|
};
|
|
30391
|
-
var addVirtualTable = async (name, editViewQuery, customFieldInfo, state, ownerTenantFields, getToken, noCustomerField) => {
|
|
30708
|
+
var addVirtualTable = async (name, editViewQuery, description, customFieldInfo, state, ownerTenantFields, getToken, noCustomerField) => {
|
|
30392
30709
|
if (!name.length) {
|
|
30393
30710
|
alert("Please enter a table name.");
|
|
30394
30711
|
return;
|
|
@@ -30409,6 +30726,7 @@ var addVirtualTable = async (name, editViewQuery, customFieldInfo, state, ownerT
|
|
|
30409
30726
|
preQueries: [editViewQuery.replace(/;/, "")],
|
|
30410
30727
|
customFieldInfo,
|
|
30411
30728
|
name,
|
|
30729
|
+
description,
|
|
30412
30730
|
clientId: state.client._id,
|
|
30413
30731
|
runQueryConfig: { getColumns: true },
|
|
30414
30732
|
databaseType: state.client.databaseType,
|
|
@@ -30441,7 +30759,7 @@ var deleteVirtualTable = async (id, state, getToken) => {
|
|
|
30441
30759
|
};
|
|
30442
30760
|
|
|
30443
30761
|
// src/public_components/VirtualTableManager.tsx
|
|
30444
|
-
var
|
|
30762
|
+
var import_react72 = require("@quillsql/react");
|
|
30445
30763
|
var import_prism_react_renderer5 = require("prism-react-renderer");
|
|
30446
30764
|
|
|
30447
30765
|
// src/components/EmptyVirtualTablesComponent.tsx
|
|
@@ -30556,7 +30874,7 @@ function EmptyVirtualTablesComponent({
|
|
|
30556
30874
|
|
|
30557
30875
|
// src/public_components/VirtualTableManager.tsx
|
|
30558
30876
|
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
30559
|
-
var
|
|
30877
|
+
var import_react73 = require("react");
|
|
30560
30878
|
function VirtualTableManager({
|
|
30561
30879
|
containerStyle,
|
|
30562
30880
|
virtualTable
|
|
@@ -30567,28 +30885,29 @@ function VirtualTableManager({
|
|
|
30567
30885
|
reloadAll,
|
|
30568
30886
|
refreshSome,
|
|
30569
30887
|
loadingTables
|
|
30570
|
-
} = (0,
|
|
30571
|
-
const { reloadFilteredReports } = (0,
|
|
30572
|
-
const [editModalIsOpen, setEditModalIsOpen] = (0,
|
|
30573
|
-
const [editQueryView, setEditQueryView] = (0,
|
|
30574
|
-
const [editVirtualTableId, setEditVirtualTableId] = (0,
|
|
30575
|
-
const [editName, setEditName] = (0,
|
|
30576
|
-
const [
|
|
30577
|
-
const [
|
|
30888
|
+
} = (0, import_react72.useVirtualTables)();
|
|
30889
|
+
const { reloadFilteredReports } = (0, import_react72.useReports)();
|
|
30890
|
+
const [editModalIsOpen, setEditModalIsOpen] = (0, import_react71.useState)(false);
|
|
30891
|
+
const [editQueryView, setEditQueryView] = (0, import_react71.useState)(false);
|
|
30892
|
+
const [editVirtualTableId, setEditVirtualTableId] = (0, import_react71.useState)("");
|
|
30893
|
+
const [editName, setEditName] = (0, import_react71.useState)("");
|
|
30894
|
+
const [editDescription, setEditDescription] = (0, import_react71.useState)("");
|
|
30895
|
+
const [editError, setEditError] = (0, import_react71.useState)();
|
|
30896
|
+
const [editVirtualTableQuery, setEditVirtualTableQuery] = (0, import_react71.useState)("");
|
|
30578
30897
|
const [
|
|
30579
30898
|
editVirtualTableOwnerTenantFields,
|
|
30580
30899
|
setEditVirtualTableOwnerTenantFields
|
|
30581
|
-
] = (0,
|
|
30582
|
-
const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0,
|
|
30583
|
-
const [referencedTablesMap, setReferencedTablesMap] = (0,
|
|
30584
|
-
const [referenceFiltersMap, setReferenceFiltersMap] = (0,
|
|
30900
|
+
] = (0, import_react71.useState)([]);
|
|
30901
|
+
const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0, import_react71.useState)(false);
|
|
30902
|
+
const [referencedTablesMap, setReferencedTablesMap] = (0, import_react71.useState)({});
|
|
30903
|
+
const [referenceFiltersMap, setReferenceFiltersMap] = (0, import_react71.useState)({});
|
|
30585
30904
|
const { schema: allTableData, isLoading: schemaIsLoading } = useDatabaseSchema();
|
|
30586
|
-
const [customFieldInfo, setCustomFieldInfo] = (0,
|
|
30587
|
-
const [initialVirtualTable, setInitialVirtualTable] = (0,
|
|
30588
|
-
const [submittingVirtualTable, setSubmittingVirtualTable] = (0,
|
|
30589
|
-
const [noCustomerField, setNoCustomerField] = (0,
|
|
30590
|
-
const parentRef = (0,
|
|
30591
|
-
const envHeaderRef = (0,
|
|
30905
|
+
const [customFieldInfo, setCustomFieldInfo] = (0, import_react71.useState)(void 0);
|
|
30906
|
+
const [initialVirtualTable, setInitialVirtualTable] = (0, import_react71.useState)(void 0);
|
|
30907
|
+
const [submittingVirtualTable, setSubmittingVirtualTable] = (0, import_react71.useState)(false);
|
|
30908
|
+
const [noCustomerField, setNoCustomerField] = (0, import_react71.useState)(false);
|
|
30909
|
+
const parentRef = (0, import_react71.useRef)(null);
|
|
30910
|
+
const envHeaderRef = (0, import_react71.useRef)(null);
|
|
30592
30911
|
const {
|
|
30593
30912
|
state,
|
|
30594
30913
|
dispatch,
|
|
@@ -30598,7 +30917,7 @@ function VirtualTableManager({
|
|
|
30598
30917
|
eventTracking
|
|
30599
30918
|
} = useAdmin();
|
|
30600
30919
|
const showCreateEnvironmentModal = state.activeComponent === "CreateEnvironment";
|
|
30601
|
-
const setShowCreateEnvironmentModal = (0,
|
|
30920
|
+
const setShowCreateEnvironmentModal = (0, import_react71.useCallback)(
|
|
30602
30921
|
(show) => {
|
|
30603
30922
|
dispatch({
|
|
30604
30923
|
type: "SET_ACTIVE_COMPONENT",
|
|
@@ -30610,11 +30929,13 @@ function VirtualTableManager({
|
|
|
30610
30929
|
const closeEditModal = () => {
|
|
30611
30930
|
setEditModalIsOpen(false);
|
|
30612
30931
|
setEditName("");
|
|
30932
|
+
setEditDescription("");
|
|
30613
30933
|
setEditVirtualTableQuery("");
|
|
30614
30934
|
setCustomFieldInfo(void 0);
|
|
30615
30935
|
};
|
|
30616
30936
|
const clickTableCell = (table, suppressModal = false) => {
|
|
30617
30937
|
setEditName(table.name);
|
|
30938
|
+
setEditDescription(table.description ?? "");
|
|
30618
30939
|
setEditVirtualTableQuery(table.viewQuery);
|
|
30619
30940
|
setEditVirtualTableOwnerTenantFields(table.ownerTenantFields ?? []);
|
|
30620
30941
|
setEditVirtualTableId(table._id);
|
|
@@ -30673,13 +30994,13 @@ function VirtualTableManager({
|
|
|
30673
30994
|
setReferencedTablesMap(data.data.referencedTablesMap);
|
|
30674
30995
|
setReferenceFiltersMap(data.data.referenceFiltersMap);
|
|
30675
30996
|
};
|
|
30676
|
-
(0,
|
|
30997
|
+
(0, import_react71.useEffect)(() => {
|
|
30677
30998
|
if (state.client.id) {
|
|
30678
30999
|
getReferencedTablesMap();
|
|
30679
31000
|
}
|
|
30680
31001
|
}, [state.client.id]);
|
|
30681
31002
|
const showVirtualTableEditorPortal = editQueryView && !clientLoading && !areTablesLoading && !state.databaseTypeMismatch.show && typeof document !== "undefined";
|
|
30682
|
-
(0,
|
|
31003
|
+
(0, import_react71.useEffect)(() => {
|
|
30683
31004
|
if (!showVirtualTableEditorPortal) return;
|
|
30684
31005
|
const prevOverflow = document.body.style.overflow;
|
|
30685
31006
|
document.body.style.overflow = "hidden";
|
|
@@ -30687,7 +31008,7 @@ function VirtualTableManager({
|
|
|
30687
31008
|
document.body.style.overflow = prevOverflow;
|
|
30688
31009
|
};
|
|
30689
31010
|
}, [showVirtualTableEditorPortal]);
|
|
30690
|
-
const handleModalSubmit = async (submitRequest, query, ownerTenantFields, name, id, columns, customFieldInfo2, override) => {
|
|
31011
|
+
const handleModalSubmit = async (submitRequest, query, ownerTenantFields, name, description, id, columns, customFieldInfo2, override) => {
|
|
30691
31012
|
if (override) {
|
|
30692
31013
|
setNoCustomerField(true);
|
|
30693
31014
|
} else {
|
|
@@ -30727,6 +31048,7 @@ ${duplicateColumns.join("\n")}`
|
|
|
30727
31048
|
submitResponse = await addVirtualTable(
|
|
30728
31049
|
trimmedName,
|
|
30729
31050
|
query,
|
|
31051
|
+
description,
|
|
30730
31052
|
customFieldInfo2,
|
|
30731
31053
|
state,
|
|
30732
31054
|
ownerTenantFields,
|
|
@@ -30763,43 +31085,45 @@ ${errorColumns.length > 1 ? "They" : "It"} will be deleted off of the referencin
|
|
|
30763
31085
|
return;
|
|
30764
31086
|
}
|
|
30765
31087
|
} else {
|
|
30766
|
-
|
|
30767
|
-
|
|
30768
|
-
|
|
30769
|
-
if (referenceFiltersMap?.[prevTableName]) {
|
|
30770
|
-
const referencedFilterInfo = referenceFiltersMap[prevTableName].map((info) => {
|
|
30771
|
-
return `${info.dashboardName} - ${info.filterField}`;
|
|
31088
|
+
if (prevTableName !== trimmedName) {
|
|
31089
|
+
const referencedTableInfo = referencedTablesMap[prevTableName].map((info) => {
|
|
31090
|
+
return `"${info.reportName}" on the "${info.dashboardName}" dashboard`;
|
|
30772
31091
|
});
|
|
30773
|
-
|
|
30774
|
-
|
|
31092
|
+
if (referenceFiltersMap?.[prevTableName]) {
|
|
31093
|
+
const referencedFilterInfo = referenceFiltersMap[prevTableName].map((info) => {
|
|
31094
|
+
return `${info.dashboardName} - ${info.filterField}`;
|
|
31095
|
+
});
|
|
31096
|
+
alert(
|
|
31097
|
+
`Warning
|
|
30775
31098
|
|
|
30776
31099
|
'${prevTableName}' is referenced in the following dashboard filters:
|
|
30777
31100
|
|
|
30778
31101
|
${referencedFilterInfo.join(
|
|
30779
|
-
|
|
30780
|
-
|
|
31102
|
+
"\n"
|
|
31103
|
+
)}
|
|
30781
31104
|
|
|
30782
31105
|
Please delete those filters before renaming this virtual table.`
|
|
30783
|
-
|
|
30784
|
-
|
|
30785
|
-
|
|
30786
|
-
|
|
31106
|
+
);
|
|
31107
|
+
return;
|
|
31108
|
+
}
|
|
31109
|
+
if (table && table.broken) {
|
|
31110
|
+
alert(
|
|
31111
|
+
"Error\n\nThis virtual table has an invalid query. Please fix the query before renaming it."
|
|
31112
|
+
);
|
|
31113
|
+
return;
|
|
31114
|
+
}
|
|
30787
31115
|
alert(
|
|
30788
|
-
|
|
30789
|
-
);
|
|
30790
|
-
return;
|
|
30791
|
-
}
|
|
30792
|
-
alert(
|
|
30793
|
-
`Warning
|
|
31116
|
+
`Warning
|
|
30794
31117
|
|
|
30795
31118
|
'${prevTableName}' is referenced by:
|
|
30796
31119
|
${referencedTableInfo.join(
|
|
30797
|
-
|
|
30798
|
-
|
|
31120
|
+
"\n"
|
|
31121
|
+
)}
|
|
30799
31122
|
|
|
30800
31123
|
Please delete those charts before renaming this virtual table.`
|
|
30801
|
-
|
|
30802
|
-
|
|
31124
|
+
);
|
|
31125
|
+
return;
|
|
31126
|
+
}
|
|
30803
31127
|
}
|
|
30804
31128
|
}
|
|
30805
31129
|
if (!trimmedName) {
|
|
@@ -30829,6 +31153,7 @@ ${duplicateColumns.join("\n")}`
|
|
|
30829
31153
|
trimmedName,
|
|
30830
31154
|
query,
|
|
30831
31155
|
id,
|
|
31156
|
+
description,
|
|
30832
31157
|
customFieldInfo2,
|
|
30833
31158
|
state,
|
|
30834
31159
|
ownerTenantFields,
|
|
@@ -30930,7 +31255,7 @@ Please delete those filters before deleting this table.`
|
|
|
30930
31255
|
await reloadTables();
|
|
30931
31256
|
return response;
|
|
30932
31257
|
};
|
|
30933
|
-
const handleEditAddView = async (request, query, ownerTenantFields, name, id, columns, override) => {
|
|
31258
|
+
const handleEditAddView = async (request, query, ownerTenantFields, name, description, id, columns, override) => {
|
|
30934
31259
|
switch (request) {
|
|
30935
31260
|
case "edit":
|
|
30936
31261
|
await handleModalSubmit(
|
|
@@ -30938,6 +31263,7 @@ Please delete those filters before deleting this table.`
|
|
|
30938
31263
|
query,
|
|
30939
31264
|
ownerTenantFields,
|
|
30940
31265
|
name,
|
|
31266
|
+
description,
|
|
30941
31267
|
id,
|
|
30942
31268
|
columns,
|
|
30943
31269
|
void 0,
|
|
@@ -30951,6 +31277,7 @@ Please delete those filters before deleting this table.`
|
|
|
30951
31277
|
ownerTenantFields,
|
|
30952
31278
|
void 0,
|
|
30953
31279
|
void 0,
|
|
31280
|
+
void 0,
|
|
30954
31281
|
columns,
|
|
30955
31282
|
void 0,
|
|
30956
31283
|
override
|
|
@@ -30992,6 +31319,7 @@ Please delete those filters before deleting this table.`
|
|
|
30992
31319
|
query,
|
|
30993
31320
|
ownerTenantFields,
|
|
30994
31321
|
name,
|
|
31322
|
+
void 0,
|
|
30995
31323
|
id,
|
|
30996
31324
|
columns,
|
|
30997
31325
|
override
|
|
@@ -31116,6 +31444,7 @@ Please delete those filters before deleting this table.`
|
|
|
31116
31444
|
{
|
|
31117
31445
|
onClick: () => {
|
|
31118
31446
|
setEditName("");
|
|
31447
|
+
setEditDescription("");
|
|
31119
31448
|
setEditVirtualTableQuery("");
|
|
31120
31449
|
setEditVirtualTableId("");
|
|
31121
31450
|
setInitialVirtualTable(void 0);
|
|
@@ -31664,6 +31993,7 @@ Please delete those filters before deleting this table.`
|
|
|
31664
31993
|
EditAddViewModal,
|
|
31665
31994
|
{
|
|
31666
31995
|
viewName: editName,
|
|
31996
|
+
viewDescription: editDescription,
|
|
31667
31997
|
viewQuery: editVirtualTableQuery,
|
|
31668
31998
|
viewId: editVirtualTableId,
|
|
31669
31999
|
viewOwnerTenantFields: editVirtualTableOwnerTenantFields,
|
|
@@ -31671,7 +32001,7 @@ Please delete those filters before deleting this table.`
|
|
|
31671
32001
|
customFieldInfo,
|
|
31672
32002
|
closeEditModal,
|
|
31673
32003
|
error: editError,
|
|
31674
|
-
submit: async (submitRequest, query, ownerTenantFields, name, id, columns, customFieldInfo2, noCustomerField2) => {
|
|
32004
|
+
submit: async (submitRequest, query, ownerTenantFields, name, description, id, columns, customFieldInfo2, noCustomerField2) => {
|
|
31675
32005
|
if (submitRequest !== "delete") {
|
|
31676
32006
|
setSubmittingVirtualTable(true);
|
|
31677
32007
|
}
|
|
@@ -31680,6 +32010,7 @@ Please delete those filters before deleting this table.`
|
|
|
31680
32010
|
query,
|
|
31681
32011
|
ownerTenantFields,
|
|
31682
32012
|
name,
|
|
32013
|
+
description,
|
|
31683
32014
|
id,
|
|
31684
32015
|
columns,
|
|
31685
32016
|
customFieldInfo2,
|
|
@@ -31725,6 +32056,7 @@ Please delete those filters before deleting this table.`
|
|
|
31725
32056
|
}
|
|
31726
32057
|
function EditAddViewModal({
|
|
31727
32058
|
viewName,
|
|
32059
|
+
viewDescription,
|
|
31728
32060
|
viewQuery,
|
|
31729
32061
|
viewOwnerTenantFields,
|
|
31730
32062
|
viewId,
|
|
@@ -31739,38 +32071,42 @@ function EditAddViewModal({
|
|
|
31739
32071
|
isLoading,
|
|
31740
32072
|
noCustomerField
|
|
31741
32073
|
}) {
|
|
31742
|
-
const [name, setName] = (0,
|
|
31743
|
-
const [
|
|
31744
|
-
const [
|
|
31745
|
-
const [
|
|
32074
|
+
const [name, setName] = (0, import_react71.useState)(viewName);
|
|
32075
|
+
const [description, setDescription] = (0, import_react71.useState)(viewDescription);
|
|
32076
|
+
const [query, setQuery] = (0, import_react71.useState)(viewQuery);
|
|
32077
|
+
const [id, setId] = (0, import_react71.useState)(viewId);
|
|
32078
|
+
const [useCustomField, setUseCustomField] = (0, import_react71.useState)(
|
|
31746
32079
|
customFieldInfo ? true : false
|
|
31747
32080
|
);
|
|
31748
|
-
const [customFieldType, setCustomFieldType] = (0,
|
|
32081
|
+
const [customFieldType, setCustomFieldType] = (0, import_react71.useState)(
|
|
31749
32082
|
customFieldInfo ? customFieldInfo.type : "eav"
|
|
31750
32083
|
);
|
|
31751
|
-
const [customFieldQuery, setCustomFieldQuery] = (0,
|
|
32084
|
+
const [customFieldQuery, setCustomFieldQuery] = (0, import_react71.useState)(
|
|
31752
32085
|
customFieldInfo ? customFieldInfo.query : ""
|
|
31753
32086
|
);
|
|
31754
|
-
const [runQueryButtonLoading, setRunQueryButtonLoading] = (0,
|
|
31755
|
-
const [tableData, setTableData] = (0,
|
|
31756
|
-
const [errorInfo, setErrorInfo] = (0,
|
|
31757
|
-
const clientIsSingleTenant = (0,
|
|
32087
|
+
const [runQueryButtonLoading, setRunQueryButtonLoading] = (0, import_react71.useState)(false);
|
|
32088
|
+
const [tableData, setTableData] = (0, import_react71.useState)(void 0);
|
|
32089
|
+
const [errorInfo, setErrorInfo] = (0, import_react71.useState)({ show: false, message: "" });
|
|
32090
|
+
const clientIsSingleTenant = (0, import_react71.useMemo)(
|
|
31758
32091
|
() => onlySingleDatabaseTenant(state.client),
|
|
31759
32092
|
[state.client]
|
|
31760
32093
|
);
|
|
31761
32094
|
const { getToken, eventTracking } = useAdmin();
|
|
31762
|
-
(0,
|
|
32095
|
+
(0, import_react71.useEffect)(() => {
|
|
31763
32096
|
setCustomFieldQuery(customFieldInfo?.query || "");
|
|
31764
32097
|
setCustomFieldType(customFieldInfo?.type || "eav");
|
|
31765
32098
|
setUseCustomField(customFieldInfo ? true : false);
|
|
31766
32099
|
}, [customFieldInfo]);
|
|
31767
|
-
(0,
|
|
32100
|
+
(0, import_react71.useEffect)(() => {
|
|
31768
32101
|
setName(viewName);
|
|
31769
32102
|
}, [viewName]);
|
|
31770
|
-
(0,
|
|
32103
|
+
(0, import_react71.useEffect)(() => {
|
|
32104
|
+
setDescription(viewDescription);
|
|
32105
|
+
}, [viewDescription]);
|
|
32106
|
+
(0, import_react71.useEffect)(() => {
|
|
31771
32107
|
setQuery(viewQuery);
|
|
31772
32108
|
}, [viewQuery]);
|
|
31773
|
-
(0,
|
|
32109
|
+
(0, import_react71.useEffect)(() => {
|
|
31774
32110
|
setId(viewId);
|
|
31775
32111
|
}, [viewId]);
|
|
31776
32112
|
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
@@ -31784,6 +32120,7 @@ function EditAddViewModal({
|
|
|
31784
32120
|
setTableData(void 0);
|
|
31785
32121
|
setErrorInfo({ show: false, message: "" });
|
|
31786
32122
|
setName("");
|
|
32123
|
+
setDescription("");
|
|
31787
32124
|
closeEditModal();
|
|
31788
32125
|
},
|
|
31789
32126
|
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
|
|
@@ -31830,21 +32167,47 @@ function EditAddViewModal({
|
|
|
31830
32167
|
]
|
|
31831
32168
|
}
|
|
31832
32169
|
),
|
|
31833
|
-
/* @__PURE__ */ (0, import_jsx_runtime71.
|
|
31834
|
-
|
|
31835
|
-
|
|
31836
|
-
|
|
31837
|
-
|
|
31838
|
-
|
|
31839
|
-
|
|
32170
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
|
|
32171
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InputLabel, { children: "Name" }),
|
|
32172
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
32173
|
+
TextInputPrimitive_default,
|
|
32174
|
+
{
|
|
32175
|
+
placeholder: "Enter view display name...",
|
|
32176
|
+
onChange: (e2) => setName(e2.target.value),
|
|
32177
|
+
value: name ? name : ""
|
|
32178
|
+
}
|
|
32179
|
+
)
|
|
32180
|
+
] }),
|
|
32181
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { style: { height: 12 } }),
|
|
32182
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
|
|
32183
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InputLabel, { children: "Description" }),
|
|
32184
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
32185
|
+
"textarea",
|
|
32186
|
+
{
|
|
32187
|
+
placeholder: "Enter description...",
|
|
32188
|
+
onChange: (e2) => setDescription(e2.target.value),
|
|
32189
|
+
value: description ?? "",
|
|
32190
|
+
rows: 3,
|
|
32191
|
+
style: {
|
|
32192
|
+
width: "100%",
|
|
32193
|
+
minHeight: 88,
|
|
32194
|
+
resize: "vertical",
|
|
32195
|
+
padding: "10px 12px",
|
|
32196
|
+
fontWeight: "medium",
|
|
32197
|
+
backgroundColor: state.theme?.backgroundColor || "white",
|
|
32198
|
+
color: state.theme?.primaryTextColor,
|
|
32199
|
+
borderWidth: "1px",
|
|
32200
|
+
borderColor: state.theme?.borderColor || "#E7E7E7",
|
|
32201
|
+
borderStyle: "solid",
|
|
32202
|
+
borderRadius: "6px",
|
|
32203
|
+
fontSize: 14,
|
|
32204
|
+
fontFamily: state.theme?.fontFamily,
|
|
32205
|
+
boxSizing: "border-box"
|
|
31840
32206
|
}
|
|
31841
|
-
}
|
|
31842
|
-
|
|
31843
|
-
|
|
31844
|
-
|
|
31845
|
-
}
|
|
31846
|
-
),
|
|
31847
|
-
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("br", {}),
|
|
32207
|
+
}
|
|
32208
|
+
)
|
|
32209
|
+
] }),
|
|
32210
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { style: { height: 16 } }),
|
|
31848
32211
|
viewOwnerTenantFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
|
|
31849
32212
|
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InputLabel, { tooltip: "Dashboards may only query from virtual tables that share an owner with them. Virtual tables are required to return each of their owners' foreign keys as part of the query.", children: "Owners" }),
|
|
31850
32213
|
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
@@ -31879,7 +32242,7 @@ function EditAddViewModal({
|
|
|
31879
32242
|
))
|
|
31880
32243
|
}
|
|
31881
32244
|
),
|
|
31882
|
-
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("
|
|
32245
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { style: { height: 16 } })
|
|
31883
32246
|
] }),
|
|
31884
32247
|
error && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
|
|
31885
32248
|
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("h3", { style: { color: "#CA3A31" }, children: error }),
|
|
@@ -31907,7 +32270,7 @@ function EditAddViewModal({
|
|
|
31907
32270
|
position: "relative"
|
|
31908
32271
|
},
|
|
31909
32272
|
children: [
|
|
31910
|
-
tokens.map((line, i2) => /* @__PURE__ */ (0,
|
|
32273
|
+
tokens.map((line, i2) => /* @__PURE__ */ (0, import_react73.createElement)(
|
|
31911
32274
|
"div",
|
|
31912
32275
|
{
|
|
31913
32276
|
...getLineProps({ line }),
|
|
@@ -32094,7 +32457,7 @@ function EditAddViewModal({
|
|
|
32094
32457
|
}
|
|
32095
32458
|
),
|
|
32096
32459
|
!errorInfo.show && tableData && !runQueryButtonLoading && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
32097
|
-
|
|
32460
|
+
import_react72.Table,
|
|
32098
32461
|
{
|
|
32099
32462
|
rows: tableData.rows,
|
|
32100
32463
|
columns: tableData.fields,
|
|
@@ -32155,7 +32518,14 @@ function EditAddViewModal({
|
|
|
32155
32518
|
viewName && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
32156
32519
|
MemoizedButton,
|
|
32157
32520
|
{
|
|
32158
|
-
onClick: () => submit(
|
|
32521
|
+
onClick: () => submit(
|
|
32522
|
+
"delete",
|
|
32523
|
+
query,
|
|
32524
|
+
viewOwnerTenantFields,
|
|
32525
|
+
name,
|
|
32526
|
+
description,
|
|
32527
|
+
id
|
|
32528
|
+
),
|
|
32159
32529
|
label: "Delete",
|
|
32160
32530
|
style: { color: "red", backgroundColor: "white" }
|
|
32161
32531
|
}
|
|
@@ -32236,6 +32606,7 @@ function EditAddViewModal({
|
|
|
32236
32606
|
query,
|
|
32237
32607
|
viewOwnerTenantFields,
|
|
32238
32608
|
name,
|
|
32609
|
+
description,
|
|
32239
32610
|
id,
|
|
32240
32611
|
void 0,
|
|
32241
32612
|
useCustomField ? {
|
|
@@ -32283,7 +32654,9 @@ function EditAddViewModal({
|
|
|
32283
32654
|
SecondaryButtonPrimitive,
|
|
32284
32655
|
TextInputPrimitive,
|
|
32285
32656
|
VirtualTableManager,
|
|
32657
|
+
clearQuillSandboxStorage,
|
|
32286
32658
|
exportChatAsMarkdown,
|
|
32287
32659
|
useAdmin,
|
|
32288
|
-
useAgentChat
|
|
32660
|
+
useAgentChat,
|
|
32661
|
+
useSandboxSession
|
|
32289
32662
|
});
|