{"version":3,"file":"items.cjs","names":["payload: Record<string, any>"],"sources":["../../../../src/rest/commands/delete/items.ts"],"sourcesContent":["import type { Query } from '../../../types/index.js';\nimport type { RestCommand } from '../../types.js';\nimport { throwIfCoreCollection, throwIfEmpty } from '../../utils/index.js';\n\n/**\n * Delete multiple existing items.\n *\n * @param collection The collection of the items\n * @param keysOrQuery The primary keys or a query\n *\n * @returns Nothing\n * @throws Will throw if collection is empty\n * @throws Will throw if collection is a core collection\n * @throws Will throw if keysOrQuery is empty\n */\nexport const deleteItems =\n\t<Schema, Collection extends keyof Schema, const TQuery extends Query<Schema, Schema[Collection]>>(\n\t\tcollection: Collection,\n\t\tkeysOrQuery: string[] | number[] | TQuery,\n\t): RestCommand<void, Schema> =>\n\t() => {\n\t\tlet payload: Record<string, any> = {};\n\n\t\tthrowIfEmpty(String(collection), 'Collection cannot be empty');\n\t\tthrowIfCoreCollection(collection, 'Cannot use deleteItems for core collections');\n\n\t\tif (Array.isArray(keysOrQuery)) {\n\t\t\tthrowIfEmpty(keysOrQuery, 'keysOrQuery cannot be empty');\n\t\t\tpayload = { keys: keysOrQuery };\n\t\t} else {\n\t\t\tthrowIfEmpty(Object.keys(keysOrQuery), 'keysOrQuery cannot be empty');\n\t\t\tpayload = { query: keysOrQuery };\n\t\t}\n\n\t\treturn {\n\t\t\tpath: `/items/${collection as string}`,\n\t\t\tbody: JSON.stringify(payload),\n\t\t\tmethod: 'DELETE',\n\t\t};\n\t};\n\n/**\n * Delete an existing item.\n *\n * @param collection The collection of the item\n * @param key The primary key of the item\n *\n * @returns Nothing\n * @throws Will throw if collection is empty\n * @throws Will throw if collection is a core collection\n * @throws Will throw if key is empty\n */\nexport const deleteItem =\n\t<Schema, Collection extends keyof Schema>(collection: Collection, key: string | number): RestCommand<void, Schema> =>\n\t() => {\n\t\tthrowIfEmpty(String(collection), 'Collection cannot be empty');\n\t\tthrowIfCoreCollection(collection, 'Cannot use deleteItem for core collections');\n\t\tthrowIfEmpty(String(key), 'Key cannot be empty');\n\n\t\treturn {\n\t\t\tpath: `/items/${collection as string}/${key}`,\n\t\t\tmethod: 'DELETE',\n\t\t};\n\t};\n"],"mappings":"qGAea,GAEX,EACA,QAEK,CACL,IAAIA,EAA+B,EAAE,CAarC,OAXA,EAAA,aAAa,OAAO,EAAW,CAAE,6BAA6B,CAC9D,EAAA,sBAAsB,EAAY,8CAA8C,CAE5E,MAAM,QAAQ,EAAY,EAC7B,EAAA,aAAa,EAAa,8BAA8B,CACxD,EAAU,CAAE,KAAM,EAAa,GAE/B,EAAA,aAAa,OAAO,KAAK,EAAY,CAAE,8BAA8B,CACrE,EAAU,CAAE,MAAO,EAAa,EAG1B,CACN,KAAM,UAAU,IAChB,KAAM,KAAK,UAAU,EAAQ,CAC7B,OAAQ,SACR,EAcU,GAC8B,EAAwB,SAEjE,EAAA,aAAa,OAAO,EAAW,CAAE,6BAA6B,CAC9D,EAAA,sBAAsB,EAAY,6CAA6C,CAC/E,EAAA,aAAa,OAAO,EAAI,CAAE,sBAAsB,CAEzC,CACN,KAAM,UAAU,EAAqB,GAAG,IACxC,OAAQ,SACR"}