@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
@@ -5,8 +5,8 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  (function(global, factory) {
8
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("dependency-graph"), require("uuid"), require("@redux-offline/redux-offline"), require("@redux-offline/redux-offline/lib/defaults"), require("localforage"), require("redux-persist-migrate"), require("@reduxjs/toolkit"), require("superagent"), require("file-saver"), require("react"), require("color"), require("@radix-ui/colors"), require("@redux-offline/redux-offline/lib/constants"), require("jwt-decode"), require("@overmap-ai/blocks"), require("idb")) : typeof define === "function" && define.amd ? define(["exports", "dependency-graph", "uuid", "@redux-offline/redux-offline", "@redux-offline/redux-offline/lib/defaults", "localforage", "redux-persist-migrate", "@reduxjs/toolkit", "superagent", "file-saver", "react", "color", "@radix-ui/colors", "@redux-offline/redux-offline/lib/constants", "jwt-decode", "@overmap-ai/blocks", "idb"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["overmap-core"] = {}, global.dependencyGraph, global.uuid, global.reduxOffline, global.offlineConfig, global.localforage, global.createMigration, global.toolkit, global.request, global.fileSaver, global.React, global.ColorCls, global.colors, global.constants, global.jwtDecode, global.blocks, global.idb));
9
- })(this, function(exports2, dependencyGraph, uuid, reduxOffline, offlineConfig, localforage, createMigration, toolkit, request, fileSaver, React, ColorCls, colors, constants, jwtDecode, blocks, idb) {
8
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("dependency-graph"), require("uuid"), require("file-saver"), require("color"), require("@radix-ui/colors"), require("@redux-offline/redux-offline"), require("@redux-offline/redux-offline/lib/defaults"), require("localforage"), require("redux-persist-migrate"), require("@reduxjs/toolkit"), require("superagent"), require("@redux-offline/redux-offline/lib/constants"), require("jwt-decode"), require("idb"), require("@overmap-ai/blocks")) : typeof define === "function" && define.amd ? define(["exports", "dependency-graph", "uuid", "file-saver", "color", "@radix-ui/colors", "@redux-offline/redux-offline", "@redux-offline/redux-offline/lib/defaults", "localforage", "redux-persist-migrate", "@reduxjs/toolkit", "superagent", "@redux-offline/redux-offline/lib/constants", "jwt-decode", "idb", "@overmap-ai/blocks"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["overmap-core"] = {}, global.dependencyGraph, global.uuid, global.fileSaver, global.ColorCls, global.colors, global.reduxOffline, global.offlineConfig, global.localforage, global.createMigration, global.toolkit, global.request, global.constants, global.jwtDecode, global.idb, global.blocks));
9
+ })(this, function(exports2, dependencyGraph, uuid, fileSaver, ColorCls, colors, reduxOffline, offlineConfig, localforage, createMigration, toolkit, request, constants, jwtDecode, idb, blocks) {
10
10
  var _a;
11
11
  "use strict";
12
12
  var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
@@ -17,6 +17,14 @@ var __publicField = (obj, key, value) => {
17
17
  HttpMethod2["DELETE"] = "DELETE";
18
18
  return HttpMethod2;
19
19
  })(HttpMethod || {});
20
+ var AttachmentModel = /* @__PURE__ */ ((AttachmentModel2) => {
21
+ AttachmentModel2["Issue"] = "issue";
22
+ AttachmentModel2["Asset"] = "asset";
23
+ AttachmentModel2["AssetType"] = "asset_type";
24
+ AttachmentModel2["Project"] = "project";
25
+ AttachmentModel2["Document"] = "document";
26
+ return AttachmentModel2;
27
+ })(AttachmentModel || {});
20
28
  var IssuePriority = /* @__PURE__ */ ((IssuePriority2) => {
21
29
  IssuePriority2[IssuePriority2["LOWEST"] = 0] = "LOWEST";
22
30
  IssuePriority2[IssuePriority2["LOW"] = 2] = "LOW";
@@ -31,6 +39,43 @@ var __publicField = (obj, key, value) => {
31
39
  IssueStatus2[IssueStatus2["DONE"] = 4] = "DONE";
32
40
  return IssueStatus2;
33
41
  })(IssueStatus || {});
42
+ var IssueUpdateChange = /* @__PURE__ */ ((IssueUpdateChange2) => {
43
+ IssueUpdateChange2["STATUS"] = "status";
44
+ IssueUpdateChange2["PRIORITY"] = "priority";
45
+ IssueUpdateChange2["CATEGORY"] = "category";
46
+ IssueUpdateChange2["DESCRIPTION"] = "description";
47
+ IssueUpdateChange2["TITLE"] = "title";
48
+ IssueUpdateChange2["ASSIGNED_TO"] = "assigned_to";
49
+ IssueUpdateChange2["DUE_DATE"] = "due_date";
50
+ return IssueUpdateChange2;
51
+ })(IssueUpdateChange || {});
52
+ var ProjectAccessLevel = /* @__PURE__ */ ((ProjectAccessLevel2) => {
53
+ ProjectAccessLevel2[ProjectAccessLevel2["BASIC"] = 0] = "BASIC";
54
+ ProjectAccessLevel2[ProjectAccessLevel2["ADMIN"] = 2] = "ADMIN";
55
+ return ProjectAccessLevel2;
56
+ })(ProjectAccessLevel || {});
57
+ var OrganizationAccessLevel = /* @__PURE__ */ ((OrganizationAccessLevel2) => {
58
+ OrganizationAccessLevel2[OrganizationAccessLevel2["BASIC"] = 0] = "BASIC";
59
+ OrganizationAccessLevel2[OrganizationAccessLevel2["ADMIN"] = 2] = "ADMIN";
60
+ return OrganizationAccessLevel2;
61
+ })(OrganizationAccessLevel || {});
62
+ var PaddleCheckoutEvent = /* @__PURE__ */ ((PaddleCheckoutEvent2) => {
63
+ PaddleCheckoutEvent2["COMPLETED"] = "checkout.completed";
64
+ PaddleCheckoutEvent2["CLOSED"] = "checkout.closed";
65
+ return PaddleCheckoutEvent2;
66
+ })(PaddleCheckoutEvent || {});
67
+ var LicenseLevel = /* @__PURE__ */ ((LicenseLevel2) => {
68
+ LicenseLevel2[LicenseLevel2["PRO"] = 0] = "PRO";
69
+ return LicenseLevel2;
70
+ })(LicenseLevel || {});
71
+ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
72
+ LicenseStatus2[LicenseStatus2["ACTIVE"] = 0] = "ACTIVE";
73
+ LicenseStatus2[LicenseStatus2["PAUSED"] = 2] = "PAUSED";
74
+ LicenseStatus2[LicenseStatus2["CANCELLED"] = 4] = "CANCELLED";
75
+ LicenseStatus2[LicenseStatus2["INACTIVE"] = 6] = "INACTIVE";
76
+ LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
77
+ return LicenseStatus2;
78
+ })(LicenseStatus || {});
34
79
  class OutboxCoordinator {
35
80
  constructor() {
36
81
  __publicField(this, "graph");
@@ -273,130 +318,6 @@ var __publicField = (obj, key, value) => {
273
318
  this.options = options;
274
319
  }
275
320
  }
276
- class DeferredPromise {
277
- constructor() {
278
- __publicField(this, _a, "Promise");
279
- __publicField(this, "_promise");
280
- __publicField(this, "_resolve");
281
- __publicField(this, "_reject");
282
- __publicField(this, "_state", "pending");
283
- this._resolve = null;
284
- this._reject = null;
285
- this._promise = new Promise((resolve, reject) => {
286
- this._resolve = resolve;
287
- this._reject = reject;
288
- });
289
- }
290
- get state() {
291
- return this._state;
292
- }
293
- then(onFulfilled, onRejected) {
294
- return this._promise.then(onFulfilled, onRejected);
295
- }
296
- catch(onRejected) {
297
- return this._promise.catch(onRejected);
298
- }
299
- resolve(value) {
300
- if (!this._resolve)
301
- throw new Error("No resolve callback");
302
- this._resolve(value);
303
- this._state = "fulfilled";
304
- }
305
- reject(reason) {
306
- if (!this._reject)
307
- throw reason;
308
- this._reject(reason);
309
- this._state = "rejected";
310
- }
311
- finally(_onFinally) {
312
- throw new Error("`finally` not implemented");
313
- }
314
- }
315
- _a = Symbol.toStringTag;
316
- var randomString = function randomString2() {
317
- return Math.random().toString(36).substring(7).split("").join(".");
318
- };
319
- ({
320
- INIT: "@@redux/INIT" + randomString(),
321
- REPLACE: "@@redux/REPLACE" + randomString(),
322
- PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
323
- return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
324
- }
325
- });
326
- function compose() {
327
- for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
328
- funcs[_key] = arguments[_key];
329
- }
330
- if (funcs.length === 0) {
331
- return function(arg) {
332
- return arg;
333
- };
334
- }
335
- if (funcs.length === 1) {
336
- return funcs[0];
337
- }
338
- return funcs.reduce(function(a, b) {
339
- return function() {
340
- return a(b.apply(void 0, arguments));
341
- };
342
- });
343
- }
344
- const VERSION_REDUCER_KEY$1 = "versioning";
345
- const latestVersion = () => migrations.length - 1;
346
- const initialVersioning = (state) => {
347
- state[VERSION_REDUCER_KEY$1] = { version: latestVersion() };
348
- return state;
349
- };
350
- const signOut = () => {
351
- return initialVersioning({});
352
- };
353
- const createOutboxState = (state) => {
354
- if (state.outboxReducer) {
355
- state.outboxReducer.deletedRequests = [];
356
- }
357
- return state;
358
- };
359
- const wrapMigration = (migrator) => (state) => {
360
- var _a2;
361
- if (state === void 0) {
362
- state = {};
363
- }
364
- if (((_a2 = state[VERSION_REDUCER_KEY$1]) == null ? void 0 : _a2.version) === latestVersion())
365
- return state;
366
- return migrator(state);
367
- };
368
- const migrations = [initialVersioning, signOut, signOut, createOutboxState];
369
- const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
370
- const initialState$B = {
371
- accessToken: "",
372
- refreshToken: "",
373
- isLoggedIn: false
374
- };
375
- const authSlice = toolkit.createSlice({
376
- name: "auth",
377
- initialState: initialState$B,
378
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
379
- reducers: {
380
- setTokens: (state, action) => {
381
- state.accessToken = action.payload.accessToken;
382
- state.refreshToken = action.payload.refreshToken;
383
- },
384
- clearTokens: (state) => {
385
- state.accessToken = "";
386
- state.refreshToken = "";
387
- },
388
- setLoggedIn: (state, action) => {
389
- if (!action.payload) {
390
- authSlice.caseReducers.clearTokens(state);
391
- }
392
- state.isLoggedIn = action.payload;
393
- }
394
- }
395
- });
396
- const { setTokens, clearTokens, setLoggedIn } = authSlice.actions;
397
- const selectAccessToken = (state) => state.authReducer.accessToken;
398
- const selectIsLoggedIn = (state) => state.authReducer.isLoggedIn;
399
- const authReducer = authSlice.reducer;
400
321
  const coordinatesToLiteral = (coordinates) => {
401
322
  return { lng: coordinates[0], lat: coordinates[1] };
402
323
  };
@@ -461,24 +382,6 @@ var __publicField = (obj, key, value) => {
461
382
  coordinates
462
383
  };
463
384
  };
464
- function classNames(...args) {
465
- const classes = [];
466
- for (const arg of args) {
467
- if (!arg) {
468
- continue;
469
- }
470
- if (typeof arg === "string") {
471
- classes.push(arg);
472
- } else if (typeof arg === "object") {
473
- for (const [key, value] of Object.entries(arg)) {
474
- if (value) {
475
- classes.push(key);
476
- }
477
- }
478
- }
479
- }
480
- return classes.join(" ");
481
- }
482
385
  function hex(buffer) {
483
386
  const hashArray = new Uint8Array(buffer);
484
387
  return hashArray.reduce((data, byte) => data + byte.toString(16).padStart(2, "0"), "");
@@ -591,14 +494,6 @@ var __publicField = (obj, key, value) => {
591
494
  }
592
495
  return asMapping;
593
496
  }
594
- const issueToSearchResult = (issue, tag) => {
595
- return {
596
- label: issue.title || "",
597
- typeLabel: "issue",
598
- tag,
599
- item: issue
600
- };
601
- };
602
497
  function toFileNameSafeString(str, extension = void 0, maxLength = 255) {
603
498
  let ret = str.replace(/[^a-z0-9_\-.]/gi, "_").replace(/_{2,}/g, "_");
604
499
  if (!extension) {
@@ -642,7 +537,6 @@ var __publicField = (obj, key, value) => {
642
537
  return bounds[0][0] > coordinates[0] && bounds[1][0] < coordinates[0] && bounds[0][1] > coordinates[1] && bounds[1][1] < coordinates[1];
643
538
  }
644
539
  const emailRegex = /^.+@.+\..+$/;
645
- const fullAssetMarkerSize = 45;
646
540
  const DEFAULT_ISSUE_STATUS = IssueStatus.BACKLOG;
647
541
  const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
648
542
  const OUTBOX_RETRY_DELAY = 6e4;
@@ -688,17 +582,6 @@ var __publicField = (obj, key, value) => {
688
582
  }
689
583
  };
690
584
  }
691
- function useMemoCompare(next, compare) {
692
- const previousRef = React.useRef(void 0);
693
- const previous = previousRef.current;
694
- const isEqual = compare(previous, next);
695
- React.useEffect(() => {
696
- if (!isEqual) {
697
- previousRef.current = next;
698
- }
699
- });
700
- return isEqual ? previous : next;
701
- }
702
585
  function areArraysEqual(first, second) {
703
586
  if (first.length !== second.length)
704
587
  return false;
@@ -708,7 +591,6 @@ var __publicField = (obj, key, value) => {
708
591
  }
709
592
  return true;
710
593
  }
711
- const genericMemo = React.memo;
712
594
  const fallbackToEmptyArray = (array) => {
713
595
  return array.length === 0 ? EMPTY_ARRAY : array;
714
596
  };
@@ -741,19 +623,6 @@ var __publicField = (obj, key, value) => {
741
623
  mint: colors.mint.mint9,
742
624
  sky: colors.sky.sky9
743
625
  };
744
- const AssetStageColors = {
745
- indigo: colors.indigo.indigo9,
746
- red: colors.red.red9,
747
- violet: colors.violet.violet9,
748
- yellow: colors.yellow.yellow9,
749
- jade: colors.jade.jade9,
750
- cyan: colors.cyan.cyan9,
751
- gold: colors.gold.gold9,
752
- orange: colors.orange.orange9,
753
- lime: colors.lime.lime9,
754
- sky: colors.sky.sky9,
755
- pink: colors.pink.pink9
756
- };
757
626
  const defaultBadgeColor = "#868686";
758
627
  const generateBadgeColors = (rawColor) => {
759
628
  const color = ColorCls(rawColor);
@@ -762,9 +631,6 @@ var __publicField = (obj, key, value) => {
762
631
  const textColor = color.hex() === safety.hex() ? "#000000" : "#FFFFFF";
763
632
  return { backgroundColor, textColor };
764
633
  };
765
- function getStageColor(index) {
766
- return Object.values(AssetStageColors)[index % Object.keys(AssetStageColors).length];
767
- }
768
634
  const getLocalDateString = memoize((date) => {
769
635
  if (!date)
770
636
  return "";
@@ -787,6 +653,130 @@ var __publicField = (obj, key, value) => {
787
653
  return getLocalDateString(date);
788
654
  return relative.format(days, "days");
789
655
  });
656
+ class DeferredPromise {
657
+ constructor() {
658
+ __publicField(this, _a, "Promise");
659
+ __publicField(this, "_promise");
660
+ __publicField(this, "_resolve");
661
+ __publicField(this, "_reject");
662
+ __publicField(this, "_state", "pending");
663
+ this._resolve = null;
664
+ this._reject = null;
665
+ this._promise = new Promise((resolve, reject) => {
666
+ this._resolve = resolve;
667
+ this._reject = reject;
668
+ });
669
+ }
670
+ get state() {
671
+ return this._state;
672
+ }
673
+ then(onFulfilled, onRejected) {
674
+ return this._promise.then(onFulfilled, onRejected);
675
+ }
676
+ catch(onRejected) {
677
+ return this._promise.catch(onRejected);
678
+ }
679
+ resolve(value) {
680
+ if (!this._resolve)
681
+ throw new Error("No resolve callback");
682
+ this._resolve(value);
683
+ this._state = "fulfilled";
684
+ }
685
+ reject(reason) {
686
+ if (!this._reject)
687
+ throw reason;
688
+ this._reject(reason);
689
+ this._state = "rejected";
690
+ }
691
+ finally(_onFinally) {
692
+ throw new Error("`finally` not implemented");
693
+ }
694
+ }
695
+ _a = Symbol.toStringTag;
696
+ var randomString = function randomString2() {
697
+ return Math.random().toString(36).substring(7).split("").join(".");
698
+ };
699
+ ({
700
+ INIT: "@@redux/INIT" + randomString(),
701
+ REPLACE: "@@redux/REPLACE" + randomString(),
702
+ PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
703
+ return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
704
+ }
705
+ });
706
+ function compose() {
707
+ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
708
+ funcs[_key] = arguments[_key];
709
+ }
710
+ if (funcs.length === 0) {
711
+ return function(arg) {
712
+ return arg;
713
+ };
714
+ }
715
+ if (funcs.length === 1) {
716
+ return funcs[0];
717
+ }
718
+ return funcs.reduce(function(a, b) {
719
+ return function() {
720
+ return a(b.apply(void 0, arguments));
721
+ };
722
+ });
723
+ }
724
+ const VERSION_REDUCER_KEY$1 = "versioning";
725
+ const latestVersion = () => migrations.length - 1;
726
+ const initialVersioning = (state) => {
727
+ state[VERSION_REDUCER_KEY$1] = { version: latestVersion() };
728
+ return state;
729
+ };
730
+ const signOut = () => {
731
+ return initialVersioning({});
732
+ };
733
+ const createOutboxState = (state) => {
734
+ if (state.outboxReducer) {
735
+ state.outboxReducer.deletedRequests = [];
736
+ }
737
+ return state;
738
+ };
739
+ const wrapMigration = (migrator) => (state) => {
740
+ var _a2;
741
+ if (state === void 0) {
742
+ state = {};
743
+ }
744
+ if (((_a2 = state[VERSION_REDUCER_KEY$1]) == null ? void 0 : _a2.version) === latestVersion())
745
+ return state;
746
+ return migrator(state);
747
+ };
748
+ const migrations = [initialVersioning, signOut, signOut, createOutboxState];
749
+ const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
750
+ const initialState$B = {
751
+ accessToken: "",
752
+ refreshToken: "",
753
+ isLoggedIn: false
754
+ };
755
+ const authSlice = toolkit.createSlice({
756
+ name: "auth",
757
+ initialState: initialState$B,
758
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
759
+ reducers: {
760
+ setTokens: (state, action) => {
761
+ state.accessToken = action.payload.accessToken;
762
+ state.refreshToken = action.payload.refreshToken;
763
+ },
764
+ clearTokens: (state) => {
765
+ state.accessToken = "";
766
+ state.refreshToken = "";
767
+ },
768
+ setLoggedIn: (state, action) => {
769
+ if (!action.payload) {
770
+ authSlice.caseReducers.clearTokens(state);
771
+ }
772
+ state.isLoggedIn = action.payload;
773
+ }
774
+ }
775
+ });
776
+ const { setTokens, clearTokens, setLoggedIn } = authSlice.actions;
777
+ const selectAccessToken = (state) => state.authReducer.accessToken;
778
+ const selectIsLoggedIn = (state) => state.authReducer.isLoggedIn;
779
+ const authReducer = authSlice.reducer;
790
780
  function createModelAdapter(computeModelId) {
791
781
  const addOne = (state, action) => {
792
782
  const id = computeModelId(action.payload);
@@ -1019,61 +1009,72 @@ var __publicField = (obj, key, value) => {
1019
1009
  )
1020
1010
  );
1021
1011
  const assetAttachmentReducer = assetAttachmentSlice.reducer;
1022
- const initialState$x = {
1023
- completionsByAssetId: {}
1024
- };
1012
+ const assetStageCompletionAdapter = createModelAdapter(
1013
+ (stageCompletion) => stageCompletion.offline_id
1014
+ );
1015
+ const initialState$x = assetStageCompletionAdapter.getInitialState({});
1025
1016
  const assetStageCompletionSlice = toolkit.createSlice({
1026
1017
  name: "assetStageCompletions",
1027
1018
  initialState: initialState$x,
1028
1019
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1029
1020
  reducers: {
1030
- addStageCompletion: (state, action) => {
1031
- let stageToCompletionDateMapping = state.completionsByAssetId[action.payload.asset];
1032
- if (!stageToCompletionDateMapping) {
1033
- stageToCompletionDateMapping = {};
1034
- state.completionsByAssetId[action.payload.asset] = stageToCompletionDateMapping;
1035
- }
1036
- stageToCompletionDateMapping[action.payload.stage] = (/* @__PURE__ */ new Date()).toISOString();
1037
- },
1038
- addStageCompletions: (state, action) => {
1039
- for (const [assetId, stageIdToCompletionDateMapping] of Object.entries(action.payload)) {
1040
- if (Object.keys(stageIdToCompletionDateMapping).length === 0)
1041
- throw new Error(`Encountered empty stageIdToCompletionDateMapping argument for asset ${assetId}`);
1042
- let thisAssetCompletions = state.completionsByAssetId[assetId];
1043
- if (thisAssetCompletions === void 0) {
1044
- thisAssetCompletions = {};
1045
- }
1046
- for (const [stageId, completionDate] of Object.entries(stageIdToCompletionDateMapping)) {
1047
- thisAssetCompletions[stageId] = completionDate;
1048
- }
1049
- state.completionsByAssetId[assetId] = thisAssetCompletions;
1050
- }
1051
- },
1052
- removeStageCompletions: (state, action) => {
1053
- for (const completion of action.payload) {
1054
- const thisAssetCompletions = state.completionsByAssetId[completion.asset];
1055
- if (!thisAssetCompletions || !(completion.stage in thisAssetCompletions)) {
1056
- console.warn(
1057
- "Skipping removal of uncompleted stage. This message indicates completion objects are created unnecessarily."
1058
- );
1059
- continue;
1060
- }
1061
- delete thisAssetCompletions[completion.stage];
1062
- }
1063
- },
1064
- setStageCompletions: (state, action) => {
1065
- state.completionsByAssetId = action.payload;
1066
- }
1021
+ initializeAssetStageCompletions: assetStageCompletionAdapter.initialize,
1022
+ addAssetStageCompletion: assetStageCompletionAdapter.addOne,
1023
+ addAssetStageCompletions: assetStageCompletionAdapter.addMany,
1024
+ updateAssetStageCompletion: assetStageCompletionAdapter.updateOne,
1025
+ updateAssetStageCompletions: assetStageCompletionAdapter.updateMany,
1026
+ deleteAssetStageCompletion: assetStageCompletionAdapter.deleteOne,
1027
+ deleteAssetStageCompletions: assetStageCompletionAdapter.deleteMany
1067
1028
  }
1068
1029
  });
1069
- const { addStageCompletion, addStageCompletions, removeStageCompletions, setStageCompletions } = assetStageCompletionSlice.actions;
1070
- const selectCompletedStages = (state) => {
1071
- return state.assetStageCompletionReducer.completionsByAssetId;
1030
+ const {
1031
+ initializeAssetStageCompletions,
1032
+ addAssetStageCompletion,
1033
+ addAssetStageCompletions,
1034
+ updateAssetStageCompletion,
1035
+ updateAssetStageCompletions,
1036
+ deleteAssetStageCompletion,
1037
+ deleteAssetStageCompletions
1038
+ } = assetStageCompletionSlice.actions;
1039
+ const selectAssetStageCompletionMapping = (state) => {
1040
+ return state.assetStageCompletionReducer.instances;
1072
1041
  };
1042
+ const selectCompletedStagesByAsset = toolkit.createSelector(
1043
+ [selectAssetStageCompletionMapping],
1044
+ (completedStagesMapping) => {
1045
+ const completedStagesByAsset = {};
1046
+ for (const stageCompletion of Object.values(completedStagesMapping)) {
1047
+ const { asset, stage, submitted_at } = stageCompletion;
1048
+ if (!completedStagesByAsset[asset])
1049
+ completedStagesByAsset[asset] = {};
1050
+ completedStagesByAsset[asset][stage] = submitted_at;
1051
+ }
1052
+ return completedStagesByAsset;
1053
+ }
1054
+ );
1073
1055
  const selectCompletedStageIdsForAsset = restructureCreateSelectorWithArgs(
1074
- toolkit.createSelector([selectCompletedStages, (_state, asset) => asset], (completedStages, asset) => {
1075
- return Object.keys(completedStages[asset.offline_id] ?? {});
1076
- })
1056
+ toolkit.createSelector(
1057
+ [selectAssetStageCompletionMapping, (_state, asset) => asset],
1058
+ (completedStages, asset) => {
1059
+ return Object.keys(completedStages[asset.offline_id] ?? {});
1060
+ }
1061
+ )
1062
+ );
1063
+ const selectAssetStageCompletionById = (id) => (state) => {
1064
+ return state.assetStageCompletionReducer.instances[id];
1065
+ };
1066
+ const selectAssetStageCompletionsByIds = restructureCreateSelectorWithArgs(
1067
+ toolkit.createSelector(
1068
+ [selectAssetStageCompletionMapping, (_, stageCompletionIds) => stageCompletionIds],
1069
+ (stageCompletionMapping, stageCompletionIds) => {
1070
+ const stageCompletionIdsSet = new Set(stageCompletionIds);
1071
+ return fallbackToEmptyArray(
1072
+ Object.values(stageCompletionMapping).filter(
1073
+ (stageCompletion) => stageCompletionIdsSet.has(stageCompletion.offline_id)
1074
+ )
1075
+ );
1076
+ }
1077
+ )
1077
1078
  );
1078
1079
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1079
1080
  const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
@@ -1083,14 +1084,29 @@ var __publicField = (obj, key, value) => {
1083
1084
  initialState: initialState$w,
1084
1085
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1085
1086
  reducers: {
1086
- initializeStages: assetStageAdapter.initialize,
1087
- setStage: assetStageAdapter.setOne,
1088
- addStages: assetStageAdapter.addMany,
1089
- updateStage: assetStageAdapter.updateOne,
1090
- updateStages: assetStageAdapter.updateMany,
1091
- removeStages: assetStageAdapter.deleteMany
1087
+ initializeAssetStages: assetStageAdapter.initialize,
1088
+ setAssetStage: assetStageAdapter.setOne,
1089
+ setAssetStages: assetStageAdapter.setMany,
1090
+ addAssetStage: assetStageAdapter.addOne,
1091
+ addAssetStages: assetStageAdapter.addMany,
1092
+ updateAssetStage: assetStageAdapter.updateOne,
1093
+ updateAssetStages: assetStageAdapter.updateMany,
1094
+ deleteAssetStage: assetStageAdapter.deleteOne,
1095
+ deleteAssetStages: assetStageAdapter.deleteMany
1092
1096
  }
1093
1097
  });
1098
+ const {
1099
+ initializeAssetStages,
1100
+ setAssetStage,
1101
+ setAssetStages,
1102
+ addAssetStage,
1103
+ addAssetStages,
1104
+ updateAssetStage,
1105
+ updateAssetStages,
1106
+ deleteAssetStage,
1107
+ deleteAssetStages
1108
+ } = assetStageSlice.actions;
1109
+ const assetStageReducer = assetStageSlice.reducer;
1094
1110
  const selectStageMapping = (state) => state.assetStageReducer.instances;
1095
1111
  const selectAssetStageById = (id) => (state) => {
1096
1112
  return state.assetStageReducer.instances[id];
@@ -1098,24 +1114,6 @@ var __publicField = (obj, key, value) => {
1098
1114
  const selectAssetStages = toolkit.createSelector([selectStageMapping], (stageMapping) => {
1099
1115
  return Object.values(stageMapping);
1100
1116
  });
1101
- const selectStagesFromAssetTypeIds = restructureCreateSelectorWithArgs(
1102
- toolkit.createSelector([selectAssetStages, (_state, assetTypeIds) => assetTypeIds], (stages, assetTypeIds) => {
1103
- const assetTypeIdsSet = new Set(assetTypeIds);
1104
- const ret = {};
1105
- for (const stage of stages) {
1106
- if (assetTypeIdsSet.has(stage.asset_type)) {
1107
- if (!ret[stage.asset_type]) {
1108
- ret[stage.asset_type] = [];
1109
- }
1110
- ret[stage.asset_type].push(stage);
1111
- }
1112
- }
1113
- for (const key in ret) {
1114
- ret[key] = ret[key].sort((a, b) => a.priority - b.priority);
1115
- }
1116
- return ret;
1117
- })
1118
- );
1119
1117
  const selectAssetTypeStagesMapping = restructureCreateSelectorWithArgs(
1120
1118
  toolkit.createSelector([selectStageMapping, (_state, assetTypeId) => assetTypeId], (stagesMapping, assetTypeId) => {
1121
1119
  const assetTypeStagesMapping = {};
@@ -1163,8 +1161,6 @@ var __publicField = (obj, key, value) => {
1163
1161
  return ret;
1164
1162
  })
1165
1163
  );
1166
- const { initializeStages, setStage, addStages, updateStages, removeStages, updateStage } = assetStageSlice.actions;
1167
- const assetStageReducer = assetStageSlice.reducer;
1168
1164
  const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
1169
1165
  const initialState$v = assetTypeAdapter.getInitialState({});
1170
1166
  const assetTypeSlice = toolkit.createSlice({
@@ -1173,11 +1169,27 @@ var __publicField = (obj, key, value) => {
1173
1169
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1174
1170
  reducers: {
1175
1171
  initializeAssetTypes: assetTypeAdapter.initialize,
1172
+ setAssetType: assetTypeAdapter.setOne,
1173
+ setAssetTypes: assetTypeAdapter.setMany,
1176
1174
  addAssetType: assetTypeAdapter.addOne,
1177
- deleteAssetType: assetTypeAdapter.deleteOne
1175
+ addAssetTypes: assetTypeAdapter.addMany,
1176
+ updateAssetType: assetTypeAdapter.updateOne,
1177
+ updateAssetTypes: assetTypeAdapter.updateMany,
1178
+ deleteAssetType: assetTypeAdapter.deleteOne,
1179
+ deleteAssetTypes: assetTypeAdapter.deleteMany
1178
1180
  }
1179
1181
  });
1180
- const { addAssetType, initializeAssetTypes, deleteAssetType } = assetTypeSlice.actions;
1182
+ const {
1183
+ initializeAssetTypes,
1184
+ setAssetType,
1185
+ setAssetTypes,
1186
+ addAssetType,
1187
+ addAssetTypes,
1188
+ updateAssetType,
1189
+ updateAssetTypes,
1190
+ deleteAssetType,
1191
+ deleteAssetTypes
1192
+ } = assetTypeSlice.actions;
1181
1193
  const selectAssetTypesMapping = (state) => state.assetTypeReducer.instances;
1182
1194
  const selectAssetTypes = toolkit.createSelector(
1183
1195
  [selectAssetTypesMapping],
@@ -1404,60 +1416,6 @@ var __publicField = (obj, key, value) => {
1404
1416
  return url;
1405
1417
  };
1406
1418
  const fileReducer = fileSlice.reducer;
1407
- var ProjectAccessLevel = /* @__PURE__ */ ((ProjectAccessLevel2) => {
1408
- ProjectAccessLevel2[ProjectAccessLevel2["BASIC"] = 0] = "BASIC";
1409
- ProjectAccessLevel2[ProjectAccessLevel2["ADMIN"] = 2] = "ADMIN";
1410
- return ProjectAccessLevel2;
1411
- })(ProjectAccessLevel || {});
1412
- var OrganizationAccessLevel = /* @__PURE__ */ ((OrganizationAccessLevel2) => {
1413
- OrganizationAccessLevel2[OrganizationAccessLevel2["BASIC"] = 0] = "BASIC";
1414
- OrganizationAccessLevel2[OrganizationAccessLevel2["ADMIN"] = 2] = "ADMIN";
1415
- return OrganizationAccessLevel2;
1416
- })(OrganizationAccessLevel || {});
1417
- var AttachmentModel = /* @__PURE__ */ ((AttachmentModel2) => {
1418
- AttachmentModel2["Issue"] = "issue";
1419
- AttachmentModel2["Asset"] = "asset";
1420
- AttachmentModel2["AssetType"] = "asset_type";
1421
- AttachmentModel2["Project"] = "project";
1422
- AttachmentModel2["Document"] = "document";
1423
- return AttachmentModel2;
1424
- })(AttachmentModel || {});
1425
- var IssueUpdateChange = /* @__PURE__ */ ((IssueUpdateChange2) => {
1426
- IssueUpdateChange2["STATUS"] = "status";
1427
- IssueUpdateChange2["PRIORITY"] = "priority";
1428
- IssueUpdateChange2["CATEGORY"] = "category";
1429
- IssueUpdateChange2["DESCRIPTION"] = "description";
1430
- IssueUpdateChange2["TITLE"] = "title";
1431
- IssueUpdateChange2["ASSIGNED_TO"] = "assigned_to";
1432
- IssueUpdateChange2["DUE_DATE"] = "due_date";
1433
- return IssueUpdateChange2;
1434
- })(IssueUpdateChange || {});
1435
- var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
1436
- VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
1437
- VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
1438
- VerificationCodeType2[VerificationCodeType2["PROJECT_INVITE"] = 4] = "PROJECT_INVITE";
1439
- VerificationCodeType2[VerificationCodeType2["ORGANIZATION_INVITE"] = 6] = "ORGANIZATION_INVITE";
1440
- VerificationCodeType2[VerificationCodeType2["ADD_EMAIL_DOMAIN"] = 8] = "ADD_EMAIL_DOMAIN";
1441
- VerificationCodeType2[VerificationCodeType2["RESET_PASSWORD"] = 10] = "RESET_PASSWORD";
1442
- return VerificationCodeType2;
1443
- })(VerificationCodeType || {});
1444
- var PaddleCheckoutEvent = /* @__PURE__ */ ((PaddleCheckoutEvent2) => {
1445
- PaddleCheckoutEvent2["COMPLETED"] = "checkout.completed";
1446
- PaddleCheckoutEvent2["CLOSED"] = "checkout.closed";
1447
- return PaddleCheckoutEvent2;
1448
- })(PaddleCheckoutEvent || {});
1449
- var LicenseLevel = /* @__PURE__ */ ((LicenseLevel2) => {
1450
- LicenseLevel2[LicenseLevel2["PRO"] = 0] = "PRO";
1451
- return LicenseLevel2;
1452
- })(LicenseLevel || {});
1453
- var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
1454
- LicenseStatus2[LicenseStatus2["ACTIVE"] = 0] = "ACTIVE";
1455
- LicenseStatus2[LicenseStatus2["PAUSED"] = 2] = "PAUSED";
1456
- LicenseStatus2[LicenseStatus2["CANCELLED"] = 4] = "CANCELLED";
1457
- LicenseStatus2[LicenseStatus2["INACTIVE"] = 6] = "INACTIVE";
1458
- LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
1459
- return LicenseStatus2;
1460
- })(LicenseStatus || {});
1461
1419
  const initialState$q = {
1462
1420
  users: {},
1463
1421
  currentUser: null
@@ -3956,53 +3914,81 @@ var __publicField = (obj, key, value) => {
3956
3914
  }
3957
3915
  class AssetService extends BaseApiService {
3958
3916
  // Basic CRUD functions
3959
- add(asset, workspaceId) {
3960
- if (!asset.canvas_marker && !asset.geo_marker) {
3917
+ add(payload) {
3918
+ const { store } = this.client;
3919
+ if (!payload.canvas_marker && !payload.geo_marker) {
3961
3920
  throw new Error("Asset must have either a canvas_marker or geo_marker");
3962
3921
  }
3963
- const offlineAsset = offline(asset);
3922
+ const createdBy = store.getState().userReducer.currentUser.id;
3923
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
3924
+ const offlineAsset = offline({
3925
+ ...payload,
3926
+ created_by: createdBy,
3927
+ submitted_at: submittedAt
3928
+ });
3964
3929
  this.dispatch(addAsset(offlineAsset));
3965
3930
  const promise = this.enqueueRequest({
3966
3931
  description: "Create asset",
3967
3932
  method: HttpMethod.POST,
3968
- url: `/assets/types/${offlineAsset.asset_type}/add-assets/`,
3969
- queryParams: {
3970
- workspace_id: workspaceId.toString()
3933
+ url: "/assets/",
3934
+ payload: {
3935
+ offline_id: offlineAsset.offline_id,
3936
+ submitted_at: offlineAsset.submitted_at,
3937
+ geo_marker: offlineAsset.geo_marker,
3938
+ canvas_marker: offlineAsset.canvas_marker,
3939
+ label: offlineAsset.label,
3940
+ description: offlineAsset.description,
3941
+ asset_type: offlineAsset.asset_type
3971
3942
  },
3972
- payload: { assets: [offlineAsset] },
3973
- blockers: [],
3943
+ blockers: [offlineAsset.asset_type],
3974
3944
  blocks: [offlineAsset.offline_id]
3975
3945
  });
3946
+ promise.then((createdAsset) => {
3947
+ this.dispatch(updateAsset(createdAsset));
3948
+ }).catch(() => {
3949
+ this.dispatch(deleteAsset(offlineAsset.offline_id));
3950
+ });
3976
3951
  return [offlineAsset, promise];
3977
3952
  }
3978
- update(asset, workspaceId) {
3979
- if (!asset.canvas_marker && !asset.geo_marker) {
3953
+ update(payload) {
3954
+ const { store } = this.client;
3955
+ if (!payload.canvas_marker && !payload.geo_marker) {
3980
3956
  throw new Error("Asset must have either a canvas_marker or geo_marker");
3981
3957
  }
3982
- this.client.store.dispatch(updateAsset(asset));
3958
+ const asset = selectAssetById(payload.offline_id)(store.getState());
3959
+ if (!asset) {
3960
+ throw new Error(`No asset with id ${payload.offline_id} found in the store`);
3961
+ }
3962
+ const updatedAsset = {
3963
+ ...asset,
3964
+ ...payload
3965
+ };
3966
+ this.dispatch(updateAsset(updatedAsset));
3983
3967
  const promise = this.enqueueRequest({
3984
3968
  description: "Edit asset",
3985
3969
  method: HttpMethod.PATCH,
3986
- url: `/assets/${asset.offline_id}/`,
3987
- queryParams: {
3988
- workspace_id: workspaceId.toString()
3989
- },
3990
- payload: asset,
3991
- blockers: [asset.offline_id],
3992
- blocks: [asset.offline_id]
3970
+ url: `/assets/${payload.offline_id}/`,
3971
+ payload,
3972
+ blockers: [payload.offline_id],
3973
+ blocks: [payload.offline_id]
3974
+ });
3975
+ promise.then((result) => {
3976
+ this.dispatch(updateAsset(result));
3977
+ }).catch(() => {
3978
+ this.dispatch(updateAsset(asset));
3993
3979
  });
3994
- return [asset, promise];
3980
+ return [updatedAsset, promise];
3995
3981
  }
3996
- async remove(assetId) {
3982
+ async remove(id) {
3997
3983
  const { store } = this.client;
3998
3984
  const state = store.getState();
3999
- const assetToBeDeleted = selectAssetById(assetId)(state);
3985
+ const assetToBeDeleted = selectAssetById(id)(state);
4000
3986
  if (!assetToBeDeleted)
4001
- throw new Error(`No asset with id ${assetId} found in the store`);
4002
- const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(state);
4003
- const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(state);
4004
- const issueAssociations = selectIssueAssociationsOfAsset(assetId)(state);
4005
- this.dispatch(deleteAsset(assetId));
3987
+ throw new Error(`No asset with id ${id} found in the store`);
3988
+ const attachmentsOfAssets = selectAttachmentsOfAsset(id)(state);
3989
+ const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(id)(state);
3990
+ const issueAssociations = selectIssueAssociationsOfAsset(id)(state);
3991
+ this.dispatch(deleteAsset(id));
4006
3992
  if (attachmentsOfAssets.length > 0) {
4007
3993
  const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
4008
3994
  this.dispatch(deleteAssetAttachments(attachmentsOfAssetIds));
@@ -4018,8 +4004,8 @@ var __publicField = (obj, key, value) => {
4018
4004
  return this.enqueueRequest({
4019
4005
  description: "Delete asset",
4020
4006
  method: HttpMethod.DELETE,
4021
- url: `/assets/${assetId}/`,
4022
- blockers: [assetId],
4007
+ url: `/assets/${id}/`,
4008
+ blockers: [id],
4023
4009
  blocks: []
4024
4010
  }).catch((err) => {
4025
4011
  this.dispatch(addAsset(assetToBeDeleted));
@@ -4029,39 +4015,17 @@ var __publicField = (obj, key, value) => {
4029
4015
  throw err;
4030
4016
  });
4031
4017
  }
4032
- async deleteAllAssetsOfAssetType(assetTypeId) {
4033
- const { store } = this.client;
4034
- const state = store.getState();
4035
- const allAssetsOfAssetType = selectAssetsOfAssetType(assetTypeId)(state);
4036
- const allAssetsOfAssetTypeIds = allAssetsOfAssetType.map((c) => c.offline_id);
4037
- const affectedOfflineIds = [assetTypeId, ...allAssetsOfAssetTypeIds];
4038
- store.dispatch(deleteAssets(allAssetsOfAssetTypeIds));
4039
- return this.enqueueRequest({
4040
- description: "Delete all assets of asset type",
4041
- method: HttpMethod.DELETE,
4042
- url: `/assets/types/${assetTypeId}/delete-all-of-type/`,
4043
- blockers: affectedOfflineIds,
4044
- blocks: affectedOfflineIds
4045
- }).catch((err) => {
4046
- store.dispatch(addAssets(allAssetsOfAssetType));
4047
- throw err;
4048
- });
4049
- }
4050
- // TODO: payload does not require asset_type
4051
- bulkAdd(assetsToCreate, workspaceId, assetTypeId, batchSize) {
4018
+ bulkAdd(payloads, assetTypeId, batchSize) {
4052
4019
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4053
4020
  const transactionId = uuid.v4();
4054
- const assetBatches = chunkArray(assetsToCreate, batchSize).map((assetBatch) => {
4055
- const assetPayloads = assetBatch.map((assetPayload) => {
4056
- return offline({
4057
- ...assetPayload,
4058
- submitted_at: submittedAt
4059
- });
4060
- });
4021
+ const assetBatches = chunkArray(payloads, batchSize).map((assetBatch) => {
4022
+ const assetPayloads = assetBatch.map((assetPayload) => offline(assetPayload));
4061
4023
  return {
4062
4024
  batchId: uuid.v4(),
4063
4025
  payload: {
4064
4026
  transaction_id: transactionId,
4027
+ submitted_at: submittedAt,
4028
+ asset_type: assetTypeId,
4065
4029
  assets: assetPayloads
4066
4030
  }
4067
4031
  };
@@ -4079,10 +4043,7 @@ var __publicField = (obj, key, value) => {
4079
4043
  const promise = this.enqueueRequest({
4080
4044
  description: "Batch create assets",
4081
4045
  method: HttpMethod.POST,
4082
- url: `/assets/types/${assetTypeId}/add-assets/`,
4083
- queryParams: {
4084
- workspace_id: workspaceId.toString()
4085
- },
4046
+ url: "/assets/bulk/",
4086
4047
  payload,
4087
4048
  blockers,
4088
4049
  blocks: blocks2
@@ -4108,117 +4069,152 @@ var __publicField = (obj, key, value) => {
4108
4069
  }
4109
4070
  }
4110
4071
  class AssetStageCompletionService extends BaseApiService {
4111
- add(assetId, stageId) {
4112
- var _a2;
4072
+ add(payload) {
4113
4073
  const { store } = this.client;
4114
- const assetTypeId = (_a2 = selectAssetById(assetId)(store.getState())) == null ? void 0 : _a2.asset_type;
4115
- if (!assetTypeId) {
4116
- throw new Error(`Asset with offline_id ${assetId} not found`);
4117
- }
4074
+ const createdBy = store.getState().userReducer.currentUser.id;
4075
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4118
4076
  const offlineStageCompletion = offline({
4119
- asset: assetId,
4120
- stage: stageId
4077
+ ...payload,
4078
+ created_by: createdBy,
4079
+ submitted_at: submittedAt
4121
4080
  });
4122
- this.dispatch(addStageCompletion(offlineStageCompletion));
4081
+ this.dispatch(addAssetStageCompletion(offlineStageCompletion));
4123
4082
  const promise = this.enqueueRequest({
4124
- description: "Complete stage",
4083
+ description: "Add asset stage completion",
4125
4084
  method: HttpMethod.POST,
4126
- url: `/assets/types/${assetTypeId}/complete-stages/`,
4127
- // TODO: Add submitted_at to model
4128
- payload: { completions: [{ ...offlineStageCompletion, submitted_at: (/* @__PURE__ */ new Date()).getTime() / 1e3 }] },
4129
- blockers: [assetId, stageId],
4085
+ url: "/assets/completions/",
4086
+ payload: {
4087
+ offline_id: offlineStageCompletion.offline_id,
4088
+ submitted_at: submittedAt,
4089
+ asset: payload.asset,
4090
+ stage: payload.stage
4091
+ },
4092
+ blockers: [payload.asset, payload.stage],
4130
4093
  blocks: [offlineStageCompletion.offline_id]
4131
4094
  });
4095
+ promise.then((result) => {
4096
+ this.dispatch(updateAssetStageCompletion(result));
4097
+ }).catch(() => {
4098
+ this.dispatch(deleteAssetStageCompletion(offlineStageCompletion.offline_id));
4099
+ });
4132
4100
  return [offlineStageCompletion, promise];
4133
4101
  }
4134
- async refreshStore(projectId) {
4135
- const result = await this.enqueueRequest({
4136
- description: "Get stage completions",
4137
- method: HttpMethod.GET,
4138
- url: `/projects/${projectId}/asset-stage-completions/`,
4139
- blockers: [],
4102
+ delete(id) {
4103
+ const { store } = this.client;
4104
+ const assetStageCompletion = selectAssetStageCompletionById(id)(store.getState());
4105
+ if (!assetStageCompletion) {
4106
+ throw new Error(`Expected asset stage completion with id ${id} to exist`);
4107
+ }
4108
+ this.dispatch(deleteAssetStageCompletion(id));
4109
+ const promise = this.enqueueRequest({
4110
+ description: "Delete asset stage completion",
4111
+ method: HttpMethod.DELETE,
4112
+ url: `/assets/completions/${id}/`,
4113
+ blockers: [id],
4140
4114
  blocks: []
4141
4115
  });
4142
- this.dispatch(addStageCompletions(result));
4116
+ promise.catch(() => {
4117
+ this.dispatch(addAssetStageCompletion(assetStageCompletion));
4118
+ });
4119
+ return promise;
4143
4120
  }
4144
- /**
4145
- * Creates a collection of AssetStageCompletions, marking the referenced stages as completed for the referenced
4146
- * assets. It's REQUIRED that all assets referenced all have the SAME asset type.
4147
- * @param assetTypeId The ID of the asset type for which we are completing stages (we can only complete
4148
- * stages for one asset type at a time)
4149
- * @param stageCompletions
4150
- */
4151
- async bulkAdd(assetTypeId, stageCompletions) {
4152
- const offlineStageCompletions = stageCompletions.map((completion) => {
4153
- return offline(completion);
4154
- });
4155
- const asMapping = {};
4156
- for (const completion of stageCompletions) {
4157
- const stageToCompletionDateMapping = asMapping[completion.asset] || {};
4158
- stageToCompletionDateMapping[completion.stage] = (/* @__PURE__ */ new Date()).toISOString();
4159
- asMapping[completion.asset] = stageToCompletionDateMapping;
4160
- }
4161
- this.dispatch(addStageCompletions(asMapping));
4162
- await this.enqueueRequest({
4163
- description: "Bulk complete stages",
4121
+ bulkAdd(payloads) {
4122
+ const { store } = this.client;
4123
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4124
+ const createdBy = store.getState().userReducer.currentUser.id;
4125
+ const payload = payloads.map((payload2) => offline(payload2));
4126
+ const offlineStageCompletions = payload.map((completion) => {
4127
+ return {
4128
+ ...completion,
4129
+ created_by: createdBy,
4130
+ submitted_at: submittedAt
4131
+ };
4132
+ });
4133
+ const offlineIds = offlineStageCompletions.map(({ offline_id }) => offline_id);
4134
+ this.dispatch(addAssetStageCompletions(offlineStageCompletions));
4135
+ const promise = this.enqueueRequest({
4136
+ description: "Bulk create asset stage completions",
4164
4137
  method: HttpMethod.POST,
4165
- url: `/assets/types/${assetTypeId}/complete-stages/`,
4138
+ url: "/assets/completions/bulk/",
4166
4139
  payload: {
4167
- completions: offlineStageCompletions
4140
+ submitted_at: submittedAt,
4141
+ completions: payload
4168
4142
  },
4169
- blockers: [assetTypeId, ...stageCompletions.map((c) => c.asset), ...stageCompletions.map((c) => c.stage)],
4170
- blocks: offlineStageCompletions.map((c) => c.offline_id)
4143
+ blockers: [...payloads.map((c) => c.asset), ...payloads.map((c) => c.stage)],
4144
+ blocks: offlineIds
4171
4145
  });
4172
- }
4173
- bulkDelete(stageId, assetIds) {
4174
- const stageCompletionsToRemove = assetIds.map((assetId) => {
4175
- return {
4176
- asset: assetId,
4177
- stage: stageId
4178
- };
4146
+ promise.then((result) => {
4147
+ this.dispatch(updateAssetStageCompletions(result));
4148
+ }).catch(() => {
4149
+ this.dispatch(deleteAssetStageCompletions(offlineIds));
4179
4150
  });
4180
- this.dispatch(removeStageCompletions(stageCompletionsToRemove));
4181
- return this.enqueueRequest({
4182
- description: `Undo stage for ${assetIds.length} assets(s)`,
4183
- // TODO: Rename to setCompletedStages
4151
+ return [offlineStageCompletions, promise];
4152
+ }
4153
+ bulkDelete(ids) {
4154
+ const { store } = this.client;
4155
+ const assetStageCompletions = selectAssetStageCompletionsByIds(ids)(store.getState());
4156
+ this.dispatch(deleteAssetStageCompletions(ids));
4157
+ const promise = this.enqueueRequest({
4158
+ description: "Deleting asset stage completions",
4184
4159
  method: HttpMethod.DELETE,
4185
- url: `/assets/stages/${stageId}/undo-stages/`,
4160
+ url: "/assets/completions/bulk/",
4186
4161
  payload: {
4187
- assets: assetIds
4162
+ completion_ids: ids
4188
4163
  },
4189
- blockers: [stageId, ...assetIds],
4164
+ blockers: ids,
4165
+ blocks: []
4166
+ });
4167
+ promise.catch(() => {
4168
+ this.dispatch(addAssetStageCompletions(assetStageCompletions));
4169
+ });
4170
+ return promise;
4171
+ }
4172
+ async refreshStore(projectId) {
4173
+ const result = await this.enqueueRequest({
4174
+ description: "Get asset stage completions",
4175
+ method: HttpMethod.GET,
4176
+ url: `/projects/${projectId}/asset-stage-completions/`,
4177
+ blockers: [],
4190
4178
  blocks: []
4191
4179
  });
4180
+ this.dispatch(initializeAssetStageCompletions(result));
4192
4181
  }
4193
4182
  }
4194
4183
  class AssetStageService extends BaseApiService {
4195
- async bulkCreateStages(stagesToSubmit, assetTypeId, workspaceId) {
4184
+ bulkAdd(stagesToSubmit, assetTypeId) {
4185
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4186
+ const createdBy = this.client.store.getState().userReducer.currentUser.id;
4196
4187
  const payload = stagesToSubmit.map((stage) => {
4197
4188
  return offline(stage);
4198
4189
  });
4199
- const fullStages = payload.map((stage) => {
4200
- return { ...stage, asset_type: assetTypeId };
4190
+ const offlineStages = payload.map((stage) => {
4191
+ return { ...stage, asset_type: assetTypeId, created_by: createdBy, submitted_at: submittedAt };
4201
4192
  });
4202
- this.dispatch(addStages(fullStages));
4203
- return this.enqueueRequest({
4193
+ this.dispatch(addAssetStages(offlineStages));
4194
+ const promise = this.enqueueRequest({
4204
4195
  description: "Add asset stages",
4205
4196
  method: HttpMethod.POST,
4206
- url: `/assets/types/${assetTypeId}/add-stages/`,
4197
+ url: "/assets/stages/bulk/",
4207
4198
  payload: {
4199
+ submitted_at: submittedAt,
4200
+ asset_type: assetTypeId,
4208
4201
  stages: payload
4209
4202
  },
4210
- queryParams: {
4211
- workspace_id: workspaceId.toString()
4212
- },
4213
- blockers: [assetTypeId, workspaceId],
4203
+ blockers: [assetTypeId],
4214
4204
  blocks: payload.map(({ offline_id }) => offline_id)
4215
4205
  });
4206
+ promise.then((result) => {
4207
+ this.dispatch(updateAssetStages(result));
4208
+ }).catch(() => {
4209
+ this.dispatch(deleteAssetStages(offlineStages.map(({ offline_id }) => offline_id)));
4210
+ });
4211
+ return [offlineStages, promise];
4216
4212
  }
4217
- async bulkUpdateStages(stagesToUpdate, assetTypeId) {
4213
+ async bulkUpdate(stagesToUpdate, assetTypeId) {
4218
4214
  const store = this.client.store;
4219
4215
  const state = store.getState();
4220
4216
  const prevStages = selectAssetStagesByIds(stagesToUpdate.map(({ offline_id }) => offline_id))(state);
4221
- this.dispatch(updateStages(stagesToUpdate));
4217
+ this.dispatch(updateAssetStages(stagesToUpdate));
4222
4218
  return this.enqueueRequest({
4223
4219
  description: "Edit asset stages",
4224
4220
  method: HttpMethod.PATCH,
@@ -4229,33 +4225,58 @@ var __publicField = (obj, key, value) => {
4229
4225
  blockers: [assetTypeId],
4230
4226
  blocks: stagesToUpdate.map(({ offline_id }) => offline_id)
4231
4227
  }).catch((e) => {
4232
- store.dispatch(updateStages(prevStages));
4228
+ this.dispatch(updateAssetStages(prevStages));
4233
4229
  throw e;
4234
4230
  });
4235
4231
  }
4236
4232
  async bulkDelete(idsToDelete) {
4237
- this.dispatch(removeStages(idsToDelete));
4238
- return this.enqueueRequest({
4233
+ const { store } = this.client;
4234
+ const assetStages = selectAssetStagesByIds(idsToDelete)(store.getState());
4235
+ this.dispatch(deleteAssetStages(idsToDelete));
4236
+ const promise = this.enqueueRequest({
4239
4237
  description: "Delete asset stages",
4240
4238
  method: HttpMethod.DELETE,
4241
- url: "/assets/stages/bulk-delete/",
4239
+ url: "/assets/stages/bulk/",
4242
4240
  payload: {
4243
4241
  stage_ids: idsToDelete
4244
4242
  },
4245
4243
  blockers: idsToDelete,
4246
4244
  blocks: []
4247
4245
  });
4246
+ promise.catch(() => {
4247
+ this.dispatch(addAssetStages(assetStages));
4248
+ });
4249
+ return promise;
4248
4250
  }
4249
- async update(assetStage) {
4250
- this.dispatch(addStages([assetStage]));
4251
- return this.enqueueRequest({
4251
+ update(payload) {
4252
+ const { store } = this.client;
4253
+ const assetStage = selectAssetStageById(payload.offline_id)(store.getState());
4254
+ if (!assetStage)
4255
+ throw new Error(`No asset stage with id ${payload.offline_id} found in the store`);
4256
+ const updatedAssetStage = {
4257
+ ...assetStage,
4258
+ ...payload
4259
+ };
4260
+ this.dispatch(updateAssetStage(updatedAssetStage));
4261
+ const promise = this.enqueueRequest({
4252
4262
  description: "Update asset stage",
4253
4263
  method: HttpMethod.PATCH,
4254
4264
  url: `/assets/stages/${assetStage.offline_id}/`,
4255
- payload: assetStage,
4265
+ payload: {
4266
+ name: payload.name,
4267
+ description: payload.description,
4268
+ priority: payload.priority,
4269
+ color: payload.color
4270
+ },
4256
4271
  blockers: [assetStage.offline_id],
4257
4272
  blocks: [assetStage.offline_id]
4258
4273
  });
4274
+ promise.then((result) => {
4275
+ this.dispatch(updateAssetStage(result));
4276
+ }).catch(() => {
4277
+ this.dispatch(setAssetStage(assetStage));
4278
+ });
4279
+ return [updatedAssetStage, promise];
4259
4280
  }
4260
4281
  async linkForm(stageId, formId) {
4261
4282
  const { store } = this.client;
@@ -4263,7 +4284,7 @@ var __publicField = (obj, key, value) => {
4263
4284
  if (!stage) {
4264
4285
  throw new Error(`No asset stage with id ${stageId} found in the store`);
4265
4286
  }
4266
- this.dispatch(updateStage({ ...stage, form: formId }));
4287
+ this.dispatch(updateAssetStage({ ...stage, form: formId }));
4267
4288
  try {
4268
4289
  await this.enqueueRequest({
4269
4290
  description: "Link asset stage to form",
@@ -4274,7 +4295,7 @@ var __publicField = (obj, key, value) => {
4274
4295
  blocks: [stageId]
4275
4296
  });
4276
4297
  } catch (e) {
4277
- this.dispatch(setStage(stage));
4298
+ this.dispatch(setAssetStage(stage));
4278
4299
  throw e;
4279
4300
  }
4280
4301
  }
@@ -4284,7 +4305,7 @@ var __publicField = (obj, key, value) => {
4284
4305
  if (!stage) {
4285
4306
  throw new Error(`No asset stage with id ${stageId} found in the store`);
4286
4307
  }
4287
- this.dispatch(updateStage({ ...stage, form: void 0 }));
4308
+ this.dispatch(updateAssetStage({ ...stage, form: void 0 }));
4288
4309
  try {
4289
4310
  await this.enqueueRequest({
4290
4311
  description: "Unlink asset stage from form",
@@ -4294,7 +4315,7 @@ var __publicField = (obj, key, value) => {
4294
4315
  blocks: [stageId]
4295
4316
  });
4296
4317
  } catch (e) {
4297
- this.dispatch(setStage(stage));
4318
+ this.dispatch(setAssetStage(stage));
4298
4319
  throw e;
4299
4320
  }
4300
4321
  }
@@ -4306,7 +4327,7 @@ var __publicField = (obj, key, value) => {
4306
4327
  blockers: [],
4307
4328
  blocks: []
4308
4329
  });
4309
- this.dispatch(initializeStages(result));
4330
+ this.dispatch(initializeAssetStages(result));
4310
4331
  }
4311
4332
  }
4312
4333
  class BaseUploadService extends BaseApiService {
@@ -4514,29 +4535,61 @@ var __publicField = (obj, key, value) => {
4514
4535
  }
4515
4536
  }
4516
4537
  class AssetTypeService extends BaseApiService {
4517
- add(assetType) {
4518
- const offlineAssetType = offline(assetType);
4538
+ add(payload) {
4539
+ const { store } = this.client;
4540
+ const createdBy = store.getState().userReducer.currentUser.id;
4541
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4542
+ const offlineAssetType = offline({
4543
+ ...payload,
4544
+ created_by: createdBy,
4545
+ submitted_at: submittedAt
4546
+ });
4519
4547
  this.dispatch(addAssetType(offlineAssetType));
4520
4548
  const promise = this.enqueueRequest({
4521
4549
  description: "Create asset type",
4522
4550
  method: HttpMethod.POST,
4523
- url: `/projects/${assetType.project}/asset-types/`,
4551
+ url: `/projects/${payload.project}/asset-types/`,
4524
4552
  payload: { ...offlineAssetType },
4525
4553
  blockers: [],
4526
4554
  blocks: [offlineAssetType.offline_id]
4527
4555
  });
4556
+ promise.then((result) => {
4557
+ this.dispatch(updateAssetType(result));
4558
+ }).catch(() => {
4559
+ this.dispatch(deleteAssetType(offlineAssetType.offline_id));
4560
+ });
4528
4561
  return [offlineAssetType, promise];
4529
4562
  }
4530
- update(assetType) {
4531
- this.dispatch(addAssetType(assetType));
4532
- return this.enqueueRequest({
4563
+ update(payload) {
4564
+ const { store } = this.client;
4565
+ const assetType = selectAssetTypeById(payload.offline_id)(store.getState());
4566
+ if (!assetType) {
4567
+ throw new Error(`Expected asset type with offline_id ${payload.offline_id} to exist`);
4568
+ }
4569
+ const updatedAssetType = {
4570
+ ...assetType,
4571
+ ...payload
4572
+ };
4573
+ this.dispatch(updateAssetType(updatedAssetType));
4574
+ const promise = this.enqueueRequest({
4533
4575
  description: "Update asset type",
4534
4576
  method: HttpMethod.PATCH,
4535
- url: `/assets/types/${assetType.offline_id}/`,
4536
- payload: assetType,
4577
+ url: `/assets/types/${payload.offline_id}/`,
4578
+ payload: {
4579
+ icon: payload.icon,
4580
+ color: payload.color,
4581
+ name: payload.name,
4582
+ description: payload.description
4583
+ },
4537
4584
  blockers: [assetType.offline_id],
4538
4585
  blocks: [assetType.offline_id]
4539
4586
  });
4587
+ promise.then((result) => {
4588
+ this.dispatch(updateAssetType(result));
4589
+ }).catch(() => {
4590
+ this.dispatch(updateAssetType(assetType));
4591
+ });
4592
+ return [updatedAssetType, promise];
4540
4593
  }
4541
4594
  async delete(assetTypeId) {
4542
4595
  const { store } = this.client;
@@ -4545,17 +4598,13 @@ var __publicField = (obj, key, value) => {
4545
4598
  if (!assetType) {
4546
4599
  throw new Error(`Expected asset type with offline_id ${assetTypeId} to exist`);
4547
4600
  }
4601
+ const assetsOfAssetType = selectAssetsOfAssetType(assetTypeId)(state);
4548
4602
  const stagesOfAssetType = selectStagesOfAssetType(assetTypeId)(state);
4549
4603
  const attachmentsOfAssetType = selectAttachmentsOfAssetType(assetTypeId)(state);
4550
4604
  this.dispatch(deleteAssetType(assetTypeId));
4551
- if (stagesOfAssetType.length > 0) {
4552
- const stagesOfAssetTypeIds = stagesOfAssetType.map((assetStage) => assetStage.offline_id);
4553
- this.dispatch(removeStages(stagesOfAssetTypeIds));
4554
- }
4555
- if (attachmentsOfAssetType.length > 0) {
4556
- const attachmentsOfAssetTypeIds = attachmentsOfAssetType.map(({ offline_id }) => offline_id);
4557
- this.dispatch(deleteAssetTypeAttachments(attachmentsOfAssetTypeIds));
4558
- }
4605
+ this.dispatch(deleteAssets(assetsOfAssetType.map((asset) => asset.offline_id)));
4606
+ this.dispatch(deleteAssetStages(stagesOfAssetType.map((assetStage) => assetStage.offline_id)));
4607
+ this.dispatch(deleteAssetTypeAttachments(attachmentsOfAssetType.map(({ offline_id }) => offline_id)));
4559
4608
  return this.enqueueRequest({
4560
4609
  description: "Delete asset type",
4561
4610
  method: HttpMethod.DELETE,
@@ -4564,7 +4613,8 @@ var __publicField = (obj, key, value) => {
4564
4613
  blocks: []
4565
4614
  }).catch((e) => {
4566
4615
  this.dispatch(addAssetType(assetType));
4567
- this.dispatch(addStages(stagesOfAssetType));
4616
+ this.dispatch(addAssets(assetsOfAssetType));
4617
+ this.dispatch(addAssetStages(stagesOfAssetType));
4568
4618
  this.dispatch(addAssetTypeAttachments(attachmentsOfAssetType));
4569
4619
  throw e;
4570
4620
  });
@@ -4769,15 +4819,6 @@ var __publicField = (obj, key, value) => {
4769
4819
  void promise.then((result) => {
4770
4820
  this.dispatch(updateIssue(result));
4771
4821
  }).catch((error) => {
4772
- var _a3;
4773
- console.error(error);
4774
- if (error instanceof APIError) {
4775
- (_a3 = blocks.unsafeShowToast) == null ? void 0 : _a3.call(blocks, {
4776
- title: "Could not create issue",
4777
- description: error.message,
4778
- accentColor: "red"
4779
- });
4780
- }
4781
4822
  this.dispatch(deleteIssue(offlineIssue.offline_id));
4782
4823
  this.dispatch(addActiveProjectIssuesCount(-1));
4783
4824
  throw error;
@@ -5025,15 +5066,6 @@ var __publicField = (obj, key, value) => {
5025
5066
  }
5026
5067
  }
5027
5068
  class ProjectAccessService extends BaseApiService {
5028
- async fetchAll(projectId) {
5029
- return this.enqueueRequest({
5030
- description: "Get project accesses",
5031
- method: HttpMethod.GET,
5032
- url: `/projects/${projectId}/access/`,
5033
- blockers: [],
5034
- blocks: []
5035
- });
5036
- }
5037
5069
  async update(projectAccess) {
5038
5070
  this.dispatch(updateProjectAccess(projectAccess));
5039
5071
  return this.enqueueRequest({
@@ -5046,19 +5078,24 @@ var __publicField = (obj, key, value) => {
5046
5078
  });
5047
5079
  }
5048
5080
  // TODO: Re-add user to project if removal fails
5049
- async remove(projectAccess) {
5050
- this.dispatch(deleteProjectAccess(projectAccess.offline_id));
5081
+ async remove(id) {
5082
+ this.dispatch(deleteProjectAccess(id));
5051
5083
  return this.enqueueRequest({
5052
5084
  description: "Delete project access",
5053
5085
  method: HttpMethod.DELETE,
5054
- url: `/access/${projectAccess.offline_id}/`,
5055
- blockers: [projectAccess.offline_id],
5086
+ url: `/access/${id}/`,
5087
+ blockers: [id],
5056
5088
  blocks: []
5057
5089
  });
5058
5090
  }
5059
5091
  async refreshStore(projectId) {
5060
- const promise = this.fetchAll(projectId);
5061
- const result = await promise;
5092
+ const result = await this.enqueueRequest({
5093
+ description: "Get project accesses",
5094
+ method: HttpMethod.GET,
5095
+ url: `/projects/${projectId}/access/`,
5096
+ blockers: [],
5097
+ blocks: []
5098
+ });
5062
5099
  this.dispatch(initializeProjectAccesses(result));
5063
5100
  }
5064
5101
  }
@@ -5194,29 +5231,23 @@ var __publicField = (obj, key, value) => {
5194
5231
  }
5195
5232
  }
5196
5233
  class ProjectService extends BaseApiService {
5197
- /**
5198
- * Creates a new project. Due to the nature of project creation,
5199
- * @param project A Payload<Project> object containing project attributes.
5200
- * @returns A promise that resolves to a Project.
5201
- * @throws An APIError if the server returns an error, or any other error that may occur.
5202
- */
5203
- async add(project) {
5204
- if (!project.organization_owner && !project.user_owner) {
5234
+ async add(payload) {
5235
+ if (!payload.organization_owner && !payload.user_owner) {
5205
5236
  throw new Error("Project type was not chosen when trying to create a project");
5206
5237
  }
5207
- if (!project.bounds && !project.canvas_bounds) {
5238
+ if (!payload.bounds && !payload.canvas_bounds) {
5208
5239
  throw new Error("Project must either have bounds or canvas_bounds set");
5209
5240
  }
5210
- const isOrganizationProject = !!project.organization_owner;
5211
- const url = isOrganizationProject ? `/organizations/${project.organization_owner}/projects/` : "/projects/";
5212
- const projectType = isOrganizationProject ? { organization_owner: project.organization_owner } : { user_owner: project.user_owner };
5241
+ const isOrganizationProject = !!payload.organization_owner;
5242
+ const url = isOrganizationProject ? `/organizations/${payload.organization_owner}/projects/` : "/projects/";
5243
+ const projectType = isOrganizationProject ? { organization_owner: payload.organization_owner } : { user_owner: payload.user_owner };
5213
5244
  return await this.enqueueRequest({
5214
5245
  description: "Create project",
5215
5246
  method: HttpMethod.POST,
5216
5247
  url,
5217
5248
  payload: {
5218
- name: project.name,
5219
- bounds: project.bounds,
5249
+ name: payload.name,
5250
+ bounds: payload.bounds,
5220
5251
  ...projectType
5221
5252
  },
5222
5253
  blockers: [],
@@ -5897,7 +5928,7 @@ var __publicField = (obj, key, value) => {
5897
5928
  description: "Delete user form submissions",
5898
5929
  method: HttpMethod.PATCH,
5899
5930
  url: `/forms/submissions/${updatedSubmission.offline_id}/`,
5900
- payload: updatedSubmission,
5931
+ payload,
5901
5932
  blockers: [updatedSubmission.offline_id],
5902
5933
  blocks: [updatedSubmission.offline_id]
5903
5934
  });
@@ -6040,7 +6071,7 @@ var __publicField = (obj, key, value) => {
6040
6071
  description: "Update Workspace",
6041
6072
  method: HttpMethod.PATCH,
6042
6073
  url: `/workspaces/${workspace.offline_id}/`,
6043
- payload: workspace,
6074
+ payload,
6044
6075
  blockers: [workspace.offline_id],
6045
6076
  blocks: [workspace.offline_id]
6046
6077
  });
@@ -6590,26 +6621,26 @@ var __publicField = (obj, key, value) => {
6590
6621
  });
6591
6622
  return [offlineDocument, promise];
6592
6623
  }
6593
- update(document2) {
6624
+ update(payload) {
6594
6625
  const { store } = this.client;
6595
- const documentToBeUpdated = store.getState().documentsReducer.documents[document2.offline_id];
6626
+ const documentToBeUpdated = store.getState().documentsReducer.documents[payload.offline_id];
6596
6627
  if (!documentToBeUpdated) {
6597
6628
  throw new Error(
6598
- `attempting to update a document with offline_id ${document2.offline_id} that does not exist in store.documents`
6629
+ `attempting to update a document with offline_id ${payload.offline_id} that does not exist in store.documents`
6599
6630
  );
6600
6631
  }
6601
6632
  const updatedDocument = {
6602
6633
  ...documentToBeUpdated,
6603
- ...document2
6634
+ ...payload
6604
6635
  };
6605
6636
  this.dispatch(updateDocuments([updatedDocument]));
6606
6637
  const promise = this.enqueueRequest({
6607
6638
  description: "Update Document",
6608
6639
  method: HttpMethod.PATCH,
6609
- url: `/documents/${document2.offline_id}/`,
6610
- payload: document2,
6611
- blockers: [document2.offline_id],
6612
- blocks: [document2.offline_id]
6640
+ url: `/documents/${payload.offline_id}/`,
6641
+ payload,
6642
+ blockers: [payload.offline_id],
6643
+ blocks: [payload.offline_id]
6613
6644
  });
6614
6645
  promise.catch(() => {
6615
6646
  updateDocuments([documentToBeUpdated]);
@@ -6960,7 +6991,7 @@ var __publicField = (obj, key, value) => {
6960
6991
  description: "Update team",
6961
6992
  method: HttpMethod.PATCH,
6962
6993
  url: `/organizations/teams/${payload.offline_id}/`,
6963
- payload: offlineUpdatedTeam,
6994
+ payload,
6964
6995
  blockers: [payload.offline_id],
6965
6996
  blocks: [payload.offline_id]
6966
6997
  });
@@ -7312,11 +7343,19 @@ var __publicField = (obj, key, value) => {
7312
7343
  this.dispatch(initializeIssueAssociations(issueAssociations));
7313
7344
  }
7314
7345
  }
7346
+ var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
7347
+ VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
7348
+ VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
7349
+ VerificationCodeType2[VerificationCodeType2["PROJECT_INVITE"] = 4] = "PROJECT_INVITE";
7350
+ VerificationCodeType2[VerificationCodeType2["ORGANIZATION_INVITE"] = 6] = "ORGANIZATION_INVITE";
7351
+ VerificationCodeType2[VerificationCodeType2["ADD_EMAIL_DOMAIN"] = 8] = "ADD_EMAIL_DOMAIN";
7352
+ VerificationCodeType2[VerificationCodeType2["RESET_PASSWORD"] = 10] = "RESET_PASSWORD";
7353
+ return VerificationCodeType2;
7354
+ })(VerificationCodeType || {});
7315
7355
  exports2.APIError = APIError;
7316
7356
  exports2.AgentService = AgentService;
7317
7357
  exports2.AssetAttachmentService = AssetAttachmentService;
7318
7358
  exports2.AssetService = AssetService;
7319
- exports2.AssetStageColors = AssetStageColors;
7320
7359
  exports2.AssetStageCompletionService = AssetStageCompletionService;
7321
7360
  exports2.AssetStageService = AssetStageService;
7322
7361
  exports2.AssetTypeAttachmentService = AssetTypeAttachmentService;
@@ -7378,9 +7417,14 @@ var __publicField = (obj, key, value) => {
7378
7417
  exports2.addAsset = addAsset;
7379
7418
  exports2.addAssetAttachment = addAssetAttachment;
7380
7419
  exports2.addAssetAttachments = addAssetAttachments;
7420
+ exports2.addAssetStage = addAssetStage;
7421
+ exports2.addAssetStageCompletion = addAssetStageCompletion;
7422
+ exports2.addAssetStageCompletions = addAssetStageCompletions;
7423
+ exports2.addAssetStages = addAssetStages;
7381
7424
  exports2.addAssetType = addAssetType;
7382
7425
  exports2.addAssetTypeAttachment = addAssetTypeAttachment;
7383
7426
  exports2.addAssetTypeAttachments = addAssetTypeAttachments;
7427
+ exports2.addAssetTypes = addAssetTypes;
7384
7428
  exports2.addAssets = addAssets;
7385
7429
  exports2.addCategory = addCategory;
7386
7430
  exports2.addConversation = addConversation;
@@ -7417,9 +7461,6 @@ var __publicField = (obj, key, value) => {
7417
7461
  exports2.addOrReplaceProjects = addOrReplaceProjects;
7418
7462
  exports2.addProjectAttachment = addProjectAttachment;
7419
7463
  exports2.addProjectAttachments = addProjectAttachments;
7420
- exports2.addStageCompletion = addStageCompletion;
7421
- exports2.addStageCompletions = addStageCompletions;
7422
- exports2.addStages = addStages;
7423
7464
  exports2.addTeam = addTeam;
7424
7465
  exports2.addUsers = addUsers;
7425
7466
  exports2.addWorkspace = addWorkspace;
@@ -7444,7 +7485,6 @@ var __publicField = (obj, key, value) => {
7444
7485
  exports2.boundsContainPoint = boundsContainPoint;
7445
7486
  exports2.categoryReducer = categoryReducer;
7446
7487
  exports2.categorySlice = categorySlice;
7447
- exports2.classNames = classNames;
7448
7488
  exports2.clearTokens = clearTokens;
7449
7489
  exports2.constructUploadedFilePayloads = constructUploadedFilePayloads;
7450
7490
  exports2.coordinatesAreEqual = coordinatesAreEqual;
@@ -7458,9 +7498,14 @@ var __publicField = (obj, key, value) => {
7458
7498
  exports2.deleteAsset = deleteAsset;
7459
7499
  exports2.deleteAssetAttachment = deleteAssetAttachment;
7460
7500
  exports2.deleteAssetAttachments = deleteAssetAttachments;
7501
+ exports2.deleteAssetStage = deleteAssetStage;
7502
+ exports2.deleteAssetStageCompletion = deleteAssetStageCompletion;
7503
+ exports2.deleteAssetStageCompletions = deleteAssetStageCompletions;
7504
+ exports2.deleteAssetStages = deleteAssetStages;
7461
7505
  exports2.deleteAssetType = deleteAssetType;
7462
7506
  exports2.deleteAssetTypeAttachment = deleteAssetTypeAttachment;
7463
7507
  exports2.deleteAssetTypeAttachments = deleteAssetTypeAttachments;
7508
+ exports2.deleteAssetTypes = deleteAssetTypes;
7464
7509
  exports2.deleteAssets = deleteAssets;
7465
7510
  exports2.deleteCategory = deleteCategory;
7466
7511
  exports2.deleteDocumentAttachment = deleteDocumentAttachment;
@@ -7525,9 +7570,7 @@ var __publicField = (obj, key, value) => {
7525
7570
  exports2.formSubmissionAttachmentSlice = formSubmissionAttachmentSlice;
7526
7571
  exports2.formSubmissionReducer = formSubmissionReducer;
7527
7572
  exports2.formSubmissionSlice = formSubmissionSlice;
7528
- exports2.fullAssetMarkerSize = fullAssetMarkerSize;
7529
7573
  exports2.generateBadgeColors = generateBadgeColors;
7530
- exports2.genericMemo = genericMemo;
7531
7574
  exports2.geoImageReducer = geoImageReducer;
7532
7575
  exports2.geoImageSlice = geoImageSlice;
7533
7576
  exports2.getFileIdentifier = getFileIdentifier;
@@ -7536,10 +7579,11 @@ var __publicField = (obj, key, value) => {
7536
7579
  exports2.getLocalRelativeDateString = getLocalRelativeDateString;
7537
7580
  exports2.getOutboxCoordinator = getOutboxCoordinator;
7538
7581
  exports2.getRenamedFile = getRenamedFile;
7539
- exports2.getStageColor = getStageColor;
7540
7582
  exports2.hashFile = hashFile;
7541
7583
  exports2.initSDK = initSDK;
7542
7584
  exports2.initializeAssetAttachments = initializeAssetAttachments;
7585
+ exports2.initializeAssetStageCompletions = initializeAssetStageCompletions;
7586
+ exports2.initializeAssetStages = initializeAssetStages;
7543
7587
  exports2.initializeAssetTypeAttachments = initializeAssetTypeAttachments;
7544
7588
  exports2.initializeAssetTypes = initializeAssetTypes;
7545
7589
  exports2.initializeAssets = initializeAssets;
@@ -7562,7 +7606,6 @@ var __publicField = (obj, key, value) => {
7562
7606
  exports2.initializeOrganizationAccesses = initializeOrganizationAccesses;
7563
7607
  exports2.initializeProjectAccesses = initializeProjectAccesses;
7564
7608
  exports2.initializeProjectAttachments = initializeProjectAttachments;
7565
- exports2.initializeStages = initializeStages;
7566
7609
  exports2.initializeTeams = initializeTeams;
7567
7610
  exports2.initializeWorkspaces = initializeWorkspaces;
7568
7611
  exports2.isToday = isToday;
@@ -7574,7 +7617,6 @@ var __publicField = (obj, key, value) => {
7574
7617
  exports2.issueCommentSlice = issueCommentSlice;
7575
7618
  exports2.issueReducer = issueReducer;
7576
7619
  exports2.issueSlice = issueSlice;
7577
- exports2.issueToSearchResult = issueToSearchResult;
7578
7620
  exports2.issueTypeReducer = issueTypeReducer;
7579
7621
  exports2.issueTypeSlice = issueTypeSlice;
7580
7622
  exports2.issueUpdateReducer = issueUpdateReducer;
@@ -7618,8 +7660,6 @@ var __publicField = (obj, key, value) => {
7618
7660
  exports2.removeIssueType = removeIssueType;
7619
7661
  exports2.removeProjectFile = removeProjectFile;
7620
7662
  exports2.removeProjectFilesOfProject = removeProjectFilesOfProject;
7621
- exports2.removeStageCompletions = removeStageCompletions;
7622
- exports2.removeStages = removeStages;
7623
7663
  exports2.removeUser = removeUser;
7624
7664
  exports2.resetProjectFileObjectUrls = resetProjectFileObjectUrls;
7625
7665
  exports2.resetStore = resetStore;
@@ -7640,6 +7680,9 @@ var __publicField = (obj, key, value) => {
7640
7680
  exports2.selectAssetAttachments = selectAssetAttachments;
7641
7681
  exports2.selectAssetById = selectAssetById;
7642
7682
  exports2.selectAssetStageById = selectAssetStageById;
7683
+ exports2.selectAssetStageCompletionById = selectAssetStageCompletionById;
7684
+ exports2.selectAssetStageCompletionMapping = selectAssetStageCompletionMapping;
7685
+ exports2.selectAssetStageCompletionsByIds = selectAssetStageCompletionsByIds;
7643
7686
  exports2.selectAssetStages = selectAssetStages;
7644
7687
  exports2.selectAssetStagesByIds = selectAssetStagesByIds;
7645
7688
  exports2.selectAssetTypeAttachmentById = selectAssetTypeAttachmentById;
@@ -7675,7 +7718,7 @@ var __publicField = (obj, key, value) => {
7675
7718
  exports2.selectCategoryMapping = selectCategoryMapping;
7676
7719
  exports2.selectCommentsOfIssue = selectCommentsOfIssue;
7677
7720
  exports2.selectCompletedStageIdsForAsset = selectCompletedStageIdsForAsset;
7678
- exports2.selectCompletedStages = selectCompletedStages;
7721
+ exports2.selectCompletedStagesByAsset = selectCompletedStagesByAsset;
7679
7722
  exports2.selectConversation = selectConversation;
7680
7723
  exports2.selectConversationMapping = selectConversationMapping;
7681
7724
  exports2.selectConversations = selectConversations;
@@ -7787,7 +7830,6 @@ var __publicField = (obj, key, value) => {
7787
7830
  exports2.selectSortedProjectUsers = selectSortedProjectUsers;
7788
7831
  exports2.selectStageFormIdsFromStageIds = selectStageFormIdsFromStageIds;
7789
7832
  exports2.selectStageMapping = selectStageMapping;
7790
- exports2.selectStagesFromAssetTypeIds = selectStagesFromAssetTypeIds;
7791
7833
  exports2.selectStagesOfAssetType = selectStagesOfAssetType;
7792
7834
  exports2.selectTeamById = selectTeamById;
7793
7835
  exports2.selectTeams = selectTeams;
@@ -7807,8 +7849,12 @@ var __publicField = (obj, key, value) => {
7807
7849
  exports2.setAsset = setAsset;
7808
7850
  exports2.setAssetAttachment = setAssetAttachment;
7809
7851
  exports2.setAssetAttachments = setAssetAttachments;
7852
+ exports2.setAssetStage = setAssetStage;
7853
+ exports2.setAssetStages = setAssetStages;
7854
+ exports2.setAssetType = setAssetType;
7810
7855
  exports2.setAssetTypeAttachment = setAssetTypeAttachment;
7811
7856
  exports2.setAssetTypeAttachments = setAssetTypeAttachments;
7857
+ exports2.setAssetTypes = setAssetTypes;
7812
7858
  exports2.setAssets = setAssets;
7813
7859
  exports2.setConversation = setConversation;
7814
7860
  exports2.setCurrentUser = setCurrentUser;
@@ -7841,8 +7887,6 @@ var __publicField = (obj, key, value) => {
7841
7887
  exports2.setProjectAttachments = setProjectAttachments;
7842
7888
  exports2.setProjects = setProjects;
7843
7889
  exports2.setRehydrated = setRehydrated;
7844
- exports2.setStage = setStage;
7845
- exports2.setStageCompletions = setStageCompletions;
7846
7890
  exports2.setTeam = setTeam;
7847
7891
  exports2.setTokens = setTokens;
7848
7892
  exports2.setUploadUrl = setUploadUrl;
@@ -7860,8 +7904,14 @@ var __publicField = (obj, key, value) => {
7860
7904
  exports2.updateAsset = updateAsset;
7861
7905
  exports2.updateAssetAttachment = updateAssetAttachment;
7862
7906
  exports2.updateAssetAttachments = updateAssetAttachments;
7907
+ exports2.updateAssetStage = updateAssetStage;
7908
+ exports2.updateAssetStageCompletion = updateAssetStageCompletion;
7909
+ exports2.updateAssetStageCompletions = updateAssetStageCompletions;
7910
+ exports2.updateAssetStages = updateAssetStages;
7911
+ exports2.updateAssetType = updateAssetType;
7863
7912
  exports2.updateAssetTypeAttachment = updateAssetTypeAttachment;
7864
7913
  exports2.updateAssetTypeAttachments = updateAssetTypeAttachments;
7914
+ exports2.updateAssetTypes = updateAssetTypes;
7865
7915
  exports2.updateAssets = updateAssets;
7866
7916
  exports2.updateCategory = updateCategory;
7867
7917
  exports2.updateConversation = updateConversation;
@@ -7889,11 +7939,8 @@ var __publicField = (obj, key, value) => {
7889
7939
  exports2.updateProjectAccess = updateProjectAccess;
7890
7940
  exports2.updateProjectAttachment = updateProjectAttachment;
7891
7941
  exports2.updateProjectAttachments = updateProjectAttachments;
7892
- exports2.updateStage = updateStage;
7893
- exports2.updateStages = updateStages;
7894
7942
  exports2.updateTeam = updateTeam;
7895
7943
  exports2.updateWorkspace = updateWorkspace;
7896
- exports2.useMemoCompare = useMemoCompare;
7897
7944
  exports2.userReducer = userReducer;
7898
7945
  exports2.userSlice = userSlice;
7899
7946
  exports2.versioningReducer = versioningReducer;