@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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @overmap-ai/core
2
-
3
- The `core` package contains core functionality for the Overmap platform. It is a peer dependency of all other overmap
4
- packages.
1
+ # @overmap-ai/core
2
+
3
+ The `core` package contains core functionality for the Overmap platform. It is a peer dependency of all other overmap
4
+ packages.
@@ -4069,18 +4069,9 @@ const documentSlice = createSlice({
4069
4069
  }
4070
4070
  }
4071
4071
  for (const document2 of action.payload) {
4072
- const existingDocument = state.documents[document2.offline_id];
4073
- if (document2.organization !== void 0 && document2.organization !== existingDocument.organization) {
4074
- throw new Error("organization cannot be updated");
4075
- }
4076
- if (document2.project !== void 0 && document2.project !== existingDocument.project) {
4077
- throw new Error("project cannot be updated");
4078
- }
4079
4072
  state.documents[document2.offline_id] = {
4080
- ...existingDocument,
4073
+ ...state.documents[document2.offline_id],
4081
4074
  ...document2
4082
- // Without the cast, TypeScript doesn't realize that we have guaranteed that the document doesn't
4083
- // have both a project and an organization.
4084
4075
  };
4085
4076
  }
4086
4077
  },
@@ -8007,28 +7998,17 @@ class LicenseService extends BaseApiService {
8007
7998
  }
8008
7999
  }
8009
8000
  class DocumentService extends BaseApiService {
8010
- // TODO: Support adding for project or organization
8011
8001
  add(document2) {
8012
8002
  const { store } = this.client;
8013
8003
  const currentUserId = store.getState().userReducer.currentUser.id;
8014
8004
  const activeProjectId = store.getState().projectReducer.activeProjectId;
8015
- if (!activeProjectId) {
8016
- throw new Error("No active project ID while creating document.");
8017
- }
8018
- const offlineDocument = offline(document2);
8019
- const submittedDocument = {
8020
- ...offlineDocument,
8021
- created_by: currentUserId,
8022
- project: activeProjectId,
8023
- organization: null,
8024
- children_documents: []
8025
- };
8026
- store.dispatch(addDocuments([submittedDocument]));
8005
+ const offlineDocument = offline({ ...document2, created_by: currentUserId });
8006
+ store.dispatch(addDocuments([offlineDocument]));
8027
8007
  const promise = this.enqueueRequest({
8028
8008
  description: "Create Document",
8029
8009
  method: HttpMethod.POST,
8030
- url: `/projects/${activeProjectId}/documents/`,
8031
- payload: offlineDocument,
8010
+ url: `/projects/${activeProjectId}/create-document/`,
8011
+ payload: { ...offlineDocument },
8032
8012
  queryParams: {
8033
8013
  parent_document: offlineDocument.parent_document ?? void 0
8034
8014
  },
@@ -8039,7 +8019,7 @@ class DocumentService extends BaseApiService {
8039
8019
  promise.catch(() => {
8040
8020
  store.dispatch(removeDocuments([offlineDocument.offline_id]));
8041
8021
  });
8042
- return [submittedDocument, promise];
8022
+ return [offlineDocument, promise];
8043
8023
  }
8044
8024
  update(document2) {
8045
8025
  const { store } = this.client;
@@ -8139,25 +8119,15 @@ class DocumentService extends BaseApiService {
8139
8119
  }
8140
8120
  async refreshStore() {
8141
8121
  const { store } = this.client;
8142
- const state = store.getState();
8143
- const activeProjectId = state.projectReducer.activeProjectId;
8144
- const projectDocumentsPromise = this.enqueueRequest({
8122
+ const activeProjectId = store.getState().projectReducer.activeProjectId;
8123
+ const result = await this.enqueueRequest({
8145
8124
  description: "Get project documents",
8146
8125
  method: HttpMethod.GET,
8147
- url: `/projects/${activeProjectId}/documents/`,
8148
- blockers: [],
8149
- blocks: []
8150
- });
8151
- const activeOrganizationId = state.organizationReducer.activeOrganizationId;
8152
- const organizationDocumentsPromise = this.enqueueRequest({
8153
- description: "Get organization documents",
8154
- method: HttpMethod.GET,
8155
- url: `/organizations/${activeOrganizationId}/documents/`,
8126
+ url: `/documents/projects/${activeProjectId}/`,
8156
8127
  blockers: [],
8157
8128
  blocks: []
8158
8129
  });
8159
- store.dispatch(setDocuments(await projectDocumentsPromise));
8160
- store.dispatch(addDocuments(await organizationDocumentsPromise));
8130
+ store.dispatch(setDocuments(result));
8161
8131
  }
8162
8132
  }
8163
8133
  class AgentService extends BaseApiService {