@hortiview/modulebase 0.0.12333 → 0.0.12550
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.
- package/dist/QueryClientProvider-Q_mWQTzQ.js +435 -0
- package/dist/components/ModuleBase.js +509 -10
- package/dist/hooks/useCustom.js +1 -1
- package/dist/hooks/useCustomMutation.js +11 -102
- package/dist/hooks/useEntity.d.ts +2 -8
- package/dist/hooks/useEntity.js +1 -1
- package/dist/hooks/useOption.js +1 -1
- package/dist/hooks/useServiceBus.d.ts +15 -0
- package/dist/hooks/useServiceBus.js +17 -0
- package/dist/hooks/useStores.d.ts +2 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.js +118 -116
- package/dist/mutation-X73nm7Df.js +192 -0
- package/dist/query-CRIVoEP7.js +277 -0
- package/dist/types/BaseProps.d.ts +3 -0
- package/dist/types/ModuleApi.d.ts +75 -4
- package/dist/types/ServiceBus.d.ts +17 -0
- package/dist/types/ServiceBus.js +1 -0
- package/dist/useMutation-3rykrmeD.js +97 -0
- package/dist/{useQuery-DtzakC1A.js → useQuery-CwwWze9O.js} +47 -53
- package/dist/utils-DxRR_XLb.js +9 -0
- package/package.json +1 -1
- package/dist/ModuleBase-brrfWM_W.js +0 -697
- package/dist/QueryClientProvider-QWqHaM3I.js +0 -707
|
@@ -1,12 +1,511 @@
|
|
|
1
|
-
import "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import "../
|
|
4
|
-
import "
|
|
5
|
-
import "
|
|
6
|
-
import "../
|
|
7
|
-
import "../
|
|
8
|
-
import "../
|
|
9
|
-
import "../stores/
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { S as R, g as k, n as u, m as q, j as A, a as h, e as H, k as K, l as B, o as j, p as D, q as S, v as L, h as I, w as F, s as U, Q as V } from "../QueryClientProvider-Q_mWQTzQ.js";
|
|
3
|
+
import { Q as W } from "../query-CRIVoEP7.js";
|
|
4
|
+
import { M as X } from "../mutation-X73nm7Df.js";
|
|
5
|
+
import { useState as $, useEffect as b } from "react";
|
|
6
|
+
import { Y as z, h as Y, O as G, aU as J } from "../chunk-IR6S3I6Y-BmDdD3SP.js";
|
|
7
|
+
import { REQUIRED_PROPS as Z } from "../constants.js";
|
|
8
|
+
import { SignalRProvider as x } from "../provider/SignalR/SignalRProvider.js";
|
|
9
|
+
import { useBasePropsStore as M } from "../stores/BasePropsStore.js";
|
|
10
|
+
import { useEnvironmentStore as T } from "../stores/EnvironmentStore.js";
|
|
11
|
+
var ee = class extends R {
|
|
12
|
+
constructor(e = {}) {
|
|
13
|
+
super(), this.config = e, this.#e = /* @__PURE__ */ new Map();
|
|
14
|
+
}
|
|
15
|
+
#e;
|
|
16
|
+
build(e, t, s) {
|
|
17
|
+
const r = t.queryKey, n = t.queryHash ?? k(r, t);
|
|
18
|
+
let i = this.get(n);
|
|
19
|
+
return i || (i = new W({
|
|
20
|
+
client: e,
|
|
21
|
+
queryKey: r,
|
|
22
|
+
queryHash: n,
|
|
23
|
+
options: e.defaultQueryOptions(t),
|
|
24
|
+
state: s,
|
|
25
|
+
defaultOptions: e.getQueryDefaults(r)
|
|
26
|
+
}), this.add(i)), i;
|
|
27
|
+
}
|
|
28
|
+
add(e) {
|
|
29
|
+
this.#e.has(e.queryHash) || (this.#e.set(e.queryHash, e), this.notify({
|
|
30
|
+
type: "added",
|
|
31
|
+
query: e
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
remove(e) {
|
|
35
|
+
const t = this.#e.get(e.queryHash);
|
|
36
|
+
t && (e.destroy(), t === e && this.#e.delete(e.queryHash), this.notify({ type: "removed", query: e }));
|
|
37
|
+
}
|
|
38
|
+
clear() {
|
|
39
|
+
u.batch(() => {
|
|
40
|
+
this.getAll().forEach((e) => {
|
|
41
|
+
this.remove(e);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
get(e) {
|
|
46
|
+
return this.#e.get(e);
|
|
47
|
+
}
|
|
48
|
+
getAll() {
|
|
49
|
+
return [...this.#e.values()];
|
|
50
|
+
}
|
|
51
|
+
find(e) {
|
|
52
|
+
const t = { exact: !0, ...e };
|
|
53
|
+
return this.getAll().find(
|
|
54
|
+
(s) => q(t, s)
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
findAll(e = {}) {
|
|
58
|
+
const t = this.getAll();
|
|
59
|
+
return Object.keys(e).length > 0 ? t.filter((s) => q(e, s)) : t;
|
|
60
|
+
}
|
|
61
|
+
notify(e) {
|
|
62
|
+
u.batch(() => {
|
|
63
|
+
this.listeners.forEach((t) => {
|
|
64
|
+
t(e);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
onFocus() {
|
|
69
|
+
u.batch(() => {
|
|
70
|
+
this.getAll().forEach((e) => {
|
|
71
|
+
e.onFocus();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
onOnline() {
|
|
76
|
+
u.batch(() => {
|
|
77
|
+
this.getAll().forEach((e) => {
|
|
78
|
+
e.onOnline();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}, te = class extends R {
|
|
83
|
+
constructor(e = {}) {
|
|
84
|
+
super(), this.config = e, this.#e = /* @__PURE__ */ new Set(), this.#t = /* @__PURE__ */ new Map(), this.#s = 0;
|
|
85
|
+
}
|
|
86
|
+
#e;
|
|
87
|
+
#t;
|
|
88
|
+
#s;
|
|
89
|
+
build(e, t, s) {
|
|
90
|
+
const r = new X({
|
|
91
|
+
mutationCache: this,
|
|
92
|
+
mutationId: ++this.#s,
|
|
93
|
+
options: e.defaultMutationOptions(t),
|
|
94
|
+
state: s
|
|
95
|
+
});
|
|
96
|
+
return this.add(r), r;
|
|
97
|
+
}
|
|
98
|
+
add(e) {
|
|
99
|
+
this.#e.add(e);
|
|
100
|
+
const t = O(e);
|
|
101
|
+
if (typeof t == "string") {
|
|
102
|
+
const s = this.#t.get(t);
|
|
103
|
+
s ? s.push(e) : this.#t.set(t, [e]);
|
|
104
|
+
}
|
|
105
|
+
this.notify({ type: "added", mutation: e });
|
|
106
|
+
}
|
|
107
|
+
remove(e) {
|
|
108
|
+
if (this.#e.delete(e)) {
|
|
109
|
+
const t = O(e);
|
|
110
|
+
if (typeof t == "string") {
|
|
111
|
+
const s = this.#t.get(t);
|
|
112
|
+
if (s)
|
|
113
|
+
if (s.length > 1) {
|
|
114
|
+
const r = s.indexOf(e);
|
|
115
|
+
r !== -1 && s.splice(r, 1);
|
|
116
|
+
} else s[0] === e && this.#t.delete(t);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
this.notify({ type: "removed", mutation: e });
|
|
120
|
+
}
|
|
121
|
+
canRun(e) {
|
|
122
|
+
const t = O(e);
|
|
123
|
+
if (typeof t == "string") {
|
|
124
|
+
const r = this.#t.get(t)?.find(
|
|
125
|
+
(n) => n.state.status === "pending"
|
|
126
|
+
);
|
|
127
|
+
return !r || r === e;
|
|
128
|
+
} else
|
|
129
|
+
return !0;
|
|
130
|
+
}
|
|
131
|
+
runNext(e) {
|
|
132
|
+
const t = O(e);
|
|
133
|
+
return typeof t == "string" ? this.#t.get(t)?.find((r) => r !== e && r.state.isPaused)?.continue() ?? Promise.resolve() : Promise.resolve();
|
|
134
|
+
}
|
|
135
|
+
clear() {
|
|
136
|
+
u.batch(() => {
|
|
137
|
+
this.#e.forEach((e) => {
|
|
138
|
+
this.notify({ type: "removed", mutation: e });
|
|
139
|
+
}), this.#e.clear(), this.#t.clear();
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
getAll() {
|
|
143
|
+
return Array.from(this.#e);
|
|
144
|
+
}
|
|
145
|
+
find(e) {
|
|
146
|
+
const t = { exact: !0, ...e };
|
|
147
|
+
return this.getAll().find(
|
|
148
|
+
(s) => A(t, s)
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
findAll(e = {}) {
|
|
152
|
+
return this.getAll().filter((t) => A(e, t));
|
|
153
|
+
}
|
|
154
|
+
notify(e) {
|
|
155
|
+
u.batch(() => {
|
|
156
|
+
this.listeners.forEach((t) => {
|
|
157
|
+
t(e);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
resumePausedMutations() {
|
|
162
|
+
const e = this.getAll().filter((t) => t.state.isPaused);
|
|
163
|
+
return u.batch(
|
|
164
|
+
() => Promise.all(
|
|
165
|
+
e.map((t) => t.continue().catch(h))
|
|
166
|
+
)
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
function O(e) {
|
|
171
|
+
return e.options.scope?.id;
|
|
172
|
+
}
|
|
173
|
+
function C(e) {
|
|
174
|
+
return {
|
|
175
|
+
onFetch: (t, s) => {
|
|
176
|
+
const r = t.options, n = t.fetchOptions?.meta?.fetchMore?.direction, i = t.state.data?.pages || [], f = t.state.data?.pageParams || [];
|
|
177
|
+
let c = { pages: [], pageParams: [] }, d = 0;
|
|
178
|
+
const P = async () => {
|
|
179
|
+
let g = !1;
|
|
180
|
+
const Q = (o) => {
|
|
181
|
+
Object.defineProperty(o, "signal", {
|
|
182
|
+
enumerable: !0,
|
|
183
|
+
get: () => (t.signal.aborted ? g = !0 : t.signal.addEventListener("abort", () => {
|
|
184
|
+
g = !0;
|
|
185
|
+
}), t.signal)
|
|
186
|
+
});
|
|
187
|
+
}, a = H(t.options, t.fetchOptions), m = async (o, l, p) => {
|
|
188
|
+
if (g)
|
|
189
|
+
return Promise.reject();
|
|
190
|
+
if (l == null && o.pages.length)
|
|
191
|
+
return Promise.resolve(o);
|
|
192
|
+
const v = {
|
|
193
|
+
client: t.client,
|
|
194
|
+
queryKey: t.queryKey,
|
|
195
|
+
pageParam: l,
|
|
196
|
+
direction: p ? "backward" : "forward",
|
|
197
|
+
meta: t.options.meta
|
|
198
|
+
};
|
|
199
|
+
Q(v);
|
|
200
|
+
const _ = await a(
|
|
201
|
+
v
|
|
202
|
+
), { maxPages: w } = t.options, E = p ? K : B;
|
|
203
|
+
return {
|
|
204
|
+
pages: E(o.pages, _, w),
|
|
205
|
+
pageParams: E(o.pageParams, l, w)
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
if (n && i.length) {
|
|
209
|
+
const o = n === "backward", l = o ? se : N, p = {
|
|
210
|
+
pages: i,
|
|
211
|
+
pageParams: f
|
|
212
|
+
}, v = l(r, p);
|
|
213
|
+
c = await m(p, v, o);
|
|
214
|
+
} else {
|
|
215
|
+
const o = e ?? i.length;
|
|
216
|
+
do {
|
|
217
|
+
const l = d === 0 ? f[0] ?? r.initialPageParam : N(r, c);
|
|
218
|
+
if (d > 0 && l == null)
|
|
219
|
+
break;
|
|
220
|
+
c = await m(c, l), d++;
|
|
221
|
+
} while (d < o);
|
|
222
|
+
}
|
|
223
|
+
return c;
|
|
224
|
+
};
|
|
225
|
+
t.options.persister ? t.fetchFn = () => t.options.persister?.(
|
|
226
|
+
P,
|
|
227
|
+
{
|
|
228
|
+
client: t.client,
|
|
229
|
+
queryKey: t.queryKey,
|
|
230
|
+
meta: t.options.meta,
|
|
231
|
+
signal: t.signal
|
|
232
|
+
},
|
|
233
|
+
s
|
|
234
|
+
) : t.fetchFn = P;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function N(e, { pages: t, pageParams: s }) {
|
|
239
|
+
const r = t.length - 1;
|
|
240
|
+
return t.length > 0 ? e.getNextPageParam(
|
|
241
|
+
t[r],
|
|
242
|
+
t,
|
|
243
|
+
s[r],
|
|
244
|
+
s
|
|
245
|
+
) : void 0;
|
|
246
|
+
}
|
|
247
|
+
function se(e, { pages: t, pageParams: s }) {
|
|
248
|
+
return t.length > 0 ? e.getPreviousPageParam?.(t[0], t, s[0], s) : void 0;
|
|
249
|
+
}
|
|
250
|
+
var re = class {
|
|
251
|
+
#e;
|
|
252
|
+
#t;
|
|
253
|
+
#s;
|
|
254
|
+
#n;
|
|
255
|
+
#i;
|
|
256
|
+
#r;
|
|
257
|
+
#a;
|
|
258
|
+
#u;
|
|
259
|
+
constructor(e = {}) {
|
|
260
|
+
this.#e = e.queryCache || new ee(), this.#t = e.mutationCache || new te(), this.#s = e.defaultOptions || {}, this.#n = /* @__PURE__ */ new Map(), this.#i = /* @__PURE__ */ new Map(), this.#r = 0;
|
|
261
|
+
}
|
|
262
|
+
mount() {
|
|
263
|
+
this.#r++, this.#r === 1 && (this.#a = j.subscribe(async (e) => {
|
|
264
|
+
e && (await this.resumePausedMutations(), this.#e.onFocus());
|
|
265
|
+
}), this.#u = D.subscribe(async (e) => {
|
|
266
|
+
e && (await this.resumePausedMutations(), this.#e.onOnline());
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
unmount() {
|
|
270
|
+
this.#r--, this.#r === 0 && (this.#a?.(), this.#a = void 0, this.#u?.(), this.#u = void 0);
|
|
271
|
+
}
|
|
272
|
+
isFetching(e) {
|
|
273
|
+
return this.#e.findAll({ ...e, fetchStatus: "fetching" }).length;
|
|
274
|
+
}
|
|
275
|
+
isMutating(e) {
|
|
276
|
+
return this.#t.findAll({ ...e, status: "pending" }).length;
|
|
277
|
+
}
|
|
278
|
+
getQueryData(e) {
|
|
279
|
+
const t = this.defaultQueryOptions({ queryKey: e });
|
|
280
|
+
return this.#e.get(t.queryHash)?.state.data;
|
|
281
|
+
}
|
|
282
|
+
ensureQueryData(e) {
|
|
283
|
+
const t = this.defaultQueryOptions(e), s = this.#e.build(this, t), r = s.state.data;
|
|
284
|
+
return r === void 0 ? this.fetchQuery(e) : (e.revalidateIfStale && s.isStaleByTime(S(t.staleTime, s)) && this.prefetchQuery(t), Promise.resolve(r));
|
|
285
|
+
}
|
|
286
|
+
getQueriesData(e) {
|
|
287
|
+
return this.#e.findAll(e).map(({ queryKey: t, state: s }) => {
|
|
288
|
+
const r = s.data;
|
|
289
|
+
return [t, r];
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
setQueryData(e, t, s) {
|
|
293
|
+
const r = this.defaultQueryOptions({ queryKey: e }), i = this.#e.get(
|
|
294
|
+
r.queryHash
|
|
295
|
+
)?.state.data, f = L(t, i);
|
|
296
|
+
if (f !== void 0)
|
|
297
|
+
return this.#e.build(this, r).setData(f, { ...s, manual: !0 });
|
|
298
|
+
}
|
|
299
|
+
setQueriesData(e, t, s) {
|
|
300
|
+
return u.batch(
|
|
301
|
+
() => this.#e.findAll(e).map(({ queryKey: r }) => [
|
|
302
|
+
r,
|
|
303
|
+
this.setQueryData(r, t, s)
|
|
304
|
+
])
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
getQueryState(e) {
|
|
308
|
+
const t = this.defaultQueryOptions({ queryKey: e });
|
|
309
|
+
return this.#e.get(
|
|
310
|
+
t.queryHash
|
|
311
|
+
)?.state;
|
|
312
|
+
}
|
|
313
|
+
removeQueries(e) {
|
|
314
|
+
const t = this.#e;
|
|
315
|
+
u.batch(() => {
|
|
316
|
+
t.findAll(e).forEach((s) => {
|
|
317
|
+
t.remove(s);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
resetQueries(e, t) {
|
|
322
|
+
const s = this.#e;
|
|
323
|
+
return u.batch(() => (s.findAll(e).forEach((r) => {
|
|
324
|
+
r.reset();
|
|
325
|
+
}), this.refetchQueries(
|
|
326
|
+
{
|
|
327
|
+
type: "active",
|
|
328
|
+
...e
|
|
329
|
+
},
|
|
330
|
+
t
|
|
331
|
+
)));
|
|
332
|
+
}
|
|
333
|
+
cancelQueries(e, t = {}) {
|
|
334
|
+
const s = { revert: !0, ...t }, r = u.batch(
|
|
335
|
+
() => this.#e.findAll(e).map((n) => n.cancel(s))
|
|
336
|
+
);
|
|
337
|
+
return Promise.all(r).then(h).catch(h);
|
|
338
|
+
}
|
|
339
|
+
invalidateQueries(e, t = {}) {
|
|
340
|
+
return u.batch(() => (this.#e.findAll(e).forEach((s) => {
|
|
341
|
+
s.invalidate();
|
|
342
|
+
}), e?.refetchType === "none" ? Promise.resolve() : this.refetchQueries(
|
|
343
|
+
{
|
|
344
|
+
...e,
|
|
345
|
+
type: e?.refetchType ?? e?.type ?? "active"
|
|
346
|
+
},
|
|
347
|
+
t
|
|
348
|
+
)));
|
|
349
|
+
}
|
|
350
|
+
refetchQueries(e, t = {}) {
|
|
351
|
+
const s = {
|
|
352
|
+
...t,
|
|
353
|
+
cancelRefetch: t.cancelRefetch ?? !0
|
|
354
|
+
}, r = u.batch(
|
|
355
|
+
() => this.#e.findAll(e).filter((n) => !n.isDisabled()).map((n) => {
|
|
356
|
+
let i = n.fetch(void 0, s);
|
|
357
|
+
return s.throwOnError || (i = i.catch(h)), n.state.fetchStatus === "paused" ? Promise.resolve() : i;
|
|
358
|
+
})
|
|
359
|
+
);
|
|
360
|
+
return Promise.all(r).then(h);
|
|
361
|
+
}
|
|
362
|
+
fetchQuery(e) {
|
|
363
|
+
const t = this.defaultQueryOptions(e);
|
|
364
|
+
t.retry === void 0 && (t.retry = !1);
|
|
365
|
+
const s = this.#e.build(this, t);
|
|
366
|
+
return s.isStaleByTime(
|
|
367
|
+
S(t.staleTime, s)
|
|
368
|
+
) ? s.fetch(t) : Promise.resolve(s.state.data);
|
|
369
|
+
}
|
|
370
|
+
prefetchQuery(e) {
|
|
371
|
+
return this.fetchQuery(e).then(h).catch(h);
|
|
372
|
+
}
|
|
373
|
+
fetchInfiniteQuery(e) {
|
|
374
|
+
return e.behavior = C(e.pages), this.fetchQuery(e);
|
|
375
|
+
}
|
|
376
|
+
prefetchInfiniteQuery(e) {
|
|
377
|
+
return this.fetchInfiniteQuery(e).then(h).catch(h);
|
|
378
|
+
}
|
|
379
|
+
ensureInfiniteQueryData(e) {
|
|
380
|
+
return e.behavior = C(e.pages), this.ensureQueryData(e);
|
|
381
|
+
}
|
|
382
|
+
resumePausedMutations() {
|
|
383
|
+
return D.isOnline() ? this.#t.resumePausedMutations() : Promise.resolve();
|
|
384
|
+
}
|
|
385
|
+
getQueryCache() {
|
|
386
|
+
return this.#e;
|
|
387
|
+
}
|
|
388
|
+
getMutationCache() {
|
|
389
|
+
return this.#t;
|
|
390
|
+
}
|
|
391
|
+
getDefaultOptions() {
|
|
392
|
+
return this.#s;
|
|
393
|
+
}
|
|
394
|
+
setDefaultOptions(e) {
|
|
395
|
+
this.#s = e;
|
|
396
|
+
}
|
|
397
|
+
setQueryDefaults(e, t) {
|
|
398
|
+
this.#n.set(I(e), {
|
|
399
|
+
queryKey: e,
|
|
400
|
+
defaultOptions: t
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
getQueryDefaults(e) {
|
|
404
|
+
const t = [...this.#n.values()], s = {};
|
|
405
|
+
return t.forEach((r) => {
|
|
406
|
+
F(e, r.queryKey) && Object.assign(s, r.defaultOptions);
|
|
407
|
+
}), s;
|
|
408
|
+
}
|
|
409
|
+
setMutationDefaults(e, t) {
|
|
410
|
+
this.#i.set(I(e), {
|
|
411
|
+
mutationKey: e,
|
|
412
|
+
defaultOptions: t
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
getMutationDefaults(e) {
|
|
416
|
+
const t = [...this.#i.values()], s = {};
|
|
417
|
+
return t.forEach((r) => {
|
|
418
|
+
F(e, r.mutationKey) && Object.assign(s, r.defaultOptions);
|
|
419
|
+
}), s;
|
|
420
|
+
}
|
|
421
|
+
defaultQueryOptions(e) {
|
|
422
|
+
if (e._defaulted)
|
|
423
|
+
return e;
|
|
424
|
+
const t = {
|
|
425
|
+
...this.#s.queries,
|
|
426
|
+
...this.getQueryDefaults(e.queryKey),
|
|
427
|
+
...e,
|
|
428
|
+
_defaulted: !0
|
|
429
|
+
};
|
|
430
|
+
return t.queryHash || (t.queryHash = k(
|
|
431
|
+
t.queryKey,
|
|
432
|
+
t
|
|
433
|
+
)), t.refetchOnReconnect === void 0 && (t.refetchOnReconnect = t.networkMode !== "always"), t.throwOnError === void 0 && (t.throwOnError = !!t.suspense), !t.networkMode && t.persister && (t.networkMode = "offlineFirst"), t.queryFn === U && (t.enabled = !1), t;
|
|
434
|
+
}
|
|
435
|
+
defaultMutationOptions(e) {
|
|
436
|
+
return e?._defaulted ? e : {
|
|
437
|
+
...this.#s.mutations,
|
|
438
|
+
...e?.mutationKey && this.getMutationDefaults(e.mutationKey),
|
|
439
|
+
...e,
|
|
440
|
+
_defaulted: !0
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
clear() {
|
|
444
|
+
this.#e.clear(), this.#t.clear();
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
const ne = new re({
|
|
448
|
+
defaultOptions: {
|
|
449
|
+
mutations: {
|
|
450
|
+
retry: !1
|
|
451
|
+
},
|
|
452
|
+
queries: {
|
|
453
|
+
refetchOnWindowFocus: !1,
|
|
454
|
+
gcTime: 1e3 * 60 * 60 * 24,
|
|
455
|
+
// 24 hours
|
|
456
|
+
staleTime: 60 * 1e3,
|
|
457
|
+
// 60 seconds
|
|
458
|
+
retry: !1
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}), ie = () => {
|
|
462
|
+
const e = M((s) => s.currentNavigationPath), t = J();
|
|
463
|
+
b(() => {
|
|
464
|
+
e && t(e, { replace: !0 });
|
|
465
|
+
}, [e, t]);
|
|
466
|
+
}, ae = () => (ie(), /* @__PURE__ */ y(G, {})), Oe = ({
|
|
467
|
+
props: e,
|
|
468
|
+
routes: t,
|
|
469
|
+
env: s = void 0,
|
|
470
|
+
useSignalR: r = !1,
|
|
471
|
+
queryClient: n = ne
|
|
472
|
+
}) => {
|
|
473
|
+
const i = M((a) => a.setBaseProps), f = M((a) => a.modulePermissionToken), c = T((a) => a.setEnvironment), d = T((a) => a.addEnvironment), [P, g] = $(!1);
|
|
474
|
+
b(() => {
|
|
475
|
+
const a = he();
|
|
476
|
+
if (g(!a), a && c(a), !s) return;
|
|
477
|
+
const m = s[a?.ENVIRONMENT];
|
|
478
|
+
m && d(m);
|
|
479
|
+
}, [d, s, c]), b(() => {
|
|
480
|
+
g(!ue(e)), i(e);
|
|
481
|
+
}, [
|
|
482
|
+
e.currentLanguage,
|
|
483
|
+
e.currentLanguageId,
|
|
484
|
+
e.modulePermissionToken,
|
|
485
|
+
e.organizationId,
|
|
486
|
+
e.currentNavigationPath,
|
|
487
|
+
e.sourcePath
|
|
488
|
+
]);
|
|
489
|
+
const Q = z([
|
|
490
|
+
{
|
|
491
|
+
path: e.basePath,
|
|
492
|
+
children: t,
|
|
493
|
+
element: /* @__PURE__ */ y(ae, {})
|
|
494
|
+
}
|
|
495
|
+
]);
|
|
496
|
+
return P ? /* @__PURE__ */ y("div", { children: "TODO: Show fancy error" }) : f ? /* @__PURE__ */ y(V, { client: n, children: /* @__PURE__ */ y(x, { enabled: r, children: /* @__PURE__ */ y(Y, { router: Q }) }) }) : /* @__PURE__ */ y("div", { children: "TODO: Show fancy Loadingspinner" });
|
|
497
|
+
}, ue = (e) => Z.every((t) => oe(t, e)), oe = (e, t) => {
|
|
498
|
+
if (!t[e]) {
|
|
499
|
+
if (t.throwError)
|
|
500
|
+
return t.throwError(`Missing required prop: ${e}`, 404), !1;
|
|
501
|
+
throw new Error(`Missing required prop: ${e}`);
|
|
502
|
+
}
|
|
503
|
+
return !0;
|
|
504
|
+
}, he = () => {
|
|
505
|
+
const e = window.__env__;
|
|
506
|
+
if (e && (e.API_PREFIX = "/api/v8.0", !!e.COMMON_API && e.MODULE_AUTH_API && e.API_PREFIX && e.ENVIRONMENT))
|
|
507
|
+
return e;
|
|
508
|
+
};
|
|
10
509
|
export {
|
|
11
|
-
|
|
510
|
+
Oe as ModuleBase
|
|
12
511
|
};
|
package/dist/hooks/useCustom.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as i } from "../useQuery-
|
|
1
|
+
import { u as i } from "../useQuery-CwwWze9O.js";
|
|
2
2
|
import { useBasePropsStore as n } from "../stores/BasePropsStore.js";
|
|
3
3
|
import { universalSelector as p } from "../types/Requests.js";
|
|
4
4
|
import { fetchFromCustomApi as a } from "../utils/fetches.js";
|
|
@@ -1,112 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { n as b, s as f } from "../useQuery-DtzakC1A.js";
|
|
1
|
+
import { u } from "../useMutation-3rykrmeD.js";
|
|
2
|
+
import "../components/ModuleBase.js";
|
|
3
|
+
import "react";
|
|
5
4
|
import "../stores/BasePropsStore.js";
|
|
6
5
|
import "../provider/SignalR/SignalRProvider.js";
|
|
7
6
|
import "../omit-B7MWDtHq.js";
|
|
8
7
|
import "../stores/EnvironmentStore.js";
|
|
9
|
-
import { mutateOnCustomApi as
|
|
8
|
+
import { mutateOnCustomApi as n } from "../utils/fetches.js";
|
|
10
9
|
import "./useEntity.js";
|
|
11
10
|
import "../api-D9Lmqe6S.js";
|
|
12
|
-
|
|
13
|
-
#e;
|
|
14
|
-
#i = void 0;
|
|
15
|
-
#t;
|
|
16
|
-
#s;
|
|
17
|
-
constructor(t, s) {
|
|
18
|
-
super(), this.#e = t, this.setOptions(s), this.bindMethods(), this.#r();
|
|
19
|
-
}
|
|
20
|
-
bindMethods() {
|
|
21
|
-
this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
|
|
22
|
-
}
|
|
23
|
-
setOptions(t) {
|
|
24
|
-
const s = this.options;
|
|
25
|
-
this.options = this.#e.defaultMutationOptions(t), l(this.options, s) || this.#e.getMutationCache().notify({
|
|
26
|
-
type: "observerOptionsUpdated",
|
|
27
|
-
mutation: this.#t,
|
|
28
|
-
observer: this
|
|
29
|
-
}), s?.mutationKey && this.options.mutationKey && a(s.mutationKey) !== a(this.options.mutationKey) ? this.reset() : this.#t?.state.status === "pending" && this.#t.setOptions(this.options);
|
|
30
|
-
}
|
|
31
|
-
onUnsubscribe() {
|
|
32
|
-
this.hasListeners() || this.#t?.removeObserver(this);
|
|
33
|
-
}
|
|
34
|
-
onMutationUpdate(t) {
|
|
35
|
-
this.#r(), this.#o(t);
|
|
36
|
-
}
|
|
37
|
-
getCurrentResult() {
|
|
38
|
-
return this.#i;
|
|
39
|
-
}
|
|
40
|
-
reset() {
|
|
41
|
-
this.#t?.removeObserver(this), this.#t = void 0, this.#r(), this.#o();
|
|
42
|
-
}
|
|
43
|
-
mutate(t, s) {
|
|
44
|
-
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);
|
|
45
|
-
}
|
|
46
|
-
#r() {
|
|
47
|
-
const t = this.#t?.state ?? m();
|
|
48
|
-
this.#i = {
|
|
49
|
-
...t,
|
|
50
|
-
isPending: t.status === "pending",
|
|
51
|
-
isSuccess: t.status === "success",
|
|
52
|
-
isError: t.status === "error",
|
|
53
|
-
isIdle: t.status === "idle",
|
|
54
|
-
mutate: this.mutate,
|
|
55
|
-
reset: this.reset
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
#o(t) {
|
|
59
|
-
h.batch(() => {
|
|
60
|
-
if (this.#s && this.hasListeners()) {
|
|
61
|
-
const s = this.#i.variables, i = this.#i.context;
|
|
62
|
-
t?.type === "success" ? (this.#s.onSuccess?.(t.data, s, i), this.#s.onSettled?.(t.data, null, s, i)) : t?.type === "error" && (this.#s.onError?.(t.error, s, i), this.#s.onSettled?.(
|
|
63
|
-
void 0,
|
|
64
|
-
t.error,
|
|
65
|
-
s,
|
|
66
|
-
i
|
|
67
|
-
));
|
|
68
|
-
}
|
|
69
|
-
this.listeners.forEach((s) => {
|
|
70
|
-
s(this.#i);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
function y(t, s) {
|
|
76
|
-
const i = d(), [e] = o.useState(
|
|
77
|
-
() => new v(
|
|
78
|
-
i,
|
|
79
|
-
t
|
|
80
|
-
)
|
|
81
|
-
);
|
|
82
|
-
o.useEffect(() => {
|
|
83
|
-
e.setOptions(t);
|
|
84
|
-
}, [e, t]);
|
|
85
|
-
const r = o.useSyncExternalStore(
|
|
86
|
-
o.useCallback(
|
|
87
|
-
(u) => e.subscribe(h.batchCalls(u)),
|
|
88
|
-
[e]
|
|
89
|
-
),
|
|
90
|
-
() => e.getCurrentResult(),
|
|
91
|
-
() => e.getCurrentResult()
|
|
92
|
-
), n = o.useCallback(
|
|
93
|
-
(u, c) => {
|
|
94
|
-
e.mutate(u, c).catch(b);
|
|
95
|
-
},
|
|
96
|
-
[e]
|
|
97
|
-
);
|
|
98
|
-
if (r.error && f(e.options.throwOnError, [r.error]))
|
|
99
|
-
throw r.error;
|
|
100
|
-
return { ...r, mutate: n, mutateAsync: r.mutate };
|
|
101
|
-
}
|
|
102
|
-
const k = ({
|
|
11
|
+
const O = ({
|
|
103
12
|
endpoint: t,
|
|
104
|
-
method:
|
|
105
|
-
token:
|
|
106
|
-
headers:
|
|
107
|
-
}) =>
|
|
108
|
-
mutationFn: (
|
|
13
|
+
method: o,
|
|
14
|
+
token: m,
|
|
15
|
+
headers: r
|
|
16
|
+
}) => u({
|
|
17
|
+
mutationFn: (i, p) => n(p ?? t, i, o, m, r)
|
|
109
18
|
});
|
|
110
19
|
export {
|
|
111
|
-
|
|
20
|
+
O as useCustomMutation
|
|
112
21
|
};
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import { Block, BlockPlantLayout, Farm, FarmOrgEntity, Field, ModuleEntity, Season } from '../types/ModuleApi';
|
|
1
|
+
import { Block, BlockPlantLayout, Farm, FarmAlertRule, FarmOrganization, FarmOrgEntity, Field, IrrigationStation, ModuleEntity, Season } from '../types/ModuleApi';
|
|
2
2
|
type HortiviewDataAreaGroup = 'FarmOrganization' | 'FarmMember';
|
|
3
3
|
type ModuleDataAreaGroup = 'ModuleDepended';
|
|
4
4
|
type FarmOrganizationEntities = 'farms' | 'fields' | 'zones' | 'irrigation_stations' | 'farm_organizations' | 'alert_rules';
|
|
5
5
|
type FarmMemberEntities = 'farm_members';
|
|
6
6
|
type ModuleDependendEntities = 'Season' | 'BlockPlantLayout' | (string & {});
|
|
7
7
|
type HortiviewDataAreaEntity<T extends HortiviewDataAreaGroup | ModuleDataAreaGroup> = T extends 'FarmOrganization' ? FarmOrganizationEntities : T extends 'FarmMember' ? FarmMemberEntities : T extends 'ModuleDepended' ? ModuleDependendEntities : never;
|
|
8
|
-
type ResultMap<T extends FarmMemberEntities | FarmOrganizationEntities | ModuleDependendEntities> = T extends 'zones' ? Block : T extends 'fields' ? Field : T extends 'farms' ? Farm : T extends 'irrigation_stations' ?
|
|
9
|
-
id: string;
|
|
10
|
-
} : T extends 'farm_organizations' ? {
|
|
11
|
-
id: string;
|
|
12
|
-
} : T extends 'alert_rules' ? {
|
|
13
|
-
id: string;
|
|
14
|
-
} : T extends 'Season' ? Season : T extends 'BlockPlantLayout' ? BlockPlantLayout : never;
|
|
8
|
+
type ResultMap<T extends FarmMemberEntities | FarmOrganizationEntities | ModuleDependendEntities> = T extends 'zones' ? Block : T extends 'fields' ? Field : T extends 'farms' ? Farm : T extends 'irrigation_stations' ? IrrigationStation : T extends 'farm_organizations' ? FarmOrganization : T extends 'alert_rules' ? FarmAlertRule : T extends 'Season' ? Season : T extends 'BlockPlantLayout' ? BlockPlantLayout : unknown;
|
|
15
9
|
export declare const FarmOrgEntitiesTypeResultMap: Record<FarmOrganizationEntities, string>;
|
|
16
10
|
export declare const FarmMemberEntitiesTypeResultMap: Record<FarmMemberEntities, string>;
|
|
17
11
|
export declare const ModuleDependedEntityTypeResultMap: Record<ModuleDependendEntities, string>;
|
package/dist/hooks/useEntity.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as l } from "../useQuery-
|
|
1
|
+
import { u as l } from "../useQuery-CwwWze9O.js";
|
|
2
2
|
import { useMemo as g } from "react";
|
|
3
3
|
import { useBasePropsStore as p } from "../stores/BasePropsStore.js";
|
|
4
4
|
import { universalSelector as y } from "../types/Requests.js";
|
package/dist/hooks/useOption.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as m } from "../useQuery-
|
|
1
|
+
import { u as m } from "../useQuery-CwwWze9O.js";
|
|
2
2
|
import { g as u } from "../api-D9Lmqe6S.js";
|
|
3
3
|
import { useBasePropsStore as n } from "../stores/BasePropsStore.js";
|
|
4
4
|
import { universalSelector as s } from "../types/Requests.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import { AlertServiceBusMessage } from '../types/ServiceBus';
|
|
3
|
+
import { BaseResponse } from '../types/Requests';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param authenticationKey SASToken, that will be provided by the vendor portal of HortiView
|
|
7
|
+
* @param queue url of the service bus queue
|
|
8
|
+
* @param topic topic of the service bus, where the message will be sent to
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare const useServiceBus: ({ authenticationKey, queue, topic, }: {
|
|
12
|
+
authenticationKey: string;
|
|
13
|
+
queue: string;
|
|
14
|
+
topic: string;
|
|
15
|
+
}) => UseMutationResult<BaseResponse<unknown>, Error, AlertServiceBusMessage, unknown>;
|