av6-core 1.5.14 → 1.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -68
- package/dist/index.mjs +0 -68
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -375,73 +375,6 @@ function smartAndMerge(a, b) {
|
|
|
375
375
|
if (merged !== void 0) return merged;
|
|
376
376
|
return andWrap(a, b);
|
|
377
377
|
}
|
|
378
|
-
var SCALAR_OPS = /* @__PURE__ */ new Set([
|
|
379
|
-
"equals",
|
|
380
|
-
"in",
|
|
381
|
-
"notIn",
|
|
382
|
-
"lt",
|
|
383
|
-
"lte",
|
|
384
|
-
"gt",
|
|
385
|
-
"gte",
|
|
386
|
-
"contains",
|
|
387
|
-
"startsWith",
|
|
388
|
-
"endsWith",
|
|
389
|
-
"mode",
|
|
390
|
-
"search",
|
|
391
|
-
"not"
|
|
392
|
-
]);
|
|
393
|
-
var RELATION_OPS = /* @__PURE__ */ new Set(["some", "every", "none", "is", "isNot"]);
|
|
394
|
-
function isScalarFilterObject(obj) {
|
|
395
|
-
if (!isPlainObject(obj)) return false;
|
|
396
|
-
return Object.keys(obj).some((k) => SCALAR_OPS.has(k));
|
|
397
|
-
}
|
|
398
|
-
function isRelationFilterObject(obj) {
|
|
399
|
-
if (!isPlainObject(obj)) return false;
|
|
400
|
-
return Object.keys(obj).some((k) => RELATION_OPS.has(k));
|
|
401
|
-
}
|
|
402
|
-
function normalizeWhere(where) {
|
|
403
|
-
if (Array.isArray(where)) return where.map(normalizeWhere);
|
|
404
|
-
if (!isPlainObject(where)) return where;
|
|
405
|
-
for (const k of Object.keys(where)) {
|
|
406
|
-
where[k] = normalizeWhere(where[k]);
|
|
407
|
-
}
|
|
408
|
-
if (Array.isArray(where.OR) && where.OR.length > 0) {
|
|
409
|
-
const orItems = where.OR;
|
|
410
|
-
const keysArr = orItems.map((it) => isPlainObject(it) ? Object.keys(it) : []);
|
|
411
|
-
const allSingleKey = keysArr.every((ks) => ks.length === 1);
|
|
412
|
-
if (allSingleKey) {
|
|
413
|
-
const commonKey = keysArr[0][0];
|
|
414
|
-
const allSameKey = keysArr.every((ks) => ks[0] === commonKey);
|
|
415
|
-
const isLogicalKey = commonKey === "AND" || commonKey === "OR" || commonKey === "NOT";
|
|
416
|
-
if (allSameKey && !isLogicalKey) {
|
|
417
|
-
const innerList = orItems.map((it) => it[commonKey]).filter((v) => isPlainObject(v));
|
|
418
|
-
const anyScalar = innerList.some(isScalarFilterObject);
|
|
419
|
-
if (!anyScalar) {
|
|
420
|
-
const shouldFold = innerList.some(isRelationFilterObject) || innerList.some(
|
|
421
|
-
(o) => Object.keys(o).some((k) => !SCALAR_OPS.has(k) && k !== "AND" && k !== "OR" && k !== "NOT")
|
|
422
|
-
);
|
|
423
|
-
if (shouldFold) {
|
|
424
|
-
const foldedRel = { OR: innerList };
|
|
425
|
-
if (isPlainObject(where[commonKey])) {
|
|
426
|
-
if (Array.isArray(where[commonKey].OR)) {
|
|
427
|
-
where[commonKey].OR = [...where[commonKey].OR, ...innerList];
|
|
428
|
-
} else {
|
|
429
|
-
where[commonKey] = { ...where[commonKey], ...foldedRel };
|
|
430
|
-
}
|
|
431
|
-
} else {
|
|
432
|
-
where[commonKey] = foldedRel;
|
|
433
|
-
}
|
|
434
|
-
delete where.OR;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
if (Array.isArray(where.AND)) {
|
|
441
|
-
where.AND = where.AND.map(normalizeWhere);
|
|
442
|
-
}
|
|
443
|
-
return where;
|
|
444
|
-
}
|
|
445
378
|
|
|
446
379
|
// src/repository/common.repository.ts
|
|
447
380
|
var import_util2 = require("util");
|
|
@@ -769,7 +702,6 @@ var commonRepository = (serviceDeps) => {
|
|
|
769
702
|
if (searchOR?.length) {
|
|
770
703
|
whereClause = smartAndMerge(whereClause, { OR: searchOR });
|
|
771
704
|
}
|
|
772
|
-
whereClause = normalizeWhere(whereClause);
|
|
773
705
|
const orderByClause = {};
|
|
774
706
|
if (sortBy && sortDir) {
|
|
775
707
|
orderByClause[sortBy] = sortDir.toLowerCase();
|
package/dist/index.mjs
CHANGED
|
@@ -325,73 +325,6 @@ function smartAndMerge(a, b) {
|
|
|
325
325
|
if (merged !== void 0) return merged;
|
|
326
326
|
return andWrap(a, b);
|
|
327
327
|
}
|
|
328
|
-
var SCALAR_OPS = /* @__PURE__ */ new Set([
|
|
329
|
-
"equals",
|
|
330
|
-
"in",
|
|
331
|
-
"notIn",
|
|
332
|
-
"lt",
|
|
333
|
-
"lte",
|
|
334
|
-
"gt",
|
|
335
|
-
"gte",
|
|
336
|
-
"contains",
|
|
337
|
-
"startsWith",
|
|
338
|
-
"endsWith",
|
|
339
|
-
"mode",
|
|
340
|
-
"search",
|
|
341
|
-
"not"
|
|
342
|
-
]);
|
|
343
|
-
var RELATION_OPS = /* @__PURE__ */ new Set(["some", "every", "none", "is", "isNot"]);
|
|
344
|
-
function isScalarFilterObject(obj) {
|
|
345
|
-
if (!isPlainObject(obj)) return false;
|
|
346
|
-
return Object.keys(obj).some((k) => SCALAR_OPS.has(k));
|
|
347
|
-
}
|
|
348
|
-
function isRelationFilterObject(obj) {
|
|
349
|
-
if (!isPlainObject(obj)) return false;
|
|
350
|
-
return Object.keys(obj).some((k) => RELATION_OPS.has(k));
|
|
351
|
-
}
|
|
352
|
-
function normalizeWhere(where) {
|
|
353
|
-
if (Array.isArray(where)) return where.map(normalizeWhere);
|
|
354
|
-
if (!isPlainObject(where)) return where;
|
|
355
|
-
for (const k of Object.keys(where)) {
|
|
356
|
-
where[k] = normalizeWhere(where[k]);
|
|
357
|
-
}
|
|
358
|
-
if (Array.isArray(where.OR) && where.OR.length > 0) {
|
|
359
|
-
const orItems = where.OR;
|
|
360
|
-
const keysArr = orItems.map((it) => isPlainObject(it) ? Object.keys(it) : []);
|
|
361
|
-
const allSingleKey = keysArr.every((ks) => ks.length === 1);
|
|
362
|
-
if (allSingleKey) {
|
|
363
|
-
const commonKey = keysArr[0][0];
|
|
364
|
-
const allSameKey = keysArr.every((ks) => ks[0] === commonKey);
|
|
365
|
-
const isLogicalKey = commonKey === "AND" || commonKey === "OR" || commonKey === "NOT";
|
|
366
|
-
if (allSameKey && !isLogicalKey) {
|
|
367
|
-
const innerList = orItems.map((it) => it[commonKey]).filter((v) => isPlainObject(v));
|
|
368
|
-
const anyScalar = innerList.some(isScalarFilterObject);
|
|
369
|
-
if (!anyScalar) {
|
|
370
|
-
const shouldFold = innerList.some(isRelationFilterObject) || innerList.some(
|
|
371
|
-
(o) => Object.keys(o).some((k) => !SCALAR_OPS.has(k) && k !== "AND" && k !== "OR" && k !== "NOT")
|
|
372
|
-
);
|
|
373
|
-
if (shouldFold) {
|
|
374
|
-
const foldedRel = { OR: innerList };
|
|
375
|
-
if (isPlainObject(where[commonKey])) {
|
|
376
|
-
if (Array.isArray(where[commonKey].OR)) {
|
|
377
|
-
where[commonKey].OR = [...where[commonKey].OR, ...innerList];
|
|
378
|
-
} else {
|
|
379
|
-
where[commonKey] = { ...where[commonKey], ...foldedRel };
|
|
380
|
-
}
|
|
381
|
-
} else {
|
|
382
|
-
where[commonKey] = foldedRel;
|
|
383
|
-
}
|
|
384
|
-
delete where.OR;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
if (Array.isArray(where.AND)) {
|
|
391
|
-
where.AND = where.AND.map(normalizeWhere);
|
|
392
|
-
}
|
|
393
|
-
return where;
|
|
394
|
-
}
|
|
395
328
|
|
|
396
329
|
// src/repository/common.repository.ts
|
|
397
330
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
|
|
@@ -719,7 +652,6 @@ var commonRepository = (serviceDeps) => {
|
|
|
719
652
|
if (searchOR?.length) {
|
|
720
653
|
whereClause = smartAndMerge(whereClause, { OR: searchOR });
|
|
721
654
|
}
|
|
722
|
-
whereClause = normalizeWhere(whereClause);
|
|
723
655
|
const orderByClause = {};
|
|
724
656
|
if (sortBy && sortDir) {
|
|
725
657
|
orderByClause[sortBy] = sortDir.toLowerCase();
|