better-supabase 0.15.1 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ai-schedules-D_Hz-ik5.d.ts → ai-schedules-BmkARmQ9.d.ts} +1 -1
- package/dist/{api-DxAPqMrE.d.ts → api-hHwieEfz.d.ts} +1 -1
- package/dist/{app-tables-CbCFSXLG.d.ts → app-tables-yMQ4ubyY.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/better-result/index.d.ts +2 -2
- package/dist/{bind-h5jre2K0.d.ts → bind-JGCPGUJh.d.ts} +4 -4
- package/dist/{block-env-BrfRvPrj.d.ts → block-env-y65GF_px.d.ts} +4 -4
- package/dist/blocks/access-requests/index.d.ts +1 -1
- package/dist/blocks/activities/index.d.ts +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 +4 -4
- package/dist/blocks/compliance/index.d.ts +1 -1
- package/dist/blocks/connectors/index.d.ts +1 -1
- package/dist/blocks/contacts/index.d.ts +1 -1
- package/dist/blocks/content/index.d.ts +1 -1
- package/dist/blocks/contracts/index.d.ts +1 -1
- package/dist/blocks/courses/index.d.ts +1 -1
- package/dist/blocks/created-by/index.d.ts +1 -1
- package/dist/blocks/custom-fields/index.d.ts +1 -1
- package/dist/blocks/data-lifecycle/index.d.ts +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 +4 -4
- 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 +1 -1
- 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-Bfb_ISrO.js +1 -0
- package/dist/cli/{add-DNOL9PDu.js → add-D7TkPdco.js} +9 -9
- package/dist/cli/{add-C04vkBk9.js → add-I8OW-qJH.js} +2 -2
- package/dist/cli/{backfill-VFzf-TJP.js → backfill-DIz5DnlQ.js} +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cli/{blocks-Bn7WUca5.js → blocks-Bp5RPoft.js} +1 -1
- package/dist/cli/{blocks-Cb7mILFU.js → blocks-xk-SE8gS.js} +1 -1
- package/dist/cli/{cache-DkplpIGe.js → cache-AznIssjI.js} +1 -1
- package/dist/cli/{codemod-BbaE5dL_.js → codemod-Aewxza6i.js} +1 -1
- package/dist/cli/{content-mapper-Cdx6arxu.js → content-mapper-DCrz6OIv.js} +2 -2
- package/dist/cli/{doctor-C-VO-QQ2.js → doctor-DkOSLPEQ.js} +13 -13
- package/dist/cli/{gen-yRHOHW1b.js → gen-CFkYUnWq.js} +10 -10
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +6 -6
- package/dist/cli/{init-BOw0SX65.js → init-CHj9ad4S.js} +5 -5
- package/dist/cli/{live-Lmg-hYyO.js → live-DGdLR41j.js} +2 -2
- package/dist/cli/{mcp-DQ1zR2eA.js → mcp-BZno503V.js} +2 -2
- package/dist/cli/{metadata-CZaxkv21.js → metadata-BfgHMe4q.js} +3 -3
- package/dist/cli/{migration-safety-BbhLu2fo.js → migration-safety-BnnXPAro.js} +1 -1
- package/dist/cli/{module-migration-DOn6EmNz.js → module-migration-O_IxewFs.js} +1 -1
- package/dist/cli/{print-D_xf8PPj.js → print-DosQIFSy.js} +1 -1
- package/dist/cli/{remove-BY_TOTRj.js → remove-DK2G_KHm.js} +5 -5
- package/dist/cli/{render-lJmHr0y9.js → render-5y5a1QZr.js} +3 -3
- package/dist/cli/{run-BJ6IMs_H.js → run-Bs4OKdDI.js} +7 -7
- package/dist/cli/{run-DkB0fhc9.js → run-MRET30vh.js} +20 -20
- package/dist/cli/{shared-Bh-6IqJS.js → shared-BLqbvY2x.js} +1 -1
- package/dist/cli/{snapshot-Bzcigm7T.js → snapshot-uTUlEzY2.js} +2 -2
- package/dist/cli/{source-WoLdcQzN.js → source-D2gJHKwC.js} +1 -1
- package/dist/cli/{spec-CZMiLhv_.js → spec-Cm2einTO.js} +2 -2
- package/dist/cli/{spec-BF_dpwzW.js → spec-DUjOtciN.js} +1 -1
- package/dist/cli/{sql-layout-rFP0oq1N.js → sql-layout-lUWenjJw.js} +2 -2
- package/dist/cli/{sync-mANmYYoL.js → sync-CZMRB3aU.js} +2 -2
- package/dist/cli/{upgrade-B0Q9wMs-.js → upgrade-BFEIMC7U.js} +3 -3
- package/dist/cli/{upgrade-BrNLt92u.js → upgrade-fVsJniXm.js} +2 -2
- package/dist/cli/{version-CyavsyGA.js → version-B2Dr6VmJ.js} +1 -1
- package/dist/client/index.d.ts +5 -5
- package/dist/client/index.js +1 -1
- package/dist/client/native/index.d.ts +5 -5
- package/dist/client/native/index.js +1 -1
- package/dist/{client-BAEbEA7t.js → client-C_mlji5R.js} +6 -5
- package/dist/{composite-BZYXlVBN.d.ts → composite-CfYyU3vs.d.ts} +4 -3
- package/dist/config/index.d.ts +1 -1
- package/dist/{context-TGX2eDS5.d.ts → context-8kb8m5uO.d.ts} +1 -1
- package/dist/{controller-DyPPMFSw.d.ts → controller-BW-5Opig.d.ts} +1 -1
- package/dist/{conversion-O-kyhXcC.d.ts → conversion-3iv2r7YC.d.ts} +1 -1
- package/dist/create/index.d.ts +2 -2
- package/dist/create/index.js +1 -1
- package/dist/{define-DFBnQyYg.d.ts → define-C5AcEkEJ.d.ts} +1 -1
- package/dist/{define-block-DvvcM54N.d.ts → define-block-C1RHXz7L.d.ts} +2 -2
- package/dist/edge/index.d.ts +5 -5
- package/dist/{entitlements-BnhDBxLW.d.ts → entitlements-sO977DO-.d.ts} +1 -1
- package/dist/{executor-CVIn6JHa.d.ts → executor-BcNWcD-4.d.ts} +2 -2
- package/dist/expo/index.d.ts +2 -2
- package/dist/{field-errors-DYtg1mwv.d.ts → field-errors-Dt86dCKk.d.ts} +12 -12
- package/dist/{framework-h5lP_5yj.d.ts → framework-BGdZVyPL.d.ts} +3 -3
- package/dist/hono/index.d.ts +4 -4
- package/dist/{index-BAHGLvGD.d.ts → index-CENWq3zb.d.ts} +1 -1
- package/dist/{index-Do2ChN_y.d.ts → index-CQhPHHDF.d.ts} +20 -2
- package/dist/{index-DN9mfmhA.d.ts → index-CTu-3fJB.d.ts} +51 -3
- package/dist/{index-BfK6olKm.d.ts → index-Cc4mIQS8.d.ts} +2 -2
- package/dist/{index-BfkltrGJ.d.ts → index-CcAmFNVi.d.ts} +2 -2
- package/dist/{index-Ab4UeEn_.d.ts → index-Craf712U.d.ts} +44 -12
- package/dist/{index-B4gcStOz.d.ts → index-DZKCc2WM.d.ts} +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/list/index.d.ts +1 -1
- package/dist/{list-query-BDVutLFr.d.ts → list-query-DYhgRTd5.d.ts} +1 -1
- package/dist/mapper/bin.js +5 -5
- package/dist/mcp/index.d.ts +3 -3
- package/dist/mcp/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/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-mObLgH1z.d.ts} +1 -1
- package/dist/powersync/index.d.ts +2 -2
- package/dist/preset/index.d.ts +3 -3
- package/dist/{push-token-B3m3pWAv.d.ts → push-token-BSSvsWXZ.d.ts} +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/{rate-limit-o44SYkVY.js → rate-limit-Dt9vAY4E.js} +53 -0
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +3 -3
- package/dist/react/native/index.d.ts +1 -1
- package/dist/react/native/index.js +1 -1
- package/dist/react/server.d.ts +12 -7
- package/dist/react/server.js +8 -3
- package/dist/react/session.d.ts +5 -0
- package/dist/react/session.js +9 -1
- package/dist/{react-BuDYI62C.js → react-CZUZYn9E.js} +41 -4
- package/dist/react-router/index.d.ts +3 -3
- package/dist/realtime/index.d.ts +5 -5
- package/dist/realtime/index.js +2 -1
- package/dist/{record-form-DB_5Ue_B.d.ts → record-form-D9ILuVtA.d.ts} +1 -1
- package/dist/records/index.d.ts +7 -7
- package/dist/relay-gKvKJ3xf.js +208 -0
- package/dist/{resource-execute-CzHuDsil.d.ts → resource-execute-Cpnob1Vj.d.ts} +1 -1
- package/dist/{resource-types-DnKiH4G2.d.ts → resource-types-pMeLs68X.d.ts} +1 -1
- package/dist/{resources-B9cQxhjw.d.ts → resources-7iq2-5_A.d.ts} +1 -1
- package/dist/server/index.d.ts +147 -9
- package/dist/server/index.js +396 -1
- package/dist/{server-types-7QPzW2bF.d.ts → server-types-CK8mUIUT.d.ts} +5 -354
- package/dist/{session-CfBCJGgc.d.ts → session-DWmFv3vB.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 +3 -3
- package/dist/sql/index.js +1 -1
- package/dist/{sql-OLVW4t08.js → sql-Dl3Alk43.js} +127 -0
- 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-qvVk79pp.d.ts} +1 -1
- package/dist/tanstack-db/index.d.ts +1 -1
- package/dist/tanstack-start/index.d.ts +3 -3
- package/dist/{tenant-DzFsg0Pc.d.ts → tenant-DOKIJI62.d.ts} +1 -1
- package/dist/testing/index.d.ts +8 -7
- package/dist/{timeline-WrFMgd3U.d.ts → timeline-CvTuXYvn.d.ts} +3 -3
- package/dist/{topic-DNFEFGKI.d.ts → topic-CZXHhZye.d.ts} +2 -2
- package/dist/{verify-CMou8dWZ.d.ts → verify-CjvNLY7N.d.ts} +1 -1
- package/dist/vue/index.d.ts +7 -7
- package/dist/vue/index.js +1 -1
- package/dist/{watch-topic-Bo9S2R4P.d.ts → watch-topic-BAxoPKZx.d.ts} +1 -1
- package/dist/yjs/index.d.ts +1 -1
- package/package.json +1 -1
- 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
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { t as topicPort } from "./watch-topic-CuaWfCuv.js";
|
|
2
|
+
//#region src/realtime/relay.ts
|
|
3
|
+
const CLOSED_STATE = 2;
|
|
4
|
+
function parse(event) {
|
|
5
|
+
if (typeof event.data !== "string") return;
|
|
6
|
+
try {
|
|
7
|
+
return JSON.parse(event.data);
|
|
8
|
+
} catch {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** The runtime's `EventSource`, read without assuming DOM types. */
|
|
13
|
+
function globalEventSource() {
|
|
14
|
+
const value = "EventSource" in globalThis ? globalThis.EventSource : void 0;
|
|
15
|
+
return typeof value === "function" ? value : void 0;
|
|
16
|
+
}
|
|
17
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18
|
+
/**
|
|
19
|
+
* A Realtime client that joins topics through `realtimeRelay` on the server
|
|
20
|
+
* instead of a browser connection with the user's token: for support sessions
|
|
21
|
+
* ("view as user") and apps that keep sessions in httpOnly cookies. It has the
|
|
22
|
+
* `RealtimeClient` surface, so `defineTopic(...).subscribe`, `send`,
|
|
23
|
+
* `liveQuery`, `watchTopic` and the React hooks take it unchanged. Each topic
|
|
24
|
+
* is one server-sent event stream that reconnects on its own and reports a
|
|
25
|
+
* rejoin after a gap, so live queries refetch. Presence states arrive, but
|
|
26
|
+
* `track` answers `error`: presence is not relayed upstream.
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* const realtime = relayRealtimeClient("/api/realtime");
|
|
30
|
+
* using sub = notifications.subscribe(realtime, { userId }, handlers);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
function relayRealtimeClient(url, options = {}) {
|
|
34
|
+
const channels = [];
|
|
35
|
+
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
36
|
+
const maxBackoffMs = options.maxBackoffMs ?? 3e4;
|
|
37
|
+
const channelClose = /* @__PURE__ */ new WeakMap();
|
|
38
|
+
const post = async (topic, event, payload) => {
|
|
39
|
+
const doFetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
40
|
+
try {
|
|
41
|
+
const response = await doFetch(url, {
|
|
42
|
+
method: "POST",
|
|
43
|
+
credentials: "same-origin",
|
|
44
|
+
headers: { "content-type": "application/json" },
|
|
45
|
+
body: JSON.stringify({
|
|
46
|
+
topic,
|
|
47
|
+
event,
|
|
48
|
+
payload
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
if (response.ok) {
|
|
52
|
+
await response.body?.cancel();
|
|
53
|
+
return { success: true };
|
|
54
|
+
}
|
|
55
|
+
const problem = await response.json().catch(() => void 0);
|
|
56
|
+
const detail = isRecord(problem) && typeof problem["detail"] === "string" ? problem["detail"] : isRecord(problem) && typeof problem["title"] === "string" ? problem["title"] : response.statusText;
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
status: response.status,
|
|
60
|
+
error: detail
|
|
61
|
+
};
|
|
62
|
+
} catch (cause) {
|
|
63
|
+
return {
|
|
64
|
+
success: false,
|
|
65
|
+
status: 0,
|
|
66
|
+
error: cause instanceof Error ? cause.message : String(cause)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const create = (name) => {
|
|
71
|
+
const topic = `realtime:${name}`;
|
|
72
|
+
const listeners = [];
|
|
73
|
+
let presence = {};
|
|
74
|
+
let source;
|
|
75
|
+
let status;
|
|
76
|
+
let subscribed = false;
|
|
77
|
+
let ending = false;
|
|
78
|
+
let removed = false;
|
|
79
|
+
let backoff = 1e3;
|
|
80
|
+
let joinTimer;
|
|
81
|
+
let retryTimer;
|
|
82
|
+
const dispatch = (type, event, message) => {
|
|
83
|
+
for (const listener of listeners) if (listener.event === `${type}:*` || listener.event === `${type}:${event}`) listener.callback(message);
|
|
84
|
+
};
|
|
85
|
+
const open = () => {
|
|
86
|
+
if (removed) return;
|
|
87
|
+
const Source = options.EventSource ?? globalEventSource();
|
|
88
|
+
if (Source === void 0) {
|
|
89
|
+
status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error("relayRealtimeClient needs EventSource"));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const next = new Source(`${url}${url.includes("?") ? "&" : "?"}topic=${encodeURIComponent(name)}`, { withCredentials: true });
|
|
93
|
+
source = next;
|
|
94
|
+
clearTimeout(joinTimer);
|
|
95
|
+
joinTimer = setTimeout(() => {
|
|
96
|
+
if (!subscribed && source === next) status?.("TIMED_OUT");
|
|
97
|
+
}, timeoutMs);
|
|
98
|
+
next.addEventListener("status", (event) => {
|
|
99
|
+
const data = parse(event);
|
|
100
|
+
if (!isRecord(data) || source !== next) return;
|
|
101
|
+
if (data["status"] === "subscribed") {
|
|
102
|
+
clearTimeout(joinTimer);
|
|
103
|
+
subscribed = true;
|
|
104
|
+
ending = false;
|
|
105
|
+
backoff = 1e3;
|
|
106
|
+
status?.("SUBSCRIBED");
|
|
107
|
+
} else if (data["status"] === "error") status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error(`Realtime error on ${name}`));
|
|
108
|
+
});
|
|
109
|
+
next.addEventListener("broadcast", (event) => {
|
|
110
|
+
const data = parse(event);
|
|
111
|
+
if (!isRecord(data) || typeof data["event"] !== "string") return;
|
|
112
|
+
dispatch("broadcast", data["event"], {
|
|
113
|
+
type: "broadcast",
|
|
114
|
+
event: data["event"],
|
|
115
|
+
payload: data["payload"]
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
next.addEventListener("presence", (event) => {
|
|
119
|
+
const data = parse(event);
|
|
120
|
+
if (!isRecord(data)) return;
|
|
121
|
+
presence = Object.fromEntries(Object.entries(data).filter((entry) => Array.isArray(entry[1])));
|
|
122
|
+
dispatch("presence", "sync", {});
|
|
123
|
+
});
|
|
124
|
+
next.addEventListener("end", () => {
|
|
125
|
+
ending = true;
|
|
126
|
+
});
|
|
127
|
+
next.addEventListener("error", () => {
|
|
128
|
+
if (removed || source !== next) return;
|
|
129
|
+
if (next.readyState !== CLOSED_STATE) {
|
|
130
|
+
if (subscribed && !ending) status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error(`The relay connection for ${name} dropped`));
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
next.close();
|
|
134
|
+
source = void 0;
|
|
135
|
+
if (!subscribed) {
|
|
136
|
+
clearTimeout(joinTimer);
|
|
137
|
+
status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error(`The relay refused ${name}`));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error(`The relay closed ${name}; reconnecting`));
|
|
141
|
+
retryTimer = setTimeout(open, backoff);
|
|
142
|
+
backoff = Math.min(backoff * 2, maxBackoffMs);
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const close = () => {
|
|
146
|
+
removed = true;
|
|
147
|
+
clearTimeout(joinTimer);
|
|
148
|
+
clearTimeout(retryTimer);
|
|
149
|
+
source?.close();
|
|
150
|
+
source = void 0;
|
|
151
|
+
};
|
|
152
|
+
const channel = {
|
|
153
|
+
topic,
|
|
154
|
+
on(type, filter, callback) {
|
|
155
|
+
listeners.push({
|
|
156
|
+
event: `${type}:${filter.event ?? "*"}`,
|
|
157
|
+
callback
|
|
158
|
+
});
|
|
159
|
+
return channel;
|
|
160
|
+
},
|
|
161
|
+
subscribe(callback) {
|
|
162
|
+
if (status !== void 0 || removed) throw new Error(`tried to subscribe multiple times to ${name} on the relay`);
|
|
163
|
+
status = callback ?? (() => void 0);
|
|
164
|
+
open();
|
|
165
|
+
return channel;
|
|
166
|
+
},
|
|
167
|
+
unsubscribe: () => {
|
|
168
|
+
close();
|
|
169
|
+
status?.("CLOSED");
|
|
170
|
+
return Promise.resolve("ok");
|
|
171
|
+
},
|
|
172
|
+
presenceState: () => presence,
|
|
173
|
+
track: () => Promise.resolve("error"),
|
|
174
|
+
untrack: () => Promise.resolve("error"),
|
|
175
|
+
send: async (message) => (await post(name, message.event, message.payload)).success ? "ok" : "error",
|
|
176
|
+
httpSend: (event, payload) => post(name, event, payload)
|
|
177
|
+
};
|
|
178
|
+
channelClose.set(channel, close);
|
|
179
|
+
return channel;
|
|
180
|
+
};
|
|
181
|
+
return {
|
|
182
|
+
channel: (name) => {
|
|
183
|
+
const topic = `realtime:${name}`;
|
|
184
|
+
const open = channels.find((each) => each.topic === topic);
|
|
185
|
+
if (open) return open;
|
|
186
|
+
const channel = create(name);
|
|
187
|
+
channels.push(channel);
|
|
188
|
+
return channel;
|
|
189
|
+
},
|
|
190
|
+
getChannels: () => [...channels],
|
|
191
|
+
removeChannel: (channel) => {
|
|
192
|
+
const index = channels.indexOf(channel);
|
|
193
|
+
if (index !== -1) channels.splice(index, 1);
|
|
194
|
+
channelClose.get(channel)?.();
|
|
195
|
+
return Promise.resolve("ok");
|
|
196
|
+
},
|
|
197
|
+
realtime: { setAuth: () => Promise.resolve() }
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The block controllers' realtime port over `realtimeRelay`:
|
|
202
|
+
* `topicPort(relayRealtimeClient(url, options))`.
|
|
203
|
+
*/
|
|
204
|
+
function relayTopicPort(url, options = {}) {
|
|
205
|
+
return topicPort(relayRealtimeClient(url, options));
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
export { relayTopicPort as n, relayRealtimeClient as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as ResourceActionSpec } from "./resource-D8pzB5Qf.js";
|
|
2
|
-
import { i as ResourceContext, n as Parsed, r as ResourceAction, t as ActionArgs } from "./resource-types-
|
|
2
|
+
import { i as ResourceContext, n as Parsed, r as ResourceAction, t as ActionArgs } from "./resource-types-pMeLs68X.js";
|
|
3
3
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
4
|
//#region src/server/resource-execute.d.ts
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D as ValidationIssue, f as Result } from "./result-DZeA5KS6.js";
|
|
2
2
|
import { Ft as RequestContext, K as Insert, dt as TableMeta, ht as Update, it as Row, k as AnyModels, ut as TableKey } from "./types-DFdg_4yN.js";
|
|
3
|
-
import { Wt as SelectArg } from "./define-
|
|
3
|
+
import { Wt as SelectArg } from "./define-C5AcEkEJ.js";
|
|
4
4
|
import { a as RespondOptions } from "./respond-Dn1_YhC1.js";
|
|
5
5
|
import { D as ResourceOperation, k as TableVerb } from "./model-hwpvole9.js";
|
|
6
6
|
import { a as ResourcePlan, i as ResourcePagination, n as ResourceActionSpec, r as ResourceDescription } from "./resource-D8pzB5Qf.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { k as AnyModels, ut as TableKey } from "./types-DFdg_4yN.js";
|
|
2
|
-
import { l as ResourceRouteOptions } from "./resource-types-
|
|
2
|
+
import { l as ResourceRouteOptions } from "./resource-types-pMeLs68X.js";
|
|
3
3
|
//#region src/server/resources.d.ts
|
|
4
4
|
/** Resources by table name; `true` serves a table with the defaults. */
|
|
5
5
|
type ResourceMap<M extends AnyModels, Ref = string, DbT = unknown> = { readonly [T in TableKey<M>]?: ResourceRouteOptions<M, T, Ref, DbT> | true; };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -5,31 +5,35 @@ import { C as readSession, D as writeSession, T as sessionCookieName, _ as Store
|
|
|
5
5
|
import { n as SqlClient } from "../executor-hGjrop3A.js";
|
|
6
6
|
import { a as SessionActor, c as agentClaims, i as IDENTITY_SCOPES, l as delegationOf, n as ActorOutcome, o as SessionDelegation, r as AgentActOptions, s as actorOf, t as ActClaim } from "../actor-CoveJgya.js";
|
|
7
7
|
import { n as PERMISSION_CAP_CLAIM } from "../delegation-C7eWP2r8.js";
|
|
8
|
-
import { c as fromProblem, d as toProblem, i as ProblemDetails, l as isProblem, n as PROBLEM_CONTENT_TYPE, o as ProblemOptions, r as PROBLEM_TYPE_BASE, s as ProblemResponseOptions, u as problemResponse } from "../problem-DNwN8iGz.js";
|
|
8
|
+
import { a as ProblemFormat, c as fromProblem, d as toProblem, i as ProblemDetails, l as isProblem, n as PROBLEM_CONTENT_TYPE, o as ProblemOptions, r as PROBLEM_TYPE_BASE, s as ProblemResponseOptions, u as problemResponse } from "../problem-DNwN8iGz.js";
|
|
9
9
|
import { a as AuthorizationSubject, c as AuthzVersionCache, d as bindAuthorizer, f as defineAuthorizer, i as AuthorizationResource, l as PermissionRef, n as AuthorizationOutcome, o as Authorizer, p as requestMemo, r as AuthorizationRequest, s as AuthorizerRuntime, t as AnyAuthorizer, u as RequestMemo } from "../authorizer-B6X09otb.js";
|
|
10
|
-
import { J as DbStats, t as BetterSupabase, v as Db } from "../define-
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { J as DbStats, t as BetterSupabase, v as Db } from "../define-C5AcEkEJ.js";
|
|
11
|
+
import { j as StorageApi } from "../bucket-vc-QRrva.js";
|
|
12
|
+
import { A as isSessionSnapshot, C as DeleteAccountResult, D as SessionMemoStats, E as SessionMemoOptions, M as sessionCacheKey, N as sessionMemo, O as SessionSnapshot, P as snapshotOf, S as DeleteAccountOptions, T as SessionMemo, _ as suspendAccount, a as ServerContext, b as ReplicaState, c as ServerOptions, d as EndSessionsResult, f as LastSignIn, g as lastSignIns, h as endSessions, i as ForContextOptions, j as issuedAtOf, k as authzVersionOf, m as SuspendAccountResult, n as BetterServer, o as ServerDbOptions, p as SuspendAccountOptions, r as ContextOptions, s as ServerKeys, t as AdminDb, u as TENANT_HEADER, v as RequestIdOptions, w as deleteAccount, x as LiteDriver, y as PRIMARY_COOKIE } from "../server-types-CK8mUIUT.js";
|
|
13
13
|
import { n as Impersonator, r as impersonatorOf, t as ImpersonationOptions } from "../impersonation-YTa9dZUv.js";
|
|
14
14
|
import { a as checkAal, i as amrOf, n as AmrEntry, r as aalOf, t as Aal } from "../mfa-oIOYTpvc.js";
|
|
15
15
|
import { _ as SupportAuthorize, a as AutomationHooks, b as TicketSubject, c as ChatActionHook, d as IdentityRef, f as IdentityTarget, g as SubscriberPolicy, h as SubscriberEvent, i as AuthorizationHooks, l as DelegationPermissions, m as Subscriber, n as Approver, o as AutomationRef, p as PrincipalByIdentity, r as ApproverOf, s as ChatAction, t as ApprovalRequestRef, u as DelegationRef, v as SupportAuthorizeInput, x as defineAuthorizationHooks, y as SupportDecision } from "../authorization-hooks-D_pwXlBs.js";
|
|
16
|
+
import { c as RealtimeClient } from "../topic-CZXHhZye.js";
|
|
16
17
|
import { n as toSession, t as AuthSession } from "../view-DyFdMCqg.js";
|
|
17
|
-
import { a as
|
|
18
|
+
import { C as SupportSessionStore, E as supportClaims, S as SupportSession, T as sqlSupportStore, _ as SupportCallerClaims, a as SupportPolicy, b as SupportRequest, c as supportSessions, d as clearSupportCookie, f as supportCookie, g as SupportApprover, h as SupportApprovalQuery, i as SupportOptions, l as SUPPORT_COOKIE, m as SqlSupportStoreOptions, n as SupportApi, o as SupportSessions, p as supportCookieValue, r as SupportExpireRouteOptions, s as SupportStartRequest, t as ActiveSupport, u as SupportCookieOptions, v as SupportEndedBy, w as SupportStartInput, x as SupportRequestInput, y as SupportListFilter } from "../support-B4ZBVxt3.js";
|
|
19
|
+
import { a as serverCore, i as ServerCore, n as SessionEntryConfig, r as withSession, t as AuthOutageHook } from "../session-DWmFv3vB.js";
|
|
18
20
|
import { a as RespondOptions, c as isResult, d as RefreshPolicy, f as isPrefetch, h as shouldRefresh, i as MiddlewareOptions, l as respond, m as shouldCheckSession, n as AuthKind, o as Settled, p as refreshFor, r as GuardOptions, s as guard, u as settle } from "../respond-Dn1_YhC1.js";
|
|
19
|
-
import { a as GuardEntryConfig, i as withBetterSupabase, n as BetterSupabaseContributions, o as withGuard, r as BetterSupabaseEntry, t as BetterSupabaseConfig } from "../composite-
|
|
21
|
+
import { a as GuardEntryConfig, i as withBetterSupabase, n as BetterSupabaseContributions, o as withGuard, r as BetterSupabaseEntry, t as BetterSupabaseConfig } from "../composite-CfYyU3vs.js";
|
|
20
22
|
import { a as AuthorizedContext, c as ResourceLoaderContext, d as rolesAt, i as AuthorizeOptions, o as BlockActionOptions, r as ActionResult, s as BlockRequireOptions, u as hasRole } from "../kit-DOwKpSkA.js";
|
|
21
23
|
import { n as subjectReaders, t as SubjectReadersOptions } from "../subject-readers-8GySC9Z8.js";
|
|
22
24
|
import { i as toCsv, n as csvColumns, t as CsvOptions } from "../csv-DhHQS2x_.js";
|
|
23
25
|
import { i as JwsAlgorithm, n as Jwks, r as JwksOfOptions } from "../jws-D0toeQlA.js";
|
|
24
26
|
import { i as ResourcePagination } from "../resource-D8pzB5Qf.js";
|
|
25
|
-
import { a as ResourceHandler, c as ResourceList, l as ResourceRouteOptions, s as ResourceInput } from "../resource-types-
|
|
26
|
-
import { i as
|
|
27
|
+
import { a as ResourceHandler, c as ResourceList, l as ResourceRouteOptions, s as ResourceInput } from "../resource-types-pMeLs68X.js";
|
|
28
|
+
import { a as claimsFingerprint, i as SessionWatchStatus, n as SessionStatusRouteOptions, o as sessionStatusRoute, r as SessionStatusServer, t as SessionStatusBody } from "../session-status-qQLm7jzh.js";
|
|
29
|
+
import { i as tagFor, n as cacheTagsOf, r as tagCache, t as TagOptions } from "../tags-qvVk79pp.js";
|
|
27
30
|
import { n as RefreshOutcome, r as refreshSession } from "../refresh-DT_ICaK-.js";
|
|
28
31
|
import { n as passwordGrant, r as safeRedirectPath, t as PasswordGrantOptions } from "../sign-in-BAjR49fq.js";
|
|
29
32
|
import { n as supportOf, t as SupportView } from "../support-view-BYOgwXsJ.js";
|
|
30
33
|
import { a as sessionStatus, i as clearSessionCookies, n as SessionStatus, o as authContext, r as SessionStatusOptions, t as ClearSessionCookiesOptions } from "../ended-gUsMZVNg.js";
|
|
31
34
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
32
35
|
import { Middleware, SingleKeyEntry } from "@supabase/middleware";
|
|
36
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
33
37
|
import { AuthMode, JWTClaims, UserClaims } from "@supabase/server";
|
|
34
38
|
import { PostgresApi } from "@supabase/server/middleware/postgres";
|
|
35
39
|
//#region src/server/csv.d.ts
|
|
@@ -194,6 +198,140 @@ interface SupportStorageOptions {
|
|
|
194
198
|
*/
|
|
195
199
|
export declare function supportStorage(options: SupportStorageOptions): StorageApi;
|
|
196
200
|
//#endregion
|
|
201
|
+
//#region src/server/realtime-relay.d.ts
|
|
202
|
+
/**
|
|
203
|
+
* A topic the relay serves: a `defineTopic(...)` topic, or `liveRelayTopic` for
|
|
204
|
+
* the `realtime-tables` channels behind `liveQuery` and `useLiveQuery`.
|
|
205
|
+
*/
|
|
206
|
+
interface RelayTopic {
|
|
207
|
+
readonly private: boolean;
|
|
208
|
+
/** Join with presence, so members' states reach the client. */
|
|
209
|
+
readonly presence?: boolean;
|
|
210
|
+
/** Whether clients may broadcast on it (`defineTopic`'s `send` option). */
|
|
211
|
+
readonly clientSend?: boolean;
|
|
212
|
+
/** Payload schemas per event; a send through the relay is validated. */
|
|
213
|
+
readonly events?: Readonly<Record<string, StandardSchemaV1>>;
|
|
214
|
+
/** Anything but `null` when `topic` is one of this topic's names. */
|
|
215
|
+
match(topic: string): unknown;
|
|
216
|
+
}
|
|
217
|
+
/** The channels `liveQuery` joins: `bsb:t:<schema>.<table>[:...]`, private. */
|
|
218
|
+
export declare const liveRelayTopic: RelayTopic;
|
|
219
|
+
/** What `authorize` decides on. */
|
|
220
|
+
interface RelayAccessInput {
|
|
221
|
+
readonly topic: string;
|
|
222
|
+
readonly action: "receive" | "send";
|
|
223
|
+
/** The caller: in a support session, the viewed user. */
|
|
224
|
+
readonly auth: AuthState;
|
|
225
|
+
readonly support: ActiveSupport | undefined;
|
|
226
|
+
/** The claims the check runs with: the target's in a support session. */
|
|
227
|
+
readonly claims: Readonly<Record<string, unknown>>;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Decides whether the caller may receive or send on a topic. A throw or
|
|
231
|
+
* rejection denies.
|
|
232
|
+
*/
|
|
233
|
+
type RelayAuthorize = (input: RelayAccessInput) => boolean | PromiseLike<boolean>;
|
|
234
|
+
/**
|
|
235
|
+
* The part of a server the relay uses: `createServer`, `createNext` and the
|
|
236
|
+
* other adapters fit.
|
|
237
|
+
*/
|
|
238
|
+
interface RelayServer {
|
|
239
|
+
context(request: Request, options?: {
|
|
240
|
+
readonly refresh?: boolean;
|
|
241
|
+
}): Promise<{
|
|
242
|
+
readonly auth: AuthState;
|
|
243
|
+
readonly resolution: {
|
|
244
|
+
readonly auth: AuthState;
|
|
245
|
+
};
|
|
246
|
+
readonly support?: ActiveSupport;
|
|
247
|
+
apply(response: Response): Response;
|
|
248
|
+
}>;
|
|
249
|
+
admin(): {
|
|
250
|
+
readonly $client: RealtimeClient;
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
/** A pool that runs a function in one transaction: `createPostgres()`. */
|
|
254
|
+
interface RelayPostgres {
|
|
255
|
+
transaction<T>(fn: (client: SqlClient) => Promise<T>): Promise<T>;
|
|
256
|
+
}
|
|
257
|
+
interface RealtimeRelayOptions {
|
|
258
|
+
/** The topics the relay serves; any other name answers 404. */
|
|
259
|
+
readonly topics: readonly RelayTopic[];
|
|
260
|
+
/**
|
|
261
|
+
* Checks each join and send against the `realtime.messages` policies, run as
|
|
262
|
+
* the caller (the viewed user in a support session) the way Realtime checks a
|
|
263
|
+
* browser's join. Needs a pool whose role may assume `authenticated`, such as
|
|
264
|
+
* `createPostgres()`.
|
|
265
|
+
*/
|
|
266
|
+
readonly postgres?: RelayPostgres;
|
|
267
|
+
/** Decides access instead of the policies. */
|
|
268
|
+
readonly authorize?: RelayAuthorize;
|
|
269
|
+
/**
|
|
270
|
+
* The client that joins upstream. Defaults to the server's secret-key client
|
|
271
|
+
* (`server.admin().$client`); joins of a topic share one channel per
|
|
272
|
+
* process.
|
|
273
|
+
*/
|
|
274
|
+
readonly upstream?: RealtimeClient;
|
|
275
|
+
/** Milliseconds between keep-alive comments. Defaults to 25000. */
|
|
276
|
+
readonly heartbeatMs?: number;
|
|
277
|
+
/**
|
|
278
|
+
* Milliseconds a stream stays open before it ends with `max_duration` and the
|
|
279
|
+
* client reconnects, which checks access again. Defaults to 240000, under
|
|
280
|
+
* common serverless limits.
|
|
281
|
+
*/
|
|
282
|
+
readonly maxDurationMs?: number;
|
|
283
|
+
/**
|
|
284
|
+
* Events a slow client may fall behind by before its stream ends with
|
|
285
|
+
* `overflow`; the reconnect reports a rejoin, so the client refetches.
|
|
286
|
+
* Defaults to 256.
|
|
287
|
+
*/
|
|
288
|
+
readonly maxQueued?: number;
|
|
289
|
+
/** Milliseconds the client waits before reconnecting. Defaults to 1000. */
|
|
290
|
+
readonly retryMs?: number;
|
|
291
|
+
/**
|
|
292
|
+
* Refresh an expiring session cookie and send the new cookies. Defaults to
|
|
293
|
+
* false: the proxy refreshes, and an expired session answers 401.
|
|
294
|
+
*/
|
|
295
|
+
readonly refresh?: boolean;
|
|
296
|
+
readonly problem?: ProblemFormat;
|
|
297
|
+
}
|
|
298
|
+
/** Why the relay ended a stream, in its `end` event. */
|
|
299
|
+
type RelayEndReason = "expired" | "max_duration" | "overflow" | "closed" | "upstream_error";
|
|
300
|
+
/**
|
|
301
|
+
* Whether `claims` may receive or send on `topic`, by the `realtime.messages`
|
|
302
|
+
* policies, checked the way Realtime checks a join: a probe message is
|
|
303
|
+
* inserted, then read (receive) or written (send) as the caller, and the
|
|
304
|
+
* transaction rolls back.
|
|
305
|
+
*/
|
|
306
|
+
export declare function realtimeTopicAccess(postgres: RelayPostgres, input: {
|
|
307
|
+
readonly claims: Readonly<Record<string, unknown>>;
|
|
308
|
+
readonly topic: string;
|
|
309
|
+
readonly action: "receive" | "send";
|
|
310
|
+
readonly extension?: "broadcast" | "presence";
|
|
311
|
+
}): Promise<boolean>;
|
|
312
|
+
/**
|
|
313
|
+
* Realtime for callers without a browser token of their own: a support session
|
|
314
|
+
* ("view as user"), or an app that keeps sessions in httpOnly cookies. `GET
|
|
315
|
+
* ?topic=<name>` resolves the caller, checks the topic's access as that caller
|
|
316
|
+
* (the viewed user in a support session), joins upstream with the secret key
|
|
317
|
+
* and streams the topic's broadcasts and presence as server-sent events. `POST
|
|
318
|
+
* { topic, event, payload }` broadcasts for the caller after the same check on
|
|
319
|
+
* the send policy; read-only support sessions can't send.
|
|
320
|
+
* `relayRealtimeClient(url)` from `better-supabase/realtime` is the client.
|
|
321
|
+
*
|
|
322
|
+
* ```ts
|
|
323
|
+
* // app/api/realtime/route.ts
|
|
324
|
+
* export const { GET, POST } = realtimeRelay(bsb, {
|
|
325
|
+
* topics: [notifications, liveRelayTopic],
|
|
326
|
+
* postgres,
|
|
327
|
+
* });
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
export declare function realtimeRelay(server: RelayServer, options: RealtimeRelayOptions): {
|
|
331
|
+
readonly GET: (request: Request) => Promise<Response>;
|
|
332
|
+
readonly POST: (request: Request) => Promise<Response>;
|
|
333
|
+
};
|
|
334
|
+
//#endregion
|
|
197
335
|
//#region src/server/entries/upstream.d.ts
|
|
198
336
|
/** The `withSupabase` context keys `withBetterDb` and `withBetterPostgres` read. */
|
|
199
337
|
interface SupabaseAuthContext {
|
|
@@ -500,4 +638,4 @@ export declare function withDbStats(options?: {
|
|
|
500
638
|
};
|
|
501
639
|
}, () => DbStats>;
|
|
502
640
|
//#endregion
|
|
503
|
-
export { AUTH_CACHE_HEADERS, type Aal, type AccessTokenResolverOptions, type AccessTokenRevocation, type AccountEventType, type ActClaim, type ActionResult, type ActiveSupport, type ActorOutcome, type AdminDb, type AgentActOptions, type AmrEntry, type AnyAuthorizer, type ApprovalRequestRef, type Approver, type ApproverOf, type AuthKind, type AuthOutageHook, type AuthResolution, type AuthResolver, type AuthSession, type AuthState, type AuthorizationHooks, type AuthorizationOutcome, type AuthorizationRequest, type AuthorizationResource, type AuthorizationSubject, type AuthorizeOptions, type AuthorizedContext, type Authorizer, type AuthorizerRuntime, type AuthzVersionCache, type AuthzVersionChannel, type AuthzVersionClient, type AuthzVersionSubscription, type AutomationHooks, type AutomationRef, type BetterServer, type BetterSupabaseConfig, type BetterSupabaseContributions, type BetterSupabaseEntry, type BlockActionOptions, type BlockRequireOptions, type ChatAction, type ChatActionHook, type ClearSessionCookiesOptions, type ContextOptions, type CookieOptions, type CookieRecord, type CookieWrite, type CsvOptions, type CsvResponseOptions, type DelegationPermissions, type DelegationRef, type DeleteAccountOptions, type DeleteAccountResult, type EndSessionsResult, type ForContextOptions, type GuardEntryConfig, type GuardOptions, type HandleOptions, IDENTITY_SCOPES, type IdentityRef, type IdentityTarget, type ImpersonationEvents, type ImpersonationOptions, type Impersonator, type InvalidReason, type LastSignIn, type LiteDriver, type MiddlewareOptions, PERMISSION_CAP_CLAIM, PRIMARY_COOKIE, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, type PasswordGrantOptions, type PermissionRef, type PrincipalByIdentity, type ProblemDetails, type ProblemOptions, type ProblemResponseOptions, type RateLimitPolicy, type RateLimitState, type RefreshOutcome, type RefreshPolicy, type ReplicaState, type RequestIdOptions, type RequestMemo, type ResolveAuthOptions, type ResolvedState, type ResourceHandler, type ResourceInput, type ResourceList, type ResourceLoaderContext, type ResourcePagination, type ResourceRouteOptions, type RespondOptions, SUPPORT_COOKIE, type ServerContext, type ServerCore, type ServerDbOptions, type ServerOptions, type ServerTiming, type SessionActor, type SessionDelegation, type SessionEntryConfig, type SessionLookup, type SessionMemo, type SessionMemoOptions, type SessionMemoStats, type SessionSnapshot, type SessionStatus, type SessionStatusOptions, type Settled, type SqlSupportStoreOptions, type StoredSession, type SubjectReadersOptions, type SubscribeAuthzVersionsOptions, type Subscriber, type SubscriberEvent, type SubscriberPolicy, type SupabaseAuthContext, type SupportApi, type SupportApprovalQuery, type SupportApprover, type SupportAuthorize, type SupportAuthorizeInput, type SupportCallerClaims, type SupportCookieOptions, type SupportDecision, type SupportEndedBy, type SupportExpireRouteOptions, type SupportListFilter, type SupportOptions, type SupportPolicy, type SupportRequest, type SupportRequestInput, type SupportSession, type SupportSessionStore, type SupportSessions, type SupportStartInput, type SupportStartRequest, type SupportStorageOptions, type SupportView, type SuspendAccountOptions, type SuspendAccountResult, TENANT_HEADER, type TagOptions, type TicketSubject, aalOf, actorOf, agentClaims, amrOf, authContext, authzVersionOf, bindAuthorizer, cacheTagsOf, checkAal, clearSessionCookies, clearSupportCookie, clientIp, csvColumns, defineAuthorizationHooks, defineAuthorizer, delegationOf, deleteAccount, endSessions, fromProblem, guard, hasRole, impersonatorOf, isPrefetch, isProblem, isResult, isSessionSnapshot, issuedAtOf, lastSignIns, passwordGrant, problemResponse, readSession, refreshFor, refreshSession, requestMemo, resolveAuth, respond, rolesAt, safeRedirectPath, serverCore, sessionCacheKey, sessionCookieName, sessionMemo, sessionStatus, settle, shouldCheckSession, shouldRefresh, snapshotOf, sqlSupportStore, subjectReaders, supportClaims, supportCookie, supportCookieValue, supportOf, supportSessions, suspendAccount, tagCache, tagFor, toCsv, toProblem, toSession, withBetterSupabase, withGuard, withSession, writeSession };
|
|
641
|
+
export { AUTH_CACHE_HEADERS, type Aal, type AccessTokenResolverOptions, type AccessTokenRevocation, type AccountEventType, type ActClaim, type ActionResult, type ActiveSupport, type ActorOutcome, type AdminDb, type AgentActOptions, type AmrEntry, type AnyAuthorizer, type ApprovalRequestRef, type Approver, type ApproverOf, type AuthKind, type AuthOutageHook, type AuthResolution, type AuthResolver, type AuthSession, type AuthState, type AuthorizationHooks, type AuthorizationOutcome, type AuthorizationRequest, type AuthorizationResource, type AuthorizationSubject, type AuthorizeOptions, type AuthorizedContext, type Authorizer, type AuthorizerRuntime, type AuthzVersionCache, type AuthzVersionChannel, type AuthzVersionClient, type AuthzVersionSubscription, type AutomationHooks, type AutomationRef, type BetterServer, type BetterSupabaseConfig, type BetterSupabaseContributions, type BetterSupabaseEntry, type BlockActionOptions, type BlockRequireOptions, type ChatAction, type ChatActionHook, type ClearSessionCookiesOptions, type ContextOptions, type CookieOptions, type CookieRecord, type CookieWrite, type CsvOptions, type CsvResponseOptions, type DelegationPermissions, type DelegationRef, type DeleteAccountOptions, type DeleteAccountResult, type EndSessionsResult, type ForContextOptions, type GuardEntryConfig, type GuardOptions, type HandleOptions, IDENTITY_SCOPES, type IdentityRef, type IdentityTarget, type ImpersonationEvents, type ImpersonationOptions, type Impersonator, type InvalidReason, type LastSignIn, type LiteDriver, type MiddlewareOptions, PERMISSION_CAP_CLAIM, PRIMARY_COOKIE, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, type PasswordGrantOptions, type PermissionRef, type PrincipalByIdentity, type ProblemDetails, type ProblemOptions, type ProblemResponseOptions, type RateLimitPolicy, type RateLimitState, type RealtimeRelayOptions, type RefreshOutcome, type RefreshPolicy, type RelayAccessInput, type RelayAuthorize, type RelayEndReason, type RelayPostgres, type RelayServer, type RelayTopic, type ReplicaState, type RequestIdOptions, type RequestMemo, type ResolveAuthOptions, type ResolvedState, type ResourceHandler, type ResourceInput, type ResourceList, type ResourceLoaderContext, type ResourcePagination, type ResourceRouteOptions, type RespondOptions, SUPPORT_COOKIE, type ServerContext, type ServerCore, type ServerDbOptions, type ServerOptions, type ServerTiming, type SessionActor, type SessionDelegation, type SessionEntryConfig, type SessionLookup, type SessionMemo, type SessionMemoOptions, type SessionMemoStats, type SessionSnapshot, type SessionStatus, type SessionStatusBody, type SessionStatusOptions, type SessionStatusRouteOptions, type SessionStatusServer, type SessionWatchStatus, type Settled, type SqlSupportStoreOptions, type StoredSession, type SubjectReadersOptions, type SubscribeAuthzVersionsOptions, type Subscriber, type SubscriberEvent, type SubscriberPolicy, type SupabaseAuthContext, type SupportApi, type SupportApprovalQuery, type SupportApprover, type SupportAuthorize, type SupportAuthorizeInput, type SupportCallerClaims, type SupportCookieOptions, type SupportDecision, type SupportEndedBy, type SupportExpireRouteOptions, type SupportListFilter, type SupportOptions, type SupportPolicy, type SupportRequest, type SupportRequestInput, type SupportSession, type SupportSessionStore, type SupportSessions, type SupportStartInput, type SupportStartRequest, type SupportStorageOptions, type SupportView, type SuspendAccountOptions, type SuspendAccountResult, TENANT_HEADER, type TagOptions, type TicketSubject, aalOf, actorOf, agentClaims, amrOf, authContext, authzVersionOf, bindAuthorizer, cacheTagsOf, checkAal, claimsFingerprint, clearSessionCookies, clearSupportCookie, clientIp, csvColumns, defineAuthorizationHooks, defineAuthorizer, delegationOf, deleteAccount, endSessions, fromProblem, guard, hasRole, impersonatorOf, isPrefetch, isProblem, isResult, isSessionSnapshot, issuedAtOf, lastSignIns, passwordGrant, problemResponse, readSession, refreshFor, refreshSession, requestMemo, resolveAuth, respond, rolesAt, safeRedirectPath, serverCore, sessionCacheKey, sessionCookieName, sessionMemo, sessionStatus, sessionStatusRoute, settle, shouldCheckSession, shouldRefresh, snapshotOf, sqlSupportStore, subjectReaders, supportClaims, supportCookie, supportCookieValue, supportOf, supportSessions, suspendAccount, tagCache, tagFor, toCsv, toProblem, toSession, withBetterSupabase, withGuard, withSession, writeSession };
|