@codesandbox/sdk
Version:
The CodeSandbox SDK
35 lines (34 loc) • 1.31 kB
TypeScript
import { TNotification, TMessage, ProtocolError } from "../protocol";
export type NotificationType = "info" | "warning" | "error";
export type Action = {
label: string;
};
/**
* Is sent from Pitcher to the client, to ask the client to show a notification.
* There's an ID given, this is important, because the client is responsible for
* using this to send a response back to the notification (either dismiss or one of
* the actions are clicked, in case there are actions).
*/
export type NotificationNotify = TNotification<"notification/notify", {
type: NotificationType;
notificationId: string;
message: string;
actions?: Action[];
}>;
/**
* Is sent from Pitcher to the client, to dismiss the notification.
*/
export type NotificationDismiss = TNotification<"notification/dismiss", {
notificationId: string;
}>;
export type NotificationAckResponse = TMessage<"notification/notifyResponse", {
notificationId: string;
response: string | null;
}, {
result: void;
error: ProtocolError;
}>;
export type NotificationNotification = NotificationNotify | NotificationDismiss;
export type NotificationMessage = NotificationAckResponse;
export type NotificationRequest = NotificationMessage["request"];
export type NotificationResponse = NotificationMessage["response"];