@panneau/data 4.0.37 → 4.0.40-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/index.d.ts +69 -286
- package/dist/index.js +1202 -1420
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,190 +1,14 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
-
import
|
|
2
|
+
import { UseQueryOptions, UseQueryResult, UseMutationResult, UseMutationOptions, QueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { Item, Pagination, Resource, ResourceItem } from '@panneau/core';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
6
|
|
|
7
|
-
declare function
|
|
8
|
-
initialData?: any;
|
|
9
|
-
autoload?: boolean;
|
|
10
|
-
}): {
|
|
11
|
-
data: any;
|
|
12
|
-
load: (...args: any[]) => any;
|
|
13
|
-
loading: boolean;
|
|
14
|
-
error: boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
declare function useItems$1({ store, url, paginated: initialPaginated, query: initialQuery, onQueryChange, queryConfig, keepData, ...oldProps }: {
|
|
18
|
-
[x: string]: any;
|
|
19
|
-
store: any;
|
|
20
|
-
url: any;
|
|
21
|
-
paginated?: boolean;
|
|
22
|
-
query?: any;
|
|
23
|
-
onQueryChange: any;
|
|
24
|
-
queryConfig?: any;
|
|
25
|
-
keepData?: boolean;
|
|
26
|
-
}): {
|
|
27
|
-
items: any;
|
|
28
|
-
allItems: any;
|
|
29
|
-
pages: any;
|
|
30
|
-
pageItems: any;
|
|
31
|
-
pagination: {
|
|
32
|
-
page: any;
|
|
33
|
-
lastPage: any;
|
|
34
|
-
total: any;
|
|
35
|
-
};
|
|
36
|
-
total: any;
|
|
37
|
-
lastPage: any;
|
|
38
|
-
loaded: boolean;
|
|
39
|
-
allLoaded: boolean;
|
|
40
|
-
loading: boolean;
|
|
41
|
-
loadNextPage: () => void;
|
|
42
|
-
loadPage: (newPage: any) => void;
|
|
43
|
-
reloadPage: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
44
|
-
reload: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
45
|
-
reset: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
46
|
-
updateItem: (item: any) => void;
|
|
47
|
-
status: "error" | "success";
|
|
7
|
+
declare function useItem<T = Item>(scope: any, id: any, loader: (id: any) => Promise<T>, opts?: any): {
|
|
48
8
|
error: Error;
|
|
49
9
|
isError: true;
|
|
50
10
|
isPending: false;
|
|
51
|
-
isLoadingError: false;
|
|
52
|
-
isRefetchError: true;
|
|
53
|
-
isSuccess: false;
|
|
54
|
-
isPlaceholderData: false;
|
|
55
|
-
dataUpdatedAt: number;
|
|
56
|
-
errorUpdatedAt: number;
|
|
57
|
-
failureCount: number;
|
|
58
|
-
failureReason: Error;
|
|
59
|
-
errorUpdateCount: number;
|
|
60
|
-
isFetchedAfterMount: boolean;
|
|
61
|
-
isInitialLoading: boolean;
|
|
62
|
-
isPaused: boolean;
|
|
63
|
-
isStale: boolean;
|
|
64
|
-
isEnabled: boolean;
|
|
65
|
-
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
66
|
-
promise: Promise<unknown>;
|
|
67
|
-
} | {
|
|
68
|
-
items: any;
|
|
69
|
-
allItems: any;
|
|
70
|
-
pages: any;
|
|
71
|
-
pageItems: any;
|
|
72
|
-
pagination: {
|
|
73
|
-
page: any;
|
|
74
|
-
lastPage: any;
|
|
75
|
-
total: any;
|
|
76
|
-
};
|
|
77
|
-
total: any;
|
|
78
|
-
lastPage: any;
|
|
79
|
-
loaded: boolean;
|
|
80
|
-
allLoaded: boolean;
|
|
81
|
-
loading: boolean;
|
|
82
|
-
loadNextPage: () => void;
|
|
83
|
-
loadPage: (newPage: any) => void;
|
|
84
|
-
reloadPage: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
85
|
-
reload: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
86
|
-
reset: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
87
|
-
updateItem: (item: any) => void;
|
|
88
|
-
status: "error" | "success";
|
|
89
|
-
error: Error;
|
|
90
|
-
isError: false;
|
|
91
|
-
isPending: false;
|
|
92
|
-
isLoadingError: false;
|
|
93
|
-
isRefetchError: false;
|
|
94
|
-
isSuccess: true;
|
|
95
|
-
isPlaceholderData: false;
|
|
96
|
-
dataUpdatedAt: number;
|
|
97
|
-
errorUpdatedAt: number;
|
|
98
|
-
failureCount: number;
|
|
99
|
-
failureReason: Error;
|
|
100
|
-
errorUpdateCount: number;
|
|
101
|
-
isFetchedAfterMount: boolean;
|
|
102
|
-
isInitialLoading: boolean;
|
|
103
|
-
isPaused: boolean;
|
|
104
|
-
isStale: boolean;
|
|
105
|
-
isEnabled: boolean;
|
|
106
|
-
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
107
|
-
promise: Promise<unknown>;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
declare function useItems({ getPage, getItems, page, count, items: providedItems, pages: initialPages, getPageFromResponse, getItemsFromResponse, onItemsLoaded, onPageLoaded, onLoaded, onError, }: {
|
|
111
|
-
getPage?: any;
|
|
112
|
-
getItems?: any;
|
|
113
|
-
page?: any;
|
|
114
|
-
count?: number;
|
|
115
|
-
items?: any;
|
|
116
|
-
pages?: any;
|
|
117
|
-
getPageFromResponse?: ({ pagination: { page: currentPage, last_page: lastPage, total, per_page: perPage }, data: items, }: {
|
|
118
|
-
pagination: {
|
|
119
|
-
page: any;
|
|
120
|
-
last_page: any;
|
|
121
|
-
total: any;
|
|
122
|
-
per_page: any;
|
|
123
|
-
};
|
|
124
|
-
data: any;
|
|
125
|
-
}) => {
|
|
126
|
-
page: number;
|
|
127
|
-
lastPage: number;
|
|
128
|
-
total: number;
|
|
129
|
-
count: number;
|
|
130
|
-
items: any;
|
|
131
|
-
};
|
|
132
|
-
getItemsFromResponse?: (data: any) => any;
|
|
133
|
-
onItemsLoaded?: any;
|
|
134
|
-
onPageLoaded?: any;
|
|
135
|
-
onLoaded?: any;
|
|
136
|
-
onError?: any;
|
|
137
|
-
}): {
|
|
138
|
-
items: any;
|
|
139
|
-
pages: any;
|
|
140
|
-
pageItems: any;
|
|
141
|
-
total: any;
|
|
142
|
-
lastPage: any;
|
|
143
|
-
loaded: boolean;
|
|
144
|
-
allLoaded: boolean;
|
|
145
|
-
loading: boolean;
|
|
146
|
-
loadNextPage: () => any;
|
|
147
|
-
loadPage: (pageToLoad: any) => any;
|
|
148
|
-
reloadPage: () => any;
|
|
149
|
-
reload: () => any;
|
|
150
|
-
reset: () => void;
|
|
151
|
-
updateItem: (newItem: any) => void;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
declare function useItemsStore(store: any, { url, getPage, getItems, getPageFromResponse, getItemsFromResponse, page: initialPage, count: initialCount, query, onQueryChange, queryConfig, keepData, }: {
|
|
155
|
-
url?: any;
|
|
156
|
-
getPage?: any;
|
|
157
|
-
getItems?: any;
|
|
158
|
-
getPageFromResponse?: any;
|
|
159
|
-
getItemsFromResponse?: any;
|
|
160
|
-
page?: any;
|
|
161
|
-
count?: any;
|
|
162
|
-
query?: any;
|
|
163
|
-
onQueryChange?: any;
|
|
164
|
-
queryConfig?: any;
|
|
165
|
-
keepData?: boolean;
|
|
166
|
-
}): {
|
|
167
11
|
isLoading: false;
|
|
168
|
-
isFetching: boolean;
|
|
169
|
-
isRefetching: boolean;
|
|
170
|
-
isFetched: boolean;
|
|
171
|
-
items: any;
|
|
172
|
-
pages: any;
|
|
173
|
-
allItems: any;
|
|
174
|
-
loading: boolean;
|
|
175
|
-
loaded: boolean;
|
|
176
|
-
reload: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
177
|
-
loadPage: (newPage: any) => void;
|
|
178
|
-
loadNextPage: () => void;
|
|
179
|
-
updateItem: (item: any) => void;
|
|
180
|
-
pagination: {
|
|
181
|
-
page: any;
|
|
182
|
-
lastPage: any;
|
|
183
|
-
total: any;
|
|
184
|
-
};
|
|
185
|
-
error: Error;
|
|
186
|
-
isError: true;
|
|
187
|
-
isPending: false;
|
|
188
12
|
isLoadingError: false;
|
|
189
13
|
isRefetchError: true;
|
|
190
14
|
isSuccess: false;
|
|
@@ -195,35 +19,23 @@ declare function useItemsStore(store: any, { url, getPage, getItems, getPageFrom
|
|
|
195
19
|
failureCount: number;
|
|
196
20
|
failureReason: Error;
|
|
197
21
|
errorUpdateCount: number;
|
|
22
|
+
isFetched: boolean;
|
|
198
23
|
isFetchedAfterMount: boolean;
|
|
24
|
+
isFetching: boolean;
|
|
199
25
|
isInitialLoading: boolean;
|
|
200
26
|
isPaused: boolean;
|
|
27
|
+
isRefetching: boolean;
|
|
201
28
|
isStale: boolean;
|
|
202
29
|
isEnabled: boolean;
|
|
30
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.NoInfer<T>, Error>>;
|
|
203
31
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
204
|
-
promise: Promise<
|
|
32
|
+
promise: Promise<_tanstack_react_query.NoInfer<T>>;
|
|
33
|
+
item: _tanstack_react_query.NoInfer<T>;
|
|
205
34
|
} | {
|
|
206
|
-
isLoading: false;
|
|
207
|
-
isFetching: boolean;
|
|
208
|
-
isRefetching: boolean;
|
|
209
|
-
isFetched: boolean;
|
|
210
|
-
items: any;
|
|
211
|
-
pages: any;
|
|
212
|
-
allItems: any;
|
|
213
|
-
loading: boolean;
|
|
214
|
-
loaded: boolean;
|
|
215
|
-
reload: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
216
|
-
loadPage: (newPage: any) => void;
|
|
217
|
-
loadNextPage: () => void;
|
|
218
|
-
updateItem: (item: any) => void;
|
|
219
|
-
pagination: {
|
|
220
|
-
page: any;
|
|
221
|
-
lastPage: any;
|
|
222
|
-
total: any;
|
|
223
|
-
};
|
|
224
35
|
error: null;
|
|
225
36
|
isError: false;
|
|
226
37
|
isPending: false;
|
|
38
|
+
isLoading: false;
|
|
227
39
|
isLoadingError: false;
|
|
228
40
|
isRefetchError: false;
|
|
229
41
|
isSuccess: true;
|
|
@@ -234,106 +46,77 @@ declare function useItemsStore(store: any, { url, getPage, getItems, getPageFrom
|
|
|
234
46
|
failureCount: number;
|
|
235
47
|
failureReason: Error;
|
|
236
48
|
errorUpdateCount: number;
|
|
49
|
+
isFetched: boolean;
|
|
237
50
|
isFetchedAfterMount: boolean;
|
|
51
|
+
isFetching: boolean;
|
|
238
52
|
isInitialLoading: boolean;
|
|
239
53
|
isPaused: boolean;
|
|
54
|
+
isRefetching: boolean;
|
|
240
55
|
isStale: boolean;
|
|
241
56
|
isEnabled: boolean;
|
|
57
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.NoInfer<T>, Error>>;
|
|
242
58
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
243
|
-
promise: Promise<
|
|
59
|
+
promise: Promise<_tanstack_react_query.NoInfer<T>>;
|
|
60
|
+
item: _tanstack_react_query.NoInfer<T>;
|
|
244
61
|
};
|
|
245
62
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
63
|
+
type UseItemsResponse<T> = {
|
|
64
|
+
data: T[];
|
|
65
|
+
pagination: Pagination;
|
|
66
|
+
meta?: Pagination;
|
|
67
|
+
} | T[];
|
|
68
|
+
type UseItemsKey = [string, Record<string, unknown> | null, number | null, number | null];
|
|
69
|
+
type UseItemsOptions<T> = UseQueryOptions<UseItemsResponse<T>, Error, UseItemsResponse<T>, UseItemsKey> & {
|
|
70
|
+
url?: string | null;
|
|
71
|
+
getItems?: ((query: Record<string, unknown> | null, page: number | null, count: number | null) => Promise<UseItemsResponse<T>>) | null;
|
|
72
|
+
page?: number | null;
|
|
73
|
+
count?: number | null;
|
|
74
|
+
query?: Record<string, unknown> | null;
|
|
75
|
+
keepData?: boolean;
|
|
256
76
|
};
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
isFetching: boolean;
|
|
261
|
-
isRefetching: boolean;
|
|
262
|
-
isFetched: boolean;
|
|
263
|
-
pages: any;
|
|
264
|
-
allItems: any;
|
|
265
|
-
loading: boolean;
|
|
266
|
-
loaded: boolean;
|
|
267
|
-
reload: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<unknown, Error>>;
|
|
268
|
-
loadPage: (newPage: any) => void;
|
|
269
|
-
loadNextPage: () => void;
|
|
270
|
-
updateItem: (item: any) => void;
|
|
77
|
+
type UseItemsResult<T> = {
|
|
78
|
+
items: T[];
|
|
79
|
+
allItems: T[];
|
|
271
80
|
pagination: {
|
|
272
|
-
page:
|
|
273
|
-
lastPage:
|
|
274
|
-
total:
|
|
275
|
-
};
|
|
276
|
-
error: Error;
|
|
277
|
-
isError: true;
|
|
278
|
-
isPending: false;
|
|
279
|
-
isLoadingError: false;
|
|
280
|
-
isRefetchError: true;
|
|
281
|
-
isSuccess: false;
|
|
282
|
-
isPlaceholderData: false;
|
|
283
|
-
status: "error";
|
|
284
|
-
dataUpdatedAt: number;
|
|
285
|
-
errorUpdatedAt: number;
|
|
286
|
-
failureCount: number;
|
|
287
|
-
failureReason: Error;
|
|
288
|
-
errorUpdateCount: number;
|
|
289
|
-
isFetchedAfterMount: boolean;
|
|
290
|
-
isInitialLoading: boolean;
|
|
291
|
-
isPaused: boolean;
|
|
292
|
-
isStale: boolean;
|
|
293
|
-
isEnabled: boolean;
|
|
294
|
-
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
295
|
-
promise: Promise<unknown>;
|
|
296
|
-
items: any;
|
|
297
|
-
} | {
|
|
298
|
-
isLoading: false;
|
|
299
|
-
isFetching: boolean;
|
|
300
|
-
isRefetching: boolean;
|
|
301
|
-
isFetched: boolean;
|
|
302
|
-
pages: any;
|
|
303
|
-
allItems: any;
|
|
81
|
+
page: number;
|
|
82
|
+
lastPage: number;
|
|
83
|
+
total: number;
|
|
84
|
+
} | null;
|
|
304
85
|
loading: boolean;
|
|
305
86
|
loaded: boolean;
|
|
306
|
-
reload: (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
dataUpdatedAt: number;
|
|
324
|
-
errorUpdatedAt: number;
|
|
325
|
-
failureCount: number;
|
|
326
|
-
failureReason: Error;
|
|
327
|
-
errorUpdateCount: number;
|
|
328
|
-
isFetchedAfterMount: boolean;
|
|
329
|
-
isInitialLoading: boolean;
|
|
330
|
-
isPaused: boolean;
|
|
331
|
-
isStale: boolean;
|
|
332
|
-
isEnabled: boolean;
|
|
333
|
-
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
334
|
-
promise: Promise<unknown>;
|
|
335
|
-
items: any;
|
|
87
|
+
reload: () => void;
|
|
88
|
+
updateItem: (item: T) => void;
|
|
89
|
+
} & UseQueryResult<UseItemsResponse<T>, Error>;
|
|
90
|
+
declare function useItems<T = Item>(scope: any, { url, getItems, page: initialPage, count: initialCount, query, keepData, ...queryConfig }: UseItemsOptions<T>): UseItemsResult<T>;
|
|
91
|
+
|
|
92
|
+
type UseResourceDestroyResult = UseMutationResult & {
|
|
93
|
+
destroy: (id?: string) => void;
|
|
94
|
+
destroyAsync: (id?: string) => Promise<unknown>;
|
|
95
|
+
loading: boolean;
|
|
96
|
+
};
|
|
97
|
+
declare function useResourceDestroy(id: string | null): UseResourceDestroyResult;
|
|
98
|
+
declare function useResourceDestroy(id: string | null, options: UseMutationOptions): UseResourceDestroyResult;
|
|
99
|
+
declare function useResourceDestroy(resource: Resource | string, id: string | null): UseResourceDestroyResult;
|
|
100
|
+
declare function useResourceDestroy(resource: Resource | string, id: string | null, options: UseMutationOptions): UseResourceDestroyResult;
|
|
101
|
+
|
|
102
|
+
type UseResourceItem<T> = UseQueryResult<T> & {
|
|
103
|
+
item: T | null;
|
|
336
104
|
};
|
|
105
|
+
declare function useResourceItem<T = ResourceItem>(id: string | null): UseResourceItem<T>;
|
|
106
|
+
declare function useResourceItem<T = ResourceItem>(id: string | null, opts: any): UseResourceItem<T>;
|
|
107
|
+
declare function useResourceItem<T = ResourceItem>(resource: Resource | string | null, id: string | null): UseResourceItem<T>;
|
|
108
|
+
declare function useResourceItem<T = ResourceItem>(resource: Resource | string | null, id: string | null, opts: any): UseResourceItem<T>;
|
|
109
|
+
|
|
110
|
+
declare function useResourceItems<T = ResourceItem>(): any;
|
|
111
|
+
declare function useResourceItems<T = ResourceItem>(resource: Resource | string): any;
|
|
112
|
+
declare function useResourceItems<T = ResourceItem>(resource: Resource | string, query: Record<string, unknown> | null): any;
|
|
113
|
+
declare function useResourceItems<T = ResourceItem>(resource: Resource | string, query: Record<string, unknown> | null, page: number | null): any;
|
|
114
|
+
declare function useResourceItems<T = ResourceItem>(resource: Resource | string, query: Record<string, unknown> | null, page: number | null, count: number | null): any;
|
|
115
|
+
declare function useResourceItems<T = ResourceItem>(resource: Resource | string, query: Record<string, unknown> | null, page: number | null, count: number | null, opts: UseItemsOptions<T>): any;
|
|
116
|
+
declare function useResourceItems<T = ResourceItem>(query: Record<string, unknown> | null): any;
|
|
117
|
+
declare function useResourceItems<T = ResourceItem>(query: Record<string, unknown> | null, page: number | null): any;
|
|
118
|
+
declare function useResourceItems<T = ResourceItem>(query: Record<string, unknown> | null, page: number | null, count: number | null): any;
|
|
119
|
+
declare function useResourceItems<T = ResourceItem>(query: Record<string, unknown> | null, page: number | null, count: number | null, opts: UseItemsOptions<T>): any;
|
|
337
120
|
|
|
338
121
|
declare function useResourceCreate(resource: any): {
|
|
339
122
|
store: (data: any) => any;
|
|
@@ -457,4 +240,4 @@ interface DataProviderProps {
|
|
|
457
240
|
}
|
|
458
241
|
declare function DataProvider({ api, apiBaseUrl, children }: DataProviderProps): react_jsx_runtime.JSX.Element;
|
|
459
242
|
|
|
460
|
-
export { Api, ApiProvider, Base as BaseApi, DataProvider, QueryProvider, useApi,
|
|
243
|
+
export { Api, ApiProvider, Base as BaseApi, DataProvider, QueryProvider, useApi, useItem, useItems, useQueryContext, useResourceClone, useResourceDestroy, useResourceItem, useResourceItems, useResourceRestore, useResourceCreate as useResourceStore, useResourceUpdate };
|