@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.
- package/README.md +3 -2
- package/dist/{aggregate-Y5IJ5aPn.d.ts → aggregate-CUirs7ka.d.ts} +1 -1
- package/dist/{chunk-M5IX7C6U.js → chunk-24X4HWL5.js} +4 -4
- package/dist/{chunk-M5IX7C6U.js.map → chunk-24X4HWL5.js.map} +1 -1
- package/dist/{chunk-XPBS5YE4.js → chunk-4POVYF6P.js} +4 -4
- package/dist/{chunk-XPBS5YE4.js.map → chunk-4POVYF6P.js.map} +1 -1
- package/dist/{chunk-IYGVJFCV.js → chunk-5KLIFJYG.js} +3 -3
- package/dist/{chunk-IYGVJFCV.js.map → chunk-5KLIFJYG.js.map} +1 -1
- package/dist/{chunk-7EFTWOMA.js → chunk-5PCGMSDX.js} +280 -41
- package/dist/chunk-5PCGMSDX.js.map +1 -0
- package/dist/chunk-6JOWGO2X.js +266 -0
- package/dist/chunk-6JOWGO2X.js.map +1 -0
- package/dist/{chunk-E3K2A3PK.js → chunk-6SHGMEA6.js} +3 -3
- package/dist/{chunk-E3K2A3PK.js.map → chunk-6SHGMEA6.js.map} +1 -1
- package/dist/chunk-6VNM6KAX.js +59 -0
- package/dist/chunk-6VNM6KAX.js.map +1 -0
- package/dist/chunk-AOIVTOHX.js +892 -0
- package/dist/chunk-AOIVTOHX.js.map +1 -0
- package/dist/{chunk-FXPODKCK.js → chunk-ATVK3VYS.js} +6 -6
- package/dist/{chunk-FXPODKCK.js.map → chunk-ATVK3VYS.js.map} +1 -1
- package/dist/chunk-BNKP2H7J.js +11 -0
- package/dist/chunk-BNKP2H7J.js.map +1 -0
- package/dist/{chunk-NOPS5EIH.js → chunk-CJ5V6JES.js} +5 -114
- package/dist/chunk-CJ5V6JES.js.map +1 -0
- package/dist/chunk-DJRT4DUF.js +53 -0
- package/dist/chunk-DJRT4DUF.js.map +1 -0
- package/dist/chunk-DTVYCATJ.js +220 -0
- package/dist/chunk-DTVYCATJ.js.map +1 -0
- package/dist/{chunk-POUI7GAI.js → chunk-JF7FXSQB.js} +5 -5
- package/dist/{chunk-POUI7GAI.js.map → chunk-JF7FXSQB.js.map} +1 -1
- package/dist/{chunk-LB6FMQQM.js → chunk-KV2HW4G4.js} +3 -11
- package/dist/chunk-KV2HW4G4.js.map +1 -0
- package/dist/chunk-LYNIHY3F.js +115 -0
- package/dist/chunk-LYNIHY3F.js.map +1 -0
- package/dist/{chunk-42NVJJTT.js → chunk-MMMC37AP.js} +3 -3
- package/dist/{chunk-42NVJJTT.js.map → chunk-MMMC37AP.js.map} +1 -1
- package/dist/chunk-MZVFOTAE.js +96 -0
- package/dist/chunk-MZVFOTAE.js.map +1 -0
- package/dist/{chunk-ALLWIK62.js → chunk-OCMYW2YE.js} +8 -6
- package/dist/chunk-OCMYW2YE.js.map +1 -0
- package/dist/{chunk-R3YXYVWF.js → chunk-OIZNABG4.js} +5 -4
- package/dist/chunk-OIZNABG4.js.map +1 -0
- package/dist/{chunk-SOO54YYY.js → chunk-OTUTSAZD.js} +4 -4
- package/dist/{chunk-SOO54YYY.js.map → chunk-OTUTSAZD.js.map} +1 -1
- package/dist/chunk-PH25HOAL.js +192 -0
- package/dist/chunk-PH25HOAL.js.map +1 -0
- package/dist/{chunk-QGWQ6LK3.js → chunk-QJOKZZKY.js} +9 -6
- package/dist/chunk-QJOKZZKY.js.map +1 -0
- package/dist/{chunk-ZYOJWU62.js → chunk-RZVLUUMY.js} +13 -54
- package/dist/chunk-RZVLUUMY.js.map +1 -0
- package/dist/chunk-SMEG63MO.js +115 -0
- package/dist/chunk-SMEG63MO.js.map +1 -0
- package/dist/chunk-UKJCF2CM.js +159 -0
- package/dist/chunk-UKJCF2CM.js.map +1 -0
- package/dist/chunk-UKWM32CG.js +31 -0
- package/dist/chunk-UKWM32CG.js.map +1 -0
- package/dist/{chunk-UDSTWXXZ.js → chunk-ZKLB2HB5.js} +3 -3
- package/dist/{chunk-UDSTWXXZ.js.map → chunk-ZKLB2HB5.js.map} +1 -1
- package/dist/csv.d.ts +12 -3
- package/dist/csv.js +4 -4
- package/dist/csv.js.map +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 +16 -6
- package/dist/hooks/index.js +29 -16
- package/dist/hooks/mutation-mode.d.ts +1 -1
- package/dist/hooks/mutation-mode.js +5 -4
- package/dist/hooks/related-keys.d.ts +1 -1
- package/dist/hooks/use-aggregate.d.ts +2 -2
- package/dist/hooks/use-aggregate.js +3 -3
- package/dist/hooks/use-board-columns.d.ts +79 -0
- package/dist/hooks/use-board-columns.js +4 -0
- package/dist/hooks/use-board-columns.js.map +1 -0
- package/dist/hooks/use-capabilities.d.ts +1 -1
- package/dist/hooks/use-capabilities.js +2 -2
- package/dist/hooks/use-infinite-resource.d.ts +1 -1
- package/dist/hooks/use-infinite-resource.js +3 -3
- package/dist/hooks/use-link-options.d.ts +1 -1
- package/dist/hooks/use-link-options.js +5 -5
- package/dist/hooks/use-list-state.d.ts +103 -0
- package/dist/hooks/use-list-state.js +22 -0
- package/dist/hooks/use-list-state.js.map +1 -0
- package/dist/hooks/use-live.d.ts +1 -1
- package/dist/hooks/use-live.js +2 -2
- package/dist/hooks/use-one.d.ts +7 -1
- package/dist/hooks/use-one.js +3 -3
- package/dist/hooks/use-persisted-ui-state.js +2 -2
- package/dist/hooks/use-relation-label.d.ts +1 -1
- package/dist/hooks/use-relation-label.js +2 -2
- package/dist/hooks/use-resource-form.d.ts +1 -1
- package/dist/hooks/use-resource-form.js +9 -8
- package/dist/hooks/use-resource.d.ts +7 -1
- package/dist/hooks/use-resource.js +7 -6
- package/dist/hooks/use-segment-counts.d.ts +23 -0
- package/dist/hooks/use-segment-counts.js +20 -0
- package/dist/hooks/use-segment-counts.js.map +1 -0
- package/dist/hooks/use-view-board.d.ts +120 -0
- package/dist/hooks/use-view-board.js +30 -0
- package/dist/hooks/use-view-board.js.map +1 -0
- package/dist/hooks/use-view-calendar-range.d.ts +91 -0
- package/dist/hooks/use-view-calendar-range.js +23 -0
- package/dist/hooks/use-view-calendar-range.js.map +1 -0
- package/dist/hooks/use-write.d.ts +1 -1
- package/dist/index.d.ts +42 -12
- package/dist/index.js +122 -28
- package/dist/index.js.map +1 -1
- package/dist/provider/index.d.ts +7 -325
- package/dist/provider/index.js +4 -3
- package/dist/{write-outcome-CkQXgtJq.d.ts → read-outcome-Cq0h2oAG.d.ts} +31 -2
- package/dist/resource-view/index.d.ts +162 -757
- package/dist/resource-view/index.js +32 -686
- package/dist/resource-view/index.js.map +1 -1
- package/dist/saved-views-Bcox3blZ.d.ts +155 -0
- package/dist/schema/index.d.ts +3 -4
- package/dist/schema/index.js +2 -1
- 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-BriIV4e_.d.ts → types-BnOCVJzm.d.ts} +11 -1
- package/dist/types-CBtBvGw0.d.ts +1063 -0
- package/dist/{viewer-scope-Dx0N9AYk.d.ts → viewer-oOk0ZZk9.d.ts} +36 -34
- package/dist/{workspaces-CxpiFu2-.d.ts → workspaces-DeaFix5Z.d.ts} +1 -1
- package/dist/workspaces.d.ts +2 -2
- package/package.json +11 -1
- package/dist/chunk-7EFTWOMA.js.map +0 -1
- package/dist/chunk-ALLWIK62.js.map +0 -1
- package/dist/chunk-LB6FMQQM.js.map +0 -1
- package/dist/chunk-NOPS5EIH.js.map +0 -1
- package/dist/chunk-QGWQ6LK3.js.map +0 -1
- package/dist/chunk-R3YXYVWF.js.map +0 -1
- package/dist/chunk-ZYOJWU62.js.map +0 -1
- package/dist/read-outcome-BnboMYOV.d.ts +0 -30
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { S as StorageAdapter } from './types-DKcxHXxq.js';
|
|
2
|
+
import { b as ViewFilterValue, c as ViewFilterKind, d as ResolvedFilter, S as SegmentWhere } from './types-CBtBvGw0.js';
|
|
3
|
+
import { a as FilterParam } from './types-BnOCVJzm.js';
|
|
4
|
+
|
|
5
|
+
/** A segment's `where` as provider filters. A range keeps only the ends it has. */
|
|
6
|
+
declare function whereParams(where: SegmentWhere | null | undefined): FilterParam[];
|
|
7
|
+
/** Whether a filter value narrows anything (an empty choice or range doesn't). @stability Beta */
|
|
8
|
+
declare function isFilterSet(value: ViewFilterValue | undefined | null): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* A stored filter value in the shape its filter takes (a choice's list of strings, a range's ends,
|
|
11
|
+
* a text), or undefined when it isn't: a saved view from a server or edited by hand can't break a list.
|
|
12
|
+
*
|
|
13
|
+
* @stability Beta
|
|
14
|
+
*/
|
|
15
|
+
declare function filterValueFor(filter: Pick<ResolvedFilter, "kind">, value: unknown): ViewFilterValue | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Everything a person can change about a list, as plain data: what a saved view stores and what
|
|
18
|
+
* the URL keeps (ADR 0017 §4).
|
|
19
|
+
*
|
|
20
|
+
* @stability Beta
|
|
21
|
+
*/
|
|
22
|
+
interface ListState {
|
|
23
|
+
/** The segment's id. */
|
|
24
|
+
segment?: string;
|
|
25
|
+
/** Declared filters' values, by field. */
|
|
26
|
+
filters?: Readonly<Record<string, ViewFilterValue>>;
|
|
27
|
+
search?: string;
|
|
28
|
+
sort?: {
|
|
29
|
+
readonly field: string;
|
|
30
|
+
readonly order: "asc" | "desc";
|
|
31
|
+
};
|
|
32
|
+
/** A column preset. */
|
|
33
|
+
columns?: string;
|
|
34
|
+
/** The view type (`table`, `board`, a registered one). */
|
|
35
|
+
type?: string;
|
|
36
|
+
/** The field rows are grouped by, or `null` for none (over the view's own `groupBy`). */
|
|
37
|
+
groupBy?: string | null;
|
|
38
|
+
}
|
|
39
|
+
/** The URL keys a list's state uses beside `q`, `sort`, `page` and `id`. @stability Beta */
|
|
40
|
+
declare const LIST_URL_KEYS: Readonly<{
|
|
41
|
+
segment: "seg";
|
|
42
|
+
filterPrefix: "f.";
|
|
43
|
+
}>;
|
|
44
|
+
/** A filter value as one URL parameter: choices joined by commas, a range as `from..to`, text as is. */
|
|
45
|
+
declare function encodeFilterValue(value: ViewFilterValue): string;
|
|
46
|
+
/** One URL parameter as a declared filter's value, by its kind; undefined when it doesn't parse. */
|
|
47
|
+
declare function decodeFilterValue(kind: ViewFilterKind, raw: string): ViewFilterValue | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* A list's segment and declared filters from URL parameters. Only declared filters and defined
|
|
50
|
+
* segments are read; anything else is ignored.
|
|
51
|
+
*
|
|
52
|
+
* @stability Beta
|
|
53
|
+
*/
|
|
54
|
+
declare function readListUrl(view: {
|
|
55
|
+
filters(): readonly ResolvedFilter[];
|
|
56
|
+
segments(): readonly {
|
|
57
|
+
id: string;
|
|
58
|
+
}[];
|
|
59
|
+
}, get: (key: string) => string | null | undefined): Pick<ListState, "segment" | "filters">;
|
|
60
|
+
/**
|
|
61
|
+
* The URL parameters a list's segment and declared filters set, `null` for each to remove: pass
|
|
62
|
+
* them to a router adapter's `setSearchParams`.
|
|
63
|
+
*
|
|
64
|
+
* @stability Beta
|
|
65
|
+
*/
|
|
66
|
+
declare function listUrlParams(view: {
|
|
67
|
+
filters(): readonly ResolvedFilter[];
|
|
68
|
+
segments(): readonly {
|
|
69
|
+
id: string;
|
|
70
|
+
}[];
|
|
71
|
+
}, state: Pick<ListState, "segment" | "filters">, defaultSegment?: string): Record<string, string | null>;
|
|
72
|
+
/** A value's words for a filter chip: its label, or the value in title case. */
|
|
73
|
+
declare function filterOptionLabel(filter: ResolvedFilter, value: string): string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* One saved view: a name, who it's for, and the list state it restores, stamped with the view's
|
|
77
|
+
* `version` when it was saved.
|
|
78
|
+
*
|
|
79
|
+
* @stability Beta
|
|
80
|
+
*/
|
|
81
|
+
interface SavedView {
|
|
82
|
+
readonly id: string;
|
|
83
|
+
readonly name: string;
|
|
84
|
+
/** `personal` (the person's own) or `team` (shared, as the app's store decides). */
|
|
85
|
+
readonly scope: "personal" | "team";
|
|
86
|
+
/** The view's resource. */
|
|
87
|
+
readonly resource: string;
|
|
88
|
+
/** The view's `version` when it was saved (1 when the view has none). */
|
|
89
|
+
readonly version: number;
|
|
90
|
+
readonly state: ListState;
|
|
91
|
+
}
|
|
92
|
+
/** A saved view to store: the store gives it its id. @stability Beta */
|
|
93
|
+
type SavedViewInput = Omit<SavedView, "id"> & {
|
|
94
|
+
readonly id?: string;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Where saved views live (ADR 0017 §4). Passed once to genesis-ui's `ResourceViewDefaultsProvider`
|
|
98
|
+
* (`savedViews`). Every method may be async. `readCurrent` and `writeCurrent`, when the store has
|
|
99
|
+
* them, keep each person's current choices for a list (its view type, say), so they follow the
|
|
100
|
+
* person the way saved views do.
|
|
101
|
+
*
|
|
102
|
+
* A store returns only the views the signed-in person may see: a server store scopes its rows to
|
|
103
|
+
* the viewer (row-level security on the app's table: their own personal views, and team views of
|
|
104
|
+
* their team). A store kept on a device that several people sign in to has `forViewer`, and lists
|
|
105
|
+
* call it with the viewer's id, so one person never sees another's views.
|
|
106
|
+
*
|
|
107
|
+
* @stability Beta
|
|
108
|
+
*/
|
|
109
|
+
interface SavedViewStore {
|
|
110
|
+
list(resource: string): readonly SavedView[] | Promise<readonly SavedView[]>;
|
|
111
|
+
save(view: SavedViewInput): SavedView | Promise<SavedView>;
|
|
112
|
+
remove(id: string, resource: string): void | Promise<void>;
|
|
113
|
+
/** Which scopes this store can save to. Default `["personal"]`. */
|
|
114
|
+
readonly scopes?: readonly ("personal" | "team")[];
|
|
115
|
+
/** The person's current state for a list (its key: the resource, or a screen's own key). */
|
|
116
|
+
readCurrent?(key: string): ListState | null | undefined | Promise<ListState | null | undefined>;
|
|
117
|
+
writeCurrent?(key: string, state: ListState): void | Promise<void>;
|
|
118
|
+
/** The store for one viewer (their id, or null signed out), for a store kept on a shared device. */
|
|
119
|
+
forViewer?(viewer: string | null): SavedViewStore;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The default saved-view store: this device only, personal views, under `<prefix>:<resource>`
|
|
123
|
+
* in the browser's localStorage (or the storage you pass, such as a phone's adapter). Without
|
|
124
|
+
* storage it keeps views in memory for the page's life. Lists use `forViewer(id)`, which keeps
|
|
125
|
+
* each person's views under `<prefix>:<viewer>:…`, so whoever signs in next on the device sees
|
|
126
|
+
* only their own.
|
|
127
|
+
*
|
|
128
|
+
* ```ts
|
|
129
|
+
* <ResourceViewDefaultsProvider savedViews={createLocalSavedViewStore()} />
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @stability Beta
|
|
133
|
+
*/
|
|
134
|
+
declare function createLocalSavedViewStore(options?: {
|
|
135
|
+
storage?: StorageAdapter;
|
|
136
|
+
prefix?: string;
|
|
137
|
+
}): SavedViewStore;
|
|
138
|
+
/**
|
|
139
|
+
* The part of a stored list state that still applies to a view: a segment it still has, filters
|
|
140
|
+
* it still declares, a column preset and view type it still offers, a field it can still group by.
|
|
141
|
+
* A saved view from an older `version` is offered as far as it applies, never refused whole.
|
|
142
|
+
*
|
|
143
|
+
* @stability Beta
|
|
144
|
+
*/
|
|
145
|
+
declare function applicableListState(view: {
|
|
146
|
+
filters(): readonly ResolvedFilter[];
|
|
147
|
+
segments(): readonly {
|
|
148
|
+
id: string;
|
|
149
|
+
}[];
|
|
150
|
+
presets: readonly string[];
|
|
151
|
+
types(): readonly string[];
|
|
152
|
+
field(name: string): unknown;
|
|
153
|
+
}, state: ListState | null | undefined): ListState;
|
|
154
|
+
|
|
155
|
+
export { type ListState as L, type SavedViewStore as S, LIST_URL_KEYS as a, type SavedView as b, type SavedViewInput as c, applicableListState as d, createLocalSavedViewStore as e, decodeFilterValue as f, encodeFilterValue as g, filterOptionLabel as h, filterValueFor as i, isFilterSet as j, listUrlParams as l, readListUrl as r, whereParams as w };
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export { D as
|
|
1
|
+
import { R as ResourceContract, c as Identifier, e as DataRow } from '../types-BnOCVJzm.js';
|
|
2
|
+
export { j as AuditEntry, q as ControlHint, v as FieldPermissions, f as FieldReference, F as FieldSchema, x as FilterOperator, P as ProviderCapabilities, O as RecordComment, Q as ResourceAccess, T as ResourceRelation, U as ResourceSchema, V as ResourceSummary, m as RowAction, l as RowOf, _ as StorageType, a1 as VersionField, a2 as WidgetHint, a3 as defineResource, a4 as fieldControl } from '../types-BnOCVJzm.js';
|
|
3
|
+
export { D as DataReadError, a as DataReadErrorOptions, b as DataWriteError, c as DataWriteErrorOptions, N as NO_ROWS_MATCHED, R as ReadOutcome, W as WriteOutcome, i as isDataReadError, d as isDataWriteError, r as readFailureMessage } from '../read-outcome-Cq0h2oAG.js';
|
|
4
4
|
export { W as WriteConflict, a as WriteConflictOptions, b as WriteState, w as writeConflict } from '../write-state-DVC4Yq9T.js';
|
|
5
|
-
export { D as DataReadError, a as DataReadErrorOptions, R as ReadOutcome, i as isDataReadError, r as readFailureMessage } from '../read-outcome-BnboMYOV.js';
|
|
6
5
|
|
|
7
6
|
/** The key of a contract as a list, whichever form `key` was declared in. */
|
|
8
7
|
declare function keyFields(contract: Pick<ResourceContract, "key">): readonly string[];
|
package/dist/schema/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { defineResource, fieldControl } from '../chunk-BNKP2H7J.js';
|
|
2
|
+
export { decodeRecordKey, encodeRecordKey, keyFields } from '../chunk-KV2HW4G4.js';
|
|
2
3
|
export { writeConflict } from '../chunk-LKRJB632.js';
|
|
3
4
|
export { DataReadError, isDataReadError, readFailureMessage } from '../chunk-HUNGCTRA.js';
|
|
4
5
|
export { DataWriteError, NO_ROWS_MATCHED, isDataWriteError } from '../chunk-WLDSIQJ2.js';
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import { c as Identifier, a as FilterParam, B as BaseRecord, I as InvalidationKey, W as WriteEvent, C as CountMode, D as DataProvider } from './types-BnOCVJzm.js';
|
|
2
|
+
import { D as DataReadError } from './read-outcome-Cq0h2oAG.js';
|
|
3
|
+
|
|
4
|
+
/** A chainable query builder returned by `client.from(table)`. */
|
|
5
|
+
interface SupabaseQueryBuilder {
|
|
6
|
+
select(columns?: string, options?: {
|
|
7
|
+
count?: "exact" | "planned" | "estimated";
|
|
8
|
+
}): SupabaseQueryBuilder;
|
|
9
|
+
insert(data: Record<string, unknown> | Record<string, unknown>[]): SupabaseQueryBuilder;
|
|
10
|
+
update(data: Record<string, unknown>): SupabaseQueryBuilder;
|
|
11
|
+
delete(): SupabaseQueryBuilder;
|
|
12
|
+
eq(column: string, value: unknown): SupabaseQueryBuilder;
|
|
13
|
+
neq(column: string, value: unknown): SupabaseQueryBuilder;
|
|
14
|
+
gt(column: string, value: unknown): SupabaseQueryBuilder;
|
|
15
|
+
lt(column: string, value: unknown): SupabaseQueryBuilder;
|
|
16
|
+
gte(column: string, value: unknown): SupabaseQueryBuilder;
|
|
17
|
+
lte(column: string, value: unknown): SupabaseQueryBuilder;
|
|
18
|
+
ilike(column: string, value: string): SupabaseQueryBuilder;
|
|
19
|
+
in(column: string, values: unknown[]): SupabaseQueryBuilder;
|
|
20
|
+
is(column: string, value: null): SupabaseQueryBuilder;
|
|
21
|
+
not(column: string, operator: string, value: unknown): SupabaseQueryBuilder;
|
|
22
|
+
or(filters: string): SupabaseQueryBuilder;
|
|
23
|
+
order(column: string, options?: {
|
|
24
|
+
ascending?: boolean;
|
|
25
|
+
nullsFirst?: boolean;
|
|
26
|
+
}): SupabaseQueryBuilder;
|
|
27
|
+
range(from: number, to: number): SupabaseQueryBuilder;
|
|
28
|
+
single(): SupabaseQueryBuilder;
|
|
29
|
+
then: Promise<{
|
|
30
|
+
data: unknown;
|
|
31
|
+
error: unknown;
|
|
32
|
+
count?: number | null;
|
|
33
|
+
}>["then"];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Minimal Supabase client interface — the public shape this package has
|
|
37
|
+
* always exposed for a caller that wants to type its own client or a
|
|
38
|
+
* wrapper around one. Unchanged: `from()` still returns `SupabaseQueryBuilder`
|
|
39
|
+
* so existing consumers that annotate a variable with this type and chain
|
|
40
|
+
* off it keep type-checking exactly as before.
|
|
41
|
+
*/
|
|
42
|
+
interface SupabaseClient {
|
|
43
|
+
from(table: string): SupabaseQueryBuilder;
|
|
44
|
+
/** Another schema's tables, for a resource named `schema.table` outside `public`. */
|
|
45
|
+
schema?(name: string): {
|
|
46
|
+
from(table: string): SupabaseQueryBuilder;
|
|
47
|
+
};
|
|
48
|
+
/** Supabase Realtime; needed only for `subscribe` (see `SupabaseProviderOptions.realtime`). */
|
|
49
|
+
channel?(name: string): SupabaseRealtimeChannel;
|
|
50
|
+
/** Releases a channel made by `channel()`. */
|
|
51
|
+
removeChannel?(channel: SupabaseRealtimeChannel): unknown;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* One `postgres_changes` message, as Supabase Realtime sends it. Only the
|
|
55
|
+
* fields the provider reads; a real payload has more.
|
|
56
|
+
*/
|
|
57
|
+
interface SupabaseRealtimePayload {
|
|
58
|
+
eventType: "INSERT" | "UPDATE" | "DELETE";
|
|
59
|
+
/** The row after an insert or update (empty for a delete). */
|
|
60
|
+
new?: Record<string, unknown>;
|
|
61
|
+
/** For a delete or update: the old row's key (all of it with `REPLICA IDENTITY FULL`). */
|
|
62
|
+
old?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The part of a Supabase `RealtimeChannel` the provider uses. A real
|
|
66
|
+
* `@supabase/supabase-js` channel satisfies it.
|
|
67
|
+
*/
|
|
68
|
+
interface SupabaseRealtimeChannel {
|
|
69
|
+
on(type: "postgres_changes", filter: {
|
|
70
|
+
event: "*" | "INSERT" | "UPDATE" | "DELETE";
|
|
71
|
+
schema: string;
|
|
72
|
+
table: string;
|
|
73
|
+
filter?: string;
|
|
74
|
+
}, callback: (payload: SupabaseRealtimePayload) => void): SupabaseRealtimeChannel;
|
|
75
|
+
subscribe(callback?: (status: string, error?: unknown) => void): SupabaseRealtimeChannel;
|
|
76
|
+
unsubscribe?(): unknown;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* What `createSupabaseProvider` actually requires from its `client` argument
|
|
80
|
+
* — deliberately looser than the public `SupabaseClient` above, and used
|
|
81
|
+
* ONLY for that one parameter. A real `@supabase/supabase-js` client's
|
|
82
|
+
* `from()` returns a generic, table-typed `PostgrestQueryBuilder` whose chain
|
|
83
|
+
* methods don't structurally match `SupabaseQueryBuilder`, which used to
|
|
84
|
+
* force callers to pass their client through `as never`. Since `unknown` is
|
|
85
|
+
* a supertype of everything, any real client's `from(table: string)`
|
|
86
|
+
* satisfies THIS shape without a cast; `createSupabaseProvider` narrows to
|
|
87
|
+
* `SupabaseQueryBuilder` internally, once, right after each `from()` call.
|
|
88
|
+
* Loosening only the input here — rather than `SupabaseClient` itself —
|
|
89
|
+
* means a caller relying on `SupabaseClient`'s stricter return type for
|
|
90
|
+
* their own chaining is unaffected.
|
|
91
|
+
*/
|
|
92
|
+
interface SupabaseClientInput {
|
|
93
|
+
from(table: string): unknown;
|
|
94
|
+
/** Another schema's tables, for a resource named `schema.table` outside `public`. Any real client's `schema` fits. */
|
|
95
|
+
schema?(name: string): {
|
|
96
|
+
from(table: string): unknown;
|
|
97
|
+
};
|
|
98
|
+
/** Database functions, for a resource whose `source` is an `rpc`. Any real client's `rpc` fits. */
|
|
99
|
+
rpc?(fn: string, args?: Record<string, unknown>, options?: {
|
|
100
|
+
count?: "exact" | "planned" | "estimated";
|
|
101
|
+
}): unknown;
|
|
102
|
+
/** Supabase Realtime, for `subscribe`. Any real client's `channel` fits. */
|
|
103
|
+
channel?(name: string): unknown;
|
|
104
|
+
removeChannel?(channel: unknown): unknown;
|
|
105
|
+
}
|
|
106
|
+
/** What a write hook is told about the write it is part of. */
|
|
107
|
+
interface SupabaseWriteContext {
|
|
108
|
+
resource: string;
|
|
109
|
+
action: "create" | "update";
|
|
110
|
+
/** The row's id, for an update. */
|
|
111
|
+
id?: Identifier;
|
|
112
|
+
}
|
|
113
|
+
/** What an `update` override is told besides the row. */
|
|
114
|
+
interface SupabaseUpdateContext {
|
|
115
|
+
/**
|
|
116
|
+
* With a `version` rule and an `expectedVersion` from the caller: the
|
|
117
|
+
* version the row must still be at. The override must apply the change
|
|
118
|
+
* only at that version (e.g. `... where id = $1 and version = $2`) and
|
|
119
|
+
* return nothing when no row matched; the provider then tells a
|
|
120
|
+
* `conflict` from `forbidden` and `gone`.
|
|
121
|
+
*/
|
|
122
|
+
expectedVersion?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A function source that pages itself (`SupabaseResourceConfig.source`'s `pages`): the order its
|
|
126
|
+
* rows come in, and the column that carries the whole result's count. A count alone asks the
|
|
127
|
+
* function for `page_limit: 0`, which it answers with one row that carries the count (and builds
|
|
128
|
+
* no other row).
|
|
129
|
+
*
|
|
130
|
+
* @stability Beta
|
|
131
|
+
*/
|
|
132
|
+
interface SourcePages {
|
|
133
|
+
readonly order?: readonly {
|
|
134
|
+
field: string;
|
|
135
|
+
order: "asc" | "desc";
|
|
136
|
+
}[];
|
|
137
|
+
readonly total?: string;
|
|
138
|
+
}
|
|
139
|
+
/** Per-resource rules for `createSupabaseProvider`. Every field is optional. */
|
|
140
|
+
/**
|
|
141
|
+
* What a function source's `args` gets (`SupabaseResourceConfig.source`): the list's filters,
|
|
142
|
+
* which carry the viewer's scope, and `take`, which reads one equality filter's value (`null` for
|
|
143
|
+
* "is empty") and keeps that filter out of the query.
|
|
144
|
+
*
|
|
145
|
+
* @stability Beta
|
|
146
|
+
*/
|
|
147
|
+
interface SourceArgsContext {
|
|
148
|
+
readonly resource: string;
|
|
149
|
+
readonly filters: readonly FilterParam[];
|
|
150
|
+
take(field: string): string | number | boolean | null | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* The values of a filter on `field` that an `in` (or an `eq`, as one value) gives, taken out of
|
|
153
|
+
* the query like `take`; undefined when there's none. For a function that filters by a list.
|
|
154
|
+
*/
|
|
155
|
+
takeIn(field: string): readonly unknown[] | undefined;
|
|
156
|
+
}
|
|
157
|
+
interface SupabaseResourceConfig {
|
|
158
|
+
/** Singular noun for failure messages, e.g. "project". Defaults to "record". */
|
|
159
|
+
noun?: string;
|
|
160
|
+
/** Plural for list messages, when it isn't `noun` + "s" ("categories"). */
|
|
161
|
+
nounPlural?: string;
|
|
162
|
+
/**
|
|
163
|
+
* The columns a search covers. `[]` means the resource can't be searched,
|
|
164
|
+
* and `capabilities(resource).search` reports false so a UI hides the box.
|
|
165
|
+
* Set, they replace the caller's `search.fields`; omitted, those are used
|
|
166
|
+
* as given.
|
|
167
|
+
*/
|
|
168
|
+
searchFields?: readonly string[];
|
|
169
|
+
/**
|
|
170
|
+
* The column a sorted list orders by last, so rows with equal sort values
|
|
171
|
+
* keep one order from page to page (none repeats, none is skipped).
|
|
172
|
+
* Default `"id"`; `false` for a table or view without one. With the
|
|
173
|
+
* default, a view that turns out to have no `id` column is read as before
|
|
174
|
+
* (without the key order) and a development warning suggests setting this.
|
|
175
|
+
*/
|
|
176
|
+
orderKey?: string | false;
|
|
177
|
+
/**
|
|
178
|
+
* `"bin"` for a table whose delete trigger moves the row to a recycle bin
|
|
179
|
+
* instead of removing it (see `SupabaseProviderOptions.binTables`).
|
|
180
|
+
* `"hard"` forces a plain delete even when `binTables` lists the table.
|
|
181
|
+
*/
|
|
182
|
+
deleteMode?: "hard" | "bin";
|
|
183
|
+
/**
|
|
184
|
+
* Turns submitted values into the row to write: trim, drop read-only keys,
|
|
185
|
+
* validate. Runs before every create and update, including the `create`
|
|
186
|
+
* and `update` overrides. Throw (ideally `DataWriteError("invalid", ...)`)
|
|
187
|
+
* to refuse the write; nothing is sent.
|
|
188
|
+
*/
|
|
189
|
+
prepare?: (values: Record<string, unknown>, context: SupabaseWriteContext) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
190
|
+
/**
|
|
191
|
+
* Creates the row some other way than an insert, e.g. a security-definer
|
|
192
|
+
* RPC. Return the new row, or its id and the provider reads the row back
|
|
193
|
+
* (if the read-back fails, the create is still reported as saved, with
|
|
194
|
+
* just the id, so the user does not retry and make a second one). Throw to
|
|
195
|
+
* fail; a Supabase `{ message, code }` error is mapped like any other.
|
|
196
|
+
*/
|
|
197
|
+
create?: (row: Record<string, unknown>) => Promise<BaseRecord | Identifier>;
|
|
198
|
+
/**
|
|
199
|
+
* Updates the row some other way than an update, e.g. an RPC. Return the
|
|
200
|
+
* updated row, or its id (or `true`) and the provider reads it back.
|
|
201
|
+
* Returning nothing (`undefined`/`null`/`false`) means no row changed: the provider then reads the
|
|
202
|
+
* row to say why (`forbidden` or `gone`), exactly as for a plain update,
|
|
203
|
+
* so a function that silently skips a row never reports a save.
|
|
204
|
+
*/
|
|
205
|
+
update?: (id: Identifier, row: Record<string, unknown>, context?: SupabaseUpdateContext) => Promise<BaseRecord | Identifier | boolean | null | undefined | void>;
|
|
206
|
+
/**
|
|
207
|
+
* The column every update and delete of this resource is checked against,
|
|
208
|
+
* so an edit made on a stale copy is refused as a `conflict` instead of
|
|
209
|
+
* overwriting someone else's (`UpdateParams.expectedVersion`).
|
|
210
|
+
*
|
|
211
|
+
* The database must advance it on every update, or it detects nothing:
|
|
212
|
+
* `integer` with genesis-supabase's `genesis_version_bump` trigger
|
|
213
|
+
* (migration 0019), or `timestamp` with a trigger that sets it to `now()`
|
|
214
|
+
* on update (`moddatetime`). The provider never writes it: a submitted
|
|
215
|
+
* value is dropped. Writes without an `expectedVersion` are not checked,
|
|
216
|
+
* so turning this on changes nothing for callers that don't send one.
|
|
217
|
+
*/
|
|
218
|
+
version?: {
|
|
219
|
+
field: string;
|
|
220
|
+
kind: "integer" | "timestamp";
|
|
221
|
+
};
|
|
222
|
+
/** Maps a stored row to edit-form values; see `DataProvider.toFormValues`. */
|
|
223
|
+
toFormValues?: (record: Record<string, unknown>) => Record<string, unknown>;
|
|
224
|
+
/**
|
|
225
|
+
* Other cache keys a committed write to this resource makes stale, e.g.
|
|
226
|
+
* `[["staff"], ["me"]]`. Served through `DataProvider.invalidates`, which
|
|
227
|
+
* `useResource` and `useResourceForm` invalidate after their writes.
|
|
228
|
+
*/
|
|
229
|
+
invalidates?: InvalidationKey[] | ((event: WriteEvent) => InvalidationKey[]);
|
|
230
|
+
/**
|
|
231
|
+
* Serve `subscribe` for this resource through Supabase Realtime
|
|
232
|
+
* (`postgres_changes`), so `live` lists and records refresh when the table
|
|
233
|
+
* changes. The table must be in the `supabase_realtime` publication, with
|
|
234
|
+
* RLS on. `false` turns it off even when `SupabaseProviderOptions.realtime`
|
|
235
|
+
* covers the resource.
|
|
236
|
+
*/
|
|
237
|
+
realtime?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Read this resource from somewhere else than its table: a view (joins,
|
|
240
|
+
* counts, aggregations) or a database function that returns rows. Writes
|
|
241
|
+
* still go to the table. Lists keep paging, filters, search, sort, totals
|
|
242
|
+
* and cursors, because PostgREST filters a view or a set-returning function
|
|
243
|
+
* like a table. Realtime still watches the table.
|
|
244
|
+
*
|
|
245
|
+
* Row-level security: a plain view runs as its owner and a SECURITY DEFINER
|
|
246
|
+
* function as its definer, so either one reads past RLS. Create the view
|
|
247
|
+
* `with (security_invoker = true)` and the function `security invoker` (or
|
|
248
|
+
* have it filter by `auth.uid()` itself), or this exposes every row.
|
|
249
|
+
*
|
|
250
|
+
* ```ts
|
|
251
|
+
* resources: {
|
|
252
|
+
* tasks: { source: "tasks_with_people" },
|
|
253
|
+
* course_progress: { source: { rpc: "group_progress", args: ({ take }) => ({ group_id: take("group_id") }) } },
|
|
254
|
+
* }
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* A function's `args` gets the list's filters (`context.filters`), which hold the viewer's scope
|
|
258
|
+
* as ResourceView applies it (a view's `scope: ["group_id"]` filters `group_id`), so a function
|
|
259
|
+
* that takes its scope as an argument reads it there rather than from a module variable.
|
|
260
|
+
* `context.take(field)` returns an equality filter's value and leaves that filter out of the
|
|
261
|
+
* query, for a scope the function takes as an argument and doesn't return as a column. A record
|
|
262
|
+
* read (`getOne`, `getMany`) gets the list's filters from `scope` (less a text search's
|
|
263
|
+
* `contains`, which `useOne` leaves out) when the caller passes them
|
|
264
|
+
* (`useOne`'s `scope`, which ResourceView's table, inbox and NativeResourceView's peek and
|
|
265
|
+
* edit sheet pass for a record off the loaded page), else none, and
|
|
266
|
+
* the function's own default scope applies.
|
|
267
|
+
*
|
|
268
|
+
* A function that pages itself declares `pages`: it takes `page_limit` and `page_offset`
|
|
269
|
+
* arguments, returns its rows in `pages.order` (newest first, say) and carries the whole
|
|
270
|
+
* result's count on each row (`pages.total`, default `total_count`). A list page whose filters
|
|
271
|
+
* the function all took, with no search and no sort other than `pages.order`, then passes the
|
|
272
|
+
* page to the function instead of a `range`, and reads its total from that column, so the
|
|
273
|
+
* function never builds rows outside the page. A count alone (a segment's) sends
|
|
274
|
+
* `page_limit: 0`: the function returns one row carrying the count, and builds no other. Any other list reads every row, as without
|
|
275
|
+
* `pages`, since PostgREST can only filter, search or sort what the function returned.
|
|
276
|
+
*/
|
|
277
|
+
source?: string | {
|
|
278
|
+
rpc: string;
|
|
279
|
+
args?: (context: SourceArgsContext) => Record<string, unknown>;
|
|
280
|
+
pages?: SourcePages;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* How lists of this resource count their total (default `exact`). Use
|
|
284
|
+
* `estimated` for large tables, or `none` when no screen shows a count.
|
|
285
|
+
*/
|
|
286
|
+
count?: CountMode;
|
|
287
|
+
/** The columns read when the caller names none, e.g. embedded joins: `"*, person:people(full_name)"`. Default `"*"`. */
|
|
288
|
+
select?: string;
|
|
289
|
+
/**
|
|
290
|
+
* With a `source` (or a `select` that embeds other tables), the table's own
|
|
291
|
+
* columns: creates and updates write only these, so a form built from the
|
|
292
|
+
* richer read row never sends its joined or computed columns to the table.
|
|
293
|
+
* Without it, an update writes only the columns the table's row has, read from the table. On a
|
|
294
|
+
* provider with `access: "declared"` that read needs `table.read`: without it and without
|
|
295
|
+
* `writeColumns`, a table update over a `source` is refused, and an app `update` rule gets the
|
|
296
|
+
* values as sent. Write functions (`writes`) always get the values as sent: they decide what
|
|
297
|
+
* to write.
|
|
298
|
+
*/
|
|
299
|
+
writeColumns?: readonly string[];
|
|
300
|
+
/**
|
|
301
|
+
* The named database functions this resource writes through: the default pattern
|
|
302
|
+
* (docs/DATA-ACCESS.md). Each is a function name, called with the default arguments, or
|
|
303
|
+
* `{ fn, args }` to name the arguments yourself:
|
|
304
|
+
*
|
|
305
|
+
* - `create`: `{ p_values }` (the prepared row, as jsonb). Returns the new id, or the new row.
|
|
306
|
+
* - `update`: `{ p_id, p_values }`, plus `p_expected_version` when the caller sent a version
|
|
307
|
+
* for a resource with a `version` rule. Returns the id (or `true`, or the row) when a row
|
|
308
|
+
* changed and nothing (null) when none did; the provider then reads the row to say why
|
|
309
|
+
* (`conflict`, `forbidden` or `gone`).
|
|
310
|
+
* - `delete`: `{ p_id }`, plus `p_expected_version` as for `update`. Returns the id (or `true`)
|
|
311
|
+
* when a row went, nothing when none did.
|
|
312
|
+
*
|
|
313
|
+
* The function holds the access rule (who may do this), so each one gets an access-rule test
|
|
314
|
+
* (`accessRules` from `@marktiderman/genesis-core/testing`). After a create or update the
|
|
315
|
+
* provider reads the record back through the resource's read (`source`), never `select *` on the
|
|
316
|
+
* table, so a write never asks for a column the client may not read.
|
|
317
|
+
*
|
|
318
|
+
* ```ts
|
|
319
|
+
* resources: {
|
|
320
|
+
* tasks: {
|
|
321
|
+
* source: "tasks_with_people",
|
|
322
|
+
* writes: { create: "create_task", update: "save_task", delete: "delete_task" },
|
|
323
|
+
* },
|
|
324
|
+
* }
|
|
325
|
+
* ```
|
|
326
|
+
*
|
|
327
|
+
* A `create` or `update` rule (above) wins over the matching `writes` entry.
|
|
328
|
+
*/
|
|
329
|
+
writes?: ResourceWrites;
|
|
330
|
+
/**
|
|
331
|
+
* Named row actions, served by `runAction`: each a database function called with `{ p_id }`
|
|
332
|
+
* (plus `p_expected_version` as for `writes.update`), or `{ fn, args }`. It returns the changed
|
|
333
|
+
* row, its id or `true` when it acted, and nothing when no row matched.
|
|
334
|
+
*/
|
|
335
|
+
actions?: Readonly<Record<string, FunctionCall<[id: Identifier, context: SupabaseUpdateContext]>>>;
|
|
336
|
+
/**
|
|
337
|
+
* Raw table access, declared: the reads or writes this resource does on its table itself
|
|
338
|
+
* instead of through a view or a named function, and why. With the provider's
|
|
339
|
+
* `access: "declared"`, a read with no `source` and a write with no `writes` entry (nor a
|
|
340
|
+
* `create`/`update` rule) is refused unless this covers it. The doctor's `data/declared-access`
|
|
341
|
+
* rule reports a provider that doesn't declare its access.
|
|
342
|
+
*/
|
|
343
|
+
table?: TableAccess;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* A database function a resource calls: its name (called with the documented default arguments),
|
|
347
|
+
* or `{ fn, args }` naming the arguments yourself.
|
|
348
|
+
*
|
|
349
|
+
* @stability Beta
|
|
350
|
+
*/
|
|
351
|
+
type FunctionCall<A extends unknown[]> = string | {
|
|
352
|
+
readonly fn: string;
|
|
353
|
+
readonly args?: (...input: A) => Record<string, unknown>;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* The named functions a resource writes through (`SupabaseResourceConfig.writes`).
|
|
357
|
+
*
|
|
358
|
+
* @stability Beta
|
|
359
|
+
*/
|
|
360
|
+
interface ResourceWrites {
|
|
361
|
+
readonly create?: FunctionCall<[values: Record<string, unknown>]>;
|
|
362
|
+
readonly update?: FunctionCall<[id: Identifier, values: Record<string, unknown>, context: SupabaseUpdateContext]>;
|
|
363
|
+
readonly delete?: FunctionCall<[id: Identifier, context: SupabaseUpdateContext]>;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* A declared opt-in to raw table access (`SupabaseResourceConfig.table`). `why` is required: it is
|
|
367
|
+
* what a reviewer reads to accept the exception.
|
|
368
|
+
*
|
|
369
|
+
* @stability Beta
|
|
370
|
+
*/
|
|
371
|
+
interface TableAccess {
|
|
372
|
+
/** Read the table itself (the resource has no `source`). */
|
|
373
|
+
readonly read?: boolean;
|
|
374
|
+
/** Write the table itself: every write (`true`) or the ones listed. */
|
|
375
|
+
readonly write?: boolean | readonly ("create" | "update" | "delete")[];
|
|
376
|
+
/** Why this resource goes to its table rather than a view or a named function. */
|
|
377
|
+
readonly why: string;
|
|
378
|
+
}
|
|
379
|
+
/** Options for `createSupabaseProvider`. All optional; none changes reads. */
|
|
380
|
+
interface SupabaseProviderOptions {
|
|
381
|
+
/**
|
|
382
|
+
* Recycle-bin tables: their delete trigger turns a delete into a "binned"
|
|
383
|
+
* mark and the binned row drops out of the caller's view (RLS or a view
|
|
384
|
+
* filter). The database reports such a delete as zero rows, so for these
|
|
385
|
+
* the provider checks the row is visible, deletes it, and reads it back:
|
|
386
|
+
* gone from view is success, still visible is `forbidden`. A row that was
|
|
387
|
+
* not visible beforehand is `gone`. A list matches a `public` table under
|
|
388
|
+
* either spelling; a test is asked once, with the name as the caller gives it.
|
|
389
|
+
*/
|
|
390
|
+
binTables?: readonly string[] | ((resource: string) => boolean);
|
|
391
|
+
/**
|
|
392
|
+
* Per-resource rules, keyed by resource name. A `public` resource may be keyed either way
|
|
393
|
+
* (`goals` or `public.goals`). The key spelled exactly as the caller names the resource wins;
|
|
394
|
+
* the other spelling is used only when that key is absent. Rules are never merged.
|
|
395
|
+
*/
|
|
396
|
+
resources?: Record<string, SupabaseResourceConfig>;
|
|
397
|
+
/**
|
|
398
|
+
* Called after every committed create, update and delete, e.g. to
|
|
399
|
+
* invalidate caches the Genesis hooks don't know about. Awaited, but a
|
|
400
|
+
* failure is logged and never turns a committed write into a failed one.
|
|
401
|
+
*/
|
|
402
|
+
onWrite?: (event: WriteEvent) => void | Promise<void>;
|
|
403
|
+
/**
|
|
404
|
+
* The most rows one list page may ask for (PostgREST's `max-rows` caps
|
|
405
|
+
* reads anyway; default 1000). A larger request is refused with an
|
|
406
|
+
* `invalid` `DataReadError` (its `cause` says why) rather than cut short,
|
|
407
|
+
* so page boundaries never disagree with the caller's `perPage`.
|
|
408
|
+
* `capabilities().maxPerPage` reports it.
|
|
409
|
+
*/
|
|
410
|
+
maxPerPage?: number;
|
|
411
|
+
/**
|
|
412
|
+
* Called with every failed read, before it is thrown. The thrown
|
|
413
|
+
* `DataReadError` carries a plain message for users; the store's own
|
|
414
|
+
* error (its raw text and code) is its `cause`, for logging here.
|
|
415
|
+
*/
|
|
416
|
+
onReadError?: (error: DataReadError, context: {
|
|
417
|
+
resource: string;
|
|
418
|
+
operation: "getList" | "getOne" | "getMany";
|
|
419
|
+
}) => void | Promise<void>;
|
|
420
|
+
/**
|
|
421
|
+
* Which resources `subscribe` serves through Supabase Realtime: `true` for
|
|
422
|
+
* all, a list of names, or a test. Off by default; a resource's own
|
|
423
|
+
* `resources[name].realtime` wins. Needs a client with `channel()` (any
|
|
424
|
+
* `@supabase/supabase-js` client). A list matches a `public` resource
|
|
425
|
+
* under either spelling; a test is asked once, with the name as the caller
|
|
426
|
+
* gives it.
|
|
427
|
+
*/
|
|
428
|
+
realtime?: boolean | readonly string[] | ((resource: string) => boolean);
|
|
429
|
+
/**
|
|
430
|
+
* Work out `sum`, `avg`, `min` and `max` in the database with PostgREST's aggregate functions
|
|
431
|
+
* (`amount.sum()`), which a project turns on with `pgrst.db_aggregates_enabled`. Off by
|
|
432
|
+
* default: `aggregate` then counts in the database and totals the other metrics from the
|
|
433
|
+
* rows, paged (`resolveAggregate`, up to 10 000 rows). A count is always the database's.
|
|
434
|
+
*/
|
|
435
|
+
aggregateFunctions?: boolean;
|
|
436
|
+
/**
|
|
437
|
+
* `"declared"`: every resource says how it is read and written (docs/DATA-ACCESS.md). Reads go
|
|
438
|
+
* through its `source` (a view or a function) and writes through its `writes` functions (or a
|
|
439
|
+
* `create`/`update` rule); touching the table itself needs a declared `table` opt-in. Anything
|
|
440
|
+
* else, a resource missing from `resources` included, is refused with a message that names what
|
|
441
|
+
* to declare. `"open"` (the default): an undeclared resource reads and writes its table, as
|
|
442
|
+
* before. The doctor's `data/declared-access` rule reports a provider left open.
|
|
443
|
+
*/
|
|
444
|
+
access?: "declared" | "open";
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* The Supabase data provider. Reads and writes go through the client you
|
|
448
|
+
* pass, under that client's session and RLS.
|
|
449
|
+
*
|
|
450
|
+
* Writes never report a save that did not happen:
|
|
451
|
+
* - `update` and `deleteOne` ask for the affected rows. Zero rows is a
|
|
452
|
+
* `DataWriteError`: the row is read back, and still visible means
|
|
453
|
+
* `forbidden` (RLS or a trigger refused the change), no longer visible
|
|
454
|
+
* means `gone`.
|
|
455
|
+
* - Database errors on writes are thrown as `DataWriteError` with the
|
|
456
|
+
* outcome their code means (`writeOutcomeFromCode`) and the code kept on
|
|
457
|
+
* `error.code`.
|
|
458
|
+
* - Recycle-bin tables (`binTables`) succeed when the row leaves the
|
|
459
|
+
* caller's view.
|
|
460
|
+
*
|
|
461
|
+
* Reads are unchanged: errors are thrown as an `Error` carrying `code`.
|
|
462
|
+
*/
|
|
463
|
+
declare function createSupabaseProvider(client: SupabaseClientInput, options?: SupabaseProviderOptions): DataProvider;
|
|
464
|
+
|
|
465
|
+
export { type FunctionCall as F, type ResourceWrites as R, type SourceArgsContext as S, type TableAccess as T, type SourcePages as a, type SupabaseClient as b, type SupabaseClientInput as c, type SupabaseProviderOptions as d, type SupabaseRealtimeChannel as e, type SupabaseRealtimePayload as f, type SupabaseResourceConfig as g, type SupabaseUpdateContext as h, type SupabaseWriteContext as i, createSupabaseProvider as j };
|