@overmap-ai/core 1.0.63-selector-standardization.6 → 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.
@@ -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,14 +960,10 @@ 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;
964
+ const selectAssets = toolkit.createSelector([selectAssetsMapping], (assetsMapping) => {
965
+ return Object.values(assetsMapping);
966
+ });
998
967
  const selectAssetsOfAssetType = restructureCreateSelectorWithArgs(
999
968
  toolkit.createSelector([selectAssets, (_state, assetTypeId) => assetTypeId], (components, assetTypeId) => {
1000
969
  return components.filter((asset) => asset.asset_type === assetTypeId);
@@ -1727,11 +1696,6 @@ var __publicField = (obj, key, value) => {
1727
1696
  const userReducer = userSlice.reducer;
1728
1697
  const selectCurrentUser = (state) => state.userReducer.currentUser;
1729
1698
  const selectUsersMapping = (state) => state.userReducer.users;
1730
- const selectUser = (userId) => (state) => {
1731
- if (userId === null)
1732
- return void 0;
1733
- return state.userReducer.users[userId];
1734
- };
1735
1699
  const selectUserById = (id) => (state) => {
1736
1700
  return state.userReducer.users[id];
1737
1701
  };
@@ -2003,19 +1967,19 @@ var __publicField = (obj, key, value) => {
2003
1967
  }
2004
1968
  });
2005
1969
  const { setOrganizations } = organizationSlice.actions;
2006
- const selectOrganizations = (state) => {
2007
- return Object.values(state.organizationReducer.organizations);
2008
- };
2009
1970
  const selectOrganizationsMapping = (state) => {
2010
1971
  return state.organizationReducer.organizations;
2011
1972
  };
1973
+ const selectOrganizations = toolkit.createSelector([selectOrganizationsMapping], (organizationsMapping) => {
1974
+ return Object.values(organizationsMapping);
1975
+ });
1976
+ const selectOrganizationById = (id) => (state) => {
1977
+ return state.organizationReducer.organizations[id];
1978
+ };
2012
1979
  const selectOrganizationsWithAccess = toolkit.createSelector(
2013
1980
  [selectOrganizations],
2014
1981
  (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2015
1982
  );
2016
- const selectOrganizationById = (id) => (state) => {
2017
- return state.organizationReducer.organizations[id];
2018
- };
2019
1983
  const selectOrganizationUsersIds = toolkit.createSelector(
2020
1984
  [selectOrganizationAccesses],
2021
1985
  (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
@@ -2058,9 +2022,6 @@ var __publicField = (obj, key, value) => {
2058
2022
  });
2059
2023
  }
2060
2024
  );
2061
- const selectOrganization = (id) => (state) => {
2062
- return state.organizationReducer.organizations[id];
2063
- };
2064
2025
  const organizationReducer = organizationSlice.reducer;
2065
2026
  const createOfflineAction = (request2, baseUrl, serviceName) => {
2066
2027
  const requestWithUuid = request2.uuid ? request2 : { ...request2, uuid: uuid.v4() };
@@ -2365,32 +2326,6 @@ var __publicField = (obj, key, value) => {
2365
2326
  }
2366
2327
  )
2367
2328
  );
2368
- const selectLatestFormRevisionsOfAssetTypes = restructureCreateSelectorWithArgs(
2369
- toolkit.createSelector(
2370
- [
2371
- (state) => state.formReducer.instances,
2372
- selectFormRevisionMapping,
2373
- (_state, assetTypeIds) => assetTypeIds
2374
- ],
2375
- (formsMapping, revisions, assetTypeIds) => {
2376
- const assetTypeIdsSet = new Set(assetTypeIds);
2377
- const formsOfAssetTypes = {};
2378
- const ret = {};
2379
- for (const form of Object.values(formsMapping)) {
2380
- if (form.asset_type && assetTypeIdsSet.has(form.asset_type)) {
2381
- formsOfAssetTypes[form.offline_id] = form;
2382
- }
2383
- }
2384
- for (const revision of Object.values(revisions)) {
2385
- const form = formsOfAssetTypes[revision.form];
2386
- if (!form || !form.asset_type || ret[form.asset_type] && formRevisionSortFn(ret[form.asset_type], revision) > 0)
2387
- continue;
2388
- ret[form.asset_type] = revision;
2389
- }
2390
- return ret;
2391
- }
2392
- )
2393
- );
2394
2329
  const selectLatestFormRevisionByForm = toolkit.createSelector([selectFormRevisionMapping], (revisions) => {
2395
2330
  const latestRevisions = {};
2396
2331
  for (const revision of Object.values(revisions)) {
@@ -2419,9 +2354,13 @@ var __publicField = (obj, key, value) => {
2419
2354
  }
2420
2355
  });
2421
2356
  const { initializeForms, setForm, addForm, addForms, updateForm, deleteForm } = formSlice.actions;
2422
- const selectFormsMapping = (state) => {
2357
+ const formReducer = formSlice.reducer;
2358
+ const selectFormMapping = (state) => {
2423
2359
  return state.formReducer.instances;
2424
2360
  };
2361
+ const selectForms = toolkit.createSelector([selectFormMapping], (formsMapping) => {
2362
+ return Object.values(formsMapping);
2363
+ });
2425
2364
  const selectFilteredForms = restructureCreateSelectorWithArgs(
2426
2365
  toolkit.createSelector(
2427
2366
  [
@@ -2458,9 +2397,6 @@ var __publicField = (obj, key, value) => {
2458
2397
  { memoizeOptions: { equalityCheck: shallowEqual } }
2459
2398
  )
2460
2399
  );
2461
- const selectFormMapping = (state) => {
2462
- return state.formReducer.instances;
2463
- };
2464
2400
  const selectFormById = (formId) => (state) => {
2465
2401
  return state.formReducer.instances[formId];
2466
2402
  };
@@ -2486,7 +2422,6 @@ var __publicField = (obj, key, value) => {
2486
2422
  const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (formsMapping) => {
2487
2423
  return Object.values(formsMapping).filter((form) => !form.asset_type).length;
2488
2424
  });
2489
- const formReducer = formSlice.reducer;
2490
2425
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2491
2426
  const initialState$d = submissionAdapter.getInitialState({});
2492
2427
  const formSubmissionSlice = toolkit.createSlice({
@@ -2805,7 +2740,7 @@ var __publicField = (obj, key, value) => {
2805
2740
  });
2806
2741
  const { initializeEmailDomains, addEmailDomain, deleteEmailDomain } = emailDomainsSlice.actions;
2807
2742
  const selectEmailDomainsAsMapping = (state) => state.emailDomainsReducer.instances;
2808
- const selectEmailDomains = (state) => Object.values(state.emailDomainsReducer.instances);
2743
+ const selectEmailDomains = toolkit.createSelector([selectEmailDomainsAsMapping], (mapping) => Object.values(mapping));
2809
2744
  const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2810
2745
  toolkit.createSelector(
2811
2746
  [selectEmailDomains, (_, organizationId) => organizationId],
@@ -4297,7 +4232,6 @@ var __publicField = (obj, key, value) => {
4297
4232
  }
4298
4233
  // TODO: payload does not require asset_type
4299
4234
  bulkAdd(assetsToCreate, workspaceId, assetTypeId, batchSize) {
4300
- const { store } = this.client;
4301
4235
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4302
4236
  const transactionId = uuid.v4();
4303
4237
  const assetBatches = chunkArray(assetsToCreate, batchSize).map((assetBatch) => {
@@ -4341,7 +4275,7 @@ var __publicField = (obj, key, value) => {
4341
4275
  }
4342
4276
  void Promise.all(batchPromises).then((result) => {
4343
4277
  const allCreatedAssets = result.flat();
4344
- store.dispatch(addAssets(allCreatedAssets));
4278
+ this.dispatch(addAssets(allCreatedAssets));
4345
4279
  });
4346
4280
  return batchPromises;
4347
4281
  }
@@ -7905,8 +7839,8 @@ var __publicField = (obj, key, value) => {
7905
7839
  exports2.selectFormSubmissionsOfAsset = selectFormSubmissionsOfAsset;
7906
7840
  exports2.selectFormSubmissionsOfForm = selectFormSubmissionsOfForm;
7907
7841
  exports2.selectFormSubmissionsOfIssue = selectFormSubmissionsOfIssue;
7842
+ exports2.selectForms = selectForms;
7908
7843
  exports2.selectFormsCount = selectFormsCount;
7909
- exports2.selectFormsMapping = selectFormsMapping;
7910
7844
  exports2.selectGeneralFormCount = selectGeneralFormCount;
7911
7845
  exports2.selectGeoImageById = selectGeoImageById;
7912
7846
  exports2.selectGeoImageMapping = selectGeoImageMapping;
@@ -7939,7 +7873,6 @@ var __publicField = (obj, key, value) => {
7939
7873
  exports2.selectIssuesOfIssueTypeCount = selectIssuesOfIssueTypeCount;
7940
7874
  exports2.selectLatestFormRevisionByForm = selectLatestFormRevisionByForm;
7941
7875
  exports2.selectLatestFormRevisionOfForm = selectLatestFormRevisionOfForm;
7942
- exports2.selectLatestFormRevisionsOfAssetTypes = selectLatestFormRevisionsOfAssetTypes;
7943
7876
  exports2.selectLatestRetryTime = selectLatestRetryTime;
7944
7877
  exports2.selectLicense = selectLicense;
7945
7878
  exports2.selectLicenseForProject = selectLicenseForProject;
@@ -7948,7 +7881,6 @@ var __publicField = (obj, key, value) => {
7948
7881
  exports2.selectLicensesOfOrganization = selectLicensesOfOrganization;
7949
7882
  exports2.selectMainWorkspace = selectMainWorkspace;
7950
7883
  exports2.selectNumberOfAssetsOfAssetType = selectNumberOfAssetsOfAssetType;
7951
- exports2.selectOrganization = selectOrganization;
7952
7884
  exports2.selectOrganizationAccessById = selectOrganizationAccessById;
7953
7885
  exports2.selectOrganizationAccessForUser = selectOrganizationAccessForUser;
7954
7886
  exports2.selectOrganizationAccessUserMapping = selectOrganizationAccessUserMapping;
@@ -7993,7 +7925,6 @@ var __publicField = (obj, key, value) => {
7993
7925
  exports2.selectTeamsOfOrganization = selectTeamsOfOrganization;
7994
7926
  exports2.selectTeamsOfUser = selectTeamsOfUser;
7995
7927
  exports2.selectUploadUrl = selectUploadUrl;
7996
- exports2.selectUser = selectUser;
7997
7928
  exports2.selectUserById = selectUserById;
7998
7929
  exports2.selectUsersByIds = selectUsersByIds;
7999
7930
  exports2.selectUsersMapping = selectUsersMapping;