@hortiview/modulebase 0.0.12628 → 0.0.13100-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/dist/ModuleCore-YCIFN_02.js +14973 -0
- package/dist/{QueryClientProvider-Q_mWQTzQ.js → QueryClientProvider-Beog9TR7.js} +39 -37
- package/dist/{_baseGet-B7FwMMGI.js → _baseGet-C6jMXSsQ.js} +447 -447
- package/dist/{api-D9Lmqe6S.js → api-s6E2GJtu.js} +48 -48
- package/dist/assets/ModuleCore.css +1 -0
- package/dist/components/ModuleBase.js +17 -498
- package/dist/components/ModuleCore.js +10 -0
- package/dist/hooks/useCustom.js +15 -18
- package/dist/hooks/useCustomMutation.js +14 -12
- package/dist/hooks/useEntity.js +51 -58
- package/dist/hooks/useOffline.js +45 -0
- package/dist/hooks/useOption.js +16 -16
- package/dist/hooks/useServiceBus.js +19 -11
- package/dist/hooks/useStores.js +1 -1
- package/dist/{query-CRIVoEP7.js → isRestoring-CLuxJVSA.js} +21 -17
- 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}/useCustom.d.ts +2 -1
- package/dist/{hooks → lib/hooks}/useCustomMutation.d.ts +2 -1
- package/dist/{hooks → lib/hooks}/useEntity.d.ts +6 -24
- package/dist/lib/hooks/useOffline.d.ts +15 -0
- package/dist/{hooks → lib/hooks}/useServiceBus.d.ts +6 -2
- package/dist/lib/hooks/useStores.d.ts +37 -0
- package/dist/lib/main.d.ts +27 -0
- package/dist/lib/types/ActionStorage.d.ts +13 -0
- package/dist/{types → lib/types}/BaseProps.d.ts +10 -2
- package/dist/{types → lib/types}/Deprecated.d.ts +6 -0
- package/dist/lib/types/Entities.d.ts +22 -0
- package/dist/{types → lib/types}/Environment.d.ts +1 -1
- package/dist/lib/types/EnvironmentVariable.d.ts +6 -0
- package/dist/{types → lib/types}/ModuleApi.d.ts +5 -5
- package/dist/{types → lib/types}/Requests.d.ts +4 -10
- package/dist/{utils → lib/utils}/api.d.ts +1 -1
- package/dist/{utils → lib/utils}/baseFetches.d.ts +2 -2
- package/dist/{utils → lib/utils}/fetches.d.ts +14 -6
- package/dist/lib/utils/helper.d.ts +29 -0
- package/dist/main.js +215 -133
- package/dist/{mutation-X73nm7Df.js → mutation-DSKlaYzY.js} +1 -1
- package/dist/{omit-B7MWDtHq.js → omit-C9Qe80rl.js} +1 -1
- package/dist/stores/EnvironmentStore.js +3 -2
- package/dist/types/ActionStorage.js +4 -0
- package/dist/types/Entities.js +25 -0
- package/dist/types/Environment.js +1 -4
- package/dist/types/EnvironmentVariable.js +1 -0
- package/dist/types/Requests.js +1 -4
- package/dist/{useMutation-3rykrmeD.js → useMutation-zu8uxBak.js} +16 -16
- package/dist/{useQuery-CwwWze9O.js → useQuery-Bj9k9zik.js} +47 -47
- package/dist/utils/api.js +1 -1
- package/dist/utils/baseFetches.js +15 -15
- package/dist/utils/fetches.js +14 -13
- package/dist/utils/helper.js +55 -0
- package/package.json +7 -2
- package/dist/components/ModuleBase.d.ts +0 -11
- package/dist/hooks/useStores.d.ts +0 -30
- package/dist/main.d.ts +0 -13
- /package/dist/{hooks → lib/hooks}/useBreadcrumbTranslation.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useOption.d.ts +0 -0
- /package/dist/{hooks → lib/hooks}/useSignalRMessages.d.ts +0 -0
- /package/dist/{module-router.d.ts → lib/module-router.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/{stores → lib/stores}/EnvironmentStore.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}/ServiceBus.d.ts +0 -0
- /package/dist/{types → lib/types}/SystemMessage.d.ts +0 -0
package/dist/hooks/useEntity.js
CHANGED
|
@@ -1,64 +1,57 @@
|
|
|
1
|
-
import { u as l } from "../useQuery-
|
|
2
|
-
import { useMemo as g } from "react";
|
|
1
|
+
import { u as l } from "../useQuery-Bj9k9zik.js";
|
|
2
|
+
import { useMemo as M, useCallback as g } from "react";
|
|
3
3
|
import { useBasePropsStore as p } from "../stores/BasePropsStore.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { useOption as E, useModuleDependency as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
farm_organizations: "farmOrg",
|
|
13
|
-
alert_rules: "farmAlertRule"
|
|
14
|
-
}, Q = {
|
|
15
|
-
farm_members: "member"
|
|
16
|
-
}, q = {
|
|
17
|
-
Season: "season",
|
|
18
|
-
BlockPlantLayout: "blockPlantLayout"
|
|
19
|
-
}, A = {
|
|
20
|
-
...F,
|
|
21
|
-
...Q,
|
|
22
|
-
...q
|
|
23
|
-
}, K = (e, t, a = !0) => {
|
|
24
|
-
const o = p((r) => r.moduleId), d = p((r) => r.organizationId), { data: u } = E("DataAreaGroup"), { data: i } = E("DataAreaEntity"), { data: n } = D(e === "ModuleDepended"), m = e === "ModuleDepended", M = g(() => {
|
|
25
|
-
if (m)
|
|
26
|
-
return n ? n.find((s) => s.registeredEntityName === t)?.id : void 0;
|
|
27
|
-
if (!u || !i) return;
|
|
28
|
-
const r = u.find((s) => s.key === e)?.id;
|
|
29
|
-
return r ? i.find((s) => s.description === r && s.value === t)?.id : void 0;
|
|
30
|
-
}, [m, u, i, n, t, e]), f = O(
|
|
4
|
+
import { getModuleDependedEntitiesRaw as Q, getModuleDependedEntities as A, getFarmOrgEntities as D } from "../utils/fetches.js";
|
|
5
|
+
import { getModuleQueryKey as m, universalSelector as y } from "../utils/helper.js";
|
|
6
|
+
import { useOption as E, useModuleDependency as q } from "./useOption.js";
|
|
7
|
+
import { AllEntitiesTypeResultMap as k } from "../types/Entities.js";
|
|
8
|
+
const N = (t, e, u = !0, n = !1) => {
|
|
9
|
+
const a = p((i) => i.moduleId), o = p((i) => i.organizationId), s = t === "ModuleDepended", { getEntityId: d } = K(t), r = F(
|
|
10
|
+
a,
|
|
11
|
+
d(e),
|
|
31
12
|
o,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
13
|
+
s,
|
|
14
|
+
n,
|
|
15
|
+
u
|
|
16
|
+
);
|
|
17
|
+
return M(() => {
|
|
18
|
+
const i = (r.data ?? []).map((c) => {
|
|
19
|
+
const f = k[e];
|
|
20
|
+
return s && n ? c : c[f];
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
...r,
|
|
24
|
+
data: i
|
|
25
|
+
};
|
|
26
|
+
}, [e, r, s, n]);
|
|
27
|
+
}, F = (t, e, u, n, a, o = !0) => {
|
|
28
|
+
const s = l({
|
|
29
|
+
queryKey: m([e]),
|
|
30
|
+
queryFn: () => a ? Q(t ?? "", e ?? "") : A(t ?? "", e ?? ""),
|
|
31
|
+
enabled: o && n && !!t && !!e && !!u,
|
|
32
|
+
select: (r) => y(r)
|
|
33
|
+
}), d = l({
|
|
34
|
+
queryKey: m([e]),
|
|
35
|
+
queryFn: () => D(t ?? "", e ?? ""),
|
|
36
|
+
enabled: o && !n && !!t && !!e && !!u,
|
|
37
|
+
select: (r) => y(r)
|
|
39
38
|
});
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
select: (n) => y(n)
|
|
55
|
-
});
|
|
56
|
-
return o ? u : i;
|
|
39
|
+
return n ? s : d;
|
|
40
|
+
}, K = (t) => {
|
|
41
|
+
const { data: e } = E("DataAreaGroup"), { data: u } = E("DataAreaEntity"), { data: n } = q(t === "ModuleDepended");
|
|
42
|
+
return { getEntityId: g(
|
|
43
|
+
(o) => {
|
|
44
|
+
if (t === "ModuleDepended")
|
|
45
|
+
return n ? n.find((r) => r.registeredEntityName === o)?.id : void 0;
|
|
46
|
+
if (!e || !u) return;
|
|
47
|
+
const d = e.find((r) => r.key === t)?.id;
|
|
48
|
+
if (d)
|
|
49
|
+
return u.find((r) => r.description === d && r.value === o)?.id;
|
|
50
|
+
},
|
|
51
|
+
[t, e, u, n]
|
|
52
|
+
) };
|
|
57
53
|
};
|
|
58
54
|
export {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
F as FarmOrgEntitiesTypeResultMap,
|
|
62
|
-
q as ModuleDependedEntityTypeResultMap,
|
|
63
|
-
K as useEntity
|
|
55
|
+
N as useEntity,
|
|
56
|
+
K as useEntityId
|
|
64
57
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { u as f } from "../QueryClientProvider-Beog9TR7.js";
|
|
2
|
+
import { fetchFromCustomApi as i, getFarmOrgEntities as c, getModuleDependedEntities as m } from "../utils/fetches.js";
|
|
3
|
+
import { getModuleQueryKey as o } from "../utils/helper.js";
|
|
4
|
+
import { useBasePropsStore as p } from "../stores/BasePropsStore.js";
|
|
5
|
+
import { useEntityId as d } from "./useEntity.js";
|
|
6
|
+
const I = () => {
|
|
7
|
+
const { moduleId: n } = p(), u = f();
|
|
8
|
+
return {
|
|
9
|
+
prefetchCustom: async ({
|
|
10
|
+
queryKey: e,
|
|
11
|
+
endpoint: t,
|
|
12
|
+
token: s,
|
|
13
|
+
noAuth: y = !1
|
|
14
|
+
}) => {
|
|
15
|
+
await u.prefetchQuery({
|
|
16
|
+
queryKey: o(e),
|
|
17
|
+
queryFn: () => i(t, s, y)
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
prefetch: ({
|
|
21
|
+
queryKey: e,
|
|
22
|
+
queryFn: t
|
|
23
|
+
}) => u.prefetchQuery({
|
|
24
|
+
queryKey: o(e),
|
|
25
|
+
queryFn: t
|
|
26
|
+
}),
|
|
27
|
+
usePrefetchEntity: (e, ...t) => {
|
|
28
|
+
const { getEntityId: s } = d(e);
|
|
29
|
+
if (!n) return "Prefetch failed: no moduleId";
|
|
30
|
+
t.forEach(async (y) => {
|
|
31
|
+
const r = s(y);
|
|
32
|
+
r && (e !== "ModuleDepended" ? await u.prefetchQuery({
|
|
33
|
+
queryKey: o([r]),
|
|
34
|
+
queryFn: () => c(n, r)
|
|
35
|
+
}) : await u.prefetchQuery({
|
|
36
|
+
queryKey: o([r]),
|
|
37
|
+
queryFn: () => m(n, r)
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
I as useOffline
|
|
45
|
+
};
|
package/dist/hooks/useOption.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { u as m } from "../useQuery-
|
|
2
|
-
import { g as u } from "../api-
|
|
1
|
+
import { u as m } from "../useQuery-Bj9k9zik.js";
|
|
2
|
+
import { g as u } from "../api-s6E2GJtu.js";
|
|
3
3
|
import { useBasePropsStore as n } from "../stores/BasePropsStore.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
7
|
-
const r = n((
|
|
4
|
+
import { fetchFromModuleApi as c, fetchFromCommonApi as i } from "../utils/fetches.js";
|
|
5
|
+
import { getModuleQueryKey as p, universalSelector as s } from "../utils/helper.js";
|
|
6
|
+
const q = (o) => {
|
|
7
|
+
const r = n((t) => t.commonOptions), e = u(r, o);
|
|
8
8
|
return m({
|
|
9
|
-
queryKey: [
|
|
10
|
-
queryFn: () =>
|
|
11
|
-
select: (
|
|
9
|
+
queryKey: [o],
|
|
10
|
+
queryFn: () => e ? Promise.resolve(e) : i(`${o}/dropdown`),
|
|
11
|
+
select: (t) => s(t)
|
|
12
12
|
});
|
|
13
|
-
},
|
|
14
|
-
const r = n((
|
|
13
|
+
}, F = (o = !0) => {
|
|
14
|
+
const r = n((e) => e.moduleId);
|
|
15
15
|
return m({
|
|
16
|
-
queryKey: [
|
|
16
|
+
queryKey: p([]),
|
|
17
17
|
queryFn: () => c(`ModuleDependencies/${r}`),
|
|
18
|
-
select: (
|
|
19
|
-
enabled:
|
|
18
|
+
select: (e) => s(e),
|
|
19
|
+
enabled: o
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
F as useModuleDependency,
|
|
24
|
+
q as useOption
|
|
25
25
|
};
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import { u } from "../useMutation-
|
|
2
|
-
import { useBasePropsStore as
|
|
3
|
-
const
|
|
1
|
+
import { u as n } from "../useMutation-zu8uxBak.js";
|
|
2
|
+
import { useBasePropsStore as r } from "../stores/BasePropsStore.js";
|
|
3
|
+
const a = ({
|
|
4
4
|
authenticationKey: i,
|
|
5
|
-
queue:
|
|
6
|
-
topic:
|
|
5
|
+
queue: s,
|
|
6
|
+
topic: o
|
|
7
7
|
}) => {
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
10
|
-
throw
|
|
11
|
-
return
|
|
12
|
-
mutationFn: (
|
|
8
|
+
const e = r((t) => t.serviceBusNotification), c = r((t) => t.throwError);
|
|
9
|
+
if (!e)
|
|
10
|
+
throw c?.("serviceBusNotification is not defined", 400);
|
|
11
|
+
return n({
|
|
12
|
+
mutationFn: (t) => e(t, i, s, o)
|
|
13
|
+
});
|
|
14
|
+
}, N = () => {
|
|
15
|
+
const i = r((o) => o.riseNotification), s = r((o) => o.throwError);
|
|
16
|
+
if (!i)
|
|
17
|
+
throw s?.("riseNotification is not defined", 400);
|
|
18
|
+
return n({
|
|
19
|
+
mutationFn: (o) => i(o)
|
|
13
20
|
});
|
|
14
21
|
};
|
|
15
22
|
export {
|
|
16
|
-
|
|
23
|
+
N as useNotification,
|
|
24
|
+
a as useServiceBus
|
|
17
25
|
};
|
package/dist/hooks/useStores.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { R as
|
|
2
|
-
|
|
1
|
+
import { R as f, r as p, a as u, b as y, d as v, t as b, c as m, n as C, e as g, i as h, f as S } from "./QueryClientProvider-Beog9TR7.js";
|
|
2
|
+
import * as c from "react";
|
|
3
|
+
var D = class extends f {
|
|
3
4
|
#a;
|
|
4
5
|
#n;
|
|
5
6
|
#e;
|
|
@@ -8,7 +9,7 @@ var q = class extends d {
|
|
|
8
9
|
#o;
|
|
9
10
|
#r;
|
|
10
11
|
constructor(t) {
|
|
11
|
-
super(), this.#r = !1, this.#o = t.defaultOptions, this.setOptions(t.options), this.observers = [], this.#i = t.client, this.#e = this.#i.getQueryCache(), this.queryKey = t.queryKey, this.queryHash = t.queryHash, this.#a =
|
|
12
|
+
super(), this.#r = !1, this.#o = t.defaultOptions, this.setOptions(t.options), this.observers = [], this.#i = t.client, this.#e = this.#i.getQueryCache(), this.queryKey = t.queryKey, this.queryHash = t.queryHash, this.#a = q(this.options), this.state = t.state ?? this.#a, this.scheduleGc();
|
|
12
13
|
}
|
|
13
14
|
get meta() {
|
|
14
15
|
return this.options.meta;
|
|
@@ -23,7 +24,7 @@ var q = class extends d {
|
|
|
23
24
|
!this.observers.length && this.state.fetchStatus === "idle" && this.#e.remove(this);
|
|
24
25
|
}
|
|
25
26
|
setData(t, e) {
|
|
26
|
-
const s =
|
|
27
|
+
const s = p(this.state.data, t, this.options);
|
|
27
28
|
return this.#s({
|
|
28
29
|
data: s,
|
|
29
30
|
type: "success",
|
|
@@ -46,11 +47,11 @@ var q = class extends d {
|
|
|
46
47
|
}
|
|
47
48
|
isActive() {
|
|
48
49
|
return this.observers.some(
|
|
49
|
-
(t) =>
|
|
50
|
+
(t) => y(t.options.enabled, this) !== !1
|
|
50
51
|
);
|
|
51
52
|
}
|
|
52
53
|
isDisabled() {
|
|
53
|
-
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn ===
|
|
54
|
+
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === v || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
|
|
54
55
|
}
|
|
55
56
|
isStale() {
|
|
56
57
|
return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
|
|
@@ -58,7 +59,7 @@ var q = class extends d {
|
|
|
58
59
|
) : this.state.data === void 0;
|
|
59
60
|
}
|
|
60
61
|
isStaleByTime(t = 0) {
|
|
61
|
-
return this.state.isInvalidated || this.state.data === void 0 || !
|
|
62
|
+
return this.state.isInvalidated || this.state.data === void 0 || !b(this.state.dataUpdatedAt, t);
|
|
62
63
|
}
|
|
63
64
|
onFocus() {
|
|
64
65
|
this.observers.find((e) => e.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
|
|
@@ -97,8 +98,8 @@ var q = class extends d {
|
|
|
97
98
|
enumerable: !0,
|
|
98
99
|
get: () => (this.#r = !0, s.signal)
|
|
99
100
|
});
|
|
100
|
-
},
|
|
101
|
-
const i =
|
|
101
|
+
}, l = () => {
|
|
102
|
+
const i = g(this.options, e), a = {
|
|
102
103
|
client: this.#i,
|
|
103
104
|
queryKey: this.queryKey,
|
|
104
105
|
meta: this.meta
|
|
@@ -114,7 +115,7 @@ var q = class extends d {
|
|
|
114
115
|
queryKey: this.queryKey,
|
|
115
116
|
client: this.#i,
|
|
116
117
|
state: this.state,
|
|
117
|
-
fetchFn:
|
|
118
|
+
fetchFn: l
|
|
118
119
|
};
|
|
119
120
|
r(n), this.options.behavior?.onFetch(
|
|
120
121
|
n,
|
|
@@ -133,7 +134,7 @@ var q = class extends d {
|
|
|
133
134
|
this
|
|
134
135
|
)), this.scheduleGc();
|
|
135
136
|
};
|
|
136
|
-
return this.#t =
|
|
137
|
+
return this.#t = m({
|
|
137
138
|
initialPromise: e?.initialPromise,
|
|
138
139
|
fn: n.fetchFn,
|
|
139
140
|
abort: s.abort.bind(s),
|
|
@@ -194,7 +195,7 @@ var q = class extends d {
|
|
|
194
195
|
case "fetch":
|
|
195
196
|
return {
|
|
196
197
|
...s,
|
|
197
|
-
...
|
|
198
|
+
...F(s.data, this.options),
|
|
198
199
|
fetchMeta: t.meta ?? null
|
|
199
200
|
};
|
|
200
201
|
case "success":
|
|
@@ -236,14 +237,14 @@ var q = class extends d {
|
|
|
236
237
|
};
|
|
237
238
|
}
|
|
238
239
|
};
|
|
239
|
-
this.state = e(this.state),
|
|
240
|
+
this.state = e(this.state), C.batch(() => {
|
|
240
241
|
this.observers.forEach((s) => {
|
|
241
242
|
s.onQueryUpdate();
|
|
242
243
|
}), this.#e.notify({ query: this, type: "updated", action: t });
|
|
243
244
|
});
|
|
244
245
|
}
|
|
245
246
|
};
|
|
246
|
-
function
|
|
247
|
+
function F(t, e) {
|
|
247
248
|
return {
|
|
248
249
|
fetchFailureCount: 0,
|
|
249
250
|
fetchFailureReason: null,
|
|
@@ -254,7 +255,7 @@ function C(t, e) {
|
|
|
254
255
|
}
|
|
255
256
|
};
|
|
256
257
|
}
|
|
257
|
-
function
|
|
258
|
+
function q(t) {
|
|
258
259
|
const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, s = e !== void 0, r = s ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
|
|
259
260
|
return {
|
|
260
261
|
data: e,
|
|
@@ -271,7 +272,10 @@ function F(t) {
|
|
|
271
272
|
fetchStatus: "idle"
|
|
272
273
|
};
|
|
273
274
|
}
|
|
275
|
+
var d = c.createContext(!1), R = () => c.useContext(d), U = d.Provider;
|
|
274
276
|
export {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
+
U as I,
|
|
278
|
+
D as Q,
|
|
279
|
+
F as f,
|
|
280
|
+
R as u
|
|
277
281
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { RouteObject } from 'react-router';
|
|
3
|
+
import { BaseProps } from '../types/BaseProps';
|
|
4
|
+
import { EnvConfig } from '../types/Environment';
|
|
5
|
+
type ModuleBaseProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Properties that are passed to the Base component by the host application, {@link BaseProps}
|
|
8
|
+
*/
|
|
9
|
+
props: BaseProps;
|
|
10
|
+
/**
|
|
11
|
+
* Routes that are used in the module, {@link RouteObject}
|
|
12
|
+
*/
|
|
13
|
+
routes: RouteObject[];
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated
|
|
16
|
+
* Environment configuration that is used to configure the module, {@link EnvConfig}.
|
|
17
|
+
* New way to pass environment variables is through the base props:
|
|
18
|
+
* Setup the environment variables in the host application (module edit in the vendor section).
|
|
19
|
+
* They are then passed to the module within the base props.
|
|
20
|
+
*/
|
|
21
|
+
env?: EnvConfig;
|
|
22
|
+
/**
|
|
23
|
+
* If true, the module will use the SignalR provider to connect to the module API.
|
|
24
|
+
*/
|
|
25
|
+
useSignalR?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Query client that is used to provide the module with a query client, {@link QueryClient}.
|
|
28
|
+
* If not provided, the default query client will be used.
|
|
29
|
+
*/
|
|
30
|
+
queryClient?: QueryClient;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Main component of the module. This component is used to create a module with a router and a signalR provider.
|
|
34
|
+
*/
|
|
35
|
+
export declare const ModuleBase: ({ props, routes, env, useSignalR, queryClient, }: ModuleBaseProps) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { BaseProps } from '../types/BaseProps';
|
|
3
|
+
import { EnvConfig } from '../types/Environment';
|
|
4
|
+
export declare const ModuleQueryClient: QueryClient;
|
|
5
|
+
type ModuleCoreProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Properties that are passed to the Base component by the host application, {@link BaseProps}
|
|
8
|
+
*/
|
|
9
|
+
props: BaseProps;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated
|
|
12
|
+
* Environment configuration that is used to configure the module, {@link EnvConfig}.
|
|
13
|
+
* New way to pass environment variables is through the base props:
|
|
14
|
+
* Setup the environment variables in the host application (module edit in the vendor section).
|
|
15
|
+
* They are then passed to the module within the base props.
|
|
16
|
+
*/
|
|
17
|
+
env?: EnvConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Query client that is used to provide the module with a query client, {@link QueryClient}.
|
|
20
|
+
* If not provided, the default query client will be used.
|
|
21
|
+
*/
|
|
22
|
+
queryClient?: QueryClient;
|
|
23
|
+
/**
|
|
24
|
+
* Children components that are rendered within the module core
|
|
25
|
+
*/
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Minimal component to create a module with a query client and a signalR provider (to use module api)
|
|
30
|
+
*/
|
|
31
|
+
export declare const ModuleCore: ({ props, env, queryClient, children, }: ModuleCoreProps) => import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare const useCustom: <T>({ endpoint, queryKey, token, selector, enabled }: {
|
|
1
|
+
export declare const useCustom: <T>({ endpoint, queryKey, token, selector, enabled, noAuth }: {
|
|
2
2
|
endpoint: string;
|
|
3
3
|
queryKey: (string | undefined)[];
|
|
4
4
|
token?: string;
|
|
5
5
|
selector?: (data: any) => T;
|
|
6
6
|
enabled?: boolean;
|
|
7
|
+
noAuth?: boolean;
|
|
7
8
|
}) => import('@tanstack/react-query').UseQueryResult<T, Error>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { UseMutationResult } from '@tanstack/react-query';
|
|
2
2
|
import { BaseResponse, httpMethod } from '../types/Requests';
|
|
3
|
-
export declare const useCustomMutation: <Input, Output>({ endpoint, method, token, headers, }: {
|
|
3
|
+
export declare const useCustomMutation: <Input, Output>({ endpoint, method, token, headers, noAuth }: {
|
|
4
4
|
endpoint: string;
|
|
5
5
|
method: Omit<httpMethod, "GET">;
|
|
6
6
|
token?: string;
|
|
7
7
|
headers?: Headers;
|
|
8
|
+
noAuth?: boolean;
|
|
8
9
|
}) => UseMutationResult<BaseResponse<Output>, Error, Input, unknown>;
|
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type FarmOrganizationEntities = 'farms' | 'fields' | 'zones' | 'irrigation_stations' | 'farm_organizations' | 'alert_rules';
|
|
5
|
-
type FarmMemberEntities = 'farm_members';
|
|
6
|
-
type ModuleDependendEntities = 'Season' | 'BlockPlantLayout' | (string & {});
|
|
7
|
-
type HortiviewDataAreaEntity<T extends HortiviewDataAreaGroup | ModuleDataAreaGroup> = T extends 'FarmOrganization' ? FarmOrganizationEntities : T extends 'FarmMember' ? FarmMemberEntities : T extends 'ModuleDepended' ? ModuleDependendEntities : never;
|
|
8
|
-
type ResultMap<T extends FarmMemberEntities | FarmOrganizationEntities | ModuleDependendEntities> = T extends 'zones' ? Block : T extends 'fields' ? Field : T extends 'farms' ? Farm : T extends 'irrigation_stations' ? IrrigationStation : T extends 'farm_organizations' ? FarmOrganization : T extends 'alert_rules' ? FarmAlertRule : T extends 'Season' ? Season : T extends 'BlockPlantLayout' ? BlockPlantLayout : unknown;
|
|
9
|
-
export declare const FarmOrgEntitiesTypeResultMap: Record<FarmOrganizationEntities, string>;
|
|
10
|
-
export declare const FarmMemberEntitiesTypeResultMap: Record<FarmMemberEntities, string>;
|
|
11
|
-
export declare const ModuleDependedEntityTypeResultMap: Record<ModuleDependendEntities, string>;
|
|
12
|
-
export declare const AllEntitiesTypeResultMap: {
|
|
13
|
-
Season: string;
|
|
14
|
-
BlockPlantLayout: string;
|
|
15
|
-
farm_members: string;
|
|
16
|
-
farms: string;
|
|
17
|
-
fields: string;
|
|
18
|
-
zones: string;
|
|
19
|
-
irrigation_stations: string;
|
|
20
|
-
farm_organizations: string;
|
|
21
|
-
alert_rules: string;
|
|
22
|
-
};
|
|
23
|
-
export declare const useEntity: <K extends HortiviewDataAreaGroup | ModuleDataAreaGroup, E extends HortiviewDataAreaEntity<K>>(group: K, entity: E, enabled?: boolean) => {
|
|
1
|
+
import { FarmOrgEntity, ModuleEntity } from '../types/ModuleApi';
|
|
2
|
+
import { HortiviewDataAreaEntity, HortiviewDataAreaGroup, ModuleDataAreaGroup, ResultMap } from '../types/Entities';
|
|
3
|
+
export declare const useEntity: <K extends HortiviewDataAreaGroup | ModuleDataAreaGroup, E extends HortiviewDataAreaEntity<K>>(group: K, entity: E, enabled?: boolean, shouldGetRawData?: boolean) => {
|
|
24
4
|
data: ResultMap<E>[];
|
|
25
5
|
error: Error;
|
|
26
6
|
isError: true;
|
|
@@ -177,4 +157,6 @@ export declare const useEntity: <K extends HortiviewDataAreaGroup | ModuleDataAr
|
|
|
177
157
|
fetchStatus: import('@tanstack/query-core').FetchStatus;
|
|
178
158
|
promise: Promise<FarmOrgEntity[] | ModuleEntity[]>;
|
|
179
159
|
};
|
|
180
|
-
export {
|
|
160
|
+
export declare const useEntityId: (group: HortiviewDataAreaGroup | ModuleDataAreaGroup) => {
|
|
161
|
+
getEntityId: (entity: HortiviewDataAreaEntity<typeof group>) => string | undefined;
|
|
162
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HortiviewDataAreaEntity, HortiviewDataAreaGroup, ModuleDataAreaGroup } from '../types/Entities';
|
|
2
|
+
export declare const useOffline: () => {
|
|
3
|
+
prefetchCustom: <T>({ queryKey, endpoint, token, noAuth, }: {
|
|
4
|
+
queryKey: (string | undefined)[];
|
|
5
|
+
endpoint: string;
|
|
6
|
+
token?: string;
|
|
7
|
+
noAuth?: boolean;
|
|
8
|
+
selector?: (data: any) => T;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
prefetch: <T>({ queryKey, queryFn, }: {
|
|
11
|
+
queryKey: (string | undefined)[];
|
|
12
|
+
queryFn: () => Promise<T>;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
usePrefetchEntity: <K extends HortiviewDataAreaGroup | ModuleDataAreaGroup, E extends HortiviewDataAreaEntity<K>>(group: K, ...entities: E[]) => "Prefetch failed: no moduleId" | undefined;
|
|
15
|
+
};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { UseMutationResult } from '@tanstack/react-query';
|
|
2
|
-
import { AlertServiceBusMessage } from '../types/ServiceBus';
|
|
3
2
|
import { BaseResponse } from '../types/Requests';
|
|
3
|
+
import { AlertServiceBusMessage } from '../types/ServiceBus';
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @param authenticationKey SASToken, that will be provided by the vendor portal of HortiView
|
|
7
7
|
* @param queue url of the service bus queue
|
|
8
8
|
* @param topic topic of the service bus, where the message will be sent to
|
|
9
|
-
* @
|
|
9
|
+
* @deprecated use useNotification instead
|
|
10
10
|
*/
|
|
11
11
|
export declare const useServiceBus: ({ authenticationKey, queue, topic, }: {
|
|
12
12
|
authenticationKey: string;
|
|
13
13
|
queue: string;
|
|
14
14
|
topic: string;
|
|
15
15
|
}) => UseMutationResult<BaseResponse<unknown>, Error, AlertServiceBusMessage, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* create a notification in the service bus
|
|
18
|
+
*/
|
|
19
|
+
export declare const useNotification: () => UseMutationResult<BaseResponse<unknown>, Error, AlertServiceBusMessage, unknown>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const useBaseProps: () => Pick<import('../main').DeprecatedBaseProps & {
|
|
2
|
+
isOnline?: boolean;
|
|
3
|
+
modulePermissionToken?: string;
|
|
4
|
+
moduleId?: string;
|
|
5
|
+
organizationId?: string;
|
|
6
|
+
basePath?: string;
|
|
7
|
+
currentNavigationPath?: string;
|
|
8
|
+
sourcePath?: string | null;
|
|
9
|
+
currentLanguage?: string;
|
|
10
|
+
currentLanguageId?: string;
|
|
11
|
+
alertRules?: string;
|
|
12
|
+
commonOptions?: import('../main').AllDropdownsData<import('../main').CommonOption>["items"];
|
|
13
|
+
riseNotification?: (message: import('../main').AlertServiceBusMessage) => Promise<unknown>;
|
|
14
|
+
navigateInHortiview?: (path: string) => void;
|
|
15
|
+
addBreadcrumbTranslation?: (translation: {
|
|
16
|
+
key: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}, hide?: boolean) => void;
|
|
19
|
+
showSnackbar?: (message: string, icon?: string) => void;
|
|
20
|
+
showMessage?: (message: import('../main').SystemMessage) => void;
|
|
21
|
+
pendingActions?: import('../main').ActionItem[];
|
|
22
|
+
resolveAction?: (key: string, result?: string) => void;
|
|
23
|
+
addAction?: (functionName: string, args: unknown[], key?: string) => void;
|
|
24
|
+
getActions?: () => import('../main').ActionItem[];
|
|
25
|
+
getActionByKey?: (key: string) => import('../main').ActionItem | undefined;
|
|
26
|
+
logEvent?: (event: import('../main').AppInsightsEvent, customProperties?: import('../main').AppInsightsProperties) => void;
|
|
27
|
+
logError?: (exception: import('../main').AppInsightsException) => void;
|
|
28
|
+
throwError?: (message: string, code: number) => void;
|
|
29
|
+
environmentVariables?: import('../main').EnvironmentVariable[];
|
|
30
|
+
} & {
|
|
31
|
+
setBaseProps: (props: import('../main').BaseProps) => void;
|
|
32
|
+
}, keyof import('../main').DeprecatedBaseProps | "isOnline" | "modulePermissionToken" | "moduleId" | "organizationId" | "basePath" | "currentNavigationPath" | "sourcePath" | "currentLanguage" | "currentLanguageId" | "alertRules" | "commonOptions" | "riseNotification" | "navigateInHortiview" | "addBreadcrumbTranslation" | "showSnackbar" | "showMessage" | "pendingActions" | "resolveAction" | "addAction" | "getActions" | "getActionByKey" | "logEvent" | "logError" | "throwError" | "environmentVariables">;
|
|
33
|
+
export declare const useConfig: () => Pick<{
|
|
34
|
+
environment: import('../main').HortiViewEnvironments;
|
|
35
|
+
setEnvironment: (environment: import('../main').HortiViewEnvironments) => void;
|
|
36
|
+
addEnvironment: (customEnv: import('../main').CustomEnv) => void;
|
|
37
|
+
}, "environment">;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { ModuleBase } from './components/ModuleBase';
|
|
2
|
+
export { ModuleCore } from './components/ModuleCore';
|
|
3
|
+
export type * from './types/AppInsights';
|
|
4
|
+
export type * from './types/BaseProps';
|
|
5
|
+
export type * from './types/CommonOptions';
|
|
6
|
+
export type * from './types/Deprecated';
|
|
7
|
+
export type * from './types/Environment';
|
|
8
|
+
export type * from './types/EnvironmentVariable';
|
|
9
|
+
export type * from './types/ModuleApi';
|
|
10
|
+
export type * from './types/Requests';
|
|
11
|
+
export type * from './types/ServiceBus';
|
|
12
|
+
export type * from './types/SystemMessage';
|
|
13
|
+
export type * from './types/ActionStorage';
|
|
14
|
+
export { useBreadcrumbTranslation } from './hooks/useBreadcrumbTranslation';
|
|
15
|
+
export { useOffline } from './hooks/useOffline';
|
|
16
|
+
export { useSignalRMessages } from './hooks/useSignalRMessages';
|
|
17
|
+
export * from './module-router';
|
|
18
|
+
export { useNavigate } from './module-router';
|
|
19
|
+
export { useBaseProps, useConfig } from './hooks/useStores';
|
|
20
|
+
export { useCustom } from './hooks/useCustom';
|
|
21
|
+
export { useCustomMutation } from './hooks/useCustomMutation';
|
|
22
|
+
export { useEntity } from './hooks/useEntity';
|
|
23
|
+
export { useOption } from './hooks/useOption';
|
|
24
|
+
export { useNotification, useServiceBus } from './hooks/useServiceBus';
|
|
25
|
+
export { QueryClient, useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
26
|
+
export { mutateOnCustomApi } from './utils/fetches';
|
|
27
|
+
export * from './utils/helper';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum ActionState {
|
|
2
|
+
ENQUEUED = "ENQUEUED",
|
|
3
|
+
PENDING = "PENDING",
|
|
4
|
+
SUCCESS = "RESOLVED",
|
|
5
|
+
ERROR = "REJECTED"
|
|
6
|
+
}
|
|
7
|
+
export type ActionItem = {
|
|
8
|
+
functionName: string;
|
|
9
|
+
args: unknown[];
|
|
10
|
+
dateAdded: string;
|
|
11
|
+
state: ActionState;
|
|
12
|
+
key: string;
|
|
13
|
+
};
|