import { InstanceLifetimes, GuidValue, StoreDefintion as OmniaStoreDefinition, StateMutation, MutatableState, IMessageBusSubscriptionHandler } from "../models"; export declare enum StoreLogTypes { mutation = "Mutation", action = "Action" } export interface StoreLog { id: GuidValue; name: string; type: StoreLogTypes; storeId: GuidValue; storeName: string; createdAt: Date; object: StateMutation; } export interface StateMutationLog { oldState: string; newState: string; } export interface StateActionLog { func: any; } export type MapOnCommitToCommit = T extends (...args: infer U) => void ? (...args: U) => IMessageBusSubscriptionHandler : T; export type MapActionOnDispatching = T extends (...args: infer U) => Promise ? (...args: U) => void : never; export type MapActionOnDispatched = T extends (...args: infer U) => Promise ? (result: Y, ...args: U) => void : never; export type MapActionOnFailure = T extends (...args: infer U) => Promise ? (failureReason: any, ...args: U) => void : never; export declare class StoreLogger { private _logState; enabled: boolean; constructor(logState: Array); add(id: GuidValue, name: string, type: StoreLogTypes, storeId: GuidValue, storeName: string, object: StateMutationLog): void; enable(): void; disable(): void; get log(): Array; } export declare abstract class Store { private static _vm; private static _state; private static _log; private static _logger; static get logging(): StoreLogger; private _storeDefinition; private _disposed; constructor(storeDefinition?: Omit); protected get id(): GuidValue; /** * Triggers when the store is ready to be used * */ protected abstract onActivated(): any; /** * Triggers when the store is being disposed * */ protected onDisposing(): void; get isDisposed(): boolean; /** * Creates a new state * */ protected state(initialValue?: T): StoreState; /** * Creates a new action * */ protected action Promise, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10>(action: Dispatcher): StoreAction, MapActionOnDispatched, MapActionOnFailure, Dispatcher>; protected action Promise, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>(action: Dispatcher): StoreAction, MapActionOnDispatched, MapActionOnFailure, Dispatcher>; protected action Promise, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>(action: Dispatcher): StoreAction, MapActionOnDispatched, MapActionOnFailure, Dispatcher>; protected action Promise, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(action: Dispatcher): StoreAction, MapActionOnDispatched, MapActionOnFailure, Dispatcher>; protected action Promise, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(action: Dispatcher): StoreAction, MapActionOnDispatched, MapActionOnFailure, Dispatcher>; protected action Promise, Arg1, Arg2, Arg3, Arg4, Arg5>(action: Dispatcher): StoreAction, MapActionOnDispatched, MapActionOnFailure, Dispatcher>; protected action Promise, Arg1, Arg2, Arg3, Arg4>(action: Dispatcher): StoreAction, MapActionOnDispatched, MapActionOnFailure, Dispatcher>; protected action Promise, Arg1, Arg2, Arg3>(action: Dispatcher): StoreAction, MapActionOnDispatched, MapActionOnFailure, Dispatcher>; protected action Promise, Arg1, Arg2>(action: Dispatcher): StoreAction, MapActionOnDispatched, MapActionOnFailure, Dispatcher>; protected action Promise, Arg1>(action: Dispatcher): StoreAction, MapActionOnDispatched, MapActionOnFailure, Dispatcher>; /** * Creates a new mutation * */ protected mutation void, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10>(mutation: Mutation): StoreMutation>; protected mutation void, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>(mutation: Mutation): StoreMutation>; protected mutation void, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>(mutation: Mutation): StoreMutation>; protected mutation void, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(mutation: Mutation): StoreMutation>; protected mutation void, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(mutation: Mutation): StoreMutation>; protected mutation void, Arg1, Arg2, Arg3, Arg4, Arg5>(mutation: Mutation): StoreMutation>; protected mutation void, Arg1, Arg2, Arg3, Arg4>(mutation: Mutation): StoreMutation>; protected mutation void, Arg1, Arg2, Arg3>(mutation: Mutation): StoreMutation>; protected mutation void, Arg1, Arg2>(mutation: Mutation): StoreMutation>; protected mutation void, Arg1>(mutation: Mutation): StoreMutation>; /** * Registers a store with a lifetime option * */ static register(type: T, lifetime: InstanceLifetimes): void; /** * Registers a store as transient * */ static registerAsTransient(type: T): void; /** * Gets an instance of a registered store * */ static get(type: T): T; private static registerInternal; private static initNewStore; private static ensure; } export declare class StoreState { private _val; private _propName; private _afterMutateSubscription; private _beforeMutateSubscription; private _globalState; private _storeDefinition; constructor(initialState: T, globalState: any); private init; get name(): string; get state(): T; mutate(state: T | ((mutatableValue: MutatableState) => void)): void; get onMutating(): (fn: (obj: StateMutation) => void) => IMessageBusSubscriptionHandler; get onMutated(): (fn: (obj: StateMutation) => void) => IMessageBusSubscriptionHandler; private ensureInitialized; } export declare class StoreAction, OnDispatched extends MapActionOnDispatched, OnFailure extends MapActionOnFailure, D extends (...args: any[]) => Promise> { dispatch: D; private _onDisplatchingSubscription; private _onCompletedSubscription; private _onFailureSubscription; private _storeDefinition; constructor(dispatcher: D, storeDefinition: OmniaStoreDefinition); /** * Invoked directly when calling action dispath * @param fn - handler function on the format (args...- any number of arguments passed to the dispatcher) */ onDispatching(fn: OnDispatching): IMessageBusSubscriptionHandler; /** * Invoked when the action completes, i.e. the promise is resolved * @param fn - handler function on the format (result- the data passed to promise resolver (or null), args...- any number of arguments passed to the dispatcher) * result - the return type of the action Promise */ onDispatched(fn: OnDispatched): IMessageBusSubscriptionHandler; /** * Invoked on any failure for this action * @param fn - handler function on the format (reason- the reject reason, args...- any number of arguments passed to the dispatcher) * reason - the reason passed to reject of action promise * */ onFailure(fn: OnFailure): IMessageBusSubscriptionHandler; } export declare class StoreMutation { commit: CommitFunc; private _afterMutateSubscription; private _beforeMutateSubscription; private _storeDefinition; constructor(mutation: T, storeDefinition: OmniaStoreDefinition); onCommiting(fn: T): IMessageBusSubscriptionHandler; onCommited(fn: T): IMessageBusSubscriptionHandler; }