@hortiview/modulebase 0.0.1

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 (56) hide show
  1. package/README.md +8 -0
  2. package/dist/QueryClientProvider-DQv4Y3Qu.js +707 -0
  3. package/dist/_baseGet-Bh5zJ_C8.js +805 -0
  4. package/dist/_commonjsHelpers-BkfeUUK-.js +28 -0
  5. package/dist/chunk-IR6S3I6Y-BvQXS3A3.js +3908 -0
  6. package/dist/components/ModuleBase.d.ts +11 -0
  7. package/dist/components/ModuleBase.js +691 -0
  8. package/dist/constants.d.ts +25 -0
  9. package/dist/constants.js +34 -0
  10. package/dist/fetches-DUCQo_6B.js +477 -0
  11. package/dist/hooks/useBreadcrumbTranslation.d.ts +1 -0
  12. package/dist/hooks/useBreadcrumbTranslation.js +20 -0
  13. package/dist/hooks/useCustom.d.ts +6 -0
  14. package/dist/hooks/useCustom.js +19 -0
  15. package/dist/hooks/useEntity.d.ts +186 -0
  16. package/dist/hooks/useEntity.js +58 -0
  17. package/dist/hooks/useNavigate.d.ts +5 -0
  18. package/dist/hooks/useNavigate.js +27 -0
  19. package/dist/hooks/useOption.d.ts +17 -0
  20. package/dist/hooks/useOption.js +23 -0
  21. package/dist/hooks/useSignalRMessages.d.ts +6 -0
  22. package/dist/hooks/useSignalRMessages.js +13 -0
  23. package/dist/hooks/useStores.d.ts +29 -0
  24. package/dist/hooks/useStores.js +844 -0
  25. package/dist/main.d.ts +9 -0
  26. package/dist/main.js +19 -0
  27. package/dist/provider/SignalR/SignalRProvider.d.ts +13 -0
  28. package/dist/provider/SignalR/SignalRProvider.js +6408 -0
  29. package/dist/provider/SignalR/signalR.d.ts +53 -0
  30. package/dist/provider/SignalR/signalR.js +11 -0
  31. package/dist/react-QiIgv49H.js +27 -0
  32. package/dist/stores/BasePropsStore.d.ts +6 -0
  33. package/dist/stores/BasePropsStore.js +7 -0
  34. package/dist/stores/EnvironmentStore.d.ts +8 -0
  35. package/dist/stores/EnvironmentStore.js +9 -0
  36. package/dist/types/AppInsights.d.ts +12 -0
  37. package/dist/types/AppInsights.js +1 -0
  38. package/dist/types/BaseProps.d.ts +38 -0
  39. package/dist/types/BaseProps.js +1 -0
  40. package/dist/types/CommonOptions.d.ts +61 -0
  41. package/dist/types/CommonOptions.js +4 -0
  42. package/dist/types/Deprecated.d.ts +93 -0
  43. package/dist/types/Deprecated.js +1 -0
  44. package/dist/types/Environment.d.ts +17 -0
  45. package/dist/types/Environment.js +1 -0
  46. package/dist/types/ModuleApi.d.ts +80 -0
  47. package/dist/types/ModuleApi.js +1 -0
  48. package/dist/types/Requests.d.ts +49 -0
  49. package/dist/types/Requests.js +4 -0
  50. package/dist/types/SystemMessage.d.ts +14 -0
  51. package/dist/types/SystemMessage.js +1 -0
  52. package/dist/useQuery-znAyMQW1.js +397 -0
  53. package/dist/utils/fetches.d.ts +26 -0
  54. package/dist/utils/fetches.js +16 -0
  55. package/dist/vite-env.d.js +1 -0
  56. package/package.json +55 -0
@@ -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,11 @@
1
+ var r = /* @__PURE__ */ ((e) => (e.Create = "Create", e.Read = "Read", e.Update = "Update", e.Delete = "Delete", e))(r || {}), t = /* @__PURE__ */ ((e) => (e.Notification = "Notification", e.Alert = "Alert", e))(t || {}), l = /* @__PURE__ */ ((e) => (e.Block = "Block", e.Field = "Field", e))(l || {});
2
+ const a = {
3
+ Block: "border_clear",
4
+ Field: "grass"
5
+ };
6
+ export {
7
+ l as EntityType,
8
+ t as MessageType,
9
+ a as NotificationIcons,
10
+ r as OperationType
11
+ };
@@ -0,0 +1,27 @@
1
+ import a from "react";
2
+ const S = (t) => {
3
+ let e;
4
+ const n = /* @__PURE__ */ new Set(), c = (s, u) => {
5
+ const o = typeof s == "function" ? s(e) : s;
6
+ if (!Object.is(o, e)) {
7
+ const f = e;
8
+ e = u ?? (typeof o != "object" || o === null) ? o : Object.assign({}, e, o), n.forEach((g) => g(e, f));
9
+ }
10
+ }, i = () => e, r = { setState: c, getState: i, getInitialState: () => b, subscribe: (s) => (n.add(s), () => n.delete(s)) }, b = e = t(c, i, r);
11
+ return r;
12
+ }, d = (t) => t ? S(t) : S, I = (t) => t;
13
+ function j(t, e = I) {
14
+ const n = a.useSyncExternalStore(
15
+ t.subscribe,
16
+ () => e(t.getState()),
17
+ () => e(t.getInitialState())
18
+ );
19
+ return a.useDebugValue(n), n;
20
+ }
21
+ const l = (t) => {
22
+ const e = d(t), n = (c) => j(e, c);
23
+ return Object.assign(n, e), n;
24
+ }, x = (t) => t ? l(t) : l;
25
+ export {
26
+ x as c
27
+ };
@@ -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,7 @@
1
+ import { c as o } from "../react-QiIgv49H.js";
2
+ const t = o((e) => ({
3
+ setBaseProps: (s) => e({ ...s })
4
+ }));
5
+ export {
6
+ t as useBasePropsStore
7
+ };
@@ -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,9 @@
1
+ import { c as r } from "../react-QiIgv49H.js";
2
+ const i = r((e) => ({
3
+ environment: void 0,
4
+ setEnvironment: (n) => e({ environment: n }),
5
+ addEnvironment: (n) => e((o) => ({ environment: { ...n, ...o.environment } }))
6
+ }));
7
+ export {
8
+ i as useEnvironmentStore
9
+ };
@@ -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 @@
1
+
@@ -0,0 +1,38 @@
1
+ import { AppInsightsEvent, AppInsightsException, AppInsightsProperties } from './AppInsights';
2
+ import { AllDropdownsData, CommonOption } from './CommonOptions';
3
+ import { DeprecatedBaseProps } from './Deprecated';
4
+ import { SystemMessage } from './SystemMessage';
5
+ /**
6
+ * Properties that are passed to the Base component by the host application
7
+ * @param token authentication user token
8
+ * @param modulePermissionToken token for the module, to communicate with the module api
9
+ * @param moduleId id of the module
10
+ * @param basePath base path of the module (that is part of the URL and will be used for routing)
11
+ * @param organizationId id of the organization, where the module is used
12
+ * @param config configuration object that is used to configure the module
13
+ * @param navigateTo function to navigate to a specific route to trigger the routing in the host application
14
+ * @param addTranslation function to add a translation to the i18n instance of the host application
15
+ * @param currentNavigationPath current path of the route, that is changed, when the host application navigates
16
+ */
17
+ export type BaseProps = DeprecatedBaseProps & {
18
+ modulePermissionToken?: string;
19
+ moduleId?: string;
20
+ organizationId?: string;
21
+ basePath?: string;
22
+ currentNavigationPath?: string;
23
+ sourcePath?: string | null;
24
+ currentLanguage?: string;
25
+ currentLanguageId?: string;
26
+ alertRules?: string;
27
+ commonOptions?: AllDropdownsData<CommonOption>["items"];
28
+ navigateInHortiview?: (path: string) => void;
29
+ addBreadcrumbTranslation?: (translation: {
30
+ key: string;
31
+ value: string;
32
+ }) => void;
33
+ showSnackbar?: (message: string, icon?: string) => void;
34
+ showMessage?: (message: SystemMessage) => void;
35
+ logEvent?: (event: AppInsightsEvent, customProperties?: AppInsightsProperties) => void;
36
+ logError?: (exception: AppInsightsException) => void;
37
+ throwError?: (message: string, code: number) => void;
38
+ };
@@ -0,0 +1 @@
1
+
@@ -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,4 @@
1
+ var e = /* @__PURE__ */ ((a) => (a[a.Category = 0] = "Category", a[a.Requirement = 1] = "Requirement", a[a.Country = 2] = "Country", a[a.CountryCode = 3] = "CountryCode", a[a.Crop = 4] = "Crop", a[a.CropType = 5] = "CropType", a[a.CropVariety = 6] = "CropVariety", a[a.Currency = 7] = "Currency", a[a.DataAreaEntity = 8] = "DataAreaEntity", a[a.DataAreaGroup = 9] = "DataAreaGroup", a[a.FieldAutomationLevelType = 10] = "FieldAutomationLevelType", a[a.FieldCoverageType = 11] = "FieldCoverageType", a[a.FieldSecurityLevelType = 12] = "FieldSecurityLevelType", a[a.FieldShadingType = 13] = "FieldShadingType", a[a.FieldSowingType = 14] = "FieldSowingType", a[a.FieldSubstrateType = 15] = "FieldSubstrateType", a[a.FieldTechnologyType = 16] = "FieldTechnologyType", a[a.Gender = 17] = "Gender", a[a.GrowingEnvironment = 18] = "GrowingEnvironment", a[a.Language = 19] = "Language", a[a.ModuleHostingType = 20] = "ModuleHostingType", a[a.ModuleType = 21] = "ModuleType", a[a.ModuleState = 22] = "ModuleState", a[a.Region = 23] = "Region", a[a.Rootstock = 24] = "Rootstock", a[a.Salutation = 25] = "Salutation", a[a.SeasonState = 26] = "SeasonState", a[a.SensorName = 27] = "SensorName", a[a.SensorState = 28] = "SensorState", a[a.TermAndCondition = 29] = "TermAndCondition", a[a.PackageState = 30] = "PackageState", a[a.DocumentType = 31] = "DocumentType", a[a.ModuleFederationType = 32] = "ModuleFederationType", a[a.PaymentCycle = 33] = "PaymentCycle", a[a.PaymentMethod = 34] = "PaymentMethod", a[a.PlantFamily = 35] = "PlantFamily", a[a.AlertCriteriaName = 36] = "AlertCriteriaName", a))(e || {});
2
+ export {
3
+ e as CommonOptionType
4
+ };
@@ -0,0 +1,93 @@
1
+ import { SystemMessage } from './SystemMessage';
2
+ /**
3
+ * @deprecated should not be used anymore, will be removed in the near future (max 2 months)
4
+ */
5
+ export type DeprecatedBaseProps = {
6
+ /**
7
+ * AlertRules, only for AlertRuleForcer to test
8
+ */
9
+ allAlertRules?: {
10
+ [moduleId: string]: string;
11
+ };
12
+ /**
13
+ * @deprecated use module-api and `modulePermissionToken` instead
14
+ */
15
+ token?: string;
16
+ /**
17
+ * @deprecated Not needed anymore
18
+ */
19
+ config?: RemoteComponentConfig;
20
+ /**
21
+ * @deprecated
22
+ */
23
+ addNotification?: (notification: OldAlertDto) => void;
24
+ /**
25
+ * @deprecated Use `showMessage` instead
26
+ */
27
+ addMessage?: (message: SystemMessage) => void;
28
+ /**
29
+ * @deprecated Use `addBreadcrumbTranslation` instead
30
+ */
31
+ addTranslation?: (translation: {
32
+ key: string;
33
+ value: string;
34
+ }) => void;
35
+ /**
36
+ * @deprecated Use `navigateInHortiview` instead
37
+ */
38
+ navigateTo?: (path: string) => void;
39
+ };
40
+ /**
41
+ * @deprecated should not be used anymore
42
+ */
43
+ export type RemoteComponentConfig = {
44
+ isBaseModule?: boolean;
45
+ /**
46
+ * The relative path to the shared module, e.g. ./MyModule
47
+ */
48
+ module: string;
49
+ /**
50
+ * 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
51
+ */
52
+ path: string;
53
+ /**
54
+ * name of the remote app, like sprayingbook
55
+ */
56
+ scope: string;
57
+ /**
58
+ * name of the module
59
+ */
60
+ name?: string;
61
+ /**
62
+ * name of the icon
63
+ */
64
+ icon?: string;
65
+ /**
66
+ * if the module has an error
67
+ */
68
+ error?: boolean;
69
+ /**
70
+ * the short name of the module
71
+ */
72
+ shortName: string;
73
+ /**
74
+ * the id of the module - used as alias
75
+ */
76
+ id: string;
77
+ };
78
+ /**
79
+ * @deprecated should not be used anymore
80
+ */
81
+ export type OldAlertDto = {
82
+ id: string;
83
+ farmOrganizationId: string;
84
+ moduleName: string;
85
+ criteriaIcon?: string | null | JSX.Element;
86
+ criteriaName: string;
87
+ description: string | JSX.Element;
88
+ timeStamp: Date;
89
+ isRead: boolean;
90
+ isSnoozed: boolean;
91
+ title: string;
92
+ link?: string;
93
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,17 @@
1
+ export interface HortiViewEnvironments {
2
+ COMMON_API: string;
3
+ MODULE_AUTH_API: string;
4
+ API_PREFIX: string;
5
+ ENVIRONMENT: string;
6
+ [customkey: string]: string;
7
+ }
8
+ export interface CustomWindow extends Window {
9
+ __env__?: HortiViewEnvironments;
10
+ }
11
+ export type Environments = 'DEVELOPMENT' | 'TEST' | 'BAYER-TEST' | 'BAYER-DEMO' | 'BAYER-PROD';
12
+ export type EnvConfig = {
13
+ [key in Environments]: CustomEnv;
14
+ };
15
+ export type CustomEnv = {
16
+ [key: string]: string;
17
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,80 @@
1
+ export type RegisterOption = {
2
+ moduleId: string;
3
+ registeredEntityName: string;
4
+ id: string;
5
+ };
6
+ export interface ModuleEntity {
7
+ season: Season | undefined;
8
+ blockPlantLayout: BlockPlantLayout | undefined;
9
+ }
10
+ /**
11
+ * the basic interface for the module apis farm organization entities
12
+ */
13
+ export interface FarmOrgEntity {
14
+ block: Block | undefined;
15
+ farm: Farm | undefined;
16
+ field: Field | undefined;
17
+ farmOrg: {
18
+ id: string;
19
+ } | undefined;
20
+ irrigationStation: {
21
+ id: string;
22
+ } | undefined;
23
+ farmAlertRule: {
24
+ id: string;
25
+ } | undefined;
26
+ id: string;
27
+ }
28
+ export type Block = {
29
+ id: string;
30
+ fieldId: string;
31
+ blockName?: string;
32
+ shortName?: string;
33
+ area?: number;
34
+ fieldPercentage?: number;
35
+ tagID?: string;
36
+ description?: string;
37
+ length?: number;
38
+ width?: number;
39
+ rows?: number;
40
+ /** Stringyfied Position, only used in BE */
41
+ location?: string;
42
+ /**Position will be transformed from the Location string, only internally used*/
43
+ position?: {
44
+ row: number;
45
+ column: number;
46
+ };
47
+ };
48
+ /**
49
+ * farm dto (only necessary fields - for now)
50
+ */
51
+ export interface Farm {
52
+ id: string;
53
+ farmName: string;
54
+ description: string;
55
+ fields: Field[];
56
+ }
57
+ export interface Field {
58
+ id: string;
59
+ name: string;
60
+ description: string;
61
+ farmId: string;
62
+ fieldCoverageId: string;
63
+ blocks: Block[];
64
+ }
65
+ export interface Season {
66
+ id: string;
67
+ cropSeasonName: string;
68
+ startDate: Date;
69
+ plantingDate: Date | null;
70
+ cropId: string;
71
+ cropTypeId: string;
72
+ cropVarietyId: string;
73
+ rootstockId: string;
74
+ farmId: string;
75
+ fieldId: string;
76
+ seasonStateId?: string;
77
+ }
78
+ export interface BlockPlantLayout {
79
+ id: string;
80
+ }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,49 @@
1
+ import { Expand, Filter, Select } from 'odata-query';
2
+ export type RequestConfig = {
3
+ redirect: "follow";
4
+ credentials: "omit";
5
+ headers: RequestHeader;
6
+ method: "GET" | "POST" | "PATCH" | "DELETE" | "PUT";
7
+ body?: string | FormData;
8
+ };
9
+ export type RequestHeader = Headers & {
10
+ "Content-Type"?: "application/json";
11
+ orgId?: string;
12
+ Authorization?: string;
13
+ Permission?: string;
14
+ "Api-Version"?: "1.0" | "2.0";
15
+ languageId?: string;
16
+ };
17
+ export type InternalError = {
18
+ status: number;
19
+ title: string;
20
+ detail: string;
21
+ stack?: string;
22
+ };
23
+ export type Query = {
24
+ filter?: Filter<unknown>;
25
+ orderBy?: string[];
26
+ expand?: string | string[] | Expand<unknown>;
27
+ select?: Select<unknown>;
28
+ count?: boolean | Filter<unknown>;
29
+ pagination?: Pagination;
30
+ top?: number;
31
+ skip?: number;
32
+ overwrite?: string;
33
+ };
34
+ export type Pagination = {
35
+ top?: number;
36
+ skip?: number;
37
+ pageSize?: number;
38
+ };
39
+ export type BaseResponse<T> = T | T[] | {
40
+ value: T | T[];
41
+ } | {
42
+ items: T | T[];
43
+ };
44
+ /**
45
+ * a universal selector that can be used for all fetches
46
+ * @param data - the data to select from
47
+ * @returns
48
+ */
49
+ export declare const universalSelector: <T>(data: BaseResponse<T>) => T | T[];
@@ -0,0 +1,4 @@
1
+ const r = (e) => typeof e == "string" || typeof e == "boolean" || typeof e == "number" ? e : typeof e == "object" && "value" in e ? e.value : typeof e == "object" && "items" in e ? e.items : (Array.isArray(e), e);
2
+ export {
3
+ r as universalSelector
4
+ };
@@ -0,0 +1,14 @@
1
+ export type SystemMessage = {
2
+ id: string;
3
+ title: string;
4
+ description: string | JSX.Element;
5
+ timeStamp: string | Date;
6
+ isRead: boolean;
7
+ isSnoozed: boolean;
8
+ icon?: {
9
+ name: string;
10
+ danger?: boolean;
11
+ };
12
+ link?: string;
13
+ action?: () => void;
14
+ };
@@ -0,0 +1 @@
1
+