From d43097654cae3d21724a26037dec9fd447b29760 Mon Sep 17 00:00:00 2001 From: CarlosGamero <101278162+CarlosGamero@users.noreply.github.com> Date: Sat, 27 Jul 2024 15:57:08 +0200 Subject: [PATCH] Fixing undefined schemaVersion on autofill + test (#196) * Fixing undefined schemaVersion on autofill + test * core patch release prepare --- .../core/lib/events/DomainEventEmitter.spec.ts | 3 +++ packages/core/lib/events/DomainEventEmitter.ts | 15 ++++++--------- packages/core/package.json | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/core/lib/events/DomainEventEmitter.spec.ts b/packages/core/lib/events/DomainEventEmitter.spec.ts index 733957cd..16334d59 100644 --- a/packages/core/lib/events/DomainEventEmitter.spec.ts +++ b/packages/core/lib/events/DomainEventEmitter.spec.ts @@ -114,6 +114,9 @@ describe('AutopilotEventEmitter', () => { }) expect(fakeListener.receivedEvents[0].metadata).toMatchObject({ correlationId: expect.any(String), + schemaVersion: '1.0.0', + producedBy: 'test', + originatedFrom: 'test', }) }) diff --git a/packages/core/lib/events/DomainEventEmitter.ts b/packages/core/lib/events/DomainEventEmitter.ts index 5433bb91..37ebd36d 100644 --- a/packages/core/lib/events/DomainEventEmitter.ts +++ b/packages/core/lib/events/DomainEventEmitter.ts @@ -72,15 +72,12 @@ export class DomainEventEmitter } if (!data.metadata) { - data.metadata = precedingMessageMetadata - ? // @ts-ignore - this.metadataFiller.produceMetadata(data, supportedEvent, precedingMessageMetadata) - : { - correlationId: this.metadataFiller.produceId(), - schemaVersion: supportedEvent.schemaVersion, - producedBy: this.metadataFiller.produceCurrentServiceId(), - originatedFrom: this.metadataFiller.produceCurrentServiceId(), - } + data.metadata = this.metadataFiller.produceMetadata( + // @ts-ignore + data, + supportedEvent, + precedingMessageMetadata ?? {}, + ) } if (!data.metadata.correlationId) { diff --git a/packages/core/package.json b/packages/core/package.json index 522dede2..70fbd097 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@message-queue-toolkit/core", - "version": "16.0.0", + "version": "16.0.1", "private": false, "license": "MIT", "description": "Useful utilities, interfaces and base classes for message queue handling. Supports AMQP and SQS with a common abstraction on top currently",