better-supabase 0.35.0 → 0.36.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/{adapter-CWzyKepA.js → adapter-ddQ9Hzka.js} +126 -91
- package/dist/{agents-DXiOPB3V.d.ts → agents-BwUHtvD6.d.ts} +4 -4
- package/dist/{ai-cache-CLiAXCPH.d.ts → ai-cache-CPOP2PYz.d.ts} +4 -4
- package/dist/{ai-chat-DlcBdOhJ.d.ts → ai-chat-BZhfCHHr.d.ts} +106 -25
- package/dist/{ai-schedules-Drx2KRTn.d.ts → ai-schedules-BZPmySUa.d.ts} +5 -5
- package/dist/ai-sdk/agents/index.d.ts +6 -6
- package/dist/ai-sdk/batches/index.d.ts +3 -3
- package/dist/ai-sdk/cache/index.d.ts +1 -1
- package/dist/ai-sdk/chat/index.d.ts +2 -2
- package/dist/ai-sdk/chat/index.js +3 -272
- package/dist/ai-sdk/embeddings/index.d.ts +2 -2
- package/dist/ai-sdk/files/index.d.ts +1 -1
- package/dist/ai-sdk/index.d.ts +5 -5
- package/dist/ai-sdk/index.js +2 -3
- package/dist/ai-sdk/mcp/index.d.ts +3 -3
- package/dist/ai-sdk/memory/index.d.ts +3 -3
- package/dist/ai-sdk/workflow/index.d.ts +6 -5
- package/dist/ai-sdk/workflow/index.js +9 -9
- package/dist/{api-myq2e9t5.d.ts → api-XEaCJbgv.d.ts} +5 -5
- package/dist/{api-keys-DbIbkGxx.d.ts → api-keys-C82fMru4.d.ts} +4 -4
- package/dist/{app-tables-X3yzJljM.d.ts → app-tables-C0XVpQEJ.d.ts} +1 -1
- package/dist/{approvals-Da4uAANx.js → approvals-D8gR1R8R.js} +95 -11
- package/dist/{approvals-DZoGtNFv.d.ts → approvals-DqCv7f-G.d.ts} +101 -7
- package/dist/{assistant-BEbRPjhn.d.ts → assistant-5heV2GeR.d.ts} +7 -3
- package/dist/assistant-BHZ6fqBR.js +300 -0
- package/dist/astro/index.d.ts +7 -7
- package/dist/astro/index.js +5 -5
- package/dist/{auth-module-CqXdm8qD.js → auth-module-DkqapRZJ.js} +1 -1
- package/dist/{authorization-D1P3VBOd.d.ts → authorization-2Rv1AJQJ.d.ts} +114 -39
- package/dist/{authorization-hooks-CxwsRnfV.d.ts → authorization-hooks-C0GfMvFm.d.ts} +8 -2
- package/dist/authz-topic-D7fPUY4P.js +13 -0
- package/dist/{availability-CebEOfMN.d.ts → availability-CZlcrkqD.d.ts} +49 -8
- package/dist/{base64-CVyKHBBw.js → base64-CEBz6-Jj.js} +9 -2
- package/dist/better-result/index.d.ts +3 -3
- package/dist/{bind-Bvv-Zrdh.d.ts → bind-C2XvMlfg.d.ts} +7 -7
- package/dist/{block-env-h_uPl2f_.d.ts → block-env-BQrtLPyc.d.ts} +4 -4
- package/dist/{block-helpers-disoUWCp.d.ts → block-helpers-BNtM1tqy.d.ts} +1 -1
- package/dist/{block-hooks-DrA_d1dJ.d.ts → block-hooks-CtMsgLQr.d.ts} +2 -2
- package/dist/{block-subjects-Br2MQNFn.d.ts → block-subjects-Bkieh2Xk.d.ts} +1 -1
- package/dist/{block-tables-pj3eHfoP.d.ts → block-tables-DPOgnT3y.d.ts} +1 -1
- package/dist/{block-transport-BEtC_Kis.d.ts → block-transport-CDmOUuLZ.d.ts} +2 -2
- package/dist/blocks/access-requests/index.d.ts +5 -5
- package/dist/blocks/activities/index.d.ts +9 -9
- package/dist/blocks/agents/index.d.ts +4 -4
- package/dist/blocks/ai-cache/index.d.ts +3 -3
- package/dist/blocks/ai-chat/index.d.ts +8 -8
- package/dist/blocks/ai-chat/index.js +80 -20
- package/dist/blocks/ai-files/index.d.ts +3 -3
- package/dist/blocks/ai-keys/index.d.ts +4 -4
- package/dist/blocks/ai-schedules/index.d.ts +3 -3
- package/dist/blocks/announcements/index.d.ts +8 -8
- package/dist/blocks/api-keys/index.d.ts +3 -3
- package/dist/blocks/approvals/index.d.ts +16 -5
- package/dist/blocks/approvals/index.js +7 -4
- package/dist/blocks/assets/index.d.ts +6 -6
- package/dist/blocks/assignment/index.d.ts +7 -7
- package/dist/blocks/attachments/index.d.ts +4 -4
- package/dist/blocks/audit/index.d.ts +13 -13
- package/dist/blocks/audit/index.js +1 -1
- package/dist/blocks/automations/index.d.ts +12 -12
- package/dist/blocks/billable-time/index.d.ts +6 -6
- package/dist/blocks/billing/index.d.ts +9 -9
- package/dist/blocks/billing/index.js +1 -1
- package/dist/blocks/bookings/index.d.ts +6 -6
- package/dist/blocks/bulk/index.d.ts +4 -4
- package/dist/blocks/calendar/index.d.ts +46 -8
- package/dist/blocks/calendar/index.js +306 -47
- package/dist/blocks/catalog/index.d.ts +39 -17
- package/dist/blocks/catalog/index.js +35 -15
- package/dist/blocks/channels/index.d.ts +7 -7
- package/dist/blocks/collections/index.d.ts +6 -6
- package/dist/blocks/comments/index.d.ts +10 -10
- package/dist/blocks/compliance/index.d.ts +5 -5
- package/dist/blocks/connectors/index.d.ts +4 -4
- package/dist/blocks/contacts/index.d.ts +6 -6
- package/dist/blocks/content/index.d.ts +5 -5
- package/dist/blocks/contracts/index.d.ts +6 -6
- package/dist/blocks/courses/index.d.ts +5 -5
- package/dist/blocks/created-by/index.d.ts +2 -2
- package/dist/blocks/custom-fields/index.d.ts +6 -6
- package/dist/blocks/data-lifecycle/index.d.ts +8 -8
- package/dist/blocks/deals/index.d.ts +6 -6
- package/dist/blocks/dispatch/index.d.ts +6 -6
- package/dist/blocks/documents/index.d.ts +4 -4
- package/dist/blocks/documents/index.js +1 -1
- package/dist/blocks/domains/index.d.ts +6 -6
- package/dist/blocks/donations/index.d.ts +6 -6
- package/dist/blocks/drive/index.d.ts +6 -6
- package/dist/blocks/employees/index.d.ts +8 -8
- package/dist/blocks/enrichment/index.d.ts +6 -6
- package/dist/blocks/enrollments/index.d.ts +74 -9
- package/dist/blocks/enrollments/index.js +67 -3
- package/dist/blocks/entitlements/index.d.ts +6 -6
- package/dist/blocks/expenses/index.d.ts +93 -6
- package/dist/blocks/expenses/index.js +95 -4
- package/dist/blocks/field-history/index.d.ts +4 -4
- package/dist/blocks/flags/index.d.ts +5 -5
- package/dist/blocks/forecasts/index.d.ts +6 -6
- package/dist/blocks/forms/index.d.ts +6 -6
- package/dist/blocks/goals/index.d.ts +4 -4
- package/dist/blocks/guests/index.d.ts +6 -6
- package/dist/blocks/hiring/index.d.ts +6 -6
- package/dist/blocks/identities/index.d.ts +5 -5
- package/dist/blocks/imports/index.d.ts +5 -5
- package/dist/blocks/inbox/index.d.ts +11 -11
- package/dist/blocks/inbox/index.js +56 -1
- package/dist/blocks/incidents/index.d.ts +5 -5
- package/dist/blocks/index.d.ts +9 -9
- package/dist/blocks/inventory/index.d.ts +6 -6
- package/dist/blocks/invoices/index.d.ts +26 -10
- package/dist/blocks/invoices/index.js +23 -7
- package/dist/blocks/knowledge/index.d.ts +4 -4
- package/dist/blocks/knowledge/index.js +1 -1
- package/dist/blocks/lead-scoring/index.d.ts +7 -7
- package/dist/blocks/leases/index.d.ts +6 -6
- package/dist/blocks/leave/index.d.ts +88 -15
- package/dist/blocks/leave/index.js +65 -14
- package/dist/blocks/ledger/index.d.ts +6 -6
- package/dist/blocks/mail-sync/index.d.ts +5 -5
- package/dist/blocks/memberships/index.d.ts +2 -2
- package/dist/blocks/memory/index.d.ts +5 -5
- package/dist/blocks/memory/index.js +30 -5
- package/dist/blocks/messaging/index.d.ts +11 -11
- package/dist/blocks/metrics/index.d.ts +6 -6
- package/dist/blocks/mfa/index.d.ts +2 -2
- package/dist/blocks/moderation/index.d.ts +6 -6
- package/dist/blocks/notifications/index.d.ts +11 -11
- package/dist/blocks/notifications/index.js +1 -1
- package/dist/blocks/numbering/index.d.ts +4 -4
- package/dist/blocks/oauth-server/index.d.ts +5 -5
- package/dist/blocks/oauth-server/index.js +1 -1
- package/dist/blocks/onboarding/index.d.ts +5 -5
- package/dist/blocks/orders/index.d.ts +7 -7
- package/dist/blocks/organizations/index.d.ts +8 -8
- package/dist/blocks/outbox/index.d.ts +4 -4
- package/dist/blocks/outbox/index.js +1 -1
- package/dist/blocks/passes/index.d.ts +8 -8
- package/dist/blocks/passes/index.js +2 -2
- package/dist/blocks/permissions/index.d.ts +7 -7
- package/dist/blocks/pipelines/index.d.ts +6 -6
- package/dist/blocks/posts/index.d.ts +5 -5
- package/dist/blocks/profiles/index.d.ts +4 -4
- package/dist/blocks/promotions/index.d.ts +5 -5
- package/dist/blocks/push/index.d.ts +7 -7
- package/dist/blocks/queue/index.d.ts +6 -6
- package/dist/blocks/queue/index.js +2 -2
- package/dist/blocks/quotes/index.d.ts +119 -27
- package/dist/blocks/quotes/index.js +111 -17
- package/dist/blocks/rank/index.d.ts +4 -4
- package/dist/blocks/reactions/index.d.ts +9 -9
- package/dist/blocks/relations/index.d.ts +7 -7
- package/dist/blocks/reminders/index.d.ts +78 -11
- package/dist/blocks/reminders/index.js +118 -6
- package/dist/blocks/reviews/index.d.ts +5 -5
- package/dist/blocks/saved-views/index.d.ts +6 -6
- package/dist/blocks/scores/index.d.ts +5 -5
- package/dist/blocks/search/index.d.ts +7 -7
- package/dist/blocks/security-events/index.d.ts +7 -7
- package/dist/blocks/security-events/index.js +1 -1
- package/dist/blocks/segments/index.d.ts +7 -7
- package/dist/blocks/sequences/index.d.ts +6 -6
- package/dist/blocks/service-accounts/index.d.ts +5 -5
- package/dist/blocks/sessions/index.d.ts +2 -2
- package/dist/blocks/sessions/index.js +1 -1
- package/dist/blocks/settings/index.d.ts +6 -6
- package/dist/blocks/share-links/index.d.ts +5 -5
- package/dist/blocks/shipments/index.d.ts +6 -6
- package/dist/blocks/shipments/index.js +1 -1
- package/dist/blocks/signatures/index.d.ts +5 -5
- package/dist/blocks/signing-keys/index.d.ts +4 -4
- package/dist/blocks/signing-keys/index.js +2 -2
- package/dist/blocks/sla/index.d.ts +7 -7
- package/dist/blocks/sso/index.d.ts +6 -6
- package/dist/blocks/state-machine/index.d.ts +27 -7
- package/dist/blocks/state-machine/index.js +7 -2
- package/dist/blocks/subjects/index.d.ts +6 -6
- package/dist/blocks/tags/index.d.ts +6 -6
- package/dist/blocks/tasks/index.d.ts +9 -9
- package/dist/blocks/teams/index.d.ts +4 -4
- package/dist/blocks/templates/index.d.ts +7 -7
- package/dist/blocks/time-tracking/index.d.ts +7 -7
- package/dist/blocks/timeline/index.d.ts +8 -8
- package/dist/blocks/trash/index.d.ts +6 -6
- package/dist/blocks/undo/index.d.ts +4 -4
- package/dist/blocks/updated-at/index.d.ts +2 -2
- package/dist/blocks/usage/index.d.ts +4 -4
- package/dist/blocks/vercel-marketplace/index.d.ts +5 -5
- package/dist/blocks/vercel-marketplace/index.js +3 -3
- package/dist/blocks/versions/index.d.ts +6 -6
- package/dist/blocks/waitlist/index.d.ts +5 -5
- package/dist/blocks/waitlist/index.js +1 -1
- package/dist/blocks/webhooks/index.d.ts +13 -13
- package/dist/blocks/webhooks/index.js +5 -5
- package/dist/blocks/workflow-editor/index.d.ts +10 -10
- package/dist/blocks/workflow-editor/index.js +65 -2
- package/dist/blocks/workflows/index.d.ts +7 -7
- package/dist/{bookings-Br0VXzaf.d.ts → bookings-Dj5cvXKv.d.ts} +4 -4
- package/dist/{bucket-DvG66r5G.d.ts → bucket-CrsJNHzi.d.ts} +1 -1
- package/dist/chat-sdk/index.d.ts +6 -6
- package/dist/claims/index.d.ts +6 -6
- package/dist/claims/index.js +2 -2
- package/dist/cli/{add-DzgsOE8V.js → add-D2CH8t_B.js} +2 -2
- package/dist/cli/add-De73Ghlh.js +1 -0
- package/dist/cli/{add-CYreXA68.js → add-Duf1-19E.js} +16 -14
- package/dist/cli/{agent-59XWXsRi.js → agent-Tqq3MAqx.js} +26 -1
- package/dist/cli/{app-table-files-BnISa3uY.js → app-table-files-ha8X0rRE.js} +2 -2
- package/dist/cli/app-tables-BIyQcsHH.js +42 -0
- package/dist/cli/{backfill-BLLTSDSa.js → backfill-CLgA6-ll.js} +3 -3
- package/dist/cli/bin.js +1 -1
- package/dist/cli/{blocks-uzh1g_0v.js → blocks-9AeouX4h.js} +2 -2
- package/dist/cli/{blocks-CpRvI7x8.js → blocks-BVB1fMMj.js} +1 -1
- package/dist/cli/{cache-BPWC7tGD.js → cache-aMk9vF1_.js} +1 -1
- package/dist/cli/{codemod-CbJVS_kG.js → codemod-B5wrcnF2.js} +113 -4
- package/dist/cli/{command-BpZ4AuhR.js → command-DM_x_yzZ.js} +6 -0
- package/dist/cli/{completion-DHTT6rjI.js → completion-CusuUJNn.js} +1 -1
- package/dist/cli/{completion-B08Q0xB3.js → completion-Cx2UYd-y.js} +2 -2
- package/dist/cli/{completion-CwL7e93t.js → completion-DbYb3N8e.js} +2 -2
- package/dist/cli/{config-D-Upz3jV.js → config-BeuImpav.js} +1 -1
- package/dist/cli/{content-mapper-Cjkm2Sg3.js → content-mapper-CEtdbshU.js} +2 -2
- package/dist/cli/{db-Diy1OebO.js → db-CeiQzhPq.js} +2 -2
- package/dist/cli/{doctor-D94FEJZs.js → doctor-DaOUWfRN.js} +386 -49
- package/dist/cli/env-BfWbheiC.js +1 -0
- package/dist/cli/{env-BAJn6wCA.js → env-DVV10l_r.js} +1 -1
- package/dist/cli/{gen-Cd0VNDjE.js → gen-BO-2NF-G.js} +14 -14
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +7 -7
- package/dist/cli/{init-Co1N9ZoA.js → init-Xit9Hnbb.js} +9 -9
- package/dist/cli/{keys-CxajkV_7.js → keys-DJTN2Avl.js} +1 -1
- package/dist/cli/{live-NFNeZsP7.js → live-CuMpyRjF.js} +2 -2
- package/dist/cli/{mcp-WZ8t7NMz.js → mcp-C7d4j5cq.js} +4 -4
- package/dist/cli/{metadata-BzMkmrZR.js → metadata-D2YvkY2D.js} +3 -3
- package/dist/cli/{migrate-C9gyDAV7.js → migrate-BCXxyTKt.js} +2 -2
- package/dist/cli/{migration-safety-BNi8PIiM.js → migration-safety-DfwTOBQ4.js} +1 -1
- package/dist/cli/{migrations-Ds0J_TmZ.js → migrations-nomh4TBo.js} +2 -2
- package/dist/cli/{module-migration-hFrlzQZ5.js → module-migration--9T_T-zt.js} +2 -2
- package/dist/cli/{moved-BAFPdJz_.js → moved-CT6i1csY.js} +1 -1
- package/dist/cli/{parse-BueItuNJ.js → parse-qgJylE_A.js} +1 -1
- package/dist/cli/{powersync-oFiwgsBi.js → powersync-DB9WZsIv.js} +4 -4
- package/dist/cli/powersync-IBM_v_eJ.js +1 -0
- package/dist/cli/{print-BtreoJSm.js → print-S6IF5rZm.js} +2 -2
- package/dist/cli/{providers-Be2dgyuR.js → providers-BDTcal71.js} +1 -1
- package/dist/cli/{prune-workflows-BPxgRrqY.js → prune-workflows-Zr2DjByi.js} +3 -3
- package/dist/cli/{remove-B4ad996E.js → remove-CPX5Tg5s.js} +6 -6
- package/dist/cli/{render-C-Mfq-o3.js → render-Bp7a7XQ9.js} +18 -4
- package/dist/cli/{run-D2nuyyPo.js → run-BclCFEyP.js} +12 -48
- package/dist/cli/{run-dY9uOC3W.js → run-BlVaLnt_.js} +2 -2
- package/dist/cli/{run-cLdnJHH0.js → run-kgG50x_Z.js} +44 -43
- package/dist/cli/{seed-BpaqqyO8.js → seed-Cn2R91cd.js} +2 -2
- package/dist/cli/seed-DGGjReq4.js +1 -0
- package/dist/cli/{shared-DCHxLAEL.js → shared-D60W9NS-.js} +1 -1
- package/dist/cli/{skills-jZThjL3B.js → skills-DH-yPDny.js} +1 -1
- package/dist/cli/{snapshot-CloKPNxv.js → snapshot-C3_eQUgY.js} +2 -2
- package/dist/cli/{source-Bwyp18Rj.js → source-Bk6XwIAK.js} +1 -1
- package/dist/cli/{spec-DsVq4_qV.js → spec-BDTpcBns.js} +1 -1
- package/dist/cli/{spec-DAUF4ybu.js → spec-C8ydQwZC.js} +3 -3
- package/dist/cli/{sql-layout-CHpEL0oq.js → sql-layout-DVQ20UMi.js} +2 -2
- package/dist/cli/{stack-147NqctC.js → stack-CmhSfY5V.js} +3 -2
- package/dist/cli/{sync-DZu1r34s.js → sync-D-WO4Yvl.js} +4 -4
- package/dist/cli/{table-D9FbJS8h.js → table-k5OABwy3.js} +1 -1
- package/dist/cli/{upgrade-Bpvi70zm.js → upgrade-DGe5Pv6v.js} +5 -5
- package/dist/cli/{upgrade-A-BALvp3.js → upgrade-XdhMuHAu.js} +3 -3
- package/dist/cli/{version-B59mZJoy.js → version-DKfeme2I.js} +1 -1
- package/dist/client/index.d.ts +6 -6
- package/dist/client/index.js +1 -1
- package/dist/client/native/index.d.ts +5 -5
- package/dist/client/native/index.js +2 -2
- package/dist/{client-Bky2z09B.js → client-DrejIxsu.js} +1 -1
- package/dist/{cloud-event-DXWmXrus.d.ts → cloud-event-BEmAUdl1.d.ts} +1 -1
- package/dist/commerce/index.js +1 -1
- package/dist/{compiler-qlXlokKn.d.ts → compiler-BOW4yPcW.d.ts} +2 -2
- package/dist/{composite-CIxjVcL1.d.ts → composite-B-oAH16L.d.ts} +7 -7
- package/dist/{composite-D2JnIiHt.js → composite-BidYZWZY.js} +3 -3
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +4 -4
- package/dist/{config-BZWSFxkG.js → config-BKxjItQ-.js} +3 -3
- package/dist/{config-DQP0IvDX.js → config-BrRlSxhx.js} +1 -1
- package/dist/{connectors-Cf2LeAuZ.d.ts → connectors-CrLRW4Ol.d.ts} +4 -4
- package/dist/{context-CderJRZf.d.ts → context-yfOlyAqb.d.ts} +3 -3
- package/dist/contract/index.d.ts +9 -9
- package/dist/{controller-DaWA9eWS.d.ts → controller-CAcLEndc.d.ts} +1 -1
- package/dist/{conversion-C9rndpEI.d.ts → conversion-s1NtB6S-.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 +4 -4
- package/dist/create/lite/index.js +2 -2
- package/dist/credentials/index.d.ts +4 -4
- package/dist/credentials/index.js +1 -1
- package/dist/{cron-route-DSITg1yC.js → cron-route-uTsC2BD0.js} +1 -1
- package/dist/{data-engine-CMENsp3d.d.ts → data-engine-CX1oYDZl.d.ts} +1 -1
- package/dist/{define-ITQA71fw.d.ts → define-BvkaC3Oh.d.ts} +5 -5
- package/dist/{define-B6D55cO0.js → define-Duh2mMYk.js} +1 -1
- package/dist/{define-block-COmMkx2x.d.ts → define-block-Ds3aLZwz.d.ts} +12 -12
- package/dist/{documents-DeZw83ue.d.ts → documents-Btk0MhC0.d.ts} +3 -3
- package/dist/edge/index.d.ts +9 -9
- package/dist/edge/index.js +7 -7
- package/dist/elysia/index.d.ts +1 -1
- package/dist/elysia/index.js +1 -1
- package/dist/{embeddings-rVR2AKVz.d.ts → embeddings-CI6P_mtD.d.ts} +1 -1
- package/dist/{ended-NC_ZesY4.d.ts → ended-iq2wp8fc.d.ts} +8 -3
- package/dist/{entitlements-BefkpQIz.d.ts → entitlements-Dhu-4vlH.d.ts} +2 -2
- package/dist/env/index.d.ts +1 -1
- package/dist/{messages-CRk1g6oe.js → errors-0Qid9fGz.js} +107 -3
- package/dist/eve/index.d.ts +9 -9
- package/dist/eve/index.js +3 -3
- package/dist/{eve-DIKjuPp5.d.ts → eve-DleYrhwj.d.ts} +2 -2
- package/dist/{event-calendar-DUtFyRrv.d.ts → event-calendar-DPMcqy7Q.d.ts} +1 -1
- package/dist/events/index.d.ts +3 -3
- package/dist/{events-DVt3Z9hw.d.ts → events-DCw3c6pj.d.ts} +1 -1
- package/dist/{executor-DqNRrFxx.d.ts → executor-B-o7QMPp.d.ts} +16 -2
- package/dist/{executor-CFmee_nV.d.ts → executor-DoSNec_H.d.ts} +1 -1
- package/dist/{executor-CHnoKOxk.d.ts → executor-H8ZLkeHj.d.ts} +4 -4
- package/dist/{executor-BDMqPbVU.js → executor-RYiR4z47.js} +71 -37
- package/dist/expo/index.d.ts +4 -4
- package/dist/expo/index.js +7 -7
- package/dist/{field-errors-D1meOs_H.d.ts → field-errors-DXZk9Qjt.d.ts} +10 -10
- package/dist/{fields-CAVk9dxX.d.ts → fields-CP46SPNE.d.ts} +1 -1
- package/dist/{filter-evaluate-Bz3Fzhz2.d.ts → filter-evaluate-Bkbb0nuQ.d.ts} +1 -1
- package/dist/{filter-query-DV-x8fio.d.ts → filter-query-Xj40B5KT.d.ts} +1 -1
- package/dist/{flags-6emyAXly.d.ts → flags-Cuew4tGx.d.ts} +2 -2
- package/dist/flags-sdk/index.d.ts +2 -2
- package/dist/{framework-BFlaPuvv.d.ts → framework-Byr_j8G-.d.ts} +8 -8
- package/dist/{framework-ChzJYkJW.js → framework-z3KTPRjk.js} +4 -4
- package/dist/{gateway-DaekJ_Me.d.ts → gateway-B9k89AC4.d.ts} +3 -3
- 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 +9 -10
- package/dist/hono/index.js +8 -8
- package/dist/{inbox-DavCzW7b.d.ts → inbox-yGfUVQr2.d.ts} +61 -6
- package/dist/{index-Dvpu22CJ.d.ts → index-1uV69AZq.d.ts} +1 -1
- package/dist/{index-BbDiBiKt.d.ts → index-6H-8Ib1w.d.ts} +4 -4
- package/dist/{index-M1izbwbN.d.ts → index-Ag-T51Jl.d.ts} +1 -1
- package/dist/{index-ZQZMQF4l.d.ts → index-BUluRi0b.d.ts} +6 -6
- package/dist/{index-BQlLxOj5.d.ts → index-C78VPlXW.d.ts} +1 -1
- package/dist/{index-D18su_r5.d.ts → index-CY612vAg.d.ts} +10 -5
- package/dist/{index-DXUiRyEk.d.ts → index-CnzGRpeH.d.ts} +5 -5
- package/dist/{index-BIAtapnD.d.ts → index-Dbd1E5Au.d.ts} +5 -5
- package/dist/{index-ChLuLxy-.d.ts → index-Dv6lfL5p.d.ts} +14 -14
- package/dist/{index-8w4OB5En.d.ts → index-F6lsRlsr.d.ts} +1 -1
- package/dist/{index-D9aV0Fvx.d.ts → index-kkZwp5M1.d.ts} +6 -6
- package/dist/{index-C13UgV67.d.ts → index-lMApFSAd.d.ts} +5 -5
- package/dist/index.d.ts +7 -7
- package/dist/index.js +1 -1
- package/dist/{instances-D9YrkoAy.js → instances-xQ2lupVE.js} +218 -11
- package/dist/jwks-cache-CBKtICNV.js +114 -0
- package/dist/{jws-B8p0ppgh.js → jws-De9qjIPV.js} +1 -1
- package/dist/{kit-9pZP5iLU.js → kit-D5rRAKWJ.js} +2 -2
- package/dist/{kit-OgFOW9rX.d.ts → kit-DCuO1ZhB.d.ts} +4 -4
- package/dist/{knowledge-DdZzUTQ-.js → knowledge-CJnZOaix.js} +67 -7
- package/dist/{knowledge-BBC2sfAY.d.ts → knowledge-DWXAxvkN.d.ts} +82 -11
- package/dist/lint/index.d.ts +1 -1
- package/dist/list/index.d.ts +3 -3
- package/dist/{list-query-C7V8kUaD.d.ts → list-query-D1h3Dmnk.d.ts} +3 -3
- package/dist/mapper/bin.js +5 -5
- package/dist/mcp/index.d.ts +3 -3
- package/dist/mcp/index.js +5 -5
- package/dist/mcp/sdk/index.d.ts +6 -6
- package/dist/mcp/sdk/index.js +2 -2
- package/dist/{messaging-D5z2TR37.d.ts → messaging-Bfe4p9Pm.d.ts} +4 -4
- package/dist/{model-messages-BcrkjsPE.js → model-messages-CIHqP7Z3.js} +1 -1
- 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 +331 -79
- package/dist/next/index.js +520 -105
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +1 -1
- package/dist/{operations-t_hlXkS4.d.ts → operations-SWpzGC_K.d.ts} +1 -1
- package/dist/{options-D4dxMGHF.js → options-Bgnm4pTD.js} +1 -0
- package/dist/{options-C13-dVMH.js → options-D-jiqb0l.js} +2 -0
- package/dist/{options-C9bp3SEA.js → options-DqmTs2nv.js} +2 -1
- package/dist/{options-CuPWezcV.js → options-RYbyaVhv.js} +3 -1
- package/dist/options-SOjQVgfS.js +37 -0
- package/dist/{options-JnPEVbBJ.js → options-ScQ6Hnxo.js} +2 -1
- package/dist/{options-CuaWhsQS.js → options-X61tvckX.js} +2 -1
- package/dist/orpc/index.d.ts +8 -8
- package/dist/orpc/index.js +6 -6
- package/dist/otel/index.d.ts +2 -2
- package/dist/otel/index.js +4 -4
- package/dist/{outbox-7zgh-7nw.d.ts → outbox-BFZS6Kvz.d.ts} +4 -4
- package/dist/{permissions-C8p6RlIZ.d.ts → permissions-2UlVQDzY.d.ts} +1 -1
- package/dist/{pool-D-4HyhuW.d.ts → pool-yO-LzZAd.d.ts} +3 -3
- package/dist/{ports-CmEXVqhg.js → ports-CkygVOeE.js} +2 -2
- package/dist/{ports-C-8uduFM.d.ts → ports-prqYrReN.d.ts} +1 -1
- package/dist/postgres/index.d.ts +4 -4
- package/dist/{postgrest-DZtM2nIS.d.ts → postgrest-Bjain6nf.d.ts} +1 -1
- package/dist/powersync/index.d.ts +6 -6
- package/dist/preset/index.d.ts +3 -3
- package/dist/preset/index.js +3 -3
- package/dist/{preset-B_sSI9vg.js → preset-BvHNleCo.js} +2 -2
- package/dist/{project-DVlXQGEp.js → project-CBvowdKY.js} +5 -5
- package/dist/{provider-BI0KC4u5.d.ts → provider-bIAzxVMB.d.ts} +1 -1
- package/dist/{push-token-D41lOoE8.d.ts → push-token-DtqJeg8w.d.ts} +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/{rate-limit-CRhlLFhP.js → rate-limit-BJ4EMdAy.js} +1 -1
- package/dist/react/index.d.ts +9 -9
- package/dist/react/index.js +3 -3
- package/dist/react/native/index.d.ts +1 -1
- package/dist/react/native/index.js +1 -1
- package/dist/react/server.d.ts +9 -9
- package/dist/react/server.js +2 -2
- package/dist/react/session.d.ts +2 -32
- package/dist/react/session.js +1 -37
- package/dist/{react-COIov1yC.js → react-DZ7AW2yf.js} +2 -2
- package/dist/react-router/index.d.ts +6 -6
- package/dist/react-router/index.js +5 -5
- package/dist/realtime/index.d.ts +6 -6
- package/dist/{record-form-DU2EoVsv.d.ts → record-form-BQA-lawE.d.ts} +1 -1
- package/dist/{recordings-D69Va7gP.d.ts → recordings-Bw5LoocX.d.ts} +1 -1
- package/dist/records/index.d.ts +9 -9
- package/dist/{refusal-CGi-0Q18.d.ts → refusal-BX1EvmpJ.d.ts} +3 -3
- package/dist/{refusal-5c6UMpUP.js → refusal-rnbr6RZD.js} +2 -2
- package/dist/{refresh-B8t_KE3s.js → request-kind-tNDM5Z_o.js} +15 -31
- package/dist/{resolve--LfVoOMg.d.ts → resolve-BIpQRhvF.d.ts} +97 -36
- package/dist/{resolve-FW8oeXvh.js → resolve-CZV31iCm.js} +402 -392
- package/dist/{resolved-names-h-3UbKcw.js → resolved-names-b6P2--jK.js} +1 -1
- package/dist/{resource-BbWk4hoP.js → resource-COaS9_i8.js} +1 -1
- package/dist/{resource-DWllVW8k.d.ts → resource-CaYpB07K.d.ts} +1 -1
- package/dist/{resource-execute-DUBYKTYU.d.ts → resource-execute-A1NbR-sd.d.ts} +2 -2
- package/dist/{resource-types-RgaljPs0.d.ts → resource-types-CTcc37WL.d.ts} +4 -4
- package/dist/{resources-Bki1J4jy.d.ts → resources-13ZFX1G6.d.ts} +2 -2
- package/dist/{resources-DYSx9NYM.js → resources-DhiK3yLO.js} +1 -1
- package/dist/{respond-DLH4tD2d.js → respond-8A3EOo61.js} +1 -1
- package/dist/{respond-BYOV7KZp.d.ts → respond-CAxhkwAi.d.ts} +15 -19
- package/dist/{sales-lines-DuNVoKHA.d.ts → sales-lines-wQHuL-pa.d.ts} +1 -1
- package/dist/{sandboxes-B2hBoBvJ.d.ts → sandboxes-BF9RxxCU.d.ts} +1 -1
- package/dist/{scores-FAORS4qU.d.ts → scores-Ce8MxQX9.d.ts} +5 -5
- package/dist/server/index.d.ts +58 -36
- package/dist/server/index.js +35 -41
- package/dist/{server-types-C2hlvhP4.d.ts → server-types-DEjva0MW.d.ts} +19 -17
- package/dist/{session-B4VasaAA.d.ts → session-BA0YDmjt.d.ts} +11 -12
- package/dist/session-BjPYE4dT.js +180 -0
- package/dist/session-CeYL3EPm.d.ts +77 -0
- package/dist/{session-status-D8CBxCqv.d.ts → session-status-Df6tuKY9.d.ts} +4 -3
- package/dist/{sign-in-CX1a5i2P.d.ts → sign-in-4u4vLtXG.d.ts} +16 -4
- package/dist/{sign-in-CxdoTEp5.js → sign-in-djgvab1X.js} +3 -3
- package/dist/{sign-in-BMm1xhKq.js → sign-in-k2lXELeC.js} +2 -2
- package/dist/{signatures-CBn7w4VR.js → signatures-DK01D2S7.js} +1 -1
- package/dist/{signers-6ih6i9aq.d.ts → signers-Dw9DBZjJ.d.ts} +4 -4
- package/dist/{signing-keys-De09WNJ3.d.ts → signing-keys-FglIQ6iL.d.ts} +2 -2
- package/dist/{signing-keys-BC5_hJN5.js → signing-keys-sGaXklwD.js} +1 -1
- package/dist/{snapshot-CVMSyTHH.js → snapshot-BOA7lkRg.js} +9 -17
- package/dist/solid/index.d.ts +10 -10
- package/dist/solid/index.js +1 -1
- package/dist/solid-start/index.d.ts +6 -6
- package/dist/solid-start/index.js +5 -5
- package/dist/spec/index.d.ts +2 -2
- package/dist/sql/index.d.ts +5 -5
- package/dist/sql/index.js +3 -3
- package/dist/{sql-C9nO-Mat.js → sql-BChN3Hxv.js} +7382 -2219
- package/dist/sqlite/index.d.ts +3 -3
- package/dist/{sso-CuzAjsc8.d.ts → sso-B7w7h8RJ.d.ts} +3 -3
- package/dist/ssr/index.d.ts +5 -6
- package/dist/ssr/index.js +3 -3
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +1 -1
- package/dist/streams/index.d.ts +1 -1
- package/dist/{subject-readers-BlD8tALG.d.ts → subject-readers-YL8H9G8X.d.ts} +2 -2
- package/dist/{subjects-Bv2dPflD.d.ts → subjects-CVjAE7nz.d.ts} +3 -3
- package/dist/{support-DxYI6sDM.d.ts → support-BwtMgjVg.d.ts} +4 -4
- package/dist/{support-view-DSmCett7.d.ts → support-view-GykHOIQ2.d.ts} +1 -1
- package/dist/svelte/index.d.ts +9 -9
- package/dist/svelte/index.js +1 -1
- package/dist/sveltekit/index.d.ts +7 -7
- package/dist/sveltekit/index.js +5 -5
- package/dist/{tags--k2fbPfO.d.ts → tags-CAfvzA1U.d.ts} +1 -1
- package/dist/tanstack-db/index.d.ts +3 -3
- package/dist/tanstack-start/index.d.ts +6 -6
- package/dist/tanstack-start/index.js +5 -5
- package/dist/{tenant-gezshhcs.d.ts → tenant-lBgoqg9T.d.ts} +1 -1
- package/dist/testing/index.d.ts +27 -28
- package/dist/testing/index.js +5 -5
- package/dist/{timeline-Bq658xsi.d.ts → timeline-CrO48Qa6.d.ts} +5 -5
- package/dist/{topic-BVq5RdsI.d.ts → topic-x-mrN_Ff.d.ts} +5 -5
- package/dist/{types-C8UyJOPJ.d.ts → types-6PMaLIyw.d.ts} +3 -3
- package/dist/{types-Dh2OGEW5.d.ts → types-BdhE7I8Z.d.ts} +5 -5
- package/dist/{types-BkYEUWdz.d.ts → types-BzIYSSWK.d.ts} +16 -1
- package/dist/{types-DCoqai8o.d.ts → types-C7K8mu9B.d.ts} +45 -15
- package/dist/{types-d0JBRTAg.d.ts → types-C9XfFGmA.d.ts} +128 -13
- package/dist/{types-hTj5OuFo.d.ts → types-CJqNGQKb.d.ts} +2 -2
- package/dist/{types-TH3zlMiM.d.ts → types-D5uf0l4_.d.ts} +1 -1
- package/dist/{types-BBqP9H6w.d.ts → types-auvHrNWC.d.ts} +4 -4
- package/dist/{undo-22ofP6Zp.d.ts → undo-CdKp5_2X.d.ts} +2 -2
- package/dist/{usage-CNCT6_3D.d.ts → usage-DZ8j5Tm_.d.ts} +4 -4
- package/dist/{vault-yGQD5Rdl.d.ts → vault-DjbG4XQS.d.ts} +2 -2
- package/dist/vercel-connect/index.d.ts +1 -1
- package/dist/vercel-sandbox/index.d.ts +2 -2
- package/dist/{verify-DY_j4GPZ.js → verify-96j8d5ps.js} +1 -1
- package/dist/{verify-BQu3eBNW.d.ts → verify-HOiu3lRR.d.ts} +2 -2
- package/dist/{view-BfEqjZJ_.js → view-Ch0Qtr36.js} +1 -1
- package/dist/{view-Cy2XxYp1.d.ts → view-DdDY88SC.d.ts} +1 -1
- package/dist/vue/index.d.ts +10 -10
- package/dist/vue/index.js +1 -1
- package/dist/{watch-topic-BOclyLFd.d.ts → watch-topic-D6bcqOrJ.d.ts} +1 -1
- package/dist/workflow-sdk/builder/index.d.ts +29 -5
- package/dist/workflow-sdk/builder/index.js +39 -12
- package/dist/workflow-sdk/index.d.ts +1 -1
- package/dist/workflow-sdk/index.js +2 -2
- package/dist/workflow-sdk/world/index.d.ts +1 -1
- package/dist/workflow-sdk/world/index.js +1 -1
- package/dist/{workflow-sdk-BL3wzkdp.js → workflow-sdk-CBS8L2Ku.js} +5 -0
- package/dist/{workflow-sdk-yIkECybp.d.ts → workflow-sdk-D3H10W5h.d.ts} +3 -3
- package/dist/{workflows-BljkWRxE.d.ts → workflows-BI4yKqFh.d.ts} +3 -3
- package/dist/yjs/index.d.ts +2 -2
- package/dist/yjs/index.js +1 -1
- package/package.json +1 -1
- package/schemas/config-v1.json +126 -0
- package/schemas/doctor-report-v1.json +4 -0
- package/skills/better-supabase-auth/SKILL.md +45 -11
- package/dist/cli/add-BaB3y1lv.js +0 -1
- package/dist/cli/env-UN6PJFX6.js +0 -1
- package/dist/cli/powersync-J2Kms2NT.js +0 -1
- package/dist/cli/seed-ByLneY1H.js +0 -1
- package/dist/errors-D3-4c-XF.js +0 -102
- package/dist/http-BDC1IvBX.js +0 -27
- package/dist/jwks-cache-IZaiICAV.js +0 -48
- package/dist/options-Itq7QYoW.js +0 -20
- package/dist/refresh-BtbC2rZe.d.ts +0 -52
- package/dist/snapshot-BGsJw9xn.d.ts +0 -83
package/dist/next/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as DbException } from "../db-exception-Dv18UZ-I.js";
|
|
2
2
|
import { n as dbError } from "../errors-B7tCfCvX.js";
|
|
3
|
-
import { t as isList } from "../guards-CsRa6v57.js";
|
|
3
|
+
import { n as isRecord, t as isList } from "../guards-CsRa6v57.js";
|
|
4
4
|
import { t as isStorageApi } from "../storage-api-COQr77e8.js";
|
|
5
5
|
import { a as ok, r as err } from "../result-8xza7w5W.js";
|
|
6
6
|
import { o as isReadSet } from "../read-set-DEDoIHMM.js";
|
|
@@ -15,25 +15,57 @@ import { n as methodOf } from "../block-method-DIbWG4Mj.js";
|
|
|
15
15
|
import { t as tenantOf } from "../tenant-Beqd7TTq.js";
|
|
16
16
|
import { t as loadTimeline } from "../timeline-Bs-FGMIJ.js";
|
|
17
17
|
import { r as permissionsOf } from "../permissions-BDt27oYF.js";
|
|
18
|
-
import { a as sessionCacheKey, i as issuedAtOf, n as authzVersionOf, r as isSessionSnapshot, s as snapshotOf, t as authOfSnapshot } from "../snapshot-
|
|
19
|
-
import { i as toSession, s as checkAal } from "../view-
|
|
20
|
-
import { c as extendServer, n as flushEvents, p as supportCookieMaxAge, r as handle, s as createServer, t as bearerRequest, v as outageResponse, x as serverCore } from "../adapter-
|
|
21
|
-
import { t as
|
|
22
|
-
import { d as
|
|
23
|
-
import { i as guard, n as defaultExpose, s as settle } from "../respond-
|
|
24
|
-
import { a as needsMfa, c as pkceGrant, d as safeRedirectPath, f as supportSessions, i as mfaGrant, l as pkcePair, n as emailFlow, o as otpGrant, r as isExistingAccount, s as passwordGrant, t as authorizeUrlFor, u as revokeSession } from "../sign-in-
|
|
25
|
-
import { i as defineAction } from "../resource-
|
|
18
|
+
import { a as sessionCacheKey, i as issuedAtOf, n as authzVersionOf, r as isSessionSnapshot, s as snapshotOf, t as authOfSnapshot } from "../snapshot-BOA7lkRg.js";
|
|
19
|
+
import { i as toSession, s as checkAal } from "../view-Ch0Qtr36.js";
|
|
20
|
+
import { c as extendServer, n as flushEvents, p as supportCookieMaxAge, r as handle, s as createServer, t as bearerRequest, v as outageResponse, x as serverCore } from "../adapter-ddQ9Hzka.js";
|
|
21
|
+
import { t as isDocumentLoad } from "../request-kind-tNDM5Z_o.js";
|
|
22
|
+
import { d as sessionCookieName, f as writeSession, o as clearCookieSession, s as applyCookieWrites, t as clientIp } from "../resolve-CZV31iCm.js";
|
|
23
|
+
import { i as guard, n as defaultExpose, s as settle } from "../respond-8A3EOo61.js";
|
|
24
|
+
import { a as needsMfa, c as pkceGrant, d as safeRedirectPath, f as supportSessions, i as mfaGrant, l as pkcePair, n as emailFlow, o as otpGrant, r as isExistingAccount, s as passwordGrant, t as authorizeUrlFor, u as revokeSession } from "../sign-in-k2lXELeC.js";
|
|
25
|
+
import { i as defineAction } from "../resource-COaS9_i8.js";
|
|
26
26
|
import { r as tagFor, t as cacheTagsOf } from "../tags-CW-KvjdL.js";
|
|
27
|
-
import { i as requireCaller, n as formDataObject, t as authorizeCaller } from "../kit-
|
|
27
|
+
import { i as requireCaller, n as formDataObject, t as authorizeCaller } from "../kit-D5rRAKWJ.js";
|
|
28
28
|
import { t as withExtra } from "../extra-Dz9n5y1s.js";
|
|
29
|
-
import { n as resourceRouter } from "../resources-
|
|
29
|
+
import { n as resourceRouter } from "../resources-DhiK3yLO.js";
|
|
30
|
+
import { a as toResponse, n as bufferInPlace, t as around } from "../shared-Ci1g9nl4.js";
|
|
30
31
|
import { cache } from "react";
|
|
31
32
|
import { cacheLife, cacheTag, io, revalidateTag, updateTag } from "next/cache.js";
|
|
33
|
+
import { redirect } from "next/dist/client/components/redirect.js";
|
|
32
34
|
import { cookies, headers } from "next/headers.js";
|
|
33
35
|
import { NextResponse, after } from "next/server.js";
|
|
34
36
|
import { forbidden } from "next/dist/client/components/forbidden.js";
|
|
35
37
|
import { notFound } from "next/dist/client/components/not-found.js";
|
|
36
38
|
import { unauthorized } from "next/dist/client/components/unauthorized.js";
|
|
39
|
+
// src/next/bootstrap.ts
|
|
40
|
+
/**
|
|
41
|
+
* The schema a `bsb.bootstrap()` call targets: the call's, then
|
|
42
|
+
* `bootstrapSchema`, then the one `gen` recorded, else `better_supabase`.
|
|
43
|
+
*/
|
|
44
|
+
function bootstrapSchema(call, options, owner) {
|
|
45
|
+
return call.schema ?? options.bootstrapSchema ?? owner.meta.bootstrap?.schema ?? "better_supabase";
|
|
46
|
+
}
|
|
47
|
+
/** Calls `<schema>.bootstrap_<rpc>(args)` and checks the row it returns. */
|
|
48
|
+
async function runBootstrap(executor, schema, rpc, args) {
|
|
49
|
+
if (!executor.rpc) throw new DbException(dbError("unsupported", "bsb.bootstrap() needs an executor that calls functions"));
|
|
50
|
+
const result = await executor.rpc(`bootstrap_${rpc}`, { args }, {
|
|
51
|
+
schema,
|
|
52
|
+
errorMappers: []
|
|
53
|
+
});
|
|
54
|
+
if (!result.ok) throw new DbException(result.error);
|
|
55
|
+
return bootstrapRow(result.data);
|
|
56
|
+
}
|
|
57
|
+
/** The wrapper's jsonb, checked: a row the wrapper didn't write throws. */
|
|
58
|
+
function bootstrapRow(value) {
|
|
59
|
+
if (!isRecord(value) || typeof value["session_active"] !== "boolean") throw new DbException(dbError("unexpected", "The bootstrap wrapper returned no session_active"));
|
|
60
|
+
const version = value["authz_version"];
|
|
61
|
+
const tenant = value["tenant"];
|
|
62
|
+
return {
|
|
63
|
+
sessionActive: value["session_active"],
|
|
64
|
+
authzVersion: typeof version === "number" ? version : typeof version === "string" && /^\d+$/.test(version) ? Number(version) : null,
|
|
65
|
+
tenant: typeof tenant === "string" ? tenant : null,
|
|
66
|
+
data: value["data"] ?? null
|
|
67
|
+
};
|
|
68
|
+
}
|
|
37
69
|
// src/next/cache.ts
|
|
38
70
|
/** The tag `bsb.cached()` adds to entries rendered in a support session. */
|
|
39
71
|
function supportTag(sessionId) {
|
|
@@ -41,28 +73,55 @@ function supportTag(sessionId) {
|
|
|
41
73
|
}
|
|
42
74
|
/** The shortest time the Next.js client router keeps a prefetched entry. */
|
|
43
75
|
const MIN_CLIENT_STALE = 30;
|
|
76
|
+
/** The shortest `stale` a private entry needs to ride in the App Shell. */
|
|
77
|
+
const APP_SHELL_STALE = 300;
|
|
78
|
+
/** `"use cache: remote"` lifetimes when `life` leaves them unset. */
|
|
79
|
+
const REMOTE_LIFE = {
|
|
80
|
+
revalidate: 300,
|
|
81
|
+
expire: 3600
|
|
82
|
+
};
|
|
83
|
+
const warned = /* @__PURE__ */ new Set();
|
|
84
|
+
/** Logs `message` once per process. */
|
|
85
|
+
function warnOnce(warn, message) {
|
|
86
|
+
if (!warned.has(message)) {
|
|
87
|
+
warned.add(message);
|
|
88
|
+
warn(message);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
44
91
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* signed-out view that a refresh would change (an `expired` or `refresh_failed`
|
|
48
|
-
* cookie, or an `invalid` token) is 0 as well, so it never joins the App
|
|
49
|
-
* Shell.
|
|
92
|
+
* Whether a refresh or a sign-in would change the view, so no shell may keep
|
|
93
|
+
* it.
|
|
50
94
|
*/
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
95
|
+
function changesOnRefresh(session) {
|
|
96
|
+
return session.kind === "invalid" || session.kind === "none" && (session.reason === "expired" || session.reason === "refresh_failed");
|
|
97
|
+
}
|
|
98
|
+
/** Seconds left on the token, or `undefined` for a view without one. */
|
|
99
|
+
function tokenSecondsLeft(session, now) {
|
|
100
|
+
return session.kind === "user" && session.expiresAt !== null ? session.expiresAt - Math.floor(now / 1e3) : void 0;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The `cacheLife` of a `bsb.cached()` entry. `stale` is `life.stale`, else 300
|
|
104
|
+
* seconds, so the entry rides in the App Shell; the token's lifetime caps it
|
|
105
|
+
* only with `capToToken`, because the proxy refreshes prefetches and the
|
|
106
|
+
* session tags are evicted on sign-out. A view that a refresh would change (an
|
|
107
|
+
* `expired` or `refresh_failed` cookie, an `invalid` token) is 0. Remote
|
|
108
|
+
* entries default to `revalidate` 300 and `expire` 3600. In development a
|
|
109
|
+
* `stale` below 300 warns that the entry leaves the App Shell, and below 30
|
|
110
|
+
* that it leaves the prerender.
|
|
111
|
+
*/
|
|
112
|
+
function cachedLife(session, scope, life = {}, options = {}) {
|
|
113
|
+
const { warn } = options;
|
|
114
|
+
if (warn && life.stale !== void 0 && life.stale < APP_SHELL_STALE) warnOnce(warn, life.stale < MIN_CLIENT_STALE ? `bsb.cached(): life.stale ${String(life.stale)} is below 30 seconds, so the entry leaves the prerender and renders on every request` : `bsb.cached(): life.stale ${String(life.stale)} is below 300 seconds, so the entry leaves the App Shell and instant navigations wait for it`);
|
|
115
|
+
let stale = changesOnRefresh(session) ? 0 : life.stale ?? APP_SHELL_STALE;
|
|
116
|
+
const left = life.capToToken ? tokenSecondsLeft(session, options.now ?? Date.now()) : void 0;
|
|
117
|
+
if (left !== void 0) stale = left < MIN_CLIENT_STALE ? 0 : Math.min(stale, left);
|
|
118
|
+
const revalidate = life.revalidate ?? (scope === "remote" ? REMOTE_LIFE.revalidate : void 0);
|
|
119
|
+
const expire = life.expire ?? (scope === "remote" ? REMOTE_LIFE.expire : void 0);
|
|
120
|
+
return {
|
|
121
|
+
stale,
|
|
122
|
+
...revalidate === void 0 ? {} : { revalidate },
|
|
123
|
+
...expire === void 0 ? {} : { expire }
|
|
124
|
+
};
|
|
66
125
|
}
|
|
67
126
|
/** The tag `bsb.cached()` puts on a user's entries. */
|
|
68
127
|
function sessionTag(userId) {
|
|
@@ -455,6 +514,56 @@ function recordListServer(bsb, recordList) {
|
|
|
455
514
|
} : result;
|
|
456
515
|
} };
|
|
457
516
|
}
|
|
517
|
+
// src/next/remote-handoff.ts
|
|
518
|
+
const HANDOFFS = Symbol.for("better-supabase.remote-handoffs");
|
|
519
|
+
/**
|
|
520
|
+
* The handoff slot, on `globalThis` so the proxy's and the render's module
|
|
521
|
+
* graphs share it.
|
|
522
|
+
*/
|
|
523
|
+
function handoffs() {
|
|
524
|
+
const scope = globalThis;
|
|
525
|
+
scope[HANDOFFS] ??= /* @__PURE__ */ new Map();
|
|
526
|
+
return scope[HANDOFFS];
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* The handoff entry for a key. It holds only what the key parts name, so a
|
|
530
|
+
* token registered under it belongs to that user and session.
|
|
531
|
+
*/
|
|
532
|
+
function handoffKey(key) {
|
|
533
|
+
const owner = key.shared === null ? `${key.userId ?? "-"}:${key.sessionId ?? "*"}:${String(key.authzVersion ?? 0)}` : `key:${key.shared}`;
|
|
534
|
+
return key.support === null ? owner : `${owner}:support:${key.support}`;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Registers the caller's verified snapshot for one call and returns its
|
|
538
|
+
* release. Concurrent calls under one key count up, so the first to finish
|
|
539
|
+
* leaves the token for the others.
|
|
540
|
+
*/
|
|
541
|
+
function handOff(key, snapshot) {
|
|
542
|
+
const slot = handoffKey(key);
|
|
543
|
+
const map = handoffs();
|
|
544
|
+
const entry = map.get(slot);
|
|
545
|
+
if (entry) {
|
|
546
|
+
entry.count += 1;
|
|
547
|
+
entry.snapshot = snapshot;
|
|
548
|
+
} else map.set(slot, {
|
|
549
|
+
snapshot,
|
|
550
|
+
count: 1
|
|
551
|
+
});
|
|
552
|
+
let released = false;
|
|
553
|
+
return () => {
|
|
554
|
+
if (released) return;
|
|
555
|
+
released = true;
|
|
556
|
+
const current = map.get(slot);
|
|
557
|
+
if (current) {
|
|
558
|
+
current.count -= 1;
|
|
559
|
+
if (current.count <= 0) map.delete(slot);
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
/** The snapshot a running call registered under the key. */
|
|
564
|
+
function takeHandoff(key) {
|
|
565
|
+
return handoffs().get(handoffKey(key))?.snapshot;
|
|
566
|
+
}
|
|
458
567
|
// src/next/resources.ts
|
|
459
568
|
/** One handler for every method; the resource router picks the operation. */
|
|
460
569
|
function resourceRoutes(serve) {
|
|
@@ -466,9 +575,39 @@ function resourceRoutes(serve) {
|
|
|
466
575
|
DELETE: serve
|
|
467
576
|
};
|
|
468
577
|
}
|
|
578
|
+
// src/next/session-tags.ts
|
|
579
|
+
/** The user's session tag and the authorization provider's tags for them. */
|
|
580
|
+
function userSessionTags(hooks, userId) {
|
|
581
|
+
return [sessionTag(userId), ...hooks?.sessionTags?.(userId) ?? []];
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Drops the caller's own cached entries and evicts them from the version cache.
|
|
585
|
+
* Only the caller's verified snapshot decides whose, so the action is safe to
|
|
586
|
+
* expose.
|
|
587
|
+
*/
|
|
588
|
+
async function refreshCallerCache(snapshot, server) {
|
|
589
|
+
if (!snapshot) return;
|
|
590
|
+
invalidateAll([...userSessionTags(server.authorization, snapshot.userId), ...snapshot.sessionId === null ? [] : [sessionIdTag(snapshot.sessionId)]]);
|
|
591
|
+
await server.evictSession(snapshot.userId);
|
|
592
|
+
}
|
|
469
593
|
// src/next/sign-in.ts
|
|
470
594
|
/** How long the PKCE verifier cookie lives, in seconds. */
|
|
471
595
|
const VERIFIER_MAX_AGE = 600;
|
|
596
|
+
/**
|
|
597
|
+
* Where to send the user after signing in: the `next` value of the search
|
|
598
|
+
* params (a `URLSearchParams`, a page's `searchParams` object or a request)
|
|
599
|
+
* when it is a same-origin path, else `fallback`.
|
|
600
|
+
*
|
|
601
|
+
* ```ts
|
|
602
|
+
* redirect(postAuthPath(await searchParams, "/dashboard"));
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
function postAuthPath(source, fallback) {
|
|
606
|
+
if (source instanceof Request) return safeRedirectPath(new URL(source.url).searchParams.get("next"), fallback);
|
|
607
|
+
if (source instanceof URLSearchParams) return safeRedirectPath(source.get("next"), fallback);
|
|
608
|
+
const next = source["next"];
|
|
609
|
+
return safeRedirectPath(typeof next === "string" ? next : next?.[0], fallback);
|
|
610
|
+
}
|
|
472
611
|
function refused(auth) {
|
|
473
612
|
return {
|
|
474
613
|
ok: false,
|
|
@@ -548,7 +687,12 @@ function authFlows(deps) {
|
|
|
548
687
|
if (stored && resolution.auth.kind !== "user") return refused(resolution.auth);
|
|
549
688
|
const jar = await deps.jar();
|
|
550
689
|
const existing = jar.getAll();
|
|
551
|
-
const writes =
|
|
690
|
+
const writes = stored ? writeSession(existing, cookieName(), stored, auth?.cookie?.options, auth?.cookie?.encode === void 0 ? {} : { encode: auth.cookie.encode }) : (await clearCookieSession({
|
|
691
|
+
cookieName: cookieName(),
|
|
692
|
+
cookies: existing,
|
|
693
|
+
...auth?.cookie?.options ? { cookieOptions: auth.cookie.options } : {},
|
|
694
|
+
scopes: deps.cookieScopes ?? []
|
|
695
|
+
})).writes;
|
|
552
696
|
for (const write of writes) jar.set(write.name, write.value, write.options);
|
|
553
697
|
const headers = new Headers((await deps.request()).headers);
|
|
554
698
|
headers.set("cookie", applyCookieWrites(existing, writes).map((cookie) => `${cookie.name}=${encodeURIComponent(cookie.value)}`).join("; "));
|
|
@@ -666,31 +810,15 @@ function endedRedirect(request, path, reason) {
|
|
|
666
810
|
target.searchParams.set("reason", reason);
|
|
667
811
|
return NextResponse.redirect(target);
|
|
668
812
|
}
|
|
669
|
-
function shouldCheckSession(request, options = {}) {
|
|
670
|
-
if (request.method !== "GET" && request.method !== "HEAD") return false;
|
|
671
|
-
if (isPrefetch(request) || !isDocument(request)) return false;
|
|
672
|
-
return options.paths?.includes(request.nextUrl.pathname) ?? true;
|
|
673
|
-
}
|
|
674
|
-
/** A top-level page load, not an RSC request, a fetch or an iframe. */
|
|
675
|
-
function isDocument(request) {
|
|
676
|
-
const h = request.headers;
|
|
677
|
-
if (h.get("rsc") === "1") return false;
|
|
678
|
-
const dest = h.get("sec-fetch-dest");
|
|
679
|
-
if (dest) return dest === "document";
|
|
680
|
-
return h.get("accept")?.includes("text/html") ?? false;
|
|
681
|
-
}
|
|
682
813
|
/**
|
|
683
|
-
*
|
|
684
|
-
*
|
|
814
|
+
* Whether the proxy asks Auth if the session still exists: top-level document
|
|
815
|
+
* loads (`sec-fetch-dest: document`) on `options.paths`, else on every path.
|
|
816
|
+
* Next.js strips its router headers before the proxy runs, so client
|
|
817
|
+
* navigations and prefetches are told apart by the browser's own headers.
|
|
685
818
|
*/
|
|
686
|
-
function
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
if (isPrefetch(request)) return false;
|
|
690
|
-
if (h.get("rsc") === "1") return true;
|
|
691
|
-
const dest = h.get("sec-fetch-dest");
|
|
692
|
-
if (dest) return dest === "document";
|
|
693
|
-
return h.get("accept")?.includes("text/html") ?? false;
|
|
819
|
+
function shouldCheckSession(request, options = {}) {
|
|
820
|
+
if (!isDocumentLoad(request)) return false;
|
|
821
|
+
return options.paths?.includes(request.nextUrl.pathname) ?? true;
|
|
694
822
|
}
|
|
695
823
|
/**
|
|
696
824
|
* A `proxy` `protect` that keeps signed-in users below `level` out of the
|
|
@@ -792,6 +920,7 @@ function createNext(betterSupabase, options = {}) {
|
|
|
792
920
|
await cookies();
|
|
793
921
|
return incomingRequest();
|
|
794
922
|
};
|
|
923
|
+
const userTags = (userId) => userSessionTags(base.authorization, userId);
|
|
795
924
|
const forget = (userId) => {
|
|
796
925
|
base.evictSession(userId).catch((cause) => {
|
|
797
926
|
betterSupabase.events.logger.warn("Could not evict the user's session", { cause });
|
|
@@ -827,6 +956,18 @@ function createNext(betterSupabase, options = {}) {
|
|
|
827
956
|
});
|
|
828
957
|
const getClaims = () => getClaimsAt(box().generation);
|
|
829
958
|
const tenantClaim = claimsOf(betterSupabase.meta).tenant;
|
|
959
|
+
/**
|
|
960
|
+
* A `next/root-params` getter's value; `undefined` without the getter and
|
|
961
|
+
* outside a render (actions and route handlers have no root params).
|
|
962
|
+
*/
|
|
963
|
+
const rootParam = async (getter) => {
|
|
964
|
+
if (!getter) return;
|
|
965
|
+
try {
|
|
966
|
+
return await getter();
|
|
967
|
+
} catch {
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
};
|
|
830
971
|
/** The tenant `scoped` resolved for a context, when it wasn't the claim. */
|
|
831
972
|
const scopedTenants = /* @__PURE__ */ new WeakMap();
|
|
832
973
|
const tenantFor = (ctx, view) => scopedTenants.get(ctx) ?? tenantOf(view, tenantClaim);
|
|
@@ -838,7 +979,7 @@ function createNext(betterSupabase, options = {}) {
|
|
|
838
979
|
/** `null` runs `NextOptions.tenant`; a string is the caller's explicit tenant. */
|
|
839
980
|
const scopedAt = cache(async (explicit, _generation) => {
|
|
840
981
|
const { request, resolution } = await incoming();
|
|
841
|
-
const [tenant, support] = await Promise.all([explicit ?? options.tenant
|
|
982
|
+
const [tenant, support] = await Promise.all([explicit ?? (options.tenant ? options.tenant(request, resolution.auth) : rootParam(options.rootParams?.tenant)), base.support.current(request, resolution.auth)]);
|
|
842
983
|
const ctx = core.context(resolution, request, {
|
|
843
984
|
...statsFor(request),
|
|
844
985
|
...support ? { support } : {}
|
|
@@ -858,22 +999,9 @@ function createNext(betterSupabase, options = {}) {
|
|
|
858
999
|
path: options.support?.options.cookie?.path ?? "/",
|
|
859
1000
|
secure: options.support?.options.cookie?.secure ?? true
|
|
860
1001
|
};
|
|
861
|
-
const
|
|
862
|
-
const ctx = await base.context(bearerRequest(token));
|
|
863
|
-
if (ctx.auth.kind === "invalid") return ctx;
|
|
864
|
-
if (ctx.auth.kind === "user" ? view.kind === "user" && view.user.id === ctx.auth.user.id : view.kind === ctx.auth.kind) return ctx;
|
|
865
|
-
return base.contextFor({
|
|
866
|
-
kind: "invalid",
|
|
867
|
-
reason: "token",
|
|
868
|
-
error: dbError("unauthorized", "The token does not belong to the session passed to contextFromSession()")
|
|
869
|
-
});
|
|
870
|
-
};
|
|
871
|
-
function contextFromSession(session, sessionOptions) {
|
|
872
|
-
if (session !== null && "kind" in session) return contextFromView(session, sessionOptions !== void 0 && "token" in sessionOptions ? sessionOptions : { token: null });
|
|
873
|
-
return base.contextFromSession(session, sessionOptions !== void 0 && "token" in sessionOptions ? {} : sessionOptions);
|
|
874
|
-
}
|
|
1002
|
+
const contextFromSession = (snapshot, contextOptions) => base.contextFromSession(snapshot, contextOptions);
|
|
875
1003
|
const evictSession = async (userId, evictOptions = {}) => {
|
|
876
|
-
invalidateAll([
|
|
1004
|
+
invalidateAll([...userTags(userId), ...evictOptions.tags ?? []]);
|
|
877
1005
|
await base.evictSession(userId);
|
|
878
1006
|
};
|
|
879
1007
|
const withAccounts = withExtra(base, {
|
|
@@ -881,17 +1009,17 @@ function createNext(betterSupabase, options = {}) {
|
|
|
881
1009
|
contextFromSession,
|
|
882
1010
|
evictSession,
|
|
883
1011
|
deleteAccount: ((userId, deleteOptions) => base.deleteAccount(userId, deleteOptions).map((result) => {
|
|
884
|
-
invalidateAll(
|
|
1012
|
+
invalidateAll(userTags(userId));
|
|
885
1013
|
forget(userId);
|
|
886
1014
|
return result;
|
|
887
1015
|
})),
|
|
888
1016
|
endSessions: ((userId) => base.endSessions(userId).map((result) => {
|
|
889
|
-
invalidateAll(
|
|
1017
|
+
invalidateAll(userTags(userId));
|
|
890
1018
|
forget(userId);
|
|
891
1019
|
return result;
|
|
892
1020
|
})),
|
|
893
1021
|
suspendAccount: ((userId, suspendOptions) => base.suspendAccount(userId, suspendOptions).map((result) => {
|
|
894
|
-
invalidateAll(
|
|
1022
|
+
invalidateAll(userTags(userId));
|
|
895
1023
|
forget(userId);
|
|
896
1024
|
return result;
|
|
897
1025
|
}))
|
|
@@ -914,38 +1042,170 @@ function createNext(betterSupabase, options = {}) {
|
|
|
914
1042
|
scope.generation += 1;
|
|
915
1043
|
},
|
|
916
1044
|
signedOut: (userId) => {
|
|
917
|
-
invalidateAll(
|
|
1045
|
+
invalidateAll(userTags(userId));
|
|
918
1046
|
forget(userId);
|
|
919
1047
|
}
|
|
920
1048
|
});
|
|
1049
|
+
/**
|
|
1050
|
+
* The context of a cache scope: the request's in `'use cache: private'`, the
|
|
1051
|
+
* handed-off snapshot's in `'use cache: remote'`.
|
|
1052
|
+
*/
|
|
1053
|
+
const scopeOf = async (cachedOptions) => {
|
|
1054
|
+
if (cachedOptions.scope !== "remote") {
|
|
1055
|
+
const [view, ctx] = await Promise.all([claims(), current(cachedOptions.tenant)]);
|
|
1056
|
+
return {
|
|
1057
|
+
ctx,
|
|
1058
|
+
view,
|
|
1059
|
+
scope: "private",
|
|
1060
|
+
tenant: tenantFor(ctx, view)
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
const { key } = cachedOptions;
|
|
1064
|
+
const tenant = key.tenant ?? void 0;
|
|
1065
|
+
const snapshot = takeHandoff(key);
|
|
1066
|
+
const ctx = snapshot ? await base.contextFromSession(snapshot, tenant === void 0 ? {} : { tenant }) : base.contextFor(key.userId === null && key.shared === null && key.support === null ? {
|
|
1067
|
+
kind: "none",
|
|
1068
|
+
reason: "none"
|
|
1069
|
+
} : {
|
|
1070
|
+
kind: "invalid",
|
|
1071
|
+
reason: "token",
|
|
1072
|
+
error: dbError("unauthorized", "No caller handed this remote cache key over: call the function through bsb.remote()")
|
|
1073
|
+
});
|
|
1074
|
+
return {
|
|
1075
|
+
ctx,
|
|
1076
|
+
view: toSession(ctx.auth),
|
|
1077
|
+
scope: "remote",
|
|
1078
|
+
tenant
|
|
1079
|
+
};
|
|
1080
|
+
};
|
|
1081
|
+
/** Sets `cacheLife` and the session, support, table and row tags of an entry. */
|
|
1082
|
+
const applyEntry = (ctx, view, scope, tenant, entry) => {
|
|
1083
|
+
cacheLife(cachedLife(view, scope, entry.life, { ...development ? { warn: (message) => {
|
|
1084
|
+
betterSupabase.events.logger.warn(message);
|
|
1085
|
+
} } : {} }));
|
|
1086
|
+
const tables = entry.tables ?? [];
|
|
1087
|
+
const first = tables[0];
|
|
1088
|
+
const claimed = ctx.auth.kind === "user" ? ctx.auth.claims["session_id"] : void 0;
|
|
1089
|
+
const sessionId = typeof claimed === "string" ? claimed : void 0;
|
|
1090
|
+
const tags = [
|
|
1091
|
+
...view.kind === "user" ? userTags(view.user.id) : [],
|
|
1092
|
+
...sessionId === void 0 ? [] : [sessionIdTag(sessionId)],
|
|
1093
|
+
...ctx.support ? [supportTag(ctx.support.session.id)] : [],
|
|
1094
|
+
...entry.tags ?? [],
|
|
1095
|
+
...tables.flatMap((table) => tableTags(table, tenant === void 0 ? {} : { tenant })),
|
|
1096
|
+
...first !== void 0 && entry.id !== void 0 ? [tagFor(first, entry.id)] : []
|
|
1097
|
+
];
|
|
1098
|
+
if (tags.length > 0) cacheTag(...tags);
|
|
1099
|
+
};
|
|
1100
|
+
/** The bootstrap calls of one request, by session key, schema, rpc and args. */
|
|
1101
|
+
const bootstrapCalls = cache(() => /* @__PURE__ */ new Map());
|
|
1102
|
+
const signedOutBootstrap = (view, tenant) => ({
|
|
1103
|
+
session: view,
|
|
1104
|
+
tenant: tenant ?? null,
|
|
1105
|
+
authzVersion: null,
|
|
1106
|
+
sessionActive: false,
|
|
1107
|
+
data: null
|
|
1108
|
+
});
|
|
921
1109
|
const next = extendServer(withAccounts, {
|
|
922
1110
|
claims,
|
|
923
1111
|
getClaims,
|
|
1112
|
+
refreshSessionCache: async () => refreshCallerCache(await getClaims(), base),
|
|
924
1113
|
async cached(cachedOptions = {}) {
|
|
925
|
-
const
|
|
926
|
-
|
|
927
|
-
const stale = sessionStale(view, life);
|
|
928
|
-
cacheLife({
|
|
929
|
-
stale: life?.stale === void 0 ? stale : Math.min(stale, life.stale),
|
|
930
|
-
...life?.revalidate === void 0 ? {} : { revalidate: life.revalidate },
|
|
931
|
-
...life?.expire === void 0 ? {} : { expire: life.expire }
|
|
932
|
-
});
|
|
933
|
-
const tables = cachedOptions.tables ?? [];
|
|
934
|
-
const tenant = tables.length > 0 ? tenantFor(ctx, view) : void 0;
|
|
935
|
-
const first = tables[0];
|
|
936
|
-
const claimed = ctx.auth.kind === "user" ? ctx.auth.claims["session_id"] : void 0;
|
|
937
|
-
const sessionId = typeof claimed === "string" ? claimed : void 0;
|
|
938
|
-
const tags = [
|
|
939
|
-
...view.kind === "user" ? [sessionTag(view.user.id)] : [],
|
|
940
|
-
...sessionId === void 0 ? [] : [sessionIdTag(sessionId)],
|
|
941
|
-
...ctx.support ? [supportTag(ctx.support.session.id)] : [],
|
|
942
|
-
...cachedOptions.tags ?? [],
|
|
943
|
-
...tables.flatMap((table) => tableTags(table, tenant === void 0 ? {} : { tenant })),
|
|
944
|
-
...first !== void 0 && cachedOptions.id !== void 0 ? [tagFor(first, cachedOptions.id)] : []
|
|
945
|
-
];
|
|
946
|
-
if (tags.length > 0) cacheTag(...tags);
|
|
1114
|
+
const { ctx, view, scope, tenant } = await scopeOf(cachedOptions);
|
|
1115
|
+
applyEntry(ctx, view, scope, tenant, cachedOptions);
|
|
947
1116
|
return withExtra(ctx, { session: view });
|
|
948
1117
|
},
|
|
1118
|
+
remote(fn, remoteOptions = {}) {
|
|
1119
|
+
return async (...args) => {
|
|
1120
|
+
const ctx = await current(remoteOptions.tenant?.(...args));
|
|
1121
|
+
const view = toSession(ctx.auth);
|
|
1122
|
+
const snapshot = ctx.support ? null : snapshotOf(ctx.auth);
|
|
1123
|
+
const share = remoteOptions.share ?? "session";
|
|
1124
|
+
const shared = typeof share === "object" ? share.key(snapshot) : null;
|
|
1125
|
+
const key = {
|
|
1126
|
+
userId: shared === null && view.kind === "user" ? view.user.id : null,
|
|
1127
|
+
sessionId: shared === null && share === "session" ? snapshot?.sessionId ?? null : null,
|
|
1128
|
+
tenant: tenantFor(ctx, view) ?? null,
|
|
1129
|
+
authzVersion: shared === null ? snapshot?.authzVersion ?? null : null,
|
|
1130
|
+
shared,
|
|
1131
|
+
support: ctx.support?.session.id ?? null
|
|
1132
|
+
};
|
|
1133
|
+
const release = snapshot ? handOff(key, snapshot) : void 0;
|
|
1134
|
+
try {
|
|
1135
|
+
return await fn(key, ...args);
|
|
1136
|
+
} finally {
|
|
1137
|
+
release?.();
|
|
1138
|
+
}
|
|
1139
|
+
};
|
|
1140
|
+
},
|
|
1141
|
+
async bootstrap(bootstrapOptions) {
|
|
1142
|
+
const { ctx, view, scope, tenant } = await scopeOf(bootstrapOptions);
|
|
1143
|
+
const snapshot = snapshotOf(ctx.auth);
|
|
1144
|
+
if (view.kind !== "user" || !snapshot) {
|
|
1145
|
+
applyEntry(ctx, view, scope, tenant, bootstrapOptions);
|
|
1146
|
+
return signedOutBootstrap(view, tenant);
|
|
1147
|
+
}
|
|
1148
|
+
const schema = bootstrapSchema(bootstrapOptions, options, betterSupabase);
|
|
1149
|
+
const args = {
|
|
1150
|
+
...bootstrapOptions.args,
|
|
1151
|
+
...tenant ? { tenant } : {}
|
|
1152
|
+
};
|
|
1153
|
+
const calls = bootstrapCalls();
|
|
1154
|
+
const callKey = `${sessionCacheKey(snapshot)}|${schema}|${bootstrapOptions.rpc}|${JSON.stringify(args)}`;
|
|
1155
|
+
let call = calls.get(callKey);
|
|
1156
|
+
if (!call) {
|
|
1157
|
+
call = runBootstrap(ctx.db.$executor, schema, bootstrapOptions.rpc, args);
|
|
1158
|
+
calls.set(callKey, call);
|
|
1159
|
+
}
|
|
1160
|
+
const row = await call;
|
|
1161
|
+
if (!row.sessionActive) {
|
|
1162
|
+
cacheLife({
|
|
1163
|
+
stale: 0,
|
|
1164
|
+
revalidate: 0,
|
|
1165
|
+
expire: 0
|
|
1166
|
+
});
|
|
1167
|
+
await evictSession(view.user.id);
|
|
1168
|
+
if (bootstrapOptions.redirect !== void 0) redirect(`${bootstrapOptions.redirect}?reason=session_not_found`);
|
|
1169
|
+
return {
|
|
1170
|
+
session: view,
|
|
1171
|
+
sessionActive: false,
|
|
1172
|
+
authzVersion: row.authzVersion,
|
|
1173
|
+
tenant: row.tenant ?? tenant ?? null,
|
|
1174
|
+
data: null
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
if (row.authzVersion !== null) await options.versions?.seed?.(view.user.id, row.authzVersion);
|
|
1178
|
+
applyEntry(ctx, view, scope, tenant ?? row.tenant ?? void 0, bootstrapOptions);
|
|
1179
|
+
return {
|
|
1180
|
+
session: view,
|
|
1181
|
+
sessionActive: true,
|
|
1182
|
+
authzVersion: row.authzVersion,
|
|
1183
|
+
tenant: row.tenant ?? tenant ?? null,
|
|
1184
|
+
data: row.data
|
|
1185
|
+
};
|
|
1186
|
+
},
|
|
1187
|
+
async getAccess(source, accessOptions = {}) {
|
|
1188
|
+
const boot = source && "session" in source ? source : void 0;
|
|
1189
|
+
const tenant = boot?.tenant ?? void 0;
|
|
1190
|
+
const snapshot = isSessionSnapshot(source) ? source : accessOptions.key ? takeHandoff(accessOptions.key) ?? null : await getClaims();
|
|
1191
|
+
const ctx = await base.contextFromSession(snapshot, tenant === void 0 ? {} : { tenant });
|
|
1192
|
+
const view = toSession(ctx.auth);
|
|
1193
|
+
const resolvedTenant = tenant ?? tenantFor(ctx, view) ?? null;
|
|
1194
|
+
return {
|
|
1195
|
+
context: ctx,
|
|
1196
|
+
session: view,
|
|
1197
|
+
tenant: resolvedTenant,
|
|
1198
|
+
authzVersion: boot ? boot.authzVersion : snapshot?.authzVersion ?? null,
|
|
1199
|
+
async can(permission) {
|
|
1200
|
+
if (view.kind !== "user") return false;
|
|
1201
|
+
const outcome = await authorizeCaller(ctx.auth, { permission }, void 0, resolvedTenant ?? void 0, base.authorizer, ctx);
|
|
1202
|
+
return !("kind" in outcome && "message" in outcome);
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
},
|
|
1206
|
+
locale: () => rootParam(options.rootParams?.locale),
|
|
1207
|
+
brand: () => rootParam(options.rootParams?.brand),
|
|
1208
|
+
tenant: () => rootParam(options.rootParams?.tenant),
|
|
949
1209
|
async liveCount(spec, db) {
|
|
950
1210
|
const result = await (db ?? (await current()).db).$run(spec);
|
|
951
1211
|
return {
|
|
@@ -959,10 +1219,10 @@ function createNext(betterSupabase, options = {}) {
|
|
|
959
1219
|
const id = collector ? crypto.randomUUID() : void 0;
|
|
960
1220
|
let authMs = 0;
|
|
961
1221
|
const phases = {};
|
|
962
|
-
const sessionCheck = proxyOptions.verifySession === true ? {} : proxyOptions.verifySession;
|
|
1222
|
+
const sessionCheck = proxyOptions.verifySession === true ? {} : proxyOptions.verifySession === "bootstrap" ? void 0 : proxyOptions.verifySession;
|
|
963
1223
|
const verifySession = sessionCheck !== void 0 && shouldCheckSession(request, sessionCheck);
|
|
964
1224
|
const [early, resolution] = await Promise.all([proxyOptions.before?.(request), base.resolve(request, {
|
|
965
|
-
refresh:
|
|
1225
|
+
refresh: true,
|
|
966
1226
|
...verifySession ? { verifySession } : {},
|
|
967
1227
|
...proxyOptions.leeway === void 0 ? {} : { leeway: proxyOptions.leeway },
|
|
968
1228
|
...proxyOptions.serverTiming ? { onTiming: (phase, ms) => {
|
|
@@ -973,10 +1233,9 @@ function createNext(betterSupabase, options = {}) {
|
|
|
973
1233
|
return resolved;
|
|
974
1234
|
})]);
|
|
975
1235
|
if (resolution.cookies.length > 0) await base.sessions.seed(resolution.auth);
|
|
976
|
-
const rendersSignedOut = proxyOptions.onExpiredPrefetch === "render" && resolution.auth.kind === "none" && resolution.auth.reason === "expired" && isPrefetch(request);
|
|
977
1236
|
const protectMethods = proxyOptions.protectMethods;
|
|
978
1237
|
const runsProtect = protectMethods === true ? true : (protectMethods ?? ["GET", "HEAD"]).includes(request.method);
|
|
979
|
-
const custom = (resolution.sessionVerified === false && sessionCheck?.redirect !== void 0 && request.nextUrl.pathname !== sessionCheck.redirect ? endedRedirect(request, sessionCheck.redirect, resolution.reason === "user_banned" ? sessionCheck.reasons?.banned ?? "user_banned" : sessionCheck.reasons?.ended ?? "session_not_found") : void 0) ?? await outageResponse(proxyOptions.onAuthOutage, resolution, request, betterSupabase.events.logger) ?? (
|
|
1238
|
+
const custom = (resolution.sessionVerified === false && sessionCheck?.redirect !== void 0 && request.nextUrl.pathname !== sessionCheck.redirect ? endedRedirect(request, sessionCheck.redirect, resolution.reason === "user_banned" ? sessionCheck.reasons?.banned ?? "user_banned" : sessionCheck.reasons?.ended ?? "session_not_found") : void 0) ?? await outageResponse(proxyOptions.onAuthOutage, resolution, request, betterSupabase.events.logger) ?? (runsProtect ? await proxyOptions.protect?.(resolution.auth, request) : void 0);
|
|
980
1239
|
const initial = custom ?? early;
|
|
981
1240
|
if (!initial && resolution.cookies.length === 0 && !id && !proxyOptions.after && !proxyOptions.serverTiming) {
|
|
982
1241
|
flushAfter();
|
|
@@ -995,7 +1254,7 @@ function createNext(betterSupabase, options = {}) {
|
|
|
995
1254
|
}
|
|
996
1255
|
if (proxyOptions.after) {
|
|
997
1256
|
const replaced = await proxyOptions.after(response, resolution.auth);
|
|
998
|
-
if (replaced) response = mutableResponse(replaced);
|
|
1257
|
+
if (replaced) response = resolution.apply(mutableResponse(replaced));
|
|
999
1258
|
}
|
|
1000
1259
|
if (proxyOptions.serverTiming) response.headers.append("server-timing", serverTimingValue({
|
|
1001
1260
|
"bsb-proxy": performance.now() - started,
|
|
@@ -1140,7 +1399,7 @@ function createNext(betterSupabase, options = {}) {
|
|
|
1140
1399
|
...supportCookieOptions,
|
|
1141
1400
|
maxAge: supportCookieMaxAge(support)
|
|
1142
1401
|
});
|
|
1143
|
-
if (resolution.auth.kind === "user") invalidateAll(
|
|
1402
|
+
if (resolution.auth.kind === "user") invalidateAll(userTags(resolution.auth.user.id));
|
|
1144
1403
|
return {
|
|
1145
1404
|
ok: true,
|
|
1146
1405
|
data: {
|
|
@@ -1167,7 +1426,7 @@ function createNext(betterSupabase, options = {}) {
|
|
|
1167
1426
|
};
|
|
1168
1427
|
const stopped = await base.support.stop(resolution.auth, id);
|
|
1169
1428
|
flushAfter();
|
|
1170
|
-
invalidateAll([supportTag(id), ...resolution.auth.kind === "user" ?
|
|
1429
|
+
invalidateAll([supportTag(id), ...resolution.auth.kind === "user" ? userTags(resolution.auth.user.id) : []]);
|
|
1171
1430
|
return stopped.ok ? {
|
|
1172
1431
|
ok: true,
|
|
1173
1432
|
data: { ended: stopped.data.ended },
|
|
@@ -1201,4 +1460,160 @@ function createNext(betterSupabase, options = {}) {
|
|
|
1201
1460
|
});
|
|
1202
1461
|
return next;
|
|
1203
1462
|
}
|
|
1204
|
-
|
|
1463
|
+
// src/bridges/next.ts
|
|
1464
|
+
/**
|
|
1465
|
+
* Runs an entry array around a Next.js route handler. The handler gets the
|
|
1466
|
+
* entries' contributions as `ctx` and may return a `Response` or a value (sent
|
|
1467
|
+
* as JSON, `undefined` as 204). Response-phase entries (`withCors`, refreshed
|
|
1468
|
+
* cookies) see the handler's response.
|
|
1469
|
+
*
|
|
1470
|
+
* ```ts
|
|
1471
|
+
* // src/app/api/notes/route.ts
|
|
1472
|
+
* export const GET = toNextRoute(
|
|
1473
|
+
* [withCors(cors), withRequiredClaims(), withSupabaseClient()],
|
|
1474
|
+
* async (request, ctx) =>
|
|
1475
|
+
* (await ctx.supabase.from("notes").select()).data,
|
|
1476
|
+
* );
|
|
1477
|
+
* ```
|
|
1478
|
+
*/
|
|
1479
|
+
function toNextRoute(entries, handler, options = {}) {
|
|
1480
|
+
const run = around(entries);
|
|
1481
|
+
return async (request, context) => {
|
|
1482
|
+
bufferInPlace(request);
|
|
1483
|
+
return run(request, options.env?.(request), async (contributions) => toResponse(await handler(request, contributions, context)));
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Thrown by an action whose entries answered before the action ran, such as
|
|
1488
|
+
* `withRequiredClaims` with a 401 for a caller without a session.
|
|
1489
|
+
*/
|
|
1490
|
+
var NextActionRejected = class extends Error {
|
|
1491
|
+
status;
|
|
1492
|
+
response;
|
|
1493
|
+
constructor(response) {
|
|
1494
|
+
super(`The action was rejected with status ${String(response.status)}.`);
|
|
1495
|
+
this.name = "NextActionRejected";
|
|
1496
|
+
this.status = response.status;
|
|
1497
|
+
this.response = response;
|
|
1498
|
+
}
|
|
1499
|
+
};
|
|
1500
|
+
/**
|
|
1501
|
+
* The `Request` of a Server Action: a POST to the page that called it, with the
|
|
1502
|
+
* incoming headers. Next.js gives actions no `Request`, so the entries see this
|
|
1503
|
+
* one.
|
|
1504
|
+
*/
|
|
1505
|
+
function actionRequest(headers) {
|
|
1506
|
+
const host = headers.get("x-forwarded-host") ?? headers.get("host");
|
|
1507
|
+
const protocol = headers.get("x-forwarded-proto") ?? "https";
|
|
1508
|
+
const origin = host ? `${protocol}://${host}` : "http://localhost";
|
|
1509
|
+
const path = headers.get("next-url") ?? "/";
|
|
1510
|
+
return new Request(new URL(path, origin), {
|
|
1511
|
+
method: "POST",
|
|
1512
|
+
headers
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Runs an entry array around a Server Action with `io` reading the request and
|
|
1517
|
+
* writing cookies. `src/next` binds `io` to `headers()` and `cookies()`.
|
|
1518
|
+
*/
|
|
1519
|
+
function nextAction(entries, action, io, options = {}) {
|
|
1520
|
+
const run = around(entries);
|
|
1521
|
+
return async (...args) => {
|
|
1522
|
+
const request = actionRequest(await io.headers());
|
|
1523
|
+
const outcome = { ran: false };
|
|
1524
|
+
const response = await run(request, options.env?.(request), async (contributions) => {
|
|
1525
|
+
outcome.result = await action(contributions, ...args);
|
|
1526
|
+
outcome.ran = true;
|
|
1527
|
+
return new Response(null, { status: 204 });
|
|
1528
|
+
});
|
|
1529
|
+
for (const header of response.headers.getSetCookie()) {
|
|
1530
|
+
const write = parseSetCookie(header);
|
|
1531
|
+
if (write) await io.setCookie(write);
|
|
1532
|
+
}
|
|
1533
|
+
if (!outcome.ran) throw new NextActionRejected(response);
|
|
1534
|
+
return outcome.result;
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
const SAME_SITE = /* @__PURE__ */ new Set([
|
|
1538
|
+
"lax",
|
|
1539
|
+
"strict",
|
|
1540
|
+
"none"
|
|
1541
|
+
]);
|
|
1542
|
+
function isSameSite(value) {
|
|
1543
|
+
return SAME_SITE.has(value);
|
|
1544
|
+
}
|
|
1545
|
+
/**
|
|
1546
|
+
* One `Set-Cookie` header as a cookie write, or `undefined` when it has no
|
|
1547
|
+
* name.
|
|
1548
|
+
*/
|
|
1549
|
+
function parseSetCookie(header) {
|
|
1550
|
+
const [pair = "", ...attributes] = header.split(";");
|
|
1551
|
+
const equals = pair.indexOf("=");
|
|
1552
|
+
if (equals <= 0) return;
|
|
1553
|
+
const write = {
|
|
1554
|
+
name: pair.slice(0, equals).trim(),
|
|
1555
|
+
value: decodeURIComponent(pair.slice(equals + 1).trim())
|
|
1556
|
+
};
|
|
1557
|
+
for (const attribute of attributes) {
|
|
1558
|
+
const at = attribute.indexOf("=");
|
|
1559
|
+
const key = (at === -1 ? attribute : attribute.slice(0, at)).trim().toLowerCase();
|
|
1560
|
+
const value = at === -1 ? "" : attribute.slice(at + 1).trim();
|
|
1561
|
+
switch (key) {
|
|
1562
|
+
case "path":
|
|
1563
|
+
write.path = value;
|
|
1564
|
+
break;
|
|
1565
|
+
case "domain":
|
|
1566
|
+
write.domain = value;
|
|
1567
|
+
break;
|
|
1568
|
+
case "max-age": {
|
|
1569
|
+
const seconds = Number(value);
|
|
1570
|
+
if (Number.isFinite(seconds)) write.maxAge = seconds;
|
|
1571
|
+
break;
|
|
1572
|
+
}
|
|
1573
|
+
case "expires": {
|
|
1574
|
+
const date = new Date(value);
|
|
1575
|
+
if (!Number.isNaN(date.getTime())) write.expires = date;
|
|
1576
|
+
break;
|
|
1577
|
+
}
|
|
1578
|
+
case "httponly":
|
|
1579
|
+
write.httpOnly = true;
|
|
1580
|
+
break;
|
|
1581
|
+
case "secure":
|
|
1582
|
+
write.secure = true;
|
|
1583
|
+
break;
|
|
1584
|
+
case "samesite": {
|
|
1585
|
+
const sameSite = value.toLowerCase();
|
|
1586
|
+
if (isSameSite(sameSite)) write.sameSite = sameSite;
|
|
1587
|
+
break;
|
|
1588
|
+
}
|
|
1589
|
+
case "partitioned": write.partitioned = true;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
return write;
|
|
1593
|
+
}
|
|
1594
|
+
// src/next/bridge.ts
|
|
1595
|
+
/**
|
|
1596
|
+
* Runs an entry array around a Server Action. The entries see a request built
|
|
1597
|
+
* from `headers()` (the session cookie included), cookies they set go through
|
|
1598
|
+
* `cookies().set`, and the action gets their contributions as `ctx`. When an
|
|
1599
|
+
* entry answers first (a 401 from `withRequiredClaims`), the call throws
|
|
1600
|
+
* `NextActionRejected` with that response.
|
|
1601
|
+
*
|
|
1602
|
+
* ```ts
|
|
1603
|
+
* "use server";
|
|
1604
|
+
* export const addNote = toNextAction(
|
|
1605
|
+
* [withRequiredClaims(), withSupabaseClient()],
|
|
1606
|
+
* async (ctx, body: string) =>
|
|
1607
|
+
* ctx.supabase.from("notes").insert({ body }),
|
|
1608
|
+
* );
|
|
1609
|
+
* ```
|
|
1610
|
+
*/
|
|
1611
|
+
function toNextAction(entries, action, options = {}) {
|
|
1612
|
+
return nextAction(entries, action, {
|
|
1613
|
+
headers: async () => new Headers(await headers()),
|
|
1614
|
+
setCookie: async ({ name, value, ...attributes }) => {
|
|
1615
|
+
(await cookies()).set(name, value, attributes);
|
|
1616
|
+
}
|
|
1617
|
+
}, options);
|
|
1618
|
+
}
|
|
1619
|
+
export { NextActionRejected, REQUEST_ID_HEADER, STATS_URL_HEADER, authzVersionOf, bindingTag, createNext, defineAction, invalidateBinding, isSessionSnapshot, issuedAtOf, nextCache, parseSetCookie, permissionsOf, postAuthPath, recordListServer, recordTag, requireAal, safeRedirectPath, sessionCacheKey, sessionIdTag, sessionTag, shouldCheckSession, supportOf, supportSessions, supportTag, tagFor, tenantOf, toNextAction, toNextRoute, toSession };
|