feat(meilisearch): add workspace, key, and task management
This commit is contained in:
48 files changed
+3984
-18
No files matched your search
@@ -167,4 +167,39 @@ describe("connectionStore Elasticsearch open/expand", () => {
|
||||
.sort(),
|
||||
).toEqual(["orders", "users"]);
|
||||
});
|
||||
|
||||
it("uses the shared Meilisearch index-list method for the Meilisearch tree", async () => {
|
||||
const elasticsearchListIndices = vi.fn().mockResolvedValue(["wrong-index"]);
|
||||
const meilisearchListIndexes = vi.fn().mockResolvedValue(["movies", "books"]);
|
||||
const checkConnectionHealth = vi.fn().mockResolvedValue(undefined);
|
||||
|
||||
vi.doMock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => false }));
|
||||
vi.doMock("@/lib/backend/api", () => ({
|
||||
checkConnectionHealth,
|
||||
elasticsearchListIndices,
|
||||
meilisearchListIndexes,
|
||||
deleteSchemaCachePrefix: vi.fn().mockResolvedValue(undefined),
|
||||
loadSchemaCache: vi.fn().mockResolvedValue(null),
|
||||
saveSchemaCache: vi.fn().mockResolvedValue(undefined),
|
||||
saveConnections: vi.fn().mockResolvedValue(undefined),
|
||||
saveSidebarLayout: vi.fn().mockResolvedValue(undefined),
|
||||
}));
|
||||
|
||||
const { useConnectionStore } = await import("@/stores/connectionStore");
|
||||
const store = useConnectionStore();
|
||||
store.addEphemeralConnection({ ...esConnection(), id: "meili-1", name: "Meilisearch", db_type: "meilisearch", port: 7700 });
|
||||
seedConnectionNode(store, "meili-1", "Meilisearch");
|
||||
|
||||
await store.loadElasticsearchIndices("meili-1");
|
||||
|
||||
expect(meilisearchListIndexes).toHaveBeenCalledWith("meili-1");
|
||||
expect(elasticsearchListIndices).not.toHaveBeenCalled();
|
||||
expect(
|
||||
store.treeNodes
|
||||
.find((node) => node.id === "meili-1")
|
||||
?.children?.filter((node) => node.type === "elasticsearch-index")
|
||||
.map((node) => node.label)
|
||||
.sort(),
|
||||
).toEqual(["books", "movies"]);
|
||||
});
|
||||
});
|
||||
@@ -4504,26 +4504,64 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
try {
|
||||
await ensureConnected(connectionId);
|
||||
load = reclaimTreeNodeLoad(load, node);
|
||||
const indices = await withMetadataLoadTimeout(connectionId, api.elasticsearchListIndices(connectionId), "Elasticsearch indices");
|
||||
const isMeilisearch = getConfig(connectionId)?.db_type === "meilisearch";
|
||||
const indices = await withMetadataLoadTimeout(connectionId, isMeilisearch ? api.meilisearchListIndexes(connectionId) : api.elasticsearchListIndices(connectionId), isMeilisearch ? "Meilisearch indexes" : "Elasticsearch indices");
|
||||
const targetNode = treeNodeLoadTarget(load);
|
||||
if (!targetNode) return;
|
||||
setChildren(
|
||||
targetNode,
|
||||
withSavedSqlRoot(
|
||||
connectionId,
|
||||
sortSidebarNames(indices).map((index) => ({
|
||||
id: `${connectionId}:__collection:${index}`,
|
||||
label: index,
|
||||
type: "elasticsearch-index" as const,
|
||||
connectionId,
|
||||
database: "default",
|
||||
isExpanded: false,
|
||||
})),
|
||||
[
|
||||
...sortSidebarNames(indices).map((index) => ({
|
||||
id: `${connectionId}:__collection:${index}`,
|
||||
label: index,
|
||||
type: "elasticsearch-index" as const,
|
||||
connectionId,
|
||||
database: "default",
|
||||
isExpanded: false,
|
||||
})),
|
||||
...(isMeilisearch
|
||||
? [
|
||||
{
|
||||
id: `${connectionId}:__meilisearch_system`,
|
||||
label: "meilisearch.systemManagement",
|
||||
type: "meilisearch-system" as const,
|
||||
connectionId,
|
||||
database: "default",
|
||||
isExpanded: false,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
targetNode,
|
||||
),
|
||||
);
|
||||
targetNode.isExpanded = true;
|
||||
} catch (e) {
|
||||
const targetNode = treeNodeLoadTarget(load);
|
||||
if (targetNode && getConfig(connectionId)?.db_type === "meilisearch") {
|
||||
const existingChildren = (targetNode.children || []).filter((child) => child.type !== "meilisearch-system");
|
||||
setChildren(
|
||||
targetNode,
|
||||
withSavedSqlRoot(
|
||||
connectionId,
|
||||
[
|
||||
...existingChildren,
|
||||
{
|
||||
id: `${connectionId}:__meilisearch_system`,
|
||||
label: "meilisearch.systemManagement",
|
||||
type: "meilisearch-system",
|
||||
connectionId,
|
||||
database: "default",
|
||||
isExpanded: false,
|
||||
},
|
||||
],
|
||||
targetNode,
|
||||
),
|
||||
);
|
||||
targetNode.isExpanded = true;
|
||||
}
|
||||
recordMetadataLoadError(connectionId, e, load);
|
||||
throw e;
|
||||
} finally {
|
||||
|
||||
@@ -1744,6 +1744,9 @@ export const useQueryStore = defineStore("query", () => {
|
||||
}
|
||||
|
||||
function findTabByIdentity(connectionId: string, database: string, title: string, mode: QueryTab["mode"], schema?: string, catalog?: string) {
|
||||
if (mode === "meilisearch-system") {
|
||||
return tabs.value.find((tab) => tab.connectionId === connectionId && tab.mode === mode);
|
||||
}
|
||||
return tabs.value.find((tab) => tab.connectionId === connectionId && tab.database === database && tab.title === title && tab.mode === mode && (tab.schema || "") === (schema || "") && (tab.catalog || "") === (catalog || ""));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user