onecore 0.5.15 → 0.5.17
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 +63 -94
- package/package.json +1 -1
- package/src/metadata.ts +6 -0
- package/tsconfig.json +4 -4
package/lib/index.js
CHANGED
|
@@ -1,115 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var SearchUseCase = (function () {
|
|
17
|
-
function SearchUseCase(repository) {
|
|
1
|
+
export class SearchUseCase {
|
|
2
|
+
constructor(repository) {
|
|
18
3
|
this.repository = repository;
|
|
19
4
|
this.search = this.search.bind(this);
|
|
20
5
|
}
|
|
21
|
-
|
|
6
|
+
search(s, limit, page, fields) {
|
|
22
7
|
return this.repository.search(s, limit, page, fields);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var Writer = (function () {
|
|
29
|
-
function Writer(repository) {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const SearchManager = SearchUseCase;
|
|
11
|
+
export class Writer {
|
|
12
|
+
constructor(repository) {
|
|
30
13
|
this.repository = repository;
|
|
31
14
|
this.create = this.create.bind(this);
|
|
32
15
|
this.update = this.update.bind(this);
|
|
33
16
|
this.patch = this.patch.bind(this);
|
|
34
17
|
}
|
|
35
|
-
|
|
18
|
+
create(obj) {
|
|
36
19
|
return this.repository.create(obj);
|
|
37
|
-
}
|
|
38
|
-
|
|
20
|
+
}
|
|
21
|
+
update(obj) {
|
|
39
22
|
return this.repository.update(obj);
|
|
40
|
-
}
|
|
41
|
-
|
|
23
|
+
}
|
|
24
|
+
patch(obj) {
|
|
42
25
|
return (this.repository.patch ? this.repository.patch(obj) : Promise.resolve(-1));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
_this.search = _this.search.bind(_this);
|
|
53
|
-
return _this;
|
|
54
|
-
}
|
|
55
|
-
SearchWriter.prototype.search = function (s, limit, page, fields) {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class SearchWriter extends Writer {
|
|
29
|
+
constructor(repository) {
|
|
30
|
+
super(repository);
|
|
31
|
+
this.repository = repository;
|
|
32
|
+
this.search = this.search.bind(this);
|
|
33
|
+
}
|
|
34
|
+
search(s, limit, page, fields) {
|
|
56
35
|
return this.repository.search(s, limit, page, fields);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
_this.delete = _this.delete.bind(_this);
|
|
70
|
-
return _this;
|
|
71
|
-
}
|
|
72
|
-
UseCase.prototype.metadata = function () {
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class UseCase extends SearchWriter {
|
|
39
|
+
constructor(repository) {
|
|
40
|
+
super(repository);
|
|
41
|
+
this.repository = repository;
|
|
42
|
+
this.metadata = this.metadata.bind(this);
|
|
43
|
+
this.keys = this.keys.bind(this);
|
|
44
|
+
this.load = this.load.bind(this);
|
|
45
|
+
this.delete = this.delete.bind(this);
|
|
46
|
+
}
|
|
47
|
+
metadata() {
|
|
73
48
|
return (this.repository.metadata ? this.repository.metadata() : undefined);
|
|
74
|
-
}
|
|
75
|
-
|
|
49
|
+
}
|
|
50
|
+
keys() {
|
|
76
51
|
return (this.repository.keys ? this.repository.keys() : []);
|
|
77
|
-
}
|
|
78
|
-
|
|
52
|
+
}
|
|
53
|
+
load(id) {
|
|
79
54
|
return this.repository.load(id);
|
|
80
|
-
}
|
|
81
|
-
|
|
55
|
+
}
|
|
56
|
+
delete(id) {
|
|
82
57
|
return this.repository.delete(id);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
_this.delete = _this.delete.bind(_this);
|
|
96
|
-
return _this;
|
|
97
|
-
}
|
|
98
|
-
GenericUseCase.prototype.metadata = function () {
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export class GenericUseCase extends Writer {
|
|
61
|
+
constructor(repository) {
|
|
62
|
+
super(repository);
|
|
63
|
+
this.repository = repository;
|
|
64
|
+
this.metadata = this.metadata.bind(this);
|
|
65
|
+
this.keys = this.keys.bind(this);
|
|
66
|
+
this.load = this.load.bind(this);
|
|
67
|
+
this.delete = this.delete.bind(this);
|
|
68
|
+
}
|
|
69
|
+
metadata() {
|
|
99
70
|
return (this.repository.metadata ? this.repository.metadata() : undefined);
|
|
100
|
-
}
|
|
101
|
-
|
|
71
|
+
}
|
|
72
|
+
keys() {
|
|
102
73
|
return (this.repository.keys ? this.repository.keys() : []);
|
|
103
|
-
}
|
|
104
|
-
|
|
74
|
+
}
|
|
75
|
+
load(id) {
|
|
105
76
|
return this.repository.load(id);
|
|
106
|
-
}
|
|
107
|
-
|
|
77
|
+
}
|
|
78
|
+
delete(id) {
|
|
108
79
|
return this.repository.delete(id);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
exports.GenericManager = GenericUseCase;
|
|
115
|
-
exports.CRUDManager = GenericUseCase;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export const CRUDUseCase = GenericUseCase;
|
|
83
|
+
export const GenericManager = GenericUseCase;
|
|
84
|
+
export const CRUDManager = GenericUseCase;
|
package/package.json
CHANGED
package/src/metadata.ts
CHANGED
|
@@ -59,3 +59,9 @@ export interface Attribute {
|
|
|
59
59
|
export interface Attributes {
|
|
60
60
|
[key: string]: Attribute;
|
|
61
61
|
}
|
|
62
|
+
export interface FixedLengthAttribute extends Attribute {
|
|
63
|
+
length: number
|
|
64
|
+
}
|
|
65
|
+
export interface FixedLengthAttributes {
|
|
66
|
+
[key: string]: FixedLengthAttribute
|
|
67
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compileOnSave": true,
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"target": "
|
|
5
|
-
"
|
|
4
|
+
"target": "es6",
|
|
5
|
+
"rootDir": "./src",
|
|
6
6
|
"outDir": "./lib",
|
|
7
|
-
"module": "
|
|
8
|
-
"moduleResolution": "
|
|
7
|
+
"module": "node16",
|
|
8
|
+
"moduleResolution": "node16",
|
|
9
9
|
"strict": true,
|
|
10
10
|
"pretty": true,
|
|
11
11
|
"sourceMap": false,
|