{"version":3,"file":"collections.cjs","names":[],"sources":["../../../../src/rest/commands/update/collections.ts"],"sourcesContent":["import type { DirectusCollection } from '../../../schema/collection.js';\nimport type { ApplyQueryFields, NestedPartial, Query } from '../../../types/index.js';\nimport type { RestCommand } from '../../types.js';\nimport { throwIfEmpty } from '../../utils/index.js';\n\nexport type UpdateCollectionOutput<\n\tSchema,\n\tTQuery extends Query,\n\tItem extends object = DirectusCollection,\n> = ApplyQueryFields;\n\n/**\n * Update the metadata for an existing collection.\n * @param collection\n * @param item\n * @param query\n * @returns The collection object for the updated collection in this request.\n * @throws Will throw if collection is empty\n */\nexport const updateCollection =\n\t>>(\n\t\tcollection: DirectusCollection['collection'],\n\t\titem: NestedPartial>,\n\t\tquery?: TQuery,\n\t): RestCommand, Schema> =>\n\t() => {\n\t\tthrowIfEmpty(collection, 'Collection cannot be empty');\n\n\t\treturn {\n\t\t\tpath: `/collections/${collection}`,\n\t\t\tparams: query ?? {},\n\t\t\tbody: JSON.stringify(item),\n\t\t\tmethod: 'PATCH',\n\t\t};\n\t};\n\n/**\n * Update multiple collections as batch.\n * @param items\n * @param query\n * @returns Returns the collection objects for the updated collections.\n */\nexport const updateCollectionsBatch =\n\t>>(\n\t\titems: NestedPartial>[],\n\t\tquery?: TQuery,\n\t): RestCommand, Schema> =>\n\t() => ({\n\t\tpath: `/collections`,\n\t\tparams: query ?? {},\n\t\tbody: JSON.stringify(items),\n\t\tmethod: 'PATCH',\n\t});\n"],"mappings":"kDAmBa,GAEX,EACA,EACA,SAGA,EAAA,aAAa,EAAY,6BAA6B,CAE/C,CACN,KAAM,gBAAgB,IACtB,OAAQ,GAAS,EAAE,CACnB,KAAM,KAAK,UAAU,EAAK,CAC1B,OAAQ,QACR,EASU,GAEX,EACA,SAEM,CACN,KAAM,eACN,OAAQ,GAAS,EAAE,CACnB,KAAM,KAAK,UAAU,EAAM,CAC3B,OAAQ,QACR"}