better-supabase 0.15.1 → 0.17.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/{ai-schedules-D_Hz-ik5.d.ts → ai-schedules-Dk9H3kAp.d.ts} +1 -1
- package/dist/ai-sdk/agents/index.d.ts +2 -2
- package/dist/{api-DxAPqMrE.d.ts → api-CpL3hm87.d.ts} +1 -1
- package/dist/{app-tables-D29Rahtg.js → app-tables-Q0TYfeih.js} +1 -0
- package/dist/{app-tables-CbCFSXLG.d.ts → app-tables-dS02piE7.d.ts} +1 -1
- package/dist/astro/index.d.ts +4 -4
- package/dist/{auth-module-BEFESDC4.js → auth-module-BbmX-N4L.js} +12 -4
- package/dist/{authorization-HZdJCaVm.d.ts → authorization-CNsvnwle.d.ts} +19 -3
- package/dist/better-result/index.d.ts +2 -2
- package/dist/{bind-h5jre2K0.d.ts → bind-C801IaK-.d.ts} +4 -4
- package/dist/{block-env-BrfRvPrj.d.ts → block-env-BeG4DiiO.d.ts} +4 -4
- package/dist/blocks/access-requests/index.d.ts +1 -1
- package/dist/blocks/activities/index.d.ts +1 -1
- package/dist/blocks/agents/index.d.ts +1 -1
- package/dist/blocks/ai-cache/index.d.ts +1 -1
- package/dist/blocks/ai-chat/index.d.ts +4 -4
- 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 +1 -1
- 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 +3 -3
- 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 +2 -2
- 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 +5 -5
- 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 +4 -3
- package/dist/blocks/created-by/index.js +2 -2
- package/dist/blocks/custom-fields/index.d.ts +1 -1
- package/dist/blocks/data-lifecycle/index.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/blocks/invoices/index.d.ts +1 -1
- package/dist/blocks/knowledge/index.d.ts +1 -1
- 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 +1 -1
- package/dist/blocks/messaging/index.d.ts +5 -5
- package/dist/blocks/metrics/index.d.ts +1 -1
- 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 +4 -4
- 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 +2 -2
- package/dist/blocks/organizations/index.d.ts +2 -2
- package/dist/blocks/outbox/index.d.ts +1 -1
- package/dist/blocks/passes/index.d.ts +1 -1
- 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 +29 -2
- package/dist/blocks/queue/index.js +1 -1
- package/dist/blocks/quotes/index.d.ts +1 -1
- package/dist/blocks/rank/index.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +7 -4
- package/dist/blocks/updated-at/index.js +2 -2
- package/dist/blocks/usage/index.d.ts +2 -2
- 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 +2 -2
- package/dist/blocks/webhooks/index.js +1 -1
- package/dist/blocks/workflow-editor/index.d.ts +4 -4
- package/dist/blocks/workflows/index.d.ts +4 -4
- package/dist/{bucket-CiNi8sIw.d.ts → bucket-vc-QRrva.d.ts} +40 -1
- package/dist/cli/{add-C04vkBk9.js → add-BinNYhFD.js} +2 -2
- package/dist/cli/{add-DNOL9PDu.js → add-DMcrsWjC.js} +13 -11
- package/dist/cli/add-z-3pXI6C.js +1 -0
- package/dist/cli/{backfill-VFzf-TJP.js → backfill-DxBB62Zr.js} +3 -3
- package/dist/cli/bin.js +1 -1
- package/dist/cli/{blocks-Cb7mILFU.js → blocks-DSgTifw0.js} +1 -1
- package/dist/cli/{blocks-Bn7WUca5.js → blocks-rxOS-Mzz.js} +1 -1
- package/dist/cli/{cache-DkplpIGe.js → cache-oU0yHKf0.js} +1 -1
- package/dist/cli/{codemod-BbaE5dL_.js → codemod-Dsrv_3gQ.js} +1 -1
- package/dist/cli/{config-9t5ec_N7.js → config-2rwFHbwj.js} +3 -1
- package/dist/cli/{config-CBqkQjjN.js → config-C6XylzKz.js} +1 -1
- package/dist/cli/{content-mapper-Cdx6arxu.js → content-mapper-DLbXilBz.js} +2 -2
- package/dist/cli/{db-DrBI_HNv.js → db-Bwrr3GHM.js} +2 -2
- package/dist/cli/{doctor-C-VO-QQ2.js → doctor-CKt5Yyl4.js} +184 -142
- package/dist/cli/{gen-yRHOHW1b.js → gen-CeG6lbka.js} +13 -13
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +7 -7
- package/dist/cli/{init-BOw0SX65.js → init-DrQlf9RL.js} +6 -6
- package/dist/cli/{live-Lmg-hYyO.js → live-BvWGM4c3.js} +2 -2
- package/dist/cli/{mcp-DQ1zR2eA.js → mcp-BrOnGB15.js} +2 -2
- package/dist/cli/{metadata-CZaxkv21.js → metadata-BNSdPuKp.js} +3 -3
- package/dist/cli/{migration-safety-BbhLu2fo.js → migration-safety-NtB3dsRU.js} +2 -2
- package/dist/cli/{module-migration-DOn6EmNz.js → module-migration-mKhX88V_.js} +1 -1
- package/dist/cli/{print-D_xf8PPj.js → print-Dh8iuPK3.js} +1 -1
- package/dist/cli/{remove-BY_TOTRj.js → remove-DfFXVBRr.js} +5 -5
- package/dist/cli/{render-lJmHr0y9.js → render-ChIwdIOJ.js} +10 -4
- package/dist/cli/{run-BJ6IMs_H.js → run-CLSHSVYo.js} +7 -7
- package/dist/cli/{run-DkB0fhc9.js → run-D48ZEU58.js} +24 -24
- package/dist/cli/{seed-Cz8PcXeT.js → seed-CG-pA-5N.js} +2 -2
- package/dist/cli/seed-CUxW5Dks.js +1 -0
- package/dist/cli/{shared-Bh-6IqJS.js → shared-D0XBFSlz.js} +1 -1
- package/dist/cli/{snapshot-Bzcigm7T.js → snapshot-C6vh_n3t.js} +3 -3
- package/dist/cli/{source-WoLdcQzN.js → source-BZbEK5if.js} +1 -1
- package/dist/cli/{source-args-IpJRJO5t.js → source-args-MTLYpifA.js} +1 -1
- package/dist/cli/{spec-CZMiLhv_.js → spec-B4LhpI6t.js} +2 -2
- package/dist/cli/{spec-BF_dpwzW.js → spec-C-dhdKwa.js} +1 -1
- package/dist/cli/{sql-layout-rFP0oq1N.js → sql-layout-26LSoifK.js} +2 -2
- package/dist/cli/{sync-mANmYYoL.js → sync-CHGMZCJ5.js} +2 -2
- package/dist/cli/{upgrade-B0Q9wMs-.js → upgrade-C0dVsqNX.js} +3 -3
- package/dist/cli/{upgrade-BrNLt92u.js → upgrade-GB9rqUGT.js} +2 -2
- package/dist/cli/{version-CyavsyGA.js → version-T507a49w.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-BZYXlVBN.d.ts → composite-B7f1MMgr.d.ts} +4 -3
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +4 -4
- package/dist/{config-DWGgUQCh.js → config-BVNNJwGC.js} +7 -6
- package/dist/{config-CcehOvbz.js → config-CIBc79_8.js} +1 -1
- package/dist/{context-TGX2eDS5.d.ts → context-CKCgjEDF.d.ts} +9 -2
- package/dist/{controller-DyPPMFSw.d.ts → controller-CJUXhshv.d.ts} +1 -1
- package/dist/{conversion-O-kyhXcC.d.ts → conversion-DgHdDlTK.d.ts} +1 -1
- package/dist/create/index.d.ts +2 -2
- package/dist/create/index.js +5 -5
- package/dist/{define-DFBnQyYg.d.ts → define-Cgru0_kF.d.ts} +2 -2
- package/dist/{define-block-DvvcM54N.d.ts → define-block-Xxw8Hroe.d.ts} +2 -2
- package/dist/edge/index.d.ts +5 -5
- package/dist/{entitlements-BnhDBxLW.d.ts → entitlements-B0jmjNLD.d.ts} +1 -1
- package/dist/{executor-CVIn6JHa.d.ts → executor-BWFfz0ik.d.ts} +2 -2
- package/dist/expo/index.d.ts +2 -2
- package/dist/{extension-B-lajjex.js → extension-DTaHjwdc.js} +3 -2
- package/dist/{extension-B0EjCYhO.js → extension-mGylYROs.js} +2 -10
- package/dist/{field-errors-DYtg1mwv.d.ts → field-errors-DqlebtTE.d.ts} +12 -12
- package/dist/{framework-h5lP_5yj.d.ts → framework-CF6zFU7a.d.ts} +3 -3
- package/dist/hono/index.d.ts +4 -4
- package/dist/{index-BfkltrGJ.d.ts → index-B8YjrfVl.d.ts} +2 -2
- package/dist/{index-BAHGLvGD.d.ts → index-BCeTYhFk.d.ts} +1 -1
- package/dist/{index-Do2ChN_y.d.ts → index-CQhPHHDF.d.ts} +20 -2
- package/dist/{index-Ab4UeEn_.d.ts → index-ClMN0f98.d.ts} +44 -12
- package/dist/{index-B4gcStOz.d.ts → index-DUxXdQN_.d.ts} +3 -3
- package/dist/{index-BfK6olKm.d.ts → index-Dbb7BQdi.d.ts} +9 -4
- package/dist/{index-DN9mfmhA.d.ts → index-lB-8iPmY.d.ts} +51 -3
- package/dist/index.d.ts +2 -2
- package/dist/{instances-BHjCZoF8.js → instances-QOzIz9-q.js} +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/{list-query-BDVutLFr.d.ts → list-query-DxjuIHEL.d.ts} +1 -1
- package/dist/mapper/bin.js +6 -6
- package/dist/mcp/index.d.ts +4 -4
- package/dist/mcp/sdk/index.d.ts +2 -2
- 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/{operations-CSc_IsHO.d.ts → operations-Dc07aV_H.d.ts} +1 -1
- package/dist/{options-DChZoVfs.d.ts → options-B_NrjVDt.d.ts} +1 -0
- package/dist/{options-B2swWnJW.js → options-CCUaRLgd.js} +2 -1
- package/dist/{options-CM6-18FQ.d.ts → options-CDSCkYxu.d.ts} +1 -0
- package/dist/{options-C-dQHH5-.js → options-tSsUF0-7.js} +2 -1
- package/dist/orpc/index.d.ts +4 -4
- package/dist/otel/index.js +4 -4
- package/dist/{ports-DOhtuw3c.js → ports-CaVRXjxq.js} +1 -1
- package/dist/{ports-CpdiQv1D.d.ts → ports-DnpAuTvB.d.ts} +1 -1
- package/dist/powersync/index.d.ts +2 -2
- package/dist/preset/index.d.ts +3 -3
- package/dist/preset/index.js +3 -3
- package/dist/{preset-CsHnIBJF.js → preset-BIANzB5p.js} +2 -2
- package/dist/{push-token-B3m3pWAv.d.ts → push-token-C_mFkYfq.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/realtime/index.d.ts +5 -5
- package/dist/realtime/index.js +2 -1
- package/dist/{record-form-DB_5Ue_B.d.ts → record-form-xWvVcb86.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-DqWfEc56.d.ts} +1 -1
- package/dist/{resource-types-DnKiH4G2.d.ts → resource-types-BIoz_ElD.d.ts} +1 -1
- package/dist/{resources-B9cQxhjw.d.ts → resources-Bt2PDKE7.d.ts} +1 -1
- package/dist/server/index.d.ts +147 -9
- package/dist/server/index.js +396 -1
- package/dist/{server-types-7QPzW2bF.d.ts → server-types-gR4Q1aM0.d.ts} +5 -354
- package/dist/{session-CfBCJGgc.d.ts → session-C1OuXbtN.d.ts} +2 -1
- package/dist/session-status-qQLm7jzh.d.ts +82 -0
- 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/spec/index.d.ts +1 -1
- package/dist/sql/index.d.ts +5 -5
- package/dist/sql/index.js +3 -3
- package/dist/{sql-OLVW4t08.js → sql-ClTmzHs8.js} +199 -31
- 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/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/{tags-BjHflcHF.d.ts → tags-sM-CH9Mn.d.ts} +1 -1
- package/dist/tanstack-db/index.d.ts +1 -1
- package/dist/tanstack-start/index.d.ts +3 -3
- package/dist/{tenant-DzFsg0Pc.d.ts → tenant-DVvjw9H-.d.ts} +1 -1
- package/dist/testing/index.d.ts +9 -8
- package/dist/testing/index.js +3 -3
- package/dist/{timeline-WrFMgd3U.d.ts → timeline-BBfKuMVL.d.ts} +3 -3
- package/dist/{topic-DNFEFGKI.d.ts → topic-BtLz-qTI.d.ts} +3 -3
- package/dist/{verify-CMou8dWZ.d.ts → verify-DEqY__0N.d.ts} +1 -1
- package/dist/vue/index.d.ts +7 -7
- package/dist/vue/index.js +1 -1
- package/dist/{watch-topic-Bo9S2R4P.d.ts → watch-topic-tnfOTa3-.d.ts} +1 -1
- package/dist/yjs/index.d.ts +1 -1
- package/package.json +1 -1
- package/schemas/config-v1.json +22 -0
- 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-CUH0rORo.js +0 -1
- package/dist/cli/seed-D6XijwbR.js +0 -1
package/dist/sql/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
3
|
-
import { a as appTableEventTypes } from "../app-tables-
|
|
4
|
-
import { $ as
|
|
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 };
|
|
1
|
+
import { M as BlockOptionsRegistry, j as BLOCK_OPTION_SCHEMAS, k as resolveBlock } from "../authorization-CNsvnwle.js";
|
|
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-CKCgjEDF.js";
|
|
3
|
+
import { a as appTableEventTypes } from "../app-tables-dS02piE7.js";
|
|
4
|
+
import { $ as moduleHidingColumns, A as expiredFlagsQuery, B as adoptedColumnProblems, C as declaredViews, Ct as renderBlocks, D as subjectColumns, E as rlsTables, F as dataExportPlan, G as appTablesFiles, H as adoptedViews, I as excludedColumns, J as SQL_MODULES, K as DEFAULT_ROLES, L as resolveExposeColumns, M as sameTenantTrigger, N as DataExportPlan, O as TenantQuery, P as SECRET_COLUMNS, Q as moduleEventTriggers, R as AdoptedTable, S as declaredUpdatedAtTriggers, St as moduleTopics, T as policyGrants, U as APP_TABLES_MARKER, V as adoptedTables, W as APP_TABLES_MODULE, X as BlockSqlExtension, Y as resolveBlocks, Z as BlockSqlPermissionKey, _ as templateFunctions, _t as moduleDeprecations, a as scopePolicyName, at as sameBlockFile, b as declaredTableColumns, bt as customContracts, c as compileReadSet, ct as EntityRenamePlan, d as MigrationOptionUse, dt as BLOCK_RENAMES, et as modulePermissionKeys, f as migrationOptionUses, ft as currentBlockName, g as scopeProblems, gt as InstalledBlock, h as resolveProviderSql, ht as BlockSqlUpgradePlan, i as TENANT_SCOPE_POLICY, it as moduleFileVersion, j as sameTenantColumn, k as tenantsQuery, l as compileReadSets, lt as EntityRenameStep, m as SCOPE_ID_TYPES, mt as renamedBlock, n as declaredPolicies, nt as blockFileState, o as hasColumnAccess, ot as moduleDataDir, p as moduleLayout, pt as formerBlockName, q as instanceFunctions, r as widenedCommands, rt as isModuleDataFile, s as CompiledReadSet, st as moduleFilePaths, t as appTablePolicyNotes, tt as moduleSchemaExtensions, u as sharedRolesProblems, ut as entityRenamePlan, v as DeclaredView, vt as upgradePlan, w as extensionSchema, x as declaredTables, xt as moduleBody, y as PolicyGrant, yt as BlockSqlTopic, z as AdoptedView } from "../index-Dbb7BQdi.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, appTablePolicyNotes, 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
|
-
import { A as resolveBlock, l as appTableEventTypes, v as hasColumnAccess } from "../app-tables-
|
|
1
|
+
import { A as resolveBlock, l as appTableEventTypes, v as hasColumnAccess } from "../app-tables-Q0TYfeih.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, 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 };
|
|
4
|
+
import { $ as MODULE_ID_TYPES, A as isModuleDataFile, B as excludedColumns, C as moduleFilePaths, D as scopePolicyName, E as appTablesFiles, F as modulePermissionKeys, G as sameTenantColumn, H as SECRET_COLUMNS, I as moduleSchemaExtensions, J as BLOCK_RENAMES, K as sameTenantTrigger, L as SQL_MODULES, M as sameBlockFile, N as moduleEventTriggers, O as blockSqlVersion, P as moduleHidingColumns, Q as AUDIT_CATEGORIES, R as resolveBlocks, S as moduleDataDir, T as APP_TABLES_MODULE, U as dataExportPlan, V as resolveExposeColumns, W as subjectColumns, X as formerBlockName, Y as currentBlockName, Z as renamedBlock, _ as moduleDeprecations, a as tenantsQuery, at as declaredTables, b as declaredPolicies, c as adoptedColumnProblems, ct as extensionSchema, d as instanceFunctions, dt as auditRegistrations, et as contractSignature, f as entityRenamePlan, g as renderBlocks, h as moduleTopics, i as moduleLayout, it as declaredTableColumns, j as moduleFileVersion, k as blockFileState, l as adoptedTables, lt as policyGrants, m as moduleBody, n as compileReadSets, nt as moduleIdType, o as expiredFlagsQuery, ot as declaredUpdatedAtTriggers, p as customContracts, q as migrationOptionUses, r as sharedRolesProblems, rt as BLOCK_OPTION_SCHEMAS, s as sameTenantLayout, st as declaredViews, t as compileReadSet, tt as isBlockSqlIdType, u as adoptedViews, ut as rlsTables, v as upgradePlan, w as APP_TABLES_MARKER, x as widenedCommands, y as appTablePolicyNotes, z as TENANT_SCOPE_POLICY } from "../sql-ClTmzHs8.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, appTablePolicyNotes, 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 };
|
|
@@ -3,10 +3,10 @@ import { d as temporalText } from "./temporal-DLZlWbOi.js";
|
|
|
3
3
|
import { r as NEGATIVE, t as FILTER_OPERATORS } from "./filter-query-DMoKo82_.js";
|
|
4
4
|
import { a as ok } from "./result-ntFBW2p2.js";
|
|
5
5
|
import { a as hasPlaceholder, l as splitPlaceholders, s as placeholderOf } from "./read-set-BnKnofIj.js";
|
|
6
|
-
import { a as resolveNames, n as instancePrefix, o as resolveJsonSchema, r as isRenamedInstance, s as CONFIG_DEFAULTS } from "./instances-
|
|
6
|
+
import { a as resolveNames, n as instancePrefix, o as resolveJsonSchema, r as isRenamedInstance, s as CONFIG_DEFAULTS } from "./instances-QOzIz9-q.js";
|
|
7
7
|
import { t as DEFAULT_CLAIMS } from "./claims-Bp9My7XP.js";
|
|
8
8
|
import { o as tenantNames, r as composeNames } from "./entity-naming-Dtyq5sKE.js";
|
|
9
|
-
import { A as resolveBlock, D as BLOCK_SCOPES, _ as encryptedColumns, c as appTableEventKinds, g as columnsWithAccess, h as hasComputed, j as tenantNameOf, r as APP_RANK_COLUMN, t as APP_DELETED_AT_COLUMN, u as appTableVersions, v as hasColumnAccess, y as hiddenColumns } from "./app-tables-
|
|
9
|
+
import { A as resolveBlock, D as BLOCK_SCOPES, _ as encryptedColumns, c as appTableEventKinds, g as columnsWithAccess, h as hasComputed, j as tenantNameOf, r as APP_RANK_COLUMN, t as APP_DELETED_AT_COLUMN, u as appTableVersions, v as hasColumnAccess, y as hiddenColumns } from "./app-tables-Q0TYfeih.js";
|
|
10
10
|
import { a as RATING_BOUNDS, n as CUSTOM_FIELD_TYPES, r as FIELD_FORMATS, t as CUSTOM_FIELD_FORM_TYPES } from "./field-formats-C6QKA3UR.js";
|
|
11
11
|
import { a as sqlString, i as sqlIdent } from "./template-Drgg3v2J.js";
|
|
12
12
|
import { i as fillTemplate, l as templatePlaceholders } from "./access-sql-B-MkVARa.js";
|
|
@@ -41,7 +41,7 @@ import { t as contactsSqlOptions } from "./options-BlncUmIc.js";
|
|
|
41
41
|
import { t as contentSqlOptions } from "./options-1GgseJq5.js";
|
|
42
42
|
import { t as contractsSqlOptions } from "./options-E7KcmHQv.js";
|
|
43
43
|
import { t as coursesSqlOptions } from "./options-63AKQNv0.js";
|
|
44
|
-
import { t as createdBySqlOptions } from "./options-
|
|
44
|
+
import { t as createdBySqlOptions } from "./options-CCUaRLgd.js";
|
|
45
45
|
import { t as customFieldsSqlOptions } from "./options-BjtrC7o6.js";
|
|
46
46
|
import { t as dataLifecycleSqlOptions } from "./options-C239TLRF.js";
|
|
47
47
|
import { t as dealsSqlOptions } from "./options-DTDxFT6J.js";
|
|
@@ -114,7 +114,7 @@ import { t as teamsSqlOptions } from "./options-C6rEL6U5.js";
|
|
|
114
114
|
import { t as templatesSqlOptions } from "./options-Fz6xqu-b.js";
|
|
115
115
|
import { t as timeTrackingSqlOptions } from "./options-BbnPv6p7.js";
|
|
116
116
|
import { t as trashSqlOptions } from "./options-DWbA9buW.js";
|
|
117
|
-
import { t as updatedAtSqlOptions } from "./options-
|
|
117
|
+
import { t as updatedAtSqlOptions } from "./options-tSsUF0-7.js";
|
|
118
118
|
import { t as usageSqlOptions } from "./options-B9q8CROT.js";
|
|
119
119
|
import { t as vercelMarketplaceSqlOptions } from "./options-RKYdmIdV.js";
|
|
120
120
|
import { t as versionsSqlOptions } from "./options-BQIYfx9F.js";
|
|
@@ -41629,7 +41629,8 @@ const ACTOR = {
|
|
|
41629
41629
|
options: [
|
|
41630
41630
|
"createdBy",
|
|
41631
41631
|
"updatedBy",
|
|
41632
|
-
"impersonatedBy"
|
|
41632
|
+
"impersonatedBy",
|
|
41633
|
+
"stamp"
|
|
41633
41634
|
]
|
|
41634
41635
|
},
|
|
41635
41636
|
build: () => `${SCHEMA$5}
|
|
@@ -54742,6 +54743,11 @@ function providerEntitlementMembers(provider) {
|
|
|
54742
54743
|
* column and key come from the module's own (possibly renamed) names.
|
|
54743
54744
|
*/
|
|
54744
54745
|
function customerSource(ctx, layout) {
|
|
54746
|
+
const source = resolvedCustomerSource(ctx, layout);
|
|
54747
|
+
if (source === void 0) throw new TypeError("The entitlements module needs auth.entitlements.customer: the table.column with each tenant's Stripe customer id. With the managed billing or organizations module it defaults to that module's customer column.");
|
|
54748
|
+
return source;
|
|
54749
|
+
}
|
|
54750
|
+
function resolvedCustomerSource(ctx, layout) {
|
|
54745
54751
|
const configured = layout.entitlements;
|
|
54746
54752
|
if (configured?.table !== void 0 && configured.column !== void 0) return {
|
|
54747
54753
|
table: configured.table,
|
|
@@ -54769,7 +54775,14 @@ function customerSource(ctx, layout) {
|
|
|
54769
54775
|
deferred: true
|
|
54770
54776
|
};
|
|
54771
54777
|
}
|
|
54772
|
-
|
|
54778
|
+
}
|
|
54779
|
+
function readsOrganizationCustomer(ctx, layout) {
|
|
54780
|
+
if (!ctx.installed("entitlements") || (layout.entitlements?.source ?? "stripe-sync") !== "stripe-sync") return false;
|
|
54781
|
+
const source = resolvedCustomerSource(ctx.of("entitlements"), layout);
|
|
54782
|
+
if (source === void 0) return false;
|
|
54783
|
+
const organizations = ctx.tableName("organizations");
|
|
54784
|
+
const [schema, table] = splitTable$1(source.table);
|
|
54785
|
+
return source.column === "stripe_customer_id" && schema === organizations.schema && table === organizations.name;
|
|
54773
54786
|
}
|
|
54774
54787
|
function entitlementsSource(source, layout) {
|
|
54775
54788
|
const provider = layout.entitlementsProvider;
|
|
@@ -69465,7 +69478,9 @@ function platformTableSql(ctx) {
|
|
|
69465
69478
|
if (!p || !ctx.manages) return "";
|
|
69466
69479
|
const c = (logical) => p.col(logical);
|
|
69467
69480
|
const add = (logical, type) => p.has(logical) ? `alter table ${p.table} add column if not exists ${c(logical)} ${type};\n` : "";
|
|
69468
|
-
const where = openFilter(p, p.table).replaceAll(`${p.table}.`, "");
|
|
69481
|
+
const where = `${openFilter(p, p.table)}${p.only(p.table)}`.replaceAll(`${p.table}.`, "");
|
|
69482
|
+
const openEmailIndex = sharesTable(ctx) ? `drop index if exists ${sqlIdent(ctx.tableName("invitations").schema)}.platform_invitations_open_email_idx;
|
|
69483
|
+
create unique index if not exists invitations_platform_open_email_idx` : "create unique index if not exists platform_invitations_open_email_idx";
|
|
69469
69484
|
return `
|
|
69470
69485
|
-- Invitations to a platform role (the catalog model's platform assignments).
|
|
69471
69486
|
create table if not exists ${p.table} (
|
|
@@ -69477,7 +69492,7 @@ create table if not exists ${p.table} (
|
|
|
69477
69492
|
${c("acceptedAt")} timestamptz
|
|
69478
69493
|
);
|
|
69479
69494
|
${add("invitedBy", "uuid references auth.users (id) on delete set null")}${add("createdAt", "timestamptz not null default now()")}${add("acceptedBy", "uuid references auth.users (id) on delete set null")}${add("declinedAt", "timestamptz")}${add("revokedAt", "timestamptz")}
|
|
69480
|
-
|
|
69495
|
+
${openEmailIndex}
|
|
69481
69496
|
on ${p.table} (lower(${c("email")})) where ${where};
|
|
69482
69497
|
${p.has("updatedAt") ? `${updatedAt(p.table, c("updatedAt"))}\n` : ""}${p.has("invitedBy") ? `create index if not exists platform_invitations_invited_by_idx on ${p.table} (${c("invitedBy")});\n` : ""}${p.has("acceptedBy") ? `create index if not exists platform_invitations_accepted_by_idx on ${p.table} (${c("acceptedBy")});\n` : ""}
|
|
69483
69498
|
alter table ${p.table} enable row level security;
|
|
@@ -87076,7 +87091,7 @@ function idColumn(ctx, column) {
|
|
|
87076
87091
|
default: return ctx.idType;
|
|
87077
87092
|
}
|
|
87078
87093
|
}
|
|
87079
|
-
function table$2(ctx, n) {
|
|
87094
|
+
function table$2(ctx, n, layout) {
|
|
87080
87095
|
if (!ctx.manages) return `
|
|
87081
87096
|
-- Adopted: ${n.organization} belongs to the app (blocks.organizations.tables.organizations).
|
|
87082
87097
|
`;
|
|
@@ -87090,7 +87105,7 @@ create table if not exists ${n.organization} (
|
|
|
87090
87105
|
${idColumn(ctx, n.id)},
|
|
87091
87106
|
${c("name")} text not null check (length(btrim(${c("name")})) > 0)${optional("slug", `${slugType} not null`)}${optional("createdBy", "uuid references auth.users (id) on delete set null")}${optional("createdAt", "timestamptz not null default now()")}${optional("disabledAt", "timestamptz")}${optional("deletedAt", "timestamptz")}
|
|
87092
87107
|
);${addExtraColumns(n.organization, organizationExtraColumns(ctx))}
|
|
87093
|
-
${slugIndex}${ctx.has("organizations", "createdBy") ? `create index if not exists ${ctx.naming.rename("organizations_created_by_idx")} on ${n.organization} (${c("createdBy")});\n` : ""}${ctx.has("organizations", "updatedAt") ? `${updatedAt(n.organization, c("updatedAt"))}\n` : ""}${ctx
|
|
87108
|
+
${slugIndex}${ctx.has("organizations", "createdBy") ? `create index if not exists ${ctx.naming.rename("organizations_created_by_idx")} on ${n.organization} (${c("createdBy")});\n` : ""}${ctx.has("organizations", "updatedAt") ? `${updatedAt(n.organization, c("updatedAt"))}\n` : ""}${readsOrganizationCustomer(ctx, layout) ? `-- The Stripe customer the entitlements module reads (config.entitlements.customer).
|
|
87094
87109
|
alter table ${n.organization} add column if not exists ${ORGANIZATION_CUSTOMER_COLUMN} text unique;
|
|
87095
87110
|
` : ""}alter table ${n.organization} enable row level security;
|
|
87096
87111
|
${revokeTable(n.organization)}
|
|
@@ -87684,12 +87699,12 @@ const functionsOf$1 = (ctx, id) => [
|
|
|
87684
87699
|
...ctx.installed("invitations") ? [["list_organization_invitations", id]] : [],
|
|
87685
87700
|
...membershipDisabledAt(ctx) === void 0 ? [] : [["suspend_member", `${id}, uuid`], ["resume_member", `${id}, uuid`]]
|
|
87686
87701
|
];
|
|
87687
|
-
function organizationsSql(ctx) {
|
|
87702
|
+
function organizationsSql(ctx, layout) {
|
|
87688
87703
|
const n = namesOf$2(ctx);
|
|
87689
87704
|
const grants = functionsOf$1(ctx, ctx.idType).map(([name, args]) => `revoke execute on function ${ctx.fn(name)}(${args}) from public, anon;
|
|
87690
87705
|
grant execute on function ${ctx.fn(name)}(${args}) to authenticated, service_role;`).join("\n");
|
|
87691
87706
|
return `${schemaPreamble(ctx)}
|
|
87692
|
-
${table$2(ctx, n)}${tenantKeys(ctx, n)}${slugCheck(ctx, n)}${create(ctx, n)}${organizationDeletion(ctx, n, {
|
|
87707
|
+
${table$2(ctx, n, layout)}${tenantKeys(ctx, n)}${slugCheck(ctx, n)}${create(ctx, n)}${organizationDeletion(ctx, n, {
|
|
87693
87708
|
platformOverride: platformOverride(ctx, "deletePlatform"),
|
|
87694
87709
|
event
|
|
87695
87710
|
})}${guards(ctx, n)}${members(ctx, n)}${memberSuspension(ctx, n, {
|
|
@@ -94909,6 +94924,133 @@ $$;
|
|
|
94909
94924
|
revoke execute on function better_supabase.check_rate_limit(text, text, integer, interval) from public, anon, authenticated;
|
|
94910
94925
|
grant execute on function better_supabase.check_rate_limit(text, text, integer, interval) to service_role;
|
|
94911
94926
|
|
|
94927
|
+
-- Counts one hit against several limits at once: hits is a JSON array of
|
|
94928
|
+
-- { scope, key, max_requests?, period? }, each with its own scope and key.
|
|
94929
|
+
-- The counters are locked in a fixed order and the hit counts only when every
|
|
94930
|
+
-- limit allows it, so a refused call leaves every counter as it was. Returns
|
|
94931
|
+
-- { allowed, blocked, retry_after, results }: blocked is the index of the first
|
|
94932
|
+
-- limit over its maximum, retry_after the longest wait of the refusing
|
|
94933
|
+
-- limits, and results one { allowed, remaining, retry_after } per hit.
|
|
94934
|
+
create or replace function better_supabase.check_rate_limits(hits jsonb)
|
|
94935
|
+
returns jsonb
|
|
94936
|
+
language plpgsql
|
|
94937
|
+
security definer
|
|
94938
|
+
set search_path = ''
|
|
94939
|
+
as $$
|
|
94940
|
+
declare
|
|
94941
|
+
total integer;
|
|
94942
|
+
scopes text[] := '{}';
|
|
94943
|
+
keys text[] := '{}';
|
|
94944
|
+
maxes integer[] := '{}';
|
|
94945
|
+
periods interval[] := '{}';
|
|
94946
|
+
used integer[] := '{}';
|
|
94947
|
+
starts timestamptz[] := '{}';
|
|
94948
|
+
hit jsonb;
|
|
94949
|
+
rule better_supabase.rate_limit_rules;
|
|
94950
|
+
counter better_supabase.rate_limits;
|
|
94951
|
+
limit_max integer;
|
|
94952
|
+
limit_period interval;
|
|
94953
|
+
current_hits integer;
|
|
94954
|
+
first_blocked integer;
|
|
94955
|
+
longest integer := 0;
|
|
94956
|
+
passed boolean;
|
|
94957
|
+
results jsonb := '[]'::jsonb;
|
|
94958
|
+
begin
|
|
94959
|
+
if jsonb_typeof(hits) is distinct from 'array' or jsonb_array_length(hits) = 0 then
|
|
94960
|
+
raise exception 'check_rate_limits needs a non-empty array of hits'
|
|
94961
|
+
using errcode = '22023', hint = 'RATE_LIMIT_HITS';
|
|
94962
|
+
end if;
|
|
94963
|
+
total := jsonb_array_length(hits);
|
|
94964
|
+
for i in 1 .. total loop
|
|
94965
|
+
hit := hits -> (i - 1);
|
|
94966
|
+
if coalesce(hit ->> 'scope', '') = '' or (hit ->> 'key') is null then
|
|
94967
|
+
raise exception 'Hit % of check_rate_limits needs a scope and a key', i - 1
|
|
94968
|
+
using errcode = '22023', hint = 'RATE_LIMIT_HITS';
|
|
94969
|
+
end if;
|
|
94970
|
+
select * into rule from better_supabase.rate_limit_rules r where r.scope = hit ->> 'scope';
|
|
94971
|
+
limit_max := coalesce((hit ->> 'max_requests')::integer, rule.max_requests);
|
|
94972
|
+
limit_period := coalesce((hit ->> 'period')::interval, rule.period);
|
|
94973
|
+
if limit_max is null or limit_period is null then
|
|
94974
|
+
raise exception 'No rate limit for %: call set_rate_limit or pass max_requests and period', hit ->> 'scope'
|
|
94975
|
+
using errcode = '22023', hint = 'RATE_LIMIT_UNKNOWN';
|
|
94976
|
+
end if;
|
|
94977
|
+
if limit_max < 1 or limit_period <= interval '0' then
|
|
94978
|
+
raise exception 'The rate limit for % needs a positive max_requests and period', hit ->> 'scope'
|
|
94979
|
+
using errcode = '22023', hint = 'RATE_LIMIT_HITS';
|
|
94980
|
+
end if;
|
|
94981
|
+
for j in 1 .. i - 1 loop
|
|
94982
|
+
if scopes[j] = hit ->> 'scope' and keys[j] = hit ->> 'key' then
|
|
94983
|
+
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'
|
|
94984
|
+
using errcode = '22023', hint = 'RATE_LIMIT_HITS';
|
|
94985
|
+
end if;
|
|
94986
|
+
end loop;
|
|
94987
|
+
scopes := scopes || (hit ->> 'scope');
|
|
94988
|
+
keys := keys || (hit ->> 'key');
|
|
94989
|
+
maxes := maxes || limit_max;
|
|
94990
|
+
periods := periods || limit_period;
|
|
94991
|
+
end loop;
|
|
94992
|
+
|
|
94993
|
+
insert into better_supabase.rate_limits as l (scope, key, window_start, hits, period)
|
|
94994
|
+
select u.scope, u.key, now(), 0, u.period
|
|
94995
|
+
from unnest(scopes, keys, periods) as u(scope, key, period)
|
|
94996
|
+
order by u.scope, u.key
|
|
94997
|
+
on conflict on constraint rate_limits_pkey do nothing;
|
|
94998
|
+
|
|
94999
|
+
perform 1
|
|
95000
|
+
from better_supabase.rate_limits l
|
|
95001
|
+
join unnest(scopes, keys) as u(scope, key) on l.scope = u.scope and l.key = u.key
|
|
95002
|
+
order by l.scope, l.key
|
|
95003
|
+
for update of l;
|
|
95004
|
+
|
|
95005
|
+
for i in 1 .. total loop
|
|
95006
|
+
select * into counter from better_supabase.rate_limits l
|
|
95007
|
+
where l.scope = scopes[i] and l.key = keys[i];
|
|
95008
|
+
if counter.window_start + periods[i] <= now() then
|
|
95009
|
+
used := used || 0;
|
|
95010
|
+
starts := starts || now();
|
|
95011
|
+
else
|
|
95012
|
+
used := used || counter.hits;
|
|
95013
|
+
starts := starts || counter.window_start;
|
|
95014
|
+
end if;
|
|
95015
|
+
if used[i] + 1 > maxes[i] then
|
|
95016
|
+
longest := greatest(longest, greatest(1, ceil(extract(epoch from starts[i] + periods[i] - now()))::integer));
|
|
95017
|
+
first_blocked := coalesce(first_blocked, i - 1);
|
|
95018
|
+
end if;
|
|
95019
|
+
end loop;
|
|
95020
|
+
|
|
95021
|
+
passed := first_blocked is null;
|
|
95022
|
+
|
|
95023
|
+
if passed then
|
|
95024
|
+
for i in 1 .. total loop
|
|
95025
|
+
update better_supabase.rate_limits l set
|
|
95026
|
+
window_start = starts[i],
|
|
95027
|
+
hits = used[i] + 1,
|
|
95028
|
+
period = periods[i]
|
|
95029
|
+
where l.scope = scopes[i] and l.key = keys[i];
|
|
95030
|
+
end loop;
|
|
95031
|
+
end if;
|
|
95032
|
+
|
|
95033
|
+
for i in 1 .. total loop
|
|
95034
|
+
current_hits := used[i] + case when passed then 1 else 0 end;
|
|
95035
|
+
results := results || jsonb_build_array(jsonb_build_object(
|
|
95036
|
+
'allowed', used[i] + 1 <= maxes[i],
|
|
95037
|
+
'remaining', greatest(maxes[i] - current_hits, 0),
|
|
95038
|
+
'retry_after', case when used[i] + 1 <= maxes[i] then 0
|
|
95039
|
+
else greatest(1, ceil(extract(epoch from starts[i] + periods[i] - now()))::integer) end
|
|
95040
|
+
));
|
|
95041
|
+
end loop;
|
|
95042
|
+
|
|
95043
|
+
return jsonb_build_object(
|
|
95044
|
+
'allowed', passed,
|
|
95045
|
+
'blocked', first_blocked,
|
|
95046
|
+
'retry_after', longest,
|
|
95047
|
+
'results', results
|
|
95048
|
+
);
|
|
95049
|
+
end
|
|
95050
|
+
$$;
|
|
95051
|
+
revoke execute on function better_supabase.check_rate_limits(jsonb) from public, anon, authenticated;
|
|
95052
|
+
grant execute on function better_supabase.check_rate_limits(jsonb) to service_role;
|
|
95053
|
+
|
|
94912
95054
|
-- Deletes up to batch counters whose window has ended: the period the
|
|
94913
95055
|
-- counter was last hit with, else its rule's, else a day (counters from
|
|
94914
95056
|
-- before the period column). Every caller keeps a row until then, so
|
|
@@ -114520,7 +114662,11 @@ const UPDATED_AT = {
|
|
|
114520
114662
|
target: "schema",
|
|
114521
114663
|
names: {
|
|
114522
114664
|
tables: {},
|
|
114523
|
-
options: [
|
|
114665
|
+
options: [
|
|
114666
|
+
"createdAt",
|
|
114667
|
+
"updatedAt",
|
|
114668
|
+
"stamp"
|
|
114669
|
+
]
|
|
114524
114670
|
},
|
|
114525
114671
|
build: () => `${SCHEMA$5}
|
|
114526
114672
|
|
|
@@ -125961,16 +126107,7 @@ function parsePolicy(statement) {
|
|
|
125961
126107
|
}
|
|
125962
126108
|
const BLOCK_PREFIX = "bsb_";
|
|
125963
126109
|
const POLICY_EDIT = new RegExp(String.raw`^\s*(?:alter\s+policy|comment\s+on\s+policy)\s+(${NAME$9})\s+on\s+(${NAME$9}(?:\s*\.\s*${NAME$9})?)`, "i");
|
|
125964
|
-
|
|
125965
|
-
* `sql` without the block's permissive `bsb_` policies that the app's own
|
|
125966
|
-
* policies on the same table already cover for every command they grant (the
|
|
125967
|
-
* comparison BS347 makes), so Postgres doesn't OR two policies that admit the
|
|
125968
|
-
* same rows. A block policy that is wider stays, and BS347 reports it. The
|
|
125969
|
-
* `drop policy if exists` before it stays too, so an earlier install's copy
|
|
125970
|
-
* goes.
|
|
125971
|
-
*/
|
|
125972
|
-
function withoutCoveredPolicies(sql, ownPolicies = {}) {
|
|
125973
|
-
if (Object.keys(ownPolicies).length === 0) return sql;
|
|
126110
|
+
function withoutBlockPolicies(sql, skip, restrictive = false) {
|
|
125974
126111
|
const masked = maskComments(sql);
|
|
125975
126112
|
const skipped = /* @__PURE__ */ new Set();
|
|
125976
126113
|
const statements = statementSpans(sql).map(([from, to]) => ({
|
|
@@ -125979,20 +126116,51 @@ function withoutCoveredPolicies(sql, ownPolicies = {}) {
|
|
|
125979
126116
|
}));
|
|
125980
126117
|
const kept = statements.map(({ text, masked: statement }) => {
|
|
125981
126118
|
const parsed = parsePolicy(statement);
|
|
125982
|
-
if (parsed === void 0 || !parsed.policy.name.startsWith(BLOCK_PREFIX) || !parsed.policy.permissive) return text;
|
|
125983
|
-
const
|
|
125984
|
-
|
|
125985
|
-
if (covering.length === 0 || covering.includes(void 0)) return text;
|
|
126119
|
+
if (parsed === void 0 || !parsed.policy.name.startsWith(BLOCK_PREFIX) || !(parsed.policy.permissive || restrictive)) return text;
|
|
126120
|
+
const comment = skip(parsed);
|
|
126121
|
+
if (comment === void 0) return text;
|
|
125986
126122
|
skipped.add(`${parsed.table}\u0000${parsed.policy.name}`);
|
|
125987
|
-
const names = [...new Set(covering.map((policy) => policy.name))].join(" and ");
|
|
125988
126123
|
const start = statement.search(/\S/);
|
|
125989
|
-
return `${text.slice(0, start === -1 ? 0 : start).trimEnd()}\n-- ${parsed.table}:
|
|
126124
|
+
return `${text.slice(0, start === -1 ? 0 : start).trimEnd()}\n-- ${parsed.table}: ${comment}`;
|
|
125990
126125
|
});
|
|
125991
126126
|
return statements.map(({ masked: statement }, index) => {
|
|
125992
126127
|
const edit = POLICY_EDIT.exec(statement);
|
|
125993
126128
|
return edit !== null && skipped.has(`${qualified$8(edit[2])}\u0000${unquote$4(edit[1])}`) ? "" : kept[index];
|
|
125994
126129
|
}).join("");
|
|
125995
126130
|
}
|
|
126131
|
+
/**
|
|
126132
|
+
* `sql` without the block's permissive `bsb_` policies that the app's own
|
|
126133
|
+
* policies on the same table already cover for every command they grant (the
|
|
126134
|
+
* comparison BS347 makes), so Postgres doesn't OR two policies that admit the
|
|
126135
|
+
* same rows. A block policy that is wider stays, and BS347 reports it. The
|
|
126136
|
+
* `drop policy if exists` before it stays too, so an earlier install's copy
|
|
126137
|
+
* goes.
|
|
126138
|
+
*/
|
|
126139
|
+
function withoutCoveredPolicies(sql, ownPolicies = {}) {
|
|
126140
|
+
if (Object.keys(ownPolicies).length === 0) return sql;
|
|
126141
|
+
return withoutBlockPolicies(sql, ({ table, policy }) => {
|
|
126142
|
+
const apps = (ownPolicies[table] ?? []).filter((own) => !own.name.startsWith(BLOCK_PREFIX));
|
|
126143
|
+
const covering = COMMANDS.filter((command) => coversCommand(policy, command)).map((command) => coveringPolicy(policy, apps, command));
|
|
126144
|
+
if (covering.length === 0 || covering.includes(void 0)) return;
|
|
126145
|
+
return `the app's policy ${[...new Set(covering.map((own) => own.name))].join(" and ")} already allows what ${policy.name} would, so the block adds none.`;
|
|
126146
|
+
});
|
|
126147
|
+
}
|
|
126148
|
+
const APP_POLICIES_NOTE = `the app's policies govern this table (ownTablePolicies "app"), so the block adds no`;
|
|
126149
|
+
const APP_POLICIES = new RegExp(String.raw`^-- (\S+): ${APP_POLICIES_NOTE.replaceAll(/[()]/g, String.raw`\$&`)} (\S+) for ([a-z, ]+)\.$`, "gm");
|
|
126150
|
+
function appTablePolicyNotes(sql) {
|
|
126151
|
+
return [...sql.matchAll(APP_POLICIES)].map(([, table = "", policy = "", commands = ""]) => ({
|
|
126152
|
+
table,
|
|
126153
|
+
policy,
|
|
126154
|
+
commands: COMMANDS.filter((command) => commands.split(", ").includes(command))
|
|
126155
|
+
}));
|
|
126156
|
+
}
|
|
126157
|
+
function withoutAppTablePolicies(sql, tables) {
|
|
126158
|
+
if (tables.size === 0) return sql;
|
|
126159
|
+
return withoutBlockPolicies(sql, ({ table, policy }) => {
|
|
126160
|
+
if (!tables.has(table)) return;
|
|
126161
|
+
return policy.permissive ? `${APP_POLICIES_NOTE} ${policy.name} for ${COMMANDS.filter((command) => coversCommand(policy, command)).join(", ")}.` : `${APP_POLICIES_NOTE} restrictive ${policy.name}.`;
|
|
126162
|
+
}, true);
|
|
126163
|
+
}
|
|
125996
126164
|
const DROP_POLICY = new RegExp(String.raw`^\s*drop\s+policy\s+(?:if\s+exists\s+)?(${NAME$9})\s+on\s+(${NAME$9}(?:\s*\.\s*${NAME$9})?)`, "i");
|
|
125997
126165
|
/**
|
|
125998
126166
|
* The policies `sources` leave on each `schema.table` in `schemas`, in order: a
|
|
@@ -126175,7 +126343,7 @@ function moduleBody(name, layout = {}) {
|
|
|
126175
126343
|
*/
|
|
126176
126344
|
function overApp(sql, ctx, layout) {
|
|
126177
126345
|
const appTables = appTableSet(ctx);
|
|
126178
|
-
return withoutUnmappedColumns(withoutUnmappedTables(blockNamesOnAppTables(withoutAppTableEdits(overAppTables(overAppViews(sql, appTableSet(ctx, ctx.appViews)), appTables, layout.ownColumns), appTables), appTables, layout.ownUpdatedAtTriggers), ctx.instance), ctx.instance);
|
|
126346
|
+
return withoutAppTablePolicies(withoutUnmappedColumns(withoutUnmappedTables(blockNamesOnAppTables(withoutAppTableEdits(overAppTables(overAppViews(sql, appTableSet(ctx, ctx.appViews)), appTables, layout.ownColumns), appTables), appTables, layout.ownUpdatedAtTriggers), ctx.instance), ctx.instance), ctx.config.ownTablePolicies === "app" ? appTables : /* @__PURE__ */ new Set());
|
|
126179
126347
|
}
|
|
126180
126348
|
/** The app's tables a module runs over, as `schema.table`. */
|
|
126181
126349
|
function appTableSet(ctx, tables = ctx.appOwned) {
|
|
@@ -127255,4 +127423,4 @@ async function compileReadSets(sets) {
|
|
|
127255
127423
|
return Promise.all(names.map((name) => compileReadSet(byName.get(name))));
|
|
127256
127424
|
}
|
|
127257
127425
|
//#endregion
|
|
127258
|
-
export {
|
|
127426
|
+
export { MODULE_ID_TYPES as $, isModuleDataFile as A, excludedColumns as B, moduleFilePaths as C, scopePolicyName as D, appTablesFiles as E, modulePermissionKeys as F, sameTenantColumn as G, SECRET_COLUMNS as H, moduleSchemaExtensions as I, BLOCK_RENAMES as J, sameTenantTrigger as K, SQL_MODULES as L, sameBlockFile as M, moduleEventTriggers as N, blockSqlVersion as O, moduleHidingColumns as P, AUDIT_CATEGORIES as Q, resolveBlocks as R, moduleDataDir as S, APP_TABLES_MODULE as T, dataExportPlan as U, resolveExposeColumns as V, subjectColumns$1 as W, formerBlockName as X, currentBlockName as Y, renamedBlock as Z, moduleDeprecations as _, tenantsQuery as a, declaredTables as at, declaredPolicies as b, adoptedColumnProblems as c, extensionSchema as ct, instanceFunctions as d, auditRegistrations as dt, contractSignature as et, entityRenamePlan as f, renderBlocks as g, moduleTopics as h, moduleLayout as i, declaredTableColumns as it, moduleFileVersion as j, blockFileState as k, adoptedTables as l, policyGrants as lt, moduleBody as m, compileReadSets as n, moduleIdType as nt, expiredFlagsQuery as o, declaredUpdatedAtTriggers as ot, customContracts as p, migrationOptionUses as q, sharedRolesProblems as r, BLOCK_OPTION_SCHEMAS as rt, sameTenantLayout as s, declaredViews as st, compileReadSet as t, isBlockSqlIdType as tt, adoptedViews as u, rlsTables as ut, upgradePlan as v, APP_TABLES_MARKER as w, widenedCommands as x, appTablePolicyNotes as y, TENANT_SCOPE_POLICY 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-BWFfz0ik.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-B0jmjNLD.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 };
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { E as AccessPolicySql, T as AccessBucketPolicy, _t as BucketLifecycle, bt as VersioningStatus, vt as BucketLifecycleRule, yt as ObjectVersion } from "../types-DFdg_4yN.js";
|
|
2
|
-
import { $ as
|
|
3
|
-
import { A as
|
|
4
|
-
export { type AccessBucketPolicy, type AccessPolicySql, type ActualBucket, type AnalyticsBucket, type AnalyticsBucketClient, type AnalyticsCatalog, type AnyBucket, type AppliedBucket, type AvatarBucketOptions, type Bucket, type BucketClient, type BucketConfig, type BucketConnectOptions, type BucketDrift, type BucketIdOf, type BucketLifecycle, type BucketLifecycleRule, type BucketMap, type BucketPolicy, type BucketWithId, type Buckets, type ConnectedRef, type DownloadOptions, IMAGE_TYPES, type ImageBucketOptions, type ImageTransform, type ImageVariant, type ObjectTarget, type ObjectVersion, type OrganizationLogoBucketOptions, type PathIn, type PathValues, type PurgeCacheOptions, type ReplaceOptions, type ReplaceResult, type Reservation, type ResolvedRef, type StorageAdminClient, type StorageApi, type StorageBucketApi, type StorageClient, type StorageDestinationOptions, type StorageDownloadOptions, type StorageFailure, type StorageFetchParameters, type StorageFileOptions, type StorageImageOptions, type StorageImageSize, type StorageListEntry, type StorageListV2Folder, type StorageListV2Object, type StorageListV2Result, type StorageObjectInfo, type StoragePath, type StorageRemoveEntry, type StorageResponse, type StorageSearchOptions, type StorageSearchV2Options, type StorageSignedUrlEntry, type StorageTransform, type StorageUrlOptions, type StoredObject, type StoredRef, type SweepOptions, type SweepResult, TTL, type TemplateParams, type TemplateValues, type TransferOptions, type TransformOptions, type TtlPreset, type UploadBody, type UploadOptions, type UrlOptions, type VectorBucket, type VectorBucketClient, type VectorBucketConfig, type VectorDistance, type VectorHit, type VectorIndexClient, type VectorIndexConfig, type VectorMetadata, type VectorQueryOptions, type VectorRecord, type VersioningStatus, avatarBucket, defineAnalyticsBucket, defineBucket, defineBuckets, defineVectorBucket, fromStorageError, organizationLogoBucket, parseSize, storageImageSrcSet, storageImageUrl };
|
|
2
|
+
import { $ as AppliedBucket, A as TtlPreset, B as StorageListV2Folder, C as TransformOptions, D as defineBucket, E as UrlOptions, F as StorageDownloadOptions, G as StorageResponse, H as StorageListV2Result, I as StorageFailure, J as StorageSignedUrlEntry, K as StorageSearchOptions, L as StorageFetchParameters, M as StorageBucketApi, N as StorageClient, O as parseSize, P as StorageDestinationOptions, Q as StoragePath, R as StorageFileOptions, S as TransferOptions, T as UploadOptions, U as StorageObjectInfo, V as StorageListV2Object, W as StorageRemoveEntry, X as StorageUrlOptions, Y as StorageTransform, Z as PathIn, _ as ResumableReservation, a as BucketConnectOptions, b as SweepOptions, c as DownloadOptions, d as PathValues, et as TemplateParams, f as PurgeCacheOptions, g as ReserveResumableOptions, h as Reservation, i as BucketConfig, j as StorageApi, k as TTL, l as ImageTransform, m as ReplaceResult, n as Bucket, o as BucketDrift, p as ReplaceOptions, q as StorageSearchV2Options, r as BucketClient, s as BucketPolicy, t as ActualBucket, tt as TemplateValues, u as ObjectTarget, v as StorageAdminClient, w as UploadBody, x as SweepResult, y as StoredObject, z as StorageListEntry } from "../bucket-vc-QRrva.js";
|
|
3
|
+
import { A as ConnectedRef, C as avatarBucket, D as BucketMap, E as BucketIdOf, F as StorageImageSize, I as storageImageSrcSet, L as storageImageUrl, M as StoredRef, N as defineBuckets, O as BucketWithId, P as StorageImageOptions, R as fromStorageError, S as OrganizationLogoBucketOptions, T as AnyBucket, _ as defineAnalyticsBucket, a as VectorBucketConfig, b as ImageBucketOptions, c as VectorIndexClient, d as VectorQueryOptions, f as VectorRecord, g as AnalyticsCatalog, h as AnalyticsBucketClient, i as VectorBucketClient, j as ResolvedRef, k as Buckets, l as VectorIndexConfig, m as AnalyticsBucket, n as resumableEndpoint, o as VectorDistance, p as defineVectorBucket, r as VectorBucket, s as VectorHit, t as ResumableEndpointOptions, u as VectorMetadata, v as AvatarBucketOptions, w as organizationLogoBucket, x as ImageVariant, y as IMAGE_TYPES } from "../index-CQhPHHDF.js";
|
|
4
|
+
export { type AccessBucketPolicy, type AccessPolicySql, type ActualBucket, type AnalyticsBucket, type AnalyticsBucketClient, type AnalyticsCatalog, type AnyBucket, type AppliedBucket, type AvatarBucketOptions, type Bucket, type BucketClient, type BucketConfig, type BucketConnectOptions, type BucketDrift, type BucketIdOf, type BucketLifecycle, type BucketLifecycleRule, type BucketMap, type BucketPolicy, type BucketWithId, type Buckets, type ConnectedRef, type DownloadOptions, IMAGE_TYPES, type ImageBucketOptions, type ImageTransform, type ImageVariant, type ObjectTarget, type ObjectVersion, type OrganizationLogoBucketOptions, type PathIn, type PathValues, type PurgeCacheOptions, type ReplaceOptions, type ReplaceResult, type Reservation, type ReserveResumableOptions, type ResolvedRef, type ResumableEndpointOptions, type ResumableReservation, type StorageAdminClient, type StorageApi, type StorageBucketApi, type StorageClient, type StorageDestinationOptions, type StorageDownloadOptions, type StorageFailure, type StorageFetchParameters, type StorageFileOptions, type StorageImageOptions, type StorageImageSize, type StorageListEntry, type StorageListV2Folder, type StorageListV2Object, type StorageListV2Result, type StorageObjectInfo, type StoragePath, type StorageRemoveEntry, type StorageResponse, type StorageSearchOptions, type StorageSearchV2Options, type StorageSignedUrlEntry, type StorageTransform, type StorageUrlOptions, type StoredObject, type StoredRef, type SweepOptions, type SweepResult, TTL, type TemplateParams, type TemplateValues, type TransferOptions, type TransformOptions, type TtlPreset, type UploadBody, type UploadOptions, type UrlOptions, type VectorBucket, type VectorBucketClient, type VectorBucketConfig, type VectorDistance, type VectorHit, type VectorIndexClient, type VectorIndexConfig, type VectorMetadata, type VectorQueryOptions, type VectorRecord, type VersioningStatus, avatarBucket, defineAnalyticsBucket, defineBucket, defineBuckets, defineVectorBucket, fromStorageError, organizationLogoBucket, parseSize, resumableEndpoint, storageImageSrcSet, storageImageUrl };
|
package/dist/storage/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { c as optionalTemporal, n as isInstant } from "../temporal-DLZlWbOi.js";
|
|
|
4
4
|
import { n as temporalMissing } from "../temporal-required-Dy0GGD8E.js";
|
|
5
5
|
import { a as ok, r as err, s as toDbError, t as AsyncResult } from "../result-ntFBW2p2.js";
|
|
6
6
|
import { a as spansAllTenants } from "../plugin-AKwwe2gF.js";
|
|
7
|
+
import { n as decodeJwtPayload } from "../base64-B9Wlsdj7.js";
|
|
7
8
|
import { a as tenantClaimPaths, o as tenantFrom, s as tenantPathsFor } from "../claims-Bp9My7XP.js";
|
|
8
9
|
import { a as sqlString, i as sqlIdent, n as parseTemplate, r as slug, t as claimSql } from "../template-Drgg3v2J.js";
|
|
9
10
|
import { r as accessCheck } from "../access-sql-B-MkVARa.js";
|
|
@@ -281,6 +282,38 @@ function parseFailure(status, text) {
|
|
|
281
282
|
};
|
|
282
283
|
}
|
|
283
284
|
//#endregion
|
|
285
|
+
//#region src/storage/resumable.ts
|
|
286
|
+
/** Storage signs upload tokens for two hours. */
|
|
287
|
+
const UPLOAD_TOKEN_SECONDS = 7200;
|
|
288
|
+
const HOSTED = /^(?<ref>[a-z0-9-]+)\.supabase\.co$/i;
|
|
289
|
+
const SIGNED_UPLOAD = "/object/upload/sign/";
|
|
290
|
+
const STORAGE_PATH = "/storage/v1";
|
|
291
|
+
/**
|
|
292
|
+
* The TUS endpoint for a signed resumable upload,
|
|
293
|
+
* `<storage>/upload/resumable/sign`. `url` is the project URL (`SUPABASE_URL`),
|
|
294
|
+
* the Storage URL (`.../storage/v1`) or a signed upload URL from
|
|
295
|
+
* `createSignedUploadUrl`.
|
|
296
|
+
*/
|
|
297
|
+
function resumableEndpoint(url, options = {}) {
|
|
298
|
+
const parsed = new URL(url);
|
|
299
|
+
const path = parsed.pathname;
|
|
300
|
+
const storage = path.indexOf(STORAGE_PATH);
|
|
301
|
+
const signed = path.indexOf(SIGNED_UPLOAD);
|
|
302
|
+
const base = storage === -1 ? signed === -1 ? `${path.replace(/\/+$/, "")}${STORAGE_PATH}` : path.slice(0, signed) : path.slice(0, storage + 11);
|
|
303
|
+
const hosted = HOSTED.exec(parsed.hostname);
|
|
304
|
+
if ((options.direct ?? true) && hosted?.groups?.["ref"] !== void 0) parsed.hostname = `${hosted.groups["ref"]}.storage.supabase.co`;
|
|
305
|
+
parsed.pathname = `${base}/upload/resumable/sign`;
|
|
306
|
+
parsed.search = "";
|
|
307
|
+
parsed.hash = "";
|
|
308
|
+
return parsed.toString();
|
|
309
|
+
}
|
|
310
|
+
/** When a signed upload token expires: its `exp`, else two hours from `now`. */
|
|
311
|
+
function uploadTokenExpiry(token, now) {
|
|
312
|
+
const exp = decodeJwtPayload(token)?.["exp"];
|
|
313
|
+
const seconds = typeof exp === "number" && Number.isFinite(exp) ? exp : Math.floor(now / 1e3) + UPLOAD_TOKEN_SECONDS;
|
|
314
|
+
return (/* @__PURE__ */ new Date(seconds * 1e3)).toISOString();
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
284
317
|
//#region src/storage/storage-api.ts
|
|
285
318
|
/** The `StorageApi` of a client, or the client itself. */
|
|
286
319
|
function storageApiOf(client) {
|
|
@@ -673,6 +706,26 @@ function connectBucket(bucket, client, resolveTarget, connectOptions, guard) {
|
|
|
673
706
|
signedUrl: data.signedUrl
|
|
674
707
|
}));
|
|
675
708
|
}),
|
|
709
|
+
reserveResumable: (target, options) => AsyncResult.from(async () => {
|
|
710
|
+
const path = resolve(target);
|
|
711
|
+
const upsert = options?.upsert ?? false;
|
|
712
|
+
return run(() => api().createSignedUploadUrl(path, upsert ? { upsert } : void 0)).map((data) => ({
|
|
713
|
+
path: data.path,
|
|
714
|
+
token: data.token,
|
|
715
|
+
signedUrl: data.signedUrl,
|
|
716
|
+
bucket: bucket.id,
|
|
717
|
+
tusEndpoint: resumableEndpoint(data.signedUrl, options?.direct === void 0 ? {} : { direct: options.direct }),
|
|
718
|
+
expiresAt: uploadTokenExpiry(data.token, options?.now?.() ?? Date.now()),
|
|
719
|
+
headers: {
|
|
720
|
+
"x-signature": data.token,
|
|
721
|
+
"x-upsert": upsert ? "true" : "false"
|
|
722
|
+
},
|
|
723
|
+
metadata: {
|
|
724
|
+
bucketName: bucket.id,
|
|
725
|
+
objectName: data.path
|
|
726
|
+
}
|
|
727
|
+
}));
|
|
728
|
+
}),
|
|
676
729
|
uploadReserved: (reservation, body, options) => AsyncResult.from(async () => {
|
|
677
730
|
options?.signal?.throwIfAborted();
|
|
678
731
|
const path = resolve(reservation.path);
|
|
@@ -1412,4 +1465,4 @@ function connectVectorBucket(config, client) {
|
|
|
1412
1465
|
};
|
|
1413
1466
|
}
|
|
1414
1467
|
//#endregion
|
|
1415
|
-
export { IMAGE_TYPES, TTL, avatarBucket, defineAnalyticsBucket, defineBucket, defineBuckets, defineVectorBucket, fromStorageError, organizationLogoBucket, parseSize, storageImageSrcSet, storageImageUrl };
|
|
1468
|
+
export { IMAGE_TYPES, TTL, avatarBucket, defineAnalyticsBucket, defineBucket, defineBuckets, defineVectorBucket, fromStorageError, organizationLogoBucket, parseSize, resumableEndpoint, storageImageSrcSet, storageImageUrl };
|