rest-client-vue 1.1.1-b1 → 1.1.1-b2

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.
@@ -12,7 +12,7 @@ var Q = (f, s, R) => (Te(f, s, "read from private field"), R ? R.call(f) : s.get
12
12
  import a from "lodash";
13
13
  import { v4 as X } from "uuid";
14
14
  import { ref as I, toRef as te, computed as S, watch as C, nextTick as Le } from "vue";
15
- import P from "axios";
15
+ import N from "axios";
16
16
  import me from "jsog";
17
17
  import V from "json-stringify-deterministic";
18
18
  import { defineStore as ye } from "pinia";
@@ -83,6 +83,7 @@ const De = {
83
83
  ]
84
84
  }, Y = {
85
85
  resources: [],
86
+ totalNumResources: null,
86
87
  status: "NotLoaded",
87
88
  selection: [],
88
89
  detailSelection: [],
@@ -93,7 +94,7 @@ const De = {
93
94
  batchSaveAttempted: !1,
94
95
  editors: [],
95
96
  listNavigators: {}
96
- }, Pe = (f, s) => {
97
+ }, Ne = (f, s) => {
97
98
  s = a.merge({}, De, s);
98
99
  const R = ye(f, {
99
100
  state: () => ({
@@ -175,7 +176,7 @@ const De = {
175
176
  * @param filter The new filter.
176
177
  */
177
178
  setFilter(e) {
178
- a.isEqual(e, this.filter) || (this.filter = e, this.status = "NotLoaded", this.resources = [], this.selection = [], this.detailSelection = [], this.invalidResources = [], this.editingDetailSelection = !1);
179
+ a.isEqual(e, this.filter) || (this.filter = e, this.status = "NotLoaded", this.resources = [], this.totalNumResources = null, this.selection = [], this.detailSelection = [], this.invalidResources = [], this.editingDetailSelection = !1);
179
180
  },
180
181
  /**
181
182
  * Set the filter query.
@@ -287,29 +288,29 @@ const De = {
287
288
  * @param loadOptions Pagination options that may override the defaults.
288
289
  */
289
290
  async _loadResources(e, r, t) {
290
- var b, q, A, z, B;
291
+ var b, x, A, z, B;
291
292
  const l = e == 0;
292
293
  if (this.status = l ? "Loading" : "LoadingMore", this._loadOffset = e, ((b = this.filter) == null ? void 0 : b.query) === !1) {
293
- this.resources = [];
294
+ this.resources = [], this.totalNumResources = 0;
294
295
  return;
295
296
  }
296
- const u = this.fixedQueryParams, c = a.cloneDeep(u), d = l ? (q = this.filter) != null && q.resourceIds && !this.order ? null : t.firstPageSize || ((A = s.loading) == null ? void 0 : A.firstPageSize) || t.pageSize || ((z = s.loading) == null ? void 0 : z.pageSize) || null : t.pageSize || ((B = s.loading) == null ? void 0 : B.pageSize) || null, y = d != null || s.limit != null ? a.min(a.filter([d, s.limit], (g) => g != null)) : void 0;
297
+ const u = this.fixedQueryParams, c = a.cloneDeep(u), d = l ? (x = this.filter) != null && x.resourceIds && !this.order ? null : t.firstPageSize || ((A = s.loading) == null ? void 0 : A.firstPageSize) || t.pageSize || ((z = s.loading) == null ? void 0 : z.pageSize) || null : t.pageSize || ((B = s.loading) == null ? void 0 : B.pageSize) || null, y = d != null || s.limit != null ? a.min(a.filter([d, s.limit], (g) => g != null)) : void 0;
297
298
  y != null ? (c.offset = e, c.limit = y) : e != 0 && (c.offset = e);
298
- const U = a.map(
299
+ const E = a.map(
299
300
  c,
300
301
  (g, m) => g != null ? `${encodeURIComponent(m)}=${encodeURIComponent(g)}` : null
301
- ).filter((g) => g != null).join("&"), T = a.isEmpty(U) ? s.restCollectionUrl : `${s.restCollectionUrl}?${U}`;
302
+ ).filter((g) => g != null).join("&"), T = a.isEmpty(E) ? s.restCollectionUrl : `${s.restCollectionUrl}?${E}`;
302
303
  try {
303
- const g = await P.get(T), m = this.fixedQueryParams;
304
+ const g = await N.get(T), m = this.fixedQueryParams;
304
305
  if (r != this._loadId || e != this._loadOffset || !a.isEqual(u, m))
305
306
  console.log(`Discarding resources fetched by obsolete query from ${s.restCollectionUrl}.`);
306
307
  else {
307
- const E = me.decode(a.get(g, "data.data", [])), L = (l ? 0 : this.resources.length) + E.length, D = y == null || E.length < y || s.limit && L >= s.limit;
308
+ const U = me.decode(a.get(g, "data.data", [])), L = (l ? 0 : this.resources.length) + U.length, D = y == null || U.length < y || s.limit && L >= s.limit;
308
309
  console.log(
309
- `Loaded ${E.length}${l ? "" : " more"} resources from ${s.restCollectionUrl}`
310
+ `Loaded ${U.length}${l ? "" : " more"} resources from ${s.restCollectionUrl}`
310
311
  ), l && (this.resources = []);
311
- const W = [...this.resources, ...E.map((H) => Object.freeze(H))];
312
- this.resources = $e(W, this), this.status = D ? "Loaded" : "LoadingMore", D || this._loadResources(this.resources.length, r, t);
312
+ const W = [...this.resources, ...U.map((H) => Object.freeze(H))];
313
+ this.resources = $e(W, this), a.get(g, "data.totalNumEntities") ? this.totalNumResources = a.get(g, "data.totalNumEntities") : this.totalNumResources = null, this.status = D ? "Loaded" : "LoadingMore", D || this._loadResources(this.resources.length, r, t);
313
314
  }
314
315
  } catch (g) {
315
316
  console.log(`Error while loading resources (URL="${T}"):`, g), this.clearRetainingTransientData(), this.status = "Failed";
@@ -330,9 +331,9 @@ const De = {
330
331
  async checkForDeletedResource(e) {
331
332
  let r;
332
333
  try {
333
- r = await P.get(`${s.restCollectionUrl}/${e}`);
334
+ r = await N.get(`${s.restCollectionUrl}/${e}`);
334
335
  } catch (t) {
335
- P.isAxiosError(t) && (r = t.response);
336
+ N.isAxiosError(t) && (r = t.response);
336
337
  }
337
338
  return r && r.status == 404 ? (this.recordDeletion(e), !0) : !1;
338
339
  },
@@ -417,7 +418,7 @@ const De = {
417
418
  const t = a.map(
418
419
  r,
419
420
  (c, d) => c != null ? `${encodeURIComponent(d)}=${encodeURIComponent(c)}` : null
420
- ).filter((c) => c != null).join("&"), l = a.isEmpty(t) ? `${s.restCollectionUrl}/${e}` : `${s.restCollectionUrl}/${e}?${t}`, u = await P.get(l);
421
+ ).filter((c) => c != null).join("&"), l = a.isEmpty(t) ? `${s.restCollectionUrl}/${e}` : `${s.restCollectionUrl}/${e}?${t}`, u = await N.get(l);
421
422
  if (u.status == 200) {
422
423
  const c = u.data;
423
424
  return this.recordUpdate(c), c;
@@ -444,7 +445,7 @@ const De = {
444
445
  * @param resourceId The ID of the resource to delete.
445
446
  */
446
447
  async deleteResource(e) {
447
- if ((await P.delete(`${s.restCollectionUrl}/${e}`)).status == 200 && ["Loaded", "LoadingMore"].includes(this.status)) {
448
+ if ((await N.delete(`${s.restCollectionUrl}/${e}`)).status == 200 && ["Loaded", "LoadingMore"].includes(this.status)) {
448
449
  let t = this.resources.findIndex((l) => v(l, this) == e);
449
450
  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];
450
451
  }
@@ -461,7 +462,7 @@ const De = {
461
462
  * the operation failed.
462
463
  */
463
464
  async saveResource(e) {
464
- const r = v(e, this), t = r == null, l = await P({
465
+ const r = v(e, this), t = r == null, l = await N({
465
466
  method: t ? "post" : "put",
466
467
  url: t ? s.restCollectionUrl : `${s.restCollectionUrl}/${r}`,
467
468
  data: e
@@ -483,7 +484,7 @@ const De = {
483
484
  * @returns An array of refreshed local resources, one for each remote resource whose save operation succeeded.
484
485
  */
485
486
  async saveResources(e) {
486
- const r = await P({
487
+ const r = await N({
487
488
  method: "put",
488
489
  url: s.restCollectionUrl,
489
490
  data: e
@@ -491,8 +492,8 @@ const De = {
491
492
  if (r.status == 200) {
492
493
  const t = r.data || [], l = [];
493
494
  for (const [u, c] of t.entries()) {
494
- const d = v(e[u], this) == null, y = v(c, this), U = y ? await this.refreshResource(y) : null;
495
- d && this.recordInsertion(U || c), l.push(U || Object.freeze(c));
495
+ const d = v(e[u], this) == null, y = v(c, this), E = y ? await this.refreshResource(y) : null;
496
+ d && this.recordInsertion(E || c), l.push(E || Object.freeze(c));
496
497
  }
497
498
  return l;
498
499
  }
@@ -688,14 +689,14 @@ const De = {
688
689
  enabled: $,
689
690
  resourceType: e,
690
691
  options: r
691
- } = f, t = I(void 0), l = I(s), u = I(R), c = I($ ?? !0), d = I([te(e)]), y = I(r), U = S(() => u.value), T = I(c.value), b = I(X()), q = I((ce = (oe = y.value) == null ? void 0 : oe.filter) == null ? void 0 : ce.resourceIds), A = I((de = (ue = y.value) == null ? void 0 : ue.filter) == null ? void 0 : de.query), z = S(
692
+ } = f, t = I(void 0), l = I(s), u = I(R), c = I($ ?? !0), d = I([te(e)]), y = I(r), E = S(() => u.value), T = I(c.value), b = I(X()), x = I((ce = (oe = y.value) == null ? void 0 : oe.filter) == null ? void 0 : ce.resourceIds), A = I((de = (ue = y.value) == null ? void 0 : ue.filter) == null ? void 0 : de.query), z = S(
692
693
  () => u.value == null && l.value != null && ie.getStore(l.value) != null
693
694
  ), B = I(z.value), g = S(() => L("status", "Uninitialized"));
694
695
  function m(i) {
695
696
  if (t.value)
696
697
  return i(t.value);
697
698
  }
698
- async function E(i) {
699
+ async function U(i) {
699
700
  if (t.value)
700
701
  return await i(t.value);
701
702
  }
@@ -715,19 +716,19 @@ const De = {
715
716
  resourceType: se,
716
717
  options: he
717
718
  } = i;
718
- l.value = o, u.value = w, c.value = _ ?? !0, d.value = [te(se)], he != null && (y.value = he, q.value = (ve = (fe = y.value) == null ? void 0 : fe.filter) == null ? void 0 : ve.resourceIds, A.value = (Re = (ge = y.value) == null ? void 0 : ge.filter) == null ? void 0 : Re.query), b.value = X(), W(c.value);
719
+ l.value = o, u.value = w, c.value = _ ?? !0, d.value = [te(se)], he != null && (y.value = he, x.value = (ve = (fe = y.value) == null ? void 0 : fe.filter) == null ? void 0 : ve.resourceIds, A.value = (Re = (ge = y.value) == null ? void 0 : ge.filter) == null ? void 0 : Re.query), b.value = X(), W(c.value);
719
720
  }, W = async (i) => {
720
- i != T.value && (T.value = i, i && (K(), N()));
721
+ i != T.value && (T.value = i, i && (K(), F()));
721
722
  }, H = async (i) => {
722
- q.value = i, await E(async (o) => await o.setFilterResourceIds(q.value || null));
723
+ x.value = i, await U(async (o) => await o.setFilterResourceIds(x.value || null));
723
724
  }, J = async (i) => {
724
725
  if (A.value = i, g.value != "Uninitialized") {
725
726
  const o = i, w = S(() => a.isFunction(o) ? p.value ? o(p.value) : null : o);
726
- await E((_) => _.setQuery(w.value || null));
727
+ await U((_) => _.setQuery(w.value || null));
727
728
  }
728
729
  }, K = () => {
729
730
  y.value = a.merge({}, y.value || {}, {
730
- filter: { resourceIds: q.value, query: A.value }
731
+ filter: { resourceIds: x.value, query: A.value }
731
732
  });
732
733
  }, p = S(
733
734
  () => d.value[0].value || void 0
@@ -741,19 +742,19 @@ const De = {
741
742
  },
742
743
  referencePathsToExpand: se
743
744
  };
744
- }, x = S(() => k(y.value)), M = S(() => {
745
+ }, P = S(() => k(y.value)), M = S(() => {
745
746
  if (!p.value)
746
747
  return null;
747
- if (x.value.restCollectionUrl !== void 0)
748
- return x.value.restCollectionUrl;
748
+ if (P.value.restCollectionUrl !== void 0)
749
+ return P.value.restCollectionUrl;
749
750
  if (!B.value)
750
- 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}`;
751
+ return !p.value || !p.value.collectionName ? null : E.value ? `${ee.config.apiBaseUrl}/draft-batches/${E.value}/${p.value.collectionName}` : `${ee.config.apiBaseUrl}/${p.value.collectionName}`;
751
752
  }), n = S(() => {
752
753
  var i;
753
754
  if (p.value)
754
755
  return a.mergeWith(
755
756
  a.cloneDeep(De),
756
- x.value,
757
+ P.value,
757
758
  {
758
759
  idProperty: (i = p.value) == null ? void 0 : i.idProperty,
759
760
  restCollectionUrl: M.value || ""
@@ -763,34 +764,34 @@ const De = {
763
764
  return w;
764
765
  }
765
766
  );
766
- }), h = I(0), F = S(
767
+ }), h = I(0), q = S(
767
768
  () => {
768
769
  var i;
769
- return h.value, l.value || p.value && ((i = p.value) == null ? void 0 : i.collectionName) && (U.value ? `draftBatches/${U.value}/${p.value.collectionName}/${b.value}` : `${p.value.collectionName}/${b.value}`) || null;
770
+ return h.value, l.value || p.value && ((i = p.value) == null ? void 0 : i.collectionName) && (E.value ? `draftBatches/${E.value}/${p.value.collectionName}/${b.value}` : `${p.value.collectionName}/${b.value}`) || null;
770
771
  }
771
- ), N = () => {
772
+ ), F = () => {
772
773
  if (T.value) {
773
774
  let i = !1;
774
- return p.value && F.value && (t.value = ie.getStore(F.value), t.value ? i = !1 : n.value && (B.value = !1, t.value = Pe(F.value, n.value)(), i = !0)), i;
775
+ return p.value && q.value && (t.value = ie.getStore(q.value), t.value ? i = !1 : n.value && (B.value = !1, t.value = Ne(q.value, n.value)(), i = !0)), i;
775
776
  } else
776
777
  return !1;
777
778
  }, G = () => {
778
- F.value && l.value == F.value ? (t.value = void 0, N()) : (t.value = void 0, h.value = h.value + 1, N());
779
+ q.value && l.value == q.value ? (t.value = void 0, F()) : (t.value = void 0, h.value = h.value + 1, F());
779
780
  };
780
- C(U, (i, o) => {
781
+ C(E, (i, o) => {
781
782
  a.isEqual(i, o) || G();
782
783
  }), C(T, (i, o) => {
783
- i != o && (i ? N() : t.value = void 0);
784
+ i != o && (i ? F() : t.value = void 0);
784
785
  }), C(p, (i, o) => {
785
- i && !o ? N() : !i && o || a.isEqual(i, o) || G();
786
+ i && !o ? F() : !i && o || a.isEqual(i, o) || G();
786
787
  }), C(n, (i, o) => {
787
788
  a.isEqual(i, o) || G();
788
789
  }), C(z, () => {
789
790
  z.value || (B.value = !1);
790
- }), C(F, () => N()), C(M, (i, o) => {
791
+ }), C(q, () => F()), C(M, (i, o) => {
791
792
  a.isEqual(i, o) || G();
792
793
  });
793
- const j = [], Ee = function(i) {
794
+ const j = [], Ue = function(i) {
794
795
  g.value != "Uninitialized" ? Le(i) : j.push(i);
795
796
  };
796
797
  return C(g, (i, o) => {
@@ -800,10 +801,10 @@ const De = {
800
801
  for (const _ of w)
801
802
  _();
802
803
  }
803
- }), N(), {
804
+ }), F(), {
804
805
  // Configuration
805
- collectionId: F,
806
- draftBatchId: U,
806
+ collectionId: q,
807
+ draftBatchId: E,
807
808
  resourceType: p,
808
809
  // Status
809
810
  enabled: T,
@@ -812,7 +813,7 @@ const De = {
812
813
  listNavigators: S(() => L("listNavigators", !1)),
813
814
  // Resources loaded from the REST API
814
815
  invalidResources: S(() => L("invalidResources", [])),
815
- resources: S(() => g.value != "Uninitialized" ? (E((i) => i.ensureCollectionLoaded()), L("resources", [])) : []),
816
+ resources: S(() => g.value != "Uninitialized" ? (U((i) => i.ensureCollectionLoaded()), L("resources", [])) : []),
816
817
  // Transient data
817
818
  transientData: S(() => L("transientData", [])),
818
819
  // Selection and detail selection
@@ -828,28 +829,28 @@ const De = {
828
829
  setFilterResourceIds: H,
829
830
  setQuery: J,
830
831
  // Methods: Status
831
- ensureStore: N,
832
+ ensureStore: F,
832
833
  // TODO Rename
833
834
  setBatchSaveAttempted: (i) => m((o) => o.setBatchSaveAttempted(i)),
834
835
  // Local collection management
835
836
  clear: () => m((i) => i.clear()),
836
- ensureCollectionLoaded: async () => await E(async (i) => i.ensureCollectionLoaded()),
837
- loadResources: async () => await E(async (i) => await i.loadResources()),
837
+ ensureCollectionLoaded: async () => await U(async (i) => i.ensureCollectionLoaded()),
838
+ loadResources: async () => await U(async (i) => await i.loadResources()),
838
839
  // Methods: Recording changes to the collection
839
840
  addResource: (i) => m((o) => o.addResource(i)),
840
- checkForDeletedResource: async (i) => await E(async (o) => await o.checkForDeletedResource(i)) == !0,
841
+ checkForDeletedResource: async (i) => await U(async (o) => await o.checkForDeletedResource(i)) == !0,
841
842
  recordDeletion: (i) => m((o) => o.recordDeletion(i)),
842
843
  recordInsertion: (i, { insertAtBeginning: o = !1, transientData: w = void 0 } = {}) => m((_) => _.recordInsertion(i, { insertAtBeginning: o, transientData: w })),
843
844
  recordUpdate: (i) => m((o) => o.recordUpdate(i)),
844
- refreshResource: async (i) => await E(
845
+ refreshResource: async (i) => await U(
845
846
  async (o) => await o.refreshResource(i)
846
847
  ),
847
848
  // Methods: Modifying the collection
848
- deleteResource: async (i) => await E(
849
+ deleteResource: async (i) => await U(
849
850
  async (o) => await o.deleteResource(i)
850
851
  ),
851
- saveResource: async (i) => await E(async (o) => await o.saveResource(i)),
852
- saveResources: async (i) => await E(async (o) => await o.saveResources(i)),
852
+ saveResource: async (i) => await U(async (o) => await o.saveResource(i)),
853
+ saveResources: async (i) => await U(async (o) => await o.saveResources(i)),
853
854
  // Methods: Transient data
854
855
  clearTransientData: () => m((i) => i.clearTransientData()),
855
856
  setInvalidResourceIds: (i) => m((o) => o.setInvalidResourceIds(i)),
@@ -871,7 +872,7 @@ const De = {
871
872
  deregisterListNavigator: (i) => m((o) => o.deregisterListNavigator(i)),
872
873
  registerListNavigator: (i) => m((o) => o.registerListNavigator(i)),
873
874
  // Callbacks
874
- onItemsStoreReady: Ee
875
+ onItemsStoreReady: Ue
875
876
  };
876
877
  }, Qe = () => {
877
878
  ie.clearAllStores();
@@ -879,13 +880,13 @@ const De = {
879
880
  function ae(f, s) {
880
881
  return a.get(f, (s == null ? void 0 : s.idProperty) || "_id");
881
882
  }
882
- const Ue = {
883
+ const Ee = {
883
884
  idProperty: "_id"
884
885
  }, Z = {
885
886
  resource: null,
886
887
  status: "NotLoaded"
887
- }, xe = (f, s) => {
888
- s = a.merge({}, Ue, s);
888
+ }, Pe = (f, s) => {
889
+ s = a.merge({}, Ee, s);
889
890
  const R = ye(f, {
890
891
  state: () => ({
891
892
  idProperty: s.idProperty,
@@ -958,7 +959,7 @@ const Ue = {
958
959
  (c, d) => c != null ? `${encodeURIComponent(d)}=${encodeURIComponent(c)}` : null
959
960
  ).filter((c) => c != null).join("&"), u = a.isEmpty(l) ? this.currentResourceUrl : `${this.currentResourceUrl}?${l}`;
960
961
  try {
961
- const c = await P.get(u), d = this.fixedQueryParams;
962
+ const c = await N.get(u), d = this.fixedQueryParams;
962
963
  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");
963
964
  } catch (c) {
964
965
  console.log(`Error while loading resource (URL="${u}")`, c), this.reset(), this.status = "Failed";
@@ -981,9 +982,9 @@ const Ue = {
981
982
  if (this.currentResourceUrl) {
982
983
  let e;
983
984
  try {
984
- e = await P.get(this.currentResourceUrl);
985
+ e = await N.get(this.currentResourceUrl);
985
986
  } catch (r) {
986
- P.isAxiosError(r) && (e = r.response);
987
+ N.isAxiosError(r) && (e = r.response);
987
988
  }
988
989
  return e && e.status == 404 ? (this.recordDeletion(), !0) : !1;
989
990
  } else
@@ -1054,7 +1055,7 @@ const Ue = {
1054
1055
  */
1055
1056
  async deleteResource() {
1056
1057
  if (this.currentResourceUrl)
1057
- (await P.delete(this.currentResourceUrl)).status == 200 && this.recordDeletion();
1058
+ (await N.delete(this.currentResourceUrl)).status == 200 && this.recordDeletion();
1058
1059
  else
1059
1060
  throw "Cannot delete a resource because its URL, or its ID and collection URL, are unknown.";
1060
1061
  },
@@ -1075,7 +1076,7 @@ const Ue = {
1075
1076
  throw "The REST resource store cannot create new resources on the server.";
1076
1077
  if (!this.currentResourceUrl)
1077
1078
  throw "Cannot save a resource because its URL, or its ID and collection URL, are unknown.";
1078
- const l = await P({
1079
+ const l = await N({
1079
1080
  method: t ? "post" : "put",
1080
1081
  url: this.currentResourceUrl,
1081
1082
  data: e
@@ -1097,7 +1098,7 @@ const Ue = {
1097
1098
  c = `${this.currentResourceUrl}/${t}`;
1098
1099
  else
1099
1100
  throw "Cannot make a custom API request for a resource because its URL, or its ID and collection URL, are unknown.";
1100
- const d = await P({
1101
+ const d = await N({
1101
1102
  method: r || "get",
1102
1103
  url: c,
1103
1104
  data: u
@@ -1120,9 +1121,9 @@ const Ue = {
1120
1121
  enabled: $,
1121
1122
  resourceType: e,
1122
1123
  options: r
1123
- } = f, t = I(void 0), l = I(s), u = I(R), c = I($ ?? !0), d = I([te(e)]), y = I(r), U = S(() => u.value), T = I(c.value), b = I(X()), q = S(
1124
+ } = f, t = I(void 0), l = I(s), u = I(R), c = I($ ?? !0), d = I([te(e)]), y = I(r), E = S(() => u.value), T = I(c.value), b = I(X()), x = S(
1124
1125
  () => u.value == null && l.value != null && ne.getStore(l.value) != null
1125
- ), A = I(q.value), z = S(() => m("status", "Uninitialized"));
1126
+ ), A = I(x.value), z = S(() => m("status", "Uninitialized"));
1126
1127
  function B(n) {
1127
1128
  if (t.value)
1128
1129
  return n(t.value);
@@ -1138,34 +1139,34 @@ const Ue = {
1138
1139
  return h;
1139
1140
  throw "Attempted to use a REST resource store that has not been created, with no default value.";
1140
1141
  }
1141
- const E = (n = {}) => {
1142
+ const U = (n = {}) => {
1142
1143
  const {
1143
1144
  resourceClientId: h,
1144
- draftBatchId: F,
1145
- enabled: N,
1145
+ draftBatchId: q,
1146
+ enabled: F,
1146
1147
  resourceType: G,
1147
1148
  options: j
1148
1149
  } = n;
1149
- l.value = h, u.value = F, c.value = N ?? !0, d.value = [te(G)], j != null && (y.value = j), b.value = X(), L(c.value);
1150
+ l.value = h, u.value = q, c.value = F ?? !0, d.value = [te(G)], j != null && (y.value = j), b.value = X(), L(c.value);
1150
1151
  }, L = async (n) => {
1151
- n != T.value && (T.value = n, n && x());
1152
+ n != T.value && (T.value = n, n && P());
1152
1153
  }, D = S(
1153
1154
  () => d.value[0].value || void 0
1154
1155
  ), W = function(n) {
1155
- const h = a.get(n, "referencePathsToExpand"), F = D.value ? a.isFunction(h) ? h(D.value) : h || [] : [];
1156
+ const h = a.get(n, "referencePathsToExpand"), q = D.value ? a.isFunction(h) ? h(D.value) : h || [] : [];
1156
1157
  return {
1157
1158
  ...a.cloneDeep(n || {}),
1158
- referencePathsToExpand: F
1159
+ referencePathsToExpand: q
1159
1160
  };
1160
1161
  }, H = S(() => W(y.value)), J = S(() => {
1161
1162
  if (!D.value)
1162
1163
  return null;
1163
1164
  if (!A.value)
1164
- 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}`;
1165
+ return !D.value || !D.value.collectionName ? null : E.value ? `${ee.config.apiBaseUrl}/draft-batches/${E.value}/${D.value.collectionName}` : `${ee.config.apiBaseUrl}/${D.value.collectionName}`;
1165
1166
  }), K = S(() => {
1166
1167
  if (D.value && J.value)
1167
1168
  return a.mergeWith(
1168
- a.cloneDeep(Ue),
1169
+ a.cloneDeep(Ee),
1169
1170
  H.value,
1170
1171
  {
1171
1172
  idProperty: D.value.idProperty,
@@ -1179,33 +1180,33 @@ const Ue = {
1179
1180
  }), p = I(0), k = S(
1180
1181
  () => {
1181
1182
  var n;
1182
- return p.value, l.value || D.value && ((n = D.value) == null ? void 0 : n.collectionName) && (U.value ? `draftBatches/${U.value}/${D.value.collectionName}/${b.value}` : `${D.value.collectionName}/${b.value}`) || null;
1183
+ return p.value, l.value || D.value && ((n = D.value) == null ? void 0 : n.collectionName) && (E.value ? `draftBatches/${E.value}/${D.value.collectionName}/${b.value}` : `${D.value.collectionName}/${b.value}`) || null;
1183
1184
  }
1184
- ), x = () => {
1185
+ ), P = () => {
1185
1186
  if (T.value) {
1186
1187
  let n = !1;
1187
- return D.value && k.value && (t.value = ne.getStore(k.value), t.value ? n = !1 : K.value && (A.value = !1, t.value = xe(k.value, K.value)(), n = !0)), n;
1188
+ return D.value && k.value && (t.value = ne.getStore(k.value), t.value ? n = !1 : K.value && (A.value = !1, t.value = Pe(k.value, K.value)(), n = !0)), n;
1188
1189
  } else
1189
1190
  return !1;
1190
1191
  }, M = () => {
1191
- k.value && l.value == k.value ? (t.value = void 0, x()) : (t.value = void 0, p.value = p.value + 1, x());
1192
+ k.value && l.value == k.value ? (t.value = void 0, P()) : (t.value = void 0, p.value = p.value + 1, P());
1192
1193
  };
1193
- return C(U, (n, h) => {
1194
+ return C(E, (n, h) => {
1194
1195
  a.isEqual(n, h) || M();
1195
1196
  }), C(T, (n, h) => {
1196
- n != h && (n ? x() : t.value = void 0);
1197
+ n != h && (n ? P() : t.value = void 0);
1197
1198
  }), C(D, (n, h) => {
1198
- n && !h ? x() : !n && h || a.isEqual(n, h) || M();
1199
+ n && !h ? P() : !n && h || a.isEqual(n, h) || M();
1199
1200
  }), C(K, (n, h) => {
1200
1201
  a.isEqual(n, h) || M();
1201
- }), C(q, () => {
1202
- q.value || (A.value = !1);
1203
- }), C(k, () => x()), C(J, (n, h) => {
1202
+ }), C(x, () => {
1203
+ x.value || (A.value = !1);
1204
+ }), C(k, () => P()), C(J, (n, h) => {
1204
1205
  a.isEqual(n, h) || M();
1205
- }), x(), {
1206
+ }), P(), {
1206
1207
  // Configuration
1207
1208
  resourceClientId: k,
1208
- draftBatchId: U,
1209
+ draftBatchId: E,
1209
1210
  enabled: T,
1210
1211
  resourceType: D,
1211
1212
  // Status
@@ -1215,12 +1216,12 @@ const Ue = {
1215
1216
  resourceId: S(() => m("resourceId", null)),
1216
1217
  resourceUrl: S(() => m("resourceUrl", null)),
1217
1218
  // Methods: Configuration
1218
- reconfigureClient: E,
1219
+ reconfigureClient: U,
1219
1220
  setEnabled: L,
1220
1221
  setResourceId: async (n) => await g(async (h) => await h.setResourceId(n)),
1221
1222
  setResourceUrl: async (n) => await g(async (h) => await h.setResourceUrl(n)),
1222
1223
  // Methods: Status
1223
- ensureStore: x,
1224
+ ensureStore: P,
1224
1225
  // Methods: Resource management
1225
1226
  clear: () => B((n) => n.clear()),
1226
1227
  ensureResourceLoaded: async () => await g(async (n) => n.ensureResourceLoaded()),
@@ -1 +1 @@
1
- (function(v,r){typeof exports=="object"&&typeof module<"u"?r(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"],r):(v=typeof globalThis<"u"?globalThis:v||self,r(v["rest-client-vue"]={},v._,v.uuid,v.Vue,v.axios,v.jsog,v.stringify,v.pinia))})(this,function(v,r,I,a,$,ne,J,ae){"use strict";var Pe=Object.defineProperty;var Fe=(v,r,I)=>r in v?Pe(v,r,{enumerable:!0,configurable:!0,writable:!0,value:I}):v[r]=I;var le=(v,r,I)=>(Fe(v,typeof r!="symbol"?r+"":r,I),I),Ne=(v,r,I)=>{if(!r.has(v))throw TypeError("Cannot "+I)};var j=(v,r,I)=>(Ne(v,r,"read from private field"),I?I.call(v):r.get(v)),Ie=(v,r,I)=>{if(r.has(v))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(v):r.set(v,I)};var A;const oe={apiBaseUrl:"",useVueLogger:!1};class we extends Error{constructor(C,q=void 0,e=void 0){super(C);le(this,"context");le(this,"innerError");this.context=q,this.innerError=e}}class ce{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,C){j(this,A)[n]=C}}A=new WeakMap;function g(w,n){return r.get(w,(n==null?void 0:n.idProperty)||"_id")}function De(w,n){var C;return w&&((C=n.filter)!=null&&C.resourceIds)&&!n.order?n.filter.resourceIds.map(q=>w.find(e=>g(e,n)==q)).filter(q=>q!=null):w}const ue={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.orderInBatch"},"desc"]]},K={resources:[],status:"NotLoaded",selection:[],detailSelection:[],invalidResources:[],transientData:{}},te={editingDetailSelection:!1,batchSaveAttempted:!1,editors:[],listNavigators:{}},Ee=(w,n)=>{n=r.merge({},ue,n);const C=ae.defineStore(w,{state:()=>({idProperty:n.idProperty,filter:n.filter,order:n.order||null,referencePathsToExpand:n.referencePathsToExpand||null,...K,...te}),getters:{fixedQueryParams:e=>{var l,d,u,h;const s={};(l=e.filter)!=null&&l.namedFilter&&(s.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 p=t.length==1?t[0]:{and:t};s.q=J(p)}return e.order&&(s.o=J(e.order)),e.referencePathsToExpand&&(s.r=J(e.referencePathsToExpand)),s}},actions:{reset(){for(const e in K)this[e]=K[e];for(const e in te)this[e]=te[e]},resetRetainingTransientData(){if(n.limitTransientDataToLocalCollection)this.reset();else{const e=this.transientData;this.reset(),this.transientData=e}},setEditingDetailSelection(e){this.editingDetailSelection=e},setFilter(e){r.isEqual(e,this.filter)||(this.filter=e,this.status="NotLoaded",this.resources=[],this.selection=[],this.detailSelection=[],this.invalidResources=[],this.editingDetailSelection=!1)},async setQuery(e){var s,t;if(!r.isEqual(e,(s=this.filter)==null?void 0:s.query)&&(e!=null||((t=this.filter)==null?void 0:t.query)!=null)){const l=r.cloneDeep(this.filter)||{};e!==null?l.query=e:r.unset(l,"query");const d=this.status;this.setFilter(l),d!="NotLoaded"&&await this.loadResources()}},async setFilterResourceIds(e){if(!r.isEqual(e,r.get(this.filter,"resourceIds"))){const s=r.cloneDeep(this.filter)||{};e!=null?s.resourceIds=e:r.unset(s,"resourceIds");const t=this.status;this.setFilter(s),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 s=I.v4();this._loadId=s,await this._loadResources(0,s,e)},async _loadResources(e,s,t){var b,F,O,k,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=[];return}const d=this.fixedQueryParams,u=r.cloneDeep(d),h=l?(F=this.filter)!=null&&F.resourceIds&&!this.order?null:t.firstPageSize||((O=n.loading)==null?void 0:O.firstPageSize)||t.pageSize||((k=n.loading)==null?void 0:k.pageSize)||null:t.pageSize||((Q=n.loading)==null?void 0:Q.pageSize)||null,p=h!=null||n.limit!=null?r.min(r.filter([h,n.limit],R=>R!=null)):void 0;p!=null?(u.offset=e,u.limit=p):e!=0&&(u.offset=e);const D=r.map(u,(R,m)=>R!=null?`${encodeURIComponent(m)}=${encodeURIComponent(R)}`:null).filter(R=>R!=null).join("&"),T=r.isEmpty(D)?n.restCollectionUrl:`${n.restCollectionUrl}?${D}`;try{const R=await $.get(T),m=this.fixedQueryParams;if(s!=this._loadId||e!=this._loadOffset||!r.isEqual(d,m))console.log(`Discarding resources fetched by obsolete query from ${n.restCollectionUrl}.`);else{const E=ne.decode(r.get(R,"data.data",[])),L=(l?0:this.resources.length)+E.length,y=p==null||E.length<p||n.limit&&L>=n.limit;console.log(`Loaded ${E.length}${l?"":" more"} resources from ${n.restCollectionUrl}`),l&&(this.resources=[]);const X=[...this.resources,...E.map(Z=>Object.freeze(Z))];this.resources=De(X,this),this.status=y?"Loaded":"LoadingMore",y||this._loadResources(this.resources.length,s,t)}}catch(R){console.log(`Error while loading resources (URL="${T}"):`,R),this.clearRetainingTransientData(),this.status="Failed"}},async checkForDeletedResource(e){let s;try{s=await $.get(`${n.restCollectionUrl}/${e}`)}catch(t){$.isAxiosError(t)&&(s=t.response)}return s&&s.status==404?(this.recordDeletion(e),!0):!1},recordDeletion(e){var s;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=((s=n.detail)==null?void 0:s.autoEdit)||!1)),n.limitTransientDataToLocalCollection&&delete this.transientData[e]}},recordInsertion(e,{insertAtBeginning:s,transientData:t}={}){var l;if(["Loaded","LoadingMore"].includes(this.status)){const d=Object.freeze(e);s?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 s=g(e,this);if(s&&["Loaded","LoadingMore"].includes(this.status)){const t=Object.freeze(e);let l=this.resources.findIndex(d=>g(d,this)==s);l>=0&&(this.resources[l]=t),l=this.selection.findIndex(d=>g(d,this)==s),l>=0&&(this.selection[l]=t),l=this.detailSelection.findIndex(d=>g(d,this)==s),l>=0&&(this.detailSelection[l]=t)}},async refreshResource(e){if(e){const s={};this.referencePathsToExpand&&(s.r=J(this.referencePathsToExpand));const t=r.map(s,(u,h)=>u!=null?`${encodeURIComponent(h)}=${encodeURIComponent(u)}`:null).filter(u=>u!=null).join("&"),l=r.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=[r.omit(r.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 s=g(e,this),t=s==null,l=await $({method:t?"post":"put",url:t?n.restCollectionUrl:`${n.restCollectionUrl}/${s}`,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 s=await $({method:"put",url:n.restCollectionUrl,data:e});if(s.status==200){const t=s.data||[],l=[];for(const[d,u]of t.entries()){const h=g(e[d],this)==null,p=g(u,this),D=p?await this.refreshResource(p):null;h&&this.recordInsertion(D||u),l.push(D||Object.freeze(u))}return l}return[]},clearTransientData(){this.transientData={}},setInvalidResourceIds(e){r.isEqual(e,this.invalidResources.map(s=>g(s,this)))||(this.invalidResources=e.map(s=>this.resources.find(t=>g(t,this)==s)).filter(s=>s!=null))},setTransientDataForResources(e){const{transientData:s,merge:t=!0}=e;t?r.merge(this.transientData,s):r.assign(this.transientData,s)},clearSelection(){this.setSelection([])},deselectResources(e){const s=this.selection.map(t=>g(t,this)).filter(t=>t!=null&&!e.includes(t));this.setSelection(s)},selectResources(e,s){const{addToSelection:t,edit:l}=s||{},d=this.selection.map(h=>g(h,this));let u=e;if(t){const h=r.difference(e,d);h.length>0&&(u=d.concat(h).filter(p=>p!=null))}r.isEqual(d,u)||this.setSelection(u,l)},setSelection(e,s){if(!r.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)r.isEqual(this.selection.map(l=>g(l,this)),this.detailSelection.map(l=>g(l,this)))||(this.detailSelection=r.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));r.isEqual(u,d)||(this.detailSelection=this.detailSelection.filter(h=>u.includes(g(h,this))))}this.detailSelection.length==0?this.editingDetailSelection=!1:this.editingDetailSelection=s!==void 0?s: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 s=this.selection.map(l=>g(l,this)),t=this.detailSelection.map(l=>g(l,this));r.isEqual(s,t)||(this.detailSelection=r.clone(this.selection)),this.detailSelection.length==0?this.editingDetailSelection=!1:this.editingDetailSelection=e!==void 0?e:this.editingDetailSelection||n.detail.autoEdit}},deregisterEditor(e){r.remove(this.editors,s=>s==e)},registerEditor(e){this.editors.includes(e)||this.editors.push(e)},deregisterListNavigator({name:e,listNavigator:s}){(s==null||this.listNavigators[e]==s)&&delete this.listNavigators[e]},registerListNavigator({name:e,listNavigator:s}){this.listNavigators[e]!=s&&(this.listNavigators[e]=s)}}});return(()=>{const e=(s,t)=>{const l=C(s,t);return ee.registerStore(l.$id,l),l};return e.$id=C.$id,e})()},ee=new ce,Ue=(w={})=>{var he,fe,ge,ve;const{collectionId:n,draftBatchId:C,enabled:q,resourceType:e,options:s}=w,t=a.ref(void 0),l=a.ref(n),d=a.ref(C),u=a.ref(q??!0),h=a.ref([a.toRef(e)]),p=a.ref(s),D=a.computed(()=>d.value),T=a.ref(u.value),b=a.ref(I.v4()),F=a.ref((fe=(he=p.value)==null?void 0:he.filter)==null?void 0:fe.resourceIds),O=a.ref((ve=(ge=p.value)==null?void 0:ge.filter)==null?void 0:ve.query),k=a.computed(()=>d.value==null&&l.value!=null&&ee.getStore(l.value)!=null),Q=a.ref(k.value),R=a.computed(()=>L("status","Uninitialized"));function m(i){if(t.value)return i(t.value)}async function E(i){if(t.value)return await i(t.value)}function L(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 me,pe,Se,ye;const{collectionId:c,draftBatchId:U,enabled:z,resourceType:re,options:Re}=i;l.value=c,d.value=U,u.value=z??!0,h.value=[a.toRef(re)],Re!=null&&(p.value=Re,F.value=(pe=(me=p.value)==null?void 0:me.filter)==null?void 0:pe.resourceIds,O.value=(ye=(Se=p.value)==null?void 0:Se.filter)==null?void 0:ye.query),b.value=I.v4(),X(u.value)},X=async i=>{i!=T.value&&(T.value=i,i&&(_(),x()))},Z=async i=>{F.value=i,await E(async c=>await c.setFilterResourceIds(F.value||null))},V=async i=>{if(O.value=i,R.value!="Uninitialized"){const c=i,U=a.computed(()=>r.isFunction(c)?S.value?c(S.value):null:c);await E(z=>z.setQuery(U.value||null))}},_=()=>{p.value=r.merge({},p.value||{},{filter:{resourceIds:F.value,query:O.value}})},S=a.computed(()=>h.value[0].value||void 0),B=function(i){const c=r.get(i,"filter.query"),U=r.get(i,"referencePathsToExpand"),z=r.isFunction(c)?c(S.value):c,re=S.value?r.isFunction(U)?U(S.value):U||[]:[];return{...r.cloneDeep(i||{}),filter:{...r.cloneDeep((i==null?void 0:i.filter)||{}),query:z},referencePathsToExpand:re}},P=a.computed(()=>B(p.value)),M=a.computed(()=>{if(!S.value)return null;if(P.value.restCollectionUrl!==void 0)return P.value.restCollectionUrl;if(!Q.value)return!S.value||!S.value.collectionName?null:D.value?`${G.config.apiBaseUrl}/draft-batches/${D.value}/${S.value.collectionName}`:`${G.config.apiBaseUrl}/${S.value.collectionName}`}),o=a.computed(()=>{var i;if(S.value)return r.mergeWith(r.cloneDeep(ue),P.value,{idProperty:(i=S.value)==null?void 0:i.idProperty,restCollectionUrl:M.value||""},(c,U)=>{if(r.isArray(U)&&U.length==0&&(c==null||r.isArray(c)))return U})}),f=a.ref(0),N=a.computed(()=>{var i;return f.value,l.value||S.value&&((i=S.value)==null?void 0:i.collectionName)&&(D.value?`draftBatches/${D.value}/${S.value.collectionName}/${b.value}`:`${S.value.collectionName}/${b.value}`)||null}),x=()=>{if(T.value){let i=!1;return S.value&&N.value&&(t.value=ee.getStore(N.value),t.value?i=!1:o.value&&(Q.value=!1,t.value=Ee(N.value,o.value)(),i=!0)),i}else return!1},H=()=>{N.value&&l.value==N.value?(t.value=void 0,x()):(t.value=void 0,f.value=f.value+1,x())};a.watch(D,(i,c)=>{r.isEqual(i,c)||H()}),a.watch(T,(i,c)=>{i!=c&&(i?x():t.value=void 0)}),a.watch(S,(i,c)=>{i&&!c?x():!i&&c||r.isEqual(i,c)||H()}),a.watch(o,(i,c)=>{r.isEqual(i,c)||H()}),a.watch(k,()=>{k.value||(Q.value=!1)}),a.watch(N,()=>x()),a.watch(M,(i,c)=>{r.isEqual(i,c)||H()});const W=[],qe=function(i){R.value!="Uninitialized"?a.nextTick(i):W.push(i)};return a.watch(R,(i,c)=>{if(i!="Uninitialized"&&c=="Uninitialized"){const U=r.clone(W);W.splice(0,W.length);for(const z of U)z()}}),x(),{collectionId:N,draftBatchId:D,resourceType:S,enabled:T,status:R,batchSaveAttempted:a.computed(()=>L("batchSaveAttempted",!1)),listNavigators:a.computed(()=>L("listNavigators",!1)),invalidResources:a.computed(()=>L("invalidResources",[])),resources:a.computed(()=>R.value!="Uninitialized"?(E(i=>i.ensureCollectionLoaded()),L("resources",[])):[]),transientData:a.computed(()=>L("transientData",[])),detailSelection:a.computed(()=>L("detailSelection",[])),editingDetailSelection:a.computed(()=>L("editingDetailSelection",!1)),selection:a.computed(()=>L("selection",[])),reconfigureCollection:y,setEditingDetailSelection:i=>m(c=>c.setEditingDetailSelection(i)),setEnabled:X,setFilterResourceIds:Z,setQuery:V,ensureStore:x,setBatchSaveAttempted:i=>m(c=>c.setBatchSaveAttempted(i)),clear:()=>m(i=>i.clear()),ensureCollectionLoaded:async()=>await E(async i=>i.ensureCollectionLoaded()),loadResources:async()=>await E(async i=>await i.loadResources()),addResource:i=>m(c=>c.addResource(i)),checkForDeletedResource:async i=>await E(async c=>await c.checkForDeletedResource(i))==!0,recordDeletion:i=>m(c=>c.recordDeletion(i)),recordInsertion:(i,{insertAtBeginning:c=!1,transientData:U=void 0}={})=>m(z=>z.recordInsertion(i,{insertAtBeginning:c,transientData:U})),recordUpdate:i=>m(c=>c.recordUpdate(i)),refreshResource:async i=>await E(async c=>await c.refreshResource(i)),deleteResource:async i=>await E(async c=>await c.deleteResource(i)),saveResource:async i=>await E(async c=>await c.saveResource(i)),saveResources:async i=>await E(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}},Ce=()=>{ee.clearAllStores()};function ie(w,n){return r.get(w,(n==null?void 0:n.idProperty)||"_id")}const de={idProperty:"_id"},Y={resource:null,status:"NotLoaded"},Te=(w,n)=>{n=r.merge({},de,n);const C=ae.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 s={};return e.referencePathsToExpand&&(s.r=J(e.referencePathsToExpand)),s}},actions:{reset(){for(const e in Y)this[e]=Y[e]},async setResourceId(e){const s=this.currentResourceUrl;this.resourceId=e,!r.isEqual(this.currentResourceUrl,s)&&this.status!="NotLoaded"&&await this.loadResource()},async setResourceUrl(e){const s=this.currentResourceUrl;this.resourceUrl=e,!r.isEqual(this.currentResourceUrl,s)&&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 s=this.fixedQueryParams,t=r.cloneDeep(s),l=r.map(t,(u,h)=>u!=null?`${encodeURIComponent(h)}=${encodeURIComponent(u)}`:null).filter(u=>u!=null).join("&"),d=r.isEmpty(l)?this.currentResourceUrl:`${this.currentResourceUrl}?${l}`;try{const u=await $.get(d),h=this.fixedQueryParams;e!=this._loadId||!r.isEqual(s,h)?console.log(`Discarding resource fetched by obsolete query from ${d}.`):(this.resource=ne.decode(r.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(s){$.isAxiosError(s)&&(e=s.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=ie(e,this)||null,this.status=="Loaded"&&(this.resource=Object.freeze(e))},recordUpdate(e){this.resourceId=ie(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 s=ie(e,this),t=s==null;if(!s)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:s,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:s||"get",url:u,data:d});return h.status>=200&&h.status<300?h.data:null}}});return(()=>{const e=(s,t)=>{const l=C(s,t);return se.registerStore(l.$id,l),l};return e.$id=C.$id,e})()},se=new ce,Le=(w={})=>{const{resourceClientId:n,draftBatchId:C,enabled:q,resourceType:e,options:s}=w,t=a.ref(void 0),l=a.ref(n),d=a.ref(C),u=a.ref(q??!0),h=a.ref([a.toRef(e)]),p=a.ref(s),D=a.computed(()=>d.value),T=a.ref(u.value),b=a.ref(I.v4()),F=a.computed(()=>d.value==null&&l.value!=null&&se.getStore(l.value)!=null),O=a.ref(F.value),k=a.computed(()=>m("status","Uninitialized"));function Q(o){if(t.value)return o(t.value)}async function R(o){if(t.value)return await o(t.value)}function m(o,f){if(t.value)return t.value[o];if(f!==void 0)return f;throw"Attempted to use a REST resource store that has not been created, with no default value."}const E=(o={})=>{const{resourceClientId:f,draftBatchId:N,enabled:x,resourceType:H,options:W}=o;l.value=f,d.value=N,u.value=x??!0,h.value=[a.toRef(H)],W!=null&&(p.value=W),b.value=I.v4(),L(u.value)},L=async o=>{o!=T.value&&(T.value=o,o&&P())},y=a.computed(()=>h.value[0].value||void 0),X=function(o){const f=r.get(o,"referencePathsToExpand"),N=y.value?r.isFunction(f)?f(y.value):f||[]:[];return{...r.cloneDeep(o||{}),referencePathsToExpand:N}},Z=a.computed(()=>X(p.value)),V=a.computed(()=>{if(!y.value)return null;if(!O.value)return!y.value||!y.value.collectionName?null:D.value?`${G.config.apiBaseUrl}/draft-batches/${D.value}/${y.value.collectionName}`:`${G.config.apiBaseUrl}/${y.value.collectionName}`}),_=a.computed(()=>{if(y.value&&V.value)return r.mergeWith(r.cloneDeep(de),Z.value,{idProperty:y.value.idProperty,restCollectionUrl:V.value},(o,f)=>{if(r.isArray(f)&&f.length==0&&(o==null||r.isArray(o)))return f})}),S=a.ref(0),B=a.computed(()=>{var o;return S.value,l.value||y.value&&((o=y.value)==null?void 0:o.collectionName)&&(D.value?`draftBatches/${D.value}/${y.value.collectionName}/${b.value}`:`${y.value.collectionName}/${b.value}`)||null}),P=()=>{if(T.value){let o=!1;return y.value&&B.value&&(t.value=se.getStore(B.value),t.value?o=!1:_.value&&(O.value=!1,t.value=Te(B.value,_.value)(),o=!0)),o}else return!1},M=()=>{B.value&&l.value==B.value?(t.value=void 0,P()):(t.value=void 0,S.value=S.value+1,P())};return a.watch(D,(o,f)=>{r.isEqual(o,f)||M()}),a.watch(T,(o,f)=>{o!=f&&(o?P():t.value=void 0)}),a.watch(y,(o,f)=>{o&&!f?P():!o&&f||r.isEqual(o,f)||M()}),a.watch(_,(o,f)=>{r.isEqual(o,f)||M()}),a.watch(F,()=>{F.value||(O.value=!1)}),a.watch(B,()=>P()),a.watch(V,(o,f)=>{r.isEqual(o,f)||M()}),P(),{resourceClientId:B,draftBatchId:D,enabled:T,resourceType:y,status:k,resource:a.computed(()=>k.value!="Uninitialized"?(R(o=>o.ensureResourceLoaded()),m("resource",[])):[]),resourceId:a.computed(()=>m("resourceId",null)),resourceUrl:a.computed(()=>m("resourceUrl",null)),reconfigureClient:E,setEnabled:L,setResourceId:async o=>await R(async f=>await f.setResourceId(o)),setResourceUrl:async o=>await R(async f=>await f.setResourceUrl(o)),ensureStore:P,clear:()=>Q(o=>o.clear()),ensureResourceLoaded:async()=>await R(async o=>o.ensureResourceLoaded()),loadResource:async()=>await R(async o=>await o.loadResource()),checkForDeletedResource:async()=>await R(async o=>await o.checkForDeletedResource())==!0,recordDeletion:()=>R(o=>o.recordDeletion()),recordInsertion:o=>R(f=>f.recordInsertion(o)),recordUpdate:o=>R(f=>f.recordUpdate(o)),refreshResource:async()=>await R(async o=>await o.refreshResource()),deleteResource:async()=>await R(async o=>await o.deleteResource()),saveResource:async o=>await R(async f=>await f.saveResource(o)),makeCustomApiRequest:async o=>await R(async f=>await f.makeCustomApiRequest(o))}},G={config:{...oe}};function $e(w){G.config=r.merge({},oe,w)}v.ApiClientError=we,v.clearAllRestCollections=Ce,v.initRestClient=$e,v.restClient=G,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,I,n,$,ae,J,ne){"use strict";var Pe=Object.defineProperty;var Ne=(v,s,I)=>s in v?Pe(v,s,{enumerable:!0,configurable:!0,writable:!0,value:I}):v[s]=I;var le=(v,s,I)=>(Ne(v,typeof s!="symbol"?s+"":s,I),I),Fe=(v,s,I)=>{if(!s.has(v))throw TypeError("Cannot "+I)};var j=(v,s,I)=>(Fe(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 oe={apiBaseUrl:"",useVueLogger:!1};class we extends Error{constructor(C,q=void 0,e=void 0){super(C);le(this,"context");le(this,"innerError");this.context=q,this.innerError=e}}class ce{constructor(){Ie(this,A,{})}clearAllStores(){for(const a in j(this,A))j(this,A)[a].clear()}destroyStore(a){j(this,A)[a]&&(j(this,A)[a].$dispose(),delete j(this,A)[a])}getStore(a){return j(this,A)[a]}registerStore(a,C){j(this,A)[a]=C}}A=new WeakMap;function g(w,a){return s.get(w,(a==null?void 0:a.idProperty)||"_id")}function De(w,a){var C;return w&&((C=a.filter)!=null&&C.resourceIds)&&!a.order?a.filter.resourceIds.map(q=>w.find(e=>g(e,a)==q)).filter(q=>q!=null):w}const ue={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.orderInBatch"},"desc"]]},K={resources:[],totalNumResources:null,status:"NotLoaded",selection:[],detailSelection:[],invalidResources:[],transientData:{}},te={editingDetailSelection:!1,batchSaveAttempted:!1,editors:[],listNavigators:{}},Ee=(w,a)=>{a=s.merge({},ue,a);const C=ne.defineStore(w,{state:()=>({idProperty:a.idProperty,filter:a.filter,order:a.order||null,referencePathsToExpand:a.referencePathsToExpand||null,...K,...te}),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 p=t.length==1?t[0]:{and:t};r.q=J(p)}return e.order&&(r.o=J(e.order)),e.referencePathsToExpand&&(r.r=J(e.referencePathsToExpand)),r}},actions:{reset(){for(const e in K)this[e]=K[e];for(const e in te)this[e]=te[e]},resetRetainingTransientData(){if(a.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.totalNumResources=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(a.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,O,k,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.totalNumResources=0;return}const d=this.fixedQueryParams,u=s.cloneDeep(d),h=l?(N=this.filter)!=null&&N.resourceIds&&!this.order?null:t.firstPageSize||((O=a.loading)==null?void 0:O.firstPageSize)||t.pageSize||((k=a.loading)==null?void 0:k.pageSize)||null:t.pageSize||((Q=a.loading)==null?void 0:Q.pageSize)||null,p=h!=null||a.limit!=null?s.min(s.filter([h,a.limit],R=>R!=null)):void 0;p!=null?(u.offset=e,u.limit=p):e!=0&&(u.offset=e);const D=s.map(u,(R,m)=>R!=null?`${encodeURIComponent(m)}=${encodeURIComponent(R)}`:null).filter(R=>R!=null).join("&"),T=s.isEmpty(D)?a.restCollectionUrl:`${a.restCollectionUrl}?${D}`;try{const R=await $.get(T),m=this.fixedQueryParams;if(r!=this._loadId||e!=this._loadOffset||!s.isEqual(d,m))console.log(`Discarding resources fetched by obsolete query from ${a.restCollectionUrl}.`);else{const E=ae.decode(s.get(R,"data.data",[])),L=(l?0:this.resources.length)+E.length,y=p==null||E.length<p||a.limit&&L>=a.limit;console.log(`Loaded ${E.length}${l?"":" more"} resources from ${a.restCollectionUrl}`),l&&(this.resources=[]);const X=[...this.resources,...E.map(Z=>Object.freeze(Z))];this.resources=De(X,this),s.get(R,"data.totalNumEntities")?this.totalNumResources=s.get(R,"data.totalNumEntities"):this.totalNumResources=null,this.status=y?"Loaded":"LoadingMore",y||this._loadResources(this.resources.length,r,t)}}catch(R){console.log(`Error while loading resources (URL="${T}"):`,R),this.clearRetainingTransientData(),this.status="Failed"}},async checkForDeletedResource(e){let r;try{r=await $.get(`${a.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=a.detail)==null?void 0:r.autoEdit)||!1)),a.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=a.detail)!=null&&l.autoFromSingleInsertion&&(this.detailSelection.length==0||this.detailSelection.length==1&&g(this.detailSelection[0],this)==null)&&(this.detailSelection=[d],this.editingDetailSelection=a.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=J(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)?`${a.restCollectionUrl}/${e}`:`${a.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(`${a.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=a.detail.autoEdit)),a.limitTransientDataToLocalCollection&&delete this.transientData[e]}},async saveResource(e){const r=g(e,this),t=r==null,l=await $({method:t?"post":"put",url:t?a.restCollectionUrl:`${a.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:a.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,p=g(u,this),D=p?await this.refreshResource(p):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(p=>p!=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(a.detail.autoFromSingleSelection&&this.selection.length==1)t=!1;else if(a.detail.autoFromMultipleSelection&&a.detail.allowMultiple&&this.selection.length>1)t=!1;else if(a.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),a.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(a.detail.autoFromMultipleSelection&&a.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(a.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||a.detail.autoEdit}},hideDetail(){this.detailSelection.length>0&&(this.detailSelection=[],this.editingDetailSelection=!1)},showSelectionAsDetail(e){if(this.selection.length<=1||a.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||a.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=C(r,t);return ee.registerStore(l.$id,l),l};return e.$id=C.$id,e})()},ee=new ce,Ue=(w={})=>{var he,fe,ge,ve;const{collectionId:a,draftBatchId:C,enabled:q,resourceType:e,options:r}=w,t=n.ref(void 0),l=n.ref(a),d=n.ref(C),u=n.ref(q??!0),h=n.ref([n.toRef(e)]),p=n.ref(r),D=n.computed(()=>d.value),T=n.ref(u.value),b=n.ref(I.v4()),N=n.ref((fe=(he=p.value)==null?void 0:he.filter)==null?void 0:fe.resourceIds),O=n.ref((ve=(ge=p.value)==null?void 0:ge.filter)==null?void 0:ve.query),k=n.computed(()=>d.value==null&&l.value!=null&&ee.getStore(l.value)!=null),Q=n.ref(k.value),R=n.computed(()=>L("status","Uninitialized"));function m(i){if(t.value)return i(t.value)}async function E(i){if(t.value)return await i(t.value)}function L(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 me,pe,Se,ye;const{collectionId:c,draftBatchId:U,enabled:z,resourceType:re,options:Re}=i;l.value=c,d.value=U,u.value=z??!0,h.value=[n.toRef(re)],Re!=null&&(p.value=Re,N.value=(pe=(me=p.value)==null?void 0:me.filter)==null?void 0:pe.resourceIds,O.value=(ye=(Se=p.value)==null?void 0:Se.filter)==null?void 0:ye.query),b.value=I.v4(),X(u.value)},X=async i=>{i!=T.value&&(T.value=i,i&&(_(),x()))},Z=async i=>{N.value=i,await E(async c=>await c.setFilterResourceIds(N.value||null))},V=async i=>{if(O.value=i,R.value!="Uninitialized"){const c=i,U=n.computed(()=>s.isFunction(c)?S.value?c(S.value):null:c);await E(z=>z.setQuery(U.value||null))}},_=()=>{p.value=s.merge({},p.value||{},{filter:{resourceIds:N.value,query:O.value}})},S=n.computed(()=>h.value[0].value||void 0),B=function(i){const c=s.get(i,"filter.query"),U=s.get(i,"referencePathsToExpand"),z=s.isFunction(c)?c(S.value):c,re=S.value?s.isFunction(U)?U(S.value):U||[]:[];return{...s.cloneDeep(i||{}),filter:{...s.cloneDeep((i==null?void 0:i.filter)||{}),query:z},referencePathsToExpand:re}},P=n.computed(()=>B(p.value)),M=n.computed(()=>{if(!S.value)return null;if(P.value.restCollectionUrl!==void 0)return P.value.restCollectionUrl;if(!Q.value)return!S.value||!S.value.collectionName?null:D.value?`${G.config.apiBaseUrl}/draft-batches/${D.value}/${S.value.collectionName}`:`${G.config.apiBaseUrl}/${S.value.collectionName}`}),o=n.computed(()=>{var i;if(S.value)return s.mergeWith(s.cloneDeep(ue),P.value,{idProperty:(i=S.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=n.ref(0),F=n.computed(()=>{var i;return f.value,l.value||S.value&&((i=S.value)==null?void 0:i.collectionName)&&(D.value?`draftBatches/${D.value}/${S.value.collectionName}/${b.value}`:`${S.value.collectionName}/${b.value}`)||null}),x=()=>{if(T.value){let i=!1;return S.value&&F.value&&(t.value=ee.getStore(F.value),t.value?i=!1:o.value&&(Q.value=!1,t.value=Ee(F.value,o.value)(),i=!0)),i}else return!1},H=()=>{F.value&&l.value==F.value?(t.value=void 0,x()):(t.value=void 0,f.value=f.value+1,x())};n.watch(D,(i,c)=>{s.isEqual(i,c)||H()}),n.watch(T,(i,c)=>{i!=c&&(i?x():t.value=void 0)}),n.watch(S,(i,c)=>{i&&!c?x():!i&&c||s.isEqual(i,c)||H()}),n.watch(o,(i,c)=>{s.isEqual(i,c)||H()}),n.watch(k,()=>{k.value||(Q.value=!1)}),n.watch(F,()=>x()),n.watch(M,(i,c)=>{s.isEqual(i,c)||H()});const W=[],qe=function(i){R.value!="Uninitialized"?n.nextTick(i):W.push(i)};return n.watch(R,(i,c)=>{if(i!="Uninitialized"&&c=="Uninitialized"){const U=s.clone(W);W.splice(0,W.length);for(const z of U)z()}}),x(),{collectionId:F,draftBatchId:D,resourceType:S,enabled:T,status:R,batchSaveAttempted:n.computed(()=>L("batchSaveAttempted",!1)),listNavigators:n.computed(()=>L("listNavigators",!1)),invalidResources:n.computed(()=>L("invalidResources",[])),resources:n.computed(()=>R.value!="Uninitialized"?(E(i=>i.ensureCollectionLoaded()),L("resources",[])):[]),transientData:n.computed(()=>L("transientData",[])),detailSelection:n.computed(()=>L("detailSelection",[])),editingDetailSelection:n.computed(()=>L("editingDetailSelection",!1)),selection:n.computed(()=>L("selection",[])),reconfigureCollection:y,setEditingDetailSelection:i=>m(c=>c.setEditingDetailSelection(i)),setEnabled:X,setFilterResourceIds:Z,setQuery:V,ensureStore:x,setBatchSaveAttempted:i=>m(c=>c.setBatchSaveAttempted(i)),clear:()=>m(i=>i.clear()),ensureCollectionLoaded:async()=>await E(async i=>i.ensureCollectionLoaded()),loadResources:async()=>await E(async i=>await i.loadResources()),addResource:i=>m(c=>c.addResource(i)),checkForDeletedResource:async i=>await E(async c=>await c.checkForDeletedResource(i))==!0,recordDeletion:i=>m(c=>c.recordDeletion(i)),recordInsertion:(i,{insertAtBeginning:c=!1,transientData:U=void 0}={})=>m(z=>z.recordInsertion(i,{insertAtBeginning:c,transientData:U})),recordUpdate:i=>m(c=>c.recordUpdate(i)),refreshResource:async i=>await E(async c=>await c.refreshResource(i)),deleteResource:async i=>await E(async c=>await c.deleteResource(i)),saveResource:async i=>await E(async c=>await c.saveResource(i)),saveResources:async i=>await E(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}},Ce=()=>{ee.clearAllStores()};function ie(w,a){return s.get(w,(a==null?void 0:a.idProperty)||"_id")}const de={idProperty:"_id"},Y={resource:null,status:"NotLoaded"},Te=(w,a)=>{a=s.merge({},de,a);const C=ne.defineStore(w,{state:()=>({idProperty:a.idProperty,resourceId:a.resourceId||null,resourceUrl:a.resourceUrl||null,referencePathsToExpand:a.referencePathsToExpand||null,...Y}),getters:{currentResourceUrl:e=>e.resourceUrl||(a.restCollectionUrl&&e.resourceId?`${a.restCollectionUrl}/${e.resourceId}`:null)||a.restCollectionUrl||null,fixedQueryParams:e=>{const r={};return e.referencePathsToExpand&&(r.r=J(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=ie(e,this)||null,this.status=="Loaded"&&(this.resource=Object.freeze(e))},recordUpdate(e){this.resourceId=ie(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=ie(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=C(r,t);return se.registerStore(l.$id,l),l};return e.$id=C.$id,e})()},se=new ce,Le=(w={})=>{const{resourceClientId:a,draftBatchId:C,enabled:q,resourceType:e,options:r}=w,t=n.ref(void 0),l=n.ref(a),d=n.ref(C),u=n.ref(q??!0),h=n.ref([n.toRef(e)]),p=n.ref(r),D=n.computed(()=>d.value),T=n.ref(u.value),b=n.ref(I.v4()),N=n.computed(()=>d.value==null&&l.value!=null&&se.getStore(l.value)!=null),O=n.ref(N.value),k=n.computed(()=>m("status","Uninitialized"));function Q(o){if(t.value)return o(t.value)}async function R(o){if(t.value)return await o(t.value)}function m(o,f){if(t.value)return t.value[o];if(f!==void 0)return f;throw"Attempted to use a REST resource store that has not been created, with no default value."}const E=(o={})=>{const{resourceClientId:f,draftBatchId:F,enabled:x,resourceType:H,options:W}=o;l.value=f,d.value=F,u.value=x??!0,h.value=[n.toRef(H)],W!=null&&(p.value=W),b.value=I.v4(),L(u.value)},L=async o=>{o!=T.value&&(T.value=o,o&&P())},y=n.computed(()=>h.value[0].value||void 0),X=function(o){const f=s.get(o,"referencePathsToExpand"),F=y.value?s.isFunction(f)?f(y.value):f||[]:[];return{...s.cloneDeep(o||{}),referencePathsToExpand:F}},Z=n.computed(()=>X(p.value)),V=n.computed(()=>{if(!y.value)return null;if(!O.value)return!y.value||!y.value.collectionName?null:D.value?`${G.config.apiBaseUrl}/draft-batches/${D.value}/${y.value.collectionName}`:`${G.config.apiBaseUrl}/${y.value.collectionName}`}),_=n.computed(()=>{if(y.value&&V.value)return s.mergeWith(s.cloneDeep(de),Z.value,{idProperty:y.value.idProperty,restCollectionUrl:V.value},(o,f)=>{if(s.isArray(f)&&f.length==0&&(o==null||s.isArray(o)))return f})}),S=n.ref(0),B=n.computed(()=>{var o;return S.value,l.value||y.value&&((o=y.value)==null?void 0:o.collectionName)&&(D.value?`draftBatches/${D.value}/${y.value.collectionName}/${b.value}`:`${y.value.collectionName}/${b.value}`)||null}),P=()=>{if(T.value){let o=!1;return y.value&&B.value&&(t.value=se.getStore(B.value),t.value?o=!1:_.value&&(O.value=!1,t.value=Te(B.value,_.value)(),o=!0)),o}else return!1},M=()=>{B.value&&l.value==B.value?(t.value=void 0,P()):(t.value=void 0,S.value=S.value+1,P())};return n.watch(D,(o,f)=>{s.isEqual(o,f)||M()}),n.watch(T,(o,f)=>{o!=f&&(o?P():t.value=void 0)}),n.watch(y,(o,f)=>{o&&!f?P():!o&&f||s.isEqual(o,f)||M()}),n.watch(_,(o,f)=>{s.isEqual(o,f)||M()}),n.watch(N,()=>{N.value||(O.value=!1)}),n.watch(B,()=>P()),n.watch(V,(o,f)=>{s.isEqual(o,f)||M()}),P(),{resourceClientId:B,draftBatchId:D,enabled:T,resourceType:y,status:k,resource:n.computed(()=>k.value!="Uninitialized"?(R(o=>o.ensureResourceLoaded()),m("resource",[])):[]),resourceId:n.computed(()=>m("resourceId",null)),resourceUrl:n.computed(()=>m("resourceUrl",null)),reconfigureClient:E,setEnabled:L,setResourceId:async o=>await R(async f=>await f.setResourceId(o)),setResourceUrl:async o=>await R(async f=>await f.setResourceUrl(o)),ensureStore:P,clear:()=>Q(o=>o.clear()),ensureResourceLoaded:async()=>await R(async o=>o.ensureResourceLoaded()),loadResource:async()=>await R(async o=>await o.loadResource()),checkForDeletedResource:async()=>await R(async o=>await o.checkForDeletedResource())==!0,recordDeletion:()=>R(o=>o.recordDeletion()),recordInsertion:o=>R(f=>f.recordInsertion(o)),recordUpdate:o=>R(f=>f.recordUpdate(o)),refreshResource:async()=>await R(async o=>await o.refreshResource()),deleteResource:async()=>await R(async o=>await o.deleteResource()),saveResource:async o=>await R(async f=>await f.saveResource(o)),makeCustomApiRequest:async o=>await R(async f=>await f.makeCustomApiRequest(o))}},G={config:{...oe}};function $e(w){G.config=s.merge({},oe,w)}v.ApiClientError=we,v.clearAllRestCollections=Ce,v.initRestClient=$e,v.restClient=G,v.useRestCollection=Ue,v.useRestResource=Le,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
@@ -41,6 +41,7 @@ export interface RestCollectionStoreState {
41
41
  order: QueryOrder | null;
42
42
  referencePathsToExpand: string[] | null;
43
43
  resources: Resource[];
44
+ totalNumResources: number | null;
44
45
  status: RestCollectionStoreStatus;
45
46
  selection: Resource[];
46
47
  detailSelection: Resource[];
@@ -97,6 +98,7 @@ declare const makeStore: (storeId: string, options: RestCollectionStoreOptions)
97
98
  }, import("../queries.js").QueryOrderDirection])[] | null;
98
99
  referencePathsToExpand: string[] | null;
99
100
  resources: Resource[];
101
+ totalNumResources: number | null;
100
102
  status: RestCollectionStoreStatus;
101
103
  selection: Resource[];
102
104
  detailSelection: Resource[];
@@ -446,6 +448,7 @@ export declare const storeRegistry: StoreRegistry<import("pinia").Store<string,
446
448
  }, import("../queries.js").QueryOrderDirection])[] | null;
447
449
  referencePathsToExpand: string[] | null;
448
450
  resources: Resource[];
451
+ totalNumResources: number | null;
449
452
  status: RestCollectionStoreStatus;
450
453
  selection: Resource[];
451
454
  detailSelection: Resource[];
@@ -1 +1 @@
1
- {"version":3,"file":"rest-collection-store.d.ts","sourceRoot":"","sources":["../../../src/stores/rest-collection-store.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,sBAAsB,EAAE,sBAAsB,EAAC,MAAM,uBAAuB,CAAA;AACpF,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,eAAe,CAAA;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAA;AAsBvD,2FAA2F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