inngest
Version:
Official SDK for Inngest.com. Inngest is the reliability layer for modern applications. Inngest combines durable execution, events, and queues into a zero-infra platform with built-in observability.
66 lines (65 loc) • 3.49 kB
TypeScript
import { Realtime } from "./components/realtime/types.js";
import { Inngest } from "./components/Inngest.js";
import { getClientSubscriptionToken } from "./components/realtime/subscribe/index.js";
//#region src/react.d.ts
type UseRealtimeConnectionStatus = "idle" | "connecting" | "open" | "paused" | "closed" | "error";
type UseRealtimeRunStatus = "unknown" | "running" | "completed" | "failed" | "cancelled";
type ClientSubscriptionToken = Realtime.Subscribe.ClientToken;
type TokenFactory = () => Promise<string | ClientSubscriptionToken | Realtime.Subscribe.Token>;
type UseRealtimePauseReason = "hidden" | "disabled" | null;
type InferTopicConfigs<TChannel extends Realtime.ChannelInput> = TChannel extends Realtime.ChannelInstance<string, infer TTopicConfigs> ? TTopicConfigs : Record<string, Realtime.TopicConfig>;
type TopicLatestMessage<TChannel extends Realtime.ChannelInput, TKey extends string, TConfigs = InferTopicConfigs<TChannel>> = TKey extends keyof TConfigs ? Extract<Realtime.Message<string, Pick<TConfigs, TKey & keyof TConfigs>>, {
topic: TKey;
}> : Realtime.Message;
type MessagesByTopicMap<TChannel extends Realtime.ChannelInput, TTopics extends readonly string[] | undefined> = TTopics extends readonly (infer K extends string)[] ? { [P in K]?: TopicLatestMessage<TChannel, P> } : Record<string, Realtime.Message | undefined>;
type SubscribedMessage<TChannel extends Realtime.ChannelInput, TTopics extends readonly string[] | undefined> = TTopics extends readonly (infer K extends string)[] ? Realtime.Message<string, Pick<InferTopicConfigs<TChannel>, K & keyof InferTopicConfigs<TChannel>>> : Realtime.Message;
interface UseRealtimeResult<TChannel extends Realtime.ChannelInput = Realtime.ChannelInput, TTopics extends readonly string[] | undefined = readonly string[] | undefined> {
connectionStatus: UseRealtimeConnectionStatus;
runStatus: UseRealtimeRunStatus;
isPaused: boolean;
pauseReason: UseRealtimePauseReason;
messages: {
byTopic: MessagesByTopicMap<TChannel, TTopics>;
all: SubscribedMessage<TChannel, TTopics>[];
last: SubscribedMessage<TChannel, TTopics> | null;
delta: SubscribedMessage<TChannel, TTopics>[];
};
result: unknown;
error: Error | null;
reset: () => void;
}
interface UseRealtimeOptions<TChannel extends Realtime.ChannelInput = Realtime.ChannelInput, TTopics extends readonly string[] | undefined = readonly string[] | undefined> {
channel?: TChannel;
topics?: TTopics;
token?: Realtime.Subscribe.Token | TokenFactory;
key?: string;
enabled?: boolean;
bufferInterval?: number;
validate?: boolean;
historyLimit?: number | null;
apiBaseUrl?: string;
reconnect?: boolean;
reconnectMinMs?: number;
reconnectMaxMs?: number;
pauseOnHidden?: boolean;
autoCloseOnTerminal?: boolean;
}
declare const useRealtime: <TChannel extends Realtime.ChannelInput = Realtime.ChannelInput, TTopics extends readonly string[] | undefined = readonly string[] | undefined>({
channel,
topics,
token: tokenInput,
key,
enabled,
bufferInterval,
validate,
apiBaseUrl,
historyLimit,
reconnect,
reconnectMinMs,
reconnectMaxMs,
pauseOnHidden,
autoCloseOnTerminal
}: UseRealtimeOptions<TChannel, TTopics>) => UseRealtimeResult<TChannel, TTopics>;
//#endregion
export { ClientSubscriptionToken, type Inngest, UseRealtimeConnectionStatus, UseRealtimeOptions, UseRealtimeResult, UseRealtimeRunStatus, getClientSubscriptionToken, useRealtime };
//# sourceMappingURL=react.d.ts.map