Skip to content

Commit

Permalink
Extract vendor-specific schemas (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
kibertoad authored May 31, 2024
1 parent 6c5b2d9 commit c891bf1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
9 changes: 2 additions & 7 deletions packages/amqp/lib/AmqpQueuePublisherManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
PublisherBaseEventType,
CommonEventDefinition,
EventRegistry,
MetadataFiller,
MessageMetadataType,
Expand All @@ -9,6 +8,7 @@ import type {
CommonCreationConfigType,
} from '@message-queue-toolkit/core'
import { AbstractPublisherManager } from '@message-queue-toolkit/core'
import type { AmqpAwareEventDefinition } from '@message-queue-toolkit/schemas'
import type z from 'zod'

import type { AbstractAmqpPublisher, AMQPPublisherOptions } from './AbstractAmqpPublisher'
Expand All @@ -24,12 +24,7 @@ import type {
import type { AmqpPublisherFactory } from './CommonAmqpPublisherFactory'
import { CommonAmqpQueuePublisherFactory } from './CommonAmqpPublisherFactory'

export type AmqpAwareEventDefinition = {
schemaVersion?: string
exchange?: string // optional if used with a direct exchange
queueName?: string // should only be specified for direct exchanges
topic?: string // used for topic exchanges
} & CommonEventDefinition
export type { AmqpAwareEventDefinition }

export type AmqpPublisherManagerDependencies<SupportedEvents extends AmqpAwareEventDefinition[]> = {
eventRegistry: EventRegistry<SupportedEvents>
Expand Down
3 changes: 3 additions & 0 deletions packages/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ export { toDatePreprocessor } from './lib/utils/toDateProcessor'
export * from './lib/events/eventTypes'
export * from './lib/events/baseEventSchemas'
export * from './lib/messages/baseMessageSchemas'

export * from './lib/vendors/amqpSchemas'
export * from './lib/vendors/snsSchemas'
8 changes: 8 additions & 0 deletions packages/schemas/lib/vendors/amqpSchemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { CommonEventDefinition } from '../events/eventTypes'

export type AmqpAwareEventDefinition = {
schemaVersion?: string
exchange?: string // optional if used with a direct exchange
queueName?: string // should only be specified for direct exchanges
topic?: string // used for topic exchanges
} & CommonEventDefinition
6 changes: 6 additions & 0 deletions packages/schemas/lib/vendors/snsSchemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { CommonEventDefinition } from '../events/eventTypes'

export type SnsAwareEventDefinition = {
schemaVersion?: string
snsTopic?: string
} & CommonEventDefinition
7 changes: 2 additions & 5 deletions packages/sns/lib/sns/SnsPublisherManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type {
CommonEventDefinition,
EventRegistry,
MessagePublishType,
MessageSchemaType,
Expand All @@ -8,6 +7,7 @@ import type {
} from '@message-queue-toolkit/core'
import { AbstractPublisherManager } from '@message-queue-toolkit/core'
import type { MessageMetadataType } from '@message-queue-toolkit/core/lib/messages/baseMessageSchemas'
import type { SnsAwareEventDefinition } from '@message-queue-toolkit/schemas'
import type z from 'zod'

import type {
Expand All @@ -19,10 +19,7 @@ import type { SNSCreationConfig, SNSDependencies, SNSQueueLocatorType } from './
import type { SnsPublisherFactory } from './CommonSnsPublisherFactory'
import { CommonSnsPublisherFactory } from './CommonSnsPublisherFactory'

export type SnsAwareEventDefinition = {
schemaVersion?: string
snsTopic?: string
} & CommonEventDefinition
export type { SnsAwareEventDefinition }

export type SnsPublisherManagerDependencies<SupportedEvents extends SnsAwareEventDefinition[]> = {
eventRegistry: EventRegistry<SupportedEvents>
Expand Down

0 comments on commit c891bf1

Please sign in to comment.