@overmap-ai/core 1.0.63-org-doc-improvements.1 → 1.0.63-selector-standardization.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.
Files changed (30) hide show
  1. package/dist/overmap-core.js +431 -283
  2. package/dist/overmap-core.js.map +1 -1
  3. package/dist/overmap-core.umd.cjs +431 -283
  4. package/dist/overmap-core.umd.cjs.map +1 -1
  5. package/dist/sdk/services/BaseAttachmentService.d.ts +1 -1
  6. package/dist/sdk/services/DocumentAttachmentService.d.ts +1 -0
  7. package/dist/sdk/services/FormSubmissionService.d.ts +9 -1
  8. package/dist/sdk/services/IssueTypeService.d.ts +1 -1
  9. package/dist/store/slices/assetSlice.d.ts +2 -1
  10. package/dist/store/slices/assetStageSlice.d.ts +9 -5
  11. package/dist/store/slices/assetTypeSlice.d.ts +4 -10
  12. package/dist/store/slices/categorySlice.d.ts +2 -1
  13. package/dist/store/slices/documentSlice.d.ts +3 -2
  14. package/dist/store/slices/formRevisionSlice.d.ts +1 -1
  15. package/dist/store/slices/formSlice.d.ts +1 -1
  16. package/dist/store/slices/formSubmissionAttachmentSlice.d.ts +2 -1
  17. package/dist/store/slices/formSubmissionSlice.d.ts +1 -1
  18. package/dist/store/slices/index.d.ts +0 -1
  19. package/dist/store/slices/issueAssociationSlice.d.ts +5 -0
  20. package/dist/store/slices/issueSlice.d.ts +2 -1
  21. package/dist/store/slices/issueTypeSlice.d.ts +2 -1
  22. package/dist/store/slices/projectAccessSlice.d.ts +2 -2
  23. package/dist/store/slices/projectSlice.d.ts +3 -3
  24. package/dist/store/slices/teamSlice.d.ts +1 -1
  25. package/dist/store/slices/userSlice.d.ts +4 -2
  26. package/dist/store/store.d.ts +1 -2
  27. package/dist/typings/models/forms.d.ts +1 -0
  28. package/dist/typings/models/store.d.ts +1 -2
  29. package/package.json +1 -1
  30. package/dist/store/slices/settingsSlice.d.ts +0 -11
@@ -379,15 +379,15 @@ const wrapMigration = (migrator) => (state) => {
379
379
  };
380
380
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
381
381
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
382
- const initialState$C = {
382
+ const initialState$B = {
383
383
  accessToken: "",
384
384
  refreshToken: "",
385
385
  isLoggedIn: false
386
386
  };
387
387
  const authSlice = createSlice({
388
388
  name: "auth",
389
- initialState: initialState$C,
390
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$C)),
389
+ initialState: initialState$B,
390
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
391
391
  reducers: {
392
392
  setTokens: (state, action) => {
393
393
  state.accessToken = action.payload.accessToken;
@@ -857,11 +857,11 @@ function createModelAdapter(computeModelId) {
857
857
  };
858
858
  }
859
859
  const categoryAdapter = createModelAdapter((category) => category.offline_id);
860
- const initialState$B = categoryAdapter.getInitialState({});
860
+ const initialState$A = categoryAdapter.getInitialState({});
861
861
  const categorySlice = createSlice({
862
862
  name: "categories",
863
- initialState: initialState$B,
864
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
863
+ initialState: initialState$A,
864
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$A)),
865
865
  reducers: {
866
866
  initializeCategories: categoryAdapter.initialize,
867
867
  addCategory: categoryAdapter.addOne,
@@ -874,28 +874,131 @@ const selectCategoryMapping = (state) => state.categoryReducer.instances;
874
874
  const selectCategories = createSelector([selectCategoryMapping], (categoryMapping) => {
875
875
  return Object.values(categoryMapping);
876
876
  });
877
- const selectCategoriesOfWorkspace = restructureCreateSelectorWithArgs(
877
+ const selectCategoryById = (id) => (state) => {
878
+ return state.categoryReducer.instances[id];
879
+ };
880
+ const selectCategoriesByIds = restructureCreateSelectorWithArgs(
878
881
  createSelector(
879
- [selectCategories, (_state, workspaceId) => workspaceId],
880
- (categories, workspaceId) => categories.filter((category) => category.workspace === workspaceId)
882
+ [selectCategoryMapping, (_state, categoryIds) => categoryIds],
883
+ (categoryMapping, categoryIds) => {
884
+ const categories = [];
885
+ for (const categoryId of categoryIds) {
886
+ const category = categoryMapping[categoryId];
887
+ if (category) {
888
+ categories.push(category);
889
+ } else {
890
+ console.warn("selectCategoryByIds: No category exists with the id", categoryId);
891
+ }
892
+ }
893
+ return categories;
894
+ }
881
895
  )
882
896
  );
883
- const selectCategoryById = restructureCreateSelectorWithArgs(
897
+ const selectCategoriesOfWorkspace = restructureCreateSelectorWithArgs(
884
898
  createSelector(
885
- [selectCategoryMapping, (_state, categoryId) => categoryId],
886
- (mapping, categoryId) => mapping[categoryId]
899
+ [selectCategories, (_state, workspaceId) => workspaceId],
900
+ (categories, workspaceId) => categories.filter((category) => category.workspace === workspaceId)
887
901
  )
888
902
  );
889
903
  const selectIssueCountOfCategory = (categoryId) => (state) => {
890
904
  return Object.values(state.issueReducer.instances).filter((issue) => issue.category === categoryId).length;
891
905
  };
892
906
  const categoryReducer = categorySlice.reducer;
907
+ const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
908
+ const initialState$z = assetStageAdapter.getInitialState({});
909
+ const assetStageSlice = createSlice({
910
+ name: "assetStages",
911
+ initialState: initialState$z,
912
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
913
+ reducers: {
914
+ initializeStages: assetStageAdapter.initialize,
915
+ setStage: assetStageAdapter.setOne,
916
+ addStages: assetStageAdapter.addMany,
917
+ updateStage: assetStageAdapter.updateOne,
918
+ updateStages: assetStageAdapter.updateMany,
919
+ removeStages: assetStageAdapter.deleteMany
920
+ }
921
+ });
922
+ const selectStageMapping = (state) => state.assetStageReducer.instances;
923
+ const selectAssetStageById = restructureCreateSelectorWithArgs(
924
+ createSelector([selectStageMapping, (_state, stageId) => stageId], (stageMapping, stageId) => {
925
+ return stageMapping[stageId];
926
+ })
927
+ );
928
+ const selectAssetStages = createSelector([selectStageMapping], (stageMapping) => {
929
+ return Object.values(stageMapping);
930
+ });
931
+ const selectStagesFromAssetTypeIds = restructureCreateSelectorWithArgs(
932
+ createSelector([selectAssetStages, (_state, assetTypeIds) => assetTypeIds], (stages, assetTypeIds) => {
933
+ const assetTypeIdsSet = new Set(assetTypeIds);
934
+ const ret = {};
935
+ for (const stage of stages) {
936
+ if (assetTypeIdsSet.has(stage.asset_type)) {
937
+ if (!ret[stage.asset_type]) {
938
+ ret[stage.asset_type] = [];
939
+ }
940
+ ret[stage.asset_type].push(stage);
941
+ }
942
+ }
943
+ for (const key in ret) {
944
+ ret[key] = ret[key].sort((a, b) => a.priority - b.priority);
945
+ }
946
+ return ret;
947
+ })
948
+ );
949
+ const selectAssetTypeStagesMapping = restructureCreateSelectorWithArgs(
950
+ createSelector([selectStageMapping, (_state, assetTypeId) => assetTypeId], (stagesMapping, assetTypeId) => {
951
+ const assetTypeStagesMapping = {};
952
+ for (const [stageId, stage] of Object.entries(stagesMapping)) {
953
+ if (stage.asset_type === assetTypeId) {
954
+ assetTypeStagesMapping[stageId] = stage;
955
+ }
956
+ }
957
+ return assetTypeStagesMapping;
958
+ })
959
+ );
960
+ const selectStagesOfAssetType = restructureCreateSelectorWithArgs(
961
+ createSelector([selectAssetStages, (_state, assetTypeId) => assetTypeId], (stages, assetTypeId) => {
962
+ return stages.filter((stage) => stage.asset_type === assetTypeId).sort((a, b) => a.priority - b.priority);
963
+ })
964
+ );
965
+ const selectAssetStagesByIds = restructureCreateSelectorWithArgs(
966
+ createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
967
+ const assetStages = [];
968
+ for (const stageId of stageIds) {
969
+ const stage = stageMapping[stageId];
970
+ if (stage) {
971
+ assetStages.push(stage);
972
+ } else {
973
+ console.warn("selectStagesFromStageIds: No stage exists with the id", stageId);
974
+ }
975
+ }
976
+ return assetStages;
977
+ })
978
+ );
979
+ const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
980
+ createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
981
+ const ret = {};
982
+ for (const stageId of stageIds) {
983
+ const stage = stageMapping[stageId];
984
+ if (!stage) {
985
+ throw new Error("No stage exists with the id " + stageId);
986
+ }
987
+ if (stage.form) {
988
+ ret[stageId] = stage.form;
989
+ }
990
+ }
991
+ return ret;
992
+ })
993
+ );
994
+ const { initializeStages, setStage, addStages, updateStages, removeStages, updateStage } = assetStageSlice.actions;
995
+ const assetStageReducer = assetStageSlice.reducer;
893
996
  const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
894
- const initialState$A = assetTypeAdapter.getInitialState({});
997
+ const initialState$y = assetTypeAdapter.getInitialState({});
895
998
  const assetTypeSlice = createSlice({
896
999
  name: "assetTypes",
897
- initialState: initialState$A,
898
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$A)),
1000
+ initialState: initialState$y,
1001
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
899
1002
  reducers: {
900
1003
  initializeAssetTypes: assetTypeAdapter.initialize,
901
1004
  addAssetType: assetTypeAdapter.addOne,
@@ -908,43 +1011,33 @@ const selectAssetTypes = createSelector(
908
1011
  [selectAssetTypesMapping],
909
1012
  (mapping) => Object.values(mapping)
910
1013
  );
911
- const selectAssetType = restructureCreateSelectorWithArgs(
912
- createSelector(
913
- [selectAssetTypesMapping, (_state, assetTypeId) => assetTypeId],
914
- (mapping, assetTypeId) => mapping[assetTypeId]
915
- )
916
- );
917
- const selectNumberOfAssetTypesMatchingCaseInsensitiveName = restructureCreateSelectorWithArgs(
1014
+ const selectAssetTypeId = (id) => (state) => {
1015
+ return state.assetTypeReducer.instances[id];
1016
+ };
1017
+ const selectAssetTypesByIds = restructureCreateSelectorWithArgs(
918
1018
  createSelector(
919
- [selectAssetTypesMapping, (_state, args) => args],
920
- (mapping, args) => {
921
- var _a2;
922
- const name = ((_a2 = args.name) == null ? void 0 : _a2.toLowerCase()) ?? null;
923
- return Object.values(mapping).filter(
924
- (assetType) => {
925
- var _a3;
926
- return (((_a3 = assetType.name) == null ? void 0 : _a3.toLowerCase()) ?? null) === name && assetType.offline_id !== args.assetTypeId;
1019
+ [selectStageMapping, (_state, assetTypeIds) => assetTypeIds],
1020
+ (assetTypeMapping, assetTypeIds) => {
1021
+ const assetTypes = [];
1022
+ for (const stageId of assetTypeIds) {
1023
+ const stage = assetTypeMapping[stageId];
1024
+ if (stage) {
1025
+ assetTypes.push(stage);
1026
+ } else {
1027
+ console.warn("selectAssetTypesByIds: No stage exists with the id", stageId);
927
1028
  }
928
- ).length;
1029
+ }
1030
+ return assetTypes;
929
1031
  }
930
1032
  )
931
1033
  );
932
- const selectAssetTypesByName = restructureCreateSelectorWithArgs(
933
- createSelector([selectAssetTypesMapping, (_state, name) => name], (mapping, name) => {
934
- name = (name == null ? void 0 : name.toLowerCase()) ?? null;
935
- return Object.values(mapping).filter((assetType) => {
936
- var _a2;
937
- return (((_a2 = assetType.name) == null ? void 0 : _a2.toLowerCase()) ?? null) === name;
938
- });
939
- })
940
- );
941
1034
  const assetTypeReducer = assetTypeSlice.reducer;
942
1035
  const assetAdapter = createModelAdapter((asset) => asset.offline_id);
943
- const initialState$z = assetAdapter.getInitialState({});
1036
+ const initialState$x = assetAdapter.getInitialState({});
944
1037
  const assetSlice = createSlice({
945
1038
  name: "assets",
946
- initialState: initialState$z,
947
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
1039
+ initialState: initialState$x,
1040
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
948
1041
  reducers: {
949
1042
  initializeAssets: (state, action) => {
950
1043
  assetAdapter.initialize(state, action);
@@ -1008,9 +1101,20 @@ const selectAssetsOfAssetType = restructureCreateSelectorWithArgs(
1008
1101
  return components.filter((asset) => asset.asset_type === assetTypeId);
1009
1102
  })
1010
1103
  );
1011
- const selectAsset = (assetId) => (state) => {
1104
+ const selectAssetById = (assetId) => (state) => {
1012
1105
  return state.assetReducer.instances[assetId];
1013
1106
  };
1107
+ const selectAssetsByIds = restructureCreateSelectorWithArgs(
1108
+ createSelector([selectAssetsMapping, (_, assetIds) => assetIds], (assetsMapping, assetIds) => {
1109
+ const assets = [];
1110
+ for (const assetId of assetIds) {
1111
+ const asset = assetsMapping[assetId];
1112
+ if (asset)
1113
+ assets.push(asset);
1114
+ }
1115
+ return assets;
1116
+ })
1117
+ );
1014
1118
  const selectAssetToAssetTypeMapping = createSelector(
1015
1119
  [selectAssets, selectAssetTypesMapping],
1016
1120
  (assets, assetTypeMapping) => {
@@ -1047,11 +1151,11 @@ const selectAssetTypesFromIds = (assetTypeIds) => (state) => {
1047
1151
  };
1048
1152
  const assetReducer = assetSlice.reducer;
1049
1153
  const assetAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
1050
- const initialState$y = assetAttachmentAdapter.getInitialState({});
1154
+ const initialState$w = assetAttachmentAdapter.getInitialState({});
1051
1155
  const assetAttachmentSlice = createSlice({
1052
1156
  name: "assetAttachments",
1053
- initialState: initialState$y,
1054
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
1157
+ initialState: initialState$w,
1158
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1055
1159
  reducers: {
1056
1160
  initializeAssetAttachments: assetAttachmentAdapter.initialize,
1057
1161
  addAssetAttachment: assetAttachmentAdapter.addOne,
@@ -1109,13 +1213,13 @@ const selectAttachmentsOfAssetByType = restructureCreateSelectorWithArgs(
1109
1213
  )
1110
1214
  );
1111
1215
  const assetAttachmentReducer = assetAttachmentSlice.reducer;
1112
- const initialState$x = {
1216
+ const initialState$v = {
1113
1217
  completionsByAssetId: {}
1114
1218
  };
1115
1219
  const assetStageCompletionSlice = createSlice({
1116
1220
  name: "assetStageCompletions",
1117
- initialState: initialState$x,
1118
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1221
+ initialState: initialState$v,
1222
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1119
1223
  reducers: {
1120
1224
  addStageCompletion: (state, action) => {
1121
1225
  let stageToCompletionDateMapping = state.completionsByAssetId[action.payload.asset];
@@ -1166,97 +1270,14 @@ const selectCompletedStageIdsForAsset = restructureCreateSelectorWithArgs(
1166
1270
  })
1167
1271
  );
1168
1272
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1169
- const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
1170
- const initialState$w = assetStageAdapter.getInitialState({});
1171
- const assetStageSlice = createSlice({
1172
- name: "assetStages",
1173
- initialState: initialState$w,
1174
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1175
- reducers: {
1176
- initializeStages: assetStageAdapter.initialize,
1177
- setStage: assetStageAdapter.setOne,
1178
- addStages: assetStageAdapter.addMany,
1179
- updateStage: assetStageAdapter.updateOne,
1180
- updateStages: assetStageAdapter.updateMany,
1181
- removeStages: assetStageAdapter.deleteMany
1182
- }
1183
- });
1184
- const selectStageMapping = (state) => state.assetStageReducer.instances;
1185
- const selectStage = restructureCreateSelectorWithArgs(
1186
- createSelector([selectStageMapping, (_state, stageId) => stageId], (stageMapping, stageId) => {
1187
- return stageMapping[stageId];
1188
- })
1189
- );
1190
- const selectStages = createSelector(
1191
- [selectStageMapping],
1192
- (stageMapping) => {
1193
- return Object.values(stageMapping);
1194
- }
1195
- );
1196
- const selectStagesFromAssetTypeIds = restructureCreateSelectorWithArgs(
1197
- createSelector([selectStages, (_state, assetTypeIds) => assetTypeIds], (stages, assetTypeIds) => {
1198
- const assetTypeIdsSet = new Set(assetTypeIds);
1199
- const ret = {};
1200
- for (const stage of stages) {
1201
- if (assetTypeIdsSet.has(stage.asset_type)) {
1202
- if (!ret[stage.asset_type]) {
1203
- ret[stage.asset_type] = [];
1204
- }
1205
- ret[stage.asset_type].push(stage);
1206
- }
1207
- }
1208
- for (const key in ret) {
1209
- ret[key] = ret[key].sort((a, b) => a.priority - b.priority);
1210
- }
1211
- return ret;
1212
- })
1213
- );
1214
- const selectAssetTypeStagesMapping = restructureCreateSelectorWithArgs(
1215
- createSelector([selectStageMapping, (_state, assetTypeId) => assetTypeId], (stagesMapping, assetTypeId) => {
1216
- const assetTypeStagesMapping = {};
1217
- for (const [stageId, stage] of Object.entries(stagesMapping)) {
1218
- if (stage.asset_type === assetTypeId) {
1219
- assetTypeStagesMapping[stageId] = stage;
1220
- }
1221
- }
1222
- return assetTypeStagesMapping;
1223
- })
1224
- );
1225
- const selectStagesOfAssetType = restructureCreateSelectorWithArgs(
1226
- createSelector([selectStages, (_state, assetTypeId) => assetTypeId], (stages, assetTypeId) => {
1227
- return stages.filter((stage) => stage.asset_type === assetTypeId).sort((a, b) => a.priority - b.priority);
1228
- })
1229
- );
1230
- const selectStagesFromStageIds = restructureCreateSelectorWithArgs(
1231
- createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
1232
- return stageIds.map((offline_id) => stageMapping[offline_id]).filter((stage) => !!stage);
1233
- })
1234
- );
1235
- const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
1236
- createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
1237
- const ret = {};
1238
- for (const stageId of stageIds) {
1239
- const stage = stageMapping[stageId];
1240
- if (!stage) {
1241
- throw new Error("No stage exists with the id " + stageId);
1242
- }
1243
- if (stage.form) {
1244
- ret[stageId] = stage.form;
1245
- }
1246
- }
1247
- return ret;
1248
- })
1249
- );
1250
- const { initializeStages, setStage, addStages, updateStages, removeStages, updateStage } = assetStageSlice.actions;
1251
- const assetStageReducer = assetStageSlice.reducer;
1252
1273
  const assetTypeAttachmentAdapter = createModelAdapter(
1253
1274
  (attachment) => attachment.offline_id
1254
1275
  );
1255
- const initialState$v = assetTypeAttachmentAdapter.getInitialState({});
1276
+ const initialState$u = assetTypeAttachmentAdapter.getInitialState({});
1256
1277
  const assetTypeAttachmentSlice = createSlice({
1257
1278
  name: "assetTypeAttachments",
1258
- initialState: initialState$v,
1259
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1279
+ initialState: initialState$u,
1280
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1260
1281
  reducers: {
1261
1282
  initializeAssetTypeAttachments: assetTypeAttachmentAdapter.initialize,
1262
1283
  addAssetTypeAttachment: assetTypeAttachmentAdapter.addOne,
@@ -1315,10 +1336,10 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1315
1336
  );
1316
1337
  const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
1317
1338
  const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
1318
- const initialState$u = workspaceAdapter.getInitialState({});
1339
+ const initialState$t = workspaceAdapter.getInitialState({});
1319
1340
  const workspaceSlice = createSlice({
1320
1341
  name: "workspace",
1321
- initialState: initialState$u,
1342
+ initialState: initialState$t,
1322
1343
  reducers: {
1323
1344
  initializeWorkspaces: workspaceAdapter.initialize,
1324
1345
  setWorkspaces: workspaceAdapter.setMany,
@@ -1350,14 +1371,14 @@ const selectPermittedWorkspaceIds = createSelector(
1350
1371
  const workspaceReducer = workspaceSlice.reducer;
1351
1372
  const maxRecentIssues = 10;
1352
1373
  const issueAdapter = createModelAdapter((issue) => issue.offline_id);
1353
- const initialState$t = issueAdapter.getInitialState({
1374
+ const initialState$s = issueAdapter.getInitialState({
1354
1375
  recentIssueIds: []
1355
1376
  });
1356
1377
  const issueSlice = createSlice({
1357
1378
  name: "issues",
1358
- initialState: initialState$t,
1379
+ initialState: initialState$s,
1359
1380
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1360
- Object.assign(state, initialState$t);
1381
+ Object.assign(state, initialState$s);
1361
1382
  }),
1362
1383
  reducers: {
1363
1384
  initializeIssues: issueAdapter.initialize,
@@ -1405,11 +1426,9 @@ const {
1405
1426
  } = issueSlice.actions;
1406
1427
  const selectIssueMapping = (state) => state.issueReducer.instances;
1407
1428
  const selectRecentIssueIds = (state) => state.issueReducer.recentIssueIds;
1408
- const selectIssue = restructureCreateSelectorWithArgs(
1409
- createSelector([selectIssueMapping, (_state, id) => id], (mapping, id) => {
1410
- return mapping[id];
1411
- })
1412
- );
1429
+ const selectIssueById = (id) => (state) => {
1430
+ return state.issueReducer.instances[id];
1431
+ };
1413
1432
  const searchIssues = restructureCreateSelectorWithArgs(
1414
1433
  createSelector(
1415
1434
  [selectIssueMapping, selectWorkspaceMapping, (_state, searchArgs) => searchArgs],
@@ -1465,6 +1484,20 @@ const searchIssues = restructureCreateSelectorWithArgs(
1465
1484
  }
1466
1485
  )
1467
1486
  );
1487
+ const selectIssuesByIds = restructureCreateSelectorWithArgs(
1488
+ createSelector([selectIssueMapping, (_, issueIds) => issueIds], (issuesMapping, issueIds) => {
1489
+ const issues = [];
1490
+ for (const issueId of issueIds) {
1491
+ const issue = issuesMapping[issueId];
1492
+ if (issue) {
1493
+ issues.push(issue);
1494
+ } else {
1495
+ console.warn("selectIssuesByIds: No issue exists with the id", issueId);
1496
+ }
1497
+ }
1498
+ return issues;
1499
+ })
1500
+ );
1468
1501
  const selectRecentIssuesAsSearchResults = createSelector(
1469
1502
  [selectIssueMapping, selectRecentIssueIds, selectWorkspaceMapping],
1470
1503
  (issueMapping, recentIssueIds, workspaceMapping) => {
@@ -1501,12 +1534,12 @@ const selectRecentIssuesAsSearchResults = createSelector(
1501
1534
  );
1502
1535
  const issueReducer = issueSlice.reducer;
1503
1536
  const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
1504
- const initialState$s = issueTypeAdapter.getInitialState({});
1537
+ const initialState$r = issueTypeAdapter.getInitialState({});
1505
1538
  const issueTypeSlice = createSlice({
1506
1539
  name: "issueTypes",
1507
- initialState: initialState$s,
1540
+ initialState: initialState$r,
1508
1541
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1509
- Object.assign(state, initialState$s);
1542
+ Object.assign(state, initialState$r);
1510
1543
  }),
1511
1544
  reducers: {
1512
1545
  initializeIssueTypes: issueTypeAdapter.initialize,
@@ -1526,14 +1559,21 @@ const selectIssueTypes = createSelector(
1526
1559
  return Object.values(issueTypes);
1527
1560
  }
1528
1561
  );
1529
- const selectIssueType = restructureCreateSelectorWithArgs(
1530
- createSelector(
1531
- [selectIssueTypeMapping, (_, issueTypeId) => issueTypeId],
1532
- (issueTypesMapping, issueTypeId) => {
1533
- return issueTypesMapping[issueTypeId];
1562
+ const selectIssueTypeById = (issueTypeId) => (state) => {
1563
+ return state.issueTypeReducer.instances[issueTypeId];
1564
+ };
1565
+ const selectIssueTypesByIds = (issueTypeIds) => (state) => {
1566
+ const issueTypes = [];
1567
+ for (const issueTypeId of issueTypeIds) {
1568
+ const issueType = state.issueTypeReducer.instances[issueTypeId];
1569
+ if (issueType) {
1570
+ issueTypes.push(issueType);
1571
+ } else {
1572
+ console.warn("selectIssueTypesByIds: No issue type exists with the id", issueTypeId);
1534
1573
  }
1535
- )
1536
- );
1574
+ }
1575
+ return issueTypes;
1576
+ };
1537
1577
  const selectIssueTypesOfOrganization = restructureCreateSelectorWithArgs(
1538
1578
  createSelector(
1539
1579
  [selectIssueTypes, (_, organizationId) => organizationId],
@@ -1555,15 +1595,15 @@ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
1555
1595
  return ((_a2 = selectIssuesOfIssueType(issueTypeId)(state)) == null ? void 0 : _a2.length) ?? 0;
1556
1596
  };
1557
1597
  const issueTypeReducer = issueTypeSlice.reducer;
1558
- const initialState$r = {
1598
+ const initialState$q = {
1559
1599
  s3Urls: {}
1560
1600
  };
1561
1601
  const msPerHour = 1e3 * 60 * 60;
1562
1602
  const msPerWeek = msPerHour * 24 * 7;
1563
1603
  const fileSlice = createSlice({
1564
1604
  name: "file",
1565
- initialState: initialState$r,
1566
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1605
+ initialState: initialState$q,
1606
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1567
1607
  reducers: {
1568
1608
  setUploadUrl: (state, action) => {
1569
1609
  const { url, fields, sha1 } = action.payload;
@@ -1644,7 +1684,7 @@ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
1644
1684
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
1645
1685
  return LicenseStatus2;
1646
1686
  })(LicenseStatus || {});
1647
- const initialState$q = {
1687
+ const initialState$p = {
1648
1688
  users: {},
1649
1689
  currentUser: {
1650
1690
  id: 0,
@@ -1655,8 +1695,8 @@ const initialState$q = {
1655
1695
  };
1656
1696
  const userSlice = createSlice({
1657
1697
  name: "users",
1658
- initialState: initialState$q,
1659
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1698
+ initialState: initialState$p,
1699
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1660
1700
  reducers: {
1661
1701
  setUsers: (state, action) => {
1662
1702
  const usersMapping = {};
@@ -1709,23 +1749,40 @@ const {
1709
1749
  setTourStep,
1710
1750
  removeUser
1711
1751
  } = userSlice.actions;
1752
+ const userReducer = userSlice.reducer;
1712
1753
  const selectCurrentUser = (state) => state.userReducer.currentUser;
1754
+ const selectUsersMapping = (state) => state.userReducer.users;
1713
1755
  const selectUser = (userId) => (state) => {
1714
1756
  if (userId === null)
1715
1757
  return void 0;
1716
1758
  return state.userReducer.users[userId];
1717
1759
  };
1718
- const selectUsersAsMapping = (state) => state.userReducer.users;
1760
+ const selectUserById = (userId) => (state) => {
1761
+ return state.userReducer.users[userId];
1762
+ };
1763
+ const selectUsersByIds = restructureCreateSelectorWithArgs(
1764
+ createSelector([selectUsersMapping, (_state, userIds) => userIds], (usersMapping, userIds) => {
1765
+ const users = [];
1766
+ for (const userId of userIds) {
1767
+ const user = usersMapping[userId];
1768
+ if (user) {
1769
+ users.push(user);
1770
+ } else {
1771
+ console.warn("selectUsersByIds: No user exists with the id", userId);
1772
+ }
1773
+ }
1774
+ return users;
1775
+ })
1776
+ );
1719
1777
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
1720
- const userReducer = userSlice.reducer;
1721
1778
  const organizationAccessAdapter = createModelAdapter(
1722
1779
  (organizationAccess) => organizationAccess.offline_id
1723
1780
  );
1724
- const initialState$p = organizationAccessAdapter.getInitialState({});
1781
+ const initialState$o = organizationAccessAdapter.getInitialState({});
1725
1782
  const organizationAccessSlice = createSlice({
1726
1783
  name: "organizationAccess",
1727
- initialState: initialState$p,
1728
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1784
+ initialState: initialState$o,
1785
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1729
1786
  reducers: {
1730
1787
  initializeOrganizationAccesses: organizationAccessAdapter.initialize,
1731
1788
  updateOrganizationAccess: organizationAccessAdapter.updateOne,
@@ -1762,11 +1819,11 @@ const selectOrganizationAccessUserMapping = (state) => {
1762
1819
  };
1763
1820
  const organizationAccessReducer = organizationAccessSlice.reducer;
1764
1821
  const licenseAdapter = createModelAdapter((license) => license.offline_id);
1765
- const initialState$o = licenseAdapter.getInitialState({});
1822
+ const initialState$n = licenseAdapter.getInitialState({});
1766
1823
  const licenseSlice = createSlice({
1767
1824
  name: "license",
1768
- initialState: initialState$o,
1769
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1825
+ initialState: initialState$n,
1826
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1770
1827
  reducers: {
1771
1828
  initializeLicences: licenseAdapter.initialize,
1772
1829
  addLicenses: licenseAdapter.addMany,
@@ -1792,11 +1849,11 @@ const selectLicensesForProjectsMapping = createSelector(
1792
1849
  );
1793
1850
  const licenseReducer = licenseSlice.reducer;
1794
1851
  const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
1795
- const initialState$n = projectAccessAdapter.getInitialState({});
1852
+ const initialState$m = projectAccessAdapter.getInitialState({});
1796
1853
  const projectAccessSlice = createSlice({
1797
1854
  name: "projectAccess",
1798
- initialState: initialState$n,
1799
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1855
+ initialState: initialState$m,
1856
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1800
1857
  reducers: {
1801
1858
  initializeProjectAccesses: projectAccessAdapter.initialize,
1802
1859
  updateProjectAccess: projectAccessAdapter.updateOne,
@@ -1814,14 +1871,9 @@ const selectProjectAccesses = createSelector(
1814
1871
  return Object.values(projectAccesses);
1815
1872
  }
1816
1873
  );
1817
- const selectProjectAccess = restructureCreateSelectorWithArgs(
1818
- createSelector(
1819
- [selectProjectAccessMapping, (_state, projectAccessId) => projectAccessId],
1820
- (projectAccesses, projectAccessId) => {
1821
- return projectAccesses[projectAccessId];
1822
- }
1823
- )
1824
- );
1874
+ const selectProjectAccessById = (projectAccessId) => (state) => {
1875
+ return state.projectAccessReducer.instances[projectAccessId];
1876
+ };
1825
1877
  const selectActiveProjectAccess = (state) => {
1826
1878
  const currentUser = state.userReducer.currentUser;
1827
1879
  const activeProjectId = state.projectReducer.activeProjectId;
@@ -1842,14 +1894,14 @@ const selectProjectAccessUserMapping = (state) => {
1842
1894
  return projectAccesses;
1843
1895
  };
1844
1896
  const projectAccessReducer = projectAccessSlice.reducer;
1845
- const initialState$m = {
1897
+ const initialState$l = {
1846
1898
  projects: {},
1847
1899
  activeProjectId: null
1848
1900
  };
1849
1901
  const projectSlice = createSlice({
1850
1902
  name: "projects",
1851
- initialState: initialState$m,
1852
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1903
+ initialState: initialState$l,
1904
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1853
1905
  reducers: {
1854
1906
  setProjects: (state, action) => {
1855
1907
  const projectsMap = {};
@@ -1914,6 +1966,7 @@ const {
1914
1966
  addActiveProjectIssuesCount,
1915
1967
  addActiveProjectFormSubmissionsCount
1916
1968
  } = projectSlice.actions;
1969
+ const projectReducer = projectSlice.reducer;
1917
1970
  const selectProjects = (state) => state.projectReducer.projects;
1918
1971
  const selectActiveProjectId = (state) => state.projectReducer.activeProjectId;
1919
1972
  const selectActiveProject = (state) => {
@@ -1923,19 +1976,15 @@ const selectActiveProject = (state) => {
1923
1976
  }
1924
1977
  return state.projectReducer.projects[activeProjectId] ?? null;
1925
1978
  };
1926
- const selectProject = restructureCreateSelectorWithArgs(
1927
- createSelector(
1928
- [selectProjects, (_state, projectId) => projectId],
1929
- (projects, projectId) => projects[projectId]
1930
- )
1931
- );
1932
- const projectReducer = projectSlice.reducer;
1979
+ const selectProjectById = (projectId) => (state) => {
1980
+ return state.projectReducer.projects[projectId];
1981
+ };
1933
1982
  const selectProjectUsersIds = createSelector(
1934
1983
  [selectProjectAccessMapping],
1935
1984
  (projectAccesses) => Object.values(projectAccesses).map((projectAccess) => projectAccess.user)
1936
1985
  );
1937
1986
  const selectProjectUsersAsMapping = createSelector(
1938
- [selectProjectUsersIds, selectUsersAsMapping],
1987
+ [selectProjectUsersIds, selectUsersMapping],
1939
1988
  (projectUserIds, users) => projectUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
1940
1989
  );
1941
1990
  const selectProjectsWithAccess = createSelector(
@@ -1963,13 +2012,13 @@ const selectSortedProjectUsers = createSelector(
1963
2012
  });
1964
2013
  }
1965
2014
  );
1966
- const initialState$l = {
2015
+ const initialState$k = {
1967
2016
  organizations: {}
1968
2017
  };
1969
2018
  const organizationSlice = createSlice({
1970
2019
  name: "organizations",
1971
- initialState: initialState$l,
1972
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
2020
+ initialState: initialState$k,
2021
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1973
2022
  reducers: {
1974
2023
  setOrganizations: (state, action) => {
1975
2024
  for (const org of action.payload) {
@@ -2007,7 +2056,7 @@ const selectLicensesOfOrganization = restructureCreateSelectorWithArgs(
2007
2056
  })
2008
2057
  );
2009
2058
  const selectOrganizationUsersAsMapping = createSelector(
2010
- [selectOrganizationUsersIds, selectUsersAsMapping],
2059
+ [selectOrganizationUsersIds, selectUsersMapping],
2011
2060
  (organizationUserIds, users) => organizationUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
2012
2061
  );
2013
2062
  const selectSortedOrganizationUsers = createSelector(
@@ -2052,14 +2101,14 @@ const createOfflineAction = (request2, baseUrl, serviceName) => {
2052
2101
  }
2053
2102
  };
2054
2103
  };
2055
- const initialState$k = {
2104
+ const initialState$j = {
2056
2105
  deletedRequests: [],
2057
2106
  latestRetryTime: 0
2058
2107
  };
2059
2108
  const outboxSlice = createSlice({
2060
2109
  name: "outbox",
2061
- initialState: initialState$k,
2062
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
2110
+ initialState: initialState$j,
2111
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2063
2112
  reducers: {
2064
2113
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2065
2114
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -2091,15 +2140,15 @@ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2091
2140
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2092
2141
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2093
2142
  const outboxReducer = outboxSlice.reducer;
2094
- const initialState$j = {
2143
+ const initialState$i = {
2095
2144
  projectFiles: {},
2096
2145
  activeProjectFileId: null,
2097
2146
  isImportingProjectFile: false
2098
2147
  };
2099
2148
  const projectFileSlice = createSlice({
2100
2149
  name: "projectFiles",
2101
- initialState: initialState$j,
2102
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2150
+ initialState: initialState$i,
2151
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2103
2152
  reducers: {
2104
2153
  addOrReplaceProjectFiles: (state, action) => {
2105
2154
  for (let fileObj of action.payload) {
@@ -2184,11 +2233,11 @@ const selectProjectFileById = (id) => (state) => {
2184
2233
  };
2185
2234
  const projectFileReducer = projectFileSlice.reducer;
2186
2235
  const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2187
- const initialState$i = projectAttachmentAdapter.getInitialState({});
2236
+ const initialState$h = projectAttachmentAdapter.getInitialState({});
2188
2237
  const projectAttachmentSlice = createSlice({
2189
2238
  name: "projectAttachments",
2190
- initialState: initialState$i,
2191
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2239
+ initialState: initialState$h,
2240
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2192
2241
  reducers: {
2193
2242
  initializeProjectAttachments: projectAttachmentAdapter.initialize,
2194
2243
  addProjectAttachment: projectAttachmentAdapter.addOne,
@@ -2246,12 +2295,12 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
2246
2295
  )
2247
2296
  );
2248
2297
  const projectAttachmentReducer = projectAttachmentSlice.reducer;
2249
- const initialState$h = {
2298
+ const initialState$g = {
2250
2299
  isRehydrated: false
2251
2300
  };
2252
2301
  const rehydratedSlice = createSlice({
2253
2302
  name: "rehydrated",
2254
- initialState: initialState$h,
2303
+ initialState: initialState$g,
2255
2304
  // The `reducers` field lets us define reducers and generate associated actions
2256
2305
  reducers: {
2257
2306
  setRehydrated: (state, action) => {
@@ -2262,22 +2311,6 @@ const rehydratedSlice = createSlice({
2262
2311
  const { setRehydrated } = rehydratedSlice.actions;
2263
2312
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
2264
2313
  const rehydratedReducer = rehydratedSlice.reducer;
2265
- const initialState$g = {
2266
- isFetchingInitialData: false
2267
- };
2268
- const settingSlice = createSlice({
2269
- name: "settings",
2270
- initialState: initialState$g,
2271
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2272
- reducers: {
2273
- setIsFetchingInitialData: (state, action) => {
2274
- state.isFetchingInitialData = action.payload;
2275
- }
2276
- }
2277
- });
2278
- const { setIsFetchingInitialData } = settingSlice.actions;
2279
- const settingReducer = settingSlice.reducer;
2280
- const selectIsFetchingInitialData = (state) => state.settingReducer.isFetchingInitialData;
2281
2314
  const formRevisionSortFn = (formRevisionA, formRevisionB) => {
2282
2315
  const revisionA = formRevisionA.revision;
2283
2316
  const revisionB = formRevisionB.revision;
@@ -2319,7 +2352,7 @@ const selectFormRevisions = createSelector(
2319
2352
  [selectFormRevisionMapping],
2320
2353
  (formRevisions) => Object.values(formRevisions)
2321
2354
  );
2322
- const selectFormRevision = (formRevisionId) => (state) => {
2355
+ const selectFormRevisionId = (formRevisionId) => (state) => {
2323
2356
  return state.formRevisionReducer.instances[formRevisionId];
2324
2357
  };
2325
2358
  const _selectLatestFormRevision = (formRevisions, formId) => {
@@ -2450,12 +2483,12 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
2450
2483
  { memoizeOptions: { equalityCheck: shallowEqual } }
2451
2484
  )
2452
2485
  );
2453
- const selectForm = (formId) => (state) => {
2454
- return state.formReducer.instances[formId];
2455
- };
2456
2486
  const selectFormMapping = (state) => {
2457
2487
  return state.formReducer.instances;
2458
2488
  };
2489
+ const selectFormById = (formId) => (state) => {
2490
+ return state.formReducer.instances[formId];
2491
+ };
2459
2492
  const selectFormOfAssetType = restructureCreateSelectorWithArgs(
2460
2493
  createSelector(
2461
2494
  [selectFormMapping, (_state, assetTypeId) => assetTypeId],
@@ -2517,7 +2550,7 @@ const selectFormSubmissions = createSelector(
2517
2550
  return Object.values(submissions);
2518
2551
  }
2519
2552
  );
2520
- const selectFormSubmission = (submissionId) => (state) => {
2553
+ const selectFormSubmissionById = (submissionId) => (state) => {
2521
2554
  return state.formSubmissionReducer.instances[submissionId];
2522
2555
  };
2523
2556
  const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
@@ -2723,6 +2756,15 @@ const {
2723
2756
  const selectFormSubmissionAttachmentsMapping = (state) => {
2724
2757
  return state.formSubmissionAttachmentReducer.instances;
2725
2758
  };
2759
+ const selectFormSubmissionAttachemntsByIds = restructureCreateSelectorWithArgs(
2760
+ createSelector(
2761
+ [selectFormSubmissionAttachmentsMapping, (_, attachmentIds) => attachmentIds],
2762
+ (mapping, attachmentIds) => {
2763
+ const attachmentIdsSet = new Set(attachmentIds);
2764
+ return Object.values(mapping).filter((attachment) => attachmentIdsSet.has(attachment.offline_id));
2765
+ }
2766
+ )
2767
+ );
2726
2768
  const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
2727
2769
  createSelector(
2728
2770
  [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
@@ -2954,10 +2996,24 @@ const selectDocuments = createSelector(
2954
2996
  [selectDocumentsMapping],
2955
2997
  (mapping) => Object.values(mapping)
2956
2998
  );
2957
- const selectDocument = restructureCreateSelectorWithArgs(
2999
+ const selectDocumentById = (documentId) => (state) => {
3000
+ return state.documentsReducer.documents[documentId];
3001
+ };
3002
+ const selectDocumentsByIds = restructureCreateSelectorWithArgs(
2958
3003
  createSelector(
2959
- [selectDocumentsMapping, (_state, documentId) => documentId],
2960
- (mapping, documentId) => mapping[documentId]
3004
+ [selectDocumentsMapping, (_state, documentIds) => documentIds],
3005
+ (mapping, documentIds) => {
3006
+ const documents = [];
3007
+ for (const documentId of documentIds) {
3008
+ const document2 = mapping[documentId];
3009
+ if (document2) {
3010
+ documents.push(document2);
3011
+ } else {
3012
+ console.warn("selectDocumentByIds: No document exists with the id", documentId);
3013
+ }
3014
+ }
3015
+ return documents;
3016
+ }
2961
3017
  )
2962
3018
  );
2963
3019
  const selectAncestorIdsOfDocument = restructureCreateSelectorWithArgs(
@@ -3061,7 +3117,7 @@ const selectTeamsMapping = (state) => state.teamReducer.instances;
3061
3117
  const selectTeams = createSelector([selectTeamsMapping], (teams) => {
3062
3118
  return Object.values(teams);
3063
3119
  });
3064
- const selectTeam = (teamId) => (state) => {
3120
+ const selectTeamById = (teamId) => (state) => {
3065
3121
  return state.teamReducer.instances[teamId];
3066
3122
  };
3067
3123
  const selectTeamsOfOrganization = restructureCreateSelectorWithArgs(
@@ -3318,6 +3374,9 @@ const {
3318
3374
  deleteIssueAssociations
3319
3375
  } = issueAssociationSlice.actions;
3320
3376
  const selectIssueAssociationMapping = (state) => state.issueAssociationReducer.instances;
3377
+ const selectIssueAssociations = createSelector([selectIssueAssociationMapping], (associations) => {
3378
+ return Object.values(associations);
3379
+ });
3321
3380
  const selectIssueAssociationById = (id) => (state) => {
3322
3381
  return state.issueAssociationReducer.instances[id];
3323
3382
  };
@@ -3402,7 +3461,6 @@ const overmapReducers = {
3402
3461
  organizationAccessReducer,
3403
3462
  projectFileReducer,
3404
3463
  rehydratedReducer,
3405
- settingReducer,
3406
3464
  formReducer,
3407
3465
  formRevisionReducer,
3408
3466
  formRevisionAttachmentReducer,
@@ -4211,7 +4269,7 @@ class AssetService extends BaseApiService {
4211
4269
  async remove(assetId) {
4212
4270
  const { store } = this.client;
4213
4271
  const state = store.getState();
4214
- const assetToBeDeleted = selectAsset(assetId)(state);
4272
+ const assetToBeDeleted = selectAssetById(assetId)(state);
4215
4273
  if (!assetToBeDeleted)
4216
4274
  throw new Error(`No asset with id ${assetId} found in the store`);
4217
4275
  const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(state);
@@ -4327,7 +4385,7 @@ class AssetStageCompletionService extends BaseApiService {
4327
4385
  add(assetId, stageId) {
4328
4386
  var _a2;
4329
4387
  const { store } = this.client;
4330
- const assetTypeId = (_a2 = selectAsset(assetId)(store.getState())) == null ? void 0 : _a2.asset_type;
4388
+ const assetTypeId = (_a2 = selectAssetById(assetId)(store.getState())) == null ? void 0 : _a2.asset_type;
4331
4389
  if (!assetTypeId) {
4332
4390
  throw new Error(`Asset with offline_id ${assetId} not found`);
4333
4391
  }
@@ -4433,12 +4491,7 @@ class AssetStageService extends BaseApiService {
4433
4491
  async bulkUpdateStages(stagesToUpdate, assetTypeId) {
4434
4492
  const store = this.client.store;
4435
4493
  const state = store.getState();
4436
- const prevStages = selectStagesFromStageIds(
4437
- stagesToUpdate.map(({ offline_id }) => offline_id)
4438
- )(state);
4439
- if (!prevStages) {
4440
- throw new Error("Could not find the desired stages to update within the store");
4441
- }
4494
+ const prevStages = selectAssetStagesByIds(stagesToUpdate.map(({ offline_id }) => offline_id))(state);
4442
4495
  this.dispatch(updateStages(stagesToUpdate));
4443
4496
  return this.enqueueRequest({
4444
4497
  description: "Edit asset stages",
@@ -4688,7 +4741,7 @@ class BaseAttachmentService extends BaseUploadService {
4688
4741
  }
4689
4742
  // Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
4690
4743
  // so for some attachment model services, this method will have to be overridden.
4691
- async refreshStore(projectId) {
4744
+ async refreshStore(projectId, _organizationId) {
4692
4745
  const meta = AttachmentModelMeta[this.attachmentModel];
4693
4746
  const result = await this.enqueueRequest({
4694
4747
  description: `Get ${meta.name} attachments`,
@@ -4761,7 +4814,7 @@ class AssetTypeService extends BaseApiService {
4761
4814
  async delete(assetTypeId) {
4762
4815
  const { store } = this.client;
4763
4816
  const state = store.getState();
4764
- const assetType = selectAssetType(assetTypeId)(state);
4817
+ const assetType = selectAssetTypeId(assetTypeId)(state);
4765
4818
  if (!assetType) {
4766
4819
  throw new Error(`Expected asset type with offline_id ${assetTypeId} to exist`);
4767
4820
  }
@@ -5015,7 +5068,7 @@ class IssueService extends BaseApiService {
5015
5068
  }
5016
5069
  update(issue) {
5017
5070
  const state = this.client.store.getState();
5018
- const issueToBeUpdated = selectIssue(issue.offline_id)(state);
5071
+ const issueToBeUpdated = selectIssueById(issue.offline_id)(state);
5019
5072
  if (!issueToBeUpdated) {
5020
5073
  throw new Error(
5021
5074
  `Attempting to update an issue with offline_id ${issue.offline_id} that doesn't exist in the store`
@@ -5109,7 +5162,7 @@ class IssueService extends BaseApiService {
5109
5162
  async remove(id) {
5110
5163
  const { store } = this.client;
5111
5164
  const state = store.getState();
5112
- const backup = selectIssue(id)(state);
5165
+ const backup = selectIssueById(id)(state);
5113
5166
  if (!backup) {
5114
5167
  throw new Error(`No issue with id ${id} found in the store`);
5115
5168
  }
@@ -5190,7 +5243,7 @@ class IssueTypeService extends BaseApiService {
5190
5243
  offline_id: offlineIssueType.offline_id,
5191
5244
  submitted_at: offlineIssueType.submitted_at,
5192
5245
  icon: offlineIssueType.icon,
5193
- icon_color: offlineIssueType.color,
5246
+ color: offlineIssueType.color,
5194
5247
  name: offlineIssueType.name,
5195
5248
  description: offlineIssueType.description
5196
5249
  },
@@ -5204,24 +5257,24 @@ class IssueTypeService extends BaseApiService {
5204
5257
  });
5205
5258
  return [offlineIssueType, promise];
5206
5259
  }
5207
- update(issueTypeFields) {
5260
+ update(payload) {
5208
5261
  const { store } = this.client;
5209
5262
  const state = store.getState();
5210
- const issueTypeToBeUpdated = selectIssueType(issueTypeFields.offline_id)(state);
5263
+ const issueTypeToBeUpdated = selectIssueTypeById(payload.offline_id)(state);
5211
5264
  if (!issueTypeToBeUpdated) {
5212
- throw new Error(`IssueType with offline_id ${issueTypeFields.offline_id} does not exist in the store.`);
5265
+ throw new Error(`IssueType with offline_id ${payload.offline_id} does not exist in the store.`);
5213
5266
  }
5214
5267
  const offlineUpdatedIssueType = {
5215
5268
  ...issueTypeToBeUpdated,
5216
- ...issueTypeFields
5269
+ ...payload
5217
5270
  };
5218
5271
  this.dispatch(updateIssueType(offlineUpdatedIssueType));
5219
5272
  const promise = this.enqueueRequest({
5220
5273
  method: HttpMethod.PATCH,
5221
- url: `/issues/types/${issueTypeFields.offline_id}/`,
5222
- payload: issueTypeFields,
5223
- blockers: [issueTypeFields.offline_id],
5224
- blocks: [issueTypeFields.offline_id]
5274
+ url: `/issues/types/${payload.offline_id}/`,
5275
+ payload,
5276
+ blockers: [payload.offline_id],
5277
+ blocks: [payload.offline_id]
5225
5278
  });
5226
5279
  promise.then((updatedIssueType) => {
5227
5280
  this.dispatch(setIssueType(updatedIssueType));
@@ -5233,7 +5286,7 @@ class IssueTypeService extends BaseApiService {
5233
5286
  delete(issueTypeId) {
5234
5287
  const { store } = this.client;
5235
5288
  const state = store.getState();
5236
- const issueTypeToDelete = selectIssueType(issueTypeId)(state);
5289
+ const issueTypeToDelete = selectIssueTypeById(issueTypeId)(state);
5237
5290
  if (!issueTypeToDelete) {
5238
5291
  throw new Error(`IssueType with offline_id ${issueTypeId} does not exist in the store.`);
5239
5292
  }
@@ -5824,7 +5877,7 @@ class FormService extends BaseUploadService {
5824
5877
  async delete(formId) {
5825
5878
  const { store } = this.client;
5826
5879
  const state = store.getState();
5827
- const form = selectForm(formId)(state);
5880
+ const form = selectFormById(formId)(state);
5828
5881
  if (!form) {
5829
5882
  throw new Error("Expected form to exist");
5830
5883
  }
@@ -6001,6 +6054,25 @@ class FormSubmissionService extends BaseUploadService {
6001
6054
  });
6002
6055
  return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
6003
6056
  }
6057
+ async bulkDeleteSubmissionAttachments(submissionId, attachmentsIds) {
6058
+ const { store } = this.client;
6059
+ const state = store.getState();
6060
+ const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
6061
+ this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
6062
+ try {
6063
+ await this.enqueueRequest({
6064
+ description: "Delete form submission attachments",
6065
+ method: HttpMethod.DELETE,
6066
+ url: `/forms/submissions/${submissionId}/attachments/bulk/`,
6067
+ payload: { attachments: attachmentsIds },
6068
+ blockers: [submissionId, ...attachmentsIds],
6069
+ blocks: []
6070
+ });
6071
+ } catch (e) {
6072
+ this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
6073
+ throw e;
6074
+ }
6075
+ }
6004
6076
  // Outer promise is for hashing and caching files for submission attachments
6005
6077
  async add(payload) {
6006
6078
  const { store } = this.client;
@@ -6140,10 +6212,64 @@ class FormSubmissionService extends BaseUploadService {
6140
6212
  });
6141
6213
  return batchPromises;
6142
6214
  }
6215
+ async update(payload) {
6216
+ const { store } = this.client;
6217
+ const state = store.getState();
6218
+ const submissionToBeUpdated = selectFormSubmissionById(payload.offline_id)(state);
6219
+ if (!submissionToBeUpdated) {
6220
+ throw new Error(`Expected submission with offline_id ${payload.offline_id} to exist`);
6221
+ }
6222
+ const { values, files } = separateFilesFromValues(payload.values ?? {});
6223
+ const updatedSubmission = {
6224
+ ...submissionToBeUpdated,
6225
+ ...payload,
6226
+ // values could also have a partial update
6227
+ values: {
6228
+ ...submissionToBeUpdated.values,
6229
+ ...values
6230
+ }
6231
+ };
6232
+ this.dispatch(updateFormSubmission(updatedSubmission));
6233
+ const promise = this.enqueueRequest({
6234
+ description: "Delete user form submissions",
6235
+ method: HttpMethod.PATCH,
6236
+ url: `/forms/submissions/${updatedSubmission.offline_id}/`,
6237
+ payload: updatedSubmission,
6238
+ blockers: [updatedSubmission.offline_id],
6239
+ blocks: [updatedSubmission.offline_id]
6240
+ });
6241
+ const formSubmissionAttachments = selectAttachmentsOfFormSubmission(payload.offline_id)(state);
6242
+ const formSubmissionAttachmentIdsToBeDeleted = [];
6243
+ for (const attachment of formSubmissionAttachments) {
6244
+ if (attachment.field_identifier in files) {
6245
+ formSubmissionAttachmentIdsToBeDeleted.push(attachment.offline_id);
6246
+ }
6247
+ }
6248
+ const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
6249
+ payload.offline_id,
6250
+ files
6251
+ );
6252
+ const deleteAttachmentsPromise = this.bulkDeleteSubmissionAttachments(
6253
+ payload.offline_id,
6254
+ formSubmissionAttachmentIdsToBeDeleted
6255
+ );
6256
+ promise.then((result) => {
6257
+ this.dispatch(setFormSubmission(result));
6258
+ }).catch(() => {
6259
+ this.dispatch(setFormSubmission(submissionToBeUpdated));
6260
+ });
6261
+ return [
6262
+ updatedSubmission,
6263
+ offlineFormSubmissionAttachments,
6264
+ promise,
6265
+ attachmentsPromise,
6266
+ deleteAttachmentsPromise
6267
+ ];
6268
+ }
6143
6269
  async delete(submissionId) {
6144
6270
  const { store } = this.client;
6145
6271
  const state = store.getState();
6146
- const submissionToBeDeleted = selectFormSubmission(submissionId)(store.getState());
6272
+ const submissionToBeDeleted = selectFormSubmissionById(submissionId)(state);
6147
6273
  if (!submissionToBeDeleted) {
6148
6274
  throw new Error(`Expected submission with offline_id ${submissionId} to exist`);
6149
6275
  }
@@ -6900,6 +7026,24 @@ class DocumentAttachmentService extends BaseAttachmentService {
6900
7026
  async deleteDocumentAttachment(attachmentId) {
6901
7027
  return this.deleteAttachment(attachmentId);
6902
7028
  }
7029
+ async refreshStore(projectId, organizationId) {
7030
+ const projectDocumentAttachments = await this.enqueueRequest({
7031
+ description: "Get document attachments",
7032
+ method: HttpMethod.GET,
7033
+ url: `/projects/${projectId}/document-attachments/`,
7034
+ blocks: [],
7035
+ blockers: []
7036
+ });
7037
+ this.dispatch(this.initializeAttachments(projectDocumentAttachments));
7038
+ const organizationDocumentAttachments = await this.enqueueRequest({
7039
+ description: "Get document attachments",
7040
+ method: HttpMethod.GET,
7041
+ url: `/organizations/${organizationId}/document-attachments/`,
7042
+ blocks: [],
7043
+ blockers: []
7044
+ });
7045
+ this.dispatch(this.addAttachments(organizationDocumentAttachments));
7046
+ }
6903
7047
  }
6904
7048
  class AgentService extends BaseApiService {
6905
7049
  async startConversation(prompt) {
@@ -7015,7 +7159,7 @@ class TeamService extends BaseApiService {
7015
7159
  // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
7016
7160
  update(team) {
7017
7161
  const { store } = this.client;
7018
- const teamToBeUpdated = selectTeam(team.offline_id)(store.getState());
7162
+ const teamToBeUpdated = selectTeamById(team.offline_id)(store.getState());
7019
7163
  if (!teamToBeUpdated) {
7020
7164
  throw new Error(`Expected team with offline_id ${team.offline_id} to exist`);
7021
7165
  }
@@ -7042,7 +7186,7 @@ class TeamService extends BaseApiService {
7042
7186
  async delete(teamId) {
7043
7187
  const { store } = this.client;
7044
7188
  const state = store.getState();
7045
- const team = selectTeam(teamId)(state);
7189
+ const team = selectTeamById(teamId)(state);
7046
7190
  if (!team) {
7047
7191
  throw new Error(`Expected team with id ${teamId} to exist`);
7048
7192
  }
@@ -7062,7 +7206,7 @@ class TeamService extends BaseApiService {
7062
7206
  }
7063
7207
  async setMembers(teamId, members) {
7064
7208
  const { store } = this.client;
7065
- const team = selectTeam(teamId)(store.getState());
7209
+ const team = selectTeamById(teamId)(store.getState());
7066
7210
  if (!team) {
7067
7211
  throw new Error(`Expected team with id ${teamId} to exist`);
7068
7212
  }
@@ -7087,7 +7231,7 @@ class TeamService extends BaseApiService {
7087
7231
  }
7088
7232
  async addMembers(teamId, members) {
7089
7233
  const { store } = this.client;
7090
- const team = selectTeam(teamId)(store.getState());
7234
+ const team = selectTeamById(teamId)(store.getState());
7091
7235
  if (!team) {
7092
7236
  throw new Error(`Expected team with id ${teamId} to exist`);
7093
7237
  }
@@ -7096,7 +7240,7 @@ class TeamService extends BaseApiService {
7096
7240
  }
7097
7241
  async removeMembers(teamId, members) {
7098
7242
  const { store } = this.client;
7099
- const team = selectTeam(teamId)(store.getState());
7243
+ const team = selectTeamById(teamId)(store.getState());
7100
7244
  if (!team) {
7101
7245
  throw new Error(`Expected team with id ${teamId} to exist`);
7102
7246
  }
@@ -7709,21 +7853,25 @@ export {
7709
7853
  selectAllDocumentAttachments,
7710
7854
  selectAllProjectAttachments,
7711
7855
  selectAncestorIdsOfDocument,
7712
- selectAsset,
7713
7856
  selectAssetAttachment,
7714
7857
  selectAssetAttachmentMapping,
7715
7858
  selectAssetAttachments,
7859
+ selectAssetById,
7860
+ selectAssetStageById,
7861
+ selectAssetStages,
7862
+ selectAssetStagesByIds,
7716
7863
  selectAssetToAssetTypeMapping,
7717
- selectAssetType,
7718
7864
  selectAssetTypeAttachment,
7719
7865
  selectAssetTypeAttachmentMapping,
7720
7866
  selectAssetTypeAttachments,
7867
+ selectAssetTypeId,
7721
7868
  selectAssetTypeStagesMapping,
7722
7869
  selectAssetTypes,
7723
- selectAssetTypesByName,
7870
+ selectAssetTypesByIds,
7724
7871
  selectAssetTypesFromIds,
7725
7872
  selectAssetTypesMapping,
7726
7873
  selectAssets,
7874
+ selectAssetsByIds,
7727
7875
  selectAssetsMapping,
7728
7876
  selectAssetsOfAssetType,
7729
7877
  selectAttachedFormSubmissionsOfAsset,
@@ -7741,6 +7889,7 @@ export {
7741
7889
  selectAttachmentsOfProject,
7742
7890
  selectAttachmentsOfProjectByType,
7743
7891
  selectCategories,
7892
+ selectCategoriesByIds,
7744
7893
  selectCategoriesOfWorkspace,
7745
7894
  selectCategoryById,
7746
7895
  selectCategoryMapping,
@@ -7752,27 +7901,29 @@ export {
7752
7901
  selectConversations,
7753
7902
  selectCurrentUser,
7754
7903
  selectDeletedRequests,
7755
- selectDocument,
7756
7904
  selectDocumentAttachment,
7757
7905
  selectDocumentAttachmentMapping,
7906
+ selectDocumentById,
7758
7907
  selectDocuments,
7908
+ selectDocumentsByIds,
7759
7909
  selectDocumentsMapping,
7760
7910
  selectEmailDomains,
7761
7911
  selectEmailDomainsAsMapping,
7762
7912
  selectEmailDomainsOfOrganization,
7763
7913
  selectFavouriteProjects,
7764
7914
  selectFilteredForms,
7765
- selectForm,
7915
+ selectFormById,
7766
7916
  selectFormMapping,
7767
7917
  selectFormOfAssetType,
7768
7918
  selectFormOfIssueType,
7769
- selectFormRevision,
7770
7919
  selectFormRevisionAttachmentsMapping,
7920
+ selectFormRevisionId,
7771
7921
  selectFormRevisionMapping,
7772
7922
  selectFormRevisions,
7773
7923
  selectFormRevisionsOfForm,
7774
- selectFormSubmission,
7924
+ selectFormSubmissionAttachemntsByIds,
7775
7925
  selectFormSubmissionAttachmentsMapping,
7926
+ selectFormSubmissionById,
7776
7927
  selectFormSubmissions,
7777
7928
  selectFormSubmissionsByAssets,
7778
7929
  selectFormSubmissionsByFormRevisions,
@@ -7788,27 +7939,29 @@ export {
7788
7939
  selectGeoImageMapping,
7789
7940
  selectGeoImages,
7790
7941
  selectGeoImagesOfProject,
7791
- selectIsFetchingInitialData,
7792
7942
  selectIsImportingProjectFile,
7793
7943
  selectIsLoggedIn,
7794
- selectIssue,
7795
7944
  selectIssueAssociationById,
7796
7945
  selectIssueAssociationMapping,
7946
+ selectIssueAssociations,
7797
7947
  selectIssueAssociationsOfAsset,
7798
7948
  selectIssueAssociationsOfIssue,
7799
7949
  selectIssueAssociationsToIssue,
7800
7950
  selectIssueAttachment,
7801
7951
  selectIssueAttachmentMapping,
7802
7952
  selectIssueAttachments,
7953
+ selectIssueById,
7803
7954
  selectIssueCommentMapping,
7804
7955
  selectIssueCountOfCategory,
7805
7956
  selectIssueMapping,
7806
- selectIssueType,
7957
+ selectIssueTypeById,
7807
7958
  selectIssueTypeMapping,
7808
7959
  selectIssueTypes,
7960
+ selectIssueTypesByIds,
7809
7961
  selectIssueTypesOfOrganization,
7810
7962
  selectIssueUpdateMapping,
7811
7963
  selectIssueUpdatesOfIssue,
7964
+ selectIssuesByIds,
7812
7965
  selectIssuesOfIssueType,
7813
7966
  selectIssuesOfIssueTypeCount,
7814
7967
  selectLatestFormRevisionByForm,
@@ -7821,7 +7974,6 @@ export {
7821
7974
  selectLicensesForProjectsMapping,
7822
7975
  selectLicensesOfOrganization,
7823
7976
  selectMainWorkspace,
7824
- selectNumberOfAssetTypesMatchingCaseInsensitiveName,
7825
7977
  selectNumberOfAssetsOfAssetType,
7826
7978
  selectOrganization,
7827
7979
  selectOrganizationAccess,
@@ -7835,14 +7987,14 @@ export {
7835
7987
  selectOrganizationsMapping,
7836
7988
  selectOrganizationsWithAccess,
7837
7989
  selectPermittedWorkspaceIds,
7838
- selectProject,
7839
- selectProjectAccess,
7990
+ selectProjectAccessById,
7840
7991
  selectProjectAccessForUser,
7841
7992
  selectProjectAccessMapping,
7842
7993
  selectProjectAccessUserMapping,
7843
7994
  selectProjectAccesses,
7844
7995
  selectProjectAttachment,
7845
7996
  selectProjectAttachmentMapping,
7997
+ selectProjectById,
7846
7998
  selectProjectFileById,
7847
7999
  selectProjectFileMapping,
7848
8000
  selectProjectFiles,
@@ -7858,21 +8010,20 @@ export {
7858
8010
  selectSortedFormSubmissionsOfForm,
7859
8011
  selectSortedOrganizationUsers,
7860
8012
  selectSortedProjectUsers,
7861
- selectStage,
7862
8013
  selectStageFormIdsFromStageIds,
7863
8014
  selectStageMapping,
7864
- selectStages,
7865
8015
  selectStagesFromAssetTypeIds,
7866
- selectStagesFromStageIds,
7867
8016
  selectStagesOfAssetType,
7868
- selectTeam,
8017
+ selectTeamById,
7869
8018
  selectTeams,
7870
8019
  selectTeamsMapping,
7871
8020
  selectTeamsOfOrganization,
7872
8021
  selectTeamsOfUser,
7873
8022
  selectUploadUrl,
7874
8023
  selectUser,
7875
- selectUsersAsMapping,
8024
+ selectUserById,
8025
+ selectUsersByIds,
8026
+ selectUsersMapping,
7876
8027
  selectWorkspaceById,
7877
8028
  selectWorkspaceMapping,
7878
8029
  selectWorkspaces,
@@ -7899,7 +8050,6 @@ export {
7899
8050
  setFormSubmissions,
7900
8051
  setGeoImage,
7901
8052
  setGeoImages,
7902
- setIsFetchingInitialData,
7903
8053
  setIsImportingProjectFile,
7904
8054
  setIssueAssociation,
7905
8055
  setIssueAssociations,
@@ -7924,8 +8074,6 @@ export {
7924
8074
  setUploadUrl,
7925
8075
  setUsers,
7926
8076
  setWorkspaces,
7927
- settingReducer,
7928
- settingSlice,
7929
8077
  shallowEqual,
7930
8078
  slugify,
7931
8079
  spacesToDashesLower,