NotificationService
internal.internal.NotificationService
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>attachmentGenerator_
unknownRequiredmanager_
EntityManagerRequiredsubscribers_
objectRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
atomicPhase_
Protected
atomicPhase_<TResult
, TError
>(work
, isolationOrErrorHandler?
, maybeErrorHandlerOrDontFail?
): Promise
<TResult
>
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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
<TResult
>
Promise
Promise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
handleEvent
handleEvent(eventName
, data
): Promise
<undefined
| void
| Notification
[]>
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
eventName
stringRequireddata
Record<string, unknown>RequiredReturns
Promise
<undefined
| void
| Notification
[]>
the result of notification subscribed
list
list(selector
, config?
): Promise
<Notification
[]>
Retrieves a list of notifications.
Parameters
config
FindConfig<Notification>Returns
Promise
<Notification
[]>
the notifications that satisfy the query.
listAndCount
listAndCount(selector
, config?
): Promise
<[Notification
[], number
]>
Retrieves a list of notifications and total count.
Parameters
config
FindConfig<Notification>Returns
Promise
<[Notification
[], number
]>
the notifications that satisfy the query as well as the count.
registerAttachmentGenerator
registerAttachmentGenerator(service
): void
Registers an attachment generator to the service. The generator can be used to generate on demand invoices or other documents.
Parameters
service
unknownRequiredReturns
void
void
voidregisterInstalledProviders
registerInstalledProviders(providerIds
): Promise
<void
>
Takes a list of notification provider ids and persists them in the database.
Parameters
providerIds
string[]RequiredReturns
Promise
<void
>
Promise
Promise<void>Requiredresend
resend(id
, config?
): Promise
<Notification
>
Resends a notification by retrieving a prior notification and calling the underlying provider's resendNotification method.
Parameters
id
stringRequiredconfig
FindConfig<Notification>Returns
Promise
<Notification
>
the newly created notification
retrieve
retrieve(id
, config?
): Promise
<Notification
>
Retrieves a notification with a given id
Parameters
id
stringRequiredconfig
FindConfig<Notification>Returns
Promise
<Notification
>
the notification
retrieveProvider_
Protected
retrieveProvider_(id
): AbstractNotificationService
Finds a provider with a given id. Will throw a NOT_FOUND error if the resolution fails.
Parameters
id
stringRequiredReturns
send
send(event
, eventData
, providerId
): Promise
<undefined
| Notification
>
Sends a notification, by calling the given provider's sendNotification method. Persists the Notification in the database.
Parameters
event
stringRequiredeventData
Record<string, unknown>RequiredproviderId
stringRequiredReturns
Promise
<undefined
| Notification
>
the created notification
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanInherited from
TransactionBaseService.shouldRetryTransaction_
subscribe
subscribe(eventName
, providerId
): void
Subscribes a given provider to an event.
Parameters
eventName
stringRequiredproviderId
stringRequiredReturns
void
void
voidwithTransaction
withTransaction(transactionManager?
): NotificationService
Parameters
transactionManager
EntityManager