@marktiderman/genesis-core 2.17.0 → 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.
- package/dist/{aggregate-v_r-nZbH.d.ts → aggregate-CUirs7ka.d.ts} +1 -1
- package/dist/{chunk-UNEZF3ZP.js → chunk-5PCGMSDX.js} +209 -28
- package/dist/chunk-5PCGMSDX.js.map +1 -0
- package/dist/{chunk-JNWTHDGF.js → chunk-AOIVTOHX.js} +3 -3
- package/dist/{chunk-JNWTHDGF.js.map → chunk-AOIVTOHX.js.map} +1 -1
- package/dist/{chunk-FBMKI22S.js → chunk-ATVK3VYS.js} +3 -3
- package/dist/{chunk-FBMKI22S.js.map → chunk-ATVK3VYS.js.map} +1 -1
- package/dist/{chunk-NOPS5EIH.js → chunk-CJ5V6JES.js} +5 -114
- package/dist/chunk-CJ5V6JES.js.map +1 -0
- package/dist/{chunk-TWLPC4S3.js → chunk-DJRT4DUF.js} +3 -3
- package/dist/{chunk-TWLPC4S3.js.map → chunk-DJRT4DUF.js.map} +1 -1
- package/dist/{chunk-WNOCPV4A.js → chunk-DTVYCATJ.js} +3 -3
- package/dist/{chunk-WNOCPV4A.js.map → chunk-DTVYCATJ.js.map} +1 -1
- package/dist/chunk-LYNIHY3F.js +115 -0
- package/dist/chunk-LYNIHY3F.js.map +1 -0
- package/dist/{chunk-6B4CN2TC.js → chunk-OCMYW2YE.js} +3 -3
- package/dist/{chunk-6B4CN2TC.js.map → chunk-OCMYW2YE.js.map} +1 -1
- package/dist/{chunk-AQX5HQD6.js → chunk-OTUTSAZD.js} +3 -3
- package/dist/{chunk-AQX5HQD6.js.map → chunk-OTUTSAZD.js.map} +1 -1
- package/dist/{chunk-KRRESUXT.js → chunk-PH25HOAL.js} +6 -6
- package/dist/{chunk-KRRESUXT.js.map → chunk-PH25HOAL.js.map} +1 -1
- package/dist/{chunk-XIBQ5BTZ.js → chunk-RZVLUUMY.js} +4 -4
- package/dist/{chunk-XIBQ5BTZ.js.map → chunk-RZVLUUMY.js.map} +1 -1
- package/dist/{chunk-2ORQLYVW.js → chunk-SMEG63MO.js} +4 -4
- package/dist/{chunk-2ORQLYVW.js.map → chunk-SMEG63MO.js.map} +1 -1
- package/dist/{chunk-YMFJLBIZ.js → chunk-UKJCF2CM.js} +3 -3
- package/dist/{chunk-YMFJLBIZ.js.map → chunk-UKJCF2CM.js.map} +1 -1
- package/dist/{chunk-K33LWVUF.js → chunk-UKWM32CG.js} +3 -3
- package/dist/{chunk-K33LWVUF.js.map → chunk-UKWM32CG.js.map} +1 -1
- package/dist/csv.d.ts +1 -1
- package/dist/errors.js +2 -1
- package/dist/form-types.d.ts +1 -1
- package/dist/headless/index.d.ts +1 -1
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/index.js +13 -12
- package/dist/hooks/mutation-mode.d.ts +1 -1
- package/dist/hooks/mutation-mode.js +3 -2
- package/dist/hooks/related-keys.d.ts +1 -1
- package/dist/hooks/use-aggregate.d.ts +2 -2
- package/dist/hooks/use-board-columns.d.ts +1 -1
- package/dist/hooks/use-capabilities.d.ts +1 -1
- package/dist/hooks/use-infinite-resource.d.ts +1 -1
- package/dist/hooks/use-link-options.d.ts +1 -1
- package/dist/hooks/use-list-state.d.ts +3 -3
- package/dist/hooks/use-list-state.js +5 -4
- package/dist/hooks/use-live.d.ts +1 -1
- package/dist/hooks/use-one.d.ts +1 -1
- package/dist/hooks/use-relation-label.d.ts +1 -1
- package/dist/hooks/use-resource-form.d.ts +1 -1
- package/dist/hooks/use-resource-form.js +4 -3
- package/dist/hooks/use-resource.d.ts +1 -1
- package/dist/hooks/use-resource.js +4 -3
- package/dist/hooks/use-segment-counts.d.ts +2 -2
- package/dist/hooks/use-segment-counts.js +5 -4
- package/dist/hooks/use-view-board.d.ts +2 -2
- package/dist/hooks/use-view-board.js +8 -7
- package/dist/hooks/use-view-calendar-range.d.ts +2 -2
- package/dist/hooks/use-view-calendar-range.js +6 -5
- package/dist/hooks/use-write.d.ts +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +15 -14
- package/dist/index.js.map +1 -1
- package/dist/provider/index.d.ts +7 -378
- package/dist/provider/index.js +3 -2
- package/dist/{write-outcome-DuwfsnyO.d.ts → read-outcome-Cq0h2oAG.d.ts} +31 -2
- package/dist/resource-view/index.d.ts +4 -4
- package/dist/resource-view/index.js +5 -4
- package/dist/resource-view/index.js.map +1 -1
- package/dist/{saved-views-C45lRm7i.d.ts → saved-views-Bcox3blZ.d.ts} +2 -2
- package/dist/schema/index.d.ts +3 -4
- package/dist/supabase-provider-D5ditkHi.d.ts +465 -0
- package/dist/testing/index.d.ts +87 -3
- package/dist/testing/index.js +88 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/{types-CiQY6hUy.d.ts → types-BnOCVJzm.d.ts} +1 -1
- package/dist/{types-BAhcze_-.d.ts → types-CBtBvGw0.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-NOPS5EIH.js.map +0 -1
- package/dist/chunk-UNEZF3ZP.js.map +0 -1
- package/dist/read-outcome-BnboMYOV.d.ts +0 -30
package/dist/provider/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { D as DataProvider,
|
|
2
|
-
export { k as AggregateMetric, A as AggregateParams, d as AggregateResult, n as ArrayFilter, o as BulkChange, p as BulkResult, 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, J as ImportParams, 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 } from '../types-
|
|
3
|
-
export { R as ResolveAggregateOptions, a as aggregateProblems, r as resolveAggregate, t as toAggregateValues } from '../aggregate-
|
|
4
|
-
import {
|
|
5
|
-
export { a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, i as isDataWriteError } from '../
|
|
6
|
-
|
|
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,376 +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
|
-
/**
|
|
142
|
-
* A function source that pages itself (`SupabaseResourceConfig.source`'s `pages`): the order its
|
|
143
|
-
* rows come in, and the column that carries the whole result's count. A count alone asks the
|
|
144
|
-
* function for `page_limit: 0`, which it answers with one row that carries the count (and builds
|
|
145
|
-
* no other row).
|
|
146
|
-
*
|
|
147
|
-
* @stability Beta
|
|
148
|
-
*/
|
|
149
|
-
interface SourcePages {
|
|
150
|
-
readonly order?: readonly {
|
|
151
|
-
field: string;
|
|
152
|
-
order: "asc" | "desc";
|
|
153
|
-
}[];
|
|
154
|
-
readonly total?: string;
|
|
155
|
-
}
|
|
156
|
-
/** Per-resource rules for `createSupabaseProvider`. Every field is optional. */
|
|
157
|
-
/**
|
|
158
|
-
* What a function source's `args` gets (`SupabaseResourceConfig.source`): the list's filters,
|
|
159
|
-
* which carry the viewer's scope, and `take`, which reads one equality filter's value (`null` for
|
|
160
|
-
* "is empty") and keeps that filter out of the query.
|
|
161
|
-
*
|
|
162
|
-
* @stability Beta
|
|
163
|
-
*/
|
|
164
|
-
interface SourceArgsContext {
|
|
165
|
-
readonly resource: string;
|
|
166
|
-
readonly filters: readonly FilterParam[];
|
|
167
|
-
take(field: string): string | number | boolean | null | undefined;
|
|
168
|
-
/**
|
|
169
|
-
* The values of a filter on `field` that an `in` (or an `eq`, as one value) gives, taken out of
|
|
170
|
-
* the query like `take`; undefined when there's none. For a function that filters by a list.
|
|
171
|
-
*/
|
|
172
|
-
takeIn(field: string): readonly unknown[] | undefined;
|
|
173
|
-
}
|
|
174
|
-
interface SupabaseResourceConfig {
|
|
175
|
-
/** Singular noun for failure messages, e.g. "project". Defaults to "record". */
|
|
176
|
-
noun?: string;
|
|
177
|
-
/** Plural for list messages, when it isn't `noun` + "s" ("categories"). */
|
|
178
|
-
nounPlural?: string;
|
|
179
|
-
/**
|
|
180
|
-
* The columns a search covers. `[]` means the resource can't be searched,
|
|
181
|
-
* and `capabilities(resource).search` reports false so a UI hides the box.
|
|
182
|
-
* Set, they replace the caller's `search.fields`; omitted, those are used
|
|
183
|
-
* as given.
|
|
184
|
-
*/
|
|
185
|
-
searchFields?: readonly string[];
|
|
186
|
-
/**
|
|
187
|
-
* The column a sorted list orders by last, so rows with equal sort values
|
|
188
|
-
* keep one order from page to page (none repeats, none is skipped).
|
|
189
|
-
* Default `"id"`; `false` for a table or view without one. With the
|
|
190
|
-
* default, a view that turns out to have no `id` column is read as before
|
|
191
|
-
* (without the key order) and a development warning suggests setting this.
|
|
192
|
-
*/
|
|
193
|
-
orderKey?: string | false;
|
|
194
|
-
/**
|
|
195
|
-
* `"bin"` for a table whose delete trigger moves the row to a recycle bin
|
|
196
|
-
* instead of removing it (see `SupabaseProviderOptions.binTables`).
|
|
197
|
-
* `"hard"` forces a plain delete even when `binTables` lists the table.
|
|
198
|
-
*/
|
|
199
|
-
deleteMode?: "hard" | "bin";
|
|
200
|
-
/**
|
|
201
|
-
* Turns submitted values into the row to write: trim, drop read-only keys,
|
|
202
|
-
* validate. Runs before every create and update, including the `create`
|
|
203
|
-
* and `update` overrides. Throw (ideally `DataWriteError("invalid", ...)`)
|
|
204
|
-
* to refuse the write; nothing is sent.
|
|
205
|
-
*/
|
|
206
|
-
prepare?: (values: Record<string, unknown>, context: SupabaseWriteContext) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
207
|
-
/**
|
|
208
|
-
* Creates the row some other way than an insert, e.g. a security-definer
|
|
209
|
-
* RPC. Return the new row, or its id and the provider reads the row back
|
|
210
|
-
* (if the read-back fails, the create is still reported as saved, with
|
|
211
|
-
* just the id, so the user does not retry and make a second one). Throw to
|
|
212
|
-
* fail; a Supabase `{ message, code }` error is mapped like any other.
|
|
213
|
-
*/
|
|
214
|
-
create?: (row: Record<string, unknown>) => Promise<BaseRecord | Identifier>;
|
|
215
|
-
/**
|
|
216
|
-
* Updates the row some other way than an update, e.g. an RPC. Return the
|
|
217
|
-
* updated row, or its id (or `true`) and the provider reads it back.
|
|
218
|
-
* Returning nothing (`undefined`/`null`/`false`) means no row changed: the provider then reads the
|
|
219
|
-
* row to say why (`forbidden` or `gone`), exactly as for a plain update,
|
|
220
|
-
* so a function that silently skips a row never reports a save.
|
|
221
|
-
*/
|
|
222
|
-
update?: (id: Identifier, row: Record<string, unknown>, context?: SupabaseUpdateContext) => Promise<BaseRecord | Identifier | boolean | null | undefined | void>;
|
|
223
|
-
/**
|
|
224
|
-
* The column every update and delete of this resource is checked against,
|
|
225
|
-
* so an edit made on a stale copy is refused as a `conflict` instead of
|
|
226
|
-
* overwriting someone else's (`UpdateParams.expectedVersion`).
|
|
227
|
-
*
|
|
228
|
-
* The database must advance it on every update, or it detects nothing:
|
|
229
|
-
* `integer` with genesis-supabase's `genesis_version_bump` trigger
|
|
230
|
-
* (migration 0019), or `timestamp` with a trigger that sets it to `now()`
|
|
231
|
-
* on update (`moddatetime`). The provider never writes it: a submitted
|
|
232
|
-
* value is dropped. Writes without an `expectedVersion` are not checked,
|
|
233
|
-
* so turning this on changes nothing for callers that don't send one.
|
|
234
|
-
*/
|
|
235
|
-
version?: {
|
|
236
|
-
field: string;
|
|
237
|
-
kind: "integer" | "timestamp";
|
|
238
|
-
};
|
|
239
|
-
/** Maps a stored row to edit-form values; see `DataProvider.toFormValues`. */
|
|
240
|
-
toFormValues?: (record: Record<string, unknown>) => Record<string, unknown>;
|
|
241
|
-
/**
|
|
242
|
-
* Other cache keys a committed write to this resource makes stale, e.g.
|
|
243
|
-
* `[["staff"], ["me"]]`. Served through `DataProvider.invalidates`, which
|
|
244
|
-
* `useResource` and `useResourceForm` invalidate after their writes.
|
|
245
|
-
*/
|
|
246
|
-
invalidates?: InvalidationKey[] | ((event: WriteEvent) => InvalidationKey[]);
|
|
247
|
-
/**
|
|
248
|
-
* Serve `subscribe` for this resource through Supabase Realtime
|
|
249
|
-
* (`postgres_changes`), so `live` lists and records refresh when the table
|
|
250
|
-
* changes. The table must be in the `supabase_realtime` publication, with
|
|
251
|
-
* RLS on. `false` turns it off even when `SupabaseProviderOptions.realtime`
|
|
252
|
-
* covers the resource.
|
|
253
|
-
*/
|
|
254
|
-
realtime?: boolean;
|
|
255
|
-
/**
|
|
256
|
-
* Read this resource from somewhere else than its table: a view (joins,
|
|
257
|
-
* counts, aggregations) or a database function that returns rows. Writes
|
|
258
|
-
* still go to the table. Lists keep paging, filters, search, sort, totals
|
|
259
|
-
* and cursors, because PostgREST filters a view or a set-returning function
|
|
260
|
-
* like a table. Realtime still watches the table.
|
|
261
|
-
*
|
|
262
|
-
* Row-level security: a plain view runs as its owner and a SECURITY DEFINER
|
|
263
|
-
* function as its definer, so either one reads past RLS. Create the view
|
|
264
|
-
* `with (security_invoker = true)` and the function `security invoker` (or
|
|
265
|
-
* have it filter by `auth.uid()` itself), or this exposes every row.
|
|
266
|
-
*
|
|
267
|
-
* ```ts
|
|
268
|
-
* resources: {
|
|
269
|
-
* tasks: { source: "tasks_with_people" },
|
|
270
|
-
* course_progress: { source: { rpc: "group_progress", args: ({ take }) => ({ group_id: take("group_id") }) } },
|
|
271
|
-
* }
|
|
272
|
-
* ```
|
|
273
|
-
*
|
|
274
|
-
* A function's `args` gets the list's filters (`context.filters`), which hold the viewer's scope
|
|
275
|
-
* as ResourceView applies it (a view's `scope: ["group_id"]` filters `group_id`), so a function
|
|
276
|
-
* that takes its scope as an argument reads it there rather than from a module variable.
|
|
277
|
-
* `context.take(field)` returns an equality filter's value and leaves that filter out of the
|
|
278
|
-
* query, for a scope the function takes as an argument and doesn't return as a column. A record
|
|
279
|
-
* read (`getOne`, `getMany`) gets the list's filters from `scope` (less a text search's
|
|
280
|
-
* `contains`, which `useOne` leaves out) when the caller passes them
|
|
281
|
-
* (`useOne`'s `scope`, which ResourceView's table, inbox and NativeResourceView's peek and
|
|
282
|
-
* edit sheet pass for a record off the loaded page), else none, and
|
|
283
|
-
* the function's own default scope applies.
|
|
284
|
-
*
|
|
285
|
-
* A function that pages itself declares `pages`: it takes `page_limit` and `page_offset`
|
|
286
|
-
* arguments, returns its rows in `pages.order` (newest first, say) and carries the whole
|
|
287
|
-
* result's count on each row (`pages.total`, default `total_count`). A list page whose filters
|
|
288
|
-
* the function all took, with no search and no sort other than `pages.order`, then passes the
|
|
289
|
-
* page to the function instead of a `range`, and reads its total from that column, so the
|
|
290
|
-
* function never builds rows outside the page. A count alone (a segment's) sends
|
|
291
|
-
* `page_limit: 0`: the function returns one row carrying the count, and builds no other. Any other list reads every row, as without
|
|
292
|
-
* `pages`, since PostgREST can only filter, search or sort what the function returned.
|
|
293
|
-
*/
|
|
294
|
-
source?: string | {
|
|
295
|
-
rpc: string;
|
|
296
|
-
args?: (context: SourceArgsContext) => Record<string, unknown>;
|
|
297
|
-
pages?: SourcePages;
|
|
298
|
-
};
|
|
299
|
-
/**
|
|
300
|
-
* How lists of this resource count their total (default `exact`). Use
|
|
301
|
-
* `estimated` for large tables, or `none` when no screen shows a count.
|
|
302
|
-
*/
|
|
303
|
-
count?: CountMode;
|
|
304
|
-
/** The columns read when the caller names none, e.g. embedded joins: `"*, person:people(full_name)"`. Default `"*"`. */
|
|
305
|
-
select?: string;
|
|
306
|
-
/**
|
|
307
|
-
* With a `source` (or a `select` that embeds other tables), the table's own
|
|
308
|
-
* columns: creates and updates write only these, so a form built from the
|
|
309
|
-
* richer read row never sends its joined or computed columns to the table.
|
|
310
|
-
* Without it, an update writes only the columns the table's row has.
|
|
311
|
-
*/
|
|
312
|
-
writeColumns?: readonly string[];
|
|
313
|
-
}
|
|
314
|
-
/** Options for `createSupabaseProvider`. All optional; none changes reads. */
|
|
315
|
-
interface SupabaseProviderOptions {
|
|
316
|
-
/**
|
|
317
|
-
* Recycle-bin tables: their delete trigger turns a delete into a "binned"
|
|
318
|
-
* mark and the binned row drops out of the caller's view (RLS or a view
|
|
319
|
-
* filter). The database reports such a delete as zero rows, so for these
|
|
320
|
-
* the provider checks the row is visible, deletes it, and reads it back:
|
|
321
|
-
* gone from view is success, still visible is `forbidden`. A row that was
|
|
322
|
-
* not visible beforehand is `gone`. A list matches a `public` table under
|
|
323
|
-
* either spelling; a test is asked once, with the name as the caller gives it.
|
|
324
|
-
*/
|
|
325
|
-
binTables?: readonly string[] | ((resource: string) => boolean);
|
|
326
|
-
/**
|
|
327
|
-
* Per-resource rules, keyed by resource name. A `public` resource may be keyed either way
|
|
328
|
-
* (`goals` or `public.goals`). The key spelled exactly as the caller names the resource wins;
|
|
329
|
-
* the other spelling is used only when that key is absent. Rules are never merged.
|
|
330
|
-
*/
|
|
331
|
-
resources?: Record<string, SupabaseResourceConfig>;
|
|
332
|
-
/**
|
|
333
|
-
* Called after every committed create, update and delete, e.g. to
|
|
334
|
-
* invalidate caches the Genesis hooks don't know about. Awaited, but a
|
|
335
|
-
* failure is logged and never turns a committed write into a failed one.
|
|
336
|
-
*/
|
|
337
|
-
onWrite?: (event: WriteEvent) => void | Promise<void>;
|
|
338
|
-
/**
|
|
339
|
-
* The most rows one list page may ask for (PostgREST's `max-rows` caps
|
|
340
|
-
* reads anyway; default 1000). A larger request is refused with an
|
|
341
|
-
* `invalid` `DataReadError` (its `cause` says why) rather than cut short,
|
|
342
|
-
* so page boundaries never disagree with the caller's `perPage`.
|
|
343
|
-
* `capabilities().maxPerPage` reports it.
|
|
344
|
-
*/
|
|
345
|
-
maxPerPage?: number;
|
|
346
|
-
/**
|
|
347
|
-
* Called with every failed read, before it is thrown. The thrown
|
|
348
|
-
* `DataReadError` carries a plain message for users; the store's own
|
|
349
|
-
* error (its raw text and code) is its `cause`, for logging here.
|
|
350
|
-
*/
|
|
351
|
-
onReadError?: (error: DataReadError, context: {
|
|
352
|
-
resource: string;
|
|
353
|
-
operation: "getList" | "getOne" | "getMany";
|
|
354
|
-
}) => void | Promise<void>;
|
|
355
|
-
/**
|
|
356
|
-
* Which resources `subscribe` serves through Supabase Realtime: `true` for
|
|
357
|
-
* all, a list of names, or a test. Off by default; a resource's own
|
|
358
|
-
* `resources[name].realtime` wins. Needs a client with `channel()` (any
|
|
359
|
-
* `@supabase/supabase-js` client). A list matches a `public` resource
|
|
360
|
-
* under either spelling; a test is asked once, with the name as the caller
|
|
361
|
-
* gives it.
|
|
362
|
-
*/
|
|
363
|
-
realtime?: boolean | readonly string[] | ((resource: string) => boolean);
|
|
364
|
-
/**
|
|
365
|
-
* Work out `sum`, `avg`, `min` and `max` in the database with PostgREST's aggregate functions
|
|
366
|
-
* (`amount.sum()`), which a project turns on with `pgrst.db_aggregates_enabled`. Off by
|
|
367
|
-
* default: `aggregate` then counts in the database and totals the other metrics from the
|
|
368
|
-
* rows, paged (`resolveAggregate`, up to 10 000 rows). A count is always the database's.
|
|
369
|
-
*/
|
|
370
|
-
aggregateFunctions?: boolean;
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* The Supabase data provider. Reads and writes go through the client you
|
|
374
|
-
* pass, under that client's session and RLS.
|
|
375
|
-
*
|
|
376
|
-
* Writes never report a save that did not happen:
|
|
377
|
-
* - `update` and `deleteOne` ask for the affected rows. Zero rows is a
|
|
378
|
-
* `DataWriteError`: the row is read back, and still visible means
|
|
379
|
-
* `forbidden` (RLS or a trigger refused the change), no longer visible
|
|
380
|
-
* means `gone`.
|
|
381
|
-
* - Database errors on writes are thrown as `DataWriteError` with the
|
|
382
|
-
* outcome their code means (`writeOutcomeFromCode`) and the code kept on
|
|
383
|
-
* `error.code`.
|
|
384
|
-
* - Recycle-bin tables (`binTables`) succeed when the row leaves the
|
|
385
|
-
* caller's view.
|
|
386
|
-
*
|
|
387
|
-
* Reads are unchanged: errors are thrown as an `Error` carrying `code`.
|
|
388
|
-
*/
|
|
389
|
-
declare function createSupabaseProvider(client: SupabaseClientInput, options?: SupabaseProviderOptions): DataProvider;
|
|
390
|
-
|
|
391
20
|
/**
|
|
392
21
|
* Maps a store error code to the read outcome it means: the write mapping,
|
|
393
22
|
* with `22***` and PostgREST request errors (`PGRST1**` other than PGRST116,
|
|
@@ -588,4 +217,4 @@ type GenesisProviderProps = {
|
|
|
588
217
|
*/
|
|
589
218
|
declare function GenesisProvider({ children, provider, mock, storage, queryClient: queryClientProp, persist, persistScope, }: GenesisProviderProps): react.JSX.Element;
|
|
590
219
|
|
|
591
|
-
export { BaseRecord, type CallRpcOptions,
|
|
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 };
|
package/dist/provider/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from '../chunk-
|
|
1
|
+
export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from '../chunk-5PCGMSDX.js';
|
|
2
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
|
-
|
|
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 { e as DataRow } from './types-
|
|
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
|
-
|
|
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 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { F as FieldSchema, R as ResourceContract, e as DataRow, l as RowOf, a as FilterParam, k as AggregateMetric, S as SortParam, A as AggregateParams } from '../types-
|
|
2
|
-
import { V as ViewBoard, e as ViewCalendar, f as ViewDefinition, R as ResourceView, D as DisplayHint, g as ViewGallery, h as ViewInbox, i as RowSummary, j as RowPicture, L as LinkFilter, A as Allowed, k as ViewCalendarDurationUnit } from '../types-
|
|
3
|
-
export { l as AnyRecordView, B as BulkTarget, C as ComputedColumn, F as FieldNameOf, I as InboxRow, m as LinkOrder, n as LinkedView, o as RECORD_OPEN_MODES, p as RecordOpen, q as RecordPageTemplate, r as RecordView, s as RecordViewDefinition, t as RecordViewDocument, u as RecordViewFilter, v as RecordViewHeader, w as RecordViewHeaderAction, x as RecordViewHeaderOptions, y as RecordViewListSection, z as RecordViewReadinessItem, E as RecordViewSection, G as RecordViewSettingsSection, H as RecordViewSlotSection, J as ResolvedColumn, d as ResolvedFilter, K as ResolvedFormField, M as ResolvedLink, N as ResolvedReadinessItem, O as ResolvedRecordViewSection, P as ResolvedSegment, Q as ResolvedViewAction, T as ResourceWorkspace, U as RowImage, S as SegmentWhere, W as TimeZoneName, X as ViewAction, Y as ViewBreakpoint, Z as ViewBulkAction, _ as ViewCalendarLayout, $ as ViewColumn, a0 as ViewCopy, a1 as ViewEmphasis, a2 as ViewExport, a3 as ViewField, a4 as ViewFilter, c as ViewFilterKind, b as ViewFilterValue, a5 as ViewFormItem, a6 as ViewGuards, a7 as ViewLink, a8 as ViewPreset, a9 as ViewSegment, aa as ViewTimeZone, a as ViewTone, ab as ViewTotal, ac as WorkspaceDefinition, ad as WorkspaceHeaderAction, ae as WorkspaceSection, af as defineRecordView, ag as defineWorkspace, ah as isRecordView, ai as isWorkspace, aj as sameFormValue } from '../types-
|
|
4
|
-
export { a as LIST_URL_KEYS, L as ListState, b as SavedView, c as SavedViewInput, S as SavedViewStore, d as applicableListState, e as createLocalSavedViewStore, f as decodeFilterValue, g as encodeFilterValue, h as filterOptionLabel, i as filterValueFor, j as isFilterSet, l as listUrlParams, r as readListUrl, w as whereParams } from '../saved-views-
|
|
1
|
+
import { F as FieldSchema, R as ResourceContract, e as DataRow, l as RowOf, a as FilterParam, k as AggregateMetric, S as SortParam, A as AggregateParams } from '../types-BnOCVJzm.js';
|
|
2
|
+
import { V as ViewBoard, e as ViewCalendar, f as ViewDefinition, R as ResourceView, D as DisplayHint, g as ViewGallery, h as ViewInbox, i as RowSummary, j as RowPicture, L as LinkFilter, A as Allowed, k as ViewCalendarDurationUnit } from '../types-CBtBvGw0.js';
|
|
3
|
+
export { l as AnyRecordView, B as BulkTarget, C as ComputedColumn, F as FieldNameOf, I as InboxRow, m as LinkOrder, n as LinkedView, o as RECORD_OPEN_MODES, p as RecordOpen, q as RecordPageTemplate, r as RecordView, s as RecordViewDefinition, t as RecordViewDocument, u as RecordViewFilter, v as RecordViewHeader, w as RecordViewHeaderAction, x as RecordViewHeaderOptions, y as RecordViewListSection, z as RecordViewReadinessItem, E as RecordViewSection, G as RecordViewSettingsSection, H as RecordViewSlotSection, J as ResolvedColumn, d as ResolvedFilter, K as ResolvedFormField, M as ResolvedLink, N as ResolvedReadinessItem, O as ResolvedRecordViewSection, P as ResolvedSegment, Q as ResolvedViewAction, T as ResourceWorkspace, U as RowImage, S as SegmentWhere, W as TimeZoneName, X as ViewAction, Y as ViewBreakpoint, Z as ViewBulkAction, _ as ViewCalendarLayout, $ as ViewColumn, a0 as ViewCopy, a1 as ViewEmphasis, a2 as ViewExport, a3 as ViewField, a4 as ViewFilter, c as ViewFilterKind, b as ViewFilterValue, a5 as ViewFormItem, a6 as ViewGuards, a7 as ViewLink, a8 as ViewPreset, a9 as ViewSegment, aa as ViewTimeZone, a as ViewTone, ab as ViewTotal, ac as WorkspaceDefinition, ad as WorkspaceHeaderAction, ae as WorkspaceSection, af as defineRecordView, ag as defineWorkspace, ah as isRecordView, ai as isWorkspace, aj as sameFormValue } from '../types-CBtBvGw0.js';
|
|
4
|
+
export { a as LIST_URL_KEYS, L as ListState, b as SavedView, c as SavedViewInput, S as SavedViewStore, d as applicableListState, e as createLocalSavedViewStore, f as decodeFilterValue, g as encodeFilterValue, h as filterOptionLabel, i as filterValueFor, j as isFilterSet, l as listUrlParams, r as readListUrl, w as whereParams } from '../saved-views-Bcox3blZ.js';
|
|
5
5
|
import { R as ResourceScope, V as Viewer } from '../viewer-oOk0ZZk9.js';
|
|
6
6
|
export { G as GenesisViewerRoles, N as NO_VIEWER } from '../viewer-oOk0ZZk9.js';
|
|
7
7
|
import { Day, DayRange } from '../dates.js';
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { readinessOf } from '../chunk-PP3XFFQM.js';
|
|
2
|
-
import { ViewDefinitionError, filterParams, scopeFilter } from '../chunk-
|
|
3
|
-
export { RECORD_OPEN_MODES, ViewDefinitionError, boardChoices, boardProblems, calendarProblems, defineView, deriveDisplay, filterParams, galleryProblems, inboxProblems, plural, scopeFilter, scopeValues, singular, valueText } from '../chunk-
|
|
2
|
+
import { ViewDefinitionError, filterParams, scopeFilter } from '../chunk-AOIVTOHX.js';
|
|
3
|
+
export { RECORD_OPEN_MODES, ViewDefinitionError, boardChoices, boardProblems, calendarProblems, defineView, deriveDisplay, filterParams, galleryProblems, inboxProblems, plural, scopeFilter, scopeValues, singular, valueText } from '../chunk-AOIVTOHX.js';
|
|
4
4
|
import '../chunk-BNKP2H7J.js';
|
|
5
|
-
export { calendarEvents, calendarLanes, calendarWindow, displayZone, eventDays, eventDots, laneKeys, placeEvents, shiftAnchor, timeStorage, warnOnce, windowBounds } from '../chunk-
|
|
5
|
+
export { calendarEvents, calendarLanes, calendarWindow, displayZone, eventDays, eventDots, laneKeys, placeEvents, shiftAnchor, timeStorage, warnOnce, windowBounds } from '../chunk-UKJCF2CM.js';
|
|
6
6
|
import { encodeRecordKey } from '../chunk-KV2HW4G4.js';
|
|
7
7
|
export { applicableListState, createLocalSavedViewStore } from '../chunk-MZVFOTAE.js';
|
|
8
8
|
export { LIST_URL_KEYS, decodeFilterValue, encodeFilterValue, filterOptionLabel, filterValueFor, isFilterSet, listUrlParams, readListUrl, whereParams } from '../chunk-6JOWGO2X.js';
|
|
9
9
|
export { NO_VIEWER } from '../chunk-OZYF55E3.js';
|
|
10
10
|
import { toAggregateValues } from '../chunk-J54XXKQD.js';
|
|
11
11
|
import { deviceTimeZone, dayIn, addDays, startOfWeek, isDay } from '../chunk-WXENWPWP.js';
|
|
12
|
-
import '../chunk-
|
|
12
|
+
import '../chunk-CJ5V6JES.js';
|
|
13
|
+
import '../chunk-LYNIHY3F.js';
|
|
13
14
|
import '../chunk-HUNGCTRA.js';
|
|
14
15
|
import '../chunk-RYEXWQFD.js';
|
|
15
16
|
import '../chunk-WLDSIQJ2.js';
|