@e22m4u/js-repository 0.8.3 → 0.8.5
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/README.md +68 -148
- package/dist/cjs/index.cjs +207 -83
- package/package.json +3 -4
- package/src/adapter/adapter.js +2 -0
- package/src/adapter/adapter.spec.js +39 -41
- package/src/adapter/decorator/index.d.ts +1 -0
- package/src/adapter/decorator/index.js +1 -0
- package/src/adapter/decorator/required-property-decorator.d.ts +14 -0
- package/src/adapter/decorator/required-property-decorator.js +54 -0
- package/src/adapter/decorator/required-property-decorator.spec.js +105 -0
- package/src/definition/model/model-definition-utils.js +6 -9
- package/src/definition/model/model-definition-utils.spec.js +2 -6
- package/src/definition/model/properties/index.d.ts +1 -0
- package/src/definition/model/properties/index.js +1 -0
- package/src/definition/model/properties/property-uniqueness-validator.js +4 -8
- package/src/definition/model/properties/property-uniqueness-validator.spec.js +229 -31
- package/src/definition/model/properties/required-property-validator.d.ts +15 -0
- package/src/definition/model/properties/required-property-validator.js +90 -0
- package/src/definition/model/properties/required-property-validator.spec.js +544 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -1758,13 +1758,12 @@ var init_definition_registry = __esm({
|
|
|
1758
1758
|
});
|
|
1759
1759
|
|
|
1760
1760
|
// src/definition/model/model-definition-utils.js
|
|
1761
|
-
var import_js_service7,
|
|
1761
|
+
var import_js_service7, DEFAULT_PRIMARY_KEY_PROPERTY_NAME, _ModelDefinitionUtils, ModelDefinitionUtils;
|
|
1762
1762
|
var init_model_definition_utils = __esm({
|
|
1763
1763
|
"src/definition/model/model-definition-utils.js"() {
|
|
1764
1764
|
"use strict";
|
|
1765
1765
|
import_js_service7 = require("@e22m4u/js-service");
|
|
1766
1766
|
init_properties();
|
|
1767
|
-
import_js_empty_values = require("@e22m4u/js-empty-values");
|
|
1768
1767
|
init_errors();
|
|
1769
1768
|
init_definition_registry();
|
|
1770
1769
|
init_utils();
|
|
@@ -1865,7 +1864,7 @@ var init_model_definition_utils = __esm({
|
|
|
1865
1864
|
return propDef.default instanceof Function ? propDef.default() : propDef.default;
|
|
1866
1865
|
}
|
|
1867
1866
|
/**
|
|
1868
|
-
* Set default values
|
|
1867
|
+
* Set default values to empty properties.
|
|
1869
1868
|
*
|
|
1870
1869
|
* @param {string} modelName
|
|
1871
1870
|
* @param {object} modelData
|
|
@@ -1876,13 +1875,12 @@ var init_model_definition_utils = __esm({
|
|
|
1876
1875
|
const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
|
|
1877
1876
|
const propNames = onlyProvidedProperties ? Object.keys(modelData) : Object.keys(propDefs);
|
|
1878
1877
|
const extendedData = cloneDeep(modelData);
|
|
1879
|
-
const emptyValuesService = this.getService(import_js_empty_values.EmptyValuesService);
|
|
1880
1878
|
propNames.forEach((propName) => {
|
|
1881
1879
|
const propDef = propDefs[propName];
|
|
1882
1880
|
const propValue = extendedData[propName];
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1881
|
+
if (propValue != null) {
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1886
1884
|
if (propDef && typeof propDef === "object" && propDef.default !== void 0) {
|
|
1887
1885
|
extendedData[propName] = this.getDefaultPropertyValue(
|
|
1888
1886
|
modelName,
|
|
@@ -2170,19 +2168,89 @@ var init_model_definition_utils = __esm({
|
|
|
2170
2168
|
}
|
|
2171
2169
|
});
|
|
2172
2170
|
|
|
2171
|
+
// src/definition/model/properties/required-property-validator.js
|
|
2172
|
+
var import_js_service8, _RequiredPropertyValidator, RequiredPropertyValidator;
|
|
2173
|
+
var init_required_property_validator = __esm({
|
|
2174
|
+
"src/definition/model/properties/required-property-validator.js"() {
|
|
2175
|
+
"use strict";
|
|
2176
|
+
init_data_type();
|
|
2177
|
+
import_js_service8 = require("@e22m4u/js-service");
|
|
2178
|
+
init_errors();
|
|
2179
|
+
init_model_definition_utils();
|
|
2180
|
+
_RequiredPropertyValidator = class _RequiredPropertyValidator extends import_js_service8.Service {
|
|
2181
|
+
/**
|
|
2182
|
+
* Validate.
|
|
2183
|
+
*
|
|
2184
|
+
* @param {string} modelName
|
|
2185
|
+
* @param {object} modelData
|
|
2186
|
+
* @param {boolean} [isPartial]
|
|
2187
|
+
*/
|
|
2188
|
+
validate(modelName, modelData, isPartial = false) {
|
|
2189
|
+
if (!modelName || typeof modelName !== "string") {
|
|
2190
|
+
throw new InvalidArgumentError(
|
|
2191
|
+
'Parameter "modelName" must be a non-empty String, but %v was given.',
|
|
2192
|
+
modelName
|
|
2193
|
+
);
|
|
2194
|
+
}
|
|
2195
|
+
if (!modelData || typeof modelData !== "object" || Array.isArray(modelData)) {
|
|
2196
|
+
throw new InvalidArgumentError(
|
|
2197
|
+
"Data of the model %v should be an Object, but %v was given.",
|
|
2198
|
+
modelName,
|
|
2199
|
+
modelData
|
|
2200
|
+
);
|
|
2201
|
+
}
|
|
2202
|
+
if (typeof isPartial !== "boolean") {
|
|
2203
|
+
throw new InvalidArgumentError(
|
|
2204
|
+
'Parameter "isPartial" must be a Boolean, but %v was given.',
|
|
2205
|
+
isPartial
|
|
2206
|
+
);
|
|
2207
|
+
}
|
|
2208
|
+
const propDefs = this.getService(
|
|
2209
|
+
ModelDefinitionUtils
|
|
2210
|
+
).getPropertiesDefinitionInBaseModelHierarchy(modelName);
|
|
2211
|
+
const propNames = Object.keys(isPartial ? modelData : propDefs);
|
|
2212
|
+
for (const propName of propNames) {
|
|
2213
|
+
const propDef = propDefs[propName];
|
|
2214
|
+
if (!propDef || typeof propDef !== "object") {
|
|
2215
|
+
continue;
|
|
2216
|
+
}
|
|
2217
|
+
const propValue = modelData[propName];
|
|
2218
|
+
if (propDef.required && propValue == null) {
|
|
2219
|
+
throw new InvalidArgumentError(
|
|
2220
|
+
"Property %v of the model %v is required, but %v was given.",
|
|
2221
|
+
propName,
|
|
2222
|
+
modelName,
|
|
2223
|
+
propValue
|
|
2224
|
+
);
|
|
2225
|
+
}
|
|
2226
|
+
if (propDef.type === DataType.OBJECT && propDef.model && propValue !== null && typeof propValue === "object" && !Array.isArray(propValue)) {
|
|
2227
|
+
this.validate(propDef.model, propValue);
|
|
2228
|
+
} else if (propDef.type === DataType.ARRAY && propDef.itemType === DataType.OBJECT && propDef.itemModel && Array.isArray(propValue)) {
|
|
2229
|
+
propValue.forEach((itemData) => {
|
|
2230
|
+
if (itemData !== null && typeof itemData === "object" && !Array.isArray(itemData)) {
|
|
2231
|
+
this.validate(propDef.itemModel, itemData);
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
};
|
|
2238
|
+
__name(_RequiredPropertyValidator, "RequiredPropertyValidator");
|
|
2239
|
+
RequiredPropertyValidator = _RequiredPropertyValidator;
|
|
2240
|
+
}
|
|
2241
|
+
});
|
|
2242
|
+
|
|
2173
2243
|
// src/definition/model/properties/property-uniqueness-validator.js
|
|
2174
|
-
var
|
|
2244
|
+
var import_js_service9, _PropertyUniquenessValidator, PropertyUniquenessValidator;
|
|
2175
2245
|
var init_property_uniqueness_validator = __esm({
|
|
2176
2246
|
"src/definition/model/properties/property-uniqueness-validator.js"() {
|
|
2177
2247
|
"use strict";
|
|
2178
|
-
|
|
2179
|
-
import_js_service8 = require("@e22m4u/js-service");
|
|
2248
|
+
import_js_service9 = require("@e22m4u/js-service");
|
|
2180
2249
|
init_utils();
|
|
2181
|
-
import_js_empty_values2 = require("@e22m4u/js-empty-values");
|
|
2182
2250
|
init_property_uniqueness();
|
|
2183
2251
|
init_errors();
|
|
2184
2252
|
init_model_definition_utils();
|
|
2185
|
-
_PropertyUniquenessValidator = class _PropertyUniquenessValidator extends
|
|
2253
|
+
_PropertyUniquenessValidator = class _PropertyUniquenessValidator extends import_js_service9.Service {
|
|
2186
2254
|
/**
|
|
2187
2255
|
* Validate.
|
|
2188
2256
|
*
|
|
@@ -2230,17 +2298,14 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2230
2298
|
propValue
|
|
2231
2299
|
), "createError");
|
|
2232
2300
|
let willBeReplaced = void 0;
|
|
2233
|
-
const emptyValuesService = this.getService(import_js_empty_values2.EmptyValuesService);
|
|
2234
2301
|
for (const propName of propNames) {
|
|
2235
2302
|
const propDef = propDefs[propName];
|
|
2236
2303
|
if (!propDef || typeof propDef === "string" || !propDef.unique || propDef.unique === PropertyUniqueness.NON_UNIQUE) {
|
|
2237
2304
|
continue;
|
|
2238
2305
|
}
|
|
2239
2306
|
const propValue = modelData[propName];
|
|
2240
|
-
if (propDef.unique === PropertyUniqueness.SPARSE) {
|
|
2241
|
-
|
|
2242
|
-
const isEmpty = emptyValuesService.isEmptyOf(propType, propValue);
|
|
2243
|
-
if (isEmpty) continue;
|
|
2307
|
+
if (propDef.unique === PropertyUniqueness.SPARSE && !propValue) {
|
|
2308
|
+
continue;
|
|
2244
2309
|
}
|
|
2245
2310
|
if (methodName === "create") {
|
|
2246
2311
|
const count = await countMethod({ [propName]: propValue });
|
|
@@ -2291,14 +2356,14 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2291
2356
|
});
|
|
2292
2357
|
|
|
2293
2358
|
// src/definition/model/properties/primary-keys-definition-validator.js
|
|
2294
|
-
var
|
|
2359
|
+
var import_js_service10, _PrimaryKeysDefinitionValidator, PrimaryKeysDefinitionValidator;
|
|
2295
2360
|
var init_primary_keys_definition_validator = __esm({
|
|
2296
2361
|
"src/definition/model/properties/primary-keys-definition-validator.js"() {
|
|
2297
2362
|
"use strict";
|
|
2298
|
-
|
|
2363
|
+
import_js_service10 = require("@e22m4u/js-service");
|
|
2299
2364
|
init_errors();
|
|
2300
2365
|
init_model_definition_utils();
|
|
2301
|
-
_PrimaryKeysDefinitionValidator = class _PrimaryKeysDefinitionValidator extends
|
|
2366
|
+
_PrimaryKeysDefinitionValidator = class _PrimaryKeysDefinitionValidator extends import_js_service10.Service {
|
|
2302
2367
|
/**
|
|
2303
2368
|
* Validate.
|
|
2304
2369
|
*
|
|
@@ -2343,17 +2408,17 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
2343
2408
|
});
|
|
2344
2409
|
|
|
2345
2410
|
// src/definition/model/properties/properties-definition-validator.js
|
|
2346
|
-
var
|
|
2411
|
+
var import_js_service11, _PropertiesDefinitionValidator, PropertiesDefinitionValidator;
|
|
2347
2412
|
var init_properties_definition_validator = __esm({
|
|
2348
2413
|
"src/definition/model/properties/properties-definition-validator.js"() {
|
|
2349
2414
|
"use strict";
|
|
2350
|
-
|
|
2415
|
+
import_js_service11 = require("@e22m4u/js-service");
|
|
2351
2416
|
init_data_type();
|
|
2352
2417
|
init_utils();
|
|
2353
2418
|
init_property_uniqueness();
|
|
2354
2419
|
init_errors();
|
|
2355
2420
|
init_primary_keys_definition_validator();
|
|
2356
|
-
_PropertiesDefinitionValidator = class _PropertiesDefinitionValidator extends
|
|
2421
|
+
_PropertiesDefinitionValidator = class _PropertiesDefinitionValidator extends import_js_service11.Service {
|
|
2357
2422
|
/**
|
|
2358
2423
|
* Validate.
|
|
2359
2424
|
*
|
|
@@ -2574,6 +2639,7 @@ var init_properties = __esm({
|
|
|
2574
2639
|
init_data_type();
|
|
2575
2640
|
init_property_definition();
|
|
2576
2641
|
init_property_uniqueness();
|
|
2642
|
+
init_required_property_validator();
|
|
2577
2643
|
init_property_uniqueness_validator();
|
|
2578
2644
|
init_properties_definition_validator();
|
|
2579
2645
|
init_primary_keys_definition_validator();
|
|
@@ -2588,14 +2654,14 @@ var init_model_definition = __esm({
|
|
|
2588
2654
|
});
|
|
2589
2655
|
|
|
2590
2656
|
// src/definition/model/model-data-sanitizer.js
|
|
2591
|
-
var
|
|
2657
|
+
var import_js_service12, _ModelDataSanitizer, ModelDataSanitizer;
|
|
2592
2658
|
var init_model_data_sanitizer = __esm({
|
|
2593
2659
|
"src/definition/model/model-data-sanitizer.js"() {
|
|
2594
2660
|
"use strict";
|
|
2595
|
-
|
|
2661
|
+
import_js_service12 = require("@e22m4u/js-service");
|
|
2596
2662
|
init_errors();
|
|
2597
2663
|
init_model_definition_utils();
|
|
2598
|
-
_ModelDataSanitizer = class _ModelDataSanitizer extends
|
|
2664
|
+
_ModelDataSanitizer = class _ModelDataSanitizer extends import_js_service12.Service {
|
|
2599
2665
|
/**
|
|
2600
2666
|
* Validate.
|
|
2601
2667
|
*
|
|
@@ -2625,15 +2691,15 @@ var init_model_data_sanitizer = __esm({
|
|
|
2625
2691
|
});
|
|
2626
2692
|
|
|
2627
2693
|
// src/definition/model/model-definition-validator.js
|
|
2628
|
-
var
|
|
2694
|
+
var import_js_service13, _ModelDefinitionValidator, ModelDefinitionValidator;
|
|
2629
2695
|
var init_model_definition_validator = __esm({
|
|
2630
2696
|
"src/definition/model/model-definition-validator.js"() {
|
|
2631
2697
|
"use strict";
|
|
2632
|
-
|
|
2698
|
+
import_js_service13 = require("@e22m4u/js-service");
|
|
2633
2699
|
init_errors();
|
|
2634
2700
|
init_relations();
|
|
2635
2701
|
init_properties();
|
|
2636
|
-
_ModelDefinitionValidator = class _ModelDefinitionValidator extends
|
|
2702
|
+
_ModelDefinitionValidator = class _ModelDefinitionValidator extends import_js_service13.Service {
|
|
2637
2703
|
/**
|
|
2638
2704
|
* Validate.
|
|
2639
2705
|
*
|
|
@@ -2715,13 +2781,13 @@ var init_model = __esm({
|
|
|
2715
2781
|
});
|
|
2716
2782
|
|
|
2717
2783
|
// src/definition/datasource/datasource-definition-validator.js
|
|
2718
|
-
var
|
|
2784
|
+
var import_js_service14, _DatasourceDefinitionValidator, DatasourceDefinitionValidator;
|
|
2719
2785
|
var init_datasource_definition_validator = __esm({
|
|
2720
2786
|
"src/definition/datasource/datasource-definition-validator.js"() {
|
|
2721
2787
|
"use strict";
|
|
2722
|
-
|
|
2788
|
+
import_js_service14 = require("@e22m4u/js-service");
|
|
2723
2789
|
init_errors();
|
|
2724
|
-
_DatasourceDefinitionValidator = class _DatasourceDefinitionValidator extends
|
|
2790
|
+
_DatasourceDefinitionValidator = class _DatasourceDefinitionValidator extends import_js_service14.Service {
|
|
2725
2791
|
/**
|
|
2726
2792
|
* Validate.
|
|
2727
2793
|
*
|
|
@@ -2770,15 +2836,15 @@ var init_definition = __esm({
|
|
|
2770
2836
|
});
|
|
2771
2837
|
|
|
2772
2838
|
// src/filter/fields-clause-tool.js
|
|
2773
|
-
var
|
|
2839
|
+
var import_js_service15, _FieldsClauseTool, FieldsClauseTool;
|
|
2774
2840
|
var init_fields_clause_tool = __esm({
|
|
2775
2841
|
"src/filter/fields-clause-tool.js"() {
|
|
2776
2842
|
"use strict";
|
|
2777
|
-
|
|
2843
|
+
import_js_service15 = require("@e22m4u/js-service");
|
|
2778
2844
|
init_utils();
|
|
2779
2845
|
init_errors();
|
|
2780
2846
|
init_definition();
|
|
2781
|
-
_FieldsClauseTool = class _FieldsClauseTool extends
|
|
2847
|
+
_FieldsClauseTool = class _FieldsClauseTool extends import_js_service15.Service {
|
|
2782
2848
|
/**
|
|
2783
2849
|
* Filter.
|
|
2784
2850
|
*
|
|
@@ -2862,15 +2928,15 @@ var init_fields_clause_tool = __esm({
|
|
|
2862
2928
|
});
|
|
2863
2929
|
|
|
2864
2930
|
// src/adapter/decorator/inclusion-decorator.js
|
|
2865
|
-
var
|
|
2931
|
+
var import_js_service16, _InclusionDecorator, InclusionDecorator;
|
|
2866
2932
|
var init_inclusion_decorator = __esm({
|
|
2867
2933
|
"src/adapter/decorator/inclusion-decorator.js"() {
|
|
2868
2934
|
"use strict";
|
|
2869
2935
|
init_adapter();
|
|
2870
|
-
|
|
2936
|
+
import_js_service16 = require("@e22m4u/js-service");
|
|
2871
2937
|
init_filter();
|
|
2872
2938
|
init_errors();
|
|
2873
|
-
_InclusionDecorator = class _InclusionDecorator extends
|
|
2939
|
+
_InclusionDecorator = class _InclusionDecorator extends import_js_service16.Service {
|
|
2874
2940
|
/**
|
|
2875
2941
|
* Decorate.
|
|
2876
2942
|
*
|
|
@@ -2951,15 +3017,15 @@ var init_inclusion_decorator = __esm({
|
|
|
2951
3017
|
});
|
|
2952
3018
|
|
|
2953
3019
|
// src/adapter/decorator/default-values-decorator.js
|
|
2954
|
-
var
|
|
3020
|
+
var import_js_service17, _DefaultValuesDecorator, DefaultValuesDecorator;
|
|
2955
3021
|
var init_default_values_decorator = __esm({
|
|
2956
3022
|
"src/adapter/decorator/default-values-decorator.js"() {
|
|
2957
3023
|
"use strict";
|
|
2958
3024
|
init_adapter();
|
|
2959
|
-
|
|
3025
|
+
import_js_service17 = require("@e22m4u/js-service");
|
|
2960
3026
|
init_errors();
|
|
2961
3027
|
init_definition();
|
|
2962
|
-
_DefaultValuesDecorator = class _DefaultValuesDecorator extends
|
|
3028
|
+
_DefaultValuesDecorator = class _DefaultValuesDecorator extends import_js_service17.Service {
|
|
2963
3029
|
/**
|
|
2964
3030
|
* Decorate.
|
|
2965
3031
|
*
|
|
@@ -3016,15 +3082,15 @@ var init_default_values_decorator = __esm({
|
|
|
3016
3082
|
});
|
|
3017
3083
|
|
|
3018
3084
|
// src/adapter/decorator/data-sanitizing-decorator.js
|
|
3019
|
-
var
|
|
3085
|
+
var import_js_service18, _DataSanitizingDecorator, DataSanitizingDecorator;
|
|
3020
3086
|
var init_data_sanitizing_decorator = __esm({
|
|
3021
3087
|
"src/adapter/decorator/data-sanitizing-decorator.js"() {
|
|
3022
3088
|
"use strict";
|
|
3023
3089
|
init_adapter();
|
|
3024
|
-
|
|
3090
|
+
import_js_service18 = require("@e22m4u/js-service");
|
|
3025
3091
|
init_errors();
|
|
3026
3092
|
init_definition();
|
|
3027
|
-
_DataSanitizingDecorator = class _DataSanitizingDecorator extends
|
|
3093
|
+
_DataSanitizingDecorator = class _DataSanitizingDecorator extends import_js_service18.Service {
|
|
3028
3094
|
/**
|
|
3029
3095
|
* Decorate.
|
|
3030
3096
|
*
|
|
@@ -3071,15 +3137,15 @@ var init_data_sanitizing_decorator = __esm({
|
|
|
3071
3137
|
});
|
|
3072
3138
|
|
|
3073
3139
|
// src/adapter/decorator/fields-filtering-decorator.js
|
|
3074
|
-
var
|
|
3140
|
+
var import_js_service19, _FieldsFilteringDecorator, FieldsFilteringDecorator;
|
|
3075
3141
|
var init_fields_filtering_decorator = __esm({
|
|
3076
3142
|
"src/adapter/decorator/fields-filtering-decorator.js"() {
|
|
3077
3143
|
"use strict";
|
|
3078
3144
|
init_adapter();
|
|
3079
|
-
|
|
3145
|
+
import_js_service19 = require("@e22m4u/js-service");
|
|
3080
3146
|
init_filter();
|
|
3081
3147
|
init_errors();
|
|
3082
|
-
_FieldsFilteringDecorator = class _FieldsFilteringDecorator extends
|
|
3148
|
+
_FieldsFilteringDecorator = class _FieldsFilteringDecorator extends import_js_service19.Service {
|
|
3083
3149
|
/**
|
|
3084
3150
|
* Decorate.
|
|
3085
3151
|
*
|
|
@@ -3153,16 +3219,70 @@ var init_fields_filtering_decorator = __esm({
|
|
|
3153
3219
|
}
|
|
3154
3220
|
});
|
|
3155
3221
|
|
|
3222
|
+
// src/adapter/decorator/required-property-decorator.js
|
|
3223
|
+
var import_js_service20, _RequiredPropertyDecorator, RequiredPropertyDecorator;
|
|
3224
|
+
var init_required_property_decorator = __esm({
|
|
3225
|
+
"src/adapter/decorator/required-property-decorator.js"() {
|
|
3226
|
+
"use strict";
|
|
3227
|
+
init_adapter();
|
|
3228
|
+
import_js_service20 = require("@e22m4u/js-service");
|
|
3229
|
+
init_errors();
|
|
3230
|
+
init_definition();
|
|
3231
|
+
_RequiredPropertyDecorator = class _RequiredPropertyDecorator extends import_js_service20.Service {
|
|
3232
|
+
/**
|
|
3233
|
+
* Decorate.
|
|
3234
|
+
*
|
|
3235
|
+
* @param {Adapter} adapter
|
|
3236
|
+
*/
|
|
3237
|
+
decorate(adapter) {
|
|
3238
|
+
if (!adapter || !(adapter instanceof Adapter))
|
|
3239
|
+
throw new InvalidArgumentError(
|
|
3240
|
+
"The first argument of RequiredPropertyDecorator.decorate should be an Adapter instance, but %v was given.",
|
|
3241
|
+
adapter
|
|
3242
|
+
);
|
|
3243
|
+
const validator = this.getService(RequiredPropertyValidator);
|
|
3244
|
+
const create = adapter.create;
|
|
3245
|
+
adapter.create = async function(modelName, modelData, filter) {
|
|
3246
|
+
validator.validate(modelName, modelData);
|
|
3247
|
+
return create.call(this, modelName, modelData, filter);
|
|
3248
|
+
};
|
|
3249
|
+
const replaceById = adapter.replaceById;
|
|
3250
|
+
adapter.replaceById = async function(modelName, id, modelData, filter) {
|
|
3251
|
+
validator.validate(modelName, modelData);
|
|
3252
|
+
return replaceById.call(this, modelName, id, modelData, filter);
|
|
3253
|
+
};
|
|
3254
|
+
const replaceOrCreate = adapter.replaceOrCreate;
|
|
3255
|
+
adapter.replaceOrCreate = async function(modelName, modelData, filter) {
|
|
3256
|
+
validator.validate(modelName, modelData);
|
|
3257
|
+
return replaceOrCreate.call(this, modelName, modelData, filter);
|
|
3258
|
+
};
|
|
3259
|
+
const patch = adapter.patch;
|
|
3260
|
+
adapter.patch = async function(modelName, modelData, where) {
|
|
3261
|
+
validator.validate(modelName, modelData, true);
|
|
3262
|
+
return patch.call(this, modelName, modelData, where);
|
|
3263
|
+
};
|
|
3264
|
+
const patchById = adapter.patchById;
|
|
3265
|
+
adapter.patchById = async function(modelName, id, modelData, filter) {
|
|
3266
|
+
validator.validate(modelName, modelData, true);
|
|
3267
|
+
return patchById.call(this, modelName, id, modelData, filter);
|
|
3268
|
+
};
|
|
3269
|
+
}
|
|
3270
|
+
};
|
|
3271
|
+
__name(_RequiredPropertyDecorator, "RequiredPropertyDecorator");
|
|
3272
|
+
RequiredPropertyDecorator = _RequiredPropertyDecorator;
|
|
3273
|
+
}
|
|
3274
|
+
});
|
|
3275
|
+
|
|
3156
3276
|
// src/adapter/decorator/property-uniqueness-decorator.js
|
|
3157
|
-
var
|
|
3277
|
+
var import_js_service21, _PropertyUniquenessDecorator, PropertyUniquenessDecorator;
|
|
3158
3278
|
var init_property_uniqueness_decorator = __esm({
|
|
3159
3279
|
"src/adapter/decorator/property-uniqueness-decorator.js"() {
|
|
3160
3280
|
"use strict";
|
|
3161
3281
|
init_adapter();
|
|
3162
|
-
|
|
3282
|
+
import_js_service21 = require("@e22m4u/js-service");
|
|
3163
3283
|
init_errors();
|
|
3164
3284
|
init_definition();
|
|
3165
|
-
_PropertyUniquenessDecorator = class _PropertyUniquenessDecorator extends
|
|
3285
|
+
_PropertyUniquenessDecorator = class _PropertyUniquenessDecorator extends import_js_service21.Service {
|
|
3166
3286
|
/**
|
|
3167
3287
|
* Decorate.
|
|
3168
3288
|
*
|
|
@@ -3237,20 +3357,21 @@ var init_decorator = __esm({
|
|
|
3237
3357
|
init_default_values_decorator();
|
|
3238
3358
|
init_data_sanitizing_decorator();
|
|
3239
3359
|
init_fields_filtering_decorator();
|
|
3360
|
+
init_required_property_decorator();
|
|
3240
3361
|
init_property_uniqueness_decorator();
|
|
3241
3362
|
}
|
|
3242
3363
|
});
|
|
3243
3364
|
|
|
3244
3365
|
// src/adapter/adapter.js
|
|
3245
|
-
var
|
|
3366
|
+
var import_js_service22, ADAPTER_CLASS_NAME, _Adapter, Adapter;
|
|
3246
3367
|
var init_adapter = __esm({
|
|
3247
3368
|
"src/adapter/adapter.js"() {
|
|
3248
3369
|
"use strict";
|
|
3249
|
-
|
|
3370
|
+
import_js_service22 = require("@e22m4u/js-service");
|
|
3250
3371
|
init_errors();
|
|
3251
3372
|
init_decorator();
|
|
3252
3373
|
ADAPTER_CLASS_NAME = "Adapter";
|
|
3253
|
-
_Adapter = class _Adapter extends
|
|
3374
|
+
_Adapter = class _Adapter extends import_js_service22.Service {
|
|
3254
3375
|
/**
|
|
3255
3376
|
* Settings.
|
|
3256
3377
|
*
|
|
@@ -3277,6 +3398,7 @@ var init_adapter = __esm({
|
|
|
3277
3398
|
if (this.constructor !== _Adapter) {
|
|
3278
3399
|
this.getService(DataSanitizingDecorator).decorate(this);
|
|
3279
3400
|
this.getService(DefaultValuesDecorator).decorate(this);
|
|
3401
|
+
this.getService(RequiredPropertyDecorator).decorate(this);
|
|
3280
3402
|
this.getService(PropertyUniquenessDecorator).decorate(this);
|
|
3281
3403
|
this.getService(FieldsFilteringDecorator).decorate(this);
|
|
3282
3404
|
this.getService(InclusionDecorator).decorate(this);
|
|
@@ -3440,7 +3562,7 @@ var init_adapter = __esm({
|
|
|
3440
3562
|
*
|
|
3441
3563
|
* @type {string[]}
|
|
3442
3564
|
*/
|
|
3443
|
-
__publicField(_Adapter, "kinds", [...
|
|
3565
|
+
__publicField(_Adapter, "kinds", [...import_js_service22.Service.kinds, ADAPTER_CLASS_NAME]);
|
|
3444
3566
|
Adapter = _Adapter;
|
|
3445
3567
|
}
|
|
3446
3568
|
});
|
|
@@ -3866,15 +3988,15 @@ function findAdapterCtorInModule(module2) {
|
|
|
3866
3988
|
}
|
|
3867
3989
|
return adapterCtor;
|
|
3868
3990
|
}
|
|
3869
|
-
var
|
|
3991
|
+
var import_js_service23, _AdapterLoader, AdapterLoader;
|
|
3870
3992
|
var init_adapter_loader = __esm({
|
|
3871
3993
|
"src/adapter/adapter-loader.js"() {
|
|
3872
3994
|
"use strict";
|
|
3873
|
-
|
|
3995
|
+
import_js_service23 = require("@e22m4u/js-service");
|
|
3874
3996
|
init_errors();
|
|
3875
3997
|
init_adapter();
|
|
3876
3998
|
init_();
|
|
3877
|
-
_AdapterLoader = class _AdapterLoader extends
|
|
3999
|
+
_AdapterLoader = class _AdapterLoader extends import_js_service23.Service {
|
|
3878
4000
|
/**
|
|
3879
4001
|
* Load by name.
|
|
3880
4002
|
*
|
|
@@ -3915,15 +4037,15 @@ var init_adapter_loader = __esm({
|
|
|
3915
4037
|
});
|
|
3916
4038
|
|
|
3917
4039
|
// src/adapter/adapter-registry.js
|
|
3918
|
-
var
|
|
4040
|
+
var import_js_service24, _AdapterRegistry, AdapterRegistry;
|
|
3919
4041
|
var init_adapter_registry = __esm({
|
|
3920
4042
|
"src/adapter/adapter-registry.js"() {
|
|
3921
4043
|
"use strict";
|
|
3922
4044
|
init_adapter();
|
|
3923
|
-
|
|
4045
|
+
import_js_service24 = require("@e22m4u/js-service");
|
|
3924
4046
|
init_adapter_loader();
|
|
3925
4047
|
init_definition();
|
|
3926
|
-
_AdapterRegistry = class _AdapterRegistry extends
|
|
4048
|
+
_AdapterRegistry = class _AdapterRegistry extends import_js_service24.Service {
|
|
3927
4049
|
/**
|
|
3928
4050
|
* Adapters.
|
|
3929
4051
|
*
|
|
@@ -3965,15 +4087,15 @@ var init_adapter2 = __esm({
|
|
|
3965
4087
|
});
|
|
3966
4088
|
|
|
3967
4089
|
// src/repository/repository.js
|
|
3968
|
-
var
|
|
4090
|
+
var import_js_service25, _Repository, Repository;
|
|
3969
4091
|
var init_repository = __esm({
|
|
3970
4092
|
"src/repository/repository.js"() {
|
|
3971
4093
|
"use strict";
|
|
3972
|
-
|
|
4094
|
+
import_js_service25 = require("@e22m4u/js-service");
|
|
3973
4095
|
init_errors();
|
|
3974
4096
|
init_definition();
|
|
3975
4097
|
init_adapter2();
|
|
3976
|
-
_Repository = class _Repository extends
|
|
4098
|
+
_Repository = class _Repository extends import_js_service25.Service {
|
|
3977
4099
|
/**
|
|
3978
4100
|
* Model name.
|
|
3979
4101
|
*
|
|
@@ -4167,15 +4289,15 @@ var init_repository = __esm({
|
|
|
4167
4289
|
});
|
|
4168
4290
|
|
|
4169
4291
|
// src/repository/repository-registry.js
|
|
4170
|
-
var
|
|
4292
|
+
var import_js_service26, _RepositoryRegistry, RepositoryRegistry;
|
|
4171
4293
|
var init_repository_registry = __esm({
|
|
4172
4294
|
"src/repository/repository-registry.js"() {
|
|
4173
4295
|
"use strict";
|
|
4174
|
-
|
|
4296
|
+
import_js_service26 = require("@e22m4u/js-service");
|
|
4175
4297
|
init_repository();
|
|
4176
4298
|
init_utils();
|
|
4177
4299
|
init_errors();
|
|
4178
|
-
_RepositoryRegistry = class _RepositoryRegistry extends
|
|
4300
|
+
_RepositoryRegistry = class _RepositoryRegistry extends import_js_service26.Service {
|
|
4179
4301
|
/**
|
|
4180
4302
|
* Repositories.
|
|
4181
4303
|
*
|
|
@@ -4233,16 +4355,16 @@ var init_repository2 = __esm({
|
|
|
4233
4355
|
});
|
|
4234
4356
|
|
|
4235
4357
|
// src/relations/has-one-resolver.js
|
|
4236
|
-
var
|
|
4358
|
+
var import_js_service27, _HasOneResolver, HasOneResolver;
|
|
4237
4359
|
var init_has_one_resolver = __esm({
|
|
4238
4360
|
"src/relations/has-one-resolver.js"() {
|
|
4239
4361
|
"use strict";
|
|
4240
|
-
|
|
4362
|
+
import_js_service27 = require("@e22m4u/js-service");
|
|
4241
4363
|
init_utils();
|
|
4242
4364
|
init_errors();
|
|
4243
4365
|
init_repository2();
|
|
4244
4366
|
init_definition();
|
|
4245
|
-
_HasOneResolver = class _HasOneResolver extends
|
|
4367
|
+
_HasOneResolver = class _HasOneResolver extends import_js_service27.Service {
|
|
4246
4368
|
/**
|
|
4247
4369
|
* Include to.
|
|
4248
4370
|
*
|
|
@@ -4487,16 +4609,16 @@ var init_has_one_resolver = __esm({
|
|
|
4487
4609
|
});
|
|
4488
4610
|
|
|
4489
4611
|
// src/relations/has-many-resolver.js
|
|
4490
|
-
var
|
|
4612
|
+
var import_js_service28, _HasManyResolver, HasManyResolver;
|
|
4491
4613
|
var init_has_many_resolver = __esm({
|
|
4492
4614
|
"src/relations/has-many-resolver.js"() {
|
|
4493
4615
|
"use strict";
|
|
4494
|
-
|
|
4616
|
+
import_js_service28 = require("@e22m4u/js-service");
|
|
4495
4617
|
init_utils();
|
|
4496
4618
|
init_errors();
|
|
4497
4619
|
init_repository2();
|
|
4498
4620
|
init_definition();
|
|
4499
|
-
_HasManyResolver = class _HasManyResolver extends
|
|
4621
|
+
_HasManyResolver = class _HasManyResolver extends import_js_service28.Service {
|
|
4500
4622
|
/**
|
|
4501
4623
|
* Include to.
|
|
4502
4624
|
*
|
|
@@ -4751,16 +4873,16 @@ var init_has_many_resolver = __esm({
|
|
|
4751
4873
|
});
|
|
4752
4874
|
|
|
4753
4875
|
// src/relations/belongs-to-resolver.js
|
|
4754
|
-
var
|
|
4876
|
+
var import_js_service29, _BelongsToResolver, BelongsToResolver;
|
|
4755
4877
|
var init_belongs_to_resolver = __esm({
|
|
4756
4878
|
"src/relations/belongs-to-resolver.js"() {
|
|
4757
4879
|
"use strict";
|
|
4758
|
-
|
|
4880
|
+
import_js_service29 = require("@e22m4u/js-service");
|
|
4759
4881
|
init_errors();
|
|
4760
4882
|
init_utils();
|
|
4761
4883
|
init_repository2();
|
|
4762
4884
|
init_definition();
|
|
4763
|
-
_BelongsToResolver = class _BelongsToResolver extends
|
|
4885
|
+
_BelongsToResolver = class _BelongsToResolver extends import_js_service29.Service {
|
|
4764
4886
|
/**
|
|
4765
4887
|
* Include to.
|
|
4766
4888
|
*
|
|
@@ -4958,16 +5080,16 @@ var init_belongs_to_resolver = __esm({
|
|
|
4958
5080
|
});
|
|
4959
5081
|
|
|
4960
5082
|
// src/relations/references-many-resolver.js
|
|
4961
|
-
var
|
|
5083
|
+
var import_js_service30, _ReferencesManyResolver, ReferencesManyResolver;
|
|
4962
5084
|
var init_references_many_resolver = __esm({
|
|
4963
5085
|
"src/relations/references-many-resolver.js"() {
|
|
4964
5086
|
"use strict";
|
|
4965
|
-
|
|
5087
|
+
import_js_service30 = require("@e22m4u/js-service");
|
|
4966
5088
|
init_errors();
|
|
4967
5089
|
init_utils();
|
|
4968
5090
|
init_repository2();
|
|
4969
5091
|
init_definition();
|
|
4970
|
-
_ReferencesManyResolver = class _ReferencesManyResolver extends
|
|
5092
|
+
_ReferencesManyResolver = class _ReferencesManyResolver extends import_js_service30.Service {
|
|
4971
5093
|
/**
|
|
4972
5094
|
* Include to.
|
|
4973
5095
|
*
|
|
@@ -5069,11 +5191,11 @@ var init_relations2 = __esm({
|
|
|
5069
5191
|
});
|
|
5070
5192
|
|
|
5071
5193
|
// src/filter/include-clause-tool.js
|
|
5072
|
-
var
|
|
5194
|
+
var import_js_service31, _IncludeClauseTool, IncludeClauseTool;
|
|
5073
5195
|
var init_include_clause_tool = __esm({
|
|
5074
5196
|
"src/filter/include-clause-tool.js"() {
|
|
5075
5197
|
"use strict";
|
|
5076
|
-
|
|
5198
|
+
import_js_service31 = require("@e22m4u/js-service");
|
|
5077
5199
|
init_where_clause_tool();
|
|
5078
5200
|
init_order_clause_tool();
|
|
5079
5201
|
init_slice_clause_tool();
|
|
@@ -5081,7 +5203,7 @@ var init_include_clause_tool = __esm({
|
|
|
5081
5203
|
init_fields_clause_tool();
|
|
5082
5204
|
init_definition();
|
|
5083
5205
|
init_relations2();
|
|
5084
|
-
_IncludeClauseTool = class _IncludeClauseTool extends
|
|
5206
|
+
_IncludeClauseTool = class _IncludeClauseTool extends import_js_service31.Service {
|
|
5085
5207
|
/**
|
|
5086
5208
|
* Include to.
|
|
5087
5209
|
*
|
|
@@ -5451,6 +5573,7 @@ __export(index_exports, {
|
|
|
5451
5573
|
RelationsDefinitionValidator: () => RelationsDefinitionValidator,
|
|
5452
5574
|
Repository: () => Repository,
|
|
5453
5575
|
RepositoryRegistry: () => RepositoryRegistry,
|
|
5576
|
+
RequiredPropertyValidator: () => RequiredPropertyValidator,
|
|
5454
5577
|
SliceClauseTool: () => SliceClauseTool,
|
|
5455
5578
|
WhereClauseTool: () => WhereClauseTool,
|
|
5456
5579
|
capitalize: () => capitalize,
|
|
@@ -5473,10 +5596,10 @@ init_filter();
|
|
|
5473
5596
|
init_adapter2();
|
|
5474
5597
|
|
|
5475
5598
|
// src/database-schema.js
|
|
5476
|
-
var
|
|
5599
|
+
var import_js_service32 = require("@e22m4u/js-service");
|
|
5477
5600
|
init_definition();
|
|
5478
5601
|
init_repository2();
|
|
5479
|
-
var _DatabaseSchema = class _DatabaseSchema extends
|
|
5602
|
+
var _DatabaseSchema = class _DatabaseSchema extends import_js_service32.Service {
|
|
5480
5603
|
/**
|
|
5481
5604
|
* Define datasource.
|
|
5482
5605
|
*
|
|
@@ -5547,6 +5670,7 @@ init_repository2();
|
|
|
5547
5670
|
RelationsDefinitionValidator,
|
|
5548
5671
|
Repository,
|
|
5549
5672
|
RepositoryRegistry,
|
|
5673
|
+
RequiredPropertyValidator,
|
|
5550
5674
|
SliceClauseTool,
|
|
5551
5675
|
WhereClauseTool,
|
|
5552
5676
|
capitalize,
|