onecore 0.0.36 → 0.0.37
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 +14 -0
- package/package.json +1 -1
- package/src/index.ts +14 -1
- package/src/service/DiffService.ts +2 -0
- package/src/service/SearchService.ts +17 -2
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
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 type SaveValues = (values: string[]) => Promise<number>;
|
|
48
|
+
export type SaveStrings = (values: string[]) => Promise<number>;
|
|
47
49
|
export interface QueryService<T> {
|
|
48
50
|
query(keyword: string, max?: number): Promise<T[]>
|
|
49
51
|
}
|
|
50
|
-
export type
|
|
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);
|
|
@@ -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 {
|
|
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
|
+
}
|