@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.
@@ -11211,6 +11211,9 @@ class ModelService extends ReadOnlyModelService {
11211
11211
  constructor(args) {
11212
11212
  super(args);
11213
11213
  }
11214
+ async normalizeInput(input) {
11215
+ return input;
11216
+ }
11214
11217
  async remove(lookup, options) {
11215
11218
  const beforeRemoveEvent = new MutationEvent(this.getDescriptor("beforeRemove" /* BeforeRemove */), lookup);
11216
11219
  await this.emitter.emitAsync(beforeRemoveEvent);
@@ -11228,23 +11231,26 @@ class ModelService extends ReadOnlyModelService {
11228
11231
  return result;
11229
11232
  }
11230
11233
  async create(input, options) {
11231
- const beforeCreateEvent = new MutationEvent(this.getDescriptor("beforeCreate" /* BeforeCreate */), input);
11234
+ const normalizedInput = await this.normalizeInput(input);
11235
+ const beforeCreateEvent = new MutationEvent(this.getDescriptor("beforeCreate" /* BeforeCreate */), normalizedInput);
11232
11236
  await this.emitter.emitAsync(beforeCreateEvent);
11233
- const result = await this.repository.create(input, options);
11234
- const afterCreateEvent = new MutationEvent(this.getDescriptor("afterCreate" /* AfterCreate */), input).setResult(result);
11237
+ const result = await this.repository.create(normalizedInput, options);
11238
+ const afterCreateEvent = new MutationEvent(this.getDescriptor("afterCreate" /* AfterCreate */), normalizedInput).setResult(result);
11235
11239
  await this.emitter.emitAsync(afterCreateEvent);
11236
11240
  return result;
11237
11241
  }
11238
11242
  async update(lookup, input, options) {
11239
- const beforeUpdateEvent = new MutationEvent(this.getDescriptor("beforeUpdate" /* BeforeUpdate */), input);
11243
+ const normalizedInput = await this.normalizeInput(input);
11244
+ const beforeUpdateEvent = new MutationEvent(this.getDescriptor("beforeUpdate" /* BeforeUpdate */), normalizedInput);
11240
11245
  await this.emitter.emitAsync(beforeUpdateEvent);
11241
- const result = await this.repository.update(lookup, input, options);
11242
- const afterUpdateEvent = new MutationEvent(this.getDescriptor("afterUpdate" /* AfterUpdate */), input).setResult(result);
11246
+ const result = await this.repository.update(lookup, normalizedInput, options);
11247
+ const afterUpdateEvent = new MutationEvent(this.getDescriptor("afterUpdate" /* AfterUpdate */), normalizedInput).setResult(result);
11243
11248
  await this.emitter.emitAsync(afterUpdateEvent);
11244
11249
  return result;
11245
11250
  }
11246
11251
  async upsert(input, options) {
11247
- const primaryKeyValue = this.getPrimaryKeyValue(input);
11252
+ const normalizedInput = await this.normalizeInput(input);
11253
+ const primaryKeyValue = this.getPrimaryKeyValue(normalizedInput);
11248
11254
  let beforeOperation;
11249
11255
  let afterOperation;
11250
11256
  if (primaryKeyValue === undefined) {
@@ -11262,10 +11268,10 @@ class ModelService extends ReadOnlyModelService {
11262
11268
  afterOperation = "afterCreate" /* AfterCreate */;
11263
11269
  }
11264
11270
  }
11265
- const beforeUpsertEvent = new MutationEvent(this.getDescriptor(beforeOperation), input);
11271
+ const beforeUpsertEvent = new MutationEvent(this.getDescriptor(beforeOperation), normalizedInput);
11266
11272
  await this.emitter.emitAsync(beforeUpsertEvent);
11267
- const result = await this.repository.upsert(input, options);
11268
- const afterUpsertEvent = new MutationEvent(this.getDescriptor(afterOperation), input).setResult(result);
11273
+ const result = await this.repository.upsert(normalizedInput, options);
11274
+ const afterUpsertEvent = new MutationEvent(this.getDescriptor(afterOperation), normalizedInput).setResult(result);
11269
11275
  await this.emitter.emitAsync(afterUpsertEvent);
11270
11276
  return result;
11271
11277
  }
@@ -11273,9 +11279,10 @@ class ModelService extends ReadOnlyModelService {
11273
11279
  if (inputs.length === 0) {
11274
11280
  return [];
11275
11281
  }
11282
+ const normalizedInputs = await Promise.all(inputs.map((input) => this.normalizeInput(input)));
11276
11283
  const entityInfoMap = new Map;
11277
11284
  const inputsWithoutPrimaryKey = [];
11278
- for (const input of inputs) {
11285
+ for (const input of normalizedInputs) {
11279
11286
  const primaryKeyValue = this.getPrimaryKeyValue(input);
11280
11287
  if (primaryKeyValue !== undefined) {
11281
11288
  const entityInfo = {
@@ -11313,7 +11320,7 @@ class ModelService extends ReadOnlyModelService {
11313
11320
  beforeEvents.push(new MutationEvent(this.getDescriptor("beforeCreate" /* BeforeCreate */), input));
11314
11321
  }
11315
11322
  await Promise.all(beforeEvents.map((event) => this.emitter.emitAsync(event)));
11316
- const results = await this.repository.bulkUpsert(inputs, options);
11323
+ const results = await this.repository.bulkUpsert(normalizedInputs, options);
11317
11324
  const resultsByPrimaryKey = new Map;
11318
11325
  const resultsWithoutPrimaryKey = [];
11319
11326
  for (const result of results) {
@@ -11549,5 +11556,5 @@ class MockMemoryRepository {
11549
11556
  }
11550
11557
  }
11551
11558
 
11552
- //# debugId=C76D81F34A7396E664756E2164756E21
11559
+ //# debugId=2ABA230E346B7A7A64756E2164756E21
11553
11560
  //# sourceMappingURL=index.cjs.map