Skip to main content

Class: NotificationService

Hierarchy

  • TransactionBaseServiceCopy to Clipboard

    NotificationServiceCopy to Clipboard

Constructors

constructor

new NotificationService(containerCopy to Clipboard)

Parameters

NameType
containerCopy to ClipboardInjectedDependenciesCopy to Clipboard

Overrides

TransactionBaseService.constructor

Defined in

packages/medusa/src/services/notification.ts:36

Properties

__configModule__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __configModule__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__configModule__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:10


__container__

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard __container__: anyCopy to Clipboard

Inherited from

TransactionBaseService.__container__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:9


__moduleDeclaration__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __moduleDeclaration__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:11


attachmentGenerator_

ProtectedCopy to Clipboard attachmentGenerator_: unknownCopy to Clipboard = nullCopy to Clipboard

Defined in

packages/medusa/src/services/notification.ts:27


container_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard container_: InjectedDependenciesCopy to Clipboard & {}

Defined in

packages/medusa/src/services/notification.ts:28


logger_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard logger_: LoggerCopy to Clipboard

Defined in

packages/medusa/src/services/notification.ts:31


manager_

ProtectedCopy to Clipboard manager_: EntityManagerCopy to Clipboard

Overrides

TransactionBaseService.manager_

Defined in

packages/medusa/src/services/notification.ts:23


notificationProviderRepository_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard notificationProviderRepository_: typeof NotificationProviderRepositoryCopy to Clipboard

Defined in

packages/medusa/src/services/notification.ts:34


notificationRepository_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard notificationRepository_: typeof NotificationRepositoryCopy to Clipboard

Defined in

packages/medusa/src/services/notification.ts:32


subscribers_

ProtectedCopy to Clipboard subscribers_: ObjectCopy to Clipboard = {}Copy to Clipboard

Defined in

packages/medusa/src/services/notification.ts:26


transactionManager_

ProtectedCopy to Clipboard transactionManager_: undefinedCopy to Clipboard | EntityManagerCopy to Clipboard

Overrides

TransactionBaseService.transactionManager_

Defined in

packages/medusa/src/services/notification.ts:24

Methods

atomicPhase_

ProtectedCopy to Clipboard atomicPhase_<TResultCopy to Clipboard, TErrorCopy to Clipboard>(workCopy to Clipboard, isolationOrErrorHandler?Copy to Clipboard, maybeErrorHandlerOrDontFail?Copy to Clipboard): PromiseCopy to Clipboard<TResultCopy 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
TResultCopy to Clipboard
TErrorCopy to Clipboard

Parameters

NameTypeDescription
workCopy to Clipboard(transactionManagerCopy to Clipboard: EntityManagerCopy to Clipboard) => PromiseCopy to Clipboard<TResultCopy to Clipboard>the transactional work to be done
isolationOrErrorHandler?Copy to ClipboardIsolationLevelCopy to Clipboard | (errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail?Copy to Clipboard(errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>Potential error handler

Returns

PromiseCopy to Clipboard<TResultCopy 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(eventNameCopy to Clipboard, dataCopy to Clipboard): PromiseCopy to Clipboard<undefinedCopy to Clipboard | voidCopy to Clipboard | NotificationCopy 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

NameTypeDescription
eventNameCopy to ClipboardstringCopy to Clipboardthe event to handle
dataCopy to ClipboardRecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>the data the event was sent with

Returns

PromiseCopy to Clipboard<undefinedCopy to Clipboard | voidCopy to Clipboard | NotificationCopy to Clipboard[]>

the result of notification subscribed

Defined in

packages/medusa/src/services/notification.ts:174


list

list(selectorCopy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<NotificationCopy to Clipboard[]>

Retrieves a list of notifications.

Parameters

NameTypeDescription
selectorCopy to ClipboardSelectorCopy to Clipboard<NotificationCopy to Clipboard>the params to select the notifications by.
configCopy to ClipboardFindConfigCopy to Clipboard<NotificationCopy to Clipboard>the configuration to apply to the query

Returns

PromiseCopy to Clipboard<NotificationCopy to Clipboard[]>

the notifications that satisfy the query.

Defined in

packages/medusa/src/services/notification.ts:86


registerAttachmentGenerator

registerAttachmentGenerator(serviceCopy to Clipboard): voidCopy to Clipboard

Registers an attachment generator to the service. The generator can be used to generate on demand invoices or other documents.

Parameters

NameTypeDescription
serviceCopy to ClipboardunknownCopy to Clipboardthe service to assign to the attachmentGenerator

Returns

voidCopy to Clipboard

Defined in

packages/medusa/src/services/notification.ts:62


registerInstalledProviders

registerInstalledProviders(providerIdsCopy to Clipboard): PromiseCopy to Clipboard<voidCopy to Clipboard>

Takes a list of notification provider ids and persists them in the database.

Parameters

NameTypeDescription
providerIdsCopy to ClipboardstringCopy to Clipboard[]a list of provider ids

Returns

PromiseCopy to Clipboard<voidCopy to Clipboard>

Defined in

packages/medusa/src/services/notification.ts:70


resend

resend(idCopy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<NotificationCopy to Clipboard>

Resends a notification by retrieving a prior notification and calling the underlying provider's resendNotification method.

Parameters

NameTypeDescription
idCopy to ClipboardstringCopy to Clipboardthe id of the notification
configCopy to ClipboardFindConfigCopy to Clipboard<NotificationCopy to Clipboard>any configuration that might override the previous send

Returns

PromiseCopy to Clipboard<NotificationCopy to Clipboard>

the newly created notification

Defined in

packages/medusa/src/services/notification.ts:254


retrieve

retrieve(idCopy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<NotificationCopy to Clipboard>

Retrieves a notification with a given id

Parameters

NameTypeDescription
idCopy to ClipboardstringCopy to Clipboardthe id of the notification
configCopy to ClipboardFindConfigCopy to Clipboard<NotificationCopy to Clipboard>the configuration to apply to the query

Returns

PromiseCopy to Clipboard<NotificationCopy to Clipboard>

the notification

Defined in

packages/medusa/src/services/notification.ts:107


retrieveProvider_

ProtectedCopy to Clipboard retrieveProvider_(idCopy to Clipboard): AbstractNotificationServiceCopy to Clipboard

Finds a provider with a given id. Will throw a NOT_FOUND error if the resolution fails.

Parameters

NameTypeDescription
idCopy to ClipboardstringCopy to Clipboardthe id of the provider

Returns

AbstractNotificationServiceCopy to Clipboard

the notification provider

Defined in

packages/medusa/src/services/notification.ts:155


send

send(eventCopy to Clipboard, eventDataCopy to Clipboard, providerIdCopy to Clipboard): PromiseCopy to Clipboard<undefinedCopy to Clipboard | NotificationCopy to Clipboard>

Sends a notification, by calling the given provider's sendNotification method. Persists the Notification in the database.

Parameters

NameTypeDescription
eventCopy to ClipboardstringCopy to Clipboardthe name of the event
eventDataCopy to ClipboardRecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>the data the event was sent with
providerIdCopy to ClipboardstringCopy to Clipboardthe provider that should hande the event.

Returns

PromiseCopy to Clipboard<undefinedCopy to Clipboard | NotificationCopy to Clipboard>

the created notification

Defined in

packages/medusa/src/services/notification.ts:206


shouldRetryTransaction_

ProtectedCopy to Clipboard shouldRetryTransaction_(errCopy to Clipboard): booleanCopy to Clipboard

Parameters

NameType
errCopy to ClipboardRecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard> | { codeCopy to Clipboard: stringCopy to Clipboard }

Returns

booleanCopy to Clipboard

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:31


subscribe

subscribe(eventNameCopy to Clipboard, providerIdCopy to Clipboard): voidCopy to Clipboard

Subscribes a given provider to an event.

Parameters

NameTypeDescription
eventNameCopy to ClipboardstringCopy to Clipboardthe event to subscribe to
providerIdCopy to ClipboardstringCopy to Clipboardthe provider that the event will be sent to

Returns

voidCopy to Clipboard

Defined in

packages/medusa/src/services/notification.ts:134


withTransaction

withTransaction(transactionManager?Copy to Clipboard): NotificationServiceCopy to Clipboard

Parameters

NameType
transactionManager?Copy to ClipboardEntityManagerCopy to Clipboard

Returns

NotificationServiceCopy to Clipboard

Inherited from

TransactionBaseService.withTransaction

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:14