-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
51 lines (42 loc) · 1.44 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/// <reference types="@types/node" />
/// <reference types="sqlite" />
import * as events from "events";
import * as sqlite from "sqlite";
declare class TransactionManager<S> extends events {
constructor(db: sqlite.Database, options?: TransactionManager.ConstructorOptions)
public verbose: boolean;
public subjects: Map<string, TransactionManager.Actions>;
public transactions: Map<string, TransactionManager.Transaction>;
public timer: number;
public readonly size: number;
loadSubjectsFromFile(fileLocation: string): Promise<void>;
registerSubject(name: TransactionManager.Subject, actions: TransactionManager.Actions): this;
open<T extends keyof S>(action: TransactionManager.Action, subject: T, data: S[T]): string;
attachData(transactId: string, data: any): boolean;
close(transactId: string): boolean;
exit(): void;
}
declare namespace TransactionManager {
interface ConstructorOptions {
interval?: number;
verbose?: boolean;
}
interface Actions {
insert?: string;
delete?: string;
update?: string;
}
interface Transaction {
index: number;
action: Actions;
subject: Subject;
openAt: number;
attachData?: any;
data: any[];
}
type Database = sqlite.Database;
type Subject = string | symbol;
type Action = keyof Actions;
}
export as namespace TransactionManager;
export = TransactionManager;