@overmap-ai/core 1.0.65-strip-workspace-access.0 → 1.0.65-strip-workspace-access.2

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.
@@ -1633,12 +1633,7 @@ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
1633
1633
  })(LicenseStatus || {});
1634
1634
  const initialState$p = {
1635
1635
  users: {},
1636
- currentUser: {
1637
- id: 0,
1638
- username: "",
1639
- email: "",
1640
- profile: { file: null, file_sha1: null, favourite_project_ids: [], tour_step: -1 }
1641
- }
1636
+ currentUser: null
1642
1637
  };
1643
1638
  const userSlice = createSlice({
1644
1639
  name: "users",
@@ -1661,6 +1656,8 @@ const userSlice = createSlice({
1661
1656
  state.currentUser = action.payload;
1662
1657
  },
1663
1658
  setProfilePicture: (state, action) => {
1659
+ if (!state.currentUser)
1660
+ return;
1664
1661
  state.currentUser.profile.file = action.payload.file ?? null;
1665
1662
  state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1666
1663
  const currentUser = state.users[state.currentUser.id];
@@ -1670,32 +1667,12 @@ const userSlice = createSlice({
1670
1667
  currentUser.profile.file = action.payload.file ?? null;
1671
1668
  currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1672
1669
  },
1673
- addFavouriteProjectId: (state, action) => {
1674
- state.currentUser.profile.favourite_project_ids.push(action.payload);
1675
- },
1676
- removeFavouriteProjectId: (state, action) => {
1677
- state.currentUser.profile.favourite_project_ids = state.currentUser.profile.favourite_project_ids.filter(
1678
- (id) => id !== action.payload
1679
- );
1680
- },
1681
- setTourStep: (state, action) => {
1682
- state.currentUser.profile.tour_step = action.payload;
1683
- },
1684
1670
  removeUser: (state, action) => {
1685
1671
  delete state.users[action.payload];
1686
1672
  }
1687
1673
  }
1688
1674
  });
1689
- const {
1690
- setCurrentUser,
1691
- setProfilePicture,
1692
- setUsers,
1693
- addUsers,
1694
- addFavouriteProjectId,
1695
- removeFavouriteProjectId,
1696
- setTourStep,
1697
- removeUser
1698
- } = userSlice.actions;
1675
+ const { setCurrentUser, setProfilePicture, setUsers, addUsers, removeUser } = userSlice.actions;
1699
1676
  const userReducer = userSlice.reducer;
1700
1677
  const selectCurrentUser = (state) => state.userReducer.currentUser;
1701
1678
  const selectUsersMapping = (state) => state.userReducer.users;
@@ -1716,7 +1693,6 @@ const selectUsersByIds = restructureCreateSelectorWithArgs(
1716
1693
  return fallbackToEmptyArray(users);
1717
1694
  })
1718
1695
  );
1719
- const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
1720
1696
  const organizationAccessAdapter = createModelAdapter(
1721
1697
  (organizationAccess) => organizationAccess.offline_id
1722
1698
  );
@@ -1742,7 +1718,7 @@ const selectActiveOrganizationAccess = createSelector(
1742
1718
  [selectCurrentUser, selectOrganizationAccesses],
1743
1719
  (currentUser, organizationAccesses) => {
1744
1720
  const activeOrganizationAccess = Object.values(organizationAccesses).find(
1745
- (organizationAccess) => organizationAccess.user === currentUser.id
1721
+ (organizationAccess) => organizationAccess.user === (currentUser == null ? void 0 : currentUser.id)
1746
1722
  );
1747
1723
  return activeOrganizationAccess ?? null;
1748
1724
  }
@@ -1819,7 +1795,7 @@ const selectActiveProjectAccess = (state) => {
1819
1795
  const currentUser = state.userReducer.currentUser;
1820
1796
  const activeProjectId = state.projectReducer.activeProjectId;
1821
1797
  return Object.values(state.projectAccessReducer.instances).find((projectAccess) => {
1822
- return projectAccess.user === currentUser.id && projectAccess.project === activeProjectId;
1798
+ return projectAccess.user === (currentUser == null ? void 0 : currentUser.id) && projectAccess.project === activeProjectId;
1823
1799
  }) ?? null;
1824
1800
  };
1825
1801
  const selectProjectAccessForUser = (user) => (state) => {
@@ -1932,9 +1908,9 @@ const selectSortedProjectUsers = createSelector(
1932
1908
  [selectCurrentUser, selectProjectUsersAsMapping, selectProjectAccessUserMapping],
1933
1909
  (currentUser, userMapping, projectAccessMapping) => {
1934
1910
  return Object.values(userMapping).sort((userA, userB) => {
1935
- if (userA.id === currentUser.id) {
1911
+ if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
1936
1912
  return -1;
1937
- } else if (userB.id === currentUser.id) {
1913
+ } else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
1938
1914
  return 1;
1939
1915
  }
1940
1916
  const projectAccessesA = projectAccessMapping[userA.id];
@@ -2011,9 +1987,9 @@ const selectSortedOrganizationUsers = createSelector(
2011
1987
  [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2012
1988
  (currentUser, userMapping, organizationAccessMapping) => {
2013
1989
  return Object.values(userMapping).sort((userA, userB) => {
2014
- if (userA.id === currentUser.id) {
1990
+ if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
2015
1991
  return -1;
2016
- } else if (userB.id === currentUser.id) {
1992
+ } else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
2017
1993
  return 1;
2018
1994
  }
2019
1995
  const organizationAccessesA = organizationAccessMapping[userA.id];
@@ -2375,29 +2351,18 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
2375
2351
  (_state, search) => search
2376
2352
  ],
2377
2353
  (formsMapping, revisions, search) => {
2378
- const { searchTerm, maxResults, favorites, organization } = search;
2379
- const favoriteMatches = [];
2354
+ const { searchTerm, maxResults, organization } = search;
2380
2355
  const regularMatches = [];
2381
2356
  for (const [formId, form] of Object.entries(formsMapping)) {
2382
- if (favorites !== void 0 && form.favorite != favorites)
2383
- continue;
2384
2357
  if (Number.isInteger(organization) && organization !== form.organization) {
2385
2358
  continue;
2386
2359
  }
2387
2360
  const latestRevision = _selectLatestFormRevision(revisions, formId);
2388
2361
  if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
2389
- if (form.favorite) {
2390
- favoriteMatches.push({ ...form, latestRevision });
2391
- } else {
2392
- regularMatches.push({ ...form, latestRevision });
2393
- }
2394
- }
2395
- if (favoriteMatches.length >= maxResults) {
2396
- break;
2362
+ regularMatches.push(form);
2397
2363
  }
2398
2364
  }
2399
- const maxRegularMatches = maxResults - favoriteMatches.length;
2400
- return [...favoriteMatches, ...regularMatches.slice(0, maxRegularMatches)];
2365
+ return [...regularMatches.slice(0, maxResults)];
2401
2366
  },
2402
2367
  // as the argument is an object, we check the first level of properties for equality
2403
2368
  { memoizeOptions: { equalityCheck: shallowEqual } }
@@ -3131,13 +3096,13 @@ const {
3131
3096
  deleteIssueComments
3132
3097
  } = issueCommentSlice.actions;
3133
3098
  const selectIssueCommentMapping = (state) => state.issueCommentReducer.instances;
3099
+ const selectIssueCommentById = (id) => (state) => {
3100
+ return state.issueCommentReducer.instances[id];
3101
+ };
3134
3102
  const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
3135
- createSelector(
3136
- [selectIssueCommentMapping, (_state, issueId) => issueId],
3137
- (commentMapping, issueId) => {
3138
- return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
3139
- }
3140
- )
3103
+ createSelector([selectIssueCommentMapping, (_state, issueId) => issueId], (commentMapping, issueId) => {
3104
+ return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
3105
+ })
3141
3106
  );
3142
3107
  const issueCommentReducer = issueCommentSlice.reducer;
3143
3108
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
@@ -4047,57 +4012,66 @@ class BaseApiService extends BaseService {
4047
4012
  }
4048
4013
  }
4049
4014
  class CategoryService extends BaseApiService {
4050
- add(category, workspaceId) {
4051
- const offlineCategory = offline(category);
4052
- const categoryWithWorkspace = { ...offlineCategory, workspace: workspaceId };
4053
- this.dispatch(addCategory(categoryWithWorkspace));
4015
+ add(payload) {
4016
+ var _a2;
4017
+ const { store } = this.client;
4018
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
4019
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4020
+ const offlineCategory = offline({
4021
+ ...payload,
4022
+ created_by: createdBy,
4023
+ submitted_at: submittedAt
4024
+ });
4025
+ this.dispatch(addCategory(offlineCategory));
4054
4026
  const promise = this.enqueueRequest({
4055
4027
  description: "Create Category",
4056
4028
  method: HttpMethod.POST,
4057
4029
  url: "/categories/",
4058
4030
  queryParams: {
4059
- workspace_id: workspaceId.toString()
4031
+ workspace_id: payload.workspace.toString()
4060
4032
  },
4061
4033
  payload: offlineCategory,
4062
- blockers: [],
4034
+ blockers: [payload.workspace],
4063
4035
  blocks: [offlineCategory.offline_id]
4064
4036
  });
4065
- return [categoryWithWorkspace, promise];
4037
+ return [offlineCategory, promise];
4066
4038
  }
4067
- update(category, workspaceId) {
4039
+ update(payload) {
4068
4040
  const state = this.client.store.getState();
4069
- const existingCategory = selectCategoryById(category.offline_id)(state);
4041
+ const existingCategory = selectCategoryById(payload.offline_id)(state);
4070
4042
  if (!existingCategory) {
4071
- throw new Error(`Expected an existing category with offline_id ${category.offline_id}`);
4043
+ throw new Error(`Expected an existing category with offline_id ${payload.offline_id}`);
4072
4044
  }
4073
- const optimisticCategory = { ...existingCategory, ...category };
4045
+ const optimisticCategory = { ...existingCategory, ...payload };
4074
4046
  this.dispatch(updateCategory(optimisticCategory));
4075
4047
  const promise = this.enqueueRequest({
4076
4048
  description: "Edit Category",
4077
4049
  method: HttpMethod.PATCH,
4078
- url: `/categories/${category.offline_id}/`,
4079
- queryParams: {
4080
- workspace_id: workspaceId.toString()
4081
- },
4082
- payload: category,
4083
- blockers: [category.offline_id],
4084
- blocks: [category.offline_id]
4050
+ url: `/categories/${payload.offline_id}/`,
4051
+ payload,
4052
+ blockers: [payload.offline_id],
4053
+ blocks: [payload.offline_id]
4085
4054
  });
4086
4055
  return [optimisticCategory, promise];
4087
4056
  }
4088
- remove(category, workspaceId) {
4089
- this.dispatch(deleteCategory(category.offline_id));
4090
- return this.enqueueRequest({
4057
+ remove(id) {
4058
+ const { store } = this.client;
4059
+ const category = selectCategoryById(id)(store.getState());
4060
+ if (!category) {
4061
+ throw new Error(`No category with id ${id} found in the store`);
4062
+ }
4063
+ this.dispatch(deleteCategory(id));
4064
+ const promise = this.enqueueRequest({
4091
4065
  description: "Delete Category",
4092
4066
  method: HttpMethod.DELETE,
4093
4067
  url: `/categories/${category.offline_id}/`,
4094
- // TODO: Shouldn't be necessary to specify workspace_id here
4095
- queryParams: {
4096
- workspace_id: workspaceId.toString()
4097
- },
4098
4068
  blockers: [category.offline_id],
4099
4069
  blocks: []
4100
4070
  });
4071
+ promise.catch(() => {
4072
+ this.dispatch(addCategory(category));
4073
+ });
4074
+ return promise;
4101
4075
  }
4102
4076
  async refreshStore(projectId) {
4103
4077
  const result = await this.enqueueRequest({
@@ -4551,8 +4525,9 @@ const AttachmentModelMeta = {
4551
4525
  };
4552
4526
  class BaseAttachmentService extends BaseUploadService {
4553
4527
  async attachFiles(files, modelId, buildOfflineAttachment) {
4528
+ var _a2;
4554
4529
  const { store } = this.client;
4555
- const currentUser = store.getState().userReducer.currentUser;
4530
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
4556
4531
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4557
4532
  const offlineAttachments = [];
4558
4533
  const attachmentPayloads = [];
@@ -4572,7 +4547,7 @@ class BaseAttachmentService extends BaseUploadService {
4572
4547
  file,
4573
4548
  sha1,
4574
4549
  submittedAt,
4575
- createdBy: currentUser.id,
4550
+ createdBy,
4576
4551
  description: "",
4577
4552
  modelId
4578
4553
  });
@@ -4776,21 +4751,21 @@ class AssetTypeAttachmentService extends BaseAttachmentService {
4776
4751
  }
4777
4752
  }
4778
4753
  class IssueCommentService extends BaseApiService {
4779
- // Omit author and submitted_at since these will always be set internally
4780
- add(comment) {
4754
+ add(payload) {
4755
+ var _a2;
4781
4756
  const { store } = this.client;
4782
4757
  const offlineComment = offline({
4783
- ...comment,
4784
- author: store.getState().userReducer.currentUser.id,
4758
+ ...payload,
4759
+ author: (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
4785
4760
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
4786
4761
  });
4787
4762
  this.dispatch(addIssueComment(offlineComment));
4788
4763
  const promise = this.enqueueRequest({
4789
- description: `${truncate(comment.content, 80)}`,
4764
+ description: "Add issue comment",
4790
4765
  method: HttpMethod.POST,
4791
- url: `/issues/${comment.issue}/comment/`,
4766
+ url: `/issues/${payload.issue}/comment/`,
4792
4767
  payload: offlineComment,
4793
- blockers: [comment.issue],
4768
+ blockers: [payload.issue],
4794
4769
  blocks: [offlineComment.offline_id]
4795
4770
  });
4796
4771
  promise.catch(() => {
@@ -4798,37 +4773,41 @@ class IssueCommentService extends BaseApiService {
4798
4773
  });
4799
4774
  return [offlineComment, promise];
4800
4775
  }
4801
- update(comment) {
4776
+ update(payload) {
4802
4777
  const { store } = this.client;
4803
- const commentToUpdate = store.getState().issueCommentReducer.instances[comment.offline_id];
4778
+ const commentToUpdate = selectIssueCommentById(payload.offline_id)(store.getState());
4804
4779
  if (!commentToUpdate) {
4805
- throw new Error(`Comment with offline_id ${comment.offline_id} not found in store`);
4780
+ throw new Error(`Comment with offline_id ${payload.offline_id} not found in store`);
4806
4781
  }
4807
- this.dispatch(setIssueComment(comment));
4782
+ const updatedComment = {
4783
+ ...commentToUpdate,
4784
+ ...payload
4785
+ };
4786
+ this.dispatch(setIssueComment(updatedComment));
4808
4787
  const promise = this.enqueueRequest({
4809
- description: `Edit comment: ${truncate(comment.content, 80)}`,
4788
+ description: "Edit issue comment",
4810
4789
  method: HttpMethod.PATCH,
4811
- url: `/issues/comments/${comment.offline_id}/`,
4812
- payload: comment,
4813
- blockers: [comment.issue],
4814
- blocks: [comment.offline_id]
4790
+ url: `/issues/comments/${payload.offline_id}/`,
4791
+ payload,
4792
+ blockers: [payload.offline_id],
4793
+ blocks: [payload.offline_id]
4815
4794
  });
4816
4795
  promise.catch(() => {
4817
4796
  this.dispatch(setIssueComment(commentToUpdate));
4818
4797
  });
4819
- return [comment, promise];
4798
+ return [updatedComment, promise];
4820
4799
  }
4821
- remove(offline_id) {
4822
- const commentToRemove = this.client.store.getState().issueCommentReducer.instances[offline_id];
4800
+ remove(id) {
4801
+ const commentToRemove = this.client.store.getState().issueCommentReducer.instances[id];
4823
4802
  if (!commentToRemove) {
4824
- throw new Error(`Comment with offline_id ${offline_id} not found in store`);
4803
+ throw new Error(`Comment with offline_id ${id} not found in store`);
4825
4804
  }
4826
- this.dispatch(deleteIssueComment(offline_id));
4805
+ this.dispatch(deleteIssueComment(id));
4827
4806
  const promise = this.enqueueRequest({
4828
4807
  description: "Delete comment",
4829
4808
  method: HttpMethod.DELETE,
4830
- url: `/issues/comments/${offline_id}/`,
4831
- blockers: [offline_id],
4809
+ url: `/issues/comments/${id}/`,
4810
+ blockers: [id],
4832
4811
  blocks: []
4833
4812
  });
4834
4813
  promise.catch(() => {
@@ -4901,67 +4880,60 @@ class IssueAttachmentService extends BaseAttachmentService {
4901
4880
  }
4902
4881
  class IssueService extends BaseApiService {
4903
4882
  // Basic CRUD functions
4904
- // TODO: Once all models are represented in `Created<TModel>`, use `Created` in `OptimisticModelResult`, so we don't
4905
- // have to repeat it for all optimistic model results (all optimistic results are created).
4906
- add(issue, workspaceId, issueType = null) {
4883
+ add(payload) {
4884
+ var _a2;
4907
4885
  const { store } = this.client;
4908
- const dateWithoutMilliseconds = /* @__PURE__ */ new Date();
4909
4886
  const state = store.getState();
4910
- const currentUserId = state.userReducer.currentUser.id;
4911
- dateWithoutMilliseconds.setMilliseconds(0);
4912
- if (!workspaceId) {
4913
- throw new Error("No active workspace ID while creating issue.");
4914
- }
4915
- const issuePayload = offline({
4916
- ...issue,
4917
- submitted_at: dateWithoutMilliseconds.toISOString(),
4918
- index_workspace: workspaceId,
4919
- created_by: currentUserId,
4920
- status: issue.status ?? DEFAULT_ISSUE_STATUS,
4921
- priority: issue.priority ?? DEFAULT_ISSUE_PRIORITY
4922
- });
4923
- this.dispatch(addIssue(issuePayload));
4924
- this.dispatch(addToRecentIssues(issuePayload.offline_id));
4887
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4888
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
4889
+ const offlineIssue = offline({
4890
+ ...payload,
4891
+ submitted_at: submittedAt,
4892
+ created_by: createdBy
4893
+ });
4894
+ this.dispatch(addIssue(offlineIssue));
4895
+ this.dispatch(addToRecentIssues(offlineIssue.offline_id));
4925
4896
  this.dispatch(addActiveProjectIssuesCount(1));
4926
4897
  const promise = this.enqueueRequest({
4927
4898
  description: "Create issue",
4928
4899
  method: HttpMethod.POST,
4929
4900
  url: "/issues/",
4930
4901
  queryParams: {
4931
- workspace_id: workspaceId,
4932
- ...issueType ? { issue_type: issueType } : {}
4902
+ workspace_id: payload.index_workspace,
4903
+ ...payload.issue_type ? { issue_type: payload.issue_type } : {}
4933
4904
  },
4934
- payload: issuePayload,
4935
- blockers: ["add-issue", ...issuePayload.index_workspace ? [issuePayload.index_workspace] : []],
4936
- blocks: [issuePayload.offline_id]
4905
+ payload: offlineIssue,
4906
+ blockers: ["add-issue", ...offlineIssue.index_workspace ? [offlineIssue.index_workspace] : []],
4907
+ blocks: [offlineIssue.offline_id]
4937
4908
  });
4938
4909
  void promise.then((result) => {
4939
4910
  this.dispatch(updateIssue(result));
4940
4911
  }).catch((error) => {
4941
- var _a2;
4912
+ var _a3;
4942
4913
  console.error(error);
4943
4914
  if (error instanceof APIError) {
4944
- (_a2 = unsafeShowToast) == null ? void 0 : _a2({
4915
+ (_a3 = unsafeShowToast) == null ? void 0 : _a3({
4945
4916
  title: "Could not create issue",
4946
4917
  description: error.message,
4947
4918
  accentColor: "red"
4948
4919
  });
4949
4920
  }
4950
- this.dispatch(deleteIssue(issuePayload.offline_id));
4921
+ this.dispatch(deleteIssue(offlineIssue.offline_id));
4951
4922
  this.dispatch(addActiveProjectIssuesCount(-1));
4952
4923
  throw error;
4953
4924
  });
4954
- return [issuePayload, promise];
4925
+ return [offlineIssue, promise];
4955
4926
  }
4956
- update(issue) {
4927
+ update(payload) {
4928
+ var _a2;
4957
4929
  const state = this.client.store.getState();
4958
- const issueToBeUpdated = selectIssueById(issue.offline_id)(state);
4930
+ const issueToBeUpdated = selectIssueById(payload.offline_id)(state);
4959
4931
  if (!issueToBeUpdated) {
4960
4932
  throw new Error(
4961
- `Attempting to update an issue with offline_id ${issue.offline_id} that doesn't exist in the store`
4933
+ `Attempting to update an issue with offline_id ${payload.offline_id} that doesn't exist in the store`
4962
4934
  );
4963
4935
  }
4964
- const updatedIssue = { ...issueToBeUpdated, ...issue };
4936
+ const updatedIssue = { ...issueToBeUpdated, ...payload };
4965
4937
  this.dispatch(updateIssue(updatedIssue));
4966
4938
  const changes = {};
4967
4939
  for (const issueUpdateChange of [
@@ -4973,11 +4945,11 @@ class IssueService extends BaseApiService {
4973
4945
  IssueUpdateChange.ASSIGNED_TO,
4974
4946
  IssueUpdateChange.DUE_DATE
4975
4947
  ]) {
4976
- if (issueUpdateChange in issue && issue[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
4948
+ if (issueUpdateChange in payload && payload[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
4977
4949
  switch (issueUpdateChange) {
4978
4950
  case "category": {
4979
4951
  let categoryOrNull = null;
4980
- const categoryIdOrNull = issue[issueUpdateChange];
4952
+ const categoryIdOrNull = payload[issueUpdateChange];
4981
4953
  if (categoryIdOrNull) {
4982
4954
  categoryOrNull = state.categoryReducer.instances[categoryIdOrNull] ?? null;
4983
4955
  if (!categoryOrNull)
@@ -4994,7 +4966,7 @@ class IssueService extends BaseApiService {
4994
4966
  }
4995
4967
  case "assigned_to": {
4996
4968
  let userOrNull = null;
4997
- const userIdOrNull = issue[issueUpdateChange];
4969
+ const userIdOrNull = payload[issueUpdateChange];
4998
4970
  if (userIdOrNull) {
4999
4971
  userOrNull = state.userReducer.users[userIdOrNull] ?? null;
5000
4972
  if (!userOrNull)
@@ -5009,24 +4981,24 @@ class IssueService extends BaseApiService {
5009
4981
  break;
5010
4982
  }
5011
4983
  case "description":
5012
- changes[issueUpdateChange] = issue[issueUpdateChange] ?? null;
4984
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
5013
4985
  break;
5014
4986
  case "title":
5015
- changes[issueUpdateChange] = issue[issueUpdateChange] ?? null;
4987
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
5016
4988
  break;
5017
4989
  case "priority":
5018
- changes[issueUpdateChange] = issue[issueUpdateChange];
4990
+ changes[issueUpdateChange] = payload[issueUpdateChange];
5019
4991
  break;
5020
4992
  case "status":
5021
- changes[issueUpdateChange] = issue[issueUpdateChange];
4993
+ changes[issueUpdateChange] = payload[issueUpdateChange];
5022
4994
  break;
5023
4995
  case "due_date":
5024
- changes[issueUpdateChange] = issue[issueUpdateChange] ? issue[issueUpdateChange] : null;
4996
+ changes[issueUpdateChange] = payload[issueUpdateChange] ? payload[issueUpdateChange] : null;
5025
4997
  }
5026
4998
  }
5027
4999
  }
5028
5000
  const offlineIssueUpdate = offline({
5029
- created_by: state.userReducer.currentUser.id,
5001
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5030
5002
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5031
5003
  issue: issueToBeUpdated.offline_id,
5032
5004
  changes
@@ -5035,10 +5007,10 @@ class IssueService extends BaseApiService {
5035
5007
  const promise = this.enqueueRequest({
5036
5008
  description: "Edit issue",
5037
5009
  method: HttpMethod.PATCH,
5038
- url: `/issues/${issue.offline_id}/`,
5039
- payload: issue,
5040
- blockers: [issue.offline_id],
5041
- blocks: [issue.offline_id]
5010
+ url: `/issues/${payload.offline_id}/`,
5011
+ payload,
5012
+ blockers: [payload.offline_id],
5013
+ blocks: [payload.offline_id]
5042
5014
  });
5043
5015
  promise.catch(() => {
5044
5016
  this.dispatch(updateIssue(issueToBeUpdated));
@@ -5090,7 +5062,6 @@ class IssueService extends BaseApiService {
5090
5062
  throw e;
5091
5063
  }
5092
5064
  }
5093
- // Special functions
5094
5065
  async refreshStore(projectId) {
5095
5066
  const result = await this.enqueueRequest({
5096
5067
  description: "Get issues",
@@ -5098,33 +5069,24 @@ class IssueService extends BaseApiService {
5098
5069
  url: `/projects/${projectId}/issues/`,
5099
5070
  blockers: [],
5100
5071
  blocks: []
5101
- }).then((result2) => {
5102
- const filteredResult = result2.filter(onlyUniqueOfflineIds);
5103
- if (result2.length !== filteredResult.length) {
5104
- console.error(
5105
- `Received duplicate issues from the API (new length ${filteredResult.length});
5106
- filtered in browser.`
5107
- );
5108
- }
5109
- return filteredResult;
5110
5072
  });
5111
5073
  this.dispatch(initializeIssues(result));
5112
5074
  }
5113
5075
  }
5114
5076
  class IssueTypeService extends BaseApiService {
5115
- add(payload, organizationId) {
5077
+ add(payload) {
5078
+ var _a2;
5116
5079
  const { store } = this.client;
5117
5080
  const state = store.getState();
5118
5081
  const offlineIssueType = offline({
5119
5082
  ...payload,
5120
5083
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5121
- created_by: state.userReducer.currentUser.id,
5122
- organization: organizationId
5084
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id
5123
5085
  });
5124
5086
  this.dispatch(addIssueType(offlineIssueType));
5125
5087
  const promise = this.enqueueRequest({
5126
5088
  method: HttpMethod.POST,
5127
- url: `/organizations/${organizationId}/issue-types/`,
5089
+ url: `/organizations/${payload.organization}/issue-types/`,
5128
5090
  // Sending only whats needed here
5129
5091
  payload: {
5130
5092
  offline_id: offlineIssueType.offline_id,
@@ -5170,20 +5132,20 @@ class IssueTypeService extends BaseApiService {
5170
5132
  });
5171
5133
  return [offlineUpdatedIssueType, promise];
5172
5134
  }
5173
- delete(issueTypeId) {
5135
+ delete(id) {
5174
5136
  const { store } = this.client;
5175
5137
  const state = store.getState();
5176
- const issueTypeToDelete = selectIssueTypeById(issueTypeId)(state);
5138
+ const issueTypeToDelete = selectIssueTypeById(id)(state);
5177
5139
  if (!issueTypeToDelete) {
5178
- throw new Error(`IssueType with offline_id ${issueTypeId} does not exist in the store.`);
5140
+ throw new Error(`IssueType with offline_id ${id} does not exist in the store.`);
5179
5141
  }
5180
- const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(state);
5181
- this.dispatch(removeIssueType(issueTypeId));
5142
+ const issuesOfIssueType = selectIssuesOfIssueType(id)(state);
5143
+ this.dispatch(removeIssueType(id));
5182
5144
  this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
5183
5145
  const promise = this.enqueueRequest({
5184
5146
  method: HttpMethod.DELETE,
5185
- url: `/issues/types/${issueTypeId}/`,
5186
- blockers: [issueTypeId],
5147
+ url: `/issues/types/${id}/`,
5148
+ blockers: [id],
5187
5149
  blocks: []
5188
5150
  });
5189
5151
  promise.catch(() => {
@@ -5241,17 +5203,6 @@ class ProjectAccessService extends BaseApiService {
5241
5203
  }
5242
5204
  }
5243
5205
  class ProjectFileService extends BaseApiService {
5244
- async refreshStore(projectId) {
5245
- const result = await this.enqueueRequest({
5246
- description: "Get project files",
5247
- method: HttpMethod.GET,
5248
- url: `/projects/${projectId}/files/`,
5249
- blockers: [],
5250
- blocks: []
5251
- });
5252
- this.dispatch(addOrReplaceProjectFiles([]));
5253
- this.dispatch(addOrReplaceProjectFiles(result));
5254
- }
5255
5206
  async saveExisting(file) {
5256
5207
  if (!file.offline_id) {
5257
5208
  throw new Error(
@@ -5339,6 +5290,17 @@ class ProjectFileService extends BaseApiService {
5339
5290
  blocks: []
5340
5291
  });
5341
5292
  }
5293
+ async refreshStore(projectId) {
5294
+ const result = await this.enqueueRequest({
5295
+ description: "Get project files",
5296
+ method: HttpMethod.GET,
5297
+ url: `/projects/${projectId}/files/`,
5298
+ blockers: [],
5299
+ blocks: []
5300
+ });
5301
+ this.dispatch(addOrReplaceProjectFiles([]));
5302
+ this.dispatch(addOrReplaceProjectFiles(result));
5303
+ }
5342
5304
  }
5343
5305
  class ProjectAttachmentService extends BaseAttachmentService {
5344
5306
  constructor() {
@@ -5524,8 +5486,9 @@ const separateImageFromFields = async (fields) => {
5524
5486
  };
5525
5487
  class FormService extends BaseUploadService {
5526
5488
  async bulkAddRevisionAttachments(revisionId, files) {
5489
+ var _a2;
5527
5490
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5528
- const createdBy = this.client.store.getState().userReducer.currentUser.id;
5491
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5529
5492
  const filePayloads = {};
5530
5493
  const offlineFormRevisionAttachments = [];
5531
5494
  const attachmentPayloads = [];
@@ -5627,10 +5590,11 @@ class FormService extends BaseUploadService {
5627
5590
  return [form, offlineFormRevision, offlineFormRevisionAttachments, formPromise, attachmentsPromise];
5628
5591
  }
5629
5592
  addForOrganization(organizationId, initialRevision) {
5593
+ var _a2;
5630
5594
  const state = this.client.store.getState();
5631
5595
  const offlineForm = offline({
5632
5596
  favorite: false,
5633
- created_by: state.userReducer.currentUser.id,
5597
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5634
5598
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5635
5599
  organization: organizationId
5636
5600
  });
@@ -5642,45 +5606,49 @@ class FormService extends BaseUploadService {
5642
5606
  );
5643
5607
  }
5644
5608
  addForProject(projectId, initialRevision) {
5609
+ var _a2;
5645
5610
  const state = this.client.store.getState();
5646
5611
  const offlineForm = offline({
5647
5612
  favorite: false,
5648
- created_by: state.userReducer.currentUser.id,
5613
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5649
5614
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5650
5615
  project: projectId
5651
5616
  });
5652
5617
  return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
5653
5618
  }
5654
5619
  addForIssueType(issueTypeId, initialRevision) {
5620
+ var _a2;
5655
5621
  const state = this.client.store.getState();
5656
5622
  const offlineForm = offline({
5657
5623
  favorite: false,
5658
- created_by: state.userReducer.currentUser.id,
5624
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5659
5625
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5660
5626
  issue_type: issueTypeId
5661
5627
  });
5662
5628
  return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
5663
5629
  }
5664
5630
  addForAssetType(assetTypeId, initialRevision) {
5631
+ var _a2;
5665
5632
  const state = this.client.store.getState();
5666
5633
  const offlineForm = offline({
5667
5634
  favorite: false,
5668
- created_by: state.userReducer.currentUser.id,
5635
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5669
5636
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5670
5637
  asset_type: assetTypeId
5671
5638
  });
5672
5639
  return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
5673
5640
  }
5674
5641
  async createRevision(formId, revision) {
5642
+ var _a2;
5675
5643
  const offlineRevision = offline(revision);
5676
5644
  const { store } = this.client;
5677
5645
  const state = store.getState();
5678
- const currentUserId = state.userReducer.currentUser.id;
5646
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
5679
5647
  const { fields, images } = await separateImageFromFields(offlineRevision.fields);
5680
5648
  const fullRevision = {
5681
5649
  ...offlineRevision,
5682
5650
  fields,
5683
- created_by: currentUserId,
5651
+ created_by: createdBy,
5684
5652
  revision: "Pending",
5685
5653
  form: formId,
5686
5654
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -5713,48 +5681,6 @@ class FormService extends BaseUploadService {
5713
5681
  });
5714
5682
  return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
5715
5683
  }
5716
- async favorite(formId, projectId) {
5717
- const { store } = this.client;
5718
- const state = store.getState();
5719
- const form = state.formReducer.instances[formId];
5720
- if (!form) {
5721
- throw new Error(`Expected form to exist, got ${form}`);
5722
- }
5723
- this.dispatch(updateForm({ ...form, favorite: true }));
5724
- try {
5725
- await this.enqueueRequest({
5726
- description: "Favorite form",
5727
- method: HttpMethod.POST,
5728
- url: `/forms/${formId}/favorite/${projectId}/`,
5729
- blockers: [formId, `favorite-${formId}`],
5730
- blocks: [`favorite-${formId}`]
5731
- });
5732
- } catch (e) {
5733
- this.dispatch(updateForm(form));
5734
- throw e;
5735
- }
5736
- }
5737
- async unfavorite(formId, projectId) {
5738
- const { store } = this.client;
5739
- const state = store.getState();
5740
- const form = state.formReducer.instances[formId];
5741
- if (!form) {
5742
- throw new Error(`Expected form to exist, got ${form}`);
5743
- }
5744
- this.dispatch(updateForm({ ...form, favorite: false }));
5745
- try {
5746
- return await this.enqueueRequest({
5747
- description: "Unfavorite form",
5748
- method: HttpMethod.DELETE,
5749
- url: `/forms/${formId}/unfavorite/${projectId}/`,
5750
- blockers: [formId, `favorite-${formId}`],
5751
- blocks: [`favorite-${formId}`]
5752
- });
5753
- } catch (e) {
5754
- this.dispatch(updateForm(form));
5755
- throw e;
5756
- }
5757
- }
5758
5684
  async delete(formId) {
5759
5685
  const { store } = this.client;
5760
5686
  const state = store.getState();
@@ -5871,8 +5797,9 @@ const separateFilesFromValues = (values) => {
5871
5797
  };
5872
5798
  class FormSubmissionService extends BaseUploadService {
5873
5799
  async bulkAddSubmissionAttachments(submissionId, files) {
5800
+ var _a2;
5874
5801
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5875
- const createdBy = this.client.store.getState().userReducer.currentUser.id;
5802
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5876
5803
  const filePayloads = {};
5877
5804
  const offlineFormSubmissionAttachments = [];
5878
5805
  const attachmentPayloads = [];
@@ -5954,13 +5881,14 @@ class FormSubmissionService extends BaseUploadService {
5954
5881
  }
5955
5882
  // Outer promise is for hashing and caching files for submission attachments
5956
5883
  async add(payload) {
5884
+ var _a2;
5957
5885
  const { store } = this.client;
5958
5886
  const state = store.getState();
5959
5887
  const { values, files } = separateFilesFromValues(payload.values);
5960
5888
  const offlineSubmission = offline({
5961
5889
  ...payload,
5962
5890
  values,
5963
- created_by: state.userReducer.currentUser.id,
5891
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5964
5892
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
5965
5893
  });
5966
5894
  const promise = this.enqueueRequest({
@@ -6215,13 +6143,20 @@ class FormSubmissionService extends BaseUploadService {
6215
6143
  }
6216
6144
  }
6217
6145
  class WorkspaceService extends BaseApiService {
6218
- add(workspace) {
6219
- const offlineWorkspace = offline(workspace);
6146
+ add(payload) {
6147
+ var _a2;
6148
+ const { store } = this.client;
6149
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6150
+ const offlineWorkspace = offline({
6151
+ ...payload,
6152
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6153
+ created_by: createdBy
6154
+ });
6220
6155
  this.dispatch(addWorkspace(offlineWorkspace));
6221
6156
  const promise = this.enqueueRequest({
6222
6157
  description: "Create Workspace",
6223
6158
  method: HttpMethod.POST,
6224
- url: `/projects/${workspace.project}/workspaces/`,
6159
+ url: `/projects/${payload.project}/workspaces/`,
6225
6160
  payload: offlineWorkspace,
6226
6161
  blockers: ["add-workspace"],
6227
6162
  blocks: [offlineWorkspace.offline_id]
@@ -6233,8 +6168,14 @@ class WorkspaceService extends BaseApiService {
6233
6168
  });
6234
6169
  return [offlineWorkspace, promise];
6235
6170
  }
6236
- update(workspace) {
6237
- this.dispatch(addWorkspace(workspace));
6171
+ update(payload) {
6172
+ const { store } = this.client;
6173
+ const workspace = selectWorkspaceById(payload.offline_id)(store.getState());
6174
+ if (!workspace) {
6175
+ throw new Error(`Expected an existing workspace with offline_id ${payload.offline_id}`);
6176
+ }
6177
+ const updatedWorkspace = { ...workspace, ...payload };
6178
+ this.dispatch(updateWorkspace(updatedWorkspace));
6238
6179
  const promise = this.enqueueRequest({
6239
6180
  description: "Update Workspace",
6240
6181
  method: HttpMethod.PATCH,
@@ -6243,10 +6184,17 @@ class WorkspaceService extends BaseApiService {
6243
6184
  blockers: [workspace.offline_id],
6244
6185
  blocks: [workspace.offline_id]
6245
6186
  });
6187
+ promise.then((result) => {
6188
+ this.dispatch(updateWorkspace(result));
6189
+ }).catch(() => {
6190
+ this.dispatch(updateWorkspace(workspace));
6191
+ });
6246
6192
  return [workspace, promise];
6247
6193
  }
6248
6194
  delete(workspaceId) {
6249
6195
  const { store } = this.client;
6196
+ const originalWorkspace = selectWorkspaceById(workspaceId)(store.getState());
6197
+ this.dispatch(deleteWorkspace(workspaceId));
6250
6198
  const promise = this.enqueueRequest({
6251
6199
  description: "Delete Workspace",
6252
6200
  method: HttpMethod.DELETE,
@@ -6254,8 +6202,6 @@ class WorkspaceService extends BaseApiService {
6254
6202
  blockers: [workspaceId],
6255
6203
  blocks: []
6256
6204
  });
6257
- const originalWorkspace = store.getState().workspaceReducer.instances[workspaceId];
6258
- this.dispatch(deleteWorkspace(workspaceId));
6259
6205
  void promise.then(() => {
6260
6206
  }).catch((reason) => {
6261
6207
  if (originalWorkspace) {
@@ -6757,12 +6703,13 @@ class LicenseService extends BaseApiService {
6757
6703
  }
6758
6704
  class DocumentService extends BaseApiService {
6759
6705
  add(payload) {
6706
+ var _a2;
6760
6707
  const { store } = this.client;
6761
- const currentUserId = store.getState().userReducer.currentUser.id;
6708
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6762
6709
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6763
6710
  const offlineDocument = offline({
6764
6711
  ...payload,
6765
- created_by: currentUserId,
6712
+ created_by: createdBy,
6766
6713
  submitted_at: submittedAt
6767
6714
  });
6768
6715
  this.dispatch(addDocuments([offlineDocument]));
@@ -6791,7 +6738,11 @@ class DocumentService extends BaseApiService {
6791
6738
  `attempting to update a document with offline_id ${document2.offline_id} that does not exist in store.documents`
6792
6739
  );
6793
6740
  }
6794
- this.dispatch(updateDocuments([document2]));
6741
+ const updatedDocument = {
6742
+ ...documentToBeUpdated,
6743
+ ...document2
6744
+ };
6745
+ this.dispatch(updateDocuments([updatedDocument]));
6795
6746
  const promise = this.enqueueRequest({
6796
6747
  description: "Update Document",
6797
6748
  method: HttpMethod.PATCH,
@@ -6803,8 +6754,7 @@ class DocumentService extends BaseApiService {
6803
6754
  promise.catch(() => {
6804
6755
  updateDocuments([documentToBeUpdated]);
6805
6756
  });
6806
- const fullDocument = store.getState().documentsReducer.documents[document2.offline_id];
6807
- return [fullDocument, promise];
6757
+ return [updatedDocument, promise];
6808
6758
  }
6809
6759
  move(documentId, targetDocumentId, position) {
6810
6760
  const { store } = this.client;
@@ -6851,22 +6801,22 @@ class DocumentService extends BaseApiService {
6851
6801
  });
6852
6802
  return promise;
6853
6803
  }
6854
- delete(documentId) {
6804
+ delete(id) {
6855
6805
  const { store } = this.client;
6856
6806
  const documentsMapping = selectDocumentsMapping(store.getState());
6857
- const documentToBeDeleted = documentsMapping[documentId];
6807
+ const documentToBeDeleted = selectDocumentById(id)(store.getState());
6858
6808
  if (!documentToBeDeleted) {
6859
6809
  throw new Error(
6860
- `attempting to delete a document with offline_id ${documentId} that does not exist in store.documents`
6810
+ `attempting to delete a document with offline_id ${id} that does not exist in store.documents`
6861
6811
  );
6862
6812
  }
6863
6813
  const parentDocument = documentToBeDeleted.parent_document ? documentsMapping[documentToBeDeleted.parent_document] : void 0;
6864
- this.dispatch(removeDocuments([documentId]));
6814
+ this.dispatch(removeDocuments([id]));
6865
6815
  const promise = this.enqueueRequest({
6866
6816
  description: "Delete Document",
6867
6817
  method: HttpMethod.DELETE,
6868
- url: `/documents/${documentId}/`,
6869
- blockers: [documentId],
6818
+ url: `/documents/${id}/`,
6819
+ blockers: [id],
6870
6820
  blocks: []
6871
6821
  });
6872
6822
  promise.then((documentsToUpdate) => {
@@ -6924,8 +6874,9 @@ class DocumentAttachmentService extends BaseAttachmentService {
6924
6874
  }
6925
6875
  // NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
6926
6876
  async attachFilesToDocument(files, documentId) {
6877
+ var _a2;
6927
6878
  const { store } = this.client;
6928
- const currentUser = store.getState().userReducer.currentUser;
6879
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6929
6880
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6930
6881
  const offlineAttachments = [];
6931
6882
  const attachmentPayloads = [];
@@ -6947,7 +6898,7 @@ class DocumentAttachmentService extends BaseAttachmentService {
6947
6898
  file,
6948
6899
  sha1,
6949
6900
  submittedAt,
6950
- createdBy: currentUser.id,
6901
+ createdBy,
6951
6902
  description: "",
6952
6903
  modelId: documentId
6953
6904
  });
@@ -7110,10 +7061,9 @@ class AgentService extends BaseApiService {
7110
7061
  }
7111
7062
  }
7112
7063
  class TeamService extends BaseApiService {
7113
- add(teamPayload, organizationId) {
7064
+ add(payload) {
7114
7065
  const offlineTeam = offline({
7115
- ...teamPayload,
7116
- organization: organizationId,
7066
+ ...payload,
7117
7067
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7118
7068
  // TODO: uncomment once supported
7119
7069
  // created_by: state.userReducer.currentUser.id,
@@ -7122,7 +7072,7 @@ class TeamService extends BaseApiService {
7122
7072
  const promise = this.enqueueRequest({
7123
7073
  description: "Create team",
7124
7074
  method: HttpMethod.POST,
7125
- url: `/organizations/${organizationId}/teams/`,
7075
+ url: `/organizations/${payload.organization}/teams/`,
7126
7076
  payload: offlineTeam,
7127
7077
  // No blocks since users and organizations are not offline
7128
7078
  blockers: [],
@@ -7135,25 +7085,24 @@ class TeamService extends BaseApiService {
7135
7085
  });
7136
7086
  return [offlineTeam, promise];
7137
7087
  }
7138
- // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
7139
- update(team) {
7088
+ update(payload) {
7140
7089
  const { store } = this.client;
7141
- const teamToBeUpdated = selectTeamById(team.offline_id)(store.getState());
7090
+ const teamToBeUpdated = selectTeamById(payload.offline_id)(store.getState());
7142
7091
  if (!teamToBeUpdated) {
7143
- throw new Error(`Expected team with offline_id ${team.offline_id} to exist`);
7092
+ throw new Error(`Expected team with offline_id ${payload.offline_id} to exist`);
7144
7093
  }
7145
7094
  const offlineUpdatedTeam = {
7146
7095
  ...teamToBeUpdated,
7147
- ...team
7096
+ ...payload
7148
7097
  };
7149
7098
  this.dispatch(updateTeam(offlineUpdatedTeam));
7150
7099
  const promise = this.enqueueRequest({
7151
7100
  description: "Update team",
7152
7101
  method: HttpMethod.PATCH,
7153
- url: `/organizations/teams/${team.offline_id}/`,
7102
+ url: `/organizations/teams/${payload.offline_id}/`,
7154
7103
  payload: offlineUpdatedTeam,
7155
- blockers: [team.offline_id],
7156
- blocks: [team.offline_id]
7104
+ blockers: [payload.offline_id],
7105
+ blocks: [payload.offline_id]
7157
7106
  });
7158
7107
  promise.then((updatedTeam) => {
7159
7108
  this.dispatch(setTeam(updatedTeam));
@@ -7265,10 +7214,11 @@ class UserService extends BaseApiService {
7265
7214
  }
7266
7215
  class GeoImageService extends BaseUploadService {
7267
7216
  async add(payload) {
7217
+ var _a2;
7268
7218
  const { store } = this.client;
7269
7219
  const { file, ...payloadWithoutFile } = payload;
7270
7220
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7271
- const currentUser = store.getState().userReducer.currentUser;
7221
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7272
7222
  const projectId = payloadWithoutFile.project;
7273
7223
  const sha1 = await hashFile(file);
7274
7224
  const filePayload = {
@@ -7283,9 +7233,9 @@ class GeoImageService extends BaseUploadService {
7283
7233
  file_sha1: sha1,
7284
7234
  file: URL.createObjectURL(file),
7285
7235
  submitted_at: submittedAt,
7286
- created_by: currentUser.id
7236
+ created_by: createdBy
7287
7237
  });
7288
- store.dispatch(addGeoImage(offlineMapImage));
7238
+ this.dispatch(addGeoImage(offlineMapImage));
7289
7239
  const promise = this.enqueueRequest({
7290
7240
  description: "Add geo image",
7291
7241
  method: HttpMethod.POST,
@@ -7309,16 +7259,17 @@ class GeoImageService extends BaseUploadService {
7309
7259
  });
7310
7260
  promise.then((result) => {
7311
7261
  this.processPresignedUrls(result.presigned_urls);
7312
- store.dispatch(setGeoImage(result.geo_image));
7262
+ this.dispatch(setGeoImage(result.geo_image));
7313
7263
  }).catch(() => {
7314
- store.dispatch(deleteGeoImage(offlineMapImage.offline_id));
7264
+ this.dispatch(deleteGeoImage(offlineMapImage.offline_id));
7315
7265
  });
7316
7266
  return [offlineMapImage, promise.then((result) => result.geo_image)];
7317
7267
  }
7318
7268
  async bulkAdd(payloads, projectId) {
7269
+ var _a2;
7319
7270
  const { store } = this.client;
7320
7271
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7321
- const currentUser = store.getState().userReducer.currentUser;
7272
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7322
7273
  const offlineGeoImages = [];
7323
7274
  const offlineIds = [];
7324
7275
  const geoImagePayloads = [];
@@ -7341,7 +7292,7 @@ class GeoImageService extends BaseUploadService {
7341
7292
  file_sha1: sha1,
7342
7293
  file: URL.createObjectURL(file),
7343
7294
  submitted_at: submittedAt,
7344
- created_by: currentUser.id,
7295
+ created_by: createdBy,
7345
7296
  project: projectId
7346
7297
  });
7347
7298
  offlineGeoImages.push(offlineMapImage);
@@ -7358,7 +7309,7 @@ class GeoImageService extends BaseUploadService {
7358
7309
  original_date: offlineMapImage.original_date
7359
7310
  });
7360
7311
  }
7361
- store.dispatch(addGeoImages(offlineGeoImages));
7312
+ this.dispatch(addGeoImages(offlineGeoImages));
7362
7313
  const promise = this.enqueueRequest({
7363
7314
  description: "Bulk add geo images",
7364
7315
  method: HttpMethod.POST,
@@ -7374,9 +7325,9 @@ class GeoImageService extends BaseUploadService {
7374
7325
  });
7375
7326
  promise.then((result) => {
7376
7327
  this.processPresignedUrls(result.presigned_urls);
7377
- store.dispatch(setGeoImages(result.geo_images));
7328
+ this.dispatch(setGeoImages(result.geo_images));
7378
7329
  }).catch(() => {
7379
- store.dispatch(deleteGeoImages(offlineIds));
7330
+ this.dispatch(deleteGeoImages(offlineIds));
7380
7331
  });
7381
7332
  return [offlineGeoImages, promise.then((result) => result.geo_images)];
7382
7333
  }
@@ -7388,7 +7339,7 @@ class GeoImageService extends BaseUploadService {
7388
7339
  throw new Error(`Map image with offline_id ${payload.offline_id} does not exist in the store`);
7389
7340
  }
7390
7341
  const updatedGeoImage = { ...geoImageToUpdate, ...payload };
7391
- store.dispatch(updateGeoImage(updatedGeoImage));
7342
+ this.dispatch(updateGeoImage(updatedGeoImage));
7392
7343
  const promise = this.enqueueRequest({
7393
7344
  description: "Update geo image",
7394
7345
  method: HttpMethod.PATCH,
@@ -7398,9 +7349,9 @@ class GeoImageService extends BaseUploadService {
7398
7349
  blockers: [payload.offline_id]
7399
7350
  });
7400
7351
  promise.then((result) => {
7401
- store.dispatch(setGeoImage(result));
7352
+ this.dispatch(setGeoImage(result));
7402
7353
  }).catch(() => {
7403
- store.dispatch(setGeoImage(geoImageToUpdate));
7354
+ this.dispatch(setGeoImage(geoImageToUpdate));
7404
7355
  });
7405
7356
  return [updatedGeoImage, promise];
7406
7357
  }
@@ -7411,7 +7362,7 @@ class GeoImageService extends BaseUploadService {
7411
7362
  if (!geoImageToDelete) {
7412
7363
  throw new Error(`Map image with offline_id ${geoImageId} does not exist in the store`);
7413
7364
  }
7414
- store.dispatch(deleteGeoImage(geoImageId));
7365
+ this.dispatch(deleteGeoImage(geoImageId));
7415
7366
  const promise = this.enqueueRequest({
7416
7367
  description: "Delete geo image",
7417
7368
  method: HttpMethod.DELETE,
@@ -7420,12 +7371,11 @@ class GeoImageService extends BaseUploadService {
7420
7371
  blockers: [geoImageId]
7421
7372
  });
7422
7373
  promise.catch(() => {
7423
- store.dispatch(setGeoImage(geoImageToDelete));
7374
+ this.dispatch(setGeoImage(geoImageToDelete));
7424
7375
  });
7425
7376
  return promise;
7426
7377
  }
7427
7378
  async refreshStore(projectId) {
7428
- const { store } = this.client;
7429
7379
  const result = await this.enqueueRequest({
7430
7380
  description: "Get geo images",
7431
7381
  method: HttpMethod.GET,
@@ -7433,14 +7383,15 @@ class GeoImageService extends BaseUploadService {
7433
7383
  blocks: [projectId.toString()],
7434
7384
  blockers: []
7435
7385
  });
7436
- store.dispatch(initializeGeoImages(result));
7386
+ this.dispatch(initializeGeoImages(result));
7437
7387
  }
7438
7388
  }
7439
7389
  class IssueAssociationService extends BaseUploadService {
7440
7390
  add(payload) {
7391
+ var _a2;
7441
7392
  const { store } = this.client;
7442
7393
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7443
- const createdBy = store.getState().userReducer.currentUser.id;
7394
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7444
7395
  const offlineIssueAssociation = offline({
7445
7396
  ...payload,
7446
7397
  submitted_at: submittedAt,
@@ -7454,7 +7405,6 @@ class IssueAssociationService extends BaseUploadService {
7454
7405
  payload: {
7455
7406
  offline_id: offlineIssueAssociation.offline_id,
7456
7407
  submitted_at: submittedAt,
7457
- created_by: createdBy,
7458
7408
  ...payload
7459
7409
  },
7460
7410
  blockers: [
@@ -7579,7 +7529,6 @@ export {
7579
7529
  addDocumentAttachments,
7580
7530
  addDocuments,
7581
7531
  addEmailDomain,
7582
- addFavouriteProjectId,
7583
7532
  addForm,
7584
7533
  addFormRevision,
7585
7534
  addFormRevisionAttachment,
@@ -7809,7 +7758,6 @@ export {
7809
7758
  rehydratedReducer,
7810
7759
  rehydratedSlice,
7811
7760
  removeDocuments,
7812
- removeFavouriteProjectId,
7813
7761
  removeIssueType,
7814
7762
  removeProjectFile,
7815
7763
  removeProjectFilesOfProject,
@@ -7888,7 +7836,6 @@ export {
7888
7836
  selectEmailDomains,
7889
7837
  selectEmailDomainsAsMapping,
7890
7838
  selectEmailDomainsOfOrganization,
7891
- selectFavouriteProjects,
7892
7839
  selectFilteredForms,
7893
7840
  selectFormById,
7894
7841
  selectFormMapping,
@@ -7929,6 +7876,7 @@ export {
7929
7876
  selectIssueAttachmentMapping,
7930
7877
  selectIssueAttachments,
7931
7878
  selectIssueById,
7879
+ selectIssueCommentById,
7932
7880
  selectIssueCommentMapping,
7933
7881
  selectIssueCountOfCategory,
7934
7882
  selectIssueMapping,
@@ -8045,7 +7993,6 @@ export {
8045
7993
  setStageCompletions,
8046
7994
  setTeam,
8047
7995
  setTokens,
8048
- setTourStep,
8049
7996
  setUploadUrl,
8050
7997
  setUsers,
8051
7998
  setWorkspaces,