onecore 0.5.4 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/db.ts +56 -13
- package/src/index.ts +17 -1
- package/src/model.ts +11 -4
package/package.json
CHANGED
package/src/db.ts
CHANGED
|
@@ -17,9 +17,9 @@ interface StringMap {
|
|
|
17
17
|
export interface Executor {
|
|
18
18
|
driver: string;
|
|
19
19
|
param(i: number): string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
query<T>(sql: string, args?: any[], m?: StringMap, bools?: Attribute[], ctx?:
|
|
20
|
+
execute(sql: string, args?: any[], ctx?: any): Promise<number>
|
|
21
|
+
executeBatch(statements: Statement[], firstSuccess?: boolean, ctx?: any): Promise<number>
|
|
22
|
+
query<T>(sql: string, args?: any[], m?: StringMap, bools?: Attribute[], ctx?: any): Promise<T[]>
|
|
23
23
|
}
|
|
24
24
|
export interface Transaction extends Executor {
|
|
25
25
|
commit(): Promise<void>
|
|
@@ -33,25 +33,25 @@ export interface DB extends Executor {
|
|
|
33
33
|
export interface ViewRepository<T, ID> {
|
|
34
34
|
metadata?(): Attributes|undefined;
|
|
35
35
|
keys?(): string[];
|
|
36
|
-
load(id: ID,
|
|
36
|
+
load(id: ID, tx?: Transaction): Promise<T | null>;
|
|
37
37
|
}
|
|
38
38
|
export interface SearchRepository<T, F extends Filter> {
|
|
39
|
-
search(s: F, limit: number, offset?: number|string, fields?: string[],
|
|
39
|
+
search(s: F, limit: number, offset?: number|string, fields?: string[], tx?: Transaction): Promise<SearchResult<T>>;
|
|
40
40
|
}
|
|
41
41
|
export interface ViewSearchRepository<T, ID, F extends Filter>
|
|
42
42
|
extends ViewRepository<T, ID>, SearchRepository<T, F> {
|
|
43
43
|
}
|
|
44
44
|
export interface GenericRepository<T, ID> extends ViewRepository<T, ID> {
|
|
45
|
-
create(obj: T,
|
|
46
|
-
update(obj: T,
|
|
47
|
-
patch(obj: Partial<T>,
|
|
48
|
-
delete(id: ID,
|
|
45
|
+
create(obj: T, tx?: Transaction): Promise<number>;
|
|
46
|
+
update(obj: T, tx?: Transaction): Promise<number>;
|
|
47
|
+
patch(obj: Partial<T>, tx?: Transaction): Promise<number>;
|
|
48
|
+
delete(id: ID, tx?: Transaction): Promise<number>;
|
|
49
49
|
}
|
|
50
50
|
export interface CRUDRepository<T, ID> extends ViewRepository<T, ID> {
|
|
51
|
-
create(obj: T,
|
|
52
|
-
update(obj: T,
|
|
53
|
-
patch(obj: Partial<T>,
|
|
54
|
-
delete(id: ID,
|
|
51
|
+
create(obj: T, tx?: Transaction): Promise<number>;
|
|
52
|
+
update(obj: T, tx?: Transaction): Promise<number>;
|
|
53
|
+
patch(obj: Partial<T>, tx?: Transaction): Promise<number>;
|
|
54
|
+
delete(id: ID, tx?: Transaction): Promise<number>;
|
|
55
55
|
}
|
|
56
56
|
export interface Repository<T, ID, F extends Filter>
|
|
57
57
|
extends GenericRepository<T, ID>, SearchRepository<T, F> {
|
|
@@ -59,3 +59,46 @@ export interface Repository<T, ID, F extends Filter>
|
|
|
59
59
|
export interface GenericSearchRepository<T, ID, F extends Filter>
|
|
60
60
|
extends GenericRepository<T, ID>, SearchRepository<T, F> {
|
|
61
61
|
}
|
|
62
|
+
export interface ApproversRepository {
|
|
63
|
+
getApprovers(tx?: Transaction): Promise<string[]>
|
|
64
|
+
}
|
|
65
|
+
export interface HistoryRepository<T> {
|
|
66
|
+
create(id: string, author: string, action: string, data: T, tx?: Transaction): Promise<number>
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
export interface ViewPort<T, ID> {
|
|
71
|
+
metadata?(): Attributes | undefined;
|
|
72
|
+
keys?(): string[];
|
|
73
|
+
load(id: ID, tx?: Transaction): Promise<T | null>;
|
|
74
|
+
}
|
|
75
|
+
export interface SearchPort<T, F extends Filter> {
|
|
76
|
+
search(s: F, limit: number, offset?: number|string, fields?: string[], tx?: Transaction): Promise<SearchResult<T>>;
|
|
77
|
+
}
|
|
78
|
+
export interface ViewSearchPort<T, ID, F extends Filter>
|
|
79
|
+
extends ViewPort<T, ID>, SearchPort<T, F> {
|
|
80
|
+
}
|
|
81
|
+
export interface GenericPort<T, ID> extends ViewPort<T, ID> {
|
|
82
|
+
create(obj: T, tx?: Transaction): Promise<number>;
|
|
83
|
+
update(obj: T, tx?: Transaction): Promise<number>;
|
|
84
|
+
patch(obj: Partial<T>, tx?: Transaction): Promise<number>;
|
|
85
|
+
delete(id: ID, tx?: Transaction): Promise<number>;
|
|
86
|
+
}
|
|
87
|
+
export interface CRUDPort<T, ID> extends ViewPort<T, ID> {
|
|
88
|
+
create(obj: T, tx?: Transaction): Promise<number>;
|
|
89
|
+
update(obj: T, tx?: Transaction): Promise<number>;
|
|
90
|
+
patch(obj: Partial<T>, tx?: Transaction): Promise<number>;
|
|
91
|
+
delete(id: ID, tx?: Transaction): Promise<number>;
|
|
92
|
+
}
|
|
93
|
+
export interface Port<T, ID, F extends Filter>
|
|
94
|
+
extends GenericPort<T, ID>, SearchPort<T, F> {
|
|
95
|
+
}
|
|
96
|
+
export interface GenericSearchPort<T, ID, F extends Filter>
|
|
97
|
+
extends GenericPort<T, ID>, SearchPort<T, F> {
|
|
98
|
+
}
|
|
99
|
+
export interface ApproversPort {
|
|
100
|
+
getApprovers(tx?: Transaction): Promise<string[]>
|
|
101
|
+
}
|
|
102
|
+
export interface HistoryPort<T> {
|
|
103
|
+
create(id: string, author: string, action: string, data: T, tx?: Transaction): Promise<number>
|
|
104
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -41,11 +41,27 @@ export type Log = (msg: string) => void;
|
|
|
41
41
|
export type LogFunc = Log;
|
|
42
42
|
|
|
43
43
|
import { Attributes } from './metadata';
|
|
44
|
-
import {
|
|
44
|
+
import { Filter, SearchResult } from './model';
|
|
45
45
|
|
|
46
46
|
export type Search<T, F> = (s: F, limit: number, page?: number | string, fields?: string[]) => Promise<SearchResult<T>>;
|
|
47
47
|
export type SearchFunc<T, F> = Search<T, F>;
|
|
48
48
|
|
|
49
|
+
export interface Notification {
|
|
50
|
+
id?: string
|
|
51
|
+
sender: string
|
|
52
|
+
receiver: string
|
|
53
|
+
url?: string
|
|
54
|
+
message: string
|
|
55
|
+
}
|
|
56
|
+
export interface NotificationPort {
|
|
57
|
+
push(notification: Notification): Promise<number>
|
|
58
|
+
pushNotifications(notifications: Notification[]): Promise<number>
|
|
59
|
+
}
|
|
60
|
+
export interface NotificationRepository {
|
|
61
|
+
push(notification: Notification): Promise<number>
|
|
62
|
+
pushNotifications(notifications: Notification[]): Promise<number>
|
|
63
|
+
}
|
|
64
|
+
|
|
49
65
|
export interface KeypairResult {
|
|
50
66
|
rsaEncrypted: string;
|
|
51
67
|
data: {
|
package/src/model.ts
CHANGED
|
@@ -20,10 +20,17 @@ export interface ModuleLoader {
|
|
|
20
20
|
load(): Promise<Module[]>;
|
|
21
21
|
}
|
|
22
22
|
export interface Tracking {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
createdBy: string
|
|
24
|
+
createdAt?: Date
|
|
25
|
+
updatedBy: string
|
|
26
|
+
updatedAt?: Date
|
|
27
|
+
}
|
|
28
|
+
export interface Approving {
|
|
29
|
+
submittedBy: string
|
|
30
|
+
submittedAt?: Date
|
|
31
|
+
approvedBy?: string
|
|
32
|
+
approvedAt?: Date
|
|
33
|
+
|
|
27
34
|
}
|
|
28
35
|
export interface Version {
|
|
29
36
|
version?: number;
|