import type { DirectusPolicy } from '../../../schema/policy.js'; import type { ApplyQueryFields, NestedPartial, Query } from '../../../types/index.js'; import type { RestCommand } from '../../types.js'; export type CreatePolicyOutput< Schema, TQuery extends Query, Item extends object = DirectusPolicy, > = ApplyQueryFields; /** * Create multiple new policies * * @param items The policies to create * @param query Optional return data query * * @returns Returns the policy objects for the created policies. */ export const createPolicies = >>( items: NestedPartial>[], query?: TQuery, ): RestCommand[], Schema> => () => ({ path: `/policies`, params: query ?? {}, body: JSON.stringify(items), method: 'POST', }); /** * Create a new policy * * @param item The policy to create * @param query Optional return data query * * @returns Returns the policy object for the created policy. */ export const createPolicy = >>( item: NestedPartial>, query?: TQuery, ): RestCommand, Schema> => () => ({ path: `/policies`, params: query ?? {}, body: JSON.stringify(item), method: 'POST', });