@bigbinary/neeto-payments-frontend 1.4.17 → 1.5.0-beta1
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.cjs.js +2738 -271
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +2639 -171
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { useState, useMemo, useEffect, useTransition } from 'react';
|
|
3
3
|
import { t as t$1 } from 'i18next';
|
|
4
|
-
import { noop, camelToSnakeCase, isPresent, snakeToCamelCase, capitalize, removeBy, filterBy, isNotPresent, humanize } from '@bigbinary/neeto-cist';
|
|
4
|
+
import { noop as noop$2, camelToSnakeCase, isPresent, snakeToCamelCase, capitalize, removeBy, filterBy, isNotPresent, humanize } from '@bigbinary/neeto-cist';
|
|
5
5
|
import { useQueryParams, withTitle, useMutationWithInvalidation, withT, useStateWithDependency } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
6
6
|
import { buildFiltersFromURL, Bar } from '@bigbinary/neeto-filters-frontend';
|
|
7
7
|
import Header from '@bigbinary/neeto-molecules/Header';
|
|
@@ -9,11 +9,8 @@ import SubHeader from '@bigbinary/neeto-molecules/SubHeader';
|
|
|
9
9
|
import Tab from '@bigbinary/neetoui/Tab';
|
|
10
10
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
11
11
|
import { useTranslation, Trans } from 'react-i18next';
|
|
12
|
-
import {
|
|
13
|
-
import { ReactQueryDevtools } from 'react-query/devtools';
|
|
12
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
14
13
|
import { DEFAULT_STALE_TIME, DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE } from '@bigbinary/neeto-commons-frontend/constants';
|
|
15
|
-
import Toastr from '@bigbinary/neetoui/Toastr';
|
|
16
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
17
14
|
import { Download, Down, Right } from '@bigbinary/neeto-icons';
|
|
18
15
|
import Button from '@bigbinary/neetoui/Button';
|
|
19
16
|
import Modal from '@bigbinary/neetoui/Modal';
|
|
@@ -144,28 +141,2421 @@ function _defineProperty(obj, key, value) {
|
|
|
144
141
|
return obj;
|
|
145
142
|
}
|
|
146
143
|
|
|
144
|
+
// src/subscribable.ts
|
|
145
|
+
var Subscribable = class {
|
|
146
|
+
constructor() {
|
|
147
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
148
|
+
this.subscribe = this.subscribe.bind(this);
|
|
149
|
+
}
|
|
150
|
+
subscribe(listener) {
|
|
151
|
+
this.listeners.add(listener);
|
|
152
|
+
this.onSubscribe();
|
|
153
|
+
return () => {
|
|
154
|
+
this.listeners.delete(listener);
|
|
155
|
+
this.onUnsubscribe();
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
hasListeners() {
|
|
159
|
+
return this.listeners.size > 0;
|
|
160
|
+
}
|
|
161
|
+
onSubscribe() {
|
|
162
|
+
}
|
|
163
|
+
onUnsubscribe() {
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// src/utils.ts
|
|
168
|
+
var isServer = typeof window === "undefined" || "Deno" in globalThis;
|
|
169
|
+
function noop$1() {
|
|
170
|
+
return void 0;
|
|
171
|
+
}
|
|
172
|
+
function functionalUpdate(updater, input) {
|
|
173
|
+
return typeof updater === "function" ? updater(input) : updater;
|
|
174
|
+
}
|
|
175
|
+
function isValidTimeout(value) {
|
|
176
|
+
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
177
|
+
}
|
|
178
|
+
function timeUntilStale(updatedAt, staleTime) {
|
|
179
|
+
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
180
|
+
}
|
|
181
|
+
function matchQuery(filters, query) {
|
|
182
|
+
const {
|
|
183
|
+
type = "all",
|
|
184
|
+
exact,
|
|
185
|
+
fetchStatus,
|
|
186
|
+
predicate,
|
|
187
|
+
queryKey,
|
|
188
|
+
stale
|
|
189
|
+
} = filters;
|
|
190
|
+
if (queryKey) {
|
|
191
|
+
if (exact) {
|
|
192
|
+
if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
} else if (!partialMatchKey(query.queryKey, queryKey)) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (type !== "all") {
|
|
200
|
+
const isActive = query.isActive();
|
|
201
|
+
if (type === "active" && !isActive) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
if (type === "inactive" && isActive) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (typeof stale === "boolean" && query.isStale() !== stale) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
if (fetchStatus && fetchStatus !== query.state.fetchStatus) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
if (predicate && !predicate(query)) {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
function matchMutation(filters, mutation) {
|
|
220
|
+
const { exact, status, predicate, mutationKey } = filters;
|
|
221
|
+
if (mutationKey) {
|
|
222
|
+
if (!mutation.options.mutationKey) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
if (exact) {
|
|
226
|
+
if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
} else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (status && mutation.state.status !== status) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
if (predicate && !predicate(mutation)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
function hashQueryKeyByOptions(queryKey, options) {
|
|
242
|
+
const hashFn = options?.queryKeyHashFn || hashKey;
|
|
243
|
+
return hashFn(queryKey);
|
|
244
|
+
}
|
|
245
|
+
function hashKey(queryKey) {
|
|
246
|
+
return JSON.stringify(
|
|
247
|
+
queryKey,
|
|
248
|
+
(_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
|
|
249
|
+
result[key] = val[key];
|
|
250
|
+
return result;
|
|
251
|
+
}, {}) : val
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
function partialMatchKey(a, b) {
|
|
255
|
+
if (a === b) {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
if (typeof a !== typeof b) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
262
|
+
return !Object.keys(b).some((key) => !partialMatchKey(a[key], b[key]));
|
|
263
|
+
}
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
function replaceEqualDeep(a, b) {
|
|
267
|
+
if (a === b) {
|
|
268
|
+
return a;
|
|
269
|
+
}
|
|
270
|
+
const array = isPlainArray(a) && isPlainArray(b);
|
|
271
|
+
if (array || isPlainObject(a) && isPlainObject(b)) {
|
|
272
|
+
const aItems = array ? a : Object.keys(a);
|
|
273
|
+
const aSize = aItems.length;
|
|
274
|
+
const bItems = array ? b : Object.keys(b);
|
|
275
|
+
const bSize = bItems.length;
|
|
276
|
+
const copy = array ? [] : {};
|
|
277
|
+
let equalItems = 0;
|
|
278
|
+
for (let i = 0; i < bSize; i++) {
|
|
279
|
+
const key = array ? i : bItems[i];
|
|
280
|
+
if ((!array && aItems.includes(key) || array) && a[key] === void 0 && b[key] === void 0) {
|
|
281
|
+
copy[key] = void 0;
|
|
282
|
+
equalItems++;
|
|
283
|
+
} else {
|
|
284
|
+
copy[key] = replaceEqualDeep(a[key], b[key]);
|
|
285
|
+
if (copy[key] === a[key] && a[key] !== void 0) {
|
|
286
|
+
equalItems++;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return aSize === bSize && equalItems === aSize ? a : copy;
|
|
291
|
+
}
|
|
292
|
+
return b;
|
|
293
|
+
}
|
|
294
|
+
function shallowEqualObjects(a, b) {
|
|
295
|
+
if (!b || Object.keys(a).length !== Object.keys(b).length) {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
for (const key in a) {
|
|
299
|
+
if (a[key] !== b[key]) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
function isPlainArray(value) {
|
|
306
|
+
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
307
|
+
}
|
|
308
|
+
function isPlainObject(o) {
|
|
309
|
+
if (!hasObjectPrototype(o)) {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
const ctor = o.constructor;
|
|
313
|
+
if (ctor === void 0) {
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
const prot = ctor.prototype;
|
|
317
|
+
if (!hasObjectPrototype(prot)) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
if (Object.getPrototypeOf(o) !== Object.prototype) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
function hasObjectPrototype(o) {
|
|
329
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
330
|
+
}
|
|
331
|
+
function sleep(ms) {
|
|
332
|
+
return new Promise((resolve) => {
|
|
333
|
+
setTimeout(resolve, ms);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
function replaceData(prevData, data, options) {
|
|
337
|
+
if (typeof options.structuralSharing === "function") {
|
|
338
|
+
return options.structuralSharing(prevData, data);
|
|
339
|
+
} else if (options.structuralSharing !== false) {
|
|
340
|
+
return replaceEqualDeep(prevData, data);
|
|
341
|
+
}
|
|
342
|
+
return data;
|
|
343
|
+
}
|
|
344
|
+
function keepPreviousData(previousData) {
|
|
345
|
+
return previousData;
|
|
346
|
+
}
|
|
347
|
+
function addToEnd(items, item, max = 0) {
|
|
348
|
+
const newItems = [...items, item];
|
|
349
|
+
return max && newItems.length > max ? newItems.slice(1) : newItems;
|
|
350
|
+
}
|
|
351
|
+
function addToStart(items, item, max = 0) {
|
|
352
|
+
const newItems = [item, ...items];
|
|
353
|
+
return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
|
|
354
|
+
}
|
|
355
|
+
var skipToken = Symbol();
|
|
356
|
+
var ensureQueryFn = (options, fetchOptions) => {
|
|
357
|
+
if (!options.queryFn && fetchOptions?.initialPromise) {
|
|
358
|
+
return () => fetchOptions.initialPromise;
|
|
359
|
+
}
|
|
360
|
+
if (!options.queryFn || options.queryFn === skipToken) {
|
|
361
|
+
return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));
|
|
362
|
+
}
|
|
363
|
+
return options.queryFn;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// src/focusManager.ts
|
|
367
|
+
var FocusManager = class extends Subscribable {
|
|
368
|
+
#focused;
|
|
369
|
+
#cleanup;
|
|
370
|
+
#setup;
|
|
371
|
+
constructor() {
|
|
372
|
+
super();
|
|
373
|
+
this.#setup = (onFocus) => {
|
|
374
|
+
if (!isServer && window.addEventListener) {
|
|
375
|
+
const listener = () => onFocus();
|
|
376
|
+
window.addEventListener("visibilitychange", listener, false);
|
|
377
|
+
return () => {
|
|
378
|
+
window.removeEventListener("visibilitychange", listener);
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
return;
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
onSubscribe() {
|
|
385
|
+
if (!this.#cleanup) {
|
|
386
|
+
this.setEventListener(this.#setup);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
onUnsubscribe() {
|
|
390
|
+
if (!this.hasListeners()) {
|
|
391
|
+
this.#cleanup?.();
|
|
392
|
+
this.#cleanup = void 0;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
setEventListener(setup) {
|
|
396
|
+
this.#setup = setup;
|
|
397
|
+
this.#cleanup?.();
|
|
398
|
+
this.#cleanup = setup((focused) => {
|
|
399
|
+
if (typeof focused === "boolean") {
|
|
400
|
+
this.setFocused(focused);
|
|
401
|
+
} else {
|
|
402
|
+
this.onFocus();
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
setFocused(focused) {
|
|
407
|
+
const changed = this.#focused !== focused;
|
|
408
|
+
if (changed) {
|
|
409
|
+
this.#focused = focused;
|
|
410
|
+
this.onFocus();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
onFocus() {
|
|
414
|
+
const isFocused = this.isFocused();
|
|
415
|
+
this.listeners.forEach((listener) => {
|
|
416
|
+
listener(isFocused);
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
isFocused() {
|
|
420
|
+
if (typeof this.#focused === "boolean") {
|
|
421
|
+
return this.#focused;
|
|
422
|
+
}
|
|
423
|
+
return globalThis.document?.visibilityState !== "hidden";
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
var focusManager = new FocusManager();
|
|
427
|
+
|
|
428
|
+
// src/onlineManager.ts
|
|
429
|
+
var OnlineManager = class extends Subscribable {
|
|
430
|
+
#online = true;
|
|
431
|
+
#cleanup;
|
|
432
|
+
#setup;
|
|
433
|
+
constructor() {
|
|
434
|
+
super();
|
|
435
|
+
this.#setup = (onOnline) => {
|
|
436
|
+
if (!isServer && window.addEventListener) {
|
|
437
|
+
const onlineListener = () => onOnline(true);
|
|
438
|
+
const offlineListener = () => onOnline(false);
|
|
439
|
+
window.addEventListener("online", onlineListener, false);
|
|
440
|
+
window.addEventListener("offline", offlineListener, false);
|
|
441
|
+
return () => {
|
|
442
|
+
window.removeEventListener("online", onlineListener);
|
|
443
|
+
window.removeEventListener("offline", offlineListener);
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
return;
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
onSubscribe() {
|
|
450
|
+
if (!this.#cleanup) {
|
|
451
|
+
this.setEventListener(this.#setup);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
onUnsubscribe() {
|
|
455
|
+
if (!this.hasListeners()) {
|
|
456
|
+
this.#cleanup?.();
|
|
457
|
+
this.#cleanup = void 0;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
setEventListener(setup) {
|
|
461
|
+
this.#setup = setup;
|
|
462
|
+
this.#cleanup?.();
|
|
463
|
+
this.#cleanup = setup(this.setOnline.bind(this));
|
|
464
|
+
}
|
|
465
|
+
setOnline(online) {
|
|
466
|
+
const changed = this.#online !== online;
|
|
467
|
+
if (changed) {
|
|
468
|
+
this.#online = online;
|
|
469
|
+
this.listeners.forEach((listener) => {
|
|
470
|
+
listener(online);
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
isOnline() {
|
|
475
|
+
return this.#online;
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
var onlineManager = new OnlineManager();
|
|
479
|
+
|
|
480
|
+
// src/retryer.ts
|
|
481
|
+
function defaultRetryDelay(failureCount) {
|
|
482
|
+
return Math.min(1e3 * 2 ** failureCount, 3e4);
|
|
483
|
+
}
|
|
484
|
+
function canFetch(networkMode) {
|
|
485
|
+
return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
|
|
486
|
+
}
|
|
487
|
+
var CancelledError = class {
|
|
488
|
+
constructor(options) {
|
|
489
|
+
this.revert = options?.revert;
|
|
490
|
+
this.silent = options?.silent;
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
function isCancelledError(value) {
|
|
494
|
+
return value instanceof CancelledError;
|
|
495
|
+
}
|
|
496
|
+
function createRetryer(config) {
|
|
497
|
+
let isRetryCancelled = false;
|
|
498
|
+
let failureCount = 0;
|
|
499
|
+
let isResolved = false;
|
|
500
|
+
let continueFn;
|
|
501
|
+
let promiseResolve;
|
|
502
|
+
let promiseReject;
|
|
503
|
+
const promise = new Promise((outerResolve, outerReject) => {
|
|
504
|
+
promiseResolve = outerResolve;
|
|
505
|
+
promiseReject = outerReject;
|
|
506
|
+
});
|
|
507
|
+
const cancel = (cancelOptions) => {
|
|
508
|
+
if (!isResolved) {
|
|
509
|
+
reject(new CancelledError(cancelOptions));
|
|
510
|
+
config.abort?.();
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
const cancelRetry = () => {
|
|
514
|
+
isRetryCancelled = true;
|
|
515
|
+
};
|
|
516
|
+
const continueRetry = () => {
|
|
517
|
+
isRetryCancelled = false;
|
|
518
|
+
};
|
|
519
|
+
const canContinue = () => focusManager.isFocused() && (config.networkMode === "always" || onlineManager.isOnline()) && config.canRun();
|
|
520
|
+
const canStart = () => canFetch(config.networkMode) && config.canRun();
|
|
521
|
+
const resolve = (value) => {
|
|
522
|
+
if (!isResolved) {
|
|
523
|
+
isResolved = true;
|
|
524
|
+
config.onSuccess?.(value);
|
|
525
|
+
continueFn?.();
|
|
526
|
+
promiseResolve(value);
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
const reject = (value) => {
|
|
530
|
+
if (!isResolved) {
|
|
531
|
+
isResolved = true;
|
|
532
|
+
config.onError?.(value);
|
|
533
|
+
continueFn?.();
|
|
534
|
+
promiseReject(value);
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
const pause = () => {
|
|
538
|
+
return new Promise((continueResolve) => {
|
|
539
|
+
continueFn = (value) => {
|
|
540
|
+
if (isResolved || canContinue()) {
|
|
541
|
+
continueResolve(value);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
config.onPause?.();
|
|
545
|
+
}).then(() => {
|
|
546
|
+
continueFn = void 0;
|
|
547
|
+
if (!isResolved) {
|
|
548
|
+
config.onContinue?.();
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
};
|
|
552
|
+
const run = () => {
|
|
553
|
+
if (isResolved) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
let promiseOrValue;
|
|
557
|
+
const initialPromise = failureCount === 0 ? config.initialPromise : void 0;
|
|
558
|
+
try {
|
|
559
|
+
promiseOrValue = initialPromise ?? config.fn();
|
|
560
|
+
} catch (error) {
|
|
561
|
+
promiseOrValue = Promise.reject(error);
|
|
562
|
+
}
|
|
563
|
+
Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
|
|
564
|
+
if (isResolved) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
const retry = config.retry ?? (isServer ? 0 : 3);
|
|
568
|
+
const retryDelay = config.retryDelay ?? defaultRetryDelay;
|
|
569
|
+
const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
|
|
570
|
+
const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
|
|
571
|
+
if (isRetryCancelled || !shouldRetry) {
|
|
572
|
+
reject(error);
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
failureCount++;
|
|
576
|
+
config.onFail?.(failureCount, error);
|
|
577
|
+
sleep(delay).then(() => {
|
|
578
|
+
return canContinue() ? void 0 : pause();
|
|
579
|
+
}).then(() => {
|
|
580
|
+
if (isRetryCancelled) {
|
|
581
|
+
reject(error);
|
|
582
|
+
} else {
|
|
583
|
+
run();
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
};
|
|
588
|
+
return {
|
|
589
|
+
promise,
|
|
590
|
+
cancel,
|
|
591
|
+
continue: () => {
|
|
592
|
+
continueFn?.();
|
|
593
|
+
return promise;
|
|
594
|
+
},
|
|
595
|
+
cancelRetry,
|
|
596
|
+
continueRetry,
|
|
597
|
+
canStart,
|
|
598
|
+
start: () => {
|
|
599
|
+
if (canStart()) {
|
|
600
|
+
run();
|
|
601
|
+
} else {
|
|
602
|
+
pause().then(run);
|
|
603
|
+
}
|
|
604
|
+
return promise;
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// src/notifyManager.ts
|
|
610
|
+
function createNotifyManager() {
|
|
611
|
+
let queue = [];
|
|
612
|
+
let transactions = 0;
|
|
613
|
+
let notifyFn = (callback) => {
|
|
614
|
+
callback();
|
|
615
|
+
};
|
|
616
|
+
let batchNotifyFn = (callback) => {
|
|
617
|
+
callback();
|
|
618
|
+
};
|
|
619
|
+
let scheduleFn = (cb) => setTimeout(cb, 0);
|
|
620
|
+
const setScheduler = (fn) => {
|
|
621
|
+
scheduleFn = fn;
|
|
622
|
+
};
|
|
623
|
+
const batch = (callback) => {
|
|
624
|
+
let result;
|
|
625
|
+
transactions++;
|
|
626
|
+
try {
|
|
627
|
+
result = callback();
|
|
628
|
+
} finally {
|
|
629
|
+
transactions--;
|
|
630
|
+
if (!transactions) {
|
|
631
|
+
flush();
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return result;
|
|
635
|
+
};
|
|
636
|
+
const schedule = (callback) => {
|
|
637
|
+
if (transactions) {
|
|
638
|
+
queue.push(callback);
|
|
639
|
+
} else {
|
|
640
|
+
scheduleFn(() => {
|
|
641
|
+
notifyFn(callback);
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
const batchCalls = (callback) => {
|
|
646
|
+
return (...args) => {
|
|
647
|
+
schedule(() => {
|
|
648
|
+
callback(...args);
|
|
649
|
+
});
|
|
650
|
+
};
|
|
651
|
+
};
|
|
652
|
+
const flush = () => {
|
|
653
|
+
const originalQueue = queue;
|
|
654
|
+
queue = [];
|
|
655
|
+
if (originalQueue.length) {
|
|
656
|
+
scheduleFn(() => {
|
|
657
|
+
batchNotifyFn(() => {
|
|
658
|
+
originalQueue.forEach((callback) => {
|
|
659
|
+
notifyFn(callback);
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
const setNotifyFunction = (fn) => {
|
|
666
|
+
notifyFn = fn;
|
|
667
|
+
};
|
|
668
|
+
const setBatchNotifyFunction = (fn) => {
|
|
669
|
+
batchNotifyFn = fn;
|
|
670
|
+
};
|
|
671
|
+
return {
|
|
672
|
+
batch,
|
|
673
|
+
batchCalls,
|
|
674
|
+
schedule,
|
|
675
|
+
setNotifyFunction,
|
|
676
|
+
setBatchNotifyFunction,
|
|
677
|
+
setScheduler
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
var notifyManager = createNotifyManager();
|
|
681
|
+
|
|
682
|
+
// src/removable.ts
|
|
683
|
+
var Removable = class {
|
|
684
|
+
#gcTimeout;
|
|
685
|
+
destroy() {
|
|
686
|
+
this.clearGcTimeout();
|
|
687
|
+
}
|
|
688
|
+
scheduleGc() {
|
|
689
|
+
this.clearGcTimeout();
|
|
690
|
+
if (isValidTimeout(this.gcTime)) {
|
|
691
|
+
this.#gcTimeout = setTimeout(() => {
|
|
692
|
+
this.optionalRemove();
|
|
693
|
+
}, this.gcTime);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
updateGcTime(newGcTime) {
|
|
697
|
+
this.gcTime = Math.max(
|
|
698
|
+
this.gcTime || 0,
|
|
699
|
+
newGcTime ?? (isServer ? Infinity : 5 * 60 * 1e3)
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
clearGcTimeout() {
|
|
703
|
+
if (this.#gcTimeout) {
|
|
704
|
+
clearTimeout(this.#gcTimeout);
|
|
705
|
+
this.#gcTimeout = void 0;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
// src/query.ts
|
|
711
|
+
var Query = class extends Removable {
|
|
712
|
+
#initialState;
|
|
713
|
+
#revertState;
|
|
714
|
+
#cache;
|
|
715
|
+
#retryer;
|
|
716
|
+
#defaultOptions;
|
|
717
|
+
#abortSignalConsumed;
|
|
718
|
+
constructor(config) {
|
|
719
|
+
super();
|
|
720
|
+
this.#abortSignalConsumed = false;
|
|
721
|
+
this.#defaultOptions = config.defaultOptions;
|
|
722
|
+
this.setOptions(config.options);
|
|
723
|
+
this.observers = [];
|
|
724
|
+
this.#cache = config.cache;
|
|
725
|
+
this.queryKey = config.queryKey;
|
|
726
|
+
this.queryHash = config.queryHash;
|
|
727
|
+
this.#initialState = config.state || getDefaultState$1(this.options);
|
|
728
|
+
this.state = this.#initialState;
|
|
729
|
+
this.scheduleGc();
|
|
730
|
+
}
|
|
731
|
+
get meta() {
|
|
732
|
+
return this.options.meta;
|
|
733
|
+
}
|
|
734
|
+
get promise() {
|
|
735
|
+
return this.#retryer?.promise;
|
|
736
|
+
}
|
|
737
|
+
setOptions(options) {
|
|
738
|
+
this.options = { ...this.#defaultOptions, ...options };
|
|
739
|
+
this.updateGcTime(this.options.gcTime);
|
|
740
|
+
}
|
|
741
|
+
optionalRemove() {
|
|
742
|
+
if (!this.observers.length && this.state.fetchStatus === "idle") {
|
|
743
|
+
this.#cache.remove(this);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
setData(newData, options) {
|
|
747
|
+
const data = replaceData(this.state.data, newData, this.options);
|
|
748
|
+
this.#dispatch({
|
|
749
|
+
data,
|
|
750
|
+
type: "success",
|
|
751
|
+
dataUpdatedAt: options?.updatedAt,
|
|
752
|
+
manual: options?.manual
|
|
753
|
+
});
|
|
754
|
+
return data;
|
|
755
|
+
}
|
|
756
|
+
setState(state, setStateOptions) {
|
|
757
|
+
this.#dispatch({ type: "setState", state, setStateOptions });
|
|
758
|
+
}
|
|
759
|
+
cancel(options) {
|
|
760
|
+
const promise = this.#retryer?.promise;
|
|
761
|
+
this.#retryer?.cancel(options);
|
|
762
|
+
return promise ? promise.then(noop$1).catch(noop$1) : Promise.resolve();
|
|
763
|
+
}
|
|
764
|
+
destroy() {
|
|
765
|
+
super.destroy();
|
|
766
|
+
this.cancel({ silent: true });
|
|
767
|
+
}
|
|
768
|
+
reset() {
|
|
769
|
+
this.destroy();
|
|
770
|
+
this.setState(this.#initialState);
|
|
771
|
+
}
|
|
772
|
+
isActive() {
|
|
773
|
+
return this.observers.some((observer) => observer.options.enabled !== false);
|
|
774
|
+
}
|
|
775
|
+
isDisabled() {
|
|
776
|
+
return this.getObserversCount() > 0 && !this.isActive();
|
|
777
|
+
}
|
|
778
|
+
isStale() {
|
|
779
|
+
if (this.state.isInvalidated) {
|
|
780
|
+
return true;
|
|
781
|
+
}
|
|
782
|
+
if (this.getObserversCount() > 0) {
|
|
783
|
+
return this.observers.some(
|
|
784
|
+
(observer) => observer.getCurrentResult().isStale
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
return this.state.data === void 0;
|
|
788
|
+
}
|
|
789
|
+
isStaleByTime(staleTime = 0) {
|
|
790
|
+
return this.state.isInvalidated || this.state.data === void 0 || !timeUntilStale(this.state.dataUpdatedAt, staleTime);
|
|
791
|
+
}
|
|
792
|
+
onFocus() {
|
|
793
|
+
const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());
|
|
794
|
+
observer?.refetch({ cancelRefetch: false });
|
|
795
|
+
this.#retryer?.continue();
|
|
796
|
+
}
|
|
797
|
+
onOnline() {
|
|
798
|
+
const observer = this.observers.find((x) => x.shouldFetchOnReconnect());
|
|
799
|
+
observer?.refetch({ cancelRefetch: false });
|
|
800
|
+
this.#retryer?.continue();
|
|
801
|
+
}
|
|
802
|
+
addObserver(observer) {
|
|
803
|
+
if (!this.observers.includes(observer)) {
|
|
804
|
+
this.observers.push(observer);
|
|
805
|
+
this.clearGcTimeout();
|
|
806
|
+
this.#cache.notify({ type: "observerAdded", query: this, observer });
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
removeObserver(observer) {
|
|
810
|
+
if (this.observers.includes(observer)) {
|
|
811
|
+
this.observers = this.observers.filter((x) => x !== observer);
|
|
812
|
+
if (!this.observers.length) {
|
|
813
|
+
if (this.#retryer) {
|
|
814
|
+
if (this.#abortSignalConsumed) {
|
|
815
|
+
this.#retryer.cancel({ revert: true });
|
|
816
|
+
} else {
|
|
817
|
+
this.#retryer.cancelRetry();
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
this.scheduleGc();
|
|
821
|
+
}
|
|
822
|
+
this.#cache.notify({ type: "observerRemoved", query: this, observer });
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
getObserversCount() {
|
|
826
|
+
return this.observers.length;
|
|
827
|
+
}
|
|
828
|
+
invalidate() {
|
|
829
|
+
if (!this.state.isInvalidated) {
|
|
830
|
+
this.#dispatch({ type: "invalidate" });
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
fetch(options, fetchOptions) {
|
|
834
|
+
if (this.state.fetchStatus !== "idle") {
|
|
835
|
+
if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) {
|
|
836
|
+
this.cancel({ silent: true });
|
|
837
|
+
} else if (this.#retryer) {
|
|
838
|
+
this.#retryer.continueRetry();
|
|
839
|
+
return this.#retryer.promise;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
if (options) {
|
|
843
|
+
this.setOptions(options);
|
|
844
|
+
}
|
|
845
|
+
if (!this.options.queryFn) {
|
|
846
|
+
const observer = this.observers.find((x) => x.options.queryFn);
|
|
847
|
+
if (observer) {
|
|
848
|
+
this.setOptions(observer.options);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
const abortController = new AbortController();
|
|
852
|
+
const addSignalProperty = (object) => {
|
|
853
|
+
Object.defineProperty(object, "signal", {
|
|
854
|
+
enumerable: true,
|
|
855
|
+
get: () => {
|
|
856
|
+
this.#abortSignalConsumed = true;
|
|
857
|
+
return abortController.signal;
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
};
|
|
861
|
+
const fetchFn = () => {
|
|
862
|
+
const queryFn = ensureQueryFn(this.options, fetchOptions);
|
|
863
|
+
const queryFnContext = {
|
|
864
|
+
queryKey: this.queryKey,
|
|
865
|
+
meta: this.meta
|
|
866
|
+
};
|
|
867
|
+
addSignalProperty(queryFnContext);
|
|
868
|
+
this.#abortSignalConsumed = false;
|
|
869
|
+
if (this.options.persister) {
|
|
870
|
+
return this.options.persister(
|
|
871
|
+
queryFn,
|
|
872
|
+
queryFnContext,
|
|
873
|
+
this
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
return queryFn(queryFnContext);
|
|
877
|
+
};
|
|
878
|
+
const context = {
|
|
879
|
+
fetchOptions,
|
|
880
|
+
options: this.options,
|
|
881
|
+
queryKey: this.queryKey,
|
|
882
|
+
state: this.state,
|
|
883
|
+
fetchFn
|
|
884
|
+
};
|
|
885
|
+
addSignalProperty(context);
|
|
886
|
+
this.options.behavior?.onFetch(
|
|
887
|
+
context,
|
|
888
|
+
this
|
|
889
|
+
);
|
|
890
|
+
this.#revertState = this.state;
|
|
891
|
+
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) {
|
|
892
|
+
this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta });
|
|
893
|
+
}
|
|
894
|
+
const onError = (error) => {
|
|
895
|
+
if (!(isCancelledError(error) && error.silent)) {
|
|
896
|
+
this.#dispatch({
|
|
897
|
+
type: "error",
|
|
898
|
+
error
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
if (!isCancelledError(error)) {
|
|
902
|
+
this.#cache.config.onError?.(
|
|
903
|
+
error,
|
|
904
|
+
this
|
|
905
|
+
);
|
|
906
|
+
this.#cache.config.onSettled?.(
|
|
907
|
+
this.state.data,
|
|
908
|
+
error,
|
|
909
|
+
this
|
|
910
|
+
);
|
|
911
|
+
}
|
|
912
|
+
if (!this.isFetchingOptimistic) {
|
|
913
|
+
this.scheduleGc();
|
|
914
|
+
}
|
|
915
|
+
this.isFetchingOptimistic = false;
|
|
916
|
+
};
|
|
917
|
+
this.#retryer = createRetryer({
|
|
918
|
+
initialPromise: fetchOptions?.initialPromise,
|
|
919
|
+
fn: context.fetchFn,
|
|
920
|
+
abort: abortController.abort.bind(abortController),
|
|
921
|
+
onSuccess: (data) => {
|
|
922
|
+
if (data === void 0) {
|
|
923
|
+
onError(new Error(`${this.queryHash} data is undefined`));
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
this.setData(data);
|
|
927
|
+
this.#cache.config.onSuccess?.(data, this);
|
|
928
|
+
this.#cache.config.onSettled?.(
|
|
929
|
+
data,
|
|
930
|
+
this.state.error,
|
|
931
|
+
this
|
|
932
|
+
);
|
|
933
|
+
if (!this.isFetchingOptimistic) {
|
|
934
|
+
this.scheduleGc();
|
|
935
|
+
}
|
|
936
|
+
this.isFetchingOptimistic = false;
|
|
937
|
+
},
|
|
938
|
+
onError,
|
|
939
|
+
onFail: (failureCount, error) => {
|
|
940
|
+
this.#dispatch({ type: "failed", failureCount, error });
|
|
941
|
+
},
|
|
942
|
+
onPause: () => {
|
|
943
|
+
this.#dispatch({ type: "pause" });
|
|
944
|
+
},
|
|
945
|
+
onContinue: () => {
|
|
946
|
+
this.#dispatch({ type: "continue" });
|
|
947
|
+
},
|
|
948
|
+
retry: context.options.retry,
|
|
949
|
+
retryDelay: context.options.retryDelay,
|
|
950
|
+
networkMode: context.options.networkMode,
|
|
951
|
+
canRun: () => true
|
|
952
|
+
});
|
|
953
|
+
return this.#retryer.start();
|
|
954
|
+
}
|
|
955
|
+
#dispatch(action) {
|
|
956
|
+
const reducer = (state) => {
|
|
957
|
+
switch (action.type) {
|
|
958
|
+
case "failed":
|
|
959
|
+
return {
|
|
960
|
+
...state,
|
|
961
|
+
fetchFailureCount: action.failureCount,
|
|
962
|
+
fetchFailureReason: action.error
|
|
963
|
+
};
|
|
964
|
+
case "pause":
|
|
965
|
+
return {
|
|
966
|
+
...state,
|
|
967
|
+
fetchStatus: "paused"
|
|
968
|
+
};
|
|
969
|
+
case "continue":
|
|
970
|
+
return {
|
|
971
|
+
...state,
|
|
972
|
+
fetchStatus: "fetching"
|
|
973
|
+
};
|
|
974
|
+
case "fetch":
|
|
975
|
+
return {
|
|
976
|
+
...state,
|
|
977
|
+
...fetchState(state.data, this.options),
|
|
978
|
+
fetchMeta: action.meta ?? null
|
|
979
|
+
};
|
|
980
|
+
case "success":
|
|
981
|
+
return {
|
|
982
|
+
...state,
|
|
983
|
+
data: action.data,
|
|
984
|
+
dataUpdateCount: state.dataUpdateCount + 1,
|
|
985
|
+
dataUpdatedAt: action.dataUpdatedAt ?? Date.now(),
|
|
986
|
+
error: null,
|
|
987
|
+
isInvalidated: false,
|
|
988
|
+
status: "success",
|
|
989
|
+
...!action.manual && {
|
|
990
|
+
fetchStatus: "idle",
|
|
991
|
+
fetchFailureCount: 0,
|
|
992
|
+
fetchFailureReason: null
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
case "error":
|
|
996
|
+
const error = action.error;
|
|
997
|
+
if (isCancelledError(error) && error.revert && this.#revertState) {
|
|
998
|
+
return { ...this.#revertState, fetchStatus: "idle" };
|
|
999
|
+
}
|
|
1000
|
+
return {
|
|
1001
|
+
...state,
|
|
1002
|
+
error,
|
|
1003
|
+
errorUpdateCount: state.errorUpdateCount + 1,
|
|
1004
|
+
errorUpdatedAt: Date.now(),
|
|
1005
|
+
fetchFailureCount: state.fetchFailureCount + 1,
|
|
1006
|
+
fetchFailureReason: error,
|
|
1007
|
+
fetchStatus: "idle",
|
|
1008
|
+
status: "error"
|
|
1009
|
+
};
|
|
1010
|
+
case "invalidate":
|
|
1011
|
+
return {
|
|
1012
|
+
...state,
|
|
1013
|
+
isInvalidated: true
|
|
1014
|
+
};
|
|
1015
|
+
case "setState":
|
|
1016
|
+
return {
|
|
1017
|
+
...state,
|
|
1018
|
+
...action.state
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
this.state = reducer(this.state);
|
|
1023
|
+
notifyManager.batch(() => {
|
|
1024
|
+
this.observers.forEach((observer) => {
|
|
1025
|
+
observer.onQueryUpdate();
|
|
1026
|
+
});
|
|
1027
|
+
this.#cache.notify({ query: this, type: "updated", action });
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
function fetchState(data, options) {
|
|
1032
|
+
return {
|
|
1033
|
+
fetchFailureCount: 0,
|
|
1034
|
+
fetchFailureReason: null,
|
|
1035
|
+
fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
|
|
1036
|
+
...data === void 0 && {
|
|
1037
|
+
error: null,
|
|
1038
|
+
status: "pending"
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
function getDefaultState$1(options) {
|
|
1043
|
+
const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
|
|
1044
|
+
const hasData = data !== void 0;
|
|
1045
|
+
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
|
|
1046
|
+
return {
|
|
1047
|
+
data,
|
|
1048
|
+
dataUpdateCount: 0,
|
|
1049
|
+
dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
|
|
1050
|
+
error: null,
|
|
1051
|
+
errorUpdateCount: 0,
|
|
1052
|
+
errorUpdatedAt: 0,
|
|
1053
|
+
fetchFailureCount: 0,
|
|
1054
|
+
fetchFailureReason: null,
|
|
1055
|
+
fetchMeta: null,
|
|
1056
|
+
isInvalidated: false,
|
|
1057
|
+
status: hasData ? "success" : "pending",
|
|
1058
|
+
fetchStatus: "idle"
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
// src/queryCache.ts
|
|
1063
|
+
var QueryCache = class extends Subscribable {
|
|
1064
|
+
constructor(config = {}) {
|
|
1065
|
+
super();
|
|
1066
|
+
this.config = config;
|
|
1067
|
+
this.#queries = /* @__PURE__ */ new Map();
|
|
1068
|
+
}
|
|
1069
|
+
#queries;
|
|
1070
|
+
build(client, options, state) {
|
|
1071
|
+
const queryKey = options.queryKey;
|
|
1072
|
+
const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
|
|
1073
|
+
let query = this.get(queryHash);
|
|
1074
|
+
if (!query) {
|
|
1075
|
+
query = new Query({
|
|
1076
|
+
cache: this,
|
|
1077
|
+
queryKey,
|
|
1078
|
+
queryHash,
|
|
1079
|
+
options: client.defaultQueryOptions(options),
|
|
1080
|
+
state,
|
|
1081
|
+
defaultOptions: client.getQueryDefaults(queryKey)
|
|
1082
|
+
});
|
|
1083
|
+
this.add(query);
|
|
1084
|
+
}
|
|
1085
|
+
return query;
|
|
1086
|
+
}
|
|
1087
|
+
add(query) {
|
|
1088
|
+
if (!this.#queries.has(query.queryHash)) {
|
|
1089
|
+
this.#queries.set(query.queryHash, query);
|
|
1090
|
+
this.notify({
|
|
1091
|
+
type: "added",
|
|
1092
|
+
query
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
remove(query) {
|
|
1097
|
+
const queryInMap = this.#queries.get(query.queryHash);
|
|
1098
|
+
if (queryInMap) {
|
|
1099
|
+
query.destroy();
|
|
1100
|
+
if (queryInMap === query) {
|
|
1101
|
+
this.#queries.delete(query.queryHash);
|
|
1102
|
+
}
|
|
1103
|
+
this.notify({ type: "removed", query });
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
clear() {
|
|
1107
|
+
notifyManager.batch(() => {
|
|
1108
|
+
this.getAll().forEach((query) => {
|
|
1109
|
+
this.remove(query);
|
|
1110
|
+
});
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
get(queryHash) {
|
|
1114
|
+
return this.#queries.get(queryHash);
|
|
1115
|
+
}
|
|
1116
|
+
getAll() {
|
|
1117
|
+
return [...this.#queries.values()];
|
|
1118
|
+
}
|
|
1119
|
+
find(filters) {
|
|
1120
|
+
const defaultedFilters = { exact: true, ...filters };
|
|
1121
|
+
return this.getAll().find(
|
|
1122
|
+
(query) => matchQuery(defaultedFilters, query)
|
|
1123
|
+
);
|
|
1124
|
+
}
|
|
1125
|
+
findAll(filters = {}) {
|
|
1126
|
+
const queries = this.getAll();
|
|
1127
|
+
return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
|
|
1128
|
+
}
|
|
1129
|
+
notify(event) {
|
|
1130
|
+
notifyManager.batch(() => {
|
|
1131
|
+
this.listeners.forEach((listener) => {
|
|
1132
|
+
listener(event);
|
|
1133
|
+
});
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
onFocus() {
|
|
1137
|
+
notifyManager.batch(() => {
|
|
1138
|
+
this.getAll().forEach((query) => {
|
|
1139
|
+
query.onFocus();
|
|
1140
|
+
});
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
onOnline() {
|
|
1144
|
+
notifyManager.batch(() => {
|
|
1145
|
+
this.getAll().forEach((query) => {
|
|
1146
|
+
query.onOnline();
|
|
1147
|
+
});
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
// src/mutation.ts
|
|
1153
|
+
var Mutation = class extends Removable {
|
|
1154
|
+
#observers;
|
|
1155
|
+
#mutationCache;
|
|
1156
|
+
#retryer;
|
|
1157
|
+
constructor(config) {
|
|
1158
|
+
super();
|
|
1159
|
+
this.mutationId = config.mutationId;
|
|
1160
|
+
this.#mutationCache = config.mutationCache;
|
|
1161
|
+
this.#observers = [];
|
|
1162
|
+
this.state = config.state || getDefaultState();
|
|
1163
|
+
this.setOptions(config.options);
|
|
1164
|
+
this.scheduleGc();
|
|
1165
|
+
}
|
|
1166
|
+
setOptions(options) {
|
|
1167
|
+
this.options = options;
|
|
1168
|
+
this.updateGcTime(this.options.gcTime);
|
|
1169
|
+
}
|
|
1170
|
+
get meta() {
|
|
1171
|
+
return this.options.meta;
|
|
1172
|
+
}
|
|
1173
|
+
addObserver(observer) {
|
|
1174
|
+
if (!this.#observers.includes(observer)) {
|
|
1175
|
+
this.#observers.push(observer);
|
|
1176
|
+
this.clearGcTimeout();
|
|
1177
|
+
this.#mutationCache.notify({
|
|
1178
|
+
type: "observerAdded",
|
|
1179
|
+
mutation: this,
|
|
1180
|
+
observer
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
removeObserver(observer) {
|
|
1185
|
+
this.#observers = this.#observers.filter((x) => x !== observer);
|
|
1186
|
+
this.scheduleGc();
|
|
1187
|
+
this.#mutationCache.notify({
|
|
1188
|
+
type: "observerRemoved",
|
|
1189
|
+
mutation: this,
|
|
1190
|
+
observer
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
optionalRemove() {
|
|
1194
|
+
if (!this.#observers.length) {
|
|
1195
|
+
if (this.state.status === "pending") {
|
|
1196
|
+
this.scheduleGc();
|
|
1197
|
+
} else {
|
|
1198
|
+
this.#mutationCache.remove(this);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
continue() {
|
|
1203
|
+
return this.#retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
|
|
1204
|
+
this.execute(this.state.variables);
|
|
1205
|
+
}
|
|
1206
|
+
async execute(variables) {
|
|
1207
|
+
this.#retryer = createRetryer({
|
|
1208
|
+
fn: () => {
|
|
1209
|
+
if (!this.options.mutationFn) {
|
|
1210
|
+
return Promise.reject(new Error("No mutationFn found"));
|
|
1211
|
+
}
|
|
1212
|
+
return this.options.mutationFn(variables);
|
|
1213
|
+
},
|
|
1214
|
+
onFail: (failureCount, error) => {
|
|
1215
|
+
this.#dispatch({ type: "failed", failureCount, error });
|
|
1216
|
+
},
|
|
1217
|
+
onPause: () => {
|
|
1218
|
+
this.#dispatch({ type: "pause" });
|
|
1219
|
+
},
|
|
1220
|
+
onContinue: () => {
|
|
1221
|
+
this.#dispatch({ type: "continue" });
|
|
1222
|
+
},
|
|
1223
|
+
retry: this.options.retry ?? 0,
|
|
1224
|
+
retryDelay: this.options.retryDelay,
|
|
1225
|
+
networkMode: this.options.networkMode,
|
|
1226
|
+
canRun: () => this.#mutationCache.canRun(this)
|
|
1227
|
+
});
|
|
1228
|
+
const restored = this.state.status === "pending";
|
|
1229
|
+
const isPaused = !this.#retryer.canStart();
|
|
1230
|
+
try {
|
|
1231
|
+
if (!restored) {
|
|
1232
|
+
this.#dispatch({ type: "pending", variables, isPaused });
|
|
1233
|
+
await this.#mutationCache.config.onMutate?.(
|
|
1234
|
+
variables,
|
|
1235
|
+
this
|
|
1236
|
+
);
|
|
1237
|
+
const context = await this.options.onMutate?.(variables);
|
|
1238
|
+
if (context !== this.state.context) {
|
|
1239
|
+
this.#dispatch({
|
|
1240
|
+
type: "pending",
|
|
1241
|
+
context,
|
|
1242
|
+
variables,
|
|
1243
|
+
isPaused
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
const data = await this.#retryer.start();
|
|
1248
|
+
await this.#mutationCache.config.onSuccess?.(
|
|
1249
|
+
data,
|
|
1250
|
+
variables,
|
|
1251
|
+
this.state.context,
|
|
1252
|
+
this
|
|
1253
|
+
);
|
|
1254
|
+
await this.options.onSuccess?.(data, variables, this.state.context);
|
|
1255
|
+
await this.#mutationCache.config.onSettled?.(
|
|
1256
|
+
data,
|
|
1257
|
+
null,
|
|
1258
|
+
this.state.variables,
|
|
1259
|
+
this.state.context,
|
|
1260
|
+
this
|
|
1261
|
+
);
|
|
1262
|
+
await this.options.onSettled?.(data, null, variables, this.state.context);
|
|
1263
|
+
this.#dispatch({ type: "success", data });
|
|
1264
|
+
return data;
|
|
1265
|
+
} catch (error) {
|
|
1266
|
+
try {
|
|
1267
|
+
await this.#mutationCache.config.onError?.(
|
|
1268
|
+
error,
|
|
1269
|
+
variables,
|
|
1270
|
+
this.state.context,
|
|
1271
|
+
this
|
|
1272
|
+
);
|
|
1273
|
+
await this.options.onError?.(
|
|
1274
|
+
error,
|
|
1275
|
+
variables,
|
|
1276
|
+
this.state.context
|
|
1277
|
+
);
|
|
1278
|
+
await this.#mutationCache.config.onSettled?.(
|
|
1279
|
+
void 0,
|
|
1280
|
+
error,
|
|
1281
|
+
this.state.variables,
|
|
1282
|
+
this.state.context,
|
|
1283
|
+
this
|
|
1284
|
+
);
|
|
1285
|
+
await this.options.onSettled?.(
|
|
1286
|
+
void 0,
|
|
1287
|
+
error,
|
|
1288
|
+
variables,
|
|
1289
|
+
this.state.context
|
|
1290
|
+
);
|
|
1291
|
+
throw error;
|
|
1292
|
+
} finally {
|
|
1293
|
+
this.#dispatch({ type: "error", error });
|
|
1294
|
+
}
|
|
1295
|
+
} finally {
|
|
1296
|
+
this.#mutationCache.runNext(this);
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
#dispatch(action) {
|
|
1300
|
+
const reducer = (state) => {
|
|
1301
|
+
switch (action.type) {
|
|
1302
|
+
case "failed":
|
|
1303
|
+
return {
|
|
1304
|
+
...state,
|
|
1305
|
+
failureCount: action.failureCount,
|
|
1306
|
+
failureReason: action.error
|
|
1307
|
+
};
|
|
1308
|
+
case "pause":
|
|
1309
|
+
return {
|
|
1310
|
+
...state,
|
|
1311
|
+
isPaused: true
|
|
1312
|
+
};
|
|
1313
|
+
case "continue":
|
|
1314
|
+
return {
|
|
1315
|
+
...state,
|
|
1316
|
+
isPaused: false
|
|
1317
|
+
};
|
|
1318
|
+
case "pending":
|
|
1319
|
+
return {
|
|
1320
|
+
...state,
|
|
1321
|
+
context: action.context,
|
|
1322
|
+
data: void 0,
|
|
1323
|
+
failureCount: 0,
|
|
1324
|
+
failureReason: null,
|
|
1325
|
+
error: null,
|
|
1326
|
+
isPaused: action.isPaused,
|
|
1327
|
+
status: "pending",
|
|
1328
|
+
variables: action.variables,
|
|
1329
|
+
submittedAt: Date.now()
|
|
1330
|
+
};
|
|
1331
|
+
case "success":
|
|
1332
|
+
return {
|
|
1333
|
+
...state,
|
|
1334
|
+
data: action.data,
|
|
1335
|
+
failureCount: 0,
|
|
1336
|
+
failureReason: null,
|
|
1337
|
+
error: null,
|
|
1338
|
+
status: "success",
|
|
1339
|
+
isPaused: false
|
|
1340
|
+
};
|
|
1341
|
+
case "error":
|
|
1342
|
+
return {
|
|
1343
|
+
...state,
|
|
1344
|
+
data: void 0,
|
|
1345
|
+
error: action.error,
|
|
1346
|
+
failureCount: state.failureCount + 1,
|
|
1347
|
+
failureReason: action.error,
|
|
1348
|
+
isPaused: false,
|
|
1349
|
+
status: "error"
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
this.state = reducer(this.state);
|
|
1354
|
+
notifyManager.batch(() => {
|
|
1355
|
+
this.#observers.forEach((observer) => {
|
|
1356
|
+
observer.onMutationUpdate(action);
|
|
1357
|
+
});
|
|
1358
|
+
this.#mutationCache.notify({
|
|
1359
|
+
mutation: this,
|
|
1360
|
+
type: "updated",
|
|
1361
|
+
action
|
|
1362
|
+
});
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
};
|
|
1366
|
+
function getDefaultState() {
|
|
1367
|
+
return {
|
|
1368
|
+
context: void 0,
|
|
1369
|
+
data: void 0,
|
|
1370
|
+
error: null,
|
|
1371
|
+
failureCount: 0,
|
|
1372
|
+
failureReason: null,
|
|
1373
|
+
isPaused: false,
|
|
1374
|
+
status: "idle",
|
|
1375
|
+
variables: void 0,
|
|
1376
|
+
submittedAt: 0
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
// src/mutationCache.ts
|
|
1381
|
+
var MutationCache = class extends Subscribable {
|
|
1382
|
+
constructor(config = {}) {
|
|
1383
|
+
super();
|
|
1384
|
+
this.config = config;
|
|
1385
|
+
this.#mutations = /* @__PURE__ */ new Map();
|
|
1386
|
+
this.#mutationId = Date.now();
|
|
1387
|
+
}
|
|
1388
|
+
#mutations;
|
|
1389
|
+
#mutationId;
|
|
1390
|
+
build(client, options, state) {
|
|
1391
|
+
const mutation = new Mutation({
|
|
1392
|
+
mutationCache: this,
|
|
1393
|
+
mutationId: ++this.#mutationId,
|
|
1394
|
+
options: client.defaultMutationOptions(options),
|
|
1395
|
+
state
|
|
1396
|
+
});
|
|
1397
|
+
this.add(mutation);
|
|
1398
|
+
return mutation;
|
|
1399
|
+
}
|
|
1400
|
+
add(mutation) {
|
|
1401
|
+
const scope = scopeFor(mutation);
|
|
1402
|
+
const mutations = this.#mutations.get(scope) ?? [];
|
|
1403
|
+
mutations.push(mutation);
|
|
1404
|
+
this.#mutations.set(scope, mutations);
|
|
1405
|
+
this.notify({ type: "added", mutation });
|
|
1406
|
+
}
|
|
1407
|
+
remove(mutation) {
|
|
1408
|
+
const scope = scopeFor(mutation);
|
|
1409
|
+
if (this.#mutations.has(scope)) {
|
|
1410
|
+
const mutations = this.#mutations.get(scope)?.filter((x) => x !== mutation);
|
|
1411
|
+
if (mutations) {
|
|
1412
|
+
if (mutations.length === 0) {
|
|
1413
|
+
this.#mutations.delete(scope);
|
|
1414
|
+
} else {
|
|
1415
|
+
this.#mutations.set(scope, mutations);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
this.notify({ type: "removed", mutation });
|
|
1420
|
+
}
|
|
1421
|
+
canRun(mutation) {
|
|
1422
|
+
const firstPendingMutation = this.#mutations.get(scopeFor(mutation))?.find((m) => m.state.status === "pending");
|
|
1423
|
+
return !firstPendingMutation || firstPendingMutation === mutation;
|
|
1424
|
+
}
|
|
1425
|
+
runNext(mutation) {
|
|
1426
|
+
const foundMutation = this.#mutations.get(scopeFor(mutation))?.find((m) => m !== mutation && m.state.isPaused);
|
|
1427
|
+
return foundMutation?.continue() ?? Promise.resolve();
|
|
1428
|
+
}
|
|
1429
|
+
clear() {
|
|
1430
|
+
notifyManager.batch(() => {
|
|
1431
|
+
this.getAll().forEach((mutation) => {
|
|
1432
|
+
this.remove(mutation);
|
|
1433
|
+
});
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
getAll() {
|
|
1437
|
+
return [...this.#mutations.values()].flat();
|
|
1438
|
+
}
|
|
1439
|
+
find(filters) {
|
|
1440
|
+
const defaultedFilters = { exact: true, ...filters };
|
|
1441
|
+
return this.getAll().find(
|
|
1442
|
+
(mutation) => matchMutation(defaultedFilters, mutation)
|
|
1443
|
+
);
|
|
1444
|
+
}
|
|
1445
|
+
findAll(filters = {}) {
|
|
1446
|
+
return this.getAll().filter((mutation) => matchMutation(filters, mutation));
|
|
1447
|
+
}
|
|
1448
|
+
notify(event) {
|
|
1449
|
+
notifyManager.batch(() => {
|
|
1450
|
+
this.listeners.forEach((listener) => {
|
|
1451
|
+
listener(event);
|
|
1452
|
+
});
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
resumePausedMutations() {
|
|
1456
|
+
const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
|
|
1457
|
+
return notifyManager.batch(
|
|
1458
|
+
() => Promise.all(
|
|
1459
|
+
pausedMutations.map((mutation) => mutation.continue().catch(noop$1))
|
|
1460
|
+
)
|
|
1461
|
+
);
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
function scopeFor(mutation) {
|
|
1465
|
+
return mutation.options.scope?.id ?? String(mutation.mutationId);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
// src/infiniteQueryBehavior.ts
|
|
1469
|
+
function infiniteQueryBehavior(pages) {
|
|
1470
|
+
return {
|
|
1471
|
+
onFetch: (context, query) => {
|
|
1472
|
+
const fetchFn = async () => {
|
|
1473
|
+
const options = context.options;
|
|
1474
|
+
const direction = context.fetchOptions?.meta?.fetchMore?.direction;
|
|
1475
|
+
const oldPages = context.state.data?.pages || [];
|
|
1476
|
+
const oldPageParams = context.state.data?.pageParams || [];
|
|
1477
|
+
const empty = { pages: [], pageParams: [] };
|
|
1478
|
+
let cancelled = false;
|
|
1479
|
+
const addSignalProperty = (object) => {
|
|
1480
|
+
Object.defineProperty(object, "signal", {
|
|
1481
|
+
enumerable: true,
|
|
1482
|
+
get: () => {
|
|
1483
|
+
if (context.signal.aborted) {
|
|
1484
|
+
cancelled = true;
|
|
1485
|
+
} else {
|
|
1486
|
+
context.signal.addEventListener("abort", () => {
|
|
1487
|
+
cancelled = true;
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
return context.signal;
|
|
1491
|
+
}
|
|
1492
|
+
});
|
|
1493
|
+
};
|
|
1494
|
+
const queryFn = ensureQueryFn(context.options, context.fetchOptions);
|
|
1495
|
+
const fetchPage = async (data, param, previous) => {
|
|
1496
|
+
if (cancelled) {
|
|
1497
|
+
return Promise.reject();
|
|
1498
|
+
}
|
|
1499
|
+
if (param == null && data.pages.length) {
|
|
1500
|
+
return Promise.resolve(data);
|
|
1501
|
+
}
|
|
1502
|
+
const queryFnContext = {
|
|
1503
|
+
queryKey: context.queryKey,
|
|
1504
|
+
pageParam: param,
|
|
1505
|
+
direction: previous ? "backward" : "forward",
|
|
1506
|
+
meta: context.options.meta
|
|
1507
|
+
};
|
|
1508
|
+
addSignalProperty(queryFnContext);
|
|
1509
|
+
const page = await queryFn(
|
|
1510
|
+
queryFnContext
|
|
1511
|
+
);
|
|
1512
|
+
const { maxPages } = context.options;
|
|
1513
|
+
const addTo = previous ? addToStart : addToEnd;
|
|
1514
|
+
return {
|
|
1515
|
+
pages: addTo(data.pages, page, maxPages),
|
|
1516
|
+
pageParams: addTo(data.pageParams, param, maxPages)
|
|
1517
|
+
};
|
|
1518
|
+
};
|
|
1519
|
+
let result;
|
|
1520
|
+
if (direction && oldPages.length) {
|
|
1521
|
+
const previous = direction === "backward";
|
|
1522
|
+
const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
|
|
1523
|
+
const oldData = {
|
|
1524
|
+
pages: oldPages,
|
|
1525
|
+
pageParams: oldPageParams
|
|
1526
|
+
};
|
|
1527
|
+
const param = pageParamFn(options, oldData);
|
|
1528
|
+
result = await fetchPage(oldData, param, previous);
|
|
1529
|
+
} else {
|
|
1530
|
+
result = await fetchPage(
|
|
1531
|
+
empty,
|
|
1532
|
+
oldPageParams[0] ?? options.initialPageParam
|
|
1533
|
+
);
|
|
1534
|
+
const remainingPages = pages ?? oldPages.length;
|
|
1535
|
+
for (let i = 1; i < remainingPages; i++) {
|
|
1536
|
+
const param = getNextPageParam(options, result);
|
|
1537
|
+
result = await fetchPage(result, param);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return result;
|
|
1541
|
+
};
|
|
1542
|
+
if (context.options.persister) {
|
|
1543
|
+
context.fetchFn = () => {
|
|
1544
|
+
return context.options.persister?.(
|
|
1545
|
+
fetchFn,
|
|
1546
|
+
{
|
|
1547
|
+
queryKey: context.queryKey,
|
|
1548
|
+
meta: context.options.meta,
|
|
1549
|
+
signal: context.signal
|
|
1550
|
+
},
|
|
1551
|
+
query
|
|
1552
|
+
);
|
|
1553
|
+
};
|
|
1554
|
+
} else {
|
|
1555
|
+
context.fetchFn = fetchFn;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
function getNextPageParam(options, { pages, pageParams }) {
|
|
1561
|
+
const lastIndex = pages.length - 1;
|
|
1562
|
+
return options.getNextPageParam(
|
|
1563
|
+
pages[lastIndex],
|
|
1564
|
+
pages,
|
|
1565
|
+
pageParams[lastIndex],
|
|
1566
|
+
pageParams
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
function getPreviousPageParam(options, { pages, pageParams }) {
|
|
1570
|
+
return options.getPreviousPageParam?.(
|
|
1571
|
+
pages[0],
|
|
1572
|
+
pages,
|
|
1573
|
+
pageParams[0],
|
|
1574
|
+
pageParams
|
|
1575
|
+
);
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
// src/queryClient.ts
|
|
1579
|
+
var QueryClient = class {
|
|
1580
|
+
#queryCache;
|
|
1581
|
+
#mutationCache;
|
|
1582
|
+
#defaultOptions;
|
|
1583
|
+
#queryDefaults;
|
|
1584
|
+
#mutationDefaults;
|
|
1585
|
+
#mountCount;
|
|
1586
|
+
#unsubscribeFocus;
|
|
1587
|
+
#unsubscribeOnline;
|
|
1588
|
+
constructor(config = {}) {
|
|
1589
|
+
this.#queryCache = config.queryCache || new QueryCache();
|
|
1590
|
+
this.#mutationCache = config.mutationCache || new MutationCache();
|
|
1591
|
+
this.#defaultOptions = config.defaultOptions || {};
|
|
1592
|
+
this.#queryDefaults = /* @__PURE__ */ new Map();
|
|
1593
|
+
this.#mutationDefaults = /* @__PURE__ */ new Map();
|
|
1594
|
+
this.#mountCount = 0;
|
|
1595
|
+
}
|
|
1596
|
+
mount() {
|
|
1597
|
+
this.#mountCount++;
|
|
1598
|
+
if (this.#mountCount !== 1)
|
|
1599
|
+
return;
|
|
1600
|
+
this.#unsubscribeFocus = focusManager.subscribe(async (focused) => {
|
|
1601
|
+
if (focused) {
|
|
1602
|
+
await this.resumePausedMutations();
|
|
1603
|
+
this.#queryCache.onFocus();
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
this.#unsubscribeOnline = onlineManager.subscribe(async (online) => {
|
|
1607
|
+
if (online) {
|
|
1608
|
+
await this.resumePausedMutations();
|
|
1609
|
+
this.#queryCache.onOnline();
|
|
1610
|
+
}
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
unmount() {
|
|
1614
|
+
this.#mountCount--;
|
|
1615
|
+
if (this.#mountCount !== 0)
|
|
1616
|
+
return;
|
|
1617
|
+
this.#unsubscribeFocus?.();
|
|
1618
|
+
this.#unsubscribeFocus = void 0;
|
|
1619
|
+
this.#unsubscribeOnline?.();
|
|
1620
|
+
this.#unsubscribeOnline = void 0;
|
|
1621
|
+
}
|
|
1622
|
+
isFetching(filters) {
|
|
1623
|
+
return this.#queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length;
|
|
1624
|
+
}
|
|
1625
|
+
isMutating(filters) {
|
|
1626
|
+
return this.#mutationCache.findAll({ ...filters, status: "pending" }).length;
|
|
1627
|
+
}
|
|
1628
|
+
getQueryData(queryKey) {
|
|
1629
|
+
const options = this.defaultQueryOptions({ queryKey });
|
|
1630
|
+
return this.#queryCache.get(options.queryHash)?.state.data;
|
|
1631
|
+
}
|
|
1632
|
+
ensureQueryData(options) {
|
|
1633
|
+
const cachedData = this.getQueryData(options.queryKey);
|
|
1634
|
+
if (cachedData === void 0)
|
|
1635
|
+
return this.fetchQuery(options);
|
|
1636
|
+
else {
|
|
1637
|
+
const defaultedOptions = this.defaultQueryOptions(options);
|
|
1638
|
+
const query = this.#queryCache.build(this, defaultedOptions);
|
|
1639
|
+
if (options.revalidateIfStale && query.isStaleByTime(defaultedOptions.staleTime)) {
|
|
1640
|
+
void this.prefetchQuery(defaultedOptions);
|
|
1641
|
+
}
|
|
1642
|
+
return Promise.resolve(cachedData);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
getQueriesData(filters) {
|
|
1646
|
+
return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
|
|
1647
|
+
const data = state.data;
|
|
1648
|
+
return [queryKey, data];
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
setQueryData(queryKey, updater, options) {
|
|
1652
|
+
const defaultedOptions = this.defaultQueryOptions({ queryKey });
|
|
1653
|
+
const query = this.#queryCache.get(
|
|
1654
|
+
defaultedOptions.queryHash
|
|
1655
|
+
);
|
|
1656
|
+
const prevData = query?.state.data;
|
|
1657
|
+
const data = functionalUpdate(updater, prevData);
|
|
1658
|
+
if (data === void 0) {
|
|
1659
|
+
return void 0;
|
|
1660
|
+
}
|
|
1661
|
+
return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true });
|
|
1662
|
+
}
|
|
1663
|
+
setQueriesData(filters, updater, options) {
|
|
1664
|
+
return notifyManager.batch(
|
|
1665
|
+
() => this.#queryCache.findAll(filters).map(({ queryKey }) => [
|
|
1666
|
+
queryKey,
|
|
1667
|
+
this.setQueryData(queryKey, updater, options)
|
|
1668
|
+
])
|
|
1669
|
+
);
|
|
1670
|
+
}
|
|
1671
|
+
getQueryState(queryKey) {
|
|
1672
|
+
const options = this.defaultQueryOptions({ queryKey });
|
|
1673
|
+
return this.#queryCache.get(options.queryHash)?.state;
|
|
1674
|
+
}
|
|
1675
|
+
removeQueries(filters) {
|
|
1676
|
+
const queryCache = this.#queryCache;
|
|
1677
|
+
notifyManager.batch(() => {
|
|
1678
|
+
queryCache.findAll(filters).forEach((query) => {
|
|
1679
|
+
queryCache.remove(query);
|
|
1680
|
+
});
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
resetQueries(filters, options) {
|
|
1684
|
+
const queryCache = this.#queryCache;
|
|
1685
|
+
const refetchFilters = {
|
|
1686
|
+
type: "active",
|
|
1687
|
+
...filters
|
|
1688
|
+
};
|
|
1689
|
+
return notifyManager.batch(() => {
|
|
1690
|
+
queryCache.findAll(filters).forEach((query) => {
|
|
1691
|
+
query.reset();
|
|
1692
|
+
});
|
|
1693
|
+
return this.refetchQueries(refetchFilters, options);
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
cancelQueries(filters = {}, cancelOptions = {}) {
|
|
1697
|
+
const defaultedCancelOptions = { revert: true, ...cancelOptions };
|
|
1698
|
+
const promises = notifyManager.batch(
|
|
1699
|
+
() => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions))
|
|
1700
|
+
);
|
|
1701
|
+
return Promise.all(promises).then(noop$1).catch(noop$1);
|
|
1702
|
+
}
|
|
1703
|
+
invalidateQueries(filters = {}, options = {}) {
|
|
1704
|
+
return notifyManager.batch(() => {
|
|
1705
|
+
this.#queryCache.findAll(filters).forEach((query) => {
|
|
1706
|
+
query.invalidate();
|
|
1707
|
+
});
|
|
1708
|
+
if (filters.refetchType === "none") {
|
|
1709
|
+
return Promise.resolve();
|
|
1710
|
+
}
|
|
1711
|
+
const refetchFilters = {
|
|
1712
|
+
...filters,
|
|
1713
|
+
type: filters.refetchType ?? filters.type ?? "active"
|
|
1714
|
+
};
|
|
1715
|
+
return this.refetchQueries(refetchFilters, options);
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
refetchQueries(filters = {}, options) {
|
|
1719
|
+
const fetchOptions = {
|
|
1720
|
+
...options,
|
|
1721
|
+
cancelRefetch: options?.cancelRefetch ?? true
|
|
1722
|
+
};
|
|
1723
|
+
const promises = notifyManager.batch(
|
|
1724
|
+
() => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled()).map((query) => {
|
|
1725
|
+
let promise = query.fetch(void 0, fetchOptions);
|
|
1726
|
+
if (!fetchOptions.throwOnError) {
|
|
1727
|
+
promise = promise.catch(noop$1);
|
|
1728
|
+
}
|
|
1729
|
+
return query.state.fetchStatus === "paused" ? Promise.resolve() : promise;
|
|
1730
|
+
})
|
|
1731
|
+
);
|
|
1732
|
+
return Promise.all(promises).then(noop$1);
|
|
1733
|
+
}
|
|
1734
|
+
fetchQuery(options) {
|
|
1735
|
+
const defaultedOptions = this.defaultQueryOptions(options);
|
|
1736
|
+
if (defaultedOptions.retry === void 0) {
|
|
1737
|
+
defaultedOptions.retry = false;
|
|
1738
|
+
}
|
|
1739
|
+
const query = this.#queryCache.build(this, defaultedOptions);
|
|
1740
|
+
return query.isStaleByTime(defaultedOptions.staleTime) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
|
|
1741
|
+
}
|
|
1742
|
+
prefetchQuery(options) {
|
|
1743
|
+
return this.fetchQuery(options).then(noop$1).catch(noop$1);
|
|
1744
|
+
}
|
|
1745
|
+
fetchInfiniteQuery(options) {
|
|
1746
|
+
options.behavior = infiniteQueryBehavior(options.pages);
|
|
1747
|
+
return this.fetchQuery(options);
|
|
1748
|
+
}
|
|
1749
|
+
prefetchInfiniteQuery(options) {
|
|
1750
|
+
return this.fetchInfiniteQuery(options).then(noop$1).catch(noop$1);
|
|
1751
|
+
}
|
|
1752
|
+
resumePausedMutations() {
|
|
1753
|
+
if (onlineManager.isOnline()) {
|
|
1754
|
+
return this.#mutationCache.resumePausedMutations();
|
|
1755
|
+
}
|
|
1756
|
+
return Promise.resolve();
|
|
1757
|
+
}
|
|
1758
|
+
getQueryCache() {
|
|
1759
|
+
return this.#queryCache;
|
|
1760
|
+
}
|
|
1761
|
+
getMutationCache() {
|
|
1762
|
+
return this.#mutationCache;
|
|
1763
|
+
}
|
|
1764
|
+
getDefaultOptions() {
|
|
1765
|
+
return this.#defaultOptions;
|
|
1766
|
+
}
|
|
1767
|
+
setDefaultOptions(options) {
|
|
1768
|
+
this.#defaultOptions = options;
|
|
1769
|
+
}
|
|
1770
|
+
setQueryDefaults(queryKey, options) {
|
|
1771
|
+
this.#queryDefaults.set(hashKey(queryKey), {
|
|
1772
|
+
queryKey,
|
|
1773
|
+
defaultOptions: options
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
getQueryDefaults(queryKey) {
|
|
1777
|
+
const defaults = [...this.#queryDefaults.values()];
|
|
1778
|
+
let result = {};
|
|
1779
|
+
defaults.forEach((queryDefault) => {
|
|
1780
|
+
if (partialMatchKey(queryKey, queryDefault.queryKey)) {
|
|
1781
|
+
result = { ...result, ...queryDefault.defaultOptions };
|
|
1782
|
+
}
|
|
1783
|
+
});
|
|
1784
|
+
return result;
|
|
1785
|
+
}
|
|
1786
|
+
setMutationDefaults(mutationKey, options) {
|
|
1787
|
+
this.#mutationDefaults.set(hashKey(mutationKey), {
|
|
1788
|
+
mutationKey,
|
|
1789
|
+
defaultOptions: options
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
getMutationDefaults(mutationKey) {
|
|
1793
|
+
const defaults = [...this.#mutationDefaults.values()];
|
|
1794
|
+
let result = {};
|
|
1795
|
+
defaults.forEach((queryDefault) => {
|
|
1796
|
+
if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {
|
|
1797
|
+
result = { ...result, ...queryDefault.defaultOptions };
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1800
|
+
return result;
|
|
1801
|
+
}
|
|
1802
|
+
defaultQueryOptions(options) {
|
|
1803
|
+
if (options._defaulted) {
|
|
1804
|
+
return options;
|
|
1805
|
+
}
|
|
1806
|
+
const defaultedOptions = {
|
|
1807
|
+
...this.#defaultOptions.queries,
|
|
1808
|
+
...this.getQueryDefaults(options.queryKey),
|
|
1809
|
+
...options,
|
|
1810
|
+
_defaulted: true
|
|
1811
|
+
};
|
|
1812
|
+
if (!defaultedOptions.queryHash) {
|
|
1813
|
+
defaultedOptions.queryHash = hashQueryKeyByOptions(
|
|
1814
|
+
defaultedOptions.queryKey,
|
|
1815
|
+
defaultedOptions
|
|
1816
|
+
);
|
|
1817
|
+
}
|
|
1818
|
+
if (defaultedOptions.refetchOnReconnect === void 0) {
|
|
1819
|
+
defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always";
|
|
1820
|
+
}
|
|
1821
|
+
if (defaultedOptions.throwOnError === void 0) {
|
|
1822
|
+
defaultedOptions.throwOnError = !!defaultedOptions.suspense;
|
|
1823
|
+
}
|
|
1824
|
+
if (!defaultedOptions.networkMode && defaultedOptions.persister) {
|
|
1825
|
+
defaultedOptions.networkMode = "offlineFirst";
|
|
1826
|
+
}
|
|
1827
|
+
if (defaultedOptions.enabled !== true && defaultedOptions.queryFn === skipToken) {
|
|
1828
|
+
defaultedOptions.enabled = false;
|
|
1829
|
+
}
|
|
1830
|
+
return defaultedOptions;
|
|
1831
|
+
}
|
|
1832
|
+
defaultMutationOptions(options) {
|
|
1833
|
+
if (options?._defaulted) {
|
|
1834
|
+
return options;
|
|
1835
|
+
}
|
|
1836
|
+
return {
|
|
1837
|
+
...this.#defaultOptions.mutations,
|
|
1838
|
+
...options?.mutationKey && this.getMutationDefaults(options.mutationKey),
|
|
1839
|
+
...options,
|
|
1840
|
+
_defaulted: true
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1843
|
+
clear() {
|
|
1844
|
+
this.#queryCache.clear();
|
|
1845
|
+
this.#mutationCache.clear();
|
|
1846
|
+
}
|
|
1847
|
+
};
|
|
1848
|
+
|
|
1849
|
+
// src/queryObserver.ts
|
|
1850
|
+
var QueryObserver = class extends Subscribable {
|
|
1851
|
+
constructor(client, options) {
|
|
1852
|
+
super();
|
|
1853
|
+
this.options = options;
|
|
1854
|
+
this.#client = client;
|
|
1855
|
+
this.#selectError = null;
|
|
1856
|
+
this.bindMethods();
|
|
1857
|
+
this.setOptions(options);
|
|
1858
|
+
}
|
|
1859
|
+
#client;
|
|
1860
|
+
#currentQuery = void 0;
|
|
1861
|
+
#currentQueryInitialState = void 0;
|
|
1862
|
+
#currentResult = void 0;
|
|
1863
|
+
#currentResultState;
|
|
1864
|
+
#currentResultOptions;
|
|
1865
|
+
#selectError;
|
|
1866
|
+
#selectFn;
|
|
1867
|
+
#selectResult;
|
|
1868
|
+
// This property keeps track of the last query with defined data.
|
|
1869
|
+
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
1870
|
+
#lastQueryWithDefinedData;
|
|
1871
|
+
#staleTimeoutId;
|
|
1872
|
+
#refetchIntervalId;
|
|
1873
|
+
#currentRefetchInterval;
|
|
1874
|
+
#trackedProps = /* @__PURE__ */ new Set();
|
|
1875
|
+
bindMethods() {
|
|
1876
|
+
this.refetch = this.refetch.bind(this);
|
|
1877
|
+
}
|
|
1878
|
+
onSubscribe() {
|
|
1879
|
+
if (this.listeners.size === 1) {
|
|
1880
|
+
this.#currentQuery.addObserver(this);
|
|
1881
|
+
if (shouldFetchOnMount(this.#currentQuery, this.options)) {
|
|
1882
|
+
this.#executeFetch();
|
|
1883
|
+
} else {
|
|
1884
|
+
this.updateResult();
|
|
1885
|
+
}
|
|
1886
|
+
this.#updateTimers();
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
onUnsubscribe() {
|
|
1890
|
+
if (!this.hasListeners()) {
|
|
1891
|
+
this.destroy();
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
shouldFetchOnReconnect() {
|
|
1895
|
+
return shouldFetchOn(
|
|
1896
|
+
this.#currentQuery,
|
|
1897
|
+
this.options,
|
|
1898
|
+
this.options.refetchOnReconnect
|
|
1899
|
+
);
|
|
1900
|
+
}
|
|
1901
|
+
shouldFetchOnWindowFocus() {
|
|
1902
|
+
return shouldFetchOn(
|
|
1903
|
+
this.#currentQuery,
|
|
1904
|
+
this.options,
|
|
1905
|
+
this.options.refetchOnWindowFocus
|
|
1906
|
+
);
|
|
1907
|
+
}
|
|
1908
|
+
destroy() {
|
|
1909
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
1910
|
+
this.#clearStaleTimeout();
|
|
1911
|
+
this.#clearRefetchInterval();
|
|
1912
|
+
this.#currentQuery.removeObserver(this);
|
|
1913
|
+
}
|
|
1914
|
+
setOptions(options, notifyOptions) {
|
|
1915
|
+
const prevOptions = this.options;
|
|
1916
|
+
const prevQuery = this.#currentQuery;
|
|
1917
|
+
this.options = this.#client.defaultQueryOptions(options);
|
|
1918
|
+
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean") {
|
|
1919
|
+
throw new Error("Expected enabled to be a boolean");
|
|
1920
|
+
}
|
|
1921
|
+
this.#updateQuery();
|
|
1922
|
+
this.#currentQuery.setOptions(this.options);
|
|
1923
|
+
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
|
|
1924
|
+
this.#client.getQueryCache().notify({
|
|
1925
|
+
type: "observerOptionsUpdated",
|
|
1926
|
+
query: this.#currentQuery,
|
|
1927
|
+
observer: this
|
|
1928
|
+
});
|
|
1929
|
+
}
|
|
1930
|
+
const mounted = this.hasListeners();
|
|
1931
|
+
if (mounted && shouldFetchOptionally(
|
|
1932
|
+
this.#currentQuery,
|
|
1933
|
+
prevQuery,
|
|
1934
|
+
this.options,
|
|
1935
|
+
prevOptions
|
|
1936
|
+
)) {
|
|
1937
|
+
this.#executeFetch();
|
|
1938
|
+
}
|
|
1939
|
+
this.updateResult(notifyOptions);
|
|
1940
|
+
if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) {
|
|
1941
|
+
this.#updateStaleTimeout();
|
|
1942
|
+
}
|
|
1943
|
+
const nextRefetchInterval = this.#computeRefetchInterval();
|
|
1944
|
+
if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== this.#currentRefetchInterval)) {
|
|
1945
|
+
this.#updateRefetchInterval(nextRefetchInterval);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
getOptimisticResult(options) {
|
|
1949
|
+
const query = this.#client.getQueryCache().build(this.#client, options);
|
|
1950
|
+
const result = this.createResult(query, options);
|
|
1951
|
+
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
1952
|
+
this.#currentResult = result;
|
|
1953
|
+
this.#currentResultOptions = this.options;
|
|
1954
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
1955
|
+
}
|
|
1956
|
+
return result;
|
|
1957
|
+
}
|
|
1958
|
+
getCurrentResult() {
|
|
1959
|
+
return this.#currentResult;
|
|
1960
|
+
}
|
|
1961
|
+
trackResult(result, onPropTracked) {
|
|
1962
|
+
const trackedResult = {};
|
|
1963
|
+
Object.keys(result).forEach((key) => {
|
|
1964
|
+
Object.defineProperty(trackedResult, key, {
|
|
1965
|
+
configurable: false,
|
|
1966
|
+
enumerable: true,
|
|
1967
|
+
get: () => {
|
|
1968
|
+
this.trackProp(key);
|
|
1969
|
+
onPropTracked?.(key);
|
|
1970
|
+
return result[key];
|
|
1971
|
+
}
|
|
1972
|
+
});
|
|
1973
|
+
});
|
|
1974
|
+
return trackedResult;
|
|
1975
|
+
}
|
|
1976
|
+
trackProp(key) {
|
|
1977
|
+
this.#trackedProps.add(key);
|
|
1978
|
+
}
|
|
1979
|
+
getCurrentQuery() {
|
|
1980
|
+
return this.#currentQuery;
|
|
1981
|
+
}
|
|
1982
|
+
refetch({ ...options } = {}) {
|
|
1983
|
+
return this.fetch({
|
|
1984
|
+
...options
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1987
|
+
fetchOptimistic(options) {
|
|
1988
|
+
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
1989
|
+
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
|
|
1990
|
+
query.isFetchingOptimistic = true;
|
|
1991
|
+
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
1992
|
+
}
|
|
1993
|
+
fetch(fetchOptions) {
|
|
1994
|
+
return this.#executeFetch({
|
|
1995
|
+
...fetchOptions,
|
|
1996
|
+
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
1997
|
+
}).then(() => {
|
|
1998
|
+
this.updateResult();
|
|
1999
|
+
return this.#currentResult;
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
#executeFetch(fetchOptions) {
|
|
2003
|
+
this.#updateQuery();
|
|
2004
|
+
let promise = this.#currentQuery.fetch(
|
|
2005
|
+
this.options,
|
|
2006
|
+
fetchOptions
|
|
2007
|
+
);
|
|
2008
|
+
if (!fetchOptions?.throwOnError) {
|
|
2009
|
+
promise = promise.catch(noop$1);
|
|
2010
|
+
}
|
|
2011
|
+
return promise;
|
|
2012
|
+
}
|
|
2013
|
+
#updateStaleTimeout() {
|
|
2014
|
+
this.#clearStaleTimeout();
|
|
2015
|
+
if (isServer || this.#currentResult.isStale || !isValidTimeout(this.options.staleTime)) {
|
|
2016
|
+
return;
|
|
2017
|
+
}
|
|
2018
|
+
const time = timeUntilStale(
|
|
2019
|
+
this.#currentResult.dataUpdatedAt,
|
|
2020
|
+
this.options.staleTime
|
|
2021
|
+
);
|
|
2022
|
+
const timeout = time + 1;
|
|
2023
|
+
this.#staleTimeoutId = setTimeout(() => {
|
|
2024
|
+
if (!this.#currentResult.isStale) {
|
|
2025
|
+
this.updateResult();
|
|
2026
|
+
}
|
|
2027
|
+
}, timeout);
|
|
2028
|
+
}
|
|
2029
|
+
#computeRefetchInterval() {
|
|
2030
|
+
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
|
|
2031
|
+
}
|
|
2032
|
+
#updateRefetchInterval(nextInterval) {
|
|
2033
|
+
this.#clearRefetchInterval();
|
|
2034
|
+
this.#currentRefetchInterval = nextInterval;
|
|
2035
|
+
if (isServer || this.options.enabled === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
|
|
2036
|
+
return;
|
|
2037
|
+
}
|
|
2038
|
+
this.#refetchIntervalId = setInterval(() => {
|
|
2039
|
+
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
|
|
2040
|
+
this.#executeFetch();
|
|
2041
|
+
}
|
|
2042
|
+
}, this.#currentRefetchInterval);
|
|
2043
|
+
}
|
|
2044
|
+
#updateTimers() {
|
|
2045
|
+
this.#updateStaleTimeout();
|
|
2046
|
+
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
2047
|
+
}
|
|
2048
|
+
#clearStaleTimeout() {
|
|
2049
|
+
if (this.#staleTimeoutId) {
|
|
2050
|
+
clearTimeout(this.#staleTimeoutId);
|
|
2051
|
+
this.#staleTimeoutId = void 0;
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
#clearRefetchInterval() {
|
|
2055
|
+
if (this.#refetchIntervalId) {
|
|
2056
|
+
clearInterval(this.#refetchIntervalId);
|
|
2057
|
+
this.#refetchIntervalId = void 0;
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
createResult(query, options) {
|
|
2061
|
+
const prevQuery = this.#currentQuery;
|
|
2062
|
+
const prevOptions = this.options;
|
|
2063
|
+
const prevResult = this.#currentResult;
|
|
2064
|
+
const prevResultState = this.#currentResultState;
|
|
2065
|
+
const prevResultOptions = this.#currentResultOptions;
|
|
2066
|
+
const queryChange = query !== prevQuery;
|
|
2067
|
+
const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
|
|
2068
|
+
const { state } = query;
|
|
2069
|
+
let newState = { ...state };
|
|
2070
|
+
let isPlaceholderData = false;
|
|
2071
|
+
let data;
|
|
2072
|
+
if (options._optimisticResults) {
|
|
2073
|
+
const mounted = this.hasListeners();
|
|
2074
|
+
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
2075
|
+
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
2076
|
+
if (fetchOnMount || fetchOptionally) {
|
|
2077
|
+
newState = {
|
|
2078
|
+
...newState,
|
|
2079
|
+
...fetchState(state.data, query.options)
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
if (options._optimisticResults === "isRestoring") {
|
|
2083
|
+
newState.fetchStatus = "idle";
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
let { error, errorUpdatedAt, status } = newState;
|
|
2087
|
+
if (options.select && newState.data !== void 0) {
|
|
2088
|
+
if (prevResult && newState.data === prevResultState?.data && options.select === this.#selectFn) {
|
|
2089
|
+
data = this.#selectResult;
|
|
2090
|
+
} else {
|
|
2091
|
+
try {
|
|
2092
|
+
this.#selectFn = options.select;
|
|
2093
|
+
data = options.select(newState.data);
|
|
2094
|
+
data = replaceData(prevResult?.data, data, options);
|
|
2095
|
+
this.#selectResult = data;
|
|
2096
|
+
this.#selectError = null;
|
|
2097
|
+
} catch (selectError) {
|
|
2098
|
+
this.#selectError = selectError;
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
} else {
|
|
2102
|
+
data = newState.data;
|
|
2103
|
+
}
|
|
2104
|
+
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
2105
|
+
let placeholderData;
|
|
2106
|
+
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
2107
|
+
placeholderData = prevResult.data;
|
|
2108
|
+
} else {
|
|
2109
|
+
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
|
|
2110
|
+
this.#lastQueryWithDefinedData?.state.data,
|
|
2111
|
+
this.#lastQueryWithDefinedData
|
|
2112
|
+
) : options.placeholderData;
|
|
2113
|
+
if (options.select && placeholderData !== void 0) {
|
|
2114
|
+
try {
|
|
2115
|
+
placeholderData = options.select(placeholderData);
|
|
2116
|
+
this.#selectError = null;
|
|
2117
|
+
} catch (selectError) {
|
|
2118
|
+
this.#selectError = selectError;
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
if (placeholderData !== void 0) {
|
|
2123
|
+
status = "success";
|
|
2124
|
+
data = replaceData(
|
|
2125
|
+
prevResult?.data,
|
|
2126
|
+
placeholderData,
|
|
2127
|
+
options
|
|
2128
|
+
);
|
|
2129
|
+
isPlaceholderData = true;
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
if (this.#selectError) {
|
|
2133
|
+
error = this.#selectError;
|
|
2134
|
+
data = this.#selectResult;
|
|
2135
|
+
errorUpdatedAt = Date.now();
|
|
2136
|
+
status = "error";
|
|
2137
|
+
}
|
|
2138
|
+
const isFetching = newState.fetchStatus === "fetching";
|
|
2139
|
+
const isPending = status === "pending";
|
|
2140
|
+
const isError = status === "error";
|
|
2141
|
+
const isLoading = isPending && isFetching;
|
|
2142
|
+
const hasData = data !== void 0;
|
|
2143
|
+
const result = {
|
|
2144
|
+
status,
|
|
2145
|
+
fetchStatus: newState.fetchStatus,
|
|
2146
|
+
isPending,
|
|
2147
|
+
isSuccess: status === "success",
|
|
2148
|
+
isError,
|
|
2149
|
+
isInitialLoading: isLoading,
|
|
2150
|
+
isLoading,
|
|
2151
|
+
data,
|
|
2152
|
+
dataUpdatedAt: newState.dataUpdatedAt,
|
|
2153
|
+
error,
|
|
2154
|
+
errorUpdatedAt,
|
|
2155
|
+
failureCount: newState.fetchFailureCount,
|
|
2156
|
+
failureReason: newState.fetchFailureReason,
|
|
2157
|
+
errorUpdateCount: newState.errorUpdateCount,
|
|
2158
|
+
isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
|
|
2159
|
+
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
2160
|
+
isFetching,
|
|
2161
|
+
isRefetching: isFetching && !isPending,
|
|
2162
|
+
isLoadingError: isError && !hasData,
|
|
2163
|
+
isPaused: newState.fetchStatus === "paused",
|
|
2164
|
+
isPlaceholderData,
|
|
2165
|
+
isRefetchError: isError && hasData,
|
|
2166
|
+
isStale: isStale(query, options),
|
|
2167
|
+
refetch: this.refetch
|
|
2168
|
+
};
|
|
2169
|
+
return result;
|
|
2170
|
+
}
|
|
2171
|
+
updateResult(notifyOptions) {
|
|
2172
|
+
const prevResult = this.#currentResult;
|
|
2173
|
+
const nextResult = this.createResult(this.#currentQuery, this.options);
|
|
2174
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
2175
|
+
this.#currentResultOptions = this.options;
|
|
2176
|
+
if (this.#currentResultState.data !== void 0) {
|
|
2177
|
+
this.#lastQueryWithDefinedData = this.#currentQuery;
|
|
2178
|
+
}
|
|
2179
|
+
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
this.#currentResult = nextResult;
|
|
2183
|
+
const defaultNotifyOptions = {};
|
|
2184
|
+
const shouldNotifyListeners = () => {
|
|
2185
|
+
if (!prevResult) {
|
|
2186
|
+
return true;
|
|
2187
|
+
}
|
|
2188
|
+
const { notifyOnChangeProps } = this.options;
|
|
2189
|
+
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
2190
|
+
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) {
|
|
2191
|
+
return true;
|
|
2192
|
+
}
|
|
2193
|
+
const includedProps = new Set(
|
|
2194
|
+
notifyOnChangePropsValue ?? this.#trackedProps
|
|
2195
|
+
);
|
|
2196
|
+
if (this.options.throwOnError) {
|
|
2197
|
+
includedProps.add("error");
|
|
2198
|
+
}
|
|
2199
|
+
return Object.keys(this.#currentResult).some((key) => {
|
|
2200
|
+
const typedKey = key;
|
|
2201
|
+
const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
|
|
2202
|
+
return changed && includedProps.has(typedKey);
|
|
2203
|
+
});
|
|
2204
|
+
};
|
|
2205
|
+
if (notifyOptions?.listeners !== false && shouldNotifyListeners()) {
|
|
2206
|
+
defaultNotifyOptions.listeners = true;
|
|
2207
|
+
}
|
|
2208
|
+
this.#notify({ ...defaultNotifyOptions, ...notifyOptions });
|
|
2209
|
+
}
|
|
2210
|
+
#updateQuery() {
|
|
2211
|
+
const query = this.#client.getQueryCache().build(this.#client, this.options);
|
|
2212
|
+
if (query === this.#currentQuery) {
|
|
2213
|
+
return;
|
|
2214
|
+
}
|
|
2215
|
+
const prevQuery = this.#currentQuery;
|
|
2216
|
+
this.#currentQuery = query;
|
|
2217
|
+
this.#currentQueryInitialState = query.state;
|
|
2218
|
+
if (this.hasListeners()) {
|
|
2219
|
+
prevQuery?.removeObserver(this);
|
|
2220
|
+
query.addObserver(this);
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
onQueryUpdate() {
|
|
2224
|
+
this.updateResult();
|
|
2225
|
+
if (this.hasListeners()) {
|
|
2226
|
+
this.#updateTimers();
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
#notify(notifyOptions) {
|
|
2230
|
+
notifyManager.batch(() => {
|
|
2231
|
+
if (notifyOptions.listeners) {
|
|
2232
|
+
this.listeners.forEach((listener) => {
|
|
2233
|
+
listener(this.#currentResult);
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
this.#client.getQueryCache().notify({
|
|
2237
|
+
query: this.#currentQuery,
|
|
2238
|
+
type: "observerResultsUpdated"
|
|
2239
|
+
});
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
};
|
|
2243
|
+
function shouldLoadOnMount(query, options) {
|
|
2244
|
+
return options.enabled !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
|
|
2245
|
+
}
|
|
2246
|
+
function shouldFetchOnMount(query, options) {
|
|
2247
|
+
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
2248
|
+
}
|
|
2249
|
+
function shouldFetchOn(query, options, field) {
|
|
2250
|
+
if (options.enabled !== false) {
|
|
2251
|
+
const value = typeof field === "function" ? field(query) : field;
|
|
2252
|
+
return value === "always" || value !== false && isStale(query, options);
|
|
2253
|
+
}
|
|
2254
|
+
return false;
|
|
2255
|
+
}
|
|
2256
|
+
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
2257
|
+
return (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
2258
|
+
}
|
|
2259
|
+
function isStale(query, options) {
|
|
2260
|
+
return options.enabled !== false && query.isStaleByTime(options.staleTime);
|
|
2261
|
+
}
|
|
2262
|
+
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
2263
|
+
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
2264
|
+
return true;
|
|
2265
|
+
}
|
|
2266
|
+
return false;
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
// src/mutationObserver.ts
|
|
2270
|
+
var MutationObserver = class extends Subscribable {
|
|
2271
|
+
#client;
|
|
2272
|
+
#currentResult = void 0;
|
|
2273
|
+
#currentMutation;
|
|
2274
|
+
#mutateOptions;
|
|
2275
|
+
constructor(client, options) {
|
|
2276
|
+
super();
|
|
2277
|
+
this.#client = client;
|
|
2278
|
+
this.setOptions(options);
|
|
2279
|
+
this.bindMethods();
|
|
2280
|
+
this.#updateResult();
|
|
2281
|
+
}
|
|
2282
|
+
bindMethods() {
|
|
2283
|
+
this.mutate = this.mutate.bind(this);
|
|
2284
|
+
this.reset = this.reset.bind(this);
|
|
2285
|
+
}
|
|
2286
|
+
setOptions(options) {
|
|
2287
|
+
const prevOptions = this.options;
|
|
2288
|
+
this.options = this.#client.defaultMutationOptions(options);
|
|
2289
|
+
if (!shallowEqualObjects(this.options, prevOptions)) {
|
|
2290
|
+
this.#client.getMutationCache().notify({
|
|
2291
|
+
type: "observerOptionsUpdated",
|
|
2292
|
+
mutation: this.#currentMutation,
|
|
2293
|
+
observer: this
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) {
|
|
2297
|
+
this.reset();
|
|
2298
|
+
} else if (this.#currentMutation?.state.status === "pending") {
|
|
2299
|
+
this.#currentMutation.setOptions(this.options);
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
onUnsubscribe() {
|
|
2303
|
+
if (!this.hasListeners()) {
|
|
2304
|
+
this.#currentMutation?.removeObserver(this);
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
onMutationUpdate(action) {
|
|
2308
|
+
this.#updateResult();
|
|
2309
|
+
this.#notify(action);
|
|
2310
|
+
}
|
|
2311
|
+
getCurrentResult() {
|
|
2312
|
+
return this.#currentResult;
|
|
2313
|
+
}
|
|
2314
|
+
reset() {
|
|
2315
|
+
this.#currentMutation?.removeObserver(this);
|
|
2316
|
+
this.#currentMutation = void 0;
|
|
2317
|
+
this.#updateResult();
|
|
2318
|
+
this.#notify();
|
|
2319
|
+
}
|
|
2320
|
+
mutate(variables, options) {
|
|
2321
|
+
this.#mutateOptions = options;
|
|
2322
|
+
this.#currentMutation?.removeObserver(this);
|
|
2323
|
+
this.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options);
|
|
2324
|
+
this.#currentMutation.addObserver(this);
|
|
2325
|
+
return this.#currentMutation.execute(variables);
|
|
2326
|
+
}
|
|
2327
|
+
#updateResult() {
|
|
2328
|
+
const state = this.#currentMutation?.state ?? getDefaultState();
|
|
2329
|
+
this.#currentResult = {
|
|
2330
|
+
...state,
|
|
2331
|
+
isPending: state.status === "pending",
|
|
2332
|
+
isSuccess: state.status === "success",
|
|
2333
|
+
isError: state.status === "error",
|
|
2334
|
+
isIdle: state.status === "idle",
|
|
2335
|
+
mutate: this.mutate,
|
|
2336
|
+
reset: this.reset
|
|
2337
|
+
};
|
|
2338
|
+
}
|
|
2339
|
+
#notify(action) {
|
|
2340
|
+
notifyManager.batch(() => {
|
|
2341
|
+
if (this.#mutateOptions && this.hasListeners()) {
|
|
2342
|
+
const variables = this.#currentResult.variables;
|
|
2343
|
+
const context = this.#currentResult.context;
|
|
2344
|
+
if (action?.type === "success") {
|
|
2345
|
+
this.#mutateOptions.onSuccess?.(action.data, variables, context);
|
|
2346
|
+
this.#mutateOptions.onSettled?.(action.data, null, variables, context);
|
|
2347
|
+
} else if (action?.type === "error") {
|
|
2348
|
+
this.#mutateOptions.onError?.(action.error, variables, context);
|
|
2349
|
+
this.#mutateOptions.onSettled?.(
|
|
2350
|
+
void 0,
|
|
2351
|
+
action.error,
|
|
2352
|
+
variables,
|
|
2353
|
+
context
|
|
2354
|
+
);
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
this.listeners.forEach((listener) => {
|
|
2358
|
+
listener(this.#currentResult);
|
|
2359
|
+
});
|
|
2360
|
+
});
|
|
2361
|
+
}
|
|
2362
|
+
};
|
|
2363
|
+
|
|
2364
|
+
var QueryClientContext = React.createContext(
|
|
2365
|
+
void 0
|
|
2366
|
+
);
|
|
2367
|
+
var useQueryClient = (queryClient) => {
|
|
2368
|
+
const client = React.useContext(QueryClientContext);
|
|
2369
|
+
if (queryClient) {
|
|
2370
|
+
return queryClient;
|
|
2371
|
+
}
|
|
2372
|
+
if (!client) {
|
|
2373
|
+
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
2374
|
+
}
|
|
2375
|
+
return client;
|
|
2376
|
+
};
|
|
2377
|
+
var QueryClientProvider = ({
|
|
2378
|
+
client,
|
|
2379
|
+
children
|
|
2380
|
+
}) => {
|
|
2381
|
+
React.useEffect(() => {
|
|
2382
|
+
client.mount();
|
|
2383
|
+
return () => {
|
|
2384
|
+
client.unmount();
|
|
2385
|
+
};
|
|
2386
|
+
}, [client]);
|
|
2387
|
+
return /* @__PURE__ */ jsx(QueryClientContext.Provider, { value: client, children });
|
|
2388
|
+
};
|
|
2389
|
+
|
|
2390
|
+
var IsRestoringContext = React.createContext(false);
|
|
2391
|
+
var useIsRestoring = () => React.useContext(IsRestoringContext);
|
|
2392
|
+
IsRestoringContext.Provider;
|
|
2393
|
+
|
|
2394
|
+
function createValue() {
|
|
2395
|
+
let isReset = false;
|
|
2396
|
+
return {
|
|
2397
|
+
clearReset: () => {
|
|
2398
|
+
isReset = false;
|
|
2399
|
+
},
|
|
2400
|
+
reset: () => {
|
|
2401
|
+
isReset = true;
|
|
2402
|
+
},
|
|
2403
|
+
isReset: () => {
|
|
2404
|
+
return isReset;
|
|
2405
|
+
}
|
|
2406
|
+
};
|
|
2407
|
+
}
|
|
2408
|
+
var QueryErrorResetBoundaryContext = React.createContext(createValue());
|
|
2409
|
+
var useQueryErrorResetBoundary = () => React.useContext(QueryErrorResetBoundaryContext);
|
|
2410
|
+
|
|
2411
|
+
// src/utils.ts
|
|
2412
|
+
function shouldThrowError(throwError, params) {
|
|
2413
|
+
if (typeof throwError === "function") {
|
|
2414
|
+
return throwError(...params);
|
|
2415
|
+
}
|
|
2416
|
+
return !!throwError;
|
|
2417
|
+
}
|
|
2418
|
+
function noop() {
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
|
|
2422
|
+
if (options.suspense || options.throwOnError) {
|
|
2423
|
+
if (!errorResetBoundary.isReset()) {
|
|
2424
|
+
options.retryOnMount = false;
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
};
|
|
2428
|
+
var useClearResetErrorBoundary = (errorResetBoundary) => {
|
|
2429
|
+
React.useEffect(() => {
|
|
2430
|
+
errorResetBoundary.clearReset();
|
|
2431
|
+
}, [errorResetBoundary]);
|
|
2432
|
+
};
|
|
2433
|
+
var getHasError = ({
|
|
2434
|
+
result,
|
|
2435
|
+
errorResetBoundary,
|
|
2436
|
+
throwOnError,
|
|
2437
|
+
query
|
|
2438
|
+
}) => {
|
|
2439
|
+
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && shouldThrowError(throwOnError, [result.error, query]);
|
|
2440
|
+
};
|
|
2441
|
+
|
|
2442
|
+
// src/suspense.ts
|
|
2443
|
+
var ensureStaleTime = (defaultedOptions) => {
|
|
2444
|
+
if (defaultedOptions.suspense) {
|
|
2445
|
+
if (typeof defaultedOptions.staleTime !== "number") {
|
|
2446
|
+
defaultedOptions.staleTime = 1e3;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
|
|
2451
|
+
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
|
2452
|
+
errorResetBoundary.clearReset();
|
|
2453
|
+
});
|
|
2454
|
+
|
|
2455
|
+
function useBaseQuery(options, Observer, queryClient) {
|
|
2456
|
+
const client = useQueryClient(queryClient);
|
|
2457
|
+
const isRestoring = useIsRestoring();
|
|
2458
|
+
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
2459
|
+
const defaultedOptions = client.defaultQueryOptions(options);
|
|
2460
|
+
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
2461
|
+
ensureStaleTime(defaultedOptions);
|
|
2462
|
+
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
2463
|
+
useClearResetErrorBoundary(errorResetBoundary);
|
|
2464
|
+
const [observer] = React.useState(
|
|
2465
|
+
() => new Observer(
|
|
2466
|
+
client,
|
|
2467
|
+
defaultedOptions
|
|
2468
|
+
)
|
|
2469
|
+
);
|
|
2470
|
+
const result = observer.getOptimisticResult(defaultedOptions);
|
|
2471
|
+
React.useSyncExternalStore(
|
|
2472
|
+
React.useCallback(
|
|
2473
|
+
(onStoreChange) => {
|
|
2474
|
+
const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
|
|
2475
|
+
observer.updateResult();
|
|
2476
|
+
return unsubscribe;
|
|
2477
|
+
},
|
|
2478
|
+
[observer, isRestoring]
|
|
2479
|
+
),
|
|
2480
|
+
() => observer.getCurrentResult(),
|
|
2481
|
+
() => observer.getCurrentResult()
|
|
2482
|
+
);
|
|
2483
|
+
React.useEffect(() => {
|
|
2484
|
+
observer.setOptions(defaultedOptions, { listeners: false });
|
|
2485
|
+
}, [defaultedOptions, observer]);
|
|
2486
|
+
if (shouldSuspend(defaultedOptions, result)) {
|
|
2487
|
+
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
2488
|
+
}
|
|
2489
|
+
if (getHasError({
|
|
2490
|
+
result,
|
|
2491
|
+
errorResetBoundary,
|
|
2492
|
+
throwOnError: defaultedOptions.throwOnError,
|
|
2493
|
+
query: client.getQueryCache().get(defaultedOptions.queryHash)
|
|
2494
|
+
})) {
|
|
2495
|
+
throw result.error;
|
|
2496
|
+
}
|
|
2497
|
+
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
function useQuery(options, queryClient) {
|
|
2501
|
+
return useBaseQuery(options, QueryObserver, queryClient);
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
function useMutation(options, queryClient) {
|
|
2505
|
+
const client = useQueryClient(queryClient);
|
|
2506
|
+
const [observer] = React.useState(
|
|
2507
|
+
() => new MutationObserver(
|
|
2508
|
+
client,
|
|
2509
|
+
options
|
|
2510
|
+
)
|
|
2511
|
+
);
|
|
2512
|
+
React.useEffect(() => {
|
|
2513
|
+
observer.setOptions(options);
|
|
2514
|
+
}, [observer, options]);
|
|
2515
|
+
const result = React.useSyncExternalStore(
|
|
2516
|
+
React.useCallback(
|
|
2517
|
+
(onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)),
|
|
2518
|
+
[observer]
|
|
2519
|
+
),
|
|
2520
|
+
() => observer.getCurrentResult(),
|
|
2521
|
+
() => observer.getCurrentResult()
|
|
2522
|
+
);
|
|
2523
|
+
const mutate = React.useCallback(
|
|
2524
|
+
(variables, mutateOptions) => {
|
|
2525
|
+
observer.mutate(variables, mutateOptions).catch(noop);
|
|
2526
|
+
},
|
|
2527
|
+
[observer]
|
|
2528
|
+
);
|
|
2529
|
+
if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) {
|
|
2530
|
+
throw result.error;
|
|
2531
|
+
}
|
|
2532
|
+
return { ...result, mutate, mutateAsync: result.mutate };
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
var ReactQueryDevtools2 = function() {
|
|
2536
|
+
return null;
|
|
2537
|
+
} ;
|
|
2538
|
+
|
|
2539
|
+
/* eslint-disable @bigbinary/neeto/api-connector-name-should-match-filename */
|
|
147
2540
|
var queryClient = new QueryClient({
|
|
148
2541
|
queryCache: new QueryCache(),
|
|
149
2542
|
defaultOptions: {
|
|
150
2543
|
queries: {
|
|
151
2544
|
staleTime: DEFAULT_STALE_TIME,
|
|
152
|
-
|
|
153
|
-
onError: function onError(error) {
|
|
154
|
-
return Toastr.error(error);
|
|
155
|
-
}
|
|
2545
|
+
placeholderData: keepPreviousData
|
|
156
2546
|
}
|
|
157
2547
|
}
|
|
158
2548
|
});
|
|
159
2549
|
|
|
160
|
-
function ownKeys$
|
|
161
|
-
function _objectSpread$
|
|
2550
|
+
function ownKeys$s(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2551
|
+
function _objectSpread$s(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$s(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$s(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
162
2552
|
var withReactQuery = function withReactQuery(Component) {
|
|
163
2553
|
var QueryWrapper = function QueryWrapper(props) {
|
|
164
2554
|
return /*#__PURE__*/jsxs(QueryClientProvider, {
|
|
165
2555
|
client: queryClient,
|
|
166
|
-
children: [/*#__PURE__*/jsx(Component, _objectSpread$
|
|
2556
|
+
children: [/*#__PURE__*/jsx(Component, _objectSpread$s({}, props)), /*#__PURE__*/jsx(ReactQueryDevtools2, {
|
|
167
2557
|
initialIsOpen: false,
|
|
168
|
-
position: "bottom
|
|
2558
|
+
position: "bottom"
|
|
169
2559
|
})]
|
|
170
2560
|
});
|
|
171
2561
|
};
|
|
@@ -662,8 +3052,8 @@ var exportsApi$1 = {
|
|
|
662
3052
|
};
|
|
663
3053
|
|
|
664
3054
|
var useExportData = function useExportData() {
|
|
665
|
-
return useMutation(
|
|
666
|
-
|
|
3055
|
+
return useMutation({
|
|
3056
|
+
mutationFn: exportsApi$1.exportData
|
|
667
3057
|
});
|
|
668
3058
|
};
|
|
669
3059
|
|
|
@@ -672,7 +3062,7 @@ var exportChannel = function exportChannel(token, receivedCallback) {
|
|
|
672
3062
|
channel: "NeetoPaymentsEngine::ExportsChannel",
|
|
673
3063
|
pubsub_token: token
|
|
674
3064
|
}, {
|
|
675
|
-
connected: noop,
|
|
3065
|
+
connected: noop$2,
|
|
676
3066
|
disconnected: function disconnected() {
|
|
677
3067
|
this.perform("unsubscribed");
|
|
678
3068
|
this.unsubscribe();
|
|
@@ -718,8 +3108,8 @@ var buildStripePayoutLink = function buildStripePayoutLink(identifier) {
|
|
|
718
3108
|
return "".concat(STRIPE_DASHBOARD_LINK).concat(isLive ? "" : "test/", "payouts/").concat(identifier);
|
|
719
3109
|
};
|
|
720
3110
|
|
|
721
|
-
function ownKeys$
|
|
722
|
-
function _objectSpread$
|
|
3111
|
+
function ownKeys$r(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3112
|
+
function _objectSpread$r(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$r(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$r(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
723
3113
|
var ExportModal$2 = function ExportModal(_ref) {
|
|
724
3114
|
var showExportModal = _ref.showExportModal,
|
|
725
3115
|
setShowExportModal = _ref.setShowExportModal,
|
|
@@ -750,7 +3140,7 @@ var ExportModal$2 = function ExportModal(_ref) {
|
|
|
750
3140
|
setIsGenerating(false);
|
|
751
3141
|
};
|
|
752
3142
|
var handleGenerateClick = function handleGenerateClick() {
|
|
753
|
-
var payload = _objectSpread$
|
|
3143
|
+
var payload = _objectSpread$r({
|
|
754
3144
|
kind: "account",
|
|
755
3145
|
token: token,
|
|
756
3146
|
filters: filters,
|
|
@@ -833,8 +3223,8 @@ function _toConsumableArray(arr) {
|
|
|
833
3223
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
834
3224
|
}
|
|
835
3225
|
|
|
836
|
-
function ownKeys$
|
|
837
|
-
function _objectSpread$
|
|
3226
|
+
function ownKeys$q(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3227
|
+
function _objectSpread$q(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$q(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$q(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
838
3228
|
var processSortProperties = function processSortProperties(sortProperties) {
|
|
839
3229
|
if (sortProperties.sortBy === "payment_amount") {
|
|
840
3230
|
return assoc("sortBy", "neeto_payments_engine_stripe_transactions.amount", sortProperties);
|
|
@@ -849,7 +3239,7 @@ var processSortProperties = function processSortProperties(sortProperties) {
|
|
|
849
3239
|
};
|
|
850
3240
|
var buildDefaultPageProperties = function buildDefaultPageProperties(tabs) {
|
|
851
3241
|
return tabs.reduce(function (pageProperties, tab) {
|
|
852
|
-
return _objectSpread$
|
|
3242
|
+
return _objectSpread$q(_objectSpread$q({}, pageProperties), {}, _defineProperty({}, tab, DEFAULT_PAGE_VALUES));
|
|
853
3243
|
}, {});
|
|
854
3244
|
};
|
|
855
3245
|
var buildPayload = function buildPayload(_ref) {
|
|
@@ -861,7 +3251,7 @@ var buildPayload = function buildPayload(_ref) {
|
|
|
861
3251
|
sortProperties = _ref$sortProperties === void 0 ? {} : _ref$sortProperties,
|
|
862
3252
|
_ref$payoutId = _ref.payoutId,
|
|
863
3253
|
payoutId = _ref$payoutId === void 0 ? null : _ref$payoutId;
|
|
864
|
-
return _objectSpread$
|
|
3254
|
+
return _objectSpread$q({
|
|
865
3255
|
tab: camelToSnakeCase(tab),
|
|
866
3256
|
payoutId: payoutId,
|
|
867
3257
|
page: (_pageProperties$tab = pageProperties[tab]) === null || _pageProperties$tab === void 0 ? void 0 : _pageProperties$tab.page,
|
|
@@ -877,7 +3267,7 @@ var buildRowData$1 = function buildRowData(_ref2) {
|
|
|
877
3267
|
tab = _ref2$tab === void 0 ? "all" : _ref2$tab;
|
|
878
3268
|
return data.map(function (element, index) {
|
|
879
3269
|
var _pageProperties$tab3, _pageProperties$tab4;
|
|
880
|
-
return _objectSpread$
|
|
3270
|
+
return _objectSpread$q(_objectSpread$q({}, element), {}, {
|
|
881
3271
|
payable: element.payable,
|
|
882
3272
|
identifier: element,
|
|
883
3273
|
id: isEmpty(pageProperties) ? index + 1 : ((_pageProperties$tab3 = pageProperties[tab]) === null || _pageProperties$tab3 === void 0 ? void 0 : _pageProperties$tab3.pageSize) * (((_pageProperties$tab4 = pageProperties[tab]) === null || _pageProperties$tab4 === void 0 ? void 0 : _pageProperties$tab4.page) - 1) + index + 1
|
|
@@ -1029,8 +3419,8 @@ var COLUMNS$5 = [{
|
|
|
1029
3419
|
sorter: true
|
|
1030
3420
|
}];
|
|
1031
3421
|
|
|
1032
|
-
function ownKeys$
|
|
1033
|
-
function _objectSpread$
|
|
3422
|
+
function ownKeys$p(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3423
|
+
function _objectSpread$p(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$p(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$p(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1034
3424
|
var useFiltersAndPagination$3 = function useFiltersAndPagination() {
|
|
1035
3425
|
var history = useHistory();
|
|
1036
3426
|
var _useState = useState(false),
|
|
@@ -1055,7 +3445,7 @@ var useFiltersAndPagination$3 = function useFiltersAndPagination() {
|
|
|
1055
3445
|
var _getQueryParams = getQueryParams(),
|
|
1056
3446
|
_getQueryParams$searc = _getQueryParams.searchTerm,
|
|
1057
3447
|
searchTerm = _getQueryParams$searc === void 0 ? "" : _getQueryParams$searc;
|
|
1058
|
-
var searchKeywordProps = _objectSpread$
|
|
3448
|
+
var searchKeywordProps = _objectSpread$p(_objectSpread$p({}, SEARCH_PROPS$1), {}, {
|
|
1059
3449
|
key: "search_term",
|
|
1060
3450
|
value: searchTerm.trim()
|
|
1061
3451
|
});
|
|
@@ -1134,12 +3524,17 @@ var QUERY_KEYS = {
|
|
|
1134
3524
|
V2_PAYMENTS: "v2-payments"
|
|
1135
3525
|
};
|
|
1136
3526
|
|
|
3527
|
+
function ownKeys$o(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3528
|
+
function _objectSpread$o(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$o(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$o(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1137
3529
|
var useFetchConnectedAccounts = function useFetchConnectedAccounts() {
|
|
1138
3530
|
var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1139
3531
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1140
|
-
return useQuery(
|
|
1141
|
-
|
|
1142
|
-
|
|
3532
|
+
return useQuery(_objectSpread$o({
|
|
3533
|
+
queryKey: [QUERY_KEYS.STRIPE_ACCOUNTS_LIST, payload],
|
|
3534
|
+
queryFn: function queryFn() {
|
|
3535
|
+
return accountsApi$4.list(payload);
|
|
3536
|
+
}
|
|
3537
|
+
}, options));
|
|
1143
3538
|
};
|
|
1144
3539
|
|
|
1145
3540
|
var List$6 = function List(_ref) {
|
|
@@ -1442,8 +3837,8 @@ var exportsApi = {
|
|
|
1442
3837
|
};
|
|
1443
3838
|
|
|
1444
3839
|
var useExportRazorpayData = function useExportRazorpayData() {
|
|
1445
|
-
return useMutation(
|
|
1446
|
-
|
|
3840
|
+
return useMutation({
|
|
3841
|
+
mutationFn: exportsApi.exportData
|
|
1447
3842
|
});
|
|
1448
3843
|
};
|
|
1449
3844
|
|
|
@@ -1989,8 +4384,8 @@ var modifySearchProps = function modifySearchProps(_ref5) {
|
|
|
1989
4384
|
}, searchProps);
|
|
1990
4385
|
};
|
|
1991
4386
|
|
|
1992
|
-
function ownKeys$
|
|
1993
|
-
function _objectSpread$
|
|
4387
|
+
function ownKeys$n(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4388
|
+
function _objectSpread$n(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$n(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$n(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1994
4389
|
var ExportModal$1 = function ExportModal(_ref) {
|
|
1995
4390
|
var showExportModal = _ref.showExportModal,
|
|
1996
4391
|
setShowExportModal = _ref.setShowExportModal,
|
|
@@ -2026,7 +4421,7 @@ var ExportModal$1 = function ExportModal(_ref) {
|
|
|
2026
4421
|
setIsGenerating(false);
|
|
2027
4422
|
};
|
|
2028
4423
|
var handleGenerateClick = function handleGenerateClick() {
|
|
2029
|
-
var payload = _objectSpread$
|
|
4424
|
+
var payload = _objectSpread$n({
|
|
2030
4425
|
kind: isTransferKind(kind) ? "connected" : kind,
|
|
2031
4426
|
token: token,
|
|
2032
4427
|
filters: filters,
|
|
@@ -2102,8 +4497,8 @@ var ExportModal$1 = function ExportModal(_ref) {
|
|
|
2102
4497
|
});
|
|
2103
4498
|
};
|
|
2104
4499
|
|
|
2105
|
-
function ownKeys$
|
|
2106
|
-
function _objectSpread$
|
|
4500
|
+
function ownKeys$m(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4501
|
+
function _objectSpread$m(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$m(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$m(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2107
4502
|
var useFiltersAndPagination$2 = function useFiltersAndPagination(_ref) {
|
|
2108
4503
|
var payableEntityColumns = _ref.payableEntityColumns,
|
|
2109
4504
|
kind = _ref.kind,
|
|
@@ -2136,7 +4531,7 @@ var useFiltersAndPagination$2 = function useFiltersAndPagination(_ref) {
|
|
|
2136
4531
|
var _getQueryParams = getQueryParams(),
|
|
2137
4532
|
_getQueryParams$searc = _getQueryParams.searchTerm,
|
|
2138
4533
|
searchTerm = _getQueryParams$searc === void 0 ? "" : _getQueryParams$searc;
|
|
2139
|
-
var searchKeywordProps = _objectSpread$
|
|
4534
|
+
var searchKeywordProps = _objectSpread$m(_objectSpread$m({}, modifySearchProps({
|
|
2140
4535
|
searchProps: searchProps,
|
|
2141
4536
|
kind: kind
|
|
2142
4537
|
})), {}, {
|
|
@@ -4313,49 +6708,66 @@ var transactionsApi$1 = {
|
|
|
4313
6708
|
list: list$8
|
|
4314
6709
|
};
|
|
4315
6710
|
|
|
4316
|
-
function ownKeys$
|
|
4317
|
-
function _objectSpread$
|
|
6711
|
+
function ownKeys$l(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6712
|
+
function _objectSpread$l(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$l(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$l(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4318
6713
|
var useFetchConnectedStripeAccount = function useFetchConnectedStripeAccount(holdableId) {
|
|
4319
6714
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4320
|
-
return useQuery(
|
|
4321
|
-
|
|
4322
|
-
|
|
6715
|
+
return useQuery(_objectSpread$l({
|
|
6716
|
+
queryKey: [QUERY_KEYS.CONNECTED_ACCOUNT, holdableId],
|
|
6717
|
+
queryFn: function queryFn() {
|
|
6718
|
+
return accountsApi$3.show(holdableId);
|
|
6719
|
+
}
|
|
6720
|
+
}, options));
|
|
4323
6721
|
};
|
|
4324
6722
|
var useFetchStripeTransactions = function useFetchStripeTransactions() {
|
|
4325
6723
|
var holdableId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
4326
6724
|
var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4327
6725
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
4328
|
-
return useQuery(
|
|
4329
|
-
|
|
4330
|
-
|
|
6726
|
+
return useQuery(_objectSpread$l({
|
|
6727
|
+
queryKey: [QUERY_KEYS.TRANSACTIONS_LIST, payload],
|
|
6728
|
+
queryFn: function queryFn() {
|
|
6729
|
+
if (isPresent(holdableId)) {
|
|
6730
|
+
return transactionsApi$1.list(holdableId, payload);
|
|
6731
|
+
}
|
|
6732
|
+
return transactionsApi$1.defaultList(payload);
|
|
4331
6733
|
}
|
|
4332
|
-
|
|
4333
|
-
}, options);
|
|
6734
|
+
}, options));
|
|
4334
6735
|
};
|
|
4335
6736
|
var useFetchStripePayouts = function useFetchStripePayouts(payload) {
|
|
4336
6737
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4337
|
-
return useQuery(
|
|
4338
|
-
|
|
4339
|
-
|
|
6738
|
+
return useQuery(_objectSpread$l({
|
|
6739
|
+
queryKey: [QUERY_KEYS.STRIPE_PAYOUTS_LIST, payload],
|
|
6740
|
+
queryFn: function queryFn() {
|
|
6741
|
+
return payoutsApi$1.list(payload);
|
|
6742
|
+
}
|
|
6743
|
+
}, options));
|
|
4340
6744
|
};
|
|
4341
6745
|
var useShowStripePayout = function useShowStripePayout(id) {
|
|
4342
6746
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4343
|
-
return useQuery(
|
|
4344
|
-
|
|
4345
|
-
|
|
6747
|
+
return useQuery(_objectSpread$l({
|
|
6748
|
+
queryKey: [QUERY_KEYS.STRIPE_PAYOUT, id],
|
|
6749
|
+
queryFn: function queryFn() {
|
|
6750
|
+
return payoutsApi$1.show(id);
|
|
6751
|
+
}
|
|
6752
|
+
}, options));
|
|
4346
6753
|
};
|
|
4347
6754
|
var usePollingStripeAccount = function usePollingStripeAccount(holdableId, _ref) {
|
|
4348
6755
|
var refetchInterval = _ref.refetchInterval;
|
|
4349
|
-
return useQuery(
|
|
4350
|
-
|
|
4351
|
-
|
|
6756
|
+
return useQuery({
|
|
6757
|
+
queryKey: [QUERY_KEYS.STRIPE_ACCOUNT_DETAILS],
|
|
6758
|
+
queryFn: function queryFn() {
|
|
6759
|
+
return accountsApi$3.show(holdableId);
|
|
6760
|
+
},
|
|
4352
6761
|
refetchInterval: refetchInterval
|
|
4353
6762
|
});
|
|
4354
6763
|
};
|
|
4355
6764
|
var usePollingStripeAccountCreationStatus = function usePollingStripeAccountCreationStatus(jobId, options) {
|
|
4356
|
-
return useQuery(
|
|
4357
|
-
|
|
4358
|
-
|
|
6765
|
+
return useQuery(_objectSpread$l({
|
|
6766
|
+
queryKey: [QUERY_KEYS.STRIPE_ACCOUNT_DETAILS, jobId],
|
|
6767
|
+
queryFn: function queryFn() {
|
|
6768
|
+
return accountsApi$3.creationStatus(jobId);
|
|
6769
|
+
}
|
|
6770
|
+
}, options));
|
|
4359
6771
|
};
|
|
4360
6772
|
var useDestroyStripeAccount = function useDestroyStripeAccount(_ref2) {
|
|
4361
6773
|
var onSuccess = _ref2.onSuccess,
|
|
@@ -4439,45 +6851,66 @@ var transactionsApi = {
|
|
|
4439
6851
|
show: show$2
|
|
4440
6852
|
};
|
|
4441
6853
|
|
|
6854
|
+
function ownKeys$k(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6855
|
+
function _objectSpread$k(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$k(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$k(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4442
6856
|
var useFetchStripePlatformAccount = function useFetchStripePlatformAccount(options) {
|
|
4443
|
-
return useQuery(
|
|
4444
|
-
|
|
4445
|
-
|
|
6857
|
+
return useQuery(_objectSpread$k({
|
|
6858
|
+
queryKey: [QUERY_KEYS.STRIPE_PLATFORM_ACCOUNT_DETAILS],
|
|
6859
|
+
queryFn: accountsApi$2.show
|
|
6860
|
+
}, options));
|
|
4446
6861
|
};
|
|
4447
6862
|
var useFetchStripePlatformSplits = function useFetchStripePlatformSplits(payload) {
|
|
4448
6863
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4449
|
-
return useQuery(
|
|
4450
|
-
|
|
4451
|
-
|
|
6864
|
+
return useQuery(_objectSpread$k({
|
|
6865
|
+
queryKey: [QUERY_KEYS.SPLITS_LIST, payload],
|
|
6866
|
+
queryFn: function queryFn() {
|
|
6867
|
+
return splitsApi.list(payload);
|
|
6868
|
+
}
|
|
6869
|
+
}, options));
|
|
4452
6870
|
};
|
|
4453
6871
|
var useFetchStripePlatformTransactions = function useFetchStripePlatformTransactions(payload, options) {
|
|
4454
|
-
return useQuery(
|
|
4455
|
-
|
|
4456
|
-
|
|
6872
|
+
return useQuery(_objectSpread$k({
|
|
6873
|
+
queryKey: [QUERY_KEYS.TRANSACTIONS_LIST, payload],
|
|
6874
|
+
queryFn: function queryFn() {
|
|
6875
|
+
return transactionsApi.list(payload);
|
|
6876
|
+
}
|
|
6877
|
+
}, options));
|
|
4457
6878
|
};
|
|
4458
6879
|
var useFetchStripePlatformTransaction = function useFetchStripePlatformTransaction(id) {
|
|
4459
6880
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4460
|
-
return useQuery(
|
|
4461
|
-
|
|
4462
|
-
|
|
6881
|
+
return useQuery(_objectSpread$k({
|
|
6882
|
+
queryKey: [QUERY_KEYS.STRIPE_PLATFORM_TRANSACTION, id],
|
|
6883
|
+
queryFn: function queryFn() {
|
|
6884
|
+
return transactionsApi.show(id);
|
|
6885
|
+
}
|
|
6886
|
+
}, options));
|
|
4463
6887
|
};
|
|
4464
6888
|
var useFetchStripeRefunds = function useFetchStripeRefunds(payload) {
|
|
4465
6889
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4466
|
-
return useQuery(
|
|
4467
|
-
|
|
4468
|
-
|
|
6890
|
+
return useQuery(_objectSpread$k({
|
|
6891
|
+
queryKey: [QUERY_KEYS.STRIPE_REFUNDS_LIST, payload],
|
|
6892
|
+
queryFn: function queryFn() {
|
|
6893
|
+
return refundsApi.list(payload);
|
|
6894
|
+
}
|
|
6895
|
+
}, options));
|
|
4469
6896
|
};
|
|
4470
6897
|
var useFetchStripePlatformPayouts = function useFetchStripePlatformPayouts(payload) {
|
|
4471
6898
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4472
|
-
return useQuery(
|
|
4473
|
-
|
|
4474
|
-
|
|
6899
|
+
return useQuery(_objectSpread$k({
|
|
6900
|
+
queryKey: [QUERY_KEYS.STRIPE_PAYOUTS_LIST, payload],
|
|
6901
|
+
queryFn: function queryFn() {
|
|
6902
|
+
return payoutsApi.list(payload);
|
|
6903
|
+
}
|
|
6904
|
+
}, options));
|
|
4475
6905
|
};
|
|
4476
6906
|
var useShowStripePlatformPayout = function useShowStripePlatformPayout(id) {
|
|
4477
6907
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4478
|
-
return useQuery(
|
|
4479
|
-
|
|
4480
|
-
|
|
6908
|
+
return useQuery(_objectSpread$k({
|
|
6909
|
+
queryKey: [QUERY_KEYS.STRIPE_PAYOUT, id],
|
|
6910
|
+
queryFn: function queryFn() {
|
|
6911
|
+
return payoutsApi.show(id);
|
|
6912
|
+
}
|
|
6913
|
+
}, options));
|
|
4481
6914
|
};
|
|
4482
6915
|
|
|
4483
6916
|
var SPLIT_COLUMNS = [{
|
|
@@ -4584,8 +7017,8 @@ var ExpandedRow = function ExpandedRow() {
|
|
|
4584
7017
|
});
|
|
4585
7018
|
};
|
|
4586
7019
|
|
|
4587
|
-
function ownKeys$
|
|
4588
|
-
function _objectSpread$
|
|
7020
|
+
function ownKeys$j(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7021
|
+
function _objectSpread$j(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$j(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$j(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4589
7022
|
var useFetchData$2 = function useFetchData(_ref) {
|
|
4590
7023
|
var _data$kind, _data$kind2, _data$kind3, _data$kind4;
|
|
4591
7024
|
var kind = _ref.kind,
|
|
@@ -4593,7 +7026,7 @@ var useFetchData$2 = function useFetchData(_ref) {
|
|
|
4593
7026
|
payload = _ref.payload,
|
|
4594
7027
|
isPlatformEnabled = _ref.isPlatformEnabled;
|
|
4595
7028
|
var data = {};
|
|
4596
|
-
data.transfer = data.connected = useFetchStripeTransactions(holdableId, _objectSpread$
|
|
7029
|
+
data.transfer = data.connected = useFetchStripeTransactions(holdableId, _objectSpread$j(_objectSpread$j({}, payload), {}, {
|
|
4597
7030
|
kind: kind
|
|
4598
7031
|
}), {
|
|
4599
7032
|
enabled: isTransferKind(kind) || isConnectedKind(kind)
|
|
@@ -4663,8 +7096,8 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
4663
7096
|
}
|
|
4664
7097
|
|
|
4665
7098
|
var _excluded$2 = ["transactionId"];
|
|
4666
|
-
function ownKeys$
|
|
4667
|
-
function _objectSpread$
|
|
7099
|
+
function ownKeys$i(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7100
|
+
function _objectSpread$i(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$i(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$i(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4668
7101
|
var Details = function Details(_ref) {
|
|
4669
7102
|
var transactionId = _ref.transactionId,
|
|
4670
7103
|
paneProps = _objectWithoutProperties(_ref, _excluded$2);
|
|
@@ -4682,7 +7115,7 @@ var Details = function Details(_ref) {
|
|
|
4682
7115
|
live = _useFetchStripePlatfo3.live,
|
|
4683
7116
|
_useFetchStripePlatfo4 = _useFetchStripePlatfo3.splits,
|
|
4684
7117
|
splits = _useFetchStripePlatfo4 === void 0 ? [] : _useFetchStripePlatfo4;
|
|
4685
|
-
return /*#__PURE__*/jsxs(Pane, _objectSpread$
|
|
7118
|
+
return /*#__PURE__*/jsxs(Pane, _objectSpread$i(_objectSpread$i({}, paneProps), {}, {
|
|
4686
7119
|
size: "large",
|
|
4687
7120
|
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
4688
7121
|
children: /*#__PURE__*/jsx(Typography, {
|
|
@@ -4756,8 +7189,8 @@ var Details = function Details(_ref) {
|
|
|
4756
7189
|
}));
|
|
4757
7190
|
};
|
|
4758
7191
|
|
|
4759
|
-
function ownKeys$
|
|
4760
|
-
function _objectSpread$
|
|
7192
|
+
function ownKeys$h(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7193
|
+
function _objectSpread$h(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$h(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$h(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4761
7194
|
var List$5 = function List(_ref) {
|
|
4762
7195
|
var _pageProperties$tab, _pageProperties$tab2, _pageProperties$tab3;
|
|
4763
7196
|
var _ref$isPlatformEnable = _ref.isPlatformEnabled,
|
|
@@ -4895,7 +7328,7 @@ var List$5 = function List(_ref) {
|
|
|
4895
7328
|
hideColumn(processDataIndex(column.dataIndex));
|
|
4896
7329
|
}
|
|
4897
7330
|
})
|
|
4898
|
-
}), /*#__PURE__*/jsx(Details, _objectSpread$
|
|
7331
|
+
}), /*#__PURE__*/jsx(Details, _objectSpread$h(_objectSpread$h({}, paneStatus), {}, {
|
|
4899
7332
|
onClose: function onClose() {
|
|
4900
7333
|
return setPaneStatus(INITIAL_PANE_STATUS);
|
|
4901
7334
|
}
|
|
@@ -4903,8 +7336,8 @@ var List$5 = function List(_ref) {
|
|
|
4903
7336
|
});
|
|
4904
7337
|
};
|
|
4905
7338
|
|
|
4906
|
-
function ownKeys$
|
|
4907
|
-
function _objectSpread$
|
|
7339
|
+
function ownKeys$g(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7340
|
+
function _objectSpread$g(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$g(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$g(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4908
7341
|
var Dashboard = function Dashboard(_ref) {
|
|
4909
7342
|
var _ref$isPlatformEnable = _ref.isPlatformEnabled,
|
|
4910
7343
|
isPlatformEnabled = _ref$isPlatformEnable === void 0 ? false : _ref$isPlatformEnable,
|
|
@@ -4963,7 +7396,7 @@ var Dashboard = function Dashboard(_ref) {
|
|
|
4963
7396
|
});
|
|
4964
7397
|
};
|
|
4965
7398
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
4966
|
-
children: [/*#__PURE__*/jsx(Header, _objectSpread$
|
|
7399
|
+
children: [/*#__PURE__*/jsx(Header, _objectSpread$g(_objectSpread$g({}, headerProps), {}, {
|
|
4967
7400
|
title: t("neetoPayments.title.".concat(titleKind)),
|
|
4968
7401
|
searchProps: isFilterButtonVisible && {
|
|
4969
7402
|
placeholder: searchKeywordProps.placeholder,
|
|
@@ -5080,8 +7513,8 @@ var DEFAULT_SORT_PROPERTIES = {
|
|
|
5080
7513
|
};
|
|
5081
7514
|
var STRIPE_PAYOUTS_TABLE_HIDDEN_COLUMNS_STORAGE_KEY = "stripePayoutsDashboard";
|
|
5082
7515
|
|
|
5083
|
-
function ownKeys$
|
|
5084
|
-
function _objectSpread$
|
|
7516
|
+
function ownKeys$f(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7517
|
+
function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$f(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$f(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5085
7518
|
var ExportModal = function ExportModal(_ref) {
|
|
5086
7519
|
var showExportModal = _ref.showExportModal,
|
|
5087
7520
|
setShowExportModal = _ref.setShowExportModal,
|
|
@@ -5112,7 +7545,7 @@ var ExportModal = function ExportModal(_ref) {
|
|
|
5112
7545
|
setIsGenerating(false);
|
|
5113
7546
|
};
|
|
5114
7547
|
var handleGenerateClick = function handleGenerateClick() {
|
|
5115
|
-
var payload = _objectSpread$
|
|
7548
|
+
var payload = _objectSpread$f({
|
|
5116
7549
|
kind: "payout",
|
|
5117
7550
|
token: token,
|
|
5118
7551
|
filters: filters,
|
|
@@ -5248,8 +7681,8 @@ var renderPayoutIdentifier$1 = curry(function (route, _ref) {
|
|
|
5248
7681
|
});
|
|
5249
7682
|
});
|
|
5250
7683
|
|
|
5251
|
-
function ownKeys$
|
|
5252
|
-
function _objectSpread$
|
|
7684
|
+
function ownKeys$e(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7685
|
+
function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$e(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$e(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5253
7686
|
var useFiltersAndPagination$1 = function useFiltersAndPagination(payoutsPageRoute) {
|
|
5254
7687
|
var history = useHistory();
|
|
5255
7688
|
var _useState = useState(false),
|
|
@@ -5274,7 +7707,7 @@ var useFiltersAndPagination$1 = function useFiltersAndPagination(payoutsPageRout
|
|
|
5274
7707
|
var _getQueryParams = getQueryParams(),
|
|
5275
7708
|
_getQueryParams$searc = _getQueryParams.searchTerm,
|
|
5276
7709
|
searchTerm = _getQueryParams$searc === void 0 ? "" : _getQueryParams$searc;
|
|
5277
|
-
var searchKeywordProps = _objectSpread$
|
|
7710
|
+
var searchKeywordProps = _objectSpread$e(_objectSpread$e({}, SEARCH_PROPS), {}, {
|
|
5278
7711
|
key: "search_term",
|
|
5279
7712
|
value: searchTerm.trim()
|
|
5280
7713
|
});
|
|
@@ -5590,8 +8023,8 @@ var renderPayoutIdentifier = function renderPayoutIdentifier() {
|
|
|
5590
8023
|
};
|
|
5591
8024
|
|
|
5592
8025
|
var _excluded$1 = ["isPlatformEnabled", "indexRoute"];
|
|
5593
|
-
function ownKeys$
|
|
5594
|
-
function _objectSpread$
|
|
8026
|
+
function ownKeys$d(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8027
|
+
function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5595
8028
|
var PayoutsPage = function PayoutsPage(_ref) {
|
|
5596
8029
|
var isPlatformEnabled = _ref.isPlatformEnabled,
|
|
5597
8030
|
indexRoute = _ref.indexRoute,
|
|
@@ -5709,7 +8142,7 @@ var PayoutsPage = function PayoutsPage(_ref) {
|
|
|
5709
8142
|
})]
|
|
5710
8143
|
})]
|
|
5711
8144
|
})
|
|
5712
|
-
}), isAutomatic && /*#__PURE__*/jsx(Dashboard$1, _objectSpread$
|
|
8145
|
+
}), isAutomatic && /*#__PURE__*/jsx(Dashboard$1, _objectSpread$d(_objectSpread$d(_objectSpread$d({}, isPlatformEnabled), {}, {
|
|
5713
8146
|
kind: "connected"
|
|
5714
8147
|
}, otherProps), {}, {
|
|
5715
8148
|
headerProps: {
|
|
@@ -5813,11 +8246,11 @@ var buildPaymentColumns$2 = function buildPaymentColumns(_ref) {
|
|
|
5813
8246
|
}));
|
|
5814
8247
|
};
|
|
5815
8248
|
|
|
5816
|
-
function ownKeys$
|
|
5817
|
-
function _objectSpread$
|
|
8249
|
+
function ownKeys$c(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8250
|
+
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5818
8251
|
var FilterWrapper = function FilterWrapper(_ref) {
|
|
5819
8252
|
var _ref$setShowExportMod = _ref.setShowExportModal,
|
|
5820
|
-
setShowExportModal = _ref$setShowExportMod === void 0 ? noop : _ref$setShowExportMod,
|
|
8253
|
+
setShowExportModal = _ref$setShowExportMod === void 0 ? noop$2 : _ref$setShowExportMod,
|
|
5821
8254
|
searchProps = _ref.searchProps,
|
|
5822
8255
|
_ref$headerProps = _ref.headerProps,
|
|
5823
8256
|
headerProps = _ref$headerProps === void 0 ? {} : _ref$headerProps,
|
|
@@ -5842,9 +8275,9 @@ var FilterWrapper = function FilterWrapper(_ref) {
|
|
|
5842
8275
|
var _useTranslation = useTranslation(),
|
|
5843
8276
|
t = _useTranslation.t;
|
|
5844
8277
|
var isTabsVisible = isFilterButtonVisible || tab !== "all";
|
|
5845
|
-
var searchKeywordProps = _objectSpread$
|
|
8278
|
+
var searchKeywordProps = _objectSpread$c(_objectSpread$c({}, searchProps), {}, {
|
|
5846
8279
|
value: searchTerm.trim(),
|
|
5847
|
-
setValue: noop
|
|
8280
|
+
setValue: noop$2
|
|
5848
8281
|
});
|
|
5849
8282
|
var handleFiltersChange = function handleFiltersChange(filters) {
|
|
5850
8283
|
startTransition(function () {
|
|
@@ -5857,7 +8290,7 @@ var FilterWrapper = function FilterWrapper(_ref) {
|
|
|
5857
8290
|
payableEntityColumns: payableEntityColumns
|
|
5858
8291
|
});
|
|
5859
8292
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
5860
|
-
children: [/*#__PURE__*/jsx(Header, _objectSpread$
|
|
8293
|
+
children: [/*#__PURE__*/jsx(Header, _objectSpread$c(_objectSpread$c({}, _objectSpread$c(_objectSpread$c({}, headerProps), {}, {
|
|
5861
8294
|
title: title
|
|
5862
8295
|
})), {}, {
|
|
5863
8296
|
searchProps: isFilterButtonVisible && {
|
|
@@ -6144,12 +8577,17 @@ var accountsApi$1 = {
|
|
|
6144
8577
|
show: show$1
|
|
6145
8578
|
};
|
|
6146
8579
|
|
|
8580
|
+
function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8581
|
+
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6147
8582
|
var useFetchRazorpayAccount = function useFetchRazorpayAccount(holdableId) {
|
|
6148
8583
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6149
|
-
return useQuery(
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
8584
|
+
return useQuery(_objectSpread$b({
|
|
8585
|
+
queryKey: [QUERY_KEYS.SQUARE_ACCOUNT_DETAILS, holdableId],
|
|
8586
|
+
queryFn: function queryFn() {
|
|
8587
|
+
if (isPresent(holdableId)) return accountsApi$1.show(holdableId);
|
|
8588
|
+
return accountsApi$1.defaultShow();
|
|
8589
|
+
}
|
|
8590
|
+
}, options));
|
|
6153
8591
|
};
|
|
6154
8592
|
|
|
6155
8593
|
var create$2 = function create(payload) {
|
|
@@ -6173,17 +8611,24 @@ var paymentsApi$3 = {
|
|
|
6173
8611
|
create: create$2
|
|
6174
8612
|
};
|
|
6175
8613
|
|
|
8614
|
+
function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8615
|
+
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6176
8616
|
var useFetchRazorpayPayments = function useFetchRazorpayPayments() {
|
|
6177
8617
|
var holdableId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
6178
8618
|
var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6179
8619
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
6180
|
-
return useQuery(
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
8620
|
+
return useQuery(_objectSpread$a({
|
|
8621
|
+
queryKey: [QUERY_KEYS.SQUARE_PAYMENTS_LIST, payload],
|
|
8622
|
+
queryFn: function queryFn() {
|
|
8623
|
+
if (isPresent(holdableId)) return paymentsApi$3.list(holdableId, payload);
|
|
8624
|
+
return paymentsApi$3.defaultList(payload);
|
|
8625
|
+
}
|
|
8626
|
+
}, options));
|
|
6184
8627
|
};
|
|
6185
8628
|
var useCreateRazorpayPayment = function useCreateRazorpayPayment(options) {
|
|
6186
|
-
return useMutation(
|
|
8629
|
+
return useMutation(_objectSpread$a({
|
|
8630
|
+
mutationFn: paymentsApi$3.create
|
|
8631
|
+
}, options));
|
|
6187
8632
|
};
|
|
6188
8633
|
|
|
6189
8634
|
var List$3 = function List(_ref) {
|
|
@@ -6303,8 +8748,8 @@ var List$3 = function List(_ref) {
|
|
|
6303
8748
|
});
|
|
6304
8749
|
};
|
|
6305
8750
|
|
|
6306
|
-
function ownKeys$
|
|
6307
|
-
function _objectSpread$
|
|
8751
|
+
function ownKeys$9(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8752
|
+
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6308
8753
|
var RazorpayDashboard = function RazorpayDashboard(_ref) {
|
|
6309
8754
|
var searchProps = _ref.searchProps,
|
|
6310
8755
|
_ref$headerProps = _ref.headerProps,
|
|
@@ -6335,9 +8780,9 @@ var RazorpayDashboard = function RazorpayDashboard(_ref) {
|
|
|
6335
8780
|
setSortProperties = filterPaginationState.setSortProperties,
|
|
6336
8781
|
tab = filterPaginationState.tab,
|
|
6337
8782
|
setDataSize = filterPaginationState.setDataSize;
|
|
6338
|
-
return /*#__PURE__*/jsxs(FilterWrapper, _objectSpread$
|
|
8783
|
+
return /*#__PURE__*/jsxs(FilterWrapper, _objectSpread$9(_objectSpread$9({
|
|
6339
8784
|
title: t("neetoPayments.common.razorpayPayments")
|
|
6340
|
-
}, _objectSpread$
|
|
8785
|
+
}, _objectSpread$9({
|
|
6341
8786
|
headerProps: headerProps,
|
|
6342
8787
|
kind: kind,
|
|
6343
8788
|
payableEntityColumns: payableEntityColumns,
|
|
@@ -6771,11 +9216,11 @@ var RazorpayPaymentButton = function RazorpayPaymentButton(_ref) {
|
|
|
6771
9216
|
_ref$isCardPreservabl = _ref.isCardPreservable,
|
|
6772
9217
|
isCardPreservable = _ref$isCardPreservabl === void 0 ? false : _ref$isCardPreservabl,
|
|
6773
9218
|
_ref$onBeforePayment = _ref.onBeforePayment,
|
|
6774
|
-
onBeforePayment = _ref$onBeforePayment === void 0 ? noop : _ref$onBeforePayment,
|
|
9219
|
+
onBeforePayment = _ref$onBeforePayment === void 0 ? noop$2 : _ref$onBeforePayment,
|
|
6775
9220
|
_ref$onSuccessfulPaym = _ref.onSuccessfulPayment,
|
|
6776
|
-
onSuccessfulPayment = _ref$onSuccessfulPaym === void 0 ? noop : _ref$onSuccessfulPaym,
|
|
9221
|
+
onSuccessfulPayment = _ref$onSuccessfulPaym === void 0 ? noop$2 : _ref$onSuccessfulPaym,
|
|
6777
9222
|
_ref$onFailedPayment = _ref.onFailedPayment,
|
|
6778
|
-
onFailedPayment = _ref$onFailedPayment === void 0 ? noop : _ref$onFailedPayment;
|
|
9223
|
+
onFailedPayment = _ref$onFailedPayment === void 0 ? noop$2 : _ref$onFailedPayment;
|
|
6779
9224
|
var _useTranslation = useTranslation(),
|
|
6780
9225
|
t = _useTranslation.t;
|
|
6781
9226
|
var openRazorpayCheckout = /*#__PURE__*/function () {
|
|
@@ -6920,7 +9365,7 @@ var SquareCard = function SquareCard(_ref) {
|
|
|
6920
9365
|
_ref$id = _ref.id,
|
|
6921
9366
|
id = _ref$id === void 0 ? DEFAULT_CARD_CONTAINER_ID : _ref$id,
|
|
6922
9367
|
_ref$onChange = _ref.onChange,
|
|
6923
|
-
onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
|
|
9368
|
+
onChange = _ref$onChange === void 0 ? noop$2 : _ref$onChange,
|
|
6924
9369
|
_ref$options = _ref.options,
|
|
6925
9370
|
options = _ref$options === void 0 ? DEFAULT_SQUARE_CARD_OPTIONS : _ref$options,
|
|
6926
9371
|
_ref$disabled = _ref.disabled,
|
|
@@ -7040,30 +9485,41 @@ var refundsapi = {
|
|
|
7040
9485
|
list: list$1
|
|
7041
9486
|
};
|
|
7042
9487
|
|
|
9488
|
+
function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9489
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7043
9490
|
var useFetchSquareAccount = function useFetchSquareAccount(holdableId) {
|
|
7044
9491
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7045
|
-
return useQuery(
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
9492
|
+
return useQuery(_objectSpread$8({
|
|
9493
|
+
queryKey: [QUERY_KEYS.SQUARE_ACCOUNT_DETAILS, holdableId],
|
|
9494
|
+
queryFn: function queryFn() {
|
|
9495
|
+
if (isPresent(holdableId)) return accountsApi.show(holdableId);
|
|
9496
|
+
return accountsApi.defaultShow();
|
|
9497
|
+
}
|
|
9498
|
+
}, options));
|
|
7049
9499
|
};
|
|
7050
9500
|
var useFetchSquarePayments = function useFetchSquarePayments() {
|
|
7051
9501
|
var holdableId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
7052
9502
|
var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7053
9503
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
7054
|
-
return useQuery(
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
9504
|
+
return useQuery(_objectSpread$8({
|
|
9505
|
+
queryKey: [QUERY_KEYS.SQUARE_PAYMENTS_LIST, payload],
|
|
9506
|
+
queryFn: function queryFn() {
|
|
9507
|
+
if (isPresent(holdableId)) return paymentsApi$2.list(holdableId, payload);
|
|
9508
|
+
return paymentsApi$2.defaultList(payload);
|
|
9509
|
+
}
|
|
9510
|
+
}, options));
|
|
7058
9511
|
};
|
|
7059
9512
|
var useFetchSquareRefunds = function useFetchSquareRefunds() {
|
|
7060
9513
|
var holdableId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
7061
9514
|
var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7062
9515
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
7063
|
-
return useQuery(
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
9516
|
+
return useQuery(_objectSpread$8({
|
|
9517
|
+
queryKey: [QUERY_KEYS.SQUARE_REFUNDS_LIST, payload],
|
|
9518
|
+
queryFn: function queryFn() {
|
|
9519
|
+
if (isPresent(holdableId)) return refundsapi.list(holdableId, payload);
|
|
9520
|
+
return refundsapi.defaultList(payload);
|
|
9521
|
+
}
|
|
9522
|
+
}, options));
|
|
7067
9523
|
};
|
|
7068
9524
|
|
|
7069
9525
|
var useFetchSquareData = function useFetchSquareData(_ref) {
|
|
@@ -7191,8 +9647,8 @@ var List$2 = function List(_ref) {
|
|
|
7191
9647
|
});
|
|
7192
9648
|
};
|
|
7193
9649
|
|
|
7194
|
-
function ownKeys$
|
|
7195
|
-
function _objectSpread$
|
|
9650
|
+
function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9651
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7196
9652
|
var SquareDashboard = function SquareDashboard(_ref) {
|
|
7197
9653
|
var searchProps = _ref.searchProps,
|
|
7198
9654
|
_ref$headerProps = _ref.headerProps,
|
|
@@ -7219,9 +9675,9 @@ var SquareDashboard = function SquareDashboard(_ref) {
|
|
|
7219
9675
|
setSortProperties = filterPaginationState.setSortProperties,
|
|
7220
9676
|
tab = filterPaginationState.tab,
|
|
7221
9677
|
setDataSize = filterPaginationState.setDataSize;
|
|
7222
|
-
return /*#__PURE__*/jsx(FilterWrapper, _objectSpread$
|
|
9678
|
+
return /*#__PURE__*/jsx(FilterWrapper, _objectSpread$7(_objectSpread$7({
|
|
7223
9679
|
title: isPaymentKind(kind) ? t("neetoPayments.title.squarePayment") : t("neetoPayments.title.squareRefund")
|
|
7224
|
-
}, _objectSpread$
|
|
9680
|
+
}, _objectSpread$7({
|
|
7225
9681
|
headerProps: headerProps,
|
|
7226
9682
|
kind: kind,
|
|
7227
9683
|
searchProps: searchProps
|
|
@@ -7255,17 +9711,17 @@ var STRIPE_ALERT_PAYMENT_KIND_CONTENT = {
|
|
|
7255
9711
|
};
|
|
7256
9712
|
|
|
7257
9713
|
var _excluded = ["isOpen", "paymentKind", "onClose"];
|
|
7258
|
-
function ownKeys$
|
|
7259
|
-
function _objectSpread$
|
|
9714
|
+
function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9715
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7260
9716
|
var PaymentKindRestrictionAlert = function PaymentKindRestrictionAlert(_ref) {
|
|
7261
9717
|
var _ref$isOpen = _ref.isOpen,
|
|
7262
9718
|
isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
|
|
7263
9719
|
_ref$paymentKind = _ref.paymentKind,
|
|
7264
9720
|
paymentKind = _ref$paymentKind === void 0 ? "standard" : _ref$paymentKind,
|
|
7265
9721
|
_ref$onClose = _ref.onClose,
|
|
7266
|
-
onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
|
|
9722
|
+
onClose = _ref$onClose === void 0 ? noop$2 : _ref$onClose,
|
|
7267
9723
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
7268
|
-
return /*#__PURE__*/jsx(Alert, _objectSpread$
|
|
9724
|
+
return /*#__PURE__*/jsx(Alert, _objectSpread$6({
|
|
7269
9725
|
isOpen: isOpen,
|
|
7270
9726
|
onClose: onClose,
|
|
7271
9727
|
message: STRIPE_ALERT_PAYMENT_KIND_CONTENT[paymentKind].message,
|
|
@@ -7299,8 +9755,9 @@ var countriesApi = {
|
|
|
7299
9755
|
};
|
|
7300
9756
|
|
|
7301
9757
|
var useFetchStripeCountries = function useFetchStripeCountries() {
|
|
7302
|
-
return useQuery(
|
|
7303
|
-
|
|
9758
|
+
return useQuery({
|
|
9759
|
+
queryKey: [QUERY_KEYS.STRIPE_COUNTRIES],
|
|
9760
|
+
queryFn: countriesApi.fetchCountries
|
|
7304
9761
|
});
|
|
7305
9762
|
};
|
|
7306
9763
|
|
|
@@ -9292,8 +11749,8 @@ var Finish = withT(function (_ref) {
|
|
|
9292
11749
|
});
|
|
9293
11750
|
});
|
|
9294
11751
|
|
|
9295
|
-
function ownKeys$
|
|
9296
|
-
function _objectSpread$
|
|
11752
|
+
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11753
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9297
11754
|
var StripeConnect = function StripeConnect(_ref) {
|
|
9298
11755
|
var _ref$holdableId = _ref.holdableId,
|
|
9299
11756
|
holdableId = _ref$holdableId === void 0 ? null : _ref$holdableId,
|
|
@@ -9316,16 +11773,16 @@ var StripeConnect = function StripeConnect(_ref) {
|
|
|
9316
11773
|
configure = _INTEGRATION_STEPS[1],
|
|
9317
11774
|
finish = _INTEGRATION_STEPS[2],
|
|
9318
11775
|
demo = _INTEGRATION_STEPS[3];
|
|
9319
|
-
return [_objectSpread$
|
|
11776
|
+
return [_objectSpread$5(_objectSpread$5({}, connect), {}, {
|
|
9320
11777
|
isActive: activeTab === STEPS.connect,
|
|
9321
11778
|
isCompleted: isPresent(stripeAccount) || activeTab === STEPS.configure || isPlatform
|
|
9322
|
-
}), _objectSpread$
|
|
11779
|
+
}), _objectSpread$5(_objectSpread$5({}, configure), {}, {
|
|
9323
11780
|
isActive: activeTab === STEPS.configure,
|
|
9324
11781
|
isCompleted: !!(stripeAccount !== null && stripeAccount !== void 0 && stripeAccount.isConnected)
|
|
9325
|
-
}), _objectSpread$
|
|
11782
|
+
}), _objectSpread$5(_objectSpread$5({}, finish), {}, {
|
|
9326
11783
|
isActive: activeTab === STEPS.finish,
|
|
9327
11784
|
isCompleted: activeTab === STEPS.finish || activeTab === STEPS.demo
|
|
9328
|
-
}), _objectSpread$
|
|
11785
|
+
}), _objectSpread$5(_objectSpread$5({}, demo), {}, {
|
|
9329
11786
|
isActive: activeTab === STEPS.demo,
|
|
9330
11787
|
isCompleted: activeTab === STEPS.demo
|
|
9331
11788
|
})];
|
|
@@ -9482,9 +11939,9 @@ var UpiConnect = function UpiConnect(_ref) {
|
|
|
9482
11939
|
_ref$isDeleting = _ref.isDeleting,
|
|
9483
11940
|
isDeleting = _ref$isDeleting === void 0 ? false : _ref$isDeleting,
|
|
9484
11941
|
_ref$handleDeleteUpiI = _ref.handleDeleteUpiId,
|
|
9485
|
-
handleDeleteUpiId = _ref$handleDeleteUpiI === void 0 ? noop : _ref$handleDeleteUpiI,
|
|
11942
|
+
handleDeleteUpiId = _ref$handleDeleteUpiI === void 0 ? noop$2 : _ref$handleDeleteUpiI,
|
|
9486
11943
|
_ref$handleCreateUpiI = _ref.handleCreateUpiId,
|
|
9487
|
-
handleCreateUpiId = _ref$handleCreateUpiI === void 0 ? noop : _ref$handleCreateUpiI;
|
|
11944
|
+
handleCreateUpiId = _ref$handleCreateUpiI === void 0 ? noop$2 : _ref$handleCreateUpiI;
|
|
9488
11945
|
if (isLoading) return /*#__PURE__*/jsx(Spinner, {});
|
|
9489
11946
|
return /*#__PURE__*/jsxs("div", {
|
|
9490
11947
|
className: "flex w-full max-w-3xl flex-col items-start space-y-6",
|
|
@@ -9513,21 +11970,27 @@ var paymentsApi$1 = {
|
|
|
9513
11970
|
update: update
|
|
9514
11971
|
};
|
|
9515
11972
|
|
|
11973
|
+
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11974
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9516
11975
|
var useCreateUpiPayment = function useCreateUpiPayment(options) {
|
|
9517
|
-
return useMutation(
|
|
11976
|
+
return useMutation(_objectSpread$4({
|
|
11977
|
+
mutationFn: paymentsApi$1.create
|
|
11978
|
+
}, options));
|
|
9518
11979
|
};
|
|
9519
11980
|
var useUpdateUpiPayment = function useUpdateUpiPayment(id) {
|
|
9520
11981
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9521
|
-
return useMutation(
|
|
9522
|
-
|
|
9523
|
-
|
|
11982
|
+
return useMutation(_objectSpread$4({
|
|
11983
|
+
mutationFn: function mutationFn(payload) {
|
|
11984
|
+
return paymentsApi$1.update(id, payload);
|
|
11985
|
+
}
|
|
11986
|
+
}, options));
|
|
9524
11987
|
};
|
|
9525
11988
|
|
|
9526
11989
|
var UpiMarkAsPaidButton = function UpiMarkAsPaidButton(_ref) {
|
|
9527
11990
|
var paymentId = _ref.paymentId,
|
|
9528
11991
|
payableId = _ref.payableId,
|
|
9529
11992
|
_ref$onSuccess = _ref.onSuccess,
|
|
9530
|
-
onSuccess = _ref$onSuccess === void 0 ? noop : _ref$onSuccess;
|
|
11993
|
+
onSuccess = _ref$onSuccess === void 0 ? noop$2 : _ref$onSuccess;
|
|
9531
11994
|
var _useTranslation = useTranslation(),
|
|
9532
11995
|
t = _useTranslation.t;
|
|
9533
11996
|
var _useUpdateUpiPayment = useUpdateUpiPayment(paymentId, {
|
|
@@ -9556,15 +12019,15 @@ var vpaIdToQrCodeValue = function vpaIdToQrCodeValue(vpaId) {
|
|
|
9556
12019
|
return "upi://pay?pa=".concat(vpaId);
|
|
9557
12020
|
};
|
|
9558
12021
|
|
|
9559
|
-
function ownKeys$
|
|
9560
|
-
function _objectSpread$
|
|
12022
|
+
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12023
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9561
12024
|
var UpiPayment = function UpiPayment(_ref) {
|
|
9562
12025
|
var _ref$fee = _ref.fee,
|
|
9563
12026
|
fee = _ref$fee === void 0 ? {} : _ref$fee,
|
|
9564
12027
|
_ref$onSubmit = _ref.onSubmit,
|
|
9565
|
-
onSubmit = _ref$onSubmit === void 0 ? noop : _ref$onSubmit,
|
|
12028
|
+
onSubmit = _ref$onSubmit === void 0 ? noop$2 : _ref$onSubmit,
|
|
9566
12029
|
_ref$onBackClick = _ref.onBackClick,
|
|
9567
|
-
onBackClick = _ref$onBackClick === void 0 ? noop : _ref$onBackClick,
|
|
12030
|
+
onBackClick = _ref$onBackClick === void 0 ? noop$2 : _ref$onBackClick,
|
|
9568
12031
|
payableId = _ref.payableId;
|
|
9569
12032
|
var _useTranslation = useTranslation(),
|
|
9570
12033
|
t = _useTranslation.t;
|
|
@@ -9572,7 +12035,7 @@ var UpiPayment = function UpiPayment(_ref) {
|
|
|
9572
12035
|
var _useCreateUpiPayment = useCreateUpiPayment({}),
|
|
9573
12036
|
createPayment = _useCreateUpiPayment.mutate;
|
|
9574
12037
|
var handleSubmit = function handleSubmit(values) {
|
|
9575
|
-
var payload = _objectSpread$
|
|
12038
|
+
var payload = _objectSpread$3(_objectSpread$3({}, values), {}, {
|
|
9576
12039
|
payableId: payableId
|
|
9577
12040
|
});
|
|
9578
12041
|
createPayment(payload);
|
|
@@ -9690,12 +12153,17 @@ var paymentsApi = {
|
|
|
9690
12153
|
list: list
|
|
9691
12154
|
};
|
|
9692
12155
|
|
|
12156
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12157
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9693
12158
|
var useFetchV2Payments = function useFetchV2Payments() {
|
|
9694
12159
|
var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
9695
12160
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9696
|
-
return useQuery(
|
|
9697
|
-
|
|
9698
|
-
|
|
12161
|
+
return useQuery(_objectSpread$2({
|
|
12162
|
+
queryKey: [QUERY_KEYS.V2_PAYMENTS, payload],
|
|
12163
|
+
queryFn: function queryFn() {
|
|
12164
|
+
return paymentsApi.list(payload);
|
|
12165
|
+
}
|
|
12166
|
+
}, options));
|
|
9699
12167
|
};
|
|
9700
12168
|
|
|
9701
12169
|
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -9911,11 +12379,11 @@ var loadScript = function loadScript(src) {
|
|
|
9911
12379
|
var useRazorpayPayment = function useRazorpayPayment(_ref) {
|
|
9912
12380
|
var payableId = _ref.payableId,
|
|
9913
12381
|
_ref$onBeforePayment = _ref.onBeforePayment,
|
|
9914
|
-
onBeforePayment = _ref$onBeforePayment === void 0 ? noop : _ref$onBeforePayment,
|
|
12382
|
+
onBeforePayment = _ref$onBeforePayment === void 0 ? noop$2 : _ref$onBeforePayment,
|
|
9915
12383
|
_ref$onSuccessfulPaym = _ref.onSuccessfulPayment,
|
|
9916
|
-
onSuccessfulPayment = _ref$onSuccessfulPaym === void 0 ? noop : _ref$onSuccessfulPaym,
|
|
12384
|
+
onSuccessfulPayment = _ref$onSuccessfulPaym === void 0 ? noop$2 : _ref$onSuccessfulPaym,
|
|
9917
12385
|
_ref$onFailedPayment = _ref.onFailedPayment,
|
|
9918
|
-
onFailedPayment = _ref$onFailedPayment === void 0 ? noop : _ref$onFailedPayment;
|
|
12386
|
+
onFailedPayment = _ref$onFailedPayment === void 0 ? noop$2 : _ref$onFailedPayment;
|
|
9919
12387
|
var _useTranslation = useTranslation(),
|
|
9920
12388
|
t = _useTranslation.t;
|
|
9921
12389
|
var openRazorpayCheckout = /*#__PURE__*/function () {
|