{"version":3,"file":"fields.js","names":[],"sources":["../../../../src/rest/commands/read/fields.ts"],"sourcesContent":["import type { DirectusField } from '../../../schema/field.js';\nimport type { ApplyQueryFields } from '../../../types/index.js';\nimport type { RestCommand } from '../../types.js';\nimport { throwIfEmpty } from '../../utils/index.js';\n\nexport type ReadFieldOutput> = ApplyQueryFields;\n\n/**\n * List the available fields.\n * @param query The query parameters\n * @returns An array of field objects.\n */\nexport const readFields =\n\t(): RestCommand[], Schema> =>\n\t() => ({\n\t\tpath: `/fields`,\n\t\tmethod: 'GET',\n\t});\n\n/**\n * List the available fields in a given collection.\n * @param collection The primary key of the field\n * @returns\n * @throws Will throw if collection is empty\n */\nexport const readFieldsByCollection =\n\t(collection: DirectusField['collection']): RestCommand[], Schema> =>\n\t() => {\n\t\tthrowIfEmpty(collection, 'Collection cannot be empty');\n\n\t\treturn {\n\t\t\tpath: `/fields/${collection}`,\n\t\t\tmethod: 'GET',\n\t\t};\n\t};\n\n/**\n *\n * @param key The primary key of the dashboard\n * @param query The query parameters\n * @returns\n * @throws Will throw if collection is empty\n * @throws Will throw if field is empty\n */\nexport const readField =\n\t(\n\t\tcollection: DirectusField['collection'],\n\t\tfield: DirectusField['field'],\n\t): RestCommand, Schema> =>\n\t() => {\n\t\tthrowIfEmpty(collection, 'Collection cannot be empty');\n\t\tthrowIfEmpty(field, 'Field cannot be empty');\n\n\t\treturn {\n\t\t\tpath: `/fields/${collection}/${field}`,\n\t\t\tmethod: 'GET',\n\t\t};\n\t};\n"],"mappings":"6DAYA,MAAa,WAEL,CACN,KAAM,UACN,OAAQ,MACR,EAQW,EACH,QAER,EAAa,EAAY,6BAA6B,CAE/C,CACN,KAAM,WAAW,IACjB,OAAQ,MACR,EAWU,GAEX,EACA,SAGA,EAAa,EAAY,6BAA6B,CACtD,EAAa,EAAO,wBAAwB,CAErC,CACN,KAAM,WAAW,EAAW,GAAG,IAC/B,OAAQ,MACR"}