Creates a new NotificationClient instance.
Protected
Readonly
loggerProtected
Readonly
providerProtected
Readonly
tracerAppend to a user's push tokens.
Promise resolving to either an error or successful response.
Protected
createSign a user token for enhanced security.
Promise resolving to either an error or successful response.
Triggers a notification through third-party providers.
This method handles:
Promise resolving to either an error or successful response.
import { type NotificationClient } from "@clipboard-health/notifications";
import { type ExampleNotificationJobData } from "./exampleNotification.job";
type ExampleNotificationDo = ExampleNotificationJobData & { attempt: number };
export class ExampleNotificationService {
constructor(private readonly client: NotificationClient) {}
async sendNotification(params: ExampleNotificationDo) {
const { attempt, expiresAt, idempotencyKey, recipients, workflowKey, workplaceId } = params;
// Assume this comes from a database and, for example, are used as template variables...
const data = { favoriteColor: "blue", secret: "2" };
return await this.client.trigger({
attempt,
body: {
recipients,
data,
workplaceId,
},
expiresAt: new Date(expiresAt),
idempotencyKey,
key: workflowKey,
keysToRedact: ["secret"],
workflowKey,
});
}
}
Updates or creates a workplace (tenant) in our provider.
Promise resolving to either an error or successful response.
Client for sending notifications through third-party providers.