Skip to content

Commit

Permalink
generated type guards
Browse files Browse the repository at this point in the history
  • Loading branch information
findus committed Nov 19, 2024
1 parent 088cfed commit 32db284
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions web/src/apiClient.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* Generated type guards for "apiClient.ts".
* WARNING: Do not manually change this file.
*/
import { Error, SearchResult, SearchResponse, StreamData, Statistics, PcapsResponse, ConvertersResponse, ProcessStderr, PcapOverIPResponse, TagsResponse, GraphResponse, ClientConfig } from "./apiClient";
import { ConfigEvent } from "./stores/websocket";
import { Error, SearchResult, SearchResponse, StreamData, Statistics, ClientConfig, PcapsResponse, ConvertersResponse, ProcessStderr, PcapOverIPResponse, TagsResponse, GraphResponse } from "./apiClient";

export function isError(obj: unknown): obj is Error {
const typedObj = obj as Error
Expand Down Expand Up @@ -139,7 +138,7 @@ export function isClientConfig(obj: unknown): obj is ClientConfig {
return (
(typedObj !== null &&
typeof typedObj === "object" ||
typeof typedObj === "function") &&
typeof typedObj === "function") &&
typeof typedObj["AutoInsertLimitToQuery"] === "boolean"
)
}
Expand Down
11 changes: 5 additions & 6 deletions web/src/stores/websocket.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* WARNING: Do not manually change this file.
*/
import { Event, TagEvent, ConverterEvent, PcapStatsEvent, ConfigEvent } from "./websocket";
import { isClientConfig } from "../apiClient.guard";

export function isEvent(obj: unknown): obj is Event {
const typedObj = obj as Event
Expand Down Expand Up @@ -94,10 +95,8 @@ export function isConfigEvent(obj: unknown): obj is ConfigEvent {
return (
(typedObj !== null &&
typeof typedObj === "object" ||
typeof typedObj === "function") &&
(typedObj["Config"] !== null &&
typeof typedObj["Config"] === "object" ||
typeof typedObj["Config"] === "function") &&
typeof typedObj["Config"]["AutoInsertLimitToQuery"] === "boolean"
typeof typedObj === "function") &&
typedObj["Type"] === "configUpdated" &&
isClientConfig(typedObj["Config"]) as boolean
)
}
}

0 comments on commit 32db284

Please sign in to comment.