UNPKG

2.4 kBTypeScriptView Raw
1import './Globals';
2import { IStorePlugin, ICoordinatorOptions, IModel, IModelType, ICoordinator, IPlugin } from './Types';
3import { Repo } from "./Repo";
4import { PluginEventType } from "./PluginTypes";
5/**
6 * ClassName -> ModelClass Mapping table
7 */
8export declare type TModelTypeMap = {
9 [clazzName: string]: IModelType;
10};
11/**
12 * The overall coordinator
13 */
14export declare class Coordinator implements ICoordinator {
15 private plugins;
16 notify(eventType: PluginEventType, ...args: any[]): void;
17 /**
18 * Model registration map type
19 */
20 /**
21 * Stores all registrations, enabling
22 * them to be configured against a
23 * changed client, multiple datasources,
24 * utility scripts, etc
25 *
26 * @type {{}}
27 */
28 private modelMap;
29 private models;
30 /**
31 * Retrieve model registrations
32 *
33 * @returns {TModelTypeMap}
34 */
35 getModels(): IModelType[];
36 private findModel(predicate);
37 getModel(clazz: any): IModelType;
38 getModelByName(name: string): IModelType;
39 /**
40 * Default options
41 */
42 private options;
43 getOptions(): ICoordinatorOptions;
44 private initialized;
45 private startPromise;
46 private internal;
47 started: boolean;
48 private checkInitialized(not?);
49 private checkStarted(not?);
50 stores(): IStorePlugin[];
51 /**
52 * Set the coordinator options
53 */
54 init(newOptions: ICoordinatorOptions, ...newPlugins: IPlugin[]): Promise<ICoordinator>;
55 /**
56 * Start the coordinator and embedded store from options
57 *
58 * @returns {Bluebird<boolean>}
59 */
60 start(...models: any[]): Promise<ICoordinator>;
61 stop(): Promise<ICoordinator>;
62 /**
63 * Execute function either immediately if
64 * ready or when the starting Promise
65 * completes
66 *
67 * @param fn
68 */
69 execute<T>(fn: Function): Promise<T>;
70 stopPlugins(): Promise<void>;
71 /**
72 * Reset the coordinator status
73 *
74 * @returns {Coordinator.reset}
75 */
76 reset(): Promise<ICoordinator>;
77 /**
78 * Register a model with the system
79 *
80 * @param constructor
81 */
82 registerModel(constructor: Function): this;
83 private repoMap;
84 /**
85 * Get a repository for the specified model/class
86 *
87 * @param clazz
88 * @returns {T}
89 */
90 getRepo<T extends Repo<M>, M extends IModel>(clazz: {
91 new (): T;
92 }): T;
93}