@marktiderman/genesis-core 2.10.0 → 2.12.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 +191 -1
- package/dist/{chunk-LGTXQTHA.js → chunk-2VJQVAJD.js} +3 -3
- package/dist/{chunk-LGTXQTHA.js.map → chunk-2VJQVAJD.js.map} +1 -1
- package/dist/chunk-2WS4LGYU.js +47 -0
- package/dist/chunk-2WS4LGYU.js.map +1 -0
- package/dist/{chunk-KXVDDDJY.js → chunk-3B5O36DU.js} +105 -13
- package/dist/chunk-3B5O36DU.js.map +1 -0
- package/dist/{chunk-EHFYSJJA.js → chunk-42QPCDQF.js} +3 -3
- package/dist/{chunk-EHFYSJJA.js.map → chunk-42QPCDQF.js.map} +1 -1
- package/dist/{chunk-RK365SO2.js → chunk-C62CMLWG.js} +8 -5
- package/dist/chunk-C62CMLWG.js.map +1 -0
- package/dist/chunk-HYYTAJBG.js +85 -0
- package/dist/chunk-HYYTAJBG.js.map +1 -0
- package/dist/{chunk-4ZR7472O.js → chunk-LOJGHR5O.js} +4 -4
- package/dist/{chunk-4ZR7472O.js.map → chunk-LOJGHR5O.js.map} +1 -1
- package/dist/{chunk-ON2V4RXX.js → chunk-OC4OGB2K.js} +19 -11
- package/dist/chunk-OC4OGB2K.js.map +1 -0
- package/dist/{chunk-HQAVDVIH.js → chunk-POMTRNAL.js} +4 -4
- package/dist/{chunk-HQAVDVIH.js.map → chunk-POMTRNAL.js.map} +1 -1
- package/dist/{chunk-VDEW4AOS.js → chunk-PSFKIG27.js} +55 -6
- package/dist/chunk-PSFKIG27.js.map +1 -0
- package/dist/{chunk-37RWGNIO.js → chunk-VFT6QKZW.js} +114 -5
- package/dist/chunk-VFT6QKZW.js.map +1 -0
- package/dist/{chunk-VDS6REM3.js → chunk-VJGU6E4U.js} +5 -5
- package/dist/{chunk-VDS6REM3.js.map → chunk-VJGU6E4U.js.map} +1 -1
- package/dist/{chunk-ZCE3CHPX.js → chunk-XVRIWP7B.js} +3 -3
- package/dist/{chunk-ZCE3CHPX.js.map → chunk-XVRIWP7B.js.map} +1 -1
- package/dist/{chunk-7FVTGKTX.js → chunk-YDMKMNDS.js} +2 -2
- package/dist/{chunk-7FVTGKTX.js.map → chunk-YDMKMNDS.js.map} +1 -1
- package/dist/{chunk-6WV6ST67.js → chunk-YNXLPOAB.js} +97 -10
- package/dist/chunk-YNXLPOAB.js.map +1 -0
- package/dist/{chunk-7GW3QR63.js → chunk-ZHC3MDCS.js} +101 -18
- package/dist/chunk-ZHC3MDCS.js.map +1 -0
- package/dist/conversation/index.d.ts +195 -0
- package/dist/conversation/index.js +110 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/csv.d.ts +1 -1
- package/dist/errors.js +1 -2
- package/dist/form-types.d.ts +1 -1
- package/dist/gallery/index.d.ts +79 -0
- package/dist/gallery/index.js +64 -0
- package/dist/gallery/index.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -4
- package/dist/hooks/index.js +19 -18
- package/dist/hooks/mutation-mode.d.ts +29 -2
- package/dist/hooks/mutation-mode.js +9 -4
- package/dist/hooks/related-keys.d.ts +1 -1
- 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 +4 -4
- package/dist/hooks/use-link-options.d.ts +1 -1
- package/dist/hooks/use-link-options.js +6 -6
- package/dist/hooks/use-live.d.ts +1 -1
- package/dist/hooks/use-live.js +3 -3
- package/dist/hooks/use-one.d.ts +1 -1
- package/dist/hooks/use-one.js +4 -4
- package/dist/hooks/use-persisted-ui-state.d.ts +12 -0
- package/dist/hooks/use-persisted-ui-state.js +5 -0
- package/dist/hooks/use-persisted-ui-state.js.map +1 -0
- 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 +14 -1
- package/dist/hooks/use-resource-form.js +12 -9
- package/dist/hooks/use-resource.d.ts +17 -3
- package/dist/hooks/use-resource.js +12 -8
- package/dist/hooks/use-write.d.ts +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.js +22 -21
- package/dist/offline/index.d.ts +84 -0
- package/dist/offline/index.js +413 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/provider/index.d.ts +60 -7
- package/dist/provider/index.js +3 -3
- package/dist/resource-view/index.d.ts +79 -4
- package/dist/resource-view/index.js +141 -19
- package/dist/resource-view/index.js.map +1 -1
- package/dist/schema/index.d.ts +4 -3
- package/dist/schema/index.js +2 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/{types-9WnGxZhj.d.ts → types-BzLv8yOm.d.ts} +8 -0
- package/dist/types-CsKSAKqs.d.ts +143 -0
- package/dist/{viewer-scope-bthEYSOB.d.ts → viewer-scope-Dx0N9AYk.d.ts} +3 -2
- package/dist/workspaces.d.ts +1 -1
- package/dist/{write-outcome-ZWlhhzRW.d.ts → write-outcome-DC5hORz-.d.ts} +1 -1
- package/dist/write-state-DVC4Yq9T.d.ts +58 -0
- package/package.json +15 -2
- package/dist/chunk-37RWGNIO.js.map +0 -1
- package/dist/chunk-6WV6ST67.js.map +0 -1
- package/dist/chunk-7GW3QR63.js.map +0 -1
- package/dist/chunk-KXVDDDJY.js.map +0 -1
- package/dist/chunk-ON2V4RXX.js.map +0 -1
- package/dist/chunk-PA6WJE5E.js +0 -115
- package/dist/chunk-PA6WJE5E.js.map +0 -1
- package/dist/chunk-RK365SO2.js.map +0 -1
- package/dist/chunk-VDEW4AOS.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
-
import { b as Identifier, B as BaseRecord, D as DataProvider, c as AuditEntry } from '../types-
|
|
2
|
+
import { b as Identifier, B as BaseRecord, D as DataProvider, c as AuditEntry } from '../types-BzLv8yOm.js';
|
|
3
3
|
|
|
4
4
|
type MutationMode = "pessimistic" | "optimistic" | "undoable";
|
|
5
5
|
/** How long an `undoable` write waits for an undo before it is sent. */
|
|
@@ -73,6 +73,16 @@ interface SendContext {
|
|
|
73
73
|
data?: Record<string, unknown>;
|
|
74
74
|
/** The page is unloading: pass `keepalive: true` to the provider. */
|
|
75
75
|
keepalive: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* The version of the row this write was made on (`base`, else the cached
|
|
78
|
+
* row when the write was made), or, for a write made behind another on the
|
|
79
|
+
* same record, the version that one committed at. The field is the one the
|
|
80
|
+
* provider's capabilities name (`version`). Pass it as `expectedVersion`, so
|
|
81
|
+
* a write made on a stale copy is refused as a `conflict`. Undefined when
|
|
82
|
+
* the resource has no version or the row isn't known: send the write
|
|
83
|
+
* unchecked, as before.
|
|
84
|
+
*/
|
|
85
|
+
expectedVersion?: string;
|
|
76
86
|
}
|
|
77
87
|
interface ExecuteWriteArgs<R extends BaseRecord | void> {
|
|
78
88
|
queryClient: QueryClient;
|
|
@@ -85,6 +95,18 @@ interface ExecuteWriteArgs<R extends BaseRecord | void> {
|
|
|
85
95
|
* nothing, e.g. when the values are form-shaped and the row is not.
|
|
86
96
|
*/
|
|
87
97
|
data?: Record<string, unknown>;
|
|
98
|
+
/**
|
|
99
|
+
* The row as the person saw it when they made this change (an edit form's
|
|
100
|
+
* loaded record). Its version is what the write is checked against.
|
|
101
|
+
* Defaults to the cached row at the moment `executeWrite` is called.
|
|
102
|
+
*/
|
|
103
|
+
base?: BaseRecord;
|
|
104
|
+
/**
|
|
105
|
+
* The version to check this write against, overriding `base` and the
|
|
106
|
+
* cache: "keep mine" after a conflict sends at the version the conflict
|
|
107
|
+
* reported (`WriteConflict.currentVersion`).
|
|
108
|
+
*/
|
|
109
|
+
expectedVersion?: string;
|
|
88
110
|
mode: MutationMode;
|
|
89
111
|
undoDelayMs?: number;
|
|
90
112
|
onUndoable?: (write: UndoableWrite) => void;
|
|
@@ -111,6 +133,11 @@ type ExecuteWriteResult<R> = {
|
|
|
111
133
|
* @internal Exported for tests.
|
|
112
134
|
*/
|
|
113
135
|
declare function providerServesUndo(queryClient: QueryClient, provider: DataProvider, resource: string): Promise<boolean>;
|
|
136
|
+
/**
|
|
137
|
+
* The version `id`'s cached row is at, as a token for `expectedVersion`.
|
|
138
|
+
* @internal Exported for tests.
|
|
139
|
+
*/
|
|
140
|
+
declare function cachedVersion(queryClient: QueryClient, provider: DataProvider, resource: string, id: Identifier): string | undefined;
|
|
114
141
|
/** A later write that built on one that was taken back. */
|
|
115
142
|
declare const DROPPED_WRITE_MESSAGE = "This change was not saved: it was made on top of an earlier change that was undone or failed. Please make it again.";
|
|
116
143
|
/**
|
|
@@ -126,4 +153,4 @@ declare const DROPPED_WRITE_MESSAGE = "This change was not saved: it was made on
|
|
|
126
153
|
*/
|
|
127
154
|
declare function executeWrite<R extends BaseRecord | void>(args: ExecuteWriteArgs<R>): Promise<ExecuteWriteResult<R>>;
|
|
128
155
|
|
|
129
|
-
export { DEFAULT_UNDO_DELAY_MS, DROPPED_WRITE_MESSAGE, type ExecuteWriteArgs, type ExecuteWriteResult, type MutationMode, type MutationModeOptions, type SendContext, type UndoableWrite, cachedRecord, dropPendingWrites, executeWrite, flushPendingWrites, invalidateResource, pendingWriteCount, providerServesUndo, sameValue };
|
|
156
|
+
export { DEFAULT_UNDO_DELAY_MS, DROPPED_WRITE_MESSAGE, type ExecuteWriteArgs, type ExecuteWriteResult, type MutationMode, type MutationModeOptions, type SendContext, type UndoableWrite, cachedRecord, cachedVersion, dropPendingWrites, executeWrite, flushPendingWrites, invalidateResource, pendingWriteCount, providerServesUndo, sameValue };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
export { DEFAULT_UNDO_DELAY_MS, DROPPED_WRITE_MESSAGE, cachedRecord, dropPendingWrites, executeWrite, flushPendingWrites, invalidateResource, pendingWriteCount, providerServesUndo, sameValue } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { DEFAULT_UNDO_DELAY_MS, DROPPED_WRITE_MESSAGE, cachedRecord, cachedVersion, dropPendingWrites, executeWrite, flushPendingWrites, invalidateResource, pendingWriteCount, providerServesUndo, sameValue } from '../chunk-YNXLPOAB.js';
|
|
2
|
+
import '../chunk-2VJQVAJD.js';
|
|
3
|
+
import '../chunk-AJGVLF37.js';
|
|
3
4
|
import '../chunk-7PUFVNPB.js';
|
|
4
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-PSFKIG27.js';
|
|
5
6
|
import '../chunk-ZYJUEJ4Z.js';
|
|
6
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-AUVKRXRC.js';
|
|
8
|
+
import '../chunk-VFT6QKZW.js';
|
|
9
|
+
import '../chunk-HUNGCTRA.js';
|
|
10
|
+
import '../chunk-RYEXWQFD.js';
|
|
11
|
+
import '../chunk-LG6TUBVM.js';
|
|
7
12
|
//# sourceMappingURL=mutation-mode.js.map
|
|
8
13
|
//# sourceMappingURL=mutation-mode.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DataProvider, W as WriteEvent, I as InvalidationKey } from '../types-
|
|
1
|
+
import { D as DataProvider, W as WriteEvent, I as InvalidationKey } from '../types-BzLv8yOm.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The cache keys a committed write makes stale beyond `[resource]`: the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import { t as ProviderCapabilities } from '../types-
|
|
2
|
+
import { t as ProviderCapabilities } from '../types-BzLv8yOm.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The query key for `provider`'s capabilities for `resource`. It includes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { capabilitiesQueryKey, useCapabilities } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { capabilitiesQueryKey, useCapabilities } from '../chunk-2VJQVAJD.js';
|
|
2
|
+
import '../chunk-PSFKIG27.js';
|
|
3
3
|
import '../chunk-ZYJUEJ4Z.js';
|
|
4
4
|
//# sourceMappingURL=use-capabilities.js.map
|
|
5
5
|
//# sourceMappingURL=use-capabilities.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseInfiniteQueryResult, InfiniteData } from '@tanstack/react-query';
|
|
2
|
-
import { S as SortParam, a as FilterParam, s as ListResult, L as ListParams, B as BaseRecord } from '../types-
|
|
2
|
+
import { S as SortParam, a as FilterParam, s as ListResult, L as ListParams, B as BaseRecord } from '../types-BzLv8yOm.js';
|
|
3
3
|
import { LiveOptions } from './use-live.js';
|
|
4
4
|
|
|
5
5
|
interface UseInfiniteResourceOptions {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { useInfiniteResource } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-AUVKRXRC.js';
|
|
1
|
+
export { useInfiniteResource } from '../chunk-POMTRNAL.js';
|
|
2
|
+
import '../chunk-XVRIWP7B.js';
|
|
4
3
|
import '../chunk-7PUFVNPB.js';
|
|
5
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-PSFKIG27.js';
|
|
6
5
|
import '../chunk-ZYJUEJ4Z.js';
|
|
6
|
+
import '../chunk-AUVKRXRC.js';
|
|
7
7
|
//# sourceMappingURL=use-infinite-resource.js.map
|
|
8
8
|
//# sourceMappingURL=use-infinite-resource.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { useLinkOptions } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-AUVKRXRC.js';
|
|
1
|
+
export { useLinkOptions } from '../chunk-VJGU6E4U.js';
|
|
2
|
+
import '../chunk-42QPCDQF.js';
|
|
3
|
+
import '../chunk-POMTRNAL.js';
|
|
4
|
+
import '../chunk-XVRIWP7B.js';
|
|
6
5
|
import '../chunk-7PUFVNPB.js';
|
|
7
|
-
import '../chunk-
|
|
6
|
+
import '../chunk-PSFKIG27.js';
|
|
8
7
|
import '../chunk-ZYJUEJ4Z.js';
|
|
8
|
+
import '../chunk-AUVKRXRC.js';
|
|
9
9
|
//# sourceMappingURL=use-link-options.js.map
|
|
10
10
|
//# sourceMappingURL=use-link-options.js.map
|
package/dist/hooks/use-live.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryKey } from '@tanstack/react-query';
|
|
2
|
-
import { V as SubscribeParams, w as ResourceChangeEvent } from '../types-
|
|
2
|
+
import { V as SubscribeParams, w as ResourceChangeEvent } from '../types-BzLv8yOm.js';
|
|
3
3
|
|
|
4
4
|
/** How long a burst of change events is gathered into one refetch. */
|
|
5
5
|
declare const DEFAULT_LIVE_DEBOUNCE_MS = 250;
|
package/dist/hooks/use-live.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-VDEW4AOS.js';
|
|
1
|
+
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from '../chunk-XVRIWP7B.js';
|
|
2
|
+
import '../chunk-PSFKIG27.js';
|
|
4
3
|
import '../chunk-ZYJUEJ4Z.js';
|
|
4
|
+
import '../chunk-AUVKRXRC.js';
|
|
5
5
|
//# sourceMappingURL=use-live.js.map
|
|
6
6
|
//# sourceMappingURL=use-live.js.map
|
package/dist/hooks/use-one.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import { B as BaseRecord, b as Identifier } from '../types-
|
|
2
|
+
import { B as BaseRecord, b as Identifier } from '../types-BzLv8yOm.js';
|
|
3
3
|
import { LiveOptions } from './use-live.js';
|
|
4
4
|
|
|
5
5
|
interface UseOneOptions {
|
package/dist/hooks/use-one.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { useOne } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-AUVKRXRC.js';
|
|
1
|
+
export { useOne } from '../chunk-LOJGHR5O.js';
|
|
2
|
+
import '../chunk-XVRIWP7B.js';
|
|
4
3
|
import '../chunk-7PUFVNPB.js';
|
|
5
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-PSFKIG27.js';
|
|
6
5
|
import '../chunk-ZYJUEJ4Z.js';
|
|
6
|
+
import '../chunk-AUVKRXRC.js';
|
|
7
7
|
//# sourceMappingURL=use-one.js.map
|
|
8
8
|
//# sourceMappingURL=use-one.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface PersistedUiStateOptions<T> {
|
|
2
|
+
/**
|
|
3
|
+
* Turns the stored string into a value; return `undefined` for one you don't accept, and the
|
|
4
|
+
* hook falls back to `initial`. Default: `JSON.parse`, any value.
|
|
5
|
+
*/
|
|
6
|
+
parse?: (raw: string) => T | undefined;
|
|
7
|
+
/** Turns a value into the string stored. Default: `JSON.stringify`. */
|
|
8
|
+
serialize?: (value: T) => string;
|
|
9
|
+
}
|
|
10
|
+
declare function usePersistedUiState<T>(key: string | null, initial: T, options?: PersistedUiStateOptions<T>): [T, (next: T | undefined | ((current: T) => T | undefined)) => void];
|
|
11
|
+
|
|
12
|
+
export { type PersistedUiStateOptions, usePersistedUiState };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"use-persisted-ui-state.js"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DataProvider, l as FieldReference, b as Identifier } from '../types-
|
|
1
|
+
import { D as DataProvider, l as FieldReference, b as Identifier } from '../types-BzLv8yOm.js';
|
|
2
2
|
|
|
3
3
|
interface UseRelationLabelOptions {
|
|
4
4
|
/** The linked row's field that names it. Default: the linked resource's `labelField` (`describe`). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { loadRelationLabel, relationNamingField, useRelationLabel } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { loadRelationLabel, relationNamingField, useRelationLabel } from '../chunk-42QPCDQF.js';
|
|
2
|
+
import '../chunk-PSFKIG27.js';
|
|
3
3
|
import '../chunk-ZYJUEJ4Z.js';
|
|
4
4
|
//# sourceMappingURL=use-relation-label.js.map
|
|
5
5
|
//# sourceMappingURL=use-relation-label.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
-
import { y as ResourceFormFieldDef, I as InvalidationKey } from '../types-
|
|
2
|
+
import { y as ResourceFormFieldDef, I as InvalidationKey } from '../types-BzLv8yOm.js';
|
|
3
|
+
import { W as WriteConflict } from '../write-state-DVC4Yq9T.js';
|
|
3
4
|
import { MutationModeOptions } from './mutation-mode.js';
|
|
4
5
|
import '@tanstack/react-query';
|
|
5
6
|
|
|
@@ -100,6 +101,18 @@ interface UseResourceFormReturn {
|
|
|
100
101
|
* `window.confirm` otherwise.
|
|
101
102
|
*/
|
|
102
103
|
confirmLeave: () => boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Set when a save met someone else's change (a versioned resource's
|
|
106
|
+
* `conflict`): their row beside what this form tried to save. Show it with
|
|
107
|
+
* ConflictSheet; null otherwise.
|
|
108
|
+
*/
|
|
109
|
+
conflict: WriteConflict | null;
|
|
110
|
+
/** Save this form's values over theirs, at the version the conflict reported. */
|
|
111
|
+
keepMine: () => Promise<void>;
|
|
112
|
+
/** Drop this form's changes and show their row. */
|
|
113
|
+
takeTheirs: () => void;
|
|
114
|
+
/** Close the conflict without choosing: the form keeps its unsaved values. */
|
|
115
|
+
dismissConflict: () => void;
|
|
103
116
|
}
|
|
104
117
|
/** Build default values for a single array item from its sub-field definitions */
|
|
105
118
|
declare function buildArrayItemDefaults(arrayFields: ResourceFormFieldDef[]): Record<string, unknown>;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-
|
|
1
|
+
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-3B5O36DU.js';
|
|
2
|
+
import '../chunk-2WS4LGYU.js';
|
|
2
3
|
import '../chunk-RVWKVD5Q.js';
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-7NUL32W7.js';
|
|
5
|
+
import '../chunk-LOJGHR5O.js';
|
|
6
|
+
import '../chunk-XVRIWP7B.js';
|
|
7
|
+
import '../chunk-YNXLPOAB.js';
|
|
8
|
+
import '../chunk-2VJQVAJD.js';
|
|
9
|
+
import '../chunk-AJGVLF37.js';
|
|
8
10
|
import '../chunk-7PUFVNPB.js';
|
|
9
|
-
import '../chunk-
|
|
11
|
+
import '../chunk-PSFKIG27.js';
|
|
10
12
|
import '../chunk-ZYJUEJ4Z.js';
|
|
11
|
-
import '../chunk-
|
|
12
|
-
import '../chunk-
|
|
13
|
+
import '../chunk-AUVKRXRC.js';
|
|
14
|
+
import '../chunk-VFT6QKZW.js';
|
|
15
|
+
import '../chunk-HUNGCTRA.js';
|
|
13
16
|
import '../chunk-RYEXWQFD.js';
|
|
14
17
|
import '../chunk-LG6TUBVM.js';
|
|
15
18
|
//# sourceMappingURL=use-resource-form.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult, UseMutationResult } from '@tanstack/react-query';
|
|
2
|
-
import { S as SortParam, a as FilterParam, I as InvalidationKey, s as ListResult, L as ListParams, b as Identifier, B as BaseRecord } from '../types-
|
|
2
|
+
import { S as SortParam, a as FilterParam, I as InvalidationKey, s as ListResult, L as ListParams, b as Identifier, B as BaseRecord } from '../types-BzLv8yOm.js';
|
|
3
3
|
import { MutationModeOptions } from './mutation-mode.js';
|
|
4
4
|
import { LiveOptions } from './use-live.js';
|
|
5
5
|
|
|
@@ -65,6 +65,19 @@ interface UseResourceOptions<T> extends MutationModeOptions {
|
|
|
65
65
|
*/
|
|
66
66
|
onError?: (error: Error) => void;
|
|
67
67
|
}
|
|
68
|
+
/** What `update` can take beside the change. */
|
|
69
|
+
interface UpdateOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Check the write against this version instead of the cached row's: "keep mine" after a
|
|
72
|
+
* conflict, at the version the conflict reported (`WriteConflict.currentVersion`). A version
|
|
73
|
+
* already chained for the row wins over it: a write sent while an earlier write of the same row
|
|
74
|
+
* is still in flight is checked against the version that one commits (as
|
|
75
|
+
* `ExecuteWriteArgs.expectedVersion`). The write
|
|
76
|
+
* still goes through the resource's write path (queued behind any other write of the row, its
|
|
77
|
+
* committed version recorded), so a move made right after it is checked against it.
|
|
78
|
+
*/
|
|
79
|
+
expectedVersion?: string;
|
|
80
|
+
}
|
|
68
81
|
interface UseResourceReturn<T> {
|
|
69
82
|
/** TanStack Query result for the list query. */
|
|
70
83
|
list: UseQueryResult<ListResult<T>>;
|
|
@@ -86,7 +99,7 @@ interface UseResourceReturn<T> {
|
|
|
86
99
|
* `optimistic` and `undoable` modes it resolves at once with the cached
|
|
87
100
|
* row merged with `data`.
|
|
88
101
|
*/
|
|
89
|
-
update: (id: Identifier, data: Partial<T
|
|
102
|
+
update: (id: Identifier, data: Partial<T>, options?: UpdateOptions) => Promise<T>;
|
|
90
103
|
/** Delete a record by id. Resolves at once in `optimistic` / `undoable` modes. */
|
|
91
104
|
remove: (id: Identifier) => Promise<void>;
|
|
92
105
|
/** True when any mutation is in-flight. */
|
|
@@ -95,9 +108,10 @@ interface UseResourceReturn<T> {
|
|
|
95
108
|
updateMutation: UseMutationResult<T, Error, {
|
|
96
109
|
id: Identifier;
|
|
97
110
|
data: Partial<T>;
|
|
111
|
+
options?: UpdateOptions;
|
|
98
112
|
}>;
|
|
99
113
|
deleteMutation: UseMutationResult<void, Error, Identifier>;
|
|
100
114
|
}
|
|
101
115
|
declare function useResource<T extends BaseRecord = BaseRecord>(resource: string, options?: UseResourceOptions<T>): UseResourceReturn<T>;
|
|
102
116
|
|
|
103
|
-
export { type UseResourceOptions, type UseResourceReturn, useResource };
|
|
117
|
+
export { type UpdateOptions, type UseResourceOptions, type UseResourceReturn, useResource };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
export { useResource } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
1
|
+
export { useResource } from '../chunk-OC4OGB2K.js';
|
|
2
|
+
import '../chunk-7NUL32W7.js';
|
|
3
|
+
import '../chunk-XVRIWP7B.js';
|
|
4
|
+
import '../chunk-YNXLPOAB.js';
|
|
5
|
+
import '../chunk-2VJQVAJD.js';
|
|
6
|
+
import '../chunk-AJGVLF37.js';
|
|
6
7
|
import '../chunk-7PUFVNPB.js';
|
|
7
|
-
import '../chunk-
|
|
8
|
+
import '../chunk-PSFKIG27.js';
|
|
8
9
|
import '../chunk-ZYJUEJ4Z.js';
|
|
9
|
-
import '../chunk-
|
|
10
|
-
import '../chunk-
|
|
10
|
+
import '../chunk-AUVKRXRC.js';
|
|
11
|
+
import '../chunk-VFT6QKZW.js';
|
|
12
|
+
import '../chunk-HUNGCTRA.js';
|
|
13
|
+
import '../chunk-RYEXWQFD.js';
|
|
14
|
+
import '../chunk-LG6TUBVM.js';
|
|
11
15
|
//# sourceMappingURL=use-resource.js.map
|
|
12
16
|
//# sourceMappingURL=use-resource.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryClient, MutationOptions } from '@tanstack/react-query';
|
|
2
|
-
import { I as InvalidationKey } from '../types-
|
|
2
|
+
import { I as InvalidationKey } from '../types-BzLv8yOm.js';
|
|
3
3
|
|
|
4
4
|
declare const WRITE_FAILED = "That didn't work. Try again.";
|
|
5
5
|
interface UseWriteOptions<A, R> {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { L as ListParams, b as Identifier } from './types-
|
|
2
|
-
export { A as ArrayFilter, c as AuditEntry, B as BaseRecord, d as BulkChange, e as BulkResult, C as CountMode, f as CreateParams, g as CreateResult, D as DataProvider, h as DataRow, i as DeleteParams, j as DeleteResult, k as FieldPermissions, l as FieldReference, F as FieldSchema, m as FieldType, n as FilterOperator, a as FilterParam, G as GetManyParams, o as GetManyResult, p as GetOneParams, q as GetOneResult, H as HistoryParams, r as ImportParams, I as InvalidationKey, s as ListResult, N as NullFilter, P as PaginationParam, t as ProviderCapabilities, R as RangeFilter, u as RecordComment, v as ResourceAccess, w as ResourceChangeEvent, x as ResourceContract, y as ResourceFormFieldDef, z as ResourceRelation, E as ResourceSchema, J as ResourceSummary, K as RowAction, M as RowFailure, O as RowOf, Q as ScalarFilter, T as SelectOption, S as SortParam, U as StorageType, V as SubscribeParams, X as UpdateParams, Y as UpdateResult, Z as VersionField, m as WidgetHint, W as WriteEvent, _ as defineResource } from './types-
|
|
3
|
-
export { D as DataWriteError, a as DataWriteErrorOptions, W as WriteOutcome, i as isDataWriteError } from './write-outcome-
|
|
4
|
-
export { CallRpcOptions, CreateOrAdoptOptions, CreateOrAdoptResult, DEFAULT_RPC_MESSAGES, DataProviderRoot, DataProviderRootProps, GenesisProvider, GenesisProviderProps, MockProviderOptions, PostgrestFieldErrors, RPC_FAILED, RpcClient, SupabaseClient, SupabaseClientInput, SupabaseProviderOptions, SupabaseRealtimeChannel, SupabaseRealtimePayload, SupabaseResourceConfig, SupabaseWriteContext, callRpc, createMockProvider, createOrAdopt, createSupabaseProvider, fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, useDataProvider, useStorage, writeOutcomeFromCode } from './provider/index.js';
|
|
1
|
+
import { L as ListParams, b as Identifier } from './types-BzLv8yOm.js';
|
|
2
|
+
export { A as ArrayFilter, c as AuditEntry, B as BaseRecord, d as BulkChange, e as BulkResult, C as CountMode, f as CreateParams, g as CreateResult, D as DataProvider, h as DataRow, i as DeleteParams, j as DeleteResult, k as FieldPermissions, l as FieldReference, F as FieldSchema, m as FieldType, n as FilterOperator, a as FilterParam, G as GetManyParams, o as GetManyResult, p as GetOneParams, q as GetOneResult, H as HistoryParams, r as ImportParams, I as InvalidationKey, s as ListResult, N as NullFilter, P as PaginationParam, t as ProviderCapabilities, R as RangeFilter, u as RecordComment, v as ResourceAccess, w as ResourceChangeEvent, x as ResourceContract, y as ResourceFormFieldDef, z as ResourceRelation, E as ResourceSchema, J as ResourceSummary, K as RowAction, M as RowFailure, O as RowOf, Q as ScalarFilter, T as SelectOption, S as SortParam, U as StorageType, V as SubscribeParams, X as UpdateParams, Y as UpdateResult, Z as VersionField, m as WidgetHint, W as WriteEvent, _ as defineResource } from './types-BzLv8yOm.js';
|
|
3
|
+
export { D as DataWriteError, a as DataWriteErrorOptions, W as WriteOutcome, i as isDataWriteError } from './write-outcome-DC5hORz-.js';
|
|
4
|
+
export { CallRpcOptions, CreateOrAdoptOptions, CreateOrAdoptResult, DEFAULT_RPC_MESSAGES, DataProviderRoot, DataProviderRootProps, GenesisProvider, GenesisProviderProps, MockProviderOptions, PostgrestFieldErrors, RPC_FAILED, RpcClient, SupabaseClient, SupabaseClientInput, SupabaseProviderOptions, SupabaseRealtimeChannel, SupabaseRealtimePayload, SupabaseResourceConfig, SupabaseUpdateContext, SupabaseWriteContext, callRpc, createMockProvider, createOrAdopt, createSupabaseProvider, fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, useDataProvider, useStorage, writeOutcomeFromCode } from './provider/index.js';
|
|
5
5
|
export { D as DataReadError, a as DataReadErrorOptions, R as ReadOutcome, i as isDataReadError, r as readFailureMessage } from './read-outcome-BnboMYOV.js';
|
|
6
6
|
export { S as StorageAdapter } from './types-DKcxHXxq.js';
|
|
7
7
|
export { createLocalStorageAdapter, createMemoryStorageAdapter, createNoopStorageAdapter } from './storage/index.js';
|
|
8
|
-
export { UseResourceOptions, UseResourceReturn, useResource } from './hooks/use-resource.js';
|
|
8
|
+
export { UpdateOptions, UseResourceOptions, UseResourceReturn, useResource } from './hooks/use-resource.js';
|
|
9
9
|
export { UseOneOptions, useOne } from './hooks/use-one.js';
|
|
10
10
|
export { UseRelationLabelOptions, loadRelationLabel, relationNamingField, useRelationLabel } from './hooks/use-relation-label.js';
|
|
11
11
|
export { LinkOption, LinkTarget, UseLinkOptionsOptions, UseLinkOptionsReturn, useLinkOptions } from './hooks/use-link-options.js';
|
|
12
12
|
export { InfinitePageParam, UseInfiniteResourceOptions, UseInfiniteResourceReturn, useInfiniteResource } from './hooks/use-infinite-resource.js';
|
|
13
13
|
export { useCapabilities } from './hooks/use-capabilities.js';
|
|
14
|
+
export { PersistedUiStateOptions, usePersistedUiState } from './hooks/use-persisted-ui-state.js';
|
|
14
15
|
export { UseWriteOptions, UseWriteReturn, WRITE_FAILED, useWrite } from './hooks/use-write.js';
|
|
15
16
|
export { UseDraftReturn, useDraft } from './hooks/use-draft.js';
|
|
16
17
|
export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftAdoption, DraftController, DraftOptions, DraftSeed, DraftState, DraftStatus, DraftValue, isNetworkFailure, stableJson } from './hooks/draft-controller.js';
|
|
17
|
-
export { G as GenesisViewerRoles, N as NO_VIEWER, R as ResourceScope, V as Viewer, a as ViewerContext, b as ViewerScope, c as ViewerScopeProps, d as clearViewerCache, s as scopeClock, u as useOptionalViewerScope, e as useViewer, f as useViewerScope } from './viewer-scope-
|
|
18
|
+
export { G as GenesisViewerRoles, N as NO_VIEWER, R as ResourceScope, V as Viewer, a as ViewerContext, b as ViewerScope, c as ViewerScopeProps, d as clearViewerCache, s as scopeClock, u as useOptionalViewerScope, e as useViewer, f as useViewerScope } from './viewer-scope-Dx0N9AYk.js';
|
|
18
19
|
export { WorkspaceContext, WorkspaceScope, WorkspaceScopeProps, rememberedWorkspaceId, useWorkspace } from './hooks/index.js';
|
|
19
20
|
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, LiveOptions, useLiveInvalidation } from './hooks/use-live.js';
|
|
20
21
|
export { UseResourceFormOptions, UseResourceFormReturn, blankValues, buildArrayItemDefaults, useResourceForm } from './hooks/use-resource-form.js';
|
|
@@ -22,11 +23,13 @@ export { UseWizardReturn, WizardStep, useWizard } from './hooks/use-wizard.js';
|
|
|
22
23
|
export { DEFAULT_UNDO_DELAY_MS, MutationMode, MutationModeOptions, UndoableWrite, dropPendingWrites, flushPendingWrites, pendingWriteCount } from './hooks/mutation-mode.js';
|
|
23
24
|
export { DEFAULT_UNSAVED_CHANGES_MESSAGE, UseUnsavedChangesGuardOptions, UseUnsavedChangesGuardReturn, useUnsavedChangesGuard } from './hooks/use-unsaved-changes-guard.js';
|
|
24
25
|
export { decodeRecordKey, encodeRecordKey, keyFields } from './schema/index.js';
|
|
26
|
+
export { W as WriteConflict, a as WriteConflictOptions, b as WriteState, w as writeConflict } from './write-state-DVC4Yq9T.js';
|
|
25
27
|
import { Query } from '@tanstack/react-query';
|
|
26
28
|
export { isSafeUrl, normalizeLinkUrl } from './urls.js';
|
|
27
29
|
export { ClassifiedError, ClassifyErrorOptions, ErrorKind, ErrorMessages, ErrorReportContext, ErrorReporter, classifyError, defaultErrorReporter, errorMessages, getErrorReporter, reportError, setErrorReporter } from './errors.js';
|
|
28
30
|
export { titleCase } from './utils.js';
|
|
29
31
|
import 'react';
|
|
32
|
+
import './types-CsKSAKqs.js';
|
|
30
33
|
import './dates.js';
|
|
31
34
|
import './workspaces.js';
|
|
32
35
|
import 'react-hook-form';
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from './chunk-7GW3QR63.js';
|
|
3
|
-
export { defineResource } from './chunk-7FVTGKTX.js';
|
|
1
|
+
export { defineResource } from './chunk-YDMKMNDS.js';
|
|
4
2
|
export { decodeRecordKey, encodeRecordKey, keyFields } from './chunk-KV2HW4G4.js';
|
|
5
|
-
|
|
6
|
-
export {
|
|
3
|
+
import './chunk-XCX2TRBL.js';
|
|
4
|
+
export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from './chunk-ZHC3MDCS.js';
|
|
5
|
+
export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from './chunk-C62CMLWG.js';
|
|
6
|
+
export { NO_VIEWER } from './chunk-OZYF55E3.js';
|
|
7
|
+
export { usePersistedUiState } from './chunk-HYYTAJBG.js';
|
|
8
|
+
export { blankValues, buildArrayItemDefaults, useResourceForm } from './chunk-3B5O36DU.js';
|
|
9
|
+
export { writeConflict } from './chunk-2WS4LGYU.js';
|
|
10
|
+
export { useResource } from './chunk-OC4OGB2K.js';
|
|
11
|
+
export { DEFAULT_UNSAVED_CHANGES_MESSAGE, useUnsavedChangesGuard } from './chunk-RVWKVD5Q.js';
|
|
7
12
|
export { useWizard } from './chunk-7KOLYF27.js';
|
|
8
13
|
export { WRITE_FAILED, useWrite } from './chunk-52T2EYXH.js';
|
|
9
|
-
|
|
14
|
+
import './chunk-7NUL32W7.js';
|
|
10
15
|
export { useDraft } from './chunk-YQBWXG2G.js';
|
|
11
|
-
export { useLinkOptions } from './chunk-
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export { useOne } from './chunk-4ZR7472O.js';
|
|
17
|
-
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from './chunk-ZCE3CHPX.js';
|
|
16
|
+
export { useLinkOptions } from './chunk-VJGU6E4U.js';
|
|
17
|
+
export { loadRelationLabel, relationNamingField, useRelationLabel } from './chunk-42QPCDQF.js';
|
|
18
|
+
export { useInfiniteResource } from './chunk-POMTRNAL.js';
|
|
19
|
+
export { useOne } from './chunk-LOJGHR5O.js';
|
|
20
|
+
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from './chunk-XVRIWP7B.js';
|
|
18
21
|
import './chunk-UHOMTFBD.js';
|
|
19
22
|
export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftController, isNetworkFailure, stableJson } from './chunk-HBAPYA5K.js';
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
|
|
23
|
+
export { DEFAULT_UNDO_DELAY_MS, dropPendingWrites, flushPendingWrites, pendingWriteCount } from './chunk-YNXLPOAB.js';
|
|
24
|
+
export { useCapabilities } from './chunk-2VJQVAJD.js';
|
|
25
|
+
import './chunk-AJGVLF37.js';
|
|
23
26
|
export { defineQueryKeys, resourceKeys } from './chunk-7PUFVNPB.js';
|
|
24
|
-
export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from './chunk-
|
|
27
|
+
export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from './chunk-PSFKIG27.js';
|
|
25
28
|
export { createLocalStorageAdapter, createMemoryStorageAdapter, createNoopStorageAdapter } from './chunk-ZYJUEJ4Z.js';
|
|
26
|
-
import './chunk-
|
|
27
|
-
import './chunk-7NUL32W7.js';
|
|
29
|
+
import './chunk-AUVKRXRC.js';
|
|
28
30
|
import './chunk-WXENWPWP.js';
|
|
29
|
-
export { classifyError, defaultErrorReporter, errorMessages, getErrorReporter, reportError, setErrorReporter } from './chunk-
|
|
30
|
-
export { fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, writeOutcomeFromCode } from './chunk-PA6WJE5E.js';
|
|
31
|
+
export { classifyError, defaultErrorReporter, errorMessages, fieldErrorsFromPostgrest, getErrorReporter, readOutcomeFromCode, reportError, setErrorReporter, toDataWriteError, writeOutcomeFromCode } from './chunk-VFT6QKZW.js';
|
|
31
32
|
export { DataReadError, isDataReadError, readFailureMessage } from './chunk-HUNGCTRA.js';
|
|
32
33
|
export { titleCase } from './chunk-RYEXWQFD.js';
|
|
33
34
|
export { DataWriteError, isDataWriteError } from './chunk-LG6TUBVM.js';
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { L as LocalCache, Q as QueryPersistence } from '../types-CsKSAKqs.js';
|
|
2
|
+
export { C as CacheOp, a as CacheScope, S as StoredQuery, b as StoredRow, c as SubscribeOptions, d as cacheScope } from '../types-CsKSAKqs.js';
|
|
3
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A `LocalCache` in memory: for tests, and for a screen that wants the
|
|
7
|
+
* contract without a device store. Nothing survives a reload.
|
|
8
|
+
*
|
|
9
|
+
* @stability Beta
|
|
10
|
+
*/
|
|
11
|
+
declare function memoryLocalCache(): LocalCache;
|
|
12
|
+
|
|
13
|
+
/** Options for {@link indexedDbLocalCache}. */
|
|
14
|
+
interface IndexedDbLocalCacheOptions {
|
|
15
|
+
/** The database name. Default `"genesis-offline"`. */
|
|
16
|
+
name?: string;
|
|
17
|
+
/** The IndexedDB factory. Default `globalThis.indexedDB`. */
|
|
18
|
+
indexedDB?: IDBFactory;
|
|
19
|
+
/**
|
|
20
|
+
* Ask the browser to keep this origin's storage (`navigator.storage.persist()`).
|
|
21
|
+
* Default false: some browsers ask the person, and kept storage outlives a
|
|
22
|
+
* shared machine's session longer. Without it the browser may evict the
|
|
23
|
+
* cache under pressure; it's rebuilt from the server.
|
|
24
|
+
*/
|
|
25
|
+
persist?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A `LocalCache` in IndexedDB, for the web: plain IndexedDB, no dependency.
|
|
29
|
+
* Rows and queries are separate object stores keyed by scope, so one row is
|
|
30
|
+
* stored once whatever lists hold it, and a write is one transaction. A newer
|
|
31
|
+
* version of the database opened in another tab closes this one, which then
|
|
32
|
+
* reopens on its next use, instead of blocking the upgrade.
|
|
33
|
+
*
|
|
34
|
+
* @stability Beta
|
|
35
|
+
*/
|
|
36
|
+
declare function indexedDbLocalCache(options?: IndexedDbLocalCacheOptions): LocalCache;
|
|
37
|
+
|
|
38
|
+
/** Options for {@link persistOffline}. */
|
|
39
|
+
interface PersistOfflineOptions {
|
|
40
|
+
/** Where reads are kept: `indexedDbLocalCache()` on the web, `sqliteLocalCache({ db })` on the phone. */
|
|
41
|
+
cache: LocalCache;
|
|
42
|
+
/**
|
|
43
|
+
* The resources whose reads are kept on the device: the one opt-in switch.
|
|
44
|
+
* Keeping data on a device is a decision, so nothing else is written. Leave
|
|
45
|
+
* out a resource whose rows shouldn't sit on a phone unencrypted.
|
|
46
|
+
*/
|
|
47
|
+
resources: readonly string[];
|
|
48
|
+
/** Your app's version: a different value discards what was kept. */
|
|
49
|
+
buster: string;
|
|
50
|
+
/** How old a kept read may be when restored. Default 7 days. */
|
|
51
|
+
maxAge?: number;
|
|
52
|
+
/** Save at most this often. Default 500 ms. */
|
|
53
|
+
throttleMs?: number;
|
|
54
|
+
/** The most reads kept per person and workspace; the least recently fetched go first. Default 200. */
|
|
55
|
+
maxReads?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Keeps the reads of the listed resources on the device, per record, and
|
|
59
|
+
* puts them back into the QueryClient on the next start, so lists and records
|
|
60
|
+
* open at once and then refresh as usual. What `GenesisNativeApp`'s and
|
|
61
|
+
* `GenesisProvider`'s `persist` take.
|
|
62
|
+
*
|
|
63
|
+
* persist={persistOffline({ cache: indexedDbLocalCache(), resources: ["tasks", "people"], buster: version })}
|
|
64
|
+
*
|
|
65
|
+
* - Only reads that came back from the provider are kept (never an optimistic
|
|
66
|
+
* change that hasn't been saved), in the bucket of the person and workspace
|
|
67
|
+
* they were read in.
|
|
68
|
+
* - A restored read is marked as fetched when it was, so a screen refetches it
|
|
69
|
+
* once it's stale (the client's `staleTime`), as with any cached read. It
|
|
70
|
+
* never replaces a newer read already in the client.
|
|
71
|
+
* - A newer read replaces a stored row, so a field the server stops returning
|
|
72
|
+
* goes; a record that comes back empty is deleted from the device. Each start
|
|
73
|
+
* deletes reads older than `maxAge` and the rows no kept read refers to.
|
|
74
|
+
* - A device is one person's: restoring someone deletes every other person's
|
|
75
|
+
* reads first, and `restore("")` (nobody signed in) deletes them all, so a
|
|
76
|
+
* session that ended outside the app leaves nothing behind.
|
|
77
|
+
* - A sign-out, a change of person or workspace, or `clear()` stops every save
|
|
78
|
+
* and restore still in flight from landing in the new bucket.
|
|
79
|
+
*
|
|
80
|
+
* @stability Beta
|
|
81
|
+
*/
|
|
82
|
+
declare function persistOffline(options: PersistOfflineOptions): (queryClient: QueryClient) => QueryPersistence;
|
|
83
|
+
|
|
84
|
+
export { type IndexedDbLocalCacheOptions, LocalCache, type PersistOfflineOptions, QueryPersistence, indexedDbLocalCache, memoryLocalCache, persistOffline };
|