@overmap-ai/core 1.0.51-fix-document-urls.2 → 1.0.51-qr-field.0

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.
@@ -4059,18 +4059,9 @@ var __publicField = (obj, key, value) => {
4059
4059
  }
4060
4060
  }
4061
4061
  for (const document2 of action.payload) {
4062
- const existingDocument = state.documents[document2.offline_id];
4063
- if (document2.organization !== void 0 && document2.organization !== existingDocument.organization) {
4064
- throw new Error("organization cannot be updated");
4065
- }
4066
- if (document2.project !== void 0 && document2.project !== existingDocument.project) {
4067
- throw new Error("project cannot be updated");
4068
- }
4069
4062
  state.documents[document2.offline_id] = {
4070
- ...existingDocument,
4063
+ ...state.documents[document2.offline_id],
4071
4064
  ...document2
4072
- // Without the cast, TypeScript doesn't realize that we have guaranteed that the document doesn't
4073
- // have both a project and an organization.
4074
4065
  };
4075
4066
  }
4076
4067
  },
@@ -7997,28 +7988,17 @@ var __publicField = (obj, key, value) => {
7997
7988
  }
7998
7989
  }
7999
7990
  class DocumentService extends BaseApiService {
8000
- // TODO: Support adding for project or organization
8001
7991
  add(document2) {
8002
7992
  const { store } = this.client;
8003
7993
  const currentUserId = store.getState().userReducer.currentUser.id;
8004
7994
  const activeProjectId = store.getState().projectReducer.activeProjectId;
8005
- if (!activeProjectId) {
8006
- throw new Error("No active project ID while creating document.");
8007
- }
8008
- const offlineDocument = offline(document2);
8009
- const submittedDocument = {
8010
- ...offlineDocument,
8011
- created_by: currentUserId,
8012
- project: activeProjectId,
8013
- organization: null,
8014
- children_documents: []
8015
- };
8016
- store.dispatch(addDocuments([submittedDocument]));
7995
+ const offlineDocument = offline({ ...document2, created_by: currentUserId });
7996
+ store.dispatch(addDocuments([offlineDocument]));
8017
7997
  const promise = this.enqueueRequest({
8018
7998
  description: "Create Document",
8019
7999
  method: HttpMethod.POST,
8020
- url: `/projects/${activeProjectId}/documents/`,
8021
- payload: offlineDocument,
8000
+ url: `/projects/${activeProjectId}/create-document/`,
8001
+ payload: { ...offlineDocument },
8022
8002
  queryParams: {
8023
8003
  parent_document: offlineDocument.parent_document ?? void 0
8024
8004
  },
@@ -8029,7 +8009,7 @@ var __publicField = (obj, key, value) => {
8029
8009
  promise.catch(() => {
8030
8010
  store.dispatch(removeDocuments([offlineDocument.offline_id]));
8031
8011
  });
8032
- return [submittedDocument, promise];
8012
+ return [offlineDocument, promise];
8033
8013
  }
8034
8014
  update(document2) {
8035
8015
  const { store } = this.client;
@@ -8129,25 +8109,15 @@ var __publicField = (obj, key, value) => {
8129
8109
  }
8130
8110
  async refreshStore() {
8131
8111
  const { store } = this.client;
8132
- const state = store.getState();
8133
- const activeProjectId = state.projectReducer.activeProjectId;
8134
- const projectDocumentsPromise = this.enqueueRequest({
8112
+ const activeProjectId = store.getState().projectReducer.activeProjectId;
8113
+ const result = await this.enqueueRequest({
8135
8114
  description: "Get project documents",
8136
8115
  method: HttpMethod.GET,
8137
- url: `/projects/${activeProjectId}/documents/`,
8138
- blockers: [],
8139
- blocks: []
8140
- });
8141
- const activeOrganizationId = state.organizationReducer.activeOrganizationId;
8142
- const organizationDocumentsPromise = this.enqueueRequest({
8143
- description: "Get organization documents",
8144
- method: HttpMethod.GET,
8145
- url: `/organizations/${activeOrganizationId}/documents/`,
8116
+ url: `/documents/projects/${activeProjectId}/`,
8146
8117
  blockers: [],
8147
8118
  blocks: []
8148
8119
  });
8149
- store.dispatch(setDocuments(await projectDocumentsPromise));
8150
- store.dispatch(addDocuments(await organizationDocumentsPromise));
8120
+ store.dispatch(setDocuments(result));
8151
8121
  }
8152
8122
  }
8153
8123
  class AgentService extends BaseApiService {