Skip to content

Commit

Permalink
bump types
Browse files Browse the repository at this point in the history
  • Loading branch information
prostgles committed Oct 12, 2023
1 parent 2f9978b commit a84fbf2
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 67 deletions.
13 changes: 1 addition & 12 deletions lib/DboBuilder/ViewHandler/parseJoinPath.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JoinPath, RawJoinPath } from "prostgles-types";
import { JoinPath, RawJoinPath, reverseJoinOn } from "prostgles-types";
import { ViewHandler } from "./ViewHandler";

type parseJoinPathArgs = {
Expand Down Expand Up @@ -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){
Expand Down
26 changes: 2 additions & 24 deletions lib/DboBuilder/getSubscribeRelatedTables.ts
Original file line number Diff line number Diff line change
@@ -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<SubscribeParams, "throttle">;
Expand Down Expand Up @@ -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();
}
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/client/PID.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1745085
1750441
30 changes: 15 additions & 15 deletions tests/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions tests/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a84fbf2

Please sign in to comment.