@vrplatform/kysely 1.3.45-stage.4366 → 1.3.45-stage.43703848639
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.
- package/build/.data.tar +2 -2
- package/build/main/camel-case/index.d.ts +4 -4
- package/build/main/camel-case/index.js +3 -2
- package/build/main/camel-case/index.js.map +1 -1
- package/build/main/connect-handoff.d.ts +12 -0
- package/build/main/connect-handoff.js +73 -0
- package/build/main/connect-handoff.js.map +1 -0
- package/build/main/control-plane/index.d.ts +413 -14
- package/build/main/control-plane/index.js +71 -0
- package/build/main/control-plane/index.js.map +1 -1
- package/build/main/domain.d.ts +4 -0
- package/build/main/domain.js +3 -0
- package/build/main/domain.js.map +1 -0
- package/build/main/error.d.ts +2 -1
- package/build/main/error.js +2 -1
- package/build/main/error.js.map +1 -1
- package/build/main/index.d.ts +57 -15
- package/build/main/index.js +498 -66
- package/build/main/index.js.map +1 -1
- package/build/main/isomorphic.d.ts +6 -6
- package/build/main/isomorphic.js +4 -8
- package/build/main/isomorphic.js.map +1 -1
- package/build/main/local/digest.d.ts +3 -3
- package/build/main/local/digest.js.map +1 -1
- package/build/main/local/generate.js +15 -13
- package/build/main/local/generate.js.map +1 -1
- package/build/main/local/index.d.ts +5 -1
- package/build/main/local/index.js +346 -12
- package/build/main/local/index.js.map +1 -1
- package/build/main/local/prune-pulled-schema.js +4 -1
- package/build/main/local/prune-pulled-schema.js.map +1 -1
- package/build/main/migration-source.d.ts +4 -0
- package/build/main/migration-source.js +45 -0
- package/build/main/migration-source.js.map +1 -0
- package/build/main/migration.d.ts +7 -0
- package/build/main/migration.js +11 -0
- package/build/main/migration.js.map +1 -0
- package/build/main/pganalyze-comment-plugin/comment-transformer.js +3 -1
- package/build/main/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
- package/build/main/pganalyze-comment-plugin/index.js.map +1 -1
- package/build/main/plugins.d.ts +2 -2
- package/build/main/plugins.js.map +1 -1
- package/build/main/postgres-error.d.ts +9 -0
- package/build/main/postgres-error.js +28 -0
- package/build/main/postgres-error.js.map +1 -0
- package/build/main/query/index.d.ts +1 -0
- package/build/main/query/index.js +1 -0
- package/build/main/query/index.js.map +1 -1
- package/build/main/query/listing/status.d.ts +2 -12
- package/build/main/query/listing/status.js +35 -20
- package/build/main/query/listing/status.js.map +1 -1
- package/build/main/query/tenant/billing-partner.d.ts +4 -0
- package/build/main/query/tenant/billing-partner.js +8 -0
- package/build/main/query/tenant/billing-partner.js.map +1 -0
- package/build/main/query/tenant/feature-enabled.d.ts +6 -0
- package/build/main/query/tenant/feature-enabled.js +30 -0
- package/build/main/query/tenant/feature-enabled.js.map +1 -0
- package/build/main/query/tenant/index.d.ts +4 -0
- package/build/main/query/tenant/index.js +21 -0
- package/build/main/query/tenant/index.js.map +1 -0
- package/build/main/query/tenant/status.d.ts +9 -0
- package/build/main/query/tenant/status.js +32 -0
- package/build/main/query/tenant/status.js.map +1 -0
- package/build/main/query/tenant/where-uuid-in.d.ts +2 -0
- package/build/main/query/tenant/where-uuid-in.js +14 -0
- package/build/main/query/tenant/where-uuid-in.js.map +1 -0
- package/build/main/regional.d.ts +31 -4
- package/build/main/regional.js +69 -8
- package/build/main/regional.js.map +1 -1
- package/build/main/test/index.d.ts +21 -11
- package/build/main/test/index.js +31 -26
- package/build/main/test/index.js.map +1 -1
- package/build/main/transaction.d.ts +3 -3
- package/build/main/transaction.js.map +1 -1
- package/build/main/v1.generated.d.ts +1333 -90
- package/build/main/v1.generated.js.map +1 -1
- package/build/migrations-v2/0000000000000-baseline.ts +5 -0
- package/build/migrations-v2/0000000000001-public-audit-events-v2.ts +137 -0
- package/build/migrations-v2/0000000000002-audit-recovery-watermarks.ts +30 -0
- package/build/migrations-v2/0000000000003-audit-effect-recovery-watermark.ts +13 -0
- package/build/migrations-v2/0000000000004-audit-event-projected-at.ts +15 -0
- package/build/migrations-v2/0000000000005-audit-recovery-indexes.ts +63 -0
- package/build/migrations-v2/0000000000006-audit-action-public-event-projected-at.ts +22 -0
- package/build/migrations-v2/0000000000007-audit-action-public-event-projected-at-backfill.ts +35 -0
- package/build/migrations-v2/0000000000008-global-user-attribution.ts +33 -0
- package/build/migrations-v2/0000000000008-team-issue-rule-state.ts +52 -0
- package/build/migrations-v2/0000000000009-reservation-issue-projections.ts +45 -0
- package/build/migrations-v2/0000000000010-bank-rule-application-bank-record-delete-cascade.ts +26 -0
- package/build/migrations-v2/0000000000011-guest-balance-journal-entry-lookup-index.ts +25 -0
- package/build/migrations-v2/0000000000012-trial-free-analytics-billing-status.ts +72 -0
- package/build/migrations-v2/0000000000013-ui-permission-bundles.ts +45 -0
- package/build/migrations-v2/0000000000014-ui-permission-bundle-top-up.ts +32 -0
- package/build/migrations-v2/0000000000015-durable-flow-events.ts +163 -0
- package/build/migrations-v2/0000000000016-billing-listing-facts.ts +539 -0
- package/build/migrations-v2/0000000000016-managed-team-access.ts +34 -0
- package/build/migrations-v2/0000000000017-drop-trial-until.ts +42 -0
- package/build/migrations-v2/0000000000017-webhook-secret-reencryption-failures.ts +18 -0
- package/build/migrations-v2/0000000000018-accounting-integrity-monitoring.ts +276 -0
- package/build/migrations-v2/0000000000018-durable-flow-event-sensitive-input.ts +28 -0
- package/build/migrations-v2/0000000000019-accounting-integrity-run-shards.ts +26 -0
- package/build/migrations-v2/0000000000019-asynchronous-operations.ts +736 -0
- package/build/migrations-v2/0000000000020-accounting-integrity-case-classification.ts +52 -0
- package/build/migrations-v2/0000000000021-payment-line-classification-monitor-indexes.ts +31 -0
- package/build/migrations-v2/0000000000022-accounting-integrity-controlled-repairs.ts +281 -0
- package/build/migrations-v2/0000000000023-line-classification-usage.ts +325 -0
- package/build/migrations-v2/0000000000024-tenant-region-migration.ts +108 -0
- package/build/migrations-v2/0000000000025-partner-ach-denial-default.ts +30 -0
- package/build/migrations-v2/0000000000026-line-classification-usage-capture.ts +399 -0
- package/build/migrations-v2/0000000000027-payout-replacement-chain.ts +27 -0
- package/build/migrations-v2/0000000000028-accounting-integrity-operator-workflow.ts +108 -0
- package/build/migrations-v2/0000000000029-accounting-integrity-definition-artifacts.ts +40 -0
- package/build/migrations-v2/0000000000030-accounting-integrity-review-metadata-compatibility.ts +49 -0
- package/build/migrations-v2/0000000000031-ui-permission-role-simplification.ts +70 -0
- package/build/migrations-v2/0000000000032-tenant-delete-ownership-cascades.ts +44 -0
- package/build/migrations-v2/0000000000033-plaid-connect-session-telemetry.ts +31 -0
- package/build/migrations-v2/0000000000033-reservation-issue-seed-bucket-index.ts +19 -0
- package/build/migrations-v2/0000000000034-retire-recent-classification-indexes.ts +29 -0
- package/build/migrations-v2/0000000000035-core-change-autovacuum.ts +24 -0
- package/build/migrations-v2/0000000000036-journal-entry-inactive-reason-constraint.ts +33 -0
- package/build/migrations-v2/0000000000037-journal-entry-inactive-reasons.ts +19 -0
- package/build/{migrations/0000000000023-journal-entry-currency-mismatch-reason.ts → migrations-v2/0000000000038-journal-entry-group-inactive-reason.ts} +4 -4
- package/build/migrations-v2/0000000000039-reservation-guest-breakdown.ts +19 -0
- package/build/migrations-v2/0000000000040-csv-import-source-identity-index.ts +23 -0
- package/build/migrations-v2/0000000000041-payment-returns.ts +38 -0
- package/build/migrations-v2/0000000000042-operation-resource-types.ts +609 -0
- package/build/migrations-v2/0000000000043-reservation-journal-freshness.ts +149 -0
- package/build/migrations-v2/0000000000044-reservation-journal-freshness-backfill.ts +254 -0
- package/build/migrations-v2/0000000000045-reservation-journal-freshness-revision-repair.ts +83 -0
- package/build/migrations-v2/0000000000046-materialized-reservation-journal-operations.ts +709 -0
- package/build/migrations-v2/0000000000047-public-audit-completion.ts +77 -0
- package/build/migrations-v2/0000000000048-reservation-journal-full-refresh-repair.ts +136 -0
- package/build/migrations-v2/0000000000049-queued-journal-operation-failures.ts +60 -0
- package/build/migrations-v2/0000000000050-connection-oauth-state.ts +43 -0
- package/build/migrations-v2/0000000000051-owner-statement-email-delivery.ts +134 -0
- package/build/migrations-v2/0000000000052-fee-journal-lock-skip-operations.ts +59 -0
- package/build/migrations-v2/0000000000053-fee-journal-lock-skip-null-attempt.ts +44 -0
- package/build/migrations-v2/0000000000054-journal-refresh-issue-codes.ts +16 -0
- package/build/migrations-v2/0000000000055-tenant-billing-subscription.ts +8 -0
- package/build/migrations-v2/0000000000056-journal-operation-failure-precedence.ts +306 -0
- package/build/migrations-v2/0000000000057-journal-invalidation-failure-code.ts +28 -0
- package/build/migrations-v2/0000000000058-journal-invalidation-locked-failure.ts +16 -0
- package/build/migrations-v2/0000000000059-billing-active-listing-cross-region-partner.ts +135 -0
- package/build/migrations-v2/0000000000060-accounting-integrity-change-driven.ts +99 -0
- package/build/migrations-v2/0000000000061-tenant-pending-onboarding-status.ts +37 -0
- package/build/migrations-v2/0000000000062-statement-payout-operations.ts +16 -0
- package/build/migrations-v2/0000000000063-missing-account-assignments-issue-code.ts +13 -0
- package/build/migrations-v2/0000000000064-journal-invalidation-source-lookup-index.ts +26 -0
- package/build/migrations-v2/0000000000065-hasura-connection-event-credentials.ts +42 -0
- package/build/migrations-v2/0000000000066-recurring-fee-listing-subscription-match-by.ts +51 -0
- package/build/migrations-v2/0000000000067-connection-credential-metadata.ts +60 -0
- package/build/migrations-v2/0000000000068-connection-credential-version.ts +34 -0
- package/build/migrations-v2/0000000000069-owner-statement-contact-email-delivery.ts +84 -0
- package/build/migrations-v2/0000000000070-payment-writer-compatibility.ts +69 -0
- package/build/migrations-v2/0000000000071-payments.ts +532 -0
- package/build/migrations-v2/0000000000072-journal-entry-payment-index.ts +21 -0
- package/build/migrations-v2/0000000000073-batch-invalidation-operation-registration.ts +74 -0
- package/build/migrations-v2/0000000000074-owner-statement-email-history.ts +34 -0
- package/build/migrations-v2/0000000000075-tenant-deletion-lookup-indexes.ts +46 -0
- package/build/migrations-v2/0000000000076-tenant-onboarding-not-null.ts +23 -0
- package/build/migrations-v2/0000000000077-payment-writer-statement-attachment.ts +92 -0
- package/build/migrations-v2/0000000000078-trigger-timeout-indexes.ts +44 -0
- package/build/migrations-v2/0000000000079-core-change-tenant-statistics.ts +26 -0
- package/build/migrations-v2/0000000000080-drop-legacy-tracking-event.ts +60 -0
- package/build/migrations-v2/0000000000081-recurring-fee-planner-operation-status.ts +35 -0
- package/build/migrations-v2/0000000000082-reservation-search-trigram-indexes.ts +54 -0
- package/build/migrations-v2/0000000000083-journal-entry-deposit-lookup-index.ts +31 -0
- package/build/migrations-v2/0000000000084-journal-entry-reservation-revenue-indexes.ts +57 -0
- package/build/migrations-v2/0000000000085-owner-statement-link-email-template.ts +23 -0
- package/build/migrations-v2/0000000000086-contact-payment-setup.ts +72 -0
- package/build/migrations-v2/0000000000087-address-delete-fk-indexes.ts +30 -0
- package/build/migrations-v2/0000000000088-owner-statement-email-switch.ts +76 -0
- package/build/migrations-v2/0000000000089-contact-bank-details-requested-at.ts +21 -0
- package/build/migrations-v2/0000000000090-contact-bank-account-api-key.ts +22 -0
- package/build/migrations-v2/0000000000091-contact-bank-details-request.ts +78 -0
- package/build/migrations-v2/0000000000092-payment-provider-reference.ts +22 -0
- package/build/migrations-v2/0000000000093-payment-reversal-offline-undo.ts +18 -0
- package/build/migrations-v2/0000000000094-reservation-status-checkout-index.ts +37 -0
- package/build/migrations-v2/0000000000095-payment-batches.ts +196 -0
- package/build/migrations-v2/0000000000096-guide-ongoing-tasks-issue-codes.ts +26 -0
- package/build/migrations-v2/0000000000097-reservation-line-mapping-suggestions.ts +53 -0
- package/build/migrations-v2/0000000000098-cancelled-reservation-balances-issue-code.ts +13 -0
- package/build/migrations-v2/0000000000099-contact-bank-account-request-source.ts +28 -0
- package/build/migrations-v2/0000000000100-drop-regional-feature-flags.ts +105 -0
- package/build/migrations-v2/0000000000101-bank-record-match-source.ts +45 -0
- package/build/migrations-v2/0000000000102-owner-statement-email-one-template.ts +63 -0
- package/build/migrations-v2/0000000000103-reservation-line-mapping-update-operation.ts +10 -0
- package/build/migrations-v2/0000000000104-export-job-payment-batch-pdf.ts +12 -0
- package/build/migrations-v2/0000000000105-drop-regional-token.ts +60 -0
- package/build/migrations-v2/0000000000106-incremental-audit-action-source.ts +158 -0
- package/build/migrations-v2/0000000000107-audit-mutation-transaction-insert-index.ts +44 -0
- package/build/migrations-v2/0000000000108-reservation-stay-type.ts +24 -0
- package/build/migrations-v2/0000000000109-long-term-liabilities-category-order.ts +21 -0
- package/build/migrations-v2/0000000000110-pms-sync-failures-issue-code.ts +13 -0
- package/build/migrations-v2/0000000000110-reservation-line-type-taxable.ts +21 -0
- package/build/migrations-v2/0000000000111-reservation-line-type-suggestion-taxable.ts +20 -0
- package/build/migrations-v2/0000000000112-contact-payment-method-outside-default.ts +44 -0
- package/build/migrations-v2/0000000000113-merchant-fee-reference-assignment.ts +25 -0
- package/build/migrations-v2/0000000000114-recurring-fee-nights-filter.ts +32 -0
- package/build/migrations-v2/0000000000115-bank-records-with-suggested-rule-issue-code.ts +13 -0
- package/build/migrations-v2/0000000000116-guest-review.ts +45 -0
- package/build/migrations-v2/0000000000117-ramp-external-funding-accounts.ts +91 -0
- package/build/migrations-v2/0000000000118-pm-payout-assignment.ts +25 -0
- package/build/migrations-v2/0000000000119-chart-of-accounts-classifications.ts +46 -0
- package/build/migrations-v2/0000000000120-feedback.ts +41 -0
- package/build/migrations-v2/0000000000121-source-owner-block-calendar-index.ts +43 -0
- package/build/migrations-v2/0000000000122-recurring-fee-stay-types-filter.ts +20 -0
- package/build/migrations-v2/0000000000123-reservation-owner-stay-type-index.ts +40 -0
- package/build/migrations-v2/0000000000124-remove-tenant-test-and-billable-columns.ts +63 -0
- package/build/migrations-v2/0000000000125-ramp-application.ts +56 -0
- package/build/migrations-v2/0000000000126-advanced-deposits-update-operation.ts +10 -0
- package/build/migrations-v2/0000000000127-contact-1099-tax-details.ts +46 -0
- package/build/migrations-v2/0000000000128-tax-1099-email-templates.ts +36 -0
- package/build/migrations-v2/0000000000129-tenant-locked-at.ts +18 -0
- package/build/migrations-v2/0000000000130-second-factor-reset.ts +65 -0
- package/build/migrations-v2/0000000000131-payout-hold.ts +49 -0
- package/build/migrations-v2/0000000000132-member-invite-approval.ts +62 -0
- package/build/migrations-v2/0000000000133-audit-action-client-ip.ts +38 -0
- package/build/migrations-v2/0000000000134-drop-orphaned-hasura-triggers.ts +39 -0
- package/build/migrations-v2/0000000000135-drop-orphaned-hasura-triggers-literal.ts +42 -0
- package/build/migrations-v2/0000000000136-drop-all-hasura-triggers.ts +43 -0
- package/build/migrations-v2/0000000000137-webhook-event.ts +57 -0
- package/build/module/camel-case/index.d.ts +4 -4
- package/build/module/camel-case/index.js +4 -3
- package/build/module/camel-case/index.js.map +1 -1
- package/build/module/connect-handoff.d.ts +12 -0
- package/build/module/connect-handoff.js +70 -0
- package/build/module/connect-handoff.js.map +1 -0
- package/build/module/control-plane/index.d.ts +413 -14
- package/build/module/control-plane/index.js +58 -1
- package/build/module/control-plane/index.js.map +1 -1
- package/build/module/domain.d.ts +4 -0
- package/build/module/domain.js +2 -0
- package/build/module/domain.js.map +1 -0
- package/build/module/error.d.ts +2 -1
- package/build/module/error.js +3 -1
- package/build/module/error.js.map +1 -1
- package/build/module/index.d.ts +57 -15
- package/build/module/index.js +496 -64
- package/build/module/index.js.map +1 -1
- package/build/module/isomorphic.d.ts +6 -6
- package/build/module/isomorphic.js +2 -7
- package/build/module/isomorphic.js.map +1 -1
- package/build/module/local/digest.d.ts +3 -3
- package/build/module/local/digest.js.map +1 -1
- package/build/module/local/generate.js +15 -13
- package/build/module/local/generate.js.map +1 -1
- package/build/module/local/index.d.ts +5 -1
- package/build/module/local/index.js +347 -13
- package/build/module/local/index.js.map +1 -1
- package/build/module/local/prune-pulled-schema.js +4 -1
- package/build/module/local/prune-pulled-schema.js.map +1 -1
- package/build/module/migration-source.d.ts +4 -0
- package/build/module/migration-source.js +42 -0
- package/build/module/migration-source.js.map +1 -0
- package/build/module/migration.d.ts +7 -0
- package/build/module/migration.js +8 -0
- package/build/module/migration.js.map +1 -0
- package/build/module/pganalyze-comment-plugin/comment-transformer.js +3 -1
- package/build/module/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
- package/build/module/plugins.d.ts +2 -2
- package/build/module/plugins.js.map +1 -1
- package/build/module/postgres-error.d.ts +9 -0
- package/build/module/postgres-error.js +24 -0
- package/build/module/postgres-error.js.map +1 -0
- package/build/module/query/index.d.ts +1 -0
- package/build/module/query/index.js +1 -0
- package/build/module/query/index.js.map +1 -1
- package/build/module/query/listing/status.d.ts +2 -12
- package/build/module/query/listing/status.js +35 -18
- package/build/module/query/listing/status.js.map +1 -1
- package/build/module/query/tenant/billing-partner.d.ts +4 -0
- package/build/module/query/tenant/billing-partner.js +5 -0
- package/build/module/query/tenant/billing-partner.js.map +1 -0
- package/build/module/query/tenant/feature-enabled.d.ts +6 -0
- package/build/module/query/tenant/feature-enabled.js +27 -0
- package/build/module/query/tenant/feature-enabled.js.map +1 -0
- package/build/module/query/tenant/index.d.ts +4 -0
- package/build/module/query/tenant/index.js +5 -0
- package/build/module/query/tenant/index.js.map +1 -0
- package/build/module/query/tenant/status.d.ts +9 -0
- package/build/module/query/tenant/status.js +28 -0
- package/build/module/query/tenant/status.js.map +1 -0
- package/build/module/query/tenant/where-uuid-in.d.ts +2 -0
- package/build/module/query/tenant/where-uuid-in.js +11 -0
- package/build/module/query/tenant/where-uuid-in.js.map +1 -0
- package/build/module/regional.d.ts +31 -4
- package/build/module/regional.js +68 -8
- package/build/module/regional.js.map +1 -1
- package/build/module/test/index.d.ts +21 -11
- package/build/module/test/index.js +31 -26
- package/build/module/test/index.js.map +1 -1
- package/build/module/transaction.d.ts +3 -3
- package/build/module/transaction.js.map +1 -1
- package/build/module/v1.generated.d.ts +1333 -90
- package/build/module/v1.generated.js.map +1 -1
- package/package.json +19 -16
- package/build/migrations/0000000000001-init.ts +0 -5
- package/build/migrations/0000000000009-drop-store-schema.ts +0 -14
- package/build/migrations/0000000000010-bank-rules.ts +0 -190
- package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +0 -65
- package/build/migrations/0000000000012-bank-rule-conditions.ts +0 -45
- package/build/migrations/0000000000013-bank-rule-name-unique.ts +0 -15
- package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +0 -41
- package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +0 -70
- package/build/migrations/0000000000016-owner-statement-draft-status.ts +0 -22
- package/build/migrations/0000000000017-tenant-migration-markers.ts +0 -18
- package/build/migrations/0000000000018-security-deposits-payable-category.ts +0 -63
- package/build/migrations/0000000000019-tenant-app-settings.ts +0 -76
- package/build/migrations/0000000000020-operating-opening-trial-balance.ts +0 -36
- package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +0 -77
- package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +0 -30
- package/build/migrations/0000000000024-listing-parent.ts +0 -37
- package/build/migrations/0000000000025-journal-entry-parent-listing.ts +0 -26
- package/build/migrations/0000000000026-booking-channel-logo-slots.ts +0 -89
- package/build/migrations/0000000000027-list-browse-performance-indexes.ts +0 -52
- package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +0 -20
- package/build/migrations/0000000000029-tenant-slug.ts +0 -328
- package/build/migrations/0000000000030-pms-accounting-windows.ts +0 -50
- package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +0 -20
- package/build/migrations/0000000000032-flow-event-listening.ts +0 -28
- package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +0 -272
- package/build/migrations/0000000000034-historic-general-ledger.ts +0 -24
- package/build/migrations/0000000000035-tenant-regional-placement.ts +0 -37
- package/build/migrations/0000000000036-control-plane-projection-events.ts +0 -43
- package/build/migrations/0000000000037-tenant-guide-onboarding.ts +0 -21
- package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +0 -31
- package/build/migrations/0000000000039-crunchy-region.ts +0 -86
- package/build/migrations/0000000000040-hostaway-region.ts +0 -72
- package/build/migrations/0000000000041-audit-tenant-fk.ts +0 -66
- package/build/migrations/0000000000042-ramp-staging-connect-params.ts +0 -35
- package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +0 -125
- package/build/migrations/0000000000044-tenant-cross-region-fks.ts +0 -45
- package/build/migrations/0000000000045-cloudflare-region-env.ts +0 -100
- package/build/migrations/0000000000046-control-plane-outbox-alias.ts +0 -46
- package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +0 -16
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// PRO-20653: one row per two-step verification reset of a team's user. A reset
|
|
5
|
+
// a Team Admin starts is approved on creation. A support start waits as
|
|
6
|
+
// `pending` until a Team Admin decides, unless support checked the identity of
|
|
7
|
+
// a team's only admin. One pending request per user and team. Expand only.
|
|
8
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
9
|
+
await sql`set local lock_timeout = '5s'`.execute(db);
|
|
10
|
+
await sql`set local statement_timeout = '60s'`.execute(db);
|
|
11
|
+
|
|
12
|
+
await sql`
|
|
13
|
+
create type public.second_factor_reset_initiator as enum ('teamAdmin', 'support')
|
|
14
|
+
`.execute(db);
|
|
15
|
+
await sql`
|
|
16
|
+
create type public.second_factor_reset_status as enum ('pending', 'approved', 'denied', 'expired')
|
|
17
|
+
`.execute(db);
|
|
18
|
+
await sql`
|
|
19
|
+
create table public.second_factor_reset (
|
|
20
|
+
id uuid primary key default gen_random_uuid(),
|
|
21
|
+
tenant_id uuid not null references public.tenant (id) on delete cascade,
|
|
22
|
+
user_id uuid not null references public."user" (id) on delete cascade,
|
|
23
|
+
initiator public.second_factor_reset_initiator not null,
|
|
24
|
+
status public.second_factor_reset_status not null,
|
|
25
|
+
requested_by_user_id uuid null references public."user" (id) on delete set null,
|
|
26
|
+
decided_by_user_id uuid null references public."user" (id) on delete set null,
|
|
27
|
+
decided_at timestamptz null,
|
|
28
|
+
identity_check text null check (length(identity_check) between 1 and 500),
|
|
29
|
+
expires_at timestamptz not null,
|
|
30
|
+
created_at timestamptz not null default now(),
|
|
31
|
+
updated_at timestamptz not null default now()
|
|
32
|
+
)
|
|
33
|
+
`.execute(db);
|
|
34
|
+
await sql`
|
|
35
|
+
create index second_factor_reset_tenant_status_idx
|
|
36
|
+
on public.second_factor_reset (tenant_id, status)
|
|
37
|
+
`.execute(db);
|
|
38
|
+
await sql`
|
|
39
|
+
create unique index second_factor_reset_pending_idx
|
|
40
|
+
on public.second_factor_reset (tenant_id, user_id)
|
|
41
|
+
where status = 'pending'
|
|
42
|
+
`.execute(db);
|
|
43
|
+
await sql`
|
|
44
|
+
create index second_factor_reset_user_idx
|
|
45
|
+
on public.second_factor_reset (user_id)
|
|
46
|
+
`.execute(db);
|
|
47
|
+
await sql`
|
|
48
|
+
do $$
|
|
49
|
+
begin
|
|
50
|
+
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
51
|
+
grant select, insert, update, delete on public.second_factor_reset
|
|
52
|
+
to application;
|
|
53
|
+
end if;
|
|
54
|
+
end;
|
|
55
|
+
$$
|
|
56
|
+
`.execute(db);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
60
|
+
await sql`drop table if exists public.second_factor_reset`.execute(db);
|
|
61
|
+
await sql`drop type if exists public.second_factor_reset_status`.execute(db);
|
|
62
|
+
await sql`drop type if exists public.second_factor_reset_initiator`.execute(
|
|
63
|
+
db
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// PRO-20657: one row per hold on payouts to a contact whose bank details just
|
|
5
|
+
// changed. A hold is active until `held_until` passes or it is released.
|
|
6
|
+
// Expand only; code that predates the table ignores it.
|
|
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
|
+
|
|
11
|
+
await sql`
|
|
12
|
+
create type accounting.payout_hold_reason as enum (
|
|
13
|
+
'newBankDetails', 'takeoverPattern'
|
|
14
|
+
)
|
|
15
|
+
`.execute(db);
|
|
16
|
+
await sql`
|
|
17
|
+
create table accounting.payout_hold (
|
|
18
|
+
id uuid primary key default gen_random_uuid(),
|
|
19
|
+
tenant_id uuid not null references public.tenant (id) on delete restrict,
|
|
20
|
+
contact_id uuid not null references accounting.contact (id) on delete cascade,
|
|
21
|
+
reason accounting.payout_hold_reason not null,
|
|
22
|
+
held_until timestamptz not null,
|
|
23
|
+
created_by_user_id uuid null references public.user (id) on delete set null,
|
|
24
|
+
created_by_api_token_id uuid null,
|
|
25
|
+
released_at timestamptz null,
|
|
26
|
+
released_by_user_id uuid null references public.user (id) on delete set null,
|
|
27
|
+
created_at timestamptz not null default now()
|
|
28
|
+
)
|
|
29
|
+
`.execute(db);
|
|
30
|
+
await sql`
|
|
31
|
+
create index payout_hold_contact_idx
|
|
32
|
+
on accounting.payout_hold (tenant_id, contact_id, held_until desc)
|
|
33
|
+
`.execute(db);
|
|
34
|
+
await sql`
|
|
35
|
+
do $$
|
|
36
|
+
begin
|
|
37
|
+
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
38
|
+
grant select, insert, update, delete
|
|
39
|
+
on accounting.payout_hold to application;
|
|
40
|
+
end if;
|
|
41
|
+
end;
|
|
42
|
+
$$
|
|
43
|
+
`.execute(db);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
47
|
+
await sql`drop table if exists accounting.payout_hold`.execute(db);
|
|
48
|
+
await sql`drop type if exists accounting.payout_hold_reason`.execute(db);
|
|
49
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// PRO-20658: an invite to an email outside the team's and its partner's email
|
|
5
|
+
// domains waits here until another Team Admin, or VRPlatform support on a team
|
|
6
|
+
// with one admin, approves it. The invite runs on approval, so nothing exists
|
|
7
|
+
// for the invited user until then. One pending request per team and email.
|
|
8
|
+
// Expand only.
|
|
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 = '60s'`.execute(db);
|
|
12
|
+
|
|
13
|
+
await sql`
|
|
14
|
+
create type public.member_invite_approval_status as enum ('pending', 'approved', 'rejected')
|
|
15
|
+
`.execute(db);
|
|
16
|
+
await sql`
|
|
17
|
+
create type public.member_invite_approval_role as enum ('admin', 'user')
|
|
18
|
+
`.execute(db);
|
|
19
|
+
await sql`
|
|
20
|
+
create table public.member_invite_approval (
|
|
21
|
+
id uuid primary key default gen_random_uuid(),
|
|
22
|
+
tenant_id uuid not null references public.tenant (id) on delete cascade,
|
|
23
|
+
email text not null,
|
|
24
|
+
role public.member_invite_approval_role null,
|
|
25
|
+
permission_bundles text[] null,
|
|
26
|
+
send_email boolean not null default true,
|
|
27
|
+
status public.member_invite_approval_status not null default 'pending',
|
|
28
|
+
requested_by_user_id uuid null references public."user" (id) on delete set null,
|
|
29
|
+
decided_by_user_id uuid null references public."user" (id) on delete set null,
|
|
30
|
+
decided_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 index member_invite_approval_tenant_status_idx
|
|
37
|
+
on public.member_invite_approval (tenant_id, status)
|
|
38
|
+
`.execute(db);
|
|
39
|
+
await sql`
|
|
40
|
+
create unique index member_invite_approval_pending_idx
|
|
41
|
+
on public.member_invite_approval (tenant_id, email)
|
|
42
|
+
where status = 'pending'
|
|
43
|
+
`.execute(db);
|
|
44
|
+
await sql`
|
|
45
|
+
do $$
|
|
46
|
+
begin
|
|
47
|
+
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
48
|
+
grant select, insert, update, delete on public.member_invite_approval
|
|
49
|
+
to application;
|
|
50
|
+
end if;
|
|
51
|
+
end;
|
|
52
|
+
$$
|
|
53
|
+
`.execute(db);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
57
|
+
await sql`drop table if exists public.member_invite_approval`.execute(db);
|
|
58
|
+
await sql`drop type if exists public.member_invite_approval_role`.execute(db);
|
|
59
|
+
await sql`drop type if exists public.member_invite_approval_status`.execute(
|
|
60
|
+
db
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// PRO-20660: the IP address of the user session that made a request, shown in
|
|
5
|
+
// the security log. It lives in its own table so the busy audit.action table is
|
|
6
|
+
// not altered or indexed: the `retention/audit-client-ips` task deletes rows
|
|
7
|
+
// after 90 days with the created_at index. Expand only; code that predates the
|
|
8
|
+
// table ignores it.
|
|
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 = '60s'`.execute(db);
|
|
12
|
+
|
|
13
|
+
await sql`
|
|
14
|
+
create table audit.action_client_ip (
|
|
15
|
+
action_id uuid primary key references audit.action (id) on delete cascade,
|
|
16
|
+
client_ip inet not null,
|
|
17
|
+
created_at timestamptz not null default now()
|
|
18
|
+
)
|
|
19
|
+
`.execute(db);
|
|
20
|
+
await sql`
|
|
21
|
+
create index action_client_ip_created_idx
|
|
22
|
+
on audit.action_client_ip (created_at)
|
|
23
|
+
`.execute(db);
|
|
24
|
+
await sql`
|
|
25
|
+
do $$
|
|
26
|
+
begin
|
|
27
|
+
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
28
|
+
grant select, insert, update, delete
|
|
29
|
+
on audit.action_client_ip to application;
|
|
30
|
+
end if;
|
|
31
|
+
end;
|
|
32
|
+
$$
|
|
33
|
+
`.execute(db);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
37
|
+
await sql`drop table if exists audit.action_client_ip`.execute(db);
|
|
38
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// PRO-20708: Hasura metadata no longer defines the event triggers
|
|
5
|
+
// tracking_user, tracking_tenant_user, tracking_tenant and user-name
|
|
6
|
+
// (PRO-16860), but their generated Postgres triggers kept writing
|
|
7
|
+
// hdb_catalog.event_log rows that nothing delivers. On Crunchy, 145k of them
|
|
8
|
+
// made every Hasura event poll take about 105 ms. Their rows are dropped with
|
|
9
|
+
// the triggers and are not restored by down.
|
|
10
|
+
const triggers = [
|
|
11
|
+
['user', 'tracking_user', ['INSERT', 'UPDATE', 'DELETE']],
|
|
12
|
+
['user', 'user-name', ['UPDATE']],
|
|
13
|
+
['tenant_user', 'tracking_tenant_user', ['INSERT', 'UPDATE', 'DELETE']],
|
|
14
|
+
['tenant', 'tracking_tenant', ['INSERT', 'UPDATE', 'DELETE']],
|
|
15
|
+
] as const;
|
|
16
|
+
|
|
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 = '240s'`.execute(db);
|
|
20
|
+
for (const [table, name, operations] of triggers) {
|
|
21
|
+
for (const operation of operations) {
|
|
22
|
+
const fn = `notify_hasura_${name}_${operation}`;
|
|
23
|
+
await sql`
|
|
24
|
+
drop trigger if exists ${sql.id(fn)} on ${sql.id('public', table)}
|
|
25
|
+
`.execute(db);
|
|
26
|
+
await sql`drop function if exists ${sql.id('hdb_catalog', fn)}()`.execute(
|
|
27
|
+
db
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
await sql`
|
|
32
|
+
delete from hdb_catalog.event_log
|
|
33
|
+
where trigger_name in (${sql.join(triggers.map(([, name]) => name))})
|
|
34
|
+
`.execute(db);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Hasura generates these functions from metadata, which no longer defines the
|
|
38
|
+
// triggers, so there is nothing to restore.
|
|
39
|
+
export async function down(): Promise<void> {}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// PRO-20708: 0000000000134 passed the trigger names through sql.id, and the
|
|
5
|
+
// migrator's CamelCasePlugin rewrote them (notify_hasura_tracking_user_INSERT
|
|
6
|
+
// became a name that does not exist), so its `drop ... if exists` statements
|
|
7
|
+
// matched nothing. The names are written literally here.
|
|
8
|
+
const statements = [
|
|
9
|
+
['user', 'notify_hasura_tracking_user_INSERT'],
|
|
10
|
+
['user', 'notify_hasura_tracking_user_UPDATE'],
|
|
11
|
+
['user', 'notify_hasura_tracking_user_DELETE'],
|
|
12
|
+
['user', 'notify_hasura_user-name_UPDATE'],
|
|
13
|
+
['tenant_user', 'notify_hasura_tracking_tenant_user_INSERT'],
|
|
14
|
+
['tenant_user', 'notify_hasura_tracking_tenant_user_UPDATE'],
|
|
15
|
+
['tenant_user', 'notify_hasura_tracking_tenant_user_DELETE'],
|
|
16
|
+
['tenant', 'notify_hasura_tracking_tenant_INSERT'],
|
|
17
|
+
['tenant', 'notify_hasura_tracking_tenant_UPDATE'],
|
|
18
|
+
['tenant', 'notify_hasura_tracking_tenant_DELETE'],
|
|
19
|
+
] as const;
|
|
20
|
+
|
|
21
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
22
|
+
await sql`set local lock_timeout = '5s'`.execute(db);
|
|
23
|
+
await sql`set local statement_timeout = '240s'`.execute(db);
|
|
24
|
+
for (const [table, name] of statements) {
|
|
25
|
+
await sql
|
|
26
|
+
.raw(`drop trigger if exists "${name}" on public."${table}"`)
|
|
27
|
+
.execute(db);
|
|
28
|
+
await sql
|
|
29
|
+
.raw(`drop function if exists hdb_catalog."${name}"()`)
|
|
30
|
+
.execute(db);
|
|
31
|
+
}
|
|
32
|
+
await sql`
|
|
33
|
+
delete from hdb_catalog.event_log
|
|
34
|
+
where trigger_name in (
|
|
35
|
+
'tracking_user', 'user-name', 'tracking_tenant_user', 'tracking_tenant'
|
|
36
|
+
)
|
|
37
|
+
`.execute(db);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Hasura generates these functions from metadata, which no longer defines the
|
|
41
|
+
// triggers, so there is nothing to restore.
|
|
42
|
+
export async function down(): Promise<void> {}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// PRO-20708: Hasura metadata defines no event trigger since 2026-11-14
|
|
5
|
+
// (PRO-20709, PRO-20753), and only Crunchy ever ran Hasura. The generated
|
|
6
|
+
// notify_hasura_* triggers left in the other databases wrote hdb_catalog.event_log
|
|
7
|
+
// rows nothing delivers. Drops every one of them and their functions, found in
|
|
8
|
+
// the catalog so the migrator's CamelCasePlugin never touches the names
|
|
9
|
+
// (0000000000134), and their undelivered rows. Not restored by down.
|
|
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 = '240s'`.execute(db);
|
|
13
|
+
await sql`
|
|
14
|
+
do $$
|
|
15
|
+
declare
|
|
16
|
+
item record;
|
|
17
|
+
begin
|
|
18
|
+
for item in
|
|
19
|
+
select trigger.tgname as name, trigger.tgrelid::regclass as relation
|
|
20
|
+
from pg_trigger as trigger
|
|
21
|
+
where trigger.tgname like 'notify\\_hasura\\_%' and not trigger.tgisinternal
|
|
22
|
+
loop
|
|
23
|
+
execute format('drop trigger if exists %I on %s', item.name, item.relation);
|
|
24
|
+
end loop;
|
|
25
|
+
for item in
|
|
26
|
+
select fn.oid::regprocedure as signature
|
|
27
|
+
from pg_proc as fn
|
|
28
|
+
inner join pg_namespace as namespace on namespace.oid = fn.pronamespace
|
|
29
|
+
where namespace.nspname = 'hdb_catalog' and fn.proname like 'notify\\_hasura\\_%'
|
|
30
|
+
loop
|
|
31
|
+
execute format('drop function if exists %s', item.signature);
|
|
32
|
+
end loop;
|
|
33
|
+
end
|
|
34
|
+
$$
|
|
35
|
+
`.execute(db);
|
|
36
|
+
await sql`
|
|
37
|
+
delete from hdb_catalog.event_log where not delivered and not archived
|
|
38
|
+
`.execute(db);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Hasura generates these functions from metadata, which defines no event
|
|
42
|
+
// trigger, so there is nothing to restore.
|
|
43
|
+
export async function down(): Promise<void> {}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// Business transactions record webhook events here; a queue processor matches them to the
|
|
5
|
+
// subscriptions that now live in the control plane
|
|
6
|
+
// (docs/rfcs/2026-11-webhook-subscriptions-control-plane.md). Deliveries and attempts keep
|
|
7
|
+
// their subscription ids, whose rows move to the control plane, so the foreign keys go.
|
|
8
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
9
|
+
await sql`
|
|
10
|
+
create table webhook.event (
|
|
11
|
+
id uuid primary key default gen_random_uuid(),
|
|
12
|
+
tenant_id uuid not null references public.tenant (id) on delete cascade,
|
|
13
|
+
event_type webhook.event_type not null,
|
|
14
|
+
resource_type webhook.resource_type not null,
|
|
15
|
+
resource_id text not null,
|
|
16
|
+
source_event_key text not null,
|
|
17
|
+
data jsonb not null,
|
|
18
|
+
created_at timestamptz not null default now(),
|
|
19
|
+
matched_at timestamptz,
|
|
20
|
+
constraint webhook_event_source_event_key_unique unique (tenant_id, source_event_key)
|
|
21
|
+
)
|
|
22
|
+
`.execute(db);
|
|
23
|
+
await sql`
|
|
24
|
+
create index webhook_event_unmatched_idx
|
|
25
|
+
on webhook.event (created_at, id)
|
|
26
|
+
where matched_at is null
|
|
27
|
+
`.execute(db);
|
|
28
|
+
await sql`
|
|
29
|
+
create index webhook_event_matched_idx
|
|
30
|
+
on webhook.event (matched_at)
|
|
31
|
+
where matched_at is not null
|
|
32
|
+
`.execute(db);
|
|
33
|
+
await sql`
|
|
34
|
+
alter table webhook.delivery
|
|
35
|
+
drop constraint delivery_subscription_id_fkey
|
|
36
|
+
`.execute(db);
|
|
37
|
+
await sql`
|
|
38
|
+
alter table webhook.delivery_attempt_secret
|
|
39
|
+
drop constraint delivery_attempt_secret_subscription_secret_id_fkey
|
|
40
|
+
`.execute(db);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
44
|
+
await sql`
|
|
45
|
+
alter table webhook.delivery_attempt_secret
|
|
46
|
+
add constraint delivery_attempt_secret_subscription_secret_id_fkey
|
|
47
|
+
foreign key (subscription_secret_id)
|
|
48
|
+
references webhook.subscription_secret (id) on delete restrict
|
|
49
|
+
`.execute(db);
|
|
50
|
+
await sql`
|
|
51
|
+
alter table webhook.delivery
|
|
52
|
+
add constraint delivery_subscription_id_fkey
|
|
53
|
+
foreign key (subscription_id)
|
|
54
|
+
references webhook.subscription (id) on delete cascade
|
|
55
|
+
`.execute(db);
|
|
56
|
+
await sql`drop table webhook.event`.execute(db);
|
|
57
|
+
}
|
|
@@ -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:
|
|
5
|
-
transformQuery(args:
|
|
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:
|
|
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
|
-
|
|
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(
|
|
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,
|
|
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
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { sql } from 'kysely';
|
|
2
|
+
// Rows never belong to a user, so no authenticated user can claim one through
|
|
3
|
+
// the OAuth state flow that shares the table.
|
|
4
|
+
const handoffUserId = '00000000-0000-0000-0000-000000000000';
|
|
5
|
+
const handoffRefPattern = /^handoff_[A-Za-z0-9_-]{22}$/;
|
|
6
|
+
async function hashRef(ref) {
|
|
7
|
+
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(ref));
|
|
8
|
+
return [...new Uint8Array(digest)]
|
|
9
|
+
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
10
|
+
.join('');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Passes secrets between the API and Trigger.dev tasks through the tenant's
|
|
14
|
+
* database, so connect credentials never enter Trigger.dev payloads or outputs.
|
|
15
|
+
* Rows expire after one hour, the lifetime of a reused connect run. Reads do not
|
|
16
|
+
* consume the row: a retried or reused run must still find it.
|
|
17
|
+
*/
|
|
18
|
+
export function useConnectHandoff(kysely, tenantId) {
|
|
19
|
+
return {
|
|
20
|
+
async put(appId, value) {
|
|
21
|
+
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
22
|
+
const ref = `handoff_${btoa(String.fromCharCode(...bytes))
|
|
23
|
+
.replaceAll('+', '-')
|
|
24
|
+
.replaceAll('/', '_')
|
|
25
|
+
.replaceAll('=', '')}`;
|
|
26
|
+
await kysely
|
|
27
|
+
.deleteFrom('public.connectionOauthState')
|
|
28
|
+
.where('stateHash', 'in', kysely
|
|
29
|
+
.selectFrom('public.connectionOauthState')
|
|
30
|
+
.select('stateHash')
|
|
31
|
+
.where('expiresAt', '<=', sql `clock_timestamp()`)
|
|
32
|
+
.orderBy('expiresAt')
|
|
33
|
+
.limit(100)
|
|
34
|
+
.forUpdate()
|
|
35
|
+
.skipLocked())
|
|
36
|
+
.execute();
|
|
37
|
+
// Transient authentication coordination is excluded from business audit:
|
|
38
|
+
// references, setup parameters and credentials must never be audited.
|
|
39
|
+
await kysely
|
|
40
|
+
.insertInto('public.connectionOauthState')
|
|
41
|
+
.values({
|
|
42
|
+
stateHash: await hashRef(ref),
|
|
43
|
+
tenantId,
|
|
44
|
+
userId: handoffUserId,
|
|
45
|
+
appId,
|
|
46
|
+
connectionId: null,
|
|
47
|
+
params: value,
|
|
48
|
+
redirectUri: '',
|
|
49
|
+
expiresAt: sql `clock_timestamp() + interval '1 hour'`,
|
|
50
|
+
})
|
|
51
|
+
.execute();
|
|
52
|
+
return ref;
|
|
53
|
+
},
|
|
54
|
+
async get(ref, appId) {
|
|
55
|
+
if (!handoffRefPattern.test(ref))
|
|
56
|
+
return undefined;
|
|
57
|
+
const row = await kysely
|
|
58
|
+
.selectFrom('public.connectionOauthState')
|
|
59
|
+
.select('params')
|
|
60
|
+
.where('stateHash', '=', await hashRef(ref))
|
|
61
|
+
.where('tenantId', '=', tenantId)
|
|
62
|
+
.where('appId', '=', appId)
|
|
63
|
+
.where('userId', '=', handoffUserId)
|
|
64
|
+
.where('expiresAt', '>', sql `clock_timestamp()`)
|
|
65
|
+
.executeTakeFirst();
|
|
66
|
+
return row?.params;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=connect-handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-handoff.js","sourceRoot":"src/","sources":["connect-handoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,8EAA8E;AAC9E,8CAA8C;AAC9C,MAAM,aAAa,GAAG,sCAAsC,CAAC;AAC7D,MAAM,iBAAiB,GAAG,6BAA6B,CAAC;AAExD,KAAK,UAAU,OAAO,CAAC,GAAW;IAChC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CACvC,SAAS,EACT,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAC9B,CAAC;IACF,OAAO,CAAC,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;SAC/B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SACjD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,QAAgB;IAChE,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,KAAa,EAAE,KAAiB;YACxC,MAAM,KAAK,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;YACzD,MAAM,GAAG,GAAG,WAAW,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC;iBACvD,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;iBACpB,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;iBACpB,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;YACzB,MAAM,MAAM;iBACT,UAAU,CAAC,6BAA6B,CAAC;iBACzC,KAAK,CACJ,WAAW,EACX,IAAI,EACJ,MAAM;iBACH,UAAU,CAAC,6BAA6B,CAAC;iBACzC,MAAM,CAAC,WAAW,CAAC;iBACnB,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,GAAG,CAAQ,mBAAmB,CAAC;iBACxD,OAAO,CAAC,WAAW,CAAC;iBACpB,KAAK,CAAC,GAAG,CAAC;iBACV,SAAS,EAAE;iBACX,UAAU,EAAE,CAChB;iBACA,OAAO,EAAE,CAAC;YACb,yEAAyE;YACzE,sEAAsE;YACtE,MAAM,MAAM;iBACT,UAAU,CAAC,6BAA6B,CAAC;iBACzC,MAAM,CAAC;gBACN,SAAS,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC;gBAC7B,QAAQ;gBACR,MAAM,EAAE,aAAa;gBACrB,KAAK;gBACL,YAAY,EAAE,IAAI;gBAClB,MAAM,EAAE,KAAK;gBACb,WAAW,EAAE,EAAE;gBACf,SAAS,EAAE,GAAG,CAAA,uCAAuC;aACtD,CAAC;iBACD,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,CAAC;QACb,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAa;YAClC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC;gBAAE,OAAO,SAAS,CAAC;YACnD,MAAM,GAAG,GAAG,MAAM,MAAM;iBACrB,UAAU,CAAC,6BAA6B,CAAC;iBACzC,MAAM,CAAC,QAAQ,CAAC;iBAChB,KAAK,CAAC,WAAW,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;iBAC3C,KAAK,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,CAAC;iBAChC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC;iBAC1B,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,aAAa,CAAC;iBACnC,KAAK,CAAC,WAAW,EAAE,GAAG,EAAE,GAAG,CAAQ,mBAAmB,CAAC;iBACvD,gBAAgB,EAAE,CAAC;YACtB,OAAO,GAAG,EAAE,MAAM,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC","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"]}
|