veza/apps/web/src/services/generated/chat/chat.ts
senke a170504784
Some checks failed
Veza CI / Backend (Go) (push) Failing after 0s
Veza CI / Frontend (Web) (push) Failing after 0s
Veza CI / Rust (Stream Server) (push) Failing after 0s
Frontend CI / test (push) Failing after 0s
Security Scan / Secret Scanning (gitleaks) (push) Failing after 0s
Veza CI / Notify on failure (push) Failing after 0s
chore(web): install orval + mutator for OpenAPI code generation (v1.0.8 P1)
Phase 1 of the OpenAPI typegen migration. Brings orval@8.8.1 into the
monorepo (workspace-hoisted) and wires a custom mutator so generated
calls route through the existing Axios instance — interceptors for
auth / CSRF / retry / offline-queue / logging keep firing unchanged.

200 .ts files generated from veza-backend-api/openapi.yaml (3441 LOC),
covering 13 tags (auth, track, user, playlist, marketplace, chat,
dashboard, webhook, validation, logging, audit, comment, users).

Changes:

- apps/web/orval.config.ts (NEW): generator config, output
  src/services/generated/, tags-split mode, vezaMutator.
- apps/web/src/services/api/orval-mutator.ts (NEW): translates
  orval's (url, RequestInit) convention into AxiosRequestConfig
  then apiClient. Forwards AbortSignal for React Query cancellation.
- apps/web/scripts/generate-types.sh: runs BOTH generators during
  the migration (legacy typescript-axios + orval). B9 drops step 1.
- apps/web/scripts/check-types-sync.sh: extended to check drift on
  both output trees.
- apps/web/eslint.config.js: ignores src/services/generated/
  (orval emits overloaded function declarations that trip no-redeclare).
- .gitignore: narrowed the bare `api` SELinux rule to `/api` plus
  `/veza-backend-api/api`. The old rule silently ignored
  apps/web/src/services/api/ new files including orval-mutator.ts.
- apps/web/package.json + package-lock.json: orval@^8.8.1 added
  as devDependency, plus @commitlint/cli + @commitlint/config-conventional
  (referenced by .husky/commit-msg but missing from deps).

Out of scope: no hand-written service changes. Pilot developer.ts
lands in B2, bulk migration in B3-B8, cleanup in B9.

npm run typecheck and npm run lint both green (0 errors).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 00:18:14 +02:00

159 lines
4.8 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 {
GetChatToken200,
InternalHandlersAPIResponse
} from '../model';
import { vezaMutator } from '../../api/orval-mutator';
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
/**
* Generate a short-lived token for chat authentication
* @summary Get Chat Token
*/
export type getChatTokenResponse200 = {
data: GetChatToken200
status: 200
}
export type getChatTokenResponse401 = {
data: InternalHandlersAPIResponse
status: 401
}
export type getChatTokenResponse500 = {
data: InternalHandlersAPIResponse
status: 500
}
export type getChatTokenResponseSuccess = (getChatTokenResponse200) & {
headers: Headers;
};
export type getChatTokenResponseError = (getChatTokenResponse401 | getChatTokenResponse500) & {
headers: Headers;
};
export type getChatTokenResponse = (getChatTokenResponseSuccess | getChatTokenResponseError)
export const getGetChatTokenUrl = () => {
return `/chat/token`
}
export const getChatToken = async ( options?: RequestInit): Promise<getChatTokenResponse> => {
return vezaMutator<getChatTokenResponse>(getGetChatTokenUrl(),
{
...options,
method: 'GET'
}
);}
export const getGetChatTokenQueryKey = () => {
return [
`/chat/token`
] as const;
}
export const getGetChatTokenQueryOptions = <TData = Awaited<ReturnType<typeof getChatToken>>, TError = InternalHandlersAPIResponse>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChatToken>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
) => {
const {query: queryOptions, request: requestOptions} = options ?? {};
const queryKey = queryOptions?.queryKey ?? getGetChatTokenQueryKey();
const queryFn: QueryFunction<Awaited<ReturnType<typeof getChatToken>>> = ({ signal }) => getChatToken({ signal, ...requestOptions });
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getChatToken>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}
export type GetChatTokenQueryResult = NonNullable<Awaited<ReturnType<typeof getChatToken>>>
export type GetChatTokenQueryError = InternalHandlersAPIResponse
export function useGetChatToken<TData = Awaited<ReturnType<typeof getChatToken>>, TError = InternalHandlersAPIResponse>(
options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChatToken>>, TError, TData>> & Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof getChatToken>>,
TError,
Awaited<ReturnType<typeof getChatToken>>
> , 'initialData'
>, request?: SecondParameter<typeof vezaMutator>}
, queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetChatToken<TData = Awaited<ReturnType<typeof getChatToken>>, TError = InternalHandlersAPIResponse>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChatToken>>, TError, TData>> & Pick<
UndefinedInitialDataOptions<
Awaited<ReturnType<typeof getChatToken>>,
TError,
Awaited<ReturnType<typeof getChatToken>>
> , 'initialData'
>, request?: SecondParameter<typeof vezaMutator>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetChatToken<TData = Awaited<ReturnType<typeof getChatToken>>, TError = InternalHandlersAPIResponse>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChatToken>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
* @summary Get Chat Token
*/
export function useGetChatToken<TData = Awaited<ReturnType<typeof getChatToken>>, TError = InternalHandlersAPIResponse>(
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChatToken>>, TError, TData>>, request?: SecondParameter<typeof vezaMutator>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
const queryOptions = getGetChatTokenQueryOptions(options)
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
return { ...query, queryKey: queryOptions.queryKey };
}