@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,697 +0,0 @@
|
|
|
1
|
-
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
-
import { S as N, a as k, Q as x, n as u, m as S, R as H, c as K, b as A, d as h, e as B, f as j, g as U, i as G, o as D, r as C, j as L, h as q, p as R, k as V, l as W } from "./QueryClientProvider-QWqHaM3I.js";
|
|
3
|
-
import { useState as X, useEffect as M } from "react";
|
|
4
|
-
import { Y as $, h as z, O as Y, aU as J } from "./chunk-IR6S3I6Y-BmDdD3SP.js";
|
|
5
|
-
import { REQUIRED_PROPS as Z } from "./constants.js";
|
|
6
|
-
import { SignalRProvider as ee } from "./provider/SignalR/SignalRProvider.js";
|
|
7
|
-
import { useBasePropsStore as b } from "./stores/BasePropsStore.js";
|
|
8
|
-
import { useEnvironmentStore as F } from "./stores/EnvironmentStore.js";
|
|
9
|
-
var te = class extends N {
|
|
10
|
-
constructor(e = {}) {
|
|
11
|
-
super(), this.config = e, this.#e = /* @__PURE__ */ new Map();
|
|
12
|
-
}
|
|
13
|
-
#e;
|
|
14
|
-
build(e, t, s) {
|
|
15
|
-
const i = t.queryKey, n = t.queryHash ?? k(i, t);
|
|
16
|
-
let r = this.get(n);
|
|
17
|
-
return r || (r = new x({
|
|
18
|
-
client: e,
|
|
19
|
-
queryKey: i,
|
|
20
|
-
queryHash: n,
|
|
21
|
-
options: e.defaultQueryOptions(t),
|
|
22
|
-
state: s,
|
|
23
|
-
defaultOptions: e.getQueryDefaults(i)
|
|
24
|
-
}), this.add(r)), r;
|
|
25
|
-
}
|
|
26
|
-
add(e) {
|
|
27
|
-
this.#e.has(e.queryHash) || (this.#e.set(e.queryHash, e), this.notify({
|
|
28
|
-
type: "added",
|
|
29
|
-
query: e
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
remove(e) {
|
|
33
|
-
const t = this.#e.get(e.queryHash);
|
|
34
|
-
t && (e.destroy(), t === e && this.#e.delete(e.queryHash), this.notify({ type: "removed", query: e }));
|
|
35
|
-
}
|
|
36
|
-
clear() {
|
|
37
|
-
u.batch(() => {
|
|
38
|
-
this.getAll().forEach((e) => {
|
|
39
|
-
this.remove(e);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
get(e) {
|
|
44
|
-
return this.#e.get(e);
|
|
45
|
-
}
|
|
46
|
-
getAll() {
|
|
47
|
-
return [...this.#e.values()];
|
|
48
|
-
}
|
|
49
|
-
find(e) {
|
|
50
|
-
const t = { exact: !0, ...e };
|
|
51
|
-
return this.getAll().find(
|
|
52
|
-
(s) => S(t, s)
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
findAll(e = {}) {
|
|
56
|
-
const t = this.getAll();
|
|
57
|
-
return Object.keys(e).length > 0 ? t.filter((s) => S(e, s)) : t;
|
|
58
|
-
}
|
|
59
|
-
notify(e) {
|
|
60
|
-
u.batch(() => {
|
|
61
|
-
this.listeners.forEach((t) => {
|
|
62
|
-
t(e);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
onFocus() {
|
|
67
|
-
u.batch(() => {
|
|
68
|
-
this.getAll().forEach((e) => {
|
|
69
|
-
e.onFocus();
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
onOnline() {
|
|
74
|
-
u.batch(() => {
|
|
75
|
-
this.getAll().forEach((e) => {
|
|
76
|
-
e.onOnline();
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}, se = class extends H {
|
|
81
|
-
#e;
|
|
82
|
-
#t;
|
|
83
|
-
#s;
|
|
84
|
-
constructor(e) {
|
|
85
|
-
super(), this.mutationId = e.mutationId, this.#t = e.mutationCache, this.#e = [], this.state = e.state || ie(), this.setOptions(e.options), this.scheduleGc();
|
|
86
|
-
}
|
|
87
|
-
setOptions(e) {
|
|
88
|
-
this.options = e, this.updateGcTime(this.options.gcTime);
|
|
89
|
-
}
|
|
90
|
-
get meta() {
|
|
91
|
-
return this.options.meta;
|
|
92
|
-
}
|
|
93
|
-
addObserver(e) {
|
|
94
|
-
this.#e.includes(e) || (this.#e.push(e), this.clearGcTimeout(), this.#t.notify({
|
|
95
|
-
type: "observerAdded",
|
|
96
|
-
mutation: this,
|
|
97
|
-
observer: e
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
removeObserver(e) {
|
|
101
|
-
this.#e = this.#e.filter((t) => t !== e), this.scheduleGc(), this.#t.notify({
|
|
102
|
-
type: "observerRemoved",
|
|
103
|
-
mutation: this,
|
|
104
|
-
observer: e
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
optionalRemove() {
|
|
108
|
-
this.#e.length || (this.state.status === "pending" ? this.scheduleGc() : this.#t.remove(this));
|
|
109
|
-
}
|
|
110
|
-
continue() {
|
|
111
|
-
return this.#s?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
|
|
112
|
-
this.execute(this.state.variables);
|
|
113
|
-
}
|
|
114
|
-
async execute(e) {
|
|
115
|
-
this.#s = K({
|
|
116
|
-
fn: () => this.options.mutationFn ? this.options.mutationFn(e) : Promise.reject(new Error("No mutationFn found")),
|
|
117
|
-
onFail: (i, n) => {
|
|
118
|
-
this.#i({ type: "failed", failureCount: i, error: n });
|
|
119
|
-
},
|
|
120
|
-
onPause: () => {
|
|
121
|
-
this.#i({ type: "pause" });
|
|
122
|
-
},
|
|
123
|
-
onContinue: () => {
|
|
124
|
-
this.#i({ type: "continue" });
|
|
125
|
-
},
|
|
126
|
-
retry: this.options.retry ?? 0,
|
|
127
|
-
retryDelay: this.options.retryDelay,
|
|
128
|
-
networkMode: this.options.networkMode,
|
|
129
|
-
canRun: () => this.#t.canRun(this)
|
|
130
|
-
});
|
|
131
|
-
const t = this.state.status === "pending", s = !this.#s.canStart();
|
|
132
|
-
try {
|
|
133
|
-
if (!t) {
|
|
134
|
-
this.#i({ type: "pending", variables: e, isPaused: s }), await this.#t.config.onMutate?.(
|
|
135
|
-
e,
|
|
136
|
-
this
|
|
137
|
-
);
|
|
138
|
-
const n = await this.options.onMutate?.(e);
|
|
139
|
-
n !== this.state.context && this.#i({
|
|
140
|
-
type: "pending",
|
|
141
|
-
context: n,
|
|
142
|
-
variables: e,
|
|
143
|
-
isPaused: s
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
const i = await this.#s.start();
|
|
147
|
-
return await this.#t.config.onSuccess?.(
|
|
148
|
-
i,
|
|
149
|
-
e,
|
|
150
|
-
this.state.context,
|
|
151
|
-
this
|
|
152
|
-
), await this.options.onSuccess?.(i, e, this.state.context), await this.#t.config.onSettled?.(
|
|
153
|
-
i,
|
|
154
|
-
null,
|
|
155
|
-
this.state.variables,
|
|
156
|
-
this.state.context,
|
|
157
|
-
this
|
|
158
|
-
), await this.options.onSettled?.(i, null, e, this.state.context), this.#i({ type: "success", data: i }), i;
|
|
159
|
-
} catch (i) {
|
|
160
|
-
try {
|
|
161
|
-
throw await this.#t.config.onError?.(
|
|
162
|
-
i,
|
|
163
|
-
e,
|
|
164
|
-
this.state.context,
|
|
165
|
-
this
|
|
166
|
-
), await this.options.onError?.(
|
|
167
|
-
i,
|
|
168
|
-
e,
|
|
169
|
-
this.state.context
|
|
170
|
-
), await this.#t.config.onSettled?.(
|
|
171
|
-
void 0,
|
|
172
|
-
i,
|
|
173
|
-
this.state.variables,
|
|
174
|
-
this.state.context,
|
|
175
|
-
this
|
|
176
|
-
), await this.options.onSettled?.(
|
|
177
|
-
void 0,
|
|
178
|
-
i,
|
|
179
|
-
e,
|
|
180
|
-
this.state.context
|
|
181
|
-
), i;
|
|
182
|
-
} finally {
|
|
183
|
-
this.#i({ type: "error", error: i });
|
|
184
|
-
}
|
|
185
|
-
} finally {
|
|
186
|
-
this.#t.runNext(this);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
#i(e) {
|
|
190
|
-
const t = (s) => {
|
|
191
|
-
switch (e.type) {
|
|
192
|
-
case "failed":
|
|
193
|
-
return {
|
|
194
|
-
...s,
|
|
195
|
-
failureCount: e.failureCount,
|
|
196
|
-
failureReason: e.error
|
|
197
|
-
};
|
|
198
|
-
case "pause":
|
|
199
|
-
return {
|
|
200
|
-
...s,
|
|
201
|
-
isPaused: !0
|
|
202
|
-
};
|
|
203
|
-
case "continue":
|
|
204
|
-
return {
|
|
205
|
-
...s,
|
|
206
|
-
isPaused: !1
|
|
207
|
-
};
|
|
208
|
-
case "pending":
|
|
209
|
-
return {
|
|
210
|
-
...s,
|
|
211
|
-
context: e.context,
|
|
212
|
-
data: void 0,
|
|
213
|
-
failureCount: 0,
|
|
214
|
-
failureReason: null,
|
|
215
|
-
error: null,
|
|
216
|
-
isPaused: e.isPaused,
|
|
217
|
-
status: "pending",
|
|
218
|
-
variables: e.variables,
|
|
219
|
-
submittedAt: Date.now()
|
|
220
|
-
};
|
|
221
|
-
case "success":
|
|
222
|
-
return {
|
|
223
|
-
...s,
|
|
224
|
-
data: e.data,
|
|
225
|
-
failureCount: 0,
|
|
226
|
-
failureReason: null,
|
|
227
|
-
error: null,
|
|
228
|
-
status: "success",
|
|
229
|
-
isPaused: !1
|
|
230
|
-
};
|
|
231
|
-
case "error":
|
|
232
|
-
return {
|
|
233
|
-
...s,
|
|
234
|
-
data: void 0,
|
|
235
|
-
error: e.error,
|
|
236
|
-
failureCount: s.failureCount + 1,
|
|
237
|
-
failureReason: e.error,
|
|
238
|
-
isPaused: !1,
|
|
239
|
-
status: "error"
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
this.state = t(this.state), u.batch(() => {
|
|
244
|
-
this.#e.forEach((s) => {
|
|
245
|
-
s.onMutationUpdate(e);
|
|
246
|
-
}), this.#t.notify({
|
|
247
|
-
mutation: this,
|
|
248
|
-
type: "updated",
|
|
249
|
-
action: e
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
function ie() {
|
|
255
|
-
return {
|
|
256
|
-
context: void 0,
|
|
257
|
-
data: void 0,
|
|
258
|
-
error: null,
|
|
259
|
-
failureCount: 0,
|
|
260
|
-
failureReason: null,
|
|
261
|
-
isPaused: !1,
|
|
262
|
-
status: "idle",
|
|
263
|
-
variables: void 0,
|
|
264
|
-
submittedAt: 0
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
var ne = class extends N {
|
|
268
|
-
constructor(e = {}) {
|
|
269
|
-
super(), this.config = e, this.#e = /* @__PURE__ */ new Set(), this.#t = /* @__PURE__ */ new Map(), this.#s = 0;
|
|
270
|
-
}
|
|
271
|
-
#e;
|
|
272
|
-
#t;
|
|
273
|
-
#s;
|
|
274
|
-
build(e, t, s) {
|
|
275
|
-
const i = new se({
|
|
276
|
-
mutationCache: this,
|
|
277
|
-
mutationId: ++this.#s,
|
|
278
|
-
options: e.defaultMutationOptions(t),
|
|
279
|
-
state: s
|
|
280
|
-
});
|
|
281
|
-
return this.add(i), i;
|
|
282
|
-
}
|
|
283
|
-
add(e) {
|
|
284
|
-
this.#e.add(e);
|
|
285
|
-
const t = O(e);
|
|
286
|
-
if (typeof t == "string") {
|
|
287
|
-
const s = this.#t.get(t);
|
|
288
|
-
s ? s.push(e) : this.#t.set(t, [e]);
|
|
289
|
-
}
|
|
290
|
-
this.notify({ type: "added", mutation: e });
|
|
291
|
-
}
|
|
292
|
-
remove(e) {
|
|
293
|
-
if (this.#e.delete(e)) {
|
|
294
|
-
const t = O(e);
|
|
295
|
-
if (typeof t == "string") {
|
|
296
|
-
const s = this.#t.get(t);
|
|
297
|
-
if (s)
|
|
298
|
-
if (s.length > 1) {
|
|
299
|
-
const i = s.indexOf(e);
|
|
300
|
-
i !== -1 && s.splice(i, 1);
|
|
301
|
-
} else s[0] === e && this.#t.delete(t);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
this.notify({ type: "removed", mutation: e });
|
|
305
|
-
}
|
|
306
|
-
canRun(e) {
|
|
307
|
-
const t = O(e);
|
|
308
|
-
if (typeof t == "string") {
|
|
309
|
-
const i = this.#t.get(t)?.find(
|
|
310
|
-
(n) => n.state.status === "pending"
|
|
311
|
-
);
|
|
312
|
-
return !i || i === e;
|
|
313
|
-
} else
|
|
314
|
-
return !0;
|
|
315
|
-
}
|
|
316
|
-
runNext(e) {
|
|
317
|
-
const t = O(e);
|
|
318
|
-
return typeof t == "string" ? this.#t.get(t)?.find((i) => i !== e && i.state.isPaused)?.continue() ?? Promise.resolve() : Promise.resolve();
|
|
319
|
-
}
|
|
320
|
-
clear() {
|
|
321
|
-
u.batch(() => {
|
|
322
|
-
this.#e.forEach((e) => {
|
|
323
|
-
this.notify({ type: "removed", mutation: e });
|
|
324
|
-
}), this.#e.clear(), this.#t.clear();
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
getAll() {
|
|
328
|
-
return Array.from(this.#e);
|
|
329
|
-
}
|
|
330
|
-
find(e) {
|
|
331
|
-
const t = { exact: !0, ...e };
|
|
332
|
-
return this.getAll().find(
|
|
333
|
-
(s) => A(t, s)
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
findAll(e = {}) {
|
|
337
|
-
return this.getAll().filter((t) => A(e, t));
|
|
338
|
-
}
|
|
339
|
-
notify(e) {
|
|
340
|
-
u.batch(() => {
|
|
341
|
-
this.listeners.forEach((t) => {
|
|
342
|
-
t(e);
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
resumePausedMutations() {
|
|
347
|
-
const e = this.getAll().filter((t) => t.state.isPaused);
|
|
348
|
-
return u.batch(
|
|
349
|
-
() => Promise.all(
|
|
350
|
-
e.map((t) => t.continue().catch(h))
|
|
351
|
-
)
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
function O(e) {
|
|
356
|
-
return e.options.scope?.id;
|
|
357
|
-
}
|
|
358
|
-
function I(e) {
|
|
359
|
-
return {
|
|
360
|
-
onFetch: (t, s) => {
|
|
361
|
-
const i = t.options, n = t.fetchOptions?.meta?.fetchMore?.direction, r = t.state.data?.pages || [], d = t.state.data?.pageParams || [];
|
|
362
|
-
let c = { pages: [], pageParams: [] }, f = 0;
|
|
363
|
-
const P = async () => {
|
|
364
|
-
let p = !1;
|
|
365
|
-
const w = (o) => {
|
|
366
|
-
Object.defineProperty(o, "signal", {
|
|
367
|
-
enumerable: !0,
|
|
368
|
-
get: () => (t.signal.aborted ? p = !0 : t.signal.addEventListener("abort", () => {
|
|
369
|
-
p = !0;
|
|
370
|
-
}), t.signal)
|
|
371
|
-
});
|
|
372
|
-
}, a = B(t.options, t.fetchOptions), m = async (o, l, g) => {
|
|
373
|
-
if (p)
|
|
374
|
-
return Promise.reject();
|
|
375
|
-
if (l == null && o.pages.length)
|
|
376
|
-
return Promise.resolve(o);
|
|
377
|
-
const v = {
|
|
378
|
-
client: t.client,
|
|
379
|
-
queryKey: t.queryKey,
|
|
380
|
-
pageParam: l,
|
|
381
|
-
direction: g ? "backward" : "forward",
|
|
382
|
-
meta: t.options.meta
|
|
383
|
-
};
|
|
384
|
-
w(v);
|
|
385
|
-
const _ = await a(
|
|
386
|
-
v
|
|
387
|
-
), { maxPages: Q } = t.options, E = g ? j : U;
|
|
388
|
-
return {
|
|
389
|
-
pages: E(o.pages, _, Q),
|
|
390
|
-
pageParams: E(o.pageParams, l, Q)
|
|
391
|
-
};
|
|
392
|
-
};
|
|
393
|
-
if (n && r.length) {
|
|
394
|
-
const o = n === "backward", l = o ? re : T, g = {
|
|
395
|
-
pages: r,
|
|
396
|
-
pageParams: d
|
|
397
|
-
}, v = l(i, g);
|
|
398
|
-
c = await m(g, v, o);
|
|
399
|
-
} else {
|
|
400
|
-
const o = e ?? r.length;
|
|
401
|
-
do {
|
|
402
|
-
const l = f === 0 ? d[0] ?? i.initialPageParam : T(i, c);
|
|
403
|
-
if (f > 0 && l == null)
|
|
404
|
-
break;
|
|
405
|
-
c = await m(c, l), f++;
|
|
406
|
-
} while (f < o);
|
|
407
|
-
}
|
|
408
|
-
return c;
|
|
409
|
-
};
|
|
410
|
-
t.options.persister ? t.fetchFn = () => t.options.persister?.(
|
|
411
|
-
P,
|
|
412
|
-
{
|
|
413
|
-
client: t.client,
|
|
414
|
-
queryKey: t.queryKey,
|
|
415
|
-
meta: t.options.meta,
|
|
416
|
-
signal: t.signal
|
|
417
|
-
},
|
|
418
|
-
s
|
|
419
|
-
) : t.fetchFn = P;
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
function T(e, { pages: t, pageParams: s }) {
|
|
424
|
-
const i = t.length - 1;
|
|
425
|
-
return t.length > 0 ? e.getNextPageParam(
|
|
426
|
-
t[i],
|
|
427
|
-
t,
|
|
428
|
-
s[i],
|
|
429
|
-
s
|
|
430
|
-
) : void 0;
|
|
431
|
-
}
|
|
432
|
-
function re(e, { pages: t, pageParams: s }) {
|
|
433
|
-
return t.length > 0 ? e.getPreviousPageParam?.(t[0], t, s[0], s) : void 0;
|
|
434
|
-
}
|
|
435
|
-
var ae = class {
|
|
436
|
-
#e;
|
|
437
|
-
#t;
|
|
438
|
-
#s;
|
|
439
|
-
#i;
|
|
440
|
-
#r;
|
|
441
|
-
#n;
|
|
442
|
-
#a;
|
|
443
|
-
#u;
|
|
444
|
-
constructor(e = {}) {
|
|
445
|
-
this.#e = e.queryCache || new te(), this.#t = e.mutationCache || new ne(), this.#s = e.defaultOptions || {}, this.#i = /* @__PURE__ */ new Map(), this.#r = /* @__PURE__ */ new Map(), this.#n = 0;
|
|
446
|
-
}
|
|
447
|
-
mount() {
|
|
448
|
-
this.#n++, this.#n === 1 && (this.#a = G.subscribe(async (e) => {
|
|
449
|
-
e && (await this.resumePausedMutations(), this.#e.onFocus());
|
|
450
|
-
}), this.#u = D.subscribe(async (e) => {
|
|
451
|
-
e && (await this.resumePausedMutations(), this.#e.onOnline());
|
|
452
|
-
}));
|
|
453
|
-
}
|
|
454
|
-
unmount() {
|
|
455
|
-
this.#n--, this.#n === 0 && (this.#a?.(), this.#a = void 0, this.#u?.(), this.#u = void 0);
|
|
456
|
-
}
|
|
457
|
-
isFetching(e) {
|
|
458
|
-
return this.#e.findAll({ ...e, fetchStatus: "fetching" }).length;
|
|
459
|
-
}
|
|
460
|
-
isMutating(e) {
|
|
461
|
-
return this.#t.findAll({ ...e, status: "pending" }).length;
|
|
462
|
-
}
|
|
463
|
-
getQueryData(e) {
|
|
464
|
-
const t = this.defaultQueryOptions({ queryKey: e });
|
|
465
|
-
return this.#e.get(t.queryHash)?.state.data;
|
|
466
|
-
}
|
|
467
|
-
ensureQueryData(e) {
|
|
468
|
-
const t = this.defaultQueryOptions(e), s = this.#e.build(this, t), i = s.state.data;
|
|
469
|
-
return i === void 0 ? this.fetchQuery(e) : (e.revalidateIfStale && s.isStaleByTime(C(t.staleTime, s)) && this.prefetchQuery(t), Promise.resolve(i));
|
|
470
|
-
}
|
|
471
|
-
getQueriesData(e) {
|
|
472
|
-
return this.#e.findAll(e).map(({ queryKey: t, state: s }) => {
|
|
473
|
-
const i = s.data;
|
|
474
|
-
return [t, i];
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
setQueryData(e, t, s) {
|
|
478
|
-
const i = this.defaultQueryOptions({ queryKey: e }), r = this.#e.get(
|
|
479
|
-
i.queryHash
|
|
480
|
-
)?.state.data, d = L(t, r);
|
|
481
|
-
if (d !== void 0)
|
|
482
|
-
return this.#e.build(this, i).setData(d, { ...s, manual: !0 });
|
|
483
|
-
}
|
|
484
|
-
setQueriesData(e, t, s) {
|
|
485
|
-
return u.batch(
|
|
486
|
-
() => this.#e.findAll(e).map(({ queryKey: i }) => [
|
|
487
|
-
i,
|
|
488
|
-
this.setQueryData(i, t, s)
|
|
489
|
-
])
|
|
490
|
-
);
|
|
491
|
-
}
|
|
492
|
-
getQueryState(e) {
|
|
493
|
-
const t = this.defaultQueryOptions({ queryKey: e });
|
|
494
|
-
return this.#e.get(
|
|
495
|
-
t.queryHash
|
|
496
|
-
)?.state;
|
|
497
|
-
}
|
|
498
|
-
removeQueries(e) {
|
|
499
|
-
const t = this.#e;
|
|
500
|
-
u.batch(() => {
|
|
501
|
-
t.findAll(e).forEach((s) => {
|
|
502
|
-
t.remove(s);
|
|
503
|
-
});
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
resetQueries(e, t) {
|
|
507
|
-
const s = this.#e;
|
|
508
|
-
return u.batch(() => (s.findAll(e).forEach((i) => {
|
|
509
|
-
i.reset();
|
|
510
|
-
}), this.refetchQueries(
|
|
511
|
-
{
|
|
512
|
-
type: "active",
|
|
513
|
-
...e
|
|
514
|
-
},
|
|
515
|
-
t
|
|
516
|
-
)));
|
|
517
|
-
}
|
|
518
|
-
cancelQueries(e, t = {}) {
|
|
519
|
-
const s = { revert: !0, ...t }, i = u.batch(
|
|
520
|
-
() => this.#e.findAll(e).map((n) => n.cancel(s))
|
|
521
|
-
);
|
|
522
|
-
return Promise.all(i).then(h).catch(h);
|
|
523
|
-
}
|
|
524
|
-
invalidateQueries(e, t = {}) {
|
|
525
|
-
return u.batch(() => (this.#e.findAll(e).forEach((s) => {
|
|
526
|
-
s.invalidate();
|
|
527
|
-
}), e?.refetchType === "none" ? Promise.resolve() : this.refetchQueries(
|
|
528
|
-
{
|
|
529
|
-
...e,
|
|
530
|
-
type: e?.refetchType ?? e?.type ?? "active"
|
|
531
|
-
},
|
|
532
|
-
t
|
|
533
|
-
)));
|
|
534
|
-
}
|
|
535
|
-
refetchQueries(e, t = {}) {
|
|
536
|
-
const s = {
|
|
537
|
-
...t,
|
|
538
|
-
cancelRefetch: t.cancelRefetch ?? !0
|
|
539
|
-
}, i = u.batch(
|
|
540
|
-
() => this.#e.findAll(e).filter((n) => !n.isDisabled()).map((n) => {
|
|
541
|
-
let r = n.fetch(void 0, s);
|
|
542
|
-
return s.throwOnError || (r = r.catch(h)), n.state.fetchStatus === "paused" ? Promise.resolve() : r;
|
|
543
|
-
})
|
|
544
|
-
);
|
|
545
|
-
return Promise.all(i).then(h);
|
|
546
|
-
}
|
|
547
|
-
fetchQuery(e) {
|
|
548
|
-
const t = this.defaultQueryOptions(e);
|
|
549
|
-
t.retry === void 0 && (t.retry = !1);
|
|
550
|
-
const s = this.#e.build(this, t);
|
|
551
|
-
return s.isStaleByTime(
|
|
552
|
-
C(t.staleTime, s)
|
|
553
|
-
) ? s.fetch(t) : Promise.resolve(s.state.data);
|
|
554
|
-
}
|
|
555
|
-
prefetchQuery(e) {
|
|
556
|
-
return this.fetchQuery(e).then(h).catch(h);
|
|
557
|
-
}
|
|
558
|
-
fetchInfiniteQuery(e) {
|
|
559
|
-
return e.behavior = I(e.pages), this.fetchQuery(e);
|
|
560
|
-
}
|
|
561
|
-
prefetchInfiniteQuery(e) {
|
|
562
|
-
return this.fetchInfiniteQuery(e).then(h).catch(h);
|
|
563
|
-
}
|
|
564
|
-
ensureInfiniteQueryData(e) {
|
|
565
|
-
return e.behavior = I(e.pages), this.ensureQueryData(e);
|
|
566
|
-
}
|
|
567
|
-
resumePausedMutations() {
|
|
568
|
-
return D.isOnline() ? this.#t.resumePausedMutations() : Promise.resolve();
|
|
569
|
-
}
|
|
570
|
-
getQueryCache() {
|
|
571
|
-
return this.#e;
|
|
572
|
-
}
|
|
573
|
-
getMutationCache() {
|
|
574
|
-
return this.#t;
|
|
575
|
-
}
|
|
576
|
-
getDefaultOptions() {
|
|
577
|
-
return this.#s;
|
|
578
|
-
}
|
|
579
|
-
setDefaultOptions(e) {
|
|
580
|
-
this.#s = e;
|
|
581
|
-
}
|
|
582
|
-
setQueryDefaults(e, t) {
|
|
583
|
-
this.#i.set(q(e), {
|
|
584
|
-
queryKey: e,
|
|
585
|
-
defaultOptions: t
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
getQueryDefaults(e) {
|
|
589
|
-
const t = [...this.#i.values()], s = {};
|
|
590
|
-
return t.forEach((i) => {
|
|
591
|
-
R(e, i.queryKey) && Object.assign(s, i.defaultOptions);
|
|
592
|
-
}), s;
|
|
593
|
-
}
|
|
594
|
-
setMutationDefaults(e, t) {
|
|
595
|
-
this.#r.set(q(e), {
|
|
596
|
-
mutationKey: e,
|
|
597
|
-
defaultOptions: t
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
getMutationDefaults(e) {
|
|
601
|
-
const t = [...this.#r.values()], s = {};
|
|
602
|
-
return t.forEach((i) => {
|
|
603
|
-
R(e, i.mutationKey) && Object.assign(s, i.defaultOptions);
|
|
604
|
-
}), s;
|
|
605
|
-
}
|
|
606
|
-
defaultQueryOptions(e) {
|
|
607
|
-
if (e._defaulted)
|
|
608
|
-
return e;
|
|
609
|
-
const t = {
|
|
610
|
-
...this.#s.queries,
|
|
611
|
-
...this.getQueryDefaults(e.queryKey),
|
|
612
|
-
...e,
|
|
613
|
-
_defaulted: !0
|
|
614
|
-
};
|
|
615
|
-
return t.queryHash || (t.queryHash = k(
|
|
616
|
-
t.queryKey,
|
|
617
|
-
t
|
|
618
|
-
)), 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 === V && (t.enabled = !1), t;
|
|
619
|
-
}
|
|
620
|
-
defaultMutationOptions(e) {
|
|
621
|
-
return e?._defaulted ? e : {
|
|
622
|
-
...this.#s.mutations,
|
|
623
|
-
...e?.mutationKey && this.getMutationDefaults(e.mutationKey),
|
|
624
|
-
...e,
|
|
625
|
-
_defaulted: !0
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
clear() {
|
|
629
|
-
this.#e.clear(), this.#t.clear();
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
const ue = new ae({
|
|
633
|
-
defaultOptions: {
|
|
634
|
-
mutations: {
|
|
635
|
-
retry: !1
|
|
636
|
-
},
|
|
637
|
-
queries: {
|
|
638
|
-
refetchOnWindowFocus: !1,
|
|
639
|
-
gcTime: 1e3 * 60 * 60 * 24,
|
|
640
|
-
// 24 hours
|
|
641
|
-
staleTime: 60 * 1e3,
|
|
642
|
-
// 60 seconds
|
|
643
|
-
retry: !1
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
}), oe = () => {
|
|
647
|
-
const e = b((s) => s.currentNavigationPath), t = J();
|
|
648
|
-
M(() => {
|
|
649
|
-
e && t(e, { replace: !0 });
|
|
650
|
-
}, [e, t]);
|
|
651
|
-
}, he = () => (oe(), /* @__PURE__ */ y(Y, {})), we = ({
|
|
652
|
-
props: e,
|
|
653
|
-
routes: t,
|
|
654
|
-
env: s = void 0,
|
|
655
|
-
useSignalR: i = !1,
|
|
656
|
-
queryClient: n = ue
|
|
657
|
-
}) => {
|
|
658
|
-
const r = b((a) => a.setBaseProps), d = b((a) => a.modulePermissionToken), c = F((a) => a.setEnvironment), f = F((a) => a.addEnvironment), [P, p] = X(!1);
|
|
659
|
-
M(() => {
|
|
660
|
-
const a = de();
|
|
661
|
-
if (p(!a), a && c(a), !s) return;
|
|
662
|
-
const m = s[a?.ENVIRONMENT];
|
|
663
|
-
m && f(m);
|
|
664
|
-
}, [f, s, c]), M(() => {
|
|
665
|
-
p(!ce(e)), r(e);
|
|
666
|
-
}, [
|
|
667
|
-
e.currentLanguage,
|
|
668
|
-
e.currentLanguageId,
|
|
669
|
-
e.modulePermissionToken,
|
|
670
|
-
e.organizationId,
|
|
671
|
-
e.currentNavigationPath,
|
|
672
|
-
e.sourcePath
|
|
673
|
-
]);
|
|
674
|
-
const w = $([
|
|
675
|
-
{
|
|
676
|
-
path: e.basePath,
|
|
677
|
-
children: t,
|
|
678
|
-
element: /* @__PURE__ */ y(he, {})
|
|
679
|
-
}
|
|
680
|
-
]);
|
|
681
|
-
return P ? /* @__PURE__ */ y("div", { children: "TODO: Show fancy error" }) : d ? /* @__PURE__ */ y(W, { client: n, children: /* @__PURE__ */ y(ee, { enabled: i, children: /* @__PURE__ */ y(z, { router: w }) }) }) : /* @__PURE__ */ y("div", { children: "TODO: Show fancy Loadingspinner" });
|
|
682
|
-
}, ce = (e) => Z.every((t) => le(t, e)), le = (e, t) => {
|
|
683
|
-
if (!t[e]) {
|
|
684
|
-
if (t.throwError)
|
|
685
|
-
return t.throwError(`Missing required prop: ${e}`, 404), !1;
|
|
686
|
-
throw new Error(`Missing required prop: ${e}`);
|
|
687
|
-
}
|
|
688
|
-
return !0;
|
|
689
|
-
}, de = () => {
|
|
690
|
-
const e = window.__env__;
|
|
691
|
-
if (e && (e.API_PREFIX = "/api/v8.0", !!e.COMMON_API && e.MODULE_AUTH_API && e.API_PREFIX && e.ENVIRONMENT))
|
|
692
|
-
return e;
|
|
693
|
-
};
|
|
694
|
-
export {
|
|
695
|
-
we as M,
|
|
696
|
-
ie as g
|
|
697
|
-
};
|