Skip to content

user-notifications API

Everything the package exports, by the path you import it from. Open an export for its signature and options.

@evolve-framework/user-notifications

The notification types and schemas, parseNotification to read one back, and QueuedUserNotificationClient to publish one.

Classes

QueuedUserNotificationClient
import { QueuedUserNotificationClient } from "@evolve-framework/user-notifications";
new QueuedUserNotificationClient()
MethodDescription
configure(origin: string, messagePublisher: MessagePublisher): void
passwordResetRequest( options: PasswordResetRequestNotification, ): Promise<void>Sends a password reset request notification.
passwordResetComplete( options: PasswordResetCompleteNotification, ): Promise<void>Sends a password reset complete notification.
orderConfirmed( options: OrderConfirmedNotification, ): Promise<void>Sends an order confirmed notification.
accountCreated( options: AccountCreatedNotification, ): Promise<void>Sends an account created notification.
orderShipped( options: OrderShippedNotification, ): Promise<void>Sends an order shipped notification.
associateInvited( options: AssociateInvitedNotification, ): Promise<void>Sends an invitation to join a business unit.
quoteRequested( options: QuoteRequestedNotification, ): Promise<void>Confirms to the buyer that their quote request was received.
quoteReady( options: QuoteReadyNotification, ): Promise<void>Tells the buyer a quote is ready to accept or decline.
backInStock( options: BackInStockNotification, ): Promise<void>Tells a shopper who asked to hear about it that a variant is back in stock.
backInStockSubscribed( options: BackInStockSubscribedNotification, ): Promise<void>Confirms a back-in-stock sign-up, with the token that withdraws it.

Functions

parseNotificationReads a message off the bus, throwing ZodError when it is not one.
import { parseNotification } from "@evolve-framework/user-notifications";

A message arrives as untrusted input, so a consumer parses rather than casts: the publisher may be a version ahead, and a field the consumer believes is there decides what the mail says.

function parseNotification(
value: unknown,
): UserNotification

Returns UserNotification

Types

AccountCreatedNotification
import { type AccountCreatedNotification } from "@evolve-framework/user-notifications";
export type AccountCreatedNotification = Pick<UserAccountCreatedNotification, "recipients" | "storeContext">;
AssociateInvitedNotification
import { type AssociateInvitedNotification } from "@evolve-framework/user-notifications";
export type AssociateInvitedNotification = Pick<UserAssociateInvitedNotification, "recipients" | "storeContext" | "variables">;
BackInStockNotification
import { type BackInStockNotification } from "@evolve-framework/user-notifications";
export type BackInStockNotification = Pick<UserBackInStockNotification, "recipients" | "storeContext" | "variables">;
BackInStockSubscribedNotification
import { type BackInStockSubscribedNotification } from "@evolve-framework/user-notifications";
export type BackInStockSubscribedNotification = Pick<UserBackInStockSubscribedNotification, "recipients" | "storeContext" | "variables">;
MessagePublisherThe publish-side port.
import { type MessagePublisher } from "@evolve-framework/user-notifications";
export type MessagePublisher = {
publish(message: Message, options?: PublishMessageOptions): Promise<void>;
close?(): Promise<void>;
};
OrderConfirmedNotification
import { type OrderConfirmedNotification } from "@evolve-framework/user-notifications";
export type OrderConfirmedNotification = Pick<UserOrderConfirmationNotification, "recipients" | "cc" | "storeContext" | "variables">;
OrderShippedNotification
import { type OrderShippedNotification } from "@evolve-framework/user-notifications";
export type OrderShippedNotification = Pick<UserOrderShippedNotification, "recipients" | "storeContext" | "variables">;
PasswordResetCompleteNotification
import { type PasswordResetCompleteNotification } from "@evolve-framework/user-notifications";
export type PasswordResetCompleteNotification = Pick<UserPasswordResetCompleteNotification, "recipients" | "storeContext">;
PasswordResetRequestNotification
import { type PasswordResetRequestNotification } from "@evolve-framework/user-notifications";
export type PasswordResetRequestNotification = Pick<UserPasswordResetRequestNotification, "recipients" | "storeContext" | "variables">;
QuoteReadyNotification
import { type QuoteReadyNotification } from "@evolve-framework/user-notifications";
export type QuoteReadyNotification = Pick<UserQuoteReadyNotification, "recipients" | "storeContext" | "variables">;
QuoteRequestedNotification
import { type QuoteRequestedNotification } from "@evolve-framework/user-notifications";
export type QuoteRequestedNotification = Pick<UserQuoteRequestedNotification, "recipients" | "storeContext" | "variables">;
UserNotificationA notification as it travels on the bus, discriminated on type.
import { type UserNotification } from "@evolve-framework/user-notifications";

Carries origin and timestamp, which the queue adds and no caller passes, so a consumer switching on type covers every case and gains a compile error when one is added.

export type UserNotification = z.infer<typeof userNotificationSchema>;
UserNotificationClient
import { type UserNotificationClient } from "@evolve-framework/user-notifications";
export interface UserNotificationClient {
passwordResetRequest(params: PasswordResetRequestNotification): Promise<void>;
passwordResetComplete(params: PasswordResetCompleteNotification): Promise<void>;
orderConfirmed(params: OrderConfirmedNotification): Promise<void>;
accountCreated(params: AccountCreatedNotification): Promise<void>;
orderShipped(params: OrderShippedNotification): Promise<void>;
associateInvited(params: AssociateInvitedNotification): Promise<void>;
quoteRequested(params: QuoteRequestedNotification): Promise<void>;
quoteReady(params: QuoteReadyNotification): Promise<void>;
backInStock(params: BackInStockNotification): Promise<void>;
backInStockSubscribed?(params: BackInStockSubscribedNotification): Promise<void>;
}