chore: gen api

This commit is contained in:
Nicolas Meienberger 2024-11-09 12:06:22 +01:00
parent 9a422d6c45
commit 65c17bba67
3 changed files with 130 additions and 0 deletions

View File

@ -8,7 +8,9 @@ import {
appContext, appContext,
updateUserSettings, updateUserSettings,
acknowledgeWelcome, acknowledgeWelcome,
getError,
systemLoad, systemLoad,
downloadLocalCertificate,
getTranslation, getTranslation,
login, login,
verifyTotp, verifyTotp,
@ -41,6 +43,7 @@ import {
createLink, createLink,
editLink, editLink,
deleteLink, deleteLink,
check,
} from '../services.gen'; } from '../services.gen';
import type { import type {
UpdateUserSettingsData, UpdateUserSettingsData,
@ -212,6 +215,22 @@ export const acknowledgeWelcomeMutation = () => {
return mutationOptions; return mutationOptions;
}; };
export const getErrorQueryKey = (options?: Options) => [createQueryKey('getError', options)];
export const getErrorOptions = (options?: Options) => {
return queryOptions({
queryFn: async ({ queryKey }) => {
const { data } = await getError({
...options,
...queryKey[0],
throwOnError: true,
});
return data;
},
queryKey: getErrorQueryKey(options),
});
};
export const systemLoadQueryKey = (options?: Options) => [createQueryKey('systemLoad', options)]; export const systemLoadQueryKey = (options?: Options) => [createQueryKey('systemLoad', options)];
export const systemLoadOptions = (options?: Options) => { export const systemLoadOptions = (options?: Options) => {
@ -228,6 +247,22 @@ export const systemLoadOptions = (options?: Options) => {
}); });
}; };
export const downloadLocalCertificateQueryKey = (options?: Options) => [createQueryKey('downloadLocalCertificate', options)];
export const downloadLocalCertificateOptions = (options?: Options) => {
return queryOptions({
queryFn: async ({ queryKey }) => {
const { data } = await downloadLocalCertificate({
...options,
...queryKey[0],
throwOnError: true,
});
return data;
},
queryKey: downloadLocalCertificateQueryKey(options),
});
};
export const getTranslationQueryKey = (options: Options<GetTranslationData>) => [createQueryKey('getTranslation', options)]; export const getTranslationQueryKey = (options: Options<GetTranslationData>) => [createQueryKey('getTranslation', options)];
export const getTranslationOptions = (options: Options<GetTranslationData>) => { export const getTranslationOptions = (options: Options<GetTranslationData>) => {
@ -981,3 +1016,19 @@ export const deleteLinkMutation = () => {
}; };
return mutationOptions; return mutationOptions;
}; };
export const checkQueryKey = (options?: Options) => [createQueryKey('check', options)];
export const checkOptions = (options?: Options) => {
return queryOptions({
queryFn: async ({ queryKey }) => {
const { data } = await check({
...options,
...queryKey[0],
throwOnError: true,
});
return data;
},
queryKey: checkQueryKey(options),
});
};

View File

@ -12,8 +12,12 @@ import type {
AcknowledgeWelcomeData, AcknowledgeWelcomeData,
AcknowledgeWelcomeError, AcknowledgeWelcomeError,
AcknowledgeWelcomeResponse, AcknowledgeWelcomeResponse,
GetErrorError,
GetErrorResponse,
SystemLoadError, SystemLoadError,
SystemLoadResponse, SystemLoadResponse,
DownloadLocalCertificateError,
DownloadLocalCertificateResponse,
GetTranslationData, GetTranslationData,
GetTranslationError, GetTranslationError,
GetTranslationResponse, GetTranslationResponse,
@ -104,6 +108,8 @@ import type {
DeleteLinkData, DeleteLinkData,
DeleteLinkError, DeleteLinkError,
DeleteLinkResponse, DeleteLinkResponse,
CheckError,
CheckResponse,
} from './types.gen'; } from './types.gen';
export const client = createClient(createConfig()); export const client = createClient(createConfig());
@ -136,6 +142,13 @@ export const acknowledgeWelcome = <ThrowOnError extends boolean = false>(options
}); });
}; };
export const getError = <ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) => {
return (options?.client ?? client).get<GetErrorResponse, GetErrorError, ThrowOnError>({
...options,
url: '/api/debug-sentry',
});
};
export const systemLoad = <ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) => { export const systemLoad = <ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) => {
return (options?.client ?? client).get<SystemLoadResponse, SystemLoadError, ThrowOnError>({ return (options?.client ?? client).get<SystemLoadResponse, SystemLoadError, ThrowOnError>({
...options, ...options,
@ -143,6 +156,13 @@ export const systemLoad = <ThrowOnError extends boolean = false>(options?: Optio
}); });
}; };
export const downloadLocalCertificate = <ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) => {
return (options?.client ?? client).get<DownloadLocalCertificateResponse, DownloadLocalCertificateError, ThrowOnError>({
...options,
url: '/api/system/certificate',
});
};
export const getTranslation = <ThrowOnError extends boolean = false>(options: Options<GetTranslationData, ThrowOnError>) => { export const getTranslation = <ThrowOnError extends boolean = false>(options: Options<GetTranslationData, ThrowOnError>) => {
return (options?.client ?? client).get<GetTranslationResponse, GetTranslationError, ThrowOnError>({ return (options?.client ?? client).get<GetTranslationResponse, GetTranslationError, ThrowOnError>({
...options, ...options,
@ -366,3 +386,10 @@ export const deleteLink = <ThrowOnError extends boolean = false>(options: Option
url: '/api/links/{id}', url: '/api/links/{id}',
}); });
}; };
export const check = <ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) => {
return (options?.client ?? client).get<CheckResponse, CheckError, ThrowOnError>({
...options,
url: '/api/health',
});
};

View File

@ -548,10 +548,18 @@ export type AcknowledgeWelcomeResponse = unknown;
export type AcknowledgeWelcomeError = unknown; export type AcknowledgeWelcomeError = unknown;
export type GetErrorResponse = unknown;
export type GetErrorError = unknown;
export type SystemLoadResponse = LoadDto; export type SystemLoadResponse = LoadDto;
export type SystemLoadError = unknown; export type SystemLoadError = unknown;
export type DownloadLocalCertificateResponse = unknown;
export type DownloadLocalCertificateError = unknown;
export type GetTranslationData = { export type GetTranslationData = {
path: { path: {
lng: string; lng: string;
@ -844,3 +852,47 @@ export type DeleteLinkData = {
export type DeleteLinkResponse = unknown; export type DeleteLinkResponse = unknown;
export type DeleteLinkError = unknown; export type DeleteLinkError = unknown;
export type CheckResponse = {
status?: string;
info?: {
[key: string]: {
status: string;
[key: string]: unknown | string;
};
} | null;
error?: {
[key: string]: {
status: string;
[key: string]: unknown | string;
};
} | null;
details?: {
[key: string]: {
status: string;
[key: string]: unknown | string;
};
};
};
export type CheckError = {
status?: string;
info?: {
[key: string]: {
status: string;
[key: string]: unknown | string;
};
} | null;
error?: {
[key: string]: {
status: string;
[key: string]: unknown | string;
};
} | null;
details?: {
[key: string]: {
status: string;
[key: string]: unknown | string;
};
};
};