@actyx/sdk
Version:
Actyx SDK
65 lines (64 loc) • 2.85 kB
TypeScript
import { EventFns, TestEventFns } from './event-fns';
import { NodeInfo } from './node-info';
import { SnapshotStore } from './snapshotStore';
import { ActyxOpts, ActyxTestOpts, AppManifest, NodeId } from './types';
/** Access all sorts of functionality related to the Actyx system!
* @public */
export declare type Actyx = EventFns & {
/** Id of the Actyx node this interface is connected to. */
readonly nodeId: NodeId;
/** Fish snapshot store for the Pond
* @beta */
readonly snapshotStore: SnapshotStore;
/** Dispose of this Actyx connector, cancelling all ongoing subscriptions and freeing all underlying ressources.
* @public */
dispose: () => void;
/** Wait for the connected node to be in sync with the swarm. This is on a
* best-effort basis and waits at most 30 seconds after the point in time the
* node has been started. This can be used in order to reduce stale state
* inside the application when started together with an Actyx node.
* @public */
waitForSync: () => Promise<void>;
/**
* Obtain information on the Actyx node. In order to save some cycles, and because the information
* doesn’t change all that quickly, please provide a time parameter that matches your app’s
* freshness requirements — for human consumption a couple hundred milliseconds is good enough.
*
* The underlying API endpoint has been added in Actyx 2.5.0, earlier versions report dummy data.
*
* Starting with Actyx 2.15.0 the returned data also contains the swarm status as seen by this node.
*
* @public
*/
nodeInfo: (maxAgeMillis: number) => Promise<NodeInfo>;
};
/**
* An instance of `Actyx` that is not talking to any Actyx instance, but mocks all functionality within TypeScript.
* Very useful for unit-testing.
*
* @public
*/
export declare type TestActyx = TestEventFns & {
/** Prented id of the underlying Actyx instance that actually is just simulated. */
readonly nodeId: NodeId;
/** Fish snapshot store for the Pond
* @beta */
readonly snapshotStore: SnapshotStore;
/** For `TestActyx` instances, this method does nothing; it’s just there so all normal `Actyx` functions are provided.
* @public */
dispose: () => void;
waitForSync: () => Promise<void>;
};
/** Function for creating `Actyx` instances.
* @public */
export declare const Actyx: {
/** Create an `Actyx` instance that talks to a running `Actyx` system.
* @public */
of: (manifest: AppManifest, opts?: ActyxOpts) => Promise<Actyx>;
/**
* Create an `Actyx` instance that mocks all APIs within TypeScript. Useful for unit-tests.
* Will not talk to other nodes, but rather that can be simulated via `directlyPushEvents`.
* @public
*/
test: (opts?: ActyxTestOpts) => TestActyx;
};