@nextage/nx-frame-be 1.0.10 → 1.0.12

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.
@@ -64,7 +64,7 @@ export declare abstract class BaseController<TAttrs, TDoc extends BaseMongoDoc,
64
64
  * @param item
65
65
  * @param context
66
66
  */
67
- protected parseItem(item: TAttrs, context: NxContext): void;
67
+ protected parseItem(item: TAttrs, context: NxContext): Promise<void>;
68
68
  /**
69
69
  *
70
70
  * @param params
@@ -58,6 +58,8 @@ class BaseController {
58
58
  * @param context
59
59
  */
60
60
  parseItem(item, context) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ });
61
63
  }
62
64
  /**
63
65
  *
@@ -75,8 +77,10 @@ class BaseController {
75
77
  * @returns
76
78
  */
77
79
  create(item, context) {
78
- this.parseItem(item, context);
79
- return this.model.create(item, context);
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ yield this.parseItem(item, context);
82
+ return this.model.create(item, context);
83
+ });
80
84
  }
81
85
  /**
82
86
  *
@@ -86,8 +90,10 @@ class BaseController {
86
90
  * @returns
87
91
  */
88
92
  update(id, item, context) {
89
- this.parseItem(item, context);
90
- return this.model.update(id, item, this.mergeUpdate, context);
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ yield this.parseItem(item, context);
95
+ return this.model.update(id, item, this.mergeUpdate, context);
96
+ });
91
97
  }
92
98
  /**
93
99
  *
@@ -432,8 +432,13 @@ class BaseModel extends events_1.EventEmitter {
432
432
  if (!itemDoc)
433
433
  throw new errors_1.AppError('messages.notFound');
434
434
  // complete merge
435
- if (mergeItem)
436
- item = (0, utils_1.merge)(itemDoc.toObject(), item); // Merge with existing doc
435
+ if (mergeItem) {
436
+ // item = merge (itemDoc.toObject(), item); // Merge with existing doc
437
+ item = (0, utils_1.merge)(itemDoc.toObject(), item, (objValue, srcValue) => {
438
+ if (Array.isArray(objValue))
439
+ return srcValue; // sovrascrivi invece di mergiare
440
+ });
441
+ }
437
442
  itemDoc === null || itemDoc === void 0 ? void 0 : itemDoc.set(item);
438
443
  const res = yield itemDoc.save();
439
444
  if (context)
@@ -336,7 +336,7 @@ export declare function uniqBy(arr: any[], iteratee: Function): any[];
336
336
  * @param {*} obj2
337
337
  * @returns
338
338
  */
339
- export declare function merge(obj1: any, obj2: any): any;
339
+ export declare function merge(obj1: any, obj2: any, mergeFnc?: Function): any;
340
340
  /**
341
341
  *
342
342
  * @param data
@@ -709,10 +709,10 @@ exports.uniqBy = uniqBy;
709
709
  * @param {*} obj2
710
710
  * @returns
711
711
  */
712
- function merge(obj1, obj2) {
712
+ function merge(obj1, obj2, mergeFnc) {
713
713
  if (!isObject(obj1) || !isObject(obj2))
714
714
  return;
715
- return lodash_1.default.merge(obj1, obj2);
715
+ return mergeFnc ? lodash_1.default.mergeWith(obj1, obj2, mergeFnc) : lodash_1.default.merge(obj1, obj2);
716
716
  }
717
717
  exports.merge = merge;
718
718
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextage/nx-frame-be",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",