/** * Resource lifecycle events — audit log of provisioning, updates, and failure events * @generated by @constructive-io/graphql-codegen * DO NOT EDIT - changes will be overwritten */ import { useQuery } from '@tanstack/react-query'; import type { UseQueryOptions, UseQueryResult, QueryClient } from '@tanstack/react-query'; import { getClient } from '../client'; import { buildSelectionArgs } from '../selection'; import type { SelectionConfig } from '../selection'; import { resourceEventKeys } from '../query-keys'; import type { ResourceEventSelect, ResourceEventWithRelations } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { ResourceEventSelect, ResourceEventWithRelations } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const resourceEventQueryKey = resourceEventKeys.detail; /** * Resource lifecycle events — audit log of provisioning, updates, and failure events * * @example * ```tsx * const { data, isLoading } = useResourceEventQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function useResourceEventQuery< S extends ResourceEventSelect, TData = { resourceEvent: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, ResourceEventSelect>; } & Omit< UseQueryOptions< { resourceEvent: InferSelectResult | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useResourceEventQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: resourceEventKeys.detail(params.id), queryFn: () => getClient() .resourceEvent.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Resource lifecycle events — audit log of provisioning, updates, and failure events * * @example * ```ts * const data = await fetchResourceEventQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchResourceEventQuery(params: { id: string; selection: { fields: S; } & HookStrictSelect, ResourceEventSelect>; }): Promise<{ resourceEvent: InferSelectResult | null; }>; export async function fetchResourceEventQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .resourceEvent.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Resource lifecycle events — audit log of provisioning, updates, and failure events * * @example * ```ts * await prefetchResourceEventQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchResourceEventQuery( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, ResourceEventSelect>; } ): Promise; export async function prefetchResourceEventQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: resourceEventKeys.detail(params.id), queryFn: () => getClient() .resourceEvent.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }