{"version":3,"file":"fields.cjs","names":[],"sources":["../../../../src/rest/commands/create/fields.ts"],"sourcesContent":["import type { DirectusField } from '../../../schema/field.js';\nimport type { ApplyQueryFields, FieldQuery, NestedPartial, Query } from '../../../types/index.js';\nimport type { RestCommand } from '../../types.js';\n\nexport type CreateFieldOutput<\n\tSchema,\n\tTQuery extends Query<Schema, Item>,\n\tItem extends object = DirectusField<Schema>,\n> = ApplyQueryFields<Schema, Item, TQuery['fields']>;\n\n/**\n * Create a new field in the given collection.\n *\n * @param collection The collection to create a field for\n * @param item The field to create\n * @param query Optional return data query\n *\n * @returns The field object for the created field.\n */\nexport const createField =\n\t<Schema, const TQuery extends FieldQuery<Schema, DirectusField<Schema>>>(\n\t\tcollection: keyof Schema,\n\t\titem: NestedPartial<DirectusField<Schema>>,\n\t\tquery?: TQuery,\n\t): RestCommand<CreateFieldOutput<Schema, TQuery>, Schema> =>\n\t() => ({\n\t\tpath: `/fields/${collection as string}`,\n\t\tparams: query ?? {},\n\t\tbody: JSON.stringify(item),\n\t\tmethod: 'POST',\n\t});\n"],"mappings":"AAmBA,MAAa,GAEX,EACA,EACA,SAEM,CACN,KAAM,WAAW,IACjB,OAAQ,GAAS,EAAE,CACnB,KAAM,KAAK,UAAU,EAAK,CAC1B,OAAQ,OACR"}