{"version":3,"file":"export.cjs","names":[],"sources":["../../../../src/rest/commands/utils/export.ts"],"sourcesContent":["import type { Query } from '../../../index.js';\nimport type { DirectusFile } from '../../../schema/file.js';\nimport type { RestCommand } from '../../types.js';\nimport { throwIfEmpty } from '../../utils/index.js';\n\nexport type FileFormat = 'csv' | 'csv_utf8' | 'json' | 'xml' | 'yaml';\n\n/**\n * Export a larger data set to a file in the File Library\n * @returns Nothing\n * @throws Will throw if collection is empty\n */\nexport const utilsExport =\n\t<Schema, TQuery extends Query<Schema, Schema[Collection]>, Collection extends keyof Schema>(\n\t\tcollection: Collection,\n\t\tformat: FileFormat,\n\t\tquery: TQuery,\n\t\tfile: Partial<DirectusFile<Schema>>,\n\t): RestCommand<void, Schema> =>\n\t() => {\n\t\tthrowIfEmpty(collection as string, 'Collection cannot be empty');\n\n\t\treturn {\n\t\t\tmethod: 'POST',\n\t\t\tpath: `/utils/export/${collection as string}`,\n\t\t\tbody: JSON.stringify({ format, query, file }),\n\t\t};\n\t};\n"],"mappings":"kDAYa,GAEX,EACA,EACA,EACA,SAGA,EAAA,aAAa,EAAsB,6BAA6B,CAEzD,CACN,OAAQ,OACR,KAAM,iBAAiB,IACvB,KAAM,KAAK,UAAU,CAAE,SAAQ,QAAO,OAAM,CAAC,CAC7C"}