Creates a new NotificationClient instance.
Protected ReadonlyloggerProtected ReadonlyproviderProtected ReadonlytracerAppend to a user's push tokens.
Promise resolving to either an error or successful response.
ProtectedcreateSign 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 ExampleNotificationData } from "./exampleNotification.job";
type ExampleNotificationDo = ExampleNotificationData["Job"] & { 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 are used as template variables...
    // Use @clipboard-health/date-time's formatShortDateTime in your service for consistency.
    const data = { favoriteColor: "blue", favoriteAt: new Date().toISOString(), secret: "2" };
    // Important: Read the TypeDoc documentation for additional context.
    return await this.client.trigger({
      attempt,
      body: {
        data,
        recipients,
        workplaceId,
      },
      expiresAt: new Date(expiresAt),
      idempotencyKey,
      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.