@steedos/objectql 2.7.0-beta.9 → 2.7.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.
Files changed (38) hide show
  1. package/lib/actions/field_updates.d.ts +1 -1
  2. package/lib/actions/field_updates.js +2 -2
  3. package/lib/actions/field_updates.js.map +1 -1
  4. package/lib/actions/workflow_notifications.d.ts +1 -1
  5. package/lib/actions/workflow_notifications.js +2 -2
  6. package/lib/actions/workflow_notifications.js.map +1 -1
  7. package/lib/actions/workflow_outbound_messages.d.ts +1 -1
  8. package/lib/actions/workflow_outbound_messages.js +2 -2
  9. package/lib/actions/workflow_outbound_messages.js.map +1 -1
  10. package/lib/actions/workflow_rule.js +3 -3
  11. package/lib/actions/workflow_rule.js.map +1 -1
  12. package/lib/formula/core.d.ts +1 -3
  13. package/lib/formula/core.js +47 -108
  14. package/lib/formula/core.js.map +1 -1
  15. package/lib/formula/field_formula.d.ts +1 -0
  16. package/lib/formula/field_formula.js +44 -2
  17. package/lib/formula/field_formula.js.map +1 -1
  18. package/lib/summary/core.d.ts +4 -2
  19. package/lib/summary/core.js +122 -62
  20. package/lib/summary/core.js.map +1 -1
  21. package/lib/triggers/trigger.d.ts +1 -1
  22. package/lib/triggers/trigger.js +62 -23
  23. package/lib/triggers/trigger.js.map +1 -1
  24. package/lib/types/defaultValue.d.ts +3 -0
  25. package/lib/types/defaultValue.js +148 -0
  26. package/lib/types/defaultValue.js.map +1 -0
  27. package/lib/types/method_base.d.ts +4 -0
  28. package/lib/types/method_base.js +142 -0
  29. package/lib/types/method_base.js.map +1 -0
  30. package/lib/types/object.d.ts +5 -1
  31. package/lib/types/object.js +195 -107
  32. package/lib/types/object.js.map +1 -1
  33. package/lib/types/validation_rules.js +2 -2
  34. package/lib/types/validation_rules.js.map +1 -1
  35. package/lib/util/field.d.ts +1 -0
  36. package/lib/util/field.js +13 -1
  37. package/lib/util/field.js.map +1 -1
  38. package/package.json +15 -14
@@ -24,6 +24,8 @@ var cachers_1 = require("@steedos/cachers");
24
24
  var lodash_2 = require("lodash");
25
25
  var trigger_1 = require("../triggers/trigger");
26
26
  var metadata_registrar_1 = require("@steedos/metadata-registrar");
27
+ var method_base_1 = require("./method_base");
28
+ var defaultValue_1 = require("./defaultValue");
27
29
  var auth = require("@steedos/auth");
28
30
  var clone = require('clone');
29
31
  var PLATFORM_ENTERPRISE = 'platform-enterprise';
@@ -548,7 +550,7 @@ var SteedosObjectType = (function (_super) {
548
550
  if (!!triggers_1_1.done) return [3, 5];
549
551
  trigger = triggers_1_1.value;
550
552
  params = (0, util_1.generateActionParams)(when, context);
551
- return [4, (0, trigger_1.runTriggerFunction)(trigger.metadata.handler, {
553
+ return [4, (0, trigger_1.runTriggerFunction)(trigger.metadata, {
552
554
  getObject: getObject,
553
555
  getUser: auth.getSessionByUserId
554
556
  }, {
@@ -1389,15 +1391,19 @@ var SteedosObjectType = (function (_super) {
1389
1391
  return tslib_1.__generator(this, function (_a) {
1390
1392
  switch (_a.label) {
1391
1393
  case 0:
1392
- _a.trys.push([0, 2, , 3]);
1394
+ _a.trys.push([0, 3, , 4]);
1393
1395
  doc = this.formatRecord(doc);
1396
+ return [4, this.getInsertBaseDoc(doc, userSession)];
1397
+ case 1:
1398
+ doc = _a.sent();
1399
+ doc = this.getDefaultValuesDoc(doc, userSession);
1394
1400
  return [4, this.callAdapter('insert', this.table_name, doc, userSession)];
1395
- case 1: return [2, _a.sent()];
1396
- case 2:
1401
+ case 2: return [2, _a.sent()];
1402
+ case 3:
1397
1403
  error_5 = _a.sent();
1398
1404
  this.handlerDuplicateKeyError(error_5, userSession);
1399
1405
  throw error_5;
1400
- case 3: return [2];
1406
+ case 4: return [2];
1401
1407
  }
1402
1408
  });
1403
1409
  });
@@ -1408,16 +1414,19 @@ var SteedosObjectType = (function (_super) {
1408
1414
  return tslib_1.__generator(this, function (_a) {
1409
1415
  switch (_a.label) {
1410
1416
  case 0:
1411
- _a.trys.push([0, 2, , 3]);
1417
+ _a.trys.push([0, 3, , 4]);
1412
1418
  doc = this.formatRecord(doc);
1419
+ return [4, this.getUpdateBaseDoc(doc, userSession)];
1420
+ case 1:
1421
+ doc = _a.sent();
1413
1422
  clonedId = id;
1414
1423
  return [4, this.callAdapter('update', this.table_name, clonedId, doc, userSession)];
1415
- case 1: return [2, _a.sent()];
1416
- case 2:
1424
+ case 2: return [2, _a.sent()];
1425
+ case 3:
1417
1426
  error_6 = _a.sent();
1418
1427
  this.handlerDuplicateKeyError(error_6, userSession);
1419
1428
  throw error_6;
1420
- case 3: return [2];
1429
+ case 4: return [2];
1421
1430
  }
1422
1431
  });
1423
1432
  });
@@ -1429,9 +1438,12 @@ var SteedosObjectType = (function (_super) {
1429
1438
  switch (_a.label) {
1430
1439
  case 0:
1431
1440
  doc = this.formatRecord(doc);
1441
+ return [4, this.getUpdateBaseDoc(doc, userSession)];
1442
+ case 1:
1443
+ doc = _a.sent();
1432
1444
  clonedId = id;
1433
1445
  return [4, this.callAdapter('updateOne', this.table_name, clonedId, doc, userSession)];
1434
- case 1: return [2, _a.sent()];
1446
+ case 2: return [2, _a.sent()];
1435
1447
  }
1436
1448
  });
1437
1449
  });
@@ -1443,9 +1455,12 @@ var SteedosObjectType = (function (_super) {
1443
1455
  switch (_a.label) {
1444
1456
  case 0:
1445
1457
  doc = this.formatRecord(doc);
1458
+ return [4, this.getUpdateBaseDoc(doc, userSession)];
1459
+ case 1:
1460
+ doc = _a.sent();
1446
1461
  clonedQueryFilters = queryFilters;
1447
1462
  return [4, this.callAdapter('updateMany', this.table_name, clonedQueryFilters, doc, userSession)];
1448
- case 1: return [2, _a.sent()];
1463
+ case 2: return [2, _a.sent()];
1449
1464
  }
1450
1465
  });
1451
1466
  });
@@ -1973,12 +1988,17 @@ var SteedosObjectType = (function (_super) {
1973
1988
  if (field.override) {
1974
1989
  field = Object.assign(field, field.override);
1975
1990
  }
1976
- if (field && field.static) {
1977
- var fieldAmis = field.amis || {};
1978
- fieldAmis.static = true;
1979
- Object.assign(field, {
1980
- amis: fieldAmis
1981
- });
1991
+ if (field) {
1992
+ if (field.static) {
1993
+ var fieldAmis = field.amis || {};
1994
+ fieldAmis.static = true;
1995
+ Object.assign(field, {
1996
+ amis: fieldAmis
1997
+ });
1998
+ }
1999
+ if (field.type == 'formula' || field.type == 'summary') {
2000
+ field.readonly = true;
2001
+ }
1982
2002
  }
1983
2003
  });
1984
2004
  if (objectLayout && objectLayout.field_groups) {
@@ -2496,34 +2516,25 @@ var SteedosObjectType = (function (_super) {
2496
2516
  });
2497
2517
  });
2498
2518
  };
2499
- SteedosObjectType.prototype.getTriggerContext = function (when, method, args, recordId) {
2519
+ SteedosObjectType.prototype.getTriggerContext = function (when, method, args) {
2500
2520
  return tslib_1.__awaiter(this, void 0, void 0, function () {
2501
- var userSession, context, _a;
2502
- return tslib_1.__generator(this, function (_b) {
2503
- switch (_b.label) {
2504
- case 0:
2505
- userSession = args[args.length - 1];
2506
- context = { objectName: this.name, userId: userSession ? userSession.userId : undefined, spaceId: userSession ? userSession.spaceId : undefined };
2507
- if (method === 'find' || method === 'findOne' || method === 'count') {
2508
- context.query = args[args.length - 2];
2509
- }
2510
- if (method === 'aggregate' || method === 'aggregatePrefixalPipeline') {
2511
- context.query = args[args.length - 3];
2512
- }
2513
- if (method === 'findOne' || method === 'update' || method === 'delete') {
2514
- context.id = args[1];
2515
- }
2516
- if (method === 'insert' || method === 'update') {
2517
- context.doc = args[args.length - 2];
2518
- }
2519
- if (!(when === 'after' && (method === 'update' || method === 'delete'))) return [3, 2];
2520
- _a = context;
2521
- return [4, this.findOne(recordId, {}, userSession)];
2522
- case 1:
2523
- _a.previousDoc = _b.sent();
2524
- _b.label = 2;
2525
- case 2: return [2, context];
2521
+ var userSession, context;
2522
+ return tslib_1.__generator(this, function (_a) {
2523
+ userSession = args[args.length - 1];
2524
+ context = { objectName: this.name, userId: userSession ? userSession.userId : undefined, spaceId: userSession ? userSession.spaceId : undefined };
2525
+ if (method === 'find' || method === 'findOne' || method === 'count') {
2526
+ context.query = args[args.length - 2];
2527
+ }
2528
+ if (method === 'aggregate' || method === 'aggregatePrefixalPipeline') {
2529
+ context.query = args[args.length - 3];
2530
+ }
2531
+ if (method === 'findOne' || method === 'update' || method === 'delete') {
2532
+ context.id = args[1];
2533
+ }
2534
+ if (method === 'insert' || method === 'update') {
2535
+ context.doc = args[args.length - 2];
2526
2536
  }
2537
+ return [2, context];
2527
2538
  });
2528
2539
  });
2529
2540
  };
@@ -2572,6 +2583,39 @@ var SteedosObjectType = (function (_super) {
2572
2583
  });
2573
2584
  });
2574
2585
  };
2586
+ SteedosObjectType.prototype.getInsertBaseDoc = function (doc, userSession) {
2587
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
2588
+ var driver;
2589
+ return tslib_1.__generator(this, function (_a) {
2590
+ switch (_a.label) {
2591
+ case 0:
2592
+ driver = this._datasource && this._datasource.driver;
2593
+ if (!(driver == datasource_1.SteedosDatabaseDriverType.Mongo || driver == datasource_1.SteedosDatabaseDriverType.MeteorMongo)) return [3, 2];
2594
+ return [4, (0, method_base_1.getMongoInsertBaseDoc)(this, doc, userSession)];
2595
+ case 1: return [2, _a.sent()];
2596
+ case 2: return [2, doc];
2597
+ }
2598
+ });
2599
+ });
2600
+ };
2601
+ SteedosObjectType.prototype.getUpdateBaseDoc = function (doc, userSession) {
2602
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
2603
+ var driver;
2604
+ return tslib_1.__generator(this, function (_a) {
2605
+ switch (_a.label) {
2606
+ case 0:
2607
+ driver = this._datasource && this._datasource.driver;
2608
+ if (!(driver == datasource_1.SteedosDatabaseDriverType.Mongo || driver == datasource_1.SteedosDatabaseDriverType.MeteorMongo)) return [3, 2];
2609
+ return [4, (0, method_base_1.getMongoUpdateBaseDoc)(this, doc, userSession)];
2610
+ case 1: return [2, _a.sent()];
2611
+ case 2: return [2, doc];
2612
+ }
2613
+ });
2614
+ });
2615
+ };
2616
+ SteedosObjectType.prototype.getDefaultValuesDoc = function (doc, userSession) {
2617
+ return (0, defaultValue_1.getDefaultValuesDoc)(this, doc, userSession);
2618
+ };
2575
2619
  SteedosObjectType.prototype.formatRecord = function (doc) {
2576
2620
  var adapterFormat = this._datasource["formatRecord"];
2577
2621
  if (typeof adapterFormat == 'function') {
@@ -2585,7 +2629,7 @@ var SteedosObjectType = (function (_super) {
2585
2629
  args[_i - 1] = arguments[_i];
2586
2630
  }
2587
2631
  return tslib_1.__awaiter(this, void 0, void 0, function () {
2588
- var adapterMethod, userSession, allow, recordId, doc, objectName, paramRecordId, returnValue, beforeTriggerContext, afterTriggerContext, previousDoc, values, _records;
2632
+ var adapterMethod, userSession, allow, recordId, doc, objectName, paramRecordId, returnValue, previousDoc, docAfterFormulaRun, beforeTriggerContext, afterTriggerContext, values, _records;
2589
2633
  return tslib_1.__generator(this, function (_a) {
2590
2634
  switch (_a.label) {
2591
2635
  case 0:
@@ -2611,7 +2655,9 @@ var SteedosObjectType = (function (_super) {
2611
2655
  }
2612
2656
  else {
2613
2657
  recordId = args[1];
2614
- doc = args[2];
2658
+ if (method !== "delete") {
2659
+ doc = args[2];
2660
+ }
2615
2661
  }
2616
2662
  }
2617
2663
  if (method === 'findOne' || method === 'update' || method === 'delete') {
@@ -2630,66 +2676,81 @@ var SteedosObjectType = (function (_super) {
2630
2676
  return [4, adapterMethod.apply(this._datasource, args)];
2631
2677
  case 5:
2632
2678
  returnValue = _a.sent();
2633
- return [3, 26];
2634
- case 6: return [4, this.getTriggerContext('before', method, args)];
2679
+ return [3, 29];
2680
+ case 6:
2681
+ previousDoc = void 0;
2682
+ if (!(method === 'update' || method === 'delete')) return [3, 8];
2683
+ return [4, this.findOne(recordId, {}, userSession)];
2635
2684
  case 7:
2685
+ previousDoc = _a.sent();
2686
+ _a.label = 8;
2687
+ case 8: return [4, this.getRecordFormulaDoc(method, objectName, doc, previousDoc, userSession)];
2688
+ case 9:
2689
+ docAfterFormulaRun = _a.sent();
2690
+ if (docAfterFormulaRun) {
2691
+ Object.assign(doc, docAfterFormulaRun);
2692
+ }
2693
+ return [4, this.getTriggerContext('before', method, args)];
2694
+ case 10:
2636
2695
  beforeTriggerContext = _a.sent();
2637
2696
  if (paramRecordId) {
2638
2697
  beforeTriggerContext = Object.assign({}, beforeTriggerContext, { id: paramRecordId });
2639
2698
  }
2640
2699
  return [4, this.runBeforeTriggers(method, beforeTriggerContext)];
2641
- case 8:
2700
+ case 11:
2642
2701
  _a.sent();
2643
2702
  return [4, (0, validation_rules_1.runValidationRules)(method, beforeTriggerContext, args[0], userSession)];
2644
- case 9:
2703
+ case 12:
2645
2704
  _a.sent();
2646
- return [4, this.getTriggerContext('after', method, args, paramRecordId)];
2647
- case 10:
2705
+ return [4, this.getTriggerContext('after', method, args)];
2706
+ case 13:
2648
2707
  afterTriggerContext = _a.sent();
2708
+ if (method === 'update' || method === 'delete') {
2709
+ afterTriggerContext.previousDoc = previousDoc;
2710
+ }
2649
2711
  if (paramRecordId) {
2650
2712
  afterTriggerContext = Object.assign({}, afterTriggerContext, { id: paramRecordId });
2651
2713
  }
2652
- previousDoc = clone(afterTriggerContext.previousDoc);
2653
2714
  args.splice(args.length - 1, 1, userSession ? userSession.userId : undefined);
2654
2715
  return [4, adapterMethod.apply(this._datasource, args)];
2655
- case 11:
2716
+ case 14:
2656
2717
  returnValue = _a.sent();
2657
- if (!(method === 'find' || method == 'findOne' || method == 'count' || method == 'aggregate' || method == 'aggregatePrefixalPipeline')) return [3, 15];
2718
+ if (!(method === 'find' || method == 'findOne' || method == 'count' || method == 'aggregate' || method == 'aggregatePrefixalPipeline')) return [3, 18];
2658
2719
  values = clone(returnValue) || {};
2659
- if (!(method === 'count')) return [3, 12];
2720
+ if (!(method === 'count')) return [3, 15];
2660
2721
  values = returnValue || 0;
2661
- return [3, 14];
2662
- case 12:
2663
- if (!userSession) return [3, 14];
2722
+ return [3, 17];
2723
+ case 15:
2724
+ if (!userSession) return [3, 17];
2664
2725
  _records = values;
2665
2726
  if (method == 'findOne' && values) {
2666
2727
  _records = [_records];
2667
2728
  }
2668
2729
  return [4, this.appendRecordPermission(_records, userSession)];
2669
- case 13:
2730
+ case 16:
2670
2731
  _a.sent();
2671
- _a.label = 14;
2672
- case 14:
2732
+ _a.label = 17;
2733
+ case 17:
2673
2734
  Object.assign(afterTriggerContext, { data: { values: values } });
2674
- _a.label = 15;
2675
- case 15:
2735
+ _a.label = 18;
2736
+ case 18:
2676
2737
  if (method == 'insert' && _.has(returnValue, '_id')) {
2677
2738
  afterTriggerContext.doc = returnValue;
2678
2739
  afterTriggerContext = Object.assign({}, afterTriggerContext, { id: returnValue._id });
2679
2740
  }
2680
- if (!(method == "update")) return [3, 18];
2681
- if (!returnValue) return [3, 17];
2741
+ if (!(method == "update")) return [3, 21];
2742
+ if (!returnValue) return [3, 20];
2682
2743
  afterTriggerContext.doc = returnValue;
2683
2744
  return [4, this.runAfterTriggers(method, afterTriggerContext)];
2684
- case 16:
2685
- _a.sent();
2686
- _a.label = 17;
2687
- case 17: return [3, 20];
2688
- case 18: return [4, this.runAfterTriggers(method, afterTriggerContext)];
2689
2745
  case 19:
2690
2746
  _a.sent();
2691
2747
  _a.label = 20;
2692
- case 20:
2748
+ case 20: return [3, 23];
2749
+ case 21: return [4, this.runAfterTriggers(method, afterTriggerContext)];
2750
+ case 22:
2751
+ _a.sent();
2752
+ _a.label = 23;
2753
+ case 23:
2693
2754
  if (method === 'find' || method == 'findOne' || method == 'count' || method == 'aggregate' || method == 'aggregatePrefixalPipeline') {
2694
2755
  if (_.isEmpty(afterTriggerContext.data) || (_.isEmpty(afterTriggerContext.data.values) && !_.isNumber(afterTriggerContext.data.values))) {
2695
2756
  return [2, returnValue];
@@ -2705,76 +2766,103 @@ var SteedosObjectType = (function (_super) {
2705
2766
  user_session: userSession,
2706
2767
  previous_record: afterTriggerContext.previousDoc
2707
2768
  }).run()];
2708
- case 21:
2769
+ case 24:
2709
2770
  _a.sent();
2710
- if (!returnValue) return [3, 24];
2771
+ if (!returnValue) return [3, 27];
2711
2772
  if (method === "insert") {
2712
2773
  doc = returnValue;
2713
2774
  recordId = doc._id;
2714
2775
  }
2715
- return [4, this.runRecordFormula(method, objectName, recordId, doc, userSession)];
2716
- case 22:
2776
+ return [4, this.runRecordQuotedByObjectFieldFormulas(method, objectName, recordId, doc, userSession)];
2777
+ case 25:
2717
2778
  _a.sent();
2718
2779
  return [4, this.runRecordSummaries(method, objectName, recordId, doc, previousDoc, userSession)];
2719
- case 23:
2780
+ case 26:
2720
2781
  _a.sent();
2721
- _a.label = 24;
2722
- case 24: return [4, (0, object_events_1.brokeEmitEvents)(objectName, method, afterTriggerContext)];
2723
- case 25:
2782
+ _a.label = 27;
2783
+ case 27: return [4, (0, object_events_1.brokeEmitEvents)(objectName, method, afterTriggerContext)];
2784
+ case 28:
2724
2785
  _a.sent();
2725
- _a.label = 26;
2726
- case 26: return [2, returnValue];
2786
+ _a.label = 29;
2787
+ case 29: return [2, returnValue];
2727
2788
  }
2728
2789
  });
2729
2790
  });
2730
2791
  };
2731
2792
  ;
2732
- SteedosObjectType.prototype.runRecordFormula = function (method, objectName, recordId, doc, userSession) {
2793
+ SteedosObjectType.prototype.getRecordFormulaDoc = function (method, objectName, doc, previousDoc, userSession) {
2733
2794
  return tslib_1.__awaiter(this, void 0, void 0, function () {
2734
- var onlyForOwn, withoutCurrent;
2795
+ var setDoc, fieldNames, quotedByConfigs, formulaDoc;
2735
2796
  return tslib_1.__generator(this, function (_a) {
2736
2797
  switch (_a.label) {
2737
2798
  case 0:
2738
- if (!(["insert", "update", "updateMany", "delete"].indexOf(method) > -1)) return [3, 5];
2739
- if (!(method === "updateMany")) return [3, 1];
2740
- return [3, 5];
2799
+ if (!(["insert", "update"].indexOf(method) > -1)) return [3, 4];
2800
+ fieldNames = method === "update" ? (0, util_1.getFieldNamesFromDoc)(doc, this.fields) : null;
2801
+ quotedByConfigs = void 0;
2802
+ if (!fieldNames) return [3, 2];
2803
+ return [4, (0, formula_1.getCurrentObjectQuotedByFieldFormulaConfigs)(objectName, fieldNames)];
2741
2804
  case 1:
2742
- if (!(method !== "delete")) return [3, 3];
2743
- return [4, (0, formula_1.runCurrentObjectFieldFormulas)(objectName, recordId, doc, userSession, true)];
2805
+ quotedByConfigs = _a.sent();
2806
+ _a.label = 2;
2744
2807
  case 2:
2745
- _a.sent();
2746
- _a.label = 3;
2808
+ formulaDoc = Object.assign({}, previousDoc, doc);
2809
+ return [4, (0, formula_1.getCurrentObjectFieldFormulasDoc)(objectName, formulaDoc, userSession, quotedByConfigs)];
2747
2810
  case 3:
2748
- onlyForOwn = method === "insert";
2749
- withoutCurrent = method === "delete";
2750
- return [4, (0, formula_1.runQuotedByObjectFieldFormulas)(objectName, recordId, userSession, { onlyForOwn: onlyForOwn, withoutCurrent: withoutCurrent })];
2751
- case 4:
2811
+ setDoc = _a.sent();
2812
+ _a.label = 4;
2813
+ case 4: return [2, setDoc];
2814
+ }
2815
+ });
2816
+ });
2817
+ };
2818
+ SteedosObjectType.prototype.runRecordQuotedByObjectFieldFormulas = function (method, objectName, recordId, doc, userSession) {
2819
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
2820
+ var onlyForOwn, withoutCurrent, fieldNames;
2821
+ return tslib_1.__generator(this, function (_a) {
2822
+ switch (_a.label) {
2823
+ case 0:
2824
+ if (!(["update", "delete"].indexOf(method) > -1)) return [3, 2];
2825
+ onlyForOwn = false;
2826
+ withoutCurrent = true;
2827
+ fieldNames = method === "update" ? (0, util_1.getFieldNamesFromDoc)(doc, this.fields) : null;
2828
+ return [4, (0, formula_1.runQuotedByObjectFieldFormulas)(objectName, recordId, userSession, { onlyForOwn: onlyForOwn, withoutCurrent: withoutCurrent, fieldNames: fieldNames })];
2829
+ case 1:
2752
2830
  _a.sent();
2753
- _a.label = 5;
2754
- case 5: return [2];
2831
+ _a.label = 2;
2832
+ case 2: return [2];
2755
2833
  }
2756
2834
  });
2757
2835
  });
2758
2836
  };
2759
2837
  SteedosObjectType.prototype.runRecordSummaries = function (method, objectName, recordId, doc, previousDoc, userSession) {
2760
2838
  return tslib_1.__awaiter(this, void 0, void 0, function () {
2839
+ var fieldNames, fields_1, hasMasterDetailField;
2761
2840
  return tslib_1.__generator(this, function (_a) {
2762
2841
  switch (_a.label) {
2763
2842
  case 0:
2764
- if (!(["insert", "update", "updateMany", "delete"].indexOf(method) > -1)) return [3, 5];
2765
- if (!(method === "updateMany")) return [3, 1];
2766
- return [3, 5];
2767
- case 1:
2768
- if (!(method === "insert")) return [3, 3];
2843
+ if (!(["insert", "update", "delete"].indexOf(method) > -1)) return [3, 4];
2844
+ if (!(method === "insert")) return [3, 2];
2769
2845
  return [4, (0, summary_1.runCurrentObjectFieldSummaries)(objectName, recordId)];
2770
- case 2:
2846
+ case 1:
2771
2847
  _a.sent();
2772
- _a.label = 3;
2773
- case 3: return [4, (0, summary_1.runQuotedByObjectFieldSummaries)(objectName, recordId, previousDoc, userSession)];
2774
- case 4:
2848
+ _a.label = 2;
2849
+ case 2:
2850
+ fieldNames = method === "update" ? (0, util_1.getFieldNamesFromDoc)(doc, this.fields) : null;
2851
+ if (fieldNames) {
2852
+ fields_1 = this.fields;
2853
+ hasMasterDetailField = !!fieldNames.find(function (item) {
2854
+ var _a;
2855
+ return ((_a = fields_1[item]) === null || _a === void 0 ? void 0 : _a.type) === "master_detail";
2856
+ });
2857
+ if (hasMasterDetailField) {
2858
+ fieldNames = null;
2859
+ }
2860
+ }
2861
+ return [4, (0, summary_1.runQuotedByObjectFieldSummaries)(objectName, recordId, previousDoc, userSession, { fieldNames: fieldNames })];
2862
+ case 3:
2775
2863
  _a.sent();
2776
- _a.label = 5;
2777
- case 5: return [2];
2864
+ _a.label = 4;
2865
+ case 4: return [2];
2778
2866
  }
2779
2867
  });
2780
2868
  });