@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.87 kB
Source Map (JSON)
{"version":3,"file":"delete-single-permanently.mjs","names":["mediaServices.checks.checkMediaAccess"],"sources":["../../../src/services/media/delete-single-permanently.ts"],"sourcesContent":["import executeHooks from \"../../libs/hooks/execute-hooks.js\";\nimport type { ServiceFn } from \"../../utils/services/types.js\";\nimport { mediaServices } from \"../index.js\";\nimport permanentlyDeleteMedia from \"./helpers/permanently-delete-media.js\";\n\nconst deleteSinglePermanently: ServiceFn<\n\t[\n\t\t{\n\t\t\tid: number;\n\t\t\tuserId: number;\n\t\t},\n\t],\n\tundefined\n> = async (context, data) => {\n\tconst accessRes = await mediaServices.checks.checkMediaAccess(context, {\n\t\tid: data.id,\n\t});\n\tif (accessRes.error) return accessRes;\n\n\tconst deleteRes = await permanentlyDeleteMedia(context, {\n\t\tid: data.id,\n\t});\n\tif (deleteRes.error) return deleteRes;\n\n\tconst hookRes = await executeHooks(\n\t\tcontext,\n\t\t{\n\t\t\tservice: \"media\",\n\t\t\tevent: \"afterDelete\",\n\t\t\tconfig: context.config,\n\t\t},\n\t\t{\n\t\t\tmeta: {\n\t\t\t\ttenantKey: context.request.tenantKey ?? null,\n\t\t\t},\n\t\t\tdata: {\n\t\t\t\tids: [data.id],\n\t\t\t\tuserId: data.userId,\n\t\t\t\thardDelete: true,\n\t\t\t},\n\t\t},\n\t);\n\tif (hookRes.error) return hookRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: undefined,\n\t};\n};\n\nexport default deleteSinglePermanently;\n"],"mappings":"uJAKA,MAAM,EAQF,MAAO,EAAS,IAAS,CAC5B,IAAM,EAAY,MAAMA,EAAsC,EAAS,CACtE,GAAI,EAAK,EACV,CAAC,EACD,GAAI,EAAU,MAAO,OAAO,EAE5B,IAAM,EAAY,MAAM,EAAuB,EAAS,CACvD,GAAI,EAAK,EACV,CAAC,EACD,GAAI,EAAU,MAAO,OAAO,EAE5B,IAAM,EAAU,MAAM,EACrB,EACA,CACC,QAAS,QACT,MAAO,cACP,OAAQ,EAAQ,MACjB,EACA,CACC,KAAM,CACL,UAAW,EAAQ,QAAQ,WAAa,IACzC,EACA,KAAM,CACL,IAAK,CAAC,EAAK,EAAE,EACb,OAAQ,EAAK,OACb,WAAY,EACb,CACD,CACD,EAGA,OAFI,EAAQ,MAAc,EAEnB,CACN,MAAO,IAAA,GACP,KAAM,IAAA,EACP,CACD"}