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.56 kB
{"version":3,"file":"delete-single.mjs","names":[],"sources":["../../../src/services/client-integrations/delete-single.ts"],"sourcesContent":["import { ClientIntegrationsRepository } from \"../../libs/repositories/index.js\";\nimport type { ServiceFn } from \"../../utils/services/types.js\";\nimport checkIntegrationAccess from \"./checks/check-integration-access.js\";\n\nconst deleteSingle: ServiceFn<\n\t[\n\t\t{\n\t\t\tid: number;\n\t\t},\n\t],\n\tundefined\n> = async (context, data) => {\n\tconst ClientIntegrations = new ClientIntegrationsRepository(\n\t\tcontext.db.client,\n\t\tcontext.config.db,\n\t);\n\n\tconst checkExistsRes = await checkIntegrationAccess(context, {\n\t\tid: data.id,\n\t});\n\tif (checkExistsRes.error) return checkExistsRes;\n\n\tconst deleteRes = await ClientIntegrations.deleteSingle({\n\t\twhere: [\n\t\t\t{\n\t\t\t\tkey: \"id\",\n\t\t\t\toperator: \"=\",\n\t\t\t\tvalue: data.id,\n\t\t\t},\n\t\t],\n\t\treturning: [\"id\"],\n\t\tvalidation: {\n\t\t\tenabled: true,\n\t\t},\n\t});\n\tif (deleteRes.error) return deleteRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: undefined,\n\t};\n};\n\nexport default deleteSingle;\n"],"mappings":"oHAIA,MAAM,EAOF,MAAO,EAAS,IAAS,CAC5B,IAAM,EAAqB,IAAI,EAC9B,EAAQ,GAAG,OACX,EAAQ,OAAO,EAChB,EAEM,EAAiB,MAAM,EAAuB,EAAS,CAC5D,GAAI,EAAK,EACV,CAAC,EACD,GAAI,EAAe,MAAO,OAAO,EAEjC,IAAM,EAAY,MAAM,EAAmB,aAAa,CACvD,MAAO,CACN,CACC,IAAK,KACL,SAAU,IACV,MAAO,EAAK,EACb,CACD,EACA,UAAW,CAAC,IAAI,EAChB,WAAY,CACX,QAAS,EACV,CACD,CAAC,EAGD,OAFI,EAAU,MAAc,EAErB,CACN,MAAO,IAAA,GACP,KAAM,IAAA,EACP,CACD"}