tsdf 8.0.0-beta.8 → 9.0.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
@@ -20,10 +20,11 @@ type TSDFUseDocumentReturn<Selected, NError> = {
20
20
  error: NError | null;
21
21
  isLoading: boolean;
22
22
  };
23
- declare function newTSDFDocumentStore<State extends ValidStoreState, NError>({ debugName, fetchFn, initialData, disableRefetchOnWindowFocus, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, errorNormalizer, }: {
23
+ declare function newTSDFDocumentStore<State extends ValidStoreState, NError>({ debugName, fetchFn, initialData, disableRefetchOnWindowFocus, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, disableInitialDataInvalidation, errorNormalizer, }: {
24
24
  debugName?: string;
25
25
  fetchFn: () => Promise<State>;
26
26
  initialData?: State;
27
+ disableInitialDataInvalidation?: boolean;
27
28
  errorNormalizer: (exception: unknown) => NError;
28
29
  disableRefetchOnWindowFocus?: boolean;
29
30
  disableRefetchOnMount?: boolean;
@@ -72,13 +73,19 @@ type TSFDUseCollectionItemReturn<Selected, ItemPayload, NError> = {
72
73
  itemStateKey: string;
73
74
  isLoading: boolean;
74
75
  };
75
- declare function newTSDFCollectionStore<ItemState extends ValidStoreState, NError, ItemPayload extends ValidPayload>({ debugName, fetchFn, disableRefetchOnWindowFocus, lowPriorityThrottleMs, errorNormalizer, mediumPriorityThrottleMs, disableRefetchOnMount: globalDisableRefetchOnMount, dynamicRealtimeThrottleMs, getCollectionItemKey: filterCollectionItemObjKey, }: {
76
+ type CollectionInitialStateItem<ItemPayload extends ValidPayload, ItemState extends ValidStoreState> = {
77
+ payload: ItemPayload;
78
+ data: ItemState;
79
+ };
80
+ declare function newTSDFCollectionStore<ItemState extends ValidStoreState, NError, ItemPayload extends ValidPayload>({ debugName, fetchFn, disableRefetchOnWindowFocus, lowPriorityThrottleMs, errorNormalizer, disableInitialDataInvalidation, mediumPriorityThrottleMs, initialStateItems, disableRefetchOnMount: globalDisableRefetchOnMount, dynamicRealtimeThrottleMs, getCollectionItemKey: filterCollectionItemObjKey, }: {
76
81
  debugName?: string;
77
82
  fetchFn: (params: ItemPayload) => Promise<ItemState>;
78
83
  getCollectionItemKey?: (params: ItemPayload) => ValidPayload | any[];
79
84
  errorNormalizer: (exception: unknown) => NError;
80
85
  disableRefetchOnWindowFocus?: boolean;
81
86
  disableRefetchOnMount?: boolean;
87
+ initialStateItems?: CollectionInitialStateItem<ItemPayload, ItemState>[];
88
+ disableInitialDataInvalidation?: boolean;
82
89
  lowPriorityThrottleMs?: number;
83
90
  mediumPriorityThrottleMs?: number;
84
91
  dynamicRealtimeThrottleMs?: (lastFetchDuration: number) => number;
@@ -167,12 +174,25 @@ type FetchListFnReturn<ItemState extends ValidStoreState, ItemPayload extends Va
167
174
  }[];
168
175
  hasMore: boolean;
169
176
  };
170
- declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>({ debugName, fetchListFn, fetchItemFn, errorNormalizer, defaultQuerySize, disableRefetchOnWindowFocus, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, syncMutationsAndInvalidations, }: {
177
+ type ListQueryStoreInitialData<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
178
+ items: {
179
+ payload: ItemPayload;
180
+ data: ItemState;
181
+ }[];
182
+ queries: {
183
+ payload: QueryPayload;
184
+ items: string[];
185
+ hasMore: boolean;
186
+ }[];
187
+ };
188
+ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>({ debugName, fetchListFn, fetchItemFn, errorNormalizer, defaultQuerySize, initialData, disableRefetchOnWindowFocus, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, disableInitialDataInvalidation, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, syncMutationsAndInvalidations, }: {
171
189
  debugName?: string;
172
190
  fetchListFn: (payload: QueryPayload, size: number) => Promise<FetchListFnReturn<ItemState, ItemPayload>>;
173
191
  fetchItemFn?: (itemId: ItemPayload) => Promise<ItemState>;
174
192
  errorNormalizer: (exception: unknown) => NError;
175
193
  defaultQuerySize?: number;
194
+ initialData?: ListQueryStoreInitialData<ItemState, QueryPayload, ItemPayload>;
195
+ disableInitialDataInvalidation?: boolean;
176
196
  disableRefetchOnWindowFocus?: boolean;
177
197
  syncMutationsAndInvalidations?: {
178
198
  syncQueries: (query1: QueryPayload, query2: QueryPayload) => boolean;
@@ -199,7 +219,7 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
199
219
  (itemPayload: ItemPayload): ItemState | null | undefined;
200
220
  };
201
221
  loadMore: (params: QueryPayload, size: number) => ScheduleFetchResults;
202
- invalidateQuery: (queryPayload: QueryPayload | QueryPayload[] | ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean), priority?: FetchType, ignoreInvalidationSync?: boolean) => void;
222
+ invalidateQuery: (queryPayload: QueryPayload | ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean) | QueryPayload[], priority?: FetchType, ignoreInvalidationSync?: boolean) => void;
203
223
  invalidateItem: (itemId: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[], priority?: FetchType, ignoreInvalidationSync?: boolean) => void;
204
224
  scheduleItemFetch: {
205
225
  (fetchType: FetchType, itemPayload: ItemPayload): ScheduleFetchResults;
@@ -220,7 +240,7 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
220
240
  } | {
221
241
  items: {
222
242
  data: ItemState;
223
- itemKey: string;
243
+ itemPayload: ItemPayload;
224
244
  }[];
225
245
  error: null;
226
246
  hasMore: boolean;
@@ -229,7 +249,7 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
229
249
  id: string;
230
250
  data: ItemState;
231
251
  }>(queries: readonly QueryPayload[], { itemSelector, omitPayload, returnIdleStatus, returnRefetchingStatus, loadSize, disableRefetchOnMount, }?: {
232
- itemSelector?: ((data: ItemState, id: string) => SelectedItem) | undefined;
252
+ itemSelector?: ((data: ItemState, id: ItemPayload) => SelectedItem) | undefined;
233
253
  omitPayload?: boolean | undefined;
234
254
  disableRefetchOnMount?: boolean | undefined;
235
255
  returnIdleStatus?: boolean | undefined;
@@ -240,7 +260,7 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
240
260
  id: string;
241
261
  data: ItemState;
242
262
  }>(payload: QueryPayload | false | null | undefined, options?: {
243
- itemSelector?: ((data: ItemState, id: string) => SelectedItem_1) | undefined;
263
+ itemSelector?: ((data: ItemState, id: ItemPayload) => SelectedItem_1) | undefined;
244
264
  omitPayload?: boolean | undefined;
245
265
  disableRefetchOnMount?: boolean | undefined;
246
266
  returnIdleStatus?: boolean | undefined;
@@ -250,22 +270,36 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
250
270
  }) => TSFDUseListQueryReturn<SelectedItem_1, QueryPayload, NError>;
251
271
  getItemKey: (params: ItemPayload) => string;
252
272
  useItem: <SelectedItem_2 = ItemState | null>(itemPayload: ItemPayload | false | null | undefined, options?: {
253
- selector?: ((data: ItemState | null, id: string) => SelectedItem_2) | undefined;
273
+ selector?: ((data: ItemState | null, id: ItemPayload | null) => SelectedItem_2) | undefined;
254
274
  disableRefetchOnMount?: boolean | undefined;
255
275
  returnIdleStatus?: boolean | undefined;
256
276
  returnRefetchingStatus?: boolean | undefined;
257
277
  ensureIsLoaded?: boolean | undefined;
278
+ loadFromStateOnly?: boolean | undefined;
258
279
  }) => TSFDUseListItemReturn<SelectedItem_2, NError, ItemPayload>;
259
- useMultipleItems: <SelectedItem_3 = ItemState | null>(itemsPayload_: ItemPayload[], { selector, returnIdleStatus, returnRefetchingStatus, disableRefetchOnMount, }?: {
260
- selector?: ((data: ItemState | null, id: string) => SelectedItem_3) | undefined;
280
+ useMultipleItems: <SelectedItem_3 = ItemState | null>(itemsPayload_: ItemPayload[], { selector, returnIdleStatus, returnRefetchingStatus, disableRefetchOnMount, loadFromStateOnly, }?: {
281
+ selector?: ((data: ItemState | null, id: ItemPayload | null) => SelectedItem_3) | undefined;
261
282
  disableRefetchOnMount?: boolean | undefined;
262
283
  returnIdleStatus?: boolean | undefined;
263
284
  returnRefetchingStatus?: boolean | undefined;
285
+ loadFromStateOnly?: boolean | undefined;
264
286
  }) => readonly TSFDUseListItemReturn<SelectedItem_3, NError, ItemPayload>[];
265
- addItemToState: (itemPayload: ItemPayload, data: ItemState) => void;
266
- updateItemState: (itemIds: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[], produceNewData: (draftData: ItemState, itemPayload: ItemPayload) => void | ItemState, ifNothingWasUpdated?: () => void) => boolean;
287
+ addItemToState: (itemPayload: ItemPayload, data: ItemState, { addItemToQueries, }?: {
288
+ addItemToQueries?: {
289
+ queries: QueryPayload | ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean) | QueryPayload[];
290
+ appendTo: "start" | "end" | ((itemsPayload: ItemPayload[]) => number);
291
+ } | undefined;
292
+ }) => void;
293
+ updateItemState: (itemIds: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[], produceNewData: (draftData: ItemState, itemPayload: ItemPayload) => void | ItemState, { ifNothingWasUpdated, }?: {
294
+ ifNothingWasUpdated?: (() => void) | undefined;
295
+ }) => boolean;
267
296
  startItemMutation: (itemId: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[]) => () => void;
297
+ getQueriesState: (params: ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean) | QueryPayload[]) => TSFDListQuery<NError, QueryPayload>[];
298
+ getQueriesRelatedToItem: (itemPayload: ItemPayload) => TSFDListQuery<NError, QueryPayload>[];
299
+ useFindItem: <SelectedItem_4 = ItemState | null>(findItem: (item: ItemState, itemPayload: ItemPayload) => boolean, { selector, }?: {
300
+ selector?: ((data: ItemState, id: ItemPayload) => SelectedItem_4) | undefined;
301
+ }) => Readonly<SelectedItem_4 | null>;
268
302
  };
269
303
  type TSFDListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = ReturnType<typeof newTSDFListQueryStore<ItemState, NError, QueryPayload, ItemPayload>>;
270
304
 
271
- export { FetchListFnReturn, TSDFCollectionStore, TSDFDocumentStore, TSDFDocumentStoreState, TSDFItemQuery, TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, TSFDListQuery, TSFDListQueryState, TSFDListQueryStore, TSFDUseCollectionItemReturn, TSFDUseListItemReturn, TSFDUseListQueryReturn, ValidPayload, ValidStoreState, newTSDFCollectionStore, newTSDFDocumentStore, newTSDFListQueryStore };
305
+ export { CollectionInitialStateItem, FetchListFnReturn, ListQueryStoreInitialData, TSDFCollectionStore, TSDFDocumentStore, TSDFDocumentStoreState, TSDFItemQuery, TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, TSFDListQuery, TSFDListQueryState, TSFDListQueryStore, TSFDUseCollectionItemReturn, TSFDUseListItemReturn, TSFDUseListQueryReturn, ValidPayload, ValidStoreState, newTSDFCollectionStore, newTSDFDocumentStore, newTSDFListQueryStore };