@byteluck-fe/model-driven-engine 2.2.7 → 2.2.11
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/dist/esm/common/ActionManager.js +114 -79
- package/dist/esm/common/DataManager.js +80 -39
- package/dist/esm/common/Engine.js +1106 -931
- package/dist/esm/common/OkWorker.js +121 -76
- package/dist/esm/common/Plugin.js +2 -2
- package/dist/esm/common/Runtime.js +61 -44
- package/dist/esm/common/Store.js +145 -113
- package/dist/esm/common/checkerValue.js +367 -292
- package/dist/esm/common/proxyState.js +11 -11
- package/dist/esm/plugins/CalcPlugin.js +405 -317
- package/dist/esm/plugins/ControlsEventPlugin.js +174 -135
- package/dist/esm/plugins/ES6ModulePlugin.js +77 -43
- package/dist/esm/plugins/LifecycleEventPlugin.js +134 -98
- package/dist/esm/plugins/StylePlugin.js +48 -15
- package/dist/index.umd.js +8 -8
- package/dist/types/common/Engine.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
2
|
if (len == null || len > arr.length) len = arr.length;
|
|
3
3
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
4
|
return arr2;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
7
|
if (Array.isArray(arr)) return arr;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function _assert_this_initialized(self) {
|
|
10
10
|
if (self === void 0) {
|
|
11
11
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
12
12
|
}
|
|
13
13
|
return self;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function _class_call_check(instance, Constructor) {
|
|
16
16
|
if (!(instance instanceof Constructor)) {
|
|
17
17
|
throw new TypeError("Cannot call a class as a function");
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function _defineProperties(target, props) {
|
|
21
|
+
for(var i = 0; i < props.length; i++){
|
|
22
|
+
var descriptor = props[i];
|
|
23
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
24
|
+
descriptor.configurable = true;
|
|
25
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
26
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
30
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
31
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
32
|
+
return Constructor;
|
|
33
|
+
}
|
|
34
|
+
function _define_property(obj, key, value) {
|
|
21
35
|
if (key in obj) {
|
|
22
36
|
Object.defineProperty(obj, key, {
|
|
23
37
|
value: value,
|
|
@@ -30,11 +44,11 @@ function _defineProperty(obj, key, value) {
|
|
|
30
44
|
}
|
|
31
45
|
return obj;
|
|
32
46
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
47
|
+
function _get_prototype_of(o) {
|
|
48
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
35
49
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
36
50
|
};
|
|
37
|
-
return
|
|
51
|
+
return _get_prototype_of(o);
|
|
38
52
|
}
|
|
39
53
|
function _inherits(subClass, superClass) {
|
|
40
54
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
@@ -47,7 +61,7 @@ function _inherits(subClass, superClass) {
|
|
|
47
61
|
configurable: true
|
|
48
62
|
}
|
|
49
63
|
});
|
|
50
|
-
if (superClass)
|
|
64
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
51
65
|
}
|
|
52
66
|
function _instanceof(left, right) {
|
|
53
67
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
@@ -56,7 +70,7 @@ function _instanceof(left, right) {
|
|
|
56
70
|
return left instanceof right;
|
|
57
71
|
}
|
|
58
72
|
}
|
|
59
|
-
function
|
|
73
|
+
function _iterable_to_array_limit(arr, i) {
|
|
60
74
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
61
75
|
if (_i == null) return;
|
|
62
76
|
var _arr = [];
|
|
@@ -80,10 +94,10 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
80
94
|
}
|
|
81
95
|
return _arr;
|
|
82
96
|
}
|
|
83
|
-
function
|
|
97
|
+
function _non_iterable_rest() {
|
|
84
98
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
85
99
|
}
|
|
86
|
-
function
|
|
100
|
+
function _object_spread(target) {
|
|
87
101
|
for(var i = 1; i < arguments.length; i++){
|
|
88
102
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
89
103
|
var ownKeys = Object.keys(source);
|
|
@@ -93,40 +107,40 @@ function _objectSpread(target) {
|
|
|
93
107
|
}));
|
|
94
108
|
}
|
|
95
109
|
ownKeys.forEach(function(key) {
|
|
96
|
-
|
|
110
|
+
_define_property(target, key, source[key]);
|
|
97
111
|
});
|
|
98
112
|
}
|
|
99
113
|
return target;
|
|
100
114
|
}
|
|
101
|
-
function
|
|
102
|
-
if (call && (
|
|
115
|
+
function _possible_constructor_return(self, call) {
|
|
116
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
103
117
|
return call;
|
|
104
118
|
}
|
|
105
|
-
return
|
|
119
|
+
return _assert_this_initialized(self);
|
|
106
120
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
121
|
+
function _set_prototype_of(o, p) {
|
|
122
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
109
123
|
o.__proto__ = p;
|
|
110
124
|
return o;
|
|
111
125
|
};
|
|
112
|
-
return
|
|
126
|
+
return _set_prototype_of(o, p);
|
|
113
127
|
}
|
|
114
|
-
function
|
|
115
|
-
return
|
|
128
|
+
function _sliced_to_array(arr, i) {
|
|
129
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
116
130
|
}
|
|
117
|
-
|
|
131
|
+
function _type_of(obj) {
|
|
118
132
|
"@swc/helpers - typeof";
|
|
119
133
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
120
|
-
}
|
|
121
|
-
function
|
|
134
|
+
}
|
|
135
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
122
136
|
if (!o) return;
|
|
123
|
-
if (typeof o === "string") return
|
|
137
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
124
138
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
125
139
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
126
140
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
127
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
141
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
128
142
|
}
|
|
129
|
-
function
|
|
143
|
+
function _is_native_reflect_construct() {
|
|
130
144
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
131
145
|
if (Reflect.construct.sham) return false;
|
|
132
146
|
if (typeof Proxy === "function") return true;
|
|
@@ -137,17 +151,17 @@ function _isNativeReflectConstruct() {
|
|
|
137
151
|
return false;
|
|
138
152
|
}
|
|
139
153
|
}
|
|
140
|
-
function
|
|
141
|
-
var hasNativeReflectConstruct =
|
|
154
|
+
function _create_super(Derived) {
|
|
155
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
142
156
|
return function _createSuperInternal() {
|
|
143
|
-
var Super =
|
|
157
|
+
var Super = _get_prototype_of(Derived), result;
|
|
144
158
|
if (hasNativeReflectConstruct) {
|
|
145
|
-
var NewTarget =
|
|
159
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
146
160
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
147
161
|
} else {
|
|
148
162
|
result = Super.apply(this, arguments);
|
|
149
163
|
}
|
|
150
|
-
return
|
|
164
|
+
return _possible_constructor_return(this, result);
|
|
151
165
|
};
|
|
152
166
|
}
|
|
153
167
|
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from "@byteluck-fe/model-driven-shared";
|
|
@@ -155,353 +169,414 @@ import { AddressValue, AmountValue, CalcValue, RangeDateValue } from "@byteluck-
|
|
|
155
169
|
import { camelizeKeys } from "humps";
|
|
156
170
|
var ValueChecker = function ValueChecker() {
|
|
157
171
|
"use strict";
|
|
158
|
-
|
|
172
|
+
_class_call_check(this, ValueChecker);
|
|
159
173
|
};
|
|
160
174
|
var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
161
175
|
"use strict";
|
|
162
176
|
_inherits(StringValueChecker, ValueChecker);
|
|
163
|
-
var _super =
|
|
177
|
+
var _super = _create_super(StringValueChecker);
|
|
164
178
|
function StringValueChecker() {
|
|
165
|
-
|
|
179
|
+
_class_call_check(this, StringValueChecker);
|
|
166
180
|
return _super.apply(this, arguments);
|
|
167
181
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
182
|
+
_create_class(StringValueChecker, [
|
|
183
|
+
{
|
|
184
|
+
key: "validate",
|
|
185
|
+
value: function validate(value) {
|
|
186
|
+
return isString(value);
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
key: "transform",
|
|
191
|
+
value: function transform(value) {
|
|
192
|
+
if (value === null || value === undefined) {
|
|
193
|
+
return "";
|
|
194
|
+
}
|
|
195
|
+
if (!isPlainObject(value) && !isFunction(value)) {
|
|
196
|
+
return String(value);
|
|
197
|
+
}
|
|
198
|
+
if (isObject(value)) {
|
|
199
|
+
return JSON.stringify(value);
|
|
200
|
+
}
|
|
201
|
+
throw "".concat(value, " is not a string");
|
|
202
|
+
}
|
|
181
203
|
}
|
|
182
|
-
|
|
183
|
-
};
|
|
204
|
+
]);
|
|
184
205
|
return StringValueChecker;
|
|
185
206
|
}(ValueChecker);
|
|
186
207
|
var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
187
208
|
"use strict";
|
|
188
209
|
_inherits(NumberValueChecker, ValueChecker);
|
|
189
|
-
var _super =
|
|
210
|
+
var _super = _create_super(NumberValueChecker);
|
|
190
211
|
function NumberValueChecker() {
|
|
191
|
-
|
|
212
|
+
_class_call_check(this, NumberValueChecker);
|
|
192
213
|
return _super.apply(this, arguments);
|
|
193
214
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
215
|
+
_create_class(NumberValueChecker, [
|
|
216
|
+
{
|
|
217
|
+
// 数字类型允许是空字符串,用于置空数据
|
|
218
|
+
key: "validate",
|
|
219
|
+
value: function validate(value) {
|
|
220
|
+
return isNumber(value) || value === "";
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
key: "transform",
|
|
225
|
+
value: function transform(value) {
|
|
226
|
+
if (value === null || value === undefined) {
|
|
227
|
+
return "";
|
|
228
|
+
}
|
|
229
|
+
var newValue = !isPlainObject(value) && !isFunction(value) ? Number(value) : undefined;
|
|
230
|
+
if (!Number.isNaN(newValue) && newValue !== undefined) {
|
|
231
|
+
return newValue;
|
|
232
|
+
}
|
|
233
|
+
throw "".concat(value, " is not a number");
|
|
234
|
+
}
|
|
206
235
|
}
|
|
207
|
-
|
|
208
|
-
};
|
|
236
|
+
]);
|
|
209
237
|
return NumberValueChecker;
|
|
210
238
|
}(ValueChecker);
|
|
211
239
|
var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
212
240
|
"use strict";
|
|
213
241
|
_inherits(StringArrayValueChecker, ValueChecker);
|
|
214
|
-
var _super =
|
|
242
|
+
var _super = _create_super(StringArrayValueChecker);
|
|
215
243
|
function StringArrayValueChecker() {
|
|
216
|
-
|
|
244
|
+
_class_call_check(this, StringArrayValueChecker);
|
|
217
245
|
return _super.apply(this, arguments);
|
|
218
246
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
247
|
+
_create_class(StringArrayValueChecker, [
|
|
248
|
+
{
|
|
249
|
+
key: "validate",
|
|
250
|
+
value: function validate(value) {
|
|
251
|
+
return isStringArray(value);
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
key: "transform",
|
|
256
|
+
value: function transform(value) {
|
|
257
|
+
var getStringValueArray = function getStringValueArray(value) {
|
|
258
|
+
return value.map(function(item) {
|
|
259
|
+
return !item ? "" : String(item);
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
if (value === undefined || value === null) {
|
|
263
|
+
return [];
|
|
264
|
+
}
|
|
265
|
+
if (isArray(value)) {
|
|
266
|
+
return getStringValueArray(value);
|
|
267
|
+
}
|
|
268
|
+
if (isString(value) && isJSONArray(value)) {
|
|
269
|
+
try {
|
|
270
|
+
var newValue = JSON.parse(value);
|
|
271
|
+
if (Array.isArray(newValue)) {
|
|
272
|
+
return getStringValueArray(newValue);
|
|
273
|
+
}
|
|
274
|
+
} catch (e) {}
|
|
240
275
|
}
|
|
241
|
-
|
|
276
|
+
return [
|
|
277
|
+
String(value)
|
|
278
|
+
];
|
|
279
|
+
}
|
|
242
280
|
}
|
|
243
|
-
|
|
244
|
-
String(value)
|
|
245
|
-
];
|
|
246
|
-
};
|
|
281
|
+
]);
|
|
247
282
|
return StringArrayValueChecker;
|
|
248
283
|
}(ValueChecker);
|
|
249
284
|
var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
250
285
|
"use strict";
|
|
251
286
|
_inherits(NumberArrayValueChecker, ValueChecker);
|
|
252
|
-
var _super =
|
|
287
|
+
var _super = _create_super(NumberArrayValueChecker);
|
|
253
288
|
function NumberArrayValueChecker() {
|
|
254
|
-
|
|
289
|
+
_class_call_check(this, NumberArrayValueChecker);
|
|
255
290
|
return _super.apply(this, arguments);
|
|
256
291
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
try {
|
|
277
|
-
var newValue = JSON.parse(value);
|
|
278
|
-
if (isArray(newValue)) {
|
|
279
|
-
return getNumberValueArray(newValue);
|
|
292
|
+
_create_class(NumberArrayValueChecker, [
|
|
293
|
+
{
|
|
294
|
+
key: "validate",
|
|
295
|
+
value: function validate(value) {
|
|
296
|
+
return isNumberAndEmptyStringArray(value);
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
key: "transform",
|
|
301
|
+
value: function transform(value) {
|
|
302
|
+
var getNumberValueArray = function getNumberValueArray(value) {
|
|
303
|
+
return value.map(function(item) {
|
|
304
|
+
return !item && item !== 0 ? "" : Number(item);
|
|
305
|
+
}).filter(function(item) {
|
|
306
|
+
return item === "" || !Number.isNaN(item);
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
if (value === undefined || value === null) {
|
|
310
|
+
return [];
|
|
280
311
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
312
|
+
if (isArray(value)) {
|
|
313
|
+
return getNumberValueArray(value);
|
|
314
|
+
}
|
|
315
|
+
if (isString(value) && isJSONArray(value)) {
|
|
316
|
+
try {
|
|
317
|
+
var newValue = JSON.parse(value);
|
|
318
|
+
if (isArray(newValue)) {
|
|
319
|
+
return getNumberValueArray(newValue);
|
|
320
|
+
}
|
|
321
|
+
} catch (e) {}
|
|
322
|
+
}
|
|
323
|
+
var newValue1 = Number(value);
|
|
324
|
+
if (Number.isNaN(newValue1)) {
|
|
325
|
+
throw "".concat(value, " is not a number array");
|
|
326
|
+
}
|
|
327
|
+
return [
|
|
328
|
+
newValue1
|
|
329
|
+
];
|
|
330
|
+
}
|
|
286
331
|
}
|
|
287
|
-
|
|
288
|
-
newValue1
|
|
289
|
-
];
|
|
290
|
-
};
|
|
332
|
+
]);
|
|
291
333
|
return NumberArrayValueChecker;
|
|
292
334
|
}(ValueChecker);
|
|
293
335
|
var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
294
336
|
"use strict";
|
|
295
337
|
_inherits(MoneyValueChecker, ValueChecker);
|
|
296
|
-
var _super =
|
|
338
|
+
var _super = _create_super(MoneyValueChecker);
|
|
297
339
|
function MoneyValueChecker() {
|
|
298
|
-
|
|
340
|
+
_class_call_check(this, MoneyValueChecker);
|
|
299
341
|
return _super.apply(this, arguments);
|
|
300
342
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (value === undefined || value === null || value === "") {
|
|
307
|
-
return new AmountValue({
|
|
308
|
-
currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
var result;
|
|
312
|
-
if (isPlainObject(value)) {
|
|
313
|
-
result = new AmountValue(_objectSpread({}, oldValue, value));
|
|
314
|
-
}
|
|
315
|
-
if (isString(value) && isJSONObject(value)) {
|
|
316
|
-
try {
|
|
317
|
-
var newValue = JSON.parse(value);
|
|
318
|
-
result = new AmountValue(_objectSpread({}, oldValue, newValue));
|
|
319
|
-
} catch (e) {}
|
|
320
|
-
}
|
|
321
|
-
if (result) {
|
|
322
|
-
var numberChecker = new NumberValueChecker();
|
|
323
|
-
var stringChecker = new StringValueChecker();
|
|
324
|
-
if (!numberChecker.validate(result.amount)) {
|
|
325
|
-
result.amount = numberChecker.transform(result.amount);
|
|
343
|
+
_create_class(MoneyValueChecker, [
|
|
344
|
+
{
|
|
345
|
+
key: "validate",
|
|
346
|
+
value: function validate(value) {
|
|
347
|
+
return _instanceof(value, AmountValue) || isPlainObject(value) && "amount" in value && isNumber(value.amount) && "currency" in value && isString(value.currency);
|
|
326
348
|
}
|
|
327
|
-
|
|
328
|
-
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
key: "transform",
|
|
352
|
+
value: function transform(value, oldValue) {
|
|
353
|
+
if (value === undefined || value === null || value === "") {
|
|
354
|
+
return new AmountValue({
|
|
355
|
+
currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
var result;
|
|
359
|
+
if (isPlainObject(value)) {
|
|
360
|
+
result = new AmountValue(_object_spread({}, oldValue, value));
|
|
361
|
+
}
|
|
362
|
+
if (isString(value) && isJSONObject(value)) {
|
|
363
|
+
try {
|
|
364
|
+
var newValue = JSON.parse(value);
|
|
365
|
+
result = new AmountValue(_object_spread({}, oldValue, newValue));
|
|
366
|
+
} catch (e) {}
|
|
367
|
+
}
|
|
368
|
+
if (result) {
|
|
369
|
+
var numberChecker = new NumberValueChecker();
|
|
370
|
+
var stringChecker = new StringValueChecker();
|
|
371
|
+
if (!numberChecker.validate(result.amount)) {
|
|
372
|
+
result.amount = numberChecker.transform(result.amount);
|
|
373
|
+
}
|
|
374
|
+
if (!stringChecker.validate(result.currency)) {
|
|
375
|
+
result.currency = stringChecker.transform(result.currency);
|
|
376
|
+
}
|
|
377
|
+
return result;
|
|
378
|
+
}
|
|
379
|
+
throw "".concat(value, " is not a { amount: number, currency: string } object");
|
|
329
380
|
}
|
|
330
|
-
return result;
|
|
331
381
|
}
|
|
332
|
-
|
|
333
|
-
};
|
|
382
|
+
]);
|
|
334
383
|
return MoneyValueChecker;
|
|
335
384
|
}(ValueChecker);
|
|
336
385
|
var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
337
386
|
"use strict";
|
|
338
387
|
_inherits(TimeScopeValueChecker, ValueChecker);
|
|
339
|
-
var _super =
|
|
388
|
+
var _super = _create_super(TimeScopeValueChecker);
|
|
340
389
|
function TimeScopeValueChecker() {
|
|
341
|
-
|
|
390
|
+
_class_call_check(this, TimeScopeValueChecker);
|
|
342
391
|
return _super.apply(this, arguments);
|
|
343
392
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
if (value === undefined || value === null || value === "") {
|
|
350
|
-
return new RangeDateValue();
|
|
351
|
-
}
|
|
352
|
-
var result;
|
|
353
|
-
if (isPlainObject(value)) {
|
|
354
|
-
result = new RangeDateValue(_objectSpread({}, oldValue, value));
|
|
355
|
-
}
|
|
356
|
-
if (isString(value) && isJSONObject(value)) {
|
|
357
|
-
try {
|
|
358
|
-
var newValue = JSON.parse(value);
|
|
359
|
-
result = new RangeDateValue(_objectSpread({}, oldValue, newValue));
|
|
360
|
-
} catch (e) {}
|
|
361
|
-
}
|
|
362
|
-
if (result) {
|
|
363
|
-
var stringChecker = new StringValueChecker();
|
|
364
|
-
if (!stringChecker.validate(result.min)) {
|
|
365
|
-
result.min = stringChecker.transform(result.min);
|
|
393
|
+
_create_class(TimeScopeValueChecker, [
|
|
394
|
+
{
|
|
395
|
+
key: "validate",
|
|
396
|
+
value: function validate(value) {
|
|
397
|
+
return _instanceof(value, RangeDateValue) || isPlainObject(value) && "min" in value && isString(value.min) && "max" in value && isString(value.max);
|
|
366
398
|
}
|
|
367
|
-
|
|
368
|
-
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
key: "transform",
|
|
402
|
+
value: function transform(value, oldValue) {
|
|
403
|
+
if (value === undefined || value === null || value === "") {
|
|
404
|
+
return new RangeDateValue();
|
|
405
|
+
}
|
|
406
|
+
var result;
|
|
407
|
+
if (isPlainObject(value)) {
|
|
408
|
+
result = new RangeDateValue(_object_spread({}, oldValue, value));
|
|
409
|
+
}
|
|
410
|
+
if (isString(value) && isJSONObject(value)) {
|
|
411
|
+
try {
|
|
412
|
+
var newValue = JSON.parse(value);
|
|
413
|
+
result = new RangeDateValue(_object_spread({}, oldValue, newValue));
|
|
414
|
+
} catch (e) {}
|
|
415
|
+
}
|
|
416
|
+
if (result) {
|
|
417
|
+
var stringChecker = new StringValueChecker();
|
|
418
|
+
if (!stringChecker.validate(result.min)) {
|
|
419
|
+
result.min = stringChecker.transform(result.min);
|
|
420
|
+
}
|
|
421
|
+
if (!stringChecker.validate(result.max)) {
|
|
422
|
+
result.max = stringChecker.transform(result.max);
|
|
423
|
+
}
|
|
424
|
+
return result;
|
|
425
|
+
}
|
|
426
|
+
throw "".concat(value, " is not a { min: string, max: string } object");
|
|
369
427
|
}
|
|
370
|
-
return result;
|
|
371
428
|
}
|
|
372
|
-
|
|
373
|
-
};
|
|
429
|
+
]);
|
|
374
430
|
return TimeScopeValueChecker;
|
|
375
431
|
}(ValueChecker);
|
|
376
432
|
var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
377
433
|
"use strict";
|
|
378
434
|
_inherits(CalcValueChecker, ValueChecker);
|
|
379
|
-
var _super =
|
|
435
|
+
var _super = _create_super(CalcValueChecker);
|
|
380
436
|
function CalcValueChecker() {
|
|
381
|
-
|
|
437
|
+
_class_call_check(this, CalcValueChecker);
|
|
382
438
|
return _super.apply(this, arguments);
|
|
383
439
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
if (value === undefined || value === null || value === "") {
|
|
390
|
-
return new CalcValue({
|
|
391
|
-
unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
var result;
|
|
395
|
-
if (isPlainObject(value)) {
|
|
396
|
-
result = new CalcValue(_objectSpread({}, oldValue, value));
|
|
397
|
-
}
|
|
398
|
-
if (isString(value) && isJSONObject(value)) {
|
|
399
|
-
try {
|
|
400
|
-
var newValue = JSON.parse(value);
|
|
401
|
-
result = new CalcValue(_objectSpread({}, oldValue, newValue));
|
|
402
|
-
} catch (e) {}
|
|
403
|
-
}
|
|
404
|
-
if (result) {
|
|
405
|
-
var numberChecker = new NumberValueChecker();
|
|
406
|
-
var stringChecker = new StringValueChecker();
|
|
407
|
-
if (!numberChecker.validate(result.result)) {
|
|
408
|
-
result.result = numberChecker.transform(result.result);
|
|
440
|
+
_create_class(CalcValueChecker, [
|
|
441
|
+
{
|
|
442
|
+
key: "validate",
|
|
443
|
+
value: function validate(value) {
|
|
444
|
+
return _instanceof(value, CalcValue) || isPlainObject(value) && "result" in value && isNumber(value.result) && "unit" in value && isString(value.unit);
|
|
409
445
|
}
|
|
410
|
-
|
|
411
|
-
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
key: "transform",
|
|
449
|
+
value: function transform(value, oldValue) {
|
|
450
|
+
if (value === undefined || value === null || value === "") {
|
|
451
|
+
return new CalcValue({
|
|
452
|
+
unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
var result;
|
|
456
|
+
if (isPlainObject(value)) {
|
|
457
|
+
result = new CalcValue(_object_spread({}, oldValue, value));
|
|
458
|
+
}
|
|
459
|
+
if (isString(value) && isJSONObject(value)) {
|
|
460
|
+
try {
|
|
461
|
+
var newValue = JSON.parse(value);
|
|
462
|
+
result = new CalcValue(_object_spread({}, oldValue, newValue));
|
|
463
|
+
} catch (e) {}
|
|
464
|
+
}
|
|
465
|
+
if (result) {
|
|
466
|
+
var numberChecker = new NumberValueChecker();
|
|
467
|
+
var stringChecker = new StringValueChecker();
|
|
468
|
+
if (!numberChecker.validate(result.result)) {
|
|
469
|
+
result.result = numberChecker.transform(result.result);
|
|
470
|
+
}
|
|
471
|
+
if (!stringChecker.validate(result.unit)) {
|
|
472
|
+
result.unit = stringChecker.transform(result.unit);
|
|
473
|
+
}
|
|
474
|
+
return result;
|
|
475
|
+
}
|
|
476
|
+
throw "".concat(value, " is not a { result: string, unit: string } object");
|
|
412
477
|
}
|
|
413
|
-
return result;
|
|
414
478
|
}
|
|
415
|
-
|
|
416
|
-
};
|
|
479
|
+
]);
|
|
417
480
|
return CalcValueChecker;
|
|
418
481
|
}(ValueChecker);
|
|
419
482
|
var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
420
483
|
"use strict";
|
|
421
484
|
_inherits(AddressValueChecker, ValueChecker);
|
|
422
|
-
var _super =
|
|
485
|
+
var _super = _create_super(AddressValueChecker);
|
|
423
486
|
function AddressValueChecker() {
|
|
424
|
-
|
|
487
|
+
_class_call_check(this, AddressValueChecker);
|
|
425
488
|
return _super.apply(this, arguments);
|
|
426
489
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (value === undefined || value === null || value === "") {
|
|
433
|
-
return new AddressValue();
|
|
434
|
-
}
|
|
435
|
-
var result;
|
|
436
|
-
if (isPlainObject(value)) {
|
|
437
|
-
result = new AddressValue(_objectSpread({}, oldValue, camelizeKeys(value)));
|
|
438
|
-
}
|
|
439
|
-
if (isString(value) && isJSONObject(value)) {
|
|
440
|
-
try {
|
|
441
|
-
var newValue = JSON.parse(value);
|
|
442
|
-
result = new AddressValue(_objectSpread({}, oldValue, camelizeKeys(newValue)));
|
|
443
|
-
} catch (e) {}
|
|
444
|
-
}
|
|
445
|
-
if (result) {
|
|
446
|
-
var stringChecker = new StringValueChecker();
|
|
447
|
-
if (!stringChecker.validate(result.city)) {
|
|
448
|
-
result.city = stringChecker.transform(result.city);
|
|
449
|
-
}
|
|
450
|
-
if (!stringChecker.validate(result.district)) {
|
|
451
|
-
result.district = stringChecker.transform(result.district);
|
|
490
|
+
_create_class(AddressValueChecker, [
|
|
491
|
+
{
|
|
492
|
+
key: "validate",
|
|
493
|
+
value: function validate(value) {
|
|
494
|
+
return _instanceof(value, AddressValue);
|
|
452
495
|
}
|
|
453
|
-
|
|
454
|
-
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
key: "transform",
|
|
499
|
+
value: function transform(value, oldValue) {
|
|
500
|
+
if (value === undefined || value === null || value === "") {
|
|
501
|
+
return new AddressValue();
|
|
502
|
+
}
|
|
503
|
+
var result;
|
|
504
|
+
if (isPlainObject(value)) {
|
|
505
|
+
result = new AddressValue(_object_spread({}, oldValue, camelizeKeys(value)));
|
|
506
|
+
}
|
|
507
|
+
if (isString(value) && isJSONObject(value)) {
|
|
508
|
+
try {
|
|
509
|
+
var newValue = JSON.parse(value);
|
|
510
|
+
result = new AddressValue(_object_spread({}, oldValue, camelizeKeys(newValue)));
|
|
511
|
+
} catch (e) {}
|
|
512
|
+
}
|
|
513
|
+
if (result) {
|
|
514
|
+
var stringChecker = new StringValueChecker();
|
|
515
|
+
if (!stringChecker.validate(result.city)) {
|
|
516
|
+
result.city = stringChecker.transform(result.city);
|
|
517
|
+
}
|
|
518
|
+
if (!stringChecker.validate(result.district)) {
|
|
519
|
+
result.district = stringChecker.transform(result.district);
|
|
520
|
+
}
|
|
521
|
+
if (!stringChecker.validate(result.province)) {
|
|
522
|
+
result.province = stringChecker.transform(result.province);
|
|
523
|
+
}
|
|
524
|
+
return result;
|
|
525
|
+
}
|
|
526
|
+
throw "".concat(value, " is not a { city: string, district: string, province: string } object");
|
|
455
527
|
}
|
|
456
|
-
return result;
|
|
457
528
|
}
|
|
458
|
-
|
|
459
|
-
};
|
|
529
|
+
]);
|
|
460
530
|
return AddressValueChecker;
|
|
461
531
|
}(ValueChecker);
|
|
462
532
|
var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
463
533
|
"use strict";
|
|
464
534
|
function ValueCheckerFactory() {
|
|
465
|
-
|
|
535
|
+
_class_call_check(this, ValueCheckerFactory);
|
|
466
536
|
}
|
|
467
|
-
ValueCheckerFactory
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
537
|
+
_create_class(ValueCheckerFactory, null, [
|
|
538
|
+
{
|
|
539
|
+
key: "getValueChecker",
|
|
540
|
+
value: function getValueChecker(fieldType) {
|
|
541
|
+
var checker;
|
|
542
|
+
switch(fieldType){
|
|
543
|
+
case FieldTypes.VARCHAR:
|
|
544
|
+
case FieldTypes.TIMESTAMP:
|
|
545
|
+
case FieldTypes.TEXT:
|
|
546
|
+
case FieldTypes.RELATION:
|
|
547
|
+
case FieldTypes.AUTO_NUMBER:
|
|
548
|
+
checker = new StringValueChecker();
|
|
549
|
+
break;
|
|
550
|
+
case FieldTypes.DECIMAL:
|
|
551
|
+
checker = new NumberValueChecker();
|
|
552
|
+
break;
|
|
553
|
+
case FieldTypes.EMPLOYEES:
|
|
554
|
+
case FieldTypes.DEPARTMENTS:
|
|
555
|
+
case FieldTypes.IMAGE:
|
|
556
|
+
case FieldTypes.FILE:
|
|
557
|
+
case FieldTypes.ARRAY:
|
|
558
|
+
checker = new StringArrayValueChecker();
|
|
559
|
+
break;
|
|
560
|
+
case FieldTypes.MONEY:
|
|
561
|
+
checker = new MoneyValueChecker();
|
|
562
|
+
break;
|
|
563
|
+
case FieldTypes.TIMESCOPE:
|
|
564
|
+
checker = new TimeScopeValueChecker();
|
|
565
|
+
break;
|
|
566
|
+
case FieldTypes.CALC:
|
|
567
|
+
checker = new CalcValueChecker();
|
|
568
|
+
break;
|
|
569
|
+
case FieldTypes.DECIMAL_RANGE:
|
|
570
|
+
checker = new NumberArrayValueChecker();
|
|
571
|
+
break;
|
|
572
|
+
case FieldTypes.ADDRESS:
|
|
573
|
+
checker = new AddressValueChecker();
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
return checker;
|
|
577
|
+
}
|
|
502
578
|
}
|
|
503
|
-
|
|
504
|
-
};
|
|
579
|
+
]);
|
|
505
580
|
return ValueCheckerFactory;
|
|
506
581
|
}();
|
|
507
582
|
function getFieldTypeFromKey(key) {
|
|
@@ -539,7 +614,7 @@ export function checkerValue(fieldType, key, value, oldValue) {
|
|
|
539
614
|
}
|
|
540
615
|
export function checkerSubtableValue(fieldTypeMap, value, emptyValue) {
|
|
541
616
|
return Object.entries(fieldTypeMap).reduce(function(result, param) {
|
|
542
|
-
var _param =
|
|
617
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], fieldType = _param[1];
|
|
543
618
|
var nowValue = value[key];
|
|
544
619
|
result[key] = checkerValue(fieldType, key, nowValue, emptyValue[key]);
|
|
545
620
|
return result;
|