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