@mobx-query/core 0.2.2 → 0.2.4
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/client/MQClient.d.ts +23 -0
- package/dist/client/MQClientAccessor.d.ts +12 -0
- package/dist/client/index.d.ts +5 -0
- package/{src/libs/mobx-query/client/types.ts → dist/client/types.d.ts} +31 -37
- package/dist/core.js +1830 -0
- package/dist/entity/Entity.d.ts +31 -0
- package/dist/entity/EntityCollection.d.ts +29 -0
- package/dist/entity/constants.d.ts +6 -0
- package/dist/entity/index.d.ts +6 -0
- package/{src/libs/mobx-query/entity/types.ts → dist/entity/types.d.ts} +8 -11
- package/dist/index.d.ts +6 -0
- package/dist/mutations/BatchMutationBase.d.ts +14 -0
- package/dist/mutations/BatchUpdateMutation.d.ts +9 -0
- package/dist/mutations/CreateMutation.d.ts +15 -0
- package/dist/mutations/DeleteMutation.d.ts +14 -0
- package/dist/mutations/EntityMutationBase.d.ts +22 -0
- package/dist/mutations/MutationBase.d.ts +13 -0
- package/dist/mutations/OptimisticMutationStrategy.d.ts +19 -0
- package/dist/mutations/UpdateMutation.d.ts +10 -0
- package/dist/mutations/constants.d.ts +12 -0
- package/dist/mutations/index.d.ts +11 -0
- package/dist/mutations/types.d.ts +55 -0
- package/dist/queries/QueryBase.d.ts +14 -0
- package/dist/queries/QueryFragmentMany.d.ts +9 -0
- package/dist/queries/QueryFragmentOne.d.ts +9 -0
- package/dist/queries/QueryMany.d.ts +11 -0
- package/dist/queries/QueryManyBase.d.ts +34 -0
- package/dist/queries/QueryOne.d.ts +11 -0
- package/dist/queries/QueryOneBase.d.ts +19 -0
- package/dist/queries/index.d.ts +10 -0
- package/dist/queries/types.d.ts +23 -0
- package/dist/react/createReactContext.d.ts +8 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/utils/generateEntityId.d.ts +2 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/invalidateQueryByHash.d.ts +2 -0
- package/dist/utils/types.d.ts +7 -0
- package/package.json +6 -1
- package/.gitattributes +0 -2
- package/eslint.config.js +0 -29
- package/index.html +0 -13
- package/src/App.css +0 -0
- package/src/App.tsx +0 -5
- package/src/api/constants.ts +0 -1
- package/src/api/fetch.ts +0 -29
- package/src/api/todos.ts +0 -14
- package/src/api/types.ts +0 -30
- package/src/api/users.ts +0 -19
- package/src/assets/react.svg +0 -1
- package/src/index.css +0 -60
- package/src/libs/mobx-query/client/MQClient.ts +0 -75
- package/src/libs/mobx-query/client/MQClientAccessor.ts +0 -74
- package/src/libs/mobx-query/client/index.ts +0 -8
- package/src/libs/mobx-query/entity/Entity.ts +0 -232
- package/src/libs/mobx-query/entity/EntityCollection.ts +0 -285
- package/src/libs/mobx-query/entity/constants.ts +0 -7
- package/src/libs/mobx-query/entity/index.ts +0 -15
- package/src/libs/mobx-query/index.ts +0 -6
- package/src/libs/mobx-query/mutations/BatchMutationBase.ts +0 -105
- package/src/libs/mobx-query/mutations/BatchUpdateMutation.ts +0 -48
- package/src/libs/mobx-query/mutations/CreateMutation.ts +0 -172
- package/src/libs/mobx-query/mutations/DeleteMutation.ts +0 -94
- package/src/libs/mobx-query/mutations/EntityMutationBase.ts +0 -110
- package/src/libs/mobx-query/mutations/MutationBase.ts +0 -40
- package/src/libs/mobx-query/mutations/OptimisticMutationStrategy.ts +0 -122
- package/src/libs/mobx-query/mutations/UpdateMutation.ts +0 -76
- package/src/libs/mobx-query/mutations/constants.ts +0 -16
- package/src/libs/mobx-query/mutations/index.ts +0 -44
- package/src/libs/mobx-query/mutations/types.ts +0 -205
- package/src/libs/mobx-query/queries/QueryBase.ts +0 -65
- package/src/libs/mobx-query/queries/QueryFragmentMany.ts +0 -31
- package/src/libs/mobx-query/queries/QueryFragmentOne.ts +0 -35
- package/src/libs/mobx-query/queries/QueryMany.ts +0 -80
- package/src/libs/mobx-query/queries/QueryManyBase.ts +0 -135
- package/src/libs/mobx-query/queries/QueryOne.ts +0 -84
- package/src/libs/mobx-query/queries/QueryOneBase.ts +0 -93
- package/src/libs/mobx-query/queries/index.ts +0 -33
- package/src/libs/mobx-query/queries/types.ts +0 -60
- package/src/libs/mobx-query/react/createReactContext.tsx +0 -23
- package/src/libs/mobx-query/react/index.ts +0 -3
- package/src/libs/mobx-query/utils/generateEntityId.ts +0 -12
- package/src/libs/mobx-query/utils/index.ts +0 -8
- package/src/libs/mobx-query/utils/invalidateQueryByHash.ts +0 -18
- package/src/libs/mobx-query/utils/types.ts +0 -18
- package/src/libs/react-query.ts +0 -11
- package/src/main.tsx +0 -16
- package/src/utils.ts +0 -3
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.app.json +0 -27
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -25
- package/vite.config.ts +0 -52
- /package/{public → dist}/vite.svg +0 -0
package/dist/core.js
ADDED
|
@@ -0,0 +1,1830 @@
|
|
|
1
|
+
var ae = Object.defineProperty;
|
|
2
|
+
var Mt = (n) => {
|
|
3
|
+
throw TypeError(n);
|
|
4
|
+
};
|
|
5
|
+
var ue = (n, t, e) => t in n ? ae(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
6
|
+
var V = (n, t, e) => ue(n, typeof t != "symbol" ? t + "" : t, e), Ct = (n, t, e) => t.has(n) || Mt("Cannot " + e);
|
|
7
|
+
var J = (n, t, e) => (Ct(n, t, "read from private field"), e ? e.call(n) : t.get(n)), X = (n, t, e) => t.has(n) ? Mt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), Z = (n, t, e, r) => (Ct(n, t, "write to private field"), r ? r.call(n, e) : t.set(n, e), e);
|
|
8
|
+
import { observe as ce, toJS as le, isObservableArray as ye, isObservableMap as he, observable as tt, action as z, computed as ht } from "mobx";
|
|
9
|
+
import { useMutation as vt, hashKey as ft, useIsFetching as fe, useQuery as Et, useSuspenseQuery as mt } from "@tanstack/react-query";
|
|
10
|
+
import de, { useDeferredValue as Gt, createContext as pe, useContext as me } from "react";
|
|
11
|
+
const It = /* @__PURE__ */ new Map(), ge = "entityClientOnlyId";
|
|
12
|
+
function Ve(n) {
|
|
13
|
+
const t = (It.get(n.name) ?? 0) + 1;
|
|
14
|
+
return It.set(n.name, t), `${ge}_${n.name}_${t}`;
|
|
15
|
+
}
|
|
16
|
+
function bt(n, t, e) {
|
|
17
|
+
const r = t.get(n);
|
|
18
|
+
r ? (r.invalidate(), r.isActive() && r.fetch()) : e?.(n);
|
|
19
|
+
}
|
|
20
|
+
const pt = {
|
|
21
|
+
PENDING: "pending",
|
|
22
|
+
CONFIRMED: "confirmed",
|
|
23
|
+
FAILED: "failed"
|
|
24
|
+
};
|
|
25
|
+
let ve, xt, wt;
|
|
26
|
+
function Ee(n, t, e, r, i, h) {
|
|
27
|
+
function b(a, y, f) {
|
|
28
|
+
return function(c, l) {
|
|
29
|
+
return f && f(c), a[y].call(c, l);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function B(a, y) {
|
|
33
|
+
for (var f = 0; f < a.length; f++) a[f].call(y);
|
|
34
|
+
return y;
|
|
35
|
+
}
|
|
36
|
+
function Q(a, y, f, c) {
|
|
37
|
+
if (typeof a != "function" && (c || a !== void 0)) throw new TypeError(y + " must " + (f || "be") + " a function" + (c ? "" : " or undefined"));
|
|
38
|
+
return a;
|
|
39
|
+
}
|
|
40
|
+
function Y(a, y, f, c, l, A, D, j, N, O, E, g, v) {
|
|
41
|
+
function T(u) {
|
|
42
|
+
if (!v(u)) throw new TypeError("Attempted to access private element on non-instance");
|
|
43
|
+
}
|
|
44
|
+
var d, M = y[0], R = y[3], w = !j;
|
|
45
|
+
if (!w) {
|
|
46
|
+
f || Array.isArray(M) || (M = [M]);
|
|
47
|
+
var s = {}, q = [], m = l === 3 ? "get" : l === 4 || g ? "set" : "value";
|
|
48
|
+
O ? (E || g ? s = { get: Qt(function() {
|
|
49
|
+
return R(this);
|
|
50
|
+
}, c, "get"), set: function(u) {
|
|
51
|
+
y[4](this, u);
|
|
52
|
+
} } : s[m] = R, E || Qt(s[m], c, l === 2 ? "" : m)) : E || (s = Object.getOwnPropertyDescriptor(a, c));
|
|
53
|
+
}
|
|
54
|
+
for (var p = a, o = M.length - 1; o >= 0; o -= f ? 2 : 1) {
|
|
55
|
+
var _ = M[o], I = f ? M[o - 1] : void 0, F = {}, x = { kind: ["field", "accessor", "method", "getter", "setter", "class"][l], name: c, metadata: A, addInitializer: (function(u, S) {
|
|
56
|
+
if (u.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
57
|
+
Q(S, "An initializer", "be", !0), D.push(S);
|
|
58
|
+
}).bind(null, F) };
|
|
59
|
+
try {
|
|
60
|
+
if (w) (d = Q(_.call(I, p, x), "class decorators", "return")) && (p = d);
|
|
61
|
+
else {
|
|
62
|
+
var C, k;
|
|
63
|
+
x.static = N, x.private = O, O ? l === 2 ? C = function(u) {
|
|
64
|
+
return T(u), s.value;
|
|
65
|
+
} : (l < 4 && (C = b(s, "get", T)), l !== 3 && (k = b(s, "set", T))) : (C = function(u) {
|
|
66
|
+
return u[c];
|
|
67
|
+
}, (l < 2 || l === 4) && (k = function(u, S) {
|
|
68
|
+
u[c] = S;
|
|
69
|
+
}));
|
|
70
|
+
var $ = x.access = { has: O ? v.bind() : function(u) {
|
|
71
|
+
return c in u;
|
|
72
|
+
} };
|
|
73
|
+
if (C && ($.get = C), k && ($.set = k), p = _.call(I, g ? { get: s.get, set: s.set } : s[m], x), g) {
|
|
74
|
+
if (typeof p == "object" && p) (d = Q(p.get, "accessor.get")) && (s.get = d), (d = Q(p.set, "accessor.set")) && (s.set = d), (d = Q(p.init, "accessor.init")) && q.push(d);
|
|
75
|
+
else if (p !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
76
|
+
} else Q(p, (E ? "field" : "method") + " decorators", "return") && (E ? q.push(p) : s[m] = p);
|
|
77
|
+
}
|
|
78
|
+
} finally {
|
|
79
|
+
F.v = !0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return (E || g) && j.push(function(u, S) {
|
|
83
|
+
for (var P = q.length - 1; P >= 0; P--) S = q[P].call(u, S);
|
|
84
|
+
return S;
|
|
85
|
+
}), E || w || (O ? g ? j.push(b(s, "get"), b(s, "set")) : j.push(l === 2 ? s[m] : b.call.bind(s[m])) : Object.defineProperty(a, c, s)), p;
|
|
86
|
+
}
|
|
87
|
+
function L(a, y) {
|
|
88
|
+
return Object.defineProperty(a, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: y });
|
|
89
|
+
}
|
|
90
|
+
if (arguments.length >= 6) var H = h[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
91
|
+
var K = Object.create(H ?? null), U = (function(a, y, f, c) {
|
|
92
|
+
var l, A, D = [], j = function(m) {
|
|
93
|
+
return Se(m) === a;
|
|
94
|
+
}, N = /* @__PURE__ */ new Map();
|
|
95
|
+
function O(m) {
|
|
96
|
+
m && D.push(B.bind(null, m));
|
|
97
|
+
}
|
|
98
|
+
for (var E = 0; E < y.length; E++) {
|
|
99
|
+
var g = y[E];
|
|
100
|
+
if (Array.isArray(g)) {
|
|
101
|
+
var v = g[1], T = g[2], d = g.length > 3, M = 16 & v, R = !!(8 & v), w = (v &= 7) == 0, s = T + "/" + R;
|
|
102
|
+
if (!w && !d) {
|
|
103
|
+
var q = N.get(s);
|
|
104
|
+
if (q === !0 || q === 3 && v !== 4 || q === 4 && v !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + T);
|
|
105
|
+
N.set(s, !(v > 2) || v);
|
|
106
|
+
}
|
|
107
|
+
Y(R ? a : a.prototype, g, M, d ? "#" + T : be(T), v, c, R ? A = A || [] : l = l || [], D, R, d, w, v === 1, R && d ? j : f);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return O(l), O(A), D;
|
|
111
|
+
})(n, t, i, K);
|
|
112
|
+
return e.length || L(n, K), { e: U, get c() {
|
|
113
|
+
var a = [];
|
|
114
|
+
return e.length && [L(Y(n, [e], r, n.name, 5, K, a), K), B.bind(null, a, n)];
|
|
115
|
+
} };
|
|
116
|
+
}
|
|
117
|
+
function be(n) {
|
|
118
|
+
var t = _e(n, "string");
|
|
119
|
+
return typeof t == "symbol" ? t : t + "";
|
|
120
|
+
}
|
|
121
|
+
function _e(n, t) {
|
|
122
|
+
if (typeof n != "object" || !n) return n;
|
|
123
|
+
var e = n[Symbol.toPrimitive];
|
|
124
|
+
if (e !== void 0) {
|
|
125
|
+
var r = e.call(n, t);
|
|
126
|
+
if (typeof r != "object") return r;
|
|
127
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
128
|
+
}
|
|
129
|
+
return String(n);
|
|
130
|
+
}
|
|
131
|
+
function Qt(n, t, e) {
|
|
132
|
+
typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
|
|
133
|
+
try {
|
|
134
|
+
Object.defineProperty(n, "name", { configurable: !0, value: e ? e + " " + t : t });
|
|
135
|
+
} catch {
|
|
136
|
+
}
|
|
137
|
+
return n;
|
|
138
|
+
}
|
|
139
|
+
function Se(n) {
|
|
140
|
+
if (Object(n) !== n) throw TypeError("right-hand side of 'in' should be an object, got " + (n !== null ? typeof n : "null"));
|
|
141
|
+
return n;
|
|
142
|
+
}
|
|
143
|
+
const Te = ["isDirty", "state"];
|
|
144
|
+
var at, ut;
|
|
145
|
+
const Rt = class Rt extends et {
|
|
146
|
+
constructor() {
|
|
147
|
+
super(...arguments);
|
|
148
|
+
V(this, "queryHashes", /* @__PURE__ */ new Set());
|
|
149
|
+
V(this, "events");
|
|
150
|
+
X(this, at, xt(this, pt.CONFIRMED));
|
|
151
|
+
X(this, ut, wt(this, !1));
|
|
152
|
+
V(this, "initValuesSnapshot", /* @__PURE__ */ new Map());
|
|
153
|
+
V(this, "isHydrated", !1);
|
|
154
|
+
}
|
|
155
|
+
get state() {
|
|
156
|
+
return J(this, at);
|
|
157
|
+
}
|
|
158
|
+
set state(e) {
|
|
159
|
+
Z(this, at, e);
|
|
160
|
+
}
|
|
161
|
+
get isDirty() {
|
|
162
|
+
return J(this, ut);
|
|
163
|
+
}
|
|
164
|
+
set isDirty(e) {
|
|
165
|
+
Z(this, ut, e);
|
|
166
|
+
}
|
|
167
|
+
_init(e, r) {
|
|
168
|
+
this.events = r;
|
|
169
|
+
for (const i of e)
|
|
170
|
+
this.queryHashes.add(i);
|
|
171
|
+
ce(this, (i) => this.onObservableChange(i));
|
|
172
|
+
}
|
|
173
|
+
// @computed get isDirty() {
|
|
174
|
+
// return this._isDirty
|
|
175
|
+
// }
|
|
176
|
+
_removeQueryHashes(e) {
|
|
177
|
+
for (const r of e)
|
|
178
|
+
this.queryHashes.delete(r);
|
|
179
|
+
this.queryHashes.size === 0 && this.events.onAllQueryHashesRemoved(this.id);
|
|
180
|
+
}
|
|
181
|
+
_markAsHydrated() {
|
|
182
|
+
this.isHydrated = !0;
|
|
183
|
+
}
|
|
184
|
+
onObservableChange(e) {
|
|
185
|
+
e.type === "update" && this.isHydrated && (Te.includes(e.name) || (this.initValuesSnapshot.has(e.name) || this.initValuesSnapshot.set(e.name, this.deepCloneValue(e.oldValue)), this.isDirty === !1 && (this.isDirty = !0)));
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Deep clones a value to ensure we store a snapshot, not a reference.
|
|
189
|
+
* Handles primitives, objects, arrays, and MobX observables.
|
|
190
|
+
*/
|
|
191
|
+
deepCloneValue(e) {
|
|
192
|
+
if (e == null)
|
|
193
|
+
return e;
|
|
194
|
+
const r = typeof e;
|
|
195
|
+
if (r === "string" || r === "number" || r === "boolean" || r === "symbol" || r === "bigint" || r === "function")
|
|
196
|
+
return e;
|
|
197
|
+
if (e instanceof Date)
|
|
198
|
+
return new Date(e.getTime());
|
|
199
|
+
if (e instanceof RegExp)
|
|
200
|
+
return new RegExp(e);
|
|
201
|
+
if (e instanceof Set)
|
|
202
|
+
return new Set(Array.from(e).map((i) => this.deepCloneValue(i)));
|
|
203
|
+
if (e instanceof Map) {
|
|
204
|
+
const i = /* @__PURE__ */ new Map();
|
|
205
|
+
for (const [h, b] of e.entries())
|
|
206
|
+
i.set(this.deepCloneValue(h), this.deepCloneValue(b));
|
|
207
|
+
return i;
|
|
208
|
+
}
|
|
209
|
+
try {
|
|
210
|
+
return le(e);
|
|
211
|
+
} catch (i) {
|
|
212
|
+
return console.warn("Failed to deep clone value for property, using reference:", i), e;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
reset() {
|
|
216
|
+
for (const [e, r] of this.initValuesSnapshot.entries()) {
|
|
217
|
+
const i = this.deepCloneValue(r), h = this[e];
|
|
218
|
+
ye(h) ? h.replace(i) : he(h) ? (h.clear(), h.merge(i)) : this[e] = i;
|
|
219
|
+
}
|
|
220
|
+
this._clearDirty();
|
|
221
|
+
}
|
|
222
|
+
_clearDirty() {
|
|
223
|
+
this.isDirty = !1, this.initValuesSnapshot.clear();
|
|
224
|
+
}
|
|
225
|
+
// isDirtyField(field: EntityValueKeys<this>) {
|
|
226
|
+
// return this.initValuesSnapshot.has(field)
|
|
227
|
+
// }
|
|
228
|
+
// getOriginalValue<K extends EntityValueKeys<this>>(
|
|
229
|
+
// field: K,
|
|
230
|
+
// ): this[K] | undefined {
|
|
231
|
+
// return this.initValuesSnapshot.get(field) as this[K] | undefined
|
|
232
|
+
// }
|
|
233
|
+
invalidateRelatedQueries() {
|
|
234
|
+
const e = this.queryClient.getQueryCache();
|
|
235
|
+
for (const r of this.queryHashes)
|
|
236
|
+
bt(r, e, () => this._removeQueryHashes([r]));
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
at = new WeakMap(), ut = new WeakMap(), [xt, wt, ve] = Ee(Rt, [[tt, 1, "state"], [tt, 1, "isDirty"], [z, 2, "onObservableChange"], [z, 2, "reset"], [z, 2, "_clearDirty"]], [], 0, void 0, et).e;
|
|
240
|
+
let jt = Rt, At, Dt, Ft, Kt;
|
|
241
|
+
function Re(n, t, e, r, i, h) {
|
|
242
|
+
function b(a, y, f) {
|
|
243
|
+
return function(c, l) {
|
|
244
|
+
return f && f(c), a[y].call(c, l);
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function B(a, y) {
|
|
248
|
+
for (var f = 0; f < a.length; f++) a[f].call(y);
|
|
249
|
+
return y;
|
|
250
|
+
}
|
|
251
|
+
function Q(a, y, f, c) {
|
|
252
|
+
if (typeof a != "function" && (c || a !== void 0)) throw new TypeError(y + " must " + (f || "be") + " a function" + (c ? "" : " or undefined"));
|
|
253
|
+
return a;
|
|
254
|
+
}
|
|
255
|
+
function Y(a, y, f, c, l, A, D, j, N, O, E, g, v) {
|
|
256
|
+
function T(u) {
|
|
257
|
+
if (!v(u)) throw new TypeError("Attempted to access private element on non-instance");
|
|
258
|
+
}
|
|
259
|
+
var d, M = y[0], R = y[3], w = !j;
|
|
260
|
+
if (!w) {
|
|
261
|
+
f || Array.isArray(M) || (M = [M]);
|
|
262
|
+
var s = {}, q = [], m = l === 3 ? "get" : l === 4 || g ? "set" : "value";
|
|
263
|
+
O ? (E || g ? s = { get: kt(function() {
|
|
264
|
+
return R(this);
|
|
265
|
+
}, c, "get"), set: function(u) {
|
|
266
|
+
y[4](this, u);
|
|
267
|
+
} } : s[m] = R, E || kt(s[m], c, l === 2 ? "" : m)) : E || (s = Object.getOwnPropertyDescriptor(a, c));
|
|
268
|
+
}
|
|
269
|
+
for (var p = a, o = M.length - 1; o >= 0; o -= f ? 2 : 1) {
|
|
270
|
+
var _ = M[o], I = f ? M[o - 1] : void 0, F = {}, x = { kind: ["field", "accessor", "method", "getter", "setter", "class"][l], name: c, metadata: A, addInitializer: (function(u, S) {
|
|
271
|
+
if (u.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
272
|
+
Q(S, "An initializer", "be", !0), D.push(S);
|
|
273
|
+
}).bind(null, F) };
|
|
274
|
+
try {
|
|
275
|
+
if (w) (d = Q(_.call(I, p, x), "class decorators", "return")) && (p = d);
|
|
276
|
+
else {
|
|
277
|
+
var C, k;
|
|
278
|
+
x.static = N, x.private = O, O ? l === 2 ? C = function(u) {
|
|
279
|
+
return T(u), s.value;
|
|
280
|
+
} : (l < 4 && (C = b(s, "get", T)), l !== 3 && (k = b(s, "set", T))) : (C = function(u) {
|
|
281
|
+
return u[c];
|
|
282
|
+
}, (l < 2 || l === 4) && (k = function(u, S) {
|
|
283
|
+
u[c] = S;
|
|
284
|
+
}));
|
|
285
|
+
var $ = x.access = { has: O ? v.bind() : function(u) {
|
|
286
|
+
return c in u;
|
|
287
|
+
} };
|
|
288
|
+
if (C && ($.get = C), k && ($.set = k), p = _.call(I, g ? { get: s.get, set: s.set } : s[m], x), g) {
|
|
289
|
+
if (typeof p == "object" && p) (d = Q(p.get, "accessor.get")) && (s.get = d), (d = Q(p.set, "accessor.set")) && (s.set = d), (d = Q(p.init, "accessor.init")) && q.push(d);
|
|
290
|
+
else if (p !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
291
|
+
} else Q(p, (E ? "field" : "method") + " decorators", "return") && (E ? q.push(p) : s[m] = p);
|
|
292
|
+
}
|
|
293
|
+
} finally {
|
|
294
|
+
F.v = !0;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return (E || g) && j.push(function(u, S) {
|
|
298
|
+
for (var P = q.length - 1; P >= 0; P--) S = q[P].call(u, S);
|
|
299
|
+
return S;
|
|
300
|
+
}), E || w || (O ? g ? j.push(b(s, "get"), b(s, "set")) : j.push(l === 2 ? s[m] : b.call.bind(s[m])) : Object.defineProperty(a, c, s)), p;
|
|
301
|
+
}
|
|
302
|
+
function L(a, y) {
|
|
303
|
+
return Object.defineProperty(a, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: y });
|
|
304
|
+
}
|
|
305
|
+
if (arguments.length >= 6) var H = h[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
306
|
+
var K = Object.create(H ?? null), U = (function(a, y, f, c) {
|
|
307
|
+
var l, A, D = [], j = function(m) {
|
|
308
|
+
return Me(m) === a;
|
|
309
|
+
}, N = /* @__PURE__ */ new Map();
|
|
310
|
+
function O(m) {
|
|
311
|
+
m && D.push(B.bind(null, m));
|
|
312
|
+
}
|
|
313
|
+
for (var E = 0; E < y.length; E++) {
|
|
314
|
+
var g = y[E];
|
|
315
|
+
if (Array.isArray(g)) {
|
|
316
|
+
var v = g[1], T = g[2], d = g.length > 3, M = 16 & v, R = !!(8 & v), w = (v &= 7) == 0, s = T + "/" + R;
|
|
317
|
+
if (!w && !d) {
|
|
318
|
+
var q = N.get(s);
|
|
319
|
+
if (q === !0 || q === 3 && v !== 4 || q === 4 && v !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + T);
|
|
320
|
+
N.set(s, !(v > 2) || v);
|
|
321
|
+
}
|
|
322
|
+
Y(R ? a : a.prototype, g, M, d ? "#" + T : qe(T), v, c, R ? A = A || [] : l = l || [], D, R, d, w, v === 1, R && d ? j : f);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return O(l), O(A), D;
|
|
326
|
+
})(n, t, i, K);
|
|
327
|
+
return e.length || L(n, K), { e: U, get c() {
|
|
328
|
+
var a = [];
|
|
329
|
+
return e.length && [L(Y(n, [e], r, n.name, 5, K, a), K), B.bind(null, a, n)];
|
|
330
|
+
} };
|
|
331
|
+
}
|
|
332
|
+
function qe(n) {
|
|
333
|
+
var t = Oe(n, "string");
|
|
334
|
+
return typeof t == "symbol" ? t : t + "";
|
|
335
|
+
}
|
|
336
|
+
function Oe(n, t) {
|
|
337
|
+
if (typeof n != "object" || !n) return n;
|
|
338
|
+
var e = n[Symbol.toPrimitive];
|
|
339
|
+
if (e !== void 0) {
|
|
340
|
+
var r = e.call(n, t);
|
|
341
|
+
if (typeof r != "object") return r;
|
|
342
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
343
|
+
}
|
|
344
|
+
return String(n);
|
|
345
|
+
}
|
|
346
|
+
function kt(n, t, e) {
|
|
347
|
+
typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
|
|
348
|
+
try {
|
|
349
|
+
Object.defineProperty(n, "name", { configurable: !0, value: e ? e + " " + t : t });
|
|
350
|
+
} catch {
|
|
351
|
+
}
|
|
352
|
+
return n;
|
|
353
|
+
}
|
|
354
|
+
function Me(n) {
|
|
355
|
+
if (Object(n) !== n) throw TypeError("right-hand side of 'in' should be an object, got " + (n !== null ? typeof n : "null"));
|
|
356
|
+
return n;
|
|
357
|
+
}
|
|
358
|
+
var ct, lt, yt;
|
|
359
|
+
const qt = class qt {
|
|
360
|
+
constructor(t, e) {
|
|
361
|
+
X(this, ct, (At(this), Dt(this, /* @__PURE__ */ new Map())));
|
|
362
|
+
X(this, lt, Ft(this, /* @__PURE__ */ new Set()));
|
|
363
|
+
X(this, yt, Kt(this, /* @__PURE__ */ new Set()));
|
|
364
|
+
this.entityConstructor = t, this.queryClient = e, this.initQueryClientCacheListener();
|
|
365
|
+
}
|
|
366
|
+
get collection() {
|
|
367
|
+
return J(this, ct);
|
|
368
|
+
}
|
|
369
|
+
set collection(t) {
|
|
370
|
+
Z(this, ct, t);
|
|
371
|
+
}
|
|
372
|
+
get deletedRecordIds() {
|
|
373
|
+
return J(this, lt);
|
|
374
|
+
}
|
|
375
|
+
set deletedRecordIds(t) {
|
|
376
|
+
Z(this, lt, t);
|
|
377
|
+
}
|
|
378
|
+
get clientOnlyEntityIds() {
|
|
379
|
+
return J(this, yt);
|
|
380
|
+
}
|
|
381
|
+
set clientOnlyEntityIds(t) {
|
|
382
|
+
Z(this, yt, t);
|
|
383
|
+
}
|
|
384
|
+
get size() {
|
|
385
|
+
return this.collection.size;
|
|
386
|
+
}
|
|
387
|
+
get entities() {
|
|
388
|
+
const t = [];
|
|
389
|
+
for (const e of this.collection.values())
|
|
390
|
+
this.deletedRecordIds.has(e.id) || t.push(e);
|
|
391
|
+
return t;
|
|
392
|
+
}
|
|
393
|
+
get clientOnlyEntitiesMap() {
|
|
394
|
+
const t = /* @__PURE__ */ new Map();
|
|
395
|
+
for (const e of this.clientOnlyEntityIds.values()) {
|
|
396
|
+
const r = this.collection.get(e);
|
|
397
|
+
r && t.set(e, r);
|
|
398
|
+
}
|
|
399
|
+
return t;
|
|
400
|
+
}
|
|
401
|
+
get clientOnlyEntities() {
|
|
402
|
+
const t = [];
|
|
403
|
+
for (const e of this.clientOnlyEntityIds.values()) {
|
|
404
|
+
const r = this.collection.get(e);
|
|
405
|
+
r && t.push(r);
|
|
406
|
+
}
|
|
407
|
+
return t;
|
|
408
|
+
}
|
|
409
|
+
setEntity(t, e) {
|
|
410
|
+
const r = new this.entityConstructor();
|
|
411
|
+
r.hydrate(t), r._markAsHydrated();
|
|
412
|
+
const i = this.collection.get(r.id), h = i ? [...i.queryHashes, ...e || []] : [...e || []];
|
|
413
|
+
if (i) {
|
|
414
|
+
if (e)
|
|
415
|
+
for (const b of e)
|
|
416
|
+
i.queryHashes.add(b);
|
|
417
|
+
return i.hydrate(t), i._clearDirty(), i;
|
|
418
|
+
}
|
|
419
|
+
return r._init(h, {
|
|
420
|
+
onAllQueryHashesRemoved: (b) => this.deleteEntity(b)
|
|
421
|
+
}), this.collection.set(r.id, r), r;
|
|
422
|
+
}
|
|
423
|
+
setEntities(t, e) {
|
|
424
|
+
const r = [], i = [];
|
|
425
|
+
if (!Array.isArray(t))
|
|
426
|
+
throw new Error("setEntities: entityData must be an array");
|
|
427
|
+
e && this.removeQueryHashesFromAllEntities(e);
|
|
428
|
+
for (const h of t) {
|
|
429
|
+
const b = this.setEntity(h, e);
|
|
430
|
+
r.push(b), i.push(b.id);
|
|
431
|
+
}
|
|
432
|
+
return [r, i];
|
|
433
|
+
}
|
|
434
|
+
deleteEntity(t) {
|
|
435
|
+
this.collection.delete(t), this.clientOnlyEntityIds.delete(t), this.deletedRecordIds.delete(t);
|
|
436
|
+
}
|
|
437
|
+
getEntityById(t) {
|
|
438
|
+
return this.collection.get(t);
|
|
439
|
+
}
|
|
440
|
+
filter(t) {
|
|
441
|
+
const e = [];
|
|
442
|
+
let r = 0;
|
|
443
|
+
for (const i of this.collection.values())
|
|
444
|
+
this.deletedRecordIds.has(i.id) || t(i, r++) && e.push(i);
|
|
445
|
+
return e;
|
|
446
|
+
}
|
|
447
|
+
find(t) {
|
|
448
|
+
let e = 0;
|
|
449
|
+
for (const r of this.collection.values())
|
|
450
|
+
if (!this.deletedRecordIds.has(r.id) && t(r, e++))
|
|
451
|
+
return r;
|
|
452
|
+
}
|
|
453
|
+
findIndex(t) {
|
|
454
|
+
let e = 0;
|
|
455
|
+
for (const r of this.collection.values())
|
|
456
|
+
if (!this.deletedRecordIds.has(r.id)) {
|
|
457
|
+
if (t(r, e))
|
|
458
|
+
return e;
|
|
459
|
+
e++;
|
|
460
|
+
}
|
|
461
|
+
return -1;
|
|
462
|
+
}
|
|
463
|
+
findLast(t) {
|
|
464
|
+
const e = this.entities;
|
|
465
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
466
|
+
const i = e[r];
|
|
467
|
+
if (t(i, r))
|
|
468
|
+
return i;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
findLastIndex(t) {
|
|
472
|
+
const e = this.entities;
|
|
473
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
474
|
+
const i = e[r];
|
|
475
|
+
if (t(i, r))
|
|
476
|
+
return r;
|
|
477
|
+
}
|
|
478
|
+
return -1;
|
|
479
|
+
}
|
|
480
|
+
some(t) {
|
|
481
|
+
let e = 0;
|
|
482
|
+
for (const r of this.collection.values())
|
|
483
|
+
if (!this.deletedRecordIds.has(r.id) && t(r, e++))
|
|
484
|
+
return !0;
|
|
485
|
+
return !1;
|
|
486
|
+
}
|
|
487
|
+
every(t) {
|
|
488
|
+
let e = 0;
|
|
489
|
+
for (const r of this.collection.values())
|
|
490
|
+
if (!this.deletedRecordIds.has(r.id) && !t(r, e++))
|
|
491
|
+
return !1;
|
|
492
|
+
return !0;
|
|
493
|
+
}
|
|
494
|
+
map(t) {
|
|
495
|
+
const e = [];
|
|
496
|
+
let r = 0;
|
|
497
|
+
for (const i of this.collection.values())
|
|
498
|
+
this.deletedRecordIds.has(i.id) || e.push(t(i, r++));
|
|
499
|
+
return tt.array(e);
|
|
500
|
+
}
|
|
501
|
+
initQueryClientCacheListener() {
|
|
502
|
+
this.queryClient.getQueryCache().subscribe((t) => {
|
|
503
|
+
t.type === "removed" && this.removeQueryHashesFromAllEntities([t.query.queryHash]);
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
removeQueryHashesFromAllEntities(t) {
|
|
507
|
+
for (const e of this.collection.values())
|
|
508
|
+
e._removeQueryHashes(t);
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
ct = new WeakMap(), lt = new WeakMap(), yt = new WeakMap(), [Dt, Ft, Kt, At] = Re(qt, [[tt, 1, "collection"], [tt, 1, "deletedRecordIds"], [tt, 1, "clientOnlyEntityIds"], [ht, 3, "size"], [ht, 3, "entities"], [ht, 3, "clientOnlyEntitiesMap"], [ht, 3, "clientOnlyEntities"], [z, 2, "setEntity"], [z, 2, "setEntities"], [z, 2, "deleteEntity"]], []).e;
|
|
512
|
+
let _t = qt;
|
|
513
|
+
const G = {
|
|
514
|
+
ALL_QUERIES: "all-queries",
|
|
515
|
+
ALL_ENTITY_QUERIES: "all-entity-queries",
|
|
516
|
+
REFERENCED_QUERIES: "referenced-queries",
|
|
517
|
+
NONE: "none"
|
|
518
|
+
}, st = {
|
|
519
|
+
ROLLBACK: "rollback",
|
|
520
|
+
KEEP: "keep"
|
|
521
|
+
};
|
|
522
|
+
let Nt;
|
|
523
|
+
function Ce(n, t, e, r, i, h) {
|
|
524
|
+
function b(a, y, f) {
|
|
525
|
+
return function(c, l) {
|
|
526
|
+
return f && f(c), a[y].call(c, l);
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
function B(a, y) {
|
|
530
|
+
for (var f = 0; f < a.length; f++) a[f].call(y);
|
|
531
|
+
return y;
|
|
532
|
+
}
|
|
533
|
+
function Q(a, y, f, c) {
|
|
534
|
+
if (typeof a != "function" && (c || a !== void 0)) throw new TypeError(y + " must " + (f || "be") + " a function" + (c ? "" : " or undefined"));
|
|
535
|
+
return a;
|
|
536
|
+
}
|
|
537
|
+
function Y(a, y, f, c, l, A, D, j, N, O, E, g, v) {
|
|
538
|
+
function T(u) {
|
|
539
|
+
if (!v(u)) throw new TypeError("Attempted to access private element on non-instance");
|
|
540
|
+
}
|
|
541
|
+
var d, M = y[0], R = y[3], w = !j;
|
|
542
|
+
if (!w) {
|
|
543
|
+
f || Array.isArray(M) || (M = [M]);
|
|
544
|
+
var s = {}, q = [], m = l === 3 ? "get" : l === 4 || g ? "set" : "value";
|
|
545
|
+
O ? (E || g ? s = { get: Pt(function() {
|
|
546
|
+
return R(this);
|
|
547
|
+
}, c, "get"), set: function(u) {
|
|
548
|
+
y[4](this, u);
|
|
549
|
+
} } : s[m] = R, E || Pt(s[m], c, l === 2 ? "" : m)) : E || (s = Object.getOwnPropertyDescriptor(a, c));
|
|
550
|
+
}
|
|
551
|
+
for (var p = a, o = M.length - 1; o >= 0; o -= f ? 2 : 1) {
|
|
552
|
+
var _ = M[o], I = f ? M[o - 1] : void 0, F = {}, x = { kind: ["field", "accessor", "method", "getter", "setter", "class"][l], name: c, metadata: A, addInitializer: (function(u, S) {
|
|
553
|
+
if (u.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
554
|
+
Q(S, "An initializer", "be", !0), D.push(S);
|
|
555
|
+
}).bind(null, F) };
|
|
556
|
+
try {
|
|
557
|
+
if (w) (d = Q(_.call(I, p, x), "class decorators", "return")) && (p = d);
|
|
558
|
+
else {
|
|
559
|
+
var C, k;
|
|
560
|
+
x.static = N, x.private = O, O ? l === 2 ? C = function(u) {
|
|
561
|
+
return T(u), s.value;
|
|
562
|
+
} : (l < 4 && (C = b(s, "get", T)), l !== 3 && (k = b(s, "set", T))) : (C = function(u) {
|
|
563
|
+
return u[c];
|
|
564
|
+
}, (l < 2 || l === 4) && (k = function(u, S) {
|
|
565
|
+
u[c] = S;
|
|
566
|
+
}));
|
|
567
|
+
var $ = x.access = { has: O ? v.bind() : function(u) {
|
|
568
|
+
return c in u;
|
|
569
|
+
} };
|
|
570
|
+
if (C && ($.get = C), k && ($.set = k), p = _.call(I, g ? { get: s.get, set: s.set } : s[m], x), g) {
|
|
571
|
+
if (typeof p == "object" && p) (d = Q(p.get, "accessor.get")) && (s.get = d), (d = Q(p.set, "accessor.set")) && (s.set = d), (d = Q(p.init, "accessor.init")) && q.push(d);
|
|
572
|
+
else if (p !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
573
|
+
} else Q(p, (E ? "field" : "method") + " decorators", "return") && (E ? q.push(p) : s[m] = p);
|
|
574
|
+
}
|
|
575
|
+
} finally {
|
|
576
|
+
F.v = !0;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return (E || g) && j.push(function(u, S) {
|
|
580
|
+
for (var P = q.length - 1; P >= 0; P--) S = q[P].call(u, S);
|
|
581
|
+
return S;
|
|
582
|
+
}), E || w || (O ? g ? j.push(b(s, "get"), b(s, "set")) : j.push(l === 2 ? s[m] : b.call.bind(s[m])) : Object.defineProperty(a, c, s)), p;
|
|
583
|
+
}
|
|
584
|
+
function L(a, y) {
|
|
585
|
+
return Object.defineProperty(a, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: y });
|
|
586
|
+
}
|
|
587
|
+
if (arguments.length >= 6) var H = h[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
588
|
+
var K = Object.create(H ?? null), U = (function(a, y, f, c) {
|
|
589
|
+
var l, A, D = [], j = function(m) {
|
|
590
|
+
return we(m) === a;
|
|
591
|
+
}, N = /* @__PURE__ */ new Map();
|
|
592
|
+
function O(m) {
|
|
593
|
+
m && D.push(B.bind(null, m));
|
|
594
|
+
}
|
|
595
|
+
for (var E = 0; E < y.length; E++) {
|
|
596
|
+
var g = y[E];
|
|
597
|
+
if (Array.isArray(g)) {
|
|
598
|
+
var v = g[1], T = g[2], d = g.length > 3, M = 16 & v, R = !!(8 & v), w = (v &= 7) == 0, s = T + "/" + R;
|
|
599
|
+
if (!w && !d) {
|
|
600
|
+
var q = N.get(s);
|
|
601
|
+
if (q === !0 || q === 3 && v !== 4 || q === 4 && v !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + T);
|
|
602
|
+
N.set(s, !(v > 2) || v);
|
|
603
|
+
}
|
|
604
|
+
Y(R ? a : a.prototype, g, M, d ? "#" + T : Ie(T), v, c, R ? A = A || [] : l = l || [], D, R, d, w, v === 1, R && d ? j : f);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return O(l), O(A), D;
|
|
608
|
+
})(n, t, i, K);
|
|
609
|
+
return e.length || L(n, K), { e: U, get c() {
|
|
610
|
+
var a = [];
|
|
611
|
+
return e.length && [L(Y(n, [e], r, n.name, 5, K, a), K), B.bind(null, a, n)];
|
|
612
|
+
} };
|
|
613
|
+
}
|
|
614
|
+
function Ie(n) {
|
|
615
|
+
var t = xe(n, "string");
|
|
616
|
+
return typeof t == "symbol" ? t : t + "";
|
|
617
|
+
}
|
|
618
|
+
function xe(n, t) {
|
|
619
|
+
if (typeof n != "object" || !n) return n;
|
|
620
|
+
var e = n[Symbol.toPrimitive];
|
|
621
|
+
if (e !== void 0) {
|
|
622
|
+
var r = e.call(n, t);
|
|
623
|
+
if (typeof r != "object") return r;
|
|
624
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
625
|
+
}
|
|
626
|
+
return String(n);
|
|
627
|
+
}
|
|
628
|
+
function Pt(n, t, e) {
|
|
629
|
+
typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
|
|
630
|
+
try {
|
|
631
|
+
Object.defineProperty(n, "name", { configurable: !0, value: e ? e + " " + t : t });
|
|
632
|
+
} catch {
|
|
633
|
+
}
|
|
634
|
+
return n;
|
|
635
|
+
}
|
|
636
|
+
function we(n) {
|
|
637
|
+
if (Object(n) !== n) throw TypeError("right-hand side of 'in' should be an object, got " + (n !== null ? typeof n : "null"));
|
|
638
|
+
return n;
|
|
639
|
+
}
|
|
640
|
+
const Ot = class Ot extends et {
|
|
641
|
+
constructor(t, e, r) {
|
|
642
|
+
var i = (...h) => (super(...h), this.entityConstructor = t, this.entities = e, this.options = r, this);
|
|
643
|
+
Nt(i());
|
|
644
|
+
}
|
|
645
|
+
get invalidationStrategy() {
|
|
646
|
+
return this.options?.invalidationStrategy ?? W.options.invalidationStrategy;
|
|
647
|
+
}
|
|
648
|
+
get mutationErrorStrategy() {
|
|
649
|
+
return this.options?.errorStrategy ?? W.options.errorStrategy;
|
|
650
|
+
}
|
|
651
|
+
get invalidateOnError() {
|
|
652
|
+
return this.options?.invalidateOnError ?? W.options.invalidateOnError;
|
|
653
|
+
}
|
|
654
|
+
onMutate() {
|
|
655
|
+
this.queryClient.cancelQueries({
|
|
656
|
+
queryKey: [this.entityConstructor.name]
|
|
657
|
+
});
|
|
658
|
+
for (const t of this.entities)
|
|
659
|
+
t.state = pt.PENDING;
|
|
660
|
+
}
|
|
661
|
+
onSuccess() {
|
|
662
|
+
for (const t of this.entities)
|
|
663
|
+
t.state = pt.CONFIRMED;
|
|
664
|
+
this.runInvalidationStrategy();
|
|
665
|
+
}
|
|
666
|
+
onError(t = !1) {
|
|
667
|
+
for (const e of this.entities)
|
|
668
|
+
e.state = pt.FAILED, this.mutationErrorStrategy === st.ROLLBACK && !t && e.reset();
|
|
669
|
+
this.invalidateOnError && this.runInvalidationStrategy();
|
|
670
|
+
}
|
|
671
|
+
runInvalidationStrategy() {
|
|
672
|
+
switch (this.invalidationStrategy) {
|
|
673
|
+
case G.ALL_QUERIES:
|
|
674
|
+
this.queryClient.invalidateQueries();
|
|
675
|
+
break;
|
|
676
|
+
case G.ALL_ENTITY_QUERIES:
|
|
677
|
+
this.invalidateCollectionRelatedQueries();
|
|
678
|
+
break;
|
|
679
|
+
case G.REFERENCED_QUERIES:
|
|
680
|
+
this.invalidateEntityRelatedQueries();
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
async invalidateCollectionRelatedQueries() {
|
|
685
|
+
await this.queryClient.invalidateQueries({
|
|
686
|
+
queryKey: [this.entityConstructor.name]
|
|
687
|
+
}).catch((t) => console.error(t));
|
|
688
|
+
}
|
|
689
|
+
invalidateEntityRelatedQueries() {
|
|
690
|
+
const t = this.queryClient.getQueryCache(), e = {};
|
|
691
|
+
for (const r of this.entities)
|
|
692
|
+
for (const i of r.queryHashes)
|
|
693
|
+
e[i] || (e[i] = []), e[i].push(r);
|
|
694
|
+
for (const [r, i] of Object.entries(e))
|
|
695
|
+
bt(r, t, () => {
|
|
696
|
+
for (const h of i)
|
|
697
|
+
h._removeQueryHashes([r]);
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
[Nt] = Ce(Ot, [[z, 2, "onMutate"], [z, 2, "onSuccess"], [z, 2, "onError"]], [], 0, void 0, et).e;
|
|
702
|
+
let St = Ot;
|
|
703
|
+
class gt extends et {
|
|
704
|
+
constructor(t, e) {
|
|
705
|
+
super(), this.mutationPrefix = t, this.entity = e, this.collection = this.getEntityCollection(e);
|
|
706
|
+
}
|
|
707
|
+
collection;
|
|
708
|
+
get baseMutationKey() {
|
|
709
|
+
return [this.entity.name, this.mutationPrefix];
|
|
710
|
+
}
|
|
711
|
+
createMutationStrategy(t, e) {
|
|
712
|
+
return new St(this.entity, t, {
|
|
713
|
+
invalidationStrategy: e.invalidationStrategy,
|
|
714
|
+
errorStrategy: e.errorStrategy,
|
|
715
|
+
invalidateOnError: e.invalidateOnError
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
class Qe extends gt {
|
|
720
|
+
constructor(t, e) {
|
|
721
|
+
super(t, e.entity), this.options = e, this.collection = this.getEntityCollection(e.entity);
|
|
722
|
+
}
|
|
723
|
+
collection;
|
|
724
|
+
async onMutateBase(t, e) {
|
|
725
|
+
return t.strategy.onMutate(), await this.options.onMutate?.(t.entities, e) ?? {};
|
|
726
|
+
}
|
|
727
|
+
async onSuccessBase(t, e, r) {
|
|
728
|
+
t.strategy.onSuccess(), await this.options.onSuccess?.(t.entities, r, e);
|
|
729
|
+
}
|
|
730
|
+
async onErrorBase(t, e, r, i) {
|
|
731
|
+
e.strategy.onError(), await this.options.onError?.(t, e.entities, i, r);
|
|
732
|
+
}
|
|
733
|
+
async onSettledBase(t, e, r, i) {
|
|
734
|
+
await this.options.onSettled?.(e.entities, i, r, t);
|
|
735
|
+
}
|
|
736
|
+
createInternalInput(t) {
|
|
737
|
+
const e = [];
|
|
738
|
+
for (const r of t) {
|
|
739
|
+
if (!r.isDirty) {
|
|
740
|
+
console.warn("Entity values has not been changed, mutation is skipped.");
|
|
741
|
+
continue;
|
|
742
|
+
}
|
|
743
|
+
e.push(r);
|
|
744
|
+
}
|
|
745
|
+
return {
|
|
746
|
+
entities: e,
|
|
747
|
+
strategy: this.createMutationStrategy(e, {
|
|
748
|
+
invalidationStrategy: this.options.invalidationStrategy,
|
|
749
|
+
errorStrategy: this.options.errorStrategy,
|
|
750
|
+
invalidateOnError: this.options.invalidateOnError
|
|
751
|
+
})
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
class Jt extends Qe {
|
|
756
|
+
static mutationPrefix = "__mutation__batch__update__";
|
|
757
|
+
constructor(t) {
|
|
758
|
+
super(Jt.mutationPrefix, t);
|
|
759
|
+
}
|
|
760
|
+
useMutation() {
|
|
761
|
+
const t = vt({
|
|
762
|
+
mutationFn: (e) => this.options.mutationFn(e.entities, this.context),
|
|
763
|
+
onMutate: (e, r) => this.onMutateBase(e, r),
|
|
764
|
+
onSuccess: (e, r, i, h) => this.onSuccessBase(r, i, h),
|
|
765
|
+
onError: (e, r, i, h) => this.onErrorBase(e, r, i, h),
|
|
766
|
+
onSettled: (e, r, i, h, b) => this.onSettledBase(r, i, h, b)
|
|
767
|
+
});
|
|
768
|
+
return (e) => {
|
|
769
|
+
t.mutate(this.createInternalInput(e));
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
let Bt;
|
|
774
|
+
function je(n, t, e, r, i, h) {
|
|
775
|
+
function b(a, y, f) {
|
|
776
|
+
return function(c, l) {
|
|
777
|
+
return f && f(c), a[y].call(c, l);
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
function B(a, y) {
|
|
781
|
+
for (var f = 0; f < a.length; f++) a[f].call(y);
|
|
782
|
+
return y;
|
|
783
|
+
}
|
|
784
|
+
function Q(a, y, f, c) {
|
|
785
|
+
if (typeof a != "function" && (c || a !== void 0)) throw new TypeError(y + " must " + (f || "be") + " a function" + (c ? "" : " or undefined"));
|
|
786
|
+
return a;
|
|
787
|
+
}
|
|
788
|
+
function Y(a, y, f, c, l, A, D, j, N, O, E, g, v) {
|
|
789
|
+
function T(u) {
|
|
790
|
+
if (!v(u)) throw new TypeError("Attempted to access private element on non-instance");
|
|
791
|
+
}
|
|
792
|
+
var d, M = y[0], R = y[3], w = !j;
|
|
793
|
+
if (!w) {
|
|
794
|
+
f || Array.isArray(M) || (M = [M]);
|
|
795
|
+
var s = {}, q = [], m = l === 3 ? "get" : l === 4 || g ? "set" : "value";
|
|
796
|
+
O ? (E || g ? s = { get: $t(function() {
|
|
797
|
+
return R(this);
|
|
798
|
+
}, c, "get"), set: function(u) {
|
|
799
|
+
y[4](this, u);
|
|
800
|
+
} } : s[m] = R, E || $t(s[m], c, l === 2 ? "" : m)) : E || (s = Object.getOwnPropertyDescriptor(a, c));
|
|
801
|
+
}
|
|
802
|
+
for (var p = a, o = M.length - 1; o >= 0; o -= f ? 2 : 1) {
|
|
803
|
+
var _ = M[o], I = f ? M[o - 1] : void 0, F = {}, x = { kind: ["field", "accessor", "method", "getter", "setter", "class"][l], name: c, metadata: A, addInitializer: (function(u, S) {
|
|
804
|
+
if (u.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
805
|
+
Q(S, "An initializer", "be", !0), D.push(S);
|
|
806
|
+
}).bind(null, F) };
|
|
807
|
+
try {
|
|
808
|
+
if (w) (d = Q(_.call(I, p, x), "class decorators", "return")) && (p = d);
|
|
809
|
+
else {
|
|
810
|
+
var C, k;
|
|
811
|
+
x.static = N, x.private = O, O ? l === 2 ? C = function(u) {
|
|
812
|
+
return T(u), s.value;
|
|
813
|
+
} : (l < 4 && (C = b(s, "get", T)), l !== 3 && (k = b(s, "set", T))) : (C = function(u) {
|
|
814
|
+
return u[c];
|
|
815
|
+
}, (l < 2 || l === 4) && (k = function(u, S) {
|
|
816
|
+
u[c] = S;
|
|
817
|
+
}));
|
|
818
|
+
var $ = x.access = { has: O ? v.bind() : function(u) {
|
|
819
|
+
return c in u;
|
|
820
|
+
} };
|
|
821
|
+
if (C && ($.get = C), k && ($.set = k), p = _.call(I, g ? { get: s.get, set: s.set } : s[m], x), g) {
|
|
822
|
+
if (typeof p == "object" && p) (d = Q(p.get, "accessor.get")) && (s.get = d), (d = Q(p.set, "accessor.set")) && (s.set = d), (d = Q(p.init, "accessor.init")) && q.push(d);
|
|
823
|
+
else if (p !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
824
|
+
} else Q(p, (E ? "field" : "method") + " decorators", "return") && (E ? q.push(p) : s[m] = p);
|
|
825
|
+
}
|
|
826
|
+
} finally {
|
|
827
|
+
F.v = !0;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
return (E || g) && j.push(function(u, S) {
|
|
831
|
+
for (var P = q.length - 1; P >= 0; P--) S = q[P].call(u, S);
|
|
832
|
+
return S;
|
|
833
|
+
}), E || w || (O ? g ? j.push(b(s, "get"), b(s, "set")) : j.push(l === 2 ? s[m] : b.call.bind(s[m])) : Object.defineProperty(a, c, s)), p;
|
|
834
|
+
}
|
|
835
|
+
function L(a, y) {
|
|
836
|
+
return Object.defineProperty(a, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: y });
|
|
837
|
+
}
|
|
838
|
+
if (arguments.length >= 6) var H = h[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
839
|
+
var K = Object.create(H ?? null), U = (function(a, y, f, c) {
|
|
840
|
+
var l, A, D = [], j = function(m) {
|
|
841
|
+
return Fe(m) === a;
|
|
842
|
+
}, N = /* @__PURE__ */ new Map();
|
|
843
|
+
function O(m) {
|
|
844
|
+
m && D.push(B.bind(null, m));
|
|
845
|
+
}
|
|
846
|
+
for (var E = 0; E < y.length; E++) {
|
|
847
|
+
var g = y[E];
|
|
848
|
+
if (Array.isArray(g)) {
|
|
849
|
+
var v = g[1], T = g[2], d = g.length > 3, M = 16 & v, R = !!(8 & v), w = (v &= 7) == 0, s = T + "/" + R;
|
|
850
|
+
if (!w && !d) {
|
|
851
|
+
var q = N.get(s);
|
|
852
|
+
if (q === !0 || q === 3 && v !== 4 || q === 4 && v !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + T);
|
|
853
|
+
N.set(s, !(v > 2) || v);
|
|
854
|
+
}
|
|
855
|
+
Y(R ? a : a.prototype, g, M, d ? "#" + T : Ae(T), v, c, R ? A = A || [] : l = l || [], D, R, d, w, v === 1, R && d ? j : f);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return O(l), O(A), D;
|
|
859
|
+
})(n, t, i, K);
|
|
860
|
+
return e.length || L(n, K), { e: U, get c() {
|
|
861
|
+
var a = [];
|
|
862
|
+
return e.length && [L(Y(n, [e], r, n.name, 5, K, a), K), B.bind(null, a, n)];
|
|
863
|
+
} };
|
|
864
|
+
}
|
|
865
|
+
function Ae(n) {
|
|
866
|
+
var t = De(n, "string");
|
|
867
|
+
return typeof t == "symbol" ? t : t + "";
|
|
868
|
+
}
|
|
869
|
+
function De(n, t) {
|
|
870
|
+
if (typeof n != "object" || !n) return n;
|
|
871
|
+
var e = n[Symbol.toPrimitive];
|
|
872
|
+
if (e !== void 0) {
|
|
873
|
+
var r = e.call(n, t);
|
|
874
|
+
if (typeof r != "object") return r;
|
|
875
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
876
|
+
}
|
|
877
|
+
return String(n);
|
|
878
|
+
}
|
|
879
|
+
function $t(n, t, e) {
|
|
880
|
+
typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
|
|
881
|
+
try {
|
|
882
|
+
Object.defineProperty(n, "name", { configurable: !0, value: e ? e + " " + t : t });
|
|
883
|
+
} catch {
|
|
884
|
+
}
|
|
885
|
+
return n;
|
|
886
|
+
}
|
|
887
|
+
function Fe(n) {
|
|
888
|
+
if (Object(n) !== n) throw TypeError("right-hand side of 'in' should be an object, got " + (n !== null ? typeof n : "null"));
|
|
889
|
+
return n;
|
|
890
|
+
}
|
|
891
|
+
const it = class it extends gt {
|
|
892
|
+
constructor(t) {
|
|
893
|
+
var e = (...r) => (super(...r), this.options = t, this);
|
|
894
|
+
Bt(e(it.mutationPrefix, t.entity));
|
|
895
|
+
}
|
|
896
|
+
useMutation() {
|
|
897
|
+
const t = vt({
|
|
898
|
+
mutationFn: (e) => this.options.mutationFn(e.input, e.entity, this.context),
|
|
899
|
+
onMutate: (e, r) => this.onMutate(e, r),
|
|
900
|
+
onSuccess: (e, r, i, h) => this.onSuccess(r, i, h),
|
|
901
|
+
onError: (e, r, i, h) => this.onError(e, r, i, h),
|
|
902
|
+
onSettled: (e, r, i, h, b) => this.onSettled(i, r, h, b),
|
|
903
|
+
gcTime: this.options.gcTime,
|
|
904
|
+
meta: this.options.meta,
|
|
905
|
+
networkMode: this.options.networkMode,
|
|
906
|
+
retry: this.options.retry,
|
|
907
|
+
retryDelay: this.options.retryDelay,
|
|
908
|
+
scope: this.options.scope,
|
|
909
|
+
throwOnError: this.options.throwOnError,
|
|
910
|
+
mutationKey: this.baseMutationKey
|
|
911
|
+
});
|
|
912
|
+
return (e) => {
|
|
913
|
+
const r = new this.options.entity();
|
|
914
|
+
r.hydrate(e), r._markAsHydrated(), this.collection.setEntity(r), this.collection.clientOnlyEntityIds.add(r.id), t.mutate({
|
|
915
|
+
input: e,
|
|
916
|
+
entity: r,
|
|
917
|
+
mutationStrategy: this.createMutationStrategy([r])
|
|
918
|
+
});
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
async onMutate(t, e) {
|
|
922
|
+
return t.mutationStrategy.onMutate(), await this.options.onMutate?.(t.input, t.entity, e) ?? {};
|
|
923
|
+
}
|
|
924
|
+
onSuccess(t, e, r) {
|
|
925
|
+
t.mutationStrategy.onSuccess(), this.options.onSuccess?.(t.input, t.entity, e, r);
|
|
926
|
+
}
|
|
927
|
+
onError(t, e, r, i) {
|
|
928
|
+
const h = e.mutationStrategy?.mutationErrorStrategy ?? st.ROLLBACK;
|
|
929
|
+
e.mutationStrategy.onError(!0), h === st.ROLLBACK && this.collection.deleteEntity(e.entity.id), this.options.onError?.(t, e.input, e.entity, r, i);
|
|
930
|
+
}
|
|
931
|
+
onSettled(t, e, r, i) {
|
|
932
|
+
this.options.onSettled?.(t.input, t.entity, e, r, i);
|
|
933
|
+
}
|
|
934
|
+
createMutationStrategy(t) {
|
|
935
|
+
if (this.options.invalidationStrategy === G.REFERENCED_QUERIES)
|
|
936
|
+
throw new Error("REFERENCED_QUERIES invalidation strategy is not supported for create mutation");
|
|
937
|
+
return super.createMutationStrategy(t, {
|
|
938
|
+
invalidationStrategy: this.options.invalidationStrategy ?? G.ALL_ENTITY_QUERIES,
|
|
939
|
+
errorStrategy: this.options.errorStrategy,
|
|
940
|
+
invalidateOnError: this.options.invalidateOnError
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
[Bt] = je(it, [[z, 2, "onMutate"], [z, 2, "onSuccess"], [z, 2, "onError"], [z, 2, "onSettled"]], [], 0, void 0, gt).e, V(it, "mutationPrefix", "__mutation__create__");
|
|
945
|
+
let Lt = it;
|
|
946
|
+
class Tt extends gt {
|
|
947
|
+
constructor(t, e) {
|
|
948
|
+
super(t, e.entity), this.options = e, this.mutationStrategy = this.createMutationStrategy([e.instance], {
|
|
949
|
+
invalidationStrategy: e.invalidationStrategy,
|
|
950
|
+
errorStrategy: e.errorStrategy,
|
|
951
|
+
invalidateOnError: e.invalidateOnError
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
mutationStrategy;
|
|
955
|
+
get entityMutationKey() {
|
|
956
|
+
return [...this.baseMutationKey, this.options.instance.id];
|
|
957
|
+
}
|
|
958
|
+
async onMutateBase(t) {
|
|
959
|
+
return this.mutationStrategy.onMutate(), await this.options.onMutate?.(this.options.instance, t);
|
|
960
|
+
}
|
|
961
|
+
async onSuccessBase(t, e) {
|
|
962
|
+
this.mutationStrategy.onSuccess(), await this.options.onSuccess?.(this.options.instance, t, e);
|
|
963
|
+
}
|
|
964
|
+
async onErrorBase(t, e, r) {
|
|
965
|
+
this.mutationStrategy.onError(), await this.options.onError?.(t, this.options.instance, e, r);
|
|
966
|
+
}
|
|
967
|
+
async onSettledBase(t, e, r) {
|
|
968
|
+
await this.options.onSettled?.(this.options.instance, t, e, r);
|
|
969
|
+
}
|
|
970
|
+
mutateBase(t, e) {
|
|
971
|
+
this.runSyncMutation(t, (r, i) => this.options.mutationFn(void 0, i), {
|
|
972
|
+
onMutate: async (r, i) => e.onMutate?.(this.options.instance, i),
|
|
973
|
+
onSuccess: (r, i, h, b) => e.onSuccess?.(this.options.instance, h, b),
|
|
974
|
+
onError: (r, i, h, b) => e.onError?.(r, this.options.instance, h, b),
|
|
975
|
+
onSettled: (r, i, h, b, B) => e.onSettled?.(this.options.instance, i, b, B),
|
|
976
|
+
gcTime: this.options.gcTime,
|
|
977
|
+
meta: this.options.meta,
|
|
978
|
+
networkMode: this.options.networkMode,
|
|
979
|
+
retry: this.options.retry,
|
|
980
|
+
retryDelay: this.options.retryDelay,
|
|
981
|
+
scope: this.options.scope,
|
|
982
|
+
mutationKey: this.entityMutationKey
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
let Ht;
|
|
987
|
+
function Ke(n, t, e, r, i, h) {
|
|
988
|
+
function b(a, y, f) {
|
|
989
|
+
return function(c, l) {
|
|
990
|
+
return f && f(c), a[y].call(c, l);
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
function B(a, y) {
|
|
994
|
+
for (var f = 0; f < a.length; f++) a[f].call(y);
|
|
995
|
+
return y;
|
|
996
|
+
}
|
|
997
|
+
function Q(a, y, f, c) {
|
|
998
|
+
if (typeof a != "function" && (c || a !== void 0)) throw new TypeError(y + " must " + (f || "be") + " a function" + (c ? "" : " or undefined"));
|
|
999
|
+
return a;
|
|
1000
|
+
}
|
|
1001
|
+
function Y(a, y, f, c, l, A, D, j, N, O, E, g, v) {
|
|
1002
|
+
function T(u) {
|
|
1003
|
+
if (!v(u)) throw new TypeError("Attempted to access private element on non-instance");
|
|
1004
|
+
}
|
|
1005
|
+
var d, M = y[0], R = y[3], w = !j;
|
|
1006
|
+
if (!w) {
|
|
1007
|
+
f || Array.isArray(M) || (M = [M]);
|
|
1008
|
+
var s = {}, q = [], m = l === 3 ? "get" : l === 4 || g ? "set" : "value";
|
|
1009
|
+
O ? (E || g ? s = { get: Yt(function() {
|
|
1010
|
+
return R(this);
|
|
1011
|
+
}, c, "get"), set: function(u) {
|
|
1012
|
+
y[4](this, u);
|
|
1013
|
+
} } : s[m] = R, E || Yt(s[m], c, l === 2 ? "" : m)) : E || (s = Object.getOwnPropertyDescriptor(a, c));
|
|
1014
|
+
}
|
|
1015
|
+
for (var p = a, o = M.length - 1; o >= 0; o -= f ? 2 : 1) {
|
|
1016
|
+
var _ = M[o], I = f ? M[o - 1] : void 0, F = {}, x = { kind: ["field", "accessor", "method", "getter", "setter", "class"][l], name: c, metadata: A, addInitializer: (function(u, S) {
|
|
1017
|
+
if (u.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
1018
|
+
Q(S, "An initializer", "be", !0), D.push(S);
|
|
1019
|
+
}).bind(null, F) };
|
|
1020
|
+
try {
|
|
1021
|
+
if (w) (d = Q(_.call(I, p, x), "class decorators", "return")) && (p = d);
|
|
1022
|
+
else {
|
|
1023
|
+
var C, k;
|
|
1024
|
+
x.static = N, x.private = O, O ? l === 2 ? C = function(u) {
|
|
1025
|
+
return T(u), s.value;
|
|
1026
|
+
} : (l < 4 && (C = b(s, "get", T)), l !== 3 && (k = b(s, "set", T))) : (C = function(u) {
|
|
1027
|
+
return u[c];
|
|
1028
|
+
}, (l < 2 || l === 4) && (k = function(u, S) {
|
|
1029
|
+
u[c] = S;
|
|
1030
|
+
}));
|
|
1031
|
+
var $ = x.access = { has: O ? v.bind() : function(u) {
|
|
1032
|
+
return c in u;
|
|
1033
|
+
} };
|
|
1034
|
+
if (C && ($.get = C), k && ($.set = k), p = _.call(I, g ? { get: s.get, set: s.set } : s[m], x), g) {
|
|
1035
|
+
if (typeof p == "object" && p) (d = Q(p.get, "accessor.get")) && (s.get = d), (d = Q(p.set, "accessor.set")) && (s.set = d), (d = Q(p.init, "accessor.init")) && q.push(d);
|
|
1036
|
+
else if (p !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
1037
|
+
} else Q(p, (E ? "field" : "method") + " decorators", "return") && (E ? q.push(p) : s[m] = p);
|
|
1038
|
+
}
|
|
1039
|
+
} finally {
|
|
1040
|
+
F.v = !0;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
return (E || g) && j.push(function(u, S) {
|
|
1044
|
+
for (var P = q.length - 1; P >= 0; P--) S = q[P].call(u, S);
|
|
1045
|
+
return S;
|
|
1046
|
+
}), E || w || (O ? g ? j.push(b(s, "get"), b(s, "set")) : j.push(l === 2 ? s[m] : b.call.bind(s[m])) : Object.defineProperty(a, c, s)), p;
|
|
1047
|
+
}
|
|
1048
|
+
function L(a, y) {
|
|
1049
|
+
return Object.defineProperty(a, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: y });
|
|
1050
|
+
}
|
|
1051
|
+
if (arguments.length >= 6) var H = h[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
1052
|
+
var K = Object.create(H ?? null), U = (function(a, y, f, c) {
|
|
1053
|
+
var l, A, D = [], j = function(m) {
|
|
1054
|
+
return Pe(m) === a;
|
|
1055
|
+
}, N = /* @__PURE__ */ new Map();
|
|
1056
|
+
function O(m) {
|
|
1057
|
+
m && D.push(B.bind(null, m));
|
|
1058
|
+
}
|
|
1059
|
+
for (var E = 0; E < y.length; E++) {
|
|
1060
|
+
var g = y[E];
|
|
1061
|
+
if (Array.isArray(g)) {
|
|
1062
|
+
var v = g[1], T = g[2], d = g.length > 3, M = 16 & v, R = !!(8 & v), w = (v &= 7) == 0, s = T + "/" + R;
|
|
1063
|
+
if (!w && !d) {
|
|
1064
|
+
var q = N.get(s);
|
|
1065
|
+
if (q === !0 || q === 3 && v !== 4 || q === 4 && v !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + T);
|
|
1066
|
+
N.set(s, !(v > 2) || v);
|
|
1067
|
+
}
|
|
1068
|
+
Y(R ? a : a.prototype, g, M, d ? "#" + T : ke(T), v, c, R ? A = A || [] : l = l || [], D, R, d, w, v === 1, R && d ? j : f);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return O(l), O(A), D;
|
|
1072
|
+
})(n, t, i, K);
|
|
1073
|
+
return e.length || L(n, K), { e: U, get c() {
|
|
1074
|
+
var a = [];
|
|
1075
|
+
return e.length && [L(Y(n, [e], r, n.name, 5, K, a), K), B.bind(null, a, n)];
|
|
1076
|
+
} };
|
|
1077
|
+
}
|
|
1078
|
+
function ke(n) {
|
|
1079
|
+
var t = Ne(n, "string");
|
|
1080
|
+
return typeof t == "symbol" ? t : t + "";
|
|
1081
|
+
}
|
|
1082
|
+
function Ne(n, t) {
|
|
1083
|
+
if (typeof n != "object" || !n) return n;
|
|
1084
|
+
var e = n[Symbol.toPrimitive];
|
|
1085
|
+
if (e !== void 0) {
|
|
1086
|
+
var r = e.call(n, t);
|
|
1087
|
+
if (typeof r != "object") return r;
|
|
1088
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1089
|
+
}
|
|
1090
|
+
return String(n);
|
|
1091
|
+
}
|
|
1092
|
+
function Yt(n, t, e) {
|
|
1093
|
+
typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
|
|
1094
|
+
try {
|
|
1095
|
+
Object.defineProperty(n, "name", { configurable: !0, value: e ? e + " " + t : t });
|
|
1096
|
+
} catch {
|
|
1097
|
+
}
|
|
1098
|
+
return n;
|
|
1099
|
+
}
|
|
1100
|
+
function Pe(n) {
|
|
1101
|
+
if (Object(n) !== n) throw TypeError("right-hand side of 'in' should be an object, got " + (n !== null ? typeof n : "null"));
|
|
1102
|
+
return n;
|
|
1103
|
+
}
|
|
1104
|
+
const ot = class ot extends Tt {
|
|
1105
|
+
constructor(t) {
|
|
1106
|
+
Ht(super(ot.mutationPrefix, t));
|
|
1107
|
+
}
|
|
1108
|
+
useMutation() {
|
|
1109
|
+
const t = vt({
|
|
1110
|
+
mutationFn: () => this.options.mutationFn(void 0, this.context),
|
|
1111
|
+
onMutate: (e, r) => this.onMutate(r),
|
|
1112
|
+
onSuccess: (e, r, i, h) => this.onSuccess(i, h),
|
|
1113
|
+
onError: (e, r, i, h) => this.onError(e, i, h),
|
|
1114
|
+
onSettled: (e, r, i, h, b) => this.onSettled(r, h, b),
|
|
1115
|
+
gcTime: this.options.gcTime,
|
|
1116
|
+
meta: this.options.meta,
|
|
1117
|
+
networkMode: this.options.networkMode,
|
|
1118
|
+
retry: this.options.retry,
|
|
1119
|
+
retryDelay: this.options.retryDelay,
|
|
1120
|
+
scope: this.options.scope,
|
|
1121
|
+
throwOnError: this.options.throwOnError,
|
|
1122
|
+
mutationKey: this.entityMutationKey
|
|
1123
|
+
});
|
|
1124
|
+
return () => t.mutate();
|
|
1125
|
+
}
|
|
1126
|
+
async onMutate(t) {
|
|
1127
|
+
const e = await this.onMutateBase(t);
|
|
1128
|
+
return this.collection.deletedRecordIds.add(this.options.instance.id), e;
|
|
1129
|
+
}
|
|
1130
|
+
async onSuccess(t, e) {
|
|
1131
|
+
await this.onSuccessBase(t, e), this.collection.deletedRecordIds.delete(this.options.instance.id), this.collection.deleteEntity(this.options.instance.id);
|
|
1132
|
+
}
|
|
1133
|
+
async onError(t, e, r) {
|
|
1134
|
+
await this.onErrorBase(t, e, r), this.collection.deletedRecordIds.delete(this.options.instance.id);
|
|
1135
|
+
}
|
|
1136
|
+
async onSettled(t, e, r) {
|
|
1137
|
+
await this.onSettledBase(t, e, r);
|
|
1138
|
+
}
|
|
1139
|
+
mutate(t) {
|
|
1140
|
+
this.mutateBase(t, {
|
|
1141
|
+
onMutate: (e, r) => this.onMutate(r),
|
|
1142
|
+
onSuccess: (e, r, i) => this.onSuccess(r, i),
|
|
1143
|
+
onError: (e, r, i, h) => this.onError(e, i, h),
|
|
1144
|
+
onSettled: (e, r, i, h) => this.onSettled(r, i, h)
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
[Ht] = Ke(ot, [[z, 2, "onMutate"], [z, 2, "onSuccess"], [z, 2, "onError"]], [], 0, void 0, Tt).e, V(ot, "mutationPrefix", "__mutation__delete__");
|
|
1149
|
+
let zt = ot;
|
|
1150
|
+
class Xt extends Tt {
|
|
1151
|
+
static mutationPrefix = "__mutation__update__";
|
|
1152
|
+
constructor(t) {
|
|
1153
|
+
super(Xt.mutationPrefix, t);
|
|
1154
|
+
}
|
|
1155
|
+
useMutation() {
|
|
1156
|
+
const t = vt({
|
|
1157
|
+
mutationFn: () => this.options.mutationFn(void 0, this.context),
|
|
1158
|
+
onMutate: async (e, r) => this.onMutateBase(r),
|
|
1159
|
+
onSuccess: (e, r, i, h) => this.onSuccessBase(i, h),
|
|
1160
|
+
onError: (e, r, i, h) => this.onErrorBase(e, i, h),
|
|
1161
|
+
onSettled: (e, r, i, h, b) => this.onSettledBase(r, h, b),
|
|
1162
|
+
gcTime: this.options.gcTime,
|
|
1163
|
+
meta: this.options.meta,
|
|
1164
|
+
networkMode: this.options.networkMode,
|
|
1165
|
+
retry: this.options.retry,
|
|
1166
|
+
retryDelay: this.options.retryDelay,
|
|
1167
|
+
scope: this.options.scope,
|
|
1168
|
+
throwOnError: this.options.throwOnError,
|
|
1169
|
+
mutationKey: this.entityMutationKey
|
|
1170
|
+
});
|
|
1171
|
+
return () => {
|
|
1172
|
+
if (!this.options.instance.isDirty)
|
|
1173
|
+
return console.warn("Entity values has not been changed, mutation is skipped.");
|
|
1174
|
+
t.mutate();
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
mutate(t) {
|
|
1178
|
+
if (!this.options.instance.isDirty)
|
|
1179
|
+
return console.warn("Entity values has not been changed, mutation is skipped.");
|
|
1180
|
+
this.mutateBase(t, {
|
|
1181
|
+
onMutate: (e, r) => this.onMutateBase(r),
|
|
1182
|
+
onSuccess: (e, r, i) => this.onSuccessBase(r, i),
|
|
1183
|
+
onError: (e, r, i, h) => this.onErrorBase(e, i, h),
|
|
1184
|
+
onSettled: (e, r, i, h) => this.onSettledBase(r, i, h)
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
const W = {
|
|
1189
|
+
state: /* @__PURE__ */ new Map(),
|
|
1190
|
+
context: null,
|
|
1191
|
+
options: {
|
|
1192
|
+
invalidationStrategy: G.REFERENCED_QUERIES,
|
|
1193
|
+
errorStrategy: st.ROLLBACK,
|
|
1194
|
+
invalidateOnError: !0
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
class Ge {
|
|
1198
|
+
rootStore;
|
|
1199
|
+
constructor(t) {
|
|
1200
|
+
W.context = t.context;
|
|
1201
|
+
for (const e of t.entities)
|
|
1202
|
+
W.state.set(e.name, new _t(e, t.context.queryClient));
|
|
1203
|
+
W.options.invalidationStrategy = t.invalidationStrategy ?? G.REFERENCED_QUERIES, W.options.errorStrategy = t.errorStrategy ?? st.ROLLBACK, W.options.invalidateOnError = t.invalidateOnError ?? !0, this.rootStore = t.rootStore();
|
|
1204
|
+
}
|
|
1205
|
+
getEntityCollection(t) {
|
|
1206
|
+
const e = W.state.get(t.name);
|
|
1207
|
+
if (!e)
|
|
1208
|
+
throw new Error(`Entity collection not found for entity ${t.name}`);
|
|
1209
|
+
return e;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
class et {
|
|
1213
|
+
queryClient;
|
|
1214
|
+
context;
|
|
1215
|
+
globalState;
|
|
1216
|
+
constructor() {
|
|
1217
|
+
if (!W)
|
|
1218
|
+
throw new Error("Client not found");
|
|
1219
|
+
if (!W.context)
|
|
1220
|
+
throw new Error("MQClientContext is required");
|
|
1221
|
+
this.queryClient = W.context.queryClient, this.globalState = W.state, this.context = W.context;
|
|
1222
|
+
}
|
|
1223
|
+
getEntityCollection(t) {
|
|
1224
|
+
const e = this.globalState.get(t.name);
|
|
1225
|
+
if (!e)
|
|
1226
|
+
throw new Error(`Entity collection not found for entity ${t.name}`);
|
|
1227
|
+
return e;
|
|
1228
|
+
}
|
|
1229
|
+
runSyncMutation(t, e, r) {
|
|
1230
|
+
this.queryClient.getMutationCache().build(this.queryClient, {
|
|
1231
|
+
mutationFn: (i) => e(i, this.context),
|
|
1232
|
+
onError: r?.onError,
|
|
1233
|
+
onMutate: r?.onMutate,
|
|
1234
|
+
onSuccess: r?.onSuccess,
|
|
1235
|
+
onSettled: r?.onSettled,
|
|
1236
|
+
gcTime: r?.gcTime,
|
|
1237
|
+
meta: r?.meta,
|
|
1238
|
+
networkMode: r?.networkMode,
|
|
1239
|
+
retry: r?.retry,
|
|
1240
|
+
retryDelay: r?.retryDelay,
|
|
1241
|
+
scope: r?.scope,
|
|
1242
|
+
mutationKey: r?.mutationKey
|
|
1243
|
+
}).execute(t).catch((i) => console.log("runSyncMutation error", i));
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
class Zt extends et {
|
|
1247
|
+
constructor(t, e) {
|
|
1248
|
+
super(), this.entityConstructors = t, this.baseQueryKeysRest = e;
|
|
1249
|
+
}
|
|
1250
|
+
get baseQueryKey() {
|
|
1251
|
+
return [this.entityConstructors.map((t) => t.name).join("_"), ...this.baseQueryKeysRest()];
|
|
1252
|
+
}
|
|
1253
|
+
get baseQueryHash() {
|
|
1254
|
+
return ft(this.baseQueryKey);
|
|
1255
|
+
}
|
|
1256
|
+
createQueryKey(t) {
|
|
1257
|
+
return [...this.baseQueryKey, t];
|
|
1258
|
+
}
|
|
1259
|
+
createQueryHash(t) {
|
|
1260
|
+
return ft(this.createQueryKey(t));
|
|
1261
|
+
}
|
|
1262
|
+
useIsFetching(t) {
|
|
1263
|
+
return fe({
|
|
1264
|
+
queryKey: this.createQueryKey(t)
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
setOneEntity(t, e, r) {
|
|
1268
|
+
return this.getEntityCollection(r).setEntity(t, [ft(e)]);
|
|
1269
|
+
}
|
|
1270
|
+
setManyEntities(t, e, r) {
|
|
1271
|
+
if (typeof t != "object" || !Array.isArray(t))
|
|
1272
|
+
throw new Error(`Query function for ${r.name} must return an array of entities`);
|
|
1273
|
+
return this.getEntityCollection(r).setEntities(t, [ft(e)]);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
class te extends Zt {
|
|
1277
|
+
constructor(t, e) {
|
|
1278
|
+
super([e.entity], () => [t, ...e.queryKey()]), this.options = e, this.collection = this.getEntityCollection(e.entity);
|
|
1279
|
+
}
|
|
1280
|
+
collection;
|
|
1281
|
+
prefetch(t) {
|
|
1282
|
+
const e = this.queryFnWrapper(t);
|
|
1283
|
+
return this.queryClient.prefetchQuery({
|
|
1284
|
+
queryKey: this.createQueryKey(t),
|
|
1285
|
+
queryFn: () => e.run()
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
ensureData(t) {
|
|
1289
|
+
const e = this.queryFnWrapper(t);
|
|
1290
|
+
return this.queryClient.ensureQueryData({
|
|
1291
|
+
queryKey: e.queryKey,
|
|
1292
|
+
queryFn: () => e.run()
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
invalidate(t) {
|
|
1296
|
+
bt(this.createQueryHash(t), this.queryClient.getQueryCache());
|
|
1297
|
+
}
|
|
1298
|
+
setQueryData(t, e) {
|
|
1299
|
+
const r = this.createQueryKey(e), [i, h] = this.setManyEntities(t, r, this.options.entity);
|
|
1300
|
+
this.queryClient.setQueryData(r, h);
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Returns the current entity ID array stored in the TanStack query cache
|
|
1304
|
+
* for the given arguments.
|
|
1305
|
+
*/
|
|
1306
|
+
getQueryIds(t) {
|
|
1307
|
+
return this.queryClient.getQueryData(this.createQueryKey(t)) ?? [];
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Directly sets the entity ID array in the TanStack query cache
|
|
1311
|
+
* for the given arguments. Used by relation mutations for optimistic updates.
|
|
1312
|
+
*/
|
|
1313
|
+
setQueryIds(t, e) {
|
|
1314
|
+
this.queryClient.setQueryData(this.createQueryKey(e), t);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Public accessor for the query key. Used by relation mutations
|
|
1318
|
+
* to construct invalidation targets.
|
|
1319
|
+
*/
|
|
1320
|
+
getQueryKey(t) {
|
|
1321
|
+
return this.createQueryKey(t);
|
|
1322
|
+
}
|
|
1323
|
+
getEntities(t) {
|
|
1324
|
+
const e = [];
|
|
1325
|
+
for (const r of t) {
|
|
1326
|
+
if (this.collection.deletedRecordIds.has(r))
|
|
1327
|
+
continue;
|
|
1328
|
+
const i = this.collection.collection.get(r);
|
|
1329
|
+
i && e.push(i);
|
|
1330
|
+
}
|
|
1331
|
+
return e;
|
|
1332
|
+
}
|
|
1333
|
+
queryFnWrapper(t) {
|
|
1334
|
+
const e = this.createQueryKey(t);
|
|
1335
|
+
return {
|
|
1336
|
+
run: async () => {
|
|
1337
|
+
if (!this.options.queryFn)
|
|
1338
|
+
throw new Error("Query function is not defined");
|
|
1339
|
+
const r = await this.options.queryFn(t, this.context), [i, h] = this.setManyEntities(r, e, this.options.entity);
|
|
1340
|
+
return h;
|
|
1341
|
+
},
|
|
1342
|
+
queryKey: e
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
class ee extends te {
|
|
1347
|
+
static queryPrefix = "__query__fragment__many__";
|
|
1348
|
+
constructor(t) {
|
|
1349
|
+
super(ee.queryPrefix, t);
|
|
1350
|
+
}
|
|
1351
|
+
useQuery(t) {
|
|
1352
|
+
const e = this.queryFnWrapper(t), r = Et({
|
|
1353
|
+
queryKey: e.queryKey,
|
|
1354
|
+
queryFn: () => e.run(),
|
|
1355
|
+
staleTime: 1 / 0,
|
|
1356
|
+
gcTime: 1 / 0
|
|
1357
|
+
});
|
|
1358
|
+
return this.getEntities(r.data ?? []);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
class re extends Zt {
|
|
1362
|
+
constructor(t, e) {
|
|
1363
|
+
super([e.entity], () => [t, ...e.queryKey()]), this.options = e, this.collection = this.getEntityCollection(e.entity);
|
|
1364
|
+
}
|
|
1365
|
+
collection;
|
|
1366
|
+
prefetch(t) {
|
|
1367
|
+
const e = this.queryFnWrapper(t);
|
|
1368
|
+
return this.queryClient.prefetchQuery({
|
|
1369
|
+
queryKey: e.queryKey,
|
|
1370
|
+
queryFn: () => e.run()
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
ensureData(t) {
|
|
1374
|
+
const e = this.queryFnWrapper(t);
|
|
1375
|
+
return this.queryClient.ensureQueryData({
|
|
1376
|
+
queryKey: e.queryKey,
|
|
1377
|
+
queryFn: () => e.run()
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
invalidate(t) {
|
|
1381
|
+
bt(this.createQueryHash(t), this.queryClient.getQueryCache());
|
|
1382
|
+
}
|
|
1383
|
+
setQueryData(t, e) {
|
|
1384
|
+
const r = this.createQueryKey(e), i = this.setOneEntity(t, r, this.options.entity);
|
|
1385
|
+
this.queryClient.setQueryData(r, i.id);
|
|
1386
|
+
}
|
|
1387
|
+
getEntity(t) {
|
|
1388
|
+
return this.collection.deletedRecordIds.has(t) ? null : this.collection.collection.get(t);
|
|
1389
|
+
}
|
|
1390
|
+
queryFnWrapper(t) {
|
|
1391
|
+
const e = this.createQueryKey(t);
|
|
1392
|
+
return {
|
|
1393
|
+
run: async () => {
|
|
1394
|
+
if (!this.options.queryFn)
|
|
1395
|
+
throw new Error("Query function is not defined");
|
|
1396
|
+
const r = await this.options.queryFn(t, this.context);
|
|
1397
|
+
return this.setOneEntity(r, e, this.options.entity).id;
|
|
1398
|
+
},
|
|
1399
|
+
queryKey: e
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
class ne extends re {
|
|
1404
|
+
static queryPrefix = "__query__fragment__one__";
|
|
1405
|
+
constructor(t) {
|
|
1406
|
+
super(ne.queryPrefix, t);
|
|
1407
|
+
}
|
|
1408
|
+
useQuery(t) {
|
|
1409
|
+
const e = this.queryFnWrapper(t), r = Et({
|
|
1410
|
+
queryKey: e.queryKey,
|
|
1411
|
+
queryFn: () => e.run(),
|
|
1412
|
+
staleTime: 1 / 0,
|
|
1413
|
+
gcTime: 1 / 0
|
|
1414
|
+
});
|
|
1415
|
+
return r.data ? this.getEntity(r.data) : null;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
class ie extends te {
|
|
1419
|
+
static queryPrefix = "__query__many__";
|
|
1420
|
+
constructor(t) {
|
|
1421
|
+
super(ie.queryPrefix, t);
|
|
1422
|
+
}
|
|
1423
|
+
useSuspenseQuery(t) {
|
|
1424
|
+
const e = this.queryFnWrapper(t), r = mt({
|
|
1425
|
+
queryKey: e.queryKey,
|
|
1426
|
+
queryFn: () => e.run(),
|
|
1427
|
+
...this.options.staleTime !== void 0 ? {
|
|
1428
|
+
staleTime: this.options.staleTime
|
|
1429
|
+
} : {},
|
|
1430
|
+
...this.options.gcTime !== void 0 ? {
|
|
1431
|
+
gcTime: this.options.gcTime
|
|
1432
|
+
} : {}
|
|
1433
|
+
});
|
|
1434
|
+
return this.getEntities(r.data);
|
|
1435
|
+
}
|
|
1436
|
+
useDeferredQuery(t) {
|
|
1437
|
+
const e = Gt(t), r = this.queryFnWrapper(e), i = mt({
|
|
1438
|
+
queryKey: r.queryKey,
|
|
1439
|
+
queryFn: () => r.run(),
|
|
1440
|
+
...this.options.staleTime !== void 0 ? {
|
|
1441
|
+
staleTime: this.options.staleTime
|
|
1442
|
+
} : {},
|
|
1443
|
+
...this.options.gcTime !== void 0 ? {
|
|
1444
|
+
gcTime: this.options.gcTime
|
|
1445
|
+
} : {}
|
|
1446
|
+
});
|
|
1447
|
+
return this.getEntities(i.data);
|
|
1448
|
+
}
|
|
1449
|
+
useQuery(t, e) {
|
|
1450
|
+
const r = this.queryFnWrapper(t), i = Et({
|
|
1451
|
+
queryKey: r.queryKey,
|
|
1452
|
+
queryFn: () => r.run(),
|
|
1453
|
+
enabled: typeof this.options.enabled == "function" ? this.options.enabled(e, t) : this.options.enabled,
|
|
1454
|
+
...this.options.staleTime !== void 0 ? {
|
|
1455
|
+
staleTime: this.options.staleTime
|
|
1456
|
+
} : {},
|
|
1457
|
+
...this.options.gcTime !== void 0 ? {
|
|
1458
|
+
gcTime: this.options.gcTime
|
|
1459
|
+
} : {}
|
|
1460
|
+
});
|
|
1461
|
+
return this.getEntities(i.data ?? []);
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
class oe extends re {
|
|
1465
|
+
static queryPrefix = "__query__one__";
|
|
1466
|
+
constructor(t) {
|
|
1467
|
+
super(oe.queryPrefix, t);
|
|
1468
|
+
}
|
|
1469
|
+
useSuspenseQuery(t) {
|
|
1470
|
+
const e = this.queryFnWrapper(t), r = mt({
|
|
1471
|
+
queryKey: e.queryKey,
|
|
1472
|
+
queryFn: () => e.run(),
|
|
1473
|
+
...this.options.staleTime !== void 0 ? {
|
|
1474
|
+
staleTime: this.options.staleTime
|
|
1475
|
+
} : {},
|
|
1476
|
+
...this.options.gcTime !== void 0 ? {
|
|
1477
|
+
gcTime: this.options.gcTime
|
|
1478
|
+
} : {}
|
|
1479
|
+
});
|
|
1480
|
+
return this.getEntity(r.data);
|
|
1481
|
+
}
|
|
1482
|
+
useDeferredQuery(t) {
|
|
1483
|
+
const e = Gt(t), r = this.queryFnWrapper(e), i = mt({
|
|
1484
|
+
queryKey: r.queryKey,
|
|
1485
|
+
queryFn: () => r.run(),
|
|
1486
|
+
...this.options.staleTime !== void 0 ? {
|
|
1487
|
+
staleTime: this.options.staleTime
|
|
1488
|
+
} : {},
|
|
1489
|
+
...this.options.gcTime !== void 0 ? {
|
|
1490
|
+
gcTime: this.options.gcTime
|
|
1491
|
+
} : {}
|
|
1492
|
+
});
|
|
1493
|
+
return this.getEntity(i.data);
|
|
1494
|
+
}
|
|
1495
|
+
useQuery(t, e) {
|
|
1496
|
+
const r = this.queryFnWrapper(t), i = Et({
|
|
1497
|
+
queryKey: r.queryKey,
|
|
1498
|
+
queryFn: () => r.run(),
|
|
1499
|
+
enabled: typeof this.options.enabled == "function" ? this.options.enabled(e, t) : this.options.enabled,
|
|
1500
|
+
...this.options.staleTime !== void 0 ? {
|
|
1501
|
+
staleTime: this.options.staleTime
|
|
1502
|
+
} : {},
|
|
1503
|
+
...this.options.gcTime !== void 0 ? {
|
|
1504
|
+
gcTime: this.options.gcTime
|
|
1505
|
+
} : {}
|
|
1506
|
+
});
|
|
1507
|
+
return i.data ? this.getEntity(i.data) : null;
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
var dt = { exports: {} }, rt = {};
|
|
1511
|
+
/**
|
|
1512
|
+
* @license React
|
|
1513
|
+
* react-jsx-runtime.production.js
|
|
1514
|
+
*
|
|
1515
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1516
|
+
*
|
|
1517
|
+
* This source code is licensed under the MIT license found in the
|
|
1518
|
+
* LICENSE file in the root directory of this source tree.
|
|
1519
|
+
*/
|
|
1520
|
+
var Wt;
|
|
1521
|
+
function Be() {
|
|
1522
|
+
if (Wt) return rt;
|
|
1523
|
+
Wt = 1;
|
|
1524
|
+
var n = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
1525
|
+
function e(r, i, h) {
|
|
1526
|
+
var b = null;
|
|
1527
|
+
if (h !== void 0 && (b = "" + h), i.key !== void 0 && (b = "" + i.key), "key" in i) {
|
|
1528
|
+
h = {};
|
|
1529
|
+
for (var B in i)
|
|
1530
|
+
B !== "key" && (h[B] = i[B]);
|
|
1531
|
+
} else h = i;
|
|
1532
|
+
return i = h.ref, {
|
|
1533
|
+
$$typeof: n,
|
|
1534
|
+
type: r,
|
|
1535
|
+
key: b,
|
|
1536
|
+
ref: i !== void 0 ? i : null,
|
|
1537
|
+
props: h
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
return rt.Fragment = t, rt.jsx = e, rt.jsxs = e, rt;
|
|
1541
|
+
}
|
|
1542
|
+
var nt = {};
|
|
1543
|
+
/**
|
|
1544
|
+
* @license React
|
|
1545
|
+
* react-jsx-runtime.development.js
|
|
1546
|
+
*
|
|
1547
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1548
|
+
*
|
|
1549
|
+
* This source code is licensed under the MIT license found in the
|
|
1550
|
+
* LICENSE file in the root directory of this source tree.
|
|
1551
|
+
*/
|
|
1552
|
+
var Ut;
|
|
1553
|
+
function $e() {
|
|
1554
|
+
return Ut || (Ut = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
1555
|
+
function n(o) {
|
|
1556
|
+
if (o == null) return null;
|
|
1557
|
+
if (typeof o == "function")
|
|
1558
|
+
return o.$$typeof === v ? null : o.displayName || o.name || null;
|
|
1559
|
+
if (typeof o == "string") return o;
|
|
1560
|
+
switch (o) {
|
|
1561
|
+
case y:
|
|
1562
|
+
return "Fragment";
|
|
1563
|
+
case c:
|
|
1564
|
+
return "Profiler";
|
|
1565
|
+
case f:
|
|
1566
|
+
return "StrictMode";
|
|
1567
|
+
case j:
|
|
1568
|
+
return "Suspense";
|
|
1569
|
+
case N:
|
|
1570
|
+
return "SuspenseList";
|
|
1571
|
+
case g:
|
|
1572
|
+
return "Activity";
|
|
1573
|
+
}
|
|
1574
|
+
if (typeof o == "object")
|
|
1575
|
+
switch (typeof o.tag == "number" && console.error(
|
|
1576
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
1577
|
+
), o.$$typeof) {
|
|
1578
|
+
case a:
|
|
1579
|
+
return "Portal";
|
|
1580
|
+
case A:
|
|
1581
|
+
return (o.displayName || "Context") + ".Provider";
|
|
1582
|
+
case l:
|
|
1583
|
+
return (o._context.displayName || "Context") + ".Consumer";
|
|
1584
|
+
case D:
|
|
1585
|
+
var _ = o.render;
|
|
1586
|
+
return o = o.displayName, o || (o = _.displayName || _.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
|
|
1587
|
+
case O:
|
|
1588
|
+
return _ = o.displayName || null, _ !== null ? _ : n(o.type) || "Memo";
|
|
1589
|
+
case E:
|
|
1590
|
+
_ = o._payload, o = o._init;
|
|
1591
|
+
try {
|
|
1592
|
+
return n(o(_));
|
|
1593
|
+
} catch {
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
return null;
|
|
1597
|
+
}
|
|
1598
|
+
function t(o) {
|
|
1599
|
+
return "" + o;
|
|
1600
|
+
}
|
|
1601
|
+
function e(o) {
|
|
1602
|
+
try {
|
|
1603
|
+
t(o);
|
|
1604
|
+
var _ = !1;
|
|
1605
|
+
} catch {
|
|
1606
|
+
_ = !0;
|
|
1607
|
+
}
|
|
1608
|
+
if (_) {
|
|
1609
|
+
_ = console;
|
|
1610
|
+
var I = _.error, F = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
|
|
1611
|
+
return I.call(
|
|
1612
|
+
_,
|
|
1613
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
1614
|
+
F
|
|
1615
|
+
), t(o);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
function r(o) {
|
|
1619
|
+
if (o === y) return "<>";
|
|
1620
|
+
if (typeof o == "object" && o !== null && o.$$typeof === E)
|
|
1621
|
+
return "<...>";
|
|
1622
|
+
try {
|
|
1623
|
+
var _ = n(o);
|
|
1624
|
+
return _ ? "<" + _ + ">" : "<...>";
|
|
1625
|
+
} catch {
|
|
1626
|
+
return "<...>";
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
function i() {
|
|
1630
|
+
var o = T.A;
|
|
1631
|
+
return o === null ? null : o.getOwner();
|
|
1632
|
+
}
|
|
1633
|
+
function h() {
|
|
1634
|
+
return Error("react-stack-top-frame");
|
|
1635
|
+
}
|
|
1636
|
+
function b(o) {
|
|
1637
|
+
if (d.call(o, "key")) {
|
|
1638
|
+
var _ = Object.getOwnPropertyDescriptor(o, "key").get;
|
|
1639
|
+
if (_ && _.isReactWarning) return !1;
|
|
1640
|
+
}
|
|
1641
|
+
return o.key !== void 0;
|
|
1642
|
+
}
|
|
1643
|
+
function B(o, _) {
|
|
1644
|
+
function I() {
|
|
1645
|
+
w || (w = !0, console.error(
|
|
1646
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
1647
|
+
_
|
|
1648
|
+
));
|
|
1649
|
+
}
|
|
1650
|
+
I.isReactWarning = !0, Object.defineProperty(o, "key", {
|
|
1651
|
+
get: I,
|
|
1652
|
+
configurable: !0
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
function Q() {
|
|
1656
|
+
var o = n(this.type);
|
|
1657
|
+
return s[o] || (s[o] = !0, console.error(
|
|
1658
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
1659
|
+
)), o = this.props.ref, o !== void 0 ? o : null;
|
|
1660
|
+
}
|
|
1661
|
+
function Y(o, _, I, F, x, C, k, $) {
|
|
1662
|
+
return I = C.ref, o = {
|
|
1663
|
+
$$typeof: U,
|
|
1664
|
+
type: o,
|
|
1665
|
+
key: _,
|
|
1666
|
+
props: C,
|
|
1667
|
+
_owner: x
|
|
1668
|
+
}, (I !== void 0 ? I : null) !== null ? Object.defineProperty(o, "ref", {
|
|
1669
|
+
enumerable: !1,
|
|
1670
|
+
get: Q
|
|
1671
|
+
}) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
|
|
1672
|
+
configurable: !1,
|
|
1673
|
+
enumerable: !1,
|
|
1674
|
+
writable: !0,
|
|
1675
|
+
value: 0
|
|
1676
|
+
}), Object.defineProperty(o, "_debugInfo", {
|
|
1677
|
+
configurable: !1,
|
|
1678
|
+
enumerable: !1,
|
|
1679
|
+
writable: !0,
|
|
1680
|
+
value: null
|
|
1681
|
+
}), Object.defineProperty(o, "_debugStack", {
|
|
1682
|
+
configurable: !1,
|
|
1683
|
+
enumerable: !1,
|
|
1684
|
+
writable: !0,
|
|
1685
|
+
value: k
|
|
1686
|
+
}), Object.defineProperty(o, "_debugTask", {
|
|
1687
|
+
configurable: !1,
|
|
1688
|
+
enumerable: !1,
|
|
1689
|
+
writable: !0,
|
|
1690
|
+
value: $
|
|
1691
|
+
}), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
|
|
1692
|
+
}
|
|
1693
|
+
function L(o, _, I, F, x, C, k, $) {
|
|
1694
|
+
var u = _.children;
|
|
1695
|
+
if (u !== void 0)
|
|
1696
|
+
if (F)
|
|
1697
|
+
if (M(u)) {
|
|
1698
|
+
for (F = 0; F < u.length; F++)
|
|
1699
|
+
H(u[F]);
|
|
1700
|
+
Object.freeze && Object.freeze(u);
|
|
1701
|
+
} else
|
|
1702
|
+
console.error(
|
|
1703
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
1704
|
+
);
|
|
1705
|
+
else H(u);
|
|
1706
|
+
if (d.call(_, "key")) {
|
|
1707
|
+
u = n(o);
|
|
1708
|
+
var S = Object.keys(_).filter(function(se) {
|
|
1709
|
+
return se !== "key";
|
|
1710
|
+
});
|
|
1711
|
+
F = 0 < S.length ? "{key: someKey, " + S.join(": ..., ") + ": ...}" : "{key: someKey}", p[u + F] || (S = 0 < S.length ? "{" + S.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
1712
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
1713
|
+
let props = %s;
|
|
1714
|
+
<%s {...props} />
|
|
1715
|
+
React keys must be passed directly to JSX without using spread:
|
|
1716
|
+
let props = %s;
|
|
1717
|
+
<%s key={someKey} {...props} />`,
|
|
1718
|
+
F,
|
|
1719
|
+
u,
|
|
1720
|
+
S,
|
|
1721
|
+
u
|
|
1722
|
+
), p[u + F] = !0);
|
|
1723
|
+
}
|
|
1724
|
+
if (u = null, I !== void 0 && (e(I), u = "" + I), b(_) && (e(_.key), u = "" + _.key), "key" in _) {
|
|
1725
|
+
I = {};
|
|
1726
|
+
for (var P in _)
|
|
1727
|
+
P !== "key" && (I[P] = _[P]);
|
|
1728
|
+
} else I = _;
|
|
1729
|
+
return u && B(
|
|
1730
|
+
I,
|
|
1731
|
+
typeof o == "function" ? o.displayName || o.name || "Unknown" : o
|
|
1732
|
+
), Y(
|
|
1733
|
+
o,
|
|
1734
|
+
u,
|
|
1735
|
+
C,
|
|
1736
|
+
x,
|
|
1737
|
+
i(),
|
|
1738
|
+
I,
|
|
1739
|
+
k,
|
|
1740
|
+
$
|
|
1741
|
+
);
|
|
1742
|
+
}
|
|
1743
|
+
function H(o) {
|
|
1744
|
+
typeof o == "object" && o !== null && o.$$typeof === U && o._store && (o._store.validated = 1);
|
|
1745
|
+
}
|
|
1746
|
+
var K = de, U = Symbol.for("react.transitional.element"), a = Symbol.for("react.portal"), y = Symbol.for("react.fragment"), f = Symbol.for("react.strict_mode"), c = Symbol.for("react.profiler"), l = Symbol.for("react.consumer"), A = Symbol.for("react.context"), D = Symbol.for("react.forward_ref"), j = Symbol.for("react.suspense"), N = Symbol.for("react.suspense_list"), O = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), g = Symbol.for("react.activity"), v = Symbol.for("react.client.reference"), T = K.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, d = Object.prototype.hasOwnProperty, M = Array.isArray, R = console.createTask ? console.createTask : function() {
|
|
1747
|
+
return null;
|
|
1748
|
+
};
|
|
1749
|
+
K = {
|
|
1750
|
+
react_stack_bottom_frame: function(o) {
|
|
1751
|
+
return o();
|
|
1752
|
+
}
|
|
1753
|
+
};
|
|
1754
|
+
var w, s = {}, q = K.react_stack_bottom_frame.bind(
|
|
1755
|
+
K,
|
|
1756
|
+
h
|
|
1757
|
+
)(), m = R(r(h)), p = {};
|
|
1758
|
+
nt.Fragment = y, nt.jsx = function(o, _, I, F, x) {
|
|
1759
|
+
var C = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
1760
|
+
return L(
|
|
1761
|
+
o,
|
|
1762
|
+
_,
|
|
1763
|
+
I,
|
|
1764
|
+
!1,
|
|
1765
|
+
F,
|
|
1766
|
+
x,
|
|
1767
|
+
C ? Error("react-stack-top-frame") : q,
|
|
1768
|
+
C ? R(r(o)) : m
|
|
1769
|
+
);
|
|
1770
|
+
}, nt.jsxs = function(o, _, I, F, x) {
|
|
1771
|
+
var C = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
1772
|
+
return L(
|
|
1773
|
+
o,
|
|
1774
|
+
_,
|
|
1775
|
+
I,
|
|
1776
|
+
!0,
|
|
1777
|
+
F,
|
|
1778
|
+
x,
|
|
1779
|
+
C ? Error("react-stack-top-frame") : q,
|
|
1780
|
+
C ? R(r(o)) : m
|
|
1781
|
+
);
|
|
1782
|
+
};
|
|
1783
|
+
})()), nt;
|
|
1784
|
+
}
|
|
1785
|
+
var Vt;
|
|
1786
|
+
function Le() {
|
|
1787
|
+
return Vt || (Vt = 1, process.env.NODE_ENV === "production" ? dt.exports = Be() : dt.exports = $e()), dt.exports;
|
|
1788
|
+
}
|
|
1789
|
+
var He = Le();
|
|
1790
|
+
function Je() {
|
|
1791
|
+
const n = pe(null);
|
|
1792
|
+
return {
|
|
1793
|
+
Provider: ({
|
|
1794
|
+
children: t,
|
|
1795
|
+
client: e
|
|
1796
|
+
}) => /* @__PURE__ */ He.jsx(n.Provider, { value: e, children: t }),
|
|
1797
|
+
useContext: () => {
|
|
1798
|
+
const t = me(n);
|
|
1799
|
+
if (!t)
|
|
1800
|
+
throw new Error("useMQ must be used within an MQProvider");
|
|
1801
|
+
return t;
|
|
1802
|
+
}
|
|
1803
|
+
};
|
|
1804
|
+
}
|
|
1805
|
+
export {
|
|
1806
|
+
Qe as BatchMutationBase,
|
|
1807
|
+
Jt as BatchUpdateMutation,
|
|
1808
|
+
Lt as CreateMutation,
|
|
1809
|
+
zt as DeleteMutation,
|
|
1810
|
+
jt as Entity,
|
|
1811
|
+
_t as EntityCollection,
|
|
1812
|
+
Tt as EntityMutationBase,
|
|
1813
|
+
pt as EntityState,
|
|
1814
|
+
Ge as MQClient,
|
|
1815
|
+
et as MQClientAccessor,
|
|
1816
|
+
gt as MutationBase,
|
|
1817
|
+
st as OptimisticMutationErrorStrategy,
|
|
1818
|
+
G as OptimisticMutationInvalidationStrategy,
|
|
1819
|
+
Zt as QueryBase,
|
|
1820
|
+
ee as QueryFragmentMany,
|
|
1821
|
+
ne as QueryFragmentOne,
|
|
1822
|
+
ie as QueryMany,
|
|
1823
|
+
te as QueryManyBase,
|
|
1824
|
+
oe as QueryOne,
|
|
1825
|
+
re as QueryOneBase,
|
|
1826
|
+
Xt as UpdateMutation,
|
|
1827
|
+
Je as createReactContext,
|
|
1828
|
+
Ve as generateEntityId,
|
|
1829
|
+
bt as invalidateQueryByHash
|
|
1830
|
+
};
|