Skip to content

Commit

Permalink
Lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosGamero committed Jul 26, 2024
1 parent 677d24a commit 4bba4c2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 43 deletions.
8 changes: 4 additions & 4 deletions packages/core/lib/events/DomainEventEmitter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ describe('AutopilotEventEmitter', () => {
expect(emitResult.message).toEqual({
id: expect.any(String),
metadata: {
"correlationId": createdEventPayload.metadata!.correlationId!,
"originatedFrom": "service",
"producedBy": undefined,
"schemaVersion": "1",
correlationId: createdEventPayload.metadata!.correlationId!,
originatedFrom: 'service',
producedBy: undefined,
schemaVersion: '1',
},
payload: {
message: 'msg',
Expand Down
4 changes: 1 addition & 3 deletions packages/core/lib/events/fakes/FakeListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ export class FakeListener<SupportedEvents extends CommonEventDefinition[]>
this.receivedEvents = []
}

handleEvent(
event: SupportedEvents[number]['publisherSchema']['_output'],
): void | Promise<void> {
handleEvent(event: SupportedEvents[number]['publisherSchema']['_output']): void | Promise<void> {
this.receivedEvents.push(event)
}
}
4 changes: 1 addition & 3 deletions packages/core/lib/messages/MetadataFiller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ export class CommonMetadataFiller implements MetadataFiller {
return {
producedBy: this.serviceId,
originatedFrom: precedingMessageMetadata?.originatedFrom ?? this.serviceId,
schemaVersion:
eventDefinition.schemaVersion ??
this.defaultVersion,
schemaVersion: eventDefinition.schemaVersion ?? this.defaultVersion,
correlationId: precedingMessageMetadata?.correlationId ?? this.produceId(),
}
}
Expand Down
60 changes: 30 additions & 30 deletions packages/schemas/lib/events/baseEventSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ import { z } from 'zod'

// External message metadata that describe the context in which the message was created, primarily used for debugging purposes
export const PUBLISHER_MESSAGE_METADATA_SCHEMA = z
.object({
schemaVersion: z.optional(z.string().min(1).describe('message schema version')),
// this is always set to a service that created the message
producedBy: z.optional(z.string().min(1).describe('app/service that produced the message')),
// this is always propagated within the message chain. For the first message in the chain it is equal to "producedBy"
originatedFrom: z.optional(
z
.string()
.min(1)
.describe('app/service that initiated entire workflow that led to creating this message'),
),
// this is always propagated within the message chain.
correlationId: z.optional(
z.string().describe('unique identifier passed to all events in workflow chain'),
),
})
.describe('external message metadata')
.object({
schemaVersion: z.optional(z.string().min(1).describe('message schema version')),
// this is always set to a service that created the message
producedBy: z.optional(z.string().min(1).describe('app/service that produced the message')),
// this is always propagated within the message chain. For the first message in the chain it is equal to "producedBy"
originatedFrom: z.optional(
z
.string()
.min(1)
.describe('app/service that initiated entire workflow that led to creating this message'),
),
// this is always propagated within the message chain.
correlationId: z.optional(
z.string().describe('unique identifier passed to all events in workflow chain'),
),
})
.describe('external message metadata')

export const CONSUMER_MESSAGE_METADATA_SCHEMA = z
.object({
schemaVersion: z.string().min(1).describe('message schema version'),
// this is always set to a service that created the message
producedBy: z.string().min(1).describe('app/service that produced the message'),
// this is always propagated within the message chain. For the first message in the chain it is equal to "producedBy"
originatedFrom: z
.string()
.min(1)
.describe('app/service that initiated entire workflow that led to creating this message'),
// this is always propagated within the message chain.
correlationId: z.string().describe('unique identifier passed to all events in workflow chain'),
})
.describe('external message metadata')
.object({
schemaVersion: z.string().min(1).describe('message schema version'),
// this is always set to a service that created the message
producedBy: z.string().min(1).describe('app/service that produced the message'),
// this is always propagated within the message chain. For the first message in the chain it is equal to "producedBy"
originatedFrom: z
.string()
.min(1)
.describe('app/service that initiated entire workflow that led to creating this message'),
// this is always propagated within the message chain.
correlationId: z.string().describe('unique identifier passed to all events in workflow chain'),
})
.describe('external message metadata')

// Base event fields that are typically autogenerated
export const GENERATED_BASE_EVENT_SCHEMA = z.object({
Expand Down
4 changes: 1 addition & 3 deletions packages/schemas/lib/events/eventTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ export type EventHandler<
EventDefinitionSchema extends
CommonEventDefinitionPublisherSchemaType<CommonEventDefinition> = CommonEventDefinitionPublisherSchemaType<CommonEventDefinition>,
> = {
handleEvent(
event: EventDefinitionSchema
): void | Promise<void>
handleEvent(event: EventDefinitionSchema): void | Promise<void>
}

export type AnyEventHandler<EventDefinitions extends CommonEventDefinition[]> = EventHandler<
Expand Down

0 comments on commit 4bba4c2

Please sign in to comment.