Skip to content

Commit e6e21c8

Browse files
committed
chore: lint
1 parent 123e5ff commit e6e21c8

File tree

11 files changed

+206
-181
lines changed

11 files changed

+206
-181
lines changed

web/components/templates/hql/QueryEditor.tsx

Lines changed: 64 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,73 +15,79 @@ interface QueryEditorProps {
1515
currentQuery: { id?: string; name: string; sql: string };
1616
}
1717

18-
const QueryEditor: React.FC<QueryEditorProps> = React.memo(({
19-
sql,
20-
onSqlChange,
21-
onExecute,
22-
onSave,
23-
editorRef,
24-
latestQueryRef,
25-
currentQuery,
26-
}) => {
18+
const QueryEditor: React.FC<QueryEditorProps> = React.memo(
19+
({
20+
sql,
21+
onSqlChange,
22+
onExecute,
23+
onSave,
24+
editorRef,
25+
latestQueryRef,
26+
currentQuery,
27+
}) => {
28+
const handleEditorMount = useCallback(
29+
async (
30+
editor: MonacoEditor.IStandaloneCodeEditor,
31+
monacoInstance: typeof monaco,
32+
) => {
33+
editorRef.current = editor;
34+
const model = editor.getModel();
35+
if (!model) return;
2736

28-
const handleEditorMount = useCallback(
29-
async (editor: MonacoEditor.IStandaloneCodeEditor, monacoInstance: typeof monaco) => {
30-
editorRef.current = editor;
31-
const model = editor.getModel();
32-
if (!model) return;
33-
34-
validateSqlQuery(sql, model, monacoInstance);
35-
36-
editor.onDidChangeModelContent(() => {
3737
validateSqlQuery(sql, model, monacoInstance);
38-
});
3938

40-
editor.addCommand(
41-
monacoInstance.KeyMod.CtrlCmd | monacoInstance.KeyCode.Enter,
42-
() => {
43-
onExecute(latestQueryRef.current.sql);
44-
}
45-
);
39+
editor.onDidChangeModelContent(() => {
40+
validateSqlQuery(sql, model, monacoInstance);
41+
});
4642

47-
editor.addCommand(
48-
monacoInstance.KeyMod.CtrlCmd | monacoInstance.KeyCode.KeyS,
49-
() => {
50-
onSave(latestQueryRef.current);
51-
}
52-
);
53-
},
54-
[sql, editorRef, latestQueryRef, onExecute, onSave]
55-
);
43+
editor.addCommand(
44+
monacoInstance.KeyMod.CtrlCmd | monacoInstance.KeyCode.Enter,
45+
() => {
46+
onExecute(latestQueryRef.current.sql);
47+
},
48+
);
5649

57-
const handleEditorChange = useCallback(
58-
(value: string | undefined) => {
59-
const newValue = value ?? "";
60-
onSqlChange(newValue);
50+
editor.addCommand(
51+
monacoInstance.KeyMod.CtrlCmd | monacoInstance.KeyCode.KeyS,
52+
() => {
53+
onSave(latestQueryRef.current);
54+
},
55+
);
56+
},
57+
[sql, editorRef, latestQueryRef, onExecute, onSave],
58+
);
6159

62-
if (value && editorRef.current) {
63-
const model = editorRef.current.getModel();
64-
if (model && typeof window !== 'undefined' && (window as any).monaco) {
65-
validateSqlQuery(value, model, (window as any).monaco);
60+
const handleEditorChange = useCallback(
61+
(value: string | undefined) => {
62+
const newValue = value ?? "";
63+
onSqlChange(newValue);
64+
65+
if (value && editorRef.current) {
66+
const model = editorRef.current.getModel();
67+
if (
68+
model &&
69+
typeof window !== "undefined" &&
70+
(window as any).monaco
71+
) {
72+
validateSqlQuery(value, model, (window as any).monaco);
73+
}
6674
}
67-
}
68-
},
69-
[onSqlChange, editorRef]
70-
);
75+
},
76+
[onSqlChange, editorRef],
77+
);
7178

72-
return (
73-
<Editor
74-
defaultLanguage="sql"
75-
defaultValue={sql}
76-
options={MONACO_EDITOR_OPTIONS}
77-
onMount={handleEditorMount}
78-
onChange={handleEditorChange}
79-
/>
80-
);
81-
});
79+
return (
80+
<Editor
81+
defaultLanguage="sql"
82+
defaultValue={sql}
83+
options={MONACO_EDITOR_OPTIONS}
84+
onMount={handleEditorMount}
85+
onChange={handleEditorChange}
86+
/>
87+
);
88+
},
89+
);
8290

8391
QueryEditor.displayName = "QueryEditor";
8492

8593
export default QueryEditor;
86-
87-

web/components/templates/hql/TableList.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,3 @@ const TableList: React.FC<TableListProps> = React.memo(({ tables }) => {
6868
TableList.displayName = "TableList";
6969

7070
export default TableList;
71-
72-

web/components/templates/hql/config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,3 @@ export const SQL_VALIDATION_ERROR_MESSAGE =
4646
export const QUERY_RESULT_LIMIT = 100;
4747

4848
export const HQL_WAITLIST_FORM_URL = "https://forms.gle/YXYkFz9Zaa7fWF2v7";
49-
50-

web/components/templates/hql/constants.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,11 @@ export const CLICKHOUSE_KEYWORDS = [
7373

7474
export const ALL_KEYWORDS = [...SQL_KEYWORDS, ...CLICKHOUSE_KEYWORDS];
7575

76-
export const getTableNames = (
77-
schemas: TableSchema[],
78-
) => Array.from(new Set(schemas?.map((d) => d.table_name) ?? []));
76+
export const getTableNames = (schemas: TableSchema[]) =>
77+
Array.from(new Set(schemas?.map((d) => d.table_name) ?? []));
7978

80-
export const getTableNamesSet = (
81-
schemas: TableSchema[],
82-
) => new Set(getTableNames(schemas));
79+
export const getTableNamesSet = (schemas: TableSchema[]) =>
80+
new Set(getTableNames(schemas));
8381

8482
export function parseSqlAndFindTableNameAndAliases(sql: string) {
8583
const regex =
@@ -109,16 +107,26 @@ export const createExecuteQueryMutation = (
109107
setQueryLoading: (loading: boolean) => void,
110108
) => {
111109
return {
112-
mutationFn: async (sql: string): Promise<{ error?: { error: string }; data?: { data: components["schemas"]["ExecuteSqlResponse"] } }> => {
110+
mutationFn: async (
111+
sql: string,
112+
): Promise<{
113+
error?: { error: string };
114+
data?: { data: components["schemas"]["ExecuteSqlResponse"] };
115+
}> => {
113116
setQueryLoading(true);
114117
const response = await $JAWN_API.POST("/v1/helicone-sql/execute", {
115118
body: {
116119
sql: sql,
117120
},
118121
});
119-
return normalizeJawnResponse<components["schemas"]["ExecuteSqlResponse"]>(response);
122+
return normalizeJawnResponse<components["schemas"]["ExecuteSqlResponse"]>(
123+
response,
124+
);
120125
},
121-
onSuccess: (data: { error?: { error: string }; data?: { data: components["schemas"]["ExecuteSqlResponse"] } }) => {
126+
onSuccess: (data: {
127+
error?: { error: string };
128+
data?: { data: components["schemas"]["ExecuteSqlResponse"] };
129+
}) => {
122130
setQueryLoading(false);
123131
if (data.error || !data.data?.data) {
124132
setQueryError(data.error?.error || "Query execution failed");

web/components/templates/hql/hooks/useAgentHandlers.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,3 @@ export function useAgentHandlers({
6060
});
6161
}, [currentQuery.sql, handleExecuteQueryAsync, setToolHandler]);
6262
}
63-
64-

0 commit comments

Comments
 (0)