@declaro/data 2.0.0-beta.126 → 2.0.0-beta.127

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 (39) hide show
  1. package/dist/browser/index.js +11 -11
  2. package/dist/browser/index.js.map +6 -6
  3. package/dist/node/index.cjs +189 -92
  4. package/dist/node/index.cjs.map +6 -6
  5. package/dist/node/index.js +181 -84
  6. package/dist/node/index.js.map +6 -6
  7. package/dist/ts/application/model-controller.d.ts +15 -5
  8. package/dist/ts/application/model-controller.d.ts.map +1 -1
  9. package/dist/ts/application/read-only-model-controller.d.ts +5 -1
  10. package/dist/ts/application/read-only-model-controller.d.ts.map +1 -1
  11. package/dist/ts/domain/services/model-service.d.ts +8 -0
  12. package/dist/ts/domain/services/model-service.d.ts.map +1 -1
  13. package/dist/ts/domain/services/read-only-model-service.d.ts +8 -0
  14. package/dist/ts/domain/services/read-only-model-service.d.ts.map +1 -1
  15. package/dist/ts/shared/utils/schema-inheritance.test.d.ts +2 -0
  16. package/dist/ts/shared/utils/schema-inheritance.test.d.ts.map +1 -0
  17. package/dist/ts/shared/utils/test/animal-schema.d.ts +57 -0
  18. package/dist/ts/shared/utils/test/animal-schema.d.ts.map +1 -0
  19. package/dist/ts/shared/utils/test/animal-trait-schema.d.ts +55 -0
  20. package/dist/ts/shared/utils/test/animal-trait-schema.d.ts.map +1 -0
  21. package/dist/ts/shared/utils/test/elephant-schema.d.ts +30 -0
  22. package/dist/ts/shared/utils/test/elephant-schema.d.ts.map +1 -0
  23. package/dist/ts/shared/utils/test/elephant-trait-schema.d.ts +26 -0
  24. package/dist/ts/shared/utils/test/elephant-trait-schema.d.ts.map +1 -0
  25. package/package.json +5 -5
  26. package/src/application/model-controller.ts +110 -59
  27. package/src/application/read-only-model-controller.ts +43 -25
  28. package/src/domain/services/model-service.test.ts +280 -0
  29. package/src/domain/services/model-service.ts +98 -66
  30. package/src/domain/services/read-only-model-service.test.ts +230 -0
  31. package/src/domain/services/read-only-model-service.ts +65 -40
  32. package/src/shared/utils/schema-inheritance.test.ts +295 -0
  33. package/src/shared/utils/test/animal-schema.ts +46 -0
  34. package/src/shared/utils/test/animal-trait-schema.ts +45 -0
  35. package/src/shared/utils/test/elephant-schema.ts +58 -0
  36. package/src/shared/utils/test/elephant-trait-schema.ts +53 -0
  37. package/dist/ts/test/mock/repositories/mock-memory-repository.custom-lookup.test.d.ts +0 -1
  38. package/dist/ts/test/mock/repositories/mock-memory-repository.custom-lookup.test.d.ts.map +0 -1
  39. package/src/test/mock/repositories/mock-memory-repository.custom-lookup.test.ts +0 -0
@@ -10,10 +10,11 @@ var __export = (target, all) => {
10
10
  };
11
11
 
12
12
  // src/application/model-controller.ts
13
- import { PermissionValidator } from "@declaro/core";
13
+ import { PermissionValidator as PermissionValidator2 } from "@declaro/core";
14
14
 
15
15
  // src/application/read-only-model-controller.ts
16
16
  import"@declaro/auth";
17
+ import { PermissionValidator } from "@declaro/core";
17
18
 
18
19
  class ReadOnlyModelController {
19
20
  service;
@@ -22,32 +23,48 @@ class ReadOnlyModelController {
22
23
  this.service = service;
23
24
  this.authValidator = authValidator;
24
25
  }
25
- async load(lookup, options) {
26
- this.authValidator.validatePermissions((v) => v.someOf([
26
+ async loadPermissions(lookup) {
27
+ return PermissionValidator.create().someOf([
27
28
  this.service.getDescriptor("load", "*").toString(),
28
29
  this.service.getDescriptor("read", "*").toString()
29
- ]));
30
+ ]);
31
+ }
32
+ async load(lookup, options) {
33
+ const permissions = await this.loadPermissions(lookup);
34
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
30
35
  return this.service.load(lookup, options);
31
36
  }
32
- async loadMany(lookups, options) {
33
- this.authValidator.validatePermissions((v) => v.someOf([
37
+ async loadManyPermissions(lookups) {
38
+ return PermissionValidator.create().someOf([
34
39
  this.service.getDescriptor("loadMany", "*").toString(),
35
40
  this.service.getDescriptor("read", "*").toString()
36
- ]));
41
+ ]);
42
+ }
43
+ async loadMany(lookups, options) {
44
+ const permissions = await this.loadManyPermissions(lookups);
45
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
37
46
  return this.service.loadMany(lookups, options);
38
47
  }
39
- async search(input, options) {
40
- this.authValidator.validatePermissions((v) => v.someOf([
48
+ async searchPermissions(input, options) {
49
+ return PermissionValidator.create().someOf([
41
50
  this.service.getDescriptor("search", "*").toString(),
42
51
  this.service.getDescriptor("read", "*").toString()
43
- ]));
52
+ ]);
53
+ }
54
+ async search(input, options) {
55
+ const permissions = await this.searchPermissions(input, options);
56
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
44
57
  return this.service.search(input, options);
45
58
  }
46
- async count(input, options) {
47
- this.authValidator.validatePermissions((v) => v.someOf([
59
+ async countPermissions(input, options) {
60
+ return PermissionValidator.create().someOf([
48
61
  this.service.getDescriptor("count", "*").toString(),
49
62
  this.service.getDescriptor("read", "*").toString()
50
- ]));
63
+ ]);
64
+ }
65
+ async count(input, options) {
66
+ const permissions = await this.countPermissions(input, options);
67
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
51
68
  return this.service.count(input, options);
52
69
  }
53
70
  }
@@ -61,64 +78,106 @@ class ModelController extends ReadOnlyModelController {
61
78
  this.service = service;
62
79
  this.authValidator = authValidator;
63
80
  }
64
- async create(input) {
65
- this.authValidator.validatePermissions((v) => v.someOf([
81
+ async createPermissions(input, options) {
82
+ return PermissionValidator2.create().someOf([
66
83
  this.service.getDescriptor("create", "*").toString(),
67
84
  this.service.getDescriptor("write", "*").toString()
68
- ]));
69
- return this.service.create(input);
85
+ ]);
70
86
  }
71
- async update(lookup, input) {
72
- this.authValidator.validatePermissions((v) => v.someOf([
87
+ async create(input, options) {
88
+ const permissions = await this.createPermissions(input, options);
89
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
90
+ return this.service.create(input, options);
91
+ }
92
+ async updatePermissions(lookup, input, options) {
93
+ return PermissionValidator2.create().someOf([
73
94
  this.service.getDescriptor("update", "*").toString(),
74
95
  this.service.getDescriptor("write", "*").toString()
75
- ]));
76
- return this.service.update(lookup, input);
96
+ ]);
77
97
  }
78
- async remove(lookup) {
79
- this.authValidator.validatePermissions((v) => v.someOf([
98
+ async update(lookup, input, options) {
99
+ const permissions = await this.updatePermissions(lookup, input, options);
100
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
101
+ return this.service.update(lookup, input, options);
102
+ }
103
+ async removePermissions(lookup, options) {
104
+ return PermissionValidator2.create().someOf([
80
105
  this.service.getDescriptor("remove", "*").toString(),
81
106
  this.service.getDescriptor("write", "*").toString()
82
- ]));
83
- return this.service.remove(lookup);
107
+ ]);
84
108
  }
85
- async restore(lookup) {
86
- this.authValidator.validatePermissions((v) => v.someOf([
109
+ async remove(lookup, options) {
110
+ const permissions = await this.removePermissions(lookup, options);
111
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
112
+ return this.service.remove(lookup, options);
113
+ }
114
+ async restorePermissions(lookup, options) {
115
+ return PermissionValidator2.create().someOf([
87
116
  this.service.getDescriptor("restore", "*").toString(),
88
117
  this.service.getDescriptor("write", "*").toString()
89
- ]));
90
- return this.service.restore(lookup);
118
+ ]);
91
119
  }
92
- async upsert(input, options) {
93
- const createAndUpdateValidator = PermissionValidator.create().allOf([
120
+ async restore(lookup, options) {
121
+ const permissions = await this.restorePermissions(lookup, options);
122
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
123
+ return this.service.restore(lookup, options);
124
+ }
125
+ async upsertPermissions(input, options) {
126
+ const createAndUpdateValidator = PermissionValidator2.create().allOf([
94
127
  this.service.getDescriptor("create", "*").toString(),
95
128
  this.service.getDescriptor("update", "*").toString()
96
129
  ]);
97
- this.authValidator.validatePermissions((v) => v.someOf([createAndUpdateValidator, this.service.getDescriptor("write", "*").toString()]));
130
+ return PermissionValidator2.create().someOf([
131
+ createAndUpdateValidator,
132
+ this.service.getDescriptor("write", "*").toString()
133
+ ]);
134
+ }
135
+ async upsert(input, options) {
136
+ const permissions = await this.upsertPermissions(input, options);
137
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
98
138
  return this.service.upsert(input, options);
99
139
  }
100
- async bulkUpsert(inputs, options) {
101
- const createAndUpdateValidator = PermissionValidator.create().allOf([
140
+ async bulkUpsertPermissions(inputs, options) {
141
+ const createAndUpdateValidator = PermissionValidator2.create().allOf([
102
142
  this.service.getDescriptor("create", "*").toString(),
103
143
  this.service.getDescriptor("update", "*").toString()
104
144
  ]);
105
- this.authValidator.validatePermissions((v) => v.someOf([createAndUpdateValidator, this.service.getDescriptor("write", "*").toString()]));
145
+ return PermissionValidator2.create().someOf([
146
+ createAndUpdateValidator,
147
+ this.service.getDescriptor("write", "*").toString()
148
+ ]);
149
+ }
150
+ async bulkUpsert(inputs, options) {
151
+ const permissions = await this.bulkUpsertPermissions(inputs, options);
152
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
106
153
  return this.service.bulkUpsert(inputs, options);
107
154
  }
108
- async permanentlyDeleteFromTrash(lookup) {
109
- this.authValidator.validatePermissions((v) => v.someOf([
155
+ async permanentlyDeleteFromTrashPermissions(lookup) {
156
+ return PermissionValidator2.create().someOf([
110
157
  this.service.getDescriptor("permanently-delete-from-trash", "*").toString(),
111
158
  this.service.getDescriptor("permanently-delete", "*").toString(),
112
159
  this.service.getDescriptor("empty-trash", "*").toString()
113
- ]));
160
+ ]);
161
+ }
162
+ async permanentlyDeleteFromTrash(lookup) {
163
+ const permissions = await this.permanentlyDeleteFromTrashPermissions(lookup);
164
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
114
165
  return this.service.permanentlyDeleteFromTrash(lookup);
115
166
  }
167
+ async permanentlyDeletePermissions(lookup) {
168
+ return PermissionValidator2.create().someOf([this.service.getDescriptor("permanently-delete", "*").toString()]);
169
+ }
116
170
  async permanentlyDelete(lookup) {
117
- this.authValidator.validatePermissions((v) => v.someOf([this.service.getDescriptor("permanently-delete", "*").toString()]));
171
+ const permissions = await this.permanentlyDeletePermissions(lookup);
172
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
118
173
  return this.service.permanentlyDelete(lookup);
119
174
  }
175
+ async emptyTrashPermissions(filters) {
176
+ return PermissionValidator2.create().someOf([this.service.getDescriptor("empty-trash", "*").toString()]);
177
+ }
120
178
  async emptyTrash(filters) {
121
- this.authValidator.validatePermissions((v) => v.someOf([this.service.getDescriptor("empty-trash", "*").toString()]));
179
+ const permissions = await this.emptyTrashPermissions(filters);
180
+ this.authValidator.validatePermissions((v) => v.extend(permissions));
122
181
  return this.service.emptyTrash(filters);
123
182
  }
124
183
  }
@@ -12673,38 +12732,54 @@ class ReadOnlyModelService extends BaseModelService {
12673
12732
  return summary;
12674
12733
  }
12675
12734
  async load(lookup, options) {
12676
- const beforeLoadEvent = new QueryEvent(this.getDescriptor("beforeLoad" /* BeforeLoad */, options?.scope), lookup);
12677
- await this.emitter.emitAsync(beforeLoadEvent);
12735
+ if (!options?.doNotDispatchEvents) {
12736
+ const beforeLoadEvent = new QueryEvent(this.getDescriptor("beforeLoad" /* BeforeLoad */, options?.scope), lookup);
12737
+ await this.emitter.emitAsync(beforeLoadEvent);
12738
+ }
12678
12739
  const details = await this.repository.load(lookup, options);
12679
- const afterLoadEvent = new QueryEvent(this.getDescriptor("afterLoad" /* AfterLoad */, options?.scope), lookup).setResult(details);
12680
- await this.emitter.emitAsync(afterLoadEvent);
12740
+ if (!options?.doNotDispatchEvents) {
12741
+ const afterLoadEvent = new QueryEvent(this.getDescriptor("afterLoad" /* AfterLoad */, options?.scope), lookup).setResult(details);
12742
+ await this.emitter.emitAsync(afterLoadEvent);
12743
+ }
12681
12744
  return await this.normalizeDetail(details);
12682
12745
  }
12683
12746
  async loadMany(lookups, options) {
12684
- const beforeLoadManyEvent = new QueryEvent(this.getDescriptor("beforeLoadMany" /* BeforeLoadMany */, options?.scope), lookups);
12685
- await this.emitter.emitAsync(beforeLoadManyEvent);
12747
+ if (!options?.doNotDispatchEvents) {
12748
+ const beforeLoadManyEvent = new QueryEvent(this.getDescriptor("beforeLoadMany" /* BeforeLoadMany */, options?.scope), lookups);
12749
+ await this.emitter.emitAsync(beforeLoadManyEvent);
12750
+ }
12686
12751
  const details = await this.repository.loadMany(lookups, options);
12687
- const afterLoadManyEvent = new QueryEvent(this.getDescriptor("afterLoadMany" /* AfterLoadMany */, options?.scope), lookups).setResult(details);
12688
- await this.emitter.emitAsync(afterLoadManyEvent);
12752
+ if (!options?.doNotDispatchEvents) {
12753
+ const afterLoadManyEvent = new QueryEvent(this.getDescriptor("afterLoadMany" /* AfterLoadMany */, options?.scope), lookups).setResult(details);
12754
+ await this.emitter.emitAsync(afterLoadManyEvent);
12755
+ }
12689
12756
  return await Promise.all(details.map((detail) => this.normalizeDetail(detail)));
12690
12757
  }
12691
12758
  async search(filters, options) {
12692
- const beforeSearchEvent = new QueryEvent(this.getDescriptor("beforeSearch" /* BeforeSearch */, options?.scope), filters);
12693
- await this.emitter.emitAsync(beforeSearchEvent);
12759
+ if (!options?.doNotDispatchEvents) {
12760
+ const beforeSearchEvent = new QueryEvent(this.getDescriptor("beforeSearch" /* BeforeSearch */, options?.scope), filters);
12761
+ await this.emitter.emitAsync(beforeSearchEvent);
12762
+ }
12694
12763
  const results = await this.repository.search(filters, options);
12695
- const afterSearchEvent = new QueryEvent(this.getDescriptor("afterSearch" /* AfterSearch */, options?.scope), filters).setResult(results);
12696
- await this.emitter.emitAsync(afterSearchEvent);
12764
+ if (!options?.doNotDispatchEvents) {
12765
+ const afterSearchEvent = new QueryEvent(this.getDescriptor("afterSearch" /* AfterSearch */, options?.scope), filters).setResult(results);
12766
+ await this.emitter.emitAsync(afterSearchEvent);
12767
+ }
12697
12768
  return {
12698
12769
  ...results,
12699
12770
  results: await Promise.all(results.results.map((detail) => this.normalizeSummary(detail)))
12700
12771
  };
12701
12772
  }
12702
12773
  async count(filters, options) {
12703
- const beforeCountEvent = new QueryEvent(this.getDescriptor("beforeCount" /* BeforeCount */, options?.scope), filters);
12704
- await this.emitter.emitAsync(beforeCountEvent);
12774
+ if (!options?.doNotDispatchEvents) {
12775
+ const beforeCountEvent = new QueryEvent(this.getDescriptor("beforeCount" /* BeforeCount */, options?.scope), filters);
12776
+ await this.emitter.emitAsync(beforeCountEvent);
12777
+ }
12705
12778
  const count = await this.repository.count(filters, options);
12706
- const afterCountEvent = new QueryEvent(this.getDescriptor("afterCount" /* AfterCount */, options?.scope), filters).setResult(count);
12707
- await this.emitter.emitAsync(afterCountEvent);
12779
+ if (!options?.doNotDispatchEvents) {
12780
+ const afterCountEvent = new QueryEvent(this.getDescriptor("afterCount" /* AfterCount */, options?.scope), filters).setResult(count);
12781
+ await this.emitter.emitAsync(afterCountEvent);
12782
+ }
12708
12783
  return count;
12709
12784
  }
12710
12785
  }
@@ -12737,24 +12812,32 @@ class ModelService extends ReadOnlyModelService {
12737
12812
  const normalizedInput = await this.normalizeInput(input, {
12738
12813
  descriptor: this.getDescriptor("create" /* Create */)
12739
12814
  });
12740
- const beforeCreateEvent = new MutationEvent(this.getDescriptor("beforeCreate" /* BeforeCreate */), normalizedInput);
12741
- await this.emitter.emitAsync(beforeCreateEvent);
12815
+ if (!options?.doNotDispatchEvents) {
12816
+ const beforeCreateEvent = new MutationEvent(this.getDescriptor("beforeCreate" /* BeforeCreate */), normalizedInput);
12817
+ await this.emitter.emitAsync(beforeCreateEvent);
12818
+ }
12742
12819
  const result = await this.repository.create(normalizedInput, options);
12743
- const afterCreateEvent = new MutationEvent(this.getDescriptor("afterCreate" /* AfterCreate */), normalizedInput).setResult(result);
12744
- await this.emitter.emitAsync(afterCreateEvent);
12820
+ if (!options?.doNotDispatchEvents) {
12821
+ const afterCreateEvent = new MutationEvent(this.getDescriptor("afterCreate" /* AfterCreate */), normalizedInput).setResult(result);
12822
+ await this.emitter.emitAsync(afterCreateEvent);
12823
+ }
12745
12824
  return await this.normalizeDetail(result);
12746
12825
  }
12747
12826
  async update(lookup, input, options) {
12748
- const existing = await this.repository.load(lookup, options);
12827
+ const existing = await this.repository.load(lookup, { ...options, doNotDispatchEvents: true });
12749
12828
  const normalizedInput = await this.normalizeInput(input, {
12750
12829
  existing,
12751
12830
  descriptor: this.getDescriptor("update" /* Update */)
12752
12831
  });
12753
- const beforeUpdateEvent = new MutationEvent(this.getDescriptor("beforeUpdate" /* BeforeUpdate */), normalizedInput);
12754
- await this.emitter.emitAsync(beforeUpdateEvent);
12832
+ if (!options?.doNotDispatchEvents) {
12833
+ const beforeUpdateEvent = new MutationEvent(this.getDescriptor("beforeUpdate" /* BeforeUpdate */), normalizedInput);
12834
+ await this.emitter.emitAsync(beforeUpdateEvent);
12835
+ }
12755
12836
  const result = await this.repository.update(lookup, normalizedInput, options);
12756
- const afterUpdateEvent = new MutationEvent(this.getDescriptor("afterUpdate" /* AfterUpdate */), normalizedInput).setResult(result);
12757
- await this.emitter.emitAsync(afterUpdateEvent);
12837
+ if (!options?.doNotDispatchEvents) {
12838
+ const afterUpdateEvent = new MutationEvent(this.getDescriptor("afterUpdate" /* AfterUpdate */), normalizedInput).setResult(result);
12839
+ await this.emitter.emitAsync(afterUpdateEvent);
12840
+ }
12758
12841
  return await this.normalizeDetail(result);
12759
12842
  }
12760
12843
  async upsert(input, options) {
@@ -12770,7 +12853,10 @@ class ModelService extends ReadOnlyModelService {
12770
12853
  } else {
12771
12854
  existingItem = await this.load({
12772
12855
  [this.entityMetadata.primaryKey]: primaryKeyValue
12773
- }, options);
12856
+ }, {
12857
+ ...options,
12858
+ doNotDispatchEvents: true
12859
+ });
12774
12860
  if (existingItem) {
12775
12861
  operation = "update" /* Update */;
12776
12862
  beforeOperation = "beforeUpdate" /* BeforeUpdate */;
@@ -12785,11 +12871,15 @@ class ModelService extends ReadOnlyModelService {
12785
12871
  descriptor: this.getDescriptor(operation),
12786
12872
  existing: existingItem
12787
12873
  });
12788
- const beforeUpsertEvent = new MutationEvent(this.getDescriptor(beforeOperation), normalizedInput);
12789
- await this.emitter.emitAsync(beforeUpsertEvent);
12874
+ if (!options?.doNotDispatchEvents) {
12875
+ const beforeUpsertEvent = new MutationEvent(this.getDescriptor(beforeOperation), normalizedInput);
12876
+ await this.emitter.emitAsync(beforeUpsertEvent);
12877
+ }
12790
12878
  const result = await this.repository.upsert(normalizedInput, options);
12791
- const afterUpsertEvent = new MutationEvent(this.getDescriptor(afterOperation), normalizedInput).setResult(result);
12792
- await this.emitter.emitAsync(afterUpsertEvent);
12879
+ if (!options?.doNotDispatchEvents) {
12880
+ const afterUpsertEvent = new MutationEvent(this.getDescriptor(afterOperation), normalizedInput).setResult(result);
12881
+ await this.emitter.emitAsync(afterUpsertEvent);
12882
+ }
12793
12883
  return await this.normalizeDetail(result);
12794
12884
  }
12795
12885
  async bulkUpsert(inputs, options) {
@@ -12816,7 +12906,10 @@ class ModelService extends ReadOnlyModelService {
12816
12906
  const existingEntitiesMap = new Map;
12817
12907
  if (uniqueLookups.size > 0) {
12818
12908
  const lookups = Array.from(uniqueLookups.values());
12819
- const existingEntities = await this.loadMany(lookups, options);
12909
+ const existingEntities = await this.loadMany(lookups, {
12910
+ ...options,
12911
+ doNotDispatchEvents: true
12912
+ });
12820
12913
  existingEntities.forEach((entity) => {
12821
12914
  if (entity) {
12822
12915
  const pkValue = this.getPrimaryKeyValue(entity);
@@ -12839,20 +12932,24 @@ class ModelService extends ReadOnlyModelService {
12839
12932
  return normalizedInput;
12840
12933
  });
12841
12934
  const normalizedInputs = await Promise.all(normalizationPromises);
12842
- const beforeEvents = [];
12843
- for (const inputInfo of inputInfos) {
12844
- beforeEvents.push(new MutationEvent(this.getDescriptor(inputInfo.operation), inputInfo.input));
12935
+ if (!options?.doNotDispatchEvents) {
12936
+ const beforeEvents = [];
12937
+ for (const inputInfo of inputInfos) {
12938
+ beforeEvents.push(new MutationEvent(this.getDescriptor(inputInfo.operation), inputInfo.input));
12939
+ }
12940
+ await Promise.all(beforeEvents.map((event) => this.emitter.emitAsync(event)));
12845
12941
  }
12846
- await Promise.all(beforeEvents.map((event) => this.emitter.emitAsync(event)));
12847
12942
  const results = await this.repository.bulkUpsert(normalizedInputs, options);
12848
- const afterEvents = [];
12849
- for (let i = 0;i < inputInfos.length; i++) {
12850
- const inputInfo = inputInfos[i];
12851
- const result = results[i];
12852
- const afterOperation = inputInfo.operation === "beforeCreate" /* BeforeCreate */ ? "afterCreate" /* AfterCreate */ : "afterUpdate" /* AfterUpdate */;
12853
- afterEvents.push(new MutationEvent(this.getDescriptor(afterOperation), inputInfo.input).setResult(result));
12854
- }
12855
- await Promise.all(afterEvents.map((event) => this.emitter.emitAsync(event)));
12943
+ if (!options?.doNotDispatchEvents) {
12944
+ const afterEvents = [];
12945
+ for (let i = 0;i < inputInfos.length; i++) {
12946
+ const inputInfo = inputInfos[i];
12947
+ const result = results[i];
12948
+ const afterOperation = inputInfo.operation === "beforeCreate" /* BeforeCreate */ ? "afterCreate" /* AfterCreate */ : "afterUpdate" /* AfterUpdate */;
12949
+ afterEvents.push(new MutationEvent(this.getDescriptor(afterOperation), inputInfo.input).setResult(result));
12950
+ }
12951
+ await Promise.all(afterEvents.map((event) => this.emitter.emitAsync(event)));
12952
+ }
12856
12953
  return await Promise.all(results.map((result) => this.normalizeDetail(result)));
12857
12954
  }
12858
12955
  async emptyTrash(filters) {
@@ -13210,5 +13307,5 @@ export {
13210
13307
  BaseModelService
13211
13308
  };
13212
13309
 
13213
- //# debugId=4FCC17E6392BEFF464756E2164756E21
13310
+ //# debugId=2F46F5B1D5A9235464756E2164756E21
13214
13311
  //# sourceMappingURL=index.js.map