better-supabase 0.6.1 → 0.7.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.
Files changed (107) hide show
  1. package/dist/{adapter-CHnPkCPd.js → adapter-B-tL8hqg.js} +29 -4
  2. package/dist/ai-sdk/batches/index.d.ts +1 -1
  3. package/dist/ai-sdk/index.d.ts +1 -1
  4. package/dist/ai-sdk/mcp/index.d.ts +3 -3
  5. package/dist/{api-keys-rCGtKaZA.d.ts → api-keys-CIjghYjV.d.ts} +1 -1
  6. package/dist/astro/index.d.ts +4 -4
  7. package/dist/astro/index.js +2 -2
  8. package/dist/blocks/ai-providers/index.d.ts +1 -1
  9. package/dist/blocks/api-keys/index.d.ts +2 -2
  10. package/dist/blocks/audit/index.js +1 -1
  11. package/dist/blocks/connectors/index.d.ts +1 -1
  12. package/dist/blocks/data-lifecycle/index.d.ts +1 -1
  13. package/dist/blocks/data-lifecycle/index.js +1 -1
  14. package/dist/blocks/entitlements/index.d.ts +1 -1
  15. package/dist/blocks/index.d.ts +1 -1
  16. package/dist/blocks/sso/index.d.ts +1 -1
  17. package/dist/blocks/workflow-builder/index.d.ts +2 -2
  18. package/dist/blocks/workflow-builder/react/index.d.ts +1 -1
  19. package/dist/chat-sdk/index.d.ts +1 -1
  20. package/dist/cli/bin.js +1 -1
  21. package/dist/cli/{doctor-BMqBgM3X.js → doctor-CVdnLahA.js} +66 -14
  22. package/dist/cli/{gen-DeuDgPxN.js → gen-AIf4MREI.js} +1 -1
  23. package/dist/cli/gen-DSrahEdX.js +2 -0
  24. package/dist/cli/index.d.ts +1 -1
  25. package/dist/cli/index.js +3 -3
  26. package/dist/cli/{init-C7Xd0Kda.js → init-Cr6arjXU.js} +1 -1
  27. package/dist/cli/{introspect-CSnMJ94U.js → introspect-Bzuv1HHj.js} +1 -1
  28. package/dist/cli/{run-C8tnlHSb.js → run-BO052mki.js} +7 -7
  29. package/dist/cli/{sql-D0GUtUPp.js → sql-B8csQPyn.js} +13 -54
  30. package/dist/cli/sql-layout-D6cphHT3.js +69 -0
  31. package/dist/cli/{version-C_4JwyiM.js → version-Bp4fyubI.js} +1 -1
  32. package/dist/{composite-CLqs9-OA.js → composite-C6I8ZyaF.js} +1 -1
  33. package/dist/{composite-pSfeJNce.d.ts → composite-CpHLEo-G.d.ts} +3 -3
  34. package/dist/{connectors-hkLCwyEz.d.ts → connectors-CrpknU0P.d.ts} +1 -1
  35. package/dist/credentials/index.d.ts +2 -2
  36. package/dist/{csv-CPAzEmB6.js → csv-DCK-PT1n.js} +1 -1
  37. package/dist/edge/index.d.ts +5 -5
  38. package/dist/edge/index.js +3 -3
  39. package/dist/elysia/index.d.ts +1 -1
  40. package/dist/{ended-jLfvw8h-.d.ts → ended-XjeGQ5XW.d.ts} +4 -1
  41. package/dist/{entitlements-DHrY2UDZ.d.ts → entitlements-BKSVGtrG.d.ts} +1 -1
  42. package/dist/eve/index.d.ts +2 -2
  43. package/dist/eve/index.js +1 -1
  44. package/dist/{executor-D14tGopJ.d.ts → executor-BVBFM86G.d.ts} +1 -1
  45. package/dist/expo/index.d.ts +2 -2
  46. package/dist/expo/index.js +3 -3
  47. package/dist/{framework-xjTBoyBB.js → framework-BDCpJI7o.js} +1 -1
  48. package/dist/{framework-CdPDPpFs.d.ts → framework-KIPvRQJU.d.ts} +4 -4
  49. package/dist/h3/index.d.ts +1 -1
  50. package/dist/h3/v1/index.d.ts +1 -1
  51. package/dist/hono/index.d.ts +6 -6
  52. package/dist/hono/index.js +2 -2
  53. package/dist/{index-DDrYaUcq.d.ts → index-CdZKQF98.d.ts} +1 -1
  54. package/dist/{index-CtuakVRc.d.ts → index-CewnYSpv.d.ts} +1 -1
  55. package/dist/{kit-B5tid-q5.d.ts → kit-CkNzZUqv.d.ts} +3 -3
  56. package/dist/mcp/index.d.ts +3 -3
  57. package/dist/mcp/index.js +1 -1
  58. package/dist/mcp/sdk/index.d.ts +3 -3
  59. package/dist/mcp/sdk/index.js +1 -1
  60. package/dist/nestjs/index.d.ts +2 -2
  61. package/dist/next/index.d.ts +13 -8
  62. package/dist/next/index.js +5 -5
  63. package/dist/node/index.d.ts +2 -2
  64. package/dist/orpc/index.d.ts +4 -4
  65. package/dist/orpc/index.js +1 -1
  66. package/dist/otel/index.js +5 -5
  67. package/dist/{provider-BH5UWZJ6.d.ts → provider-D-UEMvSD.d.ts} +1 -1
  68. package/dist/react/index.d.ts +5 -5
  69. package/dist/react/server.d.ts +5 -5
  70. package/dist/react/session.d.ts +2 -2
  71. package/dist/react-router/index.d.ts +4 -4
  72. package/dist/react-router/index.js +2 -2
  73. package/dist/{refusal-D1rgbzNq.d.ts → refusal-DhSU2Vvr.d.ts} +1 -1
  74. package/dist/{resolve-KW8nCeL6.d.ts → resolve-ChTYeTEl.d.ts} +3 -0
  75. package/dist/{resolve-D_IcnvFd.js → resolve-tJZY3FEa.js} +12 -7
  76. package/dist/{resource-D6Uc7Sk7.d.ts → resource-IPS5xi9q.d.ts} +1 -1
  77. package/dist/{respond-DoBijysA.d.ts → respond-DprrgyXX.d.ts} +1 -1
  78. package/dist/server/index.d.ts +47 -10
  79. package/dist/server/index.js +27 -5
  80. package/dist/{server-C6DWVEVG.d.ts → server-ZSJ9rCcV.d.ts} +14 -3
  81. package/dist/solid/index.d.ts +2 -2
  82. package/dist/solid-start/index.d.ts +4 -4
  83. package/dist/solid-start/index.js +2 -2
  84. package/dist/sql/index.d.ts +10 -0
  85. package/dist/sql/index.js +52 -5
  86. package/dist/ssr/index.d.ts +4 -4
  87. package/dist/ssr/index.js +1 -1
  88. package/dist/{support-zIa1URaN.js → support-DWwzVf-O.js} +1 -1
  89. package/dist/{support-view-33Oi07TT.d.ts → support-view-CVOJJLpc.d.ts} +1 -1
  90. package/dist/svelte/index.d.ts +1 -1
  91. package/dist/sveltekit/index.d.ts +4 -4
  92. package/dist/sveltekit/index.js +2 -2
  93. package/dist/tanstack-start/index.d.ts +4 -4
  94. package/dist/tanstack-start/index.js +2 -2
  95. package/dist/{tenant-icPeuUBN.d.ts → tenant-BxNFk9bx.d.ts} +1 -1
  96. package/dist/testing/index.d.ts +5 -5
  97. package/dist/{types-TaiEeBGA.d.ts → types-6rocye-y.d.ts} +1 -1
  98. package/dist/{types-BI-0Sl2v.d.ts → types-AYOvcyep.d.ts} +1 -1
  99. package/dist/{vault-CSO7ss5C.d.ts → vault-wlbBhqm7.d.ts} +1 -1
  100. package/dist/vercel-connect/index.d.ts +1 -1
  101. package/dist/{version-CQt77F3T.js → version--AolB5ej.js} +1 -1
  102. package/dist/{view-DbxLNu8L.d.ts → view-CF7ihnkg.d.ts} +1 -1
  103. package/dist/vue/index.d.ts +2 -2
  104. package/dist/workflow-sdk/builder/index.d.ts +2 -2
  105. package/package.json +1 -1
  106. package/schemas/doctor-report-v1.json +2 -0
  107. package/dist/cli/gen-4JlOwgWG.js +0 -2
@@ -1,11 +1,11 @@
1
1
  import { b as DbError, f as Result } from "../result-D7y2fT87.js";
2
2
  import { a as AnyModels, i as AnyFunctions } from "../types-6BdhkmZe.js";
3
- import { r as AuthState } from "../resolve-KW8nCeL6.js";
3
+ import { r as AuthState } from "../resolve-ChTYeTEl.js";
4
4
  import { i as ProblemDetails } from "../problem-DD8LZFjc.js";
5
5
  import { t as BetterSupabase } from "../define-CJJkkr1-.js";
6
- import { i as ServerContext, o as ServerOptions, t as BetterServer } from "../server-C6DWVEVG.js";
7
- import { i as MiddlewareOptions, r as GuardOptions } from "../respond-DoBijysA.js";
8
- import { s as BlockRequireOptions } from "../kit-B5tid-q5.js";
6
+ import { i as ServerContext, o as ServerOptions, t as BetterServer } from "../server-ZSJ9rCcV.js";
7
+ import { i as MiddlewareOptions, r as GuardOptions } from "../respond-DprrgyXX.js";
8
+ import { s as BlockRequireOptions } from "../kit-CkNzZUqv.js";
9
9
  import { t as Validated } from "../shared-DDSjEGDR.js";
10
10
  import { AnyEntry, Contributions } from "@supabase/middleware";
11
11
  import { BuilderWithMiddlewares, DecoratedMiddleware, ORPCError } from "@orpc/server";
@@ -2,7 +2,7 @@ import { r as dbErrorOf } from "../errors-B11Duf73.js";
2
2
  import { o as toProblem } from "../problem-BreOl8b8.js";
3
3
  import { i as claimsOf } from "../claims-PqzCxaTD.js";
4
4
  import { t as tenantOf } from "../tenant-I1TEZ_BX.js";
5
- import { c as extendServer, n as flushEvents, s as createServer, y as refreshFor } from "../adapter-CHnPkCPd.js";
5
+ import { c as extendServer, n as flushEvents, s as createServer, y as refreshFor } from "../adapter-B-tL8hqg.js";
6
6
  import { n as toSession } from "../view-BeFcRV6G.js";
7
7
  import { o as settle, r as guard, t as defaultExpose } from "../respond-BUgsXNgk.js";
8
8
  import { t as authorizeCaller } from "../kit-Fm-Fv7q5.js";
@@ -1,7 +1,7 @@
1
1
  import { r as definePlugin } from "../plugin-tfXW1-qO.js";
2
2
  import { t as SPEC_PINS } from "../spec-pins--j6mTok4.js";
3
3
  import { r as blockEventAttributes } from "../block-events-CrT8r7Fe.js";
4
- import "../version-CQt77F3T.js";
4
+ import "../version--AolB5ej.js";
5
5
  import { SpanKind, SpanStatusCode, context, metrics, propagation, trace } from "@opentelemetry/api";
6
6
  //#region src/otel/index.ts
7
7
  const INSTRUMENTATION_NAME = "better-supabase";
@@ -40,9 +40,9 @@ function systemOf(executor) {
40
40
  * ```
41
41
  */
42
42
  function otel(options = {}) {
43
- const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.6.1");
43
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.7.0");
44
44
  let histogram;
45
- if (options.metrics !== false) histogram = (options.meter ?? metrics.getMeter("better-supabase", "0.6.1")).createHistogram("db.client.operation.duration", {
45
+ if (options.metrics !== false) histogram = (options.meter ?? metrics.getMeter("better-supabase", "0.7.0")).createHistogram("db.client.operation.duration", {
46
46
  unit: "s",
47
47
  description: "Duration of database client operations.",
48
48
  advice: { explicitBucketBoundaries: [
@@ -181,7 +181,7 @@ function otel(options = {}) {
181
181
  * Returns a function that stops listening.
182
182
  */
183
183
  function traceAuth(betterSupabase, options = {}) {
184
- const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.6.1");
184
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.7.0");
185
185
  const offAuth = betterSupabase.events.on("auth", (event) => {
186
186
  const span = tracer.startSpan("auth.resolve", {
187
187
  kind: SpanKind.INTERNAL,
@@ -219,7 +219,7 @@ function traceAuth(betterSupabase, options = {}) {
219
219
  * set an error status. Returns a function that stops listening.
220
220
  */
221
221
  function traceBlockEvents(betterSupabase, options = {}) {
222
- const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.6.1");
222
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.7.0");
223
223
  return betterSupabase.events.on("block", (event) => {
224
224
  const attributes = {
225
225
  ...options.attributes,
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="esnext.temporal" />
2
2
  import { b as DbError, t as AsyncResult } from "./result-D7y2fT87.js";
3
- import { r as AuthState } from "./resolve-KW8nCeL6.js";
3
+ import { r as AuthState } from "./resolve-ChTYeTEl.js";
4
4
  //#region src/credentials/provider.d.ts
5
5
  /**
6
6
  * Names a credential without holding it. Tables store this as a
@@ -1,12 +1,12 @@
1
1
  import { t as escapeLike } from "../escape-like-ImTK0ps_.js";
2
2
  import { s as Impersonator } from "../mfa-Daak8ukG.js";
3
- import { t as tenantOf } from "../tenant-icPeuUBN.js";
4
- import { t as AuthSession } from "../view-DbxLNu8L.js";
3
+ import { t as tenantOf } from "../tenant-BxNFk9bx.js";
4
+ import { t as AuthSession } from "../view-CF7ihnkg.js";
5
5
  import { r as LiveCountSeed } from "../index-DunNRdnT.js";
6
- import { r as MembershipClaim } from "../entitlements-DHrY2UDZ.js";
7
- import { n as supportOf, t as SupportView } from "../support-view-33Oi07TT.js";
6
+ import { r as MembershipClaim } from "../entitlements-BKSVGtrG.js";
7
+ import { n as supportOf, t as SupportView } from "../support-view-CVOJJLpc.js";
8
8
  import { a as BroadcastOptions, f as UseActionOptions, l as LiveQueryHookOptions, n as ActionInputOf, o as ClientLike, r as ActionResultOf, s as LiveCountHookOptions, t as fieldErrorsOf } from "../field-errors-BFOa7WhB.js";
9
- import { A as useLiveCount, C as BetterSupabaseProviderProps, D as createHooks, E as ProfileOf, M as useSupabase, O as useAuth, S as BetterSupabaseProvider, T as LiveCount, _ as ActionHandle, a as UploadTarget, b as useActionForm, c as useUpload, d as useDebouncedSearch, f as Presence, g as ActionForm, h as usePresence, i as UploadStatus, j as useLiveQuery, k as useBroadcast, l as DebouncedSearch, m as PresenceTopic, n as SignedUrlSource, o as UseUploadOptions, p as PresenceHookOptions, r as Upload, s as useSignedUrl, t as SignedUrl, u as DebouncedSearchOptions, v as UseActionFormOptions, w as ClaimsOf, x as BetterHooks, y as useAction } from "../index-CtuakVRc.js";
9
+ import { A as useLiveCount, C as BetterSupabaseProviderProps, D as createHooks, E as ProfileOf, M as useSupabase, O as useAuth, S as BetterSupabaseProvider, T as LiveCount, _ as ActionHandle, a as UploadTarget, b as useActionForm, c as useUpload, d as useDebouncedSearch, f as Presence, g as ActionForm, h as usePresence, i as UploadStatus, j as useLiveQuery, k as useBroadcast, l as DebouncedSearch, m as PresenceTopic, n as SignedUrlSource, o as UseUploadOptions, p as PresenceHookOptions, r as Upload, s as useSignedUrl, t as SignedUrl, u as DebouncedSearchOptions, v as UseActionFormOptions, w as ClaimsOf, x as BetterHooks, y as useAction } from "../index-CewnYSpv.js";
10
10
  import { SessionProvider, SessionProviderProps, useSession, useSupportSession } from "./session.js";
11
11
  import { a as useSignIn, i as SignOut, n as PendingState, o as useSignOut, r as SignIn, t as AuthHookOptions } from "../sign-in-BCV5S2WZ.js";
12
12
  export { type ActionForm, type ActionHandle, type ActionInputOf, type ActionResultOf, type AuthHookOptions, type AuthSession, type BetterHooks, BetterSupabaseProvider, type BetterSupabaseProviderProps, type BroadcastOptions, type ClaimsOf, type ClientLike, type DebouncedSearch, type DebouncedSearchOptions, type Impersonator, type LiveCount, type LiveCountHookOptions, type LiveCountSeed, type LiveQueryHookOptions, type MembershipClaim, type PendingState, type Presence, type PresenceHookOptions, type PresenceTopic, type ProfileOf, SessionProvider, type SessionProviderProps, type SignIn, type SignOut, type SignedUrl, type SignedUrlSource, type SupportView, type Upload, type UploadStatus, type UploadTarget, type UseActionFormOptions, type UseActionOptions, type UseUploadOptions, createHooks, escapeLike, fieldErrorsOf, supportOf, tenantOf, useAction, useActionForm, useAuth, useBroadcast, useDebouncedSearch, useLiveCount, useLiveQuery, usePresence, useSession, useSignIn, useSignOut, useSignedUrl, useSupabase, useSupportSession, useUpload };
@@ -1,13 +1,13 @@
1
1
  import { t as escapeLike } from "../escape-like-ImTK0ps_.js";
2
2
  import { it as QuerySpec } from "../define-CJJkkr1-.js";
3
3
  import { s as Impersonator } from "../mfa-Daak8ukG.js";
4
- import { t as tenantOf } from "../tenant-icPeuUBN.js";
5
- import { t as AuthSession } from "../view-DbxLNu8L.js";
4
+ import { t as tenantOf } from "../tenant-BxNFk9bx.js";
5
+ import { t as AuthSession } from "../view-CF7ihnkg.js";
6
6
  import { r as LiveCountSeed } from "../index-DunNRdnT.js";
7
- import { r as MembershipClaim } from "../entitlements-DHrY2UDZ.js";
8
- import { n as supportOf, t as SupportView } from "../support-view-33Oi07TT.js";
7
+ import { r as MembershipClaim } from "../entitlements-BKSVGtrG.js";
8
+ import { n as supportOf, t as SupportView } from "../support-view-CVOJJLpc.js";
9
9
  import { a as BroadcastOptions, f as UseActionOptions, l as LiveQueryHookOptions, n as ActionInputOf, o as ClientLike, r as ActionResultOf, s as LiveCountHookOptions, t as fieldErrorsOf } from "../field-errors-BFOa7WhB.js";
10
- import { C as BetterSupabaseProviderProps, E as ProfileOf, M as useSupabase, O as useAuth, S as BetterSupabaseProvider, T as LiveCount, _ as ActionHandle, a as UploadTarget, c as useUpload$1, d as useDebouncedSearch$1, f as Presence, g as ActionForm, h as usePresence$1, i as UploadStatus, j as useLiveQuery, k as useBroadcast, l as DebouncedSearch, m as PresenceTopic, n as SignedUrlSource, o as UseUploadOptions, p as PresenceHookOptions, r as Upload, s as useSignedUrl$1, t as SignedUrl, u as DebouncedSearchOptions, v as UseActionFormOptions, w as ClaimsOf, x as BetterHooks } from "../index-CtuakVRc.js";
10
+ import { C as BetterSupabaseProviderProps, E as ProfileOf, M as useSupabase, O as useAuth, S as BetterSupabaseProvider, T as LiveCount, _ as ActionHandle, a as UploadTarget, c as useUpload$1, d as useDebouncedSearch$1, f as Presence, g as ActionForm, h as usePresence$1, i as UploadStatus, j as useLiveQuery, k as useBroadcast, l as DebouncedSearch, m as PresenceTopic, n as SignedUrlSource, o as UseUploadOptions, p as PresenceHookOptions, r as Upload, s as useSignedUrl$1, t as SignedUrl, u as DebouncedSearchOptions, v as UseActionFormOptions, w as ClaimsOf, x as BetterHooks } from "../index-CewnYSpv.js";
11
11
  import { SessionProvider, SessionProviderProps } from "./session.js";
12
12
  import { a as useSignIn$1, i as SignOut, n as PendingState, o as useSignOut$1, r as SignIn, t as AuthHookOptions } from "../sign-in-BCV5S2WZ.js";
13
13
  //#region src/react/server.d.ts
@@ -1,5 +1,5 @@
1
- import { t as AuthSession } from "../view-DbxLNu8L.js";
2
- import { t as SupportView } from "../support-view-33Oi07TT.js";
1
+ import { t as AuthSession } from "../view-CF7ihnkg.js";
2
+ import { t as SupportView } from "../support-view-CVOJJLpc.js";
3
3
  import { ReactNode } from "react";
4
4
  //#region src/react/session.d.ts
5
5
  export interface SessionProviderProps {
@@ -1,9 +1,9 @@
1
1
  import { a as AnyModels, i as AnyFunctions } from "../types-6BdhkmZe.js";
2
2
  import { t as BetterSupabase } from "../define-CJJkkr1-.js";
3
- import { t as BetterServer } from "../server-C6DWVEVG.js";
4
- import { a as AuthorizedContext, c as Unwrapped, i as AuthorizeOptions, n as ActionParsed, o as BlockActionOptions, r as ActionResult, s as BlockRequireOptions } from "../kit-B5tid-q5.js";
5
- import { t as RefusalRedirects } from "../refusal-D1rgbzNq.js";
6
- import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-CdPDPpFs.js";
3
+ import { t as BetterServer } from "../server-ZSJ9rCcV.js";
4
+ import { a as AuthorizedContext, c as Unwrapped, i as AuthorizeOptions, n as ActionParsed, o as BlockActionOptions, r as ActionResult, s as BlockRequireOptions } from "../kit-CkNzZUqv.js";
5
+ import { t as RefusalRedirects } from "../refusal-DhSU2Vvr.js";
6
+ import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-KIPvRQJU.js";
7
7
  import { t as Validated } from "../shared-DDSjEGDR.js";
8
8
  import { AnyEntry, Contributions } from "@supabase/middleware";
9
9
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -1,9 +1,9 @@
1
1
  import { a as problemResponse } from "../problem-BreOl8b8.js";
2
- import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-CHnPkCPd.js";
2
+ import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-B-tL8hqg.js";
3
3
  import { o as settle, t as defaultExpose } from "../respond-BUgsXNgk.js";
4
4
  import { i as requireCaller, o as runAction } from "../kit-Fm-Fv7q5.js";
5
5
  import { n as bufferInPlace, t as around } from "../shared-CBxosKK3.js";
6
- import { i as localsOf, n as actionInput, r as frameworkEntry } from "../framework-xjTBoyBB.js";
6
+ import { i as localsOf, n as actionInput, r as frameworkEntry } from "../framework-BDCpJI7o.js";
7
7
  import { r as refusalResponse } from "../refusal-CeJWxmkH.js";
8
8
  //#region src/bridges/react-router.ts
9
9
  /**
@@ -1,4 +1,4 @@
1
- import { s as BlockRequireOptions } from "./kit-B5tid-q5.js";
1
+ import { s as BlockRequireOptions } from "./kit-CkNzZUqv.js";
2
2
  //#region src/server/refusal.d.ts
3
3
  /** Where refused callers go instead of a Problem Details response. */
4
4
  interface RefusalRedirects {
@@ -147,7 +147,10 @@ interface AuthResolution<C = unknown, P = unknown> {
147
147
  readonly requestCookies: readonly CookieRecord[];
148
148
  /** Adds `cookies` and `headers` to a response. */
149
149
  apply(response: Response): Response;
150
+ /** The session was ended server-side (revoked, deleted or banned); the cookies are cleared. */
150
151
  readonly sessionEnded?: boolean;
152
+ /** Why `sessionEnded` is set: `banned` when Auth rejected the user as banned. */
153
+ readonly sessionEndedReason?: "ended" | "banned";
151
154
  }
152
155
  /** The first `x-forwarded-for` hop, the client as your edge saw it. */
153
156
  declare function clientIp(request: Request): string | undefined;
@@ -164,8 +164,8 @@ async function sessionStatus(input, options) {
164
164
  },
165
165
  signal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS$1)
166
166
  });
167
+ if (response.status === 401 || response.status === 403) return (await response.json().catch(() => null))?.["error_code"] === "user_banned" ? "banned" : "ended";
167
168
  await response.body?.cancel();
168
- if (response.status === 401 || response.status === 403) return "ended";
169
169
  return response.ok ? "active" : "unknown";
170
170
  } catch {
171
171
  return "unknown";
@@ -237,6 +237,7 @@ async function request(refreshToken, options, now) {
237
237
  ok: false,
238
238
  reason: response.status >= 500 || response.status === 429 ? "network" : "rejected",
239
239
  status: response.status,
240
+ ...typeof body?.["error_code"] === "string" ? { code: body["error_code"] } : {},
240
241
  message
241
242
  };
242
243
  }
@@ -502,12 +503,15 @@ async function verifyOnce(credentials, modes, options, source) {
502
503
  reason: "none"
503
504
  };
504
505
  }
505
- function resolution(auth, cookies, writes = [], ended = false) {
506
+ function resolution(auth, cookies, writes = [], ended) {
506
507
  const headers = writes.length > 0 ? AUTH_CACHE_HEADERS : {};
507
508
  let requestCookies;
508
509
  return {
509
510
  auth,
510
- ...ended ? { sessionEnded: true } : {},
511
+ ...ended ? {
512
+ sessionEnded: true,
513
+ sessionEndedReason: ended
514
+ } : {},
511
515
  cookies: writes,
512
516
  headers,
513
517
  /** Parsed on first read: bearer requests rarely need their cookies. */
@@ -588,16 +592,17 @@ async function resolveAuth(request, options) {
588
592
  token: session.access_token,
589
593
  apikey: null
590
594
  }, ["user"], options, "cookie");
591
- if (state.kind === "user" && options.checkSession && await sessionStatus(state.token, {
595
+ const status = state.kind === "user" && options.checkSession ? await sessionStatus(state.token, {
592
596
  url: options.env.url,
593
597
  publishableKey: options.env.publishableKey,
594
598
  ...options.fetch ? { fetch: options.fetch } : {},
595
599
  ...options.refreshTimeoutMs === void 0 ? {} : { timeoutMs: options.refreshTimeoutMs },
596
600
  ...options.now ? { now: options.now } : {}
597
- }) === "ended") return resolution({
601
+ }) : void 0;
602
+ if (status === "ended" || status === "banned") return resolution({
598
603
  kind: "anon",
599
604
  reason: "signed_out"
600
- }, cookies, options.refresh ? writeSession(cookies(), name, null, options.cookie?.options, encoding) : [], true);
605
+ }, cookies, options.refresh ? writeSession(cookies(), name, null, options.cookie?.options, encoding) : [], status);
601
606
  if (state.kind !== "invalid" || state.reason !== "token" || state.error.kind === "network") return resolution(state, cookies);
602
607
  if (!options.refresh) return resolution({
603
608
  kind: "anon",
@@ -643,7 +648,7 @@ async function resolveAuth(request, options) {
643
648
  return resolution({
644
649
  kind: "anon",
645
650
  reason: "signed_out"
646
- }, cookies, writeSession(cookies(), name, null, options.cookie?.options, encoding));
651
+ }, cookies, writeSession(cookies(), name, null, options.cookie?.options, encoding), outcome.code === "user_banned" ? "banned" : void 0);
647
652
  }
648
653
  const writes = writeSession(cookies(), name, outcome.session, options.cookie?.options, encoding);
649
654
  return resolution(await verify({
@@ -1,7 +1,7 @@
1
1
  import { E as ValidationIssue, f as Result } from "./result-D7y2fT87.js";
2
2
  import { H as Update, L as TableKey, R as TableMeta, a as AnyModels, i as AnyFunctions, x as Insert } from "./types-6BdhkmZe.js";
3
3
  import { It as SelectArg, t as BetterSupabase } from "./define-CJJkkr1-.js";
4
- import { a as RespondOptions } from "./respond-DoBijysA.js";
4
+ import { a as RespondOptions } from "./respond-DprrgyXX.js";
5
5
  import { i as ResourceOperation } from "./index-Bxih3l0u.js";
6
6
  import { StandardSchemaV1 } from "@standard-schema/spec";
7
7
  //#region src/server/resource.d.ts
@@ -1,5 +1,5 @@
1
1
  import { b as DbError } from "./result-D7y2fT87.js";
2
- import { r as AuthState } from "./resolve-KW8nCeL6.js";
2
+ import { r as AuthState } from "./resolve-ChTYeTEl.js";
3
3
  import { t as Aal } from "./mfa-Daak8ukG.js";
4
4
  //#region src/server/refresh.d.ts
5
5
  /** A router or browser prefetch, by its request headers. */
@@ -2,24 +2,61 @@ import { b as DbError } from "../result-D7y2fT87.js";
2
2
  import { a as AnyModels, i as AnyFunctions } from "../types-6BdhkmZe.js";
3
3
  import { m as RequestContext } from "../plugin-FGY8UhYm.js";
4
4
  import { _ as writeSession, a as CookieWrite, c as StoredSession, h as sessionCookieName, n as CookieOptions, p as readSession, r as CookieRecord, t as AUTH_CACHE_HEADERS } from "../session-ChiXDZdZ.js";
5
- import { a as ResolveAuthOptions, c as clientIp, i as InvalidReason, l as resolveAuth, n as AuthResolver, o as ResolvedState, r as AuthState, s as authContext, t as AuthResolution } from "../resolve-KW8nCeL6.js";
5
+ import { a as ResolveAuthOptions, c as clientIp, i as InvalidReason, l as resolveAuth, n as AuthResolver, o as ResolvedState, r as AuthState, s as authContext, t as AuthResolution } from "../resolve-ChTYeTEl.js";
6
6
  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-DD8LZFjc.js";
7
7
  import { B as DbStats, b as Db, t as BetterSupabase } from "../define-CJJkkr1-.js";
8
- import { A as SupportCookieOptions, B as SupportStartInput, C as SupportAuthorizeInput, D as SupportStartRequest, E as SupportSessions, F as SupportCallerClaims, H as supportClaims, I as SupportEndedBy, L as SupportListFilter, M as supportCookie, N as supportCookieValue, O as supportSessions, P as SqlSupportStoreOptions, R as SupportSession, S as SupportApi, T as SupportPolicy, V as sqlSupportStore, _ as ReplicaState, a as ServerDbOptions, b as deleteAccount, c as createServer, d as SuspendAccountOptions, f as SuspendAccountResult, g as PRIMARY_COOKIE, h as RequestIdOptions, i as ServerContext, j as clearSupportCookie, k as SUPPORT_COOKIE, l as extendServer, m as suspendAccount, n as ContextOptions, o as ServerOptions, p as endSessions, r as ForContextOptions, s as TENANT_HEADER, t as BetterServer, u as EndSessionsResult, v as DeleteAccountOptions, w as SupportOptions, x as ActiveSupport, y as DeleteAccountResult, z as SupportSessionStore } from "../server-C6DWVEVG.js";
8
+ import { A as supportSessions, B as SupportSession, C as ActiveSupport, D as SupportPolicy, E as SupportOptions, F as supportCookieValue, H as SupportStartInput, I as SqlSupportStoreOptions, L as SupportCallerClaims, M as SupportCookieOptions, N as clearSupportCookie, O as SupportSessions, P as supportCookie, R as SupportEndedBy, S as deleteAccount, T as SupportAuthorizeInput, U as sqlSupportStore, V as SupportSessionStore, W as supportClaims, _ as RequestIdOptions, a as ServerDbOptions, b as DeleteAccountOptions, c as createServer, d as LastSignIn, f as SuspendAccountOptions, g as suspendAccount, h as lastSignIns, i as ServerContext, j as SUPPORT_COOKIE, k as SupportStartRequest, l as extendServer, m as endSessions, n as ContextOptions, o as ServerOptions, p as SuspendAccountResult, r as ForContextOptions, s as TENANT_HEADER, t as BetterServer, u as EndSessionsResult, v as PRIMARY_COOKIE, w as SupportApi, x as DeleteAccountResult, y as ReplicaState, z as SupportListFilter } from "../server-ZSJ9rCcV.js";
9
9
  import { a as checkAal, c as impersonatorOf, i as amrOf, n as AmrEntry, o as ImpersonationOptions, r as aalOf, s as Impersonator, t as Aal } from "../mfa-Daak8ukG.js";
10
10
  import { n as SessionActor, r as SessionDelegation, t as ActClaim } from "../actor-CQTlc1Hh.js";
11
- import { n as toSession, t as AuthSession } from "../view-DbxLNu8L.js";
12
- import { a as SessionEntryConfig, c as withGuard, i as withBetterSupabase, l as ServerCore, n as BetterSupabaseContributions, o as withSession, r as BetterSupabaseEntry, s as GuardEntryConfig, t as BetterSupabaseConfig, u as serverCore } from "../composite-pSfeJNce.js";
13
- 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-DoBijysA.js";
14
- import { a as AuthorizedContext, i as AuthorizeOptions, l as hasRole, o as BlockActionOptions, r as ActionResult, s as BlockRequireOptions, u as rolesAt } from "../kit-B5tid-q5.js";
15
- import { a as ResourceRouteOptions, i as ResourcePagination, n as ResourceInput, o as defineResource, r as ResourceList, t as ResourceHandler } from "../resource-D6Uc7Sk7.js";
11
+ import { n as toSession, t as AuthSession } from "../view-CF7ihnkg.js";
12
+ import { a as SessionEntryConfig, c as withGuard, i as withBetterSupabase, l as ServerCore, n as BetterSupabaseContributions, o as withSession, r as BetterSupabaseEntry, s as GuardEntryConfig, t as BetterSupabaseConfig, u as serverCore } from "../composite-CpHLEo-G.js";
13
+ 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-DprrgyXX.js";
14
+ import { a as AuthorizedContext, i as AuthorizeOptions, l as hasRole, o as BlockActionOptions, r as ActionResult, s as BlockRequireOptions, u as rolesAt } from "../kit-CkNzZUqv.js";
15
+ import { a as ResourceRouteOptions, i as ResourcePagination, n as ResourceInput, o as defineResource, r as ResourceList, t as ResourceHandler } from "../resource-IPS5xi9q.js";
16
16
  import { i as tagFor, n as cacheTagsOf, r as tagCache, t as TagOptions } from "../tags-Cx-LnIQP.js";
17
- import { n as supportOf, t as SupportView } from "../support-view-33Oi07TT.js";
18
- import { a as sessionStatus, c as refreshSession, i as clearSessionCookies, n as SessionStatus, r as SessionStatusOptions, s as RefreshOutcome, t as ClearSessionCookiesOptions } from "../ended-jLfvw8h-.js";
17
+ import { n as supportOf, t as SupportView } from "../support-view-CVOJJLpc.js";
18
+ import { a as sessionStatus, c as refreshSession, i as clearSessionCookies, n as SessionStatus, r as SessionStatusOptions, s as RefreshOutcome, t as ClearSessionCookiesOptions } from "../ended-XjeGQ5XW.js";
19
19
  import { SupabaseClient } from "@supabase/supabase-js";
20
20
  import { Middleware, SingleKeyEntry } from "@supabase/middleware";
21
21
  import { AuthMode, JWTClaims, UserClaims } from "@supabase/server";
22
22
  import { PostgresApi } from "@supabase/server/middleware/postgres";
23
+ //#region src/blocks/csv.d.ts
24
+ interface CsvOptions {
25
+ /**
26
+ * The columns in order. Defaults to every key of the rows, in the order
27
+ * they first appear.
28
+ */
29
+ readonly columns?: readonly string[];
30
+ /**
31
+ * Prefixes a text cell that starts with `=`, `+`, `-`, `@`, a tab or a
32
+ * carriage return with `'`, so a spreadsheet shows it instead of running
33
+ * it as a formula (CSV injection). Default true.
34
+ */
35
+ readonly escapeFormulas?: boolean;
36
+ }
37
+ /** The columns of `rows`: every key, in the order it first appears. */
38
+ export declare function csvColumns(rows: readonly Readonly<Record<string, unknown>>[]): string[];
39
+ /**
40
+ * RFC 4180 CSV with a header row and CRLF line ends. Objects and arrays are
41
+ * written as JSON, null and undefined as empty cells.
42
+ */
43
+ export declare function toCsv(rows: readonly Readonly<Record<string, unknown>>[], options?: CsvOptions): string;
44
+ //#endregion
45
+ //#region src/server/csv.d.ts
46
+ interface CsvResponseOptions extends CsvOptions {
47
+ /** The download name, such as `invoices.csv`. */
48
+ readonly filename: string;
49
+ /** Extra headers, such as `cache-control`. `content-type` and `content-disposition` win. */
50
+ readonly headers?: ConstructorParameters<typeof Headers>[0];
51
+ readonly status?: number;
52
+ }
53
+ /**
54
+ * `rows` as a CSV download: `text/csv; charset=utf-8` with an `attachment`
55
+ * `Content-Disposition`. Text cells that start with a formula character are
56
+ * escaped unless `escapeFormulas` is false.
57
+ */
58
+ export declare function csvResponse(rows: readonly Readonly<Record<string, unknown>>[], options: CsvResponseOptions): Response;
59
+ //#endregion
23
60
  //#region src/server/audit.d.ts
24
61
  /** The CloudEvents `source` of the events the server sends to its `audit` sink. */
25
62
  export declare const SERVER_EVENT_SOURCE = "/better-supabase/server";
@@ -188,4 +225,4 @@ export declare function withDbStats(options?: {
188
225
  };
189
226
  }, () => DbStats>;
190
227
  //#endregion
191
- export { AUTH_CACHE_HEADERS, type Aal, type AccountEventType, type ActClaim, type ActionResult, type ActiveSupport, type AmrEntry, type AuthKind, type AuthResolution, type AuthResolver, type AuthSession, type AuthState, type AuthorizeOptions, type AuthorizedContext, type BetterServer, type BetterSupabaseConfig, type BetterSupabaseContributions, type BetterSupabaseEntry, type BlockActionOptions, type BlockRequireOptions, type ClearSessionCookiesOptions, type ContextOptions, type CookieOptions, type CookieRecord, type CookieWrite, type DeleteAccountOptions, type DeleteAccountResult, type EndSessionsResult, type ForContextOptions, type GuardEntryConfig, type GuardOptions, type HandleOptions, type ImpersonationOptions, type Impersonator, type InvalidReason, type MiddlewareOptions, PRIMARY_COOKIE, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, type ProblemDetails, type ProblemOptions, type ProblemResponseOptions, type RefreshOutcome, type RefreshPolicy, type ReplicaState, type RequestIdOptions, type ResolveAuthOptions, type ResolvedState, type ResourceHandler, type ResourceInput, type ResourceList, 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 SessionStatus, type SessionStatusOptions, type Settled, type SqlSupportStoreOptions, type StoredSession, type SupabaseAuthContext, type SupportApi, type SupportAuthorizeInput, type SupportCallerClaims, type SupportCookieOptions, type SupportEndedBy, type SupportListFilter, type SupportOptions, type SupportPolicy, type SupportSession, type SupportSessionStore, type SupportSessions, type SupportStartInput, type SupportStartRequest, type SupportView, type SuspendAccountOptions, type SuspendAccountResult, TENANT_HEADER, type TagOptions, aalOf, amrOf, authContext, cacheTagsOf, checkAal, clearSessionCookies, clearSupportCookie, clientIp, createServer, defineResource, deleteAccount, endSessions, extendServer, fromProblem, guard, hasRole, impersonatorOf, isPrefetch, isProblem, isResult, problemResponse, readSession, refreshFor, refreshSession, resolveAuth, respond, rolesAt, serverCore, sessionCookieName, sessionStatus, settle, shouldCheckSession, shouldRefresh, sqlSupportStore, supportClaims, supportCookie, supportCookieValue, supportOf, supportSessions, suspendAccount, tagCache, tagFor, toProblem, toSession, withBetterSupabase, withGuard, withSession, writeSession };
228
+ export { AUTH_CACHE_HEADERS, type Aal, type AccountEventType, type ActClaim, type ActionResult, type ActiveSupport, type AmrEntry, type AuthKind, type AuthResolution, type AuthResolver, type AuthSession, type AuthState, type AuthorizeOptions, type AuthorizedContext, type BetterServer, type BetterSupabaseConfig, type BetterSupabaseContributions, type BetterSupabaseEntry, type BlockActionOptions, type BlockRequireOptions, type ClearSessionCookiesOptions, type ContextOptions, type CookieOptions, type CookieRecord, type CookieWrite, type CsvOptions, type CsvResponseOptions, type DeleteAccountOptions, type DeleteAccountResult, type EndSessionsResult, type ForContextOptions, type GuardEntryConfig, type GuardOptions, type HandleOptions, type ImpersonationOptions, type Impersonator, type InvalidReason, type LastSignIn, type MiddlewareOptions, PRIMARY_COOKIE, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, type ProblemDetails, type ProblemOptions, type ProblemResponseOptions, type RefreshOutcome, type RefreshPolicy, type ReplicaState, type RequestIdOptions, type ResolveAuthOptions, type ResolvedState, type ResourceHandler, type ResourceInput, type ResourceList, 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 SessionStatus, type SessionStatusOptions, type Settled, type SqlSupportStoreOptions, type StoredSession, type SupabaseAuthContext, type SupportApi, type SupportAuthorizeInput, type SupportCallerClaims, type SupportCookieOptions, type SupportEndedBy, type SupportListFilter, type SupportOptions, type SupportPolicy, type SupportSession, type SupportSessionStore, type SupportSessions, type SupportStartInput, type SupportStartRequest, type SupportView, type SuspendAccountOptions, type SuspendAccountResult, TENANT_HEADER, type TagOptions, aalOf, amrOf, authContext, cacheTagsOf, checkAal, clearSessionCookies, clearSupportCookie, clientIp, createServer, defineResource, deleteAccount, endSessions, extendServer, fromProblem, guard, hasRole, impersonatorOf, isPrefetch, isProblem, isResult, lastSignIns, problemResponse, readSession, refreshFor, refreshSession, resolveAuth, respond, rolesAt, serverCore, sessionCookieName, sessionStatus, settle, shouldCheckSession, shouldRefresh, sqlSupportStore, supportClaims, supportCookie, supportCookieValue, supportOf, supportSessions, suspendAccount, tagCache, tagFor, toProblem, toSession, withBetterSupabase, withGuard, withSession, writeSession };
@@ -2,20 +2,42 @@ import { n as dbError } from "../errors-B11Duf73.js";
2
2
  import { a as problemResponse, i as isProblem, n as PROBLEM_TYPE_BASE, o as toProblem, r as fromProblem, t as PROBLEM_CONTENT_TYPE } from "../problem-BreOl8b8.js";
3
3
  import { i as userContext, r as impersonatorOf } from "../impersonation-DcqaTBHx.js";
4
4
  import { t as supportOf } from "../support-view-g4YLBeqX.js";
5
+ import { n as toCsv, t as csvColumns } from "../csv-DCK-PT1n.js";
5
6
  import { n as postgresExecutor } from "../executor-De1Of3m3.js";
6
- import { C as serverCore, D as deleteAccount, E as suspendAccount, T as endSessions, _ as withSession, a as unexpectedResponse, b as shouldCheckSession, c as extendServer, d as clearSupportCookie, f as supportCookie, i as resolveToken, m as supportCookieValue, n as flushEvents, o as TENANT_HEADER, r as handle, s as createServer, u as SUPPORT_COOKIE, v as isPrefetch, w as SERVER_EVENT_SOURCE, x as shouldRefresh, y as refreshFor } from "../adapter-CHnPkCPd.js";
7
+ import { C as serverCore, D as suspendAccount, E as lastSignIns, O as deleteAccount, T as endSessions, _ as withSession, a as unexpectedResponse, b as shouldCheckSession, c as extendServer, d as clearSupportCookie, f as supportCookie, i as resolveToken, m as supportCookieValue, n as flushEvents, o as TENANT_HEADER, r as handle, s as createServer, u as SUPPORT_COOKIE, v as isPrefetch, w as SERVER_EVENT_SOURCE, x as shouldRefresh, y as refreshFor } from "../adapter-B-tL8hqg.js";
7
8
  import { n as PRIMARY_COOKIE } from "../replicas-CwrYp5Zj.js";
8
- import { _ as writeSession, a as refreshSession, c as AUTH_CACHE_HEADERS, h as sessionCookieName, i as resolveAuth, n as clientIp, o as clearSessionCookies, p as readSession, s as sessionStatus, t as authContext } from "../resolve-D_IcnvFd.js";
9
+ import { _ as writeSession, a as refreshSession, c as AUTH_CACHE_HEADERS, h as sessionCookieName, i as resolveAuth, n as clientIp, o as clearSessionCookies, p as readSession, s as sessionStatus, t as authContext } from "../resolve-tJZY3FEa.js";
9
10
  import { a as checkAal, i as amrOf, n as toSession, r as aalOf } from "../view-BeFcRV6G.js";
10
11
  import { a as respond, i as isResult, o as settle, r as guard } from "../respond-BUgsXNgk.js";
11
- import { n as sqlSupportStore, r as supportClaims, t as supportSessions } from "../support-zIa1URaN.js";
12
+ import { n as sqlSupportStore, r as supportClaims, t as supportSessions } from "../support-DWwzVf-O.js";
12
13
  import { n as jwtClaimsOf, r as userClaimsOf, t as authModeOf } from "../claims-DDBQT6BK.js";
13
- import { n as withGuard, t as withBetterSupabase } from "../composite-CLqs9-OA.js";
14
+ import { n as withGuard, t as withBetterSupabase } from "../composite-C6I8ZyaF.js";
14
15
  import { t as defineResource } from "../resource-BsvzCMlX.js";
15
16
  import { i as withServerTiming, n as parseDbStats, r as withDbStats, t as DB_CALLS_HEADER } from "../timing-CyTQPubY.js";
16
17
  import { n as tagCache, r as tagFor, t as cacheTagsOf } from "../tags-B99_U9Pp.js";
17
18
  import { a as rolesAt, r as hasRole } from "../kit-Fm-Fv7q5.js";
18
19
  import { defineMiddleware } from "@supabase/middleware";
20
+ //#region src/server/csv.ts
21
+ function disposition(filename) {
22
+ const safe = filename.replaceAll(/[\r\n]/g, " ");
23
+ return `attachment; filename="${safe.replaceAll(/[^\u0020-\u007E]|["\\]/g, "_")}"; filename*=UTF-8''${encodeURIComponent(safe).replaceAll(/['()*]/g, (char) => `%${char.codePointAt(0).toString(16).toUpperCase()}`)}`;
24
+ }
25
+ /**
26
+ * `rows` as a CSV download: `text/csv; charset=utf-8` with an `attachment`
27
+ * `Content-Disposition`. Text cells that start with a formula character are
28
+ * escaped unless `escapeFormulas` is false.
29
+ */
30
+ function csvResponse(rows, options) {
31
+ const { filename, headers, status, ...csv } = options;
32
+ const response = new Response(toCsv(rows, csv), {
33
+ status: status ?? 200,
34
+ ...headers ? { headers } : {}
35
+ });
36
+ response.headers.set("content-type", "text/csv; charset=utf-8");
37
+ response.headers.set("content-disposition", disposition(filename));
38
+ return response;
39
+ }
40
+ //#endregion
19
41
  //#region src/server/entries/upstream.ts
20
42
  /** Repository context from a `@supabase/server` context. */
21
43
  function contextFromSupabase(ctx) {
@@ -120,4 +142,4 @@ async function checkSession(sql, auth) {
120
142
  return row?.active === true ? void 0 : revoked;
121
143
  }
122
144
  //#endregion
123
- export { AUTH_CACHE_HEADERS, DB_CALLS_HEADER, PRIMARY_COOKIE, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, SERVER_EVENT_SOURCE, SUPPORT_COOKIE, TENANT_HEADER, aalOf, amrOf, authContext, authModeOf, cacheTagsOf, checkAal, checkSession, clearSessionCookies, clearSupportCookie, clientIp, contextFromSupabase, createServer, defineResource, deleteAccount, endSessions, extendServer, flushEvents, fromProblem, guard, handle, hasRole, impersonatorOf, isPrefetch, isProblem, isResult, jwtClaimsOf, parseDbStats, problemResponse, readSession, refreshFor, refreshSession, resolveAuth, resolveToken, respond, rolesAt, serverCore, sessionCookieName, sessionStatus, settle, shouldCheckSession, shouldRefresh, sqlSupportStore, supportClaims, supportCookie, supportCookieValue, supportOf, supportSessions, suspendAccount, tagCache, tagFor, toProblem, toSession, unexpectedResponse, userClaimsOf, withBetterDb, withBetterPostgres, withBetterSupabase, withBlock, withDbStats, withGuard, withServerTiming, withSession, writeSession };
145
+ export { AUTH_CACHE_HEADERS, DB_CALLS_HEADER, PRIMARY_COOKIE, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, SERVER_EVENT_SOURCE, SUPPORT_COOKIE, TENANT_HEADER, aalOf, amrOf, authContext, authModeOf, cacheTagsOf, checkAal, checkSession, clearSessionCookies, clearSupportCookie, clientIp, contextFromSupabase, createServer, csvColumns, csvResponse, defineResource, deleteAccount, endSessions, extendServer, flushEvents, fromProblem, guard, handle, hasRole, impersonatorOf, isPrefetch, isProblem, isResult, jwtClaimsOf, lastSignIns, parseDbStats, problemResponse, readSession, refreshFor, refreshSession, resolveAuth, resolveToken, respond, rolesAt, serverCore, sessionCookieName, sessionStatus, settle, shouldCheckSession, shouldRefresh, sqlSupportStore, supportClaims, supportCookie, supportCookieValue, supportOf, supportSessions, suspendAccount, tagCache, tagFor, toCsv, toProblem, toSession, unexpectedResponse, userClaimsOf, withBetterDb, withBetterPostgres, withBetterSupabase, withBlock, withDbStats, withGuard, withServerTiming, withSession, writeSession };
@@ -6,8 +6,8 @@ import { m as RequestContext } from "./plugin-FGY8UhYm.js";
6
6
  import { a as EventHub } from "./events-DWDhx77e.js";
7
7
  import { t as BetterSupabaseEnv } from "./index-CLg87OBW.js";
8
8
  import { a as CookieWrite } from "./session-ChiXDZdZ.js";
9
- import { a as ResolveAuthOptions, r as AuthState, t as AuthResolution } from "./resolve-KW8nCeL6.js";
10
- import { r as CredentialProvider } from "./provider-BH5UWZJ6.js";
9
+ import { a as ResolveAuthOptions, r as AuthState, t as AuthResolution } from "./resolve-ChTYeTEl.js";
10
+ import { r as CredentialProvider } from "./provider-D-UEMvSD.js";
11
11
  import { B as DbStats, H as StatsRecorder, b as Db, t as BetterSupabase } from "./define-CJJkkr1-.js";
12
12
  import { r as EventSink } from "./cloud-event-C1JCc1bH.js";
13
13
  import { s as SqlClaims, t as BetterPostgres } from "./pool-CAu2nLrL.js";
@@ -301,6 +301,17 @@ interface SuspendAccountResult {
301
301
  readonly ended: number;
302
302
  }
303
303
  declare function endSessions(sql: SqlClient, userId: string): AsyncResult<EndSessionsResult>;
304
+ interface LastSignIn {
305
+ readonly userId: string;
306
+ /** `null` for a user who never signed in. */
307
+ readonly lastSignInAt: Temporal.Instant | null;
308
+ }
309
+ /**
310
+ * The last sign-in of each user, in one query (`better_supabase.last_sign_ins`
311
+ * from the `sessions` module, which only the service role may call). Users
312
+ * that don't exist are missing from the map.
313
+ */
314
+ declare function lastSignIns(sql: SqlClient, userIds: readonly string[]): AsyncResult<ReadonlyMap<string, LastSignIn>>;
304
315
  declare function suspendAccount(service: SupabaseClient | (() => SupabaseClient), sql: SqlClient, userId: string, options: SuspendAccountOptions): AsyncResult<SuspendAccountResult>;
305
316
  //#endregion
306
317
  //#region src/server/server.d.ts
@@ -526,4 +537,4 @@ declare function extendServer<R extends object>(server: object, extra: Omit<R, S
526
537
  */
527
538
  declare function createServer<M extends AnyModels, D, F extends AnyFunctions, E, C = unknown, P = unknown>(betterSupabase: BetterSupabase<M, D, F, E, C, P>, options?: ServerOptions): BetterServer<M, F, E, C, P>;
528
539
  //#endregion
529
- export { SupportCookieOptions as A, SupportStartInput as B, SupportAuthorizeInput as C, SupportStartRequest as D, SupportSessions as E, SupportCallerClaims as F, supportClaims as H, SupportEndedBy as I, SupportListFilter as L, supportCookie as M, supportCookieValue as N, supportSessions as O, SqlSupportStoreOptions as P, SupportSession as R, SupportApi as S, SupportPolicy as T, sqlSupportStore as V, ReplicaState as _, ServerDbOptions as a, deleteAccount as b, createServer as c, SuspendAccountOptions as d, SuspendAccountResult as f, PRIMARY_COOKIE as g, RequestIdOptions as h, ServerContext as i, clearSupportCookie as j, SUPPORT_COOKIE as k, extendServer as l, suspendAccount as m, ContextOptions as n, ServerOptions as o, endSessions as p, ForContextOptions as r, TENANT_HEADER as s, BetterServer as t, EndSessionsResult as u, DeleteAccountOptions as v, SupportOptions as w, ActiveSupport as x, DeleteAccountResult as y, SupportSessionStore as z };
540
+ export { supportSessions as A, SupportSession as B, ActiveSupport as C, SupportPolicy as D, SupportOptions as E, supportCookieValue as F, SupportStartInput as H, SqlSupportStoreOptions as I, SupportCallerClaims as L, SupportCookieOptions as M, clearSupportCookie as N, SupportSessions as O, supportCookie as P, SupportEndedBy as R, deleteAccount as S, SupportAuthorizeInput as T, sqlSupportStore as U, SupportSessionStore as V, supportClaims as W, RequestIdOptions as _, ServerDbOptions as a, DeleteAccountOptions as b, createServer as c, LastSignIn as d, SuspendAccountOptions as f, suspendAccount as g, lastSignIns as h, ServerContext as i, SUPPORT_COOKIE as j, SupportStartRequest as k, extendServer as l, endSessions as m, ContextOptions as n, ServerOptions as o, SuspendAccountResult as p, ForContextOptions as r, TENANT_HEADER as s, BetterServer as t, EndSessionsResult as u, PRIMARY_COOKIE as v, SupportApi as w, DeleteAccountResult as x, ReplicaState as y, SupportListFilter as z };
@@ -2,9 +2,9 @@ import { b as DbError } from "../result-D7y2fT87.js";
2
2
  import { it as QuerySpec } from "../define-CJJkkr1-.js";
3
3
  import { n as TemplateValues } from "../template-CwO38Do8.js";
4
4
  import { t as AuthSnapshot } from "../bind-Bu_ZNa3W.js";
5
- import { t as AuthSession } from "../view-DbxLNu8L.js";
5
+ import { t as AuthSession } from "../view-CF7ihnkg.js";
6
6
  import { S as Topic, f as PresenceMember, u as EventSchemas, w as TopicHandlers, x as SubscriptionStatus } from "../index-DunNRdnT.js";
7
- import { t as SupportView } from "../support-view-33Oi07TT.js";
7
+ import { t as SupportView } from "../support-view-CVOJJLpc.js";
8
8
  import { a as BroadcastOptions, c as LiveCountSource, d as PresenceTopic, f as UseActionOptions, i as ActionState, l as LiveQueryHookOptions, n as ActionInputOf, o as ClientLike, r as ActionResultOf, s as LiveCountHookOptions, t as fieldErrorsOf, u as PresenceHookOptions } from "../field-errors-BFOa7WhB.js";
9
9
  import { SupabaseClient } from "@supabase/supabase-js";
10
10
  import { Accessor, JSX } from "solid-js";
@@ -1,9 +1,9 @@
1
1
  import { a as AnyModels, i as AnyFunctions } from "../types-6BdhkmZe.js";
2
2
  import { t as BetterSupabase } from "../define-CJJkkr1-.js";
3
- import { t as BetterServer } from "../server-C6DWVEVG.js";
4
- import { a as AuthorizedContext, c as Unwrapped, n as ActionParsed, o as BlockActionOptions, r as ActionResult, s as BlockRequireOptions } from "../kit-B5tid-q5.js";
5
- import { t as RefusalRedirects } from "../refusal-D1rgbzNq.js";
6
- import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-CdPDPpFs.js";
3
+ import { t as BetterServer } from "../server-ZSJ9rCcV.js";
4
+ import { a as AuthorizedContext, c as Unwrapped, n as ActionParsed, o as BlockActionOptions, r as ActionResult, s as BlockRequireOptions } from "../kit-CkNzZUqv.js";
5
+ import { t as RefusalRedirects } from "../refusal-DhSU2Vvr.js";
6
+ import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-KIPvRQJU.js";
7
7
  import { StandardSchemaV1 } from "@standard-schema/spec";
8
8
  //#region src/solid-start/index.d.ts
9
9
  /** The part of a SolidStart `FetchEvent` the integration reads and writes. */
@@ -1,7 +1,7 @@
1
- import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-CHnPkCPd.js";
1
+ import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-B-tL8hqg.js";
2
2
  import { t as defaultExpose } from "../respond-BUgsXNgk.js";
3
3
  import { i as requireCaller, o as runAction } from "../kit-Fm-Fv7q5.js";
4
- import { i as localsOf, r as frameworkEntry } from "../framework-xjTBoyBB.js";
4
+ import { i as localsOf, r as frameworkEntry } from "../framework-BDCpJI7o.js";
5
5
  import { r as refusalResponse } from "../refusal-CeJWxmkH.js";
6
6
  import { t as beforeRoute } from "../before-route-CnR0C0Jr.js";
7
7
  //#region src/solid-start/index.ts
@@ -191,6 +191,8 @@ interface ModuleLayout {
191
191
  readonly policyGrants?: readonly TableGrant[];
192
192
  /** The tables the schema files create, for `sql.modules.sessions.options.policies`. */
193
193
  readonly declaredTables?: readonly string[];
194
+ /** The declared tables with row level security on, for tables `fromPolicies` makes service-only. */
195
+ readonly rlsTables?: readonly string[];
194
196
  /** `config.readSets`, compiled: the functions the `read-sets` module writes. */
195
197
  readonly readSets?: readonly {
196
198
  readonly name: string;
@@ -417,6 +419,14 @@ interface PolicyGrant {
417
419
  export declare function declaredTables(files: readonly {
418
420
  readonly text: string;
419
421
  }[], schemas: readonly string[]): string[];
422
+ /**
423
+ * The tables in `schemas` that `files` leave with row level security on:
424
+ * `alter table ... enable row level security`, until a later `disable` or
425
+ * `drop table`.
426
+ */
427
+ export declare function rlsTables(files: readonly {
428
+ readonly text: string;
429
+ }[], schemas: readonly string[]): string[];
420
430
  /**
421
431
  * The privileges the permissive policies in `files` imply, per table and
422
432
  * role: `for all` gives the four commands, `to public` (or no `to`) counts