prostgles-server 4.2.645 → 4.2.647
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/debug/after-commit-fix-build.log +4 -0
- package/debug/after-commit-fix-client-build.log +0 -0
- package/debug/after-commit-fix-client.log +674 -0
- package/debug/after-commit-fix-lint.log +4 -0
- package/debug/after-commit-fix-server.log +542 -0
- package/debug/after-commit-fix-test-build.log +0 -0
- package/debug/after-commit-fix-typecheck.log +8 -0
- package/debug/after-commit-review-build.log +4 -0
- package/debug/after-commit-review-regressions.log +604 -0
- package/debug/after-commit-review-reproductions.patch +62 -0
- package/debug/after-commit-review-restored-build.log +0 -0
- package/debug/after-commit-review-server.log +3249 -0
- package/debug/after-commit-review-test-build.log +0 -0
- package/debug/after-commit-review-typecheck.log +8 -0
- package/debug/after-commit-review-withUserRLS.original.ts +554 -0
- package/debug/after-commit-shared-query-build.log +4 -0
- package/debug/after-commit-shared-query-lint.log +4 -0
- package/debug/after-commit-shared-query-server.log +3253 -0
- package/debug/auth-request-build.log +4 -0
- package/debug/auth-request-lint.log +4 -0
- package/debug/auth-request-server-tests.log +3249 -0
- package/debug/auth-request-test-build.log +0 -0
- package/debug/auth-request-typecheck.log +4 -0
- package/dist/Auth/AuthTypes.d.ts +7 -5
- package/dist/Auth/AuthTypes.d.ts.map +1 -1
- package/dist/Auth/AuthTypes.js.map +1 -1
- package/dist/DboBuilder/TableHandler/TableHandler.d.ts +13 -0
- package/dist/DboBuilder/TableHandler/TableHandler.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/TableHandler.js +13 -0
- package/dist/DboBuilder/TableHandler/TableHandler.js.map +1 -1
- package/dist/DboBuilder/TableHandler/executeAfterHooksCheckAndPostValidation.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/executeAfterHooksCheckAndPostValidation.js +12 -0
- package/dist/DboBuilder/TableHandler/executeAfterHooksCheckAndPostValidation.js.map +1 -1
- package/dist/DboBuilder/TableHandler/isApplicableHook.js +1 -1
- package/dist/DboBuilder/TableHandler/isApplicableHook.js.map +1 -1
- package/dist/DboBuilder/TableHandler/updateBatch.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/updateBatch.js +18 -0
- package/dist/DboBuilder/TableHandler/updateBatch.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/getReturnTypeQuery.d.ts +1 -0
- package/dist/DboBuilder/ViewHandler/getReturnTypeQuery.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/getReturnTypeQuery.js +6 -4
- package/dist/DboBuilder/ViewHandler/getReturnTypeQuery.js.map +1 -1
- package/dist/Prostgles.d.ts +2 -0
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/Prostgles.js +2 -0
- package/dist/Prostgles.js.map +1 -1
- package/dist/PublishParser/publishTypesAndUtils.d.ts +15 -1
- package/dist/PublishParser/publishTypesAndUtils.d.ts.map +1 -1
- package/dist/PublishParser/publishTypesAndUtils.js.map +1 -1
- package/dist/TableHooks/TableHooks.d.ts +12 -4
- package/dist/TableHooks/TableHooks.d.ts.map +1 -1
- package/dist/WebsocketAPI/getClientHandlers.d.ts +9 -0
- package/dist/WebsocketAPI/getClientHandlers.d.ts.map +1 -1
- package/dist/WebsocketAPI/getClientHandlers.js +12 -1
- package/dist/WebsocketAPI/getClientHandlers.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/initProstgles.d.ts +3 -11
- package/dist/initProstgles.d.ts.map +1 -1
- package/dist/initProstgles.js +1 -11
- package/dist/initProstgles.js.map +1 -1
- package/lib/Auth/AuthTypes.ts +7 -5
- package/lib/DboBuilder/TableHandler/TableHandler.ts +13 -0
- package/lib/DboBuilder/TableHandler/executeAfterHooksCheckAndPostValidation.ts +13 -0
- package/lib/DboBuilder/TableHandler/isApplicableHook.ts +1 -1
- package/lib/DboBuilder/TableHandler/updateBatch.ts +28 -1
- package/lib/DboBuilder/ViewHandler/getReturnTypeQuery.ts +8 -3
- package/lib/Prostgles.ts +7 -0
- package/lib/PublishParser/publishTypesAndUtils.ts +16 -1
- package/lib/TableHooks/TableHooks.ts +14 -2
- package/lib/WebsocketAPI/getClientHandlers.ts +37 -0
- package/lib/index.ts +5 -0
- package/lib/initProstgles.ts +7 -30
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type TableHandler,
|
|
9
9
|
} from "prostgles-types";
|
|
10
10
|
import type { AuthClientRequest } from "../Auth/AuthTypes";
|
|
11
|
+
import { createServerSideRequest } from "../Auth/utils/serverSideRequest";
|
|
11
12
|
import type { DBOFullyTypedClient } from "../DBSchemaBuilder/DBSchemaBuilder";
|
|
12
13
|
import type { DbTxTableHandlers } from "../DboBuilder/DboBuilderTypes";
|
|
13
14
|
import type { Prostgles } from "../Prostgles";
|
|
@@ -27,6 +28,42 @@ export type ClientHandlers<S = void> = {
|
|
|
27
28
|
clientMethods: Record<string, ServerFunctionDefinition>;
|
|
28
29
|
clientSchema: ClientSchema;
|
|
29
30
|
};
|
|
31
|
+
|
|
32
|
+
export type ClientDBHandlerRequest =
|
|
33
|
+
| AuthClientRequest
|
|
34
|
+
| {
|
|
35
|
+
/** Trusted server-only identity, resolved through auth.findUser on every operation. */
|
|
36
|
+
userId: string;
|
|
37
|
+
socket?: never;
|
|
38
|
+
httpReq?: never;
|
|
39
|
+
res?: never;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type GetClientDBHandlers<ClientSchema = void> = <
|
|
43
|
+
NarrowedClientSchema = ClientSchema,
|
|
44
|
+
>(
|
|
45
|
+
clientReq: ClientDBHandlerRequest,
|
|
46
|
+
scope: PermissionScope | undefined,
|
|
47
|
+
) => Promise<ClientHandlers<NarrowedClientSchema>>;
|
|
48
|
+
|
|
49
|
+
export const getClientDBHandlers = async <ClientSchema = void>(
|
|
50
|
+
prostgles: Prostgles,
|
|
51
|
+
clientReq: ClientDBHandlerRequest,
|
|
52
|
+
scope: PermissionScope | undefined,
|
|
53
|
+
) => {
|
|
54
|
+
if ("userId" in clientReq) {
|
|
55
|
+
if ("socket" in clientReq || "httpReq" in clientReq || "res" in clientReq) {
|
|
56
|
+
throw new Error("userId cannot be combined with a client request");
|
|
57
|
+
}
|
|
58
|
+
return getClientHandlers<ClientSchema>(
|
|
59
|
+
prostgles,
|
|
60
|
+
createServerSideRequest(prostgles, clientReq.userId),
|
|
61
|
+
scope,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return getClientHandlers<ClientSchema>(prostgles, clientReq, scope);
|
|
65
|
+
};
|
|
66
|
+
|
|
30
67
|
export const getClientHandlers = async <S = void>(
|
|
31
68
|
prostgles: Prostgles,
|
|
32
69
|
clientReq: AuthClientRequest,
|
package/lib/index.ts
CHANGED
|
@@ -37,10 +37,15 @@ export type {
|
|
|
37
37
|
PublishedResult,
|
|
38
38
|
BeforeEachTsTrigger,
|
|
39
39
|
AfterAllTsTrigger,
|
|
40
|
+
AfterCommitTsTrigger,
|
|
40
41
|
AfterEachTsTrigger,
|
|
41
42
|
PublishProfile,
|
|
42
43
|
PublishParams,
|
|
43
44
|
} from "./PublishParser/publishTypesAndUtils";
|
|
45
|
+
export type {
|
|
46
|
+
ClientDBHandlerRequest,
|
|
47
|
+
GetClientDBHandlers,
|
|
48
|
+
} from "./WebsocketAPI/getClientHandlers";
|
|
44
49
|
export type { DBOFullyTyped, DBOFullyTypedClient } from "./DBSchemaBuilder/DBSchemaBuilder";
|
|
45
50
|
export type { DBHandlerServer } from "./Prostgles";
|
|
46
51
|
export type { StorageClient as CloudClient } from "./StorageClient/StorageClientTypes";
|
package/lib/initProstgles.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { deferDbQueries } from "./deferDbQueries";
|
|
|
3
3
|
import type pgPromise from "pg-promise";
|
|
4
4
|
import type pg from "pg-promise/typescript/pg-subset";
|
|
5
5
|
import type { MaybePromise, SQLHandler, TableSchema } from "prostgles-types";
|
|
6
|
-
import type {
|
|
6
|
+
import type { SessionUser } from "./Auth/AuthTypes";
|
|
7
7
|
import { removeExpressRoutesTest } from "./Auth/utils/removeExpressRoute";
|
|
8
8
|
import { DBEventsManager } from "./DBEventsManager";
|
|
9
9
|
import type { DboBuilder } from "./DboBuilder/DboBuilder";
|
|
@@ -17,19 +17,11 @@ import { SchemaWatch } from "./SchemaWatch/SchemaWatch";
|
|
|
17
17
|
import { runSQLFile } from "./TableConfig/runSQLFile";
|
|
18
18
|
import { updateConfiguration, type clientOnlyUpdateKeys } from "./updateConfiguration";
|
|
19
19
|
import { sleep } from "./utils/utils";
|
|
20
|
-
import { getClientHandlers } from "./WebsocketAPI/getClientHandlers";
|
|
21
20
|
import { getAdminClient } from "./DboBuilder/runSql/getAdminClient";
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
| {
|
|
27
|
-
/** Trusted server-only identity, resolved through auth.findUser on every operation. */
|
|
28
|
-
userId: string;
|
|
29
|
-
socket?: never;
|
|
30
|
-
httpReq?: never;
|
|
31
|
-
res?: never;
|
|
32
|
-
};
|
|
21
|
+
import type {
|
|
22
|
+
ClientDBHandlerRequest,
|
|
23
|
+
GetClientDBHandlers,
|
|
24
|
+
} from "./WebsocketAPI/getClientHandlers";
|
|
33
25
|
|
|
34
26
|
/**
|
|
35
27
|
* Database connection details
|
|
@@ -140,10 +132,7 @@ export type InitResult<
|
|
|
140
132
|
* Uses the configured client schema by default and accepts a publish-profile schema override.
|
|
141
133
|
* Only pass userId from trusted server code; never forward client-supplied input here.
|
|
142
134
|
*/
|
|
143
|
-
getClientDBHandlers: <
|
|
144
|
-
clientReq: ClientDBHandlerRequest,
|
|
145
|
-
scope: PermissionScope | undefined,
|
|
146
|
-
) => ReturnType<typeof getClientHandlers<NarrowedClientSchema>>;
|
|
135
|
+
getClientDBHandlers: GetClientDBHandlers<ClientSchema>;
|
|
147
136
|
|
|
148
137
|
getFieldsWithTypes: typeof DboBuilder.prototype.getDetailedFieldInfo;
|
|
149
138
|
};
|
|
@@ -350,19 +339,7 @@ export const initProstgles = async function (
|
|
|
350
339
|
getClientDBHandlers: async <ClientSchema = void>(
|
|
351
340
|
clientReq: ClientDBHandlerRequest,
|
|
352
341
|
scope: PermissionScope | undefined,
|
|
353
|
-
) =>
|
|
354
|
-
if ("userId" in clientReq) {
|
|
355
|
-
if ("socket" in clientReq || "httpReq" in clientReq || "res" in clientReq) {
|
|
356
|
-
throw new Error("userId cannot be combined with a client request");
|
|
357
|
-
}
|
|
358
|
-
return getClientHandlers<ClientSchema>(
|
|
359
|
-
this,
|
|
360
|
-
createServerSideRequest(this, clientReq.userId),
|
|
361
|
-
scope,
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
return getClientHandlers<ClientSchema>(this, clientReq, scope);
|
|
365
|
-
},
|
|
342
|
+
) => this.getClientDBHandlers<ClientSchema>(clientReq, scope),
|
|
366
343
|
};
|
|
367
344
|
|
|
368
345
|
return initResult;
|