@hortiview/modulebase 0.0.1-7.1-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.
Files changed (85) hide show
  1. package/README.md +8 -0
  2. package/dist/ModuleCore-YCIFN_02.js +14973 -0
  3. package/dist/QueryClientProvider-Beog9TR7.js +437 -0
  4. package/dist/_baseGet-C6jMXSsQ.js +805 -0
  5. package/dist/_commonjsHelpers-BkfeUUK-.js +28 -0
  6. package/dist/api-s6E2GJtu.js +458 -0
  7. package/dist/assets/ModuleCore.css +1 -0
  8. package/dist/chunk-IR6S3I6Y-BmDdD3SP.js +8162 -0
  9. package/dist/components/ModuleBase.js +30 -0
  10. package/dist/components/ModuleCore.js +10 -0
  11. package/dist/constants.js +34 -0
  12. package/dist/hooks/useBreadcrumbTranslation.js +23 -0
  13. package/dist/hooks/useCustom.js +19 -0
  14. package/dist/hooks/useCustomMutation.js +23 -0
  15. package/dist/hooks/useEntity.js +57 -0
  16. package/dist/hooks/useOffline.js +45 -0
  17. package/dist/hooks/useOption.js +25 -0
  18. package/dist/hooks/useServiceBus.js +25 -0
  19. package/dist/hooks/useSignalRMessages.js +13 -0
  20. package/dist/hooks/useStores.js +14 -0
  21. package/dist/isRestoring-CLuxJVSA.js +281 -0
  22. package/dist/lib/components/ModuleBase.d.ts +36 -0
  23. package/dist/lib/components/ModuleCore.d.ts +32 -0
  24. package/dist/lib/constants.d.ts +25 -0
  25. package/dist/lib/hooks/useBreadcrumbTranslation.d.ts +1 -0
  26. package/dist/lib/hooks/useCustom.d.ts +8 -0
  27. package/dist/lib/hooks/useCustomMutation.d.ts +9 -0
  28. package/dist/lib/hooks/useEntity.d.ts +162 -0
  29. package/dist/lib/hooks/useOffline.d.ts +15 -0
  30. package/dist/lib/hooks/useOption.d.ts +17 -0
  31. package/dist/lib/hooks/useServiceBus.d.ts +19 -0
  32. package/dist/lib/hooks/useSignalRMessages.d.ts +6 -0
  33. package/dist/lib/hooks/useStores.d.ts +37 -0
  34. package/dist/lib/main.d.ts +27 -0
  35. package/dist/lib/module-router.d.ts +7 -0
  36. package/dist/lib/provider/SignalR/SignalRProvider.d.ts +13 -0
  37. package/dist/lib/provider/SignalR/signalR.d.ts +53 -0
  38. package/dist/lib/stores/BasePropsStore.d.ts +6 -0
  39. package/dist/lib/stores/EnvironmentStore.d.ts +8 -0
  40. package/dist/lib/types/ActionStorage.d.ts +12 -0
  41. package/dist/lib/types/AppInsights.d.ts +12 -0
  42. package/dist/lib/types/BaseProps.d.ts +49 -0
  43. package/dist/lib/types/CommonOptions.d.ts +61 -0
  44. package/dist/lib/types/Deprecated.d.ts +99 -0
  45. package/dist/lib/types/Entities.d.ts +22 -0
  46. package/dist/lib/types/Environment.d.ts +18 -0
  47. package/dist/lib/types/EnvironmentVariable.d.ts +6 -0
  48. package/dist/lib/types/ModuleApi.d.ts +163 -0
  49. package/dist/lib/types/Requests.d.ts +44 -0
  50. package/dist/lib/types/ServiceBus.d.ts +17 -0
  51. package/dist/lib/types/SystemMessage.d.ts +14 -0
  52. package/dist/lib/utils/api.d.ts +20 -0
  53. package/dist/lib/utils/baseFetches.d.ts +19 -0
  54. package/dist/lib/utils/fetches.d.ts +43 -0
  55. package/dist/lib/utils/helper.d.ts +29 -0
  56. package/dist/main.js +218 -0
  57. package/dist/module-router.js +129 -0
  58. package/dist/mutation-DSKlaYzY.js +192 -0
  59. package/dist/omit-C9Qe80rl.js +835 -0
  60. package/dist/provider/SignalR/SignalRProvider.js +6408 -0
  61. package/dist/provider/SignalR/signalR.js +11 -0
  62. package/dist/react-QiIgv49H.js +27 -0
  63. package/dist/stores/BasePropsStore.js +7 -0
  64. package/dist/stores/EnvironmentStore.js +15 -0
  65. package/dist/types/ActionStorage.js +4 -0
  66. package/dist/types/AppInsights.js +1 -0
  67. package/dist/types/BaseProps.js +1 -0
  68. package/dist/types/CommonOptions.js +4 -0
  69. package/dist/types/Deprecated.js +1 -0
  70. package/dist/types/Entities.js +25 -0
  71. package/dist/types/Environment.js +1 -0
  72. package/dist/types/EnvironmentVariable.js +1 -0
  73. package/dist/types/ModuleApi.js +1 -0
  74. package/dist/types/Requests.js +1 -0
  75. package/dist/types/ServiceBus.js +1 -0
  76. package/dist/types/SystemMessage.js +1 -0
  77. package/dist/useMutation-zu8uxBak.js +97 -0
  78. package/dist/useQuery-Bj9k9zik.js +395 -0
  79. package/dist/utils/api.js +9 -0
  80. package/dist/utils/baseFetches.js +19 -0
  81. package/dist/utils/fetches.js +22 -0
  82. package/dist/utils/helper.js +55 -0
  83. package/dist/utils-DxRR_XLb.js +9 -0
  84. package/dist/vite-env.d.js +1 -0
  85. package/package.json +60 -0
@@ -0,0 +1,25 @@
1
+ import { BaseProps } from './types/BaseProps';
2
+ export declare const REQUIRED_PROPS: (keyof BaseProps)[];
3
+ export declare const RETRIES = 1;
4
+ export declare const RETRY_HTTP_STATUS_CODES: {
5
+ /**
6
+ * The server timed out waiting for the request.
7
+ */
8
+ RequestTimeout: number;
9
+ /**
10
+ * The user has sent too many requests in a given amount of time ("rate limiting").
11
+ */
12
+ TooManyRequests: number;
13
+ /**
14
+ * The server is not ready to handle the request.
15
+ */
16
+ BadGateway: number;
17
+ /**
18
+ * The server is not available.
19
+ */
20
+ ServiceUnavailable: number;
21
+ /**
22
+ * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
23
+ */
24
+ GatewayTimeout: number;
25
+ };
@@ -0,0 +1 @@
1
+ export declare const useBreadcrumbTranslation: () => (key: string, value: string | false) => void;
@@ -0,0 +1,8 @@
1
+ export declare const useCustom: <T>({ endpoint, queryKey, token, selector, enabled, noAuth }: {
2
+ endpoint: string;
3
+ queryKey: (string | undefined)[];
4
+ token?: string;
5
+ selector?: (data: any) => T;
6
+ enabled?: boolean;
7
+ noAuth?: boolean;
8
+ }) => import('@tanstack/react-query').UseQueryResult<T, Error>;
@@ -0,0 +1,9 @@
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, noAuth }: {
4
+ endpoint: string;
5
+ method: Omit<httpMethod, "GET">;
6
+ token?: string;
7
+ headers?: Headers;
8
+ noAuth?: boolean;
9
+ }) => UseMutationResult<BaseResponse<Output>, Error, Input, unknown>;
@@ -0,0 +1,162 @@
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) => {
4
+ data: ResultMap<E>[];
5
+ error: Error;
6
+ isError: true;
7
+ isPending: false;
8
+ isLoading: false;
9
+ isLoadingError: false;
10
+ isRefetchError: true;
11
+ isSuccess: false;
12
+ isPlaceholderData: false;
13
+ status: "error";
14
+ dataUpdatedAt: number;
15
+ errorUpdatedAt: number;
16
+ failureCount: number;
17
+ failureReason: Error | null;
18
+ errorUpdateCount: number;
19
+ isFetched: boolean;
20
+ isFetchedAfterMount: boolean;
21
+ isFetching: boolean;
22
+ isInitialLoading: boolean;
23
+ isPaused: boolean;
24
+ isRefetching: boolean;
25
+ isStale: boolean;
26
+ refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<FarmOrgEntity[] | ModuleEntity[], Error>>;
27
+ fetchStatus: import('@tanstack/query-core').FetchStatus;
28
+ promise: Promise<FarmOrgEntity[] | ModuleEntity[]>;
29
+ } | {
30
+ data: ResultMap<E>[];
31
+ error: null;
32
+ isError: false;
33
+ isPending: false;
34
+ isLoading: false;
35
+ isLoadingError: false;
36
+ isRefetchError: false;
37
+ isSuccess: true;
38
+ isPlaceholderData: false;
39
+ status: "success";
40
+ dataUpdatedAt: number;
41
+ errorUpdatedAt: number;
42
+ failureCount: number;
43
+ failureReason: Error | null;
44
+ errorUpdateCount: number;
45
+ isFetched: boolean;
46
+ isFetchedAfterMount: boolean;
47
+ isFetching: boolean;
48
+ isInitialLoading: boolean;
49
+ isPaused: boolean;
50
+ isRefetching: boolean;
51
+ isStale: boolean;
52
+ refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<FarmOrgEntity[] | ModuleEntity[], Error>>;
53
+ fetchStatus: import('@tanstack/query-core').FetchStatus;
54
+ promise: Promise<FarmOrgEntity[] | ModuleEntity[]>;
55
+ } | {
56
+ data: ResultMap<E>[];
57
+ error: Error;
58
+ isError: true;
59
+ isPending: false;
60
+ isLoading: false;
61
+ isLoadingError: true;
62
+ isRefetchError: false;
63
+ isSuccess: false;
64
+ isPlaceholderData: false;
65
+ status: "error";
66
+ dataUpdatedAt: number;
67
+ errorUpdatedAt: number;
68
+ failureCount: number;
69
+ failureReason: Error | null;
70
+ errorUpdateCount: number;
71
+ isFetched: boolean;
72
+ isFetchedAfterMount: boolean;
73
+ isFetching: boolean;
74
+ isInitialLoading: boolean;
75
+ isPaused: boolean;
76
+ isRefetching: boolean;
77
+ isStale: boolean;
78
+ refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<FarmOrgEntity[] | ModuleEntity[], Error>>;
79
+ fetchStatus: import('@tanstack/query-core').FetchStatus;
80
+ promise: Promise<FarmOrgEntity[] | ModuleEntity[]>;
81
+ } | {
82
+ data: ResultMap<E>[];
83
+ error: null;
84
+ isError: false;
85
+ isPending: true;
86
+ isLoading: true;
87
+ isLoadingError: false;
88
+ isRefetchError: false;
89
+ isSuccess: false;
90
+ isPlaceholderData: false;
91
+ status: "pending";
92
+ dataUpdatedAt: number;
93
+ errorUpdatedAt: number;
94
+ failureCount: number;
95
+ failureReason: Error | null;
96
+ errorUpdateCount: number;
97
+ isFetched: boolean;
98
+ isFetchedAfterMount: boolean;
99
+ isFetching: boolean;
100
+ isInitialLoading: boolean;
101
+ isPaused: boolean;
102
+ isRefetching: boolean;
103
+ isStale: boolean;
104
+ refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<FarmOrgEntity[] | ModuleEntity[], Error>>;
105
+ fetchStatus: import('@tanstack/query-core').FetchStatus;
106
+ promise: Promise<FarmOrgEntity[] | ModuleEntity[]>;
107
+ } | {
108
+ data: ResultMap<E>[];
109
+ error: null;
110
+ isError: false;
111
+ isPending: true;
112
+ isLoadingError: false;
113
+ isRefetchError: false;
114
+ isSuccess: false;
115
+ isPlaceholderData: false;
116
+ status: "pending";
117
+ dataUpdatedAt: number;
118
+ errorUpdatedAt: number;
119
+ failureCount: number;
120
+ failureReason: Error | null;
121
+ errorUpdateCount: number;
122
+ isFetched: boolean;
123
+ isFetchedAfterMount: boolean;
124
+ isFetching: boolean;
125
+ isLoading: boolean;
126
+ isInitialLoading: boolean;
127
+ isPaused: boolean;
128
+ isRefetching: boolean;
129
+ isStale: boolean;
130
+ refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<FarmOrgEntity[] | ModuleEntity[], Error>>;
131
+ fetchStatus: import('@tanstack/query-core').FetchStatus;
132
+ promise: Promise<FarmOrgEntity[] | ModuleEntity[]>;
133
+ } | {
134
+ data: ResultMap<E>[];
135
+ isError: false;
136
+ error: null;
137
+ isPending: false;
138
+ isLoading: false;
139
+ isLoadingError: false;
140
+ isRefetchError: false;
141
+ isSuccess: true;
142
+ isPlaceholderData: true;
143
+ status: "success";
144
+ dataUpdatedAt: number;
145
+ errorUpdatedAt: number;
146
+ failureCount: number;
147
+ failureReason: Error | null;
148
+ errorUpdateCount: number;
149
+ isFetched: boolean;
150
+ isFetchedAfterMount: boolean;
151
+ isFetching: boolean;
152
+ isInitialLoading: boolean;
153
+ isPaused: boolean;
154
+ isRefetching: boolean;
155
+ isStale: boolean;
156
+ refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<FarmOrgEntity[] | ModuleEntity[], Error>>;
157
+ fetchStatus: import('@tanstack/query-core').FetchStatus;
158
+ promise: Promise<FarmOrgEntity[] | ModuleEntity[]>;
159
+ };
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
+ };
@@ -0,0 +1,17 @@
1
+ import { UseQueryResult } from '@tanstack/react-query';
2
+ import { CommonOption, CommonOptionType } from '../types/CommonOptions';
3
+ import { RegisterOption } from '../types/ModuleApi';
4
+ /**
5
+ * Custom hook to fetch and manage options for a dropdown.
6
+ *
7
+ * @param dropdown - The key of the dropdown option to fetch from the common options.
8
+ * @returns A query object from `useQuery` containing the fetched dropdown options.
9
+ *
10
+ * This hook first attempts to retrieve the dropdown options from the HortiView-platform (module-property `commonOptions`).
11
+ * If the options are not available locally, it fetches them from a common API endpoint.
12
+ *
13
+ * The query key is set to the dropdown key, and the query function either resolves the local option
14
+ * or fetches it from the API. The result is then processed by a universal selector.
15
+ */
16
+ export declare const useOption: (dropdown: keyof typeof CommonOptionType) => UseQueryResult<CommonOption[], Error>;
17
+ export declare const useModuleDependency: (enabled?: boolean) => UseQueryResult<RegisterOption[], Error>;
@@ -0,0 +1,19 @@
1
+ import { UseMutationResult } from '@tanstack/react-query';
2
+ import { BaseResponse } from '../types/Requests';
3
+ import { AlertServiceBusMessage } from '../types/ServiceBus';
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
+ * @deprecated use useNotification instead
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>;
16
+ /**
17
+ * create a notification in the service bus
18
+ */
19
+ export declare const useNotification: () => UseMutationResult<BaseResponse<unknown>, Error, AlertServiceBusMessage, unknown>;
@@ -0,0 +1,6 @@
1
+ import { SignalRMessage } from '../provider/SignalR/signalR';
2
+ /**
3
+ * hook to react on messages from signalR
4
+ * @param callback callback function to be called when a message is received
5
+ */
6
+ export declare const useSignalRMessages: (callback: (message: SignalRMessage) => void) => void;
@@ -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,7 @@
1
+ /**
2
+ *
3
+ * @returns A function to navigate to a specific path
4
+ */
5
+ declare const useNavigate: () => (path: string) => void;
6
+ export * from 'react-router';
7
+ export { useNavigate };
@@ -0,0 +1,13 @@
1
+ import { PropsWithChildren } from 'react';
2
+ /**
3
+ * SignalRProvider on behalf of the module
4
+ */
5
+ export declare const SignalRModuleContext: import('react-signalr/lib/signalr/types').Context<import('react-signalr/lib/signalr/types').Hub<string, string>>;
6
+ /**
7
+ * SignalRProvider
8
+ * @param children
9
+ * @returns
10
+ */
11
+ export declare const SignalRProvider: ({ children, enabled, }: PropsWithChildren & {
12
+ enabled: boolean;
13
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * SignalR message interface, contains property bag for additional data
3
+ */
4
+ export interface SignalRMessage {
5
+ messageId: string;
6
+ messageType: keyof typeof MessageType;
7
+ entityId: string;
8
+ entityType: keyof typeof EntityType;
9
+ operationType: keyof typeof OperationType;
10
+ message: string;
11
+ propertyBag: PropertyBag;
12
+ }
13
+ /**
14
+ * Property bag interface
15
+ * Contains key value pairs with additional data, cant be different for each message
16
+ */
17
+ interface PropertyBag extends Record<string, string> {
18
+ }
19
+ /**
20
+ * Enum for the possible operation types
21
+ */
22
+ export declare enum OperationType {
23
+ Create = "Create",
24
+ Read = "Read",
25
+ Update = "Update",
26
+ Delete = "Delete"
27
+ }
28
+ /**
29
+ * Enum for the possible message types
30
+ * currently not in use
31
+ */
32
+ export declare enum MessageType {
33
+ Notification = "Notification",
34
+ Alert = "Alert"
35
+ }
36
+ /**
37
+ * Enum for the possible entity types
38
+ * the entity type is used to determine the target of the message
39
+ * please check which kind of entity types are available in the platform and add them here
40
+ * of course you can add more entity types if needed for your module
41
+ */
42
+ export declare enum EntityType {
43
+ Block = "Block",
44
+ Field = "Field"
45
+ }
46
+ /**
47
+ * the mapping list of notification icons for the different entity types
48
+ * the icon is used to display the notification in the notification center
49
+ * please check which icons are available in the platform and add them here
50
+ * of course you can add more icons if needed for your module
51
+ */
52
+ export declare const NotificationIcons: Record<keyof typeof EntityType, string>;
53
+ export {};
@@ -0,0 +1,6 @@
1
+ import { BaseProps } from '../types/BaseProps';
2
+ type BasePropsStore = BaseProps & {
3
+ setBaseProps: (props: BaseProps) => void;
4
+ };
5
+ export declare const useBasePropsStore: import('zustand/react').UseBoundStore<import('zustand/vanilla').StoreApi<BasePropsStore>>;
6
+ export {};
@@ -0,0 +1,8 @@
1
+ import { CustomEnv, HortiViewEnvironments } from '../types/Environment';
2
+ type EnvironmentStore = {
3
+ environment: HortiViewEnvironments;
4
+ setEnvironment: (environment: HortiViewEnvironments) => void;
5
+ addEnvironment: (customEnv: CustomEnv) => void;
6
+ };
7
+ export declare const useEnvironmentStore: import('zustand/react').UseBoundStore<import('zustand/vanilla').StoreApi<EnvironmentStore>>;
8
+ export {};
@@ -0,0 +1,12 @@
1
+ export declare enum ActionState {
2
+ PENDING = "PENDING",
3
+ SUCCESS = "RESOLVED",
4
+ ERROR = "REJECTED"
5
+ }
6
+ export type ActionItem = {
7
+ functionName: string;
8
+ args: unknown[];
9
+ dateAdded: string;
10
+ state: ActionState;
11
+ key: string;
12
+ };
@@ -0,0 +1,12 @@
1
+ export type AppInsightsEvent = {
2
+ name: string;
3
+ properties?: AppInsightsProperties;
4
+ };
5
+ export type AppInsightsException = {
6
+ id?: string;
7
+ exception: Error;
8
+ properties?: AppInsightsProperties;
9
+ };
10
+ export type AppInsightsProperties = {
11
+ [key: string]: unknown;
12
+ };
@@ -0,0 +1,49 @@
1
+ import { ActionItem } from './ActionStorage';
2
+ import { AppInsightsEvent, AppInsightsException, AppInsightsProperties } from './AppInsights';
3
+ import { AllDropdownsData, CommonOption } from './CommonOptions';
4
+ import { DeprecatedBaseProps } from './Deprecated';
5
+ import { EnvironmentVariable } from './EnvironmentVariable';
6
+ import { AlertServiceBusMessage } from './ServiceBus';
7
+ import { SystemMessage } from './SystemMessage';
8
+ /**
9
+ * Properties that are passed to the Base component by the host application
10
+ * @param token authentication user token
11
+ * @param modulePermissionToken token for the module, to communicate with the module api
12
+ * @param moduleId id of the module
13
+ * @param basePath base path of the module (that is part of the URL and will be used for routing)
14
+ * @param organizationId id of the organization, where the module is used
15
+ * @param config configuration object that is used to configure the module
16
+ * @param navigateTo function to navigate to a specific route to trigger the routing in the host application
17
+ * @param addTranslation function to add a translation to the i18n instance of the host application
18
+ * @param currentNavigationPath current path of the route, that is changed, when the host application navigates
19
+ */
20
+ export type BaseProps = DeprecatedBaseProps & {
21
+ isOnline?: boolean;
22
+ modulePermissionToken?: string;
23
+ moduleId?: string;
24
+ organizationId?: string;
25
+ basePath?: string;
26
+ currentNavigationPath?: string;
27
+ sourcePath?: string | null;
28
+ currentLanguage?: string;
29
+ currentLanguageId?: string;
30
+ alertRules?: string;
31
+ commonOptions?: AllDropdownsData<CommonOption>['items'];
32
+ riseNotification?: (message: AlertServiceBusMessage) => Promise<unknown>;
33
+ navigateInHortiview?: (path: string) => void;
34
+ addBreadcrumbTranslation?: (translation: {
35
+ key: string;
36
+ value: string;
37
+ }, hide?: boolean) => void;
38
+ showSnackbar?: (message: string, icon?: string) => void;
39
+ showMessage?: (message: SystemMessage) => void;
40
+ pendingActions?: ActionItem[];
41
+ resolveAction?: (key: string, result?: string) => void;
42
+ addAction?: (functionName: string, args: unknown[], key?: string) => void;
43
+ getActions?: () => ActionItem[];
44
+ getActionByKey?: (key: string) => ActionItem | undefined;
45
+ logEvent?: (event: AppInsightsEvent, customProperties?: AppInsightsProperties) => void;
46
+ logError?: (exception: AppInsightsException) => void;
47
+ throwError?: (message: string, code: number) => void;
48
+ environmentVariables?: EnvironmentVariable[];
49
+ };
@@ -0,0 +1,61 @@
1
+ export interface CommonOption {
2
+ id: string;
3
+ value?: string;
4
+ description?: string;
5
+ key?: string;
6
+ parent?: string;
7
+ icon?: string;
8
+ }
9
+ export interface CommonOptionOdata extends DropdownData<CommonOption> {
10
+ }
11
+ export interface AllCommonOptionsOdata extends AllDropdownsData<CommonOption> {
12
+ }
13
+ export interface AllDropdownsData<T> {
14
+ count: number;
15
+ totalCount: number;
16
+ items: Partial<Record<keyof typeof CommonOptionType, T[]>>;
17
+ }
18
+ export interface DropdownData<T> {
19
+ count: number;
20
+ totalCount: number;
21
+ items: T[];
22
+ }
23
+ export declare enum CommonOptionType {
24
+ Category = 0,
25
+ Requirement = 1,
26
+ Country = 2,
27
+ CountryCode = 3,
28
+ Crop = 4,
29
+ CropType = 5,
30
+ CropVariety = 6,
31
+ Currency = 7,
32
+ DataAreaEntity = 8,
33
+ DataAreaGroup = 9,
34
+ FieldAutomationLevelType = 10,
35
+ FieldCoverageType = 11,
36
+ FieldSecurityLevelType = 12,
37
+ FieldShadingType = 13,
38
+ FieldSowingType = 14,
39
+ FieldSubstrateType = 15,
40
+ FieldTechnologyType = 16,
41
+ Gender = 17,
42
+ GrowingEnvironment = 18,
43
+ Language = 19,
44
+ ModuleHostingType = 20,
45
+ ModuleType = 21,
46
+ ModuleState = 22,
47
+ Region = 23,
48
+ Rootstock = 24,
49
+ Salutation = 25,
50
+ SeasonState = 26,
51
+ SensorName = 27,
52
+ SensorState = 28,
53
+ TermAndCondition = 29,
54
+ PackageState = 30,
55
+ DocumentType = 31,
56
+ ModuleFederationType = 32,
57
+ PaymentCycle = 33,
58
+ PaymentMethod = 34,
59
+ PlantFamily = 35,
60
+ AlertCriteriaName = 36
61
+ }
@@ -0,0 +1,99 @@
1
+ import { AlertServiceBusMessage } from './ServiceBus';
2
+ import { SystemMessage } from './SystemMessage';
3
+ /**
4
+ * @deprecated should not be used anymore, will be removed in the near future (max 2 months)
5
+ */
6
+ export type DeprecatedBaseProps = {
7
+ /**
8
+ * AlertRules, only for AlertRuleForcer to test
9
+ */
10
+ allAlertRules?: {
11
+ [moduleId: string]: string;
12
+ };
13
+ /**
14
+ * @deprecated use module-api and `modulePermissionToken` instead
15
+ */
16
+ token?: string;
17
+ /**
18
+ * @deprecated Not needed anymore
19
+ */
20
+ config?: RemoteComponentConfig;
21
+ /**
22
+ * @deprecated
23
+ */
24
+ addNotification?: (notification: OldAlertDto) => void;
25
+ /**
26
+ * @deprecated use `riseNotification` instead
27
+ */
28
+ serviceBusNotification?: (message: AlertServiceBusMessage, //currently only used for alerts
29
+ apiKey: string, queue: string, topic: string) => Promise<unknown>;
30
+ /**
31
+ * @deprecated Use `showMessage` instead
32
+ */
33
+ addMessage?: (message: SystemMessage) => void;
34
+ /**
35
+ * @deprecated Use `addBreadcrumbTranslation` instead
36
+ */
37
+ addTranslation?: (translation: {
38
+ key: string;
39
+ value: string;
40
+ }, hide?: boolean) => void;
41
+ /**
42
+ * @deprecated Use `navigateInHortiview` instead
43
+ */
44
+ navigateTo?: (path: string) => void;
45
+ };
46
+ /**
47
+ * @deprecated should not be used anymore
48
+ */
49
+ export type RemoteComponentConfig = {
50
+ isBaseModule?: boolean;
51
+ /**
52
+ * The relative path to the shared module, e.g. ./MyModule
53
+ */
54
+ module: string;
55
+ /**
56
+ * The path to the remote container entry. The url were the app is running or the path to location of the remote js file, e.g. http://localhost:3000/remoteEntry.js
57
+ */
58
+ path: string;
59
+ /**
60
+ * name of the remote app, like sprayingbook
61
+ */
62
+ scope: string;
63
+ /**
64
+ * name of the module
65
+ */
66
+ name?: string;
67
+ /**
68
+ * name of the icon
69
+ */
70
+ icon?: string;
71
+ /**
72
+ * if the module has an error
73
+ */
74
+ error?: boolean;
75
+ /**
76
+ * the short name of the module
77
+ */
78
+ shortName: string;
79
+ /**
80
+ * the id of the module - used as alias
81
+ */
82
+ id: string;
83
+ };
84
+ /**
85
+ * @deprecated should not be used anymore
86
+ */
87
+ export type OldAlertDto = {
88
+ id: string;
89
+ farmOrganizationId: string;
90
+ moduleName: string;
91
+ criteriaIcon?: string | null | JSX.Element;
92
+ criteriaName: string;
93
+ description: string | JSX.Element;
94
+ timeStamp: Date;
95
+ isRead: boolean;
96
+ isSnoozed: boolean;
97
+ title: string;
98
+ link?: string;
99
+ };