@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.83 kB
Source Map (JSON)
{"version":3,"file":"check-integration-access.mjs","names":[],"sources":["../../../../src/services/client-integrations/checks/check-integration-access.ts"],"sourcesContent":["import { copy } from \"../../../libs/i18n/index.js\";\nimport { ClientIntegrationsRepository } from \"../../../libs/repositories/index.js\";\nimport type { ServiceFn } from \"../../../utils/services/types.js\";\n\n/**\n * Loads a client integration through the current tenant scope.\n * Global integrations remain visible to tenant requests.\n */\nconst checkIntegrationAccess: ServiceFn<\n\t[\n\t\t{\n\t\t\tid: number;\n\t\t},\n\t],\n\t{\n\t\tid: number;\n\t\tkey: string;\n\t\ttenant_key: string | null;\n\t}\n> = async (context, data) => {\n\tconst ClientIntegrations = new ClientIntegrationsRepository(\n\t\tcontext.db.client,\n\t\tcontext.config.db,\n\t);\n\n\tconst integrationRes = await ClientIntegrations.selectSingleByIdWithScopes({\n\t\tid: data.id,\n\t\ttenantKey: context.request.tenantKey,\n\t\tvalidation: {\n\t\t\tenabled: true,\n\t\t\tdefaultError: {\n\t\t\t\tmessage: copy(\"server:core.client.integrations.not.found.message\"),\n\t\t\t\tstatus: 404,\n\t\t\t},\n\t\t},\n\t});\n\tif (integrationRes.error) return integrationRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: {\n\t\t\tid: integrationRes.data.id,\n\t\t\tkey: integrationRes.data.key,\n\t\t\ttenant_key: integrationRes.data.tenant_key,\n\t\t},\n\t};\n};\n\nexport default checkIntegrationAccess;\n"],"mappings":"qHAQA,MAAM,EAWF,MAAO,EAAS,IAAS,CAM5B,IAAM,EAAiB,MAAM,IALE,EAC9B,EAAQ,GAAG,OACX,EAAQ,OAAO,EAG8B,CAAC,CAAC,2BAA2B,CAC1E,GAAI,EAAK,GACT,UAAW,EAAQ,QAAQ,UAC3B,WAAY,CACX,QAAS,GACT,aAAc,CACb,QAAS,EAAK,mDAAmD,EACjE,OAAQ,GACT,CACD,CACD,CAAC,EAGD,OAFI,EAAe,MAAc,EAE1B,CACN,MAAO,IAAA,GACP,KAAM,CACL,GAAI,EAAe,KAAK,GACxB,IAAK,EAAe,KAAK,IACzB,WAAY,EAAe,KAAK,UACjC,CACD,CACD"}