tsdf 8.0.0-beta.3 → 8.0.0-beta.5
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 +1794 -1
- package/dist/main.d.ts +32 -30
- package/dist/main.js +1759 -1
- package/package.json +3 -2
package/dist/main.d.ts
CHANGED
|
@@ -132,16 +132,17 @@ type TSFDListQuery<NError, QueryPayload extends ValidPayload> = {
|
|
|
132
132
|
refetchOnMount: false | FetchType;
|
|
133
133
|
items: string[];
|
|
134
134
|
};
|
|
135
|
-
type TSDFItemQuery<NError> = {
|
|
135
|
+
type TSDFItemQuery<NError, ItemPayload> = {
|
|
136
136
|
error: NError | null;
|
|
137
137
|
status: Exclude<QueryStatus, 'loadingMore'>;
|
|
138
138
|
wasLoaded: boolean;
|
|
139
139
|
refetchOnMount: false | FetchType;
|
|
140
|
+
payload: ItemPayload;
|
|
140
141
|
};
|
|
141
|
-
type TSFDListQueryState<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload> = {
|
|
142
|
+
type TSFDListQueryState<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
142
143
|
items: Record<string, ItemState | null>;
|
|
143
144
|
queries: Record<string, TSFDListQuery<NError, QueryPayload>>;
|
|
144
|
-
itemQueries: Record<string, TSDFItemQuery<NError> | null>;
|
|
145
|
+
itemQueries: Record<string, TSDFItemQuery<NError, ItemPayload> | null>;
|
|
145
146
|
};
|
|
146
147
|
type TSFDUseListQueryReturn<Selected, ItemPayload, NError> = {
|
|
147
148
|
items: Selected[];
|
|
@@ -152,59 +153,59 @@ type TSFDUseListQueryReturn<Selected, ItemPayload, NError> = {
|
|
|
152
153
|
hasMore: boolean;
|
|
153
154
|
isLoading: boolean;
|
|
154
155
|
};
|
|
155
|
-
type TSFDUseItemReturn<Selected, NError> = {
|
|
156
|
+
type TSFDUseItemReturn<Selected, NError, ItemPayload> = {
|
|
156
157
|
data: Selected;
|
|
157
158
|
status: QueryStatus | 'idle' | 'deleted';
|
|
158
|
-
|
|
159
|
+
payload: ItemPayload | null;
|
|
159
160
|
error: NError | null;
|
|
160
161
|
isLoading: boolean;
|
|
161
162
|
};
|
|
162
|
-
type FetchListFnReturn<ItemState extends ValidStoreState> = {
|
|
163
|
+
type FetchListFnReturn<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = {
|
|
163
164
|
items: {
|
|
164
|
-
|
|
165
|
+
itemPayload: ItemPayload;
|
|
165
166
|
data: ItemState;
|
|
166
167
|
}[];
|
|
167
168
|
hasMore: boolean;
|
|
168
169
|
};
|
|
169
|
-
declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload>({ debugName, fetchListFn, fetchItemFn, errorNormalizer, defaultQuerySize, disableRefetchOnWindowFocus, disableRefetchOnMount: globalDisableRefetchOnMount, lowPriorityThrottleMs, mediumPriorityThrottleMs, dynamicRealtimeThrottleMs, syncMutationsAndInvalidations, }: {
|
|
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, }: {
|
|
170
171
|
debugName?: string;
|
|
171
|
-
fetchListFn: (payload: QueryPayload, size: number) => Promise<FetchListFnReturn<ItemState>>;
|
|
172
|
-
fetchItemFn?: (itemId:
|
|
172
|
+
fetchListFn: (payload: QueryPayload, size: number) => Promise<FetchListFnReturn<ItemState, ItemPayload>>;
|
|
173
|
+
fetchItemFn?: (itemId: ItemPayload) => Promise<ItemState>;
|
|
173
174
|
errorNormalizer: (exception: unknown) => NError;
|
|
174
175
|
defaultQuerySize?: number;
|
|
175
176
|
disableRefetchOnWindowFocus?: boolean;
|
|
176
177
|
syncMutationsAndInvalidations?: {
|
|
177
178
|
syncQueries: (query1: QueryPayload, query2: QueryPayload) => boolean;
|
|
178
|
-
syncItemAndQuery: (
|
|
179
|
+
syncItemAndQuery: (itemPayload: ItemPayload, query: QueryPayload) => boolean;
|
|
179
180
|
};
|
|
180
181
|
disableRefetchOnMount?: boolean;
|
|
181
182
|
lowPriorityThrottleMs?: number;
|
|
182
183
|
mediumPriorityThrottleMs?: number;
|
|
183
184
|
dynamicRealtimeThrottleMs?: (lastFetchDuration: number) => number;
|
|
184
185
|
}): {
|
|
185
|
-
store: Store<TSFDListQueryState<ItemState, NError, QueryPayload>>;
|
|
186
|
+
store: Store<TSFDListQueryState<ItemState, NError, QueryPayload, ItemPayload>>;
|
|
186
187
|
scheduleListQueryFetch: {
|
|
187
188
|
(fetchType: FetchType, payload: QueryPayload, size?: number): ScheduleFetchResults;
|
|
188
189
|
(fetchType: FetchType, payload: QueryPayload[], size?: number): ScheduleFetchResults[];
|
|
189
190
|
};
|
|
190
191
|
getQueryState: (params: QueryPayload) => TSFDListQuery<NError, QueryPayload> | undefined;
|
|
191
192
|
getQueryKey: (params: QueryPayload) => string;
|
|
192
|
-
deleteItemState: (itemId:
|
|
193
|
+
deleteItemState: (itemId: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[]) => void;
|
|
193
194
|
getItemState: {
|
|
194
|
-
(
|
|
195
|
-
|
|
195
|
+
(itemPayload: ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[]): {
|
|
196
|
+
payload: ItemPayload;
|
|
196
197
|
data: ItemState;
|
|
197
198
|
}[];
|
|
198
|
-
(
|
|
199
|
+
(itemPayload: ItemPayload): ItemState | null | undefined;
|
|
199
200
|
};
|
|
200
201
|
loadMore: (params: QueryPayload, size: number) => ScheduleFetchResults;
|
|
201
202
|
invalidateQuery: (queryPayload: QueryPayload | QueryPayload[] | ((params: QueryPayload, data: TSFDListQuery<NError, QueryPayload>, queryKey: string) => boolean), priority?: FetchType, ignoreInvalidationSync?: boolean) => void;
|
|
202
|
-
invalidateItem: (itemId:
|
|
203
|
+
invalidateItem: (itemId: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[], priority?: FetchType, ignoreInvalidationSync?: boolean) => void;
|
|
203
204
|
scheduleItemFetch: {
|
|
204
|
-
(fetchType: FetchType,
|
|
205
|
-
(fetchType: FetchType,
|
|
205
|
+
(fetchType: FetchType, itemPayload: ItemPayload): ScheduleFetchResults;
|
|
206
|
+
(fetchType: FetchType, itemPayload: ItemPayload[]): ScheduleFetchResults[];
|
|
206
207
|
};
|
|
207
|
-
awaitItemFetch: (
|
|
208
|
+
awaitItemFetch: (itemPayload: ItemPayload) => Promise<{
|
|
208
209
|
data: null;
|
|
209
210
|
error: NError;
|
|
210
211
|
} | {
|
|
@@ -219,7 +220,7 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
|
|
|
219
220
|
} | {
|
|
220
221
|
items: {
|
|
221
222
|
data: ItemState;
|
|
222
|
-
|
|
223
|
+
itemKey: string;
|
|
223
224
|
}[];
|
|
224
225
|
error: null;
|
|
225
226
|
hasMore: boolean;
|
|
@@ -247,23 +248,24 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
|
|
|
247
248
|
ensureIsLoaded?: boolean | undefined;
|
|
248
249
|
loadSize?: number | undefined;
|
|
249
250
|
}) => TSFDUseListQueryReturn<SelectedItem_1, QueryPayload, NError>;
|
|
250
|
-
|
|
251
|
+
getItemKey: (params: ItemPayload) => string;
|
|
252
|
+
useItem: <SelectedItem_2 = ItemState>(itemPayload: ItemPayload | false | null | undefined, options?: {
|
|
251
253
|
selector?: ((data: ItemState | null, id: string) => SelectedItem_2) | undefined;
|
|
252
254
|
disableRefetchOnMount?: boolean | undefined;
|
|
253
255
|
returnIdleStatus?: boolean | undefined;
|
|
254
256
|
returnRefetchingStatus?: boolean | undefined;
|
|
255
257
|
ensureIsLoaded?: boolean | undefined;
|
|
256
|
-
}) => TSFDUseItemReturn<SelectedItem_2, NError>;
|
|
257
|
-
useMultipleItems: <SelectedItem_3 = ItemState>(
|
|
258
|
+
}) => TSFDUseItemReturn<SelectedItem_2, NError, ItemPayload>;
|
|
259
|
+
useMultipleItems: <SelectedItem_3 = ItemState>(itemsPayload_: ItemPayload[], { selector, returnIdleStatus, returnRefetchingStatus, disableRefetchOnMount, }?: {
|
|
258
260
|
selector?: ((data: ItemState | null, id: string) => SelectedItem_3) | undefined;
|
|
259
261
|
disableRefetchOnMount?: boolean | undefined;
|
|
260
262
|
returnIdleStatus?: boolean | undefined;
|
|
261
263
|
returnRefetchingStatus?: boolean | undefined;
|
|
262
|
-
}) => readonly TSFDUseItemReturn<SelectedItem_3, NError>[];
|
|
263
|
-
addItemToState: (
|
|
264
|
-
updateItemState: (itemIds:
|
|
265
|
-
startItemMutation: (itemId:
|
|
264
|
+
}) => readonly TSFDUseItemReturn<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;
|
|
267
|
+
startItemMutation: (itemId: ItemPayload | ((ItemPayload: ItemPayload, itemState: ItemState) => boolean) | ItemPayload[]) => () => void;
|
|
266
268
|
};
|
|
267
|
-
type TSFDListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload> = ReturnType<typeof newTSDFListQueryStore<ItemState, NError, QueryPayload>>;
|
|
269
|
+
type TSFDListQueryStore<ItemState extends ValidStoreState, NError, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = ReturnType<typeof newTSDFListQueryStore<ItemState, NError, QueryPayload, ItemPayload>>;
|
|
268
270
|
|
|
269
|
-
export { TSDFCollectionStore, TSDFDocumentStore, TSDFDocumentStoreState, TSDFItemQuery, TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, TSFDListQuery, TSFDListQueryState, TSFDListQueryStore, TSFDUseCollectionItemReturn, TSFDUseItemReturn, TSFDUseListQueryReturn, ValidPayload, ValidStoreState, newTSDFCollectionStore, newTSDFDocumentStore, newTSDFListQueryStore };
|
|
271
|
+
export { FetchListFnReturn, TSDFCollectionStore, TSDFDocumentStore, TSDFDocumentStoreState, TSDFItemQuery, TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, TSFDListQuery, TSFDListQueryState, TSFDListQueryStore, TSFDUseCollectionItemReturn, TSFDUseItemReturn, TSFDUseListQueryReturn, ValidPayload, ValidStoreState, newTSDFCollectionStore, newTSDFDocumentStore, newTSDFListQueryStore };
|