@overmap-ai/core 1.0.71-mapbox.2 → 1.0.71-mapbox.4

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.
@@ -1531,13 +1531,6 @@ const selectProjectAccesses = createSelector(
1531
1531
  const selectProjectAccessById = (id) => (state) => {
1532
1532
  return state.projectAccessReducer.instances[id];
1533
1533
  };
1534
- const selectActiveProjectAccess = (state) => {
1535
- const currentUser = state.userReducer.currentUser;
1536
- const activeProjectId = state.projectReducer.activeProjectId;
1537
- return Object.values(state.projectAccessReducer.instances).find((projectAccess) => {
1538
- return projectAccess.user === (currentUser == null ? void 0 : currentUser.id) && projectAccess.project === activeProjectId;
1539
- }) ?? null;
1540
- };
1541
1534
  const selectProjectAccessForUser = (user) => (state) => {
1542
1535
  return Object.values(state.projectAccessReducer.instances).find(
1543
1536
  (projectAccess) => projectAccess.user === user.id
@@ -1552,8 +1545,7 @@ const selectProjectAccessUserMapping = (state) => {
1552
1545
  };
1553
1546
  const projectAccessReducer = projectAccessSlice.reducer;
1554
1547
  const initialState$m = {
1555
- projects: {},
1556
- activeProjectId: null
1548
+ projects: {}
1557
1549
  };
1558
1550
  const projectSlice = createSlice({
1559
1551
  name: "projects",
@@ -1567,19 +1559,9 @@ const projectSlice = createSlice({
1567
1559
  });
1568
1560
  state.projects = projectsMap;
1569
1561
  },
1570
- setActiveProjectId: (state, action) => {
1571
- state.activeProjectId = action.payload;
1572
- },
1573
- updateOrCreateProject: (state, action) => {
1562
+ updateProject: (state, action) => {
1574
1563
  state.projects[action.payload.id] = action.payload;
1575
1564
  },
1576
- // Takes a list of Projects and updates existing ones to match the payload, or adds them
1577
- // to the store if they are not already present
1578
- updateOrCreateProjects: (state, action) => {
1579
- action.payload.forEach((project) => {
1580
- state.projects[project.id] = project;
1581
- });
1582
- },
1583
1565
  deleteProject: (state, action) => {
1584
1566
  delete state.projects[action.payload.id];
1585
1567
  },
@@ -1589,52 +1571,12 @@ const projectSlice = createSlice({
1589
1571
  } else {
1590
1572
  throw new Error("Accept project invite: user is not in this project");
1591
1573
  }
1592
- },
1593
- addActiveProjectIssuesCount: (state, action) => {
1594
- if (!state.activeProjectId || !(state.activeProjectId in state.projects)) {
1595
- throw new Error("Update issues count: no active project");
1596
- }
1597
- if (!state.projects[state.activeProjectId].issues_count) {
1598
- state.projects[state.activeProjectId].issues_count = action.payload;
1599
- } else {
1600
- state.projects[state.activeProjectId].issues_count += action.payload;
1601
- }
1602
- },
1603
- addActiveProjectFormSubmissionsCount: (state, action) => {
1604
- if (state.activeProjectId && state.activeProjectId in state.projects) {
1605
- if (!state.projects[state.activeProjectId].form_submissions_count) {
1606
- state.projects[state.activeProjectId].form_submissions_count = action.payload;
1607
- } else {
1608
- state.projects[state.activeProjectId].form_submissions_count += action.payload;
1609
- }
1610
- } else {
1611
- throw new Error("Update form submissions count: no active project");
1612
- }
1613
1574
  }
1614
1575
  }
1615
1576
  });
1616
- const {
1617
- setProjects,
1618
- updateOrCreateProject,
1619
- updateOrCreateProjects: addOrReplaceProjects,
1620
- setActiveProjectId,
1621
- deleteProject,
1622
- acceptProjectInvite,
1623
- addActiveProjectIssuesCount,
1624
- addActiveProjectFormSubmissionsCount
1625
- } = projectSlice.actions;
1577
+ const { setProjects, updateProject, deleteProject, acceptProjectInvite } = projectSlice.actions;
1626
1578
  const projectReducer = projectSlice.reducer;
1627
1579
  const selectProjectMapping = (state) => state.projectReducer.projects;
1628
- const selectActiveProjectId = (state) => state.projectReducer.activeProjectId;
1629
- const selectActiveProject = createSelector(
1630
- [selectProjectMapping, selectActiveProjectId],
1631
- (projectsMapping, activeprojectId) => {
1632
- if (activeprojectId === null) {
1633
- return null;
1634
- }
1635
- return projectsMapping[activeprojectId] ?? null;
1636
- }
1637
- );
1638
1580
  const selectProjectById = (id) => (state) => {
1639
1581
  return state.projectReducer.projects[id];
1640
1582
  };
@@ -1889,14 +1831,9 @@ const {
1889
1831
  resetProjectFileObjectUrls
1890
1832
  } = projectFileSlice.actions;
1891
1833
  const selectProjectFileMapping = (state) => state.projectFileReducer.projectFiles;
1892
- const selectProjectFiles = createSelector(
1893
- [selectProjectFileMapping, selectActiveProjectId],
1894
- (mapping, activeProjectId) => {
1895
- return fallbackToEmptyArray(
1896
- Object.values(mapping).filter((file) => file.project === activeProjectId).sort((a, b) => a.z_index - b.z_index)
1897
- );
1898
- }
1899
- );
1834
+ const selectProjectFiles = createSelector([selectProjectFileMapping], (mapping) => {
1835
+ return fallbackToEmptyArray(Object.values(mapping).sort((a, b) => a.z_index - b.z_index));
1836
+ });
1900
1837
  const selectProjectFileById = (id) => (state) => {
1901
1838
  return state.projectFileReducer.projectFiles[id];
1902
1839
  };
@@ -4768,7 +4705,6 @@ class IssueService extends BaseApiService {
4768
4705
  created_by: createdBy
4769
4706
  });
4770
4707
  this.dispatch(addIssue(offlineIssue));
4771
- this.dispatch(addActiveProjectIssuesCount(1));
4772
4708
  const promise = this.enqueueRequest({
4773
4709
  description: "Create issue",
4774
4710
  method: HttpMethod.POST,
@@ -4785,7 +4721,6 @@ class IssueService extends BaseApiService {
4785
4721
  this.dispatch(updateIssue(result));
4786
4722
  }).catch((error) => {
4787
4723
  this.dispatch(deleteIssue(offlineIssue.offline_id));
4788
- this.dispatch(addActiveProjectIssuesCount(-1));
4789
4724
  throw error;
4790
4725
  });
4791
4726
  return [offlineIssue, promise];
@@ -4901,7 +4836,6 @@ class IssueService extends BaseApiService {
4901
4836
  issueAssociationsRecord[issueAssociation.offline_id] = issueAssociation;
4902
4837
  const issueAssociations = Object.values(issueAssociationsRecord);
4903
4838
  this.dispatch(deleteIssue(id));
4904
- this.dispatch(addActiveProjectIssuesCount(-1));
4905
4839
  if (attachmentsOfIssue.length > 0)
4906
4840
  this.dispatch(deleteIssueAttachments(attachmentsOfIssue.map(({ offline_id }) => offline_id)));
4907
4841
  if (updatesOfIssue.length > 0)
@@ -4922,7 +4856,6 @@ class IssueService extends BaseApiService {
4922
4856
  this.dispatch(addIssue(backup));
4923
4857
  this.dispatch(addIssueAttachments(attachmentsOfIssue));
4924
4858
  this.dispatch(addIssueUpdates(updatesOfIssue));
4925
- this.dispatch(addActiveProjectIssuesCount(1));
4926
4859
  this.dispatch(addFormSubmissions(formSubmissionsOfIssue));
4927
4860
  this.dispatch(addIssueAssociations(issueAssociations));
4928
4861
  throw e;
@@ -5090,13 +5023,9 @@ class ProjectFileService extends BaseApiService {
5090
5023
  const { store } = this.client;
5091
5024
  const state = store.getState();
5092
5025
  const activeProjectFileId = state.projectFileReducer.activeProjectFileId;
5093
- const activeProjectId = state.projectReducer.activeProjectId;
5094
5026
  if (!activeProjectFileId) {
5095
5027
  throw new Error("No active project file");
5096
5028
  }
5097
- if (!activeProjectId) {
5098
- throw new Error("No active project");
5099
- }
5100
5029
  const activeProjectFile = state.projectFileReducer.projectFiles[activeProjectFileId];
5101
5030
  if (!activeProjectFile) {
5102
5031
  throw new Error("No active project file");
@@ -5121,7 +5050,7 @@ class ProjectFileService extends BaseApiService {
5121
5050
  this.client.files.uploadFileToS3(activeProjectFile.file_sha1).then(([fileProps]) => {
5122
5051
  resolve({
5123
5052
  method: HttpMethod.POST,
5124
- url: `/projects/${activeProjectId}/files/`,
5053
+ url: `/projects/${activeProjectFile.project}/files/`,
5125
5054
  payload: {
5126
5055
  ...activeProjectFile,
5127
5056
  ...fileProps
@@ -5217,7 +5146,7 @@ class ProjectService extends BaseApiService {
5217
5146
  if (!project.bounds && !project.canvas_bounds) {
5218
5147
  throw new Error("Project must either have bounds or canvas_bounds set");
5219
5148
  }
5220
- this.dispatch(updateOrCreateProject(project));
5149
+ this.dispatch(updateProject(project));
5221
5150
  return await this.enqueueRequest({
5222
5151
  description: "Update project",
5223
5152
  method: HttpMethod.PATCH,
@@ -5757,12 +5686,10 @@ class FormSubmissionService extends BaseUploadService {
5757
5686
  files
5758
5687
  );
5759
5688
  promise.then((result) => {
5760
- this.dispatch(addActiveProjectFormSubmissionsCount(1));
5761
5689
  this.dispatch(setFormSubmission(result));
5762
5690
  return result;
5763
5691
  }).catch(() => {
5764
5692
  this.dispatch(deleteFormSubmission(offlineSubmission.offline_id));
5765
- this.dispatch(addActiveProjectFormSubmissionsCount(-1));
5766
5693
  });
5767
5694
  return [offlineSubmission, offlineFormSubmissionAttachments, promise, attachmentsPromise];
5768
5695
  }
@@ -5929,7 +5856,6 @@ class FormSubmissionService extends BaseUploadService {
5929
5856
  }
5930
5857
  const submissionAttachments = selectAttachmentsOfFormSubmission(id)(state);
5931
5858
  this.dispatch(deleteFormSubmission(id));
5932
- this.dispatch(addActiveProjectFormSubmissionsCount(-1));
5933
5859
  this.dispatch(deleteFormSubmissionAttachments(submissionAttachments.map((x) => x.offline_id)));
5934
5860
  try {
5935
5861
  return await this.enqueueRequest({
@@ -5940,7 +5866,6 @@ class FormSubmissionService extends BaseUploadService {
5940
5866
  blocks: []
5941
5867
  });
5942
5868
  } catch (e) {
5943
- this.dispatch(addActiveProjectFormSubmissionsCount(1));
5944
5869
  this.dispatch(addFormSubmission(submissionToBeDeleted));
5945
5870
  this.dispatch(addFormSubmissionAttachments(submissionAttachments));
5946
5871
  throw e;
@@ -6817,15 +6742,14 @@ class DocumentAttachmentService extends BaseAttachmentService {
6817
6742
  }
6818
6743
  }
6819
6744
  class AgentService extends BaseApiService {
6820
- async startConversation(prompt) {
6821
- const activeProjectId = this.client.store.getState().projectReducer.activeProjectId;
6745
+ async startConversation(prompt, projectId) {
6822
6746
  return this.enqueueRequest({
6823
6747
  description: "Start agent conversation",
6824
6748
  method: HttpMethod.POST,
6825
6749
  url: "/agents/prompt/",
6826
6750
  payload: {
6827
6751
  prompt,
6828
- active_project: activeProjectId
6752
+ active_project: projectId
6829
6753
  },
6830
6754
  blockers: ["prompt"],
6831
6755
  blocks: ["prompt"]
@@ -6834,21 +6758,14 @@ class AgentService extends BaseApiService {
6834
6758
  return response;
6835
6759
  });
6836
6760
  }
6837
- /**
6838
- * Prompt the agent with a message.
6839
- * @param prompt The message to prompt the agent with.
6840
- * @param conversationId If continuing an existing message, the UUID of that conversation.
6841
- */
6842
- async continueConversation(prompt, conversationId) {
6843
- const { store } = this.client;
6844
- const activeProjectId = store.getState().projectReducer.activeProjectId;
6761
+ async continueConversation(prompt, conversationId, projectId) {
6845
6762
  return this.enqueueRequest({
6846
6763
  description: "Prompt agent",
6847
6764
  method: HttpMethod.POST,
6848
6765
  url: "/agents/prompt/",
6849
6766
  payload: {
6850
6767
  prompt,
6851
- active_project: activeProjectId
6768
+ active_project: projectId
6852
6769
  },
6853
6770
  blockers: ["prompt"],
6854
6771
  blocks: ["prompt"],
@@ -7352,8 +7269,6 @@ export {
7352
7269
  _selectLatestFormRevision,
7353
7270
  _setLatestRetryTime,
7354
7271
  acceptProjectInvite,
7355
- addActiveProjectFormSubmissionsCount,
7356
- addActiveProjectIssuesCount,
7357
7272
  addAsset,
7358
7273
  addAssetAttachment,
7359
7274
  addAssetAttachments,
@@ -7398,7 +7313,6 @@ export {
7398
7313
  addLicenses,
7399
7314
  addOrReplaceProjectFile,
7400
7315
  addOrReplaceProjectFiles,
7401
- addOrReplaceProjects,
7402
7316
  addProjectAttachment,
7403
7317
  addProjectAttachments,
7404
7318
  addTeam,
@@ -7598,10 +7512,7 @@ export {
7598
7512
  saveActiveProjectFileBounds,
7599
7513
  selectAccessToken,
7600
7514
  selectActiveOrganizationAccess,
7601
- selectActiveProject,
7602
- selectActiveProjectAccess,
7603
7515
  selectActiveProjectFileId,
7604
- selectActiveProjectId,
7605
7516
  selectActiveStatusLicenses,
7606
7517
  selectAllDocumentAttachments,
7607
7518
  selectAllProjectAttachments,
@@ -7774,7 +7685,6 @@ export {
7774
7685
  selectWorkspaceMapping,
7775
7686
  selectWorkspaces,
7776
7687
  setActiveProjectFileId,
7777
- setActiveProjectId,
7778
7688
  setAsset,
7779
7689
  setAssetAttachment,
7780
7690
  setAssetAttachments,
@@ -7863,8 +7773,8 @@ export {
7863
7773
  updateIssueAttachments,
7864
7774
  updateIssueType,
7865
7775
  updateLicense,
7866
- updateOrCreateProject,
7867
7776
  updateOrganizationAccess,
7777
+ updateProject,
7868
7778
  updateProjectAccess,
7869
7779
  updateProjectAttachment,
7870
7780
  updateProjectAttachments,