@coderich/autograph 0.13.27 → 0.13.28

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.27",
4
+ "version": "0.13.28",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -300,8 +300,8 @@ module.exports = class Resolver {
300
300
  return Emitter.emit(`pre${type}`, event).then(async (resultEarly) => {
301
301
  if (resultEarly !== undefined) return resultEarly; // Nothing to validate/transform
302
302
  // if (query.crud === 'update' && Util.isEqual({ added: {}, updated: {}, deleted: {} }, Util.changeset(query.doc, query.input))) return query.doc;
303
- const tquery = await $query.transform();
304
- // await Emitter.emit('validate', event); // We need to re-connect tquery to event
303
+ const tquery = await $query.transform(false);
304
+ await Emitter.emit('validate', event);
305
305
  return thunk(tquery);
306
306
  }).then((result) => {
307
307
  event.doc ??= result; // Case of create
@@ -62,12 +62,18 @@ module.exports = class Query {
62
62
  /**
63
63
  * Transform entire query via pipeline. At minimum, pipeline is needed to unflatten the data...
64
64
  */
65
- transform() {
65
+ transform(asClone = true) {
66
66
  return Promise.all([
67
67
  this.pipeline('input', this.#query.input),
68
68
  this.#query.isNative ? this.#query.where : this.pipeline('where', this.#query.where ?? {}),
69
69
  this.pipeline('sort', this.#query.sort),
70
- ]).then(([input, where, sort]) => this.clone({ input, where, sort }));
70
+ ]).then(([input, where, sort]) => {
71
+ if (asClone) return this.clone({ input, where, sort });
72
+ this.#query.input = input;
73
+ this.#query.where = where;
74
+ this.#query.sort = sort;
75
+ return this;
76
+ });
71
77
  }
72
78
 
73
79
  /**