@e22m4u/js-repository 0.2.6 → 0.2.7
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/cjs/index.cjs +104 -174
- package/package.json +4 -1
- package/src/definition/model/model-data-transformer.js +3 -3
- package/src/definition/model/model-data-validator.js +2 -2
- package/src/definition/model/model-data-validator.spec.js +5 -5
- package/src/definition/model/model-definition-utils.js +3 -3
- package/src/definition/model/model-definition-utils.spec.js +2 -2
- package/src/definition/model/properties/index.d.ts +0 -1
- package/src/definition/model/properties/index.js +0 -1
- package/src/definition/model/properties/property-uniqueness-validator.js +3 -3
- package/src/definition/model/properties/property-uniqueness-validator.spec.js +7 -7
- package/src/definition/model/properties/empty-values-definer.d.ts +0 -23
- package/src/definition/model/properties/empty-values-definer.js +0 -66
- package/src/definition/model/properties/empty-values-definer.spec.js +0 -96
package/dist/cjs/index.cjs
CHANGED
|
@@ -1670,73 +1670,6 @@ var init_property_uniqueness = __esm({
|
|
|
1670
1670
|
}
|
|
1671
1671
|
});
|
|
1672
1672
|
|
|
1673
|
-
// src/definition/model/properties/empty-values-definer.js
|
|
1674
|
-
var import_js_service6, _EmptyValuesDefiner, EmptyValuesDefiner;
|
|
1675
|
-
var init_empty_values_definer = __esm({
|
|
1676
|
-
"src/definition/model/properties/empty-values-definer.js"() {
|
|
1677
|
-
"use strict";
|
|
1678
|
-
init_data_type();
|
|
1679
|
-
import_js_service6 = require("@e22m4u/js-service");
|
|
1680
|
-
init_utils();
|
|
1681
|
-
init_errors();
|
|
1682
|
-
_EmptyValuesDefiner = class _EmptyValuesDefiner extends import_js_service6.Service {
|
|
1683
|
-
/**
|
|
1684
|
-
* Empty values map.
|
|
1685
|
-
*
|
|
1686
|
-
* @type {Map<string, *[]>}
|
|
1687
|
-
*/
|
|
1688
|
-
_emptyValuesMap = /* @__PURE__ */ new Map([
|
|
1689
|
-
[DataType.ANY, [void 0, null]],
|
|
1690
|
-
[DataType.STRING, [void 0, null, ""]],
|
|
1691
|
-
[DataType.NUMBER, [void 0, null, 0]],
|
|
1692
|
-
[DataType.BOOLEAN, [void 0, null]],
|
|
1693
|
-
[DataType.ARRAY, [void 0, null, []]],
|
|
1694
|
-
[DataType.OBJECT, [void 0, null, {}]]
|
|
1695
|
-
]);
|
|
1696
|
-
/**
|
|
1697
|
-
* Set empty values of data type.
|
|
1698
|
-
*
|
|
1699
|
-
* @param {string} dataType
|
|
1700
|
-
* @param {*[]} emptyValues
|
|
1701
|
-
* @returns {EmptyValuesDefiner}
|
|
1702
|
-
*/
|
|
1703
|
-
setEmptyValuesOf(dataType, emptyValues) {
|
|
1704
|
-
if (!Object.values(DataType).includes(dataType))
|
|
1705
|
-
throw new InvalidArgumentError(
|
|
1706
|
-
'The argument "dataType" of the EmptyValuesDefiner.setEmptyValuesOf must be one of data types: %l, but %v given.',
|
|
1707
|
-
Object.values(DataType),
|
|
1708
|
-
dataType
|
|
1709
|
-
);
|
|
1710
|
-
if (!Array.isArray(emptyValues))
|
|
1711
|
-
throw new InvalidArgumentError(
|
|
1712
|
-
'The argument "emptyValues" of the EmptyValuesDefiner.setEmptyValuesOf must be an Array, but %v given.',
|
|
1713
|
-
emptyValues
|
|
1714
|
-
);
|
|
1715
|
-
this._emptyValuesMap.set(dataType, emptyValues);
|
|
1716
|
-
return this;
|
|
1717
|
-
}
|
|
1718
|
-
/**
|
|
1719
|
-
* Is empty.
|
|
1720
|
-
*
|
|
1721
|
-
* @param {string} dataType
|
|
1722
|
-
* @param {*} value
|
|
1723
|
-
* @returns {boolean}
|
|
1724
|
-
*/
|
|
1725
|
-
isEmpty(dataType, value) {
|
|
1726
|
-
if (!Object.values(DataType).includes(dataType))
|
|
1727
|
-
throw new InvalidArgumentError(
|
|
1728
|
-
'The argument "dataType" of the EmptyValuesDefiner.isEmpty must be one of data types: %l, but %v given.',
|
|
1729
|
-
Object.values(DataType),
|
|
1730
|
-
dataType
|
|
1731
|
-
);
|
|
1732
|
-
return this._emptyValuesMap.get(dataType).some((v) => isDeepEqual(v, value));
|
|
1733
|
-
}
|
|
1734
|
-
};
|
|
1735
|
-
__name(_EmptyValuesDefiner, "EmptyValuesDefiner");
|
|
1736
|
-
EmptyValuesDefiner = _EmptyValuesDefiner;
|
|
1737
|
-
}
|
|
1738
|
-
});
|
|
1739
|
-
|
|
1740
1673
|
// src/definition/model/properties/property-validator/property-validator.js
|
|
1741
1674
|
var init_property_validator = __esm({
|
|
1742
1675
|
"src/definition/model/properties/property-validator/property-validator.js"() {
|
|
@@ -1833,16 +1766,16 @@ var init_builtin = __esm({
|
|
|
1833
1766
|
});
|
|
1834
1767
|
|
|
1835
1768
|
// src/definition/model/properties/property-validator/property-validator-registry.js
|
|
1836
|
-
var
|
|
1769
|
+
var import_js_service6, _PropertyValidatorRegistry, PropertyValidatorRegistry;
|
|
1837
1770
|
var init_property_validator_registry = __esm({
|
|
1838
1771
|
"src/definition/model/properties/property-validator/property-validator-registry.js"() {
|
|
1839
1772
|
"use strict";
|
|
1840
|
-
|
|
1773
|
+
import_js_service6 = require("@e22m4u/js-service");
|
|
1841
1774
|
init_builtin();
|
|
1842
1775
|
init_builtin();
|
|
1843
1776
|
init_builtin();
|
|
1844
1777
|
init_errors();
|
|
1845
|
-
_PropertyValidatorRegistry = class _PropertyValidatorRegistry extends
|
|
1778
|
+
_PropertyValidatorRegistry = class _PropertyValidatorRegistry extends import_js_service6.Service {
|
|
1846
1779
|
/**
|
|
1847
1780
|
* Validators.
|
|
1848
1781
|
*
|
|
@@ -2013,17 +1946,17 @@ var init_builtin2 = __esm({
|
|
|
2013
1946
|
});
|
|
2014
1947
|
|
|
2015
1948
|
// src/definition/model/properties/property-transformer/property-transformer-registry.js
|
|
2016
|
-
var
|
|
1949
|
+
var import_js_service7, _PropertyTransformerRegistry, PropertyTransformerRegistry;
|
|
2017
1950
|
var init_property_transformer_registry = __esm({
|
|
2018
1951
|
"src/definition/model/properties/property-transformer/property-transformer-registry.js"() {
|
|
2019
1952
|
"use strict";
|
|
2020
|
-
|
|
1953
|
+
import_js_service7 = require("@e22m4u/js-service");
|
|
2021
1954
|
init_builtin2();
|
|
2022
1955
|
init_builtin2();
|
|
2023
1956
|
init_builtin2();
|
|
2024
1957
|
init_builtin2();
|
|
2025
1958
|
init_errors();
|
|
2026
|
-
_PropertyTransformerRegistry = class _PropertyTransformerRegistry extends
|
|
1959
|
+
_PropertyTransformerRegistry = class _PropertyTransformerRegistry extends import_js_service7.Service {
|
|
2027
1960
|
/**
|
|
2028
1961
|
* Transformers.
|
|
2029
1962
|
*
|
|
@@ -2102,15 +2035,15 @@ var init_property_transformer2 = __esm({
|
|
|
2102
2035
|
});
|
|
2103
2036
|
|
|
2104
2037
|
// src/definition/definition-registry.js
|
|
2105
|
-
var
|
|
2038
|
+
var import_js_service8, _DefinitionRegistry, DefinitionRegistry;
|
|
2106
2039
|
var init_definition_registry = __esm({
|
|
2107
2040
|
"src/definition/definition-registry.js"() {
|
|
2108
2041
|
"use strict";
|
|
2109
|
-
|
|
2042
|
+
import_js_service8 = require("@e22m4u/js-service");
|
|
2110
2043
|
init_errors();
|
|
2111
2044
|
init_model();
|
|
2112
2045
|
init_definition();
|
|
2113
|
-
_DefinitionRegistry = class _DefinitionRegistry extends
|
|
2046
|
+
_DefinitionRegistry = class _DefinitionRegistry extends import_js_service8.Service {
|
|
2114
2047
|
/**
|
|
2115
2048
|
* Datasources.
|
|
2116
2049
|
*
|
|
@@ -2199,19 +2132,19 @@ var init_definition_registry = __esm({
|
|
|
2199
2132
|
});
|
|
2200
2133
|
|
|
2201
2134
|
// src/definition/model/model-definition-utils.js
|
|
2202
|
-
var
|
|
2135
|
+
var import_js_service9, import_js_empty_values, DEFAULT_PRIMARY_KEY_PROPERTY_NAME, _ModelDefinitionUtils, ModelDefinitionUtils;
|
|
2203
2136
|
var init_model_definition_utils = __esm({
|
|
2204
2137
|
"src/definition/model/model-definition-utils.js"() {
|
|
2205
2138
|
"use strict";
|
|
2206
|
-
|
|
2139
|
+
import_js_service9 = require("@e22m4u/js-service");
|
|
2207
2140
|
init_properties();
|
|
2208
2141
|
init_utils();
|
|
2209
2142
|
init_utils();
|
|
2210
|
-
|
|
2143
|
+
import_js_empty_values = require("@e22m4u/js-empty-values");
|
|
2211
2144
|
init_errors();
|
|
2212
2145
|
init_definition_registry();
|
|
2213
2146
|
DEFAULT_PRIMARY_KEY_PROPERTY_NAME = "id";
|
|
2214
|
-
_ModelDefinitionUtils = class _ModelDefinitionUtils extends
|
|
2147
|
+
_ModelDefinitionUtils = class _ModelDefinitionUtils extends import_js_service9.Service {
|
|
2215
2148
|
/**
|
|
2216
2149
|
* Get primary key as property name.
|
|
2217
2150
|
*
|
|
@@ -2318,12 +2251,12 @@ var init_model_definition_utils = __esm({
|
|
|
2318
2251
|
const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
|
|
2319
2252
|
const propNames = onlyProvidedProperties ? Object.keys(modelData) : Object.keys(propDefs);
|
|
2320
2253
|
const extendedData = cloneDeep(modelData);
|
|
2321
|
-
const
|
|
2254
|
+
const emptyValuesService = this.getService(import_js_empty_values.EmptyValuesService);
|
|
2322
2255
|
propNames.forEach((propName) => {
|
|
2323
2256
|
const propDef = propDefs[propName];
|
|
2324
2257
|
const propValue = extendedData[propName];
|
|
2325
2258
|
const propType = propDef != null ? this.getDataTypeFromPropertyDefinition(propDef) : DataType.ANY;
|
|
2326
|
-
const isEmpty =
|
|
2259
|
+
const isEmpty = emptyValuesService.isEmptyByType(propType, propValue);
|
|
2327
2260
|
if (!isEmpty) return;
|
|
2328
2261
|
if (propDef && typeof propDef === "object" && propDef.default !== void 0) {
|
|
2329
2262
|
extendedData[propName] = this.getDefaultPropertyValue(
|
|
@@ -2613,18 +2546,18 @@ var init_model_definition_utils = __esm({
|
|
|
2613
2546
|
});
|
|
2614
2547
|
|
|
2615
2548
|
// src/definition/model/properties/property-uniqueness-validator.js
|
|
2616
|
-
var
|
|
2549
|
+
var import_js_service10, import_js_empty_values2, _PropertyUniquenessValidator, PropertyUniquenessValidator;
|
|
2617
2550
|
var init_property_uniqueness_validator = __esm({
|
|
2618
2551
|
"src/definition/model/properties/property-uniqueness-validator.js"() {
|
|
2619
2552
|
"use strict";
|
|
2620
2553
|
init_data_type();
|
|
2621
|
-
|
|
2554
|
+
import_js_service10 = require("@e22m4u/js-service");
|
|
2622
2555
|
init_utils();
|
|
2556
|
+
import_js_empty_values2 = require("@e22m4u/js-empty-values");
|
|
2623
2557
|
init_property_uniqueness();
|
|
2624
|
-
init_empty_values_definer();
|
|
2625
2558
|
init_errors();
|
|
2626
2559
|
init_model_definition_utils();
|
|
2627
|
-
_PropertyUniquenessValidator = class _PropertyUniquenessValidator extends
|
|
2560
|
+
_PropertyUniquenessValidator = class _PropertyUniquenessValidator extends import_js_service10.Service {
|
|
2628
2561
|
/**
|
|
2629
2562
|
* Validate.
|
|
2630
2563
|
*
|
|
@@ -2672,7 +2605,7 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2672
2605
|
propValue
|
|
2673
2606
|
), "createError");
|
|
2674
2607
|
let willBeReplaced = void 0;
|
|
2675
|
-
const
|
|
2608
|
+
const emptyValuesService = this.getService(import_js_empty_values2.EmptyValuesService);
|
|
2676
2609
|
for (const propName of propNames) {
|
|
2677
2610
|
const propDef = propDefs[propName];
|
|
2678
2611
|
if (!propDef || typeof propDef === "string" || !propDef.unique || propDef.unique === PropertyUniqueness.NON_UNIQUE) {
|
|
@@ -2681,7 +2614,7 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2681
2614
|
const propValue = modelData[propName];
|
|
2682
2615
|
if (propDef.unique === PropertyUniqueness.SPARSE) {
|
|
2683
2616
|
const propType = propDef.type || DataType.ANY;
|
|
2684
|
-
const isEmpty =
|
|
2617
|
+
const isEmpty = emptyValuesService.isEmptyByType(propType, propValue);
|
|
2685
2618
|
if (isEmpty) continue;
|
|
2686
2619
|
}
|
|
2687
2620
|
if (methodName === "create") {
|
|
@@ -2733,14 +2666,14 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2733
2666
|
});
|
|
2734
2667
|
|
|
2735
2668
|
// src/definition/model/properties/primary-keys-definition-validator.js
|
|
2736
|
-
var
|
|
2669
|
+
var import_js_service11, _PrimaryKeysDefinitionValidator, PrimaryKeysDefinitionValidator;
|
|
2737
2670
|
var init_primary_keys_definition_validator = __esm({
|
|
2738
2671
|
"src/definition/model/properties/primary-keys-definition-validator.js"() {
|
|
2739
2672
|
"use strict";
|
|
2740
|
-
|
|
2673
|
+
import_js_service11 = require("@e22m4u/js-service");
|
|
2741
2674
|
init_errors();
|
|
2742
2675
|
init_model_definition_utils();
|
|
2743
|
-
_PrimaryKeysDefinitionValidator = class _PrimaryKeysDefinitionValidator extends
|
|
2676
|
+
_PrimaryKeysDefinitionValidator = class _PrimaryKeysDefinitionValidator extends import_js_service11.Service {
|
|
2744
2677
|
/**
|
|
2745
2678
|
* Validate.
|
|
2746
2679
|
*
|
|
@@ -2785,11 +2718,11 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
2785
2718
|
});
|
|
2786
2719
|
|
|
2787
2720
|
// src/definition/model/properties/properties-definition-validator.js
|
|
2788
|
-
var
|
|
2721
|
+
var import_js_service12, _PropertiesDefinitionValidator, PropertiesDefinitionValidator;
|
|
2789
2722
|
var init_properties_definition_validator = __esm({
|
|
2790
2723
|
"src/definition/model/properties/properties-definition-validator.js"() {
|
|
2791
2724
|
"use strict";
|
|
2792
|
-
|
|
2725
|
+
import_js_service12 = require("@e22m4u/js-service");
|
|
2793
2726
|
init_data_type();
|
|
2794
2727
|
init_utils();
|
|
2795
2728
|
init_property_uniqueness();
|
|
@@ -2797,7 +2730,7 @@ var init_properties_definition_validator = __esm({
|
|
|
2797
2730
|
init_property_validator2();
|
|
2798
2731
|
init_property_transformer2();
|
|
2799
2732
|
init_primary_keys_definition_validator();
|
|
2800
|
-
_PropertiesDefinitionValidator = class _PropertiesDefinitionValidator extends
|
|
2733
|
+
_PropertiesDefinitionValidator = class _PropertiesDefinitionValidator extends import_js_service12.Service {
|
|
2801
2734
|
/**
|
|
2802
2735
|
* Validate.
|
|
2803
2736
|
*
|
|
@@ -3102,7 +3035,6 @@ var init_properties = __esm({
|
|
|
3102
3035
|
init_data_type();
|
|
3103
3036
|
init_property_definition();
|
|
3104
3037
|
init_property_uniqueness();
|
|
3105
|
-
init_empty_values_definer();
|
|
3106
3038
|
init_property_validator2();
|
|
3107
3039
|
init_property_transformer2();
|
|
3108
3040
|
init_property_uniqueness_validator();
|
|
@@ -3119,19 +3051,19 @@ var init_model_definition = __esm({
|
|
|
3119
3051
|
});
|
|
3120
3052
|
|
|
3121
3053
|
// src/definition/model/model-data-validator.js
|
|
3122
|
-
var
|
|
3054
|
+
var import_js_service13, import_js_empty_values3, _ModelDataValidator, ModelDataValidator;
|
|
3123
3055
|
var init_model_data_validator = __esm({
|
|
3124
3056
|
"src/definition/model/model-data-validator.js"() {
|
|
3125
3057
|
"use strict";
|
|
3126
|
-
|
|
3058
|
+
import_js_service13 = require("@e22m4u/js-service");
|
|
3127
3059
|
init_properties();
|
|
3128
3060
|
init_utils();
|
|
3129
3061
|
init_utils();
|
|
3130
|
-
|
|
3062
|
+
import_js_empty_values3 = require("@e22m4u/js-empty-values");
|
|
3131
3063
|
init_errors();
|
|
3132
3064
|
init_properties();
|
|
3133
3065
|
init_model_definition_utils();
|
|
3134
|
-
_ModelDataValidator = class _ModelDataValidator extends
|
|
3066
|
+
_ModelDataValidator = class _ModelDataValidator extends import_js_service13.Service {
|
|
3135
3067
|
/**
|
|
3136
3068
|
* Validate.
|
|
3137
3069
|
*
|
|
@@ -3175,7 +3107,7 @@ var init_model_data_validator = __esm({
|
|
|
3175
3107
|
const propType = this.getService(ModelDefinitionUtils).getDataTypeFromPropertyDefinition(
|
|
3176
3108
|
propDef
|
|
3177
3109
|
);
|
|
3178
|
-
const isEmpty = this.getService(
|
|
3110
|
+
const isEmpty = this.getService(import_js_empty_values3.EmptyValuesService).isEmptyByType(
|
|
3179
3111
|
propType,
|
|
3180
3112
|
propValue
|
|
3181
3113
|
);
|
|
@@ -3329,14 +3261,14 @@ var init_model_data_validator = __esm({
|
|
|
3329
3261
|
});
|
|
3330
3262
|
|
|
3331
3263
|
// src/definition/model/model-data-sanitizer.js
|
|
3332
|
-
var
|
|
3264
|
+
var import_js_service14, _ModelDataSanitizer, ModelDataSanitizer;
|
|
3333
3265
|
var init_model_data_sanitizer = __esm({
|
|
3334
3266
|
"src/definition/model/model-data-sanitizer.js"() {
|
|
3335
3267
|
"use strict";
|
|
3336
|
-
|
|
3268
|
+
import_js_service14 = require("@e22m4u/js-service");
|
|
3337
3269
|
init_errors();
|
|
3338
3270
|
init_model_definition_utils();
|
|
3339
|
-
_ModelDataSanitizer = class _ModelDataSanitizer extends
|
|
3271
|
+
_ModelDataSanitizer = class _ModelDataSanitizer extends import_js_service14.Service {
|
|
3340
3272
|
/**
|
|
3341
3273
|
* Validate.
|
|
3342
3274
|
*
|
|
@@ -3366,19 +3298,19 @@ var init_model_data_sanitizer = __esm({
|
|
|
3366
3298
|
});
|
|
3367
3299
|
|
|
3368
3300
|
// src/definition/model/model-data-transformer.js
|
|
3369
|
-
var
|
|
3301
|
+
var import_js_service15, import_js_empty_values4, _ModelDataTransformer, ModelDataTransformer;
|
|
3370
3302
|
var init_model_data_transformer = __esm({
|
|
3371
3303
|
"src/definition/model/model-data-transformer.js"() {
|
|
3372
3304
|
"use strict";
|
|
3373
|
-
|
|
3305
|
+
import_js_service15 = require("@e22m4u/js-service");
|
|
3374
3306
|
init_utils();
|
|
3375
3307
|
init_utils();
|
|
3376
3308
|
init_utils();
|
|
3377
|
-
|
|
3309
|
+
import_js_empty_values4 = require("@e22m4u/js-empty-values");
|
|
3378
3310
|
init_errors();
|
|
3379
3311
|
init_model_definition_utils();
|
|
3380
3312
|
init_properties();
|
|
3381
|
-
_ModelDataTransformer = class _ModelDataTransformer extends
|
|
3313
|
+
_ModelDataTransformer = class _ModelDataTransformer extends import_js_service15.Service {
|
|
3382
3314
|
/**
|
|
3383
3315
|
* Transform.
|
|
3384
3316
|
*
|
|
@@ -3394,7 +3326,7 @@ var init_model_data_transformer = __esm({
|
|
|
3394
3326
|
modelName,
|
|
3395
3327
|
modelData
|
|
3396
3328
|
);
|
|
3397
|
-
const
|
|
3329
|
+
const emptyValuesService = this.getService(import_js_empty_values4.EmptyValuesService);
|
|
3398
3330
|
const modelDefinitionUtils = this.getService(ModelDefinitionUtils);
|
|
3399
3331
|
const propDefs = modelDefinitionUtils.getPropertiesDefinitionInBaseModelHierarchy(
|
|
3400
3332
|
modelName
|
|
@@ -3406,7 +3338,7 @@ var init_model_data_transformer = __esm({
|
|
|
3406
3338
|
if (!propDef) return transformedDataOrPromise;
|
|
3407
3339
|
const propType = modelDefinitionUtils.getDataTypeFromPropertyDefinition(propDef);
|
|
3408
3340
|
const propValue = modelData[propName];
|
|
3409
|
-
const isEmpty =
|
|
3341
|
+
const isEmpty = emptyValuesService.isEmptyByType(propType, propValue);
|
|
3410
3342
|
if (isEmpty) return transformedDataOrPromise;
|
|
3411
3343
|
const newPropValueOrPromise = this._transformPropertyValue(
|
|
3412
3344
|
modelName,
|
|
@@ -3475,15 +3407,15 @@ var init_model_data_transformer = __esm({
|
|
|
3475
3407
|
});
|
|
3476
3408
|
|
|
3477
3409
|
// src/definition/model/model-definition-validator.js
|
|
3478
|
-
var
|
|
3410
|
+
var import_js_service16, _ModelDefinitionValidator, ModelDefinitionValidator;
|
|
3479
3411
|
var init_model_definition_validator = __esm({
|
|
3480
3412
|
"src/definition/model/model-definition-validator.js"() {
|
|
3481
3413
|
"use strict";
|
|
3482
|
-
|
|
3414
|
+
import_js_service16 = require("@e22m4u/js-service");
|
|
3483
3415
|
init_errors();
|
|
3484
3416
|
init_relations();
|
|
3485
3417
|
init_properties();
|
|
3486
|
-
_ModelDefinitionValidator = class _ModelDefinitionValidator extends
|
|
3418
|
+
_ModelDefinitionValidator = class _ModelDefinitionValidator extends import_js_service16.Service {
|
|
3487
3419
|
/**
|
|
3488
3420
|
* Validate.
|
|
3489
3421
|
*
|
|
@@ -3567,13 +3499,13 @@ var init_model = __esm({
|
|
|
3567
3499
|
});
|
|
3568
3500
|
|
|
3569
3501
|
// src/definition/datasource/datasource-definition-validator.js
|
|
3570
|
-
var
|
|
3502
|
+
var import_js_service17, _DatasourceDefinitionValidator, DatasourceDefinitionValidator;
|
|
3571
3503
|
var init_datasource_definition_validator = __esm({
|
|
3572
3504
|
"src/definition/datasource/datasource-definition-validator.js"() {
|
|
3573
3505
|
"use strict";
|
|
3574
|
-
|
|
3506
|
+
import_js_service17 = require("@e22m4u/js-service");
|
|
3575
3507
|
init_errors();
|
|
3576
|
-
_DatasourceDefinitionValidator = class _DatasourceDefinitionValidator extends
|
|
3508
|
+
_DatasourceDefinitionValidator = class _DatasourceDefinitionValidator extends import_js_service17.Service {
|
|
3577
3509
|
/**
|
|
3578
3510
|
* Validate.
|
|
3579
3511
|
*
|
|
@@ -3622,15 +3554,15 @@ var init_definition = __esm({
|
|
|
3622
3554
|
});
|
|
3623
3555
|
|
|
3624
3556
|
// src/filter/fields-clause-tool.js
|
|
3625
|
-
var
|
|
3557
|
+
var import_js_service18, _FieldsClauseTool, FieldsClauseTool;
|
|
3626
3558
|
var init_fields_clause_tool = __esm({
|
|
3627
3559
|
"src/filter/fields-clause-tool.js"() {
|
|
3628
3560
|
"use strict";
|
|
3629
|
-
|
|
3561
|
+
import_js_service18 = require("@e22m4u/js-service");
|
|
3630
3562
|
init_utils();
|
|
3631
3563
|
init_errors();
|
|
3632
3564
|
init_definition();
|
|
3633
|
-
_FieldsClauseTool = class _FieldsClauseTool extends
|
|
3565
|
+
_FieldsClauseTool = class _FieldsClauseTool extends import_js_service18.Service {
|
|
3634
3566
|
/**
|
|
3635
3567
|
* Filter.
|
|
3636
3568
|
*
|
|
@@ -3714,17 +3646,17 @@ var init_fields_clause_tool = __esm({
|
|
|
3714
3646
|
});
|
|
3715
3647
|
|
|
3716
3648
|
// src/relations/has-one-resolver.js
|
|
3717
|
-
var
|
|
3649
|
+
var import_js_service19, _HasOneResolver, HasOneResolver;
|
|
3718
3650
|
var init_has_one_resolver = __esm({
|
|
3719
3651
|
"src/relations/has-one-resolver.js"() {
|
|
3720
3652
|
"use strict";
|
|
3721
|
-
|
|
3653
|
+
import_js_service19 = require("@e22m4u/js-service");
|
|
3722
3654
|
init_utils();
|
|
3723
3655
|
init_definition();
|
|
3724
3656
|
init_errors();
|
|
3725
3657
|
init_repository2();
|
|
3726
3658
|
init_definition();
|
|
3727
|
-
_HasOneResolver = class _HasOneResolver extends
|
|
3659
|
+
_HasOneResolver = class _HasOneResolver extends import_js_service19.Service {
|
|
3728
3660
|
/**
|
|
3729
3661
|
* Include to.
|
|
3730
3662
|
*
|
|
@@ -3969,17 +3901,17 @@ var init_has_one_resolver = __esm({
|
|
|
3969
3901
|
});
|
|
3970
3902
|
|
|
3971
3903
|
// src/relations/has-many-resolver.js
|
|
3972
|
-
var
|
|
3904
|
+
var import_js_service20, _HasManyResolver, HasManyResolver;
|
|
3973
3905
|
var init_has_many_resolver = __esm({
|
|
3974
3906
|
"src/relations/has-many-resolver.js"() {
|
|
3975
3907
|
"use strict";
|
|
3976
|
-
|
|
3908
|
+
import_js_service20 = require("@e22m4u/js-service");
|
|
3977
3909
|
init_utils();
|
|
3978
3910
|
init_definition();
|
|
3979
3911
|
init_errors();
|
|
3980
3912
|
init_repository2();
|
|
3981
3913
|
init_definition();
|
|
3982
|
-
_HasManyResolver = class _HasManyResolver extends
|
|
3914
|
+
_HasManyResolver = class _HasManyResolver extends import_js_service20.Service {
|
|
3983
3915
|
/**
|
|
3984
3916
|
* Include to.
|
|
3985
3917
|
*
|
|
@@ -4234,17 +4166,17 @@ var init_has_many_resolver = __esm({
|
|
|
4234
4166
|
});
|
|
4235
4167
|
|
|
4236
4168
|
// src/relations/belongs-to-resolver.js
|
|
4237
|
-
var
|
|
4169
|
+
var import_js_service21, _BelongsToResolver, BelongsToResolver;
|
|
4238
4170
|
var init_belongs_to_resolver = __esm({
|
|
4239
4171
|
"src/relations/belongs-to-resolver.js"() {
|
|
4240
4172
|
"use strict";
|
|
4241
|
-
|
|
4173
|
+
import_js_service21 = require("@e22m4u/js-service");
|
|
4242
4174
|
init_utils();
|
|
4243
4175
|
init_utils();
|
|
4244
4176
|
init_errors();
|
|
4245
4177
|
init_repository2();
|
|
4246
4178
|
init_definition();
|
|
4247
|
-
_BelongsToResolver = class _BelongsToResolver extends
|
|
4179
|
+
_BelongsToResolver = class _BelongsToResolver extends import_js_service21.Service {
|
|
4248
4180
|
/**
|
|
4249
4181
|
* Include to.
|
|
4250
4182
|
*
|
|
@@ -4442,17 +4374,17 @@ var init_belongs_to_resolver = __esm({
|
|
|
4442
4374
|
});
|
|
4443
4375
|
|
|
4444
4376
|
// src/relations/references-many-resolver.js
|
|
4445
|
-
var
|
|
4377
|
+
var import_js_service22, _ReferencesManyResolver, ReferencesManyResolver;
|
|
4446
4378
|
var init_references_many_resolver = __esm({
|
|
4447
4379
|
"src/relations/references-many-resolver.js"() {
|
|
4448
4380
|
"use strict";
|
|
4449
|
-
|
|
4381
|
+
import_js_service22 = require("@e22m4u/js-service");
|
|
4450
4382
|
init_utils();
|
|
4451
4383
|
init_utils();
|
|
4452
4384
|
init_errors();
|
|
4453
4385
|
init_repository2();
|
|
4454
4386
|
init_definition();
|
|
4455
|
-
_ReferencesManyResolver = class _ReferencesManyResolver extends
|
|
4387
|
+
_ReferencesManyResolver = class _ReferencesManyResolver extends import_js_service22.Service {
|
|
4456
4388
|
/**
|
|
4457
4389
|
* Include to.
|
|
4458
4390
|
*
|
|
@@ -4554,11 +4486,11 @@ var init_relations2 = __esm({
|
|
|
4554
4486
|
});
|
|
4555
4487
|
|
|
4556
4488
|
// src/filter/include-clause-tool.js
|
|
4557
|
-
var
|
|
4489
|
+
var import_js_service23, _IncludeClauseTool, IncludeClauseTool;
|
|
4558
4490
|
var init_include_clause_tool = __esm({
|
|
4559
4491
|
"src/filter/include-clause-tool.js"() {
|
|
4560
4492
|
"use strict";
|
|
4561
|
-
|
|
4493
|
+
import_js_service23 = require("@e22m4u/js-service");
|
|
4562
4494
|
init_definition();
|
|
4563
4495
|
init_relations2();
|
|
4564
4496
|
init_relations2();
|
|
@@ -4570,7 +4502,7 @@ var init_include_clause_tool = __esm({
|
|
|
4570
4502
|
init_fields_clause_tool();
|
|
4571
4503
|
init_definition();
|
|
4572
4504
|
init_relations2();
|
|
4573
|
-
_IncludeClauseTool = class _IncludeClauseTool extends
|
|
4505
|
+
_IncludeClauseTool = class _IncludeClauseTool extends import_js_service23.Service {
|
|
4574
4506
|
/**
|
|
4575
4507
|
* Include to.
|
|
4576
4508
|
*
|
|
@@ -4907,15 +4839,15 @@ var init_filter = __esm({
|
|
|
4907
4839
|
});
|
|
4908
4840
|
|
|
4909
4841
|
// src/adapter/decorator/inclusion-decorator.js
|
|
4910
|
-
var
|
|
4842
|
+
var import_js_service24, _InclusionDecorator, InclusionDecorator;
|
|
4911
4843
|
var init_inclusion_decorator = __esm({
|
|
4912
4844
|
"src/adapter/decorator/inclusion-decorator.js"() {
|
|
4913
4845
|
"use strict";
|
|
4914
4846
|
init_adapter();
|
|
4915
|
-
|
|
4847
|
+
import_js_service24 = require("@e22m4u/js-service");
|
|
4916
4848
|
init_filter();
|
|
4917
4849
|
init_errors();
|
|
4918
|
-
_InclusionDecorator = class _InclusionDecorator extends
|
|
4850
|
+
_InclusionDecorator = class _InclusionDecorator extends import_js_service24.Service {
|
|
4919
4851
|
/**
|
|
4920
4852
|
* Decorate.
|
|
4921
4853
|
*
|
|
@@ -4996,15 +4928,15 @@ var init_inclusion_decorator = __esm({
|
|
|
4996
4928
|
});
|
|
4997
4929
|
|
|
4998
4930
|
// src/adapter/decorator/default-values-decorator.js
|
|
4999
|
-
var
|
|
4931
|
+
var import_js_service25, _DefaultValuesDecorator, DefaultValuesDecorator;
|
|
5000
4932
|
var init_default_values_decorator = __esm({
|
|
5001
4933
|
"src/adapter/decorator/default-values-decorator.js"() {
|
|
5002
4934
|
"use strict";
|
|
5003
4935
|
init_adapter();
|
|
5004
|
-
|
|
4936
|
+
import_js_service25 = require("@e22m4u/js-service");
|
|
5005
4937
|
init_errors();
|
|
5006
4938
|
init_definition();
|
|
5007
|
-
_DefaultValuesDecorator = class _DefaultValuesDecorator extends
|
|
4939
|
+
_DefaultValuesDecorator = class _DefaultValuesDecorator extends import_js_service25.Service {
|
|
5008
4940
|
/**
|
|
5009
4941
|
* Decorate.
|
|
5010
4942
|
*
|
|
@@ -5061,15 +4993,15 @@ var init_default_values_decorator = __esm({
|
|
|
5061
4993
|
});
|
|
5062
4994
|
|
|
5063
4995
|
// src/adapter/decorator/data-sanitizing-decorator.js
|
|
5064
|
-
var
|
|
4996
|
+
var import_js_service26, _DataSanitizingDecorator, DataSanitizingDecorator;
|
|
5065
4997
|
var init_data_sanitizing_decorator = __esm({
|
|
5066
4998
|
"src/adapter/decorator/data-sanitizing-decorator.js"() {
|
|
5067
4999
|
"use strict";
|
|
5068
5000
|
init_adapter();
|
|
5069
|
-
|
|
5001
|
+
import_js_service26 = require("@e22m4u/js-service");
|
|
5070
5002
|
init_errors();
|
|
5071
5003
|
init_definition();
|
|
5072
|
-
_DataSanitizingDecorator = class _DataSanitizingDecorator extends
|
|
5004
|
+
_DataSanitizingDecorator = class _DataSanitizingDecorator extends import_js_service26.Service {
|
|
5073
5005
|
/**
|
|
5074
5006
|
* Decorate.
|
|
5075
5007
|
*
|
|
@@ -5116,15 +5048,15 @@ var init_data_sanitizing_decorator = __esm({
|
|
|
5116
5048
|
});
|
|
5117
5049
|
|
|
5118
5050
|
// src/adapter/decorator/data-validation-decorator.js
|
|
5119
|
-
var
|
|
5051
|
+
var import_js_service27, _DataValidationDecorator, DataValidationDecorator;
|
|
5120
5052
|
var init_data_validation_decorator = __esm({
|
|
5121
5053
|
"src/adapter/decorator/data-validation-decorator.js"() {
|
|
5122
5054
|
"use strict";
|
|
5123
5055
|
init_adapter();
|
|
5124
|
-
|
|
5056
|
+
import_js_service27 = require("@e22m4u/js-service");
|
|
5125
5057
|
init_errors();
|
|
5126
5058
|
init_definition();
|
|
5127
|
-
_DataValidationDecorator = class _DataValidationDecorator extends
|
|
5059
|
+
_DataValidationDecorator = class _DataValidationDecorator extends import_js_service27.Service {
|
|
5128
5060
|
/**
|
|
5129
5061
|
* Decorate.
|
|
5130
5062
|
*
|
|
@@ -5170,15 +5102,15 @@ var init_data_validation_decorator = __esm({
|
|
|
5170
5102
|
});
|
|
5171
5103
|
|
|
5172
5104
|
// src/adapter/decorator/fields-filtering-decorator.js
|
|
5173
|
-
var
|
|
5105
|
+
var import_js_service28, _FieldsFilteringDecorator, FieldsFilteringDecorator;
|
|
5174
5106
|
var init_fields_filtering_decorator = __esm({
|
|
5175
5107
|
"src/adapter/decorator/fields-filtering-decorator.js"() {
|
|
5176
5108
|
"use strict";
|
|
5177
5109
|
init_adapter();
|
|
5178
|
-
|
|
5110
|
+
import_js_service28 = require("@e22m4u/js-service");
|
|
5179
5111
|
init_filter();
|
|
5180
5112
|
init_errors();
|
|
5181
|
-
_FieldsFilteringDecorator = class _FieldsFilteringDecorator extends
|
|
5113
|
+
_FieldsFilteringDecorator = class _FieldsFilteringDecorator extends import_js_service28.Service {
|
|
5182
5114
|
/**
|
|
5183
5115
|
* Decorate.
|
|
5184
5116
|
*
|
|
@@ -5253,15 +5185,15 @@ var init_fields_filtering_decorator = __esm({
|
|
|
5253
5185
|
});
|
|
5254
5186
|
|
|
5255
5187
|
// src/adapter/decorator/data-transformation-decorator.js
|
|
5256
|
-
var
|
|
5188
|
+
var import_js_service29, _DataTransformationDecorator, DataTransformationDecorator;
|
|
5257
5189
|
var init_data_transformation_decorator = __esm({
|
|
5258
5190
|
"src/adapter/decorator/data-transformation-decorator.js"() {
|
|
5259
5191
|
"use strict";
|
|
5260
5192
|
init_adapter();
|
|
5261
|
-
|
|
5193
|
+
import_js_service29 = require("@e22m4u/js-service");
|
|
5262
5194
|
init_errors();
|
|
5263
5195
|
init_definition();
|
|
5264
|
-
_DataTransformationDecorator = class _DataTransformationDecorator extends
|
|
5196
|
+
_DataTransformationDecorator = class _DataTransformationDecorator extends import_js_service29.Service {
|
|
5265
5197
|
/**
|
|
5266
5198
|
* Decorate.
|
|
5267
5199
|
*
|
|
@@ -5307,15 +5239,15 @@ var init_data_transformation_decorator = __esm({
|
|
|
5307
5239
|
});
|
|
5308
5240
|
|
|
5309
5241
|
// src/adapter/decorator/property-uniqueness-decorator.js
|
|
5310
|
-
var
|
|
5242
|
+
var import_js_service30, _PropertyUniquenessDecorator, PropertyUniquenessDecorator;
|
|
5311
5243
|
var init_property_uniqueness_decorator = __esm({
|
|
5312
5244
|
"src/adapter/decorator/property-uniqueness-decorator.js"() {
|
|
5313
5245
|
"use strict";
|
|
5314
5246
|
init_adapter();
|
|
5315
|
-
|
|
5247
|
+
import_js_service30 = require("@e22m4u/js-service");
|
|
5316
5248
|
init_errors();
|
|
5317
5249
|
init_definition();
|
|
5318
|
-
_PropertyUniquenessDecorator = class _PropertyUniquenessDecorator extends
|
|
5250
|
+
_PropertyUniquenessDecorator = class _PropertyUniquenessDecorator extends import_js_service30.Service {
|
|
5319
5251
|
/**
|
|
5320
5252
|
* Decorate.
|
|
5321
5253
|
*
|
|
@@ -5397,11 +5329,11 @@ var init_decorator = __esm({
|
|
|
5397
5329
|
});
|
|
5398
5330
|
|
|
5399
5331
|
// src/adapter/adapter.js
|
|
5400
|
-
var
|
|
5332
|
+
var import_js_service31, ADAPTER_CLASS_NAME, _Adapter, Adapter;
|
|
5401
5333
|
var init_adapter = __esm({
|
|
5402
5334
|
"src/adapter/adapter.js"() {
|
|
5403
5335
|
"use strict";
|
|
5404
|
-
|
|
5336
|
+
import_js_service31 = require("@e22m4u/js-service");
|
|
5405
5337
|
init_errors();
|
|
5406
5338
|
init_decorator();
|
|
5407
5339
|
init_decorator();
|
|
@@ -5411,7 +5343,7 @@ var init_adapter = __esm({
|
|
|
5411
5343
|
init_decorator();
|
|
5412
5344
|
init_decorator();
|
|
5413
5345
|
ADAPTER_CLASS_NAME = "Adapter";
|
|
5414
|
-
_Adapter = class _Adapter extends
|
|
5346
|
+
_Adapter = class _Adapter extends import_js_service31.Service {
|
|
5415
5347
|
/**
|
|
5416
5348
|
* Settings.
|
|
5417
5349
|
*
|
|
@@ -5603,7 +5535,7 @@ var init_adapter = __esm({
|
|
|
5603
5535
|
*
|
|
5604
5536
|
* @type {string}
|
|
5605
5537
|
*/
|
|
5606
|
-
__publicField(_Adapter, "kinds", [...
|
|
5538
|
+
__publicField(_Adapter, "kinds", [...import_js_service31.Service.kinds, ADAPTER_CLASS_NAME]);
|
|
5607
5539
|
Adapter = _Adapter;
|
|
5608
5540
|
}
|
|
5609
5541
|
});
|
|
@@ -6012,16 +5944,16 @@ function findAdapterCtorInModule(module2) {
|
|
|
6012
5944
|
}
|
|
6013
5945
|
return adapterCtor;
|
|
6014
5946
|
}
|
|
6015
|
-
var
|
|
5947
|
+
var import_js_service32, _AdapterLoader, AdapterLoader;
|
|
6016
5948
|
var init_adapter_loader = __esm({
|
|
6017
5949
|
"src/adapter/adapter-loader.js"() {
|
|
6018
5950
|
"use strict";
|
|
6019
5951
|
init_adapter();
|
|
6020
|
-
|
|
5952
|
+
import_js_service32 = require("@e22m4u/js-service");
|
|
6021
5953
|
init_adapter();
|
|
6022
5954
|
init_errors();
|
|
6023
5955
|
init_();
|
|
6024
|
-
_AdapterLoader = class _AdapterLoader extends
|
|
5956
|
+
_AdapterLoader = class _AdapterLoader extends import_js_service32.Service {
|
|
6025
5957
|
/**
|
|
6026
5958
|
* Load by name.
|
|
6027
5959
|
*
|
|
@@ -6062,15 +5994,15 @@ var init_adapter_loader = __esm({
|
|
|
6062
5994
|
});
|
|
6063
5995
|
|
|
6064
5996
|
// src/adapter/adapter-registry.js
|
|
6065
|
-
var
|
|
5997
|
+
var import_js_service33, _AdapterRegistry, AdapterRegistry;
|
|
6066
5998
|
var init_adapter_registry = __esm({
|
|
6067
5999
|
"src/adapter/adapter-registry.js"() {
|
|
6068
6000
|
"use strict";
|
|
6069
6001
|
init_adapter();
|
|
6070
|
-
|
|
6002
|
+
import_js_service33 = require("@e22m4u/js-service");
|
|
6071
6003
|
init_adapter_loader();
|
|
6072
6004
|
init_definition();
|
|
6073
|
-
_AdapterRegistry = class _AdapterRegistry extends
|
|
6005
|
+
_AdapterRegistry = class _AdapterRegistry extends import_js_service33.Service {
|
|
6074
6006
|
/**
|
|
6075
6007
|
* Adapters.
|
|
6076
6008
|
*
|
|
@@ -6112,16 +6044,16 @@ var init_adapter2 = __esm({
|
|
|
6112
6044
|
});
|
|
6113
6045
|
|
|
6114
6046
|
// src/repository/repository.js
|
|
6115
|
-
var
|
|
6047
|
+
var import_js_service34, _Repository, Repository;
|
|
6116
6048
|
var init_repository = __esm({
|
|
6117
6049
|
"src/repository/repository.js"() {
|
|
6118
6050
|
"use strict";
|
|
6119
|
-
|
|
6051
|
+
import_js_service34 = require("@e22m4u/js-service");
|
|
6120
6052
|
init_adapter2();
|
|
6121
6053
|
init_adapter2();
|
|
6122
6054
|
init_errors();
|
|
6123
6055
|
init_definition();
|
|
6124
|
-
_Repository = class _Repository extends
|
|
6056
|
+
_Repository = class _Repository extends import_js_service34.Service {
|
|
6125
6057
|
/**
|
|
6126
6058
|
* Model name.
|
|
6127
6059
|
*
|
|
@@ -6315,14 +6247,14 @@ var init_repository = __esm({
|
|
|
6315
6247
|
});
|
|
6316
6248
|
|
|
6317
6249
|
// src/repository/repository-registry.js
|
|
6318
|
-
var
|
|
6250
|
+
var import_js_service35, _RepositoryRegistry, RepositoryRegistry;
|
|
6319
6251
|
var init_repository_registry = __esm({
|
|
6320
6252
|
"src/repository/repository-registry.js"() {
|
|
6321
6253
|
"use strict";
|
|
6322
|
-
|
|
6254
|
+
import_js_service35 = require("@e22m4u/js-service");
|
|
6323
6255
|
init_repository();
|
|
6324
6256
|
init_errors();
|
|
6325
|
-
_RepositoryRegistry = class _RepositoryRegistry extends
|
|
6257
|
+
_RepositoryRegistry = class _RepositoryRegistry extends import_js_service35.Service {
|
|
6326
6258
|
/**
|
|
6327
6259
|
* Repositories.
|
|
6328
6260
|
*
|
|
@@ -6391,7 +6323,6 @@ __export(index_exports, {
|
|
|
6391
6323
|
DatasourceDefinitionValidator: () => DatasourceDefinitionValidator,
|
|
6392
6324
|
DecoratorTargetType: () => DecoratorTargetType,
|
|
6393
6325
|
DefinitionRegistry: () => DefinitionRegistry,
|
|
6394
|
-
EmptyValuesDefiner: () => EmptyValuesDefiner,
|
|
6395
6326
|
FieldsClauseTool: () => FieldsClauseTool,
|
|
6396
6327
|
HasManyResolver: () => HasManyResolver,
|
|
6397
6328
|
HasOneResolver: () => HasOneResolver,
|
|
@@ -6438,11 +6369,11 @@ __export(index_exports, {
|
|
|
6438
6369
|
module.exports = __toCommonJS(index_exports);
|
|
6439
6370
|
|
|
6440
6371
|
// src/schema.js
|
|
6441
|
-
var
|
|
6372
|
+
var import_js_service36 = require("@e22m4u/js-service");
|
|
6442
6373
|
init_repository2();
|
|
6443
6374
|
init_definition();
|
|
6444
6375
|
init_repository2();
|
|
6445
|
-
var _Schema = class _Schema extends
|
|
6376
|
+
var _Schema = class _Schema extends import_js_service36.Service {
|
|
6446
6377
|
/**
|
|
6447
6378
|
* Define datasource.
|
|
6448
6379
|
*
|
|
@@ -6496,7 +6427,6 @@ init_repository2();
|
|
|
6496
6427
|
DatasourceDefinitionValidator,
|
|
6497
6428
|
DecoratorTargetType,
|
|
6498
6429
|
DefinitionRegistry,
|
|
6499
|
-
EmptyValuesDefiner,
|
|
6500
6430
|
FieldsClauseTool,
|
|
6501
6431
|
HasManyResolver,
|
|
6502
6432
|
HasOneResolver,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e22m4u/js-repository",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Реализация репозитория для работы с базами данных в Node.js",
|
|
5
5
|
"author": "e22m4u <e22m4u@yandex.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
"build:cjs": "rimraf ./dist/cjs && node --no-warnings=ExperimentalWarning build-cjs.js",
|
|
39
39
|
"prepare": "husky"
|
|
40
40
|
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@e22m4u/js-empty-values": "~0.0.1"
|
|
43
|
+
},
|
|
41
44
|
"peerDependencies": {
|
|
42
45
|
"@e22m4u/js-format": "~0.1.0",
|
|
43
46
|
"@e22m4u/js-service": "~0.2.0"
|
|
@@ -2,7 +2,7 @@ import {Service} from '@e22m4u/js-service';
|
|
|
2
2
|
import {cloneDeep} from '../../utils/index.js';
|
|
3
3
|
import {isPureObject} from '../../utils/index.js';
|
|
4
4
|
import {transformPromise} from '../../utils/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import {EmptyValuesService} from '@e22m4u/js-empty-values';
|
|
6
6
|
import {InvalidArgumentError} from '../../errors/index.js';
|
|
7
7
|
import {ModelDefinitionUtils} from './model-definition-utils.js';
|
|
8
8
|
import {PropertyTransformerRegistry} from './properties/index.js';
|
|
@@ -26,7 +26,7 @@ export class ModelDataTransformer extends Service {
|
|
|
26
26
|
modelName,
|
|
27
27
|
modelData,
|
|
28
28
|
);
|
|
29
|
-
const
|
|
29
|
+
const emptyValuesService = this.getService(EmptyValuesService);
|
|
30
30
|
const modelDefinitionUtils = this.getService(ModelDefinitionUtils);
|
|
31
31
|
const propDefs =
|
|
32
32
|
modelDefinitionUtils.getPropertiesDefinitionInBaseModelHierarchy(
|
|
@@ -40,7 +40,7 @@ export class ModelDataTransformer extends Service {
|
|
|
40
40
|
const propType =
|
|
41
41
|
modelDefinitionUtils.getDataTypeFromPropertyDefinition(propDef);
|
|
42
42
|
const propValue = modelData[propName];
|
|
43
|
-
const isEmpty =
|
|
43
|
+
const isEmpty = emptyValuesService.isEmptyByType(propType, propValue);
|
|
44
44
|
if (isEmpty) return transformedDataOrPromise;
|
|
45
45
|
const newPropValueOrPromise = this._transformPropertyValue(
|
|
46
46
|
modelName,
|
|
@@ -2,7 +2,7 @@ import {Service} from '@e22m4u/js-service';
|
|
|
2
2
|
import {DataType} from './properties/index.js';
|
|
3
3
|
import {getCtorName} from '../../utils/index.js';
|
|
4
4
|
import {isPureObject} from '../../utils/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import {EmptyValuesService} from '@e22m4u/js-empty-values';
|
|
6
6
|
import {InvalidArgumentError} from '../../errors/index.js';
|
|
7
7
|
import {PropertyValidatorRegistry} from './properties/index.js';
|
|
8
8
|
import {ModelDefinitionUtils} from './model-definition-utils.js';
|
|
@@ -57,7 +57,7 @@ export class ModelDataValidator extends Service {
|
|
|
57
57
|
this.getService(ModelDefinitionUtils).getDataTypeFromPropertyDefinition(
|
|
58
58
|
propDef,
|
|
59
59
|
);
|
|
60
|
-
const isEmpty = this.getService(
|
|
60
|
+
const isEmpty = this.getService(EmptyValuesService).isEmptyByType(
|
|
61
61
|
propType,
|
|
62
62
|
propValue,
|
|
63
63
|
);
|
|
@@ -2,7 +2,7 @@ import {expect} from 'chai';
|
|
|
2
2
|
import {Schema} from '../../schema.js';
|
|
3
3
|
import {format} from '@e22m4u/js-format';
|
|
4
4
|
import {DataType} from './properties/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import {EmptyValuesService} from '@e22m4u/js-empty-values';
|
|
6
6
|
import {ModelDataValidator} from './model-data-validator.js';
|
|
7
7
|
import {DefinitionRegistry} from '../definition-registry.js';
|
|
8
8
|
import {PropertyValidatorRegistry} from './properties/index.js';
|
|
@@ -127,7 +127,7 @@ describe('ModelDataValidator', function () {
|
|
|
127
127
|
},
|
|
128
128
|
});
|
|
129
129
|
schema
|
|
130
|
-
.getService(
|
|
130
|
+
.getService(EmptyValuesService)
|
|
131
131
|
.setEmptyValuesOf(DataType.STRING, ['empty']);
|
|
132
132
|
const throwable = () =>
|
|
133
133
|
schema.getService(ModelDataValidator).validate('model', {foo: 'empty'});
|
|
@@ -205,7 +205,7 @@ describe('ModelDataValidator', function () {
|
|
|
205
205
|
},
|
|
206
206
|
});
|
|
207
207
|
schema
|
|
208
|
-
.getService(
|
|
208
|
+
.getService(EmptyValuesService)
|
|
209
209
|
.setEmptyValuesOf(DataType.STRING, [5]);
|
|
210
210
|
const throwable = () =>
|
|
211
211
|
schema
|
|
@@ -229,7 +229,7 @@ describe('ModelDataValidator', function () {
|
|
|
229
229
|
},
|
|
230
230
|
},
|
|
231
231
|
});
|
|
232
|
-
S.getService(
|
|
232
|
+
S.getService(EmptyValuesService).setEmptyValuesOf(DataType.STRING, [5]);
|
|
233
233
|
S.getService(ModelDataValidator).validate('model', {foo: 5});
|
|
234
234
|
});
|
|
235
235
|
|
|
@@ -2089,7 +2089,7 @@ describe('ModelDataValidator', function () {
|
|
|
2089
2089
|
},
|
|
2090
2090
|
},
|
|
2091
2091
|
});
|
|
2092
|
-
S.getService(
|
|
2092
|
+
S.getService(EmptyValuesService).setEmptyValuesOf(DataType.STRING, [5]);
|
|
2093
2093
|
S.getService(ModelDataValidator).validate('model', {foo: 5});
|
|
2094
2094
|
});
|
|
2095
2095
|
|
|
@@ -2,7 +2,7 @@ import {Service} from '@e22m4u/js-service';
|
|
|
2
2
|
import {DataType} from './properties/index.js';
|
|
3
3
|
import {cloneDeep} from '../../utils/index.js';
|
|
4
4
|
import {excludeObjectKeys} from '../../utils/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import {EmptyValuesService} from '@e22m4u/js-empty-values';
|
|
6
6
|
import {InvalidArgumentError} from '../../errors/index.js';
|
|
7
7
|
import {DefinitionRegistry} from '../definition-registry.js';
|
|
8
8
|
|
|
@@ -140,7 +140,7 @@ export class ModelDefinitionUtils extends Service {
|
|
|
140
140
|
? Object.keys(modelData)
|
|
141
141
|
: Object.keys(propDefs);
|
|
142
142
|
const extendedData = cloneDeep(modelData);
|
|
143
|
-
const
|
|
143
|
+
const emptyValuesService = this.getService(EmptyValuesService);
|
|
144
144
|
propNames.forEach(propName => {
|
|
145
145
|
const propDef = propDefs[propName];
|
|
146
146
|
const propValue = extendedData[propName];
|
|
@@ -148,7 +148,7 @@ export class ModelDefinitionUtils extends Service {
|
|
|
148
148
|
propDef != null
|
|
149
149
|
? this.getDataTypeFromPropertyDefinition(propDef)
|
|
150
150
|
: DataType.ANY;
|
|
151
|
-
const isEmpty =
|
|
151
|
+
const isEmpty = emptyValuesService.isEmptyByType(propType, propValue);
|
|
152
152
|
if (!isEmpty) return;
|
|
153
153
|
if (
|
|
154
154
|
propDef &&
|
|
@@ -4,7 +4,7 @@ import {Schema} from '../../schema.js';
|
|
|
4
4
|
import {format} from '@e22m4u/js-format';
|
|
5
5
|
import {DataType} from './properties/index.js';
|
|
6
6
|
import {RelationType} from './relations/index.js';
|
|
7
|
-
import {
|
|
7
|
+
import {EmptyValuesService} from '@e22m4u/js-empty-values';
|
|
8
8
|
import {InvalidArgumentError} from '../../errors/index.js';
|
|
9
9
|
import {ModelDefinitionUtils} from './model-definition-utils.js';
|
|
10
10
|
import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from './model-definition-utils.js';
|
|
@@ -489,7 +489,7 @@ describe('ModelDefinitionUtils', function () {
|
|
|
489
489
|
},
|
|
490
490
|
});
|
|
491
491
|
schema
|
|
492
|
-
.getService(
|
|
492
|
+
.getService(EmptyValuesService)
|
|
493
493
|
.setEmptyValuesOf(DataType.STRING, ['empty']);
|
|
494
494
|
const result = schema
|
|
495
495
|
.getService(ModelDefinitionUtils)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './data-type.js';
|
|
2
2
|
export * from './property-definition.js';
|
|
3
3
|
export * from './property-uniqueness.js';
|
|
4
|
-
export * from './empty-values-definer.js';
|
|
5
4
|
export * from './property-validator/index.js';
|
|
6
5
|
export * from './property-transformer/index.js';
|
|
7
6
|
export * from './property-uniqueness-validator.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './data-type.js';
|
|
2
2
|
export * from './property-definition.js';
|
|
3
3
|
export * from './property-uniqueness.js';
|
|
4
|
-
export * from './empty-values-definer.js';
|
|
5
4
|
export * from './property-validator/index.js';
|
|
6
5
|
export * from './property-transformer/index.js';
|
|
7
6
|
export * from './property-uniqueness-validator.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {DataType} from './data-type.js';
|
|
2
2
|
import {Service} from '@e22m4u/js-service';
|
|
3
3
|
import {isPureObject} from '../../../utils/index.js';
|
|
4
|
+
import {EmptyValuesService} from '@e22m4u/js-empty-values';
|
|
4
5
|
import {PropertyUniqueness} from './property-uniqueness.js';
|
|
5
|
-
import {EmptyValuesDefiner} from './empty-values-definer.js';
|
|
6
6
|
import {InvalidArgumentError} from '../../../errors/index.js';
|
|
7
7
|
import {ModelDefinitionUtils} from '../model-definition-utils.js';
|
|
8
8
|
|
|
@@ -70,7 +70,7 @@ export class PropertyUniquenessValidator extends Service {
|
|
|
70
70
|
propValue,
|
|
71
71
|
);
|
|
72
72
|
let willBeReplaced = undefined;
|
|
73
|
-
const
|
|
73
|
+
const emptyValuesService = this.getService(EmptyValuesService);
|
|
74
74
|
for (const propName of propNames) {
|
|
75
75
|
const propDef = propDefs[propName];
|
|
76
76
|
if (
|
|
@@ -85,7 +85,7 @@ export class PropertyUniquenessValidator extends Service {
|
|
|
85
85
|
const propValue = modelData[propName];
|
|
86
86
|
if (propDef.unique === PropertyUniqueness.SPARSE) {
|
|
87
87
|
const propType = propDef.type || DataType.ANY;
|
|
88
|
-
const isEmpty =
|
|
88
|
+
const isEmpty = emptyValuesService.isEmptyByType(propType, propValue);
|
|
89
89
|
if (isEmpty) continue;
|
|
90
90
|
}
|
|
91
91
|
// create
|
|
@@ -2,8 +2,8 @@ import {expect} from 'chai';
|
|
|
2
2
|
import {DataType} from './data-type.js';
|
|
3
3
|
import {format} from '@e22m4u/js-format';
|
|
4
4
|
import {Schema} from '../../../schema.js';
|
|
5
|
+
import {EmptyValuesService} from '@e22m4u/js-empty-values';
|
|
5
6
|
import {PropertyUniqueness} from './property-uniqueness.js';
|
|
6
|
-
import {EmptyValuesDefiner} from './empty-values-definer.js';
|
|
7
7
|
import {PropertyUniquenessValidator} from './property-uniqueness-validator.js';
|
|
8
8
|
import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../model-definition-utils.js';
|
|
9
9
|
|
|
@@ -1856,7 +1856,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1856
1856
|
const S = schema.getService(PropertyUniquenessValidator);
|
|
1857
1857
|
let invoked = 0;
|
|
1858
1858
|
schema
|
|
1859
|
-
.getService(
|
|
1859
|
+
.getService(EmptyValuesService)
|
|
1860
1860
|
.setEmptyValuesOf(DataType.STRING, ['val2']);
|
|
1861
1861
|
const modelData = {foo: 'val1', bar: 'val2'};
|
|
1862
1862
|
const countMethod = where => {
|
|
@@ -1970,7 +1970,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1970
1970
|
const S = schema.getService(PropertyUniquenessValidator);
|
|
1971
1971
|
let invoked = 0;
|
|
1972
1972
|
schema
|
|
1973
|
-
.getService(
|
|
1973
|
+
.getService(EmptyValuesService)
|
|
1974
1974
|
.setEmptyValuesOf(DataType.STRING, ['val2']);
|
|
1975
1975
|
const idValue = 1;
|
|
1976
1976
|
const modelData = {foo: 'val1', bar: 'val2'};
|
|
@@ -2229,7 +2229,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
2229
2229
|
});
|
|
2230
2230
|
const S = schema.getService(PropertyUniquenessValidator);
|
|
2231
2231
|
schema
|
|
2232
|
-
.getService(
|
|
2232
|
+
.getService(EmptyValuesService)
|
|
2233
2233
|
.setEmptyValuesOf(DataType.STRING, ['val2']);
|
|
2234
2234
|
let invoked = 0;
|
|
2235
2235
|
const idValue = 1;
|
|
@@ -2408,7 +2408,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
2408
2408
|
});
|
|
2409
2409
|
const S = schema.getService(PropertyUniquenessValidator);
|
|
2410
2410
|
schema
|
|
2411
|
-
.getService(
|
|
2411
|
+
.getService(EmptyValuesService)
|
|
2412
2412
|
.setEmptyValuesOf(DataType.STRING, ['val2']);
|
|
2413
2413
|
let invoked = 0;
|
|
2414
2414
|
const idValue = 1;
|
|
@@ -2542,7 +2542,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
2542
2542
|
});
|
|
2543
2543
|
const S = schema.getService(PropertyUniquenessValidator);
|
|
2544
2544
|
schema
|
|
2545
|
-
.getService(
|
|
2545
|
+
.getService(EmptyValuesService)
|
|
2546
2546
|
.setEmptyValuesOf(DataType.STRING, ['val2']);
|
|
2547
2547
|
let invoked = 0;
|
|
2548
2548
|
const modelData = {foo: 'val1', bar: 'val2'};
|
|
@@ -2682,7 +2682,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
2682
2682
|
const S = schema.getService(PropertyUniquenessValidator);
|
|
2683
2683
|
let invoked = 0;
|
|
2684
2684
|
schema
|
|
2685
|
-
.getService(
|
|
2685
|
+
.getService(EmptyValuesService)
|
|
2686
2686
|
.setEmptyValuesOf(DataType.STRING, ['val2']);
|
|
2687
2687
|
const modelData = {foo: 'val1', bar: 'val2'};
|
|
2688
2688
|
const countMethod = where => {
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {DataType} from './data-type.js';
|
|
2
|
-
import {Service} from '@e22m4u/js-service';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Empty values definer.
|
|
6
|
-
*/
|
|
7
|
-
export class EmptyValuesDefiner extends Service {
|
|
8
|
-
/**
|
|
9
|
-
* Set empty values of.
|
|
10
|
-
*
|
|
11
|
-
* @param dataType
|
|
12
|
-
* @param emptyValues
|
|
13
|
-
*/
|
|
14
|
-
setEmptyValuesOf(dataType: DataType, emptyValues: unknown[]): this;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Is empty.
|
|
18
|
-
*
|
|
19
|
-
* @param dataType
|
|
20
|
-
* @param value
|
|
21
|
-
*/
|
|
22
|
-
isEmpty(dataType: DataType, value: unknown): boolean;
|
|
23
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {DataType} from './data-type.js';
|
|
2
|
-
import {Service} from '@e22m4u/js-service';
|
|
3
|
-
import {isDeepEqual} from '../../../utils/index.js';
|
|
4
|
-
import {InvalidArgumentError} from '../../../errors/index.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Empty values definer.
|
|
8
|
-
*/
|
|
9
|
-
export class EmptyValuesDefiner extends Service {
|
|
10
|
-
/**
|
|
11
|
-
* Empty values map.
|
|
12
|
-
*
|
|
13
|
-
* @type {Map<string, *[]>}
|
|
14
|
-
*/
|
|
15
|
-
_emptyValuesMap = new Map([
|
|
16
|
-
[DataType.ANY, [undefined, null]],
|
|
17
|
-
[DataType.STRING, [undefined, null, '']],
|
|
18
|
-
[DataType.NUMBER, [undefined, null, 0]],
|
|
19
|
-
[DataType.BOOLEAN, [undefined, null]],
|
|
20
|
-
[DataType.ARRAY, [undefined, null, []]],
|
|
21
|
-
[DataType.OBJECT, [undefined, null, {}]],
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Set empty values of data type.
|
|
26
|
-
*
|
|
27
|
-
* @param {string} dataType
|
|
28
|
-
* @param {*[]} emptyValues
|
|
29
|
-
* @returns {EmptyValuesDefiner}
|
|
30
|
-
*/
|
|
31
|
-
setEmptyValuesOf(dataType, emptyValues) {
|
|
32
|
-
if (!Object.values(DataType).includes(dataType))
|
|
33
|
-
throw new InvalidArgumentError(
|
|
34
|
-
'The argument "dataType" of the EmptyValuesDefiner.setEmptyValuesOf ' +
|
|
35
|
-
'must be one of data types: %l, but %v given.',
|
|
36
|
-
Object.values(DataType),
|
|
37
|
-
dataType,
|
|
38
|
-
);
|
|
39
|
-
if (!Array.isArray(emptyValues))
|
|
40
|
-
throw new InvalidArgumentError(
|
|
41
|
-
'The argument "emptyValues" of the EmptyValuesDefiner.setEmptyValuesOf ' +
|
|
42
|
-
'must be an Array, but %v given.',
|
|
43
|
-
emptyValues,
|
|
44
|
-
);
|
|
45
|
-
this._emptyValuesMap.set(dataType, emptyValues);
|
|
46
|
-
return this;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Is empty.
|
|
51
|
-
*
|
|
52
|
-
* @param {string} dataType
|
|
53
|
-
* @param {*} value
|
|
54
|
-
* @returns {boolean}
|
|
55
|
-
*/
|
|
56
|
-
isEmpty(dataType, value) {
|
|
57
|
-
if (!Object.values(DataType).includes(dataType))
|
|
58
|
-
throw new InvalidArgumentError(
|
|
59
|
-
'The argument "dataType" of the EmptyValuesDefiner.isEmpty ' +
|
|
60
|
-
'must be one of data types: %l, but %v given.',
|
|
61
|
-
Object.values(DataType),
|
|
62
|
-
dataType,
|
|
63
|
-
);
|
|
64
|
-
return this._emptyValuesMap.get(dataType).some(v => isDeepEqual(v, value));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import {expect} from 'chai';
|
|
2
|
-
import {DataType} from './data-type.js';
|
|
3
|
-
import {format} from '@e22m4u/js-format';
|
|
4
|
-
import {Schema} from '../../../schema.js';
|
|
5
|
-
import {EmptyValuesDefiner} from './empty-values-definer.js';
|
|
6
|
-
|
|
7
|
-
const getEmptyValues = (definer, dataType) => {
|
|
8
|
-
return definer['_emptyValuesMap'].get(dataType);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
describe('EmptyValuesDefiner', function () {
|
|
12
|
-
describe('_emptyValuesMap', function () {
|
|
13
|
-
it('has default values', function () {
|
|
14
|
-
const schema = new Schema();
|
|
15
|
-
const S = schema.getService(EmptyValuesDefiner);
|
|
16
|
-
expect(Array.from(S['_emptyValuesMap'])).to.be.eql([
|
|
17
|
-
[DataType.ANY, [undefined, null]],
|
|
18
|
-
[DataType.STRING, [undefined, null, '']],
|
|
19
|
-
[DataType.NUMBER, [undefined, null, 0]],
|
|
20
|
-
[DataType.BOOLEAN, [undefined, null]],
|
|
21
|
-
[DataType.ARRAY, [undefined, null, []]],
|
|
22
|
-
[DataType.OBJECT, [undefined, null, {}]],
|
|
23
|
-
]);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
describe('setEmptyValuesOf', function () {
|
|
28
|
-
it('requires the parameter "dataType" to be a DataType enum', function () {
|
|
29
|
-
const schema = new Schema();
|
|
30
|
-
const S = schema.getService(EmptyValuesDefiner);
|
|
31
|
-
const throwable = v => () => S.setEmptyValuesOf(v, []);
|
|
32
|
-
const error = v =>
|
|
33
|
-
format(
|
|
34
|
-
'The argument "dataType" of the EmptyValuesDefiner.setEmptyValuesOf ' +
|
|
35
|
-
'must be one of data types: %l, but %s given.',
|
|
36
|
-
Object.values(DataType),
|
|
37
|
-
v,
|
|
38
|
-
);
|
|
39
|
-
expect(throwable('str')).to.throw(error('"str"'));
|
|
40
|
-
expect(throwable('')).to.throw(error('""'));
|
|
41
|
-
expect(throwable(10)).to.throw(error('10'));
|
|
42
|
-
expect(throwable(0)).to.throw(error('0'));
|
|
43
|
-
expect(throwable(true)).to.throw(error('true'));
|
|
44
|
-
expect(throwable(false)).to.throw(error('false'));
|
|
45
|
-
expect(throwable(undefined)).to.throw(error('undefined'));
|
|
46
|
-
expect(throwable(null)).to.throw(error('null'));
|
|
47
|
-
expect(throwable({})).to.throw(error('Object'));
|
|
48
|
-
expect(throwable([])).to.throw(error('Array'));
|
|
49
|
-
throwable(DataType.ANY)();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('requires the parameter "emptyValues" to be an Array', function () {
|
|
53
|
-
const schema = new Schema();
|
|
54
|
-
const S = schema.getService(EmptyValuesDefiner);
|
|
55
|
-
const throwable = v => () => S.setEmptyValuesOf(DataType.ANY, v);
|
|
56
|
-
const error = v =>
|
|
57
|
-
format(
|
|
58
|
-
'The argument "emptyValues" of the EmptyValuesDefiner.setEmptyValuesOf ' +
|
|
59
|
-
'must be an Array, but %s given.',
|
|
60
|
-
v,
|
|
61
|
-
);
|
|
62
|
-
expect(throwable('str')).to.throw(error('"str"'));
|
|
63
|
-
expect(throwable('')).to.throw(error('""'));
|
|
64
|
-
expect(throwable(10)).to.throw(error('10'));
|
|
65
|
-
expect(throwable(0)).to.throw(error('0'));
|
|
66
|
-
expect(throwable(true)).to.throw(error('true'));
|
|
67
|
-
expect(throwable(false)).to.throw(error('false'));
|
|
68
|
-
expect(throwable(undefined)).to.throw(error('undefined'));
|
|
69
|
-
expect(throwable(null)).to.throw(error('null'));
|
|
70
|
-
expect(throwable({})).to.throw(error('Object'));
|
|
71
|
-
throwable([])();
|
|
72
|
-
throwable([1, 2, 3])();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('overrides default values of the given data type', function () {
|
|
76
|
-
const schema = new Schema();
|
|
77
|
-
const S = schema.getService(EmptyValuesDefiner);
|
|
78
|
-
expect(getEmptyValues(S, DataType.ANY)).eql([undefined, null]);
|
|
79
|
-
S.setEmptyValuesOf(DataType.ANY, [1, 2, 3]);
|
|
80
|
-
expect(getEmptyValues(S, DataType.ANY)).eql([1, 2, 3]);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
describe('isEmpty', function () {
|
|
85
|
-
it('returns true if the given value exists in the given type', function () {
|
|
86
|
-
const schema = new Schema();
|
|
87
|
-
const S = schema.getService(EmptyValuesDefiner);
|
|
88
|
-
S.setEmptyValuesOf(DataType.ANY, []);
|
|
89
|
-
expect(S.isEmpty(DataType.ANY, 'foo')).to.be.false;
|
|
90
|
-
S.setEmptyValuesOf(DataType.ANY, ['bar']);
|
|
91
|
-
expect(S.isEmpty(DataType.ANY, 'foo')).to.be.false;
|
|
92
|
-
S.setEmptyValuesOf(DataType.ANY, ['bar', 'foo']);
|
|
93
|
-
expect(S.isEmpty(DataType.ANY, 'foo')).to.be.true;
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
});
|