@vrplatform/kysely 1.3.45-stage.4407 → 1.3.45-stage.44072739210

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 (346) 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 +1405 -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/module/camel-case/index.d.ts +4 -4
  227. package/build/module/camel-case/index.js +4 -3
  228. package/build/module/camel-case/index.js.map +1 -1
  229. package/build/module/connect-handoff.d.ts +12 -0
  230. package/build/module/connect-handoff.js +70 -0
  231. package/build/module/connect-handoff.js.map +1 -0
  232. package/build/module/control-plane/index.d.ts +421 -14
  233. package/build/module/control-plane/index.js +58 -1
  234. package/build/module/control-plane/index.js.map +1 -1
  235. package/build/module/domain.d.ts +4 -0
  236. package/build/module/domain.js +2 -0
  237. package/build/module/domain.js.map +1 -0
  238. package/build/module/error.d.ts +2 -1
  239. package/build/module/error.js +3 -1
  240. package/build/module/error.js.map +1 -1
  241. package/build/module/index.d.ts +57 -15
  242. package/build/module/index.js +496 -64
  243. package/build/module/index.js.map +1 -1
  244. package/build/module/isomorphic.d.ts +6 -6
  245. package/build/module/isomorphic.js +2 -7
  246. package/build/module/isomorphic.js.map +1 -1
  247. package/build/module/local/digest.d.ts +3 -3
  248. package/build/module/local/digest.js.map +1 -1
  249. package/build/module/local/generate.js +15 -13
  250. package/build/module/local/generate.js.map +1 -1
  251. package/build/module/local/index.d.ts +5 -1
  252. package/build/module/local/index.js +347 -13
  253. package/build/module/local/index.js.map +1 -1
  254. package/build/module/local/prune-pulled-schema.js +4 -1
  255. package/build/module/local/prune-pulled-schema.js.map +1 -1
  256. package/build/module/migration-source.d.ts +4 -0
  257. package/build/module/migration-source.js +42 -0
  258. package/build/module/migration-source.js.map +1 -0
  259. package/build/module/migration.d.ts +7 -0
  260. package/build/module/migration.js +8 -0
  261. package/build/module/migration.js.map +1 -0
  262. package/build/module/pganalyze-comment-plugin/comment-transformer.js +3 -1
  263. package/build/module/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  264. package/build/module/plugins.d.ts +2 -2
  265. package/build/module/plugins.js.map +1 -1
  266. package/build/module/postgres-error.d.ts +9 -0
  267. package/build/module/postgres-error.js +24 -0
  268. package/build/module/postgres-error.js.map +1 -0
  269. package/build/module/query/index.d.ts +1 -0
  270. package/build/module/query/index.js +1 -0
  271. package/build/module/query/index.js.map +1 -1
  272. package/build/module/query/listing/status.d.ts +2 -12
  273. package/build/module/query/listing/status.js +35 -18
  274. package/build/module/query/listing/status.js.map +1 -1
  275. package/build/module/query/tenant/billing-partner.d.ts +4 -0
  276. package/build/module/query/tenant/billing-partner.js +5 -0
  277. package/build/module/query/tenant/billing-partner.js.map +1 -0
  278. package/build/module/query/tenant/feature-enabled.d.ts +6 -0
  279. package/build/module/query/tenant/feature-enabled.js +27 -0
  280. package/build/module/query/tenant/feature-enabled.js.map +1 -0
  281. package/build/module/query/tenant/index.d.ts +4 -0
  282. package/build/module/query/tenant/index.js +5 -0
  283. package/build/module/query/tenant/index.js.map +1 -0
  284. package/build/module/query/tenant/status.d.ts +9 -0
  285. package/build/module/query/tenant/status.js +28 -0
  286. package/build/module/query/tenant/status.js.map +1 -0
  287. package/build/module/query/tenant/where-uuid-in.d.ts +2 -0
  288. package/build/module/query/tenant/where-uuid-in.js +11 -0
  289. package/build/module/query/tenant/where-uuid-in.js.map +1 -0
  290. package/build/module/regional.d.ts +31 -4
  291. package/build/module/regional.js +68 -8
  292. package/build/module/regional.js.map +1 -1
  293. package/build/module/test/index.d.ts +21 -11
  294. package/build/module/test/index.js +31 -26
  295. package/build/module/test/index.js.map +1 -1
  296. package/build/module/transaction.d.ts +3 -3
  297. package/build/module/transaction.js.map +1 -1
  298. package/build/module/v1.generated.d.ts +1405 -177
  299. package/build/module/v1.generated.js.map +1 -1
  300. package/package.json +19 -16
  301. package/build/migrations/0000000000001-init.ts +0 -5
  302. package/build/migrations/0000000000009-drop-store-schema.ts +0 -14
  303. package/build/migrations/0000000000010-bank-rules.ts +0 -190
  304. package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +0 -65
  305. package/build/migrations/0000000000012-bank-rule-conditions.ts +0 -45
  306. package/build/migrations/0000000000013-bank-rule-name-unique.ts +0 -15
  307. package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +0 -41
  308. package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +0 -70
  309. package/build/migrations/0000000000016-owner-statement-draft-status.ts +0 -22
  310. package/build/migrations/0000000000017-tenant-migration-markers.ts +0 -18
  311. package/build/migrations/0000000000018-security-deposits-payable-category.ts +0 -63
  312. package/build/migrations/0000000000019-tenant-app-settings.ts +0 -76
  313. package/build/migrations/0000000000020-operating-opening-trial-balance.ts +0 -36
  314. package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +0 -77
  315. package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +0 -30
  316. package/build/migrations/0000000000024-listing-parent.ts +0 -37
  317. package/build/migrations/0000000000025-journal-entry-parent-listing.ts +0 -26
  318. package/build/migrations/0000000000026-booking-channel-logo-slots.ts +0 -89
  319. package/build/migrations/0000000000027-list-browse-performance-indexes.ts +0 -52
  320. package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +0 -20
  321. package/build/migrations/0000000000029-tenant-slug.ts +0 -328
  322. package/build/migrations/0000000000030-pms-accounting-windows.ts +0 -50
  323. package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +0 -20
  324. package/build/migrations/0000000000032-flow-event-listening.ts +0 -28
  325. package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +0 -272
  326. package/build/migrations/0000000000034-historic-general-ledger.ts +0 -24
  327. package/build/migrations/0000000000035-tenant-regional-placement.ts +0 -37
  328. package/build/migrations/0000000000036-control-plane-projection-events.ts +0 -43
  329. package/build/migrations/0000000000037-tenant-guide-onboarding.ts +0 -21
  330. package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +0 -31
  331. package/build/migrations/0000000000039-crunchy-region.ts +0 -86
  332. package/build/migrations/0000000000040-hostaway-region.ts +0 -72
  333. package/build/migrations/0000000000041-audit-tenant-fk.ts +0 -66
  334. package/build/migrations/0000000000042-ramp-staging-connect-params.ts +0 -35
  335. package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +0 -125
  336. package/build/migrations/0000000000044-tenant-cross-region-fks.ts +0 -45
  337. package/build/migrations/0000000000045-cloudflare-region-env.ts +0 -100
  338. package/build/migrations/0000000000046-control-plane-outbox-alias.ts +0 -46
  339. package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +0 -16
  340. package/build/migrations/0000000000047-tenant-status-backfill.ts +0 -40
  341. package/build/migrations/0000000000048-tenant-status-constraint.ts +0 -24
  342. package/build/migrations/0000000000049-health-tenant-issues.ts +0 -69
  343. package/build/migrations/0000000000050-partner-webhooks.ts +0 -135
  344. package/build/migrations/0000000000051-health-webhook-runtime-grants.ts +0 -42
  345. package/build/migrations/0000000000052-feature-approval-team-enablement.ts +0 -30
  346. package/build/migrations/0000000000053-health-webhook-enums.ts +0 -296
package/build/.data.tar CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/build/.data.tar
3
- size: 45640192 bytes
4
- sha256: e3f90bacc4216779512b7a1d2392e4dea309e40a4d827ba2f441eff68a62841f
3
+ size: 53013504 bytes
4
+ sha256: 05225dbcc383368fb13f184cae63976919b6d626c57aa39195d54a97a5945471
@@ -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
  }
@@ -14,7 +14,8 @@ class CustomCasePlugin extends kysely_1.CamelCasePlugin {
14
14
  return super.transformResult(args);
15
15
  }
16
16
  transformQuery(args) {
17
- this.verifyAlias(args.node);
17
+ if (kysely_1.SelectQueryNode.is(args.node))
18
+ this.verifyAlias(args.node);
18
19
  return super.transformQuery(args);
19
20
  }
20
21
  verifyAlias(node) {
@@ -37,7 +38,7 @@ class CustomCasePlugin extends kysely_1.CamelCasePlugin {
37
38
  }
38
39
  if (!alias.name.includes('_'))
39
40
  continue;
40
- throw new error_1.KyselyError(`Alias ${alias.name} contains underscore`);
41
+ throw new error_1.KyselyError('Alias contains underscore', { name: alias.name });
41
42
  }
42
43
  }
43
44
  mapRow(row) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["camel-case/index.ts"],"names":[],"mappings":";;;AAAA,mCAMgB;AAChB,oCAAuC;AAEvC,MAAa,gBAAiB,SAAQ,wBAAe;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,mBAAW,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;AA1DD,4CA0DC","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,mCASgB;AAChB,oCAAuC;AAEvC,sBAA8B,SAAQ,wBAAe;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,wBAAe,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,mBAAW,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
+ };
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useConnectHandoff = useConnectHandoff;
4
+ const kysely_1 = require("kysely");
5
+ // Rows never belong to a user, so no authenticated user can claim one through
6
+ // the OAuth state flow that shares the table.
7
+ const handoffUserId = '00000000-0000-0000-0000-000000000000';
8
+ const handoffRefPattern = /^handoff_[A-Za-z0-9_-]{22}$/;
9
+ async function hashRef(ref) {
10
+ const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(ref));
11
+ return [...new Uint8Array(digest)]
12
+ .map((byte) => byte.toString(16).padStart(2, '0'))
13
+ .join('');
14
+ }
15
+ /**
16
+ * Passes secrets between the API and Trigger.dev tasks through the tenant's
17
+ * database, so connect credentials never enter Trigger.dev payloads or outputs.
18
+ * Rows expire after one hour, the lifetime of a reused connect run. Reads do not
19
+ * consume the row: a retried or reused run must still find it.
20
+ */
21
+ function useConnectHandoff(kysely, tenantId) {
22
+ return {
23
+ async put(appId, value) {
24
+ const bytes = crypto.getRandomValues(new Uint8Array(16));
25
+ const ref = `handoff_${btoa(String.fromCharCode(...bytes))
26
+ .replaceAll('+', '-')
27
+ .replaceAll('/', '_')
28
+ .replaceAll('=', '')}`;
29
+ await kysely
30
+ .deleteFrom('public.connectionOauthState')
31
+ .where('stateHash', 'in', kysely
32
+ .selectFrom('public.connectionOauthState')
33
+ .select('stateHash')
34
+ .where('expiresAt', '<=', (0, kysely_1.sql) `clock_timestamp()`)
35
+ .orderBy('expiresAt')
36
+ .limit(100)
37
+ .forUpdate()
38
+ .skipLocked())
39
+ .execute();
40
+ // Transient authentication coordination is excluded from business audit:
41
+ // references, setup parameters and credentials must never be audited.
42
+ await kysely
43
+ .insertInto('public.connectionOauthState')
44
+ .values({
45
+ stateHash: await hashRef(ref),
46
+ tenantId,
47
+ userId: handoffUserId,
48
+ appId,
49
+ connectionId: null,
50
+ params: value,
51
+ redirectUri: '',
52
+ expiresAt: (0, kysely_1.sql) `clock_timestamp() + interval '1 hour'`,
53
+ })
54
+ .execute();
55
+ return ref;
56
+ },
57
+ async get(ref, appId) {
58
+ if (!handoffRefPattern.test(ref))
59
+ return undefined;
60
+ const row = await kysely
61
+ .selectFrom('public.connectionOauthState')
62
+ .select('params')
63
+ .where('stateHash', '=', await hashRef(ref))
64
+ .where('tenantId', '=', tenantId)
65
+ .where('appId', '=', appId)
66
+ .where('userId', '=', handoffUserId)
67
+ .where('expiresAt', '>', (0, kysely_1.sql) `clock_timestamp()`)
68
+ .executeTakeFirst();
69
+ return row?.params;
70
+ },
71
+ };
72
+ }
73
+ //# sourceMappingURL=connect-handoff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-handoff.js","sourceRoot":"src/","sources":["connect-handoff.ts"],"names":[],"mappings":"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","sourcesContent":["import { sql } from 'kysely';\nimport type { Kysely } from './index';\nimport type { JsonObject } from './v1.generated';\n\n// Rows never belong to a user, so no authenticated user can claim one through\n// the OAuth state flow that shares the table.\nconst handoffUserId = '00000000-0000-0000-0000-000000000000';\nconst handoffRefPattern = /^handoff_[A-Za-z0-9_-]{22}$/;\n\nasync function hashRef(ref: string) {\n const digest = await crypto.subtle.digest(\n 'SHA-256',\n new TextEncoder().encode(ref)\n );\n return [...new Uint8Array(digest)]\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Passes secrets between the API and Trigger.dev tasks through the tenant's\n * database, so connect credentials never enter Trigger.dev payloads or outputs.\n * Rows expire after one hour, the lifetime of a reused connect run. Reads do not\n * consume the row: a retried or reused run must still find it.\n */\nexport function useConnectHandoff(kysely: Kysely, tenantId: string) {\n return {\n async put(appId: string, value: JsonObject) {\n const bytes = crypto.getRandomValues(new Uint8Array(16));\n const ref = `handoff_${btoa(String.fromCharCode(...bytes))\n .replaceAll('+', '-')\n .replaceAll('/', '_')\n .replaceAll('=', '')}`;\n await kysely\n .deleteFrom('public.connectionOauthState')\n .where(\n 'stateHash',\n 'in',\n kysely\n .selectFrom('public.connectionOauthState')\n .select('stateHash')\n .where('expiresAt', '<=', sql<string>`clock_timestamp()`)\n .orderBy('expiresAt')\n .limit(100)\n .forUpdate()\n .skipLocked()\n )\n .execute();\n // Transient authentication coordination is excluded from business audit:\n // references, setup parameters and credentials must never be audited.\n await kysely\n .insertInto('public.connectionOauthState')\n .values({\n stateHash: await hashRef(ref),\n tenantId,\n userId: handoffUserId,\n appId,\n connectionId: null,\n params: value,\n redirectUri: '',\n expiresAt: sql`clock_timestamp() + interval '1 hour'`,\n })\n .execute();\n return ref;\n },\n async get(ref: string, appId: string) {\n if (!handoffRefPattern.test(ref)) return undefined;\n const row = await kysely\n .selectFrom('public.connectionOauthState')\n .select('params')\n .where('stateHash', '=', await hashRef(ref))\n .where('tenantId', '=', tenantId)\n .where('appId', '=', appId)\n .where('userId', '=', handoffUserId)\n .where('expiresAt', '>', sql<string>`clock_timestamp()`)\n .executeTakeFirst();\n return row?.params;\n },\n };\n}\n"]}