rest-client-vue 1.1.1-b10 → 1.1.1-b12
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/rest-client-vue.js
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
var Ee = Object.defineProperty;
|
2
|
-
var we = (
|
3
|
-
var ae = (
|
4
|
-
if (!s.has(
|
5
|
-
throw TypeError("Cannot " +
|
2
|
+
var we = (h, s, g) => s in h ? Ee(h, s, { enumerable: !0, configurable: !0, writable: !0, value: g }) : h[s] = g;
|
3
|
+
var ae = (h, s, g) => (we(h, typeof s != "symbol" ? s + "" : s, g), g), Te = (h, s, g) => {
|
4
|
+
if (!s.has(h))
|
5
|
+
throw TypeError("Cannot " + g);
|
6
6
|
};
|
7
|
-
var Q = (
|
8
|
-
if (s.has(
|
7
|
+
var Q = (h, s, g) => (Te(h, s, "read from private field"), g ? g.call(h) : s.get(h)), Se = (h, s, g) => {
|
8
|
+
if (s.has(h))
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
10
|
-
s instanceof WeakSet ? s.add(
|
10
|
+
s instanceof WeakSet ? s.add(h) : s.set(h, g);
|
11
11
|
};
|
12
12
|
import a from "lodash";
|
13
13
|
import { v4 as H } from "uuid";
|
14
|
-
import { ref as
|
15
|
-
import
|
14
|
+
import { ref as y, toRef as ie, computed as R, watch as T, nextTick as Le } from "vue";
|
15
|
+
import x from "axios";
|
16
16
|
import me from "jsog";
|
17
17
|
import X from "json-stringify-deterministic";
|
18
18
|
import { defineStore as pe } from "pinia";
|
@@ -21,39 +21,50 @@ const ye = {
|
|
21
21
|
useVueLogger: !1
|
22
22
|
};
|
23
23
|
class _e extends Error {
|
24
|
-
constructor(
|
25
|
-
super(
|
24
|
+
constructor(g, I = void 0, e = void 0) {
|
25
|
+
super(g);
|
26
26
|
ae(this, "context");
|
27
27
|
ae(this, "innerError");
|
28
|
-
this.context =
|
28
|
+
this.context = I, this.innerError = e;
|
29
29
|
}
|
30
30
|
}
|
31
|
-
var
|
31
|
+
var B;
|
32
32
|
class Ie {
|
33
33
|
constructor() {
|
34
|
-
Se(this,
|
34
|
+
Se(this, B, {});
|
35
35
|
}
|
36
36
|
clearAllStores() {
|
37
|
-
for (const s in Q(this,
|
38
|
-
Q(this,
|
37
|
+
for (const s in Q(this, B))
|
38
|
+
Q(this, B)[s].clear();
|
39
39
|
}
|
40
40
|
destroyStore(s) {
|
41
|
-
Q(this,
|
41
|
+
Q(this, B)[s] && (Q(this, B)[s].$dispose(), delete Q(this, B)[s]);
|
42
42
|
}
|
43
43
|
getStore(s) {
|
44
|
-
return Q(this,
|
44
|
+
return Q(this, B)[s];
|
45
45
|
}
|
46
|
-
registerStore(s,
|
47
|
-
Q(this,
|
46
|
+
registerStore(s, g) {
|
47
|
+
Q(this, B)[s] = g;
|
48
48
|
}
|
49
49
|
}
|
50
|
-
|
51
|
-
function v(
|
52
|
-
return a.get(
|
50
|
+
B = new WeakMap();
|
51
|
+
function v(h, s) {
|
52
|
+
return a.get(h, (s == null ? void 0 : s.idProperty) || "_id");
|
53
53
|
}
|
54
|
-
function $e(
|
55
|
-
|
56
|
-
|
54
|
+
function $e(h, s) {
|
55
|
+
const g = a.map(
|
56
|
+
s,
|
57
|
+
(I, e) => I != null ? `${encodeURIComponent(e)}=${encodeURIComponent(I)}` : null
|
58
|
+
).filter((I) => I != null).join("&");
|
59
|
+
if (g.length > 0) {
|
60
|
+
const I = h.indexOf("?");
|
61
|
+
return I == h.length - 1 ? `${h}${g}` : I >= 0 ? `${h}&${g}` : `${h}?${g}`;
|
62
|
+
} else
|
63
|
+
return h;
|
64
|
+
}
|
65
|
+
function Pe(h, s) {
|
66
|
+
var g;
|
67
|
+
return h && ((g = s.filter) != null && g.resourceIds) && !s.order ? s.filter.resourceIds.map((I) => h.find((e) => v(e, s) == I)).filter((I) => I != null) : h;
|
57
68
|
}
|
58
69
|
const De = {
|
59
70
|
detail: {
|
@@ -81,7 +92,7 @@ const De = {
|
|
81
92
|
[{ path: "history.creation.timestamp" }, "desc"],
|
82
93
|
[{ path: "history.creation.indexInBatch" }, "desc"]
|
83
94
|
]
|
84
|
-
},
|
95
|
+
}, Y = {
|
85
96
|
resources: [],
|
86
97
|
remoteCollectionSize: null,
|
87
98
|
status: "NotLoaded",
|
@@ -89,14 +100,14 @@ const De = {
|
|
89
100
|
detailSelection: [],
|
90
101
|
invalidResources: [],
|
91
102
|
transientData: {}
|
92
|
-
},
|
103
|
+
}, ne = {
|
93
104
|
editingDetailSelection: !1,
|
94
105
|
batchSaveAttempted: !1,
|
95
106
|
editors: [],
|
96
107
|
listNavigators: {}
|
97
|
-
},
|
108
|
+
}, xe = (h, s) => {
|
98
109
|
s = a.merge({}, De, s);
|
99
|
-
const
|
110
|
+
const g = pe(h, {
|
100
111
|
state: () => ({
|
101
112
|
idProperty: s.idProperty,
|
102
113
|
filter: s.filter,
|
@@ -104,8 +115,8 @@ const De = {
|
|
104
115
|
propertyBlacklist: s.propertyBlacklist || null,
|
105
116
|
referencePathsToExpand: s.referencePathsToExpand || null,
|
106
117
|
restCollectionUrl: s.restCollectionUrl,
|
107
|
-
...
|
108
|
-
...
|
118
|
+
...Y,
|
119
|
+
...ne
|
109
120
|
}),
|
110
121
|
getters: {
|
111
122
|
/**
|
@@ -119,8 +130,8 @@ const De = {
|
|
119
130
|
(l = e.filter) != null && l.namedFilter && (r.namedFilter = e.filter.namedFilter);
|
120
131
|
const t = [];
|
121
132
|
if ((u = e.filter) != null && u.resourceIds && t.push({ l: { path: e.idProperty }, r: { constant: e.filter.resourceIds }, operator: "in" }), (c = e.filter) != null && c.query && t.push((d = e.filter) == null ? void 0 : d.query), t.length > 0) {
|
122
|
-
const
|
123
|
-
r.q = X(
|
133
|
+
const p = t.length == 1 ? t[0] : { and: t };
|
134
|
+
r.q = X(p);
|
124
135
|
}
|
125
136
|
return e.order && (r.o = X(e.order)), e.propertyBlacklist && (r.ex = X(e.propertyBlacklist)), e.referencePathsToExpand && (r.r = X(e.referencePathsToExpand)), r;
|
126
137
|
}
|
@@ -135,10 +146,10 @@ const De = {
|
|
135
146
|
* Configuration is retained, but REST collection contents and contextual state are reset.
|
136
147
|
*/
|
137
148
|
reset() {
|
138
|
-
for (const e in
|
139
|
-
this[e] =
|
140
|
-
for (const e in
|
141
|
-
this[e] =
|
149
|
+
for (const e in Y)
|
150
|
+
this[e] = Y[e];
|
151
|
+
for (const e in ne)
|
152
|
+
this[e] = ne[e];
|
142
153
|
},
|
143
154
|
/**
|
144
155
|
* Reset the store to its initial state, but retain transient data if appropriate.
|
@@ -238,8 +249,8 @@ const De = {
|
|
238
249
|
* Configuration and contextual state are retained, but REST collection contents are reset.
|
239
250
|
*/
|
240
251
|
clear() {
|
241
|
-
for (const e in
|
242
|
-
this[e] =
|
252
|
+
for (const e in Y)
|
253
|
+
this[e] = Y[e];
|
243
254
|
},
|
244
255
|
/**
|
245
256
|
* Clear the collection's contents, but retain transient data if appropriate.
|
@@ -290,32 +301,29 @@ const De = {
|
|
290
301
|
* @param loadOptions Pagination options that may override the defaults.
|
291
302
|
*/
|
292
303
|
async _loadResources(e, r, t) {
|
293
|
-
var
|
304
|
+
var L, A, N, k, O;
|
294
305
|
const l = e == 0;
|
295
|
-
if (this.status = l ? "Loading" : "LoadingMore", this._loadOffset = e, ((
|
306
|
+
if (this.status = l ? "Loading" : "LoadingMore", this._loadOffset = e, ((L = this.filter) == null ? void 0 : L.query) === !1) {
|
296
307
|
this.resources = [], this.remoteCollectionSize = 0;
|
297
308
|
return;
|
298
309
|
}
|
299
|
-
const u = this.fixedQueryParams, c = a.cloneDeep(u), d = l ? (
|
300
|
-
|
301
|
-
const
|
302
|
-
c,
|
303
|
-
(g, m) => g != null ? `${encodeURIComponent(m)}=${encodeURIComponent(g)}` : null
|
304
|
-
).filter((g) => g != null).join("&"), L = a.isEmpty(U) ? s.restCollectionUrl : `${s.restCollectionUrl}?${U}`;
|
310
|
+
const u = this.fixedQueryParams, c = a.cloneDeep(u), d = l ? (A = this.filter) != null && A.resourceIds && !this.order ? null : t.firstPageSize || ((N = s.loading) == null ? void 0 : N.firstPageSize) || t.pageSize || ((k = s.loading) == null ? void 0 : k.pageSize) || null : t.pageSize || ((O = s.loading) == null ? void 0 : O.pageSize) || null, p = d != null || s.limit != null ? a.min(a.filter([d, s.limit], (P) => P != null)) : void 0;
|
311
|
+
p != null ? (c.offset = e, c.limit = p) : e != 0 && (c.offset = e);
|
312
|
+
const C = $e(s.restCollectionUrl, c);
|
305
313
|
try {
|
306
|
-
const
|
307
|
-
if (r != this._loadId || e != this._loadOffset || !a.isEqual(u,
|
314
|
+
const P = await x.get(C), D = this.fixedQueryParams;
|
315
|
+
if (r != this._loadId || e != this._loadOffset || !a.isEqual(u, D))
|
308
316
|
console.log(`Discarding resources fetched by obsolete query from ${s.restCollectionUrl}.`);
|
309
317
|
else {
|
310
|
-
const
|
318
|
+
const S = me.decode(a.get(P, "data.data", [])), $ = (l ? 0 : this.resources.length) + S.length, E = p == null || S.length < p || s.limit && $ >= s.limit;
|
311
319
|
console.log(
|
312
|
-
`Loaded ${
|
320
|
+
`Loaded ${S.length}${l ? "" : " more"} resources from ${s.restCollectionUrl}`
|
313
321
|
), l && (this.resources = []);
|
314
|
-
const
|
315
|
-
this.resources =
|
322
|
+
const U = [...this.resources, ...S.map((W) => Object.freeze(W))];
|
323
|
+
this.resources = Pe(U, this), a.get(P, "data.totalCollectionSize") ? this.remoteCollectionSize = a.get(P, "data.totalCollectionSize") : this.remoteCollectionSize = null, this.status = E ? "Loaded" : "LoadingMore", E || this._loadResources(this.resources.length, r, t);
|
316
324
|
}
|
317
|
-
} catch (
|
318
|
-
console.log(`Error while loading resources (URL="${
|
325
|
+
} catch (P) {
|
326
|
+
console.log(`Error while loading resources (URL="${C}"):`, P), this.clearRetainingTransientData(), this.status = "Failed";
|
319
327
|
}
|
320
328
|
},
|
321
329
|
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
@@ -333,9 +341,9 @@ const De = {
|
|
333
341
|
async checkForDeletedResource(e) {
|
334
342
|
let r;
|
335
343
|
try {
|
336
|
-
r = await
|
344
|
+
r = await x.get(`${s.restCollectionUrl}/${e}`);
|
337
345
|
} catch (t) {
|
338
|
-
|
346
|
+
x.isAxiosError(t) && (r = t.response);
|
339
347
|
}
|
340
348
|
return r && r.status == 404 ? (this.recordDeletion(e), !0) : !1;
|
341
349
|
},
|
@@ -420,7 +428,7 @@ const De = {
|
|
420
428
|
const t = a.map(
|
421
429
|
r,
|
422
430
|
(c, d) => c != null ? `${encodeURIComponent(d)}=${encodeURIComponent(c)}` : null
|
423
|
-
).filter((c) => c != null).join("&"), l = a.isEmpty(t) ? `${s.restCollectionUrl}/${e}` : `${s.restCollectionUrl}/${e}?${t}`, u = await
|
431
|
+
).filter((c) => c != null).join("&"), l = a.isEmpty(t) ? `${s.restCollectionUrl}/${e}` : `${s.restCollectionUrl}/${e}?${t}`, u = await x.get(l);
|
424
432
|
if (u.status == 200) {
|
425
433
|
const c = u.data;
|
426
434
|
return this.recordUpdate(c), c;
|
@@ -447,7 +455,7 @@ const De = {
|
|
447
455
|
* @param resourceId The ID of the resource to delete.
|
448
456
|
*/
|
449
457
|
async deleteResource(e) {
|
450
|
-
if ((await
|
458
|
+
if ((await x.delete(`${s.restCollectionUrl}/${e}`)).status == 200 && ["Loaded", "LoadingMore"].includes(this.status)) {
|
451
459
|
let t = this.resources.findIndex((l) => v(l, this) == e);
|
452
460
|
t >= 0 && this.resources.splice(t, 1), t = this.selection.findIndex((l) => v(l, this) == e), t >= 0 && this.selection.splice(t, 1), t = this.detailSelection.findIndex((l) => v(l, this) == e), t >= 0 && (this.detailSelection.splice(t, 1), this.detailSelection.length == 0 && (this.editingDetailSelection = s.detail.autoEdit)), s.limitTransientDataToLocalCollection && delete this.transientData[e];
|
453
461
|
}
|
@@ -464,7 +472,7 @@ const De = {
|
|
464
472
|
* the operation failed.
|
465
473
|
*/
|
466
474
|
async saveResource(e) {
|
467
|
-
const r = v(e, this), t = r == null, l = await
|
475
|
+
const r = v(e, this), t = r == null, l = await x({
|
468
476
|
method: t ? "post" : "put",
|
469
477
|
url: t ? s.restCollectionUrl : `${s.restCollectionUrl}/${r}`,
|
470
478
|
data: e
|
@@ -486,7 +494,7 @@ const De = {
|
|
486
494
|
* @returns An array of refreshed local resources, one for each remote resource whose save operation succeeded.
|
487
495
|
*/
|
488
496
|
async saveResources(e) {
|
489
|
-
const r = await
|
497
|
+
const r = await x({
|
490
498
|
method: "put",
|
491
499
|
url: s.restCollectionUrl,
|
492
500
|
data: e
|
@@ -494,8 +502,8 @@ const De = {
|
|
494
502
|
if (r.status == 200) {
|
495
503
|
const t = r.data || [], l = [];
|
496
504
|
for (const [u, c] of t.entries()) {
|
497
|
-
const d = v(e[u], this) == null,
|
498
|
-
d && this.recordInsertion(
|
505
|
+
const d = v(e[u], this) == null, p = v(c, this), C = p ? await this.refreshResource(p) : null;
|
506
|
+
d && this.recordInsertion(C || c), l.push(C || Object.freeze(c));
|
499
507
|
}
|
500
508
|
return l;
|
501
509
|
}
|
@@ -560,7 +568,7 @@ const De = {
|
|
560
568
|
let c = e;
|
561
569
|
if (t) {
|
562
570
|
const d = a.difference(e, u);
|
563
|
-
d.length > 0 && (c = u.concat(d).filter((
|
571
|
+
d.length > 0 && (c = u.concat(d).filter((p) => p != null));
|
564
572
|
}
|
565
573
|
a.isEqual(u, c) || this.setSelection(c, l);
|
566
574
|
},
|
@@ -678,225 +686,225 @@ const De = {
|
|
678
686
|
});
|
679
687
|
return (() => {
|
680
688
|
const e = (r, t) => {
|
681
|
-
const l =
|
682
|
-
return
|
689
|
+
const l = g(r, t);
|
690
|
+
return se.registerStore(l.$id, l), l;
|
683
691
|
};
|
684
|
-
return e.$id =
|
692
|
+
return e.$id = g.$id, e;
|
685
693
|
})();
|
686
|
-
},
|
694
|
+
}, se = new Ie(), Qe = (h = {}) => {
|
687
695
|
var ue, de, he, fe;
|
688
696
|
const {
|
689
697
|
collectionId: s,
|
690
|
-
draftBatchId:
|
691
|
-
enabled:
|
698
|
+
draftBatchId: g,
|
699
|
+
enabled: I,
|
692
700
|
resourceType: e,
|
693
701
|
options: r
|
694
|
-
} =
|
695
|
-
() => u.value == null && l.value != null &&
|
696
|
-
),
|
697
|
-
function
|
702
|
+
} = h, t = y(void 0), l = y(s), u = y(g), c = y(I ?? !0), d = y([ie(e)]), p = y(r), C = R(() => u.value), L = y(c.value), A = y(H()), N = y((de = (ue = p.value) == null ? void 0 : ue.filter) == null ? void 0 : de.resourceIds), k = y((fe = (he = p.value) == null ? void 0 : he.filter) == null ? void 0 : fe.query), O = R(
|
703
|
+
() => u.value == null && l.value != null && se.getStore(l.value) != null
|
704
|
+
), P = y(O.value), D = R(() => E("status", "Uninitialized"));
|
705
|
+
function S(i) {
|
698
706
|
if (t.value)
|
699
707
|
return i(t.value);
|
700
708
|
}
|
701
|
-
async function
|
709
|
+
async function $(i) {
|
702
710
|
if (t.value)
|
703
711
|
return await i(t.value);
|
704
712
|
}
|
705
|
-
function
|
713
|
+
function E(i, o) {
|
706
714
|
if (t.value)
|
707
715
|
return t.value[i];
|
708
|
-
if (
|
709
|
-
return
|
716
|
+
if (o !== void 0)
|
717
|
+
return o;
|
710
718
|
throw "Attempted to use a REST collection store that has not been created, with no default value.";
|
711
719
|
}
|
712
|
-
const
|
713
|
-
var
|
720
|
+
const U = (i = {}) => {
|
721
|
+
var te, ve, ge, Re;
|
714
722
|
const {
|
715
|
-
collectionId:
|
716
|
-
draftBatchId:
|
717
|
-
enabled:
|
723
|
+
collectionId: o,
|
724
|
+
draftBatchId: w,
|
725
|
+
enabled: F,
|
718
726
|
resourceType: le,
|
719
|
-
options:
|
727
|
+
options: ee
|
720
728
|
} = i;
|
721
|
-
l.value =
|
729
|
+
l.value = o, u.value = w, c.value = F ?? !0, d.value = [ie(le)], ee != null && (p.value = ee, N.value = (ve = (te = p.value) == null ? void 0 : te.filter) == null ? void 0 : ve.resourceIds, k.value = (Re = (ge = p.value) == null ? void 0 : ge.filter) == null ? void 0 : Re.query), A.value = H(), W(c.value);
|
722
730
|
}, W = async (i) => {
|
723
|
-
i != L.value && (L.value = i, i && (
|
731
|
+
i != L.value && (L.value = i, i && (K(), z()));
|
732
|
+
}, re = async (i) => {
|
733
|
+
N.value = i, await $(async (o) => await o.setFilterResourceIds(N.value || null));
|
724
734
|
}, J = async (i) => {
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
const n = i, E = R(() => a.isFunction(n) ? p.value ? n(p.value) : null : n);
|
729
|
-
await C((q) => q.setQuery(E.value || null));
|
735
|
+
if (k.value = i, D.value != "Uninitialized") {
|
736
|
+
const o = i, w = R(() => a.isFunction(o) ? m.value ? o(m.value) : null : o);
|
737
|
+
await $((F) => F.setQuery(w.value || null));
|
730
738
|
}
|
731
|
-
},
|
732
|
-
|
733
|
-
filter: { resourceIds:
|
739
|
+
}, K = () => {
|
740
|
+
p.value = a.merge({}, p.value || {}, {
|
741
|
+
filter: { resourceIds: N.value, query: k.value }
|
734
742
|
});
|
735
|
-
},
|
743
|
+
}, m = R(
|
736
744
|
() => d.value[0].value || void 0
|
737
745
|
), _ = function(i) {
|
738
|
-
const
|
746
|
+
const o = a.get(i, "filter.query"), w = a.get(i, "propertyBlacklist"), F = a.get(i, "referencePathsToExpand"), le = a.isFunction(o) ? o(m.value) : o, ee = m.value ? a.isFunction(w) ? w(m.value) : w || [] : [], te = m.value ? a.isFunction(F) ? F(m.value) : F || [] : [];
|
739
747
|
return {
|
740
748
|
...a.cloneDeep(i || {}),
|
741
749
|
filter: {
|
742
750
|
...a.cloneDeep((i == null ? void 0 : i.filter) || {}),
|
743
751
|
query: le
|
744
752
|
},
|
745
|
-
propertyBlacklist:
|
746
|
-
referencePathsToExpand:
|
753
|
+
propertyBlacklist: ee,
|
754
|
+
referencePathsToExpand: te
|
747
755
|
};
|
748
|
-
},
|
749
|
-
if (
|
750
|
-
return
|
751
|
-
if (!
|
752
|
-
return !
|
753
|
-
}),
|
756
|
+
}, q = R(() => _(p.value)), M = R(() => {
|
757
|
+
if (q.value.restCollectionUrl !== void 0)
|
758
|
+
return q.value.restCollectionUrl;
|
759
|
+
if (!P.value)
|
760
|
+
return !m.value || !m.value.collectionName ? null : C.value ? `${V.config.apiBaseUrl}/draft-batches/${C.value}/${m.value.collectionName}` : `${V.config.apiBaseUrl}/${m.value.collectionName}`;
|
761
|
+
}), n = R(() => {
|
754
762
|
var i;
|
755
|
-
if (
|
763
|
+
if (m.value)
|
756
764
|
return a.mergeWith(
|
757
765
|
a.cloneDeep(De),
|
758
|
-
|
766
|
+
q.value,
|
759
767
|
{
|
760
|
-
idProperty: (i =
|
768
|
+
idProperty: (i = m.value) == null ? void 0 : i.idProperty,
|
761
769
|
restCollectionUrl: M.value || ""
|
762
770
|
},
|
763
|
-
(
|
764
|
-
if (a.isArray(
|
765
|
-
return
|
771
|
+
(o, w) => {
|
772
|
+
if (a.isArray(w) && w.length == 0 && (o == null || a.isArray(o)))
|
773
|
+
return w;
|
766
774
|
}
|
767
775
|
);
|
768
|
-
}),
|
776
|
+
}), f = y(0), b = R(
|
769
777
|
() => {
|
770
778
|
var i;
|
771
|
-
return
|
779
|
+
return f.value, l.value || m.value && ((i = m.value) == null ? void 0 : i.collectionName) && (C.value ? `draftBatches/${C.value}/${m.value.collectionName}/${A.value}` : `${m.value.collectionName}/${A.value}`) || null;
|
772
780
|
}
|
773
|
-
),
|
781
|
+
), z = () => {
|
774
782
|
if (L.value) {
|
775
783
|
let i = !1;
|
776
|
-
return
|
784
|
+
return m.value && b.value && (t.value = se.getStore(b.value), t.value ? i = !1 : n.value && (P.value = !1, t.value = xe(b.value, n.value)(), i = !0)), i;
|
777
785
|
} else
|
778
786
|
return !1;
|
779
787
|
}, G = () => {
|
780
|
-
|
788
|
+
b.value && l.value == b.value ? (t.value = void 0, z()) : (t.value = void 0, f.value = f.value + 1, z());
|
781
789
|
};
|
782
|
-
T(
|
783
|
-
a.isEqual(i,
|
784
|
-
}), T(L, (i,
|
785
|
-
i !=
|
786
|
-
}), T(
|
787
|
-
i && !
|
788
|
-
}), T(
|
789
|
-
a.isEqual(i,
|
790
|
-
}), T(
|
791
|
-
|
792
|
-
}), T(
|
793
|
-
a.isEqual(i,
|
790
|
+
T(C, (i, o) => {
|
791
|
+
a.isEqual(i, o) || G();
|
792
|
+
}), T(L, (i, o) => {
|
793
|
+
i != o && (i ? z() : t.value = void 0);
|
794
|
+
}), T(m, (i, o) => {
|
795
|
+
i && !o ? z() : !i && o || a.isEqual(i, o) || G();
|
796
|
+
}), T(n, (i, o) => {
|
797
|
+
a.isEqual(i, o) || G();
|
798
|
+
}), T(O, () => {
|
799
|
+
O.value || (P.value = !1);
|
800
|
+
}), T(b, () => z()), T(M, (i, o) => {
|
801
|
+
a.isEqual(i, o) || G();
|
794
802
|
});
|
795
803
|
const j = [], Ce = function(i) {
|
796
|
-
|
804
|
+
D.value != "Uninitialized" ? Le(i) : j.push(i);
|
797
805
|
};
|
798
|
-
return T(
|
799
|
-
if (i != "Uninitialized" &&
|
800
|
-
const
|
806
|
+
return T(D, (i, o) => {
|
807
|
+
if (i != "Uninitialized" && o == "Uninitialized") {
|
808
|
+
const w = a.clone(j);
|
801
809
|
j.splice(0, j.length);
|
802
|
-
for (const
|
803
|
-
|
810
|
+
for (const F of w)
|
811
|
+
F();
|
804
812
|
}
|
805
|
-
}),
|
813
|
+
}), z(), {
|
806
814
|
// Configuration
|
807
|
-
collectionId:
|
808
|
-
draftBatchId:
|
809
|
-
resourceType:
|
810
|
-
restCollectionUrl: R(() =>
|
815
|
+
collectionId: b,
|
816
|
+
draftBatchId: C,
|
817
|
+
resourceType: m,
|
818
|
+
restCollectionUrl: R(() => E("restCollectionUrl", null)),
|
811
819
|
// Status
|
812
820
|
enabled: L,
|
813
|
-
status:
|
814
|
-
batchSaveAttempted: R(() =>
|
815
|
-
listNavigators: R(() =>
|
821
|
+
status: D,
|
822
|
+
batchSaveAttempted: R(() => E("batchSaveAttempted", !1)),
|
823
|
+
listNavigators: R(() => E("listNavigators", !1)),
|
816
824
|
// Resources loaded from the REST API
|
817
|
-
invalidResources: R(() =>
|
818
|
-
resources: R(() =>
|
819
|
-
remoteCollectionSize: R(() =>
|
825
|
+
invalidResources: R(() => E("invalidResources", [])),
|
826
|
+
resources: R(() => D.value != "Uninitialized" ? ($((i) => i.ensureCollectionLoaded()), E("resources", [])) : []),
|
827
|
+
remoteCollectionSize: R(() => E("remoteCollectionSize", null)),
|
820
828
|
// Transient data
|
821
|
-
transientData: R(() =>
|
829
|
+
transientData: R(() => E("transientData", [])),
|
822
830
|
// Selection and detail selection
|
823
|
-
detailSelection: R(() =>
|
824
|
-
editingDetailSelection: R(() =>
|
825
|
-
selection: R(() =>
|
831
|
+
detailSelection: R(() => E("detailSelection", [])),
|
832
|
+
editingDetailSelection: R(() => E("editingDetailSelection", !1)),
|
833
|
+
selection: R(() => E("selection", [])),
|
826
834
|
// Methods: Configuration
|
827
|
-
reconfigureCollection:
|
828
|
-
setEditingDetailSelection: (i) =>
|
829
|
-
(
|
835
|
+
reconfigureCollection: U,
|
836
|
+
setEditingDetailSelection: (i) => S(
|
837
|
+
(o) => o.setEditingDetailSelection(i)
|
830
838
|
),
|
831
839
|
setEnabled: W,
|
832
|
-
setFilterResourceIds:
|
833
|
-
setQuery:
|
840
|
+
setFilterResourceIds: re,
|
841
|
+
setQuery: J,
|
834
842
|
// Methods: Status
|
835
|
-
ensureStore:
|
843
|
+
ensureStore: z,
|
836
844
|
// TODO Rename
|
837
|
-
setBatchSaveAttempted: (i) =>
|
845
|
+
setBatchSaveAttempted: (i) => S((o) => o.setBatchSaveAttempted(i)),
|
838
846
|
// Local collection management
|
839
|
-
clear: () =>
|
840
|
-
ensureCollectionLoaded: async () => await
|
841
|
-
loadResources: async () => await
|
847
|
+
clear: () => S((i) => i.clear()),
|
848
|
+
ensureCollectionLoaded: async () => await $(async (i) => i.ensureCollectionLoaded()),
|
849
|
+
loadResources: async () => await $(async (i) => await i.loadResources()),
|
842
850
|
// Methods: Recording changes to the collection
|
843
|
-
addResource: (i) =>
|
844
|
-
checkForDeletedResource: async (i) => await
|
845
|
-
recordDeletion: (i) =>
|
846
|
-
recordInsertion: (i, { insertAtBeginning:
|
847
|
-
recordUpdate: (i) =>
|
848
|
-
refreshResource: async (i) => await
|
849
|
-
async (
|
851
|
+
addResource: (i) => S((o) => o.addResource(i)),
|
852
|
+
checkForDeletedResource: async (i) => await $(async (o) => await o.checkForDeletedResource(i)) == !0,
|
853
|
+
recordDeletion: (i) => S((o) => o.recordDeletion(i)),
|
854
|
+
recordInsertion: (i, { insertAtBeginning: o = !1, transientData: w = void 0 } = {}) => S((F) => F.recordInsertion(i, { insertAtBeginning: o, transientData: w })),
|
855
|
+
recordUpdate: (i) => S((o) => o.recordUpdate(i)),
|
856
|
+
refreshResource: async (i) => await $(
|
857
|
+
async (o) => await o.refreshResource(i)
|
850
858
|
),
|
851
859
|
// Methods: Modifying the collection
|
852
|
-
deleteResource: async (i) => await
|
853
|
-
async (
|
860
|
+
deleteResource: async (i) => await $(
|
861
|
+
async (o) => await o.deleteResource(i)
|
854
862
|
),
|
855
|
-
saveResource: async (i) => await
|
856
|
-
saveResources: async (i) => await
|
863
|
+
saveResource: async (i) => await $(async (o) => await o.saveResource(i)),
|
864
|
+
saveResources: async (i) => await $(async (o) => await o.saveResources(i)),
|
857
865
|
// Methods: Transient data
|
858
|
-
clearTransientData: () =>
|
859
|
-
setInvalidResourceIds: (i) =>
|
860
|
-
setTransientDataForResources: (i) =>
|
861
|
-
(
|
866
|
+
clearTransientData: () => S((i) => i.clearTransientData()),
|
867
|
+
setInvalidResourceIds: (i) => S((o) => o.setInvalidResourceIds(i)),
|
868
|
+
setTransientDataForResources: (i) => S(
|
869
|
+
(o) => o.setTransientDataForResources(i)
|
862
870
|
),
|
863
871
|
// Methods: Selection and detail selection
|
864
|
-
clearSelection: () =>
|
865
|
-
deselectResources: (i) =>
|
866
|
-
selectResources: (i,
|
867
|
-
(
|
872
|
+
clearSelection: () => S((i) => i.clearSelection()),
|
873
|
+
deselectResources: (i) => S((o) => o.deselectResources(i)),
|
874
|
+
selectResources: (i, o) => S(
|
875
|
+
(w) => w.selectResources(i, o)
|
868
876
|
),
|
869
877
|
// Methods: Managing the detail view
|
870
|
-
hideDetail: () =>
|
878
|
+
hideDetail: () => S((i) => i.hideDetail()),
|
871
879
|
// Methods: Editors
|
872
|
-
deregisterEditor: (i) =>
|
873
|
-
registerEditor: (i) =>
|
880
|
+
deregisterEditor: (i) => S((o) => o.deregisterEditor(i)),
|
881
|
+
registerEditor: (i) => S((o) => o.registerEditor(i)),
|
874
882
|
// Methods: List navigators
|
875
|
-
deregisterListNavigator: (i) =>
|
876
|
-
registerListNavigator: (i) =>
|
883
|
+
deregisterListNavigator: (i) => S((o) => o.deregisterListNavigator(i)),
|
884
|
+
registerListNavigator: (i) => S((o) => o.registerListNavigator(i)),
|
877
885
|
// Callbacks
|
878
886
|
onItemsStoreReady: Ce
|
879
887
|
};
|
880
|
-
},
|
881
|
-
|
888
|
+
}, Me = () => {
|
889
|
+
se.clearAllStores();
|
882
890
|
};
|
883
|
-
function
|
884
|
-
return a.get(
|
891
|
+
function oe(h, s) {
|
892
|
+
return a.get(h, (s == null ? void 0 : s.idProperty) || "_id");
|
885
893
|
}
|
886
894
|
const Ue = {
|
887
895
|
idProperty: "_id"
|
888
|
-
},
|
896
|
+
}, Z = {
|
889
897
|
resource: null,
|
890
898
|
status: "NotLoaded"
|
891
|
-
},
|
899
|
+
}, qe = (h, s) => {
|
892
900
|
s = a.merge({}, Ue, s);
|
893
|
-
const
|
901
|
+
const g = pe(h, {
|
894
902
|
state: () => ({
|
895
903
|
idProperty: s.idProperty,
|
896
904
|
resourceId: s.resourceId || null,
|
897
905
|
resourceUrl: s.resourceUrl || null,
|
898
906
|
referencePathsToExpand: s.referencePathsToExpand || null,
|
899
|
-
...
|
907
|
+
...Z
|
900
908
|
}),
|
901
909
|
getters: {
|
902
910
|
currentResourceUrl: (e) => e.resourceUrl || (s.restCollectionUrl && e.resourceId ? `${s.restCollectionUrl}/${e.resourceId}` : null) || s.restCollectionUrl || null,
|
@@ -916,8 +924,8 @@ const Ue = {
|
|
916
924
|
* Configuration is retained, but REST resource content and contextual state are reset.
|
917
925
|
*/
|
918
926
|
reset() {
|
919
|
-
for (const e in
|
920
|
-
this[e] =
|
927
|
+
for (const e in Z)
|
928
|
+
this[e] = Z[e];
|
921
929
|
},
|
922
930
|
async setResourceId(e) {
|
923
931
|
const r = this.currentResourceUrl;
|
@@ -936,8 +944,8 @@ const Ue = {
|
|
936
944
|
* Configuration and contextual state are retained, but REST collection contents are reset.
|
937
945
|
*/
|
938
946
|
clear() {
|
939
|
-
for (const e in
|
940
|
-
this[e] =
|
947
|
+
for (const e in Z)
|
948
|
+
this[e] = Z[e];
|
941
949
|
},
|
942
950
|
/**
|
943
951
|
* Load the resource, if it has not been loaded.
|
@@ -962,7 +970,7 @@ const Ue = {
|
|
962
970
|
(c, d) => c != null ? `${encodeURIComponent(d)}=${encodeURIComponent(c)}` : null
|
963
971
|
).filter((c) => c != null).join("&"), u = a.isEmpty(l) ? this.currentResourceUrl : `${this.currentResourceUrl}?${l}`;
|
964
972
|
try {
|
965
|
-
const c = await
|
973
|
+
const c = await x.get(u), d = this.fixedQueryParams;
|
966
974
|
e != this._loadId || !a.isEqual(r, d) ? console.log(`Discarding resource fetched by obsolete query from ${u}.`) : (this.resource = me.decode(a.get(c, "data", {})), this.status = "Loaded");
|
967
975
|
} catch (c) {
|
968
976
|
console.log(`Error while loading resource (URL="${u}")`, c), this.reset(), this.status = "Failed";
|
@@ -985,9 +993,9 @@ const Ue = {
|
|
985
993
|
if (this.currentResourceUrl) {
|
986
994
|
let e;
|
987
995
|
try {
|
988
|
-
e = await
|
996
|
+
e = await x.get(this.currentResourceUrl);
|
989
997
|
} catch (r) {
|
990
|
-
|
998
|
+
x.isAxiosError(r) && (e = r.response);
|
991
999
|
}
|
992
1000
|
return e && e.status == 404 ? (this.recordDeletion(), !0) : !1;
|
993
1001
|
} else
|
@@ -1022,7 +1030,7 @@ const Ue = {
|
|
1022
1030
|
* @param resource The resource that has been inserted.
|
1023
1031
|
*/
|
1024
1032
|
recordInsertion(e) {
|
1025
|
-
this.resourceId =
|
1033
|
+
this.resourceId = oe(e, this) || null, this.status == "Loaded" && (this.resource = Object.freeze(e));
|
1026
1034
|
},
|
1027
1035
|
/**
|
1028
1036
|
* Record an update, making the same changes in the local resource.
|
@@ -1043,7 +1051,7 @@ const Ue = {
|
|
1043
1051
|
* @param resource The resource that has been updated.
|
1044
1052
|
*/
|
1045
1053
|
recordUpdate(e) {
|
1046
|
-
this.resourceId =
|
1054
|
+
this.resourceId = oe(e, this) || null, this.status == "Loaded" && (this.resource = Object.freeze(e));
|
1047
1055
|
},
|
1048
1056
|
async refreshResource() {
|
1049
1057
|
return await this.loadResource(), this.resource;
|
@@ -1058,7 +1066,7 @@ const Ue = {
|
|
1058
1066
|
*/
|
1059
1067
|
async deleteResource() {
|
1060
1068
|
if (this.currentResourceUrl)
|
1061
|
-
(await
|
1069
|
+
(await x.delete(this.currentResourceUrl)).status == 200 && this.recordDeletion();
|
1062
1070
|
else
|
1063
1071
|
throw "Cannot delete a resource because its URL, or its ID and collection URL, are unknown.";
|
1064
1072
|
},
|
@@ -1074,12 +1082,12 @@ const Ue = {
|
|
1074
1082
|
* the operation failed.
|
1075
1083
|
*/
|
1076
1084
|
async saveResource(e) {
|
1077
|
-
const r =
|
1085
|
+
const r = oe(e, this), t = r == null;
|
1078
1086
|
if (!r)
|
1079
1087
|
throw "The REST resource store cannot create new resources on the server.";
|
1080
1088
|
if (!this.currentResourceUrl)
|
1081
1089
|
throw "Cannot save a resource because its URL, or its ID and collection URL, are unknown.";
|
1082
|
-
const l = await
|
1090
|
+
const l = await x({
|
1083
1091
|
method: t ? "post" : "put",
|
1084
1092
|
url: this.currentResourceUrl,
|
1085
1093
|
data: e
|
@@ -1101,7 +1109,7 @@ const Ue = {
|
|
1101
1109
|
c = `${this.currentResourceUrl}/${t}`;
|
1102
1110
|
else
|
1103
1111
|
throw "Cannot make a custom API request for a resource because its URL, or its ID and collection URL, are unknown.";
|
1104
|
-
const d = await
|
1112
|
+
const d = await x({
|
1105
1113
|
method: r || "get",
|
1106
1114
|
url: c,
|
1107
1115
|
data: u
|
@@ -1112,148 +1120,148 @@ const Ue = {
|
|
1112
1120
|
});
|
1113
1121
|
return (() => {
|
1114
1122
|
const e = (r, t) => {
|
1115
|
-
const l =
|
1123
|
+
const l = g(r, t);
|
1116
1124
|
return ce.registerStore(l.$id, l), l;
|
1117
1125
|
};
|
1118
|
-
return e.$id =
|
1126
|
+
return e.$id = g.$id, e;
|
1119
1127
|
})();
|
1120
|
-
}, ce = new Ie(),
|
1128
|
+
}, ce = new Ie(), je = (h = {}) => {
|
1121
1129
|
const {
|
1122
1130
|
resourceClientId: s,
|
1123
|
-
draftBatchId:
|
1124
|
-
enabled:
|
1131
|
+
draftBatchId: g,
|
1132
|
+
enabled: I,
|
1125
1133
|
resourceType: e,
|
1126
1134
|
options: r
|
1127
|
-
} =
|
1135
|
+
} = h, t = y(void 0), l = y(s), u = y(g), c = y(I ?? !0), d = y([ie(e)]), p = y(r), C = R(() => u.value), L = y(c.value), A = y(H()), N = R(
|
1128
1136
|
() => u.value == null && l.value != null && ce.getStore(l.value) != null
|
1129
|
-
),
|
1130
|
-
function
|
1137
|
+
), k = y(N.value), O = R(() => S("status", "Uninitialized"));
|
1138
|
+
function P(n) {
|
1131
1139
|
if (t.value)
|
1132
|
-
return
|
1140
|
+
return n(t.value);
|
1133
1141
|
}
|
1134
|
-
async function
|
1142
|
+
async function D(n) {
|
1135
1143
|
if (t.value)
|
1136
|
-
return await
|
1144
|
+
return await n(t.value);
|
1137
1145
|
}
|
1138
|
-
function
|
1146
|
+
function S(n, f) {
|
1139
1147
|
if (t.value)
|
1140
|
-
return t.value[
|
1141
|
-
if (
|
1142
|
-
return
|
1148
|
+
return t.value[n];
|
1149
|
+
if (f !== void 0)
|
1150
|
+
return f;
|
1143
1151
|
throw "Attempted to use a REST resource store that has not been created, with no default value.";
|
1144
1152
|
}
|
1145
|
-
const
|
1153
|
+
const $ = (n = {}) => {
|
1146
1154
|
const {
|
1147
|
-
resourceClientId:
|
1148
|
-
draftBatchId:
|
1149
|
-
enabled:
|
1155
|
+
resourceClientId: f,
|
1156
|
+
draftBatchId: b,
|
1157
|
+
enabled: z,
|
1150
1158
|
resourceType: G,
|
1151
1159
|
options: j
|
1152
|
-
} =
|
1153
|
-
l.value =
|
1154
|
-
},
|
1155
|
-
|
1156
|
-
},
|
1160
|
+
} = n;
|
1161
|
+
l.value = f, u.value = b, c.value = z ?? !0, d.value = [ie(G)], j != null && (p.value = j), A.value = H(), E(c.value);
|
1162
|
+
}, E = async (n) => {
|
1163
|
+
n != L.value && (L.value = n, n && q());
|
1164
|
+
}, U = R(
|
1157
1165
|
() => d.value[0].value || void 0
|
1158
|
-
), W = function(
|
1159
|
-
const
|
1166
|
+
), W = function(n) {
|
1167
|
+
const f = a.get(n, "referencePathsToExpand"), b = U.value ? a.isFunction(f) ? f(U.value) : f || [] : [];
|
1160
1168
|
return {
|
1161
|
-
...a.cloneDeep(
|
1162
|
-
referencePathsToExpand:
|
1169
|
+
...a.cloneDeep(n || {}),
|
1170
|
+
referencePathsToExpand: b
|
1163
1171
|
};
|
1164
|
-
},
|
1165
|
-
if (!
|
1172
|
+
}, re = R(() => W(p.value)), J = R(() => {
|
1173
|
+
if (!U.value)
|
1166
1174
|
return null;
|
1167
|
-
if (!
|
1168
|
-
return !
|
1169
|
-
}),
|
1170
|
-
if (
|
1175
|
+
if (!k.value)
|
1176
|
+
return !U.value || !U.value.collectionName ? null : C.value ? `${V.config.apiBaseUrl}/draft-batches/${C.value}/${U.value.collectionName}` : `${V.config.apiBaseUrl}/${U.value.collectionName}`;
|
1177
|
+
}), K = R(() => {
|
1178
|
+
if (U.value && J.value)
|
1171
1179
|
return a.mergeWith(
|
1172
1180
|
a.cloneDeep(Ue),
|
1173
|
-
|
1181
|
+
re.value,
|
1174
1182
|
{
|
1175
|
-
idProperty:
|
1176
|
-
restCollectionUrl:
|
1183
|
+
idProperty: U.value.idProperty,
|
1184
|
+
restCollectionUrl: J.value
|
1177
1185
|
},
|
1178
|
-
(
|
1179
|
-
if (a.isArray(
|
1180
|
-
return
|
1186
|
+
(n, f) => {
|
1187
|
+
if (a.isArray(f) && f.length == 0 && (n == null || a.isArray(n)))
|
1188
|
+
return f;
|
1181
1189
|
}
|
1182
1190
|
);
|
1183
|
-
}),
|
1191
|
+
}), m = y(0), _ = R(
|
1184
1192
|
() => {
|
1185
|
-
var
|
1186
|
-
return
|
1193
|
+
var n;
|
1194
|
+
return m.value, l.value || U.value && ((n = U.value) == null ? void 0 : n.collectionName) && (C.value ? `draftBatches/${C.value}/${U.value.collectionName}/${A.value}` : `${U.value.collectionName}/${A.value}`) || null;
|
1187
1195
|
}
|
1188
|
-
),
|
1196
|
+
), q = () => {
|
1189
1197
|
if (L.value) {
|
1190
|
-
let
|
1191
|
-
return
|
1198
|
+
let n = !1;
|
1199
|
+
return U.value && _.value && (t.value = ce.getStore(_.value), t.value ? n = !1 : K.value && (k.value = !1, t.value = qe(_.value, K.value)(), n = !0)), n;
|
1192
1200
|
} else
|
1193
1201
|
return !1;
|
1194
1202
|
}, M = () => {
|
1195
|
-
_.value && l.value == _.value ? (t.value = void 0,
|
1203
|
+
_.value && l.value == _.value ? (t.value = void 0, q()) : (t.value = void 0, m.value = m.value + 1, q());
|
1196
1204
|
};
|
1197
|
-
return T(
|
1198
|
-
a.isEqual(
|
1199
|
-
}), T(L, (
|
1200
|
-
|
1201
|
-
}), T(
|
1202
|
-
|
1203
|
-
}), T(
|
1204
|
-
a.isEqual(
|
1205
|
-
}), T(
|
1206
|
-
|
1207
|
-
}), T(_, () =>
|
1208
|
-
a.isEqual(
|
1209
|
-
}),
|
1205
|
+
return T(C, (n, f) => {
|
1206
|
+
a.isEqual(n, f) || M();
|
1207
|
+
}), T(L, (n, f) => {
|
1208
|
+
n != f && (n ? q() : t.value = void 0);
|
1209
|
+
}), T(U, (n, f) => {
|
1210
|
+
n && !f ? q() : !n && f || a.isEqual(n, f) || M();
|
1211
|
+
}), T(K, (n, f) => {
|
1212
|
+
a.isEqual(n, f) || M();
|
1213
|
+
}), T(N, () => {
|
1214
|
+
N.value || (k.value = !1);
|
1215
|
+
}), T(_, () => q()), T(J, (n, f) => {
|
1216
|
+
a.isEqual(n, f) || M();
|
1217
|
+
}), q(), {
|
1210
1218
|
// Configuration
|
1211
1219
|
resourceClientId: _,
|
1212
|
-
draftBatchId:
|
1220
|
+
draftBatchId: C,
|
1213
1221
|
enabled: L,
|
1214
|
-
resourceType:
|
1222
|
+
resourceType: U,
|
1215
1223
|
// Status
|
1216
|
-
status:
|
1224
|
+
status: O,
|
1217
1225
|
// Resources loaded from the REST API
|
1218
|
-
resource: R(() =>
|
1219
|
-
resourceId: R(() =>
|
1220
|
-
resourceUrl: R(() =>
|
1226
|
+
resource: R(() => O.value != "Uninitialized" ? (D((n) => n.ensureResourceLoaded()), S("resource", [])) : []),
|
1227
|
+
resourceId: R(() => S("resourceId", null)),
|
1228
|
+
resourceUrl: R(() => S("resourceUrl", null)),
|
1221
1229
|
// Methods: Configuration
|
1222
|
-
reconfigureClient:
|
1223
|
-
setEnabled:
|
1224
|
-
setResourceId: async (
|
1225
|
-
setResourceUrl: async (
|
1230
|
+
reconfigureClient: $,
|
1231
|
+
setEnabled: E,
|
1232
|
+
setResourceId: async (n) => await D(async (f) => await f.setResourceId(n)),
|
1233
|
+
setResourceUrl: async (n) => await D(async (f) => await f.setResourceUrl(n)),
|
1226
1234
|
// Methods: Status
|
1227
|
-
ensureStore:
|
1235
|
+
ensureStore: q,
|
1228
1236
|
// Methods: Resource management
|
1229
|
-
clear: () =>
|
1230
|
-
ensureResourceLoaded: async () => await
|
1231
|
-
loadResource: async () => await
|
1237
|
+
clear: () => P((n) => n.clear()),
|
1238
|
+
ensureResourceLoaded: async () => await D(async (n) => n.ensureResourceLoaded()),
|
1239
|
+
loadResource: async () => await D(async (n) => await n.loadResource()),
|
1232
1240
|
// Methods: Recording changes to the resource
|
1233
|
-
checkForDeletedResource: async () => await
|
1234
|
-
recordDeletion: () =>
|
1235
|
-
recordInsertion: (
|
1236
|
-
recordUpdate: (
|
1237
|
-
refreshResource: async () => await
|
1241
|
+
checkForDeletedResource: async () => await D(async (n) => await n.checkForDeletedResource()) == !0,
|
1242
|
+
recordDeletion: () => D((n) => n.recordDeletion()),
|
1243
|
+
recordInsertion: (n) => D((f) => f.recordInsertion(n)),
|
1244
|
+
recordUpdate: (n) => D((f) => f.recordUpdate(n)),
|
1245
|
+
refreshResource: async () => await D(async (n) => await n.refreshResource()),
|
1238
1246
|
// Methods: Modifying the resource
|
1239
|
-
deleteResource: async () => await
|
1240
|
-
saveResource: async (
|
1247
|
+
deleteResource: async () => await D(async (n) => await n.deleteResource()),
|
1248
|
+
saveResource: async (n) => await D(async (f) => await f.saveResource(n)),
|
1241
1249
|
// Methods: Custom API endpoints
|
1242
|
-
makeCustomApiRequest: async (
|
1243
|
-
async (
|
1250
|
+
makeCustomApiRequest: async (n) => await D(
|
1251
|
+
async (f) => await f.makeCustomApiRequest(n)
|
1244
1252
|
)
|
1245
1253
|
};
|
1246
|
-
},
|
1254
|
+
}, V = {
|
1247
1255
|
config: { ...ye }
|
1248
1256
|
};
|
1249
|
-
function
|
1250
|
-
|
1257
|
+
function We(h) {
|
1258
|
+
V.config = a.merge({}, ye, h);
|
1251
1259
|
}
|
1252
1260
|
export {
|
1253
1261
|
_e as ApiClientError,
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1262
|
+
Me as clearAllRestCollections,
|
1263
|
+
We as initRestClient,
|
1264
|
+
V as restClient,
|
1265
|
+
Qe as useRestCollection,
|
1266
|
+
je as useRestResource
|
1259
1267
|
};
|
@@ -1 +1 @@
|
|
1
|
-
(function(v,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("lodash"),require("uuid"),require("vue"),require("axios"),require("jsog"),require("json-stringify-deterministic"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","lodash","uuid","vue","axios","jsog","json-stringify-deterministic","pinia"],s):(v=typeof globalThis<"u"?globalThis:v||self,s(v["rest-client-vue"]={},v._,v.uuid,v.Vue,v.axios,v.jsog,v.stringify,v.pinia))})(this,function(v,s,I,o,$,ae,G,ce){"use strict";var Pe=Object.defineProperty;var Fe=(v,s,I)=>s in v?Pe(v,s,{enumerable:!0,configurable:!0,writable:!0,value:I}):v[s]=I;var oe=(v,s,I)=>(Fe(v,typeof s!="symbol"?s+"":s,I),I),Ne=(v,s,I)=>{if(!s.has(v))throw TypeError("Cannot "+I)};var j=(v,s,I)=>(Ne(v,s,"read from private field"),I?I.call(v):s.get(v)),Ie=(v,s,I)=>{if(s.has(v))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(v):s.set(v,I)};var A;const ue={apiBaseUrl:"",useVueLogger:!1};class we extends Error{constructor(E,q=void 0,e=void 0){super(E);oe(this,"context");oe(this,"innerError");this.context=q,this.innerError=e}}class de{constructor(){Ie(this,A,{})}clearAllStores(){for(const n in j(this,A))j(this,A)[n].clear()}destroyStore(n){j(this,A)[n]&&(j(this,A)[n].$dispose(),delete j(this,A)[n])}getStore(n){return j(this,A)[n]}registerStore(n,E){j(this,A)[n]=E}}A=new WeakMap;function g(w,n){return s.get(w,(n==null?void 0:n.idProperty)||"_id")}function De(w,n){var E;return w&&((E=n.filter)!=null&&E.resourceIds)&&!n.order?n.filter.resourceIds.map(q=>w.find(e=>g(e,n)==q)).filter(q=>q!=null):w}const he={detail:{allowMultiple:!0,autoEdit:!1,autoFromMultipleSelection:!0,autoFromSingleInsertion:!0,autoFromSingleSelection:!0,constrainToSelection:!0},filter:{namedFilter:null,query:null,resourceIds:null},idProperty:"_id",limit:5e3,limitTransientDataToLocalCollection:!0,loading:{firstPageSize:500,pageSize:5e3},order:[[{path:"history.creation.timestamp"},"desc"],[{path:"history.creation.indexInBatch"},"desc"]]},K={resources:[],remoteCollectionSize:null,status:"NotLoaded",selection:[],detailSelection:[],invalidResources:[],transientData:{}},se={editingDetailSelection:!1,batchSaveAttempted:!1,editors:[],listNavigators:{}},Ce=(w,n)=>{n=s.merge({},he,n);const E=ce.defineStore(w,{state:()=>({idProperty:n.idProperty,filter:n.filter,order:n.order||null,propertyBlacklist:n.propertyBlacklist||null,referencePathsToExpand:n.referencePathsToExpand||null,restCollectionUrl:n.restCollectionUrl,...K,...se}),getters:{fixedQueryParams:e=>{var l,d,u,h;const r={};(l=e.filter)!=null&&l.namedFilter&&(r.namedFilter=e.filter.namedFilter);const t=[];if((d=e.filter)!=null&&d.resourceIds&&t.push({l:{path:e.idProperty},r:{constant:e.filter.resourceIds},operator:"in"}),(u=e.filter)!=null&&u.query&&t.push((h=e.filter)==null?void 0:h.query),t.length>0){const S=t.length==1?t[0]:{and:t};r.q=G(S)}return e.order&&(r.o=G(e.order)),e.propertyBlacklist&&(r.ex=G(e.propertyBlacklist)),e.referencePathsToExpand&&(r.r=G(e.referencePathsToExpand)),r}},actions:{reset(){for(const e in K)this[e]=K[e];for(const e in se)this[e]=se[e]},resetRetainingTransientData(){if(n.limitTransientDataToLocalCollection)this.reset();else{const e=this.transientData;this.reset(),this.transientData=e}},setEditingDetailSelection(e){this.editingDetailSelection=e},setFilter(e){s.isEqual(e,this.filter)||(this.filter=e,this.status="NotLoaded",this.resources=[],this.remoteCollectionSize=null,this.selection=[],this.detailSelection=[],this.invalidResources=[],this.editingDetailSelection=!1)},async setQuery(e){var r,t;if(!s.isEqual(e,(r=this.filter)==null?void 0:r.query)&&(e!=null||((t=this.filter)==null?void 0:t.query)!=null)){const l=s.cloneDeep(this.filter)||{};e!==null?l.query=e:s.unset(l,"query");const d=this.status;this.setFilter(l),d!="NotLoaded"&&await this.loadResources()}},async setFilterResourceIds(e){if(!s.isEqual(e,s.get(this.filter,"resourceIds"))){const r=s.cloneDeep(this.filter)||{};e!=null?r.resourceIds=e:s.unset(r,"resourceIds");const t=this.status;this.setFilter(r),t!="NotLoaded"&&await this.loadResources()}},setBatchSaveAttempted(e){e!=this.batchSaveAttempted&&(this.batchSaveAttempted=e)},clear(){for(const e in K)this[e]=K[e]},clearRetainingTransientData(){if(n.limitTransientDataToLocalCollection)this.reset();else{const e=this.transientData;this.reset(),this.transientData=e}},async ensureCollectionLoaded(){["Loaded","Loading","LoadingMore","Failed"].includes(this.status)||await this.loadResources()},async loadResources(e={}){this.resetRetainingTransientData();const r=I.v4();this._loadId=r,await this._loadResources(0,r,e)},async _loadResources(e,r,t){var b,N,k,B,Q;const l=e==0;if(this.status=l?"Loading":"LoadingMore",this._loadOffset=e,((b=this.filter)==null?void 0:b.query)===!1){this.resources=[],this.remoteCollectionSize=0;return}const d=this.fixedQueryParams,u=s.cloneDeep(d),h=l?(N=this.filter)!=null&&N.resourceIds&&!this.order?null:t.firstPageSize||((k=n.loading)==null?void 0:k.firstPageSize)||t.pageSize||((B=n.loading)==null?void 0:B.pageSize)||null:t.pageSize||((Q=n.loading)==null?void 0:Q.pageSize)||null,S=h!=null||n.limit!=null?s.min(s.filter([h,n.limit],p=>p!=null)):void 0;S!=null?(u.offset=e,u.limit=S):e!=0&&(u.offset=e);const D=s.map(u,(p,m)=>p!=null?`${encodeURIComponent(m)}=${encodeURIComponent(p)}`:null).filter(p=>p!=null).join("&"),L=s.isEmpty(D)?n.restCollectionUrl:`${n.restCollectionUrl}?${D}`;try{const p=await $.get(L),m=this.fixedQueryParams;if(r!=this._loadId||e!=this._loadOffset||!s.isEqual(d,m))console.log(`Discarding resources fetched by obsolete query from ${n.restCollectionUrl}.`);else{const C=ae.decode(s.get(p,"data.data",[])),T=(l?0:this.resources.length)+C.length,y=S==null||C.length<S||n.limit&&T>=n.limit;console.log(`Loaded ${C.length}${l?"":" more"} resources from ${n.restCollectionUrl}`),l&&(this.resources=[]);const H=[...this.resources,...C.map(Z=>Object.freeze(Z))];this.resources=De(H,this),s.get(p,"data.totalCollectionSize")?this.remoteCollectionSize=s.get(p,"data.totalCollectionSize"):this.remoteCollectionSize=null,this.status=y?"Loaded":"LoadingMore",y||this._loadResources(this.resources.length,r,t)}}catch(p){console.log(`Error while loading resources (URL="${L}"):`,p),this.clearRetainingTransientData(),this.status="Failed"}},async checkForDeletedResource(e){let r;try{r=await $.get(`${n.restCollectionUrl}/${e}`)}catch(t){$.isAxiosError(t)&&(r=t.response)}return r&&r.status==404?(this.recordDeletion(e),!0):!1},recordDeletion(e){var r;if(["Loaded","LoadingMore"].includes(this.status)){let t=this.resources.findIndex(l=>g(l,this)==e);t>=0&&this.resources.splice(t,1),t=this.selection.findIndex(l=>g(l,this)==e),t>=0&&this.selection.splice(t,1),t=this.detailSelection.findIndex(l=>g(l,this)==e),t>=0&&(this.detailSelection.splice(t,1),this.detailSelection.length==0&&(this.editingDetailSelection=((r=n.detail)==null?void 0:r.autoEdit)||!1)),n.limitTransientDataToLocalCollection&&delete this.transientData[e]}},recordInsertion(e,{insertAtBeginning:r,transientData:t}={}){var l;if(["Loaded","LoadingMore"].includes(this.status)){const d=Object.freeze(e);r?this.resources.unshift(d):this.resources.push(d),(l=n.detail)!=null&&l.autoFromSingleInsertion&&(this.detailSelection.length==0||this.detailSelection.length==1&&g(this.detailSelection[0],this)==null)&&(this.detailSelection=[d],this.editingDetailSelection=n.detail.autoEdit);const u=g(e,this);u&&(t===void 0?delete this.transientData[u]:this.transientData[u]=t)}},recordUpdate(e){const r=g(e,this);if(r&&["Loaded","LoadingMore"].includes(this.status)){const t=Object.freeze(e);let l=this.resources.findIndex(d=>g(d,this)==r);l>=0&&(this.resources[l]=t),l=this.selection.findIndex(d=>g(d,this)==r),l>=0&&(this.selection[l]=t),l=this.detailSelection.findIndex(d=>g(d,this)==r),l>=0&&(this.detailSelection[l]=t)}},async refreshResource(e){if(e){const r={};this.referencePathsToExpand&&(r.r=G(this.referencePathsToExpand));const t=s.map(r,(u,h)=>u!=null?`${encodeURIComponent(h)}=${encodeURIComponent(u)}`:null).filter(u=>u!=null).join("&"),l=s.isEmpty(t)?`${n.restCollectionUrl}/${e}`:`${n.restCollectionUrl}/${e}?${t}`,d=await $.get(l);if(d.status==200){const u=d.data;return this.recordUpdate(u),u}}return null},addResource(e={}){this.detailSelection=[s.omit(s.merge({},e),this.idProperty)],this.editingDetailSelection=!0},async deleteResource(e){if((await $.delete(`${n.restCollectionUrl}/${e}`)).status==200&&["Loaded","LoadingMore"].includes(this.status)){let t=this.resources.findIndex(l=>g(l,this)==e);t>=0&&this.resources.splice(t,1),t=this.selection.findIndex(l=>g(l,this)==e),t>=0&&this.selection.splice(t,1),t=this.detailSelection.findIndex(l=>g(l,this)==e),t>=0&&(this.detailSelection.splice(t,1),this.detailSelection.length==0&&(this.editingDetailSelection=n.detail.autoEdit)),n.limitTransientDataToLocalCollection&&delete this.transientData[e]}},async saveResource(e){const r=g(e,this),t=r==null,l=await $({method:t?"post":"put",url:t?n.restCollectionUrl:`${n.restCollectionUrl}/${r}`,data:e});if(l.status==200){const d=l.data,u=g(d,this),h=u?await this.refreshResource(u):null;return t&&this.recordInsertion(h||Object.freeze(d)),h||d}return null},async saveResources(e){const r=await $({method:"put",url:n.restCollectionUrl,data:e});if(r.status==200){const t=r.data||[],l=[];for(const[d,u]of t.entries()){const h=g(e[d],this)==null,S=g(u,this),D=S?await this.refreshResource(S):null;h&&this.recordInsertion(D||u),l.push(D||Object.freeze(u))}return l}return[]},clearTransientData(){this.transientData={}},setInvalidResourceIds(e){s.isEqual(e,this.invalidResources.map(r=>g(r,this)))||(this.invalidResources=e.map(r=>this.resources.find(t=>g(t,this)==r)).filter(r=>r!=null))},setTransientDataForResources(e){const{transientData:r,merge:t=!0}=e;t?s.merge(this.transientData,r):s.assign(this.transientData,r)},clearSelection(){this.setSelection([])},deselectResources(e){const r=this.selection.map(t=>g(t,this)).filter(t=>t!=null&&!e.includes(t));this.setSelection(r)},selectResources(e,r){const{addToSelection:t,edit:l}=r||{},d=this.selection.map(h=>g(h,this));let u=e;if(t){const h=s.difference(e,d);h.length>0&&(u=d.concat(h).filter(S=>S!=null))}s.isEqual(d,u)||this.setSelection(u,l)},setSelection(e,r){if(!s.isEqual(e,this.selection.map(t=>g(t,this)))){let t=!0;if(this.editors.length>0){if(n.detail.autoFromSingleSelection&&this.selection.length==1)t=!1;else if(n.detail.autoFromMultipleSelection&&n.detail.allowMultiple&&this.selection.length>1)t=!1;else if(n.detail.constrainToSelection){const l=this.selection.map(h=>g(h,this)),u=this.detailSelection.map(h=>g(h,this)).filter(h=>l.includes(h));this.detailSelection.filter(h=>!u.includes(g(h,this))).length>0&&(t=!1)}}if(!t)return;if(this.selection=e.map(l=>this.resources.find(d=>g(d,this)==l)).filter(l=>l!=null),n.detail.autoFromSingleSelection&&this.selection.length==1){const l=this.selection[0];(this.detailSelection.length!=1||g(this.detailSelection[0],this)!=g(l,this))&&(this.detailSelection=[l])}else if(n.detail.autoFromMultipleSelection&&n.detail.allowMultiple&&this.selection.length>1)s.isEqual(this.selection.map(l=>g(l,this)),this.detailSelection.map(l=>g(l,this)))||(this.detailSelection=s.clone(this.selection));else if(n.detail.constrainToSelection){const l=this.selection.map(h=>g(h,this)),d=this.detailSelection.map(h=>g(h,this)),u=d.filter(h=>l.includes(h));s.isEqual(u,d)||(this.detailSelection=this.detailSelection.filter(h=>u.includes(g(h,this))))}this.detailSelection.length==0?this.editingDetailSelection=!1:this.editingDetailSelection=r!==void 0?r:this.editingDetailSelection||n.detail.autoEdit}},hideDetail(){this.detailSelection.length>0&&(this.detailSelection=[],this.editingDetailSelection=!1)},showSelectionAsDetail(e){if(this.selection.length<=1||n.detail.allowMultiple){const r=this.selection.map(l=>g(l,this)),t=this.detailSelection.map(l=>g(l,this));s.isEqual(r,t)||(this.detailSelection=s.clone(this.selection)),this.detailSelection.length==0?this.editingDetailSelection=!1:this.editingDetailSelection=e!==void 0?e:this.editingDetailSelection||n.detail.autoEdit}},deregisterEditor(e){s.remove(this.editors,r=>r==e)},registerEditor(e){this.editors.includes(e)||this.editors.push(e)},deregisterListNavigator({name:e,listNavigator:r}){(r==null||this.listNavigators[e]==r)&&delete this.listNavigators[e]},registerListNavigator({name:e,listNavigator:r}){this.listNavigators[e]!=r&&(this.listNavigators[e]=r)}}});return(()=>{const e=(r,t)=>{const l=E(r,t);return ee.registerStore(l.$id,l),l};return e.$id=E.$id,e})()},ee=new de,Ue=(w={})=>{var ge,ve,pe,me;const{collectionId:n,draftBatchId:E,enabled:q,resourceType:e,options:r}=w,t=o.ref(void 0),l=o.ref(n),d=o.ref(E),u=o.ref(q??!0),h=o.ref([o.toRef(e)]),S=o.ref(r),D=o.computed(()=>d.value),L=o.ref(u.value),b=o.ref(I.v4()),N=o.ref((ve=(ge=S.value)==null?void 0:ge.filter)==null?void 0:ve.resourceIds),k=o.ref((me=(pe=S.value)==null?void 0:pe.filter)==null?void 0:me.query),B=o.computed(()=>d.value==null&&l.value!=null&&ee.getStore(l.value)!=null),Q=o.ref(B.value),p=o.computed(()=>T("status","Uninitialized"));function m(i){if(t.value)return i(t.value)}async function C(i){if(t.value)return await i(t.value)}function T(i,c){if(t.value)return t.value[i];if(c!==void 0)return c;throw"Attempted to use a REST collection store that has not been created, with no default value."}const y=(i={})=>{var ie,Re,Se,ye;const{collectionId:c,draftBatchId:U,enabled:F,resourceType:ne,options:te}=i;l.value=c,d.value=U,u.value=F??!0,h.value=[o.toRef(ne)],te!=null&&(S.value=te,N.value=(Re=(ie=S.value)==null?void 0:ie.filter)==null?void 0:Re.resourceIds,k.value=(ye=(Se=S.value)==null?void 0:Se.filter)==null?void 0:ye.query),b.value=I.v4(),H(u.value)},H=async i=>{i!=L.value&&(L.value=i,i&&(_(),z()))},Z=async i=>{N.value=i,await C(async c=>await c.setFilterResourceIds(N.value||null))},V=async i=>{if(k.value=i,p.value!="Uninitialized"){const c=i,U=o.computed(()=>s.isFunction(c)?R.value?c(R.value):null:c);await C(F=>F.setQuery(U.value||null))}},_=()=>{S.value=s.merge({},S.value||{},{filter:{resourceIds:N.value,query:k.value}})},R=o.computed(()=>h.value[0].value||void 0),O=function(i){const c=s.get(i,"filter.query"),U=s.get(i,"propertyBlacklist"),F=s.get(i,"referencePathsToExpand"),ne=s.isFunction(c)?c(R.value):c,te=R.value?s.isFunction(U)?U(R.value):U||[]:[],ie=R.value?s.isFunction(F)?F(R.value):F||[]:[];return{...s.cloneDeep(i||{}),filter:{...s.cloneDeep((i==null?void 0:i.filter)||{}),query:ne},propertyBlacklist:te,referencePathsToExpand:ie}},P=o.computed(()=>O(S.value)),M=o.computed(()=>{if(P.value.restCollectionUrl!==void 0)return P.value.restCollectionUrl;if(!Q.value)return!R.value||!R.value.collectionName?null:D.value?`${X.config.apiBaseUrl}/draft-batches/${D.value}/${R.value.collectionName}`:`${X.config.apiBaseUrl}/${R.value.collectionName}`}),a=o.computed(()=>{var i;if(R.value)return s.mergeWith(s.cloneDeep(he),P.value,{idProperty:(i=R.value)==null?void 0:i.idProperty,restCollectionUrl:M.value||""},(c,U)=>{if(s.isArray(U)&&U.length==0&&(c==null||s.isArray(c)))return U})}),f=o.ref(0),x=o.computed(()=>{var i;return f.value,l.value||R.value&&((i=R.value)==null?void 0:i.collectionName)&&(D.value?`draftBatches/${D.value}/${R.value.collectionName}/${b.value}`:`${R.value.collectionName}/${b.value}`)||null}),z=()=>{if(L.value){let i=!1;return R.value&&x.value&&(t.value=ee.getStore(x.value),t.value?i=!1:a.value&&(Q.value=!1,t.value=Ce(x.value,a.value)(),i=!0)),i}else return!1},J=()=>{x.value&&l.value==x.value?(t.value=void 0,z()):(t.value=void 0,f.value=f.value+1,z())};o.watch(D,(i,c)=>{s.isEqual(i,c)||J()}),o.watch(L,(i,c)=>{i!=c&&(i?z():t.value=void 0)}),o.watch(R,(i,c)=>{i&&!c?z():!i&&c||s.isEqual(i,c)||J()}),o.watch(a,(i,c)=>{s.isEqual(i,c)||J()}),o.watch(B,()=>{B.value||(Q.value=!1)}),o.watch(x,()=>z()),o.watch(M,(i,c)=>{s.isEqual(i,c)||J()});const W=[],qe=function(i){p.value!="Uninitialized"?o.nextTick(i):W.push(i)};return o.watch(p,(i,c)=>{if(i!="Uninitialized"&&c=="Uninitialized"){const U=s.clone(W);W.splice(0,W.length);for(const F of U)F()}}),z(),{collectionId:x,draftBatchId:D,resourceType:R,restCollectionUrl:o.computed(()=>T("restCollectionUrl",null)),enabled:L,status:p,batchSaveAttempted:o.computed(()=>T("batchSaveAttempted",!1)),listNavigators:o.computed(()=>T("listNavigators",!1)),invalidResources:o.computed(()=>T("invalidResources",[])),resources:o.computed(()=>p.value!="Uninitialized"?(C(i=>i.ensureCollectionLoaded()),T("resources",[])):[]),remoteCollectionSize:o.computed(()=>T("remoteCollectionSize",null)),transientData:o.computed(()=>T("transientData",[])),detailSelection:o.computed(()=>T("detailSelection",[])),editingDetailSelection:o.computed(()=>T("editingDetailSelection",!1)),selection:o.computed(()=>T("selection",[])),reconfigureCollection:y,setEditingDetailSelection:i=>m(c=>c.setEditingDetailSelection(i)),setEnabled:H,setFilterResourceIds:Z,setQuery:V,ensureStore:z,setBatchSaveAttempted:i=>m(c=>c.setBatchSaveAttempted(i)),clear:()=>m(i=>i.clear()),ensureCollectionLoaded:async()=>await C(async i=>i.ensureCollectionLoaded()),loadResources:async()=>await C(async i=>await i.loadResources()),addResource:i=>m(c=>c.addResource(i)),checkForDeletedResource:async i=>await C(async c=>await c.checkForDeletedResource(i))==!0,recordDeletion:i=>m(c=>c.recordDeletion(i)),recordInsertion:(i,{insertAtBeginning:c=!1,transientData:U=void 0}={})=>m(F=>F.recordInsertion(i,{insertAtBeginning:c,transientData:U})),recordUpdate:i=>m(c=>c.recordUpdate(i)),refreshResource:async i=>await C(async c=>await c.refreshResource(i)),deleteResource:async i=>await C(async c=>await c.deleteResource(i)),saveResource:async i=>await C(async c=>await c.saveResource(i)),saveResources:async i=>await C(async c=>await c.saveResources(i)),clearTransientData:()=>m(i=>i.clearTransientData()),setInvalidResourceIds:i=>m(c=>c.setInvalidResourceIds(i)),setTransientDataForResources:i=>m(c=>c.setTransientDataForResources(i)),clearSelection:()=>m(i=>i.clearSelection()),deselectResources:i=>m(c=>c.deselectResources(i)),selectResources:(i,c)=>m(U=>U.selectResources(i,c)),hideDetail:()=>m(i=>i.hideDetail()),deregisterEditor:i=>m(c=>c.deregisterEditor(i)),registerEditor:i=>m(c=>c.registerEditor(i)),deregisterListNavigator:i=>m(c=>c.deregisterListNavigator(i)),registerListNavigator:i=>m(c=>c.registerListNavigator(i)),onItemsStoreReady:qe}},Ee=()=>{ee.clearAllStores()};function re(w,n){return s.get(w,(n==null?void 0:n.idProperty)||"_id")}const fe={idProperty:"_id"},Y={resource:null,status:"NotLoaded"},Te=(w,n)=>{n=s.merge({},fe,n);const E=ce.defineStore(w,{state:()=>({idProperty:n.idProperty,resourceId:n.resourceId||null,resourceUrl:n.resourceUrl||null,referencePathsToExpand:n.referencePathsToExpand||null,...Y}),getters:{currentResourceUrl:e=>e.resourceUrl||(n.restCollectionUrl&&e.resourceId?`${n.restCollectionUrl}/${e.resourceId}`:null)||n.restCollectionUrl||null,fixedQueryParams:e=>{const r={};return e.referencePathsToExpand&&(r.r=G(e.referencePathsToExpand)),r}},actions:{reset(){for(const e in Y)this[e]=Y[e]},async setResourceId(e){const r=this.currentResourceUrl;this.resourceId=e,!s.isEqual(this.currentResourceUrl,r)&&this.status!="NotLoaded"&&await this.loadResource()},async setResourceUrl(e){const r=this.currentResourceUrl;this.resourceUrl=e,!s.isEqual(this.currentResourceUrl,r)&&this.status!="NotLoaded"&&await this.loadResource()},clear(){for(const e in Y)this[e]=Y[e]},async ensureResourceLoaded(){["Loaded","Loading","Failed"].includes(this.status)||await this.loadResource()},async loadResource(){this.reset();const e=I.v4();if(this._loadId=e,this.currentResourceUrl){this.status="Loading";const r=this.fixedQueryParams,t=s.cloneDeep(r),l=s.map(t,(u,h)=>u!=null?`${encodeURIComponent(h)}=${encodeURIComponent(u)}`:null).filter(u=>u!=null).join("&"),d=s.isEmpty(l)?this.currentResourceUrl:`${this.currentResourceUrl}?${l}`;try{const u=await $.get(d),h=this.fixedQueryParams;e!=this._loadId||!s.isEqual(r,h)?console.log(`Discarding resource fetched by obsolete query from ${d}.`):(this.resource=ae.decode(s.get(u,"data",{})),this.status="Loaded")}catch(u){console.log(`Error while loading resource (URL="${d}")`,u),this.reset(),this.status="Failed"}}else throw"Cannot load a resource because its URL, or its ID and collection URL, are unknown."},async checkForDeletedResource(){if(this.currentResourceUrl){let e;try{e=await $.get(this.currentResourceUrl)}catch(r){$.isAxiosError(r)&&(e=r.response)}return e&&e.status==404?(this.recordDeletion(),!0):!1}else throw"Cannot check for a deleted resource because its URL, or its ID and collection URL, are unknown."},recordDeletion(){this.resource=null,this.status="Loaded"},recordInsertion(e){this.resourceId=re(e,this)||null,this.status=="Loaded"&&(this.resource=Object.freeze(e))},recordUpdate(e){this.resourceId=re(e,this)||null,this.status=="Loaded"&&(this.resource=Object.freeze(e))},async refreshResource(){return await this.loadResource(),this.resource},async deleteResource(){if(this.currentResourceUrl)(await $.delete(this.currentResourceUrl)).status==200&&this.recordDeletion();else throw"Cannot delete a resource because its URL, or its ID and collection URL, are unknown."},async saveResource(e){const r=re(e,this),t=r==null;if(!r)throw"The REST resource store cannot create new resources on the server.";if(!this.currentResourceUrl)throw"Cannot save a resource because its URL, or its ID and collection URL, are unknown.";const l=await $({method:t?"post":"put",url:this.currentResourceUrl,data:e});if(l.status==200){const d=l.data,u=await this.refreshResource();return t&&this.recordInsertion(u||d),u||Object.freeze(d)}return null},async makeCustomApiRequest(e){const{method:r,subpath:t,url:l,data:d}=e;let u=l;if(!u)if(this.currentResourceUrl)u=`${this.currentResourceUrl}/${t}`;else throw"Cannot make a custom API request for a resource because its URL, or its ID and collection URL, are unknown.";const h=await $({method:r||"get",url:u,data:d});return h.status>=200&&h.status<300?h.data:null}}});return(()=>{const e=(r,t)=>{const l=E(r,t);return le.registerStore(l.$id,l),l};return e.$id=E.$id,e})()},le=new de,Le=(w={})=>{const{resourceClientId:n,draftBatchId:E,enabled:q,resourceType:e,options:r}=w,t=o.ref(void 0),l=o.ref(n),d=o.ref(E),u=o.ref(q??!0),h=o.ref([o.toRef(e)]),S=o.ref(r),D=o.computed(()=>d.value),L=o.ref(u.value),b=o.ref(I.v4()),N=o.computed(()=>d.value==null&&l.value!=null&&le.getStore(l.value)!=null),k=o.ref(N.value),B=o.computed(()=>m("status","Uninitialized"));function Q(a){if(t.value)return a(t.value)}async function p(a){if(t.value)return await a(t.value)}function m(a,f){if(t.value)return t.value[a];if(f!==void 0)return f;throw"Attempted to use a REST resource store that has not been created, with no default value."}const C=(a={})=>{const{resourceClientId:f,draftBatchId:x,enabled:z,resourceType:J,options:W}=a;l.value=f,d.value=x,u.value=z??!0,h.value=[o.toRef(J)],W!=null&&(S.value=W),b.value=I.v4(),T(u.value)},T=async a=>{a!=L.value&&(L.value=a,a&&P())},y=o.computed(()=>h.value[0].value||void 0),H=function(a){const f=s.get(a,"referencePathsToExpand"),x=y.value?s.isFunction(f)?f(y.value):f||[]:[];return{...s.cloneDeep(a||{}),referencePathsToExpand:x}},Z=o.computed(()=>H(S.value)),V=o.computed(()=>{if(!y.value)return null;if(!k.value)return!y.value||!y.value.collectionName?null:D.value?`${X.config.apiBaseUrl}/draft-batches/${D.value}/${y.value.collectionName}`:`${X.config.apiBaseUrl}/${y.value.collectionName}`}),_=o.computed(()=>{if(y.value&&V.value)return s.mergeWith(s.cloneDeep(fe),Z.value,{idProperty:y.value.idProperty,restCollectionUrl:V.value},(a,f)=>{if(s.isArray(f)&&f.length==0&&(a==null||s.isArray(a)))return f})}),R=o.ref(0),O=o.computed(()=>{var a;return R.value,l.value||y.value&&((a=y.value)==null?void 0:a.collectionName)&&(D.value?`draftBatches/${D.value}/${y.value.collectionName}/${b.value}`:`${y.value.collectionName}/${b.value}`)||null}),P=()=>{if(L.value){let a=!1;return y.value&&O.value&&(t.value=le.getStore(O.value),t.value?a=!1:_.value&&(k.value=!1,t.value=Te(O.value,_.value)(),a=!0)),a}else return!1},M=()=>{O.value&&l.value==O.value?(t.value=void 0,P()):(t.value=void 0,R.value=R.value+1,P())};return o.watch(D,(a,f)=>{s.isEqual(a,f)||M()}),o.watch(L,(a,f)=>{a!=f&&(a?P():t.value=void 0)}),o.watch(y,(a,f)=>{a&&!f?P():!a&&f||s.isEqual(a,f)||M()}),o.watch(_,(a,f)=>{s.isEqual(a,f)||M()}),o.watch(N,()=>{N.value||(k.value=!1)}),o.watch(O,()=>P()),o.watch(V,(a,f)=>{s.isEqual(a,f)||M()}),P(),{resourceClientId:O,draftBatchId:D,enabled:L,resourceType:y,status:B,resource:o.computed(()=>B.value!="Uninitialized"?(p(a=>a.ensureResourceLoaded()),m("resource",[])):[]),resourceId:o.computed(()=>m("resourceId",null)),resourceUrl:o.computed(()=>m("resourceUrl",null)),reconfigureClient:C,setEnabled:T,setResourceId:async a=>await p(async f=>await f.setResourceId(a)),setResourceUrl:async a=>await p(async f=>await f.setResourceUrl(a)),ensureStore:P,clear:()=>Q(a=>a.clear()),ensureResourceLoaded:async()=>await p(async a=>a.ensureResourceLoaded()),loadResource:async()=>await p(async a=>await a.loadResource()),checkForDeletedResource:async()=>await p(async a=>await a.checkForDeletedResource())==!0,recordDeletion:()=>p(a=>a.recordDeletion()),recordInsertion:a=>p(f=>f.recordInsertion(a)),recordUpdate:a=>p(f=>f.recordUpdate(a)),refreshResource:async()=>await p(async a=>await a.refreshResource()),deleteResource:async()=>await p(async a=>await a.deleteResource()),saveResource:async a=>await p(async f=>await f.saveResource(a)),makeCustomApiRequest:async a=>await p(async f=>await f.makeCustomApiRequest(a))}},X={config:{...ue}};function $e(w){X.config=s.merge({},ue,w)}v.ApiClientError=we,v.clearAllRestCollections=Ee,v.initRestClient=$e,v.restClient=X,v.useRestCollection=Ue,v.useRestResource=Le,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
1
|
+
(function(v,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("lodash"),require("uuid"),require("vue"),require("axios"),require("jsog"),require("json-stringify-deterministic"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","lodash","uuid","vue","axios","jsog","json-stringify-deterministic","pinia"],s):(v=typeof globalThis<"u"?globalThis:v||self,s(v["rest-client-vue"]={},v._,v.uuid,v.Vue,v.axios,v.jsog,v.stringify,v.pinia))})(this,function(v,s,U,o,q,ae,G,ce){"use strict";var Fe=Object.defineProperty;var Ne=(v,s,U)=>s in v?Fe(v,s,{enumerable:!0,configurable:!0,writable:!0,value:U}):v[s]=U;var oe=(v,s,U)=>(Ne(v,typeof s!="symbol"?s+"":s,U),U),xe=(v,s,U)=>{if(!s.has(v))throw TypeError("Cannot "+U)};var j=(v,s,U)=>(xe(v,s,"read from private field"),U?U.call(v):s.get(v)),Ie=(v,s,U)=>{if(s.has(v))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(v):s.set(v,U)};var b;const ue={apiBaseUrl:"",useVueLogger:!1};class we extends Error{constructor(y,I=void 0,e=void 0){super(y);oe(this,"context");oe(this,"innerError");this.context=I,this.innerError=e}}class de{constructor(){Ie(this,b,{})}clearAllStores(){for(const n in j(this,b))j(this,b)[n].clear()}destroyStore(n){j(this,b)[n]&&(j(this,b)[n].$dispose(),delete j(this,b)[n])}getStore(n){return j(this,b)[n]}registerStore(n,y){j(this,b)[n]=y}}b=new WeakMap;function g(m,n){return s.get(m,(n==null?void 0:n.idProperty)||"_id")}function De(m,n){const y=s.map(n,(I,e)=>I!=null?`${encodeURIComponent(e)}=${encodeURIComponent(I)}`:null).filter(I=>I!=null).join("&");if(y.length>0){const I=m.indexOf("?");return I==m.length-1?`${m}${y}`:I>=0?`${m}&${y}`:`${m}?${y}`}else return m}function Ue(m,n){var y;return m&&((y=n.filter)!=null&&y.resourceIds)&&!n.order?n.filter.resourceIds.map(I=>m.find(e=>g(e,n)==I)).filter(I=>I!=null):m}const he={detail:{allowMultiple:!0,autoEdit:!1,autoFromMultipleSelection:!0,autoFromSingleInsertion:!0,autoFromSingleSelection:!0,constrainToSelection:!0},filter:{namedFilter:null,query:null,resourceIds:null},idProperty:"_id",limit:5e3,limitTransientDataToLocalCollection:!0,loading:{firstPageSize:500,pageSize:5e3},order:[[{path:"history.creation.timestamp"},"desc"],[{path:"history.creation.indexInBatch"},"desc"]]},K={resources:[],remoteCollectionSize:null,status:"NotLoaded",selection:[],detailSelection:[],invalidResources:[],transientData:{}},ie={editingDetailSelection:!1,batchSaveAttempted:!1,editors:[],listNavigators:{}},Ce=(m,n)=>{n=s.merge({},he,n);const y=ce.defineStore(m,{state:()=>({idProperty:n.idProperty,filter:n.filter,order:n.order||null,propertyBlacklist:n.propertyBlacklist||null,referencePathsToExpand:n.referencePathsToExpand||null,restCollectionUrl:n.restCollectionUrl,...K,...ie}),getters:{fixedQueryParams:e=>{var l,d,u,h;const r={};(l=e.filter)!=null&&l.namedFilter&&(r.namedFilter=e.filter.namedFilter);const t=[];if((d=e.filter)!=null&&d.resourceIds&&t.push({l:{path:e.idProperty},r:{constant:e.filter.resourceIds},operator:"in"}),(u=e.filter)!=null&&u.query&&t.push((h=e.filter)==null?void 0:h.query),t.length>0){const S=t.length==1?t[0]:{and:t};r.q=G(S)}return e.order&&(r.o=G(e.order)),e.propertyBlacklist&&(r.ex=G(e.propertyBlacklist)),e.referencePathsToExpand&&(r.r=G(e.referencePathsToExpand)),r}},actions:{reset(){for(const e in K)this[e]=K[e];for(const e in ie)this[e]=ie[e]},resetRetainingTransientData(){if(n.limitTransientDataToLocalCollection)this.reset();else{const e=this.transientData;this.reset(),this.transientData=e}},setEditingDetailSelection(e){this.editingDetailSelection=e},setFilter(e){s.isEqual(e,this.filter)||(this.filter=e,this.status="NotLoaded",this.resources=[],this.remoteCollectionSize=null,this.selection=[],this.detailSelection=[],this.invalidResources=[],this.editingDetailSelection=!1)},async setQuery(e){var r,t;if(!s.isEqual(e,(r=this.filter)==null?void 0:r.query)&&(e!=null||((t=this.filter)==null?void 0:t.query)!=null)){const l=s.cloneDeep(this.filter)||{};e!==null?l.query=e:s.unset(l,"query");const d=this.status;this.setFilter(l),d!="NotLoaded"&&await this.loadResources()}},async setFilterResourceIds(e){if(!s.isEqual(e,s.get(this.filter,"resourceIds"))){const r=s.cloneDeep(this.filter)||{};e!=null?r.resourceIds=e:s.unset(r,"resourceIds");const t=this.status;this.setFilter(r),t!="NotLoaded"&&await this.loadResources()}},setBatchSaveAttempted(e){e!=this.batchSaveAttempted&&(this.batchSaveAttempted=e)},clear(){for(const e in K)this[e]=K[e]},clearRetainingTransientData(){if(n.limitTransientDataToLocalCollection)this.reset();else{const e=this.transientData;this.reset(),this.transientData=e}},async ensureCollectionLoaded(){["Loaded","Loading","LoadingMore","Failed"].includes(this.status)||await this.loadResources()},async loadResources(e={}){this.resetRetainingTransientData();const r=U.v4();this._loadId=r,await this._loadResources(0,r,e)},async _loadResources(e,r,t){var L,k,x,O,B;const l=e==0;if(this.status=l?"Loading":"LoadingMore",this._loadOffset=e,((L=this.filter)==null?void 0:L.query)===!1){this.resources=[],this.remoteCollectionSize=0;return}const d=this.fixedQueryParams,u=s.cloneDeep(d),h=l?(k=this.filter)!=null&&k.resourceIds&&!this.order?null:t.firstPageSize||((x=n.loading)==null?void 0:x.firstPageSize)||t.pageSize||((O=n.loading)==null?void 0:O.pageSize)||null:t.pageSize||((B=n.loading)==null?void 0:B.pageSize)||null,S=h!=null||n.limit!=null?s.min(s.filter([h,n.limit],P=>P!=null)):void 0;S!=null?(u.offset=e,u.limit=S):e!=0&&(u.offset=e);const C=De(n.restCollectionUrl,u);try{const P=await q.get(C),w=this.fixedQueryParams;if(r!=this._loadId||e!=this._loadOffset||!s.isEqual(d,w))console.log(`Discarding resources fetched by obsolete query from ${n.restCollectionUrl}.`);else{const p=ae.decode(s.get(P,"data.data",[])),$=(l?0:this.resources.length)+p.length,E=S==null||p.length<S||n.limit&&$>=n.limit;console.log(`Loaded ${p.length}${l?"":" more"} resources from ${n.restCollectionUrl}`),l&&(this.resources=[]);const D=[...this.resources,...p.map(H=>Object.freeze(H))];this.resources=Ue(D,this),s.get(P,"data.totalCollectionSize")?this.remoteCollectionSize=s.get(P,"data.totalCollectionSize"):this.remoteCollectionSize=null,this.status=E?"Loaded":"LoadingMore",E||this._loadResources(this.resources.length,r,t)}}catch(P){console.log(`Error while loading resources (URL="${C}"):`,P),this.clearRetainingTransientData(),this.status="Failed"}},async checkForDeletedResource(e){let r;try{r=await q.get(`${n.restCollectionUrl}/${e}`)}catch(t){q.isAxiosError(t)&&(r=t.response)}return r&&r.status==404?(this.recordDeletion(e),!0):!1},recordDeletion(e){var r;if(["Loaded","LoadingMore"].includes(this.status)){let t=this.resources.findIndex(l=>g(l,this)==e);t>=0&&this.resources.splice(t,1),t=this.selection.findIndex(l=>g(l,this)==e),t>=0&&this.selection.splice(t,1),t=this.detailSelection.findIndex(l=>g(l,this)==e),t>=0&&(this.detailSelection.splice(t,1),this.detailSelection.length==0&&(this.editingDetailSelection=((r=n.detail)==null?void 0:r.autoEdit)||!1)),n.limitTransientDataToLocalCollection&&delete this.transientData[e]}},recordInsertion(e,{insertAtBeginning:r,transientData:t}={}){var l;if(["Loaded","LoadingMore"].includes(this.status)){const d=Object.freeze(e);r?this.resources.unshift(d):this.resources.push(d),(l=n.detail)!=null&&l.autoFromSingleInsertion&&(this.detailSelection.length==0||this.detailSelection.length==1&&g(this.detailSelection[0],this)==null)&&(this.detailSelection=[d],this.editingDetailSelection=n.detail.autoEdit);const u=g(e,this);u&&(t===void 0?delete this.transientData[u]:this.transientData[u]=t)}},recordUpdate(e){const r=g(e,this);if(r&&["Loaded","LoadingMore"].includes(this.status)){const t=Object.freeze(e);let l=this.resources.findIndex(d=>g(d,this)==r);l>=0&&(this.resources[l]=t),l=this.selection.findIndex(d=>g(d,this)==r),l>=0&&(this.selection[l]=t),l=this.detailSelection.findIndex(d=>g(d,this)==r),l>=0&&(this.detailSelection[l]=t)}},async refreshResource(e){if(e){const r={};this.referencePathsToExpand&&(r.r=G(this.referencePathsToExpand));const t=s.map(r,(u,h)=>u!=null?`${encodeURIComponent(h)}=${encodeURIComponent(u)}`:null).filter(u=>u!=null).join("&"),l=s.isEmpty(t)?`${n.restCollectionUrl}/${e}`:`${n.restCollectionUrl}/${e}?${t}`,d=await q.get(l);if(d.status==200){const u=d.data;return this.recordUpdate(u),u}}return null},addResource(e={}){this.detailSelection=[s.omit(s.merge({},e),this.idProperty)],this.editingDetailSelection=!0},async deleteResource(e){if((await q.delete(`${n.restCollectionUrl}/${e}`)).status==200&&["Loaded","LoadingMore"].includes(this.status)){let t=this.resources.findIndex(l=>g(l,this)==e);t>=0&&this.resources.splice(t,1),t=this.selection.findIndex(l=>g(l,this)==e),t>=0&&this.selection.splice(t,1),t=this.detailSelection.findIndex(l=>g(l,this)==e),t>=0&&(this.detailSelection.splice(t,1),this.detailSelection.length==0&&(this.editingDetailSelection=n.detail.autoEdit)),n.limitTransientDataToLocalCollection&&delete this.transientData[e]}},async saveResource(e){const r=g(e,this),t=r==null,l=await q({method:t?"post":"put",url:t?n.restCollectionUrl:`${n.restCollectionUrl}/${r}`,data:e});if(l.status==200){const d=l.data,u=g(d,this),h=u?await this.refreshResource(u):null;return t&&this.recordInsertion(h||Object.freeze(d)),h||d}return null},async saveResources(e){const r=await q({method:"put",url:n.restCollectionUrl,data:e});if(r.status==200){const t=r.data||[],l=[];for(const[d,u]of t.entries()){const h=g(e[d],this)==null,S=g(u,this),C=S?await this.refreshResource(S):null;h&&this.recordInsertion(C||u),l.push(C||Object.freeze(u))}return l}return[]},clearTransientData(){this.transientData={}},setInvalidResourceIds(e){s.isEqual(e,this.invalidResources.map(r=>g(r,this)))||(this.invalidResources=e.map(r=>this.resources.find(t=>g(t,this)==r)).filter(r=>r!=null))},setTransientDataForResources(e){const{transientData:r,merge:t=!0}=e;t?s.merge(this.transientData,r):s.assign(this.transientData,r)},clearSelection(){this.setSelection([])},deselectResources(e){const r=this.selection.map(t=>g(t,this)).filter(t=>t!=null&&!e.includes(t));this.setSelection(r)},selectResources(e,r){const{addToSelection:t,edit:l}=r||{},d=this.selection.map(h=>g(h,this));let u=e;if(t){const h=s.difference(e,d);h.length>0&&(u=d.concat(h).filter(S=>S!=null))}s.isEqual(d,u)||this.setSelection(u,l)},setSelection(e,r){if(!s.isEqual(e,this.selection.map(t=>g(t,this)))){let t=!0;if(this.editors.length>0){if(n.detail.autoFromSingleSelection&&this.selection.length==1)t=!1;else if(n.detail.autoFromMultipleSelection&&n.detail.allowMultiple&&this.selection.length>1)t=!1;else if(n.detail.constrainToSelection){const l=this.selection.map(h=>g(h,this)),u=this.detailSelection.map(h=>g(h,this)).filter(h=>l.includes(h));this.detailSelection.filter(h=>!u.includes(g(h,this))).length>0&&(t=!1)}}if(!t)return;if(this.selection=e.map(l=>this.resources.find(d=>g(d,this)==l)).filter(l=>l!=null),n.detail.autoFromSingleSelection&&this.selection.length==1){const l=this.selection[0];(this.detailSelection.length!=1||g(this.detailSelection[0],this)!=g(l,this))&&(this.detailSelection=[l])}else if(n.detail.autoFromMultipleSelection&&n.detail.allowMultiple&&this.selection.length>1)s.isEqual(this.selection.map(l=>g(l,this)),this.detailSelection.map(l=>g(l,this)))||(this.detailSelection=s.clone(this.selection));else if(n.detail.constrainToSelection){const l=this.selection.map(h=>g(h,this)),d=this.detailSelection.map(h=>g(h,this)),u=d.filter(h=>l.includes(h));s.isEqual(u,d)||(this.detailSelection=this.detailSelection.filter(h=>u.includes(g(h,this))))}this.detailSelection.length==0?this.editingDetailSelection=!1:this.editingDetailSelection=r!==void 0?r:this.editingDetailSelection||n.detail.autoEdit}},hideDetail(){this.detailSelection.length>0&&(this.detailSelection=[],this.editingDetailSelection=!1)},showSelectionAsDetail(e){if(this.selection.length<=1||n.detail.allowMultiple){const r=this.selection.map(l=>g(l,this)),t=this.detailSelection.map(l=>g(l,this));s.isEqual(r,t)||(this.detailSelection=s.clone(this.selection)),this.detailSelection.length==0?this.editingDetailSelection=!1:this.editingDetailSelection=e!==void 0?e:this.editingDetailSelection||n.detail.autoEdit}},deregisterEditor(e){s.remove(this.editors,r=>r==e)},registerEditor(e){this.editors.includes(e)||this.editors.push(e)},deregisterListNavigator({name:e,listNavigator:r}){(r==null||this.listNavigators[e]==r)&&delete this.listNavigators[e]},registerListNavigator({name:e,listNavigator:r}){this.listNavigators[e]!=r&&(this.listNavigators[e]=r)}}});return(()=>{const e=(r,t)=>{const l=y(r,t);return _.registerStore(l.$id,l),l};return e.$id=y.$id,e})()},_=new de,Ee=(m={})=>{var ge,ve,pe,me;const{collectionId:n,draftBatchId:y,enabled:I,resourceType:e,options:r}=m,t=o.ref(void 0),l=o.ref(n),d=o.ref(y),u=o.ref(I??!0),h=o.ref([o.toRef(e)]),S=o.ref(r),C=o.computed(()=>d.value),L=o.ref(u.value),k=o.ref(U.v4()),x=o.ref((ve=(ge=S.value)==null?void 0:ge.filter)==null?void 0:ve.resourceIds),O=o.ref((me=(pe=S.value)==null?void 0:pe.filter)==null?void 0:me.query),B=o.computed(()=>d.value==null&&l.value!=null&&_.getStore(l.value)!=null),P=o.ref(B.value),w=o.computed(()=>E("status","Uninitialized"));function p(i){if(t.value)return i(t.value)}async function $(i){if(t.value)return await i(t.value)}function E(i,c){if(t.value)return t.value[i];if(c!==void 0)return c;throw"Attempted to use a REST collection store that has not been created, with no default value."}const D=(i={})=>{var te,Re,Se,ye;const{collectionId:c,draftBatchId:T,enabled:N,resourceType:ne,options:ee}=i;l.value=c,d.value=T,u.value=N??!0,h.value=[o.toRef(ne)],ee!=null&&(S.value=ee,x.value=(Re=(te=S.value)==null?void 0:te.filter)==null?void 0:Re.resourceIds,O.value=(ye=(Se=S.value)==null?void 0:Se.filter)==null?void 0:ye.query),k.value=U.v4(),H(u.value)},H=async i=>{i!=L.value&&(L.value=i,i&&(V(),A()))},le=async i=>{x.value=i,await $(async c=>await c.setFilterResourceIds(x.value||null))},Z=async i=>{if(O.value=i,w.value!="Uninitialized"){const c=i,T=o.computed(()=>s.isFunction(c)?R.value?c(R.value):null:c);await $(N=>N.setQuery(T.value||null))}},V=()=>{S.value=s.merge({},S.value||{},{filter:{resourceIds:x.value,query:O.value}})},R=o.computed(()=>h.value[0].value||void 0),Q=function(i){const c=s.get(i,"filter.query"),T=s.get(i,"propertyBlacklist"),N=s.get(i,"referencePathsToExpand"),ne=s.isFunction(c)?c(R.value):c,ee=R.value?s.isFunction(T)?T(R.value):T||[]:[],te=R.value?s.isFunction(N)?N(R.value):N||[]:[];return{...s.cloneDeep(i||{}),filter:{...s.cloneDeep((i==null?void 0:i.filter)||{}),query:ne},propertyBlacklist:ee,referencePathsToExpand:te}},F=o.computed(()=>Q(S.value)),M=o.computed(()=>{if(F.value.restCollectionUrl!==void 0)return F.value.restCollectionUrl;if(!P.value)return!R.value||!R.value.collectionName?null:C.value?`${X.config.apiBaseUrl}/draft-batches/${C.value}/${R.value.collectionName}`:`${X.config.apiBaseUrl}/${R.value.collectionName}`}),a=o.computed(()=>{var i;if(R.value)return s.mergeWith(s.cloneDeep(he),F.value,{idProperty:(i=R.value)==null?void 0:i.idProperty,restCollectionUrl:M.value||""},(c,T)=>{if(s.isArray(T)&&T.length==0&&(c==null||s.isArray(c)))return T})}),f=o.ref(0),z=o.computed(()=>{var i;return f.value,l.value||R.value&&((i=R.value)==null?void 0:i.collectionName)&&(C.value?`draftBatches/${C.value}/${R.value.collectionName}/${k.value}`:`${R.value.collectionName}/${k.value}`)||null}),A=()=>{if(L.value){let i=!1;return R.value&&z.value&&(t.value=_.getStore(z.value),t.value?i=!1:a.value&&(P.value=!1,t.value=Ce(z.value,a.value)(),i=!0)),i}else return!1},J=()=>{z.value&&l.value==z.value?(t.value=void 0,A()):(t.value=void 0,f.value=f.value+1,A())};o.watch(C,(i,c)=>{s.isEqual(i,c)||J()}),o.watch(L,(i,c)=>{i!=c&&(i?A():t.value=void 0)}),o.watch(R,(i,c)=>{i&&!c?A():!i&&c||s.isEqual(i,c)||J()}),o.watch(a,(i,c)=>{s.isEqual(i,c)||J()}),o.watch(B,()=>{B.value||(P.value=!1)}),o.watch(z,()=>A()),o.watch(M,(i,c)=>{s.isEqual(i,c)||J()});const W=[],Pe=function(i){w.value!="Uninitialized"?o.nextTick(i):W.push(i)};return o.watch(w,(i,c)=>{if(i!="Uninitialized"&&c=="Uninitialized"){const T=s.clone(W);W.splice(0,W.length);for(const N of T)N()}}),A(),{collectionId:z,draftBatchId:C,resourceType:R,restCollectionUrl:o.computed(()=>E("restCollectionUrl",null)),enabled:L,status:w,batchSaveAttempted:o.computed(()=>E("batchSaveAttempted",!1)),listNavigators:o.computed(()=>E("listNavigators",!1)),invalidResources:o.computed(()=>E("invalidResources",[])),resources:o.computed(()=>w.value!="Uninitialized"?($(i=>i.ensureCollectionLoaded()),E("resources",[])):[]),remoteCollectionSize:o.computed(()=>E("remoteCollectionSize",null)),transientData:o.computed(()=>E("transientData",[])),detailSelection:o.computed(()=>E("detailSelection",[])),editingDetailSelection:o.computed(()=>E("editingDetailSelection",!1)),selection:o.computed(()=>E("selection",[])),reconfigureCollection:D,setEditingDetailSelection:i=>p(c=>c.setEditingDetailSelection(i)),setEnabled:H,setFilterResourceIds:le,setQuery:Z,ensureStore:A,setBatchSaveAttempted:i=>p(c=>c.setBatchSaveAttempted(i)),clear:()=>p(i=>i.clear()),ensureCollectionLoaded:async()=>await $(async i=>i.ensureCollectionLoaded()),loadResources:async()=>await $(async i=>await i.loadResources()),addResource:i=>p(c=>c.addResource(i)),checkForDeletedResource:async i=>await $(async c=>await c.checkForDeletedResource(i))==!0,recordDeletion:i=>p(c=>c.recordDeletion(i)),recordInsertion:(i,{insertAtBeginning:c=!1,transientData:T=void 0}={})=>p(N=>N.recordInsertion(i,{insertAtBeginning:c,transientData:T})),recordUpdate:i=>p(c=>c.recordUpdate(i)),refreshResource:async i=>await $(async c=>await c.refreshResource(i)),deleteResource:async i=>await $(async c=>await c.deleteResource(i)),saveResource:async i=>await $(async c=>await c.saveResource(i)),saveResources:async i=>await $(async c=>await c.saveResources(i)),clearTransientData:()=>p(i=>i.clearTransientData()),setInvalidResourceIds:i=>p(c=>c.setInvalidResourceIds(i)),setTransientDataForResources:i=>p(c=>c.setTransientDataForResources(i)),clearSelection:()=>p(i=>i.clearSelection()),deselectResources:i=>p(c=>c.deselectResources(i)),selectResources:(i,c)=>p(T=>T.selectResources(i,c)),hideDetail:()=>p(i=>i.hideDetail()),deregisterEditor:i=>p(c=>c.deregisterEditor(i)),registerEditor:i=>p(c=>c.registerEditor(i)),deregisterListNavigator:i=>p(c=>c.deregisterListNavigator(i)),registerListNavigator:i=>p(c=>c.registerListNavigator(i)),onItemsStoreReady:Pe}},Te=()=>{_.clearAllStores()};function se(m,n){return s.get(m,(n==null?void 0:n.idProperty)||"_id")}const fe={idProperty:"_id"},Y={resource:null,status:"NotLoaded"},Le=(m,n)=>{n=s.merge({},fe,n);const y=ce.defineStore(m,{state:()=>({idProperty:n.idProperty,resourceId:n.resourceId||null,resourceUrl:n.resourceUrl||null,referencePathsToExpand:n.referencePathsToExpand||null,...Y}),getters:{currentResourceUrl:e=>e.resourceUrl||(n.restCollectionUrl&&e.resourceId?`${n.restCollectionUrl}/${e.resourceId}`:null)||n.restCollectionUrl||null,fixedQueryParams:e=>{const r={};return e.referencePathsToExpand&&(r.r=G(e.referencePathsToExpand)),r}},actions:{reset(){for(const e in Y)this[e]=Y[e]},async setResourceId(e){const r=this.currentResourceUrl;this.resourceId=e,!s.isEqual(this.currentResourceUrl,r)&&this.status!="NotLoaded"&&await this.loadResource()},async setResourceUrl(e){const r=this.currentResourceUrl;this.resourceUrl=e,!s.isEqual(this.currentResourceUrl,r)&&this.status!="NotLoaded"&&await this.loadResource()},clear(){for(const e in Y)this[e]=Y[e]},async ensureResourceLoaded(){["Loaded","Loading","Failed"].includes(this.status)||await this.loadResource()},async loadResource(){this.reset();const e=U.v4();if(this._loadId=e,this.currentResourceUrl){this.status="Loading";const r=this.fixedQueryParams,t=s.cloneDeep(r),l=s.map(t,(u,h)=>u!=null?`${encodeURIComponent(h)}=${encodeURIComponent(u)}`:null).filter(u=>u!=null).join("&"),d=s.isEmpty(l)?this.currentResourceUrl:`${this.currentResourceUrl}?${l}`;try{const u=await q.get(d),h=this.fixedQueryParams;e!=this._loadId||!s.isEqual(r,h)?console.log(`Discarding resource fetched by obsolete query from ${d}.`):(this.resource=ae.decode(s.get(u,"data",{})),this.status="Loaded")}catch(u){console.log(`Error while loading resource (URL="${d}")`,u),this.reset(),this.status="Failed"}}else throw"Cannot load a resource because its URL, or its ID and collection URL, are unknown."},async checkForDeletedResource(){if(this.currentResourceUrl){let e;try{e=await q.get(this.currentResourceUrl)}catch(r){q.isAxiosError(r)&&(e=r.response)}return e&&e.status==404?(this.recordDeletion(),!0):!1}else throw"Cannot check for a deleted resource because its URL, or its ID and collection URL, are unknown."},recordDeletion(){this.resource=null,this.status="Loaded"},recordInsertion(e){this.resourceId=se(e,this)||null,this.status=="Loaded"&&(this.resource=Object.freeze(e))},recordUpdate(e){this.resourceId=se(e,this)||null,this.status=="Loaded"&&(this.resource=Object.freeze(e))},async refreshResource(){return await this.loadResource(),this.resource},async deleteResource(){if(this.currentResourceUrl)(await q.delete(this.currentResourceUrl)).status==200&&this.recordDeletion();else throw"Cannot delete a resource because its URL, or its ID and collection URL, are unknown."},async saveResource(e){const r=se(e,this),t=r==null;if(!r)throw"The REST resource store cannot create new resources on the server.";if(!this.currentResourceUrl)throw"Cannot save a resource because its URL, or its ID and collection URL, are unknown.";const l=await q({method:t?"post":"put",url:this.currentResourceUrl,data:e});if(l.status==200){const d=l.data,u=await this.refreshResource();return t&&this.recordInsertion(u||d),u||Object.freeze(d)}return null},async makeCustomApiRequest(e){const{method:r,subpath:t,url:l,data:d}=e;let u=l;if(!u)if(this.currentResourceUrl)u=`${this.currentResourceUrl}/${t}`;else throw"Cannot make a custom API request for a resource because its URL, or its ID and collection URL, are unknown.";const h=await q({method:r||"get",url:u,data:d});return h.status>=200&&h.status<300?h.data:null}}});return(()=>{const e=(r,t)=>{const l=y(r,t);return re.registerStore(l.$id,l),l};return e.$id=y.$id,e})()},re=new de,$e=(m={})=>{const{resourceClientId:n,draftBatchId:y,enabled:I,resourceType:e,options:r}=m,t=o.ref(void 0),l=o.ref(n),d=o.ref(y),u=o.ref(I??!0),h=o.ref([o.toRef(e)]),S=o.ref(r),C=o.computed(()=>d.value),L=o.ref(u.value),k=o.ref(U.v4()),x=o.computed(()=>d.value==null&&l.value!=null&&re.getStore(l.value)!=null),O=o.ref(x.value),B=o.computed(()=>p("status","Uninitialized"));function P(a){if(t.value)return a(t.value)}async function w(a){if(t.value)return await a(t.value)}function p(a,f){if(t.value)return t.value[a];if(f!==void 0)return f;throw"Attempted to use a REST resource store that has not been created, with no default value."}const $=(a={})=>{const{resourceClientId:f,draftBatchId:z,enabled:A,resourceType:J,options:W}=a;l.value=f,d.value=z,u.value=A??!0,h.value=[o.toRef(J)],W!=null&&(S.value=W),k.value=U.v4(),E(u.value)},E=async a=>{a!=L.value&&(L.value=a,a&&F())},D=o.computed(()=>h.value[0].value||void 0),H=function(a){const f=s.get(a,"referencePathsToExpand"),z=D.value?s.isFunction(f)?f(D.value):f||[]:[];return{...s.cloneDeep(a||{}),referencePathsToExpand:z}},le=o.computed(()=>H(S.value)),Z=o.computed(()=>{if(!D.value)return null;if(!O.value)return!D.value||!D.value.collectionName?null:C.value?`${X.config.apiBaseUrl}/draft-batches/${C.value}/${D.value.collectionName}`:`${X.config.apiBaseUrl}/${D.value.collectionName}`}),V=o.computed(()=>{if(D.value&&Z.value)return s.mergeWith(s.cloneDeep(fe),le.value,{idProperty:D.value.idProperty,restCollectionUrl:Z.value},(a,f)=>{if(s.isArray(f)&&f.length==0&&(a==null||s.isArray(a)))return f})}),R=o.ref(0),Q=o.computed(()=>{var a;return R.value,l.value||D.value&&((a=D.value)==null?void 0:a.collectionName)&&(C.value?`draftBatches/${C.value}/${D.value.collectionName}/${k.value}`:`${D.value.collectionName}/${k.value}`)||null}),F=()=>{if(L.value){let a=!1;return D.value&&Q.value&&(t.value=re.getStore(Q.value),t.value?a=!1:V.value&&(O.value=!1,t.value=Le(Q.value,V.value)(),a=!0)),a}else return!1},M=()=>{Q.value&&l.value==Q.value?(t.value=void 0,F()):(t.value=void 0,R.value=R.value+1,F())};return o.watch(C,(a,f)=>{s.isEqual(a,f)||M()}),o.watch(L,(a,f)=>{a!=f&&(a?F():t.value=void 0)}),o.watch(D,(a,f)=>{a&&!f?F():!a&&f||s.isEqual(a,f)||M()}),o.watch(V,(a,f)=>{s.isEqual(a,f)||M()}),o.watch(x,()=>{x.value||(O.value=!1)}),o.watch(Q,()=>F()),o.watch(Z,(a,f)=>{s.isEqual(a,f)||M()}),F(),{resourceClientId:Q,draftBatchId:C,enabled:L,resourceType:D,status:B,resource:o.computed(()=>B.value!="Uninitialized"?(w(a=>a.ensureResourceLoaded()),p("resource",[])):[]),resourceId:o.computed(()=>p("resourceId",null)),resourceUrl:o.computed(()=>p("resourceUrl",null)),reconfigureClient:$,setEnabled:E,setResourceId:async a=>await w(async f=>await f.setResourceId(a)),setResourceUrl:async a=>await w(async f=>await f.setResourceUrl(a)),ensureStore:F,clear:()=>P(a=>a.clear()),ensureResourceLoaded:async()=>await w(async a=>a.ensureResourceLoaded()),loadResource:async()=>await w(async a=>await a.loadResource()),checkForDeletedResource:async()=>await w(async a=>await a.checkForDeletedResource())==!0,recordDeletion:()=>w(a=>a.recordDeletion()),recordInsertion:a=>w(f=>f.recordInsertion(a)),recordUpdate:a=>w(f=>f.recordUpdate(a)),refreshResource:async()=>await w(async a=>await a.refreshResource()),deleteResource:async()=>await w(async a=>await a.deleteResource()),saveResource:async a=>await w(async f=>await f.saveResource(a)),makeCustomApiRequest:async a=>await w(async f=>await f.makeCustomApiRequest(a))}},X={config:{...ue}};function qe(m){X.config=s.merge({},ue,m)}v.ApiClientError=we,v.clearAllRestCollections=Te,v.initRestClient=qe,v.restClient=X,v.useRestCollection=Ee,v.useRestResource=$e,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rest-collection-store.d.ts","sourceRoot":"","sources":["../../../src/stores/rest-collection-store.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,sBAAsB,EAAE,sBAAsB,EAAC,MAAM,uBAAuB,CAAA;AACpF,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,eAAe,CAAA;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAA;
|
1
|
+
{"version":3,"file":"rest-collection-store.d.ts","sourceRoot":"","sources":["../../../src/stores/rest-collection-store.ts"],"names":[],"mappings":"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"}
|