/** * Function schedules — user-facing cron schedules synced into the worker scheduler (app_jobs.scheduled_jobs) * @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 { functionScheduleKeys } from '../query-keys'; import type { FunctionScheduleSelect, FunctionScheduleWithRelations, FunctionScheduleFilter, FunctionScheduleOrderBy, } from '../../orm/input-types'; import type { FindManyArgs, InferSelectResult, ConnectionResult, HookStrictSelect, } from '../../orm/select-types'; export type { FunctionScheduleSelect, FunctionScheduleWithRelations, FunctionScheduleFilter, FunctionScheduleOrderBy, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const functionSchedulesQueryKey = functionScheduleKeys.list; /** * Function schedules — user-facing cron schedules synced into the worker scheduler (app_jobs.scheduled_jobs) * * @example * ```tsx * const { data, isLoading } = useFunctionSchedulesQuery({ * selection: { * fields: { id: true, name: true }, * where: { name: { equalTo: "example" } }, * orderBy: ['CREATED_AT_DESC'], * first: 10, * }, * }); * ``` */ export function useFunctionSchedulesQuery< S extends FunctionScheduleSelect, TData = { functionSchedules: ConnectionResult>; }, >( params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, FunctionScheduleSelect>; } & Omit< UseQueryOptions< { functionSchedules: ConnectionResult>; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useFunctionSchedulesQuery( params: { selection: ListSelectionConfig< FunctionScheduleSelect, FunctionScheduleFilter, FunctionScheduleOrderBy >; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildListSelectionArgs< FunctionScheduleSelect, FunctionScheduleFilter, FunctionScheduleOrderBy >(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: functionScheduleKeys.list(args), queryFn: () => getClient().functionSchedule.findMany(args).unwrap(), ...queryOptions, }); } /** * Function schedules — user-facing cron schedules synced into the worker scheduler (app_jobs.scheduled_jobs) * * @example * ```ts * const data = await fetchFunctionSchedulesQuery({ * selection: { * fields: { id: true }, * first: 10, * }, * }); * ``` */ export async function fetchFunctionSchedulesQuery(params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, FunctionScheduleSelect>; }): Promise<{ functionSchedules: ConnectionResult>; }>; export async function fetchFunctionSchedulesQuery(params: { selection: ListSelectionConfig< FunctionScheduleSelect, FunctionScheduleFilter, FunctionScheduleOrderBy >; }) { const args = buildListSelectionArgs< FunctionScheduleSelect, FunctionScheduleFilter, FunctionScheduleOrderBy >(params.selection); return getClient().functionSchedule.findMany(args).unwrap(); } /** * Function schedules — user-facing cron schedules synced into the worker scheduler (app_jobs.scheduled_jobs) * * @example * ```ts * await prefetchFunctionSchedulesQuery(queryClient, { selection: { fields: { id: true }, first: 10 } }); * ``` */ export async function prefetchFunctionSchedulesQuery( queryClient: QueryClient, params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, FunctionScheduleSelect>; } ): Promise; export async function prefetchFunctionSchedulesQuery( queryClient: QueryClient, params: { selection: ListSelectionConfig< FunctionScheduleSelect, FunctionScheduleFilter, FunctionScheduleOrderBy >; } ): Promise { const args = buildListSelectionArgs< FunctionScheduleSelect, FunctionScheduleFilter, FunctionScheduleOrderBy >(params.selection); await queryClient.prefetchQuery({ queryKey: functionScheduleKeys.list(args), queryFn: () => getClient().functionSchedule.findMany(args).unwrap(), }); }