@overmap-ai/core 1.0.65 → 1.0.67-fix-agent-service.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/constants/index.d.ts +0 -1
  2. package/dist/enums/access.d.ts +8 -0
  3. package/dist/enums/attachments.d.ts +7 -0
  4. package/dist/enums/index.d.ts +3 -0
  5. package/dist/enums/issue.d.ts +9 -0
  6. package/dist/enums/licenses.d.ts +14 -0
  7. package/dist/overmap-core.js +1004 -1213
  8. package/dist/overmap-core.js.map +1 -1
  9. package/dist/overmap-core.umd.cjs +1013 -1221
  10. package/dist/overmap-core.umd.cjs.map +1 -1
  11. package/dist/sdk/base.d.ts +1 -1
  12. package/dist/sdk/globals.d.ts +2 -2
  13. package/dist/sdk/sdk.d.ts +3 -3
  14. package/dist/sdk/services/AgentService.d.ts +1 -1
  15. package/dist/sdk/services/AssetAttachmentService.d.ts +3 -2
  16. package/dist/sdk/services/AssetService.d.ts +6 -7
  17. package/dist/sdk/services/AssetStageCompletionService.d.ts +6 -12
  18. package/dist/sdk/services/AssetStageService.d.ts +5 -4
  19. package/dist/sdk/services/AssetTypeAttachmentService.d.ts +3 -2
  20. package/dist/sdk/services/AssetTypeService.d.ts +4 -4
  21. package/dist/sdk/services/BaseApiService.d.ts +1 -1
  22. package/dist/sdk/services/BaseAttachmentService.d.ts +4 -3
  23. package/dist/sdk/services/BaseAuthService.d.ts +1 -1
  24. package/dist/sdk/services/BaseService.d.ts +2 -2
  25. package/dist/sdk/services/BaseUploadService.d.ts +2 -2
  26. package/dist/sdk/services/CategoryService.d.ts +5 -9
  27. package/dist/sdk/services/DocumentAttachmentService.d.ts +3 -2
  28. package/dist/sdk/services/DocumentService.d.ts +5 -5
  29. package/dist/sdk/services/EmailDomainsService.d.ts +1 -1
  30. package/dist/sdk/services/EmailVerificationService.d.ts +1 -1
  31. package/dist/sdk/services/FileService.d.ts +1 -1
  32. package/dist/sdk/services/FormService.d.ts +1 -4
  33. package/dist/sdk/services/FormSubmissionService.d.ts +3 -4
  34. package/dist/sdk/services/GeoImageService.d.ts +2 -2
  35. package/dist/sdk/services/IssueAttachmentService.d.ts +3 -2
  36. package/dist/sdk/services/IssueCommentService.d.ts +5 -5
  37. package/dist/sdk/services/IssueService.d.ts +4 -4
  38. package/dist/sdk/services/IssueTypeService.d.ts +5 -5
  39. package/dist/sdk/services/IssueUpdateService.d.ts +1 -1
  40. package/dist/sdk/services/JWTAuthService.d.ts +2 -2
  41. package/dist/sdk/services/LicenseService.d.ts +1 -1
  42. package/dist/sdk/services/OrganizationAccessService.d.ts +1 -1
  43. package/dist/sdk/services/OrganizationService.d.ts +1 -1
  44. package/dist/sdk/services/ProjectAccessService.d.ts +2 -3
  45. package/dist/sdk/services/ProjectAttachmentService.d.ts +3 -2
  46. package/dist/sdk/services/ProjectFileService.d.ts +3 -4
  47. package/dist/sdk/services/ProjectService.d.ts +2 -9
  48. package/dist/sdk/services/TeamService.d.ts +4 -4
  49. package/dist/sdk/services/UserService.d.ts +2 -2
  50. package/dist/sdk/services/WorkspaceService.d.ts +4 -6
  51. package/dist/store/slices/assetStageCompletionSlice.d.ts +41 -11
  52. package/dist/store/slices/assetStageSlice.d.ts +20 -9
  53. package/dist/store/slices/assetTypeSlice.d.ts +27 -3
  54. package/dist/store/slices/documentSlice.d.ts +3 -3
  55. package/dist/store/slices/formSlice.d.ts +2 -4
  56. package/dist/store/slices/issueCommentSlice.d.ts +2 -1
  57. package/dist/store/slices/issueSlice.d.ts +4 -20
  58. package/dist/store/slices/userSlice.d.ts +13 -33
  59. package/dist/store/slices/workspaceSlice.d.ts +11 -11
  60. package/dist/typings/models/access.d.ts +2 -9
  61. package/dist/typings/models/agents.d.ts +1 -1
  62. package/dist/typings/models/assets.d.ts +8 -9
  63. package/dist/typings/models/attachments.d.ts +2 -9
  64. package/dist/typings/models/base.d.ts +3 -3
  65. package/dist/typings/models/categories.d.ts +3 -3
  66. package/dist/typings/models/documents.d.ts +1 -2
  67. package/dist/typings/models/emailDomain.d.ts +1 -1
  68. package/dist/typings/models/emailVerification.d.ts +2 -2
  69. package/dist/typings/models/forms.d.ts +5 -13
  70. package/dist/typings/models/geoImages.d.ts +3 -3
  71. package/dist/typings/models/issueTypes.d.ts +2 -3
  72. package/dist/typings/models/issues.d.ts +9 -22
  73. package/dist/typings/models/license.d.ts +2 -15
  74. package/dist/typings/models/organizations.d.ts +1 -1
  75. package/dist/typings/models/projects.d.ts +4 -6
  76. package/dist/typings/models/store.d.ts +1 -1
  77. package/dist/typings/models/teams.d.ts +3 -4
  78. package/dist/typings/models/users.d.ts +1 -1
  79. package/dist/typings/models/workspace.d.ts +3 -3
  80. package/dist/typings/store.d.ts +1 -1
  81. package/dist/utils/colors.d.ts +0 -2
  82. package/dist/utils/index.d.ts +0 -2
  83. package/dist/utils/optimization.d.ts +0 -3
  84. package/package.json +1 -1
  85. package/dist/constants/ui.d.ts +0 -1
  86. package/dist/typings/base.d.ts +0 -0
  87. package/dist/utils/css.d.ts +0 -5
  88. package/dist/utils/search.d.ts +0 -3
@@ -7,20 +7,19 @@ var __publicField = (obj, key, value) => {
7
7
  var _a;
8
8
  import { DepGraph } from "dependency-graph";
9
9
  import { v4 } from "uuid";
10
+ import { saveAs } from "file-saver";
11
+ 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";
10
13
  import { offline as offline$1 } from "@redux-offline/redux-offline";
11
14
  import offlineConfig from "@redux-offline/redux-offline/lib/defaults";
12
15
  import localforage from "localforage";
13
16
  import createMigration from "redux-persist-migrate";
14
- import { createSlice, createSelector, combineReducers, createNextState } from "@reduxjs/toolkit";
17
+ import { createSlice, createSelector, combineReducers } from "@reduxjs/toolkit";
15
18
  import request from "superagent";
16
- import { saveAs } from "file-saver";
17
- import React, { useRef, useEffect } from "react";
18
- import ColorCls from "color";
19
- 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";
20
19
  import { RESET_STATE } from "@redux-offline/redux-offline/lib/constants";
21
20
  import jwtDecode from "jwt-decode";
22
- import { unsafeShowToast } from "@overmap-ai/blocks";
23
21
  import { openDB } from "idb";
22
+ import { unsafeShowToast } from "@overmap-ai/blocks";
24
23
  var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
25
24
  HttpMethod2["GET"] = "GET";
26
25
  HttpMethod2["POST"] = "POST";
@@ -29,6 +28,14 @@ var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
29
28
  HttpMethod2["DELETE"] = "DELETE";
30
29
  return HttpMethod2;
31
30
  })(HttpMethod || {});
31
+ var AttachmentModel = /* @__PURE__ */ ((AttachmentModel2) => {
32
+ AttachmentModel2["Issue"] = "issue";
33
+ AttachmentModel2["Asset"] = "asset";
34
+ AttachmentModel2["AssetType"] = "asset_type";
35
+ AttachmentModel2["Project"] = "project";
36
+ AttachmentModel2["Document"] = "document";
37
+ return AttachmentModel2;
38
+ })(AttachmentModel || {});
32
39
  var IssuePriority = /* @__PURE__ */ ((IssuePriority2) => {
33
40
  IssuePriority2[IssuePriority2["LOWEST"] = 0] = "LOWEST";
34
41
  IssuePriority2[IssuePriority2["LOW"] = 2] = "LOW";
@@ -43,6 +50,43 @@ var IssueStatus = /* @__PURE__ */ ((IssueStatus2) => {
43
50
  IssueStatus2[IssueStatus2["DONE"] = 4] = "DONE";
44
51
  return IssueStatus2;
45
52
  })(IssueStatus || {});
53
+ var IssueUpdateChange = /* @__PURE__ */ ((IssueUpdateChange2) => {
54
+ IssueUpdateChange2["STATUS"] = "status";
55
+ IssueUpdateChange2["PRIORITY"] = "priority";
56
+ IssueUpdateChange2["CATEGORY"] = "category";
57
+ IssueUpdateChange2["DESCRIPTION"] = "description";
58
+ IssueUpdateChange2["TITLE"] = "title";
59
+ IssueUpdateChange2["ASSIGNED_TO"] = "assigned_to";
60
+ IssueUpdateChange2["DUE_DATE"] = "due_date";
61
+ return IssueUpdateChange2;
62
+ })(IssueUpdateChange || {});
63
+ var ProjectAccessLevel = /* @__PURE__ */ ((ProjectAccessLevel2) => {
64
+ ProjectAccessLevel2[ProjectAccessLevel2["BASIC"] = 0] = "BASIC";
65
+ ProjectAccessLevel2[ProjectAccessLevel2["ADMIN"] = 2] = "ADMIN";
66
+ return ProjectAccessLevel2;
67
+ })(ProjectAccessLevel || {});
68
+ var OrganizationAccessLevel = /* @__PURE__ */ ((OrganizationAccessLevel2) => {
69
+ OrganizationAccessLevel2[OrganizationAccessLevel2["BASIC"] = 0] = "BASIC";
70
+ OrganizationAccessLevel2[OrganizationAccessLevel2["ADMIN"] = 2] = "ADMIN";
71
+ return OrganizationAccessLevel2;
72
+ })(OrganizationAccessLevel || {});
73
+ var PaddleCheckoutEvent = /* @__PURE__ */ ((PaddleCheckoutEvent2) => {
74
+ PaddleCheckoutEvent2["COMPLETED"] = "checkout.completed";
75
+ PaddleCheckoutEvent2["CLOSED"] = "checkout.closed";
76
+ return PaddleCheckoutEvent2;
77
+ })(PaddleCheckoutEvent || {});
78
+ var LicenseLevel = /* @__PURE__ */ ((LicenseLevel2) => {
79
+ LicenseLevel2[LicenseLevel2["PRO"] = 0] = "PRO";
80
+ return LicenseLevel2;
81
+ })(LicenseLevel || {});
82
+ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
83
+ LicenseStatus2[LicenseStatus2["ACTIVE"] = 0] = "ACTIVE";
84
+ LicenseStatus2[LicenseStatus2["PAUSED"] = 2] = "PAUSED";
85
+ LicenseStatus2[LicenseStatus2["CANCELLED"] = 4] = "CANCELLED";
86
+ LicenseStatus2[LicenseStatus2["INACTIVE"] = 6] = "INACTIVE";
87
+ LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
88
+ return LicenseStatus2;
89
+ })(LicenseStatus || {});
46
90
  class OutboxCoordinator {
47
91
  constructor() {
48
92
  __publicField(this, "graph");
@@ -285,130 +329,6 @@ class APIError extends Error {
285
329
  this.options = options;
286
330
  }
287
331
  }
288
- class DeferredPromise {
289
- constructor() {
290
- __publicField(this, _a, "Promise");
291
- __publicField(this, "_promise");
292
- __publicField(this, "_resolve");
293
- __publicField(this, "_reject");
294
- __publicField(this, "_state", "pending");
295
- this._resolve = null;
296
- this._reject = null;
297
- this._promise = new Promise((resolve, reject) => {
298
- this._resolve = resolve;
299
- this._reject = reject;
300
- });
301
- }
302
- get state() {
303
- return this._state;
304
- }
305
- then(onFulfilled, onRejected) {
306
- return this._promise.then(onFulfilled, onRejected);
307
- }
308
- catch(onRejected) {
309
- return this._promise.catch(onRejected);
310
- }
311
- resolve(value) {
312
- if (!this._resolve)
313
- throw new Error("No resolve callback");
314
- this._resolve(value);
315
- this._state = "fulfilled";
316
- }
317
- reject(reason) {
318
- if (!this._reject)
319
- throw reason;
320
- this._reject(reason);
321
- this._state = "rejected";
322
- }
323
- finally(_onFinally) {
324
- throw new Error("`finally` not implemented");
325
- }
326
- }
327
- _a = Symbol.toStringTag;
328
- var randomString = function randomString2() {
329
- return Math.random().toString(36).substring(7).split("").join(".");
330
- };
331
- ({
332
- INIT: "@@redux/INIT" + randomString(),
333
- REPLACE: "@@redux/REPLACE" + randomString(),
334
- PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
335
- return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
336
- }
337
- });
338
- function compose() {
339
- for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
340
- funcs[_key] = arguments[_key];
341
- }
342
- if (funcs.length === 0) {
343
- return function(arg) {
344
- return arg;
345
- };
346
- }
347
- if (funcs.length === 1) {
348
- return funcs[0];
349
- }
350
- return funcs.reduce(function(a, b) {
351
- return function() {
352
- return a(b.apply(void 0, arguments));
353
- };
354
- });
355
- }
356
- const VERSION_REDUCER_KEY$1 = "versioning";
357
- const latestVersion = () => migrations.length - 1;
358
- const initialVersioning = (state) => {
359
- state[VERSION_REDUCER_KEY$1] = { version: latestVersion() };
360
- return state;
361
- };
362
- const signOut = () => {
363
- return initialVersioning({});
364
- };
365
- const createOutboxState = (state) => {
366
- if (state.outboxReducer) {
367
- state.outboxReducer.deletedRequests = [];
368
- }
369
- return state;
370
- };
371
- const wrapMigration = (migrator) => (state) => {
372
- var _a2;
373
- if (state === void 0) {
374
- state = {};
375
- }
376
- if (((_a2 = state[VERSION_REDUCER_KEY$1]) == null ? void 0 : _a2.version) === latestVersion())
377
- return state;
378
- return migrator(state);
379
- };
380
- const migrations = [initialVersioning, signOut, signOut, createOutboxState];
381
- const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
382
- const initialState$B = {
383
- accessToken: "",
384
- refreshToken: "",
385
- isLoggedIn: false
386
- };
387
- const authSlice = createSlice({
388
- name: "auth",
389
- initialState: initialState$B,
390
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
391
- reducers: {
392
- setTokens: (state, action) => {
393
- state.accessToken = action.payload.accessToken;
394
- state.refreshToken = action.payload.refreshToken;
395
- },
396
- clearTokens: (state) => {
397
- state.accessToken = "";
398
- state.refreshToken = "";
399
- },
400
- setLoggedIn: (state, action) => {
401
- if (!action.payload) {
402
- authSlice.caseReducers.clearTokens(state);
403
- }
404
- state.isLoggedIn = action.payload;
405
- }
406
- }
407
- });
408
- const { setTokens, clearTokens, setLoggedIn } = authSlice.actions;
409
- const selectAccessToken = (state) => state.authReducer.accessToken;
410
- const selectIsLoggedIn = (state) => state.authReducer.isLoggedIn;
411
- const authReducer = authSlice.reducer;
412
332
  const coordinatesToLiteral = (coordinates) => {
413
333
  return { lng: coordinates[0], lat: coordinates[1] };
414
334
  };
@@ -473,24 +393,6 @@ const createMultiPointGeometry = (coordinates) => {
473
393
  coordinates
474
394
  };
475
395
  };
476
- function classNames(...args) {
477
- const classes = [];
478
- for (const arg of args) {
479
- if (!arg) {
480
- continue;
481
- }
482
- if (typeof arg === "string") {
483
- classes.push(arg);
484
- } else if (typeof arg === "object") {
485
- for (const [key, value] of Object.entries(arg)) {
486
- if (value) {
487
- classes.push(key);
488
- }
489
- }
490
- }
491
- }
492
- return classes.join(" ");
493
- }
494
396
  function hex(buffer) {
495
397
  const hashArray = new Uint8Array(buffer);
496
398
  return hashArray.reduce((data, byte) => data + byte.toString(16).padStart(2, "0"), "");
@@ -603,14 +505,6 @@ function toOfflineIdRecord(array) {
603
505
  }
604
506
  return asMapping;
605
507
  }
606
- const issueToSearchResult = (issue, tag) => {
607
- return {
608
- label: issue.title || "",
609
- typeLabel: "issue",
610
- tag,
611
- item: issue
612
- };
613
- };
614
508
  function toFileNameSafeString(str, extension = void 0, maxLength = 255) {
615
509
  let ret = str.replace(/[^a-z0-9_\-.]/gi, "_").replace(/_{2,}/g, "_");
616
510
  if (!extension) {
@@ -654,7 +548,6 @@ function boundsContainPoint(bounds, coordinates) {
654
548
  return bounds[0][0] > coordinates[0] && bounds[1][0] < coordinates[0] && bounds[0][1] > coordinates[1] && bounds[1][1] < coordinates[1];
655
549
  }
656
550
  const emailRegex = /^.+@.+\..+$/;
657
- const fullAssetMarkerSize = 45;
658
551
  const DEFAULT_ISSUE_STATUS = IssueStatus.BACKLOG;
659
552
  const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
660
553
  const OUTBOX_RETRY_DELAY = 6e4;
@@ -700,17 +593,6 @@ function memoize(func) {
700
593
  }
701
594
  };
702
595
  }
703
- function useMemoCompare(next, compare) {
704
- const previousRef = useRef(void 0);
705
- const previous = previousRef.current;
706
- const isEqual = compare(previous, next);
707
- useEffect(() => {
708
- if (!isEqual) {
709
- previousRef.current = next;
710
- }
711
- });
712
- return isEqual ? previous : next;
713
- }
714
596
  function areArraysEqual(first, second) {
715
597
  if (first.length !== second.length)
716
598
  return false;
@@ -720,7 +602,6 @@ function areArraysEqual(first, second) {
720
602
  }
721
603
  return true;
722
604
  }
723
- const genericMemo = React.memo;
724
605
  const fallbackToEmptyArray = (array) => {
725
606
  return array.length === 0 ? EMPTY_ARRAY : array;
726
607
  };
@@ -753,19 +634,6 @@ const Colors = {
753
634
  mint: mint.mint9,
754
635
  sky: sky.sky9
755
636
  };
756
- const AssetStageColors = {
757
- indigo: indigo.indigo9,
758
- red: red.red9,
759
- violet: violet.violet9,
760
- yellow: yellow.yellow9,
761
- jade: jade.jade9,
762
- cyan: cyan.cyan9,
763
- gold: gold.gold9,
764
- orange: orange.orange9,
765
- lime: lime.lime9,
766
- sky: sky.sky9,
767
- pink: pink.pink9
768
- };
769
637
  const defaultBadgeColor = "#868686";
770
638
  const generateBadgeColors = (rawColor) => {
771
639
  const color = ColorCls(rawColor);
@@ -774,9 +642,6 @@ const generateBadgeColors = (rawColor) => {
774
642
  const textColor = color.hex() === safety.hex() ? "#000000" : "#FFFFFF";
775
643
  return { backgroundColor, textColor };
776
644
  };
777
- function getStageColor(index) {
778
- return Object.values(AssetStageColors)[index % Object.keys(AssetStageColors).length];
779
- }
780
645
  const getLocalDateString = memoize((date) => {
781
646
  if (!date)
782
647
  return "";
@@ -799,63 +664,187 @@ const getLocalRelativeDateString = memoize((date, min, max) => {
799
664
  return getLocalDateString(date);
800
665
  return relative.format(days, "days");
801
666
  });
802
- function createModelAdapter(computeModelId) {
803
- const addOne = (state, action) => {
804
- const id = computeModelId(action.payload);
805
- state.instances[id] = action.payload;
806
- };
807
- const addMany = (state, action) => {
808
- for (const model of action.payload) {
809
- const id = computeModelId(model);
810
- state.instances[id] = model;
811
- }
812
- };
813
- const setOne = (state, action) => {
814
- const id = computeModelId(action.payload);
815
- state.instances[id] = action.payload;
816
- };
817
- const setMany = (state, action) => {
818
- for (const model of action.payload) {
819
- const id = computeModelId(model);
820
- state.instances[id] = model;
821
- }
822
- };
823
- const updateOne = (state, action) => {
824
- const id = computeModelId(action.payload);
825
- state.instances[id] = action.payload;
826
- };
827
- const updateMany = (state, action) => {
828
- for (const model of action.payload) {
829
- const id = computeModelId(model);
830
- state.instances[id] = model;
831
- }
832
- };
833
- const deleteOne = (state, action) => {
834
- delete state.instances[action.payload];
835
- };
836
- const deleteMany = (state, action) => {
837
- for (const id of action.payload) {
838
- delete state.instances[id];
839
- }
840
- };
841
- const initialize = (state, action) => {
842
- state.instances = {};
843
- for (const model of action.payload) {
844
- const id = computeModelId(model);
845
- state.instances[id] = model;
846
- }
847
- };
848
- const getInitialState = (state) => {
849
- return {
850
- ...state,
851
- instances: {}
852
- };
853
- };
854
- return {
855
- addOne,
856
- addMany,
857
- setOne,
858
- setMany,
667
+ class DeferredPromise {
668
+ constructor() {
669
+ __publicField(this, _a, "Promise");
670
+ __publicField(this, "_promise");
671
+ __publicField(this, "_resolve");
672
+ __publicField(this, "_reject");
673
+ __publicField(this, "_state", "pending");
674
+ this._resolve = null;
675
+ this._reject = null;
676
+ this._promise = new Promise((resolve, reject) => {
677
+ this._resolve = resolve;
678
+ this._reject = reject;
679
+ });
680
+ }
681
+ get state() {
682
+ return this._state;
683
+ }
684
+ then(onFulfilled, onRejected) {
685
+ return this._promise.then(onFulfilled, onRejected);
686
+ }
687
+ catch(onRejected) {
688
+ return this._promise.catch(onRejected);
689
+ }
690
+ resolve(value) {
691
+ if (!this._resolve)
692
+ throw new Error("No resolve callback");
693
+ this._resolve(value);
694
+ this._state = "fulfilled";
695
+ }
696
+ reject(reason) {
697
+ if (!this._reject)
698
+ throw reason;
699
+ this._reject(reason);
700
+ this._state = "rejected";
701
+ }
702
+ finally(_onFinally) {
703
+ throw new Error("`finally` not implemented");
704
+ }
705
+ }
706
+ _a = Symbol.toStringTag;
707
+ var randomString = function randomString2() {
708
+ return Math.random().toString(36).substring(7).split("").join(".");
709
+ };
710
+ ({
711
+ INIT: "@@redux/INIT" + randomString(),
712
+ REPLACE: "@@redux/REPLACE" + randomString(),
713
+ PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
714
+ return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
715
+ }
716
+ });
717
+ function compose() {
718
+ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
719
+ funcs[_key] = arguments[_key];
720
+ }
721
+ if (funcs.length === 0) {
722
+ return function(arg) {
723
+ return arg;
724
+ };
725
+ }
726
+ if (funcs.length === 1) {
727
+ return funcs[0];
728
+ }
729
+ return funcs.reduce(function(a, b) {
730
+ return function() {
731
+ return a(b.apply(void 0, arguments));
732
+ };
733
+ });
734
+ }
735
+ const VERSION_REDUCER_KEY$1 = "versioning";
736
+ const latestVersion = () => migrations.length - 1;
737
+ const initialVersioning = (state) => {
738
+ state[VERSION_REDUCER_KEY$1] = { version: latestVersion() };
739
+ return state;
740
+ };
741
+ const signOut = () => {
742
+ return initialVersioning({});
743
+ };
744
+ const createOutboxState = (state) => {
745
+ if (state.outboxReducer) {
746
+ state.outboxReducer.deletedRequests = [];
747
+ }
748
+ return state;
749
+ };
750
+ const wrapMigration = (migrator) => (state) => {
751
+ var _a2;
752
+ if (state === void 0) {
753
+ state = {};
754
+ }
755
+ if (((_a2 = state[VERSION_REDUCER_KEY$1]) == null ? void 0 : _a2.version) === latestVersion())
756
+ return state;
757
+ return migrator(state);
758
+ };
759
+ const migrations = [initialVersioning, signOut, signOut, createOutboxState];
760
+ const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
761
+ const initialState$B = {
762
+ accessToken: "",
763
+ refreshToken: "",
764
+ isLoggedIn: false
765
+ };
766
+ const authSlice = createSlice({
767
+ name: "auth",
768
+ initialState: initialState$B,
769
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
770
+ reducers: {
771
+ setTokens: (state, action) => {
772
+ state.accessToken = action.payload.accessToken;
773
+ state.refreshToken = action.payload.refreshToken;
774
+ },
775
+ clearTokens: (state) => {
776
+ state.accessToken = "";
777
+ state.refreshToken = "";
778
+ },
779
+ setLoggedIn: (state, action) => {
780
+ if (!action.payload) {
781
+ authSlice.caseReducers.clearTokens(state);
782
+ }
783
+ state.isLoggedIn = action.payload;
784
+ }
785
+ }
786
+ });
787
+ const { setTokens, clearTokens, setLoggedIn } = authSlice.actions;
788
+ const selectAccessToken = (state) => state.authReducer.accessToken;
789
+ const selectIsLoggedIn = (state) => state.authReducer.isLoggedIn;
790
+ const authReducer = authSlice.reducer;
791
+ function createModelAdapter(computeModelId) {
792
+ const addOne = (state, action) => {
793
+ const id = computeModelId(action.payload);
794
+ state.instances[id] = action.payload;
795
+ };
796
+ const addMany = (state, action) => {
797
+ for (const model of action.payload) {
798
+ const id = computeModelId(model);
799
+ state.instances[id] = model;
800
+ }
801
+ };
802
+ const setOne = (state, action) => {
803
+ const id = computeModelId(action.payload);
804
+ state.instances[id] = action.payload;
805
+ };
806
+ const setMany = (state, action) => {
807
+ for (const model of action.payload) {
808
+ const id = computeModelId(model);
809
+ state.instances[id] = model;
810
+ }
811
+ };
812
+ const updateOne = (state, action) => {
813
+ const id = computeModelId(action.payload);
814
+ state.instances[id] = action.payload;
815
+ };
816
+ const updateMany = (state, action) => {
817
+ for (const model of action.payload) {
818
+ const id = computeModelId(model);
819
+ state.instances[id] = model;
820
+ }
821
+ };
822
+ const deleteOne = (state, action) => {
823
+ delete state.instances[action.payload];
824
+ };
825
+ const deleteMany = (state, action) => {
826
+ for (const id of action.payload) {
827
+ delete state.instances[id];
828
+ }
829
+ };
830
+ const initialize = (state, action) => {
831
+ state.instances = {};
832
+ for (const model of action.payload) {
833
+ const id = computeModelId(model);
834
+ state.instances[id] = model;
835
+ }
836
+ };
837
+ const getInitialState = (state) => {
838
+ return {
839
+ ...state,
840
+ instances: {}
841
+ };
842
+ };
843
+ return {
844
+ addOne,
845
+ addMany,
846
+ setOne,
847
+ setMany,
859
848
  updateOne,
860
849
  updateMany,
861
850
  deleteOne,
@@ -1031,61 +1020,72 @@ const selectAttachmentsOfAssetByType = restructureCreateSelectorWithArgs(
1031
1020
  )
1032
1021
  );
1033
1022
  const assetAttachmentReducer = assetAttachmentSlice.reducer;
1034
- const initialState$x = {
1035
- completionsByAssetId: {}
1036
- };
1023
+ const assetStageCompletionAdapter = createModelAdapter(
1024
+ (stageCompletion) => stageCompletion.offline_id
1025
+ );
1026
+ const initialState$x = assetStageCompletionAdapter.getInitialState({});
1037
1027
  const assetStageCompletionSlice = createSlice({
1038
1028
  name: "assetStageCompletions",
1039
1029
  initialState: initialState$x,
1040
1030
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1041
1031
  reducers: {
1042
- addStageCompletion: (state, action) => {
1043
- let stageToCompletionDateMapping = state.completionsByAssetId[action.payload.asset];
1044
- if (!stageToCompletionDateMapping) {
1045
- stageToCompletionDateMapping = {};
1046
- state.completionsByAssetId[action.payload.asset] = stageToCompletionDateMapping;
1047
- }
1048
- stageToCompletionDateMapping[action.payload.stage] = (/* @__PURE__ */ new Date()).toISOString();
1049
- },
1050
- addStageCompletions: (state, action) => {
1051
- for (const [assetId, stageIdToCompletionDateMapping] of Object.entries(action.payload)) {
1052
- if (Object.keys(stageIdToCompletionDateMapping).length === 0)
1053
- throw new Error(`Encountered empty stageIdToCompletionDateMapping argument for asset ${assetId}`);
1054
- let thisAssetCompletions = state.completionsByAssetId[assetId];
1055
- if (thisAssetCompletions === void 0) {
1056
- thisAssetCompletions = {};
1057
- }
1058
- for (const [stageId, completionDate] of Object.entries(stageIdToCompletionDateMapping)) {
1059
- thisAssetCompletions[stageId] = completionDate;
1060
- }
1061
- state.completionsByAssetId[assetId] = thisAssetCompletions;
1062
- }
1063
- },
1064
- removeStageCompletions: (state, action) => {
1065
- for (const completion of action.payload) {
1066
- const thisAssetCompletions = state.completionsByAssetId[completion.asset];
1067
- if (!thisAssetCompletions || !(completion.stage in thisAssetCompletions)) {
1068
- console.warn(
1069
- "Skipping removal of uncompleted stage. This message indicates completion objects are created unnecessarily."
1070
- );
1071
- continue;
1072
- }
1073
- delete thisAssetCompletions[completion.stage];
1074
- }
1075
- },
1076
- setStageCompletions: (state, action) => {
1077
- state.completionsByAssetId = action.payload;
1078
- }
1032
+ initializeAssetStageCompletions: assetStageCompletionAdapter.initialize,
1033
+ addAssetStageCompletion: assetStageCompletionAdapter.addOne,
1034
+ addAssetStageCompletions: assetStageCompletionAdapter.addMany,
1035
+ updateAssetStageCompletion: assetStageCompletionAdapter.updateOne,
1036
+ updateAssetStageCompletions: assetStageCompletionAdapter.updateMany,
1037
+ deleteAssetStageCompletion: assetStageCompletionAdapter.deleteOne,
1038
+ deleteAssetStageCompletions: assetStageCompletionAdapter.deleteMany
1079
1039
  }
1080
1040
  });
1081
- const { addStageCompletion, addStageCompletions, removeStageCompletions, setStageCompletions } = assetStageCompletionSlice.actions;
1082
- const selectCompletedStages = (state) => {
1083
- return state.assetStageCompletionReducer.completionsByAssetId;
1041
+ const {
1042
+ initializeAssetStageCompletions,
1043
+ addAssetStageCompletion,
1044
+ addAssetStageCompletions,
1045
+ updateAssetStageCompletion,
1046
+ updateAssetStageCompletions,
1047
+ deleteAssetStageCompletion,
1048
+ deleteAssetStageCompletions
1049
+ } = assetStageCompletionSlice.actions;
1050
+ const selectAssetStageCompletionMapping = (state) => {
1051
+ return state.assetStageCompletionReducer.instances;
1084
1052
  };
1053
+ const selectCompletedStagesByAsset = createSelector(
1054
+ [selectAssetStageCompletionMapping],
1055
+ (completedStagesMapping) => {
1056
+ const completedStagesByAsset = {};
1057
+ for (const stageCompletion of Object.values(completedStagesMapping)) {
1058
+ const { asset, stage, submitted_at } = stageCompletion;
1059
+ if (!completedStagesByAsset[asset])
1060
+ completedStagesByAsset[asset] = {};
1061
+ completedStagesByAsset[asset][stage] = submitted_at;
1062
+ }
1063
+ return completedStagesByAsset;
1064
+ }
1065
+ );
1085
1066
  const selectCompletedStageIdsForAsset = restructureCreateSelectorWithArgs(
1086
- createSelector([selectCompletedStages, (_state, asset) => asset], (completedStages, asset) => {
1087
- return Object.keys(completedStages[asset.offline_id] ?? {});
1088
- })
1067
+ createSelector(
1068
+ [selectAssetStageCompletionMapping, (_state, asset) => asset],
1069
+ (completedStages, asset) => {
1070
+ return Object.keys(completedStages[asset.offline_id] ?? {});
1071
+ }
1072
+ )
1073
+ );
1074
+ const selectAssetStageCompletionById = (id) => (state) => {
1075
+ return state.assetStageCompletionReducer.instances[id];
1076
+ };
1077
+ const selectAssetStageCompletionsByIds = restructureCreateSelectorWithArgs(
1078
+ createSelector(
1079
+ [selectAssetStageCompletionMapping, (_, stageCompletionIds) => stageCompletionIds],
1080
+ (stageCompletionMapping, stageCompletionIds) => {
1081
+ const stageCompletionIdsSet = new Set(stageCompletionIds);
1082
+ return fallbackToEmptyArray(
1083
+ Object.values(stageCompletionMapping).filter(
1084
+ (stageCompletion) => stageCompletionIdsSet.has(stageCompletion.offline_id)
1085
+ )
1086
+ );
1087
+ }
1088
+ )
1089
1089
  );
1090
1090
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1091
1091
  const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
@@ -1095,14 +1095,29 @@ const assetStageSlice = createSlice({
1095
1095
  initialState: initialState$w,
1096
1096
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1097
1097
  reducers: {
1098
- initializeStages: assetStageAdapter.initialize,
1099
- setStage: assetStageAdapter.setOne,
1100
- addStages: assetStageAdapter.addMany,
1101
- updateStage: assetStageAdapter.updateOne,
1102
- updateStages: assetStageAdapter.updateMany,
1103
- removeStages: assetStageAdapter.deleteMany
1098
+ initializeAssetStages: assetStageAdapter.initialize,
1099
+ setAssetStage: assetStageAdapter.setOne,
1100
+ setAssetStages: assetStageAdapter.setMany,
1101
+ addAssetStage: assetStageAdapter.addOne,
1102
+ addAssetStages: assetStageAdapter.addMany,
1103
+ updateAssetStage: assetStageAdapter.updateOne,
1104
+ updateAssetStages: assetStageAdapter.updateMany,
1105
+ deleteAssetStage: assetStageAdapter.deleteOne,
1106
+ deleteAssetStages: assetStageAdapter.deleteMany
1104
1107
  }
1105
1108
  });
1109
+ const {
1110
+ initializeAssetStages,
1111
+ setAssetStage,
1112
+ setAssetStages,
1113
+ addAssetStage,
1114
+ addAssetStages,
1115
+ updateAssetStage,
1116
+ updateAssetStages,
1117
+ deleteAssetStage,
1118
+ deleteAssetStages
1119
+ } = assetStageSlice.actions;
1120
+ const assetStageReducer = assetStageSlice.reducer;
1106
1121
  const selectStageMapping = (state) => state.assetStageReducer.instances;
1107
1122
  const selectAssetStageById = (id) => (state) => {
1108
1123
  return state.assetStageReducer.instances[id];
@@ -1110,24 +1125,6 @@ const selectAssetStageById = (id) => (state) => {
1110
1125
  const selectAssetStages = createSelector([selectStageMapping], (stageMapping) => {
1111
1126
  return Object.values(stageMapping);
1112
1127
  });
1113
- const selectStagesFromAssetTypeIds = restructureCreateSelectorWithArgs(
1114
- createSelector([selectAssetStages, (_state, assetTypeIds) => assetTypeIds], (stages, assetTypeIds) => {
1115
- const assetTypeIdsSet = new Set(assetTypeIds);
1116
- const ret = {};
1117
- for (const stage of stages) {
1118
- if (assetTypeIdsSet.has(stage.asset_type)) {
1119
- if (!ret[stage.asset_type]) {
1120
- ret[stage.asset_type] = [];
1121
- }
1122
- ret[stage.asset_type].push(stage);
1123
- }
1124
- }
1125
- for (const key in ret) {
1126
- ret[key] = ret[key].sort((a, b) => a.priority - b.priority);
1127
- }
1128
- return ret;
1129
- })
1130
- );
1131
1128
  const selectAssetTypeStagesMapping = restructureCreateSelectorWithArgs(
1132
1129
  createSelector([selectStageMapping, (_state, assetTypeId) => assetTypeId], (stagesMapping, assetTypeId) => {
1133
1130
  const assetTypeStagesMapping = {};
@@ -1175,8 +1172,6 @@ const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
1175
1172
  return ret;
1176
1173
  })
1177
1174
  );
1178
- const { initializeStages, setStage, addStages, updateStages, removeStages, updateStage } = assetStageSlice.actions;
1179
- const assetStageReducer = assetStageSlice.reducer;
1180
1175
  const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
1181
1176
  const initialState$v = assetTypeAdapter.getInitialState({});
1182
1177
  const assetTypeSlice = createSlice({
@@ -1185,11 +1180,27 @@ const assetTypeSlice = createSlice({
1185
1180
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1186
1181
  reducers: {
1187
1182
  initializeAssetTypes: assetTypeAdapter.initialize,
1183
+ setAssetType: assetTypeAdapter.setOne,
1184
+ setAssetTypes: assetTypeAdapter.setMany,
1188
1185
  addAssetType: assetTypeAdapter.addOne,
1189
- deleteAssetType: assetTypeAdapter.deleteOne
1186
+ addAssetTypes: assetTypeAdapter.addMany,
1187
+ updateAssetType: assetTypeAdapter.updateOne,
1188
+ updateAssetTypes: assetTypeAdapter.updateMany,
1189
+ deleteAssetType: assetTypeAdapter.deleteOne,
1190
+ deleteAssetTypes: assetTypeAdapter.deleteMany
1190
1191
  }
1191
1192
  });
1192
- const { addAssetType, initializeAssetTypes, deleteAssetType } = assetTypeSlice.actions;
1193
+ const {
1194
+ initializeAssetTypes,
1195
+ setAssetType,
1196
+ setAssetTypes,
1197
+ addAssetType,
1198
+ addAssetTypes,
1199
+ updateAssetType,
1200
+ updateAssetTypes,
1201
+ deleteAssetType,
1202
+ deleteAssetTypes
1203
+ } = assetTypeSlice.actions;
1193
1204
  const selectAssetTypesMapping = (state) => state.assetTypeReducer.instances;
1194
1205
  const selectAssetTypes = createSelector(
1195
1206
  [selectAssetTypesMapping],
@@ -1281,50 +1292,13 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1281
1292
  )
1282
1293
  );
1283
1294
  const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
1284
- const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
1285
- const initialState$t = workspaceAdapter.getInitialState({});
1286
- const workspaceSlice = createSlice({
1287
- name: "workspace",
1288
- initialState: initialState$t,
1289
- reducers: {
1290
- initializeWorkspaces: workspaceAdapter.initialize,
1291
- setWorkspaces: workspaceAdapter.setMany,
1292
- addWorkspace: workspaceAdapter.addOne,
1293
- updateWorkspace: workspaceAdapter.updateOne,
1294
- deleteWorkspace: workspaceAdapter.deleteOne
1295
- }
1296
- });
1297
- const { initializeWorkspaces, setWorkspaces, addWorkspace, updateWorkspace, deleteWorkspace } = workspaceSlice.actions;
1298
- const selectWorkspaceMapping = (state) => state.workspaceReducer.instances;
1299
- const selectWorkspaces = createSelector([selectWorkspaceMapping], (mapping) => Object.values(mapping));
1300
- const selectMainWorkspace = createSelector(
1301
- [selectWorkspaces],
1302
- (workspaces) => {
1303
- return workspaces.find((workspace) => workspace.name.toLowerCase() === "main");
1304
- }
1305
- );
1306
- const selectWorkspaceById = (id) => (state) => {
1307
- return state.workspaceReducer.instances[id];
1308
- };
1309
- const selectPermittedWorkspaceIds = createSelector(
1310
- [selectWorkspaceMapping],
1311
- (mapping) => {
1312
- return new Set(
1313
- Object.values(mapping).filter((workspace) => workspace.permitted).map((workspace) => workspace.offline_id)
1314
- );
1315
- }
1316
- );
1317
- const workspaceReducer = workspaceSlice.reducer;
1318
- const maxRecentIssues = 10;
1319
1295
  const issueAdapter = createModelAdapter((issue) => issue.offline_id);
1320
- const initialState$s = issueAdapter.getInitialState({
1321
- recentIssueIds: []
1322
- });
1296
+ const initialState$t = issueAdapter.getInitialState({});
1323
1297
  const issueSlice = createSlice({
1324
1298
  name: "issues",
1325
- initialState: initialState$s,
1299
+ initialState: initialState$t,
1326
1300
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1327
- Object.assign(state, initialState$s);
1301
+ Object.assign(state, initialState$t);
1328
1302
  }),
1329
1303
  reducers: {
1330
1304
  initializeIssues: issueAdapter.initialize,
@@ -1332,104 +1306,14 @@ const issueSlice = createSlice({
1332
1306
  addIssues: issueAdapter.addMany,
1333
1307
  updateIssue: issueAdapter.updateOne,
1334
1308
  deleteIssue: issueAdapter.deleteOne,
1335
- deleteIssues: issueAdapter.deleteMany,
1336
- cleanRecentIssues: (state) => {
1337
- state.recentIssueIds = state.recentIssueIds.filter((recentIssue) => state.instances[recentIssue.offlineId]);
1338
- },
1339
- addToRecentIssues: (state, action) => {
1340
- state.recentIssueIds = state.recentIssueIds.filter(
1341
- (recentIssue) => recentIssue.offlineId !== action.payload
1342
- );
1343
- state.recentIssueIds.push({ offlineId: action.payload.toLowerCase(), lastOpenedEpochTime: Date.now() });
1344
- if (state.recentIssueIds.length > maxRecentIssues) {
1345
- state.recentIssueIds.shift();
1346
- }
1347
- },
1348
- resetRecentIssues: (state) => {
1349
- state.recentIssueIds = [];
1350
- },
1351
- removeRecentIssue: (state, action) => {
1352
- const indexToRemove = state.recentIssueIds.findIndex((item) => {
1353
- return item.offlineId == action.payload;
1354
- });
1355
- if (indexToRemove !== -1) {
1356
- state.recentIssueIds.splice(indexToRemove, 1);
1357
- }
1358
- }
1309
+ deleteIssues: issueAdapter.deleteMany
1359
1310
  }
1360
1311
  });
1361
- const {
1362
- initializeIssues,
1363
- addIssue,
1364
- addIssues,
1365
- updateIssue,
1366
- deleteIssue,
1367
- deleteIssues,
1368
- addToRecentIssues,
1369
- cleanRecentIssues,
1370
- removeRecentIssue,
1371
- resetRecentIssues
1372
- } = issueSlice.actions;
1312
+ const { initializeIssues, addIssue, addIssues, updateIssue, deleteIssue, deleteIssues } = issueSlice.actions;
1373
1313
  const selectIssueMapping = (state) => state.issueReducer.instances;
1374
- const selectRecentIssueIds = (state) => state.issueReducer.recentIssueIds;
1375
1314
  const selectIssueById = (id) => (state) => {
1376
1315
  return state.issueReducer.instances[id];
1377
1316
  };
1378
- const searchIssues = restructureCreateSelectorWithArgs(
1379
- createSelector(
1380
- [selectIssueMapping, selectWorkspaceMapping, (_state, searchArgs) => searchArgs],
1381
- (mapping, workspaceMapping, searchArgs) => {
1382
- let searchTerm = searchArgs.searchTerm;
1383
- const maxResults = searchArgs.maxResults;
1384
- searchTerm = searchTerm.toLowerCase();
1385
- const ret = [];
1386
- const issues = Object.values(mapping);
1387
- let nbResults = 0;
1388
- for (const issue of issues) {
1389
- if (!issue.index_workspace) {
1390
- logOnlyOnce(
1391
- "issue-has-no-index-workspace",
1392
- issue.offline_id,
1393
- "warn",
1394
- `Issue ${issue.offline_id} has no index_workspace and cannot be searched.`
1395
- );
1396
- continue;
1397
- }
1398
- const workspace = workspaceMapping[issue.index_workspace];
1399
- if (!workspace) {
1400
- logOnlyOnce(
1401
- "issue-has-non-existent-index-workspace",
1402
- issue.offline_id,
1403
- "warn",
1404
- `Encountered issue with an index_workspace that doesn't exist. Issue ${issue.offline_id} has
1405
- index_workspace = ${issue.index_workspace}, which does not exist in:`,
1406
- Object.keys(workspaceMapping)
1407
- );
1408
- continue;
1409
- }
1410
- const workspaceAbbreviation = workspace.abbreviation;
1411
- if (!workspaceAbbreviation) {
1412
- logOnlyOnce(
1413
- "workspace-has-no-abbreviation",
1414
- workspace.offline_id,
1415
- "error",
1416
- `Workspace ${workspace.name} has no abbreviation. Not including any issues in search.`
1417
- );
1418
- continue;
1419
- }
1420
- const tag = "index" in issue ? `${workspaceAbbreviation.toUpperCase()}-${issue.index}` : null;
1421
- if ((issue.title || "").toLowerCase().includes(searchTerm) || tag && tag.toLowerCase().includes(searchTerm)) {
1422
- ret.push(issueToSearchResult(issue, tag));
1423
- nbResults++;
1424
- if (maxResults && nbResults >= maxResults) {
1425
- return ret;
1426
- }
1427
- }
1428
- }
1429
- return ret;
1430
- }
1431
- )
1432
- );
1433
1317
  const selectIssuesByIds = restructureCreateSelectorWithArgs(
1434
1318
  createSelector([selectIssueMapping, (_, issueIds) => issueIds], (issuesMapping, issueIds) => {
1435
1319
  const issues = [];
@@ -1444,48 +1328,14 @@ const selectIssuesByIds = restructureCreateSelectorWithArgs(
1444
1328
  return fallbackToEmptyArray(issues);
1445
1329
  })
1446
1330
  );
1447
- const selectRecentIssuesAsSearchResults = createSelector(
1448
- [selectIssueMapping, selectRecentIssueIds, selectWorkspaceMapping],
1449
- (issueMapping, recentIssueIds, workspaceMapping) => {
1450
- const ret = [];
1451
- for (const recentIssueResult of recentIssueIds) {
1452
- const issue = issueMapping[recentIssueResult.offlineId];
1453
- if (!issue) {
1454
- console.info("Recent issue no longer exists");
1455
- continue;
1456
- }
1457
- if ("index" in issue && issue.index_workspace) {
1458
- const indexWorkspace = workspaceMapping[issue.index_workspace];
1459
- if (!indexWorkspace) {
1460
- logOnlyOnce(
1461
- "issue-has-index-but-not-index-workspace",
1462
- issue.offline_id,
1463
- "warn",
1464
- `Issue ${issue.offline_id} has an index but no index_workspace. This may be because the
1465
- workspace has been deleted, but the new index has not been returned by the server yet. It will not
1466
- be included in search results.`
1467
- );
1468
- continue;
1469
- }
1470
- const workspaceTag = `${indexWorkspace.abbreviation}-${issue.index}`;
1471
- const searchResult = {
1472
- ...issueToSearchResult(issue, workspaceTag),
1473
- lastOpenedEpochTime: recentIssueResult.lastOpenedEpochTime
1474
- };
1475
- ret.push(searchResult);
1476
- }
1477
- }
1478
- return ret;
1479
- }
1480
- );
1481
1331
  const issueReducer = issueSlice.reducer;
1482
1332
  const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
1483
- const initialState$r = issueTypeAdapter.getInitialState({});
1333
+ const initialState$s = issueTypeAdapter.getInitialState({});
1484
1334
  const issueTypeSlice = createSlice({
1485
1335
  name: "issueTypes",
1486
- initialState: initialState$r,
1336
+ initialState: initialState$s,
1487
1337
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1488
- Object.assign(state, initialState$r);
1338
+ Object.assign(state, initialState$s);
1489
1339
  }),
1490
1340
  reducers: {
1491
1341
  initializeIssueTypes: issueTypeAdapter.initialize,
@@ -1533,117 +1383,58 @@ const selectIssuesOfIssueType = restructureCreateSelectorWithArgs(
1533
1383
  [(state) => state.issueReducer.instances, (_, issueTypeId) => issueTypeId],
1534
1384
  (issuesMapping, issueTypeId) => {
1535
1385
  return fallbackToEmptyArray(
1536
- Object.values(issuesMapping).filter((issue) => issue.issue_type === issueTypeId)
1537
- );
1538
- }
1539
- )
1540
- );
1541
- const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
1542
- return selectIssuesOfIssueType(issueTypeId)(state).length;
1543
- };
1544
- const issueTypeReducer = issueTypeSlice.reducer;
1545
- const initialState$q = {
1546
- s3Urls: {}
1547
- };
1548
- const msPerHour = 1e3 * 60 * 60;
1549
- const msPerWeek = msPerHour * 24 * 7;
1550
- const fileSlice = createSlice({
1551
- name: "file",
1552
- initialState: initialState$q,
1553
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1554
- reducers: {
1555
- setUploadUrl: (state, action) => {
1556
- const { url, fields, sha1 } = action.payload;
1557
- const today2 = /* @__PURE__ */ new Date();
1558
- const weekFromToday = new Date(today2.getTime() + msPerWeek);
1559
- state.s3Urls[sha1] = {
1560
- url,
1561
- fields,
1562
- exp: weekFromToday.getTime()
1563
- };
1564
- }
1565
- }
1566
- });
1567
- const { setUploadUrl } = fileSlice.actions;
1568
- const selectUploadUrl = (sha1) => (state) => {
1569
- const url = state.fileReducer.s3Urls[sha1];
1570
- if (!url) {
1571
- return void 0;
1572
- }
1573
- const today2 = (/* @__PURE__ */ new Date()).getTime();
1574
- const expiringWithinAnHour = (url.exp ?? today2) - today2 < msPerHour;
1575
- if (expiringWithinAnHour)
1576
- return void 0;
1577
- return url;
1578
- };
1579
- const fileReducer = fileSlice.reducer;
1580
- var ProjectAccessLevel = /* @__PURE__ */ ((ProjectAccessLevel2) => {
1581
- ProjectAccessLevel2[ProjectAccessLevel2["BASIC"] = 0] = "BASIC";
1582
- ProjectAccessLevel2[ProjectAccessLevel2["ADMIN"] = 2] = "ADMIN";
1583
- return ProjectAccessLevel2;
1584
- })(ProjectAccessLevel || {});
1585
- var OrganizationAccessLevel = /* @__PURE__ */ ((OrganizationAccessLevel2) => {
1586
- OrganizationAccessLevel2[OrganizationAccessLevel2["BASIC"] = 0] = "BASIC";
1587
- OrganizationAccessLevel2[OrganizationAccessLevel2["ADMIN"] = 2] = "ADMIN";
1588
- return OrganizationAccessLevel2;
1589
- })(OrganizationAccessLevel || {});
1590
- var AttachmentModel = /* @__PURE__ */ ((AttachmentModel2) => {
1591
- AttachmentModel2["Issue"] = "issue";
1592
- AttachmentModel2["Asset"] = "asset";
1593
- AttachmentModel2["AssetType"] = "asset_type";
1594
- AttachmentModel2["Project"] = "project";
1595
- AttachmentModel2["Document"] = "document";
1596
- return AttachmentModel2;
1597
- })(AttachmentModel || {});
1598
- var IssueUpdateChange = /* @__PURE__ */ ((IssueUpdateChange2) => {
1599
- IssueUpdateChange2["STATUS"] = "status";
1600
- IssueUpdateChange2["PRIORITY"] = "priority";
1601
- IssueUpdateChange2["CATEGORY"] = "category";
1602
- IssueUpdateChange2["DESCRIPTION"] = "description";
1603
- IssueUpdateChange2["TITLE"] = "title";
1604
- IssueUpdateChange2["ASSIGNED_TO"] = "assigned_to";
1605
- IssueUpdateChange2["DUE_DATE"] = "due_date";
1606
- return IssueUpdateChange2;
1607
- })(IssueUpdateChange || {});
1608
- var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
1609
- VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
1610
- VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
1611
- VerificationCodeType2[VerificationCodeType2["PROJECT_INVITE"] = 4] = "PROJECT_INVITE";
1612
- VerificationCodeType2[VerificationCodeType2["ORGANIZATION_INVITE"] = 6] = "ORGANIZATION_INVITE";
1613
- VerificationCodeType2[VerificationCodeType2["ADD_EMAIL_DOMAIN"] = 8] = "ADD_EMAIL_DOMAIN";
1614
- VerificationCodeType2[VerificationCodeType2["RESET_PASSWORD"] = 10] = "RESET_PASSWORD";
1615
- return VerificationCodeType2;
1616
- })(VerificationCodeType || {});
1617
- var PaddleCheckoutEvent = /* @__PURE__ */ ((PaddleCheckoutEvent2) => {
1618
- PaddleCheckoutEvent2["COMPLETED"] = "checkout.completed";
1619
- PaddleCheckoutEvent2["CLOSED"] = "checkout.closed";
1620
- return PaddleCheckoutEvent2;
1621
- })(PaddleCheckoutEvent || {});
1622
- var LicenseLevel = /* @__PURE__ */ ((LicenseLevel2) => {
1623
- LicenseLevel2[LicenseLevel2["PRO"] = 0] = "PRO";
1624
- return LicenseLevel2;
1625
- })(LicenseLevel || {});
1626
- var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
1627
- LicenseStatus2[LicenseStatus2["ACTIVE"] = 0] = "ACTIVE";
1628
- LicenseStatus2[LicenseStatus2["PAUSED"] = 2] = "PAUSED";
1629
- LicenseStatus2[LicenseStatus2["CANCELLED"] = 4] = "CANCELLED";
1630
- LicenseStatus2[LicenseStatus2["INACTIVE"] = 6] = "INACTIVE";
1631
- LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
1632
- return LicenseStatus2;
1633
- })(LicenseStatus || {});
1634
- const initialState$p = {
1635
- users: {},
1636
- currentUser: {
1637
- id: 0,
1638
- username: "",
1639
- email: "",
1640
- profile: { file: null, file_sha1: null, favourite_project_ids: [], tour_step: -1 }
1386
+ Object.values(issuesMapping).filter((issue) => issue.issue_type === issueTypeId)
1387
+ );
1388
+ }
1389
+ )
1390
+ );
1391
+ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
1392
+ return selectIssuesOfIssueType(issueTypeId)(state).length;
1393
+ };
1394
+ const issueTypeReducer = issueTypeSlice.reducer;
1395
+ const initialState$r = {
1396
+ s3Urls: {}
1397
+ };
1398
+ const msPerHour = 1e3 * 60 * 60;
1399
+ const msPerWeek = msPerHour * 24 * 7;
1400
+ const fileSlice = createSlice({
1401
+ name: "file",
1402
+ initialState: initialState$r,
1403
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1404
+ reducers: {
1405
+ setUploadUrl: (state, action) => {
1406
+ const { url, fields, sha1 } = action.payload;
1407
+ const today2 = /* @__PURE__ */ new Date();
1408
+ const weekFromToday = new Date(today2.getTime() + msPerWeek);
1409
+ state.s3Urls[sha1] = {
1410
+ url,
1411
+ fields,
1412
+ exp: weekFromToday.getTime()
1413
+ };
1414
+ }
1415
+ }
1416
+ });
1417
+ const { setUploadUrl } = fileSlice.actions;
1418
+ const selectUploadUrl = (sha1) => (state) => {
1419
+ const url = state.fileReducer.s3Urls[sha1];
1420
+ if (!url) {
1421
+ return void 0;
1641
1422
  }
1423
+ const today2 = (/* @__PURE__ */ new Date()).getTime();
1424
+ const expiringWithinAnHour = (url.exp ?? today2) - today2 < msPerHour;
1425
+ if (expiringWithinAnHour)
1426
+ return void 0;
1427
+ return url;
1428
+ };
1429
+ const fileReducer = fileSlice.reducer;
1430
+ const initialState$q = {
1431
+ users: {},
1432
+ currentUser: null
1642
1433
  };
1643
1434
  const userSlice = createSlice({
1644
1435
  name: "users",
1645
- initialState: initialState$p,
1646
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1436
+ initialState: initialState$q,
1437
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1647
1438
  reducers: {
1648
1439
  setUsers: (state, action) => {
1649
1440
  const usersMapping = {};
@@ -1661,6 +1452,8 @@ const userSlice = createSlice({
1661
1452
  state.currentUser = action.payload;
1662
1453
  },
1663
1454
  setProfilePicture: (state, action) => {
1455
+ if (!state.currentUser)
1456
+ return;
1664
1457
  state.currentUser.profile.file = action.payload.file ?? null;
1665
1458
  state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1666
1459
  const currentUser = state.users[state.currentUser.id];
@@ -1670,32 +1463,12 @@ const userSlice = createSlice({
1670
1463
  currentUser.profile.file = action.payload.file ?? null;
1671
1464
  currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1672
1465
  },
1673
- addFavouriteProjectId: (state, action) => {
1674
- state.currentUser.profile.favourite_project_ids.push(action.payload);
1675
- },
1676
- removeFavouriteProjectId: (state, action) => {
1677
- state.currentUser.profile.favourite_project_ids = state.currentUser.profile.favourite_project_ids.filter(
1678
- (id) => id !== action.payload
1679
- );
1680
- },
1681
- setTourStep: (state, action) => {
1682
- state.currentUser.profile.tour_step = action.payload;
1683
- },
1684
1466
  removeUser: (state, action) => {
1685
1467
  delete state.users[action.payload];
1686
1468
  }
1687
1469
  }
1688
1470
  });
1689
- const {
1690
- setCurrentUser,
1691
- setProfilePicture,
1692
- setUsers,
1693
- addUsers,
1694
- addFavouriteProjectId,
1695
- removeFavouriteProjectId,
1696
- setTourStep,
1697
- removeUser
1698
- } = userSlice.actions;
1471
+ const { setCurrentUser, setProfilePicture, setUsers, addUsers, removeUser } = userSlice.actions;
1699
1472
  const userReducer = userSlice.reducer;
1700
1473
  const selectCurrentUser = (state) => state.userReducer.currentUser;
1701
1474
  const selectUsersMapping = (state) => state.userReducer.users;
@@ -1716,15 +1489,14 @@ const selectUsersByIds = restructureCreateSelectorWithArgs(
1716
1489
  return fallbackToEmptyArray(users);
1717
1490
  })
1718
1491
  );
1719
- const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
1720
1492
  const organizationAccessAdapter = createModelAdapter(
1721
1493
  (organizationAccess) => organizationAccess.offline_id
1722
1494
  );
1723
- const initialState$o = organizationAccessAdapter.getInitialState({});
1495
+ const initialState$p = organizationAccessAdapter.getInitialState({});
1724
1496
  const organizationAccessSlice = createSlice({
1725
1497
  name: "organizationAccess",
1726
- initialState: initialState$o,
1727
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1498
+ initialState: initialState$p,
1499
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1728
1500
  reducers: {
1729
1501
  initializeOrganizationAccesses: organizationAccessAdapter.initialize,
1730
1502
  updateOrganizationAccess: organizationAccessAdapter.updateOne,
@@ -1742,7 +1514,7 @@ const selectActiveOrganizationAccess = createSelector(
1742
1514
  [selectCurrentUser, selectOrganizationAccesses],
1743
1515
  (currentUser, organizationAccesses) => {
1744
1516
  const activeOrganizationAccess = Object.values(organizationAccesses).find(
1745
- (organizationAccess) => organizationAccess.user === currentUser.id
1517
+ (organizationAccess) => organizationAccess.user === (currentUser == null ? void 0 : currentUser.id)
1746
1518
  );
1747
1519
  return activeOrganizationAccess ?? null;
1748
1520
  }
@@ -1761,11 +1533,11 @@ const selectOrganizationAccessUserMapping = (state) => {
1761
1533
  };
1762
1534
  const organizationAccessReducer = organizationAccessSlice.reducer;
1763
1535
  const licenseAdapter = createModelAdapter((license) => license.offline_id);
1764
- const initialState$n = licenseAdapter.getInitialState({});
1536
+ const initialState$o = licenseAdapter.getInitialState({});
1765
1537
  const licenseSlice = createSlice({
1766
1538
  name: "license",
1767
- initialState: initialState$n,
1768
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1539
+ initialState: initialState$o,
1540
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1769
1541
  reducers: {
1770
1542
  initializeLicences: licenseAdapter.initialize,
1771
1543
  addLicenses: licenseAdapter.addMany,
@@ -1790,11 +1562,11 @@ const selectLicensesForProjectsMapping = createSelector(
1790
1562
  );
1791
1563
  const licenseReducer = licenseSlice.reducer;
1792
1564
  const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
1793
- const initialState$m = projectAccessAdapter.getInitialState({});
1565
+ const initialState$n = projectAccessAdapter.getInitialState({});
1794
1566
  const projectAccessSlice = createSlice({
1795
1567
  name: "projectAccess",
1796
- initialState: initialState$m,
1797
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1568
+ initialState: initialState$n,
1569
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1798
1570
  reducers: {
1799
1571
  initializeProjectAccesses: projectAccessAdapter.initialize,
1800
1572
  updateProjectAccess: projectAccessAdapter.updateOne,
@@ -1819,7 +1591,7 @@ const selectActiveProjectAccess = (state) => {
1819
1591
  const currentUser = state.userReducer.currentUser;
1820
1592
  const activeProjectId = state.projectReducer.activeProjectId;
1821
1593
  return Object.values(state.projectAccessReducer.instances).find((projectAccess) => {
1822
- return projectAccess.user === currentUser.id && projectAccess.project === activeProjectId;
1594
+ return projectAccess.user === (currentUser == null ? void 0 : currentUser.id) && projectAccess.project === activeProjectId;
1823
1595
  }) ?? null;
1824
1596
  };
1825
1597
  const selectProjectAccessForUser = (user) => (state) => {
@@ -1835,14 +1607,14 @@ const selectProjectAccessUserMapping = (state) => {
1835
1607
  return projectAccesses;
1836
1608
  };
1837
1609
  const projectAccessReducer = projectAccessSlice.reducer;
1838
- const initialState$l = {
1610
+ const initialState$m = {
1839
1611
  projects: {},
1840
1612
  activeProjectId: null
1841
1613
  };
1842
1614
  const projectSlice = createSlice({
1843
1615
  name: "projects",
1844
- initialState: initialState$l,
1845
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1616
+ initialState: initialState$m,
1617
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1846
1618
  reducers: {
1847
1619
  setProjects: (state, action) => {
1848
1620
  const projectsMap = {};
@@ -1932,9 +1704,9 @@ const selectSortedProjectUsers = createSelector(
1932
1704
  [selectCurrentUser, selectProjectUsersAsMapping, selectProjectAccessUserMapping],
1933
1705
  (currentUser, userMapping, projectAccessMapping) => {
1934
1706
  return Object.values(userMapping).sort((userA, userB) => {
1935
- if (userA.id === currentUser.id) {
1707
+ if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
1936
1708
  return -1;
1937
- } else if (userB.id === currentUser.id) {
1709
+ } else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
1938
1710
  return 1;
1939
1711
  }
1940
1712
  const projectAccessesA = projectAccessMapping[userA.id];
@@ -1949,13 +1721,13 @@ const selectSortedProjectUsers = createSelector(
1949
1721
  });
1950
1722
  }
1951
1723
  );
1952
- const initialState$k = {
1724
+ const initialState$l = {
1953
1725
  organizations: {}
1954
1726
  };
1955
1727
  const organizationSlice = createSlice({
1956
1728
  name: "organizations",
1957
- initialState: initialState$k,
1958
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1729
+ initialState: initialState$l,
1730
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1959
1731
  reducers: {
1960
1732
  setOrganizations: (state, action) => {
1961
1733
  for (const org of action.payload) {
@@ -2011,9 +1783,9 @@ const selectSortedOrganizationUsers = createSelector(
2011
1783
  [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2012
1784
  (currentUser, userMapping, organizationAccessMapping) => {
2013
1785
  return Object.values(userMapping).sort((userA, userB) => {
2014
- if (userA.id === currentUser.id) {
1786
+ if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
2015
1787
  return -1;
2016
- } else if (userB.id === currentUser.id) {
1788
+ } else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
2017
1789
  return 1;
2018
1790
  }
2019
1791
  const organizationAccessesA = organizationAccessMapping[userA.id];
@@ -2046,14 +1818,14 @@ const createOfflineAction = (request2, baseUrl, serviceName) => {
2046
1818
  }
2047
1819
  };
2048
1820
  };
2049
- const initialState$j = {
1821
+ const initialState$k = {
2050
1822
  deletedRequests: [],
2051
1823
  latestRetryTime: 0
2052
1824
  };
2053
1825
  const outboxSlice = createSlice({
2054
1826
  name: "outbox",
2055
- initialState: initialState$j,
2056
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1827
+ initialState: initialState$k,
1828
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
2057
1829
  reducers: {
2058
1830
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2059
1831
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -2085,15 +1857,15 @@ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2085
1857
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2086
1858
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2087
1859
  const outboxReducer = outboxSlice.reducer;
2088
- const initialState$i = {
1860
+ const initialState$j = {
2089
1861
  projectFiles: {},
2090
1862
  activeProjectFileId: null,
2091
1863
  isImportingProjectFile: false
2092
1864
  };
2093
1865
  const projectFileSlice = createSlice({
2094
1866
  name: "projectFiles",
2095
- initialState: initialState$i,
2096
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1867
+ initialState: initialState$j,
1868
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2097
1869
  reducers: {
2098
1870
  addOrReplaceProjectFiles: (state, action) => {
2099
1871
  for (let fileObj of action.payload) {
@@ -2180,11 +1952,11 @@ const selectProjectFileById = (id) => (state) => {
2180
1952
  };
2181
1953
  const projectFileReducer = projectFileSlice.reducer;
2182
1954
  const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2183
- const initialState$h = projectAttachmentAdapter.getInitialState({});
1955
+ const initialState$i = projectAttachmentAdapter.getInitialState({});
2184
1956
  const projectAttachmentSlice = createSlice({
2185
1957
  name: "projectAttachments",
2186
- initialState: initialState$h,
2187
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
1958
+ initialState: initialState$i,
1959
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2188
1960
  reducers: {
2189
1961
  initializeProjectAttachments: projectAttachmentAdapter.initialize,
2190
1962
  addProjectAttachment: projectAttachmentAdapter.addOne,
@@ -2239,12 +2011,12 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
2239
2011
  )
2240
2012
  );
2241
2013
  const projectAttachmentReducer = projectAttachmentSlice.reducer;
2242
- const initialState$g = {
2014
+ const initialState$h = {
2243
2015
  isRehydrated: false
2244
2016
  };
2245
2017
  const rehydratedSlice = createSlice({
2246
2018
  name: "rehydrated",
2247
- initialState: initialState$g,
2019
+ initialState: initialState$h,
2248
2020
  // The `reducers` field lets us define reducers and generate associated actions
2249
2021
  reducers: {
2250
2022
  setRehydrated: (state, action) => {
@@ -2269,11 +2041,11 @@ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
2269
2041
  }
2270
2042
  };
2271
2043
  const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
2272
- const initialState$f = formRevisionAdapter.getInitialState({});
2044
+ const initialState$g = formRevisionAdapter.getInitialState({});
2273
2045
  const formRevisionsSlice = createSlice({
2274
2046
  name: "formRevisions",
2275
- initialState: initialState$f,
2276
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2047
+ initialState: initialState$g,
2048
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2277
2049
  reducers: {
2278
2050
  initializeFormRevisions: formRevisionAdapter.initialize,
2279
2051
  setFormRevision: formRevisionAdapter.setOne,
@@ -2345,11 +2117,11 @@ const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping
2345
2117
  });
2346
2118
  const formRevisionReducer = formRevisionsSlice.reducer;
2347
2119
  const formAdapter = createModelAdapter((form) => form.offline_id);
2348
- const initialState$e = formAdapter.getInitialState({});
2120
+ const initialState$f = formAdapter.getInitialState({});
2349
2121
  const formSlice = createSlice({
2350
2122
  name: "forms",
2351
- initialState: initialState$e,
2352
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2123
+ initialState: initialState$f,
2124
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2353
2125
  reducers: {
2354
2126
  initializeForms: formAdapter.initialize,
2355
2127
  setForm: formAdapter.setOne,
@@ -2375,29 +2147,18 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
2375
2147
  (_state, search) => search
2376
2148
  ],
2377
2149
  (formsMapping, revisions, search) => {
2378
- const { searchTerm, maxResults, favorites, organization } = search;
2379
- const favoriteMatches = [];
2150
+ const { searchTerm, maxResults, organization } = search;
2380
2151
  const regularMatches = [];
2381
2152
  for (const [formId, form] of Object.entries(formsMapping)) {
2382
- if (favorites !== void 0 && form.favorite != favorites)
2383
- continue;
2384
2153
  if (Number.isInteger(organization) && organization !== form.organization) {
2385
2154
  continue;
2386
2155
  }
2387
2156
  const latestRevision = _selectLatestFormRevision(revisions, formId);
2388
2157
  if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
2389
- if (form.favorite) {
2390
- favoriteMatches.push({ ...form, latestRevision });
2391
- } else {
2392
- regularMatches.push({ ...form, latestRevision });
2393
- }
2394
- }
2395
- if (favoriteMatches.length >= maxResults) {
2396
- break;
2158
+ regularMatches.push(form);
2397
2159
  }
2398
2160
  }
2399
- const maxRegularMatches = maxResults - favoriteMatches.length;
2400
- return [...favoriteMatches, ...regularMatches.slice(0, maxRegularMatches)];
2161
+ return [...regularMatches.slice(0, maxResults)];
2401
2162
  },
2402
2163
  // as the argument is an object, we check the first level of properties for equality
2403
2164
  { memoizeOptions: { equalityCheck: shallowEqual } }
@@ -2429,11 +2190,11 @@ const selectGeneralFormCount = createSelector([selectFormMapping], (formsMapping
2429
2190
  return Object.values(formsMapping).filter((form) => !form.asset_type).length;
2430
2191
  });
2431
2192
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2432
- const initialState$d = submissionAdapter.getInitialState({});
2193
+ const initialState$e = submissionAdapter.getInitialState({});
2433
2194
  const formSubmissionSlice = createSlice({
2434
2195
  name: "formSubmissions",
2435
- initialState: initialState$d,
2436
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2196
+ initialState: initialState$e,
2197
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2437
2198
  reducers: {
2438
2199
  initializeFormSubmissions: submissionAdapter.initialize,
2439
2200
  setFormSubmission: submissionAdapter.setOne,
@@ -2645,11 +2406,11 @@ const formSubmissionReducer = formSubmissionSlice.reducer;
2645
2406
  const formSubmissionAttachmentAdapter = createModelAdapter(
2646
2407
  (attachment) => attachment.offline_id
2647
2408
  );
2648
- const initialState$c = formSubmissionAttachmentAdapter.getInitialState({});
2409
+ const initialState$d = formSubmissionAttachmentAdapter.getInitialState({});
2649
2410
  const formSubmissionAttachmentSlice = createSlice({
2650
2411
  name: "formSubmissionAttachments",
2651
- initialState: initialState$c,
2652
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2412
+ initialState: initialState$d,
2413
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2653
2414
  reducers: {
2654
2415
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2655
2416
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2701,11 +2462,11 @@ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
2701
2462
  const formRevisionAttachmentAdapter = createModelAdapter(
2702
2463
  (attachment) => attachment.offline_id
2703
2464
  );
2704
- const initialState$b = formRevisionAttachmentAdapter.getInitialState({});
2465
+ const initialState$c = formRevisionAttachmentAdapter.getInitialState({});
2705
2466
  const formRevisionAttachmentSlice = createSlice({
2706
2467
  name: "formRevisionAttachments",
2707
- initialState: initialState$b,
2708
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2468
+ initialState: initialState$c,
2469
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2709
2470
  reducers: {
2710
2471
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2711
2472
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2743,6 +2504,40 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
2743
2504
  )
2744
2505
  );
2745
2506
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2507
+ const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
2508
+ const initialState$b = workspaceAdapter.getInitialState({});
2509
+ const workspaceSlice = createSlice({
2510
+ name: "workspace",
2511
+ initialState: initialState$b,
2512
+ reducers: {
2513
+ initializeWorkspaces: workspaceAdapter.initialize,
2514
+ setWorkspaces: workspaceAdapter.setMany,
2515
+ addWorkspace: workspaceAdapter.addOne,
2516
+ updateWorkspace: workspaceAdapter.updateOne,
2517
+ deleteWorkspace: workspaceAdapter.deleteOne
2518
+ }
2519
+ });
2520
+ const { initializeWorkspaces, setWorkspaces, addWorkspace, updateWorkspace, deleteWorkspace } = workspaceSlice.actions;
2521
+ const selectWorkspaceMapping = (state) => state.workspaceReducer.instances;
2522
+ const selectWorkspaces = createSelector([selectWorkspaceMapping], (mapping) => Object.values(mapping));
2523
+ const selectMainWorkspace = createSelector(
2524
+ [selectWorkspaces],
2525
+ (workspaces) => {
2526
+ return workspaces.find((workspace) => workspace.name.toLowerCase() === "main");
2527
+ }
2528
+ );
2529
+ const selectWorkspaceById = (id) => (state) => {
2530
+ return state.workspaceReducer.instances[id];
2531
+ };
2532
+ const selectPermittedWorkspaceIds = createSelector(
2533
+ [selectWorkspaceMapping],
2534
+ (mapping) => {
2535
+ return new Set(
2536
+ Object.values(mapping).filter((workspace) => workspace.permitted).map((workspace) => workspace.offline_id)
2537
+ );
2538
+ }
2539
+ );
2540
+ const workspaceReducer = workspaceSlice.reducer;
2746
2541
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2747
2542
  const initialState$a = emailDomainAdapter.getInitialState({});
2748
2543
  const emailDomainsSlice = createSlice({
@@ -3131,13 +2926,13 @@ const {
3131
2926
  deleteIssueComments
3132
2927
  } = issueCommentSlice.actions;
3133
2928
  const selectIssueCommentMapping = (state) => state.issueCommentReducer.instances;
2929
+ const selectIssueCommentById = (id) => (state) => {
2930
+ return state.issueCommentReducer.instances[id];
2931
+ };
3134
2932
  const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
3135
- createSelector(
3136
- [selectIssueCommentMapping, (_state, issueId) => issueId],
3137
- (commentMapping, issueId) => {
3138
- return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
3139
- }
3140
- )
2933
+ createSelector([selectIssueCommentMapping, (_state, issueId) => issueId], (commentMapping, issueId) => {
2934
+ return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
2935
+ })
3141
2936
  );
3142
2937
  const issueCommentReducer = issueCommentSlice.reducer;
3143
2938
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
@@ -3424,62 +3219,11 @@ const overmapReducers = {
3424
3219
  };
3425
3220
  const overmapReducer = combineReducers(overmapReducers);
3426
3221
  const resetStore = "RESET";
3427
- function handleWorkspaceRemoval(draft, action) {
3428
- const workspaceId = action.payload;
3429
- const issuesVisibleInWorkspace = Object.values(draft.issueReducer.instances).filter(
3430
- (issue) => issue.visible_in_workspaces.includes(workspaceId)
3431
- );
3432
- const mainWorkspace = selectMainWorkspace(draft);
3433
- if (!mainWorkspace) {
3434
- throw new Error("Main workspace not found");
3435
- }
3436
- if (action.payload === mainWorkspace.offline_id) {
3437
- throw new Error("Tried to delete main workspace");
3438
- }
3439
- const categoriesInThisWorkspace = new Set(
3440
- selectCategoriesOfWorkspace(workspaceId)(draft).map((category) => category.offline_id)
3441
- );
3442
- for (const issue of issuesVisibleInWorkspace) {
3443
- if (issue.category && categoriesInThisWorkspace.has(issue.category)) {
3444
- issue.category = null;
3445
- }
3446
- }
3447
- const issuesWithThisWorkspaceIndex = issuesVisibleInWorkspace.filter(
3448
- (issue) => issue.index_workspace === action.payload
3449
- );
3450
- for (const issue of issuesWithThisWorkspaceIndex) {
3451
- issue.index_workspace = mainWorkspace.offline_id;
3452
- if (!issue.visible_in_workspaces.includes(mainWorkspace.offline_id)) {
3453
- issue.visible_in_workspaces.push(mainWorkspace.offline_id);
3454
- }
3455
- }
3456
- for (const issue of issuesVisibleInWorkspace) {
3457
- const indexOfWorkspace = issue.visible_in_workspaces.indexOf(workspaceId);
3458
- if (indexOfWorkspace === -1) {
3459
- throw new Error("Workspace not found in issue's visible_in_workspaces");
3460
- }
3461
- issue.visible_in_workspaces.splice(indexOfWorkspace, 1);
3462
- }
3463
- for (const issue of issuesVisibleInWorkspace) {
3464
- if (issue.visible_in_workspaces.length === 0) {
3465
- throw new Error(`Unexpected error: Issue ${issue.offline_id} has no visible_in_workspaces`);
3466
- }
3467
- if (issue.index_workspace === action.payload || !issue.index_workspace) {
3468
- throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
3469
- }
3470
- }
3471
- }
3472
3222
  const overmapRootReducer = (state, action) => {
3473
3223
  if (action.type === "auth/setLoggedIn" && !action.payload) {
3474
3224
  return overmapReducer(void 0, action);
3475
3225
  }
3476
- let mutatedState = state;
3477
- if (state && action.type === "workspace/removeWorkspace") {
3478
- mutatedState = createNextState(state, (draft) => {
3479
- handleWorkspaceRemoval(draft, action);
3480
- });
3481
- }
3482
- return overmapReducer(mutatedState, action);
3226
+ return overmapReducer(state, action);
3483
3227
  };
3484
3228
  let __OUTBOX_COORDINATOR = null;
3485
3229
  function getOutboxCoordinator() {
@@ -4098,57 +3842,66 @@ class BaseApiService extends BaseService {
4098
3842
  }
4099
3843
  }
4100
3844
  class CategoryService extends BaseApiService {
4101
- add(category, workspaceId) {
4102
- const offlineCategory = offline(category);
4103
- const categoryWithWorkspace = { ...offlineCategory, workspace: workspaceId };
4104
- this.dispatch(addCategory(categoryWithWorkspace));
3845
+ add(payload) {
3846
+ var _a2;
3847
+ const { store } = this.client;
3848
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
3849
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
3850
+ const offlineCategory = offline({
3851
+ ...payload,
3852
+ created_by: createdBy,
3853
+ submitted_at: submittedAt
3854
+ });
3855
+ this.dispatch(addCategory(offlineCategory));
4105
3856
  const promise = this.enqueueRequest({
4106
3857
  description: "Create Category",
4107
3858
  method: HttpMethod.POST,
4108
3859
  url: "/categories/",
4109
3860
  queryParams: {
4110
- workspace_id: workspaceId.toString()
3861
+ workspace_id: payload.workspace.toString()
4111
3862
  },
4112
3863
  payload: offlineCategory,
4113
- blockers: [],
3864
+ blockers: [payload.workspace],
4114
3865
  blocks: [offlineCategory.offline_id]
4115
3866
  });
4116
- return [categoryWithWorkspace, promise];
3867
+ return [offlineCategory, promise];
4117
3868
  }
4118
- update(category, workspaceId) {
3869
+ update(payload) {
4119
3870
  const state = this.client.store.getState();
4120
- const existingCategory = selectCategoryById(category.offline_id)(state);
3871
+ const existingCategory = selectCategoryById(payload.offline_id)(state);
4121
3872
  if (!existingCategory) {
4122
- throw new Error(`Expected an existing category with offline_id ${category.offline_id}`);
3873
+ throw new Error(`Expected an existing category with offline_id ${payload.offline_id}`);
4123
3874
  }
4124
- const optimisticCategory = { ...existingCategory, ...category };
3875
+ const optimisticCategory = { ...existingCategory, ...payload };
4125
3876
  this.dispatch(updateCategory(optimisticCategory));
4126
3877
  const promise = this.enqueueRequest({
4127
3878
  description: "Edit Category",
4128
3879
  method: HttpMethod.PATCH,
4129
- url: `/categories/${category.offline_id}/`,
4130
- queryParams: {
4131
- workspace_id: workspaceId.toString()
4132
- },
4133
- payload: category,
4134
- blockers: [category.offline_id],
4135
- blocks: [category.offline_id]
3880
+ url: `/categories/${payload.offline_id}/`,
3881
+ payload,
3882
+ blockers: [payload.offline_id],
3883
+ blocks: [payload.offline_id]
4136
3884
  });
4137
3885
  return [optimisticCategory, promise];
4138
3886
  }
4139
- remove(category, workspaceId) {
4140
- this.dispatch(deleteCategory(category.offline_id));
4141
- return this.enqueueRequest({
3887
+ remove(id) {
3888
+ const { store } = this.client;
3889
+ const category = selectCategoryById(id)(store.getState());
3890
+ if (!category) {
3891
+ throw new Error(`No category with id ${id} found in the store`);
3892
+ }
3893
+ this.dispatch(deleteCategory(id));
3894
+ const promise = this.enqueueRequest({
4142
3895
  description: "Delete Category",
4143
3896
  method: HttpMethod.DELETE,
4144
3897
  url: `/categories/${category.offline_id}/`,
4145
- // TODO: Shouldn't be necessary to specify workspace_id here
4146
- queryParams: {
4147
- workspace_id: workspaceId.toString()
4148
- },
4149
3898
  blockers: [category.offline_id],
4150
3899
  blocks: []
4151
3900
  });
3901
+ promise.catch(() => {
3902
+ this.dispatch(addCategory(category));
3903
+ });
3904
+ return promise;
4152
3905
  }
4153
3906
  async refreshStore(projectId) {
4154
3907
  const result = await this.enqueueRequest({
@@ -4172,53 +3925,81 @@ function chunkArray(arr, chunkSize) {
4172
3925
  }
4173
3926
  class AssetService extends BaseApiService {
4174
3927
  // Basic CRUD functions
4175
- add(asset, workspaceId) {
4176
- if (!asset.canvas_marker && !asset.geo_marker) {
3928
+ add(payload) {
3929
+ const { store } = this.client;
3930
+ if (!payload.canvas_marker && !payload.geo_marker) {
4177
3931
  throw new Error("Asset must have either a canvas_marker or geo_marker");
4178
3932
  }
4179
- const offlineAsset = offline(asset);
3933
+ const createdBy = store.getState().userReducer.currentUser.id;
3934
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
3935
+ const offlineAsset = offline({
3936
+ ...payload,
3937
+ created_by: createdBy,
3938
+ submitted_at: submittedAt
3939
+ });
4180
3940
  this.dispatch(addAsset(offlineAsset));
4181
3941
  const promise = this.enqueueRequest({
4182
3942
  description: "Create asset",
4183
3943
  method: HttpMethod.POST,
4184
- url: `/assets/types/${offlineAsset.asset_type}/add-assets/`,
4185
- queryParams: {
4186
- workspace_id: workspaceId.toString()
3944
+ url: "/assets/",
3945
+ payload: {
3946
+ offline_id: offlineAsset.offline_id,
3947
+ submitted_at: offlineAsset.submitted_at,
3948
+ geo_marker: offlineAsset.geo_marker,
3949
+ canvas_marker: offlineAsset.canvas_marker,
3950
+ label: offlineAsset.label,
3951
+ description: offlineAsset.description,
3952
+ asset_type: offlineAsset.asset_type
4187
3953
  },
4188
- payload: { assets: [offlineAsset] },
4189
- blockers: [],
3954
+ blockers: [offlineAsset.asset_type],
4190
3955
  blocks: [offlineAsset.offline_id]
4191
3956
  });
3957
+ promise.then((createdAsset) => {
3958
+ this.dispatch(updateAsset(createdAsset));
3959
+ }).catch(() => {
3960
+ this.dispatch(deleteAsset(offlineAsset.offline_id));
3961
+ });
4192
3962
  return [offlineAsset, promise];
4193
3963
  }
4194
- update(asset, workspaceId) {
4195
- if (!asset.canvas_marker && !asset.geo_marker) {
3964
+ update(payload) {
3965
+ const { store } = this.client;
3966
+ if (!payload.canvas_marker && !payload.geo_marker) {
4196
3967
  throw new Error("Asset must have either a canvas_marker or geo_marker");
4197
3968
  }
4198
- this.client.store.dispatch(updateAsset(asset));
3969
+ const asset = selectAssetById(payload.offline_id)(store.getState());
3970
+ if (!asset) {
3971
+ throw new Error(`No asset with id ${payload.offline_id} found in the store`);
3972
+ }
3973
+ const updatedAsset = {
3974
+ ...asset,
3975
+ ...payload
3976
+ };
3977
+ this.dispatch(updateAsset(updatedAsset));
4199
3978
  const promise = this.enqueueRequest({
4200
3979
  description: "Edit asset",
4201
3980
  method: HttpMethod.PATCH,
4202
- url: `/assets/${asset.offline_id}/`,
4203
- queryParams: {
4204
- workspace_id: workspaceId.toString()
4205
- },
4206
- payload: asset,
4207
- blockers: [asset.offline_id],
4208
- blocks: [asset.offline_id]
3981
+ url: `/assets/${payload.offline_id}/`,
3982
+ payload,
3983
+ blockers: [payload.offline_id],
3984
+ blocks: [payload.offline_id]
3985
+ });
3986
+ promise.then((result) => {
3987
+ this.dispatch(updateAsset(result));
3988
+ }).catch(() => {
3989
+ this.dispatch(updateAsset(asset));
4209
3990
  });
4210
- return [asset, promise];
3991
+ return [updatedAsset, promise];
4211
3992
  }
4212
- async remove(assetId) {
3993
+ async remove(id) {
4213
3994
  const { store } = this.client;
4214
3995
  const state = store.getState();
4215
- const assetToBeDeleted = selectAssetById(assetId)(state);
3996
+ const assetToBeDeleted = selectAssetById(id)(state);
4216
3997
  if (!assetToBeDeleted)
4217
- throw new Error(`No asset with id ${assetId} found in the store`);
4218
- const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(state);
4219
- const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(state);
4220
- const issueAssociations = selectIssueAssociationsOfAsset(assetId)(state);
4221
- this.dispatch(deleteAsset(assetId));
3998
+ throw new Error(`No asset with id ${id} found in the store`);
3999
+ const attachmentsOfAssets = selectAttachmentsOfAsset(id)(state);
4000
+ const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(id)(state);
4001
+ const issueAssociations = selectIssueAssociationsOfAsset(id)(state);
4002
+ this.dispatch(deleteAsset(id));
4222
4003
  if (attachmentsOfAssets.length > 0) {
4223
4004
  const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
4224
4005
  this.dispatch(deleteAssetAttachments(attachmentsOfAssetIds));
@@ -4234,8 +4015,8 @@ class AssetService extends BaseApiService {
4234
4015
  return this.enqueueRequest({
4235
4016
  description: "Delete asset",
4236
4017
  method: HttpMethod.DELETE,
4237
- url: `/assets/${assetId}/`,
4238
- blockers: [assetId],
4018
+ url: `/assets/${id}/`,
4019
+ blockers: [id],
4239
4020
  blocks: []
4240
4021
  }).catch((err) => {
4241
4022
  this.dispatch(addAsset(assetToBeDeleted));
@@ -4245,39 +4026,17 @@ class AssetService extends BaseApiService {
4245
4026
  throw err;
4246
4027
  });
4247
4028
  }
4248
- async deleteAllAssetsOfAssetType(assetTypeId) {
4249
- const { store } = this.client;
4250
- const state = store.getState();
4251
- const allAssetsOfAssetType = selectAssetsOfAssetType(assetTypeId)(state);
4252
- const allAssetsOfAssetTypeIds = allAssetsOfAssetType.map((c) => c.offline_id);
4253
- const affectedOfflineIds = [assetTypeId, ...allAssetsOfAssetTypeIds];
4254
- store.dispatch(deleteAssets(allAssetsOfAssetTypeIds));
4255
- return this.enqueueRequest({
4256
- description: "Delete all assets of asset type",
4257
- method: HttpMethod.DELETE,
4258
- url: `/assets/types/${assetTypeId}/delete-all-of-type/`,
4259
- blockers: affectedOfflineIds,
4260
- blocks: affectedOfflineIds
4261
- }).catch((err) => {
4262
- store.dispatch(addAssets(allAssetsOfAssetType));
4263
- throw err;
4264
- });
4265
- }
4266
- // TODO: payload does not require asset_type
4267
- bulkAdd(assetsToCreate, workspaceId, assetTypeId, batchSize) {
4029
+ bulkAdd(payloads, assetTypeId, batchSize) {
4268
4030
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4269
4031
  const transactionId = v4();
4270
- const assetBatches = chunkArray(assetsToCreate, batchSize).map((assetBatch) => {
4271
- const assetPayloads = assetBatch.map((assetPayload) => {
4272
- return offline({
4273
- ...assetPayload,
4274
- submitted_at: submittedAt
4275
- });
4276
- });
4032
+ const assetBatches = chunkArray(payloads, batchSize).map((assetBatch) => {
4033
+ const assetPayloads = assetBatch.map((assetPayload) => offline(assetPayload));
4277
4034
  return {
4278
4035
  batchId: v4(),
4279
4036
  payload: {
4280
4037
  transaction_id: transactionId,
4038
+ submitted_at: submittedAt,
4039
+ asset_type: assetTypeId,
4281
4040
  assets: assetPayloads
4282
4041
  }
4283
4042
  };
@@ -4295,10 +4054,7 @@ class AssetService extends BaseApiService {
4295
4054
  const promise = this.enqueueRequest({
4296
4055
  description: "Batch create assets",
4297
4056
  method: HttpMethod.POST,
4298
- url: `/assets/types/${assetTypeId}/add-assets/`,
4299
- queryParams: {
4300
- workspace_id: workspaceId.toString()
4301
- },
4057
+ url: "/assets/bulk/",
4302
4058
  payload,
4303
4059
  blockers,
4304
4060
  blocks
@@ -4324,117 +4080,152 @@ class AssetService extends BaseApiService {
4324
4080
  }
4325
4081
  }
4326
4082
  class AssetStageCompletionService extends BaseApiService {
4327
- add(assetId, stageId) {
4328
- var _a2;
4083
+ add(payload) {
4329
4084
  const { store } = this.client;
4330
- const assetTypeId = (_a2 = selectAssetById(assetId)(store.getState())) == null ? void 0 : _a2.asset_type;
4331
- if (!assetTypeId) {
4332
- throw new Error(`Asset with offline_id ${assetId} not found`);
4333
- }
4085
+ const createdBy = store.getState().userReducer.currentUser.id;
4086
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4334
4087
  const offlineStageCompletion = offline({
4335
- asset: assetId,
4336
- stage: stageId
4088
+ ...payload,
4089
+ created_by: createdBy,
4090
+ submitted_at: submittedAt
4337
4091
  });
4338
- this.dispatch(addStageCompletion(offlineStageCompletion));
4092
+ this.dispatch(addAssetStageCompletion(offlineStageCompletion));
4339
4093
  const promise = this.enqueueRequest({
4340
- description: "Complete stage",
4094
+ description: "Add asset stage completion",
4341
4095
  method: HttpMethod.POST,
4342
- url: `/assets/types/${assetTypeId}/complete-stages/`,
4343
- // TODO: Add submitted_at to model
4344
- payload: { completions: [{ ...offlineStageCompletion, submitted_at: (/* @__PURE__ */ new Date()).getTime() / 1e3 }] },
4345
- blockers: [assetId, stageId],
4096
+ url: "/assets/completions/",
4097
+ payload: {
4098
+ offline_id: offlineStageCompletion.offline_id,
4099
+ submitted_at: submittedAt,
4100
+ asset: payload.asset,
4101
+ stage: payload.stage
4102
+ },
4103
+ blockers: [payload.asset, payload.stage],
4346
4104
  blocks: [offlineStageCompletion.offline_id]
4347
4105
  });
4106
+ promise.then((result) => {
4107
+ this.dispatch(updateAssetStageCompletion(result));
4108
+ }).catch(() => {
4109
+ this.dispatch(deleteAssetStageCompletion(offlineStageCompletion.offline_id));
4110
+ });
4348
4111
  return [offlineStageCompletion, promise];
4349
4112
  }
4350
- async refreshStore(projectId) {
4351
- const result = await this.enqueueRequest({
4352
- description: "Get stage completions",
4353
- method: HttpMethod.GET,
4354
- url: `/projects/${projectId}/asset-stage-completions/`,
4355
- blockers: [],
4113
+ delete(id) {
4114
+ const { store } = this.client;
4115
+ const assetStageCompletion = selectAssetStageCompletionById(id)(store.getState());
4116
+ if (!assetStageCompletion) {
4117
+ throw new Error(`Expected asset stage completion with id ${id} to exist`);
4118
+ }
4119
+ this.dispatch(deleteAssetStageCompletion(id));
4120
+ const promise = this.enqueueRequest({
4121
+ description: "Delete asset stage completion",
4122
+ method: HttpMethod.DELETE,
4123
+ url: `/assets/completions/${id}/`,
4124
+ blockers: [id],
4356
4125
  blocks: []
4357
4126
  });
4358
- this.dispatch(addStageCompletions(result));
4127
+ promise.catch(() => {
4128
+ this.dispatch(addAssetStageCompletion(assetStageCompletion));
4129
+ });
4130
+ return promise;
4359
4131
  }
4360
- /**
4361
- * Creates a collection of AssetStageCompletions, marking the referenced stages as completed for the referenced
4362
- * assets. It's REQUIRED that all assets referenced all have the SAME asset type.
4363
- * @param assetTypeId The ID of the asset type for which we are completing stages (we can only complete
4364
- * stages for one asset type at a time)
4365
- * @param stageCompletions
4366
- */
4367
- async bulkAdd(assetTypeId, stageCompletions) {
4368
- const offlineStageCompletions = stageCompletions.map((completion) => {
4369
- return offline(completion);
4370
- });
4371
- const asMapping = {};
4372
- for (const completion of stageCompletions) {
4373
- const stageToCompletionDateMapping = asMapping[completion.asset] || {};
4374
- stageToCompletionDateMapping[completion.stage] = (/* @__PURE__ */ new Date()).toISOString();
4375
- asMapping[completion.asset] = stageToCompletionDateMapping;
4376
- }
4377
- this.dispatch(addStageCompletions(asMapping));
4378
- await this.enqueueRequest({
4379
- description: "Bulk complete stages",
4132
+ bulkAdd(payloads) {
4133
+ const { store } = this.client;
4134
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4135
+ const createdBy = store.getState().userReducer.currentUser.id;
4136
+ const payload = payloads.map((payload2) => offline(payload2));
4137
+ const offlineStageCompletions = payload.map((completion) => {
4138
+ return {
4139
+ ...completion,
4140
+ created_by: createdBy,
4141
+ submitted_at: submittedAt
4142
+ };
4143
+ });
4144
+ const offlineIds = offlineStageCompletions.map(({ offline_id }) => offline_id);
4145
+ this.dispatch(addAssetStageCompletions(offlineStageCompletions));
4146
+ const promise = this.enqueueRequest({
4147
+ description: "Bulk create asset stage completions",
4380
4148
  method: HttpMethod.POST,
4381
- url: `/assets/types/${assetTypeId}/complete-stages/`,
4149
+ url: "/assets/completions/bulk/",
4382
4150
  payload: {
4383
- completions: offlineStageCompletions
4151
+ submitted_at: submittedAt,
4152
+ completions: payload
4384
4153
  },
4385
- blockers: [assetTypeId, ...stageCompletions.map((c) => c.asset), ...stageCompletions.map((c) => c.stage)],
4386
- blocks: offlineStageCompletions.map((c) => c.offline_id)
4154
+ blockers: [...payloads.map((c) => c.asset), ...payloads.map((c) => c.stage)],
4155
+ blocks: offlineIds
4387
4156
  });
4388
- }
4389
- bulkDelete(stageId, assetIds) {
4390
- const stageCompletionsToRemove = assetIds.map((assetId) => {
4391
- return {
4392
- asset: assetId,
4393
- stage: stageId
4394
- };
4157
+ promise.then((result) => {
4158
+ this.dispatch(updateAssetStageCompletions(result));
4159
+ }).catch(() => {
4160
+ this.dispatch(deleteAssetStageCompletions(offlineIds));
4395
4161
  });
4396
- this.dispatch(removeStageCompletions(stageCompletionsToRemove));
4397
- return this.enqueueRequest({
4398
- description: `Undo stage for ${assetIds.length} assets(s)`,
4399
- // TODO: Rename to setCompletedStages
4162
+ return [offlineStageCompletions, promise];
4163
+ }
4164
+ bulkDelete(ids) {
4165
+ const { store } = this.client;
4166
+ const assetStageCompletions = selectAssetStageCompletionsByIds(ids)(store.getState());
4167
+ this.dispatch(deleteAssetStageCompletions(ids));
4168
+ const promise = this.enqueueRequest({
4169
+ description: "Deleting asset stage completions",
4400
4170
  method: HttpMethod.DELETE,
4401
- url: `/assets/stages/${stageId}/undo-stages/`,
4171
+ url: "/assets/completions/bulk/",
4402
4172
  payload: {
4403
- assets: assetIds
4173
+ completion_ids: ids
4404
4174
  },
4405
- blockers: [stageId, ...assetIds],
4175
+ blockers: ids,
4176
+ blocks: []
4177
+ });
4178
+ promise.catch(() => {
4179
+ this.dispatch(addAssetStageCompletions(assetStageCompletions));
4180
+ });
4181
+ return promise;
4182
+ }
4183
+ async refreshStore(projectId) {
4184
+ const result = await this.enqueueRequest({
4185
+ description: "Get asset stage completions",
4186
+ method: HttpMethod.GET,
4187
+ url: `/projects/${projectId}/asset-stage-completions/`,
4188
+ blockers: [],
4406
4189
  blocks: []
4407
4190
  });
4191
+ this.dispatch(initializeAssetStageCompletions(result));
4408
4192
  }
4409
4193
  }
4410
4194
  class AssetStageService extends BaseApiService {
4411
- async bulkCreateStages(stagesToSubmit, assetTypeId, workspaceId) {
4195
+ bulkAdd(stagesToSubmit, assetTypeId) {
4196
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4197
+ const createdBy = this.client.store.getState().userReducer.currentUser.id;
4412
4198
  const payload = stagesToSubmit.map((stage) => {
4413
4199
  return offline(stage);
4414
4200
  });
4415
- const fullStages = payload.map((stage) => {
4416
- return { ...stage, asset_type: assetTypeId };
4201
+ const offlineStages = payload.map((stage) => {
4202
+ return { ...stage, asset_type: assetTypeId, created_by: createdBy, submitted_at: submittedAt };
4417
4203
  });
4418
- this.dispatch(addStages(fullStages));
4419
- return this.enqueueRequest({
4204
+ this.dispatch(addAssetStages(offlineStages));
4205
+ const promise = this.enqueueRequest({
4420
4206
  description: "Add asset stages",
4421
4207
  method: HttpMethod.POST,
4422
- url: `/assets/types/${assetTypeId}/add-stages/`,
4208
+ url: "/assets/stages/bulk/",
4423
4209
  payload: {
4210
+ submitted_at: submittedAt,
4211
+ asset_type: assetTypeId,
4424
4212
  stages: payload
4425
4213
  },
4426
- queryParams: {
4427
- workspace_id: workspaceId.toString()
4428
- },
4429
- blockers: [assetTypeId, workspaceId],
4214
+ blockers: [assetTypeId],
4430
4215
  blocks: payload.map(({ offline_id }) => offline_id)
4431
4216
  });
4217
+ promise.then((result) => {
4218
+ this.dispatch(updateAssetStages(result));
4219
+ }).catch(() => {
4220
+ this.dispatch(deleteAssetStages(offlineStages.map(({ offline_id }) => offline_id)));
4221
+ });
4222
+ return [offlineStages, promise];
4432
4223
  }
4433
- async bulkUpdateStages(stagesToUpdate, assetTypeId) {
4224
+ async bulkUpdate(stagesToUpdate, assetTypeId) {
4434
4225
  const store = this.client.store;
4435
4226
  const state = store.getState();
4436
4227
  const prevStages = selectAssetStagesByIds(stagesToUpdate.map(({ offline_id }) => offline_id))(state);
4437
- this.dispatch(updateStages(stagesToUpdate));
4228
+ this.dispatch(updateAssetStages(stagesToUpdate));
4438
4229
  return this.enqueueRequest({
4439
4230
  description: "Edit asset stages",
4440
4231
  method: HttpMethod.PATCH,
@@ -4445,33 +4236,58 @@ class AssetStageService extends BaseApiService {
4445
4236
  blockers: [assetTypeId],
4446
4237
  blocks: stagesToUpdate.map(({ offline_id }) => offline_id)
4447
4238
  }).catch((e) => {
4448
- store.dispatch(updateStages(prevStages));
4239
+ this.dispatch(updateAssetStages(prevStages));
4449
4240
  throw e;
4450
4241
  });
4451
4242
  }
4452
4243
  async bulkDelete(idsToDelete) {
4453
- this.dispatch(removeStages(idsToDelete));
4454
- return this.enqueueRequest({
4244
+ const { store } = this.client;
4245
+ const assetStages = selectAssetStagesByIds(idsToDelete)(store.getState());
4246
+ this.dispatch(deleteAssetStages(idsToDelete));
4247
+ const promise = this.enqueueRequest({
4455
4248
  description: "Delete asset stages",
4456
4249
  method: HttpMethod.DELETE,
4457
- url: "/assets/stages/bulk-delete/",
4250
+ url: "/assets/stages/bulk/",
4458
4251
  payload: {
4459
4252
  stage_ids: idsToDelete
4460
4253
  },
4461
4254
  blockers: idsToDelete,
4462
4255
  blocks: []
4463
4256
  });
4257
+ promise.catch(() => {
4258
+ this.dispatch(addAssetStages(assetStages));
4259
+ });
4260
+ return promise;
4464
4261
  }
4465
- async update(assetStage) {
4466
- this.dispatch(addStages([assetStage]));
4467
- return this.enqueueRequest({
4262
+ update(payload) {
4263
+ const { store } = this.client;
4264
+ const assetStage = selectAssetStageById(payload.offline_id)(store.getState());
4265
+ if (!assetStage)
4266
+ throw new Error(`No asset stage with id ${payload.offline_id} found in the store`);
4267
+ const updatedAssetStage = {
4268
+ ...assetStage,
4269
+ ...payload
4270
+ };
4271
+ this.dispatch(updateAssetStage(updatedAssetStage));
4272
+ const promise = this.enqueueRequest({
4468
4273
  description: "Update asset stage",
4469
4274
  method: HttpMethod.PATCH,
4470
4275
  url: `/assets/stages/${assetStage.offline_id}/`,
4471
- payload: assetStage,
4276
+ payload: {
4277
+ name: payload.name,
4278
+ description: payload.description,
4279
+ priority: payload.priority,
4280
+ color: payload.color
4281
+ },
4472
4282
  blockers: [assetStage.offline_id],
4473
4283
  blocks: [assetStage.offline_id]
4474
4284
  });
4285
+ promise.then((result) => {
4286
+ this.dispatch(updateAssetStage(result));
4287
+ }).catch(() => {
4288
+ this.dispatch(setAssetStage(assetStage));
4289
+ });
4290
+ return [updatedAssetStage, promise];
4475
4291
  }
4476
4292
  async linkForm(stageId, formId) {
4477
4293
  const { store } = this.client;
@@ -4479,7 +4295,7 @@ class AssetStageService extends BaseApiService {
4479
4295
  if (!stage) {
4480
4296
  throw new Error(`No asset stage with id ${stageId} found in the store`);
4481
4297
  }
4482
- this.dispatch(updateStage({ ...stage, form: formId }));
4298
+ this.dispatch(updateAssetStage({ ...stage, form: formId }));
4483
4299
  try {
4484
4300
  await this.enqueueRequest({
4485
4301
  description: "Link asset stage to form",
@@ -4490,7 +4306,7 @@ class AssetStageService extends BaseApiService {
4490
4306
  blocks: [stageId]
4491
4307
  });
4492
4308
  } catch (e) {
4493
- this.dispatch(setStage(stage));
4309
+ this.dispatch(setAssetStage(stage));
4494
4310
  throw e;
4495
4311
  }
4496
4312
  }
@@ -4500,7 +4316,7 @@ class AssetStageService extends BaseApiService {
4500
4316
  if (!stage) {
4501
4317
  throw new Error(`No asset stage with id ${stageId} found in the store`);
4502
4318
  }
4503
- this.dispatch(updateStage({ ...stage, form: void 0 }));
4319
+ this.dispatch(updateAssetStage({ ...stage, form: void 0 }));
4504
4320
  try {
4505
4321
  await this.enqueueRequest({
4506
4322
  description: "Unlink asset stage from form",
@@ -4510,7 +4326,7 @@ class AssetStageService extends BaseApiService {
4510
4326
  blocks: [stageId]
4511
4327
  });
4512
4328
  } catch (e) {
4513
- this.dispatch(setStage(stage));
4329
+ this.dispatch(setAssetStage(stage));
4514
4330
  throw e;
4515
4331
  }
4516
4332
  }
@@ -4522,7 +4338,7 @@ class AssetStageService extends BaseApiService {
4522
4338
  blockers: [],
4523
4339
  blocks: []
4524
4340
  });
4525
- this.dispatch(initializeStages(result));
4341
+ this.dispatch(initializeAssetStages(result));
4526
4342
  }
4527
4343
  }
4528
4344
  class BaseUploadService extends BaseApiService {
@@ -4602,8 +4418,9 @@ const AttachmentModelMeta = {
4602
4418
  };
4603
4419
  class BaseAttachmentService extends BaseUploadService {
4604
4420
  async attachFiles(files, modelId, buildOfflineAttachment) {
4421
+ var _a2;
4605
4422
  const { store } = this.client;
4606
- const currentUser = store.getState().userReducer.currentUser;
4423
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
4607
4424
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4608
4425
  const offlineAttachments = [];
4609
4426
  const attachmentPayloads = [];
@@ -4623,7 +4440,7 @@ class BaseAttachmentService extends BaseUploadService {
4623
4440
  file,
4624
4441
  sha1,
4625
4442
  submittedAt,
4626
- createdBy: currentUser.id,
4443
+ createdBy,
4627
4444
  description: "",
4628
4445
  modelId
4629
4446
  });
@@ -4729,29 +4546,61 @@ class AssetAttachmentService extends BaseAttachmentService {
4729
4546
  }
4730
4547
  }
4731
4548
  class AssetTypeService extends BaseApiService {
4732
- add(assetType) {
4733
- const offlineAssetType = offline(assetType);
4549
+ add(payload) {
4550
+ const { store } = this.client;
4551
+ const createdBy = store.getState().userReducer.currentUser.id;
4552
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4553
+ const offlineAssetType = offline({
4554
+ ...payload,
4555
+ created_by: createdBy,
4556
+ submitted_at: submittedAt
4557
+ });
4734
4558
  this.dispatch(addAssetType(offlineAssetType));
4735
4559
  const promise = this.enqueueRequest({
4736
4560
  description: "Create asset type",
4737
4561
  method: HttpMethod.POST,
4738
- url: `/projects/${assetType.project}/asset-types/`,
4562
+ url: `/projects/${payload.project}/asset-types/`,
4739
4563
  payload: { ...offlineAssetType },
4740
4564
  blockers: [],
4741
4565
  blocks: [offlineAssetType.offline_id]
4742
4566
  });
4567
+ promise.then((result) => {
4568
+ this.dispatch(updateAssetType(result));
4569
+ }).catch(() => {
4570
+ this.dispatch(deleteAssetType(offlineAssetType.offline_id));
4571
+ });
4743
4572
  return [offlineAssetType, promise];
4744
4573
  }
4745
- update(assetType) {
4746
- this.dispatch(addAssetType(assetType));
4747
- return this.enqueueRequest({
4574
+ update(payload) {
4575
+ const { store } = this.client;
4576
+ const assetType = selectAssetTypeById(payload.offline_id)(store.getState());
4577
+ if (!assetType) {
4578
+ throw new Error(`Expected asset type with offline_id ${payload.offline_id} to exist`);
4579
+ }
4580
+ const updatedAssetType = {
4581
+ ...assetType,
4582
+ ...payload
4583
+ };
4584
+ this.dispatch(updateAssetType(updatedAssetType));
4585
+ const promise = this.enqueueRequest({
4748
4586
  description: "Update asset type",
4749
4587
  method: HttpMethod.PATCH,
4750
- url: `/assets/types/${assetType.offline_id}/`,
4751
- payload: assetType,
4588
+ url: `/assets/types/${payload.offline_id}/`,
4589
+ payload: {
4590
+ icon: payload.icon,
4591
+ color: payload.color,
4592
+ name: payload.name,
4593
+ description: payload.description
4594
+ },
4752
4595
  blockers: [assetType.offline_id],
4753
4596
  blocks: [assetType.offline_id]
4754
4597
  });
4598
+ promise.then((result) => {
4599
+ this.dispatch(updateAssetType(result));
4600
+ }).catch(() => {
4601
+ this.dispatch(updateAssetType(assetType));
4602
+ });
4603
+ return [updatedAssetType, promise];
4755
4604
  }
4756
4605
  async delete(assetTypeId) {
4757
4606
  const { store } = this.client;
@@ -4760,17 +4609,13 @@ class AssetTypeService extends BaseApiService {
4760
4609
  if (!assetType) {
4761
4610
  throw new Error(`Expected asset type with offline_id ${assetTypeId} to exist`);
4762
4611
  }
4612
+ const assetsOfAssetType = selectAssetsOfAssetType(assetTypeId)(state);
4763
4613
  const stagesOfAssetType = selectStagesOfAssetType(assetTypeId)(state);
4764
4614
  const attachmentsOfAssetType = selectAttachmentsOfAssetType(assetTypeId)(state);
4765
4615
  this.dispatch(deleteAssetType(assetTypeId));
4766
- if (stagesOfAssetType.length > 0) {
4767
- const stagesOfAssetTypeIds = stagesOfAssetType.map((assetStage) => assetStage.offline_id);
4768
- this.dispatch(removeStages(stagesOfAssetTypeIds));
4769
- }
4770
- if (attachmentsOfAssetType.length > 0) {
4771
- const attachmentsOfAssetTypeIds = attachmentsOfAssetType.map(({ offline_id }) => offline_id);
4772
- this.dispatch(deleteAssetTypeAttachments(attachmentsOfAssetTypeIds));
4773
- }
4616
+ this.dispatch(deleteAssets(assetsOfAssetType.map((asset) => asset.offline_id)));
4617
+ this.dispatch(deleteAssetStages(stagesOfAssetType.map((assetStage) => assetStage.offline_id)));
4618
+ this.dispatch(deleteAssetTypeAttachments(attachmentsOfAssetType.map(({ offline_id }) => offline_id)));
4774
4619
  return this.enqueueRequest({
4775
4620
  description: "Delete asset type",
4776
4621
  method: HttpMethod.DELETE,
@@ -4779,7 +4624,8 @@ class AssetTypeService extends BaseApiService {
4779
4624
  blocks: []
4780
4625
  }).catch((e) => {
4781
4626
  this.dispatch(addAssetType(assetType));
4782
- this.dispatch(addStages(stagesOfAssetType));
4627
+ this.dispatch(addAssets(assetsOfAssetType));
4628
+ this.dispatch(addAssetStages(stagesOfAssetType));
4783
4629
  this.dispatch(addAssetTypeAttachments(attachmentsOfAssetType));
4784
4630
  throw e;
4785
4631
  });
@@ -4827,21 +4673,21 @@ class AssetTypeAttachmentService extends BaseAttachmentService {
4827
4673
  }
4828
4674
  }
4829
4675
  class IssueCommentService extends BaseApiService {
4830
- // Omit author and submitted_at since these will always be set internally
4831
- add(comment) {
4676
+ add(payload) {
4677
+ var _a2;
4832
4678
  const { store } = this.client;
4833
4679
  const offlineComment = offline({
4834
- ...comment,
4835
- author: store.getState().userReducer.currentUser.id,
4680
+ ...payload,
4681
+ author: (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
4836
4682
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
4837
4683
  });
4838
4684
  this.dispatch(addIssueComment(offlineComment));
4839
4685
  const promise = this.enqueueRequest({
4840
- description: `${truncate(comment.content, 80)}`,
4686
+ description: "Add issue comment",
4841
4687
  method: HttpMethod.POST,
4842
- url: `/issues/${comment.issue}/comment/`,
4688
+ url: `/issues/${payload.issue}/comment/`,
4843
4689
  payload: offlineComment,
4844
- blockers: [comment.issue],
4690
+ blockers: [payload.issue],
4845
4691
  blocks: [offlineComment.offline_id]
4846
4692
  });
4847
4693
  promise.catch(() => {
@@ -4849,37 +4695,41 @@ class IssueCommentService extends BaseApiService {
4849
4695
  });
4850
4696
  return [offlineComment, promise];
4851
4697
  }
4852
- update(comment) {
4698
+ update(payload) {
4853
4699
  const { store } = this.client;
4854
- const commentToUpdate = store.getState().issueCommentReducer.instances[comment.offline_id];
4700
+ const commentToUpdate = selectIssueCommentById(payload.offline_id)(store.getState());
4855
4701
  if (!commentToUpdate) {
4856
- throw new Error(`Comment with offline_id ${comment.offline_id} not found in store`);
4702
+ throw new Error(`Comment with offline_id ${payload.offline_id} not found in store`);
4857
4703
  }
4858
- this.dispatch(setIssueComment(comment));
4704
+ const updatedComment = {
4705
+ ...commentToUpdate,
4706
+ ...payload
4707
+ };
4708
+ this.dispatch(setIssueComment(updatedComment));
4859
4709
  const promise = this.enqueueRequest({
4860
- description: `Edit comment: ${truncate(comment.content, 80)}`,
4710
+ description: "Edit issue comment",
4861
4711
  method: HttpMethod.PATCH,
4862
- url: `/issues/comments/${comment.offline_id}/`,
4863
- payload: comment,
4864
- blockers: [comment.issue],
4865
- blocks: [comment.offline_id]
4712
+ url: `/issues/comments/${payload.offline_id}/`,
4713
+ payload,
4714
+ blockers: [payload.offline_id],
4715
+ blocks: [payload.offline_id]
4866
4716
  });
4867
4717
  promise.catch(() => {
4868
4718
  this.dispatch(setIssueComment(commentToUpdate));
4869
4719
  });
4870
- return [comment, promise];
4720
+ return [updatedComment, promise];
4871
4721
  }
4872
- remove(offline_id) {
4873
- const commentToRemove = this.client.store.getState().issueCommentReducer.instances[offline_id];
4722
+ remove(id) {
4723
+ const commentToRemove = this.client.store.getState().issueCommentReducer.instances[id];
4874
4724
  if (!commentToRemove) {
4875
- throw new Error(`Comment with offline_id ${offline_id} not found in store`);
4725
+ throw new Error(`Comment with offline_id ${id} not found in store`);
4876
4726
  }
4877
- this.dispatch(deleteIssueComment(offline_id));
4727
+ this.dispatch(deleteIssueComment(id));
4878
4728
  const promise = this.enqueueRequest({
4879
4729
  description: "Delete comment",
4880
4730
  method: HttpMethod.DELETE,
4881
- url: `/issues/comments/${offline_id}/`,
4882
- blockers: [offline_id],
4731
+ url: `/issues/comments/${id}/`,
4732
+ blockers: [id],
4883
4733
  blocks: []
4884
4734
  });
4885
4735
  promise.catch(() => {
@@ -4952,71 +4802,50 @@ class IssueAttachmentService extends BaseAttachmentService {
4952
4802
  }
4953
4803
  class IssueService extends BaseApiService {
4954
4804
  // Basic CRUD functions
4955
- // TODO: Once all models are represented in `Created<TModel>`, use `Created` in `OptimisticModelResult`, so we don't
4956
- // have to repeat it for all optimistic model results (all optimistic results are created).
4957
- add(issue, workspaceId, issueType = null) {
4805
+ add(payload) {
4806
+ var _a2;
4958
4807
  const { store } = this.client;
4959
- const dateWithoutMilliseconds = /* @__PURE__ */ new Date();
4960
4808
  const state = store.getState();
4961
- const currentUserId = state.userReducer.currentUser.id;
4962
- dateWithoutMilliseconds.setMilliseconds(0);
4963
- if (!workspaceId) {
4964
- throw new Error("No active workspace ID while creating issue.");
4965
- }
4966
- const issuePayload = offline({
4967
- ...issue,
4968
- submitted_at: dateWithoutMilliseconds.toISOString(),
4969
- index_workspace: workspaceId,
4970
- created_by: currentUserId,
4971
- status: issue.status ?? DEFAULT_ISSUE_STATUS,
4972
- priority: issue.priority ?? DEFAULT_ISSUE_PRIORITY
4973
- });
4974
- this.dispatch(addIssue(issuePayload));
4975
- this.dispatch(addToRecentIssues(issuePayload.offline_id));
4809
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4810
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
4811
+ const offlineIssue = offline({
4812
+ ...payload,
4813
+ submitted_at: submittedAt,
4814
+ created_by: createdBy
4815
+ });
4816
+ this.dispatch(addIssue(offlineIssue));
4976
4817
  this.dispatch(addActiveProjectIssuesCount(1));
4977
4818
  const promise = this.enqueueRequest({
4978
4819
  description: "Create issue",
4979
4820
  method: HttpMethod.POST,
4980
4821
  url: "/issues/",
4981
4822
  queryParams: {
4982
- workspace_id: workspaceId,
4983
- ...issueType ? { issue_type: issueType } : {}
4823
+ workspace_id: payload.index_workspace,
4824
+ ...payload.issue_type ? { issue_type: payload.issue_type } : {}
4984
4825
  },
4985
- payload: issuePayload,
4986
- blockers: [
4987
- "add-issue",
4988
- ...issuePayload.index_workspace ? [issuePayload.index_workspace] : [],
4989
- ...issuePayload.visible_in_workspaces
4990
- ],
4991
- blocks: [issuePayload.offline_id]
4826
+ payload: offlineIssue,
4827
+ blockers: ["add-issue", ...offlineIssue.index_workspace ? [offlineIssue.index_workspace] : []],
4828
+ blocks: [offlineIssue.offline_id]
4992
4829
  });
4993
4830
  void promise.then((result) => {
4994
4831
  this.dispatch(updateIssue(result));
4995
4832
  }).catch((error) => {
4996
- var _a2;
4997
- console.error(error);
4998
- if (error instanceof APIError) {
4999
- (_a2 = unsafeShowToast) == null ? void 0 : _a2({
5000
- title: "Could not create issue",
5001
- description: error.message,
5002
- accentColor: "red"
5003
- });
5004
- }
5005
- this.dispatch(deleteIssue(issuePayload.offline_id));
4833
+ this.dispatch(deleteIssue(offlineIssue.offline_id));
5006
4834
  this.dispatch(addActiveProjectIssuesCount(-1));
5007
4835
  throw error;
5008
4836
  });
5009
- return [issuePayload, promise];
4837
+ return [offlineIssue, promise];
5010
4838
  }
5011
- update(issue) {
4839
+ update(payload) {
4840
+ var _a2;
5012
4841
  const state = this.client.store.getState();
5013
- const issueToBeUpdated = selectIssueById(issue.offline_id)(state);
4842
+ const issueToBeUpdated = selectIssueById(payload.offline_id)(state);
5014
4843
  if (!issueToBeUpdated) {
5015
4844
  throw new Error(
5016
- `Attempting to update an issue with offline_id ${issue.offline_id} that doesn't exist in the store`
4845
+ `Attempting to update an issue with offline_id ${payload.offline_id} that doesn't exist in the store`
5017
4846
  );
5018
4847
  }
5019
- const updatedIssue = { ...issueToBeUpdated, ...issue };
4848
+ const updatedIssue = { ...issueToBeUpdated, ...payload };
5020
4849
  this.dispatch(updateIssue(updatedIssue));
5021
4850
  const changes = {};
5022
4851
  for (const issueUpdateChange of [
@@ -5028,11 +4857,11 @@ class IssueService extends BaseApiService {
5028
4857
  IssueUpdateChange.ASSIGNED_TO,
5029
4858
  IssueUpdateChange.DUE_DATE
5030
4859
  ]) {
5031
- if (issueUpdateChange in issue && issue[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
4860
+ if (issueUpdateChange in payload && payload[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
5032
4861
  switch (issueUpdateChange) {
5033
4862
  case "category": {
5034
4863
  let categoryOrNull = null;
5035
- const categoryIdOrNull = issue[issueUpdateChange];
4864
+ const categoryIdOrNull = payload[issueUpdateChange];
5036
4865
  if (categoryIdOrNull) {
5037
4866
  categoryOrNull = state.categoryReducer.instances[categoryIdOrNull] ?? null;
5038
4867
  if (!categoryOrNull)
@@ -5049,7 +4878,7 @@ class IssueService extends BaseApiService {
5049
4878
  }
5050
4879
  case "assigned_to": {
5051
4880
  let userOrNull = null;
5052
- const userIdOrNull = issue[issueUpdateChange];
4881
+ const userIdOrNull = payload[issueUpdateChange];
5053
4882
  if (userIdOrNull) {
5054
4883
  userOrNull = state.userReducer.users[userIdOrNull] ?? null;
5055
4884
  if (!userOrNull)
@@ -5064,24 +4893,24 @@ class IssueService extends BaseApiService {
5064
4893
  break;
5065
4894
  }
5066
4895
  case "description":
5067
- changes[issueUpdateChange] = issue[issueUpdateChange] ?? null;
4896
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
5068
4897
  break;
5069
4898
  case "title":
5070
- changes[issueUpdateChange] = issue[issueUpdateChange] ?? null;
4899
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
5071
4900
  break;
5072
4901
  case "priority":
5073
- changes[issueUpdateChange] = issue[issueUpdateChange];
4902
+ changes[issueUpdateChange] = payload[issueUpdateChange];
5074
4903
  break;
5075
4904
  case "status":
5076
- changes[issueUpdateChange] = issue[issueUpdateChange];
4905
+ changes[issueUpdateChange] = payload[issueUpdateChange];
5077
4906
  break;
5078
4907
  case "due_date":
5079
- changes[issueUpdateChange] = issue[issueUpdateChange] ? issue[issueUpdateChange] : null;
4908
+ changes[issueUpdateChange] = payload[issueUpdateChange] ? payload[issueUpdateChange] : null;
5080
4909
  }
5081
4910
  }
5082
4911
  }
5083
4912
  const offlineIssueUpdate = offline({
5084
- created_by: state.userReducer.currentUser.id,
4913
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5085
4914
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5086
4915
  issue: issueToBeUpdated.offline_id,
5087
4916
  changes
@@ -5090,10 +4919,10 @@ class IssueService extends BaseApiService {
5090
4919
  const promise = this.enqueueRequest({
5091
4920
  description: "Edit issue",
5092
4921
  method: HttpMethod.PATCH,
5093
- url: `/issues/${issue.offline_id}/`,
5094
- payload: issue,
5095
- blockers: [issue.offline_id],
5096
- blocks: [issue.offline_id]
4922
+ url: `/issues/${payload.offline_id}/`,
4923
+ payload,
4924
+ blockers: [payload.offline_id],
4925
+ blocks: [payload.offline_id]
5097
4926
  });
5098
4927
  promise.catch(() => {
5099
4928
  this.dispatch(updateIssue(issueToBeUpdated));
@@ -5145,7 +4974,6 @@ class IssueService extends BaseApiService {
5145
4974
  throw e;
5146
4975
  }
5147
4976
  }
5148
- // Special functions
5149
4977
  async refreshStore(projectId) {
5150
4978
  const result = await this.enqueueRequest({
5151
4979
  description: "Get issues",
@@ -5153,33 +4981,24 @@ class IssueService extends BaseApiService {
5153
4981
  url: `/projects/${projectId}/issues/`,
5154
4982
  blockers: [],
5155
4983
  blocks: []
5156
- }).then((result2) => {
5157
- const filteredResult = result2.filter(onlyUniqueOfflineIds);
5158
- if (result2.length !== filteredResult.length) {
5159
- console.error(
5160
- `Received duplicate issues from the API (new length ${filteredResult.length});
5161
- filtered in browser.`
5162
- );
5163
- }
5164
- return filteredResult;
5165
4984
  });
5166
4985
  this.dispatch(initializeIssues(result));
5167
4986
  }
5168
4987
  }
5169
4988
  class IssueTypeService extends BaseApiService {
5170
- add(payload, organizationId) {
4989
+ add(payload) {
4990
+ var _a2;
5171
4991
  const { store } = this.client;
5172
4992
  const state = store.getState();
5173
4993
  const offlineIssueType = offline({
5174
4994
  ...payload,
5175
4995
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5176
- created_by: state.userReducer.currentUser.id,
5177
- organization: organizationId
4996
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id
5178
4997
  });
5179
4998
  this.dispatch(addIssueType(offlineIssueType));
5180
4999
  const promise = this.enqueueRequest({
5181
5000
  method: HttpMethod.POST,
5182
- url: `/organizations/${organizationId}/issue-types/`,
5001
+ url: `/organizations/${payload.organization}/issue-types/`,
5183
5002
  // Sending only whats needed here
5184
5003
  payload: {
5185
5004
  offline_id: offlineIssueType.offline_id,
@@ -5225,20 +5044,20 @@ class IssueTypeService extends BaseApiService {
5225
5044
  });
5226
5045
  return [offlineUpdatedIssueType, promise];
5227
5046
  }
5228
- delete(issueTypeId) {
5047
+ delete(id) {
5229
5048
  const { store } = this.client;
5230
5049
  const state = store.getState();
5231
- const issueTypeToDelete = selectIssueTypeById(issueTypeId)(state);
5050
+ const issueTypeToDelete = selectIssueTypeById(id)(state);
5232
5051
  if (!issueTypeToDelete) {
5233
- throw new Error(`IssueType with offline_id ${issueTypeId} does not exist in the store.`);
5052
+ throw new Error(`IssueType with offline_id ${id} does not exist in the store.`);
5234
5053
  }
5235
- const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(state);
5236
- this.dispatch(removeIssueType(issueTypeId));
5054
+ const issuesOfIssueType = selectIssuesOfIssueType(id)(state);
5055
+ this.dispatch(removeIssueType(id));
5237
5056
  this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
5238
5057
  const promise = this.enqueueRequest({
5239
5058
  method: HttpMethod.DELETE,
5240
- url: `/issues/types/${issueTypeId}/`,
5241
- blockers: [issueTypeId],
5059
+ url: `/issues/types/${id}/`,
5060
+ blockers: [id],
5242
5061
  blocks: []
5243
5062
  });
5244
5063
  promise.catch(() => {
@@ -5258,15 +5077,6 @@ class IssueTypeService extends BaseApiService {
5258
5077
  }
5259
5078
  }
5260
5079
  class ProjectAccessService extends BaseApiService {
5261
- async fetchAll(projectId) {
5262
- return this.enqueueRequest({
5263
- description: "Get project accesses",
5264
- method: HttpMethod.GET,
5265
- url: `/projects/${projectId}/access/`,
5266
- blockers: [],
5267
- blocks: []
5268
- });
5269
- }
5270
5080
  async update(projectAccess) {
5271
5081
  this.dispatch(updateProjectAccess(projectAccess));
5272
5082
  return this.enqueueRequest({
@@ -5279,34 +5089,28 @@ class ProjectAccessService extends BaseApiService {
5279
5089
  });
5280
5090
  }
5281
5091
  // TODO: Re-add user to project if removal fails
5282
- async remove(projectAccess) {
5283
- this.dispatch(deleteProjectAccess(projectAccess.offline_id));
5092
+ async remove(id) {
5093
+ this.dispatch(deleteProjectAccess(id));
5284
5094
  return this.enqueueRequest({
5285
5095
  description: "Delete project access",
5286
5096
  method: HttpMethod.DELETE,
5287
- url: `/access/${projectAccess.offline_id}/`,
5288
- blockers: [projectAccess.offline_id],
5097
+ url: `/access/${id}/`,
5098
+ blockers: [id],
5289
5099
  blocks: []
5290
5100
  });
5291
5101
  }
5292
- async refreshStore(projectId) {
5293
- const promise = this.fetchAll(projectId);
5294
- const result = await promise;
5295
- this.dispatch(initializeProjectAccesses(result));
5296
- }
5297
- }
5298
- class ProjectFileService extends BaseApiService {
5299
5102
  async refreshStore(projectId) {
5300
5103
  const result = await this.enqueueRequest({
5301
- description: "Get project files",
5104
+ description: "Get project accesses",
5302
5105
  method: HttpMethod.GET,
5303
- url: `/projects/${projectId}/files/`,
5106
+ url: `/projects/${projectId}/access/`,
5304
5107
  blockers: [],
5305
5108
  blocks: []
5306
5109
  });
5307
- this.dispatch(addOrReplaceProjectFiles([]));
5308
- this.dispatch(addOrReplaceProjectFiles(result));
5110
+ this.dispatch(initializeProjectAccesses(result));
5309
5111
  }
5112
+ }
5113
+ class ProjectFileService extends BaseApiService {
5310
5114
  async saveExisting(file) {
5311
5115
  if (!file.offline_id) {
5312
5116
  throw new Error(
@@ -5394,6 +5198,17 @@ class ProjectFileService extends BaseApiService {
5394
5198
  blocks: []
5395
5199
  });
5396
5200
  }
5201
+ async refreshStore(projectId) {
5202
+ const result = await this.enqueueRequest({
5203
+ description: "Get project files",
5204
+ method: HttpMethod.GET,
5205
+ url: `/projects/${projectId}/files/`,
5206
+ blockers: [],
5207
+ blocks: []
5208
+ });
5209
+ this.dispatch(addOrReplaceProjectFiles([]));
5210
+ this.dispatch(addOrReplaceProjectFiles(result));
5211
+ }
5397
5212
  }
5398
5213
  class ProjectAttachmentService extends BaseAttachmentService {
5399
5214
  constructor() {
@@ -5427,29 +5242,23 @@ class ProjectAttachmentService extends BaseAttachmentService {
5427
5242
  }
5428
5243
  }
5429
5244
  class ProjectService extends BaseApiService {
5430
- /**
5431
- * Creates a new project. Due to the nature of project creation,
5432
- * @param project A Payload<Project> object containing project attributes.
5433
- * @returns A promise that resolves to a Project.
5434
- * @throws An APIError if the server returns an error, or any other error that may occur.
5435
- */
5436
- async add(project) {
5437
- if (!project.organization_owner && !project.user_owner) {
5245
+ async add(payload) {
5246
+ if (!payload.organization_owner && !payload.user_owner) {
5438
5247
  throw new Error("Project type was not chosen when trying to create a project");
5439
5248
  }
5440
- if (!project.bounds && !project.canvas_bounds) {
5249
+ if (!payload.bounds && !payload.canvas_bounds) {
5441
5250
  throw new Error("Project must either have bounds or canvas_bounds set");
5442
5251
  }
5443
- const isOrganizationProject = !!project.organization_owner;
5444
- const url = isOrganizationProject ? `/organizations/${project.organization_owner}/projects/` : "/projects/";
5445
- const projectType = isOrganizationProject ? { organization_owner: project.organization_owner } : { user_owner: project.user_owner };
5252
+ const isOrganizationProject = !!payload.organization_owner;
5253
+ const url = isOrganizationProject ? `/organizations/${payload.organization_owner}/projects/` : "/projects/";
5254
+ const projectType = isOrganizationProject ? { organization_owner: payload.organization_owner } : { user_owner: payload.user_owner };
5446
5255
  return await this.enqueueRequest({
5447
5256
  description: "Create project",
5448
5257
  method: HttpMethod.POST,
5449
5258
  url,
5450
5259
  payload: {
5451
- name: project.name,
5452
- bounds: project.bounds,
5260
+ name: payload.name,
5261
+ bounds: payload.bounds,
5453
5262
  ...projectType
5454
5263
  },
5455
5264
  blockers: [],
@@ -5579,8 +5388,9 @@ const separateImageFromFields = async (fields) => {
5579
5388
  };
5580
5389
  class FormService extends BaseUploadService {
5581
5390
  async bulkAddRevisionAttachments(revisionId, files) {
5391
+ var _a2;
5582
5392
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5583
- const createdBy = this.client.store.getState().userReducer.currentUser.id;
5393
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5584
5394
  const filePayloads = {};
5585
5395
  const offlineFormRevisionAttachments = [];
5586
5396
  const attachmentPayloads = [];
@@ -5682,10 +5492,11 @@ class FormService extends BaseUploadService {
5682
5492
  return [form, offlineFormRevision, offlineFormRevisionAttachments, formPromise, attachmentsPromise];
5683
5493
  }
5684
5494
  addForOrganization(organizationId, initialRevision) {
5495
+ var _a2;
5685
5496
  const state = this.client.store.getState();
5686
5497
  const offlineForm = offline({
5687
5498
  favorite: false,
5688
- created_by: state.userReducer.currentUser.id,
5499
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5689
5500
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5690
5501
  organization: organizationId
5691
5502
  });
@@ -5697,45 +5508,49 @@ class FormService extends BaseUploadService {
5697
5508
  );
5698
5509
  }
5699
5510
  addForProject(projectId, initialRevision) {
5511
+ var _a2;
5700
5512
  const state = this.client.store.getState();
5701
5513
  const offlineForm = offline({
5702
5514
  favorite: false,
5703
- created_by: state.userReducer.currentUser.id,
5515
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5704
5516
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5705
5517
  project: projectId
5706
5518
  });
5707
5519
  return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
5708
5520
  }
5709
5521
  addForIssueType(issueTypeId, initialRevision) {
5522
+ var _a2;
5710
5523
  const state = this.client.store.getState();
5711
5524
  const offlineForm = offline({
5712
5525
  favorite: false,
5713
- created_by: state.userReducer.currentUser.id,
5526
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5714
5527
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5715
5528
  issue_type: issueTypeId
5716
5529
  });
5717
5530
  return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
5718
5531
  }
5719
5532
  addForAssetType(assetTypeId, initialRevision) {
5533
+ var _a2;
5720
5534
  const state = this.client.store.getState();
5721
5535
  const offlineForm = offline({
5722
5536
  favorite: false,
5723
- created_by: state.userReducer.currentUser.id,
5537
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5724
5538
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5725
5539
  asset_type: assetTypeId
5726
5540
  });
5727
5541
  return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
5728
5542
  }
5729
5543
  async createRevision(formId, revision) {
5544
+ var _a2;
5730
5545
  const offlineRevision = offline(revision);
5731
5546
  const { store } = this.client;
5732
5547
  const state = store.getState();
5733
- const currentUserId = state.userReducer.currentUser.id;
5548
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
5734
5549
  const { fields, images } = await separateImageFromFields(offlineRevision.fields);
5735
5550
  const fullRevision = {
5736
5551
  ...offlineRevision,
5737
5552
  fields,
5738
- created_by: currentUserId,
5553
+ created_by: createdBy,
5739
5554
  revision: "Pending",
5740
5555
  form: formId,
5741
5556
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -5768,48 +5583,6 @@ class FormService extends BaseUploadService {
5768
5583
  });
5769
5584
  return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
5770
5585
  }
5771
- async favorite(formId, projectId) {
5772
- const { store } = this.client;
5773
- const state = store.getState();
5774
- const form = state.formReducer.instances[formId];
5775
- if (!form) {
5776
- throw new Error(`Expected form to exist, got ${form}`);
5777
- }
5778
- this.dispatch(updateForm({ ...form, favorite: true }));
5779
- try {
5780
- await this.enqueueRequest({
5781
- description: "Favorite form",
5782
- method: HttpMethod.POST,
5783
- url: `/forms/${formId}/favorite/${projectId}/`,
5784
- blockers: [formId, `favorite-${formId}`],
5785
- blocks: [`favorite-${formId}`]
5786
- });
5787
- } catch (e) {
5788
- this.dispatch(updateForm(form));
5789
- throw e;
5790
- }
5791
- }
5792
- async unfavorite(formId, projectId) {
5793
- const { store } = this.client;
5794
- const state = store.getState();
5795
- const form = state.formReducer.instances[formId];
5796
- if (!form) {
5797
- throw new Error(`Expected form to exist, got ${form}`);
5798
- }
5799
- this.dispatch(updateForm({ ...form, favorite: false }));
5800
- try {
5801
- return await this.enqueueRequest({
5802
- description: "Unfavorite form",
5803
- method: HttpMethod.DELETE,
5804
- url: `/forms/${formId}/unfavorite/${projectId}/`,
5805
- blockers: [formId, `favorite-${formId}`],
5806
- blocks: [`favorite-${formId}`]
5807
- });
5808
- } catch (e) {
5809
- this.dispatch(updateForm(form));
5810
- throw e;
5811
- }
5812
- }
5813
5586
  async delete(formId) {
5814
5587
  const { store } = this.client;
5815
5588
  const state = store.getState();
@@ -5926,8 +5699,9 @@ const separateFilesFromValues = (values) => {
5926
5699
  };
5927
5700
  class FormSubmissionService extends BaseUploadService {
5928
5701
  async bulkAddSubmissionAttachments(submissionId, files) {
5702
+ var _a2;
5929
5703
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5930
- const createdBy = this.client.store.getState().userReducer.currentUser.id;
5704
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5931
5705
  const filePayloads = {};
5932
5706
  const offlineFormSubmissionAttachments = [];
5933
5707
  const attachmentPayloads = [];
@@ -6009,13 +5783,14 @@ class FormSubmissionService extends BaseUploadService {
6009
5783
  }
6010
5784
  // Outer promise is for hashing and caching files for submission attachments
6011
5785
  async add(payload) {
5786
+ var _a2;
6012
5787
  const { store } = this.client;
6013
5788
  const state = store.getState();
6014
5789
  const { values, files } = separateFilesFromValues(payload.values);
6015
5790
  const offlineSubmission = offline({
6016
5791
  ...payload,
6017
5792
  values,
6018
- created_by: state.userReducer.currentUser.id,
5793
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
6019
5794
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
6020
5795
  });
6021
5796
  const promise = this.enqueueRequest({
@@ -6164,7 +5939,7 @@ class FormSubmissionService extends BaseUploadService {
6164
5939
  description: "Delete user form submissions",
6165
5940
  method: HttpMethod.PATCH,
6166
5941
  url: `/forms/submissions/${updatedSubmission.offline_id}/`,
6167
- payload: updatedSubmission,
5942
+ payload,
6168
5943
  blockers: [updatedSubmission.offline_id],
6169
5944
  blocks: [updatedSubmission.offline_id]
6170
5945
  });
@@ -6270,13 +6045,20 @@ class FormSubmissionService extends BaseUploadService {
6270
6045
  }
6271
6046
  }
6272
6047
  class WorkspaceService extends BaseApiService {
6273
- add(workspace) {
6274
- const offlineWorkspace = offline(workspace);
6048
+ add(payload) {
6049
+ var _a2;
6050
+ const { store } = this.client;
6051
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6052
+ const offlineWorkspace = offline({
6053
+ ...payload,
6054
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6055
+ created_by: createdBy
6056
+ });
6275
6057
  this.dispatch(addWorkspace(offlineWorkspace));
6276
6058
  const promise = this.enqueueRequest({
6277
6059
  description: "Create Workspace",
6278
6060
  method: HttpMethod.POST,
6279
- url: `/projects/${workspace.project}/workspaces/`,
6061
+ url: `/projects/${payload.project}/workspaces/`,
6280
6062
  payload: offlineWorkspace,
6281
6063
  blockers: ["add-workspace"],
6282
6064
  blocks: [offlineWorkspace.offline_id]
@@ -6288,20 +6070,33 @@ class WorkspaceService extends BaseApiService {
6288
6070
  });
6289
6071
  return [offlineWorkspace, promise];
6290
6072
  }
6291
- update(workspace) {
6292
- this.dispatch(addWorkspace(workspace));
6073
+ update(payload) {
6074
+ const { store } = this.client;
6075
+ const workspace = selectWorkspaceById(payload.offline_id)(store.getState());
6076
+ if (!workspace) {
6077
+ throw new Error(`Expected an existing workspace with offline_id ${payload.offline_id}`);
6078
+ }
6079
+ const updatedWorkspace = { ...workspace, ...payload };
6080
+ this.dispatch(updateWorkspace(updatedWorkspace));
6293
6081
  const promise = this.enqueueRequest({
6294
6082
  description: "Update Workspace",
6295
6083
  method: HttpMethod.PATCH,
6296
6084
  url: `/workspaces/${workspace.offline_id}/`,
6297
- payload: workspace,
6085
+ payload,
6298
6086
  blockers: [workspace.offline_id],
6299
6087
  blocks: [workspace.offline_id]
6300
6088
  });
6089
+ promise.then((result) => {
6090
+ this.dispatch(updateWorkspace(result));
6091
+ }).catch(() => {
6092
+ this.dispatch(updateWorkspace(workspace));
6093
+ });
6301
6094
  return [workspace, promise];
6302
6095
  }
6303
6096
  delete(workspaceId) {
6304
6097
  const { store } = this.client;
6098
+ const originalWorkspace = selectWorkspaceById(workspaceId)(store.getState());
6099
+ this.dispatch(deleteWorkspace(workspaceId));
6305
6100
  const promise = this.enqueueRequest({
6306
6101
  description: "Delete Workspace",
6307
6102
  method: HttpMethod.DELETE,
@@ -6309,8 +6104,6 @@ class WorkspaceService extends BaseApiService {
6309
6104
  blockers: [workspaceId],
6310
6105
  blocks: []
6311
6106
  });
6312
- const originalWorkspace = store.getState().workspaceReducer.instances[workspaceId];
6313
- this.dispatch(deleteWorkspace(workspaceId));
6314
6107
  void promise.then(() => {
6315
6108
  }).catch((reason) => {
6316
6109
  if (originalWorkspace) {
@@ -6812,12 +6605,13 @@ class LicenseService extends BaseApiService {
6812
6605
  }
6813
6606
  class DocumentService extends BaseApiService {
6814
6607
  add(payload) {
6608
+ var _a2;
6815
6609
  const { store } = this.client;
6816
- const currentUserId = store.getState().userReducer.currentUser.id;
6610
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6817
6611
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6818
6612
  const offlineDocument = offline({
6819
6613
  ...payload,
6820
- created_by: currentUserId,
6614
+ created_by: createdBy,
6821
6615
  submitted_at: submittedAt
6822
6616
  });
6823
6617
  this.dispatch(addDocuments([offlineDocument]));
@@ -6838,28 +6632,31 @@ class DocumentService extends BaseApiService {
6838
6632
  });
6839
6633
  return [offlineDocument, promise];
6840
6634
  }
6841
- update(document2) {
6635
+ update(payload) {
6842
6636
  const { store } = this.client;
6843
- const documentToBeUpdated = store.getState().documentsReducer.documents[document2.offline_id];
6637
+ const documentToBeUpdated = store.getState().documentsReducer.documents[payload.offline_id];
6844
6638
  if (!documentToBeUpdated) {
6845
6639
  throw new Error(
6846
- `attempting to update a document with offline_id ${document2.offline_id} that does not exist in store.documents`
6640
+ `attempting to update a document with offline_id ${payload.offline_id} that does not exist in store.documents`
6847
6641
  );
6848
6642
  }
6849
- this.dispatch(updateDocuments([document2]));
6643
+ const updatedDocument = {
6644
+ ...documentToBeUpdated,
6645
+ ...payload
6646
+ };
6647
+ this.dispatch(updateDocuments([updatedDocument]));
6850
6648
  const promise = this.enqueueRequest({
6851
6649
  description: "Update Document",
6852
6650
  method: HttpMethod.PATCH,
6853
- url: `/documents/${document2.offline_id}/`,
6854
- payload: document2,
6855
- blockers: [document2.offline_id],
6856
- blocks: [document2.offline_id]
6651
+ url: `/documents/${payload.offline_id}/`,
6652
+ payload,
6653
+ blockers: [payload.offline_id],
6654
+ blocks: [payload.offline_id]
6857
6655
  });
6858
6656
  promise.catch(() => {
6859
6657
  updateDocuments([documentToBeUpdated]);
6860
6658
  });
6861
- const fullDocument = store.getState().documentsReducer.documents[document2.offline_id];
6862
- return [fullDocument, promise];
6659
+ return [updatedDocument, promise];
6863
6660
  }
6864
6661
  move(documentId, targetDocumentId, position) {
6865
6662
  const { store } = this.client;
@@ -6906,22 +6703,22 @@ class DocumentService extends BaseApiService {
6906
6703
  });
6907
6704
  return promise;
6908
6705
  }
6909
- delete(documentId) {
6706
+ delete(id) {
6910
6707
  const { store } = this.client;
6911
6708
  const documentsMapping = selectDocumentsMapping(store.getState());
6912
- const documentToBeDeleted = documentsMapping[documentId];
6709
+ const documentToBeDeleted = selectDocumentById(id)(store.getState());
6913
6710
  if (!documentToBeDeleted) {
6914
6711
  throw new Error(
6915
- `attempting to delete a document with offline_id ${documentId} that does not exist in store.documents`
6712
+ `attempting to delete a document with offline_id ${id} that does not exist in store.documents`
6916
6713
  );
6917
6714
  }
6918
6715
  const parentDocument = documentToBeDeleted.parent_document ? documentsMapping[documentToBeDeleted.parent_document] : void 0;
6919
- this.dispatch(removeDocuments([documentId]));
6716
+ this.dispatch(removeDocuments([id]));
6920
6717
  const promise = this.enqueueRequest({
6921
6718
  description: "Delete Document",
6922
6719
  method: HttpMethod.DELETE,
6923
- url: `/documents/${documentId}/`,
6924
- blockers: [documentId],
6720
+ url: `/documents/${id}/`,
6721
+ blockers: [id],
6925
6722
  blocks: []
6926
6723
  });
6927
6724
  promise.then((documentsToUpdate) => {
@@ -6979,8 +6776,9 @@ class DocumentAttachmentService extends BaseAttachmentService {
6979
6776
  }
6980
6777
  // NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
6981
6778
  async attachFilesToDocument(files, documentId) {
6779
+ var _a2;
6982
6780
  const { store } = this.client;
6983
- const currentUser = store.getState().userReducer.currentUser;
6781
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6984
6782
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6985
6783
  const offlineAttachments = [];
6986
6784
  const attachmentPayloads = [];
@@ -7002,7 +6800,7 @@ class DocumentAttachmentService extends BaseAttachmentService {
7002
6800
  file,
7003
6801
  sha1,
7004
6802
  submittedAt,
7005
- createdBy: currentUser.id,
6803
+ createdBy,
7006
6804
  description: "",
7007
6805
  modelId: documentId
7008
6806
  });
@@ -7117,19 +6915,7 @@ class AgentService extends BaseApiService {
7117
6915
  blocks: ["prompt"],
7118
6916
  queryParams: { conversation_id: conversationId }
7119
6917
  }).then((response) => {
7120
- const conversation = store.getState().agentsReducer.instances[conversationId];
7121
- if (!(conversation == null ? void 0 : conversation.offline_id)) {
7122
- throw new Error("Conversation not found");
7123
- }
7124
- if (!Array.isArray(response)) {
7125
- response = [response];
7126
- }
7127
- this.dispatch(
7128
- updateConversation({
7129
- ...conversation,
7130
- tiptap_content: [...conversation.tiptap_content || [], ...response]
7131
- })
7132
- );
6918
+ this.dispatch(updateConversation(response));
7133
6919
  });
7134
6920
  }
7135
6921
  async fetchDetails(conversationId) {
@@ -7165,10 +6951,9 @@ class AgentService extends BaseApiService {
7165
6951
  }
7166
6952
  }
7167
6953
  class TeamService extends BaseApiService {
7168
- add(teamPayload, organizationId) {
6954
+ add(payload) {
7169
6955
  const offlineTeam = offline({
7170
- ...teamPayload,
7171
- organization: organizationId,
6956
+ ...payload,
7172
6957
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7173
6958
  // TODO: uncomment once supported
7174
6959
  // created_by: state.userReducer.currentUser.id,
@@ -7177,7 +6962,7 @@ class TeamService extends BaseApiService {
7177
6962
  const promise = this.enqueueRequest({
7178
6963
  description: "Create team",
7179
6964
  method: HttpMethod.POST,
7180
- url: `/organizations/${organizationId}/teams/`,
6965
+ url: `/organizations/${payload.organization}/teams/`,
7181
6966
  payload: offlineTeam,
7182
6967
  // No blocks since users and organizations are not offline
7183
6968
  blockers: [],
@@ -7190,25 +6975,24 @@ class TeamService extends BaseApiService {
7190
6975
  });
7191
6976
  return [offlineTeam, promise];
7192
6977
  }
7193
- // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
7194
- update(team) {
6978
+ update(payload) {
7195
6979
  const { store } = this.client;
7196
- const teamToBeUpdated = selectTeamById(team.offline_id)(store.getState());
6980
+ const teamToBeUpdated = selectTeamById(payload.offline_id)(store.getState());
7197
6981
  if (!teamToBeUpdated) {
7198
- throw new Error(`Expected team with offline_id ${team.offline_id} to exist`);
6982
+ throw new Error(`Expected team with offline_id ${payload.offline_id} to exist`);
7199
6983
  }
7200
6984
  const offlineUpdatedTeam = {
7201
6985
  ...teamToBeUpdated,
7202
- ...team
6986
+ ...payload
7203
6987
  };
7204
6988
  this.dispatch(updateTeam(offlineUpdatedTeam));
7205
6989
  const promise = this.enqueueRequest({
7206
6990
  description: "Update team",
7207
6991
  method: HttpMethod.PATCH,
7208
- url: `/organizations/teams/${team.offline_id}/`,
7209
- payload: offlineUpdatedTeam,
7210
- blockers: [team.offline_id],
7211
- blocks: [team.offline_id]
6992
+ url: `/organizations/teams/${payload.offline_id}/`,
6993
+ payload,
6994
+ blockers: [payload.offline_id],
6995
+ blocks: [payload.offline_id]
7212
6996
  });
7213
6997
  promise.then((updatedTeam) => {
7214
6998
  this.dispatch(setTeam(updatedTeam));
@@ -7320,10 +7104,11 @@ class UserService extends BaseApiService {
7320
7104
  }
7321
7105
  class GeoImageService extends BaseUploadService {
7322
7106
  async add(payload) {
7107
+ var _a2;
7323
7108
  const { store } = this.client;
7324
7109
  const { file, ...payloadWithoutFile } = payload;
7325
7110
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7326
- const currentUser = store.getState().userReducer.currentUser;
7111
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7327
7112
  const projectId = payloadWithoutFile.project;
7328
7113
  const sha1 = await hashFile(file);
7329
7114
  const filePayload = {
@@ -7338,9 +7123,9 @@ class GeoImageService extends BaseUploadService {
7338
7123
  file_sha1: sha1,
7339
7124
  file: URL.createObjectURL(file),
7340
7125
  submitted_at: submittedAt,
7341
- created_by: currentUser.id
7126
+ created_by: createdBy
7342
7127
  });
7343
- store.dispatch(addGeoImage(offlineMapImage));
7128
+ this.dispatch(addGeoImage(offlineMapImage));
7344
7129
  const promise = this.enqueueRequest({
7345
7130
  description: "Add geo image",
7346
7131
  method: HttpMethod.POST,
@@ -7364,16 +7149,17 @@ class GeoImageService extends BaseUploadService {
7364
7149
  });
7365
7150
  promise.then((result) => {
7366
7151
  this.processPresignedUrls(result.presigned_urls);
7367
- store.dispatch(setGeoImage(result.geo_image));
7152
+ this.dispatch(setGeoImage(result.geo_image));
7368
7153
  }).catch(() => {
7369
- store.dispatch(deleteGeoImage(offlineMapImage.offline_id));
7154
+ this.dispatch(deleteGeoImage(offlineMapImage.offline_id));
7370
7155
  });
7371
7156
  return [offlineMapImage, promise.then((result) => result.geo_image)];
7372
7157
  }
7373
7158
  async bulkAdd(payloads, projectId) {
7159
+ var _a2;
7374
7160
  const { store } = this.client;
7375
7161
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7376
- const currentUser = store.getState().userReducer.currentUser;
7162
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7377
7163
  const offlineGeoImages = [];
7378
7164
  const offlineIds = [];
7379
7165
  const geoImagePayloads = [];
@@ -7396,7 +7182,7 @@ class GeoImageService extends BaseUploadService {
7396
7182
  file_sha1: sha1,
7397
7183
  file: URL.createObjectURL(file),
7398
7184
  submitted_at: submittedAt,
7399
- created_by: currentUser.id,
7185
+ created_by: createdBy,
7400
7186
  project: projectId
7401
7187
  });
7402
7188
  offlineGeoImages.push(offlineMapImage);
@@ -7413,7 +7199,7 @@ class GeoImageService extends BaseUploadService {
7413
7199
  original_date: offlineMapImage.original_date
7414
7200
  });
7415
7201
  }
7416
- store.dispatch(addGeoImages(offlineGeoImages));
7202
+ this.dispatch(addGeoImages(offlineGeoImages));
7417
7203
  const promise = this.enqueueRequest({
7418
7204
  description: "Bulk add geo images",
7419
7205
  method: HttpMethod.POST,
@@ -7429,9 +7215,9 @@ class GeoImageService extends BaseUploadService {
7429
7215
  });
7430
7216
  promise.then((result) => {
7431
7217
  this.processPresignedUrls(result.presigned_urls);
7432
- store.dispatch(setGeoImages(result.geo_images));
7218
+ this.dispatch(setGeoImages(result.geo_images));
7433
7219
  }).catch(() => {
7434
- store.dispatch(deleteGeoImages(offlineIds));
7220
+ this.dispatch(deleteGeoImages(offlineIds));
7435
7221
  });
7436
7222
  return [offlineGeoImages, promise.then((result) => result.geo_images)];
7437
7223
  }
@@ -7443,7 +7229,7 @@ class GeoImageService extends BaseUploadService {
7443
7229
  throw new Error(`Map image with offline_id ${payload.offline_id} does not exist in the store`);
7444
7230
  }
7445
7231
  const updatedGeoImage = { ...geoImageToUpdate, ...payload };
7446
- store.dispatch(updateGeoImage(updatedGeoImage));
7232
+ this.dispatch(updateGeoImage(updatedGeoImage));
7447
7233
  const promise = this.enqueueRequest({
7448
7234
  description: "Update geo image",
7449
7235
  method: HttpMethod.PATCH,
@@ -7453,9 +7239,9 @@ class GeoImageService extends BaseUploadService {
7453
7239
  blockers: [payload.offline_id]
7454
7240
  });
7455
7241
  promise.then((result) => {
7456
- store.dispatch(setGeoImage(result));
7242
+ this.dispatch(setGeoImage(result));
7457
7243
  }).catch(() => {
7458
- store.dispatch(setGeoImage(geoImageToUpdate));
7244
+ this.dispatch(setGeoImage(geoImageToUpdate));
7459
7245
  });
7460
7246
  return [updatedGeoImage, promise];
7461
7247
  }
@@ -7466,7 +7252,7 @@ class GeoImageService extends BaseUploadService {
7466
7252
  if (!geoImageToDelete) {
7467
7253
  throw new Error(`Map image with offline_id ${geoImageId} does not exist in the store`);
7468
7254
  }
7469
- store.dispatch(deleteGeoImage(geoImageId));
7255
+ this.dispatch(deleteGeoImage(geoImageId));
7470
7256
  const promise = this.enqueueRequest({
7471
7257
  description: "Delete geo image",
7472
7258
  method: HttpMethod.DELETE,
@@ -7475,12 +7261,11 @@ class GeoImageService extends BaseUploadService {
7475
7261
  blockers: [geoImageId]
7476
7262
  });
7477
7263
  promise.catch(() => {
7478
- store.dispatch(setGeoImage(geoImageToDelete));
7264
+ this.dispatch(setGeoImage(geoImageToDelete));
7479
7265
  });
7480
7266
  return promise;
7481
7267
  }
7482
7268
  async refreshStore(projectId) {
7483
- const { store } = this.client;
7484
7269
  const result = await this.enqueueRequest({
7485
7270
  description: "Get geo images",
7486
7271
  method: HttpMethod.GET,
@@ -7488,14 +7273,15 @@ class GeoImageService extends BaseUploadService {
7488
7273
  blocks: [projectId.toString()],
7489
7274
  blockers: []
7490
7275
  });
7491
- store.dispatch(initializeGeoImages(result));
7276
+ this.dispatch(initializeGeoImages(result));
7492
7277
  }
7493
7278
  }
7494
7279
  class IssueAssociationService extends BaseUploadService {
7495
7280
  add(payload) {
7281
+ var _a2;
7496
7282
  const { store } = this.client;
7497
7283
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7498
- const createdBy = store.getState().userReducer.currentUser.id;
7284
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7499
7285
  const offlineIssueAssociation = offline({
7500
7286
  ...payload,
7501
7287
  submitted_at: submittedAt,
@@ -7509,7 +7295,6 @@ class IssueAssociationService extends BaseUploadService {
7509
7295
  payload: {
7510
7296
  offline_id: offlineIssueAssociation.offline_id,
7511
7297
  submitted_at: submittedAt,
7512
- created_by: createdBy,
7513
7298
  ...payload
7514
7299
  },
7515
7300
  blockers: [
@@ -7557,12 +7342,20 @@ class IssueAssociationService extends BaseUploadService {
7557
7342
  this.dispatch(initializeIssueAssociations(issueAssociations));
7558
7343
  }
7559
7344
  }
7345
+ var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
7346
+ VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
7347
+ VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
7348
+ VerificationCodeType2[VerificationCodeType2["PROJECT_INVITE"] = 4] = "PROJECT_INVITE";
7349
+ VerificationCodeType2[VerificationCodeType2["ORGANIZATION_INVITE"] = 6] = "ORGANIZATION_INVITE";
7350
+ VerificationCodeType2[VerificationCodeType2["ADD_EMAIL_DOMAIN"] = 8] = "ADD_EMAIL_DOMAIN";
7351
+ VerificationCodeType2[VerificationCodeType2["RESET_PASSWORD"] = 10] = "RESET_PASSWORD";
7352
+ return VerificationCodeType2;
7353
+ })(VerificationCodeType || {});
7560
7354
  export {
7561
7355
  APIError,
7562
7356
  AgentService,
7563
7357
  AssetAttachmentService,
7564
7358
  AssetService,
7565
- AssetStageColors,
7566
7359
  AssetStageCompletionService,
7567
7360
  AssetStageService,
7568
7361
  AssetTypeAttachmentService,
@@ -7624,9 +7417,14 @@ export {
7624
7417
  addAsset,
7625
7418
  addAssetAttachment,
7626
7419
  addAssetAttachments,
7420
+ addAssetStage,
7421
+ addAssetStageCompletion,
7422
+ addAssetStageCompletions,
7423
+ addAssetStages,
7627
7424
  addAssetType,
7628
7425
  addAssetTypeAttachment,
7629
7426
  addAssetTypeAttachments,
7427
+ addAssetTypes,
7630
7428
  addAssets,
7631
7429
  addCategory,
7632
7430
  addConversation,
@@ -7634,7 +7432,6 @@ export {
7634
7432
  addDocumentAttachments,
7635
7433
  addDocuments,
7636
7434
  addEmailDomain,
7637
- addFavouriteProjectId,
7638
7435
  addForm,
7639
7436
  addFormRevision,
7640
7437
  addFormRevisionAttachment,
@@ -7664,11 +7461,7 @@ export {
7664
7461
  addOrReplaceProjects,
7665
7462
  addProjectAttachment,
7666
7463
  addProjectAttachments,
7667
- addStageCompletion,
7668
- addStageCompletions,
7669
- addStages,
7670
7464
  addTeam,
7671
- addToRecentIssues,
7672
7465
  addUsers,
7673
7466
  addWorkspace,
7674
7467
  agentsReducer,
@@ -7692,8 +7485,6 @@ export {
7692
7485
  boundsContainPoint,
7693
7486
  categoryReducer,
7694
7487
  categorySlice,
7695
- classNames,
7696
- cleanRecentIssues,
7697
7488
  clearTokens,
7698
7489
  constructUploadedFilePayloads,
7699
7490
  coordinatesAreEqual,
@@ -7707,9 +7498,14 @@ export {
7707
7498
  deleteAsset,
7708
7499
  deleteAssetAttachment,
7709
7500
  deleteAssetAttachments,
7501
+ deleteAssetStage,
7502
+ deleteAssetStageCompletion,
7503
+ deleteAssetStageCompletions,
7504
+ deleteAssetStages,
7710
7505
  deleteAssetType,
7711
7506
  deleteAssetTypeAttachment,
7712
7507
  deleteAssetTypeAttachments,
7508
+ deleteAssetTypes,
7713
7509
  deleteAssets,
7714
7510
  deleteCategory,
7715
7511
  deleteDocumentAttachment,
@@ -7774,9 +7570,7 @@ export {
7774
7570
  formSubmissionAttachmentSlice,
7775
7571
  formSubmissionReducer,
7776
7572
  formSubmissionSlice,
7777
- fullAssetMarkerSize,
7778
7573
  generateBadgeColors,
7779
- genericMemo,
7780
7574
  geoImageReducer,
7781
7575
  geoImageSlice,
7782
7576
  getFileIdentifier,
@@ -7785,10 +7579,11 @@ export {
7785
7579
  getLocalRelativeDateString,
7786
7580
  getOutboxCoordinator,
7787
7581
  getRenamedFile,
7788
- getStageColor,
7789
7582
  hashFile,
7790
7583
  initSDK,
7791
7584
  initializeAssetAttachments,
7585
+ initializeAssetStageCompletions,
7586
+ initializeAssetStages,
7792
7587
  initializeAssetTypeAttachments,
7793
7588
  initializeAssetTypes,
7794
7589
  initializeAssets,
@@ -7811,7 +7606,6 @@ export {
7811
7606
  initializeOrganizationAccesses,
7812
7607
  initializeProjectAccesses,
7813
7608
  initializeProjectAttachments,
7814
- initializeStages,
7815
7609
  initializeTeams,
7816
7610
  initializeWorkspaces,
7817
7611
  isToday,
@@ -7823,7 +7617,6 @@ export {
7823
7617
  issueCommentSlice,
7824
7618
  issueReducer,
7825
7619
  issueSlice,
7826
- issueToSearchResult,
7827
7620
  issueTypeReducer,
7828
7621
  issueTypeSlice,
7829
7622
  issueUpdateReducer,
@@ -7864,20 +7657,14 @@ export {
7864
7657
  rehydratedReducer,
7865
7658
  rehydratedSlice,
7866
7659
  removeDocuments,
7867
- removeFavouriteProjectId,
7868
7660
  removeIssueType,
7869
7661
  removeProjectFile,
7870
7662
  removeProjectFilesOfProject,
7871
- removeRecentIssue,
7872
- removeStageCompletions,
7873
- removeStages,
7874
7663
  removeUser,
7875
7664
  resetProjectFileObjectUrls,
7876
- resetRecentIssues,
7877
7665
  resetStore,
7878
7666
  restructureCreateSelectorWithArgs,
7879
7667
  saveActiveProjectFileBounds,
7880
- searchIssues,
7881
7668
  selectAccessToken,
7882
7669
  selectActiveOrganizationAccess,
7883
7670
  selectActiveProject,
@@ -7893,6 +7680,9 @@ export {
7893
7680
  selectAssetAttachments,
7894
7681
  selectAssetById,
7895
7682
  selectAssetStageById,
7683
+ selectAssetStageCompletionById,
7684
+ selectAssetStageCompletionMapping,
7685
+ selectAssetStageCompletionsByIds,
7896
7686
  selectAssetStages,
7897
7687
  selectAssetStagesByIds,
7898
7688
  selectAssetTypeAttachmentById,
@@ -7928,7 +7718,7 @@ export {
7928
7718
  selectCategoryMapping,
7929
7719
  selectCommentsOfIssue,
7930
7720
  selectCompletedStageIdsForAsset,
7931
- selectCompletedStages,
7721
+ selectCompletedStagesByAsset,
7932
7722
  selectConversation,
7933
7723
  selectConversationMapping,
7934
7724
  selectConversations,
@@ -7943,7 +7733,6 @@ export {
7943
7733
  selectEmailDomains,
7944
7734
  selectEmailDomainsAsMapping,
7945
7735
  selectEmailDomainsOfOrganization,
7946
- selectFavouriteProjects,
7947
7736
  selectFilteredForms,
7948
7737
  selectFormById,
7949
7738
  selectFormMapping,
@@ -7984,6 +7773,7 @@ export {
7984
7773
  selectIssueAttachmentMapping,
7985
7774
  selectIssueAttachments,
7986
7775
  selectIssueById,
7776
+ selectIssueCommentById,
7987
7777
  selectIssueCommentMapping,
7988
7778
  selectIssueCountOfCategory,
7989
7779
  selectIssueMapping,
@@ -8033,8 +7823,6 @@ export {
8033
7823
  selectProjectUsersAsMapping,
8034
7824
  selectProjectUsersIds,
8035
7825
  selectProjectsOfOrganization,
8036
- selectRecentIssueIds,
8037
- selectRecentIssuesAsSearchResults,
8038
7826
  selectRehydrated,
8039
7827
  selectRootDocuments,
8040
7828
  selectSortedFormSubmissionsOfForm,
@@ -8042,7 +7830,6 @@ export {
8042
7830
  selectSortedProjectUsers,
8043
7831
  selectStageFormIdsFromStageIds,
8044
7832
  selectStageMapping,
8045
- selectStagesFromAssetTypeIds,
8046
7833
  selectStagesOfAssetType,
8047
7834
  selectTeamById,
8048
7835
  selectTeams,
@@ -8062,8 +7849,12 @@ export {
8062
7849
  setAsset,
8063
7850
  setAssetAttachment,
8064
7851
  setAssetAttachments,
7852
+ setAssetStage,
7853
+ setAssetStages,
7854
+ setAssetType,
8065
7855
  setAssetTypeAttachment,
8066
7856
  setAssetTypeAttachments,
7857
+ setAssetTypes,
8067
7858
  setAssets,
8068
7859
  setConversation,
8069
7860
  setCurrentUser,
@@ -8096,11 +7887,8 @@ export {
8096
7887
  setProjectAttachments,
8097
7888
  setProjects,
8098
7889
  setRehydrated,
8099
- setStage,
8100
- setStageCompletions,
8101
7890
  setTeam,
8102
7891
  setTokens,
8103
- setTourStep,
8104
7892
  setUploadUrl,
8105
7893
  setUsers,
8106
7894
  setWorkspaces,
@@ -8116,8 +7904,14 @@ export {
8116
7904
  updateAsset,
8117
7905
  updateAssetAttachment,
8118
7906
  updateAssetAttachments,
7907
+ updateAssetStage,
7908
+ updateAssetStageCompletion,
7909
+ updateAssetStageCompletions,
7910
+ updateAssetStages,
7911
+ updateAssetType,
8119
7912
  updateAssetTypeAttachment,
8120
7913
  updateAssetTypeAttachments,
7914
+ updateAssetTypes,
8121
7915
  updateAssets,
8122
7916
  updateCategory,
8123
7917
  updateConversation,
@@ -8145,11 +7939,8 @@ export {
8145
7939
  updateProjectAccess,
8146
7940
  updateProjectAttachment,
8147
7941
  updateProjectAttachments,
8148
- updateStage,
8149
- updateStages,
8150
7942
  updateTeam,
8151
7943
  updateWorkspace,
8152
- useMemoCompare,
8153
7944
  userReducer,
8154
7945
  userSlice,
8155
7946
  versioningReducer,