Skip to content

Commit

Permalink
fix: breaking changes in openapi spec (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-mcgovern authored Jan 20, 2025
1 parent a38e2cd commit cd549d2
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 105 deletions.
84 changes: 48 additions & 36 deletions src/api/generated/@tanstack/react-query.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import type { OptionsLegacyParser } from "@hey-api/client-fetch";
import { queryOptions, type UseMutationOptions } from "@tanstack/react-query";
import {
client,
getMessagesDashboardMessagesGet,
getAlertsDashboardAlertsGet,
streamSseDashboardAlertsNotificationGet,
versionCheckDashboardVersionGet,
healthCheckHealthGet,
v1GetMessages,
v1GetAlerts,
v1StreamSse,
v1VersionCheck,
v1ListWorkspaces,
v1CreateWorkspace,
v1ListActiveWorkspaces,
Expand Down Expand Up @@ -60,87 +61,98 @@ const createQueryKey = <TOptions extends OptionsLegacyParser>(
return params;
};

export const getMessagesDashboardMessagesGetQueryKey = (
options?: OptionsLegacyParser,
) => [createQueryKey("getMessagesDashboardMessagesGet", options)];
export const healthCheckHealthGetQueryKey = (options?: OptionsLegacyParser) => [
createQueryKey("healthCheckHealthGet", options),
];

export const getMessagesDashboardMessagesGetOptions = (
options?: OptionsLegacyParser,
) => {
export const healthCheckHealthGetOptions = (options?: OptionsLegacyParser) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getMessagesDashboardMessagesGet({
const { data } = await healthCheckHealthGet({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: getMessagesDashboardMessagesGetQueryKey(options),
queryKey: healthCheckHealthGetQueryKey(options),
});
};

export const getAlertsDashboardAlertsGetQueryKey = (
options?: OptionsLegacyParser,
) => [createQueryKey("getAlertsDashboardAlertsGet", options)];
export const v1GetMessagesQueryKey = (options?: OptionsLegacyParser) => [
createQueryKey("v1GetMessages", options),
];

export const getAlertsDashboardAlertsGetOptions = (
options?: OptionsLegacyParser,
) => {
export const v1GetMessagesOptions = (options?: OptionsLegacyParser) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await getAlertsDashboardAlertsGet({
const { data } = await v1GetMessages({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: getAlertsDashboardAlertsGetQueryKey(options),
queryKey: v1GetMessagesQueryKey(options),
});
};

export const streamSseDashboardAlertsNotificationGetQueryKey = (
options?: OptionsLegacyParser,
) => [createQueryKey("streamSseDashboardAlertsNotificationGet", options)];
export const v1GetAlertsQueryKey = (options?: OptionsLegacyParser) => [
createQueryKey("v1GetAlerts", options),
];

export const streamSseDashboardAlertsNotificationGetOptions = (
options?: OptionsLegacyParser,
) => {
export const v1GetAlertsOptions = (options?: OptionsLegacyParser) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await streamSseDashboardAlertsNotificationGet({
const { data } = await v1GetAlerts({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: streamSseDashboardAlertsNotificationGetQueryKey(options),
queryKey: v1GetAlertsQueryKey(options),
});
};

export const versionCheckDashboardVersionGetQueryKey = (
options?: OptionsLegacyParser,
) => [createQueryKey("versionCheckDashboardVersionGet", options)];
export const v1StreamSseQueryKey = (options?: OptionsLegacyParser) => [
createQueryKey("v1StreamSse", options),
];

export const versionCheckDashboardVersionGetOptions = (
options?: OptionsLegacyParser,
) => {
export const v1StreamSseOptions = (options?: OptionsLegacyParser) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await v1StreamSse({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: v1StreamSseQueryKey(options),
});
};

export const v1VersionCheckQueryKey = (options?: OptionsLegacyParser) => [
createQueryKey("v1VersionCheck", options),
];

export const v1VersionCheckOptions = (options?: OptionsLegacyParser) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await versionCheckDashboardVersionGet({
const { data } = await v1VersionCheck({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: versionCheckDashboardVersionGetQueryKey(options),
queryKey: v1VersionCheckQueryKey(options),
});
};

Expand Down
74 changes: 42 additions & 32 deletions src/api/generated/sdk.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import {
type OptionsLegacyParser,
} from "@hey-api/client-fetch";
import type {
GetMessagesDashboardMessagesGetError,
GetMessagesDashboardMessagesGetResponse,
GetAlertsDashboardAlertsGetError,
GetAlertsDashboardAlertsGetResponse,
StreamSseDashboardAlertsNotificationGetError,
StreamSseDashboardAlertsNotificationGetResponse,
VersionCheckDashboardVersionGetError,
VersionCheckDashboardVersionGetResponse,
HealthCheckHealthGetError,
HealthCheckHealthGetResponse,
V1GetMessagesError,
V1GetMessagesResponse,
V1GetAlertsError,
V1GetAlertsResponse,
V1StreamSseError,
V1StreamSseResponse,
V1VersionCheckError,
V1VersionCheckResponse,
V1ListWorkspacesError,
V1ListWorkspacesResponse,
V1CreateWorkspaceData,
Expand All @@ -31,78 +33,86 @@ import type {

export const client = createClient(createConfig());

/**
* Health Check
*/
export const healthCheckHealthGet = <ThrowOnError extends boolean = false>(
options?: OptionsLegacyParser<unknown, ThrowOnError>,
) => {
return (options?.client ?? client).get<
HealthCheckHealthGetResponse,
HealthCheckHealthGetError,
ThrowOnError
>({
...options,
url: "/health",
});
};

/**
* Get Messages
* Get all the messages from the database and return them as a list of conversations.
*/
export const getMessagesDashboardMessagesGet = <
ThrowOnError extends boolean = false,
>(
export const v1GetMessages = <ThrowOnError extends boolean = false>(
options?: OptionsLegacyParser<unknown, ThrowOnError>,
) => {
return (options?.client ?? client).get<
GetMessagesDashboardMessagesGetResponse,
GetMessagesDashboardMessagesGetError,
V1GetMessagesResponse,
V1GetMessagesError,
ThrowOnError
>({
...options,
url: "/dashboard/messages",
url: "/api/v1/dashboard/messages",
});
};

/**
* Get Alerts
* Get all the messages from the database and return them as a list of conversations.
*/
export const getAlertsDashboardAlertsGet = <
ThrowOnError extends boolean = false,
>(
export const v1GetAlerts = <ThrowOnError extends boolean = false>(
options?: OptionsLegacyParser<unknown, ThrowOnError>,
) => {
return (options?.client ?? client).get<
GetAlertsDashboardAlertsGetResponse,
GetAlertsDashboardAlertsGetError,
V1GetAlertsResponse,
V1GetAlertsError,
ThrowOnError
>({
...options,
url: "/dashboard/alerts",
url: "/api/v1/dashboard/alerts",
});
};

/**
* Stream Sse
* Send alerts event
*/
export const streamSseDashboardAlertsNotificationGet = <
ThrowOnError extends boolean = false,
>(
export const v1StreamSse = <ThrowOnError extends boolean = false>(
options?: OptionsLegacyParser<unknown, ThrowOnError>,
) => {
return (options?.client ?? client).get<
StreamSseDashboardAlertsNotificationGetResponse,
StreamSseDashboardAlertsNotificationGetError,
V1StreamSseResponse,
V1StreamSseError,
ThrowOnError
>({
...options,
url: "/dashboard/alerts_notification",
url: "/api/v1/dashboard/alerts_notification",
});
};

/**
* Version Check
*/
export const versionCheckDashboardVersionGet = <
ThrowOnError extends boolean = false,
>(
export const v1VersionCheck = <ThrowOnError extends boolean = false>(
options?: OptionsLegacyParser<unknown, ThrowOnError>,
) => {
return (options?.client ?? client).get<
VersionCheckDashboardVersionGetResponse,
VersionCheckDashboardVersionGetError,
V1VersionCheckResponse,
V1VersionCheckError,
ThrowOnError
>({
...options,
url: "/dashboard/version",
url: "/api/v1/dashboard/version",
});
};

Expand Down
21 changes: 12 additions & 9 deletions src/api/generated/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,25 @@ export type Workspace = {
is_active: boolean;
};

export type GetMessagesDashboardMessagesGetResponse = Array<Conversation>;
export type HealthCheckHealthGetResponse = unknown;

export type GetMessagesDashboardMessagesGetError = unknown;
export type HealthCheckHealthGetError = unknown;

export type GetAlertsDashboardAlertsGetResponse =
Array<AlertConversation | null>;
export type V1GetMessagesResponse = Array<Conversation>;

export type GetAlertsDashboardAlertsGetError = unknown;
export type V1GetMessagesError = unknown;

export type StreamSseDashboardAlertsNotificationGetResponse = unknown;
export type V1GetAlertsResponse = Array<AlertConversation | null>;

export type StreamSseDashboardAlertsNotificationGetError = unknown;
export type V1GetAlertsError = unknown;

export type VersionCheckDashboardVersionGetResponse = unknown;
export type V1StreamSseResponse = unknown;

export type VersionCheckDashboardVersionGetError = unknown;
export type V1StreamSseError = unknown;

export type V1VersionCheckResponse = unknown;

export type V1VersionCheckError = unknown;

export type V1ListWorkspacesResponse = ListWorkspacesResponse;

Expand Down
Loading

0 comments on commit cd549d2

Please sign in to comment.