@hortiview/modulebase 0.0.1 → 0.0.17-beta
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 +8 -8
- package/dist/ModuleCore-YCIFN_02.js +14973 -0
- package/dist/QueryClientProvider-Beog9TR7.js +437 -0
- package/dist/{_baseGet-Bh5zJ_C8.js → _baseGet-C6jMXSsQ.js} +448 -448
- package/dist/api-s6E2GJtu.js +458 -0
- package/dist/assets/ModuleCore.css +1 -0
- package/dist/chunk-QMGIS6GS-C4bgXQXY.js +9203 -0
- package/dist/components/ModuleBase.js +20 -681
- package/dist/components/ModuleCore.js +10 -0
- package/dist/hooks/useBreadcrumbTranslation.js +16 -13
- package/dist/hooks/useCustom.js +15 -15
- package/dist/hooks/useCustomMutation.js +23 -0
- package/dist/hooks/useEntity.js +53 -54
- package/dist/hooks/useOffline.js +45 -0
- package/dist/hooks/useOption.js +19 -17
- package/dist/hooks/useServiceBus.js +25 -0
- package/dist/hooks/useStores.js +11 -841
- package/dist/isRestoring-CLuxJVSA.js +281 -0
- package/dist/lib/components/ModuleBase.d.ts +36 -0
- package/dist/lib/components/ModuleCore.d.ts +32 -0
- package/dist/{constants.d.ts → lib/constants.d.ts} +1 -1
- package/dist/{hooks → lib/hooks}/useBreadcrumbTranslation.d.ts +1 -1
- package/dist/lib/hooks/useCustom.d.ts +8 -0
- package/dist/lib/hooks/useCustomMutation.d.ts +9 -0
- package/dist/{hooks → lib/hooks}/useEntity.d.ts +6 -30
- package/dist/lib/hooks/useOffline.d.ts +15 -0
- package/dist/{hooks → lib/hooks}/useOption.d.ts +1 -1
- package/dist/lib/hooks/useServiceBus.d.ts +19 -0
- package/dist/lib/hooks/useStores.d.ts +38 -0
- package/dist/lib/main.d.ts +27 -0
- package/dist/lib/module-router.d.ts +7 -0
- package/dist/{stores → lib/stores}/EnvironmentStore.d.ts +1 -1
- package/dist/lib/types/ActionStorage.d.ts +16 -0
- package/dist/{types → lib/types}/BaseProps.d.ts +14 -2
- package/dist/{types → lib/types}/Deprecated.d.ts +7 -1
- package/dist/lib/types/Entities.d.ts +22 -0
- package/dist/{types → lib/types}/Environment.d.ts +3 -2
- package/dist/lib/types/EnvironmentVariable.d.ts +6 -0
- package/dist/lib/types/ModuleApi.d.ts +163 -0
- package/dist/{types → lib/types}/Requests.d.ts +6 -11
- package/dist/lib/types/ServiceBus.d.ts +17 -0
- package/dist/{utils/fetches.d.ts → lib/utils/api.d.ts} +2 -8
- package/dist/lib/utils/baseFetches.d.ts +19 -0
- package/dist/lib/utils/fetches.d.ts +43 -0
- package/dist/lib/utils/helper.d.ts +29 -0
- package/dist/main.js +224 -17
- package/dist/module-router.js +137 -0
- package/dist/mutation-DSKlaYzY.js +192 -0
- package/dist/omit-C9Qe80rl.js +835 -0
- package/dist/stores/EnvironmentStore.js +9 -3
- package/dist/types/ActionStorage.js +4 -0
- package/dist/types/Entities.js +25 -0
- package/dist/types/EnvironmentVariable.js +1 -0
- package/dist/types/Requests.js +1 -4
- package/dist/types/ServiceBus.js +1 -0
- package/dist/useMutation-zu8uxBak.js +97 -0
- package/dist/{useQuery-znAyMQW1.js → useQuery-Bj9k9zik.js} +106 -108
- package/dist/utils/api.js +9 -0
- package/dist/utils/baseFetches.js +19 -0
- package/dist/utils/fetches.js +20 -14
- package/dist/utils/helper.js +55 -0
- package/dist/utils-DxRR_XLb.js +9 -0
- package/package.json +8 -3
- package/dist/QueryClientProvider-DQv4Y3Qu.js +0 -707
- package/dist/chunk-IR6S3I6Y-BvQXS3A3.js +0 -3908
- package/dist/components/ModuleBase.d.ts +0 -11
- package/dist/fetches-DUCQo_6B.js +0 -477
- package/dist/hooks/useCustom.d.ts +0 -6
- package/dist/hooks/useNavigate.d.ts +0 -5
- package/dist/hooks/useNavigate.js +0 -27
- package/dist/hooks/useStores.d.ts +0 -29
- package/dist/main.d.ts +0 -9
- package/dist/types/ModuleApi.d.ts +0 -80
- /package/dist/{hooks → lib/hooks}/useSignalRMessages.d.ts +0 -0
- /package/dist/{provider → lib/provider}/SignalR/SignalRProvider.d.ts +0 -0
- /package/dist/{provider → lib/provider}/SignalR/signalR.d.ts +0 -0
- /package/dist/{stores → lib/stores}/BasePropsStore.d.ts +0 -0
- /package/dist/{types → lib/types}/AppInsights.d.ts +0 -0
- /package/dist/{types → lib/types}/CommonOptions.d.ts +0 -0
- /package/dist/{types → lib/types}/SystemMessage.d.ts +0 -0
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { c as r } from "../react-QiIgv49H.js";
|
|
2
|
-
const
|
|
3
|
-
environment:
|
|
2
|
+
const E = r((e) => ({
|
|
3
|
+
environment: {
|
|
4
|
+
ENVIRONMENT: "DEV",
|
|
5
|
+
COMMON_API: "",
|
|
6
|
+
REQ_VERSION: "",
|
|
7
|
+
MODULE_AUTH_API: "",
|
|
8
|
+
API_PREFIX: ""
|
|
9
|
+
},
|
|
4
10
|
setEnvironment: (n) => e({ environment: n }),
|
|
5
11
|
addEnvironment: (n) => e((o) => ({ environment: { ...n, ...o.environment } }))
|
|
6
12
|
}));
|
|
7
13
|
export {
|
|
8
|
-
|
|
14
|
+
E as useEnvironmentStore
|
|
9
15
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
farms: "farm",
|
|
3
|
+
fields: "field",
|
|
4
|
+
zones: "block",
|
|
5
|
+
irrigation_stations: "irrigationStation",
|
|
6
|
+
farm_organizations: "farmOrg",
|
|
7
|
+
alert_rules: "farmAlertRule"
|
|
8
|
+
}, t = {
|
|
9
|
+
farm_members: "member"
|
|
10
|
+
}, a = {
|
|
11
|
+
Season: "season",
|
|
12
|
+
BlockPlantLayout: "blockPlantLayout",
|
|
13
|
+
Record: "recordLight",
|
|
14
|
+
Scouting: "scouting"
|
|
15
|
+
}, r = {
|
|
16
|
+
...e,
|
|
17
|
+
...t,
|
|
18
|
+
...a
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
r as AllEntitiesTypeResultMap,
|
|
22
|
+
t as FarmMemberEntitiesTypeResultMap,
|
|
23
|
+
e as FarmOrgEntitiesTypeResultMap,
|
|
24
|
+
a as ModuleDependedEntityTypeResultMap
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/types/Requests.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { g as l } from "./mutation-DSKlaYzY.js";
|
|
3
|
+
import { S as d, s as p, h, n as a, u as b } from "./QueryClientProvider-Beog9TR7.js";
|
|
4
|
+
import { n as m, s as f } from "./utils-DxRR_XLb.js";
|
|
5
|
+
var v = class extends d {
|
|
6
|
+
#e;
|
|
7
|
+
#i = void 0;
|
|
8
|
+
#t;
|
|
9
|
+
#s;
|
|
10
|
+
constructor(t, s) {
|
|
11
|
+
super(), this.#e = t, this.setOptions(s), this.bindMethods(), this.#r();
|
|
12
|
+
}
|
|
13
|
+
bindMethods() {
|
|
14
|
+
this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
|
|
15
|
+
}
|
|
16
|
+
setOptions(t) {
|
|
17
|
+
const s = this.options;
|
|
18
|
+
this.options = this.#e.defaultMutationOptions(t), p(this.options, s) || this.#e.getMutationCache().notify({
|
|
19
|
+
type: "observerOptionsUpdated",
|
|
20
|
+
mutation: this.#t,
|
|
21
|
+
observer: this
|
|
22
|
+
}), s?.mutationKey && this.options.mutationKey && h(s.mutationKey) !== h(this.options.mutationKey) ? this.reset() : this.#t?.state.status === "pending" && this.#t.setOptions(this.options);
|
|
23
|
+
}
|
|
24
|
+
onUnsubscribe() {
|
|
25
|
+
this.hasListeners() || this.#t?.removeObserver(this);
|
|
26
|
+
}
|
|
27
|
+
onMutationUpdate(t) {
|
|
28
|
+
this.#r(), this.#o(t);
|
|
29
|
+
}
|
|
30
|
+
getCurrentResult() {
|
|
31
|
+
return this.#i;
|
|
32
|
+
}
|
|
33
|
+
reset() {
|
|
34
|
+
this.#t?.removeObserver(this), this.#t = void 0, this.#r(), this.#o();
|
|
35
|
+
}
|
|
36
|
+
mutate(t, s) {
|
|
37
|
+
return this.#s = s, this.#t?.removeObserver(this), this.#t = this.#e.getMutationCache().build(this.#e, this.options), this.#t.addObserver(this), this.#t.execute(t);
|
|
38
|
+
}
|
|
39
|
+
#r() {
|
|
40
|
+
const t = this.#t?.state ?? l();
|
|
41
|
+
this.#i = {
|
|
42
|
+
...t,
|
|
43
|
+
isPending: t.status === "pending",
|
|
44
|
+
isSuccess: t.status === "success",
|
|
45
|
+
isError: t.status === "error",
|
|
46
|
+
isIdle: t.status === "idle",
|
|
47
|
+
mutate: this.mutate,
|
|
48
|
+
reset: this.reset
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
#o(t) {
|
|
52
|
+
a.batch(() => {
|
|
53
|
+
if (this.#s && this.hasListeners()) {
|
|
54
|
+
const s = this.#i.variables, i = this.#i.context;
|
|
55
|
+
t?.type === "success" ? (this.#s.onSuccess?.(t.data, s, i), this.#s.onSettled?.(t.data, null, s, i)) : t?.type === "error" && (this.#s.onError?.(t.error, s, i), this.#s.onSettled?.(
|
|
56
|
+
void 0,
|
|
57
|
+
t.error,
|
|
58
|
+
s,
|
|
59
|
+
i
|
|
60
|
+
));
|
|
61
|
+
}
|
|
62
|
+
this.listeners.forEach((s) => {
|
|
63
|
+
s(this.#i);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
function M(t, s) {
|
|
69
|
+
const i = b(s), [e] = o.useState(
|
|
70
|
+
() => new v(
|
|
71
|
+
i,
|
|
72
|
+
t
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
o.useEffect(() => {
|
|
76
|
+
e.setOptions(t);
|
|
77
|
+
}, [e, t]);
|
|
78
|
+
const r = o.useSyncExternalStore(
|
|
79
|
+
o.useCallback(
|
|
80
|
+
(n) => e.subscribe(a.batchCalls(n)),
|
|
81
|
+
[e]
|
|
82
|
+
),
|
|
83
|
+
() => e.getCurrentResult(),
|
|
84
|
+
() => e.getCurrentResult()
|
|
85
|
+
), u = o.useCallback(
|
|
86
|
+
(n, c) => {
|
|
87
|
+
e.mutate(n, c).catch(m);
|
|
88
|
+
},
|
|
89
|
+
[e]
|
|
90
|
+
);
|
|
91
|
+
if (r.error && f(e.options.throwOnError, [r.error]))
|
|
92
|
+
throw r.error;
|
|
93
|
+
return { ...r, mutate: u, mutateAsync: r.mutate };
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
M as u
|
|
97
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
import
|
|
1
|
+
import { S as B, p as U, b as f, s as w, g as O, a as N, j as Q, k, t as H, l as V, r as M, n as A, u as z } from "./QueryClientProvider-Beog9TR7.js";
|
|
2
|
+
import { f as W, u as $ } from "./isRestoring-CLuxJVSA.js";
|
|
3
|
+
import * as y from "react";
|
|
3
4
|
import "react/jsx-runtime";
|
|
4
|
-
|
|
5
|
+
import { s as K, n as _ } from "./utils-DxRR_XLb.js";
|
|
6
|
+
var G = class extends B {
|
|
5
7
|
constructor(e, t) {
|
|
6
8
|
super(), this.options = t, this.#s = e, this.#r = null, this.#i = U(), this.options.experimental_prefetchInRender || this.#i.reject(
|
|
7
9
|
new Error("experimental_prefetchInRender feature flag is not enabled")
|
|
@@ -15,20 +17,20 @@ var $ = class extends N {
|
|
|
15
17
|
#c;
|
|
16
18
|
#i;
|
|
17
19
|
#r;
|
|
18
|
-
#
|
|
20
|
+
#y;
|
|
19
21
|
#l;
|
|
20
22
|
// This property keeps track of the last query with defined data.
|
|
21
23
|
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
22
24
|
#d;
|
|
23
|
-
#h;
|
|
24
25
|
#o;
|
|
26
|
+
#h;
|
|
25
27
|
#n;
|
|
26
28
|
#f = /* @__PURE__ */ new Set();
|
|
27
29
|
bindMethods() {
|
|
28
30
|
this.refetch = this.refetch.bind(this);
|
|
29
31
|
}
|
|
30
32
|
onSubscribe() {
|
|
31
|
-
this.listeners.size === 1 && (this.#e.addObserver(this),
|
|
33
|
+
this.listeners.size === 1 && (this.#e.addObserver(this), j(this.#e, this.options) ? this.#u() : this.updateResult(), this.#R());
|
|
32
34
|
}
|
|
33
35
|
onUnsubscribe() {
|
|
34
36
|
this.hasListeners() || this.destroy();
|
|
@@ -67,13 +69,13 @@ var $ = class extends N {
|
|
|
67
69
|
r,
|
|
68
70
|
this.options,
|
|
69
71
|
s
|
|
70
|
-
) && this.#u(), this.updateResult(t), a && (this.#e !== r || f(this.options.enabled, this.#e) !== f(s.enabled, this.#e) || O(this.options.staleTime, this.#e) !== O(s.staleTime, this.#e)) && this.#
|
|
71
|
-
const u = this.#
|
|
72
|
+
) && this.#u(), this.updateResult(t), a && (this.#e !== r || f(this.options.enabled, this.#e) !== f(s.enabled, this.#e) || O(this.options.staleTime, this.#e) !== O(s.staleTime, this.#e)) && this.#b();
|
|
73
|
+
const u = this.#m();
|
|
72
74
|
a && (this.#e !== r || f(this.options.enabled, this.#e) !== f(s.enabled, this.#e) || u !== this.#n) && this.#g(u);
|
|
73
75
|
}
|
|
74
76
|
getOptimisticResult(e) {
|
|
75
77
|
const t = this.#s.getQueryCache().build(this.#s, e), s = this.createResult(t, e);
|
|
76
|
-
return
|
|
78
|
+
return X(this, s) && (this.#t = s, this.#c = this.options, this.#a = this.#e.state), s;
|
|
77
79
|
}
|
|
78
80
|
getCurrentResult() {
|
|
79
81
|
return this.#t;
|
|
@@ -115,123 +117,123 @@ var $ = class extends N {
|
|
|
115
117
|
this.options,
|
|
116
118
|
e
|
|
117
119
|
);
|
|
118
|
-
return e?.throwOnError || (t = t.catch(
|
|
120
|
+
return e?.throwOnError || (t = t.catch(N)), t;
|
|
119
121
|
}
|
|
120
|
-
#
|
|
122
|
+
#b() {
|
|
121
123
|
this.#v();
|
|
122
124
|
const e = O(
|
|
123
125
|
this.options.staleTime,
|
|
124
126
|
this.#e
|
|
125
127
|
);
|
|
126
|
-
if (Q || this.#t.isStale || !
|
|
128
|
+
if (Q || this.#t.isStale || !k(e))
|
|
127
129
|
return;
|
|
128
|
-
const s =
|
|
129
|
-
this.#
|
|
130
|
+
const s = H(this.#t.dataUpdatedAt, e) + 1;
|
|
131
|
+
this.#o = setTimeout(() => {
|
|
130
132
|
this.#t.isStale || this.updateResult();
|
|
131
133
|
}, s);
|
|
132
134
|
}
|
|
133
|
-
#
|
|
135
|
+
#m() {
|
|
134
136
|
return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#e) : this.options.refetchInterval) ?? !1;
|
|
135
137
|
}
|
|
136
138
|
#g(e) {
|
|
137
|
-
this.#O(), this.#n = e, !(Q || f(this.options.enabled, this.#e) === !1 || !
|
|
138
|
-
(this.options.refetchIntervalInBackground ||
|
|
139
|
+
this.#O(), this.#n = e, !(Q || f(this.options.enabled, this.#e) === !1 || !k(this.#n) || this.#n === 0) && (this.#h = setInterval(() => {
|
|
140
|
+
(this.options.refetchIntervalInBackground || V.isFocused()) && this.#u();
|
|
139
141
|
}, this.#n));
|
|
140
142
|
}
|
|
141
|
-
#
|
|
142
|
-
this.#
|
|
143
|
+
#R() {
|
|
144
|
+
this.#b(), this.#g(this.#m());
|
|
143
145
|
}
|
|
144
146
|
#v() {
|
|
145
|
-
this.#
|
|
147
|
+
this.#o && (clearTimeout(this.#o), this.#o = void 0);
|
|
146
148
|
}
|
|
147
149
|
#O() {
|
|
148
|
-
this.#
|
|
150
|
+
this.#h && (clearInterval(this.#h), this.#h = void 0);
|
|
149
151
|
}
|
|
150
152
|
createResult(e, t) {
|
|
151
|
-
const s = this.#e, r = this.options, a = this.#t, u = this.#a, i = this.#c,
|
|
152
|
-
let n = { ...c },
|
|
153
|
+
const s = this.#e, r = this.options, a = this.#t, u = this.#a, i = this.#c, o = e !== s ? e.state : this.#p, { state: c } = e;
|
|
154
|
+
let n = { ...c }, R = !1, l;
|
|
153
155
|
if (t._optimisticResults) {
|
|
154
|
-
const
|
|
155
|
-
(
|
|
156
|
+
const h = this.hasListeners(), b = !h && j(e, t), m = h && L(e, s, t, r);
|
|
157
|
+
(b || m) && (n = {
|
|
156
158
|
...n,
|
|
157
159
|
...W(c.data, e.options)
|
|
158
160
|
}), t._optimisticResults === "isRestoring" && (n.fetchStatus = "idle");
|
|
159
161
|
}
|
|
160
|
-
let { error:
|
|
162
|
+
let { error: F, errorUpdatedAt: x, status: p } = n;
|
|
161
163
|
if (t.select && n.data !== void 0)
|
|
162
|
-
if (a && n.data === u?.data && t.select === this.#
|
|
164
|
+
if (a && n.data === u?.data && t.select === this.#y)
|
|
163
165
|
l = this.#l;
|
|
164
166
|
else
|
|
165
167
|
try {
|
|
166
|
-
this.#
|
|
167
|
-
} catch (
|
|
168
|
-
this.#r =
|
|
168
|
+
this.#y = t.select, l = t.select(n.data), l = M(a?.data, l, t), this.#l = l, this.#r = null;
|
|
169
|
+
} catch (h) {
|
|
170
|
+
this.#r = h;
|
|
169
171
|
}
|
|
170
172
|
else
|
|
171
173
|
l = n.data;
|
|
172
|
-
if (t.placeholderData !== void 0 && l === void 0 &&
|
|
173
|
-
let
|
|
174
|
+
if (t.placeholderData !== void 0 && l === void 0 && p === "pending") {
|
|
175
|
+
let h;
|
|
174
176
|
if (a?.isPlaceholderData && t.placeholderData === i?.placeholderData)
|
|
175
|
-
|
|
176
|
-
else if (
|
|
177
|
+
h = a.data;
|
|
178
|
+
else if (h = typeof t.placeholderData == "function" ? t.placeholderData(
|
|
177
179
|
this.#d?.state.data,
|
|
178
180
|
this.#d
|
|
179
|
-
) : t.placeholderData, t.select &&
|
|
181
|
+
) : t.placeholderData, t.select && h !== void 0)
|
|
180
182
|
try {
|
|
181
|
-
|
|
182
|
-
} catch (
|
|
183
|
-
this.#r =
|
|
183
|
+
h = t.select(h), this.#r = null;
|
|
184
|
+
} catch (b) {
|
|
185
|
+
this.#r = b;
|
|
184
186
|
}
|
|
185
|
-
|
|
187
|
+
h !== void 0 && (p = "success", l = M(
|
|
186
188
|
a?.data,
|
|
187
|
-
|
|
189
|
+
h,
|
|
188
190
|
t
|
|
189
|
-
),
|
|
191
|
+
), R = !0);
|
|
190
192
|
}
|
|
191
|
-
this.#r && (
|
|
192
|
-
const C = n.fetchStatus === "fetching", S =
|
|
193
|
-
status:
|
|
193
|
+
this.#r && (F = this.#r, l = this.#l, x = Date.now(), p = "error");
|
|
194
|
+
const C = n.fetchStatus === "fetching", S = p === "pending", E = p === "error", D = S && C, P = l !== void 0, d = {
|
|
195
|
+
status: p,
|
|
194
196
|
fetchStatus: n.fetchStatus,
|
|
195
197
|
isPending: S,
|
|
196
|
-
isSuccess:
|
|
198
|
+
isSuccess: p === "success",
|
|
197
199
|
isError: E,
|
|
198
|
-
isInitialLoading:
|
|
199
|
-
isLoading:
|
|
200
|
+
isInitialLoading: D,
|
|
201
|
+
isLoading: D,
|
|
200
202
|
data: l,
|
|
201
203
|
dataUpdatedAt: n.dataUpdatedAt,
|
|
202
|
-
error:
|
|
203
|
-
errorUpdatedAt:
|
|
204
|
+
error: F,
|
|
205
|
+
errorUpdatedAt: x,
|
|
204
206
|
failureCount: n.fetchFailureCount,
|
|
205
207
|
failureReason: n.fetchFailureReason,
|
|
206
208
|
errorUpdateCount: n.errorUpdateCount,
|
|
207
209
|
isFetched: n.dataUpdateCount > 0 || n.errorUpdateCount > 0,
|
|
208
|
-
isFetchedAfterMount: n.dataUpdateCount >
|
|
210
|
+
isFetchedAfterMount: n.dataUpdateCount > o.dataUpdateCount || n.errorUpdateCount > o.errorUpdateCount,
|
|
209
211
|
isFetching: C,
|
|
210
212
|
isRefetching: C && !S,
|
|
211
|
-
isLoadingError: E && !
|
|
213
|
+
isLoadingError: E && !P,
|
|
212
214
|
isPaused: n.fetchStatus === "paused",
|
|
213
|
-
isPlaceholderData:
|
|
214
|
-
isRefetchError: E &&
|
|
215
|
+
isPlaceholderData: R,
|
|
216
|
+
isRefetchError: E && P,
|
|
215
217
|
isStale: I(e, t),
|
|
216
218
|
refetch: this.refetch,
|
|
217
219
|
promise: this.#i
|
|
218
220
|
};
|
|
219
221
|
if (this.options.experimental_prefetchInRender) {
|
|
220
|
-
const
|
|
222
|
+
const h = (v) => {
|
|
221
223
|
d.status === "error" ? v.reject(d.error) : d.data !== void 0 && v.resolve(d.data);
|
|
222
|
-
},
|
|
224
|
+
}, b = () => {
|
|
223
225
|
const v = this.#i = d.promise = U();
|
|
224
|
-
|
|
225
|
-
},
|
|
226
|
-
switch (
|
|
226
|
+
h(v);
|
|
227
|
+
}, m = this.#i;
|
|
228
|
+
switch (m.status) {
|
|
227
229
|
case "pending":
|
|
228
|
-
e.queryHash === s.queryHash &&
|
|
230
|
+
e.queryHash === s.queryHash && h(m);
|
|
229
231
|
break;
|
|
230
232
|
case "fulfilled":
|
|
231
|
-
(d.status === "error" || d.data !==
|
|
233
|
+
(d.status === "error" || d.data !== m.value) && b();
|
|
232
234
|
break;
|
|
233
235
|
case "rejected":
|
|
234
|
-
(d.status !== "error" || d.error !==
|
|
236
|
+
(d.status !== "error" || d.error !== m.reason) && b();
|
|
235
237
|
break;
|
|
236
238
|
}
|
|
237
239
|
}
|
|
@@ -251,8 +253,8 @@ var $ = class extends N {
|
|
|
251
253
|
const g = new Set(
|
|
252
254
|
i ?? this.#f
|
|
253
255
|
);
|
|
254
|
-
return this.options.throwOnError && g.add("error"), Object.keys(this.#t).some((
|
|
255
|
-
const c =
|
|
256
|
+
return this.options.throwOnError && g.add("error"), Object.keys(this.#t).some((o) => {
|
|
257
|
+
const c = o;
|
|
256
258
|
return this.#t[c] !== t[c] && g.has(c);
|
|
257
259
|
});
|
|
258
260
|
};
|
|
@@ -266,10 +268,10 @@ var $ = class extends N {
|
|
|
266
268
|
this.#e = e, this.#p = e.state, this.hasListeners() && (t?.removeObserver(this), e.addObserver(this));
|
|
267
269
|
}
|
|
268
270
|
onQueryUpdate() {
|
|
269
|
-
this.updateResult(), this.hasListeners() && this.#
|
|
271
|
+
this.updateResult(), this.hasListeners() && this.#R();
|
|
270
272
|
}
|
|
271
273
|
#S(e) {
|
|
272
|
-
|
|
274
|
+
A.batch(() => {
|
|
273
275
|
e.listeners && this.listeners.forEach((t) => {
|
|
274
276
|
t(this.#t);
|
|
275
277
|
}), this.#s.getQueryCache().notify({
|
|
@@ -279,11 +281,11 @@ var $ = class extends N {
|
|
|
279
281
|
});
|
|
280
282
|
}
|
|
281
283
|
};
|
|
282
|
-
function
|
|
284
|
+
function J(e, t) {
|
|
283
285
|
return f(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
|
|
284
286
|
}
|
|
285
|
-
function
|
|
286
|
-
return
|
|
287
|
+
function j(e, t) {
|
|
288
|
+
return J(e, t) || e.state.data !== void 0 && T(e, t, t.refetchOnMount);
|
|
287
289
|
}
|
|
288
290
|
function T(e, t, s) {
|
|
289
291
|
if (f(t.enabled, e) !== !1) {
|
|
@@ -298,11 +300,9 @@ function L(e, t, s, r) {
|
|
|
298
300
|
function I(e, t) {
|
|
299
301
|
return f(t.enabled, e) !== !1 && e.isStaleByTime(O(t.staleTime, e));
|
|
300
302
|
}
|
|
301
|
-
function
|
|
303
|
+
function X(e, t) {
|
|
302
304
|
return !w(e.getCurrentResult(), t);
|
|
303
305
|
}
|
|
304
|
-
var H = p.createContext(!1), X = () => p.useContext(H);
|
|
305
|
-
H.Provider;
|
|
306
306
|
function Y() {
|
|
307
307
|
let e = !1;
|
|
308
308
|
return {
|
|
@@ -315,28 +315,22 @@ function Y() {
|
|
|
315
315
|
isReset: () => e
|
|
316
316
|
};
|
|
317
317
|
}
|
|
318
|
-
var Z =
|
|
319
|
-
function te(e, t) {
|
|
320
|
-
return typeof e == "function" ? e(...t) : !!e;
|
|
321
|
-
}
|
|
322
|
-
function j() {
|
|
323
|
-
}
|
|
324
|
-
var se = (e, t) => {
|
|
318
|
+
var Z = y.createContext(Y()), ee = () => y.useContext(Z), te = (e, t) => {
|
|
325
319
|
(e.suspense || e.throwOnError || e.experimental_prefetchInRender) && (t.isReset() || (e.retryOnMount = !1));
|
|
326
|
-
},
|
|
327
|
-
|
|
320
|
+
}, se = (e) => {
|
|
321
|
+
y.useEffect(() => {
|
|
328
322
|
e.clearReset();
|
|
329
323
|
}, [e]);
|
|
330
|
-
},
|
|
324
|
+
}, re = ({
|
|
331
325
|
result: e,
|
|
332
326
|
errorResetBoundary: t,
|
|
333
327
|
throwOnError: s,
|
|
334
328
|
query: r,
|
|
335
329
|
suspense: a
|
|
336
|
-
}) => e.isError && !t.isReset() && !e.isFetching && r && (a && e.data === void 0 ||
|
|
330
|
+
}) => e.isError && !t.isReset() && !e.isFetching && r && (a && e.data === void 0 || K(s, [e.error, r])), ie = (e) => {
|
|
337
331
|
const t = e.staleTime;
|
|
338
332
|
e.suspense && (e.staleTime = typeof t == "function" ? (...s) => Math.max(t(...s), 1e3) : Math.max(t ?? 1e3, 1e3), typeof e.gcTime == "number" && (e.gcTime = Math.max(e.gcTime, 1e3)));
|
|
339
|
-
},
|
|
333
|
+
}, ne = (e, t) => e.isLoading && e.isFetching && !t, ae = (e, t) => e?.suspense && t.isPending, q = (e, t, s) => t.fetchOptimistic(e).catch(() => {
|
|
340
334
|
s.clearReset();
|
|
341
335
|
});
|
|
342
336
|
function oe(e, t, s) {
|
|
@@ -344,31 +338,33 @@ function oe(e, t, s) {
|
|
|
344
338
|
throw new Error(
|
|
345
339
|
'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'
|
|
346
340
|
);
|
|
347
|
-
const r =
|
|
341
|
+
const r = z(s), a = $(), u = ee(), i = r.defaultQueryOptions(e);
|
|
348
342
|
r.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
349
343
|
i
|
|
350
|
-
),
|
|
351
|
-
|
|
344
|
+
), process.env.NODE_ENV !== "production" && (i.queryFn || console.error(
|
|
345
|
+
`[${i.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`
|
|
346
|
+
)), i._optimisticResults = a ? "isRestoring" : "optimistic", ie(i), te(i, u), se(u);
|
|
347
|
+
const g = !r.getQueryCache().get(i.queryHash), [o] = y.useState(
|
|
352
348
|
() => new t(
|
|
353
349
|
r,
|
|
354
350
|
i
|
|
355
351
|
)
|
|
356
|
-
), c =
|
|
357
|
-
if (
|
|
358
|
-
|
|
359
|
-
(
|
|
360
|
-
const l = n ?
|
|
361
|
-
return
|
|
352
|
+
), c = o.getOptimisticResult(i), n = !a && e.subscribed !== !1;
|
|
353
|
+
if (y.useSyncExternalStore(
|
|
354
|
+
y.useCallback(
|
|
355
|
+
(R) => {
|
|
356
|
+
const l = n ? o.subscribe(A.batchCalls(R)) : _;
|
|
357
|
+
return o.updateResult(), l;
|
|
362
358
|
},
|
|
363
|
-
[
|
|
359
|
+
[o, n]
|
|
364
360
|
),
|
|
365
|
-
() =>
|
|
366
|
-
() =>
|
|
367
|
-
),
|
|
368
|
-
|
|
369
|
-
}, [i,
|
|
370
|
-
throw
|
|
371
|
-
if (
|
|
361
|
+
() => o.getCurrentResult(),
|
|
362
|
+
() => o.getCurrentResult()
|
|
363
|
+
), y.useEffect(() => {
|
|
364
|
+
o.setOptions(i, { listeners: !1 });
|
|
365
|
+
}, [i, o]), ae(i, c))
|
|
366
|
+
throw q(i, o, u);
|
|
367
|
+
if (re({
|
|
372
368
|
result: c,
|
|
373
369
|
errorResetBoundary: u,
|
|
374
370
|
throwOnError: i.throwOnError,
|
|
@@ -379,19 +375,21 @@ function oe(e, t, s) {
|
|
|
379
375
|
return r.getDefaultOptions().queries?._experimental_afterQuery?.(
|
|
380
376
|
i,
|
|
381
377
|
c
|
|
382
|
-
), i.experimental_prefetchInRender && !Q &&
|
|
378
|
+
), i.experimental_prefetchInRender && !Q && ne(c, a) && (g ? (
|
|
383
379
|
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
384
|
-
|
|
380
|
+
q(i, o, u)
|
|
385
381
|
) : (
|
|
386
382
|
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
387
383
|
r.getQueryCache().get(i.queryHash)?.promise
|
|
388
|
-
))?.catch(
|
|
389
|
-
|
|
390
|
-
}), i.notifyOnChangeProps ? c :
|
|
384
|
+
))?.catch(_).finally(() => {
|
|
385
|
+
o.updateResult();
|
|
386
|
+
}), i.notifyOnChangeProps ? c : o.trackResult(c);
|
|
391
387
|
}
|
|
392
|
-
function
|
|
393
|
-
return oe(e,
|
|
388
|
+
function fe(e, t) {
|
|
389
|
+
return oe(e, G, t);
|
|
394
390
|
}
|
|
395
391
|
export {
|
|
396
|
-
|
|
392
|
+
G as Q,
|
|
393
|
+
oe as a,
|
|
394
|
+
fe as u
|
|
397
395
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { a as u, f as m, i as S, b as I } from "../api-s6E2GJtu.js";
|
|
2
|
+
import { useBasePropsStore as t } from "../stores/BasePropsStore.js";
|
|
3
|
+
const E = (s, e, g, o, r, n = !1) => {
|
|
4
|
+
const a = n ? void 0 : o ?? t.getState().modulePermissionToken, i = t.getState().organizationId, c = t.getState().currentLanguageId, d = t.getState().throwError;
|
|
5
|
+
if (!n && !a)
|
|
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;
|
|
11
|
+
if (!o && !r)
|
|
12
|
+
return i?.("No token found", 404), Promise.reject();
|
|
13
|
+
const c = u(r, n, a), d = S(e) ? "" : I(e);
|
|
14
|
+
return m(`${s}${d}`, c);
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
h as baseFetch,
|
|
18
|
+
E as baseMutation
|
|
19
|
+
};
|
package/dist/utils/fetches.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../
|
|
3
|
-
import "
|
|
4
|
-
|
|
1
|
+
import { useBasePropsStore as a } from "../stores/BasePropsStore.js";
|
|
2
|
+
import { useEnvironmentStore as i } from "../stores/EnvironmentStore.js";
|
|
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}`, {}, t, n), r = (e) => {
|
|
5
|
+
const t = i.getState().environment, n = a.getState().organizationId;
|
|
6
|
+
return o(
|
|
7
|
+
`${t?.MODULE_AUTH_API}${t?.API_PREFIX}/${n}/${e}`,
|
|
8
|
+
{}
|
|
9
|
+
);
|
|
10
|
+
}, f = (e) => {
|
|
11
|
+
const t = i.getState().environment;
|
|
12
|
+
return o(`${t?.COMMON_API}${t?.API_PREFIX}/${e}`, {});
|
|
13
|
+
};
|
|
5
14
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
d as getFarmOrgEntities,
|
|
14
|
-
g as getModuleDependedEntities,
|
|
15
|
-
c as handleResponse
|
|
15
|
+
f as fetchFromCommonApi,
|
|
16
|
+
M as fetchFromCustomApi,
|
|
17
|
+
r as fetchFromModuleApi,
|
|
18
|
+
g as getFarmOrgEntities,
|
|
19
|
+
E as getModuleDependedEntities,
|
|
20
|
+
A as getModuleDependedEntitiesRaw,
|
|
21
|
+
I as mutateOnCustomApi
|
|
16
22
|
};
|