rest-client-vue 1.1.1-b11 → 1.1.1-b13

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 = (h, s, g) => (Te(h, s, "read from private field"), g ? g.call(h) : s.get
12
12
  import a from "lodash";
13
13
  import { v4 as H } from "uuid";
14
14
  import { ref as y, toRef as ie, computed as R, watch as T, nextTick as Le } from "vue";
15
- import P from "axios";
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,11 +21,11 @@ const ye = {
21
21
  useVueLogger: !1
22
22
  };
23
23
  class _e extends Error {
24
- constructor(g, U = void 0, e = void 0) {
24
+ constructor(g, I = void 0, e = void 0) {
25
25
  super(g);
26
26
  ae(this, "context");
27
27
  ae(this, "innerError");
28
- this.context = U, this.innerError = e;
28
+ this.context = I, this.innerError = e;
29
29
  }
30
30
  }
31
31
  var B;
@@ -54,13 +54,17 @@ function v(h, s) {
54
54
  function $e(h, s) {
55
55
  const g = a.map(
56
56
  s,
57
- (U, e) => U != null ? `${encodeURIComponent(e)}=${encodeURIComponent(U)}` : null
58
- ).filter((U) => U != null).join("&");
59
- return g.length > 0 ? h.indexOf("?") == h.length - 1 ? `${h}&${g}` : `${h}?${g}` : h;
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;
60
64
  }
61
- function xe(h, s) {
65
+ function Pe(h, s) {
62
66
  var g;
63
- return h && ((g = s.filter) != null && g.resourceIds) && !s.order ? s.filter.resourceIds.map((U) => h.find((e) => v(e, s) == U)).filter((U) => U != null) : h;
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;
64
68
  }
65
69
  const De = {
66
70
  detail: {
@@ -101,7 +105,7 @@ const De = {
101
105
  batchSaveAttempted: !1,
102
106
  editors: [],
103
107
  listNavigators: {}
104
- }, Pe = (h, s) => {
108
+ }, xe = (h, s) => {
105
109
  s = a.merge({}, De, s);
106
110
  const g = pe(h, {
107
111
  state: () => ({
@@ -303,23 +307,23 @@ const De = {
303
307
  this.resources = [], this.remoteCollectionSize = 0;
304
308
  return;
305
309
  }
306
- 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], (x) => x != null)) : void 0;
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;
307
311
  p != null ? (c.offset = e, c.limit = p) : e != 0 && (c.offset = e);
308
312
  const C = $e(s.restCollectionUrl, c);
309
313
  try {
310
- const x = await P.get(C), I = this.fixedQueryParams;
311
- if (r != this._loadId || e != this._loadOffset || !a.isEqual(u, I))
314
+ const P = await x.get(C), D = this.fixedQueryParams;
315
+ if (r != this._loadId || e != this._loadOffset || !a.isEqual(u, D))
312
316
  console.log(`Discarding resources fetched by obsolete query from ${s.restCollectionUrl}.`);
313
317
  else {
314
- const S = me.decode(a.get(x, "data.data", [])), $ = (l ? 0 : this.resources.length) + S.length, E = p == null || S.length < p || s.limit && $ >= 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;
315
319
  console.log(
316
320
  `Loaded ${S.length}${l ? "" : " more"} resources from ${s.restCollectionUrl}`
317
321
  ), l && (this.resources = []);
318
- const D = [...this.resources, ...S.map((W) => Object.freeze(W))];
319
- this.resources = xe(D, this), a.get(x, "data.totalCollectionSize") ? this.remoteCollectionSize = a.get(x, "data.totalCollectionSize") : this.remoteCollectionSize = null, this.status = E ? "Loaded" : "LoadingMore", E || 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);
320
324
  }
321
- } catch (x) {
322
- console.log(`Error while loading resources (URL="${C}"):`, x), this.clearRetainingTransientData(), this.status = "Failed";
325
+ } catch (P) {
326
+ console.log(`Error while loading resources (URL="${C}"):`, P), this.clearRetainingTransientData(), this.status = "Failed";
323
327
  }
324
328
  },
325
329
  // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -337,9 +341,9 @@ const De = {
337
341
  async checkForDeletedResource(e) {
338
342
  let r;
339
343
  try {
340
- r = await P.get(`${s.restCollectionUrl}/${e}`);
344
+ r = await x.get(`${s.restCollectionUrl}/${e}`);
341
345
  } catch (t) {
342
- P.isAxiosError(t) && (r = t.response);
346
+ x.isAxiosError(t) && (r = t.response);
343
347
  }
344
348
  return r && r.status == 404 ? (this.recordDeletion(e), !0) : !1;
345
349
  },
@@ -424,7 +428,7 @@ const De = {
424
428
  const t = a.map(
425
429
  r,
426
430
  (c, d) => c != null ? `${encodeURIComponent(d)}=${encodeURIComponent(c)}` : null
427
- ).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);
428
432
  if (u.status == 200) {
429
433
  const c = u.data;
430
434
  return this.recordUpdate(c), c;
@@ -451,7 +455,7 @@ const De = {
451
455
  * @param resourceId The ID of the resource to delete.
452
456
  */
453
457
  async deleteResource(e) {
454
- 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)) {
455
459
  let t = this.resources.findIndex((l) => v(l, this) == e);
456
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];
457
461
  }
@@ -468,7 +472,7 @@ const De = {
468
472
  * the operation failed.
469
473
  */
470
474
  async saveResource(e) {
471
- const r = v(e, this), t = r == null, l = await P({
475
+ const r = v(e, this), t = r == null, l = await x({
472
476
  method: t ? "post" : "put",
473
477
  url: t ? s.restCollectionUrl : `${s.restCollectionUrl}/${r}`,
474
478
  data: e
@@ -490,7 +494,7 @@ const De = {
490
494
  * @returns An array of refreshed local resources, one for each remote resource whose save operation succeeded.
491
495
  */
492
496
  async saveResources(e) {
493
- const r = await P({
497
+ const r = await x({
494
498
  method: "put",
495
499
  url: s.restCollectionUrl,
496
500
  data: e
@@ -692,12 +696,12 @@ const De = {
692
696
  const {
693
697
  collectionId: s,
694
698
  draftBatchId: g,
695
- enabled: U,
699
+ enabled: I,
696
700
  resourceType: e,
697
701
  options: r
698
- } = h, t = y(void 0), l = y(s), u = y(g), c = y(U ?? !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(
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(
699
703
  () => u.value == null && l.value != null && se.getStore(l.value) != null
700
- ), x = y(O.value), I = R(() => E("status", "Uninitialized"));
704
+ ), P = y(O.value), D = R(() => E("status", "Uninitialized"));
701
705
  function S(i) {
702
706
  if (t.value)
703
707
  return i(t.value);
@@ -713,7 +717,7 @@ const De = {
713
717
  return o;
714
718
  throw "Attempted to use a REST collection store that has not been created, with no default value.";
715
719
  }
716
- const D = (i = {}) => {
720
+ const U = (i = {}) => {
717
721
  var te, ve, ge, Re;
718
722
  const {
719
723
  collectionId: o,
@@ -728,7 +732,7 @@ const De = {
728
732
  }, re = async (i) => {
729
733
  N.value = i, await $(async (o) => await o.setFilterResourceIds(N.value || null));
730
734
  }, J = async (i) => {
731
- if (k.value = i, I.value != "Uninitialized") {
735
+ if (k.value = i, D.value != "Uninitialized") {
732
736
  const o = i, w = R(() => a.isFunction(o) ? m.value ? o(m.value) : null : o);
733
737
  await $((F) => F.setQuery(w.value || null));
734
738
  }
@@ -752,7 +756,7 @@ const De = {
752
756
  }, q = R(() => _(p.value)), M = R(() => {
753
757
  if (q.value.restCollectionUrl !== void 0)
754
758
  return q.value.restCollectionUrl;
755
- if (!x.value)
759
+ if (!P.value)
756
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}`;
757
761
  }), n = R(() => {
758
762
  var i;
@@ -777,7 +781,7 @@ const De = {
777
781
  ), z = () => {
778
782
  if (L.value) {
779
783
  let i = !1;
780
- return m.value && b.value && (t.value = se.getStore(b.value), t.value ? i = !1 : n.value && (x.value = !1, t.value = Pe(b.value, n.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;
781
785
  } else
782
786
  return !1;
783
787
  }, G = () => {
@@ -792,14 +796,14 @@ const De = {
792
796
  }), T(n, (i, o) => {
793
797
  a.isEqual(i, o) || G();
794
798
  }), T(O, () => {
795
- O.value || (x.value = !1);
799
+ O.value || (P.value = !1);
796
800
  }), T(b, () => z()), T(M, (i, o) => {
797
801
  a.isEqual(i, o) || G();
798
802
  });
799
803
  const j = [], Ce = function(i) {
800
- I.value != "Uninitialized" ? Le(i) : j.push(i);
804
+ D.value != "Uninitialized" ? Le(i) : j.push(i);
801
805
  };
802
- return T(I, (i, o) => {
806
+ return T(D, (i, o) => {
803
807
  if (i != "Uninitialized" && o == "Uninitialized") {
804
808
  const w = a.clone(j);
805
809
  j.splice(0, j.length);
@@ -814,12 +818,12 @@ const De = {
814
818
  restCollectionUrl: R(() => E("restCollectionUrl", null)),
815
819
  // Status
816
820
  enabled: L,
817
- status: I,
821
+ status: D,
818
822
  batchSaveAttempted: R(() => E("batchSaveAttempted", !1)),
819
823
  listNavigators: R(() => E("listNavigators", !1)),
820
824
  // Resources loaded from the REST API
821
825
  invalidResources: R(() => E("invalidResources", [])),
822
- resources: R(() => I.value != "Uninitialized" ? ($((i) => i.ensureCollectionLoaded()), E("resources", [])) : []),
826
+ resources: R(() => D.value != "Uninitialized" ? ($((i) => i.ensureCollectionLoaded()), E("resources", [])) : []),
823
827
  remoteCollectionSize: R(() => E("remoteCollectionSize", null)),
824
828
  // Transient data
825
829
  transientData: R(() => E("transientData", [])),
@@ -828,7 +832,7 @@ const De = {
828
832
  editingDetailSelection: R(() => E("editingDetailSelection", !1)),
829
833
  selection: R(() => E("selection", [])),
830
834
  // Methods: Configuration
831
- reconfigureCollection: D,
835
+ reconfigureCollection: U,
832
836
  setEditingDetailSelection: (i) => S(
833
837
  (o) => o.setEditingDetailSelection(i)
834
838
  ),
@@ -966,7 +970,7 @@ const Ue = {
966
970
  (c, d) => c != null ? `${encodeURIComponent(d)}=${encodeURIComponent(c)}` : null
967
971
  ).filter((c) => c != null).join("&"), u = a.isEmpty(l) ? this.currentResourceUrl : `${this.currentResourceUrl}?${l}`;
968
972
  try {
969
- const c = await P.get(u), d = this.fixedQueryParams;
973
+ const c = await x.get(u), d = this.fixedQueryParams;
970
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");
971
975
  } catch (c) {
972
976
  console.log(`Error while loading resource (URL="${u}")`, c), this.reset(), this.status = "Failed";
@@ -989,9 +993,9 @@ const Ue = {
989
993
  if (this.currentResourceUrl) {
990
994
  let e;
991
995
  try {
992
- e = await P.get(this.currentResourceUrl);
996
+ e = await x.get(this.currentResourceUrl);
993
997
  } catch (r) {
994
- P.isAxiosError(r) && (e = r.response);
998
+ x.isAxiosError(r) && (e = r.response);
995
999
  }
996
1000
  return e && e.status == 404 ? (this.recordDeletion(), !0) : !1;
997
1001
  } else
@@ -1062,7 +1066,7 @@ const Ue = {
1062
1066
  */
1063
1067
  async deleteResource() {
1064
1068
  if (this.currentResourceUrl)
1065
- (await P.delete(this.currentResourceUrl)).status == 200 && this.recordDeletion();
1069
+ (await x.delete(this.currentResourceUrl)).status == 200 && this.recordDeletion();
1066
1070
  else
1067
1071
  throw "Cannot delete a resource because its URL, or its ID and collection URL, are unknown.";
1068
1072
  },
@@ -1083,7 +1087,7 @@ const Ue = {
1083
1087
  throw "The REST resource store cannot create new resources on the server.";
1084
1088
  if (!this.currentResourceUrl)
1085
1089
  throw "Cannot save a resource because its URL, or its ID and collection URL, are unknown.";
1086
- const l = await P({
1090
+ const l = await x({
1087
1091
  method: t ? "post" : "put",
1088
1092
  url: this.currentResourceUrl,
1089
1093
  data: e
@@ -1105,7 +1109,7 @@ const Ue = {
1105
1109
  c = `${this.currentResourceUrl}/${t}`;
1106
1110
  else
1107
1111
  throw "Cannot make a custom API request for a resource because its URL, or its ID and collection URL, are unknown.";
1108
- const d = await P({
1112
+ const d = await x({
1109
1113
  method: r || "get",
1110
1114
  url: c,
1111
1115
  data: u
@@ -1125,17 +1129,17 @@ const Ue = {
1125
1129
  const {
1126
1130
  resourceClientId: s,
1127
1131
  draftBatchId: g,
1128
- enabled: U,
1132
+ enabled: I,
1129
1133
  resourceType: e,
1130
1134
  options: r
1131
- } = h, t = y(void 0), l = y(s), u = y(g), c = y(U ?? !0), d = y([ie(e)]), p = y(r), C = R(() => u.value), L = y(c.value), A = y(H()), N = 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(
1132
1136
  () => u.value == null && l.value != null && ce.getStore(l.value) != null
1133
1137
  ), k = y(N.value), O = R(() => S("status", "Uninitialized"));
1134
- function x(n) {
1138
+ function P(n) {
1135
1139
  if (t.value)
1136
1140
  return n(t.value);
1137
1141
  }
1138
- async function I(n) {
1142
+ async function D(n) {
1139
1143
  if (t.value)
1140
1144
  return await n(t.value);
1141
1145
  }
@@ -1157,26 +1161,26 @@ const Ue = {
1157
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);
1158
1162
  }, E = async (n) => {
1159
1163
  n != L.value && (L.value = n, n && q());
1160
- }, D = R(
1164
+ }, U = R(
1161
1165
  () => d.value[0].value || void 0
1162
1166
  ), W = function(n) {
1163
- const f = a.get(n, "referencePathsToExpand"), b = D.value ? a.isFunction(f) ? f(D.value) : f || [] : [];
1167
+ const f = a.get(n, "referencePathsToExpand"), b = U.value ? a.isFunction(f) ? f(U.value) : f || [] : [];
1164
1168
  return {
1165
1169
  ...a.cloneDeep(n || {}),
1166
1170
  referencePathsToExpand: b
1167
1171
  };
1168
1172
  }, re = R(() => W(p.value)), J = R(() => {
1169
- if (!D.value)
1173
+ if (!U.value)
1170
1174
  return null;
1171
1175
  if (!k.value)
1172
- return !D.value || !D.value.collectionName ? null : C.value ? `${V.config.apiBaseUrl}/draft-batches/${C.value}/${D.value.collectionName}` : `${V.config.apiBaseUrl}/${D.value.collectionName}`;
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}`;
1173
1177
  }), K = R(() => {
1174
- if (D.value && J.value)
1178
+ if (U.value && J.value)
1175
1179
  return a.mergeWith(
1176
1180
  a.cloneDeep(Ue),
1177
1181
  re.value,
1178
1182
  {
1179
- idProperty: D.value.idProperty,
1183
+ idProperty: U.value.idProperty,
1180
1184
  restCollectionUrl: J.value
1181
1185
  },
1182
1186
  (n, f) => {
@@ -1187,12 +1191,12 @@ const Ue = {
1187
1191
  }), m = y(0), _ = R(
1188
1192
  () => {
1189
1193
  var n;
1190
- return m.value, l.value || D.value && ((n = D.value) == null ? void 0 : n.collectionName) && (C.value ? `draftBatches/${C.value}/${D.value.collectionName}/${A.value}` : `${D.value.collectionName}/${A.value}`) || null;
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;
1191
1195
  }
1192
1196
  ), q = () => {
1193
1197
  if (L.value) {
1194
1198
  let n = !1;
1195
- return D.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;
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;
1196
1200
  } else
1197
1201
  return !1;
1198
1202
  }, M = () => {
@@ -1202,7 +1206,7 @@ const Ue = {
1202
1206
  a.isEqual(n, f) || M();
1203
1207
  }), T(L, (n, f) => {
1204
1208
  n != f && (n ? q() : t.value = void 0);
1205
- }), T(D, (n, f) => {
1209
+ }), T(U, (n, f) => {
1206
1210
  n && !f ? q() : !n && f || a.isEqual(n, f) || M();
1207
1211
  }), T(K, (n, f) => {
1208
1212
  a.isEqual(n, f) || M();
@@ -1215,35 +1219,35 @@ const Ue = {
1215
1219
  resourceClientId: _,
1216
1220
  draftBatchId: C,
1217
1221
  enabled: L,
1218
- resourceType: D,
1222
+ resourceType: U,
1219
1223
  // Status
1220
1224
  status: O,
1221
1225
  // Resources loaded from the REST API
1222
- resource: R(() => O.value != "Uninitialized" ? (I((n) => n.ensureResourceLoaded()), S("resource", [])) : []),
1226
+ resource: R(() => O.value != "Uninitialized" ? (D((n) => n.ensureResourceLoaded()), S("resource", [])) : []),
1223
1227
  resourceId: R(() => S("resourceId", null)),
1224
1228
  resourceUrl: R(() => S("resourceUrl", null)),
1225
1229
  // Methods: Configuration
1226
1230
  reconfigureClient: $,
1227
1231
  setEnabled: E,
1228
- setResourceId: async (n) => await I(async (f) => await f.setResourceId(n)),
1229
- setResourceUrl: async (n) => await I(async (f) => await f.setResourceUrl(n)),
1232
+ setResourceId: async (n) => await D(async (f) => await f.setResourceId(n)),
1233
+ setResourceUrl: async (n) => await D(async (f) => await f.setResourceUrl(n)),
1230
1234
  // Methods: Status
1231
1235
  ensureStore: q,
1232
1236
  // Methods: Resource management
1233
- clear: () => x((n) => n.clear()),
1234
- ensureResourceLoaded: async () => await I(async (n) => n.ensureResourceLoaded()),
1235
- loadResource: async () => await I(async (n) => await n.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()),
1236
1240
  // Methods: Recording changes to the resource
1237
- checkForDeletedResource: async () => await I(async (n) => await n.checkForDeletedResource()) == !0,
1238
- recordDeletion: () => I((n) => n.recordDeletion()),
1239
- recordInsertion: (n) => I((f) => f.recordInsertion(n)),
1240
- recordUpdate: (n) => I((f) => f.recordUpdate(n)),
1241
- refreshResource: async () => await I(async (n) => await n.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()),
1242
1246
  // Methods: Modifying the resource
1243
- deleteResource: async () => await I(async (n) => await n.deleteResource()),
1244
- saveResource: async (n) => await I(async (f) => await f.saveResource(n)),
1247
+ deleteResource: async () => await D(async (n) => await n.deleteResource()),
1248
+ saveResource: async (n) => await D(async (f) => await f.saveResource(n)),
1245
1249
  // Methods: Custom API endpoints
1246
- makeCustomApiRequest: async (n) => await I(
1250
+ makeCustomApiRequest: async (n) => await D(
1247
1251
  async (f) => await f.makeCustomApiRequest(n)
1248
1252
  )
1249
1253
  };
@@ -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,D,o,q,ae,G,ce){"use strict";var Fe=Object.defineProperty;var Ne=(v,s,D)=>s in v?Fe(v,s,{enumerable:!0,configurable:!0,writable:!0,value:D}):v[s]=D;var oe=(v,s,D)=>(Ne(v,typeof s!="symbol"?s+"":s,D),D),xe=(v,s,D)=>{if(!s.has(v))throw TypeError("Cannot "+D)};var j=(v,s,D)=>(xe(v,s,"read from private field"),D?D.call(v):s.get(v)),Ie=(v,s,D)=>{if(s.has(v))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(v):s.set(v,D)};var b;const ue={apiBaseUrl:"",useVueLogger:!1};class we extends Error{constructor(I,U=void 0,e=void 0){super(I);oe(this,"context");oe(this,"innerError");this.context=U,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,I){j(this,b)[n]=I}}b=new WeakMap;function g(m,n){return s.get(m,(n==null?void 0:n.idProperty)||"_id")}function De(m,n){const I=s.map(n,(U,e)=>U!=null?`${encodeURIComponent(e)}=${encodeURIComponent(U)}`:null).filter(U=>U!=null).join("&");return I.length>0?m.indexOf("?")==m.length-1?`${m}&${I}`:`${m}?${I}`:m}function Ue(m,n){var I;return m&&((I=n.filter)!=null&&I.resourceIds)&&!n.order?n.filter.resourceIds.map(U=>m.find(e=>g(e,n)==U)).filter(U=>U!=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 I=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=D.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),y=this.fixedQueryParams;if(r!=this._loadId||e!=this._loadOffset||!s.isEqual(d,y))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 w=[...this.resources,...p.map(H=>Object.freeze(H))];this.resources=Ue(w,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=I(r,t);return _.registerStore(l.$id,l),l};return e.$id=I.$id,e})()},_=new de,Ee=(m={})=>{var ge,ve,pe,me;const{collectionId:n,draftBatchId:I,enabled:U,resourceType:e,options:r}=m,t=o.ref(void 0),l=o.ref(n),d=o.ref(I),u=o.ref(U??!0),h=o.ref([o.toRef(e)]),S=o.ref(r),C=o.computed(()=>d.value),L=o.ref(u.value),k=o.ref(D.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),y=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 w=(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=D.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,y.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){y.value!="Uninitialized"?o.nextTick(i):W.push(i)};return o.watch(y,(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:y,batchSaveAttempted:o.computed(()=>E("batchSaveAttempted",!1)),listNavigators:o.computed(()=>E("listNavigators",!1)),invalidResources:o.computed(()=>E("invalidResources",[])),resources:o.computed(()=>y.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:w,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 I=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=D.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=I(r,t);return re.registerStore(l.$id,l),l};return e.$id=I.$id,e})()},re=new de,$e=(m={})=>{const{resourceClientId:n,draftBatchId:I,enabled:U,resourceType:e,options:r}=m,t=o.ref(void 0),l=o.ref(n),d=o.ref(I),u=o.ref(U??!0),h=o.ref([o.toRef(e)]),S=o.ref(r),C=o.computed(()=>d.value),L=o.ref(u.value),k=o.ref(D.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 y(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=D.v4(),E(u.value)},E=async a=>{a!=L.value&&(L.value=a,a&&F())},w=o.computed(()=>h.value[0].value||void 0),H=function(a){const f=s.get(a,"referencePathsToExpand"),z=w.value?s.isFunction(f)?f(w.value):f||[]:[];return{...s.cloneDeep(a||{}),referencePathsToExpand:z}},le=o.computed(()=>H(S.value)),Z=o.computed(()=>{if(!w.value)return null;if(!O.value)return!w.value||!w.value.collectionName?null:C.value?`${X.config.apiBaseUrl}/draft-batches/${C.value}/${w.value.collectionName}`:`${X.config.apiBaseUrl}/${w.value.collectionName}`}),V=o.computed(()=>{if(w.value&&Z.value)return s.mergeWith(s.cloneDeep(fe),le.value,{idProperty:w.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||w.value&&((a=w.value)==null?void 0:a.collectionName)&&(C.value?`draftBatches/${C.value}/${w.value.collectionName}/${k.value}`:`${w.value.collectionName}/${k.value}`)||null}),F=()=>{if(L.value){let a=!1;return w.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(w,(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:w,status:B,resource:o.computed(()=>B.value!="Uninitialized"?(y(a=>a.ensureResourceLoaded()),p("resource",[])):[]),resourceId:o.computed(()=>p("resourceId",null)),resourceUrl:o.computed(()=>p("resourceUrl",null)),reconfigureClient:$,setEnabled:E,setResourceId:async a=>await y(async f=>await f.setResourceId(a)),setResourceUrl:async a=>await y(async f=>await f.setResourceUrl(a)),ensureStore:F,clear:()=>P(a=>a.clear()),ensureResourceLoaded:async()=>await y(async a=>a.ensureResourceLoaded()),loadResource:async()=>await y(async a=>await a.loadResource()),checkForDeletedResource:async()=>await y(async a=>await a.checkForDeletedResource())==!0,recordDeletion:()=>y(a=>a.recordDeletion()),recordInsertion:a=>y(f=>f.recordInsertion(a)),recordUpdate:a=>y(f=>f.recordUpdate(a)),refreshResource:async()=>await y(async a=>await a.refreshResource()),deleteResource:async()=>await y(async a=>await a.deleteResource()),saveResource:async a=>await y(async f=>await f.saveResource(a)),makeCustomApiRequest:async a=>await y(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
+ (function(v,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("lodash"),require("uuid"),require("vue"),require("axios"),require("jsog"),require("json-stringify-deterministic"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","lodash","uuid","vue","axios","jsog","json-stringify-deterministic","pinia"],s):(v=typeof globalThis<"u"?globalThis:v||self,s(v["rest-client-vue"]={},v._,v.uuid,v.Vue,v.axios,v.jsog,v.stringify,v.pinia))})(this,function(v,s,U,o,q,ae,G,ce){"use strict";var Fe=Object.defineProperty;var Ne=(v,s,U)=>s in v?Fe(v,s,{enumerable:!0,configurable:!0,writable:!0,value:U}):v[s]=U;var oe=(v,s,U)=>(Ne(v,typeof s!="symbol"?s+"":s,U),U),xe=(v,s,U)=>{if(!s.has(v))throw TypeError("Cannot "+U)};var j=(v,s,U)=>(xe(v,s,"read from private field"),U?U.call(v):s.get(v)),Ie=(v,s,U)=>{if(s.has(v))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(v):s.set(v,U)};var b;const ue={apiBaseUrl:"",useVueLogger:!1};class we extends Error{constructor(y,I=void 0,e=void 0){super(y);oe(this,"context");oe(this,"innerError");this.context=I,this.innerError=e}}class de{constructor(){Ie(this,b,{})}clearAllStores(){for(const n in j(this,b))j(this,b)[n].clear()}destroyStore(n){j(this,b)[n]&&(j(this,b)[n].$dispose(),delete j(this,b)[n])}getStore(n){return j(this,b)[n]}registerStore(n,y){j(this,b)[n]=y}}b=new WeakMap;function g(m,n){return s.get(m,(n==null?void 0:n.idProperty)||"_id")}function De(m,n){const y=s.map(n,(I,e)=>I!=null?`${encodeURIComponent(e)}=${encodeURIComponent(I)}`:null).filter(I=>I!=null).join("&");if(y.length>0){const I=m.indexOf("?");return I==m.length-1?`${m}${y}`:I>=0?`${m}&${y}`:`${m}?${y}`}else return m}function Ue(m,n){var y;return m&&((y=n.filter)!=null&&y.resourceIds)&&!n.order?n.filter.resourceIds.map(I=>m.find(e=>g(e,n)==I)).filter(I=>I!=null):m}const he={detail:{allowMultiple:!0,autoEdit:!1,autoFromMultipleSelection:!0,autoFromSingleInsertion:!0,autoFromSingleSelection:!0,constrainToSelection:!0},filter:{namedFilter:null,query:null,resourceIds:null},idProperty:"_id",limit:5e3,limitTransientDataToLocalCollection:!0,loading:{firstPageSize:500,pageSize:5e3},order:[[{path:"history.creation.timestamp"},"desc"],[{path:"history.creation.indexInBatch"},"desc"]]},K={resources:[],remoteCollectionSize:null,status:"NotLoaded",selection:[],detailSelection:[],invalidResources:[],transientData:{}},ie={editingDetailSelection:!1,batchSaveAttempted:!1,editors:[],listNavigators:{}},Ce=(m,n)=>{n=s.merge({},he,n);const y=ce.defineStore(m,{state:()=>({idProperty:n.idProperty,filter:n.filter,order:n.order||null,propertyBlacklist:n.propertyBlacklist||null,referencePathsToExpand:n.referencePathsToExpand||null,restCollectionUrl:n.restCollectionUrl,...K,...ie}),getters:{fixedQueryParams:e=>{var l,d,u,h;const r={};(l=e.filter)!=null&&l.namedFilter&&(r.namedFilter=e.filter.namedFilter);const t=[];if((d=e.filter)!=null&&d.resourceIds&&t.push({l:{path:e.idProperty},r:{constant:e.filter.resourceIds},operator:"in"}),(u=e.filter)!=null&&u.query&&t.push((h=e.filter)==null?void 0:h.query),t.length>0){const S=t.length==1?t[0]:{and:t};r.q=G(S)}return e.order&&(r.o=G(e.order)),e.propertyBlacklist&&(r.ex=G(e.propertyBlacklist)),e.referencePathsToExpand&&(r.r=G(e.referencePathsToExpand)),r}},actions:{reset(){for(const e in K)this[e]=K[e];for(const e in ie)this[e]=ie[e]},resetRetainingTransientData(){if(n.limitTransientDataToLocalCollection)this.reset();else{const e=this.transientData;this.reset(),this.transientData=e}},setEditingDetailSelection(e){this.editingDetailSelection=e},setFilter(e){s.isEqual(e,this.filter)||(this.filter=e,this.status="NotLoaded",this.resources=[],this.remoteCollectionSize=null,this.selection=[],this.detailSelection=[],this.invalidResources=[],this.editingDetailSelection=!1)},async setQuery(e){var r,t;if(!s.isEqual(e,(r=this.filter)==null?void 0:r.query)&&(e!=null||((t=this.filter)==null?void 0:t.query)!=null)){const l=s.cloneDeep(this.filter)||{};e!==null?l.query=e:s.unset(l,"query");const d=this.status;this.setFilter(l),d!="NotLoaded"&&await this.loadResources()}},async setFilterResourceIds(e){if(!s.isEqual(e,s.get(this.filter,"resourceIds"))){const r=s.cloneDeep(this.filter)||{};e!=null?r.resourceIds=e:s.unset(r,"resourceIds");const t=this.status;this.setFilter(r),t!="NotLoaded"&&await this.loadResources()}},setBatchSaveAttempted(e){e!=this.batchSaveAttempted&&(this.batchSaveAttempted=e)},clear(){for(const e in K)this[e]=K[e]},clearRetainingTransientData(){if(n.limitTransientDataToLocalCollection)this.reset();else{const e=this.transientData;this.reset(),this.transientData=e}},async ensureCollectionLoaded(){["Loaded","Loading","LoadingMore","Failed"].includes(this.status)||await this.loadResources()},async loadResources(e={}){this.resetRetainingTransientData();const r=U.v4();this._loadId=r,await this._loadResources(0,r,e)},async _loadResources(e,r,t){var L,k,x,O,B;const l=e==0;if(this.status=l?"Loading":"LoadingMore",this._loadOffset=e,((L=this.filter)==null?void 0:L.query)===!1){this.resources=[],this.remoteCollectionSize=0;return}const d=this.fixedQueryParams,u=s.cloneDeep(d),h=l?(k=this.filter)!=null&&k.resourceIds&&!this.order?null:t.firstPageSize||((x=n.loading)==null?void 0:x.firstPageSize)||t.pageSize||((O=n.loading)==null?void 0:O.pageSize)||null:t.pageSize||((B=n.loading)==null?void 0:B.pageSize)||null,S=h!=null||n.limit!=null?s.min(s.filter([h,n.limit],P=>P!=null)):void 0;S!=null?(u.offset=e,u.limit=S):e!=0&&(u.offset=e);const C=De(n.restCollectionUrl,u);try{const P=await q.get(C),w=this.fixedQueryParams;if(r!=this._loadId||e!=this._loadOffset||!s.isEqual(d,w))console.log(`Discarding resources fetched by obsolete query from ${n.restCollectionUrl}.`);else{const p=ae.decode(s.get(P,"data.data",[])),$=(l?0:this.resources.length)+p.length,E=S==null||p.length<S||n.limit&&$>=n.limit;console.log(`Loaded ${p.length}${l?"":" more"} resources from ${n.restCollectionUrl}`),l&&(this.resources=[]);const D=[...this.resources,...p.map(H=>Object.freeze(H))];this.resources=Ue(D,this),s.get(P,"data.totalCollectionSize")?this.remoteCollectionSize=s.get(P,"data.totalCollectionSize"):this.remoteCollectionSize=null,this.status=E?"Loaded":"LoadingMore",E||this._loadResources(this.resources.length,r,t)}}catch(P){console.log(`Error while loading resources (URL="${C}"):`,P),this.clearRetainingTransientData(),this.status="Failed"}},async checkForDeletedResource(e){let r;try{r=await q.get(`${n.restCollectionUrl}/${e}`)}catch(t){q.isAxiosError(t)&&(r=t.response)}return r&&r.status==404?(this.recordDeletion(e),!0):!1},recordDeletion(e){var r;if(["Loaded","LoadingMore"].includes(this.status)){let t=this.resources.findIndex(l=>g(l,this)==e);t>=0&&this.resources.splice(t,1),t=this.selection.findIndex(l=>g(l,this)==e),t>=0&&this.selection.splice(t,1),t=this.detailSelection.findIndex(l=>g(l,this)==e),t>=0&&(this.detailSelection.splice(t,1),this.detailSelection.length==0&&(this.editingDetailSelection=((r=n.detail)==null?void 0:r.autoEdit)||!1)),n.limitTransientDataToLocalCollection&&delete this.transientData[e]}},recordInsertion(e,{insertAtBeginning:r,transientData:t}={}){var l;if(["Loaded","LoadingMore"].includes(this.status)){const d=Object.freeze(e);r?this.resources.unshift(d):this.resources.push(d),(l=n.detail)!=null&&l.autoFromSingleInsertion&&(this.detailSelection.length==0||this.detailSelection.length==1&&g(this.detailSelection[0],this)==null)&&(this.detailSelection=[d],this.editingDetailSelection=n.detail.autoEdit);const u=g(e,this);u&&(t===void 0?delete this.transientData[u]:this.transientData[u]=t)}},recordUpdate(e){const r=g(e,this);if(r&&["Loaded","LoadingMore"].includes(this.status)){const t=Object.freeze(e);let l=this.resources.findIndex(d=>g(d,this)==r);l>=0&&(this.resources[l]=t),l=this.selection.findIndex(d=>g(d,this)==r),l>=0&&(this.selection[l]=t),l=this.detailSelection.findIndex(d=>g(d,this)==r),l>=0&&(this.detailSelection[l]=t)}},async refreshResource(e){if(e){const r={};this.referencePathsToExpand&&(r.r=G(this.referencePathsToExpand));const t=s.map(r,(u,h)=>u!=null?`${encodeURIComponent(h)}=${encodeURIComponent(u)}`:null).filter(u=>u!=null).join("&"),l=s.isEmpty(t)?`${n.restCollectionUrl}/${e}`:`${n.restCollectionUrl}/${e}?${t}`,d=await q.get(l);if(d.status==200){const u=d.data;return this.recordUpdate(u),u}}return null},addResource(e={}){this.detailSelection=[s.omit(s.merge({},e),this.idProperty)],this.editingDetailSelection=!0},async deleteResource(e){if((await q.delete(`${n.restCollectionUrl}/${e}`)).status==200&&["Loaded","LoadingMore"].includes(this.status)){let t=this.resources.findIndex(l=>g(l,this)==e);t>=0&&this.resources.splice(t,1),t=this.selection.findIndex(l=>g(l,this)==e),t>=0&&this.selection.splice(t,1),t=this.detailSelection.findIndex(l=>g(l,this)==e),t>=0&&(this.detailSelection.splice(t,1),this.detailSelection.length==0&&(this.editingDetailSelection=n.detail.autoEdit)),n.limitTransientDataToLocalCollection&&delete this.transientData[e]}},async saveResource(e){const r=g(e,this),t=r==null,l=await q({method:t?"post":"put",url:t?n.restCollectionUrl:`${n.restCollectionUrl}/${r}`,data:e});if(l.status==200){const d=l.data,u=g(d,this),h=u?await this.refreshResource(u):null;return t&&this.recordInsertion(h||Object.freeze(d)),h||d}return null},async saveResources(e){const r=await q({method:"put",url:n.restCollectionUrl,data:e});if(r.status==200){const t=r.data||[],l=[];for(const[d,u]of t.entries()){const h=g(e[d],this)==null,S=g(u,this),C=S?await this.refreshResource(S):null;h&&this.recordInsertion(C||u),l.push(C||Object.freeze(u))}return l}return[]},clearTransientData(){this.transientData={}},setInvalidResourceIds(e){s.isEqual(e,this.invalidResources.map(r=>g(r,this)))||(this.invalidResources=e.map(r=>this.resources.find(t=>g(t,this)==r)).filter(r=>r!=null))},setTransientDataForResources(e){const{transientData:r,merge:t=!0}=e;t?s.merge(this.transientData,r):s.assign(this.transientData,r)},clearSelection(){this.setSelection([])},deselectResources(e){const r=this.selection.map(t=>g(t,this)).filter(t=>t!=null&&!e.includes(t));this.setSelection(r)},selectResources(e,r){const{addToSelection:t,edit:l}=r||{},d=this.selection.map(h=>g(h,this));let u=e;if(t){const h=s.difference(e,d);h.length>0&&(u=d.concat(h).filter(S=>S!=null))}s.isEqual(d,u)||this.setSelection(u,l)},setSelection(e,r){if(!s.isEqual(e,this.selection.map(t=>g(t,this)))){let t=!0;if(this.editors.length>0){if(n.detail.autoFromSingleSelection&&this.selection.length==1)t=!1;else if(n.detail.autoFromMultipleSelection&&n.detail.allowMultiple&&this.selection.length>1)t=!1;else if(n.detail.constrainToSelection){const l=this.selection.map(h=>g(h,this)),u=this.detailSelection.map(h=>g(h,this)).filter(h=>l.includes(h));this.detailSelection.filter(h=>!u.includes(g(h,this))).length>0&&(t=!1)}}if(!t)return;if(this.selection=e.map(l=>this.resources.find(d=>g(d,this)==l)).filter(l=>l!=null),n.detail.autoFromSingleSelection&&this.selection.length==1){const l=this.selection[0];(this.detailSelection.length!=1||g(this.detailSelection[0],this)!=g(l,this))&&(this.detailSelection=[l])}else if(n.detail.autoFromMultipleSelection&&n.detail.allowMultiple&&this.selection.length>1)s.isEqual(this.selection.map(l=>g(l,this)),this.detailSelection.map(l=>g(l,this)))||(this.detailSelection=s.clone(this.selection));else if(n.detail.constrainToSelection){const l=this.selection.map(h=>g(h,this)),d=this.detailSelection.map(h=>g(h,this)),u=d.filter(h=>l.includes(h));s.isEqual(u,d)||(this.detailSelection=this.detailSelection.filter(h=>u.includes(g(h,this))))}this.detailSelection.length==0?this.editingDetailSelection=!1:this.editingDetailSelection=r!==void 0?r:this.editingDetailSelection||n.detail.autoEdit}},hideDetail(){this.detailSelection.length>0&&(this.detailSelection=[],this.editingDetailSelection=!1)},showSelectionAsDetail(e){if(this.selection.length<=1||n.detail.allowMultiple){const r=this.selection.map(l=>g(l,this)),t=this.detailSelection.map(l=>g(l,this));s.isEqual(r,t)||(this.detailSelection=s.clone(this.selection)),this.detailSelection.length==0?this.editingDetailSelection=!1:this.editingDetailSelection=e!==void 0?e:this.editingDetailSelection||n.detail.autoEdit}},deregisterEditor(e){s.remove(this.editors,r=>r==e)},registerEditor(e){this.editors.includes(e)||this.editors.push(e)},deregisterListNavigator({name:e,listNavigator:r}){(r==null||this.listNavigators[e]==r)&&delete this.listNavigators[e]},registerListNavigator({name:e,listNavigator:r}){this.listNavigators[e]!=r&&(this.listNavigators[e]=r)}}});return(()=>{const e=(r,t)=>{const l=y(r,t);return _.registerStore(l.$id,l),l};return e.$id=y.$id,e})()},_=new de,Ee=(m={})=>{var ge,ve,pe,me;const{collectionId:n,draftBatchId:y,enabled:I,resourceType:e,options:r}=m,t=o.ref(void 0),l=o.ref(n),d=o.ref(y),u=o.ref(I??!0),h=o.ref([o.toRef(e)]),S=o.ref(r),C=o.computed(()=>d.value),L=o.ref(u.value),k=o.ref(U.v4()),x=o.ref((ve=(ge=S.value)==null?void 0:ge.filter)==null?void 0:ve.resourceIds),O=o.ref((me=(pe=S.value)==null?void 0:pe.filter)==null?void 0:me.query),B=o.computed(()=>d.value==null&&l.value!=null&&_.getStore(l.value)!=null),P=o.ref(B.value),w=o.computed(()=>E("status","Uninitialized"));function p(i){if(t.value)return i(t.value)}async function $(i){if(t.value)return await i(t.value)}function E(i,c){if(t.value)return t.value[i];if(c!==void 0)return c;throw"Attempted to use a REST collection store that has not been created, with no default value."}const D=(i={})=>{var te,Re,Se,ye;const{collectionId:c,draftBatchId:T,enabled:N,resourceType:ne,options:ee}=i;l.value=c,d.value=T,u.value=N??!0,h.value=[o.toRef(ne)],ee!=null&&(S.value=ee,x.value=(Re=(te=S.value)==null?void 0:te.filter)==null?void 0:Re.resourceIds,O.value=(ye=(Se=S.value)==null?void 0:Se.filter)==null?void 0:ye.query),k.value=U.v4(),H(u.value)},H=async i=>{i!=L.value&&(L.value=i,i&&(V(),A()))},le=async i=>{x.value=i,await $(async c=>await c.setFilterResourceIds(x.value||null))},Z=async i=>{if(O.value=i,w.value!="Uninitialized"){const c=i,T=o.computed(()=>s.isFunction(c)?R.value?c(R.value):null:c);await $(N=>N.setQuery(T.value||null))}},V=()=>{S.value=s.merge({},S.value||{},{filter:{resourceIds:x.value,query:O.value}})},R=o.computed(()=>h.value[0].value||void 0),Q=function(i){const c=s.get(i,"filter.query"),T=s.get(i,"propertyBlacklist"),N=s.get(i,"referencePathsToExpand"),ne=s.isFunction(c)?c(R.value):c,ee=R.value?s.isFunction(T)?T(R.value):T||[]:[],te=R.value?s.isFunction(N)?N(R.value):N||[]:[];return{...s.cloneDeep(i||{}),filter:{...s.cloneDeep((i==null?void 0:i.filter)||{}),query:ne},propertyBlacklist:ee,referencePathsToExpand:te}},F=o.computed(()=>Q(S.value)),M=o.computed(()=>{if(F.value.restCollectionUrl!==void 0)return F.value.restCollectionUrl;if(!P.value)return!R.value||!R.value.collectionName?null:C.value?`${X.config.apiBaseUrl}/draft-batches/${C.value}/${R.value.collectionName}`:`${X.config.apiBaseUrl}/${R.value.collectionName}`}),a=o.computed(()=>{var i;if(R.value)return s.mergeWith(s.cloneDeep(he),F.value,{idProperty:(i=R.value)==null?void 0:i.idProperty,restCollectionUrl:M.value||""},(c,T)=>{if(s.isArray(T)&&T.length==0&&(c==null||s.isArray(c)))return T})}),f=o.ref(0),z=o.computed(()=>{var i;return f.value,l.value||R.value&&((i=R.value)==null?void 0:i.collectionName)&&(C.value?`draftBatches/${C.value}/${R.value.collectionName}/${k.value}`:`${R.value.collectionName}/${k.value}`)||null}),A=()=>{if(L.value){let i=!1;return R.value&&z.value&&(t.value=_.getStore(z.value),t.value?i=!1:a.value&&(P.value=!1,t.value=Ce(z.value,a.value)(),i=!0)),i}else return!1},J=()=>{z.value&&l.value==z.value?(t.value=void 0,A()):(t.value=void 0,f.value=f.value+1,A())};o.watch(C,(i,c)=>{s.isEqual(i,c)||J()}),o.watch(L,(i,c)=>{i!=c&&(i?A():t.value=void 0)}),o.watch(R,(i,c)=>{i&&!c?A():!i&&c||s.isEqual(i,c)||J()}),o.watch(a,(i,c)=>{s.isEqual(i,c)||J()}),o.watch(B,()=>{B.value||(P.value=!1)}),o.watch(z,()=>A()),o.watch(M,(i,c)=>{s.isEqual(i,c)||J()});const W=[],Pe=function(i){w.value!="Uninitialized"?o.nextTick(i):W.push(i)};return o.watch(w,(i,c)=>{if(i!="Uninitialized"&&c=="Uninitialized"){const T=s.clone(W);W.splice(0,W.length);for(const N of T)N()}}),A(),{collectionId:z,draftBatchId:C,resourceType:R,restCollectionUrl:o.computed(()=>E("restCollectionUrl",null)),enabled:L,status:w,batchSaveAttempted:o.computed(()=>E("batchSaveAttempted",!1)),listNavigators:o.computed(()=>E("listNavigators",!1)),invalidResources:o.computed(()=>E("invalidResources",[])),resources:o.computed(()=>w.value!="Uninitialized"?($(i=>i.ensureCollectionLoaded()),E("resources",[])):[]),remoteCollectionSize:o.computed(()=>E("remoteCollectionSize",null)),transientData:o.computed(()=>E("transientData",[])),detailSelection:o.computed(()=>E("detailSelection",[])),editingDetailSelection:o.computed(()=>E("editingDetailSelection",!1)),selection:o.computed(()=>E("selection",[])),reconfigureCollection:D,setEditingDetailSelection:i=>p(c=>c.setEditingDetailSelection(i)),setEnabled:H,setFilterResourceIds:le,setQuery:Z,ensureStore:A,setBatchSaveAttempted:i=>p(c=>c.setBatchSaveAttempted(i)),clear:()=>p(i=>i.clear()),ensureCollectionLoaded:async()=>await $(async i=>i.ensureCollectionLoaded()),loadResources:async()=>await $(async i=>await i.loadResources()),addResource:i=>p(c=>c.addResource(i)),checkForDeletedResource:async i=>await $(async c=>await c.checkForDeletedResource(i))==!0,recordDeletion:i=>p(c=>c.recordDeletion(i)),recordInsertion:(i,{insertAtBeginning:c=!1,transientData:T=void 0}={})=>p(N=>N.recordInsertion(i,{insertAtBeginning:c,transientData:T})),recordUpdate:i=>p(c=>c.recordUpdate(i)),refreshResource:async i=>await $(async c=>await c.refreshResource(i)),deleteResource:async i=>await $(async c=>await c.deleteResource(i)),saveResource:async i=>await $(async c=>await c.saveResource(i)),saveResources:async i=>await $(async c=>await c.saveResources(i)),clearTransientData:()=>p(i=>i.clearTransientData()),setInvalidResourceIds:i=>p(c=>c.setInvalidResourceIds(i)),setTransientDataForResources:i=>p(c=>c.setTransientDataForResources(i)),clearSelection:()=>p(i=>i.clearSelection()),deselectResources:i=>p(c=>c.deselectResources(i)),selectResources:(i,c)=>p(T=>T.selectResources(i,c)),hideDetail:()=>p(i=>i.hideDetail()),deregisterEditor:i=>p(c=>c.deregisterEditor(i)),registerEditor:i=>p(c=>c.registerEditor(i)),deregisterListNavigator:i=>p(c=>c.deregisterListNavigator(i)),registerListNavigator:i=>p(c=>c.registerListNavigator(i)),onItemsStoreReady:Pe}},Te=()=>{_.clearAllStores()};function se(m,n){return s.get(m,(n==null?void 0:n.idProperty)||"_id")}const fe={idProperty:"_id"},Y={resource:null,status:"NotLoaded"},Le=(m,n)=>{n=s.merge({},fe,n);const y=ce.defineStore(m,{state:()=>({idProperty:n.idProperty,resourceId:n.resourceId||null,resourceUrl:n.resourceUrl||null,referencePathsToExpand:n.referencePathsToExpand||null,...Y}),getters:{currentResourceUrl:e=>e.resourceUrl||(n.restCollectionUrl&&e.resourceId?`${n.restCollectionUrl}/${e.resourceId}`:null)||n.restCollectionUrl||null,fixedQueryParams:e=>{const r={};return e.referencePathsToExpand&&(r.r=G(e.referencePathsToExpand)),r}},actions:{reset(){for(const e in Y)this[e]=Y[e]},async setResourceId(e){const r=this.currentResourceUrl;this.resourceId=e,!s.isEqual(this.currentResourceUrl,r)&&this.status!="NotLoaded"&&await this.loadResource()},async setResourceUrl(e){const r=this.currentResourceUrl;this.resourceUrl=e,!s.isEqual(this.currentResourceUrl,r)&&this.status!="NotLoaded"&&await this.loadResource()},clear(){for(const e in Y)this[e]=Y[e]},async ensureResourceLoaded(){["Loaded","Loading","Failed"].includes(this.status)||await this.loadResource()},async loadResource(){this.reset();const e=U.v4();if(this._loadId=e,this.currentResourceUrl){this.status="Loading";const r=this.fixedQueryParams,t=s.cloneDeep(r),l=s.map(t,(u,h)=>u!=null?`${encodeURIComponent(h)}=${encodeURIComponent(u)}`:null).filter(u=>u!=null).join("&"),d=s.isEmpty(l)?this.currentResourceUrl:`${this.currentResourceUrl}?${l}`;try{const u=await q.get(d),h=this.fixedQueryParams;e!=this._loadId||!s.isEqual(r,h)?console.log(`Discarding resource fetched by obsolete query from ${d}.`):(this.resource=ae.decode(s.get(u,"data",{})),this.status="Loaded")}catch(u){console.log(`Error while loading resource (URL="${d}")`,u),this.reset(),this.status="Failed"}}else throw"Cannot load a resource because its URL, or its ID and collection URL, are unknown."},async checkForDeletedResource(){if(this.currentResourceUrl){let e;try{e=await q.get(this.currentResourceUrl)}catch(r){q.isAxiosError(r)&&(e=r.response)}return e&&e.status==404?(this.recordDeletion(),!0):!1}else throw"Cannot check for a deleted resource because its URL, or its ID and collection URL, are unknown."},recordDeletion(){this.resource=null,this.status="Loaded"},recordInsertion(e){this.resourceId=se(e,this)||null,this.status=="Loaded"&&(this.resource=Object.freeze(e))},recordUpdate(e){this.resourceId=se(e,this)||null,this.status=="Loaded"&&(this.resource=Object.freeze(e))},async refreshResource(){return await this.loadResource(),this.resource},async deleteResource(){if(this.currentResourceUrl)(await q.delete(this.currentResourceUrl)).status==200&&this.recordDeletion();else throw"Cannot delete a resource because its URL, or its ID and collection URL, are unknown."},async saveResource(e){const r=se(e,this),t=r==null;if(!r)throw"The REST resource store cannot create new resources on the server.";if(!this.currentResourceUrl)throw"Cannot save a resource because its URL, or its ID and collection URL, are unknown.";const l=await q({method:t?"post":"put",url:this.currentResourceUrl,data:e});if(l.status==200){const d=l.data,u=await this.refreshResource();return t&&this.recordInsertion(u||d),u||Object.freeze(d)}return null},async makeCustomApiRequest(e){const{method:r,subpath:t,url:l,data:d}=e;let u=l;if(!u)if(this.currentResourceUrl)u=`${this.currentResourceUrl}/${t}`;else throw"Cannot make a custom API request for a resource because its URL, or its ID and collection URL, are unknown.";const h=await q({method:r||"get",url:u,data:d});return h.status>=200&&h.status<300?h.data:null}}});return(()=>{const e=(r,t)=>{const l=y(r,t);return re.registerStore(l.$id,l),l};return e.$id=y.$id,e})()},re=new de,$e=(m={})=>{const{resourceClientId:n,draftBatchId:y,enabled:I,resourceType:e,options:r}=m,t=o.ref(void 0),l=o.ref(n),d=o.ref(y),u=o.ref(I??!0),h=o.ref([o.toRef(e)]),S=o.ref(r),C=o.computed(()=>d.value),L=o.ref(u.value),k=o.ref(U.v4()),x=o.computed(()=>d.value==null&&l.value!=null&&re.getStore(l.value)!=null),O=o.ref(x.value),B=o.computed(()=>p("status","Uninitialized"));function P(a){if(t.value)return a(t.value)}async function w(a){if(t.value)return await a(t.value)}function p(a,f){if(t.value)return t.value[a];if(f!==void 0)return f;throw"Attempted to use a REST resource store that has not been created, with no default value."}const $=(a={})=>{const{resourceClientId:f,draftBatchId:z,enabled:A,resourceType:J,options:W}=a;l.value=f,d.value=z,u.value=A??!0,h.value=[o.toRef(J)],W!=null&&(S.value=W),k.value=U.v4(),E(u.value)},E=async a=>{a!=L.value&&(L.value=a,a&&F())},D=o.computed(()=>h.value[0].value||void 0),H=function(a){const f=s.get(a,"referencePathsToExpand"),z=D.value?s.isFunction(f)?f(D.value):f||[]:[];return{...s.cloneDeep(a||{}),referencePathsToExpand:z}},le=o.computed(()=>H(S.value)),Z=o.computed(()=>{if(!D.value)return null;if(!O.value)return!D.value||!D.value.collectionName?null:C.value?`${X.config.apiBaseUrl}/draft-batches/${C.value}/${D.value.collectionName}`:`${X.config.apiBaseUrl}/${D.value.collectionName}`}),V=o.computed(()=>{if(D.value&&Z.value)return s.mergeWith(s.cloneDeep(fe),le.value,{idProperty:D.value.idProperty,restCollectionUrl:Z.value},(a,f)=>{if(s.isArray(f)&&f.length==0&&(a==null||s.isArray(a)))return f})}),R=o.ref(0),Q=o.computed(()=>{var a;return R.value,l.value||D.value&&((a=D.value)==null?void 0:a.collectionName)&&(C.value?`draftBatches/${C.value}/${D.value.collectionName}/${k.value}`:`${D.value.collectionName}/${k.value}`)||null}),F=()=>{if(L.value){let a=!1;return D.value&&Q.value&&(t.value=re.getStore(Q.value),t.value?a=!1:V.value&&(O.value=!1,t.value=Le(Q.value,V.value)(),a=!0)),a}else return!1},M=()=>{Q.value&&l.value==Q.value?(t.value=void 0,F()):(t.value=void 0,R.value=R.value+1,F())};return o.watch(C,(a,f)=>{s.isEqual(a,f)||M()}),o.watch(L,(a,f)=>{a!=f&&(a?F():t.value=void 0)}),o.watch(D,(a,f)=>{a&&!f?F():!a&&f||s.isEqual(a,f)||M()}),o.watch(V,(a,f)=>{s.isEqual(a,f)||M()}),o.watch(x,()=>{x.value||(O.value=!1)}),o.watch(Q,()=>F()),o.watch(Z,(a,f)=>{s.isEqual(a,f)||M()}),F(),{resourceClientId:Q,draftBatchId:C,enabled:L,resourceType:D,status:B,resource:o.computed(()=>B.value!="Uninitialized"?(w(a=>a.ensureResourceLoaded()),p("resource",[])):[]),resourceId:o.computed(()=>p("resourceId",null)),resourceUrl:o.computed(()=>p("resourceUrl",null)),reconfigureClient:$,setEnabled:E,setResourceId:async a=>await w(async f=>await f.setResourceId(a)),setResourceUrl:async a=>await w(async f=>await f.setResourceUrl(a)),ensureStore:F,clear:()=>P(a=>a.clear()),ensureResourceLoaded:async()=>await w(async a=>a.ensureResourceLoaded()),loadResource:async()=>await w(async a=>await a.loadResource()),checkForDeletedResource:async()=>await w(async a=>await a.checkForDeletedResource())==!0,recordDeletion:()=>w(a=>a.recordDeletion()),recordInsertion:a=>w(f=>f.recordInsertion(a)),recordUpdate:a=>w(f=>f.recordUpdate(a)),refreshResource:async()=>await w(async a=>await a.refreshResource()),deleteResource:async()=>await w(async a=>await a.deleteResource()),saveResource:async a=>await w(async f=>await f.saveResource(a)),makeCustomApiRequest:async a=>await w(async f=>await f.makeCustomApiRequest(a))}},X={config:{...ue}};function qe(m){X.config=s.merge({},ue,m)}v.ApiClientError=we,v.clearAllRestCollections=Te,v.initRestClient=qe,v.restClient=X,v.useRestCollection=Ee,v.useRestResource=$e,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
@@ -1 +1 @@
1
- {"version":3,"file":"rest-collection-store.d.ts","sourceRoot":"","sources":["../../../src/stores/rest-collection-store.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,sBAAsB,EAAE,sBAAsB,EAAC,MAAM,uBAAuB,CAAA;AACpF,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,eAAe,CAAA;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAA;AAuCvD,2FAA2F;AA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