/** * Provisions security, fields, grants, and policies onto a table. Each row can independently: (1) create fields via nodes[] array (supporting multiple Data* modules per row), (2) grant privileges via grants[] array (supporting per-role privilege targeting), (3) create RLS policies via policies[] array (supporting multiple Authz* policies per row). Multiple rows can target the same table to compose different concerns. All three concerns are optional and independent. The target table is addressed by table_id, by table_name, or symbolically by a module reference in module. A row that lists a concern in owns[] replaces that concern on the target table instead of composing with what is already there. * @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 { secureTableProvisionKeys } from '../query-keys'; import type { SecureTableProvisionSelect, SecureTableProvisionWithRelations, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { SecureTableProvisionSelect, SecureTableProvisionWithRelations, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const secureTableProvisionQueryKey = secureTableProvisionKeys.detail; /** * Provisions security, fields, grants, and policies onto a table. Each row can independently: (1) create fields via nodes[] array (supporting multiple Data* modules per row), (2) grant privileges via grants[] array (supporting per-role privilege targeting), (3) create RLS policies via policies[] array (supporting multiple Authz* policies per row). Multiple rows can target the same table to compose different concerns. All three concerns are optional and independent. The target table is addressed by table_id, by table_name, or symbolically by a module reference in module. A row that lists a concern in owns[] replaces that concern on the target table instead of composing with what is already there. * * @example * ```tsx * const { data, isLoading } = useSecureTableProvisionQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function useSecureTableProvisionQuery< S extends SecureTableProvisionSelect, TData = { secureTableProvision: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, SecureTableProvisionSelect>; } & Omit< UseQueryOptions< { secureTableProvision: InferSelectResult | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useSecureTableProvisionQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: secureTableProvisionKeys.detail(params.id), queryFn: () => getClient() .secureTableProvision.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Provisions security, fields, grants, and policies onto a table. Each row can independently: (1) create fields via nodes[] array (supporting multiple Data* modules per row), (2) grant privileges via grants[] array (supporting per-role privilege targeting), (3) create RLS policies via policies[] array (supporting multiple Authz* policies per row). Multiple rows can target the same table to compose different concerns. All three concerns are optional and independent. The target table is addressed by table_id, by table_name, or symbolically by a module reference in module. A row that lists a concern in owns[] replaces that concern on the target table instead of composing with what is already there. * * @example * ```ts * const data = await fetchSecureTableProvisionQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchSecureTableProvisionQuery(params: { id: string; selection: { fields: S; } & HookStrictSelect, SecureTableProvisionSelect>; }): Promise<{ secureTableProvision: InferSelectResult | null; }>; export async function fetchSecureTableProvisionQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .secureTableProvision.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Provisions security, fields, grants, and policies onto a table. Each row can independently: (1) create fields via nodes[] array (supporting multiple Data* modules per row), (2) grant privileges via grants[] array (supporting per-role privilege targeting), (3) create RLS policies via policies[] array (supporting multiple Authz* policies per row). Multiple rows can target the same table to compose different concerns. All three concerns are optional and independent. The target table is addressed by table_id, by table_name, or symbolically by a module reference in module. A row that lists a concern in owns[] replaces that concern on the target table instead of composing with what is already there. * * @example * ```ts * await prefetchSecureTableProvisionQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchSecureTableProvisionQuery( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, SecureTableProvisionSelect>; } ): Promise; export async function prefetchSecureTableProvisionQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: secureTableProvisionKeys.detail(params.id), queryFn: () => getClient() .secureTableProvision.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }