@overmap-ai/core 1.0.71-mapbox.4 → 1.0.71-mapbox.6

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.
Files changed (132) hide show
  1. package/dist/constants/defaults.d.ts +2 -1
  2. package/dist/constants/index.d.ts +3 -3
  3. package/dist/enums/index.d.ts +5 -5
  4. package/dist/index.d.ts +6 -6
  5. package/dist/overmap-core.js +168 -305
  6. package/dist/overmap-core.js.map +1 -1
  7. package/dist/overmap-core.umd.cjs +177 -313
  8. package/dist/overmap-core.umd.cjs.map +1 -1
  9. package/dist/sdk/base.d.ts +8 -6
  10. package/dist/sdk/classes/OutboxCoordinator.d.ts +4 -4
  11. package/dist/sdk/classes/index.d.ts +1 -1
  12. package/dist/sdk/errors.d.ts +3 -1
  13. package/dist/sdk/globals.d.ts +7 -5
  14. package/dist/sdk/index.d.ts +6 -6
  15. package/dist/sdk/sdk.d.ts +6 -5
  16. package/dist/sdk/services/AgentService.d.ts +4 -3
  17. package/dist/sdk/services/AssetAttachmentService.d.ts +13 -12
  18. package/dist/sdk/services/AssetService.d.ts +5 -4
  19. package/dist/sdk/services/AssetStageCompletionService.d.ts +5 -4
  20. package/dist/sdk/services/AssetStageService.d.ts +5 -4
  21. package/dist/sdk/services/AssetTypeAttachmentService.d.ts +13 -12
  22. package/dist/sdk/services/AssetTypeService.d.ts +5 -4
  23. package/dist/sdk/services/BaseApiService.d.ts +5 -4
  24. package/dist/sdk/services/BaseAttachmentService.d.ts +7 -6
  25. package/dist/sdk/services/BaseAuthService.d.ts +5 -4
  26. package/dist/sdk/services/BaseService.d.ts +7 -5
  27. package/dist/sdk/services/BaseUploadService.d.ts +5 -4
  28. package/dist/sdk/services/CategoryService.d.ts +5 -4
  29. package/dist/sdk/services/DocumentAttachmentService.d.ts +13 -12
  30. package/dist/sdk/services/DocumentService.d.ts +5 -4
  31. package/dist/sdk/services/EmailDomainsService.d.ts +4 -3
  32. package/dist/sdk/services/EmailVerificationService.d.ts +4 -3
  33. package/dist/sdk/services/FileService.d.ts +5 -4
  34. package/dist/sdk/services/FormService.d.ts +5 -4
  35. package/dist/sdk/services/FormSubmissionService.d.ts +6 -5
  36. package/dist/sdk/services/GeoImageService.d.ts +5 -4
  37. package/dist/sdk/services/IssueAssociationService.d.ts +5 -4
  38. package/dist/sdk/services/IssueAttachmentService.d.ts +13 -12
  39. package/dist/sdk/services/IssueCommentService.d.ts +5 -4
  40. package/dist/sdk/services/IssueService.d.ts +5 -4
  41. package/dist/sdk/services/IssueTypeService.d.ts +5 -4
  42. package/dist/sdk/services/IssueUpdateService.d.ts +4 -3
  43. package/dist/sdk/services/JWTAuthService.d.ts +7 -6
  44. package/dist/sdk/services/LicenseService.d.ts +4 -3
  45. package/dist/sdk/services/OrganizationAccessService.d.ts +4 -3
  46. package/dist/sdk/services/OrganizationService.d.ts +4 -3
  47. package/dist/sdk/services/ProjectAccessService.d.ts +4 -3
  48. package/dist/sdk/services/ProjectAttachmentService.d.ts +13 -12
  49. package/dist/sdk/services/ProjectFileService.d.ts +5 -4
  50. package/dist/sdk/services/ProjectService.d.ts +4 -3
  51. package/dist/sdk/services/TeamService.d.ts +5 -4
  52. package/dist/sdk/services/UserService.d.ts +4 -3
  53. package/dist/sdk/services/WorkspaceService.d.ts +5 -4
  54. package/dist/sdk/services/index.d.ts +34 -34
  55. package/dist/sdk/typings.d.ts +9 -8
  56. package/dist/store/adapter.d.ts +12 -11
  57. package/dist/store/index.d.ts +2 -2
  58. package/dist/store/migrations.d.ts +2 -1
  59. package/dist/store/slices/agentsSlice.d.ts +11 -10
  60. package/dist/store/slices/assetAttachmentSlice.d.ts +16 -21
  61. package/dist/store/slices/assetSlice.d.ts +35 -24
  62. package/dist/store/slices/assetStageCompletionSlice.d.ts +33 -22
  63. package/dist/store/slices/assetStageSlice.d.ts +36 -25
  64. package/dist/store/slices/assetTypeAttachmentSlice.d.ts +16 -21
  65. package/dist/store/slices/assetTypeSlice.d.ts +16 -21
  66. package/dist/store/slices/authSlice.d.ts +10 -9
  67. package/dist/store/slices/categorySlice.d.ts +30 -16
  68. package/dist/store/slices/documentAttachmentSlice.d.ts +16 -21
  69. package/dist/store/slices/documentSlice.d.ts +30 -13
  70. package/dist/store/slices/emailDomainsSlice.d.ts +29 -15
  71. package/dist/store/slices/fileSlice.d.ts +7 -6
  72. package/dist/store/slices/formRevisionAttachmentSlice.d.ts +16 -21
  73. package/dist/store/slices/formRevisionSlice.d.ts +37 -26
  74. package/dist/store/slices/formSlice.d.ts +35 -21
  75. package/dist/store/slices/formSubmissionAttachmentSlice.d.ts +16 -21
  76. package/dist/store/slices/formSubmissionSlice.d.ts +16 -21
  77. package/dist/store/slices/geoImageSlice.d.ts +35 -24
  78. package/dist/store/slices/index.d.ts +38 -38
  79. package/dist/store/slices/issueAssociationSlice.d.ts +35 -24
  80. package/dist/store/slices/issueAttachmentSlice.d.ts +16 -21
  81. package/dist/store/slices/issueCommentSlice.d.ts +13 -18
  82. package/dist/store/slices/issueSlice.d.ts +13 -18
  83. package/dist/store/slices/issueTypeSlice.d.ts +12 -14
  84. package/dist/store/slices/issueUpdateSlice.d.ts +13 -18
  85. package/dist/store/slices/licenseSlice.d.ts +10 -9
  86. package/dist/store/slices/organizationAccessSlice.d.ts +11 -13
  87. package/dist/store/slices/organizationSlice.d.ts +27 -10
  88. package/dist/store/slices/outboxSlice.d.ts +15 -15
  89. package/dist/store/slices/projectAccessSlice.d.ts +11 -16
  90. package/dist/store/slices/projectAttachmentSlice.d.ts +16 -21
  91. package/dist/store/slices/projectFileSlice.d.ts +61 -30
  92. package/dist/store/slices/projectSlice.d.ts +10 -9
  93. package/dist/store/slices/rehydratedSlice.d.ts +7 -6
  94. package/dist/store/slices/teamSlice.d.ts +12 -14
  95. package/dist/store/slices/userSlice.d.ts +14 -13
  96. package/dist/store/slices/versioningSlice.d.ts +3 -2
  97. package/dist/store/slices/workspaceSlice.d.ts +31 -17
  98. package/dist/store/store.d.ts +7 -7
  99. package/dist/typings/index.d.ts +6 -6
  100. package/dist/typings/models/access.d.ts +3 -2
  101. package/dist/typings/models/agents.d.ts +3 -2
  102. package/dist/typings/models/assets.d.ts +3 -2
  103. package/dist/typings/models/attachments.d.ts +3 -2
  104. package/dist/typings/models/base.d.ts +3 -2
  105. package/dist/typings/models/categories.d.ts +3 -2
  106. package/dist/typings/models/documents.d.ts +2 -1
  107. package/dist/typings/models/emailDomain.d.ts +2 -1
  108. package/dist/typings/models/emailVerification.d.ts +3 -2
  109. package/dist/typings/models/forms.d.ts +4 -3
  110. package/dist/typings/models/geo.d.ts +2 -1
  111. package/dist/typings/models/geoImages.d.ts +4 -3
  112. package/dist/typings/models/index.d.ts +21 -21
  113. package/dist/typings/models/issueTypes.d.ts +3 -2
  114. package/dist/typings/models/issues.d.ts +7 -6
  115. package/dist/typings/models/license.d.ts +3 -2
  116. package/dist/typings/models/organizations.d.ts +2 -1
  117. package/dist/typings/models/projects.d.ts +4 -3
  118. package/dist/typings/models/store.d.ts +3 -3
  119. package/dist/typings/models/teams.d.ts +4 -3
  120. package/dist/typings/models/users.d.ts +2 -1
  121. package/dist/typings/models/workspace.d.ts +2 -1
  122. package/dist/typings/search.d.ts +1 -1
  123. package/dist/typings/store.d.ts +2 -1
  124. package/dist/utils/async/DeferredPromise.d.ts +1 -1
  125. package/dist/utils/colors.d.ts +2 -1
  126. package/dist/utils/coordinates.d.ts +2 -1
  127. package/dist/utils/file.d.ts +2 -1
  128. package/dist/utils/forms.d.ts +2 -1
  129. package/dist/utils/index.d.ts +10 -10
  130. package/dist/utils/offline.d.ts +2 -1
  131. package/dist/utils/utils.d.ts +2 -1
  132. package/package.json +20 -21
@@ -1,25 +1,21 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  var _a;
8
5
  import { DepGraph } from "dependency-graph";
9
6
  import { v4 } from "uuid";
10
7
  import { saveAs } from "file-saver";
11
8
  import ColorCls from "color";
12
- import { gray, gold, brown, yellow, amber, orange, red, crimson, pink, plum, purple, violet, iris, indigo, blue, cyan, jade, grass, lime, mint, sky } from "@radix-ui/colors";
9
+ import { sky, mint, lime, grass, jade, cyan, blue, indigo, iris, violet, purple, plum, pink, crimson, red, orange, amber, yellow, brown, gold, gray } from "@radix-ui/colors";
10
+ import { createSlice, createSelector, combineReducers, compose } from "@reduxjs/toolkit";
13
11
  import { offline as offline$1 } from "@redux-offline/redux-offline";
14
12
  import offlineConfig from "@redux-offline/redux-offline/lib/defaults";
15
13
  import localforage from "localforage";
16
14
  import createMigration from "redux-persist-migrate";
17
- import { createSlice, createSelector, combineReducers } from "@reduxjs/toolkit";
18
15
  import request from "superagent";
19
16
  import { RESET_STATE } from "@redux-offline/redux-offline/lib/constants";
20
17
  import jwtDecode from "jwt-decode";
21
18
  import { openDB } from "idb";
22
- import { unsafeShowToast } from "@overmap-ai/blocks";
23
19
  var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
24
20
  HttpMethod2["GET"] = "GET";
25
21
  HttpMethod2["POST"] = "POST";
@@ -153,8 +149,7 @@ class OutboxCoordinator {
153
149
  return;
154
150
  }
155
151
  for (const node of this.graph.overallOrder()) {
156
- if (node === request2.payload.uuid)
157
- continue;
152
+ if (node === request2.payload.uuid) continue;
158
153
  const details = this.graph.getNodeData(node);
159
154
  if (request2.payload.blockers.some((blocker) => details.payload.blocks.includes(blocker))) {
160
155
  this._addDependency(request2.payload.uuid, node);
@@ -171,8 +166,7 @@ class OutboxCoordinator {
171
166
  insertRequest(request2) {
172
167
  this.graph.addNode(request2.payload.uuid, request2);
173
168
  for (const node of this.graph.overallOrder()) {
174
- if (node === request2.payload.uuid)
175
- continue;
169
+ if (node === request2.payload.uuid) continue;
176
170
  const details = this.graph.getNodeData(node);
177
171
  if (details.payload.blockers.some((blocker) => request2.payload.blocks.includes(blocker))) {
178
172
  this._addDependency(node, request2.payload.uuid);
@@ -208,8 +202,7 @@ class OutboxCoordinator {
208
202
  */
209
203
  peek() {
210
204
  const nextNode = this._getNextNode();
211
- if (!nextNode)
212
- return void 0;
205
+ if (!nextNode) return void 0;
213
206
  return this.graph.getNodeData(nextNode);
214
207
  }
215
208
  /**
@@ -281,17 +274,15 @@ function extractErrorMessage(errorRes, err) {
281
274
  ret = responseBody.error;
282
275
  } else if (typeof responseBody.message === "string") {
283
276
  ret = responseBody.message;
284
- } else if (responseBody.body) {
277
+ } else {
285
278
  try {
286
- ret = Object.entries(responseBody.body).map(([key, value]) => {
279
+ ret = Object.entries(responseBody).map(([key, value]) => {
287
280
  if (typeof value === "string") {
288
- if (_SPECIAL_KEYS.includes(key))
289
- return value;
281
+ if (_SPECIAL_KEYS.includes(key)) return value;
290
282
  return `${key}: ${value}`;
291
283
  }
292
284
  if (Array.isArray(value)) {
293
- if (_SPECIAL_KEYS.includes(key))
294
- return value.join("\n");
285
+ if (_SPECIAL_KEYS.includes(key)) return value.join("\n");
295
286
  return value.map((v) => `${key}: ${v}`).join("\n");
296
287
  }
297
288
  return `${key}: ${JSON.stringify(value)}`;
@@ -367,7 +358,7 @@ function hashFile(file) {
367
358
  reader.onload = () => {
368
359
  const fileResult = reader.result;
369
360
  if (!fileResult) {
370
- reject();
361
+ reject(new Error("FileReader did not return a valid ArrayBuffer."));
371
362
  return;
372
363
  }
373
364
  void crypto.subtle.digest("SHA-1", fileResult).then((hash) => {
@@ -381,8 +372,7 @@ function hashFile(file) {
381
372
  function getFileIdentifier(file) {
382
373
  if (!file.name || !file.type || !file.size) {
383
374
  const message = "File has no name, type, and/or size";
384
- console.error(`${message}`, file);
385
- throw new Error(`${message}.`);
375
+ throw new Error(message);
386
376
  }
387
377
  return `${file.name}&${file.type}${file.size}`;
388
378
  }
@@ -502,21 +492,19 @@ const OUTBOX_RETRY_DELAY = 6e4;
502
492
  const EMPTY_ARRAY = Object.freeze([]);
503
493
  const EMPTY_OBJECT = Object.freeze({});
504
494
  let debug = false;
505
- const REACT_APP_DEBUG_MEMOIZATION = {}.REACT_APP_DEBUG_MEMOIZATION || "";
495
+ const REACT_APP_DEBUG_MEMOIZATION = "";
506
496
  if (["true", "1"].includes(REACT_APP_DEBUG_MEMOIZATION.toLowerCase())) {
507
497
  debug = true;
508
498
  }
509
499
  function shallowEqual(objA, objB) {
510
- if (objA === objB)
511
- return true;
500
+ if (objA === objB) return true;
512
501
  if (typeof objA !== typeof objB) {
513
502
  return false;
514
503
  }
515
504
  const keysA = Object.keys(objA);
516
505
  const keysB = Object.keys(objB);
517
506
  const keysALength = keysA.length;
518
- if (keysALength !== keysB.length)
519
- return false;
507
+ if (keysALength !== keysB.length) return false;
520
508
  for (let i = 0; i < keysALength; i++) {
521
509
  const key = keysA[i];
522
510
  if (!Object.prototype.hasOwnProperty.call(objB, key) || objA[key] !== objB[key]) {
@@ -543,11 +531,9 @@ function memoize(func) {
543
531
  };
544
532
  }
545
533
  function areArraysEqual(first, second) {
546
- if (first.length !== second.length)
547
- return false;
534
+ if (first.length !== second.length) return false;
548
535
  for (let i = 0; i < first.length; i++) {
549
- if (first[i] !== second[i])
550
- return false;
536
+ if (first[i] !== second[i]) return false;
551
537
  }
552
538
  return true;
553
539
  }
@@ -595,13 +581,11 @@ const generateBadgeColors = (rawColor) => {
595
581
  return { backgroundColor, textColor };
596
582
  };
597
583
  const getLocalDateString = memoize((date) => {
598
- if (!date)
599
- return "";
584
+ if (!date) return "";
600
585
  const asDate = new Date(date);
601
586
  const isThisYear = asDate.getFullYear() === today.getFullYear();
602
587
  const options = { day: "numeric", month: "short" };
603
- if (!isThisYear)
604
- options.year = "numeric";
588
+ if (!isThisYear) options.year = "numeric";
605
589
  return asDate.toLocaleDateString([], options);
606
590
  });
607
591
  const relative = new Intl.RelativeTimeFormat([], { style: "long", numeric: "auto" });
@@ -612,10 +596,10 @@ const isToday = (date) => {
612
596
  };
613
597
  const getLocalRelativeDateString = memoize((date, min, max) => {
614
598
  const days = Math.round((new Date(date).getTime() - today.getTime()) / msInDay);
615
- if (days < min || days > max)
616
- return getLocalDateString(date);
599
+ if (days < min || days > max) return getLocalDateString(date);
617
600
  return relative.format(days, "days");
618
601
  });
602
+ _a = Symbol.toStringTag;
619
603
  class DeferredPromise {
620
604
  constructor() {
621
605
  __publicField(this, _a, "Promise");
@@ -640,14 +624,12 @@ class DeferredPromise {
640
624
  return this._promise.catch(onRejected);
641
625
  }
642
626
  resolve(value) {
643
- if (!this._resolve)
644
- throw new Error("No resolve callback");
627
+ if (!this._resolve) throw new Error("No resolve callback");
645
628
  this._resolve(value);
646
629
  this._state = "fulfilled";
647
630
  }
648
631
  reject(reason) {
649
- if (!this._reject)
650
- throw reason;
632
+ if (!this._reject) throw reason;
651
633
  this._reject(reason);
652
634
  this._state = "rejected";
653
635
  }
@@ -655,35 +637,6 @@ class DeferredPromise {
655
637
  throw new Error("`finally` not implemented");
656
638
  }
657
639
  }
658
- _a = Symbol.toStringTag;
659
- var randomString = function randomString2() {
660
- return Math.random().toString(36).substring(7).split("").join(".");
661
- };
662
- ({
663
- INIT: "@@redux/INIT" + randomString(),
664
- REPLACE: "@@redux/REPLACE" + randomString(),
665
- PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
666
- return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
667
- }
668
- });
669
- function compose() {
670
- for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
671
- funcs[_key] = arguments[_key];
672
- }
673
- if (funcs.length === 0) {
674
- return function(arg) {
675
- return arg;
676
- };
677
- }
678
- if (funcs.length === 1) {
679
- return funcs[0];
680
- }
681
- return funcs.reduce(function(a, b) {
682
- return function() {
683
- return a(b.apply(void 0, arguments));
684
- };
685
- });
686
- }
687
640
  const VERSION_REDUCER_KEY$1 = "versioning";
688
641
  const latestVersion = () => migrations.length - 1;
689
642
  const initialVersioning = (state) => {
@@ -704,8 +657,7 @@ const wrapMigration = (migrator) => (state) => {
704
657
  if (state === void 0) {
705
658
  state = {};
706
659
  }
707
- if (((_a2 = state[VERSION_REDUCER_KEY$1]) == null ? void 0 : _a2.version) === latestVersion())
708
- return state;
660
+ if (((_a2 = state[VERSION_REDUCER_KEY$1]) == null ? void 0 : _a2.version) === latestVersion()) return state;
709
661
  return migrator(state);
710
662
  };
711
663
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
@@ -893,8 +845,7 @@ const selectAssetsByIds = restructureCreateSelectorWithArgs(
893
845
  const assets = [];
894
846
  for (const assetId of assetIds) {
895
847
  const asset = assetsMapping[assetId];
896
- if (asset)
897
- assets.push(asset);
848
+ if (asset) assets.push(asset);
898
849
  }
899
850
  return fallbackToEmptyArray(assets);
900
851
  })
@@ -953,17 +904,13 @@ const selectAttachmentsOfAssetByType = restructureCreateSelectorWithArgs(
953
904
  [selectAssetAttachments, (_state, assetId) => assetId],
954
905
  (attachments, assetId) => {
955
906
  const attachmentsOfAsset = attachments.filter(({ asset }) => assetId === asset);
956
- const fileAttachments = fallbackToEmptyArray(
957
- attachmentsOfAsset.filter(
958
- // this null check here is necessary, there are cases where file_type is null or undefined
959
- ({ file_type }) => !file_type || !file_type.startsWith("image/")
960
- )
907
+ const fileAttachments = attachmentsOfAsset.filter(
908
+ // this null check here is necessary, there are cases where file_type is null or undefined
909
+ ({ file_type }) => !file_type.startsWith("image/")
961
910
  );
962
- const imageAttachments = fallbackToEmptyArray(
963
- attachmentsOfAsset.filter(
964
- // this null check here is necessary, there are cases where file_type is null or undefined
965
- ({ file_type }) => file_type && file_type.startsWith("image/")
966
- )
911
+ const imageAttachments = attachmentsOfAsset.filter(
912
+ // this null check here is necessary, there are cases where file_type is null or undefined
913
+ ({ file_type }) => file_type.startsWith("image/")
967
914
  );
968
915
  return { fileAttachments, imageAttachments };
969
916
  }
@@ -1006,8 +953,7 @@ const selectCompletedStagesByAsset = createSelector(
1006
953
  const completedStagesByAsset = {};
1007
954
  for (const stageCompletion of Object.values(completedStagesMapping)) {
1008
955
  const { asset, stage, submitted_at } = stageCompletion;
1009
- if (!completedStagesByAsset[asset])
1010
- completedStagesByAsset[asset] = {};
956
+ if (!completedStagesByAsset[asset]) completedStagesByAsset[asset] = {};
1011
957
  completedStagesByAsset[asset][stage] = submitted_at;
1012
958
  }
1013
959
  return fallbackToEmptyObject(completedStagesByAsset);
@@ -1223,11 +1169,11 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1223
1169
  const attachmentsOfAssetType = attachments.filter(({ asset_type }) => asset_type === assetTypeId);
1224
1170
  const fileAttachments = attachmentsOfAssetType.filter(
1225
1171
  // this null check here is necessary, there are cases where file_type is null or undefined
1226
- ({ file_type }) => !file_type || !file_type.startsWith("image/")
1172
+ ({ file_type }) => !file_type.startsWith("image/")
1227
1173
  );
1228
1174
  const imageAttachments = attachmentsOfAssetType.filter(
1229
1175
  // this null check here is necessary, there are cases where file_type is null or undefined
1230
- ({ file_type }) => file_type && file_type.startsWith("image/")
1176
+ ({ file_type }) => file_type.startsWith("image/")
1231
1177
  );
1232
1178
  return { fileAttachments, imageAttachments };
1233
1179
  }
@@ -1364,8 +1310,7 @@ const selectUploadUrl = (sha1) => (state) => {
1364
1310
  }
1365
1311
  const today2 = (/* @__PURE__ */ new Date()).getTime();
1366
1312
  const expiringWithinAnHour = (url.exp ?? today2) - today2 < msPerHour;
1367
- if (expiringWithinAnHour)
1368
- return void 0;
1313
+ if (expiringWithinAnHour) return void 0;
1369
1314
  return url;
1370
1315
  };
1371
1316
  const fileReducer = fileSlice.reducer;
@@ -1394,8 +1339,7 @@ const userSlice = createSlice({
1394
1339
  state.currentUser = action.payload;
1395
1340
  },
1396
1341
  setProfilePicture: (state, action) => {
1397
- if (!state.currentUser)
1398
- return;
1342
+ if (!state.currentUser) return;
1399
1343
  state.currentUser.profile.file = action.payload.file ?? null;
1400
1344
  state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1401
1345
  const currentUser = state.users[state.currentUser.id];
@@ -1739,8 +1683,7 @@ const outboxSlice = createSlice({
1739
1683
  },
1740
1684
  markAsDeleted(state, action) {
1741
1685
  const index = state.deletedRequests.indexOf(action.payload);
1742
- if (index !== -1)
1743
- state.deletedRequests.splice(index, 1);
1686
+ if (index !== -1) state.deletedRequests.splice(index, 1);
1744
1687
  },
1745
1688
  _setLatestRetryTime: (state, action) => {
1746
1689
  state.latestRetryTime = action.payload;
@@ -1751,39 +1694,26 @@ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
1751
1694
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
1752
1695
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
1753
1696
  const outboxReducer = outboxSlice.reducer;
1754
- const initialState$j = {
1755
- projectFiles: {},
1697
+ const projectFileModelAdapter = createModelAdapter((projectFile) => projectFile.offline_id);
1698
+ const initialState$j = projectFileModelAdapter.getInitialState({
1756
1699
  activeProjectFileId: null,
1757
1700
  isImportingProjectFile: false
1758
- };
1701
+ });
1759
1702
  const projectFileSlice = createSlice({
1760
1703
  name: "projectFiles",
1761
1704
  initialState: initialState$j,
1762
1705
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1763
1706
  reducers: {
1764
- addOrReplaceProjectFiles: (state, action) => {
1765
- for (let fileObj of action.payload) {
1766
- let file = fileObj.file;
1767
- if (file.includes("+")) {
1768
- console.warn("Attempting to apply fix for image URL with '+' character:", file);
1769
- const parts = file.split("/");
1770
- if (parts.length < 2) {
1771
- throw new Error("Invalid URL: " + file);
1772
- }
1773
- const lastPart = encodeURIComponent(parts[parts.length - 1]);
1774
- file = parts.slice(0, -1).join("/") + "/" + lastPart;
1775
- console.warn("Fixed URL:", file);
1776
- fileObj = { ...fileObj, file };
1777
- }
1778
- state.projectFiles[fileObj.offline_id] = fileObj;
1779
- }
1780
- },
1781
- addOrReplaceProjectFile: (state, action) => {
1782
- if (!action.payload.project) {
1783
- throw new Error("ProjectFile has no project. A project must be set before storing.");
1784
- }
1785
- state.projectFiles[action.payload.offline_id] = action.payload;
1786
- },
1707
+ initializeProjectFiles: projectFileModelAdapter.initialize,
1708
+ setProjectFile: projectFileModelAdapter.setOne,
1709
+ setProjectFiles: projectFileModelAdapter.setMany,
1710
+ addProjectFile: projectFileModelAdapter.addOne,
1711
+ addProjectFiles: projectFileModelAdapter.addMany,
1712
+ updateProjectFile: projectFileModelAdapter.updateOne,
1713
+ updateProjectFiles: projectFileModelAdapter.updateMany,
1714
+ deleteProjectFile: projectFileModelAdapter.deleteOne,
1715
+ deleteProjectFiles: projectFileModelAdapter.deleteMany,
1716
+ // TODO: move following to /web
1787
1717
  setIsImportingProjectFile: (state, action) => {
1788
1718
  state.isImportingProjectFile = action.payload;
1789
1719
  },
@@ -1792,50 +1722,46 @@ const projectFileSlice = createSlice({
1792
1722
  if (!activeProjectFileId) {
1793
1723
  throw new Error("Tried to save bounds for active project file, but no active project file was set.");
1794
1724
  }
1795
- if (!state.projectFiles[activeProjectFileId]) {
1725
+ if (!state.instances[activeProjectFileId]) {
1796
1726
  throw new Error(
1797
1727
  `Tried to save bounds for active project file, but project file with ID ${activeProjectFileId}
1798
1728
  doesn't exist.`
1799
1729
  );
1800
1730
  }
1801
- state.projectFiles[activeProjectFileId].bounds = action.payload;
1731
+ state.instances[activeProjectFileId].bounds = action.payload;
1802
1732
  },
1803
- // TODO: Move to MapContext. Should not be persisted.
1804
1733
  setActiveProjectFileId: (state, action) => {
1805
1734
  state.activeProjectFileId = action.payload;
1806
1735
  },
1807
- removeProjectFile: (state, action) => {
1808
- delete state.projectFiles[action.payload];
1809
- },
1810
- removeProjectFilesOfProject: (state, action) => {
1811
- const filesToDelete = Object.values(state.projectFiles).filter((file) => file.project === action.payload);
1812
- for (const file of filesToDelete) {
1813
- delete state.projectFiles[file.offline_id];
1814
- }
1815
- },
1816
1736
  resetProjectFileObjectUrls: (state, ..._args) => {
1817
- for (const key in state.projectFiles) {
1818
- delete state.projectFiles[key].objectURL;
1737
+ for (const key in state.instances) {
1738
+ delete state.instances[key].objectURL;
1819
1739
  }
1820
1740
  }
1821
1741
  }
1822
1742
  });
1823
1743
  const {
1824
- addOrReplaceProjectFiles,
1825
- addOrReplaceProjectFile,
1744
+ initializeProjectFiles,
1745
+ setProjectFile,
1746
+ setProjectFiles,
1747
+ addProjectFile,
1748
+ addProjectFiles,
1749
+ updateProjectFile,
1750
+ updateProjectFiles,
1751
+ deleteProjectFile,
1752
+ deleteProjectFiles,
1753
+ // TODO: move following to /web
1826
1754
  setIsImportingProjectFile,
1827
1755
  setActiveProjectFileId,
1828
1756
  saveActiveProjectFileBounds,
1829
- removeProjectFile,
1830
- removeProjectFilesOfProject,
1831
1757
  resetProjectFileObjectUrls
1832
1758
  } = projectFileSlice.actions;
1833
- const selectProjectFileMapping = (state) => state.projectFileReducer.projectFiles;
1759
+ const selectProjectFileMapping = (state) => state.projectFileReducer.instances;
1834
1760
  const selectProjectFiles = createSelector([selectProjectFileMapping], (mapping) => {
1835
1761
  return fallbackToEmptyArray(Object.values(mapping).sort((a, b) => a.z_index - b.z_index));
1836
1762
  });
1837
1763
  const selectProjectFileById = (id) => (state) => {
1838
- return state.projectFileReducer.projectFiles[id];
1764
+ return state.projectFileReducer.instances[id];
1839
1765
  };
1840
1766
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
1841
1767
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
@@ -1889,11 +1815,11 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
1889
1815
  const attachmentsOfProject = attachments.filter(({ project }) => projectId === project);
1890
1816
  const fileAttachments = attachmentsOfProject.filter(
1891
1817
  // this null check here is necessary, there are cases where file_type is null or undefined
1892
- ({ file_type }) => !file_type || !file_type.startsWith("image/")
1818
+ ({ file_type }) => !file_type.startsWith("image/")
1893
1819
  );
1894
1820
  const imageAttachments = attachmentsOfProject.filter(
1895
1821
  // this null check here is necessary, there are cases where file_type is null or undefined
1896
- ({ file_type }) => file_type && file_type.startsWith("image/")
1822
+ ({ file_type }) => file_type.startsWith("image/")
1897
1823
  );
1898
1824
  return { fileAttachments, imageAttachments };
1899
1825
  }
@@ -1977,8 +1903,7 @@ const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
1977
1903
  [selectFormRevisionMapping, (_state, formId) => formId],
1978
1904
  (revisions, formId) => {
1979
1905
  const revisionsOfForm = Object.values(revisions).filter((revision) => revision.form === formId);
1980
- if (revisionsOfForm.length === 0)
1981
- return void 0;
1906
+ if (revisionsOfForm.length === 0) return void 0;
1982
1907
  const sortedRevisions = revisionsOfForm.sort(formRevisionSortFn);
1983
1908
  const latestRevision = sortedRevisions[revisionsOfForm.length - 1];
1984
1909
  return revisions[latestRevision.offline_id];
@@ -2050,7 +1975,7 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
2050
1975
  return [...regularMatches.slice(0, maxResults)];
2051
1976
  },
2052
1977
  // as the argument is an object, we check the first level of properties for equality
2053
- { memoizeOptions: { equalityCheck: shallowEqual } }
1978
+ { memoizeOptions: { resultEqualityCheck: shallowEqual } }
2054
1979
  )
2055
1980
  );
2056
1981
  const selectFormById = (formId) => (state) => {
@@ -2129,8 +2054,7 @@ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
2129
2054
  (submissionsMapping, revisionMapping, formId) => {
2130
2055
  const revisionIds = /* @__PURE__ */ new Set();
2131
2056
  for (const revision of Object.values(revisionMapping)) {
2132
- if (revision.form !== formId)
2133
- continue;
2057
+ if (revision.form !== formId) continue;
2134
2058
  revisionIds.add(revision.offline_id);
2135
2059
  }
2136
2060
  return Object.values(submissionsMapping).filter(
@@ -2197,8 +2121,7 @@ const selectAttachedFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2197
2121
  ],
2198
2122
  (issues, forms, formRevisions, submissions, issueId) => {
2199
2123
  const issue = issues[issueId];
2200
- if (!issue)
2201
- return [];
2124
+ if (!issue) return [];
2202
2125
  if (!issue.issue_type) {
2203
2126
  return Object.values(submissions).filter((submission) => submission.issue === issueId);
2204
2127
  }
@@ -2255,8 +2178,7 @@ const selectAttachedFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2255
2178
  ],
2256
2179
  (assets, forms, formRevisions, submissions, assetId) => {
2257
2180
  const asset = assets[assetId];
2258
- if (!asset)
2259
- return [];
2181
+ if (!asset) return [];
2260
2182
  if (!asset.asset_type) {
2261
2183
  return Object.values(submissions).filter((submission) => submission.asset === assetId);
2262
2184
  }
@@ -2632,8 +2554,7 @@ const selectAncestorIdsOfDocument = restructureCreateSelectorWithArgs(
2632
2554
  createSelector([selectDocumentsMapping, (_state, documentId) => documentId], (mapping, documentId) => {
2633
2555
  const listOfAncestors = [];
2634
2556
  const document2 = mapping[documentId];
2635
- if (!document2 || !document2.parent_document)
2636
- return listOfAncestors;
2557
+ if (!document2 || !document2.parent_document) return listOfAncestors;
2637
2558
  let currentAncestor = mapping[document2.parent_document];
2638
2559
  while (currentAncestor) {
2639
2560
  listOfAncestors.push(currentAncestor.offline_id);
@@ -2699,11 +2620,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
2699
2620
  const attachmentsOfProject = attachments.filter(({ document: document2 }) => documentId === document2);
2700
2621
  const fileAttachments = attachmentsOfProject.filter(
2701
2622
  // this null check here is necessary, there are cases where file_type is null or undefined
2702
- ({ file_type }) => !file_type || !file_type.startsWith("image/")
2623
+ ({ file_type }) => !file_type.startsWith("image/")
2703
2624
  );
2704
2625
  const imageAttachments = attachmentsOfProject.filter(
2705
2626
  // this null check here is necessary, there are cases where file_type is null or undefined
2706
- ({ file_type }) => file_type && file_type.startsWith("image/")
2627
+ ({ file_type }) => file_type.startsWith("image/")
2707
2628
  );
2708
2629
  return { fileAttachments, imageAttachments };
2709
2630
  }
@@ -2909,11 +2830,11 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
2909
2830
  const attachmentsOfIssue = attachments.filter(({ issue }) => issue === issueId);
2910
2831
  const fileAttachments = attachmentsOfIssue.filter(
2911
2832
  // this null check here is necessary, there are cases where file_type is null or undefined
2912
- ({ file_type }) => !file_type || !file_type.startsWith("image/")
2833
+ ({ file_type }) => !file_type.startsWith("image/")
2913
2834
  );
2914
2835
  const imageAttachments = attachmentsOfIssue.filter(
2915
2836
  // this null check here is necessary, there are cases where file_type is null or undefined
2916
- ({ file_type }) => file_type && file_type.startsWith("image/")
2837
+ ({ file_type }) => file_type.startsWith("image/")
2917
2838
  );
2918
2839
  return { fileAttachments, imageAttachments };
2919
2840
  }
@@ -3062,6 +2983,7 @@ class BaseService {
3062
2983
  async enqueueRequest(requestDetails) {
3063
2984
  return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
3064
2985
  }
2986
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3065
2987
  dispatch(action) {
3066
2988
  this.client.store.dispatch(action);
3067
2989
  }
@@ -3131,9 +3053,8 @@ function getOutboxCoordinator() {
3131
3053
  __OUTBOX_COORDINATOR = coordinator;
3132
3054
  return coordinator;
3133
3055
  }
3134
- const persistCallback = (err) => {
3135
- if (err)
3136
- throw err;
3056
+ const persistCallback = (e) => {
3057
+ if (e) throw e;
3137
3058
  const clientStore2 = getClientStore();
3138
3059
  if (clientStore2) {
3139
3060
  clientStore2.dispatch({ type: "rehydrated/setRehydrated", payload: true });
@@ -3197,14 +3118,11 @@ function extractResponseFromError(error) {
3197
3118
  const knownKeys = ["ok", "redirect", "clientError", "serverError", "error"];
3198
3119
  return typeof response === "object" && response !== null && knownKeys.every((key) => key in response);
3199
3120
  }
3200
- if (isResponse(error))
3201
- return error;
3121
+ if (isResponse(error)) return error;
3202
3122
  if (typeof error === "object" && error !== null) {
3203
3123
  const typedError = error;
3204
- if (isResponse(typedError.response))
3205
- return typedError.response;
3206
- if (typedError.response && isResponse(typedError.response.response))
3207
- return typedError.response.response;
3124
+ if (isResponse(typedError.response)) return typedError.response;
3125
+ if (typedError.response && isResponse(typedError.response.response)) return typedError.response.response;
3208
3126
  }
3209
3127
  return void 0;
3210
3128
  }
@@ -3245,15 +3163,11 @@ async function performRequest(action, client) {
3245
3163
  const addPayload = (req) => {
3246
3164
  if (attachmentHash) {
3247
3165
  const s3url = requestDetails.s3url;
3248
- if (!s3url)
3249
- throw new Error(`No S3 URL for file ${attachmentHash}`);
3250
- if ("warning" in s3url)
3251
- throw new Error(`S3 URL warning for file ${attachmentHash}`);
3252
- if (!file)
3253
- throw new Error(`No file for file ${attachmentHash}`);
3166
+ if (!s3url) throw new Error(`No S3 URL for file ${attachmentHash}`);
3167
+ if ("warning" in s3url) throw new Error(`S3 URL warning for file ${attachmentHash}`);
3168
+ if (!file) throw new Error(`No file for file ${attachmentHash}`);
3254
3169
  const s3Sha1Checksum = s3url.fields["x-amz-checksum-sha1"];
3255
- if (!s3Sha1Checksum)
3256
- throw new Error(`No checksum for file ${attachmentHash}`);
3170
+ if (!s3Sha1Checksum) throw new Error(`No checksum for file ${attachmentHash}`);
3257
3171
  return req.set("x-amz-checksum-sha1", s3Sha1Checksum).field({ ...payload, ...s3url.fields }).attach("file", file);
3258
3172
  }
3259
3173
  return req.send(payload);
@@ -3313,8 +3227,7 @@ class MiddlewareChainerPrivate {
3313
3227
  this.compile = this.compile.bind(this);
3314
3228
  }
3315
3229
  then(next) {
3316
- if (this._previous)
3317
- this._previous.next = next;
3230
+ if (this._previous) this._previous.next = next;
3318
3231
  this._all.push(next);
3319
3232
  this._previous = next;
3320
3233
  return {
@@ -3342,11 +3255,9 @@ class OfflineMiddleware {
3342
3255
  } else {
3343
3256
  console.debug("Middleware finished. Performing request:", action);
3344
3257
  const clientStore2 = getClientStore();
3345
- if (!clientStore2)
3346
- throw new Error("Client store not set");
3258
+ if (!clientStore2) throw new Error("Client store not set");
3347
3259
  const clientSDK2 = getClientSDK();
3348
- if (!clientSDK2)
3349
- throw new Error("Client SDK not set");
3260
+ if (!clientSDK2) throw new Error("Client SDK not set");
3350
3261
  return performRequest(action, clientSDK2);
3351
3262
  }
3352
3263
  }
@@ -3367,20 +3278,6 @@ function runMiddleware(action) {
3367
3278
  return (_a2 = allMiddleware[0]) == null ? void 0 : _a2.run(action);
3368
3279
  }
3369
3280
  const discardStatuses = [400, 409, 403, 404, 405, 500];
3370
- const statusMessages = {
3371
- 403: { title: "Forbidden", description: "You are not authorized to perform this action.", accentColor: "red" },
3372
- 404: { title: "Not found", description: "The requested resource was not found.", accentColor: "red" },
3373
- 405: {
3374
- title: "Not supported",
3375
- description: "It's not you. It's us. Sorry for the inconvenience.",
3376
- accentColor: "red"
3377
- },
3378
- 500: {
3379
- title: "Server error",
3380
- description: "Our server seems to be experiencing problems at the moment. We have been alerted and will fix the problem as soon as possible.",
3381
- accentColor: "red"
3382
- }
3383
- };
3384
3281
  function discard(reason, action, retries = 0) {
3385
3282
  var _a2;
3386
3283
  console.debug(
@@ -3433,14 +3330,6 @@ function discard(reason, action, retries = 0) {
3433
3330
  }
3434
3331
  if (status !== void 0 && discardStatuses.includes(status)) {
3435
3332
  console.warn("Discarding request due to error:", reason, "\nAction:", action);
3436
- const message = statusMessages[status];
3437
- if (message) {
3438
- if (unsafeShowToast) {
3439
- unsafeShowToast(message);
3440
- } else {
3441
- console.error(`Could not display toast for status ${status} because there is no toast handle.`);
3442
- }
3443
- }
3444
3333
  const coordinator2 = getOutboxCoordinator();
3445
3334
  if (!coordinator2) {
3446
3335
  throw new Error("Outbox coordinator not set");
@@ -3468,6 +3357,7 @@ function retry(_action, _retries) {
3468
3357
  }
3469
3358
  class BaseSDK {
3470
3359
  constructor(store) {
3360
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3471
3361
  __publicField(this, "store");
3472
3362
  this.store = store;
3473
3363
  }
@@ -3503,9 +3393,13 @@ class BaseSDK {
3503
3393
  };
3504
3394
  performRequest(fullOfflineAction, this).then((result) => {
3505
3395
  promise.resolve(result.body);
3506
- }).catch((error) => {
3507
- discard(error, fullOfflineAction);
3508
- promise.reject(error);
3396
+ }).catch((e) => {
3397
+ discard(e, fullOfflineAction);
3398
+ if (e instanceof Error) {
3399
+ promise.reject(e);
3400
+ } else {
3401
+ promise.reject(new Error((e ?? UNKNOWN_ERROR_MESSAGE).toString()));
3402
+ }
3509
3403
  });
3510
3404
  } else {
3511
3405
  const innerPromise = this.store.dispatch(
@@ -3559,10 +3453,8 @@ class BaseAuthService extends BaseService {
3559
3453
  }
3560
3454
  const EXPIRING_SOON_THRESHOLD = 1800;
3561
3455
  function parseTokens(response) {
3562
- if (!response.access)
3563
- throw new Error("Missing access token");
3564
- if (!response.refresh)
3565
- throw new Error("Missing refresh token");
3456
+ if (!response.access) throw new Error("Missing access token");
3457
+ if (!response.refresh) throw new Error("Missing refresh token");
3566
3458
  return { accessToken: response.access, refreshToken: response.refresh };
3567
3459
  }
3568
3460
  class JWTService extends BaseAuthService {
@@ -3599,8 +3491,7 @@ class JWTService extends BaseAuthService {
3599
3491
  this.clearAuth();
3600
3492
  return void 0;
3601
3493
  }
3602
- if (!response.access)
3603
- throw new Error("Missing access token");
3494
+ if (!response.access) throw new Error("Missing access token");
3604
3495
  return { accessToken: response.access, refreshToken: response.refresh ?? this.getRefreshToken() };
3605
3496
  });
3606
3497
  }
@@ -3656,8 +3547,7 @@ class JWTService extends BaseAuthService {
3656
3547
  return `Bearer ${accessToken}`;
3657
3548
  }
3658
3549
  async prepareAuth() {
3659
- if (!this.tokenIsExpiringSoon())
3660
- return;
3550
+ if (!this.tokenIsExpiringSoon()) return;
3661
3551
  console.debug(this.constructor.name, "preparing auth");
3662
3552
  try {
3663
3553
  await this.renewTokens();
@@ -3665,7 +3555,11 @@ class JWTService extends BaseAuthService {
3665
3555
  if (e instanceof APIError) {
3666
3556
  this.clearAuth();
3667
3557
  }
3668
- return Promise.reject(e);
3558
+ if (e instanceof Error) {
3559
+ return Promise.reject(e);
3560
+ } else {
3561
+ return Promise.reject(new Error((e ?? UNKNOWN_ERROR_MESSAGE).toString()));
3562
+ }
3669
3563
  }
3670
3564
  }
3671
3565
  /* if not successfull in gracefully handling an unauthorized response, throw and APIError */
@@ -3696,7 +3590,7 @@ class JWTService extends BaseAuthService {
3696
3590
  async initAuth(payload) {
3697
3591
  const uuid = v4();
3698
3592
  console.debug(this.constructor.name, "Initiating auth");
3699
- const promise = this.enqueueRequest({
3593
+ return this.enqueueRequest({
3700
3594
  uuid,
3701
3595
  description: "Get token pair",
3702
3596
  method: HttpMethod.POST,
@@ -3704,25 +3598,12 @@ class JWTService extends BaseAuthService {
3704
3598
  payload,
3705
3599
  isAuthNeeded: false,
3706
3600
  checkAuth: false,
3601
+ immediate: true,
3707
3602
  blockers: [],
3708
3603
  blocks: []
3709
- }).then(parseTokens);
3710
- const timeout = 5;
3711
- let timedOut = false;
3712
- const timeoutPromise = new Promise((_, reject) => {
3713
- setTimeout(() => {
3714
- timedOut = true;
3715
- this.dispatch(markForDeletion(uuid));
3716
- reject(new APIError({ message: `Request timed out after ${timeout} seconds` }));
3717
- }, timeout * 1e3);
3718
- });
3719
- const successPromise = promise.then((tokens) => {
3720
- if (timedOut) {
3721
- return void 0;
3722
- }
3723
- this.setTokens(tokens);
3604
+ }).then((tokens) => {
3605
+ this.setTokens(parseTokens(tokens));
3724
3606
  });
3725
- return Promise.race([timeoutPromise, successPromise]);
3726
3607
  }
3727
3608
  }
3728
3609
  class BaseApiService extends BaseService {
@@ -3885,8 +3766,7 @@ class AssetService extends BaseApiService {
3885
3766
  const { store } = this.client;
3886
3767
  const state = store.getState();
3887
3768
  const assetToBeDeleted = selectAssetById(id)(state);
3888
- if (!assetToBeDeleted)
3889
- throw new Error(`No asset with id ${id} found in the store`);
3769
+ if (!assetToBeDeleted) throw new Error(`No asset with id ${id} found in the store`);
3890
3770
  const attachmentsOfAssets = selectAttachmentsOfAsset(id)(state);
3891
3771
  const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(id)(state);
3892
3772
  const issueAssociations = selectIssueAssociationsOfAsset(id)(state);
@@ -3909,12 +3789,12 @@ class AssetService extends BaseApiService {
3909
3789
  url: `/assets/${id}/`,
3910
3790
  blockers: [id],
3911
3791
  blocks: []
3912
- }).catch((err) => {
3792
+ }).catch((e) => {
3913
3793
  this.dispatch(addAsset(assetToBeDeleted));
3914
3794
  this.dispatch(addAssetAttachments(attachmentsOfAssets));
3915
3795
  this.dispatch(addFormSubmissions(formSubmissionsOfAssets));
3916
3796
  this.dispatch(addIssueAssociations(issueAssociations));
3917
- throw err;
3797
+ throw e;
3918
3798
  });
3919
3799
  }
3920
3800
  bulkAdd(payloads, assetTypeId, batchSize) {
@@ -3938,8 +3818,7 @@ class AssetService extends BaseApiService {
3938
3818
  const { batchId, payload } = assetBatch;
3939
3819
  const batchAssetOfflineIds = payload.assets.map((c) => c.offline_id);
3940
3820
  const blockers = [assetTypeId];
3941
- if (prevBatchId)
3942
- blockers.push(prevBatchId);
3821
+ if (prevBatchId) blockers.push(prevBatchId);
3943
3822
  const blocks = batchAssetOfflineIds;
3944
3823
  blocks.push(batchId);
3945
3824
  const promise = this.enqueueRequest({
@@ -4153,8 +4032,7 @@ class AssetStageService extends BaseApiService {
4153
4032
  update(payload) {
4154
4033
  const { store } = this.client;
4155
4034
  const assetStage = selectAssetStageById(payload.offline_id)(store.getState());
4156
- if (!assetStage)
4157
- throw new Error(`No asset stage with id ${payload.offline_id} found in the store`);
4035
+ if (!assetStage) throw new Error(`No asset stage with id ${payload.offline_id} found in the store`);
4158
4036
  const updatedAssetStage = {
4159
4037
  ...assetStage,
4160
4038
  ...payload
@@ -4748,7 +4626,18 @@ class IssueService extends BaseApiService {
4748
4626
  ]) {
4749
4627
  if (issueUpdateChange in payload && payload[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
4750
4628
  switch (issueUpdateChange) {
4751
- case "category": {
4629
+ case IssueUpdateChange.PRIORITY:
4630
+ case IssueUpdateChange.STATUS: {
4631
+ const val = payload[issueUpdateChange];
4632
+ changes[issueUpdateChange] = val !== void 0 ? Number(val) : null;
4633
+ break;
4634
+ }
4635
+ case IssueUpdateChange.DUE_DATE:
4636
+ case IssueUpdateChange.DESCRIPTION:
4637
+ case IssueUpdateChange.TITLE:
4638
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
4639
+ break;
4640
+ case IssueUpdateChange.CATEGORY: {
4752
4641
  let categoryOrNull = null;
4753
4642
  const categoryIdOrNull = payload[issueUpdateChange];
4754
4643
  if (categoryIdOrNull) {
@@ -4765,7 +4654,7 @@ class IssueService extends BaseApiService {
4765
4654
  } : null;
4766
4655
  break;
4767
4656
  }
4768
- case "assigned_to": {
4657
+ case IssueUpdateChange.ASSIGNED_TO: {
4769
4658
  let userOrNull = null;
4770
4659
  const userIdOrNull = payload[issueUpdateChange];
4771
4660
  if (userIdOrNull) {
@@ -4781,20 +4670,6 @@ class IssueService extends BaseApiService {
4781
4670
  } : null;
4782
4671
  break;
4783
4672
  }
4784
- case "description":
4785
- changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
4786
- break;
4787
- case "title":
4788
- changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
4789
- break;
4790
- case "priority":
4791
- changes[issueUpdateChange] = payload[issueUpdateChange];
4792
- break;
4793
- case "status":
4794
- changes[issueUpdateChange] = payload[issueUpdateChange];
4795
- break;
4796
- case "due_date":
4797
- changes[issueUpdateChange] = payload[issueUpdateChange] ? payload[issueUpdateChange] : null;
4798
4673
  }
4799
4674
  }
4800
4675
  }
@@ -5014,7 +4889,7 @@ class ProjectFileService extends BaseApiService {
5014
4889
  blocks: [file.offline_id]
5015
4890
  });
5016
4891
  void promise.then((result) => {
5017
- this.dispatch(addOrReplaceProjectFile(result));
4892
+ this.dispatch(updateProjectFile(result));
5018
4893
  });
5019
4894
  return promise;
5020
4895
  }
@@ -5026,7 +4901,7 @@ class ProjectFileService extends BaseApiService {
5026
4901
  if (!activeProjectFileId) {
5027
4902
  throw new Error("No active project file");
5028
4903
  }
5029
- const activeProjectFile = state.projectFileReducer.projectFiles[activeProjectFileId];
4904
+ const activeProjectFile = state.projectFileReducer.instances[activeProjectFileId];
5030
4905
  if (!activeProjectFile) {
5031
4906
  throw new Error("No active project file");
5032
4907
  }
@@ -5065,7 +4940,7 @@ class ProjectFileService extends BaseApiService {
5065
4940
  return this.enqueueRequest(requestDetails2);
5066
4941
  });
5067
4942
  void promise.then((result) => {
5068
- this.dispatch(addOrReplaceProjectFile(result));
4943
+ this.dispatch(updateProjectFile(result));
5069
4944
  });
5070
4945
  this.dispatch(saveActiveProjectFileBounds);
5071
4946
  this.dispatch(setActiveProjectFileId(null));
@@ -5073,7 +4948,7 @@ class ProjectFileService extends BaseApiService {
5073
4948
  return [activeProjectFile, promise];
5074
4949
  }
5075
4950
  delete(projectFileId) {
5076
- this.dispatch(removeProjectFile(projectFileId));
4951
+ this.dispatch(deleteProjectFile(projectFileId));
5077
4952
  return this.enqueueRequest({
5078
4953
  method: HttpMethod.DELETE,
5079
4954
  url: `/projects/files/${projectFileId}`,
@@ -5089,8 +4964,7 @@ class ProjectFileService extends BaseApiService {
5089
4964
  blockers: [],
5090
4965
  blocks: []
5091
4966
  });
5092
- this.dispatch(addOrReplaceProjectFiles([]));
5093
- this.dispatch(addOrReplaceProjectFiles(result));
4967
+ this.dispatch(initializeProjectFiles(result));
5094
4968
  }
5095
4969
  }
5096
4970
  class ProjectAttachmentService extends BaseAttachmentService {
@@ -5168,7 +5042,7 @@ class ProjectService extends BaseApiService {
5168
5042
  throw new Error("Expected project to exist");
5169
5043
  }
5170
5044
  const filesToDelete = selectProjectFiles(state).filter((file) => file.project === projectId);
5171
- this.dispatch(removeProjectFilesOfProject(project.id));
5045
+ this.dispatch(deleteProjectFiles(filesToDelete.map(({ offline_id }) => offline_id)));
5172
5046
  const attachmentsOfProject = selectAttachmentsOfProject(project.id)(state);
5173
5047
  this.dispatch(deleteProjectAttachments(attachmentsOfProject.map(({ offline_id }) => offline_id)));
5174
5048
  const projectAccesses = selectProjectAccesses(state);
@@ -5191,7 +5065,7 @@ class ProjectService extends BaseApiService {
5191
5065
  } catch (e) {
5192
5066
  this.dispatch(setProjects(Object.values(projects)));
5193
5067
  this.dispatch(initializeProjectAccesses(Object.values(projectAccesses)));
5194
- this.dispatch(addOrReplaceProjectFiles(filesToDelete));
5068
+ this.dispatch(addProjectFiles(filesToDelete));
5195
5069
  this.dispatch(setProjectAttachments(attachmentsOfProject));
5196
5070
  this.dispatch({ type: "rehydrated/setRehydrated", payload: true });
5197
5071
  if (license) {
@@ -5506,12 +5380,9 @@ class FormService extends BaseUploadService {
5506
5380
  blockers: [projectId.toString()],
5507
5381
  blocks: []
5508
5382
  });
5509
- for (const form of projectFormsResult.forms)
5510
- forms.push(form);
5511
- for (const revision of projectFormsResult.revisions)
5512
- revisions.push(revision);
5513
- for (const attachment of projectFormsResult.attachments)
5514
- attachments.push(attachment);
5383
+ for (const form of projectFormsResult.forms) forms.push(form);
5384
+ for (const revision of projectFormsResult.revisions) revisions.push(revision);
5385
+ for (const attachment of projectFormsResult.attachments) attachments.push(attachment);
5515
5386
  const organizationFormsResult = await this.enqueueRequest({
5516
5387
  description: "Fetch organization forms",
5517
5388
  method: HttpMethod.GET,
@@ -5519,12 +5390,9 @@ class FormService extends BaseUploadService {
5519
5390
  blockers: [projectId.toString()],
5520
5391
  blocks: []
5521
5392
  });
5522
- for (const form of organizationFormsResult.forms)
5523
- forms.push(form);
5524
- for (const revision of organizationFormsResult.revisions)
5525
- revisions.push(revision);
5526
- for (const attachment of organizationFormsResult.attachments)
5527
- attachments.push(attachment);
5393
+ for (const form of organizationFormsResult.forms) forms.push(form);
5394
+ for (const revision of organizationFormsResult.revisions) revisions.push(revision);
5395
+ for (const attachment of organizationFormsResult.attachments) attachments.push(attachment);
5528
5396
  const assetTypeFormsResult = await this.enqueueRequest({
5529
5397
  description: "Fetch asset type forms",
5530
5398
  method: HttpMethod.GET,
@@ -5532,12 +5400,9 @@ class FormService extends BaseUploadService {
5532
5400
  blockers: [projectId.toString()],
5533
5401
  blocks: []
5534
5402
  });
5535
- for (const form of assetTypeFormsResult.forms)
5536
- forms.push(form);
5537
- for (const revision of assetTypeFormsResult.revisions)
5538
- revisions.push(revision);
5539
- for (const attachment of assetTypeFormsResult.attachments)
5540
- attachments.push(attachment);
5403
+ for (const form of assetTypeFormsResult.forms) forms.push(form);
5404
+ for (const revision of assetTypeFormsResult.revisions) revisions.push(revision);
5405
+ for (const attachment of assetTypeFormsResult.attachments) attachments.push(attachment);
5541
5406
  const issueTypeFormsResult = await this.enqueueRequest({
5542
5407
  description: "Fetch issue type forms",
5543
5408
  method: HttpMethod.GET,
@@ -5545,12 +5410,9 @@ class FormService extends BaseUploadService {
5545
5410
  blockers: [projectId.toString()],
5546
5411
  blocks: []
5547
5412
  });
5548
- for (const form of issueTypeFormsResult.forms)
5549
- forms.push(form);
5550
- for (const revision of issueTypeFormsResult.revisions)
5551
- revisions.push(revision);
5552
- for (const attachment of issueTypeFormsResult.attachments)
5553
- attachments.push(attachment);
5413
+ for (const form of issueTypeFormsResult.forms) forms.push(form);
5414
+ for (const revision of issueTypeFormsResult.revisions) revisions.push(revision);
5415
+ for (const attachment of issueTypeFormsResult.attachments) attachments.push(attachment);
5554
5416
  this.dispatch(initializeForms(forms));
5555
5417
  this.dispatch(initializeFormRevisions(revisions));
5556
5418
  this.dispatch(initializeFormRevisionAttachments(attachments));
@@ -5761,8 +5623,7 @@ class FormSubmissionService extends BaseUploadService {
5761
5623
  const batchSubmissionOfflineIds = payload.submissions.map((x) => x.offline_id);
5762
5624
  const batchAttachmentsOfflineIds = payload.attachments.map((x) => x.offline_id);
5763
5625
  const blockers = batchAssetIds;
5764
- if (prevBatchId)
5765
- blockers.push(prevBatchId);
5626
+ if (prevBatchId) blockers.push(prevBatchId);
5766
5627
  const blocks = [...batchSubmissionOfflineIds, ...batchAttachmentsOfflineIds, batchId];
5767
5628
  const promise = this.enqueueRequest({
5768
5629
  description: "Bulk add form submissions",
@@ -5782,10 +5643,8 @@ class FormSubmissionService extends BaseUploadService {
5782
5643
  const createdSubmissions = [];
5783
5644
  const createdAttachments = [];
5784
5645
  for (const result of results) {
5785
- for (const createdSubmission of result.submissions)
5786
- createdSubmissions.push(createdSubmission);
5787
- for (const createdAttachment of result.attachments)
5788
- createdAttachments.push(createdAttachment);
5646
+ for (const createdSubmission of result.submissions) createdSubmissions.push(createdSubmission);
5647
+ for (const createdAttachment of result.attachments) createdAttachments.push(createdAttachment);
5789
5648
  }
5790
5649
  this.dispatch(addFormSubmissions(createdSubmissions));
5791
5650
  this.dispatch(addFormSubmissionAttachments(createdAttachments));
@@ -5981,9 +5840,9 @@ class WorkspaceService extends BaseApiService {
5981
5840
  blockers: [id],
5982
5841
  blocks: []
5983
5842
  });
5984
- void promise.catch((reason) => {
5843
+ void promise.catch((e) => {
5985
5844
  this.dispatch(addWorkspace(originalWorkspace));
5986
- throw reason;
5845
+ throw e;
5987
5846
  });
5988
5847
  return promise;
5989
5848
  }
@@ -6044,7 +5903,7 @@ const summarizeEvery = 20;
6044
5903
  class FileService extends BaseApiService {
6045
5904
  constructor() {
6046
5905
  super(...arguments);
6047
- __publicField(this, "host", {}.REACT_APP_API_URL);
5906
+ __publicField(this, "host");
6048
5907
  // NOTE: If you alter the schema (of the IndexedDB database) in any way, you must increment the version in order to
6049
5908
  // migrate the store. This allows idb to automatically migrate the user's existing data to the new schema.
6050
5909
  __publicField(this, "_dbPromise", openDB("fileCache", 1, {
@@ -6055,8 +5914,7 @@ class FileService extends BaseApiService {
6055
5914
  }
6056
5915
  async renewUploadUrl(sha1) {
6057
5916
  const file = await this.fetchCache(sha1);
6058
- if (!file)
6059
- throw new Error(`File with sha1 ${sha1} not found in cache`);
5917
+ if (!file) throw new Error(`File with sha1 ${sha1} not found in cache`);
6060
5918
  const key = await getFileS3Key(file, sha1);
6061
5919
  const s3UploadUrl = await this.enqueueRequest({
6062
5920
  description: "Get S3 URL",
@@ -6126,8 +5984,7 @@ class FileService extends BaseApiService {
6126
5984
  /** Ensure the file has been added to the file cache before calling `uploadFileToS3()` */
6127
5985
  async uploadFileToS3(sha1) {
6128
5986
  const file = await this.fetchCache(sha1);
6129
- if (!file)
6130
- throw new Error(`File with sha1 ${sha1} not found in cache`);
5987
+ if (!file) throw new Error(`File with sha1 ${sha1} not found in cache`);
6131
5988
  const key = await getFileS3Key(file, sha1);
6132
5989
  const dbFileProperties = {
6133
5990
  file_name: file.name,
@@ -6221,7 +6078,7 @@ class FileService extends BaseApiService {
6221
6078
  isExternalUrl flag in the request details is set to true, because instead of requesting the local
6222
6079
  REST API, you will be requesting localhost:80 (where this app runs), resulting in a transformed blob
6223
6080
  (with an offline_id attached) being returned. Alternatively, you may be running with
6224
- true, which will result in some file requests being treated as
6081
+ import.meta.env.PROD, which will result in some file requests being treated as
6225
6082
  external URLs and therefore not prepended with VITE_API_URL.`;
6226
6083
  throw new Error(message);
6227
6084
  }
@@ -7261,6 +7118,7 @@ export {
7261
7118
  ProjectFileService,
7262
7119
  ProjectService,
7263
7120
  TeamService,
7121
+ UNKNOWN_ERROR_MESSAGE,
7264
7122
  UserService,
7265
7123
  VERSION_REDUCER_KEY,
7266
7124
  VerificationCodeType,
@@ -7311,10 +7169,10 @@ export {
7311
7169
  addIssueUpdates,
7312
7170
  addIssues,
7313
7171
  addLicenses,
7314
- addOrReplaceProjectFile,
7315
- addOrReplaceProjectFiles,
7316
7172
  addProjectAttachment,
7317
7173
  addProjectAttachments,
7174
+ addProjectFile,
7175
+ addProjectFiles,
7318
7176
  addTeam,
7319
7177
  addUsers,
7320
7178
  addWorkspace,
@@ -7388,6 +7246,8 @@ export {
7388
7246
  deleteProjectAccesses,
7389
7247
  deleteProjectAttachment,
7390
7248
  deleteProjectAttachments,
7249
+ deleteProjectFile,
7250
+ deleteProjectFiles,
7391
7251
  deleteTeam,
7392
7252
  deleteWorkspace,
7393
7253
  dequeue,
@@ -7455,6 +7315,7 @@ export {
7455
7315
  initializeOrganizationAccesses,
7456
7316
  initializeProjectAccesses,
7457
7317
  initializeProjectAttachments,
7318
+ initializeProjectFiles,
7458
7319
  initializeTeams,
7459
7320
  initializeWorkspaces,
7460
7321
  isToday,
@@ -7503,8 +7364,6 @@ export {
7503
7364
  rehydratedSlice,
7504
7365
  removeDocuments,
7505
7366
  removeIssueType,
7506
- removeProjectFile,
7507
- removeProjectFilesOfProject,
7508
7367
  removeUser,
7509
7368
  resetProjectFileObjectUrls,
7510
7369
  resetStore,
@@ -7724,6 +7583,8 @@ export {
7724
7583
  setProfilePicture,
7725
7584
  setProjectAttachment,
7726
7585
  setProjectAttachments,
7586
+ setProjectFile,
7587
+ setProjectFiles,
7727
7588
  setProjects,
7728
7589
  setRehydrated,
7729
7590
  setTeam,
@@ -7778,6 +7639,8 @@ export {
7778
7639
  updateProjectAccess,
7779
7640
  updateProjectAttachment,
7780
7641
  updateProjectAttachments,
7642
+ updateProjectFile,
7643
+ updateProjectFiles,
7781
7644
  updateTeam,
7782
7645
  updateWorkspace,
7783
7646
  userReducer,