@hortiview/modulebase 0.0.13925 → 0.0.14106
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/components/ModuleCore.js +444 -441
- package/dist/hooks/useEntity.js +20 -19
- package/dist/lib/components/ModuleBase.d.ts +27 -5
- package/dist/lib/components/ModuleCore.d.ts +24 -5
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/hooks/useStores.d.ts +2 -1
- package/dist/lib/main.d.ts +1 -0
- package/dist/lib/types/BaseProps.d.ts +2 -0
- package/dist/lib/types/EnvironmentVariable.d.ts +6 -0
- package/dist/types/EnvironmentVariable.js +1 -0
- package/dist/utils/helper.js +1 -1
- package/package.json +1 -1
package/dist/hooks/useEntity.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { u as f } from "../useQuery-XBGd5Kep.js";
|
|
2
2
|
import { useMemo as p } from "react";
|
|
3
3
|
import { useBasePropsStore as y } from "../stores/BasePropsStore.js";
|
|
4
|
-
import { getModuleDependedEntities as
|
|
4
|
+
import { getModuleDependedEntities as R, getFarmOrgEntities as b } from "../utils/fetches.js";
|
|
5
5
|
import { universalSelector as E } from "../utils/helper.js";
|
|
6
6
|
import { useOption as M, useModuleDependency as k } from "./useOption.js";
|
|
7
7
|
const D = {
|
|
@@ -15,45 +15,46 @@ const D = {
|
|
|
15
15
|
farm_members: "member"
|
|
16
16
|
}, Q = {
|
|
17
17
|
Season: "season",
|
|
18
|
-
BlockPlantLayout: "blockPlantLayout"
|
|
18
|
+
BlockPlantLayout: "blockPlantLayout",
|
|
19
|
+
Record: "recordLight"
|
|
19
20
|
}, q = {
|
|
20
21
|
...D,
|
|
21
22
|
...F,
|
|
22
23
|
...Q
|
|
23
|
-
},
|
|
24
|
-
const o = y((n) => n.moduleId), c = y((n) => n.organizationId), { data: u } = M("DataAreaGroup"), { data: i } = M("DataAreaEntity"), { data: s } = k(
|
|
24
|
+
}, B = (r, e, a = !0) => {
|
|
25
|
+
const o = y((n) => n.moduleId), c = y((n) => n.organizationId), { data: u } = M("DataAreaGroup"), { data: i } = M("DataAreaEntity"), { data: s } = k(r === "ModuleDepended"), d = r === "ModuleDepended", g = p(() => {
|
|
25
26
|
if (d)
|
|
26
|
-
return s ? s.find((
|
|
27
|
+
return s ? s.find((t) => t.registeredEntityName === e)?.id : void 0;
|
|
27
28
|
if (!u || !i) return;
|
|
28
|
-
const n = u.find((
|
|
29
|
-
return n ? i.find((
|
|
30
|
-
}, [d, u, i, s, e,
|
|
29
|
+
const n = u.find((t) => t.key === r)?.id;
|
|
30
|
+
return n ? i.find((t) => t.description === n && t.value === e)?.id : void 0;
|
|
31
|
+
}, [d, u, i, s, e, r]), l = A(
|
|
31
32
|
o,
|
|
32
|
-
|
|
33
|
+
g,
|
|
33
34
|
c,
|
|
34
35
|
d,
|
|
35
36
|
a
|
|
36
37
|
);
|
|
37
38
|
return p(() => {
|
|
38
39
|
const n = (l.data ?? []).map((m) => {
|
|
39
|
-
const
|
|
40
|
-
return m[
|
|
40
|
+
const t = q[e];
|
|
41
|
+
return m[t];
|
|
41
42
|
});
|
|
42
43
|
return {
|
|
43
44
|
...l,
|
|
44
45
|
data: n
|
|
45
46
|
};
|
|
46
47
|
}, [e, l, d]);
|
|
47
|
-
}, A = (
|
|
48
|
+
}, A = (r, e, a, o, c = !0) => {
|
|
48
49
|
const u = f({
|
|
49
|
-
queryKey: [
|
|
50
|
-
queryFn: () =>
|
|
51
|
-
enabled: c && o && !!
|
|
50
|
+
queryKey: [r, a, e],
|
|
51
|
+
queryFn: () => R(r ?? "", e ?? ""),
|
|
52
|
+
enabled: c && o && !!r && !!e && !!a,
|
|
52
53
|
select: (s) => E(s)
|
|
53
54
|
}), i = f({
|
|
54
|
-
queryKey: [
|
|
55
|
-
queryFn: () =>
|
|
56
|
-
enabled: c && !o && !!
|
|
55
|
+
queryKey: [r, a, e],
|
|
56
|
+
queryFn: () => b(r ?? "", e ?? ""),
|
|
57
|
+
enabled: c && !o && !!r && !!e && !!a,
|
|
57
58
|
select: (s) => E(s)
|
|
58
59
|
});
|
|
59
60
|
return o ? u : i;
|
|
@@ -63,5 +64,5 @@ export {
|
|
|
63
64
|
F as FarmMemberEntitiesTypeResultMap,
|
|
64
65
|
D as FarmOrgEntitiesTypeResultMap,
|
|
65
66
|
Q as ModuleDependedEntityTypeResultMap,
|
|
66
|
-
|
|
67
|
+
B as useEntity
|
|
67
68
|
};
|
|
@@ -2,13 +2,35 @@ import { QueryClient } from '@tanstack/react-query';
|
|
|
2
2
|
import { RouteObject } from 'react-router';
|
|
3
3
|
import { BaseProps } from '../types/BaseProps';
|
|
4
4
|
import { EnvConfig } from '../types/Environment';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
type ModuleBaseProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Properties that are passed to the Base component by the host application, {@link BaseProps}
|
|
8
|
+
*/
|
|
9
9
|
props: BaseProps;
|
|
10
|
+
/**
|
|
11
|
+
* Routes that are used in the module, {@link RouteObject}
|
|
12
|
+
*/
|
|
10
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
|
+
*/
|
|
11
21
|
env?: EnvConfig;
|
|
22
|
+
/**
|
|
23
|
+
* If true, the module will use the SignalR provider to connect to the module API.
|
|
24
|
+
*/
|
|
12
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
|
+
*/
|
|
13
30
|
queryClient?: QueryClient;
|
|
14
|
-
}
|
|
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 {};
|
|
@@ -2,12 +2,31 @@ import { QueryClient } from '@tanstack/react-query';
|
|
|
2
2
|
import { BaseProps } from '../types/BaseProps';
|
|
3
3
|
import { EnvConfig } from '../types/Environment';
|
|
4
4
|
export declare const ModuleQueryClient: QueryClient;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
type ModuleCoreProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Properties that are passed to the Base component by the host application, {@link BaseProps}
|
|
8
|
+
*/
|
|
9
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
|
+
*/
|
|
10
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
|
+
*/
|
|
11
22
|
queryClient?: QueryClient;
|
|
23
|
+
/**
|
|
24
|
+
* Children components that are rendered within the module core
|
|
25
|
+
*/
|
|
12
26
|
children: React.ReactNode;
|
|
13
|
-
}
|
|
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 {};
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -20,9 +20,10 @@ export declare const useBaseProps: () => Pick<import('../main').DeprecatedBasePr
|
|
|
20
20
|
logEvent?: (event: import('../main').AppInsightsEvent, customProperties?: import('../main').AppInsightsProperties) => void;
|
|
21
21
|
logError?: (exception: import('../main').AppInsightsException) => void;
|
|
22
22
|
throwError?: (message: string, code: number) => void;
|
|
23
|
+
environmentVariables?: import('../main').EnvironmentVariable[];
|
|
23
24
|
} & {
|
|
24
25
|
setBaseProps: (props: import('../main').BaseProps) => void;
|
|
25
|
-
}, keyof import('../main').DeprecatedBaseProps | "modulePermissionToken" | "moduleId" | "organizationId" | "basePath" | "currentNavigationPath" | "sourcePath" | "currentLanguage" | "currentLanguageId" | "alertRules" | "commonOptions" | "riseNotification" | "navigateInHortiview" | "addBreadcrumbTranslation" | "showSnackbar" | "showMessage" | "logEvent" | "logError" | "throwError">;
|
|
26
|
+
}, keyof import('../main').DeprecatedBaseProps | "modulePermissionToken" | "moduleId" | "organizationId" | "basePath" | "currentNavigationPath" | "sourcePath" | "currentLanguage" | "currentLanguageId" | "alertRules" | "commonOptions" | "riseNotification" | "navigateInHortiview" | "addBreadcrumbTranslation" | "showSnackbar" | "showMessage" | "logEvent" | "logError" | "throwError" | "environmentVariables">;
|
|
26
27
|
export declare const useConfig: () => Pick<{
|
|
27
28
|
environment: import('../main').HortiViewEnvironments;
|
|
28
29
|
setEnvironment: (environment: import('../main').HortiViewEnvironments) => void;
|
package/dist/lib/main.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type * from './types/BaseProps';
|
|
|
5
5
|
export type * from './types/CommonOptions';
|
|
6
6
|
export type * from './types/Deprecated';
|
|
7
7
|
export type * from './types/Environment';
|
|
8
|
+
export type * from './types/EnvironmentVariable';
|
|
8
9
|
export type * from './types/ModuleApi';
|
|
9
10
|
export type * from './types/Requests';
|
|
10
11
|
export type * from './types/ServiceBus';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AppInsightsEvent, AppInsightsException, AppInsightsProperties } from './AppInsights';
|
|
2
2
|
import { AllDropdownsData, CommonOption } from './CommonOptions';
|
|
3
3
|
import { DeprecatedBaseProps } from './Deprecated';
|
|
4
|
+
import { EnvironmentVariable } from './EnvironmentVariable';
|
|
4
5
|
import { AlertServiceBusMessage } from './ServiceBus';
|
|
5
6
|
import { SystemMessage } from './SystemMessage';
|
|
6
7
|
/**
|
|
@@ -37,4 +38,5 @@ export type BaseProps = DeprecatedBaseProps & {
|
|
|
37
38
|
logEvent?: (event: AppInsightsEvent, customProperties?: AppInsightsProperties) => void;
|
|
38
39
|
logError?: (exception: AppInsightsException) => void;
|
|
39
40
|
throwError?: (message: string, code: number) => void;
|
|
41
|
+
environmentVariables?: EnvironmentVariable[];
|
|
40
42
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
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.14106", 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