better-supabase 0.45.0 → 0.46.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-BHat-brX.js → access-sql-8In-gFRf.js} +15 -2
- package/dist/{adapter-C0C4jIwI.js → adapter-t7V4k_rU.js} +10 -7
- package/dist/{agents-DxhGxwDS.d.ts → agents-D81UAnah.d.ts} +1 -1
- package/dist/{ai-chat-LHWztFya.d.ts → ai-chat-BBJvSano.d.ts} +1 -1
- package/dist/{ai-schedules-BP0PBKhY.d.ts → ai-schedules-D9mYwQdO.d.ts} +5 -2
- package/dist/ai-sdk/agents/index.d.ts +6 -6
- package/dist/ai-sdk/batches/index.d.ts +1 -1
- package/dist/ai-sdk/chat/index.d.ts +2 -2
- package/dist/ai-sdk/embeddings/index.d.ts +2 -2
- package/dist/ai-sdk/index.d.ts +2 -2
- package/dist/ai-sdk/mcp/index.d.ts +3 -3
- package/dist/ai-sdk/memory/index.d.ts +2 -2
- package/dist/ai-sdk/memory/index.js +1 -1
- package/dist/ai-sdk/workflow/index.d.ts +3 -3
- package/dist/{api-CgO8Gin7.d.ts → api-Bxhw2FD2.d.ts} +4 -4
- package/dist/{api-DXCaMM2S.js → api-DzqXnR6X.js} +1 -1
- package/dist/{api-keys-DINjcAaY.d.ts → api-keys-ClEIzcc3.d.ts} +1 -1
- package/dist/{app-tables-Dg9lERHb.d.ts → app-tables-HqT8E90s.d.ts} +1 -1
- package/dist/{approvals-CoBe9E2b.d.ts → approvals-lmHzZSgF.d.ts} +1 -1
- package/dist/{assistant-DMaZZFps.d.ts → assistant-ewdCgSQn.d.ts} +2 -2
- package/dist/astro/index.d.ts +5 -5
- package/dist/astro/index.js +4 -4
- package/dist/{authorization-CcWVJSsN.d.ts → authorization-CFs44tM2.d.ts} +145 -19
- package/dist/{authorization-hooks-u2Z18CAM.d.ts → authorization-hooks-yUgoV4Q7.d.ts} +1 -1
- package/dist/better-result/index.d.ts +2 -2
- package/dist/{bind-BieIoT6r.d.ts → bind-CUxWEh27.d.ts} +4 -4
- package/dist/{block-env-YzSHv579.d.ts → block-env-DddTzDut.d.ts} +4 -4
- package/dist/{block-subjects-CTIsFATg.js → block-subjects-y1RNnlLz.js} +1 -1
- package/dist/{block-tables-D-UjSTXa.d.ts → block-tables-BNwRNU_D.d.ts} +1 -1
- package/dist/blocks/access-requests/index.d.ts +2 -2
- package/dist/blocks/activities/index.d.ts +3 -3
- package/dist/blocks/agents/index.d.ts +3 -3
- package/dist/blocks/ai-cache/index.d.ts +1 -1
- package/dist/blocks/ai-chat/index.d.ts +6 -6
- package/dist/blocks/ai-files/index.d.ts +1 -1
- package/dist/blocks/ai-keys/index.d.ts +3 -3
- package/dist/blocks/ai-schedules/index.d.ts +2 -2
- package/dist/blocks/announcements/index.d.ts +5 -5
- package/dist/blocks/api-keys/index.d.ts +2 -2
- package/dist/blocks/approvals/index.d.ts +3 -3
- package/dist/blocks/assets/index.d.ts +2 -2
- package/dist/blocks/assignment/index.d.ts +3 -3
- package/dist/blocks/attachments/index.d.ts +46 -4
- package/dist/blocks/attachments/index.js +55 -3
- package/dist/blocks/audit/index.d.ts +7 -7
- package/dist/blocks/audit/index.js +1 -1
- package/dist/blocks/automations/index.d.ts +18 -16
- package/dist/blocks/billable-time/index.d.ts +2 -2
- package/dist/blocks/billing/index.d.ts +5 -5
- package/dist/blocks/bookings/index.d.ts +3 -3
- package/dist/blocks/bulk/index.d.ts +2 -2
- package/dist/blocks/calendar/index.d.ts +3 -3
- package/dist/blocks/catalog/index.d.ts +2 -2
- package/dist/blocks/channels/index.d.ts +3 -3
- package/dist/blocks/collections/index.d.ts +3 -3
- package/dist/blocks/comments/index.d.ts +5 -5
- package/dist/blocks/compliance/index.d.ts +11 -11
- package/dist/blocks/connectors/index.d.ts +3 -3
- package/dist/blocks/contacts/index.d.ts +4 -4
- package/dist/blocks/content/index.d.ts +2 -2
- package/dist/blocks/contracts/index.d.ts +2 -2
- package/dist/blocks/courses/index.d.ts +2 -2
- package/dist/blocks/created-by/index.d.ts +1 -1
- package/dist/blocks/custom-fields/index.d.ts +2 -2
- package/dist/blocks/data-lifecycle/index.d.ts +25 -8
- package/dist/blocks/data-lifecycle/index.js +16 -2
- package/dist/blocks/deals/index.d.ts +3 -3
- package/dist/blocks/dispatch/index.d.ts +2 -2
- package/dist/blocks/documents/index.d.ts +2 -2
- package/dist/blocks/domains/index.d.ts +2 -2
- package/dist/blocks/donations/index.d.ts +2 -2
- package/dist/blocks/drive/index.d.ts +221 -8
- package/dist/blocks/drive/index.js +269 -19
- package/dist/blocks/employees/index.d.ts +4 -4
- package/dist/blocks/enrichment/index.d.ts +3 -3
- package/dist/blocks/enrollments/index.d.ts +2 -2
- package/dist/blocks/entitlements/index.d.ts +3 -3
- package/dist/blocks/expenses/index.d.ts +2 -2
- package/dist/blocks/field-history/index.d.ts +3 -3
- package/dist/blocks/flags/index.d.ts +2 -2
- package/dist/blocks/forecasts/index.d.ts +3 -3
- package/dist/blocks/forms/index.d.ts +3 -3
- package/dist/blocks/goals/index.d.ts +1 -1
- package/dist/blocks/guests/index.d.ts +2 -2
- package/dist/blocks/hiring/index.d.ts +3 -3
- package/dist/blocks/identities/index.d.ts +2 -2
- package/dist/blocks/imports/index.d.ts +2 -2
- package/dist/blocks/inbox/index.d.ts +6 -6
- package/dist/blocks/incidents/index.d.ts +2 -2
- package/dist/blocks/index.d.ts +155 -5
- package/dist/blocks/index.js +19 -1
- package/dist/blocks/inventory/index.d.ts +2 -2
- package/dist/blocks/invoices/index.d.ts +4 -3
- package/dist/blocks/invoices/index.js +3 -2
- package/dist/blocks/knowledge/index.d.ts +3 -3
- package/dist/blocks/knowledge/index.js +1 -1
- package/dist/blocks/lead-scoring/index.d.ts +1 -1
- package/dist/blocks/leases/index.d.ts +2 -2
- package/dist/blocks/leave/index.d.ts +2 -2
- package/dist/blocks/ledger/index.d.ts +2 -2
- package/dist/blocks/mail-sync/index.d.ts +3 -3
- package/dist/blocks/memberships/index.d.ts +1 -1
- package/dist/blocks/memory/index.d.ts +3 -3
- package/dist/blocks/memory/index.js +1 -1
- package/dist/blocks/messaging/index.d.ts +7 -7
- package/dist/blocks/metrics/index.d.ts +2 -2
- package/dist/blocks/mfa/index.d.ts +2 -2
- package/dist/blocks/moderation/index.d.ts +2 -2
- package/dist/blocks/notifications/index.d.ts +13 -9
- package/dist/blocks/notifications/index.js +2 -0
- package/dist/blocks/numbering/index.d.ts +2 -2
- package/dist/blocks/oauth-server/index.d.ts +2 -2
- package/dist/blocks/onboarding/index.d.ts +2 -2
- package/dist/blocks/orders/index.d.ts +3 -3
- package/dist/blocks/organizations/index.d.ts +4 -4
- package/dist/blocks/outbox/index.d.ts +2 -2
- package/dist/blocks/passes/index.d.ts +2 -2
- package/dist/blocks/permissions/index.d.ts +5 -4
- package/dist/blocks/permissions/index.js +3 -2
- package/dist/blocks/pipelines/index.d.ts +3 -3
- package/dist/blocks/posts/index.d.ts +2 -2
- package/dist/blocks/profiles/index.d.ts +1 -1
- package/dist/blocks/promotions/index.d.ts +2 -2
- package/dist/blocks/push/index.d.ts +4 -4
- package/dist/blocks/qualifications/index.d.ts +256 -0
- package/dist/blocks/qualifications/index.js +303 -0
- package/dist/blocks/queue/index.d.ts +8 -103
- package/dist/blocks/queue/index.js +9 -3
- package/dist/blocks/quotes/index.d.ts +3 -3
- package/dist/blocks/rank/index.d.ts +1 -1
- package/dist/blocks/reactions/index.d.ts +5 -5
- package/dist/blocks/relations/index.d.ts +2 -2
- package/dist/blocks/reminders/index.d.ts +3 -3
- package/dist/blocks/reviews/index.d.ts +2 -2
- package/dist/blocks/risks/index.d.ts +303 -0
- package/dist/blocks/risks/index.js +376 -0
- package/dist/blocks/saved-views/index.d.ts +6 -6
- package/dist/blocks/scores/index.d.ts +2 -2
- package/dist/blocks/search/index.d.ts +4 -4
- package/dist/blocks/security-events/index.d.ts +3 -3
- package/dist/blocks/segments/index.d.ts +4 -4
- package/dist/blocks/sequences/index.d.ts +2 -2
- package/dist/blocks/service-accounts/index.d.ts +3 -3
- package/dist/blocks/sessions/index.d.ts +2 -2
- package/dist/blocks/settings/index.d.ts +3 -3
- package/dist/blocks/share-links/index.d.ts +29 -4
- package/dist/blocks/share-links/index.js +37 -4
- package/dist/blocks/shifts/index.d.ts +334 -0
- package/dist/blocks/shifts/index.js +451 -0
- package/dist/blocks/shipments/index.d.ts +3 -3
- package/dist/blocks/signatures/index.d.ts +2 -2
- package/dist/blocks/signing-keys/index.d.ts +2 -2
- package/dist/blocks/sla/index.d.ts +3 -3
- package/dist/blocks/sso/index.d.ts +3 -3
- package/dist/blocks/state-machine/index.d.ts +2 -2
- package/dist/blocks/subjects/index.d.ts +13 -5
- package/dist/blocks/subjects/index.js +114 -5
- package/dist/blocks/tags/index.d.ts +3 -3
- package/dist/blocks/tasks/index.d.ts +5 -5
- package/dist/blocks/teams/index.d.ts +2 -2
- package/dist/blocks/templates/index.d.ts +5 -5
- package/dist/blocks/time-tracking/index.d.ts +3 -3
- package/dist/blocks/timeline/index.d.ts +6 -6
- package/dist/blocks/timeline/index.js +1 -1
- package/dist/blocks/trash/index.d.ts +2 -2
- package/dist/blocks/undo/index.d.ts +2 -2
- package/dist/blocks/updated-at/index.d.ts +1 -1
- package/dist/blocks/usage/index.d.ts +2 -2
- package/dist/blocks/vercel-marketplace/index.d.ts +2 -2
- package/dist/blocks/versions/index.d.ts +2 -2
- package/dist/blocks/waitlist/index.d.ts +2 -2
- package/dist/blocks/webhooks/index.d.ts +6 -6
- package/dist/blocks/webhooks/index.js +2 -1
- package/dist/blocks/workflow-editor/index.d.ts +8 -8
- package/dist/blocks/workflow-editor/index.js +1 -1
- package/dist/blocks/workflows/index.d.ts +6 -6
- package/dist/{cache-tags-DrywUP3I.d.ts → cache-tags-DDWP8yDs.d.ts} +2 -2
- package/dist/{channel-B_kufDZy.d.ts → channel-DW9iIWgu.d.ts} +3 -1
- package/dist/chat-sdk/index.d.ts +2 -2
- package/dist/claims/index.d.ts +5 -5
- package/dist/claims/index.js +1 -1
- package/dist/cli/{add-DcLNy2oN.js → add-B6TTIKos.js} +23 -5
- package/dist/cli/{add-B5Gq34wX.js → add-CYH9OE6d.js} +13 -13
- package/dist/cli/add-DsgNHrEH.js +1 -0
- package/dist/cli/{app-table-files-CcGWy0qX.js → app-table-files-Br1VQgjE.js} +3 -3
- package/dist/cli/{app-tables-RbPMD2M3.js → app-tables-FRO1l5rT.js} +2 -2
- package/dist/cli/{backfill-BJterqcQ.js → backfill-BgGBBidH.js} +4 -4
- package/dist/cli/bin.js +1 -1
- package/dist/cli/{blocks-DsAwI_4v.js → blocks-CX_172Ja.js} +1 -1
- package/dist/cli/{blocks-BBALfFv-.js → blocks-DZrlz-13.js} +2 -2
- package/dist/cli/{cache-DRb1xVPh.js → cache-BgiLj67N.js} +1 -1
- package/dist/cli/{codemod-Cpd4DnrL.js → codemod-C86T5p1T.js} +97 -13
- package/dist/cli/{command-67WobzTC.js → command-DtQ7P9XP.js} +6 -0
- package/dist/cli/{completion-C3nMZgUZ.js → completion-9tK4vX1l.js} +2 -2
- package/dist/cli/{completion-Dm0S3ub0.js → completion-DUnYq3GC.js} +2 -2
- package/dist/cli/{completion-DSrus7H1.js → completion-djG61QR0.js} +1 -1
- package/dist/cli/{config-CGVmcEZa.js → config-05wlBDsJ.js} +1 -1
- package/dist/cli/{config-Dy-BAGel.js → config-Cb4swJ2X.js} +32 -10
- package/dist/cli/{config-cbK-wiNs.js → config-CwcsseeT.js} +1 -1
- package/dist/cli/{content-mapper-D0riSMnP.js → content-mapper-DIO-tycM.js} +2 -2
- package/dist/cli/{db-BCVXzXDA.js → db-BND9MSu1.js} +3 -3
- package/dist/cli/{doctor-CHmX2gau.js → doctor-BqS2dAI-.js} +98 -21
- package/dist/cli/{env-CCT-dMFm.js → env-2zOK0skq.js} +1 -1
- package/dist/cli/env-NHlaYmXG.js +1 -0
- package/dist/cli/{gen-DB0svRc8.js → gen-CygGjwk4.js} +16 -16
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +8 -8
- package/dist/cli/{init-B4fQNe4C.js → init-BMDuL671.js} +10 -10
- package/dist/cli/{keys-Dj5sJNj7.js → keys-BUl10CEQ.js} +1 -1
- package/dist/cli/{live-Bft5EE70.js → live-BRhu6mk8.js} +2 -2
- package/dist/cli/{mcp-BKcS-LZw.js → mcp-DzfSUgqc.js} +3 -3
- package/dist/cli/{metadata-CgKNmMsc.js → metadata-Ao_uwhbL.js} +3 -3
- package/dist/cli/{migrate-ehxT23Gg.js → migrate-BySeyvYY.js} +2 -2
- package/dist/cli/{migration-safety-D2gG-dDs.js → migration-safety-CtSYqXjZ.js} +2 -2
- package/dist/cli/{migrations-CQ1Sgz_X.js → migrations-Cnf7TlYZ.js} +2 -2
- package/dist/cli/{module-migration-BOPJUkIX.js → module-migration-CKKOcrG0.js} +2 -2
- package/dist/cli/{moved-CY0yDtAr.js → moved-QZ-btdFz.js} +1 -1
- package/dist/cli/{parse-yAC-NFMq.js → parse-Bd_CRjbn.js} +1 -1
- package/dist/cli/{powersync-BTari5WF.js → powersync-BeeW0i26.js} +168 -67
- package/dist/cli/powersync-miOelRmt.js +1 -0
- package/dist/cli/{print-BMJnlJ8k.js → print-Sdb6L0v4.js} +2 -2
- package/dist/cli/{providers-BNZ-OqMI.js → providers-BlkYmOf-.js} +1 -1
- package/dist/cli/{prune-workflows-BG55npqs.js → prune-workflows-iRTaOxbs.js} +4 -4
- package/dist/cli/{remove-BIqGDE0A.js → remove-DvzSG08w.js} +6 -6
- package/dist/cli/{render-BIC4Wctz.js → render-svtBPq7R.js} +118 -18
- package/dist/cli/{run-C_slJx8m.js → run-BHhVGtd_.js} +46 -45
- package/dist/cli/{run-BJ4_rmHy.js → run-CnafzCVh.js} +14 -14
- package/dist/cli/{run-DX4X7xqV.js → run-WD6LyrAZ.js} +2 -2
- package/dist/cli/{seed-0r_0aD8_.js → seed-Bc_q0nFf.js} +12 -4
- package/dist/cli/seed-DT_k-CGR.js +1 -0
- package/dist/cli/{shared-DhpBDjRa.js → shared-By7_hqFX.js} +1 -1
- package/dist/cli/{skills-B5p6bDwe.js → skills-CvEA4xdj.js} +1 -1
- package/dist/cli/{snapshot-CMJksw-t.js → snapshot-T8fVRXqA.js} +3 -3
- package/dist/cli/{source-args-CgCX8KUJ.js → source-args-BiySywDB.js} +1 -1
- package/dist/cli/{source-CJilfcq-.js → source-xL7qYX0r.js} +1 -1
- package/dist/cli/{spec-CnjHA0br.js → spec-BH7BDCnA.js} +1 -1
- package/dist/cli/{spec-Br9cWMbU.js → spec-CU_OO1Gq.js} +3 -3
- package/dist/cli/{sql-layout-BCiEl_G5.js → sql-layout-C_-LNpAw.js} +2 -2
- package/dist/cli/{stack-CQXLe5j0.js → stack-DM3keIfh.js} +1 -1
- package/dist/cli/{sync-Bulv1zyy.js → sync-Bl4Kf4_T.js} +4 -4
- package/dist/cli/{table-BAR0cLmU.js → table-DocogEpr.js} +1 -1
- package/dist/cli/{upgrade-DTBvTAAV.js → upgrade-BLi83wT-.js} +5 -5
- package/dist/cli/{upgrade-C8fiTE3r.js → upgrade-kce809Am.js} +3 -3
- package/dist/cli/{version-hhuwVLKj.js → version-D8HDt2fH.js} +1 -1
- package/dist/client/index.d.ts +7 -6
- package/dist/client/index.js +2 -1
- package/dist/client/native/index.d.ts +6 -5
- package/dist/client/native/index.js +2 -1
- package/dist/{cloud-event-LTUGgt6D.d.ts → cloud-event-Dxy5EZVG.d.ts} +1 -1
- package/dist/commerce/index.d.ts +1 -1
- package/dist/{composite-BCUNxZCd.d.ts → composite-DNDFvcQc.d.ts} +6 -6
- package/dist/{composite-C3lLpMys.js → composite-c7POXFs3.js} +2 -2
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.js +4 -4
- package/dist/{config-HOXkrND2.js → config--zZjnkYA.js} +1 -1
- package/dist/{config-DA_R9O_y.js → config-CAbv8kRz.js} +21 -8
- package/dist/{connectors-DTxDzUzD.d.ts → connectors-BQtx-Llh.d.ts} +1 -1
- package/dist/{context-BJK9_ppk.d.ts → context-Lhw7PgdA.d.ts} +52 -8
- package/dist/contract/index.d.ts +8 -8
- package/dist/{controller-TplPQG5m.d.ts → controller-CouRuczb.d.ts} +1 -1
- package/dist/{controller-y1kSMuCU.js → controller-DxzV9X72.js} +1 -1
- package/dist/{conversion-DwDBNeWT.d.ts → conversion-G2ODS617.d.ts} +1 -1
- package/dist/create/index.d.ts +3 -3
- package/dist/create/index.js +3 -3
- package/dist/create/lite/index.d.ts +3 -3
- package/dist/create/lite/index.js +3 -3
- package/dist/credentials/index.d.ts +3 -3
- package/dist/{data-hooks-BToeAcQ_.js → data-hooks-DDEPFoWv.js} +44 -3
- package/dist/{define-DXQHQ2Qy.d.ts → db-blocks-Dgu-HpFb.d.ts} +296 -296
- package/dist/{define-block-tFQZ8936.d.ts → define-block-eiBbZ3mM.d.ts} +357 -357
- package/dist/{delegation-C2rLpkHO.js → delegation-C0EQp3ss.js} +1 -1
- package/dist/edge/index.d.ts +8 -8
- package/dist/edge/index.js +6 -6
- package/dist/elysia/index.d.ts +1 -1
- package/dist/elysia/index.js +1 -1
- package/dist/{email-BRm6wMWQ.d.ts → email-_X1-FD9h.d.ts} +1 -1
- package/dist/{embeddings-LhxY3bUD.d.ts → embeddings-DJs1UeQt.d.ts} +1 -1
- package/dist/{ended-CpyW7_0h.d.ts → ended-XY1q20JM.d.ts} +1 -1
- package/dist/{entitlements-SqfT4gk_.d.ts → entitlements-D_vas3Yl.d.ts} +2 -2
- package/dist/{envelope-CapD-JtH.js → envelope-CSb4c7xn.js} +1 -1
- package/dist/eve/index.d.ts +5 -5
- package/dist/eve/index.js +1 -1
- package/dist/{eve-DmbLji3M.d.ts → eve-Ck586Yfh.d.ts} +2 -2
- package/dist/events/index.d.ts +3 -3
- package/dist/{events-BrgD2StJ.d.ts → events-sK2YdMhE.d.ts} +37 -2
- package/dist/{executor-DlAtlYxY.d.ts → executor-DAQLygMX.d.ts} +2 -2
- package/dist/{executor-kfUaLlQr.d.ts → executor-h4VT8TNz.d.ts} +1 -1
- package/dist/expo/index.d.ts +5 -5
- package/dist/expo/index.js +3 -3
- package/dist/{field-errors-DyWpuH1q.d.ts → field-errors-BFLehpue.d.ts} +22 -10
- package/dist/flags-sdk/index.d.ts +1 -1
- package/dist/{framework-DydnLrMk.js → framework-DvtET86P.js} +1 -1
- package/dist/{framework-C8HFM1bX.d.ts → framework-v4jPUZJ-.d.ts} +7 -7
- package/dist/{gateway-DQirTFOg.d.ts → gateway-BEDpSlLD.d.ts} +1 -1
- 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 +10 -10
- package/dist/hono/index.js +6 -6
- package/dist/{index-0erPlzHd.d.ts → index-BRFHDjCG.d.ts} +19 -5
- package/dist/{index-vGZZjCW7.d.ts → index-BoVZxiin.d.ts} +12 -12
- package/dist/{index-Brzh6XAW.d.ts → index-CJfDiWQf.d.ts} +4 -2
- package/dist/{index-BjN_IQQd.d.ts → index-Cc2q2eaq.d.ts} +18 -5
- package/dist/{index-DCyNdhEC.d.ts → index-D2gezcOV.d.ts} +3 -3
- package/dist/{index-CwDdMCdH.d.ts → index-D430cWV7.d.ts} +1 -1
- package/dist/{index-DcmDWojr.d.ts → index-DYSGzEkY.d.ts} +1 -1
- package/dist/{index-DkmorC1b.d.ts → index-eZ8oW-DV.d.ts} +4 -4
- package/dist/{index-Ddjcn6i7.d.ts → index-nfYh7R5C.d.ts} +5 -5
- package/dist/{index-x2YRPbXr.d.ts → index-wRn2y3XS.d.ts} +5 -5
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -2
- package/dist/{instances-DGtu3S0m.js → instances-BUhbreNT.js} +1554 -225
- package/dist/{kit-C1GVbhtg.d.ts → kit-CmO46iau.d.ts} +3 -3
- package/dist/{knowledge-CCOSNGJp.d.ts → knowledge-BnKrvPT6.d.ts} +22 -4
- package/dist/{knowledge-CJnZOaix.js → knowledge-BxFkHBTc.js} +14 -3
- package/dist/list/index.d.ts +1 -1
- package/dist/{list-query-CF-5EUVX.d.ts → list-query-CnD6uNzs.d.ts} +1 -1
- package/dist/mapper/bin.js +7 -7
- package/dist/mcp/index.d.ts +3 -3
- package/dist/mcp/index.js +4 -4
- package/dist/mcp/sdk/index.d.ts +18 -7
- package/dist/mcp/sdk/index.js +21 -12
- package/dist/nestjs/index.d.ts +2 -2
- package/dist/nestjs/index.js +1 -1
- package/dist/next/client/index.d.ts +1 -1
- package/dist/next/index.d.ts +22 -22
- package/dist/next/index.js +7 -7
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +1 -1
- package/dist/{operations-CkgwsViz.d.ts → operations-kNq7cGI7.d.ts} +1 -1
- package/dist/{options-CJR59q8s.js → options-B1efbeOv.js} +5 -1
- package/dist/options-B3dQnXgp.js +6 -0
- package/dist/{options-ByxOMSXu.js → options-BEv5xfPg.js} +3 -1
- package/dist/options-BZ5TzeFN.js +12 -0
- package/dist/options-CKMLVUel.js +8 -0
- package/dist/options-CgIKw9s6.js +9 -0
- package/dist/options-D1-2o7kO.d.ts +43 -0
- package/dist/{options-CjocPkX1.js → options-EdzV163Y.js} +3 -0
- package/dist/orpc/index.d.ts +26 -15
- package/dist/orpc/index.js +29 -9
- package/dist/otel/index.d.ts +2 -2
- package/dist/otel/index.js +5 -5
- package/dist/{outbox-DL2737I0.d.ts → outbox-CcISFwgE.d.ts} +2 -2
- package/dist/{permissions-vbtGrV26.d.ts → permissions-XrrAYkXm.d.ts} +1 -1
- package/dist/{permissions-controller-B4uI5IPH.js → permissions-controller-DYm6sF8k.js} +6 -2
- package/dist/{pool-DfDolmmm.d.ts → pool-CQuNr7Nq.d.ts} +1 -1
- package/dist/{ports-ClyPs0q6.d.ts → ports-CvOsUmuD.d.ts} +1 -1
- package/dist/postgres/index.d.ts +1 -1
- package/dist/powersync/index.d.ts +55 -13
- package/dist/powersync/index.js +85 -11
- package/dist/preset/index.d.ts +3 -3
- package/dist/preset/index.js +3 -3
- package/dist/{preset-His18bto.js → preset-DFZn_TLi.js} +2 -2
- package/dist/{project-D81NwLP6.js → project-BwmNYaZt.js} +5 -5
- package/dist/{provider-DxJWo8yD.d.ts → provider-CgYoyX_d.d.ts} +1 -1
- package/dist/{push-token-DMOeO8cU.d.ts → push-token-taE-3JNT.d.ts} +1 -1
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +30 -2
- package/dist/rate-limit/index.d.ts +2 -0
- package/dist/rate-limit/index.js +1 -0
- package/dist/rate-limit-BJyp7iAx.d.ts +109 -0
- package/dist/rate-limit-DLZWqcIS.js +94 -0
- package/dist/rate-limit-DyQbVEBE.js +123 -0
- package/dist/rate-limit-lGysIP9Z.d.ts +79 -0
- package/dist/react/index.d.ts +8 -8
- package/dist/react/index.js +2 -2
- package/dist/react/native/index.d.ts +3 -3
- package/dist/react/native/index.js +2 -1
- package/dist/react/server.d.ts +8 -8
- package/dist/react/server.js +2 -2
- package/dist/react/session.d.ts +2 -2
- package/dist/{react-DkGGh9FE.js → react-AC0iYStn.js} +13 -6
- package/dist/react-router/index.d.ts +5 -5
- package/dist/react-router/index.js +4 -4
- package/dist/realtime/index.d.ts +4 -4
- package/dist/realtime/index.js +1 -1
- package/dist/{record-form-BRtDkhLZ.d.ts → record-form-BAIG-cdw.d.ts} +1 -1
- package/dist/{record-type-oQxekQTX.js → record-type-BID6K9Vk.js} +1 -1
- package/dist/records/index.d.ts +8 -8
- package/dist/records/index.js +4 -4
- package/dist/{refusal-DjCQCcCj.d.ts → refusal-D19i-uE3.d.ts} +2 -2
- package/dist/{refusal-B9w5Bapa.js → refusal-lgW07wlX.js} +1 -1
- package/dist/renames-BPU-FSIn.d.ts +36 -0
- package/dist/renames-BoN2IHI7.js +161 -0
- package/dist/{resolve-CKJMUYRc.d.ts → resolve-C_VNGFjz.d.ts} +1 -1
- package/dist/{resource-CrmhNagD.js → resource--iTRgH4N.js} +1 -1
- package/dist/{resource-execute-DZeWkyIU.d.ts → resource-execute-CoadG2g7.d.ts} +1 -1
- package/dist/{resource-types-D3gmBOeY.d.ts → resource-types-e7vzPJ7t.d.ts} +2 -2
- package/dist/{resources-CSjwmcFs.d.ts → resources-DSqe-GbC.d.ts} +1 -1
- package/dist/{resources-B2i_nIgJ.js → resources-DqEg3HBk.js} +1 -1
- package/dist/{respond-DxS_8bzC.d.ts → respond-C8rBdIBZ.d.ts} +1 -1
- package/dist/server/index.d.ts +22 -22
- package/dist/server/index.js +7 -7
- package/dist/{server-types-DCC-dWKF.d.ts → server-types-Djx3Eb2G.d.ts} +9 -9
- package/dist/{session-Ca4clB30.d.ts → session-BgxLbDYu.d.ts} +5 -5
- package/dist/{session-status-CYtwZBi5.d.ts → session-status-C4g0QoB_.d.ts} +2 -2
- package/dist/{sign-in-BUiy6unD.js → sign-in-Cl7vhgRn.js} +1 -1
- package/dist/solid/index.d.ts +11 -11
- package/dist/solid/index.js +3 -3
- package/dist/solid-start/index.d.ts +5 -5
- package/dist/solid-start/index.js +4 -4
- package/dist/spec/index.d.ts +2 -2
- package/dist/spec/index.js +2 -2
- package/dist/{spec-pins-Dd1Qj3Sj.js → spec-pins-C-1kGh8u.js} +1 -1
- package/dist/{spec-pins-CRJEZYBW.d.ts → spec-pins-DGbByPMT.d.ts} +1 -1
- package/dist/sql/index.d.ts +6 -6
- package/dist/sql/index.js +5 -5
- package/dist/{sql-D3ihagTr.js → sql-TpANPmq7.js} +8961 -2083
- package/dist/sqlite/index.d.ts +1 -1
- package/dist/ssr/index.d.ts +4 -4
- package/dist/storage/index.js +1 -1
- package/dist/{subject-readers-nnYmRpv8.d.ts → subject-readers-yxQ3r1qw.d.ts} +1 -1
- package/dist/{subjects-BGwLJ3IB.d.ts → subjects-BpUQpZhk.d.ts} +30 -2
- package/dist/subjects-D3BE9Q8J.d.ts +173 -0
- package/dist/{support-BzXcdRLG.d.ts → support-B1n33r32.d.ts} +4 -4
- package/dist/{support-view-DNZh8-wA.d.ts → support-view-CkN2Wr1r.d.ts} +1 -1
- package/dist/svelte/index.d.ts +10 -10
- package/dist/svelte/index.js +3 -3
- package/dist/sveltekit/index.d.ts +6 -6
- package/dist/sveltekit/index.js +4 -4
- package/dist/{tags-CpFIpRw8.d.ts → tags-BCjWVMKO.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 +4 -4
- package/dist/{tenant-DyZZDYmm.d.ts → tenant-CBWFqFy0.d.ts} +1 -1
- package/dist/testing/index.d.ts +35 -31
- package/dist/testing/index.js +5 -4
- package/dist/{timeline-Bs-FGMIJ.js → timeline-B3pBRGv9.js} +1 -1
- package/dist/{timeline-Df8GMPkZ.d.ts → timeline-Cy7XP2pq.d.ts} +3 -3
- package/dist/{topic-BtoL1fKf.js → topic-BC3p90lS.js} +1 -1
- package/dist/{topic-B4fSui6P.d.ts → topic-BWJAJkF3.d.ts} +3 -3
- package/dist/{types-mYxPduXR.d.ts → types-B5qUEVWI.d.ts} +22 -16
- package/dist/{types-DJfGy-40.d.ts → types-B_2C7bqG.d.ts} +1 -1
- package/dist/{types-BeXhugiI.d.ts → types-Dlir1n-q.d.ts} +2 -2
- package/dist/{types-D6GlpLD9.d.ts → types-sBLcw65Z.d.ts} +2 -2
- package/dist/{vault-nYFV6WUD.d.ts → vault-BVLUu_Ph.d.ts} +1 -1
- package/dist/vercel-connect/index.d.ts +1 -1
- package/dist/vercel-sandbox/index.d.ts +1 -1
- package/dist/{verify-DxTccsBh.d.ts → verify-DlKjgAEj.d.ts} +1 -1
- package/dist/{view-DwXy8N6Y.d.ts → view-GSwP0y5o.d.ts} +1 -1
- package/dist/vue/index.d.ts +11 -11
- package/dist/vue/index.js +3 -3
- package/dist/{watch-topic-DShzD8ul.d.ts → watch-topic-BfaaK5SW.d.ts} +1 -1
- package/dist/{rate-limit-BJ4EMdAy.js → webhook-inbox-C94C_zIV.js} +3 -119
- package/dist/workflow-sdk/builder/index.d.ts +3 -3
- package/dist/workflow-sdk/builder/index.js +1 -1
- package/dist/workflow-sdk/index.d.ts +1 -1
- package/dist/workflow-sdk/index.js +1 -1
- package/dist/workflow-sdk/world/index.d.ts +1 -1
- package/dist/workflow-sdk/world/index.js +1 -1
- package/dist/{workflow-sdk-q2jnEaAJ.js → workflow-sdk-CZa83j_U.js} +1 -1
- package/dist/{workflow-sdk-ClwzLwNe.d.ts → workflow-sdk-DiDsEArJ.d.ts} +2 -2
- package/dist/{workflow-sdk-Bps7tpOv.js → workflow-sdk-DmHaJHUL.js} +170 -115
- package/dist/{workflows-ZGDa9twb.d.ts → workflows-D1Ax0qSC.d.ts} +4 -4
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/index.js +1 -1
- package/package.json +17 -1
- package/schemas/config-v1.json +201 -2
- package/schemas/doctor-report-v1.json +2 -0
- package/skills/better-supabase/SKILL.md +2 -1
- package/skills/better-supabase/references/ui-recipes.md +1062 -15
- package/skills/better-supabase-api/SKILL.md +1 -1
- package/dist/cli/add-D_JV6V6k.js +0 -1
- package/dist/cli/env-AFfMXxWw.js +0 -1
- package/dist/cli/powersync-B8GWjT_L.js +0 -1
- package/dist/cli/seed-DX1NTTOK.js +0 -1
- package/dist/rate-limit-C89Yzwd9.d.ts +0 -48
- package/dist/rate-limit-DXJbLVg0.js +0 -48
- package/dist/subjects-DgP5x73R.d.ts +0 -86
- package/dist/{kit-CB3AfM9W.js → kit-C-uC7_aG.js} +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { m as commandMeta, r as defineCliCommand } from "./command-
|
|
1
|
+
import { m as commandMeta, r as defineCliCommand } from "./command-DtQ7P9XP.js";
|
|
2
2
|
import { n as PLAN_ARGS, r as applyPlan, u as planResult } from "./files-DQayErI8.js";
|
|
3
|
-
import { a as snapshotColumnTypes, n as migrationsDir } from "./sql-layout-
|
|
4
|
-
import { r as layoutFor } from "./providers-
|
|
5
|
-
import { i as stampAfter } from "./migrations-
|
|
3
|
+
import { a as snapshotColumnTypes, n as migrationsDir } from "./sql-layout-C_-LNpAw.js";
|
|
4
|
+
import { r as layoutFor } from "./providers-BlkYmOf-.js";
|
|
5
|
+
import { i as stampAfter } from "./migrations-Cnf7TlYZ.js";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import { join, resolve } from "node:path";
|
|
8
8
|
import { readFile, readdir } from "node:fs/promises";
|
|
9
|
-
import { declaredColumnTypes, renderBlocks } from "better-supabase/sql";
|
|
9
|
+
import { addedColumnTypes, attachmentReadRoles, declaredColumnTypes, renderBlocks } from "better-supabase/sql";
|
|
10
10
|
import { SPEC_PINS } from "better-supabase";
|
|
11
11
|
// src/cli/powersync/streams.ts
|
|
12
12
|
/** The blocks `gen.powersync` can sync. */
|
|
@@ -34,11 +34,26 @@ function powersyncColumnType(type) {
|
|
|
34
34
|
return "text";
|
|
35
35
|
}
|
|
36
36
|
const CREATE_TABLE = /create table (?:if not exists )?("(?:[^"]|"")+"|[a-z_][a-z0-9_$]*)\./gi;
|
|
37
|
-
const unquote = (name) => name.startsWith("\"") ? name.slice(1, -1).replaceAll("\"\"", "\"") : name;
|
|
37
|
+
const unquote$1 = (name) => name.startsWith("\"") ? name.slice(1, -1).replaceAll("\"\"", "\"") : name;
|
|
38
38
|
function tablesOf(input, key) {
|
|
39
39
|
const files = input.files.flatMap((file) => file.kind === "schema" && (file.instance ?? file.module) === key ? [{ text: file.contents }] : []);
|
|
40
|
-
const schemas = new Set(files.flatMap(({ text }) => [...text.matchAll(CREATE_TABLE)].map((match) => unquote(match[1]))));
|
|
41
|
-
|
|
40
|
+
const schemas = [...new Set(files.flatMap(({ text }) => [...text.matchAll(CREATE_TABLE)].map((match) => unquote$1(match[1]))))];
|
|
41
|
+
const own = input.own?.get(key) ?? /* @__PURE__ */ new Map();
|
|
42
|
+
const added = addedColumnTypes(input.files.flatMap((file) => file.kind === "schema" ? [{ text: file.contents }] : []), [...schemas, ...[...own.keys()].map((table) => table.slice(0, table.indexOf(".")))]);
|
|
43
|
+
return new Map([...declaredColumnTypes(files, schemas), ...own].map(([table, columns]) => [table, new Map([...columns, ...[...added.get(table) ?? []].filter(([column]) => !columns.has(column))])]));
|
|
44
|
+
}
|
|
45
|
+
const ROLE_SET_TABLE = /create table (?:if not exists )?((?:"(?:[^"]|"")+"|[a-z_][a-z0-9_$]*)\.(?:"(?:[^"]|"")+"|[a-z_][a-z0-9_$]*)) \((?:(?!\n\);)[\s\S])*primary key \([^)]*"?role"?\)/gi;
|
|
46
|
+
/**
|
|
47
|
+
* The tables of `key` whose primary key ends in the `role` column, such as
|
|
48
|
+
* `membership_roles`: one row per role a member holds.
|
|
49
|
+
*/
|
|
50
|
+
function roleSetTables(input, key) {
|
|
51
|
+
const found = /* @__PURE__ */ new Set();
|
|
52
|
+
for (const file of input.files) {
|
|
53
|
+
if (file.kind !== "schema" || (file.instance ?? file.module) !== key) continue;
|
|
54
|
+
for (const match of file.contents.matchAll(ROLE_SET_TABLE)) found.add(match[1].split(".").map((part) => unquote$1(part.trim())).join("."));
|
|
55
|
+
}
|
|
56
|
+
return found;
|
|
42
57
|
}
|
|
43
58
|
/** The table of `tables` that has every one of `columns`. */
|
|
44
59
|
function tableWith(tables, columns, what) {
|
|
@@ -60,23 +75,59 @@ function notificationTables(input, instance) {
|
|
|
60
75
|
"summary"
|
|
61
76
|
], `${instance.key} events`);
|
|
62
77
|
const mine = `${qualifiedIdent(recipients)} WHERE user_id = auth.user_id()`;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
const preferences = [...tables].find(([, declared]) => declared.has("user_id") && declared.has("channel") && declared.has("enabled"));
|
|
79
|
+
return [
|
|
80
|
+
{
|
|
81
|
+
qualified: recipients,
|
|
82
|
+
name: baseName(recipients),
|
|
83
|
+
stream: `${instance.key}_recipients`,
|
|
84
|
+
query: `SELECT * FROM ${mine}`,
|
|
85
|
+
columns: recipientColumns
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
qualified: events,
|
|
89
|
+
name: baseName(events),
|
|
90
|
+
stream: `${instance.key}_events`,
|
|
91
|
+
query: `SELECT * FROM ${qualifiedIdent(events)} WHERE id IN (SELECT event_id FROM ${mine})`,
|
|
92
|
+
columns: eventColumns
|
|
93
|
+
},
|
|
94
|
+
...preferences === void 0 ? [] : [{
|
|
95
|
+
qualified: preferences[0],
|
|
96
|
+
name: baseName(preferences[0]),
|
|
97
|
+
stream: `${instance.key}_preferences`,
|
|
98
|
+
query: `SELECT * FROM ${qualifiedIdent(preferences[0])} WHERE user_id = auth.user_id()`,
|
|
99
|
+
columns: preferences[1]
|
|
100
|
+
}]
|
|
101
|
+
];
|
|
76
102
|
}
|
|
77
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* The memberships table: the one with `user_id` and `role` that is not a role
|
|
105
|
+
* set (`membership_roles`).
|
|
106
|
+
*/
|
|
78
107
|
function membershipsTable(input, key) {
|
|
79
|
-
|
|
108
|
+
const roleSets = roleSetTables(input, key);
|
|
109
|
+
return [...tablesOf(input, key)].find(([table, declared]) => !roleSets.has(table) && declared.has("user_id") && declared.has("role"));
|
|
110
|
+
}
|
|
111
|
+
/** The role set table (`roles.many`), when the memberships block has one. */
|
|
112
|
+
function roleSetTable(input, key) {
|
|
113
|
+
const roleSets = roleSetTables(input, key);
|
|
114
|
+
return [...tablesOf(input, key)].find(([table]) => roleSets.has(table));
|
|
115
|
+
}
|
|
116
|
+
/** `AND disabled_at IS NULL` when the memberships table can disable a member. */
|
|
117
|
+
const active = (columns) => columns.has("disabled_at") ? " AND disabled_at IS NULL" : "";
|
|
118
|
+
/**
|
|
119
|
+
* The CTE of the organizations the signed-in user is an active member of, as
|
|
120
|
+
* the tenant column of the memberships block's table.
|
|
121
|
+
*/
|
|
122
|
+
function activeOrganizations(input, what) {
|
|
123
|
+
const memberships = membershipsTable(input, "memberships");
|
|
124
|
+
if (memberships === void 0) throw new Error(`gen.powersync: ${what} syncs the rows of the user's organizations, which needs the memberships block`);
|
|
125
|
+
const [table, columns] = memberships;
|
|
126
|
+
const tenant = membershipTenant(columns, "memberships");
|
|
127
|
+
return {
|
|
128
|
+
tenant,
|
|
129
|
+
query: `SELECT ${ident(tenant)} FROM ${qualifiedIdent(table)} WHERE user_id = auth.user_id()${active(columns)}`
|
|
130
|
+
};
|
|
80
131
|
}
|
|
81
132
|
/** The tenant column of the memberships table: its `*_id` besides `user_id`. */
|
|
82
133
|
function membershipTenant(columns, what) {
|
|
@@ -96,14 +147,25 @@ function membershipTables(input, instance) {
|
|
|
96
147
|
if (found === void 0) throw new Error(`gen.powersync: found no ${instance.key} memberships table`);
|
|
97
148
|
const [memberships, columns] = found;
|
|
98
149
|
const tenant = membershipTenant(columns, `${instance.key} memberships`);
|
|
99
|
-
const mine = `SELECT ${ident(tenant)} FROM ${qualifiedIdent(memberships)} WHERE user_id = auth.user_id()`;
|
|
150
|
+
const mine = `SELECT ${ident(tenant)} FROM ${qualifiedIdent(memberships)} WHERE user_id = auth.user_id()${active(columns)}`;
|
|
100
151
|
const synced = [{
|
|
101
152
|
qualified: memberships,
|
|
102
153
|
name: baseName(memberships),
|
|
103
154
|
stream: `${instance.key}_memberships`,
|
|
104
|
-
query: `SELECT ${ident(tenant)} || ':' || user_id AS id, * FROM ${qualifiedIdent(memberships)} WHERE user_id = auth.user_id()`,
|
|
155
|
+
query: `SELECT ${columns.has("id") ? "" : `${ident(tenant)} || ':' || user_id AS id, `}* FROM ${qualifiedIdent(memberships)} WHERE user_id = auth.user_id()${active(columns)}`,
|
|
105
156
|
columns
|
|
106
157
|
}];
|
|
158
|
+
const roleSet = roleSetTable(input, instance.key);
|
|
159
|
+
if (roleSet !== void 0) {
|
|
160
|
+
const [table, roleColumns] = roleSet;
|
|
161
|
+
synced.push({
|
|
162
|
+
qualified: table,
|
|
163
|
+
name: baseName(table),
|
|
164
|
+
stream: `${instance.key}_roles`,
|
|
165
|
+
query: `SELECT ${ident(tenant)} || ':' || user_id || ':' || role AS id, * FROM ${qualifiedIdent(table)} WHERE user_id = auth.user_id()`,
|
|
166
|
+
columns: roleColumns
|
|
167
|
+
});
|
|
168
|
+
}
|
|
107
169
|
const organizations = [...tablesOf(input, "organizations")].find(([, declared]) => declared.has("id") && declared.has("name") && !declared.has("user_id"));
|
|
108
170
|
if (organizations !== void 0) {
|
|
109
171
|
const [table, declared] = organizations;
|
|
@@ -133,18 +195,27 @@ function teamTables(input, instance) {
|
|
|
133
195
|
"slug",
|
|
134
196
|
"status"
|
|
135
197
|
], `${instance.key} teams`);
|
|
136
|
-
const
|
|
198
|
+
const orgs = activeOrganizations(input, instance.key);
|
|
199
|
+
const tenantOf = (columns, what) => {
|
|
200
|
+
const found = [...columns.keys()].find((column) => column.endsWith("_id") && column !== "team_id" && column !== "user_id");
|
|
201
|
+
if (found === void 0) throw new Error(`gen.powersync: ${what} has no organization column`);
|
|
202
|
+
return found;
|
|
203
|
+
};
|
|
204
|
+
const teamTenant = tenantOf(teamColumns, `${instance.key} teams`);
|
|
205
|
+
const memberTenant = tenantOf(memberColumns, `${instance.key} team members`);
|
|
137
206
|
return [{
|
|
138
207
|
qualified: teams,
|
|
139
208
|
name: baseName(teams),
|
|
140
209
|
stream: `${instance.key}_teams`,
|
|
141
|
-
|
|
210
|
+
with: { my_orgs: orgs.query },
|
|
211
|
+
query: `SELECT * FROM ${qualifiedIdent(teams)} WHERE ${ident(teamTenant)} IN my_orgs`,
|
|
142
212
|
columns: teamColumns
|
|
143
213
|
}, {
|
|
144
214
|
qualified: members,
|
|
145
215
|
name: baseName(members),
|
|
146
216
|
stream: `${instance.key}_members`,
|
|
147
|
-
|
|
217
|
+
with: { my_orgs: orgs.query },
|
|
218
|
+
query: `SELECT team_id || ':' || user_id AS id, * FROM ${qualifiedIdent(members)} WHERE ${ident(memberTenant)} IN my_orgs`,
|
|
148
219
|
columns: memberColumns
|
|
149
220
|
}];
|
|
150
221
|
}
|
|
@@ -164,19 +235,35 @@ function attachmentTables(input, instance) {
|
|
|
164
235
|
"object_path",
|
|
165
236
|
"uploaded_by"
|
|
166
237
|
], `${instance.key} attachments`);
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
const [membershipTable, membershipColumns] = memberships;
|
|
170
|
-
const tenant = [...columns.keys()].find((column) => column.endsWith("_id") && column !== "user_id" && membershipColumns.has(column));
|
|
238
|
+
const orgs = activeOrganizations(input, instance.key);
|
|
239
|
+
const tenant = columns.has(orgs.tenant) ? orgs.tenant : [...columns.keys()].find((column) => column.endsWith("_id") && column !== "user_id");
|
|
171
240
|
if (tenant === void 0) throw new Error(`gen.powersync: ${instance.key} and memberships share no organization column`);
|
|
241
|
+
const readers = readerOrganizations(input, instance.key, orgs.tenant);
|
|
172
242
|
return [{
|
|
173
243
|
qualified: attachments,
|
|
174
244
|
name: baseName(attachments),
|
|
175
245
|
stream: instance.key,
|
|
176
|
-
|
|
246
|
+
with: {
|
|
247
|
+
active_orgs: orgs.query,
|
|
248
|
+
...readers === void 0 ? {} : { reader_orgs: readers }
|
|
249
|
+
},
|
|
250
|
+
query: `SELECT * FROM ${qualifiedIdent(attachments)} WHERE ${ident(tenant)} IN active_orgs${readers === void 0 ? "" : ` AND ${ident(tenant)} IN reader_orgs`}`,
|
|
177
251
|
columns
|
|
178
252
|
}];
|
|
179
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* The CTE of the organizations where the user holds a role with the instance's
|
|
256
|
+
* `read` permission, read from the role set when the memberships block keeps
|
|
257
|
+
* one. Undefined when every member reads.
|
|
258
|
+
*/
|
|
259
|
+
function readerOrganizations(input, key, tenant) {
|
|
260
|
+
const roles = input.readRoles?.get(key);
|
|
261
|
+
if (roles === void 0) return;
|
|
262
|
+
const source = roleSetTable(input, "memberships") ?? membershipsTable(input, "memberships");
|
|
263
|
+
if (source === void 0) return;
|
|
264
|
+
const matches = roles.length === 0 ? "FALSE" : roles.map((role) => `role = '${role.replaceAll("'", "''")}'`).join(" OR ");
|
|
265
|
+
return `SELECT ${ident(tenant)} FROM ${qualifiedIdent(source[0])} WHERE user_id = auth.user_id() AND (${matches})`;
|
|
266
|
+
}
|
|
180
267
|
function syncedTables(input, instance) {
|
|
181
268
|
switch (instance.block) {
|
|
182
269
|
case "notifications": return notificationTables(input, instance);
|
|
@@ -195,6 +282,7 @@ function streamsYaml(tables) {
|
|
|
195
282
|
const streams = tables.flatMap((table) => [
|
|
196
283
|
` ${table.stream}:`,
|
|
197
284
|
" auto_subscribe: true",
|
|
285
|
+
...table.with === void 0 || Object.keys(table.with).length === 0 ? [] : [" with:", ...Object.entries(table.with).map(([name, query]) => ` ${name}: ${yamlString(query)}`)],
|
|
198
286
|
` query: ${yamlString(table.query)}`
|
|
199
287
|
]);
|
|
200
288
|
return [
|
|
@@ -207,32 +295,17 @@ function streamsYaml(tables) {
|
|
|
207
295
|
""
|
|
208
296
|
].join("\n");
|
|
209
297
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
for t in
|
|
222
|
-
select n.nspname as schema_name, c.relname as table_name
|
|
223
|
-
from (values ${names}) as wanted (name)
|
|
224
|
-
join pg_class c on c.oid = wanted.name::regclass
|
|
225
|
-
join pg_namespace n on n.oid = c.relnamespace
|
|
226
|
-
where not exists (
|
|
227
|
-
select 1 from pg_publication_tables p
|
|
228
|
-
where p.pubname = 'powersync' and p.schemaname = n.nspname and p.tablename = c.relname
|
|
229
|
-
)
|
|
230
|
-
loop
|
|
231
|
-
execute format('alter publication powersync add table %I.%I', t.schema_name, t.table_name);
|
|
232
|
-
end loop;
|
|
233
|
-
end;
|
|
234
|
-
$$;
|
|
235
|
-
`;
|
|
298
|
+
/**
|
|
299
|
+
* The publication migration for `tables`: `create publication` when no earlier
|
|
300
|
+
* migration made it, otherwise one `alter publication` per table that
|
|
301
|
+
* `published` lacks. Undefined when there is nothing to add.
|
|
302
|
+
*/
|
|
303
|
+
function publicationSql(tables, published) {
|
|
304
|
+
const quoted = (table) => qualifiedIdent(table);
|
|
305
|
+
const header = `-- ${GENERATED}: the block tables PowerSync replicates.`;
|
|
306
|
+
if (published === void 0) return `${header}\ncreate publication powersync for table ${tables.map(quoted).join(", ")};\n`;
|
|
307
|
+
const added = tables.filter((table) => !published.has(table));
|
|
308
|
+
return added.length === 0 ? void 0 : `${header}\n${added.map((table) => `alter publication powersync add table ${quoted(table)};`).join("\n")}\n`;
|
|
236
309
|
}
|
|
237
310
|
const propertyName = (name) => /^[A-Za-z_$][\w$]*$/.test(name) ? name : JSON.stringify(name);
|
|
238
311
|
function schemaModule(tables, importFrom) {
|
|
@@ -259,9 +332,11 @@ function schemaModule(tables, importFrom) {
|
|
|
259
332
|
function powersyncOutput(input) {
|
|
260
333
|
const byInstance = input.instances.map((instance) => [instance.key, syncedTables(input, instance)]);
|
|
261
334
|
const tables = byInstance.flatMap(([, synced]) => synced);
|
|
335
|
+
const published = [...new Set(tables.map(({ qualified }) => qualified))];
|
|
262
336
|
return {
|
|
263
337
|
streams: streamsYaml(tables),
|
|
264
|
-
publication: publicationSql(
|
|
338
|
+
publication: publicationSql(published) ?? "",
|
|
339
|
+
published,
|
|
265
340
|
schema: schemaModule(tables, input.importFrom),
|
|
266
341
|
tables: Object.fromEntries(byInstance.map(([key, synced]) => [key, synced.map(({ name }) => name)]))
|
|
267
342
|
};
|
|
@@ -304,16 +379,29 @@ function instancesOf(config, keys) {
|
|
|
304
379
|
}
|
|
305
380
|
return instances;
|
|
306
381
|
}
|
|
382
|
+
const PUBLISHED = [
|
|
383
|
+
/alter publication powersync add table ((?:"(?:[^"]|"")+"|[a-z_][a-z0-9_$]*)\.(?:"(?:[^"]|"")+"|[a-z_][a-z0-9_$]*))/g,
|
|
384
|
+
/create publication powersync for table ([^;]+);/g,
|
|
385
|
+
/\('((?:[^']|'')+)'\)/g
|
|
386
|
+
];
|
|
387
|
+
const unquote = (part) => part.startsWith("\"") ? part.slice(1, -1).replaceAll("\"\"", "\"") : part;
|
|
388
|
+
/** The `schema.table` names an earlier publication migration added. */
|
|
389
|
+
function publishedBy(sql) {
|
|
390
|
+
const found = /* @__PURE__ */ new Set();
|
|
391
|
+
for (const pattern of PUBLISHED) for (const match of sql.matchAll(pattern)) for (const table of match[1].split(",")) found.add(table.trim().replaceAll("''", "'").split(".").map((part) => unquote(part.trim())).join("."));
|
|
392
|
+
return found;
|
|
393
|
+
}
|
|
307
394
|
/**
|
|
308
|
-
* The publication migration
|
|
309
|
-
*
|
|
395
|
+
* The publication migration: `create publication` the first time, then one that
|
|
396
|
+
* adds the tables no earlier migration added. A pushed migration is never
|
|
397
|
+
* rewritten, so a change gets a new one.
|
|
310
398
|
*/
|
|
311
|
-
async function publicationMigration(config,
|
|
399
|
+
async function publicationMigration(config, tables, now) {
|
|
312
400
|
const dir = resolve(config.root, migrationsDir(config));
|
|
313
401
|
const names = existsSync(dir) ? (await readdir(dir)).toSorted() : [];
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
return {
|
|
402
|
+
const earlier = names.filter((name) => name.endsWith(PUBLICATION_SUFFIX));
|
|
403
|
+
const sql = publicationSql(tables, earlier.length === 0 ? void 0 : new Set((await Promise.all(earlier.map((name) => readFile(join(dir, name), "utf-8")))).flatMap((sql) => [...publishedBy(sql)])));
|
|
404
|
+
return sql === void 0 ? void 0 : {
|
|
317
405
|
path: join(dir, `${stampAfter(names, now())}${PUBLICATION_SUFFIX}`),
|
|
318
406
|
contents: sql,
|
|
319
407
|
policy: "create",
|
|
@@ -321,6 +409,18 @@ async function publicationMigration(config, sql, now) {
|
|
|
321
409
|
};
|
|
322
410
|
}
|
|
323
411
|
/**
|
|
412
|
+
* By attachments instance, the roles whose keys grant its `read` permission,
|
|
413
|
+
* when access runs on the `roles` model.
|
|
414
|
+
*/
|
|
415
|
+
function readRolesOf(config, layout, instances) {
|
|
416
|
+
return new Map(instances.flatMap((instance) => {
|
|
417
|
+
if (instance.block !== "attachments") return [];
|
|
418
|
+
const roles = attachmentReadRoles(layout, config.blockNames, instance.key);
|
|
419
|
+
if (roles === void 0) return [];
|
|
420
|
+
return [[instance.key, roles]];
|
|
421
|
+
}));
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
324
424
|
* Writes `sync-streams.yaml` and `schema.ts` for the synced block instances,
|
|
325
425
|
* and a migration that adds their tables to the `powersync` publication.
|
|
326
426
|
*/
|
|
@@ -351,6 +451,7 @@ async function runPowerSync(config, args, now = () => /* @__PURE__ */ new Date()
|
|
|
351
451
|
files: renderBlocks(config.blockNames, layout),
|
|
352
452
|
instances,
|
|
353
453
|
own,
|
|
454
|
+
readRoles: readRolesOf(config, layout, instances),
|
|
354
455
|
importFrom: settings?.import ?? "@powersync/common"
|
|
355
456
|
});
|
|
356
457
|
} catch (cause) {
|
|
@@ -361,7 +462,7 @@ async function runPowerSync(config, args, now = () => /* @__PURE__ */ new Date()
|
|
|
361
462
|
};
|
|
362
463
|
}
|
|
363
464
|
const out = resolve(config.root, args.out ?? settings?.out ?? "powersync");
|
|
364
|
-
const migration = await publicationMigration(config, output.
|
|
465
|
+
const migration = await publicationMigration(config, output.published, now);
|
|
365
466
|
const plan = {
|
|
366
467
|
root: config.root,
|
|
367
468
|
regenerate: REGENERATE,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as powersyncStreamsCommand } from "./powersync-BeeW0i26.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as CliError } from "./errors-DcJ_PayO.js";
|
|
2
|
-
import { n as layout } from "./providers-
|
|
3
|
-
import { o as migrationModules, r as latestMigration, u as writesMigrations } from "./module-migration-
|
|
2
|
+
import { n as layout } from "./providers-BlkYmOf-.js";
|
|
3
|
+
import { o as migrationModules, r as latestMigration, u as writesMigrations } from "./module-migration-CKKOcrG0.js";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
import { SQL_MODULES, contractSignature, customContracts, moduleBody, moduleFilePaths } from "better-supabase/sql";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as CliError } from "./errors-DcJ_PayO.js";
|
|
2
2
|
import { a as moduleKeyProblems, i as entitlementsMode, t as accessProviderMode } from "./authorization-DJkkOjjG.js";
|
|
3
3
|
import { t as importFresh } from "./fresh-import-CdO2oQaQ.js";
|
|
4
|
-
import { i as schemasDirOf, r as moduleLayoutFor } from "./sql-layout-
|
|
4
|
+
import { i as schemasDirOf, r as moduleLayoutFor } from "./sql-layout-C_-LNpAw.js";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
import { compileReadSets, moduleLayout, modulePermissionKeys, resolveBlocks } from "better-supabase/sql";
|
|
7
7
|
import { isReadSet } from "better-supabase";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { m as commandMeta, r as defineCliCommand } from "./command-
|
|
1
|
+
import { m as commandMeta, r as defineCliCommand } from "./command-DtQ7P9XP.js";
|
|
2
2
|
import { n as CliError, r as errorText } from "./errors-DcJ_PayO.js";
|
|
3
3
|
import { i as isLocalDatabaseUrl, r as databaseHost } from "./agent-Tqq3MAqx.js";
|
|
4
|
-
import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-
|
|
4
|
+
import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-Cb4swJ2X.js";
|
|
5
5
|
import { t as connect } from "./db-B8zfxjl2.js";
|
|
6
|
-
import { n as ident } from "./live-
|
|
7
|
-
import { r as STACK_ARG, t as DB_URL_STDIN_ARG } from "./source-args-
|
|
6
|
+
import { n as ident } from "./live-BRhu6mk8.js";
|
|
7
|
+
import { r as STACK_ARG, t as DB_URL_STDIN_ARG } from "./source-args-BiySywDB.js";
|
|
8
8
|
// src/cli/commands/prune-workflows.ts
|
|
9
9
|
const TERMINAL = [
|
|
10
10
|
"completed",
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { m as commandMeta, r as defineCliCommand } from "./command-
|
|
1
|
+
import { m as commandMeta, r as defineCliCommand } from "./command-DtQ7P9XP.js";
|
|
2
2
|
import { i as plain } from "./style-B5-nByxb.js";
|
|
3
3
|
import { n as CliError } from "./errors-DcJ_PayO.js";
|
|
4
4
|
import { r as readIfExists, t as display } from "./io-CQzy8PEZ.js";
|
|
5
5
|
import { i as changeLines, n as PLAN_ARGS, r as applyPlan, t as HAND_EDITED, u as planResult } from "./files-DQayErI8.js";
|
|
6
|
-
import { o as sqlPlan } from "./sql-layout-
|
|
7
|
-
import { r as layoutFor } from "./providers-
|
|
8
|
-
import { g as templateContextFor, i as blocksWiringPath, n as blockClients } from "./add-
|
|
6
|
+
import { o as sqlPlan } from "./sql-layout-C_-LNpAw.js";
|
|
7
|
+
import { r as layoutFor } from "./providers-BlkYmOf-.js";
|
|
8
|
+
import { g as templateContextFor, i as blocksWiringPath, n as blockClients } from "./add-CYH9OE6d.js";
|
|
9
9
|
import { t as detectProject } from "./detect-BcUDaO8I.js";
|
|
10
10
|
import { _ as wiringBlocks, a as configObject, c as mask, i as closingIndex, l as properties } from "./config-edit-C6sQ1MqT.js";
|
|
11
|
-
import { n as guardedRemoval } from "./sync-
|
|
11
|
+
import { n as guardedRemoval } from "./sync-Bl4Kf4_T.js";
|
|
12
12
|
import { t as SQL_ARGS } from "./args-_ZVgRBkx.js";
|
|
13
|
-
import { t as blockNames } from "./blocks-
|
|
13
|
+
import { t as blockNames } from "./blocks-DZrlz-13.js";
|
|
14
14
|
import { i as tidyInline, t as cutRange } from "./config-group-D4JWh4kG.js";
|
|
15
15
|
import { existsSync } from "node:fs";
|
|
16
16
|
import { resolve } from "node:path";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { n as CliError, r as errorText } from "./errors-DcJ_PayO.js";
|
|
2
2
|
import { n as importPath } from "./io-CQzy8PEZ.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-BgiLj67N.js";
|
|
4
4
|
import { t as byCodePoint } from "./compare-yl4sSwVn.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-T8fVRXqA.js";
|
|
6
6
|
import { s as providerTruncatedClaim } from "./authorization-DJkkOjjG.js";
|
|
7
7
|
import { t as isRecord$1 } from "./guards-DxwRG0Uv.js";
|
|
8
|
-
import { a as toCatalog } from "./source-
|
|
9
|
-
import { m as withTableTags } from "./config-
|
|
8
|
+
import { a as toCatalog } from "./source-xL7qYX0r.js";
|
|
9
|
+
import { m as withTableTags } from "./config-Cb4swJ2X.js";
|
|
10
10
|
import { basename, dirname, isAbsolute, join, posix, relative, resolve } from "node:path";
|
|
11
11
|
import { entityNames } from "better-supabase/blocks";
|
|
12
12
|
import { DEFAULT_CLAIMS, blockEntities, blockEntityRenames, blockSubjectTypes, tenantClaimPaths, tenantNameOf } from "better-supabase/config";
|
|
@@ -787,10 +787,20 @@ function prepareCatalog(snapshot, config) {
|
|
|
787
787
|
optionsOf
|
|
788
788
|
};
|
|
789
789
|
}
|
|
790
|
+
/**
|
|
791
|
+
* The columns the `updated-at` extension stamps on insert, which an insert may
|
|
792
|
+
* leave out. Under `stamp: "trigger"` only the table's own default fills them.
|
|
793
|
+
*/
|
|
794
|
+
function clientStampedColumns(config) {
|
|
795
|
+
const timestamps = config.extensions.timestamps;
|
|
796
|
+
if (timestamps === void 0 || config.blocks["updated-at"]?.options?.["stamp"] === "trigger") return /* @__PURE__ */ new Set();
|
|
797
|
+
return /* @__PURE__ */ new Set([timestamps.createdAt, timestamps.updatedAt]);
|
|
798
|
+
}
|
|
790
799
|
function draftTables(ctx) {
|
|
791
800
|
const { config, included, enumsByName, tsType, jsonTypeFor, optionsOf } = ctx;
|
|
792
801
|
const storagePaths = storagePathsOf(config);
|
|
793
802
|
const numbered = numberedColumnsOf(config);
|
|
803
|
+
const stamped = clientStampedColumns(config);
|
|
794
804
|
const tables = included.map((table) => {
|
|
795
805
|
const casing = optionsOf(table)?.casing ?? config.casing;
|
|
796
806
|
const checks = /* @__PURE__ */ new Map();
|
|
@@ -819,7 +829,7 @@ function draftTables(ctx) {
|
|
|
819
829
|
const readonly = column.generated || column.identity === "always";
|
|
820
830
|
const narrowed = column.nullable && checkedNotNull.has(column.name);
|
|
821
831
|
const nullable = column.nullable && !narrowed;
|
|
822
|
-
const filled = column.hasDefault || insertOptional.has(column.name) || (numberedColumns?.has(column.name) ?? false) || narrowed && fillers.some((trigger) => trigger.fills?.includes(column.name) ?? true);
|
|
832
|
+
const filled = column.hasDefault || insertOptional.has(column.name) || table.insertable && stamped.has(column.name) || (numberedColumns?.has(column.name) ?? false) || narrowed && fillers.some((trigger) => trigger.fills?.includes(column.name) ?? true);
|
|
823
833
|
const insertable = !readonly && table.insertable && (table.kind !== "view" || column.updatable);
|
|
824
834
|
const updatable = !readonly && table.updatable && column.updatable;
|
|
825
835
|
return {
|
|
@@ -1906,6 +1916,96 @@ function emitBlockConfig(config, options = {}) {
|
|
|
1906
1916
|
].join("\n")
|
|
1907
1917
|
};
|
|
1908
1918
|
}
|
|
1919
|
+
// src/cli/gen/layout.ts
|
|
1920
|
+
/** The repo formatter's print width; generated files must print the same. */
|
|
1921
|
+
const WIDTH = 80;
|
|
1922
|
+
const SPECIFIER = / from "([^"]+)";$/;
|
|
1923
|
+
function specifier(line) {
|
|
1924
|
+
return SPECIFIER.exec(line)?.[1] ?? line;
|
|
1925
|
+
}
|
|
1926
|
+
/** Import statements in the formatter's order: by module specifier. */
|
|
1927
|
+
function sortImports(lines) {
|
|
1928
|
+
return lines.toSorted((a, b) => specifier(a).localeCompare(specifier(b)));
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Where the formatter groups a value import: with the packages, with the repo's
|
|
1932
|
+
* internal aliases (`@/`, `@better-supabase/`), or with the relative imports
|
|
1933
|
+
* after them.
|
|
1934
|
+
*/
|
|
1935
|
+
function importGroup(from) {
|
|
1936
|
+
if (from.startsWith(".")) return "relative";
|
|
1937
|
+
return from.startsWith("@/") || from.startsWith("@better-supabase/") ? "internal" : "external";
|
|
1938
|
+
}
|
|
1939
|
+
/** `import { … } from "…";`, one name per line when it is wider than 80. */
|
|
1940
|
+
function importStatement(names, from) {
|
|
1941
|
+
const line = `import { ${names.join(", ")} } from ${q(from)};`;
|
|
1942
|
+
if (line.length <= WIDTH) return [line];
|
|
1943
|
+
return [
|
|
1944
|
+
"import {",
|
|
1945
|
+
...names.map((name) => ` ${name},`),
|
|
1946
|
+
`} from ${q(from)};`
|
|
1947
|
+
];
|
|
1948
|
+
}
|
|
1949
|
+
/** A JSDoc comment filled to 80 columns, on one line when it fits. */
|
|
1950
|
+
function docComment(text) {
|
|
1951
|
+
const single = `/** ${text} */`;
|
|
1952
|
+
if (single.length <= WIDTH) return [single];
|
|
1953
|
+
const lines = [];
|
|
1954
|
+
let line = " *";
|
|
1955
|
+
for (const word of text.split(" ")) {
|
|
1956
|
+
if (line.length + 1 + word.length > WIDTH && line !== " *") {
|
|
1957
|
+
lines.push(line);
|
|
1958
|
+
line = " *";
|
|
1959
|
+
}
|
|
1960
|
+
line += ` ${word}`;
|
|
1961
|
+
}
|
|
1962
|
+
return [
|
|
1963
|
+
"/**",
|
|
1964
|
+
...lines,
|
|
1965
|
+
line,
|
|
1966
|
+
" */"
|
|
1967
|
+
];
|
|
1968
|
+
}
|
|
1969
|
+
function call(callee, args, indent) {
|
|
1970
|
+
return [
|
|
1971
|
+
`${callee}(`,
|
|
1972
|
+
...args.map((arg) => `${indent} ${arg},`),
|
|
1973
|
+
`${indent});`
|
|
1974
|
+
];
|
|
1975
|
+
}
|
|
1976
|
+
/**
|
|
1977
|
+
* `export const { key: name, … } = callee(args);` laid out as the formatter
|
|
1978
|
+
* prints it: on one line, then with the arguments broken, then broken after
|
|
1979
|
+
* `=`, and with the pattern broken when it is wider than 80 on its own.
|
|
1980
|
+
*/
|
|
1981
|
+
function destructuredCall(bindings, callee, args) {
|
|
1982
|
+
const pattern = bindings.map(([key, name]) => `${key}: ${name}`);
|
|
1983
|
+
const head = `export const { ${pattern.join(", ")} } =`;
|
|
1984
|
+
const flat = `${callee}(${args.join(", ")});`;
|
|
1985
|
+
if (head.length > WIDTH) {
|
|
1986
|
+
const tail = `} = ${flat}`;
|
|
1987
|
+
const opened = ["export const {", ...pattern.map((entry) => ` ${entry},`)];
|
|
1988
|
+
if (tail.length <= WIDTH) return [...opened, tail];
|
|
1989
|
+
const [first = "", ...rest] = call(callee, args, "");
|
|
1990
|
+
return [
|
|
1991
|
+
...opened,
|
|
1992
|
+
`} = ${first}`,
|
|
1993
|
+
...rest
|
|
1994
|
+
];
|
|
1995
|
+
}
|
|
1996
|
+
if (`${head} ${flat}`.length <= WIDTH) return [`${head} ${flat}`];
|
|
1997
|
+
if (`${head} ${callee}(`.length <= WIDTH) {
|
|
1998
|
+
const [first = "", ...rest] = call(callee, args, "");
|
|
1999
|
+
return [`${head} ${first}`, ...rest];
|
|
2000
|
+
}
|
|
2001
|
+
if (` ${flat}`.length <= WIDTH) return [head, ` ${flat}`];
|
|
2002
|
+
const [first = "", ...rest] = call(callee, args, " ");
|
|
2003
|
+
return [
|
|
2004
|
+
head,
|
|
2005
|
+
` ${first}`,
|
|
2006
|
+
...rest
|
|
2007
|
+
];
|
|
2008
|
+
}
|
|
1909
2009
|
// src/cli/gen/hooks.ts
|
|
1910
2010
|
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
1911
2011
|
function access(property) {
|
|
@@ -1937,6 +2037,11 @@ function emitHooks(config, tables, options = {}) {
|
|
|
1937
2037
|
if (config.hooks === false) return;
|
|
1938
2038
|
const runtime = options.runtimeImport ?? "better-supabase";
|
|
1939
2039
|
if (tables.length === 0) return;
|
|
2040
|
+
const select = config.hooksSelect;
|
|
2041
|
+
const wrap = (fn) => select === void 0 ? fn : `${select.export}(${fn})`;
|
|
2042
|
+
const hooksImport = `import { defineDataHooks } from ${q(runtimeSubpath(runtime, config.hooks))};`;
|
|
2043
|
+
const selectImport = select && `import { ${select.export} } from ${q(select.module)};`;
|
|
2044
|
+
const group = select && importGroup(select.module);
|
|
1940
2045
|
return {
|
|
1941
2046
|
path: hooksPath(config),
|
|
1942
2047
|
contents: [
|
|
@@ -1945,18 +2050,16 @@ function emitHooks(config, tables, options = {}) {
|
|
|
1945
2050
|
"",
|
|
1946
2051
|
`import type { DbOf } from ${q(runtime)};`,
|
|
1947
2052
|
"",
|
|
1948
|
-
|
|
2053
|
+
...selectImport && group === "external" ? sortImports([hooksImport, selectImport]) : [hooksImport],
|
|
2054
|
+
...selectImport && group === "internal" ? ["", selectImport] : [],
|
|
1949
2055
|
"",
|
|
1950
2056
|
"import type { betterSupabase } from \"./index\";",
|
|
2057
|
+
...selectImport && group === "relative" ? ["", selectImport] : [],
|
|
1951
2058
|
"",
|
|
1952
2059
|
"type AppDb = DbOf<typeof betterSupabase>;",
|
|
1953
2060
|
...tables.flatMap((property) => {
|
|
1954
2061
|
const names = hookNames(property);
|
|
1955
|
-
return [
|
|
1956
|
-
"",
|
|
1957
|
-
`export const { useList: ${names.list}, useOne: ${names.one} } =`,
|
|
1958
|
-
` defineDataHooks(${q(property)}, (db: AppDb) => ${access(property)});`
|
|
1959
|
-
];
|
|
2062
|
+
return ["", ...destructuredCall([["useList", names.list], ["useOne", names.one]], "defineDataHooks", [q(property), wrap(`(db: AppDb) => ${access(property)}`)])];
|
|
1960
2063
|
}),
|
|
1961
2064
|
""
|
|
1962
2065
|
].join("\n")
|
|
@@ -2020,11 +2123,11 @@ function recordFile(config, path, type, blocks, extras) {
|
|
|
2020
2123
|
...extras.permissions ? ["permissions"] : [],
|
|
2021
2124
|
...blocks.filter((block) => block.from === void 0).map((b) => b.local)
|
|
2022
2125
|
].toSorted((a, b) => a.localeCompare(b));
|
|
2023
|
-
const imports = [
|
|
2126
|
+
const imports = sortImports([
|
|
2024
2127
|
"import { defineRecordType } from \"better-supabase/records\";",
|
|
2025
2128
|
...blocks.flatMap((block) => block.from === void 0 ? [] : [`import { ${block.local} } from ${q(block.from)};`]),
|
|
2026
2129
|
...extras.access === void 0 ? [] : [`import { permissionsBlock } from ${q(extras.access)};`]
|
|
2027
|
-
]
|
|
2130
|
+
]);
|
|
2028
2131
|
return {
|
|
2029
2132
|
path,
|
|
2030
2133
|
contents: [
|
|
@@ -2032,12 +2135,9 @@ function recordFile(config, path, type, blocks, extras) {
|
|
|
2032
2135
|
"",
|
|
2033
2136
|
...imports,
|
|
2034
2137
|
"",
|
|
2035
|
-
|
|
2138
|
+
...importStatement(fromGenerated, generated),
|
|
2036
2139
|
"",
|
|
2037
|
-
|
|
2038
|
-
` * The ${type} record type: each installed block that binds to it. Pass it`,
|
|
2039
|
-
" * to `bsb.record`, `recordQueries` or `createRecordProvider`.",
|
|
2040
|
-
" */",
|
|
2140
|
+
...docComment(`The ${type} record type: each installed block that binds to it. Pass it to \`bsb.record\`, \`recordQueries\` or \`createRecordProvider\`.`),
|
|
2041
2141
|
`export const ${camel(type)}Record = defineRecordType({`,
|
|
2042
2142
|
` type: ${q(type)},`,
|
|
2043
2143
|
" blocks: {",
|