tsdf 11.2.0 → 11.2.2
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.cjs +2 -2
- package/dist/main.d.cts +308 -0
- package/dist/main.js +2 -2
- package/package.json +22 -22
package/dist/main.cjs
CHANGED
|
@@ -916,7 +916,7 @@ function newTSDFCollectionStore({
|
|
|
916
916
|
const shouldFetch = !itemState?.wasLoaded || itemState.refetchOnMount;
|
|
917
917
|
if (shouldFetch) {
|
|
918
918
|
scheduleFetch(fetchType, payload);
|
|
919
|
-
|
|
919
|
+
continue;
|
|
920
920
|
}
|
|
921
921
|
} else {
|
|
922
922
|
scheduleFetch(fetchType, payload);
|
|
@@ -1498,7 +1498,7 @@ function newTSDFListQueryStore({
|
|
|
1498
1498
|
const shouldFetch = !itemState || !itemState.wasLoaded || itemState.refetchOnMount;
|
|
1499
1499
|
if (shouldFetch) {
|
|
1500
1500
|
scheduleListQueryFetch(fetchType, fetchParams, loadSizeConst);
|
|
1501
|
-
|
|
1501
|
+
continue;
|
|
1502
1502
|
}
|
|
1503
1503
|
} else {
|
|
1504
1504
|
scheduleListQueryFetch(fetchType, fetchParams, loadSizeConst);
|
package/dist/main.d.cts
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
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
|
+
declare function newTSDFDocumentStore<State extends ValidStoreState, NError>({ debugName, fetchFn, initialData, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, disableInitialDataInvalidation, errorNormalizer, }: {
|
|
24
|
+
debugName?: string;
|
|
25
|
+
fetchFn: () => Promise<State>;
|
|
26
|
+
initialData?: State;
|
|
27
|
+
disableInitialDataInvalidation?: boolean;
|
|
28
|
+
errorNormalizer: (exception: unknown) => NError;
|
|
29
|
+
disableRefetchOnMount?: boolean;
|
|
30
|
+
lowPriorityThrottleMs?: number;
|
|
31
|
+
mediumPriorityThrottleMs?: number;
|
|
32
|
+
dynamicRealtimeThrottleMs?: (lastFetchDuration: number) => number;
|
|
33
|
+
}): {
|
|
34
|
+
store: Store<TSDFDocumentStoreState<State, NError>>;
|
|
35
|
+
reset: () => void;
|
|
36
|
+
awaitFetch: () => Promise<{
|
|
37
|
+
data: State;
|
|
38
|
+
error: null;
|
|
39
|
+
} | {
|
|
40
|
+
data: null;
|
|
41
|
+
error: NError;
|
|
42
|
+
}>;
|
|
43
|
+
scheduleFetch: (fetchType: FetchType) => ScheduleFetchResults;
|
|
44
|
+
invalidateData: (priority?: FetchType) => void;
|
|
45
|
+
useDocument: <Selected = State | null>({ selector, disabled, returnRefetchingStatus, disableRefetchOnMount, returnIdleStatus, ensureIsLoaded, }?: {
|
|
46
|
+
selector?: ((data: State | null) => Selected) | undefined;
|
|
47
|
+
disabled?: boolean | undefined;
|
|
48
|
+
disableRefetchOnMount?: boolean | undefined;
|
|
49
|
+
returnIdleStatus?: boolean | undefined;
|
|
50
|
+
ensureIsLoaded?: boolean | undefined;
|
|
51
|
+
returnRefetchingStatus?: boolean | undefined;
|
|
52
|
+
}) => Readonly<TSDFUseDocumentReturn<Selected, NError>>;
|
|
53
|
+
updateState: (produceNewData: (draftData: State) => State | void | undefined) => boolean;
|
|
54
|
+
startMutation: () => () => boolean;
|
|
55
|
+
};
|
|
56
|
+
type TSDFDocumentStore<State extends ValidStoreState, NError> = ReturnType<typeof newTSDFDocumentStore<State, NError>>;
|
|
57
|
+
|
|
58
|
+
type CollectionItemStatus = TSDFStatus;
|
|
59
|
+
type TSFDCollectionItem<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, NError> = {
|
|
60
|
+
data: ItemState | null;
|
|
61
|
+
error: NError | null;
|
|
62
|
+
status: CollectionItemStatus;
|
|
63
|
+
payload: ItemPayload;
|
|
64
|
+
refetchOnMount: false | FetchType;
|
|
65
|
+
wasLoaded: boolean;
|
|
66
|
+
};
|
|
67
|
+
type TSFDCollectionState<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, NError> = Record<string, TSFDCollectionItem<ItemState, ItemPayload, NError> | null>;
|
|
68
|
+
type TSFDUseCollectionItemReturn<Selected, ItemPayload, NError> = {
|
|
69
|
+
data: Selected;
|
|
70
|
+
status: CollectionItemStatus | 'idle' | 'deleted';
|
|
71
|
+
payload: ItemPayload | undefined;
|
|
72
|
+
error: NError | null;
|
|
73
|
+
itemStateKey: string;
|
|
74
|
+
isLoading: boolean;
|
|
75
|
+
};
|
|
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, lowPriorityThrottleMs, errorNormalizer, disableInitialDataInvalidation, mediumPriorityThrottleMs, initialStateItems, disableRefetchOnMount: globalDisableRefetchOnMount, dynamicRealtimeThrottleMs, getCollectionItemKey: filterCollectionItemObjKey, }: {
|
|
81
|
+
debugName?: string;
|
|
82
|
+
fetchFn: (params: ItemPayload) => Promise<ItemState>;
|
|
83
|
+
getCollectionItemKey?: (params: ItemPayload) => ValidPayload | any[];
|
|
84
|
+
errorNormalizer: (exception: unknown) => NError;
|
|
85
|
+
disableRefetchOnMount?: boolean;
|
|
86
|
+
initialStateItems?: CollectionInitialStateItem<ItemPayload, ItemState>[];
|
|
87
|
+
disableInitialDataInvalidation?: boolean;
|
|
88
|
+
lowPriorityThrottleMs?: number;
|
|
89
|
+
mediumPriorityThrottleMs?: number;
|
|
90
|
+
dynamicRealtimeThrottleMs?: (lastFetchDuration: number) => number;
|
|
91
|
+
}): {
|
|
92
|
+
store: Store<TSFDCollectionState<ItemState, ItemPayload, NError>>;
|
|
93
|
+
scheduleFetch: {
|
|
94
|
+
(fetchType: FetchType, payload: ItemPayload): ScheduleFetchResults;
|
|
95
|
+
(fetchType: FetchType, payload: ItemPayload[]): ScheduleFetchResults[];
|
|
96
|
+
};
|
|
97
|
+
awaitFetch: (params: ItemPayload) => Promise<{
|
|
98
|
+
data: null;
|
|
99
|
+
error: NError;
|
|
100
|
+
} | {
|
|
101
|
+
data: ItemState;
|
|
102
|
+
error: null;
|
|
103
|
+
}>;
|
|
104
|
+
useMultipleItems: <Selected = ItemState | null>(queries: readonly ItemPayload[], { selector, omitPayload, returnIdleStatus, returnRefetchingStatus, disableRefetchOnMount, }?: {
|
|
105
|
+
selector?: ((data: ItemState | null) => Selected) | undefined;
|
|
106
|
+
omitPayload?: boolean | undefined;
|
|
107
|
+
disableRefetchOnMount?: boolean | undefined;
|
|
108
|
+
returnIdleStatus?: boolean | undefined;
|
|
109
|
+
returnRefetchingStatus?: boolean | undefined;
|
|
110
|
+
}) => readonly TSFDUseCollectionItemReturn<Selected, ItemPayload, NError>[];
|
|
111
|
+
useItem: <Selected_1 = ItemState | null>(payload: ItemPayload | undefined | false | null, options?: {
|
|
112
|
+
selector?: ((data: ItemState | null) => Selected_1) | undefined;
|
|
113
|
+
omitPayload?: boolean | undefined;
|
|
114
|
+
returnRefetchingStatus?: boolean | undefined;
|
|
115
|
+
disableRefetchOnMount?: boolean | undefined;
|
|
116
|
+
ensureIsLoaded?: boolean | undefined;
|
|
117
|
+
returnIdleStatus?: boolean | undefined;
|
|
118
|
+
}) => TSFDUseCollectionItemReturn<Selected_1, ItemPayload, NError>;
|
|
119
|
+
reset: () => void;
|
|
120
|
+
getItemKey: (params: ItemPayload) => string;
|
|
121
|
+
getItemState: {
|
|
122
|
+
(fetchParam: ItemPayload): TSFDCollectionItem<ItemState, ItemPayload, NError> | null | undefined;
|
|
123
|
+
(fetchParams: ItemPayload[] | ((params: ItemPayload, data: ItemState | null) => boolean)): TSFDCollectionItem<ItemState, ItemPayload, NError>[];
|
|
124
|
+
};
|
|
125
|
+
startMutation: (fetchParams: ItemPayload | ItemPayload[] | ((params: ItemPayload, data: ItemState | null) => boolean)) => () => void;
|
|
126
|
+
invalidateItem: (itemPayload: ItemPayload | ItemPayload[] | ((params: ItemPayload, data: ItemState | null) => boolean), priority?: FetchType) => void;
|
|
127
|
+
updateItemState: (fetchParams: ItemPayload | ItemPayload[] | ((params: ItemPayload, data: ItemState | null) => boolean), produceNewData: (draftData: ItemState, collectionItem: TSFDCollectionItem<ItemState, ItemPayload, NError>) => void | ItemState, ifNothingWasUpdated?: () => void) => boolean;
|
|
128
|
+
addItemToState: (fetchParams: ItemPayload, data: ItemState) => void;
|
|
129
|
+
deleteItemState: (fetchParams: ItemPayload | ItemPayload[] | ((params: ItemPayload, data: ItemState | null) => boolean)) => void;
|
|
130
|
+
};
|
|
131
|
+
type TSDFCollectionStore<ItemState extends ValidStoreState, NError, FetchParams extends ValidPayload> = ReturnType<typeof newTSDFCollectionStore<ItemState, NError, FetchParams>>;
|
|
132
|
+
|
|
133
|
+
type QueryStatus = TSDFStatus | 'loadingMore';
|
|
134
|
+
type TSFDListQuery<NError, QueryPayload extends ValidPayload> = {
|
|
135
|
+
error: NError | null;
|
|
136
|
+
status: QueryStatus;
|
|
137
|
+
payload: QueryPayload;
|
|
138
|
+
hasMore: boolean;
|
|
139
|
+
wasLoaded: boolean;
|
|
140
|
+
refetchOnMount: false | FetchType;
|
|
141
|
+
items: string[];
|
|
142
|
+
};
|
|
143
|
+
type TSDFItemQuery<NError, ItemPayload> = {
|
|
144
|
+
error: NError | null;
|
|
145
|
+
status: Exclude<QueryStatus, 'loadingMore'>;
|
|
146
|
+
wasLoaded: boolean;
|
|
147
|
+
refetchOnMount: false | FetchType;
|
|
148
|
+
payload: ItemPayload;
|
|
149
|
+
};
|
|
150
|
+
type TSFDListQueryState<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
151
|
+
items: Record<string, ItemState | null>;
|
|
152
|
+
queries: Record<string, TSFDListQuery<NError, QueryPayload>>;
|
|
153
|
+
itemQueries: Record<string, TSDFItemQuery<NError, ItemPayload> | null>;
|
|
154
|
+
};
|
|
155
|
+
type TSFDUseListQueryReturn<Selected, ItemPayload, NError> = {
|
|
156
|
+
items: Selected[];
|
|
157
|
+
status: QueryStatus | 'idle';
|
|
158
|
+
payload: ItemPayload | undefined;
|
|
159
|
+
error: NError | null;
|
|
160
|
+
queryKey: string;
|
|
161
|
+
hasMore: boolean;
|
|
162
|
+
isLoading: boolean;
|
|
163
|
+
isLoadingMore: boolean;
|
|
164
|
+
};
|
|
165
|
+
type TSFDUseListItemReturn<Selected, NError, ItemPayload> = {
|
|
166
|
+
data: Selected;
|
|
167
|
+
status: QueryStatus | 'idle' | 'deleted';
|
|
168
|
+
payload: ItemPayload | null;
|
|
169
|
+
error: NError | null;
|
|
170
|
+
isLoading: boolean;
|
|
171
|
+
};
|
|
172
|
+
type FetchListFnReturnItem<ItemPayload extends ValidPayload, ItemState extends ValidStoreState> = {
|
|
173
|
+
itemPayload: ItemPayload;
|
|
174
|
+
data: ItemState;
|
|
175
|
+
};
|
|
176
|
+
type FetchListFnReturn<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = {
|
|
177
|
+
items: FetchListFnReturnItem<ItemPayload, ItemState>[];
|
|
178
|
+
hasMore: boolean;
|
|
179
|
+
};
|
|
180
|
+
type ListQueryStoreInitialData<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
181
|
+
items: {
|
|
182
|
+
payload: ItemPayload;
|
|
183
|
+
data: ItemState;
|
|
184
|
+
}[];
|
|
185
|
+
queries: {
|
|
186
|
+
payload: QueryPayload;
|
|
187
|
+
items: string[];
|
|
188
|
+
hasMore: boolean;
|
|
189
|
+
}[];
|
|
190
|
+
};
|
|
191
|
+
declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>({ debugName, fetchListFn, fetchItemFn, errorNormalizer, defaultQuerySize, initialData, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, disableInitialDataInvalidation, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, syncMutationsAndInvalidations, }: {
|
|
192
|
+
debugName?: string;
|
|
193
|
+
fetchListFn: (payload: QueryPayload, size: number) => Promise<FetchListFnReturn<ItemState, ItemPayload>>;
|
|
194
|
+
fetchItemFn?: (itemId: ItemPayload) => Promise<ItemState>;
|
|
195
|
+
errorNormalizer: (exception: unknown) => NError;
|
|
196
|
+
defaultQuerySize?: number;
|
|
197
|
+
initialData?: ListQueryStoreInitialData<ItemState, QueryPayload, ItemPayload>;
|
|
198
|
+
disableInitialDataInvalidation?: boolean;
|
|
199
|
+
syncMutationsAndInvalidations?: {
|
|
200
|
+
syncQueries: (query1: QueryPayload, query2: QueryPayload) => boolean;
|
|
201
|
+
syncItemAndQuery: (itemPayload: ItemPayload, query: QueryPayload) => boolean;
|
|
202
|
+
};
|
|
203
|
+
disableRefetchOnMount?: boolean;
|
|
204
|
+
lowPriorityThrottleMs?: number;
|
|
205
|
+
mediumPriorityThrottleMs?: number;
|
|
206
|
+
dynamicRealtimeThrottleMs?: (lastFetchDuration: number) => number;
|
|
207
|
+
}): {
|
|
208
|
+
store: Store<TSFDListQueryState<ItemState, NError, QueryPayload, ItemPayload>>;
|
|
209
|
+
reset: () => void;
|
|
210
|
+
scheduleListQueryFetch: {
|
|
211
|
+
(fetchType: FetchType, payload: QueryPayload, size?: number): ScheduleFetchResults;
|
|
212
|
+
(fetchType: FetchType, payload: QueryPayload[], size?: number): ScheduleFetchResults[];
|
|
213
|
+
};
|
|
214
|
+
getQueryState: (params: QueryPayload) => TSFDListQuery<NError, QueryPayload> | undefined;
|
|
215
|
+
getQueryKey: (params: QueryPayload) => string;
|
|
216
|
+
deleteItemState: (itemId: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[]) => void;
|
|
217
|
+
getItemState: {
|
|
218
|
+
(itemPayload: ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[]): {
|
|
219
|
+
payload: ItemPayload;
|
|
220
|
+
data: ItemState;
|
|
221
|
+
}[];
|
|
222
|
+
(itemPayload: ItemPayload): ItemState | null | undefined;
|
|
223
|
+
};
|
|
224
|
+
loadMore: (params: QueryPayload, size?: number) => ScheduleFetchResults;
|
|
225
|
+
invalidateQuery: (queryPayload: QueryPayload | ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean) | QueryPayload[], priority?: FetchType, ignoreInvalidationSync?: boolean) => void;
|
|
226
|
+
invalidateItem: (itemId: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[], priority?: FetchType, ignoreInvalidationSync?: boolean) => void;
|
|
227
|
+
scheduleItemFetch: {
|
|
228
|
+
(fetchType: FetchType, itemPayload: ItemPayload): ScheduleFetchResults;
|
|
229
|
+
(fetchType: FetchType, itemPayload: ItemPayload[]): ScheduleFetchResults[];
|
|
230
|
+
};
|
|
231
|
+
awaitItemFetch: (itemPayload: ItemPayload) => Promise<{
|
|
232
|
+
data: null;
|
|
233
|
+
error: NError;
|
|
234
|
+
} | {
|
|
235
|
+
data: ItemState;
|
|
236
|
+
error: null;
|
|
237
|
+
}>;
|
|
238
|
+
awaitListQueryFetch: (params: QueryPayload, size?: number) => Promise<{
|
|
239
|
+
items: [
|
|
240
|
+
];
|
|
241
|
+
error: NError;
|
|
242
|
+
hasMore: boolean;
|
|
243
|
+
} | {
|
|
244
|
+
items: {
|
|
245
|
+
data: ItemState;
|
|
246
|
+
itemPayload: ItemPayload;
|
|
247
|
+
}[];
|
|
248
|
+
error: null;
|
|
249
|
+
hasMore: boolean;
|
|
250
|
+
}>;
|
|
251
|
+
useMultipleListQueries: <SelectedItem = ItemState>(queries: readonly QueryPayload[], { itemSelector, omitPayload, returnIdleStatus, returnRefetchingStatus, loadSize, disableRefetchOnMount, }?: {
|
|
252
|
+
itemSelector?: ((data: ItemState, id: ItemPayload, itemKey: string) => SelectedItem) | undefined;
|
|
253
|
+
omitPayload?: boolean | undefined;
|
|
254
|
+
disableRefetchOnMount?: boolean | undefined;
|
|
255
|
+
returnIdleStatus?: boolean | undefined;
|
|
256
|
+
returnRefetchingStatus?: boolean | undefined;
|
|
257
|
+
loadSize?: number | undefined;
|
|
258
|
+
}) => readonly TSFDUseListQueryReturn<SelectedItem, QueryPayload, NError>[];
|
|
259
|
+
useListQuery: <SelectedItem_1 = ItemState>(payload: QueryPayload | false | null | undefined, options?: {
|
|
260
|
+
itemSelector?: ((data: ItemState, id: ItemPayload, itemKey: string) => SelectedItem_1) | undefined;
|
|
261
|
+
omitPayload?: boolean | undefined;
|
|
262
|
+
disableRefetchOnMount?: boolean | undefined;
|
|
263
|
+
returnIdleStatus?: boolean | undefined;
|
|
264
|
+
returnRefetchingStatus?: boolean | undefined;
|
|
265
|
+
ensureIsLoaded?: boolean | undefined;
|
|
266
|
+
loadSize?: number | undefined;
|
|
267
|
+
}) => TSFDUseListQueryReturn<SelectedItem_1, QueryPayload, NError>;
|
|
268
|
+
getItemKey: (params: ItemPayload) => string;
|
|
269
|
+
useItem: <SelectedItem_2 = ItemState | null>(itemPayload: ItemPayload | false | null | undefined, options?: {
|
|
270
|
+
selector?: ((data: ItemState | null, id: ItemPayload | null) => SelectedItem_2) | undefined;
|
|
271
|
+
disableRefetchOnMount?: boolean | undefined;
|
|
272
|
+
returnIdleStatus?: boolean | undefined;
|
|
273
|
+
returnRefetchingStatus?: boolean | undefined;
|
|
274
|
+
ensureIsLoaded?: boolean | undefined;
|
|
275
|
+
loadFromStateOnly?: boolean | undefined;
|
|
276
|
+
}) => TSFDUseListItemReturn<SelectedItem_2, NError, ItemPayload>;
|
|
277
|
+
useMultipleItems: <SelectedItem_3 = ItemState | null>(itemsPayload_: ItemPayload[], { selector, returnIdleStatus, returnRefetchingStatus, disableRefetchOnMount, loadFromStateOnly, }?: {
|
|
278
|
+
selector?: ((data: ItemState | null, id: ItemPayload | null) => SelectedItem_3) | undefined;
|
|
279
|
+
disableRefetchOnMount?: boolean | undefined;
|
|
280
|
+
returnIdleStatus?: boolean | undefined;
|
|
281
|
+
returnRefetchingStatus?: boolean | undefined;
|
|
282
|
+
loadFromStateOnly?: boolean | undefined;
|
|
283
|
+
}) => readonly TSFDUseListItemReturn<SelectedItem_3, NError, ItemPayload>[];
|
|
284
|
+
addItemToState: (itemPayload: ItemPayload, data: ItemState, { addItemToQueries, }?: {
|
|
285
|
+
addItemToQueries?: {
|
|
286
|
+
queries: QueryPayload | ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean) | QueryPayload[];
|
|
287
|
+
appendTo: "start" | "end" | ((itemsPayload: ItemPayload[]) => number);
|
|
288
|
+
} | undefined;
|
|
289
|
+
}) => void;
|
|
290
|
+
updateItemState: (itemIds: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[], produceNewData: (draftData: ItemState, itemPayload: ItemPayload) => void | ItemState, { ifNothingWasUpdated, }?: {
|
|
291
|
+
ifNothingWasUpdated?: (() => void) | undefined;
|
|
292
|
+
}) => boolean;
|
|
293
|
+
startItemMutation: (itemId: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[]) => () => void;
|
|
294
|
+
getQueriesState: (params: ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean) | QueryPayload[]) => {
|
|
295
|
+
query: TSFDListQuery<NError, QueryPayload>;
|
|
296
|
+
key: string;
|
|
297
|
+
}[];
|
|
298
|
+
getQueriesRelatedToItem: (itemPayload: ItemPayload) => {
|
|
299
|
+
query: TSFDListQuery<NError, QueryPayload>;
|
|
300
|
+
key: string;
|
|
301
|
+
}[];
|
|
302
|
+
useFindItem: <SelectedItem_4 = ItemState | null>(findItem: (item: ItemState, itemPayload: ItemPayload) => boolean, { selector, }?: {
|
|
303
|
+
selector?: ((data: ItemState, id: ItemPayload) => SelectedItem_4) | undefined;
|
|
304
|
+
}) => Readonly<SelectedItem_4 | null>;
|
|
305
|
+
};
|
|
306
|
+
type TSFDListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = ReturnType<typeof newTSDFListQueryStore<ItemState, NError, QueryPayload, ItemPayload>>;
|
|
307
|
+
|
|
308
|
+
export { CollectionInitialStateItem, FetchListFnReturn, FetchListFnReturnItem, ListQueryStoreInitialData, TSDFCollectionStore, TSDFDocumentStore, TSDFDocumentStoreState, TSDFItemQuery, TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, TSFDListQuery, TSFDListQueryState, TSFDListQueryStore, TSFDUseCollectionItemReturn, TSFDUseListItemReturn, TSFDUseListQueryReturn, ValidPayload, ValidStoreState, newTSDFCollectionStore, newTSDFDocumentStore, newTSDFListQueryStore };
|
package/dist/main.js
CHANGED
|
@@ -888,7 +888,7 @@ function newTSDFCollectionStore({
|
|
|
888
888
|
const shouldFetch = !itemState?.wasLoaded || itemState.refetchOnMount;
|
|
889
889
|
if (shouldFetch) {
|
|
890
890
|
scheduleFetch(fetchType, payload);
|
|
891
|
-
|
|
891
|
+
continue;
|
|
892
892
|
}
|
|
893
893
|
} else {
|
|
894
894
|
scheduleFetch(fetchType, payload);
|
|
@@ -1470,7 +1470,7 @@ function newTSDFListQueryStore({
|
|
|
1470
1470
|
const shouldFetch = !itemState || !itemState.wasLoaded || itemState.refetchOnMount;
|
|
1471
1471
|
if (shouldFetch) {
|
|
1472
1472
|
scheduleListQueryFetch(fetchType, fetchParams, loadSizeConst);
|
|
1473
|
-
|
|
1473
|
+
continue;
|
|
1474
1474
|
}
|
|
1475
1475
|
} else {
|
|
1476
1476
|
scheduleListQueryFetch(fetchType, fetchParams, loadSizeConst);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdf",
|
|
3
|
-
"version": "11.2.
|
|
3
|
+
"version": "11.2.2",
|
|
4
4
|
"description": "A data fetching solution based on t-state",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Lucas Santos",
|
|
@@ -36,38 +36,38 @@
|
|
|
36
36
|
"npm-publish": "./scripts/check-if-is-sync.sh && pnpm build && npm publish"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@lucasols/eslint-plugin-extended-lint": "^0.
|
|
40
|
-
"@testing-library/jest-dom": "^5.
|
|
41
|
-
"@testing-library/react": "^
|
|
42
|
-
"@types/node": "^
|
|
39
|
+
"@lucasols/eslint-plugin-extended-lint": "^0.10.0",
|
|
40
|
+
"@testing-library/jest-dom": "^5.17.0",
|
|
41
|
+
"@testing-library/react": "^14.0.0",
|
|
42
|
+
"@types/node": "^20.4.5",
|
|
43
43
|
"@types/react": "^18.0.26",
|
|
44
44
|
"@types/react-dom": "^18.0.10",
|
|
45
|
-
"@types/testing-library__jest-dom": "^5.14.
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
47
|
-
"@typescript-eslint/parser": "^
|
|
48
|
-
"@vitest/ui": "0.
|
|
49
|
-
"eslint": "^8.
|
|
45
|
+
"@types/testing-library__jest-dom": "^5.14.9",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^6.2.0",
|
|
47
|
+
"@typescript-eslint/parser": "^6.2.0",
|
|
48
|
+
"@vitest/ui": "0.33.0",
|
|
49
|
+
"eslint": "^8.46.0",
|
|
50
50
|
"eslint-plugin-local-rules": "^1.3.2",
|
|
51
51
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
52
|
-
"eslint-plugin-vitest": "^0.
|
|
53
|
-
"happy-dom": "^
|
|
54
|
-
"jsdom": "^
|
|
55
|
-
"prettier": "^
|
|
56
|
-
"pretty-format": "^29.
|
|
52
|
+
"eslint-plugin-vitest": "^0.2.8",
|
|
53
|
+
"happy-dom": "^10.5.2",
|
|
54
|
+
"jsdom": "^22.1.0",
|
|
55
|
+
"prettier": "^3.0.0",
|
|
56
|
+
"pretty-format": "^29.6.2",
|
|
57
57
|
"react": "^18.2.0",
|
|
58
58
|
"react-dom": "^18.2.0",
|
|
59
59
|
"tiny-glob": "^0.2.9",
|
|
60
60
|
"tsm": "^2.3.0",
|
|
61
|
-
"tsup": "^
|
|
62
|
-
"typescript": "^5.
|
|
63
|
-
"vite": "^4.
|
|
64
|
-
"vitest": "^0.
|
|
61
|
+
"tsup": "^7.1.0",
|
|
62
|
+
"typescript": "^5.1.6",
|
|
63
|
+
"vite": "^4.4.7",
|
|
64
|
+
"vitest": "^0.33.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"evtmitter": "^0.3.
|
|
68
|
-
"immer": "^
|
|
67
|
+
"evtmitter": "^0.3.3",
|
|
68
|
+
"immer": "^10.0.2",
|
|
69
69
|
"klona": "^2.0.6",
|
|
70
|
-
"t-state": "^8.
|
|
70
|
+
"t-state": "^8.8.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"react": "^18.0.0",
|