@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.86 kB
Source Map (JSON)
{"version":3,"file":"check-folder-access.mjs","names":[],"sources":["../../../../src/services/media-folders/checks/check-folder-access.ts"],"sourcesContent":["import { copy } from \"../../../libs/i18n/index.js\";\nimport { MediaFoldersRepository } from \"../../../libs/repositories/index.js\";\nimport type { ServiceFn } from \"../../../utils/services/types.js\";\n\n/**\n * Confirms a folder is visible in the current tenant scope before media is linked to it.\n * Global folders are visible to tenant requests, matching other tenant-scoped resources.\n */\nconst checkFolderAccess: ServiceFn<\n\t[\n\t\t{\n\t\t\tfolderId?: number | null;\n\t\t},\n\t],\n\t{ id: number; tenant_key: string | null } | undefined\n> = async (context, data) => {\n\tif (data.folderId === undefined || data.folderId === null) {\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\tconst MediaFolders = new MediaFoldersRepository(\n\t\tcontext.db.client,\n\t\tcontext.config.db,\n\t);\n\n\tconst folderRes = await MediaFolders.selectSingleById({\n\t\tid: data.folderId,\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.media.folders.not.found.message\"),\n\t\t\t\tstatus: 404,\n\t\t\t},\n\t\t},\n\t});\n\tif (folderRes.error) return folderRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: folderRes.data,\n\t};\n};\n\nexport default checkFolderAccess;\n"],"mappings":"+GAQA,MAAM,EAOF,MAAO,EAAS,IAAS,CAC5B,GAAI,EAAK,WAAa,IAAA,IAAa,EAAK,WAAa,KACpD,MAAO,CACN,MAAO,IAAA,GACP,KAAM,IAAA,EACP,EAQD,IAAM,EAAY,MAAM,IALC,EACxB,EAAQ,GAAG,OACX,EAAQ,OAAO,EAGmB,CAAC,CAAC,iBAAiB,CACrD,GAAI,EAAK,SACT,UAAW,EAAQ,QAAQ,UAC3B,WAAY,CACX,QAAS,GACT,aAAc,CACb,QAAS,EAAK,6CAA6C,EAC3D,OAAQ,GACT,CACD,CACD,CAAC,EAGD,OAFI,EAAU,MAAc,EAErB,CACN,MAAO,IAAA,GACP,KAAM,EAAU,IACjB,CACD"}