onecore 0.0.30 → 0.0.31
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
CHANGED
package/src/index.ts
CHANGED
|
@@ -40,6 +40,10 @@ export * from './video';
|
|
|
40
40
|
export * from './health';
|
|
41
41
|
export * from './logger';
|
|
42
42
|
|
|
43
|
+
export type DeleteFile = (name: string, directory?: string) => Promise<boolean>;
|
|
44
|
+
export type Delete = (delFile: DeleteFile, url: string) => Promise<boolean>;
|
|
45
|
+
export type UrlBuild = (name: string, directory?: string) => string;
|
|
46
|
+
|
|
43
47
|
export type Log = (msg: string) => void;
|
|
44
48
|
export type LogFunc = Log;
|
|
45
49
|
|
|
@@ -59,9 +63,7 @@ export class ViewManager<T, ID> implements ViewService<T, ID> {
|
|
|
59
63
|
constructor(private r: ViewRepository<T, ID>) {
|
|
60
64
|
this.metadata = this.metadata.bind(this);
|
|
61
65
|
this.keys = this.keys.bind(this);
|
|
62
|
-
this.all = this.all.bind(this);
|
|
63
66
|
this.load = this.load.bind(this);
|
|
64
|
-
this.exist = this.exist.bind(this);
|
|
65
67
|
}
|
|
66
68
|
metadata(): Attributes|undefined {
|
|
67
69
|
return (this.r.metadata ? this.r.metadata() : undefined);
|
|
@@ -69,15 +71,9 @@ export class ViewManager<T, ID> implements ViewService<T, ID> {
|
|
|
69
71
|
keys(): string[] {
|
|
70
72
|
return (this.r.keys ? this.r.keys() : []);
|
|
71
73
|
}
|
|
72
|
-
all(ctx?: any): Promise<T[]> {
|
|
73
|
-
return (this.r.all ? this.r.all() : Promise.resolve([]));
|
|
74
|
-
}
|
|
75
74
|
load(id: ID, ctx?: any): Promise<T | null> {
|
|
76
75
|
return this.r.load(id, ctx);
|
|
77
76
|
}
|
|
78
|
-
exist(id: ID, ctx?: any): Promise<boolean> {
|
|
79
|
-
return (this.r.exist ? this.r.exist(id, ctx) : Promise.resolve(false));
|
|
80
|
-
}
|
|
81
77
|
}
|
|
82
78
|
// tslint:disable-next-line:max-classes-per-file
|
|
83
79
|
export class GenericManager<T, ID> extends ViewManager<T, ID> implements GenericService<T, ID, number> {
|
|
@@ -86,7 +82,6 @@ export class GenericManager<T, ID> extends ViewManager<T, ID> implements Generic
|
|
|
86
82
|
this.insert = this.insert.bind(this);
|
|
87
83
|
this.update = this.update.bind(this);
|
|
88
84
|
this.patch = this.patch.bind(this);
|
|
89
|
-
this.save = this.save.bind(this);
|
|
90
85
|
this.delete = this.delete.bind(this);
|
|
91
86
|
}
|
|
92
87
|
insert(obj: T, ctx?: any): Promise<number> {
|
|
@@ -95,12 +90,9 @@ export class GenericManager<T, ID> extends ViewManager<T, ID> implements Generic
|
|
|
95
90
|
update(obj: T, ctx?: any): Promise<number> {
|
|
96
91
|
return this.repository.update(obj, ctx);
|
|
97
92
|
}
|
|
98
|
-
patch(obj: T
|
|
93
|
+
patch(obj: Partial<T>, ctx?: any): Promise<number> {
|
|
99
94
|
return (this.repository.patch ? this.repository.patch(obj, ctx) : Promise.resolve(-1));
|
|
100
95
|
}
|
|
101
|
-
save(obj: T, ctx?: any): Promise<number> {
|
|
102
|
-
return (this.repository.save ? this.repository.save(obj, ctx) : Promise.resolve(-1));
|
|
103
|
-
}
|
|
104
96
|
delete(id: ID, ctx?: any): Promise<number> {
|
|
105
97
|
return (this.repository.delete ? this.repository.delete(id, ctx) : Promise.resolve(-1));
|
|
106
98
|
}
|
|
@@ -3,12 +3,12 @@ import {ViewRepository} from './ViewRepository';
|
|
|
3
3
|
export interface GenericRepository<T, ID> extends ViewRepository<T, ID> {
|
|
4
4
|
insert(obj: T, ctx?: any): Promise<number>;
|
|
5
5
|
update(obj: T, ctx?: any): Promise<number>;
|
|
6
|
-
patch(obj: T
|
|
6
|
+
patch(obj: Partial<T>, ctx?: any): Promise<number>;
|
|
7
7
|
delete(id: ID, ctx?: any): Promise<number>;
|
|
8
8
|
}
|
|
9
9
|
export interface Repository<T, ID> extends ViewRepository<T, ID> {
|
|
10
10
|
insert(obj: T, ctx?: any): Promise<number>;
|
|
11
11
|
update(obj: T, ctx?: any): Promise<number>;
|
|
12
|
-
patch(obj: T
|
|
12
|
+
patch(obj: Partial<T>, ctx?: any): Promise<number>;
|
|
13
13
|
delete(id: ID, ctx?: any): Promise<number>;
|
|
14
14
|
}
|
|
@@ -3,6 +3,6 @@ import {ViewService} from './ViewService';
|
|
|
3
3
|
export interface GenericService<T, ID, R> extends ViewService<T, ID> {
|
|
4
4
|
insert(obj: T, ctx?: any): Promise<R>;
|
|
5
5
|
update(obj: T, ctx?: any): Promise<R>;
|
|
6
|
-
patch(obj: T
|
|
6
|
+
patch(obj: Partial<T>, ctx?: any): Promise<R>;
|
|
7
7
|
delete(id: ID, ctx?: any): Promise<number>;
|
|
8
8
|
}
|