svix-react
Version:
React components for using Svix in your dashboard.
125 lines (124 loc) • 5.9 kB
TypeScript
import { EndpointOut, EndpointUpdate, EventTypeOut, StatusCodeClass, MessageStatus, MessageAttemptOut, EndpointSecretRotateIn, EndpointHeadersIn, RecoverIn, EndpointHeadersPatchIn } from "svix";
/** An object that allows for easy iteration over large sets of data */
export interface SvixPaginatedData<T> {
data: T[] | undefined;
reload: () => void;
hasPrevPage: boolean;
hasNextPage: boolean;
prevPage: () => void;
nextPage: () => void;
loading: boolean;
error: Error | undefined;
iterator: Iterator;
}
/** An object for interacting with a Svix entity */
interface SvixEntity<T> {
data: T | undefined;
reload: () => void;
loading: boolean;
error: Error | undefined;
}
/** An object for controlling iteration over large sets of data */
export interface SvixPaginatedOptions {
limit?: number;
iterator?: Iterator;
}
/** A modified SvixPaginatedOptions object that includes filters for attempts */
export interface SvixPaginatedOptionsAttempts extends SvixPaginatedOptions {
status?: MessageStatus;
eventTypes?: EventTypeOut[];
before?: Date;
after?: Date;
statusCodeClass?: StatusCodeClass;
channel?: string;
withContent?: boolean;
}
/** A modified SvixPaginatedOptions object that includes filters for attempts and messages */
export interface SvixPaginatedOptionsAttemptsByEndpoint extends SvixPaginatedOptionsAttempts {
withMsg?: boolean;
}
/** A modified SvixPaginatedOptions object that includes filters for messages */
export interface SvixPaginatedOptionsMessages extends SvixPaginatedOptions {
eventTypes?: EventTypeOut[];
before?: Date;
after?: Date;
channel?: string;
withContent?: boolean;
tag?: string;
}
/** Returns a SvixPaginatedData object containing the specified Consumer App's endpoints */
export declare function useEndpoints(options?: SvixPaginatedOptions): SvixPaginatedData<EndpointOut>;
/** Returns a Svix endpoint */
export declare function useEndpoint(endpointId: string): SvixEntity<EndpointOut>;
/** Returns a SvixEntity object for interacting with the specified endpoint's secret */
export declare function useEndpointSecret(endpointId: string): {
rotateSecret: (newSecret: EndpointSecretRotateIn) => Promise<void>;
data: import("svix").EndpointSecretOut | undefined;
reload: () => void;
loading: boolean;
error: Error | undefined;
};
/** Returns functions for interacting with the specified endpoint */
export declare function useEndpointFunctions(endpointId: string): {
recoverEndpointMessages: (options: RecoverIn) => Promise<void>;
updateEndpoint: (options: EndpointUpdate) => Promise<EndpointOut>;
deleteEndpoint: () => Promise<void>;
};
/** Returns a SvixEntity object containing the specified endpoint's stats */
export declare function useEndpointStats(endpointId: string): SvixEntity<import("svix").EndpointStats>;
/** Returns a SvixEntity object for interacting with the specified endpoint's headers */
export declare function useEndpointHeaders(endpointId: string): {
updateEndpointHeaders: (updateHeaders: EndpointHeadersIn) => Promise<void>;
patchEndpointHeaders: (patchHeaders: EndpointHeadersPatchIn) => Promise<void>;
data: import("svix").EndpointHeadersOut | undefined;
reload: () => void;
loading: boolean;
error: Error | undefined;
};
/** Returns a SvixPaginatedData object containing message attempts to the specified endpoint */
export declare function useEndpointMessageAttempts(endpointId: string, options?: SvixPaginatedOptionsAttemptsByEndpoint): SvixPaginatedData<MessageAttemptOut>;
/** Returns a SvixPaginatedData object containing the messages to the specified endpoint. Additionally includes metadata about the latest message attempt. */
export declare function useAttemptedMessages(endpointId: string, options?: SvixPaginatedOptionsAttempts): SvixPaginatedData<import("svix").EndpointMessageOut>;
/** Returns a SvixPaginatedData object containing the EventTypes on this environment */
export declare function useEventTypes(options?: SvixPaginatedOptions): SvixPaginatedData<EventTypeOut>;
/** Returns a SvixPaginatedData object containing the specified Consumer App's messages */
export declare function useMessages(options?: SvixPaginatedOptionsMessages): SvixPaginatedData<import("svix").MessageOut>;
/** Returns a SvixEntity object containing the specified message */
export declare function useMessage(messageId: string): SvixEntity<import("svix").MessageOut>;
/** Returns a SvixPaginatedData object containing endpoints the specified message is sent to */
export declare function useMessageEndpoints(messageId: string, options?: SvixPaginatedOptionsAttempts): SvixPaginatedData<import("svix").MessageEndpointOut>;
/** Returns a SvixPaginatedData object containing the specified message's attempts */
export declare function useMessageAttempts(messageId: string, options?: SvixPaginatedOptionsAttempts): SvixPaginatedData<MessageAttemptOut>;
export declare function useAttemptFunctions(attempt: MessageAttemptOut): {
resendAttempt: () => Promise<void>;
};
/** Provides form state and other useful utilities for creating a new endpoint */
export declare function useNewEndpoint(): {
url: {
value: string;
setValue: (v: string) => void;
};
description: {
value: string;
setValue: (v: string) => void;
};
eventTypes: {
value: string[];
setValue: (v: string[]) => void;
};
rateLimitPerSecond: {
value: number | undefined;
setValue: (v: number | undefined) => void;
};
createEndpoint: () => Promise<{
endpoint?: EndpointOut;
error?: Error;
}>;
};
/** Returns the Svix library and current appId */
export declare function useSvix(): {
svix: import("svix").Svix;
appId: string;
};
declare type Iterator = string | undefined;
export {};