@hortiview/modulebase 0.0.16348 → 0.0.20524

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 (65) hide show
  1. package/README.md +3 -2
  2. package/dist/IsRestoringProvider-CBSZo7ur.js +312 -0
  3. package/dist/ModuleCore-DuJVrj6v.js +11828 -0
  4. package/dist/QueryClientProvider-DyiNrPkn.js +514 -0
  5. package/dist/_commonjsHelpers-ByX85dGu.js +33 -0
  6. package/dist/api-COabZnyn.js +147 -0
  7. package/dist/assets/ModuleCore.css +1 -1
  8. package/dist/chunk-LFPYN7LY-D1ls8FXf.js +8643 -0
  9. package/dist/components/ModuleBase.js +9 -9
  10. package/dist/components/ModuleCore.js +9 -14698
  11. package/dist/constants.js +2 -3
  12. package/dist/enum/ActionStorage.js +4 -0
  13. package/dist/hooks/useCustom.js +15 -18
  14. package/dist/hooks/useCustomMutation.js +12 -11
  15. package/dist/hooks/useEntity.js +48 -60
  16. package/dist/hooks/useOffline.js +57 -0
  17. package/dist/hooks/useOption.js +19 -19
  18. package/dist/hooks/useServiceBus.js +1 -1
  19. package/dist/hooks/useStores.js +1 -1
  20. package/dist/{_baseGet-B7FwMMGI.js → isTypedArray-SkhznY1k.js} +496 -496
  21. package/dist/lib/constants.d.ts +0 -1
  22. package/dist/lib/enum/ActionStorage.d.ts +7 -0
  23. package/dist/lib/hooks/useCustom.d.ts +6 -3
  24. package/dist/lib/hooks/useCustomMutation.d.ts +9 -3
  25. package/dist/lib/hooks/useEntity.d.ts +15 -23
  26. package/dist/lib/hooks/useOffline.d.ts +15 -0
  27. package/dist/lib/hooks/useStores.d.ts +10 -2
  28. package/dist/lib/main.d.ts +4 -0
  29. package/dist/lib/types/ActionStorage.d.ts +8 -0
  30. package/dist/lib/types/BaseProps.d.ts +10 -1
  31. package/dist/lib/types/Deprecated.d.ts +4 -0
  32. package/dist/lib/types/Entities.d.ts +22 -0
  33. package/dist/lib/types/Requests.d.ts +0 -17
  34. package/dist/lib/utils/IndexedDbService.d.ts +33 -0
  35. package/dist/lib/utils/api.d.ts +7 -14
  36. package/dist/lib/utils/baseFetches.d.ts +4 -3
  37. package/dist/lib/utils/fetches.d.ts +2 -2
  38. package/dist/lib/utils/helper.d.ts +1 -0
  39. package/dist/main.js +233 -144
  40. package/dist/module-router.js +2322 -121
  41. package/dist/{mutation-CnKIetRs.js → mutation-CmhiEgfA.js} +101 -56
  42. package/dist/{omit-B7MWDtHq.js → omit-Do6MFRwA.js} +240 -223
  43. package/dist/provider/SignalR/SignalRProvider.js +2389 -2824
  44. package/dist/react-c9FSfB30.js +27 -0
  45. package/dist/stores/BasePropsStore.js +1 -1
  46. package/dist/stores/EnvironmentStore.js +1 -1
  47. package/dist/types/ActionStorage.js +1 -0
  48. package/dist/types/Entities.js +25 -0
  49. package/dist/useMutation-Aoachkw_.js +139 -0
  50. package/dist/useQuery-DEU_AUtf.js +392 -0
  51. package/dist/utils/IndexedDbService.js +43 -0
  52. package/dist/utils/api.js +3 -4
  53. package/dist/utils/baseFetches.js +18 -14
  54. package/dist/utils/fetches.js +12 -13
  55. package/dist/utils/helper.js +30 -25
  56. package/package.json +19 -12
  57. package/dist/QueryClientProvider-VtJdNkDw.js +0 -435
  58. package/dist/_commonjsHelpers-BkfeUUK-.js +0 -28
  59. package/dist/api-D9Lmqe6S.js +0 -458
  60. package/dist/chunk-IR6S3I6Y-BmDdD3SP.js +0 -8162
  61. package/dist/query-CFoO2uy7.js +0 -277
  62. package/dist/react-QiIgv49H.js +0 -27
  63. package/dist/useMutation-Num57Ulc.js +0 -97
  64. package/dist/useQuery-XBGd5Kep.js +0 -395
  65. package/dist/utils-DxRR_XLb.js +0 -9
package/dist/constants.js CHANGED
@@ -5,7 +5,7 @@ const a = [
5
5
  "organizationId",
6
6
  "currentLanguageId",
7
7
  "currentNavigationPath"
8
- ], e = 1, t = {
8
+ ], e = {
9
9
  /**
10
10
  * The server timed out waiting for the request.
11
11
  */
@@ -29,6 +29,5 @@ const a = [
29
29
  };
30
30
  export {
31
31
  a as REQUIRED_PROPS,
32
- e as RETRIES,
33
- t as RETRY_HTTP_STATUS_CODES
32
+ e as RETRY_HTTP_STATUS_CODES
34
33
  };
@@ -0,0 +1,4 @@
1
+ var N = /* @__PURE__ */ ((E) => (E.ENQUEUED = "ENQUEUED", E.PENDING = "PENDING", E.RESOLVING = "RESOLVING", E.SUCCESS = "RESOLVED", E.ERROR = "REJECTED", E))(N || {});
2
+ export {
3
+ N as ActionState
4
+ };
@@ -1,22 +1,19 @@
1
- import { u as i } from "../useQuery-XBGd5Kep.js";
2
- import { useBasePropsStore as n } from "../stores/BasePropsStore.js";
3
- import { fetchFromCustomApi as p } from "../utils/fetches.js";
4
- import { universalSelector as a } from "../utils/helper.js";
5
- const l = ({
6
- endpoint: e,
1
+ import { u as f } from "../useQuery-DEU_AUtf.js";
2
+ import { fetchFromCustomApi as i } from "../utils/fetches.js";
3
+ import { universalSelector as n } from "../utils/helper.js";
4
+ const y = ({
5
+ endpoint: o,
7
6
  queryKey: t,
8
7
  token: u,
9
- selector: o,
10
- enabled: m = !0
11
- }) => {
12
- const s = n((r) => r.organizationId);
13
- return i({
14
- queryKey: [...t, s],
15
- queryFn: () => p(e, u),
16
- select: (r) => o ? o(r) : a(r),
17
- enabled: m
18
- });
19
- };
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
+ });
20
17
  export {
21
- l as useCustom
18
+ y as useCustom
22
19
  };
@@ -1,22 +1,23 @@
1
- import { u } from "../useMutation-Num57Ulc.js";
1
+ import { u as n } from "../useMutation-Aoachkw_.js";
2
2
  import "react/jsx-runtime";
3
3
  import "react";
4
4
  import "../provider/SignalR/SignalRProvider.js";
5
5
  import "../stores/BasePropsStore.js";
6
- import "../components/ModuleCore.js";
7
- import "../omit-B7MWDtHq.js";
6
+ import "../ModuleCore-DuJVrj6v.js";
7
+ import { mutateOnCustomApi as s } from "../utils/fetches.js";
8
+ import "../types/Entities.js";
9
+ import "../api-COabZnyn.js";
10
+ import "../omit-Do6MFRwA.js";
8
11
  import "../stores/EnvironmentStore.js";
9
- import { mutateOnCustomApi as n } from "../utils/fetches.js";
10
- import "./useEntity.js";
11
- import "../api-D9Lmqe6S.js";
12
- const b = ({
12
+ const d = ({
13
13
  endpoint: t,
14
14
  method: o,
15
15
  token: m,
16
- headers: r
17
- }) => u({
18
- mutationFn: (i, p) => n(p ?? t, i, o, m, r)
16
+ headers: r,
17
+ noAuth: i
18
+ }) => n({
19
+ mutationFn: ({ input: p, replaceEndpointWith: u }) => s(u ?? t, p, o, m, r, i)
19
20
  });
20
21
  export {
21
- b as useCustomMutation
22
+ d as useCustomMutation
22
23
  };
@@ -1,70 +1,58 @@
1
- import { u as p } from "../useQuery-XBGd5Kep.js";
2
- import { useMemo as y } from "react";
3
- import { useBasePropsStore as E } from "../stores/BasePropsStore.js";
4
- import { getModuleDependedEntitiesRaw as A, getModuleDependedEntities as R, getFarmOrgEntities as k } from "../utils/fetches.js";
5
- import { universalSelector as M } from "../utils/helper.js";
6
- import { useOption as g, useModuleDependency as F } from "./useOption.js";
7
- const Q = {
8
- farms: "farm",
9
- fields: "field",
10
- zones: "block",
11
- irrigation_stations: "irrigationStation",
12
- farm_organizations: "farmOrg",
13
- alert_rules: "farmAlertRule"
14
- }, S = {
15
- farm_members: "member"
16
- }, q = {
17
- Season: "season",
18
- BlockPlantLayout: "blockPlantLayout",
19
- Record: "recordLight",
20
- Scouting: "scouting"
21
- }, O = {
22
- ...Q,
23
- ...S,
24
- ...q
25
- }, x = (r, e, u = !0, s = !1) => {
26
- const l = E((n) => n.moduleId), d = E((n) => n.organizationId), { data: a } = g("DataAreaGroup"), { data: i } = g("DataAreaEntity"), { data: o } = F(r === "ModuleDepended"), c = r === "ModuleDepended", b = y(() => {
27
- if (c)
28
- return o ? o.find((t) => t.registeredEntityName === e)?.id : void 0;
29
- if (!a || !i) return;
30
- const n = a.find((t) => t.key === r)?.id;
31
- return n ? i.find((t) => t.description === n && t.value === e)?.id : void 0;
32
- }, [c, a, i, o, e, r]), m = T(
33
- l,
34
- b,
35
- d,
36
- c,
1
+ import { u as p } from "../useQuery-DEU_AUtf.js";
2
+ import { useMemo as g, useCallback as Q } from "react";
3
+ import { useBasePropsStore as m } from "../stores/BasePropsStore.js";
4
+ import { AllEntitiesTypeResultMap as v } from "../types/Entities.js";
5
+ import { getModuleDependedEntitiesRaw as A, getModuleDependedEntities as D, getFarmOrgEntities as q } from "../utils/fetches.js";
6
+ import { getModuleQueryKey as y, universalSelector as E } from "../utils/helper.js";
7
+ import { useOption as M, useModuleDependency as k } from "./useOption.js";
8
+ const P = (t, e, o = !0, n = !1) => {
9
+ const a = m((d) => d.moduleId), u = m((d) => d.organizationId), s = t === "ModuleDepended", r = K(t)(e), c = F(
10
+ a,
11
+ r,
12
+ u,
37
13
  s,
38
- u
14
+ n,
15
+ o
39
16
  );
40
- return y(() => {
41
- const n = (m.data ?? []).map((f) => {
42
- const t = O[e];
43
- return c && s ? f : f[t];
17
+ return g(() => {
18
+ const d = (c.data ?? []).map((l) => {
19
+ if (s && n) return l;
20
+ const f = v[e];
21
+ return l[f];
44
22
  });
45
23
  return {
46
- ...m,
47
- data: n
24
+ ...c,
25
+ data: d
48
26
  };
49
- }, [e, m, c, s]);
50
- }, T = (r, e, u, s, l, d = !0) => {
51
- const a = p({
52
- queryKey: [r, u, e],
53
- queryFn: () => l ? A(r ?? "", e ?? "") : R(r ?? "", e ?? ""),
54
- enabled: d && s && !!r && !!e && !!u,
55
- select: (o) => M(o)
27
+ }, [e, c, s, n]);
28
+ }, F = (t, e, o, n, a, u = !0) => {
29
+ const s = p({
30
+ queryKey: y([e]),
31
+ queryFn: () => a ? A(t ?? "", e ?? "") : D(t ?? "", e ?? ""),
32
+ enabled: u && n && !!t && !!e && !!o,
33
+ select: (r) => E(r)
56
34
  }), i = p({
57
- queryKey: [r, u, e],
58
- queryFn: () => k(r ?? "", e ?? ""),
59
- enabled: d && !s && !!r && !!e && !!u,
60
- select: (o) => M(o)
35
+ queryKey: y([e]),
36
+ queryFn: () => q(t ?? "", e ?? ""),
37
+ enabled: u && !n && !!t && !!e && !!o,
38
+ select: (r) => E(r)
61
39
  });
62
- return s ? a : i;
40
+ return n ? s : i;
41
+ }, K = (t) => {
42
+ const { data: e } = M("DataAreaGroup"), { data: o } = M("DataAreaEntity"), { data: n } = k(t === "ModuleDepended");
43
+ return Q(
44
+ (u) => {
45
+ if (t === "ModuleDepended")
46
+ return n ? n.find((r) => r.registeredEntityName === u)?.id : void 0;
47
+ if (!e || !o) return;
48
+ const i = e.find((r) => r.key === t)?.id;
49
+ if (i)
50
+ return o.find((r) => r.description === i && r.value === u)?.id;
51
+ },
52
+ [t, e, o, n]
53
+ );
63
54
  };
64
55
  export {
65
- O as AllEntitiesTypeResultMap,
66
- S as FarmMemberEntitiesTypeResultMap,
67
- Q as FarmOrgEntitiesTypeResultMap,
68
- q as ModuleDependedEntityTypeResultMap,
69
- x as useEntity
56
+ P as useEntity,
57
+ K as useEntityId
70
58
  };
@@ -0,0 +1,57 @@
1
+ import { u as y } from "../QueryClientProvider-DyiNrPkn.js";
2
+ import { useBasePropsStore as i } from "../stores/BasePropsStore.js";
3
+ import { fetchFromCustomApi as f, getFarmOrgEntities as m, getModuleDependedEntities as d } from "../utils/fetches.js";
4
+ import { getModuleQueryKey as o } from "../utils/helper.js";
5
+ import { useEntityId as p } from "./useEntity.js";
6
+ const I = () => {
7
+ const e = a(), t = h();
8
+ return {
9
+ prefetchCustom: e,
10
+ prefetch: t,
11
+ usePrefetchEntity: l
12
+ };
13
+ }, a = () => {
14
+ const e = y();
15
+ return async ({
16
+ queryKey: t,
17
+ endpoint: r,
18
+ token: u,
19
+ noAuth: s = !1
20
+ }) => {
21
+ await e.prefetchQuery({
22
+ queryKey: o(t),
23
+ queryFn: () => f(r, u, s)
24
+ });
25
+ };
26
+ }, h = () => {
27
+ const e = y();
28
+ return ({
29
+ queryKey: t,
30
+ queryFn: r
31
+ }) => e.prefetchQuery({
32
+ queryKey: o(t),
33
+ queryFn: r
34
+ });
35
+ }, l = (e, ...t) => {
36
+ const { moduleId: r } = i(), u = y(), s = p(e);
37
+ if (!r) return "Prefetch failed: no moduleId";
38
+ t.forEach(async (c) => {
39
+ const n = s(c);
40
+ if (n) {
41
+ if (e !== "ModuleDepended") {
42
+ await u.prefetchQuery({
43
+ queryKey: o([n]),
44
+ queryFn: () => m(r, n)
45
+ });
46
+ return;
47
+ }
48
+ await u.prefetchQuery({
49
+ queryKey: o([n]),
50
+ queryFn: () => d(r, n)
51
+ });
52
+ }
53
+ });
54
+ };
55
+ export {
56
+ I as useOffline
57
+ };
@@ -1,25 +1,25 @@
1
- import { u as s } from "../useQuery-XBGd5Kep.js";
2
- import { g as c } from "../api-D9Lmqe6S.js";
3
- import { useBasePropsStore as t } from "../stores/BasePropsStore.js";
1
+ import { u as m } from "../useQuery-DEU_AUtf.js";
2
+ import { g as c } from "../api-COabZnyn.js";
3
+ import { useBasePropsStore as n } from "../stores/BasePropsStore.js";
4
4
  import { fetchFromCommonApi as i, fetchFromModuleApi as p } from "../utils/fetches.js";
5
- import { universalSelector as u } from "../utils/helper.js";
6
- const f = (o) => {
7
- const n = t((r) => r.commonOptions), m = t((r) => r.currentLanguageId), e = c(n, o);
8
- return s({
9
- queryKey: [o, m],
10
- queryFn: () => e ? Promise.resolve(e) : i(`${o}/dropdown`),
11
- select: (r) => u(r)
5
+ import { getModuleQueryKey as l, universalSelector as s } from "../utils/helper.js";
6
+ const q = (e) => {
7
+ const t = n((r) => r.commonOptions), o = n((r) => r.currentLanguageId), u = c(t, e);
8
+ return m({
9
+ queryKey: [e, o],
10
+ queryFn: () => u ? Promise.resolve(u) : i(`${e}/dropdown`),
11
+ select: (r) => s(r)
12
12
  });
13
- }, I = (o = !0) => {
14
- const n = t((e) => e.moduleId), m = t((e) => e.organizationId);
15
- return s({
16
- queryKey: [n, m],
17
- queryFn: () => p(`ModuleDependencies/${n}`),
18
- select: (e) => u(e),
19
- enabled: o
13
+ }, F = (e = !0) => {
14
+ const t = n((o) => o.moduleId);
15
+ return m({
16
+ queryKey: l([]),
17
+ queryFn: () => p(`ModuleDependencies/${t}`),
18
+ select: (o) => s(o),
19
+ enabled: e
20
20
  });
21
21
  };
22
22
  export {
23
- I as useModuleDependency,
24
- f as useOption
23
+ F as useModuleDependency,
24
+ q as useOption
25
25
  };
@@ -1,4 +1,4 @@
1
- import { u as n } from "../useMutation-Num57Ulc.js";
1
+ import { u as n } from "../useMutation-Aoachkw_.js";
2
2
  import { useBasePropsStore as r } from "../stores/BasePropsStore.js";
3
3
  const a = ({
4
4
  authenticationKey: i,
@@ -1,4 +1,4 @@
1
- import { o as r } from "../omit-B7MWDtHq.js";
1
+ import { o as r } from "../omit-Do6MFRwA.js";
2
2
  import { useBasePropsStore as e } from "../stores/BasePropsStore.js";
3
3
  import { useEnvironmentStore as t } from "../stores/EnvironmentStore.js";
4
4
  const i = () => {