better-supabase 0.16.0 → 0.18.0
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/dist/{access-sql-B-MkVARa.js → access-sql-CNIgUqWf.js} +2 -0
- package/dist/{adapter-Dyks1lX1.js → adapter-CfuBICuG.js} +3 -1
- package/dist/{ai-schedules-BmkARmQ9.d.ts → ai-schedules-DzLh6BYI.d.ts} +1 -1
- package/dist/ai-sdk/agents/index.d.ts +2 -2
- package/dist/ai-sdk/memory/index.js +1 -1
- package/dist/{api-hHwieEfz.d.ts → api-B6zteBya.d.ts} +2 -2
- package/dist/{app-tables-D29Rahtg.js → app-tables-DyswUg6J.js} +11 -2
- package/dist/{app-tables-yMQ4ubyY.d.ts → app-tables-XwCviyhP.d.ts} +1 -1
- package/dist/astro/index.d.ts +5 -5
- package/dist/astro/index.js +5 -5
- package/dist/{attachments-aJYgdYtB.js → attachments-M-Dy79Ry.js} +9 -2
- package/dist/{authorization-HZdJCaVm.d.ts → authorization-IiE__z2m.d.ts} +187 -89
- package/dist/{automations-CIwRq7zm.js → automations-B5P6vTvk.js} +2 -2
- package/dist/{automations-CD1XlL2W.js → automations-BKjJpktQ.js} +1 -1
- package/dist/{automations-Bc2ue55V.js → automations-FCnWy387.js} +2 -2
- package/dist/better-result/index.d.ts +2 -2
- package/dist/{bind-JGCPGUJh.d.ts → bind-pu5TLrla.d.ts} +4 -4
- package/dist/{block-env-y65GF_px.d.ts → block-env-CA65ulTD.d.ts} +4 -4
- package/dist/blocks/access-requests/index.d.ts +1 -1
- package/dist/blocks/access-requests/index.js +1 -1
- package/dist/blocks/activities/index.d.ts +1 -1
- package/dist/blocks/activities/index.js +1 -1
- package/dist/blocks/agents/index.d.ts +1 -1
- package/dist/blocks/agents/index.js +1 -1
- package/dist/blocks/ai-cache/index.d.ts +1 -1
- package/dist/blocks/ai-cache/index.js +1 -1
- package/dist/blocks/ai-chat/index.d.ts +4 -4
- package/dist/blocks/ai-chat/index.js +1 -1
- package/dist/blocks/ai-files/index.d.ts +1 -1
- package/dist/blocks/ai-files/index.js +1 -1
- package/dist/blocks/ai-keys/index.d.ts +1 -1
- package/dist/blocks/ai-keys/index.js +1 -1
- package/dist/blocks/ai-schedules/index.d.ts +2 -2
- package/dist/blocks/ai-schedules/index.js +1 -1
- package/dist/blocks/announcements/index.d.ts +4 -4
- package/dist/blocks/announcements/index.js +1 -1
- package/dist/blocks/api-keys/index.d.ts +2 -2
- package/dist/blocks/api-keys/index.js +1 -1
- package/dist/blocks/approvals/index.d.ts +1 -1
- package/dist/blocks/approvals/index.js +1 -1
- package/dist/blocks/assets/index.d.ts +1 -1
- package/dist/blocks/assets/index.js +1 -1
- package/dist/blocks/assignment/index.d.ts +1 -1
- package/dist/blocks/attachments/index.d.ts +40 -4
- package/dist/blocks/attachments/index.js +42 -4
- package/dist/blocks/audit/index.d.ts +5 -5
- package/dist/blocks/audit/index.js +2 -2
- package/dist/blocks/automations/index.d.ts +3 -3
- package/dist/blocks/automations/index.js +1 -1
- package/dist/blocks/billable-time/index.d.ts +1 -1
- package/dist/blocks/billing/index.d.ts +3 -3
- package/dist/blocks/billing/index.js +1 -1
- package/dist/blocks/bookings/index.d.ts +2 -2
- package/dist/blocks/bookings/index.js +1 -1
- package/dist/blocks/bulk/index.d.ts +1 -1
- package/dist/blocks/bulk/index.js +1 -1
- package/dist/blocks/calendar/index.d.ts +2 -2
- package/dist/blocks/calendar/index.js +1 -1
- package/dist/blocks/catalog/index.d.ts +1 -1
- package/dist/blocks/catalog/index.js +1 -1
- package/dist/blocks/channels/index.d.ts +1 -1
- package/dist/blocks/collections/index.d.ts +1 -1
- package/dist/blocks/collections/index.js +1 -1
- package/dist/blocks/comments/index.d.ts +5 -5
- package/dist/blocks/comments/index.js +1 -1
- package/dist/blocks/compliance/index.d.ts +1 -1
- package/dist/blocks/compliance/index.js +1 -1
- package/dist/blocks/connectors/index.d.ts +1 -1
- package/dist/blocks/connectors/index.js +1 -1
- package/dist/blocks/contacts/index.d.ts +1 -1
- package/dist/blocks/contacts/index.js +1 -1
- package/dist/blocks/content/index.d.ts +2 -2
- package/dist/blocks/content/index.js +1 -1
- package/dist/blocks/contracts/index.d.ts +1 -1
- package/dist/blocks/contracts/index.js +1 -1
- package/dist/blocks/courses/index.d.ts +2 -2
- package/dist/blocks/courses/index.js +1 -1
- package/dist/blocks/created-by/index.d.ts +4 -3
- package/dist/blocks/created-by/index.js +2 -2
- package/dist/blocks/custom-fields/index.d.ts +1 -1
- package/dist/blocks/custom-fields/index.js +1 -1
- package/dist/blocks/data-lifecycle/index.d.ts +1 -1
- package/dist/blocks/data-lifecycle/index.js +1 -1
- package/dist/blocks/deals/index.d.ts +1 -1
- package/dist/blocks/deals/index.js +1 -1
- package/dist/blocks/dispatch/index.d.ts +2 -2
- package/dist/blocks/dispatch/index.js +1 -1
- package/dist/blocks/documents/index.d.ts +1 -1
- package/dist/blocks/documents/index.js +1 -1
- package/dist/blocks/domains/index.d.ts +1 -1
- package/dist/blocks/domains/index.js +1 -1
- package/dist/blocks/donations/index.d.ts +1 -1
- package/dist/blocks/donations/index.js +1 -1
- package/dist/blocks/drive/index.d.ts +1 -1
- package/dist/blocks/drive/index.js +2 -2
- package/dist/blocks/employees/index.d.ts +2 -2
- package/dist/blocks/employees/index.js +1 -1
- package/dist/blocks/enrichment/index.d.ts +1 -1
- package/dist/blocks/enrollments/index.d.ts +1 -1
- package/dist/blocks/enrollments/index.js +1 -1
- package/dist/blocks/entitlements/index.d.ts +3 -3
- package/dist/blocks/expenses/index.d.ts +1 -1
- package/dist/blocks/expenses/index.js +1 -1
- package/dist/blocks/field-history/index.d.ts +1 -1
- package/dist/blocks/flags/index.d.ts +1 -1
- package/dist/blocks/flags/index.js +1 -1
- package/dist/blocks/forecasts/index.d.ts +1 -1
- package/dist/blocks/forms/index.d.ts +2 -2
- package/dist/blocks/forms/index.js +1 -1
- package/dist/blocks/goals/index.d.ts +1 -1
- package/dist/blocks/goals/index.js +1 -1
- package/dist/blocks/guests/index.d.ts +1 -1
- package/dist/blocks/hiring/index.d.ts +1 -1
- package/dist/blocks/hiring/index.js +1 -1
- package/dist/blocks/identities/index.d.ts +1 -1
- package/dist/blocks/identities/index.js +1 -1
- package/dist/blocks/imports/index.d.ts +1 -1
- package/dist/blocks/inbox/index.d.ts +5 -5
- package/dist/blocks/inbox/index.js +1 -1
- package/dist/blocks/incidents/index.d.ts +1 -1
- package/dist/blocks/incidents/index.js +1 -1
- package/dist/blocks/index.d.ts +4 -4
- package/dist/blocks/index.js +1 -1
- package/dist/blocks/inventory/index.d.ts +1 -1
- package/dist/blocks/inventory/index.js +1 -1
- package/dist/blocks/invoices/index.d.ts +1 -1
- package/dist/blocks/invoices/index.js +1 -1
- package/dist/blocks/knowledge/index.d.ts +1 -1
- package/dist/blocks/knowledge/index.js +1 -1
- package/dist/blocks/lead-scoring/index.d.ts +2 -2
- package/dist/blocks/lead-scoring/index.js +1 -1
- package/dist/blocks/leases/index.d.ts +1 -1
- package/dist/blocks/leases/index.js +1 -1
- package/dist/blocks/leave/index.d.ts +1 -1
- package/dist/blocks/leave/index.js +1 -1
- package/dist/blocks/ledger/index.d.ts +1 -1
- package/dist/blocks/mail-sync/index.d.ts +2 -2
- package/dist/blocks/mail-sync/index.js +1 -1
- package/dist/blocks/memberships/index.d.ts +3 -3
- package/dist/blocks/memberships/index.js +1 -1
- package/dist/blocks/memory/index.d.ts +1 -1
- package/dist/blocks/memory/index.js +1 -1
- package/dist/blocks/messaging/index.d.ts +5 -5
- package/dist/blocks/messaging/index.js +1 -1
- package/dist/blocks/metrics/index.d.ts +1 -1
- package/dist/blocks/metrics/index.js +1 -1
- package/dist/blocks/mfa/index.d.ts +2 -2
- package/dist/blocks/moderation/index.d.ts +1 -1
- package/dist/blocks/moderation/index.js +1 -1
- package/dist/blocks/notifications/index.d.ts +17 -6
- package/dist/blocks/notifications/index.js +110 -40
- package/dist/blocks/numbering/index.d.ts +1 -1
- package/dist/blocks/numbering/index.js +1 -1
- package/dist/blocks/oauth-server/index.d.ts +1 -1
- package/dist/blocks/oauth-server/index.js +1 -1
- package/dist/blocks/onboarding/index.d.ts +2 -2
- package/dist/blocks/onboarding/index.js +1 -1
- package/dist/blocks/orders/index.d.ts +2 -2
- package/dist/blocks/orders/index.js +1 -1
- package/dist/blocks/organizations/index.d.ts +38 -3
- package/dist/blocks/organizations/index.js +50 -5
- package/dist/blocks/outbox/index.d.ts +1 -1
- package/dist/blocks/outbox/index.js +1 -1
- package/dist/blocks/passes/index.d.ts +2 -2
- package/dist/blocks/passes/index.js +1 -1
- package/dist/blocks/permissions/index.d.ts +4 -4
- package/dist/blocks/permissions/index.js +2 -2
- package/dist/blocks/pipelines/index.d.ts +1 -1
- package/dist/blocks/pipelines/index.js +1 -1
- package/dist/blocks/posts/index.d.ts +2 -2
- package/dist/blocks/posts/index.js +1 -1
- package/dist/blocks/profiles/index.d.ts +1 -1
- package/dist/blocks/profiles/index.js +1 -1
- package/dist/blocks/promotions/index.d.ts +1 -1
- package/dist/blocks/promotions/index.js +1 -1
- package/dist/blocks/push/index.d.ts +76 -10
- package/dist/blocks/push/index.js +172 -43
- package/dist/blocks/queue/index.d.ts +1 -1
- package/dist/blocks/queue/index.js +1 -1
- package/dist/blocks/quotes/index.d.ts +1 -1
- package/dist/blocks/quotes/index.js +1 -1
- package/dist/blocks/rank/index.d.ts +1 -1
- package/dist/blocks/reactions/index.d.ts +4 -4
- package/dist/blocks/reactions/index.js +1 -1
- package/dist/blocks/relations/index.d.ts +1 -1
- package/dist/blocks/relations/index.js +1 -1
- package/dist/blocks/reminders/index.d.ts +1 -1
- package/dist/blocks/reminders/index.js +1 -1
- package/dist/blocks/reviews/index.d.ts +1 -1
- package/dist/blocks/reviews/index.js +1 -1
- package/dist/blocks/saved-views/index.d.ts +3 -3
- package/dist/blocks/saved-views/index.js +1 -1
- package/dist/blocks/scores/index.d.ts +1 -1
- package/dist/blocks/scores/index.js +1 -1
- package/dist/blocks/search/index.d.ts +3 -3
- package/dist/blocks/search/index.js +1 -1
- package/dist/blocks/security-events/index.d.ts +1 -1
- package/dist/blocks/security-events/index.js +1 -1
- package/dist/blocks/segments/index.d.ts +2 -2
- package/dist/blocks/segments/index.js +1 -1
- package/dist/blocks/sequences/index.d.ts +2 -2
- package/dist/blocks/sequences/index.js +1 -1
- package/dist/blocks/service-accounts/index.d.ts +1 -1
- package/dist/blocks/service-accounts/index.js +1 -1
- package/dist/blocks/sessions/index.d.ts +2 -2
- package/dist/blocks/sessions/index.js +1 -1
- package/dist/blocks/settings/index.d.ts +2 -2
- package/dist/blocks/settings/index.js +1 -1
- package/dist/blocks/share-links/index.d.ts +1 -1
- package/dist/blocks/share-links/index.js +1 -1
- package/dist/blocks/shipments/index.d.ts +2 -2
- package/dist/blocks/shipments/index.js +1 -1
- package/dist/blocks/signatures/index.d.ts +2 -2
- package/dist/blocks/signatures/index.js +1 -1
- package/dist/blocks/signing-keys/index.d.ts +1 -1
- package/dist/blocks/signing-keys/index.js +1 -1
- package/dist/blocks/sla/index.d.ts +1 -1
- package/dist/blocks/sla/index.js +1 -1
- package/dist/blocks/sso/index.d.ts +1 -1
- package/dist/blocks/sso/index.js +1 -1
- package/dist/blocks/state-machine/index.d.ts +1 -1
- package/dist/blocks/state-machine/index.js +1 -1
- package/dist/blocks/subjects/index.d.ts +2 -2
- package/dist/blocks/tags/index.d.ts +2 -2
- package/dist/blocks/tags/index.js +1 -1
- package/dist/blocks/tasks/index.d.ts +2 -2
- package/dist/blocks/tasks/index.js +1 -1
- package/dist/blocks/teams/index.d.ts +1 -1
- package/dist/blocks/teams/index.js +1 -1
- package/dist/blocks/templates/index.d.ts +2 -2
- package/dist/blocks/templates/index.js +1 -1
- package/dist/blocks/time-tracking/index.d.ts +1 -1
- package/dist/blocks/time-tracking/index.js +1 -1
- package/dist/blocks/timeline/index.d.ts +3 -3
- package/dist/blocks/trash/index.d.ts +1 -1
- package/dist/blocks/trash/index.js +1 -1
- package/dist/blocks/undo/index.d.ts +2 -2
- package/dist/blocks/updated-at/index.d.ts +7 -4
- package/dist/blocks/updated-at/index.js +2 -2
- package/dist/blocks/usage/index.d.ts +2 -2
- package/dist/blocks/usage/index.js +1 -1
- package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
- package/dist/blocks/vercel-marketplace/index.js +1 -1
- package/dist/blocks/versions/index.d.ts +1 -1
- package/dist/blocks/versions/index.js +1 -1
- package/dist/blocks/waitlist/index.d.ts +1 -1
- package/dist/blocks/waitlist/index.js +1 -1
- package/dist/blocks/webhooks/index.d.ts +2 -2
- package/dist/blocks/webhooks/index.js +1 -1
- package/dist/blocks/workflow-editor/index.d.ts +4 -4
- package/dist/blocks/workflow-editor/index.js +1 -1
- package/dist/blocks/workflows/index.d.ts +4 -4
- package/dist/{channel-BjvGO39m.d.ts → channel-JcMd5lNP.d.ts} +30 -2
- package/dist/cli/{add-D7TkPdco.js → add-B1S3yK4L.js} +20 -13
- package/dist/cli/add-BQPJnapO.js +1 -0
- package/dist/cli/{add-I8OW-qJH.js → add-D7YIXslp.js} +2 -2
- package/dist/cli/{backfill-DIz5DnlQ.js → backfill-BwkyNhlC.js} +4 -4
- package/dist/cli/bin.js +1 -1
- package/dist/cli/{blocks-Bp5RPoft.js → blocks-CBqENu3C.js} +1 -1
- package/dist/cli/{blocks-xk-SE8gS.js → blocks-DDm1Zc2S.js} +2 -2
- package/dist/cli/{cache-AznIssjI.js → cache-DE2IH1-C.js} +1 -1
- package/dist/cli/{codemod-Aewxza6i.js → codemod-OHKhVV-v.js} +4 -4
- package/dist/cli/{command-CQ61x6gN.js → command-BWEEXmtz.js} +20 -0
- package/dist/cli/{completion-Dlu5AdUW.js → completion-8EDK21xj.js} +1 -1
- package/dist/cli/{completion-BwI0_Ap5.js → completion-BfnKI4QZ.js} +2 -2
- package/dist/cli/{completion-2Y3D_eNu.js → completion-Bt7LMypX.js} +2 -2
- package/dist/cli/{config-9t5ec_N7.js → config-BJSqMi04.js} +20 -6
- package/dist/cli/{config-CBqkQjjN.js → config-BlfVh0IP.js} +1 -1
- package/dist/cli/{config-CPux9Wa7.js → config-WKDixoGK.js} +1 -1
- package/dist/cli/{content-mapper-DCrz6OIv.js → content-mapper-CaygHH_k.js} +2 -2
- package/dist/cli/{db-DrBI_HNv.js → db-DYU5hUcd.js} +3 -3
- package/dist/cli/{doctor-DkOSLPEQ.js → doctor-D_nrsd9E.js} +186 -143
- package/dist/cli/{env-BBl5L8Bf.js → env-BCgVZkcb.js} +1 -1
- package/dist/cli/env-xhwXk5Ri.js +1 -0
- package/dist/cli/{gen-CFkYUnWq.js → gen-D7gMEwvg.js} +22 -15
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +8 -8
- package/dist/cli/{init-CHj9ad4S.js → init-ch-HWJyp.js} +7 -7
- package/dist/cli/{keys-DGEpMbeB.js → keys-CbaL0lnw.js} +1 -1
- package/dist/cli/{live-DGdLR41j.js → live-B38ePuRS.js} +2 -2
- package/dist/cli/{mcp-BZno503V.js → mcp-P9RP2SJ3.js} +3 -3
- package/dist/cli/{metadata-BfgHMe4q.js → metadata-BTihErEc.js} +3 -3
- package/dist/cli/{migration-safety-BnnXPAro.js → migration-safety-DYo1vVWC.js} +2 -2
- package/dist/cli/{module-migration-O_IxewFs.js → migrations-BoIyGczt.js} +3 -113
- package/dist/cli/module-migration-DXvo0EqU.js +119 -0
- package/dist/cli/{moved-CsfDQcyk.js → moved-DVwgE8lV.js} +1 -1
- package/dist/cli/{parse-B9Iv_-Pf.js → parse-B079x40m.js} +1 -1
- package/dist/cli/powersync-D-0yV_L_.js +283 -0
- package/dist/cli/powersync-DXVsKkAu.js +1 -0
- package/dist/cli/{print-DosQIFSy.js → print-CRon4lXf.js} +2 -1
- package/dist/cli/{remove-DK2G_KHm.js → remove-D89s99ha.js} +6 -6
- package/dist/cli/{render-5y5a1QZr.js → render-BJF9ytUi.js} +15 -6
- package/dist/cli/{run-BXx6D1aR.js → run-DmOTMa44.js} +2 -2
- package/dist/cli/{run-Bs4OKdDI.js → run-jeplMBOK.js} +29 -10
- package/dist/cli/{run-MRET30vh.js → run-x9ZY4Tm0.js} +38 -37
- package/dist/cli/{seed-Cz8PcXeT.js → seed-D9mt8bnW.js} +3 -3
- package/dist/cli/seed-EPO6AvLG.js +1 -0
- package/dist/cli/{shared-BLqbvY2x.js → shared-B38Chjgd.js} +1 -1
- package/dist/cli/{skills-toUan_OV.js → skills-FXAVPLzp.js} +1 -1
- package/dist/cli/{snapshot-uTUlEzY2.js → snapshot-BXmU3IXN.js} +3 -3
- package/dist/cli/{source-args-IpJRJO5t.js → source-args-DlckPVje.js} +1 -1
- package/dist/cli/{source-D2gJHKwC.js → source-irttnsEb.js} +1 -1
- package/dist/cli/{spec-Cm2einTO.js → spec-CDxfokey.js} +3 -3
- package/dist/cli/{spec-DUjOtciN.js → spec-DzD5wMVF.js} +1 -1
- package/dist/cli/{sql-layout-lUWenjJw.js → sql-layout-D8QrNvt4.js} +2 -2
- package/dist/cli/{stack-CWEHdO0b.js → stack-DgASZP0K.js} +1 -1
- package/dist/cli/{sync-CZMRB3aU.js → sync-s1iKFIos.js} +3 -2
- package/dist/cli/{upgrade-BFEIMC7U.js → upgrade-B4FPlK-_.js} +4 -3
- package/dist/cli/{upgrade-fVsJniXm.js → upgrade-CluxP3JJ.js} +3 -3
- package/dist/cli/{version-B2Dr6VmJ.js → version-TgFM8sOd.js} +1 -1
- package/dist/client/index.d.ts +5 -5
- package/dist/client/native/index.d.ts +4 -4
- package/dist/{composite-CfYyU3vs.d.ts → composite-C-8A8qzi.d.ts} +4 -4
- package/dist/{composite-B3TIjId4.js → composite-D24L5RIY.js} +2 -2
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +4 -4
- package/dist/{config-CcehOvbz.js → config-CD2OGfCG.js} +2 -1
- package/dist/{config-DWGgUQCh.js → config-mbVyJwSc.js} +7 -6
- package/dist/{context-8kb8m5uO.d.ts → context-D24k1Cpc.d.ts} +36 -4
- package/dist/{controller-BW-5Opig.d.ts → controller-BR7CZ1R9.d.ts} +1 -1
- package/dist/{conversion-3iv2r7YC.d.ts → conversion-BgtOfTaS.d.ts} +1 -1
- package/dist/create/index.d.ts +2 -2
- package/dist/create/index.js +5 -5
- package/dist/{define-C5AcEkEJ.d.ts → define-Cgru0_kF.d.ts} +1 -1
- package/dist/{define-block-C1RHXz7L.d.ts → define-block-CJWiDWa5.d.ts} +11 -4
- package/dist/edge/index.d.ts +7 -7
- package/dist/edge/index.js +7 -7
- package/dist/elysia/index.d.ts +1 -1
- package/dist/elysia/index.js +1 -1
- package/dist/{email-tt2QqiSc.d.ts → email-B3YxEzwC.d.ts} +1 -1
- package/dist/{entitlements-sO977DO-.d.ts → entitlements-DHcNt1aF.d.ts} +1 -1
- package/dist/{events-SqJLbb8q.js → events-DuLhzjP6.js} +2 -0
- package/dist/{executor-BcNWcD-4.d.ts → executor-BWFfz0ik.d.ts} +2 -2
- package/dist/expo/index.d.ts +3 -3
- package/dist/expo/index.js +3 -3
- package/dist/{extension-B-lajjex.js → extension-DTaHjwdc.js} +3 -2
- package/dist/{extension-B0EjCYhO.js → extension-mGylYROs.js} +2 -10
- package/dist/{field-errors-Dt86dCKk.d.ts → field-errors-DucQdLl7.d.ts} +6 -6
- package/dist/{framework-BozTXRzt.js → framework-CNhTg0th.js} +1 -1
- package/dist/{framework-BGdZVyPL.d.ts → framework-x9Y4uB1q.d.ts} +5 -5
- package/dist/h3/index.d.ts +1 -1
- package/dist/h3/index.js +1 -1
- package/dist/h3/v1/index.d.ts +1 -1
- package/dist/h3/v1/index.js +1 -1
- package/dist/hono/index.d.ts +6 -6
- package/dist/hono/index.js +7 -6
- package/dist/{index-Cc4mIQS8.d.ts → index-4WT_uRRL.d.ts} +20 -4
- package/dist/{index-CENWq3zb.d.ts → index-BAcQz5DS.d.ts} +1 -1
- package/dist/{index-CTu-3fJB.d.ts → index-BH3NYExp.d.ts} +3 -3
- package/dist/{index-CcAmFNVi.d.ts → index-C0t-vNIt.d.ts} +2 -2
- package/dist/{index-DZKCc2WM.d.ts → index-C6ruLtyx.d.ts} +3 -3
- package/dist/{index-Craf712U.d.ts → index-XAyzdLns.d.ts} +9 -9
- package/dist/{index-BxYOB1Oc.d.ts → index-iRkFvJ7J.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{instances-BHjCZoF8.js → instances-DDt7NdVl.js} +1 -1
- package/dist/{kit-DOwKpSkA.d.ts → kit-CVgQCIBO.d.ts} +1 -1
- package/dist/{kit-5l-o8RxL.js → kit-DhlB-vv_.js} +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/{list-query-DYhgRTd5.d.ts → list-query-DxjuIHEL.d.ts} +1 -1
- package/dist/mapper/bin.js +7 -6
- package/dist/mcp/index.d.ts +11 -5
- package/dist/mcp/index.js +6 -6
- package/dist/mcp/sdk/index.d.ts +3 -3
- package/dist/mcp/sdk/index.js +2 -2
- package/dist/{methods-B3o7BFOW.js → methods-Cund9ZBe.js} +1 -1
- package/dist/nestjs/index.d.ts +2 -2
- package/dist/nestjs/index.js +1 -1
- package/dist/next/index.d.ts +16 -16
- package/dist/next/index.js +6 -6
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +1 -1
- package/dist/{operations-CSc_IsHO.d.ts → operations-CAjMgNr9.d.ts} +1 -1
- package/dist/{options-CK5WiFwG.js → options-3OYOU56e.js} +1 -1
- package/dist/{options-xD4_FRUq.js → options-56zYYXxc.js} +1 -1
- package/dist/{options-_F-enoBs.d.ts → options-5WvWOkAm.d.ts} +1 -1
- package/dist/{options-SViK_2x2.js → options-62woPFn3.js} +1 -1
- package/dist/{options-1GgseJq5.js → options-7ixoOoap.js} +1 -1
- package/dist/{options-BZsoPJGX.js → options-9dSU5RML.js} +2 -2
- package/dist/{options-y_-AkVCs.d.ts → options-B0YZtAkb.d.ts} +1 -1
- package/dist/{options-HLwOuF2H.js → options-B2Kz_tCx.js} +2 -2
- package/dist/{options-CEMawFrr.js → options-B685YSzQ.js} +1 -1
- package/dist/{options-DWbA9buW.js → options-B692WoK6.js} +2 -2
- package/dist/options-BHU1wc74.js +5 -0
- package/dist/{options-CPK2nQER.js → options-BHy0Z5Zd.js} +2 -2
- package/dist/{options-Fz6xqu-b.js → options-BKDxrPvE.js} +2 -2
- package/dist/{options-BVg58avP.js → options-BLfymS4s.js} +2 -2
- package/dist/{options-CYV4iZiQ.js → options-BOCRbzh3.js} +1 -1
- package/dist/{options-C-dQHH5-.js → options-BQWJqwHO.js} +3 -2
- package/dist/{options-Cl9Ag2Pt.js → options-BQunK6_Y.js} +2 -2
- package/dist/{options-CljDnQt2.js → options-BQyrZjwM.js} +4 -1
- package/dist/options-BR9xTHZW.js +5 -0
- package/dist/{options-D40CQzji.js → options-BRUdd5jY.js} +1 -1
- package/dist/{options-CsGl5BLH.d.ts → options-BTmaRzx2.d.ts} +13 -5
- package/dist/{options-Li1Dyu88.d.ts → options-BUCQYAeJ.d.ts} +2 -2
- package/dist/{options-DChZoVfs.d.ts → options-B_NrjVDt.d.ts} +1 -0
- package/dist/{options-B5BU2Yg7.js → options-BawzwlmC.js} +2 -2
- package/dist/{options-BlzSfWxC.d.ts → options-BbLDAp7G.d.ts} +2 -2
- package/dist/{options-DTDxFT6J.js → options-Bc4xz5jQ.js} +2 -2
- package/dist/options-BfFC4iFE.js +8 -0
- package/dist/{options-Br1Xi2Hw.js → options-BfPsL7E2.js} +1 -1
- package/dist/{options-DYBQ973I.js → options-Bfmwwc78.js} +1 -1
- package/dist/{options-c5WCsky5.js → options-BhsdveDk.js} +2 -2
- package/dist/{options-B5woz53h.js → options-BomoTH-8.js} +2 -2
- package/dist/{options-DeNejBtq.js → options-BtjkzIVh.js} +1 -1
- package/dist/options-Bvi9bl4H.js +5 -0
- package/dist/{options-IHPg8ZoA.js → options-BwKNmaJo.js} +2 -2
- package/dist/{options-CtUUU71w.js → options-BxpLtyk-.js} +4 -6
- package/dist/{options-D_bBVCXg.js → options-BzB2QxL3.js} +1 -1
- package/dist/{options-CmraJhd9.js → options-C078wBP0.js} +1 -1
- package/dist/options-C1-pwEqm.js +5 -0
- package/dist/{options-BZOliZvb.js → options-C3AdsFJ6.js} +2 -2
- package/dist/options-C7C5OhmL.d.ts +8 -0
- package/dist/{options-B2swWnJW.js → options-C87u6eSa.js} +3 -2
- package/dist/{options-CVSWgZpY.js → options-CBAEGxwS.js} +1 -1
- package/dist/{options-CM6-18FQ.d.ts → options-CDSCkYxu.d.ts} +1 -0
- package/dist/{options-9gvPo1BC.js → options-CDUr8zzX.js} +1 -1
- package/dist/{options-DMR68VAC.js → options-CFjGxfa8.js} +2 -2
- package/dist/{options-Bf96aVk5.js → options-CI6P0xhV.js} +1 -1
- package/dist/{options-B5VUf4IT.js → options-CJFMK9A_.js} +1 -1
- package/dist/{options-CRz8Ht_4.js → options-CLpgx7en.js} +3 -2
- package/dist/{options-BesyRBnM.js → options-CTXHj9zr.js} +2 -2
- package/dist/{options-D2d1fFuw.js → options-CTl8T88w.js} +1 -1
- package/dist/{options-C3RgtOLo.js → options-CTv-xmbA.js} +2 -2
- package/dist/{options-Bpl-WFPk.js → options-CUIOOv4z.js} +1 -1
- package/dist/{options-o2kfYU2x.js → options-CZDmtsbV.js} +2 -2
- package/dist/{options-CF7nRWXS.js → options-CZTscdPB.js} +1 -1
- package/dist/{options-BlncUmIc.js → options-CZdKndeo.js} +2 -2
- package/dist/{options-DplE18Ko.d.ts → options-C_7g9TTq.d.ts} +1 -1
- package/dist/{options-C_pb1Nd3.js → options-Cb2FOFj5.js} +1 -1
- package/dist/{options-t_O5ldT6.js → options-CbOstLa7.js} +2 -2
- package/dist/{options-Bt0bYMLl.js → options-CcXgWlvm.js} +2 -2
- package/dist/{options-BMjcVuaI.js → options-CfVPctAw.js} +7 -0
- package/dist/{options-DWpz3V3F.js → options-ChiL-4ZS.js} +2 -2
- package/dist/{options-E7KcmHQv.js → options-Cjgaf8ub.js} +2 -2
- package/dist/{options-DrSkIBCD.js → options-CoSPgWKy.js} +1 -1
- package/dist/{options-Bp7sgKvl.js → options-CpZ2HlSU.js} +5 -3
- package/dist/{options-CN7PHkhU.js → options-CsSe8Nba.js} +1 -1
- package/dist/{options-B9q8CROT.js → options-CsvJR-r2.js} +1 -1
- package/dist/{options-oeAq4Ho5.js → options-Cucv6sWP.js} +2 -2
- package/dist/{options-BOOEzor9.js → options-CyjL9lTf.js} +2 -2
- package/dist/{options-pOVWwbAK.d.ts → options-D-OOO9V2.d.ts} +1 -1
- package/dist/{options-nFzfgtA6.js → options-D0Y6ZMe8.js} +1 -1
- package/dist/{options-BnZS7IK-.js → options-D0sj5abR.js} +2 -2
- package/dist/{options-0qvUckqt.js → options-D2s7fT1s.js} +2 -2
- package/dist/{options-BjtrC7o6.js → options-D32-YxnO.js} +1 -1
- package/dist/{options-B0EJULm5.js → options-D610Fa6T.js} +2 -2
- package/dist/{options-BvtnxHfK.js → options-D96dScev.js} +1 -1
- package/dist/{options-DgQo80Xh.js → options-DFpyP1bg.js} +2 -2
- package/dist/{options-BYOtaF7w.js → options-DJEcS4DX.js} +1 -1
- package/dist/{options-DPgdAXO5.js → options-DJbN3bi9.js} +2 -2
- package/dist/{options-EsUh744F.js → options-DKoQoRCy.js} +2 -2
- package/dist/{options-CvD9vNvx.js → options-DM1qaMMQ.js} +1 -1
- package/dist/{options-eBPsk4WI.js → options-DNgSwhsm.js} +2 -2
- package/dist/{options-2EMA_x6_.js → options-DOIwzRXL.js} +2 -2
- package/dist/{options-D6as77gU.d.ts → options-DRIgHh4O.d.ts} +2 -2
- package/dist/{options-DDzggjN7.js → options-DRrZmJyI.js} +2 -2
- package/dist/{options-DJ-aYPVN.js → options-DUMUsvml.js} +2 -2
- package/dist/{options-Cp0HyUEk.js → options-DWwL5Kaz.js} +1 -1
- package/dist/{options-BCrqe3HH.js → options-DZHZYlpD.js} +1 -1
- package/dist/{options-BQIYfx9F.js → options-DZLkeqWn.js} +2 -2
- package/dist/{options-RKYdmIdV.js → options-DZRpXKQE.js} +1 -1
- package/dist/{options-D0G06Zm9.js → options-D_9Vxx7f.js} +2 -2
- package/dist/{options-BMGClqoa.js → options-DcHl59RC.js} +1 -1
- package/dist/{options-CW9wTqOk.js → options-Dcaql09y.js} +1 -1
- package/dist/{options-CXFz0xxS.js → options-DcnBNYmV.js} +1 -1
- package/dist/{options-21s0dpnX.js → options-DdpM-fiP.js} +2 -2
- package/dist/{options-BbnPv6p7.js → options-DhdazgTZ.js} +2 -2
- package/dist/{options-C239TLRF.js → options-Dpy-Ruo-.js} +1 -1
- package/dist/{options-DWVYM8P0.d.ts → options-DsVuVRH3.d.ts} +1 -1
- package/dist/{options-BlOPivzq.js → options-DtAJxfHS.js} +1 -1
- package/dist/{options-DXnBN2E7.js → options-Dz9Yo52Z.js} +2 -2
- package/dist/{options-DcOx8_3X.d.ts → options-HnfETSHr.d.ts} +1 -1
- package/dist/{options-CoX6VKGb.js → options-LqUXTpML.js} +1 -1
- package/dist/options-MsloEAIB.js +5 -0
- package/dist/{options-DCduTMST.js → options-P2FxqYpd.js} +2 -2
- package/dist/options-_1gAIMq7.d.ts +60 -0
- package/dist/{options-B0FcEKtH.js → options-aT89JqlB.js} +1 -1
- package/dist/{options-Cyu0hgmN.js → options-cVKZu9b0.js} +2 -2
- package/dist/options-fMxhtuVR.js +5 -0
- package/dist/{options-BxcFLL1G.js → options-fkShrmGQ.js} +2 -2
- package/dist/{options-Ctac2R0Q.js → options-gUvfr3no.js} +2 -2
- package/dist/{options-DNKyN5uq.js → options-hynwKWuf.js} +2 -2
- package/dist/{options-CkScQRJR.js → options-lsxJYfYx.js} +2 -2
- package/dist/{options-CyAhRKKm.d.ts → options-o5wCw8H7.d.ts} +2 -2
- package/dist/{options-DARkpk2P.js → options-p49DFg3H.js} +2 -2
- package/dist/{options-zkyhM3qi.js → options-pYNpXKcg.js} +1 -1
- package/dist/{options-Cqq2jUww.js → options-qtETCHzW.js} +2 -2
- package/dist/options-rnKlqYEr.js +5 -0
- package/dist/{options-KV84gAxl.js → options-sU_zGkiV.js} +2 -2
- package/dist/{options-BfLmA375.js → options-xq4MXG1M.js} +2 -2
- package/dist/{options-BA6jV6py.js → options-zzlznRA7.js} +2 -2
- package/dist/orpc/index.d.ts +21 -10
- package/dist/orpc/index.js +60 -31
- package/dist/otel/index.d.ts +1 -1
- package/dist/otel/index.js +5 -5
- package/dist/{ports-mObLgH1z.d.ts → ports-g0H1Kzwr.d.ts} +1 -1
- package/dist/powersync/index.d.ts +136 -3
- package/dist/powersync/index.js +333 -1
- package/dist/preset/index.d.ts +3 -3
- package/dist/preset/index.js +3 -3
- package/dist/{preset-CsHnIBJF.js → preset-B3CukUhu.js} +4 -4
- package/dist/{push-token-BSSvsWXZ.d.ts → push-token-Cl2EihRc.d.ts} +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/react/index.d.ts +5 -5
- package/dist/react/native/index.d.ts +1 -1
- package/dist/react/server.d.ts +6 -6
- package/dist/react-router/index.d.ts +5 -5
- package/dist/react-router/index.js +5 -5
- package/dist/realtime/index.d.ts +3 -3
- package/dist/realtime/index.js +1 -1
- package/dist/{record-form-D9ILuVtA.d.ts → record-form-zMwz0Ayt.d.ts} +1 -1
- package/dist/records/index.d.ts +7 -7
- package/dist/{refusal-ByBZcm0V.js → refusal-D48CMqpQ.js} +2 -2
- package/dist/{refusal-CSntB_x8.d.ts → refusal-OrlI3g4H.d.ts} +1 -1
- package/dist/{resource-DV2GC2dB.js → resource-R3KToNze.js} +1 -1
- package/dist/{resource-execute-Cpnob1Vj.d.ts → resource-execute-CKBtGL8-.d.ts} +1 -1
- package/dist/{resource-types-pMeLs68X.d.ts → resource-types-8Q5Klkpa.d.ts} +2 -2
- package/dist/{resources-C02l_YBJ.js → resources-DqIwoQsP.js} +1 -1
- package/dist/{resources-7iq2-5_A.d.ts → resources-DxpqenZA.d.ts} +1 -1
- package/dist/{respond-C3CcOZlA.js → respond-3RKp6VgU.js} +8 -1
- package/dist/{respond-Dn1_YhC1.d.ts → respond-oZeJ342J.d.ts} +6 -0
- package/dist/server/index.d.ts +9 -9
- package/dist/server/index.js +6 -6
- package/dist/{server-types-CK8mUIUT.d.ts → server-types-gR4Q1aM0.d.ts} +1 -1
- package/dist/{session-DWmFv3vB.d.ts → session-Fcft5A39.d.ts} +2 -2
- package/dist/{sign-in-B64114O4.js → sign-in-BLkRU3lc.js} +1 -1
- package/dist/solid/index.d.ts +6 -6
- package/dist/solid-start/index.d.ts +5 -5
- package/dist/solid-start/index.js +5 -5
- package/dist/spec/index.d.ts +2 -2
- package/dist/spec/index.js +1 -1
- package/dist/{spec-pins-DIx95afw.d.ts → spec-pins-BZkKfwY8.d.ts} +2 -0
- package/dist/{spec-pins-C1Vm8OBl.js → spec-pins-D3zDek-u.js} +1 -0
- package/dist/sql/index.d.ts +5 -5
- package/dist/sql/index.js +5 -5
- package/dist/{sql-Dl3Alk43.js → sql-fHTjZGqR.js} +4445 -3211
- package/dist/sql-type-iUSZpaUu.js +34 -0
- package/dist/sqlite/index.d.ts +1 -1
- package/dist/ssr/index.d.ts +1 -1
- package/dist/{statuses-DMMDwXpZ.js → statuses-Alll5Ip6.js} +2 -2
- package/dist/storage/index.js +1 -1
- package/dist/svelte/index.d.ts +6 -6
- package/dist/sveltekit/index.d.ts +6 -6
- package/dist/sveltekit/index.js +5 -5
- package/dist/{tags-qvVk79pp.d.ts → tags-sM-CH9Mn.d.ts} +1 -1
- package/dist/tanstack-db/index.d.ts +1 -1
- package/dist/tanstack-start/index.d.ts +5 -5
- package/dist/tanstack-start/index.js +5 -5
- package/dist/{tenant-DOKIJI62.d.ts → tenant-DyoVYFfC.d.ts} +1 -1
- package/dist/testing/index.d.ts +9 -9
- package/dist/testing/index.js +8 -5
- package/dist/{timeline-CvTuXYvn.d.ts → timeline-CMmo0R7g.d.ts} +3 -3
- package/dist/{topic-ikV_pLTX.js → topic-J9I3yu6f.js} +1 -1
- package/dist/{topic-CZXHhZye.d.ts → topic-nQYxoTaU.d.ts} +2 -2
- package/dist/{verify-CjvNLY7N.d.ts → verify-DEqY__0N.d.ts} +1 -1
- package/dist/vue/index.d.ts +6 -6
- package/dist/{watch-topic-BAxoPKZx.d.ts → watch-topic-UGSEWAqR.d.ts} +1 -1
- package/dist/workflow-sdk/world/index.js +1 -1
- package/dist/{workflow-sdk-Bw6_u0ar.js → workflow-sdk-DELaQEp3.js} +2 -0
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/index.js +1 -1
- package/package.json +1 -1
- package/schemas/config-v1.json +471 -69
- package/schemas/doctor-report-v1.json +1 -0
- package/dist/cli/add-Bfb_ISrO.js +0 -1
- package/dist/cli/env-CAU1nknN.js +0 -1
- package/dist/cli/seed-D6XijwbR.js +0 -1
- package/dist/options-63AKQNv0.js +0 -5
- package/dist/options-B-cxGmRA.js +0 -5
- package/dist/options-BPDiwSa-.js +0 -5
- package/dist/options-C6rEL6U5.js +0 -8
- package/dist/options-CE93HOYi.d.ts +0 -7
- package/dist/options-CTZNpb2n.js +0 -5
- package/dist/options-CrC78Tee.js +0 -5
- package/dist/options-DINdgVih.d.ts +0 -9
- package/dist/options-DWML05Cp.js +0 -5
- package/dist/options-Q1Bzgqpr.js +0 -5
|
@@ -2,7 +2,7 @@ import { n as CliError } from "./errors-BTe6A15O.js";
|
|
|
2
2
|
import { d as readSupabaseToml, p as sqlWorkflow } from "./supabase-toml-CncmQbO0.js";
|
|
3
3
|
import { t as importFresh } from "./fresh-import-DzgsGHkX.js";
|
|
4
4
|
import { i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
|
|
5
|
-
import { a as sqlPlan, i as schemasDirOf, n as migrationsDir, r as moduleLayoutFor } from "./sql-layout-
|
|
5
|
+
import { a as sqlPlan, i as schemasDirOf, n as migrationsDir, r as moduleLayoutFor } from "./sql-layout-D8QrNvt4.js";
|
|
6
6
|
import { resolve } from "node:path";
|
|
7
7
|
import { readFile, readdir } from "node:fs/promises";
|
|
8
8
|
import { MODULE_ID_TYPES, compileReadSets, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, renderBlocks, resolveBlocks, scopeProblems, templateFunctions } from "better-supabase/sql";
|
|
@@ -374,7 +374,7 @@ async function dataMigration(config, args, now) {
|
|
|
374
374
|
error: [`No migration before the data migration creates ${missing.map((extension) => extension.name).join(", ")}, and the schema migration needs ${missing.length === 1 ? "it" : "them"} while it applies.`, "Run `better-supabase upgrade` to write the extensions migration, then create the schema migration again after it."].join("\n")
|
|
375
375
|
};
|
|
376
376
|
const files = rendered.filter((file) => file.kind === "data");
|
|
377
|
-
const contents = `-- better-supabase add --adopt: the rows and settings of ${files.map((file) => file.module).join(", ")}, which a schema diff skips.\n\n${files.map((file) => file.contents.trim()).join("\n\n")}\n`;
|
|
377
|
+
const contents = `-- better-supabase add --adopt: the rows and settings of ${files.map((file) => file.module).join(", ")}, which a schema diff skips.\n\nset lock_timeout = '5s';\n\n${files.map((file) => file.contents.trim()).join("\n\n")}\n`;
|
|
378
378
|
const dir = migrationsDir(config);
|
|
379
379
|
const existing = await readdir(resolve(config.root, dir)).catch(() => []);
|
|
380
380
|
const latest = existing.toSorted().findLast((name) => name.endsWith(DATA_SUFFIX));
|
|
@@ -410,114 +410,4 @@ async function dataMigration(config, args, now) {
|
|
|
410
410
|
};
|
|
411
411
|
}
|
|
412
412
|
//#endregion
|
|
413
|
-
|
|
414
|
-
/** The migration the migrations workflow writes the SQL modules into. */
|
|
415
|
-
const MODULES_SUFFIX = "_better_supabase_modules.sql";
|
|
416
|
-
/**
|
|
417
|
-
* The migration `gen` writes the read-sets module into under the migrations
|
|
418
|
-
* workflow.
|
|
419
|
-
*/
|
|
420
|
-
const READ_SETS_SUFFIX = "_better_supabase_read_sets.sql";
|
|
421
|
-
const UPGRADE_START = "-- @bsb-upgrade-start";
|
|
422
|
-
const UPGRADE_END = "-- @bsb-upgrade-end";
|
|
423
|
-
/**
|
|
424
|
-
* Whether the project runs the migrations workflow, with no declarative
|
|
425
|
-
* schemas.
|
|
426
|
-
*/
|
|
427
|
-
async function writesMigrations(config) {
|
|
428
|
-
return sqlWorkflow(config, await readSupabaseToml(config.root)) === "migrations";
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* One migration that holds, in order, the extensions, the upgrade steps, each
|
|
432
|
-
* module's schema body with its `@bsb-block` header, the realtime topic
|
|
433
|
-
* policies and the data statements. Every statement is re-runnable, so a later
|
|
434
|
-
* migration carries all of them, not only the changes.
|
|
435
|
-
*/
|
|
436
|
-
function renderModuleMigration(parts) {
|
|
437
|
-
const schema = parts.files.filter((file) => file.kind === "schema");
|
|
438
|
-
const data = parts.files.filter((file) => file.kind === "data");
|
|
439
|
-
const modules = [...new Set(schema.map((file) => file.instance ?? file.module))];
|
|
440
|
-
const extensions = moduleSchemaExtensions(parts.files);
|
|
441
|
-
const upgrade = parts.upgrade ?? [];
|
|
442
|
-
return `${[
|
|
443
|
-
[
|
|
444
|
-
`-- better-supabase sql: ${modules.length > 0 ? `the SQL modules ${modules.join(", ")}` : "the realtime topic policies"}, in one migration (database.sql.workflow: 'migrations').`,
|
|
445
|
-
"-- Managed by `better-supabase add` and `better-supabase upgrade`, which write a new migration when they change.",
|
|
446
|
-
"-- Change them through `blocks` in better-supabase.config.ts and the module's SQL hooks."
|
|
447
|
-
].join("\n"),
|
|
448
|
-
...extensions.length > 0 ? [extensions.map((extension) => extension.statement).join("\n")] : [],
|
|
449
|
-
...upgrade.length > 0 ? [[
|
|
450
|
-
UPGRADE_START,
|
|
451
|
-
...upgrade,
|
|
452
|
-
UPGRADE_END
|
|
453
|
-
].join("\n\n")] : [],
|
|
454
|
-
...schema.map((file) => file.contents.trim()),
|
|
455
|
-
...parts.topics === void 0 ? [] : [parts.topics.trim()],
|
|
456
|
-
...data.map((file) => file.contents.trim())
|
|
457
|
-
].join("\n\n")}\n`;
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* The migration without its upgrade steps and package versions, which a later
|
|
461
|
-
* one doesn't repeat.
|
|
462
|
-
*/
|
|
463
|
-
function comparable(text) {
|
|
464
|
-
return text.replaceAll("\r\n", "\n").replace(/\n\n-- @bsb?-upgrade-start\n[\s\S]*?\n-- @bsb?-upgrade-end/, "").replaceAll(/^(-- better-supabase module: [^\n(]*?)(?: \([^)]*\))?$/gm, "$1");
|
|
465
|
-
}
|
|
466
|
-
/** Whether two module migrations hold the same modules. */
|
|
467
|
-
const sameModuleMigration = (current, expected) => current !== void 0 && comparable(current) === comparable(expected);
|
|
468
|
-
/** Whether a module migration holds `contents` (one module's file) unchanged. */
|
|
469
|
-
const migrationHolds = (text, contents) => comparable(text).includes(comparable(contents.trim()));
|
|
470
|
-
/** The newest migration that ends in `suffix`, with its text. */
|
|
471
|
-
async function latestMigration(config, suffix) {
|
|
472
|
-
const dir = migrationsDir(config);
|
|
473
|
-
const latest = (await readdir(resolve(config.root, dir)).catch(() => [])).toSorted().findLast((name) => name.endsWith(suffix));
|
|
474
|
-
if (latest === void 0) return;
|
|
475
|
-
return {
|
|
476
|
-
path: `${dir}/${latest}`,
|
|
477
|
-
text: await readFile(resolve(config.root, dir, latest), "utf-8")
|
|
478
|
-
};
|
|
479
|
-
}
|
|
480
|
-
const MODULE_MARKERS = /^-- @(?:bsb-block|bs-module) ([a-zA-Z0-9-]+)@(\d+)(?: [a-z]+(?: ([a-z0-9-]+))?)?$/gm;
|
|
481
|
-
/**
|
|
482
|
-
* The modules and versions a module migration installs, from its `@bsb-block`
|
|
483
|
-
* lines.
|
|
484
|
-
*/
|
|
485
|
-
function migrationModules(text) {
|
|
486
|
-
return new Map([...text.matchAll(MODULE_MARKERS)].map((match) => [match[1], Number(match[2])]));
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* The instances a module migration installs under another name than their
|
|
490
|
-
* block, each to its block.
|
|
491
|
-
*/
|
|
492
|
-
function migrationInstances(text) {
|
|
493
|
-
return new Map([...text.matchAll(MODULE_MARKERS)].flatMap((match) => match[3] === void 0 ? [] : [[match[1], match[3]]]));
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Writes `contents` as a new migration ending in `suffix`, unless the newest
|
|
497
|
-
* one already holds the same statements. `force` writes it anyway, for upgrade
|
|
498
|
-
* steps that have to run once.
|
|
499
|
-
*/
|
|
500
|
-
async function writeLatestMigration(config, suffix, contents, options) {
|
|
501
|
-
const latest = await latestMigration(config, suffix);
|
|
502
|
-
if (options.force !== true && latest !== void 0 && sameModuleMigration(latest.text, contents)) return {
|
|
503
|
-
path: latest.path,
|
|
504
|
-
wrote: false,
|
|
505
|
-
line: `Unchanged ${latest.path} (it has these statements)`
|
|
506
|
-
};
|
|
507
|
-
const dir = migrationsDir(config);
|
|
508
|
-
const path = `${dir}/${stampAfter(await readdir(resolve(config.root, dir)).catch(() => []), options.now)}${suffix}`;
|
|
509
|
-
const applied = await applyPlan(sqlPlan(config, {
|
|
510
|
-
regenerate: "better-supabase upgrade",
|
|
511
|
-
files: [{
|
|
512
|
-
path,
|
|
513
|
-
contents
|
|
514
|
-
}]
|
|
515
|
-
}), { "dry-run": options.dryRun });
|
|
516
|
-
return {
|
|
517
|
-
path,
|
|
518
|
-
wrote: applied.mode === "write",
|
|
519
|
-
line: changeLines(applied).join("\n")
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
//#endregion
|
|
523
|
-
export { entitlementsMode as C, unsafeKey as E, entitlementRequirements as S, providerLabel as T, layoutFor as _, migrationInstances as a, accessProviderMode as b, sameModuleMigration as c, DATA_NEXT as d, dataMigration as f, layout as g, MEMBERSHIP_CLAIM_MODULES as h, migrationHolds as i, writeLatestMigration as l, writeExtensionsMigration as m, READ_SETS_SUFFIX as n, migrationModules as o, migrationStamp as p, latestMigration as r, renderModuleMigration as s, MODULES_SUFFIX as t, writesMigrations as u, providerOwnsMemberships as v, moduleKeyProblems as w, accessRequirements as x, compiledReadSets as y };
|
|
413
|
+
export { unsafeKey as _, writeExtensionsMigration as a, layoutFor as c, accessProviderMode as d, accessRequirements as f, providerLabel as g, moduleKeyProblems as h, stampAfter as i, providerOwnsMemberships as l, entitlementsMode as m, dataMigration as n, MEMBERSHIP_CLAIM_MODULES as o, entitlementRequirements as p, migrationStamp as r, layout as s, DATA_NEXT as t, compiledReadSets as u };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { i as stampAfter } from "./migrations-BoIyGczt.js";
|
|
2
|
+
import { d as readSupabaseToml, p as sqlWorkflow } from "./supabase-toml-CncmQbO0.js";
|
|
3
|
+
import { i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
|
|
4
|
+
import { a as sqlPlan, n as migrationsDir } from "./sql-layout-D8QrNvt4.js";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
7
|
+
import { moduleSchemaExtensions } from "better-supabase/sql";
|
|
8
|
+
//#region src/cli/sql/module-migration.ts
|
|
9
|
+
/** The migration the migrations workflow writes the SQL modules into. */
|
|
10
|
+
const MODULES_SUFFIX = "_better_supabase_modules.sql";
|
|
11
|
+
/**
|
|
12
|
+
* The migration `gen` writes the read-sets module into under the migrations
|
|
13
|
+
* workflow.
|
|
14
|
+
*/
|
|
15
|
+
const READ_SETS_SUFFIX = "_better_supabase_read_sets.sql";
|
|
16
|
+
const UPGRADE_START = "-- @bsb-upgrade-start";
|
|
17
|
+
const UPGRADE_END = "-- @bsb-upgrade-end";
|
|
18
|
+
/**
|
|
19
|
+
* Whether the project runs the migrations workflow, with no declarative
|
|
20
|
+
* schemas.
|
|
21
|
+
*/
|
|
22
|
+
async function writesMigrations(config) {
|
|
23
|
+
return sqlWorkflow(config, await readSupabaseToml(config.root)) === "migrations";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* One migration that holds, in order, the extensions, the upgrade steps, each
|
|
27
|
+
* module's schema body with its `@bsb-block` header, the realtime topic
|
|
28
|
+
* policies and the data statements. Every statement is re-runnable, so a later
|
|
29
|
+
* migration carries all of them, not only the changes.
|
|
30
|
+
*/
|
|
31
|
+
function renderModuleMigration(parts) {
|
|
32
|
+
const schema = parts.files.filter((file) => file.kind === "schema");
|
|
33
|
+
const data = parts.files.filter((file) => file.kind === "data");
|
|
34
|
+
const modules = [...new Set(schema.map((file) => file.instance ?? file.module))];
|
|
35
|
+
const extensions = moduleSchemaExtensions(parts.files);
|
|
36
|
+
const upgrade = parts.upgrade ?? [];
|
|
37
|
+
return `${[
|
|
38
|
+
[
|
|
39
|
+
`-- better-supabase sql: ${modules.length > 0 ? `the SQL modules ${modules.join(", ")}` : "the realtime topic policies"}, in one migration (database.sql.workflow: 'migrations').`,
|
|
40
|
+
"-- Managed by `better-supabase add` and `better-supabase upgrade`, which write a new migration when they change.",
|
|
41
|
+
"-- Change them through `blocks` in better-supabase.config.ts and the module's SQL hooks."
|
|
42
|
+
].join("\n"),
|
|
43
|
+
...extensions.length > 0 ? [extensions.map((extension) => extension.statement).join("\n")] : [],
|
|
44
|
+
...upgrade.length > 0 ? [[
|
|
45
|
+
UPGRADE_START,
|
|
46
|
+
...upgrade,
|
|
47
|
+
UPGRADE_END
|
|
48
|
+
].join("\n\n")] : [],
|
|
49
|
+
...schema.map((file) => file.contents.trim()),
|
|
50
|
+
...parts.topics === void 0 ? [] : [parts.topics.trim()],
|
|
51
|
+
...data.map((file) => file.contents.trim())
|
|
52
|
+
].join("\n\n")}\n`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The migration without its upgrade steps and package versions, which a later
|
|
56
|
+
* one doesn't repeat.
|
|
57
|
+
*/
|
|
58
|
+
function comparable(text) {
|
|
59
|
+
return text.replaceAll("\r\n", "\n").replace(/\n\n-- @bsb?-upgrade-start\n[\s\S]*?\n-- @bsb?-upgrade-end/, "").replaceAll(/^(-- better-supabase module: [^\n(]*?)(?: \([^)]*\))?$/gm, "$1");
|
|
60
|
+
}
|
|
61
|
+
/** Whether two module migrations hold the same modules. */
|
|
62
|
+
const sameModuleMigration = (current, expected) => current !== void 0 && comparable(current) === comparable(expected);
|
|
63
|
+
/** Whether a module migration holds `contents` (one module's file) unchanged. */
|
|
64
|
+
const migrationHolds = (text, contents) => comparable(text).includes(comparable(contents.trim()));
|
|
65
|
+
/** The newest migration that ends in `suffix`, with its text. */
|
|
66
|
+
async function latestMigration(config, suffix) {
|
|
67
|
+
const dir = migrationsDir(config);
|
|
68
|
+
const latest = (await readdir(resolve(config.root, dir)).catch(() => [])).toSorted().findLast((name) => name.endsWith(suffix));
|
|
69
|
+
if (latest === void 0) return;
|
|
70
|
+
return {
|
|
71
|
+
path: `${dir}/${latest}`,
|
|
72
|
+
text: await readFile(resolve(config.root, dir, latest), "utf-8")
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const MODULE_MARKERS = /^-- @(?:bsb-block|bs-module) ([a-zA-Z0-9-]+)@(\d+)(?: [a-z]+(?: ([a-z0-9-]+))?)?$/gm;
|
|
76
|
+
/**
|
|
77
|
+
* The modules and versions a module migration installs, from its `@bsb-block`
|
|
78
|
+
* lines.
|
|
79
|
+
*/
|
|
80
|
+
function migrationModules(text) {
|
|
81
|
+
return new Map([...text.matchAll(MODULE_MARKERS)].map((match) => [match[1], Number(match[2])]));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The instances a module migration installs under another name than their
|
|
85
|
+
* block, each to its block.
|
|
86
|
+
*/
|
|
87
|
+
function migrationInstances(text) {
|
|
88
|
+
return new Map([...text.matchAll(MODULE_MARKERS)].flatMap((match) => match[3] === void 0 ? [] : [[match[1], match[3]]]));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Writes `contents` as a new migration ending in `suffix`, unless the newest
|
|
92
|
+
* one already holds the same statements. `force` writes it anyway, for upgrade
|
|
93
|
+
* steps that have to run once.
|
|
94
|
+
*/
|
|
95
|
+
async function writeLatestMigration(config, suffix, contents, options) {
|
|
96
|
+
const latest = await latestMigration(config, suffix);
|
|
97
|
+
if (options.force !== true && latest !== void 0 && sameModuleMigration(latest.text, contents)) return {
|
|
98
|
+
path: latest.path,
|
|
99
|
+
wrote: false,
|
|
100
|
+
line: `Unchanged ${latest.path} (it has these statements)`
|
|
101
|
+
};
|
|
102
|
+
const dir = migrationsDir(config);
|
|
103
|
+
const names = await readdir(resolve(config.root, dir)).catch(() => []);
|
|
104
|
+
const path = `${dir}/${stampAfter(names, options.now)}${suffix}`;
|
|
105
|
+
const applied = await applyPlan(sqlPlan(config, {
|
|
106
|
+
regenerate: "better-supabase upgrade",
|
|
107
|
+
files: [{
|
|
108
|
+
path,
|
|
109
|
+
contents
|
|
110
|
+
}]
|
|
111
|
+
}), { "dry-run": options.dryRun });
|
|
112
|
+
return {
|
|
113
|
+
path,
|
|
114
|
+
wrote: applied.mode === "write",
|
|
115
|
+
line: changeLines(applied).join("\n")
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { migrationInstances as a, sameModuleMigration as c, migrationHolds as i, writeLatestMigration as l, READ_SETS_SUFFIX as n, migrationModules as o, latestMigration as r, renderModuleMigration as s, MODULES_SUFFIX as t, writesMigrations as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as CliError } from "./errors-BTe6A15O.js";
|
|
2
|
-
import { s as positionalIndex } from "./parse-
|
|
2
|
+
import { s as positionalIndex } from "./parse-B079x40m.js";
|
|
3
3
|
//#region src/cli/core/moved.ts
|
|
4
4
|
const API_REPLACEMENT = "defineApi includes every table and block instance, and createOrpc(betterSupabase).router(api) serves it: https://bettersupabase.com/docs/frameworks/orpc#serve-the-api";
|
|
5
5
|
/** Commands removed in 0.15, with what replaces them, longest path first. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as __toESM } from "./rolldown-runtime-kJ_i4yPo.js";
|
|
2
|
-
import { t as GLOBAL_ARGS } from "./command-
|
|
2
|
+
import { t as GLOBAL_ARGS } from "./command-BWEEXmtz.js";
|
|
3
3
|
import { n as CliError } from "./errors-BTe6A15O.js";
|
|
4
4
|
//#region src/cli/core/parse.ts
|
|
5
5
|
/**
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { p as commandMeta, r as defineCliCommand } from "./command-BWEEXmtz.js";
|
|
2
|
+
import { c as layoutFor, i as stampAfter } from "./migrations-BoIyGczt.js";
|
|
3
|
+
import { n as PLAN_ARGS, r as applyPlan, u as planResult } from "./files-CX71yBm8.js";
|
|
4
|
+
import { n as migrationsDir } from "./sql-layout-D8QrNvt4.js";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { join, resolve } from "node:path";
|
|
7
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
8
|
+
import { declaredColumnTypes, renderBlocks } from "better-supabase/sql";
|
|
9
|
+
import { SPEC_PINS } from "better-supabase";
|
|
10
|
+
//#region src/cli/powersync/streams.ts
|
|
11
|
+
/** The blocks `gen.powersync` can sync. */
|
|
12
|
+
const POWERSYNC_BLOCKS = ["notifications", "attachments"];
|
|
13
|
+
const isPowerSyncBlock = (value) => POWERSYNC_BLOCKS.some((block) => block === value);
|
|
14
|
+
const GENERATED = "@generated by better-supabase gen";
|
|
15
|
+
const SAFE_IDENT = /^[a-z_][a-z0-9_]*$/;
|
|
16
|
+
const ident = (name) => SAFE_IDENT.test(name) ? name : `"${name.replaceAll("\"", "\"\"")}"`;
|
|
17
|
+
const qualifiedIdent = (qualified) => {
|
|
18
|
+
const dot = qualified.indexOf(".");
|
|
19
|
+
return `${ident(qualified.slice(0, dot))}.${ident(qualified.slice(dot + 1))}`;
|
|
20
|
+
};
|
|
21
|
+
const baseName = (qualified) => qualified.slice(qualified.indexOf(".") + 1);
|
|
22
|
+
/** The PowerSync column type a Postgres type syncs as. */
|
|
23
|
+
function powersyncColumnType(type) {
|
|
24
|
+
const base = type.replace(/\[\]$/, "").replace(/\(.*\)$/, "");
|
|
25
|
+
if (/^(?:smallint|integer|int|int2|int4|int8|bigint|boolean|bool|smallserial|serial|bigserial)$/.test(base) && !type.endsWith("[]")) return "integer";
|
|
26
|
+
if (/^(?:real|double precision|float4|float8|numeric|decimal)$/.test(base) && !type.endsWith("[]")) return "real";
|
|
27
|
+
return "text";
|
|
28
|
+
}
|
|
29
|
+
const CREATE_TABLE = /create table (?:if not exists )?("(?:[^"]|"")+"|[a-z_][a-z0-9_$]*)\./gi;
|
|
30
|
+
const unquote = (name) => name.startsWith("\"") ? name.slice(1, -1).replaceAll("\"\"", "\"") : name;
|
|
31
|
+
function tablesOf(input, key) {
|
|
32
|
+
const files = input.files.flatMap((file) => file.kind === "schema" && (file.instance ?? file.module) === key ? [{ text: file.contents }] : []);
|
|
33
|
+
const schemas = new Set(files.flatMap(({ text }) => [...text.matchAll(CREATE_TABLE)].map((match) => unquote(match[1]))));
|
|
34
|
+
return declaredColumnTypes(files, [...schemas]);
|
|
35
|
+
}
|
|
36
|
+
/** The table of `tables` that has every one of `columns`. */
|
|
37
|
+
function tableWith(tables, columns, what) {
|
|
38
|
+
const found = [...tables].find(([, declared]) => columns.every((column) => declared.has(column)));
|
|
39
|
+
if (found === void 0) throw new Error(`gen.powersync: found no ${what} table`);
|
|
40
|
+
return found;
|
|
41
|
+
}
|
|
42
|
+
function notificationTables(input, instance) {
|
|
43
|
+
const tables = tablesOf(input, instance.key);
|
|
44
|
+
const [recipients, recipientColumns] = tableWith(tables, [
|
|
45
|
+
"event_id",
|
|
46
|
+
"user_id",
|
|
47
|
+
"read_at",
|
|
48
|
+
"dismissed_at"
|
|
49
|
+
], `${instance.key} recipients`);
|
|
50
|
+
const [events, eventColumns] = tableWith(tables, [
|
|
51
|
+
"type",
|
|
52
|
+
"idempotency_key",
|
|
53
|
+
"summary"
|
|
54
|
+
], `${instance.key} events`);
|
|
55
|
+
const mine = `${qualifiedIdent(recipients)} WHERE user_id = auth.user_id()`;
|
|
56
|
+
return [{
|
|
57
|
+
qualified: recipients,
|
|
58
|
+
name: baseName(recipients),
|
|
59
|
+
stream: `${instance.key}_recipients`,
|
|
60
|
+
query: `SELECT * FROM ${mine}`,
|
|
61
|
+
columns: recipientColumns
|
|
62
|
+
}, {
|
|
63
|
+
qualified: events,
|
|
64
|
+
name: baseName(events),
|
|
65
|
+
stream: `${instance.key}_events`,
|
|
66
|
+
query: `SELECT * FROM ${qualifiedIdent(events)} WHERE id IN (SELECT event_id FROM ${mine})`,
|
|
67
|
+
columns: eventColumns
|
|
68
|
+
}];
|
|
69
|
+
}
|
|
70
|
+
function attachmentTables(input, instance) {
|
|
71
|
+
const [attachments, columns] = tableWith(tablesOf(input, instance.key), [
|
|
72
|
+
"bucket",
|
|
73
|
+
"object_path",
|
|
74
|
+
"uploaded_by"
|
|
75
|
+
], `${instance.key} attachments`);
|
|
76
|
+
const memberships = [...tablesOf(input, "memberships")].find(([, declared]) => declared.has("user_id") && declared.has("role"));
|
|
77
|
+
if (memberships === void 0) throw new Error(`gen.powersync: ${instance.key} syncs the files of the user's organizations, which needs the memberships block`);
|
|
78
|
+
const [membershipTable, membershipColumns] = memberships;
|
|
79
|
+
const tenant = [...columns.keys()].find((column) => column.endsWith("_id") && column !== "user_id" && membershipColumns.has(column));
|
|
80
|
+
if (tenant === void 0) throw new Error(`gen.powersync: ${instance.key} and memberships share no organization column`);
|
|
81
|
+
return [{
|
|
82
|
+
qualified: attachments,
|
|
83
|
+
name: baseName(attachments),
|
|
84
|
+
stream: instance.key,
|
|
85
|
+
query: `SELECT * FROM ${qualifiedIdent(attachments)} WHERE ${ident(tenant)} IN (SELECT ${ident(tenant)} FROM ${qualifiedIdent(membershipTable)} WHERE user_id = auth.user_id())`,
|
|
86
|
+
columns
|
|
87
|
+
}];
|
|
88
|
+
}
|
|
89
|
+
function syncedTables(input, instance) {
|
|
90
|
+
switch (instance.block) {
|
|
91
|
+
case "notifications": return notificationTables(input, instance);
|
|
92
|
+
case "attachments": return attachmentTables(input, instance);
|
|
93
|
+
default: {
|
|
94
|
+
const unknown = instance.block;
|
|
95
|
+
throw new Error(`gen.powersync: ${String(unknown)} can't sync`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const yamlString = (text) => JSON.stringify(text);
|
|
100
|
+
function streamsYaml(tables) {
|
|
101
|
+
const streams = tables.flatMap((table) => [
|
|
102
|
+
` ${table.stream}:`,
|
|
103
|
+
" auto_subscribe: true",
|
|
104
|
+
` query: ${yamlString(table.query)}`
|
|
105
|
+
]);
|
|
106
|
+
return [
|
|
107
|
+
`# ${GENERATED}. Do not edit; run \`better-supabase gen\` instead.`,
|
|
108
|
+
"config:",
|
|
109
|
+
` edition: ${SPEC_PINS.powersyncSyncStreams}`,
|
|
110
|
+
"",
|
|
111
|
+
"streams:",
|
|
112
|
+
...streams,
|
|
113
|
+
""
|
|
114
|
+
].join("\n");
|
|
115
|
+
}
|
|
116
|
+
function publicationSql(tables) {
|
|
117
|
+
const names = tables.map((table) => `('${table.qualified.replaceAll("'", "''")}')`).join(", ");
|
|
118
|
+
return `-- ${GENERATED}: the block tables PowerSync replicates.
|
|
119
|
+
do $$
|
|
120
|
+
declare
|
|
121
|
+
t record;
|
|
122
|
+
begin
|
|
123
|
+
if not exists (select 1 from pg_publication where pubname = 'powersync') then
|
|
124
|
+
create publication powersync;
|
|
125
|
+
end if;
|
|
126
|
+
|
|
127
|
+
for t in
|
|
128
|
+
select n.nspname as schema_name, c.relname as table_name
|
|
129
|
+
from (values ${names}) as wanted (name)
|
|
130
|
+
join pg_class c on c.oid = wanted.name::regclass
|
|
131
|
+
join pg_namespace n on n.oid = c.relnamespace
|
|
132
|
+
where not exists (
|
|
133
|
+
select 1 from pg_publication_tables p
|
|
134
|
+
where p.pubname = 'powersync' and p.schemaname = n.nspname and p.tablename = c.relname
|
|
135
|
+
)
|
|
136
|
+
loop
|
|
137
|
+
execute format('alter publication powersync add table %I.%I', t.schema_name, t.table_name);
|
|
138
|
+
end loop;
|
|
139
|
+
end;
|
|
140
|
+
$$;
|
|
141
|
+
`;
|
|
142
|
+
}
|
|
143
|
+
const propertyName = (name) => /^[A-Za-z_$][\w$]*$/.test(name) ? name : JSON.stringify(name);
|
|
144
|
+
function schemaModule(tables, importFrom) {
|
|
145
|
+
const definitions = tables.map((table) => {
|
|
146
|
+
const columns = [...table.columns].filter(([column]) => column !== "id").map(([column, type]) => ` ${propertyName(column)}: column.${powersyncColumnType(type)},`);
|
|
147
|
+
return [
|
|
148
|
+
`export const ${table.name} = new Table({`,
|
|
149
|
+
...columns,
|
|
150
|
+
"});"
|
|
151
|
+
].join("\n");
|
|
152
|
+
});
|
|
153
|
+
return [
|
|
154
|
+
`// ${GENERATED}. Do not edit; run \`better-supabase gen\` instead.`,
|
|
155
|
+
"",
|
|
156
|
+
`import { column, Table } from ${JSON.stringify(importFrom)};`,
|
|
157
|
+
"",
|
|
158
|
+
...definitions.flatMap((definition) => [definition, ""]),
|
|
159
|
+
"/** The block tables, to spread into the app's `new Schema({ ... })`. */",
|
|
160
|
+
`export const blockTables = { ${tables.map((table) => table.name).join(", ")} };`,
|
|
161
|
+
""
|
|
162
|
+
].join("\n");
|
|
163
|
+
}
|
|
164
|
+
/** The sync streams, publication and PowerSync schema for `input.instances`. */
|
|
165
|
+
function powersyncOutput(input) {
|
|
166
|
+
const byInstance = input.instances.map((instance) => [instance.key, syncedTables(input, instance)]);
|
|
167
|
+
const tables = byInstance.flatMap(([, synced]) => synced);
|
|
168
|
+
return {
|
|
169
|
+
streams: streamsYaml(tables),
|
|
170
|
+
publication: publicationSql(tables),
|
|
171
|
+
schema: schemaModule(tables, input.importFrom),
|
|
172
|
+
tables: Object.fromEntries(byInstance.map(([key, synced]) => [key, synced.map(({ name }) => name)]))
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/cli/commands/powersync.ts
|
|
177
|
+
const ARGS = {
|
|
178
|
+
instance: {
|
|
179
|
+
type: "string",
|
|
180
|
+
description: "Block instances to sync, comma separated. Defaults to gen.powersync.instances",
|
|
181
|
+
valueHint: "keys"
|
|
182
|
+
},
|
|
183
|
+
out: {
|
|
184
|
+
type: "string",
|
|
185
|
+
description: "Folder for sync-streams.yaml and schema.ts. Defaults to gen.powersync.out, then powersync",
|
|
186
|
+
valueHint: "dir"
|
|
187
|
+
},
|
|
188
|
+
...PLAN_ARGS
|
|
189
|
+
};
|
|
190
|
+
const PUBLICATION_SUFFIX = "_powersync_publication.sql";
|
|
191
|
+
const REGENERATE = "better-supabase powersync streams";
|
|
192
|
+
function instancesOf(config, keys) {
|
|
193
|
+
const instances = [];
|
|
194
|
+
for (const key of keys) {
|
|
195
|
+
const block = config.instances[key]?.block;
|
|
196
|
+
if (block === void 0) return `${key} is not a block in the config.`;
|
|
197
|
+
if (!isPowerSyncBlock(block)) return `${key} installs ${block}, which can't sync yet. PowerSync syncs ${POWERSYNC_BLOCKS.join(" and ")}.`;
|
|
198
|
+
instances.push({
|
|
199
|
+
key,
|
|
200
|
+
block
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return instances;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The publication migration, unless the newest one already adds these tables: a
|
|
207
|
+
* pushed migration is never rewritten, so a change gets a new one.
|
|
208
|
+
*/
|
|
209
|
+
async function publicationMigration(config, sql, now) {
|
|
210
|
+
const dir = resolve(config.root, migrationsDir(config));
|
|
211
|
+
const names = existsSync(dir) ? (await readdir(dir)).toSorted() : [];
|
|
212
|
+
const latest = names.findLast((name) => name.endsWith(PUBLICATION_SUFFIX));
|
|
213
|
+
if (latest !== void 0 && await readFile(join(dir, latest), "utf-8") === sql) return;
|
|
214
|
+
return {
|
|
215
|
+
path: join(dir, `${stampAfter(names, now())}${PUBLICATION_SUFFIX}`),
|
|
216
|
+
contents: sql,
|
|
217
|
+
policy: "create",
|
|
218
|
+
note: "adds the tables to the powersync publication"
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Writes `sync-streams.yaml` and `schema.ts` for the synced block instances,
|
|
223
|
+
* and a migration that adds their tables to the `powersync` publication.
|
|
224
|
+
*/
|
|
225
|
+
async function runPowerSync(config, args, now = () => /* @__PURE__ */ new Date()) {
|
|
226
|
+
const settings = config.gen.powersync;
|
|
227
|
+
const keys = args.instance === void 0 ? settings?.instances ?? [] : args.instance.split(",").map((key) => key.trim()).filter(Boolean);
|
|
228
|
+
if (keys.length === 0) return {
|
|
229
|
+
code: 1,
|
|
230
|
+
errorCode: "config_invalid",
|
|
231
|
+
error: "Name the block instances to sync: set gen.powersync.instances, or pass --instance notifications."
|
|
232
|
+
};
|
|
233
|
+
const instances = instancesOf(config, keys);
|
|
234
|
+
if (typeof instances === "string") return {
|
|
235
|
+
code: 1,
|
|
236
|
+
errorCode: "config_invalid",
|
|
237
|
+
error: instances
|
|
238
|
+
};
|
|
239
|
+
const layout = await layoutFor(config, {}, config.blockNames);
|
|
240
|
+
let output;
|
|
241
|
+
try {
|
|
242
|
+
output = powersyncOutput({
|
|
243
|
+
files: renderBlocks(config.blockNames, layout),
|
|
244
|
+
instances,
|
|
245
|
+
importFrom: settings?.import ?? "@powersync/common"
|
|
246
|
+
});
|
|
247
|
+
} catch (cause) {
|
|
248
|
+
return {
|
|
249
|
+
code: 1,
|
|
250
|
+
errorCode: "config_invalid",
|
|
251
|
+
error: cause instanceof Error ? cause.message : String(cause)
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
const out = resolve(config.root, args.out ?? settings?.out ?? "powersync");
|
|
255
|
+
const migration = await publicationMigration(config, output.publication, now);
|
|
256
|
+
const plan = {
|
|
257
|
+
root: config.root,
|
|
258
|
+
regenerate: REGENERATE,
|
|
259
|
+
files: [
|
|
260
|
+
{
|
|
261
|
+
path: join(out, "sync-streams.yaml"),
|
|
262
|
+
contents: output.streams
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
path: join(out, "schema.ts"),
|
|
266
|
+
contents: output.schema
|
|
267
|
+
},
|
|
268
|
+
...migration === void 0 ? [] : [migration]
|
|
269
|
+
]
|
|
270
|
+
};
|
|
271
|
+
const applied = await applyPlan(plan, args);
|
|
272
|
+
return planResult(plan, applied, { data: {
|
|
273
|
+
instances: keys,
|
|
274
|
+
tables: output.tables
|
|
275
|
+
} });
|
|
276
|
+
}
|
|
277
|
+
const powersyncStreamsCommand = defineCliCommand({
|
|
278
|
+
meta: commandMeta("powersync streams"),
|
|
279
|
+
args: ARGS,
|
|
280
|
+
run: (args, { config }) => runPowerSync(config, args)
|
|
281
|
+
});
|
|
282
|
+
//#endregion
|
|
283
|
+
export { runPowerSync as n, powersyncStreamsCommand as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as powersyncStreamsCommand } from "./powersync-D-0yV_L_.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { n as CliError } from "./errors-BTe6A15O.js";
|
|
2
|
-
import {
|
|
2
|
+
import { s as layout } from "./migrations-BoIyGczt.js";
|
|
3
|
+
import { o as migrationModules, r as latestMigration, u as writesMigrations } from "./module-migration-DXvo0EqU.js";
|
|
3
4
|
import { existsSync } from "node:fs";
|
|
4
5
|
import { resolve } from "node:path";
|
|
5
6
|
import { SQL_MODULES, contractSignature, customContracts, moduleBody, moduleFilePaths } from "better-supabase/sql";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { p as commandMeta, r as defineCliCommand } from "./command-
|
|
1
|
+
import { p as commandMeta, r as defineCliCommand } from "./command-BWEEXmtz.js";
|
|
2
2
|
import { i as plain } from "./style-Bm2X5JrN.js";
|
|
3
3
|
import { n as CliError } from "./errors-BTe6A15O.js";
|
|
4
4
|
import { r as readIfExists, t as display } from "./io-DH1kcmmP.js";
|
|
5
|
-
import {
|
|
5
|
+
import { c as layoutFor } from "./migrations-BoIyGczt.js";
|
|
6
6
|
import { i as changeLines, n as PLAN_ARGS, r as applyPlan, t as HAND_EDITED, u as planResult } from "./files-CX71yBm8.js";
|
|
7
|
-
import { a as sqlPlan } from "./sql-layout-
|
|
8
|
-
import { g as templateContextFor, i as blocksWiringPath, n as blockClients } from "./add-
|
|
7
|
+
import { a as sqlPlan } from "./sql-layout-D8QrNvt4.js";
|
|
8
|
+
import { g as templateContextFor, i as blocksWiringPath, n as blockClients } from "./add-B1S3yK4L.js";
|
|
9
9
|
import { t as detectProject } from "./detect-D9JaAX20.js";
|
|
10
10
|
import { _ as wiringBlocks, a as configObject, c as mask, i as closingIndex, l as properties } from "./config-edit-CrWfk8s3.js";
|
|
11
|
-
import { n as guardedRemoval } from "./sync-
|
|
11
|
+
import { n as guardedRemoval } from "./sync-s1iKFIos.js";
|
|
12
12
|
import { t as SQL_ARGS } from "./args-UEwg0l-N.js";
|
|
13
|
-
import { t as blockNames } from "./blocks-
|
|
13
|
+
import { t as blockNames } from "./blocks-DDm1Zc2S.js";
|
|
14
14
|
import { i as tidyInline, t as cutRange } from "./config-group-C8tjut39.js";
|
|
15
15
|
import { existsSync } from "node:fs";
|
|
16
16
|
import { resolve } from "node:path";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
|
|
2
2
|
import { n as importPath } from "./io-DH1kcmmP.js";
|
|
3
|
-
import { i as cachedTypesModule, n as cachedDatabaseTypes, s as typesModuleKey } from "./cache-
|
|
3
|
+
import { i as cachedTypesModule, n as cachedDatabaseTypes, s as typesModuleKey } from "./cache-DE2IH1-C.js";
|
|
4
4
|
import { t as byCodePoint } from "./compare-BmIWVEui.js";
|
|
5
|
-
import { f as generateDatabaseTypes, h as restrictSchemas, p as oxfmtInstalled, v as tsTypeOf } from "./snapshot-
|
|
5
|
+
import { f as generateDatabaseTypes, h as restrictSchemas, p as oxfmtInstalled, v as tsTypeOf } from "./snapshot-BXmU3IXN.js";
|
|
6
6
|
import { t as isRecord$1 } from "./guards-CUlDNYZs.js";
|
|
7
|
-
import { a as toCatalog } from "./source-
|
|
7
|
+
import { a as toCatalog } from "./source-irttnsEb.js";
|
|
8
8
|
import { basename, dirname, isAbsolute, join, posix, relative, resolve } from "node:path";
|
|
9
9
|
import { entityNames } from "better-supabase/blocks";
|
|
10
10
|
import { DEFAULT_CLAIMS, blockEntities, blockEntityRenames, blockSubjectTypes, tenantClaimPaths, tenantNameOf } from "better-supabase/config";
|
|
@@ -1627,7 +1627,7 @@ function schemaExtensions(config) {
|
|
|
1627
1627
|
return [{
|
|
1628
1628
|
export: manifest.extension,
|
|
1629
1629
|
subpath: `blocks/${manifest.name}`,
|
|
1630
|
-
args: manifest.name === "memberships" ? tenantArgs : ""
|
|
1630
|
+
args: manifest.name === "memberships" ? tenantArgs : STAMPED.has(manifest.name) ? stampArgs(name, config.blocks?.[name]?.options?.["stamp"]) : ""
|
|
1631
1631
|
}];
|
|
1632
1632
|
});
|
|
1633
1633
|
if (tenant !== void 0 && !extensions.some((entry) => entry.subpath === "blocks/memberships")) extensions.push({
|
|
@@ -1637,6 +1637,12 @@ function schemaExtensions(config) {
|
|
|
1637
1637
|
});
|
|
1638
1638
|
return extensions;
|
|
1639
1639
|
}
|
|
1640
|
+
const STAMPED = /* @__PURE__ */ new Set(["created-by", "updated-at"]);
|
|
1641
|
+
function stampArgs(name, stamp) {
|
|
1642
|
+
if (stamp === void 0 || stamp === "client") return "";
|
|
1643
|
+
if (stamp === "trigger") return "{ stamp: \"trigger\" }";
|
|
1644
|
+
throw new TypeError(`blocks.${name}.options.stamp must be "client" or "trigger", got ${JSON.stringify(stamp)}`);
|
|
1645
|
+
}
|
|
1640
1646
|
/** The installed blocks with their final names, for `GeneratorModel.blocks`. */
|
|
1641
1647
|
function generatorBlocks(config) {
|
|
1642
1648
|
return Object.entries(blockConfigEntries(config)).filter(([, entry]) => entry.block === void 0).map(([name, entry]) => {
|
|
@@ -1721,13 +1727,14 @@ function renamedBlockLines(entries) {
|
|
|
1721
1727
|
* `defineBlocks(blockConfig, blocks)`. A renamed instance uses its renamed
|
|
1722
1728
|
* constant; the others import their block.
|
|
1723
1729
|
*/
|
|
1724
|
-
function instanceMapLines(entries, renamed) {
|
|
1730
|
+
function instanceMapLines(entries, renamed, synced) {
|
|
1725
1731
|
const imported = /* @__PURE__ */ new Map();
|
|
1726
1732
|
const members = [];
|
|
1727
1733
|
for (const [instance, entry] of Object.entries(entries)) {
|
|
1728
1734
|
const manifest = MANIFESTS.get(entry.block ?? instance);
|
|
1729
1735
|
const client = manifest?.client;
|
|
1730
1736
|
if (manifest === void 0 || client === void 0 || client === null) continue;
|
|
1737
|
+
if (synced !== void 0 && !synced.has(instance)) members.push(" /** Needs the network on native. */");
|
|
1731
1738
|
const constant = renamed.get(instance);
|
|
1732
1739
|
if (constant !== void 0) {
|
|
1733
1740
|
members.push(` ${prop(instance)}: ${constant},`);
|
|
@@ -1754,6 +1761,7 @@ function instanceMapLines(entries, renamed) {
|
|
|
1754
1761
|
" * Every installed block instance with a client, under its key, for",
|
|
1755
1762
|
" * `defineBlocks(blockConfig, { ...blocks, ... })`. Override an entry to give",
|
|
1756
1763
|
" * a block its ports (`notifications: notificationsBlock.using(...)`).",
|
|
1764
|
+
...synced === void 0 ? [] : [" * Instances outside `gen.powersync.instances` call the Data API, so", " * their hooks need the network on native."],
|
|
1757
1765
|
" * @public",
|
|
1758
1766
|
" */",
|
|
1759
1767
|
"export const blocks = {",
|
|
@@ -1807,7 +1815,8 @@ function emitBlockConfig(config, options = {}) {
|
|
|
1807
1815
|
const runtime = options.runtimeImport ?? "better-supabase";
|
|
1808
1816
|
const renamed = renamedBlockLines(entries);
|
|
1809
1817
|
const constants = nameConstantLines(config, entries);
|
|
1810
|
-
const
|
|
1818
|
+
const synced = config.gen.powersync?.instances;
|
|
1819
|
+
const instances = instanceMapLines(entries, renamed.constants, synced === void 0 ? void 0 : new Set(synced));
|
|
1811
1820
|
const specifiers = [
|
|
1812
1821
|
...events.length === 0 ? [] : [
|
|
1813
1822
|
"type AppTableEventData",
|