Class: NotificationService
Hierarchy
TransactionBaseService
Copy to Clipboard↳
NotificationService
Copy to Clipboard
Constructors
constructor
• new NotificationService(container
Copy to Clipboard)
Parameters
Name | Type |
---|---|
container Copy to Clipboard | InjectedDependencies Copy to Clipboard |
Overrides
TransactionBaseService.constructor
Defined in
packages/medusa/src/services/notification.ts:36
Properties
__configModule__
• Protected
Copy to Clipboard Optional
Copy to Clipboard Readonly
Copy to Clipboard __configModule__: Record
Copy to Clipboard<string
Copy to Clipboard, unknown
Copy to Clipboard>
Inherited from
TransactionBaseService.__configModule__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:10
__container__
• Protected
Copy to Clipboard Readonly
Copy to Clipboard __container__: any
Copy to Clipboard
Inherited from
TransactionBaseService.__container__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:9
__moduleDeclaration__
• Protected
Copy to Clipboard Optional
Copy to Clipboard Readonly
Copy to Clipboard __moduleDeclaration__: Record
Copy to Clipboard<string
Copy to Clipboard, unknown
Copy to Clipboard>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:11
attachmentGenerator_
• Protected
Copy to Clipboard attachmentGenerator_: unknown
Copy to Clipboard = null
Copy to Clipboard
Defined in
packages/medusa/src/services/notification.ts:27
container_
• Protected
Copy to Clipboard Readonly
Copy to Clipboard container_: InjectedDependencies
Copy to Clipboard & {}
Defined in
packages/medusa/src/services/notification.ts:28
logger_
• Protected
Copy to Clipboard Readonly
Copy to Clipboard logger_: Logger
Copy to Clipboard
Defined in
packages/medusa/src/services/notification.ts:31
manager_
• Protected
Copy to Clipboard manager_: EntityManager
Copy to Clipboard
Overrides
TransactionBaseService.manager_
Defined in
packages/medusa/src/services/notification.ts:23
notificationProviderRepository_
• Protected
Copy to Clipboard Readonly
Copy to Clipboard notificationProviderRepository_: typeof NotificationProviderRepository
Copy to Clipboard
Defined in
packages/medusa/src/services/notification.ts:34
notificationRepository_
• Protected
Copy to Clipboard Readonly
Copy to Clipboard notificationRepository_: typeof NotificationRepository
Copy to Clipboard
Defined in
packages/medusa/src/services/notification.ts:32
subscribers_
• Protected
Copy to Clipboard subscribers_: Object
Copy to Clipboard = {}
Copy to Clipboard
Defined in
packages/medusa/src/services/notification.ts:26
transactionManager_
• Protected
Copy to Clipboard transactionManager_: undefined
Copy to Clipboard | EntityManager
Copy to Clipboard
Overrides
TransactionBaseService.transactionManager_
Defined in
packages/medusa/src/services/notification.ts:24
Methods
atomicPhase_
▸ Protected
Copy to Clipboard atomicPhase_<TResult
Copy to Clipboard, TError
Copy to Clipboard>(work
Copy to Clipboard, isolationOrErrorHandler?
Copy to Clipboard, maybeErrorHandlerOrDontFail?
Copy to Clipboard): Promise
Copy to Clipboard<TResult
Copy to Clipboard>
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
Type parameters
Name |
---|
TResult Copy to Clipboard |
TError Copy to Clipboard |
Parameters
Name | Type | Description |
---|---|---|
work Copy to Clipboard | (transactionManager Copy to Clipboard: EntityManager Copy to Clipboard) => Promise Copy to Clipboard<TResult Copy to Clipboard> | the transactional work to be done |
isolationOrErrorHandler? Copy to Clipboard | IsolationLevel Copy to Clipboard | (error Copy to Clipboard: TError Copy to Clipboard) => Promise Copy to Clipboard<void Copy to Clipboard | TResult Copy to Clipboard> | the isolation level to be used for the work. |
maybeErrorHandlerOrDontFail? Copy to Clipboard | (error Copy to Clipboard: TError Copy to Clipboard) => Promise Copy to Clipboard<void Copy to Clipboard | TResult Copy to Clipboard> | Potential error handler |
Returns
Promise
Copy to Clipboard<TResult
Copy to Clipboard>
the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:50
handleEvent
▸ handleEvent(eventName
Copy to Clipboard, data
Copy to Clipboard): Promise
Copy to Clipboard<undefined
Copy to Clipboard | void
Copy to Clipboard | Notification
Copy to Clipboard[]>
Handles an event by relaying the event data to the subscribing providers. The result of the notification send will be persisted in the database in order to allow for resends. Will log any errors that are encountered.
Parameters
Name | Type | Description |
---|---|---|
eventName Copy to Clipboard | string Copy to Clipboard | the event to handle |
data Copy to Clipboard | Record Copy to Clipboard<string Copy to Clipboard, unknown Copy to Clipboard> | the data the event was sent with |
Returns
Promise
Copy to Clipboard<undefined
Copy to Clipboard | void
Copy to Clipboard | Notification
Copy to Clipboard[]>
the result of notification subscribed
Defined in
packages/medusa/src/services/notification.ts:174
list
▸ list(selector
Copy to Clipboard, config?
Copy to Clipboard): Promise
Copy to Clipboard<Notification
Copy to Clipboard[]>
Retrieves a list of notifications.
Parameters
Name | Type | Description |
---|---|---|
selector Copy to Clipboard | Selector Copy to Clipboard<Notification Copy to Clipboard> | the params to select the notifications by. |
config Copy to Clipboard | FindConfig Copy to Clipboard<Notification Copy to Clipboard> | the configuration to apply to the query |
Returns
Promise
Copy to Clipboard<Notification
Copy to Clipboard[]>
the notifications that satisfy the query.
Defined in
packages/medusa/src/services/notification.ts:86
registerAttachmentGenerator
▸ registerAttachmentGenerator(service
Copy to Clipboard): void
Copy to Clipboard
Registers an attachment generator to the service. The generator can be used to generate on demand invoices or other documents.
Parameters
Name | Type | Description |
---|---|---|
service Copy to Clipboard | unknown Copy to Clipboard | the service to assign to the attachmentGenerator |
Returns
void
Copy to Clipboard
Defined in
packages/medusa/src/services/notification.ts:62
registerInstalledProviders
▸ registerInstalledProviders(providerIds
Copy to Clipboard): Promise
Copy to Clipboard<void
Copy to Clipboard>
Takes a list of notification provider ids and persists them in the database.
Parameters
Name | Type | Description |
---|---|---|
providerIds Copy to Clipboard | string Copy to Clipboard[] | a list of provider ids |
Returns
Promise
Copy to Clipboard<void
Copy to Clipboard>
Defined in
packages/medusa/src/services/notification.ts:70
resend
▸ resend(id
Copy to Clipboard, config?
Copy to Clipboard): Promise
Copy to Clipboard<Notification
Copy to Clipboard>
Resends a notification by retrieving a prior notification and calling the underlying provider's resendNotification method.
Parameters
Name | Type | Description |
---|---|---|
id Copy to Clipboard | string Copy to Clipboard | the id of the notification |
config Copy to Clipboard | FindConfig Copy to Clipboard<Notification Copy to Clipboard> | any configuration that might override the previous send |
Returns
Promise
Copy to Clipboard<Notification
Copy to Clipboard>
the newly created notification
Defined in
packages/medusa/src/services/notification.ts:254
retrieve
▸ retrieve(id
Copy to Clipboard, config?
Copy to Clipboard): Promise
Copy to Clipboard<Notification
Copy to Clipboard>
Retrieves a notification with a given id
Parameters
Name | Type | Description |
---|---|---|
id Copy to Clipboard | string Copy to Clipboard | the id of the notification |
config Copy to Clipboard | FindConfig Copy to Clipboard<Notification Copy to Clipboard> | the configuration to apply to the query |
Returns
Promise
Copy to Clipboard<Notification
Copy to Clipboard>
the notification
Defined in
packages/medusa/src/services/notification.ts:107
retrieveProvider_
▸ Protected
Copy to Clipboard retrieveProvider_(id
Copy to Clipboard): AbstractNotificationService
Copy to Clipboard
Finds a provider with a given id. Will throw a NOT_FOUND error if the resolution fails.
Parameters
Name | Type | Description |
---|---|---|
id Copy to Clipboard | string Copy to Clipboard | the id of the provider |
Returns
AbstractNotificationService
Copy to Clipboard
the notification provider
Defined in
packages/medusa/src/services/notification.ts:155
send
▸ send(event
Copy to Clipboard, eventData
Copy to Clipboard, providerId
Copy to Clipboard): Promise
Copy to Clipboard<undefined
Copy to Clipboard | Notification
Copy to Clipboard>
Sends a notification, by calling the given provider's sendNotification method. Persists the Notification in the database.
Parameters
Name | Type | Description |
---|---|---|
event Copy to Clipboard | string Copy to Clipboard | the name of the event |
eventData Copy to Clipboard | Record Copy to Clipboard<string Copy to Clipboard, unknown Copy to Clipboard> | the data the event was sent with |
providerId Copy to Clipboard | string Copy to Clipboard | the provider that should hande the event. |
Returns
Promise
Copy to Clipboard<undefined
Copy to Clipboard | Notification
Copy to Clipboard>
the created notification
Defined in
packages/medusa/src/services/notification.ts:206
shouldRetryTransaction_
▸ Protected
Copy to Clipboard shouldRetryTransaction_(err
Copy to Clipboard): boolean
Copy to Clipboard
Parameters
Name | Type |
---|---|
err Copy to Clipboard | Record Copy to Clipboard<string Copy to Clipboard, unknown Copy to Clipboard> | { code Copy to Clipboard: string Copy to Clipboard } |
Returns
boolean
Copy to Clipboard
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:31
subscribe
▸ subscribe(eventName
Copy to Clipboard, providerId
Copy to Clipboard): void
Copy to Clipboard
Subscribes a given provider to an event.
Parameters
Name | Type | Description |
---|---|---|
eventName Copy to Clipboard | string Copy to Clipboard | the event to subscribe to |
providerId Copy to Clipboard | string Copy to Clipboard | the provider that the event will be sent to |
Returns
void
Copy to Clipboard
Defined in
packages/medusa/src/services/notification.ts:134
withTransaction
▸ withTransaction(transactionManager?
Copy to Clipboard): NotificationService
Copy to Clipboard
Parameters
Name | Type |
---|---|
transactionManager? Copy to Clipboard | EntityManager Copy to Clipboard |
Returns
NotificationService
Copy to Clipboard
Inherited from
TransactionBaseService.withTransaction
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:14