@overmap-ai/core 1.0.63-selector-standardization.7 → 1.0.63-selector-standardization.9

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.
@@ -938,42 +938,15 @@ var __publicField = (obj, key, value) => {
938
938
  initialState: initialState$y,
939
939
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
940
940
  reducers: {
941
- initializeAssets: (state, action) => {
942
- assetAdapter.initialize(state, action);
943
- prevAssets = null;
944
- },
945
- addAsset: (state, action) => {
946
- assetAdapter.addOne(state, action);
947
- prevAssets = null;
948
- },
949
- addAssets: (state, action) => {
950
- assetAdapter.addMany(state, action);
951
- prevAssets = null;
952
- },
953
- setAsset: (state, action) => {
954
- assetAdapter.setOne(state, action);
955
- prevAssets = null;
956
- },
957
- setAssets: (state, action) => {
958
- assetAdapter.setMany(state, action);
959
- prevAssets = null;
960
- },
961
- updateAsset: (state, action) => {
962
- assetAdapter.updateOne(state, action);
963
- prevAssets = null;
964
- },
965
- updateAssets: (state, action) => {
966
- assetAdapter.updateMany(state, action);
967
- prevAssets = null;
968
- },
969
- deleteAsset: (state, action) => {
970
- assetAdapter.deleteOne(state, action);
971
- prevAssets = null;
972
- },
973
- deleteAssets: (state, action) => {
974
- assetAdapter.deleteMany(state, action);
975
- prevAssets = null;
976
- }
941
+ initializeAssets: assetAdapter.initialize,
942
+ addAsset: assetAdapter.addOne,
943
+ addAssets: assetAdapter.addMany,
944
+ setAsset: assetAdapter.setOne,
945
+ setAssets: assetAdapter.setMany,
946
+ updateAsset: assetAdapter.updateOne,
947
+ updateAssets: assetAdapter.updateMany,
948
+ deleteAsset: assetAdapter.deleteOne,
949
+ deleteAssets: assetAdapter.deleteMany
977
950
  }
978
951
  });
979
952
  const {
@@ -987,13 +960,6 @@ var __publicField = (obj, key, value) => {
987
960
  setAsset,
988
961
  setAssets
989
962
  } = assetSlice.actions;
990
- let prevAssets = null;
991
- const _selectAssets = (state) => {
992
- if (!prevAssets) {
993
- prevAssets = Object.values(state.assetReducer.instances);
994
- }
995
- return prevAssets;
996
- };
997
963
  const selectAssetsMapping = (state) => state.assetReducer.instances;
998
964
  const selectAssets = toolkit.createSelector([selectAssetsMapping], (assetsMapping) => {
999
965
  return Object.values(assetsMapping);
@@ -1730,11 +1696,6 @@ var __publicField = (obj, key, value) => {
1730
1696
  const userReducer = userSlice.reducer;
1731
1697
  const selectCurrentUser = (state) => state.userReducer.currentUser;
1732
1698
  const selectUsersMapping = (state) => state.userReducer.users;
1733
- const selectUser = (userId) => (state) => {
1734
- if (userId === null)
1735
- return void 0;
1736
- return state.userReducer.users[userId];
1737
- };
1738
1699
  const selectUserById = (id) => (state) => {
1739
1700
  return state.userReducer.users[id];
1740
1701
  };
@@ -1813,9 +1774,6 @@ var __publicField = (obj, key, value) => {
1813
1774
  return state.licenseReducer.instances;
1814
1775
  };
1815
1776
  const selectLicense = (id) => (state) => state.licenseReducer.instances[id];
1816
- const selectActiveLicense = (state) => Object.values(state.licenseReducer.instances).find(
1817
- (license) => license.project === state.projectReducer.activeProjectId
1818
- ) ?? null;
1819
1777
  const selectLicenseForProject = (projectId) => (state) => Object.values(state.licenseReducer.instances).find((license) => license.project === projectId);
1820
1778
  const selectActiveStatusLicenses = toolkit.createSelector(
1821
1779
  [selectLicenses],
@@ -2006,19 +1964,19 @@ var __publicField = (obj, key, value) => {
2006
1964
  }
2007
1965
  });
2008
1966
  const { setOrganizations } = organizationSlice.actions;
2009
- const selectOrganizations = (state) => {
2010
- return Object.values(state.organizationReducer.organizations);
2011
- };
2012
1967
  const selectOrganizationsMapping = (state) => {
2013
1968
  return state.organizationReducer.organizations;
2014
1969
  };
1970
+ const selectOrganizations = toolkit.createSelector([selectOrganizationsMapping], (organizationsMapping) => {
1971
+ return Object.values(organizationsMapping);
1972
+ });
1973
+ const selectOrganizationById = (id) => (state) => {
1974
+ return state.organizationReducer.organizations[id];
1975
+ };
2015
1976
  const selectOrganizationsWithAccess = toolkit.createSelector(
2016
1977
  [selectOrganizations],
2017
1978
  (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2018
1979
  );
2019
- const selectOrganizationById = (id) => (state) => {
2020
- return state.organizationReducer.organizations[id];
2021
- };
2022
1980
  const selectOrganizationUsersIds = toolkit.createSelector(
2023
1981
  [selectOrganizationAccesses],
2024
1982
  (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
@@ -2061,9 +2019,6 @@ var __publicField = (obj, key, value) => {
2061
2019
  });
2062
2020
  }
2063
2021
  );
2064
- const selectOrganization = (id) => (state) => {
2065
- return state.organizationReducer.organizations[id];
2066
- };
2067
2022
  const organizationReducer = organizationSlice.reducer;
2068
2023
  const createOfflineAction = (request2, baseUrl, serviceName) => {
2069
2024
  const requestWithUuid = request2.uuid ? request2 : { ...request2, uuid: uuid.v4() };
@@ -2368,32 +2323,6 @@ var __publicField = (obj, key, value) => {
2368
2323
  }
2369
2324
  )
2370
2325
  );
2371
- const selectLatestFormRevisionsOfAssetTypes = restructureCreateSelectorWithArgs(
2372
- toolkit.createSelector(
2373
- [
2374
- (state) => state.formReducer.instances,
2375
- selectFormRevisionMapping,
2376
- (_state, assetTypeIds) => assetTypeIds
2377
- ],
2378
- (formsMapping, revisions, assetTypeIds) => {
2379
- const assetTypeIdsSet = new Set(assetTypeIds);
2380
- const formsOfAssetTypes = {};
2381
- const ret = {};
2382
- for (const form of Object.values(formsMapping)) {
2383
- if (form.asset_type && assetTypeIdsSet.has(form.asset_type)) {
2384
- formsOfAssetTypes[form.offline_id] = form;
2385
- }
2386
- }
2387
- for (const revision of Object.values(revisions)) {
2388
- const form = formsOfAssetTypes[revision.form];
2389
- if (!form || !form.asset_type || ret[form.asset_type] && formRevisionSortFn(ret[form.asset_type], revision) > 0)
2390
- continue;
2391
- ret[form.asset_type] = revision;
2392
- }
2393
- return ret;
2394
- }
2395
- )
2396
- );
2397
2326
  const selectLatestFormRevisionByForm = toolkit.createSelector([selectFormRevisionMapping], (revisions) => {
2398
2327
  const latestRevisions = {};
2399
2328
  for (const revision of Object.values(revisions)) {
@@ -2422,9 +2351,13 @@ var __publicField = (obj, key, value) => {
2422
2351
  }
2423
2352
  });
2424
2353
  const { initializeForms, setForm, addForm, addForms, updateForm, deleteForm } = formSlice.actions;
2425
- const selectFormsMapping = (state) => {
2354
+ const formReducer = formSlice.reducer;
2355
+ const selectFormMapping = (state) => {
2426
2356
  return state.formReducer.instances;
2427
2357
  };
2358
+ const selectForms = toolkit.createSelector([selectFormMapping], (formsMapping) => {
2359
+ return Object.values(formsMapping);
2360
+ });
2428
2361
  const selectFilteredForms = restructureCreateSelectorWithArgs(
2429
2362
  toolkit.createSelector(
2430
2363
  [
@@ -2461,9 +2394,6 @@ var __publicField = (obj, key, value) => {
2461
2394
  { memoizeOptions: { equalityCheck: shallowEqual } }
2462
2395
  )
2463
2396
  );
2464
- const selectFormMapping = (state) => {
2465
- return state.formReducer.instances;
2466
- };
2467
2397
  const selectFormById = (formId) => (state) => {
2468
2398
  return state.formReducer.instances[formId];
2469
2399
  };
@@ -2489,7 +2419,6 @@ var __publicField = (obj, key, value) => {
2489
2419
  const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (formsMapping) => {
2490
2420
  return Object.values(formsMapping).filter((form) => !form.asset_type).length;
2491
2421
  });
2492
- const formReducer = formSlice.reducer;
2493
2422
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2494
2423
  const initialState$d = submissionAdapter.getInitialState({});
2495
2424
  const formSubmissionSlice = toolkit.createSlice({
@@ -2808,7 +2737,7 @@ var __publicField = (obj, key, value) => {
2808
2737
  });
2809
2738
  const { initializeEmailDomains, addEmailDomain, deleteEmailDomain } = emailDomainsSlice.actions;
2810
2739
  const selectEmailDomainsAsMapping = (state) => state.emailDomainsReducer.instances;
2811
- const selectEmailDomains = (state) => Object.values(state.emailDomainsReducer.instances);
2740
+ const selectEmailDomains = toolkit.createSelector([selectEmailDomainsAsMapping], (mapping) => Object.values(mapping));
2812
2741
  const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2813
2742
  toolkit.createSelector(
2814
2743
  [selectEmailDomains, (_, organizationId) => organizationId],
@@ -4300,7 +4229,6 @@ var __publicField = (obj, key, value) => {
4300
4229
  }
4301
4230
  // TODO: payload does not require asset_type
4302
4231
  bulkAdd(assetsToCreate, workspaceId, assetTypeId, batchSize) {
4303
- const { store } = this.client;
4304
4232
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4305
4233
  const transactionId = uuid.v4();
4306
4234
  const assetBatches = chunkArray(assetsToCreate, batchSize).map((assetBatch) => {
@@ -4344,7 +4272,7 @@ var __publicField = (obj, key, value) => {
4344
4272
  }
4345
4273
  void Promise.all(batchPromises).then((result) => {
4346
4274
  const allCreatedAssets = result.flat();
4347
- store.dispatch(addAssets(allCreatedAssets));
4275
+ this.dispatch(addAssets(allCreatedAssets));
4348
4276
  });
4349
4277
  return batchPromises;
4350
4278
  }
@@ -4765,13 +4693,11 @@ var __publicField = (obj, key, value) => {
4765
4693
  class AssetTypeService extends BaseApiService {
4766
4694
  add(assetType) {
4767
4695
  const offlineAssetType = offline(assetType);
4768
- const { store } = this.client;
4769
- const activeProjectId = store.getState().projectReducer.activeProjectId;
4770
4696
  this.dispatch(addAssetType(offlineAssetType));
4771
4697
  const promise = this.enqueueRequest({
4772
4698
  description: "Create asset type",
4773
4699
  method: HttpMethod.POST,
4774
- url: `/projects/${activeProjectId}/asset-types/`,
4700
+ url: `/projects/${assetType.project}/asset-types/`,
4775
4701
  payload: { ...offlineAssetType },
4776
4702
  blockers: [],
4777
4703
  blocks: [offlineAssetType.offline_id]
@@ -5766,10 +5692,6 @@ var __publicField = (obj, key, value) => {
5766
5692
  const offlineRevision = offline(revision);
5767
5693
  const { store } = this.client;
5768
5694
  const state = store.getState();
5769
- const activeProjectId = state.projectReducer.activeProjectId;
5770
- if (!activeProjectId) {
5771
- throw new Error("Cannot create form revision when there is no active project.");
5772
- }
5773
5695
  const currentUserId = state.userReducer.currentUser.id;
5774
5696
  const { fields, images } = await separateImageFromFields(offlineRevision.fields);
5775
5697
  const fullRevision = {
@@ -5808,10 +5730,9 @@ var __publicField = (obj, key, value) => {
5808
5730
  });
5809
5731
  return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
5810
5732
  }
5811
- async favorite(formId) {
5733
+ async favorite(formId, projectId) {
5812
5734
  const { store } = this.client;
5813
5735
  const state = store.getState();
5814
- const activeProjectId = state.projectReducer.activeProjectId;
5815
5736
  const form = state.formReducer.instances[formId];
5816
5737
  if (!form) {
5817
5738
  throw new Error(`Expected form to exist, got ${form}`);
@@ -5821,7 +5742,7 @@ var __publicField = (obj, key, value) => {
5821
5742
  await this.enqueueRequest({
5822
5743
  description: "Favorite form",
5823
5744
  method: HttpMethod.POST,
5824
- url: `/forms/${formId}/favorite/${activeProjectId}/`,
5745
+ url: `/forms/${formId}/favorite/${projectId}/`,
5825
5746
  blockers: [formId, `favorite-${formId}`],
5826
5747
  blocks: [`favorite-${formId}`]
5827
5748
  });
@@ -5830,10 +5751,9 @@ var __publicField = (obj, key, value) => {
5830
5751
  throw e;
5831
5752
  }
5832
5753
  }
5833
- async unfavorite(formId) {
5754
+ async unfavorite(formId, projectId) {
5834
5755
  const { store } = this.client;
5835
5756
  const state = store.getState();
5836
- const activeProjectId = state.projectReducer.activeProjectId;
5837
5757
  const form = state.formReducer.instances[formId];
5838
5758
  if (!form) {
5839
5759
  throw new Error(`Expected form to exist, got ${form}`);
@@ -5843,7 +5763,7 @@ var __publicField = (obj, key, value) => {
5843
5763
  return await this.enqueueRequest({
5844
5764
  description: "Unfavorite form",
5845
5765
  method: HttpMethod.DELETE,
5846
- url: `/forms/${formId}/unfavorite/${activeProjectId}/`,
5766
+ url: `/forms/${formId}/unfavorite/${projectId}/`,
5847
5767
  blockers: [formId, `favorite-${formId}`],
5848
5768
  blocks: [`favorite-${formId}`]
5849
5769
  });
@@ -6055,10 +5975,6 @@ var __publicField = (obj, key, value) => {
6055
5975
  async add(payload) {
6056
5976
  const { store } = this.client;
6057
5977
  const state = store.getState();
6058
- const activeProjectId = state.projectReducer.activeProjectId;
6059
- if (!activeProjectId) {
6060
- throw new Error("Expected an active project");
6061
- }
6062
5978
  const { values, files } = separateFilesFromValues(payload.values);
6063
5979
  const offlineSubmission = offline({
6064
5980
  ...payload,
@@ -6070,7 +5986,7 @@ var __publicField = (obj, key, value) => {
6070
5986
  description: "Respond to form",
6071
5987
  method: HttpMethod.POST,
6072
5988
  url: `/forms/revisions/${payload.form_revision}/respond/`,
6073
- payload: { ...offlineSubmission, project: activeProjectId },
5989
+ payload: offlineSubmission,
6074
5990
  blockers: [payload.issue, payload.asset, payload.asset_stage, "add-form-entry"].filter(
6075
5991
  (x) => x !== void 0
6076
5992
  ),
@@ -6291,13 +6207,12 @@ var __publicField = (obj, key, value) => {
6291
6207
  }
6292
6208
  class WorkspaceService extends BaseApiService {
6293
6209
  add(workspace) {
6294
- const { store } = this.client;
6295
6210
  const offlineWorkspace = offline(workspace);
6296
6211
  this.dispatch(addWorkspace(offlineWorkspace));
6297
6212
  const promise = this.enqueueRequest({
6298
6213
  description: "Create Workspace",
6299
6214
  method: HttpMethod.POST,
6300
- url: `/projects/${store.getState().projectReducer.activeProjectId}/workspaces/`,
6215
+ url: `/projects/${workspace.project}/workspaces/`,
6301
6216
  payload: offlineWorkspace,
6302
6217
  blockers: ["add-workspace"],
6303
6218
  blocks: [offlineWorkspace.offline_id]
@@ -7558,7 +7473,6 @@ var __publicField = (obj, key, value) => {
7558
7473
  exports2.VerificationCodeType = VerificationCodeType;
7559
7474
  exports2.WorkspaceService = WorkspaceService;
7560
7475
  exports2.YELLOW = YELLOW;
7561
- exports2._selectAssets = _selectAssets;
7562
7476
  exports2._selectLatestFormRevision = _selectLatestFormRevision;
7563
7477
  exports2._setLatestRetryTime = _setLatestRetryTime;
7564
7478
  exports2.acceptProjectInvite = acceptProjectInvite;
@@ -7821,7 +7735,6 @@ var __publicField = (obj, key, value) => {
7821
7735
  exports2.saveActiveProjectFileBounds = saveActiveProjectFileBounds;
7822
7736
  exports2.searchIssues = searchIssues;
7823
7737
  exports2.selectAccessToken = selectAccessToken;
7824
- exports2.selectActiveLicense = selectActiveLicense;
7825
7738
  exports2.selectActiveOrganizationAccess = selectActiveOrganizationAccess;
7826
7739
  exports2.selectActiveProject = selectActiveProject;
7827
7740
  exports2.selectActiveProjectAccess = selectActiveProjectAccess;
@@ -7909,8 +7822,8 @@ var __publicField = (obj, key, value) => {
7909
7822
  exports2.selectFormSubmissionsOfAsset = selectFormSubmissionsOfAsset;
7910
7823
  exports2.selectFormSubmissionsOfForm = selectFormSubmissionsOfForm;
7911
7824
  exports2.selectFormSubmissionsOfIssue = selectFormSubmissionsOfIssue;
7825
+ exports2.selectForms = selectForms;
7912
7826
  exports2.selectFormsCount = selectFormsCount;
7913
- exports2.selectFormsMapping = selectFormsMapping;
7914
7827
  exports2.selectGeneralFormCount = selectGeneralFormCount;
7915
7828
  exports2.selectGeoImageById = selectGeoImageById;
7916
7829
  exports2.selectGeoImageMapping = selectGeoImageMapping;
@@ -7943,7 +7856,6 @@ var __publicField = (obj, key, value) => {
7943
7856
  exports2.selectIssuesOfIssueTypeCount = selectIssuesOfIssueTypeCount;
7944
7857
  exports2.selectLatestFormRevisionByForm = selectLatestFormRevisionByForm;
7945
7858
  exports2.selectLatestFormRevisionOfForm = selectLatestFormRevisionOfForm;
7946
- exports2.selectLatestFormRevisionsOfAssetTypes = selectLatestFormRevisionsOfAssetTypes;
7947
7859
  exports2.selectLatestRetryTime = selectLatestRetryTime;
7948
7860
  exports2.selectLicense = selectLicense;
7949
7861
  exports2.selectLicenseForProject = selectLicenseForProject;
@@ -7952,7 +7864,6 @@ var __publicField = (obj, key, value) => {
7952
7864
  exports2.selectLicensesOfOrganization = selectLicensesOfOrganization;
7953
7865
  exports2.selectMainWorkspace = selectMainWorkspace;
7954
7866
  exports2.selectNumberOfAssetsOfAssetType = selectNumberOfAssetsOfAssetType;
7955
- exports2.selectOrganization = selectOrganization;
7956
7867
  exports2.selectOrganizationAccessById = selectOrganizationAccessById;
7957
7868
  exports2.selectOrganizationAccessForUser = selectOrganizationAccessForUser;
7958
7869
  exports2.selectOrganizationAccessUserMapping = selectOrganizationAccessUserMapping;
@@ -7997,7 +7908,6 @@ var __publicField = (obj, key, value) => {
7997
7908
  exports2.selectTeamsOfOrganization = selectTeamsOfOrganization;
7998
7909
  exports2.selectTeamsOfUser = selectTeamsOfUser;
7999
7910
  exports2.selectUploadUrl = selectUploadUrl;
8000
- exports2.selectUser = selectUser;
8001
7911
  exports2.selectUserById = selectUserById;
8002
7912
  exports2.selectUsersByIds = selectUsersByIds;
8003
7913
  exports2.selectUsersMapping = selectUsersMapping;