@vrplatform/kysely 1.3.45-4459 → 1.3.45-44603116832

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 (352) hide show
  1. package/build/.data.tar +2 -2
  2. package/build/main/camel-case/index.d.ts +4 -4
  3. package/build/main/camel-case/index.js +3 -2
  4. package/build/main/camel-case/index.js.map +1 -1
  5. package/build/main/connect-handoff.d.ts +12 -0
  6. package/build/main/connect-handoff.js +73 -0
  7. package/build/main/connect-handoff.js.map +1 -0
  8. package/build/main/control-plane/index.d.ts +421 -14
  9. package/build/main/control-plane/index.js +71 -0
  10. package/build/main/control-plane/index.js.map +1 -1
  11. package/build/main/domain.d.ts +4 -0
  12. package/build/main/domain.js +3 -0
  13. package/build/main/domain.js.map +1 -0
  14. package/build/main/error.d.ts +2 -1
  15. package/build/main/error.js +2 -1
  16. package/build/main/error.js.map +1 -1
  17. package/build/main/index.d.ts +57 -15
  18. package/build/main/index.js +498 -66
  19. package/build/main/index.js.map +1 -1
  20. package/build/main/isomorphic.d.ts +6 -6
  21. package/build/main/isomorphic.js +4 -8
  22. package/build/main/isomorphic.js.map +1 -1
  23. package/build/main/local/digest.d.ts +3 -3
  24. package/build/main/local/digest.js.map +1 -1
  25. package/build/main/local/generate.js +15 -13
  26. package/build/main/local/generate.js.map +1 -1
  27. package/build/main/local/index.d.ts +5 -1
  28. package/build/main/local/index.js +346 -12
  29. package/build/main/local/index.js.map +1 -1
  30. package/build/main/local/prune-pulled-schema.js +4 -1
  31. package/build/main/local/prune-pulled-schema.js.map +1 -1
  32. package/build/main/migration-source.d.ts +4 -0
  33. package/build/main/migration-source.js +45 -0
  34. package/build/main/migration-source.js.map +1 -0
  35. package/build/main/migration.d.ts +7 -0
  36. package/build/main/migration.js +11 -0
  37. package/build/main/migration.js.map +1 -0
  38. package/build/main/pganalyze-comment-plugin/comment-transformer.js +3 -1
  39. package/build/main/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  40. package/build/main/pganalyze-comment-plugin/index.js.map +1 -1
  41. package/build/main/plugins.d.ts +2 -2
  42. package/build/main/plugins.js.map +1 -1
  43. package/build/main/postgres-error.d.ts +9 -0
  44. package/build/main/postgres-error.js +28 -0
  45. package/build/main/postgres-error.js.map +1 -0
  46. package/build/main/query/index.d.ts +1 -0
  47. package/build/main/query/index.js +1 -0
  48. package/build/main/query/index.js.map +1 -1
  49. package/build/main/query/listing/status.d.ts +2 -12
  50. package/build/main/query/listing/status.js +35 -20
  51. package/build/main/query/listing/status.js.map +1 -1
  52. package/build/main/query/tenant/billing-partner.d.ts +4 -0
  53. package/build/main/query/tenant/billing-partner.js +8 -0
  54. package/build/main/query/tenant/billing-partner.js.map +1 -0
  55. package/build/main/query/tenant/feature-enabled.d.ts +6 -0
  56. package/build/main/query/tenant/feature-enabled.js +30 -0
  57. package/build/main/query/tenant/feature-enabled.js.map +1 -0
  58. package/build/main/query/tenant/index.d.ts +4 -0
  59. package/build/main/query/tenant/index.js +21 -0
  60. package/build/main/query/tenant/index.js.map +1 -0
  61. package/build/main/query/tenant/status.d.ts +9 -0
  62. package/build/main/query/tenant/status.js +32 -0
  63. package/build/main/query/tenant/status.js.map +1 -0
  64. package/build/main/query/tenant/where-uuid-in.d.ts +2 -0
  65. package/build/main/query/tenant/where-uuid-in.js +14 -0
  66. package/build/main/query/tenant/where-uuid-in.js.map +1 -0
  67. package/build/main/regional.d.ts +31 -4
  68. package/build/main/regional.js +69 -8
  69. package/build/main/regional.js.map +1 -1
  70. package/build/main/test/index.d.ts +21 -11
  71. package/build/main/test/index.js +31 -26
  72. package/build/main/test/index.js.map +1 -1
  73. package/build/main/transaction.d.ts +3 -3
  74. package/build/main/transaction.js.map +1 -1
  75. package/build/main/v1.generated.d.ts +1407 -177
  76. package/build/main/v1.generated.js.map +1 -1
  77. package/build/migrations-v2/0000000000000-baseline.ts +5 -0
  78. package/build/migrations-v2/0000000000001-public-audit-events-v2.ts +137 -0
  79. package/build/migrations-v2/0000000000002-audit-recovery-watermarks.ts +30 -0
  80. package/build/migrations-v2/0000000000003-audit-effect-recovery-watermark.ts +13 -0
  81. package/build/migrations-v2/0000000000004-audit-event-projected-at.ts +15 -0
  82. package/build/migrations-v2/0000000000005-audit-recovery-indexes.ts +63 -0
  83. package/build/migrations-v2/0000000000006-audit-action-public-event-projected-at.ts +22 -0
  84. package/build/migrations-v2/0000000000007-audit-action-public-event-projected-at-backfill.ts +35 -0
  85. package/build/migrations-v2/0000000000008-global-user-attribution.ts +33 -0
  86. package/build/migrations-v2/0000000000008-team-issue-rule-state.ts +52 -0
  87. package/build/migrations-v2/0000000000009-reservation-issue-projections.ts +45 -0
  88. package/build/migrations-v2/0000000000010-bank-rule-application-bank-record-delete-cascade.ts +26 -0
  89. package/build/migrations-v2/0000000000011-guest-balance-journal-entry-lookup-index.ts +25 -0
  90. package/build/migrations-v2/0000000000012-trial-free-analytics-billing-status.ts +72 -0
  91. package/build/migrations-v2/0000000000013-ui-permission-bundles.ts +45 -0
  92. package/build/migrations-v2/0000000000014-ui-permission-bundle-top-up.ts +32 -0
  93. package/build/migrations-v2/0000000000015-durable-flow-events.ts +163 -0
  94. package/build/migrations-v2/0000000000016-billing-listing-facts.ts +539 -0
  95. package/build/migrations-v2/0000000000016-managed-team-access.ts +34 -0
  96. package/build/migrations-v2/0000000000017-drop-trial-until.ts +42 -0
  97. package/build/migrations-v2/0000000000017-webhook-secret-reencryption-failures.ts +18 -0
  98. package/build/migrations-v2/0000000000018-accounting-integrity-monitoring.ts +276 -0
  99. package/build/migrations-v2/0000000000018-durable-flow-event-sensitive-input.ts +28 -0
  100. package/build/migrations-v2/0000000000019-accounting-integrity-run-shards.ts +26 -0
  101. package/build/migrations-v2/0000000000019-asynchronous-operations.ts +736 -0
  102. package/build/migrations-v2/0000000000020-accounting-integrity-case-classification.ts +52 -0
  103. package/build/migrations-v2/0000000000021-payment-line-classification-monitor-indexes.ts +31 -0
  104. package/build/migrations-v2/0000000000022-accounting-integrity-controlled-repairs.ts +281 -0
  105. package/build/migrations-v2/0000000000023-line-classification-usage.ts +325 -0
  106. package/build/migrations-v2/0000000000024-tenant-region-migration.ts +108 -0
  107. package/build/migrations-v2/0000000000025-partner-ach-denial-default.ts +30 -0
  108. package/build/migrations-v2/0000000000026-line-classification-usage-capture.ts +399 -0
  109. package/build/migrations-v2/0000000000027-payout-replacement-chain.ts +27 -0
  110. package/build/migrations-v2/0000000000028-accounting-integrity-operator-workflow.ts +108 -0
  111. package/build/migrations-v2/0000000000029-accounting-integrity-definition-artifacts.ts +40 -0
  112. package/build/migrations-v2/0000000000030-accounting-integrity-review-metadata-compatibility.ts +49 -0
  113. package/build/migrations-v2/0000000000031-ui-permission-role-simplification.ts +70 -0
  114. package/build/migrations-v2/0000000000032-tenant-delete-ownership-cascades.ts +44 -0
  115. package/build/migrations-v2/0000000000033-plaid-connect-session-telemetry.ts +31 -0
  116. package/build/migrations-v2/0000000000033-reservation-issue-seed-bucket-index.ts +19 -0
  117. package/build/migrations-v2/0000000000034-retire-recent-classification-indexes.ts +29 -0
  118. package/build/migrations-v2/0000000000035-core-change-autovacuum.ts +24 -0
  119. package/build/migrations-v2/0000000000036-journal-entry-inactive-reason-constraint.ts +33 -0
  120. package/build/migrations-v2/0000000000037-journal-entry-inactive-reasons.ts +19 -0
  121. package/build/{migrations/0000000000023-journal-entry-currency-mismatch-reason.ts → migrations-v2/0000000000038-journal-entry-group-inactive-reason.ts} +4 -4
  122. package/build/migrations-v2/0000000000039-reservation-guest-breakdown.ts +19 -0
  123. package/build/migrations-v2/0000000000040-csv-import-source-identity-index.ts +23 -0
  124. package/build/migrations-v2/0000000000041-payment-returns.ts +38 -0
  125. package/build/migrations-v2/0000000000042-operation-resource-types.ts +609 -0
  126. package/build/migrations-v2/0000000000043-reservation-journal-freshness.ts +149 -0
  127. package/build/migrations-v2/0000000000044-reservation-journal-freshness-backfill.ts +254 -0
  128. package/build/migrations-v2/0000000000045-reservation-journal-freshness-revision-repair.ts +83 -0
  129. package/build/migrations-v2/0000000000046-materialized-reservation-journal-operations.ts +709 -0
  130. package/build/migrations-v2/0000000000047-public-audit-completion.ts +77 -0
  131. package/build/migrations-v2/0000000000048-reservation-journal-full-refresh-repair.ts +136 -0
  132. package/build/migrations-v2/0000000000049-queued-journal-operation-failures.ts +60 -0
  133. package/build/migrations-v2/0000000000050-connection-oauth-state.ts +43 -0
  134. package/build/migrations-v2/0000000000051-owner-statement-email-delivery.ts +134 -0
  135. package/build/migrations-v2/0000000000052-fee-journal-lock-skip-operations.ts +59 -0
  136. package/build/migrations-v2/0000000000053-fee-journal-lock-skip-null-attempt.ts +44 -0
  137. package/build/migrations-v2/0000000000054-journal-refresh-issue-codes.ts +16 -0
  138. package/build/migrations-v2/0000000000055-tenant-billing-subscription.ts +8 -0
  139. package/build/migrations-v2/0000000000056-journal-operation-failure-precedence.ts +306 -0
  140. package/build/migrations-v2/0000000000057-journal-invalidation-failure-code.ts +28 -0
  141. package/build/migrations-v2/0000000000058-journal-invalidation-locked-failure.ts +16 -0
  142. package/build/migrations-v2/0000000000059-billing-active-listing-cross-region-partner.ts +135 -0
  143. package/build/migrations-v2/0000000000060-accounting-integrity-change-driven.ts +99 -0
  144. package/build/migrations-v2/0000000000061-tenant-pending-onboarding-status.ts +37 -0
  145. package/build/migrations-v2/0000000000062-statement-payout-operations.ts +16 -0
  146. package/build/migrations-v2/0000000000063-missing-account-assignments-issue-code.ts +13 -0
  147. package/build/migrations-v2/0000000000064-journal-invalidation-source-lookup-index.ts +26 -0
  148. package/build/migrations-v2/0000000000065-hasura-connection-event-credentials.ts +42 -0
  149. package/build/migrations-v2/0000000000066-recurring-fee-listing-subscription-match-by.ts +51 -0
  150. package/build/migrations-v2/0000000000067-connection-credential-metadata.ts +60 -0
  151. package/build/migrations-v2/0000000000068-connection-credential-version.ts +34 -0
  152. package/build/migrations-v2/0000000000069-owner-statement-contact-email-delivery.ts +84 -0
  153. package/build/migrations-v2/0000000000070-payment-writer-compatibility.ts +69 -0
  154. package/build/migrations-v2/0000000000071-payments.ts +532 -0
  155. package/build/migrations-v2/0000000000072-journal-entry-payment-index.ts +21 -0
  156. package/build/migrations-v2/0000000000073-batch-invalidation-operation-registration.ts +74 -0
  157. package/build/migrations-v2/0000000000074-owner-statement-email-history.ts +34 -0
  158. package/build/migrations-v2/0000000000075-tenant-deletion-lookup-indexes.ts +46 -0
  159. package/build/migrations-v2/0000000000076-tenant-onboarding-not-null.ts +23 -0
  160. package/build/migrations-v2/0000000000077-payment-writer-statement-attachment.ts +92 -0
  161. package/build/migrations-v2/0000000000078-trigger-timeout-indexes.ts +44 -0
  162. package/build/migrations-v2/0000000000079-core-change-tenant-statistics.ts +26 -0
  163. package/build/migrations-v2/0000000000080-drop-legacy-tracking-event.ts +60 -0
  164. package/build/migrations-v2/0000000000081-recurring-fee-planner-operation-status.ts +35 -0
  165. package/build/migrations-v2/0000000000082-reservation-search-trigram-indexes.ts +54 -0
  166. package/build/migrations-v2/0000000000083-journal-entry-deposit-lookup-index.ts +31 -0
  167. package/build/migrations-v2/0000000000084-journal-entry-reservation-revenue-indexes.ts +57 -0
  168. package/build/migrations-v2/0000000000085-owner-statement-link-email-template.ts +23 -0
  169. package/build/migrations-v2/0000000000086-contact-payment-setup.ts +72 -0
  170. package/build/migrations-v2/0000000000087-address-delete-fk-indexes.ts +30 -0
  171. package/build/migrations-v2/0000000000088-owner-statement-email-switch.ts +76 -0
  172. package/build/migrations-v2/0000000000089-contact-bank-details-requested-at.ts +21 -0
  173. package/build/migrations-v2/0000000000090-contact-bank-account-api-key.ts +22 -0
  174. package/build/migrations-v2/0000000000091-contact-bank-details-request.ts +78 -0
  175. package/build/migrations-v2/0000000000092-payment-provider-reference.ts +22 -0
  176. package/build/migrations-v2/0000000000093-payment-reversal-offline-undo.ts +18 -0
  177. package/build/migrations-v2/0000000000094-reservation-status-checkout-index.ts +37 -0
  178. package/build/migrations-v2/0000000000095-payment-batches.ts +196 -0
  179. package/build/migrations-v2/0000000000096-guide-ongoing-tasks-issue-codes.ts +26 -0
  180. package/build/migrations-v2/0000000000097-reservation-line-mapping-suggestions.ts +53 -0
  181. package/build/migrations-v2/0000000000098-cancelled-reservation-balances-issue-code.ts +13 -0
  182. package/build/migrations-v2/0000000000099-contact-bank-account-request-source.ts +28 -0
  183. package/build/migrations-v2/0000000000100-drop-regional-feature-flags.ts +105 -0
  184. package/build/migrations-v2/0000000000101-bank-record-match-source.ts +45 -0
  185. package/build/migrations-v2/0000000000102-owner-statement-email-one-template.ts +63 -0
  186. package/build/migrations-v2/0000000000103-reservation-line-mapping-update-operation.ts +10 -0
  187. package/build/migrations-v2/0000000000104-export-job-payment-batch-pdf.ts +12 -0
  188. package/build/migrations-v2/0000000000105-drop-regional-token.ts +60 -0
  189. package/build/migrations-v2/0000000000106-incremental-audit-action-source.ts +158 -0
  190. package/build/migrations-v2/0000000000107-audit-mutation-transaction-insert-index.ts +44 -0
  191. package/build/migrations-v2/0000000000108-reservation-stay-type.ts +24 -0
  192. package/build/migrations-v2/0000000000109-long-term-liabilities-category-order.ts +21 -0
  193. package/build/migrations-v2/0000000000110-pms-sync-failures-issue-code.ts +13 -0
  194. package/build/migrations-v2/0000000000110-reservation-line-type-taxable.ts +21 -0
  195. package/build/migrations-v2/0000000000111-reservation-line-type-suggestion-taxable.ts +20 -0
  196. package/build/migrations-v2/0000000000112-contact-payment-method-outside-default.ts +44 -0
  197. package/build/migrations-v2/0000000000113-merchant-fee-reference-assignment.ts +25 -0
  198. package/build/migrations-v2/0000000000114-recurring-fee-nights-filter.ts +32 -0
  199. package/build/migrations-v2/0000000000115-bank-records-with-suggested-rule-issue-code.ts +13 -0
  200. package/build/migrations-v2/0000000000116-guest-review.ts +45 -0
  201. package/build/migrations-v2/0000000000117-ramp-external-funding-accounts.ts +91 -0
  202. package/build/migrations-v2/0000000000118-pm-payout-assignment.ts +25 -0
  203. package/build/migrations-v2/0000000000119-chart-of-accounts-classifications.ts +46 -0
  204. package/build/migrations-v2/0000000000120-feedback.ts +41 -0
  205. package/build/migrations-v2/0000000000121-source-owner-block-calendar-index.ts +43 -0
  206. package/build/migrations-v2/0000000000122-recurring-fee-stay-types-filter.ts +20 -0
  207. package/build/migrations-v2/0000000000123-reservation-owner-stay-type-index.ts +40 -0
  208. package/build/migrations-v2/0000000000124-remove-tenant-test-and-billable-columns.ts +63 -0
  209. package/build/migrations-v2/0000000000125-ramp-application.ts +56 -0
  210. package/build/migrations-v2/0000000000126-advanced-deposits-update-operation.ts +10 -0
  211. package/build/migrations-v2/0000000000127-contact-1099-tax-details.ts +46 -0
  212. package/build/migrations-v2/0000000000128-tax-1099-email-templates.ts +36 -0
  213. package/build/migrations-v2/0000000000129-tenant-locked-at.ts +18 -0
  214. package/build/migrations-v2/0000000000130-second-factor-reset.ts +65 -0
  215. package/build/migrations-v2/0000000000131-payout-hold.ts +49 -0
  216. package/build/migrations-v2/0000000000132-member-invite-approval.ts +62 -0
  217. package/build/migrations-v2/0000000000133-audit-action-client-ip.ts +38 -0
  218. package/build/migrations-v2/0000000000134-drop-orphaned-hasura-triggers.ts +39 -0
  219. package/build/migrations-v2/0000000000135-drop-orphaned-hasura-triggers-literal.ts +42 -0
  220. package/build/migrations-v2/0000000000136-drop-all-hasura-triggers.ts +43 -0
  221. package/build/migrations-v2/0000000000137-webhook-event.ts +57 -0
  222. package/build/migrations-v2/0000000000138-contact-tax-details-requested-at.ts +24 -0
  223. package/build/migrations-v2/0000000000139-tax-statement-1099.ts +140 -0
  224. package/build/migrations-v2/0000000000140-owner-payment-settings.ts +53 -0
  225. package/build/migrations-v2/0000000000141-owner-payment-requests.ts +100 -0
  226. package/build/migrations-v2/0000000000148-statement-level-operation-triggers.ts +229 -0
  227. package/build/migrations-v2/0000000000150-recurring-fee-listing-subscription-listing-index.ts +37 -0
  228. package/build/migrations-v2/0000000000151-core-change-unused-indexes.ts +85 -0
  229. package/build/migrations-v2/0000000000152-core-change-pms-sync-failures-index.ts +38 -0
  230. package/build/migrations-v2/0000000000154-accounting-integrity-backlog-performance.ts +68 -0
  231. package/build/migrations-v2/0000000000155-source-last-successful-hash.ts +23 -0
  232. package/build/module/camel-case/index.d.ts +4 -4
  233. package/build/module/camel-case/index.js +4 -3
  234. package/build/module/camel-case/index.js.map +1 -1
  235. package/build/module/connect-handoff.d.ts +12 -0
  236. package/build/module/connect-handoff.js +70 -0
  237. package/build/module/connect-handoff.js.map +1 -0
  238. package/build/module/control-plane/index.d.ts +421 -14
  239. package/build/module/control-plane/index.js +58 -1
  240. package/build/module/control-plane/index.js.map +1 -1
  241. package/build/module/domain.d.ts +4 -0
  242. package/build/module/domain.js +2 -0
  243. package/build/module/domain.js.map +1 -0
  244. package/build/module/error.d.ts +2 -1
  245. package/build/module/error.js +3 -1
  246. package/build/module/error.js.map +1 -1
  247. package/build/module/index.d.ts +57 -15
  248. package/build/module/index.js +496 -64
  249. package/build/module/index.js.map +1 -1
  250. package/build/module/isomorphic.d.ts +6 -6
  251. package/build/module/isomorphic.js +2 -7
  252. package/build/module/isomorphic.js.map +1 -1
  253. package/build/module/local/digest.d.ts +3 -3
  254. package/build/module/local/digest.js.map +1 -1
  255. package/build/module/local/generate.js +15 -13
  256. package/build/module/local/generate.js.map +1 -1
  257. package/build/module/local/index.d.ts +5 -1
  258. package/build/module/local/index.js +347 -13
  259. package/build/module/local/index.js.map +1 -1
  260. package/build/module/local/prune-pulled-schema.js +4 -1
  261. package/build/module/local/prune-pulled-schema.js.map +1 -1
  262. package/build/module/migration-source.d.ts +4 -0
  263. package/build/module/migration-source.js +42 -0
  264. package/build/module/migration-source.js.map +1 -0
  265. package/build/module/migration.d.ts +7 -0
  266. package/build/module/migration.js +8 -0
  267. package/build/module/migration.js.map +1 -0
  268. package/build/module/pganalyze-comment-plugin/comment-transformer.js +3 -1
  269. package/build/module/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  270. package/build/module/plugins.d.ts +2 -2
  271. package/build/module/plugins.js.map +1 -1
  272. package/build/module/postgres-error.d.ts +9 -0
  273. package/build/module/postgres-error.js +24 -0
  274. package/build/module/postgres-error.js.map +1 -0
  275. package/build/module/query/index.d.ts +1 -0
  276. package/build/module/query/index.js +1 -0
  277. package/build/module/query/index.js.map +1 -1
  278. package/build/module/query/listing/status.d.ts +2 -12
  279. package/build/module/query/listing/status.js +35 -18
  280. package/build/module/query/listing/status.js.map +1 -1
  281. package/build/module/query/tenant/billing-partner.d.ts +4 -0
  282. package/build/module/query/tenant/billing-partner.js +5 -0
  283. package/build/module/query/tenant/billing-partner.js.map +1 -0
  284. package/build/module/query/tenant/feature-enabled.d.ts +6 -0
  285. package/build/module/query/tenant/feature-enabled.js +27 -0
  286. package/build/module/query/tenant/feature-enabled.js.map +1 -0
  287. package/build/module/query/tenant/index.d.ts +4 -0
  288. package/build/module/query/tenant/index.js +5 -0
  289. package/build/module/query/tenant/index.js.map +1 -0
  290. package/build/module/query/tenant/status.d.ts +9 -0
  291. package/build/module/query/tenant/status.js +28 -0
  292. package/build/module/query/tenant/status.js.map +1 -0
  293. package/build/module/query/tenant/where-uuid-in.d.ts +2 -0
  294. package/build/module/query/tenant/where-uuid-in.js +11 -0
  295. package/build/module/query/tenant/where-uuid-in.js.map +1 -0
  296. package/build/module/regional.d.ts +31 -4
  297. package/build/module/regional.js +68 -8
  298. package/build/module/regional.js.map +1 -1
  299. package/build/module/test/index.d.ts +21 -11
  300. package/build/module/test/index.js +31 -26
  301. package/build/module/test/index.js.map +1 -1
  302. package/build/module/transaction.d.ts +3 -3
  303. package/build/module/transaction.js.map +1 -1
  304. package/build/module/v1.generated.d.ts +1407 -177
  305. package/build/module/v1.generated.js.map +1 -1
  306. package/package.json +19 -16
  307. package/build/migrations/0000000000001-init.ts +0 -5
  308. package/build/migrations/0000000000009-drop-store-schema.ts +0 -14
  309. package/build/migrations/0000000000010-bank-rules.ts +0 -190
  310. package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +0 -65
  311. package/build/migrations/0000000000012-bank-rule-conditions.ts +0 -45
  312. package/build/migrations/0000000000013-bank-rule-name-unique.ts +0 -15
  313. package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +0 -41
  314. package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +0 -70
  315. package/build/migrations/0000000000016-owner-statement-draft-status.ts +0 -22
  316. package/build/migrations/0000000000017-tenant-migration-markers.ts +0 -18
  317. package/build/migrations/0000000000018-security-deposits-payable-category.ts +0 -63
  318. package/build/migrations/0000000000019-tenant-app-settings.ts +0 -76
  319. package/build/migrations/0000000000020-operating-opening-trial-balance.ts +0 -36
  320. package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +0 -77
  321. package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +0 -30
  322. package/build/migrations/0000000000024-listing-parent.ts +0 -37
  323. package/build/migrations/0000000000025-journal-entry-parent-listing.ts +0 -26
  324. package/build/migrations/0000000000026-booking-channel-logo-slots.ts +0 -89
  325. package/build/migrations/0000000000027-list-browse-performance-indexes.ts +0 -52
  326. package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +0 -20
  327. package/build/migrations/0000000000029-tenant-slug.ts +0 -328
  328. package/build/migrations/0000000000030-pms-accounting-windows.ts +0 -50
  329. package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +0 -20
  330. package/build/migrations/0000000000032-flow-event-listening.ts +0 -28
  331. package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +0 -272
  332. package/build/migrations/0000000000034-historic-general-ledger.ts +0 -24
  333. package/build/migrations/0000000000035-tenant-regional-placement.ts +0 -37
  334. package/build/migrations/0000000000036-control-plane-projection-events.ts +0 -43
  335. package/build/migrations/0000000000037-tenant-guide-onboarding.ts +0 -21
  336. package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +0 -31
  337. package/build/migrations/0000000000039-crunchy-region.ts +0 -86
  338. package/build/migrations/0000000000040-hostaway-region.ts +0 -72
  339. package/build/migrations/0000000000041-audit-tenant-fk.ts +0 -66
  340. package/build/migrations/0000000000042-ramp-staging-connect-params.ts +0 -35
  341. package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +0 -125
  342. package/build/migrations/0000000000044-tenant-cross-region-fks.ts +0 -45
  343. package/build/migrations/0000000000045-cloudflare-region-env.ts +0 -100
  344. package/build/migrations/0000000000046-control-plane-outbox-alias.ts +0 -46
  345. package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +0 -16
  346. package/build/migrations/0000000000047-tenant-status-backfill.ts +0 -40
  347. package/build/migrations/0000000000048-tenant-status-constraint.ts +0 -24
  348. package/build/migrations/0000000000049-health-tenant-issues.ts +0 -69
  349. package/build/migrations/0000000000050-partner-webhooks.ts +0 -135
  350. package/build/migrations/0000000000051-health-webhook-runtime-grants.ts +0 -42
  351. package/build/migrations/0000000000052-feature-approval-team-enablement.ts +0 -13
  352. package/build/migrations/0000000000053-health-webhook-enums.ts +0 -296
@@ -0,0 +1,100 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // PRO-20791: a payment request asks the owner to pay what a published
5
+ // statement owes, and an owner payment is one payment against it. A statement
6
+ // has at most one request that is not canceled. A payment posts nothing by
7
+ // itself: its receipt is the transaction it links once the Stripe payout is
8
+ // deposited.
9
+ // Expand only; code that predates the tables ignores them.
10
+ export async function up(db: Kysely<unknown>): Promise<void> {
11
+ await sql`set local lock_timeout = '5s'`.execute(db);
12
+ await sql`set local statement_timeout = '60s'`.execute(db);
13
+
14
+ await sql`
15
+ create type accounting.owner_payment_status as enum (
16
+ 'processing', 'received', 'paid', 'failed', 'returned'
17
+ )
18
+ `.execute(db);
19
+ await sql`
20
+ create table accounting.owner_payment_request (
21
+ id uuid primary key default gen_random_uuid(),
22
+ tenant_id uuid not null references public.tenant (id) on delete cascade,
23
+ owner_statement_id uuid not null
24
+ references public.owner_statement (id) on delete cascade,
25
+ amount integer not null check (amount > 0),
26
+ currency text not null references public.currency (name),
27
+ due_at date not null,
28
+ payment_methods accounting.owner_payment_method[] not null,
29
+ created_by_user_id uuid null references public.user (id) on delete set null,
30
+ canceled_at timestamptz null,
31
+ created_at timestamptz not null default now(),
32
+ updated_at timestamptz not null default now()
33
+ )
34
+ `.execute(db);
35
+ await sql`
36
+ create unique index owner_payment_request_open_statement_idx
37
+ on accounting.owner_payment_request (owner_statement_id)
38
+ where canceled_at is null
39
+ `.execute(db);
40
+ await sql`
41
+ create index owner_payment_request_statement_idx
42
+ on accounting.owner_payment_request (tenant_id, owner_statement_id)
43
+ `.execute(db);
44
+ await sql`
45
+ create index owner_payment_request_created_by_user_idx
46
+ on accounting.owner_payment_request (created_by_user_id)
47
+ `.execute(db);
48
+
49
+ await sql`
50
+ create table accounting.owner_payment (
51
+ id uuid primary key default gen_random_uuid(),
52
+ tenant_id uuid not null references public.tenant (id) on delete cascade,
53
+ owner_payment_request_id uuid not null
54
+ references accounting.owner_payment_request (id) on delete cascade,
55
+ contact_id uuid null references accounting.contact (id) on delete set null,
56
+ amount integer not null check (amount > 0),
57
+ method accounting.owner_payment_method not null,
58
+ status accounting.owner_payment_status not null default 'processing',
59
+ bank_last4 text null check (bank_last4 is null or bank_last4 ~ '^[0-9]{4}$'),
60
+ expected_payout_at date null,
61
+ transaction_id uuid null
62
+ references accounting.transaction (id) on delete set null,
63
+ received_at timestamptz null,
64
+ paid_at timestamptz null,
65
+ failed_at timestamptz null,
66
+ returned_at timestamptz null,
67
+ created_at timestamptz not null default now(),
68
+ updated_at timestamptz not null default now()
69
+ )
70
+ `.execute(db);
71
+ await sql`
72
+ create index owner_payment_request_idx
73
+ on accounting.owner_payment (tenant_id, owner_payment_request_id)
74
+ `.execute(db);
75
+ await sql`
76
+ create index owner_payment_contact_idx
77
+ on accounting.owner_payment (contact_id)
78
+ `.execute(db);
79
+ await sql`
80
+ create index owner_payment_transaction_idx
81
+ on accounting.owner_payment (transaction_id)
82
+ `.execute(db);
83
+ await sql`
84
+ do $$
85
+ begin
86
+ if exists (select 1 from pg_roles where rolname = 'application') then
87
+ grant select, insert, update, delete
88
+ on accounting.owner_payment_request, accounting.owner_payment
89
+ to application;
90
+ end if;
91
+ end;
92
+ $$
93
+ `.execute(db);
94
+ }
95
+
96
+ export async function down(db: Kysely<unknown>): Promise<void> {
97
+ await sql`drop table if exists accounting.owner_payment`.execute(db);
98
+ await sql`drop table if exists accounting.owner_payment_request`.execute(db);
99
+ await sql`drop type if exists accounting.owner_payment_status`.execute(db);
100
+ }
@@ -0,0 +1,229 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // The effect runner writes 25 effects of one action per statement: the claim,
5
+ // the attempt insert, the invalidation apply, the completion and the attempt
6
+ // completion. Row triggers refreshed the action's operation source once per row,
7
+ // 25 identical refreshes after each statement, and each one scans the action's
8
+ // active effects (40,000 for the largest US actions). Statement triggers refresh
9
+ // each action of a statement once, in action order (PRO-20933).
10
+ //
11
+ // A trigger with transition tables fires on one event, so insert, update and
12
+ // delete each get a trigger. The update triggers keep their names; the functions
13
+ // keep their names for the region migration bypass (scripts/migrate-region).
14
+ export async function up<Database>(db: Kysely<Database>): Promise<void> {
15
+ await sql`set local lock_timeout = '5s'`.execute(db);
16
+
17
+ await sql`drop trigger refresh_audit_action_operation on audit.effect`.execute(
18
+ db
19
+ );
20
+ await sql`
21
+ drop trigger refresh_audit_action_operation_attempt on audit.effect_attempt
22
+ `.execute(db);
23
+ await sql`
24
+ drop trigger refresh_reservation_journal_invalidation_operation
25
+ on accounting.reservation_journal_invalidation
26
+ `.execute(db);
27
+
28
+ // An update refreshes only when a column the old row trigger listed changed.
29
+ for (const [name, columns] of [
30
+ [
31
+ 'refresh_audit_action_operation',
32
+ 'status, retry_count, claimed_at, completed_at, last_attempt_at',
33
+ ],
34
+ [
35
+ 'refresh_audit_action_operation_attempt',
36
+ 'status, result_code, finished_at',
37
+ ],
38
+ ] as const) {
39
+ const changed = sql.raw(
40
+ `(${columns
41
+ .split(', ')
42
+ .map((column) => `changed_rows.${column}`)
43
+ .join(', ')}) is distinct from (${columns
44
+ .split(', ')
45
+ .map((column) => `old_rows.${column}`)
46
+ .join(', ')})`
47
+ );
48
+ await sql`
49
+ create or replace function ${sql.raw(`core.${name}`)}()
50
+ returns trigger
51
+ language plpgsql
52
+ as $$
53
+ declare
54
+ target_action_id uuid;
55
+ begin
56
+ if tg_op = 'UPDATE' then
57
+ for target_action_id in
58
+ select distinct changed_rows.action_id
59
+ from changed_rows
60
+ inner join old_rows on old_rows.id = changed_rows.id
61
+ where changed_rows.action_id is not null and ${changed}
62
+ order by changed_rows.action_id
63
+ loop
64
+ perform core.refresh_audit_action_source(target_action_id);
65
+ end loop;
66
+ return null;
67
+ end if;
68
+ for target_action_id in
69
+ select distinct action_id from changed_rows
70
+ where action_id is not null
71
+ order by action_id
72
+ loop
73
+ perform core.refresh_audit_action_source(target_action_id);
74
+ end loop;
75
+ return null;
76
+ end;
77
+ $$
78
+ `.execute(db);
79
+ }
80
+
81
+ // New actions register, old actions of a moved row refresh. One loop in
82
+ // action order keeps the operation source locks in one order (PRO-19762).
83
+ await sql`
84
+ create or replace function core.refresh_reservation_journal_invalidation_operation()
85
+ returns trigger
86
+ language plpgsql
87
+ as $$
88
+ declare
89
+ target record;
90
+ begin
91
+ for target in
92
+ select action_id, bool_or(registers) as registers
93
+ from (
94
+ select changed_rows.action_id, true as registers
95
+ from changed_rows
96
+ inner join old_rows on old_rows.id = changed_rows.id
97
+ where changed_rows.action_id is not null
98
+ and (changed_rows.action_id, changed_rows.applied_at)
99
+ is distinct from (old_rows.action_id, old_rows.applied_at)
100
+ union all
101
+ select old_rows.action_id, false
102
+ from old_rows
103
+ inner join changed_rows on changed_rows.id = old_rows.id
104
+ where old_rows.action_id is not null
105
+ and old_rows.action_id is distinct from changed_rows.action_id
106
+ ) as touched
107
+ group by action_id
108
+ order by action_id
109
+ loop
110
+ if target.registers then
111
+ perform core.register_reservation_journal_operation(target.action_id);
112
+ else
113
+ perform core.refresh_audit_action_source(target.action_id);
114
+ end if;
115
+ end loop;
116
+ return null;
117
+ end;
118
+ $$
119
+ `.execute(db);
120
+
121
+ for (const [table, name] of [
122
+ ['audit.effect', 'refresh_audit_action_operation'],
123
+ ['audit.effect_attempt', 'refresh_audit_action_operation_attempt'],
124
+ ] as const) {
125
+ const target = sql.raw(table);
126
+ const fn = sql.raw(`core.${name}()`);
127
+ await sql`
128
+ create trigger ${sql.raw(`${name}_insert`)}
129
+ after insert on ${target}
130
+ referencing new table as changed_rows
131
+ for each statement execute function ${fn}
132
+ `.execute(db);
133
+ await sql`
134
+ create trigger ${sql.raw(name)}
135
+ after update on ${target}
136
+ referencing old table as old_rows new table as changed_rows
137
+ for each statement execute function ${fn}
138
+ `.execute(db);
139
+ await sql`
140
+ create trigger ${sql.raw(`${name}_delete`)}
141
+ after delete on ${target}
142
+ referencing old table as changed_rows
143
+ for each statement execute function ${fn}
144
+ `.execute(db);
145
+ }
146
+ await sql`
147
+ create trigger refresh_reservation_journal_invalidation_operation
148
+ after update on accounting.reservation_journal_invalidation
149
+ referencing old table as old_rows new table as changed_rows
150
+ for each statement
151
+ execute function core.refresh_reservation_journal_invalidation_operation()
152
+ `.execute(db);
153
+ }
154
+
155
+ export async function down<Database>(db: Kysely<Database>): Promise<void> {
156
+ await sql`set local lock_timeout = '5s'`.execute(db);
157
+
158
+ for (const [table, name] of [
159
+ ['audit.effect', 'refresh_audit_action_operation'],
160
+ ['audit.effect_attempt', 'refresh_audit_action_operation_attempt'],
161
+ ] as const) {
162
+ for (const trigger of [`${name}_insert`, name, `${name}_delete`]) {
163
+ await sql`drop trigger ${sql.raw(trigger)} on ${sql.raw(table)}`.execute(
164
+ db
165
+ );
166
+ }
167
+ }
168
+ await sql`
169
+ drop trigger refresh_reservation_journal_invalidation_operation
170
+ on accounting.reservation_journal_invalidation
171
+ `.execute(db);
172
+
173
+ for (const name of [
174
+ 'refresh_audit_action_operation',
175
+ 'refresh_audit_action_operation_attempt',
176
+ ]) {
177
+ await sql`
178
+ create or replace function ${sql.raw(`core.${name}`)}()
179
+ returns trigger
180
+ language plpgsql
181
+ as $$
182
+ begin
183
+ perform core.refresh_audit_action_source(
184
+ coalesce(new.action_id, old.action_id)
185
+ );
186
+ return coalesce(new, old);
187
+ end;
188
+ $$
189
+ `.execute(db);
190
+ }
191
+ await sql`
192
+ create or replace function core.refresh_reservation_journal_invalidation_operation()
193
+ returns trigger
194
+ language plpgsql
195
+ as $$
196
+ begin
197
+ if new.action_id is not null then
198
+ perform core.register_reservation_journal_operation(new.action_id);
199
+ end if;
200
+ if tg_op = 'UPDATE'
201
+ and old.action_id is distinct from new.action_id
202
+ and old.action_id is not null then
203
+ perform core.refresh_audit_action_source(old.action_id);
204
+ end if;
205
+ return new;
206
+ end;
207
+ $$
208
+ `.execute(db);
209
+
210
+ await sql`
211
+ create trigger refresh_audit_action_operation
212
+ after insert or update of status, retry_count, claimed_at, completed_at, last_attempt_at
213
+ or delete on audit.effect
214
+ for each row execute function core.refresh_audit_action_operation()
215
+ `.execute(db);
216
+ await sql`
217
+ create trigger refresh_audit_action_operation_attempt
218
+ after insert or update of status, result_code, finished_at or delete
219
+ on audit.effect_attempt
220
+ for each row execute function core.refresh_audit_action_operation_attempt()
221
+ `.execute(db);
222
+ await sql`
223
+ create trigger refresh_reservation_journal_invalidation_operation
224
+ after update of action_id, applied_at
225
+ on accounting.reservation_journal_invalidation
226
+ for each row
227
+ execute function core.refresh_reservation_journal_invalidation_operation()
228
+ `.execute(db);
229
+ }
@@ -0,0 +1,37 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // Journal refreshes load subscriptions by listing_id (PRO-20940). The existing
5
+ // unique index starts with recurring_fee_id, so the lookup sequentially scans
6
+ // the table on large databases. On large databases run
7
+ // scripts/ben-2/pro-20940-create-listing-index.ts first; it builds the index
8
+ // concurrently, and this migration then skips the table-locking create.
9
+ export async function up(db: Kysely<unknown>): Promise<void> {
10
+ await sql`set local lock_timeout = '5s'`.execute(db);
11
+ await sql`set local statement_timeout = '30min'`.execute(db);
12
+ const existing = await sql<{ valid: boolean }>`
13
+ select (i.indisvalid and i.indisready and i.indislive) as valid
14
+ from pg_index as i
15
+ inner join pg_class as index_class on index_class.oid = i.indexrelid
16
+ where index_class.relnamespace = 'public'::regnamespace
17
+ and index_class.relname = 'recurring_fee_listing_subscription_listing_id_idx'
18
+ `.execute(db);
19
+ if (existing.rows[0]?.valid) return;
20
+ if (existing.rows[0]) {
21
+ await sql`
22
+ drop index public.recurring_fee_listing_subscription_listing_id_idx
23
+ `.execute(db);
24
+ }
25
+ await sql`
26
+ create index recurring_fee_listing_subscription_listing_id_idx
27
+ on public.recurring_fee_listing_subscription (listing_id)
28
+ `.execute(db);
29
+ }
30
+
31
+ export async function down(db: Kysely<unknown>): Promise<void> {
32
+ await sql`set local lock_timeout = '5s'`.execute(db);
33
+ await sql`set local statement_timeout = '60s'`.execute(db);
34
+ await sql`
35
+ drop index if exists public.recurring_fee_listing_subscription_listing_id_idx
36
+ `.execute(db);
37
+ }
@@ -0,0 +1,85 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // Every insert into core.change maintained 22 to 23 indexes, and on Crunchy
5
+ // they took 1,070 GB (PRO-20935). These are covered by other indexes or no
6
+ // query uses them:
7
+ // - core_change_sync_metrics_covering_idx: the sync metrics query reads the
8
+ // same keys from idx_change_metrics_source, which deduplicates and is about
9
+ // a tenth of the size. Crunchy lacked it since 2026-11-14 and gets it here.
10
+ // - change_sync_id_idx: change_sync_id_tenant_id_idx and the unique keys on
11
+ // (sync_id, ...) start with sync_id.
12
+ // - change_entity_id: change_entity_seq_tenant_idx starts with entity_id.
13
+ // - change_connection_id_tenant_id_idx: no scans; its keys lead
14
+ // change_connection_id_tenant_id_created_at_idx2.
15
+ // - idx_change_entity_seq_brin: no scans since October, dropped on Crunchy on
16
+ // 2026-11-14.
17
+ // Crunchy keeps change_tenant_id_id_idx and change_source_link_tenant_id_id_idx,
18
+ // built by hand: scripts/migrate-region pages a team's rows by id through any
19
+ // (tenant_id, id) index while teams still move off Crunchy.
20
+ // On large databases run scripts/ben-2/pro-20935-change-indexes.ts first: it
21
+ // builds and drops concurrently, and this migration then finds nothing to do.
22
+ const dropped = [
23
+ 'core_change_sync_metrics_covering_idx',
24
+ 'change_sync_id_idx',
25
+ 'change_entity_id',
26
+ 'change_connection_id_tenant_id_idx',
27
+ 'idx_change_entity_seq_brin',
28
+ ];
29
+
30
+ export async function up(db: Kysely<unknown>): Promise<void> {
31
+ await sql`set local lock_timeout = '5s'`.execute(db);
32
+ await sql`set local statement_timeout = '30min'`.execute(db);
33
+ const existing = await sql<{ valid: boolean }>`
34
+ select (i.indisvalid and i.indisready) as valid
35
+ from pg_index as i
36
+ inner join pg_class as index_class on index_class.oid = i.indexrelid
37
+ where index_class.relname = 'idx_change_metrics_source'
38
+ `.execute(db);
39
+ // `create index if not exists` locks the table before it finds the index, which
40
+ // times out on a busy database, so skip a valid pre-built index here.
41
+ if (!existing.rows[0]?.valid) {
42
+ // A failed concurrent build leaves an invalid index that `if not exists`
43
+ // would keep, so drop it first.
44
+ if (existing.rows[0]) {
45
+ await sql`drop index core.idx_change_metrics_source`.execute(db);
46
+ }
47
+ await sql`
48
+ create index idx_change_metrics_source
49
+ on core.change (tenant_id, connection_id, sync_type, created_at desc)
50
+ where entity_type = 'source'
51
+ `.execute(db);
52
+ }
53
+ for (const name of dropped) {
54
+ await sql`drop index if exists core.${sql.id(name)}`.execute(db);
55
+ }
56
+ }
57
+
58
+ export async function down(db: Kysely<unknown>): Promise<void> {
59
+ await sql`set local lock_timeout = '5s'`.execute(db);
60
+ await sql`set local statement_timeout = '30min'`.execute(db);
61
+ // Restores the indexes up() dropped. On Crunchy and US rebuild them with
62
+ // create index concurrently first: a plain build blocks writes for hours.
63
+ await sql`
64
+ create index if not exists core_change_sync_metrics_covering_idx
65
+ on core.change (tenant_id, connection_id, sync_type, created_at desc)
66
+ include (status, entity_id, id)
67
+ where entity_type = 'source'
68
+ and status in ('completed', 'failed', 'queued', 'skipped')
69
+ and entity_id is not null
70
+ `.execute(db);
71
+ await sql`
72
+ create index if not exists change_sync_id_idx on core.change (sync_id)
73
+ `.execute(db);
74
+ await sql`
75
+ create index if not exists change_entity_id on core.change (entity_id)
76
+ `.execute(db);
77
+ await sql`
78
+ create index if not exists change_connection_id_tenant_id_idx
79
+ on core.change (connection_id, tenant_id) where seq is not null
80
+ `.execute(db);
81
+ await sql`
82
+ create index if not exists idx_change_entity_seq_brin
83
+ on core.change using brin (entity_id, seq)
84
+ `.execute(db);
85
+ }
@@ -0,0 +1,38 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // Portfolio health counts failed latest changes for active PMS connections
5
+ // (PRO-20712). The partial index excludes historical and non-failed changes,
6
+ // which avoids scanning core.change for every tenant. On large databases run
7
+ // scripts/ben-2/pro-20712-create-pms-sync-failures-index.ts first; it builds the
8
+ // index concurrently, and this migration then skips the table-locking create.
9
+ export async function up(db: Kysely<unknown>): Promise<void> {
10
+ await sql`set local lock_timeout = '5s'`.execute(db);
11
+ await sql`set local statement_timeout = '30min'`.execute(db);
12
+ const existing = await sql<{ valid: boolean }>`
13
+ select (i.indisvalid and i.indisready and i.indislive) as valid
14
+ from pg_index as i
15
+ inner join pg_class as index_class on index_class.oid = i.indexrelid
16
+ where i.indrelid = 'core.change'::regclass
17
+ and index_class.relname = 'change_pms_sync_failures_idx'
18
+ `.execute(db);
19
+ if (existing.rows[0]?.valid) return;
20
+ if (existing.rows[0]) {
21
+ await sql`
22
+ drop index core.change_pms_sync_failures_idx
23
+ `.execute(db);
24
+ }
25
+ await sql`
26
+ create index change_pms_sync_failures_idx
27
+ on core.change (tenant_id, connection_id)
28
+ where is_latest_version = true and status = 'failed'
29
+ `.execute(db);
30
+ }
31
+
32
+ export async function down(db: Kysely<unknown>): Promise<void> {
33
+ await sql`set local lock_timeout = '5s'`.execute(db);
34
+ await sql`set local statement_timeout = '60s'`.execute(db);
35
+ await sql`
36
+ drop index if exists core.change_pms_sync_failures_idx
37
+ `.execute(db);
38
+ }
@@ -0,0 +1,68 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // Accounting integrity performance (PRO-20941):
5
+ // - The sweep stores the eligible record count of its cycle instead of
6
+ // counting the whole record table on every five-minute tick.
7
+ // - The health check finds the oldest unreviewed case per monitor through a
8
+ // partial index instead of reading every open case. On large databases run
9
+ // scripts/ben-2/pro-20941-create-unreviewed-case-index.ts first; it builds
10
+ // the index concurrently, and this migration then skips the table-locking
11
+ // create.
12
+ // - The dirty record table is a work queue: every claim and completion leaves
13
+ // a dead entry in its pending index, and each claim walks those entries until
14
+ // the next vacuum. At the default 20 % scale factor US vacuumed it every
15
+ // eight hours; a fixed threshold vacuums it every few minutes, and
16
+ // index cleanup always runs so the pending index loses its dead entries.
17
+ export async function up(db: Kysely<unknown>): Promise<void> {
18
+ await sql`set local lock_timeout = '5s'`.execute(db);
19
+ await sql`set local statement_timeout = '30min'`.execute(db);
20
+ await sql`
21
+ alter table health.accounting_integrity_sweep_cursor
22
+ add column eligible_rows bigint
23
+ `.execute(db);
24
+ await sql`
25
+ alter table health.accounting_integrity_dirty_record set (
26
+ autovacuum_vacuum_scale_factor = 0,
27
+ autovacuum_vacuum_threshold = 5000,
28
+ vacuum_index_cleanup = on
29
+ )
30
+ `.execute(db);
31
+ const existing = await sql<{ valid: boolean }>`
32
+ select (i.indisvalid and i.indisready and i.indislive) as valid
33
+ from pg_index as i
34
+ inner join pg_class as index_class on index_class.oid = i.indexrelid
35
+ where i.indrelid = 'health.accounting_integrity_case'::regclass
36
+ and index_class.relname = 'accounting_integrity_case_unreviewed_oldest_idx'
37
+ `.execute(db);
38
+ if (existing.rows[0]?.valid) return;
39
+ if (existing.rows[0]) {
40
+ await sql`
41
+ drop index health.accounting_integrity_case_unreviewed_oldest_idx
42
+ `.execute(db);
43
+ }
44
+ await sql`
45
+ create index accounting_integrity_case_unreviewed_oldest_idx
46
+ on health.accounting_integrity_case (code, first_seen_at)
47
+ where status = 'open' and review_status = 'unreviewed'
48
+ `.execute(db);
49
+ }
50
+
51
+ export async function down(db: Kysely<unknown>): Promise<void> {
52
+ await sql`set local lock_timeout = '5s'`.execute(db);
53
+ await sql`set local statement_timeout = '60s'`.execute(db);
54
+ await sql`
55
+ drop index if exists health.accounting_integrity_case_unreviewed_oldest_idx
56
+ `.execute(db);
57
+ await sql`
58
+ alter table health.accounting_integrity_dirty_record reset (
59
+ autovacuum_vacuum_scale_factor,
60
+ autovacuum_vacuum_threshold,
61
+ vacuum_index_cleanup
62
+ )
63
+ `.execute(db);
64
+ await sql`
65
+ alter table health.accounting_integrity_sweep_cursor
66
+ drop column eligible_rows
67
+ `.execute(db);
68
+ }
@@ -0,0 +1,23 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ // Sync bookkeeping only: keep the latest successful pull hash beside the source
5
+ // so source ingest does not search historical core.change rows. The column is
6
+ // nullable for existing sources and is intentionally not indexed.
7
+ export async function up(db: Kysely<unknown>): Promise<void> {
8
+ await sql`set local lock_timeout = '5s'`.execute(db);
9
+ await sql`set local statement_timeout = '60s'`.execute(db);
10
+ await sql`
11
+ alter table public.source
12
+ add column last_successful_data_sha256 text
13
+ `.execute(db);
14
+ }
15
+
16
+ export async function down(db: Kysely<unknown>): Promise<void> {
17
+ await sql`set local lock_timeout = '5s'`.execute(db);
18
+ await sql`set local statement_timeout = '60s'`.execute(db);
19
+ await sql`
20
+ alter table public.source
21
+ drop column if exists last_successful_data_sha256
22
+ `.execute(db);
23
+ }
@@ -1,8 +1,8 @@
1
- import { CamelCasePlugin, type SelectQueryNode } from 'kysely';
1
+ import { CamelCasePlugin, type PluginTransformQueryArgs, type PluginTransformResultArgs, SelectQueryNode, type UnknownRow } from 'kysely';
2
2
  export declare class CustomCasePlugin extends CamelCasePlugin {
3
3
  constructor();
4
- transformResult(args: any): Promise<import("kysely").QueryResult<import("kysely").UnknownRow>>;
5
- transformQuery(args: any): import("kysely").RootOperationNode;
4
+ transformResult(args: PluginTransformResultArgs): Promise<import("kysely").QueryResult<UnknownRow>>;
5
+ transformQuery(args: PluginTransformQueryArgs): import("kysely").RootOperationNode;
6
6
  verifyAlias(node: SelectQueryNode): void;
7
- protected mapRow(row: any): any;
7
+ protected mapRow(row: UnknownRow): Record<string, any>;
8
8
  }
@@ -1,4 +1,4 @@
1
- import { CamelCasePlugin, } from 'kysely';
1
+ import { CamelCasePlugin, SelectQueryNode, } from 'kysely';
2
2
  import { KyselyError } from '../error';
3
3
  export class CustomCasePlugin extends CamelCasePlugin {
4
4
  // _excludedColumns: Record<string, boolean> = {};
@@ -11,7 +11,8 @@ export class CustomCasePlugin extends CamelCasePlugin {
11
11
  return super.transformResult(args);
12
12
  }
13
13
  transformQuery(args) {
14
- this.verifyAlias(args.node);
14
+ if (SelectQueryNode.is(args.node))
15
+ this.verifyAlias(args.node);
15
16
  return super.transformQuery(args);
16
17
  }
17
18
  verifyAlias(node) {
@@ -34,7 +35,7 @@ export class CustomCasePlugin extends CamelCasePlugin {
34
35
  }
35
36
  if (!alias.name.includes('_'))
36
37
  continue;
37
- throw new KyselyError(`Alias ${alias.name} contains underscore`);
38
+ throw new KyselyError('Alias contains underscore', { name: alias.name });
38
39
  }
39
40
  }
40
41
  mapRow(row) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["camel-case/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,GAIhB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IACnD,kDAAkD;IAClD;QACE,KAAK,CAAC;YACJ,wBAAwB,EAAE,IAAI;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,IAAI;QAClB,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,cAAc,CAAC,IAAI;QACjB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,OAAO,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,WAAW,CAAC,IAAqB;QAC/B,IAAI,CAAC,IAAI,EAAE,UAAU;YAAE,OAAO;QAE9B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;YACtC,MAAM,SAAS,GAAG,CAAC,CAAC,SAAsB,CAAC;YAC3C,IAAI,CAAC,SAAS,CAAC,KAAK;gBAAE,SAAS;YAC/B,MAAM,KAAK,GAAG,SAAS,CAAC,KAAuB,CAAC;YAEhD,0CAA0C;YAC1C,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBACtC,MAAM,OAAO,GAAG,SAAS,CAAC,IAAe,CAAC;gBAC1C,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;oBACzC,IAAI,CAAC,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;wBACjC,MAAM,eAAe,GAAG,CAAoB,CAAC;wBAC7C,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;oBACpC,CAAC;gBACH,CAAC;YACH,CAAC;YAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,SAAS;YAExC,MAAM,IAAI,WAAW,CAAC,SAAS,KAAK,CAAC,IAAI,sBAAsB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAES,MAAM,CAAC,GAAG;QAClB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG;YAAE,OAAO,GAAG,CAAC;QAEhD,MAAM,MAAM,GAAwB,EAAE,CAAC;QACvC,8GAA8G;QAC9G,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACrB,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACpC,iEAAiE;YACjE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7C,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACzB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import {\n type AliasNode,\n CamelCasePlugin,\n type IdentifierNode,\n type RawNode,\n type SelectQueryNode,\n} from 'kysely';\nimport { KyselyError } from '../error';\n\nexport class CustomCasePlugin extends CamelCasePlugin {\n // _excludedColumns: Record<string, boolean> = {};\n constructor() {\n super({\n maintainNestedObjectKeys: true,\n });\n }\n\n transformResult(args) {\n return super.transformResult(args);\n }\n\n transformQuery(args) {\n this.verifyAlias(args.node);\n return super.transformQuery(args);\n }\n\n verifyAlias(node: SelectQueryNode) {\n if (!node?.selections) return;\n\n for (const x of node.selections ?? []) {\n const selection = x.selection as AliasNode;\n if (!selection.alias) continue;\n const alias = selection.alias as IdentifierNode;\n\n // alias can be a raw node (jsonArrayFrom)\n if (selection.node.kind === 'RawNode') {\n const rawNode = selection.node as RawNode;\n for (const x of rawNode.parameters ?? []) {\n if (x.kind === 'SelectQueryNode') {\n const selectQueryNode = x as SelectQueryNode;\n this.verifyAlias(selectQueryNode);\n }\n }\n }\n\n if (!alias.name.includes('_')) continue;\n\n throw new KyselyError(`Alias ${alias.name} contains underscore`);\n }\n }\n\n protected mapRow(row) {\n if (typeof row !== 'object' || !row) return row;\n\n const newRow: Record<string, any> = {};\n // we camel case on first layer, and nested ONLY if in an array (jsonArrayFrom), NOT if it's an object (jsonb)\n for (const key of Object.keys(row)) {\n let value = row[key];\n const newKey = super.camelCase(key);\n // array CAN be non object, so we need to check the first element\n if (Array.isArray(value)) {\n value = value.map((it) => this.mapRow(it));\n }\n newRow[newKey] = value;\n }\n return newRow;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["camel-case/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAKf,eAAe,GAEhB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IACnD,kDAAkD;IAClD;QACE,KAAK,CAAC;YACJ,wBAAwB,EAAE,IAAI;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,IAA+B;QAC7C,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,cAAc,CAAC,IAA8B;QAC3C,IAAI,eAAe,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,OAAO,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,WAAW,CAAC,IAAqB;QAC/B,IAAI,CAAC,IAAI,EAAE,UAAU;YAAE,OAAO;QAE9B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;YACtC,MAAM,SAAS,GAAG,CAAC,CAAC,SAAsB,CAAC;YAC3C,IAAI,CAAC,SAAS,CAAC,KAAK;gBAAE,SAAS;YAC/B,MAAM,KAAK,GAAG,SAAS,CAAC,KAAuB,CAAC;YAEhD,0CAA0C;YAC1C,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBACtC,MAAM,OAAO,GAAG,SAAS,CAAC,IAAe,CAAC;gBAC1C,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;oBACzC,IAAI,CAAC,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;wBACjC,MAAM,eAAe,GAAG,CAAoB,CAAC;wBAC7C,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;oBACpC,CAAC;gBACH,CAAC;YACH,CAAC;YAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,SAAS;YAExC,MAAM,IAAI,WAAW,CAAC,2BAA2B,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAES,MAAM,CAAC,GAAe;QAC9B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG;YAAE,OAAO,GAAG,CAAC;QAEhD,MAAM,MAAM,GAAwB,EAAE,CAAC;QACvC,8GAA8G;QAC9G,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACrB,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACpC,iEAAiE;YACjE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7C,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACzB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import {\n type AliasNode,\n CamelCasePlugin,\n type IdentifierNode,\n type PluginTransformQueryArgs,\n type PluginTransformResultArgs,\n type RawNode,\n SelectQueryNode,\n type UnknownRow,\n} from 'kysely';\nimport { KyselyError } from '../error';\n\nexport class CustomCasePlugin extends CamelCasePlugin {\n // _excludedColumns: Record<string, boolean> = {};\n constructor() {\n super({\n maintainNestedObjectKeys: true,\n });\n }\n\n transformResult(args: PluginTransformResultArgs) {\n return super.transformResult(args);\n }\n\n transformQuery(args: PluginTransformQueryArgs) {\n if (SelectQueryNode.is(args.node)) this.verifyAlias(args.node);\n return super.transformQuery(args);\n }\n\n verifyAlias(node: SelectQueryNode) {\n if (!node?.selections) return;\n\n for (const x of node.selections ?? []) {\n const selection = x.selection as AliasNode;\n if (!selection.alias) continue;\n const alias = selection.alias as IdentifierNode;\n\n // alias can be a raw node (jsonArrayFrom)\n if (selection.node.kind === 'RawNode') {\n const rawNode = selection.node as RawNode;\n for (const x of rawNode.parameters ?? []) {\n if (x.kind === 'SelectQueryNode') {\n const selectQueryNode = x as SelectQueryNode;\n this.verifyAlias(selectQueryNode);\n }\n }\n }\n\n if (!alias.name.includes('_')) continue;\n\n throw new KyselyError('Alias contains underscore', { name: alias.name });\n }\n }\n\n protected mapRow(row: UnknownRow) {\n if (typeof row !== 'object' || !row) return row;\n\n const newRow: Record<string, any> = {};\n // we camel case on first layer, and nested ONLY if in an array (jsonArrayFrom), NOT if it's an object (jsonb)\n for (const key of Object.keys(row)) {\n let value = row[key];\n const newKey = super.camelCase(key);\n // array CAN be non object, so we need to check the first element\n if (Array.isArray(value)) {\n value = value.map((it) => this.mapRow(it));\n }\n newRow[newKey] = value;\n }\n return newRow;\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import type { Kysely } from './index';
2
+ import type { JsonObject } from './v1.generated';
3
+ /**
4
+ * Passes secrets between the API and Trigger.dev tasks through the tenant's
5
+ * database, so connect credentials never enter Trigger.dev payloads or outputs.
6
+ * Rows expire after one hour, the lifetime of a reused connect run. Reads do not
7
+ * consume the row: a retried or reused run must still find it.
8
+ */
9
+ export declare function useConnectHandoff(kysely: Kysely, tenantId: string): {
10
+ put(appId: string, value: JsonObject): Promise<string>;
11
+ get(ref: string, appId: string): Promise<JsonObject | undefined>;
12
+ };