onecore 0.0.35 → 0.0.38

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
@@ -46,6 +46,20 @@ var ViewSearchManager = (function (_super) {
46
46
  return ViewSearchManager;
47
47
  }(ViewManager));
48
48
  exports.ViewSearchManager = ViewSearchManager;
49
+ var SearchManager = (function (_super) {
50
+ __extends(SearchManager, _super);
51
+ function SearchManager(repository) {
52
+ var _this = _super.call(this, repository) || this;
53
+ _this.repository = repository;
54
+ _this.search = _this.search.bind(_this);
55
+ return _this;
56
+ }
57
+ SearchManager.prototype.search = function (s, limit, offset, fields) {
58
+ return this.repository.search(s, limit, offset, fields);
59
+ };
60
+ return SearchManager;
61
+ }(ViewManager));
62
+ exports.SearchManager = SearchManager;
49
63
  var GenericManager = (function (_super) {
50
64
  __extends(GenericManager, _super);
51
65
  function GenericManager(repository) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onecore",
3
- "version": "0.0.35",
3
+ "version": "0.0.38",
4
4
  "description": "onecore",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -44,10 +44,13 @@ export type DeleteFile = (name: string, directory?: string) => Promise<boolean>;
44
44
  export type Delete = (delFile: DeleteFile, url: string) => Promise<boolean>;
45
45
  export type BuildUrl = (name: string, directory?: string) => string;
46
46
  export type Generate = () => string;
47
- export interface QueryService<T, P> {
48
- query(keyword: P, max?: number): Promise<T[]>
47
+ export type SaveValues = (values: string[]) => Promise<number>;
48
+ export type SaveStrings = (values: string[]) => Promise<number>;
49
+ export interface QueryService<T> {
50
+ query(keyword: string, max?: number): Promise<T[]>;
49
51
  }
50
- export type Query<T> = (keyword: string, max?: number) => Promise<T[]>;
52
+ export type Get<T> = (keyword: string, max?: number) => Promise<T[]>;
53
+ export type Load<T> = (keyword: string, max?: number) => Promise<T[]>;
51
54
  export type Log = (msg: string) => void;
52
55
  export type LogFunc = Log;
53
56
 
@@ -91,6 +94,16 @@ export class ViewSearchManager<T, ID, F extends Filter> extends ViewManager<T, I
91
94
  }
92
95
  }
93
96
  // tslint:disable-next-line:max-classes-per-file
97
+ export class SearchManager<T, ID, F extends Filter> extends ViewManager<T, ID> implements ViewSearchService<T, ID, F> {
98
+ constructor(protected repository: ViewSearchService<T, ID, F>) {
99
+ super(repository);
100
+ this.search = this.search.bind(this);
101
+ }
102
+ search(s: F, limit?: number, offset?: number|string, fields?: string[]): Promise<SearchResult<T>> {
103
+ return this.repository.search(s, limit, offset, fields);
104
+ }
105
+ }
106
+ // tslint:disable-next-line:max-classes-per-file
94
107
  export class GenericManager<T, ID> extends ViewManager<T, ID> implements GenericService<T, ID, number> {
95
108
  constructor(protected repository: GenericRepository<T, ID>) {
96
109
  super(repository);
package/src/model.ts CHANGED
@@ -158,3 +158,60 @@ export interface RoleFilter extends Filter {
158
158
  export type Validate<T> = (obj: T, patch?: boolean) => Promise<ErrorMessage[]>;
159
159
  export type Save<T> = (obj: T, ctx?: any) => Promise<number|ResultInfo<T>>;
160
160
  export type Load<T, ID> = ((id: ID, ctx?: any) => Promise<T|null>);
161
+
162
+ export interface ReviewComment {
163
+ commentId: string;
164
+ id: string;
165
+ author: string;
166
+ userId: string;
167
+ comment: string;
168
+ time: Date;
169
+ updatedAt?: Date;
170
+ histories?: ShortComment[];
171
+ userURL?: string;
172
+ authorURL?: string;
173
+ }
174
+ export interface ShortComment {
175
+ comment: string;
176
+ time: Date;
177
+ }
178
+
179
+ export interface ReviewCommentFilter extends Filter {
180
+ commentId?: string;
181
+ id?: string;
182
+ author?: string;
183
+ userId?: string;
184
+ comment?: string;
185
+ time?: DateRange;
186
+ updatedAt?: DateRange;
187
+ }
188
+ export interface Info {
189
+ id: string;
190
+ rate: number;
191
+ rate1: number;
192
+ rate2: number;
193
+ rate3: number;
194
+ rate4: number;
195
+ rate5: number;
196
+ count: number;
197
+ score: number;
198
+ }
199
+ export interface Info10 {
200
+ id: string;
201
+ rate: number;
202
+ rate1: number;
203
+ rate2: number;
204
+ rate3: number;
205
+ rate4: number;
206
+ rate5: number;
207
+ rate6: number;
208
+ rate7: number;
209
+ rate8: number;
210
+ rate9: number;
211
+ rate10: number;
212
+ count: number;
213
+ score: number;
214
+ }
215
+ export interface InfoRepository<ID> {
216
+ exist(id: ID, ctx?: any): Promise<boolean>;
217
+ }
@@ -7,6 +7,7 @@ export interface DiffService<T, ID> {
7
7
  }
8
8
  export interface DiffListService<T, ID> {
9
9
  keys?(): string[];
10
+ // tslint:disable-next-line:array-type
10
11
  diff(ids: ID[], ctx?: any): Promise<Array<DiffModel<T, ID>>>;
11
12
  }
12
13
 
@@ -16,5 +17,6 @@ export interface DiffRepository<T, ID> {
16
17
  }
17
18
  export interface DiffListRepository<T, ID> {
18
19
  keys?(): string[];
20
+ // tslint:disable-next-line:array-type
19
21
  diff(ids: ID[], ctx?: any): Promise<Array<DiffModel<T, ID>>>;
20
22
  }
@@ -1,7 +1,22 @@
1
- import {Filter} from '../model';
2
- import {SearchResult} from '../model';
1
+ import {Attributes} from '../metadata';
2
+ import {Filter, SearchResult} from '../model';
3
3
 
4
4
  export interface SearchService<T, F extends Filter> {
5
5
  keys?(): string[];
6
6
  search(s: F, limit?: number, offset?: number|string, fields?: string[], ctx?: any): Promise<SearchResult<T>>;
7
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
+ }