@marktiderman/genesis-core 2.16.1 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +3 -2
  2. package/dist/{aggregate-Y5IJ5aPn.d.ts → aggregate-CUirs7ka.d.ts} +1 -1
  3. package/dist/{chunk-M5IX7C6U.js → chunk-24X4HWL5.js} +4 -4
  4. package/dist/{chunk-M5IX7C6U.js.map → chunk-24X4HWL5.js.map} +1 -1
  5. package/dist/{chunk-XPBS5YE4.js → chunk-4POVYF6P.js} +4 -4
  6. package/dist/{chunk-XPBS5YE4.js.map → chunk-4POVYF6P.js.map} +1 -1
  7. package/dist/{chunk-IYGVJFCV.js → chunk-5KLIFJYG.js} +3 -3
  8. package/dist/{chunk-IYGVJFCV.js.map → chunk-5KLIFJYG.js.map} +1 -1
  9. package/dist/{chunk-7EFTWOMA.js → chunk-5PCGMSDX.js} +280 -41
  10. package/dist/chunk-5PCGMSDX.js.map +1 -0
  11. package/dist/chunk-6JOWGO2X.js +266 -0
  12. package/dist/chunk-6JOWGO2X.js.map +1 -0
  13. package/dist/{chunk-E3K2A3PK.js → chunk-6SHGMEA6.js} +3 -3
  14. package/dist/{chunk-E3K2A3PK.js.map → chunk-6SHGMEA6.js.map} +1 -1
  15. package/dist/chunk-6VNM6KAX.js +59 -0
  16. package/dist/chunk-6VNM6KAX.js.map +1 -0
  17. package/dist/chunk-AOIVTOHX.js +892 -0
  18. package/dist/chunk-AOIVTOHX.js.map +1 -0
  19. package/dist/{chunk-FXPODKCK.js → chunk-ATVK3VYS.js} +6 -6
  20. package/dist/{chunk-FXPODKCK.js.map → chunk-ATVK3VYS.js.map} +1 -1
  21. package/dist/chunk-BNKP2H7J.js +11 -0
  22. package/dist/chunk-BNKP2H7J.js.map +1 -0
  23. package/dist/{chunk-NOPS5EIH.js → chunk-CJ5V6JES.js} +5 -114
  24. package/dist/chunk-CJ5V6JES.js.map +1 -0
  25. package/dist/chunk-DJRT4DUF.js +53 -0
  26. package/dist/chunk-DJRT4DUF.js.map +1 -0
  27. package/dist/chunk-DTVYCATJ.js +220 -0
  28. package/dist/chunk-DTVYCATJ.js.map +1 -0
  29. package/dist/{chunk-POUI7GAI.js → chunk-JF7FXSQB.js} +5 -5
  30. package/dist/{chunk-POUI7GAI.js.map → chunk-JF7FXSQB.js.map} +1 -1
  31. package/dist/{chunk-LB6FMQQM.js → chunk-KV2HW4G4.js} +3 -11
  32. package/dist/chunk-KV2HW4G4.js.map +1 -0
  33. package/dist/chunk-LYNIHY3F.js +115 -0
  34. package/dist/chunk-LYNIHY3F.js.map +1 -0
  35. package/dist/{chunk-42NVJJTT.js → chunk-MMMC37AP.js} +3 -3
  36. package/dist/{chunk-42NVJJTT.js.map → chunk-MMMC37AP.js.map} +1 -1
  37. package/dist/chunk-MZVFOTAE.js +96 -0
  38. package/dist/chunk-MZVFOTAE.js.map +1 -0
  39. package/dist/{chunk-ALLWIK62.js → chunk-OCMYW2YE.js} +8 -6
  40. package/dist/chunk-OCMYW2YE.js.map +1 -0
  41. package/dist/{chunk-R3YXYVWF.js → chunk-OIZNABG4.js} +5 -4
  42. package/dist/chunk-OIZNABG4.js.map +1 -0
  43. package/dist/{chunk-SOO54YYY.js → chunk-OTUTSAZD.js} +4 -4
  44. package/dist/{chunk-SOO54YYY.js.map → chunk-OTUTSAZD.js.map} +1 -1
  45. package/dist/chunk-PH25HOAL.js +192 -0
  46. package/dist/chunk-PH25HOAL.js.map +1 -0
  47. package/dist/{chunk-QGWQ6LK3.js → chunk-QJOKZZKY.js} +9 -6
  48. package/dist/chunk-QJOKZZKY.js.map +1 -0
  49. package/dist/{chunk-ZYOJWU62.js → chunk-RZVLUUMY.js} +13 -54
  50. package/dist/chunk-RZVLUUMY.js.map +1 -0
  51. package/dist/chunk-SMEG63MO.js +115 -0
  52. package/dist/chunk-SMEG63MO.js.map +1 -0
  53. package/dist/chunk-UKJCF2CM.js +159 -0
  54. package/dist/chunk-UKJCF2CM.js.map +1 -0
  55. package/dist/chunk-UKWM32CG.js +31 -0
  56. package/dist/chunk-UKWM32CG.js.map +1 -0
  57. package/dist/{chunk-UDSTWXXZ.js → chunk-ZKLB2HB5.js} +3 -3
  58. package/dist/{chunk-UDSTWXXZ.js.map → chunk-ZKLB2HB5.js.map} +1 -1
  59. package/dist/csv.d.ts +12 -3
  60. package/dist/csv.js +4 -4
  61. package/dist/csv.js.map +1 -1
  62. package/dist/errors.js +2 -1
  63. package/dist/form-types.d.ts +1 -1
  64. package/dist/headless/index.d.ts +1 -1
  65. package/dist/hooks/index.d.ts +16 -6
  66. package/dist/hooks/index.js +29 -16
  67. package/dist/hooks/mutation-mode.d.ts +1 -1
  68. package/dist/hooks/mutation-mode.js +5 -4
  69. package/dist/hooks/related-keys.d.ts +1 -1
  70. package/dist/hooks/use-aggregate.d.ts +2 -2
  71. package/dist/hooks/use-aggregate.js +3 -3
  72. package/dist/hooks/use-board-columns.d.ts +79 -0
  73. package/dist/hooks/use-board-columns.js +4 -0
  74. package/dist/hooks/use-board-columns.js.map +1 -0
  75. package/dist/hooks/use-capabilities.d.ts +1 -1
  76. package/dist/hooks/use-capabilities.js +2 -2
  77. package/dist/hooks/use-infinite-resource.d.ts +1 -1
  78. package/dist/hooks/use-infinite-resource.js +3 -3
  79. package/dist/hooks/use-link-options.d.ts +1 -1
  80. package/dist/hooks/use-link-options.js +5 -5
  81. package/dist/hooks/use-list-state.d.ts +103 -0
  82. package/dist/hooks/use-list-state.js +22 -0
  83. package/dist/hooks/use-list-state.js.map +1 -0
  84. package/dist/hooks/use-live.d.ts +1 -1
  85. package/dist/hooks/use-live.js +2 -2
  86. package/dist/hooks/use-one.d.ts +7 -1
  87. package/dist/hooks/use-one.js +3 -3
  88. package/dist/hooks/use-persisted-ui-state.js +2 -2
  89. package/dist/hooks/use-relation-label.d.ts +1 -1
  90. package/dist/hooks/use-relation-label.js +2 -2
  91. package/dist/hooks/use-resource-form.d.ts +1 -1
  92. package/dist/hooks/use-resource-form.js +9 -8
  93. package/dist/hooks/use-resource.d.ts +7 -1
  94. package/dist/hooks/use-resource.js +7 -6
  95. package/dist/hooks/use-segment-counts.d.ts +23 -0
  96. package/dist/hooks/use-segment-counts.js +20 -0
  97. package/dist/hooks/use-segment-counts.js.map +1 -0
  98. package/dist/hooks/use-view-board.d.ts +120 -0
  99. package/dist/hooks/use-view-board.js +30 -0
  100. package/dist/hooks/use-view-board.js.map +1 -0
  101. package/dist/hooks/use-view-calendar-range.d.ts +91 -0
  102. package/dist/hooks/use-view-calendar-range.js +23 -0
  103. package/dist/hooks/use-view-calendar-range.js.map +1 -0
  104. package/dist/hooks/use-write.d.ts +1 -1
  105. package/dist/index.d.ts +42 -12
  106. package/dist/index.js +122 -28
  107. package/dist/index.js.map +1 -1
  108. package/dist/provider/index.d.ts +7 -325
  109. package/dist/provider/index.js +4 -3
  110. package/dist/{write-outcome-CkQXgtJq.d.ts → read-outcome-Cq0h2oAG.d.ts} +31 -2
  111. package/dist/resource-view/index.d.ts +162 -757
  112. package/dist/resource-view/index.js +32 -686
  113. package/dist/resource-view/index.js.map +1 -1
  114. package/dist/saved-views-Bcox3blZ.d.ts +155 -0
  115. package/dist/schema/index.d.ts +3 -4
  116. package/dist/schema/index.js +2 -1
  117. package/dist/supabase-provider-D5ditkHi.d.ts +465 -0
  118. package/dist/testing/index.d.ts +87 -3
  119. package/dist/testing/index.js +88 -1
  120. package/dist/testing/index.js.map +1 -1
  121. package/dist/{types-BriIV4e_.d.ts → types-BnOCVJzm.d.ts} +11 -1
  122. package/dist/types-CBtBvGw0.d.ts +1063 -0
  123. package/dist/{viewer-scope-Dx0N9AYk.d.ts → viewer-oOk0ZZk9.d.ts} +36 -34
  124. package/dist/{workspaces-CxpiFu2-.d.ts → workspaces-DeaFix5Z.d.ts} +1 -1
  125. package/dist/workspaces.d.ts +2 -2
  126. package/package.json +11 -1
  127. package/dist/chunk-7EFTWOMA.js.map +0 -1
  128. package/dist/chunk-ALLWIK62.js.map +0 -1
  129. package/dist/chunk-LB6FMQQM.js.map +0 -1
  130. package/dist/chunk-NOPS5EIH.js.map +0 -1
  131. package/dist/chunk-QGWQ6LK3.js.map +0 -1
  132. package/dist/chunk-R3YXYVWF.js.map +0 -1
  133. package/dist/chunk-ZYOJWU62.js.map +0 -1
  134. package/dist/read-outcome-BnboMYOV.d.ts +0 -30
@@ -1,10 +1,9 @@
1
- import { D as DataProvider, d as Identifier, B as BaseRecord, I as InvalidationKey, W as WriteEvent, n as CountMode, a as FilterParam } from '../types-BriIV4e_.js';
2
- export { i as AggregateMetric, A as AggregateParams, b as AggregateResult, k as ArrayFilter, l as BulkChange, m as BulkResult, o as CreateParams, p as CreateResult, q as DeleteParams, r as DeleteResult, G as GetManyParams, v as GetManyResult, w as GetOneParams, x as GetOneResult, H as HistoryParams, y as ImportParams, c as ListParams, L as ListResult, N as NullFilter, z as PaginationParam, E as RangeFilter, g as ResourceChangeEvent, V as RowFailure, Y as ScalarFilter, S as SortParam, f as SubscribeParams, $ as UpdateParams, a0 as UpdateResult } from '../types-BriIV4e_.js';
3
- export { R as ResolveAggregateOptions, a as aggregateProblems, r as resolveAggregate, t as toAggregateValues } from '../aggregate-Y5IJ5aPn.js';
4
- import { D as DataWriteError, W as WriteOutcome } from '../write-outcome-CkQXgtJq.js';
5
- export { a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, i as isDataWriteError } from '../write-outcome-CkQXgtJq.js';
6
- import { D as DataReadError, R as ReadOutcome } from '../read-outcome-BnboMYOV.js';
7
- export { a as DataReadErrorOptions, i as isDataReadError, r as readFailureMessage } from '../read-outcome-BnboMYOV.js';
1
+ import { D as DataProvider, B as BaseRecord, a as FilterParam } from '../types-BnOCVJzm.js';
2
+ export { k as AggregateMetric, A as AggregateParams, d as AggregateResult, n as ArrayFilter, o as BulkChange, p as BulkResult, C as CountMode, r as CreateParams, s as CreateResult, t as DeleteParams, u as DeleteResult, G as GetManyParams, y as GetManyResult, z as GetOneParams, E as GetOneResult, H as HistoryParams, c as Identifier, J as ImportParams, I as InvalidationKey, b as ListParams, L as ListResult, N as NullFilter, K as PaginationParam, M as RangeFilter, h as ResourceChangeEvent, X as RowFailure, Y as ScalarFilter, S as SortParam, g as SubscribeParams, $ as UpdateParams, a0 as UpdateResult, W as WriteEvent } from '../types-BnOCVJzm.js';
3
+ export { R as ResolveAggregateOptions, a as aggregateProblems, r as resolveAggregate, t as toAggregateValues } from '../aggregate-CUirs7ka.js';
4
+ import { R as ReadOutcome, b as DataWriteError, W as WriteOutcome } from '../read-outcome-Cq0h2oAG.js';
5
+ export { D as DataReadError, a as DataReadErrorOptions, c as DataWriteErrorOptions, N as NO_ROWS_MATCHED, i as isDataReadError, d as isDataWriteError, r as readFailureMessage } from '../read-outcome-Cq0h2oAG.js';
6
+ export { F as FunctionCall, R as ResourceWrites, S as SourceArgsContext, a as SourcePages, b as SupabaseClient, c as SupabaseClientInput, d as SupabaseProviderOptions, e as SupabaseRealtimeChannel, f as SupabaseRealtimePayload, g as SupabaseResourceConfig, h as SupabaseUpdateContext, i as SupabaseWriteContext, T as TableAccess, j as createSupabaseProvider } from '../supabase-provider-D5ditkHi.js';
8
7
  import * as react from 'react';
9
8
  import { ReactNode } from 'react';
10
9
  import { QueryClient } from '@tanstack/react-query';
@@ -18,323 +17,6 @@ interface MockProviderOptions {
18
17
  type Row$1 = Record<string, unknown>;
19
18
  declare function createMockProvider(datasets: Record<string, Row$1[]>, options?: MockProviderOptions): DataProvider;
20
19
 
21
- /** A chainable query builder returned by `client.from(table)`. */
22
- interface SupabaseQueryBuilder {
23
- select(columns?: string, options?: {
24
- count?: "exact" | "planned" | "estimated";
25
- }): SupabaseQueryBuilder;
26
- insert(data: Record<string, unknown> | Record<string, unknown>[]): SupabaseQueryBuilder;
27
- update(data: Record<string, unknown>): SupabaseQueryBuilder;
28
- delete(): SupabaseQueryBuilder;
29
- eq(column: string, value: unknown): SupabaseQueryBuilder;
30
- neq(column: string, value: unknown): SupabaseQueryBuilder;
31
- gt(column: string, value: unknown): SupabaseQueryBuilder;
32
- lt(column: string, value: unknown): SupabaseQueryBuilder;
33
- gte(column: string, value: unknown): SupabaseQueryBuilder;
34
- lte(column: string, value: unknown): SupabaseQueryBuilder;
35
- ilike(column: string, value: string): SupabaseQueryBuilder;
36
- in(column: string, values: unknown[]): SupabaseQueryBuilder;
37
- is(column: string, value: null): SupabaseQueryBuilder;
38
- not(column: string, operator: string, value: unknown): SupabaseQueryBuilder;
39
- or(filters: string): SupabaseQueryBuilder;
40
- order(column: string, options?: {
41
- ascending?: boolean;
42
- nullsFirst?: boolean;
43
- }): SupabaseQueryBuilder;
44
- range(from: number, to: number): SupabaseQueryBuilder;
45
- single(): SupabaseQueryBuilder;
46
- then: Promise<{
47
- data: unknown;
48
- error: unknown;
49
- count?: number | null;
50
- }>["then"];
51
- }
52
- /**
53
- * Minimal Supabase client interface — the public shape this package has
54
- * always exposed for a caller that wants to type its own client or a
55
- * wrapper around one. Unchanged: `from()` still returns `SupabaseQueryBuilder`
56
- * so existing consumers that annotate a variable with this type and chain
57
- * off it keep type-checking exactly as before.
58
- */
59
- interface SupabaseClient {
60
- from(table: string): SupabaseQueryBuilder;
61
- /** Another schema's tables, for a resource named `schema.table` outside `public`. */
62
- schema?(name: string): {
63
- from(table: string): SupabaseQueryBuilder;
64
- };
65
- /** Supabase Realtime; needed only for `subscribe` (see `SupabaseProviderOptions.realtime`). */
66
- channel?(name: string): SupabaseRealtimeChannel;
67
- /** Releases a channel made by `channel()`. */
68
- removeChannel?(channel: SupabaseRealtimeChannel): unknown;
69
- }
70
- /**
71
- * One `postgres_changes` message, as Supabase Realtime sends it. Only the
72
- * fields the provider reads; a real payload has more.
73
- */
74
- interface SupabaseRealtimePayload {
75
- eventType: "INSERT" | "UPDATE" | "DELETE";
76
- /** The row after an insert or update (empty for a delete). */
77
- new?: Record<string, unknown>;
78
- /** For a delete or update: the old row's key (all of it with `REPLICA IDENTITY FULL`). */
79
- old?: Record<string, unknown>;
80
- }
81
- /**
82
- * The part of a Supabase `RealtimeChannel` the provider uses. A real
83
- * `@supabase/supabase-js` channel satisfies it.
84
- */
85
- interface SupabaseRealtimeChannel {
86
- on(type: "postgres_changes", filter: {
87
- event: "*" | "INSERT" | "UPDATE" | "DELETE";
88
- schema: string;
89
- table: string;
90
- filter?: string;
91
- }, callback: (payload: SupabaseRealtimePayload) => void): SupabaseRealtimeChannel;
92
- subscribe(callback?: (status: string, error?: unknown) => void): SupabaseRealtimeChannel;
93
- unsubscribe?(): unknown;
94
- }
95
- /**
96
- * What `createSupabaseProvider` actually requires from its `client` argument
97
- * — deliberately looser than the public `SupabaseClient` above, and used
98
- * ONLY for that one parameter. A real `@supabase/supabase-js` client's
99
- * `from()` returns a generic, table-typed `PostgrestQueryBuilder` whose chain
100
- * methods don't structurally match `SupabaseQueryBuilder`, which used to
101
- * force callers to pass their client through `as never`. Since `unknown` is
102
- * a supertype of everything, any real client's `from(table: string)`
103
- * satisfies THIS shape without a cast; `createSupabaseProvider` narrows to
104
- * `SupabaseQueryBuilder` internally, once, right after each `from()` call.
105
- * Loosening only the input here — rather than `SupabaseClient` itself —
106
- * means a caller relying on `SupabaseClient`'s stricter return type for
107
- * their own chaining is unaffected.
108
- */
109
- interface SupabaseClientInput {
110
- from(table: string): unknown;
111
- /** Another schema's tables, for a resource named `schema.table` outside `public`. Any real client's `schema` fits. */
112
- schema?(name: string): {
113
- from(table: string): unknown;
114
- };
115
- /** Database functions, for a resource whose `source` is an `rpc`. Any real client's `rpc` fits. */
116
- rpc?(fn: string, args?: Record<string, unknown>, options?: {
117
- count?: "exact" | "planned" | "estimated";
118
- }): unknown;
119
- /** Supabase Realtime, for `subscribe`. Any real client's `channel` fits. */
120
- channel?(name: string): unknown;
121
- removeChannel?(channel: unknown): unknown;
122
- }
123
- /** What a write hook is told about the write it is part of. */
124
- interface SupabaseWriteContext {
125
- resource: string;
126
- action: "create" | "update";
127
- /** The row's id, for an update. */
128
- id?: Identifier;
129
- }
130
- /** What an `update` override is told besides the row. */
131
- interface SupabaseUpdateContext {
132
- /**
133
- * With a `version` rule and an `expectedVersion` from the caller: the
134
- * version the row must still be at. The override must apply the change
135
- * only at that version (e.g. `... where id = $1 and version = $2`) and
136
- * return nothing when no row matched; the provider then tells a
137
- * `conflict` from `forbidden` and `gone`.
138
- */
139
- expectedVersion?: string;
140
- }
141
- /** Per-resource rules for `createSupabaseProvider`. Every field is optional. */
142
- interface SupabaseResourceConfig {
143
- /** Singular noun for failure messages, e.g. "project". Defaults to "record". */
144
- noun?: string;
145
- /** Plural for list messages, when it isn't `noun` + "s" ("categories"). */
146
- nounPlural?: string;
147
- /**
148
- * The columns a search covers. `[]` means the resource can't be searched,
149
- * and `capabilities(resource).search` reports false so a UI hides the box.
150
- * Set, they replace the caller's `search.fields`; omitted, those are used
151
- * as given.
152
- */
153
- searchFields?: readonly string[];
154
- /**
155
- * The column a sorted list orders by last, so rows with equal sort values
156
- * keep one order from page to page (none repeats, none is skipped).
157
- * Default `"id"`; `false` for a table or view without one. With the
158
- * default, a view that turns out to have no `id` column is read as before
159
- * (without the key order) and a development warning suggests setting this.
160
- */
161
- orderKey?: string | false;
162
- /**
163
- * `"bin"` for a table whose delete trigger moves the row to a recycle bin
164
- * instead of removing it (see `SupabaseProviderOptions.binTables`).
165
- * `"hard"` forces a plain delete even when `binTables` lists the table.
166
- */
167
- deleteMode?: "hard" | "bin";
168
- /**
169
- * Turns submitted values into the row to write: trim, drop read-only keys,
170
- * validate. Runs before every create and update, including the `create`
171
- * and `update` overrides. Throw (ideally `DataWriteError("invalid", ...)`)
172
- * to refuse the write; nothing is sent.
173
- */
174
- prepare?: (values: Record<string, unknown>, context: SupabaseWriteContext) => Record<string, unknown> | Promise<Record<string, unknown>>;
175
- /**
176
- * Creates the row some other way than an insert, e.g. a security-definer
177
- * RPC. Return the new row, or its id and the provider reads the row back
178
- * (if the read-back fails, the create is still reported as saved, with
179
- * just the id, so the user does not retry and make a second one). Throw to
180
- * fail; a Supabase `{ message, code }` error is mapped like any other.
181
- */
182
- create?: (row: Record<string, unknown>) => Promise<BaseRecord | Identifier>;
183
- /**
184
- * Updates the row some other way than an update, e.g. an RPC. Return the
185
- * updated row, or its id (or `true`) and the provider reads it back.
186
- * Returning nothing (`undefined`/`null`/`false`) means no row changed: the provider then reads the
187
- * row to say why (`forbidden` or `gone`), exactly as for a plain update,
188
- * so a function that silently skips a row never reports a save.
189
- */
190
- update?: (id: Identifier, row: Record<string, unknown>, context?: SupabaseUpdateContext) => Promise<BaseRecord | Identifier | boolean | null | undefined | void>;
191
- /**
192
- * The column every update and delete of this resource is checked against,
193
- * so an edit made on a stale copy is refused as a `conflict` instead of
194
- * overwriting someone else's (`UpdateParams.expectedVersion`).
195
- *
196
- * The database must advance it on every update, or it detects nothing:
197
- * `integer` with genesis-supabase's `genesis_version_bump` trigger
198
- * (migration 0019), or `timestamp` with a trigger that sets it to `now()`
199
- * on update (`moddatetime`). The provider never writes it: a submitted
200
- * value is dropped. Writes without an `expectedVersion` are not checked,
201
- * so turning this on changes nothing for callers that don't send one.
202
- */
203
- version?: {
204
- field: string;
205
- kind: "integer" | "timestamp";
206
- };
207
- /** Maps a stored row to edit-form values; see `DataProvider.toFormValues`. */
208
- toFormValues?: (record: Record<string, unknown>) => Record<string, unknown>;
209
- /**
210
- * Other cache keys a committed write to this resource makes stale, e.g.
211
- * `[["staff"], ["me"]]`. Served through `DataProvider.invalidates`, which
212
- * `useResource` and `useResourceForm` invalidate after their writes.
213
- */
214
- invalidates?: InvalidationKey[] | ((event: WriteEvent) => InvalidationKey[]);
215
- /**
216
- * Serve `subscribe` for this resource through Supabase Realtime
217
- * (`postgres_changes`), so `live` lists and records refresh when the table
218
- * changes. The table must be in the `supabase_realtime` publication, with
219
- * RLS on. `false` turns it off even when `SupabaseProviderOptions.realtime`
220
- * covers the resource.
221
- */
222
- realtime?: boolean;
223
- /**
224
- * Read this resource from somewhere else than its table: a view (joins,
225
- * counts, aggregations) or a database function that returns rows. Writes
226
- * still go to the table. Lists keep paging, filters, search, sort, totals
227
- * and cursors, because PostgREST filters a view or a set-returning function
228
- * like a table. Realtime still watches the table.
229
- *
230
- * Row-level security: a plain view runs as its owner and a SECURITY DEFINER
231
- * function as its definer, so either one reads past RLS. Create the view
232
- * `with (security_invoker = true)` and the function `security invoker` (or
233
- * have it filter by `auth.uid()` itself), or this exposes every row.
234
- *
235
- * ```ts
236
- * resources: {
237
- * tasks: { source: "tasks_with_people" },
238
- * course_progress: { source: { rpc: "group_progress", args: () => ({ group_id: currentGroup() }) } },
239
- * }
240
- * ```
241
- */
242
- source?: string | {
243
- rpc: string;
244
- args?: () => Record<string, unknown>;
245
- };
246
- /**
247
- * How lists of this resource count their total (default `exact`). Use
248
- * `estimated` for large tables, or `none` when no screen shows a count.
249
- */
250
- count?: CountMode;
251
- /** The columns read when the caller names none, e.g. embedded joins: `"*, person:people(full_name)"`. Default `"*"`. */
252
- select?: string;
253
- /**
254
- * With a `source` (or a `select` that embeds other tables), the table's own
255
- * columns: creates and updates write only these, so a form built from the
256
- * richer read row never sends its joined or computed columns to the table.
257
- * Without it, an update writes only the columns the table's row has.
258
- */
259
- writeColumns?: readonly string[];
260
- }
261
- /** Options for `createSupabaseProvider`. All optional; none changes reads. */
262
- interface SupabaseProviderOptions {
263
- /**
264
- * Recycle-bin tables: their delete trigger turns a delete into a "binned"
265
- * mark and the binned row drops out of the caller's view (RLS or a view
266
- * filter). The database reports such a delete as zero rows, so for these
267
- * the provider checks the row is visible, deletes it, and reads it back:
268
- * gone from view is success, still visible is `forbidden`. A row that was
269
- * not visible beforehand is `gone`. A list matches a `public` table under
270
- * either spelling; a test is asked once, with the name as the caller gives it.
271
- */
272
- binTables?: readonly string[] | ((resource: string) => boolean);
273
- /**
274
- * Per-resource rules, keyed by resource name. A `public` resource may be keyed either way
275
- * (`goals` or `public.goals`). The key spelled exactly as the caller names the resource wins;
276
- * the other spelling is used only when that key is absent. Rules are never merged.
277
- */
278
- resources?: Record<string, SupabaseResourceConfig>;
279
- /**
280
- * Called after every committed create, update and delete, e.g. to
281
- * invalidate caches the Genesis hooks don't know about. Awaited, but a
282
- * failure is logged and never turns a committed write into a failed one.
283
- */
284
- onWrite?: (event: WriteEvent) => void | Promise<void>;
285
- /**
286
- * The most rows one list page may ask for (PostgREST's `max-rows` caps
287
- * reads anyway; default 1000). A larger request is refused with an
288
- * `invalid` `DataReadError` (its `cause` says why) rather than cut short,
289
- * so page boundaries never disagree with the caller's `perPage`.
290
- * `capabilities().maxPerPage` reports it.
291
- */
292
- maxPerPage?: number;
293
- /**
294
- * Called with every failed read, before it is thrown. The thrown
295
- * `DataReadError` carries a plain message for users; the store's own
296
- * error (its raw text and code) is its `cause`, for logging here.
297
- */
298
- onReadError?: (error: DataReadError, context: {
299
- resource: string;
300
- operation: "getList" | "getOne" | "getMany";
301
- }) => void | Promise<void>;
302
- /**
303
- * Which resources `subscribe` serves through Supabase Realtime: `true` for
304
- * all, a list of names, or a test. Off by default; a resource's own
305
- * `resources[name].realtime` wins. Needs a client with `channel()` (any
306
- * `@supabase/supabase-js` client). A list matches a `public` resource
307
- * under either spelling; a test is asked once, with the name as the caller
308
- * gives it.
309
- */
310
- realtime?: boolean | readonly string[] | ((resource: string) => boolean);
311
- /**
312
- * Work out `sum`, `avg`, `min` and `max` in the database with PostgREST's aggregate functions
313
- * (`amount.sum()`), which a project turns on with `pgrst.db_aggregates_enabled`. Off by
314
- * default: `aggregate` then counts in the database and totals the other metrics from the
315
- * rows, paged (`resolveAggregate`, up to 10 000 rows). A count is always the database's.
316
- */
317
- aggregateFunctions?: boolean;
318
- }
319
- /**
320
- * The Supabase data provider. Reads and writes go through the client you
321
- * pass, under that client's session and RLS.
322
- *
323
- * Writes never report a save that did not happen:
324
- * - `update` and `deleteOne` ask for the affected rows. Zero rows is a
325
- * `DataWriteError`: the row is read back, and still visible means
326
- * `forbidden` (RLS or a trigger refused the change), no longer visible
327
- * means `gone`.
328
- * - Database errors on writes are thrown as `DataWriteError` with the
329
- * outcome their code means (`writeOutcomeFromCode`) and the code kept on
330
- * `error.code`.
331
- * - Recycle-bin tables (`binTables`) succeed when the row leaves the
332
- * caller's view.
333
- *
334
- * Reads are unchanged: errors are thrown as an `Error` carrying `code`.
335
- */
336
- declare function createSupabaseProvider(client: SupabaseClientInput, options?: SupabaseProviderOptions): DataProvider;
337
-
338
20
  /**
339
21
  * Maps a store error code to the read outcome it means: the write mapping,
340
22
  * with `22***` and PostgREST request errors (`PGRST1**` other than PGRST116,
@@ -535,4 +217,4 @@ type GenesisProviderProps = {
535
217
  */
536
218
  declare function GenesisProvider({ children, provider, mock, storage, queryClient: queryClientProp, persist, persistScope, }: GenesisProviderProps): react.JSX.Element;
537
219
 
538
- export { BaseRecord, type CallRpcOptions, CountMode, type CreateOrAdoptOptions, type CreateOrAdoptResult, DEFAULT_RPC_MESSAGES, DataProvider, DataProviderRoot, type DataProviderRootProps, DataReadError, DataWriteError, FilterParam, GenesisProvider, type GenesisProviderProps, Identifier, InvalidationKey, type MockProviderOptions, type PostgrestFieldErrors, RPC_FAILED, ReadOutcome, type RpcClient, type SupabaseClient, type SupabaseClientInput, type SupabaseProviderOptions, type SupabaseRealtimeChannel, type SupabaseRealtimePayload, type SupabaseResourceConfig, type SupabaseUpdateContext, type SupabaseWriteContext, WriteEvent, WriteOutcome, callRpc, createMockProvider, createOrAdopt, createSupabaseProvider, fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, useDataProvider, useStorage, writeOutcomeFromCode };
220
+ export { BaseRecord, type CallRpcOptions, type CreateOrAdoptOptions, type CreateOrAdoptResult, DEFAULT_RPC_MESSAGES, DataProvider, DataProviderRoot, type DataProviderRootProps, DataWriteError, FilterParam, GenesisProvider, type GenesisProviderProps, type MockProviderOptions, type PostgrestFieldErrors, RPC_FAILED, ReadOutcome, type RpcClient, WriteOutcome, callRpc, createMockProvider, createOrAdopt, fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, useDataProvider, useStorage, writeOutcomeFromCode };
@@ -1,8 +1,9 @@
1
- export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from '../chunk-7EFTWOMA.js';
2
- export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from '../chunk-R3YXYVWF.js';
1
+ export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from '../chunk-5PCGMSDX.js';
2
+ export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from '../chunk-OIZNABG4.js';
3
3
  export { aggregateProblems, resolveAggregate, toAggregateValues } from '../chunk-J54XXKQD.js';
4
4
  import '../chunk-4PTQYT5J.js';
5
- export { fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, writeOutcomeFromCode } from '../chunk-NOPS5EIH.js';
5
+ import '../chunk-CJ5V6JES.js';
6
+ export { fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, writeOutcomeFromCode } from '../chunk-LYNIHY3F.js';
6
7
  export { DataReadError, isDataReadError, readFailureMessage } from '../chunk-HUNGCTRA.js';
7
8
  import '../chunk-RYEXWQFD.js';
8
9
  export { DataWriteError, NO_ROWS_MATCHED, isDataWriteError } from '../chunk-WLDSIQJ2.js';
@@ -1,4 +1,4 @@
1
- import { j as DataRow } from './types-BriIV4e_.js';
1
+ import { e as DataRow } from './types-BnOCVJzm.js';
2
2
 
3
3
  /**
4
4
  * - `conflict`: someone else changed the row since it was read. `current`
@@ -61,4 +61,33 @@ declare class DataWriteError extends Error {
61
61
  */
62
62
  declare function isDataWriteError(error: unknown): error is DataWriteError;
63
63
 
64
- export { DataWriteError as D, NO_ROWS_MATCHED as N, type WriteOutcome as W, type DataWriteErrorOptions as a, isDataWriteError as i };
64
+ /**
65
+ * - `unauthenticated`: no signed-in user, or the session expired.
66
+ * - `forbidden`: this user may not read these records.
67
+ * - `gone`: the one record asked for doesn't exist, or isn't visible.
68
+ * - `invalid`: the request itself was wrong (an unknown column, a bad value).
69
+ * - `error`: anything else.
70
+ */
71
+ type ReadOutcome = "unauthenticated" | "forbidden" | "gone" | "invalid" | "error";
72
+ interface DataReadErrorOptions {
73
+ /** The store's own error code (a Postgres SQLSTATE or PostgREST code). */
74
+ code?: string;
75
+ /** The underlying error, with its raw text, kept for logging. */
76
+ cause?: unknown;
77
+ }
78
+ /** Thrown by a provider when a read failed. Its `message` is safe to show. */
79
+ declare class DataReadError extends Error {
80
+ readonly outcome: ReadOutcome;
81
+ /** The store's own error code, when it gave one. */
82
+ readonly code?: string;
83
+ constructor(outcome: ReadOutcome, message: string, options?: DataReadErrorOptions);
84
+ }
85
+ /**
86
+ * `instanceof` fails when two copies of this package are installed, so check
87
+ * the shape instead.
88
+ */
89
+ declare function isDataReadError(error: unknown): error is DataReadError;
90
+ /** The plain sentence for a failed read of `noun` records (one, or a list). */
91
+ declare function readFailureMessage(outcome: ReadOutcome, noun: string, one: boolean, plural?: string): string;
92
+
93
+ export { DataReadError as D, NO_ROWS_MATCHED as N, type ReadOutcome as R, type WriteOutcome as W, type DataReadErrorOptions as a, DataWriteError as b, type DataWriteErrorOptions as c, isDataWriteError as d, isDataReadError as i, readFailureMessage as r };