@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
@@ -0,0 +1,27 @@
1
+ import u from "react";
2
+ const l = (t) => {
3
+ let e;
4
+ const n = /* @__PURE__ */ new Set(), o = (s, r) => {
5
+ const c = typeof s == "function" ? s(e) : s;
6
+ if (!Object.is(c, e)) {
7
+ const f = e;
8
+ e = r ?? (typeof c != "object" || c === null) ? c : Object.assign({}, e, c), n.forEach((g) => g(e, f));
9
+ }
10
+ }, a = () => e, i = { setState: o, getState: a, getInitialState: () => b, subscribe: (s) => (n.add(s), () => n.delete(s)) }, b = e = t(o, a, i);
11
+ return i;
12
+ }, d = ((t) => t ? l(t) : l), I = (t) => t;
13
+ function j(t, e = I) {
14
+ const n = u.useSyncExternalStore(
15
+ t.subscribe,
16
+ u.useCallback(() => e(t.getState()), [t, e]),
17
+ u.useCallback(() => e(t.getInitialState()), [t, e])
18
+ );
19
+ return u.useDebugValue(n), n;
20
+ }
21
+ const S = (t) => {
22
+ const e = d(t), n = (o) => j(e, o);
23
+ return Object.assign(n, e), n;
24
+ }, O = ((t) => t ? S(t) : S);
25
+ export {
26
+ O as c
27
+ };
@@ -1,4 +1,4 @@
1
- import { c as o } from "../react-QiIgv49H.js";
1
+ import { c as o } from "../react-c9FSfB30.js";
2
2
  const t = o((e) => ({
3
3
  setBaseProps: (s) => e({ ...s })
4
4
  }));
@@ -1,4 +1,4 @@
1
- import { c as r } from "../react-QiIgv49H.js";
1
+ import { c as r } from "../react-c9FSfB30.js";
2
2
  const E = r((e) => ({
3
3
  environment: {
4
4
  ENVIRONMENT: "DEV",
@@ -0,0 +1 @@
1
+
@@ -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
+ };
@@ -0,0 +1,139 @@
1
+ import * as o from "react";
2
+ import { g as l } from "./mutation-CmhiEgfA.js";
3
+ import { S as d, s as m, h as a, n as h, u as p, a as b, b as v } from "./QueryClientProvider-DyiNrPkn.js";
4
+ var f = class extends d {
5
+ #s;
6
+ #i = void 0;
7
+ #t;
8
+ #e;
9
+ constructor(t, s) {
10
+ super(), this.#s = t, this.setOptions(s), this.bindMethods(), this.#r();
11
+ }
12
+ bindMethods() {
13
+ this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
14
+ }
15
+ setOptions(t) {
16
+ const s = this.options;
17
+ this.options = this.#s.defaultMutationOptions(t), m(this.options, s) || this.#s.getMutationCache().notify({
18
+ type: "observerOptionsUpdated",
19
+ mutation: this.#t,
20
+ observer: this
21
+ }), s?.mutationKey && this.options.mutationKey && a(s.mutationKey) !== a(this.options.mutationKey) ? this.reset() : this.#t?.state.status === "pending" && this.#t.setOptions(this.options);
22
+ }
23
+ onUnsubscribe() {
24
+ this.hasListeners() || this.#t?.removeObserver(this);
25
+ }
26
+ onMutationUpdate(t) {
27
+ this.#r(), this.#o(t);
28
+ }
29
+ getCurrentResult() {
30
+ return this.#i;
31
+ }
32
+ reset() {
33
+ this.#t?.removeObserver(this), this.#t = void 0, this.#r(), this.#o();
34
+ }
35
+ mutate(t, s) {
36
+ return this.#e = s, this.#t?.removeObserver(this), this.#t = this.#s.getMutationCache().build(this.#s, this.options), this.#t.addObserver(this), this.#t.execute(t);
37
+ }
38
+ #r() {
39
+ const t = this.#t?.state ?? l();
40
+ this.#i = {
41
+ ...t,
42
+ isPending: t.status === "pending",
43
+ isSuccess: t.status === "success",
44
+ isError: t.status === "error",
45
+ isIdle: t.status === "idle",
46
+ mutate: this.mutate,
47
+ reset: this.reset
48
+ };
49
+ }
50
+ #o(t) {
51
+ h.batch(() => {
52
+ if (this.#e && this.hasListeners()) {
53
+ const s = this.#i.variables, r = this.#i.context, e = {
54
+ client: this.#s,
55
+ meta: this.options.meta,
56
+ mutationKey: this.options.mutationKey
57
+ };
58
+ if (t?.type === "success") {
59
+ try {
60
+ this.#e.onSuccess?.(
61
+ t.data,
62
+ s,
63
+ r,
64
+ e
65
+ );
66
+ } catch (i) {
67
+ Promise.reject(i);
68
+ }
69
+ try {
70
+ this.#e.onSettled?.(
71
+ t.data,
72
+ null,
73
+ s,
74
+ r,
75
+ e
76
+ );
77
+ } catch (i) {
78
+ Promise.reject(i);
79
+ }
80
+ } else if (t?.type === "error") {
81
+ try {
82
+ this.#e.onError?.(
83
+ t.error,
84
+ s,
85
+ r,
86
+ e
87
+ );
88
+ } catch (i) {
89
+ Promise.reject(i);
90
+ }
91
+ try {
92
+ this.#e.onSettled?.(
93
+ void 0,
94
+ t.error,
95
+ s,
96
+ r,
97
+ e
98
+ );
99
+ } catch (i) {
100
+ Promise.reject(i);
101
+ }
102
+ }
103
+ }
104
+ this.listeners.forEach((s) => {
105
+ s(this.#i);
106
+ });
107
+ });
108
+ }
109
+ };
110
+ function g(t, s) {
111
+ const r = p(s), [e] = o.useState(
112
+ () => new f(
113
+ r,
114
+ t
115
+ )
116
+ );
117
+ o.useEffect(() => {
118
+ e.setOptions(t);
119
+ }, [e, t]);
120
+ const i = o.useSyncExternalStore(
121
+ o.useCallback(
122
+ (n) => e.subscribe(h.batchCalls(n)),
123
+ [e]
124
+ ),
125
+ () => e.getCurrentResult(),
126
+ () => e.getCurrentResult()
127
+ ), u = o.useCallback(
128
+ (n, c) => {
129
+ e.mutate(n, c).catch(b);
130
+ },
131
+ [e]
132
+ );
133
+ if (i.error && v(e.options.throwOnError, [i.error]))
134
+ throw i.error;
135
+ return { ...i, mutate: u, mutateAsync: i.mutate };
136
+ }
137
+ export {
138
+ g as u
139
+ };
@@ -0,0 +1,392 @@
1
+ import { S as z, p as L, d as l, s as M, f as v, a as Q, j as _, k as j, t as K, l as w, m as $, r as A, n as W, b as q, u as G } from "./QueryClientProvider-DyiNrPkn.js";
2
+ import { f as J, u as X } from "./IsRestoringProvider-CBSZo7ur.js";
3
+ import * as m from "react";
4
+ import "react/jsx-runtime";
5
+ var Y = class extends z {
6
+ constructor(t, e) {
7
+ super(), this.options = e, this.#s = t, this.#i = null, this.#r = L(), this.bindMethods(), this.setOptions(e);
8
+ }
9
+ #s;
10
+ #t = void 0;
11
+ #p = void 0;
12
+ #e = void 0;
13
+ #n;
14
+ #u;
15
+ #r;
16
+ #i;
17
+ #m;
18
+ #l;
19
+ // This property keeps track of the last query with defined data.
20
+ // It will be used to pass the previous data and query to the placeholder function between renders.
21
+ #d;
22
+ #o;
23
+ #h;
24
+ #a;
25
+ #f = /* @__PURE__ */ new Set();
26
+ bindMethods() {
27
+ this.refetch = this.refetch.bind(this);
28
+ }
29
+ onSubscribe() {
30
+ this.listeners.size === 1 && (this.#t.addObserver(this), B(this.#t, this.options) ? this.#c() : this.updateResult(), this.#v());
31
+ }
32
+ onUnsubscribe() {
33
+ this.hasListeners() || this.destroy();
34
+ }
35
+ shouldFetchOnReconnect() {
36
+ return F(
37
+ this.#t,
38
+ this.options,
39
+ this.options.refetchOnReconnect
40
+ );
41
+ }
42
+ shouldFetchOnWindowFocus() {
43
+ return F(
44
+ this.#t,
45
+ this.options,
46
+ this.options.refetchOnWindowFocus
47
+ );
48
+ }
49
+ destroy() {
50
+ this.listeners = /* @__PURE__ */ new Set(), this.#R(), this.#S(), this.#t.removeObserver(this);
51
+ }
52
+ setOptions(t) {
53
+ const e = this.options, s = this.#t;
54
+ if (this.options = this.#s.defaultQueryOptions(t), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof l(this.options.enabled, this.#t) != "boolean")
55
+ throw new Error(
56
+ "Expected enabled to be a boolean or a callback that returns a boolean"
57
+ );
58
+ this.#E(), this.#t.setOptions(this.options), e._defaulted && !M(this.options, e) && this.#s.getQueryCache().notify({
59
+ type: "observerOptionsUpdated",
60
+ query: this.#t,
61
+ observer: this
62
+ });
63
+ const r = this.hasListeners();
64
+ r && H(
65
+ this.#t,
66
+ s,
67
+ this.options,
68
+ e
69
+ ) && this.#c(), this.updateResult(), r && (this.#t !== s || l(this.options.enabled, this.#t) !== l(e.enabled, this.#t) || v(this.options.staleTime, this.#t) !== v(e.staleTime, this.#t)) && this.#b();
70
+ const i = this.#y();
71
+ r && (this.#t !== s || l(this.options.enabled, this.#t) !== l(e.enabled, this.#t) || i !== this.#a) && this.#g(i);
72
+ }
73
+ getOptimisticResult(t) {
74
+ const e = this.#s.getQueryCache().build(this.#s, t), s = this.createResult(e, t);
75
+ return tt(this, s) && (this.#e = s, this.#u = this.options, this.#n = this.#t.state), s;
76
+ }
77
+ getCurrentResult() {
78
+ return this.#e;
79
+ }
80
+ trackResult(t, e) {
81
+ return new Proxy(t, {
82
+ get: (s, r) => (this.trackProp(r), e?.(r), r === "promise" && (this.trackProp("data"), !this.options.experimental_prefetchInRender && this.#r.status === "pending" && this.#r.reject(
83
+ new Error(
84
+ "experimental_prefetchInRender feature flag is not enabled"
85
+ )
86
+ )), Reflect.get(s, r))
87
+ });
88
+ }
89
+ trackProp(t) {
90
+ this.#f.add(t);
91
+ }
92
+ getCurrentQuery() {
93
+ return this.#t;
94
+ }
95
+ refetch({ ...t } = {}) {
96
+ return this.fetch({
97
+ ...t
98
+ });
99
+ }
100
+ fetchOptimistic(t) {
101
+ const e = this.#s.defaultQueryOptions(t), s = this.#s.getQueryCache().build(this.#s, e);
102
+ return s.fetch().then(() => this.createResult(s, e));
103
+ }
104
+ fetch(t) {
105
+ return this.#c({
106
+ ...t,
107
+ cancelRefetch: t.cancelRefetch ?? !0
108
+ }).then(() => (this.updateResult(), this.#e));
109
+ }
110
+ #c(t) {
111
+ this.#E();
112
+ let e = this.#t.fetch(
113
+ this.options,
114
+ t
115
+ );
116
+ return t?.throwOnError || (e = e.catch(Q)), e;
117
+ }
118
+ #b() {
119
+ this.#R();
120
+ const t = v(
121
+ this.options.staleTime,
122
+ this.#t
123
+ );
124
+ if (_ || this.#e.isStale || !j(t))
125
+ return;
126
+ const s = K(this.#e.dataUpdatedAt, t) + 1;
127
+ this.#o = w.setTimeout(() => {
128
+ this.#e.isStale || this.updateResult();
129
+ }, s);
130
+ }
131
+ #y() {
132
+ return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#t) : this.options.refetchInterval) ?? !1;
133
+ }
134
+ #g(t) {
135
+ this.#S(), this.#a = t, !(_ || l(this.options.enabled, this.#t) === !1 || !j(this.#a) || this.#a === 0) && (this.#h = w.setInterval(() => {
136
+ (this.options.refetchIntervalInBackground || $.isFocused()) && this.#c();
137
+ }, this.#a));
138
+ }
139
+ #v() {
140
+ this.#b(), this.#g(this.#y());
141
+ }
142
+ #R() {
143
+ this.#o && (w.clearTimeout(this.#o), this.#o = void 0);
144
+ }
145
+ #S() {
146
+ this.#h && (w.clearInterval(this.#h), this.#h = void 0);
147
+ }
148
+ createResult(t, e) {
149
+ const s = this.#t, r = this.options, i = this.#e, u = this.#n, a = this.#u, b = t !== s ? t.state : this.#p, { state: h } = t;
150
+ let n = { ...h }, y = !1, o;
151
+ if (e._optimisticResults) {
152
+ const c = this.hasListeners(), g = !c && B(t, e), S = c && H(t, s, e, r);
153
+ (g || S) && (n = {
154
+ ...n,
155
+ ...J(h.data, t.options)
156
+ }), e._optimisticResults === "isRestoring" && (n.fetchStatus = "idle");
157
+ }
158
+ let { error: R, errorUpdatedAt: x, status: p } = n;
159
+ o = n.data;
160
+ let U = !1;
161
+ if (e.placeholderData !== void 0 && o === void 0 && p === "pending") {
162
+ let c;
163
+ i?.isPlaceholderData && e.placeholderData === a?.placeholderData ? (c = i.data, U = !0) : c = typeof e.placeholderData == "function" ? e.placeholderData(
164
+ this.#d?.state.data,
165
+ this.#d
166
+ ) : e.placeholderData, c !== void 0 && (p = "success", o = A(
167
+ i?.data,
168
+ c,
169
+ e
170
+ ), y = !0);
171
+ }
172
+ if (e.select && o !== void 0 && !U)
173
+ if (i && o === u?.data && e.select === this.#m)
174
+ o = this.#l;
175
+ else
176
+ try {
177
+ this.#m = e.select, o = e.select(o), o = A(i?.data, o, e), this.#l = o, this.#i = null;
178
+ } catch (c) {
179
+ this.#i = c;
180
+ }
181
+ this.#i && (R = this.#i, o = this.#l, x = Date.now(), p = "error");
182
+ const C = n.fetchStatus === "fetching", I = p === "pending", T = p === "error", D = I && C, k = o !== void 0, f = {
183
+ status: p,
184
+ fetchStatus: n.fetchStatus,
185
+ isPending: I,
186
+ isSuccess: p === "success",
187
+ isError: T,
188
+ isInitialLoading: D,
189
+ isLoading: D,
190
+ data: o,
191
+ dataUpdatedAt: n.dataUpdatedAt,
192
+ error: R,
193
+ errorUpdatedAt: x,
194
+ failureCount: n.fetchFailureCount,
195
+ failureReason: n.fetchFailureReason,
196
+ errorUpdateCount: n.errorUpdateCount,
197
+ isFetched: n.dataUpdateCount > 0 || n.errorUpdateCount > 0,
198
+ isFetchedAfterMount: n.dataUpdateCount > b.dataUpdateCount || n.errorUpdateCount > b.errorUpdateCount,
199
+ isFetching: C,
200
+ isRefetching: C && !I,
201
+ isLoadingError: T && !k,
202
+ isPaused: n.fetchStatus === "paused",
203
+ isPlaceholderData: y,
204
+ isRefetchError: T && k,
205
+ isStale: P(t, e),
206
+ refetch: this.refetch,
207
+ promise: this.#r,
208
+ isEnabled: l(e.enabled, t) !== !1
209
+ };
210
+ if (this.options.experimental_prefetchInRender) {
211
+ const c = f.data !== void 0, g = f.status === "error" && !c, S = (O) => {
212
+ g ? O.reject(f.error) : c && O.resolve(f.data);
213
+ }, N = () => {
214
+ const O = this.#r = f.promise = L();
215
+ S(O);
216
+ }, E = this.#r;
217
+ switch (E.status) {
218
+ case "pending":
219
+ t.queryHash === s.queryHash && S(E);
220
+ break;
221
+ case "fulfilled":
222
+ (g || f.data !== E.value) && N();
223
+ break;
224
+ case "rejected":
225
+ (!g || f.error !== E.reason) && N();
226
+ break;
227
+ }
228
+ }
229
+ return f;
230
+ }
231
+ updateResult() {
232
+ const t = this.#e, e = this.createResult(this.#t, this.options);
233
+ if (this.#n = this.#t.state, this.#u = this.options, this.#n.data !== void 0 && (this.#d = this.#t), M(e, t))
234
+ return;
235
+ this.#e = e;
236
+ const s = () => {
237
+ if (!t)
238
+ return !0;
239
+ const { notifyOnChangeProps: r } = this.options, i = typeof r == "function" ? r() : r;
240
+ if (i === "all" || !i && !this.#f.size)
241
+ return !0;
242
+ const u = new Set(
243
+ i ?? this.#f
244
+ );
245
+ return this.options.throwOnError && u.add("error"), Object.keys(this.#e).some((a) => {
246
+ const d = a;
247
+ return this.#e[d] !== t[d] && u.has(d);
248
+ });
249
+ };
250
+ this.#O({ listeners: s() });
251
+ }
252
+ #E() {
253
+ const t = this.#s.getQueryCache().build(this.#s, this.options);
254
+ if (t === this.#t)
255
+ return;
256
+ const e = this.#t;
257
+ this.#t = t, this.#p = t.state, this.hasListeners() && (e?.removeObserver(this), t.addObserver(this));
258
+ }
259
+ onQueryUpdate() {
260
+ this.updateResult(), this.hasListeners() && this.#v();
261
+ }
262
+ #O(t) {
263
+ W.batch(() => {
264
+ t.listeners && this.listeners.forEach((e) => {
265
+ e(this.#e);
266
+ }), this.#s.getQueryCache().notify({
267
+ query: this.#t,
268
+ type: "observerResultsUpdated"
269
+ });
270
+ });
271
+ }
272
+ };
273
+ function Z(t, e) {
274
+ return l(e.enabled, t) !== !1 && t.state.data === void 0 && !(t.state.status === "error" && e.retryOnMount === !1);
275
+ }
276
+ function B(t, e) {
277
+ return Z(t, e) || t.state.data !== void 0 && F(t, e, e.refetchOnMount);
278
+ }
279
+ function F(t, e, s) {
280
+ if (l(e.enabled, t) !== !1 && v(e.staleTime, t) !== "static") {
281
+ const r = typeof s == "function" ? s(t) : s;
282
+ return r === "always" || r !== !1 && P(t, e);
283
+ }
284
+ return !1;
285
+ }
286
+ function H(t, e, s, r) {
287
+ return (t !== e || l(r.enabled, t) === !1) && (!s.suspense || t.state.status !== "error") && P(t, s);
288
+ }
289
+ function P(t, e) {
290
+ return l(e.enabled, t) !== !1 && t.isStaleByTime(v(e.staleTime, t));
291
+ }
292
+ function tt(t, e) {
293
+ return !M(t.getCurrentResult(), e);
294
+ }
295
+ function et() {
296
+ let t = !1;
297
+ return {
298
+ clearReset: () => {
299
+ t = !1;
300
+ },
301
+ reset: () => {
302
+ t = !0;
303
+ },
304
+ isReset: () => t
305
+ };
306
+ }
307
+ var st = m.createContext(et()), rt = () => m.useContext(st), it = (t, e, s) => {
308
+ const r = s?.state.error && typeof t.throwOnError == "function" ? q(t.throwOnError, [s.state.error, s]) : t.throwOnError;
309
+ (t.suspense || t.experimental_prefetchInRender || r) && (e.isReset() || (t.retryOnMount = !1));
310
+ }, at = (t) => {
311
+ m.useEffect(() => {
312
+ t.clearReset();
313
+ }, [t]);
314
+ }, nt = ({
315
+ result: t,
316
+ errorResetBoundary: e,
317
+ throwOnError: s,
318
+ query: r,
319
+ suspense: i
320
+ }) => t.isError && !e.isReset() && !t.isFetching && r && (i && t.data === void 0 || q(s, [t.error, r])), ot = (t) => {
321
+ if (t.suspense) {
322
+ const s = (i) => i === "static" ? i : Math.max(i ?? 1e3, 1e3), r = t.staleTime;
323
+ t.staleTime = typeof r == "function" ? (...i) => s(r(...i)) : s(r), typeof t.gcTime == "number" && (t.gcTime = Math.max(
324
+ t.gcTime,
325
+ 1e3
326
+ ));
327
+ }
328
+ }, ht = (t, e) => t.isLoading && t.isFetching && !e, ct = (t, e) => t?.suspense && e.isPending, V = (t, e, s) => e.fetchOptimistic(t).catch(() => {
329
+ s.clearReset();
330
+ });
331
+ function ut(t, e, s) {
332
+ if (process.env.NODE_ENV !== "production" && (typeof t != "object" || Array.isArray(t)))
333
+ throw new Error(
334
+ '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'
335
+ );
336
+ const r = X(), i = rt(), u = G(s), a = u.defaultQueryOptions(t);
337
+ u.getDefaultOptions().queries?._experimental_beforeQuery?.(
338
+ a
339
+ );
340
+ const d = u.getQueryCache().get(a.queryHash);
341
+ process.env.NODE_ENV !== "production" && (a.queryFn || console.error(
342
+ `[${a.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`
343
+ )), a._optimisticResults = r ? "isRestoring" : "optimistic", ot(a), it(a, i, d), at(i);
344
+ const b = !u.getQueryCache().get(a.queryHash), [h] = m.useState(
345
+ () => new e(
346
+ u,
347
+ a
348
+ )
349
+ ), n = h.getOptimisticResult(a), y = !r && t.subscribed !== !1;
350
+ if (m.useSyncExternalStore(
351
+ m.useCallback(
352
+ (o) => {
353
+ const R = y ? h.subscribe(W.batchCalls(o)) : Q;
354
+ return h.updateResult(), R;
355
+ },
356
+ [h, y]
357
+ ),
358
+ () => h.getCurrentResult(),
359
+ () => h.getCurrentResult()
360
+ ), m.useEffect(() => {
361
+ h.setOptions(a);
362
+ }, [a, h]), ct(a, n))
363
+ throw V(a, h, i);
364
+ if (nt({
365
+ result: n,
366
+ errorResetBoundary: i,
367
+ throwOnError: a.throwOnError,
368
+ query: d,
369
+ suspense: a.suspense
370
+ }))
371
+ throw n.error;
372
+ return u.getDefaultOptions().queries?._experimental_afterQuery?.(
373
+ a,
374
+ n
375
+ ), a.experimental_prefetchInRender && !_ && ht(n, r) && (b ? (
376
+ // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
377
+ V(a, h, i)
378
+ ) : (
379
+ // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
380
+ d?.promise
381
+ ))?.catch(Q).finally(() => {
382
+ h.updateResult();
383
+ }), a.notifyOnChangeProps ? n : h.trackResult(n);
384
+ }
385
+ function mt(t, e) {
386
+ return ut(t, Y, e);
387
+ }
388
+ export {
389
+ Y as Q,
390
+ ut as a,
391
+ mt as u
392
+ };
@@ -0,0 +1,43 @@
1
+ function a(e) {
2
+ return new Promise((n, t) => {
3
+ e.oncomplete = e.onsuccess = () => n(e.result), e.onabort = e.onerror = () => t(e.error);
4
+ });
5
+ }
6
+ function s(e, n) {
7
+ let t;
8
+ const o = () => {
9
+ if (t)
10
+ return t;
11
+ const r = indexedDB.open(e);
12
+ return r.onupgradeneeded = () => r.result.createObjectStore(n), t = a(r), t.then((c) => {
13
+ c.onclose = () => t = void 0;
14
+ }, () => {
15
+ }), t;
16
+ };
17
+ return (r, c) => o().then((d) => c(d.transaction(n, r).objectStore(n)));
18
+ }
19
+ let u;
20
+ function i() {
21
+ return u || (u = s("keyval-store", "keyval")), u;
22
+ }
23
+ function l(e, n = i()) {
24
+ return n("readonly", (t) => a(t.get(e)));
25
+ }
26
+ function f(e, n, t = i()) {
27
+ return t("readwrite", (o) => (o.put(n, e), a(o.transaction)));
28
+ }
29
+ function p(e, n = i()) {
30
+ return n("readwrite", (t) => (t.delete(e), a(t.transaction)));
31
+ }
32
+ const y = {
33
+ getItem: async (e) => await l(e),
34
+ setItem: async (e, n) => {
35
+ await f(e, n);
36
+ },
37
+ removeItem: async (e) => {
38
+ await p(e);
39
+ }
40
+ };
41
+ export {
42
+ y as indexedDbStorage
43
+ };
package/dist/utils/api.js CHANGED
@@ -1,9 +1,8 @@
1
- import { f as t, b as s, a as f, h as i } from "../api-D9Lmqe6S.js";
1
+ import { f as t, a as i, h as n } from "../api-COabZnyn.js";
2
2
  import "../constants.js";
3
3
  import "../stores/BasePropsStore.js";
4
4
  export {
5
5
  t as fetchWithErrorHandling,
6
- s as formatQuery,
7
- f as getConfig,
8
- i as handleResponse
6
+ i as getConfig,
7
+ n as handleResponse
9
8
  };
@@ -1,19 +1,23 @@
1
- import { a as d, f, i as m, b as S } from "../api-D9Lmqe6S.js";
2
1
  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);
2
+ import { a as u, f } from "../api-COabZnyn.js";
3
+ const k = (a, s, e, i, g, o = !1) => {
4
+ const r = o ? void 0 : i ?? t.getState().modulePermissionToken, n = t.getState().organizationId, c = t.getState().currentLanguageId, l = t.getState().throwError;
5
+ if (!o && !r)
6
+ return l?.("No token found", 404), Promise.reject();
7
+ const d = u(r, n, c, e, g);
8
+ return d.body = JSON.stringify(s), f(a, d);
9
+ }, I = (a, s, e = !1) => {
10
+ const i = t.getState().modulePermissionToken, g = t.getState().organizationId, o = t.getState().currentLanguageId, r = t.getState().throwError, n = e ? void 0 : s ?? i;
11
+ if (!e && !n)
12
+ return r?.("No token available", 401), Promise.reject(
13
+ new Error("No token available", {
14
+ cause: 401
15
+ })
16
+ );
17
+ const c = u(n, g, o);
18
+ return f(a, c);
15
19
  };
16
20
  export {
17
- E as baseFetch,
21
+ I as baseFetch,
18
22
  k as baseMutation
19
23
  };