@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 1.48 kB
JavaScript
import{getFieldDatabaseConfig as e,isStorageMode as t}from"../../../libs/collection/custom-fields/storage/index.mjs";const n=(n,r)=>{let i=e(r.type);if(!i||!t(i,`relation-table`))return null;let a=r.key.fieldPath?.[r.key.fieldPath.length-1];if(!a)return null;let o=r.key.brick?n.brickInstances.find(e=>e.key===r.key.brick):n;return o?o.fields.get(a)??null:null},r=e=>typeof e.config==`object`&&e.config!==null&&`multiple`in e.config,i=(e,t,i)=>{let a=n(e,t);return!a||i.position===0||!r(a)?!1:a.config.multiple!==!0},a=(e,t,n)=>{e[t]===void 0&&(e[t]=[]);let r=e[t]?.find(e=>e.table===n.table);r||(r={table:n.table,values:new Set},e[t]?.push(r)),r.values.add(n.value)},o=(e,t)=>t.includeTypes===void 0?t.excludeTypes?.includes(e)!==!0:t.includeTypes.includes(e),s=async(e,t)=>{let r={};for(let e of t.responses)for(let s of t.brickSchema){let c=e[s.name];if(!c||!Array.isArray(c)||c.length===0)continue;let l=n(t.collection,s);for(let e of c)if(!i(t.collection,s,e)){for(let n of s.columns){if(n.source===`core`||n.foreignKey===void 0||n.customField===void 0)continue;let i=e[n.name];if(i==null)continue;let s=n.customField.type,c=n.foreignKey.table;o(s,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes})&&a(r,s,{table:c,value:i})}if(l&&o(l.type,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes}))for(let t of l.getRelationFieldRefTargets(e))a(r,l.type,t)}}return{data:r,error:void 0}};export{s as default};
//# sourceMappingURL=extract-related-entity-ids.mjs.map