@byteluck-fe/model-driven-engine 2.7.0-alpha.2 → 2.7.0-alpha.3
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 +1106 -928
- package/dist/esm/common/OkWorker.js +119 -74
- package/dist/esm/common/Runtime.js +38 -21
- package/dist/esm/common/Store.js +149 -116
- package/dist/esm/common/checkerValue.js +316 -241
- 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/index.umd.js +9 -9
- package/package.json +3 -3
|
@@ -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, {
|
|
@@ -165,22 +179,29 @@ var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
165
179
|
_classCallCheck(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
|
+
_createClass(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) {
|
|
@@ -191,21 +212,28 @@ var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
191
212
|
_classCallCheck(this, NumberValueChecker);
|
|
192
213
|
return _super.apply(this, arguments);
|
|
193
214
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
215
|
+
_createClass(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) {
|
|
@@ -216,34 +244,41 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
216
244
|
_classCallCheck(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
|
-
return getStringValueArray(newValue);
|
|
247
|
+
_createClass(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);
|
|
240
267
|
}
|
|
241
|
-
|
|
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) {}
|
|
275
|
+
}
|
|
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) {
|
|
@@ -254,40 +289,47 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
254
289
|
_classCallCheck(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
|
+
_createClass(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) {
|
|
@@ -298,39 +340,46 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
298
340
|
_classCallCheck(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
|
+
_createClass(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(_objectSpread({}, oldValue, value));
|
|
361
|
+
}
|
|
362
|
+
if (isString(value) && isJSONObject(value)) {
|
|
363
|
+
try {
|
|
364
|
+
var newValue = JSON.parse(value);
|
|
365
|
+
result = new AmountValue(_objectSpread({}, 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) {
|
|
@@ -341,36 +390,43 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
341
390
|
_classCallCheck(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
|
+
_createClass(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(_objectSpread({}, oldValue, value));
|
|
409
|
+
}
|
|
410
|
+
if (isString(value) && isJSONObject(value)) {
|
|
411
|
+
try {
|
|
412
|
+
var newValue = JSON.parse(value);
|
|
413
|
+
result = new RangeDateValue(_objectSpread({}, 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) {
|
|
@@ -381,39 +437,46 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
381
437
|
_classCallCheck(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
|
+
_createClass(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(_objectSpread({}, oldValue, value));
|
|
458
|
+
}
|
|
459
|
+
if (isString(value) && isJSONObject(value)) {
|
|
460
|
+
try {
|
|
461
|
+
var newValue = JSON.parse(value);
|
|
462
|
+
result = new CalcValue(_objectSpread({}, 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) {
|
|
@@ -424,39 +487,46 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
424
487
|
_classCallCheck(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);
|
|
490
|
+
_createClass(AddressValueChecker, [
|
|
491
|
+
{
|
|
492
|
+
key: "validate",
|
|
493
|
+
value: function validate(value) {
|
|
494
|
+
return _instanceof(value, AddressValue);
|
|
449
495
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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(_objectSpread({}, oldValue, camelizeKeys(value)));
|
|
506
|
+
}
|
|
507
|
+
if (isString(value) && isJSONObject(value)) {
|
|
508
|
+
try {
|
|
509
|
+
var newValue = JSON.parse(value);
|
|
510
|
+
result = new AddressValue(_objectSpread({}, 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() {
|
|
@@ -464,44 +534,49 @@ var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
|
464
534
|
function ValueCheckerFactory() {
|
|
465
535
|
_classCallCheck(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
|
+
_createClass(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) {
|