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

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.
@@ -950,42 +950,15 @@ const assetSlice = createSlice({
950
950
  initialState: initialState$y,
951
951
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
952
952
  reducers: {
953
- initializeAssets: (state, action) => {
954
- assetAdapter.initialize(state, action);
955
- prevAssets = null;
956
- },
957
- addAsset: (state, action) => {
958
- assetAdapter.addOne(state, action);
959
- prevAssets = null;
960
- },
961
- addAssets: (state, action) => {
962
- assetAdapter.addMany(state, action);
963
- prevAssets = null;
964
- },
965
- setAsset: (state, action) => {
966
- assetAdapter.setOne(state, action);
967
- prevAssets = null;
968
- },
969
- setAssets: (state, action) => {
970
- assetAdapter.setMany(state, action);
971
- prevAssets = null;
972
- },
973
- updateAsset: (state, action) => {
974
- assetAdapter.updateOne(state, action);
975
- prevAssets = null;
976
- },
977
- updateAssets: (state, action) => {
978
- assetAdapter.updateMany(state, action);
979
- prevAssets = null;
980
- },
981
- deleteAsset: (state, action) => {
982
- assetAdapter.deleteOne(state, action);
983
- prevAssets = null;
984
- },
985
- deleteAssets: (state, action) => {
986
- assetAdapter.deleteMany(state, action);
987
- prevAssets = null;
988
- }
953
+ initializeAssets: assetAdapter.initialize,
954
+ addAsset: assetAdapter.addOne,
955
+ addAssets: assetAdapter.addMany,
956
+ setAsset: assetAdapter.setOne,
957
+ setAssets: assetAdapter.setMany,
958
+ updateAsset: assetAdapter.updateOne,
959
+ updateAssets: assetAdapter.updateMany,
960
+ deleteAsset: assetAdapter.deleteOne,
961
+ deleteAssets: assetAdapter.deleteMany
989
962
  }
990
963
  });
991
964
  const {
@@ -999,13 +972,6 @@ const {
999
972
  setAsset,
1000
973
  setAssets
1001
974
  } = assetSlice.actions;
1002
- let prevAssets = null;
1003
- const _selectAssets = (state) => {
1004
- if (!prevAssets) {
1005
- prevAssets = Object.values(state.assetReducer.instances);
1006
- }
1007
- return prevAssets;
1008
- };
1009
975
  const selectAssetsMapping = (state) => state.assetReducer.instances;
1010
976
  const selectAssets = createSelector([selectAssetsMapping], (assetsMapping) => {
1011
977
  return Object.values(assetsMapping);
@@ -1742,11 +1708,6 @@ const {
1742
1708
  const userReducer = userSlice.reducer;
1743
1709
  const selectCurrentUser = (state) => state.userReducer.currentUser;
1744
1710
  const selectUsersMapping = (state) => state.userReducer.users;
1745
- const selectUser = (userId) => (state) => {
1746
- if (userId === null)
1747
- return void 0;
1748
- return state.userReducer.users[userId];
1749
- };
1750
1711
  const selectUserById = (id) => (state) => {
1751
1712
  return state.userReducer.users[id];
1752
1713
  };
@@ -2018,19 +1979,19 @@ const organizationSlice = createSlice({
2018
1979
  }
2019
1980
  });
2020
1981
  const { setOrganizations } = organizationSlice.actions;
2021
- const selectOrganizations = (state) => {
2022
- return Object.values(state.organizationReducer.organizations);
2023
- };
2024
1982
  const selectOrganizationsMapping = (state) => {
2025
1983
  return state.organizationReducer.organizations;
2026
1984
  };
1985
+ const selectOrganizations = createSelector([selectOrganizationsMapping], (organizationsMapping) => {
1986
+ return Object.values(organizationsMapping);
1987
+ });
1988
+ const selectOrganizationById = (id) => (state) => {
1989
+ return state.organizationReducer.organizations[id];
1990
+ };
2027
1991
  const selectOrganizationsWithAccess = createSelector(
2028
1992
  [selectOrganizations],
2029
1993
  (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2030
1994
  );
2031
- const selectOrganizationById = (id) => (state) => {
2032
- return state.organizationReducer.organizations[id];
2033
- };
2034
1995
  const selectOrganizationUsersIds = createSelector(
2035
1996
  [selectOrganizationAccesses],
2036
1997
  (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
@@ -2073,9 +2034,6 @@ const selectSortedOrganizationUsers = createSelector(
2073
2034
  });
2074
2035
  }
2075
2036
  );
2076
- const selectOrganization = (id) => (state) => {
2077
- return state.organizationReducer.organizations[id];
2078
- };
2079
2037
  const organizationReducer = organizationSlice.reducer;
2080
2038
  const createOfflineAction = (request2, baseUrl, serviceName) => {
2081
2039
  const requestWithUuid = request2.uuid ? request2 : { ...request2, uuid: v4() };
@@ -2380,32 +2338,6 @@ const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
2380
2338
  }
2381
2339
  )
2382
2340
  );
2383
- const selectLatestFormRevisionsOfAssetTypes = restructureCreateSelectorWithArgs(
2384
- createSelector(
2385
- [
2386
- (state) => state.formReducer.instances,
2387
- selectFormRevisionMapping,
2388
- (_state, assetTypeIds) => assetTypeIds
2389
- ],
2390
- (formsMapping, revisions, assetTypeIds) => {
2391
- const assetTypeIdsSet = new Set(assetTypeIds);
2392
- const formsOfAssetTypes = {};
2393
- const ret = {};
2394
- for (const form of Object.values(formsMapping)) {
2395
- if (form.asset_type && assetTypeIdsSet.has(form.asset_type)) {
2396
- formsOfAssetTypes[form.offline_id] = form;
2397
- }
2398
- }
2399
- for (const revision of Object.values(revisions)) {
2400
- const form = formsOfAssetTypes[revision.form];
2401
- if (!form || !form.asset_type || ret[form.asset_type] && formRevisionSortFn(ret[form.asset_type], revision) > 0)
2402
- continue;
2403
- ret[form.asset_type] = revision;
2404
- }
2405
- return ret;
2406
- }
2407
- )
2408
- );
2409
2341
  const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping], (revisions) => {
2410
2342
  const latestRevisions = {};
2411
2343
  for (const revision of Object.values(revisions)) {
@@ -2434,9 +2366,13 @@ const formSlice = createSlice({
2434
2366
  }
2435
2367
  });
2436
2368
  const { initializeForms, setForm, addForm, addForms, updateForm, deleteForm } = formSlice.actions;
2437
- const selectFormsMapping = (state) => {
2369
+ const formReducer = formSlice.reducer;
2370
+ const selectFormMapping = (state) => {
2438
2371
  return state.formReducer.instances;
2439
2372
  };
2373
+ const selectForms = createSelector([selectFormMapping], (formsMapping) => {
2374
+ return Object.values(formsMapping);
2375
+ });
2440
2376
  const selectFilteredForms = restructureCreateSelectorWithArgs(
2441
2377
  createSelector(
2442
2378
  [
@@ -2473,9 +2409,6 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
2473
2409
  { memoizeOptions: { equalityCheck: shallowEqual } }
2474
2410
  )
2475
2411
  );
2476
- const selectFormMapping = (state) => {
2477
- return state.formReducer.instances;
2478
- };
2479
2412
  const selectFormById = (formId) => (state) => {
2480
2413
  return state.formReducer.instances[formId];
2481
2414
  };
@@ -2501,7 +2434,6 @@ const selectFormsCount = createSelector([selectFormMapping], (formsMapping) => {
2501
2434
  const selectGeneralFormCount = createSelector([selectFormMapping], (formsMapping) => {
2502
2435
  return Object.values(formsMapping).filter((form) => !form.asset_type).length;
2503
2436
  });
2504
- const formReducer = formSlice.reducer;
2505
2437
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2506
2438
  const initialState$d = submissionAdapter.getInitialState({});
2507
2439
  const formSubmissionSlice = createSlice({
@@ -2820,7 +2752,7 @@ const emailDomainsSlice = createSlice({
2820
2752
  });
2821
2753
  const { initializeEmailDomains, addEmailDomain, deleteEmailDomain } = emailDomainsSlice.actions;
2822
2754
  const selectEmailDomainsAsMapping = (state) => state.emailDomainsReducer.instances;
2823
- const selectEmailDomains = (state) => Object.values(state.emailDomainsReducer.instances);
2755
+ const selectEmailDomains = createSelector([selectEmailDomainsAsMapping], (mapping) => Object.values(mapping));
2824
2756
  const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2825
2757
  createSelector(
2826
2758
  [selectEmailDomains, (_, organizationId) => organizationId],
@@ -4312,7 +4244,6 @@ class AssetService extends BaseApiService {
4312
4244
  }
4313
4245
  // TODO: payload does not require asset_type
4314
4246
  bulkAdd(assetsToCreate, workspaceId, assetTypeId, batchSize) {
4315
- const { store } = this.client;
4316
4247
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4317
4248
  const transactionId = v4();
4318
4249
  const assetBatches = chunkArray(assetsToCreate, batchSize).map((assetBatch) => {
@@ -4356,7 +4287,7 @@ class AssetService extends BaseApiService {
4356
4287
  }
4357
4288
  void Promise.all(batchPromises).then((result) => {
4358
4289
  const allCreatedAssets = result.flat();
4359
- store.dispatch(addAssets(allCreatedAssets));
4290
+ this.dispatch(addAssets(allCreatedAssets));
4360
4291
  });
4361
4292
  return batchPromises;
4362
4293
  }
@@ -7571,7 +7502,6 @@ export {
7571
7502
  VerificationCodeType,
7572
7503
  WorkspaceService,
7573
7504
  YELLOW,
7574
- _selectAssets,
7575
7505
  _selectLatestFormRevision,
7576
7506
  _setLatestRetryTime,
7577
7507
  acceptProjectInvite,
@@ -7922,8 +7852,8 @@ export {
7922
7852
  selectFormSubmissionsOfAsset,
7923
7853
  selectFormSubmissionsOfForm,
7924
7854
  selectFormSubmissionsOfIssue,
7855
+ selectForms,
7925
7856
  selectFormsCount,
7926
- selectFormsMapping,
7927
7857
  selectGeneralFormCount,
7928
7858
  selectGeoImageById,
7929
7859
  selectGeoImageMapping,
@@ -7956,7 +7886,6 @@ export {
7956
7886
  selectIssuesOfIssueTypeCount,
7957
7887
  selectLatestFormRevisionByForm,
7958
7888
  selectLatestFormRevisionOfForm,
7959
- selectLatestFormRevisionsOfAssetTypes,
7960
7889
  selectLatestRetryTime,
7961
7890
  selectLicense,
7962
7891
  selectLicenseForProject,
@@ -7965,7 +7894,6 @@ export {
7965
7894
  selectLicensesOfOrganization,
7966
7895
  selectMainWorkspace,
7967
7896
  selectNumberOfAssetsOfAssetType,
7968
- selectOrganization,
7969
7897
  selectOrganizationAccessById,
7970
7898
  selectOrganizationAccessForUser,
7971
7899
  selectOrganizationAccessUserMapping,
@@ -8010,7 +7938,6 @@ export {
8010
7938
  selectTeamsOfOrganization,
8011
7939
  selectTeamsOfUser,
8012
7940
  selectUploadUrl,
8013
- selectUser,
8014
7941
  selectUserById,
8015
7942
  selectUsersByIds,
8016
7943
  selectUsersMapping,