/** * Provisions principals as authorization data, with no dependency on sessions or sign-in: the principals, principal_entities and principal_scope_overrides tables, the create/update/delete and scope mutations, the SPRT derivation that keeps a principal's capabilities in step with its owner, and the expiry sweep. The caller that opens the transaction sets jwt.claims.principal_id to a principal's user_id. Credentials for principals (API keys, child sessions, token exchange) are principal_auth_module, which builds on this one. * @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 { principalsModuleKeys } from '../query-keys'; import type { PrincipalsModuleSelect, PrincipalsModuleWithRelations, PrincipalsModuleFilter, PrincipalsModuleOrderBy, } from '../../orm/input-types'; import type { FindManyArgs, InferSelectResult, ConnectionResult, HookStrictSelect, } from '../../orm/select-types'; export type { PrincipalsModuleSelect, PrincipalsModuleWithRelations, PrincipalsModuleFilter, PrincipalsModuleOrderBy, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const principalsModulesQueryKey = principalsModuleKeys.list; /** * Provisions principals as authorization data, with no dependency on sessions or sign-in: the principals, principal_entities and principal_scope_overrides tables, the create/update/delete and scope mutations, the SPRT derivation that keeps a principal's capabilities in step with its owner, and the expiry sweep. The caller that opens the transaction sets jwt.claims.principal_id to a principal's user_id. Credentials for principals (API keys, child sessions, token exchange) are principal_auth_module, which builds on this one. * * @example * ```tsx * const { data, isLoading } = usePrincipalsModulesQuery({ * selection: { * fields: { id: true, name: true }, * where: { name: { equalTo: "example" } }, * orderBy: ['CREATED_AT_DESC'], * first: 10, * }, * }); * ``` */ export function usePrincipalsModulesQuery< S extends PrincipalsModuleSelect, TData = { principalsModules: ConnectionResult>; }, >( params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, PrincipalsModuleSelect>; } & Omit< UseQueryOptions< { principalsModules: ConnectionResult>; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function usePrincipalsModulesQuery( params: { selection: ListSelectionConfig< PrincipalsModuleSelect, PrincipalsModuleFilter, PrincipalsModuleOrderBy >; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildListSelectionArgs< PrincipalsModuleSelect, PrincipalsModuleFilter, PrincipalsModuleOrderBy >(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: principalsModuleKeys.list(args), queryFn: () => getClient().principalsModule.findMany(args).unwrap(), ...queryOptions, }); } /** * Provisions principals as authorization data, with no dependency on sessions or sign-in: the principals, principal_entities and principal_scope_overrides tables, the create/update/delete and scope mutations, the SPRT derivation that keeps a principal's capabilities in step with its owner, and the expiry sweep. The caller that opens the transaction sets jwt.claims.principal_id to a principal's user_id. Credentials for principals (API keys, child sessions, token exchange) are principal_auth_module, which builds on this one. * * @example * ```ts * const data = await fetchPrincipalsModulesQuery({ * selection: { * fields: { id: true }, * first: 10, * }, * }); * ``` */ export async function fetchPrincipalsModulesQuery(params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, PrincipalsModuleSelect>; }): Promise<{ principalsModules: ConnectionResult>; }>; export async function fetchPrincipalsModulesQuery(params: { selection: ListSelectionConfig< PrincipalsModuleSelect, PrincipalsModuleFilter, PrincipalsModuleOrderBy >; }) { const args = buildListSelectionArgs< PrincipalsModuleSelect, PrincipalsModuleFilter, PrincipalsModuleOrderBy >(params.selection); return getClient().principalsModule.findMany(args).unwrap(); } /** * Provisions principals as authorization data, with no dependency on sessions or sign-in: the principals, principal_entities and principal_scope_overrides tables, the create/update/delete and scope mutations, the SPRT derivation that keeps a principal's capabilities in step with its owner, and the expiry sweep. The caller that opens the transaction sets jwt.claims.principal_id to a principal's user_id. Credentials for principals (API keys, child sessions, token exchange) are principal_auth_module, which builds on this one. * * @example * ```ts * await prefetchPrincipalsModulesQuery(queryClient, { selection: { fields: { id: true }, first: 10 } }); * ``` */ export async function prefetchPrincipalsModulesQuery( queryClient: QueryClient, params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, PrincipalsModuleSelect>; } ): Promise; export async function prefetchPrincipalsModulesQuery( queryClient: QueryClient, params: { selection: ListSelectionConfig< PrincipalsModuleSelect, PrincipalsModuleFilter, PrincipalsModuleOrderBy >; } ): Promise { const args = buildListSelectionArgs< PrincipalsModuleSelect, PrincipalsModuleFilter, PrincipalsModuleOrderBy >(params.selection); await queryClient.prefetchQuery({ queryKey: principalsModuleKeys.list(args), queryFn: () => getClient().principalsModule.findMany(args).unwrap(), }); }