@byteluck-fe/model-driven-engine 2.7.0-alpha.2 → 2.7.0-alpha.20
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 +98 -63
- package/dist/esm/common/DataManager.js +75 -34
- package/dist/esm/common/Engine.js +1151 -936
- package/dist/esm/common/OkWorker.js +119 -74
- package/dist/esm/common/Runtime.js +43 -22
- package/dist/esm/common/Store.js +159 -129
- package/dist/esm/common/checkerValue.js +330 -248
- package/dist/esm/common/proxyState.js +1 -1
- package/dist/esm/plugins/CalcPlugin.js +393 -309
- package/dist/esm/plugins/ControlsEventPlugin.js +169 -130
- package/dist/esm/plugins/ES6ModulePlugin.js +65 -31
- package/dist/esm/plugins/LifecycleEventPlugin.js +119 -83
- package/dist/esm/plugins/StylePlugin.js +46 -13
- package/dist/esm/utils/runtimeUtils.js +2 -1
- package/dist/index.umd.js +11 -11
- package/dist/types/common/Engine.d.ts +1 -1
- package/package.json +4 -4
|
@@ -17,6 +17,20 @@ function _classCallCheck(instance, Constructor) {
|
|
|
17
17
|
throw new TypeError("Cannot call a class as a function");
|
|
18
18
|
}
|
|
19
19
|
}
|
|
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 _createClass(Constructor, protoProps, staticProps) {
|
|
30
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
31
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
32
|
+
return Constructor;
|
|
33
|
+
}
|
|
20
34
|
function _defineProperty(obj, key, value) {
|
|
21
35
|
if (key in obj) {
|
|
22
36
|
Object.defineProperty(obj, key, {
|
|
@@ -49,13 +63,6 @@ function _inherits(subClass, superClass) {
|
|
|
49
63
|
});
|
|
50
64
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
51
65
|
}
|
|
52
|
-
function _instanceof(left, right) {
|
|
53
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
54
|
-
return !!right[Symbol.hasInstance](left);
|
|
55
|
-
} else {
|
|
56
|
-
return left instanceof right;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
66
|
function _iterableToArrayLimit(arr, i) {
|
|
60
67
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
61
68
|
if (_i == null) return;
|
|
@@ -165,22 +172,29 @@ var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
165
172
|
_classCallCheck(this, StringValueChecker);
|
|
166
173
|
return _super.apply(this, arguments);
|
|
167
174
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
175
|
+
_createClass(StringValueChecker, [
|
|
176
|
+
{
|
|
177
|
+
key: "validate",
|
|
178
|
+
value: function validate(value) {
|
|
179
|
+
return isString(value);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
key: "transform",
|
|
184
|
+
value: function transform(value) {
|
|
185
|
+
if (value === null || value === undefined) {
|
|
186
|
+
return "";
|
|
187
|
+
}
|
|
188
|
+
if (!isPlainObject(value) && !isFunction(value)) {
|
|
189
|
+
return String(value);
|
|
190
|
+
}
|
|
191
|
+
if (isObject(value)) {
|
|
192
|
+
return JSON.stringify(value);
|
|
193
|
+
}
|
|
194
|
+
throw "".concat(value, " is not a string");
|
|
195
|
+
}
|
|
181
196
|
}
|
|
182
|
-
|
|
183
|
-
};
|
|
197
|
+
]);
|
|
184
198
|
return StringValueChecker;
|
|
185
199
|
}(ValueChecker);
|
|
186
200
|
var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
@@ -191,21 +205,28 @@ var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
191
205
|
_classCallCheck(this, NumberValueChecker);
|
|
192
206
|
return _super.apply(this, arguments);
|
|
193
207
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
208
|
+
_createClass(NumberValueChecker, [
|
|
209
|
+
{
|
|
210
|
+
// 数字类型允许是空字符串,用于置空数据
|
|
211
|
+
key: "validate",
|
|
212
|
+
value: function validate(value) {
|
|
213
|
+
return isNumber(value) || value === "";
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
key: "transform",
|
|
218
|
+
value: function transform(value) {
|
|
219
|
+
if (value === null || value === undefined) {
|
|
220
|
+
return "";
|
|
221
|
+
}
|
|
222
|
+
var newValue = !isPlainObject(value) && !isFunction(value) ? Number(value) : undefined;
|
|
223
|
+
if (!Number.isNaN(newValue) && newValue !== undefined) {
|
|
224
|
+
return newValue;
|
|
225
|
+
}
|
|
226
|
+
throw "".concat(value, " is not a number");
|
|
227
|
+
}
|
|
206
228
|
}
|
|
207
|
-
|
|
208
|
-
};
|
|
229
|
+
]);
|
|
209
230
|
return NumberValueChecker;
|
|
210
231
|
}(ValueChecker);
|
|
211
232
|
var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
@@ -216,34 +237,41 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
216
237
|
_classCallCheck(this, StringArrayValueChecker);
|
|
217
238
|
return _super.apply(this, arguments);
|
|
218
239
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
+
_createClass(StringArrayValueChecker, [
|
|
241
|
+
{
|
|
242
|
+
key: "validate",
|
|
243
|
+
value: function validate(value) {
|
|
244
|
+
return isStringArray(value);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
key: "transform",
|
|
249
|
+
value: function transform(value) {
|
|
250
|
+
var getStringValueArray = function getStringValueArray(value) {
|
|
251
|
+
return value.map(function(item) {
|
|
252
|
+
return !item ? "" : String(item);
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
if (value === undefined || value === null) {
|
|
256
|
+
return [];
|
|
257
|
+
}
|
|
258
|
+
if (isArray(value)) {
|
|
259
|
+
return getStringValueArray(value);
|
|
260
|
+
}
|
|
261
|
+
if (isString(value) && isJSONArray(value)) {
|
|
262
|
+
try {
|
|
263
|
+
var newValue = JSON.parse(value);
|
|
264
|
+
if (Array.isArray(newValue)) {
|
|
265
|
+
return getStringValueArray(newValue);
|
|
266
|
+
}
|
|
267
|
+
} catch (e) {}
|
|
240
268
|
}
|
|
241
|
-
|
|
269
|
+
return [
|
|
270
|
+
String(value)
|
|
271
|
+
];
|
|
272
|
+
}
|
|
242
273
|
}
|
|
243
|
-
|
|
244
|
-
String(value)
|
|
245
|
-
];
|
|
246
|
-
};
|
|
274
|
+
]);
|
|
247
275
|
return StringArrayValueChecker;
|
|
248
276
|
}(ValueChecker);
|
|
249
277
|
var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
@@ -254,40 +282,47 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
254
282
|
_classCallCheck(this, NumberArrayValueChecker);
|
|
255
283
|
return _super.apply(this, arguments);
|
|
256
284
|
}
|
|
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);
|
|
285
|
+
_createClass(NumberArrayValueChecker, [
|
|
286
|
+
{
|
|
287
|
+
key: "validate",
|
|
288
|
+
value: function validate(value) {
|
|
289
|
+
return isNumberAndEmptyStringArray(value);
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
key: "transform",
|
|
294
|
+
value: function transform(value) {
|
|
295
|
+
var getNumberValueArray = function getNumberValueArray(value) {
|
|
296
|
+
return value.map(function(item) {
|
|
297
|
+
return !item && item !== 0 ? "" : Number(item);
|
|
298
|
+
}).filter(function(item) {
|
|
299
|
+
return item === "" || !Number.isNaN(item);
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
if (value === undefined || value === null) {
|
|
303
|
+
return [];
|
|
280
304
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
305
|
+
if (isArray(value)) {
|
|
306
|
+
return getNumberValueArray(value);
|
|
307
|
+
}
|
|
308
|
+
if (isString(value) && isJSONArray(value)) {
|
|
309
|
+
try {
|
|
310
|
+
var newValue = JSON.parse(value);
|
|
311
|
+
if (isArray(newValue)) {
|
|
312
|
+
return getNumberValueArray(newValue);
|
|
313
|
+
}
|
|
314
|
+
} catch (e) {}
|
|
315
|
+
}
|
|
316
|
+
var newValue1 = Number(value);
|
|
317
|
+
if (Number.isNaN(newValue1)) {
|
|
318
|
+
throw "".concat(value, " is not a number array");
|
|
319
|
+
}
|
|
320
|
+
return [
|
|
321
|
+
newValue1
|
|
322
|
+
];
|
|
323
|
+
}
|
|
286
324
|
}
|
|
287
|
-
|
|
288
|
-
newValue1
|
|
289
|
-
];
|
|
290
|
-
};
|
|
325
|
+
]);
|
|
291
326
|
return NumberArrayValueChecker;
|
|
292
327
|
}(ValueChecker);
|
|
293
328
|
var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
@@ -298,39 +333,47 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
298
333
|
_classCallCheck(this, MoneyValueChecker);
|
|
299
334
|
return _super.apply(this, arguments);
|
|
300
335
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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);
|
|
336
|
+
_createClass(MoneyValueChecker, [
|
|
337
|
+
{
|
|
338
|
+
key: "validate",
|
|
339
|
+
value: function validate(value) {
|
|
340
|
+
return(// value instanceof AmountValue ||
|
|
341
|
+
isPlainObject(value) && "amount" in value && isNumber(value.amount) && "currency" in value && isString(value.currency));
|
|
326
342
|
}
|
|
327
|
-
|
|
328
|
-
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
key: "transform",
|
|
346
|
+
value: function transform(value, oldValue) {
|
|
347
|
+
if (value === undefined || value === null || value === "") {
|
|
348
|
+
return new AmountValue({
|
|
349
|
+
currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
var result;
|
|
353
|
+
if (isPlainObject(value)) {
|
|
354
|
+
result = new AmountValue(_objectSpread({}, oldValue, value));
|
|
355
|
+
}
|
|
356
|
+
if (isString(value) && isJSONObject(value)) {
|
|
357
|
+
try {
|
|
358
|
+
var newValue = JSON.parse(value);
|
|
359
|
+
result = new AmountValue(_objectSpread({}, oldValue, newValue));
|
|
360
|
+
} catch (e) {}
|
|
361
|
+
}
|
|
362
|
+
if (result) {
|
|
363
|
+
var numberChecker = new NumberValueChecker();
|
|
364
|
+
var stringChecker = new StringValueChecker();
|
|
365
|
+
if (!numberChecker.validate(result.amount)) {
|
|
366
|
+
result.amount = numberChecker.transform(result.amount);
|
|
367
|
+
}
|
|
368
|
+
if (!stringChecker.validate(result.currency)) {
|
|
369
|
+
result.currency = stringChecker.transform(result.currency);
|
|
370
|
+
}
|
|
371
|
+
return result;
|
|
372
|
+
}
|
|
373
|
+
throw "".concat(value, " is not a { amount: number, currency: string } object");
|
|
329
374
|
}
|
|
330
|
-
return result;
|
|
331
375
|
}
|
|
332
|
-
|
|
333
|
-
};
|
|
376
|
+
]);
|
|
334
377
|
return MoneyValueChecker;
|
|
335
378
|
}(ValueChecker);
|
|
336
379
|
var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
@@ -341,36 +384,44 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
341
384
|
_classCallCheck(this, TimeScopeValueChecker);
|
|
342
385
|
return _super.apply(this, arguments);
|
|
343
386
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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);
|
|
387
|
+
_createClass(TimeScopeValueChecker, [
|
|
388
|
+
{
|
|
389
|
+
key: "validate",
|
|
390
|
+
value: function validate(value) {
|
|
391
|
+
return(// value instanceof RangeDateValue ||
|
|
392
|
+
isPlainObject(value) && "min" in value && isString(value.min) && "max" in value && isString(value.max));
|
|
366
393
|
}
|
|
367
|
-
|
|
368
|
-
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
key: "transform",
|
|
397
|
+
value: function transform(value, oldValue) {
|
|
398
|
+
if (value === undefined || value === null || value === "") {
|
|
399
|
+
return new RangeDateValue();
|
|
400
|
+
}
|
|
401
|
+
var result;
|
|
402
|
+
if (isPlainObject(value)) {
|
|
403
|
+
result = new RangeDateValue(_objectSpread({}, oldValue, value));
|
|
404
|
+
}
|
|
405
|
+
if (isString(value) && isJSONObject(value)) {
|
|
406
|
+
try {
|
|
407
|
+
var newValue = JSON.parse(value);
|
|
408
|
+
result = new RangeDateValue(_objectSpread({}, oldValue, newValue));
|
|
409
|
+
} catch (e) {}
|
|
410
|
+
}
|
|
411
|
+
if (result) {
|
|
412
|
+
var stringChecker = new StringValueChecker();
|
|
413
|
+
if (!stringChecker.validate(result.min)) {
|
|
414
|
+
result.min = stringChecker.transform(result.min);
|
|
415
|
+
}
|
|
416
|
+
if (!stringChecker.validate(result.max)) {
|
|
417
|
+
result.max = stringChecker.transform(result.max);
|
|
418
|
+
}
|
|
419
|
+
return result;
|
|
420
|
+
}
|
|
421
|
+
throw "".concat(value, " is not a { min: string, max: string } object");
|
|
369
422
|
}
|
|
370
|
-
return result;
|
|
371
423
|
}
|
|
372
|
-
|
|
373
|
-
};
|
|
424
|
+
]);
|
|
374
425
|
return TimeScopeValueChecker;
|
|
375
426
|
}(ValueChecker);
|
|
376
427
|
var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
@@ -381,39 +432,47 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
381
432
|
_classCallCheck(this, CalcValueChecker);
|
|
382
433
|
return _super.apply(this, arguments);
|
|
383
434
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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);
|
|
435
|
+
_createClass(CalcValueChecker, [
|
|
436
|
+
{
|
|
437
|
+
key: "validate",
|
|
438
|
+
value: function validate(value) {
|
|
439
|
+
return(// value instanceof CalcValue ||
|
|
440
|
+
isPlainObject(value) && "result" in value && isNumber(value.result) && "unit" in value && isString(value.unit));
|
|
409
441
|
}
|
|
410
|
-
|
|
411
|
-
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
key: "transform",
|
|
445
|
+
value: function transform(value, oldValue) {
|
|
446
|
+
if (value === undefined || value === null || value === "") {
|
|
447
|
+
return new CalcValue({
|
|
448
|
+
unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
var result;
|
|
452
|
+
if (isPlainObject(value)) {
|
|
453
|
+
result = new CalcValue(_objectSpread({}, oldValue, value));
|
|
454
|
+
}
|
|
455
|
+
if (isString(value) && isJSONObject(value)) {
|
|
456
|
+
try {
|
|
457
|
+
var newValue = JSON.parse(value);
|
|
458
|
+
result = new CalcValue(_objectSpread({}, oldValue, newValue));
|
|
459
|
+
} catch (e) {}
|
|
460
|
+
}
|
|
461
|
+
if (result) {
|
|
462
|
+
var numberChecker = new NumberValueChecker();
|
|
463
|
+
var stringChecker = new StringValueChecker();
|
|
464
|
+
if (!numberChecker.validate(result.result)) {
|
|
465
|
+
result.result = numberChecker.transform(result.result);
|
|
466
|
+
}
|
|
467
|
+
if (!stringChecker.validate(result.unit)) {
|
|
468
|
+
result.unit = stringChecker.transform(result.unit);
|
|
469
|
+
}
|
|
470
|
+
return result;
|
|
471
|
+
}
|
|
472
|
+
throw "".concat(value, " is not a { result: string, unit: string } object");
|
|
412
473
|
}
|
|
413
|
-
return result;
|
|
414
474
|
}
|
|
415
|
-
|
|
416
|
-
};
|
|
475
|
+
]);
|
|
417
476
|
return CalcValueChecker;
|
|
418
477
|
}(ValueChecker);
|
|
419
478
|
var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
@@ -424,39 +483,57 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
424
483
|
_classCallCheck(this, AddressValueChecker);
|
|
425
484
|
return _super.apply(this, arguments);
|
|
426
485
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
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);
|
|
486
|
+
_createClass(AddressValueChecker, [
|
|
487
|
+
{
|
|
488
|
+
key: "validate",
|
|
489
|
+
value: function validate(value) {
|
|
490
|
+
// return value instanceof AddressValue
|
|
491
|
+
if (isPlainObject(value)) {
|
|
492
|
+
// city?: string;
|
|
493
|
+
// cityDisplay?: string;
|
|
494
|
+
// district?: string;
|
|
495
|
+
// districtDisplay?: string;
|
|
496
|
+
// province?: string;
|
|
497
|
+
// provinceDisplay?: string
|
|
498
|
+
return true;
|
|
499
|
+
} else {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
452
502
|
}
|
|
453
|
-
|
|
454
|
-
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
key: "transform",
|
|
506
|
+
value: function transform(value, oldValue) {
|
|
507
|
+
if (value === undefined || value === null || value === "") {
|
|
508
|
+
return new AddressValue();
|
|
509
|
+
}
|
|
510
|
+
var result;
|
|
511
|
+
if (isPlainObject(value)) {
|
|
512
|
+
result = new AddressValue(_objectSpread({}, oldValue, camelizeKeys(value)));
|
|
513
|
+
}
|
|
514
|
+
if (isString(value) && isJSONObject(value)) {
|
|
515
|
+
try {
|
|
516
|
+
var newValue = JSON.parse(value);
|
|
517
|
+
result = new AddressValue(_objectSpread({}, oldValue, camelizeKeys(newValue)));
|
|
518
|
+
} catch (e) {}
|
|
519
|
+
}
|
|
520
|
+
if (result) {
|
|
521
|
+
var stringChecker = new StringValueChecker();
|
|
522
|
+
if (!stringChecker.validate(result.city)) {
|
|
523
|
+
result.city = stringChecker.transform(result.city);
|
|
524
|
+
}
|
|
525
|
+
if (!stringChecker.validate(result.district)) {
|
|
526
|
+
result.district = stringChecker.transform(result.district);
|
|
527
|
+
}
|
|
528
|
+
if (!stringChecker.validate(result.province)) {
|
|
529
|
+
result.province = stringChecker.transform(result.province);
|
|
530
|
+
}
|
|
531
|
+
return result;
|
|
532
|
+
}
|
|
533
|
+
throw "".concat(value, " is not a { city: string, district: string, province: string } object");
|
|
455
534
|
}
|
|
456
|
-
return result;
|
|
457
535
|
}
|
|
458
|
-
|
|
459
|
-
};
|
|
536
|
+
]);
|
|
460
537
|
return AddressValueChecker;
|
|
461
538
|
}(ValueChecker);
|
|
462
539
|
var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
@@ -464,44 +541,49 @@ var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
|
464
541
|
function ValueCheckerFactory() {
|
|
465
542
|
_classCallCheck(this, ValueCheckerFactory);
|
|
466
543
|
}
|
|
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
|
-
|
|
544
|
+
_createClass(ValueCheckerFactory, null, [
|
|
545
|
+
{
|
|
546
|
+
key: "getValueChecker",
|
|
547
|
+
value: function getValueChecker(fieldType) {
|
|
548
|
+
var checker;
|
|
549
|
+
switch(fieldType){
|
|
550
|
+
case FieldTypes.VARCHAR:
|
|
551
|
+
case FieldTypes.TIMESTAMP:
|
|
552
|
+
case FieldTypes.TEXT:
|
|
553
|
+
case FieldTypes.RELATION:
|
|
554
|
+
case FieldTypes.AUTO_NUMBER:
|
|
555
|
+
checker = new StringValueChecker();
|
|
556
|
+
break;
|
|
557
|
+
case FieldTypes.DECIMAL:
|
|
558
|
+
checker = new NumberValueChecker();
|
|
559
|
+
break;
|
|
560
|
+
case FieldTypes.EMPLOYEES:
|
|
561
|
+
case FieldTypes.DEPARTMENTS:
|
|
562
|
+
case FieldTypes.IMAGE:
|
|
563
|
+
case FieldTypes.FILE:
|
|
564
|
+
case FieldTypes.ARRAY:
|
|
565
|
+
checker = new StringArrayValueChecker();
|
|
566
|
+
break;
|
|
567
|
+
case FieldTypes.MONEY:
|
|
568
|
+
checker = new MoneyValueChecker();
|
|
569
|
+
break;
|
|
570
|
+
case FieldTypes.TIMESCOPE:
|
|
571
|
+
checker = new TimeScopeValueChecker();
|
|
572
|
+
break;
|
|
573
|
+
case FieldTypes.CALC:
|
|
574
|
+
checker = new CalcValueChecker();
|
|
575
|
+
break;
|
|
576
|
+
case FieldTypes.DECIMAL_RANGE:
|
|
577
|
+
checker = new NumberArrayValueChecker();
|
|
578
|
+
break;
|
|
579
|
+
case FieldTypes.ADDRESS:
|
|
580
|
+
checker = new AddressValueChecker();
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
return checker;
|
|
584
|
+
}
|
|
502
585
|
}
|
|
503
|
-
|
|
504
|
-
};
|
|
586
|
+
]);
|
|
505
587
|
return ValueCheckerFactory;
|
|
506
588
|
}();
|
|
507
589
|
function getFieldTypeFromKey(key) {
|