From 97a9c00619dab77ba1c733cbf44b928c654fdb65 Mon Sep 17 00:00:00 2001 From: Jaromir Hamala Date: Fri, 27 Sep 2024 15:44:31 +0200 Subject: [PATCH 1/7] experiment: support for Notice responses --- .../src/scenes/Editor/Monaco/index.tsx | 14 ++++++ .../Notification/NoticeNotification/index.tsx | 48 +++++++++++++++++++ .../Notifications/Notification/index.tsx | 3 ++ packages/web-console/src/store/Query/types.ts | 1 + packages/web-console/src/utils/questdb.ts | 26 +++++++++- 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 packages/web-console/src/scenes/Notifications/Notification/NoticeNotification/index.tsx diff --git a/packages/web-console/src/scenes/Editor/Monaco/index.tsx b/packages/web-console/src/scenes/Editor/Monaco/index.tsx index c34caf58b..343d5586d 100644 --- a/packages/web-console/src/scenes/Editor/Monaco/index.tsx +++ b/packages/web-console/src/scenes/Editor/Monaco/index.tsx @@ -322,6 +322,20 @@ const MonacoEditor = () => { eventBus.publish(EventType.MSG_QUERY_SCHEMA) } + if (result.type === QuestDB.Type.NOTICE) { + dispatch( + actions.query.addNotification({ + content: ( + + {result.notice}: {result.query} + + ), + type: NotificationType.NOTICE, + }), + ) + eventBus.publish(EventType.MSG_QUERY_SCHEMA) + } + if (result.type === QuestDB.Type.DQL) { setLastExecutedQuery(request.query) dispatch( diff --git a/packages/web-console/src/scenes/Notifications/Notification/NoticeNotification/index.tsx b/packages/web-console/src/scenes/Notifications/Notification/NoticeNotification/index.tsx new file mode 100644 index 000000000..e2a9c463f --- /dev/null +++ b/packages/web-console/src/scenes/Notifications/Notification/NoticeNotification/index.tsx @@ -0,0 +1,48 @@ +/******************************************************************************* + * ___ _ ____ ____ + * / _ \ _ _ ___ ___| |_| _ \| __ ) + * | | | | | | |/ _ \/ __| __| | | | _ \ + * | |_| | |_| | __/\__ \ |_| |_| | |_) | + * \__\_\\__,_|\___||___/\__|____/|____/ + * + * Copyright (c) 2014-2019 Appsicle + * Copyright (c) 2019-2022 QuestDB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +import React from "react" +import styled from "styled-components" +import { Wrapper, Content, SideContent } from "../styles" +import { Timestamp } from "../Timestamp" +import { NotificationShape } from "../../../../types" +import { InfoOutline } from "@styled-icons/evaicons-outline" +import { color } from "../../../../utils" + +const InfoOutlineIcon = styled(InfoOutline)` + color: ${color("yellow")}; + flex-shrink: 0; +` + +export const NoticeNotification = (props: NotificationShape) => { + const { createdAt, content, sideContent, isMinimized } = props + return ( + + + + {content} + {sideContent} + + ) +} diff --git a/packages/web-console/src/scenes/Notifications/Notification/index.tsx b/packages/web-console/src/scenes/Notifications/Notification/index.tsx index 3d48c585e..afa2c16a4 100644 --- a/packages/web-console/src/scenes/Notifications/Notification/index.tsx +++ b/packages/web-console/src/scenes/Notifications/Notification/index.tsx @@ -27,6 +27,7 @@ import { NotificationShape, NotificationType } from "../../../types" import { SuccessNotification } from "./SuccessNotification" import { ErrorNotification } from "./ErrorNotification" import { InfoNotification } from "./InfoNotification" +import {NoticeNotification} from "./NoticeNotification"; const Notification = (props: NotificationShape) => { const { type } = props @@ -34,6 +35,8 @@ const Notification = (props: NotificationShape) => { ) : type === NotificationType.ERROR ? ( + ) : type == NotificationType.NOTICE ? ( + ) : ( ) diff --git a/packages/web-console/src/store/Query/types.ts b/packages/web-console/src/store/Query/types.ts index 1553a0836..5857b0228 100644 --- a/packages/web-console/src/store/Query/types.ts +++ b/packages/web-console/src/store/Query/types.ts @@ -34,6 +34,7 @@ export enum NotificationType { ERROR = "error", INFO = "info", SUCCESS = "success", + NOTICE = "notice", } export type NotificationShape = Readonly<{ diff --git a/packages/web-console/src/utils/questdb.ts b/packages/web-console/src/utils/questdb.ts index 286fa1264..ca1ccd0ed 100644 --- a/packages/web-console/src/utils/questdb.ts +++ b/packages/web-console/src/utils/questdb.ts @@ -38,6 +38,7 @@ export enum Type { DML = "dml", DQL = "dql", ERROR = "error", + NOTICE = "notice", } export type Timings = { @@ -58,6 +59,7 @@ type RawDqlResult = { dataset: DatasetType[] ddl: undefined dml: undefined + notice: undefined error: undefined query: string timings: Timings @@ -82,6 +84,15 @@ type RawErrorResult = { query: string } +type RawNoticeResult = { + ddl: undefined + dml: undefined + error: undefined + notice: "" + position: undefined + query: string +} + type DdlResult = { query: string type: Type.DDL @@ -92,18 +103,23 @@ type DmlResult = { type: Type.DML } -type RawResult = RawDqlResult | RawDmlResult | RawDdlResult | RawErrorResult +type RawResult = RawDqlResult | RawDmlResult | RawDdlResult | RawErrorResult | RawNoticeResult export type ErrorResult = RawErrorResult & { type: Type.ERROR status: number } +export type NoticeResult = RawNoticeResult & { + type: Type.NOTICE +} + export type QueryRawResult = | (Omit & { type: Type.DQL }) | DmlResult | DdlResult | ErrorResult + | NoticeResult export type QueryResult> = | { @@ -117,6 +133,7 @@ export type QueryResult> = | ErrorResult | DmlResult | DdlResult + | NoticeResult export type PartitionBy = "HOUR" | "DAY" | "WEEK" | "MONTH" | "YEAR" | "NONE" @@ -503,6 +520,13 @@ export class Client { }) } + if (data.notice) { + return { + ...data, + type: Type.NOTICE, + } + } + return { ...data, timings: { From 3f1007ccb69c3079bccd697688be9fed432187b6 Mon Sep 17 00:00:00 2001 From: Jaromir Hamala Date: Mon, 30 Sep 2024 17:46:30 +0200 Subject: [PATCH 2/7] submodule update --- packages/browser-tests/questdb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/browser-tests/questdb b/packages/browser-tests/questdb index 7442c9913..a9eb30934 160000 --- a/packages/browser-tests/questdb +++ b/packages/browser-tests/questdb @@ -1 +1 @@ -Subproject commit 7442c991312cb408d473bf7e7ae8a536bcf718de +Subproject commit a9eb30934414dcb513f8a72d04051a050a6b6645 From 40df428179bea7ef797522926d6bf38a3a7ebb6a Mon Sep 17 00:00:00 2001 From: Jaromir Hamala Date: Mon, 30 Sep 2024 18:04:25 +0200 Subject: [PATCH 3/7] conditionally print query. when the NOTICE does not have a query then we do not print an empty ''': --- packages/web-console/src/scenes/Editor/Monaco/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/web-console/src/scenes/Editor/Monaco/index.tsx b/packages/web-console/src/scenes/Editor/Monaco/index.tsx index 343d5586d..2a38a8365 100644 --- a/packages/web-console/src/scenes/Editor/Monaco/index.tsx +++ b/packages/web-console/src/scenes/Editor/Monaco/index.tsx @@ -327,7 +327,8 @@ const MonacoEditor = () => { actions.query.addNotification({ content: ( - {result.notice}: {result.query} + {result.notice} + {result.query !== undefined && result.query !== '' && `: ${result.query}`} ), type: NotificationType.NOTICE, From 176057eb5266d75f04242ea1aced0bf16b56c624 Mon Sep 17 00:00:00 2001 From: Jaromir Hamala Date: Tue, 8 Oct 2024 10:15:17 +0200 Subject: [PATCH 4/7] submodule update --- packages/browser-tests/questdb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/browser-tests/questdb b/packages/browser-tests/questdb index a9eb30934..5b50a4f79 160000 --- a/packages/browser-tests/questdb +++ b/packages/browser-tests/questdb @@ -1 +1 @@ -Subproject commit a9eb30934414dcb513f8a72d04051a050a6b6645 +Subproject commit 5b50a4f79151a95375cdbc937e3ab231efb971bf From f0717be8f2ec129610ccd2c4de992f4c95db66ab Mon Sep 17 00:00:00 2001 From: Jaromir Hamala Date: Mon, 14 Oct 2024 12:56:36 +0200 Subject: [PATCH 5/7] webconsole to include API version in requests to QuestDB server --- packages/web-console/src/consts/index.ts | 6 ++++++ packages/web-console/src/utils/questdb.ts | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/web-console/src/consts/index.ts b/packages/web-console/src/consts/index.ts index 93910cf20..25c4baa22 100644 --- a/packages/web-console/src/consts/index.ts +++ b/packages/web-console/src/consts/index.ts @@ -32,4 +32,10 @@ const BASE = process.env.NODE_ENV === "production" ? "fara" : "alurin" export const API = `https://${BASE}.questdb.io` +// QuestDB API version +// to be included in all requests +// so server-side can construct a reply +// the console will understand +export const API_VERSION = "2"; + export const BUTTON_ICON_SIZE = "26px" diff --git a/packages/web-console/src/utils/questdb.ts b/packages/web-console/src/utils/questdb.ts index ca1ccd0ed..6e14e72e6 100644 --- a/packages/web-console/src/utils/questdb.ts +++ b/packages/web-console/src/utils/questdb.ts @@ -27,6 +27,7 @@ import { eventBus } from "../modules/EventBus" import { EventType } from "../modules/EventBus/types" import { AuthPayload } from "../modules/OAuth2/types" import { StoreKey } from "./localStorage/types" +import {API_VERSION} from "../consts"; type ColumnDefinition = Readonly<{ name: string; type: string }> @@ -418,6 +419,7 @@ export class Client { src: "con", query, timings: true, + version: API_VERSION, ...options, } @@ -618,6 +620,7 @@ export class Client { `chk?${Client.encodeParams({ f: "json", j: name, + version: API_VERSION, })}`, { headers: this.commonHeaders }, ) @@ -691,7 +694,7 @@ export class Client { async exportQueryToCsv(query: string) { try { const response: Response = await fetch( - `exp?${Client.encodeParams({ query })}`, + `exp?${Client.encodeParams({ query, version: API_VERSION })}`, { headers: this.commonHeaders }, ) const blob = await response.blob() From 862097a91e638f4c34352eb92f1275d9a16f7f53 Mon Sep 17 00:00:00 2001 From: Jaromir Hamala Date: Mon, 14 Oct 2024 14:54:57 +0200 Subject: [PATCH 6/7] submodule update --- packages/browser-tests/questdb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/browser-tests/questdb b/packages/browser-tests/questdb index 5b50a4f79..9fb5bb98e 160000 --- a/packages/browser-tests/questdb +++ b/packages/browser-tests/questdb @@ -1 +1 @@ -Subproject commit 5b50a4f79151a95375cdbc937e3ab231efb971bf +Subproject commit 9fb5bb98ea7038a595a7b9bf472d7acdd09f52ad From 4cdc73b3f51af28c169834b0b43a9375fc98158d Mon Sep 17 00:00:00 2001 From: Vlad Ilyushchenko Date: Mon, 14 Oct 2024 19:54:32 +0100 Subject: [PATCH 7/7] sync with master --- packages/browser-tests/questdb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/browser-tests/questdb b/packages/browser-tests/questdb index 9fb5bb98e..908d0d03b 160000 --- a/packages/browser-tests/questdb +++ b/packages/browser-tests/questdb @@ -1 +1 @@ -Subproject commit 9fb5bb98ea7038a595a7b9bf472d7acdd09f52ad +Subproject commit 908d0d03b03413ffe8f31fbcec81b7ac7754c2f2