From 58984214fc1773a25ec7135f8248fb6a475e98cb Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Mon, 5 Jan 2026 13:49:54 +0100 Subject: [PATCH] Updates --- dist/package-shared/api-paths/utils/checks.js | 7 ++++--- dist/package-shared/functions/dsql/sql/sql-generator.js | 2 ++ dist/package-shared/types/index.d.ts | 2 +- package-shared/api-paths/utils/checks.ts | 6 ++++-- package-shared/functions/dsql/sql/sql-generator.ts | 4 +++- package-shared/types/index.ts | 6 +++++- package.json | 2 +- 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/dist/package-shared/api-paths/utils/checks.js b/dist/package-shared/api-paths/utils/checks.js index 1fcbafa..896a6c4 100644 --- a/dist/package-shared/api-paths/utils/checks.js +++ b/dist/package-shared/api-paths/utils/checks.js @@ -16,7 +16,7 @@ exports.default = checks; const lodash_1 = __importDefault(require("lodash")); function checks(_a) { 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); if (!allowedTable) { 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) { - for (let i = 0; i < newQuery.searchQuery.join.length; i++) { - const join = newQuery.searchQuery.join[i]; + const alljoins = (_f = newQuery === null || newQuery === void 0 ? void 0 : newQuery.searchQuery) === null || _f === void 0 ? void 0 : _f.join.flat(); + for (let i = 0; i < alljoins.length; i++) { + const join = alljoins[i]; if (!join) continue; const joinTableName = join.tableName; diff --git a/dist/package-shared/functions/dsql/sql/sql-generator.js b/dist/package-shared/functions/dsql/sql/sql-generator.js index 9ef6d64..3424d3d 100644 --- a/dist/package-shared/functions/dsql/sql/sql-generator.js +++ b/dist/package-shared/functions/dsql/sql/sql-generator.js @@ -171,6 +171,7 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) { str += "," + genObject.join + .flat() .filter((j) => !(0, lodash_1.isUndefined)(j)) .map((joinObj) => { const joinTableName = joinObj.alias @@ -214,6 +215,7 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) { str += " " + genObject.join + .flat() .filter((j) => !(0, lodash_1.isUndefined)(j)) .map((join) => { return (join.joinType + diff --git a/dist/package-shared/types/index.d.ts b/dist/package-shared/types/index.d.ts index dae0f6b..ef37a55 100644 --- a/dist/package-shared/types/index.d.ts +++ b/dist/package-shared/types/index.d.ts @@ -851,7 +851,7 @@ export type ServerQueryParam | undefined)[]; + join?: (ServerQueryParamsJoin | ServerQueryParamsJoin[] | undefined)[]; group?: (keyof T)[]; countSubQueries?: ServerQueryParamsCount[]; fullTextSearch?: ServerQueryParamFullTextSearch; diff --git a/package-shared/api-paths/utils/checks.ts b/package-shared/api-paths/utils/checks.ts index 7bed9b6..19dd874 100644 --- a/package-shared/api-paths/utils/checks.ts +++ b/package-shared/api-paths/utils/checks.ts @@ -75,8 +75,10 @@ export default async function checks< } if (newQuery?.searchQuery?.join) { - for (let i = 0; i < newQuery.searchQuery.join.length; i++) { - const join = newQuery.searchQuery.join[i]; + const alljoins = newQuery?.searchQuery?.join.flat(); + + for (let i = 0; i < alljoins.length; i++) { + const join = alljoins[i]; if (!join) continue; diff --git a/package-shared/functions/dsql/sql/sql-generator.ts b/package-shared/functions/dsql/sql/sql-generator.ts index 5735b77..daa80d4 100644 --- a/package-shared/functions/dsql/sql/sql-generator.ts +++ b/package-shared/functions/dsql/sql/sql-generator.ts @@ -44,7 +44,7 @@ export default function sqlGenerator< field, }: { queryObj: ServerQueryQueryObject[string]; - join?: (ServerQueryParamsJoin | undefined)[]; + join?: (ServerQueryParamsJoin | ServerQueryParamsJoin[] | undefined)[]; field?: string; }) { const finalFieldName = (() => { @@ -248,6 +248,7 @@ export default function sqlGenerator< str += "," + genObject.join + .flat() .filter((j) => !isUndefined(j)) .map((joinObj) => { const joinTableName = joinObj.alias @@ -296,6 +297,7 @@ export default function sqlGenerator< str += " " + genObject.join + .flat() .filter((j) => !isUndefined(j)) .map((join) => { return ( diff --git a/package-shared/types/index.ts b/package-shared/types/index.ts index bb246b6..b55d0b9 100644 --- a/package-shared/types/index.ts +++ b/package-shared/types/index.ts @@ -1043,7 +1043,11 @@ export type ServerQueryParam< addUserId?: { fieldName: keyof T; }; - join?: (ServerQueryParamsJoin | undefined)[]; + join?: ( + | ServerQueryParamsJoin + | ServerQueryParamsJoin[] + | undefined + )[]; group?: (keyof T)[]; countSubQueries?: ServerQueryParamsCount[]; fullTextSearch?: ServerQueryParamFullTextSearch; diff --git a/package.json b/package.json index 7f629f9..d215f0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "5.7.19", + "version": "5.7.20", "description": "Cloud-based SQL data management tool", "main": "dist/index.js", "bin": {