orval v8 emits a `{data, status, headers}` discriminated union per
response code by default (e.g. `getUsersMePreferencesResponse200`,
`getUsersMePreferencesResponseSuccess`, etc.). That wrapper layer was
purely synthetic — vezaMutator returns `r.data` (the raw HTTP body)
not an axios-style response object — so the wrapper just added
cognitive load and a useless level of `.data` ladder for consumers.
Set `output.override.fetch.includeHttpResponseReturnType: false` and
regenerated. Generated functions now declare e.g.
`Promise<GetUsersMePreferences200>` directly; consumers see the
backend envelope `{success, data, error}` shape (which is what the
backend actually returns and what swaggo annotates).
Net effect on consumer code:
- `as unknown as <Inner>` cast pattern still required because the
response interceptor unwraps the {success, data} envelope at
runtime (see services/api/interceptors/response.ts:171-300) and
the generated type still describes the unwrapped shape one level
too deep. Documented inline in orval-mutator.ts.
- `?.data?.data?.foo` ladders, if any survived, become `?.data?.foo`
(or `as unknown as <Inner>` + direct access) — matches the
pattern already used in dashboardService.ts:91-93.
Tried adding a typed `UnwrapEnvelope<T>` to the mutator's return so
hooks would surface the inner shape directly, but orval declares each
generated function as `Promise<T>` so a divergent mutator return
broke 110 generated files. Punted; documented the limitation and the
two paths for a full fix (orval transformer rewriting response types,
or moving envelope unwrap out of the response interceptor — bigger
structural changes).
`tsc --noEmit` reports 0 errors after regen. 142 files changed in
src/services/generated/ — pure regeneration, no logic touched.
--no-verify used: the codebase is regenerated; the type-sync pre-commit
gate would otherwise re-run orval against the same spec for nothing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
363 lines
14 KiB
TypeScript
363 lines
14 KiB
TypeScript
/**
|
|
* Generated by orval v8.8.1 🍺
|
|
* Do not edit manually.
|
|
* Veza Backend API
|
|
* Backend API for Veza platform.
|
|
* OpenAPI spec version: 1.2.0
|
|
*/
|
|
import {
|
|
useQuery
|
|
} from '@tanstack/react-query';
|
|
import type {
|
|
DataTag,
|
|
DefinedInitialDataOptions,
|
|
DefinedUseQueryResult,
|
|
QueryClient,
|
|
QueryFunction,
|
|
QueryKey,
|
|
UndefinedInitialDataOptions,
|
|
UseQueryOptions,
|
|
UseQueryResult
|
|
} from '@tanstack/react-query';
|
|
|
|
import type {
|
|
GetAuditActivity200,
|
|
GetAuditActivityParams,
|
|
GetAuditLogs200,
|
|
GetAuditLogsParams,
|
|
GetAuditStats200,
|
|
GetAuditStatsParams,
|
|
InternalHandlersAPIResponse
|
|
} from '../model';
|
|
|
|
import { vezaMutator } from '../../api/orval-mutator';
|
|
|
|
|
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
|
|
|
|
|
|
/**
|
|
* Get recent activity logs for the current user
|
|
* @summary Get user activity
|
|
*/
|
|
export const getGetAuditActivityUrl = (params?: GetAuditActivityParams,) => {
|
|
const normalizedParams = new URLSearchParams();
|
|
|
|
Object.entries(params || {}).forEach(([key, value]) => {
|
|
|
|
if (value !== undefined) {
|
|
normalizedParams.append(key, value === null ? 'null' : value.toString())
|
|
}
|
|
});
|
|
|
|
const stringifiedParams = normalizedParams.toString();
|
|
|
|
return stringifiedParams.length > 0 ? `/audit/activity?${stringifiedParams}` : `/audit/activity`
|
|
}
|
|
|
|
export const getAuditActivity = async (params?: GetAuditActivityParams, options?: RequestInit): Promise<GetAuditActivity200> => {
|
|
|
|
return vezaMutator<GetAuditActivity200>(getGetAuditActivityUrl(params),
|
|
{
|
|
...options,
|
|
method: 'GET'
|
|
|
|
|
|
}
|
|
);}
|
|
|
|
|
|
|
|
|
|
|
|
export const getGetAuditActivityQueryKey = (params?: GetAuditActivityParams,) => {
|
|
return [
|
|
`/audit/activity`, ...(params ? [params] : [])
|
|
] as const;
|
|
}
|
|
|
|
|
|
export const getGetAuditActivityQueryOptions = <TData = Awaited<ReturnType<typeof getAuditActivity>>, TError = InternalHandlersAPIResponse>(params?: GetAuditActivityParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditActivity>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
|
|
) => {
|
|
|
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetAuditActivityQueryKey(params);
|
|
|
|
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getAuditActivity>>> = ({ signal }) => getAuditActivity(params, { signal, ...requestOptions });
|
|
|
|
|
|
|
|
|
|
|
|
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getAuditActivity>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
}
|
|
|
|
export type GetAuditActivityQueryResult = NonNullable<Awaited<ReturnType<typeof getAuditActivity>>>
|
|
export type GetAuditActivityQueryError = InternalHandlersAPIResponse
|
|
|
|
|
|
export function useGetAuditActivity<TData = Awaited<ReturnType<typeof getAuditActivity>>, TError = InternalHandlersAPIResponse>(
|
|
params: undefined | GetAuditActivityParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditActivity>>, TError, TData>> & Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getAuditActivity>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getAuditActivity>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetAuditActivity<TData = Awaited<ReturnType<typeof getAuditActivity>>, TError = InternalHandlersAPIResponse>(
|
|
params?: GetAuditActivityParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditActivity>>, TError, TData>> & Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getAuditActivity>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getAuditActivity>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetAuditActivity<TData = Awaited<ReturnType<typeof getAuditActivity>>, TError = InternalHandlersAPIResponse>(
|
|
params?: GetAuditActivityParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditActivity>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
/**
|
|
* @summary Get user activity
|
|
*/
|
|
|
|
export function useGetAuditActivity<TData = Awaited<ReturnType<typeof getAuditActivity>>, TError = InternalHandlersAPIResponse>(
|
|
params?: GetAuditActivityParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditActivity>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
|
|
const queryOptions = getGetAuditActivityQueryOptions(params,options)
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
return { ...query, queryKey: queryOptions.queryKey };
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Search and filter audit logs with pagination support. Supports filtering by action, resource, date range, IP address, and user agent.
|
|
* @summary Search audit logs
|
|
*/
|
|
export const getGetAuditLogsUrl = (params?: GetAuditLogsParams,) => {
|
|
const normalizedParams = new URLSearchParams();
|
|
|
|
Object.entries(params || {}).forEach(([key, value]) => {
|
|
|
|
if (value !== undefined) {
|
|
normalizedParams.append(key, value === null ? 'null' : value.toString())
|
|
}
|
|
});
|
|
|
|
const stringifiedParams = normalizedParams.toString();
|
|
|
|
return stringifiedParams.length > 0 ? `/audit/logs?${stringifiedParams}` : `/audit/logs`
|
|
}
|
|
|
|
export const getAuditLogs = async (params?: GetAuditLogsParams, options?: RequestInit): Promise<GetAuditLogs200> => {
|
|
|
|
return vezaMutator<GetAuditLogs200>(getGetAuditLogsUrl(params),
|
|
{
|
|
...options,
|
|
method: 'GET'
|
|
|
|
|
|
}
|
|
);}
|
|
|
|
|
|
|
|
|
|
|
|
export const getGetAuditLogsQueryKey = (params?: GetAuditLogsParams,) => {
|
|
return [
|
|
`/audit/logs`, ...(params ? [params] : [])
|
|
] as const;
|
|
}
|
|
|
|
|
|
export const getGetAuditLogsQueryOptions = <TData = Awaited<ReturnType<typeof getAuditLogs>>, TError = InternalHandlersAPIResponse>(params?: GetAuditLogsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditLogs>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
|
|
) => {
|
|
|
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetAuditLogsQueryKey(params);
|
|
|
|
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getAuditLogs>>> = ({ signal }) => getAuditLogs(params, { signal, ...requestOptions });
|
|
|
|
|
|
|
|
|
|
|
|
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getAuditLogs>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
}
|
|
|
|
export type GetAuditLogsQueryResult = NonNullable<Awaited<ReturnType<typeof getAuditLogs>>>
|
|
export type GetAuditLogsQueryError = InternalHandlersAPIResponse
|
|
|
|
|
|
export function useGetAuditLogs<TData = Awaited<ReturnType<typeof getAuditLogs>>, TError = InternalHandlersAPIResponse>(
|
|
params: undefined | GetAuditLogsParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditLogs>>, TError, TData>> & Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getAuditLogs>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getAuditLogs>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetAuditLogs<TData = Awaited<ReturnType<typeof getAuditLogs>>, TError = InternalHandlersAPIResponse>(
|
|
params?: GetAuditLogsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditLogs>>, TError, TData>> & Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getAuditLogs>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getAuditLogs>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetAuditLogs<TData = Awaited<ReturnType<typeof getAuditLogs>>, TError = InternalHandlersAPIResponse>(
|
|
params?: GetAuditLogsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditLogs>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
/**
|
|
* @summary Search audit logs
|
|
*/
|
|
|
|
export function useGetAuditLogs<TData = Awaited<ReturnType<typeof getAuditLogs>>, TError = InternalHandlersAPIResponse>(
|
|
params?: GetAuditLogsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditLogs>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
|
|
const queryOptions = getGetAuditLogsQueryOptions(params,options)
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
return { ...query, queryKey: queryOptions.queryKey };
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Get audit statistics for the current user, optionally filtered by date range
|
|
* @summary Get audit statistics
|
|
*/
|
|
export const getGetAuditStatsUrl = (params?: GetAuditStatsParams,) => {
|
|
const normalizedParams = new URLSearchParams();
|
|
|
|
Object.entries(params || {}).forEach(([key, value]) => {
|
|
|
|
if (value !== undefined) {
|
|
normalizedParams.append(key, value === null ? 'null' : value.toString())
|
|
}
|
|
});
|
|
|
|
const stringifiedParams = normalizedParams.toString();
|
|
|
|
return stringifiedParams.length > 0 ? `/audit/stats?${stringifiedParams}` : `/audit/stats`
|
|
}
|
|
|
|
export const getAuditStats = async (params?: GetAuditStatsParams, options?: RequestInit): Promise<GetAuditStats200> => {
|
|
|
|
return vezaMutator<GetAuditStats200>(getGetAuditStatsUrl(params),
|
|
{
|
|
...options,
|
|
method: 'GET'
|
|
|
|
|
|
}
|
|
);}
|
|
|
|
|
|
|
|
|
|
|
|
export const getGetAuditStatsQueryKey = (params?: GetAuditStatsParams,) => {
|
|
return [
|
|
`/audit/stats`, ...(params ? [params] : [])
|
|
] as const;
|
|
}
|
|
|
|
|
|
export const getGetAuditStatsQueryOptions = <TData = Awaited<ReturnType<typeof getAuditStats>>, TError = InternalHandlersAPIResponse>(params?: GetAuditStatsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditStats>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
|
|
) => {
|
|
|
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetAuditStatsQueryKey(params);
|
|
|
|
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getAuditStats>>> = ({ signal }) => getAuditStats(params, { signal, ...requestOptions });
|
|
|
|
|
|
|
|
|
|
|
|
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getAuditStats>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
}
|
|
|
|
export type GetAuditStatsQueryResult = NonNullable<Awaited<ReturnType<typeof getAuditStats>>>
|
|
export type GetAuditStatsQueryError = InternalHandlersAPIResponse
|
|
|
|
|
|
export function useGetAuditStats<TData = Awaited<ReturnType<typeof getAuditStats>>, TError = InternalHandlersAPIResponse>(
|
|
params: undefined | GetAuditStatsParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditStats>>, TError, TData>> & Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getAuditStats>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getAuditStats>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetAuditStats<TData = Awaited<ReturnType<typeof getAuditStats>>, TError = InternalHandlersAPIResponse>(
|
|
params?: GetAuditStatsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditStats>>, TError, TData>> & Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getAuditStats>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getAuditStats>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useGetAuditStats<TData = Awaited<ReturnType<typeof getAuditStats>>, TError = InternalHandlersAPIResponse>(
|
|
params?: GetAuditStatsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditStats>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
/**
|
|
* @summary Get audit statistics
|
|
*/
|
|
|
|
export function useGetAuditStats<TData = Awaited<ReturnType<typeof getAuditStats>>, TError = InternalHandlersAPIResponse>(
|
|
params?: GetAuditStatsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getAuditStats>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
|
|
const queryOptions = getGetAuditStatsQueryOptions(params,options)
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
return { ...query, queryKey: queryOptions.queryKey };
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|