diff --git a/lib/DboBuilder/ViewHandler/parseJoinPath.ts b/lib/DboBuilder/ViewHandler/parseJoinPath.ts index bb137131..4f9f9546 100644 --- a/lib/DboBuilder/ViewHandler/parseJoinPath.ts +++ b/lib/DboBuilder/ViewHandler/parseJoinPath.ts @@ -1,4 +1,4 @@ -import { JoinPath, RawJoinPath } from "prostgles-types"; +import { JoinPath, RawJoinPath, reverseJoinOn } from "prostgles-types"; import { ViewHandler } from "./ViewHandler"; type parseJoinPathArgs = { @@ -182,17 +182,6 @@ function getJoins(viewHandler: ViewHandler, source: string, path: JoinPath[], { }; } -export const reverseJoinOn = (on: ParsedJoinPath["on"]) => { - return on.map(constraint => - Object.fromEntries( - Object.entries(constraint) - .map(([left, right]) => - [right, left] - ) - ) - ); -} - const getValidOn = (requested: JoinPath["on"], possible: ParsedJoinPath["on"]) => { if(!requested){ diff --git a/lib/DboBuilder/getSubscribeRelatedTables.ts b/lib/DboBuilder/getSubscribeRelatedTables.ts index 202af506..e90e061d 100644 --- a/lib/DboBuilder/getSubscribeRelatedTables.ts +++ b/lib/DboBuilder/getSubscribeRelatedTables.ts @@ -1,10 +1,9 @@ -import { AnyObject, asName, isDefined, SubscribeParams } from "prostgles-types"; -import { Filter, LocalParams, makeErrorFromPGError, ExistsFilterConfig } from "../DboBuilder"; +import { AnyObject, asName, reverseParsedPath, SubscribeParams } from "prostgles-types"; +import { ExistsFilterConfig, Filter, LocalParams, makeErrorFromPGError } from "../DboBuilder"; import { TableRule } from "../PublishParser"; import { log, ViewSubscriptionOptions } from "../PubSubManager/PubSubManager"; import { NewQuery } from "./QueryBuilder/QueryBuilder"; import { ViewHandler } from "./ViewHandler/ViewHandler"; -import { ParsedJoinPath, reverseJoinOn } from "./ViewHandler/parseJoinPath"; type Args = { selectParams: Omit; @@ -187,25 +186,4 @@ export async function getSubscribeRelatedTables(this: ViewHandler, { selectParam } return viewOptions; -} - -/** - * result = [ - * { table, on: parsedPath[0] } - * ...parsedPath.map(p => ({ table: p.table, on: reversedOn(parsedPath[i+1].on) })) - * ] - */ -const reverseParsedPath = (parsedPath: ParsedJoinPath[], table: string) => { - const newPPath: ParsedJoinPath[] = [ - { table, on: [{}] }, - ...(parsedPath ?? []) - ] - return newPPath.map((pp, i) => { - const nextPath = newPPath[i+1]; - if(!nextPath) return undefined; - return { - table: pp.table, - on: reverseJoinOn(nextPath.on) - } - }).filter(isDefined).reverse(); } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4a7d8d1b..e56425a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "prostgles-server", - "version": "4.1.84", + "version": "4.1.85", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "prostgles-server", - "version": "4.1.84", + "version": "4.1.85", "license": "MIT", "dependencies": { "@types/express": "^4.17.13", @@ -15,7 +15,7 @@ "check-disk-space": "^3.3.1", "file-type": "^17.1.4", "pg-promise": "^11.3.0", - "prostgles-types": "^4.0.42" + "prostgles-types": "^4.0.43" }, "devDependencies": { "@types/bluebird": "^3.5.36", @@ -1654,9 +1654,9 @@ } }, "node_modules/prostgles-types": { - "version": "4.0.42", - "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.42.tgz", - "integrity": "sha512-ZyU8x+Sn1I6XZ82vLcuJMYsHIC0dgAqiMQDmcC9mTOkeIWundhMLVG75ZEcu6QVbaCTzZDLq+aj0z3XKCxoT6A==", + "version": "4.0.43", + "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.43.tgz", + "integrity": "sha512-ElxqTKHqSch10xGPE8FZGwwzfBK0ljvsqt7aVrhUPw53KXinGGpAaFdBgSV6h9dr9y9FOKjYPMHwPEfne/kjVA==", "dependencies": { "json-schema": "^0.4.0" } @@ -3271,9 +3271,9 @@ "dev": true }, "prostgles-types": { - "version": "4.0.42", - "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.42.tgz", - "integrity": "sha512-ZyU8x+Sn1I6XZ82vLcuJMYsHIC0dgAqiMQDmcC9mTOkeIWundhMLVG75ZEcu6QVbaCTzZDLq+aj0z3XKCxoT6A==", + "version": "4.0.43", + "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.43.tgz", + "integrity": "sha512-ElxqTKHqSch10xGPE8FZGwwzfBK0ljvsqt7aVrhUPw53KXinGGpAaFdBgSV6h9dr9y9FOKjYPMHwPEfne/kjVA==", "requires": { "json-schema": "^0.4.0" } diff --git a/package.json b/package.json index f9311412..36e3c22e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prostgles-server", - "version": "4.1.84", + "version": "4.1.85", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -41,7 +41,7 @@ "check-disk-space": "^3.3.1", "file-type": "^17.1.4", "pg-promise": "^11.3.0", - "prostgles-types": "^4.0.42" + "prostgles-types": "^4.0.43" }, "devDependencies": { "@types/bluebird": "^3.5.36", diff --git a/tests/client/PID.txt b/tests/client/PID.txt index 1c34f73a..81d12095 100644 --- a/tests/client/PID.txt +++ b/tests/client/PID.txt @@ -1 +1 @@ -1745085 +1750441 diff --git a/tests/client/package-lock.json b/tests/client/package-lock.json index 0171b72e..f88e2e14 100644 --- a/tests/client/package-lock.json +++ b/tests/client/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "dependencies": { "@types/node": "^14.14.16", - "prostgles-client": "^4.0.26", + "prostgles-client": "^4.0.27", "socket.io-client": "^4.7.1" }, "devDependencies": { @@ -74,11 +74,11 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/prostgles-client": { - "version": "4.0.26", - "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-4.0.26.tgz", - "integrity": "sha512-Mmcv+z7ktaEdP2E+G8WWboiqZvmtkRZxT+SyRJimpFeJY3o+Xh2smzbTeg+KojsFP4SCWYtPQhgtPCNyQCVvUw==", + "version": "4.0.27", + "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-4.0.27.tgz", + "integrity": "sha512-qMx60nai7E6FuiN002RwIgXu0a7ql/erEJbRP9FBem07IKHg7A0+8jrBMyvqeAsOFFH8FQLYYc5L0JEozCMl9Q==", "dependencies": { - "prostgles-types": "^4.0.42" + "prostgles-types": "^4.0.43" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0" @@ -90,9 +90,9 @@ } }, "node_modules/prostgles-types": { - "version": "4.0.42", - "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.42.tgz", - "integrity": "sha512-ZyU8x+Sn1I6XZ82vLcuJMYsHIC0dgAqiMQDmcC9mTOkeIWundhMLVG75ZEcu6QVbaCTzZDLq+aj0z3XKCxoT6A==", + "version": "4.0.43", + "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.43.tgz", + "integrity": "sha512-ElxqTKHqSch10xGPE8FZGwwzfBK0ljvsqt7aVrhUPw53KXinGGpAaFdBgSV6h9dr9y9FOKjYPMHwPEfne/kjVA==", "dependencies": { "json-schema": "^0.4.0" } @@ -212,17 +212,17 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "prostgles-client": { - "version": "4.0.26", - "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-4.0.26.tgz", - "integrity": "sha512-Mmcv+z7ktaEdP2E+G8WWboiqZvmtkRZxT+SyRJimpFeJY3o+Xh2smzbTeg+KojsFP4SCWYtPQhgtPCNyQCVvUw==", + "version": "4.0.27", + "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-4.0.27.tgz", + "integrity": "sha512-qMx60nai7E6FuiN002RwIgXu0a7ql/erEJbRP9FBem07IKHg7A0+8jrBMyvqeAsOFFH8FQLYYc5L0JEozCMl9Q==", "requires": { - "prostgles-types": "^4.0.42" + "prostgles-types": "^4.0.43" } }, "prostgles-types": { - "version": "4.0.42", - "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.42.tgz", - "integrity": "sha512-ZyU8x+Sn1I6XZ82vLcuJMYsHIC0dgAqiMQDmcC9mTOkeIWundhMLVG75ZEcu6QVbaCTzZDLq+aj0z3XKCxoT6A==", + "version": "4.0.43", + "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-4.0.43.tgz", + "integrity": "sha512-ElxqTKHqSch10xGPE8FZGwwzfBK0ljvsqt7aVrhUPw53KXinGGpAaFdBgSV6h9dr9y9FOKjYPMHwPEfne/kjVA==", "requires": { "json-schema": "^0.4.0" } diff --git a/tests/client/package.json b/tests/client/package.json index 7633921e..a9fed704 100644 --- a/tests/client/package.json +++ b/tests/client/package.json @@ -13,7 +13,7 @@ "license": "ISC", "dependencies": { "@types/node": "^14.14.16", - "prostgles-client": "^4.0.26", + "prostgles-client": "^4.0.27", "socket.io-client": "^4.7.1" }, "devDependencies": { diff --git a/tests/server/package-lock.json b/tests/server/package-lock.json index 361c1af8..c485ead3 100644 --- a/tests/server/package-lock.json +++ b/tests/server/package-lock.json @@ -21,7 +21,7 @@ }, "../..": { "name": "prostgles-server", - "version": "4.1.84", + "version": "4.1.85", "license": "MIT", "dependencies": { "@types/express": "^4.17.13", @@ -30,7 +30,7 @@ "check-disk-space": "^3.3.1", "file-type": "^17.1.4", "pg-promise": "^11.3.0", - "prostgles-types": "^4.0.42" + "prostgles-types": "^4.0.43" }, "devDependencies": { "@types/bluebird": "^3.5.36", @@ -1521,7 +1521,7 @@ "eslint": "^8.44.0", "file-type": "^17.1.4", "pg-promise": "^11.3.0", - "prostgles-types": "^4.0.42", + "prostgles-types": "^4.0.43", "typescript": "^5.0.3" } },