@coderich/autograph 0.13.108 → 0.13.109

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coderich/autograph",
3
3
  "main": "index.js",
4
- "version": "0.13.108",
4
+ "version": "0.13.109",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -205,6 +205,7 @@ module.exports = class Schema {
205
205
  target.directives[name] = target.directives[name] || {};
206
206
 
207
207
  if (name === directives.model) {
208
+ model.isEntity = true;
208
209
  model.isMarkedModel = true;
209
210
  model.isEmbedded = false;
210
211
  } else if (name === directives.index) {
@@ -234,6 +235,7 @@ module.exports = class Schema {
234
235
  }
235
236
  case `${directives.model}-embed`: {
236
237
  model.isEmbedded = value;
238
+ model.isEntity = !value;
237
239
  break;
238
240
  }
239
241
  // Field specific directives
@@ -312,8 +314,6 @@ module.exports = class Schema {
312
314
 
313
315
  // Model resolution after field resolution (push)
314
316
  thunks.push(($schema) => {
315
- $model.isEntity = Boolean($model.isMarkedModel && !$model.isEmbedded);
316
-
317
317
  $model.resolvePath = (path, prop = 'name') => this.#schema.resolvePath(`${$model[prop]}.${path}`, prop);
318
318
 
319
319
  $model.isJoinPath = (path, prop = 'name') => {
@@ -611,8 +611,6 @@ module.exports = class Schema {
611
611
  },
612
612
  });
613
613
 
614
- // console.log(this.#schema.models.Person.referentialIntegrity);
615
-
616
614
  // Return schema
617
615
  return this.#schema;
618
616
  }
@@ -646,11 +644,11 @@ module.exports = class Schema {
646
644
 
647
645
  const arr = [];
648
646
 
649
- Object.values(this.#schema.models).forEach((m) => {
647
+ Object.values(this.#schema.models).filter(m => m.isEntity).forEach((m) => {
650
648
  Util.traverse(Object.values(m.fields), (f, info) => {
651
649
  const path = info.path.concat(f.name);
652
- if (f.isEmbedded) return { value: Object.values(f.model.fields), info: { path, isArray: info.isArray || f.isArray } };
653
650
  if (f.type === model.name) arr.push({ model: m, field, path: path.concat(`${field}`), isArray: info.isArray || field.isArray || f.isArray });
651
+ else if (f.isEmbedded) return { value: Object.values(f.model.fields), info: { path, isArray: info.isArray || f.isArray } };
654
652
  return null;
655
653
  }, { path: [], isArray: false });
656
654
  });