@panneau/data 4.1.0 → 5.0.0-alpha.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/README.md +65 -0
- package/dist/adapter.d.ts +84 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/errors.d.ts +51 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +78 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +4 -456
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -1794
- package/dist/laravel/index.d.ts +17 -0
- package/dist/laravel/index.d.ts.map +1 -0
- package/dist/laravel/index.js +37 -0
- package/dist/laravel/index.js.map +1 -0
- package/dist/query/context.d.ts +15 -0
- package/dist/query/context.d.ts.map +1 -0
- package/dist/query/context.js +34 -0
- package/dist/query/context.js.map +1 -0
- package/dist/query/hooks.d.ts +52 -0
- package/dist/query/hooks.d.ts.map +1 -0
- package/dist/query/hooks.js +299 -0
- package/dist/query/hooks.js.map +1 -0
- package/dist/query/index.d.ts +6 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +6 -0
- package/dist/query/keys.d.ts +17 -0
- package/dist/query/keys.d.ts.map +1 -0
- package/dist/query/keys.js +55 -0
- package/dist/query/keys.js.map +1 -0
- package/dist/query/options.d.ts +18 -0
- package/dist/query/options.d.ts.map +1 -0
- package/dist/query/options.js +30 -0
- package/dist/query/options.js.map +1 -0
- package/dist/query/refresh.d.ts +12 -0
- package/dist/query/refresh.d.ts.map +1 -0
- package/dist/query/refresh.js +24 -0
- package/dist/query/refresh.js.map +1 -0
- package/dist/rest.d.ts +25 -0
- package/dist/rest.d.ts.map +1 -0
- package/dist/rest.js +243 -0
- package/dist/rest.js.map +1 -0
- package/package.json +40 -55
package/dist/index.js
CHANGED
|
@@ -1,1794 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { getJSON, getCSRFHeaders, postJSON } from '@folklore/fetch';
|
|
5
|
-
import { generatePath } from '@folklore/routes';
|
|
6
|
-
import queryString from 'query-string';
|
|
7
|
-
import { jsx } from 'react/jsx-runtime';
|
|
8
|
-
import { useQuery, keepPreviousData, hashKey, useQueryClient, useMutation, QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
9
|
-
import isArray from 'lodash-es/isArray';
|
|
10
|
-
import isObject from 'lodash-es/isObject';
|
|
11
|
-
import isString from 'lodash-es/isString';
|
|
12
|
-
|
|
13
|
-
function useItem(scope, id, loader, t0) {
|
|
14
|
-
const $ = c(15);
|
|
15
|
-
const opts = t0 === undefined ? null : t0;
|
|
16
|
-
let t1;
|
|
17
|
-
if ($[0] !== id || $[1] !== scope) {
|
|
18
|
-
t1 = [scope, id];
|
|
19
|
-
$[0] = id;
|
|
20
|
-
$[1] = scope;
|
|
21
|
-
$[2] = t1;
|
|
22
|
-
} else {
|
|
23
|
-
t1 = $[2];
|
|
24
|
-
}
|
|
25
|
-
let t2;
|
|
26
|
-
if ($[3] !== loader) {
|
|
27
|
-
t2 = t3 => {
|
|
28
|
-
const {
|
|
29
|
-
queryKey: t4
|
|
30
|
-
} = t3;
|
|
31
|
-
const [, idParam] = t4;
|
|
32
|
-
return loader(idParam);
|
|
33
|
-
};
|
|
34
|
-
$[3] = loader;
|
|
35
|
-
$[4] = t2;
|
|
36
|
-
} else {
|
|
37
|
-
t2 = $[4];
|
|
38
|
-
}
|
|
39
|
-
let t3;
|
|
40
|
-
if ($[5] !== opts || $[6] !== t1 || $[7] !== t2) {
|
|
41
|
-
t3 = {
|
|
42
|
-
queryKey: t1,
|
|
43
|
-
queryFn: t2,
|
|
44
|
-
...opts
|
|
45
|
-
};
|
|
46
|
-
$[5] = opts;
|
|
47
|
-
$[6] = t1;
|
|
48
|
-
$[7] = t2;
|
|
49
|
-
$[8] = t3;
|
|
50
|
-
} else {
|
|
51
|
-
t3 = $[8];
|
|
52
|
-
}
|
|
53
|
-
const t4 = useQuery(t3);
|
|
54
|
-
let request;
|
|
55
|
-
let t5;
|
|
56
|
-
if ($[9] !== t4) {
|
|
57
|
-
({
|
|
58
|
-
data: t5,
|
|
59
|
-
...request
|
|
60
|
-
} = t4);
|
|
61
|
-
$[9] = t4;
|
|
62
|
-
$[10] = request;
|
|
63
|
-
$[11] = t5;
|
|
64
|
-
} else {
|
|
65
|
-
request = $[10];
|
|
66
|
-
t5 = $[11];
|
|
67
|
-
}
|
|
68
|
-
const data = t5 === undefined ? null : t5;
|
|
69
|
-
let t6;
|
|
70
|
-
if ($[12] !== data || $[13] !== request) {
|
|
71
|
-
t6 = {
|
|
72
|
-
item: data,
|
|
73
|
-
...request
|
|
74
|
-
};
|
|
75
|
-
$[12] = data;
|
|
76
|
-
$[13] = request;
|
|
77
|
-
$[14] = t6;
|
|
78
|
-
} else {
|
|
79
|
-
t6 = $[14];
|
|
80
|
-
}
|
|
81
|
-
return t6;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// The new, better version
|
|
85
|
-
|
|
86
|
-
function useItems(scope, t0) {
|
|
87
|
-
const $ = c(51);
|
|
88
|
-
const {
|
|
89
|
-
url: t1,
|
|
90
|
-
getItems: t2,
|
|
91
|
-
page: t3,
|
|
92
|
-
count: t4,
|
|
93
|
-
query: t5,
|
|
94
|
-
keepData: t6,
|
|
95
|
-
...queryConfig
|
|
96
|
-
} = t0;
|
|
97
|
-
const url = t1 === undefined ? null : t1;
|
|
98
|
-
const getItems = t2 === undefined ? null : t2;
|
|
99
|
-
const initialPage = t3 === undefined ? null : t3;
|
|
100
|
-
const initialCount = t4 === undefined ? null : t4;
|
|
101
|
-
const query = t5 === undefined ? null : t5;
|
|
102
|
-
const keepData = t6 === undefined ? true : t6;
|
|
103
|
-
const {
|
|
104
|
-
page: t7,
|
|
105
|
-
count: t8,
|
|
106
|
-
...queryWithoutPage
|
|
107
|
-
} = query || {};
|
|
108
|
-
const page = t7 === undefined ? initialPage : t7;
|
|
109
|
-
const count = t8 === undefined ? initialCount : t8;
|
|
110
|
-
const paginated = page !== null;
|
|
111
|
-
let t9;
|
|
112
|
-
if ($[0] !== getItems || $[1] !== url) {
|
|
113
|
-
t9 = t10 => {
|
|
114
|
-
const {
|
|
115
|
-
queryKey: t11
|
|
116
|
-
} = t10;
|
|
117
|
-
const [, t12, t13, t14] = t11 === undefined ? [] : t11;
|
|
118
|
-
const queryParam = t12 === undefined ? null : t12;
|
|
119
|
-
const pageParam = t13 === undefined ? null : t13;
|
|
120
|
-
const countParam = t14 === undefined ? null : t14;
|
|
121
|
-
return getItems !== null ? getItems(queryParam, pageParam, countParam) : getJSON(`${url}?${queryString.stringify({
|
|
122
|
-
...(isObject(queryParam) ? queryParam : {}),
|
|
123
|
-
...(pageParam !== null ? {
|
|
124
|
-
page: pageParam
|
|
125
|
-
} : null),
|
|
126
|
-
...(countParam !== null ? {
|
|
127
|
-
count: countParam
|
|
128
|
-
} : null)
|
|
129
|
-
}, {
|
|
130
|
-
arrayFormat: "bracket"
|
|
131
|
-
})}`);
|
|
132
|
-
};
|
|
133
|
-
$[0] = getItems;
|
|
134
|
-
$[1] = url;
|
|
135
|
-
$[2] = t9;
|
|
136
|
-
} else {
|
|
137
|
-
t9 = $[2];
|
|
138
|
-
}
|
|
139
|
-
const {
|
|
140
|
-
data: t10,
|
|
141
|
-
refetch: reload,
|
|
142
|
-
isLoading,
|
|
143
|
-
isFetching,
|
|
144
|
-
isRefetching,
|
|
145
|
-
isFetched,
|
|
146
|
-
isPlaceholderData,
|
|
147
|
-
...otherProps
|
|
148
|
-
} = useQuery({
|
|
149
|
-
queryKey: [scope, queryWithoutPage, page, count],
|
|
150
|
-
queryFn: t9,
|
|
151
|
-
refetchOnMount: "always",
|
|
152
|
-
...(keepData ? {
|
|
153
|
-
placeholderData: keepPreviousData
|
|
154
|
-
} : null),
|
|
155
|
-
...queryConfig
|
|
156
|
-
});
|
|
157
|
-
const data = t10 === undefined ? null : t10;
|
|
158
|
-
let t11;
|
|
159
|
-
if ($[3] !== data) {
|
|
160
|
-
t11 = isArray(data) ? {
|
|
161
|
-
data
|
|
162
|
-
} : data || {};
|
|
163
|
-
$[3] = data;
|
|
164
|
-
$[4] = t11;
|
|
165
|
-
} else {
|
|
166
|
-
t11 = $[4];
|
|
167
|
-
}
|
|
168
|
-
const {
|
|
169
|
-
data: t12,
|
|
170
|
-
pagination: t13,
|
|
171
|
-
meta: t14
|
|
172
|
-
} = t11;
|
|
173
|
-
let t15;
|
|
174
|
-
if ($[5] !== t12) {
|
|
175
|
-
t15 = t12 === undefined ? [] : t12;
|
|
176
|
-
$[5] = t12;
|
|
177
|
-
$[6] = t15;
|
|
178
|
-
} else {
|
|
179
|
-
t15 = $[6];
|
|
180
|
-
}
|
|
181
|
-
const items = t15;
|
|
182
|
-
const pagination = t13 === undefined ? null : t13;
|
|
183
|
-
const meta = t14 === undefined ? null : t14;
|
|
184
|
-
let t16;
|
|
185
|
-
if ($[7] !== meta || $[8] !== pagination) {
|
|
186
|
-
t16 = pagination || meta || {};
|
|
187
|
-
$[7] = meta;
|
|
188
|
-
$[8] = pagination;
|
|
189
|
-
$[9] = t16;
|
|
190
|
-
} else {
|
|
191
|
-
t16 = $[9];
|
|
192
|
-
}
|
|
193
|
-
const {
|
|
194
|
-
page: t17,
|
|
195
|
-
last_page: t18,
|
|
196
|
-
total: t19
|
|
197
|
-
} = t16;
|
|
198
|
-
const currentPage = t17 === undefined ? null : t17;
|
|
199
|
-
const lastPage = t18 === undefined ? 0 : t18;
|
|
200
|
-
const total = t19 === undefined ? null : t19;
|
|
201
|
-
let t20;
|
|
202
|
-
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
203
|
-
t20 = [];
|
|
204
|
-
$[10] = t20;
|
|
205
|
-
} else {
|
|
206
|
-
t20 = $[10];
|
|
207
|
-
}
|
|
208
|
-
const [updatedItems, setUpdatedItems] = useState(t20);
|
|
209
|
-
let t21;
|
|
210
|
-
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
211
|
-
t21 = item => {
|
|
212
|
-
const {
|
|
213
|
-
id: t22
|
|
214
|
-
} = item || {};
|
|
215
|
-
const itemId = t22 === undefined ? null : t22;
|
|
216
|
-
if (itemId !== null) {
|
|
217
|
-
setUpdatedItems(currentUpdatedItems => [...(currentUpdatedItems || []).filter(t23 => {
|
|
218
|
-
const {
|
|
219
|
-
id: t24
|
|
220
|
-
} = t23 === undefined ? {} : t23;
|
|
221
|
-
const id = t24 === undefined ? null : t24;
|
|
222
|
-
return id !== itemId;
|
|
223
|
-
}), item]);
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
$[11] = t21;
|
|
227
|
-
} else {
|
|
228
|
-
t21 = $[11];
|
|
229
|
-
}
|
|
230
|
-
const updateItem = t21;
|
|
231
|
-
let t22;
|
|
232
|
-
if ($[12] !== updatedItems) {
|
|
233
|
-
t22 = currentItems => {
|
|
234
|
-
if (currentItems === null || updatedItems === null || updatedItems.length === 0) {
|
|
235
|
-
return currentItems;
|
|
236
|
-
}
|
|
237
|
-
return (currentItems || []).map(item_0 => {
|
|
238
|
-
const {
|
|
239
|
-
id: t23
|
|
240
|
-
} = item_0 || {};
|
|
241
|
-
const itemId_0 = t23 === undefined ? null : t23;
|
|
242
|
-
const updated = (updatedItems || []).find(t24 => {
|
|
243
|
-
const {
|
|
244
|
-
id: t25
|
|
245
|
-
} = t24 === undefined ? {} : t24;
|
|
246
|
-
const id_0 = t25 === undefined ? null : t25;
|
|
247
|
-
return id_0 === itemId_0;
|
|
248
|
-
}) || null;
|
|
249
|
-
if (updated !== null) {
|
|
250
|
-
return updated;
|
|
251
|
-
}
|
|
252
|
-
return item_0;
|
|
253
|
-
}, []);
|
|
254
|
-
};
|
|
255
|
-
$[12] = updatedItems;
|
|
256
|
-
$[13] = t22;
|
|
257
|
-
} else {
|
|
258
|
-
t22 = $[13];
|
|
259
|
-
}
|
|
260
|
-
const replaceUpdatedItems = t22;
|
|
261
|
-
let t23;
|
|
262
|
-
if ($[14] !== items || $[15] !== replaceUpdatedItems) {
|
|
263
|
-
t23 = replaceUpdatedItems(items);
|
|
264
|
-
$[14] = items;
|
|
265
|
-
$[15] = replaceUpdatedItems;
|
|
266
|
-
$[16] = t23;
|
|
267
|
-
} else {
|
|
268
|
-
t23 = $[16];
|
|
269
|
-
}
|
|
270
|
-
const finalItems = t23;
|
|
271
|
-
const pagesKey = hashKey([scope, queryWithoutPage, count]);
|
|
272
|
-
let t24;
|
|
273
|
-
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
274
|
-
t24 = {};
|
|
275
|
-
$[17] = t24;
|
|
276
|
-
} else {
|
|
277
|
-
t24 = $[17];
|
|
278
|
-
}
|
|
279
|
-
let t25;
|
|
280
|
-
if ($[18] !== pagesKey) {
|
|
281
|
-
t25 = {
|
|
282
|
-
key: pagesKey,
|
|
283
|
-
pages: t24
|
|
284
|
-
};
|
|
285
|
-
$[18] = pagesKey;
|
|
286
|
-
$[19] = t25;
|
|
287
|
-
} else {
|
|
288
|
-
t25 = $[19];
|
|
289
|
-
}
|
|
290
|
-
const [pagesState, setPagesState] = useState(t25);
|
|
291
|
-
let t26;
|
|
292
|
-
if ($[20] !== pagesKey || $[21] !== pagesState.key || $[22] !== pagesState.pages) {
|
|
293
|
-
t26 = pagesState.key === pagesKey ? pagesState.pages : {};
|
|
294
|
-
$[20] = pagesKey;
|
|
295
|
-
$[21] = pagesState.key;
|
|
296
|
-
$[22] = pagesState.pages;
|
|
297
|
-
$[23] = t26;
|
|
298
|
-
} else {
|
|
299
|
-
t26 = $[23];
|
|
300
|
-
}
|
|
301
|
-
const pages = t26;
|
|
302
|
-
if (isFetched && !isPlaceholderData && page !== null && data !== null && pages[page] !== data) {
|
|
303
|
-
let t27;
|
|
304
|
-
if ($[24] !== data || $[25] !== page || $[26] !== pages) {
|
|
305
|
-
t27 = {
|
|
306
|
-
...pages,
|
|
307
|
-
[page]: data
|
|
308
|
-
};
|
|
309
|
-
$[24] = data;
|
|
310
|
-
$[25] = page;
|
|
311
|
-
$[26] = pages;
|
|
312
|
-
$[27] = t27;
|
|
313
|
-
} else {
|
|
314
|
-
t27 = $[27];
|
|
315
|
-
}
|
|
316
|
-
setPagesState({
|
|
317
|
-
key: pagesKey,
|
|
318
|
-
pages: t27
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
let t27;
|
|
322
|
-
if ($[28] !== finalItems || $[29] !== pages || $[30] !== replaceUpdatedItems) {
|
|
323
|
-
t27 = Object.keys(pages).length > 0 ? replaceUpdatedItems(Object.keys(pages).flatMap(k => pages[k]?.data)) : finalItems;
|
|
324
|
-
$[28] = finalItems;
|
|
325
|
-
$[29] = pages;
|
|
326
|
-
$[30] = replaceUpdatedItems;
|
|
327
|
-
$[31] = t27;
|
|
328
|
-
} else {
|
|
329
|
-
t27 = $[31];
|
|
330
|
-
}
|
|
331
|
-
const allItems = t27;
|
|
332
|
-
const finalLoading = isLoading || isFetching || isRefetching;
|
|
333
|
-
let t28;
|
|
334
|
-
if ($[32] !== currentPage || $[33] !== lastPage || $[34] !== paginated || $[35] !== total) {
|
|
335
|
-
t28 = paginated ? {
|
|
336
|
-
page: currentPage,
|
|
337
|
-
lastPage,
|
|
338
|
-
total
|
|
339
|
-
} : null;
|
|
340
|
-
$[32] = currentPage;
|
|
341
|
-
$[33] = lastPage;
|
|
342
|
-
$[34] = paginated;
|
|
343
|
-
$[35] = total;
|
|
344
|
-
$[36] = t28;
|
|
345
|
-
} else {
|
|
346
|
-
t28 = $[36];
|
|
347
|
-
}
|
|
348
|
-
let t29;
|
|
349
|
-
if ($[37] !== allItems || $[38] !== finalItems || $[39] !== finalLoading || $[40] !== isFetched || $[41] !== isFetching || $[42] !== isLoading || $[43] !== isPlaceholderData || $[44] !== isRefetching || $[45] !== otherProps || $[46] !== pages || $[47] !== reload || $[48] !== t28 || $[49] !== updateItem) {
|
|
350
|
-
t29 = {
|
|
351
|
-
...otherProps,
|
|
352
|
-
isLoading,
|
|
353
|
-
isFetching,
|
|
354
|
-
isRefetching,
|
|
355
|
-
isFetched,
|
|
356
|
-
isPlaceholderData,
|
|
357
|
-
items: finalItems,
|
|
358
|
-
pages,
|
|
359
|
-
allItems,
|
|
360
|
-
loading: finalLoading,
|
|
361
|
-
loaded: isFetched,
|
|
362
|
-
reload,
|
|
363
|
-
updateItem,
|
|
364
|
-
pagination: t28
|
|
365
|
-
};
|
|
366
|
-
$[37] = allItems;
|
|
367
|
-
$[38] = finalItems;
|
|
368
|
-
$[39] = finalLoading;
|
|
369
|
-
$[40] = isFetched;
|
|
370
|
-
$[41] = isFetching;
|
|
371
|
-
$[42] = isLoading;
|
|
372
|
-
$[43] = isPlaceholderData;
|
|
373
|
-
$[44] = isRefetching;
|
|
374
|
-
$[45] = otherProps;
|
|
375
|
-
$[46] = pages;
|
|
376
|
-
$[47] = reload;
|
|
377
|
-
$[48] = t28;
|
|
378
|
-
$[49] = updateItem;
|
|
379
|
-
$[50] = t29;
|
|
380
|
-
} else {
|
|
381
|
-
t29 = $[50];
|
|
382
|
-
}
|
|
383
|
-
return t29;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
class Base {
|
|
387
|
-
constructor(opts) {
|
|
388
|
-
this.options = {
|
|
389
|
-
routes: {},
|
|
390
|
-
generateUrl: null,
|
|
391
|
-
...opts
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
requestGet(path, query = null, opts = null) {
|
|
395
|
-
return getJSON(this.getFullUrl(path, query), {
|
|
396
|
-
credentials: 'include',
|
|
397
|
-
headers: getCSRFHeaders(),
|
|
398
|
-
...opts
|
|
399
|
-
}).catch(error => {
|
|
400
|
-
this.onError(error);
|
|
401
|
-
return null;
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
requestPost(path, data = null, opts = null) {
|
|
405
|
-
return postJSON(this.getFullUrl(path), data, {
|
|
406
|
-
credentials: 'include',
|
|
407
|
-
headers: getCSRFHeaders(),
|
|
408
|
-
...opts
|
|
409
|
-
}).catch(error => {
|
|
410
|
-
this.onError(error);
|
|
411
|
-
return null;
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
requestPut(path, data, opts = null) {
|
|
415
|
-
return this.requestPost(path, {
|
|
416
|
-
_method: 'PUT',
|
|
417
|
-
...data
|
|
418
|
-
}, opts);
|
|
419
|
-
}
|
|
420
|
-
requestPatch(path, data, opts = null) {
|
|
421
|
-
return this.requestPost(path, {
|
|
422
|
-
_method: 'PATCH',
|
|
423
|
-
...data
|
|
424
|
-
}, opts);
|
|
425
|
-
}
|
|
426
|
-
requestDelete(path, opts = null) {
|
|
427
|
-
return this.requestPost(path, {
|
|
428
|
-
_method: 'DELETE'
|
|
429
|
-
}, opts);
|
|
430
|
-
}
|
|
431
|
-
hasRoute(route) {
|
|
432
|
-
const {
|
|
433
|
-
routes
|
|
434
|
-
} = this.options;
|
|
435
|
-
return typeof routes[route] !== 'undefined';
|
|
436
|
-
}
|
|
437
|
-
route(route, params = null) {
|
|
438
|
-
const {
|
|
439
|
-
routes,
|
|
440
|
-
generateUrl = null
|
|
441
|
-
} = this.options;
|
|
442
|
-
// The url generator returns null for routes it doesn't know: fallback to the routes option
|
|
443
|
-
const url = generateUrl !== null ? generateUrl(route, params) : null;
|
|
444
|
-
if (url !== null && typeof url !== 'undefined') {
|
|
445
|
-
return url;
|
|
446
|
-
}
|
|
447
|
-
const path = routes?.[route] ?? null;
|
|
448
|
-
// Return null for unknown routes, so callers can fallback to another route
|
|
449
|
-
return path !== null ? generatePath(path, params || {}) : null;
|
|
450
|
-
}
|
|
451
|
-
getFullUrl(path, query = null) {
|
|
452
|
-
if (path === null || typeof path === 'undefined') {
|
|
453
|
-
throw new Error('Api: route not found');
|
|
454
|
-
}
|
|
455
|
-
const {
|
|
456
|
-
baseUrl = null
|
|
457
|
-
} = this.options;
|
|
458
|
-
const hasProtocol = path.indexOf('://') !== -1;
|
|
459
|
-
const url = baseUrl !== null && !hasProtocol ? `${baseUrl.replace(/\/$/, '')}/${path.replace(/^\//, '')}` : path;
|
|
460
|
-
const finalQuery = query !== null ? queryString.stringify(query, {
|
|
461
|
-
arrayFormat: 'bracket'
|
|
462
|
-
}) : null;
|
|
463
|
-
return `${url}${finalQuery !== null && finalQuery.length > 0 ? `${url.indexOf('?') === -1 ? '?' : '&'}${finalQuery}` : ''}`;
|
|
464
|
-
}
|
|
465
|
-
onError(err) {
|
|
466
|
-
const {
|
|
467
|
-
onUnauthorized
|
|
468
|
-
} = this.options;
|
|
469
|
-
const {
|
|
470
|
-
status = null
|
|
471
|
-
} = err || {};
|
|
472
|
-
const statusCode = parseInt(status, 10);
|
|
473
|
-
// If status is refused and callback exists
|
|
474
|
-
if ((statusCode === 401 || statusCode === 419) && onUnauthorized !== null) {
|
|
475
|
-
onUnauthorized();
|
|
476
|
-
}
|
|
477
|
-
throw err;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
class AccountApi extends Base {
|
|
482
|
-
constructor(opts) {
|
|
483
|
-
super({
|
|
484
|
-
...opts,
|
|
485
|
-
routes: {
|
|
486
|
-
account: 'account',
|
|
487
|
-
'account.password': 'account/password',
|
|
488
|
-
'account.delete': 'account/delete',
|
|
489
|
-
...(opts?.routes || null)
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
update(data) {
|
|
494
|
-
return this.requestPost(this.route('account'), data);
|
|
495
|
-
}
|
|
496
|
-
updatePassword(data) {
|
|
497
|
-
return this.requestPost(this.route('account.password'), data);
|
|
498
|
-
}
|
|
499
|
-
delete(data) {
|
|
500
|
-
return this.requestPost(this.route('account.delete'), data);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
class AuthApi extends Base {
|
|
505
|
-
constructor(opts) {
|
|
506
|
-
super({
|
|
507
|
-
...opts,
|
|
508
|
-
routes: {
|
|
509
|
-
'auth.check': 'auth/check',
|
|
510
|
-
'auth.login': 'auth/login',
|
|
511
|
-
'auth.register': 'auth/register',
|
|
512
|
-
'auth.logout': 'auth/logout',
|
|
513
|
-
'auth.password.email': 'auth/password/email',
|
|
514
|
-
'auth.password.update': 'auth/password/update',
|
|
515
|
-
...(opts?.routes || null)
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
check() {
|
|
520
|
-
return this.requestGet(this.route('auth.check'));
|
|
521
|
-
}
|
|
522
|
-
login(email, password) {
|
|
523
|
-
return this.requestPost(this.route('auth.login'), {
|
|
524
|
-
email,
|
|
525
|
-
password
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
register(data) {
|
|
529
|
-
return this.requestPost(this.route('auth.register'), data);
|
|
530
|
-
}
|
|
531
|
-
logout() {
|
|
532
|
-
return this.requestPost(this.route('auth.logout'));
|
|
533
|
-
}
|
|
534
|
-
requestPassword(email) {
|
|
535
|
-
return this.requestPost(this.route('auth.password.email'), {
|
|
536
|
-
email
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
resetPassword(data) {
|
|
540
|
-
return this.requestPost(this.route('auth.password.update'), data);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
class MediasApi extends Base {
|
|
545
|
-
constructor(opts) {
|
|
546
|
-
super({
|
|
547
|
-
...opts,
|
|
548
|
-
routes: {
|
|
549
|
-
index: 'medias',
|
|
550
|
-
trashed: 'medias/trash',
|
|
551
|
-
tags: 'medias/tags',
|
|
552
|
-
show: 'medias/:media',
|
|
553
|
-
store: 'medias',
|
|
554
|
-
update: 'medias/:media',
|
|
555
|
-
trash: 'medias/trash/:media',
|
|
556
|
-
restore: 'medias/restore/:media',
|
|
557
|
-
destroy: 'medias/:media',
|
|
558
|
-
replace: 'medias/replace/:media',
|
|
559
|
-
...(opts?.routes || null)
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
find(id) {
|
|
564
|
-
return this.requestGet(this.route('show', {
|
|
565
|
-
media: id
|
|
566
|
-
}));
|
|
567
|
-
}
|
|
568
|
-
get(query = {}, page = 1, count = 10) {
|
|
569
|
-
const finalQuery = {
|
|
570
|
-
...query
|
|
571
|
-
};
|
|
572
|
-
if (page !== null) {
|
|
573
|
-
finalQuery.page = page;
|
|
574
|
-
}
|
|
575
|
-
if (count !== null) {
|
|
576
|
-
finalQuery.count = count;
|
|
577
|
-
}
|
|
578
|
-
return this.requestGet(this.route('index'), finalQuery);
|
|
579
|
-
}
|
|
580
|
-
getTrashed(query = {}, page = 1, count = 10) {
|
|
581
|
-
return this.get({
|
|
582
|
-
trashed: true,
|
|
583
|
-
...query
|
|
584
|
-
}, page, count);
|
|
585
|
-
}
|
|
586
|
-
getTags(query = {}, count = 10) {
|
|
587
|
-
const finalQuery = {
|
|
588
|
-
...query
|
|
589
|
-
};
|
|
590
|
-
if (count !== null) {
|
|
591
|
-
finalQuery.count = count;
|
|
592
|
-
}
|
|
593
|
-
return this.requestGet(this.route('tags'), finalQuery);
|
|
594
|
-
}
|
|
595
|
-
create(data) {
|
|
596
|
-
return this.requestPost(this.route('store'), data);
|
|
597
|
-
}
|
|
598
|
-
update(id, data) {
|
|
599
|
-
return this.requestPut(this.route('update', {
|
|
600
|
-
media: id
|
|
601
|
-
}), data);
|
|
602
|
-
}
|
|
603
|
-
trash(id) {
|
|
604
|
-
return this.requestDelete(this.route('trash', {
|
|
605
|
-
media: id
|
|
606
|
-
}));
|
|
607
|
-
}
|
|
608
|
-
restore(id) {
|
|
609
|
-
return this.requestPost(this.route('restore', {
|
|
610
|
-
media: id
|
|
611
|
-
}));
|
|
612
|
-
}
|
|
613
|
-
destroy(id) {
|
|
614
|
-
return this.requestDelete(this.route('destroy', {
|
|
615
|
-
media: id
|
|
616
|
-
}));
|
|
617
|
-
}
|
|
618
|
-
replace(id, data) {
|
|
619
|
-
return this.requestPost(this.route('replace', {
|
|
620
|
-
media: id
|
|
621
|
-
}), data);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
class ResourcesApi extends Base {
|
|
626
|
-
constructor(opts) {
|
|
627
|
-
super({
|
|
628
|
-
...opts,
|
|
629
|
-
routes: {
|
|
630
|
-
'resources.index': '/:resource',
|
|
631
|
-
'resources.show': '/:resource/:id',
|
|
632
|
-
'resources.store': '/:resource',
|
|
633
|
-
'resources.update': '/:resource/:id',
|
|
634
|
-
'resources.destroy': '/:resource/:id',
|
|
635
|
-
'resources.clone': '/:resource/:id/clone',
|
|
636
|
-
'resources.restore': '/:resource/:id/restore',
|
|
637
|
-
...(opts?.routes || null)
|
|
638
|
-
}
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
find(resource, id, opts = null) {
|
|
642
|
-
return this.requestGet(this.resourceRoute(resource, 'show', {
|
|
643
|
-
id
|
|
644
|
-
}), null, opts);
|
|
645
|
-
}
|
|
646
|
-
get(resource, query, page = 1, count = 12, opts = null) {
|
|
647
|
-
const finalQuery = {
|
|
648
|
-
...query
|
|
649
|
-
};
|
|
650
|
-
if (page !== null) {
|
|
651
|
-
finalQuery.page = page;
|
|
652
|
-
}
|
|
653
|
-
if (count !== null) {
|
|
654
|
-
finalQuery.count = count;
|
|
655
|
-
}
|
|
656
|
-
return this.requestGet(this.resourceRoute(resource, 'index'), finalQuery, opts);
|
|
657
|
-
}
|
|
658
|
-
store(resource, data, opts = null) {
|
|
659
|
-
return this.requestPost(this.resourceRoute(resource, 'store'), data, opts);
|
|
660
|
-
}
|
|
661
|
-
update(resource, id, data, opts = null) {
|
|
662
|
-
return this.requestPatch(this.resourceRoute(resource, 'update', {
|
|
663
|
-
id
|
|
664
|
-
}), data, opts);
|
|
665
|
-
}
|
|
666
|
-
destroy(resource, id, opts = null) {
|
|
667
|
-
return this.requestDelete(this.resourceRoute(resource, 'destroy', {
|
|
668
|
-
id
|
|
669
|
-
}), opts);
|
|
670
|
-
}
|
|
671
|
-
clone(resource, id, data = null, opts = null) {
|
|
672
|
-
return this.requestPost(this.resourceRoute(resource, 'clone', {
|
|
673
|
-
id
|
|
674
|
-
}), data, opts);
|
|
675
|
-
}
|
|
676
|
-
restore(resource, id, data = null, opts = null) {
|
|
677
|
-
return this.requestPost(this.resourceRoute(resource, 'restore', {
|
|
678
|
-
id
|
|
679
|
-
}), data, opts);
|
|
680
|
-
}
|
|
681
|
-
resourceRoute({
|
|
682
|
-
id
|
|
683
|
-
}, route, params = null) {
|
|
684
|
-
return this.route(`resources.${id}.${route}`, params) ?? this.route(`resources.${route}`, {
|
|
685
|
-
resource: id,
|
|
686
|
-
...params
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
class Api extends Base {
|
|
692
|
-
constructor(opts) {
|
|
693
|
-
super(opts);
|
|
694
|
-
this.auth = new AuthApi(opts);
|
|
695
|
-
this.account = new AccountApi(opts);
|
|
696
|
-
this.medias = new MediasApi(opts);
|
|
697
|
-
this.resources = new ResourcesApi(opts);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
const ApiContext = /*#__PURE__*/createContext(null);
|
|
702
|
-
function useApi() {
|
|
703
|
-
return use(ApiContext);
|
|
704
|
-
}
|
|
705
|
-
function ApiProvider(t0) {
|
|
706
|
-
const $ = c(11);
|
|
707
|
-
const {
|
|
708
|
-
api: t1,
|
|
709
|
-
baseUrl: t2,
|
|
710
|
-
onUnauthorized: t3,
|
|
711
|
-
routes: t4,
|
|
712
|
-
children
|
|
713
|
-
} = t0;
|
|
714
|
-
const initialApi = t1 === undefined ? null : t1;
|
|
715
|
-
const baseUrl = t2 === undefined ? undefined : t2;
|
|
716
|
-
const onUnauthorized = t3 === undefined ? null : t3;
|
|
717
|
-
const apiRoutes = t4 === undefined ? undefined : t4;
|
|
718
|
-
const generateUrl = useUrlGenerator();
|
|
719
|
-
const previousApi = useApi();
|
|
720
|
-
const contextRoutes = useRoutes();
|
|
721
|
-
let t5;
|
|
722
|
-
if ($[0] !== apiRoutes || $[1] !== baseUrl || $[2] !== contextRoutes || $[3] !== generateUrl || $[4] !== initialApi || $[5] !== onUnauthorized || $[6] !== previousApi) {
|
|
723
|
-
t5 = initialApi || previousApi || new Api({
|
|
724
|
-
baseUrl,
|
|
725
|
-
generateUrl,
|
|
726
|
-
routes: apiRoutes || contextRoutes,
|
|
727
|
-
onUnauthorized
|
|
728
|
-
});
|
|
729
|
-
$[0] = apiRoutes;
|
|
730
|
-
$[1] = baseUrl;
|
|
731
|
-
$[2] = contextRoutes;
|
|
732
|
-
$[3] = generateUrl;
|
|
733
|
-
$[4] = initialApi;
|
|
734
|
-
$[5] = onUnauthorized;
|
|
735
|
-
$[6] = previousApi;
|
|
736
|
-
$[7] = t5;
|
|
737
|
-
} else {
|
|
738
|
-
t5 = $[7];
|
|
739
|
-
}
|
|
740
|
-
const api = t5;
|
|
741
|
-
let t6;
|
|
742
|
-
if ($[8] !== api || $[9] !== children) {
|
|
743
|
-
t6 = /*#__PURE__*/jsx(ApiContext, {
|
|
744
|
-
value: api,
|
|
745
|
-
children: children
|
|
746
|
-
});
|
|
747
|
-
$[8] = api;
|
|
748
|
-
$[9] = children;
|
|
749
|
-
$[10] = t6;
|
|
750
|
-
} else {
|
|
751
|
-
t6 = $[10];
|
|
752
|
-
}
|
|
753
|
-
return t6;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
/**
|
|
757
|
-
* Resolve the arguments of resource hooks supporting these call forms:
|
|
758
|
-
* (resource), (id), (resource, id), (resource, options), (id, options), (resource, id, options)
|
|
759
|
-
*
|
|
760
|
-
* The first argument is the resource when it is an object or a known resource id, or when a
|
|
761
|
-
* non-null id is passed as second argument. Otherwise, it is considered as the item id and the
|
|
762
|
-
* resource from the context is used.
|
|
763
|
-
*/
|
|
764
|
-
function useResourceArguments(resource, id, options) {
|
|
765
|
-
const $ = c(4);
|
|
766
|
-
const idIsOptions = isObject(id);
|
|
767
|
-
const providedResource = usePanneauResource(resource);
|
|
768
|
-
const contextResource = useResource();
|
|
769
|
-
const resourceIsExplicit = providedResource !== null || !idIsOptions && id !== null;
|
|
770
|
-
const t0 = providedResource || contextResource || null;
|
|
771
|
-
const t1 = resourceIsExplicit ? idIsOptions ? null : id : resource;
|
|
772
|
-
const t2 = idIsOptions ? id : options;
|
|
773
|
-
let t3;
|
|
774
|
-
if ($[0] !== t0 || $[1] !== t1 || $[2] !== t2) {
|
|
775
|
-
t3 = {
|
|
776
|
-
resource: t0,
|
|
777
|
-
id: t1,
|
|
778
|
-
options: t2
|
|
779
|
-
};
|
|
780
|
-
$[0] = t0;
|
|
781
|
-
$[1] = t1;
|
|
782
|
-
$[2] = t2;
|
|
783
|
-
$[3] = t3;
|
|
784
|
-
} else {
|
|
785
|
-
t3 = $[3];
|
|
786
|
-
}
|
|
787
|
-
return t3;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
function useResourceDestroy(t0, t1, t2) {
|
|
791
|
-
const $ = c(32);
|
|
792
|
-
const resource = t0 === undefined ? null : t0;
|
|
793
|
-
const id = t1 === undefined ? null : t1;
|
|
794
|
-
let t3;
|
|
795
|
-
if ($[0] !== t2) {
|
|
796
|
-
t3 = t2 === undefined ? {} : t2;
|
|
797
|
-
$[0] = t2;
|
|
798
|
-
$[1] = t3;
|
|
799
|
-
} else {
|
|
800
|
-
t3 = $[1];
|
|
801
|
-
}
|
|
802
|
-
const options = t3;
|
|
803
|
-
const {
|
|
804
|
-
resource: finalResource,
|
|
805
|
-
id: finalId,
|
|
806
|
-
options: finalOptions
|
|
807
|
-
} = useResourceArguments(resource, id, options);
|
|
808
|
-
let t4;
|
|
809
|
-
if ($[2] !== finalOptions) {
|
|
810
|
-
t4 = finalOptions || {};
|
|
811
|
-
$[2] = finalOptions;
|
|
812
|
-
$[3] = t4;
|
|
813
|
-
} else {
|
|
814
|
-
t4 = $[3];
|
|
815
|
-
}
|
|
816
|
-
let otherOptions;
|
|
817
|
-
let t5;
|
|
818
|
-
if ($[4] !== t4) {
|
|
819
|
-
({
|
|
820
|
-
onSuccess: t5,
|
|
821
|
-
...otherOptions
|
|
822
|
-
} = t4);
|
|
823
|
-
$[4] = t4;
|
|
824
|
-
$[5] = otherOptions;
|
|
825
|
-
$[6] = t5;
|
|
826
|
-
} else {
|
|
827
|
-
otherOptions = $[5];
|
|
828
|
-
t5 = $[6];
|
|
829
|
-
}
|
|
830
|
-
const customOnSuccess = t5 === undefined ? null : t5;
|
|
831
|
-
let t6;
|
|
832
|
-
if ($[7] !== finalResource) {
|
|
833
|
-
t6 = finalResource || {};
|
|
834
|
-
$[7] = finalResource;
|
|
835
|
-
$[8] = t6;
|
|
836
|
-
} else {
|
|
837
|
-
t6 = $[8];
|
|
838
|
-
}
|
|
839
|
-
const {
|
|
840
|
-
id: t7
|
|
841
|
-
} = t6;
|
|
842
|
-
const resourceId = t7 === undefined ? null : t7;
|
|
843
|
-
const api = useApi();
|
|
844
|
-
const queryClient = useQueryClient();
|
|
845
|
-
let t8;
|
|
846
|
-
if ($[9] !== api || $[10] !== finalId || $[11] !== finalResource) {
|
|
847
|
-
t8 = t9 => {
|
|
848
|
-
const providedId = t9 === undefined ? null : t9;
|
|
849
|
-
return api.resources.destroy(finalResource, providedId ?? finalId);
|
|
850
|
-
};
|
|
851
|
-
$[9] = api;
|
|
852
|
-
$[10] = finalId;
|
|
853
|
-
$[11] = finalResource;
|
|
854
|
-
$[12] = t8;
|
|
855
|
-
} else {
|
|
856
|
-
t8 = $[12];
|
|
857
|
-
}
|
|
858
|
-
let t9;
|
|
859
|
-
if ($[13] !== customOnSuccess || $[14] !== finalId || $[15] !== queryClient || $[16] !== resourceId) {
|
|
860
|
-
t9 = (data, variables, ...t10) => {
|
|
861
|
-
const args = t10;
|
|
862
|
-
const destroyedId = variables ?? finalId;
|
|
863
|
-
queryClient.invalidateQueries({
|
|
864
|
-
queryKey: [resourceId],
|
|
865
|
-
predicate: t11 => {
|
|
866
|
-
const {
|
|
867
|
-
queryKey
|
|
868
|
-
} = t11;
|
|
869
|
-
return String(queryKey[1]) !== String(destroyedId);
|
|
870
|
-
}
|
|
871
|
-
});
|
|
872
|
-
if (customOnSuccess !== null) {
|
|
873
|
-
return customOnSuccess(data, variables, ...args);
|
|
874
|
-
}
|
|
875
|
-
};
|
|
876
|
-
$[13] = customOnSuccess;
|
|
877
|
-
$[14] = finalId;
|
|
878
|
-
$[15] = queryClient;
|
|
879
|
-
$[16] = resourceId;
|
|
880
|
-
$[17] = t9;
|
|
881
|
-
} else {
|
|
882
|
-
t9 = $[17];
|
|
883
|
-
}
|
|
884
|
-
let t10;
|
|
885
|
-
if ($[18] !== otherOptions || $[19] !== t8 || $[20] !== t9) {
|
|
886
|
-
t10 = {
|
|
887
|
-
mutationFn: t8,
|
|
888
|
-
onSuccess: t9,
|
|
889
|
-
...otherOptions
|
|
890
|
-
};
|
|
891
|
-
$[18] = otherOptions;
|
|
892
|
-
$[19] = t8;
|
|
893
|
-
$[20] = t9;
|
|
894
|
-
$[21] = t10;
|
|
895
|
-
} else {
|
|
896
|
-
t10 = $[21];
|
|
897
|
-
}
|
|
898
|
-
const t11 = useMutation(t10);
|
|
899
|
-
let isPending;
|
|
900
|
-
let mutate;
|
|
901
|
-
let mutateAsync;
|
|
902
|
-
let other;
|
|
903
|
-
if ($[22] !== t11) {
|
|
904
|
-
({
|
|
905
|
-
mutate,
|
|
906
|
-
mutateAsync,
|
|
907
|
-
isPending,
|
|
908
|
-
...other
|
|
909
|
-
} = t11);
|
|
910
|
-
$[22] = t11;
|
|
911
|
-
$[23] = isPending;
|
|
912
|
-
$[24] = mutate;
|
|
913
|
-
$[25] = mutateAsync;
|
|
914
|
-
$[26] = other;
|
|
915
|
-
} else {
|
|
916
|
-
isPending = $[23];
|
|
917
|
-
mutate = $[24];
|
|
918
|
-
mutateAsync = $[25];
|
|
919
|
-
other = $[26];
|
|
920
|
-
}
|
|
921
|
-
let t12;
|
|
922
|
-
if ($[27] !== isPending || $[28] !== mutate || $[29] !== mutateAsync || $[30] !== other) {
|
|
923
|
-
t12 = {
|
|
924
|
-
destroy: mutate,
|
|
925
|
-
destroyAsync: mutateAsync,
|
|
926
|
-
loading: isPending,
|
|
927
|
-
mutate,
|
|
928
|
-
mutateAsync,
|
|
929
|
-
isPending,
|
|
930
|
-
...other
|
|
931
|
-
};
|
|
932
|
-
$[27] = isPending;
|
|
933
|
-
$[28] = mutate;
|
|
934
|
-
$[29] = mutateAsync;
|
|
935
|
-
$[30] = other;
|
|
936
|
-
$[31] = t12;
|
|
937
|
-
} else {
|
|
938
|
-
t12 = $[31];
|
|
939
|
-
}
|
|
940
|
-
return t12;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
function useResourceItem(resource, t0, t1) {
|
|
944
|
-
const $ = c(19);
|
|
945
|
-
const id = t0 === undefined ? null : t0;
|
|
946
|
-
const opts = t1 === undefined ? null : t1;
|
|
947
|
-
const api = useApi();
|
|
948
|
-
const providedResource = usePanneauResource(id !== null && !isObject(id) ? resource : null);
|
|
949
|
-
const contextResource = useResource();
|
|
950
|
-
const finalResource = providedResource || contextResource;
|
|
951
|
-
const finalId = providedResource !== null ? id : resource;
|
|
952
|
-
let t2;
|
|
953
|
-
if ($[0] !== finalResource) {
|
|
954
|
-
t2 = finalResource || {};
|
|
955
|
-
$[0] = finalResource;
|
|
956
|
-
$[1] = t2;
|
|
957
|
-
} else {
|
|
958
|
-
t2 = $[1];
|
|
959
|
-
}
|
|
960
|
-
const {
|
|
961
|
-
id: t3
|
|
962
|
-
} = t2;
|
|
963
|
-
const resourceId = t3 === undefined ? null : t3;
|
|
964
|
-
const t4 = finalId !== null ? String(finalId) : null;
|
|
965
|
-
let t5;
|
|
966
|
-
if ($[2] !== resourceId || $[3] !== t4) {
|
|
967
|
-
t5 = [resourceId, t4];
|
|
968
|
-
$[2] = resourceId;
|
|
969
|
-
$[3] = t4;
|
|
970
|
-
$[4] = t5;
|
|
971
|
-
} else {
|
|
972
|
-
t5 = $[4];
|
|
973
|
-
}
|
|
974
|
-
let t6;
|
|
975
|
-
if ($[5] !== api || $[6] !== finalId || $[7] !== finalResource) {
|
|
976
|
-
t6 = () => api.resources.find(finalResource, finalId);
|
|
977
|
-
$[5] = api;
|
|
978
|
-
$[6] = finalId;
|
|
979
|
-
$[7] = finalResource;
|
|
980
|
-
$[8] = t6;
|
|
981
|
-
} else {
|
|
982
|
-
t6 = $[8];
|
|
983
|
-
}
|
|
984
|
-
let t7;
|
|
985
|
-
if ($[9] !== opts || $[10] !== t5 || $[11] !== t6) {
|
|
986
|
-
t7 = {
|
|
987
|
-
queryKey: t5,
|
|
988
|
-
queryFn: t6,
|
|
989
|
-
...opts
|
|
990
|
-
};
|
|
991
|
-
$[9] = opts;
|
|
992
|
-
$[10] = t5;
|
|
993
|
-
$[11] = t6;
|
|
994
|
-
$[12] = t7;
|
|
995
|
-
} else {
|
|
996
|
-
t7 = $[12];
|
|
997
|
-
}
|
|
998
|
-
const t8 = useQuery(t7);
|
|
999
|
-
let request;
|
|
1000
|
-
let t9;
|
|
1001
|
-
if ($[13] !== t8) {
|
|
1002
|
-
({
|
|
1003
|
-
data: t9,
|
|
1004
|
-
...request
|
|
1005
|
-
} = t8);
|
|
1006
|
-
$[13] = t8;
|
|
1007
|
-
$[14] = request;
|
|
1008
|
-
$[15] = t9;
|
|
1009
|
-
} else {
|
|
1010
|
-
request = $[14];
|
|
1011
|
-
t9 = $[15];
|
|
1012
|
-
}
|
|
1013
|
-
const data = t9 === undefined ? null : t9;
|
|
1014
|
-
let t10;
|
|
1015
|
-
if ($[16] !== data || $[17] !== request) {
|
|
1016
|
-
t10 = {
|
|
1017
|
-
item: data,
|
|
1018
|
-
...request
|
|
1019
|
-
};
|
|
1020
|
-
$[16] = data;
|
|
1021
|
-
$[17] = request;
|
|
1022
|
-
$[18] = t10;
|
|
1023
|
-
} else {
|
|
1024
|
-
t10 = $[18];
|
|
1025
|
-
}
|
|
1026
|
-
return t10;
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
function useResourceItems(t0, t1, t2, t3, t4) {
|
|
1030
|
-
const $ = c(11);
|
|
1031
|
-
const resource = t0 === undefined ? null : t0;
|
|
1032
|
-
const query = t1 === undefined ? null : t1;
|
|
1033
|
-
const page = t2 === undefined ? null : t2;
|
|
1034
|
-
const count = t3 === undefined ? null : t3;
|
|
1035
|
-
const opts = t4 === undefined ? null : t4;
|
|
1036
|
-
const api = useApi();
|
|
1037
|
-
const providedResource = usePanneauResource(isString(resource) || isObject(resource) ? resource : null);
|
|
1038
|
-
const firstIsResource = (isString(resource) || isObject(resource)) && providedResource !== null;
|
|
1039
|
-
const contextResource = useResource();
|
|
1040
|
-
const finalResource = providedResource || contextResource;
|
|
1041
|
-
let t5;
|
|
1042
|
-
if ($[0] !== finalResource) {
|
|
1043
|
-
t5 = finalResource || {};
|
|
1044
|
-
$[0] = finalResource;
|
|
1045
|
-
$[1] = t5;
|
|
1046
|
-
} else {
|
|
1047
|
-
t5 = $[1];
|
|
1048
|
-
}
|
|
1049
|
-
const {
|
|
1050
|
-
id: t6
|
|
1051
|
-
} = t5;
|
|
1052
|
-
const resourceId = t6 === undefined ? null : t6;
|
|
1053
|
-
const finalQuery = firstIsResource ? query : resource;
|
|
1054
|
-
const finalPage = firstIsResource ? page : query;
|
|
1055
|
-
const finalCount = firstIsResource ? count : page;
|
|
1056
|
-
const finalOpts = firstIsResource ? opts : count;
|
|
1057
|
-
let t7;
|
|
1058
|
-
if ($[2] !== api || $[3] !== finalResource) {
|
|
1059
|
-
t7 = (query_0, t8, t9) => {
|
|
1060
|
-
const requestedPage = t8 === undefined ? null : t8;
|
|
1061
|
-
const count_0 = t9 === undefined ? null : t9;
|
|
1062
|
-
return api.resources.get(finalResource, query_0, requestedPage, count_0);
|
|
1063
|
-
};
|
|
1064
|
-
$[2] = api;
|
|
1065
|
-
$[3] = finalResource;
|
|
1066
|
-
$[4] = t7;
|
|
1067
|
-
} else {
|
|
1068
|
-
t7 = $[4];
|
|
1069
|
-
}
|
|
1070
|
-
const getItems = t7;
|
|
1071
|
-
let t8;
|
|
1072
|
-
if ($[5] !== finalCount || $[6] !== finalOpts || $[7] !== finalPage || $[8] !== finalQuery || $[9] !== getItems) {
|
|
1073
|
-
t8 = {
|
|
1074
|
-
getItems,
|
|
1075
|
-
query: finalQuery,
|
|
1076
|
-
page: finalPage,
|
|
1077
|
-
count: finalCount,
|
|
1078
|
-
...finalOpts
|
|
1079
|
-
};
|
|
1080
|
-
$[5] = finalCount;
|
|
1081
|
-
$[6] = finalOpts;
|
|
1082
|
-
$[7] = finalPage;
|
|
1083
|
-
$[8] = finalQuery;
|
|
1084
|
-
$[9] = getItems;
|
|
1085
|
-
$[10] = t8;
|
|
1086
|
-
} else {
|
|
1087
|
-
t8 = $[10];
|
|
1088
|
-
}
|
|
1089
|
-
return useItems(resourceId, t8);
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
function useResourceStore(resource, t0) {
|
|
1093
|
-
const $ = c(30);
|
|
1094
|
-
let t1;
|
|
1095
|
-
if ($[0] !== t0) {
|
|
1096
|
-
t1 = t0 === undefined ? {} : t0;
|
|
1097
|
-
$[0] = t0;
|
|
1098
|
-
$[1] = t1;
|
|
1099
|
-
} else {
|
|
1100
|
-
t1 = $[1];
|
|
1101
|
-
}
|
|
1102
|
-
const options = t1;
|
|
1103
|
-
const providedResource = usePanneauResource(resource);
|
|
1104
|
-
const contextResource = useResource();
|
|
1105
|
-
const finalResource = providedResource || contextResource;
|
|
1106
|
-
let t2;
|
|
1107
|
-
if ($[2] !== finalResource) {
|
|
1108
|
-
t2 = finalResource || {};
|
|
1109
|
-
$[2] = finalResource;
|
|
1110
|
-
$[3] = t2;
|
|
1111
|
-
} else {
|
|
1112
|
-
t2 = $[3];
|
|
1113
|
-
}
|
|
1114
|
-
const {
|
|
1115
|
-
id: t3
|
|
1116
|
-
} = t2;
|
|
1117
|
-
const resourceId = t3 === undefined ? null : t3;
|
|
1118
|
-
let t4;
|
|
1119
|
-
if ($[4] !== options) {
|
|
1120
|
-
t4 = options || {};
|
|
1121
|
-
$[4] = options;
|
|
1122
|
-
$[5] = t4;
|
|
1123
|
-
} else {
|
|
1124
|
-
t4 = $[5];
|
|
1125
|
-
}
|
|
1126
|
-
let otherOptions;
|
|
1127
|
-
let t5;
|
|
1128
|
-
if ($[6] !== t4) {
|
|
1129
|
-
({
|
|
1130
|
-
onSuccess: t5,
|
|
1131
|
-
...otherOptions
|
|
1132
|
-
} = t4);
|
|
1133
|
-
$[6] = t4;
|
|
1134
|
-
$[7] = otherOptions;
|
|
1135
|
-
$[8] = t5;
|
|
1136
|
-
} else {
|
|
1137
|
-
otherOptions = $[7];
|
|
1138
|
-
t5 = $[8];
|
|
1139
|
-
}
|
|
1140
|
-
const customOnSuccess = t5 === undefined ? null : t5;
|
|
1141
|
-
const api = useApi();
|
|
1142
|
-
const queryClient = useQueryClient();
|
|
1143
|
-
let t6;
|
|
1144
|
-
if ($[9] !== api || $[10] !== finalResource) {
|
|
1145
|
-
t6 = data => api.resources.store(finalResource, data);
|
|
1146
|
-
$[9] = api;
|
|
1147
|
-
$[10] = finalResource;
|
|
1148
|
-
$[11] = t6;
|
|
1149
|
-
} else {
|
|
1150
|
-
t6 = $[11];
|
|
1151
|
-
}
|
|
1152
|
-
let t7;
|
|
1153
|
-
if ($[12] !== customOnSuccess || $[13] !== queryClient || $[14] !== resourceId) {
|
|
1154
|
-
t7 = (data_0, ...t8) => {
|
|
1155
|
-
const args = t8;
|
|
1156
|
-
queryClient.invalidateQueries({
|
|
1157
|
-
queryKey: [resourceId]
|
|
1158
|
-
});
|
|
1159
|
-
if (customOnSuccess !== null) {
|
|
1160
|
-
return customOnSuccess(data_0, ...args);
|
|
1161
|
-
}
|
|
1162
|
-
};
|
|
1163
|
-
$[12] = customOnSuccess;
|
|
1164
|
-
$[13] = queryClient;
|
|
1165
|
-
$[14] = resourceId;
|
|
1166
|
-
$[15] = t7;
|
|
1167
|
-
} else {
|
|
1168
|
-
t7 = $[15];
|
|
1169
|
-
}
|
|
1170
|
-
let t8;
|
|
1171
|
-
if ($[16] !== otherOptions || $[17] !== t6 || $[18] !== t7) {
|
|
1172
|
-
t8 = {
|
|
1173
|
-
mutationFn: t6,
|
|
1174
|
-
onSuccess: t7,
|
|
1175
|
-
...otherOptions
|
|
1176
|
-
};
|
|
1177
|
-
$[16] = otherOptions;
|
|
1178
|
-
$[17] = t6;
|
|
1179
|
-
$[18] = t7;
|
|
1180
|
-
$[19] = t8;
|
|
1181
|
-
} else {
|
|
1182
|
-
t8 = $[19];
|
|
1183
|
-
}
|
|
1184
|
-
const t9 = useMutation(t8);
|
|
1185
|
-
let isPending;
|
|
1186
|
-
let mutate;
|
|
1187
|
-
let mutateAsync;
|
|
1188
|
-
let other;
|
|
1189
|
-
if ($[20] !== t9) {
|
|
1190
|
-
({
|
|
1191
|
-
mutate,
|
|
1192
|
-
mutateAsync,
|
|
1193
|
-
isPending,
|
|
1194
|
-
...other
|
|
1195
|
-
} = t9);
|
|
1196
|
-
$[20] = t9;
|
|
1197
|
-
$[21] = isPending;
|
|
1198
|
-
$[22] = mutate;
|
|
1199
|
-
$[23] = mutateAsync;
|
|
1200
|
-
$[24] = other;
|
|
1201
|
-
} else {
|
|
1202
|
-
isPending = $[21];
|
|
1203
|
-
mutate = $[22];
|
|
1204
|
-
mutateAsync = $[23];
|
|
1205
|
-
other = $[24];
|
|
1206
|
-
}
|
|
1207
|
-
let t10;
|
|
1208
|
-
if ($[25] !== isPending || $[26] !== mutate || $[27] !== mutateAsync || $[28] !== other) {
|
|
1209
|
-
t10 = {
|
|
1210
|
-
store: mutate,
|
|
1211
|
-
storeAsync: mutateAsync,
|
|
1212
|
-
loading: isPending,
|
|
1213
|
-
mutate,
|
|
1214
|
-
mutateAsync,
|
|
1215
|
-
isPending,
|
|
1216
|
-
...other
|
|
1217
|
-
};
|
|
1218
|
-
$[25] = isPending;
|
|
1219
|
-
$[26] = mutate;
|
|
1220
|
-
$[27] = mutateAsync;
|
|
1221
|
-
$[28] = other;
|
|
1222
|
-
$[29] = t10;
|
|
1223
|
-
} else {
|
|
1224
|
-
t10 = $[29];
|
|
1225
|
-
}
|
|
1226
|
-
return t10;
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
function useResourceUpdate(resource, t0, t1) {
|
|
1230
|
-
const $ = c(32);
|
|
1231
|
-
const id = t0 === undefined ? null : t0;
|
|
1232
|
-
let t2;
|
|
1233
|
-
if ($[0] !== t1) {
|
|
1234
|
-
t2 = t1 === undefined ? {} : t1;
|
|
1235
|
-
$[0] = t1;
|
|
1236
|
-
$[1] = t2;
|
|
1237
|
-
} else {
|
|
1238
|
-
t2 = $[1];
|
|
1239
|
-
}
|
|
1240
|
-
const options = t2;
|
|
1241
|
-
const {
|
|
1242
|
-
resource: finalResource,
|
|
1243
|
-
id: finalId,
|
|
1244
|
-
options: finalOptions
|
|
1245
|
-
} = useResourceArguments(resource, id, options);
|
|
1246
|
-
let t3;
|
|
1247
|
-
if ($[2] !== finalOptions) {
|
|
1248
|
-
t3 = finalOptions || {};
|
|
1249
|
-
$[2] = finalOptions;
|
|
1250
|
-
$[3] = t3;
|
|
1251
|
-
} else {
|
|
1252
|
-
t3 = $[3];
|
|
1253
|
-
}
|
|
1254
|
-
let otherOptions;
|
|
1255
|
-
let t4;
|
|
1256
|
-
if ($[4] !== t3) {
|
|
1257
|
-
({
|
|
1258
|
-
onSuccess: t4,
|
|
1259
|
-
...otherOptions
|
|
1260
|
-
} = t3);
|
|
1261
|
-
$[4] = t3;
|
|
1262
|
-
$[5] = otherOptions;
|
|
1263
|
-
$[6] = t4;
|
|
1264
|
-
} else {
|
|
1265
|
-
otherOptions = $[5];
|
|
1266
|
-
t4 = $[6];
|
|
1267
|
-
}
|
|
1268
|
-
const customOnSuccess = t4 === undefined ? null : t4;
|
|
1269
|
-
let t5;
|
|
1270
|
-
if ($[7] !== finalResource) {
|
|
1271
|
-
t5 = finalResource || {};
|
|
1272
|
-
$[7] = finalResource;
|
|
1273
|
-
$[8] = t5;
|
|
1274
|
-
} else {
|
|
1275
|
-
t5 = $[8];
|
|
1276
|
-
}
|
|
1277
|
-
const {
|
|
1278
|
-
id: t6
|
|
1279
|
-
} = t5;
|
|
1280
|
-
const resourceId = t6 === undefined ? null : t6;
|
|
1281
|
-
const api = useApi();
|
|
1282
|
-
const queryClient = useQueryClient();
|
|
1283
|
-
let t7;
|
|
1284
|
-
if ($[9] !== api || $[10] !== finalId || $[11] !== finalResource) {
|
|
1285
|
-
t7 = data => api.resources.update(finalResource, finalId, data);
|
|
1286
|
-
$[9] = api;
|
|
1287
|
-
$[10] = finalId;
|
|
1288
|
-
$[11] = finalResource;
|
|
1289
|
-
$[12] = t7;
|
|
1290
|
-
} else {
|
|
1291
|
-
t7 = $[12];
|
|
1292
|
-
}
|
|
1293
|
-
let t8;
|
|
1294
|
-
if ($[13] !== customOnSuccess || $[14] !== finalId || $[15] !== queryClient || $[16] !== resourceId) {
|
|
1295
|
-
t8 = (data_0, ...t9) => {
|
|
1296
|
-
const args = t9;
|
|
1297
|
-
queryClient.setQueryData([resourceId, String(finalId)], data_0);
|
|
1298
|
-
queryClient.invalidateQueries({
|
|
1299
|
-
queryKey: [resourceId],
|
|
1300
|
-
predicate: t10 => {
|
|
1301
|
-
const {
|
|
1302
|
-
queryKey
|
|
1303
|
-
} = t10;
|
|
1304
|
-
return String(queryKey[1]) !== String(finalId);
|
|
1305
|
-
}
|
|
1306
|
-
});
|
|
1307
|
-
if (customOnSuccess !== null) {
|
|
1308
|
-
return customOnSuccess(data_0, ...args);
|
|
1309
|
-
}
|
|
1310
|
-
};
|
|
1311
|
-
$[13] = customOnSuccess;
|
|
1312
|
-
$[14] = finalId;
|
|
1313
|
-
$[15] = queryClient;
|
|
1314
|
-
$[16] = resourceId;
|
|
1315
|
-
$[17] = t8;
|
|
1316
|
-
} else {
|
|
1317
|
-
t8 = $[17];
|
|
1318
|
-
}
|
|
1319
|
-
let t9;
|
|
1320
|
-
if ($[18] !== otherOptions || $[19] !== t7 || $[20] !== t8) {
|
|
1321
|
-
t9 = {
|
|
1322
|
-
mutationFn: t7,
|
|
1323
|
-
onSuccess: t8,
|
|
1324
|
-
...otherOptions
|
|
1325
|
-
};
|
|
1326
|
-
$[18] = otherOptions;
|
|
1327
|
-
$[19] = t7;
|
|
1328
|
-
$[20] = t8;
|
|
1329
|
-
$[21] = t9;
|
|
1330
|
-
} else {
|
|
1331
|
-
t9 = $[21];
|
|
1332
|
-
}
|
|
1333
|
-
const t10 = useMutation(t9);
|
|
1334
|
-
let isPending;
|
|
1335
|
-
let mutate;
|
|
1336
|
-
let mutateAsync;
|
|
1337
|
-
let other;
|
|
1338
|
-
if ($[22] !== t10) {
|
|
1339
|
-
({
|
|
1340
|
-
mutate,
|
|
1341
|
-
mutateAsync,
|
|
1342
|
-
isPending,
|
|
1343
|
-
...other
|
|
1344
|
-
} = t10);
|
|
1345
|
-
$[22] = t10;
|
|
1346
|
-
$[23] = isPending;
|
|
1347
|
-
$[24] = mutate;
|
|
1348
|
-
$[25] = mutateAsync;
|
|
1349
|
-
$[26] = other;
|
|
1350
|
-
} else {
|
|
1351
|
-
isPending = $[23];
|
|
1352
|
-
mutate = $[24];
|
|
1353
|
-
mutateAsync = $[25];
|
|
1354
|
-
other = $[26];
|
|
1355
|
-
}
|
|
1356
|
-
let t11;
|
|
1357
|
-
if ($[27] !== isPending || $[28] !== mutate || $[29] !== mutateAsync || $[30] !== other) {
|
|
1358
|
-
t11 = {
|
|
1359
|
-
update: mutate,
|
|
1360
|
-
updateAsync: mutateAsync,
|
|
1361
|
-
loading: isPending,
|
|
1362
|
-
mutate,
|
|
1363
|
-
mutateAsync,
|
|
1364
|
-
isPending,
|
|
1365
|
-
...other
|
|
1366
|
-
};
|
|
1367
|
-
$[27] = isPending;
|
|
1368
|
-
$[28] = mutate;
|
|
1369
|
-
$[29] = mutateAsync;
|
|
1370
|
-
$[30] = other;
|
|
1371
|
-
$[31] = t11;
|
|
1372
|
-
} else {
|
|
1373
|
-
t11 = $[31];
|
|
1374
|
-
}
|
|
1375
|
-
return t11;
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
function useResourceClone(t0, t1, t2) {
|
|
1379
|
-
const $ = c(31);
|
|
1380
|
-
const resource = t0 === undefined ? null : t0;
|
|
1381
|
-
const id = t1 === undefined ? null : t1;
|
|
1382
|
-
let t3;
|
|
1383
|
-
if ($[0] !== t2) {
|
|
1384
|
-
t3 = t2 === undefined ? {} : t2;
|
|
1385
|
-
$[0] = t2;
|
|
1386
|
-
$[1] = t3;
|
|
1387
|
-
} else {
|
|
1388
|
-
t3 = $[1];
|
|
1389
|
-
}
|
|
1390
|
-
const options = t3;
|
|
1391
|
-
const {
|
|
1392
|
-
resource: finalResource,
|
|
1393
|
-
id: finalId,
|
|
1394
|
-
options: finalOptions
|
|
1395
|
-
} = useResourceArguments(resource, id, options);
|
|
1396
|
-
let t4;
|
|
1397
|
-
if ($[2] !== finalOptions) {
|
|
1398
|
-
t4 = finalOptions || {};
|
|
1399
|
-
$[2] = finalOptions;
|
|
1400
|
-
$[3] = t4;
|
|
1401
|
-
} else {
|
|
1402
|
-
t4 = $[3];
|
|
1403
|
-
}
|
|
1404
|
-
let otherOptions;
|
|
1405
|
-
let t5;
|
|
1406
|
-
if ($[4] !== t4) {
|
|
1407
|
-
({
|
|
1408
|
-
onSuccess: t5,
|
|
1409
|
-
...otherOptions
|
|
1410
|
-
} = t4);
|
|
1411
|
-
$[4] = t4;
|
|
1412
|
-
$[5] = otherOptions;
|
|
1413
|
-
$[6] = t5;
|
|
1414
|
-
} else {
|
|
1415
|
-
otherOptions = $[5];
|
|
1416
|
-
t5 = $[6];
|
|
1417
|
-
}
|
|
1418
|
-
const customOnSuccess = t5 === undefined ? null : t5;
|
|
1419
|
-
let t6;
|
|
1420
|
-
if ($[7] !== finalResource) {
|
|
1421
|
-
t6 = finalResource || {};
|
|
1422
|
-
$[7] = finalResource;
|
|
1423
|
-
$[8] = t6;
|
|
1424
|
-
} else {
|
|
1425
|
-
t6 = $[8];
|
|
1426
|
-
}
|
|
1427
|
-
const {
|
|
1428
|
-
id: t7
|
|
1429
|
-
} = t6;
|
|
1430
|
-
const resourceId = t7 === undefined ? null : t7;
|
|
1431
|
-
const api = useApi();
|
|
1432
|
-
const queryClient = useQueryClient();
|
|
1433
|
-
let t8;
|
|
1434
|
-
if ($[9] !== api || $[10] !== finalId || $[11] !== finalResource) {
|
|
1435
|
-
t8 = t9 => {
|
|
1436
|
-
const providedId = t9 === undefined ? null : t9;
|
|
1437
|
-
return api.resources.clone(finalResource, providedId ?? finalId);
|
|
1438
|
-
};
|
|
1439
|
-
$[9] = api;
|
|
1440
|
-
$[10] = finalId;
|
|
1441
|
-
$[11] = finalResource;
|
|
1442
|
-
$[12] = t8;
|
|
1443
|
-
} else {
|
|
1444
|
-
t8 = $[12];
|
|
1445
|
-
}
|
|
1446
|
-
let t9;
|
|
1447
|
-
if ($[13] !== customOnSuccess || $[14] !== queryClient || $[15] !== resourceId) {
|
|
1448
|
-
t9 = (data, variables, ...t10) => {
|
|
1449
|
-
const args = t10;
|
|
1450
|
-
queryClient.invalidateQueries({
|
|
1451
|
-
queryKey: [resourceId]
|
|
1452
|
-
});
|
|
1453
|
-
if (customOnSuccess !== null) {
|
|
1454
|
-
return customOnSuccess(data, variables, ...args);
|
|
1455
|
-
}
|
|
1456
|
-
};
|
|
1457
|
-
$[13] = customOnSuccess;
|
|
1458
|
-
$[14] = queryClient;
|
|
1459
|
-
$[15] = resourceId;
|
|
1460
|
-
$[16] = t9;
|
|
1461
|
-
} else {
|
|
1462
|
-
t9 = $[16];
|
|
1463
|
-
}
|
|
1464
|
-
let t10;
|
|
1465
|
-
if ($[17] !== otherOptions || $[18] !== t8 || $[19] !== t9) {
|
|
1466
|
-
t10 = {
|
|
1467
|
-
mutationFn: t8,
|
|
1468
|
-
onSuccess: t9,
|
|
1469
|
-
...otherOptions
|
|
1470
|
-
};
|
|
1471
|
-
$[17] = otherOptions;
|
|
1472
|
-
$[18] = t8;
|
|
1473
|
-
$[19] = t9;
|
|
1474
|
-
$[20] = t10;
|
|
1475
|
-
} else {
|
|
1476
|
-
t10 = $[20];
|
|
1477
|
-
}
|
|
1478
|
-
const t11 = useMutation(t10);
|
|
1479
|
-
let isPending;
|
|
1480
|
-
let mutate;
|
|
1481
|
-
let mutateAsync;
|
|
1482
|
-
let other;
|
|
1483
|
-
if ($[21] !== t11) {
|
|
1484
|
-
({
|
|
1485
|
-
mutate,
|
|
1486
|
-
mutateAsync,
|
|
1487
|
-
isPending,
|
|
1488
|
-
...other
|
|
1489
|
-
} = t11);
|
|
1490
|
-
$[21] = t11;
|
|
1491
|
-
$[22] = isPending;
|
|
1492
|
-
$[23] = mutate;
|
|
1493
|
-
$[24] = mutateAsync;
|
|
1494
|
-
$[25] = other;
|
|
1495
|
-
} else {
|
|
1496
|
-
isPending = $[22];
|
|
1497
|
-
mutate = $[23];
|
|
1498
|
-
mutateAsync = $[24];
|
|
1499
|
-
other = $[25];
|
|
1500
|
-
}
|
|
1501
|
-
let t12;
|
|
1502
|
-
if ($[26] !== isPending || $[27] !== mutate || $[28] !== mutateAsync || $[29] !== other) {
|
|
1503
|
-
t12 = {
|
|
1504
|
-
clone: mutate,
|
|
1505
|
-
cloneAsync: mutateAsync,
|
|
1506
|
-
loading: isPending,
|
|
1507
|
-
mutate,
|
|
1508
|
-
mutateAsync,
|
|
1509
|
-
isPending,
|
|
1510
|
-
...other
|
|
1511
|
-
};
|
|
1512
|
-
$[26] = isPending;
|
|
1513
|
-
$[27] = mutate;
|
|
1514
|
-
$[28] = mutateAsync;
|
|
1515
|
-
$[29] = other;
|
|
1516
|
-
$[30] = t12;
|
|
1517
|
-
} else {
|
|
1518
|
-
t12 = $[30];
|
|
1519
|
-
}
|
|
1520
|
-
return t12;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
function useResourceRestore(t0, t1, t2) {
|
|
1524
|
-
const $ = c(31);
|
|
1525
|
-
const resource = t0 === undefined ? null : t0;
|
|
1526
|
-
const id = t1 === undefined ? null : t1;
|
|
1527
|
-
let t3;
|
|
1528
|
-
if ($[0] !== t2) {
|
|
1529
|
-
t3 = t2 === undefined ? {} : t2;
|
|
1530
|
-
$[0] = t2;
|
|
1531
|
-
$[1] = t3;
|
|
1532
|
-
} else {
|
|
1533
|
-
t3 = $[1];
|
|
1534
|
-
}
|
|
1535
|
-
const options = t3;
|
|
1536
|
-
const {
|
|
1537
|
-
resource: finalResource,
|
|
1538
|
-
id: finalId,
|
|
1539
|
-
options: finalOptions
|
|
1540
|
-
} = useResourceArguments(resource, id, options);
|
|
1541
|
-
let t4;
|
|
1542
|
-
if ($[2] !== finalOptions) {
|
|
1543
|
-
t4 = finalOptions || {};
|
|
1544
|
-
$[2] = finalOptions;
|
|
1545
|
-
$[3] = t4;
|
|
1546
|
-
} else {
|
|
1547
|
-
t4 = $[3];
|
|
1548
|
-
}
|
|
1549
|
-
let otherOptions;
|
|
1550
|
-
let t5;
|
|
1551
|
-
if ($[4] !== t4) {
|
|
1552
|
-
({
|
|
1553
|
-
onSuccess: t5,
|
|
1554
|
-
...otherOptions
|
|
1555
|
-
} = t4);
|
|
1556
|
-
$[4] = t4;
|
|
1557
|
-
$[5] = otherOptions;
|
|
1558
|
-
$[6] = t5;
|
|
1559
|
-
} else {
|
|
1560
|
-
otherOptions = $[5];
|
|
1561
|
-
t5 = $[6];
|
|
1562
|
-
}
|
|
1563
|
-
const customOnSuccess = t5 === undefined ? null : t5;
|
|
1564
|
-
let t6;
|
|
1565
|
-
if ($[7] !== finalResource) {
|
|
1566
|
-
t6 = finalResource || {};
|
|
1567
|
-
$[7] = finalResource;
|
|
1568
|
-
$[8] = t6;
|
|
1569
|
-
} else {
|
|
1570
|
-
t6 = $[8];
|
|
1571
|
-
}
|
|
1572
|
-
const {
|
|
1573
|
-
id: t7
|
|
1574
|
-
} = t6;
|
|
1575
|
-
const resourceId = t7 === undefined ? null : t7;
|
|
1576
|
-
const api = useApi();
|
|
1577
|
-
const queryClient = useQueryClient();
|
|
1578
|
-
let t8;
|
|
1579
|
-
if ($[9] !== api || $[10] !== finalId || $[11] !== finalResource) {
|
|
1580
|
-
t8 = t9 => {
|
|
1581
|
-
const providedId = t9 === undefined ? null : t9;
|
|
1582
|
-
return api.resources.restore(finalResource, providedId ?? finalId);
|
|
1583
|
-
};
|
|
1584
|
-
$[9] = api;
|
|
1585
|
-
$[10] = finalId;
|
|
1586
|
-
$[11] = finalResource;
|
|
1587
|
-
$[12] = t8;
|
|
1588
|
-
} else {
|
|
1589
|
-
t8 = $[12];
|
|
1590
|
-
}
|
|
1591
|
-
let t9;
|
|
1592
|
-
if ($[13] !== customOnSuccess || $[14] !== queryClient || $[15] !== resourceId) {
|
|
1593
|
-
t9 = (data, variables, ...t10) => {
|
|
1594
|
-
const args = t10;
|
|
1595
|
-
queryClient.invalidateQueries({
|
|
1596
|
-
queryKey: [resourceId]
|
|
1597
|
-
});
|
|
1598
|
-
if (customOnSuccess !== null) {
|
|
1599
|
-
return customOnSuccess(data, variables, ...args);
|
|
1600
|
-
}
|
|
1601
|
-
};
|
|
1602
|
-
$[13] = customOnSuccess;
|
|
1603
|
-
$[14] = queryClient;
|
|
1604
|
-
$[15] = resourceId;
|
|
1605
|
-
$[16] = t9;
|
|
1606
|
-
} else {
|
|
1607
|
-
t9 = $[16];
|
|
1608
|
-
}
|
|
1609
|
-
let t10;
|
|
1610
|
-
if ($[17] !== otherOptions || $[18] !== t8 || $[19] !== t9) {
|
|
1611
|
-
t10 = {
|
|
1612
|
-
mutationFn: t8,
|
|
1613
|
-
onSuccess: t9,
|
|
1614
|
-
...otherOptions
|
|
1615
|
-
};
|
|
1616
|
-
$[17] = otherOptions;
|
|
1617
|
-
$[18] = t8;
|
|
1618
|
-
$[19] = t9;
|
|
1619
|
-
$[20] = t10;
|
|
1620
|
-
} else {
|
|
1621
|
-
t10 = $[20];
|
|
1622
|
-
}
|
|
1623
|
-
const t11 = useMutation(t10);
|
|
1624
|
-
let isPending;
|
|
1625
|
-
let mutate;
|
|
1626
|
-
let mutateAsync;
|
|
1627
|
-
let other;
|
|
1628
|
-
if ($[21] !== t11) {
|
|
1629
|
-
({
|
|
1630
|
-
mutate,
|
|
1631
|
-
mutateAsync,
|
|
1632
|
-
isPending,
|
|
1633
|
-
...other
|
|
1634
|
-
} = t11);
|
|
1635
|
-
$[21] = t11;
|
|
1636
|
-
$[22] = isPending;
|
|
1637
|
-
$[23] = mutate;
|
|
1638
|
-
$[24] = mutateAsync;
|
|
1639
|
-
$[25] = other;
|
|
1640
|
-
} else {
|
|
1641
|
-
isPending = $[22];
|
|
1642
|
-
mutate = $[23];
|
|
1643
|
-
mutateAsync = $[24];
|
|
1644
|
-
other = $[25];
|
|
1645
|
-
}
|
|
1646
|
-
let t12;
|
|
1647
|
-
if ($[26] !== isPending || $[27] !== mutate || $[28] !== mutateAsync || $[29] !== other) {
|
|
1648
|
-
t12 = {
|
|
1649
|
-
restore: mutate,
|
|
1650
|
-
restoreAsync: mutateAsync,
|
|
1651
|
-
loading: isPending,
|
|
1652
|
-
mutate,
|
|
1653
|
-
mutateAsync,
|
|
1654
|
-
isPending,
|
|
1655
|
-
...other
|
|
1656
|
-
};
|
|
1657
|
-
$[26] = isPending;
|
|
1658
|
-
$[27] = mutate;
|
|
1659
|
-
$[28] = mutateAsync;
|
|
1660
|
-
$[29] = other;
|
|
1661
|
-
$[30] = t12;
|
|
1662
|
-
} else {
|
|
1663
|
-
t12 = $[30];
|
|
1664
|
-
}
|
|
1665
|
-
return t12;
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
const QueryContext = /*#__PURE__*/createContext(null);
|
|
1669
|
-
function useQueryContext() {
|
|
1670
|
-
return use(QueryContext);
|
|
1671
|
-
}
|
|
1672
|
-
function QueryProvider(t0) {
|
|
1673
|
-
const $ = c(10);
|
|
1674
|
-
const {
|
|
1675
|
-
config: t1,
|
|
1676
|
-
initialKey: t2,
|
|
1677
|
-
initialData: t3,
|
|
1678
|
-
children
|
|
1679
|
-
} = t0;
|
|
1680
|
-
const initialConfig = t1 === undefined ? null : t1;
|
|
1681
|
-
const initialKey = t2 === undefined ? null : t2;
|
|
1682
|
-
const initialData = t3 === undefined ? null : t3;
|
|
1683
|
-
let t4;
|
|
1684
|
-
if ($[0] !== initialConfig || $[1] !== initialData || $[2] !== initialKey) {
|
|
1685
|
-
t4 = () => {
|
|
1686
|
-
const newClient = new QueryClient({
|
|
1687
|
-
defaultOptions: {
|
|
1688
|
-
queries: {
|
|
1689
|
-
staleTime: Infinity
|
|
1690
|
-
}
|
|
1691
|
-
},
|
|
1692
|
-
...initialConfig
|
|
1693
|
-
});
|
|
1694
|
-
if (initialKey !== null && initialData !== null) {
|
|
1695
|
-
newClient.setQueryData(initialKey, initialData);
|
|
1696
|
-
}
|
|
1697
|
-
return newClient;
|
|
1698
|
-
};
|
|
1699
|
-
$[0] = initialConfig;
|
|
1700
|
-
$[1] = initialData;
|
|
1701
|
-
$[2] = initialKey;
|
|
1702
|
-
$[3] = t4;
|
|
1703
|
-
} else {
|
|
1704
|
-
t4 = $[3];
|
|
1705
|
-
}
|
|
1706
|
-
const [client] = useState(t4);
|
|
1707
|
-
let t5;
|
|
1708
|
-
if ($[4] !== children || $[5] !== client) {
|
|
1709
|
-
t5 = /*#__PURE__*/jsx(QueryClientProvider, {
|
|
1710
|
-
client: client,
|
|
1711
|
-
children: children
|
|
1712
|
-
});
|
|
1713
|
-
$[4] = children;
|
|
1714
|
-
$[5] = client;
|
|
1715
|
-
$[6] = t5;
|
|
1716
|
-
} else {
|
|
1717
|
-
t5 = $[6];
|
|
1718
|
-
}
|
|
1719
|
-
let t6;
|
|
1720
|
-
if ($[7] !== client || $[8] !== t5) {
|
|
1721
|
-
t6 = /*#__PURE__*/jsx(QueryContext, {
|
|
1722
|
-
value: client,
|
|
1723
|
-
children: t5
|
|
1724
|
-
});
|
|
1725
|
-
$[7] = client;
|
|
1726
|
-
$[8] = t5;
|
|
1727
|
-
$[9] = t6;
|
|
1728
|
-
} else {
|
|
1729
|
-
t6 = $[9];
|
|
1730
|
-
}
|
|
1731
|
-
return t6;
|
|
1732
|
-
}
|
|
1733
|
-
|
|
1734
|
-
function DataProvider(t0) {
|
|
1735
|
-
const $ = c(11);
|
|
1736
|
-
const {
|
|
1737
|
-
api: t1,
|
|
1738
|
-
apiBaseUrl: t2,
|
|
1739
|
-
routes: t3,
|
|
1740
|
-
baseUrl: t4,
|
|
1741
|
-
children: t5,
|
|
1742
|
-
queryConfig: t6,
|
|
1743
|
-
initialQueryKey: t7,
|
|
1744
|
-
initialQueryData: t8,
|
|
1745
|
-
onUnauthorized: t9
|
|
1746
|
-
} = t0;
|
|
1747
|
-
const api = t1 === undefined ? null : t1;
|
|
1748
|
-
const apiBaseUrl = t2 === undefined ? undefined : t2;
|
|
1749
|
-
const routes = t3 === undefined ? undefined : t3;
|
|
1750
|
-
const baseUrl = t4 === undefined ? undefined : t4;
|
|
1751
|
-
const children = t5 === undefined ? null : t5;
|
|
1752
|
-
const queryConfig = t6 === undefined ? null : t6;
|
|
1753
|
-
const initialQueryKey = t7 === undefined ? null : t7;
|
|
1754
|
-
const initialQueryData = t8 === undefined ? null : t8;
|
|
1755
|
-
const onUnauthorized = t9 === undefined ? null : t9;
|
|
1756
|
-
const t10 = baseUrl ?? apiBaseUrl;
|
|
1757
|
-
let t11;
|
|
1758
|
-
if ($[0] !== api || $[1] !== children || $[2] !== onUnauthorized || $[3] !== routes || $[4] !== t10) {
|
|
1759
|
-
t11 = /*#__PURE__*/jsx(ApiProvider, {
|
|
1760
|
-
api: api,
|
|
1761
|
-
baseUrl: t10,
|
|
1762
|
-
routes: routes,
|
|
1763
|
-
onUnauthorized: onUnauthorized,
|
|
1764
|
-
children: children
|
|
1765
|
-
});
|
|
1766
|
-
$[0] = api;
|
|
1767
|
-
$[1] = children;
|
|
1768
|
-
$[2] = onUnauthorized;
|
|
1769
|
-
$[3] = routes;
|
|
1770
|
-
$[4] = t10;
|
|
1771
|
-
$[5] = t11;
|
|
1772
|
-
} else {
|
|
1773
|
-
t11 = $[5];
|
|
1774
|
-
}
|
|
1775
|
-
let t12;
|
|
1776
|
-
if ($[6] !== initialQueryData || $[7] !== initialQueryKey || $[8] !== queryConfig || $[9] !== t11) {
|
|
1777
|
-
t12 = /*#__PURE__*/jsx(QueryProvider, {
|
|
1778
|
-
config: queryConfig,
|
|
1779
|
-
initialKey: initialQueryKey,
|
|
1780
|
-
initialData: initialQueryData,
|
|
1781
|
-
children: t11
|
|
1782
|
-
});
|
|
1783
|
-
$[6] = initialQueryData;
|
|
1784
|
-
$[7] = initialQueryKey;
|
|
1785
|
-
$[8] = queryConfig;
|
|
1786
|
-
$[9] = t11;
|
|
1787
|
-
$[10] = t12;
|
|
1788
|
-
} else {
|
|
1789
|
-
t12 = $[10];
|
|
1790
|
-
}
|
|
1791
|
-
return t12;
|
|
1792
|
-
}
|
|
1793
|
-
|
|
1794
|
-
export { Api, ApiProvider, Base as BaseApi, DataProvider, QueryProvider, useApi, useItem, useItems, useQueryContext, useResourceClone, useResourceDestroy, useResourceItem, useResourceItems, useResourceRestore, useResourceStore, useResourceUpdate };
|
|
1
|
+
import { ApiError, ConflictError, ForbiddenError, InvalidResponseError, NotFoundError, UnauthorizedError, ValidationError, createApiError, isApiError } from "./errors.js";
|
|
2
|
+
import { createRestAdapter } from "./rest.js";
|
|
3
|
+
export { ApiError, ConflictError, ForbiddenError, InvalidResponseError, NotFoundError, UnauthorizedError, ValidationError, createApiError, createRestAdapter, isApiError };
|