@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.73 kB
Source Map (JSON)
{"version":3,"file":"delete.mjs","names":["mediaServices.checks.checkHasMediaStrategy"],"sources":["../../../../src/services/media/strategies/delete.ts"],"sourcesContent":["import { resolveMediaKeyTenant } from \"../../../utils/media/index.js\";\nimport type { ServiceFn } from \"../../../utils/services/types.js\";\nimport { mediaServices } from \"../../index.js\";\nimport adjustStorageUsage from \"../adjust-storage-usage.js\";\n\nconst deleteObject: ServiceFn<\n\t[\n\t\t{\n\t\t\tkey: string;\n\t\t\tsize: number;\n\t\t\tprocessedSize: number;\n\t\t\ttenantKey?: string | null;\n\t\t},\n\t],\n\tundefined\n> = async (context, data) => {\n\tconst mediaStrategyRes =\n\t\tawait mediaServices.checks.checkHasMediaStrategy(context);\n\tif (mediaStrategyRes.error) return mediaStrategyRes;\n\n\tconst tenant = resolveMediaKeyTenant(context.config, data.key);\n\n\tconst [_, updateStorageRes] = await Promise.all([\n\t\tmediaStrategyRes.data.delete(context, {\n\t\t\tkey: data.key,\n\t\t\ttenant,\n\t\t}),\n\t\tadjustStorageUsage(context, {\n\t\t\ttenantKey: data.tenantKey ?? null,\n\t\t\tdelta: -(data.size + data.processedSize),\n\t\t\tmin: 0,\n\t\t}),\n\t]);\n\tif (updateStorageRes.error) return updateStorageRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: undefined,\n\t};\n};\n\nexport default deleteObject;\n"],"mappings":"mLAKA,MAAM,EAUF,MAAO,EAAS,IAAS,CAC5B,IAAM,EACL,MAAMA,EAA2C,CAAO,EACzD,GAAI,EAAiB,MAAO,OAAO,EAEnC,IAAM,EAAS,EAAsB,EAAQ,OAAQ,EAAK,GAAG,EAEvD,CAAC,EAAG,GAAoB,MAAM,QAAQ,IAAI,CAC/C,EAAiB,KAAK,OAAO,EAAS,CACrC,IAAK,EAAK,IACV,QACD,CAAC,EACD,EAAmB,EAAS,CAC3B,UAAW,EAAK,WAAa,KAC7B,MAAO,EAAE,EAAK,KAAO,EAAK,eAC1B,IAAK,CACN,CAAC,CACF,CAAC,EAGD,OAFI,EAAiB,MAAc,EAE5B,CACN,MAAO,IAAA,GACP,KAAM,IAAA,EACP,CACD"}