This commit is contained in:
Benjamin Toby 2026-01-05 13:49:54 +01:00
parent 8bcb35a8f0
commit 58984214fc
7 changed files with 20 additions and 9 deletions

View File

@ -16,7 +16,7 @@ exports.default = checks;
const lodash_1 = __importDefault(require("lodash")); const lodash_1 = __importDefault(require("lodash"));
function checks(_a) { function checks(_a) {
return __awaiter(this, arguments, void 0, function* ({ table, allowedTables, query, body, method, getMiddleware, postMiddleware, putMiddleware, deleteMiddleware, crudMiddleware, targetId, }) { return __awaiter(this, arguments, void 0, function* ({ table, allowedTables, query, body, method, getMiddleware, postMiddleware, putMiddleware, deleteMiddleware, crudMiddleware, targetId, }) {
var _b, _c, _d, _e; var _b, _c, _d, _e, _f;
const allowedTable = allowedTables.find((tbl) => tbl.table == table); const allowedTable = allowedTables.find((tbl) => tbl.table == table);
if (!allowedTable) { if (!allowedTable) {
throw new Error(`Can't Access this table: \`${table}\``); throw new Error(`Can't Access this table: \`${table}\``);
@ -51,8 +51,9 @@ function checks(_a) {
} }
} }
if ((_e = newQuery === null || newQuery === void 0 ? void 0 : newQuery.searchQuery) === null || _e === void 0 ? void 0 : _e.join) { if ((_e = newQuery === null || newQuery === void 0 ? void 0 : newQuery.searchQuery) === null || _e === void 0 ? void 0 : _e.join) {
for (let i = 0; i < newQuery.searchQuery.join.length; i++) { const alljoins = (_f = newQuery === null || newQuery === void 0 ? void 0 : newQuery.searchQuery) === null || _f === void 0 ? void 0 : _f.join.flat();
const join = newQuery.searchQuery.join[i]; for (let i = 0; i < alljoins.length; i++) {
const join = alljoins[i];
if (!join) if (!join)
continue; continue;
const joinTableName = join.tableName; const joinTableName = join.tableName;

View File

@ -171,6 +171,7 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
str += str +=
"," + "," +
genObject.join genObject.join
.flat()
.filter((j) => !(0, lodash_1.isUndefined)(j)) .filter((j) => !(0, lodash_1.isUndefined)(j))
.map((joinObj) => { .map((joinObj) => {
const joinTableName = joinObj.alias const joinTableName = joinObj.alias
@ -214,6 +215,7 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
str += str +=
" " + " " +
genObject.join genObject.join
.flat()
.filter((j) => !(0, lodash_1.isUndefined)(j)) .filter((j) => !(0, lodash_1.isUndefined)(j))
.map((join) => { .map((join) => {
return (join.joinType + return (join.joinType +

View File

@ -851,7 +851,7 @@ export type ServerQueryParam<T extends {
addUserId?: { addUserId?: {
fieldName: keyof T; fieldName: keyof T;
}; };
join?: (ServerQueryParamsJoin<K> | undefined)[]; join?: (ServerQueryParamsJoin<K> | ServerQueryParamsJoin<K>[] | undefined)[];
group?: (keyof T)[]; group?: (keyof T)[];
countSubQueries?: ServerQueryParamsCount[]; countSubQueries?: ServerQueryParamsCount[];
fullTextSearch?: ServerQueryParamFullTextSearch<T>; fullTextSearch?: ServerQueryParamFullTextSearch<T>;

View File

@ -75,8 +75,10 @@ export default async function checks<
} }
if (newQuery?.searchQuery?.join) { if (newQuery?.searchQuery?.join) {
for (let i = 0; i < newQuery.searchQuery.join.length; i++) { const alljoins = newQuery?.searchQuery?.join.flat();
const join = newQuery.searchQuery.join[i];
for (let i = 0; i < alljoins.length; i++) {
const join = alljoins[i];
if (!join) continue; if (!join) continue;

View File

@ -44,7 +44,7 @@ export default function sqlGenerator<
field, field,
}: { }: {
queryObj: ServerQueryQueryObject[string]; queryObj: ServerQueryQueryObject[string];
join?: (ServerQueryParamsJoin | undefined)[]; join?: (ServerQueryParamsJoin | ServerQueryParamsJoin[] | undefined)[];
field?: string; field?: string;
}) { }) {
const finalFieldName = (() => { const finalFieldName = (() => {
@ -248,6 +248,7 @@ export default function sqlGenerator<
str += str +=
"," + "," +
genObject.join genObject.join
.flat()
.filter((j) => !isUndefined(j)) .filter((j) => !isUndefined(j))
.map((joinObj) => { .map((joinObj) => {
const joinTableName = joinObj.alias const joinTableName = joinObj.alias
@ -296,6 +297,7 @@ export default function sqlGenerator<
str += str +=
" " + " " +
genObject.join genObject.join
.flat()
.filter((j) => !isUndefined(j)) .filter((j) => !isUndefined(j))
.map((join) => { .map((join) => {
return ( return (

View File

@ -1043,7 +1043,11 @@ export type ServerQueryParam<
addUserId?: { addUserId?: {
fieldName: keyof T; fieldName: keyof T;
}; };
join?: (ServerQueryParamsJoin<K> | undefined)[]; join?: (
| ServerQueryParamsJoin<K>
| ServerQueryParamsJoin<K>[]
| undefined
)[];
group?: (keyof T)[]; group?: (keyof T)[];
countSubQueries?: ServerQueryParamsCount[]; countSubQueries?: ServerQueryParamsCount[];
fullTextSearch?: ServerQueryParamFullTextSearch<T>; fullTextSearch?: ServerQueryParamFullTextSearch<T>;

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/datasquirel", "name": "@moduletrace/datasquirel",
"version": "5.7.19", "version": "5.7.20",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {