tsdf 18.3.1 → 18.5.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/main.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as OfflineResolutionConflictParseError, $t as TSFDUseListQueryReturn, A as DefineListQueryOfflineOperations, At as OfflineUploadTransportContext, B as OfflineEntityMutationKind, Bt as ListQueryUseMultipleItemsQuery, C as PersistentStorageSchema, Cn as TSDFFocusDebugOperation, Ct as OfflineSessionUploadsConfig, D as CollectionOfflineOperationDefinition, Dt as OfflineUploadProgress, E as CollectionOfflineEntityRef, Et as OfflineUploadAdapter, F as ListQueryOfflineEntityRef, Ft as DerivedQuerySource, G as OfflineMutationQueueingPolicy, Gt as OptimisticListUpdate, H as OfflineMutationInput, Ht as OffsetPaginationConfig, I as ListQueryOfflineOperationDefinition, It as FetchListFnReturn, J as OfflineReplayRetryConfig, Jt as QueryStatus, K as OfflineOperationKind, Kt as PartialResourcesConfig, L as OfflineAccumulationConfig, Lt as FetchListFnReturnItem, M as DocumentOfflineOperationDefinition, Mt as SaveOfflineUploadArgs, N as GlobalOfflineEntity, Nt as DerivedQueriesConfig, O as DefineCollectionOfflineOperations, Ot as OfflineUploadSource, P as GlobalOfflineStatus, Pt as DerivedQueryContext, Q as OfflineResolutionActionForOperation, Qt as TSFDUseListItemReturn, R as OfflineAccumulationMergeContext, Rt as FieldsInput, S as PersistentStoragePreloadResult, Sn as TSDFDebugLogger, St as OfflineOperationUploadsContext, T as AnyOfflineOperationDefinition, Tt as OfflineUpload, U as OfflineMutationQueueingCause, Ut as OnListQueryInvalidate, V as OfflineMutationDescriptor, Vt as ListQueryUseMultipleListQueriesQuery, W as OfflineMutationQueueingConfig, Wt as OnListQueryItemInvalidate, X as OfflineResolutionActionError, Xt as TSFDListQuery, Y as OfflineResolutionAction, Yt as TSDFItemQuery, Z as OfflineResolutionActionErrorCode, Zt as TSFDListQueryState, _ as ListQueryOfflineOperationsConfig, _n as ScheduleFetchOptions, _t as OperationResult, a as AsyncStorageMetadataOrder, an as StoreFetchError, at as OfflineRetryExhaustedResolutionAction, b as PersistentStorageDataSchema, bn as TSDFDebugLogEntry, bt as defaultOfflineRuntimeConfig, c as AsyncStorageNamespaceCommitUpsert, cn as TSDFStatus, ct as OfflineSession, d as AsyncStorageNamespaceKind, dn as ValidStoreState, dt as OfflineSyncState, en as TSFDUsePendingOfflineItemsReturn, et as OfflineResolutionConflictParseErrorCode, f as AsyncStorageNamespaceScope, fn as fetchTypePriority, ft as OfflineTempEntitiesConfig, g as DocumentPersistentStorageConfig, gn as RequestSchedulerEvents, gt as OperationConflict, h as ConvertedPersistentStorageDataSchema, hn as RequestSchedulerEventData, ht as OfflineTempEntityPendingEntry, i as AsyncStorageDriverSetEntry, in as StoreError, it as OfflineResolutionRecordForStore, j as DefineOfflineOperation, jt as ReplaceOfflineUploadArgs, k as DefineDocumentOfflineOperations, kt as OfflineUploadState, l as AsyncStorageNamespaceGetResult, ln as UnwrapTSDFResult, lt as OfflineSessionConfig, m as CollectionPersistentStorageConfig, mn as FetchType, mt as OfflineTempEntityConfig, n as AsyncStorageDiscoveredScope, nn as MutationSkipped, nt as OfflineResolutionRecord, o as AsyncStorageNamespaceCommitArgs, on as StoreMutationError, ot as OfflineRuntimeConfig, p as AsyncStorageReadOptions, pn as mutationSkipped, pt as OfflineTempEntitiesReconciliation, q as OfflineQueueEntry, qt as QueryFetchPayload, r as AsyncStorageDriver, rn as PayloadDebounce, rt as OfflineResolutionRecordForOperation, s as AsyncStorageNamespaceCommitTouch, sn as StoreMutationErrorOptions, st as OfflineRuntimeConfigUpdate, t as AsyncStorageAdapter, tn as MaybeTSDFResult, tt as OfflineResolutionGenericAction, u as AsyncStorageNamespaceHandle, un as ValidPayload, ut as OfflineSupersedeConfig, v as ListQueryPersistentStorageConfig, vn as ScheduleFetchResults, vt as ParsedOfflineResolutionConflictResultForOperation, w as StorageAdapter, wn as TSDFLoggerOptions, wt as OfflineStoredUploadRecord, x as PersistentStorageErrorHandler, xn as TSDFDebugLogLevel, xt as OfflineMutationUploadsInput, y as PersistentStorageBaseConfig, yn as TSDFDebugLogArea, yt as ParsedOfflineResolutionConflictResultForStore, z as OfflineConflictResolutionAction, zt as FieldsOption } from "./types-DeZ9VDOe.js";
1
+ import { $ as OfflineMutationQueueingConfig, $t as ListQueryUseMultipleItemsQuery, A as DefineDocumentOfflineOperations, An as ScheduleFetchOptions, At as OfflineMutationUploadsInput, B as OfflineAccumulationMergeContext, Bt as OfflineUploadState, C as PersistentStoragePreloadResult, Cn as ValidPayload, Ct as OfflineTempEntityConfig, D as CollectionOfflineEntityRef, Dn as FetchType, Dt as ParsedOfflineResolutionConflictResultForOperation, E as AnyOfflineOperationDefinition, En as mutationSkipped, Et as OperationResult, F as GlobalOfflineStatus, Fn as TSDFDebugLogger, Ft as OfflineUploadAdapter, G as OfflineFailureContext, Gt as DerivedQueryContext, H as OfflineEntityMutationKind, Ht as ReplaceOfflineUploadArgs, I as ItemOfflineState, In as TSDFFocusDebugOperation, It as OfflineUploadFile, J as OfflineHealthCheckContext, Jt as FetchListFnReturnItem, K as OfflineFailurePhase, Kt as DerivedQuerySource, L as ListQueryOfflineEntityRef, Ln as TSDFLoggerOptions, Lt as OfflineUploadProgress, M as DefineOfflineOperation, Mn as TSDFDebugLogArea, Mt as OfflineSessionUploadsConfig, N as DocumentOfflineOperationDefinition, Nn as TSDFDebugLogEntry, Nt as OfflineStoredUploadRecord, O as CollectionOfflineOperationDefinition, On as RequestSchedulerEventData, Ot as ParsedOfflineResolutionConflictResultForStore, P as GlobalOfflineEntity, Pn as TSDFDebugLogLevel, Pt as OfflineUpload, Q as OfflineMutationQueueingCause, Qt as ListQueryAddItemToQueries, R as ListQueryOfflineOperationDefinition, Rt as OfflineUploadRefSchema, S as PersistentStorageErrorHandler, Sn as UnwrapTSDFResult, St as OfflineTempEntitiesReconciliation, T as StorageAdapter, Tn as fetchTypePriority, Tt as OperationConflict, U as OfflineExternalEntityRef, Ut as SaveOfflineUploadArgs, V as OfflineConflictResolutionAction, Vt as OfflineUploadTransportContext, W as OfflineFailureClassification, Wt as DerivedQueriesConfig, X as OfflineMutationDescriptor, Xt as FieldsOption, Y as OfflineHealthCheckResult, Yt as FieldsInput, Z as OfflineMutationInput, Zt as ItemLoadedFields, _ as DocumentPersistentStorageConfig, _n as StoreError, _t as OfflineSession, a as AsyncStorageMetadataOrder, an as PartialResourcesConfig, at as OfflineResolutionActionError, b as PersistentStorageBaseConfig, bn as StoreMutationErrorOptions, bt as OfflineSyncState, c as AsyncStorageNamespaceCommitUpsert, cn as TSDFItemQuery, ct as OfflineResolutionConflictParseError, d as AsyncStorageNamespaceKind, dn as TSFDUseListItemReturn, dt as OfflineResolutionRecord, en as ListQueryUseMultipleListQueriesQuery, et as OfflineMutationQueueingPolicy, f as AsyncStorageNamespaceScope, fn as TSFDUseListQueryReturn, ft as OfflineResolutionRecordForOperation, g as ConvertedPersistentStorageDataSchema, gn as PayloadDebounce, gt as OfflineRuntimeConfigUpdate, h as CollectionPersistentStorageConfig, hn as MutationSkipped, ht as OfflineRuntimeConfig, i as AsyncStorageDriverSetEntry, in as OptimisticListUpdate, it as OfflineResolutionAction, j as DefineListQueryOfflineOperations, jn as ScheduleFetchResults, jt as OfflineOperationUploadsContext, k as DefineCollectionOfflineOperations, kn as RequestSchedulerEvents, kt as defaultOfflineRuntimeConfig, l as AsyncStorageNamespaceGetResult, ln as TSFDListQuery, lt as OfflineResolutionConflictParseErrorCode, m as CollectionOfflineOperationsConfig, mn as MaybeTSDFResult, mt as OfflineRetryExhaustedResolutionAction, n as AsyncStorageDiscoveredScope, nn as OnListQueryInvalidate, nt as OfflineQueueEntry, o as AsyncStorageNamespaceCommitArgs, on as QueryFetchPayload, ot as OfflineResolutionActionErrorCode, p as AsyncStorageReadOptions, pn as TSFDUsePendingOfflineItemsReturn, pt as OfflineResolutionRecordForStore, q as OfflineHealthCheckConfig, qt as FetchListFnReturn, r as AsyncStorageDriver, rn as OnListQueryItemInvalidate, rt as OfflineReplayRetryConfig, s as AsyncStorageNamespaceCommitTouch, sn as QueryStatus, st as OfflineResolutionActionForOperation, t as AsyncStorageAdapter, tn as OffsetPaginationConfig, tt as OfflineOperationKind, u as AsyncStorageNamespaceHandle, un as TSFDListQueryState, ut as OfflineResolutionGenericAction, v as ListQueryOfflineOperationsConfig, vn as StoreFetchError, vt as OfflineSessionConfig, w as PersistentStorageSchema, wn as ValidStoreState, wt as OfflineTempEntityPendingEntry, x as PersistentStorageDataSchema, xn as TSDFStatus, xt as OfflineTempEntitiesConfig, y as ListQueryPersistentStorageConfig, yn as StoreMutationError, yt as OfflineSupersedeConfig, z as OfflineAccumulationConfig, zt as OfflineUploadSource } from "./types-Bp7_Ra7_.js";
2
2
  import { __LEGIT_ANY__ } from "@ls-stack/utils/saferTyping";
3
3
  import { Emitter } from "evtmitter";
4
4
  import { Context } from "react";
@@ -10,13 +10,20 @@ import { Store } from "t-state";
10
10
  * Successful result of an offline-enabled mutation attempt.
11
11
  *
12
12
  * `online` means the direct request completed and returned the server payload.
13
- * `queued` means the mutation was durably persisted for offline replay.
13
+ * `queued` means the mutation was queued for offline replay. It is normally
14
+ * persisted, but if the queue write failed (reported through
15
+ * `onPersistentStorageError`) it is only kept in memory until the page reloads.
14
16
  */
15
17
  type OfflineMutationResult<T> = {
16
18
  /** The direct online mutation completed successfully. */kind: 'online'; /** Server payload returned by the direct mutation. */
17
19
  data: Awaited<T>;
18
20
  } | {
19
- /** The mutation was durably queued for offline replay. */kind: 'queued';
21
+ /**
22
+ * The mutation was queued for offline replay. If the queue write failed
23
+ * (reported through `onPersistentStorageError`), it is only kept in
24
+ * memory until the page reloads.
25
+ */
26
+ kind: 'queued';
20
27
  };
21
28
  //#endregion
22
29
  //#region src/persistentStorage/removedStoresCleanup.d.ts
@@ -87,17 +94,58 @@ type StoreManagerOfflineApi<TUploadRef extends ValidPayload = ValidPayload> = {
87
94
  * retried or discarded only while `blockedResolutionCount === 0`.
88
95
  */
89
96
  resolveOfflineResolution: (resolutionId: string, action: OfflineResolutionGenericAction) => Promise<Result<void, OfflineResolutionActionError>>; /** Returns the latest session-scoped offline uploads for this manager. */
90
- getOfflineUploads: () => readonly OfflineUpload<TUploadRef>[]; /** Resolves a staged upload id to its latest final ref, uploading first if needed. */
91
- resolveOfflineUpload: (id: string) => Promise<Result<TUploadRef, Error>>; /** Resolves multiple staged upload ids to their latest final refs. */
92
- resolveOfflineUploads: (ids: readonly string[]) => Promise<Result<Record<string, TUploadRef>, Error>>; /** Saves a session-scoped upload locally for later dependency resolution. */
97
+ getOfflineUploads: () => readonly OfflineUpload<TUploadRef>[];
98
+ /**
99
+ * Resolves a staged upload id to its latest final ref, uploading first if
100
+ * needed. An upload deleted after it was sent keeps resolving to its ref for
101
+ * the rest of the app session, in every tab open when it was deleted.
102
+ *
103
+ * When the `upload` transport fails, the result is `Result.err` with the
104
+ * transport error and the upload becomes `failed` with `lastError` set. The
105
+ * session failure classifiers are not consulted and nothing is retried
106
+ * automatically: call it again to run the upload again.
107
+ */
108
+ resolveOfflineUpload: (id: string) => Promise<Result<TUploadRef, Error>>;
109
+ /**
110
+ * Resolves multiple staged upload ids to their latest final refs.
111
+ *
112
+ * Fails as a whole with the first transport error, following the same rules
113
+ * as `resolveOfflineUpload`. Uploads that already succeeded stay `uploaded`
114
+ * and are not sent again by a later call.
115
+ */
116
+ resolveOfflineUploads: (ids: readonly string[]) => Promise<Result<Record<string, TUploadRef>, Error>>;
117
+ /**
118
+ * Saves a session-scoped upload locally for later dependency resolution. It
119
+ * is deleted automatically once the queued work that depends on it leaves
120
+ * the queue. Only stores created in the tab count as depending on it, so
121
+ * create the stores that share an upload id before their queued work
122
+ * replays.
123
+ */
93
124
  saveOfflineUpload: (args: SaveOfflineUploadArgs) => Promise<Result<void, Error>>; /** Replaces a previously stored session-scoped upload, keeping its metadata unless new metadata is passed. */
94
125
  replaceOfflineUpload: (args: ReplaceOfflineUploadArgs) => Promise<Result<void, Error>>; /** Loads a previously stored session-scoped upload. */
95
- loadOfflineUpload: (id: string) => Promise<Result<File | null, Error>>; /** Deletes a stored upload when it is no longer referenced. */
126
+ loadOfflineUpload: (id: string) => Promise<Result<File | null, Error>>;
127
+ /**
128
+ * Deletes a stored upload that no queued work references. Only needed for
129
+ * uploads no queued mutation used: the others are deleted with the work that
130
+ * depends on them.
131
+ */
96
132
  deleteOfflineUpload: (id: string) => Promise<Result<void, Error>>; /** React hook subscribing to the manager's aggregated offline status. */
97
133
  useOfflineStatus: () => GlobalOfflineStatus; /** React hook subscribing to the manager's aggregated offline entities. */
98
134
  useOfflineEntities: () => readonly GlobalOfflineEntity[]; /** React hook subscribing to the manager's aggregated offline resolutions. */
99
135
  useOfflineResolutions: () => readonly OfflineResolutionRecord[]; /** React hook subscribing to the manager's aggregated offline uploads. */
100
136
  useOfflineUploads: () => readonly OfflineUpload<TUploadRef>[];
137
+ /**
138
+ * React hook that reads the file of a staged upload while it is staged, to
139
+ * render local files (e.g. thumbnails of optimistic entities) by upload id.
140
+ *
141
+ * The returned `url` is an object URL managed by TSDF: components using the
142
+ * same id share one read and one URL, and the URL is revoked shortly after
143
+ * the last of them stops using it or as soon as the upload is replaced,
144
+ * deleted or leaves the session. Pass a falsy id to disable the hook (status
145
+ * `idle`), e.g. once the entity holds the uploaded server ref instead of the
146
+ * staged upload id.
147
+ */
148
+ useOfflineUploadFile: (id: string | false | null | undefined) => OfflineUploadFile;
101
149
  };
102
150
  /** Shared coordinator passed to every TSDF store instance in an app/session. */
103
151
  type StoreManager<TUploadRef extends ValidPayload = ValidPayload> = {
@@ -119,6 +167,26 @@ type StoreManager<TUploadRef extends ValidPayload = ValidPayload> = {
119
167
  */
120
168
  onTransportReconnect: () => void;
121
169
  } & StoreManagerOfflineApi<TUploadRef>;
170
+ /**
171
+ * Upload ref type of a store manager, as inferred from the `upload` transport
172
+ * in its `offlineSession.uploads` config.
173
+ *
174
+ * Pass it as the last type argument of `DefineDocumentOfflineOperations`,
175
+ * `DefineCollectionOfflineOperations` or `DefineListQueryOfflineOperations` so
176
+ * `execute` reads typed refs from `ctx.uploads.resolvedRefsById`.
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * type UploadRef = StoreManagerUploadRef<typeof storeManager>;
181
+ *
182
+ * type Operations = DefineDocumentOfflineOperations<
183
+ * UserDoc,
184
+ * { setAvatar: DefineOfflineOperation<{ avatarUploadId: string }> },
185
+ * UploadRef
186
+ * >;
187
+ * ```
188
+ */
189
+ type StoreManagerUploadRef<TStoreManager extends StoreManager> = TStoreManager extends StoreManager<infer TUploadRef> ? TUploadRef : never;
122
190
  /** Options used to create a shared TSDF store manager. */
123
191
  type CreateStoreManagerOptions<TUploadRef extends ValidPayload = ValidPayload> = {
124
192
  /**
@@ -278,12 +346,6 @@ type CollectionStateCleanup<ItemPayload extends ValidPayload> = {
278
346
  itemKeys: string[]; /** Original item payloads removed from the collection state. */
279
347
  payloads: ItemPayload[];
280
348
  };
281
- type InternalCollectionOfflineOperations<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = Record<string, AnyOfflineOperationDefinition & {
282
- getEntityRefs: (ctx: {
283
- input: __LEGIT_ANY__;
284
- }) => CollectionOfflineEntityRef<ItemPayload>[];
285
- }> & ([ItemState | ItemPayload] extends [never] ? never : unknown);
286
- type CollectionOfflineOperationsConfig<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = InternalCollectionOfflineOperations<ItemState, ItemPayload> | null;
287
349
  /** Options used to create a collection store. */
288
350
  type CollectionStoreOptions<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, TOfflineOperations extends CollectionOfflineOperationsConfig<ItemState, ItemPayload> = null, StorageState = unknown> = {
289
351
  /**
@@ -465,7 +527,15 @@ type CollectionStore<ItemState extends ValidStoreState, ItemPayload extends Vali
465
527
  (params: ItemPayload[] | CollectionFilterItemsFn<ItemState, ItemPayload>): TSFDCollectionItem<ItemState, ItemPayload>[];
466
528
  }; /** Returns offline sync metadata for this store's tracked entities. */
467
529
  getOfflineEntities: () => GlobalOfflineEntity[]; /** React hook subscribing to this store's offline entity metadata. */
468
- useOfflineEntities: () => readonly GlobalOfflineEntity[]; /** React hook subscribing to manual offline resolutions for this store. */
530
+ useOfflineEntities: () => readonly GlobalOfflineEntity[];
531
+ /**
532
+ * React hook returning the offline sync state of one item, or `null` when
533
+ * the item has nothing queued and no manual resolution waiting. The
534
+ * component re-renders only when that item's own state changes, so it is
535
+ * suited for per-item sync badges.
536
+ */
537
+ useItemOfflineState: (itemPayload: ItemPayload | false | null | undefined) => ItemOfflineState | null; /** Non-reactive version of `useItemOfflineState`, for event handlers. */
538
+ getItemOfflineState: (itemPayload: ItemPayload) => ItemOfflineState | null; /** React hook subscribing to manual offline resolutions for this store. */
469
539
  useOfflineResolutions: () => readonly OfflineResolutionRecord[]; /** Returns manual offline resolutions for this store. */
470
540
  getOfflineResolutions: () => OfflineResolutionRecord[]; /** Parses a stored offline conflict into the operation-specific conflict shape. */
471
541
  parseOfflineResolutionConflict: (resolution: OfflineResolutionRecord) => ParsedOfflineResolutionConflictResultForStore<ResolvedCollectionOfflineOperations<TOfflineOperations>>; /** Applies a retry/discard/requeue/commit action to a pending offline resolution. */
@@ -1020,10 +1090,7 @@ type ListQueryUpdateItemStateApi<ItemState extends ValidStoreState, ItemPayload
1020
1090
  ifNothingWasUpdated?: () => void;
1021
1091
  }) => boolean;
1022
1092
  type ListQueryAddItemToStateApi<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = (itemPayload: ItemPayload, data: ItemState, options?: {
1023
- addItemToQueries?: {
1024
- queries: QueryPayload[] | ListQueryFilterQuery<QueryPayload> | QueryPayload;
1025
- appendTo: 'start' | 'end' | ((itemsPayload: ItemPayload[]) => number);
1026
- };
1093
+ /** Queries that receive the item, and where it is inserted in them. */addItemToQueries?: ListQueryAddItemToQueries<QueryPayload, ItemPayload>;
1027
1094
  }) => void;
1028
1095
  type ListQueryDeleteItemStateApi<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = (itemId: ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload>) => void;
1029
1096
  type ListQueryInvalidateQueryAndItemsArgs<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
@@ -1095,7 +1162,15 @@ type ListQueryStore<ItemState extends ValidStoreState, QueryPayload extends Vali
1095
1162
  }; /** React hook for locally pending offline items in this store. */
1096
1163
  usePendingOfflineItems: ListQueryUsePendingOfflineItemsApi<ItemState, ItemPayload>; /** Returns offline sync metadata for this store's tracked entities. */
1097
1164
  getOfflineEntities: () => GlobalOfflineEntity[]; /** React hook subscribing to this store's offline entity metadata. */
1098
- useOfflineEntities: () => readonly GlobalOfflineEntity[]; /** React hook subscribing to manual offline resolutions for this store. */
1165
+ useOfflineEntities: () => readonly GlobalOfflineEntity[];
1166
+ /**
1167
+ * React hook returning the offline sync state of one item, or `null` when
1168
+ * the item has nothing queued and no manual resolution waiting. The
1169
+ * component re-renders only when that item's own state changes, so it is
1170
+ * suited for per-row sync badges.
1171
+ */
1172
+ useItemOfflineState: (itemPayload: ItemPayload | false | null | undefined) => ItemOfflineState | null; /** Non-reactive version of `useItemOfflineState`, for event handlers. */
1173
+ getItemOfflineState: (itemPayload: ItemPayload) => ItemOfflineState | null; /** React hook subscribing to manual offline resolutions for this store. */
1099
1174
  useOfflineResolutions: () => readonly OfflineResolutionRecord[]; /** Returns manual offline resolutions for this store. */
1100
1175
  getOfflineResolutions: () => OfflineResolutionRecord[]; /** Parses a stored offline conflict into the operation-specific conflict shape. */
1101
1176
  parseOfflineResolutionConflict: (resolution: OfflineResolutionRecord) => ParsedOfflineResolutionConflictResultForStore<ResolvedListQueryOfflineOperations<TOfflineOperations>>; /** Applies a retry/discard/requeue/commit action to a pending offline resolution. */
@@ -1245,6 +1320,44 @@ declare const GET_ALL: (...args: unknown[]) => true;
1245
1320
  */
1246
1321
  declare const IsOffScreenContext: Context<boolean>;
1247
1322
  //#endregion
1323
+ //#region src/persistentStorage/offline/fetchRuntime.d.ts
1324
+ /**
1325
+ * The error TSDF reports for a fetch that could not complete because the
1326
+ * offline session is in offline mode. Use `isOfflineStoreError` to recognise
1327
+ * it.
1328
+ */
1329
+ type OfflineStoreError = StoreError & {
1330
+ code: 0;
1331
+ id: 'offline';
1332
+ message: 'Offline';
1333
+ };
1334
+ //#endregion
1335
+ //#region src/persistentStorage/offline/offlineStoreError.typeGuards.d.ts
1336
+ /**
1337
+ * Whether `error` is the error TSDF reports for a fetch that could not
1338
+ * complete because the offline session is in offline mode (the request is not
1339
+ * sent while offline).
1340
+ *
1341
+ * TSDF only exposes it on reads that have nothing cached to return
1342
+ * (`status: 'error'`): a document, item or query that is returning cached data
1343
+ * stays `success` with `error: null` while offline, so this is the state the
1344
+ * app has to explain to the user ("not available offline").
1345
+ *
1346
+ * Accepts the `error` of hooks and state getters and the `StoreFetchError` of
1347
+ * the `awaitFetch` methods. The error is matched by its whole shape, not only
1348
+ * by `id`, so an app error whose `errorNormalizer` happens to use the
1349
+ * `'offline'` id is not mistaken for it.
1350
+ *
1351
+ * @example
1352
+ * ```tsx
1353
+ * const { data, error } = store.useDocument();
1354
+ *
1355
+ * if (isOfflineStoreError(error)) return <NotAvailableOffline />;
1356
+ * if (error) return <ErrorMessage error={error} />;
1357
+ * ```
1358
+ */
1359
+ declare function isOfflineStoreError(error: StoreError | null | undefined): error is OfflineStoreError;
1360
+ //#endregion
1248
1361
  //#region src/persistentStorage/offline/sessionCoordinator.d.ts
1249
1362
  /**
1250
1363
  * Returns the latest offline status for a session. If the session has not been
@@ -1389,4 +1502,4 @@ declare function clearAllSessionStorage(sessionKey: string): Promise<void>;
1389
1502
  //#region src/persistentStorage/opfsOfflineUploadAdapter.d.ts
1390
1503
  declare const opfsOfflineUploadAdapter: OfflineUploadAdapter;
1391
1504
  //#endregion
1392
- export { type AsyncStorageAdapter, type AsyncStorageDiscoveredScope, type AsyncStorageDriver, type AsyncStorageDriverSetEntry, type AsyncStorageMetadataOrder, type AsyncStorageNamespaceCommitArgs, type AsyncStorageNamespaceCommitTouch, type AsyncStorageNamespaceCommitUpsert, type AsyncStorageNamespaceGetResult, type AsyncStorageNamespaceHandle, type AsyncStorageNamespaceKind, type AsyncStorageNamespaceScope, type AsyncStorageReadOptions, type BlockWindowCloseHandler, type CollectionOfflineEntityRef, type CollectionOfflineOperationDefinition, type CollectionPersistentStorageConfig, CollectionStateCleanup, CollectionStore, CollectionStoreEvents, CollectionStoreOptions, CollectionStoreStoreEvents, CollectionUseMultipleItemsQuery, type ConvertedPersistentStorageDataSchema, type CreateStoreManagerOptions, type DefineCollectionOfflineOperations, type DefineDocumentOfflineOperations, type DefineListQueryOfflineOperations, type DefineOfflineOperation, type DerivedQueriesConfig, type DerivedQueryContext, type DerivedQuerySource, type DocumentOfflineOperationDefinition, type DocumentPersistentStorageConfig, DocumentStatus, DocumentStore, DocumentStoreOptions, DocumentStoreState, DocumentStoreStoreEvents, type DynamicRealtimeThrottleMs, type FetchListFnReturn, type FetchListFnReturnItem, type FieldsInput, type FieldsOption, GET_ALL, type GlobalOfflineEntity, type GlobalOfflineStatus, IsOffScreenContext, type ListQueryOfflineEntityRef, type ListQueryOfflineOperationDefinition, type ListQueryPersistentStorageConfig, type ListQueryStore, type ListQueryStoreEvents, type ListQueryStoreOptions, type ListQueryUseMultipleItemsQuery, type ListQueryUseMultipleListQueriesQuery, type MaybeTSDFResult, type MutationDebounce, type MutationSkipped, type OfflineAccumulationConfig, type OfflineAccumulationMergeContext, type OfflineConflictResolutionAction, type OfflineEntityMutationKind, type OfflineMutationDescriptor, type OfflineMutationInput, type OfflineMutationQueueingCause, type OfflineMutationQueueingConfig, type OfflineMutationQueueingPolicy, type OfflineMutationResult, type OfflineMutationUploadsInput, type OfflineOperationKind, type OfflineOperationUploadsContext, type OfflineQueueEntry, type OfflineReplayRetryConfig, type OfflineResolutionAction, type OfflineResolutionActionError, type OfflineResolutionActionErrorCode, type OfflineResolutionActionForOperation, type OfflineResolutionConflictParseError, type OfflineResolutionConflictParseErrorCode, type OfflineResolutionGenericAction, type OfflineResolutionRecord, type OfflineResolutionRecordForOperation, type OfflineResolutionRecordForStore, type OfflineRetryExhaustedResolutionAction, type OfflineRuntimeConfig, type OfflineRuntimeConfigUpdate, type OfflineSession, type OfflineSessionConfig, type OfflineSessionUploadsConfig, type OfflineStoredUploadRecord, type OfflineSupersedeConfig, type OfflineSyncState, type OfflineTempEntitiesConfig, type OfflineTempEntitiesReconciliation, type OfflineTempEntityConfig, type OfflineTempEntityPendingEntry, type OfflineUpload, type OfflineUploadAdapter, type OfflineUploadProgress, type OfflineUploadSource, type OfflineUploadState, type OfflineUploadTransportContext, type OffsetPaginationConfig, OnCollectionItemInvalidate, OnDocumentInvalidate, type OnListQueryInvalidate, type OnListQueryItemInvalidate, type OperationConflict, type OperationResult, type OptimisticListUpdate, type ParsedOfflineResolutionConflictResultForOperation, type PartialResourcesConfig, type PayloadDebounce, type PersistentStorageBaseConfig, type PersistentStorageDataSchema, type PersistentStoragePreloadResult, type PersistentStorageSchema, type QueryFetchPayload, type QueryStatus, type RemovedStore, type ReplaceOfflineUploadArgs, type SaveOfflineUploadArgs, type StorageAdapter, type StoreError, StoreFetchError, type StoreManager, StoreMutationError, type StoreMutationErrorOptions, type TSDFDebugLogArea, type TSDFDebugLogEntry, type TSDFDebugLogLevel, type TSDFDebugLogger, type TSDFFocusDebugOperation, type TSDFItemQuery, type TSDFLoggerOptions, type TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, type TSFDListQuery, type TSFDListQueryState, TSFDUseCollectionItemReturn, type TSFDUseListItemReturn, type TSFDUseListQueryReturn, type TSFDUsePendingOfflineItemsReturn, type ValidPayload, type ValidStoreState, clearAllSessionStorage, clearSessionStorage, createCollectionStore, createDocumentStore, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };
1505
+ export { type AsyncStorageAdapter, type AsyncStorageDiscoveredScope, type AsyncStorageDriver, type AsyncStorageDriverSetEntry, type AsyncStorageMetadataOrder, type AsyncStorageNamespaceCommitArgs, type AsyncStorageNamespaceCommitTouch, type AsyncStorageNamespaceCommitUpsert, type AsyncStorageNamespaceGetResult, type AsyncStorageNamespaceHandle, type AsyncStorageNamespaceKind, type AsyncStorageNamespaceScope, type AsyncStorageReadOptions, type BlockWindowCloseHandler, type CollectionOfflineEntityRef, type CollectionOfflineOperationDefinition, type CollectionPersistentStorageConfig, CollectionStateCleanup, CollectionStore, CollectionStoreEvents, CollectionStoreOptions, CollectionStoreStoreEvents, CollectionUseMultipleItemsQuery, type ConvertedPersistentStorageDataSchema, type CreateStoreManagerOptions, type DefineCollectionOfflineOperations, type DefineDocumentOfflineOperations, type DefineListQueryOfflineOperations, type DefineOfflineOperation, type DerivedQueriesConfig, type DerivedQueryContext, type DerivedQuerySource, type DocumentOfflineOperationDefinition, type DocumentPersistentStorageConfig, DocumentStatus, DocumentStore, DocumentStoreOptions, DocumentStoreState, DocumentStoreStoreEvents, type DynamicRealtimeThrottleMs, type FetchListFnReturn, type FetchListFnReturnItem, type FieldsInput, type FieldsOption, GET_ALL, type GlobalOfflineEntity, type GlobalOfflineStatus, IsOffScreenContext, type ItemLoadedFields, type ItemOfflineState, type ListQueryAddItemToQueries, type ListQueryOfflineEntityRef, type ListQueryOfflineOperationDefinition, type ListQueryPersistentStorageConfig, type ListQueryStore, type ListQueryStoreEvents, type ListQueryStoreOptions, type ListQueryUseMultipleItemsQuery, type ListQueryUseMultipleListQueriesQuery, type MaybeTSDFResult, type MutationDebounce, type MutationSkipped, type OfflineAccumulationConfig, type OfflineAccumulationMergeContext, type OfflineConflictResolutionAction, type OfflineEntityMutationKind, type OfflineExternalEntityRef, type OfflineFailureClassification, type OfflineFailureContext, type OfflineFailurePhase, type OfflineHealthCheckConfig, type OfflineHealthCheckContext, type OfflineHealthCheckResult, type OfflineMutationDescriptor, type OfflineMutationInput, type OfflineMutationQueueingCause, type OfflineMutationQueueingConfig, type OfflineMutationQueueingPolicy, type OfflineMutationResult, type OfflineMutationUploadsInput, type OfflineOperationKind, type OfflineOperationUploadsContext, type OfflineQueueEntry, type OfflineReplayRetryConfig, type OfflineResolutionAction, type OfflineResolutionActionError, type OfflineResolutionActionErrorCode, type OfflineResolutionActionForOperation, type OfflineResolutionConflictParseError, type OfflineResolutionConflictParseErrorCode, type OfflineResolutionGenericAction, type OfflineResolutionRecord, type OfflineResolutionRecordForOperation, type OfflineResolutionRecordForStore, type OfflineRetryExhaustedResolutionAction, type OfflineRuntimeConfig, type OfflineRuntimeConfigUpdate, type OfflineSession, type OfflineSessionConfig, type OfflineSessionUploadsConfig, type OfflineStoreError, type OfflineStoredUploadRecord, type OfflineSupersedeConfig, type OfflineSyncState, type OfflineTempEntitiesConfig, type OfflineTempEntitiesReconciliation, type OfflineTempEntityConfig, type OfflineTempEntityPendingEntry, type OfflineUpload, type OfflineUploadAdapter, type OfflineUploadFile, type OfflineUploadProgress, type OfflineUploadRefSchema, type OfflineUploadSource, type OfflineUploadState, type OfflineUploadTransportContext, type OffsetPaginationConfig, OnCollectionItemInvalidate, OnDocumentInvalidate, type OnListQueryInvalidate, type OnListQueryItemInvalidate, type OperationConflict, type OperationResult, type OptimisticListUpdate, type ParsedOfflineResolutionConflictResultForOperation, type PartialResourcesConfig, type PayloadDebounce, type PersistentStorageBaseConfig, type PersistentStorageDataSchema, type PersistentStoragePreloadResult, type PersistentStorageSchema, type QueryFetchPayload, type QueryStatus, type RemovedStore, type ReplaceOfflineUploadArgs, type SaveOfflineUploadArgs, type StorageAdapter, type StoreError, StoreFetchError, type StoreManager, type StoreManagerUploadRef, StoreMutationError, type StoreMutationErrorOptions, type TSDFDebugLogArea, type TSDFDebugLogEntry, type TSDFDebugLogLevel, type TSDFDebugLogger, type TSDFFocusDebugOperation, type TSDFItemQuery, type TSDFLoggerOptions, type TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, type TSFDListQuery, type TSFDListQueryState, TSFDUseCollectionItemReturn, type TSFDUseListItemReturn, type TSFDUseListQueryReturn, type TSFDUsePendingOfflineItemsReturn, type ValidPayload, type ValidStoreState, clearAllSessionStorage, clearSessionStorage, createCollectionStore, createDocumentStore, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, isOfflineStoreError, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };