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

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.
@@ -2375,29 +2375,18 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
2375
2375
  (_state, search) => search
2376
2376
  ],
2377
2377
  (formsMapping, revisions, search) => {
2378
- const { searchTerm, maxResults, favorites, organization } = search;
2379
- const favoriteMatches = [];
2378
+ const { searchTerm, maxResults, organization } = search;
2380
2379
  const regularMatches = [];
2381
2380
  for (const [formId, form] of Object.entries(formsMapping)) {
2382
- if (favorites !== void 0 && form.favorite != favorites)
2383
- continue;
2384
2381
  if (Number.isInteger(organization) && organization !== form.organization) {
2385
2382
  continue;
2386
2383
  }
2387
2384
  const latestRevision = _selectLatestFormRevision(revisions, formId);
2388
2385
  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;
2386
+ regularMatches.push({ ...form, latestRevision });
2397
2387
  }
2398
2388
  }
2399
- const maxRegularMatches = maxResults - favoriteMatches.length;
2400
- return [...favoriteMatches, ...regularMatches.slice(0, maxRegularMatches)];
2389
+ return [...regularMatches.slice(0, maxResults)];
2401
2390
  },
2402
2391
  // as the argument is an object, we check the first level of properties for equality
2403
2392
  { memoizeOptions: { equalityCheck: shallowEqual } }
@@ -4047,10 +4036,17 @@ class BaseApiService extends BaseService {
4047
4036
  }
4048
4037
  }
4049
4038
  class CategoryService extends BaseApiService {
4050
- add(category, workspaceId) {
4051
- const offlineCategory = offline(category);
4052
- const categoryWithWorkspace = { ...offlineCategory, workspace: workspaceId };
4053
- this.dispatch(addCategory(categoryWithWorkspace));
4039
+ add(payload, workspaceId) {
4040
+ const { store } = this.client;
4041
+ const createdBy = store.getState().userReducer.currentUser.id;
4042
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4043
+ const offlineCategory = offline({
4044
+ ...payload,
4045
+ created_by: createdBy,
4046
+ submitted_at: submittedAt,
4047
+ workspace: workspaceId
4048
+ });
4049
+ this.dispatch(addCategory(offlineCategory));
4054
4050
  const promise = this.enqueueRequest({
4055
4051
  description: "Create Category",
4056
4052
  method: HttpMethod.POST,
@@ -4059,10 +4055,10 @@ class CategoryService extends BaseApiService {
4059
4055
  workspace_id: workspaceId.toString()
4060
4056
  },
4061
4057
  payload: offlineCategory,
4062
- blockers: [],
4058
+ blockers: [workspaceId],
4063
4059
  blocks: [offlineCategory.offline_id]
4064
4060
  });
4065
- return [categoryWithWorkspace, promise];
4061
+ return [offlineCategory, promise];
4066
4062
  }
4067
4063
  update(category, workspaceId) {
4068
4064
  const state = this.client.store.getState();
@@ -5713,48 +5709,6 @@ class FormService extends BaseUploadService {
5713
5709
  });
5714
5710
  return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
5715
5711
  }
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
5712
  async delete(formId) {
5759
5713
  const { store } = this.client;
5760
5714
  const state = store.getState();
@@ -6215,13 +6169,19 @@ class FormSubmissionService extends BaseUploadService {
6215
6169
  }
6216
6170
  }
6217
6171
  class WorkspaceService extends BaseApiService {
6218
- add(workspace) {
6219
- const offlineWorkspace = offline(workspace);
6172
+ add(payload) {
6173
+ const { store } = this.client;
6174
+ const createdBy = store.getState().userReducer.currentUser.id;
6175
+ const offlineWorkspace = offline({
6176
+ ...payload,
6177
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6178
+ created_by: createdBy
6179
+ });
6220
6180
  this.dispatch(addWorkspace(offlineWorkspace));
6221
6181
  const promise = this.enqueueRequest({
6222
6182
  description: "Create Workspace",
6223
6183
  method: HttpMethod.POST,
6224
- url: `/projects/${workspace.project}/workspaces/`,
6184
+ url: `/projects/${payload.project}/workspaces/`,
6225
6185
  payload: offlineWorkspace,
6226
6186
  blockers: ["add-workspace"],
6227
6187
  blocks: [offlineWorkspace.offline_id]