@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.
@@ -1621,12 +1621,7 @@ var __publicField = (obj, key, value) => {
1621
1621
  })(LicenseStatus || {});
1622
1622
  const initialState$p = {
1623
1623
  users: {},
1624
- currentUser: {
1625
- id: 0,
1626
- username: "",
1627
- email: "",
1628
- profile: { file: null, file_sha1: null, favourite_project_ids: [], tour_step: -1 }
1629
- }
1624
+ currentUser: null
1630
1625
  };
1631
1626
  const userSlice = toolkit.createSlice({
1632
1627
  name: "users",
@@ -1649,6 +1644,8 @@ var __publicField = (obj, key, value) => {
1649
1644
  state.currentUser = action.payload;
1650
1645
  },
1651
1646
  setProfilePicture: (state, action) => {
1647
+ if (!state.currentUser)
1648
+ return;
1652
1649
  state.currentUser.profile.file = action.payload.file ?? null;
1653
1650
  state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1654
1651
  const currentUser = state.users[state.currentUser.id];
@@ -1658,32 +1655,12 @@ var __publicField = (obj, key, value) => {
1658
1655
  currentUser.profile.file = action.payload.file ?? null;
1659
1656
  currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1660
1657
  },
1661
- addFavouriteProjectId: (state, action) => {
1662
- state.currentUser.profile.favourite_project_ids.push(action.payload);
1663
- },
1664
- removeFavouriteProjectId: (state, action) => {
1665
- state.currentUser.profile.favourite_project_ids = state.currentUser.profile.favourite_project_ids.filter(
1666
- (id) => id !== action.payload
1667
- );
1668
- },
1669
- setTourStep: (state, action) => {
1670
- state.currentUser.profile.tour_step = action.payload;
1671
- },
1672
1658
  removeUser: (state, action) => {
1673
1659
  delete state.users[action.payload];
1674
1660
  }
1675
1661
  }
1676
1662
  });
1677
- const {
1678
- setCurrentUser,
1679
- setProfilePicture,
1680
- setUsers,
1681
- addUsers,
1682
- addFavouriteProjectId,
1683
- removeFavouriteProjectId,
1684
- setTourStep,
1685
- removeUser
1686
- } = userSlice.actions;
1663
+ const { setCurrentUser, setProfilePicture, setUsers, addUsers, removeUser } = userSlice.actions;
1687
1664
  const userReducer = userSlice.reducer;
1688
1665
  const selectCurrentUser = (state) => state.userReducer.currentUser;
1689
1666
  const selectUsersMapping = (state) => state.userReducer.users;
@@ -1704,7 +1681,6 @@ var __publicField = (obj, key, value) => {
1704
1681
  return fallbackToEmptyArray(users);
1705
1682
  })
1706
1683
  );
1707
- const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
1708
1684
  const organizationAccessAdapter = createModelAdapter(
1709
1685
  (organizationAccess) => organizationAccess.offline_id
1710
1686
  );
@@ -1730,7 +1706,7 @@ var __publicField = (obj, key, value) => {
1730
1706
  [selectCurrentUser, selectOrganizationAccesses],
1731
1707
  (currentUser, organizationAccesses) => {
1732
1708
  const activeOrganizationAccess = Object.values(organizationAccesses).find(
1733
- (organizationAccess) => organizationAccess.user === currentUser.id
1709
+ (organizationAccess) => organizationAccess.user === (currentUser == null ? void 0 : currentUser.id)
1734
1710
  );
1735
1711
  return activeOrganizationAccess ?? null;
1736
1712
  }
@@ -1807,7 +1783,7 @@ var __publicField = (obj, key, value) => {
1807
1783
  const currentUser = state.userReducer.currentUser;
1808
1784
  const activeProjectId = state.projectReducer.activeProjectId;
1809
1785
  return Object.values(state.projectAccessReducer.instances).find((projectAccess) => {
1810
- return projectAccess.user === currentUser.id && projectAccess.project === activeProjectId;
1786
+ return projectAccess.user === (currentUser == null ? void 0 : currentUser.id) && projectAccess.project === activeProjectId;
1811
1787
  }) ?? null;
1812
1788
  };
1813
1789
  const selectProjectAccessForUser = (user) => (state) => {
@@ -1920,9 +1896,9 @@ var __publicField = (obj, key, value) => {
1920
1896
  [selectCurrentUser, selectProjectUsersAsMapping, selectProjectAccessUserMapping],
1921
1897
  (currentUser, userMapping, projectAccessMapping) => {
1922
1898
  return Object.values(userMapping).sort((userA, userB) => {
1923
- if (userA.id === currentUser.id) {
1899
+ if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
1924
1900
  return -1;
1925
- } else if (userB.id === currentUser.id) {
1901
+ } else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
1926
1902
  return 1;
1927
1903
  }
1928
1904
  const projectAccessesA = projectAccessMapping[userA.id];
@@ -1999,9 +1975,9 @@ var __publicField = (obj, key, value) => {
1999
1975
  [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2000
1976
  (currentUser, userMapping, organizationAccessMapping) => {
2001
1977
  return Object.values(userMapping).sort((userA, userB) => {
2002
- if (userA.id === currentUser.id) {
1978
+ if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
2003
1979
  return -1;
2004
- } else if (userB.id === currentUser.id) {
1980
+ } else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
2005
1981
  return 1;
2006
1982
  }
2007
1983
  const organizationAccessesA = organizationAccessMapping[userA.id];
@@ -2363,29 +2339,18 @@ var __publicField = (obj, key, value) => {
2363
2339
  (_state, search) => search
2364
2340
  ],
2365
2341
  (formsMapping, revisions, search) => {
2366
- const { searchTerm, maxResults, favorites, organization } = search;
2367
- const favoriteMatches = [];
2342
+ const { searchTerm, maxResults, organization } = search;
2368
2343
  const regularMatches = [];
2369
2344
  for (const [formId, form] of Object.entries(formsMapping)) {
2370
- if (favorites !== void 0 && form.favorite != favorites)
2371
- continue;
2372
2345
  if (Number.isInteger(organization) && organization !== form.organization) {
2373
2346
  continue;
2374
2347
  }
2375
2348
  const latestRevision = _selectLatestFormRevision(revisions, formId);
2376
2349
  if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
2377
- if (form.favorite) {
2378
- favoriteMatches.push({ ...form, latestRevision });
2379
- } else {
2380
- regularMatches.push({ ...form, latestRevision });
2381
- }
2382
- }
2383
- if (favoriteMatches.length >= maxResults) {
2384
- break;
2350
+ regularMatches.push(form);
2385
2351
  }
2386
2352
  }
2387
- const maxRegularMatches = maxResults - favoriteMatches.length;
2388
- return [...favoriteMatches, ...regularMatches.slice(0, maxRegularMatches)];
2353
+ return [...regularMatches.slice(0, maxResults)];
2389
2354
  },
2390
2355
  // as the argument is an object, we check the first level of properties for equality
2391
2356
  { memoizeOptions: { equalityCheck: shallowEqual } }
@@ -3119,13 +3084,13 @@ var __publicField = (obj, key, value) => {
3119
3084
  deleteIssueComments
3120
3085
  } = issueCommentSlice.actions;
3121
3086
  const selectIssueCommentMapping = (state) => state.issueCommentReducer.instances;
3087
+ const selectIssueCommentById = (id) => (state) => {
3088
+ return state.issueCommentReducer.instances[id];
3089
+ };
3122
3090
  const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
3123
- toolkit.createSelector(
3124
- [selectIssueCommentMapping, (_state, issueId) => issueId],
3125
- (commentMapping, issueId) => {
3126
- return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
3127
- }
3128
- )
3091
+ toolkit.createSelector([selectIssueCommentMapping, (_state, issueId) => issueId], (commentMapping, issueId) => {
3092
+ return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
3093
+ })
3129
3094
  );
3130
3095
  const issueCommentReducer = issueCommentSlice.reducer;
3131
3096
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
@@ -4035,57 +4000,66 @@ var __publicField = (obj, key, value) => {
4035
4000
  }
4036
4001
  }
4037
4002
  class CategoryService extends BaseApiService {
4038
- add(category, workspaceId) {
4039
- const offlineCategory = offline(category);
4040
- const categoryWithWorkspace = { ...offlineCategory, workspace: workspaceId };
4041
- this.dispatch(addCategory(categoryWithWorkspace));
4003
+ add(payload) {
4004
+ var _a2;
4005
+ const { store } = this.client;
4006
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
4007
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4008
+ const offlineCategory = offline({
4009
+ ...payload,
4010
+ created_by: createdBy,
4011
+ submitted_at: submittedAt
4012
+ });
4013
+ this.dispatch(addCategory(offlineCategory));
4042
4014
  const promise = this.enqueueRequest({
4043
4015
  description: "Create Category",
4044
4016
  method: HttpMethod.POST,
4045
4017
  url: "/categories/",
4046
4018
  queryParams: {
4047
- workspace_id: workspaceId.toString()
4019
+ workspace_id: payload.workspace.toString()
4048
4020
  },
4049
4021
  payload: offlineCategory,
4050
- blockers: [],
4022
+ blockers: [payload.workspace],
4051
4023
  blocks: [offlineCategory.offline_id]
4052
4024
  });
4053
- return [categoryWithWorkspace, promise];
4025
+ return [offlineCategory, promise];
4054
4026
  }
4055
- update(category, workspaceId) {
4027
+ update(payload) {
4056
4028
  const state = this.client.store.getState();
4057
- const existingCategory = selectCategoryById(category.offline_id)(state);
4029
+ const existingCategory = selectCategoryById(payload.offline_id)(state);
4058
4030
  if (!existingCategory) {
4059
- throw new Error(`Expected an existing category with offline_id ${category.offline_id}`);
4031
+ throw new Error(`Expected an existing category with offline_id ${payload.offline_id}`);
4060
4032
  }
4061
- const optimisticCategory = { ...existingCategory, ...category };
4033
+ const optimisticCategory = { ...existingCategory, ...payload };
4062
4034
  this.dispatch(updateCategory(optimisticCategory));
4063
4035
  const promise = this.enqueueRequest({
4064
4036
  description: "Edit Category",
4065
4037
  method: HttpMethod.PATCH,
4066
- url: `/categories/${category.offline_id}/`,
4067
- queryParams: {
4068
- workspace_id: workspaceId.toString()
4069
- },
4070
- payload: category,
4071
- blockers: [category.offline_id],
4072
- blocks: [category.offline_id]
4038
+ url: `/categories/${payload.offline_id}/`,
4039
+ payload,
4040
+ blockers: [payload.offline_id],
4041
+ blocks: [payload.offline_id]
4073
4042
  });
4074
4043
  return [optimisticCategory, promise];
4075
4044
  }
4076
- remove(category, workspaceId) {
4077
- this.dispatch(deleteCategory(category.offline_id));
4078
- return this.enqueueRequest({
4045
+ remove(id) {
4046
+ const { store } = this.client;
4047
+ const category = selectCategoryById(id)(store.getState());
4048
+ if (!category) {
4049
+ throw new Error(`No category with id ${id} found in the store`);
4050
+ }
4051
+ this.dispatch(deleteCategory(id));
4052
+ const promise = this.enqueueRequest({
4079
4053
  description: "Delete Category",
4080
4054
  method: HttpMethod.DELETE,
4081
4055
  url: `/categories/${category.offline_id}/`,
4082
- // TODO: Shouldn't be necessary to specify workspace_id here
4083
- queryParams: {
4084
- workspace_id: workspaceId.toString()
4085
- },
4086
4056
  blockers: [category.offline_id],
4087
4057
  blocks: []
4088
4058
  });
4059
+ promise.catch(() => {
4060
+ this.dispatch(addCategory(category));
4061
+ });
4062
+ return promise;
4089
4063
  }
4090
4064
  async refreshStore(projectId) {
4091
4065
  const result = await this.enqueueRequest({
@@ -4539,8 +4513,9 @@ var __publicField = (obj, key, value) => {
4539
4513
  };
4540
4514
  class BaseAttachmentService extends BaseUploadService {
4541
4515
  async attachFiles(files, modelId, buildOfflineAttachment) {
4516
+ var _a2;
4542
4517
  const { store } = this.client;
4543
- const currentUser = store.getState().userReducer.currentUser;
4518
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
4544
4519
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4545
4520
  const offlineAttachments = [];
4546
4521
  const attachmentPayloads = [];
@@ -4560,7 +4535,7 @@ var __publicField = (obj, key, value) => {
4560
4535
  file,
4561
4536
  sha1,
4562
4537
  submittedAt,
4563
- createdBy: currentUser.id,
4538
+ createdBy,
4564
4539
  description: "",
4565
4540
  modelId
4566
4541
  });
@@ -4764,21 +4739,21 @@ var __publicField = (obj, key, value) => {
4764
4739
  }
4765
4740
  }
4766
4741
  class IssueCommentService extends BaseApiService {
4767
- // Omit author and submitted_at since these will always be set internally
4768
- add(comment) {
4742
+ add(payload) {
4743
+ var _a2;
4769
4744
  const { store } = this.client;
4770
4745
  const offlineComment = offline({
4771
- ...comment,
4772
- author: store.getState().userReducer.currentUser.id,
4746
+ ...payload,
4747
+ author: (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
4773
4748
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
4774
4749
  });
4775
4750
  this.dispatch(addIssueComment(offlineComment));
4776
4751
  const promise = this.enqueueRequest({
4777
- description: `${truncate(comment.content, 80)}`,
4752
+ description: "Add issue comment",
4778
4753
  method: HttpMethod.POST,
4779
- url: `/issues/${comment.issue}/comment/`,
4754
+ url: `/issues/${payload.issue}/comment/`,
4780
4755
  payload: offlineComment,
4781
- blockers: [comment.issue],
4756
+ blockers: [payload.issue],
4782
4757
  blocks: [offlineComment.offline_id]
4783
4758
  });
4784
4759
  promise.catch(() => {
@@ -4786,37 +4761,41 @@ var __publicField = (obj, key, value) => {
4786
4761
  });
4787
4762
  return [offlineComment, promise];
4788
4763
  }
4789
- update(comment) {
4764
+ update(payload) {
4790
4765
  const { store } = this.client;
4791
- const commentToUpdate = store.getState().issueCommentReducer.instances[comment.offline_id];
4766
+ const commentToUpdate = selectIssueCommentById(payload.offline_id)(store.getState());
4792
4767
  if (!commentToUpdate) {
4793
- throw new Error(`Comment with offline_id ${comment.offline_id} not found in store`);
4768
+ throw new Error(`Comment with offline_id ${payload.offline_id} not found in store`);
4794
4769
  }
4795
- this.dispatch(setIssueComment(comment));
4770
+ const updatedComment = {
4771
+ ...commentToUpdate,
4772
+ ...payload
4773
+ };
4774
+ this.dispatch(setIssueComment(updatedComment));
4796
4775
  const promise = this.enqueueRequest({
4797
- description: `Edit comment: ${truncate(comment.content, 80)}`,
4776
+ description: "Edit issue comment",
4798
4777
  method: HttpMethod.PATCH,
4799
- url: `/issues/comments/${comment.offline_id}/`,
4800
- payload: comment,
4801
- blockers: [comment.issue],
4802
- blocks: [comment.offline_id]
4778
+ url: `/issues/comments/${payload.offline_id}/`,
4779
+ payload,
4780
+ blockers: [payload.offline_id],
4781
+ blocks: [payload.offline_id]
4803
4782
  });
4804
4783
  promise.catch(() => {
4805
4784
  this.dispatch(setIssueComment(commentToUpdate));
4806
4785
  });
4807
- return [comment, promise];
4786
+ return [updatedComment, promise];
4808
4787
  }
4809
- remove(offline_id) {
4810
- const commentToRemove = this.client.store.getState().issueCommentReducer.instances[offline_id];
4788
+ remove(id) {
4789
+ const commentToRemove = this.client.store.getState().issueCommentReducer.instances[id];
4811
4790
  if (!commentToRemove) {
4812
- throw new Error(`Comment with offline_id ${offline_id} not found in store`);
4791
+ throw new Error(`Comment with offline_id ${id} not found in store`);
4813
4792
  }
4814
- this.dispatch(deleteIssueComment(offline_id));
4793
+ this.dispatch(deleteIssueComment(id));
4815
4794
  const promise = this.enqueueRequest({
4816
4795
  description: "Delete comment",
4817
4796
  method: HttpMethod.DELETE,
4818
- url: `/issues/comments/${offline_id}/`,
4819
- blockers: [offline_id],
4797
+ url: `/issues/comments/${id}/`,
4798
+ blockers: [id],
4820
4799
  blocks: []
4821
4800
  });
4822
4801
  promise.catch(() => {
@@ -4889,67 +4868,60 @@ var __publicField = (obj, key, value) => {
4889
4868
  }
4890
4869
  class IssueService extends BaseApiService {
4891
4870
  // Basic CRUD functions
4892
- // TODO: Once all models are represented in `Created<TModel>`, use `Created` in `OptimisticModelResult`, so we don't
4893
- // have to repeat it for all optimistic model results (all optimistic results are created).
4894
- add(issue, workspaceId, issueType = null) {
4871
+ add(payload) {
4872
+ var _a2;
4895
4873
  const { store } = this.client;
4896
- const dateWithoutMilliseconds = /* @__PURE__ */ new Date();
4897
4874
  const state = store.getState();
4898
- const currentUserId = state.userReducer.currentUser.id;
4899
- dateWithoutMilliseconds.setMilliseconds(0);
4900
- if (!workspaceId) {
4901
- throw new Error("No active workspace ID while creating issue.");
4902
- }
4903
- const issuePayload = offline({
4904
- ...issue,
4905
- submitted_at: dateWithoutMilliseconds.toISOString(),
4906
- index_workspace: workspaceId,
4907
- created_by: currentUserId,
4908
- status: issue.status ?? DEFAULT_ISSUE_STATUS,
4909
- priority: issue.priority ?? DEFAULT_ISSUE_PRIORITY
4910
- });
4911
- this.dispatch(addIssue(issuePayload));
4912
- this.dispatch(addToRecentIssues(issuePayload.offline_id));
4875
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4876
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
4877
+ const offlineIssue = offline({
4878
+ ...payload,
4879
+ submitted_at: submittedAt,
4880
+ created_by: createdBy
4881
+ });
4882
+ this.dispatch(addIssue(offlineIssue));
4883
+ this.dispatch(addToRecentIssues(offlineIssue.offline_id));
4913
4884
  this.dispatch(addActiveProjectIssuesCount(1));
4914
4885
  const promise = this.enqueueRequest({
4915
4886
  description: "Create issue",
4916
4887
  method: HttpMethod.POST,
4917
4888
  url: "/issues/",
4918
4889
  queryParams: {
4919
- workspace_id: workspaceId,
4920
- ...issueType ? { issue_type: issueType } : {}
4890
+ workspace_id: payload.index_workspace,
4891
+ ...payload.issue_type ? { issue_type: payload.issue_type } : {}
4921
4892
  },
4922
- payload: issuePayload,
4923
- blockers: ["add-issue", ...issuePayload.index_workspace ? [issuePayload.index_workspace] : []],
4924
- blocks: [issuePayload.offline_id]
4893
+ payload: offlineIssue,
4894
+ blockers: ["add-issue", ...offlineIssue.index_workspace ? [offlineIssue.index_workspace] : []],
4895
+ blocks: [offlineIssue.offline_id]
4925
4896
  });
4926
4897
  void promise.then((result) => {
4927
4898
  this.dispatch(updateIssue(result));
4928
4899
  }).catch((error) => {
4929
- var _a2;
4900
+ var _a3;
4930
4901
  console.error(error);
4931
4902
  if (error instanceof APIError) {
4932
- (_a2 = blocks.unsafeShowToast) == null ? void 0 : _a2.call(blocks, {
4903
+ (_a3 = blocks.unsafeShowToast) == null ? void 0 : _a3.call(blocks, {
4933
4904
  title: "Could not create issue",
4934
4905
  description: error.message,
4935
4906
  accentColor: "red"
4936
4907
  });
4937
4908
  }
4938
- this.dispatch(deleteIssue(issuePayload.offline_id));
4909
+ this.dispatch(deleteIssue(offlineIssue.offline_id));
4939
4910
  this.dispatch(addActiveProjectIssuesCount(-1));
4940
4911
  throw error;
4941
4912
  });
4942
- return [issuePayload, promise];
4913
+ return [offlineIssue, promise];
4943
4914
  }
4944
- update(issue) {
4915
+ update(payload) {
4916
+ var _a2;
4945
4917
  const state = this.client.store.getState();
4946
- const issueToBeUpdated = selectIssueById(issue.offline_id)(state);
4918
+ const issueToBeUpdated = selectIssueById(payload.offline_id)(state);
4947
4919
  if (!issueToBeUpdated) {
4948
4920
  throw new Error(
4949
- `Attempting to update an issue with offline_id ${issue.offline_id} that doesn't exist in the store`
4921
+ `Attempting to update an issue with offline_id ${payload.offline_id} that doesn't exist in the store`
4950
4922
  );
4951
4923
  }
4952
- const updatedIssue = { ...issueToBeUpdated, ...issue };
4924
+ const updatedIssue = { ...issueToBeUpdated, ...payload };
4953
4925
  this.dispatch(updateIssue(updatedIssue));
4954
4926
  const changes = {};
4955
4927
  for (const issueUpdateChange of [
@@ -4961,11 +4933,11 @@ var __publicField = (obj, key, value) => {
4961
4933
  IssueUpdateChange.ASSIGNED_TO,
4962
4934
  IssueUpdateChange.DUE_DATE
4963
4935
  ]) {
4964
- if (issueUpdateChange in issue && issue[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
4936
+ if (issueUpdateChange in payload && payload[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
4965
4937
  switch (issueUpdateChange) {
4966
4938
  case "category": {
4967
4939
  let categoryOrNull = null;
4968
- const categoryIdOrNull = issue[issueUpdateChange];
4940
+ const categoryIdOrNull = payload[issueUpdateChange];
4969
4941
  if (categoryIdOrNull) {
4970
4942
  categoryOrNull = state.categoryReducer.instances[categoryIdOrNull] ?? null;
4971
4943
  if (!categoryOrNull)
@@ -4982,7 +4954,7 @@ var __publicField = (obj, key, value) => {
4982
4954
  }
4983
4955
  case "assigned_to": {
4984
4956
  let userOrNull = null;
4985
- const userIdOrNull = issue[issueUpdateChange];
4957
+ const userIdOrNull = payload[issueUpdateChange];
4986
4958
  if (userIdOrNull) {
4987
4959
  userOrNull = state.userReducer.users[userIdOrNull] ?? null;
4988
4960
  if (!userOrNull)
@@ -4997,24 +4969,24 @@ var __publicField = (obj, key, value) => {
4997
4969
  break;
4998
4970
  }
4999
4971
  case "description":
5000
- changes[issueUpdateChange] = issue[issueUpdateChange] ?? null;
4972
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
5001
4973
  break;
5002
4974
  case "title":
5003
- changes[issueUpdateChange] = issue[issueUpdateChange] ?? null;
4975
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
5004
4976
  break;
5005
4977
  case "priority":
5006
- changes[issueUpdateChange] = issue[issueUpdateChange];
4978
+ changes[issueUpdateChange] = payload[issueUpdateChange];
5007
4979
  break;
5008
4980
  case "status":
5009
- changes[issueUpdateChange] = issue[issueUpdateChange];
4981
+ changes[issueUpdateChange] = payload[issueUpdateChange];
5010
4982
  break;
5011
4983
  case "due_date":
5012
- changes[issueUpdateChange] = issue[issueUpdateChange] ? issue[issueUpdateChange] : null;
4984
+ changes[issueUpdateChange] = payload[issueUpdateChange] ? payload[issueUpdateChange] : null;
5013
4985
  }
5014
4986
  }
5015
4987
  }
5016
4988
  const offlineIssueUpdate = offline({
5017
- created_by: state.userReducer.currentUser.id,
4989
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5018
4990
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5019
4991
  issue: issueToBeUpdated.offline_id,
5020
4992
  changes
@@ -5023,10 +4995,10 @@ var __publicField = (obj, key, value) => {
5023
4995
  const promise = this.enqueueRequest({
5024
4996
  description: "Edit issue",
5025
4997
  method: HttpMethod.PATCH,
5026
- url: `/issues/${issue.offline_id}/`,
5027
- payload: issue,
5028
- blockers: [issue.offline_id],
5029
- blocks: [issue.offline_id]
4998
+ url: `/issues/${payload.offline_id}/`,
4999
+ payload,
5000
+ blockers: [payload.offline_id],
5001
+ blocks: [payload.offline_id]
5030
5002
  });
5031
5003
  promise.catch(() => {
5032
5004
  this.dispatch(updateIssue(issueToBeUpdated));
@@ -5078,7 +5050,6 @@ var __publicField = (obj, key, value) => {
5078
5050
  throw e;
5079
5051
  }
5080
5052
  }
5081
- // Special functions
5082
5053
  async refreshStore(projectId) {
5083
5054
  const result = await this.enqueueRequest({
5084
5055
  description: "Get issues",
@@ -5086,33 +5057,24 @@ var __publicField = (obj, key, value) => {
5086
5057
  url: `/projects/${projectId}/issues/`,
5087
5058
  blockers: [],
5088
5059
  blocks: []
5089
- }).then((result2) => {
5090
- const filteredResult = result2.filter(onlyUniqueOfflineIds);
5091
- if (result2.length !== filteredResult.length) {
5092
- console.error(
5093
- `Received duplicate issues from the API (new length ${filteredResult.length});
5094
- filtered in browser.`
5095
- );
5096
- }
5097
- return filteredResult;
5098
5060
  });
5099
5061
  this.dispatch(initializeIssues(result));
5100
5062
  }
5101
5063
  }
5102
5064
  class IssueTypeService extends BaseApiService {
5103
- add(payload, organizationId) {
5065
+ add(payload) {
5066
+ var _a2;
5104
5067
  const { store } = this.client;
5105
5068
  const state = store.getState();
5106
5069
  const offlineIssueType = offline({
5107
5070
  ...payload,
5108
5071
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5109
- created_by: state.userReducer.currentUser.id,
5110
- organization: organizationId
5072
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id
5111
5073
  });
5112
5074
  this.dispatch(addIssueType(offlineIssueType));
5113
5075
  const promise = this.enqueueRequest({
5114
5076
  method: HttpMethod.POST,
5115
- url: `/organizations/${organizationId}/issue-types/`,
5077
+ url: `/organizations/${payload.organization}/issue-types/`,
5116
5078
  // Sending only whats needed here
5117
5079
  payload: {
5118
5080
  offline_id: offlineIssueType.offline_id,
@@ -5158,20 +5120,20 @@ var __publicField = (obj, key, value) => {
5158
5120
  });
5159
5121
  return [offlineUpdatedIssueType, promise];
5160
5122
  }
5161
- delete(issueTypeId) {
5123
+ delete(id) {
5162
5124
  const { store } = this.client;
5163
5125
  const state = store.getState();
5164
- const issueTypeToDelete = selectIssueTypeById(issueTypeId)(state);
5126
+ const issueTypeToDelete = selectIssueTypeById(id)(state);
5165
5127
  if (!issueTypeToDelete) {
5166
- throw new Error(`IssueType with offline_id ${issueTypeId} does not exist in the store.`);
5128
+ throw new Error(`IssueType with offline_id ${id} does not exist in the store.`);
5167
5129
  }
5168
- const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(state);
5169
- this.dispatch(removeIssueType(issueTypeId));
5130
+ const issuesOfIssueType = selectIssuesOfIssueType(id)(state);
5131
+ this.dispatch(removeIssueType(id));
5170
5132
  this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
5171
5133
  const promise = this.enqueueRequest({
5172
5134
  method: HttpMethod.DELETE,
5173
- url: `/issues/types/${issueTypeId}/`,
5174
- blockers: [issueTypeId],
5135
+ url: `/issues/types/${id}/`,
5136
+ blockers: [id],
5175
5137
  blocks: []
5176
5138
  });
5177
5139
  promise.catch(() => {
@@ -5229,17 +5191,6 @@ var __publicField = (obj, key, value) => {
5229
5191
  }
5230
5192
  }
5231
5193
  class ProjectFileService extends BaseApiService {
5232
- async refreshStore(projectId) {
5233
- const result = await this.enqueueRequest({
5234
- description: "Get project files",
5235
- method: HttpMethod.GET,
5236
- url: `/projects/${projectId}/files/`,
5237
- blockers: [],
5238
- blocks: []
5239
- });
5240
- this.dispatch(addOrReplaceProjectFiles([]));
5241
- this.dispatch(addOrReplaceProjectFiles(result));
5242
- }
5243
5194
  async saveExisting(file) {
5244
5195
  if (!file.offline_id) {
5245
5196
  throw new Error(
@@ -5327,6 +5278,17 @@ var __publicField = (obj, key, value) => {
5327
5278
  blocks: []
5328
5279
  });
5329
5280
  }
5281
+ async refreshStore(projectId) {
5282
+ const result = await this.enqueueRequest({
5283
+ description: "Get project files",
5284
+ method: HttpMethod.GET,
5285
+ url: `/projects/${projectId}/files/`,
5286
+ blockers: [],
5287
+ blocks: []
5288
+ });
5289
+ this.dispatch(addOrReplaceProjectFiles([]));
5290
+ this.dispatch(addOrReplaceProjectFiles(result));
5291
+ }
5330
5292
  }
5331
5293
  class ProjectAttachmentService extends BaseAttachmentService {
5332
5294
  constructor() {
@@ -5512,8 +5474,9 @@ var __publicField = (obj, key, value) => {
5512
5474
  };
5513
5475
  class FormService extends BaseUploadService {
5514
5476
  async bulkAddRevisionAttachments(revisionId, files) {
5477
+ var _a2;
5515
5478
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5516
- const createdBy = this.client.store.getState().userReducer.currentUser.id;
5479
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5517
5480
  const filePayloads = {};
5518
5481
  const offlineFormRevisionAttachments = [];
5519
5482
  const attachmentPayloads = [];
@@ -5615,10 +5578,11 @@ var __publicField = (obj, key, value) => {
5615
5578
  return [form, offlineFormRevision, offlineFormRevisionAttachments, formPromise, attachmentsPromise];
5616
5579
  }
5617
5580
  addForOrganization(organizationId, initialRevision) {
5581
+ var _a2;
5618
5582
  const state = this.client.store.getState();
5619
5583
  const offlineForm = offline({
5620
5584
  favorite: false,
5621
- created_by: state.userReducer.currentUser.id,
5585
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5622
5586
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5623
5587
  organization: organizationId
5624
5588
  });
@@ -5630,45 +5594,49 @@ var __publicField = (obj, key, value) => {
5630
5594
  );
5631
5595
  }
5632
5596
  addForProject(projectId, initialRevision) {
5597
+ var _a2;
5633
5598
  const state = this.client.store.getState();
5634
5599
  const offlineForm = offline({
5635
5600
  favorite: false,
5636
- created_by: state.userReducer.currentUser.id,
5601
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5637
5602
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5638
5603
  project: projectId
5639
5604
  });
5640
5605
  return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
5641
5606
  }
5642
5607
  addForIssueType(issueTypeId, initialRevision) {
5608
+ var _a2;
5643
5609
  const state = this.client.store.getState();
5644
5610
  const offlineForm = offline({
5645
5611
  favorite: false,
5646
- created_by: state.userReducer.currentUser.id,
5612
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5647
5613
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5648
5614
  issue_type: issueTypeId
5649
5615
  });
5650
5616
  return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
5651
5617
  }
5652
5618
  addForAssetType(assetTypeId, initialRevision) {
5619
+ var _a2;
5653
5620
  const state = this.client.store.getState();
5654
5621
  const offlineForm = offline({
5655
5622
  favorite: false,
5656
- created_by: state.userReducer.currentUser.id,
5623
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5657
5624
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5658
5625
  asset_type: assetTypeId
5659
5626
  });
5660
5627
  return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
5661
5628
  }
5662
5629
  async createRevision(formId, revision) {
5630
+ var _a2;
5663
5631
  const offlineRevision = offline(revision);
5664
5632
  const { store } = this.client;
5665
5633
  const state = store.getState();
5666
- const currentUserId = state.userReducer.currentUser.id;
5634
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
5667
5635
  const { fields, images } = await separateImageFromFields(offlineRevision.fields);
5668
5636
  const fullRevision = {
5669
5637
  ...offlineRevision,
5670
5638
  fields,
5671
- created_by: currentUserId,
5639
+ created_by: createdBy,
5672
5640
  revision: "Pending",
5673
5641
  form: formId,
5674
5642
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -5701,48 +5669,6 @@ var __publicField = (obj, key, value) => {
5701
5669
  });
5702
5670
  return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
5703
5671
  }
5704
- async favorite(formId, projectId) {
5705
- const { store } = this.client;
5706
- const state = store.getState();
5707
- const form = state.formReducer.instances[formId];
5708
- if (!form) {
5709
- throw new Error(`Expected form to exist, got ${form}`);
5710
- }
5711
- this.dispatch(updateForm({ ...form, favorite: true }));
5712
- try {
5713
- await this.enqueueRequest({
5714
- description: "Favorite form",
5715
- method: HttpMethod.POST,
5716
- url: `/forms/${formId}/favorite/${projectId}/`,
5717
- blockers: [formId, `favorite-${formId}`],
5718
- blocks: [`favorite-${formId}`]
5719
- });
5720
- } catch (e) {
5721
- this.dispatch(updateForm(form));
5722
- throw e;
5723
- }
5724
- }
5725
- async unfavorite(formId, projectId) {
5726
- const { store } = this.client;
5727
- const state = store.getState();
5728
- const form = state.formReducer.instances[formId];
5729
- if (!form) {
5730
- throw new Error(`Expected form to exist, got ${form}`);
5731
- }
5732
- this.dispatch(updateForm({ ...form, favorite: false }));
5733
- try {
5734
- return await this.enqueueRequest({
5735
- description: "Unfavorite form",
5736
- method: HttpMethod.DELETE,
5737
- url: `/forms/${formId}/unfavorite/${projectId}/`,
5738
- blockers: [formId, `favorite-${formId}`],
5739
- blocks: [`favorite-${formId}`]
5740
- });
5741
- } catch (e) {
5742
- this.dispatch(updateForm(form));
5743
- throw e;
5744
- }
5745
- }
5746
5672
  async delete(formId) {
5747
5673
  const { store } = this.client;
5748
5674
  const state = store.getState();
@@ -5859,8 +5785,9 @@ var __publicField = (obj, key, value) => {
5859
5785
  };
5860
5786
  class FormSubmissionService extends BaseUploadService {
5861
5787
  async bulkAddSubmissionAttachments(submissionId, files) {
5788
+ var _a2;
5862
5789
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5863
- const createdBy = this.client.store.getState().userReducer.currentUser.id;
5790
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5864
5791
  const filePayloads = {};
5865
5792
  const offlineFormSubmissionAttachments = [];
5866
5793
  const attachmentPayloads = [];
@@ -5942,13 +5869,14 @@ var __publicField = (obj, key, value) => {
5942
5869
  }
5943
5870
  // Outer promise is for hashing and caching files for submission attachments
5944
5871
  async add(payload) {
5872
+ var _a2;
5945
5873
  const { store } = this.client;
5946
5874
  const state = store.getState();
5947
5875
  const { values, files } = separateFilesFromValues(payload.values);
5948
5876
  const offlineSubmission = offline({
5949
5877
  ...payload,
5950
5878
  values,
5951
- created_by: state.userReducer.currentUser.id,
5879
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5952
5880
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
5953
5881
  });
5954
5882
  const promise = this.enqueueRequest({
@@ -6203,13 +6131,20 @@ var __publicField = (obj, key, value) => {
6203
6131
  }
6204
6132
  }
6205
6133
  class WorkspaceService extends BaseApiService {
6206
- add(workspace) {
6207
- const offlineWorkspace = offline(workspace);
6134
+ add(payload) {
6135
+ var _a2;
6136
+ const { store } = this.client;
6137
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6138
+ const offlineWorkspace = offline({
6139
+ ...payload,
6140
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6141
+ created_by: createdBy
6142
+ });
6208
6143
  this.dispatch(addWorkspace(offlineWorkspace));
6209
6144
  const promise = this.enqueueRequest({
6210
6145
  description: "Create Workspace",
6211
6146
  method: HttpMethod.POST,
6212
- url: `/projects/${workspace.project}/workspaces/`,
6147
+ url: `/projects/${payload.project}/workspaces/`,
6213
6148
  payload: offlineWorkspace,
6214
6149
  blockers: ["add-workspace"],
6215
6150
  blocks: [offlineWorkspace.offline_id]
@@ -6221,8 +6156,14 @@ var __publicField = (obj, key, value) => {
6221
6156
  });
6222
6157
  return [offlineWorkspace, promise];
6223
6158
  }
6224
- update(workspace) {
6225
- this.dispatch(addWorkspace(workspace));
6159
+ update(payload) {
6160
+ const { store } = this.client;
6161
+ const workspace = selectWorkspaceById(payload.offline_id)(store.getState());
6162
+ if (!workspace) {
6163
+ throw new Error(`Expected an existing workspace with offline_id ${payload.offline_id}`);
6164
+ }
6165
+ const updatedWorkspace = { ...workspace, ...payload };
6166
+ this.dispatch(updateWorkspace(updatedWorkspace));
6226
6167
  const promise = this.enqueueRequest({
6227
6168
  description: "Update Workspace",
6228
6169
  method: HttpMethod.PATCH,
@@ -6231,10 +6172,17 @@ var __publicField = (obj, key, value) => {
6231
6172
  blockers: [workspace.offline_id],
6232
6173
  blocks: [workspace.offline_id]
6233
6174
  });
6175
+ promise.then((result) => {
6176
+ this.dispatch(updateWorkspace(result));
6177
+ }).catch(() => {
6178
+ this.dispatch(updateWorkspace(workspace));
6179
+ });
6234
6180
  return [workspace, promise];
6235
6181
  }
6236
6182
  delete(workspaceId) {
6237
6183
  const { store } = this.client;
6184
+ const originalWorkspace = selectWorkspaceById(workspaceId)(store.getState());
6185
+ this.dispatch(deleteWorkspace(workspaceId));
6238
6186
  const promise = this.enqueueRequest({
6239
6187
  description: "Delete Workspace",
6240
6188
  method: HttpMethod.DELETE,
@@ -6242,8 +6190,6 @@ var __publicField = (obj, key, value) => {
6242
6190
  blockers: [workspaceId],
6243
6191
  blocks: []
6244
6192
  });
6245
- const originalWorkspace = store.getState().workspaceReducer.instances[workspaceId];
6246
- this.dispatch(deleteWorkspace(workspaceId));
6247
6193
  void promise.then(() => {
6248
6194
  }).catch((reason) => {
6249
6195
  if (originalWorkspace) {
@@ -6745,12 +6691,13 @@ var __publicField = (obj, key, value) => {
6745
6691
  }
6746
6692
  class DocumentService extends BaseApiService {
6747
6693
  add(payload) {
6694
+ var _a2;
6748
6695
  const { store } = this.client;
6749
- const currentUserId = store.getState().userReducer.currentUser.id;
6696
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6750
6697
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6751
6698
  const offlineDocument = offline({
6752
6699
  ...payload,
6753
- created_by: currentUserId,
6700
+ created_by: createdBy,
6754
6701
  submitted_at: submittedAt
6755
6702
  });
6756
6703
  this.dispatch(addDocuments([offlineDocument]));
@@ -6779,7 +6726,11 @@ var __publicField = (obj, key, value) => {
6779
6726
  `attempting to update a document with offline_id ${document2.offline_id} that does not exist in store.documents`
6780
6727
  );
6781
6728
  }
6782
- this.dispatch(updateDocuments([document2]));
6729
+ const updatedDocument = {
6730
+ ...documentToBeUpdated,
6731
+ ...document2
6732
+ };
6733
+ this.dispatch(updateDocuments([updatedDocument]));
6783
6734
  const promise = this.enqueueRequest({
6784
6735
  description: "Update Document",
6785
6736
  method: HttpMethod.PATCH,
@@ -6791,8 +6742,7 @@ var __publicField = (obj, key, value) => {
6791
6742
  promise.catch(() => {
6792
6743
  updateDocuments([documentToBeUpdated]);
6793
6744
  });
6794
- const fullDocument = store.getState().documentsReducer.documents[document2.offline_id];
6795
- return [fullDocument, promise];
6745
+ return [updatedDocument, promise];
6796
6746
  }
6797
6747
  move(documentId, targetDocumentId, position) {
6798
6748
  const { store } = this.client;
@@ -6839,22 +6789,22 @@ var __publicField = (obj, key, value) => {
6839
6789
  });
6840
6790
  return promise;
6841
6791
  }
6842
- delete(documentId) {
6792
+ delete(id) {
6843
6793
  const { store } = this.client;
6844
6794
  const documentsMapping = selectDocumentsMapping(store.getState());
6845
- const documentToBeDeleted = documentsMapping[documentId];
6795
+ const documentToBeDeleted = selectDocumentById(id)(store.getState());
6846
6796
  if (!documentToBeDeleted) {
6847
6797
  throw new Error(
6848
- `attempting to delete a document with offline_id ${documentId} that does not exist in store.documents`
6798
+ `attempting to delete a document with offline_id ${id} that does not exist in store.documents`
6849
6799
  );
6850
6800
  }
6851
6801
  const parentDocument = documentToBeDeleted.parent_document ? documentsMapping[documentToBeDeleted.parent_document] : void 0;
6852
- this.dispatch(removeDocuments([documentId]));
6802
+ this.dispatch(removeDocuments([id]));
6853
6803
  const promise = this.enqueueRequest({
6854
6804
  description: "Delete Document",
6855
6805
  method: HttpMethod.DELETE,
6856
- url: `/documents/${documentId}/`,
6857
- blockers: [documentId],
6806
+ url: `/documents/${id}/`,
6807
+ blockers: [id],
6858
6808
  blocks: []
6859
6809
  });
6860
6810
  promise.then((documentsToUpdate) => {
@@ -6912,8 +6862,9 @@ var __publicField = (obj, key, value) => {
6912
6862
  }
6913
6863
  // NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
6914
6864
  async attachFilesToDocument(files, documentId) {
6865
+ var _a2;
6915
6866
  const { store } = this.client;
6916
- const currentUser = store.getState().userReducer.currentUser;
6867
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6917
6868
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6918
6869
  const offlineAttachments = [];
6919
6870
  const attachmentPayloads = [];
@@ -6935,7 +6886,7 @@ var __publicField = (obj, key, value) => {
6935
6886
  file,
6936
6887
  sha1,
6937
6888
  submittedAt,
6938
- createdBy: currentUser.id,
6889
+ createdBy,
6939
6890
  description: "",
6940
6891
  modelId: documentId
6941
6892
  });
@@ -7098,10 +7049,9 @@ var __publicField = (obj, key, value) => {
7098
7049
  }
7099
7050
  }
7100
7051
  class TeamService extends BaseApiService {
7101
- add(teamPayload, organizationId) {
7052
+ add(payload) {
7102
7053
  const offlineTeam = offline({
7103
- ...teamPayload,
7104
- organization: organizationId,
7054
+ ...payload,
7105
7055
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7106
7056
  // TODO: uncomment once supported
7107
7057
  // created_by: state.userReducer.currentUser.id,
@@ -7110,7 +7060,7 @@ var __publicField = (obj, key, value) => {
7110
7060
  const promise = this.enqueueRequest({
7111
7061
  description: "Create team",
7112
7062
  method: HttpMethod.POST,
7113
- url: `/organizations/${organizationId}/teams/`,
7063
+ url: `/organizations/${payload.organization}/teams/`,
7114
7064
  payload: offlineTeam,
7115
7065
  // No blocks since users and organizations are not offline
7116
7066
  blockers: [],
@@ -7123,25 +7073,24 @@ var __publicField = (obj, key, value) => {
7123
7073
  });
7124
7074
  return [offlineTeam, promise];
7125
7075
  }
7126
- // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
7127
- update(team) {
7076
+ update(payload) {
7128
7077
  const { store } = this.client;
7129
- const teamToBeUpdated = selectTeamById(team.offline_id)(store.getState());
7078
+ const teamToBeUpdated = selectTeamById(payload.offline_id)(store.getState());
7130
7079
  if (!teamToBeUpdated) {
7131
- throw new Error(`Expected team with offline_id ${team.offline_id} to exist`);
7080
+ throw new Error(`Expected team with offline_id ${payload.offline_id} to exist`);
7132
7081
  }
7133
7082
  const offlineUpdatedTeam = {
7134
7083
  ...teamToBeUpdated,
7135
- ...team
7084
+ ...payload
7136
7085
  };
7137
7086
  this.dispatch(updateTeam(offlineUpdatedTeam));
7138
7087
  const promise = this.enqueueRequest({
7139
7088
  description: "Update team",
7140
7089
  method: HttpMethod.PATCH,
7141
- url: `/organizations/teams/${team.offline_id}/`,
7090
+ url: `/organizations/teams/${payload.offline_id}/`,
7142
7091
  payload: offlineUpdatedTeam,
7143
- blockers: [team.offline_id],
7144
- blocks: [team.offline_id]
7092
+ blockers: [payload.offline_id],
7093
+ blocks: [payload.offline_id]
7145
7094
  });
7146
7095
  promise.then((updatedTeam) => {
7147
7096
  this.dispatch(setTeam(updatedTeam));
@@ -7253,10 +7202,11 @@ var __publicField = (obj, key, value) => {
7253
7202
  }
7254
7203
  class GeoImageService extends BaseUploadService {
7255
7204
  async add(payload) {
7205
+ var _a2;
7256
7206
  const { store } = this.client;
7257
7207
  const { file, ...payloadWithoutFile } = payload;
7258
7208
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7259
- const currentUser = store.getState().userReducer.currentUser;
7209
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7260
7210
  const projectId = payloadWithoutFile.project;
7261
7211
  const sha1 = await hashFile(file);
7262
7212
  const filePayload = {
@@ -7271,9 +7221,9 @@ var __publicField = (obj, key, value) => {
7271
7221
  file_sha1: sha1,
7272
7222
  file: URL.createObjectURL(file),
7273
7223
  submitted_at: submittedAt,
7274
- created_by: currentUser.id
7224
+ created_by: createdBy
7275
7225
  });
7276
- store.dispatch(addGeoImage(offlineMapImage));
7226
+ this.dispatch(addGeoImage(offlineMapImage));
7277
7227
  const promise = this.enqueueRequest({
7278
7228
  description: "Add geo image",
7279
7229
  method: HttpMethod.POST,
@@ -7297,16 +7247,17 @@ var __publicField = (obj, key, value) => {
7297
7247
  });
7298
7248
  promise.then((result) => {
7299
7249
  this.processPresignedUrls(result.presigned_urls);
7300
- store.dispatch(setGeoImage(result.geo_image));
7250
+ this.dispatch(setGeoImage(result.geo_image));
7301
7251
  }).catch(() => {
7302
- store.dispatch(deleteGeoImage(offlineMapImage.offline_id));
7252
+ this.dispatch(deleteGeoImage(offlineMapImage.offline_id));
7303
7253
  });
7304
7254
  return [offlineMapImage, promise.then((result) => result.geo_image)];
7305
7255
  }
7306
7256
  async bulkAdd(payloads, projectId) {
7257
+ var _a2;
7307
7258
  const { store } = this.client;
7308
7259
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7309
- const currentUser = store.getState().userReducer.currentUser;
7260
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7310
7261
  const offlineGeoImages = [];
7311
7262
  const offlineIds = [];
7312
7263
  const geoImagePayloads = [];
@@ -7329,7 +7280,7 @@ var __publicField = (obj, key, value) => {
7329
7280
  file_sha1: sha1,
7330
7281
  file: URL.createObjectURL(file),
7331
7282
  submitted_at: submittedAt,
7332
- created_by: currentUser.id,
7283
+ created_by: createdBy,
7333
7284
  project: projectId
7334
7285
  });
7335
7286
  offlineGeoImages.push(offlineMapImage);
@@ -7346,7 +7297,7 @@ var __publicField = (obj, key, value) => {
7346
7297
  original_date: offlineMapImage.original_date
7347
7298
  });
7348
7299
  }
7349
- store.dispatch(addGeoImages(offlineGeoImages));
7300
+ this.dispatch(addGeoImages(offlineGeoImages));
7350
7301
  const promise = this.enqueueRequest({
7351
7302
  description: "Bulk add geo images",
7352
7303
  method: HttpMethod.POST,
@@ -7362,9 +7313,9 @@ var __publicField = (obj, key, value) => {
7362
7313
  });
7363
7314
  promise.then((result) => {
7364
7315
  this.processPresignedUrls(result.presigned_urls);
7365
- store.dispatch(setGeoImages(result.geo_images));
7316
+ this.dispatch(setGeoImages(result.geo_images));
7366
7317
  }).catch(() => {
7367
- store.dispatch(deleteGeoImages(offlineIds));
7318
+ this.dispatch(deleteGeoImages(offlineIds));
7368
7319
  });
7369
7320
  return [offlineGeoImages, promise.then((result) => result.geo_images)];
7370
7321
  }
@@ -7376,7 +7327,7 @@ var __publicField = (obj, key, value) => {
7376
7327
  throw new Error(`Map image with offline_id ${payload.offline_id} does not exist in the store`);
7377
7328
  }
7378
7329
  const updatedGeoImage = { ...geoImageToUpdate, ...payload };
7379
- store.dispatch(updateGeoImage(updatedGeoImage));
7330
+ this.dispatch(updateGeoImage(updatedGeoImage));
7380
7331
  const promise = this.enqueueRequest({
7381
7332
  description: "Update geo image",
7382
7333
  method: HttpMethod.PATCH,
@@ -7386,9 +7337,9 @@ var __publicField = (obj, key, value) => {
7386
7337
  blockers: [payload.offline_id]
7387
7338
  });
7388
7339
  promise.then((result) => {
7389
- store.dispatch(setGeoImage(result));
7340
+ this.dispatch(setGeoImage(result));
7390
7341
  }).catch(() => {
7391
- store.dispatch(setGeoImage(geoImageToUpdate));
7342
+ this.dispatch(setGeoImage(geoImageToUpdate));
7392
7343
  });
7393
7344
  return [updatedGeoImage, promise];
7394
7345
  }
@@ -7399,7 +7350,7 @@ var __publicField = (obj, key, value) => {
7399
7350
  if (!geoImageToDelete) {
7400
7351
  throw new Error(`Map image with offline_id ${geoImageId} does not exist in the store`);
7401
7352
  }
7402
- store.dispatch(deleteGeoImage(geoImageId));
7353
+ this.dispatch(deleteGeoImage(geoImageId));
7403
7354
  const promise = this.enqueueRequest({
7404
7355
  description: "Delete geo image",
7405
7356
  method: HttpMethod.DELETE,
@@ -7408,12 +7359,11 @@ var __publicField = (obj, key, value) => {
7408
7359
  blockers: [geoImageId]
7409
7360
  });
7410
7361
  promise.catch(() => {
7411
- store.dispatch(setGeoImage(geoImageToDelete));
7362
+ this.dispatch(setGeoImage(geoImageToDelete));
7412
7363
  });
7413
7364
  return promise;
7414
7365
  }
7415
7366
  async refreshStore(projectId) {
7416
- const { store } = this.client;
7417
7367
  const result = await this.enqueueRequest({
7418
7368
  description: "Get geo images",
7419
7369
  method: HttpMethod.GET,
@@ -7421,14 +7371,15 @@ var __publicField = (obj, key, value) => {
7421
7371
  blocks: [projectId.toString()],
7422
7372
  blockers: []
7423
7373
  });
7424
- store.dispatch(initializeGeoImages(result));
7374
+ this.dispatch(initializeGeoImages(result));
7425
7375
  }
7426
7376
  }
7427
7377
  class IssueAssociationService extends BaseUploadService {
7428
7378
  add(payload) {
7379
+ var _a2;
7429
7380
  const { store } = this.client;
7430
7381
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7431
- const createdBy = store.getState().userReducer.currentUser.id;
7382
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7432
7383
  const offlineIssueAssociation = offline({
7433
7384
  ...payload,
7434
7385
  submitted_at: submittedAt,
@@ -7442,7 +7393,6 @@ var __publicField = (obj, key, value) => {
7442
7393
  payload: {
7443
7394
  offline_id: offlineIssueAssociation.offline_id,
7444
7395
  submitted_at: submittedAt,
7445
- created_by: createdBy,
7446
7396
  ...payload
7447
7397
  },
7448
7398
  blockers: [
@@ -7566,7 +7516,6 @@ var __publicField = (obj, key, value) => {
7566
7516
  exports2.addDocumentAttachments = addDocumentAttachments;
7567
7517
  exports2.addDocuments = addDocuments;
7568
7518
  exports2.addEmailDomain = addEmailDomain;
7569
- exports2.addFavouriteProjectId = addFavouriteProjectId;
7570
7519
  exports2.addForm = addForm;
7571
7520
  exports2.addFormRevision = addFormRevision;
7572
7521
  exports2.addFormRevisionAttachment = addFormRevisionAttachment;
@@ -7796,7 +7745,6 @@ var __publicField = (obj, key, value) => {
7796
7745
  exports2.rehydratedReducer = rehydratedReducer;
7797
7746
  exports2.rehydratedSlice = rehydratedSlice;
7798
7747
  exports2.removeDocuments = removeDocuments;
7799
- exports2.removeFavouriteProjectId = removeFavouriteProjectId;
7800
7748
  exports2.removeIssueType = removeIssueType;
7801
7749
  exports2.removeProjectFile = removeProjectFile;
7802
7750
  exports2.removeProjectFilesOfProject = removeProjectFilesOfProject;
@@ -7875,7 +7823,6 @@ var __publicField = (obj, key, value) => {
7875
7823
  exports2.selectEmailDomains = selectEmailDomains;
7876
7824
  exports2.selectEmailDomainsAsMapping = selectEmailDomainsAsMapping;
7877
7825
  exports2.selectEmailDomainsOfOrganization = selectEmailDomainsOfOrganization;
7878
- exports2.selectFavouriteProjects = selectFavouriteProjects;
7879
7826
  exports2.selectFilteredForms = selectFilteredForms;
7880
7827
  exports2.selectFormById = selectFormById;
7881
7828
  exports2.selectFormMapping = selectFormMapping;
@@ -7916,6 +7863,7 @@ var __publicField = (obj, key, value) => {
7916
7863
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
7917
7864
  exports2.selectIssueAttachments = selectIssueAttachments;
7918
7865
  exports2.selectIssueById = selectIssueById;
7866
+ exports2.selectIssueCommentById = selectIssueCommentById;
7919
7867
  exports2.selectIssueCommentMapping = selectIssueCommentMapping;
7920
7868
  exports2.selectIssueCountOfCategory = selectIssueCountOfCategory;
7921
7869
  exports2.selectIssueMapping = selectIssueMapping;
@@ -8032,7 +7980,6 @@ var __publicField = (obj, key, value) => {
8032
7980
  exports2.setStageCompletions = setStageCompletions;
8033
7981
  exports2.setTeam = setTeam;
8034
7982
  exports2.setTokens = setTokens;
8035
- exports2.setTourStep = setTourStep;
8036
7983
  exports2.setUploadUrl = setUploadUrl;
8037
7984
  exports2.setUsers = setUsers;
8038
7985
  exports2.setWorkspaces = setWorkspaces;