@overmap-ai/core 1.0.65-strip-workspace-access.3 → 1.0.66

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 (82) 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 +586 -540
  8. package/dist/overmap-core.js.map +1 -1
  9. package/dist/overmap-core.umd.cjs +584 -537
  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 +3 -2
  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 +2 -2
  27. package/dist/sdk/services/DocumentAttachmentService.d.ts +3 -2
  28. package/dist/sdk/services/DocumentService.d.ts +3 -3
  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 -2
  33. package/dist/sdk/services/FormSubmissionService.d.ts +2 -3
  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 +2 -2
  37. package/dist/sdk/services/IssueService.d.ts +2 -2
  38. package/dist/sdk/services/IssueTypeService.d.ts +2 -2
  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 +2 -3
  47. package/dist/sdk/services/ProjectService.d.ts +2 -9
  48. package/dist/sdk/services/TeamService.d.ts +2 -2
  49. package/dist/sdk/services/UserService.d.ts +2 -2
  50. package/dist/sdk/services/WorkspaceService.d.ts +2 -4
  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/typings/models/access.d.ts +2 -9
  55. package/dist/typings/models/agents.d.ts +1 -1
  56. package/dist/typings/models/assets.d.ts +8 -9
  57. package/dist/typings/models/attachments.d.ts +2 -9
  58. package/dist/typings/models/base.d.ts +2 -2
  59. package/dist/typings/models/categories.d.ts +2 -2
  60. package/dist/typings/models/documents.d.ts +1 -1
  61. package/dist/typings/models/emailDomain.d.ts +1 -1
  62. package/dist/typings/models/emailVerification.d.ts +2 -2
  63. package/dist/typings/models/forms.d.ts +2 -2
  64. package/dist/typings/models/geoImages.d.ts +3 -3
  65. package/dist/typings/models/issueTypes.d.ts +2 -2
  66. package/dist/typings/models/issues.d.ts +1 -10
  67. package/dist/typings/models/license.d.ts +2 -15
  68. package/dist/typings/models/organizations.d.ts +1 -1
  69. package/dist/typings/models/projects.d.ts +3 -3
  70. package/dist/typings/models/store.d.ts +1 -1
  71. package/dist/typings/models/teams.d.ts +3 -3
  72. package/dist/typings/models/users.d.ts +1 -1
  73. package/dist/typings/models/workspace.d.ts +1 -1
  74. package/dist/typings/store.d.ts +1 -1
  75. package/dist/utils/colors.d.ts +0 -2
  76. package/dist/utils/index.d.ts +0 -2
  77. package/dist/utils/optimization.d.ts +0 -3
  78. package/package.json +1 -1
  79. package/dist/constants/ui.d.ts +0 -1
  80. package/dist/typings/base.d.ts +0 -0
  81. package/dist/utils/css.d.ts +0 -5
  82. 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
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,6 +664,130 @@ const getLocalRelativeDateString = memoize((date, min, max) => {
799
664
  return getLocalDateString(date);
800
665
  return relative.format(days, "days");
801
666
  });
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;
802
791
  function createModelAdapter(computeModelId) {
803
792
  const addOne = (state, action) => {
804
793
  const id = computeModelId(action.payload);
@@ -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],
@@ -1416,60 +1427,6 @@ const selectUploadUrl = (sha1) => (state) => {
1416
1427
  return url;
1417
1428
  };
1418
1429
  const fileReducer = fileSlice.reducer;
1419
- var ProjectAccessLevel = /* @__PURE__ */ ((ProjectAccessLevel2) => {
1420
- ProjectAccessLevel2[ProjectAccessLevel2["BASIC"] = 0] = "BASIC";
1421
- ProjectAccessLevel2[ProjectAccessLevel2["ADMIN"] = 2] = "ADMIN";
1422
- return ProjectAccessLevel2;
1423
- })(ProjectAccessLevel || {});
1424
- var OrganizationAccessLevel = /* @__PURE__ */ ((OrganizationAccessLevel2) => {
1425
- OrganizationAccessLevel2[OrganizationAccessLevel2["BASIC"] = 0] = "BASIC";
1426
- OrganizationAccessLevel2[OrganizationAccessLevel2["ADMIN"] = 2] = "ADMIN";
1427
- return OrganizationAccessLevel2;
1428
- })(OrganizationAccessLevel || {});
1429
- var AttachmentModel = /* @__PURE__ */ ((AttachmentModel2) => {
1430
- AttachmentModel2["Issue"] = "issue";
1431
- AttachmentModel2["Asset"] = "asset";
1432
- AttachmentModel2["AssetType"] = "asset_type";
1433
- AttachmentModel2["Project"] = "project";
1434
- AttachmentModel2["Document"] = "document";
1435
- return AttachmentModel2;
1436
- })(AttachmentModel || {});
1437
- var IssueUpdateChange = /* @__PURE__ */ ((IssueUpdateChange2) => {
1438
- IssueUpdateChange2["STATUS"] = "status";
1439
- IssueUpdateChange2["PRIORITY"] = "priority";
1440
- IssueUpdateChange2["CATEGORY"] = "category";
1441
- IssueUpdateChange2["DESCRIPTION"] = "description";
1442
- IssueUpdateChange2["TITLE"] = "title";
1443
- IssueUpdateChange2["ASSIGNED_TO"] = "assigned_to";
1444
- IssueUpdateChange2["DUE_DATE"] = "due_date";
1445
- return IssueUpdateChange2;
1446
- })(IssueUpdateChange || {});
1447
- var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
1448
- VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
1449
- VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
1450
- VerificationCodeType2[VerificationCodeType2["PROJECT_INVITE"] = 4] = "PROJECT_INVITE";
1451
- VerificationCodeType2[VerificationCodeType2["ORGANIZATION_INVITE"] = 6] = "ORGANIZATION_INVITE";
1452
- VerificationCodeType2[VerificationCodeType2["ADD_EMAIL_DOMAIN"] = 8] = "ADD_EMAIL_DOMAIN";
1453
- VerificationCodeType2[VerificationCodeType2["RESET_PASSWORD"] = 10] = "RESET_PASSWORD";
1454
- return VerificationCodeType2;
1455
- })(VerificationCodeType || {});
1456
- var PaddleCheckoutEvent = /* @__PURE__ */ ((PaddleCheckoutEvent2) => {
1457
- PaddleCheckoutEvent2["COMPLETED"] = "checkout.completed";
1458
- PaddleCheckoutEvent2["CLOSED"] = "checkout.closed";
1459
- return PaddleCheckoutEvent2;
1460
- })(PaddleCheckoutEvent || {});
1461
- var LicenseLevel = /* @__PURE__ */ ((LicenseLevel2) => {
1462
- LicenseLevel2[LicenseLevel2["PRO"] = 0] = "PRO";
1463
- return LicenseLevel2;
1464
- })(LicenseLevel || {});
1465
- var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
1466
- LicenseStatus2[LicenseStatus2["ACTIVE"] = 0] = "ACTIVE";
1467
- LicenseStatus2[LicenseStatus2["PAUSED"] = 2] = "PAUSED";
1468
- LicenseStatus2[LicenseStatus2["CANCELLED"] = 4] = "CANCELLED";
1469
- LicenseStatus2[LicenseStatus2["INACTIVE"] = 6] = "INACTIVE";
1470
- LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
1471
- return LicenseStatus2;
1472
- })(LicenseStatus || {});
1473
1430
  const initialState$q = {
1474
1431
  users: {},
1475
1432
  currentUser: null
@@ -3968,53 +3925,81 @@ function chunkArray(arr, chunkSize) {
3968
3925
  }
3969
3926
  class AssetService extends BaseApiService {
3970
3927
  // Basic CRUD functions
3971
- add(asset, workspaceId) {
3972
- if (!asset.canvas_marker && !asset.geo_marker) {
3928
+ add(payload) {
3929
+ const { store } = this.client;
3930
+ if (!payload.canvas_marker && !payload.geo_marker) {
3973
3931
  throw new Error("Asset must have either a canvas_marker or geo_marker");
3974
3932
  }
3975
- 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
+ });
3976
3940
  this.dispatch(addAsset(offlineAsset));
3977
3941
  const promise = this.enqueueRequest({
3978
3942
  description: "Create asset",
3979
3943
  method: HttpMethod.POST,
3980
- url: `/assets/types/${offlineAsset.asset_type}/add-assets/`,
3981
- queryParams: {
3982
- 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
3983
3953
  },
3984
- payload: { assets: [offlineAsset] },
3985
- blockers: [],
3954
+ blockers: [offlineAsset.asset_type],
3986
3955
  blocks: [offlineAsset.offline_id]
3987
3956
  });
3957
+ promise.then((createdAsset) => {
3958
+ this.dispatch(updateAsset(createdAsset));
3959
+ }).catch(() => {
3960
+ this.dispatch(deleteAsset(offlineAsset.offline_id));
3961
+ });
3988
3962
  return [offlineAsset, promise];
3989
3963
  }
3990
- update(asset, workspaceId) {
3991
- if (!asset.canvas_marker && !asset.geo_marker) {
3964
+ update(payload) {
3965
+ const { store } = this.client;
3966
+ if (!payload.canvas_marker && !payload.geo_marker) {
3992
3967
  throw new Error("Asset must have either a canvas_marker or geo_marker");
3993
3968
  }
3994
- 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));
3995
3978
  const promise = this.enqueueRequest({
3996
3979
  description: "Edit asset",
3997
3980
  method: HttpMethod.PATCH,
3998
- url: `/assets/${asset.offline_id}/`,
3999
- queryParams: {
4000
- workspace_id: workspaceId.toString()
4001
- },
4002
- payload: asset,
4003
- blockers: [asset.offline_id],
4004
- 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));
4005
3990
  });
4006
- return [asset, promise];
3991
+ return [updatedAsset, promise];
4007
3992
  }
4008
- async remove(assetId) {
3993
+ async remove(id) {
4009
3994
  const { store } = this.client;
4010
3995
  const state = store.getState();
4011
- const assetToBeDeleted = selectAssetById(assetId)(state);
3996
+ const assetToBeDeleted = selectAssetById(id)(state);
4012
3997
  if (!assetToBeDeleted)
4013
- throw new Error(`No asset with id ${assetId} found in the store`);
4014
- const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(state);
4015
- const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(state);
4016
- const issueAssociations = selectIssueAssociationsOfAsset(assetId)(state);
4017
- 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));
4018
4003
  if (attachmentsOfAssets.length > 0) {
4019
4004
  const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
4020
4005
  this.dispatch(deleteAssetAttachments(attachmentsOfAssetIds));
@@ -4030,8 +4015,8 @@ class AssetService extends BaseApiService {
4030
4015
  return this.enqueueRequest({
4031
4016
  description: "Delete asset",
4032
4017
  method: HttpMethod.DELETE,
4033
- url: `/assets/${assetId}/`,
4034
- blockers: [assetId],
4018
+ url: `/assets/${id}/`,
4019
+ blockers: [id],
4035
4020
  blocks: []
4036
4021
  }).catch((err) => {
4037
4022
  this.dispatch(addAsset(assetToBeDeleted));
@@ -4041,39 +4026,17 @@ class AssetService extends BaseApiService {
4041
4026
  throw err;
4042
4027
  });
4043
4028
  }
4044
- async deleteAllAssetsOfAssetType(assetTypeId) {
4045
- const { store } = this.client;
4046
- const state = store.getState();
4047
- const allAssetsOfAssetType = selectAssetsOfAssetType(assetTypeId)(state);
4048
- const allAssetsOfAssetTypeIds = allAssetsOfAssetType.map((c) => c.offline_id);
4049
- const affectedOfflineIds = [assetTypeId, ...allAssetsOfAssetTypeIds];
4050
- store.dispatch(deleteAssets(allAssetsOfAssetTypeIds));
4051
- return this.enqueueRequest({
4052
- description: "Delete all assets of asset type",
4053
- method: HttpMethod.DELETE,
4054
- url: `/assets/types/${assetTypeId}/delete-all-of-type/`,
4055
- blockers: affectedOfflineIds,
4056
- blocks: affectedOfflineIds
4057
- }).catch((err) => {
4058
- store.dispatch(addAssets(allAssetsOfAssetType));
4059
- throw err;
4060
- });
4061
- }
4062
- // TODO: payload does not require asset_type
4063
- bulkAdd(assetsToCreate, workspaceId, assetTypeId, batchSize) {
4029
+ bulkAdd(payloads, assetTypeId, batchSize) {
4064
4030
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4065
4031
  const transactionId = v4();
4066
- const assetBatches = chunkArray(assetsToCreate, batchSize).map((assetBatch) => {
4067
- const assetPayloads = assetBatch.map((assetPayload) => {
4068
- return offline({
4069
- ...assetPayload,
4070
- submitted_at: submittedAt
4071
- });
4072
- });
4032
+ const assetBatches = chunkArray(payloads, batchSize).map((assetBatch) => {
4033
+ const assetPayloads = assetBatch.map((assetPayload) => offline(assetPayload));
4073
4034
  return {
4074
4035
  batchId: v4(),
4075
4036
  payload: {
4076
4037
  transaction_id: transactionId,
4038
+ submitted_at: submittedAt,
4039
+ asset_type: assetTypeId,
4077
4040
  assets: assetPayloads
4078
4041
  }
4079
4042
  };
@@ -4091,10 +4054,7 @@ class AssetService extends BaseApiService {
4091
4054
  const promise = this.enqueueRequest({
4092
4055
  description: "Batch create assets",
4093
4056
  method: HttpMethod.POST,
4094
- url: `/assets/types/${assetTypeId}/add-assets/`,
4095
- queryParams: {
4096
- workspace_id: workspaceId.toString()
4097
- },
4057
+ url: "/assets/bulk/",
4098
4058
  payload,
4099
4059
  blockers,
4100
4060
  blocks
@@ -4120,117 +4080,152 @@ class AssetService extends BaseApiService {
4120
4080
  }
4121
4081
  }
4122
4082
  class AssetStageCompletionService extends BaseApiService {
4123
- add(assetId, stageId) {
4124
- var _a2;
4083
+ add(payload) {
4125
4084
  const { store } = this.client;
4126
- const assetTypeId = (_a2 = selectAssetById(assetId)(store.getState())) == null ? void 0 : _a2.asset_type;
4127
- if (!assetTypeId) {
4128
- throw new Error(`Asset with offline_id ${assetId} not found`);
4129
- }
4085
+ const createdBy = store.getState().userReducer.currentUser.id;
4086
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4130
4087
  const offlineStageCompletion = offline({
4131
- asset: assetId,
4132
- stage: stageId
4088
+ ...payload,
4089
+ created_by: createdBy,
4090
+ submitted_at: submittedAt
4133
4091
  });
4134
- this.dispatch(addStageCompletion(offlineStageCompletion));
4092
+ this.dispatch(addAssetStageCompletion(offlineStageCompletion));
4135
4093
  const promise = this.enqueueRequest({
4136
- description: "Complete stage",
4094
+ description: "Add asset stage completion",
4137
4095
  method: HttpMethod.POST,
4138
- url: `/assets/types/${assetTypeId}/complete-stages/`,
4139
- // TODO: Add submitted_at to model
4140
- payload: { completions: [{ ...offlineStageCompletion, submitted_at: (/* @__PURE__ */ new Date()).getTime() / 1e3 }] },
4141
- 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],
4142
4104
  blocks: [offlineStageCompletion.offline_id]
4143
4105
  });
4106
+ promise.then((result) => {
4107
+ this.dispatch(updateAssetStageCompletion(result));
4108
+ }).catch(() => {
4109
+ this.dispatch(deleteAssetStageCompletion(offlineStageCompletion.offline_id));
4110
+ });
4144
4111
  return [offlineStageCompletion, promise];
4145
4112
  }
4146
- async refreshStore(projectId) {
4147
- const result = await this.enqueueRequest({
4148
- description: "Get stage completions",
4149
- method: HttpMethod.GET,
4150
- url: `/projects/${projectId}/asset-stage-completions/`,
4151
- 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],
4152
4125
  blocks: []
4153
4126
  });
4154
- this.dispatch(addStageCompletions(result));
4127
+ promise.catch(() => {
4128
+ this.dispatch(addAssetStageCompletion(assetStageCompletion));
4129
+ });
4130
+ return promise;
4155
4131
  }
4156
- /**
4157
- * Creates a collection of AssetStageCompletions, marking the referenced stages as completed for the referenced
4158
- * assets. It's REQUIRED that all assets referenced all have the SAME asset type.
4159
- * @param assetTypeId The ID of the asset type for which we are completing stages (we can only complete
4160
- * stages for one asset type at a time)
4161
- * @param stageCompletions
4162
- */
4163
- async bulkAdd(assetTypeId, stageCompletions) {
4164
- const offlineStageCompletions = stageCompletions.map((completion) => {
4165
- return offline(completion);
4166
- });
4167
- const asMapping = {};
4168
- for (const completion of stageCompletions) {
4169
- const stageToCompletionDateMapping = asMapping[completion.asset] || {};
4170
- stageToCompletionDateMapping[completion.stage] = (/* @__PURE__ */ new Date()).toISOString();
4171
- asMapping[completion.asset] = stageToCompletionDateMapping;
4172
- }
4173
- this.dispatch(addStageCompletions(asMapping));
4174
- await this.enqueueRequest({
4175
- 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",
4176
4148
  method: HttpMethod.POST,
4177
- url: `/assets/types/${assetTypeId}/complete-stages/`,
4149
+ url: "/assets/completions/bulk/",
4178
4150
  payload: {
4179
- completions: offlineStageCompletions
4151
+ submitted_at: submittedAt,
4152
+ completions: payload
4180
4153
  },
4181
- blockers: [assetTypeId, ...stageCompletions.map((c) => c.asset), ...stageCompletions.map((c) => c.stage)],
4182
- blocks: offlineStageCompletions.map((c) => c.offline_id)
4154
+ blockers: [...payloads.map((c) => c.asset), ...payloads.map((c) => c.stage)],
4155
+ blocks: offlineIds
4183
4156
  });
4184
- }
4185
- bulkDelete(stageId, assetIds) {
4186
- const stageCompletionsToRemove = assetIds.map((assetId) => {
4187
- return {
4188
- asset: assetId,
4189
- stage: stageId
4190
- };
4157
+ promise.then((result) => {
4158
+ this.dispatch(updateAssetStageCompletions(result));
4159
+ }).catch(() => {
4160
+ this.dispatch(deleteAssetStageCompletions(offlineIds));
4191
4161
  });
4192
- this.dispatch(removeStageCompletions(stageCompletionsToRemove));
4193
- return this.enqueueRequest({
4194
- description: `Undo stage for ${assetIds.length} assets(s)`,
4195
- // 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",
4196
4170
  method: HttpMethod.DELETE,
4197
- url: `/assets/stages/${stageId}/undo-stages/`,
4171
+ url: "/assets/completions/bulk/",
4198
4172
  payload: {
4199
- assets: assetIds
4173
+ completion_ids: ids
4200
4174
  },
4201
- 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: [],
4202
4189
  blocks: []
4203
4190
  });
4191
+ this.dispatch(initializeAssetStageCompletions(result));
4204
4192
  }
4205
4193
  }
4206
4194
  class AssetStageService extends BaseApiService {
4207
- 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;
4208
4198
  const payload = stagesToSubmit.map((stage) => {
4209
4199
  return offline(stage);
4210
4200
  });
4211
- const fullStages = payload.map((stage) => {
4212
- return { ...stage, asset_type: assetTypeId };
4201
+ const offlineStages = payload.map((stage) => {
4202
+ return { ...stage, asset_type: assetTypeId, created_by: createdBy, submitted_at: submittedAt };
4213
4203
  });
4214
- this.dispatch(addStages(fullStages));
4215
- return this.enqueueRequest({
4204
+ this.dispatch(addAssetStages(offlineStages));
4205
+ const promise = this.enqueueRequest({
4216
4206
  description: "Add asset stages",
4217
4207
  method: HttpMethod.POST,
4218
- url: `/assets/types/${assetTypeId}/add-stages/`,
4208
+ url: "/assets/stages/bulk/",
4219
4209
  payload: {
4210
+ submitted_at: submittedAt,
4211
+ asset_type: assetTypeId,
4220
4212
  stages: payload
4221
4213
  },
4222
- queryParams: {
4223
- workspace_id: workspaceId.toString()
4224
- },
4225
- blockers: [assetTypeId, workspaceId],
4214
+ blockers: [assetTypeId],
4226
4215
  blocks: payload.map(({ offline_id }) => offline_id)
4227
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];
4228
4223
  }
4229
- async bulkUpdateStages(stagesToUpdate, assetTypeId) {
4224
+ async bulkUpdate(stagesToUpdate, assetTypeId) {
4230
4225
  const store = this.client.store;
4231
4226
  const state = store.getState();
4232
4227
  const prevStages = selectAssetStagesByIds(stagesToUpdate.map(({ offline_id }) => offline_id))(state);
4233
- this.dispatch(updateStages(stagesToUpdate));
4228
+ this.dispatch(updateAssetStages(stagesToUpdate));
4234
4229
  return this.enqueueRequest({
4235
4230
  description: "Edit asset stages",
4236
4231
  method: HttpMethod.PATCH,
@@ -4241,33 +4236,58 @@ class AssetStageService extends BaseApiService {
4241
4236
  blockers: [assetTypeId],
4242
4237
  blocks: stagesToUpdate.map(({ offline_id }) => offline_id)
4243
4238
  }).catch((e) => {
4244
- store.dispatch(updateStages(prevStages));
4239
+ this.dispatch(updateAssetStages(prevStages));
4245
4240
  throw e;
4246
4241
  });
4247
4242
  }
4248
4243
  async bulkDelete(idsToDelete) {
4249
- this.dispatch(removeStages(idsToDelete));
4250
- 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({
4251
4248
  description: "Delete asset stages",
4252
4249
  method: HttpMethod.DELETE,
4253
- url: "/assets/stages/bulk-delete/",
4250
+ url: "/assets/stages/bulk/",
4254
4251
  payload: {
4255
4252
  stage_ids: idsToDelete
4256
4253
  },
4257
4254
  blockers: idsToDelete,
4258
4255
  blocks: []
4259
4256
  });
4257
+ promise.catch(() => {
4258
+ this.dispatch(addAssetStages(assetStages));
4259
+ });
4260
+ return promise;
4260
4261
  }
4261
- async update(assetStage) {
4262
- this.dispatch(addStages([assetStage]));
4263
- 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({
4264
4273
  description: "Update asset stage",
4265
4274
  method: HttpMethod.PATCH,
4266
4275
  url: `/assets/stages/${assetStage.offline_id}/`,
4267
- payload: assetStage,
4276
+ payload: {
4277
+ name: payload.name,
4278
+ description: payload.description,
4279
+ priority: payload.priority,
4280
+ color: payload.color
4281
+ },
4268
4282
  blockers: [assetStage.offline_id],
4269
4283
  blocks: [assetStage.offline_id]
4270
4284
  });
4285
+ promise.then((result) => {
4286
+ this.dispatch(updateAssetStage(result));
4287
+ }).catch(() => {
4288
+ this.dispatch(setAssetStage(assetStage));
4289
+ });
4290
+ return [updatedAssetStage, promise];
4271
4291
  }
4272
4292
  async linkForm(stageId, formId) {
4273
4293
  const { store } = this.client;
@@ -4275,7 +4295,7 @@ class AssetStageService extends BaseApiService {
4275
4295
  if (!stage) {
4276
4296
  throw new Error(`No asset stage with id ${stageId} found in the store`);
4277
4297
  }
4278
- this.dispatch(updateStage({ ...stage, form: formId }));
4298
+ this.dispatch(updateAssetStage({ ...stage, form: formId }));
4279
4299
  try {
4280
4300
  await this.enqueueRequest({
4281
4301
  description: "Link asset stage to form",
@@ -4286,7 +4306,7 @@ class AssetStageService extends BaseApiService {
4286
4306
  blocks: [stageId]
4287
4307
  });
4288
4308
  } catch (e) {
4289
- this.dispatch(setStage(stage));
4309
+ this.dispatch(setAssetStage(stage));
4290
4310
  throw e;
4291
4311
  }
4292
4312
  }
@@ -4296,7 +4316,7 @@ class AssetStageService extends BaseApiService {
4296
4316
  if (!stage) {
4297
4317
  throw new Error(`No asset stage with id ${stageId} found in the store`);
4298
4318
  }
4299
- this.dispatch(updateStage({ ...stage, form: void 0 }));
4319
+ this.dispatch(updateAssetStage({ ...stage, form: void 0 }));
4300
4320
  try {
4301
4321
  await this.enqueueRequest({
4302
4322
  description: "Unlink asset stage from form",
@@ -4306,7 +4326,7 @@ class AssetStageService extends BaseApiService {
4306
4326
  blocks: [stageId]
4307
4327
  });
4308
4328
  } catch (e) {
4309
- this.dispatch(setStage(stage));
4329
+ this.dispatch(setAssetStage(stage));
4310
4330
  throw e;
4311
4331
  }
4312
4332
  }
@@ -4318,7 +4338,7 @@ class AssetStageService extends BaseApiService {
4318
4338
  blockers: [],
4319
4339
  blocks: []
4320
4340
  });
4321
- this.dispatch(initializeStages(result));
4341
+ this.dispatch(initializeAssetStages(result));
4322
4342
  }
4323
4343
  }
4324
4344
  class BaseUploadService extends BaseApiService {
@@ -4526,29 +4546,61 @@ class AssetAttachmentService extends BaseAttachmentService {
4526
4546
  }
4527
4547
  }
4528
4548
  class AssetTypeService extends BaseApiService {
4529
- add(assetType) {
4530
- 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
+ });
4531
4558
  this.dispatch(addAssetType(offlineAssetType));
4532
4559
  const promise = this.enqueueRequest({
4533
4560
  description: "Create asset type",
4534
4561
  method: HttpMethod.POST,
4535
- url: `/projects/${assetType.project}/asset-types/`,
4562
+ url: `/projects/${payload.project}/asset-types/`,
4536
4563
  payload: { ...offlineAssetType },
4537
4564
  blockers: [],
4538
4565
  blocks: [offlineAssetType.offline_id]
4539
4566
  });
4567
+ promise.then((result) => {
4568
+ this.dispatch(updateAssetType(result));
4569
+ }).catch(() => {
4570
+ this.dispatch(deleteAssetType(offlineAssetType.offline_id));
4571
+ });
4540
4572
  return [offlineAssetType, promise];
4541
4573
  }
4542
- update(assetType) {
4543
- this.dispatch(addAssetType(assetType));
4544
- 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({
4545
4586
  description: "Update asset type",
4546
4587
  method: HttpMethod.PATCH,
4547
- url: `/assets/types/${assetType.offline_id}/`,
4548
- 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
+ },
4549
4595
  blockers: [assetType.offline_id],
4550
4596
  blocks: [assetType.offline_id]
4551
4597
  });
4598
+ promise.then((result) => {
4599
+ this.dispatch(updateAssetType(result));
4600
+ }).catch(() => {
4601
+ this.dispatch(updateAssetType(assetType));
4602
+ });
4603
+ return [updatedAssetType, promise];
4552
4604
  }
4553
4605
  async delete(assetTypeId) {
4554
4606
  const { store } = this.client;
@@ -4557,17 +4609,13 @@ class AssetTypeService extends BaseApiService {
4557
4609
  if (!assetType) {
4558
4610
  throw new Error(`Expected asset type with offline_id ${assetTypeId} to exist`);
4559
4611
  }
4612
+ const assetsOfAssetType = selectAssetsOfAssetType(assetTypeId)(state);
4560
4613
  const stagesOfAssetType = selectStagesOfAssetType(assetTypeId)(state);
4561
4614
  const attachmentsOfAssetType = selectAttachmentsOfAssetType(assetTypeId)(state);
4562
4615
  this.dispatch(deleteAssetType(assetTypeId));
4563
- if (stagesOfAssetType.length > 0) {
4564
- const stagesOfAssetTypeIds = stagesOfAssetType.map((assetStage) => assetStage.offline_id);
4565
- this.dispatch(removeStages(stagesOfAssetTypeIds));
4566
- }
4567
- if (attachmentsOfAssetType.length > 0) {
4568
- const attachmentsOfAssetTypeIds = attachmentsOfAssetType.map(({ offline_id }) => offline_id);
4569
- this.dispatch(deleteAssetTypeAttachments(attachmentsOfAssetTypeIds));
4570
- }
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)));
4571
4619
  return this.enqueueRequest({
4572
4620
  description: "Delete asset type",
4573
4621
  method: HttpMethod.DELETE,
@@ -4576,7 +4624,8 @@ class AssetTypeService extends BaseApiService {
4576
4624
  blocks: []
4577
4625
  }).catch((e) => {
4578
4626
  this.dispatch(addAssetType(assetType));
4579
- this.dispatch(addStages(stagesOfAssetType));
4627
+ this.dispatch(addAssets(assetsOfAssetType));
4628
+ this.dispatch(addAssetStages(stagesOfAssetType));
4580
4629
  this.dispatch(addAssetTypeAttachments(attachmentsOfAssetType));
4581
4630
  throw e;
4582
4631
  });
@@ -4781,15 +4830,6 @@ class IssueService extends BaseApiService {
4781
4830
  void promise.then((result) => {
4782
4831
  this.dispatch(updateIssue(result));
4783
4832
  }).catch((error) => {
4784
- var _a3;
4785
- console.error(error);
4786
- if (error instanceof APIError) {
4787
- (_a3 = unsafeShowToast) == null ? void 0 : _a3({
4788
- title: "Could not create issue",
4789
- description: error.message,
4790
- accentColor: "red"
4791
- });
4792
- }
4793
4833
  this.dispatch(deleteIssue(offlineIssue.offline_id));
4794
4834
  this.dispatch(addActiveProjectIssuesCount(-1));
4795
4835
  throw error;
@@ -5037,15 +5077,6 @@ class IssueTypeService extends BaseApiService {
5037
5077
  }
5038
5078
  }
5039
5079
  class ProjectAccessService extends BaseApiService {
5040
- async fetchAll(projectId) {
5041
- return this.enqueueRequest({
5042
- description: "Get project accesses",
5043
- method: HttpMethod.GET,
5044
- url: `/projects/${projectId}/access/`,
5045
- blockers: [],
5046
- blocks: []
5047
- });
5048
- }
5049
5080
  async update(projectAccess) {
5050
5081
  this.dispatch(updateProjectAccess(projectAccess));
5051
5082
  return this.enqueueRequest({
@@ -5058,19 +5089,24 @@ class ProjectAccessService extends BaseApiService {
5058
5089
  });
5059
5090
  }
5060
5091
  // TODO: Re-add user to project if removal fails
5061
- async remove(projectAccess) {
5062
- this.dispatch(deleteProjectAccess(projectAccess.offline_id));
5092
+ async remove(id) {
5093
+ this.dispatch(deleteProjectAccess(id));
5063
5094
  return this.enqueueRequest({
5064
5095
  description: "Delete project access",
5065
5096
  method: HttpMethod.DELETE,
5066
- url: `/access/${projectAccess.offline_id}/`,
5067
- blockers: [projectAccess.offline_id],
5097
+ url: `/access/${id}/`,
5098
+ blockers: [id],
5068
5099
  blocks: []
5069
5100
  });
5070
5101
  }
5071
5102
  async refreshStore(projectId) {
5072
- const promise = this.fetchAll(projectId);
5073
- const result = await promise;
5103
+ const result = await this.enqueueRequest({
5104
+ description: "Get project accesses",
5105
+ method: HttpMethod.GET,
5106
+ url: `/projects/${projectId}/access/`,
5107
+ blockers: [],
5108
+ blocks: []
5109
+ });
5074
5110
  this.dispatch(initializeProjectAccesses(result));
5075
5111
  }
5076
5112
  }
@@ -5206,29 +5242,23 @@ class ProjectAttachmentService extends BaseAttachmentService {
5206
5242
  }
5207
5243
  }
5208
5244
  class ProjectService extends BaseApiService {
5209
- /**
5210
- * Creates a new project. Due to the nature of project creation,
5211
- * @param project A Payload<Project> object containing project attributes.
5212
- * @returns A promise that resolves to a Project.
5213
- * @throws An APIError if the server returns an error, or any other error that may occur.
5214
- */
5215
- async add(project) {
5216
- if (!project.organization_owner && !project.user_owner) {
5245
+ async add(payload) {
5246
+ if (!payload.organization_owner && !payload.user_owner) {
5217
5247
  throw new Error("Project type was not chosen when trying to create a project");
5218
5248
  }
5219
- if (!project.bounds && !project.canvas_bounds) {
5249
+ if (!payload.bounds && !payload.canvas_bounds) {
5220
5250
  throw new Error("Project must either have bounds or canvas_bounds set");
5221
5251
  }
5222
- const isOrganizationProject = !!project.organization_owner;
5223
- const url = isOrganizationProject ? `/organizations/${project.organization_owner}/projects/` : "/projects/";
5224
- 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 };
5225
5255
  return await this.enqueueRequest({
5226
5256
  description: "Create project",
5227
5257
  method: HttpMethod.POST,
5228
5258
  url,
5229
5259
  payload: {
5230
- name: project.name,
5231
- bounds: project.bounds,
5260
+ name: payload.name,
5261
+ bounds: payload.bounds,
5232
5262
  ...projectType
5233
5263
  },
5234
5264
  blockers: [],
@@ -5909,7 +5939,7 @@ class FormSubmissionService extends BaseUploadService {
5909
5939
  description: "Delete user form submissions",
5910
5940
  method: HttpMethod.PATCH,
5911
5941
  url: `/forms/submissions/${updatedSubmission.offline_id}/`,
5912
- payload: updatedSubmission,
5942
+ payload,
5913
5943
  blockers: [updatedSubmission.offline_id],
5914
5944
  blocks: [updatedSubmission.offline_id]
5915
5945
  });
@@ -6052,7 +6082,7 @@ class WorkspaceService extends BaseApiService {
6052
6082
  description: "Update Workspace",
6053
6083
  method: HttpMethod.PATCH,
6054
6084
  url: `/workspaces/${workspace.offline_id}/`,
6055
- payload: workspace,
6085
+ payload,
6056
6086
  blockers: [workspace.offline_id],
6057
6087
  blocks: [workspace.offline_id]
6058
6088
  });
@@ -6602,26 +6632,26 @@ class DocumentService extends BaseApiService {
6602
6632
  });
6603
6633
  return [offlineDocument, promise];
6604
6634
  }
6605
- update(document2) {
6635
+ update(payload) {
6606
6636
  const { store } = this.client;
6607
- const documentToBeUpdated = store.getState().documentsReducer.documents[document2.offline_id];
6637
+ const documentToBeUpdated = store.getState().documentsReducer.documents[payload.offline_id];
6608
6638
  if (!documentToBeUpdated) {
6609
6639
  throw new Error(
6610
- `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`
6611
6641
  );
6612
6642
  }
6613
6643
  const updatedDocument = {
6614
6644
  ...documentToBeUpdated,
6615
- ...document2
6645
+ ...payload
6616
6646
  };
6617
6647
  this.dispatch(updateDocuments([updatedDocument]));
6618
6648
  const promise = this.enqueueRequest({
6619
6649
  description: "Update Document",
6620
6650
  method: HttpMethod.PATCH,
6621
- url: `/documents/${document2.offline_id}/`,
6622
- payload: document2,
6623
- blockers: [document2.offline_id],
6624
- blocks: [document2.offline_id]
6651
+ url: `/documents/${payload.offline_id}/`,
6652
+ payload,
6653
+ blockers: [payload.offline_id],
6654
+ blocks: [payload.offline_id]
6625
6655
  });
6626
6656
  promise.catch(() => {
6627
6657
  updateDocuments([documentToBeUpdated]);
@@ -6972,7 +7002,7 @@ class TeamService extends BaseApiService {
6972
7002
  description: "Update team",
6973
7003
  method: HttpMethod.PATCH,
6974
7004
  url: `/organizations/teams/${payload.offline_id}/`,
6975
- payload: offlineUpdatedTeam,
7005
+ payload,
6976
7006
  blockers: [payload.offline_id],
6977
7007
  blocks: [payload.offline_id]
6978
7008
  });
@@ -7324,12 +7354,20 @@ class IssueAssociationService extends BaseUploadService {
7324
7354
  this.dispatch(initializeIssueAssociations(issueAssociations));
7325
7355
  }
7326
7356
  }
7357
+ var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
7358
+ VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
7359
+ VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
7360
+ VerificationCodeType2[VerificationCodeType2["PROJECT_INVITE"] = 4] = "PROJECT_INVITE";
7361
+ VerificationCodeType2[VerificationCodeType2["ORGANIZATION_INVITE"] = 6] = "ORGANIZATION_INVITE";
7362
+ VerificationCodeType2[VerificationCodeType2["ADD_EMAIL_DOMAIN"] = 8] = "ADD_EMAIL_DOMAIN";
7363
+ VerificationCodeType2[VerificationCodeType2["RESET_PASSWORD"] = 10] = "RESET_PASSWORD";
7364
+ return VerificationCodeType2;
7365
+ })(VerificationCodeType || {});
7327
7366
  export {
7328
7367
  APIError,
7329
7368
  AgentService,
7330
7369
  AssetAttachmentService,
7331
7370
  AssetService,
7332
- AssetStageColors,
7333
7371
  AssetStageCompletionService,
7334
7372
  AssetStageService,
7335
7373
  AssetTypeAttachmentService,
@@ -7391,9 +7429,14 @@ export {
7391
7429
  addAsset,
7392
7430
  addAssetAttachment,
7393
7431
  addAssetAttachments,
7432
+ addAssetStage,
7433
+ addAssetStageCompletion,
7434
+ addAssetStageCompletions,
7435
+ addAssetStages,
7394
7436
  addAssetType,
7395
7437
  addAssetTypeAttachment,
7396
7438
  addAssetTypeAttachments,
7439
+ addAssetTypes,
7397
7440
  addAssets,
7398
7441
  addCategory,
7399
7442
  addConversation,
@@ -7430,9 +7473,6 @@ export {
7430
7473
  addOrReplaceProjects,
7431
7474
  addProjectAttachment,
7432
7475
  addProjectAttachments,
7433
- addStageCompletion,
7434
- addStageCompletions,
7435
- addStages,
7436
7476
  addTeam,
7437
7477
  addUsers,
7438
7478
  addWorkspace,
@@ -7457,7 +7497,6 @@ export {
7457
7497
  boundsContainPoint,
7458
7498
  categoryReducer,
7459
7499
  categorySlice,
7460
- classNames,
7461
7500
  clearTokens,
7462
7501
  constructUploadedFilePayloads,
7463
7502
  coordinatesAreEqual,
@@ -7471,9 +7510,14 @@ export {
7471
7510
  deleteAsset,
7472
7511
  deleteAssetAttachment,
7473
7512
  deleteAssetAttachments,
7513
+ deleteAssetStage,
7514
+ deleteAssetStageCompletion,
7515
+ deleteAssetStageCompletions,
7516
+ deleteAssetStages,
7474
7517
  deleteAssetType,
7475
7518
  deleteAssetTypeAttachment,
7476
7519
  deleteAssetTypeAttachments,
7520
+ deleteAssetTypes,
7477
7521
  deleteAssets,
7478
7522
  deleteCategory,
7479
7523
  deleteDocumentAttachment,
@@ -7538,9 +7582,7 @@ export {
7538
7582
  formSubmissionAttachmentSlice,
7539
7583
  formSubmissionReducer,
7540
7584
  formSubmissionSlice,
7541
- fullAssetMarkerSize,
7542
7585
  generateBadgeColors,
7543
- genericMemo,
7544
7586
  geoImageReducer,
7545
7587
  geoImageSlice,
7546
7588
  getFileIdentifier,
@@ -7549,10 +7591,11 @@ export {
7549
7591
  getLocalRelativeDateString,
7550
7592
  getOutboxCoordinator,
7551
7593
  getRenamedFile,
7552
- getStageColor,
7553
7594
  hashFile,
7554
7595
  initSDK,
7555
7596
  initializeAssetAttachments,
7597
+ initializeAssetStageCompletions,
7598
+ initializeAssetStages,
7556
7599
  initializeAssetTypeAttachments,
7557
7600
  initializeAssetTypes,
7558
7601
  initializeAssets,
@@ -7575,7 +7618,6 @@ export {
7575
7618
  initializeOrganizationAccesses,
7576
7619
  initializeProjectAccesses,
7577
7620
  initializeProjectAttachments,
7578
- initializeStages,
7579
7621
  initializeTeams,
7580
7622
  initializeWorkspaces,
7581
7623
  isToday,
@@ -7587,7 +7629,6 @@ export {
7587
7629
  issueCommentSlice,
7588
7630
  issueReducer,
7589
7631
  issueSlice,
7590
- issueToSearchResult,
7591
7632
  issueTypeReducer,
7592
7633
  issueTypeSlice,
7593
7634
  issueUpdateReducer,
@@ -7631,8 +7672,6 @@ export {
7631
7672
  removeIssueType,
7632
7673
  removeProjectFile,
7633
7674
  removeProjectFilesOfProject,
7634
- removeStageCompletions,
7635
- removeStages,
7636
7675
  removeUser,
7637
7676
  resetProjectFileObjectUrls,
7638
7677
  resetStore,
@@ -7653,6 +7692,9 @@ export {
7653
7692
  selectAssetAttachments,
7654
7693
  selectAssetById,
7655
7694
  selectAssetStageById,
7695
+ selectAssetStageCompletionById,
7696
+ selectAssetStageCompletionMapping,
7697
+ selectAssetStageCompletionsByIds,
7656
7698
  selectAssetStages,
7657
7699
  selectAssetStagesByIds,
7658
7700
  selectAssetTypeAttachmentById,
@@ -7688,7 +7730,7 @@ export {
7688
7730
  selectCategoryMapping,
7689
7731
  selectCommentsOfIssue,
7690
7732
  selectCompletedStageIdsForAsset,
7691
- selectCompletedStages,
7733
+ selectCompletedStagesByAsset,
7692
7734
  selectConversation,
7693
7735
  selectConversationMapping,
7694
7736
  selectConversations,
@@ -7800,7 +7842,6 @@ export {
7800
7842
  selectSortedProjectUsers,
7801
7843
  selectStageFormIdsFromStageIds,
7802
7844
  selectStageMapping,
7803
- selectStagesFromAssetTypeIds,
7804
7845
  selectStagesOfAssetType,
7805
7846
  selectTeamById,
7806
7847
  selectTeams,
@@ -7820,8 +7861,12 @@ export {
7820
7861
  setAsset,
7821
7862
  setAssetAttachment,
7822
7863
  setAssetAttachments,
7864
+ setAssetStage,
7865
+ setAssetStages,
7866
+ setAssetType,
7823
7867
  setAssetTypeAttachment,
7824
7868
  setAssetTypeAttachments,
7869
+ setAssetTypes,
7825
7870
  setAssets,
7826
7871
  setConversation,
7827
7872
  setCurrentUser,
@@ -7854,8 +7899,6 @@ export {
7854
7899
  setProjectAttachments,
7855
7900
  setProjects,
7856
7901
  setRehydrated,
7857
- setStage,
7858
- setStageCompletions,
7859
7902
  setTeam,
7860
7903
  setTokens,
7861
7904
  setUploadUrl,
@@ -7873,8 +7916,14 @@ export {
7873
7916
  updateAsset,
7874
7917
  updateAssetAttachment,
7875
7918
  updateAssetAttachments,
7919
+ updateAssetStage,
7920
+ updateAssetStageCompletion,
7921
+ updateAssetStageCompletions,
7922
+ updateAssetStages,
7923
+ updateAssetType,
7876
7924
  updateAssetTypeAttachment,
7877
7925
  updateAssetTypeAttachments,
7926
+ updateAssetTypes,
7878
7927
  updateAssets,
7879
7928
  updateCategory,
7880
7929
  updateConversation,
@@ -7902,11 +7951,8 @@ export {
7902
7951
  updateProjectAccess,
7903
7952
  updateProjectAttachment,
7904
7953
  updateProjectAttachments,
7905
- updateStage,
7906
- updateStages,
7907
7954
  updateTeam,
7908
7955
  updateWorkspace,
7909
- useMemoCompare,
7910
7956
  userReducer,
7911
7957
  userSlice,
7912
7958
  versioningReducer,