@overmap-ai/core 1.1.1-form-submission-edits.0 → 1.2.0

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.
@@ -3,7 +3,7 @@ var ic = (t, s, e) => s in t ? sc(t, s, { enumerable: !0, configurable: !0, writ
3
3
  var o = (t, s, e) => ic(t, typeof s != "symbol" ? s + "" : s, e);
4
4
  import "@redux-offline/redux-offline/lib/types";
5
5
  import { createAction as Yt, createSelector as p, createSlice as b, isAnyOf as _, combineReducers as Gi } from "@reduxjs/toolkit";
6
- import mt from "superagent";
6
+ import pt from "superagent";
7
7
  import { v4 as lt } from "uuid";
8
8
  import { useMemo as nc } from "react";
9
9
  import rc from "fast-tree-builder";
@@ -279,7 +279,7 @@ function E(t) {
279
279
  function Vc(t, s) {
280
280
  return t.localeCompare(s);
281
281
  }
282
- function ft(t, s) {
282
+ function yt(t, s) {
283
283
  return Vc(t.uuid, s.uuid);
284
284
  }
285
285
  function xM(t, s = void 0, e = 255) {
@@ -1481,11 +1481,11 @@ const m = (
1481
1481
  setFormSubmission: mp,
1482
1482
  setFormSubmissions: yp,
1483
1483
  addFormSubmission: fp,
1484
- addFormSubmissions: St,
1484
+ addFormSubmissions: ft,
1485
1485
  updateFormSubmission: Sp,
1486
1486
  updateFormSubmissions: Op,
1487
1487
  deleteFormSubmission: Ap,
1488
- deleteFormSubmissions: Ot
1488
+ deleteFormSubmissions: St
1489
1489
  } = er.actions, Tp = (t) => t.formSubmissionReducer.instances, G = p(
1490
1490
  [Tp],
1491
1491
  (t) => Object.values(t)
@@ -2788,27 +2788,27 @@ const m = (
2788
2788
  updateProcedures: NA,
2789
2789
  deleteProcedure: HA,
2790
2790
  deleteProcedures: Rt
2791
- } = na.actions, GA = na.reducer, WA = (t) => t.procedureReducer.instances, At = p(
2791
+ } = na.actions, GA = na.reducer, WA = (t) => t.procedureReducer.instances, Ot = p(
2792
2792
  [WA],
2793
2793
  (t) => Object.values(t)
2794
2794
  ), KA = (t) => (s) => s.procedureReducer.instances[t], YA = m(
2795
- p([At, (t, s) => s], (t, s) => {
2795
+ p([Ot, (t, s) => s], (t, s) => {
2796
2796
  const e = new Set(s);
2797
2797
  return f(t.filter(({ uuid: i }) => e.has(i)));
2798
2798
  })
2799
2799
  ), ug = m(
2800
- p([At, (t, s) => s], (t, s) => f(t.filter((e) => e.project === s)))
2800
+ p([Ot, (t, s) => s], (t, s) => f(t.filter((e) => e.project === s)))
2801
2801
  ), JA = m(
2802
- p([At, (t, s) => s], (t, s) => f(t.filter((e) => e.procedure_type === s)))
2802
+ p([Ot, (t, s) => s], (t, s) => f(t.filter((e) => e.procedure_type === s)))
2803
2803
  ), ZA = m(
2804
- p([At, (t, s) => s], (t, s) => f(t.filter((e) => e.asset === s)))
2804
+ p([Ot, (t, s) => s], (t, s) => f(t.filter((e) => e.asset === s)))
2805
2805
  ), XA = m(
2806
- p([At, (t, s) => s], (t, s) => {
2806
+ p([Ot, (t, s) => s], (t, s) => {
2807
2807
  const e = new Set(s);
2808
2808
  return f(t.filter(({ asset: i }) => e.has(i)));
2809
2809
  })
2810
2810
  ), QA = m(
2811
- p([At, (t, s) => s], (t, s) => f(t.filter((e) => e.procedure_initiative === s)))
2811
+ p([Ot, (t, s) => s], (t, s) => f(t.filter((e) => e.procedure_initiative === s)))
2812
2812
  ), He = P((t) => t.uuid), _i = {
2813
2813
  instances: {}
2814
2814
  }, ra = b({
@@ -3237,19 +3237,19 @@ const m = (
3237
3237
  updateProcedureStepFieldValuesMany: QI,
3238
3238
  deleteProcedureStepFieldValues: eb,
3239
3239
  deleteProcedureStepFieldValuesMany: tb
3240
- } = ba.actions, sb = ba.reducer, ib = (t) => t.procedureStepFieldValuesReducer.instances, Tt = p(
3240
+ } = ba.actions, sb = ba.reducer, ib = (t) => t.procedureStepFieldValuesReducer.instances, At = p(
3241
3241
  [ib],
3242
3242
  (t) => Object.values(t)
3243
3243
  ), _g = m(
3244
- p([Tt, (t, s) => s], (t, s) => f(t.filter((e) => e.procedure === s)))
3244
+ p([At, (t, s) => s], (t, s) => f(t.filter((e) => e.procedure === s)))
3245
3245
  ), Mg = m(
3246
3246
  p(
3247
- [Tt, (t, s) => s],
3247
+ [At, (t, s) => s],
3248
3248
  (t, s) => f(t.filter((e) => e.procedure_step === s))
3249
3249
  )
3250
3250
  ), nb = (t) => (s) => s.procedureStepFieldValuesReducer.instances[t], rb = m(
3251
3251
  p(
3252
- [Tt, (t, s) => s],
3252
+ [At, (t, s) => s],
3253
3253
  (t, s) => {
3254
3254
  const e = new Set(s);
3255
3255
  return f(t.filter(({ uuid: i }) => e.has(i)));
@@ -3258,7 +3258,7 @@ const m = (
3258
3258
  ), Fg = m(
3259
3259
  p(
3260
3260
  [
3261
- Tt,
3261
+ At,
3262
3262
  (t, s) => s,
3263
3263
  (t, s, e) => e
3264
3264
  ],
@@ -3298,12 +3298,12 @@ const m = (
3298
3298
  updateProcedureStepFieldValuesReviews: lb,
3299
3299
  deleteProcedureStepFieldValuesReview: hb,
3300
3300
  deleteProcedureStepFieldValuesReviews: Ma
3301
- } = Pa.actions, pb = (t) => t.procedureStepFieldValuesReviewReducer.instances, It = p(
3301
+ } = Pa.actions, pb = (t) => t.procedureStepFieldValuesReviewReducer.instances, Tt = p(
3302
3302
  [pb],
3303
3303
  (t) => Object.values(t)
3304
3304
  ), mb = (t) => (s) => s.procedureStepFieldValuesReviewReducer.instances[t], yb = m(
3305
3305
  p(
3306
- [It, (t, s) => s],
3306
+ [Tt, (t, s) => s],
3307
3307
  (t, s) => {
3308
3308
  const e = new Set(s);
3309
3309
  return f(t.filter(({ uuid: i }) => e.has(i)));
@@ -3311,12 +3311,12 @@ const m = (
3311
3311
  )
3312
3312
  ), fb = m(
3313
3313
  p(
3314
- [It, (t, s) => s],
3314
+ [Tt, (t, s) => s],
3315
3315
  (t, s) => f(t.filter((e) => e.field_values === s))
3316
3316
  )
3317
3317
  ), gg = m(
3318
3318
  p(
3319
- [It, (t, s) => s],
3319
+ [Tt, (t, s) => s],
3320
3320
  (t, s) => {
3321
3321
  let e;
3322
3322
  for (const i of t) {
@@ -3329,8 +3329,8 @@ const m = (
3329
3329
  ), wg = m(
3330
3330
  p(
3331
3331
  [
3332
+ At,
3332
3333
  Tt,
3333
- It,
3334
3334
  (t, s) => s
3335
3335
  ],
3336
3336
  (t, s, e) => {
@@ -3347,8 +3347,8 @@ const m = (
3347
3347
  ), Rg = m(
3348
3348
  p(
3349
3349
  [
3350
+ At,
3350
3351
  Tt,
3351
- It,
3352
3352
  (t, s) => s,
3353
3353
  (t, s, e) => e
3354
3354
  ],
@@ -3367,7 +3367,7 @@ const m = (
3367
3367
  );
3368
3368
  }
3369
3369
  )
3370
- ), Eg = p([It], (t) => {
3370
+ ), Eg = p([Tt], (t) => {
3371
3371
  const s = {};
3372
3372
  for (const e of t) {
3373
3373
  const { field_values: i } = e, n = s[i];
@@ -3953,10 +3953,10 @@ const U_ = (t) => {
3953
3953
  const s = kt();
3954
3954
  s ? s.dispatch({ type: "rehydrated/setRehydrated", payload: !0 }) : console.error("Client store not set");
3955
3955
  }, L_ = (t, s, e) => {
3956
- const i = yt();
3956
+ const i = mt();
3957
3957
  return i ? (i.addRequest(s), i.getQueue()) : (console.warn("Outbox coordinator not set; cannot enqueue request yet."), []);
3958
3958
  }, N_ = (t, s, e) => {
3959
- const i = yt();
3959
+ const i = mt();
3960
3960
  if (!i)
3961
3961
  return console.warn("Outbox coordinator not set; cannot dequeue request yet."), [];
3962
3962
  const a = s.meta.offlineAction.payload.uuid;
@@ -4025,7 +4025,7 @@ Retries:`,
4025
4025
  const i = kt(), a = i.getState().outboxReducer.deletedRequests, r = s.payload.uuid;
4026
4026
  function d() {
4027
4027
  i.dispatch(hO(r));
4028
- const l = yt();
4028
+ const l = mt();
4029
4029
  if (!l)
4030
4030
  throw new Error("Outbox coordinator not set");
4031
4031
  l.remove(s.payload.uuid);
@@ -4034,24 +4034,24 @@ Retries:`,
4034
4034
  }
4035
4035
  if (t instanceof U && t.options.discard && (console.debug("Discarding request due to explicit discard:", s.payload.url), d()), a.includes(r) && (console.debug("Discarding request due to deletion:", s.payload.url), d()), t instanceof U) {
4036
4036
  const l = t.status || ((h = t.response) == null ? void 0 : h.status);
4037
- if (l || console.warn("Error has no status code:", t), l !== void 0 && Ka.includes(l)) {
4037
+ if (l || console.warn("Error has no status code:", t), t.options.discard !== !1 && l !== void 0 && Ka.includes(l)) {
4038
4038
  console.warn("Discarding request due to error:", t, `
4039
4039
  Action:`, s);
4040
- const y = yt();
4040
+ const y = mt();
4041
4041
  if (!y)
4042
4042
  throw new Error("Outbox coordinator not set");
4043
4043
  y.remove(s.payload.uuid), t.options.discard = !0, d();
4044
4044
  }
4045
4045
  }
4046
4046
  console.debug("Registering a retry for request:", s.payload.uuid);
4047
- const c = yt();
4047
+ const c = mt();
4048
4048
  if (!c)
4049
4049
  throw new Error("Outbox coordinator not set");
4050
4050
  return c.registerRetry(s.payload.uuid), !1;
4051
4051
  }
4052
4052
  function Y_(t, s, e) {
4053
4053
  var i;
4054
- return (i = yt()) == null ? void 0 : i.peek();
4054
+ return (i = mt()) == null ? void 0 : i.peek();
4055
4055
  }
4056
4056
  function J_(t, s) {
4057
4057
  return kt().dispatch(pO((/* @__PURE__ */ new Date()).getTime())), pc;
@@ -4088,7 +4088,7 @@ class U extends Error {
4088
4088
  o(this, "message");
4089
4089
  o(this, "options");
4090
4090
  const { response: i, innerError: n } = e;
4091
- this.message = e.message ?? X_(i, n) ?? Et, this.status = (i == null ? void 0 : i.status) ?? 0, this.response = i, e.discard = e.discard ?? !1, this.options = e;
4091
+ this.message = e.message ?? X_(i, n) ?? Et, this.status = (i == null ? void 0 : i.status) ?? 0, this.response = i, this.options = e;
4092
4092
  }
4093
4093
  }
4094
4094
  function Q_(t) {
@@ -4106,15 +4106,44 @@ class eM extends Ja {
4106
4106
  constructor(s) {
4107
4107
  super(s);
4108
4108
  }
4109
+ /**
4110
+ * Attaches this service's credentials to an outgoing request, and is the only place `performRequest` authenticates.
4111
+ *
4112
+ * A bearer token is a header and nothing else, so the default implementation just sets `Authorization` from
4113
+ * `getAuthHeader()`. A cookie-based scheme has no header to return: it needs `withCredentials()` on the request
4114
+ * itself, which a `getAuthHeader()` return value cannot express. Overriding this is how such a service reaches the
4115
+ * request at all.
4116
+ *
4117
+ * NOTE: The empty-header guard is not just tidiness. Sending `Authorization:` with an empty value still counts as a
4118
+ * non-simple header, so the browser would preflight every request to carry nothing.
4119
+ * @param request The request about to be sent.
4120
+ * @returns The request, with credentials attached.
4121
+ */
4122
+ applyAuth(s) {
4123
+ const e = this.getAuthHeader();
4124
+ return e ? s.set("Authorization", e) : s;
4125
+ }
4126
+ /**
4127
+ * Whether `response` means "you are not authenticated", as opposed to any other failure.
4128
+ *
4129
+ * Only responses this returns true for are routed to `handleUnauthorized`. A bearer token can only ever fail with a
4130
+ * 401, but a session-based service also has to recognise the 403 that Django's CSRF check produces, which is
4131
+ * otherwise indistinguishable from a genuine permission denial.
4132
+ * @param response The failing response.
4133
+ * @returns Whether the request failed because it was not authenticated.
4134
+ */
4135
+ isAuthFailure(s) {
4136
+ return s.status === 401;
4137
+ }
4109
4138
  }
4110
- class bt extends Ja {
4139
+ class It extends Ja {
4111
4140
  constructor(e, i) {
4112
4141
  super(e);
4113
4142
  o(this, "auth");
4114
4143
  this.auth = i;
4115
4144
  }
4116
4145
  }
4117
- class Jg extends bt {
4146
+ class Jg extends It {
4118
4147
  async startConversation(s, e) {
4119
4148
  return this.enqueueRequest({
4120
4149
  description: "Start agent conversation",
@@ -4214,7 +4243,7 @@ function R(t) {
4214
4243
  e in s && delete s[e];
4215
4244
  return s;
4216
4245
  }
4217
- class v extends bt {
4246
+ class v extends It {
4218
4247
  async get(s, e) {
4219
4248
  return this.performRequest(
4220
4249
  {
@@ -4307,29 +4336,29 @@ class q extends v {
4307
4336
  for (const O of h) {
4308
4337
  const w = [], g = {}, B = [], k = [];
4309
4338
  for (const V of O) {
4310
- let $;
4339
+ let j;
4311
4340
  if ("file" in V) {
4312
- const { file: ht, ...tc } = V, pt = await this.client.files.getFilePayload(ht);
4313
- pt.sha1 in g || (g[pt.sha1] = pt);
4314
- const As = URL.createObjectURL(ht);
4315
- c.add(As), $ = {
4341
+ const { file: Pt, ...tc } = V, ht = await this.client.files.getFilePayload(Pt);
4342
+ ht.sha1 in g || (g[ht.sha1] = ht);
4343
+ const As = URL.createObjectURL(Pt);
4344
+ c.add(As), j = {
4316
4345
  ...tc,
4317
- file_sha1: pt.sha1,
4318
- file_type: pt.file_type,
4319
- file_name: ht.name,
4320
- file_extension: pt.extension,
4346
+ file_sha1: ht.sha1,
4347
+ file_type: ht.file_type,
4348
+ file_name: Pt.name,
4349
+ file_extension: ht.extension,
4321
4350
  object_url: As
4322
4351
  };
4323
4352
  } else
4324
- $ = V;
4325
- const x = this.buildModel($);
4326
- d.push(x);
4327
- const zt = this.buildBulkPayload(x);
4353
+ j = V;
4354
+ const L = this.buildModel(j);
4355
+ d.push(L);
4356
+ const zt = this.buildBulkPayload(L);
4328
4357
  w.push(zt);
4329
- const j = this.getBlockers(x);
4330
- B.push(...j);
4331
- const L = this.getBlocks(x);
4332
- k.push(...L);
4358
+ const $ = this.getBlockers(L);
4359
+ B.push(...$);
4360
+ const x = this.getBlocks(L);
4361
+ k.push(...x);
4333
4362
  }
4334
4363
  const D = {
4335
4364
  payloads: w,
@@ -4640,7 +4669,7 @@ class Qg extends v {
4640
4669
  const { addOne: i, deleteOne: n } = this.actions, { selectById: a } = this.selectors, r = this.select(a(e));
4641
4670
  if (!r) throw new Error(`No asset with uuid ${e} found in the store`);
4642
4671
  const d = this.select(td(e)), c = this.select(pd(e)), h = this.select(em(e)), l = this.select(ZA(e)), y = this.select(Fp(e));
4643
- this.dispatch(n(e)), this.dispatch(tn(E(d))), this.dispatch(Kt(E(c))), this.dispatch(gt(E(h))), this.dispatch(Rt(E(l))), this.dispatch(Ot(E(y)));
4672
+ this.dispatch(n(e)), this.dispatch(tn(E(d))), this.dispatch(Kt(E(c))), this.dispatch(gt(E(h))), this.dispatch(Rt(E(l))), this.dispatch(St(E(y)));
4644
4673
  try {
4645
4674
  return await this.enqueueRequest({
4646
4675
  description: S(u.DELETE, this.name, !1),
@@ -4650,7 +4679,7 @@ class Qg extends v {
4650
4679
  blocks: []
4651
4680
  });
4652
4681
  } catch (A) {
4653
- throw this.dispatch(i(r)), this.dispatch(en(d)), this.dispatch(Wt(c)), this.dispatch(Ft(h)), this.dispatch(wt(l)), this.dispatch(St(y)), A;
4682
+ throw this.dispatch(i(r)), this.dispatch(en(d)), this.dispatch(Wt(c)), this.dispatch(Ft(h)), this.dispatch(wt(l)), this.dispatch(ft(y)), A;
4654
4683
  }
4655
4684
  }
4656
4685
  bulkAdd(e, i) {
@@ -4693,7 +4722,7 @@ class Qg extends v {
4693
4722
  throw new Error(
4694
4723
  `Attempting to bulk update ${r.length - d.length} assets that dont exist in the store`
4695
4724
  );
4696
- const c = d.toSorted(ft), h = e.toSorted(ft), l = [];
4725
+ const c = d.toSorted(yt), h = e.toSorted(yt), l = [];
4697
4726
  for (let O = 0; O < r.length; O++)
4698
4727
  l.push({
4699
4728
  ...c[O],
@@ -4723,7 +4752,7 @@ class Qg extends v {
4723
4752
  }
4724
4753
  async bulkDelete(e) {
4725
4754
  const { addMany: i, deleteMany: n } = this.actions, { selectByIds: a } = this.selectors, r = this.select(a(e)), d = this.select(md(e)), c = this.select(tm(e)), h = this.select(XA(e)), l = this.select(gp(e));
4726
- this.dispatch(n(e)), this.dispatch(Kt(E(d))), this.dispatch(gt(E(c))), this.dispatch(Rt(E(h))), this.dispatch(Ot(E(l)));
4755
+ this.dispatch(n(e)), this.dispatch(Kt(E(d))), this.dispatch(gt(E(c))), this.dispatch(Rt(E(h))), this.dispatch(St(E(l)));
4727
4756
  try {
4728
4757
  return await this.enqueueRequest({
4729
4758
  description: S(u.DELETE, this.name, !0),
@@ -4734,7 +4763,7 @@ class Qg extends v {
4734
4763
  blocks: []
4735
4764
  });
4736
4765
  } catch (y) {
4737
- throw this.dispatch(i(r)), this.dispatch(Wt(d)), this.dispatch(Ft(c)), this.dispatch(wt(h)), this.dispatch(St(l)), y;
4766
+ throw this.dispatch(i(r)), this.dispatch(Wt(d)), this.dispatch(Ft(c)), this.dispatch(wt(h)), this.dispatch(ft(l)), y;
4738
4767
  }
4739
4768
  }
4740
4769
  async refreshStore(e, i) {
@@ -5351,13 +5380,13 @@ class aw extends v {
5351
5380
  created_by: c
5352
5381
  });
5353
5382
  y.push(V);
5354
- const $ = {
5383
+ const j = {
5355
5384
  uuid: V.uuid,
5356
5385
  asset: V.asset,
5357
5386
  asset_type_identifier: V.asset_type_identifier,
5358
5387
  value: V.value
5359
5388
  };
5360
- w.push($), g.push(V.asset), g.push(V.asset_type_identifier), B.push(V.uuid);
5389
+ w.push(j), g.push(V.asset), g.push(V.asset_type_identifier), B.push(V.uuid);
5361
5390
  }
5362
5391
  const k = {
5363
5392
  payloads: w,
@@ -5821,7 +5850,7 @@ class ow extends v {
5821
5850
  return this.dispatch(n(c)), c;
5822
5851
  }
5823
5852
  }
5824
- class Pt extends bt {
5853
+ class bt extends It {
5825
5854
  async get(s, e) {
5826
5855
  return this.performRequest(
5827
5856
  {
@@ -5848,7 +5877,7 @@ class Pt extends bt {
5848
5877
  );
5849
5878
  }
5850
5879
  }
5851
- class lw extends Pt {
5880
+ class lw extends bt {
5852
5881
  constructor() {
5853
5882
  super(...arguments);
5854
5883
  o(this, "name", "Email Domains");
@@ -5906,7 +5935,7 @@ class lw extends Pt {
5906
5935
  return this.dispatch(n(a)), a;
5907
5936
  }
5908
5937
  }
5909
- class hw extends bt {
5938
+ class hw extends It {
5910
5939
  async getVerificationCode(s) {
5911
5940
  return this.enqueueRequest({
5912
5941
  description: "Get verification code",
@@ -5930,7 +5959,7 @@ class hw extends bt {
5930
5959
  }
5931
5960
  }
5932
5961
  const _t = {}, Lt = /* @__PURE__ */ new Set(), Nt = /* @__PURE__ */ new Set();
5933
- class pw extends bt {
5962
+ class pw extends It {
5934
5963
  constructor() {
5935
5964
  super(...arguments);
5936
5965
  o(this, "host");
@@ -6454,7 +6483,7 @@ class Ow extends v {
6454
6483
  if (!r)
6455
6484
  throw new Error("Expected form to exist");
6456
6485
  const d = this.select(Pp(e)), c = this.select(Oh(e)), h = this.select(Eh(e));
6457
- this.dispatch(i(e)), this.dispatch(Ot(E(d))), this.dispatch($n(E(c))), this.dispatch(Un(E(h)));
6486
+ this.dispatch(i(e)), this.dispatch(St(E(d))), this.dispatch($n(E(c))), this.dispatch(Un(E(h)));
6458
6487
  try {
6459
6488
  return await this.enqueueRequest({
6460
6489
  description: S(u.DELETE, this.name, !1),
@@ -6464,7 +6493,7 @@ class Ow extends v {
6464
6493
  blocks: []
6465
6494
  });
6466
6495
  } catch (l) {
6467
- throw this.dispatch(n(r)), this.dispatch(jn(c)), this.dispatch(St(d)), this.dispatch(Cn(h)), l;
6496
+ throw this.dispatch(n(r)), this.dispatch(jn(c)), this.dispatch(ft(d)), this.dispatch(Cn(h)), l;
6468
6497
  }
6469
6498
  }
6470
6499
  async refreshStore(e, i) {
@@ -6679,7 +6708,7 @@ class Iw extends v {
6679
6708
  });
6680
6709
  }
6681
6710
  add(e) {
6682
- const { addOne: i, setOne: n, deleteOne: a } = this.actions, r = this.select((l) => {
6711
+ const { addOne: i, updateOne: n, deleteOne: a } = this.actions, r = this.select((l) => {
6683
6712
  var y;
6684
6713
  return ((y = l.userReducer.currentUser) == null ? void 0 : y.id) ?? null;
6685
6714
  }), d = (/* @__PURE__ */ new Date()).toISOString(), c = I({
@@ -6733,13 +6762,13 @@ class bw extends v {
6733
6762
  o(this, "url", "/form-submissions");
6734
6763
  o(this, "actions", {
6735
6764
  addOne: fp,
6736
- addMany: St,
6765
+ addMany: ft,
6737
6766
  setOne: mp,
6738
6767
  setMany: yp,
6739
6768
  updateOne: Sp,
6740
6769
  updateMany: Op,
6741
6770
  deleteOne: Ap,
6742
- deleteMany: Ot,
6771
+ deleteMany: St,
6743
6772
  initialize: pp
6744
6773
  });
6745
6774
  o(this, "selectors", {
@@ -7415,7 +7444,7 @@ class ww extends v {
7415
7444
  throw new Error(
7416
7445
  `Attempting to bulk update ${r.length - d.length} issues that dont exist in the store`
7417
7446
  );
7418
- const c = d.toSorted(ft), h = e.toSorted(ft), l = [];
7447
+ const c = d.toSorted(yt), h = e.toSorted(yt), l = [];
7419
7448
  for (let O = 0; O < r.length; O++)
7420
7449
  l.push({
7421
7450
  ...c[O],
@@ -7448,7 +7477,7 @@ class ww extends v {
7448
7477
  if (!r)
7449
7478
  throw new Error(`No issue with uuid ${e} found in the store`);
7450
7479
  const d = this.select(Qp(e)), c = this.select(lm(e)), h = this.select(MS(e)), l = this.select(_p(e));
7451
- this.dispatch(i(e)), this.dispatch(ar(E(c))), this.dispatch(xr(E(h))), this.dispatch(gt(E(d))), this.dispatch(Ot(E(l)));
7480
+ this.dispatch(i(e)), this.dispatch(ar(E(c))), this.dispatch(xr(E(h))), this.dispatch(gt(E(d))), this.dispatch(St(E(l)));
7452
7481
  try {
7453
7482
  return await this.enqueueRequest({
7454
7483
  description: S(u.DELETE, this.name, !1),
@@ -7458,12 +7487,12 @@ class ww extends v {
7458
7487
  blocks: []
7459
7488
  });
7460
7489
  } catch (y) {
7461
- throw this.dispatch(n(r)), this.dispatch(rr(c)), this.dispatch(jr(h)), this.dispatch(Ft(d)), this.dispatch(St(l)), y;
7490
+ throw this.dispatch(n(r)), this.dispatch(rr(c)), this.dispatch(jr(h)), this.dispatch(Ft(d)), this.dispatch(ft(l)), y;
7462
7491
  }
7463
7492
  }
7464
7493
  async bulkDelete(e) {
7465
7494
  const { addMany: i, deleteMany: n } = this.actions, { selectByIds: a } = this.selectors, r = this.select(a(e)), d = this.select(Xp(e)), c = this.select(Mp(e));
7466
- this.dispatch(n(e)), this.dispatch(gt(E(d))), this.dispatch(Ot(E(c)));
7495
+ this.dispatch(n(e)), this.dispatch(gt(E(d))), this.dispatch(St(E(c)));
7467
7496
  try {
7468
7497
  return await this.enqueueRequest({
7469
7498
  description: S(u.DELETE, this.name, !0),
@@ -7474,7 +7503,7 @@ class ww extends v {
7474
7503
  blocks: []
7475
7504
  });
7476
7505
  } catch (h) {
7477
- throw this.dispatch(i(r)), this.dispatch(Ft(d)), this.dispatch(St(c)), h;
7506
+ throw this.dispatch(i(r)), this.dispatch(Ft(d)), this.dispatch(ft(c)), h;
7478
7507
  }
7479
7508
  }
7480
7509
  async refreshStore(e, i) {
@@ -8495,7 +8524,7 @@ class xw extends eM {
8495
8524
  });
8496
8525
  }
8497
8526
  }
8498
- class Cw extends Pt {
8527
+ class Cw extends bt {
8499
8528
  constructor() {
8500
8529
  super(...arguments);
8501
8530
  o(this, "name", "Organization Access");
@@ -8564,7 +8593,7 @@ class Cw extends Pt {
8564
8593
  return this.dispatch(n(a)), a;
8565
8594
  }
8566
8595
  }
8567
- class Uw extends Pt {
8596
+ class Uw extends bt {
8568
8597
  constructor() {
8569
8598
  super(...arguments);
8570
8599
  o(this, "name", "Organization");
@@ -9000,7 +9029,7 @@ class Gw extends q {
9000
9029
  return this.dispatch(n(r)), r;
9001
9030
  }
9002
9031
  }
9003
- class Ww extends Pt {
9032
+ class Ww extends bt {
9004
9033
  constructor() {
9005
9034
  super(...arguments);
9006
9035
  o(this, "name", "Project");
@@ -9115,17 +9144,17 @@ class Kw extends v {
9115
9144
  for (const w of y) {
9116
9145
  const g = [], B = [], k = [];
9117
9146
  for (const V of w) {
9118
- const $ = I({
9147
+ const j = I({
9119
9148
  ...V,
9120
9149
  submitted_at: c,
9121
9150
  created_by: h
9122
9151
  });
9123
- l.push($), g.push(R($)), B.push(
9124
- $.procedure_type,
9125
- $.project,
9126
- $.asset,
9127
- ...$.procedure_initiative ? [$.procedure_initiative] : []
9128
- ), k.push($.uuid);
9152
+ l.push(j), g.push(R(j)), B.push(
9153
+ j.procedure_type,
9154
+ j.project,
9155
+ j.asset,
9156
+ ...j.procedure_initiative ? [j.procedure_initiative] : []
9157
+ ), k.push(j.uuid);
9129
9158
  }
9130
9159
  const D = {
9131
9160
  payload: {
@@ -9590,7 +9619,7 @@ class Xw extends v {
9590
9619
  return this.dispatch(n(a)), a;
9591
9620
  }
9592
9621
  }
9593
- class Qw extends Pt {
9622
+ class Qw extends bt {
9594
9623
  constructor() {
9595
9624
  super(...arguments);
9596
9625
  o(this, "name", "Procedure Step Event");
@@ -10421,7 +10450,7 @@ class cR extends v {
10421
10450
  throw new Error(
10422
10451
  `Attempting to bulk update ${r.length - d.length} ${this.name} that dont exist in the store`
10423
10452
  );
10424
- const c = d.toSorted(ft), h = e.toSorted(ft), l = [];
10453
+ const c = d.toSorted(yt), h = e.toSorted(yt), l = [];
10425
10454
  for (let O = 0; O < r.length; O++)
10426
10455
  l.push({
10427
10456
  ...c[O],
@@ -11190,7 +11219,7 @@ class yR extends v {
11190
11219
  return this.dispatch(n(a)), a;
11191
11220
  }
11192
11221
  }
11193
- class fR extends Pt {
11222
+ class fR extends bt {
11194
11223
  constructor() {
11195
11224
  super(...arguments);
11196
11225
  o(this, "name", "User");
@@ -11233,7 +11262,7 @@ class fR extends Pt {
11233
11262
  }
11234
11263
  }
11235
11264
  async function Za(t, s, e, i, n) {
11236
- const a = i instanceof bt;
11265
+ const a = i instanceof It;
11237
11266
  a && s.checkAuth !== !1 && await i.auth.prepareAuth();
11238
11267
  const r = {
11239
11268
  queryParams: "",
@@ -11261,54 +11290,55 @@ async function Za(t, s, e, i, n) {
11261
11290
  throw new Error(`Cannot upload file ${A} because its has a size of 0.`);
11262
11291
  }
11263
11292
  !F && !g.startsWith("http") && (!g.startsWith("/") && !g.startsWith("blob:") && (g = "/" + g), g = t + g);
11264
- const D = (j) => {
11293
+ const D = ($) => {
11265
11294
  if (A) {
11266
11295
  if (!d) throw new Error(`No S3 URL for file ${A}`);
11267
11296
  if ("warning" in d) throw new Error(`S3 URL warning for file ${A}`);
11268
11297
  if (!k) throw new Error(`No file for file ${A}`);
11269
- const L = d.fields["x-amz-checksum-sha1"];
11270
- if (!L) throw new Error(`No checksum for file ${A}`);
11271
- return j.set("x-amz-checksum-sha1", L).field({ ...c, ...d.fields }).attach("file", k);
11298
+ const x = d.fields["x-amz-checksum-sha1"];
11299
+ if (!x) throw new Error(`No checksum for file ${A}`);
11300
+ return $.set("x-amz-checksum-sha1", x).field({ ...c, ...d.fields }).attach("file", k);
11272
11301
  }
11273
- return j.send(c);
11274
- }, $ = {
11275
- [u.GET]: () => w ? mt.get(g.toString()).responseType("blob") : mt.get(g.toString()),
11302
+ return $.send(c);
11303
+ }, j = {
11304
+ [u.GET]: () => w ? pt.get(g.toString()).responseType("blob") : pt.get(g.toString()),
11276
11305
  [u.POST]: () => {
11277
- const j = mt.post(g.toString());
11278
- return D(j);
11306
+ const $ = pt.post(g.toString());
11307
+ return D($);
11279
11308
  },
11280
11309
  [u.PATCH]: () => {
11281
- const j = mt.patch(g.toString());
11282
- return D(j);
11310
+ const $ = pt.patch(g.toString());
11311
+ return D($);
11283
11312
  },
11284
11313
  [u.PUT]: () => {
11285
- const j = mt.put(g.toString());
11286
- return D(j);
11314
+ const $ = pt.put(g.toString());
11315
+ return D($);
11287
11316
  },
11288
11317
  [u.DELETE]: () => {
11289
- const j = mt.delete(g.toString());
11290
- return D(j);
11318
+ const $ = pt.delete(g.toString());
11319
+ return D($);
11291
11320
  }
11292
11321
  }[l];
11293
- let x = $();
11322
+ let L = j();
11294
11323
  const zt = () => {
11295
- console.debug("aborting request:", s.url), x.abort();
11324
+ console.debug("aborting request:", s.url), L.abort();
11296
11325
  };
11297
- if (n == null || n.addEventListener("abort", zt), O && a) {
11298
- const j = i.auth.getAuthHeader();
11299
- x = x.set("Authorization", j);
11300
- }
11301
- h && (x = x.set(h));
11326
+ n == null || n.addEventListener("abort", zt), O && a && (L = i.auth.applyAuth(L)), h && (L = L.set(h));
11302
11327
  try {
11303
- return await x.query(y);
11304
- } catch (j) {
11305
- const L = Q_(j), ht = L == null ? void 0 : L.status;
11306
- if (a && ht === 401)
11307
- return await i.auth.handleUnauthorized(x, L), x.query(y);
11308
- throw new U({
11309
- response: L,
11310
- innerError: j,
11311
- discard: Ka.includes(ht)
11328
+ return await L.query(y);
11329
+ } catch ($) {
11330
+ const x = Q_($), Pt = x == null ? void 0 : x.status;
11331
+ throw a && x && i.auth.isAuthFailure(x) ? (await i.auth.handleUnauthorized(L, x), new U({
11332
+ response: x,
11333
+ innerError: $,
11334
+ // NOT `DISCARD_HTTP_STATUSES.includes(status)`. A CSRF failure is a 403, which is in that list,
11335
+ // so computing it would discard the request the auth service just repaired -- silent data loss on a
11336
+ // stale CSRF token. An auth failure the auth service handled is by definition retryable.
11337
+ discard: !1
11338
+ })) : new U({
11339
+ response: x,
11340
+ innerError: $,
11341
+ discard: Ka.includes(Pt)
11312
11342
  });
11313
11343
  } finally {
11314
11344
  n == null || n.removeEventListener("abort", zt);
@@ -11556,7 +11586,7 @@ function rM() {
11556
11586
  return Qa;
11557
11587
  }
11558
11588
  let Ht = null;
11559
- function yt() {
11589
+ function mt() {
11560
11590
  const t = kt();
11561
11591
  if (!t)
11562
11592
  return console.warn("Client store not set; cannot get outbox coordinator yet."), null;
@@ -11638,8 +11668,9 @@ export {
11638
11668
  aw as AssetTypeIdentifierValueService,
11639
11669
  cw as AssetTypeService,
11640
11670
  dw as AssetTypeStatusService,
11641
- bt as BaseApiService,
11642
- Pt as BaseModelApiService,
11671
+ It as BaseApiService,
11672
+ eM as BaseAuthService,
11673
+ bt as BaseModelApiService,
11643
11674
  q as BaseOfflineFileModelApiService,
11644
11675
  v as BaseOfflineModelApiService,
11645
11676
  SR as BaseSDK,
@@ -11777,7 +11808,7 @@ export {
11777
11808
  Gh as addFormSubmissionFieldValuesAttachment,
11778
11809
  Gn as addFormSubmissionFieldValuesAttachments,
11779
11810
  Zn as addFormSubmissionFieldValuesMany,
11780
- St as addFormSubmissions,
11811
+ ft as addFormSubmissions,
11781
11812
  Ih as addFormSubscriber,
11782
11813
  Cn as addFormSubscribers,
11783
11814
  zh as addForms,
@@ -11958,7 +11989,7 @@ export {
11958
11989
  Zh as deleteFormSubmissionFieldValuesAttachment,
11959
11990
  Wn as deleteFormSubmissionFieldValuesAttachments,
11960
11991
  Xn as deleteFormSubmissionFieldValuesMany,
11961
- Ot as deleteFormSubmissions,
11992
+ St as deleteFormSubmissions,
11962
11993
  Fh as deleteFormSubscriber,
11963
11994
  Un as deleteFormSubscribers,
11964
11995
  xh as deleteForms,
@@ -12100,7 +12131,7 @@ export {
12100
12131
  gc as getFileExtension,
12101
12132
  bc as getLocalDateString,
12102
12133
  zM as getLocalRelativeDateString,
12103
- yt as getOutboxCoordinator,
12134
+ mt as getOutboxCoordinator,
12104
12135
  kc as getPresignedUrlExpiryDate,
12105
12136
  DM as getRenamedFile,
12106
12137
  S as getRequestDescription,
@@ -12597,7 +12628,7 @@ export {
12597
12628
  Og as selectProcedureStepEventsOfProcedure,
12598
12629
  Tg as selectProcedureStepEventsOfProcedureAndProcedureStep,
12599
12630
  Ag as selectProcedureStepEventsOfProcedureStep,
12600
- Tt as selectProcedureStepFieldValues,
12631
+ At as selectProcedureStepFieldValues,
12601
12632
  LI as selectProcedureStepFieldValuesAttachmentById,
12602
12633
  Ia as selectProcedureStepFieldValuesAttachments,
12603
12634
  NI as selectProcedureStepFieldValuesAttachmentsByIds,
@@ -12609,7 +12640,7 @@ export {
12609
12640
  Fg as selectProcedureStepFieldValuesOfProcedureAndProcedureStep,
12610
12641
  Mg as selectProcedureStepFieldValuesOfProcedureStep,
12611
12642
  mb as selectProcedureStepFieldValuesReviewById,
12612
- It as selectProcedureStepFieldValuesReviews,
12643
+ Tt as selectProcedureStepFieldValuesReviews,
12613
12644
  yb as selectProcedureStepFieldValuesReviewsByIds,
12614
12645
  pb as selectProcedureStepFieldValuesReviewsMapping,
12615
12646
  wg as selectProcedureStepFieldValuesReviewsOfProcedure,
@@ -12653,7 +12684,7 @@ export {
12653
12684
  l_ as selectProcedureTypesByIds,
12654
12685
  u_ as selectProcedureTypesMapping,
12655
12686
  Cg as selectProcedureTypesOfOrganization,
12656
- At as selectProcedures,
12687
+ Ot as selectProcedures,
12657
12688
  YA as selectProceduresByIds,
12658
12689
  WA as selectProceduresMapping,
12659
12690
  ZA as selectProceduresOfAsset,
@@ -13013,6 +13044,6 @@ export {
13013
13044
  zS as userReducer,
13014
13045
  Lr as userSlice,
13015
13046
  I as uuidObj,
13016
- ft as uuidObjSortFn,
13047
+ yt as uuidObjSortFn,
13017
13048
  Vc as uuidSortFn
13018
13049
  };