prostgles-server 4.2.326 → 4.2.328
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/dist/DboBuilder/TableHandler/DataValidator.d.ts +1 -9
- package/dist/DboBuilder/TableHandler/DataValidator.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/DataValidator.js +35 -32
- package/dist/DboBuilder/TableHandler/DataValidator.js.map +1 -1
- package/dist/DboBuilder/TableHandler/insert/insert.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/insert/insert.js +6 -7
- package/dist/DboBuilder/TableHandler/insert/insert.js.map +1 -1
- package/dist/DboBuilder/TableHandler/insert/insertNestedRecords.js +6 -6
- package/dist/DboBuilder/TableHandler/insert/insertNestedRecords.js.map +1 -1
- package/dist/FileManager/initFileManager.d.ts.map +1 -1
- package/dist/FileManager/initFileManager.js +1 -1
- package/dist/FileManager/initFileManager.js.map +1 -1
- package/dist/Prostgles.d.ts +1 -1
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/PublishParser/PublishParser.d.ts +3 -3
- package/dist/PublishParser/PublishParser.d.ts.map +1 -1
- package/dist/PublishParser/PublishParser.js +12 -6
- package/dist/PublishParser/PublishParser.js.map +1 -1
- package/dist/PublishParser/getSchemaFromPublish.d.ts +2 -2
- package/dist/PublishParser/getSchemaFromPublish.d.ts.map +1 -1
- package/dist/PublishParser/getSchemaFromPublish.js +3 -3
- package/dist/PublishParser/getSchemaFromPublish.js.map +1 -1
- package/dist/PublishParser/publishTypesAndUtils.d.ts +10 -1
- package/dist/PublishParser/publishTypesAndUtils.d.ts.map +1 -1
- package/dist/RestApi.d.ts.map +1 -1
- package/dist/RestApi.js +2 -2
- package/dist/RestApi.js.map +1 -1
- package/dist/TableConfig/getSchemaDiffQueries.d.ts +6 -0
- package/dist/TableConfig/getSchemaDiffQueries.d.ts.map +1 -1
- package/dist/TableConfig/getSchemaForTableConfig.d.ts +3 -0
- package/dist/TableConfig/getSchemaForTableConfig.d.ts.map +1 -1
- package/dist/TableConfig/getSchemaForTableConfig.js +4 -1
- package/dist/TableConfig/getSchemaForTableConfig.js.map +1 -1
- package/dist/WebsocketAPI/getClientHandlers.d.ts +2 -1
- package/dist/WebsocketAPI/getClientHandlers.d.ts.map +1 -1
- package/dist/WebsocketAPI/getClientHandlers.js +14 -8
- package/dist/WebsocketAPI/getClientHandlers.js.map +1 -1
- package/dist/WebsocketAPI/getClientSchema.d.ts +2 -1
- package/dist/WebsocketAPI/getClientSchema.d.ts.map +1 -1
- package/dist/WebsocketAPI/getClientSchema.js +4 -4
- package/dist/WebsocketAPI/getClientSchema.js.map +1 -1
- package/dist/WebsocketAPI/onSocketConnected.js +1 -1
- package/dist/WebsocketAPI/onSocketConnected.js.map +1 -1
- package/dist/WebsocketAPI/pushSocketSchema.js +1 -1
- package/dist/WebsocketAPI/pushSocketSchema.js.map +1 -1
- package/dist/initProstgles.d.ts +2 -2
- package/dist/initProstgles.d.ts.map +1 -1
- package/dist/initProstgles.js +1 -1
- package/dist/initProstgles.js.map +1 -1
- package/dist/runClientRequest.d.ts +2 -1
- package/dist/runClientRequest.d.ts.map +1 -1
- package/dist/runClientRequest.js +4 -4
- package/dist/runClientRequest.js.map +1 -1
- package/lib/DboBuilder/TableHandler/DataValidator.ts +37 -123
- package/lib/DboBuilder/TableHandler/insert/insert.ts +27 -33
- package/lib/DboBuilder/TableHandler/insert/insertNestedRecords.ts +7 -7
- package/lib/FileManager/initFileManager.ts +2 -1
- package/lib/PublishParser/PublishParser.ts +23 -9
- package/lib/PublishParser/getSchemaFromPublish.ts +7 -4
- package/lib/PublishParser/publishTypesAndUtils.ts +11 -1
- package/lib/RestApi.ts +3 -2
- package/lib/TableConfig/getSchemaForTableConfig.ts +7 -1
- package/lib/WebsocketAPI/getClientHandlers.ts +20 -9
- package/lib/WebsocketAPI/getClientSchema.ts +14 -7
- package/lib/WebsocketAPI/onSocketConnected.ts +1 -1
- package/lib/WebsocketAPI/pushSocketSchema.ts +1 -1
- package/lib/initProstgles.ts +7 -3
- package/lib/runClientRequest.ts +7 -5
- package/package.json +2 -2
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { isObject, omitKeys, tryCatchV2, type ClientSchema } from "prostgles-types";
|
|
2
2
|
import type { AuthClientRequest } from "../Auth/AuthTypes";
|
|
3
3
|
import { Prostgles } from "../Prostgles";
|
|
4
|
-
import type { PublishParser } from "../PublishParser/PublishParser";
|
|
4
|
+
import type { PermissionScope, PublishParser } from "../PublishParser/PublishParser";
|
|
5
5
|
import { clientCanRunSqlRequest } from "../runClientRequest";
|
|
6
|
-
|
|
6
|
+
import { version } from "../../package.json";
|
|
7
7
|
|
|
8
|
-
export async function getClientSchema(
|
|
8
|
+
export async function getClientSchema(
|
|
9
|
+
this: Prostgles,
|
|
10
|
+
clientReq: AuthClientRequest,
|
|
11
|
+
scope: PermissionScope | undefined
|
|
12
|
+
) {
|
|
9
13
|
const result = await tryCatchV2(async () => {
|
|
10
14
|
const clientInfo =
|
|
11
15
|
clientReq.socket ?
|
|
@@ -22,10 +26,13 @@ export async function getClientSchema(this: Prostgles, clientReq: AuthClientRequ
|
|
|
22
26
|
|
|
23
27
|
try {
|
|
24
28
|
if (!publishParser) throw "publishParser undefined";
|
|
25
|
-
fullSchema = await publishParser.getSchemaFromPublish(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
fullSchema = await publishParser.getSchemaFromPublish(
|
|
30
|
+
{
|
|
31
|
+
...clientInfo,
|
|
32
|
+
userData,
|
|
33
|
+
},
|
|
34
|
+
scope
|
|
35
|
+
);
|
|
29
36
|
} catch (e) {
|
|
30
37
|
publishValidationError = e;
|
|
31
38
|
console.error(`\nProstgles Publish validation failed (after socket connected):\n ->`, e);
|
|
@@ -5,7 +5,7 @@ import { runClientSqlRequest } from "../runClientRequest";
|
|
|
5
5
|
import { makeSocketError } from "./onSocketConnected";
|
|
6
6
|
export async function pushSocketSchema(this: Prostgles, socket: PRGLIOSocket) {
|
|
7
7
|
try {
|
|
8
|
-
const clientSchema = await this.getClientSchema({ socket });
|
|
8
|
+
const clientSchema = await this.getClientSchema({ socket }, undefined);
|
|
9
9
|
socket.prostgles = clientSchema;
|
|
10
10
|
if (clientSchema.rawSQL) {
|
|
11
11
|
socket.removeAllListeners(CHANNELS.SQL);
|
package/lib/initProstgles.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { DBEventsManager } from "./DBEventsManager";
|
|
|
7
7
|
import { DBOFullyTyped } from "./DBSchemaBuilder";
|
|
8
8
|
import { DBHandlerServer, Prostgles, getIsSuperUser } from "./Prostgles";
|
|
9
9
|
import { ProstglesInitOptions } from "./ProstglesTypes";
|
|
10
|
-
import { DbTableInfo, PublishParser } from "./PublishParser/PublishParser";
|
|
10
|
+
import { DbTableInfo, PublishParser, type PermissionScope } from "./PublishParser/PublishParser";
|
|
11
11
|
import { SchemaWatch } from "./SchemaWatch/SchemaWatch";
|
|
12
12
|
import { runSQLFile } from "./TableConfig/runSQLFile";
|
|
13
13
|
import { sleep } from "./utils";
|
|
@@ -72,7 +72,10 @@ export type InitResult<S = void, SUser extends SessionUser = SessionUser> = {
|
|
|
72
72
|
update: (newOpts: UpdateableOptions<S, SUser>) => Promise<void>;
|
|
73
73
|
restart: () => Promise<InitResult<S, SUser>>;
|
|
74
74
|
options: ProstglesInitOptions<S, SUser>;
|
|
75
|
-
getClientDBHandlers: (
|
|
75
|
+
getClientDBHandlers: (
|
|
76
|
+
clientReq: AuthClientRequest,
|
|
77
|
+
scope: PermissionScope | undefined
|
|
78
|
+
) => ReturnType<typeof getClientHandlers<S>>;
|
|
76
79
|
};
|
|
77
80
|
|
|
78
81
|
const clientOnlyUpdateKeys = ["auth"] as const satisfies (keyof UpdateableOptions)[];
|
|
@@ -270,7 +273,8 @@ export const initProstgles = async function (
|
|
|
270
273
|
await sleep(1000);
|
|
271
274
|
return true;
|
|
272
275
|
},
|
|
273
|
-
getClientDBHandlers: (clientReq: AuthClientRequest
|
|
276
|
+
getClientDBHandlers: (clientReq: AuthClientRequest, scope: PermissionScope | undefined) =>
|
|
277
|
+
getClientHandlers(this, clientReq, scope),
|
|
274
278
|
};
|
|
275
279
|
|
|
276
280
|
return initResult;
|
package/lib/runClientRequest.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { TableHandler as TableHandlerServer } from "./DboBuilder/TableHandler/Ta
|
|
|
12
12
|
import { parseFieldFilter } from "./DboBuilder/ViewHandler/parseFieldFilter";
|
|
13
13
|
import { canRunSQL } from "./DboBuilder/runSQL";
|
|
14
14
|
import { Prostgles } from "./Prostgles";
|
|
15
|
-
import { ParsedTableRule } from "./PublishParser/publishTypesAndUtils";
|
|
15
|
+
import { ParsedTableRule, type PermissionScope } from "./PublishParser/publishTypesAndUtils";
|
|
16
16
|
|
|
17
17
|
const TABLE_METHODS = {
|
|
18
18
|
find: 1,
|
|
@@ -57,7 +57,8 @@ type TableMethodFunctionWithRulesAndLocalParams = (
|
|
|
57
57
|
export const runClientRequest = async function (
|
|
58
58
|
this: Prostgles,
|
|
59
59
|
args: Args,
|
|
60
|
-
clientReq: AuthClientRequest
|
|
60
|
+
clientReq: AuthClientRequest,
|
|
61
|
+
scope: PermissionScope | undefined
|
|
61
62
|
) {
|
|
62
63
|
/* Channel name will only include client-sent params so we ignore table_rules enforced params */
|
|
63
64
|
if (!this.publishParser || !this.dbo) {
|
|
@@ -82,7 +83,8 @@ export const runClientRequest = async function (
|
|
|
82
83
|
}
|
|
83
84
|
const validRules = await this.publishParser.getValidatedRequestRule(
|
|
84
85
|
{ tableName, command, clientReq },
|
|
85
|
-
clientInfo
|
|
86
|
+
clientInfo,
|
|
87
|
+
scope
|
|
86
88
|
);
|
|
87
89
|
|
|
88
90
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
@@ -151,8 +153,8 @@ export const clientCanRunSqlRequest = async function (
|
|
|
151
153
|
throw "authHandler missing";
|
|
152
154
|
}
|
|
153
155
|
const publishParams = await this.publishParser?.getPublishParams(clientReq, undefined);
|
|
154
|
-
const
|
|
155
|
-
return
|
|
156
|
+
const allowedToRunSQL = publishParams && (await this.opts.publishRawSQL?.(publishParams));
|
|
157
|
+
return allowedToRunSQL === true || allowedToRunSQL === "*";
|
|
156
158
|
};
|
|
157
159
|
|
|
158
160
|
const allowed = await canRunSQL();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prostgles-server",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.328",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"pg": "^8.15.6",
|
|
57
57
|
"pg-cursor": "^2.14.6",
|
|
58
58
|
"pg-promise": "^11.13.0",
|
|
59
|
-
"prostgles-types": "^4.0.
|
|
59
|
+
"prostgles-types": "^4.0.178"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@eslint/js": "^9.22.0",
|