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.
Files changed (75) hide show
  1. package/debug/after-commit-fix-build.log +4 -0
  2. package/debug/after-commit-fix-client-build.log +0 -0
  3. package/debug/after-commit-fix-client.log +674 -0
  4. package/debug/after-commit-fix-lint.log +4 -0
  5. package/debug/after-commit-fix-server.log +542 -0
  6. package/debug/after-commit-fix-test-build.log +0 -0
  7. package/debug/after-commit-fix-typecheck.log +8 -0
  8. package/debug/after-commit-review-build.log +4 -0
  9. package/debug/after-commit-review-regressions.log +604 -0
  10. package/debug/after-commit-review-reproductions.patch +62 -0
  11. package/debug/after-commit-review-restored-build.log +0 -0
  12. package/debug/after-commit-review-server.log +3249 -0
  13. package/debug/after-commit-review-test-build.log +0 -0
  14. package/debug/after-commit-review-typecheck.log +8 -0
  15. package/debug/after-commit-review-withUserRLS.original.ts +554 -0
  16. package/debug/after-commit-shared-query-build.log +4 -0
  17. package/debug/after-commit-shared-query-lint.log +4 -0
  18. package/debug/after-commit-shared-query-server.log +3253 -0
  19. package/debug/auth-request-build.log +4 -0
  20. package/debug/auth-request-lint.log +4 -0
  21. package/debug/auth-request-server-tests.log +3249 -0
  22. package/debug/auth-request-test-build.log +0 -0
  23. package/debug/auth-request-typecheck.log +4 -0
  24. package/dist/Auth/AuthTypes.d.ts +7 -5
  25. package/dist/Auth/AuthTypes.d.ts.map +1 -1
  26. package/dist/Auth/AuthTypes.js.map +1 -1
  27. package/dist/DboBuilder/TableHandler/TableHandler.d.ts +13 -0
  28. package/dist/DboBuilder/TableHandler/TableHandler.d.ts.map +1 -1
  29. package/dist/DboBuilder/TableHandler/TableHandler.js +13 -0
  30. package/dist/DboBuilder/TableHandler/TableHandler.js.map +1 -1
  31. package/dist/DboBuilder/TableHandler/executeAfterHooksCheckAndPostValidation.d.ts.map +1 -1
  32. package/dist/DboBuilder/TableHandler/executeAfterHooksCheckAndPostValidation.js +12 -0
  33. package/dist/DboBuilder/TableHandler/executeAfterHooksCheckAndPostValidation.js.map +1 -1
  34. package/dist/DboBuilder/TableHandler/isApplicableHook.js +1 -1
  35. package/dist/DboBuilder/TableHandler/isApplicableHook.js.map +1 -1
  36. package/dist/DboBuilder/TableHandler/updateBatch.d.ts.map +1 -1
  37. package/dist/DboBuilder/TableHandler/updateBatch.js +18 -0
  38. package/dist/DboBuilder/TableHandler/updateBatch.js.map +1 -1
  39. package/dist/DboBuilder/ViewHandler/getReturnTypeQuery.d.ts +1 -0
  40. package/dist/DboBuilder/ViewHandler/getReturnTypeQuery.d.ts.map +1 -1
  41. package/dist/DboBuilder/ViewHandler/getReturnTypeQuery.js +6 -4
  42. package/dist/DboBuilder/ViewHandler/getReturnTypeQuery.js.map +1 -1
  43. package/dist/Prostgles.d.ts +2 -0
  44. package/dist/Prostgles.d.ts.map +1 -1
  45. package/dist/Prostgles.js +2 -0
  46. package/dist/Prostgles.js.map +1 -1
  47. package/dist/PublishParser/publishTypesAndUtils.d.ts +15 -1
  48. package/dist/PublishParser/publishTypesAndUtils.d.ts.map +1 -1
  49. package/dist/PublishParser/publishTypesAndUtils.js.map +1 -1
  50. package/dist/TableHooks/TableHooks.d.ts +12 -4
  51. package/dist/TableHooks/TableHooks.d.ts.map +1 -1
  52. package/dist/WebsocketAPI/getClientHandlers.d.ts +9 -0
  53. package/dist/WebsocketAPI/getClientHandlers.d.ts.map +1 -1
  54. package/dist/WebsocketAPI/getClientHandlers.js +12 -1
  55. package/dist/WebsocketAPI/getClientHandlers.js.map +1 -1
  56. package/dist/index.d.ts +2 -1
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/initProstgles.d.ts +3 -11
  60. package/dist/initProstgles.d.ts.map +1 -1
  61. package/dist/initProstgles.js +1 -11
  62. package/dist/initProstgles.js.map +1 -1
  63. package/lib/Auth/AuthTypes.ts +7 -5
  64. package/lib/DboBuilder/TableHandler/TableHandler.ts +13 -0
  65. package/lib/DboBuilder/TableHandler/executeAfterHooksCheckAndPostValidation.ts +13 -0
  66. package/lib/DboBuilder/TableHandler/isApplicableHook.ts +1 -1
  67. package/lib/DboBuilder/TableHandler/updateBatch.ts +28 -1
  68. package/lib/DboBuilder/ViewHandler/getReturnTypeQuery.ts +8 -3
  69. package/lib/Prostgles.ts +7 -0
  70. package/lib/PublishParser/publishTypesAndUtils.ts +16 -1
  71. package/lib/TableHooks/TableHooks.ts +14 -2
  72. package/lib/WebsocketAPI/getClientHandlers.ts +37 -0
  73. package/lib/index.ts +5 -0
  74. package/lib/initProstgles.ts +7 -30
  75. 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";
@@ -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 { AuthClientRequest, SessionUser } from "./Auth/AuthTypes";
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 { createServerSideRequest } from "./Auth/utils/serverSideRequest";
23
-
24
- type ClientDBHandlerRequest =
25
- | AuthClientRequest
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: <NarrowedClientSchema = ClientSchema>(
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-server",
3
- "version": "4.2.645",
3
+ "version": "4.2.647",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",