@overmap-ai/core 1.0.71-mapbox.5 → 1.0.71-mapbox.7

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 (153) 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 +2035 -1311
  6. package/dist/overmap-core.js.map +1 -1
  7. package/dist/overmap-core.umd.cjs +2037 -1312
  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 +39 -16
  18. package/dist/sdk/services/AssetService.d.ts +6 -5
  19. package/dist/sdk/services/AssetStageCompletionService.d.ts +5 -4
  20. package/dist/sdk/services/AssetStageService.d.ts +6 -7
  21. package/dist/sdk/services/AssetTypeAttachmentService.d.ts +38 -16
  22. package/dist/sdk/services/AssetTypeFieldValuesAttachmentService.d.ts +13 -0
  23. package/dist/sdk/services/AssetTypeFieldValuesService.d.ts +21 -0
  24. package/dist/sdk/services/AssetTypeFieldsAttachmentService.d.ts +13 -0
  25. package/dist/sdk/services/AssetTypeFieldsService.d.ts +9 -0
  26. package/dist/sdk/services/AssetTypeService.d.ts +6 -5
  27. package/dist/sdk/services/BaseApiService.d.ts +5 -4
  28. package/dist/sdk/services/BaseAttachmentService.d.ts +22 -23
  29. package/dist/sdk/services/BaseAuthService.d.ts +5 -4
  30. package/dist/sdk/services/BaseService.d.ts +7 -5
  31. package/dist/sdk/services/BaseUploadService.d.ts +6 -4
  32. package/dist/sdk/services/CategoryService.d.ts +5 -4
  33. package/dist/sdk/services/DocumentAttachmentService.d.ts +37 -16
  34. package/dist/sdk/services/DocumentService.d.ts +5 -4
  35. package/dist/sdk/services/EmailDomainsService.d.ts +4 -3
  36. package/dist/sdk/services/EmailVerificationService.d.ts +4 -3
  37. package/dist/sdk/services/FileService.d.ts +5 -4
  38. package/dist/sdk/services/FormRevisionAttachmentService.d.ts +13 -0
  39. package/dist/sdk/services/FormRevisionService.d.ts +9 -0
  40. package/dist/sdk/services/FormService.d.ts +15 -17
  41. package/dist/sdk/services/FormSubmissionAttachmentService.d.ts +14 -0
  42. package/dist/sdk/services/FormSubmissionService.d.ts +12 -31
  43. package/dist/sdk/services/GeoImageService.d.ts +5 -4
  44. package/dist/sdk/services/IssueAssociationService.d.ts +6 -5
  45. package/dist/sdk/services/IssueAttachmentService.d.ts +38 -16
  46. package/dist/sdk/services/IssueCommentService.d.ts +5 -4
  47. package/dist/sdk/services/IssueService.d.ts +5 -7
  48. package/dist/sdk/services/IssueTypeFieldValuesAttachmentService.d.ts +14 -0
  49. package/dist/sdk/services/IssueTypeFieldValuesService.d.ts +11 -0
  50. package/dist/sdk/services/IssueTypeFieldsAttachmentService.d.ts +13 -0
  51. package/dist/sdk/services/IssueTypeFieldsService.d.ts +9 -0
  52. package/dist/sdk/services/IssueTypeService.d.ts +5 -4
  53. package/dist/sdk/services/IssueUpdateService.d.ts +4 -3
  54. package/dist/sdk/services/JWTAuthService.d.ts +7 -6
  55. package/dist/sdk/services/LicenseService.d.ts +4 -3
  56. package/dist/sdk/services/OrganizationAccessService.d.ts +4 -3
  57. package/dist/sdk/services/OrganizationService.d.ts +4 -3
  58. package/dist/sdk/services/ProjectAccessService.d.ts +4 -3
  59. package/dist/sdk/services/ProjectAttachmentService.d.ts +38 -16
  60. package/dist/sdk/services/ProjectFileService.d.ts +5 -4
  61. package/dist/sdk/services/ProjectService.d.ts +4 -3
  62. package/dist/sdk/services/TeamService.d.ts +5 -4
  63. package/dist/sdk/services/UserService.d.ts +4 -3
  64. package/dist/sdk/services/WorkspaceService.d.ts +5 -4
  65. package/dist/sdk/services/index.d.ts +45 -34
  66. package/dist/sdk/typings.d.ts +9 -8
  67. package/dist/store/adapter.d.ts +12 -11
  68. package/dist/store/index.d.ts +2 -2
  69. package/dist/store/migrations.d.ts +2 -1
  70. package/dist/store/slices/agentsSlice.d.ts +11 -10
  71. package/dist/store/slices/assetAttachmentSlice.d.ts +16 -21
  72. package/dist/store/slices/assetSlice.d.ts +35 -24
  73. package/dist/store/slices/assetStageCompletionSlice.d.ts +33 -22
  74. package/dist/store/slices/assetStageSlice.d.ts +36 -26
  75. package/dist/store/slices/assetTypeAttachmentSlice.d.ts +16 -21
  76. package/dist/store/slices/assetTypeFieldValuesAttachmentSlice.d.ts +64 -0
  77. package/dist/store/slices/assetTypeFieldValuesSlice.d.ts +64 -0
  78. package/dist/store/slices/assetTypeFieldsAttachmentSlice.d.ts +63 -0
  79. package/dist/store/slices/assetTypeFieldsSlice.d.ts +64 -0
  80. package/dist/store/slices/assetTypeSlice.d.ts +16 -21
  81. package/dist/store/slices/authSlice.d.ts +10 -9
  82. package/dist/store/slices/categorySlice.d.ts +30 -16
  83. package/dist/store/slices/documentAttachmentSlice.d.ts +16 -21
  84. package/dist/store/slices/documentSlice.d.ts +30 -13
  85. package/dist/store/slices/emailDomainsSlice.d.ts +29 -15
  86. package/dist/store/slices/fileSlice.d.ts +7 -6
  87. package/dist/store/slices/formRevisionAttachmentSlice.d.ts +16 -21
  88. package/dist/store/slices/formRevisionSlice.d.ts +37 -27
  89. package/dist/store/slices/formSlice.d.ts +36 -26
  90. package/dist/store/slices/formSubmissionAttachmentSlice.d.ts +16 -21
  91. package/dist/store/slices/formSubmissionSlice.d.ts +16 -27
  92. package/dist/store/slices/geoImageSlice.d.ts +35 -24
  93. package/dist/store/slices/index.d.ts +46 -38
  94. package/dist/store/slices/issueAssociationSlice.d.ts +35 -24
  95. package/dist/store/slices/issueAttachmentSlice.d.ts +16 -21
  96. package/dist/store/slices/issueCommentSlice.d.ts +13 -18
  97. package/dist/store/slices/issueSlice.d.ts +13 -18
  98. package/dist/store/slices/issueTypeFieldValuesAttachmentSlice.d.ts +64 -0
  99. package/dist/store/slices/issueTypeFieldValuesSlice.d.ts +63 -0
  100. package/dist/store/slices/issueTypeFieldsAttachmentSlice.d.ts +63 -0
  101. package/dist/store/slices/issueTypeFieldsSlice.d.ts +65 -0
  102. package/dist/store/slices/issueTypeSlice.d.ts +12 -14
  103. package/dist/store/slices/issueUpdateSlice.d.ts +13 -18
  104. package/dist/store/slices/licenseSlice.d.ts +10 -9
  105. package/dist/store/slices/organizationAccessSlice.d.ts +11 -13
  106. package/dist/store/slices/organizationSlice.d.ts +27 -10
  107. package/dist/store/slices/outboxSlice.d.ts +15 -15
  108. package/dist/store/slices/projectAccessSlice.d.ts +11 -16
  109. package/dist/store/slices/projectAttachmentSlice.d.ts +16 -21
  110. package/dist/store/slices/projectFileSlice.d.ts +40 -29
  111. package/dist/store/slices/projectSlice.d.ts +10 -9
  112. package/dist/store/slices/rehydratedSlice.d.ts +7 -6
  113. package/dist/store/slices/teamSlice.d.ts +12 -14
  114. package/dist/store/slices/userSlice.d.ts +14 -13
  115. package/dist/store/slices/versioningSlice.d.ts +3 -2
  116. package/dist/store/slices/workspaceSlice.d.ts +31 -17
  117. package/dist/store/store.d.ts +15 -7
  118. package/dist/typings/files.d.ts +8 -4
  119. package/dist/typings/index.d.ts +6 -6
  120. package/dist/typings/models/access.d.ts +3 -2
  121. package/dist/typings/models/agents.d.ts +3 -2
  122. package/dist/typings/models/assets.d.ts +20 -4
  123. package/dist/typings/models/attachments.d.ts +3 -7
  124. package/dist/typings/models/base.d.ts +3 -2
  125. package/dist/typings/models/categories.d.ts +3 -2
  126. package/dist/typings/models/documents.d.ts +2 -1
  127. package/dist/typings/models/emailDomain.d.ts +2 -1
  128. package/dist/typings/models/emailVerification.d.ts +3 -2
  129. package/dist/typings/models/fields.d.ts +17 -0
  130. package/dist/typings/models/forms.d.ts +14 -30
  131. package/dist/typings/models/geo.d.ts +2 -1
  132. package/dist/typings/models/geoImages.d.ts +4 -3
  133. package/dist/typings/models/index.d.ts +22 -21
  134. package/dist/typings/models/issueTypes.d.ts +3 -2
  135. package/dist/typings/models/issues.d.ts +22 -6
  136. package/dist/typings/models/license.d.ts +3 -2
  137. package/dist/typings/models/organizations.d.ts +2 -1
  138. package/dist/typings/models/projects.d.ts +4 -3
  139. package/dist/typings/models/store.d.ts +11 -3
  140. package/dist/typings/models/teams.d.ts +4 -3
  141. package/dist/typings/models/users.d.ts +2 -1
  142. package/dist/typings/models/workspace.d.ts +2 -1
  143. package/dist/typings/search.d.ts +1 -1
  144. package/dist/typings/store.d.ts +2 -1
  145. package/dist/utils/async/DeferredPromise.d.ts +1 -1
  146. package/dist/utils/colors.d.ts +2 -1
  147. package/dist/utils/coordinates.d.ts +2 -1
  148. package/dist/utils/file.d.ts +3 -2
  149. package/dist/utils/forms.d.ts +2 -1
  150. package/dist/utils/index.d.ts +10 -10
  151. package/dist/utils/offline.d.ts +2 -1
  152. package/dist/utils/utils.d.ts +2 -1
  153. 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,21 +657,20 @@ 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];
712
664
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
713
- const initialState$B = {
665
+ const initialState$J = {
714
666
  accessToken: "",
715
667
  refreshToken: "",
716
668
  isLoggedIn: false
717
669
  };
718
670
  const authSlice = createSlice({
719
671
  name: "auth",
720
- initialState: initialState$B,
721
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
672
+ initialState: initialState$J,
673
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$J)),
722
674
  reducers: {
723
675
  setTokens: (state, action) => {
724
676
  state.accessToken = action.payload.accessToken;
@@ -806,11 +758,11 @@ function createModelAdapter(computeModelId) {
806
758
  };
807
759
  }
808
760
  const categoryAdapter = createModelAdapter((category) => category.offline_id);
809
- const initialState$A = categoryAdapter.getInitialState({});
761
+ const initialState$I = categoryAdapter.getInitialState({});
810
762
  const categorySlice = createSlice({
811
763
  name: "categories",
812
- initialState: initialState$A,
813
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$A)),
764
+ initialState: initialState$I,
765
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$I)),
814
766
  reducers: {
815
767
  initializeCategories: categoryAdapter.initialize,
816
768
  addCategory: categoryAdapter.addOne,
@@ -848,11 +800,11 @@ const selectIssueCountOfCategory = (categoryId) => (state) => {
848
800
  };
849
801
  const categoryReducer = categorySlice.reducer;
850
802
  const assetAdapter = createModelAdapter((asset) => asset.offline_id);
851
- const initialState$z = assetAdapter.getInitialState({});
803
+ const initialState$H = assetAdapter.getInitialState({});
852
804
  const assetSlice = createSlice({
853
805
  name: "assets",
854
- initialState: initialState$z,
855
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
806
+ initialState: initialState$H,
807
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$H)),
856
808
  reducers: {
857
809
  initializeAssets: assetAdapter.initialize,
858
810
  addAsset: assetAdapter.addOne,
@@ -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
  })
@@ -904,11 +855,11 @@ const selectNumberOfAssetsOfAssetType = (assetTypeId) => (state) => {
904
855
  };
905
856
  const assetReducer = assetSlice.reducer;
906
857
  const assetAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
907
- const initialState$y = assetAttachmentAdapter.getInitialState({});
858
+ const initialState$G = assetAttachmentAdapter.getInitialState({});
908
859
  const assetAttachmentSlice = createSlice({
909
860
  name: "assetAttachments",
910
- initialState: initialState$y,
911
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
861
+ initialState: initialState$G,
862
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$G)),
912
863
  reducers: {
913
864
  initializeAssetAttachments: assetAttachmentAdapter.initialize,
914
865
  addAssetAttachment: assetAttachmentAdapter.addOne,
@@ -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
  }
@@ -973,11 +920,11 @@ const assetAttachmentReducer = assetAttachmentSlice.reducer;
973
920
  const assetStageCompletionAdapter = createModelAdapter(
974
921
  (stageCompletion) => stageCompletion.offline_id
975
922
  );
976
- const initialState$x = assetStageCompletionAdapter.getInitialState({});
923
+ const initialState$F = assetStageCompletionAdapter.getInitialState({});
977
924
  const assetStageCompletionSlice = createSlice({
978
925
  name: "assetStageCompletions",
979
- initialState: initialState$x,
980
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
926
+ initialState: initialState$F,
927
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$F)),
981
928
  reducers: {
982
929
  initializeAssetStageCompletions: assetStageCompletionAdapter.initialize,
983
930
  addAssetStageCompletion: assetStageCompletionAdapter.addOne,
@@ -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);
@@ -1031,11 +977,11 @@ const selectAssetStageCompletionsByIds = restructureCreateSelectorWithArgs(
1031
977
  );
1032
978
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1033
979
  const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
1034
- const initialState$w = assetStageAdapter.getInitialState({});
980
+ const initialState$E = assetStageAdapter.getInitialState({});
1035
981
  const assetStageSlice = createSlice({
1036
982
  name: "assetStages",
1037
- initialState: initialState$w,
1038
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
983
+ initialState: initialState$E,
984
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$E)),
1039
985
  reducers: {
1040
986
  initializeAssetStages: assetStageAdapter.initialize,
1041
987
  setAssetStage: assetStageAdapter.setOne,
@@ -1099,27 +1045,12 @@ const selectAssetStagesByIds = restructureCreateSelectorWithArgs(
1099
1045
  return fallbackToEmptyArray(assetStages);
1100
1046
  })
1101
1047
  );
1102
- const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
1103
- createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
1104
- const ret = {};
1105
- for (const stageId of stageIds) {
1106
- const stage = stageMapping[stageId];
1107
- if (!stage) {
1108
- throw new Error("No stage exists with the id " + stageId);
1109
- }
1110
- if (stage.form) {
1111
- ret[stageId] = stage.form;
1112
- }
1113
- }
1114
- return ret;
1115
- })
1116
- );
1117
1048
  const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
1118
- const initialState$v = assetTypeAdapter.getInitialState({});
1049
+ const initialState$D = assetTypeAdapter.getInitialState({});
1119
1050
  const assetTypeSlice = createSlice({
1120
1051
  name: "assetTypes",
1121
- initialState: initialState$v,
1122
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1052
+ initialState: initialState$D,
1053
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$D)),
1123
1054
  reducers: {
1124
1055
  initializeAssetTypes: assetTypeAdapter.initialize,
1125
1056
  setAssetType: assetTypeAdapter.setOne,
@@ -1172,11 +1103,11 @@ const assetTypeReducer = assetTypeSlice.reducer;
1172
1103
  const assetTypeAttachmentAdapter = createModelAdapter(
1173
1104
  (attachment) => attachment.offline_id
1174
1105
  );
1175
- const initialState$u = assetTypeAttachmentAdapter.getInitialState({});
1106
+ const initialState$C = assetTypeAttachmentAdapter.getInitialState({});
1176
1107
  const assetTypeAttachmentSlice = createSlice({
1177
1108
  name: "assetTypeAttachments",
1178
- initialState: initialState$u,
1179
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1109
+ initialState: initialState$C,
1110
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$C)),
1180
1111
  reducers: {
1181
1112
  initializeAssetTypeAttachments: assetTypeAttachmentAdapter.initialize,
1182
1113
  addAssetTypeAttachment: assetTypeAttachmentAdapter.addOne,
@@ -1223,11 +1154,11 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1223
1154
  const attachmentsOfAssetType = attachments.filter(({ asset_type }) => asset_type === assetTypeId);
1224
1155
  const fileAttachments = attachmentsOfAssetType.filter(
1225
1156
  // 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/")
1157
+ ({ file_type }) => !file_type.startsWith("image/")
1227
1158
  );
1228
1159
  const imageAttachments = attachmentsOfAssetType.filter(
1229
1160
  // 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/")
1161
+ ({ file_type }) => file_type.startsWith("image/")
1231
1162
  );
1232
1163
  return { fileAttachments, imageAttachments };
1233
1164
  }
@@ -1235,12 +1166,12 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1235
1166
  );
1236
1167
  const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
1237
1168
  const issueAdapter = createModelAdapter((issue) => issue.offline_id);
1238
- const initialState$t = issueAdapter.getInitialState({});
1169
+ const initialState$B = issueAdapter.getInitialState({});
1239
1170
  const issueSlice = createSlice({
1240
1171
  name: "issues",
1241
- initialState: initialState$t,
1172
+ initialState: initialState$B,
1242
1173
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1243
- Object.assign(state, initialState$t);
1174
+ Object.assign(state, initialState$B);
1244
1175
  }),
1245
1176
  reducers: {
1246
1177
  initializeIssues: issueAdapter.initialize,
@@ -1272,12 +1203,12 @@ const selectIssuesByIds = restructureCreateSelectorWithArgs(
1272
1203
  );
1273
1204
  const issueReducer = issueSlice.reducer;
1274
1205
  const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
1275
- const initialState$s = issueTypeAdapter.getInitialState({});
1206
+ const initialState$A = issueTypeAdapter.getInitialState({});
1276
1207
  const issueTypeSlice = createSlice({
1277
1208
  name: "issueTypes",
1278
- initialState: initialState$s,
1209
+ initialState: initialState$A,
1279
1210
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1280
- Object.assign(state, initialState$s);
1211
+ Object.assign(state, initialState$A);
1281
1212
  }),
1282
1213
  reducers: {
1283
1214
  initializeIssueTypes: issueTypeAdapter.initialize,
@@ -1334,15 +1265,15 @@ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
1334
1265
  return selectIssuesOfIssueType(issueTypeId)(state).length;
1335
1266
  };
1336
1267
  const issueTypeReducer = issueTypeSlice.reducer;
1337
- const initialState$r = {
1268
+ const initialState$z = {
1338
1269
  s3Urls: {}
1339
1270
  };
1340
1271
  const msPerHour = 1e3 * 60 * 60;
1341
1272
  const msPerWeek = msPerHour * 24 * 7;
1342
1273
  const fileSlice = createSlice({
1343
1274
  name: "file",
1344
- initialState: initialState$r,
1345
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1275
+ initialState: initialState$z,
1276
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
1346
1277
  reducers: {
1347
1278
  setUploadUrl: (state, action) => {
1348
1279
  const { url, fields, sha1 } = action.payload;
@@ -1364,19 +1295,18 @@ const selectUploadUrl = (sha1) => (state) => {
1364
1295
  }
1365
1296
  const today2 = (/* @__PURE__ */ new Date()).getTime();
1366
1297
  const expiringWithinAnHour = (url.exp ?? today2) - today2 < msPerHour;
1367
- if (expiringWithinAnHour)
1368
- return void 0;
1298
+ if (expiringWithinAnHour) return void 0;
1369
1299
  return url;
1370
1300
  };
1371
1301
  const fileReducer = fileSlice.reducer;
1372
- const initialState$q = {
1302
+ const initialState$y = {
1373
1303
  users: {},
1374
1304
  currentUser: null
1375
1305
  };
1376
1306
  const userSlice = createSlice({
1377
1307
  name: "users",
1378
- initialState: initialState$q,
1379
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1308
+ initialState: initialState$y,
1309
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
1380
1310
  reducers: {
1381
1311
  setUsers: (state, action) => {
1382
1312
  const usersMapping = {};
@@ -1394,8 +1324,7 @@ const userSlice = createSlice({
1394
1324
  state.currentUser = action.payload;
1395
1325
  },
1396
1326
  setProfilePicture: (state, action) => {
1397
- if (!state.currentUser)
1398
- return;
1327
+ if (!state.currentUser) return;
1399
1328
  state.currentUser.profile.file = action.payload.file ?? null;
1400
1329
  state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1401
1330
  const currentUser = state.users[state.currentUser.id];
@@ -1434,11 +1363,11 @@ const selectUsersByIds = restructureCreateSelectorWithArgs(
1434
1363
  const organizationAccessAdapter = createModelAdapter(
1435
1364
  (organizationAccess) => organizationAccess.offline_id
1436
1365
  );
1437
- const initialState$p = organizationAccessAdapter.getInitialState({});
1366
+ const initialState$x = organizationAccessAdapter.getInitialState({});
1438
1367
  const organizationAccessSlice = createSlice({
1439
1368
  name: "organizationAccess",
1440
- initialState: initialState$p,
1441
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1369
+ initialState: initialState$x,
1370
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1442
1371
  reducers: {
1443
1372
  initializeOrganizationAccesses: organizationAccessAdapter.initialize,
1444
1373
  updateOrganizationAccess: organizationAccessAdapter.updateOne,
@@ -1475,11 +1404,11 @@ const selectOrganizationAccessUserMapping = (state) => {
1475
1404
  };
1476
1405
  const organizationAccessReducer = organizationAccessSlice.reducer;
1477
1406
  const licenseAdapter = createModelAdapter((license) => license.offline_id);
1478
- const initialState$o = licenseAdapter.getInitialState({});
1407
+ const initialState$w = licenseAdapter.getInitialState({});
1479
1408
  const licenseSlice = createSlice({
1480
1409
  name: "license",
1481
- initialState: initialState$o,
1482
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1410
+ initialState: initialState$w,
1411
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1483
1412
  reducers: {
1484
1413
  initializeLicences: licenseAdapter.initialize,
1485
1414
  addLicenses: licenseAdapter.addMany,
@@ -1506,11 +1435,11 @@ const selectLicensesForProjectsMapping = createSelector(
1506
1435
  );
1507
1436
  const licenseReducer = licenseSlice.reducer;
1508
1437
  const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
1509
- const initialState$n = projectAccessAdapter.getInitialState({});
1438
+ const initialState$v = projectAccessAdapter.getInitialState({});
1510
1439
  const projectAccessSlice = createSlice({
1511
1440
  name: "projectAccess",
1512
- initialState: initialState$n,
1513
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1441
+ initialState: initialState$v,
1442
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1514
1443
  reducers: {
1515
1444
  initializeProjectAccesses: projectAccessAdapter.initialize,
1516
1445
  updateProjectAccess: projectAccessAdapter.updateOne,
@@ -1544,13 +1473,13 @@ const selectProjectAccessUserMapping = (state) => {
1544
1473
  return fallbackToEmptyObject(projectAccesses);
1545
1474
  };
1546
1475
  const projectAccessReducer = projectAccessSlice.reducer;
1547
- const initialState$m = {
1476
+ const initialState$u = {
1548
1477
  projects: {}
1549
1478
  };
1550
1479
  const projectSlice = createSlice({
1551
1480
  name: "projects",
1552
- initialState: initialState$m,
1553
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1481
+ initialState: initialState$u,
1482
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1554
1483
  reducers: {
1555
1484
  setProjects: (state, action) => {
1556
1485
  const projectsMap = {};
@@ -1611,13 +1540,13 @@ const selectSortedProjectUsers = createSelector(
1611
1540
  );
1612
1541
  }
1613
1542
  );
1614
- const initialState$l = {
1543
+ const initialState$t = {
1615
1544
  organizations: {}
1616
1545
  };
1617
1546
  const organizationSlice = createSlice({
1618
1547
  name: "organizations",
1619
- initialState: initialState$l,
1620
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1548
+ initialState: initialState$t,
1549
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$t)),
1621
1550
  reducers: {
1622
1551
  setOrganizations: (state, action) => {
1623
1552
  for (const org of action.payload) {
@@ -1712,14 +1641,14 @@ const createOfflineAction = (request2, baseUrl, serviceName) => {
1712
1641
  }
1713
1642
  };
1714
1643
  };
1715
- const initialState$k = {
1644
+ const initialState$s = {
1716
1645
  deletedRequests: [],
1717
1646
  latestRetryTime: 0
1718
1647
  };
1719
1648
  const outboxSlice = createSlice({
1720
1649
  name: "outbox",
1721
- initialState: initialState$k,
1722
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1650
+ initialState: initialState$s,
1651
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$s)),
1723
1652
  reducers: {
1724
1653
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
1725
1654
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -1739,8 +1668,7 @@ const outboxSlice = createSlice({
1739
1668
  },
1740
1669
  markAsDeleted(state, action) {
1741
1670
  const index = state.deletedRequests.indexOf(action.payload);
1742
- if (index !== -1)
1743
- state.deletedRequests.splice(index, 1);
1671
+ if (index !== -1) state.deletedRequests.splice(index, 1);
1744
1672
  },
1745
1673
  _setLatestRetryTime: (state, action) => {
1746
1674
  state.latestRetryTime = action.payload;
@@ -1752,14 +1680,14 @@ const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
1752
1680
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
1753
1681
  const outboxReducer = outboxSlice.reducer;
1754
1682
  const projectFileModelAdapter = createModelAdapter((projectFile) => projectFile.offline_id);
1755
- const initialState$j = projectFileModelAdapter.getInitialState({
1683
+ const initialState$r = projectFileModelAdapter.getInitialState({
1756
1684
  activeProjectFileId: null,
1757
1685
  isImportingProjectFile: false
1758
1686
  });
1759
1687
  const projectFileSlice = createSlice({
1760
1688
  name: "projectFiles",
1761
- initialState: initialState$j,
1762
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1689
+ initialState: initialState$r,
1690
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1763
1691
  reducers: {
1764
1692
  initializeProjectFiles: projectFileModelAdapter.initialize,
1765
1693
  setProjectFile: projectFileModelAdapter.setOne,
@@ -1824,11 +1752,11 @@ const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProj
1824
1752
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
1825
1753
  const projectFileReducer = projectFileSlice.reducer;
1826
1754
  const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
1827
- const initialState$i = projectAttachmentAdapter.getInitialState({});
1755
+ const initialState$q = projectAttachmentAdapter.getInitialState({});
1828
1756
  const projectAttachmentSlice = createSlice({
1829
1757
  name: "projectAttachments",
1830
- initialState: initialState$i,
1831
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1758
+ initialState: initialState$q,
1759
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1832
1760
  reducers: {
1833
1761
  initializeProjectAttachments: projectAttachmentAdapter.initialize,
1834
1762
  addProjectAttachment: projectAttachmentAdapter.addOne,
@@ -1872,23 +1800,23 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
1872
1800
  const attachmentsOfProject = attachments.filter(({ project }) => projectId === project);
1873
1801
  const fileAttachments = attachmentsOfProject.filter(
1874
1802
  // this null check here is necessary, there are cases where file_type is null or undefined
1875
- ({ file_type }) => !file_type || !file_type.startsWith("image/")
1803
+ ({ file_type }) => !file_type.startsWith("image/")
1876
1804
  );
1877
1805
  const imageAttachments = attachmentsOfProject.filter(
1878
1806
  // this null check here is necessary, there are cases where file_type is null or undefined
1879
- ({ file_type }) => file_type && file_type.startsWith("image/")
1807
+ ({ file_type }) => file_type.startsWith("image/")
1880
1808
  );
1881
1809
  return { fileAttachments, imageAttachments };
1882
1810
  }
1883
1811
  )
1884
1812
  );
1885
1813
  const projectAttachmentReducer = projectAttachmentSlice.reducer;
1886
- const initialState$h = {
1814
+ const initialState$p = {
1887
1815
  isRehydrated: false
1888
1816
  };
1889
1817
  const rehydratedSlice = createSlice({
1890
1818
  name: "rehydrated",
1891
- initialState: initialState$h,
1819
+ initialState: initialState$p,
1892
1820
  // The `reducers` field lets us define reducers and generate associated actions
1893
1821
  reducers: {
1894
1822
  setRehydrated: (state, action) => {
@@ -1913,11 +1841,11 @@ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
1913
1841
  }
1914
1842
  };
1915
1843
  const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
1916
- const initialState$g = formRevisionAdapter.getInitialState({});
1844
+ const initialState$o = formRevisionAdapter.getInitialState({});
1917
1845
  const formRevisionsSlice = createSlice({
1918
1846
  name: "formRevisions",
1919
- initialState: initialState$g,
1920
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
1847
+ initialState: initialState$o,
1848
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1921
1849
  reducers: {
1922
1850
  initializeFormRevisions: formRevisionAdapter.initialize,
1923
1851
  setFormRevision: formRevisionAdapter.setOne,
@@ -1960,8 +1888,7 @@ const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
1960
1888
  [selectFormRevisionMapping, (_state, formId) => formId],
1961
1889
  (revisions, formId) => {
1962
1890
  const revisionsOfForm = Object.values(revisions).filter((revision) => revision.form === formId);
1963
- if (revisionsOfForm.length === 0)
1964
- return void 0;
1891
+ if (revisionsOfForm.length === 0) return void 0;
1965
1892
  const sortedRevisions = revisionsOfForm.sort(formRevisionSortFn);
1966
1893
  const latestRevision = sortedRevisions[revisionsOfForm.length - 1];
1967
1894
  return revisions[latestRevision.offline_id];
@@ -1976,24 +1903,13 @@ const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
1976
1903
  }
1977
1904
  )
1978
1905
  );
1979
- const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping], (revisions) => {
1980
- const latestRevisions = {};
1981
- for (const revision of Object.values(revisions)) {
1982
- const formId = revision.form;
1983
- const currentLatestRevision = latestRevisions[formId];
1984
- if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
1985
- latestRevisions[formId] = revision;
1986
- }
1987
- }
1988
- return latestRevisions;
1989
- });
1990
1906
  const formRevisionReducer = formRevisionsSlice.reducer;
1991
1907
  const formAdapter = createModelAdapter((form) => form.offline_id);
1992
- const initialState$f = formAdapter.getInitialState({});
1908
+ const initialState$n = formAdapter.getInitialState({});
1993
1909
  const formSlice = createSlice({
1994
1910
  name: "forms",
1995
- initialState: initialState$f,
1996
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
1911
+ initialState: initialState$n,
1912
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1997
1913
  reducers: {
1998
1914
  initializeForms: formAdapter.initialize,
1999
1915
  setForm: formAdapter.setOne,
@@ -2011,6 +1927,9 @@ const selectFormMapping = (state) => {
2011
1927
  const selectForms = createSelector([selectFormMapping], (formsMapping) => {
2012
1928
  return Object.values(formsMapping);
2013
1929
  });
1930
+ const selectFormById = (formId) => (state) => {
1931
+ return state.formReducer.instances[formId];
1932
+ };
2014
1933
  const selectFilteredForms = restructureCreateSelectorWithArgs(
2015
1934
  createSelector(
2016
1935
  [
@@ -2033,40 +1952,15 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
2033
1952
  return [...regularMatches.slice(0, maxResults)];
2034
1953
  },
2035
1954
  // as the argument is an object, we check the first level of properties for equality
2036
- { memoizeOptions: { equalityCheck: shallowEqual } }
2037
- )
2038
- );
2039
- const selectFormById = (formId) => (state) => {
2040
- return state.formReducer.instances[formId];
2041
- };
2042
- const selectFormOfAssetType = restructureCreateSelectorWithArgs(
2043
- createSelector(
2044
- [selectFormMapping, (_state, assetTypeId) => assetTypeId],
2045
- (formsMapping, assetTypeId) => {
2046
- return Object.values(formsMapping).find((form) => form.asset_type === assetTypeId);
2047
- }
1955
+ { memoizeOptions: { resultEqualityCheck: shallowEqual } }
2048
1956
  )
2049
1957
  );
2050
- const selectFormOfIssueType = restructureCreateSelectorWithArgs(
2051
- createSelector(
2052
- [selectFormMapping, (_state, issueTypeId) => issueTypeId],
2053
- (formsMapping, issueTypeId) => {
2054
- return Object.values(formsMapping).find((form) => form.issue_type === issueTypeId);
2055
- }
2056
- )
2057
- );
2058
- const selectFormsCount = createSelector([selectFormMapping], (formsMapping) => {
2059
- return Object.keys(formsMapping).length;
2060
- });
2061
- const selectGeneralFormCount = createSelector([selectFormMapping], (formsMapping) => {
2062
- return Object.values(formsMapping).filter((form) => !form.asset_type).length;
2063
- });
2064
1958
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2065
- const initialState$e = submissionAdapter.getInitialState({});
1959
+ const initialState$m = submissionAdapter.getInitialState({});
2066
1960
  const formSubmissionSlice = createSlice({
2067
1961
  name: "formSubmissions",
2068
- initialState: initialState$e,
2069
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
1962
+ initialState: initialState$m,
1963
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
2070
1964
  reducers: {
2071
1965
  initializeFormSubmissions: submissionAdapter.initialize,
2072
1966
  setFormSubmission: submissionAdapter.setOne,
@@ -2112,8 +2006,7 @@ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
2112
2006
  (submissionsMapping, revisionMapping, formId) => {
2113
2007
  const revisionIds = /* @__PURE__ */ new Set();
2114
2008
  for (const revision of Object.values(revisionMapping)) {
2115
- if (revision.form !== formId)
2116
- continue;
2009
+ if (revision.form !== formId) continue;
2117
2010
  revisionIds.add(revision.offline_id);
2118
2011
  }
2119
2012
  return Object.values(submissionsMapping).filter(
@@ -2122,43 +2015,6 @@ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
2122
2015
  }
2123
2016
  )
2124
2017
  );
2125
- const selectFormSubmissionsByFormRevisions = createSelector([selectFormRevisionMapping, selectFormSubmissions], (revisions, submissions) => {
2126
- var _a2;
2127
- const submissionMapping = {};
2128
- for (const revisionId in revisions) {
2129
- submissionMapping[revisionId] = [];
2130
- }
2131
- for (const submission of submissions) {
2132
- (_a2 = submissionMapping[submission.form_revision]) == null ? void 0 : _a2.push(submission);
2133
- }
2134
- return submissionMapping;
2135
- });
2136
- const selectSortedFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
2137
- createSelector(
2138
- [
2139
- selectFormRevisionMapping,
2140
- selectFormSubmissionsByFormRevisions,
2141
- (_state, formId) => formId
2142
- ],
2143
- (revisionsMapping, submissionsByRevision, formId) => {
2144
- const submissionsByFormRevisions = {};
2145
- for (const revisionId in revisionsMapping) {
2146
- const revision = revisionsMapping[revisionId];
2147
- const submissionsOfRevision = submissionsByRevision[revisionId];
2148
- if (revision && submissionsOfRevision && revision.form === formId) {
2149
- submissionsByFormRevisions[revisionId] = submissionsOfRevision.sort(
2150
- (a, b) => a.submitted_at < b.submitted_at ? -1 : 1
2151
- );
2152
- }
2153
- }
2154
- return Object.entries(submissionsByFormRevisions).sort((a, b) => {
2155
- const aRevision = revisionsMapping[a[0]];
2156
- const bRevision = revisionsMapping[b[0]];
2157
- return formRevisionSortFn(aRevision, bRevision);
2158
- }).map(([_revisionId, submissions]) => submissions).flat();
2159
- }
2160
- )
2161
- );
2162
2018
  const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2163
2019
  createSelector(
2164
2020
  [selectFormSubmissions, (_state, issueId) => issueId],
@@ -2169,54 +2025,6 @@ const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2169
2025
  }
2170
2026
  )
2171
2027
  );
2172
- const selectAttachedFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2173
- createSelector(
2174
- [
2175
- (state) => state.issueReducer.instances,
2176
- (state) => state.formReducer.instances,
2177
- (state) => state.formRevisionReducer.instances,
2178
- (state) => state.formSubmissionReducer.instances,
2179
- (_state, issueId) => issueId
2180
- ],
2181
- (issues, forms, formRevisions, submissions, issueId) => {
2182
- const issue = issues[issueId];
2183
- if (!issue)
2184
- return [];
2185
- if (!issue.issue_type) {
2186
- return Object.values(submissions).filter((submission) => submission.issue === issueId);
2187
- }
2188
- const issueTypeForms = new Set(
2189
- Object.keys(forms).filter((formId) => forms[formId].issue_type === issue.issue_type)
2190
- );
2191
- const issueTypeFormRevisions = new Set(
2192
- Object.keys(formRevisions).filter(
2193
- (formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
2194
- )
2195
- );
2196
- return Object.values(submissions).filter(
2197
- (submission) => submission.issue === issueId && !issueTypeFormRevisions.has(submission.form_revision)
2198
- );
2199
- }
2200
- )
2201
- );
2202
- const selectFormSubmissionsByIssues = restructureCreateSelectorWithArgs(
2203
- createSelector(
2204
- [selectFormSubmissions, (_state, issueIds) => issueIds],
2205
- (submissions, issueIds) => {
2206
- var _a2;
2207
- const issueSubmissions = {};
2208
- for (const issueId of issueIds) {
2209
- issueSubmissions[issueId] = [];
2210
- }
2211
- for (const submission of submissions) {
2212
- if (submission.issue && issueIds.includes(submission.issue)) {
2213
- (_a2 = issueSubmissions[submission.issue]) == null ? void 0 : _a2.push(submission);
2214
- }
2215
- }
2216
- return issueSubmissions;
2217
- }
2218
- )
2219
- );
2220
2028
  const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2221
2029
  createSelector(
2222
2030
  [selectFormSubmissions, (_state, assetId) => assetId],
@@ -2227,62 +2035,15 @@ const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2227
2035
  }
2228
2036
  )
2229
2037
  );
2230
- const selectAttachedFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2231
- createSelector(
2232
- [
2233
- (state) => state.assetReducer.instances,
2234
- (state) => state.formReducer.instances,
2235
- (state) => state.formRevisionReducer.instances,
2236
- (state) => state.formSubmissionReducer.instances,
2237
- (_state, assetId) => assetId
2238
- ],
2239
- (assets, forms, formRevisions, submissions, assetId) => {
2240
- const asset = assets[assetId];
2241
- if (!asset)
2242
- return [];
2243
- if (!asset.asset_type) {
2244
- return Object.values(submissions).filter((submission) => submission.asset === assetId);
2245
- }
2246
- const issueTypeForms = new Set(
2247
- Object.keys(forms).filter((formId) => forms[formId].asset_type === asset.asset_type)
2248
- );
2249
- const issueTypeFormRevisions = new Set(
2250
- Object.keys(formRevisions).filter(
2251
- (formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
2252
- )
2253
- );
2254
- return Object.values(submissions).filter(
2255
- (submission) => submission.asset === assetId && !issueTypeFormRevisions.has(submission.form_revision)
2256
- );
2257
- }
2258
- )
2259
- );
2260
- const selectFormSubmissionsByAssets = createSelector(
2261
- [selectFormSubmissionsMapping, selectAssetsMapping],
2262
- (submissions, assets) => {
2263
- var _a2;
2264
- const assetSubmissionMapping = {};
2265
- for (const assetId in assets) {
2266
- assetSubmissionMapping[assetId] = [];
2267
- }
2268
- for (const submissionId in submissions) {
2269
- const submission = submissions[submissionId];
2270
- if (submission.asset) {
2271
- (_a2 = assetSubmissionMapping[submission.asset]) == null ? void 0 : _a2.push(submission);
2272
- }
2273
- }
2274
- return assetSubmissionMapping;
2275
- }
2276
- );
2277
2038
  const formSubmissionReducer = formSubmissionSlice.reducer;
2278
2039
  const formSubmissionAttachmentAdapter = createModelAdapter(
2279
2040
  (attachment) => attachment.offline_id
2280
2041
  );
2281
- const initialState$d = formSubmissionAttachmentAdapter.getInitialState({});
2042
+ const initialState$l = formSubmissionAttachmentAdapter.getInitialState({});
2282
2043
  const formSubmissionAttachmentSlice = createSlice({
2283
2044
  name: "formSubmissionAttachments",
2284
- initialState: initialState$d,
2285
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2045
+ initialState: initialState$l,
2046
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
2286
2047
  reducers: {
2287
2048
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2288
2049
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2325,7 +2086,9 @@ const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
2325
2086
  [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
2326
2087
  (attachmentsMapping, submissionId) => {
2327
2088
  return fallbackToEmptyArray(
2328
- Object.values(attachmentsMapping).filter((attachment) => attachment.submission === submissionId)
2089
+ Object.values(attachmentsMapping).filter(
2090
+ (attachment) => attachment.form_submission === submissionId
2091
+ )
2329
2092
  );
2330
2093
  }
2331
2094
  )
@@ -2334,11 +2097,11 @@ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
2334
2097
  const formRevisionAttachmentAdapter = createModelAdapter(
2335
2098
  (attachment) => attachment.offline_id
2336
2099
  );
2337
- const initialState$c = formRevisionAttachmentAdapter.getInitialState({});
2100
+ const initialState$k = formRevisionAttachmentAdapter.getInitialState({});
2338
2101
  const formRevisionAttachmentSlice = createSlice({
2339
2102
  name: "formRevisionAttachments",
2340
- initialState: initialState$c,
2341
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2103
+ initialState: initialState$k,
2104
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
2342
2105
  reducers: {
2343
2106
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2344
2107
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2370,17 +2133,17 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
2370
2133
  [selectFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
2371
2134
  (attachments, revisionId) => {
2372
2135
  return fallbackToEmptyArray(
2373
- Object.values(attachments).filter((attachment) => attachment.revision === revisionId)
2136
+ Object.values(attachments).filter((attachment) => attachment.form_revision === revisionId)
2374
2137
  );
2375
2138
  }
2376
2139
  )
2377
2140
  );
2378
2141
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2379
2142
  const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
2380
- const initialState$b = workspaceAdapter.getInitialState({});
2143
+ const initialState$j = workspaceAdapter.getInitialState({});
2381
2144
  const workspaceSlice = createSlice({
2382
2145
  name: "workspace",
2383
- initialState: initialState$b,
2146
+ initialState: initialState$j,
2384
2147
  reducers: {
2385
2148
  initializeWorkspaces: workspaceAdapter.initialize,
2386
2149
  setWorkspaces: workspaceAdapter.setMany,
@@ -2411,10 +2174,10 @@ const selectPermittedWorkspaceIds = createSelector(
2411
2174
  );
2412
2175
  const workspaceReducer = workspaceSlice.reducer;
2413
2176
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2414
- const initialState$a = emailDomainAdapter.getInitialState({});
2177
+ const initialState$i = emailDomainAdapter.getInitialState({});
2415
2178
  const emailDomainsSlice = createSlice({
2416
2179
  name: "emailDomains",
2417
- initialState: initialState$a,
2180
+ initialState: initialState$i,
2418
2181
  reducers: {
2419
2182
  initializeEmailDomains: emailDomainAdapter.initialize,
2420
2183
  addEmailDomain: emailDomainAdapter.addOne,
@@ -2435,14 +2198,14 @@ const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2435
2198
  )
2436
2199
  );
2437
2200
  const emailDomainsReducer = emailDomainsSlice.reducer;
2438
- const initialState$9 = {
2201
+ const initialState$h = {
2439
2202
  documents: {}
2440
2203
  };
2441
2204
  const documentSlice = createSlice({
2442
2205
  name: "documents",
2443
- initialState: initialState$9,
2206
+ initialState: initialState$h,
2444
2207
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2445
- Object.assign(state, initialState$9);
2208
+ Object.assign(state, initialState$h);
2446
2209
  }),
2447
2210
  reducers: {
2448
2211
  setDocuments: (state, action) => {
@@ -2615,8 +2378,7 @@ const selectAncestorIdsOfDocument = restructureCreateSelectorWithArgs(
2615
2378
  createSelector([selectDocumentsMapping, (_state, documentId) => documentId], (mapping, documentId) => {
2616
2379
  const listOfAncestors = [];
2617
2380
  const document2 = mapping[documentId];
2618
- if (!document2 || !document2.parent_document)
2619
- return listOfAncestors;
2381
+ if (!document2 || !document2.parent_document) return listOfAncestors;
2620
2382
  let currentAncestor = mapping[document2.parent_document];
2621
2383
  while (currentAncestor) {
2622
2384
  listOfAncestors.push(currentAncestor.offline_id);
@@ -2631,11 +2393,11 @@ const selectRootDocuments = createSelector(
2631
2393
  );
2632
2394
  const documentsReducer = documentSlice.reducer;
2633
2395
  const documentAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2634
- const initialState$8 = documentAttachmentAdapter.getInitialState({});
2396
+ const initialState$g = documentAttachmentAdapter.getInitialState({});
2635
2397
  const documentAttachmentSlice = createSlice({
2636
2398
  name: "documentAttachments",
2637
- initialState: initialState$8,
2638
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2399
+ initialState: initialState$g,
2400
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2639
2401
  reducers: {
2640
2402
  initializeDocumentAttachments: documentAttachmentAdapter.initialize,
2641
2403
  addDocumentAttachment: documentAttachmentAdapter.addOne,
@@ -2682,11 +2444,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
2682
2444
  const attachmentsOfProject = attachments.filter(({ document: document2 }) => documentId === document2);
2683
2445
  const fileAttachments = attachmentsOfProject.filter(
2684
2446
  // this null check here is necessary, there are cases where file_type is null or undefined
2685
- ({ file_type }) => !file_type || !file_type.startsWith("image/")
2447
+ ({ file_type }) => !file_type.startsWith("image/")
2686
2448
  );
2687
2449
  const imageAttachments = attachmentsOfProject.filter(
2688
2450
  // this null check here is necessary, there are cases where file_type is null or undefined
2689
- ({ file_type }) => file_type && file_type.startsWith("image/")
2451
+ ({ file_type }) => file_type.startsWith("image/")
2690
2452
  );
2691
2453
  return { fileAttachments, imageAttachments };
2692
2454
  }
@@ -2694,11 +2456,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
2694
2456
  );
2695
2457
  const documentAttachmentReducer = documentAttachmentSlice.reducer;
2696
2458
  const teamAdapter = createModelAdapter((team) => team.offline_id);
2697
- const initialState$7 = teamAdapter.getInitialState({});
2459
+ const initialState$f = teamAdapter.getInitialState({});
2698
2460
  const teamSlice = createSlice({
2699
2461
  name: "teams",
2700
- initialState: initialState$7,
2701
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2462
+ initialState: initialState$f,
2463
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2702
2464
  reducers: {
2703
2465
  setTeam: teamAdapter.setOne,
2704
2466
  initializeTeams: teamAdapter.initialize,
@@ -2749,11 +2511,11 @@ const teamReducer = teamSlice.reducer;
2749
2511
  const agentUserConversationAdapter = createModelAdapter(
2750
2512
  (conversation) => conversation.offline_id
2751
2513
  );
2752
- const initialState$6 = agentUserConversationAdapter.getInitialState({});
2514
+ const initialState$e = agentUserConversationAdapter.getInitialState({});
2753
2515
  const agentsSlice = createSlice({
2754
2516
  name: "agents",
2755
- initialState: initialState$6,
2756
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
2517
+ initialState: initialState$e,
2518
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2757
2519
  reducers: {
2758
2520
  initializeConversations: agentUserConversationAdapter.initialize,
2759
2521
  addConversation: agentUserConversationAdapter.addOne,
@@ -2775,11 +2537,11 @@ const selectConversation = restructureCreateSelectorWithArgs(
2775
2537
  );
2776
2538
  const agentsReducer = agentsSlice.reducer;
2777
2539
  const issueCommentAdapter = createModelAdapter((comment) => comment.offline_id);
2778
- const initialState$5 = issueCommentAdapter.getInitialState({});
2540
+ const initialState$d = issueCommentAdapter.getInitialState({});
2779
2541
  const issueCommentSlice = createSlice({
2780
2542
  name: "issueComments",
2781
- initialState: initialState$5,
2782
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
2543
+ initialState: initialState$d,
2544
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2783
2545
  reducers: {
2784
2546
  addIssueComment: issueCommentAdapter.addOne,
2785
2547
  addIssueComments: issueCommentAdapter.addMany,
@@ -2808,11 +2570,11 @@ const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
2808
2570
  );
2809
2571
  const issueCommentReducer = issueCommentSlice.reducer;
2810
2572
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
2811
- const initialState$4 = issueUpdateAdapter.getInitialState({});
2573
+ const initialState$c = issueUpdateAdapter.getInitialState({});
2812
2574
  const issueUpdateSlice = createSlice({
2813
2575
  name: "issueUpdates",
2814
- initialState: initialState$4,
2815
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
2576
+ initialState: initialState$c,
2577
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2816
2578
  reducers: {
2817
2579
  initializeIssueUpdates: issueUpdateAdapter.setMany,
2818
2580
  setIssueUpdate: issueUpdateAdapter.setOne,
@@ -2841,11 +2603,11 @@ const selectIssueUpdatesOfIssue = restructureCreateSelectorWithArgs(
2841
2603
  );
2842
2604
  const issueUpdateReducer = issueUpdateSlice.reducer;
2843
2605
  const issueAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2844
- const initialState$3 = issueAttachmentAdapter.getInitialState({});
2606
+ const initialState$b = issueAttachmentAdapter.getInitialState({});
2845
2607
  const issueAttachmentSlice = createSlice({
2846
2608
  name: "issueAttachments",
2847
- initialState: initialState$3,
2848
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
2609
+ initialState: initialState$b,
2610
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2849
2611
  reducers: {
2850
2612
  initializeIssueAttachments: issueAttachmentAdapter.initialize,
2851
2613
  addIssueAttachment: issueAttachmentAdapter.addOne,
@@ -2892,34 +2654,34 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
2892
2654
  const attachmentsOfIssue = attachments.filter(({ issue }) => issue === issueId);
2893
2655
  const fileAttachments = attachmentsOfIssue.filter(
2894
2656
  // this null check here is necessary, there are cases where file_type is null or undefined
2895
- ({ file_type }) => !file_type || !file_type.startsWith("image/")
2657
+ ({ file_type }) => !file_type.startsWith("image/")
2896
2658
  );
2897
2659
  const imageAttachments = attachmentsOfIssue.filter(
2898
2660
  // this null check here is necessary, there are cases where file_type is null or undefined
2899
- ({ file_type }) => file_type && file_type.startsWith("image/")
2661
+ ({ file_type }) => file_type.startsWith("image/")
2900
2662
  );
2901
2663
  return { fileAttachments, imageAttachments };
2902
2664
  }
2903
2665
  )
2904
2666
  );
2905
2667
  const issueAttachmentReducer = issueAttachmentSlice.reducer;
2906
- const initialState$2 = {
2668
+ const initialState$a = {
2907
2669
  version: 0
2908
2670
  };
2909
2671
  const versioningSlice = createSlice({
2910
2672
  name: "versioning",
2911
- initialState: initialState$2,
2673
+ initialState: initialState$a,
2912
2674
  reducers: {}
2913
2675
  });
2914
2676
  const versioningReducer = versioningSlice.reducer;
2915
2677
  const geoImageAdapter = createModelAdapter((model) => model.offline_id);
2916
- const initialState$1 = geoImageAdapter.getInitialState({});
2678
+ const initialState$9 = geoImageAdapter.getInitialState({});
2917
2679
  const geoImageSlice = createSlice({
2918
2680
  name: "geoImages",
2919
- initialState: initialState$1,
2681
+ initialState: initialState$9,
2920
2682
  extraReducers: (builder) => {
2921
2683
  builder.addCase("RESET", (state) => {
2922
- Object.assign(state, initialState$1);
2684
+ Object.assign(state, initialState$9);
2923
2685
  });
2924
2686
  },
2925
2687
  reducers: {
@@ -2959,11 +2721,11 @@ const selectGeoImagesOfProject = restructureCreateSelectorWithArgs(
2959
2721
  );
2960
2722
  const geoImageReducer = geoImageSlice.reducer;
2961
2723
  const issueAssociationAdapter = createModelAdapter((assoc) => assoc.offline_id);
2962
- const initialState = issueAssociationAdapter.getInitialState({});
2724
+ const initialState$8 = issueAssociationAdapter.getInitialState({});
2963
2725
  const issueAssociationSlice = createSlice({
2964
2726
  name: "issueAssociations",
2965
- initialState,
2966
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
2727
+ initialState: initialState$8,
2728
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2967
2729
  reducers: {
2968
2730
  initializeIssueAssociations: issueAssociationAdapter.initialize,
2969
2731
  addIssueAssociation: issueAssociationAdapter.addOne,
@@ -3021,35 +2783,458 @@ const selectIssueAssociationsOfAsset = restructureCreateSelectorWithArgs(
3021
2783
  )
3022
2784
  );
3023
2785
  const issueAssociationReducer = issueAssociationSlice.reducer;
3024
- let clientStore;
3025
- function setClientStore(store) {
3026
- clientStore = store;
3027
- }
3028
- function getClientStore() {
3029
- return clientStore;
3030
- }
3031
- let clientSDK;
3032
- function setClientSDK(sdkCtor) {
3033
- clientSDK = sdkCtor;
3034
- }
3035
- function getClientSDK() {
3036
- return clientSDK;
3037
- }
3038
- const CLASS_NAME_TO_SERVICE = {};
3039
- class BaseService {
3040
- constructor(sdk) {
3041
- __publicField(this, "client");
3042
- CLASS_NAME_TO_SERVICE[this.constructor.name] = this;
3043
- this.client = sdk;
3044
- }
3045
- async enqueueRequest(requestDetails) {
3046
- return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
3047
- }
3048
- dispatch(action) {
3049
- this.client.store.dispatch(action);
2786
+ const issueTypeFieldValuesAdapter = createModelAdapter(
2787
+ (fieldValues) => fieldValues.offline_id
2788
+ );
2789
+ const initialState$7 = issueTypeFieldValuesAdapter.getInitialState({});
2790
+ const issueTypeFieldValuesSlice = createSlice({
2791
+ name: "issueTypeFieldValues",
2792
+ initialState: initialState$7,
2793
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2794
+ reducers: {
2795
+ initializeIssueTypeFieldValues: issueTypeFieldValuesAdapter.initialize,
2796
+ addIssueTypeFieldValues: issueTypeFieldValuesAdapter.addOne,
2797
+ addIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.addMany,
2798
+ setIssueTypeFieldValues: issueTypeFieldValuesAdapter.setOne,
2799
+ setIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.setMany,
2800
+ updateIssueTypeFieldValues: issueTypeFieldValuesAdapter.updateOne,
2801
+ updateIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.updateMany,
2802
+ deleteIssueTypeFieldValues: issueTypeFieldValuesAdapter.deleteOne,
2803
+ deleteIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.deleteMany
3050
2804
  }
3051
- }
3052
- const VERSION_REDUCER_KEY = "versioning";
2805
+ });
2806
+ const {
2807
+ initializeIssueTypeFieldValues,
2808
+ addIssueTypeFieldValues,
2809
+ addIssueTypeFieldValuesMany,
2810
+ setIssueTypeFieldValues,
2811
+ setIssueTypeFieldValuesMany,
2812
+ updateIssueTypeFieldValues,
2813
+ updateIssueTypeFieldValuesMany,
2814
+ deleteIssueTypeFieldValues,
2815
+ deleteIssueTypeFieldValuesMany
2816
+ } = issueTypeFieldValuesSlice.actions;
2817
+ const selectIssueTypeFieldValuesMapping = (state) => state.issueTypeFieldValuesReducer.instances;
2818
+ const selectIssueTypeFieldValues = createSelector([selectIssueTypeFieldValuesMapping], (fieldValuesMapping) => {
2819
+ return Object.values(fieldValuesMapping);
2820
+ });
2821
+ const selectIssueTypeFieldValuesOfIssue = restructureCreateSelectorWithArgs(
2822
+ createSelector([selectIssueTypeFieldValues, (_state, issueId) => issueId], (fieldValues, issueId) => {
2823
+ return fallbackToEmptyArray(fieldValues.filter((fieldValue) => fieldValue.issue === issueId));
2824
+ })
2825
+ );
2826
+ const selectIssueTypeFieldValuesById = (fieldValuesId) => (state) => {
2827
+ return state.issueTypeFieldValuesReducer.instances[fieldValuesId];
2828
+ };
2829
+ const issueTypeFieldValuesReducer = issueTypeFieldValuesSlice.reducer;
2830
+ const issueTypeFieldsAdapter = createModelAdapter((fields) => fields.offline_id);
2831
+ const initialState$6 = issueTypeFieldsAdapter.getInitialState({});
2832
+ const issueTypeFieldsSlice = createSlice({
2833
+ name: "issueTypeFields",
2834
+ initialState: initialState$6,
2835
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
2836
+ reducers: {
2837
+ initializeIssueTypeFields: issueTypeFieldsAdapter.initialize,
2838
+ addIssueTypeFields: issueTypeFieldsAdapter.addOne,
2839
+ addIssueTypeFieldsMany: issueTypeFieldsAdapter.addMany,
2840
+ setIssueTypeFields: issueTypeFieldsAdapter.setOne,
2841
+ setIssueTypeFieldsMany: issueTypeFieldsAdapter.setMany,
2842
+ updateIssueTypeFields: issueTypeFieldsAdapter.updateOne,
2843
+ updateIssueTypeFieldsMany: issueTypeFieldsAdapter.updateMany,
2844
+ deleteIssueTypeFields: issueTypeFieldsAdapter.deleteOne,
2845
+ deleteIssueTypeFieldsMany: issueTypeFieldsAdapter.deleteMany
2846
+ }
2847
+ });
2848
+ const {
2849
+ initializeIssueTypeFields,
2850
+ addIssueTypeFields,
2851
+ addIssueTypeFieldsMany,
2852
+ setIssueTypeFields,
2853
+ setIssueTypeFieldsMany,
2854
+ updateIssueTypeFields,
2855
+ updateIssueTypeFieldsMany,
2856
+ deleteIssueTypeFields,
2857
+ deleteIssueTypeFieldsMany
2858
+ } = issueTypeFieldsSlice.actions;
2859
+ const selectIssueTypeFieldsMapping = (state) => state.issueTypeFieldsReducer.instances;
2860
+ const selectIssueTypeFields = createSelector([selectIssueTypeFieldsMapping], (fieldsMapping) => {
2861
+ return Object.values(fieldsMapping);
2862
+ });
2863
+ const selectIssueTypeFieldsOfIssueType = restructureCreateSelectorWithArgs(
2864
+ createSelector([selectIssueTypeFields, (_state, issueTypeId) => issueTypeId], (fields, issueTypeId) => {
2865
+ return fallbackToEmptyArray(fields.filter((field) => field.issue_type === issueTypeId));
2866
+ })
2867
+ );
2868
+ const selectLatestIssueTypeFieldsOfIssueType = restructureCreateSelectorWithArgs(
2869
+ createSelector([selectIssueTypeFields, (_state, id) => id], (fields, id) => {
2870
+ return fields.filter((field) => field.issue_type === id).sort((a, b) => a.submitted_at > b.submitted_at ? -1 : 1)[0];
2871
+ })
2872
+ );
2873
+ const selectIssueTypeValuesOfIssueType = restructureCreateSelectorWithArgs(
2874
+ createSelector(
2875
+ [selectIssueTypeFields, selectIssueTypeFieldValues, (_state, id) => id],
2876
+ (fields, fieldValues, id) => {
2877
+ const fieldsIds = new Set(
2878
+ fields.filter((field) => field.issue_type === id).map((field) => field.offline_id)
2879
+ );
2880
+ return fallbackToEmptyArray(fieldValues.filter((values) => fieldsIds.has(values.fields_revision)));
2881
+ }
2882
+ )
2883
+ );
2884
+ const selectIssueTypeFieldsById = (fieldsId) => (state) => {
2885
+ return state.issueTypeFieldsReducer.instances[fieldsId];
2886
+ };
2887
+ const issueTypeFieldsReducer = issueTypeFieldsSlice.reducer;
2888
+ const issueTypeFieldsAttachmentAdapter = createModelAdapter(
2889
+ (attachment) => attachment.offline_id
2890
+ );
2891
+ const initialState$5 = issueTypeFieldsAttachmentAdapter.getInitialState({});
2892
+ const issueTypeFieldsAttachmentSlice = createSlice({
2893
+ name: "issueTypeFieldsAttachments",
2894
+ initialState: initialState$5,
2895
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
2896
+ reducers: {
2897
+ initializeIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.initialize,
2898
+ addIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.addOne,
2899
+ addIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.addMany,
2900
+ setIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.setOne,
2901
+ setIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.setMany,
2902
+ updateIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.updateOne,
2903
+ updateIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.updateMany,
2904
+ deleteIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.deleteOne,
2905
+ deleteIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.deleteMany
2906
+ }
2907
+ });
2908
+ const {
2909
+ initializeIssueTypeFieldsAttachments,
2910
+ addIssueTypeFieldsAttachment,
2911
+ addIssueTypeFieldsAttachments,
2912
+ setIssueTypeFieldsAttachment,
2913
+ setIssueTypeFieldsAttachments,
2914
+ updateIssueTypeFieldsAttachment,
2915
+ updateIssueTypeFieldsAttachments,
2916
+ deleteIssueTypeFieldsAttachment,
2917
+ deleteIssueTypeFieldsAttachments
2918
+ } = issueTypeFieldsAttachmentSlice.actions;
2919
+ const selectIssueTypeFieldsAttachmentsMapping = (state) => state.issueTypeFieldsAttachmentReducer.instances;
2920
+ const selectIssueTypeFieldsAttachments = createSelector(
2921
+ [selectIssueTypeFieldsAttachmentsMapping],
2922
+ (attachmentsMapping) => {
2923
+ return Object.values(attachmentsMapping);
2924
+ }
2925
+ );
2926
+ const selectAttachmentsOfIssueTypeFields = restructureCreateSelectorWithArgs(
2927
+ createSelector(
2928
+ [selectIssueTypeFieldsAttachments, (_state, fieldsRevision) => fieldsRevision],
2929
+ (attachments, fieldsRevision) => {
2930
+ return fallbackToEmptyArray(
2931
+ attachments.filter((attachment) => attachment.fields_revision === fieldsRevision)
2932
+ );
2933
+ }
2934
+ )
2935
+ );
2936
+ const selectIssueTypeFieldsAttachmentById = (attachmentId) => (state) => {
2937
+ return state.issueTypeFieldsAttachmentReducer.instances[attachmentId];
2938
+ };
2939
+ const issueTypeFieldsAttachmentReducer = issueTypeFieldsAttachmentSlice.reducer;
2940
+ const issueTypeFieldValuesAttachmentAdapter = createModelAdapter(
2941
+ (attachment) => attachment.offline_id
2942
+ );
2943
+ const initialState$4 = issueTypeFieldValuesAttachmentAdapter.getInitialState({});
2944
+ const issueTypeFieldValuesAttachmentSlice = createSlice({
2945
+ name: "issueTypeFieldValuesAttachments",
2946
+ initialState: initialState$4,
2947
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
2948
+ reducers: {
2949
+ initializeIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.initialize,
2950
+ addIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.addOne,
2951
+ addIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.addMany,
2952
+ setIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.setOne,
2953
+ setIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.setMany,
2954
+ updateIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.updateOne,
2955
+ updateIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.updateMany,
2956
+ deleteIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.deleteOne,
2957
+ deleteIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.deleteMany
2958
+ }
2959
+ });
2960
+ const {
2961
+ initializeIssueTypeFieldValuesAttachments,
2962
+ addIssueTypeFieldValuesAttachment,
2963
+ addIssueTypeFieldValuesAttachments,
2964
+ setIssueTypeFieldValuesAttachment,
2965
+ setIssueTypeFieldValuesAttachments,
2966
+ updateIssueTypeFieldValuesAttachment,
2967
+ updateIssueTypeFieldValuesAttachments,
2968
+ deleteIssueTypeFieldValuesAttachment,
2969
+ deleteIssueTypeFieldValuesAttachments
2970
+ } = issueTypeFieldValuesAttachmentSlice.actions;
2971
+ const selectIssueTypeFieldValuesAttachmentsMapping = (state) => state.issueTypeFieldValuesAttachmentReducer.instances;
2972
+ const selectIssueTypeFieldValuesAttachments = createSelector(
2973
+ [selectIssueTypeFieldValuesAttachmentsMapping],
2974
+ (attachmentsMapping) => {
2975
+ return Object.values(attachmentsMapping);
2976
+ }
2977
+ );
2978
+ const selectIssueTypeFieldValuesAttachmentById = (attachmentId) => (state) => {
2979
+ return state.issueTypeFieldValuesAttachmentReducer.instances[attachmentId];
2980
+ };
2981
+ const selectIssueTypeFieldValuesAttachmentsByIds = restructureCreateSelectorWithArgs(
2982
+ createSelector(
2983
+ [selectIssueTypeFieldValuesAttachmentsMapping, (_, attachmentIds) => attachmentIds],
2984
+ (mapping, attachmentIds) => {
2985
+ const attachmentIdsSet = new Set(attachmentIds);
2986
+ return fallbackToEmptyArray(
2987
+ Object.values(mapping).filter((attachment) => attachmentIdsSet.has(attachment.offline_id))
2988
+ );
2989
+ }
2990
+ )
2991
+ );
2992
+ const selectAttachmentsOfIssueTypeFieldValues = restructureCreateSelectorWithArgs(
2993
+ createSelector(
2994
+ [selectIssueTypeFieldValuesAttachments, (_state, fieldValuesId) => fieldValuesId],
2995
+ (attachments, fieldValuesId) => {
2996
+ return fallbackToEmptyArray(attachments.filter((attachment) => attachment.field_values === fieldValuesId));
2997
+ }
2998
+ )
2999
+ );
3000
+ const issueTypeFieldValuesAttachmentReducer = issueTypeFieldValuesAttachmentSlice.reducer;
3001
+ const assetTypeFieldsAdapter = createModelAdapter((fields) => fields.offline_id);
3002
+ const initialState$3 = assetTypeFieldsAdapter.getInitialState({});
3003
+ const assetTypeFieldsSlice = createSlice({
3004
+ name: "assetTypeFields",
3005
+ initialState: initialState$3,
3006
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3007
+ reducers: {
3008
+ initializeAssetTypeFields: assetTypeFieldsAdapter.initialize,
3009
+ addAssetTypeFields: assetTypeFieldsAdapter.addOne,
3010
+ addAssetTypeFieldsMany: assetTypeFieldsAdapter.addMany,
3011
+ setAssetTypeFields: assetTypeFieldsAdapter.setOne,
3012
+ setAssetTypeFieldsMany: assetTypeFieldsAdapter.setMany,
3013
+ updateAssetTypeFields: assetTypeFieldsAdapter.updateOne,
3014
+ updateAssetTypeFieldsMany: assetTypeFieldsAdapter.updateMany,
3015
+ deleteAssetTypeFields: assetTypeFieldsAdapter.deleteOne,
3016
+ deleteAssetTypeFieldsMany: assetTypeFieldsAdapter.deleteMany
3017
+ }
3018
+ });
3019
+ const {
3020
+ initializeAssetTypeFields,
3021
+ addAssetTypeFields,
3022
+ addAssetTypeFieldsMany,
3023
+ setAssetTypeFields,
3024
+ setAssetTypeFieldsMany,
3025
+ updateAssetTypeFields,
3026
+ updateAssetTypeFieldsMany,
3027
+ deleteAssetTypeFields,
3028
+ deleteAssetTypeFieldsMany
3029
+ } = assetTypeFieldsSlice.actions;
3030
+ const selectAssetTypeFieldsMapping = (state) => state.assetTypeFieldsReducer.instances;
3031
+ const selectAssetTypeFields = createSelector([selectAssetTypeFieldsMapping], (fieldsMapping) => {
3032
+ return Object.values(fieldsMapping);
3033
+ });
3034
+ const selectAssetTypeFieldsOfAssetType = restructureCreateSelectorWithArgs(
3035
+ createSelector([selectAssetTypeFields, (_state, assetTypeId) => assetTypeId], (fields, assetTypeId) => {
3036
+ return fallbackToEmptyArray(fields.filter((field) => field.asset_type === assetTypeId));
3037
+ })
3038
+ );
3039
+ const selectLatestAssetTypeFieldsOfAssetType = restructureCreateSelectorWithArgs(
3040
+ createSelector([selectAssetTypeFields, (_state, id) => id], (fields, id) => {
3041
+ return fields.filter((field) => field.asset_type === id).sort((a, b) => a.submitted_at > b.submitted_at ? -1 : 1)[0];
3042
+ })
3043
+ );
3044
+ const selectAssetTypeFieldsById = (fieldsId) => (state) => {
3045
+ return state.assetTypeFieldsReducer.instances[fieldsId];
3046
+ };
3047
+ const assetTypeFieldsReducer = assetTypeFieldsSlice.reducer;
3048
+ const assetTypeFieldValuesAdapter = createModelAdapter(
3049
+ (fieldValues) => fieldValues.offline_id
3050
+ );
3051
+ const initialState$2 = assetTypeFieldValuesAdapter.getInitialState({});
3052
+ const assetTypeFieldValuesSlice = createSlice({
3053
+ name: "assetTypeFieldValues",
3054
+ initialState: initialState$2,
3055
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
3056
+ reducers: {
3057
+ initializeAssetTypeFieldValues: assetTypeFieldValuesAdapter.initialize,
3058
+ addAssetTypeFieldValues: assetTypeFieldValuesAdapter.addOne,
3059
+ addAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.addMany,
3060
+ setAssetTypeFieldValues: assetTypeFieldValuesAdapter.setOne,
3061
+ setAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.setMany,
3062
+ updateAssetTypeFieldValues: assetTypeFieldValuesAdapter.updateOne,
3063
+ updateAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.updateMany,
3064
+ deleteAssetTypeFieldValues: assetTypeFieldValuesAdapter.deleteOne,
3065
+ deleteAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.deleteMany
3066
+ }
3067
+ });
3068
+ const {
3069
+ initializeAssetTypeFieldValues,
3070
+ addAssetTypeFieldValues,
3071
+ addAssetTypeFieldValuesMany,
3072
+ setAssetTypeFieldValues,
3073
+ setAssetTypeFieldValuesMany,
3074
+ updateAssetTypeFieldValues,
3075
+ updateAssetTypeFieldValuesMany,
3076
+ deleteAssetTypeFieldValues,
3077
+ deleteAssetTypeFieldValuesMany
3078
+ } = assetTypeFieldValuesSlice.actions;
3079
+ const selectAssetTypeFieldValuesMapping = (state) => state.assetTypeFieldValuesReducer.instances;
3080
+ const selectAssetTypeFieldValues = createSelector([selectAssetTypeFieldValuesMapping], (fieldValuesMapping) => {
3081
+ return Object.values(fieldValuesMapping);
3082
+ });
3083
+ const selectAssetTypeFieldValuesOfAsset = restructureCreateSelectorWithArgs(
3084
+ createSelector([selectAssetTypeFieldValues, (_state, assetId) => assetId], (fieldValues, assetId) => {
3085
+ return fallbackToEmptyArray(fieldValues.filter((fieldValue) => fieldValue.asset === assetId));
3086
+ })
3087
+ );
3088
+ const selectAssetTypeValuesOfAssetType = restructureCreateSelectorWithArgs(
3089
+ createSelector(
3090
+ [selectAssetTypeFields, selectAssetTypeFieldValues, (_state, id) => id],
3091
+ (fields, fieldValues, id) => {
3092
+ const fieldsIds = new Set(
3093
+ fields.filter((field) => field.asset_type === id).map((field) => field.offline_id)
3094
+ );
3095
+ return fallbackToEmptyArray(fieldValues.filter((values) => fieldsIds.has(values.fields_revision)));
3096
+ }
3097
+ )
3098
+ );
3099
+ const selectAssetTypeFieldValuesById = (fieldValuesId) => (state) => {
3100
+ return state.assetTypeFieldValuesReducer.instances[fieldValuesId];
3101
+ };
3102
+ const assetTypeFieldValuesReducer = assetTypeFieldValuesSlice.reducer;
3103
+ const assetTypeFieldsAttachmentAdapter = createModelAdapter(
3104
+ (attachment) => attachment.offline_id
3105
+ );
3106
+ const initialState$1 = assetTypeFieldsAttachmentAdapter.getInitialState({});
3107
+ const assetTypeFieldsAttachmentSlice = createSlice({
3108
+ name: "assetTypeFieldsAttachments",
3109
+ initialState: initialState$1,
3110
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
3111
+ reducers: {
3112
+ initializeAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.initialize,
3113
+ addAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.addOne,
3114
+ addAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.addMany,
3115
+ setAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.setOne,
3116
+ setAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.setMany,
3117
+ updateAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.updateOne,
3118
+ updateAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.updateMany,
3119
+ deleteAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.deleteOne,
3120
+ deleteAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.deleteMany
3121
+ }
3122
+ });
3123
+ const {
3124
+ initializeAssetTypeFieldsAttachments,
3125
+ addAssetTypeFieldsAttachment,
3126
+ addAssetTypeFieldsAttachments,
3127
+ setAssetTypeFieldsAttachment,
3128
+ setAssetTypeFieldsAttachments,
3129
+ updateAssetTypeFieldsAttachment,
3130
+ updateAssetTypeFieldsAttachments,
3131
+ deleteAssetTypeFieldsAttachment,
3132
+ deleteAssetTypeFieldsAttachments
3133
+ } = assetTypeFieldsAttachmentSlice.actions;
3134
+ const selectAssetTypeFieldsAttachmentsMapping = (state) => state.assetTypeFieldsAttachmentReducer.instances;
3135
+ const selectAssetTypeFieldsAttachments = createSelector(
3136
+ [selectAssetTypeFieldsAttachmentsMapping],
3137
+ (attachmentsMapping) => {
3138
+ return Object.values(attachmentsMapping);
3139
+ }
3140
+ );
3141
+ const selectAttachmentsOfAssetTypeFields = restructureCreateSelectorWithArgs(
3142
+ createSelector([selectAssetTypeFieldsAttachments, (_state, id) => id], (attachments, id) => {
3143
+ return fallbackToEmptyArray(attachments.filter((attachment) => attachment.fields_revision === id));
3144
+ })
3145
+ );
3146
+ const selectAssetTypeFieldsAttachmentById = (attachmentId) => (state) => {
3147
+ return state.assetTypeFieldsAttachmentReducer.instances[attachmentId];
3148
+ };
3149
+ const assetTypeFieldsAttachmentReducer = assetTypeFieldsAttachmentSlice.reducer;
3150
+ const assetTypeFieldValuesAttachmentAdapter = createModelAdapter(
3151
+ (attachment) => attachment.offline_id
3152
+ );
3153
+ const initialState = assetTypeFieldValuesAttachmentAdapter.getInitialState({});
3154
+ const assetTypeFieldValuesAttachmentSlice = createSlice({
3155
+ name: "assetTypeFieldValuesAttachments",
3156
+ initialState,
3157
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
3158
+ reducers: {
3159
+ initializeAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.initialize,
3160
+ addAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.addOne,
3161
+ addAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.addMany,
3162
+ setAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.setOne,
3163
+ setAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.setMany,
3164
+ updateAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.updateOne,
3165
+ updateAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.updateMany,
3166
+ deleteAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.deleteOne,
3167
+ deleteAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.deleteMany
3168
+ }
3169
+ });
3170
+ const {
3171
+ initializeAssetTypeFieldValuesAttachments,
3172
+ addAssetTypeFieldValuesAttachment,
3173
+ addAssetTypeFieldValuesAttachments,
3174
+ setAssetTypeFieldValuesAttachment,
3175
+ setAssetTypeFieldValuesAttachments,
3176
+ updateAssetTypeFieldValuesAttachment,
3177
+ updateAssetTypeFieldValuesAttachments,
3178
+ deleteAssetTypeFieldValuesAttachment,
3179
+ deleteAssetTypeFieldValuesAttachments
3180
+ } = assetTypeFieldValuesAttachmentSlice.actions;
3181
+ const selectAssetTypeFieldValuesAttachmentsMapping = (state) => state.assetTypeFieldValuesAttachmentReducer.instances;
3182
+ const selectAssetTypeFieldValuesAttachments = createSelector(
3183
+ [selectAssetTypeFieldValuesAttachmentsMapping],
3184
+ (attachmentsMapping) => {
3185
+ return Object.values(attachmentsMapping);
3186
+ }
3187
+ );
3188
+ const selectAssetTypeFieldValuesAttachmentById = (attachmentId) => (state) => {
3189
+ return state.assetTypeFieldValuesAttachmentReducer.instances[attachmentId];
3190
+ };
3191
+ const selectAssetTypeFieldValuesAttachmentsByIds = restructureCreateSelectorWithArgs(
3192
+ createSelector(
3193
+ [selectAssetTypeFieldValuesAttachmentsMapping, (_, attachmentIds) => attachmentIds],
3194
+ (mapping, attachmentIds) => {
3195
+ const attachmentIdsSet = new Set(attachmentIds);
3196
+ return fallbackToEmptyArray(
3197
+ Object.values(mapping).filter((attachment) => attachmentIdsSet.has(attachment.offline_id))
3198
+ );
3199
+ }
3200
+ )
3201
+ );
3202
+ const selectAttachmentsOfAssetTypeFieldValues = restructureCreateSelectorWithArgs(
3203
+ createSelector([selectAssetTypeFieldValuesAttachments, (_state, id) => id], (attachments, id) => {
3204
+ return fallbackToEmptyArray(attachments.filter((attachment) => attachment.field_values === id));
3205
+ })
3206
+ );
3207
+ const assetTypeFieldValuesAttachmentReducer = assetTypeFieldValuesAttachmentSlice.reducer;
3208
+ let clientStore;
3209
+ function setClientStore(store) {
3210
+ clientStore = store;
3211
+ }
3212
+ function getClientStore() {
3213
+ return clientStore;
3214
+ }
3215
+ let clientSDK;
3216
+ function setClientSDK(sdkCtor) {
3217
+ clientSDK = sdkCtor;
3218
+ }
3219
+ function getClientSDK() {
3220
+ return clientSDK;
3221
+ }
3222
+ const CLASS_NAME_TO_SERVICE = {};
3223
+ class BaseService {
3224
+ constructor(sdk) {
3225
+ __publicField(this, "client");
3226
+ CLASS_NAME_TO_SERVICE[this.constructor.name] = this;
3227
+ this.client = sdk;
3228
+ }
3229
+ async enqueueRequest(requestDetails) {
3230
+ return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
3231
+ }
3232
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3233
+ dispatch(action) {
3234
+ this.client.store.dispatch(action);
3235
+ }
3236
+ }
3237
+ const VERSION_REDUCER_KEY = "versioning";
3053
3238
  const overmapReducers = {
3054
3239
  // TODO: attachmentReducer,
3055
3240
  [VERSION_REDUCER_KEY]: versioningReducer,
@@ -3089,7 +3274,15 @@ const overmapReducers = {
3089
3274
  issueCommentReducer,
3090
3275
  issueUpdateReducer,
3091
3276
  geoImageReducer,
3092
- issueAssociationReducer
3277
+ issueAssociationReducer,
3278
+ issueTypeFieldsReducer,
3279
+ issueTypeFieldValuesReducer,
3280
+ issueTypeFieldsAttachmentReducer,
3281
+ issueTypeFieldValuesAttachmentReducer,
3282
+ assetTypeFieldsReducer,
3283
+ assetTypeFieldValuesReducer,
3284
+ assetTypeFieldsAttachmentReducer,
3285
+ assetTypeFieldValuesAttachmentReducer
3093
3286
  };
3094
3287
  const overmapReducer = combineReducers(overmapReducers);
3095
3288
  const resetStore = "RESET";
@@ -3114,9 +3307,8 @@ function getOutboxCoordinator() {
3114
3307
  __OUTBOX_COORDINATOR = coordinator;
3115
3308
  return coordinator;
3116
3309
  }
3117
- const persistCallback = (err) => {
3118
- if (err)
3119
- throw err;
3310
+ const persistCallback = (e) => {
3311
+ if (e) throw e;
3120
3312
  const clientStore2 = getClientStore();
3121
3313
  if (clientStore2) {
3122
3314
  clientStore2.dispatch({ type: "rehydrated/setRehydrated", payload: true });
@@ -3180,14 +3372,11 @@ function extractResponseFromError(error) {
3180
3372
  const knownKeys = ["ok", "redirect", "clientError", "serverError", "error"];
3181
3373
  return typeof response === "object" && response !== null && knownKeys.every((key) => key in response);
3182
3374
  }
3183
- if (isResponse(error))
3184
- return error;
3375
+ if (isResponse(error)) return error;
3185
3376
  if (typeof error === "object" && error !== null) {
3186
3377
  const typedError = error;
3187
- if (isResponse(typedError.response))
3188
- return typedError.response;
3189
- if (typedError.response && isResponse(typedError.response.response))
3190
- return typedError.response.response;
3378
+ if (isResponse(typedError.response)) return typedError.response;
3379
+ if (typedError.response && isResponse(typedError.response.response)) return typedError.response.response;
3191
3380
  }
3192
3381
  return void 0;
3193
3382
  }
@@ -3228,15 +3417,11 @@ async function performRequest(action, client) {
3228
3417
  const addPayload = (req) => {
3229
3418
  if (attachmentHash) {
3230
3419
  const s3url = requestDetails.s3url;
3231
- if (!s3url)
3232
- throw new Error(`No S3 URL for file ${attachmentHash}`);
3233
- if ("warning" in s3url)
3234
- throw new Error(`S3 URL warning for file ${attachmentHash}`);
3235
- if (!file)
3236
- throw new Error(`No file for file ${attachmentHash}`);
3420
+ if (!s3url) throw new Error(`No S3 URL for file ${attachmentHash}`);
3421
+ if ("warning" in s3url) throw new Error(`S3 URL warning for file ${attachmentHash}`);
3422
+ if (!file) throw new Error(`No file for file ${attachmentHash}`);
3237
3423
  const s3Sha1Checksum = s3url.fields["x-amz-checksum-sha1"];
3238
- if (!s3Sha1Checksum)
3239
- throw new Error(`No checksum for file ${attachmentHash}`);
3424
+ if (!s3Sha1Checksum) throw new Error(`No checksum for file ${attachmentHash}`);
3240
3425
  return req.set("x-amz-checksum-sha1", s3Sha1Checksum).field({ ...payload, ...s3url.fields }).attach("file", file);
3241
3426
  }
3242
3427
  return req.send(payload);
@@ -3296,8 +3481,7 @@ class MiddlewareChainerPrivate {
3296
3481
  this.compile = this.compile.bind(this);
3297
3482
  }
3298
3483
  then(next) {
3299
- if (this._previous)
3300
- this._previous.next = next;
3484
+ if (this._previous) this._previous.next = next;
3301
3485
  this._all.push(next);
3302
3486
  this._previous = next;
3303
3487
  return {
@@ -3325,11 +3509,9 @@ class OfflineMiddleware {
3325
3509
  } else {
3326
3510
  console.debug("Middleware finished. Performing request:", action);
3327
3511
  const clientStore2 = getClientStore();
3328
- if (!clientStore2)
3329
- throw new Error("Client store not set");
3512
+ if (!clientStore2) throw new Error("Client store not set");
3330
3513
  const clientSDK2 = getClientSDK();
3331
- if (!clientSDK2)
3332
- throw new Error("Client SDK not set");
3514
+ if (!clientSDK2) throw new Error("Client SDK not set");
3333
3515
  return performRequest(action, clientSDK2);
3334
3516
  }
3335
3517
  }
@@ -3350,20 +3532,6 @@ function runMiddleware(action) {
3350
3532
  return (_a2 = allMiddleware[0]) == null ? void 0 : _a2.run(action);
3351
3533
  }
3352
3534
  const discardStatuses = [400, 409, 403, 404, 405, 500];
3353
- const statusMessages = {
3354
- 403: { title: "Forbidden", description: "You are not authorized to perform this action.", accentColor: "red" },
3355
- 404: { title: "Not found", description: "The requested resource was not found.", accentColor: "red" },
3356
- 405: {
3357
- title: "Not supported",
3358
- description: "It's not you. It's us. Sorry for the inconvenience.",
3359
- accentColor: "red"
3360
- },
3361
- 500: {
3362
- title: "Server error",
3363
- description: "Our server seems to be experiencing problems at the moment. We have been alerted and will fix the problem as soon as possible.",
3364
- accentColor: "red"
3365
- }
3366
- };
3367
3535
  function discard(reason, action, retries = 0) {
3368
3536
  var _a2;
3369
3537
  console.debug(
@@ -3416,14 +3584,6 @@ function discard(reason, action, retries = 0) {
3416
3584
  }
3417
3585
  if (status !== void 0 && discardStatuses.includes(status)) {
3418
3586
  console.warn("Discarding request due to error:", reason, "\nAction:", action);
3419
- const message = statusMessages[status];
3420
- if (message) {
3421
- if (unsafeShowToast) {
3422
- unsafeShowToast(message);
3423
- } else {
3424
- console.error(`Could not display toast for status ${status} because there is no toast handle.`);
3425
- }
3426
- }
3427
3587
  const coordinator2 = getOutboxCoordinator();
3428
3588
  if (!coordinator2) {
3429
3589
  throw new Error("Outbox coordinator not set");
@@ -3451,6 +3611,7 @@ function retry(_action, _retries) {
3451
3611
  }
3452
3612
  class BaseSDK {
3453
3613
  constructor(store) {
3614
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3454
3615
  __publicField(this, "store");
3455
3616
  this.store = store;
3456
3617
  }
@@ -3486,9 +3647,13 @@ class BaseSDK {
3486
3647
  };
3487
3648
  performRequest(fullOfflineAction, this).then((result) => {
3488
3649
  promise.resolve(result.body);
3489
- }).catch((error) => {
3490
- discard(error, fullOfflineAction);
3491
- promise.reject(error);
3650
+ }).catch((e) => {
3651
+ discard(e, fullOfflineAction);
3652
+ if (e instanceof Error) {
3653
+ promise.reject(e);
3654
+ } else {
3655
+ promise.reject(new Error((e ?? UNKNOWN_ERROR_MESSAGE).toString()));
3656
+ }
3492
3657
  });
3493
3658
  } else {
3494
3659
  const innerPromise = this.store.dispatch(
@@ -3542,10 +3707,8 @@ class BaseAuthService extends BaseService {
3542
3707
  }
3543
3708
  const EXPIRING_SOON_THRESHOLD = 1800;
3544
3709
  function parseTokens(response) {
3545
- if (!response.access)
3546
- throw new Error("Missing access token");
3547
- if (!response.refresh)
3548
- throw new Error("Missing refresh token");
3710
+ if (!response.access) throw new Error("Missing access token");
3711
+ if (!response.refresh) throw new Error("Missing refresh token");
3549
3712
  return { accessToken: response.access, refreshToken: response.refresh };
3550
3713
  }
3551
3714
  class JWTService extends BaseAuthService {
@@ -3582,8 +3745,7 @@ class JWTService extends BaseAuthService {
3582
3745
  this.clearAuth();
3583
3746
  return void 0;
3584
3747
  }
3585
- if (!response.access)
3586
- throw new Error("Missing access token");
3748
+ if (!response.access) throw new Error("Missing access token");
3587
3749
  return { accessToken: response.access, refreshToken: response.refresh ?? this.getRefreshToken() };
3588
3750
  });
3589
3751
  }
@@ -3639,8 +3801,7 @@ class JWTService extends BaseAuthService {
3639
3801
  return `Bearer ${accessToken}`;
3640
3802
  }
3641
3803
  async prepareAuth() {
3642
- if (!this.tokenIsExpiringSoon())
3643
- return;
3804
+ if (!this.tokenIsExpiringSoon()) return;
3644
3805
  console.debug(this.constructor.name, "preparing auth");
3645
3806
  try {
3646
3807
  await this.renewTokens();
@@ -3648,7 +3809,11 @@ class JWTService extends BaseAuthService {
3648
3809
  if (e instanceof APIError) {
3649
3810
  this.clearAuth();
3650
3811
  }
3651
- return Promise.reject(e);
3812
+ if (e instanceof Error) {
3813
+ return Promise.reject(e);
3814
+ } else {
3815
+ return Promise.reject(new Error((e ?? UNKNOWN_ERROR_MESSAGE).toString()));
3816
+ }
3652
3817
  }
3653
3818
  }
3654
3819
  /* if not successfull in gracefully handling an unauthorized response, throw and APIError */
@@ -3679,7 +3844,7 @@ class JWTService extends BaseAuthService {
3679
3844
  async initAuth(payload) {
3680
3845
  const uuid = v4();
3681
3846
  console.debug(this.constructor.name, "Initiating auth");
3682
- const promise = this.enqueueRequest({
3847
+ return this.enqueueRequest({
3683
3848
  uuid,
3684
3849
  description: "Get token pair",
3685
3850
  method: HttpMethod.POST,
@@ -3687,25 +3852,12 @@ class JWTService extends BaseAuthService {
3687
3852
  payload,
3688
3853
  isAuthNeeded: false,
3689
3854
  checkAuth: false,
3855
+ immediate: true,
3690
3856
  blockers: [],
3691
3857
  blocks: []
3692
- }).then(parseTokens);
3693
- const timeout = 5;
3694
- let timedOut = false;
3695
- const timeoutPromise = new Promise((_, reject) => {
3696
- setTimeout(() => {
3697
- timedOut = true;
3698
- this.dispatch(markForDeletion(uuid));
3699
- reject(new APIError({ message: `Request timed out after ${timeout} seconds` }));
3700
- }, timeout * 1e3);
3701
- });
3702
- const successPromise = promise.then((tokens) => {
3703
- if (timedOut) {
3704
- return void 0;
3705
- }
3706
- this.setTokens(tokens);
3858
+ }).then((tokens) => {
3859
+ this.setTokens(parseTokens(tokens));
3707
3860
  });
3708
- return Promise.race([timeoutPromise, successPromise]);
3709
3861
  }
3710
3862
  }
3711
3863
  class BaseApiService extends BaseService {
@@ -3731,9 +3883,6 @@ class CategoryService extends BaseApiService {
3731
3883
  description: "Create Category",
3732
3884
  method: HttpMethod.POST,
3733
3885
  url: "/categories/",
3734
- queryParams: {
3735
- workspace_id: payload.workspace.toString()
3736
- },
3737
3886
  payload: offlineCategory,
3738
3887
  blockers: [payload.workspace],
3739
3888
  blocks: [offlineCategory.offline_id]
@@ -3816,15 +3965,7 @@ class AssetService extends BaseApiService {
3816
3965
  description: "Create asset",
3817
3966
  method: HttpMethod.POST,
3818
3967
  url: "/assets/",
3819
- payload: {
3820
- offline_id: offlineAsset.offline_id,
3821
- submitted_at: offlineAsset.submitted_at,
3822
- geo_marker: offlineAsset.geo_marker,
3823
- canvas_marker: offlineAsset.canvas_marker,
3824
- label: offlineAsset.label,
3825
- description: offlineAsset.description,
3826
- asset_type: offlineAsset.asset_type
3827
- },
3968
+ payload: offlineAsset,
3828
3969
  blockers: [offlineAsset.asset_type],
3829
3970
  blocks: [offlineAsset.offline_id]
3830
3971
  });
@@ -3868,8 +4009,7 @@ class AssetService extends BaseApiService {
3868
4009
  const { store } = this.client;
3869
4010
  const state = store.getState();
3870
4011
  const assetToBeDeleted = selectAssetById(id)(state);
3871
- if (!assetToBeDeleted)
3872
- throw new Error(`No asset with id ${id} found in the store`);
4012
+ if (!assetToBeDeleted) throw new Error(`No asset with id ${id} found in the store`);
3873
4013
  const attachmentsOfAssets = selectAttachmentsOfAsset(id)(state);
3874
4014
  const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(id)(state);
3875
4015
  const issueAssociations = selectIssueAssociationsOfAsset(id)(state);
@@ -3892,15 +4032,15 @@ class AssetService extends BaseApiService {
3892
4032
  url: `/assets/${id}/`,
3893
4033
  blockers: [id],
3894
4034
  blocks: []
3895
- }).catch((err) => {
4035
+ }).catch((e) => {
3896
4036
  this.dispatch(addAsset(assetToBeDeleted));
3897
4037
  this.dispatch(addAssetAttachments(attachmentsOfAssets));
3898
4038
  this.dispatch(addFormSubmissions(formSubmissionsOfAssets));
3899
4039
  this.dispatch(addIssueAssociations(issueAssociations));
3900
- throw err;
4040
+ throw e;
3901
4041
  });
3902
4042
  }
3903
- bulkAdd(payloads, assetTypeId, batchSize) {
4043
+ bulkAdd(payloads, assetTypeId, projectId, batchSize) {
3904
4044
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
3905
4045
  const transactionId = v4();
3906
4046
  const assetBatches = chunkArray(payloads, batchSize).map((assetBatch) => {
@@ -3911,6 +4051,7 @@ class AssetService extends BaseApiService {
3911
4051
  transaction_id: transactionId,
3912
4052
  submitted_at: submittedAt,
3913
4053
  asset_type: assetTypeId,
4054
+ project: projectId,
3914
4055
  assets: assetPayloads
3915
4056
  }
3916
4057
  };
@@ -3921,8 +4062,7 @@ class AssetService extends BaseApiService {
3921
4062
  const { batchId, payload } = assetBatch;
3922
4063
  const batchAssetOfflineIds = payload.assets.map((c) => c.offline_id);
3923
4064
  const blockers = [assetTypeId];
3924
- if (prevBatchId)
3925
- blockers.push(prevBatchId);
4065
+ if (prevBatchId) blockers.push(prevBatchId);
3926
4066
  const blocks = batchAssetOfflineIds;
3927
4067
  blocks.push(batchId);
3928
4068
  const promise = this.enqueueRequest({
@@ -3946,7 +4086,10 @@ class AssetService extends BaseApiService {
3946
4086
  const result = await this.enqueueRequest({
3947
4087
  description: "Get assets",
3948
4088
  method: HttpMethod.GET,
3949
- url: `/projects/${projectId}/assets/`,
4089
+ url: "/assets/",
4090
+ queryParams: {
4091
+ project: projectId.toString()
4092
+ },
3950
4093
  blockers: [],
3951
4094
  blocks: []
3952
4095
  });
@@ -3967,7 +4110,7 @@ class AssetStageCompletionService extends BaseApiService {
3967
4110
  const promise = this.enqueueRequest({
3968
4111
  description: "Add asset stage completion",
3969
4112
  method: HttpMethod.POST,
3970
- url: "/assets/completions/",
4113
+ url: "/asset-stage-completions/",
3971
4114
  payload: {
3972
4115
  offline_id: offlineStageCompletion.offline_id,
3973
4116
  submitted_at: submittedAt,
@@ -3994,7 +4137,7 @@ class AssetStageCompletionService extends BaseApiService {
3994
4137
  const promise = this.enqueueRequest({
3995
4138
  description: "Delete asset stage completion",
3996
4139
  method: HttpMethod.DELETE,
3997
- url: `/assets/completions/${id}/`,
4140
+ url: `/asset-stage-completions/${id}/`,
3998
4141
  blockers: [id],
3999
4142
  blocks: []
4000
4143
  });
@@ -4020,7 +4163,7 @@ class AssetStageCompletionService extends BaseApiService {
4020
4163
  const promise = this.enqueueRequest({
4021
4164
  description: "Bulk create asset stage completions",
4022
4165
  method: HttpMethod.POST,
4023
- url: "/assets/completions/bulk/",
4166
+ url: "/asset-stage-completions/bulk/",
4024
4167
  payload: {
4025
4168
  submitted_at: submittedAt,
4026
4169
  completions: payload
@@ -4042,7 +4185,7 @@ class AssetStageCompletionService extends BaseApiService {
4042
4185
  const promise = this.enqueueRequest({
4043
4186
  description: "Deleting asset stage completions",
4044
4187
  method: HttpMethod.DELETE,
4045
- url: "/assets/completions/bulk/",
4188
+ url: "/asset-stage-completions/bulk/",
4046
4189
  payload: {
4047
4190
  completion_ids: ids
4048
4191
  },
@@ -4058,7 +4201,10 @@ class AssetStageCompletionService extends BaseApiService {
4058
4201
  const result = await this.enqueueRequest({
4059
4202
  description: "Get asset stage completions",
4060
4203
  method: HttpMethod.GET,
4061
- url: `/projects/${projectId}/asset-stage-completions/`,
4204
+ url: "/asset-stage-completions/",
4205
+ queryParams: {
4206
+ project: projectId.toString()
4207
+ },
4062
4208
  blockers: [],
4063
4209
  blocks: []
4064
4210
  });
@@ -4079,7 +4225,7 @@ class AssetStageService extends BaseApiService {
4079
4225
  const promise = this.enqueueRequest({
4080
4226
  description: "Add asset stages",
4081
4227
  method: HttpMethod.POST,
4082
- url: "/assets/stages/bulk/",
4228
+ url: "/asset-stages/bulk/",
4083
4229
  payload: {
4084
4230
  submitted_at: submittedAt,
4085
4231
  asset_type: assetTypeId,
@@ -4103,7 +4249,7 @@ class AssetStageService extends BaseApiService {
4103
4249
  return this.enqueueRequest({
4104
4250
  description: "Edit asset stages",
4105
4251
  method: HttpMethod.PATCH,
4106
- url: `/assets/types/${assetTypeId}/bulk-update-stages/`,
4252
+ url: `/asset-types/${assetTypeId}/bulk-update-stages/`,
4107
4253
  payload: {
4108
4254
  stages: stagesToUpdate
4109
4255
  },
@@ -4121,7 +4267,7 @@ class AssetStageService extends BaseApiService {
4121
4267
  const promise = this.enqueueRequest({
4122
4268
  description: "Delete asset stages",
4123
4269
  method: HttpMethod.DELETE,
4124
- url: "/assets/stages/bulk/",
4270
+ url: "/asset-stages/bulk/",
4125
4271
  payload: {
4126
4272
  stage_ids: idsToDelete
4127
4273
  },
@@ -4136,8 +4282,7 @@ class AssetStageService extends BaseApiService {
4136
4282
  update(payload) {
4137
4283
  const { store } = this.client;
4138
4284
  const assetStage = selectAssetStageById(payload.offline_id)(store.getState());
4139
- if (!assetStage)
4140
- throw new Error(`No asset stage with id ${payload.offline_id} found in the store`);
4285
+ if (!assetStage) throw new Error(`No asset stage with id ${payload.offline_id} found in the store`);
4141
4286
  const updatedAssetStage = {
4142
4287
  ...assetStage,
4143
4288
  ...payload
@@ -4146,7 +4291,7 @@ class AssetStageService extends BaseApiService {
4146
4291
  const promise = this.enqueueRequest({
4147
4292
  description: "Update asset stage",
4148
4293
  method: HttpMethod.PATCH,
4149
- url: `/assets/stages/${assetStage.offline_id}/`,
4294
+ url: `/asset-stages/${assetStage.offline_id}/`,
4150
4295
  payload: {
4151
4296
  name: payload.name,
4152
4297
  description: payload.description,
@@ -4163,52 +4308,14 @@ class AssetStageService extends BaseApiService {
4163
4308
  });
4164
4309
  return [updatedAssetStage, promise];
4165
4310
  }
4166
- async linkForm(stageId, formId) {
4167
- const { store } = this.client;
4168
- const stage = store.getState().assetStageReducer.instances[stageId];
4169
- if (!stage) {
4170
- throw new Error(`No asset stage with id ${stageId} found in the store`);
4171
- }
4172
- this.dispatch(updateAssetStage({ ...stage, form: formId }));
4173
- try {
4174
- await this.enqueueRequest({
4175
- description: "Link asset stage to form",
4176
- method: HttpMethod.POST,
4177
- url: `/assets/stages/${stageId}/associate-with-form/`,
4178
- payload: { form: formId },
4179
- blockers: [stageId, formId],
4180
- blocks: [stageId]
4181
- });
4182
- } catch (e) {
4183
- this.dispatch(setAssetStage(stage));
4184
- throw e;
4185
- }
4186
- }
4187
- async unlinkForm(stageId, formId) {
4188
- const { store } = this.client;
4189
- const stage = store.getState().assetStageReducer.instances[stageId];
4190
- if (!stage) {
4191
- throw new Error(`No asset stage with id ${stageId} found in the store`);
4192
- }
4193
- this.dispatch(updateAssetStage({ ...stage, form: void 0 }));
4194
- try {
4195
- await this.enqueueRequest({
4196
- description: "Unlink asset stage from form",
4197
- method: HttpMethod.DELETE,
4198
- url: `/assets/stages/${stageId}/associate-with-form/`,
4199
- blockers: [stageId, formId],
4200
- blocks: [stageId]
4201
- });
4202
- } catch (e) {
4203
- this.dispatch(setAssetStage(stage));
4204
- throw e;
4205
- }
4206
- }
4207
- async refreshStore(projectId) {
4311
+ async refreshStore(organizationId) {
4208
4312
  const result = await this.enqueueRequest({
4209
4313
  description: "Get asset stages",
4210
4314
  method: HttpMethod.GET,
4211
- url: `/projects/${projectId}/asset-stages/`,
4315
+ url: "/asset-stages/",
4316
+ queryParams: {
4317
+ organization: organizationId.toString()
4318
+ },
4212
4319
  blockers: [],
4213
4320
  blocks: []
4214
4321
  });
@@ -4225,7 +4332,12 @@ class BaseUploadService extends BaseApiService {
4225
4332
  projectAttachmentReducer: projectAttachmentReducer2,
4226
4333
  formRevisionAttachmentReducer: formRevisionAttachmentReducer2,
4227
4334
  formSubmissionAttachmentReducer: formSubmissionAttachmentReducer2,
4228
- geoImageReducer: geoImageReducer2
4335
+ geoImageReducer: geoImageReducer2,
4336
+ // fields
4337
+ assetTypeFieldsAttachmentReducer: assetTypeFieldsAttachmentReducer2,
4338
+ assetTypeFieldValuesAttachmentReducer: assetTypeFieldValuesAttachmentReducer2,
4339
+ issueTypeFieldsAttachmentReducer: issueTypeFieldsAttachmentReducer2,
4340
+ issueTypeFieldValuesAttachmentReducer: issueTypeFieldValuesAttachmentReducer2
4229
4341
  } = this.client.store.getState();
4230
4342
  const objectsWithSha1 = [].concat(
4231
4343
  Object.values(issueAttachmentReducer2.instances),
@@ -4235,7 +4347,11 @@ class BaseUploadService extends BaseApiService {
4235
4347
  Object.values(projectAttachmentReducer2.instances),
4236
4348
  Object.values(formRevisionAttachmentReducer2.instances),
4237
4349
  Object.values(formSubmissionAttachmentReducer2.instances),
4238
- Object.values(geoImageReducer2.instances)
4350
+ Object.values(geoImageReducer2.instances),
4351
+ Object.values(assetTypeFieldsAttachmentReducer2.instances),
4352
+ Object.values(assetTypeFieldValuesAttachmentReducer2.instances),
4353
+ Object.values(issueTypeFieldsAttachmentReducer2.instances),
4354
+ Object.values(issueTypeFieldValuesAttachmentReducer2.instances)
4239
4355
  );
4240
4356
  return objectsWithSha1.filter((object) => object.file_sha1 === sha1).length;
4241
4357
  }
@@ -4257,41 +4373,20 @@ class BaseUploadService extends BaseApiService {
4257
4373
  }
4258
4374
  return promisesBySha1;
4259
4375
  }
4260
- }
4261
- const AttachmentModelMeta = {
4262
- [AttachmentModel.Issue]: {
4263
- name: "issue",
4264
- attachUrlPrefix: "/issues",
4265
- deleteUrlPrefix: "/issues",
4266
- fetchUrlPostfix: "/issue-attachments"
4267
- },
4268
- [AttachmentModel.Asset]: {
4269
- name: "asset",
4270
- attachUrlPrefix: "/assets",
4271
- deleteUrlPrefix: "/assets",
4272
- fetchUrlPostfix: "/asset-attachments"
4273
- },
4274
- [AttachmentModel.AssetType]: {
4275
- name: "asset type",
4276
- attachUrlPrefix: "/assets/types",
4277
- deleteUrlPrefix: "/assets/types",
4278
- fetchUrlPostfix: "/asset-type-attachments"
4279
- },
4280
- [AttachmentModel.Project]: {
4281
- name: "project",
4282
- attachUrlPrefix: "/projects",
4283
- deleteUrlPrefix: "/projects",
4284
- fetchUrlPostfix: "/attachments"
4285
- },
4286
- [AttachmentModel.Document]: {
4287
- name: "document",
4288
- attachUrlPrefix: "/documents",
4289
- deleteUrlPrefix: "/documents",
4290
- fetchUrlPostfix: "/document-attachments"
4376
+ async getFilePayload(file) {
4377
+ const sha1 = await hashFile(file);
4378
+ const filePayload = {
4379
+ sha1,
4380
+ file_type: file.type,
4381
+ extension: file.name.split(".").pop(),
4382
+ size: file.size
4383
+ };
4384
+ await this.client.files.addCache(file, sha1);
4385
+ return filePayload;
4291
4386
  }
4292
- };
4387
+ }
4293
4388
  class BaseAttachmentService extends BaseUploadService {
4294
- async attachFiles(files, modelId, buildOfflineAttachment) {
4389
+ async _bulkAdd(payloads) {
4295
4390
  var _a2;
4296
4391
  const { store } = this.client;
4297
4392
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
@@ -4299,39 +4394,35 @@ class BaseAttachmentService extends BaseUploadService {
4299
4394
  const offlineAttachments = [];
4300
4395
  const attachmentPayloads = [];
4301
4396
  const filePayloads = {};
4302
- for (const file of files) {
4303
- const sha1 = await hashFile(file);
4304
- if (!(sha1 in filePayloads)) {
4305
- filePayloads[sha1] = {
4306
- sha1,
4307
- file_type: file.type,
4308
- extension: file.name.split(".").pop(),
4309
- size: file.size
4310
- };
4311
- await this.client.files.addCache(file, sha1);
4312
- }
4313
- const offlineAttachment = buildOfflineAttachment({
4397
+ for (const payload of payloads) {
4398
+ const { modelId, file } = payload;
4399
+ const filePayload = await this.getFilePayload(file);
4400
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
4401
+ const offlineAttachment = this.buildOfflineAttachment({
4314
4402
  file,
4315
- sha1,
4316
- submittedAt,
4317
- createdBy,
4403
+ file_sha1: filePayload.sha1,
4404
+ submitted_at: submittedAt,
4405
+ created_by: createdBy,
4318
4406
  description: "",
4319
4407
  modelId
4320
4408
  });
4321
4409
  offlineAttachments.push(offlineAttachment);
4322
- attachmentPayloads.push({
4323
- offline_id: offlineAttachment.offline_id,
4324
- name: offlineAttachment.file_name,
4325
- sha1: offlineAttachment.file_sha1,
4326
- description: offlineAttachment.description
4327
- });
4410
+ attachmentPayloads.push(
4411
+ this.buildAttachmentPayload({
4412
+ offline_id: offlineAttachment.offline_id,
4413
+ file_name: offlineAttachment.file_name,
4414
+ file_sha1: offlineAttachment.file_sha1,
4415
+ file_extension: filePayload.extension,
4416
+ description: offlineAttachment.description,
4417
+ modelId
4418
+ })
4419
+ );
4328
4420
  }
4329
4421
  this.dispatch(this.addAttachments(offlineAttachments));
4330
- const meta = AttachmentModelMeta[this.attachmentModel];
4331
4422
  const promise = this.enqueueRequest({
4332
- description: `Attach files to ${meta.name}`,
4423
+ description: `Add ${this.name}`,
4333
4424
  method: HttpMethod.POST,
4334
- url: `${meta.attachUrlPrefix}/${modelId}/attach/`,
4425
+ url: `${this.url}/bulk/`,
4335
4426
  payload: {
4336
4427
  submitted_at: submittedAt,
4337
4428
  attachments: attachmentPayloads,
@@ -4348,7 +4439,7 @@ class BaseAttachmentService extends BaseUploadService {
4348
4439
  });
4349
4440
  return [offlineAttachments, promise.then(({ attachments }) => attachments)];
4350
4441
  }
4351
- async deleteAttachment(attachmendId) {
4442
+ async _delete(attachmendId) {
4352
4443
  const { store } = this.client;
4353
4444
  const attachment = this.selectAttachment(attachmendId)(store.getState());
4354
4445
  if (!attachment) {
@@ -4357,11 +4448,10 @@ class BaseAttachmentService extends BaseUploadService {
4357
4448
  );
4358
4449
  }
4359
4450
  this.dispatch(this.removeAttachment(attachment.offline_id));
4360
- const meta = AttachmentModelMeta[this.attachmentModel];
4361
4451
  const promise = this.enqueueRequest({
4362
- description: "Delete attachment",
4452
+ description: `Delete ${this.name}`,
4363
4453
  method: HttpMethod.DELETE,
4364
- url: `${meta.deleteUrlPrefix}/attachments/${attachmendId}/`,
4454
+ url: `${this.url}/${attachmendId}/`,
4365
4455
  blockers: [attachmendId],
4366
4456
  blocks: []
4367
4457
  });
@@ -4374,24 +4464,12 @@ class BaseAttachmentService extends BaseUploadService {
4374
4464
  });
4375
4465
  return promise;
4376
4466
  }
4377
- // Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
4378
- // so for some attachment model services, this method will have to be overridden.
4379
- async refreshStore(projectId, _organizationId) {
4380
- const meta = AttachmentModelMeta[this.attachmentModel];
4381
- const result = await this.enqueueRequest({
4382
- description: `Get ${meta.name} attachments`,
4383
- method: HttpMethod.GET,
4384
- url: `/projects/${projectId}${meta.fetchUrlPostfix}/`,
4385
- blocks: [],
4386
- blockers: []
4387
- });
4388
- this.dispatch(this.initializeAttachments(result));
4389
- }
4390
4467
  }
4391
4468
  class AssetAttachmentService extends BaseAttachmentService {
4392
4469
  constructor() {
4393
4470
  super(...arguments);
4394
- __publicField(this, "attachmentModel", AttachmentModel.Asset);
4471
+ __publicField(this, "name", "Asset Attachment");
4472
+ __publicField(this, "url", "/asset-attachments");
4395
4473
  __publicField(this, "initializeAttachments", initializeAssetAttachments);
4396
4474
  __publicField(this, "addAttachments", addAssetAttachments);
4397
4475
  __publicField(this, "updateAttachments", updateAssetAttachments);
@@ -4403,20 +4481,39 @@ class AssetAttachmentService extends BaseAttachmentService {
4403
4481
  buildOfflineAttachment(data) {
4404
4482
  return offline({
4405
4483
  file: URL.createObjectURL(data.file),
4406
- file_sha1: data.sha1,
4407
- created_by: data.createdBy,
4484
+ file_sha1: data.file_sha1,
4485
+ created_by: data.created_by,
4408
4486
  file_name: data.file.name,
4409
4487
  file_type: data.file.type,
4410
- submitted_at: data.submittedAt,
4488
+ submitted_at: data.submitted_at,
4411
4489
  description: data.description,
4412
4490
  asset: data.modelId
4413
4491
  });
4414
4492
  }
4415
- async attachFilesToAsset(files, assetId) {
4416
- return this.attachFiles(files, assetId, this.buildOfflineAttachment.bind(this));
4493
+ buildAttachmentPayload(data) {
4494
+ return {
4495
+ ...data,
4496
+ asset: data.modelId
4497
+ };
4498
+ }
4499
+ async bulkAdd(payloads) {
4500
+ return this._bulkAdd(payloads.map((p) => ({ modelId: p.assetId, file: p.file })));
4501
+ }
4502
+ async delete(id) {
4503
+ return this._delete(id);
4417
4504
  }
4418
- async deleteAssetAttachment(attachmentId) {
4419
- return this.deleteAttachment(attachmentId);
4505
+ async refreshStore(projectId) {
4506
+ const result = await this.enqueueRequest({
4507
+ description: "Get asset attachments",
4508
+ method: HttpMethod.GET,
4509
+ url: `${this.url}/`,
4510
+ queryParams: {
4511
+ project: projectId.toString()
4512
+ },
4513
+ blocks: [],
4514
+ blockers: []
4515
+ });
4516
+ this.dispatch(initializeAssetAttachments(result));
4420
4517
  }
4421
4518
  }
4422
4519
  class AssetTypeService extends BaseApiService {
@@ -4433,8 +4530,8 @@ class AssetTypeService extends BaseApiService {
4433
4530
  const promise = this.enqueueRequest({
4434
4531
  description: "Create asset type",
4435
4532
  method: HttpMethod.POST,
4436
- url: `/projects/${payload.project}/asset-types/`,
4437
- payload: { ...offlineAssetType },
4533
+ url: "/asset-types/",
4534
+ payload: offlineAssetType,
4438
4535
  blockers: [],
4439
4536
  blocks: [offlineAssetType.offline_id]
4440
4537
  });
@@ -4459,7 +4556,7 @@ class AssetTypeService extends BaseApiService {
4459
4556
  const promise = this.enqueueRequest({
4460
4557
  description: "Update asset type",
4461
4558
  method: HttpMethod.PATCH,
4462
- url: `/assets/types/${payload.offline_id}/`,
4559
+ url: `/asset-types/${payload.offline_id}/`,
4463
4560
  payload: {
4464
4561
  icon: payload.icon,
4465
4562
  color: payload.color,
@@ -4493,7 +4590,7 @@ class AssetTypeService extends BaseApiService {
4493
4590
  return this.enqueueRequest({
4494
4591
  description: "Delete asset type",
4495
4592
  method: HttpMethod.DELETE,
4496
- url: `/assets/types/${assetTypeId}/`,
4593
+ url: `/asset-types/${assetTypeId}/`,
4497
4594
  blockers: [assetTypeId],
4498
4595
  blocks: []
4499
4596
  }).catch((e) => {
@@ -4504,11 +4601,14 @@ class AssetTypeService extends BaseApiService {
4504
4601
  throw e;
4505
4602
  });
4506
4603
  }
4507
- async refreshStore(projectId) {
4604
+ async refreshStore(organizationId) {
4508
4605
  const result = await this.enqueueRequest({
4509
4606
  description: "Get asset types",
4510
4607
  method: HttpMethod.GET,
4511
- url: `/projects/${projectId}/asset-types/`,
4608
+ url: "/asset-types/",
4609
+ queryParams: {
4610
+ organization: organizationId.toString()
4611
+ },
4512
4612
  blockers: [],
4513
4613
  blocks: []
4514
4614
  });
@@ -4518,8 +4618,8 @@ class AssetTypeService extends BaseApiService {
4518
4618
  class AssetTypeAttachmentService extends BaseAttachmentService {
4519
4619
  constructor() {
4520
4620
  super(...arguments);
4521
- __publicField(this, "attachmentModel", AttachmentModel.AssetType);
4522
- __publicField(this, "initializeAttachments", initializeAssetTypeAttachments);
4621
+ __publicField(this, "name", "Asset Type Attachment");
4622
+ __publicField(this, "url", "/asset-type-attachments");
4523
4623
  __publicField(this, "addAttachments", addAssetTypeAttachments);
4524
4624
  __publicField(this, "updateAttachments", updateAssetTypeAttachments);
4525
4625
  __publicField(this, "removeAttachments", deleteAssetTypeAttachments);
@@ -4530,20 +4630,39 @@ class AssetTypeAttachmentService extends BaseAttachmentService {
4530
4630
  buildOfflineAttachment(data) {
4531
4631
  return offline({
4532
4632
  file: URL.createObjectURL(data.file),
4533
- file_sha1: data.sha1,
4534
- created_by: data.createdBy,
4633
+ file_sha1: data.file_sha1,
4634
+ created_by: data.created_by,
4535
4635
  file_name: data.file.name,
4536
4636
  file_type: data.file.type,
4537
- submitted_at: data.submittedAt,
4637
+ submitted_at: data.submitted_at,
4538
4638
  description: data.description,
4539
4639
  asset_type: data.modelId
4540
4640
  });
4541
4641
  }
4542
- async attachFilesToAssetType(files, assetTypeId) {
4543
- return this.attachFiles(files, assetTypeId, this.buildOfflineAttachment.bind(this));
4544
- }
4545
- async deleteAssetTypeAttachment(attachmentId) {
4546
- return this.deleteAttachment(attachmentId);
4642
+ buildAttachmentPayload(data) {
4643
+ return {
4644
+ ...data,
4645
+ asset_type: data.modelId
4646
+ };
4647
+ }
4648
+ async bulkAdd(payloads) {
4649
+ return this._bulkAdd(payloads.map((p) => ({ modelId: p.assetTypeId, file: p.file })));
4650
+ }
4651
+ async delete(attachmentId) {
4652
+ return this._delete(attachmentId);
4653
+ }
4654
+ async refreshStore(organizationId) {
4655
+ const result = await this.enqueueRequest({
4656
+ description: "Get asset type attachments",
4657
+ method: HttpMethod.GET,
4658
+ url: `${this.url}/`,
4659
+ queryParams: {
4660
+ organization: organizationId.toString()
4661
+ },
4662
+ blocks: [],
4663
+ blockers: []
4664
+ });
4665
+ this.dispatch(initializeAssetTypeAttachments(result));
4547
4666
  }
4548
4667
  }
4549
4668
  class IssueCommentService extends BaseApiService {
@@ -4559,7 +4678,7 @@ class IssueCommentService extends BaseApiService {
4559
4678
  const promise = this.enqueueRequest({
4560
4679
  description: "Add issue comment",
4561
4680
  method: HttpMethod.POST,
4562
- url: `/issues/${payload.issue}/comment/`,
4681
+ url: "/issue-comments/",
4563
4682
  payload: offlineComment,
4564
4683
  blockers: [payload.issue],
4565
4684
  blocks: [offlineComment.offline_id]
@@ -4583,7 +4702,7 @@ class IssueCommentService extends BaseApiService {
4583
4702
  const promise = this.enqueueRequest({
4584
4703
  description: "Edit issue comment",
4585
4704
  method: HttpMethod.PATCH,
4586
- url: `/issues/comments/${payload.offline_id}/`,
4705
+ url: `/issue-comments/${payload.offline_id}/`,
4587
4706
  payload,
4588
4707
  blockers: [payload.offline_id],
4589
4708
  blocks: [payload.offline_id]
@@ -4602,7 +4721,7 @@ class IssueCommentService extends BaseApiService {
4602
4721
  const promise = this.enqueueRequest({
4603
4722
  description: "Delete comment",
4604
4723
  method: HttpMethod.DELETE,
4605
- url: `/issues/comments/${id}/`,
4724
+ url: `/issue-comments/${id}/`,
4606
4725
  blockers: [id],
4607
4726
  blocks: []
4608
4727
  });
@@ -4615,7 +4734,10 @@ class IssueCommentService extends BaseApiService {
4615
4734
  const result = await this.enqueueRequest({
4616
4735
  description: "Get comments",
4617
4736
  method: HttpMethod.GET,
4618
- url: `/projects/${projectId}/comments/`,
4737
+ url: "/issue-comments/",
4738
+ queryParams: {
4739
+ project: projectId.toString()
4740
+ },
4619
4741
  blockers: [],
4620
4742
  blocks: []
4621
4743
  });
@@ -4627,27 +4749,21 @@ class IssueUpdateService extends BaseApiService {
4627
4749
  const result = await this.enqueueRequest({
4628
4750
  description: "Get issue updates",
4629
4751
  method: HttpMethod.GET,
4630
- url: `/projects/${projectId}/issues/updates/`,
4752
+ url: "/issue-updates/",
4753
+ queryParams: {
4754
+ project: projectId.toString()
4755
+ },
4631
4756
  blockers: [],
4632
4757
  blocks: []
4633
4758
  });
4634
- let filteredResult = result.filter(onlyUniqueOfflineIds);
4635
- filteredResult = filteredResult.map((comment) => {
4636
- return { ...comment };
4637
- });
4638
- if (result.length !== filteredResult.length) {
4639
- console.error(
4640
- `Received duplicate comments from the API (new length ${filteredResult.length}); filtered in browser.`
4641
- );
4642
- }
4643
- this.dispatch(initializeIssueUpdates(filteredResult));
4759
+ this.dispatch(initializeIssueUpdates(result));
4644
4760
  }
4645
4761
  }
4646
4762
  class IssueAttachmentService extends BaseAttachmentService {
4647
4763
  constructor() {
4648
4764
  super(...arguments);
4649
- __publicField(this, "attachmentModel", AttachmentModel.Issue);
4650
- __publicField(this, "initializeAttachments", initializeIssueAttachments);
4765
+ __publicField(this, "name", "Issue Attachment");
4766
+ __publicField(this, "url", "/issue-attachments");
4651
4767
  __publicField(this, "addAttachments", addIssueAttachments);
4652
4768
  __publicField(this, "updateAttachments", updateIssueAttachments);
4653
4769
  __publicField(this, "removeAttachments", deleteIssueAttachments);
@@ -4658,24 +4774,42 @@ class IssueAttachmentService extends BaseAttachmentService {
4658
4774
  buildOfflineAttachment(data) {
4659
4775
  return offline({
4660
4776
  file: URL.createObjectURL(data.file),
4661
- file_sha1: data.sha1,
4662
- created_by: data.createdBy,
4777
+ file_sha1: data.file_sha1,
4778
+ created_by: data.created_by,
4663
4779
  file_name: data.file.name,
4664
4780
  file_type: data.file.type,
4665
- submitted_at: data.submittedAt,
4781
+ submitted_at: data.submitted_at,
4666
4782
  description: data.description,
4667
4783
  issue: data.modelId
4668
4784
  });
4669
4785
  }
4670
- async attachFilesToIssue(files, issueId) {
4671
- return this.attachFiles(files, issueId, this.buildOfflineAttachment.bind(this));
4786
+ buildAttachmentPayload(data) {
4787
+ return {
4788
+ ...data,
4789
+ issue: data.modelId
4790
+ };
4791
+ }
4792
+ async bulkAdd(payloads) {
4793
+ return this._bulkAdd(payloads.map((p) => ({ modelId: p.issueId, file: p.file })));
4794
+ }
4795
+ async delete(id) {
4796
+ return this._delete(id);
4672
4797
  }
4673
- async deleteIssueAttachment(attachmentId) {
4674
- return this.deleteAttachment(attachmentId);
4798
+ async refreshStore(projectId) {
4799
+ const result = await this.enqueueRequest({
4800
+ description: "Get issue attachments",
4801
+ method: HttpMethod.GET,
4802
+ url: `${this.url}/`,
4803
+ queryParams: {
4804
+ project: projectId.toString()
4805
+ },
4806
+ blocks: [],
4807
+ blockers: []
4808
+ });
4809
+ this.dispatch(initializeIssueAttachments(result));
4675
4810
  }
4676
4811
  }
4677
4812
  class IssueService extends BaseApiService {
4678
- // Basic CRUD functions
4679
4813
  add(payload) {
4680
4814
  var _a2;
4681
4815
  const { store } = this.client;
@@ -4692,10 +4826,6 @@ class IssueService extends BaseApiService {
4692
4826
  description: "Create issue",
4693
4827
  method: HttpMethod.POST,
4694
4828
  url: "/issues/",
4695
- queryParams: {
4696
- workspace_id: payload.index_workspace,
4697
- ...payload.issue_type ? { issue_type: payload.issue_type } : {}
4698
- },
4699
4829
  payload: offlineIssue,
4700
4830
  blockers: ["add-issue", ...offlineIssue.index_workspace ? [offlineIssue.index_workspace] : []],
4701
4831
  blocks: [offlineIssue.offline_id]
@@ -4731,7 +4861,18 @@ class IssueService extends BaseApiService {
4731
4861
  ]) {
4732
4862
  if (issueUpdateChange in payload && payload[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
4733
4863
  switch (issueUpdateChange) {
4734
- case "category": {
4864
+ case IssueUpdateChange.PRIORITY:
4865
+ case IssueUpdateChange.STATUS: {
4866
+ const val = payload[issueUpdateChange];
4867
+ changes[issueUpdateChange] = val !== void 0 ? Number(val) : null;
4868
+ break;
4869
+ }
4870
+ case IssueUpdateChange.DUE_DATE:
4871
+ case IssueUpdateChange.DESCRIPTION:
4872
+ case IssueUpdateChange.TITLE:
4873
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
4874
+ break;
4875
+ case IssueUpdateChange.CATEGORY: {
4735
4876
  let categoryOrNull = null;
4736
4877
  const categoryIdOrNull = payload[issueUpdateChange];
4737
4878
  if (categoryIdOrNull) {
@@ -4748,7 +4889,7 @@ class IssueService extends BaseApiService {
4748
4889
  } : null;
4749
4890
  break;
4750
4891
  }
4751
- case "assigned_to": {
4892
+ case IssueUpdateChange.ASSIGNED_TO: {
4752
4893
  let userOrNull = null;
4753
4894
  const userIdOrNull = payload[issueUpdateChange];
4754
4895
  if (userIdOrNull) {
@@ -4764,20 +4905,6 @@ class IssueService extends BaseApiService {
4764
4905
  } : null;
4765
4906
  break;
4766
4907
  }
4767
- case "description":
4768
- changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
4769
- break;
4770
- case "title":
4771
- changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
4772
- break;
4773
- case "priority":
4774
- changes[issueUpdateChange] = payload[issueUpdateChange];
4775
- break;
4776
- case "status":
4777
- changes[issueUpdateChange] = payload[issueUpdateChange];
4778
- break;
4779
- case "due_date":
4780
- changes[issueUpdateChange] = payload[issueUpdateChange] ? payload[issueUpdateChange] : null;
4781
4908
  }
4782
4909
  }
4783
4910
  }
@@ -4848,7 +4975,10 @@ class IssueService extends BaseApiService {
4848
4975
  const result = await this.enqueueRequest({
4849
4976
  description: "Get issues",
4850
4977
  method: HttpMethod.GET,
4851
- url: `/projects/${projectId}/issues/`,
4978
+ url: "/issues/",
4979
+ queryParams: {
4980
+ project: projectId.toString()
4981
+ },
4852
4982
  blockers: [],
4853
4983
  blocks: []
4854
4984
  });
@@ -4868,16 +4998,8 @@ class IssueTypeService extends BaseApiService {
4868
4998
  this.dispatch(addIssueType(offlineIssueType));
4869
4999
  const promise = this.enqueueRequest({
4870
5000
  method: HttpMethod.POST,
4871
- url: `/organizations/${payload.organization}/issue-types/`,
4872
- // Sending only whats needed here
4873
- payload: {
4874
- offline_id: offlineIssueType.offline_id,
4875
- submitted_at: offlineIssueType.submitted_at,
4876
- icon: offlineIssueType.icon,
4877
- color: offlineIssueType.color,
4878
- name: offlineIssueType.name,
4879
- description: offlineIssueType.description
4880
- },
5001
+ url: "/issue-types/",
5002
+ payload: offlineIssueType,
4881
5003
  blockers: [],
4882
5004
  blocks: [offlineIssueType.offline_id]
4883
5005
  });
@@ -4902,7 +5024,7 @@ class IssueTypeService extends BaseApiService {
4902
5024
  this.dispatch(updateIssueType(offlineUpdatedIssueType));
4903
5025
  const promise = this.enqueueRequest({
4904
5026
  method: HttpMethod.PATCH,
4905
- url: `/issues/types/${payload.offline_id}/`,
5027
+ url: `/issue-types/${payload.offline_id}/`,
4906
5028
  payload,
4907
5029
  blockers: [payload.offline_id],
4908
5030
  blocks: [payload.offline_id]
@@ -4926,7 +5048,7 @@ class IssueTypeService extends BaseApiService {
4926
5048
  this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
4927
5049
  const promise = this.enqueueRequest({
4928
5050
  method: HttpMethod.DELETE,
4929
- url: `/issues/types/${id}/`,
5051
+ url: `/issue-types/${id}/`,
4930
5052
  blockers: [id],
4931
5053
  blocks: []
4932
5054
  });
@@ -4939,7 +5061,10 @@ class IssueTypeService extends BaseApiService {
4939
5061
  async refreshStore(organizationId) {
4940
5062
  const result = await this.enqueueRequest({
4941
5063
  method: HttpMethod.GET,
4942
- url: `/organizations/${organizationId}/issue-types/`,
5064
+ url: "/issue-types/",
5065
+ queryParams: {
5066
+ organization: organizationId.toString()
5067
+ },
4943
5068
  blockers: [],
4944
5069
  blocks: []
4945
5070
  });
@@ -5078,8 +5203,8 @@ class ProjectFileService extends BaseApiService {
5078
5203
  class ProjectAttachmentService extends BaseAttachmentService {
5079
5204
  constructor() {
5080
5205
  super(...arguments);
5081
- __publicField(this, "attachmentModel", AttachmentModel.Project);
5082
- __publicField(this, "initializeAttachments", initializeProjectAttachments);
5206
+ __publicField(this, "name", "Project Attachment");
5207
+ __publicField(this, "url", "/project-attachments");
5083
5208
  __publicField(this, "addAttachments", addProjectAttachments);
5084
5209
  __publicField(this, "updateAttachments", updateProjectAttachments);
5085
5210
  __publicField(this, "removeAttachments", deleteProjectAttachments);
@@ -5090,20 +5215,39 @@ class ProjectAttachmentService extends BaseAttachmentService {
5090
5215
  buildOfflineAttachment(data) {
5091
5216
  return offline({
5092
5217
  file: URL.createObjectURL(data.file),
5093
- file_sha1: data.sha1,
5094
- created_by: data.createdBy,
5218
+ file_sha1: data.file_sha1,
5219
+ created_by: data.created_by,
5095
5220
  file_name: data.file.name,
5096
5221
  file_type: data.file.type,
5097
- submitted_at: data.submittedAt,
5222
+ submitted_at: data.submitted_at,
5098
5223
  description: data.description,
5099
5224
  project: data.modelId
5100
5225
  });
5101
5226
  }
5102
- async attachFilesToProject(files, projectId) {
5103
- return this.attachFiles(files, projectId, this.buildOfflineAttachment.bind(this));
5227
+ buildAttachmentPayload(data) {
5228
+ return {
5229
+ ...data,
5230
+ project: data.modelId
5231
+ };
5232
+ }
5233
+ async bulkAdd(payloads) {
5234
+ return this._bulkAdd(payloads.map((p) => ({ modelId: p.projectId, file: p.file })));
5235
+ }
5236
+ async delete(attachmentId) {
5237
+ return this._delete(attachmentId);
5104
5238
  }
5105
- async deleteProjectAttachment(attachmentId) {
5106
- return this.deleteAttachment(attachmentId);
5239
+ async refreshStore(projectId) {
5240
+ const result = await this.enqueueRequest({
5241
+ description: "Get project attachments",
5242
+ method: HttpMethod.GET,
5243
+ url: `${this.url}/`,
5244
+ queryParams: {
5245
+ project: projectId.toString()
5246
+ },
5247
+ blockers: [],
5248
+ blocks: []
5249
+ });
5250
+ this.dispatch(initializeProjectAttachments(result));
5107
5251
  }
5108
5252
  }
5109
5253
  class ProjectService extends BaseApiService {
@@ -5246,88 +5390,31 @@ const separateImageFromFields = async (fields) => {
5246
5390
  return { fields: newFields, images };
5247
5391
  };
5248
5392
  class FormService extends BaseUploadService {
5249
- async bulkAddRevisionAttachments(revisionId, files) {
5393
+ add(payload, initialRevision) {
5250
5394
  var _a2;
5395
+ const { store } = this.client;
5251
5396
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5252
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5253
- const filePayloads = {};
5254
- const offlineFormRevisionAttachments = [];
5255
- const attachmentPayloads = [];
5256
- for (const [fieldIdentifier, file] of Object.entries(files)) {
5257
- const sha1 = await hashFile(file);
5258
- if (!(sha1 in filePayloads)) {
5259
- filePayloads[sha1] = {
5260
- sha1,
5261
- file_type: file.type,
5262
- extension: file.name.split(".").pop(),
5263
- size: file.size
5264
- };
5265
- await this.client.files.addCache(file, sha1);
5266
- }
5267
- const offlineFormRevisionAttachment = offline({
5268
- file: URL.createObjectURL(file),
5269
- file_type: file.type,
5270
- file_name: file.name,
5271
- file_sha1: sha1,
5272
- created_by: createdBy,
5273
- revision: revisionId,
5274
- submitted_at: submittedAt,
5275
- field_identifier: fieldIdentifier
5276
- });
5277
- offlineFormRevisionAttachments.push(offlineFormRevisionAttachment);
5278
- const attachmentPayload = {
5279
- offline_id: offlineFormRevisionAttachment.offline_id,
5280
- name: file.name,
5281
- field_identifier: fieldIdentifier,
5282
- sha1
5283
- };
5284
- attachmentPayloads.push(attachmentPayload);
5285
- }
5286
- this.dispatch(addFormRevisionAttachments(offlineFormRevisionAttachments));
5287
- const promise = this.enqueueRequest({
5288
- description: "Attach files to form revision",
5289
- method: HttpMethod.POST,
5290
- url: `/forms/revisions/${revisionId}/attachments/bulk/`,
5291
- payload: {
5292
- submitted_at: submittedAt,
5293
- attachments: attachmentPayloads,
5294
- files: Object.values(filePayloads)
5295
- },
5296
- blockers: [revisionId],
5297
- blocks: offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
5298
- });
5299
- promise.then((result) => {
5300
- this.processPresignedUrls(result.presigned_urls);
5301
- this.dispatch(updateFormRevisionAttachments(result.attachments));
5302
- }).catch(() => {
5303
- this.dispatch(
5304
- deleteFormRevisionAttachments(
5305
- offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
5306
- )
5307
- );
5397
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5398
+ const offlineForm = offline({
5399
+ ...payload,
5400
+ submitted_at: submittedAt,
5401
+ created_by: createdBy
5308
5402
  });
5309
- return [offlineFormRevisionAttachments, promise.then(({ attachments }) => attachments)];
5310
- }
5311
- async add(ownerId, form, initialRevision, urlPrefix) {
5312
- const { fields, images } = await separateImageFromFields(initialRevision.fields);
5313
5403
  const offlineFormRevision = offline({
5314
5404
  ...initialRevision,
5315
- fields,
5316
- created_by: form.created_by,
5317
- form: form.offline_id,
5318
- submitted_at: form.submitted_at,
5319
- revision: "Pending"
5405
+ form: offlineForm.offline_id,
5406
+ revision: "Pending",
5407
+ submitted_at: submittedAt,
5408
+ created_by: createdBy
5320
5409
  });
5321
- this.dispatch(addForm(form));
5410
+ this.dispatch(addForm(offlineForm));
5322
5411
  this.dispatch(addFormRevision(offlineFormRevision));
5323
5412
  const formPromise = this.enqueueRequest({
5324
5413
  description: "Create form",
5325
5414
  method: HttpMethod.POST,
5326
- url: urlPrefix,
5415
+ url: "/forms/",
5327
5416
  payload: {
5328
- // Sending exactly what is currently needed for the endpoint
5329
- offline_id: form.offline_id,
5330
- submitted_at: form.submitted_at,
5417
+ ...offlineForm,
5331
5418
  initial_revision: {
5332
5419
  offline_id: offlineFormRevision.offline_id,
5333
5420
  submitted_at: offlineFormRevision.submitted_at,
@@ -5336,111 +5423,15 @@ class FormService extends BaseUploadService {
5336
5423
  fields: offlineFormRevision.fields
5337
5424
  }
5338
5425
  },
5339
- blockers: [ownerId],
5340
- blocks: [form.offline_id, offlineFormRevision.offline_id]
5426
+ blockers: [],
5427
+ blocks: [offlineForm.offline_id, offlineFormRevision.offline_id]
5341
5428
  });
5342
- const [offlineFormRevisionAttachments, attachmentsPromise] = await this.bulkAddRevisionAttachments(
5343
- offlineFormRevision.offline_id,
5344
- images
5345
- );
5346
5429
  void formPromise.catch((e) => {
5347
- this.dispatch(deleteForm(form.offline_id));
5430
+ this.dispatch(deleteForm(offlineForm.offline_id));
5348
5431
  this.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
5349
5432
  throw e;
5350
5433
  });
5351
- return [form, offlineFormRevision, offlineFormRevisionAttachments, formPromise, attachmentsPromise];
5352
- }
5353
- addForOrganization(organizationId, initialRevision) {
5354
- var _a2;
5355
- const state = this.client.store.getState();
5356
- const offlineForm = offline({
5357
- favorite: false,
5358
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5359
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5360
- organization: organizationId
5361
- });
5362
- return this.add(
5363
- organizationId.toString(),
5364
- offlineForm,
5365
- initialRevision,
5366
- `/organizations/${organizationId}/create-form/`
5367
- );
5368
- }
5369
- addForProject(projectId, initialRevision) {
5370
- var _a2;
5371
- const state = this.client.store.getState();
5372
- const offlineForm = offline({
5373
- favorite: false,
5374
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5375
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5376
- project: projectId
5377
- });
5378
- return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
5379
- }
5380
- addForIssueType(issueTypeId, initialRevision) {
5381
- var _a2;
5382
- const state = this.client.store.getState();
5383
- const offlineForm = offline({
5384
- favorite: false,
5385
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5386
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5387
- issue_type: issueTypeId
5388
- });
5389
- return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
5390
- }
5391
- addForAssetType(assetTypeId, initialRevision) {
5392
- var _a2;
5393
- const state = this.client.store.getState();
5394
- const offlineForm = offline({
5395
- favorite: false,
5396
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5397
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5398
- asset_type: assetTypeId
5399
- });
5400
- return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
5401
- }
5402
- async createRevision(formId, revision) {
5403
- var _a2;
5404
- const offlineRevision = offline(revision);
5405
- const { store } = this.client;
5406
- const state = store.getState();
5407
- const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
5408
- const { fields, images } = await separateImageFromFields(offlineRevision.fields);
5409
- const fullRevision = {
5410
- ...offlineRevision,
5411
- fields,
5412
- created_by: createdBy,
5413
- revision: "Pending",
5414
- form: formId,
5415
- submitted_at: (/* @__PURE__ */ new Date()).toISOString()
5416
- };
5417
- this.dispatch(addFormRevision(fullRevision));
5418
- const promise = this.enqueueRequest({
5419
- description: "Create form revision",
5420
- method: HttpMethod.PATCH,
5421
- url: `/forms/${formId}/`,
5422
- payload: {
5423
- initial_revision: {
5424
- offline_id: fullRevision.offline_id,
5425
- submitted_at: fullRevision.submitted_at,
5426
- title: fullRevision.title,
5427
- description: fullRevision.description,
5428
- fields: fullRevision.fields
5429
- }
5430
- },
5431
- blockers: [formId],
5432
- blocks: [offlineRevision.offline_id]
5433
- });
5434
- const [offlineFormRevisionAttachments, attachmentsPromise] = await this.bulkAddRevisionAttachments(
5435
- fullRevision.offline_id,
5436
- images
5437
- );
5438
- void promise.then((result) => {
5439
- this.dispatch(setFormRevision(result));
5440
- }).catch(() => {
5441
- this.dispatch(deleteFormRevision(fullRevision.offline_id));
5442
- });
5443
- return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
5434
+ return [offlineForm, offlineFormRevision, formPromise];
5444
5435
  }
5445
5436
  async delete(id) {
5446
5437
  const { store } = this.client;
@@ -5477,65 +5468,18 @@ class FormService extends BaseUploadService {
5477
5468
  throw e;
5478
5469
  }
5479
5470
  }
5480
- async refreshStore(projectId) {
5481
- const forms = [];
5482
- const revisions = [];
5483
- const attachments = [];
5484
- const projectFormsResult = await this.enqueueRequest({
5485
- description: "Fetch project forms",
5486
- method: HttpMethod.GET,
5487
- url: `/projects/${projectId}/forms/`,
5488
- blockers: [projectId.toString()],
5489
- blocks: []
5490
- });
5491
- for (const form of projectFormsResult.forms)
5492
- forms.push(form);
5493
- for (const revision of projectFormsResult.revisions)
5494
- revisions.push(revision);
5495
- for (const attachment of projectFormsResult.attachments)
5496
- attachments.push(attachment);
5497
- const organizationFormsResult = await this.enqueueRequest({
5471
+ async refreshStore(organizationId) {
5472
+ const forms = await this.enqueueRequest({
5498
5473
  description: "Fetch organization forms",
5499
5474
  method: HttpMethod.GET,
5500
- url: `/projects/${projectId}/organizations/forms/`,
5501
- blockers: [projectId.toString()],
5502
- blocks: []
5503
- });
5504
- for (const form of organizationFormsResult.forms)
5505
- forms.push(form);
5506
- for (const revision of organizationFormsResult.revisions)
5507
- revisions.push(revision);
5508
- for (const attachment of organizationFormsResult.attachments)
5509
- attachments.push(attachment);
5510
- const assetTypeFormsResult = await this.enqueueRequest({
5511
- description: "Fetch asset type forms",
5512
- method: HttpMethod.GET,
5513
- url: `/projects/${projectId}/asset-types/forms/`,
5514
- blockers: [projectId.toString()],
5515
- blocks: []
5516
- });
5517
- for (const form of assetTypeFormsResult.forms)
5518
- forms.push(form);
5519
- for (const revision of assetTypeFormsResult.revisions)
5520
- revisions.push(revision);
5521
- for (const attachment of assetTypeFormsResult.attachments)
5522
- attachments.push(attachment);
5523
- const issueTypeFormsResult = await this.enqueueRequest({
5524
- description: "Fetch issue type forms",
5525
- method: HttpMethod.GET,
5526
- url: `/projects/${projectId}/issue-types/forms/`,
5527
- blockers: [projectId.toString()],
5475
+ url: "/forms/",
5476
+ queryParams: {
5477
+ organization: organizationId.toString()
5478
+ },
5479
+ blockers: [organizationId.toString()],
5528
5480
  blocks: []
5529
5481
  });
5530
- for (const form of issueTypeFormsResult.forms)
5531
- forms.push(form);
5532
- for (const revision of issueTypeFormsResult.revisions)
5533
- revisions.push(revision);
5534
- for (const attachment of issueTypeFormsResult.attachments)
5535
- attachments.push(attachment);
5536
5482
  this.dispatch(initializeForms(forms));
5537
- this.dispatch(initializeFormRevisions(revisions));
5538
- this.dispatch(initializeFormRevisionAttachments(attachments));
5539
5483
  }
5540
5484
  }
5541
5485
  const isArrayOfFiles = (value) => {
@@ -5557,95 +5501,11 @@ const separateFilesFromValues = (values) => {
5557
5501
  return { values: newValues, files };
5558
5502
  };
5559
5503
  class FormSubmissionService extends BaseUploadService {
5560
- async bulkAddSubmissionAttachments(submissionId, files) {
5561
- var _a2;
5562
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5563
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5564
- const filePayloads = {};
5565
- const offlineFormSubmissionAttachments = [];
5566
- const attachmentPayloads = [];
5567
- for (const [fieldIdentifier, filesArray] of Object.entries(files)) {
5568
- for (const file of filesArray) {
5569
- const sha1 = await hashFile(file);
5570
- if (!(sha1 in filePayloads)) {
5571
- filePayloads[sha1] = {
5572
- sha1,
5573
- file_type: file.type,
5574
- extension: file.name.split(".").pop(),
5575
- size: file.size
5576
- };
5577
- await this.client.files.addCache(file, sha1);
5578
- }
5579
- const offlineFormSubmissionAttachment = offline({
5580
- file: URL.createObjectURL(file),
5581
- file_type: file.type,
5582
- file_name: file.name,
5583
- file_sha1: sha1,
5584
- created_by: createdBy,
5585
- submission: submissionId,
5586
- submitted_at: submittedAt,
5587
- field_identifier: fieldIdentifier
5588
- });
5589
- offlineFormSubmissionAttachments.push(offlineFormSubmissionAttachment);
5590
- const attachmentPayload = {
5591
- offline_id: offlineFormSubmissionAttachment.offline_id,
5592
- name: file.name,
5593
- sha1,
5594
- field_identifier: fieldIdentifier
5595
- };
5596
- attachmentPayloads.push(attachmentPayload);
5597
- }
5598
- }
5599
- this.dispatch(addFormSubmissionAttachments(offlineFormSubmissionAttachments));
5600
- const promise = this.enqueueRequest({
5601
- description: "Attach files to form submission",
5602
- method: HttpMethod.POST,
5603
- url: `/forms/submissions/${submissionId}/attachments/bulk/`,
5604
- payload: {
5605
- submitted_at: submittedAt,
5606
- attachments: attachmentPayloads,
5607
- files: Object.values(filePayloads)
5608
- },
5609
- blockers: [submissionId],
5610
- blocks: offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
5611
- });
5612
- promise.then((result) => {
5613
- this.processPresignedUrls(result.presigned_urls);
5614
- this.dispatch(updateFormSubmissionAttachments(result.attachments));
5615
- }).catch(() => {
5616
- this.dispatch(
5617
- deleteFormSubmissionAttachments(
5618
- offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
5619
- )
5620
- );
5621
- });
5622
- return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
5623
- }
5624
- async bulkDeleteSubmissionAttachments(submissionId, attachmentsIds) {
5625
- const { store } = this.client;
5626
- const state = store.getState();
5627
- const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
5628
- this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
5629
- try {
5630
- await this.enqueueRequest({
5631
- description: "Delete form submission attachments",
5632
- method: HttpMethod.DELETE,
5633
- url: `/forms/submissions/${submissionId}/attachments/bulk/`,
5634
- payload: { attachments: attachmentsIds },
5635
- blockers: [submissionId, ...attachmentsIds],
5636
- blocks: []
5637
- });
5638
- } catch (e) {
5639
- this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
5640
- throw e;
5641
- }
5642
- }
5643
- // Outer promise is for hashing and caching files for submission attachments
5644
- async add(payload) {
5504
+ add(payload) {
5645
5505
  var _a2;
5646
5506
  const { store } = this.client;
5647
5507
  const state = store.getState();
5648
- const { values, files } = separateFilesFromValues(payload.values);
5508
+ const { values } = separateFilesFromValues(payload.values);
5649
5509
  const offlineSubmission = offline({
5650
5510
  ...payload,
5651
5511
  values,
@@ -5653,135 +5513,35 @@ class FormSubmissionService extends BaseUploadService {
5653
5513
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
5654
5514
  });
5655
5515
  const promise = this.enqueueRequest({
5656
- description: "Respond to form",
5516
+ description: "Add form submission",
5657
5517
  method: HttpMethod.POST,
5658
- url: `/forms/revisions/${payload.form_revision}/respond/`,
5518
+ url: "/form-submissions/",
5659
5519
  payload: offlineSubmission,
5660
- blockers: [payload.issue, payload.asset, payload.asset_stage, "add-form-entry"].filter(
5661
- (x) => x !== void 0
5662
- ),
5663
- blocks: [offlineSubmission.offline_id]
5664
- });
5665
- this.dispatch(addFormSubmission(offlineSubmission));
5666
- const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
5667
- offlineSubmission.offline_id,
5668
- files
5669
- );
5520
+ blockers: [
5521
+ "add-form-entry",
5522
+ payload.form_revision,
5523
+ ...payload.issue ? [payload.issue] : [],
5524
+ ...payload.asset ? [payload.asset] : []
5525
+ ],
5526
+ blocks: [offlineSubmission.offline_id]
5527
+ });
5528
+ this.dispatch(addFormSubmission(offlineSubmission));
5670
5529
  promise.then((result) => {
5671
5530
  this.dispatch(setFormSubmission(result));
5672
5531
  return result;
5673
5532
  }).catch(() => {
5674
5533
  this.dispatch(deleteFormSubmission(offlineSubmission.offline_id));
5675
5534
  });
5676
- return [offlineSubmission, offlineFormSubmissionAttachments, promise, attachmentsPromise];
5677
- }
5678
- // Note currently the bulkAdd method is specific to form submissions for assets
5679
- // TODO: adapt the support bulk adding to any model type
5680
- async bulkAdd(args, batchSize) {
5681
- const { formRevision, commonFieldValues, fieldValuesByAsset } = args;
5682
- const { values: fileSeperatedCommonFieldValues, files: commonFiles } = separateFilesFromValues(commonFieldValues);
5683
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5684
- const transactionId = v4();
5685
- const assetIdBatches = chunkArray(Object.keys(fieldValuesByAsset), batchSize);
5686
- const bulkAddBatches = await Promise.all(
5687
- assetIdBatches.map(async (assetIdBatch) => {
5688
- const batchId = v4();
5689
- const submissionPayloads = [];
5690
- const attachmentPayloads = [];
5691
- const files = { ...commonFiles };
5692
- for (const assetId of assetIdBatch) {
5693
- const { values: fileSeperatedSubmissionSpecificValues, files: submissionSpecificFiles } = separateFilesFromValues(fieldValuesByAsset[assetId] ?? {});
5694
- Object.assign(files, submissionSpecificFiles);
5695
- const submissionPayload = offline({
5696
- asset_id: assetId,
5697
- form_data: fileSeperatedSubmissionSpecificValues
5698
- });
5699
- submissionPayloads.push(submissionPayload);
5700
- for (const [fieldIdentifier, fileArray] of Object.entries(files)) {
5701
- for (const file of fileArray) {
5702
- const sha1 = await hashFile(file);
5703
- await this.client.files.addCache(file, sha1);
5704
- const attachmentPayload = offline({
5705
- submission_id: submissionPayload.offline_id,
5706
- sha1,
5707
- name: file.name,
5708
- field_identifier: fieldIdentifier
5709
- });
5710
- attachmentPayloads.push(attachmentPayload);
5711
- }
5712
- }
5713
- }
5714
- const filePaylods = [];
5715
- for (const file of Object.values(files).flat()) {
5716
- const sha1 = await hashFile(file);
5717
- const filePayload = {
5718
- sha1,
5719
- extension: file.name.split(".").pop() || "",
5720
- file_type: file.type,
5721
- size: file.size
5722
- };
5723
- filePaylods.push(filePayload);
5724
- }
5725
- return {
5726
- batchId,
5727
- payload: {
5728
- transaction_id: transactionId,
5729
- form_data: fileSeperatedCommonFieldValues,
5730
- submitted_at: submittedAt,
5731
- submissions: submissionPayloads,
5732
- attachments: attachmentPayloads,
5733
- files: filePaylods
5734
- }
5735
- };
5736
- })
5737
- );
5738
- const batchPromises = [];
5739
- let prevBatchId = null;
5740
- for (const batch of bulkAddBatches) {
5741
- const { payload, batchId } = batch;
5742
- const batchAssetIds = payload.submissions.map((x) => x.asset_id);
5743
- const batchSubmissionOfflineIds = payload.submissions.map((x) => x.offline_id);
5744
- const batchAttachmentsOfflineIds = payload.attachments.map((x) => x.offline_id);
5745
- const blockers = batchAssetIds;
5746
- if (prevBatchId)
5747
- blockers.push(prevBatchId);
5748
- const blocks = [...batchSubmissionOfflineIds, ...batchAttachmentsOfflineIds, batchId];
5749
- const promise = this.enqueueRequest({
5750
- description: "Bulk add form submissions",
5751
- method: HttpMethod.POST,
5752
- url: `/forms/revisions/${formRevision}/bulk-respond/`,
5753
- payload,
5754
- blockers,
5755
- blocks
5756
- });
5757
- void promise.then(({ presigned_urls }) => {
5758
- this.processPresignedUrls(presigned_urls);
5759
- });
5760
- prevBatchId = batchId;
5761
- batchPromises.push(promise);
5762
- }
5763
- void Promise.all(batchPromises).then((results) => {
5764
- const createdSubmissions = [];
5765
- const createdAttachments = [];
5766
- for (const result of results) {
5767
- for (const createdSubmission of result.submissions)
5768
- createdSubmissions.push(createdSubmission);
5769
- for (const createdAttachment of result.attachments)
5770
- createdAttachments.push(createdAttachment);
5771
- }
5772
- this.dispatch(addFormSubmissions(createdSubmissions));
5773
- this.dispatch(addFormSubmissionAttachments(createdAttachments));
5774
- });
5775
- return batchPromises;
5535
+ return [offlineSubmission, promise];
5776
5536
  }
5777
- async update(payload) {
5537
+ update(payload) {
5778
5538
  const { store } = this.client;
5779
5539
  const state = store.getState();
5780
5540
  const submissionToBeUpdated = selectFormSubmissionById(payload.offline_id)(state);
5781
5541
  if (!submissionToBeUpdated) {
5782
5542
  throw new Error(`Expected submission with offline_id ${payload.offline_id} to exist`);
5783
5543
  }
5784
- const { values, files } = separateFilesFromValues(payload.values ?? {});
5544
+ const { values } = separateFilesFromValues(payload.values ?? {});
5785
5545
  const updatedSubmission = {
5786
5546
  ...submissionToBeUpdated,
5787
5547
  ...payload,
@@ -5795,39 +5555,18 @@ class FormSubmissionService extends BaseUploadService {
5795
5555
  const promise = this.enqueueRequest({
5796
5556
  description: "Delete user form submissions",
5797
5557
  method: HttpMethod.PATCH,
5798
- url: `/forms/submissions/${updatedSubmission.offline_id}/`,
5558
+ url: `/form-submissions/${updatedSubmission.offline_id}/`,
5799
5559
  // TODO: send just payload when FormSubmissionDeserializer is updated to handle partial updates
5800
5560
  payload: updatedSubmission,
5801
5561
  blockers: [updatedSubmission.offline_id],
5802
5562
  blocks: [updatedSubmission.offline_id]
5803
5563
  });
5804
- const formSubmissionAttachments = selectAttachmentsOfFormSubmission(payload.offline_id)(state);
5805
- const formSubmissionAttachmentIdsToBeDeleted = [];
5806
- for (const attachment of formSubmissionAttachments) {
5807
- if (attachment.field_identifier in files) {
5808
- formSubmissionAttachmentIdsToBeDeleted.push(attachment.offline_id);
5809
- }
5810
- }
5811
- const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
5812
- payload.offline_id,
5813
- files
5814
- );
5815
- const deleteAttachmentsPromise = this.bulkDeleteSubmissionAttachments(
5816
- payload.offline_id,
5817
- formSubmissionAttachmentIdsToBeDeleted
5818
- );
5819
5564
  promise.then((result) => {
5820
5565
  this.dispatch(setFormSubmission(result));
5821
5566
  }).catch(() => {
5822
5567
  this.dispatch(setFormSubmission(submissionToBeUpdated));
5823
5568
  });
5824
- return [
5825
- updatedSubmission,
5826
- offlineFormSubmissionAttachments,
5827
- promise,
5828
- attachmentsPromise,
5829
- deleteAttachmentsPromise
5830
- ];
5569
+ return [updatedSubmission, promise];
5831
5570
  }
5832
5571
  async delete(id) {
5833
5572
  const { store } = this.client;
@@ -5843,7 +5582,7 @@ class FormSubmissionService extends BaseUploadService {
5843
5582
  return await this.enqueueRequest({
5844
5583
  description: "Delete user form submissions",
5845
5584
  method: HttpMethod.DELETE,
5846
- url: `/forms/submissions/${id}/`,
5585
+ url: `/form-submissions/${id}/`,
5847
5586
  blockers: [id],
5848
5587
  blocks: []
5849
5588
  });
@@ -5854,50 +5593,17 @@ class FormSubmissionService extends BaseUploadService {
5854
5593
  }
5855
5594
  }
5856
5595
  async refreshStore(projectId) {
5857
- const formSubmissions = {};
5858
- const modelSubmissions = await this.enqueueRequest({
5859
- description: "Fetch model submissions",
5860
- method: HttpMethod.GET,
5861
- url: `/forms/in-project/${projectId}/submissions/model/latest/`,
5862
- blockers: [],
5863
- blocks: []
5864
- });
5865
- for (const modelSubmission of modelSubmissions) {
5866
- formSubmissions[modelSubmission.offline_id] = modelSubmission;
5867
- }
5868
- const standaloneSubmissions = await this.enqueueRequest({
5869
- description: "Fetch standalone submissions",
5870
- method: HttpMethod.GET,
5871
- url: `/forms/in-project/${projectId}/submissions/standalone/`,
5872
- blockers: [],
5873
- blocks: []
5874
- });
5875
- for (const standaloneSubmission of standaloneSubmissions) {
5876
- formSubmissions[standaloneSubmission.offline_id] = standaloneSubmission;
5877
- }
5878
- this.dispatch(initializeFormSubmissions(Object.values(formSubmissions)));
5879
- const attachments = {};
5880
- const modelAttachments = await this.enqueueRequest({
5881
- description: "Fetch model submission attachments",
5882
- method: HttpMethod.GET,
5883
- url: `/forms/in-project/${projectId}/attachments/model/latest/`,
5884
- blockers: [],
5885
- blocks: []
5886
- });
5887
- for (const modelAttachment of modelAttachments) {
5888
- attachments[modelAttachment.offline_id] = modelAttachment;
5889
- }
5890
- const standaloneAttachments = await this.enqueueRequest({
5891
- description: "Fetch standalone submission attachments",
5596
+ const result = await this.enqueueRequest({
5597
+ description: "Fetch form submissions",
5892
5598
  method: HttpMethod.GET,
5893
- url: `/forms/in-project/${projectId}/attachments/standalone/`,
5599
+ url: "/form-submissions/",
5600
+ queryParams: {
5601
+ project: projectId.toString()
5602
+ },
5894
5603
  blockers: [],
5895
5604
  blocks: []
5896
5605
  });
5897
- for (const standaloneAttachent of standaloneAttachments) {
5898
- attachments[standaloneAttachent.offline_id] = standaloneAttachent;
5899
- }
5900
- this.dispatch(initializeFormSubmissionAttachments(Object.values(attachments)));
5606
+ this.dispatch(initializeFormSubmissions(result));
5901
5607
  }
5902
5608
  }
5903
5609
  class WorkspaceService extends BaseApiService {
@@ -5963,9 +5669,9 @@ class WorkspaceService extends BaseApiService {
5963
5669
  blockers: [id],
5964
5670
  blocks: []
5965
5671
  });
5966
- void promise.catch((reason) => {
5672
+ void promise.catch((e) => {
5967
5673
  this.dispatch(addWorkspace(originalWorkspace));
5968
- throw reason;
5674
+ throw e;
5969
5675
  });
5970
5676
  return promise;
5971
5677
  }
@@ -6026,7 +5732,7 @@ const summarizeEvery = 20;
6026
5732
  class FileService extends BaseApiService {
6027
5733
  constructor() {
6028
5734
  super(...arguments);
6029
- __publicField(this, "host", {}.REACT_APP_API_URL);
5735
+ __publicField(this, "host");
6030
5736
  // NOTE: If you alter the schema (of the IndexedDB database) in any way, you must increment the version in order to
6031
5737
  // migrate the store. This allows idb to automatically migrate the user's existing data to the new schema.
6032
5738
  __publicField(this, "_dbPromise", openDB("fileCache", 1, {
@@ -6037,8 +5743,7 @@ class FileService extends BaseApiService {
6037
5743
  }
6038
5744
  async renewUploadUrl(sha1) {
6039
5745
  const file = await this.fetchCache(sha1);
6040
- if (!file)
6041
- throw new Error(`File with sha1 ${sha1} not found in cache`);
5746
+ if (!file) throw new Error(`File with sha1 ${sha1} not found in cache`);
6042
5747
  const key = await getFileS3Key(file, sha1);
6043
5748
  const s3UploadUrl = await this.enqueueRequest({
6044
5749
  description: "Get S3 URL",
@@ -6108,8 +5813,7 @@ class FileService extends BaseApiService {
6108
5813
  /** Ensure the file has been added to the file cache before calling `uploadFileToS3()` */
6109
5814
  async uploadFileToS3(sha1) {
6110
5815
  const file = await this.fetchCache(sha1);
6111
- if (!file)
6112
- throw new Error(`File with sha1 ${sha1} not found in cache`);
5816
+ if (!file) throw new Error(`File with sha1 ${sha1} not found in cache`);
6113
5817
  const key = await getFileS3Key(file, sha1);
6114
5818
  const dbFileProperties = {
6115
5819
  file_name: file.name,
@@ -6203,7 +5907,7 @@ class FileService extends BaseApiService {
6203
5907
  isExternalUrl flag in the request details is set to true, because instead of requesting the local
6204
5908
  REST API, you will be requesting localhost:80 (where this app runs), resulting in a transformed blob
6205
5909
  (with an offline_id attached) being returned. Alternatively, you may be running with
6206
- true, which will result in some file requests being treated as
5910
+ import.meta.env.PROD, which will result in some file requests being treated as
6207
5911
  external URLs and therefore not prepended with VITE_API_URL.`;
6208
5912
  throw new Error(message);
6209
5913
  }
@@ -6599,8 +6303,8 @@ class DocumentService extends BaseApiService {
6599
6303
  class DocumentAttachmentService extends BaseAttachmentService {
6600
6304
  constructor() {
6601
6305
  super(...arguments);
6602
- __publicField(this, "attachmentModel", AttachmentModel.Document);
6603
- __publicField(this, "initializeAttachments", initializeDocumentAttachments);
6306
+ __publicField(this, "name", "Document Attachment");
6307
+ __publicField(this, "url", "/document-attachments");
6604
6308
  __publicField(this, "addAttachments", addDocumentAttachments);
6605
6309
  __publicField(this, "updateAttachments", updateDocumentAttachments);
6606
6310
  __publicField(this, "removeAttachments", deleteDocumentAttachments);
@@ -6611,17 +6315,23 @@ class DocumentAttachmentService extends BaseAttachmentService {
6611
6315
  buildOfflineAttachment(data) {
6612
6316
  return offline({
6613
6317
  file: URL.createObjectURL(data.file),
6614
- file_sha1: data.sha1,
6615
- created_by: data.createdBy,
6318
+ file_sha1: data.file_sha1,
6319
+ created_by: data.created_by,
6616
6320
  file_name: data.file.name,
6617
6321
  file_type: data.file.type,
6618
- submitted_at: data.submittedAt,
6322
+ submitted_at: data.submitted_at,
6619
6323
  description: data.description,
6620
6324
  document: data.modelId
6621
6325
  });
6622
6326
  }
6327
+ buildAttachmentPayload(data) {
6328
+ return {
6329
+ ...data,
6330
+ document: data.modelId
6331
+ };
6332
+ }
6623
6333
  // NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
6624
- async attachFilesToDocument(files, documentId) {
6334
+ async bulkAdd(payloads) {
6625
6335
  var _a2;
6626
6336
  const { store } = this.client;
6627
6337
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
@@ -6630,40 +6340,37 @@ class DocumentAttachmentService extends BaseAttachmentService {
6630
6340
  const attachmentPayloads = [];
6631
6341
  const filePayloads = {};
6632
6342
  const sha1ToAttachmentIds = {};
6633
- for (const file of files) {
6634
- const sha1 = await hashFile(file);
6635
- if (!(sha1 in filePayloads)) {
6636
- filePayloads[sha1] = {
6637
- sha1,
6638
- file_type: file.type,
6639
- extension: file.name.split(".").pop(),
6640
- size: file.size
6641
- };
6642
- sha1ToAttachmentIds[sha1] = [];
6643
- await this.client.files.addCache(file, sha1);
6343
+ for (const payload of payloads) {
6344
+ const { documentId, file } = payload;
6345
+ const filePayload = await this.getFilePayload(file);
6346
+ if (!(filePayload.sha1 in filePayloads)) {
6347
+ filePayloads[filePayload.sha1] = filePayload;
6348
+ sha1ToAttachmentIds[filePayload.sha1] = [];
6644
6349
  }
6645
6350
  const offlineAttachment = this.buildOfflineAttachment({
6646
6351
  file,
6647
- sha1,
6648
- submittedAt,
6649
- createdBy,
6352
+ file_sha1: filePayload.sha1,
6353
+ submitted_at: submittedAt,
6354
+ created_by: createdBy,
6650
6355
  description: "",
6651
6356
  modelId: documentId
6652
6357
  });
6653
6358
  offlineAttachments.push(offlineAttachment);
6654
6359
  attachmentPayloads.push({
6655
6360
  offline_id: offlineAttachment.offline_id,
6656
- name: offlineAttachment.file_name,
6657
- sha1: offlineAttachment.file_sha1,
6658
- description: offlineAttachment.description
6361
+ file_name: offlineAttachment.file_name,
6362
+ file_sha1: offlineAttachment.file_sha1,
6363
+ file_extension: filePayload.extension,
6364
+ description: offlineAttachment.description,
6365
+ document: documentId
6659
6366
  });
6660
- sha1ToAttachmentIds[sha1].push(offlineAttachment.offline_id);
6367
+ sha1ToAttachmentIds[filePayload.sha1].push(offlineAttachment.offline_id);
6661
6368
  }
6662
6369
  this.dispatch(this.addAttachments(offlineAttachments));
6663
6370
  const promise = this.enqueueRequest({
6664
6371
  description: "Attach files to document",
6665
6372
  method: HttpMethod.POST,
6666
- url: `/documents/${documentId}/attach/`,
6373
+ url: "/document-attachments/bulk/",
6667
6374
  payload: {
6668
6375
  submitted_at: submittedAt,
6669
6376
  attachments: attachmentPayloads,
@@ -6688,14 +6395,14 @@ class DocumentAttachmentService extends BaseAttachmentService {
6688
6395
  });
6689
6396
  return [offlineAttachments, promise.then(({ attachments }) => attachments)];
6690
6397
  }
6691
- async deleteDocumentAttachment(attachmentId) {
6692
- return this.deleteAttachment(attachmentId);
6398
+ async delete(id) {
6399
+ return this._delete(id);
6693
6400
  }
6694
6401
  makeReadable(attachmnentId) {
6695
6402
  void this.enqueueRequest({
6696
6403
  description: "Add attachment to AI assistant",
6697
6404
  method: HttpMethod.PATCH,
6698
- url: `/documents/attachments/${attachmnentId}/`,
6405
+ url: `/document-attachments/${attachmnentId}/`,
6699
6406
  payload: {
6700
6407
  readable_to_assistant: true
6701
6408
  },
@@ -6712,7 +6419,7 @@ class DocumentAttachmentService extends BaseAttachmentService {
6712
6419
  blocks: [],
6713
6420
  blockers: []
6714
6421
  });
6715
- this.dispatch(this.initializeAttachments(projectDocumentAttachments));
6422
+ this.dispatch(initializeDocumentAttachments(projectDocumentAttachments));
6716
6423
  const organizationDocumentAttachments = await this.enqueueRequest({
6717
6424
  description: "Get document attachments",
6718
6425
  method: HttpMethod.GET,
@@ -6948,17 +6655,11 @@ class GeoImageService extends BaseUploadService {
6948
6655
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6949
6656
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6950
6657
  const projectId = payloadWithoutFile.project;
6951
- const sha1 = await hashFile(file);
6952
- const filePayload = {
6953
- sha1,
6954
- file_type: file.type,
6955
- extension: file.name.split(".").pop(),
6956
- size: file.size
6957
- };
6658
+ const filePayload = await this.getFilePayload(file);
6958
6659
  const offlineMapImage = offline({
6959
6660
  ...payloadWithoutFile,
6960
6661
  file_name: file.name,
6961
- file_sha1: sha1,
6662
+ file_sha1: filePayload.sha1,
6962
6663
  file: URL.createObjectURL(file),
6963
6664
  submitted_at: submittedAt,
6964
6665
  created_by: createdBy
@@ -7001,23 +6702,15 @@ class GeoImageService extends BaseUploadService {
7001
6702
  const offlineGeoImages = [];
7002
6703
  const offlineIds = [];
7003
6704
  const geoImagePayloads = [];
7004
- const filePayloadRecord = {};
6705
+ const filePayloads = {};
7005
6706
  for (const payloadAndFile of payloads) {
7006
6707
  const { file, ...payload } = payloadAndFile;
7007
- const sha1 = await hashFile(file);
7008
- if (!(sha1 in filePayloadRecord)) {
7009
- filePayloadRecord[sha1] = {
7010
- sha1,
7011
- file_type: file.type,
7012
- extension: file.name.split(".").pop(),
7013
- size: file.size
7014
- };
7015
- await this.client.files.addCache(file, sha1);
7016
- }
6708
+ const filePayload = await this.getFilePayload(file);
6709
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
7017
6710
  const offlineMapImage = offline({
7018
6711
  ...payload,
7019
6712
  file_name: file.name,
7020
- file_sha1: sha1,
6713
+ file_sha1: filePayload.sha1,
7021
6714
  file: URL.createObjectURL(file),
7022
6715
  submitted_at: submittedAt,
7023
6716
  created_by: createdBy,
@@ -7046,7 +6739,7 @@ class GeoImageService extends BaseUploadService {
7046
6739
  submitted_at: submittedAt,
7047
6740
  project: projectId,
7048
6741
  geo_images: geoImagePayloads,
7049
- files: Object.values(filePayloadRecord)
6742
+ files: Object.values(filePayloads)
7050
6743
  },
7051
6744
  blocks: [projectId.toString()],
7052
6745
  blockers: offlineIds
@@ -7114,7 +6807,7 @@ class GeoImageService extends BaseUploadService {
7114
6807
  this.dispatch(initializeGeoImages(result));
7115
6808
  }
7116
6809
  }
7117
- class IssueAssociationService extends BaseUploadService {
6810
+ class IssueAssociationService extends BaseApiService {
7118
6811
  add(payload) {
7119
6812
  var _a2;
7120
6813
  const { store } = this.client;
@@ -7129,7 +6822,7 @@ class IssueAssociationService extends BaseUploadService {
7129
6822
  const promise = this.enqueueRequest({
7130
6823
  description: "Add issue association",
7131
6824
  method: HttpMethod.POST,
7132
- url: "/issues/associations/",
6825
+ url: "/issue-associations/",
7133
6826
  payload: {
7134
6827
  offline_id: offlineIssueAssociation.offline_id,
7135
6828
  submitted_at: submittedAt,
@@ -7159,7 +6852,7 @@ class IssueAssociationService extends BaseUploadService {
7159
6852
  const promise = this.enqueueRequest({
7160
6853
  description: "Delete issue association",
7161
6854
  method: HttpMethod.DELETE,
7162
- url: `/issues/associations/${id}/`,
6855
+ url: `/issue-associations/${id}/`,
7163
6856
  blockers: [id],
7164
6857
  blocks: []
7165
6858
  });
@@ -7172,14 +6865,917 @@ class IssueAssociationService extends BaseUploadService {
7172
6865
  const issueAssociations = await this.enqueueRequest({
7173
6866
  description: "Fetch issue associations",
7174
6867
  method: HttpMethod.GET,
7175
- url: "/issues/associations/",
7176
- queryParams: { project_id: projectId.toString() },
6868
+ url: "/issue-associations/",
6869
+ queryParams: { project: projectId.toString() },
7177
6870
  blockers: [],
7178
6871
  blocks: []
7179
6872
  });
7180
6873
  this.dispatch(initializeIssueAssociations(issueAssociations));
7181
6874
  }
7182
6875
  }
6876
+ class FormRevisionAttachmentService extends BaseUploadService {
6877
+ async bulkAdd(payloads) {
6878
+ var _a2;
6879
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6880
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6881
+ const filePayloads = {};
6882
+ const offlineFormRevisionAttachments = [];
6883
+ const attachmentPayloads = [];
6884
+ for (const payload of payloads) {
6885
+ const { revisionId, fieldIdentifier, file } = payload;
6886
+ const filePayload = await this.getFilePayload(file);
6887
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
6888
+ const offlineFormRevisionAttachment = offline({
6889
+ file: URL.createObjectURL(file),
6890
+ file_type: file.type,
6891
+ file_name: file.name,
6892
+ file_sha1: filePayload.sha1,
6893
+ created_by: createdBy,
6894
+ form_revision: revisionId,
6895
+ submitted_at: submittedAt,
6896
+ field_identifier: fieldIdentifier
6897
+ });
6898
+ offlineFormRevisionAttachments.push(offlineFormRevisionAttachment);
6899
+ const attachmentPayload = {
6900
+ offline_id: offlineFormRevisionAttachment.offline_id,
6901
+ file_name: file.name,
6902
+ field_identifier: fieldIdentifier,
6903
+ file_extension: filePayload.extension,
6904
+ file_sha1: filePayload.sha1,
6905
+ form_revision: revisionId
6906
+ };
6907
+ attachmentPayloads.push(attachmentPayload);
6908
+ }
6909
+ this.dispatch(addFormRevisionAttachments(offlineFormRevisionAttachments));
6910
+ const promise = this.enqueueRequest({
6911
+ description: "Attach files to form revision",
6912
+ method: HttpMethod.POST,
6913
+ url: "/form-revision-attachments/bulk/",
6914
+ payload: {
6915
+ submitted_at: submittedAt,
6916
+ attachments: attachmentPayloads,
6917
+ files: Object.values(filePayloads)
6918
+ },
6919
+ blockers: offlineFormRevisionAttachments.map((attachment) => attachment.form_revision),
6920
+ blocks: offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
6921
+ });
6922
+ promise.then((result) => {
6923
+ this.processPresignedUrls(result.presigned_urls);
6924
+ this.dispatch(updateFormRevisionAttachments(result.attachments));
6925
+ }).catch(() => {
6926
+ this.dispatch(
6927
+ deleteFormRevisionAttachments(
6928
+ offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
6929
+ )
6930
+ );
6931
+ });
6932
+ return [offlineFormRevisionAttachments, promise.then(({ attachments }) => attachments)];
6933
+ }
6934
+ async refreshStore(organizationId) {
6935
+ const formRevisions = await this.enqueueRequest({
6936
+ description: "Fetch organization form revision attachments",
6937
+ method: HttpMethod.GET,
6938
+ url: "/form-revision-attachments/",
6939
+ queryParams: {
6940
+ organization: organizationId.toString()
6941
+ },
6942
+ blockers: [organizationId.toString()],
6943
+ blocks: []
6944
+ });
6945
+ this.dispatch(initializeFormRevisionAttachments(formRevisions));
6946
+ }
6947
+ }
6948
+ class FormSubmissionAttachmentService extends BaseUploadService {
6949
+ async bulkAdd(payloads) {
6950
+ var _a2;
6951
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6952
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6953
+ const filePayloads = {};
6954
+ const offlineFormSubmissionAttachments = [];
6955
+ const attachmentPayloads = [];
6956
+ for (const payload of payloads) {
6957
+ const { submissionId, fieldIdentifier, file } = payload;
6958
+ const filePayload = await this.getFilePayload(file);
6959
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
6960
+ const offlineFormSubmissionAttachment = offline({
6961
+ file: URL.createObjectURL(file),
6962
+ file_type: file.type,
6963
+ file_name: file.name,
6964
+ file_sha1: filePayload.sha1,
6965
+ created_by: createdBy,
6966
+ form_submission: submissionId,
6967
+ submitted_at: submittedAt,
6968
+ field_identifier: fieldIdentifier
6969
+ });
6970
+ offlineFormSubmissionAttachments.push(offlineFormSubmissionAttachment);
6971
+ const attachmentPayload = {
6972
+ offline_id: offlineFormSubmissionAttachment.offline_id,
6973
+ file_name: file.name,
6974
+ file_sha1: filePayload.sha1,
6975
+ file_extension: filePayload.extension,
6976
+ field_identifier: fieldIdentifier,
6977
+ form_submission: submissionId
6978
+ };
6979
+ attachmentPayloads.push(attachmentPayload);
6980
+ }
6981
+ this.dispatch(addFormSubmissionAttachments(offlineFormSubmissionAttachments));
6982
+ const promise = this.enqueueRequest({
6983
+ description: "Attach files to form submission",
6984
+ method: HttpMethod.POST,
6985
+ url: "/form-submission-attachments/bulk/",
6986
+ payload: {
6987
+ submitted_at: submittedAt,
6988
+ attachments: attachmentPayloads,
6989
+ files: Object.values(filePayloads)
6990
+ },
6991
+ blockers: offlineFormSubmissionAttachments.map((attachment) => attachment.form_submission),
6992
+ blocks: offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
6993
+ });
6994
+ promise.then((result) => {
6995
+ this.processPresignedUrls(result.presigned_urls);
6996
+ this.dispatch(updateFormSubmissionAttachments(result.attachments));
6997
+ }).catch((error) => {
6998
+ this.dispatch(
6999
+ deleteFormSubmissionAttachments(
7000
+ offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
7001
+ )
7002
+ );
7003
+ throw error;
7004
+ });
7005
+ return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
7006
+ }
7007
+ async bulkDelete(attachmentsIds) {
7008
+ const { store } = this.client;
7009
+ const state = store.getState();
7010
+ const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
7011
+ this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
7012
+ try {
7013
+ await this.enqueueRequest({
7014
+ description: "Delete form submission attachments",
7015
+ method: HttpMethod.DELETE,
7016
+ url: "/form-submission-attachments/bulk/",
7017
+ payload: { attachment_ids: attachmentsIds },
7018
+ blockers: attachmentsIds,
7019
+ blocks: []
7020
+ });
7021
+ } catch (e) {
7022
+ this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
7023
+ throw e;
7024
+ }
7025
+ }
7026
+ async refreshStore(projectId) {
7027
+ const result = await this.enqueueRequest({
7028
+ description: "Get form submission attachments",
7029
+ method: HttpMethod.GET,
7030
+ url: "/form-submission-attachments/",
7031
+ queryParams: {
7032
+ project: projectId.toString()
7033
+ },
7034
+ blockers: [],
7035
+ blocks: []
7036
+ });
7037
+ this.dispatch(initializeFormSubmissionAttachments(result));
7038
+ }
7039
+ }
7040
+ class FormRevisionService extends BaseUploadService {
7041
+ add(payload) {
7042
+ var _a2;
7043
+ const { store } = this.client;
7044
+ const state = store.getState();
7045
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
7046
+ const offlineFormRevision = offline({
7047
+ ...payload,
7048
+ created_by: createdBy,
7049
+ revision: "Pending",
7050
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7051
+ });
7052
+ this.dispatch(addFormRevision(offlineFormRevision));
7053
+ const promise = this.enqueueRequest({
7054
+ description: "Create form revision",
7055
+ method: HttpMethod.POST,
7056
+ url: "/form-revisions/",
7057
+ payload: offlineFormRevision,
7058
+ blockers: [payload.form],
7059
+ blocks: [offlineFormRevision.offline_id]
7060
+ });
7061
+ void promise.then((result) => {
7062
+ this.dispatch(setFormRevision(result));
7063
+ }).catch(() => {
7064
+ this.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
7065
+ });
7066
+ return [offlineFormRevision, promise];
7067
+ }
7068
+ async refreshStore(organizationId) {
7069
+ const formRevisions = await this.enqueueRequest({
7070
+ description: "Get organization form revisions",
7071
+ method: HttpMethod.GET,
7072
+ url: "/form-revisions/",
7073
+ queryParams: {
7074
+ organization: organizationId.toString()
7075
+ },
7076
+ blockers: [organizationId.toString()],
7077
+ blocks: []
7078
+ });
7079
+ this.dispatch(initializeFormRevisions(formRevisions));
7080
+ }
7081
+ }
7082
+ class AssetTypeFieldsAttachmentService extends BaseUploadService {
7083
+ async bulkAdd(payloads) {
7084
+ var _a2;
7085
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7086
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7087
+ const filePayloads = {};
7088
+ const offlineAssetTypeFieldsAttachments = [];
7089
+ const attachmentPayloads = [];
7090
+ for (const payload of payloads) {
7091
+ const { fieldsRevisionId, fieldIdentifier, file } = payload;
7092
+ const filePayload = await this.getFilePayload(file);
7093
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
7094
+ const offlineAssetTypeFieldsAttachment = offline({
7095
+ file: URL.createObjectURL(file),
7096
+ file_type: file.type,
7097
+ file_name: file.name,
7098
+ file_sha1: filePayload.sha1,
7099
+ created_by: createdBy,
7100
+ fields_revision: fieldsRevisionId,
7101
+ submitted_at: submittedAt,
7102
+ field_identifier: fieldIdentifier
7103
+ });
7104
+ offlineAssetTypeFieldsAttachments.push(offlineAssetTypeFieldsAttachment);
7105
+ const attachmentPayload = {
7106
+ offline_id: offlineAssetTypeFieldsAttachment.offline_id,
7107
+ file_name: file.name,
7108
+ field_identifier: fieldIdentifier,
7109
+ file_extension: filePayload.extension,
7110
+ file_sha1: filePayload.sha1,
7111
+ fields_revision: fieldsRevisionId
7112
+ };
7113
+ attachmentPayloads.push(attachmentPayload);
7114
+ }
7115
+ this.dispatch(addAssetTypeFieldsAttachments(offlineAssetTypeFieldsAttachments));
7116
+ const promise = this.enqueueRequest({
7117
+ description: "Add asset type fields attachments",
7118
+ method: HttpMethod.POST,
7119
+ url: "/asset-type-fields-attachments/bulk/",
7120
+ payload: {
7121
+ submitted_at: submittedAt,
7122
+ attachments: attachmentPayloads,
7123
+ files: Object.values(filePayloads)
7124
+ },
7125
+ blockers: offlineAssetTypeFieldsAttachments.map((attachment) => attachment.fields_revision),
7126
+ blocks: offlineAssetTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7127
+ });
7128
+ promise.then((result) => {
7129
+ this.processPresignedUrls(result.presigned_urls);
7130
+ this.dispatch(updateAssetTypeFieldsAttachments(result.attachments));
7131
+ }).catch(() => {
7132
+ this.dispatch(
7133
+ deleteAssetTypeFieldsAttachments(
7134
+ offlineAssetTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7135
+ )
7136
+ );
7137
+ });
7138
+ return [offlineAssetTypeFieldsAttachments, promise.then(({ attachments }) => attachments)];
7139
+ }
7140
+ async refreshStore(organization) {
7141
+ const result = await this.enqueueRequest({
7142
+ description: "Get asset type fields attachments",
7143
+ method: HttpMethod.GET,
7144
+ url: "/asset-type-fields-attachments/",
7145
+ queryParams: {
7146
+ organization: organization.toString()
7147
+ },
7148
+ blockers: [organization.toString()],
7149
+ blocks: []
7150
+ });
7151
+ this.dispatch(initializeAssetTypeFieldsAttachments(result));
7152
+ }
7153
+ }
7154
+ class AssetTypeFieldsService extends BaseApiService {
7155
+ add(payload) {
7156
+ var _a2;
7157
+ const { store } = this.client;
7158
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7159
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7160
+ const offlineAssetTypeFields = offline({
7161
+ ...payload,
7162
+ created_by: createdBy,
7163
+ submitted_at: submittedAt
7164
+ });
7165
+ this.dispatch(addAssetTypeFields(offlineAssetTypeFields));
7166
+ const promise = this.enqueueRequest({
7167
+ description: "Add Asset Type Fields",
7168
+ method: HttpMethod.POST,
7169
+ url: "/asset-type-fields/",
7170
+ payload: offlineAssetTypeFields,
7171
+ blockers: [offlineAssetTypeFields.asset_type],
7172
+ blocks: [offlineAssetTypeFields.offline_id]
7173
+ });
7174
+ promise.then((response) => {
7175
+ this.dispatch(updateAssetTypeFields(response));
7176
+ }).catch((error) => {
7177
+ this.dispatch(deleteAssetTypeFields(offlineAssetTypeFields.offline_id));
7178
+ throw error;
7179
+ });
7180
+ return [offlineAssetTypeFields, promise];
7181
+ }
7182
+ async refreshStore(organizationId) {
7183
+ const result = await this.enqueueRequest({
7184
+ description: "Get Asset Type Fields",
7185
+ method: HttpMethod.GET,
7186
+ url: "/asset-type-fields/",
7187
+ queryParams: {
7188
+ organization: organizationId.toString()
7189
+ },
7190
+ blockers: [],
7191
+ blocks: []
7192
+ });
7193
+ this.dispatch(initializeAssetTypeFields(result));
7194
+ }
7195
+ }
7196
+ class AssetTypeFieldValuesService extends BaseApiService {
7197
+ add(payload) {
7198
+ var _a2;
7199
+ const { store } = this.client;
7200
+ const state = store.getState();
7201
+ const { values } = separateFilesFromValues(payload.values);
7202
+ const offlineAssetTypeFieldValues = offline({
7203
+ ...payload,
7204
+ values,
7205
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
7206
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7207
+ });
7208
+ const promise = this.enqueueRequest({
7209
+ description: "Add asset type field values",
7210
+ method: HttpMethod.POST,
7211
+ url: "/asset-type-field-values/",
7212
+ payload: offlineAssetTypeFieldValues,
7213
+ blockers: [payload.asset, payload.fields_revision],
7214
+ blocks: [offlineAssetTypeFieldValues.offline_id]
7215
+ });
7216
+ this.dispatch(addAssetTypeFieldValues(offlineAssetTypeFieldValues));
7217
+ promise.then((result) => {
7218
+ this.dispatch(updateAssetTypeFieldValues(result));
7219
+ return result;
7220
+ }).catch(() => {
7221
+ this.dispatch(deleteAssetTypeFieldValues(offlineAssetTypeFieldValues.offline_id));
7222
+ });
7223
+ return [offlineAssetTypeFieldValues, promise];
7224
+ }
7225
+ bulkAdd(payload, batchSize) {
7226
+ var _a2;
7227
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7228
+ const { values } = separateFilesFromValues(payload.values);
7229
+ const offlineAssetTypeFieldValuesMany = [];
7230
+ const batches = chunkArray(payload.payloads, batchSize ?? payload.payloads.length);
7231
+ const batchPayloads = [];
7232
+ for (const batch of batches) {
7233
+ const assetTypeFieldValuesPayloads = [];
7234
+ for (const payload2 of batch) {
7235
+ const offlineAssetTypeFieldValues = offline({
7236
+ ...payload2,
7237
+ values: separateFilesFromValues(payload2.values).values,
7238
+ created_by: (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
7239
+ submitted_at: submittedAt
7240
+ });
7241
+ offlineAssetTypeFieldValuesMany.push(offlineAssetTypeFieldValues);
7242
+ assetTypeFieldValuesPayloads.push({
7243
+ offline_id: offlineAssetTypeFieldValues.offline_id,
7244
+ asset: payload2.asset,
7245
+ fields_revision: payload2.fields_revision,
7246
+ published_at: payload2.published_at,
7247
+ values: offlineAssetTypeFieldValues.values
7248
+ });
7249
+ }
7250
+ batchPayloads.push({
7251
+ submitted_at: submittedAt,
7252
+ values,
7253
+ field_values: assetTypeFieldValuesPayloads
7254
+ });
7255
+ }
7256
+ this.dispatch(addAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany));
7257
+ const promises = [];
7258
+ for (const payload2 of batchPayloads) {
7259
+ const assetIds = payload2.field_values.map((x) => x.asset);
7260
+ const assetTypeFieldsIds = payload2.field_values.map((x) => x.fields_revision);
7261
+ const assetTypeFieldValuesIds = payload2.field_values.map((x) => x.offline_id);
7262
+ const promise = this.enqueueRequest({
7263
+ description: "Bulk add asset type field values",
7264
+ method: HttpMethod.POST,
7265
+ url: "/asset-type-field-values/bulk/",
7266
+ payload: payload2,
7267
+ blockers: [...assetIds, ...assetTypeFieldsIds],
7268
+ blocks: assetTypeFieldValuesIds
7269
+ });
7270
+ promises.push(promise);
7271
+ }
7272
+ void Promise.all(promises).then((results) => {
7273
+ this.dispatch(updateAssetTypeFieldValuesMany(results.flat()));
7274
+ }).catch(() => {
7275
+ this.dispatch(deleteAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany.map((x) => x.offline_id)));
7276
+ });
7277
+ return [offlineAssetTypeFieldValuesMany, promises];
7278
+ }
7279
+ update(payload) {
7280
+ const { store } = this.client;
7281
+ const state = store.getState();
7282
+ const assetTypeFieldValues = selectAssetTypeFieldValuesById(payload.offline_id)(state);
7283
+ if (!assetTypeFieldValues) {
7284
+ throw new Error(`Expected AssetTypeFieldValues with offline_id ${payload.offline_id} to exist`);
7285
+ }
7286
+ const { values } = separateFilesFromValues(payload.values ?? {});
7287
+ const updatedAssetTypeFieldValues = {
7288
+ ...assetTypeFieldValues,
7289
+ ...payload,
7290
+ // values could also have a partial update
7291
+ values: {
7292
+ ...assetTypeFieldValues.values,
7293
+ ...values
7294
+ }
7295
+ };
7296
+ this.dispatch(updateAssetTypeFieldValues(updatedAssetTypeFieldValues));
7297
+ const promise = this.enqueueRequest({
7298
+ description: "Delete asset type field values",
7299
+ method: HttpMethod.PATCH,
7300
+ url: `/asset-type-field-values/${payload.offline_id}/`,
7301
+ payload: {
7302
+ ...payload,
7303
+ values: {
7304
+ ...assetTypeFieldValues.values,
7305
+ ...values
7306
+ }
7307
+ },
7308
+ blockers: [
7309
+ updatedAssetTypeFieldValues.offline_id,
7310
+ updatedAssetTypeFieldValues.fields_revision,
7311
+ updatedAssetTypeFieldValues.asset
7312
+ ],
7313
+ blocks: [updatedAssetTypeFieldValues.offline_id]
7314
+ });
7315
+ promise.then((result) => {
7316
+ this.dispatch(updateAssetTypeFieldValues(result));
7317
+ }).catch(() => {
7318
+ this.dispatch(updateAssetTypeFieldValues(assetTypeFieldValues));
7319
+ });
7320
+ return [updatedAssetTypeFieldValues, promise];
7321
+ }
7322
+ async delete(id) {
7323
+ const { store } = this.client;
7324
+ const state = store.getState();
7325
+ const assetTypeFieldValues = selectAssetTypeFieldValuesById(id)(state);
7326
+ if (!assetTypeFieldValues) {
7327
+ throw new Error(`Expected submission with offline_id ${id} to exist`);
7328
+ }
7329
+ const assetTypeFieldValuesAttachments = selectAttachmentsOfAssetTypeFieldValues(id)(state);
7330
+ this.dispatch(deleteAssetTypeFieldValues(id));
7331
+ this.dispatch(deleteAssetTypeFieldValuesAttachments(assetTypeFieldValuesAttachments.map((x) => x.offline_id)));
7332
+ try {
7333
+ await this.enqueueRequest({
7334
+ description: "Delete asset type field values",
7335
+ method: HttpMethod.DELETE,
7336
+ url: `/asset-type-field-values/${id}/`,
7337
+ blockers: [id],
7338
+ blocks: []
7339
+ });
7340
+ } catch (e) {
7341
+ this.dispatch(addAssetTypeFieldValues(assetTypeFieldValues));
7342
+ this.dispatch(addAssetTypeFieldValuesAttachments(assetTypeFieldValuesAttachments));
7343
+ throw e;
7344
+ }
7345
+ }
7346
+ async refreshStore(projectId) {
7347
+ const result = await this.enqueueRequest({
7348
+ description: "Get asset type field values",
7349
+ method: HttpMethod.GET,
7350
+ url: "/asset-type-field-values/",
7351
+ queryParams: {
7352
+ project: projectId.toString()
7353
+ },
7354
+ blockers: [],
7355
+ blocks: []
7356
+ });
7357
+ this.dispatch(initializeAssetTypeFieldValues(result));
7358
+ }
7359
+ }
7360
+ class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
7361
+ async bulkAdd(payloads, batchSize) {
7362
+ var _a2;
7363
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7364
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7365
+ const batches = chunkArray(payloads, batchSize ?? payloads.length);
7366
+ const offlineAssetTypeFieldValuesAttachments = [];
7367
+ const batchPayloads = [];
7368
+ for (const batch of batches) {
7369
+ const filePayloads = {};
7370
+ const attachmentPayloads = [];
7371
+ for (const payload of batch) {
7372
+ const { fieldValuesId, fieldIdentifier, file } = payload;
7373
+ const filePayload = await this.getFilePayload(file);
7374
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
7375
+ const offlineAssetTypeFieldValuesAttachment = offline({
7376
+ file: URL.createObjectURL(file),
7377
+ file_type: file.type,
7378
+ file_name: file.name,
7379
+ file_sha1: filePayload.sha1,
7380
+ created_by: createdBy,
7381
+ field_values: fieldValuesId,
7382
+ submitted_at: submittedAt,
7383
+ field_identifier: fieldIdentifier
7384
+ });
7385
+ offlineAssetTypeFieldValuesAttachments.push(offlineAssetTypeFieldValuesAttachment);
7386
+ const attachmentPayload = {
7387
+ offline_id: offlineAssetTypeFieldValuesAttachment.offline_id,
7388
+ file_name: file.name,
7389
+ file_sha1: filePayload.sha1,
7390
+ file_extension: filePayload.extension,
7391
+ field_identifier: fieldIdentifier,
7392
+ field_values: fieldValuesId
7393
+ };
7394
+ attachmentPayloads.push(attachmentPayload);
7395
+ }
7396
+ batchPayloads.push({
7397
+ submitted_at: submittedAt,
7398
+ attachments: attachmentPayloads,
7399
+ files: Object.values(filePayloads)
7400
+ });
7401
+ }
7402
+ this.dispatch(addAssetTypeFieldValuesAttachments(offlineAssetTypeFieldValuesAttachments));
7403
+ const promises = batchPayloads.map((payload) => {
7404
+ return this.enqueueRequest({
7405
+ description: "Add asset type field values attachments",
7406
+ method: HttpMethod.POST,
7407
+ url: "/asset-type-field-values-attachments/bulk/",
7408
+ payload,
7409
+ blockers: payload.attachments.map((payload2) => payload2.field_values),
7410
+ blocks: payload.attachments.map((payload2) => payload2.offline_id)
7411
+ });
7412
+ });
7413
+ Promise.all(promises).then((result) => {
7414
+ for (const res of result) this.processPresignedUrls(res.presigned_urls);
7415
+ const attachments = result.flatMap((res) => res.attachments);
7416
+ this.dispatch(updateAssetTypeFieldValuesAttachments(attachments));
7417
+ }).catch((error) => {
7418
+ this.dispatch(
7419
+ deleteAssetTypeFieldValuesAttachments(
7420
+ offlineAssetTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7421
+ )
7422
+ );
7423
+ throw error;
7424
+ });
7425
+ return [
7426
+ offlineAssetTypeFieldValuesAttachments,
7427
+ promises.map((promise) => promise.then(({ attachments }) => attachments))
7428
+ ];
7429
+ }
7430
+ async bulkDelete(ids) {
7431
+ const { store } = this.client;
7432
+ const state = store.getState();
7433
+ const attachments = selectAssetTypeFieldValuesAttachmentsByIds(ids)(state);
7434
+ this.dispatch(deleteAssetTypeFieldValuesAttachments(ids));
7435
+ try {
7436
+ await this.enqueueRequest({
7437
+ description: "Delete asset type field values attachments",
7438
+ method: HttpMethod.DELETE,
7439
+ url: "/asset-type-field-values-attachments/bulk/",
7440
+ payload: { attachment_ids: ids },
7441
+ blockers: ids,
7442
+ blocks: []
7443
+ });
7444
+ } catch (e) {
7445
+ this.dispatch(addAssetTypeFieldValuesAttachments(attachments));
7446
+ throw e;
7447
+ }
7448
+ }
7449
+ async refreshStore(projectId) {
7450
+ const result = await this.enqueueRequest({
7451
+ description: "Get asset type field values attachments",
7452
+ method: HttpMethod.GET,
7453
+ url: "/asset-type-field-values-attachments/",
7454
+ queryParams: {
7455
+ project: projectId.toString()
7456
+ },
7457
+ blockers: [],
7458
+ blocks: []
7459
+ });
7460
+ this.dispatch(initializeAssetTypeFieldValuesAttachments(result));
7461
+ }
7462
+ }
7463
+ class IssueTypeFieldsAttachmentService extends BaseUploadService {
7464
+ async bulkAdd(payloads) {
7465
+ var _a2;
7466
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7467
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7468
+ const filePayloads = {};
7469
+ const offlineIssueTypeFieldsAttachments = [];
7470
+ const attachmentPayloads = [];
7471
+ for (const payload of payloads) {
7472
+ const { fieldsRevisionId, fieldIdentifier, file } = payload;
7473
+ const filePayload = await this.getFilePayload(file);
7474
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
7475
+ const offlineIssueTypeFieldsAttachment = offline({
7476
+ file: URL.createObjectURL(file),
7477
+ file_type: file.type,
7478
+ file_name: file.name,
7479
+ file_sha1: filePayload.sha1,
7480
+ created_by: createdBy,
7481
+ fields_revision: fieldsRevisionId,
7482
+ submitted_at: submittedAt,
7483
+ field_identifier: fieldIdentifier
7484
+ });
7485
+ offlineIssueTypeFieldsAttachments.push(offlineIssueTypeFieldsAttachment);
7486
+ const attachmentPayload = {
7487
+ offline_id: offlineIssueTypeFieldsAttachment.offline_id,
7488
+ file_name: file.name,
7489
+ file_extension: filePayload.extension,
7490
+ field_identifier: fieldIdentifier,
7491
+ file_sha1: filePayload.sha1,
7492
+ fields_revision: fieldsRevisionId
7493
+ };
7494
+ attachmentPayloads.push(attachmentPayload);
7495
+ }
7496
+ this.dispatch(addIssueTypeFieldsAttachments(offlineIssueTypeFieldsAttachments));
7497
+ const promise = this.enqueueRequest({
7498
+ description: "Add issue type fields attachments",
7499
+ method: HttpMethod.POST,
7500
+ url: "/issue-type-fields-attachments/bulk/",
7501
+ payload: {
7502
+ submitted_at: submittedAt,
7503
+ attachments: attachmentPayloads,
7504
+ files: Object.values(filePayloads)
7505
+ },
7506
+ blockers: offlineIssueTypeFieldsAttachments.map((attachment) => attachment.fields_revision),
7507
+ blocks: offlineIssueTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7508
+ });
7509
+ promise.then((result) => {
7510
+ this.processPresignedUrls(result.presigned_urls);
7511
+ this.dispatch(updateIssueTypeFieldsAttachments(result.attachments));
7512
+ }).catch(() => {
7513
+ this.dispatch(
7514
+ deleteIssueTypeFieldsAttachments(
7515
+ offlineIssueTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7516
+ )
7517
+ );
7518
+ });
7519
+ return [offlineIssueTypeFieldsAttachments, promise.then(({ attachments }) => attachments)];
7520
+ }
7521
+ async refreshStore(organizationId) {
7522
+ const result = await this.enqueueRequest({
7523
+ description: "get issue type fields attachments",
7524
+ method: HttpMethod.GET,
7525
+ url: "/issue-type-fields-attachments/",
7526
+ queryParams: {
7527
+ organization: organizationId.toString()
7528
+ },
7529
+ blockers: [organizationId.toString()],
7530
+ blocks: []
7531
+ });
7532
+ this.dispatch(initializeIssueTypeFieldsAttachments(result));
7533
+ }
7534
+ }
7535
+ class IssueTypeFieldsService extends BaseApiService {
7536
+ add(payload) {
7537
+ var _a2;
7538
+ const { store } = this.client;
7539
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7540
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7541
+ const offlineIssueTypeFields = offline({
7542
+ ...payload,
7543
+ created_by: createdBy,
7544
+ submitted_at: submittedAt
7545
+ });
7546
+ this.dispatch(addIssueTypeFields(offlineIssueTypeFields));
7547
+ const promise = this.enqueueRequest({
7548
+ description: "Add Issue Type Fields",
7549
+ method: HttpMethod.POST,
7550
+ url: "/issue-type-fields/",
7551
+ payload: offlineIssueTypeFields,
7552
+ blockers: [offlineIssueTypeFields.issue_type],
7553
+ blocks: [offlineIssueTypeFields.offline_id]
7554
+ });
7555
+ promise.then((response) => {
7556
+ this.dispatch(updateIssueTypeFields(response));
7557
+ }).catch((error) => {
7558
+ this.dispatch(deleteIssueTypeFields(offlineIssueTypeFields.offline_id));
7559
+ throw error;
7560
+ });
7561
+ return [offlineIssueTypeFields, promise];
7562
+ }
7563
+ async refreshStore(organizationId) {
7564
+ const result = await this.enqueueRequest({
7565
+ description: "Get Issue Type Fields",
7566
+ method: HttpMethod.GET,
7567
+ url: "/issue-type-fields/",
7568
+ queryParams: {
7569
+ organization: organizationId.toString()
7570
+ },
7571
+ blockers: [],
7572
+ blocks: []
7573
+ });
7574
+ this.dispatch(initializeIssueTypeFields(result));
7575
+ }
7576
+ }
7577
+ class IssueTypeFieldValuesAttachmentService extends BaseUploadService {
7578
+ async bulkAdd(payloads) {
7579
+ var _a2;
7580
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7581
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7582
+ const filePayloads = {};
7583
+ const offlineIssueTypeFieldValuesAttachments = [];
7584
+ const attachmentPayloads = [];
7585
+ for (const payload of payloads) {
7586
+ const { fieldValuesId, fieldIdentifier, file } = payload;
7587
+ const filePayload = await this.getFilePayload(file);
7588
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
7589
+ const offlineIssueTypeFieldValuesAttachment = offline({
7590
+ file: URL.createObjectURL(file),
7591
+ file_type: file.type,
7592
+ file_name: file.name,
7593
+ file_sha1: filePayload.sha1,
7594
+ created_by: createdBy,
7595
+ field_values: fieldValuesId,
7596
+ submitted_at: submittedAt,
7597
+ field_identifier: fieldIdentifier
7598
+ });
7599
+ offlineIssueTypeFieldValuesAttachments.push(offlineIssueTypeFieldValuesAttachment);
7600
+ const attachmentPayload = {
7601
+ offline_id: offlineIssueTypeFieldValuesAttachment.offline_id,
7602
+ file_name: file.name,
7603
+ file_sha1: filePayload.sha1,
7604
+ file_extension: filePayload.extension,
7605
+ field_identifier: fieldIdentifier,
7606
+ field_values: fieldValuesId
7607
+ };
7608
+ attachmentPayloads.push(attachmentPayload);
7609
+ }
7610
+ this.dispatch(addIssueTypeFieldValuesAttachments(offlineIssueTypeFieldValuesAttachments));
7611
+ const promise = this.enqueueRequest({
7612
+ description: "Add issue type field values attachments",
7613
+ method: HttpMethod.POST,
7614
+ url: "/issue-type-field-values-attachments/bulk/",
7615
+ payload: {
7616
+ submitted_at: submittedAt,
7617
+ attachments: attachmentPayloads,
7618
+ files: Object.values(filePayloads)
7619
+ },
7620
+ blockers: offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.field_values),
7621
+ blocks: offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7622
+ });
7623
+ promise.then(({ presigned_urls, attachments }) => {
7624
+ this.processPresignedUrls(presigned_urls);
7625
+ this.dispatch(updateIssueTypeFieldValuesAttachments(attachments));
7626
+ }).catch((error) => {
7627
+ this.dispatch(
7628
+ deleteIssueTypeFieldValuesAttachments(
7629
+ offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7630
+ )
7631
+ );
7632
+ throw error;
7633
+ });
7634
+ return [offlineIssueTypeFieldValuesAttachments, promise.then(({ attachments }) => attachments)];
7635
+ }
7636
+ async bulkDelete(attachmentsIds) {
7637
+ const { store } = this.client;
7638
+ const state = store.getState();
7639
+ const attachments = selectIssueTypeFieldValuesAttachmentsByIds(attachmentsIds)(state);
7640
+ this.dispatch(deleteIssueTypeFieldValuesAttachments(attachmentsIds));
7641
+ try {
7642
+ await this.enqueueRequest({
7643
+ description: "Delete issue type field values attachments",
7644
+ method: HttpMethod.DELETE,
7645
+ url: "/issue-type-field-values-attachments/bulk/",
7646
+ payload: { attachment_ids: attachmentsIds },
7647
+ blockers: attachmentsIds,
7648
+ blocks: []
7649
+ });
7650
+ } catch (e) {
7651
+ this.dispatch(addIssueTypeFieldValuesAttachments(attachments));
7652
+ throw e;
7653
+ }
7654
+ }
7655
+ async refreshStore(projectId) {
7656
+ const result = await this.enqueueRequest({
7657
+ description: "Get issue type field values attachments",
7658
+ method: HttpMethod.GET,
7659
+ url: "/issue-type-field-values-attachments/",
7660
+ queryParams: {
7661
+ project: projectId.toString()
7662
+ },
7663
+ blockers: [],
7664
+ blocks: []
7665
+ });
7666
+ this.dispatch(initializeIssueTypeFieldValuesAttachments(result));
7667
+ }
7668
+ }
7669
+ class IssueTypeFieldValuesService extends BaseApiService {
7670
+ add(payload) {
7671
+ var _a2;
7672
+ const { store } = this.client;
7673
+ const state = store.getState();
7674
+ const { values } = separateFilesFromValues(payload.values);
7675
+ const offlineIssueTypeFieldValues = offline({
7676
+ ...payload,
7677
+ values,
7678
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
7679
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7680
+ });
7681
+ const promise = this.enqueueRequest({
7682
+ description: "Add issue type field values",
7683
+ method: HttpMethod.POST,
7684
+ url: "/issue-type-field-values/",
7685
+ payload: offlineIssueTypeFieldValues,
7686
+ blockers: [payload.issue, payload.fields_revision],
7687
+ blocks: [offlineIssueTypeFieldValues.offline_id]
7688
+ });
7689
+ this.dispatch(addIssueTypeFieldValues(offlineIssueTypeFieldValues));
7690
+ promise.then((result) => {
7691
+ this.dispatch(updateIssueTypeFieldValues(result));
7692
+ return result;
7693
+ }).catch(() => {
7694
+ this.dispatch(deleteIssueTypeFieldValues(offlineIssueTypeFieldValues.offline_id));
7695
+ });
7696
+ return [offlineIssueTypeFieldValues, promise];
7697
+ }
7698
+ update(payload) {
7699
+ const { store } = this.client;
7700
+ const state = store.getState();
7701
+ const issueTypeFieldValues = selectIssueTypeFieldValuesById(payload.offline_id)(state);
7702
+ if (!issueTypeFieldValues) {
7703
+ throw new Error(`Expected IssueTypeFieldValues with offline_id ${payload.offline_id} to exist`);
7704
+ }
7705
+ const { values } = separateFilesFromValues(payload.values ?? {});
7706
+ const updatedIssueTypeFieldValues = {
7707
+ ...issueTypeFieldValues,
7708
+ ...payload,
7709
+ // values could also have a partial update
7710
+ values: {
7711
+ ...issueTypeFieldValues.values,
7712
+ ...values
7713
+ }
7714
+ };
7715
+ this.dispatch(updateIssueTypeFieldValues(updatedIssueTypeFieldValues));
7716
+ const promise = this.enqueueRequest({
7717
+ description: "Update issue type field values",
7718
+ method: HttpMethod.PATCH,
7719
+ url: `/issue-type-field-values/${payload.offline_id}/`,
7720
+ payload: {
7721
+ ...payload,
7722
+ values: {
7723
+ ...issueTypeFieldValues.values,
7724
+ ...values
7725
+ }
7726
+ },
7727
+ blockers: [
7728
+ updatedIssueTypeFieldValues.offline_id,
7729
+ updatedIssueTypeFieldValues.fields_revision,
7730
+ updatedIssueTypeFieldValues.issue
7731
+ ],
7732
+ blocks: [updatedIssueTypeFieldValues.offline_id]
7733
+ });
7734
+ promise.then((result) => {
7735
+ this.dispatch(updateIssueTypeFieldValues(result));
7736
+ }).catch(() => {
7737
+ this.dispatch(updateIssueTypeFieldValues(issueTypeFieldValues));
7738
+ });
7739
+ return [updatedIssueTypeFieldValues, promise];
7740
+ }
7741
+ async delete(id) {
7742
+ const { store } = this.client;
7743
+ const state = store.getState();
7744
+ const issueTypeFieldValues = selectIssueTypeFieldValuesById(id)(state);
7745
+ if (!issueTypeFieldValues) {
7746
+ throw new Error(`Expected submission with offline_id ${id} to exist`);
7747
+ }
7748
+ const issueTypeFieldValuesAttachments = selectAttachmentsOfIssueTypeFieldValues(id)(state);
7749
+ this.dispatch(deleteIssueTypeFieldValues(id));
7750
+ this.dispatch(deleteIssueTypeFieldValuesAttachments(issueTypeFieldValuesAttachments.map((x) => x.offline_id)));
7751
+ try {
7752
+ await this.enqueueRequest({
7753
+ description: "Delete issue type field values",
7754
+ method: HttpMethod.DELETE,
7755
+ url: `/issue-type-field-values/${id}/`,
7756
+ blockers: [id],
7757
+ blocks: []
7758
+ });
7759
+ } catch (e) {
7760
+ this.dispatch(addIssueTypeFieldValues(issueTypeFieldValues));
7761
+ this.dispatch(addIssueTypeFieldValuesAttachments(issueTypeFieldValuesAttachments));
7762
+ throw e;
7763
+ }
7764
+ }
7765
+ async refreshStore(projectId) {
7766
+ const result = await this.enqueueRequest({
7767
+ description: "Get issue type field values",
7768
+ method: HttpMethod.GET,
7769
+ url: "/issue-type-field-values/",
7770
+ queryParams: {
7771
+ project: projectId.toString()
7772
+ },
7773
+ blockers: [],
7774
+ blocks: []
7775
+ });
7776
+ this.dispatch(initializeIssueTypeFieldValues(result));
7777
+ }
7778
+ }
7183
7779
  var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
7184
7780
  VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
7185
7781
  VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
@@ -7197,6 +7793,10 @@ export {
7197
7793
  AssetStageCompletionService,
7198
7794
  AssetStageService,
7199
7795
  AssetTypeAttachmentService,
7796
+ AssetTypeFieldValuesAttachmentService,
7797
+ AssetTypeFieldValuesService,
7798
+ AssetTypeFieldsAttachmentService,
7799
+ AssetTypeFieldsService,
7200
7800
  AssetTypeService,
7201
7801
  AttachmentModel,
7202
7802
  BaseApiService,
@@ -7213,7 +7813,10 @@ export {
7213
7813
  EmailDomainsService,
7214
7814
  EmailVerificationService,
7215
7815
  FileService,
7816
+ FormRevisionAttachmentService,
7817
+ FormRevisionService,
7216
7818
  FormService,
7819
+ FormSubmissionAttachmentService,
7217
7820
  FormSubmissionService,
7218
7821
  GREEN,
7219
7822
  GeoImageService,
@@ -7224,6 +7827,10 @@ export {
7224
7827
  IssuePriority,
7225
7828
  IssueService,
7226
7829
  IssueStatus,
7830
+ IssueTypeFieldValuesAttachmentService,
7831
+ IssueTypeFieldValuesService,
7832
+ IssueTypeFieldsAttachmentService,
7833
+ IssueTypeFieldsService,
7227
7834
  IssueTypeService,
7228
7835
  IssueUpdateChange,
7229
7836
  IssueUpdateService,
@@ -7243,6 +7850,7 @@ export {
7243
7850
  ProjectFileService,
7244
7851
  ProjectService,
7245
7852
  TeamService,
7853
+ UNKNOWN_ERROR_MESSAGE,
7246
7854
  UserService,
7247
7855
  VERSION_REDUCER_KEY,
7248
7856
  VerificationCodeType,
@@ -7261,6 +7869,14 @@ export {
7261
7869
  addAssetType,
7262
7870
  addAssetTypeAttachment,
7263
7871
  addAssetTypeAttachments,
7872
+ addAssetTypeFieldValues,
7873
+ addAssetTypeFieldValuesAttachment,
7874
+ addAssetTypeFieldValuesAttachments,
7875
+ addAssetTypeFieldValuesMany,
7876
+ addAssetTypeFields,
7877
+ addAssetTypeFieldsAttachment,
7878
+ addAssetTypeFieldsAttachments,
7879
+ addAssetTypeFieldsMany,
7264
7880
  addAssetTypes,
7265
7881
  addAssets,
7266
7882
  addCategory,
@@ -7289,6 +7905,14 @@ export {
7289
7905
  addIssueComment,
7290
7906
  addIssueComments,
7291
7907
  addIssueType,
7908
+ addIssueTypeFieldValues,
7909
+ addIssueTypeFieldValuesAttachment,
7910
+ addIssueTypeFieldValuesAttachments,
7911
+ addIssueTypeFieldValuesMany,
7912
+ addIssueTypeFields,
7913
+ addIssueTypeFieldsAttachment,
7914
+ addIssueTypeFieldsAttachments,
7915
+ addIssueTypeFieldsMany,
7292
7916
  addIssueUpdate,
7293
7917
  addIssueUpdates,
7294
7918
  addIssues,
@@ -7313,6 +7937,14 @@ export {
7313
7937
  assetStageSlice,
7314
7938
  assetTypeAttachmentReducer,
7315
7939
  assetTypeAttachmentSlice,
7940
+ assetTypeFieldValuesAttachmentReducer,
7941
+ assetTypeFieldValuesAttachmentSlice,
7942
+ assetTypeFieldValuesReducer,
7943
+ assetTypeFieldValuesSlice,
7944
+ assetTypeFieldsAttachmentReducer,
7945
+ assetTypeFieldsAttachmentSlice,
7946
+ assetTypeFieldsReducer,
7947
+ assetTypeFieldsSlice,
7316
7948
  assetTypeReducer,
7317
7949
  assetTypeSlice,
7318
7950
  authReducer,
@@ -7337,6 +7969,14 @@ export {
7337
7969
  deleteAssetType,
7338
7970
  deleteAssetTypeAttachment,
7339
7971
  deleteAssetTypeAttachments,
7972
+ deleteAssetTypeFieldValues,
7973
+ deleteAssetTypeFieldValuesAttachment,
7974
+ deleteAssetTypeFieldValuesAttachments,
7975
+ deleteAssetTypeFieldValuesMany,
7976
+ deleteAssetTypeFields,
7977
+ deleteAssetTypeFieldsAttachment,
7978
+ deleteAssetTypeFieldsAttachments,
7979
+ deleteAssetTypeFieldsMany,
7340
7980
  deleteAssetTypes,
7341
7981
  deleteAssets,
7342
7982
  deleteCategory,
@@ -7361,6 +8001,14 @@ export {
7361
8001
  deleteIssueAttachments,
7362
8002
  deleteIssueComment,
7363
8003
  deleteIssueComments,
8004
+ deleteIssueTypeFieldValues,
8005
+ deleteIssueTypeFieldValuesAttachment,
8006
+ deleteIssueTypeFieldValuesAttachments,
8007
+ deleteIssueTypeFieldValuesMany,
8008
+ deleteIssueTypeFields,
8009
+ deleteIssueTypeFieldsAttachment,
8010
+ deleteIssueTypeFieldsAttachments,
8011
+ deleteIssueTypeFieldsMany,
7364
8012
  deleteIssueUpdate,
7365
8013
  deleteIssueUpdates,
7366
8014
  deleteIssues,
@@ -7418,6 +8066,10 @@ export {
7418
8066
  initializeAssetStageCompletions,
7419
8067
  initializeAssetStages,
7420
8068
  initializeAssetTypeAttachments,
8069
+ initializeAssetTypeFieldValues,
8070
+ initializeAssetTypeFieldValuesAttachments,
8071
+ initializeAssetTypeFields,
8072
+ initializeAssetTypeFieldsAttachments,
7421
8073
  initializeAssetTypes,
7422
8074
  initializeAssets,
7423
8075
  initializeCategories,
@@ -7432,6 +8084,10 @@ export {
7432
8084
  initializeGeoImages,
7433
8085
  initializeIssueAssociations,
7434
8086
  initializeIssueAttachments,
8087
+ initializeIssueTypeFieldValues,
8088
+ initializeIssueTypeFieldValuesAttachments,
8089
+ initializeIssueTypeFields,
8090
+ initializeIssueTypeFieldsAttachments,
7435
8091
  initializeIssueTypes,
7436
8092
  initializeIssueUpdates,
7437
8093
  initializeIssues,
@@ -7451,6 +8107,14 @@ export {
7451
8107
  issueCommentSlice,
7452
8108
  issueReducer,
7453
8109
  issueSlice,
8110
+ issueTypeFieldValuesAttachmentReducer,
8111
+ issueTypeFieldValuesAttachmentSlice,
8112
+ issueTypeFieldValuesReducer,
8113
+ issueTypeFieldValuesSlice,
8114
+ issueTypeFieldsAttachmentReducer,
8115
+ issueTypeFieldsAttachmentSlice,
8116
+ issueTypeFieldsReducer,
8117
+ issueTypeFieldsSlice,
7454
8118
  issueTypeReducer,
7455
8119
  issueTypeSlice,
7456
8120
  issueUpdateReducer,
@@ -7514,7 +8178,23 @@ export {
7514
8178
  selectAssetTypeAttachmentMapping,
7515
8179
  selectAssetTypeAttachments,
7516
8180
  selectAssetTypeById,
8181
+ selectAssetTypeFieldValues,
8182
+ selectAssetTypeFieldValuesAttachmentById,
8183
+ selectAssetTypeFieldValuesAttachments,
8184
+ selectAssetTypeFieldValuesAttachmentsByIds,
8185
+ selectAssetTypeFieldValuesAttachmentsMapping,
8186
+ selectAssetTypeFieldValuesById,
8187
+ selectAssetTypeFieldValuesMapping,
8188
+ selectAssetTypeFieldValuesOfAsset,
8189
+ selectAssetTypeFields,
8190
+ selectAssetTypeFieldsAttachmentById,
8191
+ selectAssetTypeFieldsAttachments,
8192
+ selectAssetTypeFieldsAttachmentsMapping,
8193
+ selectAssetTypeFieldsById,
8194
+ selectAssetTypeFieldsMapping,
8195
+ selectAssetTypeFieldsOfAssetType,
7517
8196
  selectAssetTypeStagesMapping,
8197
+ selectAssetTypeValuesOfAssetType,
7518
8198
  selectAssetTypes,
7519
8199
  selectAssetTypesByIds,
7520
8200
  selectAssetTypesMapping,
@@ -7522,18 +8202,20 @@ export {
7522
8202
  selectAssetsByIds,
7523
8203
  selectAssetsMapping,
7524
8204
  selectAssetsOfAssetType,
7525
- selectAttachedFormSubmissionsOfAsset,
7526
- selectAttachedFormSubmissionsOfIssue,
7527
8205
  selectAttachmentsOfAsset,
7528
8206
  selectAttachmentsOfAssetByType,
7529
8207
  selectAttachmentsOfAssetType,
7530
8208
  selectAttachmentsOfAssetTypeByType,
8209
+ selectAttachmentsOfAssetTypeFieldValues,
8210
+ selectAttachmentsOfAssetTypeFields,
7531
8211
  selectAttachmentsOfDocument,
7532
8212
  selectAttachmentsOfDocumentByType,
7533
8213
  selectAttachmentsOfFormRevision,
7534
8214
  selectAttachmentsOfFormSubmission,
7535
8215
  selectAttachmentsOfIssue,
7536
8216
  selectAttachmentsOfIssueByType,
8217
+ selectAttachmentsOfIssueTypeFieldValues,
8218
+ selectAttachmentsOfIssueTypeFields,
7537
8219
  selectAttachmentsOfProject,
7538
8220
  selectAttachmentsOfProjectByType,
7539
8221
  selectCategories,
@@ -7559,8 +8241,6 @@ export {
7559
8241
  selectFilteredForms,
7560
8242
  selectFormById,
7561
8243
  selectFormMapping,
7562
- selectFormOfAssetType,
7563
- selectFormOfIssueType,
7564
8244
  selectFormRevisionAttachmentsMapping,
7565
8245
  selectFormRevisionById,
7566
8246
  selectFormRevisionMapping,
@@ -7570,16 +8250,11 @@ export {
7570
8250
  selectFormSubmissionAttachmentsMapping,
7571
8251
  selectFormSubmissionById,
7572
8252
  selectFormSubmissions,
7573
- selectFormSubmissionsByAssets,
7574
- selectFormSubmissionsByFormRevisions,
7575
- selectFormSubmissionsByIssues,
7576
8253
  selectFormSubmissionsMapping,
7577
8254
  selectFormSubmissionsOfAsset,
7578
8255
  selectFormSubmissionsOfForm,
7579
8256
  selectFormSubmissionsOfIssue,
7580
8257
  selectForms,
7581
- selectFormsCount,
7582
- selectGeneralFormCount,
7583
8258
  selectGeoImageById,
7584
8259
  selectGeoImageMapping,
7585
8260
  selectGeoImages,
@@ -7601,7 +8276,23 @@ export {
7601
8276
  selectIssueCountOfCategory,
7602
8277
  selectIssueMapping,
7603
8278
  selectIssueTypeById,
8279
+ selectIssueTypeFieldValues,
8280
+ selectIssueTypeFieldValuesAttachmentById,
8281
+ selectIssueTypeFieldValuesAttachments,
8282
+ selectIssueTypeFieldValuesAttachmentsByIds,
8283
+ selectIssueTypeFieldValuesAttachmentsMapping,
8284
+ selectIssueTypeFieldValuesById,
8285
+ selectIssueTypeFieldValuesMapping,
8286
+ selectIssueTypeFieldValuesOfIssue,
8287
+ selectIssueTypeFields,
8288
+ selectIssueTypeFieldsAttachmentById,
8289
+ selectIssueTypeFieldsAttachments,
8290
+ selectIssueTypeFieldsAttachmentsMapping,
8291
+ selectIssueTypeFieldsById,
8292
+ selectIssueTypeFieldsMapping,
8293
+ selectIssueTypeFieldsOfIssueType,
7604
8294
  selectIssueTypeMapping,
8295
+ selectIssueTypeValuesOfIssueType,
7605
8296
  selectIssueTypes,
7606
8297
  selectIssueTypesByIds,
7607
8298
  selectIssueTypesOfOrganization,
@@ -7610,8 +8301,9 @@ export {
7610
8301
  selectIssuesByIds,
7611
8302
  selectIssuesOfIssueType,
7612
8303
  selectIssuesOfIssueTypeCount,
7613
- selectLatestFormRevisionByForm,
8304
+ selectLatestAssetTypeFieldsOfAssetType,
7614
8305
  selectLatestFormRevisionOfForm,
8306
+ selectLatestIssueTypeFieldsOfIssueType,
7615
8307
  selectLatestRetryTime,
7616
8308
  selectLicense,
7617
8309
  selectLicenseForProject,
@@ -7648,10 +8340,8 @@ export {
7648
8340
  selectProjectsOfOrganization,
7649
8341
  selectRehydrated,
7650
8342
  selectRootDocuments,
7651
- selectSortedFormSubmissionsOfForm,
7652
8343
  selectSortedOrganizationUsers,
7653
8344
  selectSortedProjectUsers,
7654
- selectStageFormIdsFromStageIds,
7655
8345
  selectStageMapping,
7656
8346
  selectStagesOfAssetType,
7657
8347
  selectTeamById,
@@ -7667,6 +8357,8 @@ export {
7667
8357
  selectWorkspaceById,
7668
8358
  selectWorkspaceMapping,
7669
8359
  selectWorkspaces,
8360
+ separateFilesFromValues,
8361
+ separateImageFromFields,
7670
8362
  setActiveProjectFileId,
7671
8363
  setAsset,
7672
8364
  setAssetAttachment,
@@ -7676,6 +8368,14 @@ export {
7676
8368
  setAssetType,
7677
8369
  setAssetTypeAttachment,
7678
8370
  setAssetTypeAttachments,
8371
+ setAssetTypeFieldValues,
8372
+ setAssetTypeFieldValuesAttachment,
8373
+ setAssetTypeFieldValuesAttachments,
8374
+ setAssetTypeFieldValuesMany,
8375
+ setAssetTypeFields,
8376
+ setAssetTypeFieldsAttachment,
8377
+ setAssetTypeFieldsAttachments,
8378
+ setAssetTypeFieldsMany,
7679
8379
  setAssetTypes,
7680
8380
  setAssets,
7681
8381
  setConversation,
@@ -7701,6 +8401,14 @@ export {
7701
8401
  setIssueComment,
7702
8402
  setIssueComments,
7703
8403
  setIssueType,
8404
+ setIssueTypeFieldValues,
8405
+ setIssueTypeFieldValuesAttachment,
8406
+ setIssueTypeFieldValuesAttachments,
8407
+ setIssueTypeFieldValuesMany,
8408
+ setIssueTypeFields,
8409
+ setIssueTypeFieldsAttachment,
8410
+ setIssueTypeFieldsAttachments,
8411
+ setIssueTypeFieldsMany,
7704
8412
  setIssueUpdate,
7705
8413
  setLoggedIn,
7706
8414
  setOrganizations,
@@ -7735,6 +8443,14 @@ export {
7735
8443
  updateAssetType,
7736
8444
  updateAssetTypeAttachment,
7737
8445
  updateAssetTypeAttachments,
8446
+ updateAssetTypeFieldValues,
8447
+ updateAssetTypeFieldValuesAttachment,
8448
+ updateAssetTypeFieldValuesAttachments,
8449
+ updateAssetTypeFieldValuesMany,
8450
+ updateAssetTypeFields,
8451
+ updateAssetTypeFieldsAttachment,
8452
+ updateAssetTypeFieldsAttachments,
8453
+ updateAssetTypeFieldsMany,
7738
8454
  updateAssetTypes,
7739
8455
  updateAssets,
7740
8456
  updateCategory,
@@ -7757,6 +8473,14 @@ export {
7757
8473
  updateIssueAttachment,
7758
8474
  updateIssueAttachments,
7759
8475
  updateIssueType,
8476
+ updateIssueTypeFieldValues,
8477
+ updateIssueTypeFieldValuesAttachment,
8478
+ updateIssueTypeFieldValuesAttachments,
8479
+ updateIssueTypeFieldValuesMany,
8480
+ updateIssueTypeFields,
8481
+ updateIssueTypeFieldsAttachment,
8482
+ updateIssueTypeFieldsAttachments,
8483
+ updateIssueTypeFieldsMany,
7760
8484
  updateLicense,
7761
8485
  updateOrganizationAccess,
7762
8486
  updateProject,