@inventreedb/ui 0.8.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/.vite/manifest.json +44 -11
- package/dist/components/RowActions.js +4 -4
- package/dist/hooks/MonitorBackgroundTask.d.ts +20 -0
- package/dist/hooks/MonitorBackgroundTask.js +77 -0
- package/dist/hooks/MonitorBackgroundTask.js.map +1 -0
- package/dist/hooks/MonitorDataOutput.d.ts +6 -5
- package/dist/hooks/MonitorDataOutput.js +19 -25
- package/dist/hooks/MonitorDataOutput.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/environmentManager.js +22 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/environmentManager.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js +1 -2
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/notifyManager.js +2 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/notifyManager.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js +1 -2
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/query.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js +25 -18
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/retryer.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js +70 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/utils.js +3 -2
- package/dist/node_modules/@tanstack/query-core/build/modern/utils.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +3 -2
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +7 -5
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -1
- package/dist/types/Forms.d.ts +2 -0
- package/dist/types/Plugins.d.ts +11 -0
- package/dist/types/Plugins.js +3 -3
- package/dist/types/Plugins.js.map +1 -1
- package/lib/hooks/MonitorBackgroundTask.tsx +118 -0
- package/lib/hooks/MonitorDataOutput.tsx +25 -29
- package/lib/index.ts +8 -1
- package/lib/types/Forms.tsx +2 -0
- package/lib/types/Plugins.tsx +10 -0
- package/package.json +31 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryer.js","sources":["../../../../../../node_modules/@tanstack/query-core/build/modern/retryer.js"],"sourcesContent":["// src/retryer.ts\nimport { focusManager } from \"./focusManager.js\";\nimport { onlineManager } from \"./onlineManager.js\";\nimport { pendingThenable } from \"./thenable.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"retryer.js","sources":["../../../../../../node_modules/@tanstack/query-core/build/modern/retryer.js"],"sourcesContent":["// src/retryer.ts\nimport { focusManager } from \"./focusManager.js\";\nimport { onlineManager } from \"./onlineManager.js\";\nimport { pendingThenable } from \"./thenable.js\";\nimport { environmentManager } from \"./environmentManager.js\";\nimport { sleep } from \"./utils.js\";\nfunction defaultRetryDelay(failureCount) {\n return Math.min(1e3 * 2 ** failureCount, 3e4);\n}\nfunction canFetch(networkMode) {\n return (networkMode ?? \"online\") === \"online\" ? onlineManager.isOnline() : true;\n}\nvar CancelledError = class extends Error {\n constructor(options) {\n super(\"CancelledError\");\n this.revert = options?.revert;\n this.silent = options?.silent;\n }\n};\nfunction isCancelledError(value) {\n return value instanceof CancelledError;\n}\nfunction createRetryer(config) {\n let isRetryCancelled = false;\n let failureCount = 0;\n let continueFn;\n const thenable = pendingThenable();\n const isResolved = () => thenable.status !== \"pending\";\n const cancel = (cancelOptions) => {\n if (!isResolved()) {\n const error = new CancelledError(cancelOptions);\n reject(error);\n config.onCancel?.(error);\n }\n };\n const cancelRetry = () => {\n isRetryCancelled = true;\n };\n const continueRetry = () => {\n isRetryCancelled = false;\n };\n const canContinue = () => focusManager.isFocused() && (config.networkMode === \"always\" || onlineManager.isOnline()) && config.canRun();\n const canStart = () => canFetch(config.networkMode) && config.canRun();\n const resolve = (value) => {\n if (!isResolved()) {\n continueFn?.();\n thenable.resolve(value);\n }\n };\n const reject = (value) => {\n if (!isResolved()) {\n continueFn?.();\n thenable.reject(value);\n }\n };\n const pause = () => {\n return new Promise((continueResolve) => {\n continueFn = (value) => {\n if (isResolved() || canContinue()) {\n continueResolve(value);\n }\n };\n config.onPause?.();\n }).then(() => {\n continueFn = void 0;\n if (!isResolved()) {\n config.onContinue?.();\n }\n });\n };\n const run = () => {\n if (isResolved()) {\n return;\n }\n let promiseOrValue;\n const initialPromise = failureCount === 0 ? config.initialPromise : void 0;\n try {\n promiseOrValue = initialPromise ?? config.fn();\n } catch (error) {\n promiseOrValue = Promise.reject(error);\n }\n Promise.resolve(promiseOrValue).then(resolve).catch((error) => {\n if (isResolved()) {\n return;\n }\n const retry = config.retry ?? (environmentManager.isServer() ? 0 : 3);\n const retryDelay = config.retryDelay ?? defaultRetryDelay;\n const delay = typeof retryDelay === \"function\" ? retryDelay(failureCount, error) : retryDelay;\n const shouldRetry = retry === true || typeof retry === \"number\" && failureCount < retry || typeof retry === \"function\" && retry(failureCount, error);\n if (isRetryCancelled || !shouldRetry) {\n reject(error);\n return;\n }\n failureCount++;\n config.onFail?.(failureCount, error);\n sleep(delay).then(() => {\n return canContinue() ? void 0 : pause();\n }).then(() => {\n if (isRetryCancelled) {\n reject(error);\n } else {\n run();\n }\n });\n });\n };\n return {\n promise: thenable,\n status: () => thenable.status,\n cancel,\n continue: () => {\n continueFn?.();\n return thenable;\n },\n cancelRetry,\n continueRetry,\n canStart,\n start: () => {\n if (canStart()) {\n run();\n } else {\n pause().then(run);\n }\n return thenable;\n }\n };\n}\nexport {\n CancelledError,\n canFetch,\n createRetryer,\n isCancelledError\n};\n//# sourceMappingURL=retryer.js.map"],"names":[],"mappings":";AASA,SAAS,SAAS,aAAa;AAC7B,UAAQ,eAAe,cAAc,WAAW,cAAc,SAAQ,IAAK;AAC7E;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var defaultTimeoutProvider = {
|
|
2
|
+
// We need the wrapper function syntax below instead of direct references to
|
|
3
|
+
// global setTimeout etc.
|
|
4
|
+
//
|
|
5
|
+
// BAD: `setTimeout: setTimeout`
|
|
6
|
+
// GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
|
|
7
|
+
//
|
|
8
|
+
// If we use direct references here, then anything that wants to spy on or
|
|
9
|
+
// replace the global setTimeout (like tests) won't work since we'll already
|
|
10
|
+
// have a hard reference to the original implementation at the time when this
|
|
11
|
+
// file was imported.
|
|
12
|
+
setTimeout: (callback, delay) => setTimeout(callback, delay),
|
|
13
|
+
clearTimeout: (timeoutId) => clearTimeout(timeoutId),
|
|
14
|
+
setInterval: (callback, delay) => setInterval(callback, delay),
|
|
15
|
+
clearInterval: (intervalId) => clearInterval(intervalId)
|
|
16
|
+
};
|
|
17
|
+
var TimeoutManager = class {
|
|
18
|
+
// We cannot have TimeoutManager<T> as we must instantiate it with a concrete
|
|
19
|
+
// type at app boot; and if we leave that type, then any new timer provider
|
|
20
|
+
// would need to support the default provider's concrete timer ID, which is
|
|
21
|
+
// infeasible across environments.
|
|
22
|
+
//
|
|
23
|
+
// We settle for type safety for the TimeoutProvider type, and accept that
|
|
24
|
+
// this class is unsafe internally to allow for extension.
|
|
25
|
+
#provider = defaultTimeoutProvider;
|
|
26
|
+
#providerCalled = false;
|
|
27
|
+
setTimeoutProvider(provider) {
|
|
28
|
+
if (process.env.NODE_ENV !== "production") {
|
|
29
|
+
if (this.#providerCalled && provider !== this.#provider) {
|
|
30
|
+
console.error(
|
|
31
|
+
`[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
|
|
32
|
+
{ previous: this.#provider, provider }
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
this.#provider = provider;
|
|
37
|
+
if (process.env.NODE_ENV !== "production") {
|
|
38
|
+
this.#providerCalled = false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
setTimeout(callback, delay) {
|
|
42
|
+
if (process.env.NODE_ENV !== "production") {
|
|
43
|
+
this.#providerCalled = true;
|
|
44
|
+
}
|
|
45
|
+
return this.#provider.setTimeout(callback, delay);
|
|
46
|
+
}
|
|
47
|
+
clearTimeout(timeoutId) {
|
|
48
|
+
this.#provider.clearTimeout(timeoutId);
|
|
49
|
+
}
|
|
50
|
+
setInterval(callback, delay) {
|
|
51
|
+
if (process.env.NODE_ENV !== "production") {
|
|
52
|
+
this.#providerCalled = true;
|
|
53
|
+
}
|
|
54
|
+
return this.#provider.setInterval(callback, delay);
|
|
55
|
+
}
|
|
56
|
+
clearInterval(intervalId) {
|
|
57
|
+
this.#provider.clearInterval(intervalId);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var timeoutManager = new TimeoutManager();
|
|
61
|
+
function systemSetTimeoutZero(callback) {
|
|
62
|
+
setTimeout(callback, 0);
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
TimeoutManager,
|
|
66
|
+
defaultTimeoutProvider,
|
|
67
|
+
systemSetTimeoutZero,
|
|
68
|
+
timeoutManager
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=timeoutManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeoutManager.js","sources":["../../../../../../node_modules/@tanstack/query-core/build/modern/timeoutManager.js"],"sourcesContent":["// src/timeoutManager.ts\nvar defaultTimeoutProvider = {\n // We need the wrapper function syntax below instead of direct references to\n // global setTimeout etc.\n //\n // BAD: `setTimeout: setTimeout`\n // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`\n //\n // If we use direct references here, then anything that wants to spy on or\n // replace the global setTimeout (like tests) won't work since we'll already\n // have a hard reference to the original implementation at the time when this\n // file was imported.\n setTimeout: (callback, delay) => setTimeout(callback, delay),\n clearTimeout: (timeoutId) => clearTimeout(timeoutId),\n setInterval: (callback, delay) => setInterval(callback, delay),\n clearInterval: (intervalId) => clearInterval(intervalId)\n};\nvar TimeoutManager = class {\n // We cannot have TimeoutManager<T> as we must instantiate it with a concrete\n // type at app boot; and if we leave that type, then any new timer provider\n // would need to support the default provider's concrete timer ID, which is\n // infeasible across environments.\n //\n // We settle for type safety for the TimeoutProvider type, and accept that\n // this class is unsafe internally to allow for extension.\n #provider = defaultTimeoutProvider;\n #providerCalled = false;\n setTimeoutProvider(provider) {\n if (process.env.NODE_ENV !== \"production\") {\n if (this.#providerCalled && provider !== this.#provider) {\n console.error(\n `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,\n { previous: this.#provider, provider }\n );\n }\n }\n this.#provider = provider;\n if (process.env.NODE_ENV !== \"production\") {\n this.#providerCalled = false;\n }\n }\n setTimeout(callback, delay) {\n if (process.env.NODE_ENV !== \"production\") {\n this.#providerCalled = true;\n }\n return this.#provider.setTimeout(callback, delay);\n }\n clearTimeout(timeoutId) {\n this.#provider.clearTimeout(timeoutId);\n }\n setInterval(callback, delay) {\n if (process.env.NODE_ENV !== \"production\") {\n this.#providerCalled = true;\n }\n return this.#provider.setInterval(callback, delay);\n }\n clearInterval(intervalId) {\n this.#provider.clearInterval(intervalId);\n }\n};\nvar timeoutManager = new TimeoutManager();\nfunction systemSetTimeoutZero(callback) {\n setTimeout(callback, 0);\n}\nexport {\n TimeoutManager,\n defaultTimeoutProvider,\n systemSetTimeoutZero,\n timeoutManager\n};\n//# sourceMappingURL=timeoutManager.js.map"],"names":[],"m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x_google_ignoreList":[0]}
|
|
@@ -14,10 +14,11 @@ function resolveEnabled(enabled, query) {
|
|
|
14
14
|
return typeof enabled === "function" ? enabled(query) : enabled;
|
|
15
15
|
}
|
|
16
16
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
17
|
-
function replaceEqualDeep(a, b) {
|
|
17
|
+
function replaceEqualDeep(a, b, depth = 0) {
|
|
18
18
|
if (a === b) {
|
|
19
19
|
return a;
|
|
20
20
|
}
|
|
21
|
+
if (depth > 500) return b;
|
|
21
22
|
const array = isPlainArray(a) && isPlainArray(b);
|
|
22
23
|
if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
|
|
23
24
|
const aItems = array ? a : Object.keys(a);
|
|
@@ -39,7 +40,7 @@ function replaceEqualDeep(a, b) {
|
|
|
39
40
|
copy[key] = bItem;
|
|
40
41
|
continue;
|
|
41
42
|
}
|
|
42
|
-
const v = replaceEqualDeep(aItem, bItem);
|
|
43
|
+
const v = replaceEqualDeep(aItem, bItem, depth + 1);
|
|
43
44
|
copy[key] = v;
|
|
44
45
|
if (v === aItem) equalItems++;
|
|
45
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../../../node_modules/@tanstack/query-core/build/modern/utils.js"],"sourcesContent":["// src/utils.ts\nvar isServer = typeof window === \"undefined\" || \"Deno\" in globalThis;\nfunction noop() {\n}\nfunction functionalUpdate(updater, input) {\n return typeof updater === \"function\" ? updater(input) : updater;\n}\nfunction isValidTimeout(value) {\n return typeof value === \"number\" && value >= 0 && value !== Infinity;\n}\nfunction timeUntilStale(updatedAt, staleTime) {\n return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);\n}\nfunction resolveStaleTime(staleTime, query) {\n return typeof staleTime === \"function\" ? staleTime(query) : staleTime;\n}\nfunction resolveEnabled(enabled, query) {\n return typeof enabled === \"function\" ? enabled(query) : enabled;\n}\nfunction matchQuery(filters, query) {\n const {\n type = \"all\",\n exact,\n fetchStatus,\n predicate,\n queryKey,\n stale\n } = filters;\n if (queryKey) {\n if (exact) {\n if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {\n return false;\n }\n } else if (!partialMatchKey(query.queryKey, queryKey)) {\n return false;\n }\n }\n if (type !== \"all\") {\n const isActive = query.isActive();\n if (type === \"active\" && !isActive) {\n return false;\n }\n if (type === \"inactive\" && isActive) {\n return false;\n }\n }\n if (typeof stale === \"boolean\" && query.isStale() !== stale) {\n return false;\n }\n if (fetchStatus && fetchStatus !== query.state.fetchStatus) {\n return false;\n }\n if (predicate && !predicate(query)) {\n return false;\n }\n return true;\n}\nfunction matchMutation(filters, mutation) {\n const { exact, status, predicate, mutationKey } = filters;\n if (mutationKey) {\n if (!mutation.options.mutationKey) {\n return false;\n }\n if (exact) {\n if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {\n return false;\n }\n } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {\n return false;\n }\n }\n if (status && mutation.state.status !== status) {\n return false;\n }\n if (predicate && !predicate(mutation)) {\n return false;\n }\n return true;\n}\nfunction hashQueryKeyByOptions(queryKey, options) {\n const hashFn = options?.queryKeyHashFn || hashKey;\n return hashFn(queryKey);\n}\nfunction hashKey(queryKey) {\n return JSON.stringify(\n queryKey,\n (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {\n result[key] = val[key];\n return result;\n }, {}) : val\n );\n}\nfunction partialMatchKey(a, b) {\n if (a === b) {\n return true;\n }\n if (typeof a !== typeof b) {\n return false;\n }\n if (a && b && typeof a === \"object\" && typeof b === \"object\") {\n return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]));\n }\n return false;\n}\nvar hasOwn = Object.prototype.hasOwnProperty;\nfunction replaceEqualDeep(a, b) {\n if (a === b) {\n return a;\n }\n const array = isPlainArray(a) && isPlainArray(b);\n if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;\n const aItems = array ? a : Object.keys(a);\n const aSize = aItems.length;\n const bItems = array ? b : Object.keys(b);\n const bSize = bItems.length;\n const copy = array ? new Array(bSize) : {};\n let equalItems = 0;\n for (let i = 0; i < bSize; i++) {\n const key = array ? i : bItems[i];\n const aItem = a[key];\n const bItem = b[key];\n if (aItem === bItem) {\n copy[key] = aItem;\n if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;\n continue;\n }\n if (aItem === null || bItem === null || typeof aItem !== \"object\" || typeof bItem !== \"object\") {\n copy[key] = bItem;\n continue;\n }\n const v = replaceEqualDeep(aItem, bItem);\n copy[key] = v;\n if (v === aItem) equalItems++;\n }\n return aSize === bSize && equalItems === aSize ? a : copy;\n}\nfunction shallowEqualObjects(a, b) {\n if (!b || Object.keys(a).length !== Object.keys(b).length) {\n return false;\n }\n for (const key in a) {\n if (a[key] !== b[key]) {\n return false;\n }\n }\n return true;\n}\nfunction isPlainArray(value) {\n return Array.isArray(value) && value.length === Object.keys(value).length;\n}\nfunction isPlainObject(o) {\n if (!hasObjectPrototype(o)) {\n return false;\n }\n const ctor = o.constructor;\n if (ctor === void 0) {\n return true;\n }\n const prot = ctor.prototype;\n if (!hasObjectPrototype(prot)) {\n return false;\n }\n if (!prot.hasOwnProperty(\"isPrototypeOf\")) {\n return false;\n }\n if (Object.getPrototypeOf(o) !== Object.prototype) {\n return false;\n }\n return true;\n}\nfunction hasObjectPrototype(o) {\n return Object.prototype.toString.call(o) === \"[object Object]\";\n}\nfunction sleep(timeout) {\n return new Promise((resolve) => {\n setTimeout(resolve, timeout);\n });\n}\nfunction replaceData(prevData, data, options) {\n if (typeof options.structuralSharing === \"function\") {\n return options.structuralSharing(prevData, data);\n } else if (options.structuralSharing !== false) {\n if (process.env.NODE_ENV !== \"production\") {\n try {\n return replaceEqualDeep(prevData, data);\n } catch (error) {\n console.error(\n `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`\n );\n throw error;\n }\n }\n return replaceEqualDeep(prevData, data);\n }\n return data;\n}\nfunction keepPreviousData(previousData) {\n return previousData;\n}\nfunction addToEnd(items, item, max = 0) {\n const newItems = [...items, item];\n return max && newItems.length > max ? newItems.slice(1) : newItems;\n}\nfunction addToStart(items, item, max = 0) {\n const newItems = [item, ...items];\n return max && newItems.length > max ? newItems.slice(0, -1) : newItems;\n}\nvar skipToken = Symbol();\nfunction ensureQueryFn(options, fetchOptions) {\n if (process.env.NODE_ENV !== \"production\") {\n if (options.queryFn === skipToken) {\n console.error(\n `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`\n );\n }\n }\n if (!options.queryFn && fetchOptions?.initialPromise) {\n return () => fetchOptions.initialPromise;\n }\n if (!options.queryFn || options.queryFn === skipToken) {\n return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));\n }\n return options.queryFn;\n}\nfunction shouldThrowError(throwOnError, params) {\n if (typeof throwOnError === \"function\") {\n return throwOnError(...params);\n }\n return !!throwOnError;\n}\nexport {\n addToEnd,\n addToStart,\n ensureQueryFn,\n functionalUpdate,\n hashKey,\n hashQueryKeyByOptions,\n isPlainArray,\n isPlainObject,\n isServer,\n isValidTimeout,\n keepPreviousData,\n matchMutation,\n matchQuery,\n noop,\n partialMatchKey,\n replaceData,\n replaceEqualDeep,\n resolveEnabled,\n resolveStaleTime,\n shallowEqualObjects,\n shouldThrowError,\n skipToken,\n sleep,\n timeUntilStale\n};\n//# sourceMappingURL=utils.js.map"],"names":[],"mappings":"AACG,IAAC,WAAW,OAAO,WAAW,eAAe,UAAU;AAC1D,SAAS,OAAO;AAChB;AAIA,SAAS,eAAe,OAAO;AAC7B,SAAO,OAAO,UAAU,YAAY,SAAS,KAAK,UAAU;AAC9D;AACA,SAAS,eAAe,WAAW,WAAW;AAC5C,SAAO,KAAK,IAAI,aAAa,aAAa,KAAK,KAAK,IAAG,GAAI,CAAC;AAC9D;AACA,SAAS,iBAAiB,WAAW,OAAO;AAC1C,SAAO,OAAO,cAAc,aAAa,UAAU,KAAK,I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;AACA,SAAO,CAAC,CAAC;AACX;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../../../node_modules/@tanstack/query-core/build/modern/utils.js"],"sourcesContent":["// src/utils.ts\nimport { timeoutManager } from \"./timeoutManager.js\";\nvar isServer = typeof window === \"undefined\" || \"Deno\" in globalThis;\nfunction noop() {\n}\nfunction functionalUpdate(updater, input) {\n return typeof updater === \"function\" ? updater(input) : updater;\n}\nfunction isValidTimeout(value) {\n return typeof value === \"number\" && value >= 0 && value !== Infinity;\n}\nfunction timeUntilStale(updatedAt, staleTime) {\n return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);\n}\nfunction resolveStaleTime(staleTime, query) {\n return typeof staleTime === \"function\" ? staleTime(query) : staleTime;\n}\nfunction resolveEnabled(enabled, query) {\n return typeof enabled === \"function\" ? enabled(query) : enabled;\n}\nfunction matchQuery(filters, query) {\n const {\n type = \"all\",\n exact,\n fetchStatus,\n predicate,\n queryKey,\n stale\n } = filters;\n if (queryKey) {\n if (exact) {\n if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {\n return false;\n }\n } else if (!partialMatchKey(query.queryKey, queryKey)) {\n return false;\n }\n }\n if (type !== \"all\") {\n const isActive = query.isActive();\n if (type === \"active\" && !isActive) {\n return false;\n }\n if (type === \"inactive\" && isActive) {\n return false;\n }\n }\n if (typeof stale === \"boolean\" && query.isStale() !== stale) {\n return false;\n }\n if (fetchStatus && fetchStatus !== query.state.fetchStatus) {\n return false;\n }\n if (predicate && !predicate(query)) {\n return false;\n }\n return true;\n}\nfunction matchMutation(filters, mutation) {\n const { exact, status, predicate, mutationKey } = filters;\n if (mutationKey) {\n if (!mutation.options.mutationKey) {\n return false;\n }\n if (exact) {\n if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {\n return false;\n }\n } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {\n return false;\n }\n }\n if (status && mutation.state.status !== status) {\n return false;\n }\n if (predicate && !predicate(mutation)) {\n return false;\n }\n return true;\n}\nfunction hashQueryKeyByOptions(queryKey, options) {\n const hashFn = options?.queryKeyHashFn || hashKey;\n return hashFn(queryKey);\n}\nfunction hashKey(queryKey) {\n return JSON.stringify(\n queryKey,\n (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {\n result[key] = val[key];\n return result;\n }, {}) : val\n );\n}\nfunction partialMatchKey(a, b) {\n if (a === b) {\n return true;\n }\n if (typeof a !== typeof b) {\n return false;\n }\n if (a && b && typeof a === \"object\" && typeof b === \"object\") {\n return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]));\n }\n return false;\n}\nvar hasOwn = Object.prototype.hasOwnProperty;\nfunction replaceEqualDeep(a, b, depth = 0) {\n if (a === b) {\n return a;\n }\n if (depth > 500) return b;\n const array = isPlainArray(a) && isPlainArray(b);\n if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;\n const aItems = array ? a : Object.keys(a);\n const aSize = aItems.length;\n const bItems = array ? b : Object.keys(b);\n const bSize = bItems.length;\n const copy = array ? new Array(bSize) : {};\n let equalItems = 0;\n for (let i = 0; i < bSize; i++) {\n const key = array ? i : bItems[i];\n const aItem = a[key];\n const bItem = b[key];\n if (aItem === bItem) {\n copy[key] = aItem;\n if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;\n continue;\n }\n if (aItem === null || bItem === null || typeof aItem !== \"object\" || typeof bItem !== \"object\") {\n copy[key] = bItem;\n continue;\n }\n const v = replaceEqualDeep(aItem, bItem, depth + 1);\n copy[key] = v;\n if (v === aItem) equalItems++;\n }\n return aSize === bSize && equalItems === aSize ? a : copy;\n}\nfunction shallowEqualObjects(a, b) {\n if (!b || Object.keys(a).length !== Object.keys(b).length) {\n return false;\n }\n for (const key in a) {\n if (a[key] !== b[key]) {\n return false;\n }\n }\n return true;\n}\nfunction isPlainArray(value) {\n return Array.isArray(value) && value.length === Object.keys(value).length;\n}\nfunction isPlainObject(o) {\n if (!hasObjectPrototype(o)) {\n return false;\n }\n const ctor = o.constructor;\n if (ctor === void 0) {\n return true;\n }\n const prot = ctor.prototype;\n if (!hasObjectPrototype(prot)) {\n return false;\n }\n if (!prot.hasOwnProperty(\"isPrototypeOf\")) {\n return false;\n }\n if (Object.getPrototypeOf(o) !== Object.prototype) {\n return false;\n }\n return true;\n}\nfunction hasObjectPrototype(o) {\n return Object.prototype.toString.call(o) === \"[object Object]\";\n}\nfunction sleep(timeout) {\n return new Promise((resolve) => {\n timeoutManager.setTimeout(resolve, timeout);\n });\n}\nfunction replaceData(prevData, data, options) {\n if (typeof options.structuralSharing === \"function\") {\n return options.structuralSharing(prevData, data);\n } else if (options.structuralSharing !== false) {\n if (process.env.NODE_ENV !== \"production\") {\n try {\n return replaceEqualDeep(prevData, data);\n } catch (error) {\n console.error(\n `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`\n );\n throw error;\n }\n }\n return replaceEqualDeep(prevData, data);\n }\n return data;\n}\nfunction keepPreviousData(previousData) {\n return previousData;\n}\nfunction addToEnd(items, item, max = 0) {\n const newItems = [...items, item];\n return max && newItems.length > max ? newItems.slice(1) : newItems;\n}\nfunction addToStart(items, item, max = 0) {\n const newItems = [item, ...items];\n return max && newItems.length > max ? newItems.slice(0, -1) : newItems;\n}\nvar skipToken = /* @__PURE__ */ Symbol();\nfunction ensureQueryFn(options, fetchOptions) {\n if (process.env.NODE_ENV !== \"production\") {\n if (options.queryFn === skipToken) {\n console.error(\n `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`\n );\n }\n }\n if (!options.queryFn && fetchOptions?.initialPromise) {\n return () => fetchOptions.initialPromise;\n }\n if (!options.queryFn || options.queryFn === skipToken) {\n return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));\n }\n return options.queryFn;\n}\nfunction shouldThrowError(throwOnError, params) {\n if (typeof throwOnError === \"function\") {\n return throwOnError(...params);\n }\n return !!throwOnError;\n}\nfunction addConsumeAwareSignal(object, getSignal, onCancelled) {\n let consumed = false;\n let signal;\n Object.defineProperty(object, \"signal\", {\n enumerable: true,\n get: () => {\n signal ??= getSignal();\n if (consumed) {\n return signal;\n }\n consumed = true;\n if (signal.aborted) {\n onCancelled();\n } else {\n signal.addEventListener(\"abort\", onCancelled, { once: true });\n }\n return signal;\n }\n });\n return object;\n}\nexport {\n addConsumeAwareSignal,\n addToEnd,\n addToStart,\n ensureQueryFn,\n functionalUpdate,\n hashKey,\n hashQueryKeyByOptions,\n isPlainArray,\n isPlainObject,\n isServer,\n isValidTimeout,\n keepPreviousData,\n matchMutation,\n matchQuery,\n noop,\n partialMatchKey,\n replaceData,\n replaceEqualDeep,\n resolveEnabled,\n resolveStaleTime,\n shallowEqualObjects,\n shouldThrowError,\n skipToken,\n sleep,\n timeUntilStale\n};\n//# sourceMappingURL=utils.js.map"],"names":[],"mappings":"AAEG,IAAC,WAAW,OAAO,WAAW,eAAe,UAAU;AAC1D,SAAS,OAAO;AAChB;AAIA,SAAS,eAAe,OAAO;AAC7B,SAAO,OAAO,UAAU,YAAY,SAAS,KAAK,UAAU;AAC9D;AACA,SAAS,eAAe,WAAW,WAAW;AAC5C,SAAO,KAAK,IAAI,aAAa,aAAa,KAAK,KAAK,IAAG,GAAI,CAAC;AAC9D;AACA,SAAS,iBAAiB,WAAW,OAAO;AAC1C,SAAO,OAAO,cAAc,aAAa,UAAU,KAAK,IAAI;AAC9D;AACA,SAAS,eAAe,SAAS,OAAO;AACtC,SAAO,OAAO,YAAY,aAAa,QAAQ,KAAK,IAAI;AAC1D;AAsFA,IAAI,SAAS,OAAO,UAAU;AAC9B,SAAS,iBAAiB,GAAG,GAAG,QAAQ,GAAG;AACzC,MAAI,MAAM,GAAG;AACX,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,IAAK,QAAO;AACxB,QAAM,QAAQ,aAAa,CAAC,KAAK,aAAa,CAAC;AAC/C,MAAI,CAAC,SAAS,EAA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,CAAC,GAAG;AAC1B,WAAO;AAAA,EACT;AACA,QAAM,OAAO,EAAE;AACf,MAAI,SAAS,QAAQ;AACnB,WAAO;AAAA,EACT;AACA,QAAM,OAAO,KAAK;AAClB,MAAI,CAAC,mBAAmB,IAAI,GAAG;AAC7B,WAAO;AAAA,EACT;AACA,MAAI,CAAC,KAAK,eAAe,eAAe,GAAG;AACzC,WAAO;AAAA,EACT;AACA,MAAI,OAAO,eAAe,CAAC,MAAM,OAAO,WAAW;AACjD,WAAO;AAAA,EACT;AACA,SAAO;AACT;AACA,SAAS,mBAAmB,GAAG;AAC7B,SAAO,OAAO,UAAU,SAAS,KAAK,CAAC,MAAM;AAC/C;AAMA,SAAS,YAAY,UAAU,MAAM,SAAS;AAC5C,MAAI,OAAO,QAAQ,sBAAsB,YAAY;AACnD,WAAO,QAAQ,kBAAkB,UAAU,IAAI;AAAA,EACjD,WAAW,QAAQ,sBAAsB,OAAO;AAC9C,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,UAAI;AACF,eAAO,iBAAiB,UAAU,IAAI;AAAA,MACxC,SAAS,OAAO;AACd,gBAAQ;AAAA,UACN,0JAA0J,QAAQ,SAAS,MAAM,KAAK;AAAA,QAChM;AACQ,cAAM;AAAA,MACR;AAAA,IACF;AACA,WAAO,iBAAiB,UAAU,IAAI;AAAA,EACxC;AACA,SAAO;AACT;AA6BA,SAAS,iBAAiB,cAAc,QAAQ;AAC9C,MAAI,OAAO,iBAAiB,YAAY;AACtC,WAAO,aAAa,GAAG,MAAM;AAAA,EAC/B;AACA,SAAO,CAAC,CAAC;AACX;","x_google_ignoreList":[0]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { shouldThrowError } from "../../../query-core/build/modern/utils.js";
|
|
2
2
|
const React = window["React"];
|
|
3
|
-
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
|
|
4
|
-
|
|
3
|
+
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary, query) => {
|
|
4
|
+
const throwOnError = query?.state.error && typeof options.throwOnError === "function" ? shouldThrowError(options.throwOnError, [query.state.error, query]) : options.throwOnError;
|
|
5
|
+
if (options.suspense || options.experimental_prefetchInRender || throwOnError) {
|
|
5
6
|
if (!errorResetBoundary.isReset()) {
|
|
6
7
|
options.retryOnMount = false;
|
|
7
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorBoundaryUtils.js","sources":["../../../../../../node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js"],"sourcesContent":["\"use client\";\n\n// src/errorBoundaryUtils.ts\nimport * as React from \"react\";\nimport { shouldThrowError } from \"@tanstack/query-core\";\nvar ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {\n
|
|
1
|
+
{"version":3,"file":"errorBoundaryUtils.js","sources":["../../../../../../node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js"],"sourcesContent":["\"use client\";\n\n// src/errorBoundaryUtils.ts\nimport * as React from \"react\";\nimport { shouldThrowError } from \"@tanstack/query-core\";\nvar ensurePreventErrorBoundaryRetry = (options, errorResetBoundary, query) => {\n const throwOnError = query?.state.error && typeof options.throwOnError === \"function\" ? shouldThrowError(options.throwOnError, [query.state.error, query]) : options.throwOnError;\n if (options.suspense || options.experimental_prefetchInRender || throwOnError) {\n if (!errorResetBoundary.isReset()) {\n options.retryOnMount = false;\n }\n }\n};\nvar useClearResetErrorBoundary = (errorResetBoundary) => {\n React.useEffect(() => {\n errorResetBoundary.clearReset();\n }, [errorResetBoundary]);\n};\nvar getHasError = ({\n result,\n errorResetBoundary,\n throwOnError,\n query,\n suspense\n}) => {\n return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));\n};\nexport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary\n};\n//# sourceMappingURL=errorBoundaryUtils.js.map"],"names":[],"mappings":";AAGA,MAAA,QAAA,OAAA,OAAA;AAEG,IAAC,kCAAkC,CAAC,SAAS,oBAAoB,UAAU;AAC5E,QAAM,eAAe,OAAO,MAAM,SAAS,OAAO,QAAQ,iBAAiB,aAAa,iBAAiB,QAAQ,cAAc,CAAC,MAAM,MAAM,OAAO,KAAK,CAAC,IAAI,QAAQ;AACrK,MAAI,QAAQ,YAAY,QAAQ,iCAAiC,cAAc;AAC7E,QAAI,CAAC,mBAAmB,WAAW;AACjC,cAAQ,eAAe;AAAA,IACzB;AAAA,EACF;AACF;AACG,IAAC,6BAA6B,CAAC,uBAAuB;AACvD,QAAM,UAAU,MAAM;AACpB,uBAAmB,WAAU;AAAA,EAC/B,GAAG,CAAC,kBAAkB,CAAC;AACzB;AACG,IAAC,cAAc,CAAC;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,SAAO,OAAO,WAAW,CAAC,mBAAmB,QAAO,KAAM,CAAC,OAAO,cAAc,UAAU,YAAY,OAAO,SAAS,UAAU,iBAAiB,cAAc,CAAC,OAAO,OAAO,KAAK,CAAC;AACtL;","x_google_ignoreList":[0]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { environmentManager } from "../../../query-core/build/modern/environmentManager.js";
|
|
1
2
|
import { notifyManager } from "../../../query-core/build/modern/notifyManager.js";
|
|
2
|
-
import { noop
|
|
3
|
+
import { noop } from "../../../query-core/build/modern/utils.js";
|
|
3
4
|
import { useQueryClient } from "./QueryClientProvider.js";
|
|
4
5
|
import { useQueryErrorResetBoundary } from "./QueryErrorResetBoundary.js";
|
|
5
6
|
import { ensurePreventErrorBoundaryRetry, useClearResetErrorBoundary, getHasError } from "./errorBoundaryUtils.js";
|
|
@@ -21,6 +22,7 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
|
21
22
|
client.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
22
23
|
defaultedOptions
|
|
23
24
|
);
|
|
25
|
+
const query = client.getQueryCache().get(defaultedOptions.queryHash);
|
|
24
26
|
if (process.env.NODE_ENV !== "production") {
|
|
25
27
|
if (!defaultedOptions.queryFn) {
|
|
26
28
|
console.error(
|
|
@@ -30,7 +32,7 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
|
30
32
|
}
|
|
31
33
|
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
32
34
|
ensureSuspenseTimers(defaultedOptions);
|
|
33
|
-
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
35
|
+
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query);
|
|
34
36
|
useClearResetErrorBoundary(errorResetBoundary);
|
|
35
37
|
const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
|
|
36
38
|
const [observer] = React.useState(
|
|
@@ -63,7 +65,7 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
|
63
65
|
result,
|
|
64
66
|
errorResetBoundary,
|
|
65
67
|
throwOnError: defaultedOptions.throwOnError,
|
|
66
|
-
query
|
|
68
|
+
query,
|
|
67
69
|
suspense: defaultedOptions.suspense
|
|
68
70
|
})) {
|
|
69
71
|
throw result.error;
|
|
@@ -72,13 +74,13 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
|
72
74
|
defaultedOptions,
|
|
73
75
|
result
|
|
74
76
|
);
|
|
75
|
-
if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) {
|
|
77
|
+
if (defaultedOptions.experimental_prefetchInRender && !environmentManager.isServer() && willFetch(result, isRestoring)) {
|
|
76
78
|
const promise = isNewCacheEntry ? (
|
|
77
79
|
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
78
80
|
fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
|
|
79
81
|
) : (
|
|
80
82
|
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
81
|
-
|
|
83
|
+
query?.promise
|
|
82
84
|
);
|
|
83
85
|
promise?.catch(noop).finally(() => {
|
|
84
86
|
observer.updateResult();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseQuery.js","sources":["../../../../../../node_modules/@tanstack/react-query/build/modern/useBaseQuery.js"],"sourcesContent":["\"use client\";\n\n// src/useBaseQuery.ts\nimport * as React from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"useBaseQuery.js","sources":["../../../../../../node_modules/@tanstack/react-query/build/modern/useBaseQuery.js"],"sourcesContent":["\"use client\";\n\n// src/useBaseQuery.ts\nimport * as React from \"react\";\nimport { environmentManager, noop, notifyManager } from \"@tanstack/query-core\";\nimport { useQueryClient } from \"./QueryClientProvider.js\";\nimport { useQueryErrorResetBoundary } from \"./QueryErrorResetBoundary.js\";\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary\n} from \"./errorBoundaryUtils.js\";\nimport { useIsRestoring } from \"./IsRestoringProvider.js\";\nimport {\n ensureSuspenseTimers,\n fetchOptimistic,\n shouldSuspend,\n willFetch\n} from \"./suspense.js\";\nfunction useBaseQuery(options, Observer, queryClient) {\n if (process.env.NODE_ENV !== \"production\") {\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new Error(\n 'Bad argument type. Starting with v5, only the \"Object\" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'\n );\n }\n }\n const isRestoring = useIsRestoring();\n const errorResetBoundary = useQueryErrorResetBoundary();\n const client = useQueryClient(queryClient);\n const defaultedOptions = client.defaultQueryOptions(options);\n client.getDefaultOptions().queries?._experimental_beforeQuery?.(\n defaultedOptions\n );\n const query = client.getQueryCache().get(defaultedOptions.queryHash);\n if (process.env.NODE_ENV !== \"production\") {\n if (!defaultedOptions.queryFn) {\n console.error(\n `[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`\n );\n }\n }\n defaultedOptions._optimisticResults = isRestoring ? \"isRestoring\" : \"optimistic\";\n ensureSuspenseTimers(defaultedOptions);\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query);\n useClearResetErrorBoundary(errorResetBoundary);\n const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);\n const [observer] = React.useState(\n () => new Observer(\n client,\n defaultedOptions\n )\n );\n const result = observer.getOptimisticResult(defaultedOptions);\n const shouldSubscribe = !isRestoring && options.subscribed !== false;\n React.useSyncExternalStore(\n React.useCallback(\n (onStoreChange) => {\n const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;\n observer.updateResult();\n return unsubscribe;\n },\n [observer, shouldSubscribe]\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult()\n );\n React.useEffect(() => {\n observer.setOptions(defaultedOptions);\n }, [defaultedOptions, observer]);\n if (shouldSuspend(defaultedOptions, result)) {\n throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);\n }\n if (getHasError({\n result,\n errorResetBoundary,\n throwOnError: defaultedOptions.throwOnError,\n query,\n suspense: defaultedOptions.suspense\n })) {\n throw result.error;\n }\n ;\n client.getDefaultOptions().queries?._experimental_afterQuery?.(\n defaultedOptions,\n result\n );\n if (defaultedOptions.experimental_prefetchInRender && !environmentManager.isServer() && willFetch(result, isRestoring)) {\n const promise = isNewCacheEntry ? (\n // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted\n fetchOptimistic(defaultedOptions, observer, errorResetBoundary)\n ) : (\n // subscribe to the \"cache promise\" so that we can finalize the currentThenable once data comes in\n query?.promise\n );\n promise?.catch(noop).finally(() => {\n observer.updateResult();\n });\n }\n return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;\n}\nexport {\n useBaseQuery\n};\n//# sourceMappingURL=useBaseQuery.js.map"],"names":[],"mappings":";;;;;;;;AAGA,MAAA,QAAA,OAAA,OAA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,EACnC;AACE,QAAM,UAAU,MAAM;AACpB,aAAS,WAAW,gBAAgB;AAAA,EACtC,GAAG,CAAC,kBAAkB,QAAQ,CAAC;AAC/B,MAAI,cAAc,kBAAkB,MAAM,GAAG;AAC3C,UAAM,gBAAgB,kBAAkB,UAAU,kBAAkB;AAAA,EACtE;AACA,MAAI,YAAY;AAAA,IACd;AAAA,IACA;AAAA,IACA,cAAc,iBAAiB;AAAA,IAC/B;AAAA,IACA,UAAU,iBAAiB;AAAA,EAC/B,CAAG,GAAG;AACF,UAAM,OAAO;AAAA,EACf;AAEA,SAAO,oBAAoB,SAAS;AAAA,IAClC;AAAA,IACA;AAAA,EACJ;AACE,MAAI,iBAAiB,iCAAiC,CAAC,mBAAmB,SAAQ,KAAM,UAAU,QAAQ,WAAW,GAAG;AACtH,UAAM,UAAU;AAAA;AAAA,MAEd,gBAAgB,kBAAkB,UAAU,kBAAkB;AAAA;AAAA;AAAA,MAG9D,OAAO;AAAA;AAET,aAAS,MAAM,IAAI,EAAE,QAAQ,MAAM;AACjC,eAAS,aAAY;AAAA,IACvB,CAAC;AAAA,EACH;AACA,SAAO,CAAC,iBAAiB,sBAAsB,SAAS,YAAY,MAAM,IAAI;AAChF;","x_google_ignoreList":[0]}
|
package/dist/types/Forms.d.ts
CHANGED
|
@@ -155,6 +155,8 @@ export interface ApiFormProps {
|
|
|
155
155
|
follow?: boolean;
|
|
156
156
|
actions?: ApiFormAction[];
|
|
157
157
|
timeout?: number;
|
|
158
|
+
keepOpenOption?: boolean;
|
|
159
|
+
onKeepOpenChange?: (keepOpen: boolean) => void;
|
|
158
160
|
}
|
|
159
161
|
/**
|
|
160
162
|
* @param title : The title to display in the modal header
|
package/dist/types/Plugins.d.ts
CHANGED
|
@@ -39,6 +39,14 @@ export type InvenTreeFormsContext = {
|
|
|
39
39
|
edit: (props: ApiFormModalProps) => UseModalReturn;
|
|
40
40
|
stockActions: StockAdjustmentFormsContext;
|
|
41
41
|
};
|
|
42
|
+
export type ImporterDrawerContext = {
|
|
43
|
+
open: (sessionId: number, options?: {
|
|
44
|
+
onClose?: () => void;
|
|
45
|
+
}) => void;
|
|
46
|
+
close: () => void;
|
|
47
|
+
isOpen: () => boolean;
|
|
48
|
+
sessionId: () => number | null;
|
|
49
|
+
};
|
|
42
50
|
/**
|
|
43
51
|
* A set of properties which are passed to a plugin,
|
|
44
52
|
* for rendering an element in the user interface.
|
|
@@ -50,6 +58,8 @@ export type InvenTreeFormsContext = {
|
|
|
50
58
|
* @param globalSettings - The global settings (see ../states/SettingsState.tsx)
|
|
51
59
|
* @param navigate - The navigation function (see react-router-dom)
|
|
52
60
|
* @param theme - The current Mantine theme
|
|
61
|
+
* @param forms - A set of functions for opening various API forms (see ../components/Forms.tsx)
|
|
62
|
+
* @param importer - A set of functions for controlling the global importer drawer (see ../components/importer/GlobalImporterDrawer.tsx)
|
|
53
63
|
* @param colorScheme - The current Mantine color scheme (e.g. 'light' / 'dark')
|
|
54
64
|
* @param host - The current host URL
|
|
55
65
|
* @param i18n - The i18n instance for translations (from @lingui/core)
|
|
@@ -78,6 +88,7 @@ export type InvenTreePluginContext = {
|
|
|
78
88
|
navigate: NavigateFunction;
|
|
79
89
|
theme: MantineTheme;
|
|
80
90
|
forms: InvenTreeFormsContext;
|
|
91
|
+
importer: ImporterDrawerContext;
|
|
81
92
|
colorScheme: MantineColorScheme;
|
|
82
93
|
model?: ModelType | string;
|
|
83
94
|
id?: string | number | null;
|
package/dist/types/Plugins.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const INVENTREE_PLUGIN_VERSION = "0.
|
|
2
|
-
const INVENTREE_REACT_VERSION = "19.
|
|
1
|
+
const INVENTREE_PLUGIN_VERSION = "0.10.0";
|
|
2
|
+
const INVENTREE_REACT_VERSION = "19.2.4";
|
|
3
3
|
const INVENTREE_REACT_DOM_VERSION = (
|
|
4
4
|
// @ts-ignore
|
|
5
|
-
"19.
|
|
5
|
+
"19.2.4"
|
|
6
6
|
);
|
|
7
7
|
const INVENTREE_MANTINE_VERSION = "8.2.7";
|
|
8
8
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugins.js","sources":["../../lib/types/Plugins.tsx"],"sourcesContent":["import type { I18n } from '@lingui/core';\nimport type { MantineColorScheme, MantineTheme } from '@mantine/core';\nimport type { QueryClient } from '@tanstack/react-query';\nimport type { AxiosInstance } from 'axios';\nimport type { NavigateFunction } from 'react-router-dom';\nimport type { ModelDict } from '../enums/ModelInformation';\nimport type { ModelType } from '../enums/ModelType';\nimport type {\n ApiFormModalProps,\n BulkEditApiFormModalProps,\n StockOperationProps\n} from './Forms';\nimport type { UseModalReturn } from './Modals';\nimport type { RenderInstanceProps } from './Rendering';\nimport type { SettingsStateProps } from './Settings';\nimport type { UserStateProps } from './User';\n\nexport interface PluginProps {\n name: string;\n slug: string;\n version: null | string;\n}\n\nexport interface PluginVersion {\n inventree: string;\n react: string;\n reactDom: string;\n mantine: string;\n}\n\nexport type StockAdjustmentFormsContext = {\n addStock: (props: StockOperationProps) => UseModalReturn;\n assignStock: (props: StockOperationProps) => UseModalReturn;\n changeStatus: (props: StockOperationProps) => UseModalReturn;\n countStock: (props: StockOperationProps) => UseModalReturn;\n deleteStock: (props: StockOperationProps) => UseModalReturn;\n mergeStock: (props: StockOperationProps) => UseModalReturn;\n removeStock: (props: StockOperationProps) => UseModalReturn;\n transferStock: (props: StockOperationProps) => UseModalReturn;\n returnStock: (props: StockOperationProps) => UseModalReturn;\n};\n\nexport type InvenTreeFormsContext = {\n bulkEdit: (props: BulkEditApiFormModalProps) => UseModalReturn;\n create: (props: ApiFormModalProps) => UseModalReturn;\n delete: (props: ApiFormModalProps) => UseModalReturn;\n edit: (props: ApiFormModalProps) => UseModalReturn;\n stockActions: StockAdjustmentFormsContext;\n};\n\n/**\n * A set of properties which are passed to a plugin,\n * for rendering an element in the user interface.\n *\n * @param version - The version of the running InvenTree software stack\n * @param api - The Axios API instance (see ../states/ApiState.tsx)\n * @param user - The current user instance (see ../states/UserState.tsx)\n * @param userSettings - The current user settings (see ../states/SettingsState.tsx)\n * @param globalSettings - The global settings (see ../states/SettingsState.tsx)\n * @param navigate - The navigation function (see react-router-dom)\n * @param theme - The current Mantine theme\n * @param colorScheme - The current Mantine color scheme (e.g. 'light' / 'dark')\n * @param host - The current host URL\n * @param i18n - The i18n instance for translations (from @lingui/core)\n * @param locale - The current locale string (e.g. 'en' / 'de')\n * @param model - The model type associated with the rendered component (if applicable)\n * @param modelInformation - A dictionary of available model information\n * @param renderInstance - A component function for rendering a model instance\n * @param id - The ID (primary key) of the model instance for the plugin (if applicable)\n * @param instance - The model instance data (if available)\n * @param reloadContent - A function which can be called to reload the plugin content\n * @param reloadInstance - A function which can be called to reload the model instance\n * @param context - Any additional context data which may be passed to the plugin\n */\nexport type InvenTreePluginContext = {\n version: PluginVersion;\n api: AxiosInstance;\n queryClient: QueryClient;\n user: UserStateProps;\n userSettings: SettingsStateProps;\n globalSettings: SettingsStateProps;\n modelInformation: ModelDict;\n renderInstance: (props: Readonly<RenderInstanceProps>) => React.ReactNode;\n host: string;\n i18n: I18n;\n locale: string;\n navigate: NavigateFunction;\n theme: MantineTheme;\n forms: InvenTreeFormsContext;\n colorScheme: MantineColorScheme;\n model?: ModelType | string;\n id?: string | number | null;\n instance?: any;\n reloadContent?: () => void;\n reloadInstance?: () => void;\n context?: any;\n};\n\n/*\n * The version of the InvenTree plugin context interface.\n * This number should be incremented if the interface changes.\n */\n\n// @ts-ignore\nexport const INVENTREE_PLUGIN_VERSION: string = __INVENTREE_LIB_VERSION__;\n// @ts-ignore\nexport const INVENTREE_REACT_VERSION: string = __INVENTREE_REACT_VERSION__;\n// @ts-ignore\nexport const INVENTREE_REACT_DOM_VERSION: string =\n // @ts-ignore\n __INVENTREE_REACT_DOM_VERSION__;\n// @ts-ignore\nexport const INVENTREE_MANTINE_VERSION: string = __INVENTREE_MANTINE_VERSION__;\n"],"names":["INVENTREE_PLUGIN_VERSION","__INVENTREE_LIB_VERSION__","INVENTREE_REACT_VERSION","__INVENTREE_REACT_VERSION__","INVENTREE_REACT_DOM_VERSION","__INVENTREE_REACT_DOM_VERSION__","INVENTREE_MANTINE_VERSION","__INVENTREE_MANTINE_VERSION__"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Plugins.js","sources":["../../lib/types/Plugins.tsx"],"sourcesContent":["import type { I18n } from '@lingui/core';\nimport type { MantineColorScheme, MantineTheme } from '@mantine/core';\nimport type { QueryClient } from '@tanstack/react-query';\nimport type { AxiosInstance } from 'axios';\nimport type { NavigateFunction } from 'react-router-dom';\nimport type { ModelDict } from '../enums/ModelInformation';\nimport type { ModelType } from '../enums/ModelType';\nimport type {\n ApiFormModalProps,\n BulkEditApiFormModalProps,\n StockOperationProps\n} from './Forms';\nimport type { UseModalReturn } from './Modals';\nimport type { RenderInstanceProps } from './Rendering';\nimport type { SettingsStateProps } from './Settings';\nimport type { UserStateProps } from './User';\n\nexport interface PluginProps {\n name: string;\n slug: string;\n version: null | string;\n}\n\nexport interface PluginVersion {\n inventree: string;\n react: string;\n reactDom: string;\n mantine: string;\n}\n\nexport type StockAdjustmentFormsContext = {\n addStock: (props: StockOperationProps) => UseModalReturn;\n assignStock: (props: StockOperationProps) => UseModalReturn;\n changeStatus: (props: StockOperationProps) => UseModalReturn;\n countStock: (props: StockOperationProps) => UseModalReturn;\n deleteStock: (props: StockOperationProps) => UseModalReturn;\n mergeStock: (props: StockOperationProps) => UseModalReturn;\n removeStock: (props: StockOperationProps) => UseModalReturn;\n transferStock: (props: StockOperationProps) => UseModalReturn;\n returnStock: (props: StockOperationProps) => UseModalReturn;\n};\n\nexport type InvenTreeFormsContext = {\n bulkEdit: (props: BulkEditApiFormModalProps) => UseModalReturn;\n create: (props: ApiFormModalProps) => UseModalReturn;\n delete: (props: ApiFormModalProps) => UseModalReturn;\n edit: (props: ApiFormModalProps) => UseModalReturn;\n stockActions: StockAdjustmentFormsContext;\n};\n\nexport type ImporterDrawerContext = {\n open: (sessionId: number, options?: { onClose?: () => void }) => void;\n close: () => void;\n isOpen: () => boolean;\n sessionId: () => number | null;\n};\n\n/**\n * A set of properties which are passed to a plugin,\n * for rendering an element in the user interface.\n *\n * @param version - The version of the running InvenTree software stack\n * @param api - The Axios API instance (see ../states/ApiState.tsx)\n * @param user - The current user instance (see ../states/UserState.tsx)\n * @param userSettings - The current user settings (see ../states/SettingsState.tsx)\n * @param globalSettings - The global settings (see ../states/SettingsState.tsx)\n * @param navigate - The navigation function (see react-router-dom)\n * @param theme - The current Mantine theme\n * @param forms - A set of functions for opening various API forms (see ../components/Forms.tsx)\n * @param importer - A set of functions for controlling the global importer drawer (see ../components/importer/GlobalImporterDrawer.tsx)\n * @param colorScheme - The current Mantine color scheme (e.g. 'light' / 'dark')\n * @param host - The current host URL\n * @param i18n - The i18n instance for translations (from @lingui/core)\n * @param locale - The current locale string (e.g. 'en' / 'de')\n * @param model - The model type associated with the rendered component (if applicable)\n * @param modelInformation - A dictionary of available model information\n * @param renderInstance - A component function for rendering a model instance\n * @param id - The ID (primary key) of the model instance for the plugin (if applicable)\n * @param instance - The model instance data (if available)\n * @param reloadContent - A function which can be called to reload the plugin content\n * @param reloadInstance - A function which can be called to reload the model instance\n * @param context - Any additional context data which may be passed to the plugin\n */\nexport type InvenTreePluginContext = {\n version: PluginVersion;\n api: AxiosInstance;\n queryClient: QueryClient;\n user: UserStateProps;\n userSettings: SettingsStateProps;\n globalSettings: SettingsStateProps;\n modelInformation: ModelDict;\n renderInstance: (props: Readonly<RenderInstanceProps>) => React.ReactNode;\n host: string;\n i18n: I18n;\n locale: string;\n navigate: NavigateFunction;\n theme: MantineTheme;\n forms: InvenTreeFormsContext;\n importer: ImporterDrawerContext;\n colorScheme: MantineColorScheme;\n model?: ModelType | string;\n id?: string | number | null;\n instance?: any;\n reloadContent?: () => void;\n reloadInstance?: () => void;\n context?: any;\n};\n\n/*\n * The version of the InvenTree plugin context interface.\n * This number should be incremented if the interface changes.\n */\n\n// @ts-ignore\nexport const INVENTREE_PLUGIN_VERSION: string = __INVENTREE_LIB_VERSION__;\n// @ts-ignore\nexport const INVENTREE_REACT_VERSION: string = __INVENTREE_REACT_VERSION__;\n// @ts-ignore\nexport const INVENTREE_REACT_DOM_VERSION: string =\n // @ts-ignore\n __INVENTREE_REACT_DOM_VERSION__;\n// @ts-ignore\nexport const INVENTREE_MANTINE_VERSION: string = __INVENTREE_MANTINE_VERSION__;\n"],"names":["INVENTREE_PLUGIN_VERSION","__INVENTREE_LIB_VERSION__","INVENTREE_REACT_VERSION","__INVENTREE_REACT_VERSION__","INVENTREE_REACT_DOM_VERSION","__INVENTREE_REACT_DOM_VERSION__","INVENTREE_MANTINE_VERSION","__INVENTREE_MANTINE_VERSION__"],"mappings":"AAkHO,MAAMA,2BAAmCC;AAEzC,MAAMC,0BAAkCC;AAExC,MAAMC;AAAAA;AAAAA,EAEXC;AAAAA;AAEK,MAAMC,4BAAoCC;"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { useDocumentVisibility } from '@mantine/hooks';
|
|
2
|
+
import { notifications, showNotification } from '@mantine/notifications';
|
|
3
|
+
import {
|
|
4
|
+
IconCircleCheck,
|
|
5
|
+
IconCircleX,
|
|
6
|
+
IconExclamationCircle
|
|
7
|
+
} from '@tabler/icons-react';
|
|
8
|
+
import { type QueryClient, useQuery } from '@tanstack/react-query';
|
|
9
|
+
import type { AxiosInstance } from 'axios';
|
|
10
|
+
import { useEffect, useState } from 'react';
|
|
11
|
+
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
|
12
|
+
import { apiUrl } from '../functions/Api';
|
|
13
|
+
|
|
14
|
+
export type MonitorBackgroundTaskProps = {
|
|
15
|
+
api: AxiosInstance;
|
|
16
|
+
queryClient?: QueryClient;
|
|
17
|
+
title?: string;
|
|
18
|
+
message: string;
|
|
19
|
+
errorMessage?: string;
|
|
20
|
+
successMessage?: string;
|
|
21
|
+
failureMessage?: string;
|
|
22
|
+
taskId?: string;
|
|
23
|
+
onSuccess?: () => void;
|
|
24
|
+
onFailure?: () => void;
|
|
25
|
+
onComplete?: () => void;
|
|
26
|
+
onError?: (error: Error) => void;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Hook for monitoring a background task running on the server
|
|
31
|
+
*/
|
|
32
|
+
export default function useMonitorBackgroundTask(
|
|
33
|
+
props: MonitorBackgroundTaskProps
|
|
34
|
+
) {
|
|
35
|
+
const visibility = useDocumentVisibility();
|
|
36
|
+
|
|
37
|
+
const [tracking, setTracking] = useState<boolean>(false);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!!props.taskId) {
|
|
41
|
+
setTracking(true);
|
|
42
|
+
showNotification({
|
|
43
|
+
id: `background-task-${props.taskId}`,
|
|
44
|
+
title: props.title,
|
|
45
|
+
message: props.message,
|
|
46
|
+
loading: true,
|
|
47
|
+
autoClose: false,
|
|
48
|
+
withCloseButton: false
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
setTracking(false);
|
|
52
|
+
}
|
|
53
|
+
}, [props.taskId]);
|
|
54
|
+
|
|
55
|
+
useQuery(
|
|
56
|
+
{
|
|
57
|
+
enabled: !!props.taskId && tracking && visibility === 'visible',
|
|
58
|
+
refetchInterval: 500,
|
|
59
|
+
queryKey: ['background-task', props.taskId],
|
|
60
|
+
queryFn: () =>
|
|
61
|
+
props.api
|
|
62
|
+
.get(apiUrl(ApiEndpoints.task_overview, props.taskId))
|
|
63
|
+
.then((response) => {
|
|
64
|
+
const data = response?.data ?? {};
|
|
65
|
+
|
|
66
|
+
if (data.complete) {
|
|
67
|
+
setTracking(false);
|
|
68
|
+
props.onComplete?.();
|
|
69
|
+
|
|
70
|
+
notifications.update({
|
|
71
|
+
id: `background-task-${props.taskId}`,
|
|
72
|
+
title: props.title,
|
|
73
|
+
loading: false,
|
|
74
|
+
color: data.success ? 'green' : 'red',
|
|
75
|
+
message: response.data?.success
|
|
76
|
+
? (props.successMessage ?? props.message)
|
|
77
|
+
: (props.failureMessage ?? props.message),
|
|
78
|
+
icon: response.data?.success ? (
|
|
79
|
+
<IconCircleCheck />
|
|
80
|
+
) : (
|
|
81
|
+
<IconCircleX />
|
|
82
|
+
),
|
|
83
|
+
autoClose: 1000,
|
|
84
|
+
withCloseButton: true
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (data.success) {
|
|
88
|
+
props.onSuccess?.();
|
|
89
|
+
} else {
|
|
90
|
+
props.onFailure?.();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return response;
|
|
95
|
+
})
|
|
96
|
+
.catch((error) => {
|
|
97
|
+
console.error(
|
|
98
|
+
`Error fetching background task status for task ${props.taskId}:`,
|
|
99
|
+
error
|
|
100
|
+
);
|
|
101
|
+
setTracking(false);
|
|
102
|
+
props.onError?.(error);
|
|
103
|
+
|
|
104
|
+
notifications.update({
|
|
105
|
+
id: `background-task-${props.taskId}`,
|
|
106
|
+
title: props.title,
|
|
107
|
+
loading: false,
|
|
108
|
+
color: 'red',
|
|
109
|
+
message: props.errorMessage ?? props.message,
|
|
110
|
+
icon: <IconExclamationCircle color='red' />,
|
|
111
|
+
autoClose: 5000,
|
|
112
|
+
withCloseButton: true
|
|
113
|
+
});
|
|
114
|
+
})
|
|
115
|
+
},
|
|
116
|
+
props.queryClient
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -9,48 +9,44 @@ import { ProgressBar } from '../components/ProgressBar';
|
|
|
9
9
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
|
10
10
|
import { apiUrl } from '../functions/Api';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
* Hook for monitoring a data output process running on the server
|
|
14
|
-
*/
|
|
15
|
-
export default function monitorDataOutput({
|
|
16
|
-
api,
|
|
17
|
-
queryClient,
|
|
18
|
-
title,
|
|
19
|
-
hostname,
|
|
20
|
-
id
|
|
21
|
-
}: {
|
|
12
|
+
export type MonitorDataOutputProps = {
|
|
22
13
|
api: AxiosInstance;
|
|
23
14
|
queryClient?: QueryClient;
|
|
24
15
|
title: string;
|
|
25
16
|
hostname?: string;
|
|
26
17
|
id?: number;
|
|
27
|
-
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Hook for monitoring a data output process running on the server
|
|
22
|
+
*/
|
|
23
|
+
export default function useMonitorDataOutput(props: MonitorDataOutputProps) {
|
|
28
24
|
const visibility = useDocumentVisibility();
|
|
29
25
|
|
|
30
26
|
const [loading, setLoading] = useState<boolean>(false);
|
|
31
27
|
|
|
32
28
|
useEffect(() => {
|
|
33
|
-
if (!!id) {
|
|
29
|
+
if (!!props.id) {
|
|
34
30
|
setLoading(true);
|
|
35
31
|
showNotification({
|
|
36
|
-
id: `data-output-${id}`,
|
|
37
|
-
title: title,
|
|
32
|
+
id: `data-output-${props.id}`,
|
|
33
|
+
title: props.title,
|
|
38
34
|
loading: true,
|
|
39
35
|
autoClose: false,
|
|
40
36
|
withCloseButton: false,
|
|
41
37
|
message: <ProgressBar size='lg' value={0} progressLabel />
|
|
42
38
|
});
|
|
43
39
|
} else setLoading(false);
|
|
44
|
-
}, [id, title]);
|
|
40
|
+
}, [props.id, props.title]);
|
|
45
41
|
|
|
46
42
|
useQuery(
|
|
47
43
|
{
|
|
48
|
-
enabled: !!id && loading && visibility === 'visible',
|
|
44
|
+
enabled: !!props.id && loading && visibility === 'visible',
|
|
49
45
|
refetchInterval: 500,
|
|
50
|
-
queryKey: ['data-output', id, title],
|
|
46
|
+
queryKey: ['data-output', props.id, props.title],
|
|
51
47
|
queryFn: () =>
|
|
52
|
-
api
|
|
53
|
-
.get(apiUrl(ApiEndpoints.data_output, id))
|
|
48
|
+
props.api
|
|
49
|
+
.get(apiUrl(ApiEndpoints.data_output, props.id))
|
|
54
50
|
.then((response) => {
|
|
55
51
|
const data = response?.data ?? {};
|
|
56
52
|
|
|
@@ -61,21 +57,21 @@ export default function monitorDataOutput({
|
|
|
61
57
|
data?.error ?? data?.errors?.error ?? t`Process failed`;
|
|
62
58
|
|
|
63
59
|
notifications.update({
|
|
64
|
-
id: `data-output-${id}`,
|
|
60
|
+
id: `data-output-${props.id}`,
|
|
65
61
|
loading: false,
|
|
66
62
|
icon: <IconExclamationCircle />,
|
|
67
63
|
autoClose: 2500,
|
|
68
|
-
title: title,
|
|
64
|
+
title: props.title,
|
|
69
65
|
message: error,
|
|
70
66
|
color: 'red'
|
|
71
67
|
});
|
|
72
68
|
} else if (data.complete) {
|
|
73
69
|
setLoading(false);
|
|
74
70
|
notifications.update({
|
|
75
|
-
id: `data-output-${id}`,
|
|
71
|
+
id: `data-output-${props.id}`,
|
|
76
72
|
loading: false,
|
|
77
73
|
autoClose: 2500,
|
|
78
|
-
title: title,
|
|
74
|
+
title: props.title,
|
|
79
75
|
message: t`Process completed successfully`,
|
|
80
76
|
color: 'green',
|
|
81
77
|
icon: <IconCircleCheck />
|
|
@@ -83,7 +79,7 @@ export default function monitorDataOutput({
|
|
|
83
79
|
|
|
84
80
|
if (data.output) {
|
|
85
81
|
const url = data.output;
|
|
86
|
-
const base = hostname ?? window.location.origin;
|
|
82
|
+
const base = props.hostname ?? window.location.origin;
|
|
87
83
|
|
|
88
84
|
const downloadUrl = new URL(url, base);
|
|
89
85
|
|
|
@@ -91,7 +87,7 @@ export default function monitorDataOutput({
|
|
|
91
87
|
}
|
|
92
88
|
} else {
|
|
93
89
|
notifications.update({
|
|
94
|
-
id: `data-output-${id}`,
|
|
90
|
+
id: `data-output-${props.id}`,
|
|
95
91
|
loading: true,
|
|
96
92
|
autoClose: false,
|
|
97
93
|
withCloseButton: false,
|
|
@@ -110,19 +106,19 @@ export default function monitorDataOutput({
|
|
|
110
106
|
return data;
|
|
111
107
|
})
|
|
112
108
|
.catch((error: Error) => {
|
|
113
|
-
console.error('Error in
|
|
109
|
+
console.error('Error in useMonitorDataOutput:', error);
|
|
114
110
|
setLoading(false);
|
|
115
111
|
notifications.update({
|
|
116
|
-
id: `data-output-${id}`,
|
|
112
|
+
id: `data-output-${props.id}`,
|
|
117
113
|
loading: false,
|
|
118
114
|
autoClose: 2500,
|
|
119
|
-
title: title,
|
|
115
|
+
title: props.title,
|
|
120
116
|
message: error.message || t`Process failed`,
|
|
121
117
|
color: 'red'
|
|
122
118
|
});
|
|
123
119
|
return {};
|
|
124
120
|
})
|
|
125
121
|
},
|
|
126
|
-
queryClient
|
|
122
|
+
props.queryClient
|
|
127
123
|
);
|
|
128
124
|
}
|
package/lib/index.ts
CHANGED
|
@@ -73,4 +73,11 @@ export {
|
|
|
73
73
|
} from './components/RowActions';
|
|
74
74
|
|
|
75
75
|
// Shared hooks
|
|
76
|
-
export {
|
|
76
|
+
export {
|
|
77
|
+
default as useMonitorDataOutput,
|
|
78
|
+
type MonitorDataOutputProps
|
|
79
|
+
} from './hooks/MonitorDataOutput';
|
|
80
|
+
export {
|
|
81
|
+
default as useMonitorBackgroundTask,
|
|
82
|
+
type MonitorBackgroundTaskProps
|
|
83
|
+
} from './hooks/MonitorBackgroundTask';
|