@declaro/data 2.0.0-beta.97 → 2.0.0-beta.98

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.
@@ -11172,6 +11172,9 @@ class ModelService extends ReadOnlyModelService {
11172
11172
  constructor(args) {
11173
11173
  super(args);
11174
11174
  }
11175
+ async normalizeInput(input) {
11176
+ return input;
11177
+ }
11175
11178
  async remove(lookup, options) {
11176
11179
  const beforeRemoveEvent = new MutationEvent(this.getDescriptor("beforeRemove" /* BeforeRemove */), lookup);
11177
11180
  await this.emitter.emitAsync(beforeRemoveEvent);
@@ -11189,23 +11192,26 @@ class ModelService extends ReadOnlyModelService {
11189
11192
  return result;
11190
11193
  }
11191
11194
  async create(input, options) {
11192
- const beforeCreateEvent = new MutationEvent(this.getDescriptor("beforeCreate" /* BeforeCreate */), input);
11195
+ const normalizedInput = await this.normalizeInput(input);
11196
+ const beforeCreateEvent = new MutationEvent(this.getDescriptor("beforeCreate" /* BeforeCreate */), normalizedInput);
11193
11197
  await this.emitter.emitAsync(beforeCreateEvent);
11194
- const result = await this.repository.create(input, options);
11195
- const afterCreateEvent = new MutationEvent(this.getDescriptor("afterCreate" /* AfterCreate */), input).setResult(result);
11198
+ const result = await this.repository.create(normalizedInput, options);
11199
+ const afterCreateEvent = new MutationEvent(this.getDescriptor("afterCreate" /* AfterCreate */), normalizedInput).setResult(result);
11196
11200
  await this.emitter.emitAsync(afterCreateEvent);
11197
11201
  return result;
11198
11202
  }
11199
11203
  async update(lookup, input, options) {
11200
- const beforeUpdateEvent = new MutationEvent(this.getDescriptor("beforeUpdate" /* BeforeUpdate */), input);
11204
+ const normalizedInput = await this.normalizeInput(input);
11205
+ const beforeUpdateEvent = new MutationEvent(this.getDescriptor("beforeUpdate" /* BeforeUpdate */), normalizedInput);
11201
11206
  await this.emitter.emitAsync(beforeUpdateEvent);
11202
- const result = await this.repository.update(lookup, input, options);
11203
- const afterUpdateEvent = new MutationEvent(this.getDescriptor("afterUpdate" /* AfterUpdate */), input).setResult(result);
11207
+ const result = await this.repository.update(lookup, normalizedInput, options);
11208
+ const afterUpdateEvent = new MutationEvent(this.getDescriptor("afterUpdate" /* AfterUpdate */), normalizedInput).setResult(result);
11204
11209
  await this.emitter.emitAsync(afterUpdateEvent);
11205
11210
  return result;
11206
11211
  }
11207
11212
  async upsert(input, options) {
11208
- const primaryKeyValue = this.getPrimaryKeyValue(input);
11213
+ const normalizedInput = await this.normalizeInput(input);
11214
+ const primaryKeyValue = this.getPrimaryKeyValue(normalizedInput);
11209
11215
  let beforeOperation;
11210
11216
  let afterOperation;
11211
11217
  if (primaryKeyValue === undefined) {
@@ -11223,10 +11229,10 @@ class ModelService extends ReadOnlyModelService {
11223
11229
  afterOperation = "afterCreate" /* AfterCreate */;
11224
11230
  }
11225
11231
  }
11226
- const beforeUpsertEvent = new MutationEvent(this.getDescriptor(beforeOperation), input);
11232
+ const beforeUpsertEvent = new MutationEvent(this.getDescriptor(beforeOperation), normalizedInput);
11227
11233
  await this.emitter.emitAsync(beforeUpsertEvent);
11228
- const result = await this.repository.upsert(input, options);
11229
- const afterUpsertEvent = new MutationEvent(this.getDescriptor(afterOperation), input).setResult(result);
11234
+ const result = await this.repository.upsert(normalizedInput, options);
11235
+ const afterUpsertEvent = new MutationEvent(this.getDescriptor(afterOperation), normalizedInput).setResult(result);
11230
11236
  await this.emitter.emitAsync(afterUpsertEvent);
11231
11237
  return result;
11232
11238
  }
@@ -11234,9 +11240,10 @@ class ModelService extends ReadOnlyModelService {
11234
11240
  if (inputs.length === 0) {
11235
11241
  return [];
11236
11242
  }
11243
+ const normalizedInputs = await Promise.all(inputs.map((input) => this.normalizeInput(input)));
11237
11244
  const entityInfoMap = new Map;
11238
11245
  const inputsWithoutPrimaryKey = [];
11239
- for (const input of inputs) {
11246
+ for (const input of normalizedInputs) {
11240
11247
  const primaryKeyValue = this.getPrimaryKeyValue(input);
11241
11248
  if (primaryKeyValue !== undefined) {
11242
11249
  const entityInfo = {
@@ -11274,7 +11281,7 @@ class ModelService extends ReadOnlyModelService {
11274
11281
  beforeEvents.push(new MutationEvent(this.getDescriptor("beforeCreate" /* BeforeCreate */), input));
11275
11282
  }
11276
11283
  await Promise.all(beforeEvents.map((event) => this.emitter.emitAsync(event)));
11277
- const results = await this.repository.bulkUpsert(inputs, options);
11284
+ const results = await this.repository.bulkUpsert(normalizedInputs, options);
11278
11285
  const resultsByPrimaryKey = new Map;
11279
11286
  const resultsWithoutPrimaryKey = [];
11280
11287
  for (const result of results) {
@@ -11528,5 +11535,5 @@ export {
11528
11535
  BaseModelService
11529
11536
  };
11530
11537
 
11531
- //# debugId=79EE3AB3B0DB0FAB64756E2164756E21
11538
+ //# debugId=D05B27DAC594136E64756E2164756E21
11532
11539
  //# sourceMappingURL=index.js.map