@m1212e/rumble 0.23.4 → 0.23.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/index.cjs +34 -6
- package/out/index.cjs.map +1 -1
- package/out/index.d.cts.map +1 -1
- package/out/index.d.mts.map +1 -1
- package/out/index.mjs +34 -6
- package/out/index.mjs.map +1 -1
- package/package.json +1 -1
package/out/index.mjs
CHANGED
|
@@ -180,12 +180,25 @@ function mapNullFieldsToUndefined(obj) {
|
|
|
180
180
|
}
|
|
181
181
|
//#endregion
|
|
182
182
|
//#region package.json
|
|
183
|
-
var version = "0.23.
|
|
183
|
+
var version = "0.23.5";
|
|
184
184
|
//#endregion
|
|
185
185
|
//#region lib/helpers/mergeFilters.ts
|
|
186
|
+
const EmptyFilter$1 = Symbol.for("drizzle:EmptyFilter");
|
|
187
|
+
/**
|
|
188
|
+
* Normalizes drizzle-orm's `EmptyFilter` sentinel to `undefined` so it's
|
|
189
|
+
* treated as "no filter" rather than a real filter value to combine with
|
|
190
|
+
* AND/OR — otherwise merging an unrestricted (EmptyFilter) base filter with
|
|
191
|
+
* a real `where` would needlessly wrap it as `{ AND: [EmptyFilter, where] }`
|
|
192
|
+
* instead of just `where`.
|
|
193
|
+
*/
|
|
194
|
+
function realWhere(where) {
|
|
195
|
+
return where === EmptyFilter$1 ? void 0 : where;
|
|
196
|
+
}
|
|
186
197
|
function mergeFilters(filterA, filterB, mode = "AND") {
|
|
198
|
+
const filterAWhere = realWhere(filterA?.where);
|
|
199
|
+
const filterBWhere = realWhere(filterB?.where);
|
|
187
200
|
return {
|
|
188
|
-
where:
|
|
201
|
+
where: filterAWhere && filterBWhere ? mode === "OR" ? { OR: [filterAWhere, filterBWhere] } : { AND: [filterAWhere, filterBWhere] } : filterAWhere ?? filterBWhere,
|
|
189
202
|
columns: filterA?.columns || filterB?.columns ? new Set([Object.entries(filterA?.columns ?? {}), Object.entries(filterB?.columns ?? {})].flat().filter(([, v]) => v === true).map(([k]) => k)).entries().reduce((acc, [key]) => {
|
|
190
203
|
acc[key] = true;
|
|
191
204
|
return acc;
|
|
@@ -412,6 +425,21 @@ function tableHelper({ db, table }) {
|
|
|
412
425
|
}
|
|
413
426
|
//#endregion
|
|
414
427
|
//#region lib/abilityBuilder.ts
|
|
428
|
+
/**
|
|
429
|
+
* drizzle-orm's sentinel value for "this filter field is deliberately
|
|
430
|
+
* skipped", as opposed to `undefined`, which some drizzle-orm versions
|
|
431
|
+
* reject when it ends up as an explicit (present but `undefined`) `where`
|
|
432
|
+
* property nested inside a relational `with` query.
|
|
433
|
+
*
|
|
434
|
+
* drizzle-orm defines this via `Symbol.for("drizzle:EmptyFilter")` — a
|
|
435
|
+
* globally registered symbol — so recreating it the same way here yields
|
|
436
|
+
* the exact same value drizzle-orm's relational query engine checks for,
|
|
437
|
+
* without importing it directly: not every drizzle-orm version rumble
|
|
438
|
+
* supports exports it as a named export, and older versions that don't know
|
|
439
|
+
* about it at all still handle it safely (`Object.entries` on a symbol
|
|
440
|
+
* yields no entries, i.e. "no filter").
|
|
441
|
+
*/
|
|
442
|
+
const EmptyFilter = Symbol.for("drizzle:EmptyFilter");
|
|
415
443
|
function isDynamicQueryFilter(filter) {
|
|
416
444
|
return typeof filter === "function" && filter.constructor.name !== "AsyncFunction";
|
|
417
445
|
}
|
|
@@ -580,7 +608,7 @@ by: (explicitFilter) => {
|
|
|
580
608
|
*/
|
|
581
609
|
single: {
|
|
582
610
|
extras: filters?.extras,
|
|
583
|
-
where: filters?.where,
|
|
611
|
+
where: filters?.where ?? EmptyFilter,
|
|
584
612
|
columns: filters?.columns
|
|
585
613
|
},
|
|
586
614
|
/**
|
|
@@ -588,7 +616,7 @@ by: (explicitFilter) => {
|
|
|
588
616
|
*/
|
|
589
617
|
many: {
|
|
590
618
|
extras: filters?.extras,
|
|
591
|
-
where: filters?.where,
|
|
619
|
+
where: filters?.where ?? EmptyFilter,
|
|
592
620
|
columns: filters?.columns,
|
|
593
621
|
get limit() {
|
|
594
622
|
return limit();
|
|
@@ -634,14 +662,14 @@ by: (explicitFilter) => {
|
|
|
634
662
|
*/
|
|
635
663
|
single: {
|
|
636
664
|
extras: filters?.extras,
|
|
637
|
-
where: filters?.where
|
|
665
|
+
where: filters?.where ?? EmptyFilter
|
|
638
666
|
},
|
|
639
667
|
/**
|
|
640
668
|
* For find many calls
|
|
641
669
|
*/
|
|
642
670
|
many: {
|
|
643
671
|
extras: filters?.extras,
|
|
644
|
-
where: filters?.where,
|
|
672
|
+
where: filters?.where ?? EmptyFilter,
|
|
645
673
|
get limit() {
|
|
646
674
|
return limit();
|
|
647
675
|
}
|