onecore 0.5.3 → 0.5.5

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/lib/index.js CHANGED
@@ -32,14 +32,14 @@ var Writer = (function () {
32
32
  this.update = this.update.bind(this);
33
33
  this.patch = this.patch.bind(this);
34
34
  }
35
- Writer.prototype.create = function (obj, ctx) {
36
- return this.repository.create(obj, ctx);
35
+ Writer.prototype.create = function (obj) {
36
+ return this.repository.create(obj);
37
37
  };
38
- Writer.prototype.update = function (obj, ctx) {
39
- return this.repository.update(obj, ctx);
38
+ Writer.prototype.update = function (obj) {
39
+ return this.repository.update(obj);
40
40
  };
41
- Writer.prototype.patch = function (obj, ctx) {
42
- return (this.repository.patch ? this.repository.patch(obj, ctx) : Promise.resolve(-1));
41
+ Writer.prototype.patch = function (obj) {
42
+ return (this.repository.patch ? this.repository.patch(obj) : Promise.resolve(-1));
43
43
  };
44
44
  return Writer;
45
45
  }());
@@ -75,11 +75,11 @@ var UseCase = (function (_super) {
75
75
  UseCase.prototype.keys = function () {
76
76
  return (this.repository.keys ? this.repository.keys() : []);
77
77
  };
78
- UseCase.prototype.load = function (id, ctx) {
79
- return this.repository.load(id, ctx);
78
+ UseCase.prototype.load = function (id) {
79
+ return this.repository.load(id);
80
80
  };
81
- UseCase.prototype.delete = function (id, ctx) {
82
- return this.repository.delete(id, ctx);
81
+ UseCase.prototype.delete = function (id) {
82
+ return this.repository.delete(id);
83
83
  };
84
84
  return UseCase;
85
85
  }(SearchWriter));
@@ -101,11 +101,11 @@ var GenericUseCase = (function (_super) {
101
101
  GenericUseCase.prototype.keys = function () {
102
102
  return (this.repository.keys ? this.repository.keys() : []);
103
103
  };
104
- GenericUseCase.prototype.load = function (id, ctx) {
105
- return this.repository.load(id, ctx);
104
+ GenericUseCase.prototype.load = function (id) {
105
+ return this.repository.load(id);
106
106
  };
107
- GenericUseCase.prototype.delete = function (id, ctx) {
108
- return this.repository.delete(id, ctx);
107
+ GenericUseCase.prototype.delete = function (id) {
108
+ return this.repository.delete(id);
109
109
  };
110
110
  return GenericUseCase;
111
111
  }(Writer));
@@ -141,15 +141,4 @@ var SavedService = (function () {
141
141
  return SavedService;
142
142
  }());
143
143
  exports.SavedService = SavedService;
144
- var SavedUseCase = (function (_super) {
145
- __extends(SavedUseCase, _super);
146
- function SavedUseCase() {
147
- return _super !== null && _super.apply(this, arguments) || this;
148
- }
149
- return SavedUseCase;
150
- }(SavedService));
151
- exports.SavedUseCase = SavedUseCase;
152
- function isSuccessful(res) {
153
- return (typeof res === "number" && res <= 0) || Array.isArray(res) ? false : true;
154
- }
155
- exports.isSuccessful = isSuccessful;
144
+ exports.SavedUseCase = SavedService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onecore",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "onecore",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/db.ts CHANGED
@@ -1,4 +1,5 @@
1
- import {Attribute} from './metadata';
1
+ import { Attribute, Attributes } from './metadata';
2
+ import { Filter, SearchResult } from './model';
2
3
  export interface Statement {
3
4
  query: string;
4
5
  params?: any[];
@@ -16,9 +17,9 @@ interface StringMap {
16
17
  export interface Executor {
17
18
  driver: string;
18
19
  param(i: number): string;
19
- exec(sql: string, args?: any[], ctx?: any): Promise<number>;
20
- execBatch(statements: Statement[], firstSuccess?: boolean, ctx?: any): Promise<number>;
21
- query<T>(sql: string, args?: any[], m?: StringMap, bools?: Attribute[], ctx?: any): Promise<T[]>;
20
+ exec(sql: string, args?: any[], tx?: Transaction): Promise<number>;
21
+ execBatch(statements: Statement[], firstSuccess?: boolean, tx?: Transaction): Promise<number>;
22
+ query<T>(sql: string, args?: any[], m?: StringMap, bools?: Attribute[], tx?: Transaction): Promise<T[]>;
22
23
  }
23
24
  export interface Transaction extends Executor {
24
25
  commit(): Promise<void>
@@ -28,3 +29,76 @@ export interface Transaction extends Executor {
28
29
  export interface DB extends Executor {
29
30
  beginTransaction(): Promise<Transaction>
30
31
  }
32
+
33
+ export interface ViewRepository<T, ID> {
34
+ metadata?(): Attributes|undefined;
35
+ keys?(): string[];
36
+ load(id: ID, tx?: Transaction): Promise<T|null>;
37
+ }
38
+ export interface SearchRepository<T, F extends Filter> {
39
+ search(s: F, limit: number, offset?: number|string, fields?: string[], tx?: Transaction): Promise<SearchResult<T>>;
40
+ }
41
+ export interface ViewSearchRepository<T, ID, F extends Filter>
42
+ extends ViewRepository<T, ID>, SearchRepository<T, F> {
43
+ }
44
+ export interface GenericRepository<T, ID> extends ViewRepository<T, 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
+ }
50
+ export interface CRUDRepository<T, ID> extends ViewRepository<T, 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
+ }
56
+ export interface Repository<T, ID, F extends Filter>
57
+ extends GenericRepository<T, ID>, SearchRepository<T, F> {
58
+ }
59
+ export interface GenericSearchRepository<T, ID, F extends Filter>
60
+ extends GenericRepository<T, ID>, SearchRepository<T, F> {
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
@@ -7,23 +7,9 @@ export * from './validator';
7
7
  export * from './loader';
8
8
  export * from './model';
9
9
 
10
- import {GenericRepository} from './repository/GenericRepository';
11
-
12
- export * from './repository/ViewRepository';
13
- export * from './repository/GenericRepository';
14
- export * from './repository/SearchRepository';
15
- export * from './repository/ViewSearchRepository';
16
- export * from './repository/GenericSearchRepository';
17
-
18
- export * from './service/ViewService';
19
- export * from './service/GenericService';
20
- export * from './service/SearchService';
21
- export * from './service/ViewSearchService';
22
- export * from './service/GenericSearchService';
23
- export * from './service/DiffService';
24
- export * from './service/ApprService';
25
- export * from './service/DiffApprService';
26
- export * from './service/GenericSearchDiffApprService';
10
+ import { GenericRepository, SearchRepository, GenericSearchRepository, Transaction } from './db';
11
+ import { GenericSearchService, GenericService } from './service';
12
+ export * from './service';
27
13
 
28
14
  export * from './mail/model/AttachmentData';
29
15
  export * from './mail/model/TrackingSettings';
@@ -55,15 +41,27 @@ export type Log = (msg: string) => void;
55
41
  export type LogFunc = Log;
56
42
 
57
43
  import { Attributes } from './metadata';
58
- import { ErrorMessage, Filter, SearchResult } from './model';
59
- import { GenericSearchService } from './service/GenericSearchService';
60
- import { GenericService } from './service/GenericService';
61
- import { SearchRepository } from './repository/SearchRepository';
62
- import { GenericSearchRepository } from './repository/GenericSearchRepository';
44
+ import { Filter, SearchResult } from './model';
63
45
 
64
46
  export type Search<T, F> = (s: F, limit: number, page?: number | string, fields?: string[]) => Promise<SearchResult<T>>;
65
47
  export type SearchFunc<T, F> = Search<T, F>;
66
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
+
67
65
  export interface KeypairResult {
68
66
  rsaEncrypted: string;
69
67
  data: {
@@ -136,9 +134,9 @@ export class SearchUseCase<T, F extends Filter> {
136
134
  export const SearchManager = SearchUseCase
137
135
 
138
136
  interface WriterRepo<T> {
139
- create(obj: T, ctx?: any): Promise<number>;
140
- update(obj: T, ctx?: any): Promise<number>;
141
- patch(obj: Partial<T>, ctx?: any): Promise<number>;
137
+ create(obj: T, ctx?: Transaction): Promise<number>;
138
+ update(obj: T, ctx?: Transaction): Promise<number>;
139
+ patch(obj: Partial<T>, ctx?: Transaction): Promise<number>;
142
140
  }
143
141
  // tslint:disable-next-line:max-classes-per-file
144
142
  export class Writer<T> {
@@ -147,22 +145,22 @@ export class Writer<T> {
147
145
  this.update = this.update.bind(this);
148
146
  this.patch = this.patch.bind(this);
149
147
  }
150
- create(obj: T, ctx?: any): Promise<number> {
151
- return this.repository.create(obj, ctx);
148
+ create(obj: T): Promise<number> {
149
+ return this.repository.create(obj);
152
150
  }
153
- update(obj: T, ctx?: any): Promise<number> {
154
- return this.repository.update(obj, ctx);
151
+ update(obj: T): Promise<number> {
152
+ return this.repository.update(obj);
155
153
  }
156
- patch(obj: Partial<T>, ctx?: any): Promise<number> {
157
- return (this.repository.patch ? this.repository.patch(obj, ctx) : Promise.resolve(-1));
154
+ patch(obj: Partial<T>): Promise<number> {
155
+ return (this.repository.patch ? this.repository.patch(obj) : Promise.resolve(-1));
158
156
  }
159
157
  }
160
158
 
161
159
  interface SearchWriterRepo<T, F extends Filter> {
162
160
  search(s: F, limit: number, page?: number|string, fields?: string[]): Promise<SearchResult<T>>
163
- create(obj: T, ctx?: any): Promise<number>;
164
- update(obj: T, ctx?: any): Promise<number>;
165
- patch(obj: Partial<T>, ctx?: any): Promise<number>;
161
+ create(obj: T, ctx?: Transaction): Promise<number>;
162
+ update(obj: T, ctx?: Transaction): Promise<number>;
163
+ patch(obj: Partial<T>, ctx?: Transaction): Promise<number>;
166
164
  }
167
165
  // tslint:disable-next-line:max-classes-per-file
168
166
  export class SearchWriter<T, F extends Filter> extends Writer<T> {
@@ -190,11 +188,11 @@ export class UseCase<T, ID, F extends Filter> extends SearchWriter<T, F> impleme
190
188
  keys(): string[] {
191
189
  return (this.repository.keys ? this.repository.keys() : []);
192
190
  }
193
- load(id: ID, ctx?: any): Promise<T | null> {
194
- return this.repository.load(id, ctx);
191
+ load(id: ID): Promise<T | null> {
192
+ return this.repository.load(id);
195
193
  }
196
- delete(id: ID, ctx?: any): Promise<number> {
197
- return this.repository.delete(id, ctx);
194
+ delete(id: ID): Promise<number> {
195
+ return this.repository.delete(id);
198
196
  }
199
197
  }
200
198
 
@@ -207,17 +205,17 @@ export class GenericUseCase<T, ID> extends Writer<T> implements GenericService<T
207
205
  this.load = this.load.bind(this);
208
206
  this.delete = this.delete.bind(this);
209
207
  }
210
- metadata(): Attributes|undefined {
208
+ metadata(): Attributes | undefined {
211
209
  return (this.repository.metadata ? this.repository.metadata() : undefined);
212
210
  }
213
211
  keys(): string[] {
214
212
  return (this.repository.keys ? this.repository.keys() : []);
215
213
  }
216
- load(id: ID, ctx?: any): Promise<T | null> {
217
- return this.repository.load(id, ctx);
214
+ load(id: ID): Promise<T | null> {
215
+ return this.repository.load(id);
218
216
  }
219
- delete(id: ID, ctx?: any): Promise<number> {
220
- return this.repository.delete(id, ctx);
217
+ delete(id: ID): Promise<number> {
218
+ return this.repository.delete(id);
221
219
  }
222
220
  }
223
221
  export const CRUDUseCase = GenericUseCase
@@ -254,9 +252,4 @@ export class SavedService<UID, ID> {
254
252
  return this.savedRepository.remove(userId, id)
255
253
  }
256
254
  }
257
- // tslint:disable-next-line:max-classes-per-file
258
- export class SavedUseCase<ID, T> extends SavedService<ID, T> {
259
- }
260
- export function isSuccessful<T>(res: number | T | ErrorMessage[]): boolean {
261
- return (typeof res === "number" && res <= 0) || Array.isArray(res) ? false : true
262
- }
255
+ export const SavedUseCase = SavedService
package/src/model.ts CHANGED
@@ -20,10 +20,10 @@ export interface ModuleLoader {
20
20
  load(): Promise<Module[]>;
21
21
  }
22
22
  export interface Tracking {
23
- createdAt?: Date;
23
+ createdAt: Date;
24
24
  createdBy?: string;
25
25
  updatedAt?: Date;
26
- updatedBy?: string;
26
+ updatedBy: string;
27
27
  }
28
28
  export interface Version {
29
29
  version?: number;
package/src/service.ts ADDED
@@ -0,0 +1,45 @@
1
+ import { Filter, Result, SearchResult } from './model';
2
+ import { Attributes } from './metadata';
3
+
4
+ export interface ViewService<T, ID> {
5
+ metadata?(): Attributes|undefined;
6
+ keys?(): string[];
7
+ load(id: ID): Promise<T|null>;
8
+ }
9
+
10
+ export interface SearchService<T, F extends Filter> {
11
+ keys?(): string[];
12
+ search(s: F, limit: number, page?: number|string, fields?: string[]): Promise<SearchResult<T>>;
13
+ }
14
+
15
+ export interface Query<T, ID, F extends Filter> extends SearchService<T, F> {
16
+ metadata?(): Attributes|undefined;
17
+ load(id: ID): Promise<T|null>;
18
+ }
19
+ export interface QueryService<T, ID, F extends Filter> extends SearchService<T, F> {
20
+ metadata?(): Attributes|undefined;
21
+ load(id: ID): Promise<T|null>;
22
+ }
23
+ export interface QueryRepository<T, ID, F extends Filter> extends SearchService<T, F> {
24
+ metadata?(): Attributes|undefined;
25
+ load(id: ID): Promise<T|null>;
26
+ }
27
+
28
+ export interface GenericService<T, ID, R> extends ViewService<T, ID> {
29
+ create(obj: T): Promise<R>;
30
+ update(obj: T): Promise<R>;
31
+ patch(obj: Partial<T>): Promise<R>;
32
+ delete(id: ID): Promise<number>;
33
+ }
34
+
35
+ export interface ViewSearchService<T, ID, F extends Filter>
36
+ extends ViewService<T, ID>, SearchService<T, F> {
37
+ }
38
+
39
+ export interface GenericSearchService<T, ID, R, F extends Filter>
40
+ extends GenericService<T, ID, R>, SearchService<T, F> {
41
+ }
42
+
43
+ export interface Service<T, ID, F extends Filter>
44
+ extends GenericService<T, ID, Result<T>>, SearchService<T, F> {
45
+ }
@@ -1,20 +0,0 @@
1
- import {ViewRepository} from './ViewRepository';
2
-
3
- export interface GenericRepository<T, ID> extends ViewRepository<T, ID> {
4
- create(obj: T, ctx?: any): Promise<number>;
5
- update(obj: T, ctx?: any): Promise<number>;
6
- patch(obj: Partial<T>, ctx?: any): Promise<number>;
7
- delete(id: ID, ctx?: any): Promise<number>;
8
- }
9
- export interface Repository<T, ID> extends ViewRepository<T, ID> {
10
- create(obj: T, ctx?: any): Promise<number>;
11
- update(obj: T, ctx?: any): Promise<number>;
12
- patch(obj: Partial<T>, ctx?: any): Promise<number>;
13
- delete(id: ID, ctx?: any): Promise<number>;
14
- }
15
- export interface CRUDRepository<T, ID> extends ViewRepository<T, ID> {
16
- create(obj: T, ctx?: any): Promise<number>;
17
- update(obj: T, ctx?: any): Promise<number>;
18
- patch(obj: Partial<T>, ctx?: any): Promise<number>;
19
- delete(id: ID, ctx?: any): Promise<number>;
20
- }
@@ -1,7 +0,0 @@
1
- import {Filter} from '../model';
2
- import {GenericRepository} from './GenericRepository';
3
- import {SearchRepository} from './SearchRepository';
4
-
5
- export interface GenericSearchRepository<T, ID, F extends Filter>
6
- extends GenericRepository<T, ID>, SearchRepository<T, F> {
7
- }
@@ -1,6 +0,0 @@
1
- import {Filter} from '../model';
2
- import {SearchResult} from '../model';
3
-
4
- export interface SearchRepository<T, F extends Filter> {
5
- search(s: F, limit: number, offset?: number|string, fields?: string[], ctx?: any): Promise<SearchResult<T>>;
6
- }
@@ -1,7 +0,0 @@
1
- import {Attributes} from '../metadata';
2
-
3
- export interface ViewRepository<T, ID> {
4
- metadata?(): Attributes|undefined;
5
- keys?(): string[];
6
- load(id: ID, ctx?: any): Promise<T|null>;
7
- }
@@ -1,7 +0,0 @@
1
- import {Filter} from '../model';
2
- import {SearchRepository} from './SearchRepository';
3
- import {ViewRepository} from './ViewRepository';
4
-
5
- export interface ViewSearchRepository<T, ID, F extends Filter>
6
- extends ViewRepository<T, ID>, SearchRepository<T, F> {
7
- }
@@ -1,17 +0,0 @@
1
- export interface ApprService<ID> {
2
- approve(id: ID, ctx?: any): Promise<number|string>;
3
- reject(id: ID, ctx?: any): Promise<number|string>;
4
- }
5
- export interface ApprListService<ID> {
6
- approve(ids: ID[], ctx?: any): Promise<number|string>;
7
- reject(ids: ID[], ctx?: any): Promise<number|string>;
8
- }
9
-
10
- export interface ApprRepository<ID> {
11
- approve(id: ID, ctx?: any): Promise<number|string>;
12
- reject(id: ID, ctx?: any): Promise<number|string>;
13
- }
14
- export interface ApprListRepository<ID> {
15
- approve(ids: ID[], ctx?: any): Promise<number|string>;
16
- reject(ids: ID[], ctx?: any): Promise<number|string>;
17
- }
@@ -1,16 +0,0 @@
1
- import {ApprListRepository, ApprListService, ApprRepository, ApprService} from './ApprService';
2
- import {DiffListRepository, DiffListService, DiffRepository, DiffService} from './DiffService';
3
-
4
- export interface DiffApprService<T, ID> extends DiffService<T, ID>, ApprService<ID> {
5
-
6
- }
7
- export interface DiffApprListService<T, ID> extends DiffListService<T, ID>, ApprListService<ID> {
8
-
9
- }
10
-
11
- export interface DiffApprRepository<T, ID> extends DiffRepository<T, ID>, ApprRepository<ID> {
12
-
13
- }
14
- export interface DiffApprListRepository<T, ID> extends DiffListRepository<T, ID>, ApprListRepository<ID> {
15
-
16
- }
@@ -1,22 +0,0 @@
1
-
2
- import {DiffModel} from '../model';
3
-
4
- export interface DiffService<T, ID> {
5
- keys?(): string[];
6
- diff(id: ID, ctx?: any): Promise<DiffModel<T, ID>>;
7
- }
8
- export interface DiffListService<T, ID> {
9
- keys?(): string[];
10
- // tslint:disable-next-line:array-type
11
- diff(ids: ID[], ctx?: any): Promise<Array<DiffModel<T, ID>>>;
12
- }
13
-
14
- export interface DiffRepository<T, ID> {
15
- keys?(): string[];
16
- diff(id: ID, ctx?: any): Promise<DiffModel<T, ID>>;
17
- }
18
- export interface DiffListRepository<T, ID> {
19
- keys?(): string[];
20
- // tslint:disable-next-line:array-type
21
- diff(ids: ID[], ctx?: any): Promise<Array<DiffModel<T, ID>>>;
22
- }
@@ -1,7 +0,0 @@
1
- import {Filter} from '../model';
2
- import {DiffApprService} from './DiffApprService';
3
- import {GenericSearchService} from './GenericSearchService';
4
-
5
- export interface GenericSearchDiffApprService<T, ID, R, F extends Filter> extends GenericSearchService<T, ID, R, F>, DiffApprService<T, ID> {
6
-
7
- }
@@ -1,10 +0,0 @@
1
- import {Filter, Result} from '../model';
2
- import {GenericService} from './GenericService';
3
- import {SearchService} from './SearchService';
4
-
5
- export interface GenericSearchService<T, ID, R, F extends Filter>
6
- extends GenericService<T, ID, R>, SearchService<T, F> {
7
- }
8
- export interface Service<T, ID, F extends Filter> extends GenericSearchService<T, ID, Result<T>, F> {
9
-
10
- }
@@ -1,8 +0,0 @@
1
- import {ViewService} from './ViewService';
2
-
3
- export interface GenericService<T, ID, R> extends ViewService<T, ID> {
4
- create(obj: T, ctx?: any): Promise<R>;
5
- update(obj: T, ctx?: any): Promise<R>;
6
- patch(obj: Partial<T>, ctx?: any): Promise<R>;
7
- delete(id: ID, ctx?: any): Promise<number>;
8
- }
@@ -1,22 +0,0 @@
1
- import {Attributes} from '../metadata';
2
- import {Filter, SearchResult} from '../model';
3
-
4
- export interface SearchService<T, F extends Filter> {
5
- keys?(): string[];
6
- search(s: F, limit: number, page?: number|string, fields?: string[], ctx?: any): Promise<SearchResult<T>>;
7
- }
8
- export interface Query<T, ID, F extends Filter> extends SearchService<T, F> {
9
- metadata?(): Attributes|undefined;
10
- metadata?(): Attributes|undefined;
11
- load(id: ID, ctx?: any): Promise<T|null>;
12
- }
13
- export interface QueryService<T, ID, F extends Filter> extends SearchService<T, F> {
14
- metadata?(): Attributes|undefined;
15
- metadata?(): Attributes|undefined;
16
- load(id: ID, ctx?: any): Promise<T|null>;
17
- }
18
- export interface QueryRepository<T, ID, F extends Filter> extends SearchService<T, F> {
19
- metadata?(): Attributes|undefined;
20
- metadata?(): Attributes|undefined;
21
- load(id: ID, ctx?: any): Promise<T|null>;
22
- }
@@ -1,7 +0,0 @@
1
- import {Filter} from '../model';
2
- import {SearchService} from './SearchService';
3
- import {ViewService} from './ViewService';
4
-
5
- export interface ViewSearchService<T, ID, F extends Filter>
6
- extends ViewService<T, ID>, SearchService<T, F> {
7
- }
@@ -1,7 +0,0 @@
1
- import {Attributes} from '../metadata';
2
-
3
- export interface ViewService<T, ID> {
4
- metadata?(): Attributes|undefined;
5
- keys?(): string[];
6
- load(id: ID, ctx?: any): Promise<T|null>;
7
- }