@coderich/autograph 0.14.2 → 0.14.3

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.14.2",
4
+ "version": "0.14.3",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -245,7 +245,7 @@ module.exports = class Resolver {
245
245
  model = this.#schema.models[model];
246
246
 
247
247
  return Object.defineProperties(Util.map(result, (doc) => {
248
- const $doc = model.docTransform(doc);
248
+ const $doc = model.docTransform(doc, { resolver: this, context: this.#context });
249
249
 
250
250
  // Assign useful/needed meta data
251
251
  return Object.defineProperties($doc, {
@@ -473,15 +473,15 @@ module.exports = class Schema {
473
473
 
474
474
  // Deserialize/docs special case handling for performance
475
475
  const docFields = Object.values($model.fields);
476
- $model.docTransform = (doc) => {
476
+ $model.docTransform = (doc, args = {}) => {
477
477
  if (doc == null) return doc;
478
478
  const out = {};
479
479
  for (const docField of docFields) {
480
480
  let value = docField.key in doc ? doc[docField.key] : docField.defaultValue;
481
481
  if (value === undefined) continue; // eslint-disable-line
482
482
  if (docField.isArray) value = value == null ? value : Util.ensureArray(value);
483
- if (docField.isEmbedded) value = Util.map(value, v => docField.model.docTransform(v));
484
- if (docField.pipelines.deserialize.length) value = Pipeline.resolve({ model: $model, field: docField, value }, 'deserialize');
483
+ if (docField.isEmbedded) value = Util.map(value, v => docField.model.docTransform(v, args));
484
+ if (docField.pipelines.deserialize.length) value = Pipeline.resolve({ ...args, model: $model, field: docField, value }, 'deserialize');
485
485
  out[docField.name] = value;
486
486
  }
487
487
  return out;