feat(plugins): add AI tools and consent-gated data access
This commit is contained in:
71 files changed
+4613
-129
No files matched your search
@@ -217,3 +217,22 @@ describe("AI schema selector visibility", () => {
|
||||
expect(resolveAiDatabaseTarget(queryTab("app", "public"), postgres)).toEqual({ database: "app", schema: "public" });
|
||||
});
|
||||
});
|
||||
|
||||
describe("Plugin AI context", () => {
|
||||
beforeEach(() => vi.clearAllMocks());
|
||||
|
||||
it.each([false, true])("skips database metadata even with stale table context: %s", async (withTable) => {
|
||||
const connection: ConnectionConfig = { ...postgresConnection(), db_type: "plugin", plugin_id: "sample.plugin" };
|
||||
const tab = { ...queryTab("stale-db", "public"), connectionId: connection.id, tableMeta: withTable ? { schema: "public", tableName: "stale_table", columns: [] } : undefined };
|
||||
const context = await buildAiContext(tab, connection, { mentionedTables: [{ schema: "public", table: "stale_mention" }], sqlFiles: [{ name: "notes.sql", content: "SELECT 1" }] });
|
||||
expect(context.databaseType).toBe("plugin");
|
||||
expect(context.connectionName).toBe(connection.name);
|
||||
expect(context.tables).toEqual([]);
|
||||
expect(context.truncated).toBe(false);
|
||||
expect(context.sqlFiles).toEqual([{ name: "notes.sql", content: "SELECT 1" }]);
|
||||
expect(apiMock.listTables).not.toHaveBeenCalled();
|
||||
expect(apiMock.getColumns).not.toHaveBeenCalled();
|
||||
expect(apiMock.listIndexes).not.toHaveBeenCalled();
|
||||
expect(apiMock.listForeignKeys).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user