@axinom/mosaic-db-common 0.57.0 → 0.58.0-rc.3

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 (393) hide show
  1. package/README.md +9 -3
  2. package/dist/cjs/auth/authentication-subject.d.ts.map +1 -0
  3. package/dist/cjs/auth/authentication-subject.js.map +1 -0
  4. package/dist/{auth → cjs/auth}/helpers.d.ts +2 -2
  5. package/dist/cjs/auth/helpers.d.ts.map +1 -0
  6. package/dist/cjs/auth/helpers.js +58 -0
  7. package/dist/cjs/auth/helpers.js.map +1 -0
  8. package/dist/cjs/auth/index.d.ts +3 -0
  9. package/dist/cjs/auth/index.d.ts.map +1 -0
  10. package/dist/{auth → cjs/auth}/index.js +2 -2
  11. package/dist/cjs/auth/index.js.map +1 -0
  12. package/dist/{cli → cjs/cli}/commands/generate-define-func-migration.d.ts +1 -1
  13. package/dist/cjs/cli/commands/generate-define-func-migration.d.ts.map +1 -0
  14. package/dist/{cli → cjs/cli}/commands/generate-define-func-migration.js +6 -5
  15. package/dist/cjs/cli/commands/generate-define-func-migration.js.map +1 -0
  16. package/dist/{cli → cjs/cli}/commands/generate-vscode-sql-snippets.d.ts +1 -1
  17. package/dist/cjs/cli/commands/generate-vscode-sql-snippets.d.ts.map +1 -0
  18. package/dist/{cli → cjs/cli}/commands/generate-vscode-sql-snippets.js +35 -71
  19. package/dist/cjs/cli/commands/generate-vscode-sql-snippets.js.map +1 -0
  20. package/dist/cjs/cli/commands/index.d.ts +3 -0
  21. package/dist/cjs/cli/commands/index.d.ts.map +1 -0
  22. package/dist/{cli → cjs/cli}/commands/index.js +2 -2
  23. package/dist/cjs/cli/commands/index.js.map +1 -0
  24. package/dist/cjs/cli/commands/utils.d.ts.map +1 -0
  25. package/dist/cjs/cli/commands/utils.js.map +1 -0
  26. package/dist/{cli → cjs/cli}/index.d.ts +1 -1
  27. package/dist/cjs/cli/index.d.ts.map +1 -0
  28. package/dist/{cli → cjs/cli}/index.js +3 -3
  29. package/dist/cjs/cli/index.js.map +1 -0
  30. package/dist/cjs/common/find-up.d.ts +2 -0
  31. package/dist/cjs/common/find-up.d.ts.map +1 -0
  32. package/dist/cjs/common/find-up.js +18 -0
  33. package/dist/cjs/common/find-up.js.map +1 -0
  34. package/dist/cjs/common/index.d.ts +2 -0
  35. package/dist/cjs/common/index.d.ts.map +1 -0
  36. package/dist/{common → cjs/common}/index.js +1 -1
  37. package/dist/cjs/common/index.js.map +1 -0
  38. package/dist/cjs/common/package-root.d.ts +2 -0
  39. package/dist/cjs/common/package-root.d.ts.map +1 -0
  40. package/dist/cjs/common/package-root.js +46 -0
  41. package/dist/cjs/common/package-root.js.map +1 -0
  42. package/dist/{common → cjs/common}/types.d.ts +1 -1
  43. package/dist/cjs/common/types.d.ts.map +1 -0
  44. package/dist/{common → cjs/common}/types.js.map +1 -1
  45. package/dist/cjs/constants/index.d.ts +2 -0
  46. package/dist/cjs/constants/index.d.ts.map +1 -0
  47. package/dist/cjs/constants/index.js +18 -0
  48. package/dist/cjs/constants/index.js.map +1 -0
  49. package/dist/cjs/constants/pg-auth-settings-keys.d.ts.map +1 -0
  50. package/dist/cjs/constants/pg-auth-settings-keys.js.map +1 -0
  51. package/dist/cjs/index.d.ts +11 -0
  52. package/dist/cjs/index.d.ts.map +1 -0
  53. package/dist/cjs/index.js +27 -0
  54. package/dist/cjs/index.js.map +1 -0
  55. package/dist/cjs/messaging/index.d.ts +2 -0
  56. package/dist/cjs/messaging/index.d.ts.map +1 -0
  57. package/dist/{messaging → cjs/messaging}/index.js +1 -1
  58. package/dist/cjs/messaging/index.js.map +1 -0
  59. package/dist/{messaging → cjs/messaging}/messaging-counter.d.ts +1 -1
  60. package/dist/cjs/messaging/messaging-counter.d.ts.map +1 -0
  61. package/dist/cjs/messaging/messaging-counter.js.map +1 -0
  62. package/dist/cjs/middleware/index.d.ts +2 -0
  63. package/dist/cjs/middleware/index.d.ts.map +1 -0
  64. package/dist/{constants → cjs/middleware}/index.js +1 -1
  65. package/dist/cjs/middleware/index.js.map +1 -0
  66. package/dist/{middleware → cjs/middleware}/pg-pool.middleware.d.ts +3 -3
  67. package/dist/cjs/middleware/pg-pool.middleware.d.ts.map +1 -0
  68. package/dist/{middleware → cjs/middleware}/pg-pool.middleware.js +13 -3
  69. package/dist/cjs/middleware/pg-pool.middleware.js.map +1 -0
  70. package/dist/{migrations → cjs/migrations}/compare-migration-hashes-helpers.d.ts +2 -2
  71. package/dist/cjs/migrations/compare-migration-hashes-helpers.d.ts.map +1 -0
  72. package/dist/cjs/migrations/compare-migration-hashes-helpers.js +149 -0
  73. package/dist/cjs/migrations/compare-migration-hashes-helpers.js.map +1 -0
  74. package/dist/{migrations → cjs/migrations}/compare-migration-hashes.d.ts +2 -2
  75. package/dist/cjs/migrations/compare-migration-hashes.d.ts.map +1 -0
  76. package/dist/{migrations → cjs/migrations}/compare-migration-hashes.js +4 -4
  77. package/dist/cjs/migrations/compare-migration-hashes.js.map +1 -0
  78. package/dist/{migrations → cjs/migrations}/create-migrations-logger.d.ts +1 -1
  79. package/dist/cjs/migrations/create-migrations-logger.d.ts.map +1 -0
  80. package/dist/{migrations → cjs/migrations}/create-migrations-logger.js +8 -5
  81. package/dist/cjs/migrations/create-migrations-logger.js.map +1 -0
  82. package/dist/cjs/migrations/index.d.ts +5 -0
  83. package/dist/cjs/migrations/index.d.ts.map +1 -0
  84. package/dist/cjs/migrations/index.js +21 -0
  85. package/dist/cjs/migrations/index.js.map +1 -0
  86. package/dist/cjs/migrations/types.d.ts.map +1 -0
  87. package/dist/cjs/migrations/types.js.map +1 -0
  88. package/dist/cjs/migrations/utils.d.ts +70 -0
  89. package/dist/cjs/migrations/utils.d.ts.map +1 -0
  90. package/dist/cjs/migrations/utils.js +121 -0
  91. package/dist/cjs/migrations/utils.js.map +1 -0
  92. package/dist/cjs/monitoring/index.d.ts +2 -0
  93. package/dist/cjs/monitoring/index.d.ts.map +1 -0
  94. package/dist/{middleware → cjs/monitoring}/index.js +1 -1
  95. package/dist/cjs/monitoring/index.js.map +1 -0
  96. package/dist/{monitoring → cjs/monitoring}/postgres-metrics.d.ts +3 -3
  97. package/dist/cjs/monitoring/postgres-metrics.d.ts.map +1 -0
  98. package/dist/cjs/monitoring/postgres-metrics.js.map +1 -0
  99. package/dist/cjs/package.json +1 -0
  100. package/dist/{replication → cjs/replication}/create-logical-replication-service.d.ts +2 -2
  101. package/dist/cjs/replication/create-logical-replication-service.d.ts.map +1 -0
  102. package/dist/{replication → cjs/replication}/create-logical-replication-service.js +6 -4
  103. package/dist/cjs/replication/create-logical-replication-service.js.map +1 -0
  104. package/dist/{replication → cjs/replication}/ensure-replication-slot-and-publication-exist.d.ts +3 -3
  105. package/dist/cjs/replication/ensure-replication-slot-and-publication-exist.d.ts.map +1 -0
  106. package/dist/{replication → cjs/replication}/ensure-replication-slot-and-publication-exist.js +2 -2
  107. package/dist/cjs/replication/ensure-replication-slot-and-publication-exist.js.map +1 -0
  108. package/dist/cjs/replication/index.d.ts +3 -0
  109. package/dist/cjs/replication/index.d.ts.map +1 -0
  110. package/dist/{replication → cjs/replication}/index.js +2 -2
  111. package/dist/cjs/replication/index.js.map +1 -0
  112. package/dist/cjs/zapatos/index.d.ts +4 -0
  113. package/dist/cjs/zapatos/index.d.ts.map +1 -0
  114. package/dist/cjs/zapatos/index.js +20 -0
  115. package/dist/cjs/zapatos/index.js.map +1 -0
  116. package/dist/{zapatos → cjs/zapatos}/transaction-with-context.d.ts +2 -2
  117. package/dist/cjs/zapatos/transaction-with-context.d.ts.map +1 -0
  118. package/dist/cjs/zapatos/transaction-with-context.js.map +1 -0
  119. package/dist/cjs/zapatos/transform-custom-type.d.ts.map +1 -0
  120. package/dist/cjs/zapatos/transform-custom-type.js.map +1 -0
  121. package/dist/{zapatos → cjs/zapatos}/update-helpers.d.ts +1 -1
  122. package/dist/cjs/zapatos/update-helpers.d.ts.map +1 -0
  123. package/dist/cjs/zapatos/update-helpers.js.map +1 -0
  124. package/dist/esm/auth/authentication-subject.d.ts +44 -0
  125. package/dist/esm/auth/authentication-subject.d.ts.map +1 -0
  126. package/dist/esm/auth/authentication-subject.js +3 -0
  127. package/dist/esm/auth/authentication-subject.js.map +1 -0
  128. package/dist/esm/auth/helpers.d.ts +44 -0
  129. package/dist/esm/auth/helpers.d.ts.map +1 -0
  130. package/dist/esm/auth/helpers.js +53 -0
  131. package/dist/esm/auth/helpers.js.map +1 -0
  132. package/dist/esm/auth/index.d.ts +3 -0
  133. package/dist/esm/auth/index.d.ts.map +1 -0
  134. package/dist/esm/auth/index.js +3 -0
  135. package/dist/esm/auth/index.js.map +1 -0
  136. package/dist/esm/cli/commands/generate-define-func-migration.d.ts +14 -0
  137. package/dist/esm/cli/commands/generate-define-func-migration.d.ts.map +1 -0
  138. package/dist/esm/cli/commands/generate-define-func-migration.js +70 -0
  139. package/dist/esm/cli/commands/generate-define-func-migration.js.map +1 -0
  140. package/dist/esm/cli/commands/generate-vscode-sql-snippets.d.ts +14 -0
  141. package/dist/esm/cli/commands/generate-vscode-sql-snippets.d.ts.map +1 -0
  142. package/dist/esm/cli/commands/generate-vscode-sql-snippets.js +176 -0
  143. package/dist/esm/cli/commands/generate-vscode-sql-snippets.js.map +1 -0
  144. package/dist/esm/cli/commands/index.d.ts +3 -0
  145. package/dist/esm/cli/commands/index.d.ts.map +1 -0
  146. package/dist/esm/cli/commands/index.js +3 -0
  147. package/dist/esm/cli/commands/index.js.map +1 -0
  148. package/dist/esm/cli/commands/utils.d.ts +13 -0
  149. package/dist/esm/cli/commands/utils.d.ts.map +1 -0
  150. package/dist/esm/cli/commands/utils.js +20 -0
  151. package/dist/esm/cli/commands/utils.js.map +1 -0
  152. package/dist/esm/cli/index.d.ts +3 -0
  153. package/dist/esm/cli/index.d.ts.map +1 -0
  154. package/dist/esm/cli/index.js +7 -0
  155. package/dist/esm/cli/index.js.map +1 -0
  156. package/dist/esm/common/find-up.d.ts +2 -0
  157. package/dist/esm/common/find-up.d.ts.map +1 -0
  158. package/dist/esm/common/find-up.js +14 -0
  159. package/dist/esm/common/find-up.js.map +1 -0
  160. package/dist/esm/common/index.d.ts +2 -0
  161. package/dist/esm/common/index.d.ts.map +1 -0
  162. package/dist/esm/common/index.js +2 -0
  163. package/dist/esm/common/index.js.map +1 -0
  164. package/dist/esm/common/package-root.d.ts +2 -0
  165. package/dist/esm/common/package-root.d.ts.map +1 -0
  166. package/dist/esm/common/package-root.js +42 -0
  167. package/dist/esm/common/package-root.js.map +1 -0
  168. package/dist/esm/common/types.d.ts +52 -0
  169. package/dist/esm/common/types.d.ts.map +1 -0
  170. package/dist/esm/common/types.js +2 -0
  171. package/dist/{migrations → esm/common}/types.js.map +1 -1
  172. package/dist/esm/constants/index.d.ts +2 -0
  173. package/dist/esm/constants/index.d.ts.map +1 -0
  174. package/dist/esm/constants/index.js +2 -0
  175. package/dist/esm/constants/index.js.map +1 -0
  176. package/dist/esm/constants/pg-auth-settings-keys.d.ts +32 -0
  177. package/dist/esm/constants/pg-auth-settings-keys.d.ts.map +1 -0
  178. package/dist/esm/constants/pg-auth-settings-keys.js +32 -0
  179. package/dist/esm/constants/pg-auth-settings-keys.js.map +1 -0
  180. package/dist/esm/index.d.ts +11 -0
  181. package/dist/esm/index.d.ts.map +1 -0
  182. package/dist/esm/index.js +11 -0
  183. package/dist/esm/index.js.map +1 -0
  184. package/dist/esm/messaging/index.d.ts +2 -0
  185. package/dist/esm/messaging/index.d.ts.map +1 -0
  186. package/dist/esm/messaging/index.js +2 -0
  187. package/dist/esm/messaging/index.js.map +1 -0
  188. package/dist/esm/messaging/messaging-counter.d.ts +91 -0
  189. package/dist/esm/messaging/messaging-counter.d.ts.map +1 -0
  190. package/dist/esm/messaging/messaging-counter.js +129 -0
  191. package/dist/esm/messaging/messaging-counter.js.map +1 -0
  192. package/dist/esm/middleware/index.d.ts +2 -0
  193. package/dist/esm/middleware/index.d.ts.map +1 -0
  194. package/dist/esm/middleware/index.js +2 -0
  195. package/dist/esm/middleware/index.js.map +1 -0
  196. package/dist/esm/middleware/pg-pool.middleware.d.ts +99 -0
  197. package/dist/esm/middleware/pg-pool.middleware.d.ts.map +1 -0
  198. package/dist/esm/middleware/pg-pool.middleware.js +152 -0
  199. package/dist/esm/middleware/pg-pool.middleware.js.map +1 -0
  200. package/dist/esm/migrations/compare-migration-hashes-helpers.d.ts +14 -0
  201. package/dist/esm/migrations/compare-migration-hashes-helpers.d.ts.map +1 -0
  202. package/dist/{migrations → esm/migrations}/compare-migration-hashes-helpers.js +15 -18
  203. package/dist/esm/migrations/compare-migration-hashes-helpers.js.map +1 -0
  204. package/dist/esm/migrations/compare-migration-hashes.d.ts +17 -0
  205. package/dist/esm/migrations/compare-migration-hashes.d.ts.map +1 -0
  206. package/dist/esm/migrations/compare-migration-hashes.js +52 -0
  207. package/dist/esm/migrations/compare-migration-hashes.js.map +1 -0
  208. package/dist/esm/migrations/create-migrations-logger.d.ts +4 -0
  209. package/dist/esm/migrations/create-migrations-logger.d.ts.map +1 -0
  210. package/dist/esm/migrations/create-migrations-logger.js +35 -0
  211. package/dist/esm/migrations/create-migrations-logger.js.map +1 -0
  212. package/dist/esm/migrations/index.d.ts +5 -0
  213. package/dist/esm/migrations/index.d.ts.map +1 -0
  214. package/dist/esm/migrations/index.js +5 -0
  215. package/dist/esm/migrations/index.js.map +1 -0
  216. package/dist/esm/migrations/types.d.ts +17 -0
  217. package/dist/esm/migrations/types.d.ts.map +1 -0
  218. package/dist/esm/migrations/types.js +2 -0
  219. package/dist/esm/migrations/types.js.map +1 -0
  220. package/dist/esm/migrations/utils.d.ts +70 -0
  221. package/dist/esm/migrations/utils.d.ts.map +1 -0
  222. package/dist/esm/migrations/utils.js +113 -0
  223. package/dist/esm/migrations/utils.js.map +1 -0
  224. package/dist/esm/monitoring/index.d.ts +2 -0
  225. package/dist/esm/monitoring/index.d.ts.map +1 -0
  226. package/dist/esm/monitoring/index.js +2 -0
  227. package/dist/esm/monitoring/index.js.map +1 -0
  228. package/dist/esm/monitoring/postgres-metrics.d.ts +15 -0
  229. package/dist/esm/monitoring/postgres-metrics.d.ts.map +1 -0
  230. package/dist/esm/monitoring/postgres-metrics.js +39 -0
  231. package/dist/esm/monitoring/postgres-metrics.js.map +1 -0
  232. package/dist/esm/package.json +1 -0
  233. package/dist/esm/replication/create-logical-replication-service.d.ts +79 -0
  234. package/dist/esm/replication/create-logical-replication-service.d.ts.map +1 -0
  235. package/dist/esm/replication/create-logical-replication-service.js +145 -0
  236. package/dist/esm/replication/create-logical-replication-service.js.map +1 -0
  237. package/dist/esm/replication/ensure-replication-slot-and-publication-exist.d.ts +64 -0
  238. package/dist/esm/replication/ensure-replication-slot-and-publication-exist.d.ts.map +1 -0
  239. package/dist/esm/replication/ensure-replication-slot-and-publication-exist.js +50 -0
  240. package/dist/esm/replication/ensure-replication-slot-and-publication-exist.js.map +1 -0
  241. package/dist/esm/replication/index.d.ts +3 -0
  242. package/dist/esm/replication/index.d.ts.map +1 -0
  243. package/dist/esm/replication/index.js +3 -0
  244. package/dist/esm/replication/index.js.map +1 -0
  245. package/dist/esm/zapatos/index.d.ts +4 -0
  246. package/dist/esm/zapatos/index.d.ts.map +1 -0
  247. package/dist/esm/zapatos/index.js +4 -0
  248. package/dist/esm/zapatos/index.js.map +1 -0
  249. package/dist/esm/zapatos/transaction-with-context.d.ts +22 -0
  250. package/dist/esm/zapatos/transaction-with-context.d.ts.map +1 -0
  251. package/dist/esm/zapatos/transaction-with-context.js +36 -0
  252. package/dist/esm/zapatos/transaction-with-context.js.map +1 -0
  253. package/dist/esm/zapatos/transform-custom-type.d.ts +5 -0
  254. package/dist/esm/zapatos/transform-custom-type.d.ts.map +1 -0
  255. package/dist/esm/zapatos/transform-custom-type.js +8 -0
  256. package/dist/esm/zapatos/transform-custom-type.js.map +1 -0
  257. package/dist/esm/zapatos/update-helpers.d.ts +36 -0
  258. package/dist/esm/zapatos/update-helpers.d.ts.map +1 -0
  259. package/dist/esm/zapatos/update-helpers.js +39 -0
  260. package/dist/esm/zapatos/update-helpers.js.map +1 -0
  261. package/package.json +29 -9
  262. package/src/auth/helpers.spec.ts +3 -3
  263. package/src/auth/helpers.ts +4 -4
  264. package/src/auth/index.ts +2 -2
  265. package/src/cli/commands/commands.spec.ts +93 -0
  266. package/src/cli/commands/generate-define-func-migration.ts +9 -4
  267. package/src/cli/commands/generate-vscode-sql-snippets.ts +19 -21
  268. package/src/cli/commands/index.ts +2 -2
  269. package/src/cli/index.ts +2 -2
  270. package/src/common/find-up.ts +20 -0
  271. package/src/common/index.ts +1 -1
  272. package/src/common/package-root.ts +68 -0
  273. package/src/common/types.ts +1 -1
  274. package/src/constants/index.ts +1 -1
  275. package/src/index.ts +10 -10
  276. package/src/messaging/index.ts +1 -1
  277. package/src/messaging/messaging-counter.ts +8 -2
  278. package/src/middleware/index.ts +1 -1
  279. package/src/middleware/pg-pool.middleware.ts +10 -4
  280. package/src/migrations/compare-migration-hashes-helpers.ts +11 -3
  281. package/src/migrations/compare-migration-hashes.spec.ts +12 -3
  282. package/src/migrations/compare-migration-hashes.ts +6 -3
  283. package/src/migrations/create-migrations-logger.ts +10 -10
  284. package/src/migrations/index.ts +4 -4
  285. package/src/migrations/utils.spec.ts +31 -0
  286. package/src/migrations/utils.ts +91 -44
  287. package/src/monitoring/index.ts +1 -1
  288. package/src/monitoring/postgres-metrics.ts +3 -3
  289. package/src/replication/create-logical-replication-service.spec.ts +3 -3
  290. package/src/replication/create-logical-replication-service.ts +3 -3
  291. package/src/replication/ensure-replication-slot-and-publication-exist.spec.ts +3 -3
  292. package/src/replication/ensure-replication-slot-and-publication-exist.ts +4 -4
  293. package/src/replication/index.ts +2 -2
  294. package/src/zapatos/index.ts +3 -3
  295. package/src/zapatos/transaction-with-context.ts +4 -4
  296. package/src/zapatos/transform-custom-type.spec.ts +1 -1
  297. package/src/zapatos/update-helpers.spec.ts +1 -1
  298. package/src/zapatos/update-helpers.ts +1 -1
  299. package/dist/auth/authentication-subject.d.ts.map +0 -1
  300. package/dist/auth/authentication-subject.js.map +0 -1
  301. package/dist/auth/helpers.d.ts.map +0 -1
  302. package/dist/auth/helpers.js +0 -47
  303. package/dist/auth/helpers.js.map +0 -1
  304. package/dist/auth/index.d.ts +0 -3
  305. package/dist/auth/index.d.ts.map +0 -1
  306. package/dist/auth/index.js.map +0 -1
  307. package/dist/cli/commands/generate-define-func-migration.d.ts.map +0 -1
  308. package/dist/cli/commands/generate-define-func-migration.js.map +0 -1
  309. package/dist/cli/commands/generate-vscode-sql-snippets.d.ts.map +0 -1
  310. package/dist/cli/commands/generate-vscode-sql-snippets.js.map +0 -1
  311. package/dist/cli/commands/index.d.ts +0 -3
  312. package/dist/cli/commands/index.d.ts.map +0 -1
  313. package/dist/cli/commands/index.js.map +0 -1
  314. package/dist/cli/commands/utils.d.ts.map +0 -1
  315. package/dist/cli/commands/utils.js.map +0 -1
  316. package/dist/cli/index.d.ts.map +0 -1
  317. package/dist/cli/index.js.map +0 -1
  318. package/dist/common/index.d.ts +0 -2
  319. package/dist/common/index.d.ts.map +0 -1
  320. package/dist/common/index.js.map +0 -1
  321. package/dist/common/types.d.ts.map +0 -1
  322. package/dist/constants/index.d.ts +0 -2
  323. package/dist/constants/index.d.ts.map +0 -1
  324. package/dist/constants/index.js.map +0 -1
  325. package/dist/constants/pg-auth-settings-keys.d.ts.map +0 -1
  326. package/dist/constants/pg-auth-settings-keys.js.map +0 -1
  327. package/dist/index.d.ts +0 -11
  328. package/dist/index.d.ts.map +0 -1
  329. package/dist/index.js +0 -27
  330. package/dist/index.js.map +0 -1
  331. package/dist/messaging/index.d.ts +0 -2
  332. package/dist/messaging/index.d.ts.map +0 -1
  333. package/dist/messaging/index.js.map +0 -1
  334. package/dist/messaging/messaging-counter.d.ts.map +0 -1
  335. package/dist/messaging/messaging-counter.js.map +0 -1
  336. package/dist/middleware/index.d.ts +0 -2
  337. package/dist/middleware/index.d.ts.map +0 -1
  338. package/dist/middleware/index.js.map +0 -1
  339. package/dist/middleware/pg-pool.middleware.d.ts.map +0 -1
  340. package/dist/middleware/pg-pool.middleware.js.map +0 -1
  341. package/dist/migrations/compare-migration-hashes-helpers.d.ts.map +0 -1
  342. package/dist/migrations/compare-migration-hashes-helpers.js.map +0 -1
  343. package/dist/migrations/compare-migration-hashes.d.ts.map +0 -1
  344. package/dist/migrations/compare-migration-hashes.js.map +0 -1
  345. package/dist/migrations/create-migrations-logger.d.ts.map +0 -1
  346. package/dist/migrations/create-migrations-logger.js.map +0 -1
  347. package/dist/migrations/index.d.ts +0 -5
  348. package/dist/migrations/index.d.ts.map +0 -1
  349. package/dist/migrations/index.js +0 -21
  350. package/dist/migrations/index.js.map +0 -1
  351. package/dist/migrations/types.d.ts.map +0 -1
  352. package/dist/migrations/utils.d.ts +0 -38
  353. package/dist/migrations/utils.d.ts.map +0 -1
  354. package/dist/migrations/utils.js +0 -111
  355. package/dist/migrations/utils.js.map +0 -1
  356. package/dist/monitoring/index.d.ts +0 -2
  357. package/dist/monitoring/index.d.ts.map +0 -1
  358. package/dist/monitoring/index.js +0 -18
  359. package/dist/monitoring/index.js.map +0 -1
  360. package/dist/monitoring/postgres-metrics.d.ts.map +0 -1
  361. package/dist/monitoring/postgres-metrics.js.map +0 -1
  362. package/dist/replication/create-logical-replication-service.d.ts.map +0 -1
  363. package/dist/replication/create-logical-replication-service.js.map +0 -1
  364. package/dist/replication/ensure-replication-slot-and-publication-exist.d.ts.map +0 -1
  365. package/dist/replication/ensure-replication-slot-and-publication-exist.js.map +0 -1
  366. package/dist/replication/index.d.ts +0 -3
  367. package/dist/replication/index.d.ts.map +0 -1
  368. package/dist/replication/index.js.map +0 -1
  369. package/dist/zapatos/index.d.ts +0 -4
  370. package/dist/zapatos/index.d.ts.map +0 -1
  371. package/dist/zapatos/index.js +0 -20
  372. package/dist/zapatos/index.js.map +0 -1
  373. package/dist/zapatos/transaction-with-context.d.ts.map +0 -1
  374. package/dist/zapatos/transaction-with-context.js.map +0 -1
  375. package/dist/zapatos/transform-custom-type.d.ts.map +0 -1
  376. package/dist/zapatos/transform-custom-type.js.map +0 -1
  377. package/dist/zapatos/update-helpers.d.ts.map +0 -1
  378. package/dist/zapatos/update-helpers.js.map +0 -1
  379. /package/dist/{auth → cjs/auth}/authentication-subject.d.ts +0 -0
  380. /package/dist/{auth → cjs/auth}/authentication-subject.js +0 -0
  381. /package/dist/{cli → cjs/cli}/commands/utils.d.ts +0 -0
  382. /package/dist/{cli → cjs/cli}/commands/utils.js +0 -0
  383. /package/dist/{common → cjs/common}/types.js +0 -0
  384. /package/dist/{constants → cjs/constants}/pg-auth-settings-keys.d.ts +0 -0
  385. /package/dist/{constants → cjs/constants}/pg-auth-settings-keys.js +0 -0
  386. /package/dist/{messaging → cjs/messaging}/messaging-counter.js +0 -0
  387. /package/dist/{migrations → cjs/migrations}/types.d.ts +0 -0
  388. /package/dist/{migrations → cjs/migrations}/types.js +0 -0
  389. /package/dist/{monitoring → cjs/monitoring}/postgres-metrics.js +0 -0
  390. /package/dist/{zapatos → cjs/zapatos}/transaction-with-context.js +0 -0
  391. /package/dist/{zapatos → cjs/zapatos}/transform-custom-type.d.ts +0 -0
  392. /package/dist/{zapatos → cjs/zapatos}/transform-custom-type.js +0 -0
  393. /package/dist/{zapatos → cjs/zapatos}/update-helpers.js +0 -0
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGraphileBuildPgWatchFixturesPath = exports.getDbCommonBeforeMigrationPath = exports.getBeforeMigrationScripts = exports.runCurrentSql = exports.runSqlScripts = void 0;
4
+ /* eslint-disable no-console */
5
+ const fs_1 = require("fs");
6
+ const graphile_migrate_1 = require("graphile-migrate");
7
+ const module_1 = require("module");
8
+ const path_1 = require("path");
9
+ const readdirp_1 = require("readdirp");
10
+ const find_up_js_1 = require("../common/find-up.js");
11
+ const package_root_js_1 = require("../common/package-root.js");
12
+ /**
13
+ * Executes all .sql files located in a specified directory.
14
+ *
15
+ * @param settings - graphile-migrate settings object
16
+ * @param dirPath - relative path from the root of a project to a folder with sql scripts in it, e.g. 'migrations/after-reset'
17
+ */
18
+ const runSqlScripts = async (settings, dirPath, logger) => {
19
+ const sortedList = (await (0, readdirp_1.readdirpPromise)(dirPath, {
20
+ fileFilter: (entry) => entry.basename.endsWith('.sql'),
21
+ })).sort((a, b) => a.path.localeCompare(b.path));
22
+ for await (const { path } of sortedList) {
23
+ const scriptPath = (0, path_1.join)(dirPath, path);
24
+ const content = await fs_1.promises.readFile(scriptPath, 'utf8');
25
+ logger.debug(`Running Script: '${scriptPath}'`);
26
+ await (0, graphile_migrate_1.run)(settings, content, path);
27
+ }
28
+ };
29
+ exports.runSqlScripts = runSqlScripts;
30
+ /**
31
+ * Executes a `migrations/current.sql` located in the root of the project using graphile-migrate `run` command
32
+ *
33
+ * @param settings - graphile-migrate settings object
34
+ */
35
+ const runCurrentSql = async (settings, logger) => {
36
+ const migrationsFolder = settings.migrationsFolder ?? (0, path_1.join)(process.cwd(), 'migrations');
37
+ const path = (0, path_1.join)(migrationsFolder, 'current.sql');
38
+ const content = await fs_1.promises.readFile(path, 'utf8');
39
+ logger.debug(`Running Script: '${path}'`);
40
+ await (0, graphile_migrate_1.run)(settings, content, path);
41
+ };
42
+ exports.runCurrentSql = runCurrentSql;
43
+ /**
44
+ * Retrieves an array of relative string paths to before-migration SQL scripts,
45
+ * consumed by graphile-migrate settings. Scripts contain helper functions added
46
+ * to the `ax_utils` and `ax_define` schemas.
47
+ *
48
+ * @param migrationsFolder - Absolute path to the consuming project's
49
+ * `migrations` folder. Defaults to `<cwd>/migrations`.
50
+ * @param beforeMigrationScriptsPath - Absolute path to this package's
51
+ * `migrations/before-migration` directory. Optional override for callers that
52
+ * want to resolve the package assets themselves.
53
+ *
54
+ * When omitted, the package root is resolved internally in both the CJS and
55
+ * ESM builds and the bundled `migrations/before-migration` directory is used.
56
+ *
57
+ * Callers that need the explicit path can use
58
+ * {@link getDbCommonBeforeMigrationPath}:
59
+ * ```ts
60
+ * import { getBeforeMigrationScripts, getDbCommonBeforeMigrationPath } from '@axinom/mosaic-db-common';
61
+ *
62
+ * await getBeforeMigrationScripts(
63
+ * migrationsFolder,
64
+ * getDbCommonBeforeMigrationPath(import.meta.url),
65
+ * );
66
+ * ```
67
+ */
68
+ const getBeforeMigrationScripts = async (migrationsFolder, beforeMigrationScriptsPath) => {
69
+ const executionPath = migrationsFolder ?? (0, path_1.join)(process.cwd(), 'migrations');
70
+ const dirPath = beforeMigrationScriptsPath ??
71
+ (0, path_1.join)((0, package_root_js_1.getDbCommonPackageRoot)(), 'migrations', 'before-migration');
72
+ return (await (0, readdirp_1.readdirpPromise)(dirPath, {
73
+ fileFilter: (entry) => entry.basename.endsWith('.sql'),
74
+ }))
75
+ .sort((a, b) => a.path.localeCompare(b.path))
76
+ .map((file) => (0, path_1.relative)(executionPath, file.fullPath));
77
+ };
78
+ exports.getBeforeMigrationScripts = getBeforeMigrationScripts;
79
+ /**
80
+ * Resolves the absolute path to this package's `migrations/before-migration`
81
+ * directory from a caller module location.
82
+ *
83
+ * This helper remains useful when the caller needs to pass the path to another
84
+ * API explicitly. {@link getBeforeMigrationScripts} can resolve the same path
85
+ * internally in both CJS and ESM runtimes when the second argument is omitted.
86
+ *
87
+ * Pass `import.meta.url` from the calling ESM module. Internally uses
88
+ * `createRequire` to locate the installed package root via CJS resolution,
89
+ * which works correctly from both ESM and CJS contexts.
90
+ *
91
+ * @param callerUrl - The `import.meta.url` of the calling ESM module (or
92
+ * `pathToFileURL(__filename).href` from a CJS module when the caller wants to
93
+ * resolve this package's asset path explicitly).
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * import { getBeforeMigrationScripts, getDbCommonBeforeMigrationPath } from '@axinom/mosaic-db-common';
98
+ *
99
+ * await getBeforeMigrationScripts(
100
+ * migrationsFolder,
101
+ * getDbCommonBeforeMigrationPath(import.meta.url),
102
+ * );
103
+ * ```
104
+ */
105
+ const getDbCommonBeforeMigrationPath = (callerUrl) => (0, path_1.resolve)((0, path_1.dirname)((0, module_1.createRequire)(callerUrl).resolve('@axinom/mosaic-db-common')), '..', '..', 'migrations', 'before-migration');
106
+ exports.getDbCommonBeforeMigrationPath = getDbCommonBeforeMigrationPath;
107
+ /**
108
+ * Retrieve a relative path to watch-fixtures.sql of `graphile-build-pg` package. The path is relative to the 'migrations' folder of a specific project.
109
+ * Should only be used in development mode. Useful when there is a need to explicitly install postgraphile watch fixtures, so that database owner user can be created without a superuser privilege.
110
+ * Approximate return value: `../../../../node_modules/graphile-build-pg/res/watch-fixtures.sql`
111
+ */
112
+ const getGraphileBuildPgWatchFixturesAbsolutePath = (startPath) => (0, path_1.join)(startPath, 'node_modules', 'graphile-build-pg', 'res', 'watch-fixtures.sql');
113
+ const getGraphileBuildPgWatchFixturesPath = () => {
114
+ const projectRoot = (0, find_up_js_1.findClosestAncestorPath)(process.cwd(), (candidatePath) => (0, fs_1.existsSync)(getGraphileBuildPgWatchFixturesAbsolutePath(candidatePath)));
115
+ if (projectRoot === undefined) {
116
+ throw Error('`node_modules\\graphile-build-pg\\res\\watch-fixtures.sql` file not found. Please make sure that `graphile-build-pg` is installed.');
117
+ }
118
+ return (0, path_1.relative)((0, path_1.join)(process.cwd(), 'migrations'), getGraphileBuildPgWatchFixturesAbsolutePath(projectRoot));
119
+ };
120
+ exports.getGraphileBuildPgWatchFixturesPath = getGraphileBuildPgWatchFixturesPath;
121
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/migrations/utils.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2BAAiD;AAEjD,uDAAuC;AACvC,mCAAuC;AACvC,+BAAwD;AACxD,uCAA2C;AAC3C,qDAA+D;AAE/D,+DAAmE;AAEnE;;;;;GAKG;AACI,MAAM,aAAa,GAAG,KAAK,EAChC,QAAkB,EAClB,OAAe,EACf,MAAgB,EACD,EAAE;IACjB,MAAM,UAAU,GAAG,CACjB,MAAM,IAAA,0BAAe,EAAC,OAAO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ACrB,CAAC;AAEG,MAAM,mCAAmC,GAAG,GAAW,EAAE;IAC9D,MAAM,WAAW,GAAG,IAAA,oCAAuB,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,EAAE,EAAE,CAC3E,IAAA,eAAU,EAAC,2CAA2C,CAAC,aAAa,CAAC,CAAC,CACvE,CAAC;IAEF,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,KAAK,CACT,oIAAoI,CACrI,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,eAAQ,EACb,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,EACjC,2CAA2C,CAAC,WAAW,CAAC,CACzD,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,mCAAmC,uCAe9C"}
@@ -0,0 +1,2 @@
1
+ export * from './postgres-metrics.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/monitoring/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./pg-pool.middleware"), exports);
17
+ __exportStar(require("./postgres-metrics.js"), exports);
18
18
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/monitoring/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC"}
@@ -1,6 +1,6 @@
1
- import { Pool } from 'pg';
2
- import { Metric } from 'prom-client';
3
- import { DbLogger } from '../common';
1
+ import type { Pool } from 'pg';
2
+ import { type Metric } from 'prom-client';
3
+ import type { DbLogger } from '../common/index.js';
4
4
  /**
5
5
  * Creates a `Gauge` metric with the name `ax_postgres_<pgPoolType>_connectivity` which can be added to a metric Registry.
6
6
  * This metric will have a value of `1` if the Database can be reached via the corresponding Pool (within the given timeout),
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-metrics.d.ts","sourceRoot":"","sources":["../../../src/monitoring/postgres-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAS,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAUnD;;;;;;;;;GASG;AACH,eAAO,MAAM,oCAAoC,GAC/C,QAAQ,QAAQ,EAChB,QAAQ,IAAI,EACZ,YAAY,aAAa,GAAG,cAAc,GAAG,WAAW,EACxD,8BAA6B,KAC5B,MAAM,CAAC,MAAM,CA2Bf,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-metrics.js","sourceRoot":"","sources":["../../../src/monitoring/postgres-metrics.ts"],"names":[],"mappings":";;;AACA,6CAAiD;AAGjD,MAAM,aAAa,GAAG,CAAC,qBAA6B,EAAiB,EAAE,CACrE,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAC9B,UAAU,CACR,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,EACpD,qBAAqB,CACtB,CACF,CAAC;AAEJ;;;;;;;;;GASG;AACI,MAAM,oCAAoC,GAAG,CAClD,MAAgB,EAChB,MAAY,EACZ,UAAwD,EACxD,qBAAqB,GAAG,KAAK,EACb,EAAE;IAClB,OAAO,IAAI,mBAAK,CAAC;QACf,IAAI,EAAE,eAAe,UAAU,eAAe;QAC9C,IAAI,EAAE,4DAA4D,UAAU,kBAAkB;QAE9F,KAAK,CAAC,OAAO;YACX,IAAI,CAAC;gBACH,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnC,MAAM,OAAO,CAAC,IAAI,CAAC;oBACjB,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC;oBAC9D,aAAa,CAAC,qBAAqB,CAAC;iBACrC,CAAC,CAAC;gBACH,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC3C,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;YAC9B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAY,KAAM,CAAC,OAAO,KAAK,2BAA2B,EAAE,CAAC;oBAC3D,MAAM,CAAC,KAAK,CACV,kGAAkG,UAAU,sBAAsB,qBAAqB,KAAK,CAC7J,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,KAAK,CAAQ,KAAK,EAAE,yBAAyB,CAAC,CAAC;gBACxD,CAAC;gBAED,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAhCW,QAAA,oCAAoC,wCAgC/C"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,5 +1,5 @@
1
- import { Pgoutput } from 'pg-logical-replication';
2
- import { DbLogger } from '../common';
1
+ import type { Pgoutput } from 'pg-logical-replication';
2
+ import type { DbLogger } from '../common/index.js';
3
3
  export type LogicalReplicationOperation = 'begin' | 'commit' | 'delete' | 'insert' | 'message' | 'origin' | 'relation' | 'truncate' | 'type' | 'update';
4
4
  export interface PgOutputScopedMessage {
5
5
  operation: LogicalReplicationOperation;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-logical-replication-service.d.ts","sourceRoot":"","sources":["../../../src/replication/create-logical-replication-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAKvD,OAAO,KAAK,EAAE,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7 @@ const getScopedMessage = (message, operationsToWatch) => {
16
16
  };
17
17
  };
18
18
  const handleReconnection = async (error, reconnectionAttempts, replicationSlotName, reconnectionIntervalInMs, logger) => {
19
- if ((error === null || error === void 0 ? void 0 : error.code) === '55006' && (error === null || error === void 0 ? void 0 : error.routine) === 'ReplicationSlotAcquire') {
19
+ if (error?.code === '55006' && error?.routine === 'ReplicationSlotAcquire') {
20
20
  const isFirstFiveMinutesAfterStartup = reconnectionAttempts < 30;
21
21
  const log = isFirstFiveMinutesAfterStartup
22
22
  ? logger.trace.bind(logger)
@@ -64,7 +64,7 @@ const createLogicalReplicationService = async ({ connectionString, publicationNa
64
64
  if (operationsToWatch.length === 0) {
65
65
  throw new Error('Unable to start the logical replication service when operationsToWatch is an empty array.');
66
66
  }
67
- const logger = passedLogger !== null && passedLogger !== void 0 ? passedLogger : console;
67
+ const logger = passedLogger ?? console;
68
68
  const plugin = new pg_logical_replication_1.PgoutputPlugin({ protoVersion: 1, publicationNames });
69
69
  let service;
70
70
  let stopped = false;
@@ -139,8 +139,10 @@ const createLogicalReplicationService = async ({ connectionString, publicationNa
139
139
  return async () => {
140
140
  logger.debug('Shutting down the logical replication service.');
141
141
  stopped = true;
142
- service === null || service === void 0 ? void 0 : service.removeAllListeners();
143
- service === null || service === void 0 ? void 0 : service.stop().catch((e) => logger.error(e, 'Error on logical replicationservice shutdown.'));
142
+ service?.removeAllListeners();
143
+ service
144
+ ?.stop()
145
+ .catch((e) => logger.error(e, 'Error on logical replicationservice shutdown.'));
144
146
  };
145
147
  };
146
148
  exports.createLogicalReplicationService = createLogicalReplicationService;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-logical-replication-service.js","sourceRoot":"","sources":["../../../src/replication/create-logical-replication-service.ts"],"names":[],"mappings":";;;AAEA,mEAGgC;AAGhC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAiB,EAAE,CAC1C,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC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,IAAI,EAAE,CAAC;wBACrB,MAAM,CAAC,GAAG,CAAC,CAAC;oBACd,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,KAAK,GAAG,GAAoB,CAAC;gBAEnC,IACE,MAAM,kBAAkB,CACtB,KAAK,EACL,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,MAAM,CACP,EACD,CAAC;oBACD,oBAAoB,EAAE,CAAC;oBACvB,SAAS;gBACX,CAAC;gBAED,cAAc,EAAE,CAAC;gBACjB,wBAAwB,GAAG,MAAM,aAAa,CAC5C,KAAK,EACL,cAAc,EACd,wBAAwB,EACxB,MAAM,CACP,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IACL,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO,GAAG,IAAI,CAAC;QACf,OAAO,EAAE,kBAAkB,EAAE,CAAC;QAC9B,OAAO;YACL,EAAE,IAAI,EAAE;aACP,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CACX,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,+CAA+C,CAAC,CACjE,CAAC;IACN,CAAC,CAAC;AACJ,CAAC,CAAC;AA5HW,QAAA,+BAA+B,mCA4H1C"}
@@ -1,6 +1,6 @@
1
- import { Pool } from 'pg';
2
- import { DbLogger } from '../common';
3
- import { LogicalReplicationOperation } from './create-logical-replication-service';
1
+ import type { Pool } from 'pg';
2
+ import type { DbLogger } from '../common/index.js';
3
+ import type { LogicalReplicationOperation } from './create-logical-replication-service.js';
4
4
  /**
5
5
  * A set of parameters used by `ensureReplicationSlotAndPublicationExist` helper.
6
6
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-replication-slot-and-publication-exist.d.ts","sourceRoot":"","sources":["../../../src/replication/ensure-replication-slot-and-publication-exist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAE3F;;GAEG;AACH,MAAM,WAAW,8CAA8C;IAC7D;;;;;;OAMG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,iBAAiB,EAAE,IAAI,CAAC;IACxB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,2BAA2B,EAAE,CAAC;IAClD;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,wCAAwC,GAAU,6HAS5D,8CAA8C,KAAG,OAAO,CAAC,IAAI,CAsE/D,CAAC"}
@@ -28,7 +28,7 @@ const ensureReplicationSlotAndPublicationExist = async ({ replicationSlotName, p
28
28
  const tablesRemainTheSame = assignedTables.size === expectedTables.size &&
29
29
  [...assignedTables].every((assignedTable) => expectedTables.has(assignedTable));
30
30
  if (slotExists && pubExists && tablesRemainTheSame) {
31
- (logger !== null && logger !== void 0 ? logger : console).log(`The replication slot "${replicationSlotName}" and publication "${publicationName}" already exist.`);
31
+ (logger ?? console).log(`The replication slot "${replicationSlotName}" and publication "${publicationName}" already exist.`);
32
32
  return;
33
33
  }
34
34
  const operations = operationsToWatch.join(',');
@@ -48,7 +48,7 @@ const ensureReplicationSlotAndPublicationExist = async ({ replicationSlotName, p
48
48
  AND database = (SELECT current_database());`.run(txn);
49
49
  await (0, db_1.sql) `SELECT pg_create_logical_replication_slot(${slotName}, ${plugin});`.run(txn);
50
50
  });
51
- (logger !== null && logger !== void 0 ? logger : console).log(`The replication slot "${replicationSlotName}" and publication "${publicationName}" successfully (re)created.`);
51
+ (logger ?? console).log(`The replication slot "${replicationSlotName}" and publication "${publicationName}" successfully (re)created.`);
52
52
  };
53
53
  exports.ensureReplicationSlotAndPublicationExist = ensureReplicationSlotAndPublicationExist;
54
54
  //# sourceMappingURL=ensure-replication-slot-and-publication-exist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-replication-slot-and-publication-exist.js","sourceRoot":"","sources":["../../../src/replication/ensure-replication-slot-and-publication-exist.ts"],"names":[],"mappings":";;;AACA,mCAA+E;AAsD/E;;;;;;;;;GASG;AACI,MAAM,wCAAwC,GAAG,KAAK,EAAE,EAC7D,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,iBAAiB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAClD,UAAU,GAAG,UAAU,EACvB,MAAM,GACyC,EAAiB,EAAE;IAClE,MAAM,QAAQ,GAAG,IAAA,UAAK,EAAC,mBAAmB,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,IAAA,UAAK,EAAC,eAAe,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,MAAM,IAAA,QAAG,EAAA;;;sCAGT,QAAQ;;sCAER,OAAO,mBAAmB,CAAC,GAAG,CAChE,iBAAiB,CAClB,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,IAAA,QAAG,EAG1B;gCAC6B,OAAO,EAAE,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/D,MAAM,cAAc,GAAG,IAAI,GAAG,CAC5B,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CACvD,CAA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C;IACF,MAAM,IAAA,gBAAW,EACf,iBAAiB,EACjB,mBAAc,CAAC,YAAY,EAC3B,KAAK,EAAE,GAAG,EAAE,EAAE;QACZ,MAAM,IAAA,QAAG,EAAA,mCAAmC,QAAQ;;oCAEtB,QAAQ;8DACkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClE,MAAM,IAAA,QAAG,EAAA,6CAA6C,QAAQ,KAAK,MAAM,IAAI,CAAC,GAAG,CAC/E,GAAG,CACJ,CAAC;IACJ,CAAC,CACF,CAAC;IACF,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC,GAAG,CACrB,yBAAyB,mBAAmB,sBAAsB,eAAe,6BAA6B,CAC/G,CAAC;AACJ,CAAC,CAAC;AA/EW,QAAA,wCAAwC,4CA+EnD"}
@@ -0,0 +1,3 @@
1
+ export * from './create-logical-replication-service.js';
2
+ export * from './ensure-replication-slot-and-publication-exist.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/replication/index.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC;AACxD,cAAc,oDAAoD,CAAC"}
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./create-logical-replication-service"), exports);
18
- __exportStar(require("./ensure-replication-slot-and-publication-exist"), exports);
17
+ __exportStar(require("./create-logical-replication-service.js"), exports);
18
+ __exportStar(require("./ensure-replication-slot-and-publication-exist.js"), exports);
19
19
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/replication/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0EAAwD;AACxD,qFAAmE"}
@@ -0,0 +1,4 @@
1
+ export * from './transaction-with-context.js';
2
+ export * from './transform-custom-type.js';
3
+ export * from './update-helpers.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/zapatos/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./transaction-with-context.js"), exports);
18
+ __exportStar(require("./transform-custom-type.js"), exports);
19
+ __exportStar(require("./update-helpers.js"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/zapatos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C;AAC9C,6DAA2C;AAC3C,sDAAoC"}
@@ -1,5 +1,5 @@
1
- import { ClientBase, Pool, PoolClient } from 'pg';
2
- import { IsolationLevel, TxnClient } from 'zapatos/db';
1
+ import type { ClientBase, Pool, PoolClient } from 'pg';
2
+ import { type IsolationLevel, type TxnClient } from 'zapatos/db';
3
3
  export type DbClient = Pool | TxnClient<IsolationLevel>;
4
4
  /**
5
5
  * Iterates through pgSettings properties, composes and runs a single SELECT
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-with-context.d.ts","sourceRoot":"","sources":["../../../src/zapatos/transaction-with-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACvD,OAAO,EAIL,KAAK,cAAc,EAEnB,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,YAAY;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,YAAK,EAC1C,KAAK,IAAI,GAAG,SAAS,CAAC,cAAc,CAAC,GAAG,UAAU,GAAG,UAAU,KAC9D,OAAO,CAAC,IAAI,CAiBd,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAU,CAAC,EAC5C,MAAM,QAAQ,EACd,gBAAgB,cAAc,EAC9B,YAAY;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,YAAK,EAC1C,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,KAC1D,OAAO,CAAC,CAAC,CAKX,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-with-context.js","sourceRoot":"","sources":["../../../src/zapatos/transaction-with-context.ts"],"names":[],"mappings":";;;AACA,mCAOoB;AAIpB;;;GAGG;AACI,MAAM,mBAAmB,GAAG,KAAK,EACtC,aAAwC,EAAE,EAC1C,GAA+D,EAChD,EAAE;IACjB,IAAI,OAAO,GAAG,SAAS,CAAC;IACxB,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,KAAK,MAAM,QAAQ,IAA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,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-custom-type.js","sourceRoot":"","sources":["../../../src/zapatos/transform-custom-type.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,mBAAmB,GAAG,CAAC,UAAkB,EAAU,EAAE;IAChE,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CACxD,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAC1B,CAAC;IACF,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC,CAAC;AALW,QAAA,mBAAmB,uBAK9B"}
@@ -1,4 +1,4 @@
1
- import { Dict } from '../common';
1
+ import type { Dict } from '../common/index.js';
2
2
  /**
3
3
  * Function to be used to construct an update object. If value is null or undefined - property will not be updated. Example:
4
4
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-helpers.d.ts","sourceRoot":"","sources":["../../../src/zapatos/update-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EACxB,KAAK,CAAC,EACN,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KACvB,KAAK,GAAG,IAAI,CAAC,CAAC,CAEhB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EACxB,KAAK,CAAC,EACN,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KACvB,KAAK,GAAG,IAAI,CAAC,CAAC,CAEhB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-helpers.js","sourceRoot":"","sources":["../../../src/zapatos/update-helpers.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;GAeG;AACI,MAAM,QAAQ,GAAG,CACtB,GAAM,EACN,GAAwB,EACP,EAAE;IACnB,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;AACvD,CAAC,CAAC;AALW,QAAA,QAAQ,YAKnB;AAEF;;;;;;;;;;;;;;;GAeG;AACI,MAAM,QAAQ,GAAG,CACtB,GAAM,EACN,GAAwB,EACP,EAAE;IACnB,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC,CAAC;AALW,QAAA,QAAQ,YAKnB"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * An interface that represents an authentication subject which is provided by Mosaic Admin Service in form of a JWT token.
3
+ * The auth library `@axinom/mosaic-id-guard` can be used to validate and parse the JWT token to get such a PgAuthenticatedManagementSubject, and it also provides a more fitting interface:
4
+ * ```ts
5
+ * import { PgAuthenticatedManagementSubject } from '@axinom/mosaic-id-guard';
6
+ * ```
7
+ */
8
+ export interface PgAuthenticatedManagementSubject {
9
+ tenantId: string;
10
+ environmentId: string;
11
+ name: string;
12
+ permissions: {
13
+ [key: string]: string[];
14
+ };
15
+ tags?: string[];
16
+ sub?: string;
17
+ }
18
+ /**
19
+ * This interface represents an authenticated subject of type End User.
20
+ * These will be tokens issued by the User Service.
21
+ *
22
+ * These authenticated subjects are not expected to have any permission structure.
23
+ */
24
+ export interface PgAuthenticatedEndUser {
25
+ tenantId: string;
26
+ environmentId: string;
27
+ sub: string;
28
+ name: string;
29
+ profileId: string;
30
+ }
31
+ /**
32
+ * This interface represents an authenticated end-user application.
33
+ * These will be tokens issued by the User Service.
34
+ *
35
+ * Having name and profileId is not mandatory for these tokens.
36
+ */
37
+ export interface PgAuthenticatedEndUserApplication {
38
+ tenantId: string;
39
+ environmentId: string;
40
+ sub: string;
41
+ name: string;
42
+ [key: string]: any;
43
+ }
44
+ //# sourceMappingURL=authentication-subject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-subject.d.ts","sourceRoot":"","sources":["../../../src/auth/authentication-subject.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KACzB,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iCAAiC;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IAEb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
@@ -0,0 +1,3 @@
1
+ // This is a partial copy from `@axinom/mosaic-id-guard` that might need to be aligned if original interface changes or if more properties from original interface would be required here.
2
+ export {};
3
+ //# sourceMappingURL=authentication-subject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-subject.js","sourceRoot":"","sources":["../../../src/auth/authentication-subject.ts"],"names":[],"mappings":"AAAA,0LAA0L"}
@@ -0,0 +1,44 @@
1
+ import type { Dict } from '../common/index.js';
2
+ import type { PgAuthenticatedEndUser, PgAuthenticatedEndUserApplication, PgAuthenticatedManagementSubject } from './authentication-subject.js';
3
+ /**
4
+ * Builds a pg settings object for the currently authenticated management subject.
5
+ * Used for RLS authentication in both PostGraphile and zapatos.
6
+ *
7
+ * @param subject - Currently authenticated management subject.
8
+ * @param dbRole - The database role to switch to
9
+ * @param serviceId - The serviceId of the current service
10
+ */
11
+ export declare function buildPgSettings(subject: PgAuthenticatedManagementSubject | undefined, dbRole: string, serviceId: string): Dict<string>;
12
+ /**
13
+ * Builds a pg settings object for the currently authenticated management subject. Excludes permissions and tags.
14
+ * Used for RLS authentication in both PostGraphile and zapatos.
15
+ *
16
+ * @param subject - Currently authenticated management subject.
17
+ * @param dbRole - The database role to switch to
18
+ */
19
+ export declare function buildPgSettings(subject: PgAuthenticatedManagementSubject | undefined, dbRole: string): Dict<string>;
20
+ /**
21
+ * Builds a pg settings object for the currently authenticated management subject without role switching.
22
+ * Used for RLS authentication in both PostGraphile and zapatos.
23
+ *
24
+ * @param subject - Currently authenticated management subject.
25
+ * @param serviceId - The serviceId of the current service
26
+ */
27
+ export declare function buildAuthPgSettings(subject: PgAuthenticatedManagementSubject | undefined, serviceId?: string): Dict<string>;
28
+ /**
29
+ * Builds a pg settings object for the currently authenticated management subject without role switching. Excludes permissions and tags.
30
+ * Used for RLS authentication in both PostGraphile and zapatos.
31
+ *
32
+ * @param subject - Currently authenticated management subject.
33
+ * @param serviceId - The serviceId of the current service
34
+ */
35
+ export declare function buildAuthPgSettings(subject: PgAuthenticatedManagementSubject | undefined): Dict<string>;
36
+ /**
37
+ * Builds a pg settings object for the currently authenticated end-user or end-user application with a dedicated DB Role.
38
+ * Used for End User RLS authentication in both PostGraphile and zapatos.
39
+ *
40
+ * @param subject - Currently Authenticated end-user or end-user application
41
+ * @param dbRole - The database role to switch to
42
+ */
43
+ export declare function buildEndUserAuthPgSettings(subject: PgAuthenticatedEndUser | PgAuthenticatedEndUserApplication | undefined, dbRole: string): Dict<string>;
44
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/auth/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAiB/C,OAAO,KAAK,EACV,sBAAsB,EACtB,iCAAiC,EACjC,gCAAgC,EACjC,MAAM,6BAA6B,CAAC;AAErC;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,gCAAgC,GAAG,SAAS,EACrD,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,IAAI,CAAC,MAAM,CAAC,CAAC;AAEhB;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,gCAAgC,GAAG,SAAS,EACrD,MAAM,EAAE,MAAM,GACb,IAAI,CAAC,MAAM,CAAC,CAAC;AAahB;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gCAAgC,GAAG,SAAS,EACrD,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAAC,MAAM,CAAC,CAAC;AAEhB;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gCAAgC,GAAG,SAAS,GACpD,IAAI,CAAC,MAAM,CAAC,CAAC;AAuChB;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EACH,sBAAsB,GACtB,iCAAiC,GACjC,SAAS,EACb,MAAM,EAAE,MAAM,GACb,IAAI,CAAC,MAAM,CAAC,CASd"}
@@ -0,0 +1,53 @@
1
+ import { DEFAULT_AUTH_SUBJECT_NAME, MOSAIC_AUTH_END_USER_ID, MOSAIC_AUTH_PERMISSIONS, MOSAIC_AUTH_PROFILE_ID, MOSAIC_AUTH_SUBJECT_NAME, MOSAIC_AUTH_TAGS, MOSAIC_ENVIRONMENT_ID, MOSAIC_ID_SERVICE_AUTH_PERMISSIONS, MOSAIC_ID_SERVICE_AUTH_SUBJECT_NAME, MOSAIC_ID_SERVICE_AUTH_TAGS, MOSAIC_ID_SERVICE_ENVIRONMENT_ID, MOSAIC_ID_SERVICE_TENANT_ID, MOSAIC_TENANT_ID, PGMEMENTO_SESSION_INFO, } from '../constants/index.js';
2
+ export function buildPgSettings(subject, dbRole, serviceId) {
3
+ return {
4
+ role: dbRole, // Each GraphQL Request will run on the DB as dedicated gql role
5
+ ...buildAuthPgSettings(subject, serviceId),
6
+ };
7
+ }
8
+ export function buildAuthPgSettings(subject, serviceId) {
9
+ const pgSettings = {
10
+ // Common settings
11
+ [MOSAIC_AUTH_SUBJECT_NAME]: subject?.name ?? DEFAULT_AUTH_SUBJECT_NAME,
12
+ [MOSAIC_TENANT_ID]: subject?.tenantId ?? '',
13
+ [MOSAIC_ENVIRONMENT_ID]: subject?.environmentId ?? '',
14
+ [PGMEMENTO_SESSION_INFO]: JSON.stringify({
15
+ environmentId: subject?.environmentId,
16
+ tenantId: subject?.tenantId,
17
+ sub: subject?.sub,
18
+ }),
19
+ ...(serviceId && { [MOSAIC_AUTH_TAGS]: subject?.tags?.join?.(',') ?? '' }),
20
+ ...(serviceId && {
21
+ [MOSAIC_AUTH_PERMISSIONS]: subject?.permissions?.[serviceId]?.join?.(',') ?? '',
22
+ }),
23
+ // ID Service specific settings
24
+ [MOSAIC_ID_SERVICE_AUTH_SUBJECT_NAME]: subject?.name ?? DEFAULT_AUTH_SUBJECT_NAME,
25
+ [MOSAIC_ID_SERVICE_TENANT_ID]: subject?.tenantId ?? '',
26
+ [MOSAIC_ID_SERVICE_ENVIRONMENT_ID]: subject?.environmentId ?? '',
27
+ ...(serviceId && {
28
+ [MOSAIC_ID_SERVICE_AUTH_TAGS]: subject?.tags?.join?.(',') ?? '',
29
+ }),
30
+ ...(serviceId && {
31
+ [MOSAIC_ID_SERVICE_AUTH_PERMISSIONS]: subject?.permissions?.[serviceId]?.join?.(',') ?? '',
32
+ }),
33
+ };
34
+ return pgSettings;
35
+ }
36
+ /**
37
+ * Builds a pg settings object for the currently authenticated end-user or end-user application with a dedicated DB Role.
38
+ * Used for End User RLS authentication in both PostGraphile and zapatos.
39
+ *
40
+ * @param subject - Currently Authenticated end-user or end-user application
41
+ * @param dbRole - The database role to switch to
42
+ */
43
+ export function buildEndUserAuthPgSettings(subject, dbRole) {
44
+ return {
45
+ role: dbRole,
46
+ [MOSAIC_AUTH_SUBJECT_NAME]: subject?.name ?? DEFAULT_AUTH_SUBJECT_NAME,
47
+ [MOSAIC_TENANT_ID]: subject?.tenantId ?? '',
48
+ [MOSAIC_ENVIRONMENT_ID]: subject?.environmentId ?? '',
49
+ [MOSAIC_AUTH_END_USER_ID]: subject?.sub ?? '',
50
+ [MOSAIC_AUTH_PROFILE_ID]: subject?.profileId ?? '',
51
+ };
52
+ }
53
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/auth/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,qBAAqB,EACrB,kCAAkC,EAClC,mCAAmC,EACnC,2BAA2B,EAC3B,gCAAgC,EAChC,2BAA2B,EAC3B,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAiC/B,MAAM,UAAU,eAAe,CAC7B,OAAqD,EACrD,MAAc,EACd,SAAkB;IAElB,OAAO;QACL,IAAI,EAAE,MAAM,EAAE,gEAAgE;QAC9E,GAAG,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC;KAC3C,CAAC;AACJ,CAAC;AAyBD,MAAM,UAAU,mBAAmB,CACjC,OAAqD,EACrD,SAAkB;IAElB,MAAM,UAAU,GAAiB;QAC/B,kBAAkB;QAClB,CAAC,wBAAwB,CAAC,EAAE,OAAO,EAAE,IAAI,IAAI,yBAAyB;QACtE,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,QAAQ,IAAI,EAAE;QAC3C,CAAC,qBAAq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AAI,IAAI,yBAAyB;QACtE,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,QAAQ,IAAI,EAAE;QAC3C,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,aAAa,IAAI,EAAE;QACrD,CAAC,uBAAuB,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE;QAC7C,CAAC,sBAAsB,CAAC,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE;KACnD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './authentication-subject.js';
2
+ export * from './helpers.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './authentication-subject.js';
2
+ export * from './helpers.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,cAAc,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { CommandModule } from 'yargs';
2
+ /**
3
+ * CLI command options object.
4
+ */
5
+ interface GenerateMigrationOptions {
6
+ includeMultitenancyFunctions: boolean;
7
+ currentMigrationFolderPath: string;
8
+ }
9
+ /**
10
+ * Yargs command module definition for `generate-define-func-migration` CLI script.
11
+ */
12
+ export declare const generateDefineFuncMigration: CommandModule<unknown, GenerateMigrationOptions>;
13
+ export {};
14
+ //# sourceMappingURL=generate-define-func-migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-define-func-migration.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/generate-define-func-migration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI3C;;GAEG;AACH,UAAU,wBAAwB;IAChC,4BAA4B,EAAE,OAAO,CAAC;IACtC,0BAA0B,EAAE,MAAM,CAAC;CACpC;AAsFD;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,aAAa,CACrD,OAAO,EACP,wBAAwB,CAuBzB,CAAC"}