prostgles-server 4.2.187 → 4.2.189

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 (338) hide show
  1. package/.eslintignore +2 -1
  2. package/.eslintrc.json +2 -0
  3. package/dist/Auth/AuthHandler.d.ts +20 -11
  4. package/dist/Auth/AuthHandler.d.ts.map +1 -1
  5. package/dist/Auth/AuthHandler.js +98 -120
  6. package/dist/Auth/AuthHandler.js.map +1 -1
  7. package/dist/Auth/AuthTypes.d.ts +69 -71
  8. package/dist/Auth/AuthTypes.d.ts.map +1 -1
  9. package/dist/Auth/{setEmailProvider.d.ts → authProviders/setEmailProvider.d.ts} +1 -1
  10. package/dist/Auth/authProviders/setEmailProvider.d.ts.map +1 -0
  11. package/dist/Auth/authProviders/setEmailProvider.js +27 -0
  12. package/dist/Auth/authProviders/setEmailProvider.js.map +1 -0
  13. package/dist/Auth/authProviders/setOAuthProviders.d.ts +5 -0
  14. package/dist/Auth/authProviders/setOAuthProviders.d.ts.map +1 -0
  15. package/dist/Auth/authProviders/setOAuthProviders.js +78 -0
  16. package/dist/Auth/authProviders/setOAuthProviders.js.map +1 -0
  17. package/dist/Auth/endpoints/getConfirmEmailRequestHandler.d.ts +7 -0
  18. package/dist/Auth/endpoints/getConfirmEmailRequestHandler.d.ts.map +1 -0
  19. package/dist/Auth/endpoints/getConfirmEmailRequestHandler.js +29 -0
  20. package/dist/Auth/endpoints/getConfirmEmailRequestHandler.js.map +1 -0
  21. package/dist/Auth/endpoints/getRegisterRequestHandler.d.ts +7 -0
  22. package/dist/Auth/endpoints/getRegisterRequestHandler.d.ts.map +1 -0
  23. package/dist/Auth/endpoints/getRegisterRequestHandler.js +77 -0
  24. package/dist/Auth/endpoints/getRegisterRequestHandler.js.map +1 -0
  25. package/dist/Auth/setAuthProviders.d.ts.map +1 -1
  26. package/dist/Auth/setAuthProviders.js +4 -74
  27. package/dist/Auth/setAuthProviders.js.map +1 -1
  28. package/dist/Auth/setupAuthRoutes.d.ts.map +1 -1
  29. package/dist/Auth/setupAuthRoutes.js +23 -33
  30. package/dist/Auth/setupAuthRoutes.js.map +1 -1
  31. package/dist/Auth/utils/checkDmarc.d.ts +2 -0
  32. package/dist/Auth/utils/checkDmarc.d.ts.map +1 -0
  33. package/dist/Auth/utils/checkDmarc.js +22 -0
  34. package/dist/Auth/utils/checkDmarc.js.map +1 -0
  35. package/dist/Auth/utils/getClientRequestIPsInfo.d.ts +3 -0
  36. package/dist/Auth/utils/getClientRequestIPsInfo.d.ts.map +1 -0
  37. package/dist/Auth/utils/getClientRequestIPsInfo.js +29 -0
  38. package/dist/Auth/utils/getClientRequestIPsInfo.js.map +1 -0
  39. package/dist/Auth/utils/getReturnUrl.d.ts +3 -0
  40. package/dist/Auth/utils/getReturnUrl.d.ts.map +1 -0
  41. package/dist/Auth/utils/getReturnUrl.js +15 -0
  42. package/dist/Auth/utils/getReturnUrl.js.map +1 -0
  43. package/dist/Auth/utils/getSafeReturnURL.d.ts.map +1 -0
  44. package/dist/Auth/utils/getSafeReturnURL.js.map +1 -0
  45. package/dist/DBEventsManager.d.ts.map +1 -1
  46. package/dist/DBEventsManager.js +4 -5
  47. package/dist/DBEventsManager.js.map +1 -1
  48. package/dist/DBSchemaBuilder.js +1 -1
  49. package/dist/DBSchemaBuilder.js.map +1 -1
  50. package/dist/DboBuilder/DboBuilder.d.ts +0 -1
  51. package/dist/DboBuilder/DboBuilder.d.ts.map +1 -1
  52. package/dist/DboBuilder/DboBuilder.js +3 -12
  53. package/dist/DboBuilder/DboBuilder.js.map +1 -1
  54. package/dist/DboBuilder/DboBuilderTypes.d.ts +4 -4
  55. package/dist/DboBuilder/DboBuilderTypes.d.ts.map +1 -1
  56. package/dist/DboBuilder/DboBuilderTypes.js.map +1 -1
  57. package/dist/DboBuilder/QueryBuilder/Functions.d.ts.map +1 -1
  58. package/dist/DboBuilder/QueryBuilder/Functions.js +38 -76
  59. package/dist/DboBuilder/QueryBuilder/Functions.js.map +1 -1
  60. package/dist/DboBuilder/QueryBuilder/QueryBuilder.d.ts.map +1 -1
  61. package/dist/DboBuilder/QueryBuilder/QueryBuilder.js +4 -12
  62. package/dist/DboBuilder/QueryBuilder/QueryBuilder.js.map +1 -1
  63. package/dist/DboBuilder/QueryBuilder/getNewQuery.d.ts.map +1 -1
  64. package/dist/DboBuilder/QueryBuilder/getNewQuery.js +23 -33
  65. package/dist/DboBuilder/QueryBuilder/getNewQuery.js.map +1 -1
  66. package/dist/DboBuilder/QueryBuilder/getSelectQuery.d.ts +1 -1
  67. package/dist/DboBuilder/QueryBuilder/getSelectQuery.d.ts.map +1 -1
  68. package/dist/DboBuilder/QueryBuilder/getSelectQuery.js +6 -6
  69. package/dist/DboBuilder/QueryBuilder/getSelectQuery.js.map +1 -1
  70. package/dist/DboBuilder/QueryStreamer.d.ts.map +1 -1
  71. package/dist/DboBuilder/QueryStreamer.js +13 -19
  72. package/dist/DboBuilder/QueryStreamer.js.map +1 -1
  73. package/dist/DboBuilder/TableHandler/DataValidator.d.ts +1 -1
  74. package/dist/DboBuilder/TableHandler/DataValidator.d.ts.map +1 -1
  75. package/dist/DboBuilder/TableHandler/DataValidator.js +7 -16
  76. package/dist/DboBuilder/TableHandler/DataValidator.js.map +1 -1
  77. package/dist/DboBuilder/TableHandler/TableHandler.d.ts.map +1 -1
  78. package/dist/DboBuilder/TableHandler/TableHandler.js +7 -5
  79. package/dist/DboBuilder/TableHandler/TableHandler.js.map +1 -1
  80. package/dist/DboBuilder/TableHandler/delete.d.ts.map +1 -1
  81. package/dist/DboBuilder/TableHandler/delete.js +5 -8
  82. package/dist/DboBuilder/TableHandler/delete.js.map +1 -1
  83. package/dist/DboBuilder/TableHandler/insert.d.ts.map +1 -1
  84. package/dist/DboBuilder/TableHandler/insert.js +10 -15
  85. package/dist/DboBuilder/TableHandler/insert.js.map +1 -1
  86. package/dist/DboBuilder/TableHandler/insertTest.js +1 -1
  87. package/dist/DboBuilder/TableHandler/insertTest.js.map +1 -1
  88. package/dist/DboBuilder/TableHandler/runInsertUpdateQuery.d.ts.map +1 -1
  89. package/dist/DboBuilder/TableHandler/runInsertUpdateQuery.js +1 -1
  90. package/dist/DboBuilder/TableHandler/runInsertUpdateQuery.js.map +1 -1
  91. package/dist/DboBuilder/TableHandler/update.d.ts.map +1 -1
  92. package/dist/DboBuilder/TableHandler/update.js +5 -9
  93. package/dist/DboBuilder/TableHandler/update.js.map +1 -1
  94. package/dist/DboBuilder/TableHandler/updateFile.d.ts +1 -1
  95. package/dist/DboBuilder/TableHandler/updateFile.d.ts.map +1 -1
  96. package/dist/DboBuilder/TableHandler/updateFile.js +7 -9
  97. package/dist/DboBuilder/TableHandler/updateFile.js.map +1 -1
  98. package/dist/DboBuilder/TableHandler/upsert.d.ts.map +1 -1
  99. package/dist/DboBuilder/TableHandler/upsert.js +1 -1
  100. package/dist/DboBuilder/TableHandler/upsert.js.map +1 -1
  101. package/dist/DboBuilder/ViewHandler/ViewHandler.d.ts.map +1 -1
  102. package/dist/DboBuilder/ViewHandler/ViewHandler.js +11 -13
  103. package/dist/DboBuilder/ViewHandler/ViewHandler.js.map +1 -1
  104. package/dist/DboBuilder/ViewHandler/count.js +1 -1
  105. package/dist/DboBuilder/ViewHandler/count.js.map +1 -1
  106. package/dist/DboBuilder/ViewHandler/find.d.ts.map +1 -1
  107. package/dist/DboBuilder/ViewHandler/find.js +20 -27
  108. package/dist/DboBuilder/ViewHandler/find.js.map +1 -1
  109. package/dist/DboBuilder/ViewHandler/getExistsCondition.d.ts.map +1 -1
  110. package/dist/DboBuilder/ViewHandler/getExistsCondition.js +4 -10
  111. package/dist/DboBuilder/ViewHandler/getExistsCondition.js.map +1 -1
  112. package/dist/DboBuilder/ViewHandler/getInfo.js +2 -2
  113. package/dist/DboBuilder/ViewHandler/getInfo.js.map +1 -1
  114. package/dist/DboBuilder/ViewHandler/getTableJoinQuery.d.ts.map +1 -1
  115. package/dist/DboBuilder/ViewHandler/getTableJoinQuery.js +6 -22
  116. package/dist/DboBuilder/ViewHandler/getTableJoinQuery.js.map +1 -1
  117. package/dist/DboBuilder/ViewHandler/parseFieldFilter.d.ts.map +1 -1
  118. package/dist/DboBuilder/ViewHandler/parseFieldFilter.js +6 -10
  119. package/dist/DboBuilder/ViewHandler/parseFieldFilter.js.map +1 -1
  120. package/dist/DboBuilder/ViewHandler/parseJoinPath.d.ts.map +1 -1
  121. package/dist/DboBuilder/ViewHandler/parseJoinPath.js +8 -11
  122. package/dist/DboBuilder/ViewHandler/parseJoinPath.js.map +1 -1
  123. package/dist/DboBuilder/ViewHandler/prepareSortItems.d.ts.map +1 -1
  124. package/dist/DboBuilder/ViewHandler/prepareSortItems.js +7 -12
  125. package/dist/DboBuilder/ViewHandler/prepareSortItems.js.map +1 -1
  126. package/dist/DboBuilder/ViewHandler/prepareWhere.d.ts.map +1 -1
  127. package/dist/DboBuilder/ViewHandler/prepareWhere.js +6 -10
  128. package/dist/DboBuilder/ViewHandler/prepareWhere.js.map +1 -1
  129. package/dist/DboBuilder/dboBuilderUtils.d.ts.map +1 -1
  130. package/dist/DboBuilder/dboBuilderUtils.js +8 -23
  131. package/dist/DboBuilder/dboBuilderUtils.js.map +1 -1
  132. package/dist/DboBuilder/getColumns.d.ts.map +1 -1
  133. package/dist/DboBuilder/getColumns.js +19 -26
  134. package/dist/DboBuilder/getColumns.js.map +1 -1
  135. package/dist/DboBuilder/getCondition.d.ts.map +1 -1
  136. package/dist/DboBuilder/getCondition.js +7 -9
  137. package/dist/DboBuilder/getCondition.js.map +1 -1
  138. package/dist/DboBuilder/getSubscribeRelatedTables.js +2 -2
  139. package/dist/DboBuilder/getSubscribeRelatedTables.js.map +1 -1
  140. package/dist/DboBuilder/getTablesForSchemaPostgresSQL.d.ts.map +1 -1
  141. package/dist/DboBuilder/getTablesForSchemaPostgresSQL.js +14 -15
  142. package/dist/DboBuilder/getTablesForSchemaPostgresSQL.js.map +1 -1
  143. package/dist/DboBuilder/insertNestedRecords.d.ts.map +1 -1
  144. package/dist/DboBuilder/insertNestedRecords.js +26 -40
  145. package/dist/DboBuilder/insertNestedRecords.js.map +1 -1
  146. package/dist/DboBuilder/parseUpdateRules.js +1 -1
  147. package/dist/DboBuilder/parseUpdateRules.js.map +1 -1
  148. package/dist/DboBuilder/prepareShortestJoinPaths.d.ts.map +1 -1
  149. package/dist/DboBuilder/prepareShortestJoinPaths.js +12 -18
  150. package/dist/DboBuilder/prepareShortestJoinPaths.js.map +1 -1
  151. package/dist/DboBuilder/runSQL.d.ts +1 -1
  152. package/dist/DboBuilder/runSQL.d.ts.map +1 -1
  153. package/dist/DboBuilder/runSQL.js +14 -27
  154. package/dist/DboBuilder/runSQL.js.map +1 -1
  155. package/dist/DboBuilder/uploadFile.d.ts +1 -1
  156. package/dist/DboBuilder/uploadFile.d.ts.map +1 -1
  157. package/dist/DboBuilder/uploadFile.js +4 -11
  158. package/dist/DboBuilder/uploadFile.js.map +1 -1
  159. package/dist/FileManager/FileManager.d.ts.map +1 -1
  160. package/dist/FileManager/FileManager.js +11 -13
  161. package/dist/FileManager/FileManager.js.map +1 -1
  162. package/dist/FileManager/initFileManager.d.ts.map +1 -1
  163. package/dist/FileManager/initFileManager.js +60 -62
  164. package/dist/FileManager/initFileManager.js.map +1 -1
  165. package/dist/FileManager/uploadStream.js +2 -2
  166. package/dist/FileManager/uploadStream.js.map +1 -1
  167. package/dist/Filtering.d.ts +1 -1
  168. package/dist/Filtering.d.ts.map +1 -1
  169. package/dist/Filtering.js +12 -35
  170. package/dist/Filtering.js.map +1 -1
  171. package/dist/JSONBValidation/validation.d.ts.map +1 -1
  172. package/dist/JSONBValidation/validation.js +20 -26
  173. package/dist/JSONBValidation/validation.js.map +1 -1
  174. package/dist/Logging.d.ts +1 -0
  175. package/dist/Logging.d.ts.map +1 -1
  176. package/dist/PostgresNotifListenManager.d.ts.map +1 -1
  177. package/dist/PostgresNotifListenManager.js +1 -5
  178. package/dist/PostgresNotifListenManager.js.map +1 -1
  179. package/dist/Prostgles.d.ts +1 -1
  180. package/dist/Prostgles.d.ts.map +1 -1
  181. package/dist/Prostgles.js +18 -33
  182. package/dist/Prostgles.js.map +1 -1
  183. package/dist/PubSubManager/PubSubManager.d.ts.map +1 -1
  184. package/dist/PubSubManager/PubSubManager.js +8 -13
  185. package/dist/PubSubManager/PubSubManager.js.map +1 -1
  186. package/dist/PubSubManager/addSub.d.ts.map +1 -1
  187. package/dist/PubSubManager/addSub.js +1 -1
  188. package/dist/PubSubManager/addSub.js.map +1 -1
  189. package/dist/PubSubManager/addSync.d.ts.map +1 -1
  190. package/dist/PubSubManager/addSync.js +4 -7
  191. package/dist/PubSubManager/addSync.js.map +1 -1
  192. package/dist/PubSubManager/getCreatePubSubManagerError.js +6 -6
  193. package/dist/PubSubManager/getCreatePubSubManagerError.js.map +1 -1
  194. package/dist/PubSubManager/initPubSubManager.d.ts.map +1 -1
  195. package/dist/PubSubManager/initPubSubManager.js +2 -3
  196. package/dist/PubSubManager/initPubSubManager.js.map +1 -1
  197. package/dist/PubSubManager/pushSubData.d.ts.map +1 -1
  198. package/dist/PubSubManager/pushSubData.js +0 -2
  199. package/dist/PubSubManager/pushSubData.js.map +1 -1
  200. package/dist/PublishParser/PublishParser.d.ts.map +1 -1
  201. package/dist/PublishParser/PublishParser.js +8 -13
  202. package/dist/PublishParser/PublishParser.js.map +1 -1
  203. package/dist/PublishParser/getFileTableRules.js +1 -1
  204. package/dist/PublishParser/getFileTableRules.js.map +1 -1
  205. package/dist/PublishParser/getSchemaFromPublish.d.ts.map +1 -1
  206. package/dist/PublishParser/getSchemaFromPublish.js +6 -13
  207. package/dist/PublishParser/getSchemaFromPublish.js.map +1 -1
  208. package/dist/PublishParser/getTableRulesWithoutFileTable.d.ts.map +1 -1
  209. package/dist/PublishParser/getTableRulesWithoutFileTable.js +14 -19
  210. package/dist/PublishParser/getTableRulesWithoutFileTable.js.map +1 -1
  211. package/dist/RestApi.d.ts +1 -1
  212. package/dist/RestApi.d.ts.map +1 -1
  213. package/dist/RestApi.js +2 -2
  214. package/dist/RestApi.js.map +1 -1
  215. package/dist/SchemaWatch/SchemaWatch.d.ts.map +1 -1
  216. package/dist/SchemaWatch/SchemaWatch.js +2 -2
  217. package/dist/SchemaWatch/SchemaWatch.js.map +1 -1
  218. package/dist/SyncReplication.d.ts.map +1 -1
  219. package/dist/SyncReplication.js +31 -41
  220. package/dist/SyncReplication.js.map +1 -1
  221. package/dist/TableConfig/TableConfig.d.ts.map +1 -1
  222. package/dist/TableConfig/TableConfig.js +7 -9
  223. package/dist/TableConfig/TableConfig.js.map +1 -1
  224. package/dist/TableConfig/getConstraintDefinitionQueries.d.ts.map +1 -1
  225. package/dist/TableConfig/getConstraintDefinitionQueries.js +1 -6
  226. package/dist/TableConfig/getConstraintDefinitionQueries.js.map +1 -1
  227. package/dist/TableConfig/getFutureTableSchema.d.ts.map +1 -1
  228. package/dist/TableConfig/getFutureTableSchema.js +16 -28
  229. package/dist/TableConfig/getFutureTableSchema.js.map +1 -1
  230. package/dist/TableConfig/getTableColumnQueries.d.ts.map +1 -1
  231. package/dist/TableConfig/getTableColumnQueries.js +5 -9
  232. package/dist/TableConfig/getTableColumnQueries.js.map +1 -1
  233. package/dist/TableConfig/initTableConfig.d.ts.map +1 -1
  234. package/dist/TableConfig/initTableConfig.js +22 -25
  235. package/dist/TableConfig/initTableConfig.js.map +1 -1
  236. package/dist/initProstgles.js +1 -1
  237. package/dist/initProstgles.js.map +1 -1
  238. package/dist/onSocketConnected.d.ts.map +1 -1
  239. package/dist/onSocketConnected.js +2 -4
  240. package/dist/onSocketConnected.js.map +1 -1
  241. package/dist/runClientRequest.d.ts.map +1 -1
  242. package/dist/runClientRequest.js +14 -13
  243. package/dist/runClientRequest.js.map +1 -1
  244. package/lib/Auth/AuthHandler.ts +114 -135
  245. package/lib/Auth/AuthTypes.ts +96 -81
  246. package/lib/Auth/authProviders/setEmailProvider.ts +29 -0
  247. package/lib/Auth/authProviders/setOAuthProviders.ts +97 -0
  248. package/lib/Auth/endpoints/getConfirmEmailRequestHandler.ts +39 -0
  249. package/lib/Auth/endpoints/getRegisterRequestHandler.ts +88 -0
  250. package/lib/Auth/setAuthProviders.ts +8 -111
  251. package/lib/Auth/setupAuthRoutes.ts +105 -148
  252. package/lib/Auth/utils/checkDmarc.ts +19 -0
  253. package/lib/Auth/utils/getClientRequestIPsInfo.ts +25 -0
  254. package/lib/Auth/utils/getReturnUrl.ts +13 -0
  255. package/lib/DBEventsManager.ts +12 -26
  256. package/lib/DBSchemaBuilder.ts +1 -1
  257. package/lib/DboBuilder/DboBuilder.ts +23 -52
  258. package/lib/DboBuilder/DboBuilderTypes.ts +9 -23
  259. package/lib/DboBuilder/QueryBuilder/Functions.ts +86 -188
  260. package/lib/DboBuilder/QueryBuilder/QueryBuilder.ts +11 -36
  261. package/lib/DboBuilder/QueryBuilder/getNewQuery.ts +102 -129
  262. package/lib/DboBuilder/QueryBuilder/getSelectQuery.ts +14 -27
  263. package/lib/DboBuilder/QueryStreamer.ts +26 -57
  264. package/lib/DboBuilder/TableHandler/DataValidator.ts +58 -90
  265. package/lib/DboBuilder/TableHandler/TableHandler.ts +19 -45
  266. package/lib/DboBuilder/TableHandler/delete.ts +9 -18
  267. package/lib/DboBuilder/TableHandler/insert.ts +18 -31
  268. package/lib/DboBuilder/TableHandler/insertTest.ts +1 -1
  269. package/lib/DboBuilder/TableHandler/runInsertUpdateQuery.ts +8 -19
  270. package/lib/DboBuilder/TableHandler/update.ts +17 -46
  271. package/lib/DboBuilder/TableHandler/updateFile.ts +18 -21
  272. package/lib/DboBuilder/TableHandler/upsert.ts +7 -24
  273. package/lib/DboBuilder/ViewHandler/ViewHandler.ts +13 -15
  274. package/lib/DboBuilder/ViewHandler/count.ts +1 -1
  275. package/lib/DboBuilder/ViewHandler/find.ts +28 -35
  276. package/lib/DboBuilder/ViewHandler/getExistsCondition.ts +8 -30
  277. package/lib/DboBuilder/ViewHandler/getInfo.ts +2 -2
  278. package/lib/DboBuilder/ViewHandler/getTableJoinQuery.ts +16 -32
  279. package/lib/DboBuilder/ViewHandler/parseFieldFilter.ts +9 -16
  280. package/lib/DboBuilder/ViewHandler/parseJoinPath.ts +26 -44
  281. package/lib/DboBuilder/ViewHandler/prepareSortItems.ts +58 -82
  282. package/lib/DboBuilder/ViewHandler/prepareWhere.ts +14 -27
  283. package/lib/DboBuilder/dboBuilderUtils.ts +19 -46
  284. package/lib/DboBuilder/getColumns.ts +24 -46
  285. package/lib/DboBuilder/getCondition.ts +18 -30
  286. package/lib/DboBuilder/getSubscribeRelatedTables.ts +2 -2
  287. package/lib/DboBuilder/getTablesForSchemaPostgresSQL.ts +44 -62
  288. package/lib/DboBuilder/insertNestedRecords.ts +67 -135
  289. package/lib/DboBuilder/parseUpdateRules.ts +1 -1
  290. package/lib/DboBuilder/prepareShortestJoinPaths.ts +23 -58
  291. package/lib/DboBuilder/runSQL.ts +41 -76
  292. package/lib/DboBuilder/uploadFile.ts +26 -37
  293. package/lib/FileManager/FileManager.ts +27 -58
  294. package/lib/FileManager/initFileManager.ts +68 -76
  295. package/lib/FileManager/uploadStream.ts +2 -2
  296. package/lib/Filtering.ts +30 -87
  297. package/lib/JSONBValidation/validation.ts +36 -75
  298. package/lib/Logging.ts +1 -1
  299. package/lib/PostgresNotifListenManager.ts +11 -35
  300. package/lib/Prostgles.ts +42 -100
  301. package/lib/PubSubManager/PubSubManager.ts +30 -66
  302. package/lib/PubSubManager/addSub.ts +11 -18
  303. package/lib/PubSubManager/addSync.ts +5 -12
  304. package/lib/PubSubManager/getCreatePubSubManagerError.ts +9 -9
  305. package/lib/PubSubManager/initPubSubManager.ts +7 -13
  306. package/lib/PubSubManager/pushSubData.ts +1 -7
  307. package/lib/PublishParser/PublishParser.ts +8 -12
  308. package/lib/PublishParser/getFileTableRules.ts +1 -1
  309. package/lib/PublishParser/getSchemaFromPublish.ts +26 -42
  310. package/lib/PublishParser/getTableRulesWithoutFileTable.ts +22 -37
  311. package/lib/RestApi.ts +4 -12
  312. package/lib/SchemaWatch/SchemaWatch.ts +11 -24
  313. package/lib/SyncReplication.ts +96 -190
  314. package/lib/TableConfig/TableConfig.ts +16 -38
  315. package/lib/TableConfig/getConstraintDefinitionQueries.ts +2 -8
  316. package/lib/TableConfig/getFutureTableSchema.ts +20 -34
  317. package/lib/TableConfig/getTableColumnQueries.ts +13 -35
  318. package/lib/TableConfig/initTableConfig.ts +40 -64
  319. package/lib/initProstgles.ts +1 -1
  320. package/lib/onSocketConnected.ts +8 -12
  321. package/lib/runClientRequest.ts +31 -54
  322. package/package.json +2 -2
  323. package/dist/Auth/getSafeReturnURL.d.ts.map +0 -1
  324. package/dist/Auth/getSafeReturnURL.js.map +0 -1
  325. package/dist/Auth/setEmailProvider.d.ts.map +0 -1
  326. package/dist/Auth/setEmailProvider.js +0 -133
  327. package/dist/Auth/setEmailProvider.js.map +0 -1
  328. package/dist/DboBuilder/runTransaction.d.ts +0 -9
  329. package/dist/DboBuilder/runTransaction.d.ts.map +0 -1
  330. package/dist/DboBuilder/runTransaction.js +0 -49
  331. package/dist/DboBuilder/runTransaction.js.map +0 -1
  332. package/lib/Auth/setEmailProvider.ts +0 -132
  333. package/lib/DboBuilder/QueryBuilder/prepareHaving.ts +0 -27
  334. package/lib/DboBuilder/runTransaction.ts +0 -61
  335. package/lib/SchemaWatch/createSchemaWatchEventTrigger.ts +0 -3
  336. /package/dist/Auth/{getSafeReturnURL.d.ts → utils/getSafeReturnURL.d.ts} +0 -0
  337. /package/dist/Auth/{getSafeReturnURL.js → utils/getSafeReturnURL.js} +0 -0
  338. /package/lib/Auth/{getSafeReturnURL.ts → utils/getSafeReturnURL.ts} +0 -0
@@ -1,26 +1,13 @@
1
- import { RequestHandler } from "express";
1
+ import { RequestHandler, Response } from "express";
2
+ import { AuthResponse } from "prostgles-types";
2
3
  import { DBOFullyTyped } from "../DBSchemaBuilder";
3
- import {
4
- AUTH_ROUTES_AND_PARAMS,
5
- AuthHandler,
6
- getLoginClientInfo,
7
- HTTPCODES,
8
- } from "./AuthHandler";
9
- import {
10
- AuthClientRequest,
11
- ExpressReq,
12
- ExpressRes,
13
- LoginParams,
14
- } from "./AuthTypes";
15
- import {
16
- setAuthProviders,
17
- upsertNamedExpressMiddleware,
18
- } from "./setAuthProviders";
19
-
4
+ import { AUTH_ROUTES_AND_PARAMS, AuthHandler, HTTP_FAIL_CODES } from "./AuthHandler";
5
+ import { AuthClientRequest, ExpressReq, ExpressRes, LoginParams } from "./AuthTypes";
6
+ import { setAuthProviders, upsertNamedExpressMiddleware } from "./setAuthProviders";
7
+ import { getClientRequestIPsInfo } from "./utils/getClientRequestIPsInfo";
8
+ import { getReturnUrl } from "./utils/getReturnUrl";
20
9
  export async function setupAuthRoutes(this: AuthHandler) {
21
- if (!this.opts) return;
22
-
23
- const { login, getUser, expressConfig } = this.opts;
10
+ const { login, expressConfig } = this.opts;
24
11
 
25
12
  if (!login) {
26
13
  throw "Invalid auth: Provide { sidKeyName: string } ";
@@ -30,18 +17,10 @@ export async function setupAuthRoutes(this: AuthHandler) {
30
17
  throw "sidKeyName cannot be 'sid' due to collision with socket.io";
31
18
  }
32
19
 
33
- if (!getUser) throw "getUser missing from auth config";
34
-
35
20
  if (!expressConfig) {
36
21
  return;
37
22
  }
38
- const {
39
- app,
40
- publicRoutes = [],
41
- onGetRequestOK,
42
- magicLinks,
43
- use,
44
- } = expressConfig;
23
+ const { app, publicRoutes = [], onGetRequestOK, onMagicLink, use } = expressConfig;
45
24
  if (publicRoutes.find((r) => typeof r !== "string" || !r)) {
46
25
  throw "Invalid or empty string provided within publicRoutes ";
47
26
  }
@@ -59,79 +38,66 @@ export async function setupAuthRoutes(this: AuthHandler) {
59
38
  db: this.db,
60
39
  });
61
40
  };
62
- upsertNamedExpressMiddleware(
63
- app,
64
- prostglesUseMiddleware,
65
- "prostglesUseMiddleware",
66
- );
41
+ upsertNamedExpressMiddleware(app, prostglesUseMiddleware, "prostglesUseMiddleware");
67
42
  }
68
43
 
69
- if (magicLinks) {
70
- const { check } = magicLinks;
71
- if (!check) {
72
- throw "Check must be defined for magicLinks";
73
- }
74
-
44
+ if (onMagicLink) {
75
45
  app.get(
76
46
  AUTH_ROUTES_AND_PARAMS.magicLinksExpressRoute,
77
- async (req: ExpressReq, res: ExpressRes) => {
78
- const { id } = req.params ?? {};
47
+ async (
48
+ req: ExpressReq,
49
+ res: Response<AuthResponse.MagicLinkAuthFailure | AuthResponse.MagicLinkAuthSuccess>
50
+ ) => {
51
+ const { id } = req.params;
79
52
 
80
53
  if (typeof id !== "string" || !id) {
81
54
  res
82
- .status(HTTPCODES.BAD_REQUEST)
83
- .json({ msg: "Invalid magic-link id. Expecting a string" });
55
+ .status(HTTP_FAIL_CODES.BAD_REQUEST)
56
+ .json({ success: false, code: "something-went-wrong", message: "Invalid magic link" });
84
57
  } else {
85
58
  try {
86
- const session = await this.throttledFunc(async () => {
87
- return check(
59
+ const response = await this.throttledFunc(async () => {
60
+ return onMagicLink(
88
61
  id,
89
62
  this.dbo as any,
90
63
  this.db,
91
- getLoginClientInfo({ httpReq: req }),
64
+ getClientRequestIPsInfo({ httpReq: req })
92
65
  );
93
66
  });
94
- if (!session) {
95
- res
96
- .status(HTTPCODES.AUTH_ERROR)
97
- .json({ error: "Invalid magic-link" });
67
+ if (!response.session) {
68
+ res.status(HTTP_FAIL_CODES.UNAUTHORIZED).json(response.response);
98
69
  } else {
99
- this.setCookieAndGoToReturnURLIFSet(session, { req, res });
70
+ this.setCookieAndGoToReturnURLIFSet(response.session, { req, res });
100
71
  }
101
72
  } catch (e) {
102
- res.status(HTTPCODES.AUTH_ERROR).json({ error: e });
73
+ res
74
+ .status(HTTP_FAIL_CODES.UNAUTHORIZED)
75
+ .json({ success: false, code: "something-went-wrong" });
103
76
  }
104
77
  }
105
- },
78
+ }
106
79
  );
107
80
  }
108
81
 
109
- app.post(
110
- AUTH_ROUTES_AND_PARAMS.login,
111
- async (req: ExpressReq, res: ExpressRes) => {
112
- try {
113
- const loginParams: LoginParams = {
114
- type: "username",
115
- ...req.body,
116
- };
117
-
118
- await this.loginThrottledAndSetCookie(req, res, loginParams);
119
- } catch (error) {
120
- res.status(HTTPCODES.AUTH_ERROR).json({ error });
121
- }
122
- },
123
- );
82
+ app.post(AUTH_ROUTES_AND_PARAMS.login, async (req: ExpressReq, res: ExpressRes) => {
83
+ try {
84
+ const loginParams: LoginParams = {
85
+ type: "username",
86
+ ...req.body,
87
+ };
88
+
89
+ await this.loginThrottledAndSetCookie(req, res, loginParams);
90
+ } catch (error) {
91
+ res.status(HTTP_FAIL_CODES.BAD_REQUEST).json({ error });
92
+ }
93
+ });
124
94
 
125
95
  const onLogout = async (req: ExpressReq, res: ExpressRes) => {
126
- const sid = this.validateSid(req?.cookies?.[this.sidKeyName]);
96
+ const sid = this.validateSid(req.cookies?.[this.sidKeyName]);
127
97
  if (sid) {
128
98
  try {
129
99
  await this.throttledFunc(() => {
130
- return this.opts?.logout?.(
131
- req?.cookies?.[this.sidKeyName],
132
- this.dbo as any,
133
- this.db,
134
- );
100
+ return this.opts.logout?.(req.cookies?.[this.sidKeyName], this.dbo as any, this.db);
135
101
  });
136
102
  } catch (err) {
137
103
  console.error(err);
@@ -141,83 +107,74 @@ export async function setupAuthRoutes(this: AuthHandler) {
141
107
  };
142
108
 
143
109
  /* Redirect if not logged in and requesting non public content */
144
- app.get(
145
- AUTH_ROUTES_AND_PARAMS.catchAll,
146
- async (req: ExpressReq, res: ExpressRes, next) => {
147
- const clientReq: AuthClientRequest = { httpReq: req };
148
- const getUser = this.getUser;
149
- if (this.prostgles.restApi) {
150
- if (
151
- Object.values(this.prostgles.restApi.routes).some((restRoute) =>
152
- this.matchesRoute(restRoute.split("/:")[0], req.path),
153
- )
154
- ) {
155
- next();
156
- return;
157
- }
110
+ app.get(AUTH_ROUTES_AND_PARAMS.catchAll, async (req: ExpressReq, res: ExpressRes, next) => {
111
+ const clientReq: AuthClientRequest = { httpReq: req };
112
+ const getUser = this.getUser;
113
+ if (this.prostgles.restApi) {
114
+ if (
115
+ Object.values(this.prostgles.restApi.routes).some((restRoute) =>
116
+ this.matchesRoute(restRoute.split("/:")[0], req.path)
117
+ )
118
+ ) {
119
+ next();
120
+ return;
158
121
  }
159
- try {
160
- const returnURL = this.getReturnUrl(req);
161
-
162
- if (this.matchesRoute(AUTH_ROUTES_AND_PARAMS.logoutGetPath, req.path)) {
163
- await onLogout(req, res);
164
- return;
165
- }
166
-
167
- if (
168
- this.matchesRoute(AUTH_ROUTES_AND_PARAMS.loginWithProvider, req.path)
169
- ) {
170
- next();
171
- return;
172
- }
173
- /**
174
- * Requesting a User route
175
- */
176
- if (this.isUserRoute(req.path)) {
177
- /* Check auth. Redirect to login if unauthorized */
178
- const u = await getUser(clientReq);
179
- if (!u) {
180
- res.redirect(
181
- `${AUTH_ROUTES_AND_PARAMS.login}?returnURL=${encodeURIComponent(req.originalUrl)}`,
182
- );
183
- return;
184
- }
122
+ }
123
+ try {
124
+ const returnURL = getReturnUrl(req);
185
125
 
186
- /* If authorized and going to returnUrl then redirect. Otherwise serve file */
187
- } else if (returnURL && (await getUser(clientReq))) {
188
- res.redirect(returnURL);
189
- return;
126
+ if (this.matchesRoute(AUTH_ROUTES_AND_PARAMS.logoutGetPath, req.path)) {
127
+ await onLogout(req, res);
128
+ return;
129
+ }
190
130
 
191
- /** If Logged in and requesting login then redirect to main page */
192
- } else if (
193
- this.matchesRoute(AUTH_ROUTES_AND_PARAMS.login, req.path) &&
194
- (await getUser(clientReq))
195
- ) {
196
- res.redirect("/");
131
+ if (this.matchesRoute(AUTH_ROUTES_AND_PARAMS.loginWithProvider, req.path)) {
132
+ next();
133
+ return;
134
+ }
135
+ /**
136
+ * Requesting a User route
137
+ */
138
+ if (this.isUserRoute(req.path)) {
139
+ /* Check auth. Redirect to login if unauthorized */
140
+ const u = await getUser(clientReq);
141
+ if (!u) {
142
+ res.redirect(
143
+ `${AUTH_ROUTES_AND_PARAMS.login}?returnURL=${encodeURIComponent(req.originalUrl)}`
144
+ );
197
145
  return;
198
146
  }
199
147
 
200
- onGetRequestOK?.(req, res, {
201
- getUser: () => getUser(clientReq),
202
- dbo: this.dbo as DBOFullyTyped,
203
- db: this.db,
204
- });
205
- } catch (error) {
206
- console.error(error);
207
- const errorMessage =
208
- typeof error === "string"
209
- ? error
210
- : error instanceof Error
211
- ? error.message
212
- : "";
213
- res
214
- .status(HTTPCODES.AUTH_ERROR)
215
- .json({
216
- error:
217
- "Something went wrong when processing your request" +
218
- (errorMessage ? ": " + errorMessage : ""),
219
- });
148
+ /* If authorized and going to returnUrl then redirect. Otherwise serve file */
149
+ } else if (returnURL && (await getUser(clientReq))) {
150
+ res.redirect(returnURL);
151
+ return;
152
+
153
+ /** If Logged in and requesting login then redirect to main page */
154
+ } else if (
155
+ this.matchesRoute(AUTH_ROUTES_AND_PARAMS.login, req.path) &&
156
+ (await getUser(clientReq))
157
+ ) {
158
+ res.redirect("/");
159
+ return;
220
160
  }
221
- },
222
- );
161
+
162
+ onGetRequestOK?.(req, res, {
163
+ getUser: () => getUser(clientReq),
164
+ dbo: this.dbo as DBOFullyTyped,
165
+ db: this.db,
166
+ });
167
+ } catch (error) {
168
+ console.error(error);
169
+ const errorMessage =
170
+ typeof error === "string" ? error
171
+ : error instanceof Error ? error.message
172
+ : "";
173
+ res.status(HTTP_FAIL_CODES.UNAUTHORIZED).json({
174
+ error:
175
+ "Something went wrong when processing your request" +
176
+ (errorMessage ? ": " + errorMessage : ""),
177
+ });
178
+ }
179
+ });
223
180
  }
@@ -0,0 +1,19 @@
1
+ import { promises } from "node:dns";
2
+
3
+ export const checkDmarc = async (websiteUrl: string) => {
4
+ const { host, hostname } = new URL(websiteUrl);
5
+ const ignoredHosts = ["localhost", "127.0.0.1"];
6
+ if (!hostname || ignoredHosts.includes(hostname)) {
7
+ return;
8
+ }
9
+ const dmarc = await promises.resolveTxt(`_dmarc.${host}`);
10
+ const dmarkTxt = dmarc[0]?.[0];
11
+ if (
12
+ !dmarkTxt?.includes("v=DMARC1") ||
13
+ (!dmarkTxt.includes("p=reject") && !dmarkTxt.includes("p=quarantine"))
14
+ ) {
15
+ throw new Error("DMARC not set to reject/quarantine");
16
+ } else {
17
+ console.log("DMARC set to reject");
18
+ }
19
+ };
@@ -0,0 +1,25 @@
1
+ import { AuthClientRequest, LoginClientInfo } from "../AuthTypes";
2
+ export const getClientRequestIPsInfo = <T extends AuthClientRequest>(
3
+ req: T
4
+ ): T & LoginClientInfo => {
5
+ if (req.httpReq) {
6
+ const ip_address = req.httpReq.ip;
7
+ if (!ip_address) throw new Error("ip_address missing from req.httpReq");
8
+ const user_agent = req.httpReq.headers["user-agent"];
9
+ return {
10
+ ...req,
11
+ ip_address,
12
+ ip_address_remote: req.httpReq.connection.remoteAddress,
13
+ x_real_ip: req.httpReq.headers["x-real-ip"] as any,
14
+ user_agent,
15
+ };
16
+ } else {
17
+ return {
18
+ ...req,
19
+ ip_address: req.socket.handshake.address,
20
+ ip_address_remote: req.socket.request.connection.remoteAddress,
21
+ x_real_ip: req.socket.handshake.headers?.["x-real-ip"],
22
+ user_agent: req.socket.handshake.headers?.["user-agent"],
23
+ };
24
+ }
25
+ };
@@ -0,0 +1,13 @@
1
+ import { AUTH_ROUTES_AND_PARAMS } from "../AuthHandler";
2
+ import { ExpressReq } from "../AuthTypes";
3
+ import { getSafeReturnURL } from "./getSafeReturnURL";
4
+
5
+ export const getReturnUrl = (req: ExpressReq) => {
6
+ const { returnUrlParamName } = AUTH_ROUTES_AND_PARAMS;
7
+ if (req.query[returnUrlParamName]) {
8
+ const returnURL = decodeURIComponent(req.query[returnUrlParamName] as string);
9
+
10
+ return getSafeReturnURL(returnURL, returnUrlParamName);
11
+ }
12
+ return null;
13
+ };
@@ -1,7 +1,4 @@
1
- import {
2
- PostgresNotifListenManager,
3
- PrglNotifListener,
4
- } from "./PostgresNotifListenManager";
1
+ import { PostgresNotifListenManager, PrglNotifListener } from "./PostgresNotifListenManager";
5
2
  import { DB, PGP } from "./Prostgles";
6
3
  import { getKeys, CHANNELS } from "prostgles-types";
7
4
  import { PRGLIOSocket } from "./DboBuilder/DboBuilder";
@@ -53,7 +50,7 @@ export class DBEventsManager {
53
50
  };
54
51
 
55
52
  onNotice = (notice: any) => {
56
- if (this.notice && this.notice.sockets.length) {
53
+ if (this.notice.sockets.length) {
57
54
  this.notice.sockets.map((s) => {
58
55
  s.emit(this.notice.socketChannel, notice);
59
56
  });
@@ -68,7 +65,7 @@ export class DBEventsManager {
68
65
  async addNotify(
69
66
  query: string,
70
67
  socket?: PRGLIOSocket,
71
- func?: any,
68
+ func?: any
72
69
  ): Promise<{
73
70
  socketChannel: string;
74
71
  socketUnsubChannel: string;
@@ -120,17 +117,10 @@ export class DBEventsManager {
120
117
  socketChannel,
121
118
  sockets: socket ? [socket] : [],
122
119
  localFuncs: func ? [func] : [],
123
- notifMgr: await PostgresNotifListenManager.create(
124
- this.db_pg,
125
- this.onNotif,
126
- channel,
127
- ),
120
+ notifMgr: await PostgresNotifListenManager.create(this.db_pg, this.onNotif, channel),
128
121
  };
129
122
  } else {
130
- if (
131
- socket &&
132
- !this.notifies[notifChannel]!.sockets.find((s) => s.id === socket.id)
133
- ) {
123
+ if (socket && !this.notifies[notifChannel]!.sockets.find((s) => s.id === socket.id)) {
134
124
  this.notifies[notifChannel]!.sockets.push(socket);
135
125
  } else if (func) {
136
126
  this.notifies[notifChannel]!.localFuncs.push(func);
@@ -155,13 +145,9 @@ export class DBEventsManager {
155
145
  const notifChannel = channel && this.notifies[channel];
156
146
  if (notifChannel) {
157
147
  if (socket) {
158
- notifChannel.sockets = notifChannel.sockets.filter(
159
- (s) => s.id !== socket.id,
160
- );
148
+ notifChannel.sockets = notifChannel.sockets.filter((s) => s.id !== socket.id);
161
149
  } else if (func) {
162
- notifChannel.localFuncs = notifChannel.localFuncs.filter(
163
- (f) => f !== func,
164
- );
150
+ notifChannel.localFuncs = notifChannel.localFuncs.filter((f) => f !== func);
165
151
  }
166
152
 
167
153
  /* UNLISTEN if no listeners ?? */
@@ -169,15 +155,15 @@ export class DBEventsManager {
169
155
 
170
156
  if (socket) {
171
157
  getKeys(this.notifies).forEach((channel) => {
172
- this.notifies[channel]!.sockets = this.notifies[
173
- channel
174
- ]!.sockets.filter((s) => s.id !== socket.id);
158
+ this.notifies[channel]!.sockets = this.notifies[channel]!.sockets.filter(
159
+ (s) => s.id !== socket.id
160
+ );
175
161
  });
176
162
  }
177
163
  }
178
164
 
179
165
  addNotice(socket: PRGLIOSocket) {
180
- if (!socket || !socket.id) throw "Expecting a socket obj with id";
166
+ if (!socket.id) throw "Expecting a socket obj with id";
181
167
 
182
168
  if (!this.notice.sockets.find((s) => s.id === socket.id)) {
183
169
  this.notice.sockets.push(socket);
@@ -194,7 +180,7 @@ export class DBEventsManager {
194
180
  }
195
181
 
196
182
  removeNotice(socket: PRGLIOSocket) {
197
- if (!socket || !socket.id) throw "Expecting a socket obj with id";
183
+ if (!socket.id) throw "Expecting a socket obj with id";
198
184
  this.notice.sockets = this.notice.sockets.filter((s) => s.id !== socket.id);
199
185
  }
200
186
  }
@@ -196,7 +196,7 @@ export type PublishFullyTyped<Schema = void> = Schema extends DBSchema
196
196
  transactions: true,
197
197
  onReady: ({ dbo }) => {
198
198
  dbo.tdwa?.find!();
199
- dbo.tx?.((t) => {
199
+ dbo.tx((t) => {
200
200
  t.dwa?.find!();
201
201
  });
202
202
  },
@@ -40,7 +40,6 @@ import {
40
40
  import { getTablesForSchemaPostgresSQL } from "./getTablesForSchemaPostgresSQL";
41
41
  import { prepareShortestJoinPaths } from "./prepareShortestJoinPaths";
42
42
  import { cacheDBTypes, runSQL } from "./runSQL";
43
- import { runClientTransactionStatement } from "./runTransaction";
44
43
 
45
44
  export * from "./DboBuilderTypes";
46
45
  export * from "./dboBuilderUtils";
@@ -167,9 +166,7 @@ export class DboBuilder {
167
166
 
168
167
  _joins?: Join[];
169
168
  get joins(): Join[] {
170
- return clone(this._joins ?? []).filter(
171
- (j) => j.tables[0] !== j.tables[1],
172
- ) as Join[];
169
+ return clone(this._joins ?? []).filter((j) => j.tables[0] !== j.tables[1]) as Join[];
173
170
  }
174
171
 
175
172
  set joins(j: Join[]) {
@@ -181,8 +178,7 @@ export class DboBuilder {
181
178
  }
182
179
 
183
180
  prepareShortestJoinPaths = async () => {
184
- const { joins, shortestJoinPaths, joinGraph } =
185
- await prepareShortestJoinPaths(this);
181
+ const { joins, shortestJoinPaths, joinGraph } = await prepareShortestJoinPaths(this);
186
182
  this.joinGraph = joinGraph;
187
183
  this.joins = joins;
188
184
  this.shortestJoinPaths = shortestJoinPaths;
@@ -192,7 +188,7 @@ export class DboBuilder {
192
188
  query: string,
193
189
  params: any,
194
190
  options: SQLOptions | undefined,
195
- localParams?: LocalParams,
191
+ localParams?: LocalParams
196
192
  ) => {
197
193
  return runSQL
198
194
  .bind(this)(query, params, options, localParams)
@@ -201,8 +197,8 @@ export class DboBuilder {
201
197
  getSerializedClientErrorFromPGError(error, {
202
198
  type: "sql",
203
199
  localParams,
204
- }),
205
- ),
200
+ })
201
+ )
206
202
  );
207
203
  };
208
204
 
@@ -215,7 +211,7 @@ export class DboBuilder {
215
211
  if (subscribeError) {
216
212
  console.error(
217
213
  "Could not initiate PubSubManager. Realtime data/Subscriptions will not work. Error: ",
218
- subscribeError,
214
+ subscribeError
219
215
  );
220
216
  this.canSubscribe = false;
221
217
  } else {
@@ -226,7 +222,7 @@ export class DboBuilder {
226
222
  const start = Date.now();
227
223
  const tablesOrViewsReq = await getTablesForSchemaPostgresSQL(
228
224
  this,
229
- this.prostgles.opts.schemaFilter,
225
+ this.prostgles.opts.schemaFilter
230
226
  );
231
227
  await this.prostgles.opts.onLog?.({
232
228
  type: "debug",
@@ -236,36 +232,30 @@ export class DboBuilder {
236
232
  });
237
233
  this.tablesOrViews = tablesOrViewsReq.result;
238
234
 
239
- this.constraints = await getConstraints(
240
- this.db,
241
- this.prostgles.opts.schemaFilter,
242
- );
235
+ this.constraints = await getConstraints(this.db, this.prostgles.opts.schemaFilter);
243
236
  await this.prepareShortestJoinPaths();
244
237
 
245
238
  this.dbo = {};
246
239
  this.tablesOrViews.map((tov) => {
247
- const columnsForTypes = tov.columns
248
- .slice(0)
249
- .sort((a, b) => a.name.localeCompare(b.name));
240
+ const columnsForTypes = tov.columns.slice(0).sort((a, b) => a.name.localeCompare(b.name));
250
241
 
251
242
  const filterKeywords = Object.values(this.prostgles.keywords);
252
- const $filterCol = columnsForTypes.find((c) =>
253
- filterKeywords.includes(c.name),
254
- );
243
+ const $filterCol = columnsForTypes.find((c) => filterKeywords.includes(c.name));
255
244
  if ($filterCol) {
256
245
  throw `DboBuilder init error: \n\nTable ${JSON.stringify(tov.name)} column ${JSON.stringify($filterCol.name)} is colliding with Prostgles filtering functionality ($filter keyword)
257
246
  Please provide a replacement keyword name using the $filter_keyName init option.
258
247
  Alternatively you can rename the table column\n`;
259
248
  }
260
249
 
261
- this.dbo[tov.escaped_identifier] = new (
262
- tov.is_view ? ViewHandler : TableHandler
263
- )(this.db, tov, this, undefined, this.shortestJoinPaths);
250
+ this.dbo[tov.escaped_identifier] = new (tov.is_view ? ViewHandler : TableHandler)(
251
+ this.db,
252
+ tov,
253
+ this,
254
+ undefined,
255
+ this.shortestJoinPaths
256
+ );
264
257
 
265
- if (
266
- this.shortestJoinPaths &&
267
- this.shortestJoinPaths.find((jp) => [jp.t1, jp.t2].includes(tov.name))
268
- ) {
258
+ if (this.shortestJoinPaths.find((jp) => [jp.t1, jp.t2].includes(tov.name))) {
269
259
  const table = tov.name;
270
260
 
271
261
  this.dbo.innerJoin ??= {};
@@ -293,9 +283,7 @@ export class DboBuilder {
293
283
  if (!this.dbo.sql) {
294
284
  this.dbo.sql = this.runSQL;
295
285
  } else {
296
- console.warn(
297
- `Could not create dbo.sql handler because there is already a table named "sql"`,
298
- );
286
+ console.warn(`Could not create dbo.sql handler because there is already a table named "sql"`);
299
287
  }
300
288
 
301
289
  this.tsTypesDefinition = [
@@ -309,18 +297,16 @@ export class DboBuilder {
309
297
 
310
298
  getShortestJoinPath = (
311
299
  viewHandler: ViewHandler,
312
- target: string,
300
+ target: string
313
301
  ): JoinPaths[number] | undefined => {
314
302
  const source = viewHandler.name;
315
303
  if (source === target) {
316
- const joinPath = parseJoinPath({
304
+ parseJoinPath({
317
305
  rawPath: target,
318
306
  rootTable: source,
319
307
  viewHandler,
320
308
  });
321
309
 
322
- if (!joinPath) return undefined;
323
-
324
310
  return {
325
311
  t1: source,
326
312
  t2: target,
@@ -328,9 +314,7 @@ export class DboBuilder {
328
314
  };
329
315
  }
330
316
 
331
- const jp = this.shortestJoinPaths.find(
332
- (jp) => jp.t1 === source && jp.t2 === target,
333
- );
317
+ const jp = this.shortestJoinPaths.find((jp) => jp.t1 === source && jp.t2 === target);
334
318
  return jp;
335
319
  };
336
320
 
@@ -339,13 +323,7 @@ export class DboBuilder {
339
323
  const dbTX: DbTxTableHandlers & Pick<DBHandlerServer, "sql"> = {};
340
324
  this.tablesOrViews?.map((tov) => {
341
325
  const handlerClass = tov.is_view ? ViewHandler : TableHandler;
342
- dbTX[tov.name] = new handlerClass(
343
- this.db,
344
- tov,
345
- this,
346
- { t, dbTX },
347
- this.shortestJoinPaths,
348
- );
326
+ dbTX[tov.name] = new handlerClass(this.db, tov, this, { t, dbTX }, this.shortestJoinPaths);
349
327
  });
350
328
  dbTX.sql = (q, args, opts, localP) =>
351
329
  this.runSQL(q, args, opts, { tx: { dbTX, t }, ...(localP ?? {}) });
@@ -357,11 +335,4 @@ export class DboBuilder {
357
335
  };
358
336
 
359
337
  cacheDBTypes = cacheDBTypes.bind(this);
360
-
361
- runClientTransactionStatement = (statement: string) => {
362
- return runClientTransactionStatement(
363
- statement,
364
- this.prostgles.opts.dbConnection as any,
365
- );
366
- };
367
338
  }