/** * 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 { buildListSelectionArgs } from '../selection'; import type { ListSelectionConfig } from '../selection'; import { resourceEventKeys } from '../query-keys'; import type { ResourceEventSelect, ResourceEventWithRelations, ResourceEventFilter, ResourceEventOrderBy, } from '../../orm/input-types'; import type { FindManyArgs, InferSelectResult, ConnectionResult, HookStrictSelect, } from '../../orm/select-types'; export type { ResourceEventSelect, ResourceEventWithRelations, ResourceEventFilter, ResourceEventOrderBy, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const resourceEventsQueryKey = resourceEventKeys.list; /** * Resource lifecycle events — audit log of provisioning, updates, and failure events * * @example * ```tsx * const { data, isLoading } = useResourceEventsQuery({ * selection: { * fields: { id: true, name: true }, * where: { name: { equalTo: "example" } }, * orderBy: ['CREATED_AT_DESC'], * first: 10, * }, * }); * ``` */ export function useResourceEventsQuery< S extends ResourceEventSelect, TData = { resourceEvents: ConnectionResult>; }, >( params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, ResourceEventSelect>; } & Omit< UseQueryOptions< { resourceEvents: ConnectionResult>; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useResourceEventsQuery( params: { selection: ListSelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildListSelectionArgs< ResourceEventSelect, ResourceEventFilter, ResourceEventOrderBy >(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: resourceEventKeys.list(args), queryFn: () => getClient().resourceEvent.findMany(args).unwrap(), ...queryOptions, }); } /** * Resource lifecycle events — audit log of provisioning, updates, and failure events * * @example * ```ts * const data = await fetchResourceEventsQuery({ * selection: { * fields: { id: true }, * first: 10, * }, * }); * ``` */ export async function fetchResourceEventsQuery(params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, ResourceEventSelect>; }): Promise<{ resourceEvents: ConnectionResult>; }>; export async function fetchResourceEventsQuery(params: { selection: ListSelectionConfig; }) { const args = buildListSelectionArgs< ResourceEventSelect, ResourceEventFilter, ResourceEventOrderBy >(params.selection); return getClient().resourceEvent.findMany(args).unwrap(); } /** * Resource lifecycle events — audit log of provisioning, updates, and failure events * * @example * ```ts * await prefetchResourceEventsQuery(queryClient, { selection: { fields: { id: true }, first: 10 } }); * ``` */ export async function prefetchResourceEventsQuery( queryClient: QueryClient, params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, ResourceEventSelect>; } ): Promise; export async function prefetchResourceEventsQuery( queryClient: QueryClient, params: { selection: ListSelectionConfig; } ): Promise { const args = buildListSelectionArgs< ResourceEventSelect, ResourceEventFilter, ResourceEventOrderBy >(params.selection); await queryClient.prefetchQuery({ queryKey: resourceEventKeys.list(args), queryFn: () => getClient().resourceEvent.findMany(args).unwrap(), }); }