@m1212e/rumble 0.23.5 → 0.23.8
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 +37 -29
- package/out/index.cjs.map +1 -1
- package/out/index.d.cts +13 -1
- package/out/index.d.cts.map +1 -1
- package/out/index.d.mts +13 -1
- package/out/index.d.mts.map +1 -1
- package/out/index.mjs +37 -29
- package/out/index.mjs.map +1 -1
- package/package.json +1 -1
package/out/index.cjs
CHANGED
|
@@ -208,7 +208,7 @@ function mapNullFieldsToUndefined(obj) {
|
|
|
208
208
|
}
|
|
209
209
|
//#endregion
|
|
210
210
|
//#region package.json
|
|
211
|
-
var version = "0.23.
|
|
211
|
+
var version = "0.23.8";
|
|
212
212
|
//#endregion
|
|
213
213
|
//#region lib/helpers/mergeFilters.ts
|
|
214
214
|
const EmptyFilter$1 = Symbol.for("drizzle:EmptyFilter");
|
|
@@ -239,6 +239,20 @@ function mergeFilters(filterA, filterB, mode = "AND") {
|
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
//#endregion
|
|
242
|
+
//#region lib/helpers/sanitizeFilterValue.ts
|
|
243
|
+
const EmptyFilter = Symbol.for("drizzle:EmptyFilter");
|
|
244
|
+
function isPlainObject(value) {
|
|
245
|
+
if (typeof value !== "object" || value === null) return false;
|
|
246
|
+
const proto = Object.getPrototypeOf(value);
|
|
247
|
+
return proto === Object.prototype || proto === null;
|
|
248
|
+
}
|
|
249
|
+
function sanitizeFilterValue(value) {
|
|
250
|
+
if (value === void 0) return EmptyFilter;
|
|
251
|
+
if (Array.isArray(value)) return value.map(sanitizeFilterValue);
|
|
252
|
+
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sanitizeFilterValue(entry)]));
|
|
253
|
+
return value;
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
242
256
|
//#region lib/helpers/sqlTypes/types.ts
|
|
243
257
|
/**
|
|
244
258
|
* Strips parameter suffixes like `(256)`, `(10,2)` and timezone modifiers
|
|
@@ -453,21 +467,6 @@ function tableHelper({ db, table }) {
|
|
|
453
467
|
}
|
|
454
468
|
//#endregion
|
|
455
469
|
//#region lib/abilityBuilder.ts
|
|
456
|
-
/**
|
|
457
|
-
* drizzle-orm's sentinel value for "this filter field is deliberately
|
|
458
|
-
* skipped", as opposed to `undefined`, which some drizzle-orm versions
|
|
459
|
-
* reject when it ends up as an explicit (present but `undefined`) `where`
|
|
460
|
-
* property nested inside a relational `with` query.
|
|
461
|
-
*
|
|
462
|
-
* drizzle-orm defines this via `Symbol.for("drizzle:EmptyFilter")` — a
|
|
463
|
-
* globally registered symbol — so recreating it the same way here yields
|
|
464
|
-
* the exact same value drizzle-orm's relational query engine checks for,
|
|
465
|
-
* without importing it directly: not every drizzle-orm version rumble
|
|
466
|
-
* supports exports it as a named export, and older versions that don't know
|
|
467
|
-
* about it at all still handle it safely (`Object.entries` on a symbol
|
|
468
|
-
* yields no entries, i.e. "no filter").
|
|
469
|
-
*/
|
|
470
|
-
const EmptyFilter = Symbol.for("drizzle:EmptyFilter");
|
|
471
470
|
function isDynamicQueryFilter(filter) {
|
|
472
471
|
return typeof filter === "function" && filter.constructor.name !== "AsyncFunction";
|
|
473
472
|
}
|
|
@@ -618,7 +617,7 @@ by: (explicitFilter) => {
|
|
|
618
617
|
});
|
|
619
618
|
const sqlTransformedWhere = require_lazy.lazy(() => {
|
|
620
619
|
const casing = db._.session?.dialect?.casing;
|
|
621
|
-
return filters?.where ? (0, drizzle_orm.relationsFilterToSQL)(tableSchema.foundRelation.table, filters.where, tableSchema.relations, db._.relations, casing) : void 0;
|
|
620
|
+
return filters?.where ? (0, drizzle_orm.relationsFilterToSQL)(tableSchema.foundRelation.table, sanitizeFilterValue(filters.where), tableSchema.relations, db._.relations, casing) : void 0;
|
|
622
621
|
});
|
|
623
622
|
if (filters?.columns) return {
|
|
624
623
|
/**
|
|
@@ -636,7 +635,7 @@ by: (explicitFilter) => {
|
|
|
636
635
|
*/
|
|
637
636
|
single: {
|
|
638
637
|
extras: filters?.extras,
|
|
639
|
-
where: filters?.where
|
|
638
|
+
where: sanitizeFilterValue(filters?.where),
|
|
640
639
|
columns: filters?.columns
|
|
641
640
|
},
|
|
642
641
|
/**
|
|
@@ -644,7 +643,7 @@ by: (explicitFilter) => {
|
|
|
644
643
|
*/
|
|
645
644
|
many: {
|
|
646
645
|
extras: filters?.extras,
|
|
647
|
-
where: filters?.where
|
|
646
|
+
where: sanitizeFilterValue(filters?.where),
|
|
648
647
|
columns: filters?.columns,
|
|
649
648
|
get limit() {
|
|
650
649
|
return limit();
|
|
@@ -690,14 +689,14 @@ by: (explicitFilter) => {
|
|
|
690
689
|
*/
|
|
691
690
|
single: {
|
|
692
691
|
extras: filters?.extras,
|
|
693
|
-
where: filters?.where
|
|
692
|
+
where: sanitizeFilterValue(filters?.where)
|
|
694
693
|
},
|
|
695
694
|
/**
|
|
696
695
|
* For find many calls
|
|
697
696
|
*/
|
|
698
697
|
many: {
|
|
699
698
|
extras: filters?.extras,
|
|
700
|
-
where: filters?.where
|
|
699
|
+
where: sanitizeFilterValue(filters?.where),
|
|
701
700
|
get limit() {
|
|
702
701
|
return limit();
|
|
703
702
|
}
|
|
@@ -1890,7 +1889,7 @@ const createPubSubInstance = ({ subscriptions }) => {
|
|
|
1890
1889
|
//#region lib/query.ts
|
|
1891
1890
|
const createQueryImplementer = ({ db, schemaBuilder, search, logger: loggerConfig, whereArgImplementer, orderArgImplementer, makePubSubInstance }) => {
|
|
1892
1891
|
const registeredQueryFieldNames = /* @__PURE__ */ new Set();
|
|
1893
|
-
return ({ table, readAction = "read", listAction = "read" }) => {
|
|
1892
|
+
return ({ table, readAction = "read", listAction = "read", findFirst, findMany }) => {
|
|
1894
1893
|
const WhereArg = whereArgImplementer({ table });
|
|
1895
1894
|
const OrderArg = orderArgImplementer({ table });
|
|
1896
1895
|
const tableSchema = tableHelper({
|
|
@@ -1949,8 +1948,13 @@ const createQueryImplementer = ({ db, schemaBuilder, search, logger: loggerConfi
|
|
|
1949
1948
|
const filter = ctx.abilities[table].filter(listAction).merge(mappedArgs).query.many;
|
|
1950
1949
|
if (mappedArgs.offset) filter.offset = mappedArgs.offset;
|
|
1951
1950
|
if (mappedArgs.orderBy) filter.orderBy = mappedArgs.orderBy;
|
|
1952
|
-
const
|
|
1953
|
-
if (filter.columns)
|
|
1951
|
+
const queryArgs = query(filter);
|
|
1952
|
+
if (filter.columns) queryArgs.columns = filter.columns;
|
|
1953
|
+
const run = findMany ? (tx) => findMany({
|
|
1954
|
+
tx,
|
|
1955
|
+
filter,
|
|
1956
|
+
queryArgs
|
|
1957
|
+
}) : (tx) => tx.query[table].findMany(queryArgs);
|
|
1954
1958
|
if (search?.enabled && args.search && args.search.length > 0 && search?.cpu_operator_cost) return db.transaction(async (tx) => {
|
|
1955
1959
|
if (isPostgresDB(tx)) await tx.execute(drizzle_orm.sql.raw(`SET cpu_operator_cost = ${search.cpu_operator_cost};`));
|
|
1956
1960
|
else {
|
|
@@ -1958,9 +1962,9 @@ const createQueryImplementer = ({ db, schemaBuilder, search, logger: loggerConfi
|
|
|
1958
1962
|
const log = loggerConfig?.enabled ? loggerConfig.logger : void 0;
|
|
1959
1963
|
log ? log.info({}, msg) : console.info(msg);
|
|
1960
1964
|
}
|
|
1961
|
-
return tx
|
|
1965
|
+
return run(tx);
|
|
1962
1966
|
});
|
|
1963
|
-
return db
|
|
1967
|
+
return run(db);
|
|
1964
1968
|
}
|
|
1965
1969
|
}),
|
|
1966
1970
|
[singularName]: t.drizzleField({
|
|
@@ -1972,9 +1976,13 @@ const createQueryImplementer = ({ db, schemaBuilder, search, logger: loggerConfi
|
|
|
1972
1976
|
resolve: (query, _root, args, ctx, _info) => {
|
|
1973
1977
|
deepSetProto(args);
|
|
1974
1978
|
const filter = ctx.abilities[table].filter(readAction).merge({ where: { [primaryKeyField.name]: args.id } }).query.single;
|
|
1975
|
-
const
|
|
1976
|
-
if (filter.columns)
|
|
1977
|
-
return
|
|
1979
|
+
const queryArgs = query(filter);
|
|
1980
|
+
if (filter.columns) queryArgs.columns = filter.columns;
|
|
1981
|
+
return findFirst ? findFirst({
|
|
1982
|
+
tx: db,
|
|
1983
|
+
filter,
|
|
1984
|
+
queryArgs
|
|
1985
|
+
}) : db.query[table].findFirst(queryArgs).then(assertFindFirstExists);
|
|
1978
1986
|
}
|
|
1979
1987
|
})
|
|
1980
1988
|
};
|