@m1212e/rumble 0.18.3 → 0.18.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/index.cjs +11 -8
- 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 +11 -8
- package/out/index.mjs.map +1 -1
- package/package.json +1 -1
package/out/index.cjs
CHANGED
|
@@ -208,20 +208,20 @@ function mapNullFieldsToUndefined(obj) {
|
|
|
208
208
|
}
|
|
209
209
|
//#endregion
|
|
210
210
|
//#region package.json
|
|
211
|
-
var version = "0.18.
|
|
211
|
+
var version = "0.18.7";
|
|
212
212
|
//#endregion
|
|
213
213
|
//#region lib/helpers/mergeFilters.ts
|
|
214
|
-
function mergeFilters(filterA, filterB) {
|
|
214
|
+
function mergeFilters(filterA, filterB, mode = "AND") {
|
|
215
215
|
return {
|
|
216
|
-
where: filterA?.where && filterB?.where ? { AND: [filterA
|
|
216
|
+
where: filterA?.where && filterB?.where ? mode === "OR" ? { OR: [filterA.where, filterB.where] } : { AND: [filterA.where, filterB.where] } : filterA?.where ?? filterB?.where,
|
|
217
217
|
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]) => {
|
|
218
218
|
acc[key] = true;
|
|
219
219
|
return acc;
|
|
220
220
|
}, {}) : void 0,
|
|
221
221
|
extras: filterA?.extras || filterB?.extras ? (0, es_toolkit.toMerged)(filterA?.extras ?? {}, filterB?.extras ?? {}) : void 0,
|
|
222
222
|
orderBy: filterA?.orderBy || filterB?.orderBy ? (0, es_toolkit.toMerged)(filterA?.orderBy ?? {}, filterB?.orderBy ?? {}) : void 0,
|
|
223
|
-
limit: filterA?.limit || filterB?.limit ? Math.min(filterA?.limit ?? Infinity, filterB?.limit ?? Infinity) : void 0,
|
|
224
|
-
offset: filterA?.offset || filterB?.offset ? Math.min(filterA?.offset ?? Infinity, filterB?.offset ?? Infinity) : void 0,
|
|
223
|
+
limit: mode === "OR" ? filterA?.limit === void 0 || filterB?.limit === void 0 ? void 0 : Math.max(filterA.limit, filterB.limit) : filterA?.limit || filterB?.limit ? Math.min(filterA?.limit ?? Infinity, filterB?.limit ?? Infinity) : void 0,
|
|
224
|
+
offset: mode === "OR" ? filterA?.offset === void 0 || filterB?.offset === void 0 ? void 0 : Math.min(filterA.offset, filterB.offset) : filterA?.offset || filterB?.offset ? Math.min(filterA?.offset ?? Infinity, filterB?.offset ?? Infinity) : void 0,
|
|
225
225
|
with: filterA?.with || filterB?.with ? (0, es_toolkit.toMerged)(filterA?.with ?? {}, filterB?.with ?? {}) : void 0
|
|
226
226
|
};
|
|
227
227
|
}
|
|
@@ -380,11 +380,13 @@ const createAbilityBuilder = ({ db, actions, defaultLimit, otel }) => {
|
|
|
380
380
|
allow: (action) => {
|
|
381
381
|
if (hasBeenBuilt) throw new RumbleError("You can't call allow() after the ability builder has been built. Please ensure that you register all abilities before accessing them.");
|
|
382
382
|
const actions = Array.isArray(action) ? action : [action];
|
|
383
|
+
const setUnrestrictedByThisCall = /* @__PURE__ */ new Set();
|
|
383
384
|
for (const action of actions) {
|
|
384
385
|
let filters = queryFilters.get(action);
|
|
385
386
|
if (!filters) {
|
|
386
387
|
filters = "unrestricted";
|
|
387
388
|
queryFilters.set(action, filters);
|
|
389
|
+
setUnrestrictedByThisCall.add(action);
|
|
388
390
|
}
|
|
389
391
|
}
|
|
390
392
|
return {
|
|
@@ -401,7 +403,8 @@ const createAbilityBuilder = ({ db, actions, defaultLimit, otel }) => {
|
|
|
401
403
|
*/
|
|
402
404
|
when: (queryFilter) => {
|
|
403
405
|
for (const action of actions) {
|
|
404
|
-
if (queryFilters.get(action) === "unrestricted") queryFilters.set(action, []);
|
|
406
|
+
if (queryFilters.get(action) === "unrestricted") if (setUnrestrictedByThisCall.has(action)) queryFilters.set(action, []);
|
|
407
|
+
else continue;
|
|
405
408
|
queryFilters.get(action).push(queryFilter);
|
|
406
409
|
}
|
|
407
410
|
} };
|
|
@@ -649,8 +652,8 @@ by: (explicitFilter) => {
|
|
|
649
652
|
return transformToResponse(blockEverythingFilter);
|
|
650
653
|
}
|
|
651
654
|
const mergedFilters = allQueryFilters.length === 1 ? allQueryFilters[0] : allQueryFilters.reduce((a, b) => {
|
|
652
|
-
return mergeFilters(a, b);
|
|
653
|
-
}
|
|
655
|
+
return mergeFilters(a, b, "OR");
|
|
656
|
+
});
|
|
654
657
|
span?.setAttribute("abilities.status", "applied");
|
|
655
658
|
return transformToResponse(mergedFilters);
|
|
656
659
|
};
|