better-supabase 0.15.0 → 0.16.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-B0b6MXYS.js → adapter-Dyks1lX1.js} +1 -1
- package/dist/{agents-5n8DWRfP.d.ts → agents-CMIB3802.d.ts} +1 -1
- package/dist/{ai-cache-DyHohbFP.d.ts → ai-cache-2LGgaT7F.d.ts} +1 -1
- package/dist/{ai-chat-D1GuRnke.d.ts → ai-chat-BCaKsvLW.d.ts} +1 -1
- package/dist/{ai-schedules-CAquecT_.d.ts → ai-schedules-BmkARmQ9.d.ts} +2 -2
- package/dist/ai-sdk/agents/index.d.ts +4 -4
- package/dist/ai-sdk/batches/index.d.ts +1 -1
- package/dist/ai-sdk/cache/index.d.ts +1 -1
- package/dist/ai-sdk/chat/index.d.ts +1 -1
- package/dist/ai-sdk/embeddings/index.d.ts +2 -2
- package/dist/ai-sdk/index.d.ts +4 -4
- package/dist/ai-sdk/memory/index.d.ts +3 -3
- package/dist/ai-sdk/workflow/index.d.ts +3 -3
- package/dist/{api-DxAPqMrE.d.ts → api-hHwieEfz.d.ts} +1 -1
- package/dist/{app-tables-CF2DD-Mu.d.ts → app-tables-yMQ4ubyY.d.ts} +1 -1
- package/dist/{approvals-Crutd4-o.d.ts → approvals-Dh9dUXrN.d.ts} +1 -1
- package/dist/{assistant-CD_h8Vxx.d.ts → assistant-ndGdOBax.d.ts} +2 -2
- package/dist/astro/index.d.ts +4 -4
- package/dist/astro/index.js +2 -2
- package/dist/{auth-module-BEFESDC4.js → auth-module-BbmX-N4L.js} +12 -4
- package/dist/{authorization-hooks-Cs1vP_ej.d.ts → authorization-hooks-D_pwXlBs.d.ts} +4 -0
- package/dist/better-result/index.d.ts +2 -2
- package/dist/{bind-CrMBwrPN.d.ts → bind-JGCPGUJh.d.ts} +4 -4
- package/dist/{block-env-B_uEM2xz.d.ts → block-env-y65GF_px.d.ts} +4 -4
- package/dist/blocks/access-requests/index.d.ts +1 -1
- package/dist/blocks/activities/index.d.ts +2 -2
- package/dist/blocks/agents/index.d.ts +2 -2
- package/dist/blocks/ai-cache/index.d.ts +2 -2
- package/dist/blocks/ai-chat/index.d.ts +5 -5
- package/dist/blocks/ai-files/index.d.ts +1 -1
- package/dist/blocks/ai-keys/index.d.ts +1 -1
- package/dist/blocks/ai-schedules/index.d.ts +2 -2
- package/dist/blocks/announcements/index.d.ts +4 -4
- package/dist/blocks/api-keys/index.d.ts +2 -2
- package/dist/blocks/approvals/index.d.ts +2 -2
- package/dist/blocks/assets/index.d.ts +1 -1
- package/dist/blocks/assignment/index.d.ts +1 -1
- package/dist/blocks/attachments/index.d.ts +2 -2
- package/dist/blocks/audit/index.d.ts +5 -5
- package/dist/blocks/automations/index.d.ts +4 -4
- package/dist/blocks/billable-time/index.d.ts +1 -1
- package/dist/blocks/billing/index.d.ts +3 -3
- package/dist/blocks/bookings/index.d.ts +3 -3
- package/dist/blocks/bulk/index.d.ts +1 -1
- package/dist/blocks/calendar/index.d.ts +2 -2
- package/dist/blocks/catalog/index.d.ts +1 -1
- package/dist/blocks/channels/index.d.ts +1 -1
- package/dist/blocks/collections/index.d.ts +1 -1
- package/dist/blocks/comments/index.d.ts +4 -4
- package/dist/blocks/compliance/index.d.ts +1 -1
- package/dist/blocks/connectors/index.d.ts +1 -1
- package/dist/blocks/contacts/index.d.ts +1 -1
- package/dist/blocks/content/index.d.ts +1 -1
- package/dist/blocks/contracts/index.d.ts +1 -1
- package/dist/blocks/courses/index.d.ts +1 -1
- package/dist/blocks/created-by/index.d.ts +1 -1
- package/dist/blocks/custom-fields/index.d.ts +1 -1
- package/dist/blocks/data-lifecycle/index.d.ts +2 -2
- package/dist/blocks/deals/index.d.ts +1 -1
- package/dist/blocks/dispatch/index.d.ts +1 -1
- package/dist/blocks/documents/index.d.ts +1 -1
- package/dist/blocks/domains/index.d.ts +1 -1
- package/dist/blocks/donations/index.d.ts +1 -1
- package/dist/blocks/drive/index.d.ts +2 -2
- package/dist/blocks/employees/index.d.ts +2 -2
- package/dist/blocks/enrichment/index.d.ts +1 -1
- package/dist/blocks/enrollments/index.d.ts +1 -1
- package/dist/blocks/entitlements/index.d.ts +3 -3
- package/dist/blocks/expenses/index.d.ts +1 -1
- package/dist/blocks/field-history/index.d.ts +1 -1
- package/dist/blocks/flags/index.d.ts +1 -1
- package/dist/blocks/forecasts/index.d.ts +1 -1
- package/dist/blocks/forms/index.d.ts +2 -2
- package/dist/blocks/goals/index.d.ts +1 -1
- package/dist/blocks/guests/index.d.ts +1 -1
- package/dist/blocks/hiring/index.d.ts +1 -1
- package/dist/blocks/identities/index.d.ts +2 -2
- package/dist/blocks/imports/index.d.ts +1 -1
- package/dist/blocks/inbox/index.d.ts +5 -5
- package/dist/blocks/incidents/index.d.ts +1 -1
- package/dist/blocks/index.d.ts +2 -2
- package/dist/blocks/inventory/index.d.ts +2 -2
- package/dist/blocks/invoices/index.d.ts +1 -1
- package/dist/blocks/knowledge/index.d.ts +2 -2
- package/dist/blocks/lead-scoring/index.d.ts +1 -1
- package/dist/blocks/leases/index.d.ts +1 -1
- package/dist/blocks/leave/index.d.ts +1 -1
- package/dist/blocks/ledger/index.d.ts +1 -1
- package/dist/blocks/mail-sync/index.d.ts +1 -1
- package/dist/blocks/memberships/index.d.ts +1 -1
- package/dist/blocks/memory/index.d.ts +3 -3
- package/dist/blocks/messaging/index.d.ts +4 -4
- 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 +1 -1
- package/dist/blocks/notifications/index.d.ts +5 -5
- package/dist/blocks/numbering/index.d.ts +1 -1
- package/dist/blocks/oauth-server/index.d.ts +1 -1
- 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 +2 -2
- 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 +3 -3
- package/dist/blocks/pipelines/index.d.ts +1 -1
- package/dist/blocks/posts/index.d.ts +1 -1
- package/dist/blocks/profiles/index.d.ts +1 -1
- package/dist/blocks/promotions/index.d.ts +1 -1
- package/dist/blocks/push/index.d.ts +2 -2
- package/dist/blocks/queue/index.d.ts +30 -3
- package/dist/blocks/queue/index.js +2 -2
- package/dist/blocks/quotes/index.d.ts +1 -1
- package/dist/blocks/rank/index.d.ts +2 -2
- package/dist/blocks/reactions/index.d.ts +4 -4
- package/dist/blocks/relations/index.d.ts +1 -1
- package/dist/blocks/reminders/index.d.ts +3 -3
- package/dist/blocks/reviews/index.d.ts +1 -1
- package/dist/blocks/saved-views/index.d.ts +3 -3
- package/dist/blocks/scores/index.d.ts +1 -1
- package/dist/blocks/search/index.d.ts +3 -3
- package/dist/blocks/security-events/index.d.ts +1 -1
- package/dist/blocks/segments/index.d.ts +1 -1
- package/dist/blocks/sequences/index.d.ts +1 -1
- package/dist/blocks/service-accounts/index.d.ts +1 -1
- package/dist/blocks/sessions/index.d.ts +2 -2
- package/dist/blocks/settings/index.d.ts +2 -2
- package/dist/blocks/share-links/index.d.ts +1 -1
- package/dist/blocks/shipments/index.d.ts +1 -1
- package/dist/blocks/signatures/index.d.ts +1 -1
- package/dist/blocks/signing-keys/index.d.ts +1 -1
- package/dist/blocks/sla/index.d.ts +1 -1
- package/dist/blocks/sso/index.d.ts +1 -1
- package/dist/blocks/state-machine/index.d.ts +1 -1
- package/dist/blocks/subjects/index.d.ts +2 -2
- package/dist/blocks/tags/index.d.ts +2 -2
- package/dist/blocks/tasks/index.d.ts +2 -2
- package/dist/blocks/teams/index.d.ts +1 -1
- package/dist/blocks/templates/index.d.ts +3 -3
- package/dist/blocks/time-tracking/index.d.ts +1 -1
- package/dist/blocks/timeline/index.d.ts +3 -3
- package/dist/blocks/trash/index.d.ts +1 -1
- 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 +3 -3
- package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
- package/dist/blocks/versions/index.d.ts +1 -1
- package/dist/blocks/waitlist/index.d.ts +1 -1
- package/dist/blocks/webhooks/index.d.ts +4 -4
- package/dist/blocks/webhooks/index.js +1 -1
- package/dist/blocks/workflow-editor/index.d.ts +6 -6
- package/dist/blocks/workflow-editor/index.js +12 -1
- package/dist/blocks/workflows/index.d.ts +4 -4
- package/dist/{bookings-D4dvGXiR.d.ts → bookings-Dox2rced.d.ts} +1 -1
- package/dist/{bucket-CiNi8sIw.d.ts → bucket-vc-QRrva.d.ts} +40 -1
- package/dist/chat-sdk/index.d.ts +1 -1
- package/dist/cli/add-Bfb_ISrO.js +1 -0
- package/dist/cli/{add-BgsUjCan.js → add-D7TkPdco.js} +17 -12
- package/dist/cli/{add-DCI5JKjA.js → add-I8OW-qJH.js} +2 -2
- package/dist/cli/{backfill-nxPbcsns.js → backfill-DIz5DnlQ.js} +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cli/{blocks-Cr4HGePW.js → blocks-Bp5RPoft.js} +1 -1
- package/dist/cli/{blocks-BZHI8mRC.js → blocks-xk-SE8gS.js} +1 -1
- package/dist/cli/{cache-CXgR_Ahi.js → cache-AznIssjI.js} +1 -1
- package/dist/cli/{codemod-DSN7iAdg.js → codemod-Aewxza6i.js} +95 -3
- package/dist/cli/{content-mapper-DNs7lTu7.js → content-mapper-DCrz6OIv.js} +2 -2
- package/dist/cli/{doctor-DDrEM6S1.js → doctor-DkOSLPEQ.js} +29 -14
- package/dist/cli/{gen-MtijJQ9r.js → gen-CFkYUnWq.js} +10 -10
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +6 -6
- package/dist/cli/{init-D-aDv9r5.js → init-CHj9ad4S.js} +5 -5
- package/dist/cli/legacy-prefix-DkTA3Rhx.js +141 -0
- package/dist/cli/{live-iEeH15ck.js → live-DGdLR41j.js} +2 -2
- package/dist/cli/{mcp-BAPyaQ62.js → mcp-BZno503V.js} +2 -2
- package/dist/cli/{metadata-DVx9Zgbj.js → metadata-BfgHMe4q.js} +3 -3
- package/dist/cli/{migration-safety-D7PhzFxm.js → migration-safety-BnnXPAro.js} +1 -1
- package/dist/cli/{module-migration-aPCckev6.js → module-migration-O_IxewFs.js} +5 -216
- package/dist/cli/{print-BeWO7OJY.js → print-DosQIFSy.js} +1 -1
- package/dist/cli/{remove-B46Dmd2M.js → remove-DK2G_KHm.js} +5 -4
- package/dist/cli/{render-ucJmUyuM.js → render-5y5a1QZr.js} +3 -3
- package/dist/cli/{run-CvYVAztY.js → run-Bs4OKdDI.js} +20 -7
- package/dist/cli/{run-DYhLBcFW.js → run-MRET30vh.js} +20 -20
- package/dist/cli/{shared-LZroULBe.js → shared-BLqbvY2x.js} +1 -1
- package/dist/cli/{snapshot-C8MVPyO8.js → snapshot-uTUlEzY2.js} +2 -2
- package/dist/cli/{source-DANaJJVc.js → source-D2gJHKwC.js} +1 -1
- package/dist/cli/{spec-DGVNMSSB.js → spec-Cm2einTO.js} +2 -2
- package/dist/cli/{spec-g8_G5K7o.js → spec-DUjOtciN.js} +1 -1
- package/dist/cli/sql-layout-lUWenjJw.js +247 -0
- package/dist/cli/{sync-btj01bcM.js → sync-CZMRB3aU.js} +2 -1
- package/dist/cli/{upgrade-B596d4t8.js → upgrade-BFEIMC7U.js} +4 -137
- package/dist/cli/{upgrade-Dw3TMQzn.js → upgrade-fVsJniXm.js} +2 -2
- package/dist/cli/{version-Du4CgONY.js → version-B2Dr6VmJ.js} +1 -1
- package/dist/client/index.d.ts +5 -5
- package/dist/client/index.js +1 -1
- package/dist/client/native/index.d.ts +5 -5
- package/dist/client/native/index.js +1 -1
- package/dist/{client-BAEbEA7t.js → client-C_mlji5R.js} +6 -5
- package/dist/{composite-BARuBEDE.js → composite-B3TIjId4.js} +1 -1
- package/dist/{composite-Dsxj7T5K.d.ts → composite-CfYyU3vs.d.ts} +4 -3
- package/dist/config/index.d.ts +1 -1
- package/dist/{context-CEuTKrkz.d.ts → context-8kb8m5uO.d.ts} +24 -2
- package/dist/{controller-BrP0gn47.d.ts → controller-BW-5Opig.d.ts} +1 -1
- package/dist/{conversion-BAbucuXq.d.ts → conversion-3iv2r7YC.d.ts} +1 -1
- package/dist/create/index.d.ts +2 -2
- package/dist/create/index.js +1 -1
- package/dist/{define-DFBnQyYg.d.ts → define-C5AcEkEJ.d.ts} +1 -1
- package/dist/{define-block-BVcLQ3DF.d.ts → define-block-C1RHXz7L.d.ts} +3 -3
- package/dist/delegation-C7eWP2r8.d.ts +14 -0
- package/dist/{delegation--93jRsVO.js → delegation-DGOIiT8k.js} +12 -5
- package/dist/edge/index.d.ts +5 -5
- package/dist/edge/index.js +3 -3
- package/dist/{embeddings-kFbRvuic.d.ts → embeddings-D_RsS6ow.d.ts} +1 -1
- package/dist/{entitlements-CJpYQXeE.d.ts → entitlements-sO977DO-.d.ts} +1 -1
- package/dist/{envelope-Bzu0JnY2.js → envelope-DEI2iX-d.js} +1 -1
- package/dist/eve/index.d.ts +2 -2
- package/dist/{eve-BFSwTu1z.d.ts → eve-B7jxYPCw.d.ts} +2 -2
- package/dist/{executor-CVIn6JHa.d.ts → executor-BcNWcD-4.d.ts} +2 -2
- package/dist/{executor-_2ekNofh.d.ts → executor-Bi056Cnj.d.ts} +1 -1
- package/dist/expo/index.d.ts +2 -2
- package/dist/expo/index.js +2 -2
- package/dist/{field-errors-fsbFktYF.d.ts → field-errors-Dt86dCKk.d.ts} +12 -12
- package/dist/{framework-BKyTeS-j.d.ts → framework-BGdZVyPL.d.ts} +3 -3
- package/dist/{framework-DDdkR7FX.js → framework-BozTXRzt.js} +1 -1
- package/dist/{gateway-TD1pRfTP.d.ts → gateway-DzI687yd.d.ts} +3 -3
- package/dist/hono/index.d.ts +4 -4
- package/dist/hono/index.js +2 -2
- package/dist/{index-C-qpk8EQ.d.ts → index-CENWq3zb.d.ts} +1 -1
- package/dist/{index-Do2ChN_y.d.ts → index-CQhPHHDF.d.ts} +20 -2
- package/dist/{index-B938YqY-.d.ts → index-CTu-3fJB.d.ts} +51 -3
- package/dist/{index-CguFm716.d.ts → index-Cc4mIQS8.d.ts} +32 -4
- package/dist/{index-DLq69k3F.d.ts → index-CcAmFNVi.d.ts} +2 -2
- package/dist/{index-BnH4Gomw.d.ts → index-Craf712U.d.ts} +44 -12
- package/dist/{index-BUuVq1co.d.ts → index-DZKCc2WM.d.ts} +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/{knowledge-CtL-Vfgy.d.ts → knowledge-F1IhRI4Q.d.ts} +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/{list-query-BDVutLFr.d.ts → list-query-DYhgRTd5.d.ts} +1 -1
- package/dist/mapper/bin.js +5 -5
- package/dist/mcp/index.d.ts +3 -3
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/sdk/index.d.ts +2 -2
- package/dist/mcp/sdk/index.js +1 -1
- package/dist/next/client/index.d.ts +81 -1
- package/dist/next/client/index.js +178 -2
- package/dist/next/index.d.ts +15 -14
- package/dist/next/index.js +2 -2
- package/dist/orpc/index.d.ts +4 -4
- package/dist/orpc/index.js +1 -1
- package/dist/otel/index.js +4 -4
- package/dist/{outbox-HvGAJuBe.d.ts → outbox-HxjZTfF6.d.ts} +1 -1
- package/dist/{ports-DOhtuw3c.js → ports-CaVRXjxq.js} +1 -1
- package/dist/{ports-sx226JUL.d.ts → ports-mObLgH1z.d.ts} +1 -1
- package/dist/powersync/index.d.ts +2 -2
- package/dist/preset/index.d.ts +3 -3
- package/dist/{push-token-D3Vcf0Pf.d.ts → push-token-BSSvsWXZ.d.ts} +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/{rate-limit-o44SYkVY.js → rate-limit-Dt9vAY4E.js} +53 -0
- package/dist/react/index.d.ts +6 -6
- 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 +12 -7
- package/dist/react/server.js +8 -3
- package/dist/react/session.d.ts +5 -0
- package/dist/react/session.js +9 -1
- package/dist/{react-BuDYI62C.js → react-CZUZYn9E.js} +41 -4
- package/dist/react-router/index.d.ts +3 -3
- package/dist/react-router/index.js +2 -2
- package/dist/realtime/index.d.ts +6 -6
- package/dist/realtime/index.js +2 -1
- package/dist/{record-form-BYs9xv_N.d.ts → record-form-D9ILuVtA.d.ts} +1 -1
- package/dist/records/index.d.ts +7 -7
- package/dist/relay-gKvKJ3xf.js +208 -0
- package/dist/{resource-execute-CzHuDsil.d.ts → resource-execute-Cpnob1Vj.d.ts} +1 -1
- package/dist/{resource-types-DnKiH4G2.d.ts → resource-types-pMeLs68X.d.ts} +1 -1
- package/dist/{resources-B9cQxhjw.d.ts → resources-7iq2-5_A.d.ts} +1 -1
- package/dist/server/index.d.ts +150 -11
- package/dist/server/index.js +400 -4
- package/dist/{server-types-CFtehAsr.d.ts → server-types-CK8mUIUT.d.ts} +5 -354
- package/dist/{session-CH0SKgIz.d.ts → session-DWmFv3vB.d.ts} +2 -1
- package/dist/session-status-qQLm7jzh.d.ts +82 -0
- package/dist/{sign-in-DNCdrk05.js → sign-in-B64114O4.js} +1 -1
- package/dist/{sign-in-BsIaNx2C.js → sign-in-CmPK1AgM.js} +20 -10
- package/dist/solid/index.d.ts +7 -7
- package/dist/solid/index.js +1 -1
- package/dist/solid-start/index.d.ts +3 -3
- package/dist/solid-start/index.js +2 -2
- package/dist/spec/index.d.ts +1 -1
- package/dist/sql/index.d.ts +4 -4
- package/dist/sql/index.js +2 -2
- package/dist/{sql-ClHIdgKS.js → sql-Dl3Alk43.js} +402 -13
- package/dist/sqlite/index.d.ts +1 -1
- package/dist/ssr/index.d.ts +1 -1
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +54 -1
- package/dist/{subject-readers-BNSzkqw_.d.ts → subject-readers-8GySC9Z8.d.ts} +1 -1
- package/dist/support-B4ZBVxt3.d.ts +357 -0
- package/dist/svelte/index.d.ts +7 -7
- package/dist/svelte/index.js +1 -1
- package/dist/sveltekit/index.d.ts +4 -4
- package/dist/sveltekit/index.js +2 -2
- package/dist/{tags-BjHflcHF.d.ts → tags-qvVk79pp.d.ts} +1 -1
- package/dist/tanstack-db/index.d.ts +1 -1
- package/dist/tanstack-start/index.d.ts +3 -3
- package/dist/tanstack-start/index.js +2 -2
- package/dist/{tenant-yYg0E2-n.d.ts → tenant-DOKIJI62.d.ts} +1 -1
- package/dist/testing/index.d.ts +13 -12
- package/dist/{timeline-CtG0sehj.d.ts → timeline-CvTuXYvn.d.ts} +3 -3
- package/dist/{topic-CJrQZQaa.d.ts → topic-CZXHhZye.d.ts} +3 -3
- package/dist/{types-CAQBmpDx.d.ts → types-A4yyKEsg.d.ts} +1 -1
- package/dist/{types-SFRomQF7.d.ts → types-Czq9Xtpa.d.ts} +1 -7
- package/dist/{types-BBQLbui9.d.ts → types-DsRfiQ0v.d.ts} +1 -1
- package/dist/{usage-D7QkrwzV.d.ts → usage-Dp45V42p.d.ts} +1 -1
- package/dist/{verify-CMou8dWZ.d.ts → verify-CjvNLY7N.d.ts} +1 -1
- package/dist/vue/index.d.ts +7 -7
- package/dist/vue/index.js +1 -1
- package/dist/{watch-topic-BcGfvZOE.d.ts → watch-topic-BAxoPKZx.d.ts} +1 -1
- 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-BFHu4sci.d.ts → workflow-sdk-B3Ss55Fy.d.ts} +1 -1
- package/dist/{workflow-sdk-BVlFEB5Q.js → workflow-sdk-Cf0LAOFF.js} +2 -2
- package/dist/yjs/index.d.ts +1 -1
- package/package.json +1 -1
- package/schemas/doctor-report-v1.json +1 -0
- package/skills/better-supabase-api/SKILL.md +3 -1
- package/skills/better-supabase-auth/SKILL.md +7 -0
- package/dist/cli/add-DWjlVwvP.js +0 -1
package/dist/sql/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as BLOCK_OPTION_SCHEMAS, O as resolveBlock, j as BlockOptionsRegistry } from "../authorization-HZdJCaVm.js";
|
|
2
|
-
import { C as
|
|
3
|
-
import { a as appTableEventTypes } from "../app-tables-
|
|
4
|
-
import { $ as
|
|
5
|
-
export { APP_TABLES_MARKER, APP_TABLES_MODULE, AUDIT_CATEGORIES, type AdoptedTable, type AuditCategory, type AuditedTable, BLOCK_OPTION_SCHEMAS, BLOCK_RENAMES, type BlockOptionsRegistry, type BlockSql, type BlockSqlAccessProvider, type BlockSqlAction, type BlockSqlAudit, type BlockSqlContext, type BlockSqlContractFunction, type BlockSqlDeprecation, type BlockSqlEmit, type BlockSqlEntitlementsProvider, type BlockSqlExtension, type BlockSqlFile, type BlockSqlIdType, type BlockSqlLayout, type BlockSqlNames, type BlockSqlPermissionKey, type BlockSqlTableSpec, type BlockSqlTestFile, type BlockSqlTopic, type BlockSqlUpgrade, type BlockSqlUpgradePlan, type CompiledReadSet, DEFAULT_ROLES, type DataExportPlan, type DeclaredForeignKey, type EntityRenamePlan, type EntityRenameStep, type InstalledBlock, MODULE_ID_TYPES, type MigrationOptionUse, type PolicyGrant, SCOPE_ID_TYPES, SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, type TenantQuery, adoptedColumnProblems, adoptedTables, appTableEventTypes, appTablesFiles, auditRegistrations, blockFileState, blockSqlVersion, compileReadSet, compileReadSets, contractSignature, currentBlockName, customContracts, dataExportPlan, declaredPolicies, declaredTableColumns, declaredTables, declaredUpdatedAtTriggers, entityRenamePlan, excludedColumns, expiredFlagsQuery, extensionSchema, formerBlockName, hasColumnAccess, instanceFunctions, isBlockSqlIdType, isModuleDataFile, migrationOptionUses, moduleBody, moduleDataDir, moduleDeprecations, moduleEventTriggers, moduleFilePaths, moduleFileVersion, moduleHidingColumns, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, moduleTopics, notNullCheckName, policyGrants, renamedBlock, renderBlocks, resolveBlock, resolveBlocks, resolveExposeColumns, resolveProviderSql, rlsTables, sameBlockFile, sameTenantColumn, sameTenantLayout, sameTenantTrigger, scopePolicyName, scopeProblems, sharedRolesProblems, subjectColumns, templateFunctions, tenantsQuery, upgradePlan, widenedCommands };
|
|
2
|
+
import { C as OwnView, Qn as auditRegistrations, S as BlockSqlUpgrade, T as notNullCheckName, Xn as sameTenantLayout, Yn as DeclaredForeignKey, Zn as AuditedTable, _ as BlockSqlDeprecation, a as BlockSqlContext, b as BlockSqlLayout, c as BlockSqlIdType, d as MODULE_ID_TYPES, f as contractSignature, g as BlockSqlAccessProvider, h as BlockSql, i as BlockSqlAudit, l as BlockSqlNames, m as moduleIdType, n as AuditCategory, o as BlockSqlContractFunction, p as isBlockSqlIdType, r as BlockSqlAction, s as BlockSqlEmit, t as AUDIT_CATEGORIES, u as BlockSqlTableSpec, v as BlockSqlEntitlementsProvider, w as blockSqlVersion, x as BlockSqlTestFile, y as BlockSqlFile } from "../context-8kb8m5uO.js";
|
|
3
|
+
import { a as appTableEventTypes } from "../app-tables-yMQ4ubyY.js";
|
|
4
|
+
import { $ as modulePermissionKeys, A as sameTenantColumn, B as adoptedTables, C as extensionSchema, D as TenantQuery, E as subjectColumns, F as excludedColumns, G as DEFAULT_ROLES, H as APP_TABLES_MARKER, I as resolveExposeColumns, J as resolveBlocks, K as instanceFunctions, L as AdoptedTable, M as DataExportPlan, N as SECRET_COLUMNS, O as tenantsQuery, P as dataExportPlan, Q as moduleHidingColumns, R as AdoptedView, S as declaredViews, St as renderBlocks, T as rlsTables, U as APP_TABLES_MODULE, V as adoptedViews, W as appTablesFiles, X as BlockSqlPermissionKey, Y as BlockSqlExtension, Z as moduleEventTriggers, _ as DeclaredView, _t as upgradePlan, a as hasColumnAccess, at as moduleDataDir, b as declaredTables, bt as moduleBody, c as compileReadSets, ct as EntityRenameStep, d as migrationOptionUses, dt as currentBlockName, et as moduleSchemaExtensions, f as moduleLayout, ft as formerBlockName, g as templateFunctions, gt as moduleDeprecations, h as scopeProblems, ht as InstalledBlock, i as scopePolicyName, it as sameBlockFile, j as sameTenantTrigger, k as expiredFlagsQuery, l as sharedRolesProblems, lt as entityRenamePlan, m as resolveProviderSql, mt as BlockSqlUpgradePlan, n as widenedCommands, nt as isModuleDataFile, o as CompiledReadSet, ot as moduleFilePaths, p as SCOPE_ID_TYPES, pt as renamedBlock, q as SQL_MODULES, r as TENANT_SCOPE_POLICY, rt as moduleFileVersion, s as compileReadSet, st as EntityRenamePlan, t as declaredPolicies, tt as blockFileState, u as MigrationOptionUse, ut as BLOCK_RENAMES, v as PolicyGrant, vt as BlockSqlTopic, w as policyGrants, x as declaredUpdatedAtTriggers, xt as moduleTopics, y as declaredTableColumns, yt as customContracts, z as adoptedColumnProblems } from "../index-Cc4mIQS8.js";
|
|
5
|
+
export { APP_TABLES_MARKER, APP_TABLES_MODULE, AUDIT_CATEGORIES, type AdoptedTable, type AdoptedView, type AuditCategory, type AuditedTable, BLOCK_OPTION_SCHEMAS, BLOCK_RENAMES, type BlockOptionsRegistry, type BlockSql, type BlockSqlAccessProvider, type BlockSqlAction, type BlockSqlAudit, type BlockSqlContext, type BlockSqlContractFunction, type BlockSqlDeprecation, type BlockSqlEmit, type BlockSqlEntitlementsProvider, type BlockSqlExtension, type BlockSqlFile, type BlockSqlIdType, type BlockSqlLayout, type BlockSqlNames, type BlockSqlPermissionKey, type BlockSqlTableSpec, type BlockSqlTestFile, type BlockSqlTopic, type BlockSqlUpgrade, type BlockSqlUpgradePlan, type CompiledReadSet, DEFAULT_ROLES, type DataExportPlan, type DeclaredForeignKey, type DeclaredView, type EntityRenamePlan, type EntityRenameStep, type InstalledBlock, MODULE_ID_TYPES, type MigrationOptionUse, type OwnView, type PolicyGrant, SCOPE_ID_TYPES, SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, type TenantQuery, adoptedColumnProblems, adoptedTables, adoptedViews, appTableEventTypes, appTablesFiles, auditRegistrations, blockFileState, blockSqlVersion, compileReadSet, compileReadSets, contractSignature, currentBlockName, customContracts, dataExportPlan, declaredPolicies, declaredTableColumns, declaredTables, declaredUpdatedAtTriggers, declaredViews, entityRenamePlan, excludedColumns, expiredFlagsQuery, extensionSchema, formerBlockName, hasColumnAccess, instanceFunctions, isBlockSqlIdType, isModuleDataFile, migrationOptionUses, moduleBody, moduleDataDir, moduleDeprecations, moduleEventTriggers, moduleFilePaths, moduleFileVersion, moduleHidingColumns, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, moduleTopics, notNullCheckName, policyGrants, renamedBlock, renderBlocks, resolveBlock, resolveBlocks, resolveExposeColumns, resolveProviderSql, rlsTables, sameBlockFile, sameTenantColumn, sameTenantLayout, sameTenantTrigger, scopePolicyName, scopeProblems, sharedRolesProblems, subjectColumns, templateFunctions, tenantsQuery, upgradePlan, widenedCommands };
|
package/dist/sql/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as resolveBlock, l as appTableEventTypes, v as hasColumnAccess } from "../app-tables-D29Rahtg.js";
|
|
2
2
|
import { c as templateFunctions, o as resolveProviderSql, s as scopeProblems, t as SCOPE_ID_TYPES } from "../access-sql-B-MkVARa.js";
|
|
3
3
|
import { Y as notNullCheckName, a as DEFAULT_ROLES } from "../workflow-sdk-Bw6_u0ar.js";
|
|
4
|
-
import { $ as
|
|
5
|
-
export { APP_TABLES_MARKER, APP_TABLES_MODULE, AUDIT_CATEGORIES, BLOCK_OPTION_SCHEMAS, BLOCK_RENAMES, DEFAULT_ROLES, MODULE_ID_TYPES, SCOPE_ID_TYPES, SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, adoptedColumnProblems, adoptedTables, appTableEventTypes, appTablesFiles, auditRegistrations, blockFileState, blockSqlVersion, compileReadSet, compileReadSets, contractSignature, currentBlockName, customContracts, dataExportPlan, declaredPolicies, declaredTableColumns, declaredTables, declaredUpdatedAtTriggers, entityRenamePlan, excludedColumns, expiredFlagsQuery, extensionSchema, formerBlockName, hasColumnAccess, instanceFunctions, isBlockSqlIdType, isModuleDataFile, migrationOptionUses, moduleBody, moduleDataDir, moduleDeprecations, moduleEventTriggers, moduleFilePaths, moduleFileVersion, moduleHidingColumns, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, moduleTopics, notNullCheckName, policyGrants, renamedBlock, renderBlocks, resolveBlock, resolveBlocks, resolveExposeColumns, resolveProviderSql, rlsTables, sameBlockFile, sameTenantColumn, sameTenantLayout, sameTenantTrigger, scopePolicyName, scopeProblems, sharedRolesProblems, subjectColumns, templateFunctions, tenantsQuery, upgradePlan, widenedCommands };
|
|
4
|
+
import { $ as contractSignature, A as moduleFileVersion, B as resolveExposeColumns, C as APP_TABLES_MARKER, D as blockSqlVersion, E as scopePolicyName, F as moduleSchemaExtensions, G as sameTenantTrigger, H as dataExportPlan, I as SQL_MODULES, J as currentBlockName, K as migrationOptionUses, L as resolveBlocks, M as moduleEventTriggers, N as moduleHidingColumns, O as blockFileState, P as modulePermissionKeys, Q as MODULE_ID_TYPES, R as TENANT_SCOPE_POLICY, S as moduleFilePaths, T as appTablesFiles, U as subjectColumns, V as SECRET_COLUMNS, W as sameTenantColumn, X as renamedBlock, Y as formerBlockName, Z as AUDIT_CATEGORIES, _ as moduleDeprecations, a as tenantsQuery, at as declaredUpdatedAtTriggers, b as widenedCommands, c as adoptedColumnProblems, ct as policyGrants, d as instanceFunctions, et as isBlockSqlIdType, f as entityRenamePlan, g as renderBlocks, h as moduleTopics, i as moduleLayout, it as declaredTables, j as sameBlockFile, k as isModuleDataFile, l as adoptedTables, lt as rlsTables, m as moduleBody, n as compileReadSets, nt as BLOCK_OPTION_SCHEMAS, o as expiredFlagsQuery, ot as declaredViews, p as customContracts, q as BLOCK_RENAMES, r as sharedRolesProblems, rt as declaredTableColumns, s as sameTenantLayout, st as extensionSchema, t as compileReadSet, tt as moduleIdType, u as adoptedViews, ut as auditRegistrations, v as upgradePlan, w as APP_TABLES_MODULE, x as moduleDataDir, y as declaredPolicies, z as excludedColumns } from "../sql-Dl3Alk43.js";
|
|
5
|
+
export { APP_TABLES_MARKER, APP_TABLES_MODULE, AUDIT_CATEGORIES, BLOCK_OPTION_SCHEMAS, BLOCK_RENAMES, DEFAULT_ROLES, MODULE_ID_TYPES, SCOPE_ID_TYPES, SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, adoptedColumnProblems, adoptedTables, adoptedViews, appTableEventTypes, appTablesFiles, auditRegistrations, blockFileState, blockSqlVersion, compileReadSet, compileReadSets, contractSignature, currentBlockName, customContracts, dataExportPlan, declaredPolicies, declaredTableColumns, declaredTables, declaredUpdatedAtTriggers, declaredViews, entityRenamePlan, excludedColumns, expiredFlagsQuery, extensionSchema, formerBlockName, hasColumnAccess, instanceFunctions, isBlockSqlIdType, isModuleDataFile, migrationOptionUses, moduleBody, moduleDataDir, moduleDeprecations, moduleEventTriggers, moduleFilePaths, moduleFileVersion, moduleHidingColumns, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, moduleTopics, notNullCheckName, policyGrants, renamedBlock, renderBlocks, resolveBlock, resolveBlocks, resolveExposeColumns, resolveProviderSql, rlsTables, sameBlockFile, sameTenantColumn, sameTenantLayout, sameTenantTrigger, scopePolicyName, scopeProblems, sharedRolesProblems, subjectColumns, templateFunctions, tenantsQuery, upgradePlan, widenedCommands };
|
|
@@ -774,6 +774,108 @@ function declaredTables(files, schemas) {
|
|
|
774
774
|
}
|
|
775
775
|
return [...found];
|
|
776
776
|
}
|
|
777
|
+
const VIEW = /* @__PURE__ */ new RegExp(String.raw`\bcreate\s+(?:or\s+replace\s+)?(?:(?:temp|temporary|recursive)\s+)?(materialized\s+)?view\s+(?:if\s+not\s+exists\s+)?(${TABLE_NAME$4})\s*(\()?`, "gi");
|
|
778
|
+
const DROP_VIEW = /* @__PURE__ */ new RegExp(String.raw`\bdrop\s+(?:materialized\s+)?view\s+(?:if\s+exists\s+)?(${TABLE_NAME$4}(?:\s*,\s*${TABLE_NAME$4})*)`, "gi");
|
|
779
|
+
const INSTEAD_OF_TRIGGER = /* @__PURE__ */ new RegExp(String.raw`\bcreate\s+(?:or\s+replace\s+)?trigger\s+${NAME$9}\s+instead\s+of\b[^;]*?\bon\s+(${TABLE_NAME$4})`, "gi");
|
|
780
|
+
/**
|
|
781
|
+
* What keeps Postgres from writing through a view to its table: a view that has
|
|
782
|
+
* one of these is not auto-updatable.
|
|
783
|
+
*/
|
|
784
|
+
const NOT_UPDATABLE = /\b(?:(?:distinct|group\s+by|having|limit|offset|fetch\s+first|union|intersect|except|join|window)\b|over\s*\(|(?:count|sum|avg|min|max|array_agg|string_agg|jsonb_agg|json_agg|bool_and|bool_or)\s*\()/i;
|
|
785
|
+
/** The word that ends a view's select list, at the top level. */
|
|
786
|
+
const SELECT_END$1 = /\bfrom\b/i;
|
|
787
|
+
const ALIAS = /* @__PURE__ */ new RegExp(String.raw`\bas\s+(${NAME$9})\s*$`, "i");
|
|
788
|
+
const BARE_COLUMN = /* @__PURE__ */ new RegExp(String.raw`^(?:${NAME$9}\s*\.\s*)*(${NAME$9})$`);
|
|
789
|
+
/**
|
|
790
|
+
* The view's columns from its select list: each item's alias, or the column it
|
|
791
|
+
* names. `undefined` when an item is `*` or has no name to read.
|
|
792
|
+
*/
|
|
793
|
+
function selectColumns(body) {
|
|
794
|
+
const select = /^\s*(?:\(\s*)?select\s+/i.exec(body);
|
|
795
|
+
if (select === null) return;
|
|
796
|
+
let rest = body.slice(select[0].length);
|
|
797
|
+
const distinct = /^distinct\s+on\s*\(/i.exec(rest);
|
|
798
|
+
if (distinct === null) rest = rest.replace(/^(?:distinct|all)\b/i, "");
|
|
799
|
+
else {
|
|
800
|
+
const close = closingParen(rest, distinct[0].length - 1);
|
|
801
|
+
if (close === -1) return;
|
|
802
|
+
rest = rest.slice(close + 1);
|
|
803
|
+
}
|
|
804
|
+
const end = topLevelIndex(rest, SELECT_END$1);
|
|
805
|
+
const items = splitTopLevel(end === -1 ? rest : rest.slice(0, end));
|
|
806
|
+
const columns = [];
|
|
807
|
+
for (const item of items) {
|
|
808
|
+
const alias = ALIAS.exec(item)?.[1] ?? BARE_COLUMN.exec(item.trim())?.[1];
|
|
809
|
+
if (alias === void 0 || item.trim().endsWith("*")) return;
|
|
810
|
+
columns.push(unquote$4(alias));
|
|
811
|
+
}
|
|
812
|
+
return columns;
|
|
813
|
+
}
|
|
814
|
+
/** The first match of `pattern` outside parentheses and quotes, or -1. */
|
|
815
|
+
function topLevelIndex(text, pattern) {
|
|
816
|
+
let depth = 0;
|
|
817
|
+
let quote;
|
|
818
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
819
|
+
const char = text[i];
|
|
820
|
+
if (quote) {
|
|
821
|
+
if (char === quote) quote = void 0;
|
|
822
|
+
} else if (char === "'" || char === "\"") quote = char;
|
|
823
|
+
else if (char === "(") depth += 1;
|
|
824
|
+
else if (char === ")") depth -= 1;
|
|
825
|
+
else if (depth === 0 && /\w/.test(char) && !/\w/.test(text[i - 1] ?? "") && pattern.exec(text.slice(i))?.index === 0) return i;
|
|
826
|
+
}
|
|
827
|
+
return -1;
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* The views and materialized views `files` create, as `schema.view`, with their
|
|
831
|
+
* columns and whether they are auto-updatable. A later `drop view` removes one.
|
|
832
|
+
* Only views in `schemas` are kept.
|
|
833
|
+
*/
|
|
834
|
+
function declaredViews(files, schemas) {
|
|
835
|
+
const found = /* @__PURE__ */ new Map();
|
|
836
|
+
const insteadOf = /* @__PURE__ */ new Set();
|
|
837
|
+
for (const file of files) {
|
|
838
|
+
const text = withoutComments$1(file.text);
|
|
839
|
+
for (const match of text.matchAll(INSTEAD_OF_TRIGGER)) insteadOf.add(qualified$8(match[1]));
|
|
840
|
+
inOrder([[...text.matchAll(VIEW)].map((match) => ({
|
|
841
|
+
index: match.index,
|
|
842
|
+
apply: () => {
|
|
843
|
+
const view = qualified$8(match[2]);
|
|
844
|
+
if (!schemas.includes(view.slice(0, view.indexOf(".")))) return;
|
|
845
|
+
let at = match.index + match[0].length;
|
|
846
|
+
let listed;
|
|
847
|
+
if (match[3] !== void 0) {
|
|
848
|
+
const close = closingParen(text, at - 1);
|
|
849
|
+
if (close === -1) return;
|
|
850
|
+
listed = splitTopLevel(text.slice(at, close)).map((column) => unquote$4(column.trim()));
|
|
851
|
+
at = close + 1;
|
|
852
|
+
}
|
|
853
|
+
const as = /\bas\b/i.exec(text.slice(at));
|
|
854
|
+
if (as === null) return;
|
|
855
|
+
const start = at + as.index + as[0].length;
|
|
856
|
+
const end = text.indexOf(";", start);
|
|
857
|
+
const body = text.slice(start, end === -1 ? text.length : end);
|
|
858
|
+
found.set(view, {
|
|
859
|
+
columns: listed ?? selectColumns(body),
|
|
860
|
+
updatable: match[1] === void 0 && !NOT_UPDATABLE.test(body)
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
})), [...text.matchAll(DROP_VIEW)].map((match) => ({
|
|
864
|
+
index: match.index,
|
|
865
|
+
apply: () => {
|
|
866
|
+
for (const view of droppedTables(match[1])) found.delete(view);
|
|
867
|
+
}
|
|
868
|
+
}))]);
|
|
869
|
+
}
|
|
870
|
+
for (const view of insteadOf) {
|
|
871
|
+
const entry = found.get(view);
|
|
872
|
+
if (entry !== void 0) found.set(view, {
|
|
873
|
+
...entry,
|
|
874
|
+
updatable: true
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
return found;
|
|
878
|
+
}
|
|
777
879
|
const RLS_TOGGLE = /* @__PURE__ */ new RegExp(String.raw`\balter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?(${NAME$9}(?:\s*\.\s*${NAME$9})?)\s+(enable|disable)\s+row\s+level\s+security\b`, "gi");
|
|
778
880
|
/**
|
|
779
881
|
* The tables in `schemas` that `files` leave with row level security on: `alter
|
|
@@ -983,6 +1085,7 @@ function declaredUpdatedAtTriggers(files, schemas) {
|
|
|
983
1085
|
}
|
|
984
1086
|
//#endregion
|
|
985
1087
|
//#region src/sql/over-app-tables.ts
|
|
1088
|
+
const TABLE_NAME$3 = String.raw`${NAME$9}(?:\s*\.\s*${NAME$9})?`;
|
|
986
1089
|
/** Comments replaced by spaces, so offsets into `text` stay the same. */
|
|
987
1090
|
function maskComments(text) {
|
|
988
1091
|
return text.replaceAll(/--[^\n]*/g, (comment) => " ".repeat(comment.length)).replaceAll(/\/\*[\s\S]*?\*\//g, (comment) => comment.replaceAll(/[^\n]/g, " "));
|
|
@@ -1068,7 +1171,6 @@ function withoutUnmappedTables(sql, instance) {
|
|
|
1068
1171
|
if (use !== null) throw new TypeError(`Module "${instance}" needs table "${use[1]}", which blocks.${instance}.tables maps to null`);
|
|
1069
1172
|
return out;
|
|
1070
1173
|
}
|
|
1071
|
-
const TABLE_NAME$3 = String.raw`${NAME$9}(?:\s*\.\s*${NAME$9})?`;
|
|
1072
1174
|
const ALTER_CONSTRAINT = /* @__PURE__ */ new RegExp(String.raw`^[ \t]*alter\s+table\s+(?:only\s+)?(${TABLE_NAME$3})\s+(?:add\s+constraint|drop\s+constraint|validate\s+constraint|alter\s+column)\b[^;]*;[ \t]*\n?`, "gim");
|
|
1073
1175
|
const REVOKE = /* @__PURE__ */ new RegExp(String.raw`^[ \t]*revoke\s[^;]*?\son\s+(?:table\s+)?(${TABLE_NAME$3})\s+from\b[^;]*;[ \t]*\n?`, "gim");
|
|
1074
1176
|
const ENSURE_CHECK = /^do \$\$\nbegin\n {2}if coalesce\(obj_description\(\(\n\s+select c\.oid from pg_catalog\.pg_constraint c\n\s+where c\.conrelid = '([^']+)'::regclass[\s\S]*?\n\$\$;\n?/gm;
|
|
@@ -1082,6 +1184,42 @@ function withoutAppTableEdits(sql, appTables) {
|
|
|
1082
1184
|
const drop = (statement, table) => appTables.has(qualified$8(table)) ? "" : statement;
|
|
1083
1185
|
return sql.replaceAll(ALTER_CONSTRAINT, drop).replaceAll(REVOKE, drop).replaceAll(ENSURE_CHECK, drop);
|
|
1084
1186
|
}
|
|
1187
|
+
/**
|
|
1188
|
+
* The relation a DDL statement builds or changes: its table, index, grant,
|
|
1189
|
+
* policy, trigger or comment target.
|
|
1190
|
+
*/
|
|
1191
|
+
const DDL_TARGETS = [
|
|
1192
|
+
new RegExp(String.raw`^\s*create\s+(?:unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?(${TABLE_NAME$3})`, "i"),
|
|
1193
|
+
new RegExp(String.raw`^\s*alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?(${TABLE_NAME$3})`, "i"),
|
|
1194
|
+
new RegExp(String.raw`^\s*create\s+(?:unique\s+)?index\s+(?:concurrently\s+)?(?:if\s+not\s+exists\s+)?(?:${NAME$9}\s+)?on\s+(?:only\s+)?(${TABLE_NAME$3})`, "i"),
|
|
1195
|
+
new RegExp(String.raw`^\s*(?:grant|revoke)\s[^;]*?\bon\s+(?:table\s+)?(${TABLE_NAME$3})\s+(?:to|from)\b`, "i"),
|
|
1196
|
+
new RegExp(String.raw`^\s*(?:create|alter|drop)\s+policy\s+(?:if\s+exists\s+)?${NAME$9}\s+on\s+(${TABLE_NAME$3})`, "i"),
|
|
1197
|
+
new RegExp(String.raw`^\s*create\s+(?:or\s+replace\s+)?(?:constraint\s+)?trigger\s+${NAME$9}\s[^;]*?\bon\s+(${TABLE_NAME$3})`, "i"),
|
|
1198
|
+
new RegExp(String.raw`^\s*drop\s+trigger\s+(?:if\s+exists\s+)?${NAME$9}\s+on\s+(${TABLE_NAME$3})`, "i"),
|
|
1199
|
+
new RegExp(String.raw`^\s*comment\s+on\s+table\s+(${TABLE_NAME$3})`, "i"),
|
|
1200
|
+
new RegExp(String.raw`^\s*comment\s+on\s+column\s+(${TABLE_NAME$3})\s*\.\s*${NAME$9}`, "i")
|
|
1201
|
+
];
|
|
1202
|
+
/**
|
|
1203
|
+
* `sql` without the statements that build or change the app's views in `views`
|
|
1204
|
+
* (as `schema.view`): their `create table`, columns, constraints, indexes, row
|
|
1205
|
+
* level security, grants, revokes, policies, triggers and comments. The
|
|
1206
|
+
* functions that read the views stay.
|
|
1207
|
+
*/
|
|
1208
|
+
function overAppViews(sql, views) {
|
|
1209
|
+
if (views.size === 0) return sql;
|
|
1210
|
+
const said = /* @__PURE__ */ new Set();
|
|
1211
|
+
return statementSpans(sql).map(([from, to]) => {
|
|
1212
|
+
const statement = sql.slice(from, to);
|
|
1213
|
+
const masked = maskComments(statement);
|
|
1214
|
+
const target = DDL_TARGETS.map((pattern) => pattern.exec(masked)?.[1]).find((match) => match !== void 0);
|
|
1215
|
+
const view = target === void 0 ? void 0 : qualified$8(target);
|
|
1216
|
+
if (view === void 0 || !views.has(view)) return statement;
|
|
1217
|
+
const lead = /^\s*/.exec(statement)[0];
|
|
1218
|
+
if (said.has(view)) return "";
|
|
1219
|
+
said.add(view);
|
|
1220
|
+
return `${lead}-- ${view} is the app's view: this block writes only the functions that read it.`;
|
|
1221
|
+
}).join("");
|
|
1222
|
+
}
|
|
1085
1223
|
const COLUMN_NAME$1 = /^("(?:[^"]|"")+"|[a-z_][\w$]*)/i;
|
|
1086
1224
|
const TABLE_CONSTRAINT$1 = /^(constraint|check|unique|primary|foreign|exclude|like)\b/i;
|
|
1087
1225
|
function unquote$3(name) {
|
|
@@ -1157,8 +1295,13 @@ function appOwnedTables(input) {
|
|
|
1157
1295
|
function tableOwnership(input, column, requiredColumn) {
|
|
1158
1296
|
const appOwned = appOwnedTables(input);
|
|
1159
1297
|
const overApp = appOwned.length > 0;
|
|
1298
|
+
const views = input.source.ownViews ?? {};
|
|
1160
1299
|
return {
|
|
1161
1300
|
appOwned,
|
|
1301
|
+
appViews: appOwned.filter((logical) => {
|
|
1302
|
+
const parts = input.tableName(logical);
|
|
1303
|
+
return Object.hasOwn(views, `${parts.schema}.${parts.name}`);
|
|
1304
|
+
}),
|
|
1162
1305
|
owns: (logical) => {
|
|
1163
1306
|
input.tableName(logical);
|
|
1164
1307
|
return input.config.mode !== "custom" && !appOwned.includes(logical);
|
|
@@ -2255,6 +2398,83 @@ function guestOr(sql, checks) {
|
|
|
2255
2398
|
return live.length === 0 ? sql : `(${sql}) or ${live.join(" or ")}`;
|
|
2256
2399
|
}
|
|
2257
2400
|
//#endregion
|
|
2401
|
+
//#region src/sql/view-columns.ts
|
|
2402
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
2403
|
+
/**
|
|
2404
|
+
* The columns of the app's views that a block reads. A view can't take the
|
|
2405
|
+
* columns a block would add to a table, so each optional column (`optional` in
|
|
2406
|
+
* the table's spec) a view lacks counts as mapped to `null`, unless the config
|
|
2407
|
+
* maps it; any other column a view lacks is in `missing`. Views whose columns
|
|
2408
|
+
* aren't known are left alone.
|
|
2409
|
+
*/
|
|
2410
|
+
function viewColumns(layout, modules, namesOf) {
|
|
2411
|
+
const views = layout.ownViews;
|
|
2412
|
+
if (modules === void 0 || views === void 0 || Object.keys(views).length === 0) return {
|
|
2413
|
+
modules,
|
|
2414
|
+
missing: []
|
|
2415
|
+
};
|
|
2416
|
+
const known = cache.get(layout)?.get(modules);
|
|
2417
|
+
if (known !== void 0) return known;
|
|
2418
|
+
const out = { ...modules };
|
|
2419
|
+
const missing = [];
|
|
2420
|
+
for (const [block, config] of Object.entries(modules)) {
|
|
2421
|
+
const names = namesOf(block);
|
|
2422
|
+
if (config === void 0 || names === void 0 || !Object.values(names.tables).some((spec) => spec.app !== void 0)) continue;
|
|
2423
|
+
const ctx = createModuleContext(block, namesOf, {
|
|
2424
|
+
modules,
|
|
2425
|
+
...layout.ownTables ? { ownTables: layout.ownTables } : {},
|
|
2426
|
+
ownViews: views
|
|
2427
|
+
});
|
|
2428
|
+
const configured = config.columns ?? {};
|
|
2429
|
+
const columns = {};
|
|
2430
|
+
for (const logical of ctx.appViews) {
|
|
2431
|
+
const parts = ctx.tableName(logical);
|
|
2432
|
+
const view = `${parts.schema}.${parts.name}`;
|
|
2433
|
+
const has = layout.ownColumns?.[view];
|
|
2434
|
+
const spec = names.tables[logical];
|
|
2435
|
+
if (has === void 0 || spec.app === void 0) continue;
|
|
2436
|
+
const unused = new Set(spec.app.unused?.(ctx));
|
|
2437
|
+
for (const column of Object.keys(spec.columns)) {
|
|
2438
|
+
if (unused.has(column) || !ctx.has(logical, column)) continue;
|
|
2439
|
+
const physical = ctx.colName(logical, column);
|
|
2440
|
+
if (has.includes(physical)) continue;
|
|
2441
|
+
if (spec.optional?.includes(column) === true && configured[logical]?.[column] === void 0) columns[logical] = {
|
|
2442
|
+
...columns[logical],
|
|
2443
|
+
[column]: null
|
|
2444
|
+
};
|
|
2445
|
+
else missing.push({
|
|
2446
|
+
block,
|
|
2447
|
+
view,
|
|
2448
|
+
column: physical
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
if (Object.keys(columns).length > 0) out[block] = {
|
|
2453
|
+
...config,
|
|
2454
|
+
columns: Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(configured), ...Object.keys(columns)])].map((logical) => [logical, {
|
|
2455
|
+
...configured[logical],
|
|
2456
|
+
...columns[logical]
|
|
2457
|
+
}]))
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
const result = {
|
|
2461
|
+
modules: Object.keys(out).some((block) => out[block] !== modules[block]) ? out : modules,
|
|
2462
|
+
missing
|
|
2463
|
+
};
|
|
2464
|
+
const byModules = cache.get(layout) ?? /* @__PURE__ */ new WeakMap();
|
|
2465
|
+
byModules.set(modules, result);
|
|
2466
|
+
cache.set(layout, byModules);
|
|
2467
|
+
return result;
|
|
2468
|
+
}
|
|
2469
|
+
/**
|
|
2470
|
+
* Throws when a view of the app's at a block table's name lacks a column the
|
|
2471
|
+
* block needs, naming the view and the column.
|
|
2472
|
+
*/
|
|
2473
|
+
function assertViewColumns(missing) {
|
|
2474
|
+
if (missing[0] === void 0) return;
|
|
2475
|
+
throw new TypeError([...missing.map((each) => `blocks.${each.block} reads ${each.view}.${each.column}, which the view doesn't have.`), "Add the column to the view, or map it in blocks.<name>.columns to one the view has."].join("\n"));
|
|
2476
|
+
}
|
|
2477
|
+
//#endregion
|
|
2258
2478
|
//#region src/sql/module-context.ts
|
|
2259
2479
|
let bound;
|
|
2260
2480
|
/**
|
|
@@ -2282,6 +2502,7 @@ function moduleContext(name, layout = {}, installed, instance) {
|
|
|
2282
2502
|
...layout.subjects ? { subjects: layout.subjects } : {},
|
|
2283
2503
|
...layout.appTables ? { appTables: Object.keys(layout.appTables) } : {},
|
|
2284
2504
|
...layout.ownTables ? { ownTables: layout.ownTables } : {},
|
|
2505
|
+
...layout.ownViews ? { ownViews: layout.ownViews } : {},
|
|
2285
2506
|
...installed ? { installed } : {},
|
|
2286
2507
|
...layout.instances ? { instances: layout.instances } : {},
|
|
2287
2508
|
...instance === void 0 || instance === name ? {} : { instance },
|
|
@@ -2311,7 +2532,14 @@ function moduleContext(name, layout = {}, installed, instance) {
|
|
|
2311
2532
|
* a roles table, gets the same `roleThrough`, unless the config sets one.
|
|
2312
2533
|
*/
|
|
2313
2534
|
function withProviderDefaults(layout) {
|
|
2314
|
-
return
|
|
2535
|
+
return viewColumnsOf(layout).modules;
|
|
2536
|
+
}
|
|
2537
|
+
/**
|
|
2538
|
+
* The provider defaults, then the optional columns the app's views lack mapped
|
|
2539
|
+
* to `null`, with the required columns they lack.
|
|
2540
|
+
*/
|
|
2541
|
+
function viewColumnsOf(layout) {
|
|
2542
|
+
return viewColumns(layout, withProviderRoles(layout, withProviderSuspension(layout)), (module) => registry().modules[module]?.names);
|
|
2315
2543
|
}
|
|
2316
2544
|
/**
|
|
2317
2545
|
* `blocks.permissions.disabled` from the provider's `suspension` under the
|
|
@@ -3057,7 +3285,7 @@ function tenantSql(ctx, layout) {
|
|
|
3057
3285
|
)` : ` select has_organization_role.organization in (
|
|
3058
3286
|
select ${ctx.fn("member_organization_ids")}(has_organization_role.roles)
|
|
3059
3287
|
)`;
|
|
3060
|
-
const memberRoleFilter = members.idsFor === void 0 ? "" : ` and m.${tenant} in (select p.id from ${members.idsFor("organization_member_role.member")} as p(id))`;
|
|
3288
|
+
const memberRoleFilter = `${active}${members.idsFor === void 0 ? "" : ` and m.${tenant} in (select p.id from ${members.idsFor("organization_member_role.member")} as p(id))`}`;
|
|
3061
3289
|
const claimJson = ctx.text("claimFormat", "array") === "map" ? `coalesce(jsonb_object_agg(m.${tenant}::text, ${role}), '{}'::jsonb)` : `coalesce(jsonb_agg(jsonb_build_object(
|
|
3062
3290
|
'scope', ${sqlString(ctx.claims.scope)},
|
|
3063
3291
|
'id', m.${tenant},
|
|
@@ -7359,6 +7587,7 @@ const MAX_IDENTIFIER = 63;
|
|
|
7359
7587
|
function lockModuleTable(ctx, logical, options = {}) {
|
|
7360
7588
|
const table = ctx.table(logical);
|
|
7361
7589
|
if (!ctx.appOwned.includes(logical)) return lockTable(table, options);
|
|
7590
|
+
if (ctx.appViews.includes(logical)) return "";
|
|
7362
7591
|
return `alter table ${table} enable row level security;
|
|
7363
7592
|
${options.read ? `grant select on ${table} to authenticated;\n` : ""}grant all on ${table} to service_role;`;
|
|
7364
7593
|
}
|
|
@@ -7377,7 +7606,7 @@ function asText(ctx, logical, expr) {
|
|
|
7377
7606
|
* `where` clause.
|
|
7378
7607
|
*/
|
|
7379
7608
|
function appUniqueIndex(ctx, logical, columns, where) {
|
|
7380
|
-
if (!ctx.appOwned.includes(logical)) return "";
|
|
7609
|
+
if (!ctx.appOwned.includes(logical) || ctx.appViews.includes(logical)) return "";
|
|
7381
7610
|
const physical = columns.map((column) => ctx.colName(logical, column));
|
|
7382
7611
|
const name = `${ctx.tableName(logical).name}_${physical.join("_")}_key`;
|
|
7383
7612
|
return `\ncreate unique index if not exists ${sqlIdent(name.slice(0, MAX_IDENTIFIER))} on ${ctx.table(logical)} (${physical.map((column) => sqlIdent(column)).join(", ")})${where === void 0 ? "" : ` where ${where}`};`;
|
|
@@ -68034,6 +68263,8 @@ $$;
|
|
|
68034
68263
|
-- False when the token is narrower than the permission: a permission cap
|
|
68035
68264
|
-- (bsb_permission_cap) without the key, or a delegated token whose scopes
|
|
68036
68265
|
-- don't map to it. True for every other token, the service role included.
|
|
68266
|
+
-- 0.14 named the cap bs_permission_cap; 0.15 still reads it when the new
|
|
68267
|
+
-- claim is missing, so a cap from an older runAs keeps narrowing.
|
|
68037
68268
|
create or replace function better_supabase.cap_allows(permission text)
|
|
68038
68269
|
returns boolean
|
|
68039
68270
|
language sql
|
|
@@ -68043,9 +68274,9 @@ set search_path = ''
|
|
|
68043
68274
|
as $$
|
|
68044
68275
|
select case
|
|
68045
68276
|
when jwt is null then true
|
|
68046
|
-
when jsonb_typeof(
|
|
68277
|
+
when jsonb_typeof(cap) = 'array'
|
|
68047
68278
|
and not exists (
|
|
68048
|
-
select 1 from jsonb_array_elements_text(
|
|
68279
|
+
select 1 from jsonb_array_elements_text(cap) c(key)
|
|
68049
68280
|
where better_supabase.permission_matches(c.key, cap_allows.permission)
|
|
68050
68281
|
) then false
|
|
68051
68282
|
when coalesce(jwt ->> 'client_id', '') = ''
|
|
@@ -68065,6 +68296,9 @@ as $$
|
|
|
68065
68296
|
)
|
|
68066
68297
|
end
|
|
68067
68298
|
from (select auth.jwt() as jwt) as token
|
|
68299
|
+
cross join lateral (
|
|
68300
|
+
select coalesce(jwt -> 'bsb_permission_cap', jwt -> 'bs_permission_cap') as cap
|
|
68301
|
+
) as capped
|
|
68068
68302
|
$$;`;
|
|
68069
68303
|
}
|
|
68070
68304
|
//#endregion
|
|
@@ -94675,6 +94909,133 @@ $$;
|
|
|
94675
94909
|
revoke execute on function better_supabase.check_rate_limit(text, text, integer, interval) from public, anon, authenticated;
|
|
94676
94910
|
grant execute on function better_supabase.check_rate_limit(text, text, integer, interval) to service_role;
|
|
94677
94911
|
|
|
94912
|
+
-- Counts one hit against several limits at once: hits is a JSON array of
|
|
94913
|
+
-- { scope, key, max_requests?, period? }, each with its own scope and key.
|
|
94914
|
+
-- The counters are locked in a fixed order and the hit counts only when every
|
|
94915
|
+
-- limit allows it, so a refused call leaves every counter as it was. Returns
|
|
94916
|
+
-- { allowed, blocked, retry_after, results }: blocked is the index of the first
|
|
94917
|
+
-- limit over its maximum, retry_after the longest wait of the refusing
|
|
94918
|
+
-- limits, and results one { allowed, remaining, retry_after } per hit.
|
|
94919
|
+
create or replace function better_supabase.check_rate_limits(hits jsonb)
|
|
94920
|
+
returns jsonb
|
|
94921
|
+
language plpgsql
|
|
94922
|
+
security definer
|
|
94923
|
+
set search_path = ''
|
|
94924
|
+
as $$
|
|
94925
|
+
declare
|
|
94926
|
+
total integer;
|
|
94927
|
+
scopes text[] := '{}';
|
|
94928
|
+
keys text[] := '{}';
|
|
94929
|
+
maxes integer[] := '{}';
|
|
94930
|
+
periods interval[] := '{}';
|
|
94931
|
+
used integer[] := '{}';
|
|
94932
|
+
starts timestamptz[] := '{}';
|
|
94933
|
+
hit jsonb;
|
|
94934
|
+
rule better_supabase.rate_limit_rules;
|
|
94935
|
+
counter better_supabase.rate_limits;
|
|
94936
|
+
limit_max integer;
|
|
94937
|
+
limit_period interval;
|
|
94938
|
+
current_hits integer;
|
|
94939
|
+
first_blocked integer;
|
|
94940
|
+
longest integer := 0;
|
|
94941
|
+
passed boolean;
|
|
94942
|
+
results jsonb := '[]'::jsonb;
|
|
94943
|
+
begin
|
|
94944
|
+
if jsonb_typeof(hits) is distinct from 'array' or jsonb_array_length(hits) = 0 then
|
|
94945
|
+
raise exception 'check_rate_limits needs a non-empty array of hits'
|
|
94946
|
+
using errcode = '22023', hint = 'RATE_LIMIT_HITS';
|
|
94947
|
+
end if;
|
|
94948
|
+
total := jsonb_array_length(hits);
|
|
94949
|
+
for i in 1 .. total loop
|
|
94950
|
+
hit := hits -> (i - 1);
|
|
94951
|
+
if coalesce(hit ->> 'scope', '') = '' or (hit ->> 'key') is null then
|
|
94952
|
+
raise exception 'Hit % of check_rate_limits needs a scope and a key', i - 1
|
|
94953
|
+
using errcode = '22023', hint = 'RATE_LIMIT_HITS';
|
|
94954
|
+
end if;
|
|
94955
|
+
select * into rule from better_supabase.rate_limit_rules r where r.scope = hit ->> 'scope';
|
|
94956
|
+
limit_max := coalesce((hit ->> 'max_requests')::integer, rule.max_requests);
|
|
94957
|
+
limit_period := coalesce((hit ->> 'period')::interval, rule.period);
|
|
94958
|
+
if limit_max is null or limit_period is null then
|
|
94959
|
+
raise exception 'No rate limit for %: call set_rate_limit or pass max_requests and period', hit ->> 'scope'
|
|
94960
|
+
using errcode = '22023', hint = 'RATE_LIMIT_UNKNOWN';
|
|
94961
|
+
end if;
|
|
94962
|
+
if limit_max < 1 or limit_period <= interval '0' then
|
|
94963
|
+
raise exception 'The rate limit for % needs a positive max_requests and period', hit ->> 'scope'
|
|
94964
|
+
using errcode = '22023', hint = 'RATE_LIMIT_HITS';
|
|
94965
|
+
end if;
|
|
94966
|
+
for j in 1 .. i - 1 loop
|
|
94967
|
+
if scopes[j] = hit ->> 'scope' and keys[j] = hit ->> 'key' then
|
|
94968
|
+
raise exception 'Hits % and % of check_rate_limits count the same scope % and key; give each limit its own scope', j - 1, i - 1, hit ->> 'scope'
|
|
94969
|
+
using errcode = '22023', hint = 'RATE_LIMIT_HITS';
|
|
94970
|
+
end if;
|
|
94971
|
+
end loop;
|
|
94972
|
+
scopes := scopes || (hit ->> 'scope');
|
|
94973
|
+
keys := keys || (hit ->> 'key');
|
|
94974
|
+
maxes := maxes || limit_max;
|
|
94975
|
+
periods := periods || limit_period;
|
|
94976
|
+
end loop;
|
|
94977
|
+
|
|
94978
|
+
insert into better_supabase.rate_limits as l (scope, key, window_start, hits, period)
|
|
94979
|
+
select u.scope, u.key, now(), 0, u.period
|
|
94980
|
+
from unnest(scopes, keys, periods) as u(scope, key, period)
|
|
94981
|
+
order by u.scope, u.key
|
|
94982
|
+
on conflict on constraint rate_limits_pkey do nothing;
|
|
94983
|
+
|
|
94984
|
+
perform 1
|
|
94985
|
+
from better_supabase.rate_limits l
|
|
94986
|
+
join unnest(scopes, keys) as u(scope, key) on l.scope = u.scope and l.key = u.key
|
|
94987
|
+
order by l.scope, l.key
|
|
94988
|
+
for update of l;
|
|
94989
|
+
|
|
94990
|
+
for i in 1 .. total loop
|
|
94991
|
+
select * into counter from better_supabase.rate_limits l
|
|
94992
|
+
where l.scope = scopes[i] and l.key = keys[i];
|
|
94993
|
+
if counter.window_start + periods[i] <= now() then
|
|
94994
|
+
used := used || 0;
|
|
94995
|
+
starts := starts || now();
|
|
94996
|
+
else
|
|
94997
|
+
used := used || counter.hits;
|
|
94998
|
+
starts := starts || counter.window_start;
|
|
94999
|
+
end if;
|
|
95000
|
+
if used[i] + 1 > maxes[i] then
|
|
95001
|
+
longest := greatest(longest, greatest(1, ceil(extract(epoch from starts[i] + periods[i] - now()))::integer));
|
|
95002
|
+
first_blocked := coalesce(first_blocked, i - 1);
|
|
95003
|
+
end if;
|
|
95004
|
+
end loop;
|
|
95005
|
+
|
|
95006
|
+
passed := first_blocked is null;
|
|
95007
|
+
|
|
95008
|
+
if passed then
|
|
95009
|
+
for i in 1 .. total loop
|
|
95010
|
+
update better_supabase.rate_limits l set
|
|
95011
|
+
window_start = starts[i],
|
|
95012
|
+
hits = used[i] + 1,
|
|
95013
|
+
period = periods[i]
|
|
95014
|
+
where l.scope = scopes[i] and l.key = keys[i];
|
|
95015
|
+
end loop;
|
|
95016
|
+
end if;
|
|
95017
|
+
|
|
95018
|
+
for i in 1 .. total loop
|
|
95019
|
+
current_hits := used[i] + case when passed then 1 else 0 end;
|
|
95020
|
+
results := results || jsonb_build_array(jsonb_build_object(
|
|
95021
|
+
'allowed', used[i] + 1 <= maxes[i],
|
|
95022
|
+
'remaining', greatest(maxes[i] - current_hits, 0),
|
|
95023
|
+
'retry_after', case when used[i] + 1 <= maxes[i] then 0
|
|
95024
|
+
else greatest(1, ceil(extract(epoch from starts[i] + periods[i] - now()))::integer) end
|
|
95025
|
+
));
|
|
95026
|
+
end loop;
|
|
95027
|
+
|
|
95028
|
+
return jsonb_build_object(
|
|
95029
|
+
'allowed', passed,
|
|
95030
|
+
'blocked', first_blocked,
|
|
95031
|
+
'retry_after', longest,
|
|
95032
|
+
'results', results
|
|
95033
|
+
);
|
|
95034
|
+
end
|
|
95035
|
+
$$;
|
|
95036
|
+
revoke execute on function better_supabase.check_rate_limits(jsonb) from public, anon, authenticated;
|
|
95037
|
+
grant execute on function better_supabase.check_rate_limits(jsonb) to service_role;
|
|
95038
|
+
|
|
94678
95039
|
-- Deletes up to batch counters whose window has ended: the period the
|
|
94679
95040
|
-- counter was last hit with, else its rule's, else a day (counters from
|
|
94680
95041
|
-- before the period column). Every caller keeps a row until then, so
|
|
@@ -123684,7 +124045,7 @@ function applyTenantScope(sql, ctx) {
|
|
|
123684
124045
|
const targets = [];
|
|
123685
124046
|
for (const [logical, spec] of Object.entries(ctx.names.tables)) {
|
|
123686
124047
|
const tenant = spec.lifecycle?.tenant;
|
|
123687
|
-
if (tenant === void 0 || !ctx.hasTable(logical) || !ctx.has(logical, tenant)) continue;
|
|
124048
|
+
if (tenant === void 0 || ctx.appViews.includes(logical) || !ctx.hasTable(logical) || !ctx.has(logical, tenant)) continue;
|
|
123688
124049
|
const name = ctx.tableName(logical);
|
|
123689
124050
|
const key = tableKey(`${name.schema}.${name.name}`);
|
|
123690
124051
|
const own = policies.filter((policy) => policy.target === key && !policy.restrictive && policy.authenticated);
|
|
@@ -125880,6 +126241,7 @@ function upgradePlan(installed, layout = {}, modules = SQL_MODULES) {
|
|
|
125880
126241
|
...entry.module === block ? {} : { instance: entry.module },
|
|
125881
126242
|
installed: names,
|
|
125882
126243
|
...layout.ownTables ? { ownTables: layout.ownTables } : {},
|
|
126244
|
+
...layout.ownViews ? { ownViews: layout.ownViews } : {},
|
|
125883
126245
|
...providerIdType(layout),
|
|
125884
126246
|
...providerGuests(layout)
|
|
125885
126247
|
});
|
|
@@ -125928,6 +126290,7 @@ function moduleSql(module, ctx, layout) {
|
|
|
125928
126290
|
function moduleBody(name, layout = {}) {
|
|
125929
126291
|
checkModules(layout.modules);
|
|
125930
126292
|
checkMigrationOptions(layout.modules, layout.ownTables);
|
|
126293
|
+
assertViewColumns(viewColumnsOf(layout).missing);
|
|
125931
126294
|
const modules = resolveBlocks([name], layout);
|
|
125932
126295
|
const module = modules.find((entry) => entry.name === name);
|
|
125933
126296
|
const ctx = moduleContext(name, layout, modules.map((entry) => entry.name));
|
|
@@ -125939,11 +126302,11 @@ function moduleBody(name, layout = {}) {
|
|
|
125939
126302
|
*/
|
|
125940
126303
|
function overApp(sql, ctx, layout) {
|
|
125941
126304
|
const appTables = appTableSet(ctx);
|
|
125942
|
-
return withoutUnmappedColumns(withoutUnmappedTables(blockNamesOnAppTables(withoutAppTableEdits(overAppTables(sql, appTables, layout.ownColumns), appTables), appTables, layout.ownUpdatedAtTriggers), ctx.instance), ctx.instance);
|
|
126305
|
+
return withoutUnmappedColumns(withoutUnmappedTables(blockNamesOnAppTables(withoutAppTableEdits(overAppTables(overAppViews(sql, appTableSet(ctx, ctx.appViews)), appTables, layout.ownColumns), appTables), appTables, layout.ownUpdatedAtTriggers), ctx.instance), ctx.instance);
|
|
125943
126306
|
}
|
|
125944
126307
|
/** The app's tables a module runs over, as `schema.table`. */
|
|
125945
|
-
function appTableSet(ctx) {
|
|
125946
|
-
return new Set(ctx.manages ?
|
|
126308
|
+
function appTableSet(ctx, tables = ctx.appOwned) {
|
|
126309
|
+
return new Set(ctx.manages ? tables.map((table) => {
|
|
125947
126310
|
const parts = ctx.tableName(table);
|
|
125948
126311
|
return `${parts.schema}.${parts.name}`;
|
|
125949
126312
|
}) : []);
|
|
@@ -125989,6 +126352,7 @@ on conflict (name) do update
|
|
|
125989
126352
|
function renderBlocks(names, layout = {}) {
|
|
125990
126353
|
checkModules(layout.modules);
|
|
125991
126354
|
checkMigrationOptions(layout.modules, layout.ownTables);
|
|
126355
|
+
assertViewColumns(viewColumnsOf(layout).missing);
|
|
125992
126356
|
const modules = resolveBlocks(names, layout);
|
|
125993
126357
|
checkTenantName(modules, layout);
|
|
125994
126358
|
const installed = modules.map((module) => module.name);
|
|
@@ -126553,11 +126917,12 @@ function contextOf(name, layout) {
|
|
|
126553
126917
|
* `ownTables` lists it or `blocks.<name>.on` names it, with the columns their
|
|
126554
126918
|
* SQL names: mapped to `null` and unused optional columns are left out.
|
|
126555
126919
|
*/
|
|
126556
|
-
function adoptedTables(modules, ownTables) {
|
|
126920
|
+
function adoptedTables(modules, ownTables, views = {}) {
|
|
126557
126921
|
const tables = [];
|
|
126558
126922
|
const layout = {
|
|
126559
126923
|
modules,
|
|
126560
|
-
...ownTables === void 0 ? {} : { ownTables }
|
|
126924
|
+
...ownTables === void 0 ? {} : { ownTables },
|
|
126925
|
+
...views
|
|
126561
126926
|
};
|
|
126562
126927
|
const contexts = Object.keys(modules).flatMap((name) => {
|
|
126563
126928
|
const mode = modules[name]?.mode ?? "managed";
|
|
@@ -126635,6 +127000,30 @@ function enumColumnProblems(modules, files, schemas, ownTables) {
|
|
|
126635
127000
|
function enumColumnProblem(table, logical, column, type) {
|
|
126636
127001
|
return `blocks.${table.module} writes text into ${table.schema}.${table.table}.${column} (${table.logical}.${logical}), which is the enum ${type}. Postgres does not cast text to an enum, so the module's functions fail. Change the column to text with a check constraint on its values.`;
|
|
126637
127002
|
}
|
|
127003
|
+
/** The block tables in `modules` that run over the app's views. */
|
|
127004
|
+
function adoptedViews(modules, ownTables, views) {
|
|
127005
|
+
const layout = {
|
|
127006
|
+
modules,
|
|
127007
|
+
ownTables,
|
|
127008
|
+
...views
|
|
127009
|
+
};
|
|
127010
|
+
return Object.keys(modules).flatMap((name) => {
|
|
127011
|
+
const spec = SQL_MODULES[name]?.names?.tables;
|
|
127012
|
+
const ctx = spec === void 0 ? void 0 : contextOf(name, layout);
|
|
127013
|
+
if (spec === void 0 || ctx === void 0) return [];
|
|
127014
|
+
return ctx.appViews.map((logical) => {
|
|
127015
|
+
const { schema, name: table } = ctx.tableName(logical);
|
|
127016
|
+
const view = `${schema}.${table}`;
|
|
127017
|
+
return {
|
|
127018
|
+
module: name,
|
|
127019
|
+
logical,
|
|
127020
|
+
view,
|
|
127021
|
+
updatable: views.ownViews[view]?.updatable === true,
|
|
127022
|
+
writes: spec[logical]?.app?.writes !== false
|
|
127023
|
+
};
|
|
127024
|
+
});
|
|
127025
|
+
});
|
|
127026
|
+
}
|
|
126638
127027
|
//#endregion
|
|
126639
127028
|
//#region src/sql/foreign-keys.ts
|
|
126640
127029
|
const TABLE_NAME = String.raw`${NAME$9}(?:\s*\.\s*${NAME$9})?`;
|
|
@@ -126993,4 +127382,4 @@ async function compileReadSets(sets) {
|
|
|
126993
127382
|
return Promise.all(names.map((name) => compileReadSet(byName.get(name))));
|
|
126994
127383
|
}
|
|
126995
127384
|
//#endregion
|
|
126996
|
-
export {
|
|
127385
|
+
export { contractSignature as $, moduleFileVersion as A, resolveExposeColumns as B, APP_TABLES_MARKER as C, blockSqlVersion as D, scopePolicyName as E, moduleSchemaExtensions as F, sameTenantTrigger as G, dataExportPlan as H, SQL_MODULES as I, currentBlockName as J, migrationOptionUses as K, resolveBlocks as L, moduleEventTriggers as M, moduleHidingColumns as N, blockFileState as O, modulePermissionKeys as P, MODULE_ID_TYPES as Q, TENANT_SCOPE_POLICY as R, moduleFilePaths as S, appTablesFiles as T, subjectColumns$1 as U, SECRET_COLUMNS as V, sameTenantColumn as W, renamedBlock as X, formerBlockName as Y, AUDIT_CATEGORIES as Z, moduleDeprecations as _, tenantsQuery as a, declaredUpdatedAtTriggers as at, widenedCommands as b, adoptedColumnProblems as c, policyGrants as ct, instanceFunctions as d, isBlockSqlIdType as et, entityRenamePlan as f, renderBlocks as g, moduleTopics as h, moduleLayout as i, declaredTables as it, sameBlockFile as j, isModuleDataFile as k, adoptedTables as l, rlsTables as lt, moduleBody as m, compileReadSets as n, BLOCK_OPTION_SCHEMAS as nt, expiredFlagsQuery as o, declaredViews as ot, customContracts as p, BLOCK_RENAMES as q, sharedRolesProblems as r, declaredTableColumns as rt, sameTenantLayout as s, extensionSchema as st, compileReadSet as t, moduleIdType as tt, adoptedViews as u, auditRegistrations as ut, upgradePlan as v, APP_TABLES_MODULE as w, moduleDataDir as x, declaredPolicies as y, excludedColumns as z };
|
package/dist/sqlite/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Bt as Executor } from "../types-DFdg_4yN.js";
|
|
2
2
|
import { c as LocalTablesOption, n as DataEngine, s as LiveEngineOptions } from "../data-engine-BWoz9lED.js";
|
|
3
|
-
import { i as fromSqliteError, n as SqliteDatabaseLike, o as CheckSqliteOptions, r as SqliteExecutorOptions, s as checkSqlite, t as SqliteContextLike } from "../executor-
|
|
3
|
+
import { i as fromSqliteError, n as SqliteDatabaseLike, o as CheckSqliteOptions, r as SqliteExecutorOptions, s as checkSqlite, t as SqliteContextLike } from "../executor-BcNWcD-4.js";
|
|
4
4
|
//#region src/sqlite/engine.d.ts
|
|
5
5
|
/** A SQLite database that may report which tables changed. */
|
|
6
6
|
interface ChangingSqliteDatabase extends SqliteDatabaseLike {
|
package/dist/ssr/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as readSession, D as writeSession, E as sessionEncoding, S as pruneSessionChunks, T as sessionCookieName, _ as StoredSession, a as ResolveAuthOptions, b as clearSessionAtScopes, d as CookieOptions, f as CookieRecord, g as SessionEncoding, h as DEFAULT_SESSION_ENCODING, l as resolveAuth, m as CookieWrite, n as AuthResolver, p as CookieScope, r as AuthState, t as AuthResolution, u as AUTH_CACHE_HEADERS, v as WriteSessionOptions, w as serializeCookie, x as parseCookies, y as applyCookieWrites } from "../resolve-CXX6DHv3.js";
|
|
2
2
|
import { n as toSession, t as AuthSession } from "../view-DyFdMCqg.js";
|
|
3
|
-
import { r as MembershipClaim } from "../entitlements-
|
|
3
|
+
import { r as MembershipClaim } from "../entitlements-sO977DO-.js";
|
|
4
4
|
import { n as RefreshOutcome, r as refreshSession, t as RefreshOptions } from "../refresh-DT_ICaK-.js";
|
|
5
5
|
import { a as sessionStatus, i as clearSessionCookies, n as SessionStatus, o as authContext, r as SessionStatusOptions, t as ClearSessionCookiesOptions } from "../ended-gUsMZVNg.js";
|
|
6
6
|
export { AUTH_CACHE_HEADERS, type AuthResolution, type AuthResolver, type AuthSession, type AuthState, type ClearSessionCookiesOptions, type CookieOptions, type CookieRecord, type CookieScope, type CookieWrite, DEFAULT_SESSION_ENCODING, type MembershipClaim, type RefreshOptions, type RefreshOutcome, type ResolveAuthOptions, type SessionEncoding, type SessionStatus, type SessionStatusOptions, type StoredSession, type WriteSessionOptions, applyCookieWrites, authContext, clearSessionAtScopes, clearSessionCookies, parseCookies, pruneSessionChunks, readSession, refreshSession, resolveAuth, serializeCookie, sessionCookieName, sessionEncoding, sessionStatus, toSession, writeSession };
|