prostgles-server 4.2.178 → 4.2.180

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 (215) hide show
  1. package/.vscode/settings.json +10 -1
  2. package/dist/DboBuilder/TableHandler/DataValidator.d.ts +1 -1
  3. package/dist/DboBuilder/TableHandler/DataValidator.d.ts.map +1 -1
  4. package/dist/DboBuilder/TableHandler/DataValidator.js +4 -4
  5. package/dist/DboBuilder/TableHandler/DataValidator.js.map +1 -1
  6. package/dist/DboBuilder/TableHandler/TableHandler.d.ts +1 -1
  7. package/dist/DboBuilder/TableHandler/TableHandler.d.ts.map +1 -1
  8. package/dist/DboBuilder/TableHandler/insert.js +3 -3
  9. package/dist/DboBuilder/TableHandler/insert.js.map +1 -1
  10. package/dist/DboBuilder/TableHandler/update.d.ts.map +1 -1
  11. package/dist/DboBuilder/TableHandler/update.js +45 -19
  12. package/dist/DboBuilder/TableHandler/update.js.map +1 -1
  13. package/dist/DboBuilder/ViewHandler/ViewHandler.d.ts +1 -1
  14. package/dist/DboBuilder/ViewHandler/ViewHandler.d.ts.map +1 -1
  15. package/dist/DboBuilder/ViewHandler/ViewHandler.js +2 -2
  16. package/dist/DboBuilder/ViewHandler/ViewHandler.js.map +1 -1
  17. package/dist/DboBuilder/parseUpdateRules.js +1 -1
  18. package/dist/DboBuilder/parseUpdateRules.js.map +1 -1
  19. package/dist/Logging.d.ts +10 -3
  20. package/dist/Logging.d.ts.map +1 -1
  21. package/dist/Prostgles.d.ts +2 -2
  22. package/dist/Prostgles.d.ts.map +1 -1
  23. package/dist/Prostgles.js +118 -53
  24. package/dist/Prostgles.js.map +1 -1
  25. package/dist/ProstglesTypes.d.ts +77 -23
  26. package/dist/ProstglesTypes.d.ts.map +1 -1
  27. package/dist/ProstglesTypes.js.map +1 -1
  28. package/dist/SyncReplication.js +2 -2
  29. package/dist/SyncReplication.js.map +1 -1
  30. package/dist/initProstgles.d.ts +9 -2
  31. package/dist/initProstgles.d.ts.map +1 -1
  32. package/dist/initProstgles.js +65 -57
  33. package/dist/initProstgles.js.map +1 -1
  34. package/dist/utils.d.ts.map +1 -1
  35. package/dist/utils.js.map +1 -1
  36. package/documentation/CLIENT.md +542 -0
  37. package/documentation/SERVER.md +104 -0
  38. package/documentation/utils/clientTypes.ts +8436 -0
  39. package/documentation/utils/dist/clientTypes.d.ts +7705 -0
  40. package/documentation/utils/dist/clientTypes.d.ts.map +1 -0
  41. package/documentation/utils/dist/clientTypes.js +8438 -0
  42. package/documentation/utils/dist/definitions.d.ts +7705 -0
  43. package/documentation/utils/dist/definitions.d.ts.map +1 -0
  44. package/documentation/utils/dist/definitions.js +8438 -0
  45. package/documentation/utils/dist/generateClientDocs.d.ts +3 -0
  46. package/documentation/utils/dist/generateClientDocs.d.ts.map +1 -0
  47. package/documentation/utils/dist/generateClientDocs.js +115 -0
  48. package/documentation/utils/dist/generateDocs.d.ts +2 -0
  49. package/documentation/utils/dist/generateDocs.d.ts.map +1 -0
  50. package/documentation/utils/dist/generateDocs.js +6 -0
  51. package/documentation/utils/dist/generateMarkdown.d.ts +2 -0
  52. package/documentation/utils/dist/generateMarkdown.d.ts.map +1 -0
  53. package/documentation/utils/dist/generateMarkdown.js +68 -0
  54. package/documentation/utils/dist/generateServerDocs.d.ts +2 -0
  55. package/documentation/utils/dist/generateServerDocs.d.ts.map +1 -0
  56. package/documentation/utils/dist/generateServerDocs.js +80 -0
  57. package/documentation/utils/dist/getResolvedTypes.d.ts +15 -0
  58. package/documentation/utils/dist/getResolvedTypes.d.ts.map +1 -0
  59. package/documentation/utils/dist/getResolvedTypes.js +29 -0
  60. package/documentation/utils/dist/getSerializableType.d.ts +69 -0
  61. package/documentation/utils/dist/getSerializableType.d.ts.map +1 -0
  62. package/documentation/utils/dist/getSerializableType.js +273 -0
  63. package/documentation/utils/dist/getSymbolComments.d.ts +11 -0
  64. package/documentation/utils/dist/getSymbolComments.d.ts.map +1 -0
  65. package/documentation/utils/dist/getSymbolComments.js +60 -0
  66. package/documentation/utils/dist/loadTsFile.d.ts +7 -0
  67. package/documentation/utils/dist/loadTsFile.d.ts.map +1 -0
  68. package/documentation/utils/dist/loadTsFile.js +33 -0
  69. package/documentation/utils/dist/moduleResolver.d.ts +9 -0
  70. package/documentation/utils/dist/moduleResolver.d.ts.map +1 -0
  71. package/documentation/utils/dist/moduleResolver.js +27 -0
  72. package/documentation/utils/dist/serverTypes.d.ts +307 -0
  73. package/documentation/utils/dist/serverTypes.d.ts.map +1 -0
  74. package/documentation/utils/dist/serverTypes.js +347 -0
  75. package/documentation/utils/generateClientDocs.ts +142 -0
  76. package/documentation/utils/generateDocs.ts +4 -0
  77. package/documentation/utils/generateServerDocs.ts +82 -0
  78. package/documentation/utils/getResolvedTypes.ts +45 -0
  79. package/documentation/utils/getSerializableType.ts +479 -0
  80. package/documentation/utils/loadTsFile.ts +45 -0
  81. package/documentation/utils/moduleResolver.ts +31 -0
  82. package/documentation/utils/node_modules/.package-lock.json +67 -0
  83. package/documentation/utils/node_modules/@types/node/LICENSE +21 -0
  84. package/documentation/utils/node_modules/@types/node/README.md +15 -0
  85. package/documentation/utils/node_modules/@types/node/assert/strict.d.ts +8 -0
  86. package/documentation/utils/node_modules/@types/node/assert.d.ts +1040 -0
  87. package/documentation/utils/node_modules/@types/node/async_hooks.d.ts +541 -0
  88. package/documentation/utils/node_modules/@types/node/buffer.buffer.d.ts +385 -0
  89. package/documentation/utils/node_modules/@types/node/buffer.d.ts +1934 -0
  90. package/documentation/utils/node_modules/@types/node/child_process.d.ts +1548 -0
  91. package/documentation/utils/node_modules/@types/node/cluster.d.ts +578 -0
  92. package/documentation/utils/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
  93. package/documentation/utils/node_modules/@types/node/compatibility/index.d.ts +9 -0
  94. package/documentation/utils/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
  95. package/documentation/utils/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  96. package/documentation/utils/node_modules/@types/node/console.d.ts +452 -0
  97. package/documentation/utils/node_modules/@types/node/constants.d.ts +19 -0
  98. package/documentation/utils/node_modules/@types/node/crypto.d.ts +4519 -0
  99. package/documentation/utils/node_modules/@types/node/dgram.d.ts +596 -0
  100. package/documentation/utils/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
  101. package/documentation/utils/node_modules/@types/node/dns/promises.d.ts +477 -0
  102. package/documentation/utils/node_modules/@types/node/dns.d.ts +864 -0
  103. package/documentation/utils/node_modules/@types/node/dom-events.d.ts +124 -0
  104. package/documentation/utils/node_modules/@types/node/domain.d.ts +170 -0
  105. package/documentation/utils/node_modules/@types/node/events.d.ts +931 -0
  106. package/documentation/utils/node_modules/@types/node/fs/promises.d.ts +1245 -0
  107. package/documentation/utils/node_modules/@types/node/fs.d.ts +4317 -0
  108. package/documentation/utils/node_modules/@types/node/globals.d.ts +468 -0
  109. package/documentation/utils/node_modules/@types/node/globals.typedarray.d.ts +21 -0
  110. package/documentation/utils/node_modules/@types/node/http.d.ts +1944 -0
  111. package/documentation/utils/node_modules/@types/node/http2.d.ts +2555 -0
  112. package/documentation/utils/node_modules/@types/node/https.d.ts +544 -0
  113. package/documentation/utils/node_modules/@types/node/index.d.ts +91 -0
  114. package/documentation/utils/node_modules/@types/node/inspector.d.ts +3696 -0
  115. package/documentation/utils/node_modules/@types/node/module.d.ts +315 -0
  116. package/documentation/utils/node_modules/@types/node/net.d.ts +1005 -0
  117. package/documentation/utils/node_modules/@types/node/os.d.ts +495 -0
  118. package/documentation/utils/node_modules/@types/node/package.json +220 -0
  119. package/documentation/utils/node_modules/@types/node/path.d.ts +200 -0
  120. package/documentation/utils/node_modules/@types/node/perf_hooks.d.ts +934 -0
  121. package/documentation/utils/node_modules/@types/node/process.d.ts +1879 -0
  122. package/documentation/utils/node_modules/@types/node/punycode.d.ts +117 -0
  123. package/documentation/utils/node_modules/@types/node/querystring.d.ts +153 -0
  124. package/documentation/utils/node_modules/@types/node/readline/promises.d.ts +162 -0
  125. package/documentation/utils/node_modules/@types/node/readline.d.ts +589 -0
  126. package/documentation/utils/node_modules/@types/node/repl.d.ts +430 -0
  127. package/documentation/utils/node_modules/@types/node/sea.d.ts +153 -0
  128. package/documentation/utils/node_modules/@types/node/stream/consumers.d.ts +12 -0
  129. package/documentation/utils/node_modules/@types/node/stream/promises.d.ts +90 -0
  130. package/documentation/utils/node_modules/@types/node/stream/web.d.ts +524 -0
  131. package/documentation/utils/node_modules/@types/node/stream.d.ts +1726 -0
  132. package/documentation/utils/node_modules/@types/node/string_decoder.d.ts +67 -0
  133. package/documentation/utils/node_modules/@types/node/test.d.ts +1938 -0
  134. package/documentation/utils/node_modules/@types/node/timers/promises.d.ts +97 -0
  135. package/documentation/utils/node_modules/@types/node/timers.d.ts +240 -0
  136. package/documentation/utils/node_modules/@types/node/tls.d.ts +1217 -0
  137. package/documentation/utils/node_modules/@types/node/trace_events.d.ts +197 -0
  138. package/documentation/utils/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
  139. package/documentation/utils/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
  140. package/documentation/utils/node_modules/@types/node/ts5.6/index.d.ts +91 -0
  141. package/documentation/utils/node_modules/@types/node/tty.d.ts +208 -0
  142. package/documentation/utils/node_modules/@types/node/url.d.ts +955 -0
  143. package/documentation/utils/node_modules/@types/node/util.d.ts +2306 -0
  144. package/documentation/utils/node_modules/@types/node/v8.d.ts +808 -0
  145. package/documentation/utils/node_modules/@types/node/vm.d.ts +922 -0
  146. package/documentation/utils/node_modules/@types/node/wasi.d.ts +181 -0
  147. package/documentation/utils/node_modules/@types/node/worker_threads.d.ts +694 -0
  148. package/documentation/utils/node_modules/@types/node/zlib.d.ts +539 -0
  149. package/documentation/utils/node_modules/undici-types/LICENSE +21 -0
  150. package/documentation/utils/node_modules/undici-types/README.md +6 -0
  151. package/documentation/utils/node_modules/undici-types/agent.d.ts +31 -0
  152. package/documentation/utils/node_modules/undici-types/api.d.ts +43 -0
  153. package/documentation/utils/node_modules/undici-types/balanced-pool.d.ts +29 -0
  154. package/documentation/utils/node_modules/undici-types/cache.d.ts +36 -0
  155. package/documentation/utils/node_modules/undici-types/client.d.ts +108 -0
  156. package/documentation/utils/node_modules/undici-types/connector.d.ts +34 -0
  157. package/documentation/utils/node_modules/undici-types/content-type.d.ts +21 -0
  158. package/documentation/utils/node_modules/undici-types/cookies.d.ts +28 -0
  159. package/documentation/utils/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
  160. package/documentation/utils/node_modules/undici-types/dispatcher.d.ts +255 -0
  161. package/documentation/utils/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
  162. package/documentation/utils/node_modules/undici-types/errors.d.ts +149 -0
  163. package/documentation/utils/node_modules/undici-types/eventsource.d.ts +63 -0
  164. package/documentation/utils/node_modules/undici-types/fetch.d.ts +209 -0
  165. package/documentation/utils/node_modules/undici-types/file.d.ts +39 -0
  166. package/documentation/utils/node_modules/undici-types/filereader.d.ts +54 -0
  167. package/documentation/utils/node_modules/undici-types/formdata.d.ts +108 -0
  168. package/documentation/utils/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  169. package/documentation/utils/node_modules/undici-types/global-origin.d.ts +7 -0
  170. package/documentation/utils/node_modules/undici-types/handlers.d.ts +15 -0
  171. package/documentation/utils/node_modules/undici-types/header.d.ts +4 -0
  172. package/documentation/utils/node_modules/undici-types/index.d.ts +71 -0
  173. package/documentation/utils/node_modules/undici-types/interceptors.d.ts +15 -0
  174. package/documentation/utils/node_modules/undici-types/mock-agent.d.ts +50 -0
  175. package/documentation/utils/node_modules/undici-types/mock-client.d.ts +25 -0
  176. package/documentation/utils/node_modules/undici-types/mock-errors.d.ts +12 -0
  177. package/documentation/utils/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  178. package/documentation/utils/node_modules/undici-types/mock-pool.d.ts +25 -0
  179. package/documentation/utils/node_modules/undici-types/package.json +55 -0
  180. package/documentation/utils/node_modules/undici-types/patch.d.ts +71 -0
  181. package/documentation/utils/node_modules/undici-types/pool-stats.d.ts +19 -0
  182. package/documentation/utils/node_modules/undici-types/pool.d.ts +39 -0
  183. package/documentation/utils/node_modules/undici-types/proxy-agent.d.ts +28 -0
  184. package/documentation/utils/node_modules/undici-types/readable.d.ts +60 -0
  185. package/documentation/utils/node_modules/undici-types/retry-agent.d.ts +8 -0
  186. package/documentation/utils/node_modules/undici-types/retry-handler.d.ts +116 -0
  187. package/documentation/utils/node_modules/undici-types/util.d.ts +18 -0
  188. package/documentation/utils/node_modules/undici-types/webidl.d.ts +222 -0
  189. package/documentation/utils/node_modules/undici-types/websocket.d.ts +152 -0
  190. package/documentation/utils/package-lock.json +75 -0
  191. package/documentation/utils/package.json +14 -0
  192. package/documentation/utils/serverTypes.ts +345 -0
  193. package/documentation/utils/tsconfig.json +28 -0
  194. package/examples/full-example-typescript/DBoGenerated.d.ts +2 -2
  195. package/examples/full-example-typescript/DBoGenerated.ts +2 -2
  196. package/examples/full-example-typescript/index.ts +39 -45
  197. package/examples/full-example-vanilla/index.js +51 -53
  198. package/examples/server/typescript/index.ts +24 -30
  199. package/lib/DboBuilder/TableHandler/DataValidator.ts +5 -5
  200. package/lib/DboBuilder/TableHandler/TableHandler.ts +1 -1
  201. package/lib/DboBuilder/TableHandler/insert.ts +3 -3
  202. package/lib/DboBuilder/TableHandler/update.ts +106 -48
  203. package/lib/DboBuilder/ViewHandler/ViewHandler.ts +2 -2
  204. package/lib/DboBuilder/parseUpdateRules.ts +1 -1
  205. package/lib/Logging.ts +7 -3
  206. package/lib/Prostgles.ts +209 -142
  207. package/lib/ProstglesTypes.ts +130 -51
  208. package/lib/SyncReplication.ts +2 -2
  209. package/lib/initProstgles.ts +145 -111
  210. package/lib/utils.ts +4 -5
  211. package/package.json +3 -2
  212. package/examples/server/typescript/index.d.ts +0 -2
  213. package/examples/server/typescript/index.d.ts.map +0 -1
  214. package/examples/server/typescript/index.js +0 -54
  215. package/examples/server/typescript/index.js.map +0 -1
@@ -1,4 +1,3 @@
1
-
2
1
  import { FileColumnConfig } from "prostgles-types";
3
2
  import { Auth, AuthRequestParams, SessionUser } from "./Auth/AuthTypes";
4
3
  import { EventTriggerTagFilter } from "./Event_Trigger_Tags";
@@ -10,12 +9,10 @@ import { ColConstraint } from "./TableConfig/getConstraintDefinitionQueries";
10
9
  import { DbConnection, DbConnectionOpts, OnReadyCallback } from "./initProstgles";
11
10
  import { RestApiConfig } from "./RestApi";
12
11
  import { TableConfig } from "./TableConfig/TableConfig";
13
-
12
+
14
13
  import { PRGLIOSocket } from "./DboBuilder/DboBuilder";
15
14
 
16
- import {
17
- AnyObject
18
- } from "prostgles-types";
15
+ import { AnyObject } from "prostgles-types";
19
16
  import type { Server } from "socket.io";
20
17
  import { Publish, PublishMethods, PublishParams } from "./PublishParser/PublishParser";
21
18
  import { DB } from "./Prostgles";
@@ -25,21 +22,21 @@ import pg from "pg-promise/typescript/pg-subset";
25
22
  /**
26
23
  * Allows uploading and downloading files.
27
24
  * Currently supports only S3.
28
- *
25
+ *
29
26
  * @description
30
27
  * Will create a media table that contains file metadata and urls
31
28
  * Inserting a file into this table through prostgles will upload it to S3 and insert the relevant metadata into the media table
32
29
  * Requesting a file from HTTP GET {fileUrlPath}/{fileId} will:
33
- * 1. check auth (if provided)
30
+ * 1. check auth (if provided)
34
31
  * 2. check the permissions in publish (if provided)
35
32
  * 3. redirect the request to the signed url (if allowed)
36
- *
33
+ *
37
34
  * Specifying referencedTables will:
38
35
  * 1. create a column in that table called media
39
- * 2. create a lookup table lookup_media_{referencedTable} that joins referencedTable to the media table
36
+ * 2. create a lookup table lookup_media_{referencedTable} that joins referencedTable to the media table
40
37
  */
41
38
  export type FileTableConfig = {
42
- tableName?: string; /* defaults to 'media' */
39
+ tableName?: string /* defaults to 'media' */;
43
40
 
44
41
  /**
45
42
  * GET path used in serving media. defaults to /${tableName}
@@ -54,31 +51,27 @@ export type FileTableConfig = {
54
51
  * Instead, the "deleted" field will be updated to the current timestamp and after the day interval provided in "deleteAfterNDays" the files will be deleted
55
52
  * "checkIntervalMinutes" is the frequency in hours at which the files ready for deletion are deleted
56
53
  */
57
- delayedDelete?: {
54
+ delayedDelete?: {
58
55
  /**
59
56
  * Minimum amount of time measured in days for which the files will not be deleted after requesting delete
60
57
  */
61
- deleteAfterNDays: number;
58
+ deleteAfterNDays: number;
62
59
  /**
63
60
  * How freuquently the files will be checked for deletion delay
64
61
  */
65
- checkIntervalHours?: number;
66
- }
62
+ checkIntervalHours?: number;
63
+ };
67
64
  expressApp: ExpressApp;
68
65
  referencedTables?: {
69
- [tableName: string]:
70
-
71
- /**
72
- * If defined then will try to create (if necessary) these columns which will reference files_table(id)
73
- * Prostgles UI will use these hints (obtained through tableHandler.getInfo())
74
- * */
75
- | { type: "column", referenceColumns: Record<string, FileColumnConfig> }
76
- },
77
- imageOptions?: ImageOptions
66
+ [tableName: string]: /**
67
+ * If defined then will try to create (if necessary) these columns which will reference files_table(id)
68
+ * Prostgles UI will use these hints (obtained through tableHandler.getInfo())
69
+ * */
70
+ { type: "column"; referenceColumns: Record<string, FileColumnConfig> };
71
+ };
72
+ imageOptions?: ImageOptions;
78
73
  };
79
74
 
80
-
81
-
82
75
  type Keywords = {
83
76
  $and: string;
84
77
  $or: string;
@@ -89,59 +82,127 @@ export const JOIN_TYPES = ["one-many", "many-one", "one-one", "many-many"] as co
89
82
  export type Join = {
90
83
  tables: [string, string];
91
84
  on: { [key: string]: string }[]; // Allow multi references to table
92
- type: typeof JOIN_TYPES[number];
85
+ type: (typeof JOIN_TYPES)[number];
93
86
  };
94
87
  type Joins = Join[] | "inferred";
95
88
 
96
89
  export type ProstglesInitOptions<S = void, SUser extends SessionUser = SessionUser> = {
97
90
  dbConnection: DbConnection;
91
+ /**
92
+ * Called when the prostgles server is ready to accept connections.
93
+ * It waits for auth, tableConfig and other async configurations to complete before executing
94
+ */
95
+ onReady: OnReadyCallback<S>;
98
96
  dbOptions?: DbConnectionOpts;
97
+
98
+ /**
99
+ * If defined then a `DBSchemaGenerated.d.ts` file will be created in the provided directory.
100
+ * This file exports a `DBSchemaGenerated` type which contains types for the database tables and
101
+ * can be used as a generic type input for the prostgles instances to ensure type safety
102
+ */
99
103
  tsGeneratedTypesDir?: string;
104
+
105
+ /**
106
+ * If true then schema watch, subscriptions and syncs will be disabled.
107
+ * No `prostgles` schema will be created which is needed for the realtime features.
108
+ * This is useful when you want to connect to a database and prevent any changes to the schema
109
+ */
100
110
  disableRealtime?: boolean;
111
+
112
+ /**
113
+ * Socket.IO server instance object
114
+ */
101
115
  io?: Server;
116
+
117
+ /**
118
+ * Data access rules applied to clients.
119
+ * By default, nothing is allowed.
120
+ */
102
121
  publish?: Publish<S, SUser>;
122
+
103
123
  /**
104
- * If true then will test all table methods on each socket connect
124
+ * If true then will test all table methods on each socket connect.
125
+ * Not recommended for production
105
126
  */
106
127
  testRulesOnConnect?: boolean;
128
+
129
+ /**
130
+ * Custom methods that can be called from the client
131
+ */
107
132
  publishMethods?: PublishMethods<S, SUser>;
108
- publishRawSQL?(params: PublishParams<S, SUser>): ((boolean | "*") | Promise<(boolean | "*")>);
133
+
134
+ /**
135
+ * If defined and resolves to true then the connected client can run SQL queries
136
+ */
137
+ publishRawSQL?(params: PublishParams<S, SUser>): (boolean | "*") | Promise<boolean | "*">;
138
+
139
+ /**
140
+ * Allows defining joins between tables:
141
+ * - `infered` - uses the foreign keys to infer the joins
142
+ * - `Join[]` - specifies the joins manually
143
+ */
109
144
  joins?: Joins;
145
+
146
+ /**
147
+ * If defined then the specified schemas are included/excluded from the prostgles schema.
148
+ * By default the `public` schema is included.
149
+ */
110
150
  schema?: Record<string, 1> | Record<string, 0>;
151
+
152
+ /**
153
+ * Path to a SQL file that will be executed on startup (but before onReady)
154
+ */
111
155
  sqlFilePath?: string;
112
- onReady: OnReadyCallback<S>;
113
156
  transactions?: string | boolean;
114
157
  wsChannelNamePrefix?: string;
158
+
115
159
  /**
160
+ * Called when a socket connects
116
161
  * Use for connection verification. Will disconnect socket on any errors
117
162
  */
118
- onSocketConnect?: (args: AuthRequestParams<S, SUser> & { socket: PRGLIOSocket }) => void | Promise<void>;
119
- onSocketDisconnect?: (args: AuthRequestParams<S, SUser> & { socket: PRGLIOSocket }) => void | Promise<void>;
163
+ onSocketConnect?: (
164
+ args: AuthRequestParams<S, SUser> & { socket: PRGLIOSocket }
165
+ ) => void | Promise<void>;
166
+
167
+ /**
168
+ * Called when a socket disconnects
169
+ */
170
+ onSocketDisconnect?: (
171
+ args: AuthRequestParams<S, SUser> & { socket: PRGLIOSocket }
172
+ ) => void | Promise<void>;
173
+
174
+ /**
175
+ * Auth configuration.
176
+ * Supports email and OAuth strategies
177
+ */
120
178
  auth?: Auth<S, SUser>;
121
179
  DEBUG_MODE?: boolean;
122
- onQuery?: (error: any, ctx: pgPromise.IEventContext<pg.IClient>) => void;
123
- watchSchemaType?:
124
180
 
125
181
  /**
182
+ * Callback called when a query is executed.
183
+ * Useful for logging or debugging
184
+ */
185
+ onQuery?: (error: any, ctx: pgPromise.IEventContext<pg.IClient>) => void;
186
+ watchSchemaType?: /**
126
187
  * Will set database event trigger for schema changes. Requires superuser
127
188
  * Default
128
189
  */
129
190
  | "DDL_trigger"
130
191
 
131
- /**
132
- * Will check client queries for schema changes
133
- * fallback if DDL not possible
134
- */
135
- | "prostgles_queries"
192
+ /**
193
+ * Will check client queries for schema changes
194
+ * fallback if DDL not possible
195
+ */
196
+ | "prostgles_queries";
136
197
 
137
198
  /**
138
- * If truthy then DBoGenerated.d.ts will be updated and "onReady" will be called with new schema on both client and server
199
+ * If truthy then DBSchemaGenerated.d.ts will be updated
200
+ * and "onReady" will be called with new schema on both client and server
139
201
  */
140
- watchSchema?:
141
- /**
142
- * Will listen only to few events (create table/view)
143
- */
144
- | boolean
202
+ watchSchema?: /**
203
+ * Will listen only to few events (create table/view)
204
+ */
205
+ | boolean
145
206
 
146
207
  /**
147
208
  * Will listen to specified events (or all if "*" is specified)
@@ -161,10 +222,25 @@ export type ProstglesInitOptions<S = void, SUser extends SessionUser = SessionUs
161
222
 
162
223
  keywords?: Keywords;
163
224
  onNotice?: (notice: AnyObject, message?: string) => void;
225
+
226
+ /**
227
+ * Enables file storage and serving.
228
+ * Currently supports saving files locally or to AWS S3
229
+ */
164
230
  fileTable?: FileTableConfig;
231
+
232
+ /**
233
+ * Rest API configuration.
234
+ * The REST API allows interacting with the database similarly to the socket connection
235
+ * with the exception of subscriptions and realtime features
236
+ */
165
237
  restApi?: RestApiConfig;
238
+
166
239
  /**
167
- * Creates tables and provides UI labels, autocomplete and hints for a given json structure
240
+ * A simple way of defining tables through a JSON-schema like object.
241
+ * Allowes adding runtime JSONB validation and type safety.
242
+ * Should be used with caution because it tends to revert any changes
243
+ * made to the database schema through SQL queries
168
244
  */
169
245
  tableConfig?: TableConfig;
170
246
  tableConfigMigrations?: {
@@ -175,9 +251,9 @@ export type ProstglesInitOptions<S = void, SUser extends SessionUser = SessionUs
175
251
  silentFail?: boolean;
176
252
 
177
253
  version: number;
178
- /** Table that will contain the schema version number and the tableConfig
254
+ /** Table that will contain the schema version number and the tableConfig
179
255
  * Defaults to schema_version
180
- */
256
+ */
181
257
  versionTableName?: string;
182
258
  /**
183
259
  * Script run before tableConfig is loaded IF an older schema_version is present
@@ -186,11 +262,14 @@ export type ProstglesInitOptions<S = void, SUser extends SessionUser = SessionUs
186
262
  db: DB;
187
263
  oldVersion: number | undefined;
188
264
  getConstraints: (
189
- table: string,
190
- column?: string,
265
+ table: string,
266
+ column?: string,
191
267
  types?: ColConstraint["type"][]
192
- ) => Promise<ColConstraint[]>
268
+ ) => Promise<ColConstraint[]>;
193
269
  }) => void;
194
270
  };
271
+ /**
272
+ * Usefull for logging or debugging
273
+ */
195
274
  onLog?: (evt: EventInfo) => Promise<void>;
196
- }
275
+ };
@@ -219,13 +219,13 @@ export async function syncData (this: PubSubManager, sync: SyncParams, clientDat
219
219
 
220
220
  updateData.push([syncSafeFilter, omitKeys(upd, id_fields)])
221
221
  }));
222
- await tbl.updateBatch(updateData, { fixIssues: true }, undefined, table_rules);
222
+ await tbl.updateBatch(updateData, { removeDisallowedFields: true }, undefined, table_rules);
223
223
  } else {
224
224
  updates = [];
225
225
  }
226
226
 
227
227
  if (table_rules.insert && inserts.length) {
228
- await tbl.insert(inserts, { fixIssues: true }, undefined, table_rules);
228
+ await tbl.insert(inserts, { removeDisallowedFields: true }, undefined, table_rules);
229
229
  } else {
230
230
  inserts = [];
231
231
  }