better-supabase 0.20.0 → 0.22.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-CfuBICuG.js → adapter-D4aNBxhm.js} +4 -4
- package/dist/{ai-cache-BuNbWEFI.js → ai-cache-BFRKxgZ4.js} +2 -2
- package/dist/{ai-files-DeMWQfzs.js → ai-files-m_2z3rH1.js} +3 -3
- package/dist/{ai-schedules-Bp-U0cZG.d.ts → ai-schedules-7uQNMXve.d.ts} +1 -1
- package/dist/ai-sdk/agents/index.d.ts +2 -2
- package/dist/ai-sdk/batches/index.js +3 -3
- package/dist/ai-sdk/cache/index.js +1 -1
- package/dist/ai-sdk/chat/index.js +1 -1
- package/dist/ai-sdk/files/index.js +2 -2
- package/dist/ai-sdk/index.js +3 -3
- package/dist/ai-sdk/mcp/index.js +2 -2
- package/dist/ai-sdk/workflow/index.js +2 -2
- package/dist/api-3C0AWFeP.js +696 -0
- package/dist/{api-BIw5g_4V.d.ts → api-CHObZL7m.d.ts} +2 -2
- package/dist/{app-tables-oYkgtcRM.d.ts → app-tables-BGzdnQm5.d.ts} +1 -1
- package/dist/astro/index.d.ts +3 -3
- package/dist/astro/index.js +5 -5
- package/dist/{attachments-BTIwCuwm.js → attachments-BXbLnNxm.js} +5 -5
- package/dist/{authorization-08F77H2w.d.ts → authorization-DhoA7dsD.d.ts} +22 -8
- package/dist/{automations-jIIaT9EJ.js → automations-BMuqwZZn.js} +5 -5
- package/dist/better-result/index.d.ts +2 -2
- package/dist/{bind-BwQGUqdQ.d.ts → bind-CFsctoFJ.d.ts} +4 -4
- package/dist/{block-authors-D9hyCizs.js → block-authors-Bw3zdzgl.js} +1 -1
- package/dist/{block-env-Dh0Fe-fK.d.ts → block-env-BrUNeuJ_.d.ts} +4 -4
- package/dist/{block-events-pBXPzwnW.js → block-events-IWAyafO3.js} +1 -1
- package/dist/{block-fields-DE_FgpOU.js → block-fields-BjXgX_5c.js} +4 -3
- package/dist/{block-helpers-DnCtsKtv.js → block-helpers-B0f0ZVb5.js} +169 -4
- package/dist/{block-hooks-DbIpkq7a.js → block-hooks-DKtz0HRh.js} +1 -1
- package/dist/{block-subjects-BRJO0IqO.js → block-subjects-DFSuFY1a.js} +1 -1
- package/dist/blocks/access-requests/index.d.ts +1 -1
- package/dist/blocks/access-requests/index.js +4 -5
- package/dist/blocks/activities/index.d.ts +1 -1
- package/dist/blocks/activities/index.js +4 -5
- package/dist/blocks/agents/index.d.ts +1 -1
- package/dist/blocks/agents/index.js +3 -4
- package/dist/blocks/ai-cache/index.d.ts +1 -1
- package/dist/blocks/ai-cache/index.js +2 -2
- package/dist/blocks/ai-chat/index.d.ts +4 -4
- package/dist/blocks/ai-chat/index.js +4 -5
- package/dist/blocks/ai-files/index.d.ts +1 -1
- package/dist/blocks/ai-files/index.js +2 -2
- package/dist/blocks/ai-keys/index.d.ts +1 -1
- package/dist/blocks/ai-keys/index.js +3 -4
- package/dist/blocks/ai-schedules/index.d.ts +2 -2
- package/dist/blocks/ai-schedules/index.js +5 -6
- package/dist/blocks/announcements/index.d.ts +4 -4
- package/dist/blocks/announcements/index.js +4 -5
- package/dist/blocks/api-keys/index.d.ts +2 -2
- package/dist/blocks/api-keys/index.js +5 -6
- package/dist/blocks/approvals/index.d.ts +1 -1
- package/dist/blocks/approvals/index.js +4 -5
- package/dist/blocks/assets/index.d.ts +1 -1
- package/dist/blocks/assets/index.js +3 -4
- package/dist/blocks/assignment/index.d.ts +1 -1
- package/dist/blocks/assignment/index.js +4 -5
- package/dist/blocks/attachments/index.d.ts +2 -2
- package/dist/blocks/attachments/index.js +5 -6
- package/dist/blocks/audit/index.d.ts +5 -5
- package/dist/blocks/audit/index.js +8 -9
- package/dist/blocks/automations/index.d.ts +3 -3
- package/dist/blocks/automations/index.js +6 -6
- package/dist/blocks/billable-time/index.d.ts +1 -1
- package/dist/blocks/billable-time/index.js +6 -7
- package/dist/blocks/billing/index.d.ts +3 -3
- package/dist/blocks/billing/index.js +6 -7
- package/dist/blocks/bookings/index.d.ts +3 -3
- package/dist/blocks/bookings/index.js +7 -7
- package/dist/blocks/bulk/index.d.ts +4 -3
- package/dist/blocks/bulk/index.js +4 -4
- package/dist/blocks/calendar/index.d.ts +2 -2
- package/dist/blocks/calendar/index.js +7 -7
- package/dist/blocks/catalog/index.d.ts +1 -1
- package/dist/blocks/catalog/index.js +5 -6
- package/dist/blocks/channels/index.d.ts +1 -1
- package/dist/blocks/channels/index.js +3 -4
- package/dist/blocks/collections/index.d.ts +1 -1
- package/dist/blocks/collections/index.js +3 -4
- package/dist/blocks/comments/index.d.ts +5 -5
- package/dist/blocks/comments/index.js +8 -9
- package/dist/blocks/compliance/index.d.ts +1 -1
- package/dist/blocks/compliance/index.js +5 -6
- package/dist/blocks/connectors/index.d.ts +1 -1
- package/dist/blocks/connectors/index.js +3 -4
- package/dist/blocks/contacts/index.d.ts +1 -1
- package/dist/blocks/contacts/index.js +4 -5
- package/dist/blocks/content/index.d.ts +1 -1
- package/dist/blocks/content/index.js +3 -4
- package/dist/blocks/contracts/index.d.ts +1 -1
- package/dist/blocks/contracts/index.js +8 -9
- package/dist/blocks/courses/index.d.ts +1 -1
- package/dist/blocks/courses/index.js +5 -6
- package/dist/blocks/created-by/index.d.ts +1 -1
- package/dist/blocks/custom-fields/index.d.ts +1 -1
- package/dist/blocks/custom-fields/index.js +2 -2
- package/dist/blocks/data-lifecycle/index.d.ts +1 -1
- package/dist/blocks/data-lifecycle/index.js +3 -4
- package/dist/blocks/deals/index.d.ts +1 -1
- package/dist/blocks/deals/index.js +9 -10
- package/dist/blocks/dispatch/index.d.ts +1 -1
- package/dist/blocks/dispatch/index.js +7 -8
- package/dist/blocks/documents/index.d.ts +1 -1
- package/dist/blocks/documents/index.js +2 -3
- package/dist/blocks/domains/index.d.ts +1 -1
- package/dist/blocks/domains/index.js +3 -4
- package/dist/blocks/donations/index.d.ts +1 -1
- package/dist/blocks/donations/index.js +7 -8
- package/dist/blocks/drive/index.d.ts +5 -1
- package/dist/blocks/drive/index.js +6 -7
- package/dist/blocks/employees/index.d.ts +2 -2
- package/dist/blocks/employees/index.js +7 -8
- package/dist/blocks/enrichment/index.d.ts +1 -1
- package/dist/blocks/enrichment/index.js +2 -3
- package/dist/blocks/enrollments/index.d.ts +1 -1
- package/dist/blocks/enrollments/index.js +3 -4
- package/dist/blocks/entitlements/index.d.ts +3 -3
- package/dist/blocks/entitlements/index.js +2 -2
- package/dist/blocks/expenses/index.d.ts +1 -1
- package/dist/blocks/expenses/index.js +6 -7
- package/dist/blocks/field-history/index.d.ts +1 -1
- package/dist/blocks/field-history/index.js +2 -3
- package/dist/blocks/flags/index.d.ts +1 -1
- package/dist/blocks/flags/index.js +4 -5
- package/dist/blocks/forecasts/index.d.ts +1 -1
- package/dist/blocks/forecasts/index.js +5 -6
- package/dist/blocks/forms/index.d.ts +2 -2
- package/dist/blocks/forms/index.js +4 -5
- package/dist/blocks/goals/index.d.ts +1 -1
- package/dist/blocks/goals/index.js +4 -5
- package/dist/blocks/guests/index.d.ts +1 -1
- package/dist/blocks/guests/index.js +4 -5
- package/dist/blocks/hiring/index.d.ts +1 -1
- package/dist/blocks/hiring/index.js +4 -5
- package/dist/blocks/identities/index.d.ts +1 -1
- package/dist/blocks/identities/index.js +2 -3
- package/dist/blocks/imports/index.d.ts +1 -1
- package/dist/blocks/imports/index.js +3 -3
- package/dist/blocks/inbox/index.d.ts +5 -5
- package/dist/blocks/inbox/index.js +4 -5
- package/dist/blocks/incidents/index.d.ts +1 -1
- package/dist/blocks/incidents/index.js +5 -6
- package/dist/blocks/index.d.ts +2 -2
- package/dist/blocks/index.js +7 -7
- package/dist/blocks/inventory/index.d.ts +1 -1
- package/dist/blocks/inventory/index.js +3 -4
- package/dist/blocks/invoices/index.d.ts +1 -1
- package/dist/blocks/invoices/index.js +6 -7
- package/dist/blocks/knowledge/index.d.ts +1 -1
- package/dist/blocks/knowledge/index.js +2 -2
- package/dist/blocks/lead-scoring/index.d.ts +1 -1
- package/dist/blocks/lead-scoring/index.js +4 -5
- package/dist/blocks/leases/index.d.ts +1 -1
- package/dist/blocks/leases/index.js +7 -8
- package/dist/blocks/leave/index.d.ts +1 -1
- package/dist/blocks/leave/index.js +4 -5
- package/dist/blocks/ledger/index.d.ts +1 -1
- package/dist/blocks/ledger/index.js +3 -4
- package/dist/blocks/mail-sync/index.d.ts +1 -1
- package/dist/blocks/mail-sync/index.js +5 -6
- package/dist/blocks/memberships/index.d.ts +1 -1
- package/dist/blocks/memory/index.d.ts +1 -1
- package/dist/blocks/memory/index.js +3 -4
- package/dist/blocks/messaging/index.d.ts +5 -5
- package/dist/blocks/messaging/index.js +6 -7
- package/dist/blocks/metrics/index.d.ts +1 -1
- package/dist/blocks/metrics/index.js +4 -5
- package/dist/blocks/mfa/index.d.ts +2 -2
- package/dist/blocks/moderation/index.d.ts +1 -1
- package/dist/blocks/moderation/index.js +3 -4
- package/dist/blocks/notifications/index.d.ts +4 -4
- package/dist/blocks/notifications/index.js +8 -9
- package/dist/blocks/numbering/index.d.ts +1 -1
- package/dist/blocks/numbering/index.js +2 -2
- package/dist/blocks/oauth-server/index.d.ts +1 -1
- package/dist/blocks/oauth-server/index.js +3 -4
- package/dist/blocks/onboarding/index.d.ts +2 -2
- package/dist/blocks/onboarding/index.js +2 -3
- package/dist/blocks/orders/index.d.ts +9 -2
- package/dist/blocks/orders/index.js +7 -8
- package/dist/blocks/organizations/index.d.ts +3 -3
- package/dist/blocks/organizations/index.js +5 -6
- package/dist/blocks/outbox/index.d.ts +1 -1
- package/dist/blocks/outbox/index.js +3 -4
- package/dist/blocks/passes/index.d.ts +2 -2
- package/dist/blocks/passes/index.js +7 -8
- package/dist/blocks/permissions/index.d.ts +3 -3
- package/dist/blocks/permissions/index.js +2 -3
- package/dist/blocks/pipelines/index.d.ts +1 -1
- package/dist/blocks/pipelines/index.js +4 -5
- package/dist/blocks/posts/index.d.ts +1 -1
- package/dist/blocks/posts/index.js +4 -5
- package/dist/blocks/profiles/index.d.ts +1 -1
- package/dist/blocks/profiles/index.js +3 -4
- package/dist/blocks/promotions/index.d.ts +1 -1
- package/dist/blocks/promotions/index.js +4 -5
- package/dist/blocks/push/index.d.ts +2 -2
- package/dist/blocks/push/index.js +5 -6
- package/dist/blocks/queue/index.d.ts +1 -1
- package/dist/blocks/queue/index.js +7 -8
- package/dist/blocks/quotes/index.d.ts +1 -1
- package/dist/blocks/quotes/index.js +6 -7
- package/dist/blocks/rank/index.d.ts +1 -1
- package/dist/blocks/rank/index.js +2 -2
- package/dist/blocks/reactions/index.d.ts +4 -4
- package/dist/blocks/reactions/index.js +4 -5
- package/dist/blocks/relations/index.d.ts +3 -2
- package/dist/blocks/relations/index.js +8 -8
- package/dist/blocks/reminders/index.d.ts +10 -6
- package/dist/blocks/reminders/index.js +13 -12
- package/dist/blocks/reviews/index.d.ts +1 -1
- package/dist/blocks/reviews/index.js +3 -4
- package/dist/blocks/saved-views/index.d.ts +3 -3
- package/dist/blocks/saved-views/index.js +4 -4
- package/dist/blocks/scores/index.d.ts +1 -1
- package/dist/blocks/scores/index.js +4 -4
- package/dist/blocks/search/index.d.ts +3 -3
- package/dist/blocks/search/index.js +3 -4
- package/dist/blocks/security-events/index.d.ts +1 -1
- package/dist/blocks/security-events/index.js +2 -3
- package/dist/blocks/segments/index.d.ts +1 -1
- package/dist/blocks/segments/index.js +4 -5
- package/dist/blocks/sequences/index.d.ts +1 -1
- package/dist/blocks/sequences/index.js +3 -4
- package/dist/blocks/service-accounts/index.d.ts +1 -1
- package/dist/blocks/service-accounts/index.js +3 -4
- package/dist/blocks/sessions/index.d.ts +2 -2
- package/dist/blocks/sessions/index.js +1 -1
- package/dist/blocks/settings/index.d.ts +2 -2
- package/dist/blocks/settings/index.js +3 -4
- package/dist/blocks/share-links/index.d.ts +1 -1
- package/dist/blocks/share-links/index.js +6 -6
- package/dist/blocks/shipments/index.d.ts +1 -1
- package/dist/blocks/shipments/index.js +9 -10
- package/dist/blocks/signatures/index.d.ts +1 -1
- package/dist/blocks/signatures/index.js +3 -4
- package/dist/blocks/signing-keys/index.d.ts +1 -1
- package/dist/blocks/signing-keys/index.js +2 -2
- package/dist/blocks/sla/index.d.ts +1 -1
- package/dist/blocks/sla/index.js +7 -8
- package/dist/blocks/sso/index.d.ts +1 -1
- package/dist/blocks/sso/index.js +2 -3
- package/dist/blocks/state-machine/index.d.ts +1 -1
- package/dist/blocks/state-machine/index.js +3 -3
- package/dist/blocks/subjects/index.d.ts +2 -2
- package/dist/blocks/subjects/index.js +3 -4
- package/dist/blocks/tags/index.d.ts +2 -2
- package/dist/blocks/tags/index.js +6 -6
- package/dist/blocks/tasks/index.d.ts +2 -2
- package/dist/blocks/tasks/index.js +7 -8
- package/dist/blocks/teams/index.d.ts +1 -1
- package/dist/blocks/teams/index.js +3 -3
- package/dist/blocks/templates/index.d.ts +3 -3
- package/dist/blocks/templates/index.js +3 -4
- package/dist/blocks/time-tracking/index.d.ts +8 -1
- package/dist/blocks/time-tracking/index.js +9 -10
- package/dist/blocks/timeline/index.d.ts +3 -3
- package/dist/blocks/timeline/index.js +4 -5
- package/dist/blocks/trash/index.d.ts +1 -1
- package/dist/blocks/trash/index.js +3 -4
- package/dist/blocks/undo/index.d.ts +2 -2
- package/dist/blocks/undo/index.js +2 -2
- package/dist/blocks/updated-at/index.d.ts +1 -1
- package/dist/blocks/usage/index.d.ts +2 -2
- package/dist/blocks/usage/index.js +2 -3
- package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
- package/dist/blocks/vercel-marketplace/index.js +3 -4
- package/dist/blocks/versions/index.d.ts +1 -1
- package/dist/blocks/versions/index.js +6 -7
- package/dist/blocks/waitlist/index.d.ts +1 -1
- package/dist/blocks/waitlist/index.js +4 -5
- package/dist/blocks/webhooks/index.d.ts +3 -3
- package/dist/blocks/webhooks/index.js +13 -14
- package/dist/blocks/workflow-editor/index.d.ts +6 -6
- package/dist/blocks/workflow-editor/index.js +10 -11
- package/dist/blocks/workflows/index.d.ts +4 -4
- package/dist/blocks/workflows/index.js +5 -6
- package/dist/{bookings-Dox2rced.d.ts → bookings-BpCNphYp.d.ts} +1 -2
- package/dist/{build-D9lWi5bk.js → build-CH2N3Yf0.js} +4 -4
- package/dist/{build-BFC8nFiL.js → build-DbIRFcHQ.js} +3 -65
- package/dist/chat-sdk/index.js +2 -3
- package/dist/cli/{add-CH7dC6UR.js → add-B6CQOt3A.js} +2 -2
- package/dist/cli/{add-CtLjnwds.js → add-BXFzr0Wf.js} +9 -9
- package/dist/cli/add-w_HumDPX.js +1 -0
- package/dist/cli/{backfill-DBJIMzcy.js → backfill-Dflp6JZk.js} +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cli/{blocks-i1w0EEvs.js → blocks-CBH3N7Fy.js} +1 -1
- package/dist/cli/{blocks-CS58-xnw.js → blocks-FtOIcUbu.js} +1 -1
- package/dist/cli/{cache-Cn3crN0v.js → cache-61VwYKEv.js} +1 -1
- package/dist/cli/{codemod-D6wifOAH.js → codemod-CqPRa25J.js} +1 -1
- package/dist/cli/{content-mapper-Q9We297z.js → content-mapper-DGQQY5IA.js} +2 -2
- package/dist/cli/{doctor-DmfdE5Ct.js → doctor-BxxSO193.js} +62 -58
- package/dist/cli/{gen-D68A0uN8.js → gen-D2cqqqTH.js} +11 -11
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +6 -6
- package/dist/cli/{init-N7pkBbJn.js → init-BnG1IE1y.js} +5 -5
- package/dist/cli/{live-0xAAlTK_.js → live-D26OWOAb.js} +2 -2
- package/dist/cli/{mcp-CbN3ulRF.js → mcp-1l3C_GdB.js} +2 -2
- package/dist/cli/{metadata-417ldpf4.js → metadata-DDfPBHwI.js} +3 -3
- package/dist/cli/{migration-safety-BC_UI4jC.js → migration-safety-CQbrfZIx.js} +1 -1
- package/dist/cli/{migrations-DdBKwrvG.js → migrations-Ch5Uuvyj.js} +1 -1
- package/dist/cli/{module-migration-DdxPdqMC.js → module-migration-Dul1uTYX.js} +2 -2
- package/dist/cli/{powersync-CJTEz-uY.js → powersync-CfT-tRx1.js} +2 -2
- package/dist/cli/powersync-Vmhw5c1N.js +1 -0
- package/dist/cli/{print-DyFm91R-.js → print-CbPT4PTL.js} +2 -2
- package/dist/cli/{remove-CPY0xsVm.js → remove-kDH1yxKZ.js} +5 -5
- package/dist/cli/{render-DE3O1OFq.js → render-0Vd7BaNA.js} +22 -5
- package/dist/cli/{run-WtIEFGvP.js → run-Dafms0D2.js} +8 -8
- package/dist/cli/{run-CcrNGX9C.js → run-DxTd55Ug.js} +21 -21
- package/dist/cli/{shared-SlukBuKn.js → shared-BQAMXvwd.js} +1 -1
- package/dist/cli/{snapshot-pyIsJjUV.js → snapshot-B8K6gYjA.js} +2 -2
- package/dist/cli/{source-Bclt9D0Y.js → source-CXDyCWz5.js} +1 -1
- package/dist/cli/{spec-D7zsEVj_.js → spec-BGsnTkIl.js} +2 -2
- package/dist/cli/{spec-BsdLx7tZ.js → spec-CaN7nOqI.js} +1 -1
- package/dist/cli/{sql-layout-C6baAM5t.js → sql-layout-BGAlcp1U.js} +2 -2
- package/dist/cli/{sync-Cse8VXAU.js → sync-CT_5VG0E.js} +3 -3
- package/dist/cli/{upgrade-28ENjIJU.js → upgrade-DA7aO88E.js} +2 -2
- package/dist/cli/{upgrade-Cwc1RiAE.js → upgrade-frUtPDDb.js} +4 -4
- package/dist/cli/{version-yWIaLG04.js → version-CUdPyV6J.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 +4 -4
- package/dist/client/native/index.js +1 -1
- package/dist/{codecs-BfmQSbM6.js → codecs-CSUFGrdP.js} +3 -3
- package/dist/commerce/index.js +3 -3
- package/dist/{composite-D24L5RIY.js → composite-CBRbvn5j.js} +2 -2
- package/dist/{composite-DbRuu6Jb.d.ts → composite-ChzHhSB0.d.ts} +3 -3
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +5 -5
- package/dist/{config-CD2OGfCG.js → config-C9AOcQ9S.js} +1 -1
- package/dist/{config-D74JT0qL.js → config-CH-D2B-4.js} +4 -4
- package/dist/{context-CjHXhCck.d.ts → context-DEisra3V.d.ts} +19 -7
- package/dist/{controller-BeqcjERs.d.ts → controller-B6vWdKSa.d.ts} +1 -1
- package/dist/{controller-BNZKd6bJ.js → controller-qG-B1eDn.js} +1 -1
- package/dist/{conversion-BqDvi8ty.d.ts → conversion-DBgMck5U.d.ts} +1 -1
- package/dist/create/index.d.ts +72 -451
- package/dist/create/index.js +15 -1687
- package/dist/create/lite/index.d.ts +250 -13
- package/dist/create/lite/index.js +1007 -24
- package/dist/{create-blocks-0pWKQ6x4.js → create-blocks-BfrDUSM6.js} +14 -10
- package/dist/credentials/index.js +3 -4
- package/dist/{cron-CgHTKwYG.js → cron-DdT4ti8a.js} +1 -1
- package/dist/{cron-route-UU9i5i9J.js → cron-route-FjKgRvTY.js} +1 -1
- package/dist/{deal-forecast-DikouYGj.js → deal-forecast-CKBnRodz.js} +2 -2
- package/dist/{define-Djgn3HQQ.js → define-D-dLADd5.js} +16 -19
- package/dist/{define-BqaUwrIC.d.ts → define-Lf6rI2QN.d.ts} +14 -8
- package/dist/{define-block-CRwHsxZO.d.ts → define-block-DCAiOrNX.d.ts} +12 -3
- package/dist/edge/index.d.ts +5 -5
- package/dist/edge/index.js +7 -7
- package/dist/elysia/index.js +1 -1
- package/dist/{entitlements-mDz7GfA_.d.ts → entitlements-BPaPd3MD.d.ts} +1 -1
- package/dist/{entitlements-DBir2qwB.js → entitlements-tGL6-69B.js} +2 -2
- package/dist/{entity-schema-BDv6w-OQ.js → entity-schema-B1YmMtP8.js} +1 -1
- package/dist/events/index.js +3 -3
- package/dist/{executor-3qcMhg6R.js → executor-C2Ne-Scm.js} +3 -2
- package/dist/{executor-Bi056Cnj.d.ts → executor-DNK401lZ.d.ts} +1 -1
- package/dist/{executor-D3gB-9si.js → executor-DqIci3Jb.js} +3 -3
- package/dist/{executor-BQ7dYw4E.js → executor-WolvKszH.js} +3 -3
- package/dist/{executor-_O-CqCPl.d.ts → executor-aFV7nEBs.d.ts} +2 -2
- package/dist/expo/index.d.ts +2 -2
- package/dist/expo/index.js +3 -3
- package/dist/{field-errors-Cfvcg-C3.d.ts → field-errors-DBgDCITw.d.ts} +6 -6
- package/dist/{fields--5a88KJe.js → fields-BBm49w-E.js} +1 -1
- package/dist/{filter-evaluate-w1XOIUOL.js → filter-evaluate-lCToXzZI.js} +2 -2
- package/dist/{filter-query-DMoKo82_.js → filter-query-CQ6d5GnQ.js} +1 -1
- package/dist/{flags-ClOQY-p5.js → flags-DF_SCqp5.js} +1 -1
- package/dist/flags-sdk/index.js +2 -2
- package/dist/{framework-B-1Ka0GW.d.ts → framework-DKA3fTHl.d.ts} +3 -3
- package/dist/{framework-CNhTg0th.js → framework-DYEUraqt.js} +1 -1
- package/dist/h3/index.js +1 -1
- package/dist/h3/v1/index.js +1 -1
- package/dist/hono/index.d.ts +4 -4
- package/dist/hono/index.js +6 -6
- package/dist/{index-CjnDGAJr.d.ts → index-3p_oWttZ.d.ts} +77 -2
- package/dist/{index-BzW1T3oI.d.ts → index-ByF22_C6.d.ts} +3 -3
- package/dist/{index-BdzfjFnd.d.ts → index-C4sjewrr.d.ts} +9 -9
- package/dist/{index-CYzckGOz.d.ts → index-CM2aGNRo.d.ts} +9 -5
- package/dist/{index-DfgP-9eC.d.ts → index-CdMZQCYR.d.ts} +3 -3
- package/dist/{index-EieRHooI.d.ts → index-ClvuSZEz.d.ts} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -7
- package/dist/{app-tables-DyswUg6J.js → instances-CK0jR3Pc.js} +147 -3
- package/dist/{json-schema-Ca6gYbEP.js → json-schema-DHJxiizN.js} +1 -1
- package/dist/{kit-DhlB-vv_.js → kit-Bcd9wYCV.js} +1 -1
- package/dist/{knowledge-CV6OSirC.js → knowledge-tCrrU99q.js} +2 -2
- package/dist/list/index.d.ts +1 -1
- package/dist/list/index.js +3 -3
- package/dist/{list-query-BKy2zBaT.js → list-query-BnpA2BDg.js} +1 -1
- package/dist/{list-query-6vTI1VN6.d.ts → list-query-XYfUZb0j.d.ts} +1 -1
- package/dist/mapper/bin.js +5 -5
- package/dist/mcp/index.d.ts +4 -4
- package/dist/mcp/index.js +7 -7
- package/dist/mcp/sdk/index.d.ts +2 -2
- package/dist/mcp/sdk/index.js +2 -2
- package/dist/{messages-D4XWuRTj.js → messages-ecPW_nOv.js} +1 -1
- package/dist/{model-messages-CKG0zwdF.js → model-messages-CkZSDDHP.js} +1 -1
- package/dist/{money-codec-uV5WbT60.js → money-codec-BJuS2zEW.js} +1 -1
- package/dist/nestjs/index.js +1 -1
- package/dist/next/index.d.ts +14 -14
- package/dist/next/index.js +8 -8
- package/dist/node/index.js +1 -1
- package/dist/{operations-DbNAgo7E.d.ts → operations-DC3wU3Sy.d.ts} +1 -1
- package/dist/orpc/index.d.ts +4 -4
- package/dist/orpc/index.js +5 -5
- package/dist/otel/index.js +5 -5
- package/dist/{ports-DO3tgLTo.d.ts → ports-BbBJVyS0.d.ts} +1 -1
- package/dist/{ports-CaVRXjxq.js → ports-DvpNseap.js} +1 -1
- package/dist/postgres/index.js +5 -4
- package/dist/{postgrest-executor-BFW4oWte.js → postgrest-executor-B_Uezhrm.js} +7 -3
- package/dist/powersync/index.d.ts +3 -3
- package/dist/powersync/index.js +1 -1
- package/dist/preset/index.d.ts +4 -4
- package/dist/preset/index.js +4 -4
- package/dist/{preset-B3CukUhu.js → preset-CS490mYJ.js} +179 -7
- package/dist/project-NmP1NdLi.js +1760 -0
- package/dist/{push-token-IFGi8jvd.d.ts → push-token-CPJfPFa2.d.ts} +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/query/index.js +1 -1
- package/dist/{rate-limit-BPuUWz4U.js → rate-limit-fZ_d8gSE.js} +4 -5
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.js +2 -2
- package/dist/react/native/index.d.ts +1 -1
- package/dist/react/server.d.ts +6 -6
- package/dist/react/server.js +2 -2
- package/dist/{react-D-p70_wL.js → react-CcrQQl0_.js} +4 -4
- package/dist/react-router/index.d.ts +3 -3
- package/dist/react-router/index.js +5 -5
- package/dist/{read-set-BnKnofIj.js → read-set-B1sDib5O.js} +1 -1
- package/dist/realtime/index.d.ts +3 -3
- package/dist/realtime/index.js +2 -2
- package/dist/{record-bindings-DkBJpC5A.js → record-bindings-Z51mGfhB.js} +1 -1
- package/dist/{record-form-yMVvkPiQ.d.ts → record-form-BbZpwsEi.d.ts} +1 -1
- package/dist/records/index.d.ts +7 -7
- package/dist/records/index.js +3 -3
- package/dist/{refusal-D48CMqpQ.js → refusal-DDlInPff.js} +2 -2
- package/dist/{instances-DDt7NdVl.js → resolved-names-DdlJzoMK.js} +2 -146
- package/dist/{resource-R3KToNze.js → resource-BUJcZKiW.js} +2 -2
- package/dist/{resource-execute-LR71zWej.d.ts → resource-execute-CUG6xUuh.d.ts} +1 -1
- package/dist/{resource-types-eXuFxVt7.d.ts → resource-types-DjZ91WKA.d.ts} +1 -1
- package/dist/{resources-Dpz3h8Fe.d.ts → resources-6Ncdt9XT.d.ts} +1 -1
- package/dist/{resources-DqIwoQsP.js → resources-jb3R6rEa.js} +1 -1
- package/dist/{rows-EGAbu7MG.js → rows-BdqXmiB-.js} +2 -2
- package/dist/{rows-Bh9QemqN.js → rows-jijHLVE_.js} +1 -1
- package/dist/{rrule-79K2c3Nr.js → rrule-C9Ot6ax8.js} +1 -1
- package/dist/{sales-lines-CP4Z_LyE.js → sales-lines-DO7oRu1o.js} +3 -3
- package/dist/{sales-shared-BKXXA5qV.js → sales-shared-BuTA8JK7.js} +2 -2
- package/dist/{schemas-BSTNfGsQ.js → schemas-CLOTvdsC.js} +1 -1
- package/dist/{scores-CsgM-dw7.js → scores-bY2Is0kx.js} +2 -2
- package/dist/server/index.d.ts +7 -7
- package/dist/server/index.js +9 -9
- package/dist/{server-types-BTBzrzOH.d.ts → server-types-BH6AjDBN.d.ts} +1 -1
- package/dist/{session-BgYGk_FS.d.ts → session-Y5SSYO2C.d.ts} +1 -1
- package/dist/{shared-C47zAh2A.js → shared-BeHTi8Fu.js} +1 -1
- package/dist/{sign-in-BTaRWS-L.js → sign-in-NO7LWlw4.js} +5 -5
- package/dist/{signatures-CNcoq392.js → signatures-CX1b4WHa.js} +2 -2
- package/dist/{signers-BAEzvTJ0.d.ts → signers-BKgmVh6A.d.ts} +2 -2
- package/dist/{signing-keys-DqI-gB_C.js → signing-keys-CWtpMask.js} +3 -3
- package/dist/solid/index.d.ts +6 -6
- package/dist/solid/index.js +1 -1
- package/dist/solid-start/index.d.ts +3 -3
- package/dist/solid-start/index.js +5 -5
- package/dist/spec/index.d.ts +2 -2
- package/dist/spec/index.js +2 -693
- package/dist/{spec-DTWkHzYZ.js → spec-BMvCCNnd.js} +1 -1
- package/dist/sql/index.d.ts +4 -4
- package/dist/sql/index.js +2 -2
- package/dist/{sql-B0wb7XA5.js → sql-BMXEHTvr.js} +9685 -6254
- package/dist/{sql-BPbbPzRJ.js → sql-CYt7EhH0.js} +2 -2
- package/dist/sqlite/index.d.ts +1 -1
- package/dist/sqlite/index.js +1 -1
- package/dist/{sso-Co2TbnEy.js → sso-DdDpJQzw.js} +2 -2
- package/dist/ssr/index.d.ts +1 -1
- package/dist/storage/index.js +3 -3
- package/dist/streams/index.js +1 -2
- package/dist/{subject-readers-F1xvRY-d.js → subject-readers-CeeJJOQ4.js} +1 -1
- package/dist/svelte/index.d.ts +6 -6
- package/dist/svelte/index.js +1 -1
- package/dist/sveltekit/index.d.ts +4 -4
- package/dist/sveltekit/index.js +5 -5
- package/dist/{table-schema-CD8cJz_M.js → table-schema-C80xItaV.js} +1 -1
- package/dist/{tags-CXeJu332.d.ts → tags-Cjtcp5cN.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 +5 -5
- package/dist/{temporal-DLZlWbOi.js → temporal-Dbo0fLzc.js} +12 -2
- package/dist/{temporal-required-Dy0GGD8E.js → temporal-required-DcLhnDhQ.js} +1 -1
- package/dist/{tenant-DzymQ9sv.d.ts → tenant-BHvMFNXl.d.ts} +1 -1
- package/dist/testing/index.d.ts +10 -10
- package/dist/testing/index.js +10 -10
- package/dist/{timeline-BMVOKokJ.d.ts → timeline-CEzj9v1z.d.ts} +3 -3
- package/dist/{topic-0uK4db_2.d.ts → topic-gTVjLGTk.d.ts} +2 -2
- package/dist/types-BC1HLEVx.d.ts +461 -0
- package/dist/{types-DsRfiQ0v.d.ts → types-yj8VF4oY.d.ts} +5 -0
- package/dist/{undo-B3FQvuAd.js → undo-BbftL9-4.js} +2 -2
- package/dist/vercel-connect/index.js +1 -1
- package/dist/{verify-ZLFUdlqE.js → verify-7EucfCnv.js} +3 -3
- package/dist/{verify-DexkIx4t.d.ts → verify-B0KLBb3j.d.ts} +1 -1
- package/dist/vue/index.d.ts +6 -6
- package/dist/vue/index.js +1 -1
- package/dist/{watch-topic-CG3kOX-D.d.ts → watch-topic-C6HhbnVz.d.ts} +1 -1
- package/dist/wire-ChYn1g21.js +91 -0
- package/dist/workflow-sdk/builder/index.d.ts +2 -2
- package/dist/workflow-sdk/builder/index.js +1 -1
- package/dist/workflow-sdk/world/index.js +1 -1
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/index.js +1 -1
- package/package.json +1 -1
- package/skills/better-supabase/references/ui-recipes.md +1 -1
- package/dist/block-transport-PNea4lfQ.js +0 -84
- package/dist/cli/add-DyCrVejx.js +0 -1
- package/dist/cli/powersync-CYQ4Ljcz.js +0 -1
- package/dist/types-DGHfTW8_.d.ts +0 -9
- package/dist/{data-hooks-tgF1Ct0F.js → data-hooks-CdcZfVS1.js} +1 -1
- package/dist/{respond-3RKp6VgU.js → respond-CZMWbUs3.js} +1 -1
- package/dist/{topic-DXbA-jwr.js → topic-DClSoqY7.js} +2 -2
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
import { r as isPlainObject } from "./clone-CkG0-hlI.js";
|
|
2
|
+
import { t as SPEC_PINS } from "./spec-pins-D3zDek-u.js";
|
|
3
|
+
import { d as mergeJson, f as pointerToken, n as publishedResources, o as publishedBlocks, t as buildApiModel, u as pascal } from "./build-CH2N3Yf0.js";
|
|
4
|
+
//#region src/spec/format.ts
|
|
5
|
+
/**
|
|
6
|
+
* Identity helper that fixes `apiVersion` and checks that the default version
|
|
7
|
+
* exists.
|
|
8
|
+
*/
|
|
9
|
+
function defineDocumentFormat(format) {
|
|
10
|
+
if (!Object.hasOwn(format.versions, format.defaultVersion)) throw new TypeError(`Document format "${format.id}": the default version "${format.defaultVersion}" is not in versions`);
|
|
11
|
+
if (format.versions[format.defaultVersion].status === "preview") throw new TypeError(`Document format "${format.id}": a preview version cannot be the default`);
|
|
12
|
+
return {
|
|
13
|
+
...format,
|
|
14
|
+
apiVersion: 1
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/openapi/schema30.ts
|
|
19
|
+
/** Keywords whose value is one subschema. */
|
|
20
|
+
const SINGLE = /* @__PURE__ */ new Set([
|
|
21
|
+
"items",
|
|
22
|
+
"additionalProperties",
|
|
23
|
+
"not"
|
|
24
|
+
]);
|
|
25
|
+
/** Keywords whose value is a list of subschemas. */
|
|
26
|
+
const LISTS = /* @__PURE__ */ new Set([
|
|
27
|
+
"allOf",
|
|
28
|
+
"anyOf",
|
|
29
|
+
"oneOf"
|
|
30
|
+
]);
|
|
31
|
+
/** 2020-12 keywords the OpenAPI 3.0 Schema Object does not have. */
|
|
32
|
+
const DROPPED = /* @__PURE__ */ new Set([
|
|
33
|
+
"$schema",
|
|
34
|
+
"$id",
|
|
35
|
+
"$anchor",
|
|
36
|
+
"$dynamicAnchor",
|
|
37
|
+
"$dynamicRef",
|
|
38
|
+
"$comment",
|
|
39
|
+
"$defs",
|
|
40
|
+
"$vocabulary",
|
|
41
|
+
"prefixItems",
|
|
42
|
+
"contains",
|
|
43
|
+
"minContains",
|
|
44
|
+
"maxContains",
|
|
45
|
+
"propertyNames",
|
|
46
|
+
"patternProperties",
|
|
47
|
+
"dependentRequired",
|
|
48
|
+
"dependentSchemas",
|
|
49
|
+
"unevaluatedItems",
|
|
50
|
+
"unevaluatedProperties",
|
|
51
|
+
"if",
|
|
52
|
+
"then",
|
|
53
|
+
"else",
|
|
54
|
+
"contentMediaType",
|
|
55
|
+
"contentSchema"
|
|
56
|
+
]);
|
|
57
|
+
const isNullSchema = (value) => isPlainObject(value) && value["type"] === "null" && Object.keys(value).length === 1;
|
|
58
|
+
/**
|
|
59
|
+
* Rewrites a JSON Schema 2020-12 schema into the OpenAPI 3.0 Schema Object:
|
|
60
|
+
* `null` in `type` or in an `anyOf`/`oneOf` becomes `nullable`, a type list
|
|
61
|
+
* becomes `anyOf`, `const` becomes a one-value `enum`, `examples` becomes
|
|
62
|
+
* `example`, numeric `exclusiveMinimum`/`exclusiveMaximum` become the boolean
|
|
63
|
+
* form, `contentEncoding: base64` becomes `format: byte`, and a `$ref` with
|
|
64
|
+
* siblings is wrapped in `allOf`. Keywords 3.0 does not have are left out. The
|
|
65
|
+
* input is not changed.
|
|
66
|
+
*/
|
|
67
|
+
function toOpenApi30Schema(schema) {
|
|
68
|
+
const out = {};
|
|
69
|
+
let nullable = false;
|
|
70
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
71
|
+
if (DROPPED.has(key)) continue;
|
|
72
|
+
if (key === "properties" && isPlainObject(value)) out[key] = Object.fromEntries(Object.entries(value).map(([name, child]) => [name, isPlainObject(child) ? toOpenApi30Schema(child) : child]));
|
|
73
|
+
else if (SINGLE.has(key) && isPlainObject(value)) out[key] = toOpenApi30Schema(value);
|
|
74
|
+
else if (LISTS.has(key) && Array.isArray(value)) {
|
|
75
|
+
const branches = value;
|
|
76
|
+
const rest = branches.filter((branch) => !isNullSchema(branch));
|
|
77
|
+
if (key !== "allOf" && rest.length < branches.length) nullable = true;
|
|
78
|
+
out[key] = rest.map((branch) => isPlainObject(branch) ? toOpenApi30Schema(branch) : branch);
|
|
79
|
+
} else if (key === "examples" && Array.isArray(value)) {
|
|
80
|
+
if (value.length > 0) out["example"] = value[0];
|
|
81
|
+
} else if ((key === "exclusiveMinimum" || key === "exclusiveMaximum") && typeof value === "number") {
|
|
82
|
+
out[key === "exclusiveMinimum" ? "minimum" : "maximum"] = value;
|
|
83
|
+
out[key] = true;
|
|
84
|
+
} else if (key === "const") out["enum"] = [value];
|
|
85
|
+
else if (key === "contentEncoding") {
|
|
86
|
+
if (value === "base64" && schema["format"] === void 0) out["format"] = "byte";
|
|
87
|
+
} else if (key === "type" && Array.isArray(value)) {
|
|
88
|
+
const types = value;
|
|
89
|
+
const rest = types.filter((type) => type !== "null");
|
|
90
|
+
if (rest.length < types.length) nullable = true;
|
|
91
|
+
if (rest.length === 1) out["type"] = rest[0];
|
|
92
|
+
else if (rest.length > 1) out["anyOf"] = rest.map((type) => ({ type }));
|
|
93
|
+
} else if (key === "type" && value === "null") {
|
|
94
|
+
nullable = true;
|
|
95
|
+
out["enum"] = [null];
|
|
96
|
+
} else out[key] = value;
|
|
97
|
+
}
|
|
98
|
+
for (const key of ["anyOf", "oneOf"]) {
|
|
99
|
+
const branches = out[key];
|
|
100
|
+
if (!Array.isArray(branches) || branches.length !== 1) continue;
|
|
101
|
+
const only = branches[0];
|
|
102
|
+
if (!isPlainObject(only)) continue;
|
|
103
|
+
delete out[key];
|
|
104
|
+
if (typeof only["$ref"] === "string") out["allOf"] = [only];
|
|
105
|
+
else for (const [name, entry] of Object.entries(only)) if (!(name in out)) out[name] = entry;
|
|
106
|
+
}
|
|
107
|
+
if (typeof out["$ref"] === "string" && Object.keys(out).length > 1) {
|
|
108
|
+
const { $ref, ...siblings } = out;
|
|
109
|
+
return {
|
|
110
|
+
allOf: [{ $ref }],
|
|
111
|
+
...siblings,
|
|
112
|
+
...nullable ? { nullable: true } : {}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
if (nullable) {
|
|
116
|
+
if (typeof out["$ref"] === "string") return {
|
|
117
|
+
allOf: [{ $ref: out["$ref"] }],
|
|
118
|
+
nullable: true
|
|
119
|
+
};
|
|
120
|
+
out["nullable"] = true;
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
const mapEntries = (value, convert) => isPlainObject(value) ? Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, isPlainObject(entry) ? convert(entry) : entry])) : value;
|
|
125
|
+
const withSchema = (holder) => {
|
|
126
|
+
const out = { ...holder };
|
|
127
|
+
for (const key of ["schema", "x-oai-itemSchema"]) {
|
|
128
|
+
const schema = out[key];
|
|
129
|
+
if (isPlainObject(schema)) out[key] = toOpenApi30Schema(schema);
|
|
130
|
+
}
|
|
131
|
+
if (isPlainObject(out["content"])) out["content"] = mapEntries(out["content"], withSchema);
|
|
132
|
+
if (isPlainObject(out["headers"])) out["headers"] = mapEntries(out["headers"], withSchema);
|
|
133
|
+
return out;
|
|
134
|
+
};
|
|
135
|
+
const lowerParameters = (value) => Array.isArray(value) ? value.map((entry) => isPlainObject(entry) ? withSchema(entry) : entry) : value;
|
|
136
|
+
const lowerOperation$1 = (operation) => {
|
|
137
|
+
const out = { ...operation };
|
|
138
|
+
out["parameters"] = lowerParameters(out["parameters"]);
|
|
139
|
+
if (out["parameters"] === void 0) delete out["parameters"];
|
|
140
|
+
if (isPlainObject(out["requestBody"])) out["requestBody"] = withSchema(out["requestBody"]);
|
|
141
|
+
if (isPlainObject(out["responses"])) out["responses"] = mapEntries(out["responses"], withSchema);
|
|
142
|
+
return out;
|
|
143
|
+
};
|
|
144
|
+
const PATH_ITEM_LISTS = /* @__PURE__ */ new Set(["parameters"]);
|
|
145
|
+
const lowerPathItem = (item) => {
|
|
146
|
+
const out = {};
|
|
147
|
+
for (const [key, value] of Object.entries(item)) if (PATH_ITEM_LISTS.has(key)) out[key] = lowerParameters(value);
|
|
148
|
+
else if (isPlainObject(value) && !key.startsWith("x-") && key !== "servers") out[key] = lowerOperation$1(value);
|
|
149
|
+
else out[key] = value;
|
|
150
|
+
return out;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Lowers every Schema Object position of an OpenAPI document to the 3.0
|
|
154
|
+
* dialect.
|
|
155
|
+
*/
|
|
156
|
+
function lowerDocumentSchemas30(document) {
|
|
157
|
+
const out = { ...document };
|
|
158
|
+
if (isPlainObject(out["paths"])) out["paths"] = mapEntries(out["paths"], lowerPathItem);
|
|
159
|
+
const components = out["components"];
|
|
160
|
+
if (isPlainObject(components)) {
|
|
161
|
+
const lowered = {
|
|
162
|
+
...components,
|
|
163
|
+
schemas: mapEntries(components["schemas"], toOpenApi30Schema)
|
|
164
|
+
};
|
|
165
|
+
for (const key of [
|
|
166
|
+
"responses",
|
|
167
|
+
"parameters",
|
|
168
|
+
"requestBodies",
|
|
169
|
+
"headers"
|
|
170
|
+
]) if (isPlainObject(components[key])) lowered[key] = mapEntries(components[key], withSchema);
|
|
171
|
+
if (lowered["schemas"] === void 0) delete lowered["schemas"];
|
|
172
|
+
out["components"] = lowered;
|
|
173
|
+
}
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/openapi/types.ts
|
|
178
|
+
/** The `openapi` field `3.3-preview` emits, as in the v3.3-dev branch. */
|
|
179
|
+
const OPENAPI_33_PREVIEW_VERSION = "3.3.0";
|
|
180
|
+
/** The file name `openapiFormat` writes for every version. */
|
|
181
|
+
const OPENAPI_FILE_NAME = "openapi.json";
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/openapi/format.ts
|
|
184
|
+
const DIALECT = "https://json-schema.org/draft/2020-12/schema";
|
|
185
|
+
const OPENAPI_FIELD = {
|
|
186
|
+
"3.0": SPEC_PINS.openapi30,
|
|
187
|
+
"3.1": SPEC_PINS.openapi31,
|
|
188
|
+
"3.2": SPEC_PINS.openapi32,
|
|
189
|
+
"3.3-preview": OPENAPI_33_PREVIEW_VERSION
|
|
190
|
+
};
|
|
191
|
+
/** Path Item fields that hold an Operation Object. */
|
|
192
|
+
const METHODS = /* @__PURE__ */ new Set([
|
|
193
|
+
"get",
|
|
194
|
+
"put",
|
|
195
|
+
"post",
|
|
196
|
+
"delete",
|
|
197
|
+
"options",
|
|
198
|
+
"head",
|
|
199
|
+
"patch",
|
|
200
|
+
"trace",
|
|
201
|
+
"query"
|
|
202
|
+
]);
|
|
203
|
+
const omitUndefined = (value) => Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
|
|
204
|
+
function lowerContent(content, features) {
|
|
205
|
+
return Object.fromEntries(Object.entries(content).map(([type, media]) => [type, omitUndefined({
|
|
206
|
+
schema: media.schema,
|
|
207
|
+
[features.native32 ? "itemSchema" : "x-oai-itemSchema"]: media.itemSchema,
|
|
208
|
+
examples: media.examples ? Object.fromEntries(Object.entries(media.examples).map(([name, example]) => [name, omitUndefined({ ...example })])) : void 0
|
|
209
|
+
})]));
|
|
210
|
+
}
|
|
211
|
+
function lowerResponse(response, features) {
|
|
212
|
+
return omitUndefined({
|
|
213
|
+
[features.native32 ? "summary" : "x-oai-summary"]: response.summary,
|
|
214
|
+
description: response.description,
|
|
215
|
+
headers: response.headers ? Object.fromEntries(Object.entries(response.headers).map(([name, header]) => [name, omitUndefined({ ...header })])) : void 0,
|
|
216
|
+
content: response.content ? lowerContent(response.content, features) : void 0
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const lowerResponseOrRef = (response, features) => "ref" in response ? { $ref: `#/components/responses/${response.ref}` } : lowerResponse(response, features);
|
|
220
|
+
const lowerParameter = (parameter) => omitUndefined({ ...parameter });
|
|
221
|
+
function lowerSecurity(requirements, features) {
|
|
222
|
+
return requirements.filter((requirement) => Object.keys(requirement).every((name) => !features.dropped.has(name))).map((requirement) => ({ ...requirement }));
|
|
223
|
+
}
|
|
224
|
+
function lowerScheme(scheme, features) {
|
|
225
|
+
switch (scheme.type) {
|
|
226
|
+
case "http":
|
|
227
|
+
case "apiKey":
|
|
228
|
+
case "openIdConnect": return omitUndefined({ ...scheme });
|
|
229
|
+
case "oauth2": {
|
|
230
|
+
const { metadataUrl, ...rest } = scheme;
|
|
231
|
+
return omitUndefined({
|
|
232
|
+
...rest,
|
|
233
|
+
[features.native32 ? "oauth2MetadataUrl" : `${features.prefix}oauth2MetadataUrl`]: metadataUrl
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
case "profile": return features.is33 ? omitUndefined({ ...scheme }) : void 0;
|
|
237
|
+
default: return scheme;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function lowerOperation(operation, features) {
|
|
241
|
+
return omitUndefined({
|
|
242
|
+
operationId: operation.id,
|
|
243
|
+
summary: operation.summary,
|
|
244
|
+
description: operation.description,
|
|
245
|
+
tags: operation.tags.length > 0 ? [...operation.tags] : void 0,
|
|
246
|
+
deprecated: operation.deprecated,
|
|
247
|
+
parameters: operation.parameters.length > 0 ? operation.parameters.map(lowerParameter) : void 0,
|
|
248
|
+
requestBody: operation.requestBody ? omitUndefined({
|
|
249
|
+
description: operation.requestBody.description,
|
|
250
|
+
required: operation.requestBody.required,
|
|
251
|
+
content: lowerContent(operation.requestBody.content, features)
|
|
252
|
+
}) : void 0,
|
|
253
|
+
responses: Object.fromEntries(Object.entries(operation.responses).map(([status, response]) => [status, lowerResponseOrRef(response, features)])),
|
|
254
|
+
servers: operation.servers ? lowerServers(operation.servers, features) : void 0,
|
|
255
|
+
security: operation.security ? lowerSecurity(operation.security, features) : void 0,
|
|
256
|
+
...operation.extensions
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function lowerServers(servers, features) {
|
|
260
|
+
return servers.length > 0 ? servers.map((server) => omitUndefined({
|
|
261
|
+
url: server.url,
|
|
262
|
+
description: server.description,
|
|
263
|
+
[features.native32 ? "name" : "x-oai-name"]: server.name
|
|
264
|
+
})) : void 0;
|
|
265
|
+
}
|
|
266
|
+
const sameJson = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
267
|
+
/**
|
|
268
|
+
* Builds one Path Item. Path parameters every operation shares move to the Path
|
|
269
|
+
* Item; in 3.3 a `security` every operation shares does too.
|
|
270
|
+
*/
|
|
271
|
+
function pathItem(operations, features) {
|
|
272
|
+
const pathParameters = (operation) => Array.isArray(operation["parameters"]) ? operation["parameters"].filter((parameter) => isPlainObject(parameter) && parameter["in"] === "path") : [];
|
|
273
|
+
const first = operations[0];
|
|
274
|
+
const shared = first ? pathParameters(first.operation) : [];
|
|
275
|
+
const hoist = shared.length > 0 && operations.every(({ operation }) => sameJson(pathParameters(operation), shared));
|
|
276
|
+
const firstSecurity = first?.operation["security"];
|
|
277
|
+
const hoistSecurity = features.is33 && firstSecurity !== void 0 && operations.every(({ operation }) => sameJson(operation["security"], firstSecurity));
|
|
278
|
+
const item = {};
|
|
279
|
+
if (hoist) item["parameters"] = shared;
|
|
280
|
+
if (hoistSecurity) item["security"] = firstSecurity;
|
|
281
|
+
for (const { method, operation } of operations) {
|
|
282
|
+
const out = { ...operation };
|
|
283
|
+
if (hoist) {
|
|
284
|
+
const rest = Array.isArray(out["parameters"]) ? out["parameters"].filter((parameter) => !isPlainObject(parameter) || parameter["in"] !== "path") : [];
|
|
285
|
+
if (rest.length > 0) out["parameters"] = rest;
|
|
286
|
+
else delete out["parameters"];
|
|
287
|
+
}
|
|
288
|
+
if (hoistSecurity) delete out["security"];
|
|
289
|
+
item[method] = out;
|
|
290
|
+
}
|
|
291
|
+
return item;
|
|
292
|
+
}
|
|
293
|
+
const STANDARD_WEBHOOK_HEADERS = [
|
|
294
|
+
{
|
|
295
|
+
name: "webhook-id",
|
|
296
|
+
in: "header",
|
|
297
|
+
required: true,
|
|
298
|
+
description: "Unique message id; the same on every retry.",
|
|
299
|
+
schema: { type: "string" }
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: "webhook-timestamp",
|
|
303
|
+
in: "header",
|
|
304
|
+
required: true,
|
|
305
|
+
description: "Unix time in seconds when the message was sent.",
|
|
306
|
+
schema: {
|
|
307
|
+
type: "string",
|
|
308
|
+
pattern: "^[0-9]+$"
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: "webhook-signature",
|
|
313
|
+
in: "header",
|
|
314
|
+
required: true,
|
|
315
|
+
description: "Space-separated signatures of `id.timestamp.body`, each `v1,<base64>`.",
|
|
316
|
+
schema: { type: "string" }
|
|
317
|
+
}
|
|
318
|
+
];
|
|
319
|
+
function lowerWebhook(webhook) {
|
|
320
|
+
return { post: omitUndefined({
|
|
321
|
+
operationId: `on${pascal(webhook.id.replaceAll(".", "_"))}`,
|
|
322
|
+
summary: webhook.summary,
|
|
323
|
+
description: webhook.description,
|
|
324
|
+
parameters: webhook.standardWebhooks ? STANDARD_WEBHOOK_HEADERS.map((header) => ({ ...header })) : void 0,
|
|
325
|
+
requestBody: {
|
|
326
|
+
required: true,
|
|
327
|
+
content: { "application/json": { schema: webhook.payload } }
|
|
328
|
+
},
|
|
329
|
+
responses: { "2XX": { description: "The receiver accepted the event." } }
|
|
330
|
+
}) };
|
|
331
|
+
}
|
|
332
|
+
function lowerTags(model, features) {
|
|
333
|
+
return model.tags.map((tag) => features.native32 ? omitUndefined({ ...tag }) : omitUndefined({
|
|
334
|
+
name: tag.name,
|
|
335
|
+
description: tag.description,
|
|
336
|
+
[`${features.prefix}summary`]: tag.summary,
|
|
337
|
+
[`${features.prefix}parent`]: tag.parent,
|
|
338
|
+
[`${features.prefix}kind`]: tag.kind
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
function lowerOpenApi(model, version, ctx) {
|
|
342
|
+
const is33 = version === "3.3-preview";
|
|
343
|
+
const dropped = new Set(is33 ? [] : Object.entries(model.securitySchemes).filter(([, scheme]) => scheme.type === "profile").map(([name]) => name));
|
|
344
|
+
const features = {
|
|
345
|
+
version,
|
|
346
|
+
native32: version === "3.2" || is33,
|
|
347
|
+
is30: version === "3.0",
|
|
348
|
+
is33,
|
|
349
|
+
prefix: model.extensionPrefix,
|
|
350
|
+
dropped
|
|
351
|
+
};
|
|
352
|
+
for (const name of dropped) ctx.report({
|
|
353
|
+
code: "preview-only",
|
|
354
|
+
severity: "info",
|
|
355
|
+
message: `Security scheme "${name}" uses Security Profiles, which only 3.3-preview emits; it and the requirements that name it are left out`,
|
|
356
|
+
pointer: `/components/securitySchemes/${pointerToken(name)}`
|
|
357
|
+
});
|
|
358
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
359
|
+
const placed = [];
|
|
360
|
+
for (const operation of model.operations) {
|
|
361
|
+
if (operation.method === "query" && !features.native32) {
|
|
362
|
+
ctx.report({
|
|
363
|
+
code: "method-unsupported",
|
|
364
|
+
severity: "warning",
|
|
365
|
+
message: `Operation "${operation.id}" uses the QUERY method, which OpenAPI ${version} cannot describe; it is left out`,
|
|
366
|
+
pointer: `/paths/${pointerToken(operation.path)}`
|
|
367
|
+
});
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
const list = grouped.get(operation.path) ?? [];
|
|
371
|
+
list.push({
|
|
372
|
+
method: operation.method,
|
|
373
|
+
operation: lowerOperation(operation, features)
|
|
374
|
+
});
|
|
375
|
+
grouped.set(operation.path, list);
|
|
376
|
+
placed.push(operation);
|
|
377
|
+
}
|
|
378
|
+
const paths = {};
|
|
379
|
+
for (const [path, operations] of grouped) paths[path] = pathItem(operations, features);
|
|
380
|
+
const securitySchemes = {};
|
|
381
|
+
for (const [name, scheme] of Object.entries(model.securitySchemes)) {
|
|
382
|
+
const lowered = lowerScheme(scheme, features);
|
|
383
|
+
if (lowered) securitySchemes[name] = lowered;
|
|
384
|
+
}
|
|
385
|
+
const components = {
|
|
386
|
+
schemas: structuredClone(model.schemas),
|
|
387
|
+
responses: Object.fromEntries(Object.entries(model.responses).map(([name, response]) => [name, lowerResponse(response, features)])),
|
|
388
|
+
securitySchemes
|
|
389
|
+
};
|
|
390
|
+
if (is33 && model.securityProfileRequirements) components["securityProfileRequirements"] = structuredClone(model.securityProfileRequirements);
|
|
391
|
+
let webhooks;
|
|
392
|
+
if (model.webhooks.length > 0) {
|
|
393
|
+
if (features.is30) ctx.report({
|
|
394
|
+
code: "webhooks-unsupported",
|
|
395
|
+
severity: "warning",
|
|
396
|
+
message: `OpenAPI 3.0 has no webhooks; ${model.webhooks.length} webhook(s) are left out`
|
|
397
|
+
});
|
|
398
|
+
else webhooks = Object.fromEntries(model.webhooks.map((webhook) => [webhook.id, lowerWebhook(webhook)]));
|
|
399
|
+
}
|
|
400
|
+
const info = features.is30 ? omitUndefined({
|
|
401
|
+
...model.info,
|
|
402
|
+
summary: void 0,
|
|
403
|
+
license: model.info.license ? omitUndefined({
|
|
404
|
+
...model.info.license,
|
|
405
|
+
identifier: void 0
|
|
406
|
+
}) : void 0
|
|
407
|
+
}) : omitUndefined({ ...model.info });
|
|
408
|
+
let document = omitUndefined({
|
|
409
|
+
openapi: OPENAPI_FIELD[version],
|
|
410
|
+
[features.native32 ? "$self" : "x-oai-$self"]: model.self,
|
|
411
|
+
info: structuredClone(info),
|
|
412
|
+
jsonSchemaDialect: features.is30 ? void 0 : DIALECT,
|
|
413
|
+
servers: lowerServers(model.servers, features),
|
|
414
|
+
tags: lowerTags(model, features),
|
|
415
|
+
security: lowerSecurity(model.security, features),
|
|
416
|
+
paths,
|
|
417
|
+
webhooks,
|
|
418
|
+
components,
|
|
419
|
+
[`${features.prefix}preview`]: is33 ? SPEC_PINS.openapi33Preview : void 0
|
|
420
|
+
});
|
|
421
|
+
for (const [index, fragment] of model.fragments.entries()) document = mergeJson(document, fragment, (pointer) => {
|
|
422
|
+
ctx.report({
|
|
423
|
+
code: "fragment-conflict",
|
|
424
|
+
severity: "warning",
|
|
425
|
+
message: `Fragment ${index} replaces a generated value`,
|
|
426
|
+
pointer
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
for (const operation of placed) {
|
|
430
|
+
if (!operation.extend) continue;
|
|
431
|
+
const patch = { paths: { [operation.path]: { [operation.method]: operation.extend } } };
|
|
432
|
+
document = mergeJson(document, patch);
|
|
433
|
+
}
|
|
434
|
+
if (features.is30) document = lowerDocumentSchemas30(document);
|
|
435
|
+
if (!isOpenApiDocument(document)) throw new TypeError("better-supabase/spec: a fragment removed a required document field");
|
|
436
|
+
return document;
|
|
437
|
+
}
|
|
438
|
+
/** The fields every OpenAPI document this format renders has. */
|
|
439
|
+
function isOpenApiDocument(value) {
|
|
440
|
+
return typeof value["openapi"] === "string" && isPlainObject(value["info"]) && isPlainObject(value["paths"]) && isPlainObject(value["components"]) && Array.isArray(value["tags"]) && Array.isArray(value["security"]);
|
|
441
|
+
}
|
|
442
|
+
const PATH_PARAM = /\{([^}]+)\}/g;
|
|
443
|
+
function resolves(document, ref) {
|
|
444
|
+
if (!ref.startsWith("#")) return true;
|
|
445
|
+
let node = document;
|
|
446
|
+
for (const raw of ref.slice(2).split("/")) {
|
|
447
|
+
if (raw === "" && ref === "#") break;
|
|
448
|
+
const key = raw.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
449
|
+
if (Array.isArray(node)) node = node[Number(key)];
|
|
450
|
+
else if (isPlainObject(node)) node = node[key];
|
|
451
|
+
else return false;
|
|
452
|
+
if (node === void 0) return false;
|
|
453
|
+
}
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
456
|
+
function collectRefs(value, pointer, out) {
|
|
457
|
+
if (Array.isArray(value)) for (const [index, item] of value.entries()) collectRefs(item, `${pointer}/${index}`, out);
|
|
458
|
+
else if (isPlainObject(value)) for (const [key, item] of Object.entries(value)) if (key === "$ref" && typeof item === "string") out.push([pointer, item]);
|
|
459
|
+
else collectRefs(item, `${pointer}/${pointerToken(key)}`, out);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* The keys of `value[key]` when it is an object; documents read from disk may
|
|
463
|
+
* omit any field.
|
|
464
|
+
*/
|
|
465
|
+
function keysAt(value, key) {
|
|
466
|
+
if (!isPlainObject(value)) return [];
|
|
467
|
+
const child = value[key];
|
|
468
|
+
return isPlainObject(child) ? Object.keys(child) : [];
|
|
469
|
+
}
|
|
470
|
+
function lintOpenApi(document) {
|
|
471
|
+
const diagnostics = [];
|
|
472
|
+
const ids = /* @__PURE__ */ new Map();
|
|
473
|
+
const components = document.components;
|
|
474
|
+
const schemes = new Set(keysAt(components, "securitySchemes"));
|
|
475
|
+
const checkSecurity = (requirements, pointer) => {
|
|
476
|
+
if (!Array.isArray(requirements)) return;
|
|
477
|
+
const list = requirements;
|
|
478
|
+
for (const requirement of list) {
|
|
479
|
+
if (!isPlainObject(requirement)) continue;
|
|
480
|
+
for (const name of Object.keys(requirement)) if (!schemes.has(name)) diagnostics.push({
|
|
481
|
+
code: "security-unresolved",
|
|
482
|
+
severity: "error",
|
|
483
|
+
message: `Security requirement names an unknown scheme "${name}"`,
|
|
484
|
+
pointer
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
checkSecurity(document.security, "/security");
|
|
489
|
+
const paths = document.paths;
|
|
490
|
+
for (const [path, item] of Object.entries(isPlainObject(paths) ? paths : {})) {
|
|
491
|
+
if (!isPlainObject(item)) continue;
|
|
492
|
+
const base = `/paths/${pointerToken(path)}`;
|
|
493
|
+
const templated = new Set([...path.matchAll(PATH_PARAM)].map((match) => match[1] ?? ""));
|
|
494
|
+
const shared = Array.isArray(item["parameters"]) ? item["parameters"] : [];
|
|
495
|
+
checkSecurity(item["security"], `${base}/security`);
|
|
496
|
+
for (const [method, operation] of Object.entries(item)) {
|
|
497
|
+
if (!METHODS.has(method) || !isPlainObject(operation)) continue;
|
|
498
|
+
const pointer = `${base}/${method}`;
|
|
499
|
+
const id = operation["operationId"];
|
|
500
|
+
if (typeof id === "string") {
|
|
501
|
+
const seen = ids.get(id);
|
|
502
|
+
if (seen) diagnostics.push({
|
|
503
|
+
code: "operation-id-duplicate",
|
|
504
|
+
severity: "error",
|
|
505
|
+
message: `operationId "${id}" is also used at ${seen}`,
|
|
506
|
+
pointer
|
|
507
|
+
});
|
|
508
|
+
else ids.set(id, pointer);
|
|
509
|
+
}
|
|
510
|
+
checkSecurity(operation["security"], `${pointer}/security`);
|
|
511
|
+
const own = Array.isArray(operation["parameters"]) ? operation["parameters"] : [];
|
|
512
|
+
const declared = /* @__PURE__ */ new Set();
|
|
513
|
+
for (const parameter of [...shared, ...own]) {
|
|
514
|
+
if (!isPlainObject(parameter) || parameter["in"] !== "path") continue;
|
|
515
|
+
const name = String(parameter["name"]);
|
|
516
|
+
declared.add(name);
|
|
517
|
+
if (!templated.has(name)) diagnostics.push({
|
|
518
|
+
code: "path-param-unknown",
|
|
519
|
+
severity: "error",
|
|
520
|
+
message: `Path parameter "${name}" is not in the path template`,
|
|
521
|
+
pointer
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
for (const name of templated) if (!declared.has(name)) diagnostics.push({
|
|
525
|
+
code: "path-param-missing",
|
|
526
|
+
severity: "error",
|
|
527
|
+
message: `Path template parameter "${name}" has no parameter`,
|
|
528
|
+
pointer
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
const refs = [];
|
|
533
|
+
collectRefs(document, "", refs);
|
|
534
|
+
for (const [pointer, ref] of refs) if (!resolves(document, ref)) diagnostics.push({
|
|
535
|
+
code: "ref-unresolved",
|
|
536
|
+
severity: "error",
|
|
537
|
+
message: `$ref "${ref}" does not resolve inside the document`,
|
|
538
|
+
pointer
|
|
539
|
+
});
|
|
540
|
+
return diagnostics;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* OpenAPI as a `DocumentFormat`. 3.1 is the default; 3.0 is legacy (schemas
|
|
544
|
+
* lowered to the 3.0 Schema Object); 3.2 has native `$self`, nested tags,
|
|
545
|
+
* `itemSchema`, `oauth2MetadataUrl` and `query`; `3.3-preview` follows the
|
|
546
|
+
* v3.3-dev branch at `SPEC_PINS.openapi33Preview`, with Path Item `security`
|
|
547
|
+
* and the Security Profiles proposal. Below 3.2, the 3.2 fields travel as the
|
|
548
|
+
* registered `x-oai-*` extensions where one exists, and as the model's prefixed
|
|
549
|
+
* extensions otherwise.
|
|
550
|
+
*/
|
|
551
|
+
const openapiFormat = defineDocumentFormat({
|
|
552
|
+
id: "openapi",
|
|
553
|
+
versions: {
|
|
554
|
+
"3.0": {
|
|
555
|
+
pin: SPEC_PINS.openapi30,
|
|
556
|
+
status: "legacy"
|
|
557
|
+
},
|
|
558
|
+
"3.1": {
|
|
559
|
+
pin: SPEC_PINS.openapi31,
|
|
560
|
+
status: "stable"
|
|
561
|
+
},
|
|
562
|
+
"3.2": {
|
|
563
|
+
pin: SPEC_PINS.openapi32,
|
|
564
|
+
status: "stable"
|
|
565
|
+
},
|
|
566
|
+
"3.3-preview": {
|
|
567
|
+
pin: SPEC_PINS.openapi33Preview,
|
|
568
|
+
status: "preview"
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
defaultVersion: "3.1",
|
|
572
|
+
lower: lowerOpenApi,
|
|
573
|
+
lint: lintOpenApi,
|
|
574
|
+
fileName: () => OPENAPI_FILE_NAME
|
|
575
|
+
});
|
|
576
|
+
//#endregion
|
|
577
|
+
//#region src/spec/api.ts
|
|
578
|
+
function dedupe(diagnostics) {
|
|
579
|
+
const seen = /* @__PURE__ */ new Set();
|
|
580
|
+
return diagnostics.filter((diagnostic) => {
|
|
581
|
+
const key = `${diagnostic.code}\u0000${diagnostic.pointer ?? ""}\u0000${diagnostic.message}`;
|
|
582
|
+
if (seen.has(key)) return false;
|
|
583
|
+
seen.add(key);
|
|
584
|
+
return true;
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* The API model for a `defineSupabase()` result, and the documents it renders.
|
|
589
|
+
* The model is built once per options object; each format and version is
|
|
590
|
+
* lowered once and copied for every render.
|
|
591
|
+
*
|
|
592
|
+
* ```ts
|
|
593
|
+
* const api = defineApi(betterSupabase, {
|
|
594
|
+
* info: { title: "CRM API", version: "1.0.0" },
|
|
595
|
+
* resources: { customers: { list: customerList } },
|
|
596
|
+
* });
|
|
597
|
+
* ```
|
|
598
|
+
*
|
|
599
|
+
* Without `resources` it publishes every table, and without `blocks` every
|
|
600
|
+
* block instance `betterSupabase.blocks(set)` registered:
|
|
601
|
+
*
|
|
602
|
+
* ```ts
|
|
603
|
+
* const api = defineApi(betterSupabase, { info, basePath: "/api" });
|
|
604
|
+
* export const { procedures } = bsb.router(api, { meta: openapi });
|
|
605
|
+
* const { document } = api.openapi({ version: "3.2" });
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
608
|
+
function defineApi(source, options) {
|
|
609
|
+
const built = buildApiModel(source, options);
|
|
610
|
+
const lowered = /* @__PURE__ */ new WeakMap();
|
|
611
|
+
const lower = (format, version) => {
|
|
612
|
+
let byVersion = lowered.get(format);
|
|
613
|
+
if (!byVersion) {
|
|
614
|
+
byVersion = /* @__PURE__ */ new Map();
|
|
615
|
+
lowered.set(format, byVersion);
|
|
616
|
+
}
|
|
617
|
+
let hit = byVersion.get(version);
|
|
618
|
+
if (!hit) {
|
|
619
|
+
const diagnostics = [];
|
|
620
|
+
hit = {
|
|
621
|
+
document: format.lower(built.model, version, { report: (diagnostic) => {
|
|
622
|
+
diagnostics.push(diagnostic);
|
|
623
|
+
} }),
|
|
624
|
+
diagnostics
|
|
625
|
+
};
|
|
626
|
+
byVersion.set(version, hit);
|
|
627
|
+
}
|
|
628
|
+
return hit;
|
|
629
|
+
};
|
|
630
|
+
const render = (format, renderOptions = {}) => {
|
|
631
|
+
const fallback = format.defaultVersion;
|
|
632
|
+
const version = renderOptions.version ?? fallback;
|
|
633
|
+
const status = format.versions[version];
|
|
634
|
+
if (!status) throw new TypeError(`Document format "${format.id}" has no version "${String(version)}"`);
|
|
635
|
+
const diagnostics = [...built.diagnostics];
|
|
636
|
+
if (status.status === "preview") diagnostics.push({
|
|
637
|
+
code: "preview-version",
|
|
638
|
+
severity: "warning",
|
|
639
|
+
message: `${format.id} ${String(version)} follows a draft (${status.pin}); its fields may change before release`
|
|
640
|
+
});
|
|
641
|
+
const base = lower(format, version);
|
|
642
|
+
diagnostics.push(...base.diagnostics);
|
|
643
|
+
let document = structuredClone(base.document);
|
|
644
|
+
if (renderOptions.transform) {
|
|
645
|
+
const rendered = {
|
|
646
|
+
format: format.id,
|
|
647
|
+
version,
|
|
648
|
+
document
|
|
649
|
+
};
|
|
650
|
+
document = renderOptions.transform(rendered) ?? document;
|
|
651
|
+
}
|
|
652
|
+
const overlays = renderOptions.overlays ?? [];
|
|
653
|
+
if (overlays.length > 0) {
|
|
654
|
+
const engine = renderOptions.applyOverlays ?? options.applyOverlays;
|
|
655
|
+
if (!engine) throw new TypeError("better-supabase/spec: overlays need applyOverlays (from better-supabase/spec)");
|
|
656
|
+
const result = engine(document, overlays);
|
|
657
|
+
document = result.document;
|
|
658
|
+
diagnostics.push(...result.diagnostics ?? []);
|
|
659
|
+
}
|
|
660
|
+
diagnostics.push(...format.lint?.(document, version) ?? []);
|
|
661
|
+
return {
|
|
662
|
+
format: format.id,
|
|
663
|
+
version,
|
|
664
|
+
document,
|
|
665
|
+
diagnostics: dedupe(diagnostics),
|
|
666
|
+
fileName: format.fileName(version)
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
return {
|
|
670
|
+
model: built.model,
|
|
671
|
+
basePath: (options.basePath ?? "").replace(/\/$/, ""),
|
|
672
|
+
resources: publishedResources(source.meta, options),
|
|
673
|
+
blocks: publishedBlocks(source.options?.blocks, options.blocks),
|
|
674
|
+
diagnostics: built.diagnostics,
|
|
675
|
+
render,
|
|
676
|
+
openapi(openapiOptions = {}) {
|
|
677
|
+
const { transform, version, overlays, applyOverlays } = openapiOptions;
|
|
678
|
+
const renderOptions = {
|
|
679
|
+
...version === void 0 ? {} : { version },
|
|
680
|
+
...overlays === void 0 ? {} : { overlays },
|
|
681
|
+
...applyOverlays === void 0 ? {} : { applyOverlays },
|
|
682
|
+
...transform === void 0 ? {} : { transform: (rendered) => transform(rendered) }
|
|
683
|
+
};
|
|
684
|
+
const result = render(openapiFormat, renderOptions);
|
|
685
|
+
return {
|
|
686
|
+
format: "openapi",
|
|
687
|
+
version: result.version,
|
|
688
|
+
document: result.document,
|
|
689
|
+
diagnostics: result.diagnostics,
|
|
690
|
+
fileName: result.fileName
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
//#endregion
|
|
696
|
+
export { toOpenApi30Schema as a, OPENAPI_FILE_NAME as i, openapiFormat as n, defineDocumentFormat as o, OPENAPI_33_PREVIEW_VERSION as r, defineApi as t };
|