@hortiview/modulebase 0.0.20436 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/IsRestoringProvider-CBSZo7ur.js +312 -0
- package/dist/ModuleCore-DuJVrj6v.js +11828 -0
- package/dist/QueryClientProvider-DyiNrPkn.js +514 -0
- package/dist/_commonjsHelpers-ByX85dGu.js +33 -0
- package/dist/api-COabZnyn.js +147 -0
- package/dist/assets/ModuleCore.css +1 -1
- package/dist/chunk-LFPYN7LY-D1ls8FXf.js +8643 -0
- package/dist/components/ModuleBase.js +9 -9
- package/dist/components/ModuleCore.js +1 -1
- package/dist/constants.js +2 -3
- package/dist/hooks/useCustom.js +1 -1
- package/dist/hooks/useCustomMutation.js +5 -5
- package/dist/hooks/useEntity.js +30 -30
- package/dist/hooks/useOffline.js +1 -1
- package/dist/hooks/useOption.js +5 -5
- package/dist/hooks/useServiceBus.js +1 -1
- package/dist/hooks/useStores.js +1 -1
- package/dist/{_baseGet-C6jMXSsQ.js → isTypedArray-SkhznY1k.js} +494 -494
- package/dist/lib/constants.d.ts +0 -1
- package/dist/lib/hooks/useCustom.d.ts +4 -2
- package/dist/lib/hooks/useCustomMutation.d.ts +8 -3
- package/dist/lib/hooks/useEntity.d.ts +6 -0
- package/dist/lib/types/Requests.d.ts +0 -17
- package/dist/lib/utils/api.d.ts +6 -13
- package/dist/lib/utils/baseFetches.d.ts +3 -2
- package/dist/main.js +188 -173
- package/dist/module-router.js +2322 -121
- package/dist/{mutation-DSKlaYzY.js → mutation-CmhiEgfA.js} +101 -56
- package/dist/{omit-C9Qe80rl.js → omit-Do6MFRwA.js} +240 -223
- package/dist/provider/SignalR/SignalRProvider.js +2389 -2824
- package/dist/react-c9FSfB30.js +27 -0
- package/dist/stores/BasePropsStore.js +1 -1
- package/dist/stores/EnvironmentStore.js +1 -1
- package/dist/useMutation-Aoachkw_.js +139 -0
- package/dist/useQuery-DEU_AUtf.js +392 -0
- package/dist/utils/api.js +3 -4
- package/dist/utils/baseFetches.js +18 -14
- package/dist/utils/fetches.js +3 -4
- package/dist/utils/helper.js +13 -13
- package/package.json +17 -13
- package/dist/ModuleCore-DpwHP0IU.js +0 -14973
- package/dist/QueryClientProvider-Beog9TR7.js +0 -437
- package/dist/_commonjsHelpers-BkfeUUK-.js +0 -28
- package/dist/api-CogBuK0n.js +0 -473
- package/dist/chunk-IR6S3I6Y-BmDdD3SP.js +0 -8162
- package/dist/isRestoring-CLuxJVSA.js +0 -281
- package/dist/react-QiIgv49H.js +0 -27
- package/dist/useMutation-zu8uxBak.js +0 -97
- package/dist/useQuery-Bj9k9zik.js +0 -395
- package/dist/utils-DxRR_XLb.js +0 -9
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import u from "react";
|
|
2
|
+
const l = (t) => {
|
|
3
|
+
let e;
|
|
4
|
+
const n = /* @__PURE__ */ new Set(), o = (s, r) => {
|
|
5
|
+
const c = typeof s == "function" ? s(e) : s;
|
|
6
|
+
if (!Object.is(c, e)) {
|
|
7
|
+
const f = e;
|
|
8
|
+
e = r ?? (typeof c != "object" || c === null) ? c : Object.assign({}, e, c), n.forEach((g) => g(e, f));
|
|
9
|
+
}
|
|
10
|
+
}, a = () => e, i = { setState: o, getState: a, getInitialState: () => b, subscribe: (s) => (n.add(s), () => n.delete(s)) }, b = e = t(o, a, i);
|
|
11
|
+
return i;
|
|
12
|
+
}, d = ((t) => t ? l(t) : l), I = (t) => t;
|
|
13
|
+
function j(t, e = I) {
|
|
14
|
+
const n = u.useSyncExternalStore(
|
|
15
|
+
t.subscribe,
|
|
16
|
+
u.useCallback(() => e(t.getState()), [t, e]),
|
|
17
|
+
u.useCallback(() => e(t.getInitialState()), [t, e])
|
|
18
|
+
);
|
|
19
|
+
return u.useDebugValue(n), n;
|
|
20
|
+
}
|
|
21
|
+
const S = (t) => {
|
|
22
|
+
const e = d(t), n = (o) => j(e, o);
|
|
23
|
+
return Object.assign(n, e), n;
|
|
24
|
+
}, O = ((t) => t ? S(t) : S);
|
|
25
|
+
export {
|
|
26
|
+
O as c
|
|
27
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { g as l } from "./mutation-CmhiEgfA.js";
|
|
3
|
+
import { S as d, s as m, h as a, n as h, u as p, a as b, b as v } from "./QueryClientProvider-DyiNrPkn.js";
|
|
4
|
+
var f = class extends d {
|
|
5
|
+
#s;
|
|
6
|
+
#i = void 0;
|
|
7
|
+
#t;
|
|
8
|
+
#e;
|
|
9
|
+
constructor(t, s) {
|
|
10
|
+
super(), this.#s = t, this.setOptions(s), this.bindMethods(), this.#r();
|
|
11
|
+
}
|
|
12
|
+
bindMethods() {
|
|
13
|
+
this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
|
|
14
|
+
}
|
|
15
|
+
setOptions(t) {
|
|
16
|
+
const s = this.options;
|
|
17
|
+
this.options = this.#s.defaultMutationOptions(t), m(this.options, s) || this.#s.getMutationCache().notify({
|
|
18
|
+
type: "observerOptionsUpdated",
|
|
19
|
+
mutation: this.#t,
|
|
20
|
+
observer: this
|
|
21
|
+
}), s?.mutationKey && this.options.mutationKey && a(s.mutationKey) !== a(this.options.mutationKey) ? this.reset() : this.#t?.state.status === "pending" && this.#t.setOptions(this.options);
|
|
22
|
+
}
|
|
23
|
+
onUnsubscribe() {
|
|
24
|
+
this.hasListeners() || this.#t?.removeObserver(this);
|
|
25
|
+
}
|
|
26
|
+
onMutationUpdate(t) {
|
|
27
|
+
this.#r(), this.#o(t);
|
|
28
|
+
}
|
|
29
|
+
getCurrentResult() {
|
|
30
|
+
return this.#i;
|
|
31
|
+
}
|
|
32
|
+
reset() {
|
|
33
|
+
this.#t?.removeObserver(this), this.#t = void 0, this.#r(), this.#o();
|
|
34
|
+
}
|
|
35
|
+
mutate(t, s) {
|
|
36
|
+
return this.#e = s, this.#t?.removeObserver(this), this.#t = this.#s.getMutationCache().build(this.#s, this.options), this.#t.addObserver(this), this.#t.execute(t);
|
|
37
|
+
}
|
|
38
|
+
#r() {
|
|
39
|
+
const t = this.#t?.state ?? l();
|
|
40
|
+
this.#i = {
|
|
41
|
+
...t,
|
|
42
|
+
isPending: t.status === "pending",
|
|
43
|
+
isSuccess: t.status === "success",
|
|
44
|
+
isError: t.status === "error",
|
|
45
|
+
isIdle: t.status === "idle",
|
|
46
|
+
mutate: this.mutate,
|
|
47
|
+
reset: this.reset
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
#o(t) {
|
|
51
|
+
h.batch(() => {
|
|
52
|
+
if (this.#e && this.hasListeners()) {
|
|
53
|
+
const s = this.#i.variables, r = this.#i.context, e = {
|
|
54
|
+
client: this.#s,
|
|
55
|
+
meta: this.options.meta,
|
|
56
|
+
mutationKey: this.options.mutationKey
|
|
57
|
+
};
|
|
58
|
+
if (t?.type === "success") {
|
|
59
|
+
try {
|
|
60
|
+
this.#e.onSuccess?.(
|
|
61
|
+
t.data,
|
|
62
|
+
s,
|
|
63
|
+
r,
|
|
64
|
+
e
|
|
65
|
+
);
|
|
66
|
+
} catch (i) {
|
|
67
|
+
Promise.reject(i);
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
this.#e.onSettled?.(
|
|
71
|
+
t.data,
|
|
72
|
+
null,
|
|
73
|
+
s,
|
|
74
|
+
r,
|
|
75
|
+
e
|
|
76
|
+
);
|
|
77
|
+
} catch (i) {
|
|
78
|
+
Promise.reject(i);
|
|
79
|
+
}
|
|
80
|
+
} else if (t?.type === "error") {
|
|
81
|
+
try {
|
|
82
|
+
this.#e.onError?.(
|
|
83
|
+
t.error,
|
|
84
|
+
s,
|
|
85
|
+
r,
|
|
86
|
+
e
|
|
87
|
+
);
|
|
88
|
+
} catch (i) {
|
|
89
|
+
Promise.reject(i);
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
this.#e.onSettled?.(
|
|
93
|
+
void 0,
|
|
94
|
+
t.error,
|
|
95
|
+
s,
|
|
96
|
+
r,
|
|
97
|
+
e
|
|
98
|
+
);
|
|
99
|
+
} catch (i) {
|
|
100
|
+
Promise.reject(i);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
this.listeners.forEach((s) => {
|
|
105
|
+
s(this.#i);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
function g(t, s) {
|
|
111
|
+
const r = p(s), [e] = o.useState(
|
|
112
|
+
() => new f(
|
|
113
|
+
r,
|
|
114
|
+
t
|
|
115
|
+
)
|
|
116
|
+
);
|
|
117
|
+
o.useEffect(() => {
|
|
118
|
+
e.setOptions(t);
|
|
119
|
+
}, [e, t]);
|
|
120
|
+
const i = o.useSyncExternalStore(
|
|
121
|
+
o.useCallback(
|
|
122
|
+
(n) => e.subscribe(h.batchCalls(n)),
|
|
123
|
+
[e]
|
|
124
|
+
),
|
|
125
|
+
() => e.getCurrentResult(),
|
|
126
|
+
() => e.getCurrentResult()
|
|
127
|
+
), u = o.useCallback(
|
|
128
|
+
(n, c) => {
|
|
129
|
+
e.mutate(n, c).catch(b);
|
|
130
|
+
},
|
|
131
|
+
[e]
|
|
132
|
+
);
|
|
133
|
+
if (i.error && v(e.options.throwOnError, [i.error]))
|
|
134
|
+
throw i.error;
|
|
135
|
+
return { ...i, mutate: u, mutateAsync: i.mutate };
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
g as u
|
|
139
|
+
};
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { S as z, p as L, d as l, s as M, f as v, a as Q, j as _, k as j, t as K, l as w, m as $, r as A, n as W, b as q, u as G } from "./QueryClientProvider-DyiNrPkn.js";
|
|
2
|
+
import { f as J, u as X } from "./IsRestoringProvider-CBSZo7ur.js";
|
|
3
|
+
import * as m from "react";
|
|
4
|
+
import "react/jsx-runtime";
|
|
5
|
+
var Y = class extends z {
|
|
6
|
+
constructor(t, e) {
|
|
7
|
+
super(), this.options = e, this.#s = t, this.#i = null, this.#r = L(), this.bindMethods(), this.setOptions(e);
|
|
8
|
+
}
|
|
9
|
+
#s;
|
|
10
|
+
#t = void 0;
|
|
11
|
+
#p = void 0;
|
|
12
|
+
#e = void 0;
|
|
13
|
+
#n;
|
|
14
|
+
#u;
|
|
15
|
+
#r;
|
|
16
|
+
#i;
|
|
17
|
+
#m;
|
|
18
|
+
#l;
|
|
19
|
+
// This property keeps track of the last query with defined data.
|
|
20
|
+
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
21
|
+
#d;
|
|
22
|
+
#o;
|
|
23
|
+
#h;
|
|
24
|
+
#a;
|
|
25
|
+
#f = /* @__PURE__ */ new Set();
|
|
26
|
+
bindMethods() {
|
|
27
|
+
this.refetch = this.refetch.bind(this);
|
|
28
|
+
}
|
|
29
|
+
onSubscribe() {
|
|
30
|
+
this.listeners.size === 1 && (this.#t.addObserver(this), B(this.#t, this.options) ? this.#c() : this.updateResult(), this.#v());
|
|
31
|
+
}
|
|
32
|
+
onUnsubscribe() {
|
|
33
|
+
this.hasListeners() || this.destroy();
|
|
34
|
+
}
|
|
35
|
+
shouldFetchOnReconnect() {
|
|
36
|
+
return F(
|
|
37
|
+
this.#t,
|
|
38
|
+
this.options,
|
|
39
|
+
this.options.refetchOnReconnect
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
shouldFetchOnWindowFocus() {
|
|
43
|
+
return F(
|
|
44
|
+
this.#t,
|
|
45
|
+
this.options,
|
|
46
|
+
this.options.refetchOnWindowFocus
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
destroy() {
|
|
50
|
+
this.listeners = /* @__PURE__ */ new Set(), this.#R(), this.#S(), this.#t.removeObserver(this);
|
|
51
|
+
}
|
|
52
|
+
setOptions(t) {
|
|
53
|
+
const e = this.options, s = this.#t;
|
|
54
|
+
if (this.options = this.#s.defaultQueryOptions(t), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof l(this.options.enabled, this.#t) != "boolean")
|
|
55
|
+
throw new Error(
|
|
56
|
+
"Expected enabled to be a boolean or a callback that returns a boolean"
|
|
57
|
+
);
|
|
58
|
+
this.#E(), this.#t.setOptions(this.options), e._defaulted && !M(this.options, e) && this.#s.getQueryCache().notify({
|
|
59
|
+
type: "observerOptionsUpdated",
|
|
60
|
+
query: this.#t,
|
|
61
|
+
observer: this
|
|
62
|
+
});
|
|
63
|
+
const r = this.hasListeners();
|
|
64
|
+
r && H(
|
|
65
|
+
this.#t,
|
|
66
|
+
s,
|
|
67
|
+
this.options,
|
|
68
|
+
e
|
|
69
|
+
) && this.#c(), this.updateResult(), r && (this.#t !== s || l(this.options.enabled, this.#t) !== l(e.enabled, this.#t) || v(this.options.staleTime, this.#t) !== v(e.staleTime, this.#t)) && this.#b();
|
|
70
|
+
const i = this.#y();
|
|
71
|
+
r && (this.#t !== s || l(this.options.enabled, this.#t) !== l(e.enabled, this.#t) || i !== this.#a) && this.#g(i);
|
|
72
|
+
}
|
|
73
|
+
getOptimisticResult(t) {
|
|
74
|
+
const e = this.#s.getQueryCache().build(this.#s, t), s = this.createResult(e, t);
|
|
75
|
+
return tt(this, s) && (this.#e = s, this.#u = this.options, this.#n = this.#t.state), s;
|
|
76
|
+
}
|
|
77
|
+
getCurrentResult() {
|
|
78
|
+
return this.#e;
|
|
79
|
+
}
|
|
80
|
+
trackResult(t, e) {
|
|
81
|
+
return new Proxy(t, {
|
|
82
|
+
get: (s, r) => (this.trackProp(r), e?.(r), r === "promise" && (this.trackProp("data"), !this.options.experimental_prefetchInRender && this.#r.status === "pending" && this.#r.reject(
|
|
83
|
+
new Error(
|
|
84
|
+
"experimental_prefetchInRender feature flag is not enabled"
|
|
85
|
+
)
|
|
86
|
+
)), Reflect.get(s, r))
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
trackProp(t) {
|
|
90
|
+
this.#f.add(t);
|
|
91
|
+
}
|
|
92
|
+
getCurrentQuery() {
|
|
93
|
+
return this.#t;
|
|
94
|
+
}
|
|
95
|
+
refetch({ ...t } = {}) {
|
|
96
|
+
return this.fetch({
|
|
97
|
+
...t
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
fetchOptimistic(t) {
|
|
101
|
+
const e = this.#s.defaultQueryOptions(t), s = this.#s.getQueryCache().build(this.#s, e);
|
|
102
|
+
return s.fetch().then(() => this.createResult(s, e));
|
|
103
|
+
}
|
|
104
|
+
fetch(t) {
|
|
105
|
+
return this.#c({
|
|
106
|
+
...t,
|
|
107
|
+
cancelRefetch: t.cancelRefetch ?? !0
|
|
108
|
+
}).then(() => (this.updateResult(), this.#e));
|
|
109
|
+
}
|
|
110
|
+
#c(t) {
|
|
111
|
+
this.#E();
|
|
112
|
+
let e = this.#t.fetch(
|
|
113
|
+
this.options,
|
|
114
|
+
t
|
|
115
|
+
);
|
|
116
|
+
return t?.throwOnError || (e = e.catch(Q)), e;
|
|
117
|
+
}
|
|
118
|
+
#b() {
|
|
119
|
+
this.#R();
|
|
120
|
+
const t = v(
|
|
121
|
+
this.options.staleTime,
|
|
122
|
+
this.#t
|
|
123
|
+
);
|
|
124
|
+
if (_ || this.#e.isStale || !j(t))
|
|
125
|
+
return;
|
|
126
|
+
const s = K(this.#e.dataUpdatedAt, t) + 1;
|
|
127
|
+
this.#o = w.setTimeout(() => {
|
|
128
|
+
this.#e.isStale || this.updateResult();
|
|
129
|
+
}, s);
|
|
130
|
+
}
|
|
131
|
+
#y() {
|
|
132
|
+
return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#t) : this.options.refetchInterval) ?? !1;
|
|
133
|
+
}
|
|
134
|
+
#g(t) {
|
|
135
|
+
this.#S(), this.#a = t, !(_ || l(this.options.enabled, this.#t) === !1 || !j(this.#a) || this.#a === 0) && (this.#h = w.setInterval(() => {
|
|
136
|
+
(this.options.refetchIntervalInBackground || $.isFocused()) && this.#c();
|
|
137
|
+
}, this.#a));
|
|
138
|
+
}
|
|
139
|
+
#v() {
|
|
140
|
+
this.#b(), this.#g(this.#y());
|
|
141
|
+
}
|
|
142
|
+
#R() {
|
|
143
|
+
this.#o && (w.clearTimeout(this.#o), this.#o = void 0);
|
|
144
|
+
}
|
|
145
|
+
#S() {
|
|
146
|
+
this.#h && (w.clearInterval(this.#h), this.#h = void 0);
|
|
147
|
+
}
|
|
148
|
+
createResult(t, e) {
|
|
149
|
+
const s = this.#t, r = this.options, i = this.#e, u = this.#n, a = this.#u, b = t !== s ? t.state : this.#p, { state: h } = t;
|
|
150
|
+
let n = { ...h }, y = !1, o;
|
|
151
|
+
if (e._optimisticResults) {
|
|
152
|
+
const c = this.hasListeners(), g = !c && B(t, e), S = c && H(t, s, e, r);
|
|
153
|
+
(g || S) && (n = {
|
|
154
|
+
...n,
|
|
155
|
+
...J(h.data, t.options)
|
|
156
|
+
}), e._optimisticResults === "isRestoring" && (n.fetchStatus = "idle");
|
|
157
|
+
}
|
|
158
|
+
let { error: R, errorUpdatedAt: x, status: p } = n;
|
|
159
|
+
o = n.data;
|
|
160
|
+
let U = !1;
|
|
161
|
+
if (e.placeholderData !== void 0 && o === void 0 && p === "pending") {
|
|
162
|
+
let c;
|
|
163
|
+
i?.isPlaceholderData && e.placeholderData === a?.placeholderData ? (c = i.data, U = !0) : c = typeof e.placeholderData == "function" ? e.placeholderData(
|
|
164
|
+
this.#d?.state.data,
|
|
165
|
+
this.#d
|
|
166
|
+
) : e.placeholderData, c !== void 0 && (p = "success", o = A(
|
|
167
|
+
i?.data,
|
|
168
|
+
c,
|
|
169
|
+
e
|
|
170
|
+
), y = !0);
|
|
171
|
+
}
|
|
172
|
+
if (e.select && o !== void 0 && !U)
|
|
173
|
+
if (i && o === u?.data && e.select === this.#m)
|
|
174
|
+
o = this.#l;
|
|
175
|
+
else
|
|
176
|
+
try {
|
|
177
|
+
this.#m = e.select, o = e.select(o), o = A(i?.data, o, e), this.#l = o, this.#i = null;
|
|
178
|
+
} catch (c) {
|
|
179
|
+
this.#i = c;
|
|
180
|
+
}
|
|
181
|
+
this.#i && (R = this.#i, o = this.#l, x = Date.now(), p = "error");
|
|
182
|
+
const C = n.fetchStatus === "fetching", I = p === "pending", T = p === "error", D = I && C, k = o !== void 0, f = {
|
|
183
|
+
status: p,
|
|
184
|
+
fetchStatus: n.fetchStatus,
|
|
185
|
+
isPending: I,
|
|
186
|
+
isSuccess: p === "success",
|
|
187
|
+
isError: T,
|
|
188
|
+
isInitialLoading: D,
|
|
189
|
+
isLoading: D,
|
|
190
|
+
data: o,
|
|
191
|
+
dataUpdatedAt: n.dataUpdatedAt,
|
|
192
|
+
error: R,
|
|
193
|
+
errorUpdatedAt: x,
|
|
194
|
+
failureCount: n.fetchFailureCount,
|
|
195
|
+
failureReason: n.fetchFailureReason,
|
|
196
|
+
errorUpdateCount: n.errorUpdateCount,
|
|
197
|
+
isFetched: n.dataUpdateCount > 0 || n.errorUpdateCount > 0,
|
|
198
|
+
isFetchedAfterMount: n.dataUpdateCount > b.dataUpdateCount || n.errorUpdateCount > b.errorUpdateCount,
|
|
199
|
+
isFetching: C,
|
|
200
|
+
isRefetching: C && !I,
|
|
201
|
+
isLoadingError: T && !k,
|
|
202
|
+
isPaused: n.fetchStatus === "paused",
|
|
203
|
+
isPlaceholderData: y,
|
|
204
|
+
isRefetchError: T && k,
|
|
205
|
+
isStale: P(t, e),
|
|
206
|
+
refetch: this.refetch,
|
|
207
|
+
promise: this.#r,
|
|
208
|
+
isEnabled: l(e.enabled, t) !== !1
|
|
209
|
+
};
|
|
210
|
+
if (this.options.experimental_prefetchInRender) {
|
|
211
|
+
const c = f.data !== void 0, g = f.status === "error" && !c, S = (O) => {
|
|
212
|
+
g ? O.reject(f.error) : c && O.resolve(f.data);
|
|
213
|
+
}, N = () => {
|
|
214
|
+
const O = this.#r = f.promise = L();
|
|
215
|
+
S(O);
|
|
216
|
+
}, E = this.#r;
|
|
217
|
+
switch (E.status) {
|
|
218
|
+
case "pending":
|
|
219
|
+
t.queryHash === s.queryHash && S(E);
|
|
220
|
+
break;
|
|
221
|
+
case "fulfilled":
|
|
222
|
+
(g || f.data !== E.value) && N();
|
|
223
|
+
break;
|
|
224
|
+
case "rejected":
|
|
225
|
+
(!g || f.error !== E.reason) && N();
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return f;
|
|
230
|
+
}
|
|
231
|
+
updateResult() {
|
|
232
|
+
const t = this.#e, e = this.createResult(this.#t, this.options);
|
|
233
|
+
if (this.#n = this.#t.state, this.#u = this.options, this.#n.data !== void 0 && (this.#d = this.#t), M(e, t))
|
|
234
|
+
return;
|
|
235
|
+
this.#e = e;
|
|
236
|
+
const s = () => {
|
|
237
|
+
if (!t)
|
|
238
|
+
return !0;
|
|
239
|
+
const { notifyOnChangeProps: r } = this.options, i = typeof r == "function" ? r() : r;
|
|
240
|
+
if (i === "all" || !i && !this.#f.size)
|
|
241
|
+
return !0;
|
|
242
|
+
const u = new Set(
|
|
243
|
+
i ?? this.#f
|
|
244
|
+
);
|
|
245
|
+
return this.options.throwOnError && u.add("error"), Object.keys(this.#e).some((a) => {
|
|
246
|
+
const d = a;
|
|
247
|
+
return this.#e[d] !== t[d] && u.has(d);
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
this.#O({ listeners: s() });
|
|
251
|
+
}
|
|
252
|
+
#E() {
|
|
253
|
+
const t = this.#s.getQueryCache().build(this.#s, this.options);
|
|
254
|
+
if (t === this.#t)
|
|
255
|
+
return;
|
|
256
|
+
const e = this.#t;
|
|
257
|
+
this.#t = t, this.#p = t.state, this.hasListeners() && (e?.removeObserver(this), t.addObserver(this));
|
|
258
|
+
}
|
|
259
|
+
onQueryUpdate() {
|
|
260
|
+
this.updateResult(), this.hasListeners() && this.#v();
|
|
261
|
+
}
|
|
262
|
+
#O(t) {
|
|
263
|
+
W.batch(() => {
|
|
264
|
+
t.listeners && this.listeners.forEach((e) => {
|
|
265
|
+
e(this.#e);
|
|
266
|
+
}), this.#s.getQueryCache().notify({
|
|
267
|
+
query: this.#t,
|
|
268
|
+
type: "observerResultsUpdated"
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
function Z(t, e) {
|
|
274
|
+
return l(e.enabled, t) !== !1 && t.state.data === void 0 && !(t.state.status === "error" && e.retryOnMount === !1);
|
|
275
|
+
}
|
|
276
|
+
function B(t, e) {
|
|
277
|
+
return Z(t, e) || t.state.data !== void 0 && F(t, e, e.refetchOnMount);
|
|
278
|
+
}
|
|
279
|
+
function F(t, e, s) {
|
|
280
|
+
if (l(e.enabled, t) !== !1 && v(e.staleTime, t) !== "static") {
|
|
281
|
+
const r = typeof s == "function" ? s(t) : s;
|
|
282
|
+
return r === "always" || r !== !1 && P(t, e);
|
|
283
|
+
}
|
|
284
|
+
return !1;
|
|
285
|
+
}
|
|
286
|
+
function H(t, e, s, r) {
|
|
287
|
+
return (t !== e || l(r.enabled, t) === !1) && (!s.suspense || t.state.status !== "error") && P(t, s);
|
|
288
|
+
}
|
|
289
|
+
function P(t, e) {
|
|
290
|
+
return l(e.enabled, t) !== !1 && t.isStaleByTime(v(e.staleTime, t));
|
|
291
|
+
}
|
|
292
|
+
function tt(t, e) {
|
|
293
|
+
return !M(t.getCurrentResult(), e);
|
|
294
|
+
}
|
|
295
|
+
function et() {
|
|
296
|
+
let t = !1;
|
|
297
|
+
return {
|
|
298
|
+
clearReset: () => {
|
|
299
|
+
t = !1;
|
|
300
|
+
},
|
|
301
|
+
reset: () => {
|
|
302
|
+
t = !0;
|
|
303
|
+
},
|
|
304
|
+
isReset: () => t
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
var st = m.createContext(et()), rt = () => m.useContext(st), it = (t, e, s) => {
|
|
308
|
+
const r = s?.state.error && typeof t.throwOnError == "function" ? q(t.throwOnError, [s.state.error, s]) : t.throwOnError;
|
|
309
|
+
(t.suspense || t.experimental_prefetchInRender || r) && (e.isReset() || (t.retryOnMount = !1));
|
|
310
|
+
}, at = (t) => {
|
|
311
|
+
m.useEffect(() => {
|
|
312
|
+
t.clearReset();
|
|
313
|
+
}, [t]);
|
|
314
|
+
}, nt = ({
|
|
315
|
+
result: t,
|
|
316
|
+
errorResetBoundary: e,
|
|
317
|
+
throwOnError: s,
|
|
318
|
+
query: r,
|
|
319
|
+
suspense: i
|
|
320
|
+
}) => t.isError && !e.isReset() && !t.isFetching && r && (i && t.data === void 0 || q(s, [t.error, r])), ot = (t) => {
|
|
321
|
+
if (t.suspense) {
|
|
322
|
+
const s = (i) => i === "static" ? i : Math.max(i ?? 1e3, 1e3), r = t.staleTime;
|
|
323
|
+
t.staleTime = typeof r == "function" ? (...i) => s(r(...i)) : s(r), typeof t.gcTime == "number" && (t.gcTime = Math.max(
|
|
324
|
+
t.gcTime,
|
|
325
|
+
1e3
|
|
326
|
+
));
|
|
327
|
+
}
|
|
328
|
+
}, ht = (t, e) => t.isLoading && t.isFetching && !e, ct = (t, e) => t?.suspense && e.isPending, V = (t, e, s) => e.fetchOptimistic(t).catch(() => {
|
|
329
|
+
s.clearReset();
|
|
330
|
+
});
|
|
331
|
+
function ut(t, e, s) {
|
|
332
|
+
if (process.env.NODE_ENV !== "production" && (typeof t != "object" || Array.isArray(t)))
|
|
333
|
+
throw new Error(
|
|
334
|
+
'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'
|
|
335
|
+
);
|
|
336
|
+
const r = X(), i = rt(), u = G(s), a = u.defaultQueryOptions(t);
|
|
337
|
+
u.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
338
|
+
a
|
|
339
|
+
);
|
|
340
|
+
const d = u.getQueryCache().get(a.queryHash);
|
|
341
|
+
process.env.NODE_ENV !== "production" && (a.queryFn || console.error(
|
|
342
|
+
`[${a.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`
|
|
343
|
+
)), a._optimisticResults = r ? "isRestoring" : "optimistic", ot(a), it(a, i, d), at(i);
|
|
344
|
+
const b = !u.getQueryCache().get(a.queryHash), [h] = m.useState(
|
|
345
|
+
() => new e(
|
|
346
|
+
u,
|
|
347
|
+
a
|
|
348
|
+
)
|
|
349
|
+
), n = h.getOptimisticResult(a), y = !r && t.subscribed !== !1;
|
|
350
|
+
if (m.useSyncExternalStore(
|
|
351
|
+
m.useCallback(
|
|
352
|
+
(o) => {
|
|
353
|
+
const R = y ? h.subscribe(W.batchCalls(o)) : Q;
|
|
354
|
+
return h.updateResult(), R;
|
|
355
|
+
},
|
|
356
|
+
[h, y]
|
|
357
|
+
),
|
|
358
|
+
() => h.getCurrentResult(),
|
|
359
|
+
() => h.getCurrentResult()
|
|
360
|
+
), m.useEffect(() => {
|
|
361
|
+
h.setOptions(a);
|
|
362
|
+
}, [a, h]), ct(a, n))
|
|
363
|
+
throw V(a, h, i);
|
|
364
|
+
if (nt({
|
|
365
|
+
result: n,
|
|
366
|
+
errorResetBoundary: i,
|
|
367
|
+
throwOnError: a.throwOnError,
|
|
368
|
+
query: d,
|
|
369
|
+
suspense: a.suspense
|
|
370
|
+
}))
|
|
371
|
+
throw n.error;
|
|
372
|
+
return u.getDefaultOptions().queries?._experimental_afterQuery?.(
|
|
373
|
+
a,
|
|
374
|
+
n
|
|
375
|
+
), a.experimental_prefetchInRender && !_ && ht(n, r) && (b ? (
|
|
376
|
+
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
377
|
+
V(a, h, i)
|
|
378
|
+
) : (
|
|
379
|
+
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
380
|
+
d?.promise
|
|
381
|
+
))?.catch(Q).finally(() => {
|
|
382
|
+
h.updateResult();
|
|
383
|
+
}), a.notifyOnChangeProps ? n : h.trackResult(n);
|
|
384
|
+
}
|
|
385
|
+
function mt(t, e) {
|
|
386
|
+
return ut(t, Y, e);
|
|
387
|
+
}
|
|
388
|
+
export {
|
|
389
|
+
Y as Q,
|
|
390
|
+
ut as a,
|
|
391
|
+
mt as u
|
|
392
|
+
};
|
package/dist/utils/api.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { f as t,
|
|
1
|
+
import { f as t, a as i, h as n } from "../api-COabZnyn.js";
|
|
2
2
|
import "../constants.js";
|
|
3
3
|
import "../stores/BasePropsStore.js";
|
|
4
4
|
export {
|
|
5
5
|
t as fetchWithErrorHandling,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
i as handleResponse
|
|
6
|
+
i as getConfig,
|
|
7
|
+
n as handleResponse
|
|
9
8
|
};
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { a as u, f as m, i as S, b as I } from "../api-CogBuK0n.js";
|
|
2
1
|
import { useBasePropsStore as t } from "../stores/BasePropsStore.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return d?.("No token found", 404), Promise.reject();
|
|
7
|
-
const f = u(a, i, c, g, r);
|
|
8
|
-
return f.body = JSON.stringify(e), m(s, f);
|
|
9
|
-
}, h = (s, e, g, o = !1) => {
|
|
10
|
-
const r = o ? void 0 : g ?? t.getState().modulePermissionToken, n = t.getState().organizationId, a = t.getState().currentLanguageId, i = t.getState().throwError;
|
|
2
|
+
import { a as u, f } from "../api-COabZnyn.js";
|
|
3
|
+
const k = (a, s, e, i, g, o = !1) => {
|
|
4
|
+
const r = o ? void 0 : i ?? t.getState().modulePermissionToken, n = t.getState().organizationId, c = t.getState().currentLanguageId, l = t.getState().throwError;
|
|
11
5
|
if (!o && !r)
|
|
12
|
-
return
|
|
13
|
-
const
|
|
14
|
-
return
|
|
6
|
+
return l?.("No token found", 404), Promise.reject();
|
|
7
|
+
const d = u(r, n, c, e, g);
|
|
8
|
+
return d.body = JSON.stringify(s), f(a, d);
|
|
9
|
+
}, I = (a, s, e = !1) => {
|
|
10
|
+
const i = t.getState().modulePermissionToken, g = t.getState().organizationId, o = t.getState().currentLanguageId, r = t.getState().throwError, n = e ? void 0 : s ?? i;
|
|
11
|
+
if (!e && !n)
|
|
12
|
+
return r?.("No token available", 401), Promise.reject(
|
|
13
|
+
new Error("No token available", {
|
|
14
|
+
cause: 401
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
const c = u(n, g, o);
|
|
18
|
+
return f(a, c);
|
|
15
19
|
};
|
|
16
20
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
I as baseFetch,
|
|
22
|
+
k as baseMutation
|
|
19
23
|
};
|
package/dist/utils/fetches.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { useBasePropsStore as a } from "../stores/BasePropsStore.js";
|
|
2
2
|
import { useEnvironmentStore as i } from "../stores/EnvironmentStore.js";
|
|
3
3
|
import { baseMutation as d, baseFetch as o } from "./baseFetches.js";
|
|
4
|
-
const I = (e, t, n = "POST", s, m, u = !1) => d(e, t, n, s, m, u), g = (e, t) => r(`FarmOrgEntities/${e}/byId/${t}`), E = (e, t) => r(`ModuleDependentEntities/${e}/byId/${t}`), A = (e, t) => r(`ModuleDependentEntitiesRaw/${e}/byId/${t}`), M = (e, t, n = !1) => o(`${e}`,
|
|
4
|
+
const I = (e, t, n = "POST", s, m, u = !1) => d(e, t, n, s, m, u), g = (e, t) => r(`FarmOrgEntities/${e}/byId/${t}`), E = (e, t) => r(`ModuleDependentEntities/${e}/byId/${t}`), A = (e, t) => r(`ModuleDependentEntitiesRaw/${e}/byId/${t}`), M = (e, t, n = !1) => o(`${e}`, t, n), r = (e) => {
|
|
5
5
|
const t = i.getState().environment, n = a.getState().organizationId;
|
|
6
6
|
return o(
|
|
7
|
-
`${t?.MODULE_AUTH_API}${t?.API_PREFIX}/${n}/${e}
|
|
8
|
-
{}
|
|
7
|
+
`${t?.MODULE_AUTH_API}${t?.API_PREFIX}/${n}/${e}`
|
|
9
8
|
);
|
|
10
9
|
}, f = (e) => {
|
|
11
10
|
const t = i.getState().environment;
|
|
12
|
-
return o(`${t?.COMMON_API}${t?.API_PREFIX}/${e}
|
|
11
|
+
return o(`${t?.COMMON_API}${t?.API_PREFIX}/${e}`);
|
|
13
12
|
};
|
|
14
13
|
export {
|
|
15
14
|
f as fetchFromCommonApi,
|
package/dist/utils/helper.js
CHANGED
|
@@ -10,22 +10,22 @@ const g = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([
|
|
|
10
10
|
}, f = (r) => r === "*" || r === "x" || r === "X", l = (r) => {
|
|
11
11
|
const e = parseInt(r, 10);
|
|
12
12
|
return isNaN(e) ? r : e;
|
|
13
|
-
},
|
|
13
|
+
}, v = (r, e) => typeof r != typeof e ? [String(r), String(e)] : [r, e], h = (r, e) => {
|
|
14
14
|
if (f(r) || f(e))
|
|
15
15
|
return 0;
|
|
16
|
-
const [
|
|
17
|
-
return
|
|
16
|
+
const [t, n] = v(l(r), l(e));
|
|
17
|
+
return t > n ? 1 : t < n ? -1 : 0;
|
|
18
18
|
}, p = (r, e) => {
|
|
19
|
-
for (let
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
return
|
|
19
|
+
for (let t = 0; t < Math.max(r.length, e.length); t++) {
|
|
20
|
+
const n = h(r[t] || "0", e[t] || "0");
|
|
21
|
+
if (n !== 0)
|
|
22
|
+
return n;
|
|
23
23
|
}
|
|
24
24
|
return 0;
|
|
25
|
-
},
|
|
26
|
-
const
|
|
25
|
+
}, E = (r, e) => {
|
|
26
|
+
const t = c(r), n = c(e), o = t.pop(), i = n.pop(), s = p(t, n);
|
|
27
27
|
return s !== 0 ? s : o && i ? p(o.split("."), i.split(".")) : o || i ? o ? -1 : 1 : 0;
|
|
28
|
-
}, d = "0.0.
|
|
28
|
+
}, d = "0.0.13105-beta", w = (r) => m.every((e) => a(e, r)), a = (r, e) => {
|
|
29
29
|
if (!e[r]) {
|
|
30
30
|
if (e.throwError)
|
|
31
31
|
return e.throwError(`Missing required prop: ${r}`, 404), !1;
|
|
@@ -39,10 +39,10 @@ const g = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([
|
|
|
39
39
|
}, S = (r) => {
|
|
40
40
|
if (!r?.REQ_VERSION) return null;
|
|
41
41
|
const e = r.REQ_VERSION;
|
|
42
|
-
return
|
|
42
|
+
return E(d, e) < 0 ? `ModuleBase version ${d} is probably not compatible with the current HortiView version ${e}. Please update the modulebase to be at least ${e}` : null;
|
|
43
43
|
}, _ = (r) => typeof r == "string" || typeof r == "boolean" || typeof r == "number" ? r : typeof r == "object" && "value" in r ? r.value : typeof r == "object" && "items" in r ? r.items : (Array.isArray(r), r), M = (r) => r, R = (r) => {
|
|
44
|
-
const e = u.getState().organizationId,
|
|
45
|
-
return [...r, e,
|
|
44
|
+
const e = u.getState().organizationId, t = u.getState().moduleId;
|
|
45
|
+
return [...r, e, t];
|
|
46
46
|
};
|
|
47
47
|
export {
|
|
48
48
|
w as arePropsValid,
|