tsdf 16.0.2 → 17.0.0-alpha.1

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.cts DELETED
@@ -1,400 +0,0 @@
1
- import { Store } from 't-state';
2
-
3
- type FetchType = 'lowPriority' | 'highPriority' | 'realtimeUpdate';
4
- type ScheduleFetchResults = 'skipped' | 'started' | 'scheduled' | 'rt-scheduled';
5
-
6
- type TSDFStatus = 'loading' | 'error' | 'refetching' | 'success';
7
- type ValidPayload = number | string | Record<string, unknown>;
8
- type ValidStoreState = Record<string, unknown> | any[];
9
-
10
- type DocumentStatus = TSDFStatus | 'idle';
11
- type TSDFDocumentStoreState<State extends ValidStoreState, NError> = {
12
- data: State | null;
13
- error: NError | null;
14
- status: DocumentStatus;
15
- refetchOnMount: false | FetchType;
16
- };
17
- type TSDFUseDocumentReturn<Selected, NError> = {
18
- status: DocumentStatus;
19
- data: Selected;
20
- error: NError | null;
21
- isLoading: boolean;
22
- };
23
- type OnDocumentInvalidate = (priority: FetchType) => void;
24
- declare function newTSDFDocumentStore<State extends ValidStoreState, NError>({ debugName, fetchFn, getInitialData, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, disableInitialDataInvalidation, errorNormalizer, onInvalidate, }: {
25
- debugName?: string;
26
- fetchFn: () => Promise<State>;
27
- getInitialData?: () => State | undefined;
28
- disableInitialDataInvalidation?: boolean;
29
- errorNormalizer: (exception: unknown) => NError;
30
- disableRefetchOnMount?: boolean;
31
- lowPriorityThrottleMs?: number;
32
- mediumPriorityThrottleMs?: number;
33
- dynamicRealtimeThrottleMs?: (lastFetchDuration: number) => number;
34
- onInvalidate?: OnDocumentInvalidate;
35
- }): {
36
- store: Store<TSDFDocumentStoreState<State, NError>>;
37
- reset: () => void;
38
- awaitFetch: () => Promise<{
39
- data: State;
40
- error: null;
41
- } | {
42
- data: null;
43
- error: NError;
44
- }>;
45
- scheduleFetch: (fetchType: FetchType) => ScheduleFetchResults;
46
- invalidateData: (priority?: FetchType) => void;
47
- useDocument: <Selected = State | null>({ selector, isOffScreen, disabled, returnRefetchingStatus, disableRefetchOnMount, returnIdleStatus, ensureIsLoaded, selectorUsesExternalDeps, }?: {
48
- selector?: (data: State | null) => Selected;
49
- disabled?: boolean;
50
- isOffScreen?: boolean;
51
- disableRefetchOnMount?: boolean;
52
- returnIdleStatus?: boolean;
53
- ensureIsLoaded?: boolean;
54
- returnRefetchingStatus?: boolean;
55
- selectorUsesExternalDeps?: boolean;
56
- }) => Readonly<TSDFUseDocumentReturn<Selected, NError>>;
57
- updateState: (produceNewData: (draftData: State) => State | void | undefined) => boolean;
58
- startMutation: () => () => boolean;
59
- };
60
- type TSDFDocumentStore<State extends ValidStoreState, NError> = ReturnType<typeof newTSDFDocumentStore<State, NError>>;
61
-
62
- type CollectionItemStatus = TSDFStatus;
63
- type TSFDCollectionItem<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, NError> = {
64
- data: ItemState | null;
65
- error: NError | null;
66
- status: CollectionItemStatus;
67
- payload: ItemPayload;
68
- refetchOnMount: false | FetchType;
69
- wasLoaded: boolean;
70
- };
71
- type TSFDCollectionState<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, NError> = Record<string, TSFDCollectionItem<ItemState, ItemPayload, NError> | null>;
72
- type TSFDUseCollectionItemReturn<Selected, ItemPayload, NError, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
73
- data: Selected;
74
- status: CollectionItemStatus | 'idle' | 'deleted';
75
- payload: ItemPayload | undefined;
76
- error: NError | null;
77
- itemStateKey: string;
78
- isLoading: boolean;
79
- queryMetadata: QueryMetadata;
80
- };
81
- type CollectionInitialStateItem<ItemPayload extends ValidPayload, ItemState extends ValidStoreState> = {
82
- payload: ItemPayload;
83
- data: ItemState;
84
- };
85
- type OnCollectionItemInvalidate<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = (props: {
86
- itemState: ItemState;
87
- payload: ItemPayload;
88
- priority: FetchType;
89
- }) => void;
90
- type CollectionUseMultipleItemsQuery<ItemPayload extends ValidPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
91
- payload: ItemPayload;
92
- queryMetadata?: QueryMetadata;
93
- omitPayload?: boolean;
94
- disableRefetchOnMount?: boolean;
95
- returnIdleStatus?: boolean;
96
- returnRefetchingStatus?: boolean;
97
- isOffScreen?: boolean;
98
- };
99
- declare function newTSDFCollectionStore<ItemState extends ValidStoreState, NError, ItemPayload extends ValidPayload>({ debugName, fetchFn, lowPriorityThrottleMs, errorNormalizer, disableInitialDataInvalidation, mediumPriorityThrottleMs, getInitialData, disableRefetchOnMount: globalDisableRefetchOnMount, dynamicRealtimeThrottleMs, getCollectionItemKey: filterCollectionItemObjKey, onInvalidate, }: {
100
- debugName?: string;
101
- fetchFn: (params: ItemPayload) => Promise<ItemState>;
102
- getCollectionItemKey?: (params: ItemPayload) => ValidPayload | any[];
103
- errorNormalizer: (exception: unknown) => NError;
104
- disableRefetchOnMount?: boolean;
105
- getInitialData?: () => CollectionInitialStateItem<ItemPayload, ItemState>[] | undefined;
106
- disableInitialDataInvalidation?: boolean;
107
- lowPriorityThrottleMs?: number;
108
- mediumPriorityThrottleMs?: number;
109
- dynamicRealtimeThrottleMs?: (lastFetchDuration: number) => number;
110
- onInvalidate?: OnCollectionItemInvalidate<ItemState, ItemPayload>;
111
- }): {
112
- store: Store<TSFDCollectionState<ItemState, ItemPayload, NError>>;
113
- scheduleFetch: {
114
- (fetchType: FetchType, payload: ItemPayload): ScheduleFetchResults;
115
- (fetchType: FetchType, payload: ItemPayload[]): ScheduleFetchResults[];
116
- };
117
- awaitFetch: (params: ItemPayload) => Promise<{
118
- data: null;
119
- error: NError;
120
- } | {
121
- data: ItemState;
122
- error: null;
123
- }>;
124
- useMultipleItems: <Selected = ItemState | null, QueryMetadata extends Record<string, unknown> | undefined = undefined>(items: CollectionUseMultipleItemsQuery<ItemPayload, QueryMetadata>[], { selector, selectorUsesExternalDeps, returnIdleStatus: allItemsReturnIdleStatus, returnRefetchingStatus: allItemsReturnRefetchingStatus, omitPayload: allItemsOmitPayload, disableRefetchOnMount: allItemsDisableRefetchOnMount, isOffScreen: allItemsIsOffScreen, }?: {
125
- selector?: (data: ItemState | null) => Selected;
126
- selectorUsesExternalDeps?: boolean;
127
- returnIdleStatus?: boolean;
128
- returnRefetchingStatus?: boolean;
129
- omitPayload?: boolean;
130
- disableRefetchOnMount?: boolean;
131
- isOffScreen?: boolean;
132
- }) => readonly TSFDUseCollectionItemReturn<Selected, ItemPayload, NError, QueryMetadata>[];
133
- useItem: <Selected_1 = ItemState | null>(payload: ItemPayload | undefined | false | null, { omitPayload, selector, selectorUsesExternalDeps, ensureIsLoaded, returnRefetchingStatus, disableRefetchOnMount, returnIdleStatus, isOffScreen, }?: {
134
- selector?: ((data: ItemState | null) => Selected_1) | undefined;
135
- selectorUsesExternalDeps?: boolean | undefined;
136
- omitPayload?: boolean | undefined;
137
- returnRefetchingStatus?: boolean | undefined;
138
- disableRefetchOnMount?: boolean | undefined;
139
- ensureIsLoaded?: boolean | undefined;
140
- returnIdleStatus?: boolean | undefined;
141
- isOffScreen?: boolean | undefined;
142
- }) => TSFDUseCollectionItemReturn<Selected_1, ItemPayload, NError, undefined>;
143
- reset: () => void;
144
- getItemKey: (params: ItemPayload) => string;
145
- getItemState: {
146
- (fetchParam: ItemPayload): TSFDCollectionItem<ItemState, ItemPayload, NError> | null | undefined;
147
- (fetchParams: ItemPayload[] | ((params: ItemPayload, data: ItemState | null) => boolean)): TSFDCollectionItem<ItemState, ItemPayload, NError>[];
148
- };
149
- startMutation: (fetchParams: ItemPayload | ItemPayload[] | ((params: ItemPayload, data: ItemState | null) => boolean)) => () => void;
150
- invalidateItem: (itemPayload: ItemPayload | ItemPayload[] | ((params: ItemPayload, data: ItemState | null) => boolean), priority?: FetchType) => void;
151
- updateItemState: (fetchParams: ItemPayload | ItemPayload[] | ((params: ItemPayload, data: ItemState | null) => boolean), produceNewData: (draftData: ItemState, collectionItem: TSFDCollectionItem<ItemState, ItemPayload, NError>) => void | ItemState, ifNothingWasUpdated?: () => void) => boolean;
152
- addItemToState: (fetchParams: ItemPayload, data: ItemState) => void;
153
- deleteItemState: (fetchParams: ItemPayload | ItemPayload[] | ((params: ItemPayload, data: ItemState | null) => boolean)) => void;
154
- };
155
- type TSDFCollectionStore<ItemState extends ValidStoreState, NError, FetchParams extends ValidPayload> = ReturnType<typeof newTSDFCollectionStore<ItemState, NError, FetchParams>>;
156
-
157
- type QueryStatus = TSDFStatus | 'loadingMore';
158
- type TSFDListQuery<NError, QueryPayload extends ValidPayload> = {
159
- error: NError | null;
160
- status: QueryStatus;
161
- payload: QueryPayload;
162
- hasMore: boolean;
163
- wasLoaded: boolean;
164
- refetchOnMount: false | FetchType;
165
- items: string[];
166
- };
167
- type TSDFItemQuery<NError, ItemPayload> = {
168
- error: NError | null;
169
- status: Exclude<QueryStatus, 'loadingMore'>;
170
- wasLoaded: boolean;
171
- refetchOnMount: false | FetchType;
172
- payload: ItemPayload;
173
- };
174
- type TSFDListQueryState<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
175
- items: Record<string, ItemState | null>;
176
- queries: Record<string, TSFDListQuery<NError, QueryPayload>>;
177
- itemQueries: Record<string, TSDFItemQuery<NError, ItemPayload> | null>;
178
- };
179
- type TSFDUseListQueryReturn<Selected, ItemPayload, NError, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
180
- items: Selected[];
181
- status: QueryStatus | 'idle';
182
- payload: ItemPayload | undefined;
183
- error: NError | null;
184
- queryKey: string;
185
- hasMore: boolean;
186
- isLoading: boolean;
187
- isLoadingMore: boolean;
188
- queryMetadata: QueryMetadata;
189
- };
190
- type TSFDUseListItemReturn<Selected, NError, ItemPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
191
- data: Selected;
192
- status: QueryStatus | 'idle' | 'deleted';
193
- payload: ItemPayload | null;
194
- error: NError | null;
195
- isLoading: boolean;
196
- queryMetadata: QueryMetadata;
197
- };
198
- type FetchListFnReturnItem<ItemPayload extends ValidPayload, ItemState extends ValidStoreState> = {
199
- itemPayload: ItemPayload;
200
- data: ItemState;
201
- };
202
- type FetchListFnReturn<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = {
203
- items: FetchListFnReturnItem<ItemPayload, ItemState>[];
204
- hasMore: boolean;
205
- };
206
- type ListQueryStoreInitialData<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
207
- items: {
208
- payload: ItemPayload;
209
- data: ItemState;
210
- }[];
211
- queries: {
212
- payload: QueryPayload;
213
- items: string[];
214
- hasMore: boolean;
215
- }[];
216
- };
217
- type OnListQueryInvalidate<QueryPayload extends ValidPayload> = (query: QueryPayload, priority: FetchType) => void;
218
- type OnListQueryItemInvalidate<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = (props: {
219
- itemState: ItemState;
220
- payload: ItemPayload;
221
- priority: FetchType;
222
- }) => void;
223
- type ListQueryUseMultipleItemsQuery<ItemPayload extends ValidPayload, QueryMetadata extends undefined | Record<string, unknown>> = {
224
- payload: ItemPayload;
225
- queryMetadata?: QueryMetadata;
226
- disableRefetchOnMount?: boolean;
227
- returnIdleStatus?: boolean;
228
- returnRefetchingStatus?: boolean;
229
- isOffScreen?: boolean;
230
- };
231
- type ListQueryUseMultipleListQueriesQuery<QueryPayload extends ValidPayload, QueryMetadata extends undefined | Record<string, unknown>> = {
232
- payload: QueryPayload;
233
- queryMetadata?: QueryMetadata;
234
- omitPayload?: boolean;
235
- disableRefetchOnMount?: boolean;
236
- returnIdleStatus?: boolean;
237
- returnRefetchingStatus?: boolean;
238
- isOffScreen?: boolean;
239
- loadSize?: number;
240
- };
241
- declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>({ debugName, fetchListFn, fetchItemFn, errorNormalizer, defaultQuerySize, getInitialData, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, disableInitialDataInvalidation, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, optimisticListUpdates, onInvalidateItem, onInvalidateQuery, }: {
242
- debugName?: string;
243
- fetchListFn: (payload: QueryPayload, size: number) => Promise<FetchListFnReturn<ItemState, ItemPayload>>;
244
- fetchItemFn?: (itemId: ItemPayload) => Promise<ItemState>;
245
- errorNormalizer: (exception: unknown) => NError;
246
- defaultQuerySize?: number;
247
- getInitialData?: () => ListQueryStoreInitialData<ItemState, QueryPayload, ItemPayload> | undefined;
248
- disableInitialDataInvalidation?: boolean;
249
- disableRefetchOnMount?: boolean;
250
- lowPriorityThrottleMs?: number;
251
- mediumPriorityThrottleMs?: number;
252
- dynamicRealtimeThrottleMs?: (lastFetchDuration: number) => number;
253
- optimisticListUpdates?: {
254
- queries: QueryPayload | ((query: QueryPayload) => boolean) | QueryPayload[];
255
- filterItem?: (item: ItemState) => boolean | null;
256
- /** @default 'end' */
257
- appendNewTo?: 'start' | 'end';
258
- invalidateQueries?: boolean;
259
- sort?: {
260
- sortBy: (item: ItemState, itemPayload: ItemPayload) => string | number | (string | number)[];
261
- /** @default 'asc' */
262
- order?: 'asc' | 'desc' | ('asc' | 'desc')[];
263
- };
264
- }[];
265
- onInvalidateQuery?: OnListQueryInvalidate<QueryPayload>;
266
- onInvalidateItem?: OnListQueryItemInvalidate<ItemState, ItemPayload>;
267
- }): {
268
- store: Store<TSFDListQueryState<ItemState, NError, QueryPayload, ItemPayload>>;
269
- reset: () => void;
270
- scheduleListQueryFetch: {
271
- (fetchType: FetchType, payload: QueryPayload, size?: number): ScheduleFetchResults;
272
- (fetchType: FetchType, payload: QueryPayload[], size?: number): ScheduleFetchResults[];
273
- };
274
- getQueryState: (params: QueryPayload) => TSFDListQuery<NError, QueryPayload> | undefined;
275
- getQueryKey: (params: QueryPayload) => string;
276
- deleteItemState: (itemId: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[]) => void;
277
- getItemState: {
278
- (itemPayload: ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[]): {
279
- payload: ItemPayload;
280
- data: ItemState;
281
- }[];
282
- (itemPayload: ItemPayload): ItemState | null | undefined;
283
- };
284
- loadMore: (params: QueryPayload, size?: number) => ScheduleFetchResults;
285
- invalidateQueryAndItems: ({ itemPayload, queryPayload, type: priority, }: {
286
- itemPayload: false | ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[];
287
- queryPayload: false | QueryPayload | QueryPayload[] | ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean);
288
- type?: FetchType | undefined;
289
- }) => void;
290
- scheduleItemFetch: {
291
- (fetchType: FetchType, itemPayload: ItemPayload): ScheduleFetchResults;
292
- (fetchType: FetchType, itemPayload: ItemPayload[]): ScheduleFetchResults[];
293
- };
294
- awaitItemFetch: (itemPayload: ItemPayload) => Promise<{
295
- data: null;
296
- error: NError;
297
- } | {
298
- data: ItemState;
299
- error: null;
300
- }>;
301
- awaitListQueryFetch: (params: QueryPayload, size?: number) => Promise<{
302
- items: [
303
- ];
304
- error: NError;
305
- hasMore: boolean;
306
- } | {
307
- items: {
308
- data: ItemState;
309
- itemPayload: ItemPayload;
310
- }[];
311
- error: null;
312
- hasMore: boolean;
313
- }>;
314
- useMultipleListQueries: <SelectedItem = ItemState, QueryMetadata extends Record<string, unknown> | undefined = undefined>(queries: ListQueryUseMultipleListQueriesQuery<QueryPayload, QueryMetadata>[], { itemSelector, selectorUsesExternalDeps, returnIdleStatus: allItemsReturnIdleStatus, returnRefetchingStatus: allItemsReturnRefetchingStatus, omitPayload: allItemsOmitPayload, disableRefetchOnMount: allItemsDisableRefetchOnMount, isOffScreen: allItemsIsOffScreen, loadSize: allItemsLoadSize, }?: {
315
- itemSelector?: (data: ItemState, id: ItemPayload, itemKey: string) => SelectedItem;
316
- selectorUsesExternalDeps?: boolean;
317
- returnIdleStatus?: boolean;
318
- returnRefetchingStatus?: boolean;
319
- omitPayload?: boolean;
320
- disableRefetchOnMount?: boolean;
321
- isOffScreen?: boolean;
322
- loadSize?: number;
323
- }) => readonly TSFDUseListQueryReturn<SelectedItem, QueryPayload, NError, QueryMetadata>[];
324
- useListQuery: <SelectedItem_1 = ItemState>(payload: QueryPayload | false | null | undefined, { isOffScreen, itemSelector, disableRefetchOnMount, returnIdleStatus, returnRefetchingStatus, loadSize, omitPayload, ensureIsLoaded, selectorUsesExternalDeps, }?: {
325
- itemSelector?: ((data: ItemState, id: ItemPayload, itemKey: string) => SelectedItem_1) | undefined;
326
- omitPayload?: boolean | undefined;
327
- disableRefetchOnMount?: boolean | undefined;
328
- returnIdleStatus?: boolean | undefined;
329
- returnRefetchingStatus?: boolean | undefined;
330
- ensureIsLoaded?: boolean | undefined;
331
- loadSize?: number | undefined;
332
- isOffScreen?: boolean | undefined;
333
- selectorUsesExternalDeps?: boolean | undefined;
334
- }) => TSFDUseListQueryReturn<SelectedItem_1, QueryPayload, NError, undefined>;
335
- getItemKey: (params: ItemPayload) => string;
336
- useItem: <SelectedItem_2 = ItemState | null>(itemPayload: ItemPayload | false | null | undefined, { selector, selectorUsesExternalDeps, disableRefetchOnMount, returnIdleStatus, returnRefetchingStatus, ensureIsLoaded, loadFromStateOnly, isOffScreen, }?: {
337
- selector?: ((data: ItemState | null, id: ItemPayload | null) => SelectedItem_2) | undefined;
338
- selectorUsesExternalDeps?: boolean | undefined;
339
- disableRefetchOnMount?: boolean | undefined;
340
- returnIdleStatus?: boolean | undefined;
341
- returnRefetchingStatus?: boolean | undefined;
342
- ensureIsLoaded?: boolean | undefined;
343
- loadFromStateOnly?: boolean | undefined;
344
- isOffScreen?: boolean | undefined;
345
- }) => TSFDUseListItemReturn<SelectedItem_2, NError, ItemPayload, undefined>;
346
- useMultipleItems: <SelectedItem_3 = ItemState | null, QueryMetadata_1 extends Record<string, unknown> | undefined = undefined>(items: ListQueryUseMultipleItemsQuery<ItemPayload, QueryMetadata_1>[], { selector, loadFromStateOnly, selectorUsesExternalDeps, returnIdleStatus: allItemsReturnIdleStatus, returnRefetchingStatus: allItemsReturnRefetchingStatus, disableRefetchOnMount: allItemsDisableRefetchOnMount, isOffScreen: allItemsIsOffScreen, }?: {
347
- loadFromStateOnly?: boolean | undefined;
348
- selector?: ((data: ItemState | null, id: ItemPayload | null) => SelectedItem_3) | undefined;
349
- selectorUsesExternalDeps?: boolean | undefined;
350
- returnIdleStatus?: boolean | undefined;
351
- returnRefetchingStatus?: boolean | undefined;
352
- disableRefetchOnMount?: boolean | undefined;
353
- isOffScreen?: boolean | undefined;
354
- }) => readonly TSFDUseListItemReturn<SelectedItem_3, NError, ItemPayload, QueryMetadata_1>[];
355
- addItemToState: (itemPayload: ItemPayload, data: ItemState, { addItemToQueries, }?: {
356
- addItemToQueries?: {
357
- queries: QueryPayload | QueryPayload[] | ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean);
358
- appendTo: 'start' | 'end' | ((itemsPayload: ItemPayload[]) => number);
359
- } | undefined;
360
- }) => void;
361
- updateItemState: (itemIds: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[], produceNewData: (draftData: ItemState, itemPayload: ItemPayload) => void | ItemState, { ifNothingWasUpdated, }?: {
362
- ifNothingWasUpdated?: () => void;
363
- }) => boolean;
364
- startItemMutation: (itemId: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[]) => () => void;
365
- getQueriesState: (params: QueryPayload[] | ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean)) => {
366
- query: TSFDListQuery<NError, QueryPayload>;
367
- key: string;
368
- }[];
369
- getQueriesRelatedToItem: (itemPayload: ItemPayload) => {
370
- query: TSFDListQuery<NError, QueryPayload>;
371
- key: string;
372
- }[];
373
- useFindItem: <SelectedItem_4 = ItemState | null>(findItem: (item: ItemState, itemPayload: ItemPayload) => boolean, { selector, }?: {
374
- selector?: ((data: ItemState, id: ItemPayload) => SelectedItem_4) | undefined;
375
- }) => Readonly<SelectedItem_4 | null>;
376
- };
377
- type TSFDListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = ReturnType<typeof newTSDFListQueryStore<ItemState, NError, QueryPayload, ItemPayload>>;
378
-
379
- /** Use to detect if a item of a list may be loading in cases which there is no
380
- * clear indication of the status of individual items, ex: an item in a document collection that is loaded on demand */
381
- declare function useListItemIsLoading({ listIsLoading, isRefetching, itemExists, loadItemFallback, itemId, }: {
382
- itemId: string | null | false;
383
- isRefetching: boolean;
384
- listIsLoading: boolean;
385
- /** true if item exists in any condition, ex: if list is not loaded item not exists in memory yet */
386
- itemExists: boolean;
387
- loadItemFallback: () => void;
388
- }): boolean;
389
-
390
- declare function getCacheId(input: unknown, maxDepth?: number): string;
391
-
392
- declare function useListItemIsDeleted({ itemExists, listIsLoading, onDelete, itemId, }: {
393
- itemId: string;
394
- /** true if item exists in any condition, ex: if list is not loaded item not exists in memory yet */
395
- itemExists: boolean;
396
- listIsLoading: boolean;
397
- onDelete?: () => void;
398
- }): boolean;
399
-
400
- export { type CollectionInitialStateItem, type CollectionUseMultipleItemsQuery, type FetchListFnReturn, type FetchListFnReturnItem, type ListQueryStoreInitialData, type ListQueryUseMultipleItemsQuery, type ListQueryUseMultipleListQueriesQuery, type OnCollectionItemInvalidate, type OnDocumentInvalidate, type OnListQueryInvalidate, type OnListQueryItemInvalidate, type TSDFCollectionStore, type TSDFDocumentStore, type TSDFDocumentStoreState, type TSDFItemQuery, type TSDFStatus, type TSDFUseDocumentReturn, type TSFDCollectionItem, type TSFDCollectionState, type TSFDListQuery, type TSFDListQueryState, type TSFDListQueryStore, type TSFDUseCollectionItemReturn, type TSFDUseListItemReturn, type TSFDUseListQueryReturn, type ValidPayload, type ValidStoreState, getCacheId, newTSDFCollectionStore, newTSDFDocumentStore, newTSDFListQueryStore, useListItemIsDeleted, useListItemIsLoading };