@overmap-ai/core 1.0.63-table-filters.0 → 1.0.63

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 (68) hide show
  1. package/dist/overmap-core.js +667 -403
  2. package/dist/overmap-core.js.map +1 -1
  3. package/dist/overmap-core.umd.cjs +667 -403
  4. package/dist/overmap-core.umd.cjs.map +1 -1
  5. package/dist/sdk/services/AssetAttachmentService.d.ts +1 -1
  6. package/dist/sdk/services/AssetTypeAttachmentService.d.ts +1 -1
  7. package/dist/sdk/services/BaseAttachmentService.d.ts +9 -3
  8. package/dist/sdk/services/BaseUploadService.d.ts +1 -1
  9. package/dist/sdk/services/DocumentAttachmentService.d.ts +3 -1
  10. package/dist/sdk/services/DocumentService.d.ts +1 -1
  11. package/dist/sdk/services/FormService.d.ts +2 -2
  12. package/dist/sdk/services/FormSubmissionService.d.ts +9 -1
  13. package/dist/sdk/services/IssueAssociationService.d.ts +9 -0
  14. package/dist/sdk/services/IssueAttachmentService.d.ts +1 -1
  15. package/dist/sdk/services/IssueTypeService.d.ts +1 -1
  16. package/dist/sdk/services/ProjectAttachmentService.d.ts +1 -1
  17. package/dist/sdk/services/index.d.ts +1 -0
  18. package/dist/store/adapter.d.ts +1 -1
  19. package/dist/store/slices/agentsSlice.d.ts +2 -2
  20. package/dist/store/slices/assetAttachmentSlice.d.ts +3 -3
  21. package/dist/store/slices/assetSlice.d.ts +48 -17
  22. package/dist/store/slices/assetStageCompletionSlice.d.ts +2 -2
  23. package/dist/store/slices/assetStageSlice.d.ts +10 -6
  24. package/dist/store/slices/assetTypeAttachmentSlice.d.ts +3 -3
  25. package/dist/store/slices/assetTypeSlice.d.ts +4 -10
  26. package/dist/store/slices/authSlice.d.ts +2 -2
  27. package/dist/store/slices/categorySlice.d.ts +4 -4
  28. package/dist/store/slices/documentAttachmentSlice.d.ts +3 -3
  29. package/dist/store/slices/documentSlice.d.ts +5 -312
  30. package/dist/store/slices/emailDomainsSlice.d.ts +7 -3
  31. package/dist/store/slices/fileSlice.d.ts +2 -2
  32. package/dist/store/slices/formRevisionAttachmentSlice.d.ts +2 -2
  33. package/dist/store/slices/formRevisionSlice.d.ts +4 -5
  34. package/dist/store/slices/formSlice.d.ts +15 -11
  35. package/dist/store/slices/formSubmissionAttachmentSlice.d.ts +3 -2
  36. package/dist/store/slices/formSubmissionSlice.d.ts +3 -3
  37. package/dist/store/slices/geoImageSlice.d.ts +2 -2
  38. package/dist/store/slices/index.d.ts +1 -1
  39. package/dist/store/slices/issueAssociationSlice.d.ts +54 -0
  40. package/dist/store/slices/issueAttachmentSlice.d.ts +3 -3
  41. package/dist/store/slices/issueCommentSlice.d.ts +2 -2
  42. package/dist/store/slices/issueSlice.d.ts +4 -3
  43. package/dist/store/slices/issueTypeSlice.d.ts +4 -3
  44. package/dist/store/slices/issueUpdateSlice.d.ts +2 -2
  45. package/dist/store/slices/licenseSlice.d.ts +3 -4
  46. package/dist/store/slices/organizationAccessSlice.d.ts +4 -4
  47. package/dist/store/slices/organizationSlice.d.ts +8 -5
  48. package/dist/store/slices/outboxSlice.d.ts +1 -1
  49. package/dist/store/slices/projectAccessSlice.d.ts +3 -3
  50. package/dist/store/slices/projectAttachmentSlice.d.ts +3 -3
  51. package/dist/store/slices/projectFileSlice.d.ts +2 -2
  52. package/dist/store/slices/projectSlice.d.ts +4 -4
  53. package/dist/store/slices/rehydratedSlice.d.ts +1 -1
  54. package/dist/store/slices/teamSlice.d.ts +3 -3
  55. package/dist/store/slices/userSlice.d.ts +4 -4
  56. package/dist/store/slices/workspaceSlice.d.ts +3 -3
  57. package/dist/store/store.d.ts +3 -3
  58. package/dist/typings/models/assets.d.ts +3 -2
  59. package/dist/typings/models/base.d.ts +6 -4
  60. package/dist/typings/models/documents.d.ts +6 -16
  61. package/dist/typings/models/forms.d.ts +2 -0
  62. package/dist/typings/models/issueTypes.d.ts +2 -2
  63. package/dist/typings/models/issues.d.ts +13 -9
  64. package/dist/typings/models/store.d.ts +2 -2
  65. package/dist/typings/models/teams.d.ts +2 -2
  66. package/dist/typings/store.d.ts +1 -1
  67. package/package.json +1 -1
  68. package/dist/store/slices/settingsSlice.d.ts +0 -11
@@ -874,24 +874,32 @@ 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
- const selectCategoriesByIds = restructureCreateSelectorWithArgs(
890
- createSelector([selectCategoryMapping, (_, ids) => ids], (categoryMapping, ids) => {
891
- const idsSet = new Set(ids);
892
- return Object.values(categoryMapping).filter((category) => idsSet.has(category.offline_id));
893
- })
894
- );
895
903
  const selectIssueCountOfCategory = (categoryId) => (state) => {
896
904
  return Object.values(state.issueReducer.instances).filter((issue) => issue.category === categoryId).length;
897
905
  };
@@ -914,36 +922,26 @@ const selectAssetTypes = createSelector(
914
922
  [selectAssetTypesMapping],
915
923
  (mapping) => Object.values(mapping)
916
924
  );
917
- const selectAssetType = restructureCreateSelectorWithArgs(
918
- createSelector(
919
- [selectAssetTypesMapping, (_state, assetTypeId) => assetTypeId],
920
- (mapping, assetTypeId) => mapping[assetTypeId]
921
- )
922
- );
923
- const selectNumberOfAssetTypesMatchingCaseInsensitiveName = restructureCreateSelectorWithArgs(
925
+ const selectAssetTypeById = (id) => (state) => {
926
+ return state.assetTypeReducer.instances[id];
927
+ };
928
+ const selectAssetTypesByIds = restructureCreateSelectorWithArgs(
924
929
  createSelector(
925
- [selectAssetTypesMapping, (_state, args) => args],
926
- (mapping, args) => {
927
- var _a2;
928
- const name = ((_a2 = args.name) == null ? void 0 : _a2.toLowerCase()) ?? null;
929
- return Object.values(mapping).filter(
930
- (assetType) => {
931
- var _a3;
932
- return (((_a3 = assetType.name) == null ? void 0 : _a3.toLowerCase()) ?? null) === name && assetType.offline_id !== args.assetTypeId;
930
+ [selectAssetTypesMapping, (_state, assetTypeIds) => assetTypeIds],
931
+ (assetTypeMapping, assetTypeIds) => {
932
+ const assetTypes = [];
933
+ for (const assetTypeId of assetTypeIds) {
934
+ const assetType = assetTypeMapping[assetTypeId];
935
+ if (assetType) {
936
+ assetTypes.push(assetType);
937
+ } else {
938
+ console.warn("selectAssetTypesByIds: No assetType exists with the id", assetTypeId);
933
939
  }
934
- ).length;
940
+ }
941
+ return assetTypes;
935
942
  }
936
943
  )
937
944
  );
938
- const selectAssetTypesByName = restructureCreateSelectorWithArgs(
939
- createSelector([selectAssetTypesMapping, (_state, name) => name], (mapping, name) => {
940
- name = (name == null ? void 0 : name.toLowerCase()) ?? null;
941
- return Object.values(mapping).filter((assetType) => {
942
- var _a2;
943
- return (((_a2 = assetType.name) == null ? void 0 : _a2.toLowerCase()) ?? null) === name;
944
- });
945
- })
946
- );
947
945
  const assetTypeReducer = assetTypeSlice.reducer;
948
946
  const assetAdapter = createModelAdapter((asset) => asset.offline_id);
949
947
  const initialState$y = assetAdapter.getInitialState({});
@@ -952,42 +950,15 @@ const assetSlice = createSlice({
952
950
  initialState: initialState$y,
953
951
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
954
952
  reducers: {
955
- initializeAssets: (state, action) => {
956
- assetAdapter.initialize(state, action);
957
- prevAssets = null;
958
- },
959
- addAsset: (state, action) => {
960
- assetAdapter.addOne(state, action);
961
- prevAssets = null;
962
- },
963
- addAssets: (state, action) => {
964
- assetAdapter.addMany(state, action);
965
- prevAssets = null;
966
- },
967
- setAsset: (state, action) => {
968
- assetAdapter.setOne(state, action);
969
- prevAssets = null;
970
- },
971
- setAssets: (state, action) => {
972
- assetAdapter.setMany(state, action);
973
- prevAssets = null;
974
- },
975
- updateAsset: (state, action) => {
976
- assetAdapter.updateOne(state, action);
977
- prevAssets = null;
978
- },
979
- updateAssets: (state, action) => {
980
- assetAdapter.updateMany(state, action);
981
- prevAssets = null;
982
- },
983
- deleteAsset: (state, action) => {
984
- assetAdapter.deleteOne(state, action);
985
- prevAssets = null;
986
- },
987
- deleteAssets: (state, action) => {
988
- assetAdapter.deleteMany(state, action);
989
- prevAssets = null;
990
- }
953
+ initializeAssets: assetAdapter.initialize,
954
+ addAsset: assetAdapter.addOne,
955
+ addAssets: assetAdapter.addMany,
956
+ setAsset: assetAdapter.setOne,
957
+ setAssets: assetAdapter.setMany,
958
+ updateAsset: assetAdapter.updateOne,
959
+ updateAssets: assetAdapter.updateMany,
960
+ deleteAsset: assetAdapter.deleteOne,
961
+ deleteAssets: assetAdapter.deleteMany
991
962
  }
992
963
  });
993
964
  const {
@@ -1001,22 +972,29 @@ const {
1001
972
  setAsset,
1002
973
  setAssets
1003
974
  } = assetSlice.actions;
1004
- let prevAssets = null;
1005
- const selectAssets = (state) => {
1006
- if (!prevAssets) {
1007
- prevAssets = Object.values(state.assetReducer.instances);
1008
- }
1009
- return prevAssets;
1010
- };
1011
975
  const selectAssetsMapping = (state) => state.assetReducer.instances;
976
+ const selectAssets = createSelector([selectAssetsMapping], (assetsMapping) => {
977
+ return Object.values(assetsMapping);
978
+ });
1012
979
  const selectAssetsOfAssetType = restructureCreateSelectorWithArgs(
1013
980
  createSelector([selectAssets, (_state, assetTypeId) => assetTypeId], (components, assetTypeId) => {
1014
981
  return components.filter((asset) => asset.asset_type === assetTypeId);
1015
982
  })
1016
983
  );
1017
- const selectAsset = (assetId) => (state) => {
984
+ const selectAssetById = (assetId) => (state) => {
1018
985
  return state.assetReducer.instances[assetId];
1019
986
  };
987
+ const selectAssetsByIds = restructureCreateSelectorWithArgs(
988
+ createSelector([selectAssetsMapping, (_, assetIds) => assetIds], (assetsMapping, assetIds) => {
989
+ const assets = [];
990
+ for (const assetId of assetIds) {
991
+ const asset = assetsMapping[assetId];
992
+ if (asset)
993
+ assets.push(asset);
994
+ }
995
+ return assets;
996
+ })
997
+ );
1020
998
  const selectAssetToAssetTypeMapping = createSelector(
1021
999
  [selectAssets, selectAssetTypesMapping],
1022
1000
  (assets, assetTypeMapping) => {
@@ -1037,19 +1015,7 @@ const selectAssetToAssetTypeMapping = createSelector(
1037
1015
  }
1038
1016
  );
1039
1017
  const selectNumberOfAssetsOfAssetType = (assetTypeId) => (state) => {
1040
- var _a2;
1041
- if (!assetTypeId)
1042
- return 0;
1043
- return (_a2 = selectAssetsOfAssetType(assetTypeId)(state)) == null ? void 0 : _a2.length;
1044
- };
1045
- const selectAssetTypesFromIds = (assetTypeIds) => (state) => {
1046
- return assetTypeIds.reduce((acc, assetTypeId) => {
1047
- const assetType = state.assetTypeReducer.instances[assetTypeId];
1048
- if (assetType) {
1049
- acc.push(assetType);
1050
- }
1051
- return acc;
1052
- }, []);
1018
+ return selectAssetsOfAssetType(assetTypeId)(state).length;
1053
1019
  };
1054
1020
  const assetReducer = assetSlice.reducer;
1055
1021
  const assetAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
@@ -1086,8 +1052,8 @@ const selectAssetAttachments = createSelector(
1086
1052
  [selectAssetAttachmentMapping],
1087
1053
  (mapping) => Object.values(mapping)
1088
1054
  );
1089
- const selectAssetAttachment = (attachmentId) => (state) => {
1090
- return state.assetAttachmentReducer.instances[attachmentId];
1055
+ const selectAssetAttachmentById = (id) => (state) => {
1056
+ return state.assetAttachmentReducer.instances[id];
1091
1057
  };
1092
1058
  const selectAttachmentsOfAsset = restructureCreateSelectorWithArgs(
1093
1059
  createSelector(
@@ -1188,19 +1154,16 @@ const assetStageSlice = createSlice({
1188
1154
  }
1189
1155
  });
1190
1156
  const selectStageMapping = (state) => state.assetStageReducer.instances;
1191
- const selectStage = restructureCreateSelectorWithArgs(
1157
+ const selectAssetStageById = restructureCreateSelectorWithArgs(
1192
1158
  createSelector([selectStageMapping, (_state, stageId) => stageId], (stageMapping, stageId) => {
1193
1159
  return stageMapping[stageId];
1194
1160
  })
1195
1161
  );
1196
- const selectStages = createSelector(
1197
- [selectStageMapping],
1198
- (stageMapping) => {
1199
- return Object.values(stageMapping);
1200
- }
1201
- );
1162
+ const selectAssetStages = createSelector([selectStageMapping], (stageMapping) => {
1163
+ return Object.values(stageMapping);
1164
+ });
1202
1165
  const selectStagesFromAssetTypeIds = restructureCreateSelectorWithArgs(
1203
- createSelector([selectStages, (_state, assetTypeIds) => assetTypeIds], (stages, assetTypeIds) => {
1166
+ createSelector([selectAssetStages, (_state, assetTypeIds) => assetTypeIds], (stages, assetTypeIds) => {
1204
1167
  const assetTypeIdsSet = new Set(assetTypeIds);
1205
1168
  const ret = {};
1206
1169
  for (const stage of stages) {
@@ -1229,13 +1192,22 @@ const selectAssetTypeStagesMapping = restructureCreateSelectorWithArgs(
1229
1192
  })
1230
1193
  );
1231
1194
  const selectStagesOfAssetType = restructureCreateSelectorWithArgs(
1232
- createSelector([selectStages, (_state, assetTypeId) => assetTypeId], (stages, assetTypeId) => {
1195
+ createSelector([selectAssetStages, (_state, assetTypeId) => assetTypeId], (stages, assetTypeId) => {
1233
1196
  return stages.filter((stage) => stage.asset_type === assetTypeId).sort((a, b) => a.priority - b.priority);
1234
1197
  })
1235
1198
  );
1236
- const selectStagesFromStageIds = restructureCreateSelectorWithArgs(
1199
+ const selectAssetStagesByIds = restructureCreateSelectorWithArgs(
1237
1200
  createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
1238
- return stageIds.map((offline_id) => stageMapping[offline_id]).filter((stage) => !!stage);
1201
+ const assetStages = [];
1202
+ for (const stageId of stageIds) {
1203
+ const stage = stageMapping[stageId];
1204
+ if (stage) {
1205
+ assetStages.push(stage);
1206
+ } else {
1207
+ console.warn("selectStagesFromStageIds: No stage exists with the id", stageId);
1208
+ }
1209
+ }
1210
+ return assetStages;
1239
1211
  })
1240
1212
  );
1241
1213
  const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
@@ -1291,8 +1263,8 @@ const selectAssetTypeAttachments = createSelector(
1291
1263
  [selectAssetTypeAttachmentMapping],
1292
1264
  (mapping) => Object.values(mapping)
1293
1265
  );
1294
- const selectAssetTypeAttachment = (attachmentId) => (state) => {
1295
- return state.assetTypeAttachmentReducer.instances[attachmentId];
1266
+ const selectAssetTypeAttachmentById = (id) => (state) => {
1267
+ return state.assetTypeAttachmentReducer.instances[id];
1296
1268
  };
1297
1269
  const selectAttachmentsOfAssetType = restructureCreateSelectorWithArgs(
1298
1270
  createSelector(
@@ -1342,8 +1314,8 @@ const selectMainWorkspace = createSelector(
1342
1314
  return workspaces.find((workspace) => workspace.name.toLowerCase() === "main");
1343
1315
  }
1344
1316
  );
1345
- const selectWorkspaceById = (workspaceId) => (state) => {
1346
- return state.workspaceReducer.instances[workspaceId];
1317
+ const selectWorkspaceById = (id) => (state) => {
1318
+ return state.workspaceReducer.instances[id];
1347
1319
  };
1348
1320
  const selectPermittedWorkspaceIds = createSelector(
1349
1321
  [selectWorkspaceMapping],
@@ -1411,11 +1383,9 @@ const {
1411
1383
  } = issueSlice.actions;
1412
1384
  const selectIssueMapping = (state) => state.issueReducer.instances;
1413
1385
  const selectRecentIssueIds = (state) => state.issueReducer.recentIssueIds;
1414
- const selectIssue = restructureCreateSelectorWithArgs(
1415
- createSelector([selectIssueMapping, (_state, id) => id], (mapping, id) => {
1416
- return mapping[id];
1417
- })
1418
- );
1386
+ const selectIssueById = (id) => (state) => {
1387
+ return state.issueReducer.instances[id];
1388
+ };
1419
1389
  const searchIssues = restructureCreateSelectorWithArgs(
1420
1390
  createSelector(
1421
1391
  [selectIssueMapping, selectWorkspaceMapping, (_state, searchArgs) => searchArgs],
@@ -1471,6 +1441,20 @@ const searchIssues = restructureCreateSelectorWithArgs(
1471
1441
  }
1472
1442
  )
1473
1443
  );
1444
+ const selectIssuesByIds = restructureCreateSelectorWithArgs(
1445
+ createSelector([selectIssueMapping, (_, issueIds) => issueIds], (issuesMapping, issueIds) => {
1446
+ const issues = [];
1447
+ for (const issueId of issueIds) {
1448
+ const issue = issuesMapping[issueId];
1449
+ if (issue) {
1450
+ issues.push(issue);
1451
+ } else {
1452
+ console.warn("selectIssuesByIds: No issue exists with the id", issueId);
1453
+ }
1454
+ }
1455
+ return issues;
1456
+ })
1457
+ );
1474
1458
  const selectRecentIssuesAsSearchResults = createSelector(
1475
1459
  [selectIssueMapping, selectRecentIssueIds, selectWorkspaceMapping],
1476
1460
  (issueMapping, recentIssueIds, workspaceMapping) => {
@@ -1532,14 +1516,21 @@ const selectIssueTypes = createSelector(
1532
1516
  return Object.values(issueTypes);
1533
1517
  }
1534
1518
  );
1535
- const selectIssueType = restructureCreateSelectorWithArgs(
1536
- createSelector(
1537
- [selectIssueTypeMapping, (_, issueTypeId) => issueTypeId],
1538
- (issueTypesMapping, issueTypeId) => {
1539
- return issueTypesMapping[issueTypeId];
1519
+ const selectIssueTypeById = (id) => (state) => {
1520
+ return state.issueTypeReducer.instances[id];
1521
+ };
1522
+ const selectIssueTypesByIds = (issueTypeIds) => (state) => {
1523
+ const issueTypes = [];
1524
+ for (const issueTypeId of issueTypeIds) {
1525
+ const issueType = state.issueTypeReducer.instances[issueTypeId];
1526
+ if (issueType) {
1527
+ issueTypes.push(issueType);
1528
+ } else {
1529
+ console.warn("selectIssueTypesByIds: No issue type exists with the id", issueTypeId);
1540
1530
  }
1541
- )
1542
- );
1531
+ }
1532
+ return issueTypes;
1533
+ };
1543
1534
  const selectIssueTypesOfOrganization = restructureCreateSelectorWithArgs(
1544
1535
  createSelector(
1545
1536
  [selectIssueTypes, (_, organizationId) => organizationId],
@@ -1557,8 +1548,7 @@ const selectIssuesOfIssueType = restructureCreateSelectorWithArgs(
1557
1548
  )
1558
1549
  );
1559
1550
  const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
1560
- var _a2;
1561
- return ((_a2 = selectIssuesOfIssueType(issueTypeId)(state)) == null ? void 0 : _a2.length) ?? 0;
1551
+ return selectIssuesOfIssueType(issueTypeId)(state).length;
1562
1552
  };
1563
1553
  const issueTypeReducer = issueTypeSlice.reducer;
1564
1554
  const initialState$q = {
@@ -1715,21 +1705,27 @@ const {
1715
1705
  setTourStep,
1716
1706
  removeUser
1717
1707
  } = userSlice.actions;
1708
+ const userReducer = userSlice.reducer;
1718
1709
  const selectCurrentUser = (state) => state.userReducer.currentUser;
1719
- const selectUser = (userId) => (state) => {
1720
- if (userId === null)
1721
- return void 0;
1722
- return state.userReducer.users[userId];
1710
+ const selectUsersMapping = (state) => state.userReducer.users;
1711
+ const selectUserById = (id) => (state) => {
1712
+ return state.userReducer.users[id];
1723
1713
  };
1724
- const selectUsersAsMapping = (state) => state.userReducer.users;
1725
1714
  const selectUsersByIds = restructureCreateSelectorWithArgs(
1726
- createSelector([selectUsersAsMapping, (_, ids) => ids], (usersMapping, ids) => {
1727
- const idsSet = new Set(ids);
1728
- return Object.values(usersMapping).filter((user) => idsSet.has(user.id));
1715
+ createSelector([selectUsersMapping, (_state, userIds) => userIds], (usersMapping, userIds) => {
1716
+ const users = [];
1717
+ for (const userId of userIds) {
1718
+ const user = usersMapping[userId];
1719
+ if (user) {
1720
+ users.push(user);
1721
+ } else {
1722
+ console.warn("selectUsersByIds: No user exists with the id", userId);
1723
+ }
1724
+ }
1725
+ return users;
1729
1726
  })
1730
1727
  );
1731
1728
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
1732
- const userReducer = userSlice.reducer;
1733
1729
  const organizationAccessAdapter = createModelAdapter(
1734
1730
  (organizationAccess) => organizationAccess.offline_id
1735
1731
  );
@@ -1748,8 +1744,8 @@ const { initializeOrganizationAccesses, updateOrganizationAccess, deleteOrganiza
1748
1744
  const selectOrganizationAccesses = (state) => {
1749
1745
  return state.organizationAccessReducer.instances;
1750
1746
  };
1751
- const selectOrganizationAccess = (organizationAccessId) => (state) => {
1752
- return state.organizationAccessReducer.instances[organizationAccessId];
1747
+ const selectOrganizationAccessById = (id) => (state) => {
1748
+ return state.organizationAccessReducer.instances[id];
1753
1749
  };
1754
1750
  const selectActiveOrganizationAccess = createSelector(
1755
1751
  [selectCurrentUser, selectOrganizationAccesses],
@@ -1789,10 +1785,7 @@ const { initializeLicences, addLicenses, updateLicense } = licenseSlice.actions;
1789
1785
  const selectLicenses = (state) => {
1790
1786
  return state.licenseReducer.instances;
1791
1787
  };
1792
- const selectLicense = (licenseId) => (state) => state.licenseReducer.instances[licenseId];
1793
- const selectActiveLicense = (state) => Object.values(state.licenseReducer.instances).find(
1794
- (license) => license.project === state.projectReducer.activeProjectId
1795
- ) ?? null;
1788
+ const selectLicense = (id) => (state) => state.licenseReducer.instances[id];
1796
1789
  const selectLicenseForProject = (projectId) => (state) => Object.values(state.licenseReducer.instances).find((license) => license.project === projectId);
1797
1790
  const selectActiveStatusLicenses = createSelector(
1798
1791
  [selectLicenses],
@@ -1826,14 +1819,9 @@ const selectProjectAccesses = createSelector(
1826
1819
  return Object.values(projectAccesses);
1827
1820
  }
1828
1821
  );
1829
- const selectProjectAccess = restructureCreateSelectorWithArgs(
1830
- createSelector(
1831
- [selectProjectAccessMapping, (_state, projectAccessId) => projectAccessId],
1832
- (projectAccesses, projectAccessId) => {
1833
- return projectAccesses[projectAccessId];
1834
- }
1835
- )
1836
- );
1822
+ const selectProjectAccessById = (id) => (state) => {
1823
+ return state.projectAccessReducer.instances[id];
1824
+ };
1837
1825
  const selectActiveProjectAccess = (state) => {
1838
1826
  const currentUser = state.userReducer.currentUser;
1839
1827
  const activeProjectId = state.projectReducer.activeProjectId;
@@ -1926,7 +1914,8 @@ const {
1926
1914
  addActiveProjectIssuesCount,
1927
1915
  addActiveProjectFormSubmissionsCount
1928
1916
  } = projectSlice.actions;
1929
- const selectProjects = (state) => state.projectReducer.projects;
1917
+ const projectReducer = projectSlice.reducer;
1918
+ const selectProjectMapping = (state) => state.projectReducer.projects;
1930
1919
  const selectActiveProjectId = (state) => state.projectReducer.activeProjectId;
1931
1920
  const selectActiveProject = (state) => {
1932
1921
  const activeProjectId = selectActiveProjectId(state);
@@ -1935,23 +1924,19 @@ const selectActiveProject = (state) => {
1935
1924
  }
1936
1925
  return state.projectReducer.projects[activeProjectId] ?? null;
1937
1926
  };
1938
- const selectProject = restructureCreateSelectorWithArgs(
1939
- createSelector(
1940
- [selectProjects, (_state, projectId) => projectId],
1941
- (projects, projectId) => projects[projectId]
1942
- )
1943
- );
1944
- const projectReducer = projectSlice.reducer;
1927
+ const selectProjectById = (id) => (state) => {
1928
+ return state.projectReducer.projects[id];
1929
+ };
1945
1930
  const selectProjectUsersIds = createSelector(
1946
1931
  [selectProjectAccessMapping],
1947
1932
  (projectAccesses) => Object.values(projectAccesses).map((projectAccess) => projectAccess.user)
1948
1933
  );
1949
1934
  const selectProjectUsersAsMapping = createSelector(
1950
- [selectProjectUsersIds, selectUsersAsMapping],
1935
+ [selectProjectUsersIds, selectUsersMapping],
1951
1936
  (projectUserIds, users) => projectUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
1952
1937
  );
1953
1938
  const selectProjectsWithAccess = createSelector(
1954
- [selectProjects],
1939
+ [selectProjectMapping],
1955
1940
  (projects) => Object.values(projects).filter((project) => !project.invited)
1956
1941
  );
1957
1942
  const selectSortedProjectUsers = createSelector(
@@ -1991,27 +1976,30 @@ const organizationSlice = createSlice({
1991
1976
  }
1992
1977
  });
1993
1978
  const { setOrganizations } = organizationSlice.actions;
1994
- const selectOrganizations = (state) => {
1995
- return Object.values(state.organizationReducer.organizations);
1996
- };
1997
1979
  const selectOrganizationsMapping = (state) => {
1998
1980
  return state.organizationReducer.organizations;
1999
1981
  };
1982
+ const selectOrganizations = createSelector([selectOrganizationsMapping], (organizationsMapping) => {
1983
+ return Object.values(organizationsMapping);
1984
+ });
1985
+ const selectOrganizationById = (id) => (state) => {
1986
+ return state.organizationReducer.organizations[id];
1987
+ };
2000
1988
  const selectOrganizationsWithAccess = createSelector(
2001
1989
  [selectOrganizations],
2002
1990
  (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2003
1991
  );
2004
- const selectOrganizationById = (organizationId) => (state) => {
2005
- return state.organizationReducer.organizations[organizationId];
2006
- };
2007
1992
  const selectOrganizationUsersIds = createSelector(
2008
1993
  [selectOrganizationAccesses],
2009
1994
  (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
2010
1995
  );
2011
1996
  const selectProjectsOfOrganization = restructureCreateSelectorWithArgs(
2012
- createSelector([selectProjects, (_, organizationId) => organizationId], (projects, organizationId) => {
2013
- return Object.values(projects).filter((project) => project.organization_owner === organizationId);
2014
- })
1997
+ createSelector(
1998
+ [selectProjectMapping, (_, organizationId) => organizationId],
1999
+ (projects, organizationId) => {
2000
+ return Object.values(projects).filter((project) => project.organization_owner === organizationId);
2001
+ }
2002
+ )
2015
2003
  );
2016
2004
  const selectLicensesOfOrganization = restructureCreateSelectorWithArgs(
2017
2005
  createSelector([selectLicenses, (_, organizationId) => organizationId], (licenses, organizationId) => {
@@ -2019,7 +2007,7 @@ const selectLicensesOfOrganization = restructureCreateSelectorWithArgs(
2019
2007
  })
2020
2008
  );
2021
2009
  const selectOrganizationUsersAsMapping = createSelector(
2022
- [selectOrganizationUsersIds, selectUsersAsMapping],
2010
+ [selectOrganizationUsersIds, selectUsersMapping],
2023
2011
  (organizationUserIds, users) => organizationUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
2024
2012
  );
2025
2013
  const selectSortedOrganizationUsers = createSelector(
@@ -2043,9 +2031,6 @@ const selectSortedOrganizationUsers = createSelector(
2043
2031
  });
2044
2032
  }
2045
2033
  );
2046
- const selectOrganization = (id) => (state) => {
2047
- return state.organizationReducer.organizations[id];
2048
- };
2049
2034
  const organizationReducer = organizationSlice.reducer;
2050
2035
  const createOfflineAction = (request2, baseUrl, serviceName) => {
2051
2036
  const requestWithUuid = request2.uuid ? request2 : { ...request2, uuid: v4() };
@@ -2229,16 +2214,13 @@ const selectAllProjectAttachments = createSelector(
2229
2214
  [selectProjectAttachmentMapping],
2230
2215
  (mapping) => Object.values(mapping)
2231
2216
  );
2232
- const selectProjectAttachment = (attachmentId) => (state) => {
2233
- return state.projectAttachmentReducer.instances[attachmentId];
2217
+ const selectProjectAttachmentById = (id) => (state) => {
2218
+ return state.projectAttachmentReducer.instances[id];
2234
2219
  };
2235
2220
  const selectAttachmentsOfProject = restructureCreateSelectorWithArgs(
2236
- createSelector(
2237
- [selectAllProjectAttachments, (_state, projectId) => projectId],
2238
- (attachments, projectId) => {
2239
- return attachments.filter(({ project }) => projectId === project);
2240
- }
2241
- )
2221
+ createSelector([selectAllProjectAttachments, (_, projectId) => projectId], (attachments, projectId) => {
2222
+ return attachments.filter(({ project }) => projectId === project);
2223
+ })
2242
2224
  );
2243
2225
  const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
2244
2226
  createSelector(
@@ -2274,22 +2256,6 @@ const rehydratedSlice = createSlice({
2274
2256
  const { setRehydrated } = rehydratedSlice.actions;
2275
2257
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
2276
2258
  const rehydratedReducer = rehydratedSlice.reducer;
2277
- const initialState$f = {
2278
- isFetchingInitialData: false
2279
- };
2280
- const settingSlice = createSlice({
2281
- name: "settings",
2282
- initialState: initialState$f,
2283
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2284
- reducers: {
2285
- setIsFetchingInitialData: (state, action) => {
2286
- state.isFetchingInitialData = action.payload;
2287
- }
2288
- }
2289
- });
2290
- const { setIsFetchingInitialData } = settingSlice.actions;
2291
- const settingReducer = settingSlice.reducer;
2292
- const selectIsFetchingInitialData = (state) => state.settingReducer.isFetchingInitialData;
2293
2259
  const formRevisionSortFn = (formRevisionA, formRevisionB) => {
2294
2260
  const revisionA = formRevisionA.revision;
2295
2261
  const revisionB = formRevisionB.revision;
@@ -2304,11 +2270,11 @@ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
2304
2270
  }
2305
2271
  };
2306
2272
  const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
2307
- const initialState$e = formRevisionAdapter.getInitialState({});
2273
+ const initialState$f = formRevisionAdapter.getInitialState({});
2308
2274
  const formRevisionsSlice = createSlice({
2309
2275
  name: "formRevisions",
2310
- initialState: initialState$e,
2311
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2276
+ initialState: initialState$f,
2277
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2312
2278
  reducers: {
2313
2279
  initializeFormRevisions: formRevisionAdapter.initialize,
2314
2280
  setFormRevision: formRevisionAdapter.setOne,
@@ -2331,7 +2297,7 @@ const selectFormRevisions = createSelector(
2331
2297
  [selectFormRevisionMapping],
2332
2298
  (formRevisions) => Object.values(formRevisions)
2333
2299
  );
2334
- const selectFormRevision = (formRevisionId) => (state) => {
2300
+ const selectFormRevisionById = (formRevisionId) => (state) => {
2335
2301
  return state.formRevisionReducer.instances[formRevisionId];
2336
2302
  };
2337
2303
  const _selectLatestFormRevision = (formRevisions, formId) => {
@@ -2369,32 +2335,6 @@ const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
2369
2335
  }
2370
2336
  )
2371
2337
  );
2372
- const selectLatestFormRevisionsOfAssetTypes = restructureCreateSelectorWithArgs(
2373
- createSelector(
2374
- [
2375
- (state) => state.formReducer.instances,
2376
- selectFormRevisionMapping,
2377
- (_state, assetTypeIds) => assetTypeIds
2378
- ],
2379
- (formsMapping, revisions, assetTypeIds) => {
2380
- const assetTypeIdsSet = new Set(assetTypeIds);
2381
- const formsOfAssetTypes = {};
2382
- const ret = {};
2383
- for (const form of Object.values(formsMapping)) {
2384
- if (form.asset_type && assetTypeIdsSet.has(form.asset_type)) {
2385
- formsOfAssetTypes[form.offline_id] = form;
2386
- }
2387
- }
2388
- for (const revision of Object.values(revisions)) {
2389
- const form = formsOfAssetTypes[revision.form];
2390
- if (!form || !form.asset_type || ret[form.asset_type] && formRevisionSortFn(ret[form.asset_type], revision) > 0)
2391
- continue;
2392
- ret[form.asset_type] = revision;
2393
- }
2394
- return ret;
2395
- }
2396
- )
2397
- );
2398
2338
  const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping], (revisions) => {
2399
2339
  const latestRevisions = {};
2400
2340
  for (const revision of Object.values(revisions)) {
@@ -2408,11 +2348,11 @@ const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping
2408
2348
  });
2409
2349
  const formRevisionReducer = formRevisionsSlice.reducer;
2410
2350
  const formAdapter = createModelAdapter((form) => form.offline_id);
2411
- const initialState$d = formAdapter.getInitialState({});
2351
+ const initialState$e = formAdapter.getInitialState({});
2412
2352
  const formSlice = createSlice({
2413
2353
  name: "forms",
2414
- initialState: initialState$d,
2415
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2354
+ initialState: initialState$e,
2355
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2416
2356
  reducers: {
2417
2357
  initializeForms: formAdapter.initialize,
2418
2358
  setForm: formAdapter.setOne,
@@ -2423,9 +2363,13 @@ const formSlice = createSlice({
2423
2363
  }
2424
2364
  });
2425
2365
  const { initializeForms, setForm, addForm, addForms, updateForm, deleteForm } = formSlice.actions;
2426
- const selectFormsMapping = (state) => {
2366
+ const formReducer = formSlice.reducer;
2367
+ const selectFormMapping = (state) => {
2427
2368
  return state.formReducer.instances;
2428
2369
  };
2370
+ const selectForms = createSelector([selectFormMapping], (formsMapping) => {
2371
+ return Object.values(formsMapping);
2372
+ });
2429
2373
  const selectFilteredForms = restructureCreateSelectorWithArgs(
2430
2374
  createSelector(
2431
2375
  [
@@ -2462,12 +2406,9 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
2462
2406
  { memoizeOptions: { equalityCheck: shallowEqual } }
2463
2407
  )
2464
2408
  );
2465
- const selectForm = (formId) => (state) => {
2409
+ const selectFormById = (formId) => (state) => {
2466
2410
  return state.formReducer.instances[formId];
2467
2411
  };
2468
- const selectFormMapping = (state) => {
2469
- return state.formReducer.instances;
2470
- };
2471
2412
  const selectFormOfAssetType = restructureCreateSelectorWithArgs(
2472
2413
  createSelector(
2473
2414
  [selectFormMapping, (_state, assetTypeId) => assetTypeId],
@@ -2490,13 +2431,12 @@ const selectFormsCount = createSelector([selectFormMapping], (formsMapping) => {
2490
2431
  const selectGeneralFormCount = createSelector([selectFormMapping], (formsMapping) => {
2491
2432
  return Object.values(formsMapping).filter((form) => !form.asset_type).length;
2492
2433
  });
2493
- const formReducer = formSlice.reducer;
2494
2434
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2495
- const initialState$c = submissionAdapter.getInitialState({});
2435
+ const initialState$d = submissionAdapter.getInitialState({});
2496
2436
  const formSubmissionSlice = createSlice({
2497
2437
  name: "formSubmissions",
2498
- initialState: initialState$c,
2499
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2438
+ initialState: initialState$d,
2439
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2500
2440
  reducers: {
2501
2441
  initializeFormSubmissions: submissionAdapter.initialize,
2502
2442
  setFormSubmission: submissionAdapter.setOne,
@@ -2529,7 +2469,7 @@ const selectFormSubmissions = createSelector(
2529
2469
  return Object.values(submissions);
2530
2470
  }
2531
2471
  );
2532
- const selectFormSubmission = (submissionId) => (state) => {
2472
+ const selectFormSubmissionById = (submissionId) => (state) => {
2533
2473
  return state.formSubmissionReducer.instances[submissionId];
2534
2474
  };
2535
2475
  const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
@@ -2704,11 +2644,11 @@ const formSubmissionReducer = formSubmissionSlice.reducer;
2704
2644
  const formSubmissionAttachmentAdapter = createModelAdapter(
2705
2645
  (attachment) => attachment.offline_id
2706
2646
  );
2707
- const initialState$b = formSubmissionAttachmentAdapter.getInitialState({});
2647
+ const initialState$c = formSubmissionAttachmentAdapter.getInitialState({});
2708
2648
  const formSubmissionAttachmentSlice = createSlice({
2709
2649
  name: "formSubmissionAttachments",
2710
- initialState: initialState$b,
2711
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2650
+ initialState: initialState$c,
2651
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2712
2652
  reducers: {
2713
2653
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2714
2654
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2735,6 +2675,15 @@ const {
2735
2675
  const selectFormSubmissionAttachmentsMapping = (state) => {
2736
2676
  return state.formSubmissionAttachmentReducer.instances;
2737
2677
  };
2678
+ const selectFormSubmissionAttachemntsByIds = restructureCreateSelectorWithArgs(
2679
+ createSelector(
2680
+ [selectFormSubmissionAttachmentsMapping, (_, attachmentIds) => attachmentIds],
2681
+ (mapping, attachmentIds) => {
2682
+ const attachmentIdsSet = new Set(attachmentIds);
2683
+ return Object.values(mapping).filter((attachment) => attachmentIdsSet.has(attachment.offline_id));
2684
+ }
2685
+ )
2686
+ );
2738
2687
  const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
2739
2688
  createSelector(
2740
2689
  [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
@@ -2747,11 +2696,11 @@ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
2747
2696
  const formRevisionAttachmentAdapter = createModelAdapter(
2748
2697
  (attachment) => attachment.offline_id
2749
2698
  );
2750
- const initialState$a = formRevisionAttachmentAdapter.getInitialState({});
2699
+ const initialState$b = formRevisionAttachmentAdapter.getInitialState({});
2751
2700
  const formRevisionAttachmentSlice = createSlice({
2752
2701
  name: "formRevisionAttachments",
2753
- initialState: initialState$a,
2754
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2702
+ initialState: initialState$b,
2703
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2755
2704
  reducers: {
2756
2705
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2757
2706
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2788,10 +2737,10 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
2788
2737
  );
2789
2738
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2790
2739
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2791
- const initialState$9 = emailDomainAdapter.getInitialState({});
2740
+ const initialState$a = emailDomainAdapter.getInitialState({});
2792
2741
  const emailDomainsSlice = createSlice({
2793
2742
  name: "emailDomains",
2794
- initialState: initialState$9,
2743
+ initialState: initialState$a,
2795
2744
  reducers: {
2796
2745
  initializeEmailDomains: emailDomainAdapter.initialize,
2797
2746
  addEmailDomain: emailDomainAdapter.addOne,
@@ -2800,7 +2749,7 @@ const emailDomainsSlice = createSlice({
2800
2749
  });
2801
2750
  const { initializeEmailDomains, addEmailDomain, deleteEmailDomain } = emailDomainsSlice.actions;
2802
2751
  const selectEmailDomainsAsMapping = (state) => state.emailDomainsReducer.instances;
2803
- const selectEmailDomains = (state) => Object.values(state.emailDomainsReducer.instances);
2752
+ const selectEmailDomains = createSelector([selectEmailDomainsAsMapping], (mapping) => Object.values(mapping));
2804
2753
  const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2805
2754
  createSelector(
2806
2755
  [selectEmailDomains, (_, organizationId) => organizationId],
@@ -2810,14 +2759,14 @@ const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2810
2759
  )
2811
2760
  );
2812
2761
  const emailDomainsReducer = emailDomainsSlice.reducer;
2813
- const initialState$8 = {
2762
+ const initialState$9 = {
2814
2763
  documents: {}
2815
2764
  };
2816
2765
  const documentSlice = createSlice({
2817
2766
  name: "documents",
2818
- initialState: initialState$8,
2767
+ initialState: initialState$9,
2819
2768
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2820
- Object.assign(state, initialState$8);
2769
+ Object.assign(state, initialState$9);
2821
2770
  }),
2822
2771
  reducers: {
2823
2772
  setDocuments: (state, action) => {
@@ -2966,10 +2915,24 @@ const selectDocuments = createSelector(
2966
2915
  [selectDocumentsMapping],
2967
2916
  (mapping) => Object.values(mapping)
2968
2917
  );
2969
- const selectDocument = restructureCreateSelectorWithArgs(
2918
+ const selectDocumentById = (documentId) => (state) => {
2919
+ return state.documentsReducer.documents[documentId];
2920
+ };
2921
+ const selectDocumentsByIds = restructureCreateSelectorWithArgs(
2970
2922
  createSelector(
2971
- [selectDocumentsMapping, (_state, documentId) => documentId],
2972
- (mapping, documentId) => mapping[documentId]
2923
+ [selectDocumentsMapping, (_state, documentIds) => documentIds],
2924
+ (mapping, documentIds) => {
2925
+ const documents = [];
2926
+ for (const documentId of documentIds) {
2927
+ const document2 = mapping[documentId];
2928
+ if (document2) {
2929
+ documents.push(document2);
2930
+ } else {
2931
+ console.warn("selectDocumentByIds: No document exists with the id", documentId);
2932
+ }
2933
+ }
2934
+ return documents;
2935
+ }
2973
2936
  )
2974
2937
  );
2975
2938
  const selectAncestorIdsOfDocument = restructureCreateSelectorWithArgs(
@@ -2992,11 +2955,11 @@ const selectRootDocuments = createSelector(
2992
2955
  );
2993
2956
  const documentsReducer = documentSlice.reducer;
2994
2957
  const documentAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2995
- const initialState$7 = documentAttachmentAdapter.getInitialState({});
2958
+ const initialState$8 = documentAttachmentAdapter.getInitialState({});
2996
2959
  const documentAttachmentSlice = createSlice({
2997
2960
  name: "documentAttachments",
2998
- initialState: initialState$7,
2999
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2961
+ initialState: initialState$8,
2962
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3000
2963
  reducers: {
3001
2964
  initializeDocumentAttachments: documentAttachmentAdapter.initialize,
3002
2965
  addDocumentAttachment: documentAttachmentAdapter.addOne,
@@ -3025,8 +2988,8 @@ const selectAllDocumentAttachments = createSelector(
3025
2988
  [selectDocumentAttachmentMapping],
3026
2989
  (mapping) => Object.values(mapping)
3027
2990
  );
3028
- const selectDocumentAttachment = (attachmentId) => (state) => {
3029
- return state.documentAttachmentReducer.instances[attachmentId];
2991
+ const selectDocumentAttachmentById = (id) => (state) => {
2992
+ return state.documentAttachmentReducer.instances[id];
3030
2993
  };
3031
2994
  const selectAttachmentsOfDocument = restructureCreateSelectorWithArgs(
3032
2995
  createSelector(
@@ -3055,11 +3018,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
3055
3018
  );
3056
3019
  const documentAttachmentReducer = documentAttachmentSlice.reducer;
3057
3020
  const teamAdapter = createModelAdapter((team) => team.offline_id);
3058
- const initialState$6 = teamAdapter.getInitialState({});
3021
+ const initialState$7 = teamAdapter.getInitialState({});
3059
3022
  const teamSlice = createSlice({
3060
3023
  name: "teams",
3061
- initialState: initialState$6,
3062
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3024
+ initialState: initialState$7,
3025
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3063
3026
  reducers: {
3064
3027
  setTeam: teamAdapter.setOne,
3065
3028
  initializeTeams: teamAdapter.initialize,
@@ -3073,8 +3036,8 @@ const selectTeamsMapping = (state) => state.teamReducer.instances;
3073
3036
  const selectTeams = createSelector([selectTeamsMapping], (teams) => {
3074
3037
  return Object.values(teams);
3075
3038
  });
3076
- const selectTeam = (teamId) => (state) => {
3077
- return state.teamReducer.instances[teamId];
3039
+ const selectTeamById = (id) => (state) => {
3040
+ return state.teamReducer.instances[id];
3078
3041
  };
3079
3042
  const selectTeamsOfOrganization = restructureCreateSelectorWithArgs(
3080
3043
  createSelector(
@@ -3093,11 +3056,11 @@ const teamReducer = teamSlice.reducer;
3093
3056
  const agentUserConversationAdapter = createModelAdapter(
3094
3057
  (conversation) => conversation.offline_id
3095
3058
  );
3096
- const initialState$5 = agentUserConversationAdapter.getInitialState({});
3059
+ const initialState$6 = agentUserConversationAdapter.getInitialState({});
3097
3060
  const agentsSlice = createSlice({
3098
3061
  name: "agents",
3099
- initialState: initialState$5,
3100
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3062
+ initialState: initialState$6,
3063
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3101
3064
  reducers: {
3102
3065
  initializeConversations: agentUserConversationAdapter.initialize,
3103
3066
  addConversation: agentUserConversationAdapter.addOne,
@@ -3119,11 +3082,11 @@ const selectConversation = restructureCreateSelectorWithArgs(
3119
3082
  );
3120
3083
  const agentsReducer = agentsSlice.reducer;
3121
3084
  const issueCommentAdapter = createModelAdapter((comment) => comment.offline_id);
3122
- const initialState$4 = issueCommentAdapter.getInitialState({});
3085
+ const initialState$5 = issueCommentAdapter.getInitialState({});
3123
3086
  const issueCommentSlice = createSlice({
3124
3087
  name: "issueComments",
3125
- initialState: initialState$4,
3126
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3088
+ initialState: initialState$5,
3089
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3127
3090
  reducers: {
3128
3091
  addIssueComment: issueCommentAdapter.addOne,
3129
3092
  addIssueComments: issueCommentAdapter.addMany,
@@ -3152,11 +3115,11 @@ const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
3152
3115
  );
3153
3116
  const issueCommentReducer = issueCommentSlice.reducer;
3154
3117
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
3155
- const initialState$3 = issueUpdateAdapter.getInitialState({});
3118
+ const initialState$4 = issueUpdateAdapter.getInitialState({});
3156
3119
  const issueUpdateSlice = createSlice({
3157
3120
  name: "issueUpdates",
3158
- initialState: initialState$3,
3159
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3121
+ initialState: initialState$4,
3122
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3160
3123
  reducers: {
3161
3124
  initializeIssueUpdates: issueUpdateAdapter.setMany,
3162
3125
  setIssueUpdate: issueUpdateAdapter.setOne,
@@ -3185,11 +3148,11 @@ const selectIssueUpdatesOfIssue = restructureCreateSelectorWithArgs(
3185
3148
  );
3186
3149
  const issueUpdateReducer = issueUpdateSlice.reducer;
3187
3150
  const issueAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
3188
- const initialState$2 = issueAttachmentAdapter.getInitialState({});
3151
+ const initialState$3 = issueAttachmentAdapter.getInitialState({});
3189
3152
  const issueAttachmentSlice = createSlice({
3190
3153
  name: "issueAttachments",
3191
- initialState: initialState$2,
3192
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
3154
+ initialState: initialState$3,
3155
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3193
3156
  reducers: {
3194
3157
  initializeIssueAttachments: issueAttachmentAdapter.initialize,
3195
3158
  addIssueAttachment: issueAttachmentAdapter.addOne,
@@ -3226,8 +3189,8 @@ const selectAttachmentsOfIssue = restructureCreateSelectorWithArgs(
3226
3189
  }
3227
3190
  )
3228
3191
  );
3229
- const selectIssueAttachment = (attachmentId) => (root) => {
3230
- return root.issueAttachmentReducer.instances[attachmentId];
3192
+ const selectIssueAttachmentById = (id) => (root) => {
3193
+ return root.issueAttachmentReducer.instances[id];
3231
3194
  };
3232
3195
  const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
3233
3196
  createSelector(
@@ -3247,23 +3210,23 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
3247
3210
  )
3248
3211
  );
3249
3212
  const issueAttachmentReducer = issueAttachmentSlice.reducer;
3250
- const initialState$1 = {
3213
+ const initialState$2 = {
3251
3214
  version: 0
3252
3215
  };
3253
3216
  const versioningSlice = createSlice({
3254
3217
  name: "versioning",
3255
- initialState: initialState$1,
3218
+ initialState: initialState$2,
3256
3219
  reducers: {}
3257
3220
  });
3258
3221
  const versioningReducer = versioningSlice.reducer;
3259
3222
  const geoImageAdapter = createModelAdapter((model) => model.offline_id);
3260
- const initialState = geoImageAdapter.getInitialState({});
3223
+ const initialState$1 = geoImageAdapter.getInitialState({});
3261
3224
  const geoImageSlice = createSlice({
3262
3225
  name: "geoImages",
3263
- initialState,
3226
+ initialState: initialState$1,
3264
3227
  extraReducers: (builder) => {
3265
3228
  builder.addCase("RESET", (state) => {
3266
- Object.assign(state, initialState);
3229
+ Object.assign(state, initialState$1);
3267
3230
  });
3268
3231
  },
3269
3232
  reducers: {
@@ -3300,6 +3263,67 @@ const selectGeoImagesOfProject = restructureCreateSelectorWithArgs(
3300
3263
  })
3301
3264
  );
3302
3265
  const geoImageReducer = geoImageSlice.reducer;
3266
+ const issueAssociationAdapter = createModelAdapter((assoc) => assoc.offline_id);
3267
+ const initialState = issueAssociationAdapter.getInitialState({});
3268
+ const issueAssociationSlice = createSlice({
3269
+ name: "issueAssociations",
3270
+ initialState,
3271
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
3272
+ reducers: {
3273
+ initializeIssueAssociations: issueAssociationAdapter.initialize,
3274
+ addIssueAssociation: issueAssociationAdapter.addOne,
3275
+ addIssueAssociations: issueAssociationAdapter.addMany,
3276
+ setIssueAssociation: issueAssociationAdapter.setOne,
3277
+ setIssueAssociations: issueAssociationAdapter.setMany,
3278
+ updateIssueAssociation: issueAssociationAdapter.updateOne,
3279
+ updateIssueAssociations: issueAssociationAdapter.updateMany,
3280
+ deleteIssueAssociation: issueAssociationAdapter.deleteOne,
3281
+ deleteIssueAssociations: issueAssociationAdapter.deleteMany
3282
+ }
3283
+ });
3284
+ const {
3285
+ initializeIssueAssociations,
3286
+ setIssueAssociations,
3287
+ setIssueAssociation,
3288
+ updateIssueAssociation,
3289
+ updateIssueAssociations,
3290
+ addIssueAssociation,
3291
+ addIssueAssociations,
3292
+ deleteIssueAssociation,
3293
+ deleteIssueAssociations
3294
+ } = issueAssociationSlice.actions;
3295
+ const selectIssueAssociationMapping = (state) => state.issueAssociationReducer.instances;
3296
+ const selectIssueAssociations = createSelector([selectIssueAssociationMapping], (associations) => {
3297
+ return Object.values(associations);
3298
+ });
3299
+ const selectIssueAssociationById = (id) => (state) => {
3300
+ return state.issueAssociationReducer.instances[id];
3301
+ };
3302
+ const selectIssueAssociationsToIssue = restructureCreateSelectorWithArgs(
3303
+ createSelector(
3304
+ [selectIssueAssociationMapping, (_state, issueId) => issueId],
3305
+ (associationMapping, issueId) => {
3306
+ return Object.values(associationMapping).filter((assoc) => assoc.associated_issue === issueId);
3307
+ }
3308
+ )
3309
+ );
3310
+ const selectIssueAssociationsOfIssue = restructureCreateSelectorWithArgs(
3311
+ createSelector(
3312
+ [selectIssueAssociationMapping, (_state, issueId) => issueId],
3313
+ (associationMapping, issueId) => {
3314
+ return Object.values(associationMapping).filter((assoc) => assoc.issue === issueId);
3315
+ }
3316
+ )
3317
+ );
3318
+ const selectIssueAssociationsOfAsset = restructureCreateSelectorWithArgs(
3319
+ createSelector(
3320
+ [selectIssueAssociationMapping, (_state, assetId) => assetId],
3321
+ (associationMapping, assetId) => {
3322
+ return Object.values(associationMapping).filter((assoc) => assoc.asset === assetId);
3323
+ }
3324
+ )
3325
+ );
3326
+ const issueAssociationReducer = issueAssociationSlice.reducer;
3303
3327
  const fullAssetMarkerSize = 45;
3304
3328
  const DEFAULT_ISSUE_STATUS = IssueStatus.BACKLOG;
3305
3329
  const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
@@ -3356,7 +3380,6 @@ const overmapReducers = {
3356
3380
  organizationAccessReducer,
3357
3381
  projectFileReducer,
3358
3382
  rehydratedReducer,
3359
- settingReducer,
3360
3383
  formReducer,
3361
3384
  formRevisionReducer,
3362
3385
  formRevisionAttachmentReducer,
@@ -3372,7 +3395,8 @@ const overmapReducers = {
3372
3395
  agentsReducer,
3373
3396
  issueCommentReducer,
3374
3397
  issueUpdateReducer,
3375
- geoImageReducer
3398
+ geoImageReducer,
3399
+ issueAssociationReducer
3376
3400
  };
3377
3401
  const overmapReducer = combineReducers(overmapReducers);
3378
3402
  const resetStore = "RESET";
@@ -3389,7 +3413,7 @@ function handleWorkspaceRemoval(draft, action) {
3389
3413
  throw new Error("Tried to delete main workspace");
3390
3414
  }
3391
3415
  const categoriesInThisWorkspace = new Set(
3392
- (selectCategoriesOfWorkspace(workspaceId)(draft) ?? []).map((category) => category.offline_id)
3416
+ selectCategoriesOfWorkspace(workspaceId)(draft).map((category) => category.offline_id)
3393
3417
  );
3394
3418
  for (const issue of issuesVisibleInWorkspace) {
3395
3419
  if (issue.category && categoriesInThisWorkspace.has(issue.category)) {
@@ -4163,11 +4187,13 @@ class AssetService extends BaseApiService {
4163
4187
  }
4164
4188
  async remove(assetId) {
4165
4189
  const { store } = this.client;
4166
- const assetToBeDeleted = selectAsset(assetId)(store.getState());
4190
+ const state = store.getState();
4191
+ const assetToBeDeleted = selectAssetById(assetId)(state);
4167
4192
  if (!assetToBeDeleted)
4168
4193
  throw new Error(`No asset with id ${assetId} found in the store`);
4169
- const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(store.getState());
4170
- const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(store.getState());
4194
+ const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(state);
4195
+ const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(state);
4196
+ const issueAssociations = selectIssueAssociationsOfAsset(assetId)(state);
4171
4197
  this.dispatch(deleteAsset(assetId));
4172
4198
  if (attachmentsOfAssets.length > 0) {
4173
4199
  const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
@@ -4177,6 +4203,10 @@ class AssetService extends BaseApiService {
4177
4203
  const formSubmissionsOfAssetIds = formSubmissionsOfAssets.map(({ offline_id }) => offline_id);
4178
4204
  this.dispatch(deleteFormSubmissions(formSubmissionsOfAssetIds));
4179
4205
  }
4206
+ if (issueAssociations.length > 0) {
4207
+ const issueAssociationsIds = issueAssociations.map(({ offline_id }) => offline_id);
4208
+ this.dispatch(deleteIssueAssociations(issueAssociationsIds));
4209
+ }
4180
4210
  return this.enqueueRequest({
4181
4211
  description: "Delete asset",
4182
4212
  method: HttpMethod.DELETE,
@@ -4187,13 +4217,14 @@ class AssetService extends BaseApiService {
4187
4217
  this.dispatch(addAsset(assetToBeDeleted));
4188
4218
  this.dispatch(addAssetAttachments(attachmentsOfAssets));
4189
4219
  this.dispatch(addFormSubmissions(formSubmissionsOfAssets));
4220
+ this.dispatch(addIssueAssociations(issueAssociations));
4190
4221
  throw err;
4191
4222
  });
4192
4223
  }
4193
4224
  async deleteAllAssetsOfAssetType(assetTypeId) {
4194
4225
  const { store } = this.client;
4195
4226
  const state = store.getState();
4196
- const allAssetsOfAssetType = selectAssetsOfAssetType(assetTypeId)(state) ?? [];
4227
+ const allAssetsOfAssetType = selectAssetsOfAssetType(assetTypeId)(state);
4197
4228
  const allAssetsOfAssetTypeIds = allAssetsOfAssetType.map((c) => c.offline_id);
4198
4229
  const affectedOfflineIds = [assetTypeId, ...allAssetsOfAssetTypeIds];
4199
4230
  store.dispatch(deleteAssets(allAssetsOfAssetTypeIds));
@@ -4210,7 +4241,6 @@ class AssetService extends BaseApiService {
4210
4241
  }
4211
4242
  // TODO: payload does not require asset_type
4212
4243
  bulkAdd(assetsToCreate, workspaceId, assetTypeId, batchSize) {
4213
- const { store } = this.client;
4214
4244
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4215
4245
  const transactionId = v4();
4216
4246
  const assetBatches = chunkArray(assetsToCreate, batchSize).map((assetBatch) => {
@@ -4254,7 +4284,7 @@ class AssetService extends BaseApiService {
4254
4284
  }
4255
4285
  void Promise.all(batchPromises).then((result) => {
4256
4286
  const allCreatedAssets = result.flat();
4257
- store.dispatch(addAssets(allCreatedAssets));
4287
+ this.dispatch(addAssets(allCreatedAssets));
4258
4288
  });
4259
4289
  return batchPromises;
4260
4290
  }
@@ -4273,7 +4303,7 @@ class AssetStageCompletionService extends BaseApiService {
4273
4303
  add(assetId, stageId) {
4274
4304
  var _a2;
4275
4305
  const { store } = this.client;
4276
- const assetTypeId = (_a2 = selectAsset(assetId)(store.getState())) == null ? void 0 : _a2.asset_type;
4306
+ const assetTypeId = (_a2 = selectAssetById(assetId)(store.getState())) == null ? void 0 : _a2.asset_type;
4277
4307
  if (!assetTypeId) {
4278
4308
  throw new Error(`Asset with offline_id ${assetId} not found`);
4279
4309
  }
@@ -4379,12 +4409,7 @@ class AssetStageService extends BaseApiService {
4379
4409
  async bulkUpdateStages(stagesToUpdate, assetTypeId) {
4380
4410
  const store = this.client.store;
4381
4411
  const state = store.getState();
4382
- const prevStages = selectStagesFromStageIds(
4383
- stagesToUpdate.map(({ offline_id }) => offline_id)
4384
- )(state);
4385
- if (!prevStages) {
4386
- throw new Error("Could not find the desired stages to update within the store");
4387
- }
4412
+ const prevStages = selectAssetStagesByIds(stagesToUpdate.map(({ offline_id }) => offline_id))(state);
4388
4413
  this.dispatch(updateStages(stagesToUpdate));
4389
4414
  return this.enqueueRequest({
4390
4415
  description: "Edit asset stages",
@@ -4501,8 +4526,9 @@ class BaseUploadService extends BaseApiService {
4501
4526
  return objectsWithSha1.filter((object) => object.file_sha1 === sha1).length;
4502
4527
  }
4503
4528
  processPresignedUrls(presignedUrls) {
4529
+ const promisesBySha1 = {};
4504
4530
  for (const [sha1, presignedUrl] of Object.entries(presignedUrls)) {
4505
- void this.enqueueRequest({
4531
+ promisesBySha1[sha1] = this.enqueueRequest({
4506
4532
  url: presignedUrl.url,
4507
4533
  description: "Upload file to S3",
4508
4534
  method: HttpMethod.POST,
@@ -4515,6 +4541,7 @@ class BaseUploadService extends BaseApiService {
4515
4541
  s3url: presignedUrl
4516
4542
  });
4517
4543
  }
4544
+ return promisesBySha1;
4518
4545
  }
4519
4546
  }
4520
4547
  const AttachmentModelMeta = {
@@ -4634,7 +4661,7 @@ class BaseAttachmentService extends BaseUploadService {
4634
4661
  }
4635
4662
  // Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
4636
4663
  // so for some attachment model services, this method will have to be overridden.
4637
- async refreshStore(projectId) {
4664
+ async refreshStore(projectId, _organizationId) {
4638
4665
  const meta = AttachmentModelMeta[this.attachmentModel];
4639
4666
  const result = await this.enqueueRequest({
4640
4667
  description: `Get ${meta.name} attachments`,
@@ -4656,7 +4683,7 @@ class AssetAttachmentService extends BaseAttachmentService {
4656
4683
  __publicField(this, "removeAttachments", deleteAssetAttachments);
4657
4684
  __publicField(this, "removeAttachment", deleteAssetAttachment);
4658
4685
  __publicField(this, "setAttachment", setAssetAttachment);
4659
- __publicField(this, "selectAttachment", selectAssetAttachment);
4686
+ __publicField(this, "selectAttachment", selectAssetAttachmentById);
4660
4687
  }
4661
4688
  buildOfflineAttachment(data) {
4662
4689
  return offline({
@@ -4680,13 +4707,11 @@ class AssetAttachmentService extends BaseAttachmentService {
4680
4707
  class AssetTypeService extends BaseApiService {
4681
4708
  add(assetType) {
4682
4709
  const offlineAssetType = offline(assetType);
4683
- const { store } = this.client;
4684
- const activeProjectId = store.getState().projectReducer.activeProjectId;
4685
4710
  this.dispatch(addAssetType(offlineAssetType));
4686
4711
  const promise = this.enqueueRequest({
4687
4712
  description: "Create asset type",
4688
4713
  method: HttpMethod.POST,
4689
- url: `/projects/${activeProjectId}/asset-types/`,
4714
+ url: `/projects/${assetType.project}/asset-types/`,
4690
4715
  payload: { ...offlineAssetType },
4691
4716
  blockers: [],
4692
4717
  blocks: [offlineAssetType.offline_id]
@@ -4707,11 +4732,11 @@ class AssetTypeService extends BaseApiService {
4707
4732
  async delete(assetTypeId) {
4708
4733
  const { store } = this.client;
4709
4734
  const state = store.getState();
4710
- const assetType = selectAssetType(assetTypeId)(state);
4735
+ const assetType = selectAssetTypeById(assetTypeId)(state);
4711
4736
  if (!assetType) {
4712
4737
  throw new Error(`Expected asset type with offline_id ${assetTypeId} to exist`);
4713
4738
  }
4714
- const stagesOfAssetType = selectStagesOfAssetType(assetTypeId)(state) ?? [];
4739
+ const stagesOfAssetType = selectStagesOfAssetType(assetTypeId)(state);
4715
4740
  const attachmentsOfAssetType = selectAttachmentsOfAssetType(assetTypeId)(state);
4716
4741
  this.dispatch(deleteAssetType(assetTypeId));
4717
4742
  if (stagesOfAssetType.length > 0) {
@@ -4756,7 +4781,7 @@ class AssetTypeAttachmentService extends BaseAttachmentService {
4756
4781
  __publicField(this, "removeAttachments", deleteAssetTypeAttachments);
4757
4782
  __publicField(this, "removeAttachment", deleteAssetTypeAttachment);
4758
4783
  __publicField(this, "setAttachment", setAssetTypeAttachment);
4759
- __publicField(this, "selectAttachment", selectAssetTypeAttachment);
4784
+ __publicField(this, "selectAttachment", selectAssetTypeAttachmentById);
4760
4785
  }
4761
4786
  buildOfflineAttachment(data) {
4762
4787
  return offline({
@@ -4880,7 +4905,7 @@ class IssueAttachmentService extends BaseAttachmentService {
4880
4905
  __publicField(this, "removeAttachments", deleteIssueAttachments);
4881
4906
  __publicField(this, "removeAttachment", deleteIssueAttachment);
4882
4907
  __publicField(this, "setAttachment", setIssueAttachment);
4883
- __publicField(this, "selectAttachment", selectIssueAttachment);
4908
+ __publicField(this, "selectAttachment", selectIssueAttachmentById);
4884
4909
  }
4885
4910
  buildOfflineAttachment(data) {
4886
4911
  return offline({
@@ -4961,7 +4986,7 @@ class IssueService extends BaseApiService {
4961
4986
  }
4962
4987
  update(issue) {
4963
4988
  const state = this.client.store.getState();
4964
- const issueToBeUpdated = selectIssue(issue.offline_id)(state);
4989
+ const issueToBeUpdated = selectIssueById(issue.offline_id)(state);
4965
4990
  if (!issueToBeUpdated) {
4966
4991
  throw new Error(
4967
4992
  `Attempting to update an issue with offline_id ${issue.offline_id} that doesn't exist in the store`
@@ -5055,13 +5080,19 @@ class IssueService extends BaseApiService {
5055
5080
  async remove(id) {
5056
5081
  const { store } = this.client;
5057
5082
  const state = store.getState();
5058
- const backup = selectIssue(id)(state);
5083
+ const backup = selectIssueById(id)(state);
5059
5084
  if (!backup) {
5060
5085
  throw new Error(`No issue with id ${id} found in the store`);
5061
5086
  }
5062
5087
  const attachmentsOfIssue = selectAttachmentsOfIssue(id)(state);
5063
5088
  const updatesOfIssue = selectIssueUpdatesOfIssue(id)(state);
5064
5089
  const formSubmissionsOfIssue = selectFormSubmissionsOfIssue(id)(state);
5090
+ const issueAssociationsRecord = {};
5091
+ for (const issueAssociation of selectIssueAssociationsToIssue(id)(state))
5092
+ issueAssociationsRecord[issueAssociation.offline_id] = issueAssociation;
5093
+ for (const issueAssociation of selectIssueAssociationsOfIssue(id)(state))
5094
+ issueAssociationsRecord[issueAssociation.offline_id] = issueAssociation;
5095
+ const issueAssociations = Object.values(issueAssociationsRecord);
5065
5096
  this.dispatch(deleteIssue(id));
5066
5097
  this.dispatch(addActiveProjectIssuesCount(-1));
5067
5098
  if (attachmentsOfIssue.length > 0)
@@ -5070,6 +5101,8 @@ class IssueService extends BaseApiService {
5070
5101
  this.dispatch(deleteIssueUpdates(updatesOfIssue.map(({ offline_id }) => offline_id)));
5071
5102
  if (formSubmissionsOfIssue.length > 0)
5072
5103
  this.dispatch(deleteFormSubmissions(formSubmissionsOfIssue.map(({ offline_id }) => offline_id)));
5104
+ if (issueAssociations.length > 0)
5105
+ this.dispatch(deleteIssueAssociations(issueAssociations.map(({ offline_id }) => offline_id)));
5073
5106
  try {
5074
5107
  return await this.enqueueRequest({
5075
5108
  description: "Delete issue",
@@ -5084,6 +5117,7 @@ class IssueService extends BaseApiService {
5084
5117
  this.dispatch(addIssueUpdates(updatesOfIssue));
5085
5118
  this.dispatch(addActiveProjectIssuesCount(1));
5086
5119
  this.dispatch(addFormSubmissions(formSubmissionsOfIssue));
5120
+ this.dispatch(addIssueAssociations(issueAssociations));
5087
5121
  throw e;
5088
5122
  }
5089
5123
  }
@@ -5127,7 +5161,7 @@ class IssueTypeService extends BaseApiService {
5127
5161
  offline_id: offlineIssueType.offline_id,
5128
5162
  submitted_at: offlineIssueType.submitted_at,
5129
5163
  icon: offlineIssueType.icon,
5130
- icon_color: offlineIssueType.icon_color,
5164
+ color: offlineIssueType.color,
5131
5165
  name: offlineIssueType.name,
5132
5166
  description: offlineIssueType.description
5133
5167
  },
@@ -5141,24 +5175,24 @@ class IssueTypeService extends BaseApiService {
5141
5175
  });
5142
5176
  return [offlineIssueType, promise];
5143
5177
  }
5144
- update(issueTypeFields) {
5178
+ update(payload) {
5145
5179
  const { store } = this.client;
5146
5180
  const state = store.getState();
5147
- const issueTypeToBeUpdated = selectIssueType(issueTypeFields.offline_id)(state);
5181
+ const issueTypeToBeUpdated = selectIssueTypeById(payload.offline_id)(state);
5148
5182
  if (!issueTypeToBeUpdated) {
5149
- throw new Error(`IssueType with offline_id ${issueTypeFields.offline_id} does not exist in the store.`);
5183
+ throw new Error(`IssueType with offline_id ${payload.offline_id} does not exist in the store.`);
5150
5184
  }
5151
5185
  const offlineUpdatedIssueType = {
5152
5186
  ...issueTypeToBeUpdated,
5153
- ...issueTypeFields
5187
+ ...payload
5154
5188
  };
5155
5189
  this.dispatch(updateIssueType(offlineUpdatedIssueType));
5156
5190
  const promise = this.enqueueRequest({
5157
5191
  method: HttpMethod.PATCH,
5158
- url: `/issues/types/${issueTypeFields.offline_id}/`,
5159
- payload: issueTypeFields,
5160
- blockers: [issueTypeFields.offline_id],
5161
- blocks: [issueTypeFields.offline_id]
5192
+ url: `/issues/types/${payload.offline_id}/`,
5193
+ payload,
5194
+ blockers: [payload.offline_id],
5195
+ blocks: [payload.offline_id]
5162
5196
  });
5163
5197
  promise.then((updatedIssueType) => {
5164
5198
  this.dispatch(setIssueType(updatedIssueType));
@@ -5170,11 +5204,11 @@ class IssueTypeService extends BaseApiService {
5170
5204
  delete(issueTypeId) {
5171
5205
  const { store } = this.client;
5172
5206
  const state = store.getState();
5173
- const issueTypeToDelete = selectIssueType(issueTypeId)(state);
5207
+ const issueTypeToDelete = selectIssueTypeById(issueTypeId)(state);
5174
5208
  if (!issueTypeToDelete) {
5175
5209
  throw new Error(`IssueType with offline_id ${issueTypeId} does not exist in the store.`);
5176
5210
  }
5177
- const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(state) ?? [];
5211
+ const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(state);
5178
5212
  this.dispatch(removeIssueType(issueTypeId));
5179
5213
  this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
5180
5214
  const promise = this.enqueueRequest({
@@ -5347,7 +5381,7 @@ class ProjectAttachmentService extends BaseAttachmentService {
5347
5381
  __publicField(this, "removeAttachments", deleteProjectAttachments);
5348
5382
  __publicField(this, "removeAttachment", deleteProjectAttachment);
5349
5383
  __publicField(this, "setAttachment", setProjectAttachment);
5350
- __publicField(this, "selectAttachment", selectProjectAttachment);
5384
+ __publicField(this, "selectAttachment", selectProjectAttachmentById);
5351
5385
  }
5352
5386
  buildOfflineAttachment(data) {
5353
5387
  return offline({
@@ -5418,7 +5452,7 @@ class ProjectService extends BaseApiService {
5418
5452
  async delete(projectId) {
5419
5453
  const { store } = this.client;
5420
5454
  const state = store.getState();
5421
- const projects = selectProjects(state);
5455
+ const projects = selectProjectMapping(state);
5422
5456
  const project = projects[projectId];
5423
5457
  if (!project) {
5424
5458
  throw new Error("Expected project to exist");
@@ -5672,10 +5706,6 @@ class FormService extends BaseUploadService {
5672
5706
  const offlineRevision = offline(revision);
5673
5707
  const { store } = this.client;
5674
5708
  const state = store.getState();
5675
- const activeProjectId = state.projectReducer.activeProjectId;
5676
- if (!activeProjectId) {
5677
- throw new Error("Cannot create form revision when there is no active project.");
5678
- }
5679
5709
  const currentUserId = state.userReducer.currentUser.id;
5680
5710
  const { fields, images } = await separateImageFromFields(offlineRevision.fields);
5681
5711
  const fullRevision = {
@@ -5714,10 +5744,9 @@ class FormService extends BaseUploadService {
5714
5744
  });
5715
5745
  return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
5716
5746
  }
5717
- async favorite(formId) {
5747
+ async favorite(formId, projectId) {
5718
5748
  const { store } = this.client;
5719
5749
  const state = store.getState();
5720
- const activeProjectId = state.projectReducer.activeProjectId;
5721
5750
  const form = state.formReducer.instances[formId];
5722
5751
  if (!form) {
5723
5752
  throw new Error(`Expected form to exist, got ${form}`);
@@ -5727,7 +5756,7 @@ class FormService extends BaseUploadService {
5727
5756
  await this.enqueueRequest({
5728
5757
  description: "Favorite form",
5729
5758
  method: HttpMethod.POST,
5730
- url: `/forms/${formId}/favorite/${activeProjectId}/`,
5759
+ url: `/forms/${formId}/favorite/${projectId}/`,
5731
5760
  blockers: [formId, `favorite-${formId}`],
5732
5761
  blocks: [`favorite-${formId}`]
5733
5762
  });
@@ -5736,10 +5765,9 @@ class FormService extends BaseUploadService {
5736
5765
  throw e;
5737
5766
  }
5738
5767
  }
5739
- async unfavorite(formId) {
5768
+ async unfavorite(formId, projectId) {
5740
5769
  const { store } = this.client;
5741
5770
  const state = store.getState();
5742
- const activeProjectId = state.projectReducer.activeProjectId;
5743
5771
  const form = state.formReducer.instances[formId];
5744
5772
  if (!form) {
5745
5773
  throw new Error(`Expected form to exist, got ${form}`);
@@ -5749,7 +5777,7 @@ class FormService extends BaseUploadService {
5749
5777
  return await this.enqueueRequest({
5750
5778
  description: "Unfavorite form",
5751
5779
  method: HttpMethod.DELETE,
5752
- url: `/forms/${formId}/unfavorite/${activeProjectId}/`,
5780
+ url: `/forms/${formId}/unfavorite/${projectId}/`,
5753
5781
  blockers: [formId, `favorite-${formId}`],
5754
5782
  blocks: [`favorite-${formId}`]
5755
5783
  });
@@ -5761,16 +5789,16 @@ class FormService extends BaseUploadService {
5761
5789
  async delete(formId) {
5762
5790
  const { store } = this.client;
5763
5791
  const state = store.getState();
5764
- const form = selectForm(formId)(state);
5792
+ const form = selectFormById(formId)(state);
5765
5793
  if (!form) {
5766
5794
  throw new Error("Expected form to exist");
5767
5795
  }
5768
5796
  const formSubmissions = selectFormSubmissionsOfForm(formId)(state);
5769
- if (formSubmissions && formSubmissions.length > 0) {
5797
+ if (formSubmissions.length > 0) {
5770
5798
  this.dispatch(deleteFormSubmissions(formSubmissions.map(({ offline_id }) => offline_id)));
5771
5799
  }
5772
5800
  const formRevisions = selectFormRevisionsOfForm(formId)(state);
5773
- if (formRevisions && formRevisions.length > 0) {
5801
+ if (formRevisions.length > 0) {
5774
5802
  this.dispatch(deleteFormRevisions(formRevisions.map(({ offline_id }) => offline_id)));
5775
5803
  }
5776
5804
  this.dispatch(deleteForm(formId));
@@ -5784,10 +5812,10 @@ class FormService extends BaseUploadService {
5784
5812
  });
5785
5813
  } catch (e) {
5786
5814
  this.dispatch(addForm(form));
5787
- if (formRevisions && formRevisions.length > 0) {
5815
+ if (formRevisions.length > 0) {
5788
5816
  this.dispatch(addFormRevisions(formRevisions));
5789
5817
  }
5790
- if (formSubmissions && formSubmissions.length > 0) {
5818
+ if (formSubmissions.length > 0) {
5791
5819
  this.dispatch(addFormSubmissions(formSubmissions));
5792
5820
  }
5793
5821
  throw e;
@@ -5938,14 +5966,29 @@ class FormSubmissionService extends BaseUploadService {
5938
5966
  });
5939
5967
  return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
5940
5968
  }
5969
+ async bulkDeleteSubmissionAttachments(submissionId, attachmentsIds) {
5970
+ const { store } = this.client;
5971
+ const state = store.getState();
5972
+ const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
5973
+ this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
5974
+ try {
5975
+ await this.enqueueRequest({
5976
+ description: "Delete form submission attachments",
5977
+ method: HttpMethod.DELETE,
5978
+ url: `/forms/submissions/${submissionId}/attachments/bulk/`,
5979
+ payload: { attachments: attachmentsIds },
5980
+ blockers: [submissionId, ...attachmentsIds],
5981
+ blocks: []
5982
+ });
5983
+ } catch (e) {
5984
+ this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
5985
+ throw e;
5986
+ }
5987
+ }
5941
5988
  // Outer promise is for hashing and caching files for submission attachments
5942
5989
  async add(payload) {
5943
5990
  const { store } = this.client;
5944
5991
  const state = store.getState();
5945
- const activeProjectId = state.projectReducer.activeProjectId;
5946
- if (!activeProjectId) {
5947
- throw new Error("Expected an active project");
5948
- }
5949
5992
  const { values, files } = separateFilesFromValues(payload.values);
5950
5993
  const offlineSubmission = offline({
5951
5994
  ...payload,
@@ -5957,7 +6000,7 @@ class FormSubmissionService extends BaseUploadService {
5957
6000
  description: "Respond to form",
5958
6001
  method: HttpMethod.POST,
5959
6002
  url: `/forms/revisions/${payload.form_revision}/respond/`,
5960
- payload: { ...offlineSubmission, project: activeProjectId },
6003
+ payload: offlineSubmission,
5961
6004
  blockers: [payload.issue, payload.asset, payload.asset_stage, "add-form-entry"].filter(
5962
6005
  (x) => x !== void 0
5963
6006
  ),
@@ -6077,10 +6120,64 @@ class FormSubmissionService extends BaseUploadService {
6077
6120
  });
6078
6121
  return batchPromises;
6079
6122
  }
6123
+ async update(payload) {
6124
+ const { store } = this.client;
6125
+ const state = store.getState();
6126
+ const submissionToBeUpdated = selectFormSubmissionById(payload.offline_id)(state);
6127
+ if (!submissionToBeUpdated) {
6128
+ throw new Error(`Expected submission with offline_id ${payload.offline_id} to exist`);
6129
+ }
6130
+ const { values, files } = separateFilesFromValues(payload.values ?? {});
6131
+ const updatedSubmission = {
6132
+ ...submissionToBeUpdated,
6133
+ ...payload,
6134
+ // values could also have a partial update
6135
+ values: {
6136
+ ...submissionToBeUpdated.values,
6137
+ ...values
6138
+ }
6139
+ };
6140
+ this.dispatch(updateFormSubmission(updatedSubmission));
6141
+ const promise = this.enqueueRequest({
6142
+ description: "Delete user form submissions",
6143
+ method: HttpMethod.PATCH,
6144
+ url: `/forms/submissions/${updatedSubmission.offline_id}/`,
6145
+ payload: updatedSubmission,
6146
+ blockers: [updatedSubmission.offline_id],
6147
+ blocks: [updatedSubmission.offline_id]
6148
+ });
6149
+ const formSubmissionAttachments = selectAttachmentsOfFormSubmission(payload.offline_id)(state);
6150
+ const formSubmissionAttachmentIdsToBeDeleted = [];
6151
+ for (const attachment of formSubmissionAttachments) {
6152
+ if (attachment.field_identifier in files) {
6153
+ formSubmissionAttachmentIdsToBeDeleted.push(attachment.offline_id);
6154
+ }
6155
+ }
6156
+ const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
6157
+ payload.offline_id,
6158
+ files
6159
+ );
6160
+ const deleteAttachmentsPromise = this.bulkDeleteSubmissionAttachments(
6161
+ payload.offline_id,
6162
+ formSubmissionAttachmentIdsToBeDeleted
6163
+ );
6164
+ promise.then((result) => {
6165
+ this.dispatch(setFormSubmission(result));
6166
+ }).catch(() => {
6167
+ this.dispatch(setFormSubmission(submissionToBeUpdated));
6168
+ });
6169
+ return [
6170
+ updatedSubmission,
6171
+ offlineFormSubmissionAttachments,
6172
+ promise,
6173
+ attachmentsPromise,
6174
+ deleteAttachmentsPromise
6175
+ ];
6176
+ }
6080
6177
  async delete(submissionId) {
6081
6178
  const { store } = this.client;
6082
6179
  const state = store.getState();
6083
- const submissionToBeDeleted = selectFormSubmission(submissionId)(store.getState());
6180
+ const submissionToBeDeleted = selectFormSubmissionById(submissionId)(state);
6084
6181
  if (!submissionToBeDeleted) {
6085
6182
  throw new Error(`Expected submission with offline_id ${submissionId} to exist`);
6086
6183
  }
@@ -6124,13 +6221,12 @@ class FormSubmissionService extends BaseUploadService {
6124
6221
  }
6125
6222
  class WorkspaceService extends BaseApiService {
6126
6223
  add(workspace) {
6127
- const { store } = this.client;
6128
6224
  const offlineWorkspace = offline(workspace);
6129
6225
  this.dispatch(addWorkspace(offlineWorkspace));
6130
6226
  const promise = this.enqueueRequest({
6131
6227
  description: "Create Workspace",
6132
6228
  method: HttpMethod.POST,
6133
- url: `/projects/${store.getState().projectReducer.activeProjectId}/workspaces/`,
6229
+ url: `/projects/${workspace.project}/workspaces/`,
6134
6230
  payload: offlineWorkspace,
6135
6231
  blockers: ["add-workspace"],
6136
6232
  blocks: [offlineWorkspace.offline_id]
@@ -6665,27 +6761,20 @@ class LicenseService extends BaseApiService {
6665
6761
  }
6666
6762
  }
6667
6763
  class DocumentService extends BaseApiService {
6668
- // TODO: Support adding for project or organization
6669
- add(document2) {
6764
+ add(payload) {
6670
6765
  const { store } = this.client;
6671
6766
  const currentUserId = store.getState().userReducer.currentUser.id;
6672
- const activeProjectId = store.getState().projectReducer.activeProjectId;
6673
- if (!activeProjectId) {
6674
- throw new Error("No active project ID while creating document.");
6675
- }
6676
- const offlineDocument = offline(document2);
6677
- const submittedDocument = {
6678
- ...offlineDocument,
6767
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6768
+ const offlineDocument = offline({
6769
+ ...payload,
6679
6770
  created_by: currentUserId,
6680
- project: activeProjectId,
6681
- organization: null,
6682
- children_documents: []
6683
- };
6684
- this.dispatch(addDocuments([submittedDocument]));
6771
+ submitted_at: submittedAt
6772
+ });
6773
+ this.dispatch(addDocuments([offlineDocument]));
6685
6774
  const promise = this.enqueueRequest({
6686
6775
  description: "Create Document",
6687
6776
  method: HttpMethod.POST,
6688
- url: `/projects/${activeProjectId}/documents/`,
6777
+ url: "/documents/",
6689
6778
  payload: offlineDocument,
6690
6779
  queryParams: {
6691
6780
  parent_document: offlineDocument.parent_document ?? void 0
@@ -6697,7 +6786,7 @@ class DocumentService extends BaseApiService {
6697
6786
  promise.catch(() => {
6698
6787
  this.dispatch(removeDocuments([offlineDocument.offline_id]));
6699
6788
  });
6700
- return [submittedDocument, promise];
6789
+ return [offlineDocument, promise];
6701
6790
  }
6702
6791
  update(document2) {
6703
6792
  const { store } = this.client;
@@ -6824,7 +6913,7 @@ class DocumentAttachmentService extends BaseAttachmentService {
6824
6913
  __publicField(this, "removeAttachments", deleteDocumentAttachments);
6825
6914
  __publicField(this, "removeAttachment", deleteDocumentAttachment);
6826
6915
  __publicField(this, "setAttachment", setDocumentAttachment);
6827
- __publicField(this, "selectAttachment", selectDocumentAttachment);
6916
+ __publicField(this, "selectAttachment", selectDocumentAttachmentById);
6828
6917
  }
6829
6918
  buildOfflineAttachment(data) {
6830
6919
  return offline({
@@ -6838,12 +6927,107 @@ class DocumentAttachmentService extends BaseAttachmentService {
6838
6927
  document: data.modelId
6839
6928
  });
6840
6929
  }
6930
+ // NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
6841
6931
  async attachFilesToDocument(files, documentId) {
6842
- return this.attachFiles(files, documentId, this.buildOfflineAttachment.bind(this));
6932
+ const { store } = this.client;
6933
+ const currentUser = store.getState().userReducer.currentUser;
6934
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6935
+ const offlineAttachments = [];
6936
+ const attachmentPayloads = [];
6937
+ const filePayloads = {};
6938
+ const sha1ToAttachmentIds = {};
6939
+ for (const file of files) {
6940
+ const sha1 = await hashFile(file);
6941
+ if (!(sha1 in filePayloads)) {
6942
+ filePayloads[sha1] = {
6943
+ sha1,
6944
+ file_type: file.type,
6945
+ extension: file.name.split(".").pop(),
6946
+ size: file.size
6947
+ };
6948
+ sha1ToAttachmentIds[sha1] = [];
6949
+ await this.client.files.addCache(file, sha1);
6950
+ }
6951
+ const offlineAttachment = this.buildOfflineAttachment({
6952
+ file,
6953
+ sha1,
6954
+ submittedAt,
6955
+ createdBy: currentUser.id,
6956
+ description: "",
6957
+ modelId: documentId
6958
+ });
6959
+ offlineAttachments.push(offlineAttachment);
6960
+ attachmentPayloads.push({
6961
+ offline_id: offlineAttachment.offline_id,
6962
+ name: offlineAttachment.file_name,
6963
+ sha1: offlineAttachment.file_sha1,
6964
+ description: offlineAttachment.description
6965
+ });
6966
+ sha1ToAttachmentIds[sha1].push(offlineAttachment.offline_id);
6967
+ }
6968
+ this.dispatch(this.addAttachments(offlineAttachments));
6969
+ const promise = this.enqueueRequest({
6970
+ description: "Attach files to document",
6971
+ method: HttpMethod.POST,
6972
+ url: `/documents/${documentId}/attach/`,
6973
+ payload: {
6974
+ submitted_at: submittedAt,
6975
+ attachments: attachmentPayloads,
6976
+ files: Object.values(filePayloads)
6977
+ },
6978
+ blocks: offlineAttachments.map((attachment) => attachment.offline_id),
6979
+ blockers: offlineAttachments.map((attachment) => attachment.file_sha1)
6980
+ });
6981
+ promise.then(({ attachments, presigned_urls }) => {
6982
+ this.dispatch(this.updateAttachments(attachments));
6983
+ const promisesBySha1 = this.processPresignedUrls(presigned_urls);
6984
+ for (const [sha1, promise2] of Object.entries(promisesBySha1)) {
6985
+ void promise2.then(() => {
6986
+ const attachmentIds = sha1ToAttachmentIds[sha1];
6987
+ for (const attachmentId of attachmentIds) {
6988
+ this.makeReadable(attachmentId);
6989
+ }
6990
+ });
6991
+ }
6992
+ }).catch(() => {
6993
+ this.dispatch(this.removeAttachments(offlineAttachments.map((attachment) => attachment.offline_id)));
6994
+ });
6995
+ return [offlineAttachments, promise.then(({ attachments }) => attachments)];
6843
6996
  }
6844
6997
  async deleteDocumentAttachment(attachmentId) {
6845
6998
  return this.deleteAttachment(attachmentId);
6846
6999
  }
7000
+ makeReadable(attachmnentId) {
7001
+ void this.enqueueRequest({
7002
+ description: "Add attachment to AI assistant",
7003
+ method: HttpMethod.PATCH,
7004
+ url: `/document-attachments/${attachmnentId}/`,
7005
+ payload: {
7006
+ readable_to_assistant: true
7007
+ },
7008
+ // passing through "index-document-attachment" so at most one document attachment being indexed at a time
7009
+ blockers: ["index-document-attachment", attachmnentId],
7010
+ blocks: ["index-document-attachment"]
7011
+ });
7012
+ }
7013
+ async refreshStore(projectId, organizationId) {
7014
+ const projectDocumentAttachments = await this.enqueueRequest({
7015
+ description: "Get document attachments",
7016
+ method: HttpMethod.GET,
7017
+ url: `/projects/${projectId}/document-attachments/`,
7018
+ blocks: [],
7019
+ blockers: []
7020
+ });
7021
+ this.dispatch(this.initializeAttachments(projectDocumentAttachments));
7022
+ const organizationDocumentAttachments = await this.enqueueRequest({
7023
+ description: "Get document attachments",
7024
+ method: HttpMethod.GET,
7025
+ url: `/organizations/${organizationId}/document-attachments/`,
7026
+ blocks: [],
7027
+ blockers: []
7028
+ });
7029
+ this.dispatch(this.addAttachments(organizationDocumentAttachments));
7030
+ }
6847
7031
  }
6848
7032
  class AgentService extends BaseApiService {
6849
7033
  async startConversation(prompt) {
@@ -6959,7 +7143,7 @@ class TeamService extends BaseApiService {
6959
7143
  // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
6960
7144
  update(team) {
6961
7145
  const { store } = this.client;
6962
- const teamToBeUpdated = selectTeam(team.offline_id)(store.getState());
7146
+ const teamToBeUpdated = selectTeamById(team.offline_id)(store.getState());
6963
7147
  if (!teamToBeUpdated) {
6964
7148
  throw new Error(`Expected team with offline_id ${team.offline_id} to exist`);
6965
7149
  }
@@ -6986,7 +7170,7 @@ class TeamService extends BaseApiService {
6986
7170
  async delete(teamId) {
6987
7171
  const { store } = this.client;
6988
7172
  const state = store.getState();
6989
- const team = selectTeam(teamId)(state);
7173
+ const team = selectTeamById(teamId)(state);
6990
7174
  if (!team) {
6991
7175
  throw new Error(`Expected team with id ${teamId} to exist`);
6992
7176
  }
@@ -7006,7 +7190,7 @@ class TeamService extends BaseApiService {
7006
7190
  }
7007
7191
  async setMembers(teamId, members) {
7008
7192
  const { store } = this.client;
7009
- const team = selectTeam(teamId)(store.getState());
7193
+ const team = selectTeamById(teamId)(store.getState());
7010
7194
  if (!team) {
7011
7195
  throw new Error(`Expected team with id ${teamId} to exist`);
7012
7196
  }
@@ -7031,7 +7215,7 @@ class TeamService extends BaseApiService {
7031
7215
  }
7032
7216
  async addMembers(teamId, members) {
7033
7217
  const { store } = this.client;
7034
- const team = selectTeam(teamId)(store.getState());
7218
+ const team = selectTeamById(teamId)(store.getState());
7035
7219
  if (!team) {
7036
7220
  throw new Error(`Expected team with id ${teamId} to exist`);
7037
7221
  }
@@ -7040,7 +7224,7 @@ class TeamService extends BaseApiService {
7040
7224
  }
7041
7225
  async removeMembers(teamId, members) {
7042
7226
  const { store } = this.client;
7043
- const team = selectTeam(teamId)(store.getState());
7227
+ const team = selectTeamById(teamId)(store.getState());
7044
7228
  if (!team) {
7045
7229
  throw new Error(`Expected team with id ${teamId} to exist`);
7046
7230
  }
@@ -7257,6 +7441,72 @@ class GeoImageService extends BaseUploadService {
7257
7441
  store.dispatch(initializeGeoImages(result));
7258
7442
  }
7259
7443
  }
7444
+ class IssueAssociationService extends BaseUploadService {
7445
+ add(payload) {
7446
+ const { store } = this.client;
7447
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7448
+ const createdBy = store.getState().userReducer.currentUser.id;
7449
+ const offlineIssueAssociation = offline({
7450
+ ...payload,
7451
+ submitted_at: submittedAt,
7452
+ created_by: createdBy
7453
+ });
7454
+ this.dispatch(addIssueAssociation(offlineIssueAssociation));
7455
+ const promise = this.enqueueRequest({
7456
+ description: "Add issue association",
7457
+ method: HttpMethod.POST,
7458
+ url: "/issues/associations/",
7459
+ payload: {
7460
+ offline_id: offlineIssueAssociation.offline_id,
7461
+ submitted_at: submittedAt,
7462
+ created_by: createdBy,
7463
+ ...payload
7464
+ },
7465
+ blockers: [
7466
+ payload.associated_issue,
7467
+ ...payload.issue ? [payload.issue] : [],
7468
+ ...payload.asset ? [payload.asset] : []
7469
+ ],
7470
+ blocks: [offlineIssueAssociation.offline_id]
7471
+ });
7472
+ promise.then((issueAssociation) => {
7473
+ this.dispatch(updateIssueAssociation(issueAssociation));
7474
+ }).catch(() => {
7475
+ this.dispatch(deleteIssueAssociation(offlineIssueAssociation.offline_id));
7476
+ });
7477
+ return [offlineIssueAssociation, promise];
7478
+ }
7479
+ async delete(id) {
7480
+ const { store } = this.client;
7481
+ const issueAssociation = selectIssueAssociationById(id)(store.getState());
7482
+ if (!issueAssociation) {
7483
+ throw new Error(`Issue association with id ${id} not found in store.`);
7484
+ }
7485
+ this.dispatch(deleteIssueAssociation(id));
7486
+ const promise = this.enqueueRequest({
7487
+ description: "Delete issue association",
7488
+ method: HttpMethod.DELETE,
7489
+ url: `/issues/associations/${id}/`,
7490
+ blockers: [id],
7491
+ blocks: []
7492
+ });
7493
+ promise.catch(() => {
7494
+ this.dispatch(addIssueAssociation(issueAssociation));
7495
+ });
7496
+ return promise;
7497
+ }
7498
+ async refreshStore(projectId) {
7499
+ const issueAssociations = await this.enqueueRequest({
7500
+ description: "Fetch issue associations",
7501
+ method: HttpMethod.GET,
7502
+ url: "/issues/associations/",
7503
+ queryParams: { project_id: projectId.toString() },
7504
+ blockers: [],
7505
+ blocks: []
7506
+ });
7507
+ this.dispatch(initializeIssueAssociations(issueAssociations));
7508
+ }
7509
+ }
7260
7510
  export {
7261
7511
  APIError,
7262
7512
  AgentService,
@@ -7285,6 +7535,7 @@ export {
7285
7535
  GREEN,
7286
7536
  GeoImageService,
7287
7537
  HttpMethod,
7538
+ IssueAssociationService,
7288
7539
  IssueAttachmentService,
7289
7540
  IssueCommentService,
7290
7541
  IssuePriority,
@@ -7346,6 +7597,8 @@ export {
7346
7597
  addGeoImage,
7347
7598
  addGeoImages,
7348
7599
  addIssue,
7600
+ addIssueAssociation,
7601
+ addIssueAssociations,
7349
7602
  addIssueAttachment,
7350
7603
  addIssueAttachments,
7351
7604
  addIssueComment,
@@ -7423,6 +7676,8 @@ export {
7423
7676
  deleteGeoImage,
7424
7677
  deleteGeoImages,
7425
7678
  deleteIssue,
7679
+ deleteIssueAssociation,
7680
+ deleteIssueAssociations,
7426
7681
  deleteIssueAttachment,
7427
7682
  deleteIssueAttachments,
7428
7683
  deleteIssueComment,
@@ -7495,6 +7750,7 @@ export {
7495
7750
  initializeFormSubmissions,
7496
7751
  initializeForms,
7497
7752
  initializeGeoImages,
7753
+ initializeIssueAssociations,
7498
7754
  initializeIssueAttachments,
7499
7755
  initializeIssueTypes,
7500
7756
  initializeIssueUpdates,
@@ -7507,6 +7763,8 @@ export {
7507
7763
  initializeTeams,
7508
7764
  initializeWorkspaces,
7509
7765
  isToday,
7766
+ issueAssociationReducer,
7767
+ issueAssociationSlice,
7510
7768
  issueAttachmentReducer,
7511
7769
  issueAttachmentSlice,
7512
7770
  issueCommentReducer,
@@ -7569,7 +7827,6 @@ export {
7569
7827
  saveActiveProjectFileBounds,
7570
7828
  searchIssues,
7571
7829
  selectAccessToken,
7572
- selectActiveLicense,
7573
7830
  selectActiveOrganizationAccess,
7574
7831
  selectActiveProject,
7575
7832
  selectActiveProjectAccess,
@@ -7579,21 +7836,24 @@ export {
7579
7836
  selectAllDocumentAttachments,
7580
7837
  selectAllProjectAttachments,
7581
7838
  selectAncestorIdsOfDocument,
7582
- selectAsset,
7583
- selectAssetAttachment,
7839
+ selectAssetAttachmentById,
7584
7840
  selectAssetAttachmentMapping,
7585
7841
  selectAssetAttachments,
7842
+ selectAssetById,
7843
+ selectAssetStageById,
7844
+ selectAssetStages,
7845
+ selectAssetStagesByIds,
7586
7846
  selectAssetToAssetTypeMapping,
7587
- selectAssetType,
7588
- selectAssetTypeAttachment,
7847
+ selectAssetTypeAttachmentById,
7589
7848
  selectAssetTypeAttachmentMapping,
7590
7849
  selectAssetTypeAttachments,
7850
+ selectAssetTypeById,
7591
7851
  selectAssetTypeStagesMapping,
7592
7852
  selectAssetTypes,
7593
- selectAssetTypesByName,
7594
- selectAssetTypesFromIds,
7853
+ selectAssetTypesByIds,
7595
7854
  selectAssetTypesMapping,
7596
7855
  selectAssets,
7856
+ selectAssetsByIds,
7597
7857
  selectAssetsMapping,
7598
7858
  selectAssetsOfAssetType,
7599
7859
  selectAttachedFormSubmissionsOfAsset,
@@ -7623,27 +7883,29 @@ export {
7623
7883
  selectConversations,
7624
7884
  selectCurrentUser,
7625
7885
  selectDeletedRequests,
7626
- selectDocument,
7627
- selectDocumentAttachment,
7886
+ selectDocumentAttachmentById,
7628
7887
  selectDocumentAttachmentMapping,
7888
+ selectDocumentById,
7629
7889
  selectDocuments,
7890
+ selectDocumentsByIds,
7630
7891
  selectDocumentsMapping,
7631
7892
  selectEmailDomains,
7632
7893
  selectEmailDomainsAsMapping,
7633
7894
  selectEmailDomainsOfOrganization,
7634
7895
  selectFavouriteProjects,
7635
7896
  selectFilteredForms,
7636
- selectForm,
7897
+ selectFormById,
7637
7898
  selectFormMapping,
7638
7899
  selectFormOfAssetType,
7639
7900
  selectFormOfIssueType,
7640
- selectFormRevision,
7641
7901
  selectFormRevisionAttachmentsMapping,
7902
+ selectFormRevisionById,
7642
7903
  selectFormRevisionMapping,
7643
7904
  selectFormRevisions,
7644
7905
  selectFormRevisionsOfForm,
7645
- selectFormSubmission,
7906
+ selectFormSubmissionAttachemntsByIds,
7646
7907
  selectFormSubmissionAttachmentsMapping,
7908
+ selectFormSubmissionById,
7647
7909
  selectFormSubmissions,
7648
7910
  selectFormSubmissionsByAssets,
7649
7911
  selectFormSubmissionsByFormRevisions,
@@ -7652,34 +7914,40 @@ export {
7652
7914
  selectFormSubmissionsOfAsset,
7653
7915
  selectFormSubmissionsOfForm,
7654
7916
  selectFormSubmissionsOfIssue,
7917
+ selectForms,
7655
7918
  selectFormsCount,
7656
- selectFormsMapping,
7657
7919
  selectGeneralFormCount,
7658
7920
  selectGeoImageById,
7659
7921
  selectGeoImageMapping,
7660
7922
  selectGeoImages,
7661
7923
  selectGeoImagesOfProject,
7662
- selectIsFetchingInitialData,
7663
7924
  selectIsImportingProjectFile,
7664
7925
  selectIsLoggedIn,
7665
- selectIssue,
7666
- selectIssueAttachment,
7926
+ selectIssueAssociationById,
7927
+ selectIssueAssociationMapping,
7928
+ selectIssueAssociations,
7929
+ selectIssueAssociationsOfAsset,
7930
+ selectIssueAssociationsOfIssue,
7931
+ selectIssueAssociationsToIssue,
7932
+ selectIssueAttachmentById,
7667
7933
  selectIssueAttachmentMapping,
7668
7934
  selectIssueAttachments,
7935
+ selectIssueById,
7669
7936
  selectIssueCommentMapping,
7670
7937
  selectIssueCountOfCategory,
7671
7938
  selectIssueMapping,
7672
- selectIssueType,
7939
+ selectIssueTypeById,
7673
7940
  selectIssueTypeMapping,
7674
7941
  selectIssueTypes,
7942
+ selectIssueTypesByIds,
7675
7943
  selectIssueTypesOfOrganization,
7676
7944
  selectIssueUpdateMapping,
7677
7945
  selectIssueUpdatesOfIssue,
7946
+ selectIssuesByIds,
7678
7947
  selectIssuesOfIssueType,
7679
7948
  selectIssuesOfIssueTypeCount,
7680
7949
  selectLatestFormRevisionByForm,
7681
7950
  selectLatestFormRevisionOfForm,
7682
- selectLatestFormRevisionsOfAssetTypes,
7683
7951
  selectLatestRetryTime,
7684
7952
  selectLicense,
7685
7953
  selectLicenseForProject,
@@ -7687,10 +7955,8 @@ export {
7687
7955
  selectLicensesForProjectsMapping,
7688
7956
  selectLicensesOfOrganization,
7689
7957
  selectMainWorkspace,
7690
- selectNumberOfAssetTypesMatchingCaseInsensitiveName,
7691
7958
  selectNumberOfAssetsOfAssetType,
7692
- selectOrganization,
7693
- selectOrganizationAccess,
7959
+ selectOrganizationAccessById,
7694
7960
  selectOrganizationAccessForUser,
7695
7961
  selectOrganizationAccessUserMapping,
7696
7962
  selectOrganizationAccesses,
@@ -7701,20 +7967,20 @@ export {
7701
7967
  selectOrganizationsMapping,
7702
7968
  selectOrganizationsWithAccess,
7703
7969
  selectPermittedWorkspaceIds,
7704
- selectProject,
7705
- selectProjectAccess,
7970
+ selectProjectAccessById,
7706
7971
  selectProjectAccessForUser,
7707
7972
  selectProjectAccessMapping,
7708
7973
  selectProjectAccessUserMapping,
7709
7974
  selectProjectAccesses,
7710
- selectProjectAttachment,
7975
+ selectProjectAttachmentById,
7711
7976
  selectProjectAttachmentMapping,
7977
+ selectProjectById,
7712
7978
  selectProjectFileById,
7713
7979
  selectProjectFileMapping,
7714
7980
  selectProjectFiles,
7981
+ selectProjectMapping,
7715
7982
  selectProjectUsersAsMapping,
7716
7983
  selectProjectUsersIds,
7717
- selectProjects,
7718
7984
  selectProjectsOfOrganization,
7719
7985
  selectProjectsWithAccess,
7720
7986
  selectRecentIssueIds,
@@ -7724,22 +7990,19 @@ export {
7724
7990
  selectSortedFormSubmissionsOfForm,
7725
7991
  selectSortedOrganizationUsers,
7726
7992
  selectSortedProjectUsers,
7727
- selectStage,
7728
7993
  selectStageFormIdsFromStageIds,
7729
7994
  selectStageMapping,
7730
- selectStages,
7731
7995
  selectStagesFromAssetTypeIds,
7732
- selectStagesFromStageIds,
7733
7996
  selectStagesOfAssetType,
7734
- selectTeam,
7997
+ selectTeamById,
7735
7998
  selectTeams,
7736
7999
  selectTeamsMapping,
7737
8000
  selectTeamsOfOrganization,
7738
8001
  selectTeamsOfUser,
7739
8002
  selectUploadUrl,
7740
- selectUser,
7741
- selectUsersAsMapping,
8003
+ selectUserById,
7742
8004
  selectUsersByIds,
8005
+ selectUsersMapping,
7743
8006
  selectWorkspaceById,
7744
8007
  selectWorkspaceMapping,
7745
8008
  selectWorkspaces,
@@ -7766,8 +8029,9 @@ export {
7766
8029
  setFormSubmissions,
7767
8030
  setGeoImage,
7768
8031
  setGeoImages,
7769
- setIsFetchingInitialData,
7770
8032
  setIsImportingProjectFile,
8033
+ setIssueAssociation,
8034
+ setIssueAssociations,
7771
8035
  setIssueAttachment,
7772
8036
  setIssueAttachments,
7773
8037
  setIssueComment,
@@ -7789,8 +8053,6 @@ export {
7789
8053
  setUploadUrl,
7790
8054
  setUsers,
7791
8055
  setWorkspaces,
7792
- settingReducer,
7793
- settingSlice,
7794
8056
  shallowEqual,
7795
8057
  slugify,
7796
8058
  spacesToDashesLower,
@@ -7821,6 +8083,8 @@ export {
7821
8083
  updateGeoImage,
7822
8084
  updateGeoImages,
7823
8085
  updateIssue,
8086
+ updateIssueAssociation,
8087
+ updateIssueAssociations,
7824
8088
  updateIssueAttachment,
7825
8089
  updateIssueAttachments,
7826
8090
  updateIssueType,