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.
@@ -1,18 +1,18 @@
1
1
  var Ee = Object.defineProperty;
2
- var we = (f, s, S) => s in f ? Ee(f, s, { enumerable: !0, configurable: !0, writable: !0, value: S }) : f[s] = S;
3
- var ae = (f, s, S) => (we(f, typeof s != "symbol" ? s + "" : s, S), S), Te = (f, s, S) => {
4
- if (!s.has(f))
5
- throw TypeError("Cannot " + S);
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 = (f, s, S) => (Te(f, s, "read from private field"), S ? S.call(f) : s.get(f)), Se = (f, s, S) => {
8
- if (s.has(f))
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(f) : s.set(f, S);
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 I, toRef as se, computed as R, watch as T, nextTick as Le } from "vue";
15
- import P from "axios";
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(S, $ = void 0, e = void 0) {
25
- super(S);
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 = $, this.innerError = e;
28
+ this.context = I, this.innerError = e;
29
29
  }
30
30
  }
31
- var k;
31
+ var B;
32
32
  class Ie {
33
33
  constructor() {
34
- Se(this, k, {});
34
+ Se(this, B, {});
35
35
  }
36
36
  clearAllStores() {
37
- for (const s in Q(this, k))
38
- Q(this, k)[s].clear();
37
+ for (const s in Q(this, B))
38
+ Q(this, B)[s].clear();
39
39
  }
40
40
  destroyStore(s) {
41
- Q(this, k)[s] && (Q(this, k)[s].$dispose(), delete Q(this, k)[s]);
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, k)[s];
44
+ return Q(this, B)[s];
45
45
  }
46
- registerStore(s, S) {
47
- Q(this, k)[s] = S;
46
+ registerStore(s, g) {
47
+ Q(this, B)[s] = g;
48
48
  }
49
49
  }
50
- k = new WeakMap();
51
- function v(f, s) {
52
- return a.get(f, (s == null ? void 0 : s.idProperty) || "_id");
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(f, s) {
55
- var S;
56
- return f && ((S = s.filter) != null && S.resourceIds) && !s.order ? s.filter.resourceIds.map(($) => f.find((e) => v(e, s) == $)).filter(($) => $ != null) : f;
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
- }, Z = {
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
- }, oe = {
103
+ }, ne = {
93
104
  editingDetailSelection: !1,
94
105
  batchSaveAttempted: !1,
95
106
  editors: [],
96
107
  listNavigators: {}
97
- }, Pe = (f, s) => {
108
+ }, xe = (h, s) => {
98
109
  s = a.merge({}, De, s);
99
- const S = pe(f, {
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
- ...Z,
108
- ...oe
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 y = t.length == 1 ? t[0] : { and: t };
123
- r.q = X(y);
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 Z)
139
- this[e] = Z[e];
140
- for (const e in oe)
141
- this[e] = oe[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 Z)
242
- this[e] = Z[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 z, F, A, B, O;
304
+ var L, A, N, k, O;
294
305
  const l = e == 0;
295
- if (this.status = l ? "Loading" : "LoadingMore", this._loadOffset = e, ((z = this.filter) == null ? void 0 : z.query) === !1) {
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 ? (F = this.filter) != null && F.resourceIds && !this.order ? null : t.firstPageSize || ((A = s.loading) == null ? void 0 : A.firstPageSize) || t.pageSize || ((B = s.loading) == null ? void 0 : B.pageSize) || null : t.pageSize || ((O = s.loading) == null ? void 0 : O.pageSize) || null, y = d != null || s.limit != null ? a.min(a.filter([d, s.limit], (g) => g != null)) : void 0;
300
- y != null ? (c.offset = e, c.limit = y) : e != 0 && (c.offset = e);
301
- const U = a.map(
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 g = await P.get(L), m = this.fixedQueryParams;
307
- if (r != this._loadId || e != this._loadOffset || !a.isEqual(u, m))
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 C = me.decode(a.get(g, "data.data", [])), w = (l ? 0 : this.resources.length) + C.length, D = y == null || C.length < y || s.limit && w >= s.limit;
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 ${C.length}${l ? "" : " more"} resources from ${s.restCollectionUrl}`
320
+ `Loaded ${S.length}${l ? "" : " more"} resources from ${s.restCollectionUrl}`
313
321
  ), l && (this.resources = []);
314
- const W = [...this.resources, ...C.map((J) => Object.freeze(J))];
315
- this.resources = $e(W, this), a.get(g, "data.totalCollectionSize") ? this.remoteCollectionSize = a.get(g, "data.totalCollectionSize") : this.remoteCollectionSize = null, this.status = D ? "Loaded" : "LoadingMore", D || this._loadResources(this.resources.length, r, t);
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 (g) {
318
- console.log(`Error while loading resources (URL="${L}"):`, g), this.clearRetainingTransientData(), this.status = "Failed";
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 P.get(`${s.restCollectionUrl}/${e}`);
344
+ r = await x.get(`${s.restCollectionUrl}/${e}`);
337
345
  } catch (t) {
338
- P.isAxiosError(t) && (r = t.response);
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 P.get(l);
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 P.delete(`${s.restCollectionUrl}/${e}`)).status == 200 && ["Loaded", "LoadingMore"].includes(this.status)) {
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 P({
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 P({
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, y = v(c, this), U = y ? await this.refreshResource(y) : null;
498
- d && this.recordInsertion(U || c), l.push(U || Object.freeze(c));
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((y) => y != null));
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 = S(r, t);
682
- return re.registerStore(l.$id, l), l;
689
+ const l = g(r, t);
690
+ return se.registerStore(l.$id, l), l;
683
691
  };
684
- return e.$id = S.$id, e;
692
+ return e.$id = g.$id, e;
685
693
  })();
686
- }, re = new Ie(), Oe = (f = {}) => {
694
+ }, se = new Ie(), Qe = (h = {}) => {
687
695
  var ue, de, he, fe;
688
696
  const {
689
697
  collectionId: s,
690
- draftBatchId: S,
691
- enabled: $,
698
+ draftBatchId: g,
699
+ enabled: I,
692
700
  resourceType: e,
693
701
  options: r
694
- } = f, t = I(void 0), l = I(s), u = I(S), c = I($ ?? !0), d = I([se(e)]), y = I(r), U = R(() => u.value), L = I(c.value), z = I(H()), F = I((de = (ue = y.value) == null ? void 0 : ue.filter) == null ? void 0 : de.resourceIds), A = I((fe = (he = y.value) == null ? void 0 : he.filter) == null ? void 0 : fe.query), B = R(
695
- () => u.value == null && l.value != null && re.getStore(l.value) != null
696
- ), O = I(B.value), g = R(() => w("status", "Uninitialized"));
697
- function m(i) {
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 C(i) {
709
+ async function $(i) {
702
710
  if (t.value)
703
711
  return await i(t.value);
704
712
  }
705
- function w(i, n) {
713
+ function E(i, o) {
706
714
  if (t.value)
707
715
  return t.value[i];
708
- if (n !== void 0)
709
- return n;
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 D = (i = {}) => {
713
- var ie, ve, ge, Re;
720
+ const U = (i = {}) => {
721
+ var te, ve, ge, Re;
714
722
  const {
715
- collectionId: n,
716
- draftBatchId: E,
717
- enabled: q,
723
+ collectionId: o,
724
+ draftBatchId: w,
725
+ enabled: F,
718
726
  resourceType: le,
719
- options: te
727
+ options: ee
720
728
  } = i;
721
- l.value = n, u.value = E, c.value = q ?? !0, d.value = [se(le)], te != null && (y.value = te, F.value = (ve = (ie = y.value) == null ? void 0 : ie.filter) == null ? void 0 : ve.resourceIds, A.value = (Re = (ge = y.value) == null ? void 0 : ge.filter) == null ? void 0 : Re.query), z.value = H(), W(c.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 && (Y(), b()));
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
- F.value = i, await C(async (n) => await n.setFilterResourceIds(F.value || null));
726
- }, K = async (i) => {
727
- if (A.value = i, g.value != "Uninitialized") {
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
- }, Y = () => {
732
- y.value = a.merge({}, y.value || {}, {
733
- filter: { resourceIds: F.value, query: A.value }
739
+ }, K = () => {
740
+ p.value = a.merge({}, p.value || {}, {
741
+ filter: { resourceIds: N.value, query: k.value }
734
742
  });
735
- }, p = R(
743
+ }, m = R(
736
744
  () => d.value[0].value || void 0
737
745
  ), _ = function(i) {
738
- const n = a.get(i, "filter.query"), E = a.get(i, "propertyBlacklist"), q = a.get(i, "referencePathsToExpand"), le = a.isFunction(n) ? n(p.value) : n, te = p.value ? a.isFunction(E) ? E(p.value) : E || [] : [], ie = p.value ? a.isFunction(q) ? q(p.value) : q || [] : [];
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: te,
746
- referencePathsToExpand: ie
753
+ propertyBlacklist: ee,
754
+ referencePathsToExpand: te
747
755
  };
748
- }, x = R(() => _(y.value)), M = R(() => {
749
- if (x.value.restCollectionUrl !== void 0)
750
- return x.value.restCollectionUrl;
751
- if (!O.value)
752
- return !p.value || !p.value.collectionName ? null : U.value ? `${ee.config.apiBaseUrl}/draft-batches/${U.value}/${p.value.collectionName}` : `${ee.config.apiBaseUrl}/${p.value.collectionName}`;
753
- }), o = R(() => {
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 (p.value)
763
+ if (m.value)
756
764
  return a.mergeWith(
757
765
  a.cloneDeep(De),
758
- x.value,
766
+ q.value,
759
767
  {
760
- idProperty: (i = p.value) == null ? void 0 : i.idProperty,
768
+ idProperty: (i = m.value) == null ? void 0 : i.idProperty,
761
769
  restCollectionUrl: M.value || ""
762
770
  },
763
- (n, E) => {
764
- if (a.isArray(E) && E.length == 0 && (n == null || a.isArray(n)))
765
- return E;
771
+ (o, w) => {
772
+ if (a.isArray(w) && w.length == 0 && (o == null || a.isArray(o)))
773
+ return w;
766
774
  }
767
775
  );
768
- }), h = I(0), N = R(
776
+ }), f = y(0), b = R(
769
777
  () => {
770
778
  var i;
771
- return h.value, l.value || p.value && ((i = p.value) == null ? void 0 : i.collectionName) && (U.value ? `draftBatches/${U.value}/${p.value.collectionName}/${z.value}` : `${p.value.collectionName}/${z.value}`) || null;
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
- ), b = () => {
781
+ ), z = () => {
774
782
  if (L.value) {
775
783
  let i = !1;
776
- return p.value && N.value && (t.value = re.getStore(N.value), t.value ? i = !1 : o.value && (O.value = !1, t.value = Pe(N.value, o.value)(), i = !0)), i;
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
- N.value && l.value == N.value ? (t.value = void 0, b()) : (t.value = void 0, h.value = h.value + 1, b());
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(U, (i, n) => {
783
- a.isEqual(i, n) || G();
784
- }), T(L, (i, n) => {
785
- i != n && (i ? b() : t.value = void 0);
786
- }), T(p, (i, n) => {
787
- i && !n ? b() : !i && n || a.isEqual(i, n) || G();
788
- }), T(o, (i, n) => {
789
- a.isEqual(i, n) || G();
790
- }), T(B, () => {
791
- B.value || (O.value = !1);
792
- }), T(N, () => b()), T(M, (i, n) => {
793
- a.isEqual(i, n) || G();
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
- g.value != "Uninitialized" ? Le(i) : j.push(i);
804
+ D.value != "Uninitialized" ? Le(i) : j.push(i);
797
805
  };
798
- return T(g, (i, n) => {
799
- if (i != "Uninitialized" && n == "Uninitialized") {
800
- const E = a.clone(j);
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 q of E)
803
- q();
810
+ for (const F of w)
811
+ F();
804
812
  }
805
- }), b(), {
813
+ }), z(), {
806
814
  // Configuration
807
- collectionId: N,
808
- draftBatchId: U,
809
- resourceType: p,
810
- restCollectionUrl: R(() => w("restCollectionUrl", null)),
815
+ collectionId: b,
816
+ draftBatchId: C,
817
+ resourceType: m,
818
+ restCollectionUrl: R(() => E("restCollectionUrl", null)),
811
819
  // Status
812
820
  enabled: L,
813
- status: g,
814
- batchSaveAttempted: R(() => w("batchSaveAttempted", !1)),
815
- listNavigators: R(() => w("listNavigators", !1)),
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(() => w("invalidResources", [])),
818
- resources: R(() => g.value != "Uninitialized" ? (C((i) => i.ensureCollectionLoaded()), w("resources", [])) : []),
819
- remoteCollectionSize: R(() => w("remoteCollectionSize", null)),
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(() => w("transientData", [])),
829
+ transientData: R(() => E("transientData", [])),
822
830
  // Selection and detail selection
823
- detailSelection: R(() => w("detailSelection", [])),
824
- editingDetailSelection: R(() => w("editingDetailSelection", !1)),
825
- selection: R(() => w("selection", [])),
831
+ detailSelection: R(() => E("detailSelection", [])),
832
+ editingDetailSelection: R(() => E("editingDetailSelection", !1)),
833
+ selection: R(() => E("selection", [])),
826
834
  // Methods: Configuration
827
- reconfigureCollection: D,
828
- setEditingDetailSelection: (i) => m(
829
- (n) => n.setEditingDetailSelection(i)
835
+ reconfigureCollection: U,
836
+ setEditingDetailSelection: (i) => S(
837
+ (o) => o.setEditingDetailSelection(i)
830
838
  ),
831
839
  setEnabled: W,
832
- setFilterResourceIds: J,
833
- setQuery: K,
840
+ setFilterResourceIds: re,
841
+ setQuery: J,
834
842
  // Methods: Status
835
- ensureStore: b,
843
+ ensureStore: z,
836
844
  // TODO Rename
837
- setBatchSaveAttempted: (i) => m((n) => n.setBatchSaveAttempted(i)),
845
+ setBatchSaveAttempted: (i) => S((o) => o.setBatchSaveAttempted(i)),
838
846
  // Local collection management
839
- clear: () => m((i) => i.clear()),
840
- ensureCollectionLoaded: async () => await C(async (i) => i.ensureCollectionLoaded()),
841
- loadResources: async () => await C(async (i) => await i.loadResources()),
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) => m((n) => n.addResource(i)),
844
- checkForDeletedResource: async (i) => await C(async (n) => await n.checkForDeletedResource(i)) == !0,
845
- recordDeletion: (i) => m((n) => n.recordDeletion(i)),
846
- recordInsertion: (i, { insertAtBeginning: n = !1, transientData: E = void 0 } = {}) => m((q) => q.recordInsertion(i, { insertAtBeginning: n, transientData: E })),
847
- recordUpdate: (i) => m((n) => n.recordUpdate(i)),
848
- refreshResource: async (i) => await C(
849
- async (n) => await n.refreshResource(i)
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 C(
853
- async (n) => await n.deleteResource(i)
860
+ deleteResource: async (i) => await $(
861
+ async (o) => await o.deleteResource(i)
854
862
  ),
855
- saveResource: async (i) => await C(async (n) => await n.saveResource(i)),
856
- saveResources: async (i) => await C(async (n) => await n.saveResources(i)),
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: () => m((i) => i.clearTransientData()),
859
- setInvalidResourceIds: (i) => m((n) => n.setInvalidResourceIds(i)),
860
- setTransientDataForResources: (i) => m(
861
- (n) => n.setTransientDataForResources(i)
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: () => m((i) => i.clearSelection()),
865
- deselectResources: (i) => m((n) => n.deselectResources(i)),
866
- selectResources: (i, n) => m(
867
- (E) => E.selectResources(i, n)
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: () => m((i) => i.hideDetail()),
878
+ hideDetail: () => S((i) => i.hideDetail()),
871
879
  // Methods: Editors
872
- deregisterEditor: (i) => m((n) => n.deregisterEditor(i)),
873
- registerEditor: (i) => m((n) => n.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) => m((n) => n.deregisterListNavigator(i)),
876
- registerListNavigator: (i) => m((n) => n.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
- }, Qe = () => {
881
- re.clearAllStores();
888
+ }, Me = () => {
889
+ se.clearAllStores();
882
890
  };
883
- function ne(f, s) {
884
- return a.get(f, (s == null ? void 0 : s.idProperty) || "_id");
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
- }, V = {
896
+ }, Z = {
889
897
  resource: null,
890
898
  status: "NotLoaded"
891
- }, xe = (f, s) => {
899
+ }, qe = (h, s) => {
892
900
  s = a.merge({}, Ue, s);
893
- const S = pe(f, {
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
- ...V
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 V)
920
- this[e] = V[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 V)
940
- this[e] = V[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 P.get(u), d = this.fixedQueryParams;
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 P.get(this.currentResourceUrl);
996
+ e = await x.get(this.currentResourceUrl);
989
997
  } catch (r) {
990
- P.isAxiosError(r) && (e = r.response);
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 = ne(e, this) || null, this.status == "Loaded" && (this.resource = Object.freeze(e));
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 = ne(e, this) || null, this.status == "Loaded" && (this.resource = Object.freeze(e));
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 P.delete(this.currentResourceUrl)).status == 200 && this.recordDeletion();
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 = ne(e, this), t = r == null;
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 P({
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 P({
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 = S(r, t);
1123
+ const l = g(r, t);
1116
1124
  return ce.registerStore(l.$id, l), l;
1117
1125
  };
1118
- return e.$id = S.$id, e;
1126
+ return e.$id = g.$id, e;
1119
1127
  })();
1120
- }, ce = new Ie(), Me = (f = {}) => {
1128
+ }, ce = new Ie(), je = (h = {}) => {
1121
1129
  const {
1122
1130
  resourceClientId: s,
1123
- draftBatchId: S,
1124
- enabled: $,
1131
+ draftBatchId: g,
1132
+ enabled: I,
1125
1133
  resourceType: e,
1126
1134
  options: r
1127
- } = f, t = I(void 0), l = I(s), u = I(S), c = I($ ?? !0), d = I([se(e)]), y = I(r), U = R(() => u.value), L = I(c.value), z = I(H()), F = R(
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
- ), A = I(F.value), B = R(() => m("status", "Uninitialized"));
1130
- function O(o) {
1137
+ ), k = y(N.value), O = R(() => S("status", "Uninitialized"));
1138
+ function P(n) {
1131
1139
  if (t.value)
1132
- return o(t.value);
1140
+ return n(t.value);
1133
1141
  }
1134
- async function g(o) {
1142
+ async function D(n) {
1135
1143
  if (t.value)
1136
- return await o(t.value);
1144
+ return await n(t.value);
1137
1145
  }
1138
- function m(o, h) {
1146
+ function S(n, f) {
1139
1147
  if (t.value)
1140
- return t.value[o];
1141
- if (h !== void 0)
1142
- return h;
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 C = (o = {}) => {
1153
+ const $ = (n = {}) => {
1146
1154
  const {
1147
- resourceClientId: h,
1148
- draftBatchId: N,
1149
- enabled: b,
1155
+ resourceClientId: f,
1156
+ draftBatchId: b,
1157
+ enabled: z,
1150
1158
  resourceType: G,
1151
1159
  options: j
1152
- } = o;
1153
- l.value = h, u.value = N, c.value = b ?? !0, d.value = [se(G)], j != null && (y.value = j), z.value = H(), w(c.value);
1154
- }, w = async (o) => {
1155
- o != L.value && (L.value = o, o && x());
1156
- }, D = R(
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(o) {
1159
- const h = a.get(o, "referencePathsToExpand"), N = D.value ? a.isFunction(h) ? h(D.value) : h || [] : [];
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(o || {}),
1162
- referencePathsToExpand: N
1169
+ ...a.cloneDeep(n || {}),
1170
+ referencePathsToExpand: b
1163
1171
  };
1164
- }, J = R(() => W(y.value)), K = R(() => {
1165
- if (!D.value)
1172
+ }, re = R(() => W(p.value)), J = R(() => {
1173
+ if (!U.value)
1166
1174
  return null;
1167
- if (!A.value)
1168
- return !D.value || !D.value.collectionName ? null : U.value ? `${ee.config.apiBaseUrl}/draft-batches/${U.value}/${D.value.collectionName}` : `${ee.config.apiBaseUrl}/${D.value.collectionName}`;
1169
- }), Y = R(() => {
1170
- if (D.value && K.value)
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
- J.value,
1181
+ re.value,
1174
1182
  {
1175
- idProperty: D.value.idProperty,
1176
- restCollectionUrl: K.value
1183
+ idProperty: U.value.idProperty,
1184
+ restCollectionUrl: J.value
1177
1185
  },
1178
- (o, h) => {
1179
- if (a.isArray(h) && h.length == 0 && (o == null || a.isArray(o)))
1180
- return h;
1186
+ (n, f) => {
1187
+ if (a.isArray(f) && f.length == 0 && (n == null || a.isArray(n)))
1188
+ return f;
1181
1189
  }
1182
1190
  );
1183
- }), p = I(0), _ = R(
1191
+ }), m = y(0), _ = R(
1184
1192
  () => {
1185
- var o;
1186
- return p.value, l.value || D.value && ((o = D.value) == null ? void 0 : o.collectionName) && (U.value ? `draftBatches/${U.value}/${D.value.collectionName}/${z.value}` : `${D.value.collectionName}/${z.value}`) || null;
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
- ), x = () => {
1196
+ ), q = () => {
1189
1197
  if (L.value) {
1190
- let o = !1;
1191
- return D.value && _.value && (t.value = ce.getStore(_.value), t.value ? o = !1 : Y.value && (A.value = !1, t.value = xe(_.value, Y.value)(), o = !0)), o;
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, x()) : (t.value = void 0, p.value = p.value + 1, x());
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(U, (o, h) => {
1198
- a.isEqual(o, h) || M();
1199
- }), T(L, (o, h) => {
1200
- o != h && (o ? x() : t.value = void 0);
1201
- }), T(D, (o, h) => {
1202
- o && !h ? x() : !o && h || a.isEqual(o, h) || M();
1203
- }), T(Y, (o, h) => {
1204
- a.isEqual(o, h) || M();
1205
- }), T(F, () => {
1206
- F.value || (A.value = !1);
1207
- }), T(_, () => x()), T(K, (o, h) => {
1208
- a.isEqual(o, h) || M();
1209
- }), x(), {
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: U,
1220
+ draftBatchId: C,
1213
1221
  enabled: L,
1214
- resourceType: D,
1222
+ resourceType: U,
1215
1223
  // Status
1216
- status: B,
1224
+ status: O,
1217
1225
  // Resources loaded from the REST API
1218
- resource: R(() => B.value != "Uninitialized" ? (g((o) => o.ensureResourceLoaded()), m("resource", [])) : []),
1219
- resourceId: R(() => m("resourceId", null)),
1220
- resourceUrl: R(() => m("resourceUrl", null)),
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: C,
1223
- setEnabled: w,
1224
- setResourceId: async (o) => await g(async (h) => await h.setResourceId(o)),
1225
- setResourceUrl: async (o) => await g(async (h) => await h.setResourceUrl(o)),
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: x,
1235
+ ensureStore: q,
1228
1236
  // Methods: Resource management
1229
- clear: () => O((o) => o.clear()),
1230
- ensureResourceLoaded: async () => await g(async (o) => o.ensureResourceLoaded()),
1231
- loadResource: async () => await g(async (o) => await o.loadResource()),
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 g(async (o) => await o.checkForDeletedResource()) == !0,
1234
- recordDeletion: () => g((o) => o.recordDeletion()),
1235
- recordInsertion: (o) => g((h) => h.recordInsertion(o)),
1236
- recordUpdate: (o) => g((h) => h.recordUpdate(o)),
1237
- refreshResource: async () => await g(async (o) => await o.refreshResource()),
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 g(async (o) => await o.deleteResource()),
1240
- saveResource: async (o) => await g(async (h) => await h.saveResource(o)),
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 (o) => await g(
1243
- async (h) => await h.makeCustomApiRequest(o)
1250
+ makeCustomApiRequest: async (n) => await D(
1251
+ async (f) => await f.makeCustomApiRequest(n)
1244
1252
  )
1245
1253
  };
1246
- }, ee = {
1254
+ }, V = {
1247
1255
  config: { ...ye }
1248
1256
  };
1249
- function je(f) {
1250
- ee.config = a.merge({}, ye, f);
1257
+ function We(h) {
1258
+ V.config = a.merge({}, ye, h);
1251
1259
  }
1252
1260
  export {
1253
1261
  _e as ApiClientError,
1254
- Qe as clearAllRestCollections,
1255
- je as initRestClient,
1256
- ee as restClient,
1257
- Oe as useRestCollection,
1258
- Me as useRestResource
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,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