import { ConnectionOptions, NatsConnection } from '@nats-io/nats-core'; import { ExternalEvents as KvExternalEvents } from './kv'; import { ExternalEvents as SubjectExternalEvents } from './subject'; import { type AuthConfig } from '../actions/types'; import { InternalStatusEvents as NatsStatusEvents } from '../actions/connection'; import { NatsTrafficResetEvent } from '../traffic'; import { CredentialActor, NatsCredentialConfig } from './credentials'; export interface NatsDiagnosticsConfig { lifecycle?: boolean; } export interface NatsConnectionConfig { opts: ConnectionOptions; auth?: AuthConfig; credentials?: NatsCredentialConfig; maxRetries: number; diagnostics?: NatsDiagnosticsConfig; } export interface Context { connection: NatsConnection | null; error?: Error; natsConfig?: NatsConnectionConfig; retries: number; subjectManagerReady: boolean; kvManagerReady: boolean; configureAfterClose: boolean; connectAfterClose: boolean; credentialActor?: CredentialActor; } export type ExternalEvents = { type: 'CONFIGURE'; config: NatsConnectionConfig; } | { type: 'CONNECT'; } | { type: 'DISCONNECT'; } | { type: 'RESET'; } | { type: 'CREDENTIALS.RELOAD'; } | NatsTrafficResetEvent | SubjectExternalEvents | KvExternalEvents; export declare const natsMachine: import("xstate").StateMachine void; } | { type: 'KV.BUCKET_CREATE'; bucket: string; onResult: (result: { ok: true; } | { ok: false; } | { error: Error; }) => void; } | { type: 'KV.BUCKET_DELETE'; bucket: string; onResult: (result: { ok: true; } | { ok: false; } | { error: Error; }) => void; } | { type: 'KV.GET'; bucket: string; key: string; onResult: (result: import("@nats-io/kv").KvEntry | null | { error: Error; }) => void; } | { type: 'KV.PUT'; bucket: string; key: string; value: any; onResult: (result: { ok: true; } | { error: Error; }) => void; } | { type: 'KV.DELETE'; bucket: string; key: string; onResult: (result: { ok: true; } | { error: Error; }) => void; } | { type: 'KV.SUBSCRIBE'; config: import("..").KvSubscriptionConfig; } | { type: 'KV.UNSUBSCRIBE'; bucket: string; key: string; } | { type: 'KV.UNSUBSCRIBE_ALL'; } | { type: 'NATS_CONNECTION.DISCONNECTED'; status: import("@nats-io/nats-core").Status; } | { type: 'NATS_CONNECTION.RECONNECT'; status: import("@nats-io/nats-core").Status; } | { type: 'NATS_CONNECTION.ERROR'; status: import("@nats-io/nats-core").Status; } | { type: 'NATS_CONNECTION.CLOSE'; status: import("@nats-io/nats-core").Status; } | { type: 'NATS_CONNECTION.RECONNECTING'; status: import("@nats-io/nats-core").Status; } | { type: 'SUBJECT.CONNECT'; connection: NatsConnection; } | { type: 'SUBJECT.CONNECTED'; } | { type: 'SUBJECT.DISCONNECTED'; } | { type: 'SUBJECT.PUBLISH'; subject: string; payload: any; opts?: import("@nats-io/nats-core").PublishOptions; onPublishResult?: (result: { ok: true; } | { ok: false; error: Error; }) => void; } | { type: 'SUBJECT.REQUEST'; subject: string; payload: any; opts?: import("@nats-io/nats-core").RequestOptions; callback: (data: any) => void; onRequestResult?: (result: import("../actions/subject").RequestResult) => void; requestHeaders?: () => Promise; } | { type: 'SUBJECT.SUBSCRIBE'; config: import("../actions/subject").SubjectSubscriptionConfig; } | { type: 'SUBJECT.UNSUBSCRIBE'; subject: string; } | { type: 'SUBJECT.UNSUBSCRIBE_ALL'; } | { type: 'CONNECTED'; connection: NatsConnection; } | { type: 'DISCONNECTED'; } | { type: 'FAIL'; error: Error; } | { type: 'RECONNECT'; } | { type: 'CLOSE'; } | { type: 'CREDENTIALS.UNAVAILABLE'; error: Error; } | { type: 'CONFIGURE'; config: NatsConnectionConfig; } | { type: 'CONNECT'; } | { type: 'DISCONNECT'; } | { type: 'RESET'; } | { type: 'CREDENTIALS.RELOAD'; }, { [x: string]: import("xstate").ActorRefFromLogic | import("xstate").PromiseActorLogic void; }, import("xstate").EventObject> | import("xstate").StateMachine void; } | { type: 'CREDENTIALS.RELOAD'; }, { [x: string]: import("xstate").ActorRefFromLogic | import("xstate").PromiseActorLogic> | undefined; }, { src: "load"; logic: import("xstate").PromiseActorLogic; id: string | undefined; } | { src: "refresh"; logic: import("xstate").PromiseActorLogic; id: string | undefined; }, { type: "acceptCredentials"; params: import("xstate").NonReducibleUnknown; } | { type: "markExpired"; params: import("xstate").NonReducibleUnknown; } | { type: "notifyUnavailable"; params: unknown; } | { type: "queue"; params: import("xstate").NonReducibleUnknown; } | { type: "rejectWaiters"; params: import("xstate").NonReducibleUnknown; } | { type: "replyReady"; params: unknown; } | { type: "storeCredentials"; params: import("xstate").NonReducibleUnknown; }, { type: "canRefresh"; params: unknown; } | { type: "hasExpiry"; params: unknown; } | { type: "isExpired"; params: unknown; } | { type: "outputExpired"; params: unknown; } | { type: "outputShouldRefresh"; params: unknown; } | { type: "shouldRefreshNow"; params: unknown; }, "credentialDeadline", "expired" | "failed" | "loading" | "ready" | "refreshing", string, NatsCredentialConfig, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, { id: "credentials"; states: { readonly loading: {}; readonly ready: {}; readonly refreshing: {}; readonly expired: {}; readonly failed: {}; }; }, import("xstate").MetaObject>> | undefined; kv?: import("xstate").ActorRefFromLogic void; } | { type: 'KV.BUCKET_CREATE'; bucket: string; onResult: (result: { ok: true; } | { ok: false; } | { error: Error; }) => void; } | { type: 'KV.BUCKET_DELETE'; bucket: string; onResult: (result: { ok: true; } | { ok: false; } | { error: Error; }) => void; } | { type: 'KV.GET'; bucket: string; key: string; onResult: (result: import("@nats-io/kv").KvEntry | null | { error: Error; }) => void; } | { type: 'KV.PUT'; bucket: string; key: string; value: any; onResult: (result: { ok: true; } | { error: Error; }) => void; } | { type: 'KV.DELETE'; bucket: string; key: string; onResult: (result: { ok: true; } | { error: Error; }) => void; } | { type: 'KV.SUBSCRIBE'; config: import("..").KvSubscriptionConfig; } | { type: 'KV.UNSUBSCRIBE'; bucket: string; key: string; } | { type: 'KV.UNSUBSCRIBE_ALL'; }, { [x: string]: import("xstate").ActorRefFromLogic>, { kvm: import("@nats-io/kv").Kvm | null; connection: NatsConnection | null; currentState: Map>; targetState: Map; }, import("xstate").EventObject>> | undefined; }, { src: "kvConsolidateState"; logic: import("xstate").PromiseActorLogic>, { kvm: import("@nats-io/kv").Kvm | null; connection: NatsConnection | null; currentState: Map>; targetState: Map; }, import("xstate").EventObject>; id: string | undefined; }, never, { type: "hasPendingSync"; params: unknown; }, never, "kv_check_sync" | "kv_connected" | "kv_disconnecting" | "kv_error" | "kv_idle" | "kv_syncing", string, import("xstate").NonReducibleUnknown, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, { states: { readonly kv_idle: {}; readonly kv_disconnecting: {}; readonly kv_connected: {}; readonly kv_check_sync: {}; readonly kv_syncing: {}; readonly kv_error: {}; }; }, import("xstate").MetaObject>> | undefined; subject?: import("xstate").ActorRefFromLogic void; } | { type: 'SUBJECT.REQUEST'; subject: string; payload: any; opts?: import("@nats-io/nats-core").RequestOptions; callback: (data: any) => void; onRequestResult?: (result: import("../actions/subject").RequestResult) => void; requestHeaders?: () => Promise; } | { type: 'SUBJECT.SUBSCRIBE'; config: import("../actions/subject").SubjectSubscriptionConfig; } | { type: 'SUBJECT.UNSUBSCRIBE'; subject: string; } | { type: 'SUBJECT.UNSUBSCRIBE_ALL'; }, {}, never, { type: "rejectUnavailableRequest"; params: unknown; }, { type: "hasPendingSync"; params: unknown; }, never, "subject_check_sync" | "subject_connected" | "subject_disconnecting" | "subject_error" | "subject_idle" | "subject_syncing", string, import("xstate").NonReducibleUnknown, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, { states: { readonly subject_idle: {}; readonly subject_disconnecting: {}; readonly subject_connected: {}; readonly subject_check_sync: {}; readonly subject_syncing: {}; readonly subject_error: {}; }; }, import("xstate").MetaObject>> | undefined; }, { src: "connectToNats"; logic: import("xstate").PromiseActorLogic void; }, import("xstate").EventObject>; id: string | undefined; } | { src: "credentials"; logic: import("xstate").StateMachine void; } | { type: 'CREDENTIALS.RELOAD'; }, { [x: string]: import("xstate").ActorRefFromLogic | import("xstate").PromiseActorLogic> | undefined; }, { src: "load"; logic: import("xstate").PromiseActorLogic; id: string | undefined; } | { src: "refresh"; logic: import("xstate").PromiseActorLogic; id: string | undefined; }, { type: "acceptCredentials"; params: import("xstate").NonReducibleUnknown; } | { type: "markExpired"; params: import("xstate").NonReducibleUnknown; } | { type: "notifyUnavailable"; params: unknown; } | { type: "queue"; params: import("xstate").NonReducibleUnknown; } | { type: "rejectWaiters"; params: import("xstate").NonReducibleUnknown; } | { type: "replyReady"; params: unknown; } | { type: "storeCredentials"; params: import("xstate").NonReducibleUnknown; }, { type: "canRefresh"; params: unknown; } | { type: "hasExpiry"; params: unknown; } | { type: "isExpired"; params: unknown; } | { type: "outputExpired"; params: unknown; } | { type: "outputShouldRefresh"; params: unknown; } | { type: "shouldRefreshNow"; params: unknown; }, "credentialDeadline", "expired" | "failed" | "loading" | "ready" | "refreshing", string, NatsCredentialConfig, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, { id: "credentials"; states: { readonly loading: {}; readonly ready: {}; readonly refreshing: {}; readonly expired: {}; readonly failed: {}; }; }, import("xstate").MetaObject>; id: string | undefined; } | { src: "disconnectNats"; logic: import("xstate").PromiseActorLogic; id: string | undefined; } | { src: "kv"; logic: import("xstate").StateMachine void; } | { type: 'KV.BUCKET_CREATE'; bucket: string; onResult: (result: { ok: true; } | { ok: false; } | { error: Error; }) => void; } | { type: 'KV.BUCKET_DELETE'; bucket: string; onResult: (result: { ok: true; } | { ok: false; } | { error: Error; }) => void; } | { type: 'KV.GET'; bucket: string; key: string; onResult: (result: import("@nats-io/kv").KvEntry | null | { error: Error; }) => void; } | { type: 'KV.PUT'; bucket: string; key: string; value: any; onResult: (result: { ok: true; } | { error: Error; }) => void; } | { type: 'KV.DELETE'; bucket: string; key: string; onResult: (result: { ok: true; } | { error: Error; }) => void; } | { type: 'KV.SUBSCRIBE'; config: import("..").KvSubscriptionConfig; } | { type: 'KV.UNSUBSCRIBE'; bucket: string; key: string; } | { type: 'KV.UNSUBSCRIBE_ALL'; }, { [x: string]: import("xstate").ActorRefFromLogic>, { kvm: import("@nats-io/kv").Kvm | null; connection: NatsConnection | null; currentState: Map>; targetState: Map; }, import("xstate").EventObject>> | undefined; }, { src: "kvConsolidateState"; logic: import("xstate").PromiseActorLogic>, { kvm: import("@nats-io/kv").Kvm | null; connection: NatsConnection | null; currentState: Map>; targetState: Map; }, import("xstate").EventObject>; id: string | undefined; }, never, { type: "hasPendingSync"; params: unknown; }, never, "kv_check_sync" | "kv_connected" | "kv_disconnecting" | "kv_error" | "kv_idle" | "kv_syncing", string, import("xstate").NonReducibleUnknown, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, { states: { readonly kv_idle: {}; readonly kv_disconnecting: {}; readonly kv_connected: {}; readonly kv_check_sync: {}; readonly kv_syncing: {}; readonly kv_error: {}; }; }, import("xstate").MetaObject>; id: "kv"; } | { src: "subject"; logic: import("xstate").StateMachine void; } | { type: 'SUBJECT.REQUEST'; subject: string; payload: any; opts?: import("@nats-io/nats-core").RequestOptions; callback: (data: any) => void; onRequestResult?: (result: import("../actions/subject").RequestResult) => void; requestHeaders?: () => Promise; } | { type: 'SUBJECT.SUBSCRIBE'; config: import("../actions/subject").SubjectSubscriptionConfig; } | { type: 'SUBJECT.UNSUBSCRIBE'; subject: string; } | { type: 'SUBJECT.UNSUBSCRIBE_ALL'; }, {}, never, { type: "rejectUnavailableRequest"; params: unknown; }, { type: "hasPendingSync"; params: unknown; }, never, "subject_check_sync" | "subject_connected" | "subject_disconnecting" | "subject_error" | "subject_idle" | "subject_syncing", string, import("xstate").NonReducibleUnknown, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, { states: { readonly subject_idle: {}; readonly subject_disconnecting: {}; readonly subject_connected: {}; readonly subject_check_sync: {}; readonly subject_syncing: {}; readonly subject_error: {}; }; }, import("xstate").MetaObject>; id: "subject"; }, { type: "clearDeferredCloseActions"; params: import("xstate").NonReducibleUnknown; } | { type: "configureNats"; params: import("xstate").NonReducibleUnknown; } | { type: "configureNatsAfterClose"; params: import("xstate").NonReducibleUnknown; } | { type: "doReset"; params: import("xstate").NonReducibleUnknown; } | { type: "reconnectAfterClose"; params: import("xstate").NonReducibleUnknown; } | { type: "recordCredentialError"; params: import("xstate").NonReducibleUnknown; } | { type: "rejectUnavailableRequest"; params: unknown; } | { type: "reloadCredentials"; params: unknown; } | { type: "stopCredentialActor"; params: import("xstate").NonReducibleUnknown; }, { type: "allManagersReady"; params: unknown; } | { type: "shouldConfigureAfterClose"; params: unknown; } | { type: "shouldConnectAfterClose"; params: unknown; }, never, "closed" | "closing" | "configured" | "connected" | "connecting" | "error" | "initialise_managers" | "not_configured", string, import("xstate").NonReducibleUnknown, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, { states: { readonly not_configured: {}; readonly configured: {}; readonly connecting: {}; readonly initialise_managers: {}; readonly connected: {}; readonly closing: {}; readonly closed: {}; readonly error: {}; }; }, import("xstate").MetaObject>; //# sourceMappingURL=root.d.ts.map