@hortiview/modulebase 0.0.1 → 0.0.17-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 (80) hide show
  1. package/README.md +8 -8
  2. package/dist/ModuleCore-YCIFN_02.js +14973 -0
  3. package/dist/QueryClientProvider-Beog9TR7.js +437 -0
  4. package/dist/{_baseGet-Bh5zJ_C8.js → _baseGet-C6jMXSsQ.js} +448 -448
  5. package/dist/api-s6E2GJtu.js +458 -0
  6. package/dist/assets/ModuleCore.css +1 -0
  7. package/dist/chunk-QMGIS6GS-C4bgXQXY.js +9203 -0
  8. package/dist/components/ModuleBase.js +20 -681
  9. package/dist/components/ModuleCore.js +10 -0
  10. package/dist/hooks/useBreadcrumbTranslation.js +16 -13
  11. package/dist/hooks/useCustom.js +15 -15
  12. package/dist/hooks/useCustomMutation.js +23 -0
  13. package/dist/hooks/useEntity.js +53 -54
  14. package/dist/hooks/useOffline.js +45 -0
  15. package/dist/hooks/useOption.js +19 -17
  16. package/dist/hooks/useServiceBus.js +25 -0
  17. package/dist/hooks/useStores.js +11 -841
  18. package/dist/isRestoring-CLuxJVSA.js +281 -0
  19. package/dist/lib/components/ModuleBase.d.ts +36 -0
  20. package/dist/lib/components/ModuleCore.d.ts +32 -0
  21. package/dist/{constants.d.ts → lib/constants.d.ts} +1 -1
  22. package/dist/{hooks → lib/hooks}/useBreadcrumbTranslation.d.ts +1 -1
  23. package/dist/lib/hooks/useCustom.d.ts +8 -0
  24. package/dist/lib/hooks/useCustomMutation.d.ts +9 -0
  25. package/dist/{hooks → lib/hooks}/useEntity.d.ts +6 -30
  26. package/dist/lib/hooks/useOffline.d.ts +15 -0
  27. package/dist/{hooks → lib/hooks}/useOption.d.ts +1 -1
  28. package/dist/lib/hooks/useServiceBus.d.ts +19 -0
  29. package/dist/lib/hooks/useStores.d.ts +38 -0
  30. package/dist/lib/main.d.ts +27 -0
  31. package/dist/lib/module-router.d.ts +7 -0
  32. package/dist/{stores → lib/stores}/EnvironmentStore.d.ts +1 -1
  33. package/dist/lib/types/ActionStorage.d.ts +16 -0
  34. package/dist/{types → lib/types}/BaseProps.d.ts +14 -2
  35. package/dist/{types → lib/types}/Deprecated.d.ts +7 -1
  36. package/dist/lib/types/Entities.d.ts +22 -0
  37. package/dist/{types → lib/types}/Environment.d.ts +3 -2
  38. package/dist/lib/types/EnvironmentVariable.d.ts +6 -0
  39. package/dist/lib/types/ModuleApi.d.ts +163 -0
  40. package/dist/{types → lib/types}/Requests.d.ts +6 -11
  41. package/dist/lib/types/ServiceBus.d.ts +17 -0
  42. package/dist/{utils/fetches.d.ts → lib/utils/api.d.ts} +2 -8
  43. package/dist/lib/utils/baseFetches.d.ts +19 -0
  44. package/dist/lib/utils/fetches.d.ts +43 -0
  45. package/dist/lib/utils/helper.d.ts +29 -0
  46. package/dist/main.js +224 -17
  47. package/dist/module-router.js +137 -0
  48. package/dist/mutation-DSKlaYzY.js +192 -0
  49. package/dist/omit-C9Qe80rl.js +835 -0
  50. package/dist/stores/EnvironmentStore.js +9 -3
  51. package/dist/types/ActionStorage.js +4 -0
  52. package/dist/types/Entities.js +25 -0
  53. package/dist/types/EnvironmentVariable.js +1 -0
  54. package/dist/types/Requests.js +1 -4
  55. package/dist/types/ServiceBus.js +1 -0
  56. package/dist/useMutation-zu8uxBak.js +97 -0
  57. package/dist/{useQuery-znAyMQW1.js → useQuery-Bj9k9zik.js} +106 -108
  58. package/dist/utils/api.js +9 -0
  59. package/dist/utils/baseFetches.js +19 -0
  60. package/dist/utils/fetches.js +20 -14
  61. package/dist/utils/helper.js +55 -0
  62. package/dist/utils-DxRR_XLb.js +9 -0
  63. package/package.json +8 -3
  64. package/dist/QueryClientProvider-DQv4Y3Qu.js +0 -707
  65. package/dist/chunk-IR6S3I6Y-BvQXS3A3.js +0 -3908
  66. package/dist/components/ModuleBase.d.ts +0 -11
  67. package/dist/fetches-DUCQo_6B.js +0 -477
  68. package/dist/hooks/useCustom.d.ts +0 -6
  69. package/dist/hooks/useNavigate.d.ts +0 -5
  70. package/dist/hooks/useNavigate.js +0 -27
  71. package/dist/hooks/useStores.d.ts +0 -29
  72. package/dist/main.d.ts +0 -9
  73. package/dist/types/ModuleApi.d.ts +0 -80
  74. /package/dist/{hooks → lib/hooks}/useSignalRMessages.d.ts +0 -0
  75. /package/dist/{provider → lib/provider}/SignalR/SignalRProvider.d.ts +0 -0
  76. /package/dist/{provider → lib/provider}/SignalR/signalR.d.ts +0 -0
  77. /package/dist/{stores → lib/stores}/BasePropsStore.d.ts +0 -0
  78. /package/dist/{types → lib/types}/AppInsights.d.ts +0 -0
  79. /package/dist/{types → lib/types}/CommonOptions.d.ts +0 -0
  80. /package/dist/{types → lib/types}/SystemMessage.d.ts +0 -0
@@ -1,20 +1,23 @@
1
- import { useCallback as s } from "react";
2
- import { useBasePropsStore as o } from "../stores/BasePropsStore.js";
3
- const c = () => {
4
- const a = o(
5
- (r) => r.addBreadcrumbTranslation
6
- ), t = o((r) => r.addTranslation);
7
- return s(
8
- (r, n) => {
9
- if (a) {
10
- a({ key: r, value: n });
1
+ import { useCallback as d } from "react";
2
+ import { useBasePropsStore as s } from "../stores/BasePropsStore.js";
3
+ const u = () => {
4
+ const o = s((a) => a.addBreadcrumbTranslation), t = s((a) => a.addTranslation);
5
+ return d(
6
+ (a, r) => {
7
+ const e = a, n = typeof r == "boolean" ? a : r;
8
+ if (o) {
9
+ o(
10
+ { key: e, value: n },
11
+ //if boolean hide the translation in the breadcrumb
12
+ typeof r == "boolean"
13
+ );
11
14
  return;
12
15
  }
13
- t && t({ key: r, value: n });
16
+ t && t({ key: e, value: n }, typeof r == "boolean");
14
17
  },
15
- [a, t]
18
+ [o, t]
16
19
  );
17
20
  };
18
21
  export {
19
- c as useBreadcrumbTranslation
22
+ u as useBreadcrumbTranslation
20
23
  };
@@ -1,19 +1,19 @@
1
- import { u as m } from "../useQuery-znAyMQW1.js";
2
- import { useBasePropsStore as u } from "../stores/BasePropsStore.js";
3
- import { universalSelector as i } from "../types/Requests.js";
4
- import { d as n } from "../fetches-DUCQo_6B.js";
1
+ import { u as f } from "../useQuery-Bj9k9zik.js";
2
+ import { fetchFromCustomApi as i } from "../utils/fetches.js";
3
+ import { universalSelector as n } from "../utils/helper.js";
5
4
  const y = ({
6
- endpoint: r,
7
- queryKey: e,
8
- token: t
9
- }) => {
10
- const s = u((o) => o.organizationId);
11
- return m({
12
- queryKey: [...e, s],
13
- queryFn: () => n(r, t),
14
- select: (o) => i(o)
15
- });
16
- };
5
+ endpoint: o,
6
+ queryKey: t,
7
+ token: u,
8
+ selector: r,
9
+ enabled: m = !0,
10
+ noAuth: s = !1
11
+ }) => f({
12
+ queryKey: t,
13
+ queryFn: () => i(o, u, s),
14
+ select: (e) => r ? r(e) : n(e),
15
+ enabled: m
16
+ });
17
17
  export {
18
18
  y as useCustom
19
19
  };
@@ -0,0 +1,23 @@
1
+ import { u as n } from "../useMutation-zu8uxBak.js";
2
+ import "react/jsx-runtime";
3
+ import "react";
4
+ import "../provider/SignalR/SignalRProvider.js";
5
+ import "../stores/BasePropsStore.js";
6
+ import "../ModuleCore-YCIFN_02.js";
7
+ import { mutateOnCustomApi as s } from "../utils/fetches.js";
8
+ import "../api-s6E2GJtu.js";
9
+ import "../types/Entities.js";
10
+ import "../omit-C9Qe80rl.js";
11
+ import "../stores/EnvironmentStore.js";
12
+ const d = ({
13
+ endpoint: t,
14
+ method: o,
15
+ token: m,
16
+ headers: r,
17
+ noAuth: i
18
+ }) => n({
19
+ mutationFn: (p, u) => s(u ?? t, p, o, m, r, i)
20
+ });
21
+ export {
22
+ d as useCustomMutation
23
+ };
@@ -1,58 +1,57 @@
1
- import { u as f } from "../useQuery-znAyMQW1.js";
2
- import { useMemo as g } from "react";
3
- import { useBasePropsStore as l } from "../stores/BasePropsStore.js";
4
- import { universalSelector as p } from "../types/Requests.js";
5
- import { g as b, a as R } from "../fetches-DUCQo_6B.js";
6
- import { useOption as y, useModuleDependency as k } from "./useOption.js";
7
- const F = {
8
- farms: "farm",
9
- fields: "field",
10
- zones: "block",
11
- irrigation_stations: "irrigationStation",
12
- farm_organizations: "farmOrg",
13
- alert_rules: "farmAlertRule"
14
- }, Q = {
15
- farm_members: "member"
16
- }, q = {
17
- Season: "season",
18
- BlockPlantLayout: "blockPlantLayout"
19
- }, A = {
20
- ...F,
21
- ...Q,
22
- ...q
23
- }, B = (t, e) => {
24
- const a = l((r) => r.moduleId), o = l((r) => r.organizationId), { data: i } = y("DataAreaGroup"), { data: u } = y("DataAreaEntity"), { data: n } = k(), d = t === "ModuleDepended", E = g(() => {
25
- if (d)
26
- return n ? n.find((s) => s.registeredEntityName === e)?.id : void 0;
27
- if (!i || !u) return;
28
- const r = i.find((s) => s.key === t)?.id;
29
- return r ? u.find((s) => s.description === r && s.value === e)?.id : void 0;
30
- }, [d, i, u, n, e, t]), c = D(a, E, o, d), M = (c.data ?? []).map((r) => {
31
- const m = A[e];
32
- return r[m];
1
+ import { u as l } from "../useQuery-Bj9k9zik.js";
2
+ import { useMemo as M, useCallback as g } from "react";
3
+ import { useBasePropsStore as p } from "../stores/BasePropsStore.js";
4
+ import { getModuleDependedEntitiesRaw as Q, getModuleDependedEntities as A, getFarmOrgEntities as D } from "../utils/fetches.js";
5
+ import { getModuleQueryKey as m, universalSelector as y } from "../utils/helper.js";
6
+ import { useOption as E, useModuleDependency as q } from "./useOption.js";
7
+ import { AllEntitiesTypeResultMap as k } from "../types/Entities.js";
8
+ const N = (t, e, u = !0, n = !1) => {
9
+ const a = p((i) => i.moduleId), o = p((i) => i.organizationId), s = t === "ModuleDepended", { getEntityId: d } = K(t), r = F(
10
+ a,
11
+ d(e),
12
+ o,
13
+ s,
14
+ n,
15
+ u
16
+ );
17
+ return M(() => {
18
+ const i = (r.data ?? []).map((c) => {
19
+ const f = k[e];
20
+ return s && n ? c : c[f];
21
+ });
22
+ return {
23
+ ...r,
24
+ data: i
25
+ };
26
+ }, [e, r, s, n]);
27
+ }, F = (t, e, u, n, a, o = !0) => {
28
+ const s = l({
29
+ queryKey: m([e]),
30
+ queryFn: () => a ? Q(t ?? "", e ?? "") : A(t ?? "", e ?? ""),
31
+ enabled: o && n && !!t && !!e && !!u,
32
+ select: (r) => y(r)
33
+ }), d = l({
34
+ queryKey: m([e]),
35
+ queryFn: () => D(t ?? "", e ?? ""),
36
+ enabled: o && !n && !!t && !!e && !!u,
37
+ select: (r) => y(r)
33
38
  });
34
- return {
35
- ...c,
36
- data: M
37
- };
38
- }, D = (t, e, a, o) => {
39
- const i = f({
40
- queryKey: [t, a, e],
41
- queryFn: () => b(t ?? "", e ?? ""),
42
- enabled: o && !!t && !!e && !!a,
43
- select: (n) => p(n)
44
- }), u = f({
45
- queryKey: [t, a, e],
46
- queryFn: () => R(t ?? "", e ?? ""),
47
- enabled: !o && !!t && !!e && !!a,
48
- select: (n) => p(n)
49
- });
50
- return o ? i : u;
39
+ return n ? s : d;
40
+ }, K = (t) => {
41
+ const { data: e } = E("DataAreaGroup"), { data: u } = E("DataAreaEntity"), { data: n } = q(t === "ModuleDepended");
42
+ return { getEntityId: g(
43
+ (o) => {
44
+ if (t === "ModuleDepended")
45
+ return n ? n.find((r) => r.registeredEntityName === o)?.id : void 0;
46
+ if (!e || !u) return;
47
+ const d = e.find((r) => r.key === t)?.id;
48
+ if (d)
49
+ return u.find((r) => r.description === d && r.value === o)?.id;
50
+ },
51
+ [t, e, u, n]
52
+ ) };
51
53
  };
52
54
  export {
53
- A as AllEntitiesTypeResultMap,
54
- Q as FarmMemberEntitiesTypeResultMap,
55
- F as FarmOrgEntitiesTypeResultMap,
56
- q as ModuleDependedEntityTypeResultMap,
57
- B as useEntity
55
+ N as useEntity,
56
+ K as useEntityId
58
57
  };
@@ -0,0 +1,45 @@
1
+ import { u as f } from "../QueryClientProvider-Beog9TR7.js";
2
+ import { fetchFromCustomApi as i, getFarmOrgEntities as c, getModuleDependedEntities as m } from "../utils/fetches.js";
3
+ import { getModuleQueryKey as o } from "../utils/helper.js";
4
+ import { useBasePropsStore as p } from "../stores/BasePropsStore.js";
5
+ import { useEntityId as d } from "./useEntity.js";
6
+ const I = () => {
7
+ const { moduleId: n } = p(), u = f();
8
+ return {
9
+ prefetchCustom: async ({
10
+ queryKey: e,
11
+ endpoint: t,
12
+ token: s,
13
+ noAuth: y = !1
14
+ }) => {
15
+ await u.prefetchQuery({
16
+ queryKey: o(e),
17
+ queryFn: () => i(t, s, y)
18
+ });
19
+ },
20
+ prefetch: ({
21
+ queryKey: e,
22
+ queryFn: t
23
+ }) => u.prefetchQuery({
24
+ queryKey: o(e),
25
+ queryFn: t
26
+ }),
27
+ usePrefetchEntity: (e, ...t) => {
28
+ const { getEntityId: s } = d(e);
29
+ if (!n) return "Prefetch failed: no moduleId";
30
+ t.forEach(async (y) => {
31
+ const r = s(y);
32
+ r && (e !== "ModuleDepended" ? await u.prefetchQuery({
33
+ queryKey: o([r]),
34
+ queryFn: () => c(n, r)
35
+ }) : await u.prefetchQuery({
36
+ queryKey: o([r]),
37
+ queryFn: () => m(n, r)
38
+ }));
39
+ });
40
+ }
41
+ };
42
+ };
43
+ export {
44
+ I as useOffline
45
+ };
@@ -1,23 +1,25 @@
1
- import { u as s } from "../useQuery-znAyMQW1.js";
2
- import { b as u, f as c, c as i } from "../fetches-DUCQo_6B.js";
3
- import { useBasePropsStore as t } from "../stores/BasePropsStore.js";
4
- import { universalSelector as m } from "../types/Requests.js";
5
- const y = (o) => {
6
- const r = t((n) => n.commonOptions), e = u(r, o);
7
- return s({
1
+ import { u as m } from "../useQuery-Bj9k9zik.js";
2
+ import { g as u } from "../api-s6E2GJtu.js";
3
+ import { useBasePropsStore as n } from "../stores/BasePropsStore.js";
4
+ import { fetchFromModuleApi as c, fetchFromCommonApi as i } from "../utils/fetches.js";
5
+ import { getModuleQueryKey as p, universalSelector as s } from "../utils/helper.js";
6
+ const q = (o) => {
7
+ const r = n((t) => t.commonOptions), e = u(r, o);
8
+ return m({
8
9
  queryKey: [o],
9
- queryFn: () => e ? Promise.resolve(e) : c(`${o}/dropdown`),
10
- select: (n) => m(n)
10
+ queryFn: () => e ? Promise.resolve(e) : i(`${o}/dropdown`),
11
+ select: (t) => s(t)
11
12
  });
12
- }, f = () => {
13
- const o = t((e) => e.moduleId), r = t((e) => e.organizationId);
14
- return s({
15
- queryKey: [o, r],
16
- queryFn: () => i(`ModuleDependencies/${o}`),
17
- select: (e) => m(e)
13
+ }, F = (o = !0) => {
14
+ const r = n((e) => e.moduleId);
15
+ return m({
16
+ queryKey: p([]),
17
+ queryFn: () => c(`ModuleDependencies/${r}`),
18
+ select: (e) => s(e),
19
+ enabled: o
18
20
  });
19
21
  };
20
22
  export {
21
- f as useModuleDependency,
22
- y as useOption
23
+ F as useModuleDependency,
24
+ q as useOption
23
25
  };
@@ -0,0 +1,25 @@
1
+ import { u as n } from "../useMutation-zu8uxBak.js";
2
+ import { useBasePropsStore as r } from "../stores/BasePropsStore.js";
3
+ const a = ({
4
+ authenticationKey: i,
5
+ queue: s,
6
+ topic: o
7
+ }) => {
8
+ const e = r((t) => t.serviceBusNotification), c = r((t) => t.throwError);
9
+ if (!e)
10
+ throw c?.("serviceBusNotification is not defined", 400);
11
+ return n({
12
+ mutationFn: (t) => e(t, i, s, o)
13
+ });
14
+ }, N = () => {
15
+ const i = r((o) => o.riseNotification), s = r((o) => o.throwError);
16
+ if (!i)
17
+ throw s?.("riseNotification is not defined", 400);
18
+ return n({
19
+ mutationFn: (o) => i(o)
20
+ });
21
+ };
22
+ export {
23
+ N as useNotification,
24
+ a as useServiceBus
25
+ };