{"version":3,"file":"panels.cjs","names":[],"sources":["../../../../src/rest/commands/update/panels.ts"],"sourcesContent":["import type { DirectusPanel } from '../../../schema/panel.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 UpdatePanelOutput<\n\tSchema,\n\tTQuery extends Query<Schema, Item>,\n\tItem extends object = DirectusPanel<Schema>,\n> = ApplyQueryFields<Schema, Item, TQuery['fields']>;\n\n/**\n * Update multiple existing panels.\n * @param keys\n * @param item\n * @param query\n * @returns Returns the panel objects for the updated panels.\n * @throws Will throw if keys is empty\n */\nexport const updatePanels =\n\t<Schema, const TQuery extends Query<Schema, DirectusPanel<Schema>>>(\n\t\tkeys: DirectusPanel<Schema>['id'][],\n\t\titem: NestedPartial<DirectusPanel<Schema>>,\n\t\tquery?: TQuery,\n\t): RestCommand<UpdatePanelOutput<Schema, TQuery>[], Schema> =>\n\t() => {\n\t\tthrowIfEmpty(keys, 'Keys cannot be empty');\n\n\t\treturn {\n\t\t\tpath: `/panels`,\n\t\t\tparams: query ?? {},\n\t\t\tbody: JSON.stringify({ keys, data: item }),\n\t\t\tmethod: 'PATCH',\n\t\t};\n\t};\n\n/**\n * Update multiple panels as batch.\n * @param items\n * @param query\n * @returns Returns the panel objects for the updated panels.\n */\nexport const updatePanelsBatch =\n\t<Schema, const TQuery extends Query<Schema, DirectusPanel<Schema>>>(\n\t\titems: NestedPartial<DirectusPanel<Schema>>[],\n\t\tquery?: TQuery,\n\t): RestCommand<UpdatePanelOutput<Schema, TQuery>[], Schema> =>\n\t() => ({\n\t\tpath: `/panels`,\n\t\tparams: query ?? {},\n\t\tbody: JSON.stringify(items),\n\t\tmethod: 'PATCH',\n\t});\n\n/**\n * Update an existing panel.\n * @param key\n * @param item\n * @param query\n * @returns Returns the panel object for the updated panel.\n * @throws Will throw if key is empty\n */\nexport const updatePanel =\n\t<Schema, const TQuery extends Query<Schema, DirectusPanel<Schema>>>(\n\t\tkey: DirectusPanel<Schema>['id'],\n\t\titem: NestedPartial<DirectusPanel<Schema>>,\n\t\tquery?: TQuery,\n\t): RestCommand<UpdatePanelOutput<Schema, TQuery>, Schema> =>\n\t() => {\n\t\tthrowIfEmpty(key, 'Key cannot be empty');\n\n\t\treturn {\n\t\t\tpath: `/panels/${key}`,\n\t\t\tparams: query ?? {},\n\t\t\tbody: JSON.stringify(item),\n\t\t\tmethod: 'PATCH',\n\t\t};\n\t};\n"],"mappings":"kDAmBa,GAEX,EACA,EACA,SAGA,EAAA,aAAa,EAAM,uBAAuB,CAEnC,CACN,KAAM,UACN,OAAQ,GAAS,EAAE,CACnB,KAAM,KAAK,UAAU,CAAE,OAAM,KAAM,EAAM,CAAC,CAC1C,OAAQ,QACR,EASU,GAEX,EACA,SAEM,CACN,KAAM,UACN,OAAQ,GAAS,EAAE,CACnB,KAAM,KAAK,UAAU,EAAM,CAC3B,OAAQ,QACR,EAUW,GAEX,EACA,EACA,SAGA,EAAA,aAAa,EAAK,sBAAsB,CAEjC,CACN,KAAM,WAAW,IACjB,OAAQ,GAAS,EAAE,CACnB,KAAM,KAAK,UAAU,EAAK,CAC1B,OAAQ,QACR"}