core-utils
    Preparing search index...

    Module @clipboard-health/notifications - v0.1.1

    @clipboard-health/notifications

    Send notifications through third-party providers.

    npm install @clipboard-health/notifications
    
    import { NotificationClient, type Span } from "@clipboard-health/notifications";
    import { isSuccess } from "@clipboard-health/util-ts";

    const client = new NotificationClient({
    apiKey: "test-api-key",
    logger: {
    info: console.log,
    warn: console.warn,
    error: console.error,
    } as const,
    tracer: {
    trace: <T>(_name: string, _options: unknown, fun: (span?: Span | undefined) => T): T => fun(),
    },
    });

    async function triggerNotification(job: { attemptsCount: number }) {
    const result = await client.trigger({
    attempt: (job?.attemptsCount ?? 0) + 1,
    body: {
    recipients: ["user-1"],
    data: { favoriteColor: "blue", secret: "2" },
    },
    expiresAt: new Date(Date.now() + 300_000), // 5 minutes
    idempotencyKey: "welcome-user-4",
    key: "welcome-email",
    keysToRedact: ["secret"],
    });

    if (isSuccess(result)) {
    console.log("Notification sent:", result.value.id);
    }
    }

    // eslint-disable-next-line unicorn/prefer-top-level-await
    void triggerNotification({ attemptsCount: 0 });

    See package.json scripts for a list of commands.

    Classes

    NotificationClient

    Interfaces

    AppendPushTokenRequest
    AppendPushTokenResponse
    InlineIdentifyUserRequest
    LogParams
    PushChannelData
    Span
    TraceOptions
    Tracer
    TriggerBody
    TriggerRequest
    TriggerResponse
    UpsertWorkplaceRequest
    UpsertWorkplaceResponse

    Type Aliases

    ErrorCode
    InlineChannelDataRequest
    MobilePlatform
    RecipientRequest
    Tags

    Variables

    ERROR_CODES
    MAXIMUM_RECIPIENTS_COUNT
    MOBILE_PLATFORMS

    Functions

    chunkRecipients
    createDeterministicHash
    errorsInResult