better-supabase 0.4.0 → 0.5.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 (180) hide show
  1. package/README.md +135 -16
  2. package/dist/actor-DaJjqD5R.d.ts +43 -0
  3. package/dist/channel-FQW-CnGR.d.ts +70 -0
  4. package/dist/cli/bin.js +1 -1
  5. package/dist/cli/codemod-DqV7612m.js +388 -0
  6. package/dist/cli/{config-D9R0o1LH.js → config-CPVpXP5I.js} +78 -8
  7. package/dist/cli/{config-SSKSTUl2.js → config-dtoekM0v.js} +1 -1
  8. package/dist/cli/{read-sets-CMa29t9a.js → diff-SjkO5rNr.js} +1 -220
  9. package/dist/cli/{dist-CFgGknmZ.js → dist-DBPdlPYK.js} +4 -4
  10. package/dist/cli/{dist-B1MvLv-M.js → dist-DreZ24Sz.js} +1 -1
  11. package/dist/cli/{dist-Du7VnEUG.js → dist-xn4wlboc.js} +112 -1
  12. package/dist/cli/{doctor-BOym3mbL.js → doctor-C_A-KEAz.js} +533 -50
  13. package/dist/cli/{env-BZ0uy8XK.js → env-DmKv_G4A.js} +1 -1
  14. package/dist/cli/gen-CIdSQZad.js +2 -0
  15. package/dist/cli/{gen-Ccn_p90L.js → gen-CjElD1Vw.js} +321 -88
  16. package/dist/cli/index.d.ts +1 -1
  17. package/dist/cli/index.js +4 -4
  18. package/dist/cli/{init-ClnxRYBF.js → init-DMa6M7hV.js} +2 -2
  19. package/dist/cli/{introspect-DxqfkVIv.js → introspect-BKlaIu_M.js} +2 -2
  20. package/dist/cli/{openapi-8WHjxiTJ.js → openapi-Cp5Fyta-.js} +1 -1
  21. package/dist/cli/read-sets-VQcPgxU9.js +436 -0
  22. package/dist/cli/{run-CP20LKk_.js → run-Bo_NLT5n.js} +16 -12
  23. package/dist/cli/{seed-5J6eu_Xg.js → seed-CUlqWh-8.js} +1 -1
  24. package/dist/cli/sql-CVx-1O8G.js +373 -0
  25. package/dist/cli/{version-5mW_8sY1.js → version-BCtlgDQx.js} +1 -1
  26. package/dist/client/index.d.ts +1 -1
  27. package/dist/client/index.js +3 -10
  28. package/dist/clone-BfgmLU90.js +21 -0
  29. package/dist/{compiler-DB3aSFOA.d.ts → compiler-BXH_aZ7N.d.ts} +2 -2
  30. package/dist/config/index.d.ts +4 -4
  31. package/dist/config/index.js +4 -4
  32. package/dist/{config-C1CYcm6o.d.ts → config-Bv7gvfzC.d.ts} +185 -11
  33. package/dist/{config-CbvFmGD8.js → config-DreERlKo.js} +1 -1
  34. package/dist/{define-CRS2MRV3.d.ts → define-Bp_BZa5h.d.ts} +11 -7
  35. package/dist/{define-Bh0AqTik.js → define-cNKzqwL_.js} +202 -16
  36. package/dist/edge/index.d.ts +16 -5
  37. package/dist/edge/index.js +10 -7
  38. package/dist/{entitlements-Dm-FHpNH.d.ts → entitlements-BiJZ4t49.d.ts} +1 -1
  39. package/dist/env/index.d.ts +2 -2
  40. package/dist/env/index.js +34 -1
  41. package/dist/{errors-L0xK41y_.js → errors-DtwXa6b8.js} +1 -0
  42. package/dist/events/index.d.ts +3 -2
  43. package/dist/events/index.js +65 -12
  44. package/dist/events-aIO7vsIk.d.ts +230 -0
  45. package/dist/{result-CqEsbgYs.d.ts → executor-BunPOO-k.d.ts} +200 -1
  46. package/dist/{executor-CZ7ImRiD.d.ts → executor-Cghdstwu.d.ts} +1 -2
  47. package/dist/{executor-CVt6dD0B.js → executor-XycESQPH.js} +3 -3
  48. package/dist/hono/index.d.ts +17 -6
  49. package/dist/hono/index.js +40 -5
  50. package/dist/impersonation-BgSHAYLf.js +133 -0
  51. package/dist/{resolve-BAqQcwMW.d.ts → impersonation-BmePsuxz.d.ts} +36 -6
  52. package/dist/{index-BhHEC04r.d.ts → index-C7f8cOBM.d.ts} +2 -2
  53. package/dist/{index-Dy6kuF0P.d.ts → index-CLg87OBW.d.ts} +6 -1
  54. package/dist/{index-Cf-D2jk1.d.ts → index-CWMDdEr4.d.ts} +2 -2
  55. package/dist/{index-D5IfUIDh.d.ts → index-DOESKG27.d.ts} +33 -8
  56. package/dist/{index-DFmOpBGC.d.ts → index-DgILJRXj.d.ts} +35 -9
  57. package/dist/{index-RlLXd8dL.d.ts → index-DmXSxbLi.d.ts} +4 -4
  58. package/dist/{index-BBdvo-5d.d.ts → index-Dp2VDwog.d.ts} +49 -6
  59. package/dist/{index-528Ugmyp.d.ts → index-SaTsEfGP.d.ts} +76 -8
  60. package/dist/{index-BAy4tsAP.d.ts → index-fag8VJZ2.d.ts} +3 -4
  61. package/dist/index.d.ts +30 -13
  62. package/dist/index.js +10 -9
  63. package/dist/jobs/index.d.ts +147 -101
  64. package/dist/jobs/index.js +744 -237
  65. package/dist/{json-schema-DP6V7cbr.js → json-schema-m1fiwKgN.js} +22 -1
  66. package/dist/kit-events-CTFDfSwb.js +60 -0
  67. package/dist/kit-transport-B82k1djG.d.ts +33 -0
  68. package/dist/kit-transport-DJlHQUBU.js +55 -0
  69. package/dist/{config-BpxDfnbg.js → kits-CGLLrNPd.js} +37 -9
  70. package/dist/list/index.d.ts +1 -1
  71. package/dist/{live-BHakSWWo.d.ts → live-D9W2M5aO.d.ts} +6 -5
  72. package/dist/mcp/index.d.ts +25 -8
  73. package/dist/mcp/index.js +23 -14
  74. package/dist/{mfa-C7MNQ1Ob.d.ts → mfa-Cu96oJdw.d.ts} +2 -16
  75. package/dist/next/index.d.ts +31 -10
  76. package/dist/next/index.js +136 -27
  77. package/dist/notifications/index.d.ts +162 -0
  78. package/dist/notifications/index.js +264 -0
  79. package/dist/openapi/index.d.ts +1 -1
  80. package/dist/openapi/index.js +2 -2
  81. package/dist/orgs/index.d.ts +132 -0
  82. package/dist/orgs/index.js +245 -0
  83. package/dist/orpc/index.d.ts +28 -8
  84. package/dist/orpc/index.js +16 -3
  85. package/dist/otel/index.d.ts +21 -2
  86. package/dist/otel/index.js +50 -9
  87. package/dist/permdock-sql-C2Inc6Xc.d.ts +29 -0
  88. package/dist/permdock-sql-DgOfeixi.js +51 -0
  89. package/dist/plugin-DwARMuQp.js +59 -0
  90. package/dist/{plugin-bNhvJwRh.d.ts → plugin-o144f322.d.ts} +17 -5
  91. package/dist/plugins/actor/index.d.ts +5 -2
  92. package/dist/plugins/actor/index.js +22 -8
  93. package/dist/plugins/rules/index.d.ts +2 -2
  94. package/dist/plugins/rules/index.js +15 -10
  95. package/dist/plugins/soft-delete/index.d.ts +3 -3
  96. package/dist/plugins/soft-delete/index.js +14 -5
  97. package/dist/plugins/tenant/index.d.ts +2 -2
  98. package/dist/plugins/tenant/index.js +38 -20
  99. package/dist/plugins/timestamps/index.d.ts +1 -1
  100. package/dist/plugins/timestamps/index.js +4 -3
  101. package/dist/plugins/validation/index.d.ts +2 -2
  102. package/dist/plugins/validation/index.js +26 -6
  103. package/dist/{pool-DFwEQwmN.d.ts → pool-C9voM4Kw.d.ts} +17 -6
  104. package/dist/postgres/index.d.ts +5 -5
  105. package/dist/postgres/index.js +20 -11
  106. package/dist/{postgrest-Bc-0Xw62.d.ts → postgrest-CruYKAvV.d.ts} +1 -1
  107. package/dist/{problem-BihjPR0t.js → problem-BW1KhzSG.js} +2 -1
  108. package/dist/{problem-U8UEKccv.d.ts → problem-Blxe8S31.d.ts} +1 -1
  109. package/dist/query/index.d.ts +2 -2
  110. package/dist/query/index.js +3 -3
  111. package/dist/{query-BMMSWbI7.js → query-CCbo44lG.js} +2 -2
  112. package/dist/queue-BYUCjr59.d.ts +252 -0
  113. package/dist/react/index.d.ts +8 -7
  114. package/dist/react/index.js +4 -3
  115. package/dist/react/server.d.ts +14 -3
  116. package/dist/react/server.js +10 -2
  117. package/dist/react/session.d.ts +7 -1
  118. package/dist/react/session.js +9 -1
  119. package/dist/{react-CQHMaESR.js → react-C_s7kiNz.js} +103 -11
  120. package/dist/{read-set-FWK8qQ58.js → read-set-DQFt1N_Y.js} +22 -1
  121. package/dist/realtime/index.d.ts +3 -3
  122. package/dist/realtime/index.js +5 -4
  123. package/dist/{refresh-BwYkyNOQ.d.ts → refresh-CFPX0Qft.d.ts} +1 -1
  124. package/dist/{resource-BJcaIfxi.d.ts → resource-DNRFP7KR.d.ts} +5 -5
  125. package/dist/{resource-My_y-Syh.js → resource-mqfJW4YF.js} +22 -7
  126. package/dist/respond-BR1fJWOB.d.ts +377 -0
  127. package/dist/{result-Bj6yt33D.js → result-BKiliPY7.js} +1 -1
  128. package/dist/server/index.d.ts +15 -12
  129. package/dist/server/index.js +11 -17
  130. package/dist/{server-BA75B0mT.js → server-B1mZ7CgQ.js} +259 -37
  131. package/dist/{shared-DnoCdMDr.js → shared-D1dRUrAg.js} +16 -2
  132. package/dist/signers-Cc6r98SW.d.ts +162 -0
  133. package/dist/{simplify-Cqvfr9dj.js → simplify-_0oUKqCd.js} +4 -115
  134. package/dist/sql/index.d.ts +283 -11
  135. package/dist/sql/index.js +8705 -775
  136. package/dist/{sql-B34HU2DI.js → sql-Coh6n4cC.js} +9 -2
  137. package/dist/ssr/index.d.ts +4 -4
  138. package/dist/ssr/index.js +1 -2
  139. package/dist/{standard-BRyBGTtp.js → standard-D7r6dMUu.js} +6 -3
  140. package/dist/{standard-BsaCYQJc.d.ts → standard-J4YgMOLm.d.ts} +1 -1
  141. package/dist/{stats-C_YxA2r1.js → stats-Bqob3WqT.js} +4 -4
  142. package/dist/storage/index.d.ts +4 -4
  143. package/dist/storage/index.js +155 -26
  144. package/dist/support-CEPwlw2G.d.ts +89 -0
  145. package/dist/support-view-B8SlToQX.d.ts +17 -0
  146. package/dist/support-view-g4YLBeqX.js +18 -0
  147. package/dist/support-wHnK6zp-.js +293 -0
  148. package/dist/{permdock-sql-C4KFzLc9.js → template-TxrGI5jR.js} +2 -31
  149. package/dist/{temporal-BwshQk0W.js → temporal-CVlIV2DZ.js} +17 -4
  150. package/dist/{temporal-required-CBNHT6ni.js → temporal-required-CAt4Dc9Z.js} +2 -2
  151. package/dist/testing/index.d.ts +132 -10
  152. package/dist/testing/index.js +476 -8
  153. package/dist/{types-DONv9SHN.d.ts → types-Dnf_wRDz.d.ts} +26 -3
  154. package/dist/user-change-CHFEUro1.js +49 -0
  155. package/dist/{webhooks-Bh_Jf_-l.js → verify-Ce49ETPz.js} +5 -5
  156. package/dist/{version-Bmf7_FzM.js → version-DOYTYwHP.js} +1 -1
  157. package/dist/{mfa-byfjruR9.js → view-Bn6HNKUe.js} +97 -98
  158. package/dist/{view-B64o81wp.d.ts → view-CbgObAeb.d.ts} +22 -31
  159. package/dist/webhooks/index.d.ts +135 -4
  160. package/dist/webhooks/index.js +588 -2
  161. package/dist/wire-D2dT86vi.js +35 -0
  162. package/package.json +27 -19
  163. package/schemas/config-v1.json +131 -1
  164. package/schemas/doctor-report-v1.json +11 -0
  165. package/skills/better-supabase/SKILL.md +9 -6
  166. package/skills/better-supabase/references/plugins.md +6 -3
  167. package/skills/better-supabase/references/troubleshooting.md +1 -0
  168. package/skills/better-supabase-api/SKILL.md +9 -2
  169. package/skills/better-supabase-api/references/adapters.md +11 -8
  170. package/skills/better-supabase-auth/SKILL.md +18 -7
  171. package/skills/better-supabase-auth/references/permdock.md +78 -11
  172. package/dist/cli/gen-D5cLCULx.js +0 -2
  173. package/dist/cli/sql-D4VbqmXi.js +0 -199
  174. package/dist/events-B21UOhvP.d.ts +0 -84
  175. package/dist/executor-B5IoUxLE.d.ts +0 -195
  176. package/dist/invalidate-CgxmRamI.js +0 -24
  177. package/dist/permdock-sql-DImJULY-.d.ts +0 -17
  178. package/dist/plugin-BqR6wKMB.js +0 -23
  179. package/dist/respond-DgIbdrt8.d.ts +0 -194
  180. package/dist/view-BrJI2LKp.js +0 -45
@@ -1,7 +1,7 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { A as SchemaMeta } from "./types-DONv9SHN.js";
3
- import { a as EventHub, s as MutationNotice } from "./events-B21UOhvP.js";
4
- import { l as MutationKind } from "./plugin-bNhvJwRh.js";
2
+ import { j as SchemaMeta } from "./types-Dnf_wRDz.js";
3
+ import { a as EventHub, g as KitEventPattern, p as KitEvent, s as MutationNotice } from "./events-aIO7vsIk.js";
4
+ import { l as MutationIntent } from "./plugin-o144f322.js";
5
5
  //#region src/events/index.d.ts
6
6
  /** A CloudEvents 1.0 event. Extension attributes are lowercase alphanumerics. */
7
7
  interface CloudEvent<T = unknown> {
@@ -16,10 +16,11 @@ interface CloudEvent<T = unknown> {
16
16
  readonly data?: T;
17
17
  readonly [extension: string]: unknown;
18
18
  }
19
- declare const ROW_EVENT_TYPES: { readonly [K in MutationKind]: string; };
19
+ declare const ROW_EVENT_TYPES: { readonly [K in MutationIntent]: string; };
20
20
  interface RowEventData {
21
21
  readonly table: string;
22
22
  readonly row: Readonly<Record<string, unknown>>;
23
+ readonly actorId?: string;
23
24
  }
24
25
  interface CloudEventOptions {
25
26
  /** URI-reference of the producer, e.g. `https://crm.example.com` or `/crm`. */
@@ -35,8 +36,10 @@ interface EventSink {
35
36
  }
36
37
  /**
37
38
  * One CloudEvent per mutated row: `dev.better-supabase.row.created` with the
38
- * app-cased row as `data`, the primary key as `subject`, the tenant as
39
- * `partitionkey` and the actor as `actorid`.
39
+ * app-cased row and the actor in `data`, the primary key as `subject` and the
40
+ * tenant as `partitionkey`. Writes that return no rows (soft
41
+ * deletes, `returning: false`) send one event per known primary key, with the
42
+ * key as `row`.
40
43
  */
41
44
  declare function toCloudEvents(notice: MutationNotice, options: CloudEventOptions & {
42
45
  readonly meta?: SchemaMeta;
@@ -49,12 +52,34 @@ interface ForwardOptions extends CloudEventOptions {
49
52
  }
50
53
  /**
51
54
  * Sends a CloudEvent for every mutation to `sink`. Returns a function that
52
- * stops forwarding. Use an outbox (SQL kit) when events must not be lost.
55
+ * stops forwarding. Sends in flight are tracked on `betterSupabase.events`
56
+ * (`settled()`), which the Next adapter hands to `after()` and the edge
57
+ * entry to `waitUntil`. Use an outbox (SQL kit) when events must not be lost.
53
58
  */
54
59
  declare function forwardMutations(betterSupabase: {
55
60
  readonly events: EventHub;
56
61
  readonly meta: SchemaMeta;
57
62
  }, sink: EventSink, options: ForwardOptions): () => void;
63
+ /**
64
+ * A kit event as a CloudEvent: `dev.better-supabase.support.started` with
65
+ * the event data and the actor (`actorId`) as `data` and the tenant as
66
+ * `partitionkey`.
67
+ */
68
+ declare function kitCloudEvent(event: KitEvent, options: CloudEventOptions): CloudEvent;
69
+ interface ForwardKitOptions extends CloudEventOptions {
70
+ /** Only forward events that match, e.g. `support.*`. Defaults to all. */
71
+ readonly types?: readonly KitEventPattern[];
72
+ /** Sink failures never fail the kit call. Defaults to the `Logger`. */
73
+ readonly onError?: (error: unknown, events: readonly CloudEvent[]) => void;
74
+ }
75
+ /**
76
+ * Sends a CloudEvent for every kit event (`support.*`, `org.*`, ...) to
77
+ * `sink`. Returns a function that stops forwarding. Like
78
+ * `forwardMutations`, sends are tracked on `betterSupabase.events`.
79
+ */
80
+ declare function forwardKitEvents(betterSupabase: {
81
+ readonly events: EventHub;
82
+ }, sink: EventSink, options: ForwardKitOptions): () => void;
58
83
  type HttpMode = "structured" | "binary" | "batch";
59
84
  /** The HTTP protocol binding: headers and body for one event (or a batch). */
60
85
  declare function toHttp(events: CloudEvent | readonly CloudEvent[], mode?: HttpMode): {
@@ -72,4 +97,4 @@ interface HttpSinkOptions {
72
97
  /** POSTs events to `url`. Non-2xx responses reject. */
73
98
  declare function httpSink(url: string | URL, options?: HttpSinkOptions): EventSink;
74
99
  //#endregion
75
- export { HttpMode as a, RowEventData as c, httpSink as d, isCloudEvent as f, ForwardOptions as i, forwardMutations as l, toHttp as m, CloudEventOptions as n, HttpSinkOptions as o, toCloudEvents as p, EventSink as r, ROW_EVENT_TYPES as s, CloudEvent as t, fromHttp as u };
100
+ export { toHttp as _, ForwardOptions as a, ROW_EVENT_TYPES as c, forwardMutations as d, fromHttp as f, toCloudEvents as g, kitCloudEvent as h, ForwardKitOptions as i, RowEventData as l, isCloudEvent as m, CloudEventOptions as n, HttpMode as o, httpSink as p, EventSink as r, HttpSinkOptions as s, CloudEvent as t, forwardKitEvents as u };
@@ -1,13 +1,16 @@
1
- import { C as PrimaryKeyValue, L as UniqueWhere, N as TableKey, R as Update, g as Insert, n as AnyModels, t as AnyFunctions } from "./types-DONv9SHN.js";
2
- import { _ as DbException } from "./result-CqEsbgYs.js";
3
- import { C as FindExt, Ct as WhereInput, M as UpsertArgs, N as WriteArgs, S as DeleteExt, T as OffsetPageArgs, X as InferResult, Z as QuerySpec, _ as CursorPage, it as AggregateResult, j as UpdateArgs, k as Returned, l as CacheAdapter, lt as FindFirstArgs, rt as AggregateArgs, st as CountArgs, t as BetterSupabase, ut as FindManyArgs, v as CursorPageArgs, vt as Payload, w as OffsetPage, x as DeleteArgs, y as Db, yt as ReadArgs } from "./define-CRS2MRV3.js";
4
- import { DataTag, InfiniteData, QueryClient, SkipToken } from "@tanstack/query-core";
1
+ import { P as TableKey, R as UniqueWhere, _ as Insert, n as AnyFunctions, r as AnyModels, w as PrimaryKeyValue, z as Update } from "./types-Dnf_wRDz.js";
2
+ import { x as DbException } from "./executor-BunPOO-k.js";
3
+ import { C as FindExt, Ct as WhereInput, M as UpsertArgs, N as WriteArgs, S as DeleteExt, T as OffsetPageArgs, X as InferResult, Z as QuerySpec, _ as CursorPage, it as AggregateResult, j as UpdateArgs, k as Returned, l as CacheAdapter, lt as FindFirstArgs, rt as AggregateArgs, st as CountArgs, t as BetterSupabase, ut as FindManyArgs, v as CursorPageArgs, vt as Payload, w as OffsetPage, x as DeleteArgs, y as Db, yt as ReadArgs } from "./define-Bp_BZa5h.js";
4
+ import { DataTag, InfiniteData, QueryClient, QueryMeta, SkipToken } from "@tanstack/query-core";
5
5
  //#region src/query/invalidate.d.ts
6
- /** Carried by every better-supabase query: the tables whose changes make it stale. */
7
- interface BetterQueryMeta {
6
+ /**
7
+ * Carried by every better-supabase query: the tables whose changes make it
8
+ * stale, on top of the app's `Register['queryMeta']`, so the options stay
9
+ * assignable to `useQuery` when the app narrows its query meta.
10
+ */
11
+ type BetterQueryMeta = QueryMeta & {
8
12
  readonly bsTables: readonly string[];
9
- readonly [key: string]: unknown;
10
- }
13
+ };
11
14
  /**
12
15
  * Invalidates every query that read one of `tables`: better-supabase queries
13
16
  * by their `meta.bsTables`, and other `['bs', table, ...]` keys by prefix.
@@ -114,4 +117,27 @@ declare function queryCache(client: QueryClient): CacheAdapter;
114
117
  /** Invalidates affected queries for every mutation and declared RPC `betterSupabase` performs in this runtime. */
115
118
  declare function invalidateOnMutation<M extends AnyModels, D, F extends AnyFunctions, E>(betterSupabase: BetterSupabase<M, D, F, E>, client: QueryClient): () => void;
116
119
  //#endregion
117
- export { QueryHelpers as a, TableQueries as c, queryCache as d, BetterQueryMeta as f, QueriesOptions as i, createQueries as l, InfiniteOptionsOf as n, QueryKeyOf as o, invalidateTables as p, MutationOptionsOf as r, QueryOptionsOf as s, BetterQueries as t, invalidateOnMutation as u };
120
+ //#region src/query/user-change.d.ts
121
+ /** The part of `createClient().auth` that `clearOnUserChange` reads. */
122
+ interface UserChangeSource {
123
+ subscribe(listener: () => void): () => void;
124
+ current(): {
125
+ readonly status: string;
126
+ readonly user: {
127
+ readonly id: string;
128
+ } | null;
129
+ };
130
+ }
131
+ /**
132
+ * Removes every `['bs', ...]` query when the signed-in user changes or signs
133
+ * out, so the next user never sees the previous user's rows. Returns the
134
+ * function that stops listening. `BetterSupabaseProvider` calls it for React;
135
+ * call it yourself with Vue, Solid, Svelte or Angular Query.
136
+ *
137
+ * ```ts
138
+ * const stop = clearOnUserChange(queryClient, bs.auth);
139
+ * ```
140
+ */
141
+ declare function clearOnUserChange(queryClient: Pick<QueryClient, "removeQueries">, auth: UserChangeSource): () => void;
142
+ //#endregion
143
+ export { MutationOptionsOf as a, QueryKeyOf as c, createQueries as d, invalidateOnMutation as f, invalidateTables as h, InfiniteOptionsOf as i, QueryOptionsOf as l, BetterQueryMeta as m, clearOnUserChange as n, QueriesOptions as o, queryCache as p, BetterQueries as r, QueryHelpers as s, UserChangeSource as t, TableQueries as u };
@@ -1,7 +1,7 @@
1
- import { n as AnyModels, t as AnyFunctions } from "./types-DONv9SHN.js";
2
- import { t as BetterSupabase, y as Db } from "./define-CRS2MRV3.js";
3
- import { c as PublicEnv } from "./index-Dy6kuF0P.js";
4
- import { t as BetterQueries } from "./index-DFmOpBGC.js";
1
+ import { n as AnyFunctions, r as AnyModels } from "./types-Dnf_wRDz.js";
2
+ import { t as BetterSupabase, y as Db } from "./define-Bp_BZa5h.js";
3
+ import { l as PublicEnv } from "./index-CLg87OBW.js";
4
+ import { r as BetterQueries } from "./index-DgILJRXj.js";
5
5
  import { SupabaseClient } from "@supabase/supabase-js";
6
6
  //#region src/client/index.d.ts
7
7
  interface ClientOptions {
@@ -1,9 +1,9 @@
1
- import { p as DbError } from "./result-CqEsbgYs.js";
2
- import { Z as QuerySpec } from "./define-CRS2MRV3.js";
3
- import { i as ClientAuth, t as AuthSnapshot } from "./index-RlLXd8dL.js";
1
+ import { _ as DbError } from "./executor-BunPOO-k.js";
2
+ import { Z as QuerySpec } from "./define-Bp_BZa5h.js";
3
+ import { i as ClientAuth, t as AuthSnapshot } from "./index-DmXSxbLi.js";
4
4
  import { n as TemplateValues } from "./template-mbvlysOo.js";
5
- import { t as AuthSession } from "./view-B64o81wp.js";
6
- import { a as LiveSource, g as Topic, h as SubscriptionStatus, p as SubscribeOptions, r as LiveCountSeed, u as EventSchemas, v as TopicHandlers, y as TopicMessage } from "./live-BHakSWWo.js";
5
+ import { t as AuthSession } from "./view-CbgObAeb.js";
6
+ import { a as LiveSource, g as Topic, h as SubscriptionStatus, p as SubscribeOptions, r as LiveCountSeed, u as EventSchemas, v as TopicHandlers, y as TopicMessage } from "./live-D9W2M5aO.js";
7
7
  import { SupabaseClient } from "@supabase/supabase-js";
8
8
  import { ReactNode } from "react";
9
9
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -115,4 +115,47 @@ interface LiveCount {
115
115
  */
116
116
  declare function useLiveCount(source: QuerySpec<string, "count", number> | LiveCountSeed | null | undefined, options?: LiveCountHookOptions): LiveCount;
117
117
  //#endregion
118
- export { ClaimsOf as a, LiveCountHookOptions as c, createHooks as d, useAuth as f, useSupabase as g, useLiveQuery as h, BroadcastOptions as i, LiveQueryHookOptions as l, useLiveCount as m, BetterSupabaseProvider as n, ClientLike as o, useBroadcast as p, BetterSupabaseProviderProps as r, LiveCount as s, BetterHooks as t, ProfileOf as u };
118
+ //#region src/react/notifications.d.ts
119
+ /** Loads one list of items, e.g. a server action that calls `notifications.list()`. */
120
+ type NotificationSource<T> = () => Promise<readonly T[]>;
121
+ interface UseNotificationsOptions<T> {
122
+ /**
123
+ * The private topic the `notifications` module broadcasts to, e.g.
124
+ * `notifications:${userId}` (`kits.notifications.options.topic`). `null`
125
+ * loads once without realtime.
126
+ */
127
+ readonly topic: string | null;
128
+ /** The notifications, newest first. */
129
+ readonly load: NotificationSource<T>;
130
+ /** More items merged in, such as running jobs or pending approvals. */
131
+ readonly sources?: readonly NotificationSource<T>[];
132
+ /** Orders the merged list. Defaults to the order the sources return. */
133
+ readonly sort?: (a: T, b: T) => number;
134
+ /** The badge number. Defaults to the items without a `readAt`. */
135
+ readonly count?: (items: readonly T[]) => number;
136
+ /** Runs for each broadcast, e.g. to show a toast for `notification_created`. */
137
+ readonly onMessage?: (event: string, payload: unknown) => void;
138
+ }
139
+ interface NotificationsState<T> {
140
+ /** `undefined` until the first load. */
141
+ readonly items: readonly T[] | undefined;
142
+ readonly count: number;
143
+ readonly status: SubscriptionStatus;
144
+ readonly error: unknown;
145
+ /** Loads again, e.g. after marking items read. */
146
+ readonly refresh: () => Promise<void>;
147
+ }
148
+ /**
149
+ * The signed-in user's notifications, kept current: loads them, then loads
150
+ * again after each broadcast on `topic` and after the channel rejoins.
151
+ *
152
+ * ```tsx
153
+ * const { items, count } = useNotifications({
154
+ * topic: `org:${orgId}:notifications:${userId}`,
155
+ * load: () => listNotifications(orgId),
156
+ * });
157
+ * ```
158
+ */
159
+ declare function useNotifications<T>(options: UseNotificationsOptions<T>): NotificationsState<T>;
160
+ //#endregion
161
+ export { useBroadcast as _, BetterHooks as a, useSupabase as b, BroadcastOptions as c, LiveCount as d, LiveCountHookOptions as f, useAuth as g, createHooks as h, useNotifications as i, ClaimsOf as l, ProfileOf as m, NotificationsState as n, BetterSupabaseProvider as o, LiveQueryHookOptions as p, UseNotificationsOptions as r, BetterSupabaseProviderProps as s, NotificationSource as t, ClientLike as u, useLiveCount as v, useLiveQuery as y };
@@ -1,12 +1,13 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { b as PermdockBucketPolicy, i as BucketPolicyName } from "./types-DONv9SHN.js";
3
- import { p as DbError, t as AsyncResult } from "./result-CqEsbgYs.js";
2
+ import { a as BucketPolicyName, t as AccessBucketPolicy, x as PermdockBucketPolicy } from "./types-Dnf_wRDz.js";
3
+ import { _ as DbError, a as AsyncResult, u as Result } from "./executor-BunPOO-k.js";
4
+ import { g as RequestContext } from "./plugin-o144f322.js";
5
+ import { n as PermdockCatalog } from "./permdock-sql-C2Inc6Xc.js";
4
6
  import { n as StoragePath, t as PathIn } from "./path-Cv__-OTj.js";
5
- import { t as PermdockCatalog } from "./permdock-sql-DImJULY-.js";
6
7
  import { n as TemplateValues, t as TemplateParams } from "./template-mbvlysOo.js";
7
8
  import { SupabaseClient } from "@supabase/supabase-js";
8
9
  //#region src/storage/bucket.d.ts
9
- type BucketPolicy = BucketPolicyName | PermdockBucketPolicy;
10
+ type BucketPolicy = BucketPolicyName | PermdockBucketPolicy | AccessBucketPolicy;
10
11
  interface BucketConfig<P extends string = string, Id extends string = string> {
11
12
  /** Bucket id, e.g. `customer-logos`. */
12
13
  readonly id: Id;
@@ -15,8 +16,11 @@ interface BucketConfig<P extends string = string, Id extends string = string> {
15
16
  readonly public?: boolean;
16
17
  /**
17
18
  * Generated `storage.objects` policies. `tenant` and `owner` match a path
18
- * segment against the JWT; `public` allows reads; `none` leaves access to
19
- * the secret key; `{ permdock, scope }` calls PermDock's SQL helpers.
19
+ * segment against the JWT; `public` allows reads (on a `public: true`
20
+ * bucket the public URLs need no policy, so none is written and nobody can
21
+ * list the objects); `none` leaves access to
22
+ * the secret key; `{ permdock, scope }` calls PermDock's SQL helpers;
23
+ * `{ access }` calls the SQL kit's access contract (`tenant_ids_with`).
20
24
  * Defaults to `none`.
21
25
  *
22
26
  * The helpers check role and scope only. Use `permdock` just for
@@ -29,13 +33,19 @@ interface BucketConfig<P extends string = string, Id extends string = string> {
29
33
  readonly policy?: BucketPolicy;
30
34
  /**
31
35
  * PermDock's `permissions.catalog.json`. With it, a `permdock` policy
32
- * naming a permission with `rowConditions: true` throws.
36
+ * naming a permission without `rowConditions: false` (including one the
37
+ * catalog doesn't list) throws.
33
38
  */
34
39
  readonly catalog?: PermdockCatalog;
35
40
  /** `'5MiB'`, `'500KB'` or bytes. */
36
41
  readonly fileSizeLimit?: string | number;
37
42
  /** `['image/png', 'image/*']`. */
38
43
  readonly allowedMimeTypes?: readonly string[];
44
+ /**
45
+ * The tenant segment. Set it and connected clients only touch paths whose
46
+ * `param` holds the caller's tenant: pass `{ context }` or `{ tenant }` to
47
+ * `connect()`, or `{ allTenants: true }` for cross-tenant admin work.
48
+ */
39
49
  readonly tenant?: {
40
50
  /** Placeholder holding the tenant id. Defaults to `orgId`. */
41
51
  readonly param?: string;
@@ -145,6 +155,8 @@ interface ActualBucket {
145
155
  type StorageClient = Pick<SupabaseClient, "storage">;
146
156
  interface BucketClient<P extends string, Id extends string = string> {
147
157
  readonly bucket: Bucket<P, Id>;
158
+ /** The object path, checked against the template and, with `tenant`, the caller's tenant. */
159
+ path(target: ObjectTarget<P, Id>): Result<StoragePath<Id>>;
148
160
  upload(target: ObjectTarget<P, Id>, body: UploadBody, options?: UploadOptions): AsyncResult<{
149
161
  path: StoragePath<Id>;
150
162
  }>;
@@ -186,6 +198,8 @@ interface Bucket<P extends string, Id extends string = string> {
186
198
  * removes the objects it fills.
187
199
  */
188
200
  readonly owner: string | undefined;
201
+ /** Placeholder connected clients check against the caller's tenant; set by `tenant`. */
202
+ readonly tenant: string | undefined;
189
203
  readonly fileSizeLimit: number | undefined;
190
204
  readonly allowedMimeTypes: readonly string[] | undefined;
191
205
  path(values: TemplateValues<P>): StoragePath<Id>;
@@ -212,6 +226,17 @@ interface BucketConnectOptions {
212
226
  * never cross users.
213
227
  */
214
228
  readonly cacheSignedUrls?: boolean;
229
+ /**
230
+ * The request context (`db.$context`, or what an adapter passes to
231
+ * `connect`). For a bucket with `tenant`, its tenant (`context.tenant`, the
232
+ * one `tenant()` resolved, or the `tenant.claim` claims) must fill the
233
+ * tenant segment of every path.
234
+ */
235
+ readonly context?: RequestContext;
236
+ /** The tenant every path must hold, instead of reading it from `context`. */
237
+ readonly tenant?: string;
238
+ /** Skip the tenant check, for admin jobs that work across tenants. */
239
+ readonly allTenants?: boolean;
215
240
  }
216
241
  declare function parseSize(value: string | number): number;
217
242
  /** Maps a Storage error (`StorageApiError`, fetch failures) to a `DbError`. */
@@ -233,4 +258,47 @@ declare function fromStorageError(raw: unknown, table?: string): DbError;
233
258
  */
234
259
  declare function defineBucket<const P extends string, const Id extends string = string>(config: BucketConfig<P, Id>): Bucket<P, Id>;
235
260
  //#endregion
236
- export { fromStorageError as C, defineBucket as S, TransformOptions as _, BucketConnectOptions as a, UploadOptions as b, ObjectTarget as c, Reservation as d, StorageClient as f, TTL as g, SweepResult as h, BucketConfig as i, ReplaceOptions as l, SweepOptions as m, Bucket as n, BucketDrift as o, StoredObject as p, BucketClient as r, BucketPolicy as s, ActualBucket as t, ReplaceResult as u, TtlPreset as v, parseSize as w, UrlOptions as x, UploadBody as y };
261
+ //#region src/storage/presets.d.ts
262
+ /** The image types browsers display everywhere. */
263
+ declare const IMAGE_TYPES: readonly string[];
264
+ interface ImageBucketOptions<P extends string, Id extends string> {
265
+ readonly id?: Id;
266
+ /** The path template; keep the preset's placeholders the policy relies on. */
267
+ readonly path?: P;
268
+ /** Defaults to `true`: images load from their public URL without signing. */
269
+ readonly public?: boolean;
270
+ readonly fileSizeLimit?: string | number;
271
+ readonly allowedMimeTypes?: readonly string[];
272
+ /** Replaces the preset's policy. */
273
+ readonly policy?: BucketPolicy;
274
+ }
275
+ type AvatarBucketOptions<P extends string, Id extends string> = ImageBucketOptions<P, Id>;
276
+ interface OrgLogoBucketOptions<P extends string, Id extends string> extends ImageBucketOptions<P, Id> {
277
+ /**
278
+ * The permission that may upload, replace and delete a logo, checked
279
+ * through the access contract. Defaults to `organization.update`, the
280
+ * `organizations` module's update permission.
281
+ */
282
+ readonly permission?: string;
283
+ /**
284
+ * The tenant segment connected clients are held to. `false` lets one
285
+ * client upload for any organization the policy allows. Defaults to
286
+ * `{ param: 'orgId' }`.
287
+ */
288
+ readonly tenant?: BucketConfig["tenant"] | false;
289
+ }
290
+ declare const AVATAR_PATH = "{userId}/avatar-{version}.{ext}";
291
+ declare const LOGO_PATH = "{orgId}/logo-{version}.{ext}";
292
+ /**
293
+ * A bucket for profile pictures: `{userId}/avatar-{version}.{ext}`, public,
294
+ * 2 MiB of images, written only by their owner (the `owner` policy).
295
+ */
296
+ declare function avatarBucket<const P extends string = typeof AVATAR_PATH, const Id extends string = "avatars">(options?: AvatarBucketOptions<P, Id>): Bucket<P, Id>;
297
+ /**
298
+ * A bucket for organization logos: `{orgId}/logo-{version}.{ext}`, public,
299
+ * 2 MiB of images, written by members with the update permission through
300
+ * the access contract (`tenant_ids_with`), so it follows the app's roles.
301
+ */
302
+ declare function orgLogoBucket<const P extends string = typeof LOGO_PATH, const Id extends string = "organization-logos">(options?: OrgLogoBucketOptions<P, Id>): Bucket<P, Id>;
303
+ //#endregion
304
+ export { parseSize as A, TransformOptions as C, UrlOptions as D, UploadOptions as E, defineBucket as O, TTL as S, UploadBody as T, Reservation as _, avatarBucket as a, SweepOptions as b, Bucket as c, BucketConnectOptions as d, BucketDrift as f, ReplaceResult as g, ReplaceOptions as h, OrgLogoBucketOptions as i, fromStorageError as k, BucketClient as l, ObjectTarget as m, IMAGE_TYPES as n, orgLogoBucket as o, BucketPolicy as p, ImageBucketOptions as r, ActualBucket as s, AvatarBucketOptions as t, BucketConfig as u, StorageClient as v, TtlPreset as w, SweepResult as x, StoredObject as y };
@@ -1,7 +1,6 @@
1
- import { N as TableKey, O as Row, n as AnyModels, t as AnyFunctions } from "./types-DONv9SHN.js";
2
- import { l as CountMode } from "./executor-B5IoUxLE.js";
3
- import { b as ValidationIssue, t as AsyncResult } from "./result-CqEsbgYs.js";
4
- import { C as FindExt, Ct as WhereInput, O as RepositoryOf, T as OffsetPageArgs, _ as CursorPage, dt as IncludeArg, gt as OrderByArg, t as BetterSupabase, v as CursorPageArgs, vt as Payload, w as OffsetPage, xt as SelectArg } from "./define-CRS2MRV3.js";
1
+ import { P as TableKey, k as Row, n as AnyFunctions, r as AnyModels } from "./types-Dnf_wRDz.js";
2
+ import { I as CountMode, a as AsyncResult, w as ValidationIssue } from "./executor-BunPOO-k.js";
3
+ import { C as FindExt, Ct as WhereInput, O as RepositoryOf, T as OffsetPageArgs, _ as CursorPage, dt as IncludeArg, gt as OrderByArg, t as BetterSupabase, v as CursorPageArgs, vt as Payload, w as OffsetPage, xt as SelectArg } from "./define-Bp_BZa5h.js";
5
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
5
  //#region src/list/list-query.d.ts
7
6
  /** Facet value meaning "not set": filters with `is null`. */
package/dist/index.d.ts CHANGED
@@ -1,14 +1,13 @@
1
- import { A as SchemaMeta, C as PrimaryKeyValue, D as Relations, E as RelationTypes, F as UniqueConstraint, I as UniqueKeyName, L as UniqueWhere, M as TableFlags, N as TableKey, O as Row, P as TableMeta, R as Update, S as PrimaryKeyColumn, T as RelationMeta, _ as ModelFlags, a as Casing, b as PermdockBucketPolicy, c as Codec, d as Flags, f as ForeignKeyConstraint, g as Insert, h as FunctionsOf, i as BucketPolicyName, j as Simplify, k as Schema, l as ColumnMeta, m as FunctionTypes, n as AnyModels, o as CheckConstraint, p as FunctionMeta, r as BucketMeta, s as ClaimsMeta, t as AnyFunctions, u as DatabaseOf, v as ModelTypes, w as RealtimeTableMeta, x as PermdockTopicPolicy, y as ModelsOf } from "./types-DONv9SHN.js";
2
- import { C as and, E as or, S as UpdateOp, T as not, _ as OrderTerm, a as AggregateFn, b as SelectOp, c as Condition, d as FunctionSource, f as Include, g as Operation, h as MutationOp, i as RpcContext, l as CountMode, m as Measure, n as ExecuteResult, o as Aggregation, p as InsertOp, r as Executor, s as ColumnOp, t as ExecuteContext, u as DeleteOp, v as Quantifier, w as column, x as Selection, y as SelectColumn } from "./executor-B5IoUxLE.js";
3
- import { C as isConflict, D as statusOf, E as mapDbError, S as isCheck, T as isForeignKey, _ as DbException, a as Ok, b as ValidationIssue, c as err, d as toBetterResult, f as toDbError, g as DbErrorOf, h as DbErrorKinds, i as Err, l as fromBetterResult, m as DbErrorKind, n as BetterResultApi, o as Result, p as DbError, r as BetterResultValue, t as AsyncResult, u as ok, v as ErrorMapper, w as isDbError, x as dbError, y as RawDbError } from "./result-CqEsbgYs.js";
4
- import { a as EventHub, c as QueryEvent, d as LogFields, f as Logger, i as EventHandler, l as RefreshEvent, m as silentLogger, n as BetterSupabaseEvents, o as EventName, p as consoleLogger, r as ErrorEvent, s as MutationNotice, t as AuthEvent, u as RpcNotice } from "./events-B21UOhvP.js";
5
- import { $ as Specs, A as RpcOptions, B as ReadSet, C as FindExt, Ct as WhereInput, D as Repository, E as PageOf, F as EMPTY_STATS, G as ReadSetParams, H as ReadSetParamType, I as StatsRecorder, J as isReadSet, K as ReadSetResult, L as recordStats, M as UpsertArgs, N as WriteArgs, O as RepositoryOf, P as DbStats, Q as ReadMethod, R as SearchArgs, S as DeleteExt, St as SortDirection, T as OffsetPageArgs, U as ReadSetParamTypes, V as ReadSetOptions, W as ReadSetParamValue, X as InferResult, Y as readSetTables, Z as QuerySpec, _ as CursorPage, _t as OrderByInput, a as defineSupabase, at as AggregateRow, b as DbHelpers, bt as RelationMeasureArg, c as postgrestExecutor, ct as FieldFilter, d as MemoryCache, dt as IncludeArg, et as TableSpecs, f as cacheTargetOf, ft as IncludeArgs, g as ConflictTarget, gt as OrderByArg, h as rpcCacheTargets, ht as NumericMeasureArg, i as SupabaseOptions, it as AggregateResult, j as UpdateArgs, k as Returned, l as CacheAdapter, lt as FindFirstArgs, m as rowKey, mt as MeasureKey, n as ConnectOptions, nt as specTables, o as PostgrestClientLike, ot as CountArg, p as memoryCache, pt as MeasureArg, q as defineReadSet, r as RpcDefinition, rt as AggregateArgs, s as explainPostgrest, st as CountArgs, t as BetterSupabase, tt as isQuerySpec, u as CacheTarget, ut as FindManyArgs, v as CursorPageArgs, vt as Payload, w as OffsetPage, x as DeleteArgs, xt as SelectArg, y as Db, yt as ReadArgs, z as InferReadSetParams } from "./define-CRS2MRV3.js";
6
- import { _ as definePlugin, a as ExtensionOf, c as MutationEvent, d as PLUGIN_API_VERSION, f as Plugin, g as WithExtension, h as RequestContext, i as CallOptions, l as MutationKind, m as RepositoryExtension, n as AnyPlugin, o as HasFlag, p as RepositoryApi, r as ApplyExtension, s as HookArgs, t as Actor, u as NoExtension } from "./plugin-bNhvJwRh.js";
7
- import { n as validate, t as StandardSchemaV1 } from "./standard-BsaCYQJc.js";
8
- import { a as compilePostgrest, i as PostgrestPlan, n as PlanLimit, r as PlanOrder, t as PlanFilter } from "./postgrest-Bc-0Xw62.js";
1
+ import { A as Schema, C as PrimaryKeyColumn, D as RelationTypes, E as RelationMeta, F as TableMeta, I as UniqueConstraint, L as UniqueKeyName, M as Simplify, N as TableFlags, O as Relations, P as TableKey, R as UniqueWhere, S as PermdockTopicPolicy, T as RealtimeTableMeta, _ as Insert, a as BucketPolicyName, b as ModelsOf, c as ClaimsMeta, d as DatabaseOf, f as Flags, g as FunctionsOf, h as FunctionTypes, i as BucketMeta, j as SchemaMeta, k as Row, l as Codec, m as FunctionMeta, n as AnyFunctions, o as Casing, p as ForeignKeyConstraint, r as AnyModels, s as CheckConstraint, t as AccessBucketPolicy, u as ColumnMeta, v as ModelFlags, w as PrimaryKeyValue, x as PermdockBucketPolicy, y as ModelTypes, z as Update } from "./types-Dnf_wRDz.js";
2
+ import { $ as or, A as mapDbError, B as InsertOp, C as RawDbError, D as isConflict, E as isCheck, F as Condition, G as Quantifier, H as MutationOp, I as CountMode, J as Selection, K as SelectColumn, L as DeleteOp, M as AggregateFn, N as Aggregation, O as isDbError, P as ColumnOp, Q as not, R as FunctionSource, S as ErrorMapper, T as dbError, U as Operation, V as Measure, W as OrderTerm, X as and, Y as UpdateOp, Z as column, _ as DbError, a as AsyncResult, b as DbErrorOf, c as Err, f as err, g as toDbError, h as toBetterResult, i as RpcContext, j as statusOf, k as isForeignKey, l as Ok, m as ok, n as ExecuteResult, o as BetterResultApi, p as fromBetterResult, q as SelectOp, r as Executor, s as BetterResultValue, t as ExecuteContext, u as Result, v as DbErrorKind, w as ValidationIssue, x as DbException, y as DbErrorKinds, z as Include } from "./executor-BunPOO-k.js";
3
+ import { D as consoleLogger, E as Logger, O as silentLogger, T as LogFields, _ as KitEventType, a as EventHub, c as QueryEvent, i as EventHandler, l as RefreshEvent, m as KitEventMap, n as BetterSupabaseEvents, o as EventName, p as KitEvent, r as ErrorEvent, s as MutationNotice, t as AuthEvent, u as RpcNotice } from "./events-aIO7vsIk.js";
4
+ import { $ as Specs, A as RpcOptions, B as ReadSet, C as FindExt, Ct as WhereInput, D as Repository, E as PageOf, F as EMPTY_STATS, G as ReadSetParams, H as ReadSetParamType, I as StatsRecorder, J as isReadSet, K as ReadSetResult, L as recordStats, M as UpsertArgs, N as WriteArgs, O as RepositoryOf, P as DbStats, Q as ReadMethod, R as SearchArgs, S as DeleteExt, St as SortDirection, T as OffsetPageArgs, U as ReadSetParamTypes, V as ReadSetOptions, W as ReadSetParamValue, X as InferResult, Y as readSetTables, Z as QuerySpec, _ as CursorPage, _t as OrderByInput, a as defineSupabase, at as AggregateRow, b as DbHelpers, bt as RelationMeasureArg, c as postgrestExecutor, ct as FieldFilter, d as MemoryCache, dt as IncludeArg, et as TableSpecs, f as cacheTargetOf, ft as IncludeArgs, g as ConflictTarget, gt as OrderByArg, h as rpcCacheTargets, ht as NumericMeasureArg, i as SupabaseOptions, it as AggregateResult, j as UpdateArgs, k as Returned, l as CacheAdapter, lt as FindFirstArgs, m as rowKey, mt as MeasureKey, n as ConnectOptions, nt as specTables, o as PostgrestClientLike, ot as CountArg, p as memoryCache, pt as MeasureArg, q as defineReadSet, r as RpcDefinition, rt as AggregateArgs, s as explainPostgrest, st as CountArgs, t as BetterSupabase, tt as isQuerySpec, u as CacheTarget, ut as FindManyArgs, v as CursorPageArgs, vt as Payload, w as OffsetPage, x as DeleteArgs, xt as SelectArg, y as Db, yt as ReadArgs, z as InferReadSetParams } from "./define-Bp_BZa5h.js";
5
+ import { _ as WithExtension, a as ExtensionOf, c as MutationEvent, d as NoExtension, f as PLUGIN_API_VERSION, g as RequestContext, h as RepositoryExtension, i as CallOptions, l as MutationIntent, m as RepositoryApi, n as AnyPlugin, o as HasFlag, p as Plugin, r as ApplyExtension, s as HookArgs, t as Actor, u as MutationKind, v as definePlugin } from "./plugin-o144f322.js";
6
+ import { n as validate, t as StandardSchemaV1 } from "./standard-J4YgMOLm.js";
7
+ import { a as compilePostgrest, i as PostgrestPlan, n as PlanLimit, r as PlanOrder, t as PlanFilter } from "./postgrest-CruYKAvV.js";
9
8
  import { n as StoragePath } from "./path-Cv__-OTj.js";
10
- import { n as postgrestCompiler, t as Compiler } from "./compiler-DB3aSFOA.js";
11
- import { a as ProblemResponseOptions, c as problemResponse, i as ProblemOptions, l as toProblem, n as PROBLEM_TYPE_BASE, o as fromProblem, r as ProblemDetails, s as isProblem, t as PROBLEM_CONTENT_TYPE } from "./problem-U8UEKccv.js";
9
+ import { n as postgrestCompiler, t as Compiler } from "./compiler-BXH_aZ7N.js";
10
+ import { a as ProblemResponseOptions, c as problemResponse, i as ProblemOptions, l as toProblem, n as PROBLEM_TYPE_BASE, o as fromProblem, r as ProblemDetails, s as isProblem, t as PROBLEM_CONTENT_TYPE } from "./problem-Blxe8S31.js";
12
11
  import { t as SPEC_PINS } from "./spec-pins-CqorWDnO.js";
13
12
  //#region src/core/define-repository.d.ts
14
13
  /** Adds `Methods` to the repository of `Table` only. */
@@ -43,6 +42,22 @@ export declare function touchedTables(op: Operation): string[];
43
42
  */
44
43
  export declare function invalidationTargets(meta: SchemaMeta, table: string): readonly string[];
45
44
  //#endregion
45
+ //#region src/core/policy.d.ts
46
+ /**
47
+ * A callback that decides something a kit would otherwise allow or refuse
48
+ * by default: `authorize`, `canInvite`, `shouldDeliver`, `allowUrl`. Only
49
+ * `true` allows; `false`, any other value, a throw or a rejection denies.
50
+ */
51
+ type Policy<A extends readonly unknown[]> = (...args: A) => boolean | PromiseLike<boolean>;
52
+ type PolicyDecision = {
53
+ readonly allowed: true;
54
+ } | {
55
+ readonly allowed: false;
56
+ /** `denied`: the policy returned something other than `true`. `threw`: it threw or rejected. */
57
+ readonly reason: "denied" | "threw";
58
+ readonly cause?: unknown;
59
+ };
60
+ //#endregion
46
61
  //#region src/core/cursor.d.ts
47
62
  /** Opaque, URL-safe keyset cursor. */
48
63
  export declare function encodeCursor(values: readonly unknown[]): string;
@@ -71,11 +86,13 @@ type EnrichDatabase<D, O> = { [S in keyof D]: S extends keyof O ? EnrichSchema<D
71
86
  export declare function escapeLike(value: string): string;
72
87
  //#endregion
73
88
  //#region src/ir/codec.d.ts
74
- /** Wire form of an app value: Temporal values to ISO text, `bigint` to decimal text. */
75
- export declare function encodeValue(value: unknown): unknown;
76
89
  /** Applies column codecs to returned rows, including embedded relations. */
77
90
  export declare function decodeRows(selection: Selection | undefined, rows: readonly Record<string, unknown>[], checked?: boolean): Record<string, unknown>[];
78
91
  //#endregion
92
+ //#region src/ir/wire.d.ts
93
+ /** Wire form of an app value: Temporal values to ISO text, `bigint` to decimal text. */
94
+ export declare function encodeValue(value: unknown): unknown;
95
+ //#endregion
79
96
  //#region src/ir/scope.d.ts
80
97
  /** Returns the filter that always applies to rows of `table`, if any. */
81
98
  type ScopeFor = (table: TableMeta) => Condition | undefined;
@@ -107,4 +124,4 @@ export declare function toCamel(name: string): string;
107
124
  /** `firstName` to `first_name`. */
108
125
  export declare function toSnake(name: string): string;
109
126
  //#endregion
110
- export { type Actor, type AggregateArgs, type AggregateFn, type AggregateResult, type AggregateRow, type Aggregation, type AnyFunctions, type AnyModels, type AnyPlugin, type ApplyExtension, AsyncResult, type AuthEvent, type BetterResultApi, type BetterResultValue, BetterSupabase, type BetterSupabaseEvents, type BucketMeta, type BucketPolicyName, type CacheAdapter, type CacheTarget, type CallOptions, type Casing, type CheckConstraint, type ClaimsMeta, type Codec, type ColumnMeta, type ColumnOp, type Compiler, type Condition, type ConflictTarget, type ConnectOptions, type CountArg, type CountArgs, type CountMode, type CursorPage, type CursorPageArgs, type DatabaseOf, type Db, type DbError, type DbErrorKind, type DbErrorKinds, type DbErrorOf, DbException, type DbHelpers, type DbStats, type DeleteArgs, type DeleteExt, type DeleteOp, EMPTY_STATS, type EnrichDatabase, type Err, type ErrorEvent, type ErrorMapper, type EventHandler, EventHub, type EventName, type ExecuteContext, type ExecuteResult, type Executor, type ExtensionOf, type FieldFilter, type FindExt, type FindFirstArgs, type FindManyArgs, type Flags, type ForeignKeyConstraint, type FunctionMeta, type FunctionSource, type FunctionTypes, type FunctionsOf, type HasFlag, type HookArgs, type Include, type IncludeArg, type IncludeArgs, type InferReadSetParams, type InferResult, type Insert, type InsertOp, type LogFields, type Logger, type Measure, type MeasureArg, type MeasureKey, type MemoryCache, type ModelFlags, type ModelTypes, type ModelsOf, type MutationEvent, type MutationKind, type MutationNotice, type MutationOp, type NoExtension, type NumericMeasureArg, type OffsetPage, type OffsetPageArgs, type Ok, type Operation, type OrderByArg, type OrderByInput, type OrderTerm, PLUGIN_API_VERSION, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, type PageOf, type Payload, type PermdockBucketPolicy, type PermdockTopicPolicy, type PlanFilter, type PlanLimit, type PlanOrder, type Plugin, type PostgrestClientLike, type PostgrestPlan, type PrimaryKeyColumn, type PrimaryKeyValue, type ProblemDetails, type ProblemOptions, type ProblemResponseOptions, type Quantifier, type QueryEvent, type QuerySpec, type RawDbError, type ReadArgs, type ReadMethod, type ReadSet, type ReadSetOptions, type ReadSetParamType, type ReadSetParamTypes, type ReadSetParamValue, type ReadSetParams, type ReadSetResult, type RealtimeTableMeta, type RefreshEvent, type RelationMeasureArg, type RelationMeta, type RelationTypes, type Relations, type Repository, type RepositoryApi, type RepositoryExtension, type RepositoryOf, type RequestContext, type Result, type Returned, type Row, type RpcContext, type RpcDefinition, type RpcNotice, type RpcOptions, SPEC_PINS, type Schema, type SchemaMeta, type ScopeFor, type SearchArgs, type SelectArg, type SelectColumn, type SelectOp, type Selection, type Simplify, type SortDirection, type Specs, type StandardSchemaV1, StatsRecorder, type StoragePath, type SupabaseOptions, type TableFlags, type TableKey, type TableMeta, type TableRepositoryExtension, type TableSpecs, type UniqueConstraint, type UniqueKeyName, type UniqueWhere, type Update, type UpdateArgs, type UpdateOp, type UpsertArgs, type ValidationIssue, type WhereInput, type WithExtension, type WriteArgs, and, cacheTargetOf, column, compilePostgrest, consoleLogger, dbError, definePlugin, defineReadSet, defineSupabase, err, explainPostgrest, fromBetterResult, fromProblem, isCheck, isConflict, isDbError, isForeignKey, isProblem, isQuerySpec, isReadSet, mapDbError, memoryCache, not, ok, or, postgrestCompiler, postgrestExecutor, problemResponse, readSetTables, recordStats, rowKey, rpcCacheTargets, silentLogger, specTables, statusOf, toBetterResult, toDbError, toProblem, validate };
127
+ export { type AccessBucketPolicy, type Actor, type AggregateArgs, type AggregateFn, type AggregateResult, type AggregateRow, type Aggregation, type AnyFunctions, type AnyModels, type AnyPlugin, type ApplyExtension, AsyncResult, type AuthEvent, type BetterResultApi, type BetterResultValue, BetterSupabase, type BetterSupabaseEvents, type BucketMeta, type BucketPolicyName, type CacheAdapter, type CacheTarget, type CallOptions, type Casing, type CheckConstraint, type ClaimsMeta, type Codec, type ColumnMeta, type ColumnOp, type Compiler, type Condition, type ConflictTarget, type ConnectOptions, type CountArg, type CountArgs, type CountMode, type CursorPage, type CursorPageArgs, type DatabaseOf, type Db, type DbError, type DbErrorKind, type DbErrorKinds, type DbErrorOf, DbException, type DbHelpers, type DbStats, type DeleteArgs, type DeleteExt, type DeleteOp, EMPTY_STATS, type EnrichDatabase, type Err, type ErrorEvent, type ErrorMapper, type EventHandler, EventHub, type EventName, type ExecuteContext, type ExecuteResult, type Executor, type ExtensionOf, type FieldFilter, type FindExt, type FindFirstArgs, type FindManyArgs, type Flags, type ForeignKeyConstraint, type FunctionMeta, type FunctionSource, type FunctionTypes, type FunctionsOf, type HasFlag, type HookArgs, type Include, type IncludeArg, type IncludeArgs, type InferReadSetParams, type InferResult, type Insert, type InsertOp, type KitEvent, type KitEventMap, type KitEventType, type LogFields, type Logger, type Measure, type MeasureArg, type MeasureKey, type MemoryCache, type ModelFlags, type ModelTypes, type ModelsOf, type MutationEvent, type MutationIntent, type MutationKind, type MutationNotice, type MutationOp, type NoExtension, type NumericMeasureArg, type OffsetPage, type OffsetPageArgs, type Ok, type Operation, type OrderByArg, type OrderByInput, type OrderTerm, PLUGIN_API_VERSION, PROBLEM_CONTENT_TYPE, PROBLEM_TYPE_BASE, type PageOf, type Payload, type PermdockBucketPolicy, type PermdockTopicPolicy, type PlanFilter, type PlanLimit, type PlanOrder, type Plugin, type Policy, type PolicyDecision, type PostgrestClientLike, type PostgrestPlan, type PrimaryKeyColumn, type PrimaryKeyValue, type ProblemDetails, type ProblemOptions, type ProblemResponseOptions, type Quantifier, type QueryEvent, type QuerySpec, type RawDbError, type ReadArgs, type ReadMethod, type ReadSet, type ReadSetOptions, type ReadSetParamType, type ReadSetParamTypes, type ReadSetParamValue, type ReadSetParams, type ReadSetResult, type RealtimeTableMeta, type RefreshEvent, type RelationMeasureArg, type RelationMeta, type RelationTypes, type Relations, type Repository, type RepositoryApi, type RepositoryExtension, type RepositoryOf, type RequestContext, type Result, type Returned, type Row, type RpcContext, type RpcDefinition, type RpcNotice, type RpcOptions, SPEC_PINS, type Schema, type SchemaMeta, type ScopeFor, type SearchArgs, type SelectArg, type SelectColumn, type SelectOp, type Selection, type Simplify, type SortDirection, type Specs, type StandardSchemaV1, StatsRecorder, type StoragePath, type SupabaseOptions, type TableFlags, type TableKey, type TableMeta, type TableRepositoryExtension, type TableSpecs, type UniqueConstraint, type UniqueKeyName, type UniqueWhere, type Update, type UpdateArgs, type UpdateOp, type UpsertArgs, type ValidationIssue, type WhereInput, type WithExtension, type WriteArgs, and, cacheTargetOf, column, compilePostgrest, consoleLogger, dbError, definePlugin, defineReadSet, defineSupabase, err, explainPostgrest, fromBetterResult, fromProblem, isCheck, isConflict, isDbError, isForeignKey, isProblem, isQuerySpec, isReadSet, mapDbError, memoryCache, not, ok, or, postgrestCompiler, postgrestExecutor, problemResponse, readSetTables, recordStats, rowKey, rpcCacheTargets, silentLogger, specTables, statusOf, toBetterResult, toDbError, toProblem, validate };
package/dist/index.js CHANGED
@@ -1,15 +1,16 @@
1
- import { a as isConflict, c as mapDbError, i as isCheck, l as statusOf, n as dbError, o as isDbError, s as isForeignKey, t as DbException } from "./errors-L0xK41y_.js";
2
- import { i as escapeLike, l as defineSchema, o as decodeRows, s as encodeValue, t as simplify, u as tableMeta } from "./simplify-Cqvfr9dj.js";
1
+ import { a as isConflict, c as mapDbError, i as isCheck, l as statusOf, n as dbError, o as isDbError, s as isForeignKey, t as DbException } from "./errors-DtwXa6b8.js";
2
+ import { i as escapeLike, o as defineSchema, s as tableMeta, t as simplify } from "./simplify-_0oUKqCd.js";
3
3
  import { i as or, n as column, r as not, t as and } from "./types-6cYK9pbJ.js";
4
- import { a as toBetterResult, i as ok, n as err, o as toDbError, r as fromBetterResult, t as AsyncResult } from "./result-Bj6yt33D.js";
5
- import { a as EventHub, c as rowKey, i as encodeCursor, l as rpcCacheTargets, n as defineSupabase, o as cacheTargetOf, r as decodeCursor, s as memoryCache, t as BetterSupabase } from "./define-Bh0AqTik.js";
4
+ import { r as encodeValue } from "./wire-D2dT86vi.js";
5
+ import { a as toBetterResult, i as ok, n as err, o as toDbError, r as fromBetterResult, t as AsyncResult } from "./result-BKiliPY7.js";
6
+ import { a as decodeRows, c as memoryCache, i as encodeCursor, l as rowKey, n as defineSupabase, o as EventHub, r as decodeCursor, s as cacheTargetOf, t as BetterSupabase, u as rpcCacheTargets } from "./define-cNKzqwL_.js";
6
7
  import { n as touchedTables, t as invalidationTargets } from "./tables-Cb-3_VWc.js";
7
8
  import { n as silentLogger, t as consoleLogger } from "./logger-glM28NVN.js";
8
- import { n as definePlugin, t as PLUGIN_API_VERSION } from "./plugin-BqR6wKMB.js";
9
- import { a as postgrestExecutor, i as explainPostgrest, n as StatsRecorder, o as compilePostgrest, r as recordStats, t as EMPTY_STATS } from "./stats-C_YxA2r1.js";
10
- import { c as readSetTables, d as isQuerySpec, f as specTables, i as defineReadSet, o as isReadSet } from "./read-set-FWK8qQ58.js";
11
- import { t as validate } from "./standard-BRyBGTtp.js";
12
- 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-BihjPR0t.js";
9
+ import { r as definePlugin, t as PLUGIN_API_VERSION } from "./plugin-DwARMuQp.js";
10
+ import { a as postgrestExecutor, i as explainPostgrest, n as StatsRecorder, o as compilePostgrest, r as recordStats, t as EMPTY_STATS } from "./stats-Bqob3WqT.js";
11
+ import { c as readSetTables, d as isQuerySpec, f as specTables, i as defineReadSet, o as isReadSet } from "./read-set-DQFt1N_Y.js";
12
+ import { t as validate } from "./standard-D7r6dMUu.js";
13
+ 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-BW1KhzSG.js";
13
14
  import { t as SPEC_PINS } from "./spec-pins-C3oc-Tdp.js";
14
15
  import { n as scopeOperation, r as scopeSelection, t as scopeCondition } from "./scope-CDHcS7dE.js";
15
16
  //#region src/core/define-repository.ts