@apex-pub/convector-core-model 1.4.1-4-alpha.5f94f88e → 1.5.0
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/CHANGELOG.md +36 -0
- package/dist/src/convector-model.d.ts +2 -2
- package/dist/src/convector-model.js +185 -114
- package/dist/src/convector-model.js.map +1 -1
- package/dist/src/default.decorator.js +11 -8
- package/dist/src/default.decorator.js.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/read-only.decorator.js +8 -9
- package/dist/src/read-only.decorator.js.map +1 -1
- package/dist/src/required.decorator.js +10 -10
- package/dist/src/required.decorator.js.map +1 -1
- package/dist/src/validate.decorator.js +16 -16
- package/dist/src/validate.decorator.js.map +1 -1
- package/package.json +13 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
<a name="1.5.0"></a>
|
|
7
|
+
# 1.5.0 (2024-07-29)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* add semver package and enforceType validation ([96489cb](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/96489cb))
|
|
13
|
+
* error handlers for testing and chaincode ([ef9bae6](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/ef9bae6))
|
|
14
|
+
* fix conditional for enforceType ([f9e1105](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/f9e1105))
|
|
15
|
+
* fix getOne conditional ([b1b143b](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/b1b143b))
|
|
16
|
+
* **core-model:** Validate to accept convector moddels ([6efb592](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/6efb592)), closes [#45](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/issues/45)
|
|
17
|
+
* **core-model,core-controller:** convector model to accept yup.lazy ([c7e67ed](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/c7e67ed)), closes [#50](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/issues/50)
|
|
18
|
+
* flat-convector-model with optional props ([57ce2bb](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/57ce2bb))
|
|
19
|
+
* getOne error when not found by id ([be2c099](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/be2c099))
|
|
20
|
+
* handle global on browser environments ([44fcd22](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/44fcd22))
|
|
21
|
+
* modify getone type validation ([6a21087](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/6a21087))
|
|
22
|
+
* update access public to the packages (pull request [#27](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/issues/27)) ([f2eebde](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/f2eebde))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* Add documentation (pull request [#28](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/issues/28)) ([fc8ddbc](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/fc8ddbc))
|
|
28
|
+
* clean up dependencies to be front-end enabled (pull request [#46](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/issues/46)) ([fa1ee0a](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/fa1ee0a))
|
|
29
|
+
* **core-model:** Add inheritance to convector models ([077f1ec](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/077f1ec)), closes [#43](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/issues/43)
|
|
30
|
+
* enhance errors from yup to be more descriptive ([bcac669](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/bcac669))
|
|
31
|
+
* group packages and update package.json's ([3971b44](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/3971b44))
|
|
32
|
+
* Preparing versions for stable release (pull request [#25](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/issues/25)) ([1f5a876](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/1f5a876))
|
|
33
|
+
* Production readiness (pull request [#48](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/issues/48)) ([5bb7287](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/5bb7287))
|
|
34
|
+
* refactor convector client implementation and add browser support ([30ec673](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/30ec673))
|
|
35
|
+
* Rename logically (pull request [#21](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/issues/21)) ([d1a78ad](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/d1a78ad))
|
|
36
|
+
* transient and private data features ([3fa0442](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model/commit/3fa0442))
|
|
@@ -31,7 +31,7 @@ export declare abstract class ConvectorModel<T extends ConvectorModel<any>> {
|
|
|
31
31
|
static query<T>(type: new (content: any) => T, ...args: any[]): Promise<T | T[]>;
|
|
32
32
|
static getAll<T extends ConvectorModel<any>>(this: new (content: any) => T, type?: string): Promise<T[]>;
|
|
33
33
|
id: string;
|
|
34
|
-
abstract
|
|
34
|
+
readonly abstract type: string;
|
|
35
35
|
constructor();
|
|
36
36
|
constructor(id: string);
|
|
37
37
|
constructor(content: {
|
|
@@ -48,5 +48,5 @@ export declare abstract class ConvectorModel<T extends ConvectorModel<any>> {
|
|
|
48
48
|
[key in keyof T]?: T[key];
|
|
49
49
|
};
|
|
50
50
|
delete(storageOptions?: any): Promise<void>;
|
|
51
|
-
private assign;
|
|
51
|
+
private assign(content, defaults?);
|
|
52
52
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
constructor(content) {
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var yup = require("yup");
|
|
5
|
+
var convector_core_errors_1 = require("@apex-pub/convector-core-errors");
|
|
6
|
+
var convector_core_storage_1 = require("@apex-pub/convector-core-storage");
|
|
7
|
+
var validate_decorator_1 = require("../src/validate.decorator");
|
|
8
|
+
var default_decorator_1 = require("../src/default.decorator");
|
|
9
|
+
var required_decorator_1 = require("../src/required.decorator");
|
|
10
|
+
var validate_decorator_2 = require("../src/validate.decorator");
|
|
11
|
+
var ConvectorModel = (function () {
|
|
12
|
+
function ConvectorModel(content) {
|
|
14
13
|
if (!content) {
|
|
15
14
|
return;
|
|
16
15
|
}
|
|
@@ -20,106 +19,166 @@ class ConvectorModel {
|
|
|
20
19
|
}
|
|
21
20
|
this.assign(content);
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
return yup.object().shape(
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return tslib_1.__awaiter(this, void 0, void 0, function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
ConvectorModel.schema = function () {
|
|
23
|
+
return yup.object().shape(tslib_1.__assign({ id: yup.string().required(), type: yup.string() }, validate_decorator_2.getPropertiesValidation(this.prototype)));
|
|
24
|
+
};
|
|
25
|
+
ConvectorModel.getOne = function (id, type, storageOptions) {
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
27
|
+
var content, model;
|
|
28
|
+
return tslib_1.__generator(this, function (_a) {
|
|
29
|
+
switch (_a.label) {
|
|
30
|
+
case 0:
|
|
31
|
+
type = type || this;
|
|
32
|
+
return [4, convector_core_storage_1.BaseStorage.current.get(id, storageOptions)];
|
|
33
|
+
case 1:
|
|
34
|
+
content = _a.sent();
|
|
35
|
+
model = new type(content);
|
|
36
|
+
if ((content && model) && content.type !== new type('').type) {
|
|
37
|
+
if (storageOptions && storageOptions.enforceType) {
|
|
38
|
+
throw new Error("Possible ID collision, element " + id + " of type " + content.type + " is not " + new type('').type);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.warn("Possible ID collision, element " + id + " of type " + content.type + " is not " + new type('').type);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return [2, model];
|
|
37
45
|
}
|
|
38
|
-
}
|
|
39
|
-
return model;
|
|
46
|
+
});
|
|
40
47
|
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
};
|
|
49
|
+
ConvectorModel.query = function () {
|
|
50
|
+
var args = [];
|
|
51
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
52
|
+
args[_i] = arguments[_i];
|
|
53
|
+
}
|
|
54
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
55
|
+
var type, content, _a;
|
|
56
|
+
return tslib_1.__generator(this, function (_b) {
|
|
57
|
+
switch (_b.label) {
|
|
58
|
+
case 0:
|
|
59
|
+
type = this;
|
|
60
|
+
if (args[0] && 'type' in args[0] && args[0].type === ConvectorModel.type) {
|
|
61
|
+
type = args.shift();
|
|
62
|
+
}
|
|
63
|
+
return [4, (_a = convector_core_storage_1.BaseStorage.current).query.apply(_a, args)];
|
|
64
|
+
case 1:
|
|
65
|
+
content = _b.sent();
|
|
66
|
+
return [2, Array.isArray(content) ? content.map(function (c) { return new type(c); }) : new type(content)];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
56
69
|
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return tslib_1.__awaiter(this, void 0, void 0, function
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
};
|
|
71
|
+
ConvectorModel.getAll = function (type) {
|
|
72
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
73
|
+
return tslib_1.__generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
type = type || new this('').type;
|
|
77
|
+
return [4, ConvectorModel.query(this, { selector: { type: type } })];
|
|
78
|
+
case 1: return [2, _a.sent()];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
62
81
|
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return tslib_1.__awaiter(this, void 0, void 0, function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
};
|
|
83
|
+
ConvectorModel.prototype.update = function (content) {
|
|
84
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
85
|
+
return tslib_1.__generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
this.assign(content);
|
|
89
|
+
return [4, this.save()];
|
|
90
|
+
case 1:
|
|
91
|
+
_a.sent();
|
|
92
|
+
return [2];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
71
95
|
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return tslib_1.__awaiter(this, void 0, void 0, function
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
96
|
+
};
|
|
97
|
+
ConvectorModel.prototype.fetch = function (storageOptions) {
|
|
98
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
99
|
+
var content;
|
|
100
|
+
return tslib_1.__generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0: return [4, convector_core_storage_1.BaseStorage.current.get(this.id, storageOptions)];
|
|
103
|
+
case 1:
|
|
104
|
+
content = _a.sent();
|
|
105
|
+
if (content.type !== this.type) {
|
|
106
|
+
throw new Error("Possible ID collision, element " + this.id + " of type " + content.type + " is not " + this.type);
|
|
107
|
+
}
|
|
108
|
+
this.assign(content);
|
|
109
|
+
return [2];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
81
112
|
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return tslib_1.__awaiter(this, void 0, void 0, function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
113
|
+
};
|
|
114
|
+
ConvectorModel.prototype.history = function () {
|
|
115
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
116
|
+
var _this = this;
|
|
117
|
+
var history;
|
|
118
|
+
return tslib_1.__generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0: return [4, convector_core_storage_1.BaseStorage.current.history(this.id)];
|
|
121
|
+
case 1:
|
|
122
|
+
history = _a.sent();
|
|
123
|
+
return [2, history.map(function (item) { return ({
|
|
124
|
+
txId: item.tx_id,
|
|
125
|
+
value: new _this.constructor(item.value),
|
|
126
|
+
timestamp: item.timestamp
|
|
127
|
+
}); })];
|
|
89
128
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
ConvectorModel.prototype.save = function (storageOptions) {
|
|
133
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
134
|
+
return tslib_1.__generator(this, function (_a) {
|
|
135
|
+
switch (_a.label) {
|
|
136
|
+
case 0:
|
|
137
|
+
this.assign(default_decorator_1.getDefaults(this), true);
|
|
138
|
+
if (!required_decorator_1.ensureRequired(this)) {
|
|
139
|
+
if (!this.id) {
|
|
140
|
+
throw new Error("Model " + this.type + " is missing the 'id' property \n" + JSON.stringify(this));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
throw new Error("Model " + this.type + " is not complete\n" + JSON.stringify(this) + ".\n Check your model definition for more details.");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
convector_core_errors_1.InvalidIdError.test(this.id);
|
|
147
|
+
return [4, convector_core_storage_1.BaseStorage.current.set(this.id, this, storageOptions)];
|
|
148
|
+
case 1:
|
|
149
|
+
_a.sent();
|
|
150
|
+
return [2];
|
|
93
151
|
}
|
|
94
|
-
}
|
|
95
|
-
convector_core_errors_1.InvalidIdError.test(this.id);
|
|
96
|
-
yield convector_core_storage_1.BaseStorage.current.set(this.id, this, storageOptions);
|
|
152
|
+
});
|
|
97
153
|
});
|
|
98
|
-
}
|
|
99
|
-
clone() {
|
|
154
|
+
};
|
|
155
|
+
ConvectorModel.prototype.clone = function () {
|
|
100
156
|
return new this.constructor(Object.assign({}, this));
|
|
101
|
-
}
|
|
102
|
-
toJSON
|
|
103
|
-
|
|
104
|
-
|
|
157
|
+
};
|
|
158
|
+
ConvectorModel.prototype.toJSON = function (skipEmpty) {
|
|
159
|
+
var _this = this;
|
|
160
|
+
if (skipEmpty === void 0) { skipEmpty = false; }
|
|
161
|
+
var protos = [];
|
|
162
|
+
var children = this;
|
|
105
163
|
do {
|
|
106
164
|
children = Object.getPrototypeOf(children);
|
|
107
165
|
protos.push(children);
|
|
108
166
|
} while (children['__proto__'].constructor.name !== ConvectorModel.name);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
.
|
|
116
|
-
|
|
117
|
-
|
|
167
|
+
var descriptors = protos.reduce(function (result, proto) { return result.concat(Object.keys(proto)
|
|
168
|
+
.map(function (key) { return [key, Object.getOwnPropertyDescriptor(proto, key)]; })); }, []);
|
|
169
|
+
var base = Object.keys(this).concat('id')
|
|
170
|
+
.filter(function (k) { return !k.startsWith('_'); })
|
|
171
|
+
.filter(function (k) { return !skipEmpty || !(_this[k] === undefined || _this[k] === null); })
|
|
172
|
+
.reduce(function (result, key) {
|
|
173
|
+
return (tslib_1.__assign({}, result, (_a = {}, _a[key] = _this[key], _a)));
|
|
174
|
+
var _a;
|
|
175
|
+
}, {});
|
|
118
176
|
return descriptors
|
|
119
|
-
.reduce((result,
|
|
120
|
-
|
|
177
|
+
.reduce(function (result, _a) {
|
|
178
|
+
var key = _a[0], desc = _a[1];
|
|
179
|
+
var hasGetter = desc && typeof desc.get === 'function';
|
|
121
180
|
if (hasGetter) {
|
|
122
|
-
result[key] = desc.get.call(
|
|
181
|
+
result[key] = desc.get.call(_this);
|
|
123
182
|
}
|
|
124
183
|
if (skipEmpty && (result[key] === undefined || result[key] === null)) {
|
|
125
184
|
delete result[key];
|
|
@@ -129,26 +188,38 @@ class ConvectorModel {
|
|
|
129
188
|
}
|
|
130
189
|
return result;
|
|
131
190
|
}, base);
|
|
132
|
-
}
|
|
133
|
-
delete(storageOptions) {
|
|
134
|
-
return tslib_1.__awaiter(this, void 0, void 0, function
|
|
135
|
-
|
|
191
|
+
};
|
|
192
|
+
ConvectorModel.prototype.delete = function (storageOptions) {
|
|
193
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
194
|
+
return tslib_1.__generator(this, function (_a) {
|
|
195
|
+
switch (_a.label) {
|
|
196
|
+
case 0: return [4, convector_core_storage_1.BaseStorage.current.delete(this.id, storageOptions)];
|
|
197
|
+
case 1:
|
|
198
|
+
_a.sent();
|
|
199
|
+
return [2];
|
|
200
|
+
}
|
|
201
|
+
});
|
|
136
202
|
});
|
|
137
|
-
}
|
|
138
|
-
assign(content, defaults
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.
|
|
143
|
-
.
|
|
144
|
-
|
|
203
|
+
};
|
|
204
|
+
ConvectorModel.prototype.assign = function (content, defaults) {
|
|
205
|
+
if (defaults === void 0) { defaults = false; }
|
|
206
|
+
var validated = ['id', 'type'].concat(validate_decorator_2.getValidatedProperties(this));
|
|
207
|
+
var filteredContent = Object.keys(content)
|
|
208
|
+
.map(function (key) { return key.replace(/^_/, ''); })
|
|
209
|
+
.filter(function (key) { return validated.indexOf(key) >= 0; })
|
|
210
|
+
.reduce(function (result, key) {
|
|
211
|
+
return (tslib_1.__assign({}, result, (_a = {}, _a[key] = content[key] !== undefined ? content[key] : content['_' + key], _a)));
|
|
212
|
+
var _a;
|
|
213
|
+
}, {});
|
|
214
|
+
var afterDefaults = defaults ? this.toJSON(true) : {};
|
|
145
215
|
Object.assign(this, filteredContent, afterDefaults);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
216
|
+
};
|
|
217
|
+
ConvectorModel.type = 'io.convector.model';
|
|
218
|
+
tslib_1.__decorate([
|
|
219
|
+
required_decorator_1.Required(),
|
|
220
|
+
validate_decorator_1.Validate(yup.string())
|
|
221
|
+
], ConvectorModel.prototype, "id", void 0);
|
|
222
|
+
return ConvectorModel;
|
|
223
|
+
}());
|
|
153
224
|
exports.ConvectorModel = ConvectorModel;
|
|
154
225
|
//# sourceMappingURL=convector-model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convector-model.js","sourceRoot":"","sources":["../../src/convector-model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convector-model.js","sourceRoot":"","sources":["../../src/convector-model.ts"],"names":[],"mappings":";;;AAEA,yBAA2B;AAC3B,yEAAiE;AACjE,2EAA+D;AAE/D,gEAAqD;AACrD,8DAAuD;AACvD,gEAAqE;AACrE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IAAI,EAAE,MAAM,SAAK,2CAAsB,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE,IAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;aACzC,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAArB,CAAqB,CAAC;aACjC,MAAM,CAAC,UAAA,GAAG,IAAI,OAAA,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAA3B,CAA2B,CAAC;aAC1C,MAAM,CAAC,UAAC,MAAM,EAAE,GAAG;YAAK,OAAA,sBACpB,MAAM,eACR,GAAG,IAAG,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,OACrE;;QAHuB,CAGvB,EAAE,EAAE,CAAC,CAAC;QAEV,IAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;IACtD,CAAC;IAjQc,mBAAI,GAAG,oBAAoB,CAAC;IAkF3C;QAFC,6BAAQ,EAAE;QACV,6BAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;8CACL;IAgLpB,qBAAC;CAAA,AAnQD,IAmQC;AAnQqB,wCAAc"}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const g = tslib_1.__importStar(require("window-or-global"));
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var g = require("window-or-global");
|
|
6
5
|
require("reflect-metadata");
|
|
7
6
|
exports.defaultMetadataKey = g.ConvectorDefaultMetadataKey || Symbol('default');
|
|
8
7
|
g.ConvectorDefaultMetadataKey = exports.defaultMetadataKey;
|
|
9
8
|
function Default(defaultValue) {
|
|
10
|
-
return (target, key)
|
|
11
|
-
|
|
12
|
-
Reflect.defineMetadata(exports.defaultMetadataKey,
|
|
9
|
+
return function (target, key) {
|
|
10
|
+
var defaults = Reflect.getMetadata(exports.defaultMetadataKey, target) || {};
|
|
11
|
+
Reflect.defineMetadata(exports.defaultMetadataKey, tslib_1.__assign({}, defaults, (_a = {}, _a[key] = defaultValue, _a)), target);
|
|
12
|
+
var _a;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
exports.Default = Default;
|
|
16
16
|
function getDefaults(obj) {
|
|
17
|
-
|
|
17
|
+
var defaults = Reflect.getMetadata(exports.defaultMetadataKey, obj);
|
|
18
18
|
return !defaults ? {} : Object.keys(defaults)
|
|
19
|
-
.reduce(
|
|
19
|
+
.reduce(function (result, k) {
|
|
20
|
+
return (tslib_1.__assign({}, result, (_a = {}, _a[k] = typeof defaults[k] === 'function' ? defaults[k]() : defaults[k], _a)));
|
|
21
|
+
var _a;
|
|
22
|
+
}, {});
|
|
20
23
|
}
|
|
21
24
|
exports.getDefaults = getDefaults;
|
|
22
25
|
//# sourceMappingURL=default.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.decorator.js","sourceRoot":"","sources":["../../src/default.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default.decorator.js","sourceRoot":"","sources":["../../src/default.decorator.ts"],"names":[],"mappings":";;;AAEA,oCAAsC;AACtC,4BAA0B;AAEb,QAAA,kBAAkB,GAAG,CAAC,CAAC,2BAA2B,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC;AACrF,CAAC,CAAC,2BAA2B,GAAG,0BAAkB,CAAC;AAEnD,iBAA2B,YAAe;IACxC,OAAO,UAAC,MAAW,EAAE,GAAW;QAC9B,IAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,0BAAkB,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;QAEvE,OAAO,CAAC,cAAc,CAAC,0BAAkB,uBACpC,QAAQ,eACV,GAAG,IAAG,YAAY,QAClB,MAAM,CAAC,CAAC;;IACb,CAAC,CAAC;AACJ,CAAC;AATD,0BASC;AAED,qBAA4B,GAAQ;IAClC,IAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,0BAAkB,EAAE,GAAG,CAAC,CAAC;IAE9D,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC1C,MAAM,CAAC,UAAC,MAAM,EAAE,CAAC;QAAK,OAAA,sBAClB,MAAM,eACR,CAAC,IAAG,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OACpE;;IAHqB,CAGrB,EAAE,EAAE,CAAC,CAAC;AACZ,CAAC;AARD,kCAQC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./convector-model"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./default.decorator"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./required.decorator"), exports);
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReadOnly = void 0;
|
|
4
3
|
function ReadOnly() {
|
|
5
4
|
return function (target, key) {
|
|
6
|
-
|
|
7
|
-
get() {
|
|
8
|
-
return this[
|
|
5
|
+
var getSet = {
|
|
6
|
+
get: function () {
|
|
7
|
+
return this["_" + key];
|
|
9
8
|
},
|
|
10
|
-
set(newVal) {
|
|
11
|
-
|
|
12
|
-
setter = !setter || setter === getSet.set ? (v
|
|
13
|
-
this[
|
|
14
|
-
setter.call(this, newVal) : this[
|
|
9
|
+
set: function (newVal) {
|
|
10
|
+
var setter = target.__lookupSetter__(key);
|
|
11
|
+
setter = !setter || setter === getSet.set ? (function (v) { return v; }) : setter;
|
|
12
|
+
this["_" + key] = this["_" + key] === undefined ?
|
|
13
|
+
setter.call(this, newVal) : this["_" + key];
|
|
15
14
|
},
|
|
16
15
|
enumerable: true,
|
|
17
16
|
configurable: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-only.decorator.js","sourceRoot":"","sources":["../../src/read-only.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-only.decorator.js","sourceRoot":"","sources":["../../src/read-only.decorator.ts"],"names":[],"mappings":";;AAGA;IACE,OAAO,UACL,MAAW,EACX,GAAW;QAEX,IAAM,MAAM,GAAG;YACb,GAAG;gBACD,OAAO,IAAI,CAAC,MAAI,GAAK,CAAC,CAAC;YACzB,CAAC;YACD,GAAG,YAAC,MAAM;gBACR,IAAI,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;gBAC1C,MAAM,GAAG,CAAC,MAAM,IAAI,MAAM,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,EAAD,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;gBAE9D,IAAI,CAAC,MAAI,GAAK,CAAC,GAAG,IAAI,CAAC,MAAI,GAAK,CAAC,KAAK,SAAS,CAAC,CAAC;oBAC/C,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAI,GAAK,CAAC,CAAC;YAChD,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC;QAEF,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC;AAtBD,4BAsBC"}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const g = tslib_1.__importStar(require("window-or-global"));
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var g = require("window-or-global");
|
|
6
5
|
require("reflect-metadata");
|
|
7
6
|
exports.requiredMetadataKey = g.ConvectorRequiredMetadataKey || Symbol('required');
|
|
8
7
|
g.ConvectorRequiredMetadataKey = exports.requiredMetadataKey;
|
|
9
8
|
function Required() {
|
|
10
|
-
return (target, key)
|
|
11
|
-
|
|
12
|
-
Reflect.defineMetadata(exports.requiredMetadataKey,
|
|
9
|
+
return function (target, key) {
|
|
10
|
+
var required = Reflect.getMetadata(exports.requiredMetadataKey, target);
|
|
11
|
+
Reflect.defineMetadata(exports.requiredMetadataKey, tslib_1.__assign({}, required, (_a = {}, _a[key] = true, _a)), target);
|
|
12
|
+
var _a;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
exports.Required = Required;
|
|
16
16
|
function ensureRequired(obj) {
|
|
17
|
-
|
|
17
|
+
var required = {};
|
|
18
18
|
try {
|
|
19
19
|
required = Reflect.getMetadata(exports.requiredMetadataKey, obj) || {};
|
|
20
20
|
}
|
|
21
21
|
catch (e) {
|
|
22
22
|
}
|
|
23
23
|
return Object.keys(required)
|
|
24
|
-
.every(k
|
|
25
|
-
|
|
24
|
+
.every(function (k) {
|
|
25
|
+
var res = !required[k] || obj[k] !== undefined;
|
|
26
26
|
if (!res) {
|
|
27
|
-
console.log(
|
|
27
|
+
console.log("Validation error. Field " + k + " is required but was not found.");
|
|
28
28
|
}
|
|
29
29
|
return res;
|
|
30
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"required.decorator.js","sourceRoot":"","sources":["../../src/required.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"required.decorator.js","sourceRoot":"","sources":["../../src/required.decorator.ts"],"names":[],"mappings":";;;AAEA,oCAAsC;AACtC,4BAA0B;AAEb,QAAA,mBAAmB,GAAG,CAAC,CAAC,4BAA4B,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;AACxF,CAAC,CAAC,4BAA4B,GAAG,2BAAmB,CAAC;AAErD;IACE,OAAO,UAAC,MAAW,EAAE,GAAW;QAC9B,IAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,2BAAmB,EAAE,MAAM,CAAC,CAAC;QAElE,OAAO,CAAC,cAAc,CAAC,2BAAmB,uBACrC,QAAQ,eACV,GAAG,IAAG,IAAI,QACV,MAAM,CAAC,CAAC;;IACb,CAAC,CAAC;AACJ,CAAC;AATD,4BASC;AAED,wBAA+B,GAAQ;IACrC,IAAI,QAAQ,GAAG,EAAE,CAAC;IAElB,IAAI;QACF,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,2BAAmB,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;KAChE;IAAC,OAAO,CAAC,EAAE;KAEX;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;SACzB,KAAK,CAAC,UAAA,CAAC;QACN,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;QAC/C,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,CAAC,GAAG,CAAC,6BAA2B,CAAC,oCAAiC,CAAC,CAAC;SAC5E;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACP,CAAC;AAjBD,wCAiBC"}
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const g = tslib_1.__importStar(require("window-or-global"));
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var g = require("window-or-global");
|
|
6
5
|
require("reflect-metadata");
|
|
7
6
|
exports.validateMetadataKey = g.ConvectorValidateMetadataKey || Symbol('validate');
|
|
8
7
|
g.ConvectorValidateMetadataKey = exports.validateMetadataKey;
|
|
9
8
|
function Validate(input) {
|
|
10
|
-
|
|
9
|
+
var schema = input;
|
|
11
10
|
if ('schema' in input) {
|
|
12
11
|
schema = input.schema();
|
|
13
12
|
}
|
|
14
|
-
return (target, key)
|
|
15
|
-
|
|
16
|
-
get() {
|
|
17
|
-
return this[
|
|
13
|
+
return function (target, key) {
|
|
14
|
+
var getSet = {
|
|
15
|
+
get: function () {
|
|
16
|
+
return this["_" + key];
|
|
18
17
|
},
|
|
19
|
-
set(newVal) {
|
|
20
|
-
|
|
21
|
-
setter = !setter || setter === getSet.set ? (v
|
|
18
|
+
set: function (newVal) {
|
|
19
|
+
var setter = target.__lookupSetter__(key);
|
|
20
|
+
setter = !setter || setter === getSet.set ? (function (v) { return v; }) : setter;
|
|
22
21
|
try {
|
|
23
|
-
this[
|
|
22
|
+
this["_" + key] = schema.validateSync(setter.call(this, newVal));
|
|
24
23
|
}
|
|
25
24
|
catch (ex) {
|
|
26
|
-
ex.message =
|
|
25
|
+
ex.message = "Error for field '" + key + "' with val '" + JSON.stringify(newVal) + "' " + ex.message;
|
|
27
26
|
throw ex;
|
|
28
27
|
}
|
|
29
28
|
},
|
|
@@ -31,13 +30,14 @@ function Validate(input) {
|
|
|
31
30
|
configurable: true
|
|
32
31
|
};
|
|
33
32
|
Object.defineProperty(target, key, getSet);
|
|
34
|
-
|
|
35
|
-
Reflect.defineMetadata(exports.validateMetadataKey,
|
|
33
|
+
var validated = Reflect.getMetadata(exports.validateMetadataKey, target);
|
|
34
|
+
Reflect.defineMetadata(exports.validateMetadataKey, tslib_1.__assign({}, validated, (_a = {}, _a[key] = schema, _a)), target);
|
|
35
|
+
var _a;
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
exports.Validate = Validate;
|
|
39
39
|
function getPropertiesValidation(obj) {
|
|
40
|
-
|
|
40
|
+
var validated = {};
|
|
41
41
|
try {
|
|
42
42
|
validated = Reflect.getMetadata(exports.validateMetadataKey, obj) || {};
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.decorator.js","sourceRoot":"","sources":["../../src/validate.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.decorator.js","sourceRoot":"","sources":["../../src/validate.decorator.ts"],"names":[],"mappings":";;;AAIA,oCAAsC;AACtC,4BAA0B;AAEb,QAAA,mBAAmB,GAAG,CAAC,CAAC,4BAA4B,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;AACxF,CAAC,CAAC,4BAA4B,GAAG,2BAAmB,CAAC;AAErD,kBAA4B,KAA8C;IACxE,IAAI,MAAM,GAAG,KAAkB,CAAC;IAEhC,IAAI,QAAQ,IAAI,KAAK,EAAE;QACrB,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;KACzB;IAED,OAAO,UAAC,MAAW,EAAE,GAAW;QAC9B,IAAM,MAAM,GAAG;YACb,GAAG;gBACD,OAAO,IAAI,CAAC,MAAI,GAAK,CAAC,CAAC;YACzB,CAAC;YACD,GAAG,YAAC,MAAM;gBACR,IAAI,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;gBAC1C,MAAM,GAAG,CAAC,MAAM,IAAI,MAAM,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,EAAD,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;gBAE9D,IAAI;oBACF,IAAI,CAAC,MAAI,GAAK,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;iBAClE;gBAAC,OAAO,EAAE,EAAE;oBACX,EAAE,CAAC,OAAO,GAAG,sBAAoB,GAAG,oBAAe,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAK,EAAE,CAAC,OAAS,CAAC;oBAC3F,MAAM,EAAE,CAAC;iBACV;YAEH,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC;QAEF,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAE3C,IAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,2BAAmB,EAAE,MAAM,CAAC,CAAC;QACnE,OAAO,CAAC,cAAc,CAAC,2BAAmB,uBACrC,SAAS,eACX,GAAG,IAAG,MAAM,QACZ,MAAM,CAAC,CAAC;;IACb,CAAC,CAAC;AACJ,CAAC;AApCD,4BAoCC;AAED,iCAAwC,GAAQ;IAC9C,IAAI,SAAS,GAAG,EAAE,CAAC;IAEnB,IAAI;QACF,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,2BAAmB,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;KACjE;IAAC,OAAO,CAAC,EAAE;KAEX;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAVD,0DAUC;AAED,gCAAuC,GAAQ;IAC7C,OAAO,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC;AACnD,CAAC;AAFD,wDAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apex-pub/convector-core-model",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Convector Model base class",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -50,12 +50,21 @@
|
|
|
50
50
|
"reflect-metadata": ">=0.1.12"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@apex-pub/convector-core-errors": "1.
|
|
54
|
-
"@apex-pub/convector-core-storage": "1.
|
|
53
|
+
"@apex-pub/convector-core-errors": "^1.5.0",
|
|
54
|
+
"@apex-pub/convector-core-storage": "^1.5.0",
|
|
55
|
+
"tslib": "^1.9.0",
|
|
55
56
|
"window-or-global": "^1.0.1",
|
|
56
57
|
"yup": "^0.26.10"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"
|
|
60
|
+
"http-server": "^0.11.1",
|
|
61
|
+
"mocha": "^5.0.3",
|
|
62
|
+
"npm-scripts-watcher": "^1.0.2",
|
|
63
|
+
"reflect-metadata": "^0.1.12",
|
|
64
|
+
"rimraf": "^2.6.2",
|
|
65
|
+
"ts-node": "^6.0.3",
|
|
66
|
+
"tslint": "^5.9.1",
|
|
67
|
+
"typedoc": "^0.11.1",
|
|
68
|
+
"typescript": "2.8.3"
|
|
60
69
|
}
|
|
61
70
|
}
|