@hortiview/modulebase 0.0.12119 → 0.0.12550
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/QueryClientProvider-Q_mWQTzQ.js +435 -0
- package/dist/{_baseGet-Bh5zJ_C8.js → _baseGet-B7FwMMGI.js} +9 -9
- package/dist/api-D9Lmqe6S.js +458 -0
- package/dist/components/ModuleBase.js +127 -312
- package/dist/hooks/useCustom.d.ts +2 -1
- package/dist/hooks/useCustom.js +15 -13
- package/dist/hooks/useCustomMutation.d.ts +8 -0
- package/dist/hooks/useCustomMutation.js +21 -0
- package/dist/hooks/useEntity.d.ts +3 -9
- package/dist/hooks/useEntity.js +36 -30
- package/dist/hooks/useOption.d.ts +1 -1
- package/dist/hooks/useOption.js +20 -18
- package/dist/hooks/useServiceBus.d.ts +15 -0
- package/dist/hooks/useServiceBus.js +17 -0
- package/dist/hooks/useStores.d.ts +2 -1
- package/dist/hooks/useStores.js +11 -841
- package/dist/main.d.ts +3 -0
- package/dist/main.js +121 -115
- package/dist/mutation-X73nm7Df.js +192 -0
- package/dist/omit-B7MWDtHq.js +835 -0
- package/dist/query-CRIVoEP7.js +277 -0
- package/dist/types/BaseProps.d.ts +3 -0
- package/dist/types/ModuleApi.d.ts +77 -4
- package/dist/types/Requests.d.ts +2 -1
- package/dist/types/ServiceBus.d.ts +17 -0
- package/dist/types/ServiceBus.js +1 -0
- package/dist/useMutation-3rykrmeD.js +97 -0
- package/dist/{useQuery-znAyMQW1.js → useQuery-CwwWze9O.js} +96 -98
- package/dist/utils/api.d.ts +20 -0
- package/dist/utils/api.js +9 -0
- package/dist/utils/baseFetches.d.ts +19 -0
- package/dist/utils/baseFetches.js +19 -0
- package/dist/utils/fetches.d.ts +31 -22
- package/dist/utils/fetches.js +19 -14
- package/dist/utils-DxRR_XLb.js +9 -0
- package/package.json +2 -2
- package/dist/QueryClientProvider-DQv4Y3Qu.js +0 -707
- package/dist/fetches-DUCQo_6B.js +0 -477
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export declare const useCustom: <T>({ endpoint, queryKey, token, selector, }: {
|
|
1
|
+
export declare const useCustom: <T>({ endpoint, queryKey, token, selector, enabled }: {
|
|
2
2
|
endpoint: string;
|
|
3
3
|
queryKey: (string | undefined)[];
|
|
4
4
|
token?: string;
|
|
5
5
|
selector?: (data: any) => T;
|
|
6
|
+
enabled?: boolean;
|
|
6
7
|
}) => import('@tanstack/react-query').UseQueryResult<T, Error>;
|
package/dist/hooks/useCustom.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import { useBasePropsStore as
|
|
3
|
-
import { universalSelector as
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
1
|
+
import { u as i } from "../useQuery-CwwWze9O.js";
|
|
2
|
+
import { useBasePropsStore as n } from "../stores/BasePropsStore.js";
|
|
3
|
+
import { universalSelector as p } from "../types/Requests.js";
|
|
4
|
+
import { fetchFromCustomApi as a } from "../utils/fetches.js";
|
|
5
|
+
const l = ({
|
|
6
6
|
endpoint: e,
|
|
7
7
|
queryKey: t,
|
|
8
|
-
token:
|
|
9
|
-
selector: o
|
|
8
|
+
token: u,
|
|
9
|
+
selector: o,
|
|
10
|
+
enabled: m = !0
|
|
10
11
|
}) => {
|
|
11
|
-
const
|
|
12
|
-
return
|
|
13
|
-
queryKey: [...t,
|
|
14
|
-
queryFn: () =>
|
|
15
|
-
select: (r) => o ? o(r) :
|
|
12
|
+
const s = n((r) => r.organizationId);
|
|
13
|
+
return i({
|
|
14
|
+
queryKey: [...t, s],
|
|
15
|
+
queryFn: () => a(e, u),
|
|
16
|
+
select: (r) => o ? o(r) : p(r),
|
|
17
|
+
enabled: m
|
|
16
18
|
});
|
|
17
19
|
};
|
|
18
20
|
export {
|
|
19
|
-
|
|
21
|
+
l as useCustom
|
|
20
22
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import { BaseResponse, httpMethod } from '../types/Requests';
|
|
3
|
+
export declare const useCustomMutation: <Input, Output>({ endpoint, method, token, headers, }: {
|
|
4
|
+
endpoint: string;
|
|
5
|
+
method: Omit<httpMethod, "GET">;
|
|
6
|
+
token?: string;
|
|
7
|
+
headers?: Headers;
|
|
8
|
+
}) => UseMutationResult<BaseResponse<Output>, Error, Input, unknown>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { u } from "../useMutation-3rykrmeD.js";
|
|
2
|
+
import "../components/ModuleBase.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import "../stores/BasePropsStore.js";
|
|
5
|
+
import "../provider/SignalR/SignalRProvider.js";
|
|
6
|
+
import "../omit-B7MWDtHq.js";
|
|
7
|
+
import "../stores/EnvironmentStore.js";
|
|
8
|
+
import { mutateOnCustomApi as n } from "../utils/fetches.js";
|
|
9
|
+
import "./useEntity.js";
|
|
10
|
+
import "../api-D9Lmqe6S.js";
|
|
11
|
+
const O = ({
|
|
12
|
+
endpoint: t,
|
|
13
|
+
method: o,
|
|
14
|
+
token: m,
|
|
15
|
+
headers: r
|
|
16
|
+
}) => u({
|
|
17
|
+
mutationFn: (i, p) => n(p ?? t, i, o, m, r)
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
O as useCustomMutation
|
|
21
|
+
};
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import { Block, BlockPlantLayout, Farm, FarmOrgEntity, Field, ModuleEntity, Season } from '../types/ModuleApi';
|
|
1
|
+
import { Block, BlockPlantLayout, Farm, FarmAlertRule, FarmOrganization, FarmOrgEntity, Field, IrrigationStation, ModuleEntity, Season } from '../types/ModuleApi';
|
|
2
2
|
type HortiviewDataAreaGroup = 'FarmOrganization' | 'FarmMember';
|
|
3
3
|
type ModuleDataAreaGroup = 'ModuleDepended';
|
|
4
4
|
type FarmOrganizationEntities = 'farms' | 'fields' | 'zones' | 'irrigation_stations' | 'farm_organizations' | 'alert_rules';
|
|
5
5
|
type FarmMemberEntities = 'farm_members';
|
|
6
6
|
type ModuleDependendEntities = 'Season' | 'BlockPlantLayout' | (string & {});
|
|
7
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' ?
|
|
9
|
-
id: string;
|
|
10
|
-
} : T extends 'farm_organizations' ? {
|
|
11
|
-
id: string;
|
|
12
|
-
} : T extends 'alert_rules' ? {
|
|
13
|
-
id: string;
|
|
14
|
-
} : T extends 'Season' ? Season : T extends 'BlockPlantLayout' ? BlockPlantLayout : 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;
|
|
15
9
|
export declare const FarmOrgEntitiesTypeResultMap: Record<FarmOrganizationEntities, string>;
|
|
16
10
|
export declare const FarmMemberEntitiesTypeResultMap: Record<FarmMemberEntities, string>;
|
|
17
11
|
export declare const ModuleDependedEntityTypeResultMap: Record<ModuleDependendEntities, string>;
|
|
@@ -26,7 +20,7 @@ export declare const AllEntitiesTypeResultMap: {
|
|
|
26
20
|
farm_organizations: string;
|
|
27
21
|
alert_rules: string;
|
|
28
22
|
};
|
|
29
|
-
export declare const useEntity: <K extends HortiviewDataAreaGroup | ModuleDataAreaGroup, E extends HortiviewDataAreaEntity<K>>(group: K, entity: E) => {
|
|
23
|
+
export declare const useEntity: <K extends HortiviewDataAreaGroup | ModuleDataAreaGroup, E extends HortiviewDataAreaEntity<K>>(group: K, entity: E, enabled?: boolean) => {
|
|
30
24
|
data: ResultMap<E>[];
|
|
31
25
|
error: Error;
|
|
32
26
|
isError: true;
|
package/dist/hooks/useEntity.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { u as
|
|
1
|
+
import { u as l } from "../useQuery-CwwWze9O.js";
|
|
2
2
|
import { useMemo as g } from "react";
|
|
3
|
-
import { useBasePropsStore as
|
|
4
|
-
import { universalSelector as
|
|
5
|
-
import {
|
|
6
|
-
import { useOption as
|
|
3
|
+
import { useBasePropsStore as p } from "../stores/BasePropsStore.js";
|
|
4
|
+
import { universalSelector as y } from "../types/Requests.js";
|
|
5
|
+
import { getModuleDependedEntities as R, getFarmOrgEntities as k } from "../utils/fetches.js";
|
|
6
|
+
import { useOption as E, useModuleDependency as D } from "./useOption.js";
|
|
7
7
|
const F = {
|
|
8
8
|
farms: "farm",
|
|
9
9
|
fields: "field",
|
|
@@ -20,39 +20,45 @@ const F = {
|
|
|
20
20
|
...F,
|
|
21
21
|
...Q,
|
|
22
22
|
...q
|
|
23
|
-
},
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
return n ? n.find((s) => s.registeredEntityName ===
|
|
27
|
-
if (!
|
|
28
|
-
const r =
|
|
29
|
-
return r ?
|
|
30
|
-
}, [
|
|
31
|
-
|
|
32
|
-
|
|
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(
|
|
31
|
+
o,
|
|
32
|
+
M,
|
|
33
|
+
d,
|
|
34
|
+
m,
|
|
35
|
+
a
|
|
36
|
+
), b = (f.data ?? []).map((r) => {
|
|
37
|
+
const c = A[t];
|
|
38
|
+
return r[c];
|
|
33
39
|
});
|
|
34
40
|
return {
|
|
35
|
-
...
|
|
36
|
-
data:
|
|
41
|
+
...f,
|
|
42
|
+
data: b
|
|
37
43
|
};
|
|
38
|
-
},
|
|
39
|
-
const
|
|
40
|
-
queryKey: [
|
|
41
|
-
queryFn: () =>
|
|
42
|
-
enabled: o && !!
|
|
43
|
-
select: (n) =>
|
|
44
|
-
}),
|
|
45
|
-
queryKey: [
|
|
46
|
-
queryFn: () =>
|
|
47
|
-
enabled: !o && !!
|
|
48
|
-
select: (n) =>
|
|
44
|
+
}, O = (e, t, a, o, d = !0) => {
|
|
45
|
+
const u = l({
|
|
46
|
+
queryKey: [e, a, t],
|
|
47
|
+
queryFn: () => R(e ?? "", t ?? ""),
|
|
48
|
+
enabled: d && o && !!e && !!t && !!a,
|
|
49
|
+
select: (n) => y(n)
|
|
50
|
+
}), i = l({
|
|
51
|
+
queryKey: [e, a, t],
|
|
52
|
+
queryFn: () => k(e ?? "", t ?? ""),
|
|
53
|
+
enabled: d && !o && !!e && !!t && !!a,
|
|
54
|
+
select: (n) => y(n)
|
|
49
55
|
});
|
|
50
|
-
return o ?
|
|
56
|
+
return o ? u : i;
|
|
51
57
|
};
|
|
52
58
|
export {
|
|
53
59
|
A as AllEntitiesTypeResultMap,
|
|
54
60
|
Q as FarmMemberEntitiesTypeResultMap,
|
|
55
61
|
F as FarmOrgEntitiesTypeResultMap,
|
|
56
62
|
q as ModuleDependedEntityTypeResultMap,
|
|
57
|
-
|
|
63
|
+
K as useEntity
|
|
58
64
|
};
|
|
@@ -14,4 +14,4 @@ import { RegisterOption } from '../types/ModuleApi';
|
|
|
14
14
|
* or fetches it from the API. The result is then processed by a universal selector.
|
|
15
15
|
*/
|
|
16
16
|
export declare const useOption: (dropdown: keyof typeof CommonOptionType) => UseQueryResult<CommonOption[], Error>;
|
|
17
|
-
export declare const useModuleDependency: () => UseQueryResult<RegisterOption[], Error>;
|
|
17
|
+
export declare const useModuleDependency: (enabled?: boolean) => UseQueryResult<RegisterOption[], Error>;
|
package/dist/hooks/useOption.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import {
|
|
3
|
-
import { useBasePropsStore as
|
|
4
|
-
import { universalSelector as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { u as m } from "../useQuery-CwwWze9O.js";
|
|
2
|
+
import { g as u } from "../api-D9Lmqe6S.js";
|
|
3
|
+
import { useBasePropsStore as n } from "../stores/BasePropsStore.js";
|
|
4
|
+
import { universalSelector as s } from "../types/Requests.js";
|
|
5
|
+
import { fetchFromCommonApi as i, fetchFromModuleApi as c } from "../utils/fetches.js";
|
|
6
|
+
const f = (e) => {
|
|
7
|
+
const r = n((o) => o.commonOptions), t = u(r, e);
|
|
8
|
+
return m({
|
|
9
|
+
queryKey: [e],
|
|
10
|
+
queryFn: () => t ? Promise.resolve(t) : i(`${e}/dropdown`),
|
|
11
|
+
select: (o) => s(o)
|
|
11
12
|
});
|
|
12
|
-
},
|
|
13
|
-
const
|
|
14
|
-
return
|
|
15
|
-
queryKey: [
|
|
16
|
-
queryFn: () =>
|
|
17
|
-
select: (
|
|
13
|
+
}, g = (e = !0) => {
|
|
14
|
+
const r = n((o) => o.moduleId), t = n((o) => o.organizationId);
|
|
15
|
+
return m({
|
|
16
|
+
queryKey: [r, t],
|
|
17
|
+
queryFn: () => c(`ModuleDependencies/${r}`),
|
|
18
|
+
select: (o) => s(o),
|
|
19
|
+
enabled: e
|
|
18
20
|
});
|
|
19
21
|
};
|
|
20
22
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
g as useModuleDependency,
|
|
24
|
+
f as useOption
|
|
23
25
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import { AlertServiceBusMessage } from '../types/ServiceBus';
|
|
3
|
+
import { BaseResponse } from '../types/Requests';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param authenticationKey SASToken, that will be provided by the vendor portal of HortiView
|
|
7
|
+
* @param queue url of the service bus queue
|
|
8
|
+
* @param topic topic of the service bus, where the message will be sent to
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare const useServiceBus: ({ authenticationKey, queue, topic, }: {
|
|
12
|
+
authenticationKey: string;
|
|
13
|
+
queue: string;
|
|
14
|
+
topic: string;
|
|
15
|
+
}) => UseMutationResult<BaseResponse<unknown>, Error, AlertServiceBusMessage, unknown>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { u } from "../useMutation-3rykrmeD.js";
|
|
2
|
+
import { useBasePropsStore as t } from "../stores/BasePropsStore.js";
|
|
3
|
+
const f = ({
|
|
4
|
+
authenticationKey: i,
|
|
5
|
+
queue: e,
|
|
6
|
+
topic: s
|
|
7
|
+
}) => {
|
|
8
|
+
const r = t((o) => o.serviceBusNotification), n = t((o) => o.throwError);
|
|
9
|
+
if (!r)
|
|
10
|
+
throw n?.("serviceBusNotification is not defined", 400);
|
|
11
|
+
return u({
|
|
12
|
+
mutationFn: (o) => r(o, i, e, s)
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
f as useServiceBus
|
|
17
|
+
};
|
|
@@ -9,6 +9,7 @@ export declare const useBaseProps: () => Pick<import('../types/Deprecated').Depr
|
|
|
9
9
|
currentLanguageId?: string;
|
|
10
10
|
alertRules?: string;
|
|
11
11
|
commonOptions?: import('../types/CommonOptions').AllDropdownsData<import('../types/CommonOptions').CommonOption>["items"];
|
|
12
|
+
serviceBusNotification?: (message: import('../types/ServiceBus').AlertServiceBusMessage, apiKey: string, queue: string, topic: string) => Promise<unknown>;
|
|
12
13
|
navigateInHortiview?: (path: string) => void;
|
|
13
14
|
addBreadcrumbTranslation?: (translation: {
|
|
14
15
|
key: string;
|
|
@@ -21,7 +22,7 @@ export declare const useBaseProps: () => Pick<import('../types/Deprecated').Depr
|
|
|
21
22
|
throwError?: (message: string, code: number) => void;
|
|
22
23
|
} & {
|
|
23
24
|
setBaseProps: (props: import('../main').BaseProps) => void;
|
|
24
|
-
}, keyof import('../types/Deprecated').DeprecatedBaseProps | "modulePermissionToken" | "moduleId" | "organizationId" | "basePath" | "currentNavigationPath" | "sourcePath" | "currentLanguage" | "currentLanguageId" | "alertRules" | "commonOptions" | "navigateInHortiview" | "addBreadcrumbTranslation" | "showSnackbar" | "showMessage" | "logEvent" | "logError" | "throwError">;
|
|
25
|
+
}, keyof import('../types/Deprecated').DeprecatedBaseProps | "modulePermissionToken" | "moduleId" | "organizationId" | "basePath" | "currentNavigationPath" | "sourcePath" | "currentLanguage" | "currentLanguageId" | "alertRules" | "commonOptions" | "serviceBusNotification" | "navigateInHortiview" | "addBreadcrumbTranslation" | "showSnackbar" | "showMessage" | "logEvent" | "logError" | "throwError">;
|
|
25
26
|
export declare const useConfig: () => Pick<{
|
|
26
27
|
environment: import('../types/Environment').HortiViewEnvironments;
|
|
27
28
|
setEnvironment: (environment: import('../types/Environment').HortiViewEnvironments) => void;
|