-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
71 lines (61 loc) · 1.64 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { PoolClient, PoolConfig } from 'pg';
export { PoolConfig };
export class Filby {
static HOOK_MAX_ATTEMPTS_EXHAUSTED: string;
constructor(config: Config);
init(): Promise<void>;
startNotifications(): Promise<void>;
stopNotifications(): Promise<void>;
subscribe<T>(event: string, handler: (notification: T) => Promise<void>);
unsubscribe<T>(event: string, handler?: (notification: T) => Promise<void>);
unsubscribeAll();
stop(): Promise<void>;
withTransaction<T>(callback: (client: PoolClient) => Promise<T>): Promise<T>;
getProjections(): Promise<Projection[]>;
getProjection(name: string, version: number): Promise<Projection>;
getChangeLog(projection: Projection): Promise<ChangeSet[]>;
getCurrentChangeSet(projection: Projection): Promise<ChangeSet>;
getChangeSet(id: number): Promise<ChangeSet>;
getAggregates<T>(changeSetId: number, name: string, version: number): Promise<T[]>;
}
export type Migration = {
path: string;
permissions: string[];
};
export type Config = {
database?: PoolConfig;
migrations?: Migration[];
notification?: {
interval?: string;
delay?: string;
maxAttempts?: number;
}
};
export type Projection = {
name: string;
version: number;
key: string;
};
export type ChangeSet = {
id: number;
effective: Date;
description: string;
lastModified: Date;
entityTag: string;
};
export type Hook = {
name: string;
event: string;
}
export type Notification = {
hook: Hook;
projection: Projection;
attempts: number;
};
export type ErrorNotification<T> = {
err: T extends Error ? T : never;
} & Notification;
export type Entity = {
name: string;
version: number;
};