better-supabase 0.6.0 → 0.6.1

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 (53) hide show
  1. package/dist/{adapter-Bc1o3zyy.js → adapter-CHnPkCPd.js} +75 -21
  2. package/dist/astro/index.d.ts +2 -2
  3. package/dist/astro/index.js +2 -2
  4. package/dist/blocks/attachments/index.d.ts +18 -4
  5. package/dist/blocks/attachments/index.js +16 -4
  6. package/dist/blocks/data-lifecycle/index.d.ts +10 -2
  7. package/dist/blocks/data-lifecycle/index.js +7 -2
  8. package/dist/cli/bin.js +1 -1
  9. package/dist/cli/{doctor-B4JOm_ox.js → doctor-BMqBgM3X.js} +2 -2
  10. package/dist/cli/gen-4JlOwgWG.js +2 -0
  11. package/dist/cli/{gen-BGLb_zou.js → gen-DeuDgPxN.js} +1 -1
  12. package/dist/cli/index.d.ts +1 -1
  13. package/dist/cli/index.js +3 -3
  14. package/dist/cli/{init-BIIwclPg.js → init-C7Xd0Kda.js} +1 -1
  15. package/dist/cli/{introspect-DNUTuNvb.js → introspect-CSnMJ94U.js} +1 -1
  16. package/dist/cli/{run-DNWxHynX.js → run-C8tnlHSb.js} +6 -6
  17. package/dist/cli/{version-hr88OZG0.js → version-C_4JwyiM.js} +1 -1
  18. package/dist/{composite-DhE66P5u.js → composite-CLqs9-OA.js} +1 -1
  19. package/dist/{composite-Bt1YK3Ke.d.ts → composite-pSfeJNce.d.ts} +1 -1
  20. package/dist/edge/index.d.ts +1 -1
  21. package/dist/edge/index.js +3 -3
  22. package/dist/expo/index.d.ts +1 -1
  23. package/dist/expo/index.js +2 -2
  24. package/dist/{framework-DuVb4Xa8.d.ts → framework-CdPDPpFs.d.ts} +2 -2
  25. package/dist/{framework-CONDyPYx.js → framework-xjTBoyBB.js} +1 -1
  26. package/dist/hono/index.d.ts +1 -1
  27. package/dist/hono/index.js +2 -2
  28. package/dist/mcp/index.d.ts +1 -1
  29. package/dist/mcp/index.js +1 -1
  30. package/dist/mcp/sdk/index.d.ts +1 -1
  31. package/dist/mcp/sdk/index.js +1 -1
  32. package/dist/next/index.d.ts +1 -1
  33. package/dist/next/index.js +2 -2
  34. package/dist/orpc/index.d.ts +1 -1
  35. package/dist/orpc/index.js +1 -1
  36. package/dist/otel/index.js +5 -5
  37. package/dist/react-router/index.d.ts +2 -2
  38. package/dist/react-router/index.js +2 -2
  39. package/dist/server/index.d.ts +3 -3
  40. package/dist/server/index.js +3 -3
  41. package/dist/{server-CeVeeXwz.d.ts → server-C6DWVEVG.d.ts} +14 -1
  42. package/dist/solid-start/index.d.ts +2 -2
  43. package/dist/solid-start/index.js +2 -2
  44. package/dist/sql/index.js +31 -9
  45. package/dist/{support-BivNqSpK.js → support-zIa1URaN.js} +1 -1
  46. package/dist/sveltekit/index.d.ts +2 -2
  47. package/dist/sveltekit/index.js +2 -2
  48. package/dist/tanstack-start/index.d.ts +2 -2
  49. package/dist/tanstack-start/index.js +2 -2
  50. package/dist/testing/index.d.ts +1 -1
  51. package/dist/{version-Bvv6aLjZ.js → version-CQt77F3T.js} +1 -1
  52. package/package.json +1 -1
  53. package/dist/cli/gen-DAH8FM2W.js +0 -2
@@ -426,6 +426,57 @@ function withTenant(core) {
426
426
  })();
427
427
  }
428
428
  //#endregion
429
+ //#region src/server/request-ids.ts
430
+ const REQUEST_ID_PATTERN = /^[A-Za-z0-9._:;,@/+=-]{1,128}$/;
431
+ function requestIdOrUndefined(value) {
432
+ return typeof value === "string" && REQUEST_ID_PATTERN.test(value) ? value : void 0;
433
+ }
434
+ function sessionWith(ids, tenant, readOnly = false) {
435
+ const settings = {
436
+ ...ids.requestId === void 0 ? {} : { "better_supabase.request_id": ids.requestId },
437
+ ...ids.correlationId === void 0 ? {} : { "better_supabase.correlation_id": ids.correlationId },
438
+ ...tenant === void 0 ? {} : { "better_supabase.tenant": tenant }
439
+ };
440
+ const hasSettings = Object.keys(settings).length > 0;
441
+ if (!hasSettings && !readOnly) return void 0;
442
+ return {
443
+ ...readOnly ? { readOnly: true } : {},
444
+ ...hasSettings ? { settings } : {}
445
+ };
446
+ }
447
+ function requestIdPolicy(options = {}) {
448
+ const on = options !== false;
449
+ const settings = on ? options : {};
450
+ const requestHeader = (settings.requestHeader ?? "x-request-id").toLowerCase();
451
+ const correlationHeader = (settings.correlationHeader ?? "x-correlation-id").toLowerCase();
452
+ const incoming = on && (settings.incoming ?? true);
453
+ const generate = on && (settings.generate ?? true);
454
+ const generated = /* @__PURE__ */ new WeakMap();
455
+ const fromHeader = (request, name) => incoming && request ? requestIdOrUndefined(request.headers.get(name)) : void 0;
456
+ const generatedFor = (request) => {
457
+ if (!generate || !request) return void 0;
458
+ const known = generated.get(request);
459
+ if (known !== void 0) return known;
460
+ const id = crypto.randomUUID();
461
+ generated.set(request, id);
462
+ return id;
463
+ };
464
+ return {
465
+ forRequest(request, explicit) {
466
+ const requestId = requestIdOrUndefined(explicit.requestId) ?? fromHeader(request, requestHeader) ?? generatedFor(request);
467
+ const correlationId = requestIdOrUndefined(explicit.correlationId) ?? fromHeader(request, correlationHeader) ?? requestId;
468
+ return {
469
+ ...requestId === void 0 ? {} : { requestId },
470
+ ...correlationId === void 0 ? {} : { correlationId }
471
+ };
472
+ },
473
+ headers: (ids) => ({
474
+ ...ids.requestId === void 0 ? {} : { [requestHeader]: ids.requestId },
475
+ ...ids.correlationId === void 0 ? {} : { [correlationHeader]: ids.correlationId }
476
+ })
477
+ };
478
+ }
479
+ //#endregion
429
480
  //#region src/auth/support-cookie.ts
430
481
  /** The cookie that carries the support session id. */
431
482
  const SUPPORT_COOKIE = "bs-support";
@@ -674,6 +725,7 @@ function createServer(betterSupabase, options = {}) {
674
725
  return tenant;
675
726
  };
676
727
  const pinMs = options.replicas?.pinMs ?? 5e3;
728
+ const idPolicy = requestIdPolicy(options.requestIds);
677
729
  if (options.support && !options.postgres) throw new TypeError("Support sessions need createServer(betterSupabase, { postgres: createPostgres(), support })");
678
730
  const audit = serverAudit(betterSupabase, options.audit);
679
731
  const support = options.support ? options.support.create(betterSupabase.events, options.auth?.claims ?? betterSupabase.claimsSchema) : supportOff;
@@ -682,7 +734,7 @@ function createServer(betterSupabase, options = {}) {
682
734
  * Postgres with the target's claims plus `act`, read-only unless the
683
735
  * session allows writes; nothing reaches Supabase with the admin's token.
684
736
  */
685
- const supportContextFor = (resolution, active, parent, tenant) => {
737
+ const supportContextFor = (resolution, active, parent, tenant, ids) => {
686
738
  const { session, claims } = active;
687
739
  const record = (key) => {
688
740
  const value = claims[key];
@@ -711,10 +763,7 @@ function createServer(betterSupabase, options = {}) {
711
763
  ...base,
712
764
  tenant: scope
713
765
  };
714
- const sessionOptions = {
715
- ...session.readOnly ? { readOnly: true } : {},
716
- ...scope === void 0 ? {} : { settings: { "better_supabase.tenant": scope } }
717
- };
766
+ const sessionOptions = sessionWith(ids, scope, session.readOnly);
718
767
  const recorder = new StatsRecorder(parent);
719
768
  const sqlClaims = claims;
720
769
  const unavailable = () => {
@@ -724,6 +773,7 @@ function createServer(betterSupabase, options = {}) {
724
773
  let sql;
725
774
  return {
726
775
  ...credentials,
776
+ ...ids,
727
777
  auth,
728
778
  resolution,
729
779
  support: active,
@@ -753,19 +803,20 @@ function createServer(betterSupabase, options = {}) {
753
803
  * `ctx.sql` run over direct Postgres with the key's synthesized claims,
754
804
  * scoped to its organization unless the tenant option names another.
755
805
  */
756
- const apiKeyContextFor = (resolution, auth, parent, tenant) => {
806
+ const apiKeyContextFor = (resolution, auth, parent, tenant, ids) => {
757
807
  const scope = tenant ?? auth.organizationId;
758
808
  const base = authContext(auth);
759
809
  const context = scope === void 0 ? base : {
760
810
  ...base,
761
811
  tenant: scope
762
812
  };
763
- const session = scope === void 0 ? void 0 : { settings: { "better_supabase.tenant": scope } };
813
+ const session = sessionWith(ids, scope);
764
814
  const recorder = new StatsRecorder(parent);
765
815
  let db;
766
816
  let sql;
767
817
  return {
768
818
  ...credentials,
819
+ ...ids,
769
820
  auth: resolution.auth,
770
821
  resolution,
771
822
  get supabase() {
@@ -790,25 +841,30 @@ function createServer(betterSupabase, options = {}) {
790
841
  };
791
842
  };
792
843
  /** Clients and repositories are built on first access: most scopes use one of them. */
793
- const contextFor = (resolution, requestHeaders, parent, until = 0, tenant, active) => {
794
- if (active) return supportContextFor(resolution, active, parent, tenant);
844
+ const contextFor = (resolution, requestHeaders, parent, until = 0, tenant, active, ids = {}) => {
845
+ if (active) return supportContextFor(resolution, active, parent, tenant, ids);
795
846
  const { auth } = resolution;
796
- if (auth.kind === "apiKey") return apiKeyContextFor(resolution, auth, parent, tenant);
847
+ if (auth.kind === "apiKey") return apiKeyContextFor(resolution, auth, parent, tenant, ids);
797
848
  const context = tenant === void 0 ? authContext(auth) : {
798
849
  ...authContext(auth),
799
850
  tenant
800
851
  };
801
- const headers = tenant === void 0 ? requestHeaders : {
852
+ const clientHeaders = tenant === void 0 ? requestHeaders : {
802
853
  ...requestHeaders,
803
854
  [TENANT_HEADER]: tenant
804
855
  };
805
- const session = tenant === void 0 ? void 0 : { settings: { "better_supabase.tenant": tenant } };
856
+ const headers = {
857
+ ...idPolicy.headers(ids),
858
+ ...clientHeaders
859
+ };
860
+ const sharesClient = auth.kind !== "user";
861
+ const session = sessionWith(ids, tenant);
806
862
  const recorder = new StatsRecorder(parent);
807
863
  let supabase;
808
864
  let db;
809
865
  let sql;
810
866
  const sqlClaims = auth.kind === "user" ? auth.claims : auth.kind === "anon" ? { role: "anon" } : void 0;
811
- const client = () => supabase ??= supabaseFor(auth, headers);
867
+ const client = () => supabase ??= supabaseFor(auth, sharesClient ? clientHeaders : headers);
812
868
  let replica;
813
869
  const replicaUrl = () => {
814
870
  const url = readUrl();
@@ -817,6 +873,7 @@ function createServer(betterSupabase, options = {}) {
817
873
  };
818
874
  return {
819
875
  ...credentials,
876
+ ...ids,
820
877
  auth,
821
878
  resolution,
822
879
  get supabase() {
@@ -825,7 +882,7 @@ function createServer(betterSupabase, options = {}) {
825
882
  get db() {
826
883
  if (db) return db;
827
884
  const url = replicaUrl();
828
- const rest = supabase ?? restAt(env().url, auth, headers);
885
+ const rest = (sharesClient ? void 0 : supabase) ?? restAt(env().url, auth, headers);
829
886
  const connected = betterSupabase.connect(rest, context, {
830
887
  stats: recorder,
831
888
  ...url && replica ? { executor: routedExecutor(postgrestExecutor(rest, executorOptions), postgrestExecutor(restAt(url, auth, headers), executorOptions), replica) } : tunedExecutor ? { executor: postgrestExecutor(rest, executorOptions) } : {}
@@ -850,7 +907,7 @@ function createServer(betterSupabase, options = {}) {
850
907
  }
851
908
  };
852
909
  };
853
- const fromResolution = (resolution, request, contextOptions, tenant) => contextFor(resolution, options.headers?.(request) ?? {}, contextOptions.stats, contextOptions.pinnedUntil ?? (readUrl() ? pinnedUntil(resolution.requestCookies) : 0), tenant, contextOptions.support);
910
+ const fromResolution = (resolution, request, contextOptions, tenant) => contextFor(resolution, options.headers?.(request) ?? {}, contextOptions.stats, contextOptions.pinnedUntil ?? (readUrl() ? pinnedUntil(resolution.requestCookies) : 0), tenant, contextOptions.support, idPolicy.forRequest(request, contextOptions));
854
911
  const resolve = async (request, resolveOptions = {}) => {
855
912
  const claims = options.auth?.claims ?? betterSupabase.claimsSchema;
856
913
  const userMetadata = betterSupabase.userMetadataSchema;
@@ -902,7 +959,7 @@ function createServer(betterSupabase, options = {}) {
902
959
  headers: {},
903
960
  requestCookies: [],
904
961
  apply: (response) => response
905
- }, {}, contextOptions.stats, contextOptions.pinnedUntil, contextOptions.tenant, contextOptions.support),
962
+ }, {}, contextOptions.stats, contextOptions.pinnedUntil, contextOptions.tenant, contextOptions.support, idPolicy.forRequest(void 0, contextOptions)),
906
963
  context(request, contextOptions = {}) {
907
964
  const { refresh, cookies, ...rest } = contextOptions;
908
965
  const key = Object.keys(rest).length === 0 ? `${String(refresh ?? false)}:${String(cookies ?? true)}` : void 0;
@@ -998,10 +1055,7 @@ function createServer(betterSupabase, options = {}) {
998
1055
  reason: forOptions.reason ?? "job"
999
1056
  }) } : {}
1000
1057
  };
1001
- const session = {
1002
- ...support?.readOnly ? { readOnly: true } : {},
1003
- ...tenant === void 0 ? {} : { settings: { "better_supabase.tenant": tenant } }
1004
- };
1058
+ const session = sessionWith({}, tenant, support?.readOnly);
1005
1059
  return ok(sqlFor(claims, {
1006
1060
  actor: {
1007
1061
  id: actor.id,
@@ -1011,7 +1065,7 @@ function createServer(betterSupabase, options = {}) {
1011
1065
  },
1012
1066
  claims,
1013
1067
  ...tenant === void 0 ? {} : { tenant }
1014
- }, void 0, Object.keys(session).length === 0 ? void 0 : session));
1068
+ }, void 0, session));
1015
1069
  });
1016
1070
  }
1017
1071
  };
@@ -1,10 +1,10 @@
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-CeVeeXwz.js";
3
+ import { t as BetterServer } from "../server-C6DWVEVG.js";
4
4
  import { j as StorageImageOptions } from "../index-D48jVS-N.js";
5
5
  import { a as AuthorizedContext, c as Unwrapped, n as ActionParsed, o as BlockActionOptions, r as ActionResult, s as BlockRequireOptions } from "../kit-B5tid-q5.js";
6
6
  import { t as RefusalRedirects } from "../refusal-D1rgbzNq.js";
7
- import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-DuVb4Xa8.js";
7
+ import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-CdPDPpFs.js";
8
8
  import { StandardSchemaV1 } from "@standard-schema/spec";
9
9
  //#region src/astro/index.d.ts
10
10
  /** The part of Astro's `APIContext` (middleware, pages, endpoints, actions) the integration uses. */
@@ -1,9 +1,9 @@
1
- import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-Bc1o3zyy.js";
1
+ import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-CHnPkCPd.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
4
  import { t as storageImageUrl } from "../image-url-pIVlO6R1.js";
5
5
  import { t as around } from "../shared-CBxosKK3.js";
6
- import { i as localsOf, r as frameworkEntry } from "../framework-CONDyPYx.js";
6
+ import { i as localsOf, r as frameworkEntry } from "../framework-xjTBoyBB.js";
7
7
  import { r as refusalResponse } from "../refusal-CeJWxmkH.js";
8
8
  //#region src/astro/index.ts
9
9
  function runtimeEnv(locals) {
@@ -152,9 +152,16 @@ interface AttachmentScanJob {
152
152
  interface AttachmentScanner {
153
153
  /** Scans one uploaded file and records the verdict. */
154
154
  scan(id: string, signal?: AbortSignal): AsyncResult<Attachment>;
155
- /** A jobs handler: `queue.work('attachment-scans', scanner.job)`. */
155
+ /**
156
+ * A jobs handler: `queue.work('attachment-scans', scanner.job)`. A deleted
157
+ * attachment completes the job; other errors throw so the queue retries.
158
+ */
156
159
  readonly job: JobHandler<AttachmentScanJob>;
157
- /** An outbox sink that scans each `attachment.uploaded` event's file. */
160
+ /**
161
+ * An outbox sink that scans each `attachment.uploaded` event's file. An
162
+ * event for a deleted attachment is skipped, so it never holds up the
163
+ * events behind it; other errors throw so the relay retries the batch.
164
+ */
158
165
  sink(): EventSink;
159
166
  }
160
167
  /**
@@ -193,9 +200,16 @@ interface ObjectScanJob {
193
200
  interface ObjectScanner {
194
201
  /** Scans one object and records the verdict; a clean or infected object is not scanned again. */
195
202
  scan(bucket: string, path: string, signal?: AbortSignal): AsyncResult<ScannedObject>;
196
- /** A jobs handler: `queue.work('object-scans', scanner.job)`. */
203
+ /**
204
+ * A jobs handler: `queue.work('object-scans', scanner.job)`. An object
205
+ * deleted from storage completes the job; other errors throw.
206
+ */
197
207
  readonly job: JobHandler<ObjectScanJob>;
198
- /** An outbox sink that scans each `object.uploaded` event's object. */
208
+ /**
209
+ * An outbox sink that scans each `object.uploaded` event's object. An
210
+ * event for an object deleted from storage is skipped; other errors throw
211
+ * so the relay retries the batch.
212
+ */
199
213
  sink(): EventSink;
200
214
  }
201
215
  /**
@@ -49,6 +49,18 @@ function stored(reply) {
49
49
  }
50
50
  });
51
51
  }
52
+ /**
53
+ * Waits for a scan from a job or an event. A scan whose target is gone (the
54
+ * attachment row, or for an object the stored object) is done, not a
55
+ * failure, so the job or event is not retried; every other error throws.
56
+ */
57
+ async function settle(scanned, gone) {
58
+ const result = await scanned;
59
+ if (result.ok || gone(result.error)) return;
60
+ await scanned.orThrow();
61
+ }
62
+ const attachmentGone = (error) => error.kind === "not_found" && error.hint === "ATTACHMENT_NOT_FOUND";
63
+ const objectGone = (error) => error.kind === "not_found" && error.code === "NoSuchKey";
52
64
  function lookup(call, id) {
53
65
  return call("get_attachment", { id }, (value) => value).andThen((value) => Promise.resolve(isRecord(value) ? ok(attachmentOf(value)) : err(notFound())));
54
66
  }
@@ -145,13 +157,13 @@ function createAttachmentScanner(options) {
145
157
  return {
146
158
  scan,
147
159
  job: async (payload, _job, signal) => {
148
- await scan(payload.attachmentId, signal).orThrow();
160
+ await settle(scan(payload.attachmentId, signal), attachmentGone);
149
161
  },
150
162
  sink: () => ({ async send(events) {
151
163
  for (const event of events) {
152
164
  if ((event.type.startsWith(prefix) ? event.type.slice(prefix.length) : event.type) !== "attachment.uploaded" || !isRecord(event.data)) continue;
153
165
  const id = optionalText(event.data["attachmentId"]);
154
- if (id !== void 0) await scan(id).orThrow();
166
+ if (id !== void 0) await settle(scan(id), attachmentGone);
155
167
  }
156
168
  } })
157
169
  };
@@ -206,14 +218,14 @@ function createObjectScanner(options) {
206
218
  return {
207
219
  scan,
208
220
  job: async (payload, _job, signal) => {
209
- await scan(payload.bucket, payload.path, signal).orThrow();
221
+ await settle(scan(payload.bucket, payload.path, signal), objectGone);
210
222
  },
211
223
  sink: () => ({ async send(events) {
212
224
  for (const event of events) {
213
225
  if ((event.type.startsWith(prefix) ? event.type.slice(prefix.length) : event.type) !== "object.uploaded" || !isRecord(event.data)) continue;
214
226
  const bucket = optionalText(event.data["bucket"]);
215
227
  const path = optionalText(event.data["path"]);
216
- if (bucket !== void 0 && path !== void 0) await scan(bucket, path).orThrow();
228
+ if (bucket !== void 0 && path !== void 0) await settle(scan(bucket, path), objectGone);
217
229
  }
218
230
  } })
219
231
  };
@@ -132,9 +132,17 @@ interface DataExporter {
132
132
  * emits `data_export.completed`). A failure marks it failed and returns the error.
133
133
  */
134
134
  run(exportId: string, signal?: AbortSignal): AsyncResult<DataExport>;
135
- /** A jobs handler: `queue.work('data-exports', exporter.job)`. */
135
+ /**
136
+ * A jobs handler: `queue.work('data-exports', exporter.job)`. An export
137
+ * that is no longer pending or failed (cancelled, deleted, running or
138
+ * ready) completes the job; other errors throw so the queue retries.
139
+ */
136
140
  readonly job: JobHandler<DataExportJob>;
137
- /** An outbox sink that runs each `data_export.requested` export. */
141
+ /**
142
+ * An outbox sink that runs each `data_export.requested` export. An event
143
+ * for an export that is no longer pending or failed is skipped, so it never
144
+ * holds up the events behind it; other errors throw so the relay retries.
145
+ */
138
146
  sink(): EventSink;
139
147
  }
140
148
  /** Runs requested exports with a service-role client. */
@@ -180,16 +180,21 @@ function createDataExporter(options) {
180
180
  files: written.data
181
181
  }, exportOf);
182
182
  });
183
+ const settle = async (ran) => {
184
+ const result = await ran;
185
+ if (result.ok || result.error.hint === "DATA_EXPORT_NOT_FOUND") return;
186
+ await ran.orThrow();
187
+ };
183
188
  return {
184
189
  run,
185
190
  job: async (payload, _job, signal) => {
186
- await run(payload.exportId, signal).orThrow();
191
+ await settle(run(payload.exportId, signal));
187
192
  },
188
193
  sink: () => ({ async send(events) {
189
194
  for (const event of events) {
190
195
  if ((event.type.startsWith(prefix) ? event.type.slice(prefix.length) : event.type) !== "data_export.requested" || !isRecord(event.data)) continue;
191
196
  const id = optionalText(event.data["exportId"]);
192
- if (id !== void 0) await run(id).orThrow();
197
+ if (id !== void 0) await settle(run(id));
193
198
  }
194
199
  } })
195
200
  };
package/dist/cli/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { i as run } from "./run-DNWxHynX.js";
2
+ import { i as run } from "./run-C8tnlHSb.js";
3
3
  import { t as colorEnabled } from "./style-C0NFdJRL.js";
4
4
  import { text } from "node:stream/consumers";
5
5
  //#region src/cli/bin.ts
@@ -2,12 +2,12 @@ import { a as list, r as defineCliCommand } from "./command-CK14fP91.js";
2
2
  import { n as CliError } from "./errors-4v4DTtda.js";
3
3
  import { i as writeIfChanged, t as display } from "./io-DI1mTdSA.js";
4
4
  import { i as plain, r as painter } from "./style-C0NFdJRL.js";
5
- import { t as VERSION } from "./version-hr88OZG0.js";
5
+ import { t as VERSION } from "./version-C_4JwyiM.js";
6
6
  import { s as providerLabel, t as compiledReadSets } from "./read-sets-CETOSFx4.js";
7
7
  import { s as stdinDatabaseUrl } from "./config-NiPxAmUF.js";
8
8
  import { c as migrationCommand, d as schemaPaths, i as findRepoRoot, l as pgFunctionHooks, n as declarativeSchemasDir, p as tomlGet, r as diffEngine, s as httpHooks, u as readSupabaseToml } from "./supabase-toml-B-bIukQF.js";
9
9
  import { t as byCodePoint } from "./compare-BmIWVEui.js";
10
- import { A as exposed, C as MetadataRejectedError, D as accessModule, E as AUTHORIZATION_RULES, F as qualified, I as tableObject, M as lineOf, N as permissionCatalogKeys, O as entitlementsModule, P as policyObject, S as configFor, _ as METADATA_GAPS_TEXT, a as renderFiles, c as loadSnapshot, j as exposedSchemas, k as catalogOf, l as managementTarget, p as snapshotFile, r as readMetadataSnapshot, u as openSource, v as CACHE_DIR } from "./gen-BGLb_zou.js";
10
+ import { A as exposed, C as MetadataRejectedError, D as accessModule, E as AUTHORIZATION_RULES, F as qualified, I as tableObject, M as lineOf, N as permissionCatalogKeys, O as entitlementsModule, P as policyObject, S as configFor, _ as METADATA_GAPS_TEXT, a as renderFiles, c as loadSnapshot, j as exposedSchemas, k as catalogOf, l as managementTarget, p as snapshotFile, r as readMetadataSnapshot, u as openSource, v as CACHE_DIR } from "./gen-DeuDgPxN.js";
11
11
  import { n as withSpinner } from "./prompts-BNcNfAve.js";
12
12
  import { t as connect } from "./db-DOBPt660.js";
13
13
  import { dirname, resolve } from "node:path";
@@ -0,0 +1,2 @@
1
+ import { n as genCommand } from "./gen-DeuDgPxN.js";
2
+ export { genCommand };
@@ -2,7 +2,7 @@ import { r as defineCliCommand } from "./command-CK14fP91.js";
2
2
  import { n as CliError } from "./errors-4v4DTtda.js";
3
3
  import { i as writeIfChanged, n as importPath, r as sameText, t as display } from "./io-DI1mTdSA.js";
4
4
  import { r as painter } from "./style-C0NFdJRL.js";
5
- import { t as VERSION } from "./version-hr88OZG0.js";
5
+ import { t as VERSION } from "./version-C_4JwyiM.js";
6
6
  import { a as entitlementsMode, c as unsafeKey, i as entitlementRequirements, n as accessProviderMode, o as moduleKeyProblems, r as accessRequirements, s as providerLabel, t as compiledReadSets } from "./read-sets-CETOSFx4.js";
7
7
  import { s as stdinDatabaseUrl, t as databaseUrl } from "./config-NiPxAmUF.js";
8
8
  import { l as pgFunctionHooks, p as tomlGet, u as readSupabaseToml } from "./supabase-toml-B-bIukQF.js";
@@ -527,6 +527,6 @@ export declare function emitModule(model: Model, options: EmitOptions): string;
527
527
  export declare function loadConfig(cwd: string, explicit?: string): Promise<ResolvedConfig>;
528
528
  //#endregion
529
529
  //#region src/cli/version.d.ts
530
- export declare const VERSION = "0.6.0";
530
+ export declare const VERSION = "0.6.1";
531
531
  //#endregion
532
532
  export type { Catalog, CatalogCheck, CatalogColumn, CatalogColumnGrant, CatalogEnum, CatalogForeignKey, CatalogFunction, CatalogFunctionArg, CatalogGrant, CatalogIndex, CatalogPolicy, CatalogTable, CatalogTrigger, CatalogUnique, CliArgs, CliCommandDef, CliContext, CliEnv, CliErrorCode, CliErrorOptions, CliIo, CliProblem, CliProblemExtensions, Command, CommandContext, CommandResult, ExitCode, ExtrasFunction, ExtrasHook, ExtrasHookFunction, ExtrasTable, ForeignKeyAction, GeneratorMetadata, IntrospectionSource, ManagementSourceOptions, ParsedArgs, Queryable, RunOptions, RunResult, Snapshot, SnapshotBucket, SnapshotExtras };
package/dist/cli/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { a as list, r as defineCliCommand } from "./command-CK14fP91.js";
2
2
  import { n as CliError, t as CLI_ERRORS_URL } from "./errors-4v4DTtda.js";
3
- import { i as run, n as help, r as registerCommand, t as commandNames } from "./run-DNWxHynX.js";
4
- import { t as VERSION } from "./version-hr88OZG0.js";
3
+ import { i as run, n as help, r as registerCommand, t as commandNames } from "./run-C8tnlHSb.js";
4
+ import { t as VERSION } from "./version-C_4JwyiM.js";
5
5
  import { a as loadConfig } from "./config-NiPxAmUF.js";
6
- import { L as toCatalog, a as renderFiles, b as emitModule, c as loadSnapshot, d as parseSnapshot, f as serializeSnapshot, g as pgSource, h as managementSource, m as introspect, o as runGen, x as buildModel, y as GENERATED_HEADER } from "./gen-BGLb_zou.js";
6
+ import { L as toCatalog, a as renderFiles, b as emitModule, c as loadSnapshot, d as parseSnapshot, f as serializeSnapshot, g as pgSource, h as managementSource, m as introspect, o as runGen, x as buildModel, y as GENERATED_HEADER } from "./gen-DeuDgPxN.js";
7
7
  //#region src/cli/introspect/from-catalog.ts
8
8
  /**
9
9
  * Builds a snapshot from catalog records: the inverse of `toCatalog`. Tests
@@ -1,6 +1,6 @@
1
1
  import { a as list, r as defineCliCommand } from "./command-CK14fP91.js";
2
2
  import { i as writeIfChanged, t as display } from "./io-DI1mTdSA.js";
3
- import { t as VERSION } from "./version-hr88OZG0.js";
3
+ import { t as VERSION } from "./version-C_4JwyiM.js";
4
4
  import { a as loadConfig, r as findConfig } from "./config-NiPxAmUF.js";
5
5
  import { a as findSupabaseRoot, p as tomlGet, r as diffEngine, t as PGDELTA_TABLE, u as readSupabaseToml } from "./supabase-toml-B-bIukQF.js";
6
6
  import { t as TYPEGEN_VERSION } from "./typegen-version-DeFbtzYI.js";
@@ -2,7 +2,7 @@ import { r as defineCliCommand } from "./command-CK14fP91.js";
2
2
  import { i as writeIfChanged, r as sameText, t as display } from "./io-DI1mTdSA.js";
3
3
  import { r as painter } from "./style-C0NFdJRL.js";
4
4
  import { t as fileDiff } from "./diff-SjkO5rNr.js";
5
- import { T as serializeGenerator, c as loadSnapshot, f as serializeSnapshot, s as sourceArgs, t as SOURCE_ARGS, w as restrictSchemas } from "./gen-BGLb_zou.js";
5
+ import { T as serializeGenerator, c as loadSnapshot, f as serializeSnapshot, s as sourceArgs, t as SOURCE_ARGS, w as restrictSchemas } from "./gen-DeuDgPxN.js";
6
6
  import { n as withSpinner } from "./prompts-BNcNfAve.js";
7
7
  import { resolve } from "node:path";
8
8
  import { readFile } from "node:fs/promises";
@@ -2,7 +2,7 @@ import { n as __toESM } from "./rolldown-runtime-BPOCksWG.js";
2
2
  import { c as parseArgs$2, i as joinRepeated, l as renderUsage, n as cliContext, o as listArgs, s as defineCommand, t as GLOBAL_ARGS, u as runCommand } from "./command-CK14fP91.js";
3
3
  import { n as CliError, r as toCliError } from "./errors-4v4DTtda.js";
4
4
  import { n as highlight, r as painter } from "./style-C0NFdJRL.js";
5
- import { t as VERSION } from "./version-hr88OZG0.js";
5
+ import { t as VERSION } from "./version-C_4JwyiM.js";
6
6
  import { stripVTControlCharacters } from "node:util";
7
7
  import { resolve } from "node:path";
8
8
  //#region src/cli/legacy.ts
@@ -134,11 +134,11 @@ function renderError(error, options) {
134
134
  //#region src/cli/run.ts
135
135
  const COMMANDS = /* @__PURE__ */ new Map([
136
136
  ["init", {
137
- load: () => import("./init-BIIwclPg.js").then((m) => m.initCommand),
137
+ load: () => import("./init-C7Xd0Kda.js").then((m) => m.initCommand),
138
138
  description: "Writes better-supabase.config.ts, src/lib/supabase/index.ts and glue for the frameworks in package.json"
139
139
  }],
140
140
  ["add", {
141
- load: () => import("./init-BIIwclPg.js").then((m) => m.addCommand),
141
+ load: () => import("./init-C7Xd0Kda.js").then((m) => m.addCommand),
142
142
  description: "Adds glue for an integration to an existing project"
143
143
  }],
144
144
  ["env", {
@@ -154,11 +154,11 @@ const COMMANDS = /* @__PURE__ */ new Map([
154
154
  description: "Installs the Agent Skills that ship with this version of better-supabase"
155
155
  }],
156
156
  ["gen", {
157
- load: () => import("./gen-DAH8FM2W.js").then((m) => m.genCommand),
157
+ load: () => import("./gen-4JlOwgWG.js").then((m) => m.genCommand),
158
158
  description: "Writes database.types.ts, generated.ts and its metadata module from the database"
159
159
  }],
160
160
  ["introspect", {
161
- load: () => import("./introspect-DNUTuNvb.js").then((m) => m.introspectCommand),
161
+ load: () => import("./introspect-CSnMJ94U.js").then((m) => m.introspectCommand),
162
162
  description: "Saves the database schema as a snapshot for offline gen"
163
163
  }],
164
164
  ["openapi", {
@@ -170,7 +170,7 @@ const COMMANDS = /* @__PURE__ */ new Map([
170
170
  description: "Renders the fixtures from defineSeed() (better-supabase/testing) to SQL"
171
171
  }],
172
172
  ["doctor", {
173
- load: () => import("./doctor-B4JOm_ox.js").then((m) => m.doctorCommand),
173
+ load: () => import("./doctor-BMqBgM3X.js").then((m) => m.doctorCommand),
174
174
  description: "Checks RLS, indexes, drift, auth config and env files; exits 1 on errors, or on warnings with --strict"
175
175
  }],
176
176
  ["sql", {
@@ -1,4 +1,4 @@
1
1
  //#region src/cli/version.ts
2
- const VERSION = "0.6.0";
2
+ const VERSION = "0.6.1";
3
3
  //#endregion
4
4
  export { VERSION as t };
@@ -1,5 +1,5 @@
1
1
  import { a as problemResponse } from "./problem-BreOl8b8.js";
2
- import { C as serverCore, S as withServerContext, _ as withSession, g as withSupport, h as withTenant, s as createServer } from "./adapter-Bc1o3zyy.js";
2
+ import { C as serverCore, S as withServerContext, _ as withSession, g as withSupport, h as withTenant, s as createServer } from "./adapter-CHnPkCPd.js";
3
3
  import { s as withPrimaryPin } from "./replicas-CwrYp5Zj.js";
4
4
  import { r as guard, t as defaultExpose } from "./respond-BUgsXNgk.js";
5
5
  import { a as withAuthMode, i as withAuth, o as withJwtClaims, s as withUserClaims } from "./claims-DDBQT6BK.js";
@@ -3,7 +3,7 @@ import { a as EventHub } from "./events-DWDhx77e.js";
3
3
  import { i as CookieScope, s as SessionEncoding } from "./session-ChiXDZdZ.js";
4
4
  import { r as AuthState, t as AuthResolution } from "./resolve-KW8nCeL6.js";
5
5
  import { b as Db, t as BetterSupabase } from "./define-CJJkkr1-.js";
6
- import { b as ActiveSupport, g as ReplicaState, i as ServerContext, n as ContextOptions, o as ServerOptions, t as BetterServer } from "./server-CeVeeXwz.js";
6
+ import { _ as ReplicaState, i as ServerContext, n as ContextOptions, o as ServerOptions, t as BetterServer, x as ActiveSupport } from "./server-C6DWVEVG.js";
7
7
  import { d as RefreshPolicy, r as GuardOptions } from "./respond-DoBijysA.js";
8
8
  import { SupabaseClient } from "@supabase/supabase-js";
9
9
  import { Entry, SingleKeyEntry } from "@supabase/middleware";
@@ -1,6 +1,6 @@
1
1
  import { L as TableKey, a as AnyModels, i as AnyFunctions } from "../types-6BdhkmZe.js";
2
2
  import { t as BetterSupabase } from "../define-CJJkkr1-.js";
3
- import { i as ServerContext, o as ServerOptions, t as BetterServer } from "../server-CeVeeXwz.js";
3
+ import { i as ServerContext, o as ServerOptions, t as BetterServer } from "../server-C6DWVEVG.js";
4
4
  import { t as AuthSession } from "../view-DbxLNu8L.js";
5
5
  import { i as MiddlewareOptions, r as GuardOptions } from "../respond-DoBijysA.js";
6
6
  import { s as BlockRequireOptions } from "../kit-B5tid-q5.js";
@@ -1,12 +1,12 @@
1
1
  import { n as dbError } from "../errors-B11Duf73.js";
2
2
  import { r as err } from "../result-DzUbqgdW.js";
3
3
  import { a as problemResponse } from "../problem-BreOl8b8.js";
4
- import { a as unexpectedResponse, c as extendServer, l as withExtra, n as flushEvents, s as createServer } from "../adapter-Bc1o3zyy.js";
4
+ import { a as unexpectedResponse, c as extendServer, l as withExtra, n as flushEvents, s as createServer } from "../adapter-CHnPkCPd.js";
5
5
  import { a as respond, t as defaultExpose } from "../respond-BUgsXNgk.js";
6
- import { t as withBetterSupabase } from "../composite-DhE66P5u.js";
6
+ import { t as withBetterSupabase } from "../composite-CLqs9-OA.js";
7
7
  import { t as defineResource } from "../resource-BsvzCMlX.js";
8
8
  import { i as requireCaller } from "../kit-Fm-Fv7q5.js";
9
- import { t as EVERY_CALLER } from "../framework-CONDyPYx.js";
9
+ import { t as EVERY_CALLER } from "../framework-xjTBoyBB.js";
10
10
  import { bufferRequest, pipeline, seedContext } from "@supabase/middleware";
11
11
  import { withCors } from "@supabase/middleware/cors";
12
12
  //#region src/bridges/edge.ts
@@ -1,6 +1,6 @@
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 { i as ServerContext, n as ContextOptions, o as ServerOptions, t as BetterServer } from "../server-CeVeeXwz.js";
3
+ import { i as ServerContext, n as ContextOptions, o as ServerOptions, t as BetterServer } from "../server-C6DWVEVG.js";
4
4
  import { i as MiddlewareOptions, r as GuardOptions } from "../respond-DoBijysA.js";
5
5
  import { t as Validated } from "../shared-DDSjEGDR.js";
6
6
  import { AnyEntry, Contributions } from "@supabase/middleware";
@@ -1,9 +1,9 @@
1
1
  import { t as DbException } from "../db-exception-CnWcYPxL.js";
2
2
  import { o as toProblem } from "../problem-BreOl8b8.js";
3
- import { a as unexpectedResponse, c as extendServer, s as createServer, y as refreshFor } from "../adapter-Bc1o3zyy.js";
3
+ import { a as unexpectedResponse, c as extendServer, s as createServer, y as refreshFor } from "../adapter-CHnPkCPd.js";
4
4
  import { m as serializeCookie } from "../resolve-D_IcnvFd.js";
5
5
  import { a as respond, r as guard, t as defaultExpose } from "../respond-BUgsXNgk.js";
6
- import { t as withBetterSupabase } from "../composite-DhE66P5u.js";
6
+ import { t as withBetterSupabase } from "../composite-CLqs9-OA.js";
7
7
  import { r as handoffOf } from "../shared-CBxosKK3.js";
8
8
  import { bufferRequest, pipeline, seedContext } from "@supabase/middleware";
9
9
  import { StatusError, setResponseHeaders } from "expo-server";
@@ -1,7 +1,7 @@
1
1
  import { a as AnyModels, i as AnyFunctions } from "./types-6BdhkmZe.js";
2
- import { o as ServerOptions } from "./server-CeVeeXwz.js";
2
+ import { o as ServerOptions } from "./server-C6DWVEVG.js";
3
3
  import { t as AuthSession } from "./view-DbxLNu8L.js";
4
- import { a as SessionEntryConfig, n as BetterSupabaseContributions } from "./composite-Bt1YK3Ke.js";
4
+ import { a as SessionEntryConfig, n as BetterSupabaseContributions } from "./composite-pSfeJNce.js";
5
5
  import { t as RefusalRedirects } from "./refusal-D1rgbzNq.js";
6
6
  //#region src/server/framework.d.ts
7
7
  /** What the framework factories (`createSvelteKit`, `createReactRouter`, `createTanStackStart`) take. */
@@ -1,5 +1,5 @@
1
1
  import { n as toSession } from "./view-BeFcRV6G.js";
2
- import { t as withBetterSupabase } from "./composite-DhE66P5u.js";
2
+ import { t as withBetterSupabase } from "./composite-CLqs9-OA.js";
3
3
  //#region src/server/framework.ts
4
4
  /** Every caller: the framework factories guard per loader, action or route instead. */
5
5
  const EVERY_CALLER = [
@@ -1,7 +1,7 @@
1
1
  import { L as TableKey, a as AnyModels, i as AnyFunctions } from "../types-6BdhkmZe.js";
2
2
  import { r as AuthState } from "../resolve-KW8nCeL6.js";
3
3
  import { t as BetterSupabase } from "../define-CJJkkr1-.js";
4
- import { i as ServerContext, o as ServerOptions, t as BetterServer } from "../server-CeVeeXwz.js";
4
+ import { i as ServerContext, o as ServerOptions, t as BetterServer } from "../server-C6DWVEVG.js";
5
5
  import { t as AuthSession } from "../view-DbxLNu8L.js";
6
6
  import { i as MiddlewareOptions, r as GuardOptions } from "../respond-DoBijysA.js";
7
7
  import { s as BlockRequireOptions } from "../kit-B5tid-q5.js";
@@ -1,9 +1,9 @@
1
1
  import { r as dbErrorOf } from "../errors-B11Duf73.js";
2
2
  import { a as problemResponse } from "../problem-BreOl8b8.js";
3
- import { a as unexpectedResponse, c as extendServer, n as flushEvents, s as createServer } from "../adapter-Bc1o3zyy.js";
3
+ import { a as unexpectedResponse, c as extendServer, n as flushEvents, s as createServer } from "../adapter-CHnPkCPd.js";
4
4
  import { n as toSession } from "../view-BeFcRV6G.js";
5
5
  import { a as respond, t as defaultExpose } from "../respond-BUgsXNgk.js";
6
- import { t as withBetterSupabase } from "../composite-DhE66P5u.js";
6
+ import { t as withBetterSupabase } from "../composite-CLqs9-OA.js";
7
7
  import { t as defineResource } from "../resource-BsvzCMlX.js";
8
8
  import { i as requireCaller } from "../kit-Fm-Fv7q5.js";
9
9
  import { r as handoffOf } from "../shared-CBxosKK3.js";
@@ -1,6 +1,6 @@
1
1
  import { L as TableKey, a as AnyModels, i as AnyFunctions } from "../types-6BdhkmZe.js";
2
2
  import { t as BetterSupabase } from "../define-CJJkkr1-.js";
3
- import { i as ServerContext, o as ServerOptions, t as BetterServer } from "../server-CeVeeXwz.js";
3
+ import { i as ServerContext, o as ServerOptions, t as BetterServer } from "../server-C6DWVEVG.js";
4
4
  import { r as GuardOptions } from "../respond-DoBijysA.js";
5
5
  import { i as ResourceOperation } from "../index-Bxih3l0u.js";
6
6
  import { a as ResourceRouteOptions } from "../resource-D6Uc7Sk7.js";
package/dist/mcp/index.js CHANGED
@@ -4,7 +4,7 @@ import { n as validate } from "../standard-BK0cqJ7y.js";
4
4
  import { a as problemResponse, o as toProblem } from "../problem-BreOl8b8.js";
5
5
  import { t as SPEC_PINS } from "../spec-pins--j6mTok4.js";
6
6
  import { t as buildJsonSchema } from "../json-schema-CvER4kgT.js";
7
- import { c as extendServer, l as withExtra, n as flushEvents, s as createServer } from "../adapter-Bc1o3zyy.js";
7
+ import { c as extendServer, l as withExtra, n as flushEvents, s as createServer } from "../adapter-CHnPkCPd.js";
8
8
  import { n as jsonResponse, t as jsonReplacer } from "../json-CEnpTHlZ.js";
9
9
  import { o as settle, r as guard, t as defaultExpose } from "../respond-BUgsXNgk.js";
10
10
  import { t as defineResource } from "../resource-BsvzCMlX.js";
@@ -1,7 +1,7 @@
1
1
  import { a as AnyModels, i as AnyFunctions } from "../../types-6BdhkmZe.js";
2
2
  import { r as AuthState } from "../../resolve-KW8nCeL6.js";
3
3
  import { t as BetterSupabase } from "../../define-CJJkkr1-.js";
4
- import { i as ServerContext$1, o as ServerOptions, t as BetterServer } from "../../server-CeVeeXwz.js";
4
+ import { i as ServerContext$1, o as ServerOptions, t as BetterServer } from "../../server-C6DWVEVG.js";
5
5
  import { r as GuardOptions, t as AllowedCaller } from "../../respond-DoBijysA.js";
6
6
  import { AuthInfo, CallToolResult, Icon, InputRequiredResult, OAuthTokenVerifier, RegisteredTool, ScopeChallengeHandler, ServerContext, StandardSchemaWithJSON, ToolAnnotations } from "@modelcontextprotocol/server";
7
7
  //#region src/mcp/sdk/sdk.d.ts
@@ -1,5 +1,5 @@
1
1
  import { o as delegationOf } from "../../impersonation-DcqaTBHx.js";
2
- import { c as extendServer, i as resolveToken, l as withExtra, n as flushEvents, s as createServer } from "../../adapter-Bc1o3zyy.js";
2
+ import { c as extendServer, i as resolveToken, l as withExtra, n as flushEvents, s as createServer } from "../../adapter-CHnPkCPd.js";
3
3
  import { r as guard } from "../../respond-BUgsXNgk.js";
4
4
  import { a as withCors, i as metadataPreflight, n as endpointPreflight, r as isMetadataRequest, t as discovery } from "../../http-DdYadv-o.js";
5
5
  import { OAuthError, bearerAuthChallengeResponse, verifyBearerToken } from "@modelcontextprotocol/server";
@@ -1,7 +1,7 @@
1
1
  import { a as AnyModels, i as AnyFunctions } from "../types-6BdhkmZe.js";
2
2
  import { r as AuthState } from "../resolve-KW8nCeL6.js";
3
3
  import { B as DbStats, K as ReadSet, it as QuerySpec, t as BetterSupabase, u as CacheAdapter } from "../define-CJJkkr1-.js";
4
- import { C as SupportOptions, D as supportSessions, E as SupportStartRequest, T as SupportSessions, b as ActiveSupport, i as ServerContext, n as ContextOptions, o as ServerOptions, t as BetterServer, w as SupportPolicy } from "../server-CeVeeXwz.js";
4
+ import { D as SupportStartRequest, E as SupportSessions, O as supportSessions, T as SupportPolicy, i as ServerContext, n as ContextOptions, o as ServerOptions, t as BetterServer, w as SupportOptions, x as ActiveSupport } from "../server-C6DWVEVG.js";
5
5
  import { n as AmrEntry, s as Impersonator, t as Aal } from "../mfa-Daak8ukG.js";
6
6
  import { t as tenantOf } from "../tenant-icPeuUBN.js";
7
7
  import { n as toSession, t as AuthSession } from "../view-DbxLNu8L.js";
@@ -9,10 +9,10 @@ import { a as problemResponse } from "../problem-BreOl8b8.js";
9
9
  import { i as claimsOf } from "../claims-PqzCxaTD.js";
10
10
  import { t as supportOf } from "../support-view-g4YLBeqX.js";
11
11
  import { t as tenantOf } from "../tenant-I1TEZ_BX.js";
12
- import { C as serverCore, c as extendServer, l as withExtra, n as flushEvents, p as supportCookieMaxAge, r as handle, s as createServer, t as bearerRequest, v as isPrefetch } from "../adapter-Bc1o3zyy.js";
12
+ import { C as serverCore, c as extendServer, l as withExtra, n as flushEvents, p as supportCookieMaxAge, r as handle, s as createServer, t as bearerRequest, v as isPrefetch } from "../adapter-CHnPkCPd.js";
13
13
  import { a as checkAal, n as toSession } from "../view-BeFcRV6G.js";
14
14
  import { o as settle, r as guard, t as defaultExpose } from "../respond-BUgsXNgk.js";
15
- import { t as supportSessions } from "../support-BivNqSpK.js";
15
+ import { t as supportSessions } from "../support-zIa1URaN.js";
16
16
  import { r as tagFor, t as cacheTagsOf } from "../tags-B99_U9Pp.js";
17
17
  import { n as formDataObject } from "../kit-Fm-Fv7q5.js";
18
18
  import { cache } from "react";
@@ -3,7 +3,7 @@ import { a as AnyModels, i as AnyFunctions } from "../types-6BdhkmZe.js";
3
3
  import { r as AuthState } from "../resolve-KW8nCeL6.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-CeVeeXwz.js";
6
+ import { i as ServerContext, o as ServerOptions, t as BetterServer } from "../server-C6DWVEVG.js";
7
7
  import { i as MiddlewareOptions, r as GuardOptions } from "../respond-DoBijysA.js";
8
8
  import { s as BlockRequireOptions } from "../kit-B5tid-q5.js";
9
9
  import { t as Validated } from "../shared-DDSjEGDR.js";
@@ -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-Bc1o3zyy.js";
5
+ import { c as extendServer, n as flushEvents, s as createServer, y as refreshFor } from "../adapter-CHnPkCPd.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-Bvv6aLjZ.js";
4
+ import "../version-CQt77F3T.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.0");
43
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.6.1");
44
44
  let histogram;
45
- if (options.metrics !== false) histogram = (options.meter ?? metrics.getMeter("better-supabase", "0.6.0")).createHistogram("db.client.operation.duration", {
45
+ if (options.metrics !== false) histogram = (options.meter ?? metrics.getMeter("better-supabase", "0.6.1")).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.0");
184
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.6.1");
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.0");
222
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.6.1");
223
223
  return betterSupabase.events.on("block", (event) => {
224
224
  const attributes = {
225
225
  ...options.attributes,
@@ -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-CeVeeXwz.js";
3
+ import { t as BetterServer } from "../server-C6DWVEVG.js";
4
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
5
  import { t as RefusalRedirects } from "../refusal-D1rgbzNq.js";
6
- import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-DuVb4Xa8.js";
6
+ import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-CdPDPpFs.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-Bc1o3zyy.js";
2
+ import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-CHnPkCPd.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-CONDyPYx.js";
6
+ import { i as localsOf, n as actionInput, r as frameworkEntry } from "../framework-xjTBoyBB.js";
7
7
  import { r as refusalResponse } from "../refusal-CeJWxmkH.js";
8
8
  //#region src/bridges/react-router.ts
9
9
  /**
@@ -5,11 +5,11 @@ import { _ as writeSession, a as CookieWrite, c as StoredSession, h as sessionCo
5
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";
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 clearSupportCookie, B as sqlSupportStore, C as SupportOptions, D as supportSessions, E as SupportStartRequest, F as SupportEndedBy, I as SupportListFilter, L as SupportSession, M as supportCookieValue, N as SqlSupportStoreOptions, O as SUPPORT_COOKIE, P as SupportCallerClaims, R as SupportSessionStore, S as SupportAuthorizeInput, T as SupportSessions, V as supportClaims, _ as DeleteAccountOptions, a as ServerDbOptions, b as ActiveSupport, c as createServer, d as SuspendAccountOptions, f as SuspendAccountResult, g as ReplicaState, h as PRIMARY_COOKIE, i as ServerContext, j as supportCookie, k as SupportCookieOptions, 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 DeleteAccountResult, w as SupportPolicy, x as SupportApi, y as deleteAccount, z as SupportStartInput } from "../server-CeVeeXwz.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";
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
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-Bt1YK3Ke.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
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
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
15
  import { a as ResourceRouteOptions, i as ResourcePagination, n as ResourceInput, o as defineResource, r as ResourceList, t as ResourceHandler } from "../resource-D6Uc7Sk7.js";
@@ -188,4 +188,4 @@ export declare function withDbStats(options?: {
188
188
  };
189
189
  }, () => DbStats>;
190
190
  //#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 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 };
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 };
@@ -3,14 +3,14 @@ import { a as problemResponse, i as isProblem, n as PROBLEM_TYPE_BASE, o as toPr
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
5
  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-Bc1o3zyy.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
7
  import { n as PRIMARY_COOKIE } from "../replicas-CwrYp5Zj.js";
8
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
9
  import { a as checkAal, i as amrOf, n as toSession, r as aalOf } from "../view-BeFcRV6G.js";
10
10
  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-BivNqSpK.js";
11
+ import { n as sqlSupportStore, r as supportClaims, t as supportSessions } from "../support-zIa1URaN.js";
12
12
  import { n as jwtClaimsOf, r as userClaimsOf, t as authModeOf } from "../claims-DDBQT6BK.js";
13
- import { n as withGuard, t as withBetterSupabase } from "../composite-DhE66P5u.js";
13
+ import { n as withGuard, t as withBetterSupabase } from "../composite-CLqs9-OA.js";
14
14
  import { t as defineResource } from "../resource-BsvzCMlX.js";
15
15
  import { i as withServerTiming, n as parseDbStats, r as withDbStats, t as DB_CALLS_HEADER } from "../timing-CyTQPubY.js";
16
16
  import { n as tagCache, r as tagFor, t as cacheTagsOf } from "../tags-B99_U9Pp.js";
@@ -278,6 +278,14 @@ interface ReplicaState {
278
278
  pin(): void;
279
279
  }
280
280
  //#endregion
281
+ //#region src/server/request-ids.d.ts
282
+ interface RequestIdOptions {
283
+ readonly requestHeader?: string;
284
+ readonly correlationHeader?: string;
285
+ readonly incoming?: boolean;
286
+ readonly generate?: boolean;
287
+ }
288
+ //#endregion
281
289
  //#region src/server/suspend-account.d.ts
282
290
  interface EndSessionsResult {
283
291
  readonly userId: string;
@@ -334,6 +342,7 @@ interface ServerOptions {
334
342
  * `current_setting('request.headers')` (channel, request id, client IP for audit).
335
343
  */
336
344
  readonly headers?: (request: Request) => Readonly<Record<string, string>>;
345
+ readonly requestIds?: RequestIdOptions | false;
337
346
  /**
338
347
  * PostgREST URL for the caller's reads: a read replica or the `<ref>-all`
339
348
  * load balancer. Defaults to `SUPABASE_READ_URL`; `false` reads from the
@@ -431,6 +440,8 @@ interface ServerContext<M extends AnyModels, F extends AnyFunctions, E, C = unkn
431
440
  readonly support?: ActiveSupport;
432
441
  /** `options.credentials`, when the server has one. */
433
442
  readonly credentials?: CredentialProvider;
443
+ readonly requestId?: string;
444
+ readonly correlationId?: string;
434
445
  }
435
446
  interface ContextOptions {
436
447
  readonly refresh?: boolean;
@@ -447,6 +458,8 @@ interface ContextOptions {
447
458
  * looks it up itself; `contextFromResolution` only uses this.
448
459
  */
449
460
  readonly support?: ActiveSupport;
461
+ readonly requestId?: string;
462
+ readonly correlationId?: string;
450
463
  }
451
464
  interface BetterServer<M extends AnyModels, F extends AnyFunctions, E, C = unknown, P = unknown> {
452
465
  readonly env: BetterSupabaseEnv;
@@ -513,4 +526,4 @@ declare function extendServer<R extends object>(server: object, extra: Omit<R, S
513
526
  */
514
527
  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>;
515
528
  //#endregion
516
- export { clearSupportCookie as A, sqlSupportStore as B, SupportOptions as C, supportSessions as D, SupportStartRequest as E, SupportEndedBy as F, SupportListFilter as I, SupportSession as L, supportCookieValue as M, SqlSupportStoreOptions as N, SUPPORT_COOKIE as O, SupportCallerClaims as P, SupportSessionStore as R, SupportAuthorizeInput as S, SupportSessions as T, supportClaims as V, DeleteAccountOptions as _, ServerDbOptions as a, ActiveSupport as b, createServer as c, SuspendAccountOptions as d, SuspendAccountResult as f, ReplicaState as g, PRIMARY_COOKIE as h, ServerContext as i, supportCookie as j, SupportCookieOptions 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, DeleteAccountResult as v, SupportPolicy as w, SupportApi as x, deleteAccount as y, SupportStartInput as z };
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 };
@@ -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-CeVeeXwz.js";
3
+ import { t as BetterServer } from "../server-C6DWVEVG.js";
4
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
5
  import { t as RefusalRedirects } from "../refusal-D1rgbzNq.js";
6
- import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-DuVb4Xa8.js";
6
+ import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-CdPDPpFs.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-Bc1o3zyy.js";
1
+ import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-CHnPkCPd.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-CONDyPYx.js";
4
+ import { i as localsOf, r as frameworkEntry } from "../framework-xjTBoyBB.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
package/dist/sql/index.js CHANGED
@@ -9,7 +9,7 @@ import { t as FINAL_RUN_STATES$1 } from "../run-state-CgBKzYMW.js";
9
9
  import { t as AI_MESSAGE_PART_TYPES } from "../message-CaKlqdsX.js";
10
10
  import { A as jwtClaim, B as replaceColumnCheck, C as canIn, D as disabledHelpersNeedLaterTables, E as disabledHelpers, F as pageSize, G as splitTable$1, H as serviceGrant, I as quotedTable, J as userGrant, K as tenantIn, L as raise$1, M as membershipDisabledAt, N as membershipSuspended, O as ensureCheck, P as organizationMissing, R as recordTrigger, S as addForeignKey, T as columnsObject, U as serviceOnly$1, V as schemaPreamble, W as sha256Hex, _ as SCHEMA, a as MODULE_PERMISSION_SCOPES, b as activeMembership, c as modulePermission, d as roleNames, f as roleScopeIs, g as NOTHING, h as EQUIVALENT_TRIGGERS, i as MODULE_PERMISSIONS, j as memberAddedRecord, k as jsonSchemaChecks, l as modulePermissionKey, m as tenantScope, n as WORKFLOW_SDK_WORLD, o as accessModel, p as rolesOf, q as updatedAt, s as hasPlatformRoles, u as providerPlatformRoles, v as SERVICE_CALLER, w as columnRef, x as addExtraColumns, y as accessDefinesDisabledHelpers, z as renameSql } from "../workflow-sdk-world-D-prir6O.js";
11
11
  import { c as templateFunctions, i as fillTemplate, o as resolveProviderSql, s as scopeProblems, t as SCOPE_ID_TYPES } from "../access-sql-B0dF-SoF.js";
12
- import { t as VERSION } from "../version-Bvv6aLjZ.js";
12
+ import { t as VERSION } from "../version-CQt77F3T.js";
13
13
  //#region src/sql/api-schema.ts
14
14
  /** The roles PostgREST runs a request as. */
15
15
  const API_ROLES = /* @__PURE__ */ new Set([
@@ -10196,6 +10196,20 @@ revoke execute on function better_supabase.audit_settings(regclass) from public,
10196
10196
  revoke execute on function better_supabase.audit_schema_calls(text, text, text[]) from public, anon, authenticated;
10197
10197
  revoke execute on function better_supabase.audit_schema(text, text, text[]) from public, anon, authenticated;`;
10198
10198
  //#endregion
10199
+ //#region src/sql/modules/audit-request.ts
10200
+ const requestHeader = (name) => `better_supabase.request_header(${sqlString(name)})`;
10201
+ const traceId = (setting, header) => `coalesce(better_supabase.request_id_or_null(current_setting(${sqlString(setting)}, true)), better_supabase.request_id_or_null(${requestHeader(header)}))`;
10202
+ const requestIdSql = (ctx) => traceId("better_supabase.request_id", ctx.text("requestIdHeader", "x-request-id").toLowerCase());
10203
+ const correlationIdSql = (ctx) => traceId("better_supabase.correlation_id", ctx.text("correlationIdHeader", "x-correlation-id").toLowerCase());
10204
+ const REQUEST_ID_OR_NULL = `create or replace function better_supabase.request_id_or_null(value text)
10205
+ returns text
10206
+ language sql
10207
+ immutable
10208
+ set search_path = ''
10209
+ as $$
10210
+ select case when value ~ '^[A-Za-z0-9._:;,@/+=-]{1,128}$' then value end;
10211
+ $$;`;
10212
+ //#endregion
10199
10213
  //#region src/sql/modules/audit-retention.ts
10200
10214
  /**
10201
10215
  * `purge_audit_log`, which honours an `audit_retention(tenant)` hook, and
@@ -10437,6 +10451,7 @@ const NAMES$24 = {
10437
10451
  } },
10438
10452
  options: [
10439
10453
  "appendOnly",
10454
+ "correlationIdHeader",
10440
10455
  "eventCategory",
10441
10456
  "eventRoles",
10442
10457
  "trustedRoles",
@@ -10446,6 +10461,7 @@ const NAMES$24 = {
10446
10461
  "keepMappedMetadata",
10447
10462
  "metadataColumns",
10448
10463
  "readPolicy",
10464
+ "requestIdHeader",
10449
10465
  "restricted",
10450
10466
  "tenantColumn",
10451
10467
  "tenantLabel",
@@ -10562,8 +10578,6 @@ function castId(value, idType) {
10562
10578
  default: return idType;
10563
10579
  }
10564
10580
  }
10565
- /** The request header `name`, or null outside a Data API request. */
10566
- const requestHeader = (name) => `better_supabase.request_header(${sqlString(name)})`;
10567
10581
  /** How the caller acted: service, support, impersonation, oauth-client, user or system. */
10568
10582
  const ACTOR_KIND = `case
10569
10583
  when coalesce(auth.jwt() ->> 'role', '') = 'service_role' then 'service'
@@ -10582,7 +10596,7 @@ function contextPairs(ctx, tenant, values) {
10582
10596
  ["tenantLabel", tenantLabel(ctx, tenant)],
10583
10597
  ["targetLabel", values.targetLabel],
10584
10598
  ["summary", values.summary],
10585
- ["requestId", values.requestId ?? requestHeader("x-request-id")],
10599
+ ["requestId", values.requestId ?? requestIdSql(ctx)],
10586
10600
  ["correlationId", values.correlationId],
10587
10601
  ["scope", auditWrite(ctx, "scope", values.scope ?? `case when ${tenant} is null then 'platform' else 'tenant' end`)]
10588
10602
  ];
@@ -10632,7 +10646,8 @@ revoke all on ${ctx.table("restricted")} from anon, authenticated;` : "";
10632
10646
  -- Semantic events (audit_event) and the per-table registry fill these.${add("eventType", "text")}${add("category", "text")}${add("outcome", "text")}${add("source", "text")}${add("targetType", "text")}${add("metadata", "jsonb")}${add("idempotencyKey", "text")}
10633
10647
  -- Who acted and on what, as it was then, for audit pages.${add("actorKind", "text")}${add("actorLabel", "text")}${add("tenantLabel", "text")}${add("targetLabel", "text")}${add("summary", "text")}${add("requestId", "text")}${add("correlationId", "text")}${add("scope", "text")}
10634
10648
  ${ctx.has("log", "table") && ctx.has("log", "record") ? `create index if not exists audit_events_record_idx on ${log} (${c("table")}, ${c("record")}, ${c("occurredAt")} desc);\n` : ""}create index if not exists audit_events_organization_idx on ${log} (${c("tenant")}, ${c("occurredAt")} desc);
10635
- create index if not exists audit_events_occurred_at_idx on ${log} (${c("occurredAt")});${ctx.has("log", "idempotencyKey") ? `
10649
+ create index if not exists audit_events_occurred_at_idx on ${log} (${c("occurredAt")});${ctx.has("log", "correlationId") ? `
10650
+ create index if not exists audit_events_correlation_idx on ${log} (${c("correlationId")}) where ${c("correlationId")} is not null;` : ""}${ctx.has("log", "idempotencyKey") ? `
10636
10651
  create unique index if not exists audit_events_idempotency_idx on ${log} (${c("idempotencyKey")}, ${c("tenant")}) nulls not distinct where ${c("idempotencyKey")} is not null;` : ""}
10637
10652
  alter table ${log} enable row level security;
10638
10653
  revoke all on ${log} from anon, authenticated;
@@ -10682,6 +10697,8 @@ exception when others then
10682
10697
  end;
10683
10698
  $$;
10684
10699
 
10700
+ ${REQUEST_ID_OR_NULL}
10701
+
10685
10702
  -- The client address the API gateway appended to x-forwarded-for (the
10686
10703
  -- right-most hop; clients can forge the ones before it), or null.
10687
10704
  create or replace function better_supabase.request_ip()
@@ -10750,7 +10767,7 @@ function triggerFunction(ctx, tenantColumn, restricted) {
10750
10767
  ...contextPairs(ctx, "row_tenant", {
10751
10768
  targetLabel: "row_data ->> entry.label_column",
10752
10769
  summary: "null",
10753
- correlationId: requestHeader("x-correlation-id")
10770
+ correlationId: correlationIdSql(ctx)
10754
10771
  })
10755
10772
  ]);
10756
10773
  const tenantValue = castId(`row_data ->> coalesce(entry.tenant_column, ${sqlString(tenantColumn)})`, ctx.idType);
@@ -10864,10 +10881,10 @@ function auditEvent(ctx, restricted) {
10864
10881
  ...contextPairs(ctx, "tenant", {
10865
10882
  targetLabel: "target_label",
10866
10883
  summary: "summary",
10867
- correlationId: `coalesce(correlation_id, ${requestHeader("x-correlation-id")})`,
10884
+ correlationId: `coalesce(better_supabase.request_id_or_null(correlation_id), ${correlationIdSql(ctx)})`,
10868
10885
  actorKind: `coalesce(actor_kind, ${ACTOR_KIND})`,
10869
10886
  actorLabel: `coalesce(actor_label, ${ACTOR_LABEL})`,
10870
- requestId: `coalesce(request_id, ${requestHeader("x-request-id")})`,
10887
+ requestId: `coalesce(better_supabase.request_id_or_null(request_id), ${requestIdSql(ctx)})`,
10871
10888
  scope: "coalesce(audit_event.scope, case when tenant is null then 'platform' else 'tenant' end)"
10872
10889
  })
10873
10890
  ]);
@@ -11075,7 +11092,7 @@ const AUDIT = {
11075
11092
  dependencies: (layout) => layout.modules?.["audit"]?.options?.["readPolicy"] === true ? ["access"] : [],
11076
11093
  target: "schema",
11077
11094
  modes: ["managed", "adopt"],
11078
- version: 5,
11095
+ version: 6,
11079
11096
  names: NAMES$24,
11080
11097
  contract: () => [
11081
11098
  {
@@ -11170,6 +11187,11 @@ const AUDIT = {
11170
11187
  from: 4,
11171
11188
  description: "Drops the read-only audit_log view that 0.5 kept for the 0.4 names; read better_supabase.audit_events.",
11172
11189
  sql: (ctx) => `drop view if exists ${sqlIdent(ctx.tableName("log").schema)}.audit_log;`
11190
+ },
11191
+ {
11192
+ from: 5,
11193
+ description: "Row changes and audit_event read the request and correlation ids from the better_supabase.request_id and better_supabase.correlation_id settings, then from the requestIdHeader and correlationIdHeader headers, and keep only ids of up to 128 safe characters; managed logs index correlation_id.",
11194
+ sql: () => ""
11173
11195
  }
11174
11196
  ],
11175
11197
  deprecated: [{
@@ -3,7 +3,7 @@ import { t as temporal } from "./temporal-required-BVvW7SYJ.js";
3
3
  import { a as ok, r as err, s as toDbError, t as AsyncResult } from "./result-DzUbqgdW.js";
4
4
  import { n as validate } from "./standard-BK0cqJ7y.js";
5
5
  import { t as fromPgError } from "./executor-De1Of3m3.js";
6
- import { d as clearSupportCookie, f as supportCookie, m as supportCookieValue } from "./adapter-Bc1o3zyy.js";
6
+ import { d as clearSupportCookie, f as supportCookie, m as supportCookieValue } from "./adapter-CHnPkCPd.js";
7
7
  import { r as sqlIdent } from "./template--jDkl3UP.js";
8
8
  import { i as emitBlockEvent } from "./block-events-CrT8r7Fe.js";
9
9
  //#region src/auth/support.ts
@@ -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-CeVeeXwz.js";
3
+ import { t as BetterServer } from "../server-C6DWVEVG.js";
4
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
5
  import { t as RefusalRedirects } from "../refusal-D1rgbzNq.js";
6
- import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-DuVb4Xa8.js";
6
+ import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-CdPDPpFs.js";
7
7
  import { t as Validated } from "../shared-DDSjEGDR.js";
8
8
  import { i as tagFor } from "../tags-Cx-LnIQP.js";
9
9
  import { AnyEntry, Contributions } from "@supabase/middleware";
@@ -1,12 +1,12 @@
1
1
  import { t as DbException } from "../db-exception-CnWcYPxL.js";
2
2
  import { r as dbErrorOf } from "../errors-B11Duf73.js";
3
3
  import { o as toProblem } from "../problem-BreOl8b8.js";
4
- import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-Bc1o3zyy.js";
4
+ import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-CHnPkCPd.js";
5
5
  import { t as defaultExpose } from "../respond-BUgsXNgk.js";
6
6
  import { r as tagFor } from "../tags-B99_U9Pp.js";
7
7
  import { i as requireCaller, o as runAction } from "../kit-Fm-Fv7q5.js";
8
8
  import { n as bufferInPlace, t as around } from "../shared-CBxosKK3.js";
9
- import { a as platformWaitUntil, i as localsOf, n as actionInput, r as frameworkEntry } from "../framework-CONDyPYx.js";
9
+ import { a as platformWaitUntil, i as localsOf, n as actionInput, r as frameworkEntry } from "../framework-xjTBoyBB.js";
10
10
  import { i as refusalTarget } from "../refusal-CeJWxmkH.js";
11
11
  //#region src/bridges/sveltekit.ts
12
12
  /**
@@ -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-CeVeeXwz.js";
3
+ import { t as BetterServer } from "../server-C6DWVEVG.js";
4
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
5
  import { t as RefusalRedirects } from "../refusal-D1rgbzNq.js";
6
- import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-DuVb4Xa8.js";
6
+ import { n as FrameworkOptions, t as FrameworkLocals } from "../framework-CdPDPpFs.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,8 +1,8 @@
1
- import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-Bc1o3zyy.js";
1
+ import { c as extendServer, n as flushEvents, s as createServer } from "../adapter-CHnPkCPd.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
4
  import { n as bufferInPlace, t as around } from "../shared-CBxosKK3.js";
5
- import { i as localsOf, r as frameworkEntry } from "../framework-CONDyPYx.js";
5
+ import { i as localsOf, r as frameworkEntry } from "../framework-xjTBoyBB.js";
6
6
  import { r as refusalResponse } from "../refusal-CeJWxmkH.js";
7
7
  //#region src/bridges/tanstack-start.ts
8
8
  /** The `response` of a request middleware's `next()` result; server function results have none. */
@@ -10,7 +10,7 @@ import { o as StreamStore } from "../store-CGjgWu5n.js";
10
10
  import { B as DbStats, b as Db, t as BetterSupabase, u as CacheAdapter } from "../define-CJJkkr1-.js";
11
11
  import { r as EventSink, t as CloudEvent } from "../cloud-event-C1JCc1bH.js";
12
12
  import { t as BetterPostgres } from "../pool-CAu2nLrL.js";
13
- import { R as SupportSessionStore, i as ServerContext, o as ServerOptions } from "../server-CeVeeXwz.js";
13
+ import { i as ServerContext, o as ServerOptions, z as SupportSessionStore } from "../server-C6DWVEVG.js";
14
14
  import { s as Impersonator } from "../mfa-Daak8ukG.js";
15
15
  import { n as SessionActor, r as SessionDelegation } from "../actor-CQTlc1Hh.js";
16
16
  import { r as GuardOptions } from "../respond-DoBijysA.js";
@@ -1,4 +1,4 @@
1
1
  //#region src/core/version.ts
2
- const VERSION = "0.6.0";
2
+ const VERSION = "0.6.1";
3
3
  //#endregion
4
4
  export { VERSION as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-supabase",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Strongly typed Supabase: generated schema, typed repositories, plugins, auth glue, framework integrations and the better-supabase CLI.",
5
5
  "keywords": [
6
6
  "cli",
@@ -1,2 +0,0 @@
1
- import { n as genCommand } from "./gen-BGLb_zou.js";
2
- export { genCommand };