@overmap-ai/core 1.0.63-org-doc-improvements.2 → 1.0.63-selector-standardization.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 selectAssetTypeById = (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,
@@ -1736,7 +1793,7 @@ const { initializeOrganizationAccesses, updateOrganizationAccess, deleteOrganiza
1736
1793
  const selectOrganizationAccesses = (state) => {
1737
1794
  return state.organizationAccessReducer.instances;
1738
1795
  };
1739
- const selectOrganizationAccess = (organizationAccessId) => (state) => {
1796
+ const selectOrganizationAccessById = (organizationAccessId) => (state) => {
1740
1797
  return state.organizationAccessReducer.instances[organizationAccessId];
1741
1798
  };
1742
1799
  const selectActiveOrganizationAccess = createSelector(
@@ -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,7 +1966,8 @@ const {
1914
1966
  addActiveProjectIssuesCount,
1915
1967
  addActiveProjectFormSubmissionsCount
1916
1968
  } = projectSlice.actions;
1917
- const selectProjects = (state) => state.projectReducer.projects;
1969
+ const projectReducer = projectSlice.reducer;
1970
+ const selectProjectMapping = (state) => state.projectReducer.projects;
1918
1971
  const selectActiveProjectId = (state) => state.projectReducer.activeProjectId;
1919
1972
  const selectActiveProject = (state) => {
1920
1973
  const activeProjectId = selectActiveProjectId(state);
@@ -1923,23 +1976,19 @@ 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(
1942
- [selectProjects],
1991
+ [selectProjectMapping],
1943
1992
  (projects) => Object.values(projects).filter((project) => !project.invited)
1944
1993
  );
1945
1994
  const selectSortedProjectUsers = 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) {
@@ -1997,9 +2046,12 @@ const selectOrganizationUsersIds = createSelector(
1997
2046
  (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
1998
2047
  );
1999
2048
  const selectProjectsOfOrganization = restructureCreateSelectorWithArgs(
2000
- createSelector([selectProjects, (_, organizationId) => organizationId], (projects, organizationId) => {
2001
- return Object.values(projects).filter((project) => project.organization_owner === organizationId);
2002
- })
2049
+ createSelector(
2050
+ [selectProjectMapping, (_, organizationId) => organizationId],
2051
+ (projects, organizationId) => {
2052
+ return Object.values(projects).filter((project) => project.organization_owner === organizationId);
2053
+ }
2054
+ )
2003
2055
  );
2004
2056
  const selectLicensesOfOrganization = restructureCreateSelectorWithArgs(
2005
2057
  createSelector([selectLicenses, (_, organizationId) => organizationId], (licenses, organizationId) => {
@@ -2007,7 +2059,7 @@ const selectLicensesOfOrganization = restructureCreateSelectorWithArgs(
2007
2059
  })
2008
2060
  );
2009
2061
  const selectOrganizationUsersAsMapping = createSelector(
2010
- [selectOrganizationUsersIds, selectUsersAsMapping],
2062
+ [selectOrganizationUsersIds, selectUsersMapping],
2011
2063
  (organizationUserIds, users) => organizationUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
2012
2064
  );
2013
2065
  const selectSortedOrganizationUsers = createSelector(
@@ -2052,14 +2104,14 @@ const createOfflineAction = (request2, baseUrl, serviceName) => {
2052
2104
  }
2053
2105
  };
2054
2106
  };
2055
- const initialState$k = {
2107
+ const initialState$j = {
2056
2108
  deletedRequests: [],
2057
2109
  latestRetryTime: 0
2058
2110
  };
2059
2111
  const outboxSlice = createSlice({
2060
2112
  name: "outbox",
2061
- initialState: initialState$k,
2062
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
2113
+ initialState: initialState$j,
2114
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2063
2115
  reducers: {
2064
2116
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2065
2117
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -2091,15 +2143,15 @@ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2091
2143
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2092
2144
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2093
2145
  const outboxReducer = outboxSlice.reducer;
2094
- const initialState$j = {
2146
+ const initialState$i = {
2095
2147
  projectFiles: {},
2096
2148
  activeProjectFileId: null,
2097
2149
  isImportingProjectFile: false
2098
2150
  };
2099
2151
  const projectFileSlice = createSlice({
2100
2152
  name: "projectFiles",
2101
- initialState: initialState$j,
2102
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2153
+ initialState: initialState$i,
2154
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2103
2155
  reducers: {
2104
2156
  addOrReplaceProjectFiles: (state, action) => {
2105
2157
  for (let fileObj of action.payload) {
@@ -2184,11 +2236,11 @@ const selectProjectFileById = (id) => (state) => {
2184
2236
  };
2185
2237
  const projectFileReducer = projectFileSlice.reducer;
2186
2238
  const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2187
- const initialState$i = projectAttachmentAdapter.getInitialState({});
2239
+ const initialState$h = projectAttachmentAdapter.getInitialState({});
2188
2240
  const projectAttachmentSlice = createSlice({
2189
2241
  name: "projectAttachments",
2190
- initialState: initialState$i,
2191
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2242
+ initialState: initialState$h,
2243
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2192
2244
  reducers: {
2193
2245
  initializeProjectAttachments: projectAttachmentAdapter.initialize,
2194
2246
  addProjectAttachment: projectAttachmentAdapter.addOne,
@@ -2246,12 +2298,12 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
2246
2298
  )
2247
2299
  );
2248
2300
  const projectAttachmentReducer = projectAttachmentSlice.reducer;
2249
- const initialState$h = {
2301
+ const initialState$g = {
2250
2302
  isRehydrated: false
2251
2303
  };
2252
2304
  const rehydratedSlice = createSlice({
2253
2305
  name: "rehydrated",
2254
- initialState: initialState$h,
2306
+ initialState: initialState$g,
2255
2307
  // The `reducers` field lets us define reducers and generate associated actions
2256
2308
  reducers: {
2257
2309
  setRehydrated: (state, action) => {
@@ -2262,22 +2314,6 @@ const rehydratedSlice = createSlice({
2262
2314
  const { setRehydrated } = rehydratedSlice.actions;
2263
2315
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
2264
2316
  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
2317
  const formRevisionSortFn = (formRevisionA, formRevisionB) => {
2282
2318
  const revisionA = formRevisionA.revision;
2283
2319
  const revisionB = formRevisionB.revision;
@@ -2319,7 +2355,7 @@ const selectFormRevisions = createSelector(
2319
2355
  [selectFormRevisionMapping],
2320
2356
  (formRevisions) => Object.values(formRevisions)
2321
2357
  );
2322
- const selectFormRevision = (formRevisionId) => (state) => {
2358
+ const selectFormRevisionById = (formRevisionId) => (state) => {
2323
2359
  return state.formRevisionReducer.instances[formRevisionId];
2324
2360
  };
2325
2361
  const _selectLatestFormRevision = (formRevisions, formId) => {
@@ -2450,12 +2486,12 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
2450
2486
  { memoizeOptions: { equalityCheck: shallowEqual } }
2451
2487
  )
2452
2488
  );
2453
- const selectForm = (formId) => (state) => {
2454
- return state.formReducer.instances[formId];
2455
- };
2456
2489
  const selectFormMapping = (state) => {
2457
2490
  return state.formReducer.instances;
2458
2491
  };
2492
+ const selectFormById = (formId) => (state) => {
2493
+ return state.formReducer.instances[formId];
2494
+ };
2459
2495
  const selectFormOfAssetType = restructureCreateSelectorWithArgs(
2460
2496
  createSelector(
2461
2497
  [selectFormMapping, (_state, assetTypeId) => assetTypeId],
@@ -2517,7 +2553,7 @@ const selectFormSubmissions = createSelector(
2517
2553
  return Object.values(submissions);
2518
2554
  }
2519
2555
  );
2520
- const selectFormSubmission = (submissionId) => (state) => {
2556
+ const selectFormSubmissionById = (submissionId) => (state) => {
2521
2557
  return state.formSubmissionReducer.instances[submissionId];
2522
2558
  };
2523
2559
  const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
@@ -2723,6 +2759,15 @@ const {
2723
2759
  const selectFormSubmissionAttachmentsMapping = (state) => {
2724
2760
  return state.formSubmissionAttachmentReducer.instances;
2725
2761
  };
2762
+ const selectFormSubmissionAttachemntsByIds = restructureCreateSelectorWithArgs(
2763
+ createSelector(
2764
+ [selectFormSubmissionAttachmentsMapping, (_, attachmentIds) => attachmentIds],
2765
+ (mapping, attachmentIds) => {
2766
+ const attachmentIdsSet = new Set(attachmentIds);
2767
+ return Object.values(mapping).filter((attachment) => attachmentIdsSet.has(attachment.offline_id));
2768
+ }
2769
+ )
2770
+ );
2726
2771
  const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
2727
2772
  createSelector(
2728
2773
  [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
@@ -2954,10 +2999,24 @@ const selectDocuments = createSelector(
2954
2999
  [selectDocumentsMapping],
2955
3000
  (mapping) => Object.values(mapping)
2956
3001
  );
2957
- const selectDocument = restructureCreateSelectorWithArgs(
3002
+ const selectDocumentById = (documentId) => (state) => {
3003
+ return state.documentsReducer.documents[documentId];
3004
+ };
3005
+ const selectDocumentsByIds = restructureCreateSelectorWithArgs(
2958
3006
  createSelector(
2959
- [selectDocumentsMapping, (_state, documentId) => documentId],
2960
- (mapping, documentId) => mapping[documentId]
3007
+ [selectDocumentsMapping, (_state, documentIds) => documentIds],
3008
+ (mapping, documentIds) => {
3009
+ const documents = [];
3010
+ for (const documentId of documentIds) {
3011
+ const document2 = mapping[documentId];
3012
+ if (document2) {
3013
+ documents.push(document2);
3014
+ } else {
3015
+ console.warn("selectDocumentByIds: No document exists with the id", documentId);
3016
+ }
3017
+ }
3018
+ return documents;
3019
+ }
2961
3020
  )
2962
3021
  );
2963
3022
  const selectAncestorIdsOfDocument = restructureCreateSelectorWithArgs(
@@ -3061,7 +3120,7 @@ const selectTeamsMapping = (state) => state.teamReducer.instances;
3061
3120
  const selectTeams = createSelector([selectTeamsMapping], (teams) => {
3062
3121
  return Object.values(teams);
3063
3122
  });
3064
- const selectTeam = (teamId) => (state) => {
3123
+ const selectTeamById = (teamId) => (state) => {
3065
3124
  return state.teamReducer.instances[teamId];
3066
3125
  };
3067
3126
  const selectTeamsOfOrganization = restructureCreateSelectorWithArgs(
@@ -3318,6 +3377,9 @@ const {
3318
3377
  deleteIssueAssociations
3319
3378
  } = issueAssociationSlice.actions;
3320
3379
  const selectIssueAssociationMapping = (state) => state.issueAssociationReducer.instances;
3380
+ const selectIssueAssociations = createSelector([selectIssueAssociationMapping], (associations) => {
3381
+ return Object.values(associations);
3382
+ });
3321
3383
  const selectIssueAssociationById = (id) => (state) => {
3322
3384
  return state.issueAssociationReducer.instances[id];
3323
3385
  };
@@ -3402,7 +3464,6 @@ const overmapReducers = {
3402
3464
  organizationAccessReducer,
3403
3465
  projectFileReducer,
3404
3466
  rehydratedReducer,
3405
- settingReducer,
3406
3467
  formReducer,
3407
3468
  formRevisionReducer,
3408
3469
  formRevisionAttachmentReducer,
@@ -4211,7 +4272,7 @@ class AssetService extends BaseApiService {
4211
4272
  async remove(assetId) {
4212
4273
  const { store } = this.client;
4213
4274
  const state = store.getState();
4214
- const assetToBeDeleted = selectAsset(assetId)(state);
4275
+ const assetToBeDeleted = selectAssetById(assetId)(state);
4215
4276
  if (!assetToBeDeleted)
4216
4277
  throw new Error(`No asset with id ${assetId} found in the store`);
4217
4278
  const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(state);
@@ -4327,7 +4388,7 @@ class AssetStageCompletionService extends BaseApiService {
4327
4388
  add(assetId, stageId) {
4328
4389
  var _a2;
4329
4390
  const { store } = this.client;
4330
- const assetTypeId = (_a2 = selectAsset(assetId)(store.getState())) == null ? void 0 : _a2.asset_type;
4391
+ const assetTypeId = (_a2 = selectAssetById(assetId)(store.getState())) == null ? void 0 : _a2.asset_type;
4331
4392
  if (!assetTypeId) {
4332
4393
  throw new Error(`Asset with offline_id ${assetId} not found`);
4333
4394
  }
@@ -4433,12 +4494,7 @@ class AssetStageService extends BaseApiService {
4433
4494
  async bulkUpdateStages(stagesToUpdate, assetTypeId) {
4434
4495
  const store = this.client.store;
4435
4496
  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
- }
4497
+ const prevStages = selectAssetStagesByIds(stagesToUpdate.map(({ offline_id }) => offline_id))(state);
4442
4498
  this.dispatch(updateStages(stagesToUpdate));
4443
4499
  return this.enqueueRequest({
4444
4500
  description: "Edit asset stages",
@@ -4761,7 +4817,7 @@ class AssetTypeService extends BaseApiService {
4761
4817
  async delete(assetTypeId) {
4762
4818
  const { store } = this.client;
4763
4819
  const state = store.getState();
4764
- const assetType = selectAssetType(assetTypeId)(state);
4820
+ const assetType = selectAssetTypeById(assetTypeId)(state);
4765
4821
  if (!assetType) {
4766
4822
  throw new Error(`Expected asset type with offline_id ${assetTypeId} to exist`);
4767
4823
  }
@@ -5015,7 +5071,7 @@ class IssueService extends BaseApiService {
5015
5071
  }
5016
5072
  update(issue) {
5017
5073
  const state = this.client.store.getState();
5018
- const issueToBeUpdated = selectIssue(issue.offline_id)(state);
5074
+ const issueToBeUpdated = selectIssueById(issue.offline_id)(state);
5019
5075
  if (!issueToBeUpdated) {
5020
5076
  throw new Error(
5021
5077
  `Attempting to update an issue with offline_id ${issue.offline_id} that doesn't exist in the store`
@@ -5109,7 +5165,7 @@ class IssueService extends BaseApiService {
5109
5165
  async remove(id) {
5110
5166
  const { store } = this.client;
5111
5167
  const state = store.getState();
5112
- const backup = selectIssue(id)(state);
5168
+ const backup = selectIssueById(id)(state);
5113
5169
  if (!backup) {
5114
5170
  throw new Error(`No issue with id ${id} found in the store`);
5115
5171
  }
@@ -5190,7 +5246,7 @@ class IssueTypeService extends BaseApiService {
5190
5246
  offline_id: offlineIssueType.offline_id,
5191
5247
  submitted_at: offlineIssueType.submitted_at,
5192
5248
  icon: offlineIssueType.icon,
5193
- icon_color: offlineIssueType.color,
5249
+ color: offlineIssueType.color,
5194
5250
  name: offlineIssueType.name,
5195
5251
  description: offlineIssueType.description
5196
5252
  },
@@ -5204,24 +5260,24 @@ class IssueTypeService extends BaseApiService {
5204
5260
  });
5205
5261
  return [offlineIssueType, promise];
5206
5262
  }
5207
- update(issueTypeFields) {
5263
+ update(payload) {
5208
5264
  const { store } = this.client;
5209
5265
  const state = store.getState();
5210
- const issueTypeToBeUpdated = selectIssueType(issueTypeFields.offline_id)(state);
5266
+ const issueTypeToBeUpdated = selectIssueTypeById(payload.offline_id)(state);
5211
5267
  if (!issueTypeToBeUpdated) {
5212
- throw new Error(`IssueType with offline_id ${issueTypeFields.offline_id} does not exist in the store.`);
5268
+ throw new Error(`IssueType with offline_id ${payload.offline_id} does not exist in the store.`);
5213
5269
  }
5214
5270
  const offlineUpdatedIssueType = {
5215
5271
  ...issueTypeToBeUpdated,
5216
- ...issueTypeFields
5272
+ ...payload
5217
5273
  };
5218
5274
  this.dispatch(updateIssueType(offlineUpdatedIssueType));
5219
5275
  const promise = this.enqueueRequest({
5220
5276
  method: HttpMethod.PATCH,
5221
- url: `/issues/types/${issueTypeFields.offline_id}/`,
5222
- payload: issueTypeFields,
5223
- blockers: [issueTypeFields.offline_id],
5224
- blocks: [issueTypeFields.offline_id]
5277
+ url: `/issues/types/${payload.offline_id}/`,
5278
+ payload,
5279
+ blockers: [payload.offline_id],
5280
+ blocks: [payload.offline_id]
5225
5281
  });
5226
5282
  promise.then((updatedIssueType) => {
5227
5283
  this.dispatch(setIssueType(updatedIssueType));
@@ -5233,7 +5289,7 @@ class IssueTypeService extends BaseApiService {
5233
5289
  delete(issueTypeId) {
5234
5290
  const { store } = this.client;
5235
5291
  const state = store.getState();
5236
- const issueTypeToDelete = selectIssueType(issueTypeId)(state);
5292
+ const issueTypeToDelete = selectIssueTypeById(issueTypeId)(state);
5237
5293
  if (!issueTypeToDelete) {
5238
5294
  throw new Error(`IssueType with offline_id ${issueTypeId} does not exist in the store.`);
5239
5295
  }
@@ -5481,7 +5537,7 @@ class ProjectService extends BaseApiService {
5481
5537
  async delete(projectId) {
5482
5538
  const { store } = this.client;
5483
5539
  const state = store.getState();
5484
- const projects = selectProjects(state);
5540
+ const projects = selectProjectMapping(state);
5485
5541
  const project = projects[projectId];
5486
5542
  if (!project) {
5487
5543
  throw new Error("Expected project to exist");
@@ -5824,7 +5880,7 @@ class FormService extends BaseUploadService {
5824
5880
  async delete(formId) {
5825
5881
  const { store } = this.client;
5826
5882
  const state = store.getState();
5827
- const form = selectForm(formId)(state);
5883
+ const form = selectFormById(formId)(state);
5828
5884
  if (!form) {
5829
5885
  throw new Error("Expected form to exist");
5830
5886
  }
@@ -6001,6 +6057,25 @@ class FormSubmissionService extends BaseUploadService {
6001
6057
  });
6002
6058
  return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
6003
6059
  }
6060
+ async bulkDeleteSubmissionAttachments(submissionId, attachmentsIds) {
6061
+ const { store } = this.client;
6062
+ const state = store.getState();
6063
+ const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
6064
+ this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
6065
+ try {
6066
+ await this.enqueueRequest({
6067
+ description: "Delete form submission attachments",
6068
+ method: HttpMethod.DELETE,
6069
+ url: `/forms/submissions/${submissionId}/attachments/bulk/`,
6070
+ payload: { attachments: attachmentsIds },
6071
+ blockers: [submissionId, ...attachmentsIds],
6072
+ blocks: []
6073
+ });
6074
+ } catch (e) {
6075
+ this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
6076
+ throw e;
6077
+ }
6078
+ }
6004
6079
  // Outer promise is for hashing and caching files for submission attachments
6005
6080
  async add(payload) {
6006
6081
  const { store } = this.client;
@@ -6140,10 +6215,64 @@ class FormSubmissionService extends BaseUploadService {
6140
6215
  });
6141
6216
  return batchPromises;
6142
6217
  }
6218
+ async update(payload) {
6219
+ const { store } = this.client;
6220
+ const state = store.getState();
6221
+ const submissionToBeUpdated = selectFormSubmissionById(payload.offline_id)(state);
6222
+ if (!submissionToBeUpdated) {
6223
+ throw new Error(`Expected submission with offline_id ${payload.offline_id} to exist`);
6224
+ }
6225
+ const { values, files } = separateFilesFromValues(payload.values ?? {});
6226
+ const updatedSubmission = {
6227
+ ...submissionToBeUpdated,
6228
+ ...payload,
6229
+ // values could also have a partial update
6230
+ values: {
6231
+ ...submissionToBeUpdated.values,
6232
+ ...values
6233
+ }
6234
+ };
6235
+ this.dispatch(updateFormSubmission(updatedSubmission));
6236
+ const promise = this.enqueueRequest({
6237
+ description: "Delete user form submissions",
6238
+ method: HttpMethod.PATCH,
6239
+ url: `/forms/submissions/${updatedSubmission.offline_id}/`,
6240
+ payload: updatedSubmission,
6241
+ blockers: [updatedSubmission.offline_id],
6242
+ blocks: [updatedSubmission.offline_id]
6243
+ });
6244
+ const formSubmissionAttachments = selectAttachmentsOfFormSubmission(payload.offline_id)(state);
6245
+ const formSubmissionAttachmentIdsToBeDeleted = [];
6246
+ for (const attachment of formSubmissionAttachments) {
6247
+ if (attachment.field_identifier in files) {
6248
+ formSubmissionAttachmentIdsToBeDeleted.push(attachment.offline_id);
6249
+ }
6250
+ }
6251
+ const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
6252
+ payload.offline_id,
6253
+ files
6254
+ );
6255
+ const deleteAttachmentsPromise = this.bulkDeleteSubmissionAttachments(
6256
+ payload.offline_id,
6257
+ formSubmissionAttachmentIdsToBeDeleted
6258
+ );
6259
+ promise.then((result) => {
6260
+ this.dispatch(setFormSubmission(result));
6261
+ }).catch(() => {
6262
+ this.dispatch(setFormSubmission(submissionToBeUpdated));
6263
+ });
6264
+ return [
6265
+ updatedSubmission,
6266
+ offlineFormSubmissionAttachments,
6267
+ promise,
6268
+ attachmentsPromise,
6269
+ deleteAttachmentsPromise
6270
+ ];
6271
+ }
6143
6272
  async delete(submissionId) {
6144
6273
  const { store } = this.client;
6145
6274
  const state = store.getState();
6146
- const submissionToBeDeleted = selectFormSubmission(submissionId)(store.getState());
6275
+ const submissionToBeDeleted = selectFormSubmissionById(submissionId)(state);
6147
6276
  if (!submissionToBeDeleted) {
6148
6277
  throw new Error(`Expected submission with offline_id ${submissionId} to exist`);
6149
6278
  }
@@ -7033,7 +7162,7 @@ class TeamService extends BaseApiService {
7033
7162
  // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
7034
7163
  update(team) {
7035
7164
  const { store } = this.client;
7036
- const teamToBeUpdated = selectTeam(team.offline_id)(store.getState());
7165
+ const teamToBeUpdated = selectTeamById(team.offline_id)(store.getState());
7037
7166
  if (!teamToBeUpdated) {
7038
7167
  throw new Error(`Expected team with offline_id ${team.offline_id} to exist`);
7039
7168
  }
@@ -7060,7 +7189,7 @@ class TeamService extends BaseApiService {
7060
7189
  async delete(teamId) {
7061
7190
  const { store } = this.client;
7062
7191
  const state = store.getState();
7063
- const team = selectTeam(teamId)(state);
7192
+ const team = selectTeamById(teamId)(state);
7064
7193
  if (!team) {
7065
7194
  throw new Error(`Expected team with id ${teamId} to exist`);
7066
7195
  }
@@ -7080,7 +7209,7 @@ class TeamService extends BaseApiService {
7080
7209
  }
7081
7210
  async setMembers(teamId, members) {
7082
7211
  const { store } = this.client;
7083
- const team = selectTeam(teamId)(store.getState());
7212
+ const team = selectTeamById(teamId)(store.getState());
7084
7213
  if (!team) {
7085
7214
  throw new Error(`Expected team with id ${teamId} to exist`);
7086
7215
  }
@@ -7105,7 +7234,7 @@ class TeamService extends BaseApiService {
7105
7234
  }
7106
7235
  async addMembers(teamId, members) {
7107
7236
  const { store } = this.client;
7108
- const team = selectTeam(teamId)(store.getState());
7237
+ const team = selectTeamById(teamId)(store.getState());
7109
7238
  if (!team) {
7110
7239
  throw new Error(`Expected team with id ${teamId} to exist`);
7111
7240
  }
@@ -7114,7 +7243,7 @@ class TeamService extends BaseApiService {
7114
7243
  }
7115
7244
  async removeMembers(teamId, members) {
7116
7245
  const { store } = this.client;
7117
- const team = selectTeam(teamId)(store.getState());
7246
+ const team = selectTeamById(teamId)(store.getState());
7118
7247
  if (!team) {
7119
7248
  throw new Error(`Expected team with id ${teamId} to exist`);
7120
7249
  }
@@ -7727,21 +7856,25 @@ export {
7727
7856
  selectAllDocumentAttachments,
7728
7857
  selectAllProjectAttachments,
7729
7858
  selectAncestorIdsOfDocument,
7730
- selectAsset,
7731
7859
  selectAssetAttachment,
7732
7860
  selectAssetAttachmentMapping,
7733
7861
  selectAssetAttachments,
7862
+ selectAssetById,
7863
+ selectAssetStageById,
7864
+ selectAssetStages,
7865
+ selectAssetStagesByIds,
7734
7866
  selectAssetToAssetTypeMapping,
7735
- selectAssetType,
7736
7867
  selectAssetTypeAttachment,
7737
7868
  selectAssetTypeAttachmentMapping,
7738
7869
  selectAssetTypeAttachments,
7870
+ selectAssetTypeById,
7739
7871
  selectAssetTypeStagesMapping,
7740
7872
  selectAssetTypes,
7741
- selectAssetTypesByName,
7873
+ selectAssetTypesByIds,
7742
7874
  selectAssetTypesFromIds,
7743
7875
  selectAssetTypesMapping,
7744
7876
  selectAssets,
7877
+ selectAssetsByIds,
7745
7878
  selectAssetsMapping,
7746
7879
  selectAssetsOfAssetType,
7747
7880
  selectAttachedFormSubmissionsOfAsset,
@@ -7759,6 +7892,7 @@ export {
7759
7892
  selectAttachmentsOfProject,
7760
7893
  selectAttachmentsOfProjectByType,
7761
7894
  selectCategories,
7895
+ selectCategoriesByIds,
7762
7896
  selectCategoriesOfWorkspace,
7763
7897
  selectCategoryById,
7764
7898
  selectCategoryMapping,
@@ -7770,27 +7904,29 @@ export {
7770
7904
  selectConversations,
7771
7905
  selectCurrentUser,
7772
7906
  selectDeletedRequests,
7773
- selectDocument,
7774
7907
  selectDocumentAttachment,
7775
7908
  selectDocumentAttachmentMapping,
7909
+ selectDocumentById,
7776
7910
  selectDocuments,
7911
+ selectDocumentsByIds,
7777
7912
  selectDocumentsMapping,
7778
7913
  selectEmailDomains,
7779
7914
  selectEmailDomainsAsMapping,
7780
7915
  selectEmailDomainsOfOrganization,
7781
7916
  selectFavouriteProjects,
7782
7917
  selectFilteredForms,
7783
- selectForm,
7918
+ selectFormById,
7784
7919
  selectFormMapping,
7785
7920
  selectFormOfAssetType,
7786
7921
  selectFormOfIssueType,
7787
- selectFormRevision,
7788
7922
  selectFormRevisionAttachmentsMapping,
7923
+ selectFormRevisionById,
7789
7924
  selectFormRevisionMapping,
7790
7925
  selectFormRevisions,
7791
7926
  selectFormRevisionsOfForm,
7792
- selectFormSubmission,
7927
+ selectFormSubmissionAttachemntsByIds,
7793
7928
  selectFormSubmissionAttachmentsMapping,
7929
+ selectFormSubmissionById,
7794
7930
  selectFormSubmissions,
7795
7931
  selectFormSubmissionsByAssets,
7796
7932
  selectFormSubmissionsByFormRevisions,
@@ -7806,27 +7942,29 @@ export {
7806
7942
  selectGeoImageMapping,
7807
7943
  selectGeoImages,
7808
7944
  selectGeoImagesOfProject,
7809
- selectIsFetchingInitialData,
7810
7945
  selectIsImportingProjectFile,
7811
7946
  selectIsLoggedIn,
7812
- selectIssue,
7813
7947
  selectIssueAssociationById,
7814
7948
  selectIssueAssociationMapping,
7949
+ selectIssueAssociations,
7815
7950
  selectIssueAssociationsOfAsset,
7816
7951
  selectIssueAssociationsOfIssue,
7817
7952
  selectIssueAssociationsToIssue,
7818
7953
  selectIssueAttachment,
7819
7954
  selectIssueAttachmentMapping,
7820
7955
  selectIssueAttachments,
7956
+ selectIssueById,
7821
7957
  selectIssueCommentMapping,
7822
7958
  selectIssueCountOfCategory,
7823
7959
  selectIssueMapping,
7824
- selectIssueType,
7960
+ selectIssueTypeById,
7825
7961
  selectIssueTypeMapping,
7826
7962
  selectIssueTypes,
7963
+ selectIssueTypesByIds,
7827
7964
  selectIssueTypesOfOrganization,
7828
7965
  selectIssueUpdateMapping,
7829
7966
  selectIssueUpdatesOfIssue,
7967
+ selectIssuesByIds,
7830
7968
  selectIssuesOfIssueType,
7831
7969
  selectIssuesOfIssueTypeCount,
7832
7970
  selectLatestFormRevisionByForm,
@@ -7839,10 +7977,9 @@ export {
7839
7977
  selectLicensesForProjectsMapping,
7840
7978
  selectLicensesOfOrganization,
7841
7979
  selectMainWorkspace,
7842
- selectNumberOfAssetTypesMatchingCaseInsensitiveName,
7843
7980
  selectNumberOfAssetsOfAssetType,
7844
7981
  selectOrganization,
7845
- selectOrganizationAccess,
7982
+ selectOrganizationAccessById,
7846
7983
  selectOrganizationAccessForUser,
7847
7984
  selectOrganizationAccessUserMapping,
7848
7985
  selectOrganizationAccesses,
@@ -7853,20 +7990,20 @@ export {
7853
7990
  selectOrganizationsMapping,
7854
7991
  selectOrganizationsWithAccess,
7855
7992
  selectPermittedWorkspaceIds,
7856
- selectProject,
7857
- selectProjectAccess,
7993
+ selectProjectAccessById,
7858
7994
  selectProjectAccessForUser,
7859
7995
  selectProjectAccessMapping,
7860
7996
  selectProjectAccessUserMapping,
7861
7997
  selectProjectAccesses,
7862
7998
  selectProjectAttachment,
7863
7999
  selectProjectAttachmentMapping,
8000
+ selectProjectById,
7864
8001
  selectProjectFileById,
7865
8002
  selectProjectFileMapping,
7866
8003
  selectProjectFiles,
8004
+ selectProjectMapping,
7867
8005
  selectProjectUsersAsMapping,
7868
8006
  selectProjectUsersIds,
7869
- selectProjects,
7870
8007
  selectProjectsOfOrganization,
7871
8008
  selectProjectsWithAccess,
7872
8009
  selectRecentIssueIds,
@@ -7876,21 +8013,20 @@ export {
7876
8013
  selectSortedFormSubmissionsOfForm,
7877
8014
  selectSortedOrganizationUsers,
7878
8015
  selectSortedProjectUsers,
7879
- selectStage,
7880
8016
  selectStageFormIdsFromStageIds,
7881
8017
  selectStageMapping,
7882
- selectStages,
7883
8018
  selectStagesFromAssetTypeIds,
7884
- selectStagesFromStageIds,
7885
8019
  selectStagesOfAssetType,
7886
- selectTeam,
8020
+ selectTeamById,
7887
8021
  selectTeams,
7888
8022
  selectTeamsMapping,
7889
8023
  selectTeamsOfOrganization,
7890
8024
  selectTeamsOfUser,
7891
8025
  selectUploadUrl,
7892
8026
  selectUser,
7893
- selectUsersAsMapping,
8027
+ selectUserById,
8028
+ selectUsersByIds,
8029
+ selectUsersMapping,
7894
8030
  selectWorkspaceById,
7895
8031
  selectWorkspaceMapping,
7896
8032
  selectWorkspaces,
@@ -7917,7 +8053,6 @@ export {
7917
8053
  setFormSubmissions,
7918
8054
  setGeoImage,
7919
8055
  setGeoImages,
7920
- setIsFetchingInitialData,
7921
8056
  setIsImportingProjectFile,
7922
8057
  setIssueAssociation,
7923
8058
  setIssueAssociations,
@@ -7942,8 +8077,6 @@ export {
7942
8077
  setUploadUrl,
7943
8078
  setUsers,
7944
8079
  setWorkspaces,
7945
- settingReducer,
7946
- settingSlice,
7947
8080
  shallowEqual,
7948
8081
  slugify,
7949
8082
  spacesToDashesLower,