@e22m4u/js-repository 0.1.25 → 0.2.1
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/build-cjs.js +5 -0
- package/dist/cjs/index.cjs +494 -846
- package/package.json +11 -10
- package/src/adapter/adapter-loader.js +6 -2
- package/src/adapter/adapter.js +8 -1
- package/src/adapter/adapter.spec.js +6 -6
- package/src/definition/model/model-data-validator.js +7 -3
- package/src/definition/model/model-data-validator.spec.js +18 -3
- package/src/definition/model/properties/properties-definition-validator.js +37 -15
- package/src/definition/model/properties/properties-definition-validator.spec.js +48 -19
- package/src/definition/model/properties/property-definition.d.ts +1 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -38,393 +38,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
38
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
39
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
40
40
|
|
|
41
|
-
// node_modules/@e22m4u/js-format/src/utils/is-class.js
|
|
42
|
-
function isClass(value) {
|
|
43
|
-
if (!value) return false;
|
|
44
|
-
return typeof value === "function" && /^class\s/.test(Function.prototype.toString.call(value));
|
|
45
|
-
}
|
|
46
|
-
var init_is_class = __esm({
|
|
47
|
-
"node_modules/@e22m4u/js-format/src/utils/is-class.js"() {
|
|
48
|
-
__name(isClass, "isClass");
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// node_modules/@e22m4u/js-format/src/utils/index.js
|
|
53
|
-
var init_utils = __esm({
|
|
54
|
-
"node_modules/@e22m4u/js-format/src/utils/index.js"() {
|
|
55
|
-
init_is_class();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// node_modules/@e22m4u/js-format/src/value-to-string.js
|
|
60
|
-
function valueToString(input) {
|
|
61
|
-
if (input == null) return String(input);
|
|
62
|
-
if (typeof input === "string") return `"${input}"`;
|
|
63
|
-
if (typeof input === "number" || typeof input === "boolean")
|
|
64
|
-
return String(input);
|
|
65
|
-
if (isClass(input)) return input.name ? input.name : "Class";
|
|
66
|
-
if (input.constructor && input.constructor.name)
|
|
67
|
-
return BASE_CTOR_NAMES.includes(input.constructor.name) ? input.constructor.name : `${input.constructor.name} (instance)`;
|
|
68
|
-
if (typeof input === "object" && input.constructor == null) return "Object";
|
|
69
|
-
return String(input);
|
|
70
|
-
}
|
|
71
|
-
var BASE_CTOR_NAMES;
|
|
72
|
-
var init_value_to_string = __esm({
|
|
73
|
-
"node_modules/@e22m4u/js-format/src/value-to-string.js"() {
|
|
74
|
-
init_utils();
|
|
75
|
-
BASE_CTOR_NAMES = [
|
|
76
|
-
"String",
|
|
77
|
-
"Number",
|
|
78
|
-
"Boolean",
|
|
79
|
-
"Object",
|
|
80
|
-
"Array",
|
|
81
|
-
"Function",
|
|
82
|
-
"Symbol",
|
|
83
|
-
"Map",
|
|
84
|
-
"Set",
|
|
85
|
-
"Date"
|
|
86
|
-
];
|
|
87
|
-
__name(valueToString, "valueToString");
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// node_modules/@e22m4u/js-format/src/array-to-list.js
|
|
92
|
-
function arrayToList(input) {
|
|
93
|
-
if (Array.isArray(input) && input.length)
|
|
94
|
-
return input.map(valueToString).join(SEPARATOR);
|
|
95
|
-
return valueToString(input);
|
|
96
|
-
}
|
|
97
|
-
var SEPARATOR;
|
|
98
|
-
var init_array_to_list = __esm({
|
|
99
|
-
"node_modules/@e22m4u/js-format/src/array-to-list.js"() {
|
|
100
|
-
init_value_to_string();
|
|
101
|
-
SEPARATOR = ", ";
|
|
102
|
-
__name(arrayToList, "arrayToList");
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// node_modules/@e22m4u/js-format/src/format.js
|
|
107
|
-
function format(pattern) {
|
|
108
|
-
if (pattern instanceof Date) {
|
|
109
|
-
pattern = pattern.toISOString();
|
|
110
|
-
} else if (typeof pattern !== "string") {
|
|
111
|
-
pattern = String(pattern);
|
|
112
|
-
}
|
|
113
|
-
const re = /(%?)(%([sdjvl]))/g;
|
|
114
|
-
const args = Array.prototype.slice.call(arguments, 1);
|
|
115
|
-
if (args.length) {
|
|
116
|
-
pattern = pattern.replace(re, function(match, escaped, ptn, flag) {
|
|
117
|
-
let arg = args.shift();
|
|
118
|
-
switch (flag) {
|
|
119
|
-
case "s":
|
|
120
|
-
arg = String(arg);
|
|
121
|
-
break;
|
|
122
|
-
case "d":
|
|
123
|
-
arg = Number(arg);
|
|
124
|
-
break;
|
|
125
|
-
case "j":
|
|
126
|
-
arg = JSON.stringify(arg);
|
|
127
|
-
break;
|
|
128
|
-
case "v":
|
|
129
|
-
arg = valueToString(arg);
|
|
130
|
-
break;
|
|
131
|
-
case "l":
|
|
132
|
-
arg = arrayToList(arg);
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
if (!escaped) return arg;
|
|
136
|
-
args.unshift(arg);
|
|
137
|
-
return match;
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
if (args.length) pattern += " " + args.join(" ");
|
|
141
|
-
pattern = pattern.replace(/%{2}/g, "%");
|
|
142
|
-
return "" + pattern;
|
|
143
|
-
}
|
|
144
|
-
var init_format = __esm({
|
|
145
|
-
"node_modules/@e22m4u/js-format/src/format.js"() {
|
|
146
|
-
init_array_to_list();
|
|
147
|
-
init_value_to_string();
|
|
148
|
-
__name(format, "format");
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
// node_modules/@e22m4u/js-format/src/errorf.js
|
|
153
|
-
var _Errorf, Errorf;
|
|
154
|
-
var init_errorf = __esm({
|
|
155
|
-
"node_modules/@e22m4u/js-format/src/errorf.js"() {
|
|
156
|
-
init_format();
|
|
157
|
-
_Errorf = class _Errorf extends Error {
|
|
158
|
-
/**
|
|
159
|
-
* Constructor.
|
|
160
|
-
*
|
|
161
|
-
* @param {string|undefined} pattern
|
|
162
|
-
* @param {any} args
|
|
163
|
-
*/
|
|
164
|
-
constructor(pattern = void 0, ...args) {
|
|
165
|
-
const message = pattern != null ? format(pattern, ...args) : void 0;
|
|
166
|
-
super(message);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
__name(_Errorf, "Errorf");
|
|
170
|
-
Errorf = _Errorf;
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// node_modules/@e22m4u/js-format/src/index.js
|
|
175
|
-
var init_src = __esm({
|
|
176
|
-
"node_modules/@e22m4u/js-format/src/index.js"() {
|
|
177
|
-
init_format();
|
|
178
|
-
init_errorf();
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
// node_modules/@e22m4u/js-service/src/errors/invalid-argument-error.js
|
|
183
|
-
var _InvalidArgumentError, InvalidArgumentError;
|
|
184
|
-
var init_invalid_argument_error = __esm({
|
|
185
|
-
"node_modules/@e22m4u/js-service/src/errors/invalid-argument-error.js"() {
|
|
186
|
-
init_src();
|
|
187
|
-
_InvalidArgumentError = class _InvalidArgumentError extends Errorf {
|
|
188
|
-
};
|
|
189
|
-
__name(_InvalidArgumentError, "InvalidArgumentError");
|
|
190
|
-
InvalidArgumentError = _InvalidArgumentError;
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// node_modules/@e22m4u/js-service/src/errors/index.js
|
|
195
|
-
var init_errors = __esm({
|
|
196
|
-
"node_modules/@e22m4u/js-service/src/errors/index.js"() {
|
|
197
|
-
init_invalid_argument_error();
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
// node_modules/@e22m4u/js-service/src/service-container.js
|
|
202
|
-
var _ServiceContainer, ServiceContainer;
|
|
203
|
-
var init_service_container = __esm({
|
|
204
|
-
"node_modules/@e22m4u/js-service/src/service-container.js"() {
|
|
205
|
-
init_service();
|
|
206
|
-
init_errors();
|
|
207
|
-
_ServiceContainer = class _ServiceContainer {
|
|
208
|
-
/**
|
|
209
|
-
* Services map.
|
|
210
|
-
*
|
|
211
|
-
* @type {Map<any, any>}
|
|
212
|
-
* @private
|
|
213
|
-
*/
|
|
214
|
-
_services = /* @__PURE__ */ new Map();
|
|
215
|
-
/**
|
|
216
|
-
* Parent container.
|
|
217
|
-
*
|
|
218
|
-
* @type {ServiceContainer}
|
|
219
|
-
* @private
|
|
220
|
-
*/
|
|
221
|
-
_parent;
|
|
222
|
-
/**
|
|
223
|
-
* Constructor.
|
|
224
|
-
*
|
|
225
|
-
* @param {ServiceContainer|undefined} parent
|
|
226
|
-
*/
|
|
227
|
-
constructor(parent = void 0) {
|
|
228
|
-
if (parent != null) {
|
|
229
|
-
if (!(parent instanceof _ServiceContainer))
|
|
230
|
-
throw new InvalidArgumentError(
|
|
231
|
-
'The provided parameter "parent" of ServicesContainer.constructor must be an instance ServiceContainer, but %v given.',
|
|
232
|
-
parent
|
|
233
|
-
);
|
|
234
|
-
this._parent = parent;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Получить существующий или новый экземпляр.
|
|
239
|
-
*
|
|
240
|
-
* @param {*} ctor
|
|
241
|
-
* @param {*} args
|
|
242
|
-
* @return {*}
|
|
243
|
-
*/
|
|
244
|
-
get(ctor, ...args) {
|
|
245
|
-
if (!ctor || typeof ctor !== "function")
|
|
246
|
-
throw new InvalidArgumentError(
|
|
247
|
-
"The first argument of ServicesContainer.get must be a class constructor, but %v given.",
|
|
248
|
-
ctor
|
|
249
|
-
);
|
|
250
|
-
if (!this._services.has(ctor) && this._parent && this._parent.has(ctor)) {
|
|
251
|
-
return this._parent.get(ctor);
|
|
252
|
-
}
|
|
253
|
-
let service = this._services.get(ctor);
|
|
254
|
-
if (!service || args.length) {
|
|
255
|
-
service = "prototype" in ctor && ctor.prototype instanceof Service ? new ctor(this, ...args) : new ctor(...args);
|
|
256
|
-
this._services.set(ctor, service);
|
|
257
|
-
} else if (typeof service === "function") {
|
|
258
|
-
service = service();
|
|
259
|
-
this._services.set(ctor, service);
|
|
260
|
-
}
|
|
261
|
-
return service;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Проверка существования конструктора в контейнере.
|
|
265
|
-
*
|
|
266
|
-
* @param {*} ctor
|
|
267
|
-
* @return {boolean}
|
|
268
|
-
*/
|
|
269
|
-
has(ctor) {
|
|
270
|
-
if (this._services.has(ctor)) return true;
|
|
271
|
-
if (this._parent) return this._parent.has(ctor);
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Добавить конструктор в контейнер.
|
|
276
|
-
*
|
|
277
|
-
* @param {*} ctor
|
|
278
|
-
* @param {*} args
|
|
279
|
-
* @return {this}
|
|
280
|
-
*/
|
|
281
|
-
add(ctor, ...args) {
|
|
282
|
-
if (!ctor || typeof ctor !== "function")
|
|
283
|
-
throw new InvalidArgumentError(
|
|
284
|
-
"The first argument of ServicesContainer.add must be a class constructor, but %v given.",
|
|
285
|
-
ctor
|
|
286
|
-
);
|
|
287
|
-
const factory = /* @__PURE__ */ __name(() => ctor.prototype instanceof Service ? new ctor(this, ...args) : new ctor(...args), "factory");
|
|
288
|
-
this._services.set(ctor, factory);
|
|
289
|
-
return this;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Добавить конструктор и создать экземпляр.
|
|
293
|
-
*
|
|
294
|
-
* @param {*} ctor
|
|
295
|
-
* @param {*} args
|
|
296
|
-
* @return {this}
|
|
297
|
-
*/
|
|
298
|
-
use(ctor, ...args) {
|
|
299
|
-
if (!ctor || typeof ctor !== "function")
|
|
300
|
-
throw new InvalidArgumentError(
|
|
301
|
-
"The first argument of ServicesContainer.use must be a class constructor, but %v given.",
|
|
302
|
-
ctor
|
|
303
|
-
);
|
|
304
|
-
const service = ctor.prototype instanceof Service ? new ctor(this, ...args) : new ctor(...args);
|
|
305
|
-
this._services.set(ctor, service);
|
|
306
|
-
return this;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Добавить конструктор и связанный экземпляр.
|
|
310
|
-
*
|
|
311
|
-
* @param {*} ctor
|
|
312
|
-
* @param {*} service
|
|
313
|
-
* @return {this}
|
|
314
|
-
*/
|
|
315
|
-
set(ctor, service) {
|
|
316
|
-
if (!ctor || typeof ctor !== "function")
|
|
317
|
-
throw new InvalidArgumentError(
|
|
318
|
-
"The first argument of ServicesContainer.set must be a class constructor, but %v given.",
|
|
319
|
-
ctor
|
|
320
|
-
);
|
|
321
|
-
if (!service || typeof service !== "object" || Array.isArray(service))
|
|
322
|
-
throw new InvalidArgumentError(
|
|
323
|
-
"The second argument of ServicesContainer.set must be an Object, but %v given.",
|
|
324
|
-
service
|
|
325
|
-
);
|
|
326
|
-
this._services.set(ctor, service);
|
|
327
|
-
return this;
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
__name(_ServiceContainer, "ServiceContainer");
|
|
331
|
-
ServiceContainer = _ServiceContainer;
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
// node_modules/@e22m4u/js-service/src/service.js
|
|
336
|
-
var _Service, Service;
|
|
337
|
-
var init_service = __esm({
|
|
338
|
-
"node_modules/@e22m4u/js-service/src/service.js"() {
|
|
339
|
-
init_service_container();
|
|
340
|
-
_Service = class _Service {
|
|
341
|
-
/**
|
|
342
|
-
* Container.
|
|
343
|
-
*
|
|
344
|
-
* @type {ServiceContainer}
|
|
345
|
-
*/
|
|
346
|
-
container;
|
|
347
|
-
/**
|
|
348
|
-
* Constructor.
|
|
349
|
-
*
|
|
350
|
-
* @param {ServiceContainer|undefined} container
|
|
351
|
-
*/
|
|
352
|
-
constructor(container = void 0) {
|
|
353
|
-
this.container = container instanceof ServiceContainer ? container : new ServiceContainer();
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Получить существующий или новый экземпляр.
|
|
357
|
-
*
|
|
358
|
-
* @param {*} ctor
|
|
359
|
-
* @param {*} args
|
|
360
|
-
* @return {*}
|
|
361
|
-
*/
|
|
362
|
-
getService(ctor, ...args) {
|
|
363
|
-
return this.container.get(ctor, ...args);
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Проверка существования конструктора в контейнере.
|
|
367
|
-
*
|
|
368
|
-
* @param {*} ctor
|
|
369
|
-
* @return {boolean}
|
|
370
|
-
*/
|
|
371
|
-
hasService(ctor) {
|
|
372
|
-
return this.container.has(ctor);
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Добавить конструктор в контейнер.
|
|
376
|
-
*
|
|
377
|
-
* @param {*} ctor
|
|
378
|
-
* @param {*} args
|
|
379
|
-
* @return {this}
|
|
380
|
-
*/
|
|
381
|
-
addService(ctor, ...args) {
|
|
382
|
-
this.container.add(ctor, ...args);
|
|
383
|
-
return this;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Добавить конструктор и создать экземпляр.
|
|
387
|
-
*
|
|
388
|
-
* @param {*} ctor
|
|
389
|
-
* @param {*} args
|
|
390
|
-
* @return {this}
|
|
391
|
-
*/
|
|
392
|
-
useService(ctor, ...args) {
|
|
393
|
-
this.container.use(ctor, ...args);
|
|
394
|
-
return this;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Добавить конструктор и связанный экземпляр.
|
|
398
|
-
*
|
|
399
|
-
* @param {*} ctor
|
|
400
|
-
* @param {*} service
|
|
401
|
-
* @return {this}
|
|
402
|
-
*/
|
|
403
|
-
setService(ctor, service) {
|
|
404
|
-
this.container.set(ctor, service);
|
|
405
|
-
return this;
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
__name(_Service, "Service");
|
|
409
|
-
Service = _Service;
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
// node_modules/@e22m4u/js-service/src/index.js
|
|
414
|
-
var init_src2 = __esm({
|
|
415
|
-
"node_modules/@e22m4u/js-service/src/index.js"() {
|
|
416
|
-
init_service();
|
|
417
|
-
init_service_container();
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
|
|
421
41
|
// src/errors/not-implemented-error.js
|
|
422
|
-
var _NotImplementedError, NotImplementedError;
|
|
42
|
+
var import_js_format, _NotImplementedError, NotImplementedError;
|
|
423
43
|
var init_not_implemented_error = __esm({
|
|
424
44
|
"src/errors/not-implemented-error.js"() {
|
|
425
45
|
"use strict";
|
|
426
|
-
|
|
427
|
-
_NotImplementedError = class _NotImplementedError extends Errorf {
|
|
46
|
+
import_js_format = require("@e22m4u/js-format");
|
|
47
|
+
_NotImplementedError = class _NotImplementedError extends import_js_format.Errorf {
|
|
428
48
|
};
|
|
429
49
|
__name(_NotImplementedError, "NotImplementedError");
|
|
430
50
|
NotImplementedError = _NotImplementedError;
|
|
@@ -432,24 +52,24 @@ var init_not_implemented_error = __esm({
|
|
|
432
52
|
});
|
|
433
53
|
|
|
434
54
|
// src/errors/invalid-argument-error.js
|
|
435
|
-
var
|
|
436
|
-
var
|
|
55
|
+
var import_js_format2, _InvalidArgumentError, InvalidArgumentError;
|
|
56
|
+
var init_invalid_argument_error = __esm({
|
|
437
57
|
"src/errors/invalid-argument-error.js"() {
|
|
438
58
|
"use strict";
|
|
439
|
-
|
|
440
|
-
|
|
59
|
+
import_js_format2 = require("@e22m4u/js-format");
|
|
60
|
+
_InvalidArgumentError = class _InvalidArgumentError extends import_js_format2.Errorf {
|
|
441
61
|
};
|
|
442
|
-
__name(
|
|
443
|
-
|
|
62
|
+
__name(_InvalidArgumentError, "InvalidArgumentError");
|
|
63
|
+
InvalidArgumentError = _InvalidArgumentError;
|
|
444
64
|
}
|
|
445
65
|
});
|
|
446
66
|
|
|
447
67
|
// src/errors/invalid-operator-value-error.js
|
|
448
|
-
var _InvalidOperatorValueError, InvalidOperatorValueError;
|
|
68
|
+
var import_js_format3, _InvalidOperatorValueError, InvalidOperatorValueError;
|
|
449
69
|
var init_invalid_operator_value_error = __esm({
|
|
450
70
|
"src/errors/invalid-operator-value-error.js"() {
|
|
451
71
|
"use strict";
|
|
452
|
-
|
|
72
|
+
import_js_format3 = require("@e22m4u/js-format");
|
|
453
73
|
_InvalidOperatorValueError = class _InvalidOperatorValueError extends Error {
|
|
454
74
|
/**
|
|
455
75
|
* Constructor.
|
|
@@ -460,7 +80,7 @@ var init_invalid_operator_value_error = __esm({
|
|
|
460
80
|
*/
|
|
461
81
|
constructor(operator, expected, value) {
|
|
462
82
|
super(
|
|
463
|
-
format(
|
|
83
|
+
(0, import_js_format3.format)(
|
|
464
84
|
"Condition of {%s: ...} should have %s, but %v given.",
|
|
465
85
|
operator,
|
|
466
86
|
expected,
|
|
@@ -475,23 +95,23 @@ var init_invalid_operator_value_error = __esm({
|
|
|
475
95
|
});
|
|
476
96
|
|
|
477
97
|
// src/errors/index.js
|
|
478
|
-
var
|
|
98
|
+
var init_errors = __esm({
|
|
479
99
|
"src/errors/index.js"() {
|
|
480
100
|
"use strict";
|
|
481
101
|
init_not_implemented_error();
|
|
482
|
-
|
|
102
|
+
init_invalid_argument_error();
|
|
483
103
|
init_invalid_operator_value_error();
|
|
484
104
|
}
|
|
485
105
|
});
|
|
486
106
|
|
|
487
107
|
// src/filter/slice-clause-tool.js
|
|
488
|
-
var _SliceClauseTool, SliceClauseTool;
|
|
108
|
+
var import_js_service, _SliceClauseTool, SliceClauseTool;
|
|
489
109
|
var init_slice_clause_tool = __esm({
|
|
490
110
|
"src/filter/slice-clause-tool.js"() {
|
|
491
111
|
"use strict";
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
_SliceClauseTool = class _SliceClauseTool extends Service {
|
|
112
|
+
import_js_service = require("@e22m4u/js-service");
|
|
113
|
+
init_errors();
|
|
114
|
+
_SliceClauseTool = class _SliceClauseTool extends import_js_service.Service {
|
|
495
115
|
/**
|
|
496
116
|
* Slice.
|
|
497
117
|
*
|
|
@@ -502,17 +122,17 @@ var init_slice_clause_tool = __esm({
|
|
|
502
122
|
*/
|
|
503
123
|
slice(entities, skip = void 0, limit = void 0) {
|
|
504
124
|
if (!Array.isArray(entities))
|
|
505
|
-
throw new
|
|
125
|
+
throw new InvalidArgumentError(
|
|
506
126
|
"The first argument of SliceClauseTool.slice should be an Array, but %v given.",
|
|
507
127
|
entities
|
|
508
128
|
);
|
|
509
129
|
if (skip != null && typeof skip !== "number")
|
|
510
|
-
throw new
|
|
130
|
+
throw new InvalidArgumentError(
|
|
511
131
|
'The provided option "skip" should be a Number, but %v given.',
|
|
512
132
|
skip
|
|
513
133
|
);
|
|
514
134
|
if (limit != null && typeof limit !== "number")
|
|
515
|
-
throw new
|
|
135
|
+
throw new InvalidArgumentError(
|
|
516
136
|
'The provided option "limit" should be a Number, but %v given.',
|
|
517
137
|
limit
|
|
518
138
|
);
|
|
@@ -528,7 +148,7 @@ var init_slice_clause_tool = __esm({
|
|
|
528
148
|
static validateSkipClause(skip) {
|
|
529
149
|
if (skip == null) return;
|
|
530
150
|
if (typeof skip !== "number")
|
|
531
|
-
throw new
|
|
151
|
+
throw new InvalidArgumentError(
|
|
532
152
|
'The provided option "skip" should be a Number, but %v given.',
|
|
533
153
|
skip
|
|
534
154
|
);
|
|
@@ -541,7 +161,7 @@ var init_slice_clause_tool = __esm({
|
|
|
541
161
|
static validateLimitClause(limit) {
|
|
542
162
|
if (limit == null) return;
|
|
543
163
|
if (typeof limit !== "number")
|
|
544
|
-
throw new
|
|
164
|
+
throw new InvalidArgumentError(
|
|
545
165
|
'The provided option "limit" should be a Number, but %v given.',
|
|
546
166
|
limit
|
|
547
167
|
);
|
|
@@ -793,18 +413,18 @@ var init_transform_promise = __esm({
|
|
|
793
413
|
// src/utils/select-object-keys.js
|
|
794
414
|
function selectObjectKeys(obj, keys) {
|
|
795
415
|
if (!obj || typeof obj !== "object" || Array.isArray(obj))
|
|
796
|
-
throw new
|
|
416
|
+
throw new InvalidArgumentError(
|
|
797
417
|
"The first argument of selectObjectKeys should be an Object, but %v given.",
|
|
798
418
|
obj
|
|
799
419
|
);
|
|
800
420
|
if (!Array.isArray(keys))
|
|
801
|
-
throw new
|
|
421
|
+
throw new InvalidArgumentError(
|
|
802
422
|
"The second argument of selectObjectKeys should be an Array of String, but %v given.",
|
|
803
423
|
keys
|
|
804
424
|
);
|
|
805
425
|
keys.forEach((key) => {
|
|
806
426
|
if (typeof key !== "string")
|
|
807
|
-
throw new
|
|
427
|
+
throw new InvalidArgumentError(
|
|
808
428
|
"The second argument of selectObjectKeys should be an Array of String, but %v given.",
|
|
809
429
|
key
|
|
810
430
|
);
|
|
@@ -819,7 +439,7 @@ function selectObjectKeys(obj, keys) {
|
|
|
819
439
|
var init_select_object_keys = __esm({
|
|
820
440
|
"src/utils/select-object-keys.js"() {
|
|
821
441
|
"use strict";
|
|
822
|
-
|
|
442
|
+
init_errors();
|
|
823
443
|
__name(selectObjectKeys, "selectObjectKeys");
|
|
824
444
|
}
|
|
825
445
|
});
|
|
@@ -827,7 +447,7 @@ var init_select_object_keys = __esm({
|
|
|
827
447
|
// src/utils/exclude-object-keys.js
|
|
828
448
|
function excludeObjectKeys(obj, keys) {
|
|
829
449
|
if (typeof obj !== "object" || !obj || Array.isArray(obj))
|
|
830
|
-
throw new
|
|
450
|
+
throw new InvalidArgumentError(
|
|
831
451
|
"Cannot exclude keys from a non-Object value, %v given.",
|
|
832
452
|
obj
|
|
833
453
|
);
|
|
@@ -839,7 +459,7 @@ function excludeObjectKeys(obj, keys) {
|
|
|
839
459
|
var init_exclude_object_keys = __esm({
|
|
840
460
|
"src/utils/exclude-object-keys.js"() {
|
|
841
461
|
"use strict";
|
|
842
|
-
|
|
462
|
+
init_errors();
|
|
843
463
|
__name(excludeObjectKeys, "excludeObjectKeys");
|
|
844
464
|
}
|
|
845
465
|
});
|
|
@@ -884,7 +504,7 @@ var init_get_decorator_target_type = __esm({
|
|
|
884
504
|
});
|
|
885
505
|
|
|
886
506
|
// src/utils/index.js
|
|
887
|
-
var
|
|
507
|
+
var init_utils = __esm({
|
|
888
508
|
"src/utils/index.js"() {
|
|
889
509
|
"use strict";
|
|
890
510
|
init_is_ctor();
|
|
@@ -920,14 +540,14 @@ function compareFn(a, b) {
|
|
|
920
540
|
}
|
|
921
541
|
return 0;
|
|
922
542
|
}
|
|
923
|
-
var _OrderClauseTool, OrderClauseTool;
|
|
543
|
+
var import_js_service2, _OrderClauseTool, OrderClauseTool;
|
|
924
544
|
var init_order_clause_tool = __esm({
|
|
925
545
|
"src/filter/order-clause-tool.js"() {
|
|
926
546
|
"use strict";
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
_OrderClauseTool = class _OrderClauseTool extends Service {
|
|
547
|
+
import_js_service2 = require("@e22m4u/js-service");
|
|
548
|
+
init_utils();
|
|
549
|
+
init_errors();
|
|
550
|
+
_OrderClauseTool = class _OrderClauseTool extends import_js_service2.Service {
|
|
931
551
|
/**
|
|
932
552
|
* Sort.
|
|
933
553
|
*
|
|
@@ -941,7 +561,7 @@ var init_order_clause_tool = __esm({
|
|
|
941
561
|
const mapping = [];
|
|
942
562
|
clause.forEach((key, index) => {
|
|
943
563
|
if (!key || typeof key !== "string")
|
|
944
|
-
throw new
|
|
564
|
+
throw new InvalidArgumentError(
|
|
945
565
|
'The provided option "order" should be a non-empty String or an Array of non-empty String, but %v given.',
|
|
946
566
|
key
|
|
947
567
|
);
|
|
@@ -966,7 +586,7 @@ var init_order_clause_tool = __esm({
|
|
|
966
586
|
if (!clause.length) return;
|
|
967
587
|
clause.forEach((field) => {
|
|
968
588
|
if (!field || typeof field !== "string")
|
|
969
|
-
throw new
|
|
589
|
+
throw new InvalidArgumentError(
|
|
970
590
|
'The provided option "order" should be a non-empty String or an Array of non-empty String, but %v given.',
|
|
971
591
|
field
|
|
972
592
|
);
|
|
@@ -984,7 +604,7 @@ var init_order_clause_tool = __esm({
|
|
|
984
604
|
if (!clause.length) return;
|
|
985
605
|
clause.forEach((field) => {
|
|
986
606
|
if (!field || typeof field !== "string")
|
|
987
|
-
throw new
|
|
607
|
+
throw new InvalidArgumentError(
|
|
988
608
|
'The provided option "order" should be a non-empty String or an Array of non-empty String, but %v given.',
|
|
989
609
|
field
|
|
990
610
|
);
|
|
@@ -999,15 +619,15 @@ var init_order_clause_tool = __esm({
|
|
|
999
619
|
});
|
|
1000
620
|
|
|
1001
621
|
// src/filter/operator-clause-tool.js
|
|
1002
|
-
var _OperatorClauseTool, OperatorClauseTool;
|
|
622
|
+
var import_js_service3, _OperatorClauseTool, OperatorClauseTool;
|
|
1003
623
|
var init_operator_clause_tool = __esm({
|
|
1004
624
|
"src/filter/operator-clause-tool.js"() {
|
|
1005
625
|
"use strict";
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
_OperatorClauseTool = class _OperatorClauseTool extends Service {
|
|
626
|
+
import_js_service3 = require("@e22m4u/js-service");
|
|
627
|
+
init_utils();
|
|
628
|
+
init_errors();
|
|
629
|
+
init_errors();
|
|
630
|
+
_OperatorClauseTool = class _OperatorClauseTool extends import_js_service3.Service {
|
|
1011
631
|
/**
|
|
1012
632
|
* Compare.
|
|
1013
633
|
*
|
|
@@ -1051,7 +671,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1051
671
|
*/
|
|
1052
672
|
testAll(clause, value) {
|
|
1053
673
|
if (!clause || typeof clause !== "object" || Array.isArray(clause))
|
|
1054
|
-
throw new
|
|
674
|
+
throw new InvalidArgumentError(
|
|
1055
675
|
"The first argument of OperatorUtils.testAll should be an Object, but %v given.",
|
|
1056
676
|
clause
|
|
1057
677
|
);
|
|
@@ -1101,7 +721,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1101
721
|
*/
|
|
1102
722
|
testEqNeq(clause, value) {
|
|
1103
723
|
if (!clause || typeof clause !== "object")
|
|
1104
|
-
throw new
|
|
724
|
+
throw new InvalidArgumentError(
|
|
1105
725
|
"The first argument of OperatorUtils.testEqNeq should be an Object, but %v given.",
|
|
1106
726
|
clause
|
|
1107
727
|
);
|
|
@@ -1145,7 +765,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1145
765
|
*/
|
|
1146
766
|
testGtLt(clause, value) {
|
|
1147
767
|
if (!clause || typeof clause !== "object")
|
|
1148
|
-
throw new
|
|
768
|
+
throw new InvalidArgumentError(
|
|
1149
769
|
"The first argument of OperatorUtils.testGtLt should be an Object, but %v given.",
|
|
1150
770
|
clause
|
|
1151
771
|
);
|
|
@@ -1170,7 +790,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1170
790
|
*/
|
|
1171
791
|
testInq(clause, value) {
|
|
1172
792
|
if (!clause || typeof clause !== "object")
|
|
1173
|
-
throw new
|
|
793
|
+
throw new InvalidArgumentError(
|
|
1174
794
|
"The first argument of OperatorUtils.testInq should be an Object, but %v given.",
|
|
1175
795
|
clause
|
|
1176
796
|
);
|
|
@@ -1204,7 +824,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1204
824
|
*/
|
|
1205
825
|
testNin(clause, value) {
|
|
1206
826
|
if (!clause || typeof clause !== "object")
|
|
1207
|
-
throw new
|
|
827
|
+
throw new InvalidArgumentError(
|
|
1208
828
|
"The first argument of OperatorUtils.testNin should be an Object, but %v given.",
|
|
1209
829
|
clause
|
|
1210
830
|
);
|
|
@@ -1238,7 +858,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1238
858
|
*/
|
|
1239
859
|
testBetween(clause, value) {
|
|
1240
860
|
if (!clause || typeof clause !== "object")
|
|
1241
|
-
throw new
|
|
861
|
+
throw new InvalidArgumentError(
|
|
1242
862
|
"The first argument of OperatorUtils.testBetween should be an Object, but %v given.",
|
|
1243
863
|
clause
|
|
1244
864
|
);
|
|
@@ -1269,7 +889,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1269
889
|
*/
|
|
1270
890
|
testExists(clause, value) {
|
|
1271
891
|
if (!clause || typeof clause !== "object")
|
|
1272
|
-
throw new
|
|
892
|
+
throw new InvalidArgumentError(
|
|
1273
893
|
"The first argument of OperatorUtils.testExists should be an Object, but %v given.",
|
|
1274
894
|
clause
|
|
1275
895
|
);
|
|
@@ -1300,7 +920,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1300
920
|
*/
|
|
1301
921
|
testLike(clause, value) {
|
|
1302
922
|
if (!clause || typeof clause !== "object")
|
|
1303
|
-
throw new
|
|
923
|
+
throw new InvalidArgumentError(
|
|
1304
924
|
"The first argument of OperatorUtils.testLike should be an Object, but %v given.",
|
|
1305
925
|
clause
|
|
1306
926
|
);
|
|
@@ -1326,7 +946,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1326
946
|
*/
|
|
1327
947
|
testNlike(clause, value) {
|
|
1328
948
|
if (!clause || typeof clause !== "object")
|
|
1329
|
-
throw new
|
|
949
|
+
throw new InvalidArgumentError(
|
|
1330
950
|
"The first argument of OperatorUtils.testNlike should be an Object, but %v given.",
|
|
1331
951
|
clause
|
|
1332
952
|
);
|
|
@@ -1353,7 +973,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1353
973
|
*/
|
|
1354
974
|
testIlike(clause, value) {
|
|
1355
975
|
if (!clause || typeof clause !== "object")
|
|
1356
|
-
throw new
|
|
976
|
+
throw new InvalidArgumentError(
|
|
1357
977
|
"The first argument of OperatorUtils.testIlike should be an Object, but %v given.",
|
|
1358
978
|
clause
|
|
1359
979
|
);
|
|
@@ -1380,7 +1000,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1380
1000
|
*/
|
|
1381
1001
|
testNilike(clause, value) {
|
|
1382
1002
|
if (!clause || typeof clause !== "object")
|
|
1383
|
-
throw new
|
|
1003
|
+
throw new InvalidArgumentError(
|
|
1384
1004
|
"The first argument of OperatorUtils.testNilike should be an Object, but %v given.",
|
|
1385
1005
|
clause
|
|
1386
1006
|
);
|
|
@@ -1419,7 +1039,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1419
1039
|
*/
|
|
1420
1040
|
testRegexp(clause, value) {
|
|
1421
1041
|
if (!clause || typeof clause !== "object")
|
|
1422
|
-
throw new
|
|
1042
|
+
throw new InvalidArgumentError(
|
|
1423
1043
|
"The first argument of OperatorUtils.testRegexp should be an Object, but %v given.",
|
|
1424
1044
|
clause
|
|
1425
1045
|
);
|
|
@@ -1433,7 +1053,7 @@ var init_operator_clause_tool = __esm({
|
|
|
1433
1053
|
}
|
|
1434
1054
|
const flags = clause.flags || void 0;
|
|
1435
1055
|
if (flags && typeof flags !== "string")
|
|
1436
|
-
throw new
|
|
1056
|
+
throw new InvalidArgumentError(
|
|
1437
1057
|
"RegExp flags should be a String, but %v given.",
|
|
1438
1058
|
clause.flags
|
|
1439
1059
|
);
|
|
@@ -1449,15 +1069,15 @@ var init_operator_clause_tool = __esm({
|
|
|
1449
1069
|
});
|
|
1450
1070
|
|
|
1451
1071
|
// src/filter/where-clause-tool.js
|
|
1452
|
-
var _WhereClauseTool, WhereClauseTool;
|
|
1072
|
+
var import_js_service4, _WhereClauseTool, WhereClauseTool;
|
|
1453
1073
|
var init_where_clause_tool = __esm({
|
|
1454
1074
|
"src/filter/where-clause-tool.js"() {
|
|
1455
1075
|
"use strict";
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1076
|
+
import_js_service4 = require("@e22m4u/js-service");
|
|
1077
|
+
init_utils();
|
|
1078
|
+
init_errors();
|
|
1459
1079
|
init_operator_clause_tool();
|
|
1460
|
-
_WhereClauseTool = class _WhereClauseTool extends Service {
|
|
1080
|
+
_WhereClauseTool = class _WhereClauseTool extends import_js_service4.Service {
|
|
1461
1081
|
/**
|
|
1462
1082
|
* Filter by where clause.
|
|
1463
1083
|
*
|
|
@@ -1489,7 +1109,7 @@ var init_where_clause_tool = __esm({
|
|
|
1489
1109
|
*/
|
|
1490
1110
|
filter(entities, where = void 0) {
|
|
1491
1111
|
if (!Array.isArray(entities))
|
|
1492
|
-
throw new
|
|
1112
|
+
throw new InvalidArgumentError(
|
|
1493
1113
|
"The first argument of WhereClauseTool.filter should be an Array of Object, but %v given.",
|
|
1494
1114
|
entities
|
|
1495
1115
|
);
|
|
@@ -1504,14 +1124,14 @@ var init_where_clause_tool = __esm({
|
|
|
1504
1124
|
*/
|
|
1505
1125
|
_createFilter(whereClause) {
|
|
1506
1126
|
if (typeof whereClause !== "object" || Array.isArray(whereClause))
|
|
1507
|
-
throw new
|
|
1127
|
+
throw new InvalidArgumentError(
|
|
1508
1128
|
'The provided option "where" should be an Object, but %v given.',
|
|
1509
1129
|
whereClause
|
|
1510
1130
|
);
|
|
1511
1131
|
const keys = Object.keys(whereClause);
|
|
1512
1132
|
return (data) => {
|
|
1513
1133
|
if (typeof data !== "object")
|
|
1514
|
-
throw new
|
|
1134
|
+
throw new InvalidArgumentError(
|
|
1515
1135
|
"The first argument of WhereClauseTool.filter should be an Array of Object, but %v given.",
|
|
1516
1136
|
data
|
|
1517
1137
|
);
|
|
@@ -1581,7 +1201,7 @@ var init_where_clause_tool = __esm({
|
|
|
1581
1201
|
static validateWhereClause(clause) {
|
|
1582
1202
|
if (clause == null || typeof clause === "function") return;
|
|
1583
1203
|
if (typeof clause !== "object" || Array.isArray(clause))
|
|
1584
|
-
throw new
|
|
1204
|
+
throw new InvalidArgumentError(
|
|
1585
1205
|
'The provided option "where" should be an Object, but %v given.',
|
|
1586
1206
|
clause
|
|
1587
1207
|
);
|
|
@@ -1614,15 +1234,15 @@ var init_relation_definition = __esm({
|
|
|
1614
1234
|
});
|
|
1615
1235
|
|
|
1616
1236
|
// src/definition/model/relations/relations-definition-validator.js
|
|
1617
|
-
var _RelationsDefinitionValidator, RelationsDefinitionValidator;
|
|
1237
|
+
var import_js_service5, _RelationsDefinitionValidator, RelationsDefinitionValidator;
|
|
1618
1238
|
var init_relations_definition_validator = __esm({
|
|
1619
1239
|
"src/definition/model/relations/relations-definition-validator.js"() {
|
|
1620
1240
|
"use strict";
|
|
1621
|
-
|
|
1241
|
+
import_js_service5 = require("@e22m4u/js-service");
|
|
1622
1242
|
init_relation_type();
|
|
1623
1243
|
init_relation_type();
|
|
1624
|
-
|
|
1625
|
-
_RelationsDefinitionValidator = class _RelationsDefinitionValidator extends Service {
|
|
1244
|
+
init_errors();
|
|
1245
|
+
_RelationsDefinitionValidator = class _RelationsDefinitionValidator extends import_js_service5.Service {
|
|
1626
1246
|
/**
|
|
1627
1247
|
* Validate.
|
|
1628
1248
|
*
|
|
@@ -1631,12 +1251,12 @@ var init_relations_definition_validator = __esm({
|
|
|
1631
1251
|
*/
|
|
1632
1252
|
validate(modelName, relDefs) {
|
|
1633
1253
|
if (!modelName || typeof modelName !== "string")
|
|
1634
|
-
throw new
|
|
1254
|
+
throw new InvalidArgumentError(
|
|
1635
1255
|
"The first argument of RelationsDefinitionValidator.validate should be a non-empty String, but %v given.",
|
|
1636
1256
|
modelName
|
|
1637
1257
|
);
|
|
1638
1258
|
if (!relDefs || typeof relDefs !== "object" || Array.isArray(relDefs))
|
|
1639
|
-
throw new
|
|
1259
|
+
throw new InvalidArgumentError(
|
|
1640
1260
|
'The provided option "relations" of the model %v should be an Object, but %v given.',
|
|
1641
1261
|
modelName,
|
|
1642
1262
|
relDefs
|
|
@@ -1656,25 +1276,25 @@ var init_relations_definition_validator = __esm({
|
|
|
1656
1276
|
*/
|
|
1657
1277
|
_validateRelation(modelName, relName, relDef) {
|
|
1658
1278
|
if (!modelName || typeof modelName !== "string")
|
|
1659
|
-
throw new
|
|
1279
|
+
throw new InvalidArgumentError(
|
|
1660
1280
|
"The first argument of RelationsDefinitionValidator._validateRelation should be a non-empty String, but %v given.",
|
|
1661
1281
|
modelName
|
|
1662
1282
|
);
|
|
1663
1283
|
if (!relName || typeof relName !== "string")
|
|
1664
|
-
throw new
|
|
1284
|
+
throw new InvalidArgumentError(
|
|
1665
1285
|
"The relation name of the model %v should be a non-empty String, but %v given.",
|
|
1666
1286
|
modelName,
|
|
1667
1287
|
relName
|
|
1668
1288
|
);
|
|
1669
1289
|
if (!relDef || typeof relDef !== "object" || Array.isArray(relDef))
|
|
1670
|
-
throw new
|
|
1290
|
+
throw new InvalidArgumentError(
|
|
1671
1291
|
"The relation %v of the model %v should be an Object, but %v given.",
|
|
1672
1292
|
relName,
|
|
1673
1293
|
modelName,
|
|
1674
1294
|
relDef
|
|
1675
1295
|
);
|
|
1676
1296
|
if (!relDef.type || !Object.values(RelationType).includes(relDef.type))
|
|
1677
|
-
throw new
|
|
1297
|
+
throw new InvalidArgumentError(
|
|
1678
1298
|
'The relation %v of the model %v requires the option "type" to have one of relation types: %l, but %v given.',
|
|
1679
1299
|
relName,
|
|
1680
1300
|
modelName,
|
|
@@ -1717,21 +1337,21 @@ var init_relations_definition_validator = __esm({
|
|
|
1717
1337
|
if (relDef.type !== RelationType.BELONGS_TO) return;
|
|
1718
1338
|
if (relDef.polymorphic) {
|
|
1719
1339
|
if (typeof relDef.polymorphic !== "boolean")
|
|
1720
|
-
throw new
|
|
1340
|
+
throw new InvalidArgumentError(
|
|
1721
1341
|
'The relation %v of the model %v has the type "belongsTo", so it expects the option "polymorphic" to be a Boolean, but %v given.',
|
|
1722
1342
|
relName,
|
|
1723
1343
|
modelName,
|
|
1724
1344
|
relDef.polymorphic
|
|
1725
1345
|
);
|
|
1726
1346
|
if (relDef.foreignKey && typeof relDef.foreignKey !== "string")
|
|
1727
|
-
throw new
|
|
1347
|
+
throw new InvalidArgumentError(
|
|
1728
1348
|
'The relation %v of the model %v is a polymorphic "belongsTo" relation, so it expects the provided option "foreignKey" to be a String, but %v given.',
|
|
1729
1349
|
relName,
|
|
1730
1350
|
modelName,
|
|
1731
1351
|
relDef.foreignKey
|
|
1732
1352
|
);
|
|
1733
1353
|
if (relDef.discriminator && typeof relDef.discriminator !== "string")
|
|
1734
|
-
throw new
|
|
1354
|
+
throw new InvalidArgumentError(
|
|
1735
1355
|
'The relation %v of the model %v is a polymorphic "belongsTo" relation, so it expects the provided option "discriminator" to be a String, but %v given.',
|
|
1736
1356
|
relName,
|
|
1737
1357
|
modelName,
|
|
@@ -1739,21 +1359,21 @@ var init_relations_definition_validator = __esm({
|
|
|
1739
1359
|
);
|
|
1740
1360
|
} else {
|
|
1741
1361
|
if (!relDef.model || typeof relDef.model !== "string")
|
|
1742
|
-
throw new
|
|
1362
|
+
throw new InvalidArgumentError(
|
|
1743
1363
|
'The relation %v of the model %v has the type "belongsTo", so it requires the option "model" to be a non-empty String, but %v given.',
|
|
1744
1364
|
relName,
|
|
1745
1365
|
modelName,
|
|
1746
1366
|
relDef.model
|
|
1747
1367
|
);
|
|
1748
1368
|
if (relDef.foreignKey && typeof relDef.foreignKey !== "string")
|
|
1749
|
-
throw new
|
|
1369
|
+
throw new InvalidArgumentError(
|
|
1750
1370
|
'The relation %v of the model %v has the type "belongsTo", so it expects the provided option "foreignKey" to be a String, but %v given.',
|
|
1751
1371
|
relName,
|
|
1752
1372
|
modelName,
|
|
1753
1373
|
relDef.foreignKey
|
|
1754
1374
|
);
|
|
1755
1375
|
if (relDef.discriminator)
|
|
1756
|
-
throw new
|
|
1376
|
+
throw new InvalidArgumentError(
|
|
1757
1377
|
'The relation %v of the model %v is a non-polymorphic "belongsTo" relation, so it should not have the option "discriminator" to be provided.',
|
|
1758
1378
|
relName,
|
|
1759
1379
|
modelName
|
|
@@ -1800,7 +1420,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1800
1420
|
_validateHasOne(modelName, relName, relDef) {
|
|
1801
1421
|
if (relDef.type !== RelationType.HAS_ONE) return;
|
|
1802
1422
|
if (!relDef.model || typeof relDef.model !== "string")
|
|
1803
|
-
throw new
|
|
1423
|
+
throw new InvalidArgumentError(
|
|
1804
1424
|
'The relation %v of the model %v has the type "hasOne", so it requires the option "model" to be a non-empty String, but %v given.',
|
|
1805
1425
|
relName,
|
|
1806
1426
|
modelName,
|
|
@@ -1809,34 +1429,34 @@ var init_relations_definition_validator = __esm({
|
|
|
1809
1429
|
if (relDef.polymorphic) {
|
|
1810
1430
|
if (typeof relDef.polymorphic === "string") {
|
|
1811
1431
|
if (relDef.foreignKey)
|
|
1812
|
-
throw new
|
|
1432
|
+
throw new InvalidArgumentError(
|
|
1813
1433
|
'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "foreignKey" to be provided.',
|
|
1814
1434
|
relName,
|
|
1815
1435
|
modelName
|
|
1816
1436
|
);
|
|
1817
1437
|
if (relDef.discriminator)
|
|
1818
|
-
throw new
|
|
1438
|
+
throw new InvalidArgumentError(
|
|
1819
1439
|
'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "discriminator" to be provided.',
|
|
1820
1440
|
relName,
|
|
1821
1441
|
modelName
|
|
1822
1442
|
);
|
|
1823
1443
|
} else if (typeof relDef.polymorphic === "boolean") {
|
|
1824
1444
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
|
|
1825
|
-
throw new
|
|
1445
|
+
throw new InvalidArgumentError(
|
|
1826
1446
|
'The relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "foreignKey" to be a non-empty String, but %v given.',
|
|
1827
1447
|
relName,
|
|
1828
1448
|
modelName,
|
|
1829
1449
|
relDef.foreignKey
|
|
1830
1450
|
);
|
|
1831
1451
|
if (!relDef.discriminator || typeof relDef.discriminator !== "string")
|
|
1832
|
-
throw new
|
|
1452
|
+
throw new InvalidArgumentError(
|
|
1833
1453
|
'The relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "discriminator" to be a non-empty String, but %v given.',
|
|
1834
1454
|
relName,
|
|
1835
1455
|
modelName,
|
|
1836
1456
|
relDef.discriminator
|
|
1837
1457
|
);
|
|
1838
1458
|
} else {
|
|
1839
|
-
throw new
|
|
1459
|
+
throw new InvalidArgumentError(
|
|
1840
1460
|
'The relation %v of the model %v has the type "hasOne", so it expects the provided option "polymorphic" to be a String or a Boolean, but %v given.',
|
|
1841
1461
|
relName,
|
|
1842
1462
|
modelName,
|
|
@@ -1845,14 +1465,14 @@ var init_relations_definition_validator = __esm({
|
|
|
1845
1465
|
}
|
|
1846
1466
|
} else {
|
|
1847
1467
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
|
|
1848
|
-
throw new
|
|
1468
|
+
throw new InvalidArgumentError(
|
|
1849
1469
|
'The relation %v of the model %v has the type "hasOne", so it requires the option "foreignKey" to be a non-empty String, but %v given.',
|
|
1850
1470
|
relName,
|
|
1851
1471
|
modelName,
|
|
1852
1472
|
relDef.foreignKey
|
|
1853
1473
|
);
|
|
1854
1474
|
if (relDef.discriminator)
|
|
1855
|
-
throw new
|
|
1475
|
+
throw new InvalidArgumentError(
|
|
1856
1476
|
'The relation %v of the model %v is a non-polymorphic "hasOne" relation, so it should not have the option "discriminator" to be provided.',
|
|
1857
1477
|
relName,
|
|
1858
1478
|
modelName
|
|
@@ -1899,7 +1519,7 @@ var init_relations_definition_validator = __esm({
|
|
|
1899
1519
|
_validateHasMany(modelName, relName, relDef) {
|
|
1900
1520
|
if (relDef.type !== RelationType.HAS_MANY) return;
|
|
1901
1521
|
if (!relDef.model || typeof relDef.model !== "string")
|
|
1902
|
-
throw new
|
|
1522
|
+
throw new InvalidArgumentError(
|
|
1903
1523
|
'The relation %v of the model %v has the type "hasMany", so it requires the option "model" to be a non-empty String, but %v given.',
|
|
1904
1524
|
relName,
|
|
1905
1525
|
modelName,
|
|
@@ -1908,34 +1528,34 @@ var init_relations_definition_validator = __esm({
|
|
|
1908
1528
|
if (relDef.polymorphic) {
|
|
1909
1529
|
if (typeof relDef.polymorphic === "string") {
|
|
1910
1530
|
if (relDef.foreignKey)
|
|
1911
|
-
throw new
|
|
1531
|
+
throw new InvalidArgumentError(
|
|
1912
1532
|
'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "foreignKey" to be provided.',
|
|
1913
1533
|
relName,
|
|
1914
1534
|
modelName
|
|
1915
1535
|
);
|
|
1916
1536
|
if (relDef.discriminator)
|
|
1917
|
-
throw new
|
|
1537
|
+
throw new InvalidArgumentError(
|
|
1918
1538
|
'The relation %v of the model %v has the option "polymorphic" with a String value, so it should not have the option "discriminator" to be provided.',
|
|
1919
1539
|
relName,
|
|
1920
1540
|
modelName
|
|
1921
1541
|
);
|
|
1922
1542
|
} else if (typeof relDef.polymorphic === "boolean") {
|
|
1923
1543
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
|
|
1924
|
-
throw new
|
|
1544
|
+
throw new InvalidArgumentError(
|
|
1925
1545
|
'The relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "foreignKey" to be a non-empty String, but %v given.',
|
|
1926
1546
|
relName,
|
|
1927
1547
|
modelName,
|
|
1928
1548
|
relDef.foreignKey
|
|
1929
1549
|
);
|
|
1930
1550
|
if (!relDef.discriminator || typeof relDef.discriminator !== "string")
|
|
1931
|
-
throw new
|
|
1551
|
+
throw new InvalidArgumentError(
|
|
1932
1552
|
'The relation %v of the model %v has the option "polymorphic" with "true" value, so it requires the option "discriminator" to be a non-empty String, but %v given.',
|
|
1933
1553
|
relName,
|
|
1934
1554
|
modelName,
|
|
1935
1555
|
relDef.discriminator
|
|
1936
1556
|
);
|
|
1937
1557
|
} else {
|
|
1938
|
-
throw new
|
|
1558
|
+
throw new InvalidArgumentError(
|
|
1939
1559
|
'The relation %v of the model %v has the type "hasMany", so it expects the provided option "polymorphic" to be a String or a Boolean, but %v given.',
|
|
1940
1560
|
relName,
|
|
1941
1561
|
modelName,
|
|
@@ -1944,14 +1564,14 @@ var init_relations_definition_validator = __esm({
|
|
|
1944
1564
|
}
|
|
1945
1565
|
} else {
|
|
1946
1566
|
if (!relDef.foreignKey || typeof relDef.foreignKey !== "string")
|
|
1947
|
-
throw new
|
|
1567
|
+
throw new InvalidArgumentError(
|
|
1948
1568
|
'The relation %v of the model %v has the type "hasMany", so it requires the option "foreignKey" to be a non-empty String, but %v given.',
|
|
1949
1569
|
relName,
|
|
1950
1570
|
modelName,
|
|
1951
1571
|
relDef.foreignKey
|
|
1952
1572
|
);
|
|
1953
1573
|
if (relDef.discriminator)
|
|
1954
|
-
throw new
|
|
1574
|
+
throw new InvalidArgumentError(
|
|
1955
1575
|
'The relation %v of the model %v is a non-polymorphic "hasMany" relation, so it should not have the option "discriminator" to be provided.',
|
|
1956
1576
|
relName,
|
|
1957
1577
|
modelName
|
|
@@ -1978,21 +1598,21 @@ var init_relations_definition_validator = __esm({
|
|
|
1978
1598
|
_validateReferencesMany(modelName, relName, relDef) {
|
|
1979
1599
|
if (relDef.type !== RelationType.REFERENCES_MANY) return;
|
|
1980
1600
|
if (!relDef.model || typeof relDef.model !== "string")
|
|
1981
|
-
throw new
|
|
1601
|
+
throw new InvalidArgumentError(
|
|
1982
1602
|
'The relation %v of the model %v has the type "referencesMany", so it requires the option "model" to be a non-empty String, but %v given.',
|
|
1983
1603
|
relName,
|
|
1984
1604
|
modelName,
|
|
1985
1605
|
relDef.model
|
|
1986
1606
|
);
|
|
1987
1607
|
if (relDef.foreignKey && typeof relDef.foreignKey !== "string")
|
|
1988
|
-
throw new
|
|
1608
|
+
throw new InvalidArgumentError(
|
|
1989
1609
|
'The relation %v of the model %v has the type "referencesMany", so it expects the provided option "foreignKey" to be a String, but %v given.',
|
|
1990
1610
|
relName,
|
|
1991
1611
|
modelName,
|
|
1992
1612
|
relDef.foreignKey
|
|
1993
1613
|
);
|
|
1994
1614
|
if (relDef.discriminator)
|
|
1995
|
-
throw new
|
|
1615
|
+
throw new InvalidArgumentError(
|
|
1996
1616
|
'The relation %v of the model %v has the type "referencesMany", so it should not have the option "discriminator" to be provided.',
|
|
1997
1617
|
relName,
|
|
1998
1618
|
modelName
|
|
@@ -2051,15 +1671,15 @@ var init_property_uniqueness = __esm({
|
|
|
2051
1671
|
});
|
|
2052
1672
|
|
|
2053
1673
|
// src/definition/model/properties/empty-values-definer.js
|
|
2054
|
-
var _EmptyValuesDefiner, EmptyValuesDefiner;
|
|
1674
|
+
var import_js_service6, _EmptyValuesDefiner, EmptyValuesDefiner;
|
|
2055
1675
|
var init_empty_values_definer = __esm({
|
|
2056
1676
|
"src/definition/model/properties/empty-values-definer.js"() {
|
|
2057
1677
|
"use strict";
|
|
2058
1678
|
init_data_type();
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
_EmptyValuesDefiner = class _EmptyValuesDefiner extends Service {
|
|
1679
|
+
import_js_service6 = require("@e22m4u/js-service");
|
|
1680
|
+
init_utils();
|
|
1681
|
+
init_errors();
|
|
1682
|
+
_EmptyValuesDefiner = class _EmptyValuesDefiner extends import_js_service6.Service {
|
|
2063
1683
|
/**
|
|
2064
1684
|
* Empty values map.
|
|
2065
1685
|
*
|
|
@@ -2082,13 +1702,13 @@ var init_empty_values_definer = __esm({
|
|
|
2082
1702
|
*/
|
|
2083
1703
|
setEmptyValuesOf(dataType, emptyValues) {
|
|
2084
1704
|
if (!Object.values(DataType).includes(dataType))
|
|
2085
|
-
throw new
|
|
1705
|
+
throw new InvalidArgumentError(
|
|
2086
1706
|
'The argument "dataType" of the EmptyValuesDefiner.setEmptyValuesOf must be one of data types: %l, but %v given.',
|
|
2087
1707
|
Object.values(DataType),
|
|
2088
1708
|
dataType
|
|
2089
1709
|
);
|
|
2090
1710
|
if (!Array.isArray(emptyValues))
|
|
2091
|
-
throw new
|
|
1711
|
+
throw new InvalidArgumentError(
|
|
2092
1712
|
'The argument "emptyValues" of the EmptyValuesDefiner.setEmptyValuesOf must be an Array, but %v given.',
|
|
2093
1713
|
emptyValues
|
|
2094
1714
|
);
|
|
@@ -2104,7 +1724,7 @@ var init_empty_values_definer = __esm({
|
|
|
2104
1724
|
*/
|
|
2105
1725
|
isEmpty(dataType, value) {
|
|
2106
1726
|
if (!Object.values(DataType).includes(dataType))
|
|
2107
|
-
throw new
|
|
1727
|
+
throw new InvalidArgumentError(
|
|
2108
1728
|
'The argument "dataType" of the EmptyValuesDefiner.isEmpty must be one of data types: %l, but %v given.',
|
|
2109
1729
|
Object.values(DataType),
|
|
2110
1730
|
dataType
|
|
@@ -2128,7 +1748,7 @@ var init_property_validator = __esm({
|
|
|
2128
1748
|
function regexpValidator(value, options, context) {
|
|
2129
1749
|
if (value == null || options === false) return true;
|
|
2130
1750
|
if (typeof options !== "string" && !(options instanceof RegExp))
|
|
2131
|
-
throw new
|
|
1751
|
+
throw new InvalidArgumentError(
|
|
2132
1752
|
'The validator %v requires the "options" argument as a String or RegExp, but %v given.',
|
|
2133
1753
|
context.validatorName,
|
|
2134
1754
|
options
|
|
@@ -2137,7 +1757,7 @@ function regexpValidator(value, options, context) {
|
|
|
2137
1757
|
const regexp = stringToRegexp(options);
|
|
2138
1758
|
return regexp.test(value);
|
|
2139
1759
|
}
|
|
2140
|
-
throw new
|
|
1760
|
+
throw new InvalidArgumentError(
|
|
2141
1761
|
"The property validator %v requires a String value, but %v given.",
|
|
2142
1762
|
context.validatorName,
|
|
2143
1763
|
value
|
|
@@ -2146,8 +1766,8 @@ function regexpValidator(value, options, context) {
|
|
|
2146
1766
|
var init_regexp_validator = __esm({
|
|
2147
1767
|
"src/definition/model/properties/property-validator/builtin/regexp-validator.js"() {
|
|
2148
1768
|
"use strict";
|
|
2149
|
-
|
|
2150
|
-
|
|
1769
|
+
init_utils();
|
|
1770
|
+
init_errors();
|
|
2151
1771
|
__name(regexpValidator, "regexpValidator");
|
|
2152
1772
|
}
|
|
2153
1773
|
});
|
|
@@ -2156,14 +1776,14 @@ var init_regexp_validator = __esm({
|
|
|
2156
1776
|
function maxLengthValidator(value, options, context) {
|
|
2157
1777
|
if (value == null || options === false) return true;
|
|
2158
1778
|
if (typeof options !== "number")
|
|
2159
|
-
throw new
|
|
1779
|
+
throw new InvalidArgumentError(
|
|
2160
1780
|
'The validator %v requires the "options" argument as a Number, but %v given.',
|
|
2161
1781
|
context.validatorName,
|
|
2162
1782
|
options
|
|
2163
1783
|
);
|
|
2164
1784
|
if (typeof value === "string" || Array.isArray(value))
|
|
2165
1785
|
return value.length <= options;
|
|
2166
|
-
throw new
|
|
1786
|
+
throw new InvalidArgumentError(
|
|
2167
1787
|
"The property validator %v requires a String or an Array value, but %v given.",
|
|
2168
1788
|
context.validatorName,
|
|
2169
1789
|
value
|
|
@@ -2172,7 +1792,7 @@ function maxLengthValidator(value, options, context) {
|
|
|
2172
1792
|
var init_max_length_validator = __esm({
|
|
2173
1793
|
"src/definition/model/properties/property-validator/builtin/max-length-validator.js"() {
|
|
2174
1794
|
"use strict";
|
|
2175
|
-
|
|
1795
|
+
init_errors();
|
|
2176
1796
|
__name(maxLengthValidator, "maxLengthValidator");
|
|
2177
1797
|
}
|
|
2178
1798
|
});
|
|
@@ -2181,14 +1801,14 @@ var init_max_length_validator = __esm({
|
|
|
2181
1801
|
function minLengthValidator(value, options, context) {
|
|
2182
1802
|
if (value == null || options === false) return true;
|
|
2183
1803
|
if (typeof options !== "number")
|
|
2184
|
-
throw new
|
|
1804
|
+
throw new InvalidArgumentError(
|
|
2185
1805
|
'The validator %v requires the "options" argument as a Number, but %v given.',
|
|
2186
1806
|
context.validatorName,
|
|
2187
1807
|
options
|
|
2188
1808
|
);
|
|
2189
1809
|
if (typeof value === "string" || Array.isArray(value))
|
|
2190
1810
|
return value.length >= options;
|
|
2191
|
-
throw new
|
|
1811
|
+
throw new InvalidArgumentError(
|
|
2192
1812
|
"The property validator %v requires a String or an Array value, but %v given.",
|
|
2193
1813
|
context.validatorName,
|
|
2194
1814
|
value
|
|
@@ -2197,7 +1817,7 @@ function minLengthValidator(value, options, context) {
|
|
|
2197
1817
|
var init_min_length_validator = __esm({
|
|
2198
1818
|
"src/definition/model/properties/property-validator/builtin/min-length-validator.js"() {
|
|
2199
1819
|
"use strict";
|
|
2200
|
-
|
|
1820
|
+
init_errors();
|
|
2201
1821
|
__name(minLengthValidator, "minLengthValidator");
|
|
2202
1822
|
}
|
|
2203
1823
|
});
|
|
@@ -2213,16 +1833,16 @@ var init_builtin = __esm({
|
|
|
2213
1833
|
});
|
|
2214
1834
|
|
|
2215
1835
|
// src/definition/model/properties/property-validator/property-validator-registry.js
|
|
2216
|
-
var _PropertyValidatorRegistry, PropertyValidatorRegistry;
|
|
1836
|
+
var import_js_service7, _PropertyValidatorRegistry, PropertyValidatorRegistry;
|
|
2217
1837
|
var init_property_validator_registry = __esm({
|
|
2218
1838
|
"src/definition/model/properties/property-validator/property-validator-registry.js"() {
|
|
2219
1839
|
"use strict";
|
|
2220
|
-
|
|
1840
|
+
import_js_service7 = require("@e22m4u/js-service");
|
|
2221
1841
|
init_builtin();
|
|
2222
1842
|
init_builtin();
|
|
2223
1843
|
init_builtin();
|
|
2224
|
-
|
|
2225
|
-
_PropertyValidatorRegistry = class _PropertyValidatorRegistry extends Service {
|
|
1844
|
+
init_errors();
|
|
1845
|
+
_PropertyValidatorRegistry = class _PropertyValidatorRegistry extends import_js_service7.Service {
|
|
2226
1846
|
/**
|
|
2227
1847
|
* Validators.
|
|
2228
1848
|
*
|
|
@@ -2242,17 +1862,17 @@ var init_property_validator_registry = __esm({
|
|
|
2242
1862
|
*/
|
|
2243
1863
|
addValidator(name, validator) {
|
|
2244
1864
|
if (!name || typeof name !== "string")
|
|
2245
|
-
throw new
|
|
1865
|
+
throw new InvalidArgumentError(
|
|
2246
1866
|
"A name of the property validator must be a non-empty String, but %v given.",
|
|
2247
1867
|
name
|
|
2248
1868
|
);
|
|
2249
1869
|
if (name in this._validators)
|
|
2250
|
-
throw new
|
|
1870
|
+
throw new InvalidArgumentError(
|
|
2251
1871
|
"The property validator %v is already defined.",
|
|
2252
1872
|
name
|
|
2253
1873
|
);
|
|
2254
1874
|
if (typeof validator !== "function")
|
|
2255
|
-
throw new
|
|
1875
|
+
throw new InvalidArgumentError(
|
|
2256
1876
|
"The property validator %v must be a Function, but %v given.",
|
|
2257
1877
|
name,
|
|
2258
1878
|
validator
|
|
@@ -2278,7 +1898,7 @@ var init_property_validator_registry = __esm({
|
|
|
2278
1898
|
getValidator(name) {
|
|
2279
1899
|
const validator = this._validators[name];
|
|
2280
1900
|
if (!validator)
|
|
2281
|
-
throw new
|
|
1901
|
+
throw new InvalidArgumentError(
|
|
2282
1902
|
"The property validator %v is not defined.",
|
|
2283
1903
|
name
|
|
2284
1904
|
);
|
|
@@ -2310,7 +1930,7 @@ var init_property_transformer = __esm({
|
|
|
2310
1930
|
function trimTransformer(value, options, context) {
|
|
2311
1931
|
if (value == null) return value;
|
|
2312
1932
|
if (typeof value === "string") return value.trim();
|
|
2313
|
-
throw new
|
|
1933
|
+
throw new InvalidArgumentError(
|
|
2314
1934
|
"The property transformer %v requires a String value, but %v given.",
|
|
2315
1935
|
context.transformerName,
|
|
2316
1936
|
value
|
|
@@ -2319,7 +1939,7 @@ function trimTransformer(value, options, context) {
|
|
|
2319
1939
|
var init_trim_transformer = __esm({
|
|
2320
1940
|
"src/definition/model/properties/property-transformer/builtin/trim-transformer.js"() {
|
|
2321
1941
|
"use strict";
|
|
2322
|
-
|
|
1942
|
+
init_errors();
|
|
2323
1943
|
__name(trimTransformer, "trimTransformer");
|
|
2324
1944
|
}
|
|
2325
1945
|
});
|
|
@@ -2328,7 +1948,7 @@ var init_trim_transformer = __esm({
|
|
|
2328
1948
|
function toLowerCaseTransformer(value, options, context) {
|
|
2329
1949
|
if (value == null) return value;
|
|
2330
1950
|
if (typeof value === "string") return value.toLowerCase();
|
|
2331
|
-
throw new
|
|
1951
|
+
throw new InvalidArgumentError(
|
|
2332
1952
|
"The property transformer %v requires a String value, but %v given.",
|
|
2333
1953
|
context.transformerName,
|
|
2334
1954
|
value
|
|
@@ -2337,7 +1957,7 @@ function toLowerCaseTransformer(value, options, context) {
|
|
|
2337
1957
|
var init_to_lower_case_transformer = __esm({
|
|
2338
1958
|
"src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.js"() {
|
|
2339
1959
|
"use strict";
|
|
2340
|
-
|
|
1960
|
+
init_errors();
|
|
2341
1961
|
__name(toLowerCaseTransformer, "toLowerCaseTransformer");
|
|
2342
1962
|
}
|
|
2343
1963
|
});
|
|
@@ -2346,7 +1966,7 @@ var init_to_lower_case_transformer = __esm({
|
|
|
2346
1966
|
function toUpperCaseTransformer(value, options, context) {
|
|
2347
1967
|
if (value == null) return value;
|
|
2348
1968
|
if (typeof value === "string") return value.toUpperCase();
|
|
2349
|
-
throw new
|
|
1969
|
+
throw new InvalidArgumentError(
|
|
2350
1970
|
"The property transformer %v requires a String value, but %v given.",
|
|
2351
1971
|
context.transformerName,
|
|
2352
1972
|
value
|
|
@@ -2355,7 +1975,7 @@ function toUpperCaseTransformer(value, options, context) {
|
|
|
2355
1975
|
var init_to_upper_case_transformer = __esm({
|
|
2356
1976
|
"src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.js"() {
|
|
2357
1977
|
"use strict";
|
|
2358
|
-
|
|
1978
|
+
init_errors();
|
|
2359
1979
|
__name(toUpperCaseTransformer, "toUpperCaseTransformer");
|
|
2360
1980
|
}
|
|
2361
1981
|
});
|
|
@@ -2367,7 +1987,7 @@ function toTitleCaseTransformer(value, options, context) {
|
|
|
2367
1987
|
return value.replace(new RegExp("\\p{L}\\S*", "gu"), (text) => {
|
|
2368
1988
|
return text.charAt(0).toUpperCase() + text.substring(1).toLowerCase();
|
|
2369
1989
|
});
|
|
2370
|
-
throw new
|
|
1990
|
+
throw new InvalidArgumentError(
|
|
2371
1991
|
"The property transformer %v requires a String value, but %v given.",
|
|
2372
1992
|
context.transformerName,
|
|
2373
1993
|
value
|
|
@@ -2376,7 +1996,7 @@ function toTitleCaseTransformer(value, options, context) {
|
|
|
2376
1996
|
var init_to_title_case_transformer = __esm({
|
|
2377
1997
|
"src/definition/model/properties/property-transformer/builtin/to-title-case-transformer.js"() {
|
|
2378
1998
|
"use strict";
|
|
2379
|
-
|
|
1999
|
+
init_errors();
|
|
2380
2000
|
__name(toTitleCaseTransformer, "toTitleCaseTransformer");
|
|
2381
2001
|
}
|
|
2382
2002
|
});
|
|
@@ -2393,17 +2013,17 @@ var init_builtin2 = __esm({
|
|
|
2393
2013
|
});
|
|
2394
2014
|
|
|
2395
2015
|
// src/definition/model/properties/property-transformer/property-transformer-registry.js
|
|
2396
|
-
var _PropertyTransformerRegistry, PropertyTransformerRegistry;
|
|
2016
|
+
var import_js_service8, _PropertyTransformerRegistry, PropertyTransformerRegistry;
|
|
2397
2017
|
var init_property_transformer_registry = __esm({
|
|
2398
2018
|
"src/definition/model/properties/property-transformer/property-transformer-registry.js"() {
|
|
2399
2019
|
"use strict";
|
|
2400
|
-
|
|
2020
|
+
import_js_service8 = require("@e22m4u/js-service");
|
|
2401
2021
|
init_builtin2();
|
|
2402
2022
|
init_builtin2();
|
|
2403
2023
|
init_builtin2();
|
|
2404
2024
|
init_builtin2();
|
|
2405
|
-
|
|
2406
|
-
_PropertyTransformerRegistry = class _PropertyTransformerRegistry extends Service {
|
|
2025
|
+
init_errors();
|
|
2026
|
+
_PropertyTransformerRegistry = class _PropertyTransformerRegistry extends import_js_service8.Service {
|
|
2407
2027
|
/**
|
|
2408
2028
|
* Transformers.
|
|
2409
2029
|
*
|
|
@@ -2424,17 +2044,17 @@ var init_property_transformer_registry = __esm({
|
|
|
2424
2044
|
*/
|
|
2425
2045
|
addTransformer(name, transformer) {
|
|
2426
2046
|
if (!name || typeof name !== "string")
|
|
2427
|
-
throw new
|
|
2047
|
+
throw new InvalidArgumentError(
|
|
2428
2048
|
"A name of the property transformer must be a non-empty String, but %v given.",
|
|
2429
2049
|
name
|
|
2430
2050
|
);
|
|
2431
2051
|
if (name in this._transformers)
|
|
2432
|
-
throw new
|
|
2052
|
+
throw new InvalidArgumentError(
|
|
2433
2053
|
"The property transformer %v is already defined.",
|
|
2434
2054
|
name
|
|
2435
2055
|
);
|
|
2436
2056
|
if (typeof transformer !== "function")
|
|
2437
|
-
throw new
|
|
2057
|
+
throw new InvalidArgumentError(
|
|
2438
2058
|
"The property transformer %v must be a Function, but %v given.",
|
|
2439
2059
|
name,
|
|
2440
2060
|
transformer
|
|
@@ -2460,7 +2080,7 @@ var init_property_transformer_registry = __esm({
|
|
|
2460
2080
|
getTransformer(name) {
|
|
2461
2081
|
const transformer = this._transformers[name];
|
|
2462
2082
|
if (!transformer)
|
|
2463
|
-
throw new
|
|
2083
|
+
throw new InvalidArgumentError(
|
|
2464
2084
|
"The property transformer %v is not defined.",
|
|
2465
2085
|
name
|
|
2466
2086
|
);
|
|
@@ -2482,15 +2102,15 @@ var init_property_transformer2 = __esm({
|
|
|
2482
2102
|
});
|
|
2483
2103
|
|
|
2484
2104
|
// src/definition/definition-registry.js
|
|
2485
|
-
var _DefinitionRegistry, DefinitionRegistry;
|
|
2105
|
+
var import_js_service9, _DefinitionRegistry, DefinitionRegistry;
|
|
2486
2106
|
var init_definition_registry = __esm({
|
|
2487
2107
|
"src/definition/definition-registry.js"() {
|
|
2488
2108
|
"use strict";
|
|
2489
|
-
|
|
2490
|
-
|
|
2109
|
+
import_js_service9 = require("@e22m4u/js-service");
|
|
2110
|
+
init_errors();
|
|
2491
2111
|
init_model();
|
|
2492
2112
|
init_definition();
|
|
2493
|
-
_DefinitionRegistry = class _DefinitionRegistry extends Service {
|
|
2113
|
+
_DefinitionRegistry = class _DefinitionRegistry extends import_js_service9.Service {
|
|
2494
2114
|
/**
|
|
2495
2115
|
* Datasources.
|
|
2496
2116
|
*
|
|
@@ -2512,7 +2132,7 @@ var init_definition_registry = __esm({
|
|
|
2512
2132
|
this.getService(DatasourceDefinitionValidator).validate(datasourceDef);
|
|
2513
2133
|
const name = datasourceDef.name;
|
|
2514
2134
|
if (name in this._datasources)
|
|
2515
|
-
throw new
|
|
2135
|
+
throw new InvalidArgumentError(
|
|
2516
2136
|
"The datasource %v is already defined.",
|
|
2517
2137
|
name
|
|
2518
2138
|
);
|
|
@@ -2536,7 +2156,7 @@ var init_definition_registry = __esm({
|
|
|
2536
2156
|
getDatasource(name) {
|
|
2537
2157
|
const datasourceDef = this._datasources[name];
|
|
2538
2158
|
if (!datasourceDef)
|
|
2539
|
-
throw new
|
|
2159
|
+
throw new InvalidArgumentError("The datasource %v is not defined.", name);
|
|
2540
2160
|
return datasourceDef;
|
|
2541
2161
|
}
|
|
2542
2162
|
/**
|
|
@@ -2548,7 +2168,7 @@ var init_definition_registry = __esm({
|
|
|
2548
2168
|
this.getService(ModelDefinitionValidator).validate(modelDef);
|
|
2549
2169
|
const name = modelDef.name;
|
|
2550
2170
|
if (name in this._models)
|
|
2551
|
-
throw new
|
|
2171
|
+
throw new InvalidArgumentError("The model %v is already defined.", name);
|
|
2552
2172
|
this._models[name] = modelDef;
|
|
2553
2173
|
}
|
|
2554
2174
|
/**
|
|
@@ -2569,7 +2189,7 @@ var init_definition_registry = __esm({
|
|
|
2569
2189
|
getModel(name) {
|
|
2570
2190
|
const modelDef = this._models[name];
|
|
2571
2191
|
if (!modelDef)
|
|
2572
|
-
throw new
|
|
2192
|
+
throw new InvalidArgumentError("The model %v is not defined.", name);
|
|
2573
2193
|
return modelDef;
|
|
2574
2194
|
}
|
|
2575
2195
|
};
|
|
@@ -2579,19 +2199,19 @@ var init_definition_registry = __esm({
|
|
|
2579
2199
|
});
|
|
2580
2200
|
|
|
2581
2201
|
// src/definition/model/model-definition-utils.js
|
|
2582
|
-
var DEFAULT_PRIMARY_KEY_PROPERTY_NAME, _ModelDefinitionUtils, ModelDefinitionUtils;
|
|
2202
|
+
var import_js_service10, DEFAULT_PRIMARY_KEY_PROPERTY_NAME, _ModelDefinitionUtils, ModelDefinitionUtils;
|
|
2583
2203
|
var init_model_definition_utils = __esm({
|
|
2584
2204
|
"src/definition/model/model-definition-utils.js"() {
|
|
2585
2205
|
"use strict";
|
|
2586
|
-
|
|
2206
|
+
import_js_service10 = require("@e22m4u/js-service");
|
|
2587
2207
|
init_properties();
|
|
2588
|
-
|
|
2589
|
-
|
|
2208
|
+
init_utils();
|
|
2209
|
+
init_utils();
|
|
2590
2210
|
init_properties();
|
|
2591
|
-
|
|
2211
|
+
init_errors();
|
|
2592
2212
|
init_definition_registry();
|
|
2593
2213
|
DEFAULT_PRIMARY_KEY_PROPERTY_NAME = "id";
|
|
2594
|
-
_ModelDefinitionUtils = class _ModelDefinitionUtils extends Service {
|
|
2214
|
+
_ModelDefinitionUtils = class _ModelDefinitionUtils extends import_js_service10.Service {
|
|
2595
2215
|
/**
|
|
2596
2216
|
* Get primary key as property name.
|
|
2597
2217
|
*
|
|
@@ -2609,7 +2229,7 @@ var init_model_definition_utils = __esm({
|
|
|
2609
2229
|
DEFAULT_PRIMARY_KEY_PROPERTY_NAME
|
|
2610
2230
|
);
|
|
2611
2231
|
if (isDefaultPrimaryKeyAlreadyInUse)
|
|
2612
|
-
throw new
|
|
2232
|
+
throw new InvalidArgumentError(
|
|
2613
2233
|
'The property name %v of the model %v is defined as a regular property. In this case, a primary key should be defined explicitly. Do use the option "primaryKey" to specify the primary key.',
|
|
2614
2234
|
DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
|
|
2615
2235
|
modelName
|
|
@@ -2630,7 +2250,7 @@ var init_model_definition_utils = __esm({
|
|
|
2630
2250
|
try {
|
|
2631
2251
|
pkColName = this.getColumnNameByPropertyName(modelName, pkPropName);
|
|
2632
2252
|
} catch (error) {
|
|
2633
|
-
if (!(error instanceof
|
|
2253
|
+
if (!(error instanceof InvalidArgumentError)) throw error;
|
|
2634
2254
|
}
|
|
2635
2255
|
if (pkColName === void 0) return pkPropName;
|
|
2636
2256
|
return pkColName;
|
|
@@ -2658,7 +2278,7 @@ var init_model_definition_utils = __esm({
|
|
|
2658
2278
|
const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
|
|
2659
2279
|
const propDef = propDefs[propertyName];
|
|
2660
2280
|
if (!propDef)
|
|
2661
|
-
throw new
|
|
2281
|
+
throw new InvalidArgumentError(
|
|
2662
2282
|
"The model %v does not have the property %v.",
|
|
2663
2283
|
modelName,
|
|
2664
2284
|
propertyName
|
|
@@ -2678,7 +2298,7 @@ var init_model_definition_utils = __esm({
|
|
|
2678
2298
|
const propDefs = this.getPropertiesDefinitionInBaseModelHierarchy(modelName);
|
|
2679
2299
|
const propDef = propDefs[propertyName];
|
|
2680
2300
|
if (!propDef)
|
|
2681
|
-
throw new
|
|
2301
|
+
throw new InvalidArgumentError(
|
|
2682
2302
|
"The model %v does not have the property %v.",
|
|
2683
2303
|
modelName,
|
|
2684
2304
|
propertyName
|
|
@@ -2768,7 +2388,7 @@ var init_model_definition_utils = __esm({
|
|
|
2768
2388
|
if (!propDef) {
|
|
2769
2389
|
const pkPropName = this.getPrimaryKeyAsPropertyName(modelName);
|
|
2770
2390
|
if (pkPropName === propertyName) return DataType.ANY;
|
|
2771
|
-
throw new
|
|
2391
|
+
throw new InvalidArgumentError(
|
|
2772
2392
|
"The model %v does not have the property %v.",
|
|
2773
2393
|
modelName,
|
|
2774
2394
|
propertyName
|
|
@@ -2785,7 +2405,7 @@ var init_model_definition_utils = __esm({
|
|
|
2785
2405
|
*/
|
|
2786
2406
|
getDataTypeFromPropertyDefinition(propDef) {
|
|
2787
2407
|
if ((!propDef || typeof propDef !== "object") && !Object.values(DataType).includes(propDef)) {
|
|
2788
|
-
throw new
|
|
2408
|
+
throw new InvalidArgumentError(
|
|
2789
2409
|
'The argument "propDef" of the ModelDefinitionUtils.getDataTypeFromPropertyDefinition should be an Object or the DataType enum, but %v given.',
|
|
2790
2410
|
propDef
|
|
2791
2411
|
);
|
|
@@ -2793,7 +2413,7 @@ var init_model_definition_utils = __esm({
|
|
|
2793
2413
|
if (typeof propDef === "string") return propDef;
|
|
2794
2414
|
const dataType = propDef.type;
|
|
2795
2415
|
if (!Object.values(DataType).includes(dataType))
|
|
2796
|
-
throw new
|
|
2416
|
+
throw new InvalidArgumentError(
|
|
2797
2417
|
'The given Object to the ModelDefinitionUtils.getDataTypeFromPropertyDefinition should have the "type" property with one of values: %l, but %v given.',
|
|
2798
2418
|
Object.values(DataType),
|
|
2799
2419
|
propDef.type
|
|
@@ -2843,7 +2463,7 @@ var init_model_definition_utils = __esm({
|
|
|
2843
2463
|
let pkPropDefs = {};
|
|
2844
2464
|
const recursion = /* @__PURE__ */ __name((currModelName, prevModelName = void 0) => {
|
|
2845
2465
|
if (currModelName === prevModelName)
|
|
2846
|
-
throw new
|
|
2466
|
+
throw new InvalidArgumentError(
|
|
2847
2467
|
"The model %v has a circular inheritance.",
|
|
2848
2468
|
currModelName
|
|
2849
2469
|
);
|
|
@@ -2881,7 +2501,7 @@ var init_model_definition_utils = __esm({
|
|
|
2881
2501
|
const recursion = /* @__PURE__ */ __name((currModelName, prevModelName = void 0) => {
|
|
2882
2502
|
var _a;
|
|
2883
2503
|
if (currModelName === prevModelName)
|
|
2884
|
-
throw new
|
|
2504
|
+
throw new InvalidArgumentError(
|
|
2885
2505
|
"The model %v has a circular inheritance.",
|
|
2886
2506
|
currModelName
|
|
2887
2507
|
);
|
|
@@ -2911,7 +2531,7 @@ var init_model_definition_utils = __esm({
|
|
|
2911
2531
|
}
|
|
2912
2532
|
}
|
|
2913
2533
|
if (!foundDef)
|
|
2914
|
-
throw new
|
|
2534
|
+
throw new InvalidArgumentError(
|
|
2915
2535
|
"The model %v does not have relation name %v.",
|
|
2916
2536
|
modelName,
|
|
2917
2537
|
relationName
|
|
@@ -2927,7 +2547,7 @@ var init_model_definition_utils = __esm({
|
|
|
2927
2547
|
*/
|
|
2928
2548
|
excludeObjectKeysByRelationNames(modelName, modelData) {
|
|
2929
2549
|
if (!modelData || typeof modelData !== "object" || Array.isArray(modelData))
|
|
2930
|
-
throw new
|
|
2550
|
+
throw new InvalidArgumentError(
|
|
2931
2551
|
"The second argument of ModelDefinitionUtils.excludeObjectKeysByRelationNames should be an Object, but %v given.",
|
|
2932
2552
|
modelData
|
|
2933
2553
|
);
|
|
@@ -2942,18 +2562,18 @@ var init_model_definition_utils = __esm({
|
|
|
2942
2562
|
});
|
|
2943
2563
|
|
|
2944
2564
|
// src/definition/model/properties/property-uniqueness-validator.js
|
|
2945
|
-
var _PropertyUniquenessValidator, PropertyUniquenessValidator;
|
|
2565
|
+
var import_js_service11, _PropertyUniquenessValidator, PropertyUniquenessValidator;
|
|
2946
2566
|
var init_property_uniqueness_validator = __esm({
|
|
2947
2567
|
"src/definition/model/properties/property-uniqueness-validator.js"() {
|
|
2948
2568
|
"use strict";
|
|
2949
2569
|
init_data_type();
|
|
2950
|
-
|
|
2951
|
-
|
|
2570
|
+
import_js_service11 = require("@e22m4u/js-service");
|
|
2571
|
+
init_utils();
|
|
2952
2572
|
init_property_uniqueness();
|
|
2953
2573
|
init_empty_values_definer();
|
|
2954
|
-
|
|
2574
|
+
init_errors();
|
|
2955
2575
|
init_model_definition_utils();
|
|
2956
|
-
_PropertyUniquenessValidator = class _PropertyUniquenessValidator extends Service {
|
|
2576
|
+
_PropertyUniquenessValidator = class _PropertyUniquenessValidator extends import_js_service11.Service {
|
|
2957
2577
|
/**
|
|
2958
2578
|
* Validate.
|
|
2959
2579
|
*
|
|
@@ -2966,22 +2586,22 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2966
2586
|
*/
|
|
2967
2587
|
async validate(countMethod, methodName, modelName, modelData, modelId = void 0) {
|
|
2968
2588
|
if (typeof countMethod !== "function")
|
|
2969
|
-
throw new
|
|
2589
|
+
throw new InvalidArgumentError(
|
|
2970
2590
|
'The parameter "countMethod" of the PropertyUniquenessValidator must be a Function, but %v given.',
|
|
2971
2591
|
countMethod
|
|
2972
2592
|
);
|
|
2973
2593
|
if (!methodName || typeof methodName !== "string")
|
|
2974
|
-
throw new
|
|
2594
|
+
throw new InvalidArgumentError(
|
|
2975
2595
|
'The parameter "methodName" of the PropertyUniquenessValidator must be a non-empty String, but %v given.',
|
|
2976
2596
|
methodName
|
|
2977
2597
|
);
|
|
2978
2598
|
if (!modelName || typeof modelName !== "string")
|
|
2979
|
-
throw new
|
|
2599
|
+
throw new InvalidArgumentError(
|
|
2980
2600
|
'The parameter "modelName" of the PropertyUniquenessValidator must be a non-empty String, but %v given.',
|
|
2981
2601
|
modelName
|
|
2982
2602
|
);
|
|
2983
2603
|
if (!isPureObject(modelData))
|
|
2984
|
-
throw new
|
|
2604
|
+
throw new InvalidArgumentError(
|
|
2985
2605
|
"The data of the model %v should be an Object, but %v given.",
|
|
2986
2606
|
modelName,
|
|
2987
2607
|
modelData
|
|
@@ -2994,7 +2614,7 @@ var init_property_uniqueness_validator = __esm({
|
|
|
2994
2614
|
const idProp = this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
|
|
2995
2615
|
modelName
|
|
2996
2616
|
);
|
|
2997
|
-
const createError = /* @__PURE__ */ __name((propName, propValue) => new
|
|
2617
|
+
const createError = /* @__PURE__ */ __name((propName, propValue) => new InvalidArgumentError(
|
|
2998
2618
|
"An existing document of the model %v already has the property %v with the value %v and should be unique.",
|
|
2999
2619
|
modelName,
|
|
3000
2620
|
propName,
|
|
@@ -3048,7 +2668,7 @@ var init_property_uniqueness_validator = __esm({
|
|
|
3048
2668
|
});
|
|
3049
2669
|
if (count > 0) throw createError(propName, propValue);
|
|
3050
2670
|
} else {
|
|
3051
|
-
throw new
|
|
2671
|
+
throw new InvalidArgumentError(
|
|
3052
2672
|
"The PropertyUniquenessValidator does not support the adapter method %v.",
|
|
3053
2673
|
methodName
|
|
3054
2674
|
);
|
|
@@ -3062,14 +2682,14 @@ var init_property_uniqueness_validator = __esm({
|
|
|
3062
2682
|
});
|
|
3063
2683
|
|
|
3064
2684
|
// src/definition/model/properties/primary-keys-definition-validator.js
|
|
3065
|
-
var _PrimaryKeysDefinitionValidator, PrimaryKeysDefinitionValidator;
|
|
2685
|
+
var import_js_service12, _PrimaryKeysDefinitionValidator, PrimaryKeysDefinitionValidator;
|
|
3066
2686
|
var init_primary_keys_definition_validator = __esm({
|
|
3067
2687
|
"src/definition/model/properties/primary-keys-definition-validator.js"() {
|
|
3068
2688
|
"use strict";
|
|
3069
|
-
|
|
3070
|
-
|
|
2689
|
+
import_js_service12 = require("@e22m4u/js-service");
|
|
2690
|
+
init_errors();
|
|
3071
2691
|
init_model_definition_utils();
|
|
3072
|
-
_PrimaryKeysDefinitionValidator = class _PrimaryKeysDefinitionValidator extends Service {
|
|
2692
|
+
_PrimaryKeysDefinitionValidator = class _PrimaryKeysDefinitionValidator extends import_js_service12.Service {
|
|
3073
2693
|
/**
|
|
3074
2694
|
* Validate.
|
|
3075
2695
|
*
|
|
@@ -3084,7 +2704,7 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
3084
2704
|
if (propNames.length < 1) {
|
|
3085
2705
|
const isDefaultPrimaryKeyAlreadyInUse = Object.keys(propDefs).includes(DEFAULT_PRIMARY_KEY_PROPERTY_NAME);
|
|
3086
2706
|
if (isDefaultPrimaryKeyAlreadyInUse)
|
|
3087
|
-
throw new
|
|
2707
|
+
throw new InvalidArgumentError(
|
|
3088
2708
|
'The property name %v of the model %v is defined as a regular property. In this case, a primary key should be defined explicitly. Do use the option "primaryKey" to specify the primary key.',
|
|
3089
2709
|
DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
|
|
3090
2710
|
modelName
|
|
@@ -3092,7 +2712,7 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
3092
2712
|
return;
|
|
3093
2713
|
}
|
|
3094
2714
|
if (propNames.length > 1)
|
|
3095
|
-
throw new
|
|
2715
|
+
throw new InvalidArgumentError(
|
|
3096
2716
|
"The model definition %v should not have multiple primary keys, but %v keys given.",
|
|
3097
2717
|
modelName,
|
|
3098
2718
|
propNames.length
|
|
@@ -3100,7 +2720,7 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
3100
2720
|
const pkPropName = propNames[0];
|
|
3101
2721
|
const pkPropDef = propDefs[pkPropName];
|
|
3102
2722
|
if (pkPropDef && typeof pkPropDef === "object" && pkPropDef.default !== void 0) {
|
|
3103
|
-
throw new
|
|
2723
|
+
throw new InvalidArgumentError(
|
|
3104
2724
|
"Do not specify a default value for the primary key %v of the model %v.",
|
|
3105
2725
|
pkPropName,
|
|
3106
2726
|
modelName
|
|
@@ -3114,19 +2734,19 @@ var init_primary_keys_definition_validator = __esm({
|
|
|
3114
2734
|
});
|
|
3115
2735
|
|
|
3116
2736
|
// src/definition/model/properties/properties-definition-validator.js
|
|
3117
|
-
var _PropertiesDefinitionValidator, PropertiesDefinitionValidator;
|
|
2737
|
+
var import_js_service13, _PropertiesDefinitionValidator, PropertiesDefinitionValidator;
|
|
3118
2738
|
var init_properties_definition_validator = __esm({
|
|
3119
2739
|
"src/definition/model/properties/properties-definition-validator.js"() {
|
|
3120
2740
|
"use strict";
|
|
3121
|
-
|
|
2741
|
+
import_js_service13 = require("@e22m4u/js-service");
|
|
3122
2742
|
init_data_type();
|
|
3123
|
-
|
|
2743
|
+
init_utils();
|
|
3124
2744
|
init_property_uniqueness();
|
|
3125
|
-
|
|
2745
|
+
init_errors();
|
|
3126
2746
|
init_property_validator2();
|
|
3127
2747
|
init_property_transformer2();
|
|
3128
2748
|
init_primary_keys_definition_validator();
|
|
3129
|
-
_PropertiesDefinitionValidator = class _PropertiesDefinitionValidator extends Service {
|
|
2749
|
+
_PropertiesDefinitionValidator = class _PropertiesDefinitionValidator extends import_js_service13.Service {
|
|
3130
2750
|
/**
|
|
3131
2751
|
* Validate.
|
|
3132
2752
|
*
|
|
@@ -3135,12 +2755,12 @@ var init_properties_definition_validator = __esm({
|
|
|
3135
2755
|
*/
|
|
3136
2756
|
validate(modelName, propDefs) {
|
|
3137
2757
|
if (!modelName || typeof modelName !== "string")
|
|
3138
|
-
throw new
|
|
2758
|
+
throw new InvalidArgumentError(
|
|
3139
2759
|
"The first argument of PropertiesDefinitionValidator.validate should be a non-empty String, but %v given.",
|
|
3140
2760
|
modelName
|
|
3141
2761
|
);
|
|
3142
2762
|
if (!propDefs || typeof propDefs !== "object" || Array.isArray(propDefs)) {
|
|
3143
|
-
throw new
|
|
2763
|
+
throw new InvalidArgumentError(
|
|
3144
2764
|
'The provided option "properties" of the model %v should be an Object, but %v given.',
|
|
3145
2765
|
modelName,
|
|
3146
2766
|
propDefs
|
|
@@ -3165,18 +2785,18 @@ var init_properties_definition_validator = __esm({
|
|
|
3165
2785
|
*/
|
|
3166
2786
|
_validateProperty(modelName, propName, propDef) {
|
|
3167
2787
|
if (!modelName || typeof modelName !== "string")
|
|
3168
|
-
throw new
|
|
2788
|
+
throw new InvalidArgumentError(
|
|
3169
2789
|
"The first argument of PropertiesDefinitionValidator._validateProperty should be a non-empty String, but %v given.",
|
|
3170
2790
|
modelName
|
|
3171
2791
|
);
|
|
3172
2792
|
if (!propName || typeof propName !== "string")
|
|
3173
|
-
throw new
|
|
2793
|
+
throw new InvalidArgumentError(
|
|
3174
2794
|
"The property name of the model %v should be a non-empty String, but %v given.",
|
|
3175
2795
|
modelName,
|
|
3176
2796
|
propName
|
|
3177
2797
|
);
|
|
3178
2798
|
if (!propDef)
|
|
3179
|
-
throw new
|
|
2799
|
+
throw new InvalidArgumentError(
|
|
3180
2800
|
"The property %v of the model %v should have a property definition, but %v given.",
|
|
3181
2801
|
propName,
|
|
3182
2802
|
modelName,
|
|
@@ -3184,7 +2804,7 @@ var init_properties_definition_validator = __esm({
|
|
|
3184
2804
|
);
|
|
3185
2805
|
if (typeof propDef === "string") {
|
|
3186
2806
|
if (!Object.values(DataType).includes(propDef))
|
|
3187
|
-
throw new
|
|
2807
|
+
throw new InvalidArgumentError(
|
|
3188
2808
|
"In case of a short property definition, the property %v of the model %v should have one of data types: %l, but %v given.",
|
|
3189
2809
|
propName,
|
|
3190
2810
|
modelName,
|
|
@@ -3194,7 +2814,7 @@ var init_properties_definition_validator = __esm({
|
|
|
3194
2814
|
return;
|
|
3195
2815
|
}
|
|
3196
2816
|
if (!propDef || typeof propDef !== "object" || Array.isArray(propDef)) {
|
|
3197
|
-
throw new
|
|
2817
|
+
throw new InvalidArgumentError(
|
|
3198
2818
|
"In case of a full property definition, the property %v of the model %v should be an Object, but %v given.",
|
|
3199
2819
|
propName,
|
|
3200
2820
|
modelName,
|
|
@@ -3202,7 +2822,7 @@ var init_properties_definition_validator = __esm({
|
|
|
3202
2822
|
);
|
|
3203
2823
|
}
|
|
3204
2824
|
if (!propDef.type || !Object.values(DataType).includes(propDef.type))
|
|
3205
|
-
throw new
|
|
2825
|
+
throw new InvalidArgumentError(
|
|
3206
2826
|
'The property %v of the model %v requires the option "type" to have one of data types: %l, but %v given.',
|
|
3207
2827
|
propName,
|
|
3208
2828
|
modelName,
|
|
@@ -3210,7 +2830,7 @@ var init_properties_definition_validator = __esm({
|
|
|
3210
2830
|
propDef.type
|
|
3211
2831
|
);
|
|
3212
2832
|
if (propDef.itemType && !Object.values(DataType).includes(propDef.itemType)) {
|
|
3213
|
-
throw new
|
|
2833
|
+
throw new InvalidArgumentError(
|
|
3214
2834
|
'The provided option "itemType" of the property %v in the model %v should have one of data types: %l, but %v given.',
|
|
3215
2835
|
propName,
|
|
3216
2836
|
modelName,
|
|
@@ -3218,104 +2838,125 @@ var init_properties_definition_validator = __esm({
|
|
|
3218
2838
|
propDef.itemType
|
|
3219
2839
|
);
|
|
3220
2840
|
}
|
|
2841
|
+
if (propDef.itemModel && typeof propDef.itemModel !== "string") {
|
|
2842
|
+
throw new InvalidArgumentError(
|
|
2843
|
+
'The provided option "itemModel" of the property %v in the model %v should be a String, but %v given.',
|
|
2844
|
+
propName,
|
|
2845
|
+
modelName,
|
|
2846
|
+
propDef.itemModel
|
|
2847
|
+
);
|
|
2848
|
+
}
|
|
3221
2849
|
if (propDef.model && typeof propDef.model !== "string")
|
|
3222
|
-
throw new
|
|
2850
|
+
throw new InvalidArgumentError(
|
|
3223
2851
|
'The provided option "model" of the property %v in the model %v should be a String, but %v given.',
|
|
3224
2852
|
propName,
|
|
3225
2853
|
modelName,
|
|
3226
2854
|
propDef.model
|
|
3227
2855
|
);
|
|
3228
2856
|
if (propDef.primaryKey && typeof propDef.primaryKey !== "boolean")
|
|
3229
|
-
throw new
|
|
2857
|
+
throw new InvalidArgumentError(
|
|
3230
2858
|
'The provided option "primaryKey" of the property %v in the model %v should be a Boolean, but %v given.',
|
|
3231
2859
|
propName,
|
|
3232
2860
|
modelName,
|
|
3233
2861
|
propDef.primaryKey
|
|
3234
2862
|
);
|
|
3235
2863
|
if (propDef.columnName && typeof propDef.columnName !== "string")
|
|
3236
|
-
throw new
|
|
2864
|
+
throw new InvalidArgumentError(
|
|
3237
2865
|
'The provided option "columnName" of the property %v in the model %v should be a String, but %v given.',
|
|
3238
2866
|
propName,
|
|
3239
2867
|
modelName,
|
|
3240
2868
|
propDef.columnName
|
|
3241
2869
|
);
|
|
3242
2870
|
if (propDef.columnType && typeof propDef.columnType !== "string")
|
|
3243
|
-
throw new
|
|
2871
|
+
throw new InvalidArgumentError(
|
|
3244
2872
|
'The provided option "columnType" of the property %v in the model %v should be a String, but %v given.',
|
|
3245
2873
|
propName,
|
|
3246
2874
|
modelName,
|
|
3247
2875
|
propDef.columnType
|
|
3248
2876
|
);
|
|
3249
2877
|
if (propDef.required && typeof propDef.required !== "boolean")
|
|
3250
|
-
throw new
|
|
2878
|
+
throw new InvalidArgumentError(
|
|
3251
2879
|
'The provided option "required" of the property %v in the model %v should be a Boolean, but %v given.',
|
|
3252
2880
|
propName,
|
|
3253
2881
|
modelName,
|
|
3254
2882
|
propDef.required
|
|
3255
2883
|
);
|
|
3256
2884
|
if (propDef.required && propDef.default !== void 0)
|
|
3257
|
-
throw new
|
|
2885
|
+
throw new InvalidArgumentError(
|
|
3258
2886
|
'The property %v of the model %v is a required property, so it should not have the option "default" to be provided.',
|
|
3259
2887
|
propName,
|
|
3260
2888
|
modelName
|
|
3261
2889
|
);
|
|
3262
2890
|
if (propDef.primaryKey && propDef.required)
|
|
3263
|
-
throw new
|
|
2891
|
+
throw new InvalidArgumentError(
|
|
3264
2892
|
'The property %v of the model %v is a primary key, so it should not have the option "required" to be provided.',
|
|
3265
2893
|
propName,
|
|
3266
2894
|
modelName
|
|
3267
2895
|
);
|
|
3268
2896
|
if (propDef.primaryKey && propDef.default !== void 0)
|
|
3269
|
-
throw new
|
|
2897
|
+
throw new InvalidArgumentError(
|
|
3270
2898
|
'The property %v of the model %v is a primary key, so it should not have the option "default" to be provided.',
|
|
3271
2899
|
propName,
|
|
3272
2900
|
modelName
|
|
3273
2901
|
);
|
|
3274
2902
|
if (propDef.itemType && propDef.type !== DataType.ARRAY)
|
|
3275
|
-
throw new
|
|
3276
|
-
'The property %v of the model %v has
|
|
2903
|
+
throw new InvalidArgumentError(
|
|
2904
|
+
'The property %v of the model %v has a non-array type, so it should not have the option "itemType" to be provided.',
|
|
3277
2905
|
propName,
|
|
3278
2906
|
modelName,
|
|
3279
2907
|
propDef.type
|
|
3280
2908
|
);
|
|
3281
|
-
if (propDef.
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
2909
|
+
if (propDef.itemModel && propDef.type !== DataType.ARRAY)
|
|
2910
|
+
throw new InvalidArgumentError(
|
|
2911
|
+
'The option "itemModel" is not supported for %s property type, so the property %v of the model %v should not have the option "itemModel" to be provided.',
|
|
2912
|
+
capitalize(propDef.type),
|
|
2913
|
+
propName,
|
|
2914
|
+
modelName
|
|
2915
|
+
);
|
|
2916
|
+
if (propDef.itemModel && propDef.itemType !== DataType.OBJECT) {
|
|
2917
|
+
if (propDef.itemType) {
|
|
2918
|
+
throw new InvalidArgumentError(
|
|
2919
|
+
'The provided option "itemModel" requires the option "itemType" to be explicitly set to Object, but the property %v of the model %v has specified item type as %s.',
|
|
3286
2920
|
propName,
|
|
3287
|
-
modelName
|
|
2921
|
+
modelName,
|
|
2922
|
+
capitalize(propDef.itemType)
|
|
3288
2923
|
);
|
|
3289
2924
|
} else {
|
|
3290
|
-
throw new
|
|
3291
|
-
'The option "
|
|
3292
|
-
capitalize(propDef.itemType),
|
|
2925
|
+
throw new InvalidArgumentError(
|
|
2926
|
+
'The provided option "itemModel" requires the option "itemType" to be explicitly set to Object, but the property %v of the model %v does not have specified item type.',
|
|
3293
2927
|
propName,
|
|
3294
2928
|
modelName
|
|
3295
2929
|
);
|
|
3296
2930
|
}
|
|
3297
2931
|
}
|
|
2932
|
+
if (propDef.model && propDef.type !== DataType.OBJECT)
|
|
2933
|
+
throw new InvalidArgumentError(
|
|
2934
|
+
'The option "model" is not supported for %s property type, so the property %v of the model %v should not have the option "model" to be provided.',
|
|
2935
|
+
capitalize(propDef.type),
|
|
2936
|
+
propName,
|
|
2937
|
+
modelName
|
|
2938
|
+
);
|
|
3298
2939
|
if (propDef.validate != null) {
|
|
3299
2940
|
const propertyValidatorRegistry = this.getService(
|
|
3300
2941
|
PropertyValidatorRegistry
|
|
3301
2942
|
);
|
|
3302
2943
|
if (propDef.validate && typeof propDef.validate === "string") {
|
|
3303
2944
|
if (!propertyValidatorRegistry.hasValidator(propDef.validate))
|
|
3304
|
-
throw new
|
|
2945
|
+
throw new InvalidArgumentError(
|
|
3305
2946
|
"The property validator %v is not found.",
|
|
3306
2947
|
propDef.validate
|
|
3307
2948
|
);
|
|
3308
2949
|
} else if (Array.isArray(propDef.validate)) {
|
|
3309
2950
|
for (const validatorName of propDef.validate) {
|
|
3310
2951
|
if (typeof validatorName !== "string")
|
|
3311
|
-
throw new
|
|
2952
|
+
throw new InvalidArgumentError(
|
|
3312
2953
|
'The provided option "validate" of the property %v in the model %v has an Array value that should have a non-empty String, but %v given.',
|
|
3313
2954
|
propName,
|
|
3314
2955
|
modelName,
|
|
3315
2956
|
validatorName
|
|
3316
2957
|
);
|
|
3317
2958
|
if (!propertyValidatorRegistry.hasValidator(validatorName))
|
|
3318
|
-
throw new
|
|
2959
|
+
throw new InvalidArgumentError(
|
|
3319
2960
|
"The property validator %v is not found.",
|
|
3320
2961
|
validatorName
|
|
3321
2962
|
);
|
|
@@ -3323,13 +2964,13 @@ var init_properties_definition_validator = __esm({
|
|
|
3323
2964
|
} else if (typeof propDef.validate === "object") {
|
|
3324
2965
|
for (const validatorName in propDef.validate) {
|
|
3325
2966
|
if (!propertyValidatorRegistry.hasValidator(validatorName))
|
|
3326
|
-
throw new
|
|
2967
|
+
throw new InvalidArgumentError(
|
|
3327
2968
|
"The property validator %v is not found.",
|
|
3328
2969
|
validatorName
|
|
3329
2970
|
);
|
|
3330
2971
|
}
|
|
3331
2972
|
} else {
|
|
3332
|
-
throw new
|
|
2973
|
+
throw new InvalidArgumentError(
|
|
3333
2974
|
'The provided option "validate" of the property %v in the model %v should be a non-empty String, an Array of String or an Object, but %v given.',
|
|
3334
2975
|
propName,
|
|
3335
2976
|
modelName,
|
|
@@ -3343,21 +2984,21 @@ var init_properties_definition_validator = __esm({
|
|
|
3343
2984
|
);
|
|
3344
2985
|
if (propDef.transform && typeof propDef.transform === "string") {
|
|
3345
2986
|
if (!propertyTransformerRegistry.hasTransformer(propDef.transform))
|
|
3346
|
-
throw new
|
|
2987
|
+
throw new InvalidArgumentError(
|
|
3347
2988
|
"The property transformer %v is not found.",
|
|
3348
2989
|
propDef.transform
|
|
3349
2990
|
);
|
|
3350
2991
|
} else if (Array.isArray(propDef.transform)) {
|
|
3351
2992
|
for (const transformerName of propDef.transform) {
|
|
3352
2993
|
if (typeof transformerName !== "string")
|
|
3353
|
-
throw new
|
|
2994
|
+
throw new InvalidArgumentError(
|
|
3354
2995
|
'The provided option "transform" of the property %v in the model %v has an Array value that should have a non-empty String, but %v given.',
|
|
3355
2996
|
propName,
|
|
3356
2997
|
modelName,
|
|
3357
2998
|
transformerName
|
|
3358
2999
|
);
|
|
3359
3000
|
if (!propertyTransformerRegistry.hasTransformer(transformerName))
|
|
3360
|
-
throw new
|
|
3001
|
+
throw new InvalidArgumentError(
|
|
3361
3002
|
"The property transformer %v is not found.",
|
|
3362
3003
|
transformerName
|
|
3363
3004
|
);
|
|
@@ -3365,13 +3006,13 @@ var init_properties_definition_validator = __esm({
|
|
|
3365
3006
|
} else if (typeof propDef.transform === "object") {
|
|
3366
3007
|
for (const transformerName in propDef.transform) {
|
|
3367
3008
|
if (!propertyTransformerRegistry.hasTransformer(transformerName))
|
|
3368
|
-
throw new
|
|
3009
|
+
throw new InvalidArgumentError(
|
|
3369
3010
|
"The property transformer %v is not found.",
|
|
3370
3011
|
transformerName
|
|
3371
3012
|
);
|
|
3372
3013
|
}
|
|
3373
3014
|
} else {
|
|
3374
|
-
throw new
|
|
3015
|
+
throw new InvalidArgumentError(
|
|
3375
3016
|
'The provided option "transform" of the property %v in the model %v should be a non-empty String, an Array of String or an Object, but %v given.',
|
|
3376
3017
|
propName,
|
|
3377
3018
|
modelName,
|
|
@@ -3381,7 +3022,7 @@ var init_properties_definition_validator = __esm({
|
|
|
3381
3022
|
}
|
|
3382
3023
|
if (propDef.unique) {
|
|
3383
3024
|
if (typeof propDef.unique !== "boolean" && !Object.values(PropertyUniqueness).includes(propDef.unique)) {
|
|
3384
|
-
throw new
|
|
3025
|
+
throw new InvalidArgumentError(
|
|
3385
3026
|
'The provided option "unique" of the property %v in the model %v should be a Boolean or one of values: %l, but %v given.',
|
|
3386
3027
|
propName,
|
|
3387
3028
|
modelName,
|
|
@@ -3391,7 +3032,7 @@ var init_properties_definition_validator = __esm({
|
|
|
3391
3032
|
}
|
|
3392
3033
|
}
|
|
3393
3034
|
if (propDef.unique && propDef.primaryKey)
|
|
3394
|
-
throw new
|
|
3035
|
+
throw new InvalidArgumentError(
|
|
3395
3036
|
'The property %v of the model %v is a primary key, so it should not have the option "unique" to be provided.',
|
|
3396
3037
|
propName,
|
|
3397
3038
|
modelName
|
|
@@ -3427,19 +3068,19 @@ var init_model_definition = __esm({
|
|
|
3427
3068
|
});
|
|
3428
3069
|
|
|
3429
3070
|
// src/definition/model/model-data-validator.js
|
|
3430
|
-
var _ModelDataValidator, ModelDataValidator;
|
|
3071
|
+
var import_js_service14, _ModelDataValidator, ModelDataValidator;
|
|
3431
3072
|
var init_model_data_validator = __esm({
|
|
3432
3073
|
"src/definition/model/model-data-validator.js"() {
|
|
3433
3074
|
"use strict";
|
|
3434
|
-
|
|
3075
|
+
import_js_service14 = require("@e22m4u/js-service");
|
|
3435
3076
|
init_properties();
|
|
3436
|
-
|
|
3437
|
-
|
|
3077
|
+
init_utils();
|
|
3078
|
+
init_utils();
|
|
3438
3079
|
init_properties();
|
|
3439
|
-
|
|
3080
|
+
init_errors();
|
|
3440
3081
|
init_properties();
|
|
3441
3082
|
init_model_definition_utils();
|
|
3442
|
-
_ModelDataValidator = class _ModelDataValidator extends Service {
|
|
3083
|
+
_ModelDataValidator = class _ModelDataValidator extends import_js_service14.Service {
|
|
3443
3084
|
/**
|
|
3444
3085
|
* Validate.
|
|
3445
3086
|
*
|
|
@@ -3450,7 +3091,7 @@ var init_model_data_validator = __esm({
|
|
|
3450
3091
|
*/
|
|
3451
3092
|
validate(modelName, modelData, isPartial = false) {
|
|
3452
3093
|
if (!isPureObject(modelData))
|
|
3453
|
-
throw new
|
|
3094
|
+
throw new InvalidArgumentError(
|
|
3454
3095
|
"The data of the model %v should be an Object, but %v given.",
|
|
3455
3096
|
modelName,
|
|
3456
3097
|
modelData
|
|
@@ -3490,7 +3131,7 @@ var init_model_data_validator = __esm({
|
|
|
3490
3131
|
if (isEmpty) {
|
|
3491
3132
|
const isRequired = typeof propDef === "string" ? false : Boolean(propDef.required);
|
|
3492
3133
|
if (!isRequired) return;
|
|
3493
|
-
throw new
|
|
3134
|
+
throw new InvalidArgumentError(
|
|
3494
3135
|
"The property %v of the model %v is required, but %v given.",
|
|
3495
3136
|
propName,
|
|
3496
3137
|
modelName,
|
|
@@ -3531,7 +3172,7 @@ var init_model_data_validator = __esm({
|
|
|
3531
3172
|
const pattern = isArrayValue ? "The array property %v of the model %v must have %s element, but %s given." : "The property %v of the model %v must have %s, but %s given.";
|
|
3532
3173
|
const ctorName = getCtorName(propValue);
|
|
3533
3174
|
const givenStr = ctorName != null ? ctorName : typeof propValue;
|
|
3534
|
-
return new
|
|
3175
|
+
return new InvalidArgumentError(
|
|
3535
3176
|
pattern,
|
|
3536
3177
|
propName,
|
|
3537
3178
|
modelName,
|
|
@@ -3566,11 +3207,15 @@ var init_model_data_validator = __esm({
|
|
|
3566
3207
|
);
|
|
3567
3208
|
break;
|
|
3568
3209
|
// OBJECT
|
|
3569
|
-
case DataType.OBJECT:
|
|
3210
|
+
case DataType.OBJECT: {
|
|
3570
3211
|
if (!isPureObject(propValue)) throw createError("an Object");
|
|
3571
|
-
if (typeof propDef === "object"
|
|
3572
|
-
|
|
3212
|
+
if (typeof propDef === "object") {
|
|
3213
|
+
const modelOptionField = isArrayValue ? "itemModel" : "model";
|
|
3214
|
+
const modelOptionValue = propDef[modelOptionField];
|
|
3215
|
+
if (modelOptionValue) this.validate(modelOptionValue, propValue);
|
|
3216
|
+
}
|
|
3573
3217
|
break;
|
|
3218
|
+
}
|
|
3574
3219
|
}
|
|
3575
3220
|
}
|
|
3576
3221
|
/**
|
|
@@ -3586,7 +3231,7 @@ var init_model_data_validator = __esm({
|
|
|
3586
3231
|
if (typeof propDef === "string" || propDef.validate == null) return;
|
|
3587
3232
|
const validateDef = propDef.validate;
|
|
3588
3233
|
const validatorRegistry = this.getService(PropertyValidatorRegistry);
|
|
3589
|
-
const createError = /* @__PURE__ */ __name((validatorName) => new
|
|
3234
|
+
const createError = /* @__PURE__ */ __name((validatorName) => new InvalidArgumentError(
|
|
3590
3235
|
"The property %v of the model %v has an invalid value %v that caught by the validator %v.",
|
|
3591
3236
|
propName,
|
|
3592
3237
|
modelName,
|
|
@@ -3598,7 +3243,7 @@ var init_model_data_validator = __esm({
|
|
|
3598
3243
|
const context = { validatorName, modelName, propName };
|
|
3599
3244
|
const valid = validator(propValue, validatorOptions, context);
|
|
3600
3245
|
if (valid instanceof Promise) {
|
|
3601
|
-
throw new
|
|
3246
|
+
throw new InvalidArgumentError(
|
|
3602
3247
|
"Asynchronous property validators are not supported, but the property validator %v returns a Promise.",
|
|
3603
3248
|
validatorName
|
|
3604
3249
|
);
|
|
@@ -3618,7 +3263,7 @@ var init_model_data_validator = __esm({
|
|
|
3618
3263
|
}
|
|
3619
3264
|
});
|
|
3620
3265
|
} else {
|
|
3621
|
-
throw new
|
|
3266
|
+
throw new InvalidArgumentError(
|
|
3622
3267
|
'The provided option "validate" of the property %v in the model %v should be a non-empty String, an Array of String or an Object, but %v given.',
|
|
3623
3268
|
propName,
|
|
3624
3269
|
modelName,
|
|
@@ -3633,14 +3278,14 @@ var init_model_data_validator = __esm({
|
|
|
3633
3278
|
});
|
|
3634
3279
|
|
|
3635
3280
|
// src/definition/model/model-data-sanitizer.js
|
|
3636
|
-
var _ModelDataSanitizer, ModelDataSanitizer;
|
|
3281
|
+
var import_js_service15, _ModelDataSanitizer, ModelDataSanitizer;
|
|
3637
3282
|
var init_model_data_sanitizer = __esm({
|
|
3638
3283
|
"src/definition/model/model-data-sanitizer.js"() {
|
|
3639
3284
|
"use strict";
|
|
3640
|
-
|
|
3641
|
-
|
|
3285
|
+
import_js_service15 = require("@e22m4u/js-service");
|
|
3286
|
+
init_errors();
|
|
3642
3287
|
init_model_definition_utils();
|
|
3643
|
-
_ModelDataSanitizer = class _ModelDataSanitizer extends Service {
|
|
3288
|
+
_ModelDataSanitizer = class _ModelDataSanitizer extends import_js_service15.Service {
|
|
3644
3289
|
/**
|
|
3645
3290
|
* Validate.
|
|
3646
3291
|
*
|
|
@@ -3650,12 +3295,12 @@ var init_model_data_sanitizer = __esm({
|
|
|
3650
3295
|
*/
|
|
3651
3296
|
sanitize(modelName, modelData) {
|
|
3652
3297
|
if (!modelName || typeof modelName !== "string")
|
|
3653
|
-
throw new
|
|
3298
|
+
throw new InvalidArgumentError(
|
|
3654
3299
|
"The first argument of ModelDataSanitizer.sanitize should be a string, but %v given.",
|
|
3655
3300
|
modelName
|
|
3656
3301
|
);
|
|
3657
3302
|
if (!modelData || typeof modelData !== "object")
|
|
3658
|
-
throw new
|
|
3303
|
+
throw new InvalidArgumentError(
|
|
3659
3304
|
"The second argument of ModelDataSanitizer.sanitize should be an Object, but %v given.",
|
|
3660
3305
|
modelData
|
|
3661
3306
|
);
|
|
@@ -3670,19 +3315,19 @@ var init_model_data_sanitizer = __esm({
|
|
|
3670
3315
|
});
|
|
3671
3316
|
|
|
3672
3317
|
// src/definition/model/model-data-transformer.js
|
|
3673
|
-
var _ModelDataTransformer, ModelDataTransformer;
|
|
3318
|
+
var import_js_service16, _ModelDataTransformer, ModelDataTransformer;
|
|
3674
3319
|
var init_model_data_transformer = __esm({
|
|
3675
3320
|
"src/definition/model/model-data-transformer.js"() {
|
|
3676
3321
|
"use strict";
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3322
|
+
import_js_service16 = require("@e22m4u/js-service");
|
|
3323
|
+
init_utils();
|
|
3324
|
+
init_utils();
|
|
3325
|
+
init_utils();
|
|
3681
3326
|
init_properties();
|
|
3682
|
-
|
|
3327
|
+
init_errors();
|
|
3683
3328
|
init_model_definition_utils();
|
|
3684
3329
|
init_properties();
|
|
3685
|
-
_ModelDataTransformer = class _ModelDataTransformer extends Service {
|
|
3330
|
+
_ModelDataTransformer = class _ModelDataTransformer extends import_js_service16.Service {
|
|
3686
3331
|
/**
|
|
3687
3332
|
* Transform.
|
|
3688
3333
|
*
|
|
@@ -3693,7 +3338,7 @@ var init_model_data_transformer = __esm({
|
|
|
3693
3338
|
*/
|
|
3694
3339
|
transform(modelName, modelData, isPartial = false) {
|
|
3695
3340
|
if (!isPureObject(modelData))
|
|
3696
|
-
throw new
|
|
3341
|
+
throw new InvalidArgumentError(
|
|
3697
3342
|
"The data of the model %v should be an Object, but %v given.",
|
|
3698
3343
|
modelName,
|
|
3699
3344
|
modelData
|
|
@@ -3764,7 +3409,7 @@ var init_model_data_transformer = __esm({
|
|
|
3764
3409
|
propValue
|
|
3765
3410
|
);
|
|
3766
3411
|
} else {
|
|
3767
|
-
throw new
|
|
3412
|
+
throw new InvalidArgumentError(
|
|
3768
3413
|
'The provided option "transform" of the property %v in the model %v should be a non-empty String, an Array of String or an Object, but %v given.',
|
|
3769
3414
|
propName,
|
|
3770
3415
|
modelName,
|
|
@@ -3779,15 +3424,15 @@ var init_model_data_transformer = __esm({
|
|
|
3779
3424
|
});
|
|
3780
3425
|
|
|
3781
3426
|
// src/definition/model/model-definition-validator.js
|
|
3782
|
-
var _ModelDefinitionValidator, ModelDefinitionValidator;
|
|
3427
|
+
var import_js_service17, _ModelDefinitionValidator, ModelDefinitionValidator;
|
|
3783
3428
|
var init_model_definition_validator = __esm({
|
|
3784
3429
|
"src/definition/model/model-definition-validator.js"() {
|
|
3785
3430
|
"use strict";
|
|
3786
|
-
|
|
3787
|
-
|
|
3431
|
+
import_js_service17 = require("@e22m4u/js-service");
|
|
3432
|
+
init_errors();
|
|
3788
3433
|
init_relations();
|
|
3789
3434
|
init_properties();
|
|
3790
|
-
_ModelDefinitionValidator = class _ModelDefinitionValidator extends Service {
|
|
3435
|
+
_ModelDefinitionValidator = class _ModelDefinitionValidator extends import_js_service17.Service {
|
|
3791
3436
|
/**
|
|
3792
3437
|
* Validate.
|
|
3793
3438
|
*
|
|
@@ -3795,36 +3440,36 @@ var init_model_definition_validator = __esm({
|
|
|
3795
3440
|
*/
|
|
3796
3441
|
validate(modelDef) {
|
|
3797
3442
|
if (!modelDef || typeof modelDef !== "object" || Array.isArray(modelDef))
|
|
3798
|
-
throw new
|
|
3443
|
+
throw new InvalidArgumentError(
|
|
3799
3444
|
"The model definition should be an Object, but %v given.",
|
|
3800
3445
|
modelDef
|
|
3801
3446
|
);
|
|
3802
3447
|
if (!modelDef.name || typeof modelDef.name !== "string")
|
|
3803
|
-
throw new
|
|
3448
|
+
throw new InvalidArgumentError(
|
|
3804
3449
|
'The model definition requires the option "name" as a non-empty String, but %v given.',
|
|
3805
3450
|
modelDef.name
|
|
3806
3451
|
);
|
|
3807
3452
|
if (modelDef.datasource && typeof modelDef.datasource !== "string")
|
|
3808
|
-
throw new
|
|
3453
|
+
throw new InvalidArgumentError(
|
|
3809
3454
|
'The provided option "datasource" of the model %v should be a String, but %v given.',
|
|
3810
3455
|
modelDef.name,
|
|
3811
3456
|
modelDef.datasource
|
|
3812
3457
|
);
|
|
3813
3458
|
if (modelDef.base && typeof modelDef.base !== "string")
|
|
3814
|
-
throw new
|
|
3459
|
+
throw new InvalidArgumentError(
|
|
3815
3460
|
'The provided option "base" of the model %v should be a String, but %v given.',
|
|
3816
3461
|
modelDef.name,
|
|
3817
3462
|
modelDef.base
|
|
3818
3463
|
);
|
|
3819
3464
|
if (modelDef.tableName && typeof modelDef.tableName !== "string")
|
|
3820
|
-
throw new
|
|
3465
|
+
throw new InvalidArgumentError(
|
|
3821
3466
|
'The provided option "tableName" of the model %v should be a String, but %v given.',
|
|
3822
3467
|
modelDef.name,
|
|
3823
3468
|
modelDef.tableName
|
|
3824
3469
|
);
|
|
3825
3470
|
if (modelDef.properties) {
|
|
3826
3471
|
if (typeof modelDef.properties !== "object" || Array.isArray(modelDef.properties)) {
|
|
3827
|
-
throw new
|
|
3472
|
+
throw new InvalidArgumentError(
|
|
3828
3473
|
'The provided option "properties" of the model %v should be an Object, but %v given.',
|
|
3829
3474
|
modelDef.name,
|
|
3830
3475
|
modelDef.properties
|
|
@@ -3837,7 +3482,7 @@ var init_model_definition_validator = __esm({
|
|
|
3837
3482
|
}
|
|
3838
3483
|
if (modelDef.relations) {
|
|
3839
3484
|
if (typeof modelDef.relations !== "object" || Array.isArray(modelDef.relations)) {
|
|
3840
|
-
throw new
|
|
3485
|
+
throw new InvalidArgumentError(
|
|
3841
3486
|
'The provided option "relations" of the model %v should be an Object, but %v given.',
|
|
3842
3487
|
modelDef.name,
|
|
3843
3488
|
modelDef.relations
|
|
@@ -3871,13 +3516,13 @@ var init_model = __esm({
|
|
|
3871
3516
|
});
|
|
3872
3517
|
|
|
3873
3518
|
// src/definition/datasource/datasource-definition-validator.js
|
|
3874
|
-
var _DatasourceDefinitionValidator, DatasourceDefinitionValidator;
|
|
3519
|
+
var import_js_service18, _DatasourceDefinitionValidator, DatasourceDefinitionValidator;
|
|
3875
3520
|
var init_datasource_definition_validator = __esm({
|
|
3876
3521
|
"src/definition/datasource/datasource-definition-validator.js"() {
|
|
3877
3522
|
"use strict";
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
_DatasourceDefinitionValidator = class _DatasourceDefinitionValidator extends Service {
|
|
3523
|
+
import_js_service18 = require("@e22m4u/js-service");
|
|
3524
|
+
init_errors();
|
|
3525
|
+
_DatasourceDefinitionValidator = class _DatasourceDefinitionValidator extends import_js_service18.Service {
|
|
3881
3526
|
/**
|
|
3882
3527
|
* Validate.
|
|
3883
3528
|
*
|
|
@@ -3885,17 +3530,17 @@ var init_datasource_definition_validator = __esm({
|
|
|
3885
3530
|
*/
|
|
3886
3531
|
validate(datasourceDef) {
|
|
3887
3532
|
if (!datasourceDef || typeof datasourceDef !== "object")
|
|
3888
|
-
throw new
|
|
3533
|
+
throw new InvalidArgumentError(
|
|
3889
3534
|
"The datasource definition should be an Object, but %v given.",
|
|
3890
3535
|
datasourceDef
|
|
3891
3536
|
);
|
|
3892
3537
|
if (!datasourceDef.name || typeof datasourceDef.name !== "string")
|
|
3893
|
-
throw new
|
|
3538
|
+
throw new InvalidArgumentError(
|
|
3894
3539
|
'The datasource definition requires the option "name" as a non-empty String, but %v given.',
|
|
3895
3540
|
datasourceDef.name
|
|
3896
3541
|
);
|
|
3897
3542
|
if (!datasourceDef.adapter || typeof datasourceDef.adapter !== "string")
|
|
3898
|
-
throw new
|
|
3543
|
+
throw new InvalidArgumentError(
|
|
3899
3544
|
'The datasource %v requires the option "adapter" as a non-empty String, but %v given.',
|
|
3900
3545
|
datasourceDef.name,
|
|
3901
3546
|
datasourceDef.adapter
|
|
@@ -3926,15 +3571,15 @@ var init_definition = __esm({
|
|
|
3926
3571
|
});
|
|
3927
3572
|
|
|
3928
3573
|
// src/filter/fields-clause-tool.js
|
|
3929
|
-
var _FieldsClauseTool, FieldsClauseTool;
|
|
3574
|
+
var import_js_service19, _FieldsClauseTool, FieldsClauseTool;
|
|
3930
3575
|
var init_fields_clause_tool = __esm({
|
|
3931
3576
|
"src/filter/fields-clause-tool.js"() {
|
|
3932
3577
|
"use strict";
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3578
|
+
import_js_service19 = require("@e22m4u/js-service");
|
|
3579
|
+
init_utils();
|
|
3580
|
+
init_errors();
|
|
3936
3581
|
init_definition();
|
|
3937
|
-
_FieldsClauseTool = class _FieldsClauseTool extends Service {
|
|
3582
|
+
_FieldsClauseTool = class _FieldsClauseTool extends import_js_service19.Service {
|
|
3938
3583
|
/**
|
|
3939
3584
|
* Filter.
|
|
3940
3585
|
*
|
|
@@ -3948,13 +3593,13 @@ var init_fields_clause_tool = __esm({
|
|
|
3948
3593
|
let entities = isArray ? input : [input];
|
|
3949
3594
|
entities.forEach((entity) => {
|
|
3950
3595
|
if (!entity || typeof entity !== "object" || Array.isArray(entity))
|
|
3951
|
-
throw new
|
|
3596
|
+
throw new InvalidArgumentError(
|
|
3952
3597
|
"The first argument of FieldsClauseTool.filter should be an Object or an Array of Object, but %v given.",
|
|
3953
3598
|
entity
|
|
3954
3599
|
);
|
|
3955
3600
|
});
|
|
3956
3601
|
if (!modelName || typeof modelName !== "string")
|
|
3957
|
-
throw new
|
|
3602
|
+
throw new InvalidArgumentError(
|
|
3958
3603
|
"The second argument of FieldsClauseTool.filter should be a non-empty String, but %v given.",
|
|
3959
3604
|
modelName
|
|
3960
3605
|
);
|
|
@@ -3963,7 +3608,7 @@ var init_fields_clause_tool = __esm({
|
|
|
3963
3608
|
if (!fields.length) return input;
|
|
3964
3609
|
fields.forEach((field) => {
|
|
3965
3610
|
if (!field || typeof field !== "string")
|
|
3966
|
-
throw new
|
|
3611
|
+
throw new InvalidArgumentError(
|
|
3967
3612
|
'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v given.',
|
|
3968
3613
|
field
|
|
3969
3614
|
);
|
|
@@ -3986,7 +3631,7 @@ var init_fields_clause_tool = __esm({
|
|
|
3986
3631
|
if (!fields.length) return;
|
|
3987
3632
|
fields.forEach((field) => {
|
|
3988
3633
|
if (!field || typeof field !== "string")
|
|
3989
|
-
throw new
|
|
3634
|
+
throw new InvalidArgumentError(
|
|
3990
3635
|
'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v given.',
|
|
3991
3636
|
field
|
|
3992
3637
|
);
|
|
@@ -4004,7 +3649,7 @@ var init_fields_clause_tool = __esm({
|
|
|
4004
3649
|
if (!fields.length) return;
|
|
4005
3650
|
fields.forEach((field) => {
|
|
4006
3651
|
if (!field || typeof field !== "string")
|
|
4007
|
-
throw new
|
|
3652
|
+
throw new InvalidArgumentError(
|
|
4008
3653
|
'The provided option "fields" should be a non-empty String or an Array of non-empty String, but %v given.',
|
|
4009
3654
|
field
|
|
4010
3655
|
);
|
|
@@ -4018,17 +3663,17 @@ var init_fields_clause_tool = __esm({
|
|
|
4018
3663
|
});
|
|
4019
3664
|
|
|
4020
3665
|
// src/relations/has-one-resolver.js
|
|
4021
|
-
var _HasOneResolver, HasOneResolver;
|
|
3666
|
+
var import_js_service20, _HasOneResolver, HasOneResolver;
|
|
4022
3667
|
var init_has_one_resolver = __esm({
|
|
4023
3668
|
"src/relations/has-one-resolver.js"() {
|
|
4024
3669
|
"use strict";
|
|
4025
|
-
|
|
4026
|
-
|
|
3670
|
+
import_js_service20 = require("@e22m4u/js-service");
|
|
3671
|
+
init_utils();
|
|
4027
3672
|
init_definition();
|
|
4028
|
-
|
|
3673
|
+
init_errors();
|
|
4029
3674
|
init_repository2();
|
|
4030
3675
|
init_definition();
|
|
4031
|
-
_HasOneResolver = class _HasOneResolver extends Service {
|
|
3676
|
+
_HasOneResolver = class _HasOneResolver extends import_js_service20.Service {
|
|
4032
3677
|
/**
|
|
4033
3678
|
* Include to.
|
|
4034
3679
|
*
|
|
@@ -4042,32 +3687,32 @@ var init_has_one_resolver = __esm({
|
|
|
4042
3687
|
*/
|
|
4043
3688
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey, scope = void 0) {
|
|
4044
3689
|
if (!entities || !Array.isArray(entities))
|
|
4045
|
-
throw new
|
|
3690
|
+
throw new InvalidArgumentError(
|
|
4046
3691
|
'The parameter "entities" of HasOneResolver.includeTo requires an Array of Object, but %v given.',
|
|
4047
3692
|
entities
|
|
4048
3693
|
);
|
|
4049
3694
|
if (!sourceName || typeof sourceName !== "string")
|
|
4050
|
-
throw new
|
|
3695
|
+
throw new InvalidArgumentError(
|
|
4051
3696
|
'The parameter "sourceName" of HasOneResolver.includeTo requires a non-empty String, but %v given.',
|
|
4052
3697
|
sourceName
|
|
4053
3698
|
);
|
|
4054
3699
|
if (!targetName || typeof targetName !== "string")
|
|
4055
|
-
throw new
|
|
3700
|
+
throw new InvalidArgumentError(
|
|
4056
3701
|
'The parameter "targetName" of HasOneResolver.includeTo requires a non-empty String, but %v given.',
|
|
4057
3702
|
targetName
|
|
4058
3703
|
);
|
|
4059
3704
|
if (!relationName || typeof relationName !== "string")
|
|
4060
|
-
throw new
|
|
3705
|
+
throw new InvalidArgumentError(
|
|
4061
3706
|
'The parameter "relationName" of HasOneResolver.includeTo requires a non-empty String, but %v given.',
|
|
4062
3707
|
relationName
|
|
4063
3708
|
);
|
|
4064
3709
|
if (!foreignKey || typeof foreignKey !== "string")
|
|
4065
|
-
throw new
|
|
3710
|
+
throw new InvalidArgumentError(
|
|
4066
3711
|
'The parameter "foreignKey" of HasOneResolver.includeTo requires a non-empty String, but %v given.',
|
|
4067
3712
|
foreignKey
|
|
4068
3713
|
);
|
|
4069
3714
|
if (scope && (typeof scope !== "object" || Array.isArray(scope)))
|
|
4070
|
-
throw new
|
|
3715
|
+
throw new InvalidArgumentError(
|
|
4071
3716
|
'The provided parameter "scope" of HasOneResolver.includeTo should be an Object, but %v given.',
|
|
4072
3717
|
scope
|
|
4073
3718
|
);
|
|
@@ -4077,7 +3722,7 @@ var init_has_one_resolver = __esm({
|
|
|
4077
3722
|
const sourceIds = [];
|
|
4078
3723
|
entities.forEach((entity) => {
|
|
4079
3724
|
if (!entity || typeof entity !== "object" || Array.isArray(entity))
|
|
4080
|
-
throw new
|
|
3725
|
+
throw new InvalidArgumentError(
|
|
4081
3726
|
'The parameter "entities" of HasOneResolver.includeTo requires an Array of Object, but %v given.',
|
|
4082
3727
|
entity
|
|
4083
3728
|
);
|
|
@@ -4121,37 +3766,37 @@ var init_has_one_resolver = __esm({
|
|
|
4121
3766
|
*/
|
|
4122
3767
|
async includePolymorphicTo(entities, sourceName, targetName, relationName, foreignKey, discriminator, scope = void 0) {
|
|
4123
3768
|
if (!entities || !Array.isArray(entities))
|
|
4124
|
-
throw new
|
|
3769
|
+
throw new InvalidArgumentError(
|
|
4125
3770
|
'The parameter "entities" of HasOneResolver.includePolymorphicTo requires an Array of Object, but %v given.',
|
|
4126
3771
|
entities
|
|
4127
3772
|
);
|
|
4128
3773
|
if (!sourceName || typeof sourceName !== "string")
|
|
4129
|
-
throw new
|
|
3774
|
+
throw new InvalidArgumentError(
|
|
4130
3775
|
'The parameter "sourceName" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4131
3776
|
sourceName
|
|
4132
3777
|
);
|
|
4133
3778
|
if (!targetName || typeof targetName !== "string")
|
|
4134
|
-
throw new
|
|
3779
|
+
throw new InvalidArgumentError(
|
|
4135
3780
|
'The parameter "targetName" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4136
3781
|
targetName
|
|
4137
3782
|
);
|
|
4138
3783
|
if (!relationName || typeof relationName !== "string")
|
|
4139
|
-
throw new
|
|
3784
|
+
throw new InvalidArgumentError(
|
|
4140
3785
|
'The parameter "relationName" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4141
3786
|
relationName
|
|
4142
3787
|
);
|
|
4143
3788
|
if (!foreignKey || typeof foreignKey !== "string")
|
|
4144
|
-
throw new
|
|
3789
|
+
throw new InvalidArgumentError(
|
|
4145
3790
|
'The parameter "foreignKey" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4146
3791
|
foreignKey
|
|
4147
3792
|
);
|
|
4148
3793
|
if (!discriminator || typeof discriminator !== "string")
|
|
4149
|
-
throw new
|
|
3794
|
+
throw new InvalidArgumentError(
|
|
4150
3795
|
'The parameter "discriminator" of HasOneResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4151
3796
|
discriminator
|
|
4152
3797
|
);
|
|
4153
3798
|
if (scope && (typeof scope !== "object" || Array.isArray(scope)))
|
|
4154
|
-
throw new
|
|
3799
|
+
throw new InvalidArgumentError(
|
|
4155
3800
|
'The provided parameter "scope" of HasOneResolver.includePolymorphicTo should be an Object, but %v given.',
|
|
4156
3801
|
scope
|
|
4157
3802
|
);
|
|
@@ -4161,7 +3806,7 @@ var init_has_one_resolver = __esm({
|
|
|
4161
3806
|
const sourceIds = [];
|
|
4162
3807
|
entities.forEach((entity) => {
|
|
4163
3808
|
if (!entity || typeof entity !== "object" || Array.isArray(entity))
|
|
4164
|
-
throw new
|
|
3809
|
+
throw new InvalidArgumentError(
|
|
4165
3810
|
'The parameter "entities" of HasOneResolver.includePolymorphicTo requires an Array of Object, but %v given.',
|
|
4166
3811
|
entity
|
|
4167
3812
|
);
|
|
@@ -4207,32 +3852,32 @@ var init_has_one_resolver = __esm({
|
|
|
4207
3852
|
*/
|
|
4208
3853
|
async includePolymorphicByRelationName(entities, sourceName, targetName, relationName, targetRelationName, scope = void 0) {
|
|
4209
3854
|
if (!entities || !Array.isArray(entities))
|
|
4210
|
-
throw new
|
|
3855
|
+
throw new InvalidArgumentError(
|
|
4211
3856
|
'The parameter "entities" of HasOneResolver.includePolymorphicByRelationName requires an Array of Object, but %v given.',
|
|
4212
3857
|
entities
|
|
4213
3858
|
);
|
|
4214
3859
|
if (!sourceName || typeof sourceName !== "string")
|
|
4215
|
-
throw new
|
|
3860
|
+
throw new InvalidArgumentError(
|
|
4216
3861
|
'The parameter "sourceName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
|
|
4217
3862
|
sourceName
|
|
4218
3863
|
);
|
|
4219
3864
|
if (!targetName || typeof targetName !== "string")
|
|
4220
|
-
throw new
|
|
3865
|
+
throw new InvalidArgumentError(
|
|
4221
3866
|
'The parameter "targetName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
|
|
4222
3867
|
targetName
|
|
4223
3868
|
);
|
|
4224
3869
|
if (!relationName || typeof relationName !== "string")
|
|
4225
|
-
throw new
|
|
3870
|
+
throw new InvalidArgumentError(
|
|
4226
3871
|
'The parameter "relationName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
|
|
4227
3872
|
relationName
|
|
4228
3873
|
);
|
|
4229
3874
|
if (!targetRelationName || typeof targetRelationName !== "string")
|
|
4230
|
-
throw new
|
|
3875
|
+
throw new InvalidArgumentError(
|
|
4231
3876
|
'The parameter "targetRelationName" of HasOneResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
|
|
4232
3877
|
targetRelationName
|
|
4233
3878
|
);
|
|
4234
3879
|
if (scope && (typeof scope !== "object" || Array.isArray(scope)))
|
|
4235
|
-
throw new
|
|
3880
|
+
throw new InvalidArgumentError(
|
|
4236
3881
|
'The provided parameter "scope" of HasOneResolver.includePolymorphicByRelationName should be an Object, but %v given.',
|
|
4237
3882
|
scope
|
|
4238
3883
|
);
|
|
@@ -4240,7 +3885,7 @@ var init_has_one_resolver = __esm({
|
|
|
4240
3885
|
ModelDefinitionUtils
|
|
4241
3886
|
).getRelationDefinitionByName(targetName, targetRelationName);
|
|
4242
3887
|
if (targetRelationDef.type !== RelationType.BELONGS_TO)
|
|
4243
|
-
throw new
|
|
3888
|
+
throw new InvalidArgumentError(
|
|
4244
3889
|
'The relation %v of the model %v is a polymorphic "hasOne" relation, so it requires the target relation %v to be a polymorphic "belongsTo", but %v type given.',
|
|
4245
3890
|
relationName,
|
|
4246
3891
|
sourceName,
|
|
@@ -4248,7 +3893,7 @@ var init_has_one_resolver = __esm({
|
|
|
4248
3893
|
targetRelationDef.type
|
|
4249
3894
|
);
|
|
4250
3895
|
if (!targetRelationDef.polymorphic)
|
|
4251
|
-
throw new
|
|
3896
|
+
throw new InvalidArgumentError(
|
|
4252
3897
|
'The relation %v of the model %v is a polymorphic "hasOne" relation, so it requires the target relation %v to be a polymorphic too.',
|
|
4253
3898
|
relationName,
|
|
4254
3899
|
sourceName,
|
|
@@ -4273,17 +3918,17 @@ var init_has_one_resolver = __esm({
|
|
|
4273
3918
|
});
|
|
4274
3919
|
|
|
4275
3920
|
// src/relations/has-many-resolver.js
|
|
4276
|
-
var _HasManyResolver, HasManyResolver;
|
|
3921
|
+
var import_js_service21, _HasManyResolver, HasManyResolver;
|
|
4277
3922
|
var init_has_many_resolver = __esm({
|
|
4278
3923
|
"src/relations/has-many-resolver.js"() {
|
|
4279
3924
|
"use strict";
|
|
4280
|
-
|
|
4281
|
-
|
|
3925
|
+
import_js_service21 = require("@e22m4u/js-service");
|
|
3926
|
+
init_utils();
|
|
4282
3927
|
init_definition();
|
|
4283
|
-
|
|
3928
|
+
init_errors();
|
|
4284
3929
|
init_repository2();
|
|
4285
3930
|
init_definition();
|
|
4286
|
-
_HasManyResolver = class _HasManyResolver extends Service {
|
|
3931
|
+
_HasManyResolver = class _HasManyResolver extends import_js_service21.Service {
|
|
4287
3932
|
/**
|
|
4288
3933
|
* Include to.
|
|
4289
3934
|
*
|
|
@@ -4297,32 +3942,32 @@ var init_has_many_resolver = __esm({
|
|
|
4297
3942
|
*/
|
|
4298
3943
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey, scope = void 0) {
|
|
4299
3944
|
if (!entities || !Array.isArray(entities))
|
|
4300
|
-
throw new
|
|
3945
|
+
throw new InvalidArgumentError(
|
|
4301
3946
|
'The parameter "entities" of HasManyResolver.includeTo requires an Array of Object, but %v given.',
|
|
4302
3947
|
entities
|
|
4303
3948
|
);
|
|
4304
3949
|
if (!sourceName || typeof sourceName !== "string")
|
|
4305
|
-
throw new
|
|
3950
|
+
throw new InvalidArgumentError(
|
|
4306
3951
|
'The parameter "sourceName" of HasManyResolver.includeTo requires a non-empty String, but %v given.',
|
|
4307
3952
|
sourceName
|
|
4308
3953
|
);
|
|
4309
3954
|
if (!targetName || typeof targetName !== "string")
|
|
4310
|
-
throw new
|
|
3955
|
+
throw new InvalidArgumentError(
|
|
4311
3956
|
'The parameter "targetName" of HasManyResolver.includeTo requires a non-empty String, but %v given.',
|
|
4312
3957
|
targetName
|
|
4313
3958
|
);
|
|
4314
3959
|
if (!relationName || typeof relationName !== "string")
|
|
4315
|
-
throw new
|
|
3960
|
+
throw new InvalidArgumentError(
|
|
4316
3961
|
'The parameter "relationName" of HasManyResolver.includeTo requires a non-empty String, but %v given.',
|
|
4317
3962
|
relationName
|
|
4318
3963
|
);
|
|
4319
3964
|
if (!foreignKey || typeof foreignKey !== "string")
|
|
4320
|
-
throw new
|
|
3965
|
+
throw new InvalidArgumentError(
|
|
4321
3966
|
'The parameter "foreignKey" of HasManyResolver.includeTo requires a non-empty String, but %v given.',
|
|
4322
3967
|
foreignKey
|
|
4323
3968
|
);
|
|
4324
3969
|
if (scope && (typeof scope !== "object" || Array.isArray(scope)))
|
|
4325
|
-
throw new
|
|
3970
|
+
throw new InvalidArgumentError(
|
|
4326
3971
|
'The provided parameter "scope" of HasManyResolver.includeTo should be an Object, but %v given.',
|
|
4327
3972
|
scope
|
|
4328
3973
|
);
|
|
@@ -4332,7 +3977,7 @@ var init_has_many_resolver = __esm({
|
|
|
4332
3977
|
const sourceIds = [];
|
|
4333
3978
|
entities.forEach((entity) => {
|
|
4334
3979
|
if (!entity || typeof entity !== "object" || Array.isArray(entity))
|
|
4335
|
-
throw new
|
|
3980
|
+
throw new InvalidArgumentError(
|
|
4336
3981
|
'The parameter "entities" of HasManyResolver.includeTo requires an Array of Object, but %v given.',
|
|
4337
3982
|
entity
|
|
4338
3983
|
);
|
|
@@ -4381,37 +4026,37 @@ var init_has_many_resolver = __esm({
|
|
|
4381
4026
|
*/
|
|
4382
4027
|
async includePolymorphicTo(entities, sourceName, targetName, relationName, foreignKey, discriminator, scope = void 0) {
|
|
4383
4028
|
if (!entities || !Array.isArray(entities))
|
|
4384
|
-
throw new
|
|
4029
|
+
throw new InvalidArgumentError(
|
|
4385
4030
|
'The parameter "entities" of HasManyResolver.includePolymorphicTo requires an Array of Object, but %v given.',
|
|
4386
4031
|
entities
|
|
4387
4032
|
);
|
|
4388
4033
|
if (!sourceName || typeof sourceName !== "string")
|
|
4389
|
-
throw new
|
|
4034
|
+
throw new InvalidArgumentError(
|
|
4390
4035
|
'The parameter "sourceName" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4391
4036
|
sourceName
|
|
4392
4037
|
);
|
|
4393
4038
|
if (!targetName || typeof targetName !== "string")
|
|
4394
|
-
throw new
|
|
4039
|
+
throw new InvalidArgumentError(
|
|
4395
4040
|
'The parameter "targetName" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4396
4041
|
targetName
|
|
4397
4042
|
);
|
|
4398
4043
|
if (!relationName || typeof relationName !== "string")
|
|
4399
|
-
throw new
|
|
4044
|
+
throw new InvalidArgumentError(
|
|
4400
4045
|
'The parameter "relationName" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4401
4046
|
relationName
|
|
4402
4047
|
);
|
|
4403
4048
|
if (!foreignKey || typeof foreignKey !== "string")
|
|
4404
|
-
throw new
|
|
4049
|
+
throw new InvalidArgumentError(
|
|
4405
4050
|
'The parameter "foreignKey" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4406
4051
|
foreignKey
|
|
4407
4052
|
);
|
|
4408
4053
|
if (!discriminator || typeof discriminator !== "string")
|
|
4409
|
-
throw new
|
|
4054
|
+
throw new InvalidArgumentError(
|
|
4410
4055
|
'The parameter "discriminator" of HasManyResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4411
4056
|
discriminator
|
|
4412
4057
|
);
|
|
4413
4058
|
if (scope && (typeof scope !== "object" || Array.isArray(scope)))
|
|
4414
|
-
throw new
|
|
4059
|
+
throw new InvalidArgumentError(
|
|
4415
4060
|
'The provided parameter "scope" of HasManyResolver.includePolymorphicTo should be an Object, but %v given.',
|
|
4416
4061
|
scope
|
|
4417
4062
|
);
|
|
@@ -4421,7 +4066,7 @@ var init_has_many_resolver = __esm({
|
|
|
4421
4066
|
const sourceIds = [];
|
|
4422
4067
|
entities.forEach((entity) => {
|
|
4423
4068
|
if (!entity || typeof entity !== "object" || Array.isArray(entity))
|
|
4424
|
-
throw new
|
|
4069
|
+
throw new InvalidArgumentError(
|
|
4425
4070
|
'The parameter "entities" of HasManyResolver.includePolymorphicTo requires an Array of Object, but %v given.',
|
|
4426
4071
|
entity
|
|
4427
4072
|
);
|
|
@@ -4472,32 +4117,32 @@ var init_has_many_resolver = __esm({
|
|
|
4472
4117
|
*/
|
|
4473
4118
|
async includePolymorphicByRelationName(entities, sourceName, targetName, relationName, targetRelationName, scope = void 0) {
|
|
4474
4119
|
if (!entities || !Array.isArray(entities))
|
|
4475
|
-
throw new
|
|
4120
|
+
throw new InvalidArgumentError(
|
|
4476
4121
|
'The parameter "entities" of HasManyResolver.includePolymorphicByRelationName requires an Array of Object, but %v given.',
|
|
4477
4122
|
entities
|
|
4478
4123
|
);
|
|
4479
4124
|
if (!sourceName || typeof sourceName !== "string")
|
|
4480
|
-
throw new
|
|
4125
|
+
throw new InvalidArgumentError(
|
|
4481
4126
|
'The parameter "sourceName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
|
|
4482
4127
|
sourceName
|
|
4483
4128
|
);
|
|
4484
4129
|
if (!targetName || typeof targetName !== "string")
|
|
4485
|
-
throw new
|
|
4130
|
+
throw new InvalidArgumentError(
|
|
4486
4131
|
'The parameter "targetName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
|
|
4487
4132
|
targetName
|
|
4488
4133
|
);
|
|
4489
4134
|
if (!relationName || typeof relationName !== "string")
|
|
4490
|
-
throw new
|
|
4135
|
+
throw new InvalidArgumentError(
|
|
4491
4136
|
'The parameter "relationName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
|
|
4492
4137
|
relationName
|
|
4493
4138
|
);
|
|
4494
4139
|
if (!targetRelationName || typeof targetRelationName !== "string")
|
|
4495
|
-
throw new
|
|
4140
|
+
throw new InvalidArgumentError(
|
|
4496
4141
|
'The parameter "targetRelationName" of HasManyResolver.includePolymorphicByRelationName requires a non-empty String, but %v given.',
|
|
4497
4142
|
targetRelationName
|
|
4498
4143
|
);
|
|
4499
4144
|
if (scope && (typeof scope !== "object" || Array.isArray(scope)))
|
|
4500
|
-
throw new
|
|
4145
|
+
throw new InvalidArgumentError(
|
|
4501
4146
|
'The provided parameter "scope" of HasManyResolver.includePolymorphicByRelationName should be an Object, but %v given.',
|
|
4502
4147
|
scope
|
|
4503
4148
|
);
|
|
@@ -4505,7 +4150,7 @@ var init_has_many_resolver = __esm({
|
|
|
4505
4150
|
ModelDefinitionUtils
|
|
4506
4151
|
).getRelationDefinitionByName(targetName, targetRelationName);
|
|
4507
4152
|
if (targetRelationDef.type !== RelationType.BELONGS_TO)
|
|
4508
|
-
throw new
|
|
4153
|
+
throw new InvalidArgumentError(
|
|
4509
4154
|
'The relation %v of the model %v is a polymorphic "hasMany" relation, so it requires the target relation %v to be a polymorphic "belongsTo", but %v type given.',
|
|
4510
4155
|
relationName,
|
|
4511
4156
|
sourceName,
|
|
@@ -4513,7 +4158,7 @@ var init_has_many_resolver = __esm({
|
|
|
4513
4158
|
targetRelationDef.type
|
|
4514
4159
|
);
|
|
4515
4160
|
if (!targetRelationDef.polymorphic)
|
|
4516
|
-
throw new
|
|
4161
|
+
throw new InvalidArgumentError(
|
|
4517
4162
|
'The relation %v of the model %v is a polymorphic "hasMany" relation, so it requires the target relation %v to be a polymorphic too.',
|
|
4518
4163
|
relationName,
|
|
4519
4164
|
sourceName,
|
|
@@ -4538,17 +4183,17 @@ var init_has_many_resolver = __esm({
|
|
|
4538
4183
|
});
|
|
4539
4184
|
|
|
4540
4185
|
// src/relations/belongs-to-resolver.js
|
|
4541
|
-
var _BelongsToResolver, BelongsToResolver;
|
|
4186
|
+
var import_js_service22, _BelongsToResolver, BelongsToResolver;
|
|
4542
4187
|
var init_belongs_to_resolver = __esm({
|
|
4543
4188
|
"src/relations/belongs-to-resolver.js"() {
|
|
4544
4189
|
"use strict";
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4190
|
+
import_js_service22 = require("@e22m4u/js-service");
|
|
4191
|
+
init_utils();
|
|
4192
|
+
init_utils();
|
|
4193
|
+
init_errors();
|
|
4549
4194
|
init_repository2();
|
|
4550
4195
|
init_definition();
|
|
4551
|
-
_BelongsToResolver = class _BelongsToResolver extends Service {
|
|
4196
|
+
_BelongsToResolver = class _BelongsToResolver extends import_js_service22.Service {
|
|
4552
4197
|
/**
|
|
4553
4198
|
* Include to.
|
|
4554
4199
|
*
|
|
@@ -4562,39 +4207,39 @@ var init_belongs_to_resolver = __esm({
|
|
|
4562
4207
|
*/
|
|
4563
4208
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey = void 0, scope = void 0) {
|
|
4564
4209
|
if (!entities || !Array.isArray(entities))
|
|
4565
|
-
throw new
|
|
4210
|
+
throw new InvalidArgumentError(
|
|
4566
4211
|
'The parameter "entities" of BelongsToResolver.includeTo requires an Array of Object, but %v given.',
|
|
4567
4212
|
entities
|
|
4568
4213
|
);
|
|
4569
4214
|
if (!sourceName || typeof sourceName !== "string")
|
|
4570
|
-
throw new
|
|
4215
|
+
throw new InvalidArgumentError(
|
|
4571
4216
|
'The parameter "sourceName" of BelongsToResolver.includeTo requires a non-empty String, but %v given.',
|
|
4572
4217
|
sourceName
|
|
4573
4218
|
);
|
|
4574
4219
|
if (!targetName || typeof targetName !== "string")
|
|
4575
|
-
throw new
|
|
4220
|
+
throw new InvalidArgumentError(
|
|
4576
4221
|
'The parameter "targetName" of BelongsToResolver.includeTo requires a non-empty String, but %v given.',
|
|
4577
4222
|
targetName
|
|
4578
4223
|
);
|
|
4579
4224
|
if (!relationName || typeof relationName !== "string")
|
|
4580
|
-
throw new
|
|
4225
|
+
throw new InvalidArgumentError(
|
|
4581
4226
|
'The parameter "relationName" of BelongsToResolver.includeTo requires a non-empty String, but %v given.',
|
|
4582
4227
|
relationName
|
|
4583
4228
|
);
|
|
4584
4229
|
if (foreignKey && typeof foreignKey !== "string")
|
|
4585
|
-
throw new
|
|
4230
|
+
throw new InvalidArgumentError(
|
|
4586
4231
|
'The provided parameter "foreignKey" of BelongsToResolver.includeTo should be a String, but %v given.',
|
|
4587
4232
|
foreignKey
|
|
4588
4233
|
);
|
|
4589
4234
|
if (scope && (typeof scope !== "object" || Array.isArray(scope)))
|
|
4590
|
-
throw new
|
|
4235
|
+
throw new InvalidArgumentError(
|
|
4591
4236
|
'The provided parameter "scope" of BelongsToResolver.includeTo should be an Object, but %v given.',
|
|
4592
4237
|
scope
|
|
4593
4238
|
);
|
|
4594
4239
|
if (foreignKey == null) foreignKey = `${relationName}Id`;
|
|
4595
4240
|
const targetIds = entities.reduce((acc, entity) => {
|
|
4596
4241
|
if (!entity || typeof entity !== "object" || Array.isArray(entity))
|
|
4597
|
-
throw new
|
|
4242
|
+
throw new InvalidArgumentError(
|
|
4598
4243
|
'The parameter "entities" of BelongsToResolver.includeTo requires an Array of Object, but %v given.',
|
|
4599
4244
|
entity
|
|
4600
4245
|
);
|
|
@@ -4634,32 +4279,32 @@ var init_belongs_to_resolver = __esm({
|
|
|
4634
4279
|
*/
|
|
4635
4280
|
async includePolymorphicTo(entities, sourceName, relationName, foreignKey = void 0, discriminator = void 0, scope = void 0) {
|
|
4636
4281
|
if (!entities || !Array.isArray(entities))
|
|
4637
|
-
throw new
|
|
4282
|
+
throw new InvalidArgumentError(
|
|
4638
4283
|
'The parameter "entities" of BelongsToResolver.includePolymorphicTo requires an Array of Object, but %v given.',
|
|
4639
4284
|
entities
|
|
4640
4285
|
);
|
|
4641
4286
|
if (!sourceName || typeof sourceName !== "string")
|
|
4642
|
-
throw new
|
|
4287
|
+
throw new InvalidArgumentError(
|
|
4643
4288
|
'The parameter "sourceName" of BelongsToResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4644
4289
|
sourceName
|
|
4645
4290
|
);
|
|
4646
4291
|
if (!relationName || typeof relationName !== "string")
|
|
4647
|
-
throw new
|
|
4292
|
+
throw new InvalidArgumentError(
|
|
4648
4293
|
'The parameter "relationName" of BelongsToResolver.includePolymorphicTo requires a non-empty String, but %v given.',
|
|
4649
4294
|
relationName
|
|
4650
4295
|
);
|
|
4651
4296
|
if (foreignKey && typeof foreignKey !== "string")
|
|
4652
|
-
throw new
|
|
4297
|
+
throw new InvalidArgumentError(
|
|
4653
4298
|
'The provided parameter "foreignKey" of BelongsToResolver.includePolymorphicTo should be a String, but %v given.',
|
|
4654
4299
|
foreignKey
|
|
4655
4300
|
);
|
|
4656
4301
|
if (discriminator && typeof discriminator !== "string")
|
|
4657
|
-
throw new
|
|
4302
|
+
throw new InvalidArgumentError(
|
|
4658
4303
|
'The provided parameter "discriminator" of BelongsToResolver.includePolymorphicTo should be a String, but %v given.',
|
|
4659
4304
|
discriminator
|
|
4660
4305
|
);
|
|
4661
4306
|
if (scope && (typeof scope !== "object" || Array.isArray(scope)))
|
|
4662
|
-
throw new
|
|
4307
|
+
throw new InvalidArgumentError(
|
|
4663
4308
|
'The provided parameter "scope" of BelongsToResolver.includePolymorphicTo should be an Object, but %v given.',
|
|
4664
4309
|
scope
|
|
4665
4310
|
);
|
|
@@ -4674,7 +4319,7 @@ var init_belongs_to_resolver = __esm({
|
|
|
4674
4319
|
const targetIdsByTargetName = {};
|
|
4675
4320
|
entities.forEach((entity) => {
|
|
4676
4321
|
if (!entity || typeof entity !== "object" || Array.isArray(entity))
|
|
4677
|
-
throw new
|
|
4322
|
+
throw new InvalidArgumentError(
|
|
4678
4323
|
'The parameter "entities" of BelongsToResolver.includePolymorphicTo requires an Array of Object, but %v given.',
|
|
4679
4324
|
entity
|
|
4680
4325
|
);
|
|
@@ -4695,7 +4340,7 @@ var init_belongs_to_resolver = __esm({
|
|
|
4695
4340
|
try {
|
|
4696
4341
|
targetRepository = this.getService(RepositoryRegistry).getRepository(targetName);
|
|
4697
4342
|
} catch (error) {
|
|
4698
|
-
if (error instanceof
|
|
4343
|
+
if (error instanceof InvalidArgumentError) {
|
|
4699
4344
|
if (error.message === `The model "${targetName}" is not defined.` || error.message === `The model "${targetName}" does not have a specified datasource.`) {
|
|
4700
4345
|
return;
|
|
4701
4346
|
}
|
|
@@ -4746,17 +4391,17 @@ var init_belongs_to_resolver = __esm({
|
|
|
4746
4391
|
});
|
|
4747
4392
|
|
|
4748
4393
|
// src/relations/references-many-resolver.js
|
|
4749
|
-
var _ReferencesManyResolver, ReferencesManyResolver;
|
|
4394
|
+
var import_js_service23, _ReferencesManyResolver, ReferencesManyResolver;
|
|
4750
4395
|
var init_references_many_resolver = __esm({
|
|
4751
4396
|
"src/relations/references-many-resolver.js"() {
|
|
4752
4397
|
"use strict";
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4398
|
+
import_js_service23 = require("@e22m4u/js-service");
|
|
4399
|
+
init_utils();
|
|
4400
|
+
init_utils();
|
|
4401
|
+
init_errors();
|
|
4757
4402
|
init_repository2();
|
|
4758
4403
|
init_definition();
|
|
4759
|
-
_ReferencesManyResolver = class _ReferencesManyResolver extends Service {
|
|
4404
|
+
_ReferencesManyResolver = class _ReferencesManyResolver extends import_js_service23.Service {
|
|
4760
4405
|
/**
|
|
4761
4406
|
* Include to.
|
|
4762
4407
|
*
|
|
@@ -4770,32 +4415,32 @@ var init_references_many_resolver = __esm({
|
|
|
4770
4415
|
*/
|
|
4771
4416
|
async includeTo(entities, sourceName, targetName, relationName, foreignKey = void 0, scope = void 0) {
|
|
4772
4417
|
if (!entities || !Array.isArray(entities))
|
|
4773
|
-
throw new
|
|
4418
|
+
throw new InvalidArgumentError(
|
|
4774
4419
|
'The parameter "entities" of ReferencesManyResolver.includeTo requires an Array of Object, but %v given.',
|
|
4775
4420
|
entities
|
|
4776
4421
|
);
|
|
4777
4422
|
if (!sourceName || typeof sourceName !== "string")
|
|
4778
|
-
throw new
|
|
4423
|
+
throw new InvalidArgumentError(
|
|
4779
4424
|
'The parameter "sourceName" of ReferencesManyResolver.includeTo requires a non-empty String, but %v given.',
|
|
4780
4425
|
sourceName
|
|
4781
4426
|
);
|
|
4782
4427
|
if (!targetName || typeof targetName !== "string")
|
|
4783
|
-
throw new
|
|
4428
|
+
throw new InvalidArgumentError(
|
|
4784
4429
|
'The parameter "targetName" of ReferencesManyResolver.includeTo requires a non-empty String, but %v given.',
|
|
4785
4430
|
targetName
|
|
4786
4431
|
);
|
|
4787
4432
|
if (!relationName || typeof relationName !== "string")
|
|
4788
|
-
throw new
|
|
4433
|
+
throw new InvalidArgumentError(
|
|
4789
4434
|
'The parameter "relationName" of ReferencesManyResolver.includeTo requires a non-empty String, but %v given.',
|
|
4790
4435
|
relationName
|
|
4791
4436
|
);
|
|
4792
4437
|
if (foreignKey && typeof foreignKey !== "string")
|
|
4793
|
-
throw new
|
|
4438
|
+
throw new InvalidArgumentError(
|
|
4794
4439
|
'The provided parameter "foreignKey" of ReferencesManyResolver.includeTo should be a String, but %v given.',
|
|
4795
4440
|
foreignKey
|
|
4796
4441
|
);
|
|
4797
4442
|
if (scope && (typeof scope !== "object" || Array.isArray(scope)))
|
|
4798
|
-
throw new
|
|
4443
|
+
throw new InvalidArgumentError(
|
|
4799
4444
|
'The provided parameter "scope" of ReferencesManyResolver.includeTo should be an Object, but %v given.',
|
|
4800
4445
|
scope
|
|
4801
4446
|
);
|
|
@@ -4805,7 +4450,7 @@ var init_references_many_resolver = __esm({
|
|
|
4805
4450
|
}
|
|
4806
4451
|
const targetIds = entities.reduce((acc, entity) => {
|
|
4807
4452
|
if (!entity || typeof entity !== "object" || Array.isArray(entity))
|
|
4808
|
-
throw new
|
|
4453
|
+
throw new InvalidArgumentError(
|
|
4809
4454
|
'The parameter "entities" of ReferencesManyResolver.includeTo requires an Array of Object, but %v given.',
|
|
4810
4455
|
entity
|
|
4811
4456
|
);
|
|
@@ -4858,23 +4503,23 @@ var init_relations2 = __esm({
|
|
|
4858
4503
|
});
|
|
4859
4504
|
|
|
4860
4505
|
// src/filter/include-clause-tool.js
|
|
4861
|
-
var _IncludeClauseTool, IncludeClauseTool;
|
|
4506
|
+
var import_js_service24, _IncludeClauseTool, IncludeClauseTool;
|
|
4862
4507
|
var init_include_clause_tool = __esm({
|
|
4863
4508
|
"src/filter/include-clause-tool.js"() {
|
|
4864
4509
|
"use strict";
|
|
4865
|
-
|
|
4510
|
+
import_js_service24 = require("@e22m4u/js-service");
|
|
4866
4511
|
init_definition();
|
|
4867
4512
|
init_relations2();
|
|
4868
4513
|
init_relations2();
|
|
4869
4514
|
init_where_clause_tool();
|
|
4870
4515
|
init_order_clause_tool();
|
|
4871
4516
|
init_slice_clause_tool();
|
|
4872
|
-
|
|
4517
|
+
init_errors();
|
|
4873
4518
|
init_relations2();
|
|
4874
4519
|
init_fields_clause_tool();
|
|
4875
4520
|
init_definition();
|
|
4876
4521
|
init_relations2();
|
|
4877
|
-
_IncludeClauseTool = class _IncludeClauseTool extends Service {
|
|
4522
|
+
_IncludeClauseTool = class _IncludeClauseTool extends import_js_service24.Service {
|
|
4878
4523
|
/**
|
|
4879
4524
|
* Include to.
|
|
4880
4525
|
*
|
|
@@ -5006,7 +4651,7 @@ var init_include_clause_tool = __esm({
|
|
|
5006
4651
|
);
|
|
5007
4652
|
break;
|
|
5008
4653
|
default:
|
|
5009
|
-
throw new
|
|
4654
|
+
throw new InvalidArgumentError(
|
|
5010
4655
|
"The relation type %v does not have an inclusion resolver.",
|
|
5011
4656
|
relDef.type
|
|
5012
4657
|
);
|
|
@@ -5039,14 +4684,14 @@ var init_include_clause_tool = __esm({
|
|
|
5039
4684
|
(name, i) => relNames.indexOf(name) !== i
|
|
5040
4685
|
);
|
|
5041
4686
|
if (duplicateNames.length)
|
|
5042
|
-
throw new
|
|
4687
|
+
throw new InvalidArgumentError(
|
|
5043
4688
|
'The provided option "include" has duplicates of %v.',
|
|
5044
4689
|
duplicateNames[0]
|
|
5045
4690
|
);
|
|
5046
4691
|
} else if (typeof clause === "object") {
|
|
5047
4692
|
if ("relation" in clause) {
|
|
5048
4693
|
if (!clause.relation || typeof clause.relation !== "string")
|
|
5049
|
-
throw new
|
|
4694
|
+
throw new InvalidArgumentError(
|
|
5050
4695
|
'The provided option "relation" should be a non-empty String, but %v given.',
|
|
5051
4696
|
clause.relation
|
|
5052
4697
|
);
|
|
@@ -5059,7 +4704,7 @@ var init_include_clause_tool = __esm({
|
|
|
5059
4704
|
});
|
|
5060
4705
|
}
|
|
5061
4706
|
} else {
|
|
5062
|
-
throw new
|
|
4707
|
+
throw new InvalidArgumentError(
|
|
5063
4708
|
'The provided option "include" should have a non-empty String, an Object or an Array, but %v given.',
|
|
5064
4709
|
clause
|
|
5065
4710
|
);
|
|
@@ -5073,7 +4718,7 @@ var init_include_clause_tool = __esm({
|
|
|
5073
4718
|
static validateScopeClause(clause) {
|
|
5074
4719
|
if (clause == null) return;
|
|
5075
4720
|
if (typeof clause !== "object" || Array.isArray(clause))
|
|
5076
|
-
throw new
|
|
4721
|
+
throw new InvalidArgumentError(
|
|
5077
4722
|
'The provided option "scope" should be an Object, but %v given.',
|
|
5078
4723
|
clause
|
|
5079
4724
|
);
|
|
@@ -5118,14 +4763,14 @@ var init_include_clause_tool = __esm({
|
|
|
5118
4763
|
(name, i) => relNames.indexOf(name) !== i
|
|
5119
4764
|
);
|
|
5120
4765
|
if (duplicateNames.length)
|
|
5121
|
-
throw new
|
|
4766
|
+
throw new InvalidArgumentError(
|
|
5122
4767
|
'The provided option "include" has duplicates of %v.',
|
|
5123
4768
|
duplicateNames[0]
|
|
5124
4769
|
);
|
|
5125
4770
|
} else if (typeof clause === "object") {
|
|
5126
4771
|
if ("relation" in clause) {
|
|
5127
4772
|
if (!clause.relation || typeof clause.relation !== "string")
|
|
5128
|
-
throw new
|
|
4773
|
+
throw new InvalidArgumentError(
|
|
5129
4774
|
'The provided option "relation" should be a non-empty String, but %v given.',
|
|
5130
4775
|
clause.relation
|
|
5131
4776
|
);
|
|
@@ -5144,7 +4789,7 @@ var init_include_clause_tool = __esm({
|
|
|
5144
4789
|
});
|
|
5145
4790
|
}
|
|
5146
4791
|
} else {
|
|
5147
|
-
throw new
|
|
4792
|
+
throw new InvalidArgumentError(
|
|
5148
4793
|
'The provided option "include" should have a non-empty String, an Object or an Array, but %v given.',
|
|
5149
4794
|
clause
|
|
5150
4795
|
);
|
|
@@ -5160,7 +4805,7 @@ var init_include_clause_tool = __esm({
|
|
|
5160
4805
|
static normalizeScopeClause(clause) {
|
|
5161
4806
|
if (clause == null) return;
|
|
5162
4807
|
if (typeof clause !== "object" || Array.isArray(clause))
|
|
5163
|
-
throw new
|
|
4808
|
+
throw new InvalidArgumentError(
|
|
5164
4809
|
'The provided option "scope" should be an Object, but %v given.',
|
|
5165
4810
|
clause
|
|
5166
4811
|
);
|
|
@@ -5211,15 +4856,15 @@ var init_filter = __esm({
|
|
|
5211
4856
|
});
|
|
5212
4857
|
|
|
5213
4858
|
// src/adapter/decorator/inclusion-decorator.js
|
|
5214
|
-
var _InclusionDecorator, InclusionDecorator;
|
|
4859
|
+
var import_js_service25, _InclusionDecorator, InclusionDecorator;
|
|
5215
4860
|
var init_inclusion_decorator = __esm({
|
|
5216
4861
|
"src/adapter/decorator/inclusion-decorator.js"() {
|
|
5217
4862
|
"use strict";
|
|
5218
4863
|
init_adapter();
|
|
5219
|
-
|
|
4864
|
+
import_js_service25 = require("@e22m4u/js-service");
|
|
5220
4865
|
init_filter();
|
|
5221
|
-
|
|
5222
|
-
_InclusionDecorator = class _InclusionDecorator extends Service {
|
|
4866
|
+
init_errors();
|
|
4867
|
+
_InclusionDecorator = class _InclusionDecorator extends import_js_service25.Service {
|
|
5223
4868
|
/**
|
|
5224
4869
|
* Decorate.
|
|
5225
4870
|
*
|
|
@@ -5227,7 +4872,7 @@ var init_inclusion_decorator = __esm({
|
|
|
5227
4872
|
*/
|
|
5228
4873
|
decorate(adapter) {
|
|
5229
4874
|
if (!adapter || !(adapter instanceof Adapter))
|
|
5230
|
-
throw new
|
|
4875
|
+
throw new InvalidArgumentError(
|
|
5231
4876
|
"The first argument of InclusionDecorator.decorate should be an Adapter instance, but %v given.",
|
|
5232
4877
|
adapter
|
|
5233
4878
|
);
|
|
@@ -5300,15 +4945,15 @@ var init_inclusion_decorator = __esm({
|
|
|
5300
4945
|
});
|
|
5301
4946
|
|
|
5302
4947
|
// src/adapter/decorator/default-values-decorator.js
|
|
5303
|
-
var _DefaultValuesDecorator, DefaultValuesDecorator;
|
|
4948
|
+
var import_js_service26, _DefaultValuesDecorator, DefaultValuesDecorator;
|
|
5304
4949
|
var init_default_values_decorator = __esm({
|
|
5305
4950
|
"src/adapter/decorator/default-values-decorator.js"() {
|
|
5306
4951
|
"use strict";
|
|
5307
4952
|
init_adapter();
|
|
5308
|
-
|
|
5309
|
-
|
|
4953
|
+
import_js_service26 = require("@e22m4u/js-service");
|
|
4954
|
+
init_errors();
|
|
5310
4955
|
init_definition();
|
|
5311
|
-
_DefaultValuesDecorator = class _DefaultValuesDecorator extends Service {
|
|
4956
|
+
_DefaultValuesDecorator = class _DefaultValuesDecorator extends import_js_service26.Service {
|
|
5312
4957
|
/**
|
|
5313
4958
|
* Decorate.
|
|
5314
4959
|
*
|
|
@@ -5316,7 +4961,7 @@ var init_default_values_decorator = __esm({
|
|
|
5316
4961
|
*/
|
|
5317
4962
|
decorate(adapter) {
|
|
5318
4963
|
if (!adapter || !(adapter instanceof Adapter))
|
|
5319
|
-
throw new
|
|
4964
|
+
throw new InvalidArgumentError(
|
|
5320
4965
|
"The first argument of DefaultValuesDecorator.decorate should be an Adapter instance, but %v given.",
|
|
5321
4966
|
adapter
|
|
5322
4967
|
);
|
|
@@ -5365,15 +5010,15 @@ var init_default_values_decorator = __esm({
|
|
|
5365
5010
|
});
|
|
5366
5011
|
|
|
5367
5012
|
// src/adapter/decorator/data-sanitizing-decorator.js
|
|
5368
|
-
var _DataSanitizingDecorator, DataSanitizingDecorator;
|
|
5013
|
+
var import_js_service27, _DataSanitizingDecorator, DataSanitizingDecorator;
|
|
5369
5014
|
var init_data_sanitizing_decorator = __esm({
|
|
5370
5015
|
"src/adapter/decorator/data-sanitizing-decorator.js"() {
|
|
5371
5016
|
"use strict";
|
|
5372
5017
|
init_adapter();
|
|
5373
|
-
|
|
5374
|
-
|
|
5018
|
+
import_js_service27 = require("@e22m4u/js-service");
|
|
5019
|
+
init_errors();
|
|
5375
5020
|
init_definition();
|
|
5376
|
-
_DataSanitizingDecorator = class _DataSanitizingDecorator extends Service {
|
|
5021
|
+
_DataSanitizingDecorator = class _DataSanitizingDecorator extends import_js_service27.Service {
|
|
5377
5022
|
/**
|
|
5378
5023
|
* Decorate.
|
|
5379
5024
|
*
|
|
@@ -5381,7 +5026,7 @@ var init_data_sanitizing_decorator = __esm({
|
|
|
5381
5026
|
*/
|
|
5382
5027
|
decorate(adapter) {
|
|
5383
5028
|
if (!adapter || !(adapter instanceof Adapter))
|
|
5384
|
-
throw new
|
|
5029
|
+
throw new InvalidArgumentError(
|
|
5385
5030
|
"The first argument of DataSanitizingDecorator.decorate should be an Adapter instance, but %v given.",
|
|
5386
5031
|
adapter
|
|
5387
5032
|
);
|
|
@@ -5420,15 +5065,15 @@ var init_data_sanitizing_decorator = __esm({
|
|
|
5420
5065
|
});
|
|
5421
5066
|
|
|
5422
5067
|
// src/adapter/decorator/data-validation-decorator.js
|
|
5423
|
-
var _DataValidationDecorator, DataValidationDecorator;
|
|
5068
|
+
var import_js_service28, _DataValidationDecorator, DataValidationDecorator;
|
|
5424
5069
|
var init_data_validation_decorator = __esm({
|
|
5425
5070
|
"src/adapter/decorator/data-validation-decorator.js"() {
|
|
5426
5071
|
"use strict";
|
|
5427
5072
|
init_adapter();
|
|
5428
|
-
|
|
5429
|
-
|
|
5073
|
+
import_js_service28 = require("@e22m4u/js-service");
|
|
5074
|
+
init_errors();
|
|
5430
5075
|
init_definition();
|
|
5431
|
-
_DataValidationDecorator = class _DataValidationDecorator extends Service {
|
|
5076
|
+
_DataValidationDecorator = class _DataValidationDecorator extends import_js_service28.Service {
|
|
5432
5077
|
/**
|
|
5433
5078
|
* Decorate.
|
|
5434
5079
|
*
|
|
@@ -5436,7 +5081,7 @@ var init_data_validation_decorator = __esm({
|
|
|
5436
5081
|
*/
|
|
5437
5082
|
decorate(adapter) {
|
|
5438
5083
|
if (!adapter || !(adapter instanceof Adapter))
|
|
5439
|
-
throw new
|
|
5084
|
+
throw new InvalidArgumentError(
|
|
5440
5085
|
"The first argument of DataValidationDecorator.decorate should be an Adapter instance, but %v given.",
|
|
5441
5086
|
adapter
|
|
5442
5087
|
);
|
|
@@ -5474,15 +5119,15 @@ var init_data_validation_decorator = __esm({
|
|
|
5474
5119
|
});
|
|
5475
5120
|
|
|
5476
5121
|
// src/adapter/decorator/fields-filtering-decorator.js
|
|
5477
|
-
var _FieldsFilteringDecorator, FieldsFilteringDecorator;
|
|
5122
|
+
var import_js_service29, _FieldsFilteringDecorator, FieldsFilteringDecorator;
|
|
5478
5123
|
var init_fields_filtering_decorator = __esm({
|
|
5479
5124
|
"src/adapter/decorator/fields-filtering-decorator.js"() {
|
|
5480
5125
|
"use strict";
|
|
5481
5126
|
init_adapter();
|
|
5482
|
-
|
|
5127
|
+
import_js_service29 = require("@e22m4u/js-service");
|
|
5483
5128
|
init_filter();
|
|
5484
|
-
|
|
5485
|
-
_FieldsFilteringDecorator = class _FieldsFilteringDecorator extends Service {
|
|
5129
|
+
init_errors();
|
|
5130
|
+
_FieldsFilteringDecorator = class _FieldsFilteringDecorator extends import_js_service29.Service {
|
|
5486
5131
|
/**
|
|
5487
5132
|
* Decorate.
|
|
5488
5133
|
*
|
|
@@ -5490,7 +5135,7 @@ var init_fields_filtering_decorator = __esm({
|
|
|
5490
5135
|
*/
|
|
5491
5136
|
decorate(adapter) {
|
|
5492
5137
|
if (!adapter || !(adapter instanceof Adapter))
|
|
5493
|
-
throw new
|
|
5138
|
+
throw new InvalidArgumentError(
|
|
5494
5139
|
"The first argument of FieldsFilteringDecorator.decorate should be an Adapter instance, but %v given.",
|
|
5495
5140
|
adapter
|
|
5496
5141
|
);
|
|
@@ -5557,15 +5202,15 @@ var init_fields_filtering_decorator = __esm({
|
|
|
5557
5202
|
});
|
|
5558
5203
|
|
|
5559
5204
|
// src/adapter/decorator/data-transformation-decorator.js
|
|
5560
|
-
var _DataTransformationDecorator, DataTransformationDecorator;
|
|
5205
|
+
var import_js_service30, _DataTransformationDecorator, DataTransformationDecorator;
|
|
5561
5206
|
var init_data_transformation_decorator = __esm({
|
|
5562
5207
|
"src/adapter/decorator/data-transformation-decorator.js"() {
|
|
5563
5208
|
"use strict";
|
|
5564
5209
|
init_adapter();
|
|
5565
|
-
|
|
5566
|
-
|
|
5210
|
+
import_js_service30 = require("@e22m4u/js-service");
|
|
5211
|
+
init_errors();
|
|
5567
5212
|
init_definition();
|
|
5568
|
-
_DataTransformationDecorator = class _DataTransformationDecorator extends Service {
|
|
5213
|
+
_DataTransformationDecorator = class _DataTransformationDecorator extends import_js_service30.Service {
|
|
5569
5214
|
/**
|
|
5570
5215
|
* Decorate.
|
|
5571
5216
|
*
|
|
@@ -5573,7 +5218,7 @@ var init_data_transformation_decorator = __esm({
|
|
|
5573
5218
|
*/
|
|
5574
5219
|
decorate(adapter) {
|
|
5575
5220
|
if (!adapter || !(adapter instanceof Adapter))
|
|
5576
|
-
throw new
|
|
5221
|
+
throw new InvalidArgumentError(
|
|
5577
5222
|
"The first argument of DataTransformerDecorator.decorate should be an Adapter instance, but %v given.",
|
|
5578
5223
|
adapter
|
|
5579
5224
|
);
|
|
@@ -5611,15 +5256,15 @@ var init_data_transformation_decorator = __esm({
|
|
|
5611
5256
|
});
|
|
5612
5257
|
|
|
5613
5258
|
// src/adapter/decorator/property-uniqueness-decorator.js
|
|
5614
|
-
var _PropertyUniquenessDecorator, PropertyUniquenessDecorator;
|
|
5259
|
+
var import_js_service31, _PropertyUniquenessDecorator, PropertyUniquenessDecorator;
|
|
5615
5260
|
var init_property_uniqueness_decorator = __esm({
|
|
5616
5261
|
"src/adapter/decorator/property-uniqueness-decorator.js"() {
|
|
5617
5262
|
"use strict";
|
|
5618
5263
|
init_adapter();
|
|
5619
|
-
|
|
5620
|
-
|
|
5264
|
+
import_js_service31 = require("@e22m4u/js-service");
|
|
5265
|
+
init_errors();
|
|
5621
5266
|
init_definition();
|
|
5622
|
-
_PropertyUniquenessDecorator = class _PropertyUniquenessDecorator extends Service {
|
|
5267
|
+
_PropertyUniquenessDecorator = class _PropertyUniquenessDecorator extends import_js_service31.Service {
|
|
5623
5268
|
/**
|
|
5624
5269
|
* Decorate.
|
|
5625
5270
|
*
|
|
@@ -5627,7 +5272,7 @@ var init_property_uniqueness_decorator = __esm({
|
|
|
5627
5272
|
*/
|
|
5628
5273
|
decorate(adapter) {
|
|
5629
5274
|
if (!adapter || !(adapter instanceof Adapter))
|
|
5630
|
-
throw new
|
|
5275
|
+
throw new InvalidArgumentError(
|
|
5631
5276
|
"The first argument of PropertyUniquenessDecorator.decorate should be an Adapter instance, but %v given.",
|
|
5632
5277
|
adapter
|
|
5633
5278
|
);
|
|
@@ -5701,12 +5346,12 @@ var init_decorator = __esm({
|
|
|
5701
5346
|
});
|
|
5702
5347
|
|
|
5703
5348
|
// src/adapter/adapter.js
|
|
5704
|
-
var _Adapter, Adapter;
|
|
5349
|
+
var import_js_service32, ADAPTER_CLASS_NAME, _Adapter, Adapter;
|
|
5705
5350
|
var init_adapter = __esm({
|
|
5706
5351
|
"src/adapter/adapter.js"() {
|
|
5707
5352
|
"use strict";
|
|
5708
|
-
|
|
5709
|
-
|
|
5353
|
+
import_js_service32 = require("@e22m4u/js-service");
|
|
5354
|
+
init_errors();
|
|
5710
5355
|
init_decorator();
|
|
5711
5356
|
init_decorator();
|
|
5712
5357
|
init_decorator();
|
|
@@ -5714,7 +5359,8 @@ var init_adapter = __esm({
|
|
|
5714
5359
|
init_decorator();
|
|
5715
5360
|
init_decorator();
|
|
5716
5361
|
init_decorator();
|
|
5717
|
-
|
|
5362
|
+
ADAPTER_CLASS_NAME = "Adapter";
|
|
5363
|
+
_Adapter = class _Adapter extends import_js_service32.Service {
|
|
5718
5364
|
/**
|
|
5719
5365
|
* Settings.
|
|
5720
5366
|
*
|
|
@@ -5906,7 +5552,7 @@ var init_adapter = __esm({
|
|
|
5906
5552
|
*
|
|
5907
5553
|
* @type {string}
|
|
5908
5554
|
*/
|
|
5909
|
-
__publicField(_Adapter, "
|
|
5555
|
+
__publicField(_Adapter, "kinds", [...import_js_service32.Service.kinds, ADAPTER_CLASS_NAME]);
|
|
5910
5556
|
Adapter = _Adapter;
|
|
5911
5557
|
}
|
|
5912
5558
|
});
|
|
@@ -5921,13 +5567,13 @@ var init_memory_adapter = __esm({
|
|
|
5921
5567
|
"src/adapter/builtin/memory-adapter.js"() {
|
|
5922
5568
|
"use strict";
|
|
5923
5569
|
init_adapter();
|
|
5924
|
-
|
|
5925
|
-
|
|
5570
|
+
init_utils();
|
|
5571
|
+
init_utils();
|
|
5926
5572
|
init_definition();
|
|
5927
5573
|
init_filter();
|
|
5928
5574
|
init_filter();
|
|
5929
5575
|
init_filter();
|
|
5930
|
-
|
|
5576
|
+
init_errors();
|
|
5931
5577
|
init_definition();
|
|
5932
5578
|
_MemoryAdapter = class _MemoryAdapter extends Adapter {
|
|
5933
5579
|
/**
|
|
@@ -5969,7 +5615,7 @@ var init_memory_adapter = __esm({
|
|
|
5969
5615
|
ModelDefinitionUtils
|
|
5970
5616
|
).getDataTypeByPropertyName(modelName, propName);
|
|
5971
5617
|
if (propType !== DataType.ANY && propType !== DataType.NUMBER)
|
|
5972
|
-
throw new
|
|
5618
|
+
throw new InvalidArgumentError(
|
|
5973
5619
|
"The memory adapter able to generate only Number identifiers, but the primary key %v of the model %v is defined as %s. Do provide your own value for the %v property, or change the type in the primary key definition to a Number that will be generated automatically.",
|
|
5974
5620
|
propName,
|
|
5975
5621
|
modelName,
|
|
@@ -6005,7 +5651,7 @@ var init_memory_adapter = __esm({
|
|
|
6005
5651
|
}
|
|
6006
5652
|
const table = this._getTableOrCreate(modelName);
|
|
6007
5653
|
if (table.has(idValue))
|
|
6008
|
-
throw new
|
|
5654
|
+
throw new InvalidArgumentError(
|
|
6009
5655
|
"The value %v of the primary key %v already exists in the model %v.",
|
|
6010
5656
|
idValue,
|
|
6011
5657
|
pkPropName,
|
|
@@ -6038,7 +5684,7 @@ var init_memory_adapter = __esm({
|
|
|
6038
5684
|
modelName
|
|
6039
5685
|
);
|
|
6040
5686
|
if (!isExists)
|
|
6041
|
-
throw new
|
|
5687
|
+
throw new InvalidArgumentError(
|
|
6042
5688
|
"The value %v of the primary key %v does not exist in the model %v.",
|
|
6043
5689
|
id,
|
|
6044
5690
|
pkPropName,
|
|
@@ -6135,7 +5781,7 @@ var init_memory_adapter = __esm({
|
|
|
6135
5781
|
modelName
|
|
6136
5782
|
);
|
|
6137
5783
|
if (existingTableData == null)
|
|
6138
|
-
throw new
|
|
5784
|
+
throw new InvalidArgumentError(
|
|
6139
5785
|
"The value %v of the primary key %v does not exist in the model %v.",
|
|
6140
5786
|
id,
|
|
6141
5787
|
pkPropName,
|
|
@@ -6204,7 +5850,7 @@ var init_memory_adapter = __esm({
|
|
|
6204
5850
|
modelName
|
|
6205
5851
|
);
|
|
6206
5852
|
if (!tableData)
|
|
6207
|
-
throw new
|
|
5853
|
+
throw new InvalidArgumentError(
|
|
6208
5854
|
"The value %v of the primary key %v does not exist in the model %v.",
|
|
6209
5855
|
id,
|
|
6210
5856
|
pkPropName,
|
|
@@ -6308,23 +5954,23 @@ function findAdapterCtorInModule(module2) {
|
|
|
6308
5954
|
let adapterCtor;
|
|
6309
5955
|
if (!module2 || typeof module2 !== "object" || Array.isArray(module2)) return;
|
|
6310
5956
|
for (const ctor of Object.values(module2)) {
|
|
6311
|
-
|
|
6312
|
-
if (typeof ctor === "function" && ctor.kind === Adapter.name) {
|
|
5957
|
+
if (typeof ctor === "function" && Array.isArray(ctor.kinds) && Adapter.kinds.includes(ADAPTER_CLASS_NAME)) {
|
|
6313
5958
|
adapterCtor = ctor;
|
|
6314
5959
|
break;
|
|
6315
5960
|
}
|
|
6316
5961
|
}
|
|
6317
5962
|
return adapterCtor;
|
|
6318
5963
|
}
|
|
6319
|
-
var _AdapterLoader, AdapterLoader;
|
|
5964
|
+
var import_js_service33, _AdapterLoader, AdapterLoader;
|
|
6320
5965
|
var init_adapter_loader = __esm({
|
|
6321
5966
|
"src/adapter/adapter-loader.js"() {
|
|
6322
5967
|
"use strict";
|
|
6323
5968
|
init_adapter();
|
|
6324
|
-
|
|
6325
|
-
|
|
5969
|
+
import_js_service33 = require("@e22m4u/js-service");
|
|
5970
|
+
init_adapter();
|
|
5971
|
+
init_errors();
|
|
6326
5972
|
init_();
|
|
6327
|
-
_AdapterLoader = class _AdapterLoader extends Service {
|
|
5973
|
+
_AdapterLoader = class _AdapterLoader extends import_js_service33.Service {
|
|
6328
5974
|
/**
|
|
6329
5975
|
* Load by name.
|
|
6330
5976
|
*
|
|
@@ -6334,7 +5980,7 @@ var init_adapter_loader = __esm({
|
|
|
6334
5980
|
*/
|
|
6335
5981
|
async loadByName(adapterName, settings = void 0) {
|
|
6336
5982
|
if (!adapterName || typeof adapterName !== "string")
|
|
6337
|
-
throw new
|
|
5983
|
+
throw new InvalidArgumentError(
|
|
6338
5984
|
"The adapter name should be a non-empty String, but %v given.",
|
|
6339
5985
|
adapterName
|
|
6340
5986
|
);
|
|
@@ -6351,7 +5997,7 @@ var init_adapter_loader = __esm({
|
|
|
6351
5997
|
} catch (e) {
|
|
6352
5998
|
}
|
|
6353
5999
|
if (!adapterCtor)
|
|
6354
|
-
throw new
|
|
6000
|
+
throw new InvalidArgumentError(
|
|
6355
6001
|
"The adapter %v is not found.",
|
|
6356
6002
|
adapterName
|
|
6357
6003
|
);
|
|
@@ -6365,15 +6011,15 @@ var init_adapter_loader = __esm({
|
|
|
6365
6011
|
});
|
|
6366
6012
|
|
|
6367
6013
|
// src/adapter/adapter-registry.js
|
|
6368
|
-
var _AdapterRegistry, AdapterRegistry;
|
|
6014
|
+
var import_js_service34, _AdapterRegistry, AdapterRegistry;
|
|
6369
6015
|
var init_adapter_registry = __esm({
|
|
6370
6016
|
"src/adapter/adapter-registry.js"() {
|
|
6371
6017
|
"use strict";
|
|
6372
6018
|
init_adapter();
|
|
6373
|
-
|
|
6019
|
+
import_js_service34 = require("@e22m4u/js-service");
|
|
6374
6020
|
init_adapter_loader();
|
|
6375
6021
|
init_definition();
|
|
6376
|
-
_AdapterRegistry = class _AdapterRegistry extends Service {
|
|
6022
|
+
_AdapterRegistry = class _AdapterRegistry extends import_js_service34.Service {
|
|
6377
6023
|
/**
|
|
6378
6024
|
* Adapters.
|
|
6379
6025
|
*
|
|
@@ -6415,16 +6061,16 @@ var init_adapter2 = __esm({
|
|
|
6415
6061
|
});
|
|
6416
6062
|
|
|
6417
6063
|
// src/repository/repository.js
|
|
6418
|
-
var _Repository, Repository;
|
|
6064
|
+
var import_js_service35, _Repository, Repository;
|
|
6419
6065
|
var init_repository = __esm({
|
|
6420
6066
|
"src/repository/repository.js"() {
|
|
6421
6067
|
"use strict";
|
|
6422
|
-
|
|
6068
|
+
import_js_service35 = require("@e22m4u/js-service");
|
|
6423
6069
|
init_adapter2();
|
|
6424
6070
|
init_adapter2();
|
|
6425
|
-
|
|
6071
|
+
init_errors();
|
|
6426
6072
|
init_definition();
|
|
6427
|
-
_Repository = class _Repository extends Service {
|
|
6073
|
+
_Repository = class _Repository extends import_js_service35.Service {
|
|
6428
6074
|
/**
|
|
6429
6075
|
* Model name.
|
|
6430
6076
|
*
|
|
@@ -6466,7 +6112,7 @@ var init_repository = __esm({
|
|
|
6466
6112
|
const modelDef = this.getService(DefinitionRegistry).getModel(modelName);
|
|
6467
6113
|
const datasourceName = modelDef.datasource;
|
|
6468
6114
|
if (!datasourceName)
|
|
6469
|
-
throw new
|
|
6115
|
+
throw new InvalidArgumentError(
|
|
6470
6116
|
"The model %v does not have a specified datasource.",
|
|
6471
6117
|
modelName
|
|
6472
6118
|
);
|
|
@@ -6618,14 +6264,14 @@ var init_repository = __esm({
|
|
|
6618
6264
|
});
|
|
6619
6265
|
|
|
6620
6266
|
// src/repository/repository-registry.js
|
|
6621
|
-
var _RepositoryRegistry, RepositoryRegistry;
|
|
6267
|
+
var import_js_service36, _RepositoryRegistry, RepositoryRegistry;
|
|
6622
6268
|
var init_repository_registry = __esm({
|
|
6623
6269
|
"src/repository/repository-registry.js"() {
|
|
6624
6270
|
"use strict";
|
|
6625
|
-
|
|
6271
|
+
import_js_service36 = require("@e22m4u/js-service");
|
|
6626
6272
|
init_repository();
|
|
6627
|
-
|
|
6628
|
-
_RepositoryRegistry = class _RepositoryRegistry extends Service {
|
|
6273
|
+
init_errors();
|
|
6274
|
+
_RepositoryRegistry = class _RepositoryRegistry extends import_js_service36.Service {
|
|
6629
6275
|
/**
|
|
6630
6276
|
* Repositories.
|
|
6631
6277
|
*
|
|
@@ -6646,7 +6292,7 @@ var init_repository_registry = __esm({
|
|
|
6646
6292
|
*/
|
|
6647
6293
|
setRepositoryCtor(ctor) {
|
|
6648
6294
|
if (!ctor || typeof ctor !== "function" || !(ctor.prototype instanceof Repository)) {
|
|
6649
|
-
throw new
|
|
6295
|
+
throw new InvalidArgumentError(
|
|
6650
6296
|
"The first argument of RepositoryRegistry.setRepositoryCtor must inherit from Repository class, but %v given.",
|
|
6651
6297
|
ctor
|
|
6652
6298
|
);
|
|
@@ -6684,6 +6330,7 @@ var init_repository2 = __esm({
|
|
|
6684
6330
|
// src/index.js
|
|
6685
6331
|
var src_exports = {};
|
|
6686
6332
|
__export(src_exports, {
|
|
6333
|
+
ADAPTER_CLASS_NAME: () => ADAPTER_CLASS_NAME,
|
|
6687
6334
|
Adapter: () => Adapter,
|
|
6688
6335
|
AdapterLoader: () => AdapterLoader,
|
|
6689
6336
|
AdapterRegistry: () => AdapterRegistry,
|
|
@@ -6698,7 +6345,7 @@ __export(src_exports, {
|
|
|
6698
6345
|
HasManyResolver: () => HasManyResolver,
|
|
6699
6346
|
HasOneResolver: () => HasOneResolver,
|
|
6700
6347
|
IncludeClauseTool: () => IncludeClauseTool,
|
|
6701
|
-
InvalidArgumentError: () =>
|
|
6348
|
+
InvalidArgumentError: () => InvalidArgumentError,
|
|
6702
6349
|
InvalidOperatorValueError: () => InvalidOperatorValueError,
|
|
6703
6350
|
ModelDataSanitizer: () => ModelDataSanitizer,
|
|
6704
6351
|
ModelDataTransformer: () => ModelDataTransformer,
|
|
@@ -6740,11 +6387,11 @@ __export(src_exports, {
|
|
|
6740
6387
|
module.exports = __toCommonJS(src_exports);
|
|
6741
6388
|
|
|
6742
6389
|
// src/schema.js
|
|
6743
|
-
|
|
6390
|
+
var import_js_service37 = require("@e22m4u/js-service");
|
|
6744
6391
|
init_repository2();
|
|
6745
6392
|
init_definition();
|
|
6746
6393
|
init_repository2();
|
|
6747
|
-
var _Schema = class _Schema extends Service {
|
|
6394
|
+
var _Schema = class _Schema extends import_js_service37.Service {
|
|
6748
6395
|
/**
|
|
6749
6396
|
* Define datasource.
|
|
6750
6397
|
*
|
|
@@ -6779,8 +6426,8 @@ __name(_Schema, "Schema");
|
|
|
6779
6426
|
var Schema = _Schema;
|
|
6780
6427
|
|
|
6781
6428
|
// src/index.js
|
|
6782
|
-
|
|
6783
|
-
|
|
6429
|
+
init_utils();
|
|
6430
|
+
init_errors();
|
|
6784
6431
|
init_filter();
|
|
6785
6432
|
init_adapter2();
|
|
6786
6433
|
init_relations2();
|
|
@@ -6788,6 +6435,7 @@ init_definition();
|
|
|
6788
6435
|
init_repository2();
|
|
6789
6436
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6790
6437
|
0 && (module.exports = {
|
|
6438
|
+
ADAPTER_CLASS_NAME,
|
|
6791
6439
|
Adapter,
|
|
6792
6440
|
AdapterLoader,
|
|
6793
6441
|
AdapterRegistry,
|