@hortiview/modulebase 0.0.15690 → 0.0.20436
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-DpwHP0IU.js +14973 -0
- package/dist/{QueryClientProvider-VtJdNkDw.js → QueryClientProvider-Beog9TR7.js} +25 -23
- package/dist/{_baseGet-B7FwMMGI.js → _baseGet-C6jMXSsQ.js} +447 -447
- package/dist/api-CogBuK0n.js +473 -0
- package/dist/components/ModuleBase.js +1 -1
- package/dist/components/ModuleCore.js +9 -14698
- package/dist/constants.js +1 -1
- package/dist/enum/ActionStorage.js +4 -0
- package/dist/hooks/useCustom.js +15 -18
- package/dist/hooks/useCustomMutation.js +12 -11
- package/dist/hooks/useEntity.js +48 -60
- package/dist/hooks/useOffline.js +57 -0
- package/dist/hooks/useOption.js +15 -15
- package/dist/hooks/useServiceBus.js +1 -1
- package/dist/hooks/useStores.js +1 -1
- package/dist/{query-CFoO2uy7.js → isRestoring-CLuxJVSA.js} +21 -17
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/enum/ActionStorage.d.ts +7 -0
- package/dist/lib/hooks/useCustom.d.ts +3 -2
- package/dist/lib/hooks/useCustomMutation.d.ts +2 -1
- package/dist/lib/hooks/useEntity.d.ts +9 -23
- package/dist/lib/hooks/useOffline.d.ts +15 -0
- package/dist/lib/hooks/useStores.d.ts +10 -2
- package/dist/lib/main.d.ts +4 -0
- package/dist/lib/types/ActionStorage.d.ts +8 -0
- package/dist/lib/types/BaseProps.d.ts +10 -1
- package/dist/lib/types/CommonOptions.d.ts +2 -1
- package/dist/lib/types/Deprecated.d.ts +4 -0
- package/dist/lib/types/Entities.d.ts +22 -0
- package/dist/lib/utils/IndexedDbService.d.ts +33 -0
- package/dist/lib/utils/api.d.ts +1 -1
- package/dist/lib/utils/baseFetches.d.ts +2 -2
- package/dist/lib/utils/fetches.d.ts +2 -2
- package/dist/lib/utils/helper.d.ts +1 -0
- package/dist/main.js +218 -144
- package/dist/{mutation-CnKIetRs.js → mutation-DSKlaYzY.js} +1 -1
- package/dist/{omit-B7MWDtHq.js → omit-C9Qe80rl.js} +1 -1
- package/dist/types/ActionStorage.js +1 -0
- package/dist/types/CommonOptions.js +1 -1
- package/dist/types/Entities.js +25 -0
- package/dist/{useMutation-Num57Ulc.js → useMutation-zu8uxBak.js} +16 -16
- package/dist/{useQuery-XBGd5Kep.js → useQuery-Bj9k9zik.js} +39 -39
- package/dist/utils/IndexedDbService.js +43 -0
- package/dist/utils/api.js +1 -1
- package/dist/utils/baseFetches.js +15 -15
- package/dist/utils/fetches.js +10 -10
- package/dist/utils/helper.js +25 -20
- package/package.json +7 -3
- package/dist/api-D9Lmqe6S.js +0 -458
package/dist/constants.js
CHANGED
package/dist/hooks/useCustom.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
endpoint: e,
|
|
1
|
+
import { u as f } from "../useQuery-Bj9k9zik.js";
|
|
2
|
+
import { fetchFromCustomApi as i } from "../utils/fetches.js";
|
|
3
|
+
import { universalSelector as n } from "../utils/helper.js";
|
|
4
|
+
const y = ({
|
|
5
|
+
endpoint: o,
|
|
7
6
|
queryKey: t,
|
|
8
7
|
token: u,
|
|
9
|
-
selector:
|
|
10
|
-
enabled: m = !0
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
};
|
|
8
|
+
selector: r,
|
|
9
|
+
enabled: m = !0,
|
|
10
|
+
noAuth: s = !1
|
|
11
|
+
}) => f({
|
|
12
|
+
queryKey: t,
|
|
13
|
+
queryFn: () => i(o, u, s),
|
|
14
|
+
select: (e) => r ? r(e) : n(e),
|
|
15
|
+
enabled: m
|
|
16
|
+
});
|
|
20
17
|
export {
|
|
21
|
-
|
|
18
|
+
y as useCustom
|
|
22
19
|
};
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { u } from "../useMutation-
|
|
1
|
+
import { u as n } from "../useMutation-zu8uxBak.js";
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
3
|
import "react";
|
|
4
4
|
import "../provider/SignalR/SignalRProvider.js";
|
|
5
5
|
import "../stores/BasePropsStore.js";
|
|
6
|
-
import "../
|
|
7
|
-
import "../
|
|
6
|
+
import "../ModuleCore-DpwHP0IU.js";
|
|
7
|
+
import { mutateOnCustomApi as s } from "../utils/fetches.js";
|
|
8
|
+
import "../types/Entities.js";
|
|
9
|
+
import "../api-CogBuK0n.js";
|
|
10
|
+
import "../omit-C9Qe80rl.js";
|
|
8
11
|
import "../stores/EnvironmentStore.js";
|
|
9
|
-
|
|
10
|
-
import "./useEntity.js";
|
|
11
|
-
import "../api-D9Lmqe6S.js";
|
|
12
|
-
const b = ({
|
|
12
|
+
const d = ({
|
|
13
13
|
endpoint: t,
|
|
14
14
|
method: o,
|
|
15
15
|
token: m,
|
|
16
|
-
headers: r
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
headers: r,
|
|
17
|
+
noAuth: i
|
|
18
|
+
}) => n({
|
|
19
|
+
mutationFn: (p, u) => s(u ?? t, p, o, m, r, i)
|
|
19
20
|
});
|
|
20
21
|
export {
|
|
21
|
-
|
|
22
|
+
d as useCustomMutation
|
|
22
23
|
};
|
package/dist/hooks/useEntity.js
CHANGED
|
@@ -1,70 +1,58 @@
|
|
|
1
|
-
import { u as p } from "../useQuery-
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { useBasePropsStore as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
alert_rules: "farmAlertRule"
|
|
14
|
-
}, S = {
|
|
15
|
-
farm_members: "member"
|
|
16
|
-
}, q = {
|
|
17
|
-
Season: "season",
|
|
18
|
-
BlockPlantLayout: "blockPlantLayout",
|
|
19
|
-
Record: "recordLight",
|
|
20
|
-
Scouting: "scouting"
|
|
21
|
-
}, O = {
|
|
22
|
-
...Q,
|
|
23
|
-
...S,
|
|
24
|
-
...q
|
|
25
|
-
}, x = (r, e, u = !0, s = !1) => {
|
|
26
|
-
const l = E((n) => n.moduleId), d = E((n) => n.organizationId), { data: a } = g("DataAreaGroup"), { data: i } = g("DataAreaEntity"), { data: o } = F(r === "ModuleDepended"), c = r === "ModuleDepended", b = y(() => {
|
|
27
|
-
if (c)
|
|
28
|
-
return o ? o.find((t) => t.registeredEntityName === e)?.id : void 0;
|
|
29
|
-
if (!a || !i) return;
|
|
30
|
-
const n = a.find((t) => t.key === r)?.id;
|
|
31
|
-
return n ? i.find((t) => t.description === n && t.value === e)?.id : void 0;
|
|
32
|
-
}, [c, a, i, o, e, r]), m = T(
|
|
33
|
-
l,
|
|
34
|
-
b,
|
|
35
|
-
d,
|
|
36
|
-
c,
|
|
1
|
+
import { u as p } from "../useQuery-Bj9k9zik.js";
|
|
2
|
+
import { useMemo as g, useCallback as Q } from "react";
|
|
3
|
+
import { useBasePropsStore as m } from "../stores/BasePropsStore.js";
|
|
4
|
+
import { AllEntitiesTypeResultMap as A } from "../types/Entities.js";
|
|
5
|
+
import { getModuleDependedEntitiesRaw as D, getModuleDependedEntities as q, getFarmOrgEntities as k } from "../utils/fetches.js";
|
|
6
|
+
import { getModuleQueryKey as y, universalSelector as E } from "../utils/helper.js";
|
|
7
|
+
import { useOption as M, useModuleDependency as F } from "./useOption.js";
|
|
8
|
+
const P = (t, e, u = !0, n = !1) => {
|
|
9
|
+
const a = m((i) => i.moduleId), o = m((i) => i.organizationId), s = t === "ModuleDepended", r = b(t)(e), c = K(
|
|
10
|
+
a,
|
|
11
|
+
r,
|
|
12
|
+
o,
|
|
37
13
|
s,
|
|
14
|
+
n,
|
|
38
15
|
u
|
|
39
16
|
);
|
|
40
|
-
return
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
17
|
+
return g(() => {
|
|
18
|
+
const i = (c.data ?? []).map((f) => {
|
|
19
|
+
if (s && n) return f;
|
|
20
|
+
const l = A[e];
|
|
21
|
+
return f[l];
|
|
44
22
|
});
|
|
45
23
|
return {
|
|
46
|
-
...
|
|
47
|
-
data:
|
|
24
|
+
...c,
|
|
25
|
+
data: i
|
|
48
26
|
};
|
|
49
|
-
}, [e,
|
|
50
|
-
},
|
|
51
|
-
const
|
|
52
|
-
queryKey: [
|
|
53
|
-
queryFn: () =>
|
|
54
|
-
enabled:
|
|
55
|
-
select: (
|
|
56
|
-
}),
|
|
57
|
-
queryKey: [
|
|
58
|
-
queryFn: () => k(
|
|
59
|
-
enabled:
|
|
60
|
-
select: (
|
|
27
|
+
}, [e, c, s, n]);
|
|
28
|
+
}, K = (t, e, u, n, a, o = !0) => {
|
|
29
|
+
const s = p({
|
|
30
|
+
queryKey: y([e]),
|
|
31
|
+
queryFn: () => a ? D(t ?? "", e ?? "") : q(t ?? "", e ?? ""),
|
|
32
|
+
enabled: o && n && !!t && !!e && !!u,
|
|
33
|
+
select: (r) => E(r)
|
|
34
|
+
}), d = p({
|
|
35
|
+
queryKey: y([e]),
|
|
36
|
+
queryFn: () => k(t ?? "", e ?? ""),
|
|
37
|
+
enabled: o && !n && !!t && !!e && !!u,
|
|
38
|
+
select: (r) => E(r)
|
|
61
39
|
});
|
|
62
|
-
return
|
|
40
|
+
return n ? s : d;
|
|
41
|
+
}, b = (t) => {
|
|
42
|
+
const { data: e } = M("DataAreaGroup"), { data: u } = M("DataAreaEntity"), { data: n } = F(t === "ModuleDepended");
|
|
43
|
+
return Q(
|
|
44
|
+
(o) => {
|
|
45
|
+
if (t === "ModuleDepended")
|
|
46
|
+
return n ? n.find((r) => r.registeredEntityName === o)?.id : void 0;
|
|
47
|
+
if (!e || !u) return;
|
|
48
|
+
const d = e.find((r) => r.key === t)?.id;
|
|
49
|
+
if (d)
|
|
50
|
+
return u.find((r) => r.description === d && r.value === o)?.id;
|
|
51
|
+
},
|
|
52
|
+
[t, e, u, n]
|
|
53
|
+
);
|
|
63
54
|
};
|
|
64
55
|
export {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Q as FarmOrgEntitiesTypeResultMap,
|
|
68
|
-
q as ModuleDependedEntityTypeResultMap,
|
|
69
|
-
x as useEntity
|
|
56
|
+
P as useEntity,
|
|
57
|
+
b as useEntityId
|
|
70
58
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { u as y } from "../QueryClientProvider-Beog9TR7.js";
|
|
2
|
+
import { useBasePropsStore as i } from "../stores/BasePropsStore.js";
|
|
3
|
+
import { fetchFromCustomApi as f, getFarmOrgEntities as m, getModuleDependedEntities as d } from "../utils/fetches.js";
|
|
4
|
+
import { getModuleQueryKey as o } from "../utils/helper.js";
|
|
5
|
+
import { useEntityId as p } from "./useEntity.js";
|
|
6
|
+
const I = () => {
|
|
7
|
+
const e = a(), t = h();
|
|
8
|
+
return {
|
|
9
|
+
prefetchCustom: e,
|
|
10
|
+
prefetch: t,
|
|
11
|
+
usePrefetchEntity: l
|
|
12
|
+
};
|
|
13
|
+
}, a = () => {
|
|
14
|
+
const e = y();
|
|
15
|
+
return async ({
|
|
16
|
+
queryKey: t,
|
|
17
|
+
endpoint: r,
|
|
18
|
+
token: u,
|
|
19
|
+
noAuth: s = !1
|
|
20
|
+
}) => {
|
|
21
|
+
await e.prefetchQuery({
|
|
22
|
+
queryKey: o(t),
|
|
23
|
+
queryFn: () => f(r, u, s)
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}, h = () => {
|
|
27
|
+
const e = y();
|
|
28
|
+
return ({
|
|
29
|
+
queryKey: t,
|
|
30
|
+
queryFn: r
|
|
31
|
+
}) => e.prefetchQuery({
|
|
32
|
+
queryKey: o(t),
|
|
33
|
+
queryFn: r
|
|
34
|
+
});
|
|
35
|
+
}, l = (e, ...t) => {
|
|
36
|
+
const { moduleId: r } = i(), u = y(), s = p(e);
|
|
37
|
+
if (!r) return "Prefetch failed: no moduleId";
|
|
38
|
+
t.forEach(async (c) => {
|
|
39
|
+
const n = s(c);
|
|
40
|
+
if (n) {
|
|
41
|
+
if (e !== "ModuleDepended") {
|
|
42
|
+
await u.prefetchQuery({
|
|
43
|
+
queryKey: o([n]),
|
|
44
|
+
queryFn: () => m(r, n)
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
await u.prefetchQuery({
|
|
49
|
+
queryKey: o([n]),
|
|
50
|
+
queryFn: () => d(r, n)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
I as useOffline
|
|
57
|
+
};
|
package/dist/hooks/useOption.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { u as m } from "../useQuery-
|
|
2
|
-
import { g as
|
|
1
|
+
import { u as m } from "../useQuery-Bj9k9zik.js";
|
|
2
|
+
import { g as c } from "../api-CogBuK0n.js";
|
|
3
3
|
import { useBasePropsStore as n } from "../stores/BasePropsStore.js";
|
|
4
|
-
import {
|
|
5
|
-
import { universalSelector as s } from "../utils/helper.js";
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
import { fetchFromModuleApi as i, fetchFromCommonApi as p } from "../utils/fetches.js";
|
|
5
|
+
import { getModuleQueryKey as l, universalSelector as s } from "../utils/helper.js";
|
|
6
|
+
const q = (e) => {
|
|
7
|
+
const t = n((r) => r.commonOptions), o = n((r) => r.currentLanguageId), u = c(t, e);
|
|
8
8
|
return m({
|
|
9
|
-
queryKey: [e],
|
|
10
|
-
queryFn: () =>
|
|
11
|
-
select: (
|
|
9
|
+
queryKey: [e, o],
|
|
10
|
+
queryFn: () => u ? Promise.resolve(u) : p(`${e}/dropdown`),
|
|
11
|
+
select: (r) => s(r)
|
|
12
12
|
});
|
|
13
|
-
},
|
|
14
|
-
const
|
|
13
|
+
}, F = (e = !0) => {
|
|
14
|
+
const t = n((o) => o.moduleId);
|
|
15
15
|
return m({
|
|
16
|
-
queryKey: [
|
|
17
|
-
queryFn: () =>
|
|
16
|
+
queryKey: l([]),
|
|
17
|
+
queryFn: () => i(`ModuleDependencies/${t}`),
|
|
18
18
|
select: (o) => s(o),
|
|
19
19
|
enabled: e
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
F as useModuleDependency,
|
|
24
|
+
q as useOption
|
|
25
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
|
};
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseProps } from './types/BaseProps';
|
|
2
2
|
export declare const REQUIRED_PROPS: (keyof BaseProps)[];
|
|
3
|
-
export declare const RETRIES =
|
|
3
|
+
export declare const RETRIES = 2;
|
|
4
4
|
export declare const RETRY_HTTP_STATUS_CODES: {
|
|
5
5
|
/**
|
|
6
6
|
* The server timed out waiting for the request.
|
|
@@ -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
|
-
selector?: (data:
|
|
5
|
+
selector?: (data: unknown) => 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,25 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type ModuleDataAreaGroup = 'ModuleDepended';
|
|
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
|
-
};
|
|
1
|
+
import { HortiviewDataAreaEntity, HortiviewDataAreaGroup, ModuleDataAreaGroup, ResultMap } from '../types/Entities';
|
|
2
|
+
import { FarmOrgEntity, ModuleEntity } from '../types/ModuleApi';
|
|
23
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;
|
|
@@ -177,4 +157,10 @@ 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
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Returns a function to get the entity id based on the group and entity name.
|
|
162
|
+
* Needs to return a function to get an entity id out of a list of entities, see useOffline
|
|
163
|
+
* @param group
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
export declare const useEntityId: (group: HortiviewDataAreaGroup | ModuleDataAreaGroup) => ((entity: HortiviewDataAreaEntity<typeof group>) => string | undefined);
|
|
@@ -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: unknown) => 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,4 +1,5 @@
|
|
|
1
1
|
export declare const useBaseProps: () => Pick<import('../main').DeprecatedBaseProps & {
|
|
2
|
+
isOnline?: boolean;
|
|
2
3
|
modulePermissionToken?: string;
|
|
3
4
|
moduleId?: string;
|
|
4
5
|
organizationId?: string;
|
|
@@ -7,8 +8,8 @@ export declare const useBaseProps: () => Pick<import('../main').DeprecatedBasePr
|
|
|
7
8
|
sourcePath?: string | null;
|
|
8
9
|
currentLanguage?: string;
|
|
9
10
|
currentLanguageId?: string;
|
|
10
|
-
alertRules?: string;
|
|
11
11
|
commonOptions?: import('../main').AllDropdownsData<import('../main').CommonOption>["items"];
|
|
12
|
+
refreshModulePermissionToken?: () => Promise<string | undefined>;
|
|
12
13
|
riseNotification?: (message: import('../main').AlertServiceBusMessage) => Promise<unknown>;
|
|
13
14
|
navigateInHortiview?: (path: string) => void;
|
|
14
15
|
addBreadcrumbTranslation?: (translation: {
|
|
@@ -17,13 +18,20 @@ export declare const useBaseProps: () => Pick<import('../main').DeprecatedBasePr
|
|
|
17
18
|
}, hide?: boolean) => void;
|
|
18
19
|
showSnackbar?: (message: string, icon?: string) => void;
|
|
19
20
|
showMessage?: (message: import('../main').SystemMessage) => void;
|
|
21
|
+
pendingActions?: import('../main').ActionItem[];
|
|
22
|
+
getPendingActions?: () => import('../main').ActionItem[];
|
|
23
|
+
resolveAction?: (key: string, result?: string) => void;
|
|
24
|
+
startResolvingAction?: (key: string) => void;
|
|
25
|
+
addAction?: (functionName: string, args: unknown[], key?: string) => void;
|
|
26
|
+
getActions?: () => import('../main').ActionItem[];
|
|
27
|
+
getActionByKey?: (key: string) => import('../main').ActionItem | undefined;
|
|
20
28
|
logEvent?: (event: import('../main').AppInsightsEvent, customProperties?: import('../main').AppInsightsProperties) => void;
|
|
21
29
|
logError?: (exception: import('../main').AppInsightsException) => void;
|
|
22
30
|
throwError?: (message: string, code: number) => void;
|
|
23
31
|
environmentVariables?: import('../main').EnvironmentVariable[];
|
|
24
32
|
} & {
|
|
25
33
|
setBaseProps: (props: import('../main').BaseProps) => void;
|
|
26
|
-
}, keyof import('../main').DeprecatedBaseProps | "modulePermissionToken" | "moduleId" | "organizationId" | "basePath" | "currentNavigationPath" | "sourcePath" | "currentLanguage" | "currentLanguageId" | "
|
|
34
|
+
}, keyof import('../main').DeprecatedBaseProps | "isOnline" | "modulePermissionToken" | "moduleId" | "organizationId" | "basePath" | "currentNavigationPath" | "sourcePath" | "currentLanguage" | "currentLanguageId" | "commonOptions" | "refreshModulePermissionToken" | "riseNotification" | "navigateInHortiview" | "addBreadcrumbTranslation" | "showSnackbar" | "showMessage" | "pendingActions" | "getPendingActions" | "resolveAction" | "startResolvingAction" | "addAction" | "getActions" | "getActionByKey" | "logEvent" | "logError" | "throwError" | "environmentVariables">;
|
|
27
35
|
export declare const useConfig: () => Pick<{
|
|
28
36
|
environment: import('../main').HortiViewEnvironments;
|
|
29
37
|
setEnvironment: (environment: import('../main').HortiViewEnvironments) => void;
|
package/dist/lib/main.d.ts
CHANGED
|
@@ -10,7 +10,10 @@ export type * from './types/ModuleApi';
|
|
|
10
10
|
export type * from './types/Requests';
|
|
11
11
|
export type * from './types/ServiceBus';
|
|
12
12
|
export type * from './types/SystemMessage';
|
|
13
|
+
export type * from './types/ActionStorage';
|
|
14
|
+
export * from './enum/ActionStorage';
|
|
13
15
|
export { useBreadcrumbTranslation } from './hooks/useBreadcrumbTranslation';
|
|
16
|
+
export { useOffline } from './hooks/useOffline';
|
|
14
17
|
export { useSignalRMessages } from './hooks/useSignalRMessages';
|
|
15
18
|
export * from './module-router';
|
|
16
19
|
export { useNavigate } from './module-router';
|
|
@@ -20,5 +23,6 @@ export { useCustomMutation } from './hooks/useCustomMutation';
|
|
|
20
23
|
export { useEntity } from './hooks/useEntity';
|
|
21
24
|
export { useOption } from './hooks/useOption';
|
|
22
25
|
export { useNotification, useServiceBus } from './hooks/useServiceBus';
|
|
26
|
+
export { QueryClient, useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
23
27
|
export { mutateOnCustomApi } from './utils/fetches';
|
|
24
28
|
export * from './utils/helper';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ActionItem } from './ActionStorage';
|
|
1
2
|
import { AppInsightsEvent, AppInsightsException, AppInsightsProperties } from './AppInsights';
|
|
2
3
|
import { AllDropdownsData, CommonOption } from './CommonOptions';
|
|
3
4
|
import { DeprecatedBaseProps } from './Deprecated';
|
|
@@ -17,6 +18,7 @@ import { SystemMessage } from './SystemMessage';
|
|
|
17
18
|
* @param currentNavigationPath current path of the route, that is changed, when the host application navigates
|
|
18
19
|
*/
|
|
19
20
|
export type BaseProps = DeprecatedBaseProps & {
|
|
21
|
+
isOnline?: boolean;
|
|
20
22
|
modulePermissionToken?: string;
|
|
21
23
|
moduleId?: string;
|
|
22
24
|
organizationId?: string;
|
|
@@ -25,8 +27,8 @@ export type BaseProps = DeprecatedBaseProps & {
|
|
|
25
27
|
sourcePath?: string | null;
|
|
26
28
|
currentLanguage?: string;
|
|
27
29
|
currentLanguageId?: string;
|
|
28
|
-
alertRules?: string;
|
|
29
30
|
commonOptions?: AllDropdownsData<CommonOption>['items'];
|
|
31
|
+
refreshModulePermissionToken?: () => Promise<string | undefined>;
|
|
30
32
|
riseNotification?: (message: AlertServiceBusMessage) => Promise<unknown>;
|
|
31
33
|
navigateInHortiview?: (path: string) => void;
|
|
32
34
|
addBreadcrumbTranslation?: (translation: {
|
|
@@ -35,6 +37,13 @@ export type BaseProps = DeprecatedBaseProps & {
|
|
|
35
37
|
}, hide?: boolean) => void;
|
|
36
38
|
showSnackbar?: (message: string, icon?: string) => void;
|
|
37
39
|
showMessage?: (message: SystemMessage) => void;
|
|
40
|
+
pendingActions?: ActionItem[];
|
|
41
|
+
getPendingActions?: () => ActionItem[];
|
|
42
|
+
resolveAction?: (key: string, result?: string) => void;
|
|
43
|
+
startResolvingAction?: (key: string) => void;
|
|
44
|
+
addAction?: (functionName: string, args: unknown[], key?: string) => void;
|
|
45
|
+
getActions?: () => ActionItem[];
|
|
46
|
+
getActionByKey?: (key: string) => ActionItem | undefined;
|
|
38
47
|
logEvent?: (event: AppInsightsEvent, customProperties?: AppInsightsProperties) => void;
|
|
39
48
|
logError?: (exception: AppInsightsException) => void;
|
|
40
49
|
throwError?: (message: string, code: number) => void;
|