UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.6 kB
{"version":3,"file":"deactivate-crop.mjs","names":[],"sources":["../../../../src/services/media/helpers/deactivate-crop.ts"],"sourcesContent":["import { MediaRepository } from \"../../../libs/repositories/index.js\";\nimport type { ServiceFn } from \"../../../utils/services/types.js\";\n\n/** Soft-deletes a source's crop while retaining its object and stale URL. */\nconst deactivateCrop: ServiceFn<\n\t[{ parentId: number; userId: number }],\n\tundefined\n> = async (context, data) => {\n\tconst Media = new MediaRepository(context.db.client, context.config.db);\n\tconst cropRes = await Media.updateSingle({\n\t\twhere: [\n\t\t\t{ key: \"parent_media_id\", operator: \"=\", value: data.parentId },\n\t\t\t{ key: \"relation_type\", operator: \"=\", value: \"crop\" },\n\t\t],\n\t\tdata: {\n\t\t\tis_deleted: true,\n\t\t\tis_deleted_at: new Date().toISOString(),\n\t\t\tdeleted_by: data.userId,\n\t\t\tupdated_at: new Date().toISOString(),\n\t\t\tupdated_by: data.userId,\n\t\t},\n\t\treturning: [\"id\"],\n\t});\n\tif (cropRes.error) return cropRes;\n\treturn { error: undefined, data: undefined };\n};\n\nexport default deactivateCrop;\n"],"mappings":"oDAIA,MAAM,EAGF,MAAO,EAAS,IAAS,CAE5B,IAAM,EAAU,MAAM,IADJ,EAAgB,EAAQ,GAAG,OAAQ,EAAQ,OAAO,EAC1C,CAAC,CAAC,aAAa,CACxC,MAAO,CACN,CAAE,IAAK,kBAAmB,SAAU,IAAK,MAAO,EAAK,QAAS,EAC9D,CAAE,IAAK,gBAAiB,SAAU,IAAK,MAAO,MAAO,CACtD,EACA,KAAM,CACL,WAAY,GACZ,cAAe,IAAI,KAAK,CAAA,CAAE,YAAY,EACtC,WAAY,EAAK,OACjB,WAAY,IAAI,KAAK,CAAA,CAAE,YAAY,EACnC,WAAY,EAAK,MAClB,EACA,UAAW,CAAC,IAAI,CACjB,CAAC,EAED,OADI,EAAQ,MAAc,EACnB,CAAE,MAAO,IAAA,GAAW,KAAM,IAAA,EAAU,CAC5C"}