Skip to content

feat: workspace scoped queries (messages & alerts) #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/api/generated/@tanstack/react-query.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
v1ListActiveWorkspaces,
v1ActivateWorkspace,
v1DeleteWorkspace,
v1GetWorkspaceAlerts,
v1GetWorkspaceMessages,
} from "../sdk.gen";
import type {
V1CreateWorkspaceData,
Expand All @@ -25,6 +27,8 @@ import type {
V1DeleteWorkspaceData,
V1DeleteWorkspaceError,
V1DeleteWorkspaceResponse,
V1GetWorkspaceAlertsData,
V1GetWorkspaceMessagesData,
} from "../types.gen";

type QueryKey<TOptions extends OptionsLegacyParser> = [
Expand Down Expand Up @@ -297,3 +301,45 @@ export const v1DeleteWorkspaceMutation = (
};
return mutationOptions;
};

export const v1GetWorkspaceAlertsQueryKey = (
options: OptionsLegacyParser<V1GetWorkspaceAlertsData>,
) => [createQueryKey("v1GetWorkspaceAlerts", options)];

export const v1GetWorkspaceAlertsOptions = (
options: OptionsLegacyParser<V1GetWorkspaceAlertsData>,
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await v1GetWorkspaceAlerts({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: v1GetWorkspaceAlertsQueryKey(options),
});
};

export const v1GetWorkspaceMessagesQueryKey = (
options: OptionsLegacyParser<V1GetWorkspaceMessagesData>,
) => [createQueryKey("v1GetWorkspaceMessages", options)];

export const v1GetWorkspaceMessagesOptions = (
options: OptionsLegacyParser<V1GetWorkspaceMessagesData>,
) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await v1GetWorkspaceMessages({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: v1GetWorkspaceMessagesQueryKey(options),
});
};
40 changes: 40 additions & 0 deletions src/api/generated/sdk.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ import type {
V1DeleteWorkspaceData,
V1DeleteWorkspaceError,
V1DeleteWorkspaceResponse,
V1GetWorkspaceAlertsData,
V1GetWorkspaceAlertsError,
V1GetWorkspaceAlertsResponse,
V1GetWorkspaceMessagesData,
V1GetWorkspaceMessagesError,
V1GetWorkspaceMessagesResponse,
} from "./types.gen";

export const client = createClient(createConfig());
Expand Down Expand Up @@ -203,3 +209,37 @@ export const v1DeleteWorkspace = <ThrowOnError extends boolean = false>(
url: "/api/v1/workspaces/{workspace_name}",
});
};

/**
* Get Workspace Alerts
* Get alerts for a workspace.
*/
export const v1GetWorkspaceAlerts = <ThrowOnError extends boolean = false>(
options: OptionsLegacyParser<V1GetWorkspaceAlertsData, ThrowOnError>,
) => {
return (options?.client ?? client).get<
V1GetWorkspaceAlertsResponse,
V1GetWorkspaceAlertsError,
ThrowOnError
>({
...options,
url: "/api/v1/workspaces/{workspace_name}/alerts",
});
};

/**
* Get Workspace Messages
* Get messages for a workspace.
*/
export const v1GetWorkspaceMessages = <ThrowOnError extends boolean = false>(
options: OptionsLegacyParser<V1GetWorkspaceMessagesData, ThrowOnError>,
) => {
return (options?.client ?? client).get<
V1GetWorkspaceMessagesResponse,
V1GetWorkspaceMessagesError,
ThrowOnError
>({
...options,
url: "/api/v1/workspaces/{workspace_name}/messages",
});
};
24 changes: 22 additions & 2 deletions src/api/generated/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export type V1CreateWorkspaceData = {
body: CreateWorkspaceRequest;
};

export type V1CreateWorkspaceResponse = unknown;
export type V1CreateWorkspaceResponse = Workspace;

export type V1CreateWorkspaceError = HTTPValidationError;

Expand All @@ -143,6 +143,26 @@ export type V1DeleteWorkspaceData = {
};
};

export type V1DeleteWorkspaceResponse = void;
export type V1DeleteWorkspaceResponse = unknown;

export type V1DeleteWorkspaceError = HTTPValidationError;

export type V1GetWorkspaceAlertsData = {
path: {
workspace_name: string;
};
};

export type V1GetWorkspaceAlertsResponse = Array<AlertConversation | null>;

export type V1GetWorkspaceAlertsError = HTTPValidationError;

export type V1GetWorkspaceMessagesData = {
path: {
workspace_name: string;
};
};

export type V1GetWorkspaceMessagesResponse = Array<Conversation>;

export type V1GetWorkspaceMessagesError = HTTPValidationError;
Loading
Loading