@hortiview/modulebase 0.0.13075 → 0.0.13101-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 (68) hide show
  1. package/dist/ModuleCore-BWvRhZyP.js +14980 -0
  2. package/dist/{QueryClientProvider-Q_mWQTzQ.js → QueryClientProvider-BSM1ol7r.js} +81 -78
  3. package/dist/{_baseGet-B7FwMMGI.js → _baseGet-C6jMXSsQ.js} +447 -447
  4. package/dist/{api-D9Lmqe6S.js → api-s6E2GJtu.js} +48 -48
  5. package/dist/assets/ModuleCore.css +1 -0
  6. package/dist/components/ModuleBase.js +17 -498
  7. package/dist/components/ModuleCore.js +10 -0
  8. package/dist/hooks/useCustom.js +15 -18
  9. package/dist/hooks/useCustomMutation.js +14 -12
  10. package/dist/hooks/useEntity.js +48 -58
  11. package/dist/hooks/useOffline.js +45 -0
  12. package/dist/hooks/useOption.js +16 -16
  13. package/dist/hooks/useServiceBus.js +19 -11
  14. package/dist/hooks/useStores.js +1 -1
  15. package/dist/{query-CRIVoEP7.js → isRestoring-LSIsLTaI.js} +21 -17
  16. package/dist/lib/components/ModuleBase.d.ts +36 -0
  17. package/dist/lib/components/ModuleCore.d.ts +32 -0
  18. package/dist/{constants.d.ts → lib/constants.d.ts} +1 -1
  19. package/dist/{hooks → lib/hooks}/useCustom.d.ts +2 -1
  20. package/dist/{hooks → lib/hooks}/useCustomMutation.d.ts +2 -1
  21. package/dist/{hooks → lib/hooks}/useEntity.d.ts +6 -24
  22. package/dist/lib/hooks/useOffline.d.ts +15 -0
  23. package/dist/{hooks → lib/hooks}/useServiceBus.d.ts +6 -2
  24. package/dist/lib/hooks/useStores.d.ts +38 -0
  25. package/dist/lib/main.d.ts +27 -0
  26. package/dist/lib/types/ActionStorage.d.ts +13 -0
  27. package/dist/{types → lib/types}/BaseProps.d.ts +11 -2
  28. package/dist/{types → lib/types}/Deprecated.d.ts +6 -0
  29. package/dist/lib/types/Entities.d.ts +22 -0
  30. package/dist/{types → lib/types}/Environment.d.ts +1 -1
  31. package/dist/lib/types/EnvironmentVariable.d.ts +6 -0
  32. package/dist/{types → lib/types}/Requests.d.ts +4 -10
  33. package/dist/{utils → lib/utils}/api.d.ts +1 -1
  34. package/dist/{utils → lib/utils}/baseFetches.d.ts +2 -2
  35. package/dist/{utils → lib/utils}/fetches.d.ts +14 -6
  36. package/dist/lib/utils/helper.d.ts +29 -0
  37. package/dist/main.js +212 -133
  38. package/dist/{mutation-X73nm7Df.js → mutation-EhVtpjb0.js} +1 -1
  39. package/dist/{omit-B7MWDtHq.js → omit-C9Qe80rl.js} +1 -1
  40. package/dist/stores/EnvironmentStore.js +3 -2
  41. package/dist/types/ActionStorage.js +4 -0
  42. package/dist/types/Entities.js +25 -0
  43. package/dist/types/Environment.js +1 -4
  44. package/dist/types/EnvironmentVariable.js +1 -0
  45. package/dist/types/Requests.js +1 -4
  46. package/dist/{useMutation-3rykrmeD.js → useMutation-BYO7aks8.js} +16 -16
  47. package/dist/{useQuery-CwwWze9O.js → useQuery-Jx956wwH.js} +94 -94
  48. package/dist/utils/api.js +1 -1
  49. package/dist/utils/baseFetches.js +15 -15
  50. package/dist/utils/fetches.js +14 -13
  51. package/dist/utils/helper.js +55 -0
  52. package/package.json +7 -2
  53. package/dist/components/ModuleBase.d.ts +0 -11
  54. package/dist/hooks/useStores.d.ts +0 -30
  55. package/dist/main.d.ts +0 -13
  56. /package/dist/{hooks → lib/hooks}/useBreadcrumbTranslation.d.ts +0 -0
  57. /package/dist/{hooks → lib/hooks}/useOption.d.ts +0 -0
  58. /package/dist/{hooks → lib/hooks}/useSignalRMessages.d.ts +0 -0
  59. /package/dist/{module-router.d.ts → lib/module-router.d.ts} +0 -0
  60. /package/dist/{provider → lib/provider}/SignalR/SignalRProvider.d.ts +0 -0
  61. /package/dist/{provider → lib/provider}/SignalR/signalR.d.ts +0 -0
  62. /package/dist/{stores → lib/stores}/BasePropsStore.d.ts +0 -0
  63. /package/dist/{stores → lib/stores}/EnvironmentStore.d.ts +0 -0
  64. /package/dist/{types → lib/types}/AppInsights.d.ts +0 -0
  65. /package/dist/{types → lib/types}/CommonOptions.d.ts +0 -0
  66. /package/dist/{types → lib/types}/ModuleApi.d.ts +0 -0
  67. /package/dist/{types → lib/types}/ServiceBus.d.ts +0 -0
  68. /package/dist/{types → lib/types}/SystemMessage.d.ts +0 -0
@@ -0,0 +1,25 @@
1
+ const e = {
2
+ farms: "farm",
3
+ fields: "field",
4
+ zones: "block",
5
+ irrigation_stations: "irrigationStation",
6
+ farm_organizations: "farmOrg",
7
+ alert_rules: "farmAlertRule"
8
+ }, t = {
9
+ farm_members: "member"
10
+ }, a = {
11
+ Season: "season",
12
+ BlockPlantLayout: "blockPlantLayout",
13
+ Record: "recordLight",
14
+ Scouting: "scouting"
15
+ }, r = {
16
+ ...e,
17
+ ...t,
18
+ ...a
19
+ };
20
+ export {
21
+ r as AllEntitiesTypeResultMap,
22
+ t as FarmMemberEntitiesTypeResultMap,
23
+ e as FarmOrgEntitiesTypeResultMap,
24
+ a as ModuleDependedEntityTypeResultMap
25
+ };
@@ -1,4 +1 @@
1
- const e = (c) => c;
2
- export {
3
- e as checkConfig
4
- };
1
+
@@ -0,0 +1 @@
1
+
@@ -1,4 +1 @@
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
- };
1
+
@@ -1,6 +1,6 @@
1
- import * as n from "react";
2
- import { g as l } from "./mutation-X73nm7Df.js";
3
- import { S as d, f as p, h, n as a, u as b } from "./QueryClientProvider-Q_mWQTzQ.js";
1
+ import * as o from "react";
2
+ import { g as l } from "./mutation-EhVtpjb0.js";
3
+ import { S as d, s as p, h, n as a, u as b } from "./QueryClientProvider-BSM1ol7r.js";
4
4
  import { n as m, s as f } from "./utils-DxRR_XLb.js";
5
5
  var v = class extends d {
6
6
  #e;
@@ -25,13 +25,13 @@ var v = class extends d {
25
25
  this.hasListeners() || this.#t?.removeObserver(this);
26
26
  }
27
27
  onMutationUpdate(t) {
28
- this.#r(), this.#n(t);
28
+ this.#r(), this.#o(t);
29
29
  }
30
30
  getCurrentResult() {
31
31
  return this.#i;
32
32
  }
33
33
  reset() {
34
- this.#t?.removeObserver(this), this.#t = void 0, this.#r(), this.#n();
34
+ this.#t?.removeObserver(this), this.#t = void 0, this.#r(), this.#o();
35
35
  }
36
36
  mutate(t, s) {
37
37
  return this.#s = s, this.#t?.removeObserver(this), this.#t = this.#e.getMutationCache().build(this.#e, this.options), this.#t.addObserver(this), this.#t.execute(t);
@@ -48,7 +48,7 @@ var v = class extends d {
48
48
  reset: this.reset
49
49
  };
50
50
  }
51
- #n(t) {
51
+ #o(t) {
52
52
  a.batch(() => {
53
53
  if (this.#s && this.hasListeners()) {
54
54
  const s = this.#i.variables, i = this.#i.context;
@@ -65,26 +65,26 @@ var v = class extends d {
65
65
  });
66
66
  }
67
67
  };
68
- function C(t, s) {
69
- const i = b(), [e] = n.useState(
68
+ function M(t, s) {
69
+ const i = b(s), [e] = o.useState(
70
70
  () => new v(
71
71
  i,
72
72
  t
73
73
  )
74
74
  );
75
- n.useEffect(() => {
75
+ o.useEffect(() => {
76
76
  e.setOptions(t);
77
77
  }, [e, t]);
78
- const r = n.useSyncExternalStore(
79
- n.useCallback(
80
- (o) => e.subscribe(a.batchCalls(o)),
78
+ const r = o.useSyncExternalStore(
79
+ o.useCallback(
80
+ (n) => e.subscribe(a.batchCalls(n)),
81
81
  [e]
82
82
  ),
83
83
  () => e.getCurrentResult(),
84
84
  () => e.getCurrentResult()
85
- ), u = n.useCallback(
86
- (o, c) => {
87
- e.mutate(o, c).catch(m);
85
+ ), u = o.useCallback(
86
+ (n, c) => {
87
+ e.mutate(n, c).catch(m);
88
88
  },
89
89
  [e]
90
90
  );
@@ -93,5 +93,5 @@ function C(t, s) {
93
93
  return { ...r, mutate: u, mutateAsync: r.mutate };
94
94
  }
95
95
  export {
96
- C as u
96
+ M as u
97
97
  };
@@ -1,9 +1,9 @@
1
- import { S as N, x as U, b as f, f as w, q as O, a as H, y as Q, z as M, t as V, o as z, r as k, n as A, u as W } from "./QueryClientProvider-Q_mWQTzQ.js";
2
- import { f as $ } from "./query-CRIVoEP7.js";
3
- import * as p from "react";
1
+ import { S as B, p as U, b as f, s as w, g as O, a as H, j as Q, k, t as N, l as V, r as M, n as A, u as z } from "./QueryClientProvider-BSM1ol7r.js";
2
+ import { f as W, u as $ } from "./isRestoring-LSIsLTaI.js";
3
+ import * as y from "react";
4
4
  import "react/jsx-runtime";
5
5
  import { s as K, n as _ } from "./utils-DxRR_XLb.js";
6
- var G = class extends N {
6
+ var G = class extends B {
7
7
  constructor(e, t) {
8
8
  super(), this.options = t, this.#s = e, this.#r = null, this.#i = U(), this.options.experimental_prefetchInRender || this.#i.reject(
9
9
  new Error("experimental_prefetchInRender feature flag is not enabled")
@@ -30,7 +30,7 @@ var G = class extends N {
30
30
  this.refetch = this.refetch.bind(this);
31
31
  }
32
32
  onSubscribe() {
33
- this.listeners.size === 1 && (this.#e.addObserver(this), q(this.#e, this.options) ? this.#u() : this.updateResult(), this.#R());
33
+ this.listeners.size === 1 && (this.#e.addObserver(this), j(this.#e, this.options) ? this.#u() : this.updateResult(), this.#R());
34
34
  }
35
35
  onUnsubscribe() {
36
36
  this.hasListeners() || this.destroy();
@@ -52,26 +52,26 @@ var G = class extends N {
52
52
  destroy() {
53
53
  this.listeners = /* @__PURE__ */ new Set(), this.#v(), this.#O(), this.#e.removeObserver(this);
54
54
  }
55
- setOptions(e, t) {
56
- const s = this.options, r = this.#e;
55
+ setOptions(e) {
56
+ const t = this.options, s = this.#e;
57
57
  if (this.options = this.#s.defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof f(this.options.enabled, this.#e) != "boolean")
58
58
  throw new Error(
59
59
  "Expected enabled to be a boolean or a callback that returns a boolean"
60
60
  );
61
- this.#C(), this.#e.setOptions(this.options), s._defaulted && !w(this.options, s) && this.#s.getQueryCache().notify({
61
+ this.#C(), this.#e.setOptions(this.options), t._defaulted && !w(this.options, t) && this.#s.getQueryCache().notify({
62
62
  type: "observerOptionsUpdated",
63
63
  query: this.#e,
64
64
  observer: this
65
65
  });
66
- const a = this.hasListeners();
67
- a && L(
66
+ const r = this.hasListeners();
67
+ r && L(
68
68
  this.#e,
69
- r,
69
+ s,
70
70
  this.options,
71
- s
72
- ) && this.#u(), this.updateResult(t), a && (this.#e !== r || f(this.options.enabled, this.#e) !== f(s.enabled, this.#e) || O(this.options.staleTime, this.#e) !== O(s.staleTime, this.#e)) && this.#b();
73
- const u = this.#m();
74
- a && (this.#e !== r || f(this.options.enabled, this.#e) !== f(s.enabled, this.#e) || u !== this.#n) && this.#g(u);
71
+ t
72
+ ) && this.#u(), this.updateResult(), r && (this.#e !== s || f(this.options.enabled, this.#e) !== f(t.enabled, this.#e) || O(this.options.staleTime, this.#e) !== O(t.staleTime, this.#e)) && this.#b();
73
+ const a = this.#m();
74
+ r && (this.#e !== s || f(this.options.enabled, this.#e) !== f(t.enabled, this.#e) || a !== this.#n) && this.#g(a);
75
75
  }
76
76
  getOptimisticResult(e) {
77
77
  const t = this.#s.getQueryCache().build(this.#s, e), s = this.createResult(t, e);
@@ -125,9 +125,9 @@ var G = class extends N {
125
125
  this.options.staleTime,
126
126
  this.#e
127
127
  );
128
- if (Q || this.#t.isStale || !M(e))
128
+ if (Q || this.#t.isStale || !k(e))
129
129
  return;
130
- const s = V(this.#t.dataUpdatedAt, e) + 1;
130
+ const s = N(this.#t.dataUpdatedAt, e) + 1;
131
131
  this.#o = setTimeout(() => {
132
132
  this.#t.isStale || this.updateResult();
133
133
  }, s);
@@ -136,8 +136,8 @@ var G = class extends N {
136
136
  return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#e) : this.options.refetchInterval) ?? !1;
137
137
  }
138
138
  #g(e) {
139
- this.#O(), this.#n = e, !(Q || f(this.options.enabled, this.#e) === !1 || !M(this.#n) || this.#n === 0) && (this.#h = setInterval(() => {
140
- (this.options.refetchIntervalInBackground || z.isFocused()) && this.#u();
139
+ this.#O(), this.#n = e, !(Q || f(this.options.enabled, this.#e) === !1 || !k(this.#n) || this.#n === 0) && (this.#h = setInterval(() => {
140
+ (this.options.refetchIntervalInBackground || V.isFocused()) && this.#u();
141
141
  }, this.#n));
142
142
  }
143
143
  #R() {
@@ -150,28 +150,28 @@ var G = class extends N {
150
150
  this.#h && (clearInterval(this.#h), this.#h = void 0);
151
151
  }
152
152
  createResult(e, t) {
153
- const s = this.#e, r = this.options, a = this.#t, u = this.#a, i = this.#c, o = e !== s ? e.state : this.#p, { state: c } = e;
154
- let n = { ...c }, R = !1, l;
153
+ const s = this.#e, r = this.options, a = this.#t, c = this.#a, i = this.#c, o = e !== s ? e.state : this.#p, { state: l } = e;
154
+ let n = { ...l }, R = !1, u;
155
155
  if (t._optimisticResults) {
156
- const h = this.hasListeners(), b = !h && q(e, t), m = h && L(e, s, t, r);
157
- (b || m) && (n = {
156
+ const h = this.hasListeners(), m = !h && j(e, t), g = h && L(e, s, t, r);
157
+ (m || g) && (n = {
158
158
  ...n,
159
- ...$(c.data, e.options)
159
+ ...W(l.data, e.options)
160
160
  }), t._optimisticResults === "isRestoring" && (n.fetchStatus = "idle");
161
161
  }
162
- let { error: x, errorUpdatedAt: F, status: y } = n;
162
+ let { error: F, errorUpdatedAt: x, status: p } = n;
163
163
  if (t.select && n.data !== void 0)
164
- if (a && n.data === u?.data && t.select === this.#y)
165
- l = this.#l;
164
+ if (a && n.data === c?.data && t.select === this.#y)
165
+ u = this.#l;
166
166
  else
167
167
  try {
168
- this.#y = t.select, l = t.select(n.data), l = k(a?.data, l, t), this.#l = l, this.#r = null;
168
+ this.#y = t.select, u = t.select(n.data), u = M(a?.data, u, t), this.#l = u, this.#r = null;
169
169
  } catch (h) {
170
170
  this.#r = h;
171
171
  }
172
172
  else
173
- l = n.data;
174
- if (t.placeholderData !== void 0 && l === void 0 && y === "pending") {
173
+ u = n.data;
174
+ if (t.placeholderData !== void 0 && u === void 0 && p === "pending") {
175
175
  let h;
176
176
  if (a?.isPlaceholderData && t.placeholderData === i?.placeholderData)
177
177
  h = a.data;
@@ -181,28 +181,28 @@ var G = class extends N {
181
181
  ) : t.placeholderData, t.select && h !== void 0)
182
182
  try {
183
183
  h = t.select(h), this.#r = null;
184
- } catch (b) {
185
- this.#r = b;
184
+ } catch (m) {
185
+ this.#r = m;
186
186
  }
187
- h !== void 0 && (y = "success", l = k(
187
+ h !== void 0 && (p = "success", u = M(
188
188
  a?.data,
189
189
  h,
190
190
  t
191
191
  ), R = !0);
192
192
  }
193
- this.#r && (x = this.#r, l = this.#l, F = Date.now(), y = "error");
194
- const C = n.fetchStatus === "fetching", S = y === "pending", E = y === "error", D = S && C, P = l !== void 0, d = {
195
- status: y,
193
+ this.#r && (F = this.#r, u = this.#l, x = Date.now(), p = "error");
194
+ const C = n.fetchStatus === "fetching", S = p === "pending", E = p === "error", D = S && C, P = u !== void 0, d = {
195
+ status: p,
196
196
  fetchStatus: n.fetchStatus,
197
197
  isPending: S,
198
- isSuccess: y === "success",
198
+ isSuccess: p === "success",
199
199
  isError: E,
200
200
  isInitialLoading: D,
201
201
  isLoading: D,
202
- data: l,
202
+ data: u,
203
203
  dataUpdatedAt: n.dataUpdatedAt,
204
- error: x,
205
- errorUpdatedAt: F,
204
+ error: F,
205
+ errorUpdatedAt: x,
206
206
  failureCount: n.fetchFailureCount,
207
207
  failureReason: n.fetchFailureReason,
208
208
  errorUpdateCount: n.errorUpdateCount,
@@ -221,44 +221,44 @@ var G = class extends N {
221
221
  if (this.options.experimental_prefetchInRender) {
222
222
  const h = (v) => {
223
223
  d.status === "error" ? v.reject(d.error) : d.data !== void 0 && v.resolve(d.data);
224
- }, b = () => {
224
+ }, m = () => {
225
225
  const v = this.#i = d.promise = U();
226
226
  h(v);
227
- }, m = this.#i;
228
- switch (m.status) {
227
+ }, g = this.#i;
228
+ switch (g.status) {
229
229
  case "pending":
230
- e.queryHash === s.queryHash && h(m);
230
+ e.queryHash === s.queryHash && h(g);
231
231
  break;
232
232
  case "fulfilled":
233
- (d.status === "error" || d.data !== m.value) && b();
233
+ (d.status === "error" || d.data !== g.value) && m();
234
234
  break;
235
235
  case "rejected":
236
- (d.status !== "error" || d.error !== m.reason) && b();
236
+ (d.status !== "error" || d.error !== g.reason) && m();
237
237
  break;
238
238
  }
239
239
  }
240
240
  return d;
241
241
  }
242
- updateResult(e) {
243
- const t = this.#t, s = this.createResult(this.#e, this.options);
244
- if (this.#a = this.#e.state, this.#c = this.options, this.#a.data !== void 0 && (this.#d = this.#e), w(s, t))
242
+ updateResult() {
243
+ const e = this.#t, t = this.createResult(this.#e, this.options);
244
+ if (this.#a = this.#e.state, this.#c = this.options, this.#a.data !== void 0 && (this.#d = this.#e), w(t, e))
245
245
  return;
246
- this.#t = s;
247
- const r = {}, a = () => {
248
- if (!t)
246
+ this.#t = t;
247
+ const s = () => {
248
+ if (!e)
249
249
  return !0;
250
- const { notifyOnChangeProps: u } = this.options, i = typeof u == "function" ? u() : u;
251
- if (i === "all" || !i && !this.#f.size)
250
+ const { notifyOnChangeProps: r } = this.options, a = typeof r == "function" ? r() : r;
251
+ if (a === "all" || !a && !this.#f.size)
252
252
  return !0;
253
- const g = new Set(
254
- i ?? this.#f
253
+ const c = new Set(
254
+ a ?? this.#f
255
255
  );
256
- return this.options.throwOnError && g.add("error"), Object.keys(this.#t).some((o) => {
257
- const c = o;
258
- return this.#t[c] !== t[c] && g.has(c);
256
+ return this.options.throwOnError && c.add("error"), Object.keys(this.#t).some((i) => {
257
+ const b = i;
258
+ return this.#t[b] !== e[b] && c.has(b);
259
259
  });
260
260
  };
261
- e?.listeners !== !1 && a() && (r.listeners = !0), this.#S({ ...r, ...e });
261
+ this.#S({ listeners: s() });
262
262
  }
263
263
  #C() {
264
264
  const e = this.#s.getQueryCache().build(this.#s, this.options);
@@ -284,7 +284,7 @@ var G = class extends N {
284
284
  function J(e, t) {
285
285
  return f(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
286
286
  }
287
- function q(e, t) {
287
+ function j(e, t) {
288
288
  return J(e, t) || e.state.data !== void 0 && T(e, t, t.refetchOnMount);
289
289
  }
290
290
  function T(e, t, s) {
@@ -303,9 +303,7 @@ function I(e, t) {
303
303
  function X(e, t) {
304
304
  return !w(e.getCurrentResult(), t);
305
305
  }
306
- var B = p.createContext(!1), Y = () => p.useContext(B);
307
- B.Provider;
308
- function Z() {
306
+ function Y() {
309
307
  let e = !1;
310
308
  return {
311
309
  clearReset: () => {
@@ -317,79 +315,81 @@ function Z() {
317
315
  isReset: () => e
318
316
  };
319
317
  }
320
- var ee = p.createContext(Z()), te = () => p.useContext(ee), se = (e, t) => {
318
+ var Z = y.createContext(Y()), ee = () => y.useContext(Z), te = (e, t) => {
321
319
  (e.suspense || e.throwOnError || e.experimental_prefetchInRender) && (t.isReset() || (e.retryOnMount = !1));
322
- }, re = (e) => {
323
- p.useEffect(() => {
320
+ }, se = (e) => {
321
+ y.useEffect(() => {
324
322
  e.clearReset();
325
323
  }, [e]);
326
- }, ie = ({
324
+ }, re = ({
327
325
  result: e,
328
326
  errorResetBoundary: t,
329
327
  throwOnError: s,
330
328
  query: r,
331
329
  suspense: a
332
- }) => e.isError && !t.isReset() && !e.isFetching && r && (a && e.data === void 0 || K(s, [e.error, r])), ne = (e) => {
330
+ }) => e.isError && !t.isReset() && !e.isFetching && r && (a && e.data === void 0 || K(s, [e.error, r])), ie = (e) => {
333
331
  const t = e.staleTime;
334
332
  e.suspense && (e.staleTime = typeof t == "function" ? (...s) => Math.max(t(...s), 1e3) : Math.max(t ?? 1e3, 1e3), typeof e.gcTime == "number" && (e.gcTime = Math.max(e.gcTime, 1e3)));
335
- }, ae = (e, t) => e.isLoading && e.isFetching && !t, oe = (e, t) => e?.suspense && t.isPending, j = (e, t, s) => t.fetchOptimistic(e).catch(() => {
333
+ }, ne = (e, t) => e.isLoading && e.isFetching && !t, ae = (e, t) => e?.suspense && t.isPending, q = (e, t, s) => t.fetchOptimistic(e).catch(() => {
336
334
  s.clearReset();
337
335
  });
338
- function he(e, t, s) {
336
+ function oe(e, t, s) {
339
337
  if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e)))
340
338
  throw new Error(
341
339
  'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
342
340
  );
343
- const r = W(), a = Y(), u = te(), i = r.defaultQueryOptions(e);
341
+ const r = z(s), a = $(), c = ee(), i = r.defaultQueryOptions(e);
344
342
  r.getDefaultOptions().queries?._experimental_beforeQuery?.(
345
343
  i
346
344
  ), process.env.NODE_ENV !== "production" && (i.queryFn || console.error(
347
345
  `[${i.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
348
- )), i._optimisticResults = a ? "isRestoring" : "optimistic", ne(i), se(i, u), re(u);
349
- const g = !r.getQueryCache().get(i.queryHash), [o] = p.useState(
346
+ )), i._optimisticResults = a ? "isRestoring" : "optimistic", ie(i), te(i, c), se(c);
347
+ const b = !r.getQueryCache().get(i.queryHash), [o] = y.useState(
350
348
  () => new t(
351
349
  r,
352
350
  i
353
351
  )
354
- ), c = o.getOptimisticResult(i), n = !a && e.subscribed !== !1;
355
- if (p.useSyncExternalStore(
356
- p.useCallback(
352
+ ), l = o.getOptimisticResult(i), n = !a && e.subscribed !== !1;
353
+ if (y.useSyncExternalStore(
354
+ y.useCallback(
357
355
  (R) => {
358
- const l = n ? o.subscribe(A.batchCalls(R)) : _;
359
- return o.updateResult(), l;
356
+ const u = n ? o.subscribe(A.batchCalls(R)) : _;
357
+ return o.updateResult(), u;
360
358
  },
361
359
  [o, n]
362
360
  ),
363
361
  () => o.getCurrentResult(),
364
362
  () => o.getCurrentResult()
365
- ), p.useEffect(() => {
366
- o.setOptions(i, { listeners: !1 });
367
- }, [i, o]), oe(i, c))
368
- throw j(i, o, u);
369
- if (ie({
370
- result: c,
371
- errorResetBoundary: u,
363
+ ), y.useEffect(() => {
364
+ o.setOptions(i);
365
+ }, [i, o]), ae(i, l))
366
+ throw q(i, o, c);
367
+ if (re({
368
+ result: l,
369
+ errorResetBoundary: c,
372
370
  throwOnError: i.throwOnError,
373
371
  query: r.getQueryCache().get(i.queryHash),
374
372
  suspense: i.suspense
375
373
  }))
376
- throw c.error;
374
+ throw l.error;
377
375
  return r.getDefaultOptions().queries?._experimental_afterQuery?.(
378
376
  i,
379
- c
380
- ), i.experimental_prefetchInRender && !Q && ae(c, a) && (g ? (
377
+ l
378
+ ), i.experimental_prefetchInRender && !Q && ne(l, a) && (b ? (
381
379
  // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
382
- j(i, o, u)
380
+ q(i, o, c)
383
381
  ) : (
384
382
  // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
385
383
  r.getQueryCache().get(i.queryHash)?.promise
386
384
  ))?.catch(_).finally(() => {
387
385
  o.updateResult();
388
- }), i.notifyOnChangeProps ? c : o.trackResult(c);
386
+ }), i.notifyOnChangeProps ? l : o.trackResult(l);
389
387
  }
390
- function pe(e, t) {
391
- return he(e, G);
388
+ function fe(e, t) {
389
+ return oe(e, G, t);
392
390
  }
393
391
  export {
394
- pe as u
392
+ G as Q,
393
+ oe as a,
394
+ fe as u
395
395
  };
package/dist/utils/api.js CHANGED
@@ -1,4 +1,4 @@
1
- import { f as t, b as s, a as f, h as i } from "../api-D9Lmqe6S.js";
1
+ import { f as t, b as s, a as f, h as i } from "../api-s6E2GJtu.js";
2
2
  import "../constants.js";
3
3
  import "../stores/BasePropsStore.js";
4
4
  export {
@@ -1,19 +1,19 @@
1
- import { a as d, f, i as m, b as S } from "../api-D9Lmqe6S.js";
1
+ import { a as u, f as m, i as S, b as I } from "../api-s6E2GJtu.js";
2
2
  import { useBasePropsStore as t } from "../stores/BasePropsStore.js";
3
- const k = (n, o, a, e, s) => {
4
- const r = e ?? t.getState().modulePermissionToken, g = t.getState().organizationId, i = t.getState().currentLanguageId, c = t.getState().throwError;
5
- if (!r)
6
- return c?.("No token found", 404), Promise.reject();
7
- const u = d(r, g, i, a, s);
8
- return u.body = JSON.stringify(o), f(n, u);
9
- }, E = (n, o, a) => {
10
- const e = a ?? t.getState().modulePermissionToken, s = t.getState().organizationId, r = t.getState().currentLanguageId, g = t.getState().throwError;
11
- if (!e)
12
- return g?.("No token found", 404), Promise.reject();
13
- const i = d(e, s, r), c = m(o) ? "" : S(o);
14
- return f(`${n}${c}`, i);
3
+ const E = (s, e, g, o, r, n = !1) => {
4
+ const a = n ? void 0 : o ?? t.getState().modulePermissionToken, i = t.getState().organizationId, c = t.getState().currentLanguageId, d = t.getState().throwError;
5
+ if (!n && !a)
6
+ return d?.("No token found", 404), Promise.reject();
7
+ const f = u(a, i, c, g, r);
8
+ return f.body = JSON.stringify(e), m(s, f);
9
+ }, h = (s, e, g, o = !1) => {
10
+ const r = o ? void 0 : g ?? t.getState().modulePermissionToken, n = t.getState().organizationId, a = t.getState().currentLanguageId, i = t.getState().throwError;
11
+ if (!o && !r)
12
+ return i?.("No token found", 404), Promise.reject();
13
+ const c = u(r, n, a), d = S(e) ? "" : I(e);
14
+ return m(`${s}${d}`, c);
15
15
  };
16
16
  export {
17
- E as baseFetch,
18
- k as baseMutation
17
+ h as baseFetch,
18
+ E as baseMutation
19
19
  };
@@ -1,21 +1,22 @@
1
- import { useBasePropsStore as u } from "../stores/BasePropsStore.js";
2
- import { useEnvironmentStore as r } from "../stores/EnvironmentStore.js";
3
- import { baseMutation as c, baseFetch as o } from "./baseFetches.js";
4
- const d = (e, t, n = "POST", m, s) => c(e, t, n, m, s), I = (e, t) => i(`FarmOrgEntities/${e}/byId/${t}`), g = (e, t) => i(`ModuleDependentEntities/${e}/byId/${t}`), A = (e, t) => o(`${e}`, {}, t), i = (e) => {
5
- const t = r.getState().environment, n = u.getState().organizationId;
1
+ import { useBasePropsStore as a } from "../stores/BasePropsStore.js";
2
+ import { useEnvironmentStore as i } from "../stores/EnvironmentStore.js";
3
+ import { baseMutation as d, baseFetch as o } from "./baseFetches.js";
4
+ const I = (e, t, n = "POST", s, m, u = !1) => d(e, t, n, s, m, u), g = (e, t) => r(`FarmOrgEntities/${e}/byId/${t}`), E = (e, t) => r(`ModuleDependentEntities/${e}/byId/${t}`), A = (e, t) => r(`ModuleDependentEntitiesRaw/${e}/byId/${t}`), M = (e, t, n = !1) => o(`${e}`, {}, t, n), r = (e) => {
5
+ const t = i.getState().environment, n = a.getState().organizationId;
6
6
  return o(
7
7
  `${t?.MODULE_AUTH_API}${t?.API_PREFIX}/${n}/${e}`,
8
8
  {}
9
9
  );
10
- }, E = (e) => {
11
- const t = r.getState().environment;
10
+ }, f = (e) => {
11
+ const t = i.getState().environment;
12
12
  return o(`${t?.COMMON_API}${t?.API_PREFIX}/${e}`, {});
13
13
  };
14
14
  export {
15
- E as fetchFromCommonApi,
16
- A as fetchFromCustomApi,
17
- i as fetchFromModuleApi,
18
- I as getFarmOrgEntities,
19
- g as getModuleDependedEntities,
20
- d as mutateOnCustomApi
15
+ f as fetchFromCommonApi,
16
+ M as fetchFromCustomApi,
17
+ r as fetchFromModuleApi,
18
+ g as getFarmOrgEntities,
19
+ E as getModuleDependedEntities,
20
+ A as getModuleDependedEntitiesRaw,
21
+ I as mutateOnCustomApi
21
22
  };
@@ -0,0 +1,55 @@
1
+ import { REQUIRED_PROPS as m } from "../constants.js";
2
+ import { useBasePropsStore as u } from "../stores/BasePropsStore.js";
3
+ const g = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, c = (r) => {
4
+ if (typeof r != "string")
5
+ throw new TypeError("Invalid argument expected string");
6
+ const e = r.match(g);
7
+ if (!e)
8
+ throw new Error(`Invalid argument not valid semver ('${r}' received)`);
9
+ return e.shift(), e;
10
+ }, f = (r) => r === "*" || r === "x" || r === "X", l = (r) => {
11
+ const e = parseInt(r, 10);
12
+ return isNaN(e) ? r : e;
13
+ }, h = (r, e) => typeof r != typeof e ? [String(r), String(e)] : [r, e], E = (r, e) => {
14
+ if (f(r) || f(e))
15
+ return 0;
16
+ const [t, n] = h(l(r), l(e));
17
+ return t > n ? 1 : t < n ? -1 : 0;
18
+ }, p = (r, e) => {
19
+ for (let t = 0; t < Math.max(r.length, e.length); t++) {
20
+ const n = E(r[t] || "0", e[t] || "0");
21
+ if (n !== 0)
22
+ return n;
23
+ }
24
+ return 0;
25
+ }, a = (r, e) => {
26
+ const t = c(r), n = c(e), o = t.pop(), i = n.pop(), s = p(t, n);
27
+ return s !== 0 ? s : o && i ? p(o.split("."), i.split(".")) : o || i ? o ? -1 : 1 : 0;
28
+ }, d = "0.0.13100-beta", w = (r) => m.every((e) => y(e, r)), y = (r, e) => {
29
+ if (!e[r]) {
30
+ if (e.throwError)
31
+ return e.throwError(`Missing required prop: ${r}`, 404), !1;
32
+ throw new Error(`Missing required prop: ${r}`);
33
+ }
34
+ return !0;
35
+ }, P = () => {
36
+ const r = window.__env__;
37
+ if (r && r.COMMON_API && r.MODULE_AUTH_API && r.API_PREFIX && r.ENVIRONMENT)
38
+ return r;
39
+ }, S = (r) => {
40
+ if (!r?.REQ_VERSION) return null;
41
+ const e = r.REQ_VERSION;
42
+ return a(d, e) < 0 ? `ModuleBase version ${d} is probably not compatible with the current HortiView version ${e}. Please update the modulebase to be at least ${e}` : null;
43
+ }, _ = (r) => typeof r == "string" || typeof r == "boolean" || typeof r == "number" ? r : typeof r == "object" && "value" in r ? r.value : typeof r == "object" && "items" in r ? r.items : (Array.isArray(r), r), M = (r) => r, R = (r) => {
44
+ const e = u.getState().organizationId, t = u.getState().moduleId;
45
+ return [...r, e, t];
46
+ };
47
+ export {
48
+ w as arePropsValid,
49
+ M as checkConfig,
50
+ y as checkIfPropExists,
51
+ S as checkVersion,
52
+ P as getEnvironmentVariables,
53
+ R as getModuleQueryKey,
54
+ _ as universalSelector
55
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hortiview/modulebase",
3
3
  "description": "This is a base module for hortiview",
4
- "version": "0.0.13075",
4
+ "version": "0.0.13101-beta",
5
5
  "type": "module",
6
6
  "author": "Falk Menge <falk.menge.ext@bayer.com>",
7
7
  "contributors": [
@@ -9,7 +9,7 @@
9
9
  ],
10
10
  "license": "GPL-3.0",
11
11
  "main": "dist/main.js",
12
- "types": "dist/main.d.ts",
12
+ "types": "dist/lib/main.d.ts",
13
13
  "files": [
14
14
  "dist"
15
15
  ],
@@ -23,8 +23,13 @@
23
23
  "preview": "vite preview"
24
24
  },
25
25
  "dependencies": {
26
+ "@hortiview/default-components": "^1.2.1",
27
+ "@hortiview/shared-components": "^2.0.0",
26
28
  "@microsoft/signalr": "^8.0.7",
29
+ "@tanstack/query-async-storage-persister": "^5.85.5",
27
30
  "@tanstack/react-query": "^5.67.3",
31
+ "@tanstack/react-query-persist-client": "^5.85.5",
32
+ "compare-versions": "^6.1.1",
28
33
  "lodash": "^4.17.21",
29
34
  "odata-query": "^7.0.9",
30
35
  "react": "^18.3.1",