@almadar/core 10.51.0 → 10.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -188,13 +188,29 @@ function ownerFieldsFromSchema(schema) {
188
188
  const identity = identityEntityName(schema);
189
189
  if (identity === void 0) return [];
190
190
  const out = [];
191
- for (const def of inlineEntities(schema)) {
191
+ const defs = inlineEntities(schema);
192
+ const declaredByCollection = /* @__PURE__ */ new Map();
193
+ for (const def of defs) {
192
194
  for (const field of def.fields ?? []) {
193
195
  if (field.name && field.type === "relation" && field.relation.entity === identity) {
194
196
  out.push(`${def.name}.${field.name}`);
197
+ if (def.collection) {
198
+ const cols = declaredByCollection.get(def.collection) ?? [];
199
+ if (!cols.includes(field.name)) cols.push(field.name);
200
+ declaredByCollection.set(def.collection, cols);
201
+ }
195
202
  }
196
203
  }
197
204
  }
205
+ for (const def of defs) {
206
+ const cols = def.collection ? declaredByCollection.get(def.collection) : void 0;
207
+ if (!cols) continue;
208
+ for (const col of cols) {
209
+ const key = `${def.name}.${col}`;
210
+ if (out.includes(key)) continue;
211
+ if ((def.fields ?? []).some((f) => f.name === col)) out.push(key);
212
+ }
213
+ }
198
214
  return out;
199
215
  }
200
216