@hortiview/modulebase 0.0.14106 → 0.0.15687
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/assets/ModuleCore.css +1 -1
- package/dist/components/ModuleCore.js +3749 -3746
- package/dist/hooks/useEntity.js +50 -48
- package/dist/lib/hooks/useEntity.d.ts +1 -1
- package/dist/lib/utils/fetches.d.ts +8 -0
- package/dist/utils/fetches.js +10 -9
- package/dist/utils/helper.js +1 -1
- package/package.json +3 -3
package/dist/hooks/useEntity.js
CHANGED
|
@@ -1,68 +1,70 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { useBasePropsStore as
|
|
4
|
-
import { getModuleDependedEntities as R, getFarmOrgEntities as
|
|
5
|
-
import { universalSelector as
|
|
6
|
-
import { useOption as
|
|
7
|
-
const
|
|
1
|
+
import { u as p } from "../useQuery-XBGd5Kep.js";
|
|
2
|
+
import { useMemo as y } from "react";
|
|
3
|
+
import { useBasePropsStore as E } from "../stores/BasePropsStore.js";
|
|
4
|
+
import { getModuleDependedEntitiesRaw as A, getModuleDependedEntities as R, getFarmOrgEntities as k } from "../utils/fetches.js";
|
|
5
|
+
import { universalSelector as M } from "../utils/helper.js";
|
|
6
|
+
import { useOption as g, useModuleDependency as F } from "./useOption.js";
|
|
7
|
+
const Q = {
|
|
8
8
|
farms: "farm",
|
|
9
9
|
fields: "field",
|
|
10
10
|
zones: "block",
|
|
11
11
|
irrigation_stations: "irrigationStation",
|
|
12
12
|
farm_organizations: "farmOrg",
|
|
13
13
|
alert_rules: "farmAlertRule"
|
|
14
|
-
},
|
|
14
|
+
}, S = {
|
|
15
15
|
farm_members: "member"
|
|
16
|
-
},
|
|
16
|
+
}, q = {
|
|
17
17
|
Season: "season",
|
|
18
18
|
BlockPlantLayout: "blockPlantLayout",
|
|
19
|
-
Record: "recordLight"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
...
|
|
23
|
-
...
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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;
|
|
30
31
|
return n ? i.find((t) => t.description === n && t.value === e)?.id : void 0;
|
|
31
|
-
}, [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
c,
|
|
32
|
+
}, [c, a, i, o, e, r]), m = T(
|
|
33
|
+
l,
|
|
34
|
+
b,
|
|
35
35
|
d,
|
|
36
|
-
|
|
36
|
+
c,
|
|
37
|
+
s,
|
|
38
|
+
u
|
|
37
39
|
);
|
|
38
|
-
return
|
|
39
|
-
const n = (
|
|
40
|
-
const t =
|
|
41
|
-
return
|
|
40
|
+
return y(() => {
|
|
41
|
+
const n = (m.data ?? []).map((f) => {
|
|
42
|
+
const t = O[e];
|
|
43
|
+
return c && s ? f : f[t];
|
|
42
44
|
});
|
|
43
45
|
return {
|
|
44
|
-
...
|
|
46
|
+
...m,
|
|
45
47
|
data: n
|
|
46
48
|
};
|
|
47
|
-
}, [e,
|
|
48
|
-
},
|
|
49
|
-
const
|
|
50
|
-
queryKey: [r,
|
|
51
|
-
queryFn: () => R(r ?? "", e ?? ""),
|
|
52
|
-
enabled:
|
|
53
|
-
select: (
|
|
54
|
-
}), i =
|
|
55
|
-
queryKey: [r,
|
|
56
|
-
queryFn: () =>
|
|
57
|
-
enabled:
|
|
58
|
-
select: (
|
|
49
|
+
}, [e, m, c, s]);
|
|
50
|
+
}, T = (r, e, u, s, l, d = !0) => {
|
|
51
|
+
const a = p({
|
|
52
|
+
queryKey: [r, u, e],
|
|
53
|
+
queryFn: () => l ? A(r ?? "", e ?? "") : R(r ?? "", e ?? ""),
|
|
54
|
+
enabled: d && s && !!r && !!e && !!u,
|
|
55
|
+
select: (o) => M(o)
|
|
56
|
+
}), i = p({
|
|
57
|
+
queryKey: [r, u, e],
|
|
58
|
+
queryFn: () => k(r ?? "", e ?? ""),
|
|
59
|
+
enabled: d && !s && !!r && !!e && !!u,
|
|
60
|
+
select: (o) => M(o)
|
|
59
61
|
});
|
|
60
|
-
return
|
|
62
|
+
return s ? a : i;
|
|
61
63
|
};
|
|
62
64
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
O as AllEntitiesTypeResultMap,
|
|
66
|
+
S as FarmMemberEntitiesTypeResultMap,
|
|
67
|
+
Q as FarmOrgEntitiesTypeResultMap,
|
|
68
|
+
q as ModuleDependedEntityTypeResultMap,
|
|
69
|
+
x as useEntity
|
|
68
70
|
};
|
|
@@ -20,7 +20,7 @@ export declare const AllEntitiesTypeResultMap: {
|
|
|
20
20
|
farm_organizations: string;
|
|
21
21
|
alert_rules: string;
|
|
22
22
|
};
|
|
23
|
-
export declare const useEntity: <K extends HortiviewDataAreaGroup | ModuleDataAreaGroup, E extends HortiviewDataAreaEntity<K>>(group: K, entity: E, enabled?: boolean) => {
|
|
23
|
+
export declare const useEntity: <K extends HortiviewDataAreaGroup | ModuleDataAreaGroup, E extends HortiviewDataAreaEntity<K>>(group: K, entity: E, enabled?: boolean, shouldGetRawData?: boolean) => {
|
|
24
24
|
data: ResultMap<E>[];
|
|
25
25
|
error: Error;
|
|
26
26
|
isError: true;
|
|
@@ -14,6 +14,14 @@ export declare const getFarmOrgEntities: <T>(moduleId: string, entityId: string)
|
|
|
14
14
|
* @returns entity to get
|
|
15
15
|
*/
|
|
16
16
|
export declare const getModuleDependedEntities: <T>(moduleId: string, entityId: string) => Promise<import('../main').BaseResponse<T>>;
|
|
17
|
+
/**
|
|
18
|
+
* a fetch function to get a certain MODULEDEPENDED entity from the moduleApi (will be used in useEntity)
|
|
19
|
+
* the data will be returned in a raw format
|
|
20
|
+
* @param moduleId
|
|
21
|
+
* @param entityId
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export declare const getModuleDependedEntitiesRaw: <T>(moduleId: string, entityId: string) => Promise<import('../main').BaseResponse<T>>;
|
|
17
25
|
/**
|
|
18
26
|
* a fetch function to handle GET requests and returns the response.
|
|
19
27
|
* @param endpoint custom endpoint to GET data from
|
package/dist/utils/fetches.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { useBasePropsStore as u } from "../stores/BasePropsStore.js";
|
|
2
|
-
import { useEnvironmentStore as
|
|
3
|
-
import { baseMutation as
|
|
4
|
-
const
|
|
5
|
-
const t =
|
|
2
|
+
import { useEnvironmentStore as i } from "../stores/EnvironmentStore.js";
|
|
3
|
+
import { baseMutation as d, baseFetch as o } from "./baseFetches.js";
|
|
4
|
+
const p = (e, t, n = "POST", s, m) => d(e, t, n, s, m), I = (e, t) => r(`FarmOrgEntities/${e}/byId/${t}`), g = (e, t) => r(`ModuleDependentEntities/${e}/byId/${t}`), E = (e, t) => r(`ModuleDependentEntitiesRaw/${e}/byId/${t}`), A = (e, t) => o(`${e}`, {}, t), r = (e) => {
|
|
5
|
+
const t = i.getState().environment, n = u.getState().organizationId;
|
|
6
6
|
return o(
|
|
7
7
|
`${t?.MODULE_AUTH_API}${t?.API_PREFIX}/${n}/${e}`,
|
|
8
8
|
{}
|
|
9
9
|
);
|
|
10
|
-
},
|
|
11
|
-
const t =
|
|
10
|
+
}, M = (e) => {
|
|
11
|
+
const t = i.getState().environment;
|
|
12
12
|
return o(`${t?.COMMON_API}${t?.API_PREFIX}/${e}`, {});
|
|
13
13
|
};
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
M as fetchFromCommonApi,
|
|
16
16
|
A as fetchFromCustomApi,
|
|
17
|
-
|
|
17
|
+
r as fetchFromModuleApi,
|
|
18
18
|
I as getFarmOrgEntities,
|
|
19
19
|
g as getModuleDependedEntities,
|
|
20
|
-
|
|
20
|
+
E as getModuleDependedEntitiesRaw,
|
|
21
|
+
p as mutateOnCustomApi
|
|
21
22
|
};
|
package/dist/utils/helper.js
CHANGED
|
@@ -24,7 +24,7 @@ const h = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([
|
|
|
24
24
|
}, g = (r, e) => {
|
|
25
25
|
const n = u(r), t = u(e), i = n.pop(), o = t.pop(), s = l(n, t);
|
|
26
26
|
return s !== 0 ? s : i && o ? l(i.split("."), o.split(".")) : i || o ? i ? -1 : 1 : 0;
|
|
27
|
-
}, p = "0.0.
|
|
27
|
+
}, p = "0.0.15687", w = (r) => d.every((e) => v(e, r)), v = (r, e) => {
|
|
28
28
|
if (!e[r]) {
|
|
29
29
|
if (e.throwError)
|
|
30
30
|
return e.throwError(`Missing required prop: ${r}`, 404), !1;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hortiview/modulebase",
|
|
3
3
|
"description": "This is a base module for hortiview",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.15687",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Falk Menge <falk.menge.ext@bayer.com>",
|
|
7
7
|
"contributors": [
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"preview": "vite preview"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@hortiview/default-components": "^1.2.
|
|
27
|
-
"@hortiview/shared-components": "^
|
|
26
|
+
"@hortiview/default-components": "^1.2.1",
|
|
27
|
+
"@hortiview/shared-components": "^2.0.0",
|
|
28
28
|
"@microsoft/signalr": "^8.0.7",
|
|
29
29
|
"@tanstack/react-query": "^5.67.3",
|
|
30
30
|
"compare-versions": "^6.1.1",
|