Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(deps): update dependency emittery to v2 (#20883)

renovate[bot]6f9d6ed3f70b
diff --git a/frontend/package.json b/frontend/package.json
index 0554c051db..b05dd741f4 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -51,7 +51,7 @@
"dompurify": "3.4.11",
"downloadjs": "1.4.7",
"elkjs": "^0.11.0",
- "emittery": "^1.2.0",
+ "emittery": "^2.0.0",
"events": "^3.3.0",
"file-saver": "^2.0.5",
"highlight.js": "11.11.1",
diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml
index 8833243eab..7cf0cbdd09 100644
--- a/frontend/pnpm-lock.yaml
+++ b/frontend/pnpm-lock.yaml
@@ -92,8 +92,8 @@ importers:
specifier: ^0.11.0
version: 0.11.1
emittery:
- specifier: ^1.2.0
- version: 1.2.1
+ specifier: ^2.0.0
+ version: 2.0.0
events:
specifier: ^3.3.0
version: 3.3.0
@@ -2695,9 +2695,9 @@ packages:
resolution: {integrity: sha512-zxxR9k+rx5ktMwT/FwyLdPCrq7xN6e4VGGHH8hA01vVYKjTFik7nHOxBnAYtrgYUB1RpAiLvA1/U2YraWxyKKg==}
- resolution: {integrity: sha512-sFz64DCRjirhwHLxofFqxYQm6DCp6o0Ix7jwKQvuCHPn4GMRZNuBZyLPu9Ccmk/QSCAMZt6FOUqA8JZCQvA9fw==}
- engines: {node: '>=14.16'}
+ resolution: {integrity: sha512-FLtgn/CGBXiX3ZtPAm5q4LWWepHChOt55J9u01WFu3dyap2U7IwptlrqoE1COR/kxwdy/DOxIBALSxIW449I1g==}
+ engines: {node: '>=22'}
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
@@ -6724,7 +6724,7 @@ snapshots:
diff --git a/frontend/src/plugins/ai/react/context.tsx b/frontend/src/plugins/ai/react/context.tsx
index e4da4499ac..e040b6ffa9 100644
--- a/frontend/src/plugins/ai/react/context.tsx
+++ b/frontend/src/plugins/ai/react/context.tsx
@@ -230,7 +230,7 @@ export function AIContextProvider({ children }: { children: ReactNode }) {
const offNewConversation = events.on(
"new-conversation",
- async ({ input }) => {
+ async ({ data: { input } }) => {
const tab = getCurrentSQLEditorTab();
if (!tab) return;
const conn = tab.connection;
@@ -258,27 +258,30 @@ export function AIContextProvider({ children }: { children: ReactNode }) {
}
);
- const offSendChat = events.on("send-chat", async ({ content, newChat }) => {
- const tab = getCurrentSQLEditorTab();
- if (!tab) return;
- const conn = tab.connection;
- await useConversationStore
- .getState()
- .fetchConversationListByConnection(conn);
- if (newChat) {
- setShowHistoryDialog(false);
- const c = await useConversationStore
+ const offSendChat = events.on(
+ "send-chat",
+ async ({ data: { content, newChat } }) => {
+ const tab = getCurrentSQLEditorTab();
+ if (!tab) return;
+ const conn = tab.connection;
+ await useConversationStore
.getState()
- .createConversation({ name: "", ...conn });
- setSelectedIdByConn((prev) => ({
- ...prev,
- [`${conn.instance}/${conn.database}`]: c.id,
- }));
+ .fetchConversationListByConnection(conn);
+ if (newChat) {
+ setShowHistoryDialog(false);
+ const c = await useConversationStore
+ .getState()
+ .createConversation({ name: "", ...conn });
+ setSelectedIdByConn((prev) => ({
+ ...prev,
+ [`${conn.instance}/${conn.database}`]: c.id,
+ }));
+ }
+ requestAnimationFrame(() => {
+ setPendingSendChat({ content });
+ });
}
- requestAnimationFrame(() => {
- setPendingSendChat({ content });
- });
- });
+ );
return () => {
offNewConversation();
diff --git a/frontend/src/react/components/SchemaDiagram/Canvas/composables/useSetCenter.tsx b/frontend/src/react/components/SchemaDiagram/Canvas/composables/useSetCenter.tsx
index 8f9e1e2c61..b200051b0c 100644
--- a/frontend/src/react/components/SchemaDiagram/Canvas/composables/useSetCenter.tsx
+++ b/frontend/src/react/components/SchemaDiagram/Canvas/composables/useSetCenter.tsx
@@ -24,7 +24,7 @@ export const useSetCenter = (canvas: Element | null) => {
stateRef.current = { canvas, zoom, setZoom, setPosition, rectOfTable };
useEffect(() => {
- const off = events.on("set-center", (e) => {
+ const off = events.on("set-center", ({ data: e }) => {
const {
canvas: el,
zoom: currentZoom,
diff --git a/frontend/src/react/components/SchemaDiagram/SchemaDiagram.tsx b/frontend/src/react/components/SchemaDiagram/SchemaDiagram.tsx
index 43ad7796d2..0cebe77dab 100644
--- a/frontend/src/react/components/SchemaDiagram/SchemaDiagram.tsx
+++ b/frontend/src/react/components/SchemaDiagram/SchemaDiagram.tsx
@@ -175,7 +175,7 @@ function Body({ databaseName, onEditTable, onEditColumn }: BodyProps) {
// External `edit-table` / `edit-column` events bridge to caller props.
useEffect(() => {
if (!onEditTable) return;
- const off = events.on("edit-table", ({ schema, table }) => {
+ const off = events.on("edit-table", ({ data: { schema, table } }) => {
onEditTable(schema, table);
});
return () => {
@@ -187,7 +187,7 @@ function Body({ databaseName, onEditTable, onEditColumn }: BodyProps) {
if (!onEditColumn) return;
const off = events.on(
"edit-column",
- ({ schema, table, column, target }) => {
+ ({ data: { schema, table, column, target } }) => {
onEditColumn(schema, table, column, target);
}
);
diff --git a/frontend/src/react/components/sql-editor/Panels/Panels.tsx b/frontend/src/react/components/sql-editor/Panels/Panels.tsx
index 7d3247b264..c1361588f5 100644
--- a/frontend/src/react/components/sql-editor/Panels/Panels.tsx
+++ b/frontend/src/react/components/sql-editor/Panels/Panels.tsx
@@ -107,24 +107,27 @@ export function Panels() {
// event bus is a module-level singleton so we don't need to traverse
// a Vue provide chain to access it.
useEffect(() => {
- const off = aiContextEvents.on("run-statement", async ({ statement }) => {
- const tabsState = getSQLEditorTabsState();
- const t = tabsState.tabsById.get(tabsState.currentTabId);
- if (!t) return;
- updateViewState({ view: "CODE" });
- await nextAnimationFrame();
- const connection = t.connection;
- const database = await useAppStore
- .getState()
- .getOrFetchDatabaseByName(connection.database);
- void execute({
- connection,
- statement,
- engine: getInstanceResource(database).engine,
- explain: false,
- selection: t.editorState.selection,
- });
- });
+ const off = aiContextEvents.on(
+ "run-statement",
+ async ({ data: { statement } }) => {
+ const tabsState = getSQLEditorTabsState();
+ const t = tabsState.tabsById.get(tabsState.currentTabId);
+ if (!t) return;
+ updateViewState({ view: "CODE" });
+ await nextAnimationFrame();
+ const connection = t.connection;
+ const database = await useAppStore
+ .getState()
+ .getOrFetchDatabaseByName(connection.database);
+ void execute({
+ connection,
+ statement,
+ engine: getInstanceResource(database).engine,
+ explain: false,
+ selection: t.editorState.selection,
+ });
+ }
+ );
return () => {
off();
};
diff --git a/frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsx b/frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsx
index 2d1f4f622f..710c24ea2a 100644
--- a/frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsx
+++ b/frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsx
@@ -218,7 +218,11 @@ export function BatchQuerySelect({
useEffect(() => {
const unsubscribe = resultTabEvents.on(
"close-tab",
- ({ index, action }: { index: number; action: CloseTabAction }) => {
+ ({
+ data: { index, action },
+ }: {
+ data: { index: number; action: CloseTabAction };
+ }) => {
const max = items.length - 1;
switch (action) {
case "CLOSE":
diff --git a/frontend/src/react/components/sql-editor/SQLEditorHomePage.tsx b/frontend/src/react/components/sql-editor/SQLEditorHomePage.tsx
index 86606fe2fc..99a5d917dc 100644
--- a/frontend/src/react/components/sql-editor/SQLEditorHomePage.tsx
+++ b/frontend/src/react/components/sql-editor/SQLEditorHomePage.tsx
@@ -101,7 +101,7 @@ export function SQLEditorHomePage() {
useEffect(() => {
const off = sqlEditorEvents.on(
"alter-schema",
- async ({ databaseName, schema, table }) => {
+ async ({ data: { databaseName, schema, table } }) => {
const database = await useAppStore
.getState()
.getOrFetchDatabaseByName(databaseName);
@@ -147,17 +147,20 @@ export function SQLEditorHomePage() {
// pendingInsertAtCaret. The React `<SQLEditor>` reads the same Pinia
// ref and inserts at the cursor.
useEffect(() => {
- const off = sqlEditorEvents.on("insert-at-caret", ({ content }) => {
- const tabsState = getSQLEditorTabsState();
- const t = tabsState.tabsById.get(tabsState.currentTabId);
- if (!t) return;
- tabsState.updateTab(t.id, {
- viewState: { ...(t.viewState ?? {}), view: "CODE" },
- });
- requestAnimationFrame(() => {
- setPendingInsertAtCaret(content);
- });
- });
+ const off = sqlEditorEvents.on(
+ "insert-at-caret",
+ ({ data: { content } }) => {
+ const tabsState = getSQLEditorTabsState();
+ const t = tabsState.tabsById.get(tabsState.currentTabId);
+ if (!t) return;
+ tabsState.updateTab(t.id, {
+ viewState: { ...(t.viewState ?? {}), view: "CODE" },
+ });
+ requestAnimationFrame(() => {
+ setPendingInsertAtCaret(content);
+ });
+ }
+ );
return () => {
off();
};
diff --git a/frontend/src/react/components/sql-editor/SQLEditorRouteShell.tsx b/frontend/src/react/components/sql-editor/SQLEditorRouteShell.tsx
index 8fcb2f4ece..c92145af70 100644
--- a/frontend/src/react/components/sql-editor/SQLEditorRouteShell.tsx
+++ b/frontend/src/react/components/sql-editor/SQLEditorRouteShell.tsx
@@ -542,10 +542,13 @@ export function SQLEditorRouteShell() {
// ---- sidebar tab restore (after project context ready) ----------------
useEffect(() => {
- const off = sqlEditorEvents.on("project-context-ready", ({ project }) => {
- if (!project) return;
- requestAnimationFrame(() => restoreLastVisitedSidebarTab());
- });
+ const off = sqlEditorEvents.on(
+ "project-context-ready",
+ ({ data: { project } }) => {
+ if (!project) return;
+ requestAnimationFrame(() => restoreLastVisitedSidebarTab());
+ }
+ );
return () => {
off();
};
diff --git a/frontend/src/react/components/sql-editor/SheetTree.tsx b/frontend/src/react/components/sql-editor/SheetTree.tsx
index 751980bcc9..b2c7313470 100644
--- a/frontend/src/react/components/sql-editor/SheetTree.tsx
+++ b/frontend/src/react/components/sql-editor/SheetTree.tsx
@@ -316,7 +316,7 @@ export function SheetTree({
// the input. Again keyed on the stable `.key`, not the object identity.
useEffect(() => {
if (!editingKey) return;
- const unsub = events.on("on-built", ({ viewMode }) => {
+ const unsub = events.on("on-built", ({ data: { viewMode } }) => {
if (viewMode !== view) return;
const input = document.getElementById(
`sheet-input-${editingKey}`
diff --git a/frontend/src/react/components/sql-editor/StandardPanel/EditorMain.tsx b/frontend/src/react/components/sql-editor/StandardPanel/EditorMain.tsx
index 168eaf976a..0bbfe0e423 100644
--- a/frontend/src/react/components/sql-editor/StandardPanel/EditorMain.tsx
+++ b/frontend/src/react/components/sql-editor/StandardPanel/EditorMain.tsx
@@ -80,7 +80,7 @@ export function EditorMain({ onChangeConnection }: EditorMainProps) {
useEffect(() => {
const off = sqlEditorEvents.on(
"execute-sql",
- async ({ connection, statement, batchQueryContext }) => {
+ async ({ data: { connection, statement, batchQueryContext } }) => {
const database = await useAppStore
.getState()
.getOrFetchDatabaseByName(connection.database);
diff --git a/frontend/src/react/components/sql-editor/StandardPanel/SQLEditor.tsx b/frontend/src/react/components/sql-editor/StandardPanel/SQLEditor.tsx
index bff7865c6e..6b7d53313c 100644
--- a/frontend/src/react/components/sql-editor/StandardPanel/SQLEditor.tsx
+++ b/frontend/src/react/components/sql-editor/StandardPanel/SQLEditor.tsx
@@ -372,7 +372,7 @@ export function SQLEditor({ onExecute }: SQLEditorProps) {
});
const offSetSelection = sqlEditorEvents.on(
"set-editor-selection",
- (selection: IRange) => {
+ ({ data: selection }: { data: IRange }) => {
const editor = activeSQLEditorRef.value;
if (!editor) return;
editor.setSelection(selection);
@@ -382,7 +382,7 @@ export function SQLEditor({ onExecute }: SQLEditorProps) {
);
const offAppend = sqlEditorEvents.on(
"append-editor-content",
- ({ content: appended, select }) => {
+ ({ data: { content: appended, select } }) => {
const editor = activeSQLEditorRef.value;
if (!editor) return;
const tabsState = getSQLEditorTabsState();
diff --git a/frontend/src/react/components/sql-editor/TabItem/Label.tsx b/frontend/src/react/components/sql-editor/TabItem/Label.tsx
index fad0199caa..f03c7eddb7 100644
--- a/frontend/src/react/components/sql-editor/TabItem/Label.tsx
+++ b/frontend/src/react/components/sql-editor/TabItem/Label.tsx
@@ -89,7 +89,7 @@ export function Label({ tab }: Props) {
// `readonly` + `tab.id` are the only closure values we care about; the
// other helpers are referentially stable via the Pinia store singletons.
useEffect(() => {
- const unsubscribe = tabListEvents.on("rename-tab", (payload) => {
+ const unsubscribe = tabListEvents.on("rename-tab", ({ data: payload }) => {
if (payload.tab.id !== tab.id) return;
getSQLEditorTabsState().setCurrentTabId(tab.id);
if (readonly) return;
diff --git a/frontend/src/react/components/sql-editor/TabList.tsx b/frontend/src/react/components/sql-editor/TabList.tsx
index 714e841457..791f7bf1e0 100644
--- a/frontend/src/react/components/sql-editor/TabList.tsx
+++ b/frontend/src/react/components/sql-editor/TabList.tsx
@@ -219,7 +219,7 @@ export function TabList() {
useEffect(() => {
const unsubscribe = tabListEvents.on(
"close-tab",
- async ({ tab, index, action }) => {
+ async ({ data: { tab, index, action } }) => {
const tabsState = getSQLEditorTabsState();
const snapshot = tabsState.openTmpTabList
.map((persisted) => tabsState.tabsById.get(persisted.id))
diff --git a/frontend/src/react/hooks/useSQLEditorEvent.ts b/frontend/src/react/hooks/useSQLEditorEvent.ts
index d759794a0e..a779010b04 100644
--- a/frontend/src/react/hooks/useSQLEditorEvent.ts
+++ b/frontend/src/react/hooks/useSQLEditorEvent.ts
@@ -12,7 +12,7 @@ export function useSQLEditorEvent<E extends keyof SQLEditorEvents>(
handlerRef.current = handler;
useEffect(() => {
- const unsubscribe = sqlEditorEvents.on(event, (data) => {
+ const unsubscribe = sqlEditorEvents.on(event, ({ data }) => {
handlerRef.current(data as SQLEditorEvents[E]);
});
return unsubscribe;
diff --git a/frontend/src/react/stores/sqlEditor/webTerminal-service.ts b/frontend/src/react/stores/sqlEditor/webTerminal-service.ts
index 050f5edc52..80ee888498 100644
--- a/frontend/src/react/stores/sqlEditor/webTerminal-service.ts
+++ b/frontend/src/react/stores/sqlEditor/webTerminal-service.ts
@@ -82,8 +82,8 @@ const createStreamingQueryController = () => {
let status: "CONNECTED" | "DISCONNECTED" = "DISCONNECTED";
const events: StreamingQueryController["events"] = new Emittery();
const input$ = fromEventPattern<SQLEditorQueryParams>(
- (handler) => events.on("query", handler),
- (handler) => events.off("query", handler)
+ (handler) => events.on("query", ({ data }) => handler(data)),
+ (_handler, unsubscribe) => unsubscribe()
);
// Holds the active WebSocket reference. Only written, never read —
@@ -100,7 +100,7 @@ const createStreamingQueryController = () => {
},
};
- events.on("query", async (params) => {
+ events.on("query", async ({ data: params }) => {
const request = mapRequest(params);
console.debug("query", request);
@@ -235,7 +235,7 @@ const bindStreamingLogic = (session: WebTerminalQuerySession) => {
return list[list.length - 1];
};
- session.controller.events.on("query", (input) => {
+ session.controller.events.on("query", ({ data: input }) => {
session.timer.start();
const tail = activeItem();
if (!tail) return;
@@ -247,7 +247,7 @@ const bindStreamingLogic = (session: WebTerminalQuerySession) => {
});
});
- session.controller.events.on("result", (resultSet) => {
+ session.controller.events.on("result", ({ data: resultSet }) => {
// The tab may have been closed mid-flight; disposeWebTerminalQuerySession
// dropped our session entry, but the WebSocket is still bound and this
// handler is still subscribed. Bail before pushing a new query item,
diff --git a/frontend/src/views/sql-editor/events.test.ts b/frontend/src/views/sql-editor/events.test.ts
index 91aca11ce2..3399b6b3dd 100644
--- a/frontend/src/views/sql-editor/events.test.ts
+++ b/frontend/src/views/sql-editor/events.test.ts
@@ -16,4 +16,19 @@ describe("sqlEditorEvents", () => {
expect(handler).toHaveBeenCalledTimes(1);
unsubscribe();
});
+
+ test("listeners receive the emittery v2 {name, data} envelope", async () => {
+ const handler = vi.fn();
+ const unsubscribe = sqlEditorEvents.on("insert-at-caret", handler);
+
+ await sqlEditorEvents.emit("insert-at-caret", { content: "SELECT 1" });
+
+ // emittery v2 wraps the payload in an envelope; every listener in the
+ // app destructures `data`. If this shape changes again, callsites break.
+ expect(handler).toHaveBeenCalledWith({
+ name: "insert-at-caret",
+ data: { content: "SELECT 1" },
+ });
+ unsubscribe();
+ });
});